From 867081bf85eaeaa3122b5f0add4fd9c7f8a22815 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Thu, 12 Nov 2026 03:00:01 +0800 Subject: [PATCH 01/13] Replace SPARQL.js with Traqula (#429) --- .../writer/function/ParseQuery.java | 99 ++- src/main/js/sparql/index.js | 53 ++ src/main/js/sparql/package-lock.json | 561 +++++++++++++++ src/main/js/sparql/package.json | 17 + src/main/js/sparql/test/traqula.test.js | 48 ++ .../com/atomgraph/linkeddatahub/js/SPARQL.js | 1 - .../js/traqula-chevrotain.LICENSE.txt | 202 ++++++ .../linkeddatahub/js/traqula.LICENSE.txt | 22 + .../atomgraph/linkeddatahub/js/traqula.min.js | 122 ++++ .../atomgraph/linkeddatahub/xsl/client.xsl | 6 +- .../linkeddatahub/xsl/client/block/view.xsl | 12 +- .../linkeddatahub/xsl/client/constructor.xsl | 4 +- .../linkeddatahub/xsl/client/form.xsl | 6 +- .../linkeddatahub/xsl/client/functions.xsl | 98 +-- .../linkeddatahub/xsl/client/map.xsl | 2 +- .../linkeddatahub/xsl/client/modal.xsl | 4 +- .../linkeddatahub/xsl/client/navigation.xsl | 4 +- .../xsl/client/query-transforms.xsl | 646 +++++++++++------- .../linkeddatahub/xsl/imports/default.xsl | 124 ++-- .../atomgraph/linkeddatahub/xsl/layout.xsl | 8 +- .../writer/function/ParseQueryTest.java | 57 ++ 21 files changed, 1696 insertions(+), 400 deletions(-) create mode 100644 src/main/js/sparql/index.js create mode 100644 src/main/js/sparql/package-lock.json create mode 100644 src/main/js/sparql/package.json create mode 100644 src/main/js/sparql/test/traqula.test.js delete mode 100644 src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js create mode 100644 src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt create mode 100644 src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt create mode 100644 src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js create mode 100644 src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java diff --git a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java index 47f67434b4..04d20db6c5 100644 --- a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java +++ b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java @@ -37,28 +37,13 @@ import org.apache.jena.sparql.syntax.ElementGroup; /** - * Server-side counterpart of the browser's SPARQL.js 2.x Parser, backing the Saxon - * declaration of the ldh:parse-query stylesheet function so that - * ldh:construct-instance runs identically on both products. + * Server-side counterpart of the browser's Traqula Parser, backing the Saxon + * declaration of the ldh:parse-query stylesheet function for + * ldh:construct-instance. *

- * This is deliberately NOT a full SPARQL.js replacement: it emits only the subset of the parse - * tree that the stylesheets consume — a template array of triple maps and a - * where array whose non-emptiness marks a query that cannot be instantiated as a pure - * template (SPARQL.js puts the actual parsed patterns there; only the emptiness test is shared). - * Term strings follow the SPARQL.js 2.x serialization expected by - * ldh:triples-to-descriptions: bare URIs (no angle brackets), _:label - * blank nodes, ?name variables, and "lex" / - * "lex"@lang / "lex"^^datatypeURI literals with the datatype URI - * unwrapped — a 2.x quirk that the stylesheet regexes depend on. Divergences from SPARQL.js: - * blank node labels are Jena's parser-allocated ones, not the source labels (downstream only needs - * per-query consistency — ldh:instance-term prefixes them per constructor); variables - * are normalized to the ? sigil (SPARQL.js preserves $, and the - * stylesheets accept both); plain literals are emitted without ^^xsd:string to match - * SPARQL.js 2.x, although Jena types them as such per RDF 1.1. - *

- * If SPARQL.js is ever upgraded to 3.x (see the TO-DO in ldh:triples-to-descriptions), - * this function, ldh:triples-to-descriptions and ldh:construct-instance - * must change in lockstep. + * The stylesheet consumes the Traqula query and pattern keys, including typed RDF terms. The + * server only needs the construct template and whether the WHERE group is empty; it does not + * manufacture a second parser AST for query patterns. * * @author {@literal Martynas Jusevičius } */ @@ -93,27 +78,40 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException { Query query = QueryFactory.create(arguments[0].itemAt(0).getStringValue()); JsonObject json = new JsonObject(); - JsonArray template = new JsonArray(); - JsonArray where = new JsonArray(); + JsonObject template = new JsonObject(); + JsonArray triples = new JsonArray(); + JsonObject where = new JsonObject(); + JsonArray patterns = new JsonArray(); if (query.isConstructType()) for (Triple triple : query.getConstructTemplate().getBGP().getList()) { JsonObject map = new JsonObject(); + map.put("type", "triple"); map.put("subject", term(triple.getSubject())); map.put("predicate", term(triple.getPredicate())); map.put("object", term(triple.getObject())); - template.add(map); + map.put("loc", loc()); + triples.add(map); } - else - where.add(new JsonObject()); // not a CONSTRUCT: mark as non-instantiable Element pattern = query.getQueryPattern(); if (pattern != null && !(pattern instanceof ElementGroup && ((ElementGroup)pattern).isEmpty())) - where.add(new JsonObject()); + patterns.add(new JsonObject()); // only emptiness is consumed by construct-instance + template.put("type", "pattern"); + template.put("subType", "bgp"); + template.put("triples", triples); + template.put("loc", loc()); + where.put("type", "pattern"); + where.put("subType", "group"); + where.put("patterns", patterns); + where.put("loc", loc()); + json.put("type", "query"); + json.put("subType", query.isConstructType() ? "construct" : query.isDescribeType() ? "describe" : query.isAskType() ? "ask" : "select"); json.put("template", template); json.put("where", where); + json.put("loc", loc()); return new XdmAtomicValue(json.toString()); } catch (QueryParseException ex) @@ -122,18 +120,49 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException } } - private String term(Node node) + private JsonObject term(Node node) { - if (node.isVariable()) return "?" + node.getName(); - if (node.isBlank()) return "_:" + node.getBlankNodeLabel(); + JsonObject term = new JsonObject(); + term.put("type", "term"); + if (node.isVariable()) + { + term.put("subType", "variable"); + term.put("value", node.getName()); + } + else if (node.isBlank()) + { + term.put("subType", "blankNode"); + term.put("value", node.getBlankNodeLabel()); + } if (node.isLiteral()) { - String lex = "\"" + node.getLiteralLexicalForm() + "\""; - if (!node.getLiteralLanguage().isEmpty()) return lex + "@" + node.getLiteralLanguage(); - if (node.getLiteralDatatypeURI() != null && !node.getLiteralDatatypeURI().equals(XSDDatatype.XSDstring.getURI())) return lex + "^^" + node.getLiteralDatatypeURI(); - return lex; + term.put("subType", "literal"); + term.put("value", node.getLiteralLexicalForm()); + if (!node.getLiteralLanguage().isEmpty()) term.put("langOrIri", node.getLiteralLanguage()); + else if (node.getLiteralDatatypeURI() != null && !node.getLiteralDatatypeURI().equals(XSDDatatype.XSDstring.getURI())) + { + JsonObject datatype = new JsonObject(); + datatype.put("type", "term"); + datatype.put("subType", "namedNode"); + datatype.put("value", node.getLiteralDatatypeURI()); + datatype.put("loc", loc()); + term.put("langOrIri", datatype); + } } - return node.getURI(); + else if (node.isURI()) + { + term.put("subType", "namedNode"); + term.put("value", node.getURI()); + } + term.put("loc", loc()); + return term; + } + + private JsonObject loc() + { + JsonObject loc = new JsonObject(); + loc.put("sourceLocationType", "autoGenerate"); + return loc; } } diff --git a/src/main/js/sparql/index.js b/src/main/js/sparql/index.js new file mode 100644 index 0000000000..94660b25d2 --- /dev/null +++ b/src/main/js/sparql/index.js @@ -0,0 +1,53 @@ +import { Parser as TraqulaParser } from '@traqula/parser-sparql-1-1'; +import { Generator as TraqulaGenerator } from '@traqula/generator-sparql-1-1'; + +function expandPrefixes(node, inheritedPrefixes = new Map()) { + if (Array.isArray(node)) { + node.forEach((value) => expandPrefixes(value, inheritedPrefixes)); + return node; + } + if (!node || typeof node !== 'object') return node; + + const prefixes = new Map(inheritedPrefixes); + if (Array.isArray(node.context)) { + for (const definition of node.context) { + if (definition.subType === 'prefix' && definition.key && definition.value?.value) { + prefixes.set(definition.key, definition.value.value); + } + } + } + + if (node.type === 'term' && node.subType === 'namedNode' && node.prefix) { + const namespace = prefixes.get(node.prefix); + if (!namespace) throw new Error(`Undefined SPARQL prefix: ${node.prefix}`); + node.value = namespace + node.value; + delete node.prefix; + } + + for (const value of Object.values(node)) expandPrefixes(value, prefixes); + return node; +} + +export class Parser { + constructor(options) { + this.parser = new TraqulaParser(options); + } + + parse(query) { + return expandPrefixes(this.parser.parse(query)); + } +} + +export class Generator { + constructor(options) { + this.generator = new TraqulaGenerator(options); + } + + generate(ast, options) { + return this.generator.generate(ast, options); + } +} + +if (typeof window !== 'undefined') { + window.LDH_SPARQL = { Parser, Generator }; +} diff --git a/src/main/js/sparql/package-lock.json b/src/main/js/sparql/package-lock.json new file mode 100644 index 0000000000..77f7bc4b14 --- /dev/null +++ b/src/main/js/sparql/package-lock.json @@ -0,0 +1,561 @@ +{ + "name": "ldh-traqula-browser", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ldh-traqula-browser", + "dependencies": { + "@traqula/generator-sparql-1-1": "1.5.0-alpha.7", + "@traqula/parser-sparql-1-1": "1.5.0-alpha.7" + }, + "devDependencies": { + "esbuild": "0.25.10" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", + "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", + "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", + "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", + "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", + "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", + "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", + "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", + "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", + "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", + "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", + "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", + "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", + "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", + "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", + "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", + "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", + "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", + "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", + "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", + "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", + "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", + "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.10.tgz", + "integrity": "sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", + "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", + "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", + "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@traqula/chevrotain": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@traqula/chevrotain/-/chevrotain-1.1.0.tgz", + "integrity": "sha512-VpcoQKb2ZnsOQPlPO2mE9hfR0Aidp7drwTCtaXfpdRHGkXeQ5Nv4rnxmxwUoEDRzu6b/3z4n8oTd+sYhe4fAaA==", + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/core": { + "version": "1.5.0-alpha.5", + "resolved": "https://registry.npmjs.org/@traqula/core/-/core-1.5.0-alpha.5.tgz", + "integrity": "sha512-5KqvutRWXnasccXzVA3GAnmDuBwQ8Gn+JctaIWx/jyTf3may2EahjhtfJxNxvn/R61i/95OEqWKP6Ozo8e/J0A==", + "license": "MIT", + "dependencies": { + "@traqula/chevrotain": "^1.1.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/generator-sparql-1-1": { + "version": "1.5.0-alpha.7", + "resolved": "https://registry.npmjs.org/@traqula/generator-sparql-1-1/-/generator-sparql-1-1-1.5.0-alpha.7.tgz", + "integrity": "sha512-t23EUganH812/eeDz8DddqTVkVThjB0YGpWPP9GlvhTxlxqXhgCp5HXpA8bx1EJgWO+GFed/PQAI8D+ABL2dFw==", + "license": "MIT", + "dependencies": { + "@traqula/core": "^1.5.0-alpha.5", + "@traqula/rules-sparql-1-1": "^1.5.0-alpha.6" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/parser-sparql-1-1": { + "version": "1.5.0-alpha.7", + "resolved": "https://registry.npmjs.org/@traqula/parser-sparql-1-1/-/parser-sparql-1-1-1.5.0-alpha.7.tgz", + "integrity": "sha512-b5sKuoyeE6whbXaq7/REl5PVMZFLoG5wOvMunmkUstcS7KP9Q1Su4RMIRvk3lt78qa3NmFfsfP3o++ZgDCdoyQ==", + "license": "MIT", + "dependencies": { + "@traqula/core": "^1.5.0-alpha.5", + "@traqula/rules-sparql-1-1": "^1.5.0-alpha.6" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@traqula/rules-sparql-1-1": { + "version": "1.5.0-alpha.6", + "resolved": "https://registry.npmjs.org/@traqula/rules-sparql-1-1/-/rules-sparql-1-1-1.5.0-alpha.6.tgz", + "integrity": "sha512-ZgJbh2Bk1xXk6KcajoISNCaYdOKuBmis+T4ZvqVmjAhzJCohdJDDtvzBAWKlc8cDJWKLiYAwmFyLnS1GLrPAcA==", + "license": "MIT", + "dependencies": { + "@traqula/chevrotain": "^1.1.0", + "@traqula/core": "^1.5.0-alpha.5" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/esbuild": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", + "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.10", + "@esbuild/android-arm": "0.25.10", + "@esbuild/android-arm64": "0.25.10", + "@esbuild/android-x64": "0.25.10", + "@esbuild/darwin-arm64": "0.25.10", + "@esbuild/darwin-x64": "0.25.10", + "@esbuild/freebsd-arm64": "0.25.10", + "@esbuild/freebsd-x64": "0.25.10", + "@esbuild/linux-arm": "0.25.10", + "@esbuild/linux-arm64": "0.25.10", + "@esbuild/linux-ia32": "0.25.10", + "@esbuild/linux-loong64": "0.25.10", + "@esbuild/linux-mips64el": "0.25.10", + "@esbuild/linux-ppc64": "0.25.10", + "@esbuild/linux-riscv64": "0.25.10", + "@esbuild/linux-s390x": "0.25.10", + "@esbuild/linux-x64": "0.25.10", + "@esbuild/netbsd-arm64": "0.25.10", + "@esbuild/netbsd-x64": "0.25.10", + "@esbuild/openbsd-arm64": "0.25.10", + "@esbuild/openbsd-x64": "0.25.10", + "@esbuild/openharmony-arm64": "0.25.10", + "@esbuild/sunos-x64": "0.25.10", + "@esbuild/win32-arm64": "0.25.10", + "@esbuild/win32-ia32": "0.25.10", + "@esbuild/win32-x64": "0.25.10" + } + } + } +} diff --git a/src/main/js/sparql/package.json b/src/main/js/sparql/package.json new file mode 100644 index 0000000000..8031fe4f24 --- /dev/null +++ b/src/main/js/sparql/package.json @@ -0,0 +1,17 @@ +{ + "name": "ldh-traqula-browser", + "type": "module", + "private": true, + "description": "Traqula SPARQL 1.1 parser and generator bundle for LinkedDataHub", + "scripts": { + "build": "esbuild index.js --bundle --minify --format=iife --legal-comments=none --outfile=../../webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js", + "test": "node --test" + }, + "dependencies": { + "@traqula/generator-sparql-1-1": "1.5.0-alpha.7", + "@traqula/parser-sparql-1-1": "1.5.0-alpha.7" + }, + "devDependencies": { + "esbuild": "0.25.10" + } +} diff --git a/src/main/js/sparql/test/traqula.test.js b/src/main/js/sparql/test/traqula.test.js new file mode 100644 index 0000000000..ef52511f75 --- /dev/null +++ b/src/main/js/sparql/test/traqula.test.js @@ -0,0 +1,48 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { Generator, Parser } from '../index.js'; + +test('parses and generates SELECT queries with the Traqula AST', () => { + const query = 'PREFIX ex: SELECT ?s WHERE { ?s ex:p ?o OPTIONAL { ?s ex:q ?v } FILTER(?o > 2) VALUES ?v { ex:a ex:b } } ORDER BY DESC(?s) LIMIT 5 OFFSET 2'; + const ast = new Parser().parse(query); + + assert.equal(ast.type, 'query'); + assert.equal(ast.subType, 'select'); + assert.equal(ast.variables[0].type, 'term'); + assert.equal(ast.variables[0].subType, 'variable'); + assert.equal(ast.where.subType, 'group'); + assert.equal(ast.where.patterns[0].triples[0].predicate.value, 'https://example.com/p'); + assert.equal('prefix' in ast.where.patterns[0].triples[0].predicate, false); + assert.ok(ast.context.some((item) => item.subType === 'prefix' && item.key === 'ex')); + + const generated = new Generator().generate(ast); + const reparsed = new Parser().parse(generated); + assert.equal(reparsed.subType, 'select'); + assert.equal(reparsed.where.patterns.length, 4); + assert.equal(reparsed.solutionModifiers.limitOffset.limit, 5); + assert.equal(reparsed.solutionModifiers.limitOffset.offset, 2); + assert.equal(reparsed.solutionModifiers.order.orderDefs[0].descending, true); +}); + +test('preserves typed CONSTRUCT template terms and named graph IRIs', () => { + const ast = new Parser().parse('CONSTRUCT { ?s ?o } WHERE { GRAPH { ?s ?p ?o } }'); + const triple = ast.template.triples[0]; + + assert.equal(ast.subType, 'construct'); + assert.equal(triple.subject.subType, 'variable'); + assert.equal(triple.predicate.subType, 'namedNode'); + assert.equal(triple.predicate.value, 'https://example.com/p'); + assert.equal(ast.where.patterns[0].subType, 'graph'); + assert.match(new Generator().generate(ast), /CONSTRUCT/); +}); + +test('preserves language and datatype terms in SPARQL updates', () => { + const ast = new Parser().parse('INSERT DATA { "hello"@en, "7"^^ }'); + const triples = ast.updates[0].operation.data[0].triples; + + assert.equal(ast.type, 'update'); + assert.equal(triples[0].object.subType, 'literal'); + assert.equal(triples[0].object.langOrIri, 'en'); + assert.equal(triples[1].object.langOrIri.value, 'http://www.w3.org/2001/XMLSchema#integer'); + assert.match(new Generator().generate(ast), /INSERT DATA/); +}); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js deleted file mode 100644 index 067e6db3c4..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/SPARQL.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={734:(e,t,r)=>{var i=r(192).Parser,s=r(55);e.exports={Parser:function(e,t){var r={};for(var s in e||{})r[s]=e[s];var n=new i;return n.parse=function(){return i.base=t||"",i.prefixes=Object.create(r),i.prototype.parse.apply(n,arguments)},n._resetBlanks=i._resetBlanks,n},Generator:s}},55:e=>{function t(e,t){this._options=e=e||{},t=t||{},this._prefixByIri={};var r=[];for(var i in t){var s=t[i];n(s)&&(this._prefixByIri[s]=i,r.push(s))}var a=r.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+a+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._indent=n(e.indent)?e.indent:" ",this._newline=n(e.newline)?e.newline:"\n"}t.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=a(e.variables,void 0,(function(e){return n(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+e.variable+")"}),this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=a(e.from.default||[],"",(function(e){return"FROM "+this.toEntity(e)+this._newline}),this)+a(e.from.named||[],"",(function(e){return"FROM NAMED "+this.toEntity(e)+this._newline}),this)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=a(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+a(e.group,void 0,(function(e){var t=n(e.expression)?e.expression:"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+e.variable+")":t}),this)+this._newline),e.having&&(t+="HAVING ("+a(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+a(e.order,void 0,(function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t}),this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},t.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",r="";for(var i in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[i])&&(r+="PREFIX "+i+": <"+e.prefixes[i]+">"+this._newline);return t+r},t.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},t.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},t.prototype.array=function(e){return a(e,this._newline,this.toPattern,this)},t.prototype.bgp=function(e){return this.encodeTriples(e.triples)},t.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],r="",i="",s=0;s":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(n(r[0])?this.toEntity(r[0]):"("+this.toExpression(r[0])+")")+" "+t+" "+(n(r[1])?this.toEntity(r[1]):"("+this.toExpression(r[1])+")");case"!":return"!("+this.toExpression(r[0])+")";case"notin":t="NOT IN";case"in":return this.toExpression(r[0])+" "+t+"("+(n(r[1])?r[1]:a(r[1],", ",this.toExpression,this))+")";case"notexists":t="NOT EXISTS";case"exists":return t+" "+this.group(r[0],!0);default:return t+"("+a(r,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},t.prototype.toEntity=function(e){if(n(e))switch(e[0]){case"?":case"$":case"*":case"_":return e;case'"':var t=e.match(/^"([^]*)"(?:(@.+)|\^\^(.+))?$/)||{},s=t[1]||"",a=t[2]||"",u=t[3];if(e='"'+s.replace(r,i)+'"'+a,u){if("http://www.w3.org/2001/XMLSchema#integer"===u&&/^\d+$/.test(s))return s+" ";e+="^^"+this.encodeIRI(u)}return e;default:return this.encodeIRI(e)}else{var o=e.items.map(this.toEntity,this),c=e.pathType;switch(c){case"^":case"!":return c+o[0];case"*":case"+":case"?":return"("+o[0]+c+")";default:return"("+o.join(c)+")"}}};var r=/["\\\t\n\r\b\f]/g,i=function(e){return s[e]},s={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function n(e){return"string"==typeof e}function a(e,t,r,i){return e.map(r,i).join(n(t)?t:" ")}t.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var r=this._prefixByIri[t[1]];return this._usedPrefixes[r]=!0,r+":"+t[2]}return"<"+e+">"},t.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+(e.source.default?" DEFAULT ":" ")+"TO "+this.toEntity(e.destination.name);case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},t.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},e.exports=function(e){return{stringify:function(r){return new t(e,r.prefixes).toQuery(r)}}}},192:(e,t,r)=>{e=r.nmd(e);var i=function(){var e=function(e,t,r,i){for(r=r||{},i=e.length;i--;r[e[i]]=t);return r},t=[6,12,15,24,34,43,48,99,109,112,114,115,124,125,130,298,299,300,301,302],r=[2,196],i=[99,109,112,114,115,124,125,130,298,299,300,301,302],s=[1,18],n=[1,27],a=[6,83],u=[38,39,51],o=[38,51],c=[1,55],p=[1,57],h=[1,53],l=[1,56],F=[28,29,293],E=[13,16,286],y=[111,133,296,303],f=[13,16,111,133,286],_=[1,80],D=[1,84],A=[1,86],g=[111,133,296,297,303],b=[13,16,111,133,286,297],T=[1,92],d=[2,236],C=[1,91],I=[13,16,28,29,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],S=[6,38,39,51,61,68,71,79,81,83],N=[6,13,16,28,38,39,51,61,68,71,79,81,83,286],k=[6,13,16,28,29,31,32,38,39,41,51,61,68,71,79,80,81,83,86,92,108,111,124,125,127,132,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,306,307,309,310,311,312,313,314,315,316],R=[1,107],m=[1,108],L=[6,13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],O=[2,295],$=[1,125],x=[1,123],P=[6,183],v=[2,312],U=[2,300],w=[38,127],G=[6,41,68,71,79,81,83],B=[2,238],M=[1,139],V=[1,141],j=[1,151],H=[1,157],Q=[1,160],z=[1,156],Z=[1,158],Y=[1,154],W=[1,155],X=[1,161],q=[1,162],K=[1,165],J=[1,166],ee=[1,167],te=[1,168],re=[1,169],ie=[1,170],se=[1,171],ne=[1,172],ae=[1,173],ue=[1,174],oe=[1,175],ce=[1,176],pe=[6,61,68,71,79,81,83],he=[28,29,38,39,51],le=[13,16,28,29,80,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,316,317,318,319,320,321],Fe=[2,409],Ee=[1,189],ye=[1,190],fe=[1,191],_e=[13,16,41,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],De=[41,86],Ae=[28,32],ge=[6,108,183],be=[41,111],Te=[6,41,71,79,81,83],de=[2,324],Ce=[2,316],Ie=[1,226],Se=[1,228],Ne=[41,111,304],ke=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,187,208,213,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],Re=[13,16,28,29,31,32,39,41,80,83,86,92,111,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316],me=[13,16,28,29,31,32,39,41,80,83,86,92,111,159,160,162,165,166,183,187,208,213,215,216,218,219,223,227,231,246,251,268,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316],Le=[31,32,183,223,251],Oe=[31,32,183,223,227,251],$e=[31,32,183,223,227,231,246,251,268,280,281,282,283,284,285,310,311,312,313,314,315,316],xe=[31,32,183,223,227,231,246,251,268,280,281,282,283,284,285,293,307,310,311,312,313,314,315,316],Pe=[1,260],ve=[1,261],Ue=[1,263],we=[1,264],Ge=[1,265],Be=[1,266],Me=[1,268],Ve=[1,269],je=[2,416],He=[1,271],Qe=[1,272],ze=[1,273],Ze=[1,279],Ye=[1,274],We=[1,275],Xe=[1,276],qe=[1,277],Ke=[1,278],Je=[1,286],et=[1,299],tt=[6,41,79,81,83],rt=[1,316],it=[1,315],st=[39,41,83,111,159,160,162,165,166],nt=[1,324],at=[1,325],ut=[41,111,183,216,304],ot=[2,354],ct=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],pt=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],ht=[13,16,28,29,80,208,246,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,310,316,317,318,319,320,321],lt=[1,349],Ft=[1,350],Et=[1,352],yt=[1,351],ft=[6,13,16,28,29,31,32,39,41,68,71,74,76,79,80,81,83,86,111,159,160,162,165,166,183,215,218,219,223,227,231,246,248,249,250,251,252,254,255,257,258,261,263,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,307,310,311,312,313,314,315,316,317,318,319,320,321],_t=[1,360],Dt=[1,359],At=[29,86],gt=[13,16,32,41,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],bt=[29,41],Tt=[2,315],dt=[6,41,83],Ct=[6,13,16,29,41,71,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],It=[6,13,16,28,29,39,41,71,74,76,79,80,81,83,86,111,159,160,162,165,166,215,218,219,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304,316,317,318,319,320,321],St=[6,13,16,28,29,41,68,71,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],Nt=[6,13,16,28,29,31,32,39,41,61,68,71,74,76,79,80,81,83,86,111,159,160,162,165,166,183,215,218,219,223,227,231,246,248,249,250,251,252,254,255,257,258,261,263,268,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,304,305,307,310,311,312,313,314,315,316,317,318,319,320,321],kt=[13,16,29,187,208,213,286],Rt=[2,366],mt=[1,401],Lt=[39,41,83,111,159,160,162,165,166,304],Ot=[13,16,28,29,32,39,41,80,83,86,111,159,160,162,165,166,183,187,215,216,218,219,251,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],$t=[13,16,28,29,80,208,246,248,249,250,252,254,255,257,258,261,263,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,310,316,317,318,319,320,321],xt=[1,450],Pt=[1,447],vt=[1,448],Ut=[13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],wt=[13,16,28,286],Gt=[13,16,28,29,39,41,80,83,86,111,159,160,162,165,166,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,304],Bt=[2,327],Mt=[39,41,83,111,159,160,162,165,166,183,216,304],Vt=[6,13,16,28,29,41,74,76,79,81,83,248,249,250,252,254,255,257,258,261,263,286,316,317,318,319,320,321],jt=[2,322],Ht=[13,16,29,187,208,286],Qt=[13,16,32,80,92,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],zt=[13,16,28,29,41,80,86,111,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286],Zt=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,306,307],Yt=[13,16,28,29,32,80,86,215,218,219,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,293,306,307,309,310],Wt=[1,561],Xt=[1,562],qt=[2,310],Kt=[13,16,32,187,213,286],Jt={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Prologue_repetition0:7,Query:8,Query_group0:9,Query_option0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectQuery:17,SelectClause:18,SelectQuery_repetition0:19,WhereClause:20,SolutionModifier:21,SubSelect:22,SubSelect_option0:23,SELECT:24,SelectClause_option0:25,SelectClause_group0:26,SelectClauseItem:27,VAR:28,"(":29,Expression:30,AS:31,")":32,ConstructQuery:33,CONSTRUCT:34,ConstructTemplate:35,ConstructQuery_repetition0:36,ConstructQuery_repetition1:37,WHERE:38,"{":39,ConstructQuery_option0:40,"}":41,DescribeQuery:42,DESCRIBE:43,DescribeQuery_group0:44,DescribeQuery_repetition0:45,DescribeQuery_option0:46,AskQuery:47,ASK:48,AskQuery_repetition0:49,DatasetClause:50,FROM:51,DatasetClause_option0:52,iri:53,WhereClause_option0:54,GroupGraphPattern:55,SolutionModifier_option0:56,SolutionModifier_option1:57,SolutionModifier_option2:58,SolutionModifier_option3:59,GroupClause:60,GROUP:61,BY:62,GroupClause_repetition_plus0:63,GroupCondition:64,BuiltInCall:65,FunctionCall:66,HavingClause:67,HAVING:68,HavingClause_repetition_plus0:69,OrderClause:70,ORDER:71,OrderClause_repetition_plus0:72,OrderCondition:73,ASC:74,BrackettedExpression:75,DESC:76,Constraint:77,LimitOffsetClauses:78,LIMIT:79,INTEGER:80,OFFSET:81,ValuesClause:82,VALUES:83,InlineData:84,InlineData_repetition0:85,NIL:86,InlineData_repetition1:87,InlineData_repetition_plus2:88,InlineData_repetition3:89,DataBlockValue:90,Literal:91,UNDEF:92,DataBlockValueList:93,DataBlockValueList_repetition_plus0:94,Update:95,Update_repetition0:96,Update1:97,Update_option0:98,LOAD:99,Update1_option0:100,Update1_option1:101,Update1_group0:102,Update1_option2:103,GraphRefAll:104,Update1_group1:105,Update1_option3:106,GraphOrDefault:107,TO:108,CREATE:109,Update1_option4:110,GRAPH:111,INSERTDATA:112,QuadPattern:113,DELETEDATA:114,DELETEWHERE:115,Update1_option5:116,InsertClause:117,Update1_option6:118,Update1_repetition0:119,Update1_option7:120,DeleteClause:121,Update1_option8:122,Update1_repetition1:123,DELETE:124,INSERT:125,UsingClause:126,USING:127,UsingClause_option0:128,WithClause:129,WITH:130,IntoGraphClause:131,INTO:132,DEFAULT:133,GraphOrDefault_option0:134,GraphRefAll_group0:135,QuadPattern_option0:136,QuadPattern_repetition0:137,QuadsNotTriples:138,QuadsNotTriples_group0:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GraphPatternNotTriples_repetition0:158,OPTIONAL:159,MINUS:160,GraphPatternNotTriples_group0:161,SERVICE:162,GraphPatternNotTriples_option0:163,GraphPatternNotTriples_group1:164,FILTER:165,BIND:166,FunctionCall_option0:167,FunctionCall_repetition0:168,ExpressionList:169,ExpressionList_repetition0:170,ConstructTemplate_option0:171,ConstructTriples:172,ConstructTriples_repetition0:173,ConstructTriples_option0:174,VarOrTerm:175,PropertyListNotEmpty:176,TriplesNode:177,PropertyList:178,PropertyList_option0:179,VerbObjectList:180,PropertyListNotEmpty_repetition0:181,SemiOptionalVerbObjectList:182,";":183,SemiOptionalVerbObjectList_option0:184,Verb:185,ObjectList:186,a:187,ObjectList_repetition0:188,GraphNode:189,PropertyListPathNotEmpty:190,TriplesNodePath:191,TriplesSameSubjectPath_option0:192,PropertyListPathNotEmpty_group0:193,PropertyListPathNotEmpty_repetition0:194,GraphNodePath:195,PropertyListPathNotEmpty_repetition1:196,PropertyListPathNotEmptyTail:197,PropertyListPathNotEmptyTail_group0:198,Path:199,Path_repetition0:200,PathSequence:201,PathSequence_repetition0:202,PathEltOrInverse:203,PathElt:204,PathPrimary:205,PathElt_option0:206,PathEltOrInverse_option0:207,"!":208,PathNegatedPropertySet:209,PathOneInPropertySet:210,PathNegatedPropertySet_repetition0:211,PathNegatedPropertySet_option0:212,"^":213,TriplesNode_repetition_plus0:214,"[":215,"]":216,TriplesNodePath_repetition_plus0:217,BLANK_NODE_LABEL:218,ANON:219,ConditionalAndExpression:220,Expression_repetition0:221,ExpressionTail:222,"||":223,RelationalExpression:224,ConditionalAndExpression_repetition0:225,ConditionalAndExpressionTail:226,"&&":227,AdditiveExpression:228,RelationalExpression_group0:229,RelationalExpression_option0:230,IN:231,MultiplicativeExpression:232,AdditiveExpression_repetition0:233,AdditiveExpressionTail:234,AdditiveExpressionTail_group0:235,NumericLiteralPositive:236,AdditiveExpressionTail_repetition0:237,NumericLiteralNegative:238,AdditiveExpressionTail_repetition1:239,UnaryExpression:240,MultiplicativeExpression_repetition0:241,MultiplicativeExpressionTail:242,MultiplicativeExpressionTail_group0:243,UnaryExpression_option0:244,PrimaryExpression:245,"-":246,Aggregate:247,FUNC_ARITY0:248,FUNC_ARITY1:249,FUNC_ARITY2:250,",":251,IF:252,BuiltInCall_group0:253,BOUND:254,BNODE:255,BuiltInCall_option0:256,EXISTS:257,COUNT:258,Aggregate_option0:259,Aggregate_group0:260,FUNC_AGGREGATE:261,Aggregate_option1:262,GROUP_CONCAT:263,Aggregate_option2:264,Aggregate_option3:265,GroupConcatSeparator:266,SEPARATOR:267,"=":268,String:269,LANGTAG:270,"^^":271,DECIMAL:272,DOUBLE:273,true:274,false:275,STRING_LITERAL1:276,STRING_LITERAL2:277,STRING_LITERAL_LONG1:278,STRING_LITERAL_LONG2:279,INTEGER_POSITIVE:280,DECIMAL_POSITIVE:281,DOUBLE_POSITIVE:282,INTEGER_NEGATIVE:283,DECIMAL_NEGATIVE:284,DOUBLE_NEGATIVE:285,PNAME_LN:286,QueryOrUpdate_group0_option0:287,Prologue_repetition0_group0:288,SelectClause_option0_group0:289,DISTINCT:290,REDUCED:291,SelectClause_group0_repetition_plus0:292,"*":293,DescribeQuery_group0_repetition_plus0_group0:294,DescribeQuery_group0_repetition_plus0:295,NAMED:296,SILENT:297,CLEAR:298,DROP:299,ADD:300,MOVE:301,COPY:302,ALL:303,".":304,UNION:305,"|":306,"/":307,PathElt_option0_group0:308,"?":309,"+":310,"!=":311,"<":312,">":313,"<=":314,">=":315,NOT:316,CONCAT:317,COALESCE:318,SUBSTR:319,REGEX:320,REPLACE:321,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"SELECT",28:"VAR",29:"(",31:"AS",32:")",34:"CONSTRUCT",38:"WHERE",39:"{",41:"}",43:"DESCRIBE",48:"ASK",51:"FROM",61:"GROUP",62:"BY",68:"HAVING",71:"ORDER",74:"ASC",76:"DESC",79:"LIMIT",80:"INTEGER",81:"OFFSET",83:"VALUES",86:"NIL",92:"UNDEF",99:"LOAD",108:"TO",109:"CREATE",111:"GRAPH",112:"INSERTDATA",114:"DELETEDATA",115:"DELETEWHERE",124:"DELETE",125:"INSERT",127:"USING",130:"WITH",132:"INTO",133:"DEFAULT",159:"OPTIONAL",160:"MINUS",162:"SERVICE",165:"FILTER",166:"BIND",183:";",187:"a",208:"!",213:"^",215:"[",216:"]",218:"BLANK_NODE_LABEL",219:"ANON",223:"||",227:"&&",231:"IN",246:"-",248:"FUNC_ARITY0",249:"FUNC_ARITY1",250:"FUNC_ARITY2",251:",",252:"IF",254:"BOUND",255:"BNODE",257:"EXISTS",258:"COUNT",261:"FUNC_AGGREGATE",263:"GROUP_CONCAT",267:"SEPARATOR",268:"=",270:"LANGTAG",271:"^^",272:"DECIMAL",273:"DOUBLE",274:"true",275:"false",276:"STRING_LITERAL1",277:"STRING_LITERAL2",278:"STRING_LITERAL_LONG1",279:"STRING_LITERAL_LONG2",280:"INTEGER_POSITIVE",281:"DECIMAL_POSITIVE",282:"DOUBLE_POSITIVE",283:"INTEGER_NEGATIVE",284:"DECIMAL_NEGATIVE",285:"DOUBLE_NEGATIVE",286:"PNAME_LN",290:"DISTINCT",291:"REDUCED",293:"*",296:"NAMED",297:"SILENT",298:"CLEAR",299:"DROP",300:"ADD",301:"MOVE",302:"COPY",303:"ALL",304:".",305:"UNION",306:"|",307:"/",309:"?",310:"+",311:"!=",312:"<",313:">",314:"<=",315:">=",316:"NOT",317:"CONCAT",318:"COALESCE",319:"SUBSTR",320:"REGEX",321:"REPLACE"},productions_:[0,[3,3],[4,1],[8,2],[11,2],[14,3],[17,4],[22,4],[18,3],[27,1],[27,5],[33,5],[33,7],[42,5],[47,4],[50,3],[20,2],[21,4],[60,3],[64,1],[64,1],[64,3],[64,5],[64,1],[67,2],[70,3],[73,2],[73,2],[73,1],[73,1],[78,2],[78,2],[78,4],[78,4],[82,2],[84,4],[84,4],[84,6],[90,1],[90,1],[90,1],[93,3],[95,3],[97,4],[97,3],[97,5],[97,4],[97,2],[97,2],[97,2],[97,6],[97,6],[121,2],[117,2],[126,3],[129,2],[131,3],[107,1],[107,2],[104,2],[104,1],[113,4],[138,7],[143,3],[55,3],[55,3],[147,2],[150,3],[154,3],[151,2],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[77,1],[77,1],[77,1],[66,2],[66,6],[169,1],[169,4],[35,3],[172,3],[145,2],[145,2],[178,1],[176,2],[182,2],[180,2],[185,1],[185,1],[185,1],[186,2],[156,2],[156,2],[190,4],[197,1],[197,3],[199,2],[201,2],[204,2],[203,2],[205,1],[205,1],[205,2],[205,3],[209,1],[209,1],[209,4],[210,1],[210,1],[210,2],[210,2],[177,3],[177,3],[191,3],[191,3],[189,1],[189,1],[195,1],[195,1],[175,1],[175,1],[175,1],[175,1],[175,1],[175,1],[30,2],[222,2],[220,2],[226,2],[224,1],[224,3],[224,4],[228,2],[234,2],[234,2],[234,2],[232,2],[242,2],[240,2],[240,2],[240,2],[245,1],[245,1],[245,1],[245,1],[245,1],[245,1],[75,3],[65,1],[65,2],[65,4],[65,6],[65,8],[65,2],[65,4],[65,2],[65,4],[65,3],[247,5],[247,5],[247,6],[266,4],[91,1],[91,2],[91,3],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[269,1],[269,1],[269,1],[269,1],[236,1],[236,1],[236,1],[238,1],[238,1],[238,1],[53,1],[53,1],[53,1],[287,0],[287,1],[5,1],[5,1],[288,1],[288,1],[7,0],[7,2],[9,1],[9,1],[9,1],[9,1],[10,0],[10,1],[19,0],[19,2],[23,0],[23,1],[289,1],[289,1],[25,0],[25,1],[292,1],[292,2],[26,1],[26,1],[36,0],[36,2],[37,0],[37,2],[40,0],[40,1],[294,1],[294,1],[295,1],[295,2],[44,1],[44,1],[45,0],[45,2],[46,0],[46,1],[49,0],[49,2],[52,0],[52,1],[54,0],[54,1],[56,0],[56,1],[57,0],[57,1],[58,0],[58,1],[59,0],[59,1],[63,1],[63,2],[69,1],[69,2],[72,1],[72,2],[85,0],[85,2],[87,0],[87,2],[88,1],[88,2],[89,0],[89,2],[94,1],[94,2],[96,0],[96,4],[98,0],[98,2],[100,0],[100,1],[101,0],[101,1],[102,1],[102,1],[103,0],[103,1],[105,1],[105,1],[105,1],[106,0],[106,1],[110,0],[110,1],[116,0],[116,1],[118,0],[118,1],[119,0],[119,2],[120,0],[120,1],[122,0],[122,1],[123,0],[123,2],[128,0],[128,1],[134,0],[134,1],[135,1],[135,1],[135,1],[136,0],[136,1],[137,0],[137,2],[139,1],[139,1],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[158,0],[158,3],[161,1],[161,1],[163,0],[163,1],[164,1],[164,1],[167,0],[167,1],[168,0],[168,3],[170,0],[170,3],[171,0],[171,1],[173,0],[173,3],[174,0],[174,1],[179,0],[179,1],[181,0],[181,2],[184,0],[184,1],[188,0],[188,3],[192,0],[192,1],[193,1],[193,1],[194,0],[194,3],[196,0],[196,2],[198,1],[198,1],[200,0],[200,3],[202,0],[202,3],[308,1],[308,1],[308,1],[206,0],[206,1],[207,0],[207,1],[211,0],[211,3],[212,0],[212,1],[214,1],[214,2],[217,1],[217,2],[221,0],[221,2],[225,0],[225,2],[229,1],[229,1],[229,1],[229,1],[229,1],[229,1],[230,0],[230,1],[233,0],[233,2],[235,1],[235,1],[237,0],[237,2],[239,0],[239,2],[241,0],[241,2],[243,1],[243,1],[244,0],[244,1],[253,1],[253,1],[253,1],[253,1],[253,1],[256,0],[256,1],[259,0],[259,1],[260,1],[260,1],[262,0],[262,1],[264,0],[264,1],[265,0],[265,1]],performAction:function(e,t,r,i,s,n,a){var u,o,c=n.length-1;switch(s){case 1:return n[c-1]=n[c-1]||{},Gr.base&&(n[c-1].base=Gr.base),Gr.base=lr=Fr=Er="",n[c-1].prefixes=Gr.prefixes,Gr.prefixes=null,n[c-1];case 3:this.$=Dr(n[c-1],n[c],{type:"query"});break;case 4:Gr.base=gr(n[c]),lr=Fr=Er="";break;case 5:Gr.prefixes||(Gr.prefixes={}),n[c-1]=n[c-1].substr(0,n[c-1].length-1),n[c]=gr(n[c]),Gr.prefixes[n[c-1]]=n[c];break;case 6:this.$=Dr(n[c-3],Sr(n[c-2]),n[c-1],n[c]);break;case 7:this.$=Dr(n[c-3],n[c-2],n[c-1],n[c],{type:"query"});break;case 8:this.$=Dr({queryType:"SELECT",variables:"*"===n[c]?["*"]:n[c]},n[c-1]&&(n[c-2]=yr(n[c-1]),n[c-1]={},n[c-1][n[c-2]]=!0,n[c-1]));break;case 9:case 92:case 124:case 151:this.$=br(n[c]);break;case 10:case 22:this.$=dr(n[c-3],{variable:br(n[c-1])});break;case 11:this.$=Dr({queryType:"CONSTRUCT",template:n[c-3]},Sr(n[c-2]),n[c-1],n[c]);break;case 12:this.$=Dr({queryType:"CONSTRUCT",template:n[c-2]=n[c-2]?n[c-2].triples:[]},Sr(n[c-5]),{where:[{type:"bgp",triples:_r([],n[c-2])}]},n[c]);break;case 13:this.$=Dr({queryType:"DESCRIBE",variables:"*"===n[c-3]?["*"]:n[c-3].map(br)},Sr(n[c-2]),n[c-1],n[c]);break;case 14:this.$=Dr({queryType:"ASK"},Sr(n[c-2]),n[c-1],n[c]);break;case 15:case 54:this.$={iri:n[c],named:!!n[c-1]};break;case 16:this.$={where:n[c].patterns};break;case 17:this.$=Dr(n[c-3],n[c-2],n[c-1],n[c]);break;case 18:this.$={group:n[c]};break;case 19:case 20:case 26:case 28:this.$=dr(n[c]);break;case 21:this.$=dr(n[c-1]);break;case 23:case 29:this.$=dr(br(n[c]));break;case 24:this.$={having:n[c]};break;case 25:this.$={order:n[c]};break;case 27:this.$=dr(n[c],{descending:!0});break;case 30:this.$={limit:Nr(n[c])};break;case 31:this.$={offset:Nr(n[c])};break;case 32:this.$={limit:Nr(n[c-2]),offset:Nr(n[c])};break;case 33:this.$={limit:Nr(n[c]),offset:Nr(n[c-2])};break;case 34:this.$={type:"values",values:n[c]};break;case 35:n[c-3]=br(n[c-3]),this.$=n[c-1].map((function(e){var t={};return t[n[c-3]]=e,t}));break;case 36:this.$=n[c-1].map((function(){return{}}));break;case 37:var p=n[c-4].length;n[c-4]=n[c-4].map(br),this.$=n[c-1].map((function(e){if(e.length!==p)throw Error("Inconsistent VALUES length");for(var t={},r=0;r2&&I.push("'"+this.terminals_[T]+"'");N=h.showPosition?"Parse error on line "+(u+1)+":\n"+h.showPosition()+"\nExpecting "+I.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(u+1)+": Unexpected "+(1==_?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(N,{text:h.match,token:this.terminals_[_]||_,line:h.yylineno,loc:E,expected:I})}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+_);switch(g[0]){case 1:r.push(_),i.push(h.yytext),s.push(h.yylloc),r.push(g[1]),_=null,D?(_=D,D=null):(o=h.yyleng,a=h.yytext,u=h.yylineno,E=h.yylloc,c>0&&c--);break;case 2:if(d=this.productions_[g[1]][1],S.$=i[i.length-d],S._$={first_line:s[s.length-(d||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(d||1)].first_column,last_column:s[s.length-1].last_column},f&&(S._$.range=[s[s.length-(d||1)].range[0],s[s.length-1].range[1]]),void 0!==(b=this.performAction.apply(S,[a,o,u,l.yy,g[1],i,s].concat(p))))return b;d&&(r=r.slice(0,-1*d*2),i=i.slice(0,-1*d),s=s.slice(0,-1*d)),r.push(this.productions_[g[1]][0]),i.push(S.$),s.push(S._$),C=n[r[r.length-2]][r[r.length-1]],r.push(C);break;case 3:return!0}}return!0}},er="http://www.w3.org/1999/02/22-rdf-syntax-ns#",tr=er+"type",rr=er+"first",ir=er+"rest",sr=er+"nil",nr="http://www.w3.org/2001/XMLSchema#",ar=nr+"integer",ur=nr+"decimal",or=nr+"double",cr=nr+"boolean",pr='"true"^^'+cr,hr='"false"^^'+cr,lr="",Fr="",Er="";function yr(e){return e.toLowerCase()}function fr(e,t){return e.push(t),e}function _r(e,t){return e.push.apply(e,t),e}function Dr(e){e||(e={});for(var t,r=1,i=arguments.length;r>10),56320+(1023&s))}var n=xr[i];if(!n)throw new Error;return n}))}catch(e){return""}return'"'+e+'"'}function Ur(e,t,r){var i=[],s=[];return t.forEach((function(t){i.push(mr(null,e,t.entity)),_r(s,t.triples)})),Ar(i,r||[],s)}var wr={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===i.length?this.yylloc.first_column:0)+i[i.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,i,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var n in s)this[n]=s[n];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),n=0;nt[0].length)){if(t=r,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,s[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,s[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,r,i){switch(r){case 0:break;case 1:return 12;case 2:return 15;case 3:return 24;case 4:return 290;case 5:return 291;case 6:return 29;case 7:return 31;case 8:return 32;case 9:return 293;case 10:return 34;case 11:return 38;case 12:return 39;case 13:return 41;case 14:return 43;case 15:return 48;case 16:return 51;case 17:return 296;case 18:return 61;case 19:return 62;case 20:return 68;case 21:return 71;case 22:return 74;case 23:return 76;case 24:return 79;case 25:return 81;case 26:return 83;case 27:return 183;case 28:return 99;case 29:return 297;case 30:return 132;case 31:return 298;case 32:return 299;case 33:return 109;case 34:return 300;case 35:return 108;case 36:return 301;case 37:return 302;case 38:return 112;case 39:return 114;case 40:return 115;case 41:return 130;case 42:return 124;case 43:return 125;case 44:return 127;case 45:return 133;case 46:return 111;case 47:return 303;case 48:return 304;case 49:return 159;case 50:return 162;case 51:return 166;case 52:return 92;case 53:return 160;case 54:return 305;case 55:return 165;case 56:return 251;case 57:return 187;case 58:return 306;case 59:return 307;case 60:return 213;case 61:return 309;case 62:return 310;case 63:return 208;case 64:return 215;case 65:return 216;case 66:return 223;case 67:return 227;case 68:return 268;case 69:return 311;case 70:return 312;case 71:return 313;case 72:return 314;case 73:return 315;case 74:return 231;case 75:return 316;case 76:return 246;case 77:return 254;case 78:return 255;case 79:return 248;case 80:return 249;case 81:return 250;case 82:return 317;case 83:return 318;case 84:return 252;case 85:return 320;case 86:return 319;case 87:return 321;case 88:return 257;case 89:return 258;case 90:return 261;case 91:return 263;case 92:return 267;case 93:return 271;case 94:return 274;case 95:return 275;case 96:return 13;case 97:return 16;case 98:return 286;case 99:return 218;case 100:return 28;case 101:return 270;case 102:return 80;case 103:return 272;case 104:return 273;case 105:return 280;case 106:return 281;case 107:return 282;case 108:return 283;case 109:return 284;case 110:return 285;case 111:return"EXPONENT";case 112:return 276;case 113:return 277;case 114:return 278;case 115:return 279;case 116:return 86;case 117:return 219;case 118:return 6;case 119:return"INVALID";case 120:console.log(t.yytext)}},rules:[/^(?:\s+|#[^\n\r]*)/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT\s+DATA)/i,/^(?:DELETE\s+DATA)/i,/^(?:DELETE\s+WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true)/i,/^(?:false)/i,/^(?:(<([^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?)?:)((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.|:|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|:|((%([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])|\.)*(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]))?))/i,/^(?:([\?\$]((((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(((?:([A-Z]|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(([^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])))*'))/i,/^(?:("(([^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])))*"))/i,/^(?:('''(('|'')?([^'\\]|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))))*'''))/i,/^(?:("""(("|"")?([^\"\\]|(\\[tbnrf\\\"']|\\u([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])|\\U([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f])([0-9]|[A-F]|[a-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120],inclusive:!0}}};function Gr(){this.yy={}}return Jt.lexer=wr,Gr.prototype=Jt,Jt.Parser=Gr,new Gr}();t.parser=i,t.Parser=i.Parser,t.parse=function(){return i.parse.apply(i,arguments)},t.main=function(e){e[1]||(console.log("Usage: "+e[0]+" FILE"),process.exit(1));var i=r(203).readFileSync(r(783).normalize(e[1]),"utf8");return t.parser.parse(i)},r.c[r.s]===e&&t.main(process.argv.slice(1))},203:()=>{},783:()=>{}},t={};function r(i){var s=t[i];if(void 0!==s)return s.exports;var n=t[i]={id:i,loaded:!1,exports:{}};return e[i](n,n.exports,r),n.loaded=!0,n.exports}r.c=t,r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var i=r(r.s=734);window["SPARQL.js"]=i})(); \ No newline at end of file diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula-chevrotain.LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt new file mode 100644 index 0000000000..7c47ec05c9 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.LICENSE.txt @@ -0,0 +1,22 @@ +The bundled Traqula parser and generator are licensed under the MIT License. + +Copyright © 2024–now Jitse De Smet +Comunica Association and Ghent University – imec, Belgium + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js new file mode 100644 index 0000000000..fbb50c92d5 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js @@ -0,0 +1,122 @@ +(()=>{var Wm=Object.defineProperty;var Mt=(e,t)=>{for(var r in t)Wm(e,r,{get:t[r],enumerable:!0})};var tr=class{tracksSourceLocation;constructor(t={}){this.tracksSourceLocation=t.tracksSourceLocation??!0}wrap(t,r){return{val:t,loc:r}}isLocalized(t){return typeof t=="object"&&t!==null&&"loc"in t&&typeof t.loc=="object"&&t.loc!==null&&"sourceLocationType"in t.loc}sourceLocation(...t){if(!this.tracksSourceLocation)return this.gen();let r=t.filter(a=>a!==void 0);if(r.length===0)return this.sourceLocationNoMaterialize();let n=r.filter(a=>!this.isLocalized(a)||this.isSourceLocationSource(a.loc)||this.isSourceLocationStringReplace(a.loc)||this.isSourceLocationNodeReplace(a.loc));if(n.length===0)return this.gen();let i=n.at(0),s=n.at(-1);return{sourceLocationType:"source",start:this.isLocalized(i)?i.loc.start:i.startOffset,end:this.isLocalized(s)?s.loc.end:s.endOffset+1}}sourceLocationNoMaterialize(){return this.tracksSourceLocation?{sourceLocationType:"noMaterialize"}:this.gen()}dematerialized(t){return{...t,loc:this.sourceLocationNoMaterialize()}}safeObjectTransform(t,r){return t&&typeof t=="object"?Array.isArray(t)?t.map(n=>this.safeObjectTransform(n,r)):r(t):t}forcedAutoGenTree(t){let r={...t};for(let[n,i]of Object.entries(r))r[n]=this.safeObjectTransform(i,s=>this.forcedAutoGenTree(s));return this.isLocalized(r)&&(r.loc=this.gen()),r}forceMaterialized(t){return this.isSourceLocationNoMaterialize(t.loc)?this.forcedAutoGenTree(t):{...t}}isSourceLocation(t){return"sourceLocationType"in t}sourceLocationSource(t,r){return{sourceLocationType:"source",start:t,end:r}}sourceLocationInlinedSource(t,r,n,i,s=0,a=t.length){return this.tracksSourceLocation?(this.isSourceLocationSource(r)&&(s=r.start,a=r.end),{sourceLocationType:"inlinedSource",newSource:t,start:n,end:i,loc:r,startOnNew:s,endOnNew:a}):this.gen()}isSourceLocationInlinedSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="inlinedSource"}gen(){return{sourceLocationType:"autoGenerate"}}isSourceLocationSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="source"}sourceLocationStringReplace(t,r,n){return this.tracksSourceLocation?{sourceLocationType:"stringReplace",newSource:t,start:r,end:n}:this.gen()}isSourceLocationStringReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="stringReplace"}sourceLocationNodeReplaceUnsafe(t){if(this.isSourceLocationSource(t))return this.sourceLocationNodeReplace(t);if(this.isSourceLocationInlinedSource(t))return this.sourceLocationNodeReplaceUnsafe(t.loc);throw new Error(`Cannot convert SourceLocation of type ${t.sourceLocationType} to SourceLocationNodeReplace`)}sourceLocationNodeReplace(t,r){let n,i;return typeof t=="number"?(n=t,i=r):(n=t.start,i=t.end),{sourceLocationType:"nodeReplace",start:n,end:i}}isSourceLocationNodeReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="nodeReplace"}isSourceLocationNodeAutoGenerate(t){return this.isSourceLocation(t)&&t.sourceLocationType==="autoGenerate"}isPrintingLoc(t){return this.isSourceLocationNodeReplace(t)||this.isSourceLocationNodeAutoGenerate(t)||this.isSourceLocationInlinedSource(t)&&this.isPrintingLoc(t.loc)}printFilter(t,r){this.isPrintingLoc(t.loc)&&r()}isSourceLocationNoMaterialize(t){return this.isSourceLocation(t)&&t.sourceLocationType==="noMaterialize"}isOfType(t,r){return t.type===r}isOfSubType(t,r,n){let i=t;return i.type===r&&i.subType===n}};var zm=typeof global=="object"&&global&&global.Object===Object&&global,wc=zm,Ym=typeof self=="object"&&self&&self.Object===Object&&self,qm=wc||Ym||Function("return this")(),it=qm,Xm=it.Symbol,$e=Xm,Rc=Object.prototype,Qm=Rc.hasOwnProperty,Bm=Rc.toString,Or=$e?$e.toStringTag:void 0;function Zm(e){var t=Qm.call(e,Or),r=e[Or];try{e[Or]=void 0;var n=!0}catch{}var i=Bm.call(e);return n&&(t?e[Or]=r:delete e[Or]),i}var Jm=Zm,Um=Object.prototype,eg=Um.toString;function tg(e){return eg.call(e)}var rg=tg,ng="[object Null]",ig="[object Undefined]",Nl=$e?$e.toStringTag:void 0;function sg(e){return e==null?e===void 0?ig:ng:Nl&&Nl in Object(e)?Jm(e):rg(e)}var St=sg;function ag(e){return e!=null&&typeof e=="object"}var Qe=ag,og="[object Symbol]";function lg(e){return typeof e=="symbol"||Qe(e)&&St(e)==og}var zn=lg;function cg(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r0){if(++t>=lT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var hT=pT;function fT(e){return function(){return e}}var dT=fT,mT=(function(){try{var e=Ht(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Fn=mT,gT=Fn?function(e,t){return Fn(e,"toString",{configurable:!0,enumerable:!1,value:dT(t),writable:!0})}:Kr,TT=gT,vT=hT(TT),yT=vT;function AT(e,t){for(var r=-1,n=e==null?0:e.length;++r-1}var Dc=OT,ST=9007199254740991,NT=/^(?:0|[1-9]\d*)$/;function PT(e,t){var r=typeof e;return t=t??ST,!!t&&(r=="number"||r!="symbol"&&NT.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=VT}var ha=jT;function KT(e){return e!=null&&ha(e.length)&&!vt(e)}var st=KT;function HT(e,t,r){if(!Ve(r))return!1;var n=typeof t;return(n=="number"?st(r)&&Yn(t,r.length):n=="string"&&t in r)?Hr(r[t],e):!1}var Xn=HT;function WT(e){return pa(function(t,r){var n=-1,i=r.length,s=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(s=e.length>3&&typeof s=="function"?(i--,s):void 0,a&&Xn(r[0],r[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++n-1}var wy=ky;function Ry(e,t){var r=this.__data__,n=Zn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Fy=Ry;function lr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0&&r(o)?t>1?zc(o,t-1,r,n,i):Ta(i,o):n||(i[i.length]=o)}return i}var va=zc;function dA(e){var t=e==null?0:e.length;return t?va(e,1):[]}var qe=dA,mA=Kc(Object.getPrototypeOf,Object),Yc=mA;function gA(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(i);++n=n?e:ya(e,t,r)}var vA=TA,yA="\\ud800-\\udfff",AA="\\u0300-\\u036f",xA="\\ufe20-\\ufe2f",bA="\\u20d0-\\u20ff",IA=AA+xA+bA,EA="\\ufe0e\\ufe0f",LA="\\u200d",_A=RegExp("["+LA+yA+IA+EA+"]");function OA(e){return _A.test(e)}var qc=OA;function SA(e){return e.split("")}var NA=SA,Xc="\\ud800-\\udfff",PA="\\u0300-\\u036f",kA="\\ufe20-\\ufe2f",wA="\\u20d0-\\u20ff",RA=PA+kA+wA,FA="\\ufe0e\\ufe0f",CA="["+Xc+"]",Qs="["+RA+"]",Bs="\\ud83c[\\udffb-\\udfff]",MA="(?:"+Qs+"|"+Bs+")",Qc="[^"+Xc+"]",Bc="(?:\\ud83c[\\udde6-\\uddff]){2}",Zc="[\\ud800-\\udbff][\\udc00-\\udfff]",DA="\\u200d",Jc=MA+"?",Uc="["+FA+"]?",GA="(?:"+DA+"(?:"+[Qc,Bc,Zc].join("|")+")"+Uc+Jc+")*",$A=Uc+Jc+GA,VA="(?:"+[Qc+Qs+"?",Qs,Bc,Zc,CA].join("|")+")",jA=RegExp(Bs+"(?="+Bs+")|"+VA+$A,"g");function KA(e){return e.match(jA)||[]}var HA=KA;function WA(e){return qc(e)?HA(e):NA(e)}var zA=WA;function YA(e){return function(t){t=Wc(t);var r=qc(t)?zA(t):void 0,n=r?r[0]:t.charAt(0),i=r?vA(r,1).join(""):t.slice(1);return n[e]()+i}}var qA=YA,ZS=qA("toUpperCase");function XA(e,t,r,n){var i=-1,s=e==null?0:e.length;for(n&&s&&(r=e[++i]);++io))return!1;var u=s.get(e),p=s.get(t);if(u&&p)return u==t&&p==e;var h=-1,f=!0,m=r&mI?new Ia:void 0;for(s.set(e,t),s.set(t,e);++h2?t[2]:void 0;for(i&&Xn(t[0],t[1],i)&&(n=1);++r=CE&&(s=Ea,a=!1,t=new Ia(t));e:for(;++i-1?i[s?t[a]:a]:void 0}}var UE=JE,eL=Math.max;function tL(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:jr(r);return i<0&&(i=eL(n+i,0)),Mc(e,at(t,3),i)}var rL=tL,nL=UE(rL),sr=nL;function iL(e){return e&&e.length?e[0]:void 0}var Be=iL;function sL(e,t){var r=-1,n=st(e)?Array(e.length):[];return Wt(e,function(i,s,a){n[++r]=t(i,s,a)}),n}var aL=sL;function oL(e,t){var r=M(e)?Vr:aL;return r(e,at(t,3))}var O=oL;function lL(e,t){return va(O(e,t),1)}var Ge=lL,cL=Object.prototype,uL=cL.hasOwnProperty,pL=PE(function(e,t,r){uL.call(e,r)?e[r].push(t):ua(e,r,[t])}),hL=pL,fL=Object.prototype,dL=fL.hasOwnProperty;function mL(e,t){return e!=null&&dL.call(e,t)}var gL=mL;function TL(e,t){return e!=null&&du(e,t,gL)}var S=TL,vL="[object String]";function yL(e){return typeof e=="string"||!M(e)&&Qe(e)&&St(e)==vL}var Oe=yL;function AL(e,t){return Vr(t,function(r){return e[r]})}var xL=AL;function bL(e){return e==null?[]:xL(e,Pe(e))}var ce=bL,IL=Math.max;function EL(e,t,r,n){e=st(e)?e:ce(e),r=r&&!n?jr(r):0;var i=e.length;return r<0&&(r=IL(i+r,0)),Oe(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&ca(e,t,r)>-1}var be=EL,LL=Math.max;function _L(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:jr(r);return i<0&&(i=LL(n+i,0)),ca(e,t,i)}var oc=_L,OL="[object Map]",SL="[object Set]",NL=Object.prototype,PL=NL.hasOwnProperty;function kL(e){if(e==null)return!0;if(st(e)&&(M(e)||typeof e=="string"||typeof e.splice=="function"||Mr(e)||fa(e)||Qn(e)))return!e.length;var t=ir(e);if(t==OL||t==SL)return!e.size;if(zr(e))return!Hc(e).length;for(var r in e)if(PL.call(e,r))return!1;return!0}var z=kL,wL="[object RegExp]";function RL(e){return Qe(e)&&St(e)==wL}var FL=RL,lc=_t&&_t.isRegExp,CL=lc?Yr(lc):FL,mt=CL;function ML(e){return e===void 0}var gt=ML,DL="Expected a function";function GL(e){if(typeof e!="function")throw new TypeError(DL);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var $L=GL;function VL(e,t,r,n){if(!Ve(e))return e;t=ti(t,e);for(var i=-1,s=t.length,a=s-1,o=e;o!=null&&++i=t_){var u=t?null:e_(e);if(u)return La(u);a=!1,i=Ea,l=new Ia}else l=t?[]:o;e:for(;++n{t.accept(e)})}},Re=class extends ot{constructor(e){super([]),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},pr=class extends ot{constructor(e){super(e.definition),this.orgText="",ke(this,Ze(e,t=>t!==void 0))}},Se=class extends ot{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,ke(this,Ze(e,t=>t!==void 0))}},Le=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},lt=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},ct=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},ue=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},Je=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},Ue=class extends ot{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,ke(this,Ze(e,t=>t!==void 0))}},U=class{constructor(e){this.idx=1,ke(this,Ze(e,t=>t!==void 0))}accept(e){e.visit(this)}};function o_(e){return O(e,Nn)}function Nn(e){function t(r){return O(r,Nn)}if(e instanceof Re){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Oe(e.label)&&(r.label=e.label),r}else{if(e instanceof Se)return{type:"Alternative",definition:t(e.definition)};if(e instanceof Le)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof lt)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof ct)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Nn(new U({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof Je)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Nn(new U({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ue)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof Ue)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof U){let r={type:"Terminal",name:e.terminalType.name,label:s_(e.terminalType),idx:e.idx};Oe(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=mt(n)?n.source:n),r}else{if(e instanceof pr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var hr=class{visit(e){let t=e;switch(t.constructor){case Re:return this.visitNonTerminal(t);case Se:return this.visitAlternative(t);case Le:return this.visitOption(t);case lt:return this.visitRepetitionMandatory(t);case ct:return this.visitRepetitionMandatoryWithSeparator(t);case Je:return this.visitRepetitionWithSeparator(t);case ue:return this.visitRepetition(t);case Ue:return this.visitAlternation(t);case U:return this.visitTerminal(t);case pr:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function l_(e){return e instanceof Se||e instanceof Le||e instanceof ue||e instanceof lt||e instanceof ct||e instanceof Je||e instanceof U||e instanceof pr}function Dn(e,t=[]){return e instanceof Le||e instanceof ue||e instanceof Je?!0:e instanceof Ue?vu(e.definition,n=>Dn(n,t)):e instanceof Re&&be(t,e)?!1:e instanceof ot?(e instanceof Re&&t.push(e),Xe(e.definition,n=>Dn(n,t))):!1}function c_(e){return e instanceof Ue}function nt(e){if(e instanceof Re)return"SUBRULE";if(e instanceof Le)return"OPTION";if(e instanceof Ue)return"OR";if(e instanceof lt)return"AT_LEAST_ONE";if(e instanceof ct)return"AT_LEAST_ONE_SEP";if(e instanceof Je)return"MANY_SEP";if(e instanceof ue)return"MANY";if(e instanceof U)return"CONSUME";throw Error("non exhaustive match")}var ii=class{walk(e,t=[]){N(e.definition,(r,n)=>{let i=de(e.definition,n+1);if(r instanceof Re)this.walkProdRef(r,i,t);else if(r instanceof U)this.walkTerminal(r,i,t);else if(r instanceof Se)this.walkFlat(r,i,t);else if(r instanceof Le)this.walkOption(r,i,t);else if(r instanceof lt)this.walkAtLeastOne(r,i,t);else if(r instanceof ct)this.walkAtLeastOneSep(r,i,t);else if(r instanceof Je)this.walkManySep(r,i,t);else if(r instanceof ue)this.walkMany(r,i,t);else if(r instanceof Ue)this.walkOr(r,i,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){let n=t.concat(r);this.walk(e,n)}walkOption(e,t,r){let n=t.concat(r);this.walk(e,n)}walkAtLeastOne(e,t,r){let n=[new Le({definition:e.definition})].concat(t,r);this.walk(e,n)}walkAtLeastOneSep(e,t,r){let n=cc(e,t,r);this.walk(e,n)}walkMany(e,t,r){let n=[new Le({definition:e.definition})].concat(t,r);this.walk(e,n)}walkManySep(e,t,r){let n=cc(e,t,r);this.walk(e,n)}walkOr(e,t,r){let n=t.concat(r);N(e.definition,i=>{let s=new Se({definition:[i]});this.walk(s,n)})}};function cc(e,t,r){return[new Le({definition:[new U({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Qr(e){if(e instanceof Re)return Qr(e.referencedRule);if(e instanceof U)return h_(e);if(l_(e))return u_(e);if(c_(e))return p_(e);throw Error("non exhaustive match")}function u_(e){let t=[],r=e.definition,n=0,i=r.length>n,s,a=!0;for(;i&&a;)s=r[n],a=Dn(s),t=t.concat(Qr(s)),n=n+1,i=r.length>n;return Oa(t)}function p_(e){let t=O(e.definition,r=>Qr(r));return Oa(qe(t))}function h_(e){return[e.terminalType]}var bu="_~IN~_",f_=class extends ii{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){let n=m_(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),s=new Se({definition:i}),a=Qr(s);this.follows[n]=a}};function d_(e){let t={};return N(e,r=>{let n=new f_(r).startWalking();ke(t,n)}),t}function m_(e,t){return e.name+t+bu}function P(e){return e.charCodeAt(0)}function Hs(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function Sr(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function rr(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function In(){throw Error("Internal Error - Should never get here!")}function uc(e){return e.type==="Character"}var Gn=[];for(let e=P("0");e<=P("9");e++)Gn.push(e);var $n=[P("_")].concat(Gn);for(let e=P("a");e<=P("z");e++)$n.push(e);for(let e=P("A");e<=P("Z");e++)$n.push(e);var pc=[P(" "),P("\f"),P(` +`),P("\r"),P(" "),P("\v"),P(" "),P("\xA0"),P("\u1680"),P("\u2000"),P("\u2001"),P("\u2002"),P("\u2003"),P("\u2004"),P("\u2005"),P("\u2006"),P("\u2007"),P("\u2008"),P("\u2009"),P("\u200A"),P("\u2028"),P("\u2029"),P("\u202F"),P("\u205F"),P("\u3000"),P("\uFEFF")],g_=/[0-9a-fA-F]/,En=/[0-9]/,T_=/[1-9]/,v_=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Sr(r,"global");break;case"i":Sr(r,"ignoreCase");break;case"m":Sr(r,"multiLine");break;case"u":Sr(r,"unicode");break;case"y":Sr(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}rr(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return In()}quantifier(e=!1){let t,r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),t={atLeast:n,atMost:i}):t={atLeast:n,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;rr(t);break}if(!(e===!0&&t===void 0)&&rr(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),rr(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):In()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[P(` +`),P("\r"),P("\u2028"),P("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=Gn;break;case"D":e=Gn,t=!0;break;case"s":e=pc;break;case"S":e=pc,t=!0;break;case"w":e=$n;break;case"W":e=$n,t=!0;break}return rr(e)?{type:"Set",value:e,complement:t}:In()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=P("\f");break;case"n":e=P(` +`);break;case"r":e=P("\r");break;case"t":e=P(" ");break;case"v":e=P("\v");break}return rr(e)?{type:"Character",value:e}:In()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:P("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:P(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` +`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:P(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let r=this.classAtom(),n=r.type==="Character";if(uc(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),s=i.type==="Character";if(uc(i)){if(i.value=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}},Sa=class{visitChildren(e){for(let t in e){let r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(n=>{this.visit(n)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},Pn={},y_=new v_;function si(e){let t=e.toString();if(Pn.hasOwnProperty(t))return Pn[t];{let r=y_.pattern(t);return Pn[t]=r,r}}function A_(){Pn={}}var Iu="Complement Sets are not supported for first char optimization",Vn=`Unable to use "first char" lexer optimizations: +`;function x_(e,t=!1){try{let r=si(e);return ta(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===Iu)t&&yu(`${Vn} Unable to optimize: < ${e.toString()} > + Complement Sets cannot be automatically optimized. + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=` + This will disable the lexer's first char optimizations. + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),ea(`${Vn} + Failed parsing: < ${e.toString()} > + Using the @chevrotain/regexp-to-ast library + Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function ta(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i{if(typeof l=="number")Ln(l,t,r);else{let u=l;if(r===!0)for(let p=u.from;p<=u.to;p++)Ln(p,t,r);else{for(let p=u.from;p<=u.to&&p=kr){let p=u.from>=kr?u.from:kr,h=u.to,f=Ot(p),m=Ot(h);for(let v=f;v<=m;v++)t[v]=v}}}});break;case"Group":ta(a.value,t,r);break;default:throw Error("Non Exhaustive Match")}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&ra(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return ce(t)}function Ln(e,t,r){let n=Ot(e);t[n]=n,r===!0&&b_(e,t)}function b_(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=Ot(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let s=Ot(i.charCodeAt(0));t[s]=s}}}function hc(e,t){return sr(e.value,r=>{if(typeof r=="number")return be(t,r);{let n=r;return sr(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function ra(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?M(e.value)?Xe(e.value,ra):ra(e.value):!1}var I_=class extends Sa{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){be(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?hc(e,this.targetCharCodes)===void 0&&(this.found=!0):hc(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Na(e,t){if(t instanceof RegExp){let r=si(t),n=new I_(e);return n.visit(r),n.found}else return sr(t,r=>be(e,r.charCodeAt(0)))!==void 0}var Vt="PATTERN",Pr="defaultMode",_n="modes";function E_(e,t){t=_a(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` +`],tracer:(b,g)=>g()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{X_()});let n;r("Reject Lexer.NA",()=>{n=ni(e,b=>b[Vt]===me.NA)});let i=!1,s;r("Transform Patterns",()=>{i=!1,s=O(n,b=>{let g=b[Vt];if(mt(g)){let I=g.source;return I.length===1&&I!=="^"&&I!=="$"&&I!=="."&&!g.ignoreCase?I:I.length===2&&I[0]==="\\"&&!be(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:fc(g)}else{if(vt(g))return i=!0,{exec:g};if(typeof g=="object")return i=!0,g;if(typeof g=="string"){if(g.length===1)return g;{let I=g.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),w=new RegExp(I);return fc(w)}}else throw Error("non exhaustive match")}})});let a,o,l,u,p;r("misc mapping",()=>{a=O(n,b=>b.tokenTypeIdx),o=O(n,b=>{let g=b.GROUP;if(g!==me.SKIPPED){if(Oe(g))return g;if(gt(g))return!1;throw Error("non exhaustive match")}}),l=O(n,b=>{let g=b.LONGER_ALT;if(g)return M(g)?O(g,w=>oc(n,w)):[oc(n,g)]}),u=O(n,b=>b.PUSH_MODE),p=O(n,b=>S(b,"POP_MODE"))});let h;r("Line Terminator Handling",()=>{let b=_u(t.lineTerminatorCharacters);h=O(n,g=>!1),t.positionTracking!=="onlyOffset"&&(h=O(n,g=>S(g,"LINE_BREAKS")?!!g.LINE_BREAKS:Lu(g,b)===!1&&Na(b,g.PATTERN)))});let f,m,v,x;r("Misc Mapping #2",()=>{f=O(n,Eu),m=O(s,z_),v=we(n,(b,g)=>{let I=g.GROUP;return Oe(I)&&I!==me.SKIPPED&&(b[I]=[]),b},{}),x=O(s,(b,g)=>({pattern:s[g],longerAlt:l[g],canLineTerminator:h[g],isCustom:f[g],short:m[g],group:o[g],push:u[g],pop:p[g],tokenTypeIdx:a[g],tokenType:n[g]}))});let A=!0,y=[];return t.safeMode||r("First Char Optimization",()=>{y=we(n,(b,g,I)=>{if(typeof g.PATTERN=="string"){let w=g.PATTERN.charCodeAt(0),C=Ot(w);Ws(b,C,x[I])}else if(M(g.START_CHARS_HINT)){let w;N(g.START_CHARS_HINT,C=>{let se=typeof C=="string"?C.charCodeAt(0):C,Z=Ot(se);w!==Z&&(w=Z,Ws(b,Z,x[I]))})}else if(mt(g.PATTERN))if(g.PATTERN.unicode)A=!1,t.ensureOptimizations&&ea(`${Vn} Unable to analyze < ${g.PATTERN.toString()} > pattern. + The regexp unicode flag is not currently supported by the regexp-to-ast library. + This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let w=x_(g.PATTERN,t.ensureOptimizations);z(w)&&(A=!1),N(w,C=>{Ws(b,C,x[I])})}else t.ensureOptimizations&&ea(`${Vn} TokenType: <${g.name}> is using a custom token pattern without providing parameter. + This will disable the lexer's first char optimizations. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),A=!1;return b},[])}),{emptyGroups:v,patternIdxToConfig:x,charCodeToPatternIdxToConfig:y,hasCustom:i,canBeOptimized:A}}function L_(e,t){let r=[],n=O_(e);r=r.concat(n.errors);let i=S_(n.valid),s=i.valid;return r=r.concat(i.errors),r=r.concat(__(s)),r=r.concat(M_(s)),r=r.concat(D_(s,t)),r=r.concat(G_(s)),r}function __(e){let t=[],r=je(e,n=>mt(n[Vt]));return t=t.concat(P_(r)),t=t.concat(R_(r)),t=t.concat(F_(r)),t=t.concat(C_(r)),t=t.concat(k_(r)),t}function O_(e){let t=je(e,i=>!S(i,Vt)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:ne.MISSING_PATTERN,tokenTypes:[i]})),n=ri(e,t);return{errors:r,valid:n}}function S_(e){let t=je(e,i=>{let s=i[Vt];return!mt(s)&&!vt(s)&&!S(s,"exec")&&!Oe(s)}),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:ne.INVALID_PATTERN,tokenTypes:[i]})),n=ri(e,t);return{errors:r,valid:n}}var N_=/[^\\][$]/;function P_(e){class t extends Sa{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}let r=je(e,i=>{let s=i.PATTERN;try{let a=si(s),o=new t;return o.visit(a),o.found}catch{return N_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$' + See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ne.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function k_(e){let t=je(e,n=>n.PATTERN.test(""));return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:ne.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var w_=/[^\\[][\^]|^\^/;function R_(e){class t extends Sa{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}let r=je(e,i=>{let s=i.PATTERN;try{let a=si(s),o=new t;return o.visit(a),o.found}catch{return w_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^' + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ne.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function F_(e){let t=je(e,n=>{let i=n[Vt];return i instanceof RegExp&&(i.multiline||i.global)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:ne.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function C_(e){let t=[],r=O(e,s=>we(e,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!be(t,o)&&o.PATTERN!==me.NA&&(t.push(o),a.push(o)),a),[]));r=Xr(r);let n=je(r,s=>s.length>1);return O(n,s=>{let a=O(s,l=>l.name);return{message:`The same RegExp pattern ->${Be(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:ne.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function M_(e){let t=je(e,n=>{if(!S(n,"GROUP"))return!1;let i=n.GROUP;return i!==me.SKIPPED&&i!==me.NA&&!Oe(i)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:ne.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function D_(e,t){let r=je(e,i=>i.PUSH_MODE!==void 0&&!be(t,i.PUSH_MODE));return O(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:ne.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function G_(e){let t=[],r=we(e,(n,i,s)=>{let a=i.PATTERN;return a===me.NA||(Oe(a)?n.push({str:a,idx:s,tokenType:i}):mt(a)&&V_(a)&&n.push({str:a.source,idx:s,tokenType:i})),n},[]);return N(e,(n,i)=>{N(r,({str:s,idx:a,tokenType:o})=>{if(i${o.name}<- can never be matched. +Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition. +See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:l,type:ne.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function $_(e,t){if(mt(t)){if(j_(t))return!1;let r=t.exec(e);return r!==null&&r.index===0}else{if(vt(t))return t(e,0,[],{});if(S(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function V_(e){return sr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function j_(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\? property in its definition +`,type:ne.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),S(e,_n)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+_n+`> property in its definition +`,type:ne.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),S(e,_n)&&S(e,Pr)&&!S(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${Pr}: <${e.defaultMode}>which does not exist +`,type:ne.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),S(e,_n)&&N(e.modes,(i,s)=>{N(i,(a,o)=>{if(gt(a))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${o}> +`,type:ne.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(S(a,"LONGER_ALT")){let l=M(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];N(l,u=>{!gt(u)&&!be(i,u)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${u.name}> on token <${a.name}> outside of mode <${s}> +`,type:ne.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function H_(e,t,r){let n=[],i=!1,s=Xr(qe(ce(e.modes))),a=ni(s,l=>l[Vt]===me.NA),o=_u(r);return t&&N(a,l=>{let u=Lu(l,o);if(u!==!1){let h={message:q_(l,u),type:u.issue,tokenType:l};n.push(h)}else S(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):Na(o,l.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found. + This Lexer has been defined to track line and column information, + But none of the Token Types can be identified as matching a line terminator. + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS + for details.`,type:ne.NO_LINE_BREAKS_FLAGS}),n}function W_(e){let t={},r=Pe(e);return N(r,n=>{let i=e[n];if(M(i))t[n]=[];else throw Error("non exhaustive match")}),t}function Eu(e){let t=e.PATTERN;if(mt(t))return!1;if(vt(t))return!0;if(S(t,"exec"))return!0;if(Oe(t))return!1;throw Error("non exhaustive match")}function z_(e){return Oe(e)&&e.length===1?e.charCodeAt(0):!1}var Y_={test:function(e){let t=e.length;for(let r=this.lastIndex;r Token Type + Root cause: ${t.errMsg}. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===ne.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. + The problem is in the <${e.name}> Token Type + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function _u(e){return O(e,r=>Oe(r)?r.charCodeAt(0):r)}function Ws(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var kr=256,kn=[];function Ot(e){return e255?255+~~(e/255):e}}function Br(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function jn(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var dc=1,Ou={};function Zr(e){let t=Q_(e);B_(t),J_(t),Z_(t),N(t,r=>{r.isParent=r.categoryMatches.length>0})}function Q_(e){let t=_e(e),r=e,n=!0;for(;n;){r=Xr(qe(O(r,s=>s.CATEGORIES)));let i=ri(r,t);t=t.concat(i),z(i)?n=!1:r=i}return t}function B_(e){N(e,t=>{Nu(t)||(Ou[dc]=t,t.tokenTypeIdx=dc++),mc(t)&&!M(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),mc(t)||(t.CATEGORIES=[]),U_(t)||(t.categoryMatches=[]),eO(t)||(t.categoryMatchesMap={})})}function Z_(e){N(e,t=>{t.categoryMatches=[],N(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(Ou[n].tokenTypeIdx)})})}function J_(e){N(e,t=>{Su([],t)})}function Su(e,t){N(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),N(t.CATEGORIES,r=>{let n=e.concat(t);be(n,r)||Su(n,r)})}function Nu(e){return S(e,"tokenTypeIdx")}function mc(e){return S(e,"CATEGORIES")}function U_(e){return S(e,"categoryMatches")}function eO(e){return S(e,"categoryMatchesMap")}function tO(e){return S(e,"tokenTypeIdx")}var rO={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i,s){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}},ne;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(ne||(ne={}));var wr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` +`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:rO,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(wr);var me=class{constructor(e,t=wr){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(n,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${n}>`);let{time:a,value:o}=Au(i),l=a>10?console.warn:console.log;return this.traceInitIndent time: ${a}ms`),this.traceInitIndent--,o}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. +a boolean 2nd argument is no longer supported`);this.config=ke({},wr,t);let r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===wr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Y_;else if(this.config.lineTerminatorCharacters===wr.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),M(e)?n={modes:{defaultMode:_e(e)},defaultMode:Pr}:(i=!1,n=_e(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(K_(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(H_(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},N(n.modes,(a,o)=>{n.modes[o]=ni(a,l=>gt(l))});let s=Pe(n.modes);if(N(n.modes,(a,o)=>{this.TRACE_INIT(`Mode: <${o}> processing`,()=>{if(this.modes.push(o),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(L_(a,s))}),z(this.lexerDefinitionErrors)){Zr(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=E_(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[o]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[o]=l.charCodeToPatternIdxToConfig,this.emptyGroups=ke({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[o]=l.canBeOptimized}})}),this.defaultMode=n.defaultMode,!z(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let o=O(this.lexerDefinitionErrors,l=>l.message).join(`----------------------- +`);throw new Error(`Errors detected in definition of Lexer: +`+o)}N(this.lexerDefinitionWarning,a=>{yu(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=pe),this.trackStartLines===!1&&(this.computeNewColumn=Kr),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=pe),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let a=we(this.canModeBeOptimized,(o,l,u)=>(l===!1&&o.push(u),o),[]);if(t.ensureOptimizations&&!z(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized. + Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode. + Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{A_()}),this.TRACE_INIT("toFastProperties",()=>{xu(this)})})}tokenize(e,t=this.defaultMode){if(!z(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`----------------------- +`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer: +`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,s,a,o,l,u,p,h,f,m,v,x,A,y=e,b=y.length,g=0,I=0,w=this.hasCustom?0:Math.floor(e.length/10),C=new Array(w),se=[],Z=this.trackStartLines?1:void 0,F=this.trackStartLines?1:void 0,ee=W_(this.emptyGroups),V=this.trackStartLines,H=this.config.lineTerminatorsPattern,j=0,$=[],te=[],J=[],ye=[];Object.freeze(ye);let Te=!1,Ye=fe=>{if(J.length===1&&fe.tokenType.PUSH_MODE===void 0){let Me=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(fe);se.push({offset:fe.startOffset,line:fe.startLine,column:fe.startColumn,length:fe.image.length,message:Me})}else{J.pop();let Me=$t(J);$=this.patternIdxToConfig[Me],te=this.charCodeToPatternIdxToConfig[Me],j=$.length;let Gs=this.canModeBeOptimized[Me]&&this.config.safeMode===!1;te&&Gs?Te=!0:Te=!1}};function he(fe){J.push(fe),te=this.charCodeToPatternIdxToConfig[fe],$=this.patternIdxToConfig[fe],j=$.length,j=$.length;let Me=this.canModeBeOptimized[fe]&&this.config.safeMode===!1;te&&Me?Te=!0:Te=!1}he.call(this,t);let Y,Ce=this.config.recoveryEnabled;for(;go.length){o=s,p=s.length,l=u,Y=dt;break}}}break}}if(p!==-1){if(h=Y.group,h!==void 0&&(o=o!==null?o:e.substring(g,g+p),f=Y.tokenTypeIdx,m=this.createTokenInstance(o,g,f,Y.tokenType,Z,F,p),this.handlePayload(m,l),h===!1?I=this.addToken(C,I,m):ee[h].push(m)),V===!0&&Y.canLineTerminator===!0){let Ae=0,De,Lt;H.lastIndex=0;do o=o!==null?o:e.substring(g,g+p),De=H.test(o),De===!0&&(Lt=H.lastIndex-1,Ae++);while(De===!0);Ae!==0?(Z=Z+Ae,F=p-Lt,this.updateTokenEndLineColumnLocation(m,h,Lt,Ae,Z,F,p)):F=this.computeNewColumn(F,p)}else F=this.computeNewColumn(F,p);g=g+p,this.handleModes(Y,Ye,he,m)}else{let Ae=g,De=Z,Lt=F,dt=Ce===!1;for(;dt===!1&&g ${Cr(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let s="Expecting: ",o=` +but found: '`+Be(t).image+"'";if(n)return s+n+o;{let l=we(e,(f,m)=>f.concat(m),[]),u=O(l,f=>`[${O(f,m=>Cr(m)).join(", ")}]`),h=`one of these possible Token sequences: +${O(u,(f,m)=>` ${m+1}. ${f}`).join(` +`)}`;return s+h+o}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",a=` +but found: '`+Be(t).image+"'";if(r)return i+r+a;{let l=`expecting at least one iteration which starts with one of these possible Token sequences:: + <${O(e,u=>`[${O(u,p=>Cr(p)).join(",")}]`).join(" ,")}>`;return i+l+a}}};Object.freeze(ku);var aO={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<- +inside top level rule: ->`+e.name+"<-"}},Gt={buildDuplicateFoundError(e,t){function r(p){return p instanceof U?p.terminalType.name:p instanceof Re?p.nonTerminalName:""}let n=e.name,i=Be(t),s=i.idx,a=nt(i),o=r(i),l=s>0,u=`->${a}${l?s:""}<- ${o?`with argument: ->${o}<-`:""} + appears more than once (${t.length} times) in the top level rule: ->${n}<-. + For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES + `;return u=u.replace(/[ \t]+/g," "),u=u.replace(/\s\s+/g,` +`),u},buildNamespaceConflictError(e){return`Namespace conflict found in grammar. +The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>. +To resolve this make sure each Terminal and Non-Terminal names are unique +This is easy to accomplish by using the convention that Terminal names start with an uppercase letter +and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=O(e.prefixPath,i=>Cr(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix +in inside <${e.topLevelRule.name}> Rule, +<${t}> may appears as a prefix path in all these alternatives. +See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX +For Further details.`},buildAlternationAmbiguityError(e){let t=e.alternation.idx===0?"":e.alternation.idx,r=e.prefixPath.length===0,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in inside <${e.topLevelRule.name}> Rule, +`;if(r)n+=`These alternatives are all empty (match no tokens), making them indistinguishable. +Only the last alternative may be empty. +`;else{let i=O(e.prefixPath,s=>Cr(s)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives. +`}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES +For Further details.`,n},buildEmptyRepetitionError(e){let t=nt(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens. +This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in inside <${e.topLevelRule.name}> Rule. +Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives: + inside <${e.topLevelRule.name}> Rule. + has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=O(e.leftRecursionPath,s=>s.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar. +rule: <${t}> can be invoked from itself (directly or indirectly) +without consuming any Tokens. The grammar path that causes this is: + ${n} + To fix this refactor your grammar to remove the left recursion. +see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof pr?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function oO(e,t){let r=new lO(e,t);return r.resolveRefs(),r.errors}var lO=class extends hr{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){N(ce(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:xe.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},cO=class extends ii{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=_e(this.path.ruleStack).reverse(),this.occurrenceStack=_e(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let n=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){z(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},uO=class extends cO{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let n=t.concat(r),i=new Se({definition:n});this.possibleTokTypes=Qr(i),this.found=!0}}},oi=class extends ii{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},pO=class extends oi{walkMany(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,t,r)}},Ec=class extends oi{walkManySep(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,t,r)}},hO=class extends oi{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,t,r)}},Lc=class extends oi{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,t,r)}};function na(e,t,r=[]){r=_e(r);let n=[],i=0;function s(o){return o.concat(de(e,i+1))}function a(o){let l=na(s(o),t,r);return n.concat(l)}for(;r.length{z(l.definition)===!1&&(n=a(l.definition))}),n;if(o instanceof U)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:de(e,i)}),n}function wu(e,t,r,n){let i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE",o=!1,l=t.length,u=l-n-1,p=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!z(h);){let f=h.pop();if(f===a){o&&$t(h).idx<=u&&h.pop();continue}let m=f.def,v=f.idx,x=f.ruleStack,A=f.occurrenceStack;if(z(m))continue;let y=m[0];if(y===i){let b={idx:v,def:de(m),ruleStack:$r(x),occurrenceStack:$r(A)};h.push(b)}else if(y instanceof U)if(v=0;b--){let g=y.definition[b],I={idx:v,def:g.definition.concat(de(m)),ruleStack:x,occurrenceStack:A};h.push(I),h.push(a)}else if(y instanceof Se)h.push({idx:v,def:y.definition.concat(de(m)),ruleStack:x,occurrenceStack:A});else if(y instanceof pr)h.push(fO(y,v,x,A));else throw Error("non exhaustive match")}return p}function fO(e,t,r,n){let i=_e(r);i.push(e.name);let s=_e(n);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var re;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(re||(re={}));function Ru(e){if(e instanceof Le||e==="Option")return re.OPTION;if(e instanceof ue||e==="Repetition")return re.REPETITION;if(e instanceof lt||e==="RepetitionMandatory")return re.REPETITION_MANDATORY;if(e instanceof ct||e==="RepetitionMandatoryWithSeparator")return re.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof Je||e==="RepetitionWithSeparator")return re.REPETITION_WITH_SEPARATOR;if(e instanceof Ue||e==="Alternation")return re.ALTERNATION;throw Error("non exhaustive match")}function dO(e,t,r,n,i,s){let a=ka(e,t,r),o=Mu(a)?jn:Br;return s(a,n,o,i)}function mO(e,t,r,n,i,s){let a=wa(e,t,i,r),o=Mu(a)?jn:Br;return s(a[0],o,n)}function gO(e,t,r,n){let i=e.length,s=Xe(e,a=>Xe(a,o=>o.length===1));if(t)return function(a){let o=O(a,l=>l.GATE);for(let l=0;lqe(l)),o=we(a,(l,u,p)=>(N(u,h=>{S(l,h.tokenTypeIdx)||(l[h.tokenTypeIdx]=p),N(h.categoryMatches,f=>{S(l,f)||(l[f]=p)})}),l),{});return function(){let l=this.LA_FAST(1);return o[l.tokenTypeIdx]}}else return function(){for(let a=0;as.length===1),i=e.length;if(n&&!r){let s=qe(e);if(s.length===1&&z(s[0].categoryMatches)){let o=s[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{let a=we(s,(o,l,u)=>(o[l.tokenTypeIdx]=!0,N(l.categoryMatches,p=>{o[p]=!0}),o),[]);return function(){let o=this.LA_FAST(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;sna([a],1)),n=_c(r.length),i=O(r,a=>{let o={};return N(a,l=>{let u=zs(l.partialPath);N(u,p=>{o[p]=!0})}),o}),s=r;for(let a=1;a<=t;a++){let o=s;s=_c(o.length);for(let l=0;l{let y=zs(A.partialPath);N(y,b=>{i[l][b]=!0})})}}}}return n}function ka(e,t,r,n){let i=new Fu(e,re.ALTERNATION,n);return t.accept(i),Cu(i.result,r)}function wa(e,t,r,n){let i=new Fu(e,r);t.accept(i);let s=i.result,o=new vO(t,e,r).startWalking(),l=new Se({definition:s}),u=new Se({definition:o});return Cu([l,u],n)}function ia(e,t){e:for(let r=0;r{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Mu(e){return Xe(e,t=>Xe(t,r=>Xe(r,n=>z(n.categoryMatches))))}function xO(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return O(t,r=>Object.assign({type:xe.CUSTOM_LOOKAHEAD_VALIDATION},r))}function bO(e,t,r,n){let i=Ge(e,l=>IO(l,r)),s=CO(e,t,r),a=Ge(e,l=>kO(l,r)),o=Ge(e,l=>_O(l,e,n,r));return i.concat(s,a,o)}function IO(e,t){let r=new LO;e.accept(r);let n=r.allProductions,i=hL(n,EO),s=Ze(i,o=>o.length>1);return O(ce(s),o=>{let l=Be(o),u=t.buildDuplicateFoundError(e,o),p=nt(l),h={message:u,type:xe.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:p,occurrence:l.idx},f=Du(l);return f&&(h.parameter=f),h})}function EO(e){return`${nt(e)}_#_${e.idx}_#_${Du(e)}`}function Du(e){return e instanceof U?e.terminalType.name:e instanceof Re?e.nonTerminalName:""}var LO=class extends hr{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function _O(e,t,r,n){let i=[];if(we(t,(a,o)=>o.name===e.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:a,type:xe.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function OO(e,t,r){let n=[],i;return be(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:xe.INVALID_RULE_OVERRIDE,ruleName:e})),n}function Gu(e,t,r,n=[]){let i=[],s=wn(t.definition);if(z(s))return[];{let a=e.name;be(s,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:xe.LEFT_RECURSION,ruleName:a});let l=ri(s,n.concat([e])),u=Ge(l,p=>{let h=_e(n);return h.push(p),Gu(e,p,r,h)});return i.concat(u)}}function wn(e){let t=[];if(z(e))return t;let r=Be(e);if(r instanceof Re)t.push(r.referencedRule);else if(r instanceof Se||r instanceof Le||r instanceof lt||r instanceof ct||r instanceof Je||r instanceof ue)t=t.concat(wn(r.definition));else if(r instanceof Ue)t=qe(O(r.definition,s=>wn(s.definition)));else if(!(r instanceof U))throw Error("non exhaustive match");let n=Dn(r),i=e.length>1;if(n&&i){let s=de(e);return t.concat(wn(s))}else return t}var Ra=class extends hr{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function SO(e,t){let r=new Ra;e.accept(r);let n=r.alternations;return Ge(n,s=>{let a=$r(s.definition);return Ge(a,(o,l)=>{let u=wu([o],[],Br,1);return z(u)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:l}),type:xe.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:l+1}]:[]})})}function NO(e,t,r){let n=new Ra;e.accept(n);let i=n.alternations;return i=ni(i,a=>a.ignoreAmbiguities===!0),Ge(i,a=>{let o=a.idx,l=a.maxLookahead||t,u=ka(o,e,l,a),p=RO(u,a,e,r),h=FO(u,a,e,r);return p.concat(h)})}var PO=class extends hr{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function kO(e,t){let r=new Ra;e.accept(r);let n=r.alternations;return Ge(n,s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:xe.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[])}function wO(e,t,r){let n=[];return N(e,i=>{let s=new PO;i.accept(s);let a=s.allProductions;N(a,o=>{let l=Ru(o),u=o.maxLookahead||t,p=o.idx,f=wa(p,i,l,u)[0];if(z(qe(f))){let m=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:m,type:xe.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function RO(e,t,r,n){let i=[],s=we(e,(o,l,u)=>(t.definition[u].ignoreAmbiguities===!0||N(l,p=>{let h=[u];N(e,(f,m)=>{u!==m&&ia(f,p)&&t.definition[m].ignoreAmbiguities!==!0&&h.push(m)}),h.length>1&&!ia(i,p)&&(i.push(p),o.push({alts:h,path:p}))}),o),[]);return O(s,o=>{let l=O(o.alts,p=>p+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:l,prefixPath:o.path}),type:xe.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:o.alts}})}function FO(e,t,r,n){let i=we(e,(a,o,l)=>{let u=O(o,p=>({idx:l,path:p}));return a.concat(u)},[]);return Xr(Ge(i,a=>{if(t.definition[a.idx].ignoreAmbiguities===!0)return[];let l=a.idx,u=a.path,p=je(i,f=>t.definition[f.idx].ignoreAmbiguities!==!0&&f.idx{let m=[f.idx+1,l+1],v=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:m,prefixPath:f.path}),type:xe.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:v,alternatives:m}})}))}function CO(e,t,r){let n=[],i=O(t,s=>s.name);return N(e,s=>{let a=s.name;if(be(i,a)){let o=r.buildNamespaceConflictError(s);n.push({message:o,type:xe.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function MO(e){let t=_a(e,{errMsgProvider:aO}),r={};return N(e.rules,n=>{r[n.name]=n}),oO(r,t.errMsgProvider)}function DO(e){return e=_a(e,{errMsgProvider:Gt}),bO(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var $u="MismatchedTokenException",Vu="NoViableAltException",ju="EarlyExitException",Ku="NotAllInputParsedException",Hu=[$u,Vu,ju,Ku];Object.freeze(Hu);function Kn(e){return be(Hu,e.name)}var li=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Wu=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=$u}},GO=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Vu}},$O=class extends li{constructor(e,t){super(e,t),this.name=Ku}},VO=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=ju}},Ys={},zu="InRuleRecoveryException",jO=class extends Error{constructor(e){super(e),this.name=zu}},KO=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=S(e,"recoveryEnabled")?e.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=HO)}getTokenToInsert(e){let t=Pa(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,n){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],o=!1,l=this.LA_FAST(1),u=this.LA_FAST(1),p=()=>{let h=this.LA(0),f=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),m=new Wu(f,l,this.LA(0));m.resyncedTokens=$r(a),this.SAVE_ERROR(m)};for(;!o;)if(this.tokenMatcher(u,n)){p();return}else if(r.call(this)){p(),e.apply(this,t);return}else this.tokenMatcher(u,i)?o=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new jO("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||z(t))return!1;let r=this.LA_FAST(1);return sr(t,i=>this.tokenMatcher(r,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return be(r,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let n=sr(e,i=>sO(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Ys;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,r=this.RULE_STACK_IDX+1,n=new Array(r);for(let i=0;ithis.getFollowSetFromFollowKey(t));return qe(e)}getFollowSetFromFollowKey(e){if(e===Ys)return[jt];let t=e.ruleName+e.idxInCallingRule+bu+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,jt)||t.push(e),t}reSyncTo(e){let t=[],r=this.LA_FAST(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return $r(t)}attemptInRepetitionRecovery(e,t,r,n,i,s,a){}getCurrentGrammarPath(e,t){let r=this.getHumanReadableRuleStack(),n=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:r,occurrenceStack:n,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let r=0;rGu(t,t,Gt))}validateEmptyOrAlternatives(e){return Ge(e,t=>SO(t,Gt))}validateAmbiguousAlternationAlternatives(e,t){return Ge(e,r=>NO(r,t,Gt))}validateSomeNonEmptyLookaheadPath(e,t){return wO(e,t,Gt)}buildLookaheadForAlternation(e){return dO(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,gO)}buildLookaheadForOptional(e){return mO(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Ru(e.prodType),TO)}},qO=class{initLooksAhead(e){this.dynamicTokensEnabled=S(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=S(e,"maxLookahead")?e.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=S(e,"lookaheadStrategy")?e.lookaheadStrategy:new YO({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){N(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:n,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=QO(t);N(r,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${nt(l)}${u}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:t,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=qs(this.fullRuleNameToShort[t.name],Yu,l.idx);this.setLaFuncCache(h,p)})}),N(n,l=>{this.computeLookaheadFunc(t,l.idx,sa,"Repetition",l.maxLookahead,nt(l))}),N(i,l=>{this.computeLookaheadFunc(t,l.idx,qu,"Option",l.maxLookahead,nt(l))}),N(s,l=>{this.computeLookaheadFunc(t,l.idx,aa,"RepetitionMandatory",l.maxLookahead,nt(l))}),N(a,l=>{this.computeLookaheadFunc(t,l.idx,Rn,"RepetitionMandatoryWithSeparator",l.maxLookahead,nt(l))}),N(o,l=>{this.computeLookaheadFunc(t,l.idx,oa,"RepetitionWithSeparator",l.maxLookahead,nt(l))})})})}computeLookaheadFunc(e,t,r,n,i,s){this.TRACE_INIT(`${s}${t===0?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),o=qs(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return qs(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},XO=class extends hr{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},On=new XO;function QO(e){On.reset(),e.accept(On);let t=On.dslMethods;return On.reset(),t}function Oc(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffseta.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>: + ${s.join(` + +`).replace(/\n/g,` + `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function tS(e,t,r){let n=function(){};Xu(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return N(t,s=>{i[s]=UO}),n.prototype=i,n.prototype.constructor=n,n}var la;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(la||(la={}));function rS(e,t){return nS(e,t)}function nS(e,t){let r=je(t,i=>vt(e[i])===!1),n=O(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:la.MISSING_METHOD,methodName:i}));return Xr(n)}var iS=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=S(e,"nodeLocationTracking")?e.nodeLocationTracking:Tt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=pe,this.cstFinallyStateUpdate=pe,this.cstPostTerminal=pe,this.cstPostNonTerminal=pe,this.cstPostRule=pe;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Sc,this.setNodeLocationFromNode=Sc,this.cstPostRule=pe,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Oc,this.setNodeLocationFromNode=Oc,this.cstPostRule=pe,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=pe,this.setInitialNodeLocation=pe;else throw Error(`Invalid config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];BO(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];ZO(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(gt(this.baseCstVisitorConstructor)){let e=eS(this.className,Pe(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(gt(this.baseCstVisitorWithDefaultsConstructor)){let e=tS(this.className,Pe(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},sS=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):ar}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ar:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},aS=class{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=Wn){if(be(this.definedRulesNames,e)){let s={message:Gt.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:xe.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);let n=this.defineRule(e,t,r);return this[e]=n,n}OVERRIDE_RULE(e,t,r=Wn){let n=OO(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);let i=this.defineRule(e,t,r);return this[e]=i,i}BACKTRACK(e,t){var r;let n=(r=e.coreRule)!==null&&r!==void 0?r:e;return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return n.apply(this,t),!0}catch(s){if(Kn(s))return!1;throw s}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return o_(ce(this.gastProductionsCache))}},oS=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=jn,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},S(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0 + For Further details.`);if(M(e)){if(z(e))throw Error(`A Token Vocabulary cannot be empty. + Note that the first argument for the parser constructor + is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument. + See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0 + For Further details.`)}if(M(e))this.tokensMap=we(e,(i,s)=>(i[s.name]=s,i),{});else if(S(e,"modes")&&Xe(qe(ce(e.modes)),tO)){let i=qe(ce(e.modes)),s=Oa(i);this.tokensMap=we(s,(a,o)=>(a[o.name]=o,a),{})}else if(Ve(e))this.tokensMap=_e(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=jt;let r=S(e,"modes")?qe(ce(e.modes)):ce(e),n=Xe(r,i=>z(i.categoryMatches));this.tokenMatcher=n?jn:Br,Zr(ce(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called' +Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=S(r,"resyncEnabled")?r.resyncEnabled:Wn.resyncEnabled,i=S(r,"recoveryValueFunc")?r.recoveryValueFunc:Wn.recoveryValueFunc,s=this.ruleShortNameIdx<s.call(this)&&a.call(this)}}else i=e;if(n.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(aa,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let s=t.GATE;if(s!==void 0){let a=n;n=()=>s.call(this)&&a.call(this)}}else i=t;if(n.call(this)===!0){let s=this.doSingleRepetition(i);for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,re.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,aa,e,hO)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Rn,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,Lc],a,Rn,e,Lc)}else throw this.raiseEarlyExitException(e,re.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(sa,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let a=t.GATE;if(a!==void 0){let o=n;n=()=>a.call(this)&&o.call(this)}}else i=t;let s=!0;for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,sa,e,pO,s)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(oa,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,Ec],a,oa,e,Ec)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,Rn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Yu,t),n=M(e)?e:e.DEF,s=this.getLaFuncFromCache(r).call(this,n);if(s!==void 0)return n[s].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(e,t,r){let n;try{let i=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,n=e.coreRule.apply(this,i),this.cstPostNonTerminal(n,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),n}catch(i){throw this.subruleInternalError(i,r,e.ruleName)}}subruleInternalError(e,t,r){throw Kn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let n;try{let i=this.LA_FAST(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),n=i):this.consumeInternalError(e,i,r)}catch(i){n=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,n),n}consumeInternalError(e,t,r){let n,i=this.LA(0);throw r!==void 0&&r.ERR_MSG?n=r.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Wu(n,t,i))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){let n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(i){throw i.name===zu?r:i}}else throw r}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let r=0;r=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=r,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),jt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t${e}<- does not exist in this grammar.`);return wu([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=Be(e.ruleStack),n=this.getGAstProductions()[t];return new uO(n,e).startWalking()}},ci={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(ci);var Nc=!0,Pc=Math.pow(2,Nt)-1,Qu=ai({name:"RECORDING_PHASE_TOKEN",pattern:me.NA});Zr([Qu]);var Bu=Pa(Qu,`This IToken indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Bu);var uS={name:`This CSTNode indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},pS=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(r,n){return this.consumeInternalRecord(r,e,n)},this[`SUBRULE${t}`]=function(r,n){return this.subruleInternalRecord(r,e,n)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return ar}topLevelRuleRecord(e,t){try{let r=new pr({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+` + This error was thrown during the "grammar recording phase" For more info see: + https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return Nr.call(this,Le,e,t)}atLeastOneInternalRecord(e,t){Nr.call(this,lt,t,e)}atLeastOneSepFirstInternalRecord(e,t){Nr.call(this,ct,t,e,Nc)}manyInternalRecord(e,t){Nr.call(this,ue,t,e)}manySepFirstInternalRecord(e,t){Nr.call(this,Je,t,e,Nc)}orInternalRecord(e,t){return hS.call(this,e,t)}subruleInternalRecord(e,t,r){if(Hn(t),!e||S(e,"ruleName")===!1){let a=new Error(` argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=$t(this.recordingProdStack),i=e.ruleName,s=new Re({idx:t,nonTerminalName:i,label:r?.LABEL,referencedRule:void 0});return n.definition.push(s),this.outputCst?uS:ci}consumeInternalRecord(e,t,r){if(Hn(t),!Nu(e)){let s=new Error(` argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=$t(this.recordingProdStack),i=new U({idx:t,terminalType:e,label:r?.LABEL});return n.definition.push(i),Bu}};function Nr(e,t,r,n=!1){Hn(r);let i=$t(this.recordingProdStack),s=vt(t)?t:t.DEF,a=new e({definition:[],idx:r});return n&&(a.separator=t.SEP),S(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),ci}function hS(e,t){Hn(t);let r=$t(this.recordingProdStack),n=M(e)===!1,i=n===!1?e:e.DEF,s=new Ue({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});S(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);let a=vu(i,o=>vt(o.GATE));return s.hasPredicates=a,r.definition.push(s),N(i,o=>{let l=new Se({definition:[]});s.definition.push(l),S(o,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:S(o,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),o.ALT.call(this),this.recordingProdStack.pop()}),ci}function kc(e){return e===0?"":`${e}`}function Hn(e){if(e<0||e>Pc){let t=new Error(`Invalid DSL Method idx value: <${e}> + Idx value must be a none negative value smaller than ${Pc+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var fS=class{initPerformanceTracer(e){if(S(e,"traceInitPerf")){let t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Tt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${e}>`);let{time:n,value:i}=Au(t),s=n>10?console.warn:console.log;return this.traceInitIndent time: ${n}ms`),this.traceInitIndent--,i}else return t()}};function dS(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let s=Object.getOwnPropertyDescriptor(n,i);s&&(s.get||s.set)?Object.defineProperty(e.prototype,i,s):e.prototype[i]=r.prototype[i]})})}var ar=Pa(jt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ar);var Tt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ku,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Wn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),xe;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(xe||(xe={}));var Fa=class Zu{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{xu(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),N(this.definedRulesNames,i=>{let a=this[i].originalGrammarAction,o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=MO({rules:ce(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(z(n)&&this.skipValidations===!1){let i=DO({rules:ce(this.gastProductionsCache),tokenTypes:ce(this.tokensMap),errMsgProvider:Gt,grammarName:r}),s=xO({lookaheadStrategy:this.lookaheadStrategy,rules:ce(this.gastProductionsCache),tokenTypes:ce(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,s)}}),z(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=d_(ce(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:ce(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(ce(this.gastProductionsCache))})),!Zu.DEFER_DEFINITION_ERRORS_HANDLING&&!z(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected: + ${t.join(` +------------------------------- +`)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),S(r,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. + Please use the flag on the relevant DSL method instead. + See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES + For further details.`);this.skipValidations=S(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Fa.DEFER_DEFINITION_ERRORS_HANDLING=!1;dS(Fa,[KO,qO,iS,sS,oS,aS,lS,cS,pS,fS]);var Ju=class extends Fa{constructor(e,t=Tt){let r=_e(t);r.outputCst=!1,super(e,r)}};function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function d(e){return ai(e)}var X="When you use this string, you expect traqula to handle indentation after every newline",Jr="When you use this string, you expect that the core generator of Traqula does prints a given string instead of a ewline when NEW_LINE printing is disabled through traqulaIndentation";var ui=class e{rules;factory=new tr;__context=void 0;origSource="";handledInlineSource;generatedUntil=0;toEnsure=[];stringBuilder=[];constructor(t){this.rules=t;for(let r of Object.values(t))this[r.name]=((n,i,s)=>(this.stringBuilder.length=0,this.toEnsure.length=0,this.origSource=i.origSource,this.generatedUntil=i?.offset??0,this.setContext(i),this.subrule(r,n,s),this.catchup(this.origSource.length),this.handeEnsured(""),this.stringBuilder.join("")))}setContext(t){this.__context=t}getSafeContext(){return this.__context}subrule=(t,r,...n)=>{let i=this.rules[t.name];if(!i)throw new Error(`Rule ${t.name} not found`);let s=()=>i.gImpl({SUBRULE:this.subrule,PRINT:this.print,ENSURE:this.ensure,ENSURE_EITHER:this.ensureEither,NEW_LINE:this.newLine,HANDLE_LOC:this.handleLoc,CATCHUP:this.catchup,PRINT_WORD:this.printWord,PRINT_WORDS:this.printWords,PRINT_ON_EMPTY:this.printOnEmpty,PRINT_ON_OWN_LINE:this.printOnOwnLine})(r,this.getSafeContext(),...n);this.factory.isLocalized(r)?this.handleLoc(r,s):s()};handleLoc=(t,r)=>{if(this.factory.isSourceLocationNoMaterialize(t.loc))return;if(this.factory.isSourceLocationStringReplace(t.loc)){this.catchup(t.loc.start),this.print(t.loc.newSource),this.generatedUntil=t.loc.end;return}if(this.factory.isSourceLocationNodeReplace(t.loc)&&(this.catchup(t.loc.start),this.generatedUntil=t.loc.end),this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.start),this.factory.isSourceLocationInlinedSource(t.loc)&&this.handledInlineSource!==t.loc){this.handledInlineSource=t.loc,this.catchup(t.loc.start);let i=this.origSource,s=this.generatedUntil;this.origSource=t.loc.newSource,this.generatedUntil=0,this.catchup(t.loc.startOnNew);let a=this.handleLoc(t.loc,r);return this.generatedUntil=t.loc.endOnNew,this.catchup(this.origSource.length),this.origSource=i,this.generatedUntil=Math.max(s,t.loc.end),a}let n=r();return this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.end),n};catchup=t=>{let r=this.generatedUntil;r{let r=t.join("");this.handeEnsured(r),this.stringBuilder.push(r)};doesEndWith(t){let r=t.length;for(let n=this.stringBuilder.length-1;n>=0&&r>0;n--){let i=this.stringBuilder[n],s=r-i.length,a=t.slice(s>0?s:0,r);if(!i.endsWith(a))return!1;r-=a.length}return r===0}ensure=(...t)=>{let r=t.join("");this.doesEndWith(r)||this.toEnsure.push(n=>{!n.startsWith(r)&&!this.doesEndWith(r)&&this.stringBuilder.push(r)})};ensureEither=(...t)=>{t.length===1?this.ensure(...t):t.length>1&&!t.some(r=>this.doesEndWith(r))&&this.toEnsure.push(r=>{!t.some(n=>r.startsWith(n))&&!t.some(n=>this.doesEndWith(n))&&this.stringBuilder.push(t[0])})};static isBlank(t){return t===" "||t===" "}pruneEndingBlanks(){let t=this.stringBuilder,r=t.length-1,n=0;for(;r>=0;r--){let s=t[r];for(n=s.length;n>0&&e.isBlank(s[n-1]);)n--;if(n>0)break}let i=r>=0?t[r].slice(0,n):"";t.length=r>0?r:0,this.print(i)}endsWithNewline(){for(let t=this.stringBuilder.length-1;t>=0;t--){let r=this.stringBuilder[t];if(r.length>0)return r.endsWith(` +`)}return!1}newLine=t=>{let r=this.getSafeContext()[X]??0,n=t?.force??!1;if(r<0){let i=this.getSafeContext()[Jr];i!==void 0&&(n||!this.doesEndWith(i))&&this.print(i);return}this.pruneEndingBlanks(),n?this.print(` +`," ".repeat(r)):this.endsWithNewline()?this.print(" ".repeat(r)):this.print(` +`," ".repeat(r))};printWord=(...t)=>{this.ensureEither(" ",` +`),this.print(...t),this.ensureEither(" ",` +`)};printWords=(...t)=>{for(let r of t)this.printWord(r)};printOnEmpty=(...t)=>{this.newLine(),this.print(...t)};printOnOwnLine=(...t)=>{this.newLine(),this.print(...t),this.newLine()}};function Uu(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var pi=class e{static create(t){return Array.isArray(t)?new e(Uu(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the GeneratorBuilder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Uu(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(l=>l.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`)}return this.rules=n,this}build(){return new ui(this.rules)}};var Ie=class e{tokens;static create(t){return new e(t)}constructor(t){this.tokens=t?.tokens?[...t.tokens]:[]}merge(t,r=[]){let n=t.tokens.filter(i=>{if(r.find(o=>o.name===i.name))return!1;let a=this.tokens.find(o=>o.name===i.name);if(a){if(a!==i)throw new Error(`Token with name ${i.name} already exists. Implementation is different and no overwrite was provided.`);return!1}return!0});return this.tokens.push(...n),this}add(...t){return this.tokens.push(...t),this}addBefore(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n,0,...r),this}moveBeforeOrAfter(t,r,...n){let i=this.tokens.indexOf(r)+(t==="before"?0:1);if(i===-1)throw new Error("BeforeToken not found");for(let s of n){let a=this.tokens.indexOf(s);if(a===-1)throw new Error("Token not found");this.tokens.splice(a,1),this.tokens.splice(i,0,s)}return this}moveBefore(t,...r){return this.moveBeforeOrAfter("before",t,...r)}moveAfter(t,...r){return this.moveBeforeOrAfter("after",t,...r)}addAfter(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n+1,0,...r),this}delete(...t){for(let r of t){let n=this.tokens.indexOf(r);if(n===-1)throw new Error("Token not found");this.tokens.splice(n,1)}return this}deleteToken(...t){for(let r of t){let n=this.tokens.findIndex(i=>i.name===r);if(n===-1)throw new Error(`Token with name "${r}" not found`);this.tokens.splice(n,1)}return this}replace(t){let r=this.tokens.findIndex(n=>n.name===t.name);if(r===-1)throw new Error(`Token with name "${t.name}" not found`);return this.tokens[r]=t,this}build(t){return new me(this.tokens,{positionTracking:"onlyStart",recoveryEnabled:!1,ensureOptimizations:!0,...t})}get tokenVocabulary(){return this.tokens}};var hi=class extends Ju{context;setContext(t){this.context=t}constructor(t,r,n={}){super(r,{maxLookahead:1,skipValidations:!0,dynamicTokensEnabled:!1,...n}),this.context=void 0;let s={...this.constructSelfRef(),cache:new WeakMap};for(let a of Object.values(t))this[a.name]=this.RULE(a.name,a.impl(s));this.performSelfAnalysis()}constructSelfRef(){let t=r=>((n,...i)=>r(this[n.name],{ARGS:[this.context,...i]}));return{CONSUME:(r,n)=>this.CONSUME(r,n),CONSUME1:(r,n)=>this.CONSUME1(r,n),CONSUME2:(r,n)=>this.CONSUME2(r,n),CONSUME3:(r,n)=>this.CONSUME3(r,n),CONSUME4:(r,n)=>this.CONSUME4(r,n),CONSUME5:(r,n)=>this.CONSUME5(r,n),CONSUME6:(r,n)=>this.CONSUME6(r,n),CONSUME7:(r,n)=>this.CONSUME7(r,n),CONSUME8:(r,n)=>this.CONSUME8(r,n),CONSUME9:(r,n)=>this.CONSUME9(r,n),OPTION:r=>this.OPTION(r),OPTION1:r=>this.OPTION1(r),OPTION2:r=>this.OPTION2(r),OPTION3:r=>this.OPTION3(r),OPTION4:r=>this.OPTION4(r),OPTION5:r=>this.OPTION5(r),OPTION6:r=>this.OPTION6(r),OPTION7:r=>this.OPTION7(r),OPTION8:r=>this.OPTION8(r),OPTION9:r=>this.OPTION9(r),OR:r=>this.OR(r),OR1:r=>this.OR1(r),OR2:r=>this.OR2(r),OR3:r=>this.OR3(r),OR4:r=>this.OR4(r),OR5:r=>this.OR5(r),OR6:r=>this.OR6(r),OR7:r=>this.OR7(r),OR8:r=>this.OR8(r),OR9:r=>this.OR9(r),MANY:r=>this.MANY(r),MANY1:r=>this.MANY1(r),MANY2:r=>this.MANY2(r),MANY3:r=>this.MANY3(r),MANY4:r=>this.MANY4(r),MANY5:r=>this.MANY5(r),MANY6:r=>this.MANY6(r),MANY7:r=>this.MANY7(r),MANY8:r=>this.MANY8(r),MANY9:r=>this.MANY9(r),MANY_SEP:r=>this.MANY_SEP(r),MANY_SEP1:r=>this.MANY_SEP1(r),MANY_SEP2:r=>this.MANY_SEP2(r),MANY_SEP3:r=>this.MANY_SEP3(r),MANY_SEP4:r=>this.MANY_SEP4(r),MANY_SEP5:r=>this.MANY_SEP5(r),MANY_SEP6:r=>this.MANY_SEP6(r),MANY_SEP7:r=>this.MANY_SEP7(r),MANY_SEP8:r=>this.MANY_SEP8(r),MANY_SEP9:r=>this.MANY_SEP9(r),AT_LEAST_ONE:r=>this.AT_LEAST_ONE(r),AT_LEAST_ONE1:r=>this.AT_LEAST_ONE1(r),AT_LEAST_ONE2:r=>this.AT_LEAST_ONE2(r),AT_LEAST_ONE3:r=>this.AT_LEAST_ONE3(r),AT_LEAST_ONE4:r=>this.AT_LEAST_ONE4(r),AT_LEAST_ONE5:r=>this.AT_LEAST_ONE5(r),AT_LEAST_ONE6:r=>this.AT_LEAST_ONE6(r),AT_LEAST_ONE7:r=>this.AT_LEAST_ONE7(r),AT_LEAST_ONE8:r=>this.AT_LEAST_ONE8(r),AT_LEAST_ONE9:r=>this.AT_LEAST_ONE9(r),AT_LEAST_ONE_SEP:r=>this.AT_LEAST_ONE_SEP(r),AT_LEAST_ONE_SEP1:r=>this.AT_LEAST_ONE_SEP1(r),AT_LEAST_ONE_SEP2:r=>this.AT_LEAST_ONE_SEP2(r),AT_LEAST_ONE_SEP3:r=>this.AT_LEAST_ONE_SEP3(r),AT_LEAST_ONE_SEP4:r=>this.AT_LEAST_ONE_SEP4(r),AT_LEAST_ONE_SEP5:r=>this.AT_LEAST_ONE_SEP5(r),AT_LEAST_ONE_SEP6:r=>this.AT_LEAST_ONE_SEP6(r),AT_LEAST_ONE_SEP7:r=>this.AT_LEAST_ONE_SEP7(r),AT_LEAST_ONE_SEP8:r=>this.AT_LEAST_ONE_SEP8(r),AT_LEAST_ONE_SEP9:r=>this.AT_LEAST_ONE_SEP9(r),ACTION:r=>this.ACTION(r),BACKTRACK:(r,...n)=>this.BACKTRACK(this[r.name],{ARGS:n}),SUBRULE:t((r,n)=>this.SUBRULE(r,n)),SUBRULE1:t((r,n)=>this.SUBRULE1(r,n)),SUBRULE2:t((r,n)=>this.SUBRULE2(r,n)),SUBRULE3:t((r,n)=>this.SUBRULE3(r,n)),SUBRULE4:t((r,n)=>this.SUBRULE4(r,n)),SUBRULE5:t((r,n)=>this.SUBRULE5(r,n)),SUBRULE6:t((r,n)=>this.SUBRULE6(r,n)),SUBRULE7:t((r,n)=>this.SUBRULE7(r,n)),SUBRULE8:t((r,n)=>this.SUBRULE8(r,n)),SUBRULE9:t((r,n)=>this.SUBRULE9(r,n))}}};function ep(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var oe=class e{static create(t){return Array.isArray(t)?new e(ep(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the builder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...ep(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(l=>l.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the builder, specify an override to resolve conflict`)}return this.rules=n,this}defaultErrorHandler(t,r){let n=r[0],i=["Parse error"],s=n.token.startLine;if(s!==void 0&&!Number.isNaN(s)){let a=t.split(` +`)[s-1];i.push(` on line ${s} +${a}`);let o=n.token.startColumn;o!==void 0&&i.push(` +${"-".repeat(o-1)}^`)}throw i.push(` +${n.message}`),new Error(i.join(""))}build({tokenVocabulary:t,parserConfig:r={},lexerConfig:n={},queryPreProcessor:i=a=>a,errorHandler:s}){let a=Ie.create().add(...t).build({positionTracking:"onlyOffset",recoveryEnabled:!1,ensureOptimizations:!0,safeMode:!1,skipValidations:!0,...n}),o=this.consume({tokenVocabulary:t,config:r}),l={};for(let u of Object.values(this.rules))l[u.name]=((p,h,...f)=>{let m=i(p),v=a.tokenize(m);if(v.errors.length>0)throw new Error(v.errors[0].message);o.input=v.tokens,o.setContext(h);let x=o[u.name](h,...f);return o.errors.length>0&&(s?s(o.errors):this.defaultErrorHandler(m,o.errors)),x});return l}consume({tokenVocabulary:t,config:r={}}){return new hi(this.rules,t,r)}};function fr(e){return e instanceof Promise}function Pt(e,t){return fr(e)?e.then(t):t(e)}function fi(e){return{shortcut:void 0,continue:void 0,ignoreKeys:void 0,visitChildren:void 0,shallowKeys:void 0,copy:void 0,reTransform:void 0,...e}}var zt=class e{maxStackSize=1e6;maxNodeRewrites=1e3;defaultContext;constructor(t={}){this.defaultContext=fi(t)}clone(t={}){return new e({...this.defaultContext,...t})}cloneObj(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return[...t];let r=Object.getPrototypeOf(t);return r===Object.prototype||r===null?{...t}:Object.assign(Object.create(r),t)}createVisitChildrenOf(t){let r,n,i=new Set,s=(u,p)=>u===r&&(n.ignoreKeys?.has(p)===!0||n.shallowKeys?.has(p)===!0),l={visitKey:((u,p)=>{let h=u?.[p];h!==null&&typeof h=="object"&&!s(u,p)&&t(h,u,String(p))}),stepIntoKey:((u,p)=>{let h=u?.[p];if(h===null||typeof h!="object")return h;if(s(u,p))return Array.isArray(h)?[]:{};if(!n.copiesSteps||i.has(h))return h;let f=this.cloneObj(h);return i.add(f),u[p]=f,f})};return(u,p)=>{if(p.shallowKeys!==void 0){let h=u;for(let f of p.shallowKeys){let m=h[f];m!==null&&typeof m=="object"&&Object.hasOwn(h,f)&&(h[f]=this.cloneObj(m))}}r=u,n=p,p.visitChildren(u,l),i.size>0&&i.clear()}}transformObject(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!1)}async transformObjectAsync(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!0)}runTransformObject(t,r,n,i){let s=this.defaultContext,a=s.copy??!0,o=s.continue??!0,l=s.ignoreKeys,u=s.visitChildren,p=s.shallowKeys,h=s.shortcut??!1,f=!1,m={res:t},v=[t],x=[m],A=["res"],y=[],b=[],g=[],I=[],w=[];function C(){for(;v.length===y.at(-1);){y.pop();let V=b.pop(),H=g.pop(),j=I.pop(),$=w.pop(),te=r(V,H);if(i&&fr(te))return te.then(J=>(j[$]=J,C()));j[$]=te}}let se=(V,H,j)=>{v.push(V),A.push(j),x.push(H)},Z,F=(V,H,j,$)=>{let te=$.copy??a,J=$.continue??o,ye=$.ignoreKeys??l,Te=$.visitChildren??u,Ye=$.shallowKeys??p;f=$.shortcut??h;let he=te?this.cloneObj(V):V;if(y.push(v.length),b.push(he),g.push(V),I.push(H),w.push(j),J&&!f){if(Te){Z??=this.createVisitChildrenOf(se),Z(he,{visitChildren:Te,ignoreKeys:ye,shallowKeys:Ye,copiesSteps:te});return}for(let Y in he){if(!Object.hasOwn(he,Y))continue;let Ce=he[Y],fe=Ye&&Ye?.has(Y);fe&&(he[Y]=this.cloneObj(Ce)),!(ye&&ye.has(Y))&&!fe&&Ce!==null&&typeof Ce=="object"&&(v.push(Ce),A.push(Y),x.push(he))}}},ee=()=>{for(;v.length>0&&v.length=0;Te--){let Ye=V[Te];Ye!==null&&typeof Ye=="object"&&(v.push(Ye),x.push(J),A.push(Te.toString()))}let ye=C();if(ye)return ye.then(ee);continue}let te=n(V);if(i&&fr(te))return te.then(J=>{F(V,H,j,J);let ye=C();return ye?ye.then(ee):ee()});F(V,H,j,te)}let $=C();if($)return $.then(ee)}if(v.length>=this.maxStackSize||y.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return m.res};return ee()}transformObjectPreOrder(t,r){return this.runTransformObjectPreOrder(t,r,!1)}async transformObjectPreOrderAsync(t,r){return this.runTransformObjectPreOrder(t,r,!0)}runTransformObjectPreOrder(t,r,n){let i=this.defaultContext,s=i.copy??!0,a=i.continue??!0,o=i.ignoreKeys,l=i.visitChildren,u=i.shallowKeys,p=i.shortcut??!1,h=i.reTransform??!1,f=!1,m={res:t},v=[t],x=[m],A=["res"],y=[0],b=[0];function g(F,ee,V){for(let H=F.length-1;H>=0;H--){let j=F[H];j!==null&&typeof j=="object"&&(v.push(j),x.push(F),A.push(H.toString()),y.push(ee),b.push(V+1))}}let I=0,w=(F,ee,V)=>{v.push(F),x.push(ee),A.push(V),y.push(0),b.push(I)},C,se=(F,ee,V,H,j)=>{let $=F.newValue;ee[V]=$;let te=F.continue??a,J=F.ignoreKeys??o,ye=F.visitChildren??l,Te=F.shallowKeys??u,Ye=F.reTransform??h;if(f=F.shortcut??p,!te||f||$===null||typeof $!="object")return;if(Array.isArray($)){g($,H+1,j);return}if(Ye){v.push($),x.push(ee),A.push(V),y.push(H+1),b.push(j);return}let he=$;if(I=j+1,ye){C??=this.createVisitChildrenOf(w),C(he,{visitChildren:ye,ignoreKeys:J,shallowKeys:Te,copiesSteps:s});return}for(let Y in he){if(!Object.hasOwn(he,Y))continue;let Ce=he[Y];Ce!==null&&typeof Ce=="object"&&(Te?.has(Y)?he[Y]=this.cloneObj(Ce):(J===void 0||!J.has(Y))&&w(Ce,he,Y))}},Z=()=>{for(;!f&&v.length>0&&v.length=this.maxNodeRewrites)throw new Error(`Pre order transform did not converge: rewrote the same position ${this.maxNodeRewrites} times.`,{cause:F});if(j>=this.maxStackSize)throw new Error("Transform object stack overflowed");if(Array.isArray(F)){let J=[...F];ee[V]=J,g(J,H,j);continue}let $=s?this.cloneObj(F):F,te=r($,F);if(n&&fr(te))return te.then(J=>(se(J,ee,V,H,j),Z()));se(te,ee,V,H,j)}if(v.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return m.res};return Z()}visitObject(t,r,n=()=>({})){this.runVisitObject(t,r,n,!1)}async visitObjectAsync(t,r,n=()=>({})){await this.runVisitObject(t,r,n,!0)}runVisitObject(t,r,n,i){let s=this.defaultContext,a=s.continue??!0,o=s.ignoreKeys,l=s.visitChildren,u=s.shortcut??!1,p=!1,h=[t],f=[],m=[];function v(){for(;h.length===f.at(-1);){f.pop();let g=m.pop();if(g===void 0)continue;let I=r(g);if(i&&fr(I))return I.then(()=>v())}}let x=g=>{h.push(g)},A,y=(g,I)=>{p=I.shortcut??u;let w=I.continue??a,C=I.ignoreKeys??o,se=I.visitChildren??l;if(f.push(h.length),m.push(g),w&&!p){if(se){A??=this.createVisitChildrenOf(x),A(g,{visitChildren:se,ignoreKeys:C,shallowKeys:void 0,copiesSteps:!1});return}for(let Z in g){if(!Object.hasOwn(g,Z)||C&&C.has(Z))continue;let F=g[Z];F&&typeof F=="object"&&h.push(F)}}},b=()=>{for(;h.length>0&&h.length=0;se--){let Z=g[se];Z!==null&&typeof Z=="object"&&h.push(Z)}let C=v();if(C)return C.then(b);continue}let w=n(g);if(i&&fr(w))return w.then(C=>{y(g,C);let se=v();return se?se.then(b):b()});y(g,w)}let I=v();if(I)return I.then(b)}if(h.length>=this.maxStackSize||f.length>=this.maxStackSize)throw new Error("Transform object stack overflowed")};return b()}};var mS=Object.freeze(fi({}));function Ne(e){return e!==null&&typeof e=="object"&&typeof e.type=="string"}function Ca(e){let t={};for(let[r,n]of Object.entries(e)){let i=Object.entries(n),s=i.filter(([,l])=>l===!0).map(([l])=>l),a=i.flatMap(([l,u])=>typeof u=="function"?[{key:l,visitor:u}]:[]),o=(l,u)=>{for(let p of s)u.visitKey(l,p);for(let{key:p,visitor:h}of a){let f=u.stepIntoKey(l,p);f!==null&&typeof f=="object"&&h(f,u)}};t[r]={visitChildren:o}}return t}function dr(...e){return(t,{visitKey:r,stepIntoKey:n})=>{for(let i=t.length-1;i>=0;i--){if(Ne(t[i])){r(t,i);continue}let s=n(t,i);for(let a of e)r(s,a)}}}var Ur=class e extends zt{defaultNodePreVisitor;constructor(t={},r={}){super(t),this.defaultNodePreVisitor=Object.fromEntries(Object.entries(r).map(([n,i])=>[n,fi(i)]))}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}withNodeDefault(t,r){let n=t?.type,i=typeof n=="string"?this.defaultNodePreVisitor[n]:void 0;return i===void 0?r??mS:r?{...i,...r}:i}transformNode(t,r){let n=(s,a)=>{let o,l=s;return Ne(l)&&(o=r[l.type]?.transform),o?o(l,a):s},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),this.withNodeDefault(o,a?.(o))};return this.transformObject(t,n,i)}transformNodeAsync(t,r){let n=(s,a)=>{let o,l=s;return Ne(l)&&(o=r[l.type]?.transform),o?o(l,a):s},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),Pt(a?.(o),l=>this.withNodeDefault(o,l))};return this.transformObjectAsync(t,n,i)}transformNodePreOrder(t,r){let n=(i,s)=>{let a,o=i;Ne(o)&&(a=r[o.type]);let l=a?a(i,s):{newValue:i,reTransform:!1};return this.withNodeDefault(l.newValue,l)};return this.transformObjectPreOrder(t,n)}transformNodePreOrderAsync(t,r){let n=(i,s)=>{let a,o=i;Ne(o)&&(a=r[o.type]);let l=a?a(i,s):{newValue:i,reTransform:!1};return Pt(l,u=>this.withNodeDefault(u.newValue,u))};return this.transformObjectPreOrderAsync(t,n)}visitNode(t,r){let n=s=>{let a=s;if(Ne(a)){let o=r[a.type]?.visitor;o&&o(a)}},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),this.withNodeDefault(o,a?.(o))};return this.visitObject(t,n,i)}visitNodeAsync(t,r){let n=s=>{let a=s;if(Ne(a)){let o=r[a.type]?.visitor;if(o)return o(a)}},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),Pt(a?.(o),l=>this.withNodeDefault(o,l))};return this.visitObjectAsync(t,n,i)}};function ut(e,t,r,n){if(!Ne(e))return;let i=e.subType?r[e.type]?.[e.subType]:void 0;return n===void 0?i??t[e.type]:i?.[n]??t[e.type]?.[n]}var en=class e extends Ur{constructor(t={},r={}){super(t,r)}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNodeSpecific(t,r,n){let i=(a,o)=>{let l=ut(a,r,n,"transform");return l?l(a,o):a},s=a=>{let o=ut(a,r,n,"preVisitor");return this.withNodeDefault(a,o?.(a))};return this.transformObject(t,i,s)}transformNodeSpecificAsync(t,r,n){let i=(a,o)=>{let l=ut(a,r,n,"transform");return l?l(a,o):a},s=a=>{let o=ut(a,r,n,"preVisitor");return Pt(o?.(a),l=>this.withNodeDefault(a,l))};return this.transformObjectAsync(t,i,s)}transformNodeSpecificPreOrder(t,r,n){let i=(s,a)=>{let o=ut(s,r,n),l=o?o(s,a):{newValue:s,reTransform:!1};return this.withNodeDefault(l.newValue,l)};return this.transformObjectPreOrder(t,i)}transformNodeSpecificPreOrderAsync(t,r,n){let i=(s,a)=>{let o=ut(s,r,n),l=o?o(s,a):{newValue:s,reTransform:!1};return Pt(l,u=>this.withNodeDefault(u.newValue,u))};return this.transformObjectPreOrderAsync(t,i)}visitNodeSpecific(t,r,n){let i=a=>{ut(a,r,n,"visitor")?.(a)},s=a=>{let o=ut(a,r,n,"preVisitor");return this.withNodeDefault(a,o?.(a))};this.visitObject(t,i,s)}visitNodeSpecificAsync(t,r,n){let i=a=>ut(a,r,n,"visitor")?.(a),s=a=>{let o=ut(a,r,n,"preVisitor");return Pt(o?.(a),l=>this.withNodeDefault(a,l))};return this.visitObjectAsync(t,i,s)}};var c={};Mt(c,{add:()=>pl,additiveExpression:()=>km,aggregate:()=>bs,aggregateAvg:()=>zd,aggregateCount:()=>jd,aggregateGroup_concat:()=>qd,aggregateMax:()=>Wd,aggregateMin:()=>Hd,aggregateSample:()=>Yd,aggregateSum:()=>Kd,argList:()=>br,askQuery:()=>yn,baseAggregateFunc:()=>Zt,baseDecl:()=>ho,bind:()=>jo,blankNode:()=>ms,blankNodePropertyList:()=>bm,blankNodePropertyListPath:()=>Fo,booleanLiteral:()=>Qt,brackettedExpression:()=>Ir,builtInAbs:()=>Qf,builtInBnodeSparqlJs:()=>qf,builtInBound:()=>Wf,builtInCall:()=>It,builtInCallList:()=>Cd,builtInCeil:()=>Bf,builtInCoalesce:()=>Ld,builtInConcat:()=>Uf,builtInContains:()=>id,builtInDatatype:()=>Hf,builtInDay:()=>pd,builtInEncode_for_uri:()=>nd,builtInFloor:()=>Zf,builtInHours:()=>hd,builtInIf:()=>_d,builtInIri:()=>zf,builtInIsblank:()=>wd,builtInIsiri:()=>Pd,builtInIsliteral:()=>Rd,builtInIsnumeric:()=>Fd,builtInIsuri:()=>kd,builtInLang:()=>jf,builtInLangmatches:()=>Kf,builtInLcase:()=>rd,builtInMd5:()=>Ad,builtInMinutes:()=>fd,builtInMonth:()=>ud,builtInNow:()=>Td,builtInRand:()=>Xf,builtInRound:()=>Jf,builtInSameterm:()=>Nd,builtInSeconds:()=>dd,builtInSha1:()=>xd,builtInSha256:()=>bd,builtInSha384:()=>Id,builtInSha512:()=>Ed,builtInStr:()=>Vf,builtInStrafter:()=>ld,builtInStrbefore:()=>od,builtInStrdt:()=>Sd,builtInStrends:()=>ad,builtInStrlang:()=>Od,builtInStrlen:()=>ed,builtInStrstarts:()=>sd,builtInStruuid:()=>yd,builtInTimezone:()=>md,builtInTz:()=>gd,builtInUcase:()=>td,builtInUri:()=>Yf,builtInUuid:()=>vd,builtInYear:()=>cd,canCreateBlankNodes:()=>ES,clear:()=>ll,collection:()=>ym,collectionPath:()=>Ro,conditionalAndExpression:()=>Xo,conditionalOrExpression:()=>Nm,constraint:()=>dn,constructQuery:()=>Tn,constructTemplate:()=>al,constructTriples:()=>Cm,copy:()=>fl,create:()=>ul,dataBlock:()=>_m,dataBlockValue:()=>Yo,datasetClause:()=>If,datasetClauseStar:()=>tt,datasetClauseUsing:()=>To,datasetClauseUsingStar:()=>vo,defaultGraphClause:()=>Ef,deleteClause:()=>Dm,deleteData:()=>ml,deleteWhere:()=>gl,describeQuery:()=>vn,drop:()=>cl,existsFunc:()=>$d,expression:()=>k,expressionList:()=>As,filter:()=>Wo,funcExpr1:()=>D,funcExpr2:()=>rt,funcExpr2or3:()=>vs,funcExpr3:()=>Ao,funcExpr3or4:()=>Io,funcExprList1:()=>Ts,funcExprOrNil1:()=>bo,funcGroupGraphPattern:()=>ys,funcNil1:()=>Ar,funcVar1:()=>xo,functionCall:()=>Os,generatePattern:()=>Em,graphGraphPattern:()=>$o,graphNode:()=>Do,graphNodePath:()=>ht,graphOrDefault:()=>yl,graphPatternNotTriples:()=>zo,graphRef:()=>xn,graphRefAll:()=>er,graphTerm:()=>mo,groupClause:()=>el,groupCondition:()=>wm,groupGraphPattern:()=>B,groupGraphPatternSub:()=>Lm,groupOrUnionGraphPattern:()=>Ho,havingClause:()=>tl,havingCondition:()=>Rm,inlineData:()=>xr,inlineDataFull:()=>Sm,inlineDataOneVar:()=>Om,insertClause:()=>vl,insertData:()=>dl,iri:()=>G,iriFull:()=>yr,iriOrFunction:()=>Uo,limitClause:()=>il,limitOffsetClauses:()=>nl,load:()=>ol,minusGraphPattern:()=>Ko,modify:()=>Tl,move:()=>hl,multiplicativeExpression:()=>Zo,namedGraphClause:()=>_f,notExistsFunc:()=>Vd,numericExpression:()=>Bo,numericLiteral:()=>Xt,numericLiteralNegative:()=>fs,numericLiteralPositive:()=>hs,numericLiteralUnsigned:()=>bf,object:()=>gm,objectList:()=>fm,objectListPath:()=>dm,objectPath:()=>Tm,offsetClause:()=>sl,optionalGraphPattern:()=>Go,orderClause:()=>rl,orderCondition:()=>Fm,path:()=>Es,pathAlternative:()=>Jd,pathChainHelper:()=>wo,pathElt:()=>ko,pathEltOrInverse:()=>Bd,pathGenerator:()=>Et,pathMod:()=>Ud,pathNegatedPropertySet:()=>tm,pathOneInPropertySet:()=>Is,pathPrimary:()=>em,pathSequence:()=>Zd,prefixDecl:()=>fo,prefixOperators:()=>Ut,prefixedName:()=>po,primaryExpression:()=>Jo,prologue:()=>He,propertyList:()=>om,propertyListNotEmpty:()=>Ls,propertyListPath:()=>lm,propertyListPathNotEmpty:()=>_s,quadData:()=>bl,quadPattern:()=>ks,quads:()=>_r,quadsNotTriples:()=>Al,query:()=>Er,queryOrUpdate:()=>DS,queryUnit:()=>CS,rdfLiteral:()=>Ft,regexExpression:()=>Md,relationalExpression:()=>Pm,selectClause:()=>Ns,selectQuery:()=>gn,serviceGraphPattern:()=>Vo,solutionModifier:()=>ze,sourceSelector:()=>yo,strReplaceExpression:()=>Gd,string:()=>ds,stringEscapedLexical:()=>un,subSelect:()=>qo,substringExpression:()=>Dd,triplesBlock:()=>ft,triplesNode:()=>Co,triplesNodePath:()=>Mo,triplesSameSubject:()=>im,triplesSameSubjectPath:()=>sm,triplesTemplate:()=>Jt,unaryExpression:()=>Ss,update:()=>Ps,update1:()=>Lr,updateUnit:()=>MS,usingClause:()=>Lf,usingClauseStar:()=>gs,validateDescribeQuery:()=>Qd,validateFunctionCall:()=>fn,validateGroupGraphPattern:()=>No,validateGroupGraphPatternSub:()=>Po,validateQuery:()=>pn,validateSelectQuery:()=>Xd,validateSubSelect:()=>So,validateUpdate:()=>hn,valueLogical:()=>Qo,valuesClause:()=>An,varOrIri:()=>bt,varOrTerm:()=>ge,var_:()=>Q,verb:()=>go,verbA:()=>Bt,verbPath:()=>um,verbSimple:()=>pm,whereClause:()=>We});var ve={};Mt(ve,{a:()=>Tr,add:()=>Ki,allBaseTokens:()=>lf,as:()=>kt,ask:()=>Si,baseDecl:()=>bi,bind:()=>ts,builtIn:()=>E,by:()=>ln,clear:()=>$i,construct:()=>_i,copy:()=>zi,create:()=>ji,deleteClause:()=>Qi,deleteDataClause:()=>qi,deleteWhereClause:()=>Xi,describe:()=>Oi,distinct:()=>et,drop:()=>Vi,false_:()=>os,filter:()=>ss,from:()=>Ni,graph:()=>Ee,groupByGroup:()=>on,having:()=>Pi,in_:()=>ls,insertClause:()=>Zi,insertDataClause:()=>Bi,limit:()=>Fi,load:()=>Di,loadInto:()=>Gi,minus:()=>ns,modifyWith:()=>Yi,move:()=>Wi,notIn:()=>cs,offset:()=>Ci,optional:()=>Ui,order:()=>ki,orderAsc:()=>wi,orderDesc:()=>Ri,patterns:()=>io,prefixDecl:()=>Ii,reduced:()=>Li,select:()=>Ei,separator:()=>us,service:()=>es,silent:()=>yt,sparql11LexerBuilder:()=>gS,symbols:()=>T,terminals:()=>R,to:()=>Hi,true_:()=>as,undef:()=>rs,union:()=>is,usingClause:()=>Ji,values:()=>Mi,where:()=>wt});var E={};Mt(E,{BuiltInCalls:()=>L,abs:()=>up,allBuiltInCalls:()=>Ma,avg:()=>di,bnode:()=>lp,bound:()=>sp,ceil:()=>pp,coalesce:()=>Vp,concat:()=>dp,contains:()=>yp,count:()=>th,datatype:()=>ip,day:()=>_p,encode_for_uri:()=>vp,exists:()=>Up,floor:()=>hp,groupConcat:()=>mi,hours:()=>Op,if_:()=>jp,iri:()=>ap,isblank:()=>qp,isiri:()=>zp,isliteral:()=>Xp,isnumeric:()=>Qp,isuri:()=>Yp,lang:()=>rp,langmatches:()=>np,lcase:()=>Tp,max:()=>ih,md5:()=>Cp,min:()=>nh,minutes:()=>Sp,month:()=>Lp,notexists:()=>eh,now:()=>wp,rand:()=>cp,regex:()=>Bp,replace:()=>Jp,round:()=>fp,sameterm:()=>Wp,sample:()=>sh,seconds:()=>Np,sha1:()=>Mp,sha256:()=>Dp,sha384:()=>Gp,sha512:()=>$p,str:()=>tp,strafter:()=>Ip,strbefore:()=>bp,strdt:()=>Hp,strends:()=>xp,strlang:()=>Kp,strlen:()=>mp,strstarts:()=>Ap,struuid:()=>Fp,substr:()=>Zp,sum:()=>rh,timezone:()=>Pp,tz:()=>kp,ucase:()=>gp,uri:()=>op,uuid:()=>Rp,year:()=>Ep});var L;(function(e){e.Str="builtInStr",e.Lang="builtInLang",e.Langmatches="builtInLangmatches",e.Datatype="builtInDatatype",e.Bound="builtInBound",e.Iri="builtInIri",e.Uri="builtInUri",e.Bnode="builtInBnode",e.Rand="builtInRand",e.Abs="builtInAbs",e.Ceil="builtInCeil",e.Floor="builtInFloor",e.Round="builtInRound",e.Concat="builtInConcat",e.Strlen="builtInStrlen",e.Ucase="builtInUcase",e.Lcase="builtInLcase",e.Encode_for_uri="builtInEncode_for_uri",e.Contains="builtInContains",e.Strstarts="builtInStrstarts",e.Strends="builtInStrends",e.Strbefore="builtInStrbefore",e.Strafter="builtInStrafter",e.Year="builtInYear",e.Month="builtInMonth",e.Day="builtInDay",e.Hours="builtInHours",e.Minutes="builtInMinutes",e.Seconds="builtInSeconds",e.Timezone="builtInTimezone",e.Tz="builtInTz",e.Now="builtInNow",e.Uuid="builtInUuid",e.Struuid="builtInStruuid",e.Md5="builtInMd5",e.Sha1="builtInSha1",e.Sha256="builtInSha256",e.Sha384="builtInSha384",e.Sha512="builtInSha512",e.Coalesce="builtInCoalesce",e.If="builtInIf",e.Strlang="builtInStrlang",e.Strdt="builtInStrdt",e.Sameterm="builtInSameterm",e.Isiri="builtInIsiri",e.Isuri="builtInIsuri",e.Isblank="builtInIsblank",e.Isliteral="builtInIsliteral",e.Isnumeric="builtInIsnumeric",e.Regex="builtInRegex",e.Substr="builtInSubstr",e.Replace="builtInReplace",e.Exists="builtInExists",e.Notexists="builtInNotexists",e.Count="builtInCount",e.Sum="builtInSum",e.Min="builtInMin",e.Max="builtInMax",e.Avg="builtInAvg",e.Sample="builtInSample",e.Group_concat="builtInGroup_concat"})(L||(L={}));function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}var tp=d({name:_(L.Str),pattern:/str/i,label:"STR"}),rp=d({name:_(L.Lang),pattern:/lang/i,label:"LANG"}),np=d({name:_(L.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),ip=d({name:_(L.Datatype),pattern:/datatype/i,label:"DATATYPE"}),sp=d({name:_(L.Bound),pattern:/bound/i,label:"BOUND"}),ap=d({name:_(L.Iri),pattern:/iri/i,label:"IRI"}),op=d({name:_(L.Uri),pattern:/uri/i,label:"URI"}),lp=d({name:_(L.Bnode),pattern:/bnode/i,label:"BNODE"}),cp=d({name:_(L.Rand),pattern:/rand/i,label:"RAND"}),up=d({name:_(L.Abs),pattern:/abs/i,label:"ABS"}),pp=d({name:_(L.Ceil),pattern:/ceil/i,label:"CEIL"}),hp=d({name:_(L.Floor),pattern:/floor/i,label:"FLOOR"}),fp=d({name:_(L.Round),pattern:/round/i,label:"ROUND"}),dp=d({name:_(L.Concat),pattern:/concat/i,label:"CONCAT"}),mp=d({name:_(L.Strlen),pattern:/strlen/i,label:"STRLEN"}),gp=d({name:_(L.Ucase),pattern:/ucase/i,label:"UCASE"}),Tp=d({name:_(L.Lcase),pattern:/lcase/i,label:"LCASE"}),vp=d({name:_(L.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),yp=d({name:_(L.Contains),pattern:/contains/i,label:"CONTAINS"}),Ap=d({name:_(L.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),xp=d({name:_(L.Strends),pattern:/strends/i,label:"STRENDS"}),bp=d({name:_(L.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),Ip=d({name:_(L.Strafter),pattern:/strafter/i,label:"STRAFTER"}),Ep=d({name:_(L.Year),pattern:/year/i,label:"YEAR"}),Lp=d({name:_(L.Month),pattern:/month/i,label:"MONTH"}),_p=d({name:_(L.Day),pattern:/day/i,label:"DAY"}),Op=d({name:_(L.Hours),pattern:/hours/i,label:"HOURS"}),Sp=d({name:_(L.Minutes),pattern:/minutes/i,label:"MINUTES"}),Np=d({name:_(L.Seconds),pattern:/seconds/i,label:"SECONDS"}),Pp=d({name:_(L.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),kp=d({name:_(L.Tz),pattern:/tz/i,label:"TZ"}),wp=d({name:_(L.Now),pattern:/now/i,label:"NOW"}),Rp=d({name:_(L.Uuid),pattern:/uuid/i,label:"UUID"}),Fp=d({name:_(L.Struuid),pattern:/struuid/i,label:"STRUUID"}),Cp=d({name:_(L.Md5),pattern:/md5/i,label:"MD5"}),Mp=d({name:_(L.Sha1),pattern:/sha1/i,label:"SHA1"}),Dp=d({name:_(L.Sha256),pattern:/sha256/i,label:"SHA256"}),Gp=d({name:_(L.Sha384),pattern:/sha384/i,label:"SHA384"}),$p=d({name:_(L.Sha512),pattern:/sha512/i,label:"SHA512"}),Vp=d({name:_(L.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),jp=d({name:_(L.If),pattern:/if/i,label:"IF"}),Kp=d({name:_(L.Strlang),pattern:/strlang/i,label:"STRLANG"}),Hp=d({name:_(L.Strdt),pattern:/strdt/i,label:"STRDT"}),Wp=d({name:_(L.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),zp=d({name:_(L.Isiri),pattern:/isiri/i,label:"ISIRI"}),Yp=d({name:_(L.Isuri),pattern:/isuri/i,label:"ISURI"}),qp=d({name:_(L.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Xp=d({name:_(L.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Qp=d({name:_(L.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),Bp=d({name:_(L.Regex),pattern:/regex/i,label:"REGEX"}),Zp=d({name:_(L.Substr),pattern:/substr/i,label:"SUBSTR"}),Jp=d({name:_(L.Replace),pattern:/replace/i,label:"REPLACE"}),Up=d({name:_(L.Exists),pattern:/exists/i,label:"EXISTS"}),eh=d({name:_(L.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),th=d({name:_(L.Count),pattern:/count/i,label:"COUNT"}),rh=d({name:_(L.Sum),pattern:/sum/i,label:"SUM"}),nh=d({name:_(L.Min),pattern:/min/i,label:"MIN"}),ih=d({name:_(L.Max),pattern:/max/i,label:"MAX"}),di=d({name:_(L.Avg),pattern:/avg/i,label:"AVG"}),sh=d({name:_(L.Sample),pattern:/sample/i,label:"SAMPLE"}),mi=d({name:_(L.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),Ma=Ie.create().add(np,ip,rp,sp,ap,op,lp,cp,up,pp,hp,fp,dp,mp,gp,Tp,vp,yp,Ap,xp,bp,Ip,Ep,Lp,_p,Op,Sp,Np,Pp,kp,wp,Rp,Fp,Cp,Mp,Dp,Gp,$p,Vp,jp,Kp,Hp,Wp,zp,Yp,qp,Xp,Qp,Bp,Zp,Jp,Up,eh,th,rh,nh,ih,di,sh,mi,tp);var Ee={};Mt(Ee,{allGraphTokens:()=>Da,default_:()=>oh,graph:()=>lh,graphAll:()=>gi,named:()=>ah});var ah=d({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),oh=d({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),lh=d({name:"Graph",pattern:/graph/i,label:"GRAPH"}),gi=d({name:"GraphAll",pattern:/all/i,label:"ALL"}),Da=Ie.create().add(ah,oh,lh,gi);var io={};Mt(io,{anonPattern:()=>no,atLeastOneBlankPattern:()=>an,blankNodeLabelPattern:()=>Ka,commentPattern:()=>xi,decimalNegativePattern:()=>Ba,decimalPattern:()=>rn,decimalPositivePattern:()=>qa,doubleNegativePattern:()=>Za,doublePattern:()=>nn,doublePositivePattern:()=>Xa,echarPattern:()=>sn,exponentPattern:()=>vi,integerNegativePattern:()=>Qa,integerPattern:()=>tn,integerPositivePattern:()=>Ya,iriRefPattern:()=>Va,langTagPattern:()=>za,nilPattern:()=>ro,pNameLnPattern:()=>ja,pNameNsPattern:()=>yi,percentPattern:()=>uh,plxPattern:()=>Ti,pnCharsBasePattern:()=>Ga,pnCharsPattern:()=>Yt,pnCharsUPattern:()=>mr,pnLocalEscPattern:()=>Ai,pnLocalPattern:()=>ph,pnPrefixPattern:()=>ch,stringLiteral1Pattern:()=>Ja,stringLiteral2Pattern:()=>Ua,stringLiteralLong1Pattern:()=>eo,stringLiteralLong2Pattern:()=>to,var1Pattern:()=>Ha,var2Pattern:()=>Wa,varNamePattern:()=>$a,wsPattern:()=>gr});var Ga=/[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/,mr=new RegExp(`(${Ga.source})|_`),$a=new RegExp(`((${mr.source})|[0-9])((${mr.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),Va=/<([^\u0000-\u0020"<>\\^`{|}])*>/,Yt=new RegExp(`(${mr.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),ch=new RegExp(`(${Ga.source})(((${Yt.source})|\\.)*(${Yt.source}))?`),yi=new RegExp(`(${ch.source})?:`),uh=/%[\dA-Fa-f]{2}/,Ai=/\\[!#$%&'()*+,./;=?@_~-]/,Ti=new RegExp(`(${uh.source})|(${Ai.source})`),ph=new RegExp(`((${mr.source})|:|[0-9]|(${Ti.source}))(((${Yt.source})|\\.|:|(${Ti.source}))*((${Yt.source})|:|(${Ti.source})))?`),ja=new RegExp(`(${yi.source})(${ph.source})`),Ka=new RegExp(`_:((${mr.source})|[0-9])(((${Yt.source})|\\.)*(${Yt.source}))?`),Ha=new RegExp(`\\?(${$a.source})`),Wa=new RegExp(`\\$(${$a.source})`),za=/@[A-Za-z]+(-[\dA-Za-z]+)*/,tn=/\d+/,rn=/\d+\.\d+/,vi=/[Ee][+-]?\d+/,nn=new RegExp(`([0-9]+\\.[0-9]*(${vi.source}))|(\\.[0-9]+(${vi.source}))|([0-9]+(${vi.source}))`),Ya=new RegExp(`\\+(${tn.source})`),qa=new RegExp(`\\+(${rn.source})`),Xa=new RegExp(`\\+(${nn.source})`),Qa=new RegExp(`-(${tn.source})`),Ba=new RegExp(`-(${rn.source})`),Za=new RegExp(`-(${nn.source})`),sn=/\\["'\\bfnrt]/,Ja=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${sn.source}))*'`),Ua=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${sn.source}))*"`),eo=new RegExp(`'''(('|(''))?([^'\\\\]|(${sn.source})))*'''`),to=new RegExp(`"""(("|(""))?([^"\\\\]|(${sn.source})))*"""`),gr=/[\u0009\u000A\u000D ]/,ro=new RegExp(`\\((${gr.source})*\\)`),no=new RegExp(`\\[(${gr.source})*\\]`),xi=/#[^\n\r]*/,an=new RegExp(`(((${gr.source})+)|((${xi.source})(\r +|\r| +)))+`);var T={};Mt(T,{LCurly:()=>hh,LParen:()=>Th,LSquare:()=>yh,RCurly:()=>fh,RParen:()=>vh,RSquare:()=>Ah,allSymbols:()=>so,comma:()=>mh,dot:()=>dh,equal:()=>kh,exclamation:()=>Sh,greaterThan:()=>Fh,greaterThanEqual:()=>Mh,hat:()=>Ih,hathat:()=>Dh,lessThan:()=>Rh,lessThanEqual:()=>Ch,logicAnd:()=>Nh,logicOr:()=>Ph,notEqual:()=>wh,opMinus:()=>Oh,opPlus:()=>_h,pipe:()=>xh,question:()=>Eh,semi:()=>gh,slash:()=>bh,star:()=>Lh});var hh=d({name:"LCurly",pattern:"{",label:"{"}),fh=d({name:"RCurly",pattern:"}",label:"}"}),dh=d({name:"Dot",pattern:".",label:"."}),mh=d({name:"Comma",pattern:",",label:","}),gh=d({name:"Semi",pattern:";",label:";"}),Th=d({name:"LParen",pattern:"(",label:"("}),vh=d({name:"RParen",pattern:")",label:")"}),yh=d({name:"LSquare",pattern:"[",label:"["}),Ah=d({name:"RSquare",pattern:"]",label:"]"}),xh=d({name:"Pipe",pattern:"|",label:"|"}),bh=d({name:"Slash",pattern:"/",label:"/"}),Ih=d({name:"Hat",pattern:"^",label:"^"}),Eh=d({name:"Question",pattern:"?",label:"?"}),Lh=d({name:"Star",pattern:"*",label:"*"}),_h=d({name:"OpPlus",pattern:"+",label:"+"}),Oh=d({name:"OpMinus",pattern:"-",label:"-"}),Sh=d({name:"Exclamation",pattern:"!",label:"!"}),Nh=d({name:"LogicAnd",pattern:"&&",label:"&&"}),Ph=d({name:"LogicOr",pattern:"||",label:"||"}),kh=d({name:"Equal",pattern:"=",label:"="}),wh=d({name:"NotEqual",pattern:"!=",label:"!="}),Rh=d({name:"LessThan",pattern:"<",label:"<"}),Fh=d({name:"GreaterThan",pattern:">",label:">"}),Ch=d({name:"LessThanEqual",pattern:"<=",label:"<="}),Mh=d({name:"GreaterThanEqual",pattern:">=",label:">="}),Dh=d({name:"Hathat",pattern:"^^",label:"^^"}),so=Ie.create().add(Nh,Ph,wh,Ch,Mh,hh,fh,dh,mh,gh,Th,vh,yh,Ah,xh,bh,Dh,Ih,Eh,Lh,_h,Oh,Sh,kh,Rh,Fh);var R={};Mt(R,{allTerminals:()=>oo,anon:()=>of,blankNodeLabel:()=>Vh,comment:()=>sf,decimal:()=>zh,decimalNegative:()=>Zh,decimalPositive:()=>Xh,double:()=>Yh,doubleNegative:()=>Jh,doublePositive:()=>Qh,integer:()=>Wh,integerNegative:()=>Bh,integerPositive:()=>qh,iriRef:()=>Gh,langTag:()=>Hh,nil:()=>af,pNameLn:()=>ao,pNameNs:()=>$h,stringLiteral1:()=>Uh,stringLiteral2:()=>ef,stringLiteralLong1:()=>tf,stringLiteralLong2:()=>rf,var1:()=>jh,var2:()=>Kh,ws:()=>nf});var Gh=d({name:"IriRef",pattern:Va}),ao=d({name:"PNameLn",pattern:ja}),$h=d({name:"PNameNs",pattern:yi,longer_alt:[ao]}),Vh=d({name:"BlankNodeLabel",pattern:Ka}),jh=d({name:"Var1",pattern:Ha}),Kh=d({name:"Var2",pattern:Wa}),Hh=d({name:"LangTag",pattern:za}),Wh=d({name:"Integer",pattern:tn}),zh=d({name:"Decimal",pattern:rn}),Yh=d({name:"Double",pattern:nn}),qh=d({name:"IntegerPositive",pattern:Ya}),Xh=d({name:"DecimalPositive",pattern:qa}),Qh=d({name:"DoublePositive",pattern:Xa}),Bh=d({name:"IntegerNegative",pattern:Qa}),Zh=d({name:"DecimalNegative",pattern:Ba}),Jh=d({name:"DoubleNegative",pattern:Za}),Uh=d({name:"StringLiteral1",pattern:Ja}),ef=d({name:"StringLiteral2",pattern:Ua}),tf=d({name:"StringLiteralLong1",pattern:eo}),rf=d({name:"StringLiteralLong2",pattern:to}),nf=d({name:"Ws",pattern:gr,group:me.SKIPPED}),sf=d({name:"Comment",pattern:xi,group:me.SKIPPED}),af=d({name:"Nil",pattern:ro}),of=d({name:"Anon",pattern:no}),oo=Ie.create().add(Gh,$h,ao,Vh,jh,Kh,Hh,Yh,zh,Wh,Qh,Xh,qh,Jh,Zh,Bh,tf,rf,Uh,ef,nf,sf,af,of);var bi=d({name:"BaseDecl",pattern:/base/i,label:"BASE"}),Ii=d({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),Ei=d({name:"Select",pattern:/select/i,label:"SELECT"}),et=d({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),Li=d({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),kt=d({name:"As",pattern:/as/i,label:"AS"}),_i=d({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),Oi=d({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),Si=d({name:"Ask",pattern:/ask/i,label:"ASK"}),Ni=d({name:"From",pattern:/from/i,label:"FROM"}),wt=d({name:"Where",pattern:/where/i,label:"WHERE"}),on=d({name:"GroupByGroup",pattern:/group/i,label:"_GROUP_ BY"}),ln=d({name:"By",pattern:/by/i,label:"BY"}),Pi=d({name:"Having",pattern:/having/i,label:"HAVING"}),ki=d({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),wi=d({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Ri=d({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),Fi=d({name:"Limit",pattern:/limit/i,label:"LIMIT"}),Ci=d({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Mi=d({name:"Values",pattern:/values/i,label:"VALUES"}),Di=d({name:"Load",pattern:/load/i,label:"LOAD"}),yt=d({name:"Silent",pattern:/silent/i,label:"SILENT"}),Gi=d({name:"LoadInto",pattern:/into/i,label:"INTO"}),$i=d({name:"Clear",pattern:/clear/i,label:"CLEAR"}),Vi=d({name:"Drop",pattern:/drop/i,label:"DROP"}),ji=d({name:"Create",pattern:/create/i,label:"CREATE"}),Ki=d({name:"Add",pattern:/add/i,label:"ADD"}),Hi=d({name:"To",pattern:/to/i,label:"TO"}),Wi=d({name:"Move",pattern:/move/i,label:"MOVE"}),zi=d({name:"Copy",pattern:/copy/i,label:"COPY"}),Yi=d({name:"ModifyWith",pattern:/with/i,label:"WITH"}),qi=d({name:"DeleteDataClause",pattern:new RegExp(`delete(${an.source})data`,"i"),label:"DELETE DATA"}),Xi=d({name:"DeleteWhereClause",pattern:new RegExp(`delete(${an.source})where`,"i"),label:"DELETE WHERE"}),Qi=d({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),Bi=d({name:"InsertDataClause",pattern:new RegExp(`insert(${an.source})data`,"i"),label:"INSERT DATA"}),Zi=d({name:"InsertClause",pattern:/insert/i,label:"insert"}),Ji=d({name:"UsingClause",pattern:/using/i,label:"USING"}),Ui=d({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),es=d({name:"Service",pattern:/service/i,label:"SERVICE"}),ts=d({name:"Bind",pattern:/bind/i,label:"BIND"}),rs=d({name:"Undef",pattern:/undef/i,label:"UNDEF"}),ns=d({name:"Minus",pattern:/minus/i,label:"MINUS"}),is=d({name:"Union",pattern:/union/i,label:"UNION"}),ss=d({name:"Filter",pattern:/filter/i,label:"FILTER"}),Tr=d({name:"a",pattern:"a",label:"type declaration 'a'"}),as=d({name:"True",pattern:/true/i,label:"true"}),os=d({name:"False",pattern:/false/i,label:"false"}),ls=d({name:"In",pattern:/in/i,label:"IN"}),cs=d({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),us=d({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),lf=Ie.create().add(bi,Ii,Ei,et,Li,_i,Oi,Si,Ni,wt,Pi,on,ln,ki,wi,Ri,Fi,Ci,Mi,Di,yt,Gi,$i,Vi,ji,Ki,Hi,Wi,zi,Yi,Xi,qi,Qi,Bi,Zi,Ji,Ui,es,ts,rs,ns,is,ss,kt,Tr,as,os,ls,cs,us),gS=Ie.create(oo).merge(lf).merge(Ma).merge(Da).merge(so).moveAfter(di,Tr).moveBefore(Tr,gi).moveAfter(mi,on);var lo="contextDef";function cf(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:lo,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,lo,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,lo,"base")}}}var pt="expression";function uf(e){return class extends e{isExpressionPure(r){return this.isOfType(r,pt)}formatOperator(r){return r.toLowerCase().replaceAll(" ","")}expressionOperation(r,n,i){return{type:pt,subType:"operation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionOperator(r){return this.isOfSubType(r,pt,"operation")}expressionFunctionCall(r,n,i,s){return{type:"expression",subType:"functionCall",function:r,args:n,distinct:i,loc:s}}isExpressionFunctionCall(r){return this.isOfSubType(r,pt,"functionCall")}expressionPatternOperation(r,n,i){return{type:pt,subType:"patternOperation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionPatternOperation(r){return this.isOfSubType(r,pt,"patternOperation")}aggregate(r,n,i,s,a){let o={type:"expression",subType:"aggregate",aggregation:this.formatOperator(r),distinct:n,loc:a};return this.isOfType(i,"wildcard")?{...o,expression:[i]}:s===void 0?{...o,expression:[i]}:{...o,expression:[i],separator:s}}isExpressionAggregate(r){return this.isOfSubType(r,pt,"aggregate")}isExpressionAggregateSeparator(r){return this.isOfSubType(r,pt,"aggregate")&&typeof r.separator=="string"}isExpressionAggregateOnWildcard(r){let n=r;return this.isOfSubType(r,pt,"aggregate")&&Array.isArray(n.expression)&&n.expression.length===1&&this.isOfType(n.expression[0],"wildcard")}isExpressionAggregateDefault(r){let n=r;return this.isOfSubType(r,pt,"operation")&&Array.isArray(n.expression)&&n.expression.length===1&&!this.isOfType(n.expression[0],"wildcard")}}}var At="graphRef";function pf(e){return class extends e{isGraphRef(r){return this.isOfType(r,At)}graphRefDefault(r){return{type:At,subType:"default",loc:r}}isGraphRefDefault(r){return this.isOfSubType(r,At,"default")}graphRefNamed(r){return{type:At,subType:"named",loc:r}}isGraphRefNamed(r){return this.isOfSubType(r,At,"named")}graphRefAll(r){return{type:At,subType:"all",loc:r}}isGraphRefAll(r){return this.isOfSubType(r,At,"all")}graphRefSpecific(r,n){return{type:At,subType:"specific",graph:r,loc:n}}isGraphRefSpecific(r){return this.isOfSubType(r,At,"specific")}}}function hf(e){return new co(e)}var co=class{input;constructor(t){this.input=t}call(t){return this.input=t(this.input),this}returns(){return this.input}};var Ke="path";function ff(e){return class extends e{isPathPure(r){return this.isOfType(r,Ke)}path(r,n,i){let s={type:Ke,loc:i,items:n};if(r==="|"||r==="/")return{...s,subType:r};if((r==="?"||r==="*"||r==="+"||r==="^"&&this.isPathPure(n[0]))&&n.length===1)return{...s,subType:r,items:n};if(r==="^"&&n.length===1&&!this.isPathPure(n[0]))return{...s,subType:r,items:n};if(r==="!"&&n.length===1&&(this.isPathAlternativeLimited(n[0])||!this.isPathPure(n[0])||this.isPathNegatedElt(n[0])))return{...s,subType:r,items:n};throw new Error("Invalid path type")}isPathOfType(r,n){return this.isOfType(r,Ke)&&n.includes(r.subType)}isPathChain(r){return this.isOfSubType(r,Ke,"/")||this.isOfSubType(r,Ke,"|")}isPathModified(r){return this.isOfSubType(r,Ke,"?")||this.isOfSubType(r,Ke,"*")||this.isOfSubType(r,Ke,"+")||this.isOfSubType(r,Ke,"^")}isPathNegatedElt(r){let n=r;return this.isOfSubType(r,Ke,"^")&&Array.isArray(n.items)&&n.items.length===1&&n.items[0]!==null&&typeof n.items[0]=="object"&&!this.isPathPure(n.items[0])}isPathNegated(r){return this.isOfSubType(r,Ke,"!")}isPathAlternativeLimited(r){let n=r;return this.isOfSubType(r,Ke,"|")&&Array.isArray(n.items)&&n.items.every(i=>!this.isPathPure(i)||this.isPathNegatedElt(i))}}}var ie="pattern";function df(e){return class extends e{isPattern(r){return this.isOfType(r,ie)}patternBgp(r,n){return{type:ie,subType:"bgp",triples:r,loc:n}}isPatternBgp(r){return this.isOfSubType(r,ie,"bgp")}patternGroup(r,n){return{type:ie,subType:"group",patterns:r,loc:n}}isPatternGroup(r){return this.isOfSubType(r,ie,"group")}patternGraph(r,n,i){return{type:ie,subType:"graph",name:r,patterns:n,loc:i}}isPatternGraph(r){return this.isOfSubType(r,ie,"graph")}patternOptional(r,n){return{type:ie,subType:"optional",patterns:r,loc:n}}isPatternOptional(r){return this.isOfSubType(r,ie,"optional")}patternValues(r,n,i){return{type:ie,subType:"values",variables:r,values:n,loc:i}}isPatternValues(r){return this.isOfSubType(r,ie,"values")}patternFilter(r,n){return{type:ie,subType:"filter",expression:r,loc:n}}isPatternFilter(r){return this.isOfSubType(r,ie,"filter")}patternBind(r,n,i){return{type:ie,subType:"bind",expression:r,variable:n,loc:i}}isPatternBind(r){return this.isOfSubType(r,ie,"bind")}patternUnion(r,n){return{type:ie,subType:"union",patterns:r,loc:n}}isPatternUnion(r){return this.isOfSubType(r,ie,"union")}patternMinus(r,n){return{type:ie,subType:"minus",patterns:r,loc:n}}isPatternMinus(r){return this.isOfSubType(r,ie,"minus")}patternService(r,n,i,s){return{type:ie,subType:"service",silent:i,name:r,patterns:n,loc:s}}isPatternService(r){return this.isOfSubType(r,ie,"service")}}}var vr="query";function mf(e){return class extends e{isQuery(r){return this.isOfType(r,vr)}isQuerySelect(r){return this.isOfSubType(r,vr,"select")}queryConstruct(r,n,i,s,a,o,l){return{type:"query",subType:"construct",context:n,template:i,where:s,solutionModifiers:a,datasets:o,values:l,loc:r}}isQueryConstruct(r){return this.isOfSubType(r,vr,"construct")}isQueryDescribe(r){return this.isOfSubType(r,vr,"describe")}isQueryAsk(r){return this.isOfSubType(r,vr,"ask")}querySelect(r,n){return{type:vr,subType:"select",...r,loc:n}}}}var Rt="solutionModifier";function gf(e){return class extends e{isSolutionModifier(r){return this.isOfType(r,Rt)}solutionModifierHaving(r,n){return{type:Rt,subType:"having",having:r,loc:n}}isSolutionModifierHaving(r){return this.isOfSubType(r,Rt,"having")}solutionModifierOrder(r,n){return{type:Rt,subType:"order",orderDefs:r,loc:n}}isSolutionModifierOrder(r){return this.isOfSubType(r,Rt,"order")}solutionModifierLimitOffset(r,n,i){return{type:Rt,subType:"limitOffset",limit:r,offset:n,loc:i}}isSolutionModifierLimitOffset(r){return this.isOfSubType(r,Rt,"limitOffset")}solutionModifierGroup(r,n){return{type:"solutionModifier",subType:"group",groupings:r,loc:n}}isSolutionModifierGroup(r){return this.isOfSubType(r,Rt,"group")}}}var qt="term";function Tf(e){return class extends e{__blankNodeCounter=0;resetBlankNodeCounter(){this.__blankNodeCounter=0}isTerm(r){return this.isOfType(r,"term")}termBlank(r,n){let i={type:"term",subType:"blankNode",loc:n};return r===void 0?{...i,label:`g_${this.__blankNodeCounter++}`}:{...i,label:`e_${r}`}}isTermBlank(r){return this.isOfSubType(r,qt,"blankNode")}termLiteral(r,n,i){return{type:qt,subType:"literal",value:n,langOrIri:i,loc:r}}isTermLiteral(r){return this.isOfSubType(r,qt,"literal")}isTermLiteralLangStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri=="string"}isTermLiteralStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri>"u"}isTermLiteralTyped(r){let n=r;return this.isTermLiteral(r)&&typeof n.langOrIri=="object"&&n.langOrIri!==null&&this.isTermNamed(n.langOrIri)}termVariable(r,n){return{type:qt,subType:"variable",value:r,loc:n}}isTermVariable(r){return this.isOfSubType(r,qt,"variable")}termNamed(r,n,i){let s={type:qt,subType:"namedNode",value:n,loc:r};return i===void 0?s:{...s,prefix:i}}isTermNamed(r){return this.isOfSubType(r,qt,"namedNode")}isTermNamedPrefixed(r){let n=r;return this.isTermNamed(r)&&typeof n.prefix=="string"}}}var Fe="updateOperation";function vf(e){return class extends e{isUpdateOperation(r){return this.isOfType(r,Fe)}updateOperationLoad(r,n,i,s){return{type:Fe,subType:"load",silent:i,source:n,...s&&{destination:s},loc:r}}isUpdateOperationLoad(r){return this.isOfSubType(r,Fe,"load")}updateOperationClearDrop(r,n,i,s){return{type:"updateOperation",subType:r,silent:n,destination:i,loc:s}}updateOperationClear(r,n,i){return this.updateOperationClearDrop("clear",n,r,i)}isUpdateOperationClear(r){return this.isOfSubType(r,Fe,"clear")}updateOperationDrop(r,n,i){return this.updateOperationClearDrop("drop",n,r,i)}isUpdateOperationDrop(r){return this.isOfSubType(r,Fe,"drop")}updateOperationCreate(r,n,i){return{type:"updateOperation",subType:"create",silent:n,destination:r,loc:i}}isUpdateOperationCreate(r){return this.isOfSubType(r,Fe,"create")}updateOperationAddMoveCopy(r,n,i,s,a){return{type:"updateOperation",subType:r,silent:s,source:n,destination:i,loc:a}}updateOperationAdd(r,n,i,s){return this.updateOperationAddMoveCopy("add",r,n,i,s)}isUpdateOperationAdd(r){return this.isOfSubType(r,Fe,"add")}updateOperationMove(r,n,i,s){return this.updateOperationAddMoveCopy("move",r,n,i,s)}isUpdateOperationMove(r){return this.isOfSubType(r,Fe,"move")}updateOperationCopy(r,n,i,s){return this.updateOperationAddMoveCopy("copy",r,n,i,s)}isUpdateOperationCopy(r){return this.isOfSubType(r,Fe,"copy")}updateOperationInsDelDataWhere(r,n,i){return{type:"updateOperation",subType:r,data:n,loc:i}}updateOperationInsertData(r,n){return this.updateOperationInsDelDataWhere("insertdata",r,n)}isUpdateOperationInsertData(r){return this.isOfSubType(r,Fe,"insertdata")}updateOperationDeleteData(r,n){return this.updateOperationInsDelDataWhere("deletedata",r,n)}isUpdateOperationDeleteData(r){return this.isOfSubType(r,Fe,"deletedata")}updateOperationDeleteWhere(r,n){return this.updateOperationInsDelDataWhere("deletewhere",r,n)}isUpdateOperationDeleteWhere(r){return this.isOfSubType(r,Fe,"deletewhere")}updateOperationModify(r,n,i,s,a,o){return{type:"updateOperation",subType:"modify",insert:n??[],delete:i??[],graph:o,where:s,from:a,loc:r}}isUpdateOperationModify(r){return this.isOfSubType(r,Fe,"modify")}}}var xt=class extends hf(tr).call(cf).call(uf).call(pf).call(ff).call(df).call(mf).call(gf).call(Tf).call(vf).returns(){alwaysSparql11(t){return!0}isPath(t){return this.isPathPure(t)||this.isTermNamed(t)}isExpression(t){return this.isExpressionPure(t)||this.isTermNamed(t)||this.isTermVariable(t)||this.isTermLiteral(t)}graphNodeIdentifier(t){return t.type==="tripleCollection"?t.identifier:t}triple(t,r,n,i){return{type:"triple",subject:t,predicate:r,object:n,loc:i??this.sourceLocation(t,r,n)}}isTriple(t){return this.isOfType(t,"triple")}datasetClauses(t,r){return{type:"datasetClauses",clauses:t,loc:r}}isDatasetClauses(t){return this.isOfType(t,"datasetClauses")}wildcard(t){return{type:"wildcard",loc:t}}isWildcard(t){return this.isOfType(t,"wildcard")}isTripleCollection(t){return this.isOfType(t,"tripleCollection")}tripleCollectionBlankNodeProperties(t,r,n){return{type:"tripleCollection",subType:"blankNodeProperties",identifier:t,triples:r,loc:n}}isTripleCollectionBlankNodeProperties(t){return this.isOfSubType(t,"tripleCollection","blankNodeProperties")}tripleCollectionList(t,r,n){return{type:"tripleCollection",subType:"list",identifier:t,triples:r,loc:n}}isTripleCollectionList(t){return this.isOfSubType(t,"tripleCollection","list")}graphQuads(t,r,n){return{type:"graph",graph:t,triples:r,loc:n}}isGraphQuads(t){return super.isOfType(t,"graph")}isUpdate(t){return super.isOfType(t,"update")}};function yf(e){let t=e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(r,n,i)=>{if(n){let o=Number.parseInt(n,16);return String.fromCodePoint(o)}let s=Number.parseInt(i,16);if(s<65535)return String.fromCodePoint(s);let a=s-65536;return String.fromCodePoint(55296+(a>>10),56320+(a&1023))});if(/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(t))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint");return t}var le;(function(e){e.BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",e.INTEGER="http://www.w3.org/2001/XMLSchema#integer",e.DECIMAL="http://www.w3.org/2001/XMLSchema#decimal",e.DOUBLE="http://www.w3.org/2001/XMLSchema#double",e.STRING="http://www.w3.org/2001/XMLSchema#string",e.FIRST="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",e.REST="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",e.NIL="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",e.TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"})(le||(le={}));var cn=class extends en{constructor(t={},r={}){super(...TS(xf,t,r))}};function TS(e,t,r){if(t.ignoreKeys)return[t,r];let n={ignoreKeys:new Set(["loc"])};return[t,{...Object.fromEntries(Object.keys(e).map(i=>[i,n])),...r}]}var vS=/^[a-z][\d+.a-z-]*:/iu,yS=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su,AS=/^(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su;function ps(e){let t=e,r="",n=()=>{let i=r.lastIndexOf("/");r=r.slice(0,i>0?i:0)};for(;t.length>0;)if(t.startsWith("../"))t=t.slice(3);else if(t.startsWith("./")||t.startsWith("/./"))t=t.slice(2);else if(t==="/.")t="/";else if(t.startsWith("/../"))t=t.slice(3),n();else if(t==="/..")t="/",n();else if(t==="."||t==="..")t="";else{let i=t.indexOf("/",1),s=i===-1?t:t.slice(0,i);r+=s,t=t.slice(s.length)}return r}function uo(e,t){if(vS.test(e))return e;if(!t)throw new Error(`Cannot resolve relative IRI ${e} because no base IRI was set.`);let[,r,n,i,s]=AS.exec(e),[,a,o,l,u]=yS.exec(t),p,h,f;r===void 0?(n===""?(h=l,f=i??u):(n.startsWith("/")?h=ps(n):o!==void 0&&l===""?h=ps(`/${n}`):h=ps(l.slice(0,l.lastIndexOf("/")+1)+n),f=i),p=o):(p=r,h=ps(n),f=i);let m=a===void 0?"":`${a}:`;return p!==void 0&&(m+=`//${p}`),m+=h,f!==void 0&&(m+=`?${f}`),s!==void 0&&(m+=`#${s}`),m}var xS=new xt,bS=new RegExp(Ai.source,"gu");function Af(e,t,r){let n=e.value;if(xS.isTermNamedPrefixed(e)){let i=t[e.prefix];if(!i)throw new Error(`Unknown prefix: ${e.prefix}`);n=i+e.value.replaceAll(bS,s=>s.slice(1))}return uo(n,r)}var xf={path:{items:!0,loc:!1},pattern:{values:(e,{visitKey:t,stepIntoKey:r})=>{for(let n=e.length-1;n>=0;n--){let i=r(e,n);for(let s in i)t(i,s)}},name:!0,variable:!0,expression:!0,variables:!0,patterns:!0,triples:!0,loc:!1},update:{updates:dr("operation","context"),loc:!1},query:{values:!0,template:!0,context:!0,solutionModifiers:(e,{visitKey:t})=>{t(e,"group"),t(e,"having"),t(e,"order"),t(e,"limitOffset")},datasets:!0,where:!0,variables:!0,loc:!1},graph:{graph:!0,triples:!0,loc:!1},graphRef:{graph:!0,loc:!1},updateOperation:{data:!0,source:!0,destination:!0,from:!0,graph:!0,where:!0,delete:!0,insert:!0,loc:!1},datasetClauses:{clauses:dr("value"),loc:!1},tripleCollection:{triples:!0,identifier:!0,loc:!1},triple:{object:!0,subject:!0,predicate:!0,loc:!1},solutionModifier:{having:!0,orderDefs:dr("expression"),groupings:dr("variable","value"),loc:!1},expression:{function:!0,args:!0,expression:!0,loc:!1},contextDef:{value:!0,loc:!1},wildcard:{loc:!1},term:{langOrIri:!0,loc:!1}},Ok=Ca(xf);var IS={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function un(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>IS[r])}"`}var Ft={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>{let a=t(ds);return n(()=>i([{ALT:()=>{let o=r(R.langTag);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o.image.slice(1).toLowerCase()))}},{ALT:()=>{r(T.hathat);let o=t(G);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o))}}]))??a},gImpl:({SUBRULE:e,PRINT:t,PRINT_WORD:r})=>(n,{astFactory:i})=>{!n.langOrIri||typeof n.langOrIri=="string"?(i.printFilter(n,()=>{r(""),t(un(n.value))}),typeof n.langOrIri=="string"&&i.printFilter(n,()=>t("@",n.langOrIri))):i.isSourceLocationNoMaterialize(n.langOrIri.loc)?i.printFilter(n,()=>{r(n.value)}):(i.printFilter(n,()=>{r(""),t(un(n.value),"^^")}),e(G,n.langOrIri))}},Xt={name:"numericLiteral",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(bf)},{ALT:()=>e(hs)},{ALT:()=>e(fs)}])},bf={name:"numericLiteralUnsigned",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integer),le.INTEGER]},{ALT:()=>[t(R.decimal),le.DECIMAL]},{ALT:()=>[t(R.double),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},hs={name:"numericLiteralPositive",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integerPositive),le.INTEGER]},{ALT:()=>[t(R.decimalPositive),le.DECIMAL]},{ALT:()=>[t(R.doublePositive),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},fs={name:"numericLiteralNegative",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integerNegative),le.INTEGER]},{ALT:()=>[t(R.decimalNegative),le.DECIMAL]},{ALT:()=>[t(R.doubleNegative),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Qt={name:"booleanLiteral",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(as)},{ALT:()=>t(os)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),le.BOOLEAN)))}},ds={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(R.stringLiteral1);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(R.stringLiteral2);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(R.stringLiteralLong1);return[s,s.image.slice(3,-3)]}},{ALT:()=>{let s=t(R.stringLiteralLong2);return[s,s.image.slice(3,-3)]}}]);return e(()=>{let s=n.astFactory,a=i[1].replaceAll(/\\([tnrbf"'\\])/gu,(o,l)=>{switch(l){case"t":return" ";case"n":return` +`;case"r":return"\r";case"b":return"\b";case"f":return"\f";default:return l}});return s.termLiteral(s.sourceLocation(i[0]),a)})}},G={name:"iri",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(yr)},{ALT:()=>e(po)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(po,t):e(yr,t)},yr={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(R.iriRef);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),n.image.slice(1,-1)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("<",t.value,">"))}},po={name:"prefixedName",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{function i(s){if(!n.skipValidation&&n.prefixes[s]===void 0)throw new Error(`Unknown prefix: ${s}`)}return r([{ALT:()=>{let s=t(R.pNameLn);return e(()=>{let a=s.image.indexOf(":"),o=s.image.slice(0,a),l=s.image.slice(a+1);return i(o),n.astFactory.termNamed(n.astFactory.sourceLocation(s),l,o)})}},{ALT:()=>{let s=t(R.pNameNs);return e(()=>{let a=s.image.slice(0,-1);return i(a),n.astFactory.termNamed(n.astFactory.sourceLocation(s),"",a)})}}])},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(t.prefix,":",t.value))}},ES=Symbol("canCreateBlankNodes"),ms={name:"blankNode",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(R.blankNodeLabel);return e(()=>n.astFactory.termBlank(s.image.slice(2),n.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=t(R.anon);return e(()=>n.astFactory.termBlank(void 0,n.astFactory.sourceLocation(s)))}}]);return e(()=>{if(!n.parseMode.has("canCreateBlankNodes"))throw new Error("Blank nodes are not allowed in this context")}),i},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("_:",t.label.replace(/^e_/u,"")))}},Bt={name:"VerbA",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Tr);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),le.TYPE,void 0))}};var He={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(ho))},{ALT:()=>n.push(e(fo))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(ho,n):e(fo,n)}},ho={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(bi),s=r(yr);return e(()=>{try{n.baseIRI=uo(s.value,n.baseIRI)}catch{}return n.astFactory.contextDefinitionBase(n.astFactory.sourceLocation(i,s),s)})},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BASE ")),e(G,n.value),i.printFilter(n,()=>r())}},fo={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Ii),s=t(R.pNameNs).image.slice(0,-1),a=r(yr);return e(()=>(n.prefixes[s]=a.value,n.astFactory.contextDefinitionPrefix(n.astFactory.sourceLocation(i,a),s,a)))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("PREFIX ",`${n.key}: `)}),e(G,n.value),i.printFilter(n,()=>r())}},go={name:"verb",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(bt)},{ALT:()=>e(Bt)}])},ge={name:"varOrTerm",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(Q)},{ALT:()=>e(mo)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(Q,t):e(mo,t)},bt={name:"varOrIri",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(Q)},{ALT:()=>e(G)}])},Q={name:"var",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(R.var1)},{ALT:()=>t(R.var2)}]);return e(()=>n.astFactory.termVariable(i.image.slice(1),n.astFactory.sourceLocation(i)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(`?${t.value}`))}},mo={name:"graphTerm",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(G)},{ALT:()=>t(Ft)},{ALT:()=>t(Xt)},{ALT:()=>t(Qt)},{GATE:()=>i.parseMode.has("canCreateBlankNodes"),ALT:()=>t(ms)},{ALT:()=>{let s=r(R.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(s),le.NIL))}}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(G,t):r.isTermLiteral(t)?e(Ft,t):e(ms,t)}};function To(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i,OR:s})=>a=>{let o=i(t);return s([{ALT:()=>{let l=n(Ef);return r(()=>a.astFactory.wrap({clauseType:"default",value:l},a.astFactory.sourceLocation(o,l)))}},{ALT:()=>{let l=n(_f);return r(()=>a.astFactory.wrap({clauseType:"named",value:l.val},a.astFactory.sourceLocation(o,l)))}}])}}}var If=To("datasetClause",Ni),Ef={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(yo)},Lf=To("usingClause",Ji);function vo(e,t,r){return{name:e,impl:({ACTION:n,MANY:i,SUBRULE:s})=>a=>{let o=[];return i(()=>{let l=s(t);o.push(l)}),n(()=>a.astFactory.datasetClauses(o.map(l=>l.val),a.astFactory.sourceLocation(...o)))},gImpl:({SUBRULE:n,PRINT_WORD:i})=>(s,{astFactory:a})=>{for(let o of s.clauses)a.printFilter(s,()=>i(r)),o.clauseType==="named"&&a.printFilter(s,()=>i("NAMED")),n(G,o.value)}}}var tt=vo("datasetClauses",If,"FROM"),gs=vo("usingClauses",Lf,"USING"),_f={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.named),s=t(yo);return e(()=>n.astFactory.wrap(s,n.astFactory.sourceLocation(i,s)))}},yo={name:"sourceSelector",impl:({SUBRULE:e})=>()=>e(G)};function D(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(T.LParen);let a=r(k),o=n(T.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function rt(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>{let a=r(e);r(T.LParen);let o=n(k);r(T.comma);let l=i(k),u=r(T.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o,l],s.astFactory.sourceLocation(a,u)))}}}function Ao(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,CONSUME1:n,CONSUME2:i,SUBRULE1:s,SUBRULE2:a,SUBRULE3:o})=>l=>{let u=r(e);r(T.LParen);let p=s(k);n(T.comma);let h=a(k);i(T.comma);let f=o(k),m=r(T.RParen);return t(()=>l.astFactory.expressionOperation(u.image,[p,h,f],l.astFactory.sourceLocation(u,m)))}}}function xo(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(T.LParen);let a=r(Q),o=n(T.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function bo(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,OR:n,SUBRULE:i})=>s=>{let a=r(e);return n([{ALT:()=>{r(T.LParen);let o=i(k),l=r(T.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o],s.astFactory.sourceLocation(a,l)))}},{ALT:()=>{let o=r(R.nil);return t(()=>s.astFactory.expressionOperation(a.image,[],s.astFactory.sourceLocation(a,o)))}}])}}}function Ar(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r})=>n=>{let i=r(e),s=r(R.nil);return t(()=>n.astFactory.expressionOperation(i.image,[],n.astFactory.sourceLocation(i,s)))}}}function Ts(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let s=r(e),a=n(As);return t(()=>i.astFactory.expressionOperation(s.image,a.val,i.astFactory.sourceLocation(s,a)))}}}function vs(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,CONSUME1:a,OPTION:o,CONSUME2:l})=>u=>{let p=r(e);r(T.LParen);let h=n(k);a(T.comma);let f=i(k),m=o(()=>(l(T.comma),s(k))),v=r(T.RParen);return t(()=>u.astFactory.expressionOperation(p.image,m?[h,f,m]:[h,f],u.astFactory.sourceLocation(p,v)))}}}function Io(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,SUBRULE4:a,CONSUME1:o,OPTION:l,CONSUME2:u,CONSUME3:p})=>h=>{let f=r(e);r(T.LParen);let m=n(k);o(T.comma);let v=i(k);u(T.comma);let x=s(k),A=l(()=>(p(T.comma),a(k))),y=r(T.RParen);return t(()=>h.astFactory.expressionOperation(f.image,A?[m,v,x,A]:[m,v,x],h.astFactory.sourceLocation(f,y)))}}}function ys(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e),a=r(B);return t(()=>i.astFactory.expressionPatternOperation(s.image,a,i.astFactory.sourceLocation(s,a)))}}}function Zt(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n,OPTION:i})=>s=>{let a=r(e);r(T.LParen);let o=i(()=>r(et)),l=n(k),u=r(T.RParen);return t(()=>s.astFactory.aggregate(a.image,o!==void 0,l,void 0,s.astFactory.sourceLocation(a,u)))}}}var K=new xt,Eo=new cn,Of=new cn({ignoreKeys:new Set(["loc","langOrIri","function"])}),Sf={preVisitor:()=>({continue:!1})},Nf={patternOperation:Sf},Pf=()=>!0,LS=()=>!1;function kf(e,t,r=Of){let n=[],i=s=>(n.push(s),{continue:!1});return r.visitNodeSpecific(e,{},{expression:{...Nf,aggregate:{preVisitor:i},functionCall:{preVisitor:s=>t(s)?i(s):{}}}}),n}function wf(e){return e?.groupings.flatMap(t=>"variable"in t?[t.variable]:K.isTermVariable(t)?[t]:[])??[]}function _S(e){return[...wf(e.solutionModifiers.group),...e.values?.variables??[]]}function OS(e,t,r=Pf,n=Of){n.visitNodeSpecific(e,{},{expression:{...Nf,aggregate:Sf,functionCall:{preVisitor:i=>({continue:!r(i)})}},term:{variable:{visitor:i=>{t.add(i.value)}}}})}function xs(e){let{prefixes:t=Object.create(null),baseIRI:r,namedAggregatorCallback:n}=e;if(n!==void 0)return i=>{let s;try{s=Af(i.function,t,r)}catch{return!1}return n(s)}}function Rf(e,t={}){let r=xs(t),n=Cf(e,r??LS,t.astTransformer);if(e.variables.length===1&&K.isWildcard(e.variables[0])){if(e.solutionModifiers.group!==void 0)throw new Error("GROUP BY not allowed with wildcard");if(n)throw new Error("Aggregates not allowed with wildcard");return}let i=e.variables;if(n){let s=new Set,a=new Set(_S(e).map(o=>o.value));for(let o of i)if(K.isTerm(o)){if(!a.has(o.value))throw new Error("Variable not allowed in projection")}else{let l=new Set;OS(o.expression,l,r,t.astTransformer);for(let u of l)if(s.has(u)){if(t.rejectGroupedSelectAliasReuse)throw new Error(`Use of variable bound by an earlier select expression (?${u}) in a grouped query`)}else if(!a.has(u))throw new Error(`Use of ungrouped variable in projection of operation (?${u})`);s.add(o.variable.value)}}}function Lo(e,t={}){SS(e,t),Rf(e,t)}function Ff(e,t={}){Rf({variables:e.variables.filter(r=>K.isTermVariable(r)),solutionModifiers:e.solutionModifiers,values:e.values},t)}function SS(e,t){let r=e.variables.filter(n=>!K.isTerm(n)&&!K.isWildcard(n));if(r.length>0){let n=new Set;Cf(e,xs(t)??Pf,t.astTransformer)||Oo(e.where,n);for(let i of wf(e.solutionModifiers.group))n.add(i.value);for(let{variable:i}of r)if(n.has(i.value))throw new Error(`Target id of 'AS' (?${i.value}) is already in scope`)}PS(e,t.astTransformer),kS(e)}function Cf(e,t,r){return e.solutionModifiers.group?!0:NS(e).some(n=>kf(n,t,r).length>0)}function NS(e){let{having:t,order:r}=e.solutionModifiers;return[...e.variables.flatMap(n=>"expression"in n?[n.expression]:[]),...t?.having??[],...r?.orderDefs.map(n=>n.expression)??[]]}function _o(e){if(!e.has("canParseAggregate"))throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");if(e.has("inAggregate"))throw new Error("An aggregate function is not allowed within an aggregate function.")}function Mf(e,t,r,n){if(!t(e)){if(e.distinct)throw new Error("DISTINCT is only allowed in a function call of a custom aggregate");return}if(_o(r),e.args.some(i=>kf(i,t,n).length>0))throw new Error("An aggregate function is not allowed within an aggregate function.")}function PS(e,t=Eo){let r=new Set;for(let n of e.variables)if("expression"in n){if(r.has(n.variable.value))throw new Error(`Target id of 'AS' (?${n.variable.value}) is used in an earlier select expression`);t.visitNodeSpecific(n.expression,{},{term:{variable:{visitor:i=>{r.add(i.value)}}}})}}function kS(e){let t=new Set(e.values?.variables.map(r=>r.value));for(let r of e.variables)if("variable"in r&&t.has(r.variable.value))throw new Error(`Target id of 'AS' (?${r.variable.value}) is already in scope`)}function Oo(e,t){function r(n){Oo(n,t)}if(e!==void 0)if(Array.isArray(e))for(let n of e)r(n);else if(K.isQuery(e))K.isQuerySelect(e)||K.isQueryDescribe(e)?r(e.variables.some(n=>K.isWildcard(n))?[e.where,e.solutionModifiers.group,e.values]:e.variables):r(e.solutionModifiers.group);else if(K.isTriple(e))r([e.subject,e.predicate,e.object]);else if(K.isPathPure(e))r(e.items);else if(K.isTripleCollection(e))r([e.identifier,...e.triples]);else if(K.isSolutionModifierGroup(e))r(e.groupings.filter(n=>"variable"in n).map(n=>n.variable));else if(K.isSolutionModifierHaving(e))r(e.having);else if(K.isSolutionModifierOrder(e))r(e.orderDefs.map(n=>n.expression));else if(K.isPatternValues(e))for(let n of e.variables)t.add(n.value);else K.isPatternBgp(e)?r(e.triples):K.isPatternGroup(e)||K.isPatternUnion(e)||K.isPatternOptional(e)?r(e.patterns):K.isPatternService(e)||K.isPatternGraph(e)?r([e.name,...e.patterns]):K.isPatternBind(e)?r(e.variable):K.isTermVariable(e)&&t.add(e.value)}function Df(e){if(!e.some(r=>K.isPatternBind(r)))return;let t=new Set;for(let r of e){if(K.isPatternBind(r)&&t.has(r.variable.value))throw new Error(`Variable used to bind is already bound (?${r.variable.value})`);Oo(r,t)}}function Gf(e,t=Eo){let r=new Set;for(let n of e.updates){if(!n.operation)continue;let i=n.operation;if(i.subType==="insertdata"){let s=new Set;t.visitNodeSpecific(i,{},{term:{blankNode:{visitor:a=>{if(s.add(a.label),r.has(a.label))throw new Error("Detected reuse blank node across different INSERT DATA clauses")}}}});for(let a of s)r.add(a)}}}function $f(e,t=Eo){let r=new Map,n=[{}],i=()=>n.at(-1);function s(o){let l=new Set;return t.visitNodeSpecific(o,{},{term:{blankNode:{visitor:u=>{l.add(u.label)}}}}),l}let a={preVisitor:()=>(n.push({}),{}),visitor:()=>{n.pop(),n[n.length-1]={}}};t.visitNodeSpecific(e,{query:{preVisitor:()=>({continue:!1})},pattern:a},{pattern:{bgp:{preVisitor:o=>{let l=i();for(let u of s(o)){let p=r.get(u);if(p!==void 0&&p!==l)throw new Error(`Detected reuse of blank node across two different basic graph patterns (_:${u.replace(/^[eg]_/u,"")})`);r.set(u,l)}return{continue:!1}},visitor:()=>{}},filter:{preVisitor:()=>(n.push({}),{}),visitor:()=>{n.pop()}}}})}var Vf=D(E.str),jf=D(E.lang),Kf=rt(E.langmatches),Hf=D(E.datatype),Wf=xo(E.bound),zf=D(E.iri),Yf=D(E.uri),qf=bo(E.bnode),Xf=Ar(E.rand),Qf=D(E.abs),Bf=D(E.ceil),Zf=D(E.floor),Jf=D(E.round),Uf=Ts(E.concat),ed=D(E.strlen),td=D(E.ucase),rd=D(E.lcase),nd=D(E.encode_for_uri),id=rt(E.contains),sd=rt(E.strstarts),ad=rt(E.strends),od=rt(E.strbefore),ld=rt(E.strafter),cd=D(E.year),ud=D(E.month),pd=D(E.day),hd=D(E.hours),fd=D(E.minutes),dd=D(E.seconds),md=D(E.timezone),gd=D(E.tz),Td=Ar(E.now),vd=Ar(E.uuid),yd=Ar(E.struuid),Ad=D(E.md5),xd=D(E.sha1),bd=D(E.sha256),Id=D(E.sha384),Ed=D(E.sha512),Ld=Ts(E.coalesce),_d=Ao(E.if_),Od=rt(E.strlang),Sd=rt(E.strdt),Nd=rt(E.sameterm),Pd=D(E.isiri),kd=D(E.isuri),wd=D(E.isblank),Rd=D(E.isliteral),Fd=D(E.isnumeric);function Cd(e){return[{ALT:()=>e(bs)},{ALT:()=>e(Vf)},{ALT:()=>e(jf)},{ALT:()=>e(Kf)},{ALT:()=>e(Hf)},{ALT:()=>e(Wf)},{ALT:()=>e(zf)},{ALT:()=>e(Yf)},{ALT:()=>e(qf)},{ALT:()=>e(Xf)},{ALT:()=>e(Qf)},{ALT:()=>e(Bf)},{ALT:()=>e(Zf)},{ALT:()=>e(Jf)},{ALT:()=>e(Uf)},{ALT:()=>e(Dd)},{ALT:()=>e(ed)},{ALT:()=>e(Gd)},{ALT:()=>e(td)},{ALT:()=>e(rd)},{ALT:()=>e(nd)},{ALT:()=>e(id)},{ALT:()=>e(sd)},{ALT:()=>e(ad)},{ALT:()=>e(od)},{ALT:()=>e(ld)},{ALT:()=>e(cd)},{ALT:()=>e(ud)},{ALT:()=>e(pd)},{ALT:()=>e(hd)},{ALT:()=>e(fd)},{ALT:()=>e(dd)},{ALT:()=>e(md)},{ALT:()=>e(gd)},{ALT:()=>e(Td)},{ALT:()=>e(vd)},{ALT:()=>e(yd)},{ALT:()=>e(Ad)},{ALT:()=>e(xd)},{ALT:()=>e(bd)},{ALT:()=>e(Id)},{ALT:()=>e(Ed)},{ALT:()=>e(Ld)},{ALT:()=>e(_d)},{ALT:()=>e(Od)},{ALT:()=>e(Sd)},{ALT:()=>e(Nd)},{ALT:()=>e(Pd)},{ALT:()=>e(kd)},{ALT:()=>e(wd)},{ALT:()=>e(Rd)},{ALT:()=>e(Fd)},{ALT:()=>e(Md)},{ALT:()=>e($d)},{ALT:()=>e(Vd)}]}var It={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(It);if(n)return e(n);let i=Cd(t);return r.set(It,i),e(i)}},Md=vs(E.regex),Dd=vs(E.substr),Gd=Io(E.replace),$d=ys(E.exists),Vd=ys(E.notexists),jd={name:ae(E.count.name),impl:({ACTION:e,CONSUME:t,SUBRULE:r,OR:n,OPTION:i})=>s=>{let a=t(E.count);t(T.LParen);let o=i(()=>t(et)),l=n([{ALT:()=>{let p=t(T.star);return e(()=>s.astFactory.wildcard(s.astFactory.sourceLocation(p)))}},{ALT:()=>r(k)}]),u=t(T.RParen);return e(()=>{let p=s.astFactory;return s.astFactory.isWildcard(l),p.aggregate(a.image,!!o,l,void 0,s.astFactory.sourceLocation(a,u))})}},Kd=Zt(E.sum),Hd=Zt(E.min),Wd=Zt(E.max),zd=Zt(E.avg),Yd=Zt(E.sample),qd={name:ae(E.groupConcat.name),impl:({ACTION:e,CONSUME:t,OPTION1:r,SUBRULE:n,OPTION2:i})=>s=>{let a=t(E.groupConcat);t(T.LParen);let o=r(()=>t(et)),l=n(k),u=i(()=>(t(T.semi),t(us),t(T.equal),n(ds))),p=t(T.RParen);return e(()=>{let h=s.astFactory;return h.aggregate(a.image,!!o,l,u?.value??" ",h.sourceLocation(a,p))})}},bs={name:"aggregate",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=e(()=>n.parseMode.has("inAggregate"));e(()=>n.parseMode.add("inAggregate"));let s=r([{ALT:()=>t(jd)},{ALT:()=>t(Kd)},{ALT:()=>t(Hd)},{ALT:()=>t(Wd)},{ALT:()=>t(zd)},{ALT:()=>t(Yd)},{ALT:()=>t(qd)}]);return e(()=>!i&&n.parseMode.delete("inAggregate")),e(()=>_o(n.parseMode)),s},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(r.aggregation.toUpperCase(),"("),r.distinct&&t("DISTINCT")});let i=r.expression[0];n.isWildcard(i)?n.printFilter(r,()=>t("*")):e(k,i),n.isExpressionAggregateSeparator(r)&&n.printFilter(r,()=>t(";","SEPARATOR","=",un(r.separator))),n.printFilter(r,()=>t(")"))}};var Xd={name:"validateSelectQuery",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Lo(r,t))}},So={name:"validateSubSelect",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Lo(r,t))}},Qd={name:"validateDescribeQuery",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Ff(r,t))}},pn={name:"validateQuery",impl:({OPTION1:e,OPTION2:t,SUBRULE:r})=>(n,i)=>{e({GATE:()=>n.astFactory.isQuerySelect(i),DEF:()=>r(Xd,i)}),t({GATE:()=>n.astFactory.isQueryDescribe(i),DEF:()=>r(Qd,i)})}},hn={name:"validateUpdate",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Gf(r,t.astTransformer))}},No={name:"validateGroupGraphPattern",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&$f(r,t.astTransformer))}},Po={name:"validateGroupGraphPatternSub",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Df(r))}},fn={name:"validateFunctionCall",impl:({ACTION:e})=>(t,r)=>{e(()=>{let n=t.skipValidation?void 0:xs(t);n&&Mf(r,n,t.parseMode,t.astTransformer)})}};var Es={name:"path",impl:({SUBRULE:e})=>()=>e(Jd)},Et={name:"path",gImpl:({PRINT:e,SUBRULE:t})=>(r,{astFactory:n},i=!0)=>{if(n.isTerm(r)&&n.isTermNamed(r))t(G,r);else{switch(n.printFilter(r,()=>i&&e("(")),r.subType){case"|":case"/":{let[s,...a]=r.items;t(Et,s,i);for(let o of a)n.printFilter(r,()=>e(r.subType)),t(Et,o,i);break}case"^":n.printFilter(r,()=>e("^")),t(Et,r.items[0],i);break;case"?":case"*":case"+":t(Et,r.items[0],i),n.printFilter(r,()=>e(r.subType));break;case"!":n.printFilter(r,()=>e("!")),n.printFilter(r,()=>e("(")),t(Et,r.items[0],!1),n.printFilter(r,()=>e(")"));break}n.printFilter(r,()=>i&&e(")"))}}};function wo(e,t,r,n){return{name:e,impl:({ACTION:i,CONSUME:s,SUBRULE1:a,SUBRULE2:o,MANY:l})=>u=>{let p=a(n),h=p,f=[];return l(()=>{s(t),h=o(n),f.push(h)}),i(()=>f.length===0?p:u.astFactory.path(r,[p,...f],u.astFactory.sourceLocation(p,h)))}}}var Bd={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>s=>i([{ALT:()=>r(ko)},{ALT:()=>{let a=t(T.hat),o=n(ko);return e(()=>s.astFactory.path("^",[o],s.astFactory.sourceLocation(a,o)))}}])},Zd=wo("pathSequence",T.slash,"/",Bd),Jd=wo("pathAlternative",T.pipe,"|",Zd),ko={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(em),s=r(()=>t(Ud));return e(()=>s===void 0?i:n.astFactory.path(s.image,[i],n.astFactory.sourceLocation(i,s)))}},Ud={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(T.question)},{ALT:()=>e(T.star)},{ALT:()=>e(T.opPlus)}])},em={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(G)},{ALT:()=>e(Bt)},{ALT:()=>e(tm)},{ALT:()=>{t(T.LParen);let n=e(Es);return t(T.RParen),n}}])},tm={name:"pathNegatedPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,SUBRULE3:i,OR:s,MANY:a})=>o=>{let l=t(T.exclamation);return s([{ALT:()=>{let u=r(Is);return e(()=>o.astFactory.path("!",[u],o.astFactory.sourceLocation(l,u)))}},{ALT:()=>{let u=t(T.LParen),p=n(Is),h=[];a(()=>{t(T.pipe);let m=i(Is);h.push(m)});let f=t(T.RParen);return e(()=>{let m=o.astFactory;return h.length===0?m.path("!",[p],m.sourceLocation(l,f)):m.path("!",[m.path("|",[p,...h],m.sourceLocation(u,f))],m.sourceLocation(l,f))})}}])}},Is={name:"pathOneInPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(G)},{ALT:()=>r(Bt)},{ALT:()=>{let o=t(T.hat),l=s([{ALT:()=>n(G)},{ALT:()=>n(Bt)}]);return e(()=>a.astFactory.path("^",[l],a.astFactory.sourceLocation(o,l)))}}])};function rm(e){return({ACTION:t,AT_LEAST_ONE:r,SUBRULE:n,CONSUME:i,OPTION:s})=>a=>{let o=[],l=!0,u;return r({GATE:()=>l,DEF:()=>{l=!1;let p=n(e);t(()=>{o.push(...p)}),s(()=>{u=i(T.dot),l=!0})}}),t(()=>a.astFactory.patternBgp(o,a.astFactory.sourceLocation(...o,u)))}}var ft={name:"triplesBlock",impl:e=>t=>rm(sm)(e)(t),gImpl:({SUBRULE:e,PRINT_WORD:t,HANDLE_LOC:r,NEW_LINE:n})=>(i,{astFactory:s})=>{for(let[a,o]of i.triples.entries())r(o,()=>{let l=i.triples.at(a+1);s.isTripleCollection(o)?(e(ht,o),s.printFilter(o,()=>{t("."),n()})):(e(ht,o.subject),s.printFilter(o,()=>t("")),s.isTerm(o.predicate)&&s.isTermVariable(o.predicate)?e(ge,o.predicate):e(Et,o.predicate,void 0),s.printFilter(o,()=>t("")),e(ht,o.object),l===void 0||s.isTripleCollection(l)||!s.isSourceLocationNoMaterialize(l.subject.loc)?s.printFilter(i,()=>{t("."),n()}):s.isSourceLocationNoMaterialize(l.predicate.loc)?s.printFilter(i,()=>t(",")):s.printFilter(i,()=>{t(";"),n()}))})}};function nm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>s=>i([{ALT:()=>{let a=n(ge),o=n(t?_s:Ls,r(()=>s.astFactory.dematerialized(a)));return r(()=>(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}},{ALT:()=>{let a=n(t?Mo:Co),o=n(t?lm:om,r(()=>s.astFactory.graphNodeIdentifier(a)));return r(()=>o.length===0?[a]:(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}}])}}var im=nm("triplesSameSubject",!1),sm=nm("triplesSameSubjectPath",!0),Jt={name:"triplesTemplate",impl:rm(im)};function am(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,s)=>n(()=>r(t?_s:Ls,s))??[]}}var om=am("propertyList",!1),lm=am("propertyListPath",!0);function cm(e,t){return{name:e,impl:({ACTION:r,CONSUME:n,AT_LEAST_ONE:i,SUBRULE1:s,MANY2:a,OR1:o})=>(l,u)=>{let p=[],h=!0;return i({GATE:()=>h,DEF:()=>{h=!1;let f=t?o([{ALT:()=>s(um)},{ALT:()=>s(pm)}]):s(go),m=s(t?dm:fm,u,f);a(()=>{n(T.semi),h=!0}),r(()=>{p.push(...m)})}}),p}}}var Ls=cm("propertyListNotEmpty",!1),_s=cm("propertyListPathNotEmpty",!0),um={name:"verbPath",impl:({SUBRULE:e})=>()=>e(Es)},pm={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(Q)};function hm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,AT_LEAST_ONE_SEP:i})=>(s,a,o)=>{let l=[];return i({SEP:T.comma,DEF:()=>{let u=n(t?Tm:gm,a,o);r(()=>{l.push(u)})}}),l}}}var fm=hm("objectList",!1),dm=hm("objectListPath",!0);function mm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,s,a)=>{let o=n(t?ht:Do);return r(()=>i.astFactory.triple(s,a,o))}}}var gm=mm("object",!1),Tm=mm("objectPath",!0);function vm(e,t){return{name:e,impl:({ACTION:r,AT_LEAST_ONE:n,SUBRULE:i,CONSUME:s})=>a=>{let o=[],l=s(T.LParen);n(()=>{o.push(i(t?ht:Do))});let u=s(T.RParen);return r(()=>{let p=a.astFactory,h=[],f=p.termNamed(p.sourceLocation(),le.FIRST,void 0),m=p.termNamed(p.sourceLocation(),le.REST,void 0),v=p.termNamed(p.sourceLocation(),le.NIL,void 0),x=p.termBlank(void 0,p.sourceLocation()),A=x;for(let[y,b]of o.entries()){let g=y===o.length-1,I=p.triple(A,f,b);if(h.push(I),g){let w=p.triple(A,m,v);h.push(w)}else{let w=p.termBlank(void 0,p.sourceLocation()),C=p.triple(A,m,w);h.push(C),A=w}}return p.tripleCollectionList(x,h,p.sourceLocation(l,u))})},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>n("("));for(let[a,o]of i.triples.entries())a%2===0&&(s.printFilter(i,()=>n("")),r(ht,o.object));s.printFilter(i,()=>n(")"))}}}var ym=vm("collection",!1),Ro=vm("collectionPath",!0);function Am(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?Ro:ym)},{ALT:()=>r(t?Fo:bm)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(Ro,n):r(Fo,n)}}var Co=Am("triplesNode",!1),Mo=Am("triplesNodePath",!0);function xm(e,t){let r=t?_s:Ls;return{name:e,impl:({ACTION:n,SUBRULE:i,CONSUME:s})=>a=>{let o=s(T.LSquare),l=n(()=>a.astFactory.termBlank(void 0,a.astFactory.sourceLocation())),u=i(r,l),p=s(T.RSquare);return n(()=>a.astFactory.tripleCollectionBlankNodeProperties(l,u,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:n,PRINT:i,PRINT_WORD:s,HANDLE_LOC:a,PRINT_ON_EMPTY:o,NEW_LINE:l})=>(u,p)=>{let{astFactory:h,indentInc:f}=p;h.printFilter(u,()=>{p[X]+=f,i("["),l()});for(let m of u.triples)a(m,()=>{h.isTerm(m.predicate)&&h.isTermVariable(m.predicate)?n(ge,m.predicate):n(Et,m.predicate,void 0),h.printFilter(m,()=>s("")),n(ht,m.object),h.printFilter(u,()=>{s(";"),l()})});h.printFilter(u,()=>{p[X]-=f,o("]")})}}}var bm=xm("blankNodePropertyList",!1),Fo=xm("blankNodePropertyListPath",!0);function Im(e,t){let r=t?Mo:Co;return{name:e,impl:({SUBRULE:n,OR:i})=>s=>i([{ALT:()=>n(ge)},{GATE:()=>s.parseMode.has("canCreateBlankNodes"),ALT:()=>n(r)}]),gImpl:({SUBRULE:n})=>(i,{astFactory:s})=>{s.isTerm(i)?n(ge,i):n(r,i)}}}var Do=Im("graphNode",!1),ht=Im("graphNodePath",!0);var We={name:"whereClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OPTION:n})=>i=>{let s=n(()=>r(wt)),a=t(B);return e(()=>i.astFactory.wrap(a,i.astFactory.sourceLocation(s,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("WHERE")),e(B,r.val)}},RS=["canParseAggregate","inAggregate"],B={name:"groupGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>{let s=r(T.LCurly),a=e(()=>RS.filter(u=>i.parseMode.delete(u))),o=n([{ALT:()=>[t(qo)]},{ALT:()=>t(Lm)}]),l=r(T.RCurly);return e(()=>{for(let u of a)i.parseMode.add(u)}),t(No,o),e(()=>i.astFactory.patternGroup(o,i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>{s[X]+=o,t("{"),r()});for(let l of i.patterns)e(Em,l);a.printFilter(i,()=>{s[X]-=o,n("}")})}},Em={name:"generatePattern",gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{t.type==="query"?e(Er,r.querySelect({context:[],datasets:r.datasetClauses([],r.sourceLocation()),where:t.where,variables:t.variables,solutionModifiers:t.solutionModifiers,values:t.values,distinct:t.distinct,reduced:t.reduced},t.loc)):t.subType==="group"?e(B,t):t.subType==="bgp"?e(ft,t):e(zo,t)}},Lm={name:"groupGraphPatternSub",impl:({SUBRULE:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OPTION1:s,OPTION2:a,OPTION3:o})=>()=>{let l=[],u=s(()=>n(ft));return u&&l.push(u),r(()=>{let p=e(zo);l.push(p),a(()=>t(T.dot));let h=o(()=>i(ft));h&&l.push(h)}),e(Po,l),l}},zo={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ho)},{ALT:()=>e(Go)},{ALT:()=>e(Ko)},{ALT:()=>e($o)},{ALT:()=>e(Vo)},{ALT:()=>e(Wo)},{ALT:()=>e(jo)},{ALT:()=>e(xr)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e(Ho,t);break;case"optional":e(Go,t);break;case"minus":e(Ko,t);break;case"graph":e($o,t);break;case"service":e(Vo,t);break;case"filter":e(Wo,t);break;case"bind":e(jo,t);break;case"values":e(xr,t);break}}},Go={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ui),s=t(B);return e(()=>n.astFactory.patternOptional(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("OPTIONAL")),e(B,n.patternGroup(r.patterns,r.loc))}},$o={name:"graphGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.graph),s=t(bt),a=t(B);return e(()=>n.astFactory.patternGraph(s,a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(ge,r.name),e(B,n.patternGroup(r.patterns,r.loc))}},Vo={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(es),a=n(()=>(r(yt),!0))??!1,o=t(bt),l=t(B);return e(()=>i.astFactory.patternService(o,l.patterns,a,i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("SERVICE"),r.silent&&t("SILENT")}),e(ge,r.name),e(B,n.patternGroup(r.patterns,r.loc))}},jo={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ts);r(T.LParen);let s=t(k);r(kt);let a=t(Q),o=r(T.RParen);return e(()=>n.astFactory.patternBind(s,a,n.astFactory.sourceLocation(i,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BIND","(")),e(k,n.expression),i.printFilter(n,()=>t("AS")),e(Q,n.variable),i.printFilter(n,()=>{t(")"),r()})}},xr={name:"inlineData",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Mi),s=t(_m);return e(()=>(s.loc=n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,NEW_LINE:n,PRINT_ON_OWN_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:l}=a,u=s.variables,p=u.length===1;o.printFilter(s,()=>{r("VALUES",p?"":"( ")});for(let h of u)o.printFilter(s,()=>t("")),e(ge,h),o.printFilter(s,()=>t(""));o.printFilter(s,()=>{a[X]+=l,t(p?"":")","{"),n()});for(let h of s.values){o.printFilter(s,()=>!p&&t("("));for(let f of u){let m=f.value;h[m]===void 0?o.printFilter(s,()=>t("UNDEF")):(e(ht,h[m]),o.printFilter(s,()=>t("")))}o.printFilter(s,()=>{t(p?"":")"),n()})}o.printFilter(s,()=>{a[X]-=l,i("}")})}},_m={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Om)},{ALT:()=>e(Sm)}])},Om={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let s=[],a=t(Q);r(T.LCurly),n(()=>{let l=t(Yo);e(()=>{s.push(Object.assign(Object.create(null),{[a.value]:l}))})});let o=r(T.RCurly);return e(()=>i.astFactory.patternValues([a],s,i.astFactory.sourceLocation(a,o)))}},Sm={name:"inlineDataFull",impl:({ACTION:e,OR:t,MANY1:r,MANY2:n,MANY3:i,MANY4:s,SUBRULE:a,CONSUME1:o,CONSUME2:l})=>u=>{let p=[],h=[];return t([{ALT:()=>{let f=o(R.nil);o(T.LCurly),r(()=>{l(R.nil),p.push(Object.create(null))});let m=o(T.RCurly);return e(()=>u.astFactory.patternValues(h,p,u.astFactory.sourceLocation(f,m)))}},{ALT:()=>{let f=o(T.LParen);n(()=>{h.push(a(Q))}),o(T.RParen),l(T.LCurly),i(()=>{let v=0,x=Object.create(null);l(T.LParen),s(()=>{e(()=>{if(!u.skipValidation&&v>=h.length)throw new Error("Number of dataBlockValues does not match number of variables. Too much values.")});let A=a(Yo);e(()=>{x[h[v].value]=A,v++})}),l(T.RParen),e(()=>{if(p.push(x),!u.skipValidation&&h.length!==v)throw new Error("Number of dataBlockValues does not match number of variables. Too few values.")})});let m=l(T.RCurly);return e(()=>u.astFactory.patternValues(h,p,u.astFactory.sourceLocation(f,m)))}}])}},Yo={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(G)},{ALT:()=>e(Ft)},{ALT:()=>e(Xt)},{ALT:()=>e(Qt)},{ALT:()=>{t(rs)}}])},Ko={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ns),s=t(B);return e(()=>n.astFactory.patternMinus(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("MINUS")),e(B,n.patternGroup(r.patterns,r.loc))}},Ho={name:"groupOrUnionGraphPattern",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>{let a=[],o=r(B);return a.push(o),t(()=>{i(is);let l=n(B);a.push(l)}),e(()=>a.length===1?a[0]:s.astFactory.patternUnion(a,s.astFactory.sourceLocation(o,a.at(-1))))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isPatternUnion(r)){let[i,...s]=r.patterns;e(B,i);for(let a of s)n.printFilter(r,()=>t("UNION")),e(B,a)}else e(B,r)}},Wo={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ss),s=t(dn);return e(()=>n.astFactory.patternFilter(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("FILTER (")),e(k,n.expression),i.printFilter(n,()=>{t(")"),r()})}},dn={name:"constraint",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ir)},{ALT:()=>e(It)},{ALT:()=>e(Os)}])},Os={name:"functionCall",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(G),i=t(br),s=e(()=>r.astFactory.expressionFunctionCall(n,i.val.args,i.val.distinct,r.astFactory.sourceLocation(n,i)));return t(fn,s),s}};var br={name:"argList",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,OPTION:n,OR:i,AT_LEAST_ONE_SEP:s})=>a=>i([{ALT:()=>{let o=t(R.nil);return e(()=>a.astFactory.wrap({args:[],distinct:!1},a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=[],l=t(T.LParen),u=n(()=>(t(et),!0))??!1;s({SEP:T.comma,DEF:()=>{let h=r(k);o.push(h)}});let p=t(T.RParen);return e(()=>a.astFactory.wrap({args:o,distinct:u},a.astFactory.sourceLocation(l,p)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("("),r.val.distinct&&t("DISTINCT")});let[i,...s]=r.val.args;i&&e(k,i);for(let a of s)n.printFilter(r,()=>t(",")),e(k,a);n.printFilter(r,()=>t(")"))}},As={name:"expressionList",impl:({ACTION:e,CONSUME:t,MANY:r,OR:n,SUBRULE1:i,SUBRULE2:s})=>a=>n([{ALT:()=>{let o=t(R.nil);return e(()=>a.astFactory.wrap([],a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=t(T.LParen),u=[i(k)];r(()=>{t(T.comma);let h=s(k);u.push(h)});let p=t(T.RParen);return e(()=>a.astFactory.wrap(u,a.astFactory.sourceLocation(o,p)))}}])},FS=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),Ut=new Map([["!","!"],["uplus","+"],["uminus","-"]]),k={name:"expression",impl:({SUBRULE:e})=>()=>e(Nm),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isTerm(r))e(ge,r);else if(n.isExpressionPatternOperation(r)){let i=r.args;n.printFilter(r,()=>t(r.operator==="exists"?"EXISTS":"NOT EXISTS")),e(B,i)}else if(n.isExpressionFunctionCall(r))e(Uo,r);else if(n.isExpressionAggregate(r))e(bs,r);else if(r.operator==="in"||r.operator==="notin"){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(k,i),n.printFilter(r,()=>t(r.operator==="in"?"IN":"NOT IN")),e(br,n.wrap({args:s,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(FS.has(r.operator)){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(k,i);for(let a of s)n.printFilter(r,()=>t(r.operator)),e(k,a);n.printFilter(r,()=>t(")"))}else if(Ut.has(r.operator)){let[i]=r.args;n.printFilter(r,()=>t(Ut.get(r.operator)));let s=n.isExpressionOperator(i)&&Ut.has(i.operator);s&&n.printFilter(r,()=>t("(")),e(k,i),s&&n.printFilter(r,()=>t(")"))}else{n.printFilter(r,()=>t(r.operator.toUpperCase(),"("));let[i,...s]=r.args;i&&e(k,i);for(let a of s)n.printFilter(r,()=>t(",")),e(k,a);n.printFilter(r,()=>t(")"))}}};function mn(e,t,r,n){let i=e();return n(()=>{let s=t();r(()=>{i=s(i)})}),i}var Nm={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>mn(()=>n(Xo),()=>{r(T.logicOr);let a=i(Xo);return o=>e(()=>s.astFactory.expressionOperation("||",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Xo={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>mn(()=>r(Qo),()=>{i(T.logicAnd);let a=n(Qo);return o=>e(()=>s.astFactory.expressionOperation("&&",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Qo={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(Pm)},Pm={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:s,OR2:a,OR3:o})=>l=>{let u=r(Bo);return i(()=>s([{ALT:()=>{let h=a([{ALT:()=>t(T.equal)},{ALT:()=>t(T.notEqual)},{ALT:()=>t(T.lessThan)},{ALT:()=>t(T.greaterThan)},{ALT:()=>t(T.lessThanEqual)},{ALT:()=>t(T.greaterThanEqual)}]),f=n(Bo);return e(()=>l.astFactory.expressionOperation(h.image,[u,f],l.astFactory.sourceLocation(u,f)))}},{ALT:()=>{let h=o([{ALT:()=>t(ls)},{ALT:()=>t(cs)}]),f=r(As);return e(()=>l.astFactory.expressionOperation(h.image,[u,...f.val],l.astFactory.sourceLocation(u,f)))}}]))??u}},Bo={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(km)},km={name:"additiveExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,MANY1:s,MANY2:a,OR1:o,OR2:l,OR3:u,OR4:p})=>h=>mn(()=>n(Zo),()=>o([{ALT:()=>{let f=l([{ALT:()=>r(T.opPlus)},{ALT:()=>r(T.opMinus)}]),m=i(Zo);return e(()=>v=>h.astFactory.expressionOperation(f.image,[v,m],h.astFactory.sourceLocation(v,m)))}},{ALT:()=>{let{operator:f,startInt:m}=u([{ALT:()=>{let x=t(hs);return e(()=>(x.value=x.value.replace(/^\+/u,""),{operator:"+",startInt:x}))}},{ALT:()=>{let x=t(fs);return e(()=>(x.value=x.value.replace(/^-/u,""),{operator:"-",startInt:x}))}}]),v=mn(()=>e(()=>m),()=>{let x=p([{ALT:()=>r(T.star)},{ALT:()=>r(T.slash)}]),A=n(Ss);return y=>e(()=>h.astFactory.expressionOperation(x.image,[y,A],h.astFactory.sourceLocation(y,A)))},e,a);return x=>h.astFactory.expressionOperation(f,[x,v],h.astFactory.sourceLocation(x,v))}}]),e,s)},Zo={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:s})=>a=>mn(()=>n(Ss),()=>{let o=s([{ALT:()=>t(T.star)},{ALT:()=>t(T.slash)}]),l=i(Ss);return u=>({type:"expression",subType:"operation",operator:o.image,args:[u,l],loc:a.astFactory.sourceLocation(u,l)})},e,r)},Ss={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(Jo)},{ALT:()=>{let o=s([{ALT:()=>t(T.exclamation)},{ALT:()=>t(T.opPlus)},{ALT:()=>t(T.opMinus)}]),l=n(Jo);return e(()=>a.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[l],a.astFactory.sourceLocation(o,l)))}}])},Jo={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ir)},{ALT:()=>e(It)},{ALT:()=>e(Uo)},{ALT:()=>e(Ft)},{ALT:()=>e(Xt)},{ALT:()=>e(Qt)},{ALT:()=>e(Q)}])},Ir={name:"brackettedExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(T.LParen),s=t(k),a=r(T.RParen);return e(()=>(s.loc=n.astFactory.sourceLocation(i,a),s))}},Uo={name:"iriOrFunction",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(G);return r(()=>{let a=t(br),o=e(()=>{let l=a.val.distinct;if(!n.parseMode.has("canParseAggregate")&&l)throw new Error("DISTINCT implies that this function is an aggregated function, which is not allowed in this context.");return n.astFactory.expressionFunctionCall(i,a.val.args,l,n.astFactory.sourceLocation(i,a))});return t(fn,o),o})??i},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(G,t):(e(G,t.function),e(br,r.wrap({args:t.args,distinct:t.distinct},t.loc)))}};var ze={name:"solutionModifier",impl:({ACTION:e,SUBRULE:t,OPTION1:r,OPTION2:n,OPTION3:i,OPTION4:s})=>()=>{let a=r(()=>t(el)),o=n(()=>t(tl)),l=i(()=>t(rl)),u=s(()=>t(nl));return e(()=>({...u&&{limitOffset:u},...a&&{group:a},...o&&{having:o},...l&&{order:l}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(el,t.group),t.having&&e(tl,t.having),t.order&&e(rl,t.order),t.limitOffset&&e(nl,t.limitOffset)}},el={name:"groupClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=[],a=n(on);return n(ln),t(()=>{s.push(r(wm))}),e(()=>({type:"solutionModifier",subType:"group",groupings:s,loc:i.astFactory.sourceLocation(a,s.at(-1))}))},gImpl:({PRINT_WORDS:e,SUBRULE:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("GROUP BY ")});for(let s of n.groupings)if(i.printFilter(n,()=>e("")),i.isExpression(s)){let a=i.isTerm(s)&&!i.isTermVariable(s)||i.isExpressionOperator(s)&&Ut.has(s.operator);a&&i.printFilter(s,()=>e("(")),t(k,s),a&&i.printFilter(s,()=>e(")"))}else i.printFilter(n,()=>e("(")),t(k,s.value),i.printFilter(n,()=>e("AS")),t(Q,s.variable),i.printFilter(n,()=>e(")"))}},wm={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s,OR:a})=>o=>a([{ALT:()=>t(It)},{ALT:()=>t(Os)},{ALT:()=>i(Q)},{ALT:()=>{let l=r(T.LParen),u=t(k),p=s(()=>(r(kt),n(Q))),h=r(T.RParen);return e(()=>p!==void 0?{variable:p,value:u,loc:o.astFactory.sourceLocation(l,h)}:u)}}])},tl={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(Pi),a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(Rm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierHaving(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_ON_EMPTY:e,PRINT_WORD:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{e("HAVING ")});for(let s of n.having){let a=i.isTerm(s)||i.isExpressionOperator(s)&&Ut.has(s.operator);a&&i.printFilter(s,()=>t("(")),r(k,s),a&&i.printFilter(s,()=>t(")"))}}},Rm={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(dn)},rl={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=n(ki);n(ln);let a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(Fm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierOrder(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_WORDS:e,PRINT_ON_EMPTY:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("ORDER BY ")});for(let s of n.orderDefs)s.descending?i.printFilter(n,()=>e("DESC")):i.printFilter(n,()=>e("ASC")),i.printFilter(n,()=>e("(")),r(k,s.expression),i.printFilter(n,()=>e(")"))}},Fm={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>s=>n([{ALT:()=>{let a=i([{ALT:()=>[!1,r(wi)]},{ALT:()=>[!0,r(Ri)]}]),o=t(Ir);return e(()=>({expression:o,descending:a[0],loc:s.astFactory.sourceLocation(a[1],o)}))}},{ALT:()=>{let a=t(dn);return e(()=>({expression:a,descending:!1,loc:a.loc}))}},{ALT:()=>{let a=t(Q);return e(()=>({expression:a,descending:!1,loc:a.loc}))}}])},nl={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:s})=>a=>s([{ALT:()=>{let o=t(il),l=n(()=>t(sl));return e(()=>a.astFactory.solutionModifierLimitOffset(o.val,l?.val,a.astFactory.sourceLocation(o,...l?[l]:[])))}},{ALT:()=>{let o=r(sl),l=i(()=>r(il));return e(()=>a.astFactory.solutionModifierLimitOffset(l?.val,o.val,a.astFactory.sourceLocation(o,l)))}}]),gImpl:({PRINT_WORDS:e,NEW_LINE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(),r.limit!==void 0&&e("LIMIT",String(r.limit)),r.offset&&e("OFFSET",String(r.offset))})}},il={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Fi),i=t(R.integer),s=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}},sl={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(Ci),i=e(R.integer),s=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}};var CS={name:"queryUnit",impl:({SUBRULE:e})=>()=>e(Er)},Er={name:"query",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=t(He),s=r([{ALT:()=>t(gn)},{ALT:()=>t(Tn)},{ALT:()=>t(vn)},{ALT:()=>t(yn)}]),a=t(An),o=e(()=>{let l={context:i,...s,type:"query",loc:n.astFactory.sourceLocation(i.at(0),s,a)};return a&&(l.values=a),l});return t(pn,o),o},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(He,t.context),r.isQuerySelect(t)?e(gn,t):r.isQueryConstruct(t)?e(Tn,t):r.isQueryDescribe(t)?e(vn,t):e(yn,t),t.values&&e(xr,t.values)}},gn={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ns),i=t(tt),s=t(We),a=t(ze);return e(()=>({subType:"select",where:s.val,solutionModifiers:a,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,s,a.group,a.having,a.order,a.limitOffset)}))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Ns,r.wrap({variables:t.variables,distinct:t.distinct,reduced:t.reduced},r.sourceLocation(...t.variables))),e(tt,t.datasets),e(We,r.wrap(t.where,t.where.loc)),e(ze,t.solutionModifiers)}},qo={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ns),i=t(We),s=t(ze),a=t(An),o=e(()=>r.astFactory.querySelect({where:i.val,datasets:r.astFactory.datasetClauses([],r.astFactory.sourceLocation()),context:[],solutionModifiers:s,...n.val,...a&&{values:a}},r.astFactory.sourceLocation(n,i,s.group,s.having,s.order,s.limitOffset,a)));return t(So,o),o}},Ns={name:"selectClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION:s,OR1:a,OR2:o,OR3:l})=>u=>{let p=i(Ei),h=e(()=>u.parseMode.has("canParseAggregate")||!u.parseMode.add("canParseAggregate")),f=s(()=>a([{ALT:()=>(i(et),[!0,!1])},{ALT:()=>(i(Li),[!1,!0])}]))??[!1,!1],m=e(()=>{let[A,y]=f;return{...A&&{distinct:A},...y&&{reduced:y}}}),v,x=o([{ALT:()=>{let A=i(T.star);return e(()=>(v=A,{variables:[u.astFactory.wildcard(u.astFactory.sourceLocation(A))],...m}))}},{ALT:()=>{let A=[],y=[];return t(()=>l([{ALT:()=>{let b=r(Q);e(()=>{if(!u.skipValidation&&A.some(g=>g.value===b.value))throw new Error(`Variable ${b.value} used more than once in SELECT clause`);A.push(b),y.push(b),v=b})}},{ALT:()=>{let b=i(T.LParen),g=r(k);i(kt);let I=n(Q),w=i(T.RParen);e(()=>{if(v=w,!u.skipValidation&&A.some(C=>C.value===I.value))throw new Error(`Variable ${I.value} used more than once in SELECT clause`);A.push(I),y.push(u.astFactory.patternBind(g,I,u.astFactory.sourceLocation(b,v)))})}}])),{variables:y,...m}}}]);return e(()=>!h&&u.parseMode.delete("canParseAggregate")),e(()=>u.astFactory.wrap(x,u.astFactory.sourceLocation(p,v)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("SELECT "),n.val.distinct?t("DISTINCT"):n.val.reduced&&t("REDUCED")});for(let s of n.val.variables)i.isWildcard(s)?i.printFilter(n,()=>t("*")):i.isTerm(s)?e(Q,s):(i.printFilter(n,()=>t("(")),e(k,s.expression),i.printFilter(n,()=>t("AS")),e(Q,s.variable),i.printFilter(n,()=>t(")"))),i.printFilter(n,()=>t(""));i.printFilter(n,()=>t(""))}},Tn={name:"constructQuery",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,CONSUME:n,OR:i})=>s=>{let a=n(_i);return i([{ALT:()=>{let o=t(al),l=t(tt),u=t(We),p=t(ze);return e(()=>({subType:"construct",template:o.val,datasets:l,where:u.val,solutionModifiers:p,loc:s.astFactory.sourceLocation(a,u,p.group,p.having,p.order,p.limitOffset)}))}},{ALT:()=>{let o=r(tt);n(wt);let l=r(al),u=r(ze);return e(()=>({subType:"construct",template:l.val,datasets:o,where:s.astFactory.patternGroup([l.val],s.astFactory.sourceLocation()),solutionModifiers:u,loc:s.astFactory.sourceLocation(a,l,u.group,u.having,u.order,u.limitOffset)}))}}])},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,PRINT_ON_OWN_LINE:n,NEW_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:l}=a;o.printFilter(s,()=>r("CONSTRUCT ")),o.isSourceLocationNoMaterialize(s.where.loc)||(o.printFilter(s,()=>{a[X]+=l,t("{"),i()}),e(ft,s.template),o.printFilter(s,()=>{a[X]-=l,n("}")})),e(tt,s.datasets),o.isSourceLocationNoMaterialize(s.where.loc)?e(We,o.wrap(o.patternGroup([s.template],s.template.loc),s.template.loc)):e(We,o.wrap(s.where,s.where.loc)),e(ze,s.solutionModifiers)}},vn={name:"describeQuery",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n,OPTION:i,OR:s})=>a=>{let o=n(Oi),l=s([{ALT:()=>{let f=[];return t(()=>{f.push(r(bt))}),f}},{ALT:()=>{let f=n(T.star);return[e(()=>a.astFactory.wildcard(a.astFactory.sourceLocation(f)))]}}]),u=r(tt),p=i(()=>r(We)),h=r(ze);return e(()=>({subType:"describe",variables:l,datasets:u,...p&&{where:p.val},solutionModifiers:h,loc:a.astFactory.sourceLocation(o,...l,u,p,h.group,h.having,h.order,h.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{if(i.printFilter(n,()=>r("DESCRIBE ")),i.isWildcard(n.variables[0]))i.printFilter(n,()=>t("*"));else for(let s of n.variables)i.printFilter(n,()=>t("")),e(ge,s);e(tt,n.datasets),n.where&&e(We,i.wrap(n.where,n.loc)),e(ze,n.solutionModifiers)}},yn={name:"askQuery",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Si),s=t(tt),a=t(We),o=t(ze);return e(()=>({subType:"ask",datasets:s,where:a.val,solutionModifiers:o,loc:n.astFactory.sourceLocation(i,s,a,o.group,o.having,o.order,o.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("ASK ")),e(tt,r.datasets),e(We,n.wrap(r.where,r.loc)),e(ze,r.solutionModifiers)}},An={name:"valuesClause",impl:({OPTION:e,SUBRULE:t})=>()=>e(()=>t(xr))},al={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(T.LCurly),a=n(()=>t(Cm)),o=r(T.RCurly);return e(()=>i.astFactory.wrap(a??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,o)))}},Cm={name:"constructTriples",impl:Jt.impl};var MS={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(Ps)},Ps={name:"update",impl:({ACTION:e,SUBRULE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION1:s,MANY:a})=>o=>{let l=[],u=r(He);l.push({context:u});let p=!0;a({GATE:()=>p,DEF:()=>{p=!1,l.at(-1).operation=t(Lr),s(()=>{i(T.semi),p=!0;let f=n(He);l.push({context:f})})}});let h=e(()=>({type:"update",updates:l,loc:o.astFactory.sourceLocation(...l.flatMap(f=>[...f.context,f.operation]))}));return t(hn,h),h},gImpl:({SUBRULE:e,PRINT:t,NEW_LINE:r})=>(n,{astFactory:i})=>{let[s,...a]=n.updates;s&&(e(He,s.context),s.operation&&e(Lr,s.operation));for(let o of a)i.printFilter(n,()=>{t(";"),r()}),e(He,o.context),o.operation&&e(Lr,o.operation)}},Lr={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(ol)},{ALT:()=>e(ll)},{ALT:()=>e(cl)},{ALT:()=>e(pl)},{ALT:()=>e(hl)},{ALT:()=>e(fl)},{ALT:()=>e(ul)},{ALT:()=>e(dl)},{ALT:()=>e(ml)},{ALT:()=>e(gl)},{ALT:()=>e(Tl)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(ol,t);break;case"clear":e(ll,t);break;case"drop":e(cl,t);break;case"add":e(pl,t);break;case"move":e(hl,t);break;case"copy":e(fl,t);break;case"create":e(ul,t);break;case"insertdata":e(dl,t);break;case"deletedata":e(ml,t);break;case"deletewhere":e(gl,t);break;case"modify":e(Tl,t);break}}},ol={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>s=>{let a=r(Di),o=n(()=>r(yt)),l=t(G),u=i(()=>(r(Gi),t(xn)));return e(()=>s.astFactory.updateOperationLoad(s.astFactory.sourceLocation(a,l,u),l,!!o,u))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("LOAD "),n.silent&&t("SILENT")}),e(G,n.source),n.destination&&(i.printFilter(n,()=>t("INTO")),e(er,n.destination))}};function Mm(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE1:r,CONSUME:n,OPTION:i})=>s=>{let a=n(e),o=i(()=>n(yt)),l=r(er);return t(()=>s.astFactory.updateOperationClearDrop(ae(e.name),!!o,l,s.astFactory.sourceLocation(a,l)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(er,i.destination)}}}var ll=Mm($i),cl=Mm(Vi),ul={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(ji),a=n(()=>r(yt)),o=t(xn);return e(()=>i.astFactory.updateOperationCreate(o,!!a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("CREATE "),n.silent&&t("SILENT")}),e(er,n.destination)}};function xl(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s})=>a=>{let o=r(e),l=s(()=>r(yt)),u=n(yl);r(Hi);let p=i(yl);return t(()=>a.astFactory.updateOperationAddMoveCopy(ae(e.name),u,p,!!l,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(er,i.source),s.printFilter(i,()=>r("TO")),t(er,i.destination)}}}var pl=xl(Ki),hl=xl(Wi),fl=xl(zi),ks={name:"quadPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(T.LCurly),s=t(_r),a=r(T.RCurly);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,a)))}},bl={name:"quadData",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(T.LCurly),s=e(()=>n.parseMode.delete("canParseVars")),a=t(_r);e(()=>s&&n.parseMode.add("canParseVars"));let o=r(T.RCurly);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,o)))}};function Il(e,t,r,n){return{name:e,impl:({ACTION:i,SUBRULE1:s,CONSUME:a})=>o=>{let l=a(r),u=!0;e!=="insertData"&&(u=i(()=>o.parseMode.delete("canCreateBlankNodes")));let p=s(n);return e!=="insertData"&&i(()=>u&&o.parseMode.add("canCreateBlankNodes")),i(()=>o.astFactory.updateOperationInsDelDataWhere(t,p.val,o.astFactory.sourceLocation(l,p)))},gImpl:({SUBRULE:i,PRINT_WORD:s,PRINT_ON_EMPTY:a,PRINT_ON_OWN_LINE:o,NEW_LINE:l})=>(u,p)=>{let{astFactory:h,indentInc:f}=p;h.printFilter(u,()=>{a(t==="insertdata"?"INSERT DATA ":t==="deletedata"?"DELETE DATA ":"DELETE WHERE "),p[X]+=f,s("{"),l()}),i(_r,h.wrap(u.data,u.loc)),h.printFilter(u,()=>{p[X]-=f,o("}")})}}}var dl=Il("insertData","insertdata",Bi,bl),ml=Il("deleteData","deletedata",qi,bl),gl=Il("deleteWhere","deletewhere",Xi,ks),Tl={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:s,OR:a})=>o=>{let l=i(()=>{let m=t(Yi),v=r(G);return{withToken:m,graph:v}}),{insert:u,del:p}=a([{ALT:()=>{let m=r(Dm),v=s(()=>r(vl));return{del:m,insert:v}}},{ALT:()=>({insert:n(vl),del:void 0})}]),h=r(gs);t(wt);let f=r(B);return e(()=>o.astFactory.updateOperationModify(o.astFactory.sourceLocation(l?.withToken,p,u,f),u?.val??[],p?.val??[],f,h,l?.graph))},gImpl:({SUBRULE:e,PRINT_WORDS:t,PRINT_ON_EMPTY:r,NEW_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;i.graph&&(a.printFilter(i,()=>t("WITH")),e(G,i.graph)),(i.delete.length>0||i.insert.length===0)&&(a.printFilter(i,()=>{s[X]+=o,t("DELETE","{"),n()}),e(_r,a.wrap(i.delete,i.loc)),a.printFilter(i,()=>{s[X]-=o,r("}"),n()})),i.insert.length>0&&(a.printFilter(i,()=>{s[X]+=o,t("INSERT","{"),n()}),e(_r,a.wrap(i.insert,i.loc)),a.printFilter(i,()=>{s[X]-=o,r("} "),n()})),e(gs,i.from),a.printFilter(i,()=>t("WHERE")),e(B,i.where)}},Dm={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Qi),s=e(()=>n.parseMode.delete("canCreateBlankNodes")),a=t(ks);return e(()=>s&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},vl={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Zi),s=t(ks);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},yl={name:"graphOrDefault",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>i([{ALT:()=>{let a=r(Ee.default_);return e(()=>s.astFactory.graphRefDefault(s.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=n(()=>r(Ee.graph)),o=t(G);return e(()=>s.astFactory.graphRefSpecific(o,s.astFactory.sourceLocation(a,o)))}}])},xn={name:"graphRef",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.graph),s=t(G);return e(()=>n.astFactory.graphRefSpecific(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(G,r.graph)}},er={name:"graphRefAll",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(xn)},{ALT:()=>{let s=r(Ee.default_);return e(()=>i.astFactory.graphRefDefault(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(Ee.named);return e(()=>i.astFactory.graphRefNamed(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(Ee.graphAll);return e(()=>i.astFactory.graphRefAll(i.astFactory.sourceLocation(s)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.isGraphRefSpecific(r)?e(xn,r):n.isGraphRefDefault(r)?n.printFilter(r,()=>t("DEFAULT")):n.isGraphRefNamed(r)?n.printFilter(r,()=>t("NAMED")):n.printFilter(r,()=>t("ALL"))}},_r={name:"quads",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:l})=>u=>{let p=[],h;return a(()=>{let f=i(Jt);h=f,e(()=>p.push(f))}),n(()=>{let f=t(Al);h=f,p.push(f),o(()=>{let m=r(T.dot);return h=m,m}),l(()=>{let m=s(Jt);h=m,e(()=>p.push(m))})}),e(()=>u.astFactory.wrap(p,u.astFactory.sourceLocation(p.at(0),h)))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t.val)r.isPattern(n)?e(ft,n):e(Al,n)}},Al={name:"quadsNotTriples",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Ee.graph),a=t(bt);r(T.LCurly);let o=n(()=>t(Jt)),l=r(T.RCurly);return e(()=>i.astFactory.graphQuads(a,o??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>t("GRAPH")),e(ge,i.graph),a.printFilter(i,()=>{s[X]+=o,t("{"),r()}),e(ft,i.triples),a.printFilter(i,()=>{s[X]-=o,n("}")})}};var DS={name:"queryOrUpdate",impl:({ACTION:e,SUBRULE:t,OR1:r,OR2:n,MANY:i,OPTION1:s,CONSUME:a,SUBRULE2:o})=>l=>{let u=t(He);return r([{ALT:()=>{let p=n([{ALT:()=>t(gn)},{ALT:()=>t(Tn)},{ALT:()=>t(vn)},{ALT:()=>t(yn)}]),h=t(An),f=e(()=>({context:u,...p,type:"query",...h&&{values:h},loc:l.astFactory.sourceLocation(u.at(0),p,h)}));return t(pn,f),f}},{ALT:()=>{let p=[];p.push({context:u});let h=!0;i({GATE:()=>h,DEF:()=>{h=!1,p.at(-1).operation=t(Lr),s(()=>{a(T.semi),h=!0;let m=o(He);p.push({context:m})})}});let f=e(()=>({type:"update",updates:p,loc:l.astFactory.sourceLocation(...p.flatMap(m=>[...m.context,m.operation]))}));return t(hn,f),f}}])},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isQuery(t)?e(Er,t):e(Ps,t)}};function GS(e){return{astFactory:e.astFactory??new xt({tracksSourceLocation:!1}),baseIRI:e.baseIRI,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:e.parseMode?new Set(e.parseMode):new Set(["canParseVars","canCreateBlankNodes"]),skipValidation:e.skipValidation??!1,rejectGroupedSelectAliasReuse:e.rejectGroupedSelectAliasReuse??!1,namedAggregatorCallback:e.namedAggregatorCallback,astTransformer:e.astTransformer}}function El(e){return{astFactory:e.astFactory??new xt,origSource:e.origSource??"",offset:e.offset,[X]:e[X]??0,[Jr]:e[Jr]??" ",indentInc:e.indentInc??2}}function Gm(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var ws=class{parser;defaultContext;coreTransformer=new zt;constructor(t,r={}){this.parser=t,this.defaultContext=GS(r)}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Gm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),n}parsePath(t,r={}){let n=this.parser.path(t,Gm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),this.defaultContext.astFactory.isPathPure(n)?{...n,prefixes:Object.create(null)}:n}};var $S=[c.expression,c.conditionalOrExpression,c.conditionalAndExpression,c.valueLogical,c.relationalExpression,c.numericExpression,c.expressionList,c.additiveExpression,c.multiplicativeExpression,c.unaryExpression,c.primaryExpression,c.brackettedExpression,c.iriOrFunction,c.validateFunctionCall,c.rdfLiteral,c.numericLiteral,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative,c.booleanLiteral,c.var_,c.builtInStr,c.builtInLang,c.builtInLangmatches,c.builtInDatatype,c.builtInBound,c.builtInIri,c.builtInUri,c.builtInBnodeSparqlJs,c.builtInRand,c.builtInAbs,c.builtInCeil,c.builtInFloor,c.builtInRound,c.builtInConcat,c.builtInStrlen,c.builtInUcase,c.builtInLcase,c.builtInEncode_for_uri],VS={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(c.builtInCallList(t).slice(0,-2))},$m=oe.create($S).addMany(c.builtInContains,c.builtInStrstarts,c.builtInStrends,c.builtInStrbefore,c.builtInStrafter,c.builtInYear,c.builtInMonth,c.builtInDay,c.builtInHours,c.builtInMinutes,c.builtInSeconds,c.builtInTimezone,c.builtInTz,c.builtInNow,c.builtInUuid,c.builtInStruuid,c.builtInMd5,c.builtInSha1,c.builtInSha256,c.builtInSha384,c.builtInSha512,c.builtInCoalesce,c.builtInIf,c.builtInStrlang,c.builtInStrdt,c.builtInSameterm,c.builtInIsiri,c.builtInIsuri,c.builtInIsblank,c.builtInIsliteral,c.builtInIsnumeric,c.regexExpression,c.substringExpression,c.strReplaceExpression,c.aggregateCount,c.aggregateSum,c.aggregateMin,c.aggregateMax,c.aggregateAvg,c.aggregateSample,c.aggregateGroup_concat,c.aggregate,c.iri,c.iriFull,c.prefixedName,c.argList,c.string).addRule(VS);var jS=[c.objectList,c.object,c.graphNode,c.varOrTerm,c.triplesNode,c.collection,c.blankNodePropertyList,c.propertyListNotEmpty,c.verb,c.verbA,c.varOrIri,c.var_,c.iri,c.iriFull,c.prefixedName,c.graphTerm,c.rdfLiteral,c.numericLiteral,c.booleanLiteral,c.blankNode,c.string,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative],Rs=oe.create(jS);var Vm=oe.create([c.triplesBlock,c.triplesSameSubjectPath,c.propertyListPathNotEmpty,c.triplesNodePath,c.propertyListPath,c.verbPath,c.verbSimple,c.objectListPath]).merge(Rs,[]).addMany(c.path,c.pathAlternative,c.pathSequence,c.pathEltOrInverse,c.pathElt,c.pathPrimary,c.pathMod,c.pathNegatedPropertySet,c.pathOneInPropertySet,c.objectPath,c.graphNodePath,c.collectionPath,c.blankNodePropertyListPath);var KS=[c.subSelect,c.selectClause,c.whereClause,c.solutionModifier,c.valuesClause,c.validateSubSelect,c.validateGroupGraphPattern,c.validateGroupGraphPatternSub],Fs=oe.create(KS).merge($m,[]).patchRule(c.builtInCall).addMany(c.existsFunc,c.notExistsFunc,c.groupGraphPattern,c.groupGraphPatternSub).merge(Vm,[]).addMany(c.graphPatternNotTriples,c.groupOrUnionGraphPattern,c.optionalGraphPattern,c.minusGraphPattern,c.graphGraphPattern,c.serviceGraphPattern,c.filter,c.bind,c.inlineData,c.constraint,c.functionCall,c.dataBlock,c.inlineDataOneVar,c.inlineDataFull,c.dataBlockValue,c.groupClause,c.havingClause,c.orderClause,c.limitOffsetClauses,c.groupCondition,c.havingCondition,c.orderCondition,c.limitClause,c.offsetClause);var HS=[c.triplesTemplate,c.triplesSameSubject,c.varOrTerm,c.propertyListNotEmpty,c.triplesNode,c.propertyList,c.var_,c.graphTerm,c.iri,c.iriFull,c.prefixedName,c.rdfLiteral,c.string,c.numericLiteral,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative,c.booleanLiteral,c.blankNode,c.verb,c.verbA,c.varOrIri,c.objectList,c.object,c.collection,c.blankNodePropertyList,c.graphNode],Cs=oe.create(HS);var WS=[c.queryUnit,c.query,c.prologue,c.selectQuery,c.constructQuery,c.describeQuery,c.askQuery,c.valuesClause,c.baseDecl,c.prefixDecl,c.validateQuery,c.validateSelectQuery,c.validateDescribeQuery],jm=oe.create(WS).merge(Fs,[]).addRule(c.datasetClause).addRule(c.datasetClauseStar).addRule(c.defaultGraphClause).addRule(c.namedGraphClause).addRule(c.sourceSelector).addRule(c.constructTemplate).merge(Cs,[]).addRule(c.constructTriples);var zS={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(c.load)},{ALT:()=>e(c.clear)},{ALT:()=>e(c.drop)},{ALT:()=>e(c.add)},{ALT:()=>e(c.move)},{ALT:()=>e(c.copy)},{ALT:()=>e(c.create)},{ALT:()=>e(c.insertData)},{ALT:()=>e(c.deleteData)},{ALT:()=>e(c.deleteWhere)}]),gImpl:c.update1.gImpl},YS=[c.updateUnit,c.update,c.prologue,c.baseDecl,c.prefixDecl,c.load,c.clear,c.drop,c.add,c.move,c.copy,c.create,c.insertData,c.deleteData,c.deleteWhere,c.iri,c.prefixedName,c.graphRef,c.graphRefAll,c.graphOrDefault,c.quadData,c.quads,c.validateUpdate],Km=oe.create(YS).addRule(zS).merge(Cs,[]).addRule(c.quadPattern).addRule(c.quadsNotTriples);var Hm=oe.create(Km).patchRule(c.update1).addMany(c.modify,c.deleteClause,c.insertClause,c.usingClause,c.defaultGraphClause,c.namedGraphClause,c.sourceSelector,c.usingClauseStar,c.groupGraphPattern).merge(Rs,[]).merge(Fs,[]);var qS=oe.create(jm).merge(Hm,[]).addRule(c.queryOrUpdate),Ms=class extends ws{constructor(t={}){let r=qS.build({...t,tokenVocabulary:ve.sparql11LexerBuilder.tokenVocabulary,queryPreProcessor:yf});super(r,t.defaultContext)}};var XS=pi.create([c.queryOrUpdate,c.query,c.selectQuery,c.constructQuery,c.describeQuery,c.askQuery,c.selectClause]).addMany(c.update,c.update1,c.load,c.clear,c.drop,c.create,c.copy,c.move,c.add,c.insertData,c.deleteData,c.deleteWhere,c.modify,c.graphRef,c.graphRefAll,c.quads,c.quadsNotTriples).addRule(c.aggregate).addMany(c.datasetClauseStar,c.usingClauseStar).addMany(c.argList,c.expression,c.iriOrFunction).addMany(c.prologue,c.prefixDecl,c.baseDecl,c.varOrTerm,c.var_,c.graphTerm).addMany(c.rdfLiteral,c.iri,c.iriFull,c.prefixedName,c.blankNode).addRule(c.pathGenerator).addMany(c.solutionModifier,c.groupClause,c.havingClause,c.orderClause,c.limitOffsetClauses).addMany(c.triplesBlock,c.collectionPath,c.blankNodePropertyListPath,c.triplesNodePath,c.graphNodePath).addMany(c.whereClause,c.generatePattern,c.groupGraphPattern,c.graphPatternNotTriples,c.optionalGraphPattern,c.graphGraphPattern,c.serviceGraphPattern,c.bind,c.inlineData,c.minusGraphPattern,c.groupOrUnionGraphPattern,c.filter),Ds=class{defaultContext;constructor(t={}){this.defaultContext=El(t)}generator=XS.build();generate(t,r={}){return this.generator.queryOrUpdate(t,{...this.defaultContext,...r}).trim()}generatePath(t,r={}){return this.generator.path(t,El({...this.defaultContext,...r}),void 0).trim()}};function Ll(e,t=new Map){if(Array.isArray(e))return e.forEach(n=>Ll(n,t)),e;if(!e||typeof e!="object")return e;let r=new Map(t);if(Array.isArray(e.context))for(let n of e.context)n.subType==="prefix"&&n.key&&n.value?.value&&r.set(n.key,n.value.value);if(e.type==="term"&&e.subType==="namedNode"&&e.prefix){let n=r.get(e.prefix);if(!n)throw new Error(`Undefined SPARQL prefix: ${e.prefix}`);e.value=n+e.value,delete e.prefix}for(let n of Object.values(e))Ll(n,r);return e}var _l=class{constructor(t){this.parser=new Ms(t)}parse(t){return Ll(this.parser.parse(t))}},Ol=class{constructor(t){this.generator=new Ds(t)}generate(t,r){return this.generator.generate(t,r)}};typeof window<"u"&&(window.LDH_SPARQL={Parser:_l,Generator:Ol});})(); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl index 216b4df23d..72fb15878e 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl @@ -102,8 +102,8 @@ extension-element-prefixes="ixsl" - - + + @@ -2534,7 +2534,7 @@ WHERE - + @@ -2722,4 +2722,4 @@ WHERE - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl index 0ce5a47dbf..5bed370a16 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl @@ -304,7 +304,8 @@ exclude-result-prefixes="#all" - + @@ -417,7 +418,7 @@ exclude-result-prefixes="#all" - + @@ -439,58 +440,60 @@ exclude-result-prefixes="#all" + triple - _: + - + - + - _: + - + - - ""^^ + + - - ""^^ + + - ""@ + - ""@ + - "" + + autoGenerate @@ -525,50 +528,53 @@ exclude-result-prefixes="#all" - + + triple - _: + - + - + - _: + - + - ""^^ + + - ""@ + - "" + + autoGenerate @@ -579,9 +585,11 @@ exclude-result-prefixes="#all" - - ?p - ?o + triple + + + + autoGenerate @@ -591,10 +599,12 @@ exclude-result-prefixes="#all" - bgp + pattern + bgp + autoGenerate @@ -605,7 +615,7 @@ exclude-result-prefixes="#all" - + @@ -617,23 +627,33 @@ exclude-result-prefixes="#all" update - insertdelete - - - - - - - - - + + + updateOperation + modify + + + + pattern + group + + autoGenerate + + + datasetClauses + + autoGenerate + + autoGenerate + + autoGenerate - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl index 8037b8d7dd..13ccc731df 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/map.xsl @@ -132,7 +132,7 @@ exclude-result-prefixes="#all" - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl index 2e9e463f9b..77851e56f8 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl @@ -1505,7 +1505,7 @@ LIMIT 10 - + - + @@ -1400,4 +1400,4 @@ ORDER BY DESC(?created) on-failure="ldh:promise-failure($container, 'results-not-loaded', ?)"/> - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 770139cfbc..321418e4ef 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -45,7 +45,7 @@ extension-element-prefixes="ixsl" - ? + @@ -59,21 +59,18 @@ extension-element-prefixes="ixsl" - + - - - - - - - - + + + + + + + - - @@ -84,24 +81,21 @@ extension-element-prefixes="ixsl" - + - - - - - - - - + + + + + + + - - - @@ -109,9 +103,40 @@ extension-element-prefixes="ixsl" - + + + + + + + + + + + + + + + + + + + + + + - - - + wildcard + + + pattern + group + + + + + @@ -168,7 +195,7 @@ extension-element-prefixes="ixsl" - + @@ -180,7 +207,7 @@ extension-element-prefixes="ixsl" - + @@ -192,33 +219,44 @@ extension-element-prefixes="ixsl" - union + pattern + union - bgp + pattern + bgp - - - + triple + + + - graph + pattern + graph - bgp + pattern + bgp - - - + triple + + + - + + term + variable + + autoGenerate + @@ -263,20 +301,25 @@ extension-element-prefixes="ixsl" - SELECT + query + select - - + + - - - + + + pattern + group + - union + pattern + union - group + pattern + group @@ -288,8 +331,16 @@ extension-element-prefixes="ixsl" - - + + + + + solutionModifier + limitOffset + + autoGenerate + + @@ -304,18 +355,41 @@ extension-element-prefixes="ixsl" query - SELECT + select - + - ""^^&xsd;boolean - + pattern + bind + + term + literal + + + term + namedNode + &xsd;boolean + autoGenerate + + autoGenerate + + + term + variable + inverse + autoGenerate + + autoGenerate - + + pattern + group + - group + pattern + group @@ -340,31 +414,37 @@ extension-element-prefixes="ixsl" - - filter + + pattern + filter - operation + expression + operation ! - operation + expression + operation isliteral - + - - filter + + pattern + filter - operation + expression + operation exists - group + pattern + group @@ -379,12 +459,16 @@ extension-element-prefixes="ixsl" - - - - + + + + + solutionModifier + group + + autoGenerate - + @@ -432,7 +516,7 @@ extension-element-prefixes="ixsl" - + @@ -449,49 +533,62 @@ extension-element-prefixes="ixsl" - union + pattern + union - bgp + pattern + bgp - ? - - ? + triple + + + - ? - - ? + triple + + + - graph + pattern + graph - bgp + pattern + bgp - ? - - ? + triple + + + - ? - - ? + triple + + + - ? + + term + variable + + autoGenerate + @@ -507,24 +604,30 @@ extension-element-prefixes="ixsl" - + - - - ? - - + + solutionModifier + order + + + + false + + + autoGenerate + - + @@ -532,9 +635,10 @@ extension-element-prefixes="ixsl" - + - ? + + false @@ -544,10 +648,10 @@ extension-element-prefixes="ixsl" - + - + @@ -555,13 +659,10 @@ extension-element-prefixes="ixsl" - + - - - ? - + @@ -573,7 +674,7 @@ extension-element-prefixes="ixsl" - + @@ -585,7 +686,7 @@ extension-element-prefixes="ixsl" - + @@ -615,26 +716,32 @@ extension-element-prefixes="ixsl" - ? + + pattern + bind - ? - aggregate + expression + aggregate count true + - ? + + pattern + bind - ? - aggregate + expression + aggregate sample false + - ? + @@ -646,28 +753,35 @@ extension-element-prefixes="ixsl" - - - - - - ? + + + + + + solutionModifier + group + + autoGenerate - - - - - - ? - + + + solutionModifier + order + + + + + + + autoGenerate - - + + - + @@ -679,49 +793,67 @@ extension-element-prefixes="ixsl" predicate bound by VALUES --> - ? - ? - ? + triple + + + - + - optional + pattern + optional - values + pattern + values + - + + term + namedNode + + autoGenerate + - union + pattern + union - bgp + pattern + bgp - graph + pattern + graph - bgp + pattern + bgp - ? + + term + variable + + autoGenerate + @@ -755,10 +887,10 @@ extension-element-prefixes="ixsl" - + - + @@ -770,12 +902,14 @@ extension-element-prefixes="ixsl" - filter + pattern + filter - operation + expression + operation in - ? + @@ -801,12 +935,12 @@ extension-element-prefixes="ixsl" - + - + @@ -814,44 +948,22 @@ extension-element-prefixes="ixsl" - + - + - - - - - - "" - - - - @ - - - - - ^^ - - - - - - - - - - + + @@ -871,21 +983,27 @@ extension-element-prefixes="ixsl" query - SELECT + select - ? + - + - - - group - - - - - + + pattern + group + + + pattern + group + + + + + + + @@ -901,7 +1019,7 @@ extension-element-prefixes="ixsl" - + @@ -920,23 +1038,25 @@ extension-element-prefixes="ixsl" + pattern + bind - + expression + aggregate + count + true + - ? - + - * + wildcard - - aggregate - count - true + - ? + @@ -969,7 +1089,7 @@ extension-element-prefixes="ixsl" - + @@ -988,7 +1108,7 @@ extension-element-prefixes="ixsl" - + @@ -996,11 +1116,19 @@ extension-element-prefixes="ixsl" - + true - 2 + + + + solutionModifier + limitOffset + 2 + autoGenerate + + @@ -1011,13 +1139,13 @@ extension-element-prefixes="ixsl" - ? + - + @@ -1030,38 +1158,44 @@ extension-element-prefixes="ixsl" - graph + pattern + graph - bgp + pattern + bgp - ? - ? - ? + triple + + + - ? + - graph + pattern + graph - bgp + pattern + bgp - ? - &sioc;has_container - ? + triple + + + - ? + @@ -1076,7 +1210,7 @@ extension-element-prefixes="ixsl" - + @@ -1085,14 +1219,16 @@ extension-element-prefixes="ixsl" - - - _: + triple + + + - _: - &rdf;type - + triple + + + @@ -1107,7 +1243,7 @@ extension-element-prefixes="ixsl" - + @@ -1116,16 +1252,18 @@ extension-element-prefixes="ixsl" - filter + pattern + filter - operation + expression + operation regex - ? - "" + + - "" + @@ -1141,7 +1279,7 @@ extension-element-prefixes="ixsl" - + @@ -1149,21 +1287,37 @@ extension-element-prefixes="ixsl" - values + pattern + values + + + + + - - - + + + + + + + + + + + + + autoGenerate - \ No newline at end of file + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl index 6d3f2bbd3f..68220bf731 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl @@ -469,13 +469,37 @@ exclude-result-prefixes="#all" CONSTRUCT templates are expanded onto a single instance — one bnode prototype typed with all the classes, value-range markers as sibling Descriptions in the same document. --> - - - + + + + + + + + + + + + + - + + + + + + + + + + + - + - + @@ -506,57 +530,41 @@ exclude-result-prefixes="#all" - - + + + - + - - - + - - - - - + - - - - - - - - - + + + - - - - - - - - + + + - - + + - - + + - + @@ -579,21 +587,23 @@ exclude-result-prefixes="#all" - + Constructor skipped: a non-empty WHERE clause cannot be instantiated: - - + + - - Constructor template triple skipped: variable predicate + + Constructor template triple skipped: variable predicate - - - + triple + + + + autoGenerate @@ -606,18 +616,20 @@ exclude-result-prefixes="#all" - - + + - + - _:instance - &rdf;type - + triple + + + + autoGenerate diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl index bd2f42e1ad..18530b980e 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/layout.xsl @@ -312,7 +312,7 @@ exclude-result-prefixes="#all"> - + @@ -397,8 +397,8 @@ exclude-result-prefixes="#all"> - - + + @@ -960,4 +960,4 @@ WHERE - \ No newline at end of file + diff --git a/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java new file mode 100644 index 0000000000..289ce970a3 --- /dev/null +++ b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2026 Martynas Jusevičius + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.atomgraph.linkeddatahub.writer.function; + +import net.sf.saxon.s9api.SaxonApiException; +import net.sf.saxon.s9api.XdmAtomicValue; +import net.sf.saxon.s9api.XdmValue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the server-side construct subset emitted in the Traqula AST shape. + */ +public class ParseQueryTest +{ + + private String parse(String query) throws SaxonApiException + { + XdmValue result = new ParseQuery().call(new XdmValue[] { new XdmAtomicValue(query) }); + return result.itemAt(0).getStringValue().replaceAll("\\s+", ""); + } + + @Test + public void testConstructTemplateUsesTypedTraqulaTerms() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?s \"hello\"@en } WHERE { }"); + + assertTrue(json.contains("\"subType\":\"construct\"")); + assertTrue(json.contains("\"template\":{\"type\":\"pattern\",\"subType\":\"bgp\"")); + assertTrue(json.contains("\"subType\":\"variable\",\"value\":\"s\"")); + assertTrue(json.contains("\"subType\":\"namedNode\",\"value\":\"https://example.com/p\"")); + assertTrue(json.contains("\"subType\":\"literal\",\"value\":\"hello\",\"langOrIri\":\"en\""), json); + assertTrue(json.contains("\"where\":{\"type\":\"pattern\",\"subType\":\"group\",\"patterns\":[]")); + } + + @Test + public void testNonemptyWhereIsMarkedAsNonInstantiable() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?s ?o } WHERE { ?s ?p ?o }"); + + assertTrue(json.contains("\"where\":{\"type\":\"pattern\",\"subType\":\"group\",\"patterns\":[{}]"), json); + } + +} From fecbc07211682a6f6a0d4df1dba1c8565572f6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:19:43 +0100 Subject: [PATCH 02/13] The SPARQL bundle is built from the Traqula 1.4.0 release, and its shim hands the stylesheets flat triples with full IRIs and fills in the source locations and query members the generator needs Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + src/main/js/sparql/index.js | 143 ++++++++++++++++-- src/main/js/sparql/package-lock.json | 38 ++--- src/main/js/sparql/package.json | 4 +- src/main/js/sparql/test/traqula.test.js | 107 +++++++++++-- .../atomgraph/linkeddatahub/js/traqula.min.js | 126 +++++++-------- 6 files changed, 309 insertions(+), 110 deletions(-) diff --git a/.gitignore b/.gitignore index b8dbaa1f48..1c18d37673 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ /tests/ui/test-results /rdf/target/ /src/main/js/graph3d/node_modules +/src/main/js/sparql/node_modules diff --git a/src/main/js/sparql/index.js b/src/main/js/sparql/index.js index 94660b25d2..7c07bdfe6d 100644 --- a/src/main/js/sparql/index.js +++ b/src/main/js/sparql/index.js @@ -1,30 +1,145 @@ import { Parser as TraqulaParser } from '@traqula/parser-sparql-1-1'; import { Generator as TraqulaGenerator } from '@traqula/generator-sparql-1-1'; -function expandPrefixes(node, inheritedPrefixes = new Map()) { +// The stylesheets read and rewrite Traqula's AST as JSON (json-to-xml / xml-to-json). This shim keeps that AST in +// a shape the stylesheets can compare and edit without knowing Traqula's source-tracking details: +// - parse() expands prefixed names and BASE-relative IRIs to full IRIs, so a predicate compares as the IRI it is; +// - parse() flattens blank-node property lists ([ ... ]) and collections (( ... )) into plain triples, and gives +// every triple a subject and predicate of its own (Traqula marks repeats after ';' and ',' as not printed), so a +// triple can be matched, moved or appended on its own; +// - generate() gives every node the source location the generator needs, wraps union branches in groups, and +// fills the members a query needs (prologue, dataset clause, solution modifiers), so a stylesheet never writes +// them. + +const AUTO = () => ({ sourceLocationType: 'autoGenerate' }); + +function resolveIri(value, base) { + if (!base) return value; + try { + return new URL(value, base).href; + } catch { + return value; + } +} + +function expandIris(node, scope = { prefixes: new Map(), base: undefined }) { if (Array.isArray(node)) { - node.forEach((value) => expandPrefixes(value, inheritedPrefixes)); + node.forEach((value) => expandIris(value, scope)); return node; } if (!node || typeof node !== 'object') return node; - const prefixes = new Map(inheritedPrefixes); - if (Array.isArray(node.context)) { + let inner = scope; + if (Array.isArray(node.context) && node.context.length > 0) { + inner = { prefixes: new Map(scope.prefixes), base: scope.base }; for (const definition of node.context) { - if (definition.subType === 'prefix' && definition.key && definition.value?.value) { - prefixes.set(definition.key, definition.value.value); + if (definition.subType === 'base' && definition.value?.value) { + inner.base = resolveIri(definition.value.value, inner.base); + } + if (definition.subType === 'prefix' && definition.key !== undefined && definition.value?.value) { + inner.prefixes.set(definition.key, resolveIri(definition.value.value, inner.base)); } } } - if (node.type === 'term' && node.subType === 'namedNode' && node.prefix) { - const namespace = prefixes.get(node.prefix); - if (!namespace) throw new Error(`Undefined SPARQL prefix: ${node.prefix}`); - node.value = namespace + node.value; - delete node.prefix; + if (node.type === 'term' && node.subType === 'namedNode') { + if (node.prefix !== undefined) { + const namespace = inner.prefixes.get(node.prefix); + if (namespace === undefined) throw new Error(`Undefined SPARQL prefix: ${node.prefix}`); + node.value = namespace + node.value; + delete node.prefix; + } else { + node.value = resolveIri(node.value, inner.base); + } + } + + for (const [key, value] of Object.entries(node)) { + if (key !== 'context') expandIris(value, inner); } + return node; +} - for (const value of Object.values(node)) expandPrefixes(value, prefixes); +// a graph node as a plain term, emitting the triples of a blank-node property list or collection into out +function flattenNode(node, out) { + if (node && node.type === 'tripleCollection') { + for (const triple of node.triples) flattenTriple(triple, out); + return materialize(node.identifier); + } + return materialize(node); +} + +function flattenTriple(triple, out) { + if (triple.type === 'tripleCollection') { + flattenNode(triple, out); + return; + } + const subject = flattenNode(triple.subject, out); + const object = flattenNode(triple.object, out); + out.push({ ...triple, subject, predicate: materialize(triple.predicate), object, loc: AUTO() }); +} + +function materialize(term) { + return term && typeof term === 'object' ? { ...term, loc: AUTO() } : term; +} + +function flattenBgps(node) { + if (Array.isArray(node)) { + node.forEach(flattenBgps); + return node; + } + if (!node || typeof node !== 'object') return node; + if (node.type === 'pattern' && node.subType === 'bgp' && Array.isArray(node.triples)) { + const out = []; + for (const triple of node.triples) flattenTriple(triple, out); + node.triples = out; + } + for (const value of Object.values(node)) flattenBgps(value); + return node; +} + +function group(patterns) { + return { type: 'pattern', subType: 'group', patterns, loc: AUTO() }; +} + +// the members the generator dereferences, filled where a stylesheet-built node lacks them +function complete(node) { + if (node.type === 'query') { + if (!Array.isArray(node.context)) node.context = []; + if (!node.datasets) node.datasets = { type: 'datasetClauses', clauses: [] }; + if (!node.solutionModifiers) node.solutionModifiers = {}; + if (node.subType !== 'describe' && !node.where) node.where = group([]); + const modifiers = node.solutionModifiers; + const limitOffset = modifiers.limitOffset; + if (limitOffset) { + if (limitOffset.limit === undefined && !limitOffset.offset) delete modifiers.limitOffset; + else Object.assign(limitOffset, { type: 'solutionModifier', subType: 'limitOffset' }); + } + if (modifiers.order && !(modifiers.order.orderDefs?.length > 0)) delete modifiers.order; + if (modifiers.group && !(modifiers.group.groupings?.length > 0)) delete modifiers.group; + } + if (node.type === 'pattern' && node.subType === 'union' && Array.isArray(node.patterns)) { + node.patterns = node.patterns.map(pattern => pattern.type === 'pattern' && pattern.subType === 'group' ? pattern : group([ pattern ])); + } +} + +// every object the generator visits carries a source location; the rows of VALUES are keyed by variable name +// and are not nodes, so they get none (a variable named 'loc' would otherwise be clobbered) +function localize(node, rows = false) { + if (Array.isArray(node)) { + node.forEach(value => localize(value, rows)); + return node; + } + if (!node || typeof node !== 'object') return node; + if (rows) { + for (const value of Object.values(node)) localize(value); + return node; + } + if (typeof node.type === 'string') complete(node); + if (!node.loc) node.loc = AUTO(); + for (const [key, value] of Object.entries(node)) { + if (key === 'loc') continue; + localize(value, key === 'values' && node.subType === 'values'); + } return node; } @@ -34,7 +149,7 @@ export class Parser { } parse(query) { - return expandPrefixes(this.parser.parse(query)); + return flattenBgps(expandIris(this.parser.parse(query))); } } @@ -44,7 +159,7 @@ export class Generator { } generate(ast, options) { - return this.generator.generate(ast, options); + return this.generator.generate(localize(ast), options); } } diff --git a/src/main/js/sparql/package-lock.json b/src/main/js/sparql/package-lock.json index 77f7bc4b14..6d05be3112 100644 --- a/src/main/js/sparql/package-lock.json +++ b/src/main/js/sparql/package-lock.json @@ -6,8 +6,8 @@ "": { "name": "ldh-traqula-browser", "dependencies": { - "@traqula/generator-sparql-1-1": "1.5.0-alpha.7", - "@traqula/parser-sparql-1-1": "1.5.0-alpha.7" + "@traqula/generator-sparql-1-1": "1.4.0", + "@traqula/parser-sparql-1-1": "1.4.0" }, "devDependencies": { "esbuild": "0.25.10" @@ -465,9 +465,9 @@ } }, "node_modules/@traqula/core": { - "version": "1.5.0-alpha.5", - "resolved": "https://registry.npmjs.org/@traqula/core/-/core-1.5.0-alpha.5.tgz", - "integrity": "sha512-5KqvutRWXnasccXzVA3GAnmDuBwQ8Gn+JctaIWx/jyTf3may2EahjhtfJxNxvn/R61i/95OEqWKP6Ozo8e/J0A==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@traqula/core/-/core-1.3.0.tgz", + "integrity": "sha512-xVp6sblElVsZeeXIQQ8KNRiUFqobNT/IfgWNymlUlICi69aLJWydSWsKcH+TnS5Sz7LW2BoFpoQiIcErXaXPfQ==", "license": "MIT", "dependencies": { "@traqula/chevrotain": "^1.1.0" @@ -477,39 +477,39 @@ } }, "node_modules/@traqula/generator-sparql-1-1": { - "version": "1.5.0-alpha.7", - "resolved": "https://registry.npmjs.org/@traqula/generator-sparql-1-1/-/generator-sparql-1-1-1.5.0-alpha.7.tgz", - "integrity": "sha512-t23EUganH812/eeDz8DddqTVkVThjB0YGpWPP9GlvhTxlxqXhgCp5HXpA8bx1EJgWO+GFed/PQAI8D+ABL2dFw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/generator-sparql-1-1/-/generator-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-4C3UETTYFSe8xRKwxkbddRgmBfMncpgk3lcmbgFaFsVatHpZe2CdKFZc+oW+hF8tOu2biJXc09YUdKeWiFNOzw==", "license": "MIT", "dependencies": { - "@traqula/core": "^1.5.0-alpha.5", - "@traqula/rules-sparql-1-1": "^1.5.0-alpha.6" + "@traqula/core": "^1.3.0", + "@traqula/rules-sparql-1-1": "^1.4.0" }, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@traqula/parser-sparql-1-1": { - "version": "1.5.0-alpha.7", - "resolved": "https://registry.npmjs.org/@traqula/parser-sparql-1-1/-/parser-sparql-1-1-1.5.0-alpha.7.tgz", - "integrity": "sha512-b5sKuoyeE6whbXaq7/REl5PVMZFLoG5wOvMunmkUstcS7KP9Q1Su4RMIRvk3lt78qa3NmFfsfP3o++ZgDCdoyQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/parser-sparql-1-1/-/parser-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-+EcGTlk7QzRBJVH81pE8SDNSneD1glYnfcVNkQi4yWXA7Tw0IYfsINKmNawfJxylcjGr44arh3Qn4HBNtB2agg==", "license": "MIT", "dependencies": { - "@traqula/core": "^1.5.0-alpha.5", - "@traqula/rules-sparql-1-1": "^1.5.0-alpha.6" + "@traqula/core": "^1.3.0", + "@traqula/rules-sparql-1-1": "^1.4.0" }, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@traqula/rules-sparql-1-1": { - "version": "1.5.0-alpha.6", - "resolved": "https://registry.npmjs.org/@traqula/rules-sparql-1-1/-/rules-sparql-1-1-1.5.0-alpha.6.tgz", - "integrity": "sha512-ZgJbh2Bk1xXk6KcajoISNCaYdOKuBmis+T4ZvqVmjAhzJCohdJDDtvzBAWKlc8cDJWKLiYAwmFyLnS1GLrPAcA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@traqula/rules-sparql-1-1/-/rules-sparql-1-1-1.4.0.tgz", + "integrity": "sha512-EuFbKVUOJQGBlRqoG6+aNoZXft3p1H9a4Yn9iHYsxgv5AKlUu8XzweyKh3ouvQk3P+qO2KWnsGwZ8Z3kEPQ/jg==", "license": "MIT", "dependencies": { "@traqula/chevrotain": "^1.1.0", - "@traqula/core": "^1.5.0-alpha.5" + "@traqula/core": "^1.3.0" }, "engines": { "node": "^20.19.0 || >=22.12.0" diff --git a/src/main/js/sparql/package.json b/src/main/js/sparql/package.json index 8031fe4f24..287d02185d 100644 --- a/src/main/js/sparql/package.json +++ b/src/main/js/sparql/package.json @@ -8,8 +8,8 @@ "test": "node --test" }, "dependencies": { - "@traqula/generator-sparql-1-1": "1.5.0-alpha.7", - "@traqula/parser-sparql-1-1": "1.5.0-alpha.7" + "@traqula/generator-sparql-1-1": "1.4.0", + "@traqula/parser-sparql-1-1": "1.4.0" }, "devDependencies": { "esbuild": "0.25.10" diff --git a/src/main/js/sparql/test/traqula.test.js b/src/main/js/sparql/test/traqula.test.js index ef52511f75..6c2450e125 100644 --- a/src/main/js/sparql/test/traqula.test.js +++ b/src/main/js/sparql/test/traqula.test.js @@ -2,6 +2,12 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import { Generator, Parser } from '../index.js'; +// what the stylesheets do to an AST: serialise it to JSON and read it back +const roundTrip = ast => JSON.parse(JSON.stringify(ast)); +const loc = () => ({ sourceLocationType: 'autoGenerate' }); +const variable = value => ({ type: 'term', subType: 'variable', value }); +const iri = value => ({ type: 'term', subType: 'namedNode', value }); + test('parses and generates SELECT queries with the Traqula AST', () => { const query = 'PREFIX ex: SELECT ?s WHERE { ?s ex:p ?o OPTIONAL { ?s ex:q ?v } FILTER(?o > 2) VALUES ?v { ex:a ex:b } } ORDER BY DESC(?s) LIMIT 5 OFFSET 2'; const ast = new Parser().parse(query); @@ -13,9 +19,8 @@ test('parses and generates SELECT queries with the Traqula AST', () => { assert.equal(ast.where.subType, 'group'); assert.equal(ast.where.patterns[0].triples[0].predicate.value, 'https://example.com/p'); assert.equal('prefix' in ast.where.patterns[0].triples[0].predicate, false); - assert.ok(ast.context.some((item) => item.subType === 'prefix' && item.key === 'ex')); - const generated = new Generator().generate(ast); + const generated = new Generator().generate(roundTrip(ast)); const reparsed = new Parser().parse(generated); assert.equal(reparsed.subType, 'select'); assert.equal(reparsed.where.patterns.length, 4); @@ -24,16 +29,79 @@ test('parses and generates SELECT queries with the Traqula AST', () => { assert.equal(reparsed.solutionModifiers.order.orderDefs[0].descending, true); }); -test('preserves typed CONSTRUCT template terms and named graph IRIs', () => { - const ast = new Parser().parse('CONSTRUCT { ?s ?o } WHERE { GRAPH { ?s ?p ?o } }'); - const triple = ast.template.triples[0]; +test('resolves BASE-relative IRIs', () => { + const ast = new Parser().parse('BASE SELECT * { ?s

<../o> }'); + const [ triple ] = ast.where.patterns[0].triples; + + assert.equal(triple.predicate.value, 'https://example.com/dir/p'); + assert.equal(triple.object.value, 'https://example.com/o'); +}); + +test('gives every triple of a predicate-object list its own subject and predicate', () => { + const ast = roundTrip(new Parser().parse('SELECT * { ?s ?a, ?b ; ?c }')); + const triples = ast.where.patterns[0].triples; + + assert.equal(triples.length, 3); + assert.ok(triples.every(triple => triple.subject.value === 's' && triple.subject.loc.sourceLocationType === 'autoGenerate')); + assert.ok(triples.every(triple => triple.predicate.loc.sourceLocationType === 'autoGenerate')); + + // a triple moved on its own still prints its subject + ast.where.patterns[0].triples = [ triples[2] ]; + assert.match(new Generator().generate(ast), /\?s\s+\s+\?c/); +}); + +test('flattens blank-node property lists and collections in CONSTRUCT templates', () => { + const ast = new Parser().parse('PREFIX ex: CONSTRUCT { $this ex:p [ a ex:T ] ; ex:list ( 1 2 ) } WHERE {}'); + const triples = ast.template.triples; - assert.equal(ast.subType, 'construct'); - assert.equal(triple.subject.subType, 'variable'); - assert.equal(triple.predicate.subType, 'namedNode'); - assert.equal(triple.predicate.value, 'https://example.com/p'); - assert.equal(ast.where.patterns[0].subType, 'graph'); - assert.match(new Generator().generate(ast), /CONSTRUCT/); + assert.ok(triples.every(triple => triple.type === 'triple')); + assert.ok(triples.every(triple => [ 'variable', 'namedNode', 'blankNode', 'literal' ].includes(triple.subject.subType))); + const link = triples.find(triple => triple.predicate.value === 'https://example.com/p'); + assert.equal(link.subject.value, 'this'); + assert.equal(link.object.subType, 'blankNode'); + assert.ok(triples.some(triple => triple.subject.label === link.object.label && triple.object.value === 'https://example.com/T')); + assert.equal(triples.filter(triple => triple.predicate.value === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first').length, 2); + + const reparsed = new Parser().parse(new Generator().generate(roundTrip(ast))); + assert.equal(reparsed.template.triples.length, triples.length); +}); + +test('generates nodes built without source locations, query members or grouped union branches', () => { + const bgp = { type: 'pattern', subType: 'bgp', triples: [ { type: 'triple', subject: variable('s'), predicate: iri('https://example.com/p'), object: variable('o') } ] }; + const ast = { + type: 'query', + subType: 'select', + variables: [ variable('s'), { + type: 'pattern', subType: 'bind', + expression: { type: 'expression', subType: 'aggregate', aggregation: 'count', distinct: true, expression: [ { type: 'wildcard' } ] }, + variable: variable('count'), + } ], + where: { type: 'pattern', subType: 'group', patterns: [ + { type: 'pattern', subType: 'union', patterns: [ bgp, { type: 'pattern', subType: 'graph', name: variable('g'), patterns: [ bgp ] } ] }, + { type: 'pattern', subType: 'filter', expression: { type: 'expression', subType: 'patternOperation', operator: 'exists', args: { type: 'pattern', subType: 'group', patterns: [ bgp ] } } }, + { type: 'pattern', subType: 'values', variables: [ variable('loc') ], values: [ { loc: iri('https://example.com/a') } ] }, + ] }, + solutionModifiers: { + group: { type: 'solutionModifier', subType: 'group', groupings: [ variable('s') ] }, + order: { type: 'solutionModifier', subType: 'order', orderDefs: [ { expression: variable('count'), descending: true } ] }, + limitOffset: { limit: 10 }, + }, + }; + + const generated = new Generator().generate(ast); + const reparsed = new Parser().parse(generated); + assert.equal(reparsed.where.patterns[0].subType, 'union'); + assert.equal(reparsed.where.patterns[1].expression.subType, 'patternOperation'); + assert.equal(reparsed.where.patterns[2].values[0].loc.value, 'https://example.com/a'); + assert.equal(reparsed.solutionModifiers.limitOffset.limit, 10); + assert.equal(reparsed.solutionModifiers.order.orderDefs[0].descending, true); +}); + +test('drops empty solution modifiers', () => { + const ast = roundTrip(new Parser().parse('SELECT * { ?s ?p ?o } LIMIT 5')); + ast.solutionModifiers.limitOffset = { type: 'solutionModifier', subType: 'limitOffset', loc: loc() }; + + assert.doesNotMatch(new Generator().generate(ast), /LIMIT/); }); test('preserves language and datatype terms in SPARQL updates', () => { @@ -44,5 +112,20 @@ test('preserves language and datatype terms in SPARQL updates', () => { assert.equal(triples[0].object.subType, 'literal'); assert.equal(triples[0].object.langOrIri, 'en'); assert.equal(triples[1].object.langOrIri.value, 'http://www.w3.org/2001/XMLSchema#integer'); - assert.match(new Generator().generate(ast), /INSERT DATA/); + assert.match(new Generator().generate(roundTrip(ast)), /INSERT DATA/); +}); + +test('generates blank nodes from their label', () => { + const ast = { + type: 'update', + updates: [ { context: [], operation: { + type: 'updateOperation', subType: 'modify', graph: undefined, delete: [], from: { type: 'datasetClauses', clauses: [] }, + insert: [ { type: 'pattern', subType: 'bgp', triples: [ { type: 'triple', subject: { type: 'term', subType: 'blankNode', label: 'b1' }, predicate: iri('https://example.com/p'), object: { type: 'term', subType: 'literal', value: 'a "quoted"\nvalue' } } ] } ], + where: { type: 'pattern', subType: 'group', patterns: [] }, + } } ], + }; + + const generated = new Generator().generate(ast); + assert.match(generated, /_:b1/); + assert.equal(new Parser().parse(generated).updates[0].operation.insert[0].triples[0].object.value, 'a "quoted"\nvalue'); }); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js index fbb50c92d5..d2e08423a2 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/traqula.min.js @@ -1,80 +1,80 @@ -(()=>{var Wm=Object.defineProperty;var Mt=(e,t)=>{for(var r in t)Wm(e,r,{get:t[r],enumerable:!0})};var tr=class{tracksSourceLocation;constructor(t={}){this.tracksSourceLocation=t.tracksSourceLocation??!0}wrap(t,r){return{val:t,loc:r}}isLocalized(t){return typeof t=="object"&&t!==null&&"loc"in t&&typeof t.loc=="object"&&t.loc!==null&&"sourceLocationType"in t.loc}sourceLocation(...t){if(!this.tracksSourceLocation)return this.gen();let r=t.filter(a=>a!==void 0);if(r.length===0)return this.sourceLocationNoMaterialize();let n=r.filter(a=>!this.isLocalized(a)||this.isSourceLocationSource(a.loc)||this.isSourceLocationStringReplace(a.loc)||this.isSourceLocationNodeReplace(a.loc));if(n.length===0)return this.gen();let i=n.at(0),s=n.at(-1);return{sourceLocationType:"source",start:this.isLocalized(i)?i.loc.start:i.startOffset,end:this.isLocalized(s)?s.loc.end:s.endOffset+1}}sourceLocationNoMaterialize(){return this.tracksSourceLocation?{sourceLocationType:"noMaterialize"}:this.gen()}dematerialized(t){return{...t,loc:this.sourceLocationNoMaterialize()}}safeObjectTransform(t,r){return t&&typeof t=="object"?Array.isArray(t)?t.map(n=>this.safeObjectTransform(n,r)):r(t):t}forcedAutoGenTree(t){let r={...t};for(let[n,i]of Object.entries(r))r[n]=this.safeObjectTransform(i,s=>this.forcedAutoGenTree(s));return this.isLocalized(r)&&(r.loc=this.gen()),r}forceMaterialized(t){return this.isSourceLocationNoMaterialize(t.loc)?this.forcedAutoGenTree(t):{...t}}isSourceLocation(t){return"sourceLocationType"in t}sourceLocationSource(t,r){return{sourceLocationType:"source",start:t,end:r}}sourceLocationInlinedSource(t,r,n,i,s=0,a=t.length){return this.tracksSourceLocation?(this.isSourceLocationSource(r)&&(s=r.start,a=r.end),{sourceLocationType:"inlinedSource",newSource:t,start:n,end:i,loc:r,startOnNew:s,endOnNew:a}):this.gen()}isSourceLocationInlinedSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="inlinedSource"}gen(){return{sourceLocationType:"autoGenerate"}}isSourceLocationSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="source"}sourceLocationStringReplace(t,r,n){return this.tracksSourceLocation?{sourceLocationType:"stringReplace",newSource:t,start:r,end:n}:this.gen()}isSourceLocationStringReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="stringReplace"}sourceLocationNodeReplaceUnsafe(t){if(this.isSourceLocationSource(t))return this.sourceLocationNodeReplace(t);if(this.isSourceLocationInlinedSource(t))return this.sourceLocationNodeReplaceUnsafe(t.loc);throw new Error(`Cannot convert SourceLocation of type ${t.sourceLocationType} to SourceLocationNodeReplace`)}sourceLocationNodeReplace(t,r){let n,i;return typeof t=="number"?(n=t,i=r):(n=t.start,i=t.end),{sourceLocationType:"nodeReplace",start:n,end:i}}isSourceLocationNodeReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="nodeReplace"}isSourceLocationNodeAutoGenerate(t){return this.isSourceLocation(t)&&t.sourceLocationType==="autoGenerate"}isPrintingLoc(t){return this.isSourceLocationNodeReplace(t)||this.isSourceLocationNodeAutoGenerate(t)||this.isSourceLocationInlinedSource(t)&&this.isPrintingLoc(t.loc)}printFilter(t,r){this.isPrintingLoc(t.loc)&&r()}isSourceLocationNoMaterialize(t){return this.isSourceLocation(t)&&t.sourceLocationType==="noMaterialize"}isOfType(t,r){return t.type===r}isOfSubType(t,r,n){let i=t;return i.type===r&&i.subType===n}};var zm=typeof global=="object"&&global&&global.Object===Object&&global,wc=zm,Ym=typeof self=="object"&&self&&self.Object===Object&&self,qm=wc||Ym||Function("return this")(),it=qm,Xm=it.Symbol,$e=Xm,Rc=Object.prototype,Qm=Rc.hasOwnProperty,Bm=Rc.toString,Or=$e?$e.toStringTag:void 0;function Zm(e){var t=Qm.call(e,Or),r=e[Or];try{e[Or]=void 0;var n=!0}catch{}var i=Bm.call(e);return n&&(t?e[Or]=r:delete e[Or]),i}var Jm=Zm,Um=Object.prototype,eg=Um.toString;function tg(e){return eg.call(e)}var rg=tg,ng="[object Null]",ig="[object Undefined]",Nl=$e?$e.toStringTag:void 0;function sg(e){return e==null?e===void 0?ig:ng:Nl&&Nl in Object(e)?Jm(e):rg(e)}var St=sg;function ag(e){return e!=null&&typeof e=="object"}var Qe=ag,og="[object Symbol]";function lg(e){return typeof e=="symbol"||Qe(e)&&St(e)==og}var zn=lg;function cg(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r0){if(++t>=lT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var hT=pT;function fT(e){return function(){return e}}var dT=fT,mT=(function(){try{var e=Ht(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Fn=mT,gT=Fn?function(e,t){return Fn(e,"toString",{configurable:!0,enumerable:!1,value:dT(t),writable:!0})}:Kr,TT=gT,vT=hT(TT),yT=vT;function AT(e,t){for(var r=-1,n=e==null?0:e.length;++r-1}var Dc=OT,ST=9007199254740991,NT=/^(?:0|[1-9]\d*)$/;function PT(e,t){var r=typeof e;return t=t??ST,!!t&&(r=="number"||r!="symbol"&&NT.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=VT}var ha=jT;function KT(e){return e!=null&&ha(e.length)&&!vt(e)}var st=KT;function HT(e,t,r){if(!Ve(r))return!1;var n=typeof t;return(n=="number"?st(r)&&Yn(t,r.length):n=="string"&&t in r)?Hr(r[t],e):!1}var Xn=HT;function WT(e){return pa(function(t,r){var n=-1,i=r.length,s=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(s=e.length>3&&typeof s=="function"?(i--,s):void 0,a&&Xn(r[0],r[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++n-1}var wy=ky;function Ry(e,t){var r=this.__data__,n=Zn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var Fy=Ry;function lr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0&&r(o)?t>1?zc(o,t-1,r,n,i):Ta(i,o):n||(i[i.length]=o)}return i}var va=zc;function dA(e){var t=e==null?0:e.length;return t?va(e,1):[]}var qe=dA,mA=Kc(Object.getPrototypeOf,Object),Yc=mA;function gA(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(i);++n=n?e:ya(e,t,r)}var vA=TA,yA="\\ud800-\\udfff",AA="\\u0300-\\u036f",xA="\\ufe20-\\ufe2f",bA="\\u20d0-\\u20ff",IA=AA+xA+bA,EA="\\ufe0e\\ufe0f",LA="\\u200d",_A=RegExp("["+LA+yA+IA+EA+"]");function OA(e){return _A.test(e)}var qc=OA;function SA(e){return e.split("")}var NA=SA,Xc="\\ud800-\\udfff",PA="\\u0300-\\u036f",kA="\\ufe20-\\ufe2f",wA="\\u20d0-\\u20ff",RA=PA+kA+wA,FA="\\ufe0e\\ufe0f",CA="["+Xc+"]",Qs="["+RA+"]",Bs="\\ud83c[\\udffb-\\udfff]",MA="(?:"+Qs+"|"+Bs+")",Qc="[^"+Xc+"]",Bc="(?:\\ud83c[\\udde6-\\uddff]){2}",Zc="[\\ud800-\\udbff][\\udc00-\\udfff]",DA="\\u200d",Jc=MA+"?",Uc="["+FA+"]?",GA="(?:"+DA+"(?:"+[Qc,Bc,Zc].join("|")+")"+Uc+Jc+")*",$A=Uc+Jc+GA,VA="(?:"+[Qc+Qs+"?",Qs,Bc,Zc,CA].join("|")+")",jA=RegExp(Bs+"(?="+Bs+")|"+VA+$A,"g");function KA(e){return e.match(jA)||[]}var HA=KA;function WA(e){return qc(e)?HA(e):NA(e)}var zA=WA;function YA(e){return function(t){t=Wc(t);var r=qc(t)?zA(t):void 0,n=r?r[0]:t.charAt(0),i=r?vA(r,1).join(""):t.slice(1);return n[e]()+i}}var qA=YA,ZS=qA("toUpperCase");function XA(e,t,r,n){var i=-1,s=e==null?0:e.length;for(n&&s&&(r=e[++i]);++io))return!1;var u=s.get(e),p=s.get(t);if(u&&p)return u==t&&p==e;var h=-1,f=!0,m=r&mI?new Ia:void 0;for(s.set(e,t),s.set(t,e);++h2?t[2]:void 0;for(i&&Xn(t[0],t[1],i)&&(n=1);++r=CE&&(s=Ea,a=!1,t=new Ia(t));e:for(;++i-1?i[s?t[a]:a]:void 0}}var UE=JE,eL=Math.max;function tL(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:jr(r);return i<0&&(i=eL(n+i,0)),Mc(e,at(t,3),i)}var rL=tL,nL=UE(rL),sr=nL;function iL(e){return e&&e.length?e[0]:void 0}var Be=iL;function sL(e,t){var r=-1,n=st(e)?Array(e.length):[];return Wt(e,function(i,s,a){n[++r]=t(i,s,a)}),n}var aL=sL;function oL(e,t){var r=M(e)?Vr:aL;return r(e,at(t,3))}var O=oL;function lL(e,t){return va(O(e,t),1)}var Ge=lL,cL=Object.prototype,uL=cL.hasOwnProperty,pL=PE(function(e,t,r){uL.call(e,r)?e[r].push(t):ua(e,r,[t])}),hL=pL,fL=Object.prototype,dL=fL.hasOwnProperty;function mL(e,t){return e!=null&&dL.call(e,t)}var gL=mL;function TL(e,t){return e!=null&&du(e,t,gL)}var S=TL,vL="[object String]";function yL(e){return typeof e=="string"||!M(e)&&Qe(e)&&St(e)==vL}var Oe=yL;function AL(e,t){return Vr(t,function(r){return e[r]})}var xL=AL;function bL(e){return e==null?[]:xL(e,Pe(e))}var ce=bL,IL=Math.max;function EL(e,t,r,n){e=st(e)?e:ce(e),r=r&&!n?jr(r):0;var i=e.length;return r<0&&(r=IL(i+r,0)),Oe(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&ca(e,t,r)>-1}var be=EL,LL=Math.max;function _L(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:jr(r);return i<0&&(i=LL(n+i,0)),ca(e,t,i)}var oc=_L,OL="[object Map]",SL="[object Set]",NL=Object.prototype,PL=NL.hasOwnProperty;function kL(e){if(e==null)return!0;if(st(e)&&(M(e)||typeof e=="string"||typeof e.splice=="function"||Mr(e)||fa(e)||Qn(e)))return!e.length;var t=ir(e);if(t==OL||t==SL)return!e.size;if(zr(e))return!Hc(e).length;for(var r in e)if(PL.call(e,r))return!1;return!0}var z=kL,wL="[object RegExp]";function RL(e){return Qe(e)&&St(e)==wL}var FL=RL,lc=_t&&_t.isRegExp,CL=lc?Yr(lc):FL,mt=CL;function ML(e){return e===void 0}var gt=ML,DL="Expected a function";function GL(e){if(typeof e!="function")throw new TypeError(DL);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var $L=GL;function VL(e,t,r,n){if(!Ve(e))return e;t=ti(t,e);for(var i=-1,s=t.length,a=s-1,o=e;o!=null&&++i=t_){var u=t?null:e_(e);if(u)return La(u);a=!1,i=Ea,l=new Ia}else l=t?[]:o;e:for(;++n{t.accept(e)})}},Re=class extends ot{constructor(e){super([]),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},pr=class extends ot{constructor(e){super(e.definition),this.orgText="",ke(this,Ze(e,t=>t!==void 0))}},Se=class extends ot{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,ke(this,Ze(e,t=>t!==void 0))}},Le=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},lt=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},ct=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},ue=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},Je=class extends ot{constructor(e){super(e.definition),this.idx=1,ke(this,Ze(e,t=>t!==void 0))}},Ue=class extends ot{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,ke(this,Ze(e,t=>t!==void 0))}},U=class{constructor(e){this.idx=1,ke(this,Ze(e,t=>t!==void 0))}accept(e){e.visit(this)}};function o_(e){return O(e,Nn)}function Nn(e){function t(r){return O(r,Nn)}if(e instanceof Re){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Oe(e.label)&&(r.label=e.label),r}else{if(e instanceof Se)return{type:"Alternative",definition:t(e.definition)};if(e instanceof Le)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof lt)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof ct)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Nn(new U({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof Je)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Nn(new U({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ue)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof Ue)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof U){let r={type:"Terminal",name:e.terminalType.name,label:s_(e.terminalType),idx:e.idx};Oe(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=mt(n)?n.source:n),r}else{if(e instanceof pr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var hr=class{visit(e){let t=e;switch(t.constructor){case Re:return this.visitNonTerminal(t);case Se:return this.visitAlternative(t);case Le:return this.visitOption(t);case lt:return this.visitRepetitionMandatory(t);case ct:return this.visitRepetitionMandatoryWithSeparator(t);case Je:return this.visitRepetitionWithSeparator(t);case ue:return this.visitRepetition(t);case Ue:return this.visitAlternation(t);case U:return this.visitTerminal(t);case pr:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function l_(e){return e instanceof Se||e instanceof Le||e instanceof ue||e instanceof lt||e instanceof ct||e instanceof Je||e instanceof U||e instanceof pr}function Dn(e,t=[]){return e instanceof Le||e instanceof ue||e instanceof Je?!0:e instanceof Ue?vu(e.definition,n=>Dn(n,t)):e instanceof Re&&be(t,e)?!1:e instanceof ot?(e instanceof Re&&t.push(e),Xe(e.definition,n=>Dn(n,t))):!1}function c_(e){return e instanceof Ue}function nt(e){if(e instanceof Re)return"SUBRULE";if(e instanceof Le)return"OPTION";if(e instanceof Ue)return"OR";if(e instanceof lt)return"AT_LEAST_ONE";if(e instanceof ct)return"AT_LEAST_ONE_SEP";if(e instanceof Je)return"MANY_SEP";if(e instanceof ue)return"MANY";if(e instanceof U)return"CONSUME";throw Error("non exhaustive match")}var ii=class{walk(e,t=[]){N(e.definition,(r,n)=>{let i=de(e.definition,n+1);if(r instanceof Re)this.walkProdRef(r,i,t);else if(r instanceof U)this.walkTerminal(r,i,t);else if(r instanceof Se)this.walkFlat(r,i,t);else if(r instanceof Le)this.walkOption(r,i,t);else if(r instanceof lt)this.walkAtLeastOne(r,i,t);else if(r instanceof ct)this.walkAtLeastOneSep(r,i,t);else if(r instanceof Je)this.walkManySep(r,i,t);else if(r instanceof ue)this.walkMany(r,i,t);else if(r instanceof Ue)this.walkOr(r,i,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){let n=t.concat(r);this.walk(e,n)}walkOption(e,t,r){let n=t.concat(r);this.walk(e,n)}walkAtLeastOne(e,t,r){let n=[new Le({definition:e.definition})].concat(t,r);this.walk(e,n)}walkAtLeastOneSep(e,t,r){let n=cc(e,t,r);this.walk(e,n)}walkMany(e,t,r){let n=[new Le({definition:e.definition})].concat(t,r);this.walk(e,n)}walkManySep(e,t,r){let n=cc(e,t,r);this.walk(e,n)}walkOr(e,t,r){let n=t.concat(r);N(e.definition,i=>{let s=new Se({definition:[i]});this.walk(s,n)})}};function cc(e,t,r){return[new Le({definition:[new U({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Qr(e){if(e instanceof Re)return Qr(e.referencedRule);if(e instanceof U)return h_(e);if(l_(e))return u_(e);if(c_(e))return p_(e);throw Error("non exhaustive match")}function u_(e){let t=[],r=e.definition,n=0,i=r.length>n,s,a=!0;for(;i&&a;)s=r[n],a=Dn(s),t=t.concat(Qr(s)),n=n+1,i=r.length>n;return Oa(t)}function p_(e){let t=O(e.definition,r=>Qr(r));return Oa(qe(t))}function h_(e){return[e.terminalType]}var bu="_~IN~_",f_=class extends ii{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){let n=m_(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),s=new Se({definition:i}),a=Qr(s);this.follows[n]=a}};function d_(e){let t={};return N(e,r=>{let n=new f_(r).startWalking();ke(t,n)}),t}function m_(e,t){return e.name+t+bu}function P(e){return e.charCodeAt(0)}function Hs(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function Sr(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function rr(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function In(){throw Error("Internal Error - Should never get here!")}function uc(e){return e.type==="Character"}var Gn=[];for(let e=P("0");e<=P("9");e++)Gn.push(e);var $n=[P("_")].concat(Gn);for(let e=P("a");e<=P("z");e++)$n.push(e);for(let e=P("A");e<=P("Z");e++)$n.push(e);var pc=[P(" "),P("\f"),P(` -`),P("\r"),P(" "),P("\v"),P(" "),P("\xA0"),P("\u1680"),P("\u2000"),P("\u2001"),P("\u2002"),P("\u2003"),P("\u2004"),P("\u2005"),P("\u2006"),P("\u2007"),P("\u2008"),P("\u2009"),P("\u200A"),P("\u2028"),P("\u2029"),P("\u202F"),P("\u205F"),P("\u3000"),P("\uFEFF")],g_=/[0-9a-fA-F]/,En=/[0-9]/,T_=/[1-9]/,v_=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Sr(r,"global");break;case"i":Sr(r,"ignoreCase");break;case"m":Sr(r,"multiLine");break;case"u":Sr(r,"unicode");break;case"y":Sr(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}rr(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return In()}quantifier(e=!1){let t,r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),t={atLeast:n,atMost:i}):t={atLeast:n,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;rr(t);break}if(!(e===!0&&t===void 0)&&rr(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),rr(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):In()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[P(` -`),P("\r"),P("\u2028"),P("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=Gn;break;case"D":e=Gn,t=!0;break;case"s":e=pc;break;case"S":e=pc,t=!0;break;case"w":e=$n;break;case"W":e=$n,t=!0;break}return rr(e)?{type:"Set",value:e,complement:t}:In()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=P("\f");break;case"n":e=P(` -`);break;case"r":e=P("\r");break;case"t":e=P(" ");break;case"v":e=P("\v");break}return rr(e)?{type:"Character",value:e}:In()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:P("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:P(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` -`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:P(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let r=this.classAtom(),n=r.type==="Character";if(uc(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),s=i.type==="Character";if(uc(i)){if(i.value{var Lm=Object.defineProperty;var Pt=(e,t)=>{for(var r in t)Lm(e,r,{get:t[r],enumerable:!0})};var Bt=class{tracksSourceLocation;constructor(t={}){this.tracksSourceLocation=t.tracksSourceLocation??!0}wrap(t,r){return{val:t,loc:r}}isLocalized(t){return typeof t=="object"&&t!==null&&"loc"in t&&typeof t.loc=="object"&&t.loc!==null&&"sourceLocationType"in t.loc}sourceLocation(...t){if(!this.tracksSourceLocation)return this.gen();let r=t.filter(a=>a!==void 0);if(r.length===0)return this.sourceLocationNoMaterialize();let n=r.filter(a=>!this.isLocalized(a)||this.isSourceLocationSource(a.loc)||this.isSourceLocationStringReplace(a.loc)||this.isSourceLocationNodeReplace(a.loc));if(n.length===0)return this.gen();let i=n.at(0),s=n.at(-1);return{sourceLocationType:"source",start:this.isLocalized(i)?i.loc.start:i.startOffset,end:this.isLocalized(s)?s.loc.end:s.endOffset+1}}sourceLocationNoMaterialize(){return this.tracksSourceLocation?{sourceLocationType:"noMaterialize"}:this.gen()}dematerialized(t){return{...t,loc:this.sourceLocationNoMaterialize()}}safeObjectTransform(t,r){return t&&typeof t=="object"?Array.isArray(t)?t.map(n=>this.safeObjectTransform(n,r)):r(t):t}forcedAutoGenTree(t){let r={...t};for(let[n,i]of Object.entries(r))r[n]=this.safeObjectTransform(i,s=>this.forcedAutoGenTree(s));return this.isLocalized(r)&&(r.loc=this.gen()),r}forceMaterialized(t){return this.isSourceLocationNoMaterialize(t.loc)?this.forcedAutoGenTree(t):{...t}}isSourceLocation(t){return"sourceLocationType"in t}sourceLocationSource(t,r){return{sourceLocationType:"source",start:t,end:r}}sourceLocationInlinedSource(t,r,n,i,s=0,a=t.length){return this.tracksSourceLocation?(this.isSourceLocationSource(r)&&(s=r.start,a=r.end),{sourceLocationType:"inlinedSource",newSource:t,start:n,end:i,loc:r,startOnNew:s,endOnNew:a}):this.gen()}isSourceLocationInlinedSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="inlinedSource"}gen(){return{sourceLocationType:"autoGenerate"}}isSourceLocationSource(t){return this.isSourceLocation(t)&&t.sourceLocationType==="source"}sourceLocationStringReplace(t,r,n){return this.tracksSourceLocation?{sourceLocationType:"stringReplace",newSource:t,start:r,end:n}:this.gen()}isSourceLocationStringReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="stringReplace"}sourceLocationNodeReplaceUnsafe(t){if(this.isSourceLocationSource(t))return this.sourceLocationNodeReplace(t);if(this.isSourceLocationInlinedSource(t))return this.sourceLocationNodeReplaceUnsafe(t.loc);throw new Error(`Cannot convert SourceLocation of type ${t.sourceLocationType} to SourceLocationNodeReplace`)}sourceLocationNodeReplace(t,r){let n,i;return typeof t=="number"?(n=t,i=r):(n=t.start,i=t.end),{sourceLocationType:"nodeReplace",start:n,end:i}}isSourceLocationNodeReplace(t){return this.isSourceLocation(t)&&t.sourceLocationType==="nodeReplace"}isSourceLocationNodeAutoGenerate(t){return this.isSourceLocation(t)&&t.sourceLocationType==="autoGenerate"}isPrintingLoc(t){return this.isSourceLocationNodeReplace(t)||this.isSourceLocationNodeAutoGenerate(t)||this.isSourceLocationInlinedSource(t)&&this.isPrintingLoc(t.loc)}printFilter(t,r){this.isPrintingLoc(t.loc)&&r()}isSourceLocationNoMaterialize(t){return this.isSourceLocation(t)&&t.sourceLocationType==="noMaterialize"}isOfType(t,r){return t.type===r}isOfSubType(t,r,n){let i=t;return i.type===r&&i.subType===n}};var _m=typeof global=="object"&&global&&global.Object===Object&&global,bl=_m,Om=typeof self=="object"&&self&&self.Object===Object&&self,Sm=bl||Om||Function("return this")(),Ue=Sm,Nm=Ue.Symbol,Fe=Nm,xl=Object.prototype,Pm=xl.hasOwnProperty,km=xl.toString,vr=Fe?Fe.toStringTag:void 0;function Rm(e){var t=Pm.call(e,vr),r=e[vr];try{e[vr]=void 0;var n=!0}catch{}var i=km.call(e);return n&&(t?e[vr]=r:delete e[vr]),i}var Fm=Rm,wm=Object.prototype,Cm=wm.toString;function Mm(e){return Cm.call(e)}var Dm=Mm,Gm="[object Null]",$m="[object Undefined]",yc=Fe?Fe.toStringTag:void 0;function jm(e){return e==null?e===void 0?$m:Gm:yc&&yc in Object(e)?Fm(e):Dm(e)}var It=jm;function Vm(e){return e!=null&&typeof e=="object"}var He=Vm,Km="[object Symbol]";function Hm(e){return typeof e=="symbol"||He(e)&&It(e)==Km}var Fn=Hm;function Wm(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r0){if(++t>=Hg)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Yg=qg;function Xg(e){return function(){return e}}var Bg=Xg,Qg=(function(){try{var e=Dt(Object,"defineProperty");return e({},"",{}),e}catch{}})(),xn=Qg,Zg=xn?function(e,t){return xn(e,"toString",{configurable:!0,enumerable:!1,value:Bg(t),writable:!0})}:wr,Jg=Zg,Ug=Yg(Jg),eT=Ug;function tT(e,t){for(var r=-1,n=e==null?0:e.length;++r-1}var _l=cT,lT=9007199254740991,uT=/^(?:0|[1-9]\d*)$/;function pT(e,t){var r=typeof e;return t=t??lT,!!t&&(r=="number"||r!="symbol"&&uT.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=bT}var ra=xT;function IT(e){return e!=null&&ra(e.length)&&!ft(e)}var et=IT;function ET(e,t,r){if(!we(r))return!1;var n=typeof t;return(n=="number"?et(r)&&wn(t,r.length):n=="string"&&t in r)?Cr(r[t],e):!1}var Mn=ET;function LT(e){return ta(function(t,r){var n=-1,i=r.length,s=i>1?r[i-1]:void 0,a=i>2?r[2]:void 0;for(s=e.length>3&&typeof s=="function"?(i--,s):void 0,a&&Mn(r[0],r[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++n-1}var fv=hv;function dv(e,t){var r=this.__data__,n=$n(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var mv=dv;function rr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t0&&r(o)?t>1?wl(o,t-1,r,n,i):oa(i,o):n||(i[i.length]=o)}return i}var ca=wl;function Bv(e){var t=e==null?0:e.length;return t?ca(e,1):[]}var Ve=Bv,Qv=kl(Object.getPrototypeOf,Object),Cl=Qv;function Zv(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(i);++n=n?e:la(e,t,r)}var Uv=Jv,eA="\\ud800-\\udfff",tA="\\u0300-\\u036f",rA="\\ufe20-\\ufe2f",nA="\\u20d0-\\u20ff",iA=tA+rA+nA,sA="\\ufe0e\\ufe0f",aA="\\u200d",oA=RegExp("["+aA+eA+iA+sA+"]");function cA(e){return oA.test(e)}var Ml=cA;function lA(e){return e.split("")}var uA=lA,Dl="\\ud800-\\udfff",pA="\\u0300-\\u036f",hA="\\ufe20-\\ufe2f",fA="\\u20d0-\\u20ff",dA=pA+hA+fA,mA="\\ufe0e\\ufe0f",gA="["+Dl+"]",$s="["+dA+"]",js="\\ud83c[\\udffb-\\udfff]",TA="(?:"+$s+"|"+js+")",Gl="[^"+Dl+"]",$l="(?:\\ud83c[\\udde6-\\uddff]){2}",jl="[\\ud800-\\udbff][\\udc00-\\udfff]",yA="\\u200d",Vl=TA+"?",Kl="["+mA+"]?",vA="(?:"+yA+"(?:"+[Gl,$l,jl].join("|")+")"+Kl+Vl+")*",AA=Kl+Vl+vA,bA="(?:"+[Gl+$s+"?",$s,$l,jl,gA].join("|")+")",xA=RegExp(js+"(?="+js+")|"+bA+AA,"g");function IA(e){return e.match(xA)||[]}var EA=IA;function LA(e){return Ml(e)?EA(e):uA(e)}var _A=LA;function OA(e){return function(t){t=Fl(t);var r=Ml(t)?_A(t):void 0,n=r?r[0]:t.charAt(0),i=r?Uv(r,1).join(""):t.slice(1);return n[e]()+i}}var SA=OA,vS=SA("toUpperCase");function NA(e,t,r,n){var i=-1,s=e==null?0:e.length;for(n&&s&&(r=e[++i]);++io))return!1;var l=s.get(e),p=s.get(t);if(l&&p)return l==t&&p==e;var h=-1,d=!0,m=r&Qx?new fa:void 0;for(s.set(e,t),s.set(t,e);++h2?t[2]:void 0;for(i&&Mn(t[0],t[1],i)&&(n=1);++r=gE&&(s=da,a=!1,t=new fa(t));e:for(;++i-1?i[s?t[a]:a]:void 0}}var wE=FE,CE=Math.max;function ME(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:Fr(r);return i<0&&(i=CE(n+i,0)),Ll(e,tt(t,3),i)}var DE=ME,GE=wE(DE),Ut=GE;function $E(e){return e&&e.length?e[0]:void 0}var We=$E;function jE(e,t){var r=-1,n=et(e)?Array(e.length):[];return Gt(e,function(i,s,a){n[++r]=t(i,s,a)}),n}var VE=jE;function KE(e,t){var r=D(e)?Rr:VE;return r(e,tt(t,3))}var O=KE;function HE(e,t){return ca(O(e,t),1)}var Re=HE,WE=Object.prototype,zE=WE.hasOwnProperty,qE=pE(function(e,t,r){zE.call(e,r)?e[r].push(t):ea(e,r,[t])}),YE=qE,XE=Object.prototype,BE=XE.hasOwnProperty;function QE(e,t){return e!=null&&BE.call(e,t)}var ZE=QE;function JE(e,t){return e!=null&&nu(e,t,ZE)}var N=JE,UE="[object String]";function eL(e){return typeof e=="string"||!D(e)&&He(e)&&It(e)==UE}var Ie=eL;function tL(e,t){return Rr(t,function(r){return e[r]})}var rL=tL;function nL(e){return e==null?[]:rL(e,Le(e))}var ie=nL,iL=Math.max;function sL(e,t,r,n){e=et(e)?e:ie(e),r=r&&!n?Fr(r):0;var i=e.length;return r<0&&(r=iL(i+r,0)),Ie(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Us(e,t,r)>-1}var Te=sL,aL=Math.max;function oL(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:Fr(r);return i<0&&(i=aL(n+i,0)),Us(e,t,i)}var Qc=oL,cL="[object Map]",lL="[object Set]",uL=Object.prototype,pL=uL.hasOwnProperty;function hL(e){if(e==null)return!0;if(et(e)&&(D(e)||typeof e=="string"||typeof e.splice=="function"||Sr(e)||na(e)||Dn(e)))return!e.length;var t=Jt(e);if(t==cL||t==lL)return!e.size;if(Dr(e))return!Rl(e).length;for(var r in e)if(pL.call(e,r))return!1;return!0}var V=hL,fL="[object RegExp]";function dL(e){return He(e)&&It(e)==fL}var mL=dL,Zc=bt&&bt.isRegExp,gL=Zc?Gr(Zc):mL,ut=gL;function TL(e){return e===void 0}var pt=TL,yL="Expected a function";function vL(e){if(typeof e!="function")throw new TypeError(yL);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}var AL=vL;function bL(e,t,r,n){if(!we(e))return e;t=Hn(t,e);for(var i=-1,s=t.length,a=s-1,o=e;o!=null&&++i=ML){var l=t?null:CL(e);if(l)return ma(l);a=!1,i=da,c=new fa}else c=t?[]:o;e:for(;++n{t.accept(e)})}},Se=class extends rt{constructor(e){super([]),this.idx=1,_e(this,ze(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},sr=class extends rt{constructor(e){super(e.definition),this.orgText="",_e(this,ze(e,t=>t!==void 0))}},Ee=class extends rt{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,_e(this,ze(e,t=>t!==void 0))}},be=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},nt=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},it=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},se=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},qe=class extends rt{constructor(e){super(e.definition),this.idx=1,_e(this,ze(e,t=>t!==void 0))}},Ye=class extends rt{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,_e(this,ze(e,t=>t!==void 0))}},B=class{constructor(e){this.idx=1,_e(this,ze(e,t=>t!==void 0))}accept(e){e.visit(this)}};function KL(e){return O(e,Tn)}function Tn(e){function t(r){return O(r,Tn)}if(e instanceof Se){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Ie(e.label)&&(r.label=e.label),r}else{if(e instanceof Ee)return{type:"Alternative",definition:t(e.definition)};if(e instanceof be)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof nt)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof it)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Tn(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof qe)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Tn(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof se)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof Ye)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof B){let r={type:"Terminal",name:e.terminalType.name,label:jL(e.terminalType),idx:e.idx};Ie(e.label)&&(r.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(r.pattern=ut(n)?n.source:n),r}else{if(e instanceof sr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var ar=class{visit(e){let t=e;switch(t.constructor){case Se:return this.visitNonTerminal(t);case Ee:return this.visitAlternative(t);case be:return this.visitOption(t);case nt:return this.visitRepetitionMandatory(t);case it:return this.visitRepetitionMandatoryWithSeparator(t);case qe:return this.visitRepetitionWithSeparator(t);case se:return this.visitRepetition(t);case Ye:return this.visitAlternation(t);case B:return this.visitTerminal(t);case sr:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function HL(e){return e instanceof Ee||e instanceof be||e instanceof se||e instanceof nt||e instanceof it||e instanceof qe||e instanceof B||e instanceof sr}function Ln(e,t=[]){return e instanceof be||e instanceof se||e instanceof qe?!0:e instanceof Ye?ou(e.definition,n=>Ln(n,t)):e instanceof Se&&Te(t,e)?!1:e instanceof rt?(e instanceof Se&&t.push(e),Ke(e.definition,n=>Ln(n,t))):!1}function WL(e){return e instanceof Ye}function Je(e){if(e instanceof Se)return"SUBRULE";if(e instanceof be)return"OPTION";if(e instanceof Ye)return"OR";if(e instanceof nt)return"AT_LEAST_ONE";if(e instanceof it)return"AT_LEAST_ONE_SEP";if(e instanceof qe)return"MANY_SEP";if(e instanceof se)return"MANY";if(e instanceof B)return"CONSUME";throw Error("non exhaustive match")}var qn=class{walk(e,t=[]){P(e.definition,(r,n)=>{let i=ce(e.definition,n+1);if(r instanceof Se)this.walkProdRef(r,i,t);else if(r instanceof B)this.walkTerminal(r,i,t);else if(r instanceof Ee)this.walkFlat(r,i,t);else if(r instanceof be)this.walkOption(r,i,t);else if(r instanceof nt)this.walkAtLeastOne(r,i,t);else if(r instanceof it)this.walkAtLeastOneSep(r,i,t);else if(r instanceof qe)this.walkManySep(r,i,t);else if(r instanceof se)this.walkMany(r,i,t);else if(r instanceof Ye)this.walkOr(r,i,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){let n=t.concat(r);this.walk(e,n)}walkOption(e,t,r){let n=t.concat(r);this.walk(e,n)}walkAtLeastOne(e,t,r){let n=[new be({definition:e.definition})].concat(t,r);this.walk(e,n)}walkAtLeastOneSep(e,t,r){let n=Jc(e,t,r);this.walk(e,n)}walkMany(e,t,r){let n=[new be({definition:e.definition})].concat(t,r);this.walk(e,n)}walkManySep(e,t,r){let n=Jc(e,t,r);this.walk(e,n)}walkOr(e,t,r){let n=t.concat(r);P(e.definition,i=>{let s=new Ee({definition:[i]});this.walk(s,n)})}};function Jc(e,t,r){return[new be({definition:[new B({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Vr(e){if(e instanceof Se)return Vr(e.referencedRule);if(e instanceof B)return YL(e);if(HL(e))return zL(e);if(WL(e))return qL(e);throw Error("non exhaustive match")}function zL(e){let t=[],r=e.definition,n=0,i=r.length>n,s,a=!0;for(;i&&a;)s=r[n],a=Ln(s),t=t.concat(Vr(s)),n=n+1,i=r.length>n;return Ta(t)}function qL(e){let t=O(e.definition,r=>Vr(r));return Ta(Ve(t))}function YL(e){return[e.terminalType]}var pu="_~IN~_",XL=class extends qn{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){let n=QL(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),s=new Ee({definition:i}),a=Vr(s);this.follows[n]=a}};function BL(e){let t={};return P(e,r=>{let n=new XL(r).startWalking();_e(t,n)}),t}function QL(e,t){return e.name+t+pu}function k(e){return e.charCodeAt(0)}function Fs(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function Ar(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function Qt(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function pn(){throw Error("Internal Error - Should never get here!")}function Uc(e){return e.type==="Character"}var _n=[];for(let e=k("0");e<=k("9");e++)_n.push(e);var On=[k("_")].concat(_n);for(let e=k("a");e<=k("z");e++)On.push(e);for(let e=k("A");e<=k("Z");e++)On.push(e);var el=[k(" "),k("\f"),k(` +`),k("\r"),k(" "),k("\v"),k(" "),k("\xA0"),k("\u1680"),k("\u2000"),k("\u2001"),k("\u2002"),k("\u2003"),k("\u2004"),k("\u2005"),k("\u2006"),k("\u2007"),k("\u2008"),k("\u2009"),k("\u200A"),k("\u2028"),k("\u2029"),k("\u202F"),k("\u205F"),k("\u3000"),k("\uFEFF")],ZL=/[0-9a-fA-F]/,hn=/[0-9]/,JL=/[1-9]/,UL=class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Ar(r,"global");break;case"i":Ar(r,"ignoreCase");break;case"m":Ar(r,"multiLine");break;case"u":Ar(r,"unicode");break;case"y":Ar(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}Qt(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return pn()}quantifier(e=!1){let t,r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),t={atLeast:n,atMost:i}):t={atLeast:n,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;Qt(t);break}if(!(e===!0&&t===void 0)&&Qt(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Qt(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):pn()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[k(` +`),k("\r"),k("\u2028"),k("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=_n;break;case"D":e=_n,t=!0;break;case"s":e=el;break;case"S":e=el,t=!0;break;case"w":e=On;break;case"W":e=On,t=!0;break}return Qt(e)?{type:"Set",value:e,complement:t}:pn()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=k("\f");break;case"n":e=k(` +`);break;case"r":e=k("\r");break;case"t":e=k(" ");break;case"v":e=k("\v");break}return Qt(e)?{type:"Character",value:e}:pn()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:k("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:k(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` +`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:k(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let r=this.classAtom(),n=r.type==="Character";if(Uc(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),s=i.type==="Character";if(Uc(i)){if(i.value=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}},Sa=class{visitChildren(e){for(let t in e){let r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(n=>{this.visit(n)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},Pn={},y_=new v_;function si(e){let t=e.toString();if(Pn.hasOwnProperty(t))return Pn[t];{let r=y_.pattern(t);return Pn[t]=r,r}}function A_(){Pn={}}var Iu="Complement Sets are not supported for first char optimization",Vn=`Unable to use "first char" lexer optimizations: -`;function x_(e,t=!1){try{let r=si(e);return ta(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===Iu)t&&yu(`${Vn} Unable to optimize: < ${e.toString()} > +`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let n=0;n=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}},ya=class{visitChildren(e){for(let t in e){let r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(n=>{this.visit(n)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},yn={},e_=new UL;function Yn(e){let t=e.toString();if(yn.hasOwnProperty(t))return yn[t];{let r=e_.pattern(t);return yn[t]=r,r}}function t_(){yn={}}var hu="Complement Sets are not supported for first char optimization",Sn=`Unable to use "first char" lexer optimizations: +`;function r_(e,t=!1){try{let r=Yn(e);return zs(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===hu)t&&cu(`${Sn} Unable to optimize: < ${e.toString()} > Complement Sets cannot be automatically optimized. This will disable the lexer's first char optimizations. See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=` This will disable the lexer's first char optimizations. - See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),ea(`${Vn} + See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Ws(`${Sn} Failed parsing: < ${e.toString()} > Using the @chevrotain/regexp-to-ast library - Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function ta(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i{if(typeof l=="number")Ln(l,t,r);else{let u=l;if(r===!0)for(let p=u.from;p<=u.to;p++)Ln(p,t,r);else{for(let p=u.from;p<=u.to&&p=kr){let p=u.from>=kr?u.from:kr,h=u.to,f=Ot(p),m=Ot(h);for(let v=f;v<=m;v++)t[v]=v}}}});break;case"Group":ta(a.value,t,r);break;default:throw Error("Non Exhaustive Match")}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&ra(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return ce(t)}function Ln(e,t,r){let n=Ot(e);t[n]=n,r===!0&&b_(e,t)}function b_(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=Ot(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let s=Ot(i.charCodeAt(0));t[s]=s}}}function hc(e,t){return sr(e.value,r=>{if(typeof r=="number")return be(t,r);{let n=r;return sr(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function ra(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?M(e.value)?Xe(e.value,ra):ra(e.value):!1}var I_=class extends Sa{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){be(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?hc(e,this.targetCharCodes)===void 0&&(this.found=!0):hc(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Na(e,t){if(t instanceof RegExp){let r=si(t),n=new I_(e);return n.visit(r),n.found}else return sr(t,r=>be(e,r.charCodeAt(0)))!==void 0}var Vt="PATTERN",Pr="defaultMode",_n="modes";function E_(e,t){t=_a(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` -`],tracer:(b,g)=>g()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{X_()});let n;r("Reject Lexer.NA",()=>{n=ni(e,b=>b[Vt]===me.NA)});let i=!1,s;r("Transform Patterns",()=>{i=!1,s=O(n,b=>{let g=b[Vt];if(mt(g)){let I=g.source;return I.length===1&&I!=="^"&&I!=="$"&&I!=="."&&!g.ignoreCase?I:I.length===2&&I[0]==="\\"&&!be(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:fc(g)}else{if(vt(g))return i=!0,{exec:g};if(typeof g=="object")return i=!0,g;if(typeof g=="string"){if(g.length===1)return g;{let I=g.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),w=new RegExp(I);return fc(w)}}else throw Error("non exhaustive match")}})});let a,o,l,u,p;r("misc mapping",()=>{a=O(n,b=>b.tokenTypeIdx),o=O(n,b=>{let g=b.GROUP;if(g!==me.SKIPPED){if(Oe(g))return g;if(gt(g))return!1;throw Error("non exhaustive match")}}),l=O(n,b=>{let g=b.LONGER_ALT;if(g)return M(g)?O(g,w=>oc(n,w)):[oc(n,g)]}),u=O(n,b=>b.PUSH_MODE),p=O(n,b=>S(b,"POP_MODE"))});let h;r("Line Terminator Handling",()=>{let b=_u(t.lineTerminatorCharacters);h=O(n,g=>!1),t.positionTracking!=="onlyOffset"&&(h=O(n,g=>S(g,"LINE_BREAKS")?!!g.LINE_BREAKS:Lu(g,b)===!1&&Na(b,g.PATTERN)))});let f,m,v,x;r("Misc Mapping #2",()=>{f=O(n,Eu),m=O(s,z_),v=we(n,(b,g)=>{let I=g.GROUP;return Oe(I)&&I!==me.SKIPPED&&(b[I]=[]),b},{}),x=O(s,(b,g)=>({pattern:s[g],longerAlt:l[g],canLineTerminator:h[g],isCustom:f[g],short:m[g],group:o[g],push:u[g],pop:p[g],tokenTypeIdx:a[g],tokenType:n[g]}))});let A=!0,y=[];return t.safeMode||r("First Char Optimization",()=>{y=we(n,(b,g,I)=>{if(typeof g.PATTERN=="string"){let w=g.PATTERN.charCodeAt(0),C=Ot(w);Ws(b,C,x[I])}else if(M(g.START_CHARS_HINT)){let w;N(g.START_CHARS_HINT,C=>{let se=typeof C=="string"?C.charCodeAt(0):C,Z=Ot(se);w!==Z&&(w=Z,Ws(b,Z,x[I]))})}else if(mt(g.PATTERN))if(g.PATTERN.unicode)A=!1,t.ensureOptimizations&&ea(`${Vn} Unable to analyze < ${g.PATTERN.toString()} > pattern. + Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function zs(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i{if(typeof c=="number")fn(c,t,r);else{let l=c;if(r===!0)for(let p=l.from;p<=l.to;p++)fn(p,t,r);else{for(let p=l.from;p<=l.to&&p=Ir){let p=l.from>=Ir?l.from:Ir,h=l.to,d=xt(p),m=xt(h);for(let A=d;A<=m;A++)t[A]=A}}}});break;case"Group":zs(a.value,t,r);break;default:throw Error("Non Exhaustive Match")}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&qs(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return ie(t)}function fn(e,t,r){let n=xt(e);t[n]=n,r===!0&&n_(e,t)}function n_(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=xt(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let s=xt(i.charCodeAt(0));t[s]=s}}}function tl(e,t){return Ut(e.value,r=>{if(typeof r=="number")return Te(t,r);{let n=r;return Ut(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function qs(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?D(e.value)?Ke(e.value,qs):qs(e.value):!1}var i_=class extends ya{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){Te(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?tl(e,this.targetCharCodes)===void 0&&(this.found=!0):tl(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function va(e,t){if(t instanceof RegExp){let r=Yn(t),n=new i_(e);return n.visit(r),n.found}else return Ut(t,r=>Te(e,r.charCodeAt(0)))!==void 0}var wt="PATTERN",xr="defaultMode",dn="modes";function s_(e,t){t=ga(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` +`],tracer:(x,T)=>T()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{N_()});let n;r("Reject Lexer.NA",()=>{n=zn(e,x=>x[wt]===le.NA)});let i=!1,s;r("Transform Patterns",()=>{i=!1,s=O(n,x=>{let T=x[wt];if(ut(T)){let I=T.source;return I.length===1&&I!=="^"&&I!=="$"&&I!=="."&&!T.ignoreCase?I:I.length===2&&I[0]==="\\"&&!Te(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],I[1])?I[1]:rl(T)}else{if(ft(T))return i=!0,{exec:T};if(typeof T=="object")return i=!0,T;if(typeof T=="string"){if(T.length===1)return T;{let I=T.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),S=new RegExp(I);return rl(S)}}else throw Error("non exhaustive match")}})});let a,o,c,l,p;r("misc mapping",()=>{a=O(n,x=>x.tokenTypeIdx),o=O(n,x=>{let T=x.GROUP;if(T!==le.SKIPPED){if(Ie(T))return T;if(pt(T))return!1;throw Error("non exhaustive match")}}),c=O(n,x=>{let T=x.LONGER_ALT;if(T)return D(T)?O(T,S=>Qc(n,S)):[Qc(n,T)]}),l=O(n,x=>x.PUSH_MODE),p=O(n,x=>N(x,"POP_MODE"))});let h;r("Line Terminator Handling",()=>{let x=mu(t.lineTerminatorCharacters);h=O(n,T=>!1),t.positionTracking!=="onlyOffset"&&(h=O(n,T=>N(T,"LINE_BREAKS")?!!T.LINE_BREAKS:du(T,x)===!1&&va(x,T.PATTERN)))});let d,m,A,b;r("Misc Mapping #2",()=>{d=O(n,fu),m=O(s,__),A=Oe(n,(x,T)=>{let I=T.GROUP;return Ie(I)&&I!==le.SKIPPED&&(x[I]=[]),x},{}),b=O(s,(x,T)=>({pattern:s[T],longerAlt:c[T],canLineTerminator:h[T],isCustom:d[T],short:m[T],group:o[T],push:l[T],pop:p[T],tokenTypeIdx:a[T],tokenType:n[T]}))});let y=!0,v=[];return t.safeMode||r("First Char Optimization",()=>{v=Oe(n,(x,T,I)=>{if(typeof T.PATTERN=="string"){let S=T.PATTERN.charCodeAt(0),C=xt(S);ws(x,C,b[I])}else if(D(T.START_CHARS_HINT)){let S;P(T.START_CHARS_HINT,C=>{let X=typeof C=="string"?C.charCodeAt(0):C,M=xt(X);S!==M&&(S=M,ws(x,M,b[I]))})}else if(ut(T.PATTERN))if(T.PATTERN.unicode)y=!1,t.ensureOptimizations&&Ws(`${Sn} Unable to analyze < ${T.PATTERN.toString()} > pattern. The regexp unicode flag is not currently supported by the regexp-to-ast library. This will disable the lexer's first char optimizations. - For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let w=x_(g.PATTERN,t.ensureOptimizations);z(w)&&(A=!1),N(w,C=>{Ws(b,C,x[I])})}else t.ensureOptimizations&&ea(`${Vn} TokenType: <${g.name}> is using a custom token pattern without providing parameter. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let S=r_(T.PATTERN,t.ensureOptimizations);V(S)&&(y=!1),P(S,C=>{ws(x,C,b[I])})}else t.ensureOptimizations&&Ws(`${Sn} TokenType: <${T.name}> is using a custom token pattern without providing parameter. This will disable the lexer's first char optimizations. - For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),A=!1;return b},[])}),{emptyGroups:v,patternIdxToConfig:x,charCodeToPatternIdxToConfig:y,hasCustom:i,canBeOptimized:A}}function L_(e,t){let r=[],n=O_(e);r=r.concat(n.errors);let i=S_(n.valid),s=i.valid;return r=r.concat(i.errors),r=r.concat(__(s)),r=r.concat(M_(s)),r=r.concat(D_(s,t)),r=r.concat(G_(s)),r}function __(e){let t=[],r=je(e,n=>mt(n[Vt]));return t=t.concat(P_(r)),t=t.concat(R_(r)),t=t.concat(F_(r)),t=t.concat(C_(r)),t=t.concat(k_(r)),t}function O_(e){let t=je(e,i=>!S(i,Vt)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:ne.MISSING_PATTERN,tokenTypes:[i]})),n=ri(e,t);return{errors:r,valid:n}}function S_(e){let t=je(e,i=>{let s=i[Vt];return!mt(s)&&!vt(s)&&!S(s,"exec")&&!Oe(s)}),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:ne.INVALID_PATTERN,tokenTypes:[i]})),n=ri(e,t);return{errors:r,valid:n}}var N_=/[^\\][$]/;function P_(e){class t extends Sa{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}let r=je(e,i=>{let s=i.PATTERN;try{let a=si(s),o=new t;return o.visit(a),o.found}catch{return N_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),y=!1;return x},[])}),{emptyGroups:A,patternIdxToConfig:b,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:y}}function a_(e,t){let r=[],n=c_(e);r=r.concat(n.errors);let i=l_(n.valid),s=i.valid;return r=r.concat(i.errors),r=r.concat(o_(s)),r=r.concat(T_(s)),r=r.concat(y_(s,t)),r=r.concat(v_(s)),r}function o_(e){let t=[],r=Ce(e,n=>ut(n[wt]));return t=t.concat(p_(r)),t=t.concat(d_(r)),t=t.concat(m_(r)),t=t.concat(g_(r)),t=t.concat(h_(r)),t}function c_(e){let t=Ce(e,i=>!N(i,wt)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:Z.MISSING_PATTERN,tokenTypes:[i]})),n=Wn(e,t);return{errors:r,valid:n}}function l_(e){let t=Ce(e,i=>{let s=i[wt];return!ut(s)&&!ft(s)&&!N(s,"exec")&&!Ie(s)}),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:Z.INVALID_PATTERN,tokenTypes:[i]})),n=Wn(e,t);return{errors:r,valid:n}}var u_=/[^\\][$]/;function p_(e){class t extends ya{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}let r=Ce(e,i=>{let s=i.PATTERN;try{let a=Yn(s),o=new t;return o.visit(a),o.found}catch{return u_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$' - See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ne.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function k_(e){let t=je(e,n=>n.PATTERN.test(""));return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:ne.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var w_=/[^\\[][\^]|^\^/;function R_(e){class t extends Sa{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}let r=je(e,i=>{let s=i.PATTERN;try{let a=si(s),o=new t;return o.visit(a),o.found}catch{return w_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: + See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Z.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function h_(e){let t=Ce(e,n=>n.PATTERN.test(""));return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:Z.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var f_=/[^\\[][\^]|^\^/;function d_(e){class t extends ya{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}let r=Ce(e,i=>{let s=i.PATTERN;try{let a=Yn(s),o=new t;return o.visit(a),o.found}catch{return f_.test(s.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error: Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^' - See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ne.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function F_(e){let t=je(e,n=>{let i=n[Vt];return i instanceof RegExp&&(i.multiline||i.global)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:ne.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function C_(e){let t=[],r=O(e,s=>we(e,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!be(t,o)&&o.PATTERN!==me.NA&&(t.push(o),a.push(o)),a),[]));r=Xr(r);let n=je(r,s=>s.length>1);return O(n,s=>{let a=O(s,l=>l.name);return{message:`The same RegExp pattern ->${Be(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:ne.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function M_(e){let t=je(e,n=>{if(!S(n,"GROUP"))return!1;let i=n.GROUP;return i!==me.SKIPPED&&i!==me.NA&&!Oe(i)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:ne.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function D_(e,t){let r=je(e,i=>i.PUSH_MODE!==void 0&&!be(t,i.PUSH_MODE));return O(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:ne.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function G_(e){let t=[],r=we(e,(n,i,s)=>{let a=i.PATTERN;return a===me.NA||(Oe(a)?n.push({str:a,idx:s,tokenType:i}):mt(a)&&V_(a)&&n.push({str:a.source,idx:s,tokenType:i})),n},[]);return N(e,(n,i)=>{N(r,({str:s,idx:a,tokenType:o})=>{if(i${o.name}<- can never be matched. + See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:Z.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function m_(e){let t=Ce(e,n=>{let i=n[wt];return i instanceof RegExp&&(i.multiline||i.global)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:Z.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function g_(e){let t=[],r=O(e,s=>Oe(e,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!Te(t,o)&&o.PATTERN!==le.NA&&(t.push(o),a.push(o)),a),[]));r=jr(r);let n=Ce(r,s=>s.length>1);return O(n,s=>{let a=O(s,c=>c.name);return{message:`The same RegExp pattern ->${We(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:Z.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function T_(e){let t=Ce(e,n=>{if(!N(n,"GROUP"))return!1;let i=n.GROUP;return i!==le.SKIPPED&&i!==le.NA&&!Ie(i)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:Z.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function y_(e,t){let r=Ce(e,i=>i.PUSH_MODE!==void 0&&!Te(t,i.PUSH_MODE));return O(r,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:Z.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function v_(e){let t=[],r=Oe(e,(n,i,s)=>{let a=i.PATTERN;return a===le.NA||(Ie(a)?n.push({str:a,idx:s,tokenType:i}):ut(a)&&b_(a)&&n.push({str:a.source,idx:s,tokenType:i})),n},[]);return P(e,(n,i)=>{P(r,({str:s,idx:a,tokenType:o})=>{if(i${o.name}<- can never be matched. Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition. -See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:l,type:ne.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function $_(e,t){if(mt(t)){if(j_(t))return!1;let r=t.exec(e);return r!==null&&r.index===0}else{if(vt(t))return t(e,0,[],{});if(S(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function V_(e){return sr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function j_(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\? property in its definition -`,type:ne.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),S(e,_n)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+_n+`> property in its definition -`,type:ne.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),S(e,_n)&&S(e,Pr)&&!S(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${Pr}: <${e.defaultMode}>which does not exist -`,type:ne.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),S(e,_n)&&N(e.modes,(i,s)=>{N(i,(a,o)=>{if(gt(a))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${o}> -`,type:ne.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(S(a,"LONGER_ALT")){let l=M(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];N(l,u=>{!gt(u)&&!be(i,u)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${u.name}> on token <${a.name}> outside of mode <${s}> -`,type:ne.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function H_(e,t,r){let n=[],i=!1,s=Xr(qe(ce(e.modes))),a=ni(s,l=>l[Vt]===me.NA),o=_u(r);return t&&N(a,l=>{let u=Lu(l,o);if(u!==!1){let h={message:q_(l,u),type:u.issue,tokenType:l};n.push(h)}else S(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):Na(o,l.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found. +See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:c,type:Z.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function A_(e,t){if(ut(t)){if(x_(t))return!1;let r=t.exec(e);return r!==null&&r.index===0}else{if(ft(t))return t(e,0,[],{});if(N(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function b_(e){return Ut([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function x_(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\? property in its definition +`,type:Z.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),N(e,dn)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+dn+`> property in its definition +`,type:Z.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),N(e,dn)&&N(e,xr)&&!N(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${xr}: <${e.defaultMode}>which does not exist +`,type:Z.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),N(e,dn)&&P(e.modes,(i,s)=>{P(i,(a,o)=>{if(pt(a))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${o}> +`,type:Z.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(N(a,"LONGER_ALT")){let c=D(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];P(c,l=>{!pt(l)&&!Te(i,l)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${a.name}> outside of mode <${s}> +`,type:Z.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function E_(e,t,r){let n=[],i=!1,s=jr(Ve(ie(e.modes))),a=zn(s,c=>c[wt]===le.NA),o=mu(r);return t&&P(a,c=>{let l=du(c,o);if(l!==!1){let h={message:S_(c,l),type:l.issue,tokenType:c};n.push(h)}else N(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):va(o,c.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found. This Lexer has been defined to track line and column information, But none of the Token Types can be identified as matching a line terminator. See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS - for details.`,type:ne.NO_LINE_BREAKS_FLAGS}),n}function W_(e){let t={},r=Pe(e);return N(r,n=>{let i=e[n];if(M(i))t[n]=[];else throw Error("non exhaustive match")}),t}function Eu(e){let t=e.PATTERN;if(mt(t))return!1;if(vt(t))return!0;if(S(t,"exec"))return!0;if(Oe(t))return!1;throw Error("non exhaustive match")}function z_(e){return Oe(e)&&e.length===1?e.charCodeAt(0):!1}var Y_={test:function(e){let t=e.length;for(let r=this.lastIndex;r{let i=e[n];if(D(i))t[n]=[];else throw Error("non exhaustive match")}),t}function fu(e){let t=e.PATTERN;if(ut(t))return!1;if(ft(t))return!0;if(N(t,"exec"))return!0;if(Ie(t))return!1;throw Error("non exhaustive match")}function __(e){return Ie(e)&&e.length===1?e.charCodeAt(0):!1}var O_={test:function(e){let t=e.length;for(let r=this.lastIndex;r Token Type Root cause: ${t.errMsg}. - For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===ne.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===Z.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. The problem is in the <${e.name}> Token Type - For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function _u(e){return O(e,r=>Oe(r)?r.charCodeAt(0):r)}function Ws(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var kr=256,kn=[];function Ot(e){return e255?255+~~(e/255):e}}function Br(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function jn(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var dc=1,Ou={};function Zr(e){let t=Q_(e);B_(t),J_(t),Z_(t),N(t,r=>{r.isParent=r.categoryMatches.length>0})}function Q_(e){let t=_e(e),r=e,n=!0;for(;n;){r=Xr(qe(O(r,s=>s.CATEGORIES)));let i=ri(r,t);t=t.concat(i),z(i)?n=!1:r=i}return t}function B_(e){N(e,t=>{Nu(t)||(Ou[dc]=t,t.tokenTypeIdx=dc++),mc(t)&&!M(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),mc(t)||(t.CATEGORIES=[]),U_(t)||(t.categoryMatches=[]),eO(t)||(t.categoryMatchesMap={})})}function Z_(e){N(e,t=>{t.categoryMatches=[],N(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(Ou[n].tokenTypeIdx)})})}function J_(e){N(e,t=>{Su([],t)})}function Su(e,t){N(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),N(t.CATEGORIES,r=>{let n=e.concat(t);be(n,r)||Su(n,r)})}function Nu(e){return S(e,"tokenTypeIdx")}function mc(e){return S(e,"CATEGORIES")}function U_(e){return S(e,"categoryMatches")}function eO(e){return S(e,"categoryMatchesMap")}function tO(e){return S(e,"tokenTypeIdx")}var rO={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i,s){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}},ne;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(ne||(ne={}));var wr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` -`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:rO,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(wr);var me=class{constructor(e,t=wr){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(n,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${n}>`);let{time:a,value:o}=Au(i),l=a>10?console.warn:console.log;return this.traceInitIndent time: ${a}ms`),this.traceInitIndent--,o}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. -a boolean 2nd argument is no longer supported`);this.config=ke({},wr,t);let r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===wr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Y_;else if(this.config.lineTerminatorCharacters===wr.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. - For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),M(e)?n={modes:{defaultMode:_e(e)},defaultMode:Pr}:(i=!1,n=_e(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(K_(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(H_(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},N(n.modes,(a,o)=>{n.modes[o]=ni(a,l=>gt(l))});let s=Pe(n.modes);if(N(n.modes,(a,o)=>{this.TRACE_INIT(`Mode: <${o}> processing`,()=>{if(this.modes.push(o),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(L_(a,s))}),z(this.lexerDefinitionErrors)){Zr(a);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=E_(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[o]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[o]=l.charCodeToPatternIdxToConfig,this.emptyGroups=ke({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[o]=l.canBeOptimized}})}),this.defaultMode=n.defaultMode,!z(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let o=O(this.lexerDefinitionErrors,l=>l.message).join(`----------------------- + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function mu(e){return O(e,r=>Ie(r)?r.charCodeAt(0):r)}function ws(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var Ir=256,vn=[];function xt(e){return e255?255+~~(e/255):e}}function Kr(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function Nn(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var nl=1,gu={};function Hr(e){let t=P_(e);k_(t),F_(t),R_(t),P(t,r=>{r.isParent=r.categoryMatches.length>0})}function P_(e){let t=xe(e),r=e,n=!0;for(;n;){r=jr(Ve(O(r,s=>s.CATEGORIES)));let i=Wn(r,t);t=t.concat(i),V(i)?n=!1:r=i}return t}function k_(e){P(e,t=>{yu(t)||(gu[nl]=t,t.tokenTypeIdx=nl++),il(t)&&!D(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),il(t)||(t.CATEGORIES=[]),w_(t)||(t.categoryMatches=[]),C_(t)||(t.categoryMatchesMap={})})}function R_(e){P(e,t=>{t.categoryMatches=[],P(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(gu[n].tokenTypeIdx)})})}function F_(e){P(e,t=>{Tu([],t)})}function Tu(e,t){P(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),P(t.CATEGORIES,r=>{let n=e.concat(t);Te(n,r)||Tu(n,r)})}function yu(e){return N(e,"tokenTypeIdx")}function il(e){return N(e,"CATEGORIES")}function w_(e){return N(e,"categoryMatches")}function C_(e){return N(e,"categoryMatchesMap")}function M_(e){return N(e,"tokenTypeIdx")}var D_={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i,s){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}},Z;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(Z||(Z={}));var Er={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` +`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:D_,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Er);var le=class{constructor(e,t=Er){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(n,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${n}>`);let{time:a,value:o}=lu(i),c=a>10?console.warn:console.log;return this.traceInitIndent time: ${a}ms`),this.traceInitIndent--,o}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. +a boolean 2nd argument is no longer supported`);this.config=_e({},Er,t);let r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Er.lineTerminatorsPattern)this.config.lineTerminatorsPattern=O_;else if(this.config.lineTerminatorCharacters===Er.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. + For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),D(e)?n={modes:{defaultMode:xe(e)},defaultMode:xr}:(i=!1,n=xe(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(I_(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(E_(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},P(n.modes,(a,o)=>{n.modes[o]=zn(a,c=>pt(c))});let s=Le(n.modes);if(P(n.modes,(a,o)=>{this.TRACE_INIT(`Mode: <${o}> processing`,()=>{if(this.modes.push(o),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(a_(a,s))}),V(this.lexerDefinitionErrors)){Hr(a);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=s_(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[o]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[o]=c.charCodeToPatternIdxToConfig,this.emptyGroups=_e({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[o]=c.canBeOptimized}})}),this.defaultMode=n.defaultMode,!V(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let o=O(this.lexerDefinitionErrors,c=>c.message).join(`----------------------- `);throw new Error(`Errors detected in definition of Lexer: -`+o)}N(this.lexerDefinitionWarning,a=>{yu(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=pe),this.trackStartLines===!1&&(this.computeNewColumn=Kr),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=pe),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let a=we(this.canModeBeOptimized,(o,l,u)=>(l===!1&&o.push(u),o),[]);if(t.ensureOptimizations&&!z(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized. +`+o)}P(this.lexerDefinitionWarning,a=>{cu(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=oe),this.trackStartLines===!1&&(this.computeNewColumn=wr),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=oe),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let a=Oe(this.canModeBeOptimized,(o,c,l)=>(c===!1&&o.push(l),o),[]);if(t.ensureOptimizations&&!V(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized. Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode. - Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{A_()}),this.TRACE_INIT("toFastProperties",()=>{xu(this)})})}tokenize(e,t=this.defaultMode){if(!z(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`----------------------- + Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{t_()}),this.TRACE_INIT("toFastProperties",()=>{uu(this)})})}tokenize(e,t=this.defaultMode){if(!V(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`----------------------- `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer: -`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,s,a,o,l,u,p,h,f,m,v,x,A,y=e,b=y.length,g=0,I=0,w=this.hasCustom?0:Math.floor(e.length/10),C=new Array(w),se=[],Z=this.trackStartLines?1:void 0,F=this.trackStartLines?1:void 0,ee=W_(this.emptyGroups),V=this.trackStartLines,H=this.config.lineTerminatorsPattern,j=0,$=[],te=[],J=[],ye=[];Object.freeze(ye);let Te=!1,Ye=fe=>{if(J.length===1&&fe.tokenType.PUSH_MODE===void 0){let Me=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(fe);se.push({offset:fe.startOffset,line:fe.startLine,column:fe.startColumn,length:fe.image.length,message:Me})}else{J.pop();let Me=$t(J);$=this.patternIdxToConfig[Me],te=this.charCodeToPatternIdxToConfig[Me],j=$.length;let Gs=this.canModeBeOptimized[Me]&&this.config.safeMode===!1;te&&Gs?Te=!0:Te=!1}};function he(fe){J.push(fe),te=this.charCodeToPatternIdxToConfig[fe],$=this.patternIdxToConfig[fe],j=$.length,j=$.length;let Me=this.canModeBeOptimized[fe]&&this.config.safeMode===!1;te&&Me?Te=!0:Te=!1}he.call(this,t);let Y,Ce=this.config.recoveryEnabled;for(;go.length){o=s,p=s.length,l=u,Y=dt;break}}}break}}if(p!==-1){if(h=Y.group,h!==void 0&&(o=o!==null?o:e.substring(g,g+p),f=Y.tokenTypeIdx,m=this.createTokenInstance(o,g,f,Y.tokenType,Z,F,p),this.handlePayload(m,l),h===!1?I=this.addToken(C,I,m):ee[h].push(m)),V===!0&&Y.canLineTerminator===!0){let Ae=0,De,Lt;H.lastIndex=0;do o=o!==null?o:e.substring(g,g+p),De=H.test(o),De===!0&&(Lt=H.lastIndex-1,Ae++);while(De===!0);Ae!==0?(Z=Z+Ae,F=p-Lt,this.updateTokenEndLineColumnLocation(m,h,Lt,Ae,Z,F,p)):F=this.computeNewColumn(F,p)}else F=this.computeNewColumn(F,p);g=g+p,this.handleModes(Y,Ye,he,m)}else{let Ae=g,De=Z,Lt=F,dt=Ce===!1;for(;dt===!1&&g ${Cr(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let s="Expecting: ",o=` -but found: '`+Be(t).image+"'";if(n)return s+n+o;{let l=we(e,(f,m)=>f.concat(m),[]),u=O(l,f=>`[${O(f,m=>Cr(m)).join(", ")}]`),h=`one of these possible Token sequences: -${O(u,(f,m)=>` ${m+1}. ${f}`).join(` +`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,s,a,o,c,l,p,h,d,m,A,b,y,v=e,x=v.length,T=0,I=0,S=this.hasCustom?0:Math.floor(e.length/10),C=new Array(S),X=[],M=this.trackStartLines?1:void 0,z=this.trackStartLines?1:void 0,J=L_(this.emptyGroups),fe=this.trackStartLines,de=this.config.lineTerminatorsPattern,ne=0,q=[],ae=[],pe=[],ct=[];Object.freeze(ct);let Ze=!1,ln=Ae=>{if(pe.length===1&&Ae.tokenType.PUSH_MODE===void 0){let Pe=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(Ae);X.push({offset:Ae.startOffset,line:Ae.startLine,column:Ae.startColumn,length:Ae.image.length,message:Pe})}else{pe.pop();let Pe=Ft(pe);q=this.patternIdxToConfig[Pe],ae=this.charCodeToPatternIdxToConfig[Pe],ne=q.length;let Ss=this.canModeBeOptimized[Pe]&&this.config.safeMode===!1;ae&&Ss?Ze=!0:Ze=!1}};function mc(Ae){pe.push(Ae),ae=this.charCodeToPatternIdxToConfig[Ae],q=this.patternIdxToConfig[Ae],ne=q.length,ne=q.length;let Pe=this.canModeBeOptimized[Ae]&&this.config.safeMode===!1;ae&&Pe?Ze=!0:Ze=!1}mc.call(this,t);let je,gc=this.config.recoveryEnabled;for(;To.length){o=s,p=s.length,c=l,je=lt;break}}}break}}if(p!==-1){if(h=je.group,h!==void 0&&(o=o!==null?o:e.substring(T,T+p),d=je.tokenTypeIdx,m=this.createTokenInstance(o,T,d,je.tokenType,M,z,p),this.handlePayload(m,c),h===!1?I=this.addToken(C,I,m):J[h].push(m)),fe===!0&&je.canLineTerminator===!0){let me=0,ke,At;de.lastIndex=0;do o=o!==null?o:e.substring(T,T+p),ke=de.test(o),ke===!0&&(At=de.lastIndex-1,me++);while(ke===!0);me!==0?(M=M+me,z=p-At,this.updateTokenEndLineColumnLocation(m,h,At,me,M,z,p)):z=this.computeNewColumn(z,p)}else z=this.computeNewColumn(z,p);T=T+p,this.handleModes(je,ln,mc,m)}else{let me=T,ke=M,At=z,lt=gc===!1;for(;lt===!1&&T ${Or(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:r,customUserDescription:n,ruleName:i}){let s="Expecting: ",o=` +but found: '`+We(t).image+"'";if(n)return s+n+o;{let c=Oe(e,(d,m)=>d.concat(m),[]),l=O(c,d=>`[${O(d,m=>Or(m)).join(", ")}]`),h=`one of these possible Token sequences: +${O(l,(d,m)=>` ${m+1}. ${d}`).join(` `)}`;return s+h+o}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",a=` -but found: '`+Be(t).image+"'";if(r)return i+r+a;{let l=`expecting at least one iteration which starts with one of these possible Token sequences:: - <${O(e,u=>`[${O(u,p=>Cr(p)).join(",")}]`).join(" ,")}>`;return i+l+a}}};Object.freeze(ku);var aO={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<- -inside top level rule: ->`+e.name+"<-"}},Gt={buildDuplicateFoundError(e,t){function r(p){return p instanceof U?p.terminalType.name:p instanceof Re?p.nonTerminalName:""}let n=e.name,i=Be(t),s=i.idx,a=nt(i),o=r(i),l=s>0,u=`->${a}${l?s:""}<- ${o?`with argument: ->${o}<-`:""} +but found: '`+We(t).image+"'";if(r)return i+r+a;{let c=`expecting at least one iteration which starts with one of these possible Token sequences:: + <${O(e,l=>`[${O(l,p=>Or(p)).join(",")}]`).join(" ,")}>`;return i+c+a}}};Object.freeze(Au);var V_={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<- +inside top level rule: ->`+e.name+"<-"}},Rt={buildDuplicateFoundError(e,t){function r(p){return p instanceof B?p.terminalType.name:p instanceof Se?p.nonTerminalName:""}let n=e.name,i=We(t),s=i.idx,a=Je(i),o=r(i),c=s>0,l=`->${a}${c?s:""}<- ${o?`with argument: ->${o}<-`:""} appears more than once (${t.length} times) in the top level rule: ->${n}<-. For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES - `;return u=u.replace(/[ \t]+/g," "),u=u.replace(/\s\s+/g,` -`),u},buildNamespaceConflictError(e){return`Namespace conflict found in grammar. + `;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,` +`),l},buildNamespaceConflictError(e){return`Namespace conflict found in grammar. The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>. To resolve this make sure each Terminal and Non-Terminal names are unique This is easy to accomplish by using the convention that Terminal names start with an uppercase letter -and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=O(e.prefixPath,i=>Cr(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix +and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=O(e.prefixPath,i=>Or(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix in inside <${e.topLevelRule.name}> Rule, <${t}> may appears as a prefix path in all these alternatives. See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX For Further details.`},buildAlternationAmbiguityError(e){let t=e.alternation.idx===0?"":e.alternation.idx,r=e.prefixPath.length===0,n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in inside <${e.topLevelRule.name}> Rule, `;if(r)n+=`These alternatives are all empty (match no tokens), making them indistinguishable. Only the last alternative may be empty. -`;else{let i=O(e.prefixPath,s=>Cr(s)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives. +`;else{let i=O(e.prefixPath,s=>Or(s)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives. `}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES -For Further details.`,n},buildEmptyRepetitionError(e){let t=nt(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens. +For Further details.`,n},buildEmptyRepetitionError(e){let t=Je(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens. This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in inside <${e.topLevelRule.name}> Rule. Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives: inside <${e.topLevelRule.name}> Rule. @@ -83,40 +83,40 @@ rule: <${t}> can be invoked from itself (directly or indirectly) without consuming any Tokens. The grammar path that causes this is: ${n} To fix this refactor your grammar to remove the left recursion. -see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof pr?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function oO(e,t){let r=new lO(e,t);return r.resolveRefs(),r.errors}var lO=class extends hr{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){N(ce(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:xe.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},cO=class extends ii{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=_e(this.path.ruleStack).reverse(),this.occurrenceStack=_e(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let n=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){z(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},uO=class extends cO{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let n=t.concat(r),i=new Se({definition:n});this.possibleTokTypes=Qr(i),this.found=!0}}},oi=class extends ii{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},pO=class extends oi{walkMany(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,t,r)}},Ec=class extends oi{walkManySep(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,t,r)}},hO=class extends oi{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,t,r)}},Lc=class extends oi{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let n=Be(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof U&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,t,r)}};function na(e,t,r=[]){r=_e(r);let n=[],i=0;function s(o){return o.concat(de(e,i+1))}function a(o){let l=na(s(o),t,r);return n.concat(l)}for(;r.length{z(l.definition)===!1&&(n=a(l.definition))}),n;if(o instanceof U)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:de(e,i)}),n}function wu(e,t,r,n){let i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE",o=!1,l=t.length,u=l-n-1,p=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!z(h);){let f=h.pop();if(f===a){o&&$t(h).idx<=u&&h.pop();continue}let m=f.def,v=f.idx,x=f.ruleStack,A=f.occurrenceStack;if(z(m))continue;let y=m[0];if(y===i){let b={idx:v,def:de(m),ruleStack:$r(x),occurrenceStack:$r(A)};h.push(b)}else if(y instanceof U)if(v=0;b--){let g=y.definition[b],I={idx:v,def:g.definition.concat(de(m)),ruleStack:x,occurrenceStack:A};h.push(I),h.push(a)}else if(y instanceof Se)h.push({idx:v,def:y.definition.concat(de(m)),ruleStack:x,occurrenceStack:A});else if(y instanceof pr)h.push(fO(y,v,x,A));else throw Error("non exhaustive match")}return p}function fO(e,t,r,n){let i=_e(r);i.push(e.name);let s=_e(n);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var re;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(re||(re={}));function Ru(e){if(e instanceof Le||e==="Option")return re.OPTION;if(e instanceof ue||e==="Repetition")return re.REPETITION;if(e instanceof lt||e==="RepetitionMandatory")return re.REPETITION_MANDATORY;if(e instanceof ct||e==="RepetitionMandatoryWithSeparator")return re.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof Je||e==="RepetitionWithSeparator")return re.REPETITION_WITH_SEPARATOR;if(e instanceof Ue||e==="Alternation")return re.ALTERNATION;throw Error("non exhaustive match")}function dO(e,t,r,n,i,s){let a=ka(e,t,r),o=Mu(a)?jn:Br;return s(a,n,o,i)}function mO(e,t,r,n,i,s){let a=wa(e,t,i,r),o=Mu(a)?jn:Br;return s(a[0],o,n)}function gO(e,t,r,n){let i=e.length,s=Xe(e,a=>Xe(a,o=>o.length===1));if(t)return function(a){let o=O(a,l=>l.GATE);for(let l=0;lqe(l)),o=we(a,(l,u,p)=>(N(u,h=>{S(l,h.tokenTypeIdx)||(l[h.tokenTypeIdx]=p),N(h.categoryMatches,f=>{S(l,f)||(l[f]=p)})}),l),{});return function(){let l=this.LA_FAST(1);return o[l.tokenTypeIdx]}}else return function(){for(let a=0;as.length===1),i=e.length;if(n&&!r){let s=qe(e);if(s.length===1&&z(s[0].categoryMatches)){let o=s[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{let a=we(s,(o,l,u)=>(o[l.tokenTypeIdx]=!0,N(l.categoryMatches,p=>{o[p]=!0}),o),[]);return function(){let o=this.LA_FAST(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;sna([a],1)),n=_c(r.length),i=O(r,a=>{let o={};return N(a,l=>{let u=zs(l.partialPath);N(u,p=>{o[p]=!0})}),o}),s=r;for(let a=1;a<=t;a++){let o=s;s=_c(o.length);for(let l=0;l{let y=zs(A.partialPath);N(y,b=>{i[l][b]=!0})})}}}}return n}function ka(e,t,r,n){let i=new Fu(e,re.ALTERNATION,n);return t.accept(i),Cu(i.result,r)}function wa(e,t,r,n){let i=new Fu(e,r);t.accept(i);let s=i.result,o=new vO(t,e,r).startWalking(),l=new Se({definition:s}),u=new Se({definition:o});return Cu([l,u],n)}function ia(e,t){e:for(let r=0;r{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Mu(e){return Xe(e,t=>Xe(t,r=>Xe(r,n=>z(n.categoryMatches))))}function xO(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return O(t,r=>Object.assign({type:xe.CUSTOM_LOOKAHEAD_VALIDATION},r))}function bO(e,t,r,n){let i=Ge(e,l=>IO(l,r)),s=CO(e,t,r),a=Ge(e,l=>kO(l,r)),o=Ge(e,l=>_O(l,e,n,r));return i.concat(s,a,o)}function IO(e,t){let r=new LO;e.accept(r);let n=r.allProductions,i=hL(n,EO),s=Ze(i,o=>o.length>1);return O(ce(s),o=>{let l=Be(o),u=t.buildDuplicateFoundError(e,o),p=nt(l),h={message:u,type:xe.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:p,occurrence:l.idx},f=Du(l);return f&&(h.parameter=f),h})}function EO(e){return`${nt(e)}_#_${e.idx}_#_${Du(e)}`}function Du(e){return e instanceof U?e.terminalType.name:e instanceof Re?e.nonTerminalName:""}var LO=class extends hr{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function _O(e,t,r,n){let i=[];if(we(t,(a,o)=>o.name===e.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:a,type:xe.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function OO(e,t,r){let n=[],i;return be(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:xe.INVALID_RULE_OVERRIDE,ruleName:e})),n}function Gu(e,t,r,n=[]){let i=[],s=wn(t.definition);if(z(s))return[];{let a=e.name;be(s,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:xe.LEFT_RECURSION,ruleName:a});let l=ri(s,n.concat([e])),u=Ge(l,p=>{let h=_e(n);return h.push(p),Gu(e,p,r,h)});return i.concat(u)}}function wn(e){let t=[];if(z(e))return t;let r=Be(e);if(r instanceof Re)t.push(r.referencedRule);else if(r instanceof Se||r instanceof Le||r instanceof lt||r instanceof ct||r instanceof Je||r instanceof ue)t=t.concat(wn(r.definition));else if(r instanceof Ue)t=qe(O(r.definition,s=>wn(s.definition)));else if(!(r instanceof U))throw Error("non exhaustive match");let n=Dn(r),i=e.length>1;if(n&&i){let s=de(e);return t.concat(wn(s))}else return t}var Ra=class extends hr{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function SO(e,t){let r=new Ra;e.accept(r);let n=r.alternations;return Ge(n,s=>{let a=$r(s.definition);return Ge(a,(o,l)=>{let u=wu([o],[],Br,1);return z(u)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:l}),type:xe.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:l+1}]:[]})})}function NO(e,t,r){let n=new Ra;e.accept(n);let i=n.alternations;return i=ni(i,a=>a.ignoreAmbiguities===!0),Ge(i,a=>{let o=a.idx,l=a.maxLookahead||t,u=ka(o,e,l,a),p=RO(u,a,e,r),h=FO(u,a,e,r);return p.concat(h)})}var PO=class extends hr{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function kO(e,t){let r=new Ra;e.accept(r);let n=r.alternations;return Ge(n,s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:xe.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[])}function wO(e,t,r){let n=[];return N(e,i=>{let s=new PO;i.accept(s);let a=s.allProductions;N(a,o=>{let l=Ru(o),u=o.maxLookahead||t,p=o.idx,f=wa(p,i,l,u)[0];if(z(qe(f))){let m=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:m,type:xe.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function RO(e,t,r,n){let i=[],s=we(e,(o,l,u)=>(t.definition[u].ignoreAmbiguities===!0||N(l,p=>{let h=[u];N(e,(f,m)=>{u!==m&&ia(f,p)&&t.definition[m].ignoreAmbiguities!==!0&&h.push(m)}),h.length>1&&!ia(i,p)&&(i.push(p),o.push({alts:h,path:p}))}),o),[]);return O(s,o=>{let l=O(o.alts,p=>p+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:l,prefixPath:o.path}),type:xe.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:o.alts}})}function FO(e,t,r,n){let i=we(e,(a,o,l)=>{let u=O(o,p=>({idx:l,path:p}));return a.concat(u)},[]);return Xr(Ge(i,a=>{if(t.definition[a.idx].ignoreAmbiguities===!0)return[];let l=a.idx,u=a.path,p=je(i,f=>t.definition[f.idx].ignoreAmbiguities!==!0&&f.idx{let m=[f.idx+1,l+1],v=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:m,prefixPath:f.path}),type:xe.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:v,alternatives:m}})}))}function CO(e,t,r){let n=[],i=O(t,s=>s.name);return N(e,s=>{let a=s.name;if(be(i,a)){let o=r.buildNamespaceConflictError(s);n.push({message:o,type:xe.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function MO(e){let t=_a(e,{errMsgProvider:aO}),r={};return N(e.rules,n=>{r[n.name]=n}),oO(r,t.errMsgProvider)}function DO(e){return e=_a(e,{errMsgProvider:Gt}),bO(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var $u="MismatchedTokenException",Vu="NoViableAltException",ju="EarlyExitException",Ku="NotAllInputParsedException",Hu=[$u,Vu,ju,Ku];Object.freeze(Hu);function Kn(e){return be(Hu,e.name)}var li=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Wu=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=$u}},GO=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Vu}},$O=class extends li{constructor(e,t){super(e,t),this.name=Ku}},VO=class extends li{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=ju}},Ys={},zu="InRuleRecoveryException",jO=class extends Error{constructor(e){super(e),this.name=zu}},KO=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=S(e,"recoveryEnabled")?e.recoveryEnabled:Tt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=HO)}getTokenToInsert(e){let t=Pa(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,n){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],o=!1,l=this.LA_FAST(1),u=this.LA_FAST(1),p=()=>{let h=this.LA(0),f=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:l,previous:h,ruleName:this.getCurrRuleFullName()}),m=new Wu(f,l,this.LA(0));m.resyncedTokens=$r(a),this.SAVE_ERROR(m)};for(;!o;)if(this.tokenMatcher(u,n)){p();return}else if(r.call(this)){p(),e.apply(this,t);return}else this.tokenMatcher(u,i)?o=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new jO("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||z(t))return!1;let r=this.LA_FAST(1);return sr(t,i=>this.tokenMatcher(r,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return be(r,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let n=sr(e,i=>sO(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Ys;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,r=this.RULE_STACK_IDX+1,n=new Array(r);for(let i=0;ithis.getFollowSetFromFollowKey(t));return qe(e)}getFollowSetFromFollowKey(e){if(e===Ys)return[jt];let t=e.ruleName+e.idxInCallingRule+bu+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,jt)||t.push(e),t}reSyncTo(e){let t=[],r=this.LA_FAST(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return $r(t)}attemptInRepetitionRecovery(e,t,r,n,i,s,a){}getCurrentGrammarPath(e,t){let r=this.getHumanReadableRuleStack(),n=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:r,occurrenceStack:n,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let r=0;rGu(t,t,Gt))}validateEmptyOrAlternatives(e){return Ge(e,t=>SO(t,Gt))}validateAmbiguousAlternationAlternatives(e,t){return Ge(e,r=>NO(r,t,Gt))}validateSomeNonEmptyLookaheadPath(e,t){return wO(e,t,Gt)}buildLookaheadForAlternation(e){return dO(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,gO)}buildLookaheadForOptional(e){return mO(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Ru(e.prodType),TO)}},qO=class{initLooksAhead(e){this.dynamicTokensEnabled=S(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:Tt.dynamicTokensEnabled,this.maxLookahead=S(e,"maxLookahead")?e.maxLookahead:Tt.maxLookahead,this.lookaheadStrategy=S(e,"lookaheadStrategy")?e.lookaheadStrategy:new YO({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){N(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:n,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=QO(t);N(r,l=>{let u=l.idx===0?"":l.idx;this.TRACE_INIT(`${nt(l)}${u}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:t,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=qs(this.fullRuleNameToShort[t.name],Yu,l.idx);this.setLaFuncCache(h,p)})}),N(n,l=>{this.computeLookaheadFunc(t,l.idx,sa,"Repetition",l.maxLookahead,nt(l))}),N(i,l=>{this.computeLookaheadFunc(t,l.idx,qu,"Option",l.maxLookahead,nt(l))}),N(s,l=>{this.computeLookaheadFunc(t,l.idx,aa,"RepetitionMandatory",l.maxLookahead,nt(l))}),N(a,l=>{this.computeLookaheadFunc(t,l.idx,Rn,"RepetitionMandatoryWithSeparator",l.maxLookahead,nt(l))}),N(o,l=>{this.computeLookaheadFunc(t,l.idx,oa,"RepetitionWithSeparator",l.maxLookahead,nt(l))})})})}computeLookaheadFunc(e,t,r,n,i,s){this.TRACE_INIT(`${s}${t===0?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),o=qs(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return qs(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},XO=class extends hr{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},On=new XO;function QO(e){On.reset(),e.accept(On);let t=On.dslMethods;return On.reset(),t}function Oc(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffseta.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>: +see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof sr?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function K_(e,t){let r=new H_(e,t);return r.resolveRefs(),r.errors}var H_=class extends ar{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){P(ie(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:ge.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},W_=class extends qn{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=xe(this.path.ruleStack).reverse(),this.occurrenceStack=xe(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let n=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){V(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},z_=class extends W_{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let n=t.concat(r),i=new Ee({definition:n});this.possibleTokTypes=Vr(i),this.found=!0}}},Bn=class extends qn{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},q_=class extends Bn{walkMany(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,t,r)}},fl=class extends Bn{walkManySep(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,t,r)}},Y_=class extends Bn{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,t,r)}},dl=class extends Bn{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let n=We(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof B&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,t,r)}};function Ys(e,t,r=[]){r=xe(r);let n=[],i=0;function s(o){return o.concat(ce(e,i+1))}function a(o){let c=Ys(s(o),t,r);return n.concat(c)}for(;r.length{V(c.definition)===!1&&(n=a(c.definition))}),n;if(o instanceof B)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:ce(e,i)}),n}function bu(e,t,r,n){let i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE",o=!1,c=t.length,l=c-n-1,p=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!V(h);){let d=h.pop();if(d===a){o&&Ft(h).idx<=l&&h.pop();continue}let m=d.def,A=d.idx,b=d.ruleStack,y=d.occurrenceStack;if(V(m))continue;let v=m[0];if(v===i){let x={idx:A,def:ce(m),ruleStack:kr(b),occurrenceStack:kr(y)};h.push(x)}else if(v instanceof B)if(A=0;x--){let T=v.definition[x],I={idx:A,def:T.definition.concat(ce(m)),ruleStack:b,occurrenceStack:y};h.push(I),h.push(a)}else if(v instanceof Ee)h.push({idx:A,def:v.definition.concat(ce(m)),ruleStack:b,occurrenceStack:y});else if(v instanceof sr)h.push(X_(v,A,b,y));else throw Error("non exhaustive match")}return p}function X_(e,t,r,n){let i=xe(r);i.push(e.name);let s=xe(n);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var Q;(function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"})(Q||(Q={}));function xu(e){if(e instanceof be||e==="Option")return Q.OPTION;if(e instanceof se||e==="Repetition")return Q.REPETITION;if(e instanceof nt||e==="RepetitionMandatory")return Q.REPETITION_MANDATORY;if(e instanceof it||e==="RepetitionMandatoryWithSeparator")return Q.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof qe||e==="RepetitionWithSeparator")return Q.REPETITION_WITH_SEPARATOR;if(e instanceof Ye||e==="Alternation")return Q.ALTERNATION;throw Error("non exhaustive match")}function B_(e,t,r,n,i,s){let a=ba(e,t,r),o=Lu(a)?Nn:Kr;return s(a,n,o,i)}function Q_(e,t,r,n,i,s){let a=xa(e,t,i,r),o=Lu(a)?Nn:Kr;return s(a[0],o,n)}function Z_(e,t,r,n){let i=e.length,s=Ke(e,a=>Ke(a,o=>o.length===1));if(t)return function(a){let o=O(a,c=>c.GATE);for(let c=0;cVe(c)),o=Oe(a,(c,l,p)=>(P(l,h=>{N(c,h.tokenTypeIdx)||(c[h.tokenTypeIdx]=p),P(h.categoryMatches,d=>{N(c,d)||(c[d]=p)})}),c),{});return function(){let c=this.LA_FAST(1);return o[c.tokenTypeIdx]}}else return function(){for(let a=0;as.length===1),i=e.length;if(n&&!r){let s=Ve(e);if(s.length===1&&V(s[0].categoryMatches)){let o=s[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{let a=Oe(s,(o,c,l)=>(o[c.tokenTypeIdx]=!0,P(c.categoryMatches,p=>{o[p]=!0}),o),[]);return function(){let o=this.LA_FAST(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;sYs([a],1)),n=ml(r.length),i=O(r,a=>{let o={};return P(a,c=>{let l=Cs(c.partialPath);P(l,p=>{o[p]=!0})}),o}),s=r;for(let a=1;a<=t;a++){let o=s;s=ml(o.length);for(let c=0;c{let v=Cs(y.partialPath);P(v,x=>{i[c][x]=!0})})}}}}return n}function ba(e,t,r,n){let i=new Iu(e,Q.ALTERNATION,n);return t.accept(i),Eu(i.result,r)}function xa(e,t,r,n){let i=new Iu(e,r);t.accept(i);let s=i.result,o=new U_(t,e,r).startWalking(),c=new Ee({definition:s}),l=new Ee({definition:o});return Eu([c,l],n)}function Xs(e,t){e:for(let r=0;r{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Lu(e){return Ke(e,t=>Ke(t,r=>Ke(r,n=>V(n.categoryMatches))))}function rO(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return O(t,r=>Object.assign({type:ge.CUSTOM_LOOKAHEAD_VALIDATION},r))}function nO(e,t,r,n){let i=Re(e,c=>iO(c,r)),s=gO(e,t,r),a=Re(e,c=>hO(c,r)),o=Re(e,c=>oO(c,e,n,r));return i.concat(s,a,o)}function iO(e,t){let r=new aO;e.accept(r);let n=r.allProductions,i=YE(n,sO),s=ze(i,o=>o.length>1);return O(ie(s),o=>{let c=We(o),l=t.buildDuplicateFoundError(e,o),p=Je(c),h={message:l,type:ge.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:p,occurrence:c.idx},d=_u(c);return d&&(h.parameter=d),h})}function sO(e){return`${Je(e)}_#_${e.idx}_#_${_u(e)}`}function _u(e){return e instanceof B?e.terminalType.name:e instanceof Se?e.nonTerminalName:""}var aO=class extends ar{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function oO(e,t,r,n){let i=[];if(Oe(t,(a,o)=>o.name===e.name?a+1:a,0)>1){let a=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:a,type:ge.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function cO(e,t,r){let n=[],i;return Te(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,n.push({message:i,type:ge.INVALID_RULE_OVERRIDE,ruleName:e})),n}function Ou(e,t,r,n=[]){let i=[],s=An(t.definition);if(V(s))return[];{let a=e.name;Te(s,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:ge.LEFT_RECURSION,ruleName:a});let c=Wn(s,n.concat([e])),l=Re(c,p=>{let h=xe(n);return h.push(p),Ou(e,p,r,h)});return i.concat(l)}}function An(e){let t=[];if(V(e))return t;let r=We(e);if(r instanceof Se)t.push(r.referencedRule);else if(r instanceof Ee||r instanceof be||r instanceof nt||r instanceof it||r instanceof qe||r instanceof se)t=t.concat(An(r.definition));else if(r instanceof Ye)t=Ve(O(r.definition,s=>An(s.definition)));else if(!(r instanceof B))throw Error("non exhaustive match");let n=Ln(r),i=e.length>1;if(n&&i){let s=ce(e);return t.concat(An(s))}else return t}var Ia=class extends ar{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function lO(e,t){let r=new Ia;e.accept(r);let n=r.alternations;return Re(n,s=>{let a=kr(s.definition);return Re(a,(o,c)=>{let l=bu([o],[],Kr,1);return V(l)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:c}),type:ge.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:c+1}]:[]})})}function uO(e,t,r){let n=new Ia;e.accept(n);let i=n.alternations;return i=zn(i,a=>a.ignoreAmbiguities===!0),Re(i,a=>{let o=a.idx,c=a.maxLookahead||t,l=ba(o,e,c,a),p=dO(l,a,e,r),h=mO(l,a,e,r);return p.concat(h)})}var pO=class extends ar{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function hO(e,t){let r=new Ia;e.accept(r);let n=r.alternations;return Re(n,s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:ge.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[])}function fO(e,t,r){let n=[];return P(e,i=>{let s=new pO;i.accept(s);let a=s.allProductions;P(a,o=>{let c=xu(o),l=o.maxLookahead||t,p=o.idx,d=xa(p,i,c,l)[0];if(V(Ve(d))){let m=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:m,type:ge.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function dO(e,t,r,n){let i=[],s=Oe(e,(o,c,l)=>(t.definition[l].ignoreAmbiguities===!0||P(c,p=>{let h=[l];P(e,(d,m)=>{l!==m&&Xs(d,p)&&t.definition[m].ignoreAmbiguities!==!0&&h.push(m)}),h.length>1&&!Xs(i,p)&&(i.push(p),o.push({alts:h,path:p}))}),o),[]);return O(s,o=>{let c=O(o.alts,p=>p+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:c,prefixPath:o.path}),type:ge.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:o.alts}})}function mO(e,t,r,n){let i=Oe(e,(a,o,c)=>{let l=O(o,p=>({idx:c,path:p}));return a.concat(l)},[]);return jr(Re(i,a=>{if(t.definition[a.idx].ignoreAmbiguities===!0)return[];let c=a.idx,l=a.path,p=Ce(i,d=>t.definition[d.idx].ignoreAmbiguities!==!0&&d.idx{let m=[d.idx+1,c+1],A=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:m,prefixPath:d.path}),type:ge.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:A,alternatives:m}})}))}function gO(e,t,r){let n=[],i=O(t,s=>s.name);return P(e,s=>{let a=s.name;if(Te(i,a)){let o=r.buildNamespaceConflictError(s);n.push({message:o,type:ge.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),n}function TO(e){let t=ga(e,{errMsgProvider:V_}),r={};return P(e.rules,n=>{r[n.name]=n}),K_(r,t.errMsgProvider)}function yO(e){return e=ga(e,{errMsgProvider:Rt}),nO(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Su="MismatchedTokenException",Nu="NoViableAltException",Pu="EarlyExitException",ku="NotAllInputParsedException",Ru=[Su,Nu,Pu,ku];Object.freeze(Ru);function Pn(e){return Te(Ru,e.name)}var Qn=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Fu=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Su}},vO=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Nu}},AO=class extends Qn{constructor(e,t){super(e,t),this.name=ku}},bO=class extends Qn{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Pu}},Ms={},wu="InRuleRecoveryException",xO=class extends Error{constructor(e){super(e),this.name=wu}},IO=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=N(e,"recoveryEnabled")?e.recoveryEnabled:ht.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=EO)}getTokenToInsert(e){let t=Aa(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,n){let i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[],o=!1,c=this.LA_FAST(1),l=this.LA_FAST(1),p=()=>{let h=this.LA(0),d=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:c,previous:h,ruleName:this.getCurrRuleFullName()}),m=new Fu(d,c,this.LA(0));m.resyncedTokens=kr(a),this.SAVE_ERROR(m)};for(;!o;)if(this.tokenMatcher(l,n)){p();return}else if(r.call(this)){p(),e.apply(this,t);return}else this.tokenMatcher(l,i)?o=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,a));this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new xO("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||V(t))return!1;let r=this.LA_FAST(1);return Ut(t,i=>this.tokenMatcher(r,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return Te(r,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let n=Ut(e,i=>j_(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Ms;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,r=this.RULE_STACK_IDX+1,n=new Array(r);for(let i=0;ithis.getFollowSetFromFollowKey(t));return Ve(e)}getFollowSetFromFollowKey(e){if(e===Ms)return[Ct];let t=e.ruleName+e.idxInCallingRule+pu+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ct)||t.push(e),t}reSyncTo(e){let t=[],r=this.LA_FAST(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return kr(t)}attemptInRepetitionRecovery(e,t,r,n,i,s,a){}getCurrentGrammarPath(e,t){let r=this.getHumanReadableRuleStack(),n=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:r,occurrenceStack:n,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let r=0;rOu(t,t,Rt))}validateEmptyOrAlternatives(e){return Re(e,t=>lO(t,Rt))}validateAmbiguousAlternationAlternatives(e,t){return Re(e,r=>uO(r,t,Rt))}validateSomeNonEmptyLookaheadPath(e,t){return fO(e,t,Rt)}buildLookaheadForAlternation(e){return B_(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Z_)}buildLookaheadForOptional(e){return Q_(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,xu(e.prodType),J_)}},SO=class{initLooksAhead(e){this.dynamicTokensEnabled=N(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ht.dynamicTokensEnabled,this.maxLookahead=N(e,"maxLookahead")?e.maxLookahead:ht.maxLookahead,this.lookaheadStrategy=N(e,"lookaheadStrategy")?e.lookaheadStrategy:new OO({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){P(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:n,option:i,repetitionMandatory:s,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=PO(t);P(r,c=>{let l=c.idx===0?"":c.idx;this.TRACE_INIT(`${Je(c)}${l}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:t,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=Ds(this.fullRuleNameToShort[t.name],Cu,c.idx);this.setLaFuncCache(h,p)})}),P(n,c=>{this.computeLookaheadFunc(t,c.idx,Bs,"Repetition",c.maxLookahead,Je(c))}),P(i,c=>{this.computeLookaheadFunc(t,c.idx,Mu,"Option",c.maxLookahead,Je(c))}),P(s,c=>{this.computeLookaheadFunc(t,c.idx,Qs,"RepetitionMandatory",c.maxLookahead,Je(c))}),P(a,c=>{this.computeLookaheadFunc(t,c.idx,bn,"RepetitionMandatoryWithSeparator",c.maxLookahead,Je(c))}),P(o,c=>{this.computeLookaheadFunc(t,c.idx,Zs,"RepetitionWithSeparator",c.maxLookahead,Je(c))})})})}computeLookaheadFunc(e,t,r,n,i,s){this.TRACE_INIT(`${s}${t===0?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),o=Ds(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return Ds(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},NO=class extends ar{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},mn=new NO;function PO(e){mn.reset(),e.accept(mn);let t=mn.dslMethods;return mn.reset(),t}function gl(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffseta.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>: ${s.join(` `).replace(/\n/g,` - `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function tS(e,t,r){let n=function(){};Xu(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return N(t,s=>{i[s]=UO}),n.prototype=i,n.prototype.constructor=n,n}var la;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(la||(la={}));function rS(e,t){return nS(e,t)}function nS(e,t){let r=je(t,i=>vt(e[i])===!1),n=O(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:la.MISSING_METHOD,methodName:i}));return Xr(n)}var iS=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=S(e,"nodeLocationTracking")?e.nodeLocationTracking:Tt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=pe,this.cstFinallyStateUpdate=pe,this.cstPostTerminal=pe,this.cstPostNonTerminal=pe,this.cstPostRule=pe;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Sc,this.setNodeLocationFromNode=Sc,this.cstPostRule=pe,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Oc,this.setNodeLocationFromNode=Oc,this.cstPostRule=pe,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=pe,this.setNodeLocationFromNode=pe,this.cstPostRule=pe,this.setInitialNodeLocation=pe;else throw Error(`Invalid config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];BO(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];ZO(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(gt(this.baseCstVisitorConstructor)){let e=eS(this.className,Pe(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(gt(this.baseCstVisitorWithDefaultsConstructor)){let e=tS(this.className,Pe(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},sS=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):ar}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ar:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},aS=class{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=Wn){if(be(this.definedRulesNames,e)){let s={message:Gt.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:xe.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);let n=this.defineRule(e,t,r);return this[e]=n,n}OVERRIDE_RULE(e,t,r=Wn){let n=OO(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);let i=this.defineRule(e,t,r);return this[e]=i,i}BACKTRACK(e,t){var r;let n=(r=e.coreRule)!==null&&r!==void 0?r:e;return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return n.apply(this,t),!0}catch(s){if(Kn(s))return!1;throw s}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return o_(ce(this.gastProductionsCache))}},oS=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=jn,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},S(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. + `)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function MO(e,t,r){let n=function(){};Du(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return P(t,s=>{i[s]=wO}),n.prototype=i,n.prototype.constructor=n,n}var Js;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(Js||(Js={}));function DO(e,t){return GO(e,t)}function GO(e,t){let r=Ce(t,i=>ft(e[i])===!1),n=O(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:Js.MISSING_METHOD,methodName:i}));return jr(n)}var $O=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=N(e,"nodeLocationTracking")?e.nodeLocationTracking:ht.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=oe,this.cstFinallyStateUpdate=oe,this.cstPostTerminal=oe,this.cstPostNonTerminal=oe,this.cstPostRule=oe;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Tl,this.setNodeLocationFromNode=Tl,this.cstPostRule=oe,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=gl,this.setNodeLocationFromNode=gl,this.cstPostRule=oe,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=oe,this.setNodeLocationFromNode=oe,this.cstPostRule=oe,this.setInitialNodeLocation=oe;else throw Error(`Invalid config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];kO(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];RO(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(pt(this.baseCstVisitorConstructor)){let e=CO(this.className,Le(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){let e=MO(this.className,Le(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},jO=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):er}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?er:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},VO=class{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=Rn){if(Te(this.definedRulesNames,e)){let s={message:Rt.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ge.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);let n=this.defineRule(e,t,r);return this[e]=n,n}OVERRIDE_RULE(e,t,r=Rn){let n=cO(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);let i=this.defineRule(e,t,r);return this[e]=i,i}BACKTRACK(e,t){var r;let n=(r=e.coreRule)!==null&&r!==void 0?r:e;return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return n.apply(this,t),!0}catch(s){if(Pn(s))return!1;throw s}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return KL(ie(this.gastProductionsCache))}},KO=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Nn,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},N(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0 - For Further details.`);if(M(e)){if(z(e))throw Error(`A Token Vocabulary cannot be empty. + For Further details.`);if(D(e)){if(V(e))throw Error(`A Token Vocabulary cannot be empty. Note that the first argument for the parser constructor is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument. See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0 - For Further details.`)}if(M(e))this.tokensMap=we(e,(i,s)=>(i[s.name]=s,i),{});else if(S(e,"modes")&&Xe(qe(ce(e.modes)),tO)){let i=qe(ce(e.modes)),s=Oa(i);this.tokensMap=we(s,(a,o)=>(a[o.name]=o,a),{})}else if(Ve(e))this.tokensMap=_e(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=jt;let r=S(e,"modes")?qe(ce(e.modes)):ce(e),n=Xe(r,i=>z(i.categoryMatches));this.tokenMatcher=n?jn:Br,Zr(ce(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called' -Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=S(r,"resyncEnabled")?r.resyncEnabled:Wn.resyncEnabled,i=S(r,"recoveryValueFunc")?r.recoveryValueFunc:Wn.recoveryValueFunc,s=this.ruleShortNameIdx<s.call(this)&&a.call(this)}}else i=e;if(n.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(aa,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let s=t.GATE;if(s!==void 0){let a=n;n=()=>s.call(this)&&a.call(this)}}else i=t;if(n.call(this)===!0){let s=this.doSingleRepetition(i);for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,re.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,aa,e,hO)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Rn,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,Lc],a,Rn,e,Lc)}else throw this.raiseEarlyExitException(e,re.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(sa,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let a=t.GATE;if(a!==void 0){let o=n;n=()=>a.call(this)&&o.call(this)}}else i=t;let s=!0;for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,sa,e,pO,s)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(oa,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,Ec],a,oa,e,Ec)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,Rn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Yu,t),n=M(e)?e:e.DEF,s=this.getLaFuncFromCache(r).call(this,n);if(s!==void 0)return n[s].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(e,t,r){let n;try{let i=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,n=e.coreRule.apply(this,i),this.cstPostNonTerminal(n,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),n}catch(i){throw this.subruleInternalError(i,r,e.ruleName)}}subruleInternalError(e,t,r){throw Kn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let n;try{let i=this.LA_FAST(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),n=i):this.consumeInternalError(e,i,r)}catch(i){n=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,n),n}consumeInternalError(e,t,r){let n,i=this.LA(0);throw r!==void 0&&r.ERR_MSG?n=r.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Wu(n,t,i))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){let n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(i){throw i.name===zu?r:i}}else throw r}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let r=0;r=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=r,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),jt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t${e}<- does not exist in this grammar.`);return wu([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=Be(e.ruleStack),n=this.getGAstProductions()[t];return new uO(n,e).startWalking()}},ci={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(ci);var Nc=!0,Pc=Math.pow(2,Nt)-1,Qu=ai({name:"RECORDING_PHASE_TOKEN",pattern:me.NA});Zr([Qu]);var Bu=Pa(Qu,`This IToken indicates the Parser is in Recording Phase - See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Bu);var uS={name:`This CSTNode indicates the Parser is in Recording Phase - See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},pS=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(r,n){return this.consumeInternalRecord(r,e,n)},this[`SUBRULE${t}`]=function(r,n){return this.subruleInternalRecord(r,e,n)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return ar}topLevelRuleRecord(e,t){try{let r=new pr({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+` + For Further details.`)}if(D(e))this.tokensMap=Oe(e,(i,s)=>(i[s.name]=s,i),{});else if(N(e,"modes")&&Ke(Ve(ie(e.modes)),M_)){let i=Ve(ie(e.modes)),s=Ta(i);this.tokensMap=Oe(s,(a,o)=>(a[o.name]=o,a),{})}else if(we(e))this.tokensMap=xe(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Ct;let r=N(e,"modes")?Ve(ie(e.modes)):ie(e),n=Ke(r,i=>V(i.categoryMatches));this.tokenMatcher=n?Nn:Kr,Hr(ie(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called' +Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=N(r,"resyncEnabled")?r.resyncEnabled:Rn.resyncEnabled,i=N(r,"recoveryValueFunc")?r.recoveryValueFunc:Rn.recoveryValueFunc,s=this.ruleShortNameIdx<s.call(this)&&a.call(this)}}else i=e;if(n.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(Qs,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let s=t.GATE;if(s!==void 0){let a=n;n=()=>s.call(this)&&a.call(this)}}else i=t;if(n.call(this)===!0){let s=this.doSingleRepetition(i);for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,Q.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,Qs,e,Y_)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(bn,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,dl],a,bn,e,dl)}else throw this.raiseEarlyExitException(e,Q.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(Bs,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof t!="function"){i=t.DEF;let a=t.GATE;if(a!==void 0){let o=n;n=()=>a.call(this)&&o.call(this)}}else i=t;let s=!0;for(;n.call(this)===!0&&s===!0;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,Bs,e,q_,s)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Zs,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){let n=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){n.call(this);let a=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,a,n,fl],a,Zs,e,fl)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,bn,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Cu,t),n=D(e)?e:e.DEF,s=this.getLaFuncFromCache(r).call(this,n);if(s!==void 0)return n[s].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(e,t,r){let n;try{let i=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,n=e.coreRule.apply(this,i),this.cstPostNonTerminal(n,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),n}catch(i){throw this.subruleInternalError(i,r,e.ruleName)}}subruleInternalError(e,t,r){throw Pn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let n;try{let i=this.LA_FAST(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),n=i):this.consumeInternalError(e,i,r)}catch(i){n=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,n),n}consumeInternalError(e,t,r){let n,i=this.LA(0);throw r!==void 0&&r.ERR_MSG?n=r.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Fu(n,t,i))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){let n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(i){throw i.name===wu?r:i}}else throw r}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let r=0;r=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=r,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ct)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t${e}<- does not exist in this grammar.`);return bu([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=We(e.ruleStack),n=this.getGAstProductions()[t];return new z_(n,e).startWalking()}},Zn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Zn);var yl=!0,vl=Math.pow(2,Et)-1,Gu=Xn({name:"RECORDING_PHASE_TOKEN",pattern:le.NA});Hr([Gu]);var $u=Aa(Gu,`This IToken indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze($u);var zO={name:`This CSTNode indicates the Parser is in Recording Phase + See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},qO=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(r,n){return this.consumeInternalRecord(r,e,n)},this[`SUBRULE${t}`]=function(r,n){return this.subruleInternalRecord(r,e,n)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return er}topLevelRuleRecord(e,t){try{let r=new sr({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+` This error was thrown during the "grammar recording phase" For more info see: - https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return Nr.call(this,Le,e,t)}atLeastOneInternalRecord(e,t){Nr.call(this,lt,t,e)}atLeastOneSepFirstInternalRecord(e,t){Nr.call(this,ct,t,e,Nc)}manyInternalRecord(e,t){Nr.call(this,ue,t,e)}manySepFirstInternalRecord(e,t){Nr.call(this,Je,t,e,Nc)}orInternalRecord(e,t){return hS.call(this,e,t)}subruleInternalRecord(e,t,r){if(Hn(t),!e||S(e,"ruleName")===!1){let a=new Error(` argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}> - inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=$t(this.recordingProdStack),i=e.ruleName,s=new Re({idx:t,nonTerminalName:i,label:r?.LABEL,referencedRule:void 0});return n.definition.push(s),this.outputCst?uS:ci}consumeInternalRecord(e,t,r){if(Hn(t),!Nu(e)){let s=new Error(` argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}> - inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=$t(this.recordingProdStack),i=new U({idx:t,terminalType:e,label:r?.LABEL});return n.definition.push(i),Bu}};function Nr(e,t,r,n=!1){Hn(r);let i=$t(this.recordingProdStack),s=vt(t)?t:t.DEF,a=new e({definition:[],idx:r});return n&&(a.separator=t.SEP),S(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),ci}function hS(e,t){Hn(t);let r=$t(this.recordingProdStack),n=M(e)===!1,i=n===!1?e:e.DEF,s=new Ue({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});S(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);let a=vu(i,o=>vt(o.GATE));return s.hasPredicates=a,r.definition.push(s),N(i,o=>{let l=new Se({definition:[]});s.definition.push(l),S(o,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:S(o,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),o.ALT.call(this),this.recordingProdStack.pop()}),ci}function kc(e){return e===0?"":`${e}`}function Hn(e){if(e<0||e>Pc){let t=new Error(`Invalid DSL Method idx value: <${e}> - Idx value must be a none negative value smaller than ${Pc+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var fS=class{initPerformanceTracer(e){if(S(e,"traceInitPerf")){let t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Tt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${e}>`);let{time:n,value:i}=Au(t),s=n>10?console.warn:console.log;return this.traceInitIndent time: ${n}ms`),this.traceInitIndent--,i}else return t()}};function dS(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let s=Object.getOwnPropertyDescriptor(n,i);s&&(s.get||s.set)?Object.defineProperty(e.prototype,i,s):e.prototype[i]=r.prototype[i]})})}var ar=Pa(jt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ar);var Tt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ku,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Wn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),xe;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(xe||(xe={}));var Fa=class Zu{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{xu(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),N(this.definedRulesNames,i=>{let a=this[i].originalGrammarAction,o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=MO({rules:ce(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(z(n)&&this.skipValidations===!1){let i=DO({rules:ce(this.gastProductionsCache),tokenTypes:ce(this.tokensMap),errMsgProvider:Gt,grammarName:r}),s=xO({lookaheadStrategy:this.lookaheadStrategy,rules:ce(this.gastProductionsCache),tokenTypes:ce(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,s)}}),z(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=d_(ce(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:ce(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(ce(this.gastProductionsCache))})),!Zu.DEFER_DEFINITION_ERRORS_HANDLING&&!z(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected: + https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return br.call(this,be,e,t)}atLeastOneInternalRecord(e,t){br.call(this,nt,t,e)}atLeastOneSepFirstInternalRecord(e,t){br.call(this,it,t,e,yl)}manyInternalRecord(e,t){br.call(this,se,t,e)}manySepFirstInternalRecord(e,t){br.call(this,qe,t,e,yl)}orInternalRecord(e,t){return YO.call(this,e,t)}subruleInternalRecord(e,t,r){if(kn(t),!e||N(e,"ruleName")===!1){let a=new Error(` argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=Ft(this.recordingProdStack),i=e.ruleName,s=new Se({idx:t,nonTerminalName:i,label:r?.LABEL,referencedRule:void 0});return n.definition.push(s),this.outputCst?zO:Zn}consumeInternalRecord(e,t,r){if(kn(t),!yu(e)){let s=new Error(` argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}> + inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=Ft(this.recordingProdStack),i=new B({idx:t,terminalType:e,label:r?.LABEL});return n.definition.push(i),$u}};function br(e,t,r,n=!1){kn(r);let i=Ft(this.recordingProdStack),s=ft(t)?t:t.DEF,a=new e({definition:[],idx:r});return n&&(a.separator=t.SEP),N(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),Zn}function YO(e,t){kn(t);let r=Ft(this.recordingProdStack),n=D(e)===!1,i=n===!1?e:e.DEF,s=new Ye({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});N(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);let a=ou(i,o=>ft(o.GATE));return s.hasPredicates=a,r.definition.push(s),P(i,o=>{let c=new Ee({definition:[]});s.definition.push(c),N(o,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:N(o,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),o.ALT.call(this),this.recordingProdStack.pop()}),Zn}function Al(e){return e===0?"":`${e}`}function kn(e){if(e<0||e>vl){let t=new Error(`Invalid DSL Method idx value: <${e}> + Idx value must be a none negative value smaller than ${vl+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var XO=class{initPerformanceTracer(e){if(N(e,"traceInitPerf")){let t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ht.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <${e}>`);let{time:n,value:i}=lu(t),s=n>10?console.warn:console.log;return this.traceInitIndent time: ${n}ms`),this.traceInitIndent--,i}else return t()}};function BO(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let s=Object.getOwnPropertyDescriptor(n,i);s&&(s.get||s.set)?Object.defineProperty(e.prototype,i,s):e.prototype[i]=r.prototype[i]})})}var er=Aa(Ct,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(er);var ht=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Au,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Rn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),ge;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ge||(ge={}));var Ea=class ju{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let r=this.className;this.TRACE_INIT("toFastProps",()=>{uu(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),P(this.definedRulesNames,i=>{let a=this[i].originalGrammarAction,o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=TO({rules:ie(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(V(n)&&this.skipValidations===!1){let i=yO({rules:ie(this.gastProductionsCache),tokenTypes:ie(this.tokensMap),errMsgProvider:Rt,grammarName:r}),s=rO({lookaheadStrategy:this.lookaheadStrategy,rules:ie(this.gastProductionsCache),tokenTypes:ie(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,s)}}),V(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=BL(ie(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:ie(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(ie(this.gastProductionsCache))})),!ju.DEFER_DEFINITION_ERRORS_HANDLING&&!V(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected: ${t.join(` ------------------------------- -`)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),S(r,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. +`)}`)})}constructor(t,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(t,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),N(r,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. Please use the flag on the relevant DSL method instead. See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES - For further details.`);this.skipValidations=S(r,"skipValidations")?r.skipValidations:Tt.skipValidations}};Fa.DEFER_DEFINITION_ERRORS_HANDLING=!1;dS(Fa,[KO,qO,iS,sS,oS,aS,lS,cS,pS,fS]);var Ju=class extends Fa{constructor(e,t=Tt){let r=_e(t);r.outputCst=!1,super(e,r)}};function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function d(e){return ai(e)}var X="When you use this string, you expect traqula to handle indentation after every newline",Jr="When you use this string, you expect that the core generator of Traqula does prints a given string instead of a ewline when NEW_LINE printing is disabled through traqulaIndentation";var ui=class e{rules;factory=new tr;__context=void 0;origSource="";handledInlineSource;generatedUntil=0;toEnsure=[];stringBuilder=[];constructor(t){this.rules=t;for(let r of Object.values(t))this[r.name]=((n,i,s)=>(this.stringBuilder.length=0,this.toEnsure.length=0,this.origSource=i.origSource,this.generatedUntil=i?.offset??0,this.setContext(i),this.subrule(r,n,s),this.catchup(this.origSource.length),this.handeEnsured(""),this.stringBuilder.join("")))}setContext(t){this.__context=t}getSafeContext(){return this.__context}subrule=(t,r,...n)=>{let i=this.rules[t.name];if(!i)throw new Error(`Rule ${t.name} not found`);let s=()=>i.gImpl({SUBRULE:this.subrule,PRINT:this.print,ENSURE:this.ensure,ENSURE_EITHER:this.ensureEither,NEW_LINE:this.newLine,HANDLE_LOC:this.handleLoc,CATCHUP:this.catchup,PRINT_WORD:this.printWord,PRINT_WORDS:this.printWords,PRINT_ON_EMPTY:this.printOnEmpty,PRINT_ON_OWN_LINE:this.printOnOwnLine})(r,this.getSafeContext(),...n);this.factory.isLocalized(r)?this.handleLoc(r,s):s()};handleLoc=(t,r)=>{if(this.factory.isSourceLocationNoMaterialize(t.loc))return;if(this.factory.isSourceLocationStringReplace(t.loc)){this.catchup(t.loc.start),this.print(t.loc.newSource),this.generatedUntil=t.loc.end;return}if(this.factory.isSourceLocationNodeReplace(t.loc)&&(this.catchup(t.loc.start),this.generatedUntil=t.loc.end),this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.start),this.factory.isSourceLocationInlinedSource(t.loc)&&this.handledInlineSource!==t.loc){this.handledInlineSource=t.loc,this.catchup(t.loc.start);let i=this.origSource,s=this.generatedUntil;this.origSource=t.loc.newSource,this.generatedUntil=0,this.catchup(t.loc.startOnNew);let a=this.handleLoc(t.loc,r);return this.generatedUntil=t.loc.endOnNew,this.catchup(this.origSource.length),this.origSource=i,this.generatedUntil=Math.max(s,t.loc.end),a}let n=r();return this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.end),n};catchup=t=>{let r=this.generatedUntil;r{let r=t.join("");this.handeEnsured(r),this.stringBuilder.push(r)};doesEndWith(t){let r=t.length;for(let n=this.stringBuilder.length-1;n>=0&&r>0;n--){let i=this.stringBuilder[n],s=r-i.length,a=t.slice(s>0?s:0,r);if(!i.endsWith(a))return!1;r-=a.length}return r===0}ensure=(...t)=>{let r=t.join("");this.doesEndWith(r)||this.toEnsure.push(n=>{!n.startsWith(r)&&!this.doesEndWith(r)&&this.stringBuilder.push(r)})};ensureEither=(...t)=>{t.length===1?this.ensure(...t):t.length>1&&!t.some(r=>this.doesEndWith(r))&&this.toEnsure.push(r=>{!t.some(n=>r.startsWith(n))&&!t.some(n=>this.doesEndWith(n))&&this.stringBuilder.push(t[0])})};static isBlank(t){return t===" "||t===" "}pruneEndingBlanks(){let t=this.stringBuilder,r=t.length-1,n=0;for(;r>=0;r--){let s=t[r];for(n=s.length;n>0&&e.isBlank(s[n-1]);)n--;if(n>0)break}let i=r>=0?t[r].slice(0,n):"";t.length=r>0?r:0,this.print(i)}endsWithNewline(){for(let t=this.stringBuilder.length-1;t>=0;t--){let r=this.stringBuilder[t];if(r.length>0)return r.endsWith(` -`)}return!1}newLine=t=>{let r=this.getSafeContext()[X]??0,n=t?.force??!1;if(r<0){let i=this.getSafeContext()[Jr];i!==void 0&&(n||!this.doesEndWith(i))&&this.print(i);return}this.pruneEndingBlanks(),n?this.print(` -`," ".repeat(r)):this.endsWithNewline()?this.print(" ".repeat(r)):this.print(` -`," ".repeat(r))};printWord=(...t)=>{this.ensureEither(" ",` + For further details.`);this.skipValidations=N(r,"skipValidations")?r.skipValidations:ht.skipValidations}};Ea.DEFER_DEFINITION_ERRORS_HANDLING=!1;BO(Ea,[IO,SO,$O,jO,KO,VO,HO,WO,qO,XO]);var Vu=class extends Ea{constructor(e,t=ht){let r=xe(t);r.outputCst=!1,super(e,r)}};function ee(e){return e.charAt(0).toLowerCase()+e.slice(1)}function f(e){return Xn(e)}var H="When you use this string, you expect traqula to handle indentation after every newline",Wr="When you use this string, you expect that the core generator of Traqula does prints a given string instead of a ewline when NEW_LINE printing is disabled through traqulaIndentation";var Jn=class{rules;factory=new Bt;__context=void 0;origSource="";handledInlineSource;generatedUntil=0;toEnsure=[];stringBuilder=[];constructor(t){this.rules=t;for(let r of Object.values(t))this[r.name]=((n,i,s)=>(this.stringBuilder.length=0,this.toEnsure.length=0,this.origSource=i.origSource,this.generatedUntil=i?.offset??0,this.setContext(i),this.subrule(r,n,s),this.catchup(this.origSource.length),this.handeEnsured(""),this.stringBuilder.join("")))}setContext(t){this.__context=t}getSafeContext(){return this.__context}subrule=(t,r,...n)=>{let i=this.rules[t.name];if(!i)throw new Error(`Rule ${t.name} not found`);let s=()=>i.gImpl({SUBRULE:this.subrule,PRINT:this.print,ENSURE:this.ensure,ENSURE_EITHER:this.ensureEither,NEW_LINE:this.newLine,HANDLE_LOC:this.handleLoc,CATCHUP:this.catchup,PRINT_WORD:this.printWord,PRINT_WORDS:this.printWords,PRINT_ON_EMPTY:this.printOnEmpty,PRINT_ON_OWN_LINE:this.printOnOwnLine})(r,this.getSafeContext(),...n);this.factory.isLocalized(r)?this.handleLoc(r,s):s()};handleLoc=(t,r)=>{if(this.factory.isSourceLocationNoMaterialize(t.loc))return;if(this.factory.isSourceLocationStringReplace(t.loc)){this.catchup(t.loc.start),this.print(t.loc.newSource),this.generatedUntil=t.loc.end;return}if(this.factory.isSourceLocationNodeReplace(t.loc)&&(this.catchup(t.loc.start),this.generatedUntil=t.loc.end),this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.start),this.factory.isSourceLocationInlinedSource(t.loc)&&this.handledInlineSource!==t.loc){this.handledInlineSource=t.loc,this.catchup(t.loc.start);let i=this.origSource,s=this.generatedUntil;this.origSource=t.loc.newSource,this.generatedUntil=0,this.catchup(t.loc.startOnNew);let a=this.handleLoc(t.loc,r);return this.generatedUntil=t.loc.endOnNew,this.catchup(this.origSource.length),this.origSource=i,this.generatedUntil=Math.max(s,t.loc.end),a}let n=r();return this.factory.isSourceLocationSource(t.loc)&&this.catchup(t.loc.end),n};catchup=t=>{let r=this.generatedUntil;r{let r=t.join("");this.handeEnsured(r),this.stringBuilder.push(r)};doesEndWith(t){let r=t.length,n="";for(;n.length0;)n=this.stringBuilder.pop()+n;return this.stringBuilder.push(n),n.endsWith(t)}ensure=(...t)=>{let r=t.join("");this.doesEndWith(r)||this.toEnsure.push(n=>{!n.startsWith(r)&&!this.doesEndWith(r)&&this.stringBuilder.push(r)})};ensureEither=(...t)=>{t.length===1?this.ensure(...t):t.length>1&&!t.some(r=>this.doesEndWith(r))&&this.toEnsure.push(r=>{!t.some(n=>r.startsWith(n))&&!t.some(n=>this.doesEndWith(n))&&this.stringBuilder.push(t[0])})};pruneEndingBlanks(){let t="";for(;/^[ \t]*$/u.test(t)&&this.stringBuilder.length>0;)t=this.stringBuilder.pop()+t;this.print(t.replace(/[\t ]*$/u,""))}newLine=t=>{let r=this.getSafeContext()[H]??0,n=t?.force??!1;if(r<0){let i=this.getSafeContext()[Wr];i!==void 0&&(n||this.stringBuilder.at(-1)!==i)&&this.print(i);return}if(this.pruneEndingBlanks(),n)this.print(` +`," ".repeat(r));else{let i="";for(;!i.includes(` +`)&&this.stringBuilder.length>0;)i=this.stringBuilder.pop()+i;/\n[ \t]*$/u.test(i)?(i=i.replace(/\n[ \t]*$/u,` +${" ".repeat(r)}`),this.print(i)):this.print(i,` +`," ".repeat(r))}};printWord=(...t)=>{this.ensureEither(" ",` `),this.print(...t),this.ensureEither(" ",` -`)};printWords=(...t)=>{for(let r of t)this.printWord(r)};printOnEmpty=(...t)=>{this.newLine(),this.print(...t)};printOnOwnLine=(...t)=>{this.newLine(),this.print(...t),this.newLine()}};function Uu(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var pi=class e{static create(t){return Array.isArray(t)?new e(Uu(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the GeneratorBuilder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Uu(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(l=>l.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`)}return this.rules=n,this}build(){return new ui(this.rules)}};var Ie=class e{tokens;static create(t){return new e(t)}constructor(t){this.tokens=t?.tokens?[...t.tokens]:[]}merge(t,r=[]){let n=t.tokens.filter(i=>{if(r.find(o=>o.name===i.name))return!1;let a=this.tokens.find(o=>o.name===i.name);if(a){if(a!==i)throw new Error(`Token with name ${i.name} already exists. Implementation is different and no overwrite was provided.`);return!1}return!0});return this.tokens.push(...n),this}add(...t){return this.tokens.push(...t),this}addBefore(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n,0,...r),this}moveBeforeOrAfter(t,r,...n){let i=this.tokens.indexOf(r)+(t==="before"?0:1);if(i===-1)throw new Error("BeforeToken not found");for(let s of n){let a=this.tokens.indexOf(s);if(a===-1)throw new Error("Token not found");this.tokens.splice(a,1),this.tokens.splice(i,0,s)}return this}moveBefore(t,...r){return this.moveBeforeOrAfter("before",t,...r)}moveAfter(t,...r){return this.moveBeforeOrAfter("after",t,...r)}addAfter(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n+1,0,...r),this}delete(...t){for(let r of t){let n=this.tokens.indexOf(r);if(n===-1)throw new Error("Token not found");this.tokens.splice(n,1)}return this}deleteToken(...t){for(let r of t){let n=this.tokens.findIndex(i=>i.name===r);if(n===-1)throw new Error(`Token with name "${r}" not found`);this.tokens.splice(n,1)}return this}replace(t){let r=this.tokens.findIndex(n=>n.name===t.name);if(r===-1)throw new Error(`Token with name "${t.name}" not found`);return this.tokens[r]=t,this}build(t){return new me(this.tokens,{positionTracking:"onlyStart",recoveryEnabled:!1,ensureOptimizations:!0,...t})}get tokenVocabulary(){return this.tokens}};var hi=class extends Ju{context;setContext(t){this.context=t}constructor(t,r,n={}){super(r,{maxLookahead:1,skipValidations:!0,dynamicTokensEnabled:!1,...n}),this.context=void 0;let s={...this.constructSelfRef(),cache:new WeakMap};for(let a of Object.values(t))this[a.name]=this.RULE(a.name,a.impl(s));this.performSelfAnalysis()}constructSelfRef(){let t=r=>((n,...i)=>r(this[n.name],{ARGS:[this.context,...i]}));return{CONSUME:(r,n)=>this.CONSUME(r,n),CONSUME1:(r,n)=>this.CONSUME1(r,n),CONSUME2:(r,n)=>this.CONSUME2(r,n),CONSUME3:(r,n)=>this.CONSUME3(r,n),CONSUME4:(r,n)=>this.CONSUME4(r,n),CONSUME5:(r,n)=>this.CONSUME5(r,n),CONSUME6:(r,n)=>this.CONSUME6(r,n),CONSUME7:(r,n)=>this.CONSUME7(r,n),CONSUME8:(r,n)=>this.CONSUME8(r,n),CONSUME9:(r,n)=>this.CONSUME9(r,n),OPTION:r=>this.OPTION(r),OPTION1:r=>this.OPTION1(r),OPTION2:r=>this.OPTION2(r),OPTION3:r=>this.OPTION3(r),OPTION4:r=>this.OPTION4(r),OPTION5:r=>this.OPTION5(r),OPTION6:r=>this.OPTION6(r),OPTION7:r=>this.OPTION7(r),OPTION8:r=>this.OPTION8(r),OPTION9:r=>this.OPTION9(r),OR:r=>this.OR(r),OR1:r=>this.OR1(r),OR2:r=>this.OR2(r),OR3:r=>this.OR3(r),OR4:r=>this.OR4(r),OR5:r=>this.OR5(r),OR6:r=>this.OR6(r),OR7:r=>this.OR7(r),OR8:r=>this.OR8(r),OR9:r=>this.OR9(r),MANY:r=>this.MANY(r),MANY1:r=>this.MANY1(r),MANY2:r=>this.MANY2(r),MANY3:r=>this.MANY3(r),MANY4:r=>this.MANY4(r),MANY5:r=>this.MANY5(r),MANY6:r=>this.MANY6(r),MANY7:r=>this.MANY7(r),MANY8:r=>this.MANY8(r),MANY9:r=>this.MANY9(r),MANY_SEP:r=>this.MANY_SEP(r),MANY_SEP1:r=>this.MANY_SEP1(r),MANY_SEP2:r=>this.MANY_SEP2(r),MANY_SEP3:r=>this.MANY_SEP3(r),MANY_SEP4:r=>this.MANY_SEP4(r),MANY_SEP5:r=>this.MANY_SEP5(r),MANY_SEP6:r=>this.MANY_SEP6(r),MANY_SEP7:r=>this.MANY_SEP7(r),MANY_SEP8:r=>this.MANY_SEP8(r),MANY_SEP9:r=>this.MANY_SEP9(r),AT_LEAST_ONE:r=>this.AT_LEAST_ONE(r),AT_LEAST_ONE1:r=>this.AT_LEAST_ONE1(r),AT_LEAST_ONE2:r=>this.AT_LEAST_ONE2(r),AT_LEAST_ONE3:r=>this.AT_LEAST_ONE3(r),AT_LEAST_ONE4:r=>this.AT_LEAST_ONE4(r),AT_LEAST_ONE5:r=>this.AT_LEAST_ONE5(r),AT_LEAST_ONE6:r=>this.AT_LEAST_ONE6(r),AT_LEAST_ONE7:r=>this.AT_LEAST_ONE7(r),AT_LEAST_ONE8:r=>this.AT_LEAST_ONE8(r),AT_LEAST_ONE9:r=>this.AT_LEAST_ONE9(r),AT_LEAST_ONE_SEP:r=>this.AT_LEAST_ONE_SEP(r),AT_LEAST_ONE_SEP1:r=>this.AT_LEAST_ONE_SEP1(r),AT_LEAST_ONE_SEP2:r=>this.AT_LEAST_ONE_SEP2(r),AT_LEAST_ONE_SEP3:r=>this.AT_LEAST_ONE_SEP3(r),AT_LEAST_ONE_SEP4:r=>this.AT_LEAST_ONE_SEP4(r),AT_LEAST_ONE_SEP5:r=>this.AT_LEAST_ONE_SEP5(r),AT_LEAST_ONE_SEP6:r=>this.AT_LEAST_ONE_SEP6(r),AT_LEAST_ONE_SEP7:r=>this.AT_LEAST_ONE_SEP7(r),AT_LEAST_ONE_SEP8:r=>this.AT_LEAST_ONE_SEP8(r),AT_LEAST_ONE_SEP9:r=>this.AT_LEAST_ONE_SEP9(r),ACTION:r=>this.ACTION(r),BACKTRACK:(r,...n)=>this.BACKTRACK(this[r.name],{ARGS:n}),SUBRULE:t((r,n)=>this.SUBRULE(r,n)),SUBRULE1:t((r,n)=>this.SUBRULE1(r,n)),SUBRULE2:t((r,n)=>this.SUBRULE2(r,n)),SUBRULE3:t((r,n)=>this.SUBRULE3(r,n)),SUBRULE4:t((r,n)=>this.SUBRULE4(r,n)),SUBRULE5:t((r,n)=>this.SUBRULE5(r,n)),SUBRULE6:t((r,n)=>this.SUBRULE6(r,n)),SUBRULE7:t((r,n)=>this.SUBRULE7(r,n)),SUBRULE8:t((r,n)=>this.SUBRULE8(r,n)),SUBRULE9:t((r,n)=>this.SUBRULE9(r,n))}}};function ep(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var oe=class e{static create(t){return Array.isArray(t)?new e(ep(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the builder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...ep(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(l=>l.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the builder, specify an override to resolve conflict`)}return this.rules=n,this}defaultErrorHandler(t,r){let n=r[0],i=["Parse error"],s=n.token.startLine;if(s!==void 0&&!Number.isNaN(s)){let a=t.split(` +`)};printWords=(...t)=>{for(let r of t)this.printWord(r)};printOnEmpty=(...t)=>{this.newLine(),this.print(...t)};printOnOwnLine=(...t)=>{this.newLine(),this.print(...t),this.newLine()}};function Ku(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var Un=class e{static create(t){return Array.isArray(t)?new e(Ku(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the GeneratorBuilder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Ku(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(c=>c.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`)}return this.rules=n,this}build(){return new Jn(this.rules)}};var ye=class e{tokens;static create(t){return new e(t)}constructor(t){this.tokens=t?.tokens?[...t.tokens]:[]}merge(t,r=[]){let n=t.tokens.filter(i=>{if(r.find(o=>o.name===i.name))return!1;let a=this.tokens.find(o=>o.name===i.name);if(a){if(a!==i)throw new Error(`Token with name ${i.name} already exists. Implementation is different and no overwrite was provided.`);return!1}return!0});return this.tokens.push(...n),this}add(...t){return this.tokens.push(...t),this}addBefore(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n,0,...r),this}moveBeforeOrAfter(t,r,...n){let i=this.tokens.indexOf(r)+(t==="before"?0:1);if(i===-1)throw new Error("BeforeToken not found");for(let s of n){let a=this.tokens.indexOf(s);if(a===-1)throw new Error("Token not found");this.tokens.splice(a,1),this.tokens.splice(i,0,s)}return this}moveBefore(t,...r){return this.moveBeforeOrAfter("before",t,...r)}moveAfter(t,...r){return this.moveBeforeOrAfter("after",t,...r)}addAfter(t,...r){let n=this.tokens.indexOf(t);if(n===-1)throw new Error("Token not found");return this.tokens.splice(n+1,0,...r),this}delete(...t){for(let r of t){let n=this.tokens.indexOf(r);if(n===-1)throw new Error("Token not found");this.tokens.splice(n,1)}return this}deleteToken(...t){for(let r of t){let n=this.tokens.findIndex(i=>i.name===r);if(n===-1)throw new Error(`Token with name "${r}" not found`);this.tokens.splice(n,1)}return this}replace(t){let r=this.tokens.findIndex(n=>n.name===t.name);if(r===-1)throw new Error(`Token with name "${t.name}" not found`);return this.tokens[r]=t,this}build(t){return new le(this.tokens,{positionTracking:"onlyStart",recoveryEnabled:!1,ensureOptimizations:!0,...t})}get tokenVocabulary(){return this.tokens}};var ei=class extends Vu{context;setContext(t){this.context=t}constructor(t,r,n={}){super(r,{maxLookahead:1,skipValidations:!0,dynamicTokensEnabled:!1,...n}),this.context=void 0;let s={...this.constructSelfRef(),cache:new WeakMap};for(let a of Object.values(t))this[a.name]=this.RULE(a.name,a.impl(s));this.performSelfAnalysis()}constructSelfRef(){let t=r=>((n,...i)=>r(this[n.name],{ARGS:[this.context,...i]}));return{CONSUME:(r,n)=>this.CONSUME(r,n),CONSUME1:(r,n)=>this.CONSUME1(r,n),CONSUME2:(r,n)=>this.CONSUME2(r,n),CONSUME3:(r,n)=>this.CONSUME3(r,n),CONSUME4:(r,n)=>this.CONSUME4(r,n),CONSUME5:(r,n)=>this.CONSUME5(r,n),CONSUME6:(r,n)=>this.CONSUME6(r,n),CONSUME7:(r,n)=>this.CONSUME7(r,n),CONSUME8:(r,n)=>this.CONSUME8(r,n),CONSUME9:(r,n)=>this.CONSUME9(r,n),OPTION:r=>this.OPTION(r),OPTION1:r=>this.OPTION1(r),OPTION2:r=>this.OPTION2(r),OPTION3:r=>this.OPTION3(r),OPTION4:r=>this.OPTION4(r),OPTION5:r=>this.OPTION5(r),OPTION6:r=>this.OPTION6(r),OPTION7:r=>this.OPTION7(r),OPTION8:r=>this.OPTION8(r),OPTION9:r=>this.OPTION9(r),OR:r=>this.OR(r),OR1:r=>this.OR1(r),OR2:r=>this.OR2(r),OR3:r=>this.OR3(r),OR4:r=>this.OR4(r),OR5:r=>this.OR5(r),OR6:r=>this.OR6(r),OR7:r=>this.OR7(r),OR8:r=>this.OR8(r),OR9:r=>this.OR9(r),MANY:r=>this.MANY(r),MANY1:r=>this.MANY1(r),MANY2:r=>this.MANY2(r),MANY3:r=>this.MANY3(r),MANY4:r=>this.MANY4(r),MANY5:r=>this.MANY5(r),MANY6:r=>this.MANY6(r),MANY7:r=>this.MANY7(r),MANY8:r=>this.MANY8(r),MANY9:r=>this.MANY9(r),MANY_SEP:r=>this.MANY_SEP(r),MANY_SEP1:r=>this.MANY_SEP1(r),MANY_SEP2:r=>this.MANY_SEP2(r),MANY_SEP3:r=>this.MANY_SEP3(r),MANY_SEP4:r=>this.MANY_SEP4(r),MANY_SEP5:r=>this.MANY_SEP5(r),MANY_SEP6:r=>this.MANY_SEP6(r),MANY_SEP7:r=>this.MANY_SEP7(r),MANY_SEP8:r=>this.MANY_SEP8(r),MANY_SEP9:r=>this.MANY_SEP9(r),AT_LEAST_ONE:r=>this.AT_LEAST_ONE(r),AT_LEAST_ONE1:r=>this.AT_LEAST_ONE1(r),AT_LEAST_ONE2:r=>this.AT_LEAST_ONE2(r),AT_LEAST_ONE3:r=>this.AT_LEAST_ONE3(r),AT_LEAST_ONE4:r=>this.AT_LEAST_ONE4(r),AT_LEAST_ONE5:r=>this.AT_LEAST_ONE5(r),AT_LEAST_ONE6:r=>this.AT_LEAST_ONE6(r),AT_LEAST_ONE7:r=>this.AT_LEAST_ONE7(r),AT_LEAST_ONE8:r=>this.AT_LEAST_ONE8(r),AT_LEAST_ONE9:r=>this.AT_LEAST_ONE9(r),AT_LEAST_ONE_SEP:r=>this.AT_LEAST_ONE_SEP(r),AT_LEAST_ONE_SEP1:r=>this.AT_LEAST_ONE_SEP1(r),AT_LEAST_ONE_SEP2:r=>this.AT_LEAST_ONE_SEP2(r),AT_LEAST_ONE_SEP3:r=>this.AT_LEAST_ONE_SEP3(r),AT_LEAST_ONE_SEP4:r=>this.AT_LEAST_ONE_SEP4(r),AT_LEAST_ONE_SEP5:r=>this.AT_LEAST_ONE_SEP5(r),AT_LEAST_ONE_SEP6:r=>this.AT_LEAST_ONE_SEP6(r),AT_LEAST_ONE_SEP7:r=>this.AT_LEAST_ONE_SEP7(r),AT_LEAST_ONE_SEP8:r=>this.AT_LEAST_ONE_SEP8(r),AT_LEAST_ONE_SEP9:r=>this.AT_LEAST_ONE_SEP9(r),ACTION:r=>this.ACTION(r),BACKTRACK:(r,...n)=>this.BACKTRACK(this[r.name],{ARGS:n}),SUBRULE:t((r,n)=>this.SUBRULE(r,n)),SUBRULE1:t((r,n)=>this.SUBRULE1(r,n)),SUBRULE2:t((r,n)=>this.SUBRULE2(r,n)),SUBRULE3:t((r,n)=>this.SUBRULE3(r,n)),SUBRULE4:t((r,n)=>this.SUBRULE4(r,n)),SUBRULE5:t((r,n)=>this.SUBRULE5(r,n)),SUBRULE6:t((r,n)=>this.SUBRULE6(r,n)),SUBRULE7:t((r,n)=>this.SUBRULE7(r,n)),SUBRULE8:t((r,n)=>this.SUBRULE8(r,n)),SUBRULE9:t((r,n)=>this.SUBRULE9(r,n))}}};function Hu(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var te=class e{static create(t){return Array.isArray(t)?new e(Hu(t)):new e({...t.rules})}rules;constructor(t){this.rules=t}widenContext(){return this}typePatch(){return this}patchRule(t){let r=this;return r.rules[t.name]=t,r}addRuleRedundant(t){let r=this,n=r.rules;if(n[t.name]!==void 0&&n[t.name]!==t)throw new Error(`Rule ${t.name} already exists in the builder`);return n[t.name]=t,r}addRule(t){return this.addRuleRedundant(t)}addMany(...t){return this.rules={...this.rules,...Hu(t)},this}deleteRule(t){return delete this.rules[t],this}deleteMany(...t){for(let r of t)delete this.rules[r];return this}getRule(t){return this.rules[t]}merge(t,r){let n=Object.assign(Object.create(null),t.rules),i=this.rules;for(let s of Object.values(i))if(n[s.name]===void 0)n[s.name]=s;else if(n[s.name]!==s){let o=r.find(c=>c.name===s.name);if(o)n[s.name]=o;else throw new Error(`Rule with name "${s.name}" already exists in the builder, specify an override to resolve conflict`)}return this.rules=n,this}defaultErrorHandler(t,r){let n=r[0],i=["Parse error"],s=n.token.startLine;if(s!==void 0&&!Number.isNaN(s)){let a=t.split(` `)[s-1];i.push(` on line ${s} ${a}`);let o=n.token.startColumn;o!==void 0&&i.push(` ${"-".repeat(o-1)}^`)}throw i.push(` -${n.message}`),new Error(i.join(""))}build({tokenVocabulary:t,parserConfig:r={},lexerConfig:n={},queryPreProcessor:i=a=>a,errorHandler:s}){let a=Ie.create().add(...t).build({positionTracking:"onlyOffset",recoveryEnabled:!1,ensureOptimizations:!0,safeMode:!1,skipValidations:!0,...n}),o=this.consume({tokenVocabulary:t,config:r}),l={};for(let u of Object.values(this.rules))l[u.name]=((p,h,...f)=>{let m=i(p),v=a.tokenize(m);if(v.errors.length>0)throw new Error(v.errors[0].message);o.input=v.tokens,o.setContext(h);let x=o[u.name](h,...f);return o.errors.length>0&&(s?s(o.errors):this.defaultErrorHandler(m,o.errors)),x});return l}consume({tokenVocabulary:t,config:r={}}){return new hi(this.rules,t,r)}};function fr(e){return e instanceof Promise}function Pt(e,t){return fr(e)?e.then(t):t(e)}function fi(e){return{shortcut:void 0,continue:void 0,ignoreKeys:void 0,visitChildren:void 0,shallowKeys:void 0,copy:void 0,reTransform:void 0,...e}}var zt=class e{maxStackSize=1e6;maxNodeRewrites=1e3;defaultContext;constructor(t={}){this.defaultContext=fi(t)}clone(t={}){return new e({...this.defaultContext,...t})}cloneObj(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return[...t];let r=Object.getPrototypeOf(t);return r===Object.prototype||r===null?{...t}:Object.assign(Object.create(r),t)}createVisitChildrenOf(t){let r,n,i=new Set,s=(u,p)=>u===r&&(n.ignoreKeys?.has(p)===!0||n.shallowKeys?.has(p)===!0),l={visitKey:((u,p)=>{let h=u?.[p];h!==null&&typeof h=="object"&&!s(u,p)&&t(h,u,String(p))}),stepIntoKey:((u,p)=>{let h=u?.[p];if(h===null||typeof h!="object")return h;if(s(u,p))return Array.isArray(h)?[]:{};if(!n.copiesSteps||i.has(h))return h;let f=this.cloneObj(h);return i.add(f),u[p]=f,f})};return(u,p)=>{if(p.shallowKeys!==void 0){let h=u;for(let f of p.shallowKeys){let m=h[f];m!==null&&typeof m=="object"&&Object.hasOwn(h,f)&&(h[f]=this.cloneObj(m))}}r=u,n=p,p.visitChildren(u,l),i.size>0&&i.clear()}}transformObject(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!1)}async transformObjectAsync(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!0)}runTransformObject(t,r,n,i){let s=this.defaultContext,a=s.copy??!0,o=s.continue??!0,l=s.ignoreKeys,u=s.visitChildren,p=s.shallowKeys,h=s.shortcut??!1,f=!1,m={res:t},v=[t],x=[m],A=["res"],y=[],b=[],g=[],I=[],w=[];function C(){for(;v.length===y.at(-1);){y.pop();let V=b.pop(),H=g.pop(),j=I.pop(),$=w.pop(),te=r(V,H);if(i&&fr(te))return te.then(J=>(j[$]=J,C()));j[$]=te}}let se=(V,H,j)=>{v.push(V),A.push(j),x.push(H)},Z,F=(V,H,j,$)=>{let te=$.copy??a,J=$.continue??o,ye=$.ignoreKeys??l,Te=$.visitChildren??u,Ye=$.shallowKeys??p;f=$.shortcut??h;let he=te?this.cloneObj(V):V;if(y.push(v.length),b.push(he),g.push(V),I.push(H),w.push(j),J&&!f){if(Te){Z??=this.createVisitChildrenOf(se),Z(he,{visitChildren:Te,ignoreKeys:ye,shallowKeys:Ye,copiesSteps:te});return}for(let Y in he){if(!Object.hasOwn(he,Y))continue;let Ce=he[Y],fe=Ye&&Ye?.has(Y);fe&&(he[Y]=this.cloneObj(Ce)),!(ye&&ye.has(Y))&&!fe&&Ce!==null&&typeof Ce=="object"&&(v.push(Ce),A.push(Y),x.push(he))}}},ee=()=>{for(;v.length>0&&v.length=0;Te--){let Ye=V[Te];Ye!==null&&typeof Ye=="object"&&(v.push(Ye),x.push(J),A.push(Te.toString()))}let ye=C();if(ye)return ye.then(ee);continue}let te=n(V);if(i&&fr(te))return te.then(J=>{F(V,H,j,J);let ye=C();return ye?ye.then(ee):ee()});F(V,H,j,te)}let $=C();if($)return $.then(ee)}if(v.length>=this.maxStackSize||y.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return m.res};return ee()}transformObjectPreOrder(t,r){return this.runTransformObjectPreOrder(t,r,!1)}async transformObjectPreOrderAsync(t,r){return this.runTransformObjectPreOrder(t,r,!0)}runTransformObjectPreOrder(t,r,n){let i=this.defaultContext,s=i.copy??!0,a=i.continue??!0,o=i.ignoreKeys,l=i.visitChildren,u=i.shallowKeys,p=i.shortcut??!1,h=i.reTransform??!1,f=!1,m={res:t},v=[t],x=[m],A=["res"],y=[0],b=[0];function g(F,ee,V){for(let H=F.length-1;H>=0;H--){let j=F[H];j!==null&&typeof j=="object"&&(v.push(j),x.push(F),A.push(H.toString()),y.push(ee),b.push(V+1))}}let I=0,w=(F,ee,V)=>{v.push(F),x.push(ee),A.push(V),y.push(0),b.push(I)},C,se=(F,ee,V,H,j)=>{let $=F.newValue;ee[V]=$;let te=F.continue??a,J=F.ignoreKeys??o,ye=F.visitChildren??l,Te=F.shallowKeys??u,Ye=F.reTransform??h;if(f=F.shortcut??p,!te||f||$===null||typeof $!="object")return;if(Array.isArray($)){g($,H+1,j);return}if(Ye){v.push($),x.push(ee),A.push(V),y.push(H+1),b.push(j);return}let he=$;if(I=j+1,ye){C??=this.createVisitChildrenOf(w),C(he,{visitChildren:ye,ignoreKeys:J,shallowKeys:Te,copiesSteps:s});return}for(let Y in he){if(!Object.hasOwn(he,Y))continue;let Ce=he[Y];Ce!==null&&typeof Ce=="object"&&(Te?.has(Y)?he[Y]=this.cloneObj(Ce):(J===void 0||!J.has(Y))&&w(Ce,he,Y))}},Z=()=>{for(;!f&&v.length>0&&v.length=this.maxNodeRewrites)throw new Error(`Pre order transform did not converge: rewrote the same position ${this.maxNodeRewrites} times.`,{cause:F});if(j>=this.maxStackSize)throw new Error("Transform object stack overflowed");if(Array.isArray(F)){let J=[...F];ee[V]=J,g(J,H,j);continue}let $=s?this.cloneObj(F):F,te=r($,F);if(n&&fr(te))return te.then(J=>(se(J,ee,V,H,j),Z()));se(te,ee,V,H,j)}if(v.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return m.res};return Z()}visitObject(t,r,n=()=>({})){this.runVisitObject(t,r,n,!1)}async visitObjectAsync(t,r,n=()=>({})){await this.runVisitObject(t,r,n,!0)}runVisitObject(t,r,n,i){let s=this.defaultContext,a=s.continue??!0,o=s.ignoreKeys,l=s.visitChildren,u=s.shortcut??!1,p=!1,h=[t],f=[],m=[];function v(){for(;h.length===f.at(-1);){f.pop();let g=m.pop();if(g===void 0)continue;let I=r(g);if(i&&fr(I))return I.then(()=>v())}}let x=g=>{h.push(g)},A,y=(g,I)=>{p=I.shortcut??u;let w=I.continue??a,C=I.ignoreKeys??o,se=I.visitChildren??l;if(f.push(h.length),m.push(g),w&&!p){if(se){A??=this.createVisitChildrenOf(x),A(g,{visitChildren:se,ignoreKeys:C,shallowKeys:void 0,copiesSteps:!1});return}for(let Z in g){if(!Object.hasOwn(g,Z)||C&&C.has(Z))continue;let F=g[Z];F&&typeof F=="object"&&h.push(F)}}},b=()=>{for(;h.length>0&&h.length=0;se--){let Z=g[se];Z!==null&&typeof Z=="object"&&h.push(Z)}let C=v();if(C)return C.then(b);continue}let w=n(g);if(i&&fr(w))return w.then(C=>{y(g,C);let se=v();return se?se.then(b):b()});y(g,w)}let I=v();if(I)return I.then(b)}if(h.length>=this.maxStackSize||f.length>=this.maxStackSize)throw new Error("Transform object stack overflowed")};return b()}};var mS=Object.freeze(fi({}));function Ne(e){return e!==null&&typeof e=="object"&&typeof e.type=="string"}function Ca(e){let t={};for(let[r,n]of Object.entries(e)){let i=Object.entries(n),s=i.filter(([,l])=>l===!0).map(([l])=>l),a=i.flatMap(([l,u])=>typeof u=="function"?[{key:l,visitor:u}]:[]),o=(l,u)=>{for(let p of s)u.visitKey(l,p);for(let{key:p,visitor:h}of a){let f=u.stepIntoKey(l,p);f!==null&&typeof f=="object"&&h(f,u)}};t[r]={visitChildren:o}}return t}function dr(...e){return(t,{visitKey:r,stepIntoKey:n})=>{for(let i=t.length-1;i>=0;i--){if(Ne(t[i])){r(t,i);continue}let s=n(t,i);for(let a of e)r(s,a)}}}var Ur=class e extends zt{defaultNodePreVisitor;constructor(t={},r={}){super(t),this.defaultNodePreVisitor=Object.fromEntries(Object.entries(r).map(([n,i])=>[n,fi(i)]))}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}withNodeDefault(t,r){let n=t?.type,i=typeof n=="string"?this.defaultNodePreVisitor[n]:void 0;return i===void 0?r??mS:r?{...i,...r}:i}transformNode(t,r){let n=(s,a)=>{let o,l=s;return Ne(l)&&(o=r[l.type]?.transform),o?o(l,a):s},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),this.withNodeDefault(o,a?.(o))};return this.transformObject(t,n,i)}transformNodeAsync(t,r){let n=(s,a)=>{let o,l=s;return Ne(l)&&(o=r[l.type]?.transform),o?o(l,a):s},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),Pt(a?.(o),l=>this.withNodeDefault(o,l))};return this.transformObjectAsync(t,n,i)}transformNodePreOrder(t,r){let n=(i,s)=>{let a,o=i;Ne(o)&&(a=r[o.type]);let l=a?a(i,s):{newValue:i,reTransform:!1};return this.withNodeDefault(l.newValue,l)};return this.transformObjectPreOrder(t,n)}transformNodePreOrderAsync(t,r){let n=(i,s)=>{let a,o=i;Ne(o)&&(a=r[o.type]);let l=a?a(i,s):{newValue:i,reTransform:!1};return Pt(l,u=>this.withNodeDefault(u.newValue,u))};return this.transformObjectPreOrderAsync(t,n)}visitNode(t,r){let n=s=>{let a=s;if(Ne(a)){let o=r[a.type]?.visitor;o&&o(a)}},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),this.withNodeDefault(o,a?.(o))};return this.visitObject(t,n,i)}visitNodeAsync(t,r){let n=s=>{let a=s;if(Ne(a)){let o=r[a.type]?.visitor;if(o)return o(a)}},i=s=>{let a,o=s;return Ne(o)&&(a=r[o.type]?.preVisitor),Pt(a?.(o),l=>this.withNodeDefault(o,l))};return this.visitObjectAsync(t,n,i)}};function ut(e,t,r,n){if(!Ne(e))return;let i=e.subType?r[e.type]?.[e.subType]:void 0;return n===void 0?i??t[e.type]:i?.[n]??t[e.type]?.[n]}var en=class e extends Ur{constructor(t={},r={}){super(t,r)}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNodeSpecific(t,r,n){let i=(a,o)=>{let l=ut(a,r,n,"transform");return l?l(a,o):a},s=a=>{let o=ut(a,r,n,"preVisitor");return this.withNodeDefault(a,o?.(a))};return this.transformObject(t,i,s)}transformNodeSpecificAsync(t,r,n){let i=(a,o)=>{let l=ut(a,r,n,"transform");return l?l(a,o):a},s=a=>{let o=ut(a,r,n,"preVisitor");return Pt(o?.(a),l=>this.withNodeDefault(a,l))};return this.transformObjectAsync(t,i,s)}transformNodeSpecificPreOrder(t,r,n){let i=(s,a)=>{let o=ut(s,r,n),l=o?o(s,a):{newValue:s,reTransform:!1};return this.withNodeDefault(l.newValue,l)};return this.transformObjectPreOrder(t,i)}transformNodeSpecificPreOrderAsync(t,r,n){let i=(s,a)=>{let o=ut(s,r,n),l=o?o(s,a):{newValue:s,reTransform:!1};return Pt(l,u=>this.withNodeDefault(u.newValue,u))};return this.transformObjectPreOrderAsync(t,i)}visitNodeSpecific(t,r,n){let i=a=>{ut(a,r,n,"visitor")?.(a)},s=a=>{let o=ut(a,r,n,"preVisitor");return this.withNodeDefault(a,o?.(a))};this.visitObject(t,i,s)}visitNodeSpecificAsync(t,r,n){let i=a=>ut(a,r,n,"visitor")?.(a),s=a=>{let o=ut(a,r,n,"preVisitor");return Pt(o?.(a),l=>this.withNodeDefault(a,l))};return this.visitObjectAsync(t,i,s)}};var c={};Mt(c,{add:()=>pl,additiveExpression:()=>km,aggregate:()=>bs,aggregateAvg:()=>zd,aggregateCount:()=>jd,aggregateGroup_concat:()=>qd,aggregateMax:()=>Wd,aggregateMin:()=>Hd,aggregateSample:()=>Yd,aggregateSum:()=>Kd,argList:()=>br,askQuery:()=>yn,baseAggregateFunc:()=>Zt,baseDecl:()=>ho,bind:()=>jo,blankNode:()=>ms,blankNodePropertyList:()=>bm,blankNodePropertyListPath:()=>Fo,booleanLiteral:()=>Qt,brackettedExpression:()=>Ir,builtInAbs:()=>Qf,builtInBnodeSparqlJs:()=>qf,builtInBound:()=>Wf,builtInCall:()=>It,builtInCallList:()=>Cd,builtInCeil:()=>Bf,builtInCoalesce:()=>Ld,builtInConcat:()=>Uf,builtInContains:()=>id,builtInDatatype:()=>Hf,builtInDay:()=>pd,builtInEncode_for_uri:()=>nd,builtInFloor:()=>Zf,builtInHours:()=>hd,builtInIf:()=>_d,builtInIri:()=>zf,builtInIsblank:()=>wd,builtInIsiri:()=>Pd,builtInIsliteral:()=>Rd,builtInIsnumeric:()=>Fd,builtInIsuri:()=>kd,builtInLang:()=>jf,builtInLangmatches:()=>Kf,builtInLcase:()=>rd,builtInMd5:()=>Ad,builtInMinutes:()=>fd,builtInMonth:()=>ud,builtInNow:()=>Td,builtInRand:()=>Xf,builtInRound:()=>Jf,builtInSameterm:()=>Nd,builtInSeconds:()=>dd,builtInSha1:()=>xd,builtInSha256:()=>bd,builtInSha384:()=>Id,builtInSha512:()=>Ed,builtInStr:()=>Vf,builtInStrafter:()=>ld,builtInStrbefore:()=>od,builtInStrdt:()=>Sd,builtInStrends:()=>ad,builtInStrlang:()=>Od,builtInStrlen:()=>ed,builtInStrstarts:()=>sd,builtInStruuid:()=>yd,builtInTimezone:()=>md,builtInTz:()=>gd,builtInUcase:()=>td,builtInUri:()=>Yf,builtInUuid:()=>vd,builtInYear:()=>cd,canCreateBlankNodes:()=>ES,clear:()=>ll,collection:()=>ym,collectionPath:()=>Ro,conditionalAndExpression:()=>Xo,conditionalOrExpression:()=>Nm,constraint:()=>dn,constructQuery:()=>Tn,constructTemplate:()=>al,constructTriples:()=>Cm,copy:()=>fl,create:()=>ul,dataBlock:()=>_m,dataBlockValue:()=>Yo,datasetClause:()=>If,datasetClauseStar:()=>tt,datasetClauseUsing:()=>To,datasetClauseUsingStar:()=>vo,defaultGraphClause:()=>Ef,deleteClause:()=>Dm,deleteData:()=>ml,deleteWhere:()=>gl,describeQuery:()=>vn,drop:()=>cl,existsFunc:()=>$d,expression:()=>k,expressionList:()=>As,filter:()=>Wo,funcExpr1:()=>D,funcExpr2:()=>rt,funcExpr2or3:()=>vs,funcExpr3:()=>Ao,funcExpr3or4:()=>Io,funcExprList1:()=>Ts,funcExprOrNil1:()=>bo,funcGroupGraphPattern:()=>ys,funcNil1:()=>Ar,funcVar1:()=>xo,functionCall:()=>Os,generatePattern:()=>Em,graphGraphPattern:()=>$o,graphNode:()=>Do,graphNodePath:()=>ht,graphOrDefault:()=>yl,graphPatternNotTriples:()=>zo,graphRef:()=>xn,graphRefAll:()=>er,graphTerm:()=>mo,groupClause:()=>el,groupCondition:()=>wm,groupGraphPattern:()=>B,groupGraphPatternSub:()=>Lm,groupOrUnionGraphPattern:()=>Ho,havingClause:()=>tl,havingCondition:()=>Rm,inlineData:()=>xr,inlineDataFull:()=>Sm,inlineDataOneVar:()=>Om,insertClause:()=>vl,insertData:()=>dl,iri:()=>G,iriFull:()=>yr,iriOrFunction:()=>Uo,limitClause:()=>il,limitOffsetClauses:()=>nl,load:()=>ol,minusGraphPattern:()=>Ko,modify:()=>Tl,move:()=>hl,multiplicativeExpression:()=>Zo,namedGraphClause:()=>_f,notExistsFunc:()=>Vd,numericExpression:()=>Bo,numericLiteral:()=>Xt,numericLiteralNegative:()=>fs,numericLiteralPositive:()=>hs,numericLiteralUnsigned:()=>bf,object:()=>gm,objectList:()=>fm,objectListPath:()=>dm,objectPath:()=>Tm,offsetClause:()=>sl,optionalGraphPattern:()=>Go,orderClause:()=>rl,orderCondition:()=>Fm,path:()=>Es,pathAlternative:()=>Jd,pathChainHelper:()=>wo,pathElt:()=>ko,pathEltOrInverse:()=>Bd,pathGenerator:()=>Et,pathMod:()=>Ud,pathNegatedPropertySet:()=>tm,pathOneInPropertySet:()=>Is,pathPrimary:()=>em,pathSequence:()=>Zd,prefixDecl:()=>fo,prefixOperators:()=>Ut,prefixedName:()=>po,primaryExpression:()=>Jo,prologue:()=>He,propertyList:()=>om,propertyListNotEmpty:()=>Ls,propertyListPath:()=>lm,propertyListPathNotEmpty:()=>_s,quadData:()=>bl,quadPattern:()=>ks,quads:()=>_r,quadsNotTriples:()=>Al,query:()=>Er,queryOrUpdate:()=>DS,queryUnit:()=>CS,rdfLiteral:()=>Ft,regexExpression:()=>Md,relationalExpression:()=>Pm,selectClause:()=>Ns,selectQuery:()=>gn,serviceGraphPattern:()=>Vo,solutionModifier:()=>ze,sourceSelector:()=>yo,strReplaceExpression:()=>Gd,string:()=>ds,stringEscapedLexical:()=>un,subSelect:()=>qo,substringExpression:()=>Dd,triplesBlock:()=>ft,triplesNode:()=>Co,triplesNodePath:()=>Mo,triplesSameSubject:()=>im,triplesSameSubjectPath:()=>sm,triplesTemplate:()=>Jt,unaryExpression:()=>Ss,update:()=>Ps,update1:()=>Lr,updateUnit:()=>MS,usingClause:()=>Lf,usingClauseStar:()=>gs,validateDescribeQuery:()=>Qd,validateFunctionCall:()=>fn,validateGroupGraphPattern:()=>No,validateGroupGraphPatternSub:()=>Po,validateQuery:()=>pn,validateSelectQuery:()=>Xd,validateSubSelect:()=>So,validateUpdate:()=>hn,valueLogical:()=>Qo,valuesClause:()=>An,varOrIri:()=>bt,varOrTerm:()=>ge,var_:()=>Q,verb:()=>go,verbA:()=>Bt,verbPath:()=>um,verbSimple:()=>pm,whereClause:()=>We});var ve={};Mt(ve,{a:()=>Tr,add:()=>Ki,allBaseTokens:()=>lf,as:()=>kt,ask:()=>Si,baseDecl:()=>bi,bind:()=>ts,builtIn:()=>E,by:()=>ln,clear:()=>$i,construct:()=>_i,copy:()=>zi,create:()=>ji,deleteClause:()=>Qi,deleteDataClause:()=>qi,deleteWhereClause:()=>Xi,describe:()=>Oi,distinct:()=>et,drop:()=>Vi,false_:()=>os,filter:()=>ss,from:()=>Ni,graph:()=>Ee,groupByGroup:()=>on,having:()=>Pi,in_:()=>ls,insertClause:()=>Zi,insertDataClause:()=>Bi,limit:()=>Fi,load:()=>Di,loadInto:()=>Gi,minus:()=>ns,modifyWith:()=>Yi,move:()=>Wi,notIn:()=>cs,offset:()=>Ci,optional:()=>Ui,order:()=>ki,orderAsc:()=>wi,orderDesc:()=>Ri,patterns:()=>io,prefixDecl:()=>Ii,reduced:()=>Li,select:()=>Ei,separator:()=>us,service:()=>es,silent:()=>yt,sparql11LexerBuilder:()=>gS,symbols:()=>T,terminals:()=>R,to:()=>Hi,true_:()=>as,undef:()=>rs,union:()=>is,usingClause:()=>Ji,values:()=>Mi,where:()=>wt});var E={};Mt(E,{BuiltInCalls:()=>L,abs:()=>up,allBuiltInCalls:()=>Ma,avg:()=>di,bnode:()=>lp,bound:()=>sp,ceil:()=>pp,coalesce:()=>Vp,concat:()=>dp,contains:()=>yp,count:()=>th,datatype:()=>ip,day:()=>_p,encode_for_uri:()=>vp,exists:()=>Up,floor:()=>hp,groupConcat:()=>mi,hours:()=>Op,if_:()=>jp,iri:()=>ap,isblank:()=>qp,isiri:()=>zp,isliteral:()=>Xp,isnumeric:()=>Qp,isuri:()=>Yp,lang:()=>rp,langmatches:()=>np,lcase:()=>Tp,max:()=>ih,md5:()=>Cp,min:()=>nh,minutes:()=>Sp,month:()=>Lp,notexists:()=>eh,now:()=>wp,rand:()=>cp,regex:()=>Bp,replace:()=>Jp,round:()=>fp,sameterm:()=>Wp,sample:()=>sh,seconds:()=>Np,sha1:()=>Mp,sha256:()=>Dp,sha384:()=>Gp,sha512:()=>$p,str:()=>tp,strafter:()=>Ip,strbefore:()=>bp,strdt:()=>Hp,strends:()=>xp,strlang:()=>Kp,strlen:()=>mp,strstarts:()=>Ap,struuid:()=>Fp,substr:()=>Zp,sum:()=>rh,timezone:()=>Pp,tz:()=>kp,ucase:()=>gp,uri:()=>op,uuid:()=>Rp,year:()=>Ep});var L;(function(e){e.Str="builtInStr",e.Lang="builtInLang",e.Langmatches="builtInLangmatches",e.Datatype="builtInDatatype",e.Bound="builtInBound",e.Iri="builtInIri",e.Uri="builtInUri",e.Bnode="builtInBnode",e.Rand="builtInRand",e.Abs="builtInAbs",e.Ceil="builtInCeil",e.Floor="builtInFloor",e.Round="builtInRound",e.Concat="builtInConcat",e.Strlen="builtInStrlen",e.Ucase="builtInUcase",e.Lcase="builtInLcase",e.Encode_for_uri="builtInEncode_for_uri",e.Contains="builtInContains",e.Strstarts="builtInStrstarts",e.Strends="builtInStrends",e.Strbefore="builtInStrbefore",e.Strafter="builtInStrafter",e.Year="builtInYear",e.Month="builtInMonth",e.Day="builtInDay",e.Hours="builtInHours",e.Minutes="builtInMinutes",e.Seconds="builtInSeconds",e.Timezone="builtInTimezone",e.Tz="builtInTz",e.Now="builtInNow",e.Uuid="builtInUuid",e.Struuid="builtInStruuid",e.Md5="builtInMd5",e.Sha1="builtInSha1",e.Sha256="builtInSha256",e.Sha384="builtInSha384",e.Sha512="builtInSha512",e.Coalesce="builtInCoalesce",e.If="builtInIf",e.Strlang="builtInStrlang",e.Strdt="builtInStrdt",e.Sameterm="builtInSameterm",e.Isiri="builtInIsiri",e.Isuri="builtInIsuri",e.Isblank="builtInIsblank",e.Isliteral="builtInIsliteral",e.Isnumeric="builtInIsnumeric",e.Regex="builtInRegex",e.Substr="builtInSubstr",e.Replace="builtInReplace",e.Exists="builtInExists",e.Notexists="builtInNotexists",e.Count="builtInCount",e.Sum="builtInSum",e.Min="builtInMin",e.Max="builtInMax",e.Avg="builtInAvg",e.Sample="builtInSample",e.Group_concat="builtInGroup_concat"})(L||(L={}));function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}var tp=d({name:_(L.Str),pattern:/str/i,label:"STR"}),rp=d({name:_(L.Lang),pattern:/lang/i,label:"LANG"}),np=d({name:_(L.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),ip=d({name:_(L.Datatype),pattern:/datatype/i,label:"DATATYPE"}),sp=d({name:_(L.Bound),pattern:/bound/i,label:"BOUND"}),ap=d({name:_(L.Iri),pattern:/iri/i,label:"IRI"}),op=d({name:_(L.Uri),pattern:/uri/i,label:"URI"}),lp=d({name:_(L.Bnode),pattern:/bnode/i,label:"BNODE"}),cp=d({name:_(L.Rand),pattern:/rand/i,label:"RAND"}),up=d({name:_(L.Abs),pattern:/abs/i,label:"ABS"}),pp=d({name:_(L.Ceil),pattern:/ceil/i,label:"CEIL"}),hp=d({name:_(L.Floor),pattern:/floor/i,label:"FLOOR"}),fp=d({name:_(L.Round),pattern:/round/i,label:"ROUND"}),dp=d({name:_(L.Concat),pattern:/concat/i,label:"CONCAT"}),mp=d({name:_(L.Strlen),pattern:/strlen/i,label:"STRLEN"}),gp=d({name:_(L.Ucase),pattern:/ucase/i,label:"UCASE"}),Tp=d({name:_(L.Lcase),pattern:/lcase/i,label:"LCASE"}),vp=d({name:_(L.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),yp=d({name:_(L.Contains),pattern:/contains/i,label:"CONTAINS"}),Ap=d({name:_(L.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),xp=d({name:_(L.Strends),pattern:/strends/i,label:"STRENDS"}),bp=d({name:_(L.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),Ip=d({name:_(L.Strafter),pattern:/strafter/i,label:"STRAFTER"}),Ep=d({name:_(L.Year),pattern:/year/i,label:"YEAR"}),Lp=d({name:_(L.Month),pattern:/month/i,label:"MONTH"}),_p=d({name:_(L.Day),pattern:/day/i,label:"DAY"}),Op=d({name:_(L.Hours),pattern:/hours/i,label:"HOURS"}),Sp=d({name:_(L.Minutes),pattern:/minutes/i,label:"MINUTES"}),Np=d({name:_(L.Seconds),pattern:/seconds/i,label:"SECONDS"}),Pp=d({name:_(L.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),kp=d({name:_(L.Tz),pattern:/tz/i,label:"TZ"}),wp=d({name:_(L.Now),pattern:/now/i,label:"NOW"}),Rp=d({name:_(L.Uuid),pattern:/uuid/i,label:"UUID"}),Fp=d({name:_(L.Struuid),pattern:/struuid/i,label:"STRUUID"}),Cp=d({name:_(L.Md5),pattern:/md5/i,label:"MD5"}),Mp=d({name:_(L.Sha1),pattern:/sha1/i,label:"SHA1"}),Dp=d({name:_(L.Sha256),pattern:/sha256/i,label:"SHA256"}),Gp=d({name:_(L.Sha384),pattern:/sha384/i,label:"SHA384"}),$p=d({name:_(L.Sha512),pattern:/sha512/i,label:"SHA512"}),Vp=d({name:_(L.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),jp=d({name:_(L.If),pattern:/if/i,label:"IF"}),Kp=d({name:_(L.Strlang),pattern:/strlang/i,label:"STRLANG"}),Hp=d({name:_(L.Strdt),pattern:/strdt/i,label:"STRDT"}),Wp=d({name:_(L.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),zp=d({name:_(L.Isiri),pattern:/isiri/i,label:"ISIRI"}),Yp=d({name:_(L.Isuri),pattern:/isuri/i,label:"ISURI"}),qp=d({name:_(L.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Xp=d({name:_(L.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Qp=d({name:_(L.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),Bp=d({name:_(L.Regex),pattern:/regex/i,label:"REGEX"}),Zp=d({name:_(L.Substr),pattern:/substr/i,label:"SUBSTR"}),Jp=d({name:_(L.Replace),pattern:/replace/i,label:"REPLACE"}),Up=d({name:_(L.Exists),pattern:/exists/i,label:"EXISTS"}),eh=d({name:_(L.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),th=d({name:_(L.Count),pattern:/count/i,label:"COUNT"}),rh=d({name:_(L.Sum),pattern:/sum/i,label:"SUM"}),nh=d({name:_(L.Min),pattern:/min/i,label:"MIN"}),ih=d({name:_(L.Max),pattern:/max/i,label:"MAX"}),di=d({name:_(L.Avg),pattern:/avg/i,label:"AVG"}),sh=d({name:_(L.Sample),pattern:/sample/i,label:"SAMPLE"}),mi=d({name:_(L.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),Ma=Ie.create().add(np,ip,rp,sp,ap,op,lp,cp,up,pp,hp,fp,dp,mp,gp,Tp,vp,yp,Ap,xp,bp,Ip,Ep,Lp,_p,Op,Sp,Np,Pp,kp,wp,Rp,Fp,Cp,Mp,Dp,Gp,$p,Vp,jp,Kp,Hp,Wp,zp,Yp,qp,Xp,Qp,Bp,Zp,Jp,Up,eh,th,rh,nh,ih,di,sh,mi,tp);var Ee={};Mt(Ee,{allGraphTokens:()=>Da,default_:()=>oh,graph:()=>lh,graphAll:()=>gi,named:()=>ah});var ah=d({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),oh=d({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),lh=d({name:"Graph",pattern:/graph/i,label:"GRAPH"}),gi=d({name:"GraphAll",pattern:/all/i,label:"ALL"}),Da=Ie.create().add(ah,oh,lh,gi);var io={};Mt(io,{anonPattern:()=>no,atLeastOneBlankPattern:()=>an,blankNodeLabelPattern:()=>Ka,commentPattern:()=>xi,decimalNegativePattern:()=>Ba,decimalPattern:()=>rn,decimalPositivePattern:()=>qa,doubleNegativePattern:()=>Za,doublePattern:()=>nn,doublePositivePattern:()=>Xa,echarPattern:()=>sn,exponentPattern:()=>vi,integerNegativePattern:()=>Qa,integerPattern:()=>tn,integerPositivePattern:()=>Ya,iriRefPattern:()=>Va,langTagPattern:()=>za,nilPattern:()=>ro,pNameLnPattern:()=>ja,pNameNsPattern:()=>yi,percentPattern:()=>uh,plxPattern:()=>Ti,pnCharsBasePattern:()=>Ga,pnCharsPattern:()=>Yt,pnCharsUPattern:()=>mr,pnLocalEscPattern:()=>Ai,pnLocalPattern:()=>ph,pnPrefixPattern:()=>ch,stringLiteral1Pattern:()=>Ja,stringLiteral2Pattern:()=>Ua,stringLiteralLong1Pattern:()=>eo,stringLiteralLong2Pattern:()=>to,var1Pattern:()=>Ha,var2Pattern:()=>Wa,varNamePattern:()=>$a,wsPattern:()=>gr});var Ga=/[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/,mr=new RegExp(`(${Ga.source})|_`),$a=new RegExp(`((${mr.source})|[0-9])((${mr.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),Va=/<([^\u0000-\u0020"<>\\^`{|}])*>/,Yt=new RegExp(`(${mr.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),ch=new RegExp(`(${Ga.source})(((${Yt.source})|\\.)*(${Yt.source}))?`),yi=new RegExp(`(${ch.source})?:`),uh=/%[\dA-Fa-f]{2}/,Ai=/\\[!#$%&'()*+,./;=?@_~-]/,Ti=new RegExp(`(${uh.source})|(${Ai.source})`),ph=new RegExp(`((${mr.source})|:|[0-9]|(${Ti.source}))(((${Yt.source})|\\.|:|(${Ti.source}))*((${Yt.source})|:|(${Ti.source})))?`),ja=new RegExp(`(${yi.source})(${ph.source})`),Ka=new RegExp(`_:((${mr.source})|[0-9])(((${Yt.source})|\\.)*(${Yt.source}))?`),Ha=new RegExp(`\\?(${$a.source})`),Wa=new RegExp(`\\$(${$a.source})`),za=/@[A-Za-z]+(-[\dA-Za-z]+)*/,tn=/\d+/,rn=/\d+\.\d+/,vi=/[Ee][+-]?\d+/,nn=new RegExp(`([0-9]+\\.[0-9]*(${vi.source}))|(\\.[0-9]+(${vi.source}))|([0-9]+(${vi.source}))`),Ya=new RegExp(`\\+(${tn.source})`),qa=new RegExp(`\\+(${rn.source})`),Xa=new RegExp(`\\+(${nn.source})`),Qa=new RegExp(`-(${tn.source})`),Ba=new RegExp(`-(${rn.source})`),Za=new RegExp(`-(${nn.source})`),sn=/\\["'\\bfnrt]/,Ja=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${sn.source}))*'`),Ua=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${sn.source}))*"`),eo=new RegExp(`'''(('|(''))?([^'\\\\]|(${sn.source})))*'''`),to=new RegExp(`"""(("|(""))?([^"\\\\]|(${sn.source})))*"""`),gr=/[\u0009\u000A\u000D ]/,ro=new RegExp(`\\((${gr.source})*\\)`),no=new RegExp(`\\[(${gr.source})*\\]`),xi=/#[^\n\r]*/,an=new RegExp(`(((${gr.source})+)|((${xi.source})(\r -|\r| -)))+`);var T={};Mt(T,{LCurly:()=>hh,LParen:()=>Th,LSquare:()=>yh,RCurly:()=>fh,RParen:()=>vh,RSquare:()=>Ah,allSymbols:()=>so,comma:()=>mh,dot:()=>dh,equal:()=>kh,exclamation:()=>Sh,greaterThan:()=>Fh,greaterThanEqual:()=>Mh,hat:()=>Ih,hathat:()=>Dh,lessThan:()=>Rh,lessThanEqual:()=>Ch,logicAnd:()=>Nh,logicOr:()=>Ph,notEqual:()=>wh,opMinus:()=>Oh,opPlus:()=>_h,pipe:()=>xh,question:()=>Eh,semi:()=>gh,slash:()=>bh,star:()=>Lh});var hh=d({name:"LCurly",pattern:"{",label:"{"}),fh=d({name:"RCurly",pattern:"}",label:"}"}),dh=d({name:"Dot",pattern:".",label:"."}),mh=d({name:"Comma",pattern:",",label:","}),gh=d({name:"Semi",pattern:";",label:";"}),Th=d({name:"LParen",pattern:"(",label:"("}),vh=d({name:"RParen",pattern:")",label:")"}),yh=d({name:"LSquare",pattern:"[",label:"["}),Ah=d({name:"RSquare",pattern:"]",label:"]"}),xh=d({name:"Pipe",pattern:"|",label:"|"}),bh=d({name:"Slash",pattern:"/",label:"/"}),Ih=d({name:"Hat",pattern:"^",label:"^"}),Eh=d({name:"Question",pattern:"?",label:"?"}),Lh=d({name:"Star",pattern:"*",label:"*"}),_h=d({name:"OpPlus",pattern:"+",label:"+"}),Oh=d({name:"OpMinus",pattern:"-",label:"-"}),Sh=d({name:"Exclamation",pattern:"!",label:"!"}),Nh=d({name:"LogicAnd",pattern:"&&",label:"&&"}),Ph=d({name:"LogicOr",pattern:"||",label:"||"}),kh=d({name:"Equal",pattern:"=",label:"="}),wh=d({name:"NotEqual",pattern:"!=",label:"!="}),Rh=d({name:"LessThan",pattern:"<",label:"<"}),Fh=d({name:"GreaterThan",pattern:">",label:">"}),Ch=d({name:"LessThanEqual",pattern:"<=",label:"<="}),Mh=d({name:"GreaterThanEqual",pattern:">=",label:">="}),Dh=d({name:"Hathat",pattern:"^^",label:"^^"}),so=Ie.create().add(Nh,Ph,wh,Ch,Mh,hh,fh,dh,mh,gh,Th,vh,yh,Ah,xh,bh,Dh,Ih,Eh,Lh,_h,Oh,Sh,kh,Rh,Fh);var R={};Mt(R,{allTerminals:()=>oo,anon:()=>of,blankNodeLabel:()=>Vh,comment:()=>sf,decimal:()=>zh,decimalNegative:()=>Zh,decimalPositive:()=>Xh,double:()=>Yh,doubleNegative:()=>Jh,doublePositive:()=>Qh,integer:()=>Wh,integerNegative:()=>Bh,integerPositive:()=>qh,iriRef:()=>Gh,langTag:()=>Hh,nil:()=>af,pNameLn:()=>ao,pNameNs:()=>$h,stringLiteral1:()=>Uh,stringLiteral2:()=>ef,stringLiteralLong1:()=>tf,stringLiteralLong2:()=>rf,var1:()=>jh,var2:()=>Kh,ws:()=>nf});var Gh=d({name:"IriRef",pattern:Va}),ao=d({name:"PNameLn",pattern:ja}),$h=d({name:"PNameNs",pattern:yi,longer_alt:[ao]}),Vh=d({name:"BlankNodeLabel",pattern:Ka}),jh=d({name:"Var1",pattern:Ha}),Kh=d({name:"Var2",pattern:Wa}),Hh=d({name:"LangTag",pattern:za}),Wh=d({name:"Integer",pattern:tn}),zh=d({name:"Decimal",pattern:rn}),Yh=d({name:"Double",pattern:nn}),qh=d({name:"IntegerPositive",pattern:Ya}),Xh=d({name:"DecimalPositive",pattern:qa}),Qh=d({name:"DoublePositive",pattern:Xa}),Bh=d({name:"IntegerNegative",pattern:Qa}),Zh=d({name:"DecimalNegative",pattern:Ba}),Jh=d({name:"DoubleNegative",pattern:Za}),Uh=d({name:"StringLiteral1",pattern:Ja}),ef=d({name:"StringLiteral2",pattern:Ua}),tf=d({name:"StringLiteralLong1",pattern:eo}),rf=d({name:"StringLiteralLong2",pattern:to}),nf=d({name:"Ws",pattern:gr,group:me.SKIPPED}),sf=d({name:"Comment",pattern:xi,group:me.SKIPPED}),af=d({name:"Nil",pattern:ro}),of=d({name:"Anon",pattern:no}),oo=Ie.create().add(Gh,$h,ao,Vh,jh,Kh,Hh,Yh,zh,Wh,Qh,Xh,qh,Jh,Zh,Bh,tf,rf,Uh,ef,nf,sf,af,of);var bi=d({name:"BaseDecl",pattern:/base/i,label:"BASE"}),Ii=d({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),Ei=d({name:"Select",pattern:/select/i,label:"SELECT"}),et=d({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),Li=d({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),kt=d({name:"As",pattern:/as/i,label:"AS"}),_i=d({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),Oi=d({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),Si=d({name:"Ask",pattern:/ask/i,label:"ASK"}),Ni=d({name:"From",pattern:/from/i,label:"FROM"}),wt=d({name:"Where",pattern:/where/i,label:"WHERE"}),on=d({name:"GroupByGroup",pattern:/group/i,label:"_GROUP_ BY"}),ln=d({name:"By",pattern:/by/i,label:"BY"}),Pi=d({name:"Having",pattern:/having/i,label:"HAVING"}),ki=d({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),wi=d({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Ri=d({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),Fi=d({name:"Limit",pattern:/limit/i,label:"LIMIT"}),Ci=d({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Mi=d({name:"Values",pattern:/values/i,label:"VALUES"}),Di=d({name:"Load",pattern:/load/i,label:"LOAD"}),yt=d({name:"Silent",pattern:/silent/i,label:"SILENT"}),Gi=d({name:"LoadInto",pattern:/into/i,label:"INTO"}),$i=d({name:"Clear",pattern:/clear/i,label:"CLEAR"}),Vi=d({name:"Drop",pattern:/drop/i,label:"DROP"}),ji=d({name:"Create",pattern:/create/i,label:"CREATE"}),Ki=d({name:"Add",pattern:/add/i,label:"ADD"}),Hi=d({name:"To",pattern:/to/i,label:"TO"}),Wi=d({name:"Move",pattern:/move/i,label:"MOVE"}),zi=d({name:"Copy",pattern:/copy/i,label:"COPY"}),Yi=d({name:"ModifyWith",pattern:/with/i,label:"WITH"}),qi=d({name:"DeleteDataClause",pattern:new RegExp(`delete(${an.source})data`,"i"),label:"DELETE DATA"}),Xi=d({name:"DeleteWhereClause",pattern:new RegExp(`delete(${an.source})where`,"i"),label:"DELETE WHERE"}),Qi=d({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),Bi=d({name:"InsertDataClause",pattern:new RegExp(`insert(${an.source})data`,"i"),label:"INSERT DATA"}),Zi=d({name:"InsertClause",pattern:/insert/i,label:"insert"}),Ji=d({name:"UsingClause",pattern:/using/i,label:"USING"}),Ui=d({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),es=d({name:"Service",pattern:/service/i,label:"SERVICE"}),ts=d({name:"Bind",pattern:/bind/i,label:"BIND"}),rs=d({name:"Undef",pattern:/undef/i,label:"UNDEF"}),ns=d({name:"Minus",pattern:/minus/i,label:"MINUS"}),is=d({name:"Union",pattern:/union/i,label:"UNION"}),ss=d({name:"Filter",pattern:/filter/i,label:"FILTER"}),Tr=d({name:"a",pattern:"a",label:"type declaration 'a'"}),as=d({name:"True",pattern:/true/i,label:"true"}),os=d({name:"False",pattern:/false/i,label:"false"}),ls=d({name:"In",pattern:/in/i,label:"IN"}),cs=d({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),us=d({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),lf=Ie.create().add(bi,Ii,Ei,et,Li,_i,Oi,Si,Ni,wt,Pi,on,ln,ki,wi,Ri,Fi,Ci,Mi,Di,yt,Gi,$i,Vi,ji,Ki,Hi,Wi,zi,Yi,Xi,qi,Qi,Bi,Zi,Ji,Ui,es,ts,rs,ns,is,ss,kt,Tr,as,os,ls,cs,us),gS=Ie.create(oo).merge(lf).merge(Ma).merge(Da).merge(so).moveAfter(di,Tr).moveBefore(Tr,gi).moveAfter(mi,on);var lo="contextDef";function cf(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:lo,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,lo,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,lo,"base")}}}var pt="expression";function uf(e){return class extends e{isExpressionPure(r){return this.isOfType(r,pt)}formatOperator(r){return r.toLowerCase().replaceAll(" ","")}expressionOperation(r,n,i){return{type:pt,subType:"operation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionOperator(r){return this.isOfSubType(r,pt,"operation")}expressionFunctionCall(r,n,i,s){return{type:"expression",subType:"functionCall",function:r,args:n,distinct:i,loc:s}}isExpressionFunctionCall(r){return this.isOfSubType(r,pt,"functionCall")}expressionPatternOperation(r,n,i){return{type:pt,subType:"patternOperation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionPatternOperation(r){return this.isOfSubType(r,pt,"patternOperation")}aggregate(r,n,i,s,a){let o={type:"expression",subType:"aggregate",aggregation:this.formatOperator(r),distinct:n,loc:a};return this.isOfType(i,"wildcard")?{...o,expression:[i]}:s===void 0?{...o,expression:[i]}:{...o,expression:[i],separator:s}}isExpressionAggregate(r){return this.isOfSubType(r,pt,"aggregate")}isExpressionAggregateSeparator(r){return this.isOfSubType(r,pt,"aggregate")&&typeof r.separator=="string"}isExpressionAggregateOnWildcard(r){let n=r;return this.isOfSubType(r,pt,"aggregate")&&Array.isArray(n.expression)&&n.expression.length===1&&this.isOfType(n.expression[0],"wildcard")}isExpressionAggregateDefault(r){let n=r;return this.isOfSubType(r,pt,"operation")&&Array.isArray(n.expression)&&n.expression.length===1&&!this.isOfType(n.expression[0],"wildcard")}}}var At="graphRef";function pf(e){return class extends e{isGraphRef(r){return this.isOfType(r,At)}graphRefDefault(r){return{type:At,subType:"default",loc:r}}isGraphRefDefault(r){return this.isOfSubType(r,At,"default")}graphRefNamed(r){return{type:At,subType:"named",loc:r}}isGraphRefNamed(r){return this.isOfSubType(r,At,"named")}graphRefAll(r){return{type:At,subType:"all",loc:r}}isGraphRefAll(r){return this.isOfSubType(r,At,"all")}graphRefSpecific(r,n){return{type:At,subType:"specific",graph:r,loc:n}}isGraphRefSpecific(r){return this.isOfSubType(r,At,"specific")}}}function hf(e){return new co(e)}var co=class{input;constructor(t){this.input=t}call(t){return this.input=t(this.input),this}returns(){return this.input}};var Ke="path";function ff(e){return class extends e{isPathPure(r){return this.isOfType(r,Ke)}path(r,n,i){let s={type:Ke,loc:i,items:n};if(r==="|"||r==="/")return{...s,subType:r};if((r==="?"||r==="*"||r==="+"||r==="^"&&this.isPathPure(n[0]))&&n.length===1)return{...s,subType:r,items:n};if(r==="^"&&n.length===1&&!this.isPathPure(n[0]))return{...s,subType:r,items:n};if(r==="!"&&n.length===1&&(this.isPathAlternativeLimited(n[0])||!this.isPathPure(n[0])||this.isPathNegatedElt(n[0])))return{...s,subType:r,items:n};throw new Error("Invalid path type")}isPathOfType(r,n){return this.isOfType(r,Ke)&&n.includes(r.subType)}isPathChain(r){return this.isOfSubType(r,Ke,"/")||this.isOfSubType(r,Ke,"|")}isPathModified(r){return this.isOfSubType(r,Ke,"?")||this.isOfSubType(r,Ke,"*")||this.isOfSubType(r,Ke,"+")||this.isOfSubType(r,Ke,"^")}isPathNegatedElt(r){let n=r;return this.isOfSubType(r,Ke,"^")&&Array.isArray(n.items)&&n.items.length===1&&n.items[0]!==null&&typeof n.items[0]=="object"&&!this.isPathPure(n.items[0])}isPathNegated(r){return this.isOfSubType(r,Ke,"!")}isPathAlternativeLimited(r){let n=r;return this.isOfSubType(r,Ke,"|")&&Array.isArray(n.items)&&n.items.every(i=>!this.isPathPure(i)||this.isPathNegatedElt(i))}}}var ie="pattern";function df(e){return class extends e{isPattern(r){return this.isOfType(r,ie)}patternBgp(r,n){return{type:ie,subType:"bgp",triples:r,loc:n}}isPatternBgp(r){return this.isOfSubType(r,ie,"bgp")}patternGroup(r,n){return{type:ie,subType:"group",patterns:r,loc:n}}isPatternGroup(r){return this.isOfSubType(r,ie,"group")}patternGraph(r,n,i){return{type:ie,subType:"graph",name:r,patterns:n,loc:i}}isPatternGraph(r){return this.isOfSubType(r,ie,"graph")}patternOptional(r,n){return{type:ie,subType:"optional",patterns:r,loc:n}}isPatternOptional(r){return this.isOfSubType(r,ie,"optional")}patternValues(r,n,i){return{type:ie,subType:"values",variables:r,values:n,loc:i}}isPatternValues(r){return this.isOfSubType(r,ie,"values")}patternFilter(r,n){return{type:ie,subType:"filter",expression:r,loc:n}}isPatternFilter(r){return this.isOfSubType(r,ie,"filter")}patternBind(r,n,i){return{type:ie,subType:"bind",expression:r,variable:n,loc:i}}isPatternBind(r){return this.isOfSubType(r,ie,"bind")}patternUnion(r,n){return{type:ie,subType:"union",patterns:r,loc:n}}isPatternUnion(r){return this.isOfSubType(r,ie,"union")}patternMinus(r,n){return{type:ie,subType:"minus",patterns:r,loc:n}}isPatternMinus(r){return this.isOfSubType(r,ie,"minus")}patternService(r,n,i,s){return{type:ie,subType:"service",silent:i,name:r,patterns:n,loc:s}}isPatternService(r){return this.isOfSubType(r,ie,"service")}}}var vr="query";function mf(e){return class extends e{isQuery(r){return this.isOfType(r,vr)}isQuerySelect(r){return this.isOfSubType(r,vr,"select")}queryConstruct(r,n,i,s,a,o,l){return{type:"query",subType:"construct",context:n,template:i,where:s,solutionModifiers:a,datasets:o,values:l,loc:r}}isQueryConstruct(r){return this.isOfSubType(r,vr,"construct")}isQueryDescribe(r){return this.isOfSubType(r,vr,"describe")}isQueryAsk(r){return this.isOfSubType(r,vr,"ask")}querySelect(r,n){return{type:vr,subType:"select",...r,loc:n}}}}var Rt="solutionModifier";function gf(e){return class extends e{isSolutionModifier(r){return this.isOfType(r,Rt)}solutionModifierHaving(r,n){return{type:Rt,subType:"having",having:r,loc:n}}isSolutionModifierHaving(r){return this.isOfSubType(r,Rt,"having")}solutionModifierOrder(r,n){return{type:Rt,subType:"order",orderDefs:r,loc:n}}isSolutionModifierOrder(r){return this.isOfSubType(r,Rt,"order")}solutionModifierLimitOffset(r,n,i){return{type:Rt,subType:"limitOffset",limit:r,offset:n,loc:i}}isSolutionModifierLimitOffset(r){return this.isOfSubType(r,Rt,"limitOffset")}solutionModifierGroup(r,n){return{type:"solutionModifier",subType:"group",groupings:r,loc:n}}isSolutionModifierGroup(r){return this.isOfSubType(r,Rt,"group")}}}var qt="term";function Tf(e){return class extends e{__blankNodeCounter=0;resetBlankNodeCounter(){this.__blankNodeCounter=0}isTerm(r){return this.isOfType(r,"term")}termBlank(r,n){let i={type:"term",subType:"blankNode",loc:n};return r===void 0?{...i,label:`g_${this.__blankNodeCounter++}`}:{...i,label:`e_${r}`}}isTermBlank(r){return this.isOfSubType(r,qt,"blankNode")}termLiteral(r,n,i){return{type:qt,subType:"literal",value:n,langOrIri:i,loc:r}}isTermLiteral(r){return this.isOfSubType(r,qt,"literal")}isTermLiteralLangStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri=="string"}isTermLiteralStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri>"u"}isTermLiteralTyped(r){let n=r;return this.isTermLiteral(r)&&typeof n.langOrIri=="object"&&n.langOrIri!==null&&this.isTermNamed(n.langOrIri)}termVariable(r,n){return{type:qt,subType:"variable",value:r,loc:n}}isTermVariable(r){return this.isOfSubType(r,qt,"variable")}termNamed(r,n,i){let s={type:qt,subType:"namedNode",value:n,loc:r};return i===void 0?s:{...s,prefix:i}}isTermNamed(r){return this.isOfSubType(r,qt,"namedNode")}isTermNamedPrefixed(r){let n=r;return this.isTermNamed(r)&&typeof n.prefix=="string"}}}var Fe="updateOperation";function vf(e){return class extends e{isUpdateOperation(r){return this.isOfType(r,Fe)}updateOperationLoad(r,n,i,s){return{type:Fe,subType:"load",silent:i,source:n,...s&&{destination:s},loc:r}}isUpdateOperationLoad(r){return this.isOfSubType(r,Fe,"load")}updateOperationClearDrop(r,n,i,s){return{type:"updateOperation",subType:r,silent:n,destination:i,loc:s}}updateOperationClear(r,n,i){return this.updateOperationClearDrop("clear",n,r,i)}isUpdateOperationClear(r){return this.isOfSubType(r,Fe,"clear")}updateOperationDrop(r,n,i){return this.updateOperationClearDrop("drop",n,r,i)}isUpdateOperationDrop(r){return this.isOfSubType(r,Fe,"drop")}updateOperationCreate(r,n,i){return{type:"updateOperation",subType:"create",silent:n,destination:r,loc:i}}isUpdateOperationCreate(r){return this.isOfSubType(r,Fe,"create")}updateOperationAddMoveCopy(r,n,i,s,a){return{type:"updateOperation",subType:r,silent:s,source:n,destination:i,loc:a}}updateOperationAdd(r,n,i,s){return this.updateOperationAddMoveCopy("add",r,n,i,s)}isUpdateOperationAdd(r){return this.isOfSubType(r,Fe,"add")}updateOperationMove(r,n,i,s){return this.updateOperationAddMoveCopy("move",r,n,i,s)}isUpdateOperationMove(r){return this.isOfSubType(r,Fe,"move")}updateOperationCopy(r,n,i,s){return this.updateOperationAddMoveCopy("copy",r,n,i,s)}isUpdateOperationCopy(r){return this.isOfSubType(r,Fe,"copy")}updateOperationInsDelDataWhere(r,n,i){return{type:"updateOperation",subType:r,data:n,loc:i}}updateOperationInsertData(r,n){return this.updateOperationInsDelDataWhere("insertdata",r,n)}isUpdateOperationInsertData(r){return this.isOfSubType(r,Fe,"insertdata")}updateOperationDeleteData(r,n){return this.updateOperationInsDelDataWhere("deletedata",r,n)}isUpdateOperationDeleteData(r){return this.isOfSubType(r,Fe,"deletedata")}updateOperationDeleteWhere(r,n){return this.updateOperationInsDelDataWhere("deletewhere",r,n)}isUpdateOperationDeleteWhere(r){return this.isOfSubType(r,Fe,"deletewhere")}updateOperationModify(r,n,i,s,a,o){return{type:"updateOperation",subType:"modify",insert:n??[],delete:i??[],graph:o,where:s,from:a,loc:r}}isUpdateOperationModify(r){return this.isOfSubType(r,Fe,"modify")}}}var xt=class extends hf(tr).call(cf).call(uf).call(pf).call(ff).call(df).call(mf).call(gf).call(Tf).call(vf).returns(){alwaysSparql11(t){return!0}isPath(t){return this.isPathPure(t)||this.isTermNamed(t)}isExpression(t){return this.isExpressionPure(t)||this.isTermNamed(t)||this.isTermVariable(t)||this.isTermLiteral(t)}graphNodeIdentifier(t){return t.type==="tripleCollection"?t.identifier:t}triple(t,r,n,i){return{type:"triple",subject:t,predicate:r,object:n,loc:i??this.sourceLocation(t,r,n)}}isTriple(t){return this.isOfType(t,"triple")}datasetClauses(t,r){return{type:"datasetClauses",clauses:t,loc:r}}isDatasetClauses(t){return this.isOfType(t,"datasetClauses")}wildcard(t){return{type:"wildcard",loc:t}}isWildcard(t){return this.isOfType(t,"wildcard")}isTripleCollection(t){return this.isOfType(t,"tripleCollection")}tripleCollectionBlankNodeProperties(t,r,n){return{type:"tripleCollection",subType:"blankNodeProperties",identifier:t,triples:r,loc:n}}isTripleCollectionBlankNodeProperties(t){return this.isOfSubType(t,"tripleCollection","blankNodeProperties")}tripleCollectionList(t,r,n){return{type:"tripleCollection",subType:"list",identifier:t,triples:r,loc:n}}isTripleCollectionList(t){return this.isOfSubType(t,"tripleCollection","list")}graphQuads(t,r,n){return{type:"graph",graph:t,triples:r,loc:n}}isGraphQuads(t){return super.isOfType(t,"graph")}isUpdate(t){return super.isOfType(t,"update")}};function yf(e){let t=e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(r,n,i)=>{if(n){let o=Number.parseInt(n,16);return String.fromCodePoint(o)}let s=Number.parseInt(i,16);if(s<65535)return String.fromCodePoint(s);let a=s-65536;return String.fromCodePoint(55296+(a>>10),56320+(a&1023))});if(/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(t))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint");return t}var le;(function(e){e.BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",e.INTEGER="http://www.w3.org/2001/XMLSchema#integer",e.DECIMAL="http://www.w3.org/2001/XMLSchema#decimal",e.DOUBLE="http://www.w3.org/2001/XMLSchema#double",e.STRING="http://www.w3.org/2001/XMLSchema#string",e.FIRST="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",e.REST="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",e.NIL="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",e.TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"})(le||(le={}));var cn=class extends en{constructor(t={},r={}){super(...TS(xf,t,r))}};function TS(e,t,r){if(t.ignoreKeys)return[t,r];let n={ignoreKeys:new Set(["loc"])};return[t,{...Object.fromEntries(Object.keys(e).map(i=>[i,n])),...r}]}var vS=/^[a-z][\d+.a-z-]*:/iu,yS=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su,AS=/^(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su;function ps(e){let t=e,r="",n=()=>{let i=r.lastIndexOf("/");r=r.slice(0,i>0?i:0)};for(;t.length>0;)if(t.startsWith("../"))t=t.slice(3);else if(t.startsWith("./")||t.startsWith("/./"))t=t.slice(2);else if(t==="/.")t="/";else if(t.startsWith("/../"))t=t.slice(3),n();else if(t==="/..")t="/",n();else if(t==="."||t==="..")t="";else{let i=t.indexOf("/",1),s=i===-1?t:t.slice(0,i);r+=s,t=t.slice(s.length)}return r}function uo(e,t){if(vS.test(e))return e;if(!t)throw new Error(`Cannot resolve relative IRI ${e} because no base IRI was set.`);let[,r,n,i,s]=AS.exec(e),[,a,o,l,u]=yS.exec(t),p,h,f;r===void 0?(n===""?(h=l,f=i??u):(n.startsWith("/")?h=ps(n):o!==void 0&&l===""?h=ps(`/${n}`):h=ps(l.slice(0,l.lastIndexOf("/")+1)+n),f=i),p=o):(p=r,h=ps(n),f=i);let m=a===void 0?"":`${a}:`;return p!==void 0&&(m+=`//${p}`),m+=h,f!==void 0&&(m+=`?${f}`),s!==void 0&&(m+=`#${s}`),m}var xS=new xt,bS=new RegExp(Ai.source,"gu");function Af(e,t,r){let n=e.value;if(xS.isTermNamedPrefixed(e)){let i=t[e.prefix];if(!i)throw new Error(`Unknown prefix: ${e.prefix}`);n=i+e.value.replaceAll(bS,s=>s.slice(1))}return uo(n,r)}var xf={path:{items:!0,loc:!1},pattern:{values:(e,{visitKey:t,stepIntoKey:r})=>{for(let n=e.length-1;n>=0;n--){let i=r(e,n);for(let s in i)t(i,s)}},name:!0,variable:!0,expression:!0,variables:!0,patterns:!0,triples:!0,loc:!1},update:{updates:dr("operation","context"),loc:!1},query:{values:!0,template:!0,context:!0,solutionModifiers:(e,{visitKey:t})=>{t(e,"group"),t(e,"having"),t(e,"order"),t(e,"limitOffset")},datasets:!0,where:!0,variables:!0,loc:!1},graph:{graph:!0,triples:!0,loc:!1},graphRef:{graph:!0,loc:!1},updateOperation:{data:!0,source:!0,destination:!0,from:!0,graph:!0,where:!0,delete:!0,insert:!0,loc:!1},datasetClauses:{clauses:dr("value"),loc:!1},tripleCollection:{triples:!0,identifier:!0,loc:!1},triple:{object:!0,subject:!0,predicate:!0,loc:!1},solutionModifier:{having:!0,orderDefs:dr("expression"),groupings:dr("variable","value"),loc:!1},expression:{function:!0,args:!0,expression:!0,loc:!1},contextDef:{value:!0,loc:!1},wildcard:{loc:!1},term:{langOrIri:!0,loc:!1}},Ok=Ca(xf);var IS={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function un(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>IS[r])}"`}var Ft={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>{let a=t(ds);return n(()=>i([{ALT:()=>{let o=r(R.langTag);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o.image.slice(1).toLowerCase()))}},{ALT:()=>{r(T.hathat);let o=t(G);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o))}}]))??a},gImpl:({SUBRULE:e,PRINT:t,PRINT_WORD:r})=>(n,{astFactory:i})=>{!n.langOrIri||typeof n.langOrIri=="string"?(i.printFilter(n,()=>{r(""),t(un(n.value))}),typeof n.langOrIri=="string"&&i.printFilter(n,()=>t("@",n.langOrIri))):i.isSourceLocationNoMaterialize(n.langOrIri.loc)?i.printFilter(n,()=>{r(n.value)}):(i.printFilter(n,()=>{r(""),t(un(n.value),"^^")}),e(G,n.langOrIri))}},Xt={name:"numericLiteral",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(bf)},{ALT:()=>e(hs)},{ALT:()=>e(fs)}])},bf={name:"numericLiteralUnsigned",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integer),le.INTEGER]},{ALT:()=>[t(R.decimal),le.DECIMAL]},{ALT:()=>[t(R.double),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},hs={name:"numericLiteralPositive",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integerPositive),le.INTEGER]},{ALT:()=>[t(R.decimalPositive),le.DECIMAL]},{ALT:()=>[t(R.doublePositive),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},fs={name:"numericLiteralNegative",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(R.integerNegative),le.INTEGER]},{ALT:()=>[t(R.decimalNegative),le.DECIMAL]},{ALT:()=>[t(R.doubleNegative),le.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Qt={name:"booleanLiteral",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(as)},{ALT:()=>t(os)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),le.BOOLEAN)))}},ds={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(R.stringLiteral1);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(R.stringLiteral2);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(R.stringLiteralLong1);return[s,s.image.slice(3,-3)]}},{ALT:()=>{let s=t(R.stringLiteralLong2);return[s,s.image.slice(3,-3)]}}]);return e(()=>{let s=n.astFactory,a=i[1].replaceAll(/\\([tnrbf"'\\])/gu,(o,l)=>{switch(l){case"t":return" ";case"n":return` -`;case"r":return"\r";case"b":return"\b";case"f":return"\f";default:return l}});return s.termLiteral(s.sourceLocation(i[0]),a)})}},G={name:"iri",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(yr)},{ALT:()=>e(po)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(po,t):e(yr,t)},yr={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(R.iriRef);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),n.image.slice(1,-1)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("<",t.value,">"))}},po={name:"prefixedName",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{function i(s){if(!n.skipValidation&&n.prefixes[s]===void 0)throw new Error(`Unknown prefix: ${s}`)}return r([{ALT:()=>{let s=t(R.pNameLn);return e(()=>{let a=s.image.indexOf(":"),o=s.image.slice(0,a),l=s.image.slice(a+1);return i(o),n.astFactory.termNamed(n.astFactory.sourceLocation(s),l,o)})}},{ALT:()=>{let s=t(R.pNameNs);return e(()=>{let a=s.image.slice(0,-1);return i(a),n.astFactory.termNamed(n.astFactory.sourceLocation(s),"",a)})}}])},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(t.prefix,":",t.value))}},ES=Symbol("canCreateBlankNodes"),ms={name:"blankNode",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(R.blankNodeLabel);return e(()=>n.astFactory.termBlank(s.image.slice(2),n.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=t(R.anon);return e(()=>n.astFactory.termBlank(void 0,n.astFactory.sourceLocation(s)))}}]);return e(()=>{if(!n.parseMode.has("canCreateBlankNodes"))throw new Error("Blank nodes are not allowed in this context")}),i},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("_:",t.label.replace(/^e_/u,"")))}},Bt={name:"VerbA",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Tr);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),le.TYPE,void 0))}};var He={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(ho))},{ALT:()=>n.push(e(fo))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(ho,n):e(fo,n)}},ho={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(bi),s=r(yr);return e(()=>{try{n.baseIRI=uo(s.value,n.baseIRI)}catch{}return n.astFactory.contextDefinitionBase(n.astFactory.sourceLocation(i,s),s)})},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BASE ")),e(G,n.value),i.printFilter(n,()=>r())}},fo={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Ii),s=t(R.pNameNs).image.slice(0,-1),a=r(yr);return e(()=>(n.prefixes[s]=a.value,n.astFactory.contextDefinitionPrefix(n.astFactory.sourceLocation(i,a),s,a)))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("PREFIX ",`${n.key}: `)}),e(G,n.value),i.printFilter(n,()=>r())}},go={name:"verb",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(bt)},{ALT:()=>e(Bt)}])},ge={name:"varOrTerm",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(Q)},{ALT:()=>e(mo)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(Q,t):e(mo,t)},bt={name:"varOrIri",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(Q)},{ALT:()=>e(G)}])},Q={name:"var",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(R.var1)},{ALT:()=>t(R.var2)}]);return e(()=>n.astFactory.termVariable(i.image.slice(1),n.astFactory.sourceLocation(i)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(`?${t.value}`))}},mo={name:"graphTerm",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(G)},{ALT:()=>t(Ft)},{ALT:()=>t(Xt)},{ALT:()=>t(Qt)},{GATE:()=>i.parseMode.has("canCreateBlankNodes"),ALT:()=>t(ms)},{ALT:()=>{let s=r(R.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(s),le.NIL))}}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(G,t):r.isTermLiteral(t)?e(Ft,t):e(ms,t)}};function To(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i,OR:s})=>a=>{let o=i(t);return s([{ALT:()=>{let l=n(Ef);return r(()=>a.astFactory.wrap({clauseType:"default",value:l},a.astFactory.sourceLocation(o,l)))}},{ALT:()=>{let l=n(_f);return r(()=>a.astFactory.wrap({clauseType:"named",value:l.val},a.astFactory.sourceLocation(o,l)))}}])}}}var If=To("datasetClause",Ni),Ef={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(yo)},Lf=To("usingClause",Ji);function vo(e,t,r){return{name:e,impl:({ACTION:n,MANY:i,SUBRULE:s})=>a=>{let o=[];return i(()=>{let l=s(t);o.push(l)}),n(()=>a.astFactory.datasetClauses(o.map(l=>l.val),a.astFactory.sourceLocation(...o)))},gImpl:({SUBRULE:n,PRINT_WORD:i})=>(s,{astFactory:a})=>{for(let o of s.clauses)a.printFilter(s,()=>i(r)),o.clauseType==="named"&&a.printFilter(s,()=>i("NAMED")),n(G,o.value)}}}var tt=vo("datasetClauses",If,"FROM"),gs=vo("usingClauses",Lf,"USING"),_f={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.named),s=t(yo);return e(()=>n.astFactory.wrap(s,n.astFactory.sourceLocation(i,s)))}},yo={name:"sourceSelector",impl:({SUBRULE:e})=>()=>e(G)};function D(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(T.LParen);let a=r(k),o=n(T.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function rt(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>{let a=r(e);r(T.LParen);let o=n(k);r(T.comma);let l=i(k),u=r(T.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o,l],s.astFactory.sourceLocation(a,u)))}}}function Ao(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,CONSUME1:n,CONSUME2:i,SUBRULE1:s,SUBRULE2:a,SUBRULE3:o})=>l=>{let u=r(e);r(T.LParen);let p=s(k);n(T.comma);let h=a(k);i(T.comma);let f=o(k),m=r(T.RParen);return t(()=>l.astFactory.expressionOperation(u.image,[p,h,f],l.astFactory.sourceLocation(u,m)))}}}function xo(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(T.LParen);let a=r(Q),o=n(T.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function bo(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,OR:n,SUBRULE:i})=>s=>{let a=r(e);return n([{ALT:()=>{r(T.LParen);let o=i(k),l=r(T.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o],s.astFactory.sourceLocation(a,l)))}},{ALT:()=>{let o=r(R.nil);return t(()=>s.astFactory.expressionOperation(a.image,[],s.astFactory.sourceLocation(a,o)))}}])}}}function Ar(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r})=>n=>{let i=r(e),s=r(R.nil);return t(()=>n.astFactory.expressionOperation(i.image,[],n.astFactory.sourceLocation(i,s)))}}}function Ts(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let s=r(e),a=n(As);return t(()=>i.astFactory.expressionOperation(s.image,a.val,i.astFactory.sourceLocation(s,a)))}}}function vs(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,CONSUME1:a,OPTION:o,CONSUME2:l})=>u=>{let p=r(e);r(T.LParen);let h=n(k);a(T.comma);let f=i(k),m=o(()=>(l(T.comma),s(k))),v=r(T.RParen);return t(()=>u.astFactory.expressionOperation(p.image,m?[h,f,m]:[h,f],u.astFactory.sourceLocation(p,v)))}}}function Io(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,SUBRULE4:a,CONSUME1:o,OPTION:l,CONSUME2:u,CONSUME3:p})=>h=>{let f=r(e);r(T.LParen);let m=n(k);o(T.comma);let v=i(k);u(T.comma);let x=s(k),A=l(()=>(p(T.comma),a(k))),y=r(T.RParen);return t(()=>h.astFactory.expressionOperation(f.image,A?[m,v,x,A]:[m,v,x],h.astFactory.sourceLocation(f,y)))}}}function ys(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e),a=r(B);return t(()=>i.astFactory.expressionPatternOperation(s.image,a,i.astFactory.sourceLocation(s,a)))}}}function Zt(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n,OPTION:i})=>s=>{let a=r(e);r(T.LParen);let o=i(()=>r(et)),l=n(k),u=r(T.RParen);return t(()=>s.astFactory.aggregate(a.image,o!==void 0,l,void 0,s.astFactory.sourceLocation(a,u)))}}}var K=new xt,Eo=new cn,Of=new cn({ignoreKeys:new Set(["loc","langOrIri","function"])}),Sf={preVisitor:()=>({continue:!1})},Nf={patternOperation:Sf},Pf=()=>!0,LS=()=>!1;function kf(e,t,r=Of){let n=[],i=s=>(n.push(s),{continue:!1});return r.visitNodeSpecific(e,{},{expression:{...Nf,aggregate:{preVisitor:i},functionCall:{preVisitor:s=>t(s)?i(s):{}}}}),n}function wf(e){return e?.groupings.flatMap(t=>"variable"in t?[t.variable]:K.isTermVariable(t)?[t]:[])??[]}function _S(e){return[...wf(e.solutionModifiers.group),...e.values?.variables??[]]}function OS(e,t,r=Pf,n=Of){n.visitNodeSpecific(e,{},{expression:{...Nf,aggregate:Sf,functionCall:{preVisitor:i=>({continue:!r(i)})}},term:{variable:{visitor:i=>{t.add(i.value)}}}})}function xs(e){let{prefixes:t=Object.create(null),baseIRI:r,namedAggregatorCallback:n}=e;if(n!==void 0)return i=>{let s;try{s=Af(i.function,t,r)}catch{return!1}return n(s)}}function Rf(e,t={}){let r=xs(t),n=Cf(e,r??LS,t.astTransformer);if(e.variables.length===1&&K.isWildcard(e.variables[0])){if(e.solutionModifiers.group!==void 0)throw new Error("GROUP BY not allowed with wildcard");if(n)throw new Error("Aggregates not allowed with wildcard");return}let i=e.variables;if(n){let s=new Set,a=new Set(_S(e).map(o=>o.value));for(let o of i)if(K.isTerm(o)){if(!a.has(o.value))throw new Error("Variable not allowed in projection")}else{let l=new Set;OS(o.expression,l,r,t.astTransformer);for(let u of l)if(s.has(u)){if(t.rejectGroupedSelectAliasReuse)throw new Error(`Use of variable bound by an earlier select expression (?${u}) in a grouped query`)}else if(!a.has(u))throw new Error(`Use of ungrouped variable in projection of operation (?${u})`);s.add(o.variable.value)}}}function Lo(e,t={}){SS(e,t),Rf(e,t)}function Ff(e,t={}){Rf({variables:e.variables.filter(r=>K.isTermVariable(r)),solutionModifiers:e.solutionModifiers,values:e.values},t)}function SS(e,t){let r=e.variables.filter(n=>!K.isTerm(n)&&!K.isWildcard(n));if(r.length>0){let n=new Set;Cf(e,xs(t)??Pf,t.astTransformer)||Oo(e.where,n);for(let i of wf(e.solutionModifiers.group))n.add(i.value);for(let{variable:i}of r)if(n.has(i.value))throw new Error(`Target id of 'AS' (?${i.value}) is already in scope`)}PS(e,t.astTransformer),kS(e)}function Cf(e,t,r){return e.solutionModifiers.group?!0:NS(e).some(n=>kf(n,t,r).length>0)}function NS(e){let{having:t,order:r}=e.solutionModifiers;return[...e.variables.flatMap(n=>"expression"in n?[n.expression]:[]),...t?.having??[],...r?.orderDefs.map(n=>n.expression)??[]]}function _o(e){if(!e.has("canParseAggregate"))throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");if(e.has("inAggregate"))throw new Error("An aggregate function is not allowed within an aggregate function.")}function Mf(e,t,r,n){if(!t(e)){if(e.distinct)throw new Error("DISTINCT is only allowed in a function call of a custom aggregate");return}if(_o(r),e.args.some(i=>kf(i,t,n).length>0))throw new Error("An aggregate function is not allowed within an aggregate function.")}function PS(e,t=Eo){let r=new Set;for(let n of e.variables)if("expression"in n){if(r.has(n.variable.value))throw new Error(`Target id of 'AS' (?${n.variable.value}) is used in an earlier select expression`);t.visitNodeSpecific(n.expression,{},{term:{variable:{visitor:i=>{r.add(i.value)}}}})}}function kS(e){let t=new Set(e.values?.variables.map(r=>r.value));for(let r of e.variables)if("variable"in r&&t.has(r.variable.value))throw new Error(`Target id of 'AS' (?${r.variable.value}) is already in scope`)}function Oo(e,t){function r(n){Oo(n,t)}if(e!==void 0)if(Array.isArray(e))for(let n of e)r(n);else if(K.isQuery(e))K.isQuerySelect(e)||K.isQueryDescribe(e)?r(e.variables.some(n=>K.isWildcard(n))?[e.where,e.solutionModifiers.group,e.values]:e.variables):r(e.solutionModifiers.group);else if(K.isTriple(e))r([e.subject,e.predicate,e.object]);else if(K.isPathPure(e))r(e.items);else if(K.isTripleCollection(e))r([e.identifier,...e.triples]);else if(K.isSolutionModifierGroup(e))r(e.groupings.filter(n=>"variable"in n).map(n=>n.variable));else if(K.isSolutionModifierHaving(e))r(e.having);else if(K.isSolutionModifierOrder(e))r(e.orderDefs.map(n=>n.expression));else if(K.isPatternValues(e))for(let n of e.variables)t.add(n.value);else K.isPatternBgp(e)?r(e.triples):K.isPatternGroup(e)||K.isPatternUnion(e)||K.isPatternOptional(e)?r(e.patterns):K.isPatternService(e)||K.isPatternGraph(e)?r([e.name,...e.patterns]):K.isPatternBind(e)?r(e.variable):K.isTermVariable(e)&&t.add(e.value)}function Df(e){if(!e.some(r=>K.isPatternBind(r)))return;let t=new Set;for(let r of e){if(K.isPatternBind(r)&&t.has(r.variable.value))throw new Error(`Variable used to bind is already bound (?${r.variable.value})`);Oo(r,t)}}function Gf(e,t=Eo){let r=new Set;for(let n of e.updates){if(!n.operation)continue;let i=n.operation;if(i.subType==="insertdata"){let s=new Set;t.visitNodeSpecific(i,{},{term:{blankNode:{visitor:a=>{if(s.add(a.label),r.has(a.label))throw new Error("Detected reuse blank node across different INSERT DATA clauses")}}}});for(let a of s)r.add(a)}}}function $f(e,t=Eo){let r=new Map,n=[{}],i=()=>n.at(-1);function s(o){let l=new Set;return t.visitNodeSpecific(o,{},{term:{blankNode:{visitor:u=>{l.add(u.label)}}}}),l}let a={preVisitor:()=>(n.push({}),{}),visitor:()=>{n.pop(),n[n.length-1]={}}};t.visitNodeSpecific(e,{query:{preVisitor:()=>({continue:!1})},pattern:a},{pattern:{bgp:{preVisitor:o=>{let l=i();for(let u of s(o)){let p=r.get(u);if(p!==void 0&&p!==l)throw new Error(`Detected reuse of blank node across two different basic graph patterns (_:${u.replace(/^[eg]_/u,"")})`);r.set(u,l)}return{continue:!1}},visitor:()=>{}},filter:{preVisitor:()=>(n.push({}),{}),visitor:()=>{n.pop()}}}})}var Vf=D(E.str),jf=D(E.lang),Kf=rt(E.langmatches),Hf=D(E.datatype),Wf=xo(E.bound),zf=D(E.iri),Yf=D(E.uri),qf=bo(E.bnode),Xf=Ar(E.rand),Qf=D(E.abs),Bf=D(E.ceil),Zf=D(E.floor),Jf=D(E.round),Uf=Ts(E.concat),ed=D(E.strlen),td=D(E.ucase),rd=D(E.lcase),nd=D(E.encode_for_uri),id=rt(E.contains),sd=rt(E.strstarts),ad=rt(E.strends),od=rt(E.strbefore),ld=rt(E.strafter),cd=D(E.year),ud=D(E.month),pd=D(E.day),hd=D(E.hours),fd=D(E.minutes),dd=D(E.seconds),md=D(E.timezone),gd=D(E.tz),Td=Ar(E.now),vd=Ar(E.uuid),yd=Ar(E.struuid),Ad=D(E.md5),xd=D(E.sha1),bd=D(E.sha256),Id=D(E.sha384),Ed=D(E.sha512),Ld=Ts(E.coalesce),_d=Ao(E.if_),Od=rt(E.strlang),Sd=rt(E.strdt),Nd=rt(E.sameterm),Pd=D(E.isiri),kd=D(E.isuri),wd=D(E.isblank),Rd=D(E.isliteral),Fd=D(E.isnumeric);function Cd(e){return[{ALT:()=>e(bs)},{ALT:()=>e(Vf)},{ALT:()=>e(jf)},{ALT:()=>e(Kf)},{ALT:()=>e(Hf)},{ALT:()=>e(Wf)},{ALT:()=>e(zf)},{ALT:()=>e(Yf)},{ALT:()=>e(qf)},{ALT:()=>e(Xf)},{ALT:()=>e(Qf)},{ALT:()=>e(Bf)},{ALT:()=>e(Zf)},{ALT:()=>e(Jf)},{ALT:()=>e(Uf)},{ALT:()=>e(Dd)},{ALT:()=>e(ed)},{ALT:()=>e(Gd)},{ALT:()=>e(td)},{ALT:()=>e(rd)},{ALT:()=>e(nd)},{ALT:()=>e(id)},{ALT:()=>e(sd)},{ALT:()=>e(ad)},{ALT:()=>e(od)},{ALT:()=>e(ld)},{ALT:()=>e(cd)},{ALT:()=>e(ud)},{ALT:()=>e(pd)},{ALT:()=>e(hd)},{ALT:()=>e(fd)},{ALT:()=>e(dd)},{ALT:()=>e(md)},{ALT:()=>e(gd)},{ALT:()=>e(Td)},{ALT:()=>e(vd)},{ALT:()=>e(yd)},{ALT:()=>e(Ad)},{ALT:()=>e(xd)},{ALT:()=>e(bd)},{ALT:()=>e(Id)},{ALT:()=>e(Ed)},{ALT:()=>e(Ld)},{ALT:()=>e(_d)},{ALT:()=>e(Od)},{ALT:()=>e(Sd)},{ALT:()=>e(Nd)},{ALT:()=>e(Pd)},{ALT:()=>e(kd)},{ALT:()=>e(wd)},{ALT:()=>e(Rd)},{ALT:()=>e(Fd)},{ALT:()=>e(Md)},{ALT:()=>e($d)},{ALT:()=>e(Vd)}]}var It={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(It);if(n)return e(n);let i=Cd(t);return r.set(It,i),e(i)}},Md=vs(E.regex),Dd=vs(E.substr),Gd=Io(E.replace),$d=ys(E.exists),Vd=ys(E.notexists),jd={name:ae(E.count.name),impl:({ACTION:e,CONSUME:t,SUBRULE:r,OR:n,OPTION:i})=>s=>{let a=t(E.count);t(T.LParen);let o=i(()=>t(et)),l=n([{ALT:()=>{let p=t(T.star);return e(()=>s.astFactory.wildcard(s.astFactory.sourceLocation(p)))}},{ALT:()=>r(k)}]),u=t(T.RParen);return e(()=>{let p=s.astFactory;return s.astFactory.isWildcard(l),p.aggregate(a.image,!!o,l,void 0,s.astFactory.sourceLocation(a,u))})}},Kd=Zt(E.sum),Hd=Zt(E.min),Wd=Zt(E.max),zd=Zt(E.avg),Yd=Zt(E.sample),qd={name:ae(E.groupConcat.name),impl:({ACTION:e,CONSUME:t,OPTION1:r,SUBRULE:n,OPTION2:i})=>s=>{let a=t(E.groupConcat);t(T.LParen);let o=r(()=>t(et)),l=n(k),u=i(()=>(t(T.semi),t(us),t(T.equal),n(ds))),p=t(T.RParen);return e(()=>{let h=s.astFactory;return h.aggregate(a.image,!!o,l,u?.value??" ",h.sourceLocation(a,p))})}},bs={name:"aggregate",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=e(()=>n.parseMode.has("inAggregate"));e(()=>n.parseMode.add("inAggregate"));let s=r([{ALT:()=>t(jd)},{ALT:()=>t(Kd)},{ALT:()=>t(Hd)},{ALT:()=>t(Wd)},{ALT:()=>t(zd)},{ALT:()=>t(Yd)},{ALT:()=>t(qd)}]);return e(()=>!i&&n.parseMode.delete("inAggregate")),e(()=>_o(n.parseMode)),s},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(r.aggregation.toUpperCase(),"("),r.distinct&&t("DISTINCT")});let i=r.expression[0];n.isWildcard(i)?n.printFilter(r,()=>t("*")):e(k,i),n.isExpressionAggregateSeparator(r)&&n.printFilter(r,()=>t(";","SEPARATOR","=",un(r.separator))),n.printFilter(r,()=>t(")"))}};var Xd={name:"validateSelectQuery",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Lo(r,t))}},So={name:"validateSubSelect",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Lo(r,t))}},Qd={name:"validateDescribeQuery",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Ff(r,t))}},pn={name:"validateQuery",impl:({OPTION1:e,OPTION2:t,SUBRULE:r})=>(n,i)=>{e({GATE:()=>n.astFactory.isQuerySelect(i),DEF:()=>r(Xd,i)}),t({GATE:()=>n.astFactory.isQueryDescribe(i),DEF:()=>r(Qd,i)})}},hn={name:"validateUpdate",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Gf(r,t.astTransformer))}},No={name:"validateGroupGraphPattern",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&$f(r,t.astTransformer))}},Po={name:"validateGroupGraphPatternSub",impl:({ACTION:e})=>(t,r)=>{e(()=>!t.skipValidation&&Df(r))}},fn={name:"validateFunctionCall",impl:({ACTION:e})=>(t,r)=>{e(()=>{let n=t.skipValidation?void 0:xs(t);n&&Mf(r,n,t.parseMode,t.astTransformer)})}};var Es={name:"path",impl:({SUBRULE:e})=>()=>e(Jd)},Et={name:"path",gImpl:({PRINT:e,SUBRULE:t})=>(r,{astFactory:n},i=!0)=>{if(n.isTerm(r)&&n.isTermNamed(r))t(G,r);else{switch(n.printFilter(r,()=>i&&e("(")),r.subType){case"|":case"/":{let[s,...a]=r.items;t(Et,s,i);for(let o of a)n.printFilter(r,()=>e(r.subType)),t(Et,o,i);break}case"^":n.printFilter(r,()=>e("^")),t(Et,r.items[0],i);break;case"?":case"*":case"+":t(Et,r.items[0],i),n.printFilter(r,()=>e(r.subType));break;case"!":n.printFilter(r,()=>e("!")),n.printFilter(r,()=>e("(")),t(Et,r.items[0],!1),n.printFilter(r,()=>e(")"));break}n.printFilter(r,()=>i&&e(")"))}}};function wo(e,t,r,n){return{name:e,impl:({ACTION:i,CONSUME:s,SUBRULE1:a,SUBRULE2:o,MANY:l})=>u=>{let p=a(n),h=p,f=[];return l(()=>{s(t),h=o(n),f.push(h)}),i(()=>f.length===0?p:u.astFactory.path(r,[p,...f],u.astFactory.sourceLocation(p,h)))}}}var Bd={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>s=>i([{ALT:()=>r(ko)},{ALT:()=>{let a=t(T.hat),o=n(ko);return e(()=>s.astFactory.path("^",[o],s.astFactory.sourceLocation(a,o)))}}])},Zd=wo("pathSequence",T.slash,"/",Bd),Jd=wo("pathAlternative",T.pipe,"|",Zd),ko={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(em),s=r(()=>t(Ud));return e(()=>s===void 0?i:n.astFactory.path(s.image,[i],n.astFactory.sourceLocation(i,s)))}},Ud={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(T.question)},{ALT:()=>e(T.star)},{ALT:()=>e(T.opPlus)}])},em={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(G)},{ALT:()=>e(Bt)},{ALT:()=>e(tm)},{ALT:()=>{t(T.LParen);let n=e(Es);return t(T.RParen),n}}])},tm={name:"pathNegatedPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,SUBRULE3:i,OR:s,MANY:a})=>o=>{let l=t(T.exclamation);return s([{ALT:()=>{let u=r(Is);return e(()=>o.astFactory.path("!",[u],o.astFactory.sourceLocation(l,u)))}},{ALT:()=>{let u=t(T.LParen),p=n(Is),h=[];a(()=>{t(T.pipe);let m=i(Is);h.push(m)});let f=t(T.RParen);return e(()=>{let m=o.astFactory;return h.length===0?m.path("!",[p],m.sourceLocation(l,f)):m.path("!",[m.path("|",[p,...h],m.sourceLocation(u,f))],m.sourceLocation(l,f))})}}])}},Is={name:"pathOneInPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(G)},{ALT:()=>r(Bt)},{ALT:()=>{let o=t(T.hat),l=s([{ALT:()=>n(G)},{ALT:()=>n(Bt)}]);return e(()=>a.astFactory.path("^",[l],a.astFactory.sourceLocation(o,l)))}}])};function rm(e){return({ACTION:t,AT_LEAST_ONE:r,SUBRULE:n,CONSUME:i,OPTION:s})=>a=>{let o=[],l=!0,u;return r({GATE:()=>l,DEF:()=>{l=!1;let p=n(e);t(()=>{o.push(...p)}),s(()=>{u=i(T.dot),l=!0})}}),t(()=>a.astFactory.patternBgp(o,a.astFactory.sourceLocation(...o,u)))}}var ft={name:"triplesBlock",impl:e=>t=>rm(sm)(e)(t),gImpl:({SUBRULE:e,PRINT_WORD:t,HANDLE_LOC:r,NEW_LINE:n})=>(i,{astFactory:s})=>{for(let[a,o]of i.triples.entries())r(o,()=>{let l=i.triples.at(a+1);s.isTripleCollection(o)?(e(ht,o),s.printFilter(o,()=>{t("."),n()})):(e(ht,o.subject),s.printFilter(o,()=>t("")),s.isTerm(o.predicate)&&s.isTermVariable(o.predicate)?e(ge,o.predicate):e(Et,o.predicate,void 0),s.printFilter(o,()=>t("")),e(ht,o.object),l===void 0||s.isTripleCollection(l)||!s.isSourceLocationNoMaterialize(l.subject.loc)?s.printFilter(i,()=>{t("."),n()}):s.isSourceLocationNoMaterialize(l.predicate.loc)?s.printFilter(i,()=>t(",")):s.printFilter(i,()=>{t(";"),n()}))})}};function nm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>s=>i([{ALT:()=>{let a=n(ge),o=n(t?_s:Ls,r(()=>s.astFactory.dematerialized(a)));return r(()=>(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}},{ALT:()=>{let a=n(t?Mo:Co),o=n(t?lm:om,r(()=>s.astFactory.graphNodeIdentifier(a)));return r(()=>o.length===0?[a]:(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}}])}}var im=nm("triplesSameSubject",!1),sm=nm("triplesSameSubjectPath",!0),Jt={name:"triplesTemplate",impl:rm(im)};function am(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,s)=>n(()=>r(t?_s:Ls,s))??[]}}var om=am("propertyList",!1),lm=am("propertyListPath",!0);function cm(e,t){return{name:e,impl:({ACTION:r,CONSUME:n,AT_LEAST_ONE:i,SUBRULE1:s,MANY2:a,OR1:o})=>(l,u)=>{let p=[],h=!0;return i({GATE:()=>h,DEF:()=>{h=!1;let f=t?o([{ALT:()=>s(um)},{ALT:()=>s(pm)}]):s(go),m=s(t?dm:fm,u,f);a(()=>{n(T.semi),h=!0}),r(()=>{p.push(...m)})}}),p}}}var Ls=cm("propertyListNotEmpty",!1),_s=cm("propertyListPathNotEmpty",!0),um={name:"verbPath",impl:({SUBRULE:e})=>()=>e(Es)},pm={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(Q)};function hm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,AT_LEAST_ONE_SEP:i})=>(s,a,o)=>{let l=[];return i({SEP:T.comma,DEF:()=>{let u=n(t?Tm:gm,a,o);r(()=>{l.push(u)})}}),l}}}var fm=hm("objectList",!1),dm=hm("objectListPath",!0);function mm(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,s,a)=>{let o=n(t?ht:Do);return r(()=>i.astFactory.triple(s,a,o))}}}var gm=mm("object",!1),Tm=mm("objectPath",!0);function vm(e,t){return{name:e,impl:({ACTION:r,AT_LEAST_ONE:n,SUBRULE:i,CONSUME:s})=>a=>{let o=[],l=s(T.LParen);n(()=>{o.push(i(t?ht:Do))});let u=s(T.RParen);return r(()=>{let p=a.astFactory,h=[],f=p.termNamed(p.sourceLocation(),le.FIRST,void 0),m=p.termNamed(p.sourceLocation(),le.REST,void 0),v=p.termNamed(p.sourceLocation(),le.NIL,void 0),x=p.termBlank(void 0,p.sourceLocation()),A=x;for(let[y,b]of o.entries()){let g=y===o.length-1,I=p.triple(A,f,b);if(h.push(I),g){let w=p.triple(A,m,v);h.push(w)}else{let w=p.termBlank(void 0,p.sourceLocation()),C=p.triple(A,m,w);h.push(C),A=w}}return p.tripleCollectionList(x,h,p.sourceLocation(l,u))})},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>n("("));for(let[a,o]of i.triples.entries())a%2===0&&(s.printFilter(i,()=>n("")),r(ht,o.object));s.printFilter(i,()=>n(")"))}}}var ym=vm("collection",!1),Ro=vm("collectionPath",!0);function Am(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?Ro:ym)},{ALT:()=>r(t?Fo:bm)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(Ro,n):r(Fo,n)}}var Co=Am("triplesNode",!1),Mo=Am("triplesNodePath",!0);function xm(e,t){let r=t?_s:Ls;return{name:e,impl:({ACTION:n,SUBRULE:i,CONSUME:s})=>a=>{let o=s(T.LSquare),l=n(()=>a.astFactory.termBlank(void 0,a.astFactory.sourceLocation())),u=i(r,l),p=s(T.RSquare);return n(()=>a.astFactory.tripleCollectionBlankNodeProperties(l,u,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:n,PRINT:i,PRINT_WORD:s,HANDLE_LOC:a,PRINT_ON_EMPTY:o,NEW_LINE:l})=>(u,p)=>{let{astFactory:h,indentInc:f}=p;h.printFilter(u,()=>{p[X]+=f,i("["),l()});for(let m of u.triples)a(m,()=>{h.isTerm(m.predicate)&&h.isTermVariable(m.predicate)?n(ge,m.predicate):n(Et,m.predicate,void 0),h.printFilter(m,()=>s("")),n(ht,m.object),h.printFilter(u,()=>{s(";"),l()})});h.printFilter(u,()=>{p[X]-=f,o("]")})}}}var bm=xm("blankNodePropertyList",!1),Fo=xm("blankNodePropertyListPath",!0);function Im(e,t){let r=t?Mo:Co;return{name:e,impl:({SUBRULE:n,OR:i})=>s=>i([{ALT:()=>n(ge)},{GATE:()=>s.parseMode.has("canCreateBlankNodes"),ALT:()=>n(r)}]),gImpl:({SUBRULE:n})=>(i,{astFactory:s})=>{s.isTerm(i)?n(ge,i):n(r,i)}}}var Do=Im("graphNode",!1),ht=Im("graphNodePath",!0);var We={name:"whereClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OPTION:n})=>i=>{let s=n(()=>r(wt)),a=t(B);return e(()=>i.astFactory.wrap(a,i.astFactory.sourceLocation(s,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("WHERE")),e(B,r.val)}},RS=["canParseAggregate","inAggregate"],B={name:"groupGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>{let s=r(T.LCurly),a=e(()=>RS.filter(u=>i.parseMode.delete(u))),o=n([{ALT:()=>[t(qo)]},{ALT:()=>t(Lm)}]),l=r(T.RCurly);return e(()=>{for(let u of a)i.parseMode.add(u)}),t(No,o),e(()=>i.astFactory.patternGroup(o,i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>{s[X]+=o,t("{"),r()});for(let l of i.patterns)e(Em,l);a.printFilter(i,()=>{s[X]-=o,n("}")})}},Em={name:"generatePattern",gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{t.type==="query"?e(Er,r.querySelect({context:[],datasets:r.datasetClauses([],r.sourceLocation()),where:t.where,variables:t.variables,solutionModifiers:t.solutionModifiers,values:t.values,distinct:t.distinct,reduced:t.reduced},t.loc)):t.subType==="group"?e(B,t):t.subType==="bgp"?e(ft,t):e(zo,t)}},Lm={name:"groupGraphPatternSub",impl:({SUBRULE:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OPTION1:s,OPTION2:a,OPTION3:o})=>()=>{let l=[],u=s(()=>n(ft));return u&&l.push(u),r(()=>{let p=e(zo);l.push(p),a(()=>t(T.dot));let h=o(()=>i(ft));h&&l.push(h)}),e(Po,l),l}},zo={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ho)},{ALT:()=>e(Go)},{ALT:()=>e(Ko)},{ALT:()=>e($o)},{ALT:()=>e(Vo)},{ALT:()=>e(Wo)},{ALT:()=>e(jo)},{ALT:()=>e(xr)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e(Ho,t);break;case"optional":e(Go,t);break;case"minus":e(Ko,t);break;case"graph":e($o,t);break;case"service":e(Vo,t);break;case"filter":e(Wo,t);break;case"bind":e(jo,t);break;case"values":e(xr,t);break}}},Go={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ui),s=t(B);return e(()=>n.astFactory.patternOptional(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("OPTIONAL")),e(B,n.patternGroup(r.patterns,r.loc))}},$o={name:"graphGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.graph),s=t(bt),a=t(B);return e(()=>n.astFactory.patternGraph(s,a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(ge,r.name),e(B,n.patternGroup(r.patterns,r.loc))}},Vo={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(es),a=n(()=>(r(yt),!0))??!1,o=t(bt),l=t(B);return e(()=>i.astFactory.patternService(o,l.patterns,a,i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("SERVICE"),r.silent&&t("SILENT")}),e(ge,r.name),e(B,n.patternGroup(r.patterns,r.loc))}},jo={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ts);r(T.LParen);let s=t(k);r(kt);let a=t(Q),o=r(T.RParen);return e(()=>n.astFactory.patternBind(s,a,n.astFactory.sourceLocation(i,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BIND","(")),e(k,n.expression),i.printFilter(n,()=>t("AS")),e(Q,n.variable),i.printFilter(n,()=>{t(")"),r()})}},xr={name:"inlineData",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Mi),s=t(_m);return e(()=>(s.loc=n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,NEW_LINE:n,PRINT_ON_OWN_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:l}=a,u=s.variables,p=u.length===1;o.printFilter(s,()=>{r("VALUES",p?"":"( ")});for(let h of u)o.printFilter(s,()=>t("")),e(ge,h),o.printFilter(s,()=>t(""));o.printFilter(s,()=>{a[X]+=l,t(p?"":")","{"),n()});for(let h of s.values){o.printFilter(s,()=>!p&&t("("));for(let f of u){let m=f.value;h[m]===void 0?o.printFilter(s,()=>t("UNDEF")):(e(ht,h[m]),o.printFilter(s,()=>t("")))}o.printFilter(s,()=>{t(p?"":")"),n()})}o.printFilter(s,()=>{a[X]-=l,i("}")})}},_m={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Om)},{ALT:()=>e(Sm)}])},Om={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let s=[],a=t(Q);r(T.LCurly),n(()=>{let l=t(Yo);e(()=>{s.push(Object.assign(Object.create(null),{[a.value]:l}))})});let o=r(T.RCurly);return e(()=>i.astFactory.patternValues([a],s,i.astFactory.sourceLocation(a,o)))}},Sm={name:"inlineDataFull",impl:({ACTION:e,OR:t,MANY1:r,MANY2:n,MANY3:i,MANY4:s,SUBRULE:a,CONSUME1:o,CONSUME2:l})=>u=>{let p=[],h=[];return t([{ALT:()=>{let f=o(R.nil);o(T.LCurly),r(()=>{l(R.nil),p.push(Object.create(null))});let m=o(T.RCurly);return e(()=>u.astFactory.patternValues(h,p,u.astFactory.sourceLocation(f,m)))}},{ALT:()=>{let f=o(T.LParen);n(()=>{h.push(a(Q))}),o(T.RParen),l(T.LCurly),i(()=>{let v=0,x=Object.create(null);l(T.LParen),s(()=>{e(()=>{if(!u.skipValidation&&v>=h.length)throw new Error("Number of dataBlockValues does not match number of variables. Too much values.")});let A=a(Yo);e(()=>{x[h[v].value]=A,v++})}),l(T.RParen),e(()=>{if(p.push(x),!u.skipValidation&&h.length!==v)throw new Error("Number of dataBlockValues does not match number of variables. Too few values.")})});let m=l(T.RCurly);return e(()=>u.astFactory.patternValues(h,p,u.astFactory.sourceLocation(f,m)))}}])}},Yo={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(G)},{ALT:()=>e(Ft)},{ALT:()=>e(Xt)},{ALT:()=>e(Qt)},{ALT:()=>{t(rs)}}])},Ko={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ns),s=t(B);return e(()=>n.astFactory.patternMinus(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("MINUS")),e(B,n.patternGroup(r.patterns,r.loc))}},Ho={name:"groupOrUnionGraphPattern",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>{let a=[],o=r(B);return a.push(o),t(()=>{i(is);let l=n(B);a.push(l)}),e(()=>a.length===1?a[0]:s.astFactory.patternUnion(a,s.astFactory.sourceLocation(o,a.at(-1))))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isPatternUnion(r)){let[i,...s]=r.patterns;e(B,i);for(let a of s)n.printFilter(r,()=>t("UNION")),e(B,a)}else e(B,r)}},Wo={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ss),s=t(dn);return e(()=>n.astFactory.patternFilter(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("FILTER (")),e(k,n.expression),i.printFilter(n,()=>{t(")"),r()})}},dn={name:"constraint",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ir)},{ALT:()=>e(It)},{ALT:()=>e(Os)}])},Os={name:"functionCall",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(G),i=t(br),s=e(()=>r.astFactory.expressionFunctionCall(n,i.val.args,i.val.distinct,r.astFactory.sourceLocation(n,i)));return t(fn,s),s}};var br={name:"argList",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,OPTION:n,OR:i,AT_LEAST_ONE_SEP:s})=>a=>i([{ALT:()=>{let o=t(R.nil);return e(()=>a.astFactory.wrap({args:[],distinct:!1},a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=[],l=t(T.LParen),u=n(()=>(t(et),!0))??!1;s({SEP:T.comma,DEF:()=>{let h=r(k);o.push(h)}});let p=t(T.RParen);return e(()=>a.astFactory.wrap({args:o,distinct:u},a.astFactory.sourceLocation(l,p)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("("),r.val.distinct&&t("DISTINCT")});let[i,...s]=r.val.args;i&&e(k,i);for(let a of s)n.printFilter(r,()=>t(",")),e(k,a);n.printFilter(r,()=>t(")"))}},As={name:"expressionList",impl:({ACTION:e,CONSUME:t,MANY:r,OR:n,SUBRULE1:i,SUBRULE2:s})=>a=>n([{ALT:()=>{let o=t(R.nil);return e(()=>a.astFactory.wrap([],a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=t(T.LParen),u=[i(k)];r(()=>{t(T.comma);let h=s(k);u.push(h)});let p=t(T.RParen);return e(()=>a.astFactory.wrap(u,a.astFactory.sourceLocation(o,p)))}}])},FS=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),Ut=new Map([["!","!"],["uplus","+"],["uminus","-"]]),k={name:"expression",impl:({SUBRULE:e})=>()=>e(Nm),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isTerm(r))e(ge,r);else if(n.isExpressionPatternOperation(r)){let i=r.args;n.printFilter(r,()=>t(r.operator==="exists"?"EXISTS":"NOT EXISTS")),e(B,i)}else if(n.isExpressionFunctionCall(r))e(Uo,r);else if(n.isExpressionAggregate(r))e(bs,r);else if(r.operator==="in"||r.operator==="notin"){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(k,i),n.printFilter(r,()=>t(r.operator==="in"?"IN":"NOT IN")),e(br,n.wrap({args:s,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(FS.has(r.operator)){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(k,i);for(let a of s)n.printFilter(r,()=>t(r.operator)),e(k,a);n.printFilter(r,()=>t(")"))}else if(Ut.has(r.operator)){let[i]=r.args;n.printFilter(r,()=>t(Ut.get(r.operator)));let s=n.isExpressionOperator(i)&&Ut.has(i.operator);s&&n.printFilter(r,()=>t("(")),e(k,i),s&&n.printFilter(r,()=>t(")"))}else{n.printFilter(r,()=>t(r.operator.toUpperCase(),"("));let[i,...s]=r.args;i&&e(k,i);for(let a of s)n.printFilter(r,()=>t(",")),e(k,a);n.printFilter(r,()=>t(")"))}}};function mn(e,t,r,n){let i=e();return n(()=>{let s=t();r(()=>{i=s(i)})}),i}var Nm={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>mn(()=>n(Xo),()=>{r(T.logicOr);let a=i(Xo);return o=>e(()=>s.astFactory.expressionOperation("||",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Xo={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>mn(()=>r(Qo),()=>{i(T.logicAnd);let a=n(Qo);return o=>e(()=>s.astFactory.expressionOperation("&&",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Qo={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(Pm)},Pm={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:s,OR2:a,OR3:o})=>l=>{let u=r(Bo);return i(()=>s([{ALT:()=>{let h=a([{ALT:()=>t(T.equal)},{ALT:()=>t(T.notEqual)},{ALT:()=>t(T.lessThan)},{ALT:()=>t(T.greaterThan)},{ALT:()=>t(T.lessThanEqual)},{ALT:()=>t(T.greaterThanEqual)}]),f=n(Bo);return e(()=>l.astFactory.expressionOperation(h.image,[u,f],l.astFactory.sourceLocation(u,f)))}},{ALT:()=>{let h=o([{ALT:()=>t(ls)},{ALT:()=>t(cs)}]),f=r(As);return e(()=>l.astFactory.expressionOperation(h.image,[u,...f.val],l.astFactory.sourceLocation(u,f)))}}]))??u}},Bo={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(km)},km={name:"additiveExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,MANY1:s,MANY2:a,OR1:o,OR2:l,OR3:u,OR4:p})=>h=>mn(()=>n(Zo),()=>o([{ALT:()=>{let f=l([{ALT:()=>r(T.opPlus)},{ALT:()=>r(T.opMinus)}]),m=i(Zo);return e(()=>v=>h.astFactory.expressionOperation(f.image,[v,m],h.astFactory.sourceLocation(v,m)))}},{ALT:()=>{let{operator:f,startInt:m}=u([{ALT:()=>{let x=t(hs);return e(()=>(x.value=x.value.replace(/^\+/u,""),{operator:"+",startInt:x}))}},{ALT:()=>{let x=t(fs);return e(()=>(x.value=x.value.replace(/^-/u,""),{operator:"-",startInt:x}))}}]),v=mn(()=>e(()=>m),()=>{let x=p([{ALT:()=>r(T.star)},{ALT:()=>r(T.slash)}]),A=n(Ss);return y=>e(()=>h.astFactory.expressionOperation(x.image,[y,A],h.astFactory.sourceLocation(y,A)))},e,a);return x=>h.astFactory.expressionOperation(f,[x,v],h.astFactory.sourceLocation(x,v))}}]),e,s)},Zo={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:s})=>a=>mn(()=>n(Ss),()=>{let o=s([{ALT:()=>t(T.star)},{ALT:()=>t(T.slash)}]),l=i(Ss);return u=>({type:"expression",subType:"operation",operator:o.image,args:[u,l],loc:a.astFactory.sourceLocation(u,l)})},e,r)},Ss={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(Jo)},{ALT:()=>{let o=s([{ALT:()=>t(T.exclamation)},{ALT:()=>t(T.opPlus)},{ALT:()=>t(T.opMinus)}]),l=n(Jo);return e(()=>a.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[l],a.astFactory.sourceLocation(o,l)))}}])},Jo={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Ir)},{ALT:()=>e(It)},{ALT:()=>e(Uo)},{ALT:()=>e(Ft)},{ALT:()=>e(Xt)},{ALT:()=>e(Qt)},{ALT:()=>e(Q)}])},Ir={name:"brackettedExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(T.LParen),s=t(k),a=r(T.RParen);return e(()=>(s.loc=n.astFactory.sourceLocation(i,a),s))}},Uo={name:"iriOrFunction",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(G);return r(()=>{let a=t(br),o=e(()=>{let l=a.val.distinct;if(!n.parseMode.has("canParseAggregate")&&l)throw new Error("DISTINCT implies that this function is an aggregated function, which is not allowed in this context.");return n.astFactory.expressionFunctionCall(i,a.val.args,l,n.astFactory.sourceLocation(i,a))});return t(fn,o),o})??i},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(G,t):(e(G,t.function),e(br,r.wrap({args:t.args,distinct:t.distinct},t.loc)))}};var ze={name:"solutionModifier",impl:({ACTION:e,SUBRULE:t,OPTION1:r,OPTION2:n,OPTION3:i,OPTION4:s})=>()=>{let a=r(()=>t(el)),o=n(()=>t(tl)),l=i(()=>t(rl)),u=s(()=>t(nl));return e(()=>({...u&&{limitOffset:u},...a&&{group:a},...o&&{having:o},...l&&{order:l}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(el,t.group),t.having&&e(tl,t.having),t.order&&e(rl,t.order),t.limitOffset&&e(nl,t.limitOffset)}},el={name:"groupClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=[],a=n(on);return n(ln),t(()=>{s.push(r(wm))}),e(()=>({type:"solutionModifier",subType:"group",groupings:s,loc:i.astFactory.sourceLocation(a,s.at(-1))}))},gImpl:({PRINT_WORDS:e,SUBRULE:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("GROUP BY ")});for(let s of n.groupings)if(i.printFilter(n,()=>e("")),i.isExpression(s)){let a=i.isTerm(s)&&!i.isTermVariable(s)||i.isExpressionOperator(s)&&Ut.has(s.operator);a&&i.printFilter(s,()=>e("(")),t(k,s),a&&i.printFilter(s,()=>e(")"))}else i.printFilter(n,()=>e("(")),t(k,s.value),i.printFilter(n,()=>e("AS")),t(Q,s.variable),i.printFilter(n,()=>e(")"))}},wm={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s,OR:a})=>o=>a([{ALT:()=>t(It)},{ALT:()=>t(Os)},{ALT:()=>i(Q)},{ALT:()=>{let l=r(T.LParen),u=t(k),p=s(()=>(r(kt),n(Q))),h=r(T.RParen);return e(()=>p!==void 0?{variable:p,value:u,loc:o.astFactory.sourceLocation(l,h)}:u)}}])},tl={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(Pi),a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(Rm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierHaving(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_ON_EMPTY:e,PRINT_WORD:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{e("HAVING ")});for(let s of n.having){let a=i.isTerm(s)||i.isExpressionOperator(s)&&Ut.has(s.operator);a&&i.printFilter(s,()=>t("(")),r(k,s),a&&i.printFilter(s,()=>t(")"))}}},Rm={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(dn)},rl={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=n(ki);n(ln);let a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(Fm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierOrder(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_WORDS:e,PRINT_ON_EMPTY:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("ORDER BY ")});for(let s of n.orderDefs)s.descending?i.printFilter(n,()=>e("DESC")):i.printFilter(n,()=>e("ASC")),i.printFilter(n,()=>e("(")),r(k,s.expression),i.printFilter(n,()=>e(")"))}},Fm={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>s=>n([{ALT:()=>{let a=i([{ALT:()=>[!1,r(wi)]},{ALT:()=>[!0,r(Ri)]}]),o=t(Ir);return e(()=>({expression:o,descending:a[0],loc:s.astFactory.sourceLocation(a[1],o)}))}},{ALT:()=>{let a=t(dn);return e(()=>({expression:a,descending:!1,loc:a.loc}))}},{ALT:()=>{let a=t(Q);return e(()=>({expression:a,descending:!1,loc:a.loc}))}}])},nl={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:s})=>a=>s([{ALT:()=>{let o=t(il),l=n(()=>t(sl));return e(()=>a.astFactory.solutionModifierLimitOffset(o.val,l?.val,a.astFactory.sourceLocation(o,...l?[l]:[])))}},{ALT:()=>{let o=r(sl),l=i(()=>r(il));return e(()=>a.astFactory.solutionModifierLimitOffset(l?.val,o.val,a.astFactory.sourceLocation(o,l)))}}]),gImpl:({PRINT_WORDS:e,NEW_LINE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(),r.limit!==void 0&&e("LIMIT",String(r.limit)),r.offset&&e("OFFSET",String(r.offset))})}},il={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Fi),i=t(R.integer),s=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}},sl={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(Ci),i=e(R.integer),s=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}};var CS={name:"queryUnit",impl:({SUBRULE:e})=>()=>e(Er)},Er={name:"query",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=t(He),s=r([{ALT:()=>t(gn)},{ALT:()=>t(Tn)},{ALT:()=>t(vn)},{ALT:()=>t(yn)}]),a=t(An),o=e(()=>{let l={context:i,...s,type:"query",loc:n.astFactory.sourceLocation(i.at(0),s,a)};return a&&(l.values=a),l});return t(pn,o),o},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(He,t.context),r.isQuerySelect(t)?e(gn,t):r.isQueryConstruct(t)?e(Tn,t):r.isQueryDescribe(t)?e(vn,t):e(yn,t),t.values&&e(xr,t.values)}},gn={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ns),i=t(tt),s=t(We),a=t(ze);return e(()=>({subType:"select",where:s.val,solutionModifiers:a,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,s,a.group,a.having,a.order,a.limitOffset)}))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Ns,r.wrap({variables:t.variables,distinct:t.distinct,reduced:t.reduced},r.sourceLocation(...t.variables))),e(tt,t.datasets),e(We,r.wrap(t.where,t.where.loc)),e(ze,t.solutionModifiers)}},qo={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ns),i=t(We),s=t(ze),a=t(An),o=e(()=>r.astFactory.querySelect({where:i.val,datasets:r.astFactory.datasetClauses([],r.astFactory.sourceLocation()),context:[],solutionModifiers:s,...n.val,...a&&{values:a}},r.astFactory.sourceLocation(n,i,s.group,s.having,s.order,s.limitOffset,a)));return t(So,o),o}},Ns={name:"selectClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION:s,OR1:a,OR2:o,OR3:l})=>u=>{let p=i(Ei),h=e(()=>u.parseMode.has("canParseAggregate")||!u.parseMode.add("canParseAggregate")),f=s(()=>a([{ALT:()=>(i(et),[!0,!1])},{ALT:()=>(i(Li),[!1,!0])}]))??[!1,!1],m=e(()=>{let[A,y]=f;return{...A&&{distinct:A},...y&&{reduced:y}}}),v,x=o([{ALT:()=>{let A=i(T.star);return e(()=>(v=A,{variables:[u.astFactory.wildcard(u.astFactory.sourceLocation(A))],...m}))}},{ALT:()=>{let A=[],y=[];return t(()=>l([{ALT:()=>{let b=r(Q);e(()=>{if(!u.skipValidation&&A.some(g=>g.value===b.value))throw new Error(`Variable ${b.value} used more than once in SELECT clause`);A.push(b),y.push(b),v=b})}},{ALT:()=>{let b=i(T.LParen),g=r(k);i(kt);let I=n(Q),w=i(T.RParen);e(()=>{if(v=w,!u.skipValidation&&A.some(C=>C.value===I.value))throw new Error(`Variable ${I.value} used more than once in SELECT clause`);A.push(I),y.push(u.astFactory.patternBind(g,I,u.astFactory.sourceLocation(b,v)))})}}])),{variables:y,...m}}}]);return e(()=>!h&&u.parseMode.delete("canParseAggregate")),e(()=>u.astFactory.wrap(x,u.astFactory.sourceLocation(p,v)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("SELECT "),n.val.distinct?t("DISTINCT"):n.val.reduced&&t("REDUCED")});for(let s of n.val.variables)i.isWildcard(s)?i.printFilter(n,()=>t("*")):i.isTerm(s)?e(Q,s):(i.printFilter(n,()=>t("(")),e(k,s.expression),i.printFilter(n,()=>t("AS")),e(Q,s.variable),i.printFilter(n,()=>t(")"))),i.printFilter(n,()=>t(""));i.printFilter(n,()=>t(""))}},Tn={name:"constructQuery",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,CONSUME:n,OR:i})=>s=>{let a=n(_i);return i([{ALT:()=>{let o=t(al),l=t(tt),u=t(We),p=t(ze);return e(()=>({subType:"construct",template:o.val,datasets:l,where:u.val,solutionModifiers:p,loc:s.astFactory.sourceLocation(a,u,p.group,p.having,p.order,p.limitOffset)}))}},{ALT:()=>{let o=r(tt);n(wt);let l=r(al),u=r(ze);return e(()=>({subType:"construct",template:l.val,datasets:o,where:s.astFactory.patternGroup([l.val],s.astFactory.sourceLocation()),solutionModifiers:u,loc:s.astFactory.sourceLocation(a,l,u.group,u.having,u.order,u.limitOffset)}))}}])},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,PRINT_ON_OWN_LINE:n,NEW_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:l}=a;o.printFilter(s,()=>r("CONSTRUCT ")),o.isSourceLocationNoMaterialize(s.where.loc)||(o.printFilter(s,()=>{a[X]+=l,t("{"),i()}),e(ft,s.template),o.printFilter(s,()=>{a[X]-=l,n("}")})),e(tt,s.datasets),o.isSourceLocationNoMaterialize(s.where.loc)?e(We,o.wrap(o.patternGroup([s.template],s.template.loc),s.template.loc)):e(We,o.wrap(s.where,s.where.loc)),e(ze,s.solutionModifiers)}},vn={name:"describeQuery",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n,OPTION:i,OR:s})=>a=>{let o=n(Oi),l=s([{ALT:()=>{let f=[];return t(()=>{f.push(r(bt))}),f}},{ALT:()=>{let f=n(T.star);return[e(()=>a.astFactory.wildcard(a.astFactory.sourceLocation(f)))]}}]),u=r(tt),p=i(()=>r(We)),h=r(ze);return e(()=>({subType:"describe",variables:l,datasets:u,...p&&{where:p.val},solutionModifiers:h,loc:a.astFactory.sourceLocation(o,...l,u,p,h.group,h.having,h.order,h.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{if(i.printFilter(n,()=>r("DESCRIBE ")),i.isWildcard(n.variables[0]))i.printFilter(n,()=>t("*"));else for(let s of n.variables)i.printFilter(n,()=>t("")),e(ge,s);e(tt,n.datasets),n.where&&e(We,i.wrap(n.where,n.loc)),e(ze,n.solutionModifiers)}},yn={name:"askQuery",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Si),s=t(tt),a=t(We),o=t(ze);return e(()=>({subType:"ask",datasets:s,where:a.val,solutionModifiers:o,loc:n.astFactory.sourceLocation(i,s,a,o.group,o.having,o.order,o.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("ASK ")),e(tt,r.datasets),e(We,n.wrap(r.where,r.loc)),e(ze,r.solutionModifiers)}},An={name:"valuesClause",impl:({OPTION:e,SUBRULE:t})=>()=>e(()=>t(xr))},al={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(T.LCurly),a=n(()=>t(Cm)),o=r(T.RCurly);return e(()=>i.astFactory.wrap(a??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,o)))}},Cm={name:"constructTriples",impl:Jt.impl};var MS={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(Ps)},Ps={name:"update",impl:({ACTION:e,SUBRULE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION1:s,MANY:a})=>o=>{let l=[],u=r(He);l.push({context:u});let p=!0;a({GATE:()=>p,DEF:()=>{p=!1,l.at(-1).operation=t(Lr),s(()=>{i(T.semi),p=!0;let f=n(He);l.push({context:f})})}});let h=e(()=>({type:"update",updates:l,loc:o.astFactory.sourceLocation(...l.flatMap(f=>[...f.context,f.operation]))}));return t(hn,h),h},gImpl:({SUBRULE:e,PRINT:t,NEW_LINE:r})=>(n,{astFactory:i})=>{let[s,...a]=n.updates;s&&(e(He,s.context),s.operation&&e(Lr,s.operation));for(let o of a)i.printFilter(n,()=>{t(";"),r()}),e(He,o.context),o.operation&&e(Lr,o.operation)}},Lr={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(ol)},{ALT:()=>e(ll)},{ALT:()=>e(cl)},{ALT:()=>e(pl)},{ALT:()=>e(hl)},{ALT:()=>e(fl)},{ALT:()=>e(ul)},{ALT:()=>e(dl)},{ALT:()=>e(ml)},{ALT:()=>e(gl)},{ALT:()=>e(Tl)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(ol,t);break;case"clear":e(ll,t);break;case"drop":e(cl,t);break;case"add":e(pl,t);break;case"move":e(hl,t);break;case"copy":e(fl,t);break;case"create":e(ul,t);break;case"insertdata":e(dl,t);break;case"deletedata":e(ml,t);break;case"deletewhere":e(gl,t);break;case"modify":e(Tl,t);break}}},ol={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>s=>{let a=r(Di),o=n(()=>r(yt)),l=t(G),u=i(()=>(r(Gi),t(xn)));return e(()=>s.astFactory.updateOperationLoad(s.astFactory.sourceLocation(a,l,u),l,!!o,u))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("LOAD "),n.silent&&t("SILENT")}),e(G,n.source),n.destination&&(i.printFilter(n,()=>t("INTO")),e(er,n.destination))}};function Mm(e){return{name:ae(e.name),impl:({ACTION:t,SUBRULE1:r,CONSUME:n,OPTION:i})=>s=>{let a=n(e),o=i(()=>n(yt)),l=r(er);return t(()=>s.astFactory.updateOperationClearDrop(ae(e.name),!!o,l,s.astFactory.sourceLocation(a,l)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(er,i.destination)}}}var ll=Mm($i),cl=Mm(Vi),ul={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(ji),a=n(()=>r(yt)),o=t(xn);return e(()=>i.astFactory.updateOperationCreate(o,!!a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("CREATE "),n.silent&&t("SILENT")}),e(er,n.destination)}};function xl(e){return{name:ae(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s})=>a=>{let o=r(e),l=s(()=>r(yt)),u=n(yl);r(Hi);let p=i(yl);return t(()=>a.astFactory.updateOperationAddMoveCopy(ae(e.name),u,p,!!l,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(er,i.source),s.printFilter(i,()=>r("TO")),t(er,i.destination)}}}var pl=xl(Ki),hl=xl(Wi),fl=xl(zi),ks={name:"quadPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(T.LCurly),s=t(_r),a=r(T.RCurly);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,a)))}},bl={name:"quadData",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(T.LCurly),s=e(()=>n.parseMode.delete("canParseVars")),a=t(_r);e(()=>s&&n.parseMode.add("canParseVars"));let o=r(T.RCurly);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,o)))}};function Il(e,t,r,n){return{name:e,impl:({ACTION:i,SUBRULE1:s,CONSUME:a})=>o=>{let l=a(r),u=!0;e!=="insertData"&&(u=i(()=>o.parseMode.delete("canCreateBlankNodes")));let p=s(n);return e!=="insertData"&&i(()=>u&&o.parseMode.add("canCreateBlankNodes")),i(()=>o.astFactory.updateOperationInsDelDataWhere(t,p.val,o.astFactory.sourceLocation(l,p)))},gImpl:({SUBRULE:i,PRINT_WORD:s,PRINT_ON_EMPTY:a,PRINT_ON_OWN_LINE:o,NEW_LINE:l})=>(u,p)=>{let{astFactory:h,indentInc:f}=p;h.printFilter(u,()=>{a(t==="insertdata"?"INSERT DATA ":t==="deletedata"?"DELETE DATA ":"DELETE WHERE "),p[X]+=f,s("{"),l()}),i(_r,h.wrap(u.data,u.loc)),h.printFilter(u,()=>{p[X]-=f,o("}")})}}}var dl=Il("insertData","insertdata",Bi,bl),ml=Il("deleteData","deletedata",qi,bl),gl=Il("deleteWhere","deletewhere",Xi,ks),Tl={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:s,OR:a})=>o=>{let l=i(()=>{let m=t(Yi),v=r(G);return{withToken:m,graph:v}}),{insert:u,del:p}=a([{ALT:()=>{let m=r(Dm),v=s(()=>r(vl));return{del:m,insert:v}}},{ALT:()=>({insert:n(vl),del:void 0})}]),h=r(gs);t(wt);let f=r(B);return e(()=>o.astFactory.updateOperationModify(o.astFactory.sourceLocation(l?.withToken,p,u,f),u?.val??[],p?.val??[],f,h,l?.graph))},gImpl:({SUBRULE:e,PRINT_WORDS:t,PRINT_ON_EMPTY:r,NEW_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;i.graph&&(a.printFilter(i,()=>t("WITH")),e(G,i.graph)),(i.delete.length>0||i.insert.length===0)&&(a.printFilter(i,()=>{s[X]+=o,t("DELETE","{"),n()}),e(_r,a.wrap(i.delete,i.loc)),a.printFilter(i,()=>{s[X]-=o,r("}"),n()})),i.insert.length>0&&(a.printFilter(i,()=>{s[X]+=o,t("INSERT","{"),n()}),e(_r,a.wrap(i.insert,i.loc)),a.printFilter(i,()=>{s[X]-=o,r("} "),n()})),e(gs,i.from),a.printFilter(i,()=>t("WHERE")),e(B,i.where)}},Dm={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Qi),s=e(()=>n.parseMode.delete("canCreateBlankNodes")),a=t(ks);return e(()=>s&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},vl={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Zi),s=t(ks);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},yl={name:"graphOrDefault",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>i([{ALT:()=>{let a=r(Ee.default_);return e(()=>s.astFactory.graphRefDefault(s.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=n(()=>r(Ee.graph)),o=t(G);return e(()=>s.astFactory.graphRefSpecific(o,s.astFactory.sourceLocation(a,o)))}}])},xn={name:"graphRef",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ee.graph),s=t(G);return e(()=>n.astFactory.graphRefSpecific(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(G,r.graph)}},er={name:"graphRefAll",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(xn)},{ALT:()=>{let s=r(Ee.default_);return e(()=>i.astFactory.graphRefDefault(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(Ee.named);return e(()=>i.astFactory.graphRefNamed(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(Ee.graphAll);return e(()=>i.astFactory.graphRefAll(i.astFactory.sourceLocation(s)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.isGraphRefSpecific(r)?e(xn,r):n.isGraphRefDefault(r)?n.printFilter(r,()=>t("DEFAULT")):n.isGraphRefNamed(r)?n.printFilter(r,()=>t("NAMED")):n.printFilter(r,()=>t("ALL"))}},_r={name:"quads",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:l})=>u=>{let p=[],h;return a(()=>{let f=i(Jt);h=f,e(()=>p.push(f))}),n(()=>{let f=t(Al);h=f,p.push(f),o(()=>{let m=r(T.dot);return h=m,m}),l(()=>{let m=s(Jt);h=m,e(()=>p.push(m))})}),e(()=>u.astFactory.wrap(p,u.astFactory.sourceLocation(p.at(0),h)))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t.val)r.isPattern(n)?e(ft,n):e(Al,n)}},Al={name:"quadsNotTriples",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Ee.graph),a=t(bt);r(T.LCurly);let o=n(()=>t(Jt)),l=r(T.RCurly);return e(()=>i.astFactory.graphQuads(a,o??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>t("GRAPH")),e(ge,i.graph),a.printFilter(i,()=>{s[X]+=o,t("{"),r()}),e(ft,i.triples),a.printFilter(i,()=>{s[X]-=o,n("}")})}};var DS={name:"queryOrUpdate",impl:({ACTION:e,SUBRULE:t,OR1:r,OR2:n,MANY:i,OPTION1:s,CONSUME:a,SUBRULE2:o})=>l=>{let u=t(He);return r([{ALT:()=>{let p=n([{ALT:()=>t(gn)},{ALT:()=>t(Tn)},{ALT:()=>t(vn)},{ALT:()=>t(yn)}]),h=t(An),f=e(()=>({context:u,...p,type:"query",...h&&{values:h},loc:l.astFactory.sourceLocation(u.at(0),p,h)}));return t(pn,f),f}},{ALT:()=>{let p=[];p.push({context:u});let h=!0;i({GATE:()=>h,DEF:()=>{h=!1,p.at(-1).operation=t(Lr),s(()=>{a(T.semi),h=!0;let m=o(He);p.push({context:m})})}});let f=e(()=>({type:"update",updates:p,loc:l.astFactory.sourceLocation(...p.flatMap(m=>[...m.context,m.operation]))}));return t(hn,f),f}}])},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isQuery(t)?e(Er,t):e(Ps,t)}};function GS(e){return{astFactory:e.astFactory??new xt({tracksSourceLocation:!1}),baseIRI:e.baseIRI,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:e.parseMode?new Set(e.parseMode):new Set(["canParseVars","canCreateBlankNodes"]),skipValidation:e.skipValidation??!1,rejectGroupedSelectAliasReuse:e.rejectGroupedSelectAliasReuse??!1,namedAggregatorCallback:e.namedAggregatorCallback,astTransformer:e.astTransformer}}function El(e){return{astFactory:e.astFactory??new xt,origSource:e.origSource??"",offset:e.offset,[X]:e[X]??0,[Jr]:e[Jr]??" ",indentInc:e.indentInc??2}}function Gm(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var ws=class{parser;defaultContext;coreTransformer=new zt;constructor(t,r={}){this.parser=t,this.defaultContext=GS(r)}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Gm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),n}parsePath(t,r={}){let n=this.parser.path(t,Gm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),this.defaultContext.astFactory.isPathPure(n)?{...n,prefixes:Object.create(null)}:n}};var $S=[c.expression,c.conditionalOrExpression,c.conditionalAndExpression,c.valueLogical,c.relationalExpression,c.numericExpression,c.expressionList,c.additiveExpression,c.multiplicativeExpression,c.unaryExpression,c.primaryExpression,c.brackettedExpression,c.iriOrFunction,c.validateFunctionCall,c.rdfLiteral,c.numericLiteral,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative,c.booleanLiteral,c.var_,c.builtInStr,c.builtInLang,c.builtInLangmatches,c.builtInDatatype,c.builtInBound,c.builtInIri,c.builtInUri,c.builtInBnodeSparqlJs,c.builtInRand,c.builtInAbs,c.builtInCeil,c.builtInFloor,c.builtInRound,c.builtInConcat,c.builtInStrlen,c.builtInUcase,c.builtInLcase,c.builtInEncode_for_uri],VS={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(c.builtInCallList(t).slice(0,-2))},$m=oe.create($S).addMany(c.builtInContains,c.builtInStrstarts,c.builtInStrends,c.builtInStrbefore,c.builtInStrafter,c.builtInYear,c.builtInMonth,c.builtInDay,c.builtInHours,c.builtInMinutes,c.builtInSeconds,c.builtInTimezone,c.builtInTz,c.builtInNow,c.builtInUuid,c.builtInStruuid,c.builtInMd5,c.builtInSha1,c.builtInSha256,c.builtInSha384,c.builtInSha512,c.builtInCoalesce,c.builtInIf,c.builtInStrlang,c.builtInStrdt,c.builtInSameterm,c.builtInIsiri,c.builtInIsuri,c.builtInIsblank,c.builtInIsliteral,c.builtInIsnumeric,c.regexExpression,c.substringExpression,c.strReplaceExpression,c.aggregateCount,c.aggregateSum,c.aggregateMin,c.aggregateMax,c.aggregateAvg,c.aggregateSample,c.aggregateGroup_concat,c.aggregate,c.iri,c.iriFull,c.prefixedName,c.argList,c.string).addRule(VS);var jS=[c.objectList,c.object,c.graphNode,c.varOrTerm,c.triplesNode,c.collection,c.blankNodePropertyList,c.propertyListNotEmpty,c.verb,c.verbA,c.varOrIri,c.var_,c.iri,c.iriFull,c.prefixedName,c.graphTerm,c.rdfLiteral,c.numericLiteral,c.booleanLiteral,c.blankNode,c.string,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative],Rs=oe.create(jS);var Vm=oe.create([c.triplesBlock,c.triplesSameSubjectPath,c.propertyListPathNotEmpty,c.triplesNodePath,c.propertyListPath,c.verbPath,c.verbSimple,c.objectListPath]).merge(Rs,[]).addMany(c.path,c.pathAlternative,c.pathSequence,c.pathEltOrInverse,c.pathElt,c.pathPrimary,c.pathMod,c.pathNegatedPropertySet,c.pathOneInPropertySet,c.objectPath,c.graphNodePath,c.collectionPath,c.blankNodePropertyListPath);var KS=[c.subSelect,c.selectClause,c.whereClause,c.solutionModifier,c.valuesClause,c.validateSubSelect,c.validateGroupGraphPattern,c.validateGroupGraphPatternSub],Fs=oe.create(KS).merge($m,[]).patchRule(c.builtInCall).addMany(c.existsFunc,c.notExistsFunc,c.groupGraphPattern,c.groupGraphPatternSub).merge(Vm,[]).addMany(c.graphPatternNotTriples,c.groupOrUnionGraphPattern,c.optionalGraphPattern,c.minusGraphPattern,c.graphGraphPattern,c.serviceGraphPattern,c.filter,c.bind,c.inlineData,c.constraint,c.functionCall,c.dataBlock,c.inlineDataOneVar,c.inlineDataFull,c.dataBlockValue,c.groupClause,c.havingClause,c.orderClause,c.limitOffsetClauses,c.groupCondition,c.havingCondition,c.orderCondition,c.limitClause,c.offsetClause);var HS=[c.triplesTemplate,c.triplesSameSubject,c.varOrTerm,c.propertyListNotEmpty,c.triplesNode,c.propertyList,c.var_,c.graphTerm,c.iri,c.iriFull,c.prefixedName,c.rdfLiteral,c.string,c.numericLiteral,c.numericLiteralUnsigned,c.numericLiteralPositive,c.numericLiteralNegative,c.booleanLiteral,c.blankNode,c.verb,c.verbA,c.varOrIri,c.objectList,c.object,c.collection,c.blankNodePropertyList,c.graphNode],Cs=oe.create(HS);var WS=[c.queryUnit,c.query,c.prologue,c.selectQuery,c.constructQuery,c.describeQuery,c.askQuery,c.valuesClause,c.baseDecl,c.prefixDecl,c.validateQuery,c.validateSelectQuery,c.validateDescribeQuery],jm=oe.create(WS).merge(Fs,[]).addRule(c.datasetClause).addRule(c.datasetClauseStar).addRule(c.defaultGraphClause).addRule(c.namedGraphClause).addRule(c.sourceSelector).addRule(c.constructTemplate).merge(Cs,[]).addRule(c.constructTriples);var zS={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(c.load)},{ALT:()=>e(c.clear)},{ALT:()=>e(c.drop)},{ALT:()=>e(c.add)},{ALT:()=>e(c.move)},{ALT:()=>e(c.copy)},{ALT:()=>e(c.create)},{ALT:()=>e(c.insertData)},{ALT:()=>e(c.deleteData)},{ALT:()=>e(c.deleteWhere)}]),gImpl:c.update1.gImpl},YS=[c.updateUnit,c.update,c.prologue,c.baseDecl,c.prefixDecl,c.load,c.clear,c.drop,c.add,c.move,c.copy,c.create,c.insertData,c.deleteData,c.deleteWhere,c.iri,c.prefixedName,c.graphRef,c.graphRefAll,c.graphOrDefault,c.quadData,c.quads,c.validateUpdate],Km=oe.create(YS).addRule(zS).merge(Cs,[]).addRule(c.quadPattern).addRule(c.quadsNotTriples);var Hm=oe.create(Km).patchRule(c.update1).addMany(c.modify,c.deleteClause,c.insertClause,c.usingClause,c.defaultGraphClause,c.namedGraphClause,c.sourceSelector,c.usingClauseStar,c.groupGraphPattern).merge(Rs,[]).merge(Fs,[]);var qS=oe.create(jm).merge(Hm,[]).addRule(c.queryOrUpdate),Ms=class extends ws{constructor(t={}){let r=qS.build({...t,tokenVocabulary:ve.sparql11LexerBuilder.tokenVocabulary,queryPreProcessor:yf});super(r,t.defaultContext)}};var XS=pi.create([c.queryOrUpdate,c.query,c.selectQuery,c.constructQuery,c.describeQuery,c.askQuery,c.selectClause]).addMany(c.update,c.update1,c.load,c.clear,c.drop,c.create,c.copy,c.move,c.add,c.insertData,c.deleteData,c.deleteWhere,c.modify,c.graphRef,c.graphRefAll,c.quads,c.quadsNotTriples).addRule(c.aggregate).addMany(c.datasetClauseStar,c.usingClauseStar).addMany(c.argList,c.expression,c.iriOrFunction).addMany(c.prologue,c.prefixDecl,c.baseDecl,c.varOrTerm,c.var_,c.graphTerm).addMany(c.rdfLiteral,c.iri,c.iriFull,c.prefixedName,c.blankNode).addRule(c.pathGenerator).addMany(c.solutionModifier,c.groupClause,c.havingClause,c.orderClause,c.limitOffsetClauses).addMany(c.triplesBlock,c.collectionPath,c.blankNodePropertyListPath,c.triplesNodePath,c.graphNodePath).addMany(c.whereClause,c.generatePattern,c.groupGraphPattern,c.graphPatternNotTriples,c.optionalGraphPattern,c.graphGraphPattern,c.serviceGraphPattern,c.bind,c.inlineData,c.minusGraphPattern,c.groupOrUnionGraphPattern,c.filter),Ds=class{defaultContext;constructor(t={}){this.defaultContext=El(t)}generator=XS.build();generate(t,r={}){return this.generator.queryOrUpdate(t,{...this.defaultContext,...r}).trim()}generatePath(t,r={}){return this.generator.path(t,El({...this.defaultContext,...r}),void 0).trim()}};function Ll(e,t=new Map){if(Array.isArray(e))return e.forEach(n=>Ll(n,t)),e;if(!e||typeof e!="object")return e;let r=new Map(t);if(Array.isArray(e.context))for(let n of e.context)n.subType==="prefix"&&n.key&&n.value?.value&&r.set(n.key,n.value.value);if(e.type==="term"&&e.subType==="namedNode"&&e.prefix){let n=r.get(e.prefix);if(!n)throw new Error(`Undefined SPARQL prefix: ${e.prefix}`);e.value=n+e.value,delete e.prefix}for(let n of Object.values(e))Ll(n,r);return e}var _l=class{constructor(t){this.parser=new Ms(t)}parse(t){return Ll(this.parser.parse(t))}},Ol=class{constructor(t){this.generator=new Ds(t)}generate(t,r){return this.generator.generate(t,r)}};typeof window<"u"&&(window.LDH_SPARQL={Parser:_l,Generator:Ol});})(); +${n.message}`),new Error(i.join(""))}build({tokenVocabulary:t,parserConfig:r={},lexerConfig:n={},queryPreProcessor:i=a=>a,errorHandler:s}){let a=ye.create().add(...t).build({positionTracking:"onlyOffset",recoveryEnabled:!1,ensureOptimizations:!0,safeMode:!1,skipValidations:!0,...n}),o=this.consume({tokenVocabulary:t,config:r}),c={};for(let l of Object.values(this.rules))c[l.name]=((p,h,...d)=>{let m=i(p),A=a.tokenize(m);if(A.errors.length>0)throw new Error(A.errors[0].message);o.input=A.tokens,o.setContext(h);let b=o[l.name](h,...d);return o.errors.length>0&&(s?s(o.errors):this.defaultErrorHandler(m,o.errors)),b});return c}consume({tokenVocabulary:t,config:r={}}){return new ei(this.rules,t,r)}};function dt(e){return e instanceof Promise}var $t=class e{defaultContext;maxStackSize=1e6;maxNodeRewrites=1e3;constructor(t={}){this.defaultContext=t}clone(t={}){return new e({...this.defaultContext,...t})}cloneObj(t){if(t===null||typeof t!="object")return t;let r=Object.getPrototypeOf(t);return r===Object.prototype||r===null?{...t}:Object.assign(Object.create(r),t)}transformObject(t,r,n=()=>({})){return this.runTransformObject(t,r,n,!1)}transformObjectAsync(t,r,n=()=>({})){return Promise.resolve(this.runTransformObject(t,r,n,!0))}runTransformObject(t,r,n,i){let s=this.defaultContext,a=s.copy??!0,o=s.continue??!0,c=s.ignoreKeys,l=s.shallowKeys,p=s.shortcut??!1,h=!1,d={res:t},m=[t],A=[d],b=["res"],y=[],v=[],x=[],T=[],I=[];function S(){for(;m.length===y.at(-1);){y.pop();let M=v.pop(),z=x.pop(),J=T.pop(),fe=I.pop(),de=r(M,z);if(i&&dt(de))return de.then(ne=>(J[fe]=ne,S()));J[fe]=de}}let C=(M,z,J,fe)=>{let de=fe.copy??a,ne=fe.continue??o,q=fe.ignoreKeys??c,ae=fe.shallowKeys??l;h=fe.shortcut??p;let pe=de?this.cloneObj(M):M;if(y.push(m.length),v.push(pe),x.push(M),T.push(z),I.push(J),ne&&!h)for(let ct in pe){if(!Object.hasOwn(pe,ct))continue;let Ze=pe[ct],ln=ae&&ae?.has(ct);ln&&(pe[ct]=this.cloneObj(Ze)),!(q&&q.has(ct))&&!ln&&Ze!==null&&typeof Ze=="object"&&(m.push(Ze),b.push(ct),A.push(pe))}},X=()=>{for(;m.length>0&&m.length=0;ae--){let pe=M[ae];pe!==null&&typeof pe=="object"&&(m.push(pe),A.push(ne),b.push(ae.toString()))}let q=S();if(q)return q.then(X);continue}let de=n(M);if(i&&dt(de))return de.then(ne=>{C(M,z,J,ne);let q=S();return q?q.then(X):X()});C(M,z,J,de)}let fe=S();if(fe)return fe.then(X)}if(m.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return d.res};return X()}transformObjectPreOrder(t,r){return this.runTransformObjectPreOrder(t,r,!1)}transformObjectPreOrderAsync(t,r){return Promise.resolve(this.runTransformObjectPreOrder(t,r,!0))}runTransformObjectPreOrder(t,r,n){let i=this.defaultContext,s=i.copy??!0,a=i.continue??!0,o=i.ignoreKeys,c=i.shallowKeys,l=i.shortcut??!1,p=i.reTransform??!1,h=!1,d={res:t},m=[t],A=[d],b=["res"],y=[0];function v(I,S){for(let C=I.length-1;C>=0;C--){let X=I[C];X!==null&&typeof X=="object"&&(m.push(X),A.push(I),b.push(C.toString()),y.push(S))}}let x=(I,S,C,X)=>{let M=I.newValue;S[C]=M;let z=I.continue??a,J=I.ignoreKeys??o,fe=I.shallowKeys??c,de=I.reTransform??p;if(h=I.shortcut??l,!z||h||M===null||typeof M!="object")return;if(Array.isArray(M)){v(M,X+1);return}if(de){m.push(M),A.push(S),b.push(C),y.push(X+1);return}let ne=M;for(let q in ne){if(!Object.hasOwn(ne,q)||J?.has(q))continue;let ae=ne[q];ae!==null&&typeof ae=="object"&&(fe?.has(q)?ne[q]=this.cloneObj(ae):(m.push(ae),A.push(ne),b.push(q),y.push(0)))}},T=()=>{for(;!h&&m.length>0&&m.length=this.maxNodeRewrites)throw new Error(`Pre order transform did not converge: rewrote the same position ${this.maxNodeRewrites} times.`,{cause:I});if(Array.isArray(I)){let J=[...I];S[C]=J,v(J,X);continue}let M=s?this.cloneObj(I):I,z=r(M,I);if(n&&dt(z))return z.then(J=>(x(J,S,C,X),T()));x(z,S,C,X)}if(m.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return d.res};return T()}visitObject(t,r,n=()=>({})){this.runVisitObject(t,r,n,!1)}visitObjectAsync(t,r,n=()=>({})){return Promise.resolve(this.runVisitObject(t,r,n,!0))}runVisitObject(t,r,n,i){let s=this.defaultContext,a=s.continue??!0,o=s.ignoreKeys,c=s.shortcut??!1,l=!1,p=[t],h=[],d=[];function m(){for(;p.length===h.at(-1);){h.pop();let y=d.pop(),v=r(y);if(i&&dt(v))return v.then(()=>m())}}let A=(y,v)=>{l=v.shortcut??c;let x=v.continue??a,T=v.ignoreKeys??o;if(h.push(p.length),d.push(y),x&&!l)for(let I in y){if(!Object.hasOwn(y,I)||T&&T.has(I))continue;let S=y[I];S&&typeof S=="object"&&p.push(S)}},b=()=>{for(;p.length>0&&p.length=0;I--){let S=y[I];S!==null&&typeof S=="object"&&p.push(S)}let T=m();if(T)return T.then(b);continue}let x=n(y);if(i&&dt(x))return x.then(T=>{A(y,T);let I=m();return I?I.then(b):b()});A(y,x)}let v=m();if(v)return v.then(b)}if(p.length>=this.maxStackSize)throw new Error("Transform object stack overflowed")};return b()}};var ti=class e extends $t{defaultNodePreVisitor;constructor(t={},r={}){super(t),this.defaultNodePreVisitor=r}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNode(t,r){let n=(a,o)=>{let c,l=a;return l.type&&(c=r[l.type]?.transform),c?c(l,o):a},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;return l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),o?{...c,...o(l)}:c};return this.transformObject(t,n,s)}transformNodeAsync(t,r){let n=(a,o)=>{let c,l=a;return l.type&&(c=r[l.type]?.transform),c?c(l,o):a},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;if(l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),!o)return c;let p=o(l);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.transformObjectAsync(t,n,s)}transformNodePreOrder(t,r){let n=this.defaultNodePreVisitor,i=(s,a)=>{let o,c={},l=s;return l.type&&(o=r[l.type],c=n[l.type]??c),o?{...c,...o(s,a)}:{...c,newValue:s,reTransform:!1}};return this.transformObjectPreOrder(t,i)}transformNodePreOrderAsync(t,r){let n=this.defaultNodePreVisitor,i=(s,a)=>{let o,c={},l=s;if(l.type&&(o=r[l.type],c=n[l.type]??c),!o)return{...c,newValue:s,reTransform:!1};let p=o(s,a);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.transformObjectPreOrderAsync(t,i)}visitNode(t,r){let n=a=>{let o=a;if(o.type){let c=r[o.type]?.visitor;c&&c(o)}},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;return l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),o?{...c,...o(l)}:c};return this.visitObject(t,n,s)}visitNodeAsync(t,r){let n=a=>{let o=a;if(o.type){let c=r[o.type]?.visitor;if(c)return c(o)}},i=this.defaultNodePreVisitor,s=a=>{let o,c={},l=a;if(l.type&&(o=r[l.type]?.preVisitor,c=i[l.type]??c),!o)return c;let p=o(l);return dt(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.visitObjectAsync(t,n,s)}};var zr=class e extends ti{constructor(t={},r={}){super(t,r)}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNodeSpecific(t,r,n){let i=(a,o)=>{let c,l=a;if(l.type&&l.subType){let p=n[l.type];p&&(c=p[l.subType]?.transform),c||(c=r[l.type]?.transform)}return c?c(l,o):a},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.transformObject(t,i,s)}transformNodeSpecificAsync(t,r,n){let i=(a,o)=>{let c,l=a;if(l.type&&l.subType){let p=n[l.type];p&&(c=p[l.subType]?.transform),c||(c=r[l.type]?.transform)}return c?c(l,o):a},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.transformObjectAsync(t,i,s)}transformNodeSpecificPreOrder(t,r,n){let i=(s,a)=>{let o,c=s;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]),o||(o=r[c.type])}return o?o(s,a):{newValue:s}};return this.transformObjectPreOrder(t,i)}transformNodeSpecificPreOrderAsync(t,r,n){let i=(s,a)=>{let o,c=s;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]),o||(o=r[c.type])}return o?o(s,a):{newValue:s}};return this.transformObjectPreOrderAsync(t,i)}visitNodeSpecific(t,r,n){let i=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.visitor),o||(o=r[c.type]?.visitor)}o&&o(c)},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};this.visitObject(t,i,s)}visitNodeSpecificAsync(t,r,n){let i=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.visitor),o||(o=r[c.type]?.visitor)}if(o)return o(c)},s=a=>{let o,c=a;if(c.type&&c.subType){let l=n[c.type];l&&(o=l[c.subType]?.preVisitor),o||(o=r[c.type]?.preVisitor)}return o?o(c):{}};return this.visitObjectAsync(t,i,s)}};var u={};Pt(u,{add:()=>Xo,additiveExpression:()=>um,aggregate:()=>us,aggregateAvg:()=>Ld,aggregateCount:()=>bd,aggregateGroup_concat:()=>Od,aggregateMax:()=>Ed,aggregateMin:()=>Id,aggregateSample:()=>_d,aggregateSum:()=>xd,argList:()=>dr,askQuery:()=>an,baseAggregateFunc:()=>qt,baseDecl:()=>ro,bind:()=>Eo,blankNode:()=>is,blankNodePropertyList:()=>em,blankNodePropertyListPath:()=>To,booleanLiteral:()=>Wt,brackettedExpression:()=>mr,builtInAbs:()=>Nf,builtInBnodeSparqlJs:()=>Of,builtInBound:()=>Ef,builtInCall:()=>yt,builtInCallList:()=>md,builtInCeil:()=>Pf,builtInCoalesce:()=>sd,builtInConcat:()=>Ff,builtInContains:()=>Gf,builtInDatatype:()=>If,builtInDay:()=>zf,builtInEncode_for_uri:()=>Df,builtInFloor:()=>kf,builtInHours:()=>qf,builtInIf:()=>ad,builtInIri:()=>Lf,builtInIsblank:()=>hd,builtInIsiri:()=>ud,builtInIsliteral:()=>fd,builtInIsnumeric:()=>dd,builtInIsuri:()=>pd,builtInLang:()=>bf,builtInLangmatches:()=>xf,builtInLcase:()=>Mf,builtInMd5:()=>ed,builtInMinutes:()=>Yf,builtInMonth:()=>Wf,builtInNow:()=>Zf,builtInRand:()=>Sf,builtInRound:()=>Rf,builtInSameterm:()=>ld,builtInSeconds:()=>Xf,builtInSha1:()=>td,builtInSha256:()=>rd,builtInSha384:()=>nd,builtInSha512:()=>id,builtInStr:()=>Af,builtInStrafter:()=>Kf,builtInStrbefore:()=>Vf,builtInStrdt:()=>cd,builtInStrends:()=>jf,builtInStrlang:()=>od,builtInStrlen:()=>wf,builtInStrstarts:()=>$f,builtInStruuid:()=>Uf,builtInTimezone:()=>Bf,builtInTz:()=>Qf,builtInUcase:()=>Cf,builtInUri:()=>_f,builtInUuid:()=>Jf,builtInYear:()=>Hf,canCreateBlankNodes:()=>UO,clear:()=>zo,collection:()=>Zd,collectionPath:()=>go,conditionalAndExpression:()=>ko,conditionalOrExpression:()=>cm,constraint:()=>en,constructQuery:()=>nn,constructTemplate:()=>Ho,constructTriples:()=>dm,copy:()=>Qo,create:()=>Yo,dataBlock:()=>im,dataBlockValue:()=>No,datasetClause:()=>gf,datasetClauseStar:()=>Be,datasetClauseUsing:()=>ao,datasetClauseUsingStar:()=>oo,defaultGraphClause:()=>Tf,deleteClause:()=>gm,deleteData:()=>Jo,deleteWhere:()=>Uo,describeQuery:()=>sn,drop:()=>qo,existsFunc:()=>vd,expression:()=>R,expressionList:()=>ls,filter:()=>Oo,funcExpr1:()=>G,funcExpr2:()=>Qe,funcExpr2or3:()=>os,funcExpr3:()=>lo,funcExpr3or4:()=>ho,funcExprList1:()=>as,funcExprOrNil1:()=>po,funcGroupGraphPattern:()=>cs,funcNil1:()=>hr,funcVar1:()=>uo,functionCall:()=>ms,generatePattern:()=>rm,graphGraphPattern:()=>xo,graphNode:()=>Ao,graphNodePath:()=>at,graphOrDefault:()=>rc,graphPatternNotTriples:()=>So,graphRef:()=>cn,graphRefAll:()=>Xt,graphTerm:()=>io,groupClause:()=>Do,groupCondition:()=>pm,groupGraphPattern:()=>Y,groupGraphPatternSub:()=>nm,groupOrUnionGraphPattern:()=>_o,havingClause:()=>Go,havingCondition:()=>hm,inlineData:()=>fr,inlineDataFull:()=>am,inlineDataOneVar:()=>sm,insertClause:()=>tc,insertData:()=>Zo,iri:()=>$,iriFull:()=>pr,iriOrFunction:()=>Mo,limitClause:()=>Vo,limitOffsetClauses:()=>jo,load:()=>Wo,minusGraphPattern:()=>Lo,modify:()=>ec,move:()=>Bo,multiplicativeExpression:()=>wo,namedGraphClause:()=>vf,notExistsFunc:()=>Ad,numericExpression:()=>Fo,numericLiteral:()=>Ht,numericLiteralNegative:()=>rs,numericLiteralPositive:()=>ts,numericLiteralUnsigned:()=>mf,object:()=>Xd,objectList:()=>zd,objectListPath:()=>qd,objectPath:()=>Bd,offsetClause:()=>Ko,optionalGraphPattern:()=>bo,orderClause:()=>$o,orderCondition:()=>fm,path:()=>hs,pathAlternative:()=>Pd,pathChainHelper:()=>mo,pathElt:()=>fo,pathEltOrInverse:()=>Sd,pathGenerator:()=>vt,pathMod:()=>kd,pathNegatedPropertySet:()=>Fd,pathOneInPropertySet:()=>ps,pathPrimary:()=>Rd,pathSequence:()=>Nd,prefixDecl:()=>no,prefixedName:()=>to,primaryExpression:()=>Co,prologue:()=>De,propertyList:()=>$d,propertyListNotEmpty:()=>fs,propertyListPath:()=>jd,propertyListPathNotEmpty:()=>ds,quadData:()=>sc,quadPattern:()=>vs,quads:()=>yr,quadsNotTriples:()=>nc,query:()=>gr,queryOrUpdate:()=>iS,queryUnit:()=>rS,rdfLiteral:()=>St,regexExpression:()=>gd,relationalExpression:()=>lm,selectClause:()=>Ts,selectQuery:()=>rn,serviceGraphPattern:()=>Io,solutionModifier:()=>$e,sourceSelector:()=>co,strReplaceExpression:()=>yd,string:()=>ns,stringEscapedLexical:()=>Ur,subSelect:()=>Po,substringExpression:()=>Td,triplesBlock:()=>ot,triplesNode:()=>yo,triplesNodePath:()=>vo,triplesSameSubject:()=>Md,triplesSameSubjectPath:()=>Dd,triplesTemplate:()=>Yt,unaryExpression:()=>gs,update:()=>ys,update1:()=>Tr,updateUnit:()=>nS,usingClause:()=>yf,usingClauseStar:()=>ss,valueLogical:()=>Ro,valuesClause:()=>on,varOrIri:()=>Tt,varOrTerm:()=>ue,var_:()=>W,verb:()=>so,verbA:()=>zt,verbPath:()=>Kd,verbSimple:()=>Hd,whereClause:()=>Ge});var he={};Pt(he,{a:()=>lr,add:()=>Ni,allBaseTokens:()=>Zh,as:()=>Lt,ask:()=>mi,baseDecl:()=>li,bind:()=>Ki,builtIn:()=>E,by:()=>Jr,clear:()=>_i,construct:()=>fi,copy:()=>Ri,create:()=>Si,deleteClause:()=>Mi,deleteDataClause:()=>wi,deleteWhereClause:()=>Ci,describe:()=>di,distinct:()=>Xe,drop:()=>Oi,false_:()=>Xi,filter:()=>qi,from:()=>gi,graph:()=>ve,groupByGroup:()=>Zr,having:()=>Ti,in_:()=>Bi,insertClause:()=>Gi,insertDataClause:()=>Di,limit:()=>bi,load:()=>Ei,loadInto:()=>Li,minus:()=>Wi,modifyWith:()=>Fi,move:()=>ki,notIn:()=>Qi,offset:()=>xi,optional:()=>ji,order:()=>yi,orderAsc:()=>vi,orderDesc:()=>Ai,patterns:()=>Ya,prefixDecl:()=>ui,reduced:()=>hi,select:()=>pi,separator:()=>Zi,service:()=>Vi,silent:()=>mt,sparql11LexerBuilder:()=>QO,symbols:()=>g,terminals:()=>F,to:()=>Pi,true_:()=>Yi,undef:()=>Hi,union:()=>zi,usingClause:()=>$i,values:()=>Ii,where:()=>_t});var E={};Pt(E,{BuiltInCalls:()=>L,abs:()=>Uu,allBuiltInCalls:()=>La,avg:()=>ri,bnode:()=>Zu,bound:()=>Xu,ceil:()=>ep,coalesce:()=>Np,concat:()=>np,contains:()=>cp,count:()=>Wp,datatype:()=>Yu,day:()=>mp,encode_for_uri:()=>op,exists:()=>Kp,floor:()=>tp,groupConcat:()=>ni,hours:()=>gp,if_:()=>Pp,iri:()=>Bu,isblank:()=>Mp,isiri:()=>wp,isliteral:()=>Dp,isnumeric:()=>Gp,isuri:()=>Cp,lang:()=>zu,langmatches:()=>qu,lcase:()=>ap,max:()=>Yp,md5:()=>Ep,min:()=>qp,minutes:()=>Tp,month:()=>dp,notexists:()=>Hp,now:()=>bp,rand:()=>Ju,regex:()=>$p,replace:()=>Vp,round:()=>rp,sameterm:()=>Fp,sample:()=>Xp,seconds:()=>yp,sha1:()=>Lp,sha256:()=>_p,sha384:()=>Op,sha512:()=>Sp,str:()=>Wu,strafter:()=>hp,strbefore:()=>pp,strdt:()=>Rp,strends:()=>up,strlang:()=>kp,strlen:()=>ip,strstarts:()=>lp,struuid:()=>Ip,substr:()=>jp,sum:()=>zp,timezone:()=>vp,tz:()=>Ap,ucase:()=>sp,uri:()=>Qu,uuid:()=>xp,year:()=>fp});var L;(function(e){e.Str="builtInStr",e.Lang="builtInLang",e.Langmatches="builtInLangmatches",e.Datatype="builtInDatatype",e.Bound="builtInBound",e.Iri="builtInIri",e.Uri="builtInUri",e.Bnode="builtInBnode",e.Rand="builtInRand",e.Abs="builtInAbs",e.Ceil="builtInCeil",e.Floor="builtInFloor",e.Round="builtInRound",e.Concat="builtInConcat",e.Strlen="builtInStrlen",e.Ucase="builtInUcase",e.Lcase="builtInLcase",e.Encode_for_uri="builtInEncode_for_uri",e.Contains="builtInContains",e.Strstarts="builtInStrstarts",e.Strends="builtInStrends",e.Strbefore="builtInStrbefore",e.Strafter="builtInStrafter",e.Year="builtInYear",e.Month="builtInMonth",e.Day="builtInDay",e.Hours="builtInHours",e.Minutes="builtInMinutes",e.Seconds="builtInSeconds",e.Timezone="builtInTimezone",e.Tz="builtInTz",e.Now="builtInNow",e.Uuid="builtInUuid",e.Struuid="builtInStruuid",e.Md5="builtInMd5",e.Sha1="builtInSha1",e.Sha256="builtInSha256",e.Sha384="builtInSha384",e.Sha512="builtInSha512",e.Coalesce="builtInCoalesce",e.If="builtInIf",e.Strlang="builtInStrlang",e.Strdt="builtInStrdt",e.Sameterm="builtInSameterm",e.Isiri="builtInIsiri",e.Isuri="builtInIsuri",e.Isblank="builtInIsblank",e.Isliteral="builtInIsliteral",e.Isnumeric="builtInIsnumeric",e.Regex="builtInRegex",e.Substr="builtInSubstr",e.Replace="builtInReplace",e.Exists="builtInExists",e.Notexists="builtInNotexists",e.Count="builtInCount",e.Sum="builtInSum",e.Min="builtInMin",e.Max="builtInMax",e.Avg="builtInAvg",e.Sample="builtInSample",e.Group_concat="builtInGroup_concat"})(L||(L={}));function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Wu=f({name:_(L.Str),pattern:/str/i,label:"STR"}),zu=f({name:_(L.Lang),pattern:/lang/i,label:"LANG"}),qu=f({name:_(L.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),Yu=f({name:_(L.Datatype),pattern:/datatype/i,label:"DATATYPE"}),Xu=f({name:_(L.Bound),pattern:/bound/i,label:"BOUND"}),Bu=f({name:_(L.Iri),pattern:/iri/i,label:"IRI"}),Qu=f({name:_(L.Uri),pattern:/uri/i,label:"URI"}),Zu=f({name:_(L.Bnode),pattern:/bnode/i,label:"BNODE"}),Ju=f({name:_(L.Rand),pattern:/rand/i,label:"RAND"}),Uu=f({name:_(L.Abs),pattern:/abs/i,label:"ABS"}),ep=f({name:_(L.Ceil),pattern:/ceil/i,label:"CEIL"}),tp=f({name:_(L.Floor),pattern:/floor/i,label:"FLOOR"}),rp=f({name:_(L.Round),pattern:/round/i,label:"ROUND"}),np=f({name:_(L.Concat),pattern:/concat/i,label:"CONCAT"}),ip=f({name:_(L.Strlen),pattern:/strlen/i,label:"STRLEN"}),sp=f({name:_(L.Ucase),pattern:/ucase/i,label:"UCASE"}),ap=f({name:_(L.Lcase),pattern:/lcase/i,label:"LCASE"}),op=f({name:_(L.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),cp=f({name:_(L.Contains),pattern:/contains/i,label:"CONTAINS"}),lp=f({name:_(L.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),up=f({name:_(L.Strends),pattern:/strends/i,label:"STRENDS"}),pp=f({name:_(L.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),hp=f({name:_(L.Strafter),pattern:/strafter/i,label:"STRAFTER"}),fp=f({name:_(L.Year),pattern:/year/i,label:"YEAR"}),dp=f({name:_(L.Month),pattern:/month/i,label:"MONTH"}),mp=f({name:_(L.Day),pattern:/day/i,label:"DAY"}),gp=f({name:_(L.Hours),pattern:/hours/i,label:"HOURS"}),Tp=f({name:_(L.Minutes),pattern:/minutes/i,label:"MINUTES"}),yp=f({name:_(L.Seconds),pattern:/seconds/i,label:"SECONDS"}),vp=f({name:_(L.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),Ap=f({name:_(L.Tz),pattern:/tz/i,label:"TZ"}),bp=f({name:_(L.Now),pattern:/now/i,label:"NOW"}),xp=f({name:_(L.Uuid),pattern:/uuid/i,label:"UUID"}),Ip=f({name:_(L.Struuid),pattern:/struuid/i,label:"STRUUID"}),Ep=f({name:_(L.Md5),pattern:/md5/i,label:"MD5"}),Lp=f({name:_(L.Sha1),pattern:/sha1/i,label:"SHA1"}),_p=f({name:_(L.Sha256),pattern:/sha256/i,label:"SHA256"}),Op=f({name:_(L.Sha384),pattern:/sha384/i,label:"SHA384"}),Sp=f({name:_(L.Sha512),pattern:/sha512/i,label:"SHA512"}),Np=f({name:_(L.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),Pp=f({name:_(L.If),pattern:/if/i,label:"IF"}),kp=f({name:_(L.Strlang),pattern:/strlang/i,label:"STRLANG"}),Rp=f({name:_(L.Strdt),pattern:/strdt/i,label:"STRDT"}),Fp=f({name:_(L.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),wp=f({name:_(L.Isiri),pattern:/isiri/i,label:"ISIRI"}),Cp=f({name:_(L.Isuri),pattern:/isuri/i,label:"ISURI"}),Mp=f({name:_(L.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Dp=f({name:_(L.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Gp=f({name:_(L.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),$p=f({name:_(L.Regex),pattern:/regex/i,label:"REGEX"}),jp=f({name:_(L.Substr),pattern:/substr/i,label:"SUBSTR"}),Vp=f({name:_(L.Replace),pattern:/replace/i,label:"REPLACE"}),Kp=f({name:_(L.Exists),pattern:/exists/i,label:"EXISTS"}),Hp=f({name:_(L.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),Wp=f({name:_(L.Count),pattern:/count/i,label:"COUNT"}),zp=f({name:_(L.Sum),pattern:/sum/i,label:"SUM"}),qp=f({name:_(L.Min),pattern:/min/i,label:"MIN"}),Yp=f({name:_(L.Max),pattern:/max/i,label:"MAX"}),ri=f({name:_(L.Avg),pattern:/avg/i,label:"AVG"}),Xp=f({name:_(L.Sample),pattern:/sample/i,label:"SAMPLE"}),ni=f({name:_(L.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),La=ye.create().add(qu,Yu,zu,Xu,Bu,Qu,Zu,Ju,Uu,ep,tp,rp,np,ip,sp,ap,op,cp,lp,up,pp,hp,fp,dp,mp,gp,Tp,yp,vp,Ap,bp,xp,Ip,Ep,Lp,_p,Op,Sp,Np,Pp,kp,Rp,Fp,wp,Cp,Mp,Dp,Gp,$p,jp,Vp,Kp,Hp,Wp,zp,qp,Yp,ri,Xp,ni,Wu);var ve={};Pt(ve,{allGraphTokens:()=>_a,default_:()=>Qp,graph:()=>Zp,graphAll:()=>ii,named:()=>Bp});var Bp=f({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),Qp=f({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),Zp=f({name:"Graph",pattern:/graph/i,label:"GRAPH"}),ii=f({name:"GraphAll",pattern:/all/i,label:"ALL"}),_a=ye.create().add(Bp,Qp,Zp,ii);var Ya={};Pt(Ya,{anonPattern:()=>qa,atLeastOneBlankPattern:()=>Qr,blankNodeLabelPattern:()=>ka,commentPattern:()=>ci,decimalNegativePattern:()=>$a,decimalPattern:()=>Yr,decimalPositivePattern:()=>Ma,doubleNegativePattern:()=>ja,doublePattern:()=>Xr,doublePositivePattern:()=>Da,echarPattern:()=>Br,exponentPattern:()=>ai,integerNegativePattern:()=>Ga,integerPattern:()=>qr,integerPositivePattern:()=>Ca,iriRefPattern:()=>Na,langTagPattern:()=>wa,nilPattern:()=>za,pNameLnPattern:()=>Pa,pNameNsPattern:()=>oi,percentPattern:()=>Up,plxPattern:()=>si,pnCharsBasePattern:()=>Oa,pnCharsPattern:()=>jt,pnCharsUPattern:()=>or,pnLocalEscPattern:()=>eh,pnLocalPattern:()=>th,pnPrefixPattern:()=>Jp,stringLiteral1Pattern:()=>Va,stringLiteral2Pattern:()=>Ka,stringLiteralLong1Pattern:()=>Ha,stringLiteralLong2Pattern:()=>Wa,var1Pattern:()=>Ra,var2Pattern:()=>Fa,varNamePattern:()=>Sa,wsPattern:()=>cr});var Oa=/[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/,or=new RegExp(`(${Oa.source})|_`),Sa=new RegExp(`((${or.source})|[0-9])((${or.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),Na=/<([^\u0000-\u0020"<>\\^`{|}])*>/,jt=new RegExp(`(${or.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),Jp=new RegExp(`(${Oa.source})(((${jt.source})|\\.)*(${jt.source}))?`),oi=new RegExp(`(${Jp.source})?:`),Up=/%[\dA-Fa-f]{2}/,eh=/\\[!#$%&'()*+,./;=?@_~-]/,si=new RegExp(`(${Up.source})|(${eh.source})`),th=new RegExp(`((${or.source})|:|[0-9]|(${si.source}))(((${jt.source})|\\.|:|(${si.source}))*((${jt.source})|:|(${si.source})))?`),Pa=new RegExp(`(${oi.source})(${th.source})`),ka=new RegExp(`_:((${or.source})|[0-9])(((${jt.source})|\\.)*(${jt.source}))?`),Ra=new RegExp(`\\?(${Sa.source})`),Fa=new RegExp(`\\$(${Sa.source})`),wa=/@[A-Za-z]+(-[\dA-Za-z]+)*/,qr=/\d+/,Yr=/\d+\.\d+/,ai=/[Ee][+-]?\d+/,Xr=new RegExp(`([0-9]+\\.[0-9]*(${ai.source}))|(\\.[0-9]+(${ai.source}))|([0-9]+(${ai.source}))`),Ca=new RegExp(`\\+(${qr.source})`),Ma=new RegExp(`\\+(${Yr.source})`),Da=new RegExp(`\\+(${Xr.source})`),Ga=new RegExp(`-(${qr.source})`),$a=new RegExp(`-(${Yr.source})`),ja=new RegExp(`-(${Xr.source})`),Br=/\\["'\\bfnrt]/,Va=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${Br.source}))*'`),Ka=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${Br.source}))*"`),Ha=new RegExp(`'''(('|(''))?([^'\\\\]|(${Br.source})))*'''`),Wa=new RegExp(`"""(("|(""))?([^"\\\\]|(${Br.source})))*"""`),cr=/[\u0009\u000A\u000D ]/,za=new RegExp(`\\((${cr.source})*\\)`),qa=new RegExp(`\\[(${cr.source})*\\]`),ci=/#[^\n]*/,Qr=new RegExp(`(((${cr.source})+)|((${ci.source}) +))+`);var g={};Pt(g,{LCurly:()=>rh,LParen:()=>oh,LSquare:()=>lh,RCurly:()=>nh,RParen:()=>ch,RSquare:()=>uh,allSymbols:()=>Xa,comma:()=>sh,dot:()=>ih,equal:()=>bh,exclamation:()=>yh,greaterThan:()=>Eh,greaterThanEqual:()=>_h,hat:()=>fh,hathat:()=>Oh,lessThan:()=>Ih,lessThanEqual:()=>Lh,logicAnd:()=>vh,logicOr:()=>Ah,notEqual:()=>xh,opMinus:()=>Th,opPlus:()=>gh,pipe:()=>ph,question:()=>dh,semi:()=>ah,slash:()=>hh,star:()=>mh});var rh=f({name:"LCurly",pattern:"{",label:"{"}),nh=f({name:"RCurly",pattern:"}",label:"}"}),ih=f({name:"Dot",pattern:".",label:"."}),sh=f({name:"Comma",pattern:",",label:","}),ah=f({name:"Semi",pattern:";",label:";"}),oh=f({name:"LParen",pattern:"(",label:"("}),ch=f({name:"RParen",pattern:")",label:")"}),lh=f({name:"LSquare",pattern:"[",label:"["}),uh=f({name:"RSquare",pattern:"]",label:"]"}),ph=f({name:"Pipe",pattern:"|",label:"|"}),hh=f({name:"Slash",pattern:"/",label:"/"}),fh=f({name:"Hat",pattern:"^",label:"^"}),dh=f({name:"Question",pattern:"?",label:"?"}),mh=f({name:"Star",pattern:"*",label:"*"}),gh=f({name:"OpPlus",pattern:"+",label:"+"}),Th=f({name:"OpMinus",pattern:"-",label:"-"}),yh=f({name:"Exclamation",pattern:"!",label:"!"}),vh=f({name:"LogicAnd",pattern:"&&",label:"&&"}),Ah=f({name:"LogicOr",pattern:"||",label:"||"}),bh=f({name:"Equal",pattern:"=",label:"="}),xh=f({name:"NotEqual",pattern:"!=",label:"!="}),Ih=f({name:"LessThan",pattern:"<",label:"<"}),Eh=f({name:"GreaterThan",pattern:">",label:">"}),Lh=f({name:"LessThanEqual",pattern:"<=",label:"<="}),_h=f({name:"GreaterThanEqual",pattern:">=",label:">="}),Oh=f({name:"Hathat",pattern:"^^",label:"^^"}),Xa=ye.create().add(vh,Ah,xh,Lh,_h,rh,nh,ih,sh,ah,oh,ch,lh,uh,ph,hh,Oh,fh,dh,mh,gh,Th,yh,bh,Ih,Eh);var F={};Pt(F,{allTerminals:()=>Qa,anon:()=>Qh,blankNodeLabel:()=>Ph,comment:()=>Xh,decimal:()=>Ch,decimalNegative:()=>Vh,decimalPositive:()=>Gh,double:()=>Mh,doubleNegative:()=>Kh,doublePositive:()=>$h,integer:()=>wh,integerNegative:()=>jh,integerPositive:()=>Dh,iriRef:()=>Sh,langTag:()=>Fh,nil:()=>Bh,pNameLn:()=>Ba,pNameNs:()=>Nh,stringLiteral1:()=>Hh,stringLiteral2:()=>Wh,stringLiteralLong1:()=>zh,stringLiteralLong2:()=>qh,var1:()=>kh,var2:()=>Rh,ws:()=>Yh});var Sh=f({name:"IriRef",pattern:Na}),Ba=f({name:"PNameLn",pattern:Pa}),Nh=f({name:"PNameNs",pattern:oi,longer_alt:[Ba]}),Ph=f({name:"BlankNodeLabel",pattern:ka}),kh=f({name:"Var1",pattern:Ra}),Rh=f({name:"Var2",pattern:Fa}),Fh=f({name:"LangTag",pattern:wa}),wh=f({name:"Integer",pattern:qr}),Ch=f({name:"Decimal",pattern:Yr}),Mh=f({name:"Double",pattern:Xr}),Dh=f({name:"IntegerPositive",pattern:Ca}),Gh=f({name:"DecimalPositive",pattern:Ma}),$h=f({name:"DoublePositive",pattern:Da}),jh=f({name:"IntegerNegative",pattern:Ga}),Vh=f({name:"DecimalNegative",pattern:$a}),Kh=f({name:"DoubleNegative",pattern:ja}),Hh=f({name:"StringLiteral1",pattern:Va}),Wh=f({name:"StringLiteral2",pattern:Ka}),zh=f({name:"StringLiteralLong1",pattern:Ha}),qh=f({name:"StringLiteralLong2",pattern:Wa}),Yh=f({name:"Ws",pattern:cr,group:le.SKIPPED}),Xh=f({name:"Comment",pattern:ci,group:le.SKIPPED}),Bh=f({name:"Nil",pattern:za}),Qh=f({name:"Anon",pattern:qa}),Qa=ye.create().add(Sh,Nh,Ba,Ph,kh,Rh,Fh,Mh,Ch,wh,$h,Gh,Dh,Kh,Vh,jh,zh,qh,Hh,Wh,Yh,Xh,Bh,Qh);var li=f({name:"BaseDecl",pattern:/base/i,label:"BASE"}),ui=f({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),pi=f({name:"Select",pattern:/select/i,label:"SELECT"}),Xe=f({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),hi=f({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),Lt=f({name:"As",pattern:/as/i,label:"AS"}),fi=f({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),di=f({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),mi=f({name:"Ask",pattern:/ask/i,label:"ASK"}),gi=f({name:"From",pattern:/from/i,label:"FROM"}),_t=f({name:"Where",pattern:/where/i,label:"WHERE"}),Zr=f({name:"GroupByGroup",pattern:/group/i,label:"_GROUP_ BY"}),Jr=f({name:"By",pattern:/by/i,label:"BY"}),Ti=f({name:"Having",pattern:/having/i,label:"HAVING"}),yi=f({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),vi=f({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Ai=f({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),bi=f({name:"Limit",pattern:/limit/i,label:"LIMIT"}),xi=f({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Ii=f({name:"Values",pattern:/values/i,label:"VALUES"}),Ei=f({name:"Load",pattern:/load/i,label:"LOAD"}),mt=f({name:"Silent",pattern:/silent/i,label:"SILENT"}),Li=f({name:"LoadInto",pattern:/into/i,label:"INTO"}),_i=f({name:"Clear",pattern:/clear/i,label:"CLEAR"}),Oi=f({name:"Drop",pattern:/drop/i,label:"DROP"}),Si=f({name:"Create",pattern:/create/i,label:"CREATE"}),Ni=f({name:"Add",pattern:/add/i,label:"ADD"}),Pi=f({name:"To",pattern:/to/i,label:"TO"}),ki=f({name:"Move",pattern:/move/i,label:"MOVE"}),Ri=f({name:"Copy",pattern:/copy/i,label:"COPY"}),Fi=f({name:"ModifyWith",pattern:/with/i,label:"WITH"}),wi=f({name:"DeleteDataClause",pattern:new RegExp(`delete(${Qr.source})data`,"i"),label:"DELETE DATA"}),Ci=f({name:"DeleteWhereClause",pattern:new RegExp(`delete(${Qr.source})where`,"i"),label:"DELETE WHERE"}),Mi=f({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),Di=f({name:"InsertDataClause",pattern:new RegExp(`insert(${Qr.source})data`,"i"),label:"INSERT DATA"}),Gi=f({name:"InsertClause",pattern:/insert/i,label:"insert"}),$i=f({name:"UsingClause",pattern:/using/i,label:"USING"}),ji=f({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),Vi=f({name:"Service",pattern:/service/i,label:"SERVICE"}),Ki=f({name:"Bind",pattern:/bind/i,label:"BIND"}),Hi=f({name:"Undef",pattern:/undef/i,label:"UNDEF"}),Wi=f({name:"Minus",pattern:/minus/i,label:"MINUS"}),zi=f({name:"Union",pattern:/union/i,label:"UNION"}),qi=f({name:"Filter",pattern:/filter/i,label:"FILTER"}),lr=f({name:"a",pattern:"a",label:"type declaration 'a'"}),Yi=f({name:"True",pattern:/true/i,label:"true"}),Xi=f({name:"False",pattern:/false/i,label:"false"}),Bi=f({name:"In",pattern:/in/i,label:"IN"}),Qi=f({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),Zi=f({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),Zh=ye.create().add(li,ui,pi,Xe,hi,fi,di,mi,gi,_t,Ti,Zr,Jr,yi,vi,Ai,bi,xi,Ii,Ei,mt,Li,_i,Oi,Si,Ni,Pi,ki,Ri,Fi,Ci,wi,Mi,Di,Gi,$i,ji,Vi,Ki,Hi,Wi,zi,qi,Lt,lr,Yi,Xi,Bi,Qi,Zi),QO=ye.create(Qa).merge(Zh).merge(La).merge(_a).merge(Xa).moveAfter(ri,lr).moveBefore(lr,ii).moveAfter(ni,Zr);var Za="contextDef";function Jh(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:Za,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,Za,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,Za,"base")}}}var st="expression";function Uh(e){return class extends e{isExpressionPure(r){return this.isOfType(r,st)}formatOperator(r){return r.toLowerCase().replaceAll(" ","")}expressionOperation(r,n,i){return{type:st,subType:"operation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionOperator(r){return this.isOfSubType(r,st,"operation")}expressionFunctionCall(r,n,i,s){return{type:"expression",subType:"functionCall",function:r,args:n,distinct:i,loc:s}}isExpressionFunctionCall(r){return this.isOfSubType(r,st,"functionCall")}expressionPatternOperation(r,n,i){return{type:st,subType:"patternOperation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionPatternOperation(r){return this.isOfSubType(r,st,"patternOperation")}aggregate(r,n,i,s,a){let o={type:"expression",subType:"aggregate",aggregation:this.formatOperator(r),distinct:n,loc:a};return this.isOfType(i,"wildcard")?{...o,expression:[i]}:s===void 0?{...o,expression:[i]}:{...o,expression:[i],separator:s}}isExpressionAggregate(r){return this.isOfSubType(r,st,"aggregate")}isExpressionAggregateSeparator(r){return this.isOfSubType(r,st,"aggregate")&&typeof r.separator=="string"}isExpressionAggregateOnWildcard(r){let n=r;return this.isOfSubType(r,st,"aggregate")&&Array.isArray(n.expression)&&n.expression.length===1&&this.isOfType(n.expression[0],"wildcard")}isExpressionAggregateDefault(r){let n=r;return this.isOfSubType(r,st,"operation")&&Array.isArray(n.expression)&&n.expression.length===1&&!this.isOfType(n.expression[0],"wildcard")}}}var gt="graphRef";function ef(e){return class extends e{isGraphRef(r){return this.isOfType(r,gt)}graphRefDefault(r){return{type:gt,subType:"default",loc:r}}isGraphRefDefault(r){return this.isOfSubType(r,gt,"default")}graphRefNamed(r){return{type:gt,subType:"named",loc:r}}isGraphRefNamed(r){return this.isOfSubType(r,gt,"named")}graphRefAll(r){return{type:gt,subType:"all",loc:r}}isGraphRefAll(r){return this.isOfSubType(r,gt,"all")}graphRefSpecific(r,n){return{type:gt,subType:"specific",graph:r,loc:n}}isGraphRefSpecific(r){return this.isOfSubType(r,gt,"specific")}}}function tf(e){return new Ja(e)}var Ja=class{input;constructor(t){this.input=t}call(t){return this.input=t(this.input),this}returns(){return this.input}};var Me="path";function rf(e){return class extends e{isPathPure(r){return this.isOfType(r,Me)}path(r,n,i){let s={type:Me,loc:i,items:n};if(r==="|"||r==="/")return{...s,subType:r};if((r==="?"||r==="*"||r==="+"||r==="^"&&this.isPathPure(n[0]))&&n.length===1)return{...s,subType:r,items:n};if(r==="^"&&n.length===1&&!this.isPathPure(n[0]))return{...s,subType:r,items:n};if(r==="!"&&n.length===1&&(this.isPathAlternativeLimited(n[0])||!this.isPathPure(n[0])||this.isPathNegatedElt(n[0])))return{...s,subType:r,items:n};throw new Error("Invalid path type")}isPathOfType(r,n){return this.isOfType(r,Me)&&n.includes(r.subType)}isPathChain(r){return this.isOfSubType(r,Me,"/")||this.isOfSubType(r,Me,"|")}isPathModified(r){return this.isOfSubType(r,Me,"?")||this.isOfSubType(r,Me,"*")||this.isOfSubType(r,Me,"+")||this.isOfSubType(r,Me,"^")}isPathNegatedElt(r){let n=r;return this.isOfSubType(r,Me,"^")&&Array.isArray(n.items)&&n.items.length===1&&n.items[0]!==null&&typeof n.items[0]=="object"&&!this.isPathPure(n.items[0])}isPathNegated(r){return this.isOfSubType(r,Me,"!")}isPathAlternativeLimited(r){let n=r;return this.isOfSubType(r,Me,"|")&&Array.isArray(n.items)&&n.items.every(i=>!this.isPathPure(i)||this.isPathNegatedElt(i))}}}var U="pattern";function nf(e){return class extends e{isPattern(r){return this.isOfType(r,U)}patternBgp(r,n){return{type:U,subType:"bgp",triples:r,loc:n}}isPatternBgp(r){return this.isOfSubType(r,U,"bgp")}patternGroup(r,n){return{type:U,subType:"group",patterns:r,loc:n}}isPatternGroup(r){return this.isOfSubType(r,U,"group")}patternGraph(r,n,i){return{type:U,subType:"graph",name:r,patterns:n,loc:i}}isPatternGraph(r){return this.isOfSubType(r,U,"graph")}patternOptional(r,n){return{type:U,subType:"optional",patterns:r,loc:n}}isPatternOptional(r){return this.isOfSubType(r,U,"optional")}patternValues(r,n,i){return{type:U,subType:"values",variables:r,values:n,loc:i}}isPatternValues(r){return this.isOfSubType(r,U,"values")}patternFilter(r,n){return{type:U,subType:"filter",expression:r,loc:n}}isPatternFilter(r){return this.isOfSubType(r,U,"filter")}patternBind(r,n,i){return{type:U,subType:"bind",expression:r,variable:n,loc:i}}isPatternBind(r){return this.isOfSubType(r,U,"bind")}patternUnion(r,n){return{type:U,subType:"union",patterns:r,loc:n}}isPatternUnion(r){return this.isOfSubType(r,U,"union")}patternMinus(r,n){return{type:U,subType:"minus",patterns:r,loc:n}}isPatternMinus(r){return this.isOfSubType(r,U,"minus")}patternService(r,n,i,s){return{type:U,subType:"service",silent:i,name:r,patterns:n,loc:s}}isPatternService(r){return this.isOfSubType(r,U,"service")}}}var ur="query";function sf(e){return class extends e{isQuery(r){return this.isOfType(r,ur)}isQuerySelect(r){return this.isOfSubType(r,ur,"select")}queryConstruct(r,n,i,s,a,o,c){return{type:"query",subType:"construct",context:n,template:i,where:s,solutionModifiers:a,datasets:o,values:c,loc:r}}isQueryConstruct(r){return this.isOfSubType(r,ur,"construct")}isQueryDescribe(r){return this.isOfSubType(r,ur,"describe")}isQueryAsk(r){return this.isOfSubType(r,ur,"ask")}querySelect(r,n){return{type:ur,subType:"select",...r,loc:n}}}}var Ot="solutionModifier";function af(e){return class extends e{isSolutionModifier(r){return this.isOfType(r,Ot)}solutionModifierHaving(r,n){return{type:Ot,subType:"having",having:r,loc:n}}isSolutionModifierHaving(r){return this.isOfSubType(r,Ot,"having")}solutionModifierOrder(r,n){return{type:Ot,subType:"order",orderDefs:r,loc:n}}isSolutionModifierOrder(r){return this.isOfSubType(r,Ot,"order")}solutionModifierLimitOffset(r,n,i){return{type:Ot,subType:"limitOffset",limit:r,offset:n,loc:i}}isSolutionModifierLimitOffset(r){return this.isOfSubType(r,Ot,"limitOffset")}solutionModifierGroup(r,n){return{type:"solutionModifier",subType:"group",groupings:r,loc:n}}isSolutionModifierGroup(r){return this.isOfSubType(r,Ot,"group")}}}var Vt="term";function of(e){return class extends e{__blankNodeCounter=0;resetBlankNodeCounter(){this.__blankNodeCounter=0}isTerm(r){return this.isOfType(r,"term")}termBlank(r,n){let i={type:"term",subType:"blankNode",loc:n};return r===void 0?{...i,label:`g_${this.__blankNodeCounter++}`}:{...i,label:`e_${r}`}}isTermBlank(r){return this.isOfSubType(r,Vt,"blankNode")}termLiteral(r,n,i){return{type:Vt,subType:"literal",value:n,langOrIri:i,loc:r}}isTermLiteral(r){return this.isOfSubType(r,Vt,"literal")}isTermLiteralLangStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri=="string"}isTermLiteralStr(r){return this.isTermLiteral(r)&&typeof r.langOrIri>"u"}isTermLiteralTyped(r){let n=r;return this.isTermLiteral(r)&&typeof n.langOrIri=="object"&&n.langOrIri!==null&&this.isTermNamed(n.langOrIri)}termVariable(r,n){return{type:Vt,subType:"variable",value:r,loc:n}}isTermVariable(r){return this.isOfSubType(r,Vt,"variable")}termNamed(r,n,i){let s={type:Vt,subType:"namedNode",value:n,loc:r};return i===void 0?s:{...s,prefix:i}}isTermNamed(r){return this.isOfSubType(r,Vt,"namedNode")}isTermNamedPrefixed(r){let n=r;return this.isTermNamed(r)&&typeof n.prefix=="string"}}}var Ne="updateOperation";function cf(e){return class extends e{isUpdateOperation(r){return this.isOfType(r,Ne)}updateOperationLoad(r,n,i,s){return{type:Ne,subType:"load",silent:i,source:n,...s&&{destination:s},loc:r}}isUpdateOperationLoad(r){return this.isOfSubType(r,Ne,"load")}updateOperationClearDrop(r,n,i,s){return{type:"updateOperation",subType:r,silent:n,destination:i,loc:s}}updateOperationClear(r,n,i){return this.updateOperationClearDrop("clear",n,r,i)}isUpdateOperationClear(r){return this.isOfSubType(r,Ne,"clear")}updateOperationDrop(r,n,i){return this.updateOperationClearDrop("drop",n,r,i)}isUpdateOperationDrop(r){return this.isOfSubType(r,Ne,"drop")}updateOperationCreate(r,n,i){return{type:"updateOperation",subType:"create",silent:n,destination:r,loc:i}}isUpdateOperationCreate(r){return this.isOfSubType(r,Ne,"create")}updateOperationAddMoveCopy(r,n,i,s,a){return{type:"updateOperation",subType:r,silent:s,source:n,destination:i,loc:a}}updateOperationAdd(r,n,i,s){return this.updateOperationAddMoveCopy("add",r,n,i,s)}isUpdateOperationAdd(r){return this.isOfSubType(r,Ne,"add")}updateOperationMove(r,n,i,s){return this.updateOperationAddMoveCopy("move",r,n,i,s)}isUpdateOperationMove(r){return this.isOfSubType(r,Ne,"move")}updateOperationCopy(r,n,i,s){return this.updateOperationAddMoveCopy("copy",r,n,i,s)}isUpdateOperationCopy(r){return this.isOfSubType(r,Ne,"copy")}updateOperationInsDelDataWhere(r,n,i){return{type:"updateOperation",subType:r,data:n,loc:i}}updateOperationInsertData(r,n){return this.updateOperationInsDelDataWhere("insertdata",r,n)}isUpdateOperationInsertData(r){return this.isOfSubType(r,Ne,"insertdata")}updateOperationDeleteData(r,n){return this.updateOperationInsDelDataWhere("deletedata",r,n)}isUpdateOperationDeleteData(r){return this.isOfSubType(r,Ne,"deletedata")}updateOperationDeleteWhere(r,n){return this.updateOperationInsDelDataWhere("deletewhere",r,n)}isUpdateOperationDeleteWhere(r){return this.isOfSubType(r,Ne,"deletewhere")}updateOperationModify(r,n,i,s,a,o){return{type:"updateOperation",subType:"modify",insert:n??[],delete:i??[],graph:o,where:s,from:a,loc:r}}isUpdateOperationModify(r){return this.isOfSubType(r,Ne,"modify")}}}var Kt=class extends tf(Bt).call(Jh).call(Uh).call(ef).call(rf).call(nf).call(sf).call(af).call(of).call(cf).returns(){alwaysSparql11(t){return!0}isPath(t){return this.isPathPure(t)||this.isTermNamed(t)}isExpression(t){return this.isExpressionPure(t)||this.isTermNamed(t)||this.isTermVariable(t)||this.isTermLiteral(t)}graphNodeIdentifier(t){return t.type==="tripleCollection"?t.identifier:t}triple(t,r,n,i){return{type:"triple",subject:t,predicate:r,object:n,loc:i??this.sourceLocation(t,r,n)}}isTriple(t){return this.isOfType(t,"triple")}datasetClauses(t,r){return{type:"datasetClauses",clauses:t,loc:r}}isDatasetClauses(t){return this.isOfType(t,"datasetClauses")}wildcard(t){return{type:"wildcard",loc:t}}isWildcard(t){return this.isOfType(t,"wildcard")}isTripleCollection(t){return this.isOfType(t,"tripleCollection")}tripleCollectionBlankNodeProperties(t,r,n){return{type:"tripleCollection",subType:"blankNodeProperties",identifier:t,triples:r,loc:n}}isTripleCollectionBlankNodeProperties(t){return this.isOfSubType(t,"tripleCollection","blankNodeProperties")}tripleCollectionList(t,r,n){return{type:"tripleCollection",subType:"list",identifier:t,triples:r,loc:n}}isTripleCollectionList(t){return this.isOfSubType(t,"tripleCollection","list")}graphQuads(t,r,n){return{type:"graph",graph:t,triples:r,loc:n}}isGraphQuads(t){return super.isOfType(t,"graph")}isUpdate(t){return super.isOfType(t,"update")}};function lf(e){let t=e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(r,n,i)=>{if(n){let o=Number.parseInt(n,16);return String.fromCodePoint(o)}let s=Number.parseInt(i,16);if(s<65535)return String.fromCodePoint(s);let a=s-65536;return String.fromCodePoint(55296+(a>>10),56320+(a&1023))});if(/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(t))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint");return t}var re;(function(e){e.BOOLEAN="http://www.w3.org/2001/XMLSchema#boolean",e.INTEGER="http://www.w3.org/2001/XMLSchema#integer",e.DECIMAL="http://www.w3.org/2001/XMLSchema#decimal",e.DOUBLE="http://www.w3.org/2001/XMLSchema#double",e.STRING="http://www.w3.org/2001/XMLSchema#string",e.FIRST="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",e.REST="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",e.NIL="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",e.TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"})(re||(re={}));var Ji=class extends zr{};var w=new Kt,Ui=new Ji;function eo(e){if(w.isExpressionAggregate(e))return[e];if(w.isExpressionOperator(e)){let t=[];for(let r of e.args)t.push(...eo(r));return t}return[]}function Ua(e){return w.isTerm(e)&&w.isTermVariable(e)?e.value:w.isExpression(e)?w.isExpressionAggregate(e)&&w.isTermVariable(e.expression[0])?e.expression[0].value:void 0:e.variable.value}function uf(e,t){if(w.isExpressionOperator(e))for(let r of e.args)uf(r,t);else w.isTerm(e)&&w.isTermVariable(e)&&t.add(e.value)}function pf(e){if(e.variables.length===1&&w.isWildcard(e.variables[0])){if(e.solutionModifiers.group!==void 0)throw new Error("GROUP BY not allowed with wildcard");return}let t=e.variables,r=t.flatMap(s=>w.isTerm(s)?[]:eo(s.expression)).some(s=>s.aggregation==="count"&&!s.expression.some(a=>w.isWildcard(a))),n=e.solutionModifiers.group;if(r||n){for(let s of t)if(w.isTerm(s)){if(!n||!n.groupings.map(a=>Ua(a)).includes(Ua(s)))throw new Error("Variable not allowed in projection")}else if(eo(s.expression).length===0){let a=new Set;uf(s.expression,a);for(let o of a)if(!n||!n.groupings.map(c=>Ua(c)).includes(o))throw new Error(`Use of ungrouped variable in projection of operation (?${o})`)}}let i=e.where.patterns.filter(s=>s.type==="query");if(i.length>0){let s=new Set;for(let c of t)"variable"in c&&s.add(c.variable.value);let a=i.flatMap(c=>c.variables).map(c=>w.isTerm(c)?c.value:w.isWildcard(c)?"*":c.variable.value),o=new Set(a);for(let c of s)if(o.has(c))throw new Error(`Target id of 'AS' (?${c}) already used in subquery`)}}function hf(e,t){function r(n){hf(n,t)}if(e!==void 0)if(Array.isArray(e))for(let n of e)r(n);else if(w.isQuery(e))w.isQuerySelect(e)||w.isQueryDescribe(e)?r([...e.variables.some(n=>w.isWildcard(n))?[e.where]:e.variables,e.solutionModifiers.group,e.values]):r(e.solutionModifiers.group);else if(w.isTriple(e))r([e.subject,e.predicate,e.object]);else if(w.isPathPure(e))r(e.items);else if(w.isTripleCollection(e))r([e.identifier,...e.triples]);else if(w.isSolutionModifierGroup(e))r(e.groupings.filter(n=>"variable"in n).map(n=>n.variable));else if(w.isSolutionModifierHaving(e))r(e.having);else if(w.isSolutionModifierOrder(e))r(e.orderDefs.map(n=>n.expression));else if(w.isPatternValues(e))for(let n of Object.keys(e.values.at(0)??{}))t.add(n);else w.isPatternBgp(e)?r(e.triples):w.isPatternGroup(e)||w.isPatternUnion(e)||w.isPatternOptional(e)?r(e.patterns):w.isPatternService(e)||w.isPatternGraph(e)?r([e.name,...e.patterns]):w.isPatternBind(e)?r(e.variable):w.isTermVariable(e)&&t.add(e.value)}function ff(e){for(let[r,n]of e.entries())if(w.isPatternBind(n)&&r>0&&w.isPatternBgp(e[r-1])){let i=e[r-1],s=[];if(Ui.visitNodeSpecific(i,{},{term:{variable:{visitor:a=>{s.push(a)}}}}),s.some(a=>a.value===n.variable.value))throw new Error(`Variable used to bind is already bound (?${n.variable.value})`)}let t=new Set;for(let r of e)if(w.isPatternBind(r)){if(t.has(r.variable.value))throw new Error(`Variable used to bind is already bound (?${r.variable.value})`)}else hf(r,t)}function es(e){let t=new Set;for(let r of e.updates){if(!r.operation)continue;let n=r.operation;if(n.subType==="insertdata"){let i=new Set;Ui.visitNodeSpecific(n,{},{term:{blankNode:{visitor:s=>{if(i.add(s.label),t.has(s.label))throw new Error("Detected reuse blank node across different INSERT DATA clauses")}}}});for(let s of i)t.add(s)}}}function df(e){let t=new Map,r=[{}],n=()=>r.at(-1);function i(a){let o=new Set;return Ui.visitNodeSpecific(a,{},{term:{blankNode:{visitor:c=>{o.add(c.label)}}}}),o}let s={preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop(),r[r.length-1]={}}};Ui.visitNodeSpecific(e,{query:{preVisitor:()=>({continue:!1})},pattern:s},{pattern:{bgp:{preVisitor:a=>{let o=n();for(let c of i(a)){let l=t.get(c);if(l!==void 0&&l!==o)throw new Error(`Detected reuse of blank node across two different basic graph patterns (_:${c.replace(/^[eg]_/u,"")})`);t.set(c,o)}return{continue:!1}},visitor:()=>{}},filter:{preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop()}}}})}var JO={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function Ur(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>JO[r])}"`}var St={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>{let a=t(ns);return n(()=>i([{ALT:()=>{let o=r(F.langTag);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o.image.slice(1).toLowerCase()))}},{ALT:()=>{r(g.hathat);let o=t($);return e(()=>s.astFactory.termLiteral(s.astFactory.sourceLocation(a,o),a.value,o))}}]))??a},gImpl:({SUBRULE:e,PRINT:t,PRINT_WORD:r})=>(n,{astFactory:i})=>{!n.langOrIri||typeof n.langOrIri=="string"?(i.printFilter(n,()=>{r(""),t(Ur(n.value))}),typeof n.langOrIri=="string"&&i.printFilter(n,()=>t("@",n.langOrIri))):i.isSourceLocationNoMaterialize(n.langOrIri.loc)?i.printFilter(n,()=>{r(n.value)}):(i.printFilter(n,()=>{r(""),t(Ur(n.value),"^^")}),e($,n.langOrIri))}},Ht={name:"numericLiteral",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mf)},{ALT:()=>e(ts)},{ALT:()=>e(rs)}])},mf={name:"numericLiteralUnsigned",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integer),re.INTEGER]},{ALT:()=>[t(F.decimal),re.DECIMAL]},{ALT:()=>[t(F.double),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},ts={name:"numericLiteralPositive",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integerPositive),re.INTEGER]},{ALT:()=>[t(F.decimalPositive),re.DECIMAL]},{ALT:()=>[t(F.doublePositive),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},rs={name:"numericLiteralNegative",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(F.integerNegative),re.INTEGER]},{ALT:()=>[t(F.decimalNegative),re.DECIMAL]},{ALT:()=>[t(F.doubleNegative),re.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Wt={name:"booleanLiteral",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(Yi)},{ALT:()=>t(Xi)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),re.BOOLEAN)))}},ns={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(F.stringLiteral1);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(F.stringLiteral2);return[s,s.image.slice(1,-1)]}},{ALT:()=>{let s=t(F.stringLiteralLong1);return[s,s.image.slice(3,-3)]}},{ALT:()=>{let s=t(F.stringLiteralLong2);return[s,s.image.slice(3,-3)]}}]);return e(()=>{let s=n.astFactory,a=i[1].replaceAll(/\\([tnrbf"'\\])/gu,(o,c)=>{switch(c){case"t":return" ";case"n":return` +`;case"r":return"\r";case"b":return"\b";case"f":return"\f";default:return c}});return s.termLiteral(s.sourceLocation(i[0]),a)})}},$={name:"iri",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(pr)},{ALT:()=>e(to)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(to,t):e(pr,t)},pr={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(F.iriRef);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),n.image.slice(1,-1)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("<",t.value,">"))}},to={name:"prefixedName",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{function i(s){if(!n.skipValidation&&n.prefixes[s]===void 0)throw new Error(`Unknown prefix: ${s}`)}return r([{ALT:()=>{let s=t(F.pNameLn);return e(()=>{let a=s.image.indexOf(":"),o=s.image.slice(0,a),c=s.image.slice(a+1);return i(o),n.astFactory.termNamed(n.astFactory.sourceLocation(s),c,o)})}},{ALT:()=>{let s=t(F.pNameNs);return e(()=>{let a=s.image.slice(0,-1);return i(a),n.astFactory.termNamed(n.astFactory.sourceLocation(s),"",a)})}}])},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(t.prefix,":",t.value))}},UO=Symbol("canCreateBlankNodes"),is={name:"blankNode",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let s=t(F.blankNodeLabel);return e(()=>n.astFactory.termBlank(s.image.slice(2),n.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=t(F.anon);return e(()=>n.astFactory.termBlank(void 0,n.astFactory.sourceLocation(s)))}}]);return e(()=>{if(!n.parseMode.has("canCreateBlankNodes"))throw new Error("Blank nodes are not allowed in this context")}),i},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e("_:",t.label.replace(/^e_/u,"")))}},zt={name:"VerbA",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(lr);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),re.TYPE,void 0))}};var De={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(ro))},{ALT:()=>n.push(e(no))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(ro,n):e(no,n)}},ro={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(li),s=r(pr);return e(()=>n.astFactory.contextDefinitionBase(n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BASE ")),e($,n.value),i.printFilter(n,()=>r())}},no={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(ui),s=t(F.pNameNs).image.slice(0,-1),a=r(pr);return e(()=>(n.prefixes[s]=a.value,n.astFactory.contextDefinitionPrefix(n.astFactory.sourceLocation(i,a),s,a)))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("PREFIX ",`${n.key}: `)}),e($,n.value),i.printFilter(n,()=>r())}},so={name:"verb",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Tt)},{ALT:()=>e(zt)}])},ue={name:"varOrTerm",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(W)},{ALT:()=>e(io)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(W,t):e(io,t)},Tt={name:"varOrIri",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(W)},{ALT:()=>e($)}])},W={name:"var",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(F.var1)},{ALT:()=>t(F.var2)}]);return e(()=>n.astFactory.termVariable(i.image.slice(1),n.astFactory.sourceLocation(i)))},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(`?${t.value}`))}},io={name:"graphTerm",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t($)},{ALT:()=>t(St)},{ALT:()=>t(Ht)},{ALT:()=>t(Wt)},{GATE:()=>i.parseMode.has("canCreateBlankNodes"),ALT:()=>t(is)},{ALT:()=>{let s=r(F.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(s),re.NIL))}}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e($,t):r.isTermLiteral(t)?e(St,t):e(is,t)}};function ao(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i,OR:s})=>a=>{let o=i(t);return s([{ALT:()=>{let c=n(Tf);return r(()=>a.astFactory.wrap({clauseType:"default",value:c},a.astFactory.sourceLocation(o,c)))}},{ALT:()=>{let c=n(vf);return r(()=>a.astFactory.wrap({clauseType:"named",value:c.val},a.astFactory.sourceLocation(o,c)))}}])}}}var gf=ao("datasetClause",gi),Tf={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(co)},yf=ao("usingClause",$i);function oo(e,t,r){return{name:e,impl:({ACTION:n,MANY:i,SUBRULE:s})=>a=>{let o=[];return i(()=>{let c=s(t);o.push(c)}),n(()=>a.astFactory.datasetClauses(o.map(c=>c.val),a.astFactory.sourceLocation(...o)))},gImpl:({SUBRULE:n,PRINT_WORD:i})=>(s,{astFactory:a})=>{for(let o of s.clauses)a.printFilter(s,()=>i(r)),o.clauseType==="named"&&a.printFilter(s,()=>i("NAMED")),n($,o.value)}}}var Be=oo("datasetClauses",gf,"FROM"),ss=oo("usingClauses",yf,"USING"),vf={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.named),s=t(co);return e(()=>n.astFactory.wrap(s,n.astFactory.sourceLocation(i,s)))}},co={name:"sourceSelector",impl:({SUBRULE:e})=>()=>e($)};function G(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(g.LParen);let a=r(R),o=n(g.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function Qe(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>{let a=r(e);r(g.LParen);let o=n(R);r(g.comma);let c=i(R),l=r(g.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o,c],s.astFactory.sourceLocation(a,l)))}}}function lo(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,CONSUME1:n,CONSUME2:i,SUBRULE1:s,SUBRULE2:a,SUBRULE3:o})=>c=>{let l=r(e);r(g.LParen);let p=s(R);n(g.comma);let h=a(R);i(g.comma);let d=o(R),m=r(g.RParen);return t(()=>c.astFactory.expressionOperation(l.image,[p,h,d],c.astFactory.sourceLocation(l,m)))}}}function uo(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e);n(g.LParen);let a=r(W),o=n(g.RParen);return t(()=>i.astFactory.expressionOperation(s.image,[a],i.astFactory.sourceLocation(s,o)))}}}function po(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,OR:n,SUBRULE:i})=>s=>{let a=r(e);return n([{ALT:()=>{r(g.LParen);let o=i(R),c=r(g.RParen);return t(()=>s.astFactory.expressionOperation(a.image,[o],s.astFactory.sourceLocation(a,c)))}},{ALT:()=>{let o=r(F.nil);return t(()=>s.astFactory.expressionOperation(a.image,[],s.astFactory.sourceLocation(a,o)))}}])}}}function hr(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r})=>n=>{let i=r(e),s=r(F.nil);return t(()=>n.astFactory.expressionOperation(i.image,[],n.astFactory.sourceLocation(i,s)))}}}function as(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let s=r(e),a=n(ls);return t(()=>i.astFactory.expressionOperation(s.image,a.val,i.astFactory.sourceLocation(s,a)))}}}function os(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,CONSUME1:a,OPTION:o,CONSUME2:c})=>l=>{let p=r(e);r(g.LParen);let h=n(R);a(g.comma);let d=i(R),m=o(()=>(c(g.comma),s(R))),A=r(g.RParen);return t(()=>l.astFactory.expressionOperation(p.image,m?[h,d,m]:[h,d],l.astFactory.sourceLocation(p,A)))}}}function ho(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:s,SUBRULE4:a,CONSUME1:o,OPTION:c,CONSUME2:l,CONSUME3:p})=>h=>{let d=r(e);r(g.LParen);let m=n(R);o(g.comma);let A=i(R);l(g.comma);let b=s(R),y=c(()=>(p(g.comma),a(R))),v=r(g.RParen);return t(()=>h.astFactory.expressionOperation(d.image,y?[m,A,b,y]:[m,A,b],h.astFactory.sourceLocation(d,v)))}}}function cs(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(e),a=r(Y);return t(()=>i.astFactory.expressionPatternOperation(s.image,a,i.astFactory.sourceLocation(s,a)))}}}function qt(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n,OPTION:i})=>s=>{let a=r(e);r(g.LParen);let o=i(()=>r(Xe)),c=n(R),l=r(g.RParen);return t(()=>s.astFactory.aggregate(a.image,o!==void 0,c,void 0,s.astFactory.sourceLocation(a,l)))}}}var Af=G(E.str),bf=G(E.lang),xf=Qe(E.langmatches),If=G(E.datatype),Ef=uo(E.bound),Lf=G(E.iri),_f=G(E.uri),Of=po(E.bnode),Sf=hr(E.rand),Nf=G(E.abs),Pf=G(E.ceil),kf=G(E.floor),Rf=G(E.round),Ff=as(E.concat),wf=G(E.strlen),Cf=G(E.ucase),Mf=G(E.lcase),Df=G(E.encode_for_uri),Gf=Qe(E.contains),$f=Qe(E.strstarts),jf=Qe(E.strends),Vf=Qe(E.strbefore),Kf=Qe(E.strafter),Hf=G(E.year),Wf=G(E.month),zf=G(E.day),qf=G(E.hours),Yf=G(E.minutes),Xf=G(E.seconds),Bf=G(E.timezone),Qf=G(E.tz),Zf=hr(E.now),Jf=hr(E.uuid),Uf=hr(E.struuid),ed=G(E.md5),td=G(E.sha1),rd=G(E.sha256),nd=G(E.sha384),id=G(E.sha512),sd=as(E.coalesce),ad=lo(E.if_),od=Qe(E.strlang),cd=Qe(E.strdt),ld=Qe(E.sameterm),ud=G(E.isiri),pd=G(E.isuri),hd=G(E.isblank),fd=G(E.isliteral),dd=G(E.isnumeric);function md(e){return[{ALT:()=>e(us)},{ALT:()=>e(Af)},{ALT:()=>e(bf)},{ALT:()=>e(xf)},{ALT:()=>e(If)},{ALT:()=>e(Ef)},{ALT:()=>e(Lf)},{ALT:()=>e(_f)},{ALT:()=>e(Of)},{ALT:()=>e(Sf)},{ALT:()=>e(Nf)},{ALT:()=>e(Pf)},{ALT:()=>e(kf)},{ALT:()=>e(Rf)},{ALT:()=>e(Ff)},{ALT:()=>e(Td)},{ALT:()=>e(wf)},{ALT:()=>e(yd)},{ALT:()=>e(Cf)},{ALT:()=>e(Mf)},{ALT:()=>e(Df)},{ALT:()=>e(Gf)},{ALT:()=>e($f)},{ALT:()=>e(jf)},{ALT:()=>e(Vf)},{ALT:()=>e(Kf)},{ALT:()=>e(Hf)},{ALT:()=>e(Wf)},{ALT:()=>e(zf)},{ALT:()=>e(qf)},{ALT:()=>e(Yf)},{ALT:()=>e(Xf)},{ALT:()=>e(Bf)},{ALT:()=>e(Qf)},{ALT:()=>e(Zf)},{ALT:()=>e(Jf)},{ALT:()=>e(Uf)},{ALT:()=>e(ed)},{ALT:()=>e(td)},{ALT:()=>e(rd)},{ALT:()=>e(nd)},{ALT:()=>e(id)},{ALT:()=>e(sd)},{ALT:()=>e(ad)},{ALT:()=>e(od)},{ALT:()=>e(cd)},{ALT:()=>e(ld)},{ALT:()=>e(ud)},{ALT:()=>e(pd)},{ALT:()=>e(hd)},{ALT:()=>e(fd)},{ALT:()=>e(dd)},{ALT:()=>e(gd)},{ALT:()=>e(vd)},{ALT:()=>e(Ad)}]}var yt={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(yt);if(n)return e(n);let i=md(t);return r.set(yt,i),e(i)}},gd=os(E.regex),Td=os(E.substr),yd=ho(E.replace),vd=cs(E.exists),Ad=cs(E.notexists),bd={name:ee(E.count.name),impl:({ACTION:e,CONSUME:t,SUBRULE:r,OR:n,OPTION:i})=>s=>{let a=t(E.count);t(g.LParen);let o=i(()=>t(Xe)),c=n([{ALT:()=>{let p=t(g.star);return e(()=>s.astFactory.wildcard(s.astFactory.sourceLocation(p)))}},{ALT:()=>r(R)}]),l=t(g.RParen);return e(()=>{let p=s.astFactory;return s.astFactory.isWildcard(c),p.aggregate(a.image,!!o,c,void 0,s.astFactory.sourceLocation(a,l))})}},xd=qt(E.sum),Id=qt(E.min),Ed=qt(E.max),Ld=qt(E.avg),_d=qt(E.sample),Od={name:ee(E.groupConcat.name),impl:({ACTION:e,CONSUME:t,OPTION1:r,SUBRULE:n,OPTION2:i})=>s=>{let a=t(E.groupConcat);t(g.LParen);let o=r(()=>t(Xe)),c=n(R),l=i(()=>(t(g.semi),t(Zi),t(g.equal),n(ns))),p=t(g.RParen);return e(()=>{let h=s.astFactory;return h.aggregate(a.image,!!o,c,l?.value??" ",h.sourceLocation(a,p))})}},us={name:"aggregate",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=e(()=>n.parseMode.has("inAggregate"));e(()=>n.parseMode.add("inAggregate"));let s=r([{ALT:()=>t(bd)},{ALT:()=>t(xd)},{ALT:()=>t(Id)},{ALT:()=>t(Ed)},{ALT:()=>t(Ld)},{ALT:()=>t(_d)},{ALT:()=>t(Od)}]);return e(()=>!i&&n.parseMode.delete("inAggregate")),e(()=>{if(!n.parseMode.has("canParseAggregate"))throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");if(n.parseMode.has("inAggregate"))throw new Error("An aggregate function is not allowed within an aggregate function.")}),s},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(r.aggregation.toUpperCase(),"("),r.distinct&&t("DISTINCT")});let i=r.expression[0];n.isWildcard(i)?n.printFilter(r,()=>t("*")):e(R,i),n.isExpressionAggregateSeparator(r)&&n.printFilter(r,()=>t(";","SEPARATOR","=",Ur(r.separator))),n.printFilter(r,()=>t(")"))}};var hs={name:"path",impl:({SUBRULE:e})=>()=>e(Pd)},vt={name:"path",gImpl:({PRINT:e,SUBRULE:t})=>(r,{astFactory:n},i=!0)=>{if(n.isTerm(r)&&n.isTermNamed(r))t($,r);else{switch(n.printFilter(r,()=>i&&e("(")),r.subType){case"|":case"/":{let[s,...a]=r.items;t(vt,s,i);for(let o of a)n.printFilter(r,()=>e(r.subType)),t(vt,o,i);break}case"^":n.printFilter(r,()=>e("^")),t(vt,r.items[0],i);break;case"?":case"*":case"+":t(vt,r.items[0],i),n.printFilter(r,()=>e(r.subType));break;case"!":n.printFilter(r,()=>e("!")),n.printFilter(r,()=>e("(")),t(vt,r.items[0],!1),n.printFilter(r,()=>e(")"));break}n.printFilter(r,()=>i&&e(")"))}}};function mo(e,t,r,n){return{name:e,impl:({ACTION:i,CONSUME:s,SUBRULE1:a,SUBRULE2:o,MANY:c})=>l=>{let p=a(n),h=p,d=[];return c(()=>{s(t),h=o(n),d.push(h)}),i(()=>d.length===0?p:l.astFactory.path(r,[p,...d],l.astFactory.sourceLocation(p,h)))}}}var Sd={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>s=>i([{ALT:()=>r(fo)},{ALT:()=>{let a=t(g.hat),o=n(fo);return e(()=>s.astFactory.path("^",[o],s.astFactory.sourceLocation(a,o)))}}])},Nd=mo("pathSequence",g.slash,"/",Sd),Pd=mo("pathAlternative",g.pipe,"|",Nd),fo={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(Rd),s=r(()=>t(kd));return e(()=>s===void 0?i:n.astFactory.path(s.image,[i],n.astFactory.sourceLocation(i,s)))}},kd={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(g.question)},{ALT:()=>e(g.star)},{ALT:()=>e(g.opPlus)}])},Rd={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e($)},{ALT:()=>e(zt)},{ALT:()=>e(Fd)},{ALT:()=>{t(g.LParen);let n=e(hs);return t(g.RParen),n}}])},Fd={name:"pathNegatedPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,SUBRULE3:i,OR:s,MANY:a})=>o=>{let c=t(g.exclamation);return s([{ALT:()=>{let l=r(ps);return e(()=>o.astFactory.path("!",[l],o.astFactory.sourceLocation(c,l)))}},{ALT:()=>{let l=t(g.LParen),p=n(ps),h=[];a(()=>{t(g.pipe);let m=i(ps);h.push(m)});let d=t(g.RParen);return e(()=>{let m=o.astFactory;return h.length===0?m.path("!",[p],m.sourceLocation(c,d)):m.path("!",[m.path("|",[p,...h],m.sourceLocation(l,d))],m.sourceLocation(c,d))})}}])}},ps={name:"pathOneInPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r($)},{ALT:()=>r(zt)},{ALT:()=>{let o=t(g.hat),c=s([{ALT:()=>n($)},{ALT:()=>n(zt)}]);return e(()=>a.astFactory.path("^",[c],a.astFactory.sourceLocation(o,c)))}}])};function wd(e){return({ACTION:t,AT_LEAST_ONE:r,SUBRULE:n,CONSUME:i,OPTION:s})=>a=>{let o=[],c=!0,l;return r({GATE:()=>c,DEF:()=>{c=!1;let p=n(e);t(()=>{o.push(...p)}),s(()=>{l=i(g.dot),c=!0})}}),t(()=>a.astFactory.patternBgp(o,a.astFactory.sourceLocation(...o,l)))}}var ot={name:"triplesBlock",impl:e=>t=>wd(Dd)(e)(t),gImpl:({SUBRULE:e,PRINT_WORD:t,HANDLE_LOC:r,NEW_LINE:n})=>(i,{astFactory:s})=>{for(let[a,o]of i.triples.entries())r(o,()=>{let c=i.triples.at(a+1);s.isTripleCollection(o)?(e(at,o),s.printFilter(o,()=>{t("."),n()})):(e(at,o.subject),s.printFilter(o,()=>t("")),s.isTerm(o.predicate)&&s.isTermVariable(o.predicate)?e(ue,o.predicate):e(vt,o.predicate,void 0),s.printFilter(o,()=>t("")),e(at,o.object),c===void 0||s.isTripleCollection(c)||!s.isSourceLocationNoMaterialize(c.subject.loc)?s.printFilter(i,()=>{t("."),n()}):s.isSourceLocationNoMaterialize(c.predicate.loc)?s.printFilter(i,()=>t(",")):s.printFilter(i,()=>{t(";"),n()}))})}};function Cd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>s=>i([{ALT:()=>{let a=n(ue),o=n(t?ds:fs,r(()=>s.astFactory.dematerialized(a)));return r(()=>(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}},{ALT:()=>{let a=n(t?vo:yo),o=n(t?jd:$d,r(()=>s.astFactory.graphNodeIdentifier(a)));return r(()=>o.length===0?[a]:(o[0].subject=a,o[0].loc=s.astFactory.sourceLocation(a,o[0]),o))}}])}}var Md=Cd("triplesSameSubject",!1),Dd=Cd("triplesSameSubjectPath",!0),Yt={name:"triplesTemplate",impl:wd(Md)};function Gd(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,s)=>n(()=>r(t?ds:fs,s))??[]}}var $d=Gd("propertyList",!1),jd=Gd("propertyListPath",!0);function Vd(e,t){return{name:e,impl:({ACTION:r,CONSUME:n,AT_LEAST_ONE:i,SUBRULE1:s,MANY2:a,OR1:o})=>(c,l)=>{let p=[],h=!0;return i({GATE:()=>h,DEF:()=>{h=!1;let d=t?o([{ALT:()=>s(Kd)},{ALT:()=>s(Hd)}]):s(so),m=s(t?qd:zd,l,d);a(()=>{n(g.semi),h=!0}),r(()=>{p.push(...m)})}}),p}}}var fs=Vd("propertyListNotEmpty",!1),ds=Vd("propertyListPathNotEmpty",!0),Kd={name:"verbPath",impl:({SUBRULE:e})=>()=>e(hs)},Hd={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(W)};function Wd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,AT_LEAST_ONE_SEP:i})=>(s,a,o)=>{let c=[];return i({SEP:g.comma,DEF:()=>{let l=n(t?Bd:Xd,a,o);r(()=>{c.push(l)})}}),c}}}var zd=Wd("objectList",!1),qd=Wd("objectListPath",!0);function Yd(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,s,a)=>{let o=n(t?at:Ao);return r(()=>i.astFactory.triple(s,a,o))}}}var Xd=Yd("object",!1),Bd=Yd("objectPath",!0);function Qd(e,t){return{name:e,impl:({ACTION:r,AT_LEAST_ONE:n,SUBRULE:i,CONSUME:s})=>a=>{let o=[],c=s(g.LParen);n(()=>{o.push(i(t?at:Ao))});let l=s(g.RParen);return r(()=>{let p=a.astFactory,h=[],d=p.termNamed(p.sourceLocation(),re.FIRST,void 0),m=p.termNamed(p.sourceLocation(),re.REST,void 0),A=p.termNamed(p.sourceLocation(),re.NIL,void 0),b=p.termBlank(void 0,p.sourceLocation()),y=b;for(let[v,x]of o.entries()){let T=v===o.length-1,I=p.triple(y,d,x);if(h.push(I),T){let S=p.triple(y,m,A);h.push(S)}else{let S=p.termBlank(void 0,p.sourceLocation()),C=p.triple(y,m,S);h.push(C),y=S}}return p.tripleCollectionList(b,h,p.sourceLocation(c,l))})},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>n("("));for(let[a,o]of i.triples.entries())a%2===0&&(s.printFilter(i,()=>n("")),r(at,o.object));s.printFilter(i,()=>n(")"))}}}var Zd=Qd("collection",!1),go=Qd("collectionPath",!0);function Jd(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?go:Zd)},{ALT:()=>r(t?To:em)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(go,n):r(To,n)}}var yo=Jd("triplesNode",!1),vo=Jd("triplesNodePath",!0);function Ud(e,t){let r=t?ds:fs;return{name:e,impl:({ACTION:n,SUBRULE:i,CONSUME:s})=>a=>{let o=s(g.LSquare),c=n(()=>a.astFactory.termBlank(void 0,a.astFactory.sourceLocation())),l=i(r,c),p=s(g.RSquare);return n(()=>a.astFactory.tripleCollectionBlankNodeProperties(c,l,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:n,PRINT:i,PRINT_WORD:s,HANDLE_LOC:a,PRINT_ON_EMPTY:o,NEW_LINE:c})=>(l,p)=>{let{astFactory:h,indentInc:d}=p;h.printFilter(l,()=>{p[H]+=d,i("["),c()});for(let m of l.triples)a(m,()=>{h.isTerm(m.predicate)&&h.isTermVariable(m.predicate)?n(ue,m.predicate):n(vt,m.predicate,void 0),h.printFilter(m,()=>s("")),n(at,m.object),h.printFilter(l,()=>{s(";"),c()})});h.printFilter(l,()=>{p[H]-=d,o("]")})}}}var em=Ud("blankNodePropertyList",!1),To=Ud("blankNodePropertyListPath",!0);function tm(e,t){let r=t?vo:yo;return{name:e,impl:({SUBRULE:n,OR:i})=>s=>i([{ALT:()=>n(ue)},{GATE:()=>s.parseMode.has("canCreateBlankNodes"),ALT:()=>n(r)}]),gImpl:({SUBRULE:n})=>(i,{astFactory:s})=>{s.isTerm(i)?n(ue,i):n(r,i)}}}var Ao=tm("graphNode",!1),at=tm("graphNodePath",!0);var Ge={name:"whereClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OPTION:n})=>i=>{let s=n(()=>r(_t)),a=t(Y);return e(()=>i.astFactory.wrap(a,i.astFactory.sourceLocation(s,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("WHERE")),e(Y,r.val)}},Y={name:"groupGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>{let s=r(g.LCurly),a=n([{ALT:()=>[t(Po)]},{ALT:()=>t(nm)}]),o=r(g.RCurly);return e(()=>!i.skipValidation&&df(a)),e(()=>i.astFactory.patternGroup(a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>{s[H]+=o,t("{"),r()});for(let c of i.patterns)e(rm,c);a.printFilter(i,()=>{s[H]-=o,n("}")})}},rm={name:"generatePattern",gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{t.type==="query"?e(gr,r.querySelect({context:[],datasets:r.datasetClauses([],r.sourceLocation()),where:t.where,variables:t.variables,solutionModifiers:t.solutionModifiers,values:t.values,distinct:t.distinct,reduced:t.reduced},t.loc)):t.subType==="group"?e(Y,t):t.subType==="bgp"?e(ot,t):e(So,t)}},nm={name:"groupGraphPatternSub",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:c})=>l=>{let p=[],h=a(()=>i(ot));return h&&p.push(h),n(()=>{let d=t(So);p.push(d),o(()=>r(g.dot));let m=c(()=>s(ot));m&&p.push(m)}),e(()=>!l.skipValidation&&ff(p)),p}},So={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(_o)},{ALT:()=>e(bo)},{ALT:()=>e(Lo)},{ALT:()=>e(xo)},{ALT:()=>e(Io)},{ALT:()=>e(Oo)},{ALT:()=>e(Eo)},{ALT:()=>e(fr)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e(_o,t);break;case"optional":e(bo,t);break;case"minus":e(Lo,t);break;case"graph":e(xo,t);break;case"service":e(Io,t);break;case"filter":e(Oo,t);break;case"bind":e(Eo,t);break;case"values":e(fr,t);break}}},bo={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ji),s=t(Y);return e(()=>n.astFactory.patternOptional(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("OPTIONAL")),e(Y,n.patternGroup(r.patterns,r.loc))}},xo={name:"graphGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.graph),s=t(Tt),a=t(Y);return e(()=>n.astFactory.patternGraph(s,a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(ue,r.name),e(Y,n.patternGroup(r.patterns,r.loc))}},Io={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Vi),a=n(()=>(r(mt),!0))??!1,o=t(Tt),c=t(Y);return e(()=>i.astFactory.patternService(o,c.patterns,a,i.astFactory.sourceLocation(s,c)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("SERVICE"),r.silent&&t("SILENT")}),e(ue,r.name),e(Y,n.patternGroup(r.patterns,r.loc))}},Eo={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ki);r(g.LParen);let s=t(R);r(Lt);let a=t(W),o=r(g.RParen);return e(()=>n.astFactory.patternBind(s,a,n.astFactory.sourceLocation(i,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BIND","(")),e(R,n.expression),i.printFilter(n,()=>t("AS")),e(W,n.variable),i.printFilter(n,()=>{t(")"),r()})}},fr={name:"inlineData",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ii),s=t(im);return e(()=>(s.loc=n.astFactory.sourceLocation(i,s),s))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,NEW_LINE:n,PRINT_ON_OWN_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:c}=a,l=s.variables,p=l.length===1;o.printFilter(s,()=>{r("VALUES",p?"":"( ")});for(let h of l)o.printFilter(s,()=>t("")),e(ue,h),o.printFilter(s,()=>t(""));o.printFilter(s,()=>{a[H]+=c,t(p?"":")","{"),n()});for(let h of s.values){o.printFilter(s,()=>!p&&t("("));for(let d of l){let m=d.value;h[m]===void 0?o.printFilter(s,()=>t("UNDEF")):(e(at,h[m]),o.printFilter(s,()=>t("")))}o.printFilter(s,()=>{t(p?"":")"),n()})}o.printFilter(s,()=>{a[H]-=c,i("}")})}},im={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(sm)},{ALT:()=>e(am)}])},sm={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let s=[],a=t(W);r(g.LCurly),n(()=>{let c=t(No);e(()=>{s.push(Object.assign(Object.create(null),{[a.value]:c}))})});let o=r(g.RCurly);return e(()=>i.astFactory.patternValues([a],s,i.astFactory.sourceLocation(a,o)))}},am={name:"inlineDataFull",impl:({ACTION:e,OR:t,MANY1:r,MANY2:n,MANY3:i,MANY4:s,SUBRULE:a,CONSUME1:o,CONSUME2:c})=>l=>{let p=[],h=[];return t([{ALT:()=>{let d=o(F.nil);o(g.LCurly),r(()=>{c(F.nil),p.push(Object.create(null))});let m=o(g.RCurly);return e(()=>l.astFactory.patternValues(h,p,l.astFactory.sourceLocation(d,m)))}},{ALT:()=>{let d=o(g.LParen);n(()=>{h.push(a(W))}),o(g.RParen),c(g.LCurly),i(()=>{let A=0,b=Object.create(null);c(g.LParen),s(()=>{e(()=>{if(!l.skipValidation&&A>=h.length)throw new Error("Number of dataBlockValues does not match number of variables. Too much values.")});let y=a(No);e(()=>{b[h[A].value]=y,A++})}),c(g.RParen),e(()=>{if(p.push(b),!l.skipValidation&&h.length!==A)throw new Error("Number of dataBlockValues does not match number of variables. Too few values.")})});let m=c(g.RCurly);return e(()=>l.astFactory.patternValues(h,p,l.astFactory.sourceLocation(d,m)))}}])}},No={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e($)},{ALT:()=>e(St)},{ALT:()=>e(Ht)},{ALT:()=>e(Wt)},{ALT:()=>{t(Hi)}}])},Lo={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Wi),s=t(Y);return e(()=>n.astFactory.patternMinus(s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("MINUS")),e(Y,n.patternGroup(r.patterns,r.loc))}},_o={name:"groupOrUnionGraphPattern",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>{let a=[],o=r(Y);return a.push(o),t(()=>{i(zi);let c=n(Y);a.push(c)}),e(()=>a.length===1?a[0]:s.astFactory.patternUnion(a,s.astFactory.sourceLocation(o,a.at(-1))))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isPatternUnion(r)){let[i,...s]=r.patterns;e(Y,i);for(let a of s)n.printFilter(r,()=>t("UNION")),e(Y,a)}else e(Y,r)}},Oo={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(qi),s=t(en);return e(()=>n.astFactory.patternFilter(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("FILTER (")),e(R,n.expression),i.printFilter(n,()=>{t(")"),r()})}},en={name:"constraint",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mr)},{ALT:()=>e(yt)},{ALT:()=>e(ms)}])},ms={name:"functionCall",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t($),i=t(dr);return e(()=>r.astFactory.expressionFunctionCall(n,i.val.args,i.val.distinct,r.astFactory.sourceLocation(n,i)))}};var dr={name:"argList",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,OPTION:n,OR:i,AT_LEAST_ONE_SEP:s})=>a=>i([{ALT:()=>{let o=t(F.nil);return e(()=>a.astFactory.wrap({args:[],distinct:!1},a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=[],c=t(g.LParen),l=n(()=>(t(Xe),!0))??!1;s({SEP:g.comma,DEF:()=>{let h=r(R);o.push(h)}});let p=t(g.RParen);return e(()=>a.astFactory.wrap({args:o,distinct:l},a.astFactory.sourceLocation(c,p)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("("),r.val.distinct&&t("DISTINCT")});let[i,...s]=r.val.args;i&&e(R,i);for(let a of s)n.printFilter(r,()=>t(",")),e(R,a);n.printFilter(r,()=>t(")"))}},ls={name:"expressionList",impl:({ACTION:e,CONSUME:t,MANY:r,OR:n,SUBRULE1:i,SUBRULE2:s})=>a=>n([{ALT:()=>{let o=t(F.nil);return e(()=>a.astFactory.wrap([],a.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=t(g.LParen),l=[i(R)];r(()=>{t(g.comma);let h=s(R);l.push(h)});let p=t(g.RParen);return e(()=>a.astFactory.wrap(l,a.astFactory.sourceLocation(o,p)))}}])},eS=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),tS=new Set(["in","notin","||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),om={"!":"",uplus:"+",uminus:"-"},R={name:"expression",impl:({SUBRULE:e})=>()=>e(cm),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isTerm(r))e(ue,r);else if(n.isExpressionPatternOperation(r)){let i=r.args;n.printFilter(r,()=>t(r.operator==="exists"?"EXISTS":"NOT EXISTS")),e(Y,i)}else if(n.isExpressionFunctionCall(r))e(Mo,r);else if(n.isExpressionAggregate(r))e(us,r);else if(tS.has(r.operator)){let[i,...s]=r.args;n.printFilter(r,()=>t("(")),e(R,i),n.printFilter(r,()=>{r.operator==="notin"?t("NOT IN"):r.operator==="in"?t("IN"):t(r.operator.toUpperCase())}),s.length===1&&eS.has(r.operator)?e(R,s[0]):e(dr,n.wrap({args:s,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(typeof om[r.operator]=="string"){let[i]=r.args;n.printFilter(r,()=>t(om[r.operator]||r.operator.toUpperCase())),e(R,i)}else{n.printFilter(r,()=>t(r.operator.toUpperCase(),"("));let[i,...s]=r.args;i&&e(R,i);for(let a of s)n.printFilter(r,()=>t(",")),e(R,a);n.printFilter(r,()=>t(")"))}}};function tn(e,t,r,n){let i=e();return n(()=>{let s=t();r(()=>{i=s(i)})}),i}var cm={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>s=>tn(()=>n(ko),()=>{r(g.logicOr);let a=i(ko);return o=>e(()=>s.astFactory.expressionOperation("||",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},ko={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>s=>tn(()=>r(Ro),()=>{i(g.logicAnd);let a=n(Ro);return o=>e(()=>s.astFactory.expressionOperation("&&",[o,a],s.astFactory.sourceLocation(o,a)))},e,t)},Ro={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(lm)},lm={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:s,OR2:a,OR3:o})=>c=>{let l=r(Fo);return i(()=>s([{ALT:()=>{let h=a([{ALT:()=>t(g.equal)},{ALT:()=>t(g.notEqual)},{ALT:()=>t(g.lessThan)},{ALT:()=>t(g.greaterThan)},{ALT:()=>t(g.lessThanEqual)},{ALT:()=>t(g.greaterThanEqual)}]),d=n(Fo);return e(()=>c.astFactory.expressionOperation(h.image,[l,d],c.astFactory.sourceLocation(l,d)))}},{ALT:()=>{let h=o([{ALT:()=>t(Bi)},{ALT:()=>t(Qi)}]),d=r(ls);return e(()=>c.astFactory.expressionOperation(h.image,[l,...d.val],c.astFactory.sourceLocation(l,d)))}}]))??l}},Fo={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(um)},um={name:"additiveExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,MANY1:s,MANY2:a,OR1:o,OR2:c,OR3:l,OR4:p})=>h=>tn(()=>n(wo),()=>o([{ALT:()=>{let d=c([{ALT:()=>r(g.opPlus)},{ALT:()=>r(g.opMinus)}]),m=i(wo);return e(()=>A=>h.astFactory.expressionOperation(d.image,[A,m],h.astFactory.sourceLocation(A,m)))}},{ALT:()=>{let{operator:d,startInt:m}=l([{ALT:()=>{let b=t(ts);return e(()=>(b.value=b.value.replace(/^\+/u,""),{operator:"+",startInt:b}))}},{ALT:()=>{let b=t(rs);return e(()=>(b.value=b.value.replace(/^-/u,""),{operator:"-",startInt:b}))}}]),A=tn(()=>e(()=>m),()=>{let b=p([{ALT:()=>r(g.star)},{ALT:()=>r(g.slash)}]),y=n(gs);return v=>e(()=>h.astFactory.expressionOperation(b.image,[v,y],h.astFactory.sourceLocation(v,y)))},e,a);return b=>h.astFactory.expressionOperation(d,[b,A],h.astFactory.sourceLocation(b,A))}}]),e,s)},wo={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:s})=>a=>tn(()=>n(gs),()=>{let o=s([{ALT:()=>t(g.star)},{ALT:()=>t(g.slash)}]),c=i(gs);return l=>({type:"expression",subType:"operation",operator:o.image,args:[l,c],loc:a.astFactory.sourceLocation(l,c)})},e,r)},gs={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:s})=>a=>i([{ALT:()=>r(Co)},{ALT:()=>{let o=s([{ALT:()=>t(g.exclamation)},{ALT:()=>t(g.opPlus)},{ALT:()=>t(g.opMinus)}]),c=n(Co);return e(()=>a.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[c],a.astFactory.sourceLocation(o,c)))}}])},Co={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(mr)},{ALT:()=>e(yt)},{ALT:()=>e(Mo)},{ALT:()=>e(St)},{ALT:()=>e(Ht)},{ALT:()=>e(Wt)},{ALT:()=>e(W)}])},mr={name:"brackettedExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(g.LParen),s=t(R),a=r(g.RParen);return e(()=>(s.loc=n.astFactory.sourceLocation(i,a),s))}},Mo={name:"iriOrFunction",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t($);return r(()=>{let a=t(dr);return e(()=>{let o=a.val.distinct;if(!n.parseMode.has("canParseAggregate")&&o)throw new Error("DISTINCT implies that this function is an aggregated function, which is not allowed in this context.");return{type:"expression",subType:"functionCall",function:i,args:a.val.args,distinct:o,loc:n.astFactory.sourceLocation(i,a)}})})??i},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e($,t):(e($,t.function),e(dr,r.wrap({args:t.args,distinct:t.distinct},t.loc)))}};var $e={name:"solutionModifier",impl:({ACTION:e,SUBRULE:t,OPTION1:r,OPTION2:n,OPTION3:i,OPTION4:s})=>()=>{let a=r(()=>t(Do)),o=n(()=>t(Go)),c=i(()=>t($o)),l=s(()=>t(jo));return e(()=>({...l&&{limitOffset:l},...a&&{group:a},...o&&{having:o},...c&&{order:c}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(Do,t.group),t.having&&e(Go,t.having),t.order&&e($o,t.order),t.limitOffset&&e(jo,t.limitOffset)}},Do={name:"groupClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=[],a=n(Zr);return n(Jr),t(()=>{s.push(r(pm))}),e(()=>({type:"solutionModifier",subType:"group",groupings:s,loc:i.astFactory.sourceLocation(a,s.at(-1))}))},gImpl:({PRINT_WORDS:e,SUBRULE:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("GROUP BY ")});for(let s of n.groupings)i.printFilter(n,()=>e("")),i.isExpression(s)?t(R,s):(i.printFilter(n,()=>e("(")),t(R,s.value),i.printFilter(n,()=>e("AS")),t(W,s.variable),i.printFilter(n,()=>e(")")))}},pm={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s,OR:a})=>o=>a([{ALT:()=>t(yt)},{ALT:()=>t(ms)},{ALT:()=>i(W)},{ALT:()=>{let c=r(g.LParen),l=t(R),p=s(()=>(r(Lt),n(W))),h=r(g.RParen);return e(()=>p!==void 0?{variable:p,value:l,loc:o.astFactory.sourceLocation(c,h)}:l)}}])},Go={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let s=n(Ti),a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(hm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierHaving(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_ON_EMPTY:e,SUBRULE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{e("HAVING ")});for(let i of r.having)t(R,i)}},hm={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(en)},$o={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let s=n(yi);n(Jr);let a=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{a.push(r(fm))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierOrder(a,i.astFactory.sourceLocation(s,a.at(-1))))},gImpl:({PRINT_WORDS:e,PRINT_ON_EMPTY:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("ORDER BY ")});for(let s of n.orderDefs)s.descending?i.printFilter(n,()=>e("DESC")):i.printFilter(n,()=>e("ASC")),i.printFilter(n,()=>e("(")),r(R,s.expression),i.printFilter(n,()=>e(")"))}},fm={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>s=>n([{ALT:()=>{let a=i([{ALT:()=>[!1,r(vi)]},{ALT:()=>[!0,r(Ai)]}]),o=t(mr);return e(()=>({expression:o,descending:a[0],loc:s.astFactory.sourceLocation(a[1],o)}))}},{ALT:()=>{let a=t(en);return e(()=>({expression:a,descending:!1,loc:a.loc}))}},{ALT:()=>{let a=t(W);return e(()=>({expression:a,descending:!1,loc:a.loc}))}}])},jo={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:s})=>a=>s([{ALT:()=>{let o=t(Vo),c=n(()=>t(Ko));return e(()=>a.astFactory.solutionModifierLimitOffset(o.val,c?.val,a.astFactory.sourceLocation(o,...c?[c]:[])))}},{ALT:()=>{let o=r(Ko),c=i(()=>r(Vo));return e(()=>a.astFactory.solutionModifierLimitOffset(c?.val,o.val,a.astFactory.sourceLocation(o,c)))}}]),gImpl:({PRINT_WORDS:e,NEW_LINE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t(),r.limit!==void 0&&e("LIMIT",String(r.limit)),r.offset&&e("OFFSET",String(r.offset))})}},Vo={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(bi),i=t(F.integer),s=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}},Ko={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(xi),i=e(F.integer),s=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(s,r.astFactory.sourceLocation(n,i)))}};var rS={name:"queryUnit",impl:({SUBRULE:e})=>()=>e(gr)},gr={name:"query",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=t(De),s=r([{ALT:()=>t(rn)},{ALT:()=>t(nn)},{ALT:()=>t(sn)},{ALT:()=>t(an)}]),a=t(on);return e(()=>{let o={context:i,...s,type:"query",loc:n.astFactory.sourceLocation(i.at(0),s,a)};return a&&(o.values=a),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(De,t.context),r.isQuerySelect(t)?e(rn,t):r.isQueryConstruct(t)?e(nn,t):r.isQueryDescribe(t)?e(sn,t):e(an,t),t.values&&e(fr,t.values)}},rn={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ts),i=t(Be),s=t(Ge),a=t($e);return e(()=>{let o={subType:"select",where:s.val,solutionModifiers:a,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,s,a.group,a.having,a.order,a.limitOffset)};return r.skipValidation||pf(o),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Ts,r.wrap({variables:t.variables,distinct:t.distinct,reduced:t.reduced},r.sourceLocation(...t.variables))),e(Be,t.datasets),e(Ge,r.wrap(t.where,t.where.loc)),e($e,t.solutionModifiers)}},Po={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Ts),i=t(Ge),s=t($e),a=t(on);return e(()=>r.astFactory.querySelect({where:i.val,datasets:r.astFactory.datasetClauses([],r.astFactory.sourceLocation()),context:[],solutionModifiers:s,...n.val,...a&&{values:a}},r.astFactory.sourceLocation(n,i,s.group,s.having,s.order,s.limitOffset,a)))}},Ts={name:"selectClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION:s,OR1:a,OR2:o,OR3:c})=>l=>{let p=i(pi),h=e(()=>l.parseMode.has("canParseAggregate")||!l.parseMode.add("canParseAggregate")),d=s(()=>a([{ALT:()=>(i(Xe),[!0,!1])},{ALT:()=>(i(hi),[!1,!0])}]))??[!1,!1],m=e(()=>{let[y,v]=d;return{...y&&{distinct:y},...v&&{reduced:v}}}),A,b=o([{ALT:()=>{let y=i(g.star);return e(()=>(A=y,{variables:[l.astFactory.wildcard(l.astFactory.sourceLocation(y))],...m}))}},{ALT:()=>{let y=[],v=[];return t(()=>c([{ALT:()=>{let x=r(W);e(()=>{if(!l.skipValidation&&y.some(T=>T.value===x.value))throw new Error(`Variable ${x.value} used more than once in SELECT clause`);y.push(x),v.push(x),A=x})}},{ALT:()=>{let x=i(g.LParen),T=r(R);i(Lt);let I=n(W),S=i(g.RParen);e(()=>{if(A=S,!l.skipValidation&&y.some(C=>C.value===I.value))throw new Error(`Variable ${I.value} used more than once in SELECT clause`);y.push(I),v.push(l.astFactory.patternBind(T,I,l.astFactory.sourceLocation(x,A)))})}}])),{variables:v,...m}}}]);return e(()=>!h&&l.parseMode.delete("canParseAggregate")),e(()=>l.astFactory.wrap(b,l.astFactory.sourceLocation(p,A)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("SELECT "),n.val.distinct?t("DISTINCT"):n.val.reduced&&t("REDUCED")});for(let s of n.val.variables)i.isWildcard(s)?i.printFilter(n,()=>t("*")):i.isTerm(s)?e(W,s):(i.printFilter(n,()=>t("(")),e(R,s.expression),i.printFilter(n,()=>t("AS")),e(W,s.variable),i.printFilter(n,()=>t(")"))),i.printFilter(n,()=>t(""));i.printFilter(n,()=>t(""))}},nn={name:"constructQuery",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,CONSUME:n,OR:i})=>s=>{let a=n(fi);return i([{ALT:()=>{let o=t(Ho),c=t(Be),l=t(Ge),p=t($e);return e(()=>({subType:"construct",template:o.val,datasets:c,where:l.val,solutionModifiers:p,loc:s.astFactory.sourceLocation(a,l,p.group,p.having,p.order,p.limitOffset)}))}},{ALT:()=>{let o=r(Be);n(_t);let c=r(Ho),l=r($e);return e(()=>({subType:"construct",template:c.val,datasets:o,where:s.astFactory.patternGroup([c.val],s.astFactory.sourceLocation()),solutionModifiers:l,loc:s.astFactory.sourceLocation(a,c,l.group,l.having,l.order,l.limitOffset)}))}}])},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,PRINT_ON_OWN_LINE:n,NEW_LINE:i})=>(s,a)=>{let{astFactory:o,indentInc:c}=a;o.printFilter(s,()=>r("CONSTRUCT ")),o.isSourceLocationNoMaterialize(s.where.loc)||(o.printFilter(s,()=>{a[H]+=c,t("{"),i()}),e(ot,s.template),o.printFilter(s,()=>{a[H]-=c,n("}")})),e(Be,s.datasets),o.isSourceLocationNoMaterialize(s.where.loc)?e(Ge,o.wrap(o.patternGroup([s.template],s.template.loc),s.template.loc)):e(Ge,o.wrap(s.where,s.where.loc)),e($e,s.solutionModifiers)}},sn={name:"describeQuery",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n,OPTION:i,OR:s})=>a=>{let o=n(di),c=s([{ALT:()=>{let d=[];return t(()=>{d.push(r(Tt))}),d}},{ALT:()=>{let d=n(g.star);return[e(()=>a.astFactory.wildcard(a.astFactory.sourceLocation(d)))]}}]),l=r(Be),p=i(()=>r(Ge)),h=r($e);return e(()=>({subType:"describe",variables:c,datasets:l,...p&&{where:p.val},solutionModifiers:h,loc:a.astFactory.sourceLocation(o,...c,l,p,h.group,h.having,h.order,h.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{if(i.printFilter(n,()=>r("DESCRIBE ")),i.isWildcard(n.variables[0]))i.printFilter(n,()=>t("*"));else for(let s of n.variables)i.printFilter(n,()=>t("")),e(ue,s);e(Be,n.datasets),n.where&&e(Ge,i.wrap(n.where,n.loc)),e($e,n.solutionModifiers)}},an={name:"askQuery",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(mi),s=t(Be),a=t(Ge),o=t($e);return e(()=>({subType:"ask",datasets:s,where:a.val,solutionModifiers:o,loc:n.astFactory.sourceLocation(i,s,a,o.group,o.having,o.order,o.limitOffset)}))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("ASK ")),e(Be,r.datasets),e(Ge,n.wrap(r.where,r.loc)),e($e,r.solutionModifiers)}},on={name:"valuesClause",impl:({OPTION:e,SUBRULE:t})=>()=>e(()=>t(fr))},Ho={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(g.LCurly),a=n(()=>t(dm)),o=r(g.RCurly);return e(()=>i.astFactory.wrap(a??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,o)))}},dm={name:"constructTriples",impl:Yt.impl};var nS={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(ys)},ys={name:"update",impl:({ACTION:e,SUBRULE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION1:s,MANY:a})=>o=>{let c=[],l=r(De);c.push({context:l});let p=!0;return a({GATE:()=>p,DEF:()=>{p=!1,c.at(-1).operation=t(Tr),s(()=>{i(g.semi),p=!0;let h=n(De);c.push({context:h})})}}),e(()=>{let h={type:"update",updates:c,loc:o.astFactory.sourceLocation(...c.flatMap(d=>[...d.context,d.operation]))};return o.skipValidation||es(h),h})},gImpl:({SUBRULE:e,PRINT:t,NEW_LINE:r})=>(n,{astFactory:i})=>{let[s,...a]=n.updates;s&&(e(De,s.context),s.operation&&e(Tr,s.operation));for(let o of a)i.printFilter(n,()=>{t(";"),r()}),e(De,o.context),o.operation&&e(Tr,o.operation)}},Tr={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Wo)},{ALT:()=>e(zo)},{ALT:()=>e(qo)},{ALT:()=>e(Xo)},{ALT:()=>e(Bo)},{ALT:()=>e(Qo)},{ALT:()=>e(Yo)},{ALT:()=>e(Zo)},{ALT:()=>e(Jo)},{ALT:()=>e(Uo)},{ALT:()=>e(ec)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(Wo,t);break;case"clear":e(zo,t);break;case"drop":e(qo,t);break;case"add":e(Xo,t);break;case"move":e(Bo,t);break;case"copy":e(Qo,t);break;case"create":e(Yo,t);break;case"insertdata":e(Zo,t);break;case"deletedata":e(Jo,t);break;case"deletewhere":e(Uo,t);break;case"modify":e(ec,t);break}}},Wo={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>s=>{let a=r(Ei),o=n(()=>r(mt)),c=t($),l=i(()=>(r(Li),t(cn)));return e(()=>s.astFactory.updateOperationLoad(s.astFactory.sourceLocation(a,c,l),c,!!o,l))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("LOAD "),n.silent&&t("SILENT")}),e($,n.source),n.destination&&(i.printFilter(n,()=>t("INTO")),e(Xt,n.destination))}};function mm(e){return{name:ee(e.name),impl:({ACTION:t,SUBRULE1:r,CONSUME:n,OPTION:i})=>s=>{let a=n(e),o=i(()=>n(mt)),c=r(Xt);return t(()=>s.astFactory.updateOperationClearDrop(ee(e.name),!!o,c,s.astFactory.sourceLocation(a,c)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Xt,i.destination)}}}var zo=mm(_i),qo=mm(Oi),Yo={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(Si),a=n(()=>r(mt)),o=t(cn);return e(()=>i.astFactory.updateOperationCreate(o,!!a,i.astFactory.sourceLocation(s,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("CREATE "),n.silent&&t("SILENT")}),e(Xt,n.destination)}};function ic(e){return{name:ee(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:s})=>a=>{let o=r(e),c=s(()=>r(mt)),l=n(rc);r(Pi);let p=i(rc);return t(()=>a.astFactory.updateOperationAddMoveCopy(ee(e.name),l,p,!!c,a.astFactory.sourceLocation(o,p)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:s})=>{s.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Xt,i.source),s.printFilter(i,()=>r("TO")),t(Xt,i.destination)}}}var Xo=ic(Ni),Bo=ic(ki),Qo=ic(Ri),vs={name:"quadPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(g.LCurly),s=t(yr),a=r(g.RCurly);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,a)))}},sc={name:"quadData",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(g.LCurly),s=e(()=>n.parseMode.delete("canParseVars")),a=t(yr);e(()=>s&&n.parseMode.add("canParseVars"));let o=r(g.RCurly);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,o)))}};function ac(e,t,r,n){return{name:e,impl:({ACTION:i,SUBRULE1:s,CONSUME:a})=>o=>{let c=a(r),l=!0;e!=="insertData"&&(l=i(()=>o.parseMode.delete("canCreateBlankNodes")));let p=s(n);return e!=="insertData"&&i(()=>l&&o.parseMode.add("canCreateBlankNodes")),i(()=>o.astFactory.updateOperationInsDelDataWhere(t,p.val,o.astFactory.sourceLocation(c,p)))},gImpl:({SUBRULE:i,PRINT_WORD:s,PRINT_ON_EMPTY:a,PRINT_ON_OWN_LINE:o,NEW_LINE:c})=>(l,p)=>{let{astFactory:h,indentInc:d}=p;h.printFilter(l,()=>{a(t==="insertdata"?"INSERT DATA ":t==="deletedata"?"DELETE DATA ":"DELETE WHERE "),p[H]+=d,s("{"),c()}),i(yr,h.wrap(l.data,l.loc)),h.printFilter(l,()=>{p[H]-=d,o("}")})}}}var Zo=ac("insertData","insertdata",Di,sc),Jo=ac("deleteData","deletedata",wi,sc),Uo=ac("deleteWhere","deletewhere",Ci,vs),ec={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:s,OR:a})=>o=>{let c=i(()=>{let m=t(Fi),A=r($);return{withToken:m,graph:A}}),{insert:l,del:p}=a([{ALT:()=>{let m=r(gm),A=s(()=>r(tc));return{del:m,insert:A}}},{ALT:()=>({insert:n(tc),del:void 0})}]),h=r(ss);t(_t);let d=r(Y);return e(()=>o.astFactory.updateOperationModify(o.astFactory.sourceLocation(c?.withToken,p,l,d),l?.val??[],p?.val??[],d,h,c?.graph))},gImpl:({SUBRULE:e,PRINT_WORDS:t,PRINT_ON_EMPTY:r,NEW_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;i.graph&&(a.printFilter(i,()=>t("WITH")),e($,i.graph)),i.delete.length>0&&(a.printFilter(i,()=>{s[H]+=o,t("DELETE","{"),n()}),e(yr,a.wrap(i.delete,i.loc)),a.printFilter(i,()=>{s[H]-=o,r("}"),n()})),i.insert.length>0&&(a.printFilter(i,()=>{s[H]+=o,t("INSERT","{"),n()}),e(yr,a.wrap(i.insert,i.loc)),a.printFilter(i,()=>{s[H]-=o,r("} "),n()})),e(ss,i.from),a.printFilter(i,()=>t("WHERE")),e(Y,i.where)}},gm={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Mi),s=e(()=>n.parseMode.delete("canCreateBlankNodes")),a=t(vs);return e(()=>s&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},tc={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Gi),s=t(vs);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},rc={name:"graphOrDefault",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>s=>i([{ALT:()=>{let a=r(ve.default_);return e(()=>s.astFactory.graphRefDefault(s.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=n(()=>r(ve.graph)),o=t($);return e(()=>s.astFactory.graphRefSpecific(o,s.astFactory.sourceLocation(a,o)))}}])},cn={name:"graphRef",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ve.graph),s=t($);return e(()=>n.astFactory.graphRefSpecific(s,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e($,r.graph)}},Xt={name:"graphRefAll",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(cn)},{ALT:()=>{let s=r(ve.default_);return e(()=>i.astFactory.graphRefDefault(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(ve.named);return e(()=>i.astFactory.graphRefNamed(i.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=r(ve.graphAll);return e(()=>i.astFactory.graphRefAll(i.astFactory.sourceLocation(s)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.isGraphRefSpecific(r)?e(cn,r):n.isGraphRefDefault(r)?n.printFilter(r,()=>t("DEFAULT")):n.isGraphRefNamed(r)?n.printFilter(r,()=>t("NAMED")):n.printFilter(r,()=>t("ALL"))}},yr={name:"quads",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:s,OPTION1:a,OPTION2:o,OPTION3:c})=>l=>{let p=[],h;return a(()=>{let d=i(Yt);h=d,e(()=>p.push(d))}),n(()=>{let d=t(nc);h=d,p.push(d),o(()=>{let m=r(g.dot);return h=m,m}),c(()=>{let m=s(Yt);h=m,e(()=>p.push(m))})}),e(()=>l.astFactory.wrap(p,l.astFactory.sourceLocation(p.at(0),h)))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t.val)r.isPattern(n)?e(ot,n):e(nc,n)}},nc={name:"quadsNotTriples",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let s=r(ve.graph),a=t(Tt);r(g.LCurly);let o=n(()=>t(Yt)),c=r(g.RCurly);return e(()=>i.astFactory.graphQuads(a,o??i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(s,c)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,s)=>{let{astFactory:a,indentInc:o}=s;a.printFilter(i,()=>t("GRAPH")),e(ue,i.graph),a.printFilter(i,()=>{s[H]+=o,t("{"),r()}),e(ot,i.triples),a.printFilter(i,()=>{s[H]-=o,n("}")})}};var iS={name:"queryOrUpdate",impl:({ACTION:e,SUBRULE:t,OR1:r,OR2:n,MANY:i,OPTION1:s,CONSUME:a,SUBRULE2:o})=>c=>{let l=t(De);return r([{ALT:()=>{let p=n([{ALT:()=>t(rn)},{ALT:()=>t(nn)},{ALT:()=>t(sn)},{ALT:()=>t(an)}]),h=t(on);return e(()=>({context:l,...p,type:"query",...h&&{values:h},loc:c.astFactory.sourceLocation(l.at(0),p,h)}))}},{ALT:()=>{let p=[];p.push({context:l});let h=!0;return i({GATE:()=>h,DEF:()=>{h=!1,p.at(-1).operation=t(Tr),s(()=>{a(g.semi),h=!0;let d=o(De);p.push({context:d})})}}),e(()=>{let d={type:"update",updates:p,loc:c.astFactory.sourceLocation(...p.flatMap(m=>[...m.context,m.operation]))};return c.skipValidation||es(d),d})}}])},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isQuery(t)?e(gr,t):e(ys,t)}};function sS(e){return{astFactory:e.astFactory??new Kt({tracksSourceLocation:!1}),baseIRI:e.baseIRI,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:e.parseMode?new Set(e.parseMode):new Set(["canParseVars","canCreateBlankNodes"]),skipValidation:e.skipValidation??!1}}function oc(e){return{astFactory:e.astFactory??new Kt,origSource:e.origSource??"",offset:e.offset,[H]:e[H]??0,[Wr]:e[Wr]??" ",indentInc:e.indentInc??2}}function Tm(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var As=class{parser;defaultContext;coreTransformer=new $t;constructor(t,r={}){this.parser=t,this.defaultContext=sS(r)}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Tm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),n}parsePath(t,r={}){let n=this.parser.path(t,Tm({...this.defaultContext,...r}));return n.loc=this.defaultContext.astFactory.sourceLocationInlinedSource(t,n.loc,0,Number.MAX_SAFE_INTEGER),this.defaultContext.astFactory.isPathPure(n)?{...n,prefixes:Object.create(null)}:n}};var aS=[u.expression,u.conditionalOrExpression,u.conditionalAndExpression,u.valueLogical,u.relationalExpression,u.numericExpression,u.expressionList,u.additiveExpression,u.multiplicativeExpression,u.unaryExpression,u.primaryExpression,u.brackettedExpression,u.iriOrFunction,u.rdfLiteral,u.numericLiteral,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative,u.booleanLiteral,u.var_,u.builtInStr,u.builtInLang,u.builtInLangmatches,u.builtInDatatype,u.builtInBound,u.builtInIri,u.builtInUri,u.builtInBnodeSparqlJs,u.builtInRand,u.builtInAbs,u.builtInCeil,u.builtInFloor,u.builtInRound,u.builtInConcat,u.builtInStrlen,u.builtInUcase,u.builtInLcase,u.builtInEncode_for_uri],oS={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(u.builtInCallList(t).slice(0,-2))},ym=te.create(aS).addMany(u.builtInContains,u.builtInStrstarts,u.builtInStrends,u.builtInStrbefore,u.builtInStrafter,u.builtInYear,u.builtInMonth,u.builtInDay,u.builtInHours,u.builtInMinutes,u.builtInSeconds,u.builtInTimezone,u.builtInTz,u.builtInNow,u.builtInUuid,u.builtInStruuid,u.builtInMd5,u.builtInSha1,u.builtInSha256,u.builtInSha384,u.builtInSha512,u.builtInCoalesce,u.builtInIf,u.builtInStrlang,u.builtInStrdt,u.builtInSameterm,u.builtInIsiri,u.builtInIsuri,u.builtInIsblank,u.builtInIsliteral,u.builtInIsnumeric,u.regexExpression,u.substringExpression,u.strReplaceExpression,u.aggregateCount,u.aggregateSum,u.aggregateMin,u.aggregateMax,u.aggregateAvg,u.aggregateSample,u.aggregateGroup_concat,u.aggregate,u.iri,u.iriFull,u.prefixedName,u.argList,u.string).addRule(oS);var cS=[u.objectList,u.object,u.graphNode,u.varOrTerm,u.triplesNode,u.collection,u.blankNodePropertyList,u.propertyListNotEmpty,u.verb,u.verbA,u.varOrIri,u.var_,u.iri,u.iriFull,u.prefixedName,u.graphTerm,u.rdfLiteral,u.numericLiteral,u.booleanLiteral,u.blankNode,u.string,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative],bs=te.create(cS);var vm=te.create([u.triplesBlock,u.triplesSameSubjectPath,u.propertyListPathNotEmpty,u.triplesNodePath,u.propertyListPath,u.verbPath,u.verbSimple,u.objectListPath]).merge(bs,[]).addMany(u.path,u.pathAlternative,u.pathSequence,u.pathEltOrInverse,u.pathElt,u.pathPrimary,u.pathMod,u.pathNegatedPropertySet,u.pathOneInPropertySet,u.objectPath,u.graphNodePath,u.collectionPath,u.blankNodePropertyListPath);var lS=[u.subSelect,u.selectClause,u.whereClause,u.solutionModifier,u.valuesClause],xs=te.create(lS).merge(ym,[]).patchRule(u.builtInCall).addMany(u.existsFunc,u.notExistsFunc,u.groupGraphPattern,u.groupGraphPatternSub).merge(vm,[]).addMany(u.graphPatternNotTriples,u.groupOrUnionGraphPattern,u.optionalGraphPattern,u.minusGraphPattern,u.graphGraphPattern,u.serviceGraphPattern,u.filter,u.bind,u.inlineData,u.constraint,u.functionCall,u.dataBlock,u.inlineDataOneVar,u.inlineDataFull,u.dataBlockValue,u.groupClause,u.havingClause,u.orderClause,u.limitOffsetClauses,u.groupCondition,u.havingCondition,u.orderCondition,u.limitClause,u.offsetClause);var uS=[u.triplesTemplate,u.triplesSameSubject,u.varOrTerm,u.propertyListNotEmpty,u.triplesNode,u.propertyList,u.var_,u.graphTerm,u.iri,u.iriFull,u.prefixedName,u.rdfLiteral,u.string,u.numericLiteral,u.numericLiteralUnsigned,u.numericLiteralPositive,u.numericLiteralNegative,u.booleanLiteral,u.blankNode,u.verb,u.verbA,u.varOrIri,u.objectList,u.object,u.collection,u.blankNodePropertyList,u.graphNode],Is=te.create(uS);var pS=[u.queryUnit,u.query,u.prologue,u.selectQuery,u.constructQuery,u.describeQuery,u.askQuery,u.valuesClause,u.baseDecl,u.prefixDecl],Am=te.create(pS).merge(xs,[]).addRule(u.datasetClause).addRule(u.datasetClauseStar).addRule(u.defaultGraphClause).addRule(u.namedGraphClause).addRule(u.sourceSelector).addRule(u.constructTemplate).merge(Is,[]).addRule(u.constructTriples);var hS={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(u.load)},{ALT:()=>e(u.clear)},{ALT:()=>e(u.drop)},{ALT:()=>e(u.add)},{ALT:()=>e(u.move)},{ALT:()=>e(u.copy)},{ALT:()=>e(u.create)},{ALT:()=>e(u.insertData)},{ALT:()=>e(u.deleteData)},{ALT:()=>e(u.deleteWhere)}]),gImpl:u.update1.gImpl},fS=[u.updateUnit,u.update,u.prologue,u.baseDecl,u.prefixDecl,u.load,u.clear,u.drop,u.add,u.move,u.copy,u.create,u.insertData,u.deleteData,u.deleteWhere,u.iri,u.prefixedName,u.graphRef,u.graphRefAll,u.graphOrDefault,u.quadData,u.quads],bm=te.create(fS).addRule(hS).merge(Is,[]).addRule(u.quadPattern).addRule(u.quadsNotTriples);var xm=te.create(bm).patchRule(u.update1).addMany(u.modify,u.deleteClause,u.insertClause,u.usingClause,u.defaultGraphClause,u.namedGraphClause,u.sourceSelector,u.usingClauseStar,u.groupGraphPattern).merge(bs,[]).merge(xs,[]);var dS=te.create(Am).merge(xm,[]).addRule(u.queryOrUpdate),Es=class extends As{constructor(t={}){let r=dS.build({...t,tokenVocabulary:he.sparql11LexerBuilder.tokenVocabulary,queryPreProcessor:lf});super(r,t.defaultContext)}};var mS=Un.create([u.queryOrUpdate,u.query,u.selectQuery,u.constructQuery,u.describeQuery,u.askQuery,u.selectClause]).addMany(u.update,u.update1,u.load,u.clear,u.drop,u.create,u.copy,u.move,u.add,u.insertData,u.deleteData,u.deleteWhere,u.modify,u.graphRef,u.graphRefAll,u.quads,u.quadsNotTriples).addRule(u.aggregate).addMany(u.datasetClauseStar,u.usingClauseStar).addMany(u.argList,u.expression,u.iriOrFunction).addMany(u.prologue,u.prefixDecl,u.baseDecl,u.varOrTerm,u.var_,u.graphTerm).addMany(u.rdfLiteral,u.iri,u.iriFull,u.prefixedName,u.blankNode).addRule(u.pathGenerator).addMany(u.solutionModifier,u.groupClause,u.havingClause,u.orderClause,u.limitOffsetClauses).addMany(u.triplesBlock,u.collectionPath,u.blankNodePropertyListPath,u.triplesNodePath,u.graphNodePath).addMany(u.whereClause,u.generatePattern,u.groupGraphPattern,u.graphPatternNotTriples,u.optionalGraphPattern,u.graphGraphPattern,u.serviceGraphPattern,u.bind,u.inlineData,u.minusGraphPattern,u.groupOrUnionGraphPattern,u.filter),Ls=class{defaultContext;constructor(t={}){this.defaultContext=oc(t)}generator=mS.build();generate(t,r={}){return this.generator.queryOrUpdate(t,{...this.defaultContext,...r}).trim()}generatePath(t,r={}){return this.generator.path(t,oc({...this.defaultContext,...r}),void 0).trim()}};var Os=()=>({sourceLocationType:"autoGenerate"});function cc(e,t){if(!t)return e;try{return new URL(e,t).href}catch{return e}}function uc(e,t={prefixes:new Map,base:void 0}){if(Array.isArray(e))return e.forEach(n=>uc(n,t)),e;if(!e||typeof e!="object")return e;let r=t;if(Array.isArray(e.context)&&e.context.length>0){r={prefixes:new Map(t.prefixes),base:t.base};for(let n of e.context)n.subType==="base"&&n.value?.value&&(r.base=cc(n.value.value,r.base)),n.subType==="prefix"&&n.key!==void 0&&n.value?.value&&r.prefixes.set(n.key,cc(n.value.value,r.base))}if(e.type==="term"&&e.subType==="namedNode")if(e.prefix!==void 0){let n=r.prefixes.get(e.prefix);if(n===void 0)throw new Error(`Undefined SPARQL prefix: ${e.prefix}`);e.value=n+e.value,delete e.prefix}else e.value=cc(e.value,r.base);for(let[n,i]of Object.entries(e))n!=="context"&&uc(i,r);return e}function lc(e,t){if(e&&e.type==="tripleCollection"){for(let r of e.triples)Em(r,t);return pc(e.identifier)}return pc(e)}function Em(e,t){if(e.type==="tripleCollection"){lc(e,t);return}let r=lc(e.subject,t),n=lc(e.object,t);t.push({...e,subject:r,predicate:pc(e.predicate),object:n,loc:Os()})}function pc(e){return e&&typeof e=="object"?{...e,loc:Os()}:e}function hc(e){if(Array.isArray(e))return e.forEach(hc),e;if(!e||typeof e!="object")return e;if(e.type==="pattern"&&e.subType==="bgp"&&Array.isArray(e.triples)){let t=[];for(let r of e.triples)Em(r,t);e.triples=t}for(let t of Object.values(e))hc(t);return e}function Im(e){return{type:"pattern",subType:"group",patterns:e,loc:Os()}}function gS(e){if(e.type==="query"){Array.isArray(e.context)||(e.context=[]),e.datasets||(e.datasets={type:"datasetClauses",clauses:[]}),e.solutionModifiers||(e.solutionModifiers={}),e.subType!=="describe"&&!e.where&&(e.where=Im([]));let t=e.solutionModifiers,r=t.limitOffset;r&&(r.limit===void 0&&!r.offset?delete t.limitOffset:Object.assign(r,{type:"solutionModifier",subType:"limitOffset"})),t.order&&!(t.order.orderDefs?.length>0)&&delete t.order,t.group&&!(t.group.groupings?.length>0)&&delete t.group}e.type==="pattern"&&e.subType==="union"&&Array.isArray(e.patterns)&&(e.patterns=e.patterns.map(t=>t.type==="pattern"&&t.subType==="group"?t:Im([t])))}function _s(e,t=!1){if(Array.isArray(e))return e.forEach(r=>_s(r,t)),e;if(!e||typeof e!="object")return e;if(t){for(let r of Object.values(e))_s(r);return e}typeof e.type=="string"&&gS(e),e.loc||(e.loc=Os());for(let[r,n]of Object.entries(e))r!=="loc"&&_s(n,r==="values"&&e.subType==="values");return e}var fc=class{constructor(t){this.parser=new Es(t)}parse(t){return hc(uc(this.parser.parse(t)))}},dc=class{constructor(t){this.generator=new Ls(t)}generate(t,r){return this.generator.generate(_s(t),r)}};typeof window<"u"&&(window.LDH_SPARQL={Parser:fc,Generator:dc});})(); From 7899633574ea414a22c376b4d6223ad06c246d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:21:07 +0100 Subject: [PATCH 03/13] A blank node in a parsed or built triple carries its name as Traqula's label, so the generator prints it and constructor instances, value-range markers and RDF/XML descriptions find it Co-Authored-By: Claude Opus 5.5 --- .../writer/function/ParseQuery.java | 23 ++++------- .../xsl/client/query-transforms.xsl | 2 +- .../linkeddatahub/xsl/imports/default.xsl | 41 +++++++++++-------- .../writer/function/ParseQueryTest.java | 10 +++++ 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java index 04d20db6c5..0d72469d0b 100644 --- a/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java +++ b/src/main/java/com/atomgraph/linkeddatahub/writer/function/ParseQuery.java @@ -41,9 +41,12 @@ * declaration of the ldh:parse-query stylesheet function for * ldh:construct-instance. *

- * The stylesheet consumes the Traqula query and pattern keys, including typed RDF terms. The - * server only needs the construct template and whether the WHERE group is empty; it does not - * manufacture a second parser AST for query patterns. + * The stylesheet consumes the Traqula query and pattern keys, including typed RDF terms (a blank + * node carries its name as label, as in Traqula). The server only needs the construct + * template and whether the WHERE group is empty; it does not manufacture a second parser AST for + * query patterns, and since nothing generates SPARQL from this tree, its nodes carry no source + * locations. Jena flattens blank-node property lists and collections in the template, which the + * browser's parser shim does as well. * * @author {@literal Martynas Jusevičius } */ @@ -91,7 +94,6 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException map.put("subject", term(triple.getSubject())); map.put("predicate", term(triple.getPredicate())); map.put("object", term(triple.getObject())); - map.put("loc", loc()); triples.add(map); } @@ -102,16 +104,13 @@ public XdmValue call(XdmValue[] arguments) throws SaxonApiException template.put("type", "pattern"); template.put("subType", "bgp"); template.put("triples", triples); - template.put("loc", loc()); where.put("type", "pattern"); where.put("subType", "group"); where.put("patterns", patterns); - where.put("loc", loc()); json.put("type", "query"); json.put("subType", query.isConstructType() ? "construct" : query.isDescribeType() ? "describe" : query.isAskType() ? "ask" : "select"); json.put("template", template); json.put("where", where); - json.put("loc", loc()); return new XdmAtomicValue(json.toString()); } catch (QueryParseException ex) @@ -132,7 +131,7 @@ private JsonObject term(Node node) else if (node.isBlank()) { term.put("subType", "blankNode"); - term.put("value", node.getBlankNodeLabel()); + term.put("label", node.getBlankNodeLabel()); } if (node.isLiteral()) { @@ -145,7 +144,6 @@ else if (node.getLiteralDatatypeURI() != null && !node.getLiteralDatatypeURI().e datatype.put("type", "term"); datatype.put("subType", "namedNode"); datatype.put("value", node.getLiteralDatatypeURI()); - datatype.put("loc", loc()); term.put("langOrIri", datatype); } } @@ -154,15 +152,8 @@ else if (node.isURI()) term.put("subType", "namedNode"); term.put("value", node.getURI()); } - term.put("loc", loc()); return term; } - private JsonObject loc() - { - JsonObject loc = new JsonObject(); - loc.put("sourceLocationType", "autoGenerate"); - return loc; - } } diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 321418e4ef..278f05b66e 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -117,7 +117,7 @@ extension-element-prefixes="ixsl" - + - - + + + + + + + + @@ -494,7 +501,7 @@ exclude-result-prefixes="#all" - + @@ -508,15 +515,17 @@ exclude-result-prefixes="#all" - - + + - + - + @@ -561,7 +570,7 @@ exclude-result-prefixes="#all" - + @@ -616,11 +625,11 @@ exclude-result-prefixes="#all" - - + + - + diff --git a/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java index 289ce970a3..d75c5e99bb 100644 --- a/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java +++ b/src/test/java/com/atomgraph/linkeddatahub/writer/function/ParseQueryTest.java @@ -54,4 +54,14 @@ public void testNonemptyWhereIsMarkedAsNonInstantiable() throws SaxonApiExceptio assertTrue(json.contains("\"where\":{\"type\":\"pattern\",\"subType\":\"group\",\"patterns\":[{}]"), json); } + @Test + public void testBlankNodesCarryTheirLabel() throws SaxonApiException + { + String json = parse("CONSTRUCT { ?this [ a ] } WHERE { }"); + + assertTrue(json.contains("\"subType\":\"blankNode\",\"label\":"), json); + assertTrue(!json.contains("\"subType\":\"blankNode\",\"value\":"), json); + assertTrue(!json.contains("\"loc\""), json); + } + } From 4df97e23f48b27e532c2ade3c4aafbec05da0104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:23:52 +0100 Subject: [PATCH 04/13] A view reads its paging, sort keys, facets and sort predicates from Traqula's AST, and its rewrites build EXISTS, IN and DESC the way Traqula's generator prints them Co-Authored-By: Claude Opus 5.5 --- .../linkeddatahub/xsl/client/block/view.xsl | 76 +++++----- .../xsl/client/query-transforms.xsl | 141 +++++++++++------- 2 files changed, 123 insertions(+), 94 deletions(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl index 27097d6351..0bd4990728 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl @@ -120,14 +120,14 @@ exclude-result-prefixes="#all" "/> - + - - + + - + @@ -549,8 +549,8 @@ exclude-result-prefixes="#all" - - + + @@ -574,8 +574,8 @@ exclude-result-prefixes="#all" - - + +

@@ -882,8 +882,8 @@ exclude-result-prefixes="#all" - - + + @@ -983,8 +983,8 @@ exclude-result-prefixes="#all" - - + + @@ -1093,8 +1093,8 @@ exclude-result-prefixes="#all" - - + + @@ -1384,8 +1384,8 @@ exclude-result-prefixes="#all" - - + + @@ -1457,7 +1457,7 @@ exclude-result-prefixes="#all" - + @@ -1465,11 +1465,11 @@ exclude-result-prefixes="#all" - + - - - + + + @@ -1799,7 +1799,7 @@ exclude-result-prefixes="#all" - + @@ -2140,7 +2140,7 @@ exclude-result-prefixes="#all" - + @@ -2187,7 +2187,7 @@ exclude-result-prefixes="#all" - + @@ -2225,8 +2225,8 @@ exclude-result-prefixes="#all" - - + + @@ -2250,7 +2250,7 @@ exclude-result-prefixes="#all" - + @@ -2339,7 +2339,7 @@ exclude-result-prefixes="#all" - + @@ -2382,11 +2382,11 @@ exclude-result-prefixes="#all" - + - + - + @@ -3059,10 +3059,10 @@ exclude-result-prefixes="#all" - + - + @@ -3072,13 +3072,13 @@ exclude-result-prefixes="#all" - + - - + + - + @@ -3486,7 +3486,7 @@ exclude-result-prefixes="#all" values - a literal, a computed (YEAR(NOW()) AS ?year) - and a view shows resources. Said in the results region, where the empty state would have claimed that nothing matched --> - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 278f05b66e..8e2cc71a5b 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -106,6 +106,43 @@ extension-element-prefixes="ixsl" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -439,22 +476,20 @@ extension-element-prefixes="ixsl" filter expression - operation + patternOperation exists - - - pattern - group - - - - - - - - - - + + pattern + group + + + + + + + + + @@ -482,7 +517,7 @@ extension-element-prefixes="ixsl" - + @@ -674,27 +709,16 @@ extension-element-prefixes="ixsl" + - + - - true - + - - - - - - - - - - @@ -755,7 +779,7 @@ extension-element-prefixes="ixsl" - + solutionModifier @@ -803,7 +827,7 @@ extension-element-prefixes="ixsl" - + pattern optional @@ -863,15 +887,16 @@ extension-element-prefixes="ixsl" - + + - + - ? + @@ -886,11 +911,12 @@ extension-element-prefixes="ixsl" - + - + @@ -910,9 +936,6 @@ extension-element-prefixes="ixsl" in - - - @@ -921,13 +944,21 @@ extension-element-prefixes="ixsl" - + + + + + + + + + @@ -935,35 +966,33 @@ extension-element-prefixes="ixsl" + - - + - - + + - - + + + - - - + + @@ -1019,7 +1048,7 @@ extension-element-prefixes="ixsl" - + @@ -1089,7 +1118,7 @@ extension-element-prefixes="ixsl" - + From 33b89304d9842632344fd96269463cb6e52eaf00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:24:26 +0100 Subject: [PATCH 05/13] The constructor editor reads a constructor's template triples, and builds the CONSTRUCT it saves, in Traqula's AST Co-Authored-By: Claude Opus 5.5 --- .../linkeddatahub/xsl/client/constructor.xsl | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl index 7fef961dee..3ec3a1ba40 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl @@ -381,23 +381,24 @@ exclude-result-prefixes="#all" - + +
- + - +
- - + +
@@ -448,9 +449,9 @@ exclude-result-prefixes="#all"
- - - + + + - - - &ldh;chartType - - + - - - - - + - - - - - + - optional + pattern + optional - filter + pattern + filter - operation + expression + operation in - ?p - - &ldh;chartType - &ldh;categoryVarName - &ldh;categoryProperty - &ldh;seriesVarName - &ldh;seriesProperty - + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl index 0bd4990728..c2174e0b0d 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl @@ -3671,11 +3671,7 @@ exclude-result-prefixes="#all" - - - - - + @@ -3699,17 +3695,9 @@ exclude-result-prefixes="#all" - - - &foaf;primaryTopic - - + - - - &dct;title - "" - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl index 85cd842ccc..c8ae6204ae 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl @@ -2503,38 +2503,7 @@ WHERE - - - bgp - - - - ?p - ?o - - - - - - - update - - - insertdelete - - - - - - - - - - - - - - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl index 77851e56f8..bc91ad03b1 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/modal.xsl @@ -986,63 +986,57 @@ LIMIT 10 + + - bgp - - - - ?p - ?o - - - - - filter + pattern + filter - operation + expression + operation notin - ?p - - &dct;created - &dct;modified - &sioc;has_parent - &sioc;has_container - &dct;creator - &acl;owner - + + + - filter + pattern + filter - operation + expression + operation ! - operation + expression + operation strstarts - operation + expression + operation str - ?p + - operation + expression + operation concat - operation + expression + operation str - http://www.w3.org/1999/02/22-rdf-syntax-ns# + - "_" + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl index 29048e5730..5b1b52eeb6 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl @@ -482,6 +482,20 @@ exclude-result-prefixes="#all" + + + + + + + + triple + + + + + + From f5e06df96e5fca791fd3a99eea0d8a510604ae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:25:42 +0100 Subject: [PATCH 07/13] The class drawer and the typeahead bind their VALUES by the bare variable name, as Traqula keys VALUES rows Co-Authored-By: Claude Opus 5.5 --- .../static/com/atomgraph/linkeddatahub/xsl/client/form.xsl | 2 +- .../com/atomgraph/linkeddatahub/xsl/client/navigation.xsl | 2 +- .../atomgraph/linkeddatahub/xsl/client/query-transforms.xsl | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl index c8ae6204ae..6997222244 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/form.xsl @@ -2169,7 +2169,7 @@ WHERE
- +
diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/navigation.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/navigation.xsl index d3766cf938..5480a0c515 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/navigation.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/navigation.xsl @@ -878,7 +878,7 @@ ORDER BY DESC(?created) - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 8e2cc71a5b..1c6112cd8b 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -1300,7 +1300,7 @@ extension-element-prefixes="ixsl"
- + @@ -1319,7 +1319,7 @@ extension-element-prefixes="ixsl" pattern values - + @@ -1329,7 +1329,7 @@ extension-element-prefixes="ixsl" - + From 9513920816165f79909ad923e1cf9c8d8002d73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:25:59 +0100 Subject: [PATCH 08/13] The stylesheets build Traqula nodes without source locations, which the parser shim adds when it generates the query Co-Authored-By: Claude Opus 5.5 --- .../linkeddatahub/xsl/client/functions.xsl | 14 +++-------- .../xsl/client/query-transforms.xsl | 25 ++++--------------- .../linkeddatahub/xsl/imports/default.xsl | 2 -- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl index 5bed370a16..024e6cb606 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/functions.xsl @@ -469,7 +469,7 @@ exclude-result-prefixes="#all" - +
@@ -477,7 +477,7 @@ exclude-result-prefixes="#all" - + @@ -493,7 +493,6 @@ exclude-result-prefixes="#all"
- autoGenerate
@@ -562,7 +561,7 @@ exclude-result-prefixes="#all" - + @@ -574,7 +573,6 @@ exclude-result-prefixes="#all" - autoGenerate
@@ -589,7 +587,6 @@ exclude-result-prefixes="#all" - autoGenerate @@ -604,7 +601,6 @@ exclude-result-prefixes="#all" - autoGenerate @@ -637,18 +633,14 @@ exclude-result-prefixes="#all" pattern group - autoGenerate datasetClauses - autoGenerate - autoGenerate - autoGenerate
diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index 1c6112cd8b..dee738aadd 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -153,15 +153,15 @@ extension-element-prefixes="ixsl" + else map { 'type': 'term', 'subType': 'namedNode', 'value': if (starts-with($token, '<') and ends-with($token, '>')) then substring($token, 2, string-length($token) - 2) else $token }"/> @@ -292,7 +292,6 @@ extension-element-prefixes="ixsl" term variable - autoGenerate @@ -375,7 +374,6 @@ extension-element-prefixes="ixsl" solutionModifier limitOffset - autoGenerate @@ -406,17 +404,13 @@ extension-element-prefixes="ixsl" term namedNode &xsd;boolean - autoGenerate - autoGenerate term variable inverse - autoGenerate - autoGenerate @@ -501,7 +495,6 @@ extension-element-prefixes="ixsl" solutionModifier group - autoGenerate @@ -622,7 +615,6 @@ extension-element-prefixes="ixsl" term variable - autoGenerate @@ -655,7 +647,6 @@ extension-element-prefixes="ixsl" false - autoGenerate @@ -785,7 +776,6 @@ extension-element-prefixes="ixsl" solutionModifier group - autoGenerate @@ -797,7 +787,6 @@ extension-element-prefixes="ixsl" - autoGenerate @@ -843,7 +832,6 @@ extension-element-prefixes="ixsl" term namedNode - autoGenerate @@ -876,7 +864,6 @@ extension-element-prefixes="ixsl" term variable - autoGenerate @@ -1155,7 +1142,6 @@ extension-element-prefixes="ixsl" solutionModifier limitOffset 2 - autoGenerate @@ -1344,7 +1330,6 @@ extension-element-prefixes="ixsl" - autoGenerate diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl index 5b1b52eeb6..d241eddf75 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/imports/default.xsl @@ -626,7 +626,6 @@ exclude-result-prefixes="#all" - autoGenerate @@ -652,7 +651,6 @@ exclude-result-prefixes="#all" - autoGenerate From e0a7b51dbdda5fb35757ba191ebf05e1202e6cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:26:22 +0100 Subject: [PATCH 09/13] The static content-type test, the README and the comments name Traqula as the browser's SPARQL parser, and the CHANGELOG records the switch Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + README.md | 2 +- .../static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl | 2 +- .../static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl | 4 ++-- tests/http/static/content-type-charset.sh | 2 +- tests/packages/editor/taxonomy/ns.ttl | 4 ++-- tests/ui/specs/document/blocks/view/projection.spec.mjs | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb30e5e231..0e6b9167bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - `PATCH /settings` refuses to change `lds:versioningRepository` too: an owner could otherwise have their dataspace commit, with the deployment's credentials, over another dataspace's versions ### Changed +- The browser parses and generates SPARQL with Traqula instead of SPARQL.js 2.x, and the stylesheets read and rewrite queries in Traqula's AST, with typed terms instead of SPARQL.js's term strings (#429) - A resource a document describes may be left without a type: `PATCH` refuses only to leave the document itself untyped, which it already did, as the document must keep a document hierarchy class. Imported data often describes entities without a type, and a resource that had one could not be given the same shape (#308 held every resource to keeping one) - The `ldh` plugin's skills show how to check which property views a type gets without a browser, with the page's own lookup query against the installed ontology: `ldh get --accept text/html` returns the page before the browser renders its blocks and property views - A container's children view lists its documents, not the things they are about: `ldh:SelectChildren` no longer selects each child's `foaf:primaryTopic`, and the list, grid and table modes render each result as itself instead of standing a document's topic in for it. A document's row carries no type tag, as its header carries no type chip. A page that lists things (a catalogue, a table of people) is a view over the things diff --git a/README.md b/README.md index b2afb9e455..33e03e38cf 100644 --- a/README.md +++ b/README.md @@ -385,7 +385,7 @@ The models are transcribed from the code, not extracted from it. The `Formal` wo ### Browser * [Saxon-JS](https://www.saxonica.com/saxon-js/) -* [SPARQL.js](https://github.com/RubenVerborgh/SPARQL.js) +* [Traqula](https://github.com/comunica/traqula) * [OpenLayers](https://openlayers.org) * [Google Charts](https://developers.google.com/chart) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl index 8f7486c704..6f6d17424f 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/admin/signup.xsl @@ -62,7 +62,7 @@ exclude-result-prefixes="#all"> - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl index ec6bc4c6e7..aa94d43992 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/tree.xsl @@ -87,8 +87,8 @@ exclude-result-prefixes="#all" concept's. Scoping both to one GRAPH silently drops every child linked from above - measured against a fixture where it returned one top concept of two. --> diff --git a/tests/http/static/content-type-charset.sh b/tests/http/static/content-type-charset.sh index 83aea812a9..b072e781e5 100755 --- a/tests/http/static/content-type-charset.sh +++ b/tests/http/static/content-type-charset.sh @@ -25,7 +25,7 @@ clear_ontology declare -a expectations=( "static/com/atomgraph/linkeddatahub/css/ldh.css|text/css;charset=UTF-8" "static/com/atomgraph/linkeddatahub/xsl/client.xsl|text/xsl;charset=UTF-8" - "static/com/atomgraph/linkeddatahub/js/SPARQL.js|text/javascript;charset=UTF-8" + "static/com/atomgraph/linkeddatahub/js/traqula.min.js|text/javascript;charset=UTF-8" "static/com/atomgraph/linkeddatahub/js/saxon-js/LICENSE.txt|text/plain;charset=UTF-8" "static/com/atomgraph/linkeddatahub/css/ol.css.map|application/json" "AGENTS.md|text/markdown;charset=UTF-8" diff --git a/tests/packages/editor/taxonomy/ns.ttl b/tests/packages/editor/taxonomy/ns.ttl index 2b54650834..63be4f5381 100644 --- a/tests/packages/editor/taxonomy/ns.ttl +++ b/tests/packages/editor/taxonomy/ns.ttl @@ -215,8 +215,8 @@ skos:hasTopConcept ldh:view :TopConcepts . # fixture, Hot drinks' Narrower block showed 1 child where the tree showed 3, because Coffee and Tea # assert skos:broader upwards, and Juice's Broader block showed nothing while the tree nested it under # Hot drinks. The union stays INSIDE the link's GRAPH rather than becoming a sibling block, because -# the SPARQL.js parse/serialise round-trip merges sibling GRAPH blocks into one and would scope the child's label to -# the link's document. +# the SPARQL.js parse/serialise round-trip views went through merged sibling GRAPH blocks into one and scoped the +# child's label to the link's document. :SelectTopConcepts a sp:Select ; rdfs:label "Select top concepts" ; dct:title "Select top concepts" ; diff --git a/tests/ui/specs/document/blocks/view/projection.spec.mjs b/tests/ui/specs/document/blocks/view/projection.spec.mjs index bdbe0eb985..93970814db 100644 --- a/tests/ui/specs/document/blocks/view/projection.spec.mjs +++ b/tests/ui/specs/document/blocks/view/projection.spec.mjs @@ -2,7 +2,7 @@ // // A view lists the resources its query's first variable binds: it wraps the SELECT in a DESCRIBE // of that variable, and counts it for the pager. The variable may be projected plain, ?resource, -// or as an expression's alias, (?s AS ?resource) - SPARQL.js gives the two in different shapes, +// or as an expression's alias, (?s AS ?resource) - the parser gives the two in different shapes, // and reading only the plain one left the name empty and the whole block failing to render. An // alias is as good a variable as any. What a view cannot show is a first variable that binds // values rather than resources, (YEAR(NOW()) AS ?year): the count finds rows where the DESCRIBE From 607111fb2115316526bf6180223b55da67884902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:30:51 +0100 Subject: [PATCH 10/13] A facet's label lookup matches the array that holds the basic graph pattern, a match pattern Saxon-HE compiles as well as Saxon-JS Co-Authored-By: Claude Opus 5.5 --- .../com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl index dee738aadd..bad1dd5118 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/query-transforms.xsl @@ -794,7 +794,7 @@ extension-element-prefixes="ixsl" - + From e95af0b2228ed83aad1e59fca4ac3f79b7b65e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 22:53:33 +0100 Subject: [PATCH 11/13] The page-load test prints what a failure alert and a page error said Co-Authored-By: Claude Opus 5.5 --- tests/load/page-load/measure.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/load/page-load/measure.mjs b/tests/load/page-load/measure.mjs index d331a58c53..bdd1cfddfb 100644 --- a/tests/load/page-load/measure.mjs +++ b/tests/load/page-load/measure.mjs @@ -99,7 +99,9 @@ async function load(browser, url) { if (response.status() === 429) refused++; statuses.set(keyOf(request), [...(statuses.get(keyOf(request)) ?? []), response.status()]); }); - page.on('pageerror', () => errors++); + const errorMessages = []; + page.on('pageerror', error => { errors++; errorMessages.push(error.message); }); + page.on('console', message => { if (message.type() === 'error') errorMessages.push(message.text()); }); await page.goto(url, { waitUntil: 'load', timeout: LOAD_TIMEOUT_MS }); const deadline = t0 + LOAD_TIMEOUT_MS; @@ -109,9 +111,10 @@ async function load(browser, url) { const timedOut = Date.now() >= deadline; const lost = [...statuses.entries()].filter(([, s]) => s.includes(429) && s.at(-1) === 429).map(([key]) => key); - const failures = await page.locator('.ldh-failure').count(); + const failureTexts = await page.locator('.ldh-failure').allTextContents(); + const failures = failureTexts.length; await context.close(); - return { requests, refused, lost: lost.length, lostRequests: lost, failures, errors, timedOut, settleMs: last - t0 }; + return { requests, refused, lost: lost.length, lostRequests: lost, failures, failureTexts, errors, errorMessages, timedOut, settleMs: last - t0 }; } const { exempt, limited } = await nginxAddresses(); @@ -140,6 +143,9 @@ for (let i = 1; i <= LOADS; i++) { console.log(`load ${i}/${LOADS} ${url}`); console.log(` exempt ${e.requests} requests, ${e.refused} refused, ${e.lost} lost, ${e.failures} failures, settled ${e.settleMs} ms`); console.log(` limited ${l.requests} requests, ${l.refused} refused, ${l.lost} lost, ${l.failures} failures, settled ${l.settleMs} ms`); + // what a failure said, so a red run names its cause + for (const text of new Set([...e.failureTexts, ...l.failureTexts])) console.log(` DEBUG failure: ${text.replace(/\s+/g, ' ').trim()}`); + for (const text of new Set([...e.errorMessages, ...l.errorMessages])) console.log(` DEBUG error: ${text}`); } } From 07a3a593c213f29e57fc2ece14d363a771d1a167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Wed, 18 Nov 2026 23:10:14 +0100 Subject: [PATCH 12/13] A view's sort map is keyed by the variable name as a string, which the Traqula port had keyed by its JSON node Co-Authored-By: Claude Opus 5.5 --- .../com/atomgraph/linkeddatahub/xsl/client/block/view.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl index c2174e0b0d..ba698b0124 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/block/view.xsl @@ -3059,7 +3059,7 @@ exclude-result-prefixes="#all" - + From 916fbb2a3617dd069eb672d8975d6aa49221ceed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Thu, 19 Nov 2026 00:09:03 +0100 Subject: [PATCH 13/13] A new constructor row's object control reads its blank node only from a template triple, so the add-row button, which calls it from the HTML form, no longer passes the button to ldh:term-key Co-Authored-By: Claude Opus 5.5 --- .../com/atomgraph/linkeddatahub/xsl/client/constructor.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl index 3ec3a1ba40..c6277d7292 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client/constructor.xsl @@ -450,7 +450,7 @@ exclude-result-prefixes="#all" - +