@matdata/yasgui-explain-plugin 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +90 -2
- package/dist/ExplainPlugin.d.ts +64 -0
- package/dist/ExplainPlugin.d.ts.map +1 -0
- package/dist/algebra/print.d.ts +21 -0
- package/dist/algebra/print.d.ts.map +1 -0
- package/dist/algebra/terms.d.ts +18 -0
- package/dist/algebra/terms.d.ts.map +1 -0
- package/dist/algebra/translate.d.ts +19 -0
- package/dist/algebra/translate.d.ts.map +1 -0
- package/dist/engines/blazegraph.d.ts +12 -0
- package/dist/engines/blazegraph.d.ts.map +1 -0
- package/dist/engines/graphdb.d.ts +23 -0
- package/dist/engines/graphdb.d.ts.map +1 -0
- package/dist/engines/index.d.ts +23 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/neptune.d.ts +11 -0
- package/dist/engines/neptune.d.ts.map +1 -0
- package/dist/engines/qlever.d.ts +35 -0
- package/dist/engines/qlever.d.ts.map +1 -0
- package/dist/engines/stardog.d.ts +14 -0
- package/dist/engines/stardog.d.ts.map +1 -0
- package/dist/host.d.ts +24 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/icons.d.ts +22 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/render.d.ts +46 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/settings.d.ts +11 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/yasgui-explain-plugin.cjs.js +20519 -0
- package/dist/yasgui-explain-plugin.cjs.js.map +7 -0
- package/dist/yasgui-explain-plugin.css +354 -0
- package/dist/yasgui-explain-plugin.esm.js +20513 -0
- package/dist/yasgui-explain-plugin.esm.js.map +7 -0
- package/dist/yasgui-explain-plugin.min.css +1 -0
- package/dist/yasgui-explain-plugin.min.js +146 -0
- package/dist/yasgui-explain-plugin.min.js.map +7 -0
- package/package.json +71 -4
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";var YasguiExplainPlugin=(()=>{var kb=Object.create;var Pn=Object.defineProperty;var Cb=Object.getOwnPropertyDescriptor;var Rb=Object.getOwnPropertyNames;var Fb=Object.getPrototypeOf,Mb=Object.prototype.hasOwnProperty;var Db=(e,t,r)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var lt=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Ze=(e,t)=>{for(var r in t)Pn(e,r,{get:t[r],enumerable:!0})},dp=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Rb(t))!Mb.call(e,i)&&i!==r&&Pn(e,i,{get:()=>t[i],enumerable:!(n=Cb(t,i))||n.enumerable});return e};var _n=(e,t,r)=>(r=e!=null?kb(Fb(e)):{},dp(t||!e||!e.__esModule?Pn(r,"default",{value:e,enumerable:!0}):r,e)),jb=e=>dp(Pn({},"__esModule",{value:!0}),e);var H=(e,t,r)=>Db(e,typeof t!="symbol"?t+"":t,r);var rb=lt((yD,tb)=>{"use strict";tb.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,a;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(a=Object.keys(t),n=a.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,a[i]))return!1;for(i=n;i--!==0;){var s=a[i];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r}});var Fu=lt(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.BlankNode=void 0;var Ru=class{constructor(t){this.termType="BlankNode",this.value=t}equals(t){return!!t&&t.termType==="BlankNode"&&t.value===this.value}};yo.BlankNode=Ru});var Mu=lt(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.DefaultGraph=void 0;var Pi=class{constructor(){this.termType="DefaultGraph",this.value=""}equals(t){return!!t&&t.termType==="DefaultGraph"}};bo.DefaultGraph=Pi;Pi.INSTANCE=new Pi});var xo=lt(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.NamedNode=void 0;var Du=class{constructor(t){this.termType="NamedNode",this.value=t}equals(t){return!!t&&t.termType==="NamedNode"&&t.value===this.value}};vo.NamedNode=Du});var Gu=lt(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.Literal=void 0;var ju=xo(),An=class e{constructor(t,r){var n;this.termType="Literal",this.value=t,typeof r=="string"?(this.language=r.toLowerCase(),this.datatype=e.RDF_LANGUAGE_STRING,this.direction=""):r?"termType"in r?(this.language="",this.datatype=r,this.direction=""):(this.language=r.language.toLowerCase(),this.datatype=r.direction?e.RDF_DIRECTIONAL_LANGUAGE_STRING:e.RDF_LANGUAGE_STRING,this.direction=(n=r.direction)!==null&&n!==void 0?n:""):(this.language="",this.datatype=e.XSD_STRING,this.direction="")}equals(t){return!!t&&t.termType==="Literal"&&t.value===this.value&&t.language===this.language&&(t.direction===this.direction||!t.direction&&this.direction==="")&&this.datatype.equals(t.datatype)}};Ao.Literal=An;An.RDF_LANGUAGE_STRING=new ju.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");An.RDF_DIRECTIONAL_LANGUAGE_STRING=new ju.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString");An.XSD_STRING=new ju.NamedNode("http://www.w3.org/2001/XMLSchema#string")});var Vu=lt(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.Quad=void 0;var $u=class{constructor(t,r,n,i){this.termType="Quad",this.value="",this.subject=t,this.predicate=r,this.object=n,this.graph=i}equals(t){return!!t&&(t.termType==="Quad"||!t.termType)&&this.subject.equals(t.subject)&&this.predicate.equals(t.predicate)&&this.object.equals(t.object)&&this.graph.equals(t.graph)}};Eo.Quad=$u});var Ku=lt(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.Variable=void 0;var Hu=class{constructor(t){this.termType="Variable",this.value=t}equals(t){return!!t&&t.termType==="Variable"&&t.value===this.value}};Io.Variable=Hu});var sb=lt(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.DataFactory=void 0;var oC=Fu(),lC=Mu(),ab=Gu(),cC=xo(),uC=Vu(),pC=Ku(),dC=0,qu=class{constructor(t){var r;this.blankNodeCounter=0,t=t!=null?t:{},this.blankNodePrefix=(r=t.blankNodePrefix)!==null&&r!==void 0?r:`df_${dC++}_`}namedNode(t){return new cC.NamedNode(t)}blankNode(t){return new oC.BlankNode(t!=null?t:`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(t,r){return new ab.Literal(t,r)}variable(t){return new pC.Variable(t)}defaultGraph(){return lC.DefaultGraph.INSTANCE}quad(t,r,n,i){return new uC.Quad(t,r,n,i!=null?i:this.defaultGraph())}fromTerm(t){switch(t.termType){case"NamedNode":return this.namedNode(t.value);case"BlankNode":return this.blankNode(t.value);case"Literal":return t.language?this.literal(t.value,t.language):t.datatype.equals(ab.Literal.XSD_STRING)?this.literal(t.value):this.literal(t.value,this.fromTerm(t.datatype));case"Variable":return this.variable(t.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(t.subject),this.fromTerm(t.predicate),this.fromTerm(t.object),this.fromTerm(t.graph))}}fromQuad(t){return this.fromTerm(t)}resetBlankNodeCounter(){this.blankNodeCounter=0}};Lo.DataFactory=qu});var Po=lt(Qe=>{"use strict";var fC=Qe&&Qe.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),Mr=Qe&&Qe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&fC(t,e,r)};Object.defineProperty(Qe,"__esModule",{value:!0});Mr(Fu(),Qe);Mr(sb(),Qe);Mr(Mu(),Qe);Mr(Gu(),Qe);Mr(xo(),Qe);Mr(Vu(),Qe);Mr(Ku(),Qe)});var db=lt(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.termToString=Wt;Ct.getLiteralValue=lb;Ct.getLiteralType=cb;Ct.getLiteralLanguage=ub;Ct.getLiteralDirection=pb;Ct.stringToTerm=Yt;Ct.quadToStringQuad=mC;Ct.stringQuadToQuad=gC;var hC=Po(),ob=new hC.DataFactory;function Wt(e){if(e)switch(e.termType){case"NamedNode":return e.value;case"BlankNode":return"_:"+e.value;case"Literal":let t=e;return'"'+t.value+'"'+(t.datatype&&t.datatype.value!=="http://www.w3.org/2001/XMLSchema#string"&&t.datatype.value!=="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"&&t.datatype.value!=="http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString"?"^^"+t.datatype.value:"")+(t.language?"@"+t.language:"")+(t.direction?"--"+t.direction:"");case"Quad":return`<<${Wt(e.subject)} ${Wt(e.predicate)} ${Wt(e.object)}${e.graph.termType==="DefaultGraph"?"":" "+Wt(e.graph)}>>`;case"Variable":return"?"+e.value;case"DefaultGraph":return e.value}}function lb(e){let t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]}function cb(e){let t=/^"[^]*"(?:\^\^([^"]+)|(@)[^@"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]||(t[2]?"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString":"http://www.w3.org/2001/XMLSchema#string")}function ub(e){let t=/^"[^]*"(?:@([^@"]+)|\^\^[^"]+)?$/.exec(e);if(!t)throw new Error(e+" is not a literal");if(t[1]){let r=t[1].toLowerCase(),n=r.indexOf("--");return n>=0&&(r=r.slice(0,n)),r}return""}function pb(e){let t=e.indexOf("--",e.lastIndexOf('"'));if(t>=0){let r=e.slice(t+2,e.length);if(r==="ltr"||r==="rtl")return r;throw new Error(e+" is not a literal with a valid direction")}return""}function Yt(e,t){if(t=t||ob,!e||!e.length)return t.defaultGraph();switch(e[0]){case"_":return t.blankNode(e.substr(2));case"?":if(!t.variable)throw new Error("Missing 'variable()' method on the given DataFactory");return t.variable(e.substr(1));case'"':let r=ub(e),n=pb(e),i=t.namedNode(cb(e));return t.literal(lb(e),r?{language:r,direction:n}:i);default:if(e[0]==="<"&&e.length>4&&e[1]==="<"&&e[e.length-1]===">"&&e[e.length-2]===">"){let a=e.slice(2,-2).trim(),s=[],o=0,l=0,c=!1;for(let u=0;u<a.length;u++){let p=a[u];if(p==="<"&&o++,p===">"){if(o===0)throw new Error("Found closing tag without opening tag in "+e);o--}if(p==='"'){let f=!1,h=u;for(;h-- >0&&a[h]==="\\";)f=!f;f||(c=!c)}if(p===" "&&!c&&o===0){for(s.push(a.slice(l,u));a[u+1]===" ";)u+=1;l=u+1}}if(o!==0)throw new Error("Found opening tag without closing tag in "+e);if(s.push(a.slice(l,a.length)),s.length!==3&&s.length!==4)throw new Error("Nested quad syntax error "+e);return s=s.map(u=>u.startsWith("<")&&!u.includes(" ")?u.slice(1,-1):u),t.quad(Yt(s[0]),Yt(s[1]),Yt(s[2]),s[3]?Yt(s[3]):void 0)}return t.namedNode(e)}}function mC(e){return{subject:Wt(e.subject),predicate:Wt(e.predicate),object:Wt(e.object),graph:Wt(e.graph)}}function gC(e,t){return t=t||ob,t.quad(Yt(e.subject,t),Yt(e.predicate,t),Yt(e.object,t),Yt(e.graph,t))}});var zu=lt(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.termToString=Ie.stringToTerm=Ie.stringQuadToQuad=Ie.quadToStringQuad=Ie.getLiteralValue=Ie.getLiteralType=Ie.getLiteralDirection=Ie.getLiteralLanguage=void 0;var fr=db();Object.defineProperty(Ie,"getLiteralLanguage",{enumerable:!0,get:function(){return fr.getLiteralLanguage}});Object.defineProperty(Ie,"getLiteralDirection",{enumerable:!0,get:function(){return fr.getLiteralDirection}});Object.defineProperty(Ie,"getLiteralType",{enumerable:!0,get:function(){return fr.getLiteralType}});Object.defineProperty(Ie,"getLiteralValue",{enumerable:!0,get:function(){return fr.getLiteralValue}});Object.defineProperty(Ie,"quadToStringQuad",{enumerable:!0,get:function(){return fr.quadToStringQuad}});Object.defineProperty(Ie,"stringQuadToQuad",{enumerable:!0,get:function(){return fr.stringQuadToQuad}});Object.defineProperty(Ie,"stringToTerm",{enumerable:!0,get:function(){return fr.stringToTerm}});Object.defineProperty(Ie,"termToString",{enumerable:!0,get:function(){return fr.termToString}})});var SC={};Ze(SC,{AlgebraError:()=>Bt,ENGINES:()=>tr,ENGINE_IDS:()=>Ci,ExplainPlugin:()=>Go,default:()=>OC,detectEngine:()=>Vo,toSExpression:()=>Mo,toTree:()=>Ln,translate:()=>Co});var Gb="application/qlever-results+json";function Tr(e){return typeof e=="number"&&Number.isFinite(e)}function ki(e){return e.toLocaleString("en-US")}function $b(e,t){return t&&typeof t=="object"?`${e}: ${JSON.stringify(t)}`:`${e}: ${String(t)}`}function fp(e){let t=e.was_cached===!0||typeof e.cache_status=="string"&&e.cache_status!=="computed"&&e.cache_status!=="not_cached",r=[];if(typeof e.cache_status=="string"&&e.cache_status!=="computed"&&r.push(`cache: ${e.cache_status.replace(/_/g," ")}`),Tr(e.estimated_size)&&r.push(`estimated size: ${ki(e.estimated_size)}`),Tr(e.estimated_operation_cost)&&r.push(`estimated cost: ${ki(e.estimated_operation_cost)}`),Array.isArray(e.estimated_column_multiplicities)&&e.estimated_column_multiplicities.length&&r.push(`estimated multiplicities: ${e.estimated_column_multiplicities.join(", ")}`),e.details&&typeof e.details=="object")for(let[n,i]of Object.entries(e.details))i==null||i===""||r.push($b(n.replace(/_/g," "),i));return{label:(e.description||"operation").replace(/\s+/g," ").trim(),details:r,rows:Tr(e.result_rows)?e.result_rows:void 0,columns:Array.isArray(e.column_names)?e.column_names.map(String):void 0,timeMs:Tr(e.operation_time)?e.operation_time:void 0,totalMs:Tr(e.total_time)?e.total_time:void 0,cached:t,status:typeof e.status=="string"?e.status:void 0,children:Array.isArray(e.children)?e.children.map(fp):[]}}function Nn(e){if(Tr(e))return`${ki(e)} ms`;if(typeof e=="string")return e}function Vb(e){var s;let t;try{t=JSON.parse(e)}catch(o){throw new Error("QLever did not return JSON. Is this endpoint a QLever instance?")}if(t&&typeof t=="object"&&t.status==="ERROR")throw new Error(`QLever reported an error: ${t.exception||t.error||"unknown error"}`);let r=t==null?void 0:t.runtimeInformation;if(!r||typeof r!="object")throw new Error("The response carries no runtime information. Is this endpoint a QLever instance?");let n=(s=r.query_execution_tree)!=null?s:r.description?r:void 0;if(!n)throw new Error("The runtime information holds no query execution tree.");let i=[],a=r.meta;if(a&&typeof a=="object"){let o=Nn(a.time_query_planning);o&&i.push(`Query planning: ${o}`);let l=Nn(a.total_time_computing);l&&i.push(`Computing: ${l}`);let c=Nn(a.total_time);c&&i.push(`Total: ${c}`)}if(t.time&&typeof t.time=="object"&&i.length===0){let o=Nn(t.time.total);o&&i.push(`Total: ${o}`);let l=Nn(t.time.computeResult);l&&i.push(`Computing: ${l}`)}return Tr(t.resultsize)&&i.push(`Result size: ${ki(t.resultsize)} rows`),Array.isArray(t.warnings)&&t.warnings.length&&i.push(`Warnings: ${t.warnings.map(String).join(" | ")}`),{kind:"tree",root:fp(n),summary:i}}var hp={id:"qlever",label:"QLever",description:"The operations QLever executed, with the time and rows of each.",needsRequestOptions:!1,buildRequest(e){return{query:e,accept:Gb,extraArgs:{send:"1"}}},parse(e){return Vb(e)}};var Hb="http://www.ontotext.com/explain";function Kb(e){let t=qb(e);if(t<0)throw new Error("Could not find the WHERE clause of the query to add the explain graph to.");let r=`FROM <${Hb}>`,n=e.slice(0,t),i=n.length>0&&!/\s$/.test(n);return`${n}${i?" ":""}${r} ${e.slice(t)}`}function qb(e){let t=0,r=e.length,n=!1,i=0,a=-1,s=0;for(;t<r;){let o=e[t];if(o==="#"){for(;t<r&&e[t]!==`
|
|
2
|
+
`;)t++;continue}if(o==="<"){let l=e.indexOf(">",t+1);if(l>0&&!/\s/.test(e.slice(t+1,l))){t=l+1;continue}}if(o==='"'||o==="'"){t=zb(e,t);continue}if(o==="{"){n&&i===0&&a<0&&(s>0?s--:a=t),i++,t++;continue}if(o==="}"){i--,t++;continue}if(/[A-Za-z]/.test(o)){let l=t;for(;l<r&&/[A-Za-z_]/.test(e[l]);)l++;let c=e.slice(t,l).toUpperCase();if(i===0){if(c==="SELECT"||c==="CONSTRUCT"||c==="DESCRIBE"||c==="ASK")n=!0,a=-1,s=c==="CONSTRUCT"?1:0;else if(c==="WHERE"&&n)return t}t=l;continue}t++}return a}function zb(e,t){let r=e[t],n=e.startsWith(r.repeat(3),t),i=n?r.repeat(3):r,a=t+i.length;for(;a<e.length;){if(e[a]==="\\"){a+=2;continue}if(e.startsWith(i,a))return a+i.length;if(!n&&e[a]===`
|
|
3
|
+
`)return a;a++}return e.length}function Wb(e,t){var n;let r=e.trim();if(!r)throw new Error("GraphDB returned an empty response.");if(/json/i.test(t||"")||r.startsWith("{"))try{let i=JSON.parse(r),a=(n=i==null?void 0:i.results)==null?void 0:n.bindings;if(Array.isArray(a)){let s=[];for(let o of a)for(let l of Object.values(o))l&&typeof l.value=="string"&&s.push(l.value);if(s.length===0)throw new Error("GraphDB returned results instead of a plan. The onto:explain pseudo graph needs GraphDB; RDF4J does not support it.");return{kind:"text",text:s.join(`
|
|
4
|
+
`)}}}catch(i){if(i instanceof Error&&i.message.startsWith("GraphDB returned"))throw i}if(/^<\?xml|^<sparql/i.test(r))throw new Error("GraphDB returned results instead of a plan. The onto:explain pseudo graph needs GraphDB; RDF4J does not support it.");return{kind:"text",text:r}}var mp={id:"graphdb",label:"GraphDB",description:"The plan GraphDB chose, with the order of the patterns and estimated sizes (no timings).",needsRequestOptions:!1,buildRequest(e){return{query:Kb(e),accept:"text/plain, application/sparql-results+json;q=0.9, */*;q=0.1"}},parse(e,t){return Wb(e,t)}};function Yb(e){let[t,r]=Qb(e),n=t.replace(/\/+$/,"");return/\/(query|update)$/i.test(n)?n.replace(/\/(query|update)$/i,"/explain")+r:/\/explain$/i.test(n)?n+r:`${n}/explain${r}`}function Qb(e){let t=e.search(/[?#]/);return t<0?[e,""]:[e.slice(0,t),e.slice(t)]}function Xb(e){let t=e.trim();if(!t)throw new Error("Stardog returned an empty response.");if(t.startsWith("{"))try{let r=JSON.parse(t);if(r&&typeof r=="object"&&typeof r.message=="string")throw new Error(`Stardog reported an error: ${r.message}`);if(r&&typeof r=="object"&&typeof r.plan=="string")return{kind:"text",text:r.plan}}catch(r){if(r instanceof Error&&r.message.startsWith("Stardog reported"))throw r}return{kind:"text",text:t}}var gp={id:"stardog",label:"Stardog",description:"The profiled plan from Stardog, with rows, wall time and memory of each operator.",needsRequestOptions:!0,buildRequest(e,t){return{query:e,accept:"text/plain, application/json;q=0.5, */*;q=0.1",extraArgs:{profile:"true"},endpoint:Yb(t)}},parse(e){return Xb(e)}};function Bb(e,t){let r=e.trim();if(!r)throw new Error("Blazegraph returned an empty response.");if(/html/i.test(t||"")||/^<!doctype html|^<html/i.test(r))return{kind:"html",html:e};if(/^<\?xml|^<sparql|^\{/.test(r))throw new Error("The endpoint returned results instead of an explain page. Is this a Blazegraph instance?");return{kind:"text",text:r}}var Tp={id:"blazegraph",label:"Blazegraph",description:"The explain page of Blazegraph: abstract syntax tree, operator plan and statistics.",needsRequestOptions:!0,buildRequest(e){return{query:e,accept:"text/html, */*;q=0.1",extraArgs:{explain:"details"}}},parse(e,t){return Bb(e,t)}};function Jb(e,t){var n;let r=e.trim();if(!r)throw new Error("Neptune returned an empty response.");if(/html/i.test(t||"")||/^<!doctype html|^<html/i.test(r))return{kind:"html",html:e};if(r.startsWith("{"))try{let i=JSON.parse(r);if(i&&typeof i=="object"&&(i.detailedMessage||i.message))throw new Error(`Neptune reported an error: ${i.detailedMessage||i.message}`);if((n=i==null?void 0:i.results)!=null&&n.bindings)throw new Error("The endpoint returned results instead of an explain table. Is this a Neptune instance?")}catch(i){if(i instanceof Error&&!(i instanceof SyntaxError))throw i}return{kind:"text",text:r}}var yp={id:"neptune",label:"Neptune",description:"The explain table of Amazon Neptune, one row per operator with its time.",needsRequestOptions:!0,buildRequest(e){return{query:e,accept:"text/plain, */*;q=0.1",extraArgs:{explain:"details"}}},parse(e,t){return Jb(e,t)}};var tr={qlever:hp,graphdb:mp,stardog:gp,blazegraph:Tp,neptune:yp},Ci=["qlever","graphdb","stardog","blazegraph","neptune"];function bp(e){return typeof e=="string"&&e in tr}function On(e){return e==="auto"||e==="none"||bp(e)}function Vo(e,t){let r=(t||"").toLowerCase();if(r.includes("qlever"))return"qlever";if(r.includes("graphdb"))return"graphdb";if(r.includes("stardog"))return"stardog";if(r.includes("blazegraph")||r.includes("bigdata"))return"blazegraph";if(!e)return;let n;try{n=new URL(e)}catch(s){return}let i=n.hostname.toLowerCase(),a=n.pathname.toLowerCase();if(i.includes("qlever")||a.includes("qlever"))return"qlever";if(i.includes("neptune.amazonaws.com")||i.endsWith(".neptune.amazonaws.com"))return"neptune";if(/\/(bigdata|blazegraph)(\/|$)/.test(a)||i==="query.wikidata.org")return"blazegraph";if(i==="lindas.admin.ch"||i==="ld.admin.ch")return"stardog";if(i.includes("graphdb")||a.includes("graphdb")||/\/repositories\/[^/]+\/?$/.test(a))return"graphdb";if(i.includes("stardog")||a.includes("stardog")||n.port==="5820"||/\/[^/]+\/query\/?$/.test(a))return"stardog"}function vp(e,t,r,n){let i=n&&n!=="auto"?n:e,a=n&&n!=="auto"?"forced":"stored";if(i==="none")return{engine:void 0,source:a};if(bp(i))return{engine:tr[i],source:a};let s=Vo(t,r);return s?{engine:tr[s],source:"detected"}:{engine:void 0,source:"none"}}var xp="yasgui-explain-plugin:engines";function Ap(){try{let e=window.localStorage.getItem(xp);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!="object")return{};let r={};for(let[n,i]of Object.entries(t))On(i)&&(r[n]=i);return r}catch(e){return{}}}function Ko(e){var t;return e&&(t=Ap()[Ho(e)])!=null?t:"auto"}function Ep(e,t){if(e)try{let r=Ap();t==="auto"?delete r[Ho(e)]:r[Ho(e)]=t,window.localStorage.setItem(xp,JSON.stringify(r))}catch(r){}}function Ho(e){return e.trim().replace(/\/+$/,"")}function Ip(e){var t;if(!((t=e==null?void 0:e.hostApi)!=null&&t.toolbar)||typeof e.getPluginToolbar!="function")return null;try{let r=e.getPluginToolbar();return r instanceof HTMLElement?r:null}catch(r){return console.warn("yasgui-explain-plugin: could not get the plugin toolbar",r),null}}function Lp(e){var t;return!!((t=e==null?void 0:e.hostApi)!=null&&t.queryRequest)&&typeof e.executeQuery=="function"}function Pp(e){return typeof(e==null?void 0:e.executeQuery)=="function"}function _p(e){var o,l,c;let t=(o=e==null?void 0:e.config)==null?void 0:o.getPlainQueryLinkToEndpoint;if(typeof t!="function")return{};let r;try{r=t()}catch(u){return console.warn("yasgui-explain-plugin: could not read the query link",u),{}}if(!r)return{};let n=r.indexOf("?");if(n<0)return{endpoint:r};let i=r.slice(0,n),a=new URLSearchParams(r.slice(n+1)),s=(c=(l=a.get("query"))!=null?l:a.get("update"))!=null?c:void 0;return{query:s!=null?s:void 0,endpoint:i}}var Ri=class{constructor(t={}){H(this,"tracksSourceLocation");var r;this.tracksSourceLocation=(r=t.tracksSourceLocation)!=null?r:!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(s=>s!==void 0);if(r.length===0)return this.sourceLocationNoMaterialize();let n=r.filter(s=>!this.isLocalized(s)||this.isSourceLocationSource(s.loc)||this.isSourceLocationStringReplace(s.loc)||this.isSourceLocationNodeReplace(s.loc));if(n.length===0)return this.gen();let i=n.at(0),a=n.at(-1);return{sourceLocationType:"source",start:this.isLocalized(i)?i.loc.start:i.startOffset,end:this.isLocalized(a)?a.loc.end:a.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,a=>this.forcedAutoGenTree(a));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,a=0,s=t.length){return this.tracksSourceLocation?(this.isSourceLocationSource(r)&&(a=r.start,s=r.end),{sourceLocationType:"inlinedSource",newSource:t,start:n,end:i,loc:r,startOnNew:a,endOnNew:s}):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 Zb=typeof global=="object"&&global&&global.Object===Object&&global,wd=Zb,Ub=typeof self=="object"&&self&&self.Object===Object&&self,ev=wd||Ub||Function("return this")(),Et=ev,tv=Et.Symbol,et=tv,kd=Object.prototype,rv=kd.hasOwnProperty,nv=kd.toString,Sn=et?et.toStringTag:void 0;function iv(e){var t=rv.call(e,Sn),r=e[Sn];try{e[Sn]=void 0;var n=!0}catch(a){}var i=nv.call(e);return n&&(t?e[Sn]=r:delete e[Sn]),i}var av=iv,sv=Object.prototype,ov=sv.toString;function lv(e){return ov.call(e)}var cv=lv,uv="[object Null]",pv="[object Undefined]",Np=et?et.toStringTag:void 0;function dv(e){return e==null?e===void 0?pv:uv:Np&&Np in Object(e)?av(e):cv(e)}var ir=dv;function fv(e){return e!=null&&typeof e=="object"}var pt=fv,hv="[object Symbol]";function mv(e){return typeof e=="symbol"||pt(e)&&ir(e)==hv}var ia=mv;function gv(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var Kn=gv,Tv=Array.isArray,V=Tv,yv=1/0,Op=et?et.prototype:void 0,Sp=Op?Op.toString:void 0;function Cd(e){if(typeof e=="string")return e;if(V(e))return Kn(e,Cd)+"";if(ia(e))return Sp?Sp.call(e):"";var t=e+"";return t=="0"&&1/e==-yv?"-0":t}var bv=Cd,vv=/\s/;function xv(e){for(var t=e.length;t--&&vv.test(e.charAt(t)););return t}var Av=xv,Ev=/^\s+/;function Iv(e){return e&&e.slice(0,Av(e)+1).replace(Ev,"")}var Lv=Iv;function Pv(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var tt=Pv,wp=NaN,_v=/^[-+]0x[0-9a-f]+$/i,Nv=/^0b[01]+$/i,Ov=/^0o[0-7]+$/i,Sv=parseInt;function wv(e){if(typeof e=="number")return e;if(ia(e))return wp;if(tt(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=tt(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Lv(e);var r=Nv.test(e);return r||Ov.test(e)?Sv(e.slice(2),r?2:8):_v.test(e)?wp:+e}var kv=wv,kp=1/0,Cv=17976931348623157e292;function Rv(e){if(!e)return e===0?e:0;if(e=kv(e),e===kp||e===-kp){var t=e<0?-1:1;return t*Cv}return e===e?e:0}var Fv=Rv;function Mv(e){var t=Fv(e),r=t%1;return t===t?r?t-r:t:0}var qn=Mv;function Dv(e){return e}var zn=Dv,jv="[object AsyncFunction]",Gv="[object Function]",$v="[object GeneratorFunction]",Vv="[object Proxy]";function Hv(e){if(!tt(e))return!1;var t=ir(e);return t==Gv||t==$v||t==jv||t==Vv}var Gt=Hv,Kv=Et["__core-js_shared__"],qo=Kv,Cp=(function(){var e=/[^.]+$/.exec(qo&&qo.keys&&qo.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function qv(e){return!!Cp&&Cp in e}var zv=qv,Wv=Function.prototype,Yv=Wv.toString;function Qv(e){if(e!=null){try{return Yv.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Er=Qv,Xv=/[\\^$.*+?()[\]{}|]/g,Bv=/^\[object .+?Constructor\]$/,Jv=Function.prototype,Zv=Object.prototype,Uv=Jv.toString,ex=Zv.hasOwnProperty,tx=RegExp("^"+Uv.call(ex).replace(Xv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rx(e){if(!tt(e)||zv(e))return!1;var t=Gt(e)?tx:Bv;return t.test(Er(e))}var nx=rx;function ix(e,t){return e==null?void 0:e[t]}var ax=ix;function sx(e,t){var r=ax(e,t);return nx(r)?r:void 0}var Ir=sx,ox=Ir(Et,"WeakMap"),Zo=ox,Rp=Object.create,lx=(function(){function e(){}return function(t){if(!tt(t))return{};if(Rp)return Rp(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),cx=lx;function ux(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var px=ux;function dx(){}var Ee=dx;function fx(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var hx=fx,mx=800,gx=16,Tx=Date.now;function yx(e){var t=0,r=0;return function(){var n=Tx(),i=gx-(n-r);if(r=n,i>0){if(++t>=mx)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var bx=yx;function vx(e){return function(){return e}}var xx=vx,Ax=(function(){try{var e=Ir(Object,"defineProperty");return e({},"",{}),e}catch(t){}})(),Yi=Ax,Ex=Yi?function(e,t){return Yi(e,"toString",{configurable:!0,enumerable:!1,value:xx(t),writable:!0})}:zn,Ix=Ex,Lx=bx(Ix),Px=Lx;function _x(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var Rd=_x;function Nx(e,t,r,n){for(var i=e.length,a=r+(n?1:-1);n?a--:++a<i;)if(t(e[a],a,e))return a;return-1}var Fd=Nx;function Ox(e){return e!==e}var Sx=Ox;function wx(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var kx=wx;function Cx(e,t,r){return t===t?kx(e,t,r):Fd(e,Sx,r)}var fl=Cx;function Rx(e,t){var r=e==null?0:e.length;return!!r&&fl(e,t,0)>-1}var Md=Rx,Fx=9007199254740991,Mx=/^(?:0|[1-9]\d*)$/;function Dx(e,t){var r=typeof e;return t=t==null?Fx:t,!!t&&(r=="number"||r!="symbol"&&Mx.test(e))&&e>-1&&e%1==0&&e<t}var aa=Dx;function jx(e,t,r){t=="__proto__"&&Yi?Yi(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var hl=jx;function Gx(e,t){return e===t||e!==e&&t!==t}var Wn=Gx,$x=Object.prototype,Vx=$x.hasOwnProperty;function Hx(e,t,r){var n=e[t];(!(Vx.call(e,t)&&Wn(n,r))||r===void 0&&!(t in e))&&hl(e,t,r)}var sa=Hx;function Kx(e,t,r,n){var i=!r;r||(r={});for(var a=-1,s=t.length;++a<s;){var o=t[a],l=n?n(r[o],e[o],o,r,e):void 0;l===void 0&&(l=e[o]),i?hl(r,o,l):sa(r,o,l)}return r}var Yn=Kx,Fp=Math.max;function qx(e,t,r){return t=Fp(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=Fp(n.length-t,0),s=Array(a);++i<a;)s[i]=n[t+i];i=-1;for(var o=Array(t+1);++i<t;)o[i]=n[i];return o[t]=r(s),px(e,this,o)}}var zx=qx;function Wx(e,t){return Px(zx(e,t,zn),e+"")}var ml=Wx,Yx=9007199254740991;function Qx(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Yx}var gl=Qx;function Xx(e){return e!=null&&gl(e.length)&&!Gt(e)}var It=Xx;function Bx(e,t,r){if(!tt(r))return!1;var n=typeof t;return(n=="number"?It(r)&&aa(t,r.length):n=="string"&&t in r)?Wn(r[t],e):!1}var oa=Bx;function Jx(e){return ml(function(t,r){var n=-1,i=r.length,a=i>1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(a=e.length>3&&typeof a=="function"?(i--,a):void 0,s&&oa(r[0],r[1],s)&&(a=i<3?void 0:a,i=1),t=Object(t);++n<i;){var o=r[n];o&&e(t,o,n,a)}return t})}var Zx=Jx,Ux=Object.prototype;function eA(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||Ux;return e===r}var Qn=eA;function tA(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var rA=tA,nA="[object Arguments]";function iA(e){return pt(e)&&ir(e)==nA}var Mp=iA,Dd=Object.prototype,aA=Dd.hasOwnProperty,sA=Dd.propertyIsEnumerable,oA=Mp((function(){return arguments})())?Mp:function(e){return pt(e)&&aA.call(e,"callee")&&!sA.call(e,"callee")},la=oA;function lA(){return!1}var cA=lA,jd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dp=jd&&typeof module=="object"&&module&&!module.nodeType&&module,uA=Dp&&Dp.exports===jd,jp=uA?Et.Buffer:void 0,pA=jp?jp.isBuffer:void 0,dA=pA||cA,Gn=dA,fA="[object Arguments]",hA="[object Array]",mA="[object Boolean]",gA="[object Date]",TA="[object Error]",yA="[object Function]",bA="[object Map]",vA="[object Number]",xA="[object Object]",AA="[object RegExp]",EA="[object Set]",IA="[object String]",LA="[object WeakMap]",PA="[object ArrayBuffer]",_A="[object DataView]",NA="[object Float32Array]",OA="[object Float64Array]",SA="[object Int8Array]",wA="[object Int16Array]",kA="[object Int32Array]",CA="[object Uint8Array]",RA="[object Uint8ClampedArray]",FA="[object Uint16Array]",MA="[object Uint32Array]",U={};U[NA]=U[OA]=U[SA]=U[wA]=U[kA]=U[CA]=U[RA]=U[FA]=U[MA]=!0;U[fA]=U[hA]=U[PA]=U[mA]=U[_A]=U[gA]=U[TA]=U[yA]=U[bA]=U[vA]=U[xA]=U[AA]=U[EA]=U[IA]=U[LA]=!1;function DA(e){return pt(e)&&gl(e.length)&&!!U[ir(e)]}var jA=DA;function GA(e){return function(t){return e(t)}}var Xn=GA,Gd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mn=Gd&&typeof module=="object"&&module&&!module.nodeType&&module,$A=Mn&&Mn.exports===Gd,zo=$A&&wd.process,VA=(function(){try{var e=Mn&&Mn.require&&Mn.require("util").types;return e||zo&&zo.binding&&zo.binding("util")}catch(t){}})(),rr=VA,Gp=rr&&rr.isTypedArray,HA=Gp?Xn(Gp):jA,Tl=HA,KA=Object.prototype,qA=KA.hasOwnProperty;function zA(e,t){var r=V(e),n=!r&&la(e),i=!r&&!n&&Gn(e),a=!r&&!n&&!i&&Tl(e),s=r||n||i||a,o=s?rA(e.length,String):[],l=o.length;for(var c in e)(t||qA.call(e,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||aa(c,l)))&&o.push(c);return o}var $d=zA;function WA(e,t){return function(r){return e(t(r))}}var Vd=WA,YA=Vd(Object.keys,Object),QA=YA,XA=Object.prototype,BA=XA.hasOwnProperty;function JA(e){if(!Qn(e))return QA(e);var t=[];for(var r in Object(e))BA.call(e,r)&&r!="constructor"&&t.push(r);return t}var Hd=JA;function ZA(e){return It(e)?$d(e):Hd(e)}var Ke=ZA,UA=Object.prototype,eE=UA.hasOwnProperty,tE=Zx(function(e,t){if(Qn(t)||It(t)){Yn(t,Ke(t),e);return}for(var r in t)eE.call(t,r)&&sa(e,r,t[r])}),qe=tE;function rE(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var nE=rE,iE=Object.prototype,aE=iE.hasOwnProperty;function sE(e){if(!tt(e))return nE(e);var t=Qn(e),r=[];for(var n in e)n=="constructor"&&(t||!aE.call(e,n))||r.push(n);return r}var oE=sE;function lE(e){return It(e)?$d(e,!0):oE(e)}var ca=lE,cE=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uE=/^\w*$/;function pE(e,t){if(V(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||ia(e)?!0:uE.test(e)||!cE.test(e)||t!=null&&e in Object(t)}var yl=pE,dE=Ir(Object,"create"),$n=dE;function fE(){this.__data__=$n?$n(null):{},this.size=0}var hE=fE;function mE(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var gE=mE,TE="__lodash_hash_undefined__",yE=Object.prototype,bE=yE.hasOwnProperty;function vE(e){var t=this.__data__;if($n){var r=t[e];return r===TE?void 0:r}return bE.call(t,e)?t[e]:void 0}var xE=vE,AE=Object.prototype,EE=AE.hasOwnProperty;function IE(e){var t=this.__data__;return $n?t[e]!==void 0:EE.call(t,e)}var LE=IE,PE="__lodash_hash_undefined__";function _E(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=$n&&t===void 0?PE:t,this}var NE=_E;function zr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}zr.prototype.clear=hE;zr.prototype.delete=gE;zr.prototype.get=xE;zr.prototype.has=LE;zr.prototype.set=NE;var $p=zr;function OE(){this.__data__=[],this.size=0}var SE=OE;function wE(e,t){for(var r=e.length;r--;)if(Wn(e[r][0],t))return r;return-1}var ua=wE,kE=Array.prototype,CE=kE.splice;function RE(e){var t=this.__data__,r=ua(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():CE.call(t,r,1),--this.size,!0}var FE=RE;function ME(e){var t=this.__data__,r=ua(t,e);return r<0?void 0:t[r][1]}var DE=ME;function jE(e){return ua(this.__data__,e)>-1}var GE=jE;function $E(e,t){var r=this.__data__,n=ua(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var VE=$E;function Wr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Wr.prototype.clear=SE;Wr.prototype.delete=FE;Wr.prototype.get=DE;Wr.prototype.has=GE;Wr.prototype.set=VE;var pa=Wr,HE=Ir(Et,"Map"),Vn=HE;function KE(){this.size=0,this.__data__={hash:new $p,map:new(Vn||pa),string:new $p}}var qE=KE;function zE(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var WE=zE;function YE(e,t){var r=e.__data__;return WE(t)?r[typeof t=="string"?"string":"hash"]:r.map}var da=YE;function QE(e){var t=da(this,e).delete(e);return this.size-=t?1:0,t}var XE=QE;function BE(e){return da(this,e).get(e)}var JE=BE;function ZE(e){return da(this,e).has(e)}var UE=ZE;function eI(e,t){var r=da(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var tI=eI;function Yr(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Yr.prototype.clear=qE;Yr.prototype.delete=XE;Yr.prototype.get=JE;Yr.prototype.has=UE;Yr.prototype.set=tI;var fa=Yr,rI="Expected a function";function bl(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(rI);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var s=e.apply(this,n);return r.cache=a.set(i,s)||a,s};return r.cache=new(bl.Cache||fa),r}bl.Cache=fa;var nI=bl,iI=500;function aI(e){var t=nI(e,function(n){return r.size===iI&&r.clear(),n}),r=t.cache;return t}var sI=aI,oI=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lI=/\\(\\)?/g,cI=sI(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(oI,function(r,n,i,a){t.push(i?a.replace(lI,"$1"):n||r)}),t}),uI=cI;function pI(e){return e==null?"":bv(e)}var Kd=pI;function dI(e,t){return V(e)?e:yl(e,t)?[e]:uI(Kd(e))}var ha=dI,fI=1/0;function hI(e){if(typeof e=="string"||ia(e))return e;var t=e+"";return t=="0"&&1/e==-fI?"-0":t}var Bn=hI;function mI(e,t){t=ha(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Bn(t[r++])];return r&&r==n?e:void 0}var vl=mI;function gI(e,t,r){var n=e==null?void 0:vl(e,t);return n===void 0?r:n}var TI=gI;function yI(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var xl=yI,Vp=et?et.isConcatSpreadable:void 0;function bI(e){return V(e)||la(e)||!!(Vp&&e&&e[Vp])}var vI=bI;function qd(e,t,r,n,i){var a=-1,s=e.length;for(r||(r=vI),i||(i=[]);++a<s;){var o=e[a];t>0&&r(o)?t>1?qd(o,t-1,r,n,i):xl(i,o):n||(i[i.length]=o)}return i}var Al=qd;function xI(e){var t=e==null?0:e.length;return t?Al(e,1):[]}var ct=xI,AI=Vd(Object.getPrototypeOf,Object),zd=AI;function EI(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 a=Array(i);++n<i;)a[n]=e[n+t];return a}var El=EI;function II(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:El(e,t,r)}var LI=II,PI="\\ud800-\\udfff",_I="\\u0300-\\u036f",NI="\\ufe20-\\ufe2f",OI="\\u20d0-\\u20ff",SI=_I+NI+OI,wI="\\ufe0e\\ufe0f",kI="\\u200d",CI=RegExp("["+kI+PI+SI+wI+"]");function RI(e){return CI.test(e)}var Wd=RI;function FI(e){return e.split("")}var MI=FI,Yd="\\ud800-\\udfff",DI="\\u0300-\\u036f",jI="\\ufe20-\\ufe2f",GI="\\u20d0-\\u20ff",$I=DI+jI+GI,VI="\\ufe0e\\ufe0f",HI="["+Yd+"]",Uo="["+$I+"]",el="\\ud83c[\\udffb-\\udfff]",KI="(?:"+Uo+"|"+el+")",Qd="[^"+Yd+"]",Xd="(?:\\ud83c[\\udde6-\\uddff]){2}",Bd="[\\ud800-\\udbff][\\udc00-\\udfff]",qI="\\u200d",Jd=KI+"?",Zd="["+VI+"]?",zI="(?:"+qI+"(?:"+[Qd,Xd,Bd].join("|")+")"+Zd+Jd+")*",WI=Zd+Jd+zI,YI="(?:"+[Qd+Uo+"?",Uo,Xd,Bd,HI].join("|")+")",QI=RegExp(el+"(?="+el+")|"+YI+WI,"g");function XI(e){return e.match(QI)||[]}var BI=XI;function JI(e){return Wd(e)?BI(e):MI(e)}var ZI=JI;function UI(e){return function(t){t=Kd(t);var r=Wd(t)?ZI(t):void 0,n=r?r[0]:t.charAt(0),i=r?LI(r,1).join(""):t.slice(1);return n[e]()+i}}var eL=UI,QC=eL("toUpperCase");function tL(e,t,r,n){var i=-1,a=e==null?0:e.length;for(n&&a&&(r=e[++i]);++i<a;)r=t(r,e[i],i,e);return r}var rL=tL;function nL(){this.__data__=new pa,this.size=0}var iL=nL;function aL(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var sL=aL;function oL(e){return this.__data__.get(e)}var lL=oL;function cL(e){return this.__data__.has(e)}var uL=cL,pL=200;function dL(e,t){var r=this.__data__;if(r instanceof pa){var n=r.__data__;if(!Vn||n.length<pL-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new fa(n)}return r.set(e,t),this.size=r.size,this}var fL=dL;function Qr(e){var t=this.__data__=new pa(e);this.size=t.size}Qr.prototype.clear=iL;Qr.prototype.delete=sL;Qr.prototype.get=lL;Qr.prototype.has=uL;Qr.prototype.set=fL;var Dn=Qr;function hL(e,t){return e&&Yn(t,Ke(t),e)}var mL=hL;function gL(e,t){return e&&Yn(t,ca(t),e)}var TL=gL,Ud=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hp=Ud&&typeof module=="object"&&module&&!module.nodeType&&module,yL=Hp&&Hp.exports===Ud,Kp=yL?Et.Buffer:void 0,qp=Kp?Kp.allocUnsafe:void 0;function bL(e,t){if(t)return e.slice();var r=e.length,n=qp?qp(r):new e.constructor(r);return e.copy(n),n}var vL=bL;function xL(e,t){for(var r=-1,n=e==null?0:e.length,i=0,a=[];++r<n;){var s=e[r];t(s,r,e)&&(a[i++]=s)}return a}var Il=xL;function AL(){return[]}var ef=AL,EL=Object.prototype,IL=EL.propertyIsEnumerable,zp=Object.getOwnPropertySymbols,LL=zp?function(e){return e==null?[]:(e=Object(e),Il(zp(e),function(t){return IL.call(e,t)}))}:ef,Ll=LL;function PL(e,t){return Yn(e,Ll(e),t)}var _L=PL,NL=Object.getOwnPropertySymbols,OL=NL?function(e){for(var t=[];e;)xl(t,Ll(e)),e=zd(e);return t}:ef,tf=OL;function SL(e,t){return Yn(e,tf(e),t)}var wL=SL;function kL(e,t,r){var n=t(e);return V(e)?n:xl(n,r(e))}var rf=kL;function CL(e){return rf(e,Ke,Ll)}var tl=CL;function RL(e){return rf(e,ca,tf)}var nf=RL,FL=Ir(Et,"DataView"),rl=FL,ML=Ir(Et,"Promise"),nl=ML,DL=Ir(Et,"Set"),Vr=DL,Wp="[object Map]",jL="[object Object]",Yp="[object Promise]",Qp="[object Set]",Xp="[object WeakMap]",Bp="[object DataView]",GL=Er(rl),$L=Er(Vn),VL=Er(nl),HL=Er(Vr),KL=Er(Zo),yr=ir;(rl&&yr(new rl(new ArrayBuffer(1)))!=Bp||Vn&&yr(new Vn)!=Wp||nl&&yr(nl.resolve())!=Yp||Vr&&yr(new Vr)!=Qp||Zo&&yr(new Zo)!=Xp)&&(yr=function(e){var t=ir(e),r=t==jL?e.constructor:void 0,n=r?Er(r):"";if(n)switch(n){case GL:return Bp;case $L:return Wp;case VL:return Yp;case HL:return Qp;case KL:return Xp}return t});var Hr=yr,qL=Object.prototype,zL=qL.hasOwnProperty;function WL(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&zL.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var YL=WL,QL=Et.Uint8Array,Qi=QL;function XL(e){var t=new e.constructor(e.byteLength);return new Qi(t).set(new Qi(e)),t}var Pl=XL;function BL(e,t){var r=t?Pl(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var JL=BL,ZL=/\w*$/;function UL(e){var t=new e.constructor(e.source,ZL.exec(e));return t.lastIndex=e.lastIndex,t}var eP=UL,Jp=et?et.prototype:void 0,Zp=Jp?Jp.valueOf:void 0;function tP(e){return Zp?Object(Zp.call(e)):{}}var rP=tP;function nP(e,t){var r=t?Pl(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var iP=nP,aP="[object Boolean]",sP="[object Date]",oP="[object Map]",lP="[object Number]",cP="[object RegExp]",uP="[object Set]",pP="[object String]",dP="[object Symbol]",fP="[object ArrayBuffer]",hP="[object DataView]",mP="[object Float32Array]",gP="[object Float64Array]",TP="[object Int8Array]",yP="[object Int16Array]",bP="[object Int32Array]",vP="[object Uint8Array]",xP="[object Uint8ClampedArray]",AP="[object Uint16Array]",EP="[object Uint32Array]";function IP(e,t,r){var n=e.constructor;switch(t){case fP:return Pl(e);case aP:case sP:return new n(+e);case hP:return JL(e,r);case mP:case gP:case TP:case yP:case bP:case vP:case xP:case AP:case EP:return iP(e,r);case oP:return new n;case lP:case pP:return new n(e);case cP:return eP(e);case uP:return new n;case dP:return rP(e)}}var LP=IP;function PP(e){return typeof e.constructor=="function"&&!Qn(e)?cx(zd(e)):{}}var _P=PP,NP="[object Map]";function OP(e){return pt(e)&&Hr(e)==NP}var SP=OP,Up=rr&&rr.isMap,wP=Up?Xn(Up):SP,kP=wP,CP="[object Set]";function RP(e){return pt(e)&&Hr(e)==CP}var FP=RP,ed=rr&&rr.isSet,MP=ed?Xn(ed):FP,DP=MP,jP=1,GP=2,$P=4,af="[object Arguments]",VP="[object Array]",HP="[object Boolean]",KP="[object Date]",qP="[object Error]",sf="[object Function]",zP="[object GeneratorFunction]",WP="[object Map]",YP="[object Number]",of="[object Object]",QP="[object RegExp]",XP="[object Set]",BP="[object String]",JP="[object Symbol]",ZP="[object WeakMap]",UP="[object ArrayBuffer]",e_="[object DataView]",t_="[object Float32Array]",r_="[object Float64Array]",n_="[object Int8Array]",i_="[object Int16Array]",a_="[object Int32Array]",s_="[object Uint8Array]",o_="[object Uint8ClampedArray]",l_="[object Uint16Array]",c_="[object Uint32Array]",J={};J[af]=J[VP]=J[UP]=J[e_]=J[HP]=J[KP]=J[t_]=J[r_]=J[n_]=J[i_]=J[a_]=J[WP]=J[YP]=J[of]=J[QP]=J[XP]=J[BP]=J[JP]=J[s_]=J[o_]=J[l_]=J[c_]=!0;J[qP]=J[sf]=J[ZP]=!1;function Vi(e,t,r,n,i,a){var s,o=t&jP,l=t&GP,c=t&$P;if(r&&(s=i?r(e,n,i,a):r(e)),s!==void 0)return s;if(!tt(e))return e;var u=V(e);if(u){if(s=YL(e),!o)return hx(e,s)}else{var p=Hr(e),f=p==sf||p==zP;if(Gn(e))return vL(e,o);if(p==of||p==af||f&&!i){if(s=l||f?{}:_P(e),!o)return l?wL(e,TL(s,e)):_L(e,mL(s,e))}else{if(!J[p])return i?e:{};s=LP(e,p,o)}}a||(a=new Dn);var h=a.get(e);if(h)return h;a.set(e,s),DP(e)?e.forEach(function(x){s.add(Vi(x,t,r,x,e,a))}):kP(e)&&e.forEach(function(x,v){s.set(v,Vi(x,t,r,v,e,a))});var g=c?l?nf:tl:l?ca:Ke,T=u?void 0:g(e);return Rd(T||e,function(x,v){T&&(v=x,x=e[v]),sa(s,v,Vi(x,t,r,v,e,a))}),s}var u_=Vi,p_=4;function d_(e){return u_(e,p_)}var $e=d_;function f_(e){for(var t=-1,r=e==null?0:e.length,n=0,i=[];++t<r;){var a=e[t];a&&(i[n++]=a)}return i}var Jn=f_,h_="__lodash_hash_undefined__";function m_(e){return this.__data__.set(e,h_),this}var g_=m_;function T_(e){return this.__data__.has(e)}var y_=T_;function Xi(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new fa;++t<r;)this.add(e[t])}Xi.prototype.add=Xi.prototype.push=g_;Xi.prototype.has=y_;var _l=Xi;function b_(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var lf=b_;function v_(e,t){return e.has(t)}var Nl=v_,x_=1,A_=2;function E_(e,t,r,n,i,a){var s=r&x_,o=e.length,l=t.length;if(o!=l&&!(s&&l>o))return!1;var c=a.get(e),u=a.get(t);if(c&&u)return c==t&&u==e;var p=-1,f=!0,h=r&A_?new _l:void 0;for(a.set(e,t),a.set(t,e);++p<o;){var g=e[p],T=t[p];if(n)var x=s?n(T,g,p,t,e,a):n(g,T,p,e,t,a);if(x!==void 0){if(x)continue;f=!1;break}if(h){if(!lf(t,function(v,A){if(!Nl(h,A)&&(g===v||i(g,v,r,n,a)))return h.push(A)})){f=!1;break}}else if(!(g===T||i(g,T,r,n,a))){f=!1;break}}return a.delete(e),a.delete(t),f}var cf=E_;function I_(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var L_=I_;function P_(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Ol=P_,__=1,N_=2,O_="[object Boolean]",S_="[object Date]",w_="[object Error]",k_="[object Map]",C_="[object Number]",R_="[object RegExp]",F_="[object Set]",M_="[object String]",D_="[object Symbol]",j_="[object ArrayBuffer]",G_="[object DataView]",td=et?et.prototype:void 0,Wo=td?td.valueOf:void 0;function $_(e,t,r,n,i,a,s){switch(r){case G_:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case j_:return!(e.byteLength!=t.byteLength||!a(new Qi(e),new Qi(t)));case O_:case S_:case C_:return Wn(+e,+t);case w_:return e.name==t.name&&e.message==t.message;case R_:case M_:return e==t+"";case k_:var o=L_;case F_:var l=n&__;if(o||(o=Ol),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;n|=N_,s.set(e,t);var u=cf(o(e),o(t),n,i,a,s);return s.delete(e),u;case D_:if(Wo)return Wo.call(e)==Wo.call(t)}return!1}var V_=$_,H_=1,K_=Object.prototype,q_=K_.hasOwnProperty;function z_(e,t,r,n,i,a){var s=r&H_,o=tl(e),l=o.length,c=tl(t),u=c.length;if(l!=u&&!s)return!1;for(var p=l;p--;){var f=o[p];if(!(s?f in t:q_.call(t,f)))return!1}var h=a.get(e),g=a.get(t);if(h&&g)return h==t&&g==e;var T=!0;a.set(e,t),a.set(t,e);for(var x=s;++p<l;){f=o[p];var v=e[f],A=t[f];if(n)var y=s?n(A,v,f,t,e,a):n(v,A,f,e,t,a);if(!(y===void 0?v===A||i(v,A,r,n,a):y)){T=!1;break}x||(x=f=="constructor")}if(T&&!x){var L=e.constructor,S=t.constructor;L!=S&&"constructor"in e&&"constructor"in t&&!(typeof L=="function"&&L instanceof L&&typeof S=="function"&&S instanceof S)&&(T=!1)}return a.delete(e),a.delete(t),T}var W_=z_,Y_=1,rd="[object Arguments]",nd="[object Array]",Fi="[object Object]",Q_=Object.prototype,id=Q_.hasOwnProperty;function X_(e,t,r,n,i,a){var s=V(e),o=V(t),l=s?nd:Hr(e),c=o?nd:Hr(t);l=l==rd?Fi:l,c=c==rd?Fi:c;var u=l==Fi,p=c==Fi,f=l==c;if(f&&Gn(e)){if(!Gn(t))return!1;s=!0,u=!1}if(f&&!u)return a||(a=new Dn),s||Tl(e)?cf(e,t,r,n,i,a):V_(e,t,l,r,n,i,a);if(!(r&Y_)){var h=u&&id.call(e,"__wrapped__"),g=p&&id.call(t,"__wrapped__");if(h||g){var T=h?e.value():e,x=g?t.value():t;return a||(a=new Dn),i(T,x,r,n,a)}}return f?(a||(a=new Dn),W_(e,t,r,n,i,a)):!1}var B_=X_;function uf(e,t,r,n,i){return e===t?!0:e==null||t==null||!pt(e)&&!pt(t)?e!==e&&t!==t:B_(e,t,r,n,uf,i)}var pf=uf,J_=1,Z_=2;function U_(e,t,r,n){var i=r.length,a=i,s=!n;if(e==null)return!a;for(e=Object(e);i--;){var o=r[i];if(s&&o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++i<a;){o=r[i];var l=o[0],c=e[l],u=o[1];if(s&&o[2]){if(c===void 0&&!(l in e))return!1}else{var p=new Dn;if(n)var f=n(c,u,l,e,t,p);if(!(f===void 0?pf(u,c,J_|Z_,n,p):f))return!1}}return!0}var eN=U_;function tN(e){return e===e&&!tt(e)}var df=tN;function rN(e){for(var t=Ke(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,df(i)]}return t}var nN=rN;function iN(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var ff=iN;function aN(e){var t=nN(e);return t.length==1&&t[0][2]?ff(t[0][0],t[0][1]):function(r){return r===e||eN(r,e,t)}}var sN=aN;function oN(e,t){return e!=null&&t in Object(e)}var lN=oN;function cN(e,t,r){t=ha(t,e);for(var n=-1,i=t.length,a=!1;++n<i;){var s=Bn(t[n]);if(!(a=e!=null&&r(e,s)))break;e=e[s]}return a||++n!=i?a:(i=e==null?0:e.length,!!i&&gl(i)&&aa(s,i)&&(V(e)||la(e)))}var hf=cN;function uN(e,t){return e!=null&&hf(e,t,lN)}var pN=uN,dN=1,fN=2;function hN(e,t){return yl(e)&&df(t)?ff(Bn(e),t):function(r){var n=TI(r,e);return n===void 0&&n===t?pN(r,e):pf(t,n,dN|fN)}}var mN=hN;function gN(e){return function(t){return t==null?void 0:t[e]}}var TN=gN;function yN(e){return function(t){return vl(t,e)}}var bN=yN;function vN(e){return yl(e)?TN(Bn(e)):bN(e)}var xN=vN;function AN(e){return typeof e=="function"?e:e==null?zn:typeof e=="object"?V(e)?mN(e[0],e[1]):sN(e):xN(e)}var Lt=AN;function EN(e,t,r,n){for(var i=-1,a=e==null?0:e.length;++i<a;){var s=e[i];t(n,s,r(s),e)}return n}var IN=EN;function LN(e){return function(t,r,n){for(var i=-1,a=Object(t),s=n(t),o=s.length;o--;){var l=s[e?o:++i];if(r(a[l],l,a)===!1)break}return t}}var PN=LN,_N=PN(),NN=_N;function ON(e,t){return e&&NN(e,t,Ke)}var SN=ON;function wN(e,t){return function(r,n){if(r==null)return r;if(!It(r))return e(r,n);for(var i=r.length,a=t?i:-1,s=Object(r);(t?a--:++a<i)&&n(s[a],a,s)!==!1;);return r}}var kN=wN,CN=kN(SN),Lr=CN;function RN(e,t,r,n){return Lr(e,function(i,a,s){t(n,i,r(i),s)}),n}var FN=RN;function MN(e,t){return function(r,n){var i=V(r)?IN:FN,a=t?t():{};return i(r,e,Lt(n,2),a)}}var DN=MN,mf=Object.prototype,jN=mf.hasOwnProperty,GN=ml(function(e,t){e=Object(e);var r=-1,n=t.length,i=n>2?t[2]:void 0;for(i&&oa(t[0],t[1],i)&&(n=1);++r<n;)for(var a=t[r],s=ca(a),o=-1,l=s.length;++o<l;){var c=s[o],u=e[c];(u===void 0||Wn(u,mf[c])&&!jN.call(e,c))&&(e[c]=a[c])}return e}),Sl=GN;function $N(e){return pt(e)&&It(e)}var ad=$N;function VN(e,t,r){for(var n=-1,i=e==null?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}var gf=VN,HN=200;function KN(e,t,r,n){var i=-1,a=Md,s=!0,o=e.length,l=[],c=t.length;if(!o)return l;r&&(t=Kn(t,Xn(r))),n?(a=gf,s=!1):t.length>=HN&&(a=Nl,s=!1,t=new _l(t));e:for(;++i<o;){var u=e[i],p=r==null?u:r(u);if(u=n||u!==0?u:0,s&&p===p){for(var f=c;f--;)if(t[f]===p)continue e;l.push(u)}else a(t,p,n)||l.push(u)}return l}var qN=KN,zN=ml(function(e,t){return ad(e)?qN(e,Al(t,1,ad,!0)):[]}),ma=zN;function WN(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var vr=WN;function YN(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:qn(t),El(e,t<0?0:t,n)):[]}var _e=YN;function QN(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:qn(t),t=n-t,El(e,0,t<0?0:t)):[]}var Hn=QN;function XN(e){return typeof e=="function"?e:zn}var BN=XN;function JN(e,t){var r=V(e)?Rd:Lr;return r(e,BN(t))}var C=JN;function ZN(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}var UN=ZN;function eO(e,t){var r=!0;return Lr(e,function(n,i,a){return r=!!t(n,i,a),r}),r}var tO=eO;function rO(e,t,r){var n=V(e)?UN:tO;return r&&oa(e,t,r)&&(t=void 0),n(e,Lt(t,3))}var ut=rO;function nO(e,t){var r=[];return Lr(e,function(n,i,a){t(n,i,a)&&r.push(n)}),r}var Tf=nO;function iO(e,t){var r=V(e)?Il:Tf;return r(e,Lt(t,3))}var rt=iO;function aO(e){return function(t,r,n){var i=Object(t);if(!It(t)){var a=Lt(r,3);t=Ke(t),r=function(o){return a(i[o],o,i)}}var s=e(t,r,n);return s>-1?i[a?t[s]:s]:void 0}}var sO=aO,oO=Math.max;function lO(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:qn(r);return i<0&&(i=oO(n+i,0)),Fd(e,Lt(t,3),i)}var cO=lO,uO=sO(cO),Kr=uO;function pO(e){return e&&e.length?e[0]:void 0}var dt=pO;function dO(e,t){var r=-1,n=It(e)?Array(e.length):[];return Lr(e,function(i,a,s){n[++r]=t(i,a,s)}),n}var fO=dO;function hO(e,t){var r=V(e)?Kn:fO;return r(e,Lt(t,3))}var O=hO;function mO(e,t){return Al(O(e,t),1)}var Ue=mO,gO=Object.prototype,TO=gO.hasOwnProperty,yO=DN(function(e,t,r){TO.call(e,r)?e[r].push(t):hl(e,r,[t])}),bO=yO,vO=Object.prototype,xO=vO.hasOwnProperty;function AO(e,t){return e!=null&&xO.call(e,t)}var EO=AO;function IO(e,t){return e!=null&&hf(e,t,EO)}var w=IO,LO="[object String]";function PO(e){return typeof e=="string"||!V(e)&&pt(e)&&ir(e)==LO}var Ve=PO;function _O(e,t){return Kn(t,function(r){return e[r]})}var NO=_O;function OO(e){return e==null?[]:NO(e,Ke(e))}var ve=OO,SO=Math.max;function wO(e,t,r,n){e=It(e)?e:ve(e),r=r&&!n?qn(r):0;var i=e.length;return r<0&&(r=SO(i+r,0)),Ve(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&fl(e,t,r)>-1}var De=wO,kO=Math.max;function CO(e,t,r){var n=e==null?0:e.length;if(!n)return-1;var i=r==null?0:qn(r);return i<0&&(i=kO(n+i,0)),fl(e,t,i)}var sd=CO,RO="[object Map]",FO="[object Set]",MO=Object.prototype,DO=MO.hasOwnProperty;function jO(e){if(e==null)return!0;if(It(e)&&(V(e)||typeof e=="string"||typeof e.splice=="function"||Gn(e)||Tl(e)||la(e)))return!e.length;var t=Hr(e);if(t==RO||t==FO)return!e.size;if(Qn(e))return!Hd(e).length;for(var r in e)if(DO.call(e,r))return!1;return!0}var Z=jO,GO="[object RegExp]";function $O(e){return pt(e)&&ir(e)==GO}var VO=$O,od=rr&&rr.isRegExp,HO=od?Xn(od):VO,Mt=HO;function KO(e){return e===void 0}var Dt=KO,qO="Expected a function";function zO(e){if(typeof e!="function")throw new TypeError(qO);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 WO=zO;function YO(e,t,r,n){if(!tt(e))return e;t=ha(t,e);for(var i=-1,a=t.length,s=a-1,o=e;o!=null&&++i<a;){var l=Bn(t[i]),c=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(i!=s){var u=o[l];c=n?n(u,l,o):void 0,c===void 0&&(c=tt(u)?u:aa(t[i+1])?[]:{})}sa(o,l,c),o=o[l]}return e}var QO=YO;function XO(e,t,r){for(var n=-1,i=t.length,a={};++n<i;){var s=t[n],o=vl(e,s);r(o,s)&&QO(a,ha(s,e),o)}return a}var BO=XO;function JO(e,t){if(e==null)return{};var r=Kn(nf(e),function(n){return[n]});return t=Lt(t),BO(e,r,function(n,i){return t(n,i[0])})}var ft=JO;function ZO(e,t,r,n,i){return i(e,function(a,s,o){r=n?(n=!1,a):t(r,a,s,o)}),r}var UO=ZO;function eS(e,t,r){var n=V(e)?rL:UO,i=arguments.length<3;return n(e,Lt(t,4),r,i,Lr)}var ze=eS;function tS(e,t){var r=V(e)?Il:Tf;return r(e,WO(Lt(t,3)))}var ga=tS;function rS(e,t){var r;return Lr(e,function(n,i,a){return r=t(n,i,a),!r}),!!r}var nS=rS;function iS(e,t,r){var n=V(e)?lf:nS;return r&&oa(e,t,r)&&(t=void 0),n(e,Lt(t,3))}var yf=iS,aS=1/0,sS=Vr&&1/Ol(new Vr([,-0]))[1]==aS?function(e){return new Vr(e)}:Ee,oS=sS,lS=200;function cS(e,t,r){var n=-1,i=Md,a=e.length,s=!0,o=[],l=o;if(r)s=!1,i=gf;else if(a>=lS){var c=t?null:oS(e);if(c)return Ol(c);s=!1,i=Nl,l=new _l}else l=t?[]:o;e:for(;++n<a;){var u=e[n],p=t?t(u):u;if(u=r||u!==0?u:0,s&&p===p){for(var f=l.length;f--;)if(l[f]===p)continue e;t&&l.push(p),o.push(u)}else i(l,p,r)||(l!==o&&l.push(p),o.push(u))}return o}var uS=cS;function pS(e){return e&&e.length?uS(e):[]}var wl=pS;function il(e){console&&console.error&&console.error(`Error: ${e}`)}function bf(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function vf(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function xf(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function dS(e){return fS(e)?e.LABEL:e.name}function fS(e){return Ve(e.LABEL)&&e.LABEL!==""}var Pt=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),C(this.definition,t=>{t.accept(e)})}},We=class extends Pt{constructor(e){super([]),this.idx=1,qe(this,ft(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},Xr=class extends Pt{constructor(e){super(e.definition),this.orgText="",qe(this,ft(e,t=>t!==void 0))}},He=class extends Pt{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,qe(this,ft(e,t=>t!==void 0))}},Ge=class extends Pt{constructor(e){super(e.definition),this.idx=1,qe(this,ft(e,t=>t!==void 0))}},_t=class extends Pt{constructor(e){super(e.definition),this.idx=1,qe(this,ft(e,t=>t!==void 0))}},Nt=class extends Pt{constructor(e){super(e.definition),this.idx=1,qe(this,ft(e,t=>t!==void 0))}},xe=class extends Pt{constructor(e){super(e.definition),this.idx=1,qe(this,ft(e,t=>t!==void 0))}},ht=class extends Pt{constructor(e){super(e.definition),this.idx=1,qe(this,ft(e,t=>t!==void 0))}},mt=class extends Pt{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,qe(this,ft(e,t=>t!==void 0))}},ae=class{constructor(e){this.idx=1,qe(this,ft(e,t=>t!==void 0))}accept(e){e.visit(this)}};function hS(e){return O(e,Hi)}function Hi(e){function t(r){return O(r,Hi)}if(e instanceof We){let r={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return Ve(e.label)&&(r.label=e.label),r}else{if(e instanceof He)return{type:"Alternative",definition:t(e.definition)};if(e instanceof Ge)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof _t)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof Nt)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:Hi(new ae({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ht)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Hi(new ae({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof xe)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof mt)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof ae){let r={type:"Terminal",name:e.terminalType.name,label:dS(e.terminalType),idx:e.idx};Ve(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 Xr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}}}var Br=class{visit(e){let t=e;switch(t.constructor){case We:return this.visitNonTerminal(t);case He:return this.visitAlternative(t);case Ge:return this.visitOption(t);case _t:return this.visitRepetitionMandatory(t);case Nt:return this.visitRepetitionMandatoryWithSeparator(t);case ht:return this.visitRepetitionWithSeparator(t);case xe:return this.visitRepetition(t);case mt:return this.visitAlternation(t);case ae:return this.visitTerminal(t);case Xr: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 mS(e){return e instanceof He||e instanceof Ge||e instanceof xe||e instanceof _t||e instanceof Nt||e instanceof ht||e instanceof ae||e instanceof Xr}function Bi(e,t=[]){return e instanceof Ge||e instanceof xe||e instanceof ht?!0:e instanceof mt?yf(e.definition,n=>Bi(n,t)):e instanceof We&&De(t,e)?!1:e instanceof Pt?(e instanceof We&&t.push(e),ut(e.definition,n=>Bi(n,t))):!1}function gS(e){return e instanceof mt}function At(e){if(e instanceof We)return"SUBRULE";if(e instanceof Ge)return"OPTION";if(e instanceof mt)return"OR";if(e instanceof _t)return"AT_LEAST_ONE";if(e instanceof Nt)return"AT_LEAST_ONE_SEP";if(e instanceof ht)return"MANY_SEP";if(e instanceof xe)return"MANY";if(e instanceof ae)return"CONSUME";throw Error("non exhaustive match")}var Ta=class{walk(e,t=[]){C(e.definition,(r,n)=>{let i=_e(e.definition,n+1);if(r instanceof We)this.walkProdRef(r,i,t);else if(r instanceof ae)this.walkTerminal(r,i,t);else if(r instanceof He)this.walkFlat(r,i,t);else if(r instanceof Ge)this.walkOption(r,i,t);else if(r instanceof _t)this.walkAtLeastOne(r,i,t);else if(r instanceof Nt)this.walkAtLeastOneSep(r,i,t);else if(r instanceof ht)this.walkManySep(r,i,t);else if(r instanceof xe)this.walkMany(r,i,t);else if(r instanceof mt)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 Ge({definition:e.definition})].concat(t,r);this.walk(e,n)}walkAtLeastOneSep(e,t,r){let n=ld(e,t,r);this.walk(e,n)}walkMany(e,t,r){let n=[new Ge({definition:e.definition})].concat(t,r);this.walk(e,n)}walkManySep(e,t,r){let n=ld(e,t,r);this.walk(e,n)}walkOr(e,t,r){let n=t.concat(r);C(e.definition,i=>{let a=new He({definition:[i]});this.walk(a,n)})}};function ld(e,t,r){return[new Ge({definition:[new ae({terminalType:e.separator})].concat(e.definition)})].concat(t,r)}function Zn(e){if(e instanceof We)return Zn(e.referencedRule);if(e instanceof ae)return bS(e);if(mS(e))return TS(e);if(gS(e))return yS(e);throw Error("non exhaustive match")}function TS(e){let t=[],r=e.definition,n=0,i=r.length>n,a,s=!0;for(;i&&s;)a=r[n],s=Bi(a),t=t.concat(Zn(a)),n=n+1,i=r.length>n;return wl(t)}function yS(e){let t=O(e.definition,r=>Zn(r));return wl(ct(t))}function bS(e){return[e.terminalType]}var Af="_~IN~_",vS=class extends Ta{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=AS(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),a=new He({definition:i}),s=Zn(a);this.follows[n]=s}};function xS(e){let t={};return C(e,r=>{let n=new vS(r).startWalking();qe(t,n)}),t}function AS(e,t){return e.name+t+Af}function R(e){return e.charCodeAt(0)}function Yo(e,t){Array.isArray(e)?e.forEach(function(r){t.push(r)}):t.push(e)}function wn(e,t){if(e[t]===!0)throw"duplicate flag "+t;let r=e[t];e[t]=!0}function $r(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function Mi(){throw Error("Internal Error - Should never get here!")}function cd(e){return e.type==="Character"}var Ji=[];for(let e=R("0");e<=R("9");e++)Ji.push(e);var Zi=[R("_")].concat(Ji);for(let e=R("a");e<=R("z");e++)Zi.push(e);for(let e=R("A");e<=R("Z");e++)Zi.push(e);var ud=[R(" "),R("\f"),R(`
|
|
5
|
+
`),R("\r"),R(" "),R("\v"),R(" "),R("\xA0"),R("\u1680"),R("\u2000"),R("\u2001"),R("\u2002"),R("\u2003"),R("\u2004"),R("\u2005"),R("\u2006"),R("\u2007"),R("\u2008"),R("\u2009"),R("\u200A"),R("\u2028"),R("\u2029"),R("\u202F"),R("\u205F"),R("\u3000"),R("\uFEFF")],ES=/[0-9a-fA-F]/,Di=/[0-9]/,IS=/[1-9]/,LS=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":wn(r,"global");break;case"i":wn(r,"ignoreCase");break;case"m":wn(r,"multiLine");break;case"u":wn(r,"unicode");break;case"y":wn(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}}$r(t);let r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return Mi()}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;$r(t);break}if(!(e===!0&&t===void 0)&&$r(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()),$r(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Mi()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[R(`
|
|
6
|
+
`),R("\r"),R("\u2028"),R("\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=Ji;break;case"D":e=Ji,t=!0;break;case"s":e=ud;break;case"S":e=ud,t=!0;break;case"w":e=Zi;break;case"W":e=Zi,t=!0;break}return $r(e)?{type:"Set",value:e,complement:t}:Mi()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=R("\f");break;case"n":e=R(`
|
|
7
|
+
`);break;case"r":e=R("\r");break;case"t":e=R(" ");break;case"v":e=R("\v");break}return $r(e)?{type:"Character",value:e}:Mi()}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:R("\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:R(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
8
|
+
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:R(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(cd(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),a=i.type==="Character";if(cd(i)){if(i.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:i.value})}else Yo(r.value,e),e.push(R("-")),Yo(i.value,e)}else Yo(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
9
|
+
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:R("\b")};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()}}group(){let e=!0;this.consumeChar("("),this.peekChar(0)==="?"?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;let t=this.disjunction();this.consumeChar(")");let r={type:"Group",capturing:e,value:t};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(IS.test(e)===!1)throw Error("Expecting a positive integer");for(;Di.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Di.test(e)===!1)throw Error("Expecting an integer");for(;Di.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|
10
|
+
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:R(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return Di.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
11
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!"||this.peekChar(2)==="<"&&(this.peekChar(3)==="="||this.peekChar(3)==="!"));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch(t){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
12
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let n=0;n<e;n++){let i=this.popChar();if(ES.test(i)===!1)throw Error("Expecting a HexDecimal digits");t+=i}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}},kl=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){}},Ki={},PS=new LS;function ya(e){let t=e.toString();if(Ki.hasOwnProperty(t))return Ki[t];{let r=PS.pattern(t);return Ki[t]=r,r}}function _S(){Ki={}}var Ef="Complement Sets are not supported for first char optimization",Ui=`Unable to use "first char" lexer optimizations:
|
|
13
|
+
`;function NS(e,t=!1){try{let r=ya(e);return al(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===Ef)t&&bf(`${Ui} Unable to optimize: < ${e.toString()} >
|
|
14
|
+
Complement Sets cannot be automatically optimized.
|
|
15
|
+
This will disable the lexer's first char optimizations.
|
|
16
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=`
|
|
17
|
+
This will disable the lexer's first char optimizations.
|
|
18
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),il(`${Ui}
|
|
19
|
+
Failed parsing: < ${e.toString()} >
|
|
20
|
+
Using the @chevrotain/regexp-to-ast library
|
|
21
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function al(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)al(e.value[i],t,r);break;case"Alternative":let n=e.value;for(let i=0;i<n.length;i++){let a=n[i];switch(a.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let s=a;switch(s.type){case"Character":ji(s.value,t,r);break;case"Set":if(s.complement===!0)throw Error(Ef);C(s.value,l=>{if(typeof l=="number")ji(l,t,r);else{let c=l;if(r===!0)for(let u=c.from;u<=c.to;u++)ji(u,t,r);else{for(let u=c.from;u<=c.to&&u<Rn;u++)ji(u,t,r);if(c.to>=Rn){let u=c.from>=Rn?c.from:Rn,p=c.to,f=nr(u),h=nr(p);for(let g=f;g<=h;g++)t[g]=g}}}});break;case"Group":al(s.value,t,r);break;default:throw Error("Non Exhaustive Match")}let o=s.quantifier!==void 0&&s.quantifier.atLeast===0;if(s.type==="Group"&&sl(s)===!1||s.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return ve(t)}function ji(e,t,r){let n=nr(e);t[n]=n,r===!0&&OS(e,t)}function OS(e,t){let r=String.fromCharCode(e),n=r.toUpperCase();if(n!==r){let i=nr(n.charCodeAt(0));t[i]=i}else{let i=r.toLowerCase();if(i!==r){let a=nr(i.charCodeAt(0));t[a]=a}}}function pd(e,t){return Kr(e.value,r=>{if(typeof r=="number")return De(t,r);{let n=r;return Kr(t,i=>n.from<=i&&i<=n.to)!==void 0}})}function sl(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?V(e.value)?ut(e.value,sl):sl(e.value):!1}var SS=class extends kl{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){De(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?pd(e,this.targetCharCodes)===void 0&&(this.found=!0):pd(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Cl(e,t){if(t instanceof RegExp){let r=ya(t),n=new SS(e);return n.visit(r),n.found}else return Kr(t,r=>De(e,r.charCodeAt(0)))!==void 0}var xr="PATTERN",Cn="defaultMode",Gi="modes";function wS(e,t){t=Sl(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
22
|
+
`],tracer:(A,y)=>y()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{tw()});let n;r("Reject Lexer.NA",()=>{n=ga(e,A=>A[xr]===Ne.NA)});let i=!1,a;r("Transform Patterns",()=>{i=!1,a=O(n,A=>{let y=A[xr];if(Mt(y)){let L=y.source;return L.length===1&&L!=="^"&&L!=="$"&&L!=="."&&!y.ignoreCase?L:L.length===2&&L[0]==="\\"&&!De(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],L[1])?L[1]:dd(y)}else{if(Gt(y))return i=!0,{exec:y};if(typeof y=="object")return i=!0,y;if(typeof y=="string"){if(y.length===1)return y;{let L=y.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),S=new RegExp(L);return dd(S)}}else throw Error("non exhaustive match")}})});let s,o,l,c,u;r("misc mapping",()=>{s=O(n,A=>A.tokenTypeIdx),o=O(n,A=>{let y=A.GROUP;if(y!==Ne.SKIPPED){if(Ve(y))return y;if(Dt(y))return!1;throw Error("non exhaustive match")}}),l=O(n,A=>{let y=A.LONGER_ALT;if(y)return V(y)?O(y,S=>sd(n,S)):[sd(n,y)]}),c=O(n,A=>A.PUSH_MODE),u=O(n,A=>w(A,"POP_MODE"))});let p;r("Line Terminator Handling",()=>{let A=Pf(t.lineTerminatorCharacters);p=O(n,y=>!1),t.positionTracking!=="onlyOffset"&&(p=O(n,y=>w(y,"LINE_BREAKS")?!!y.LINE_BREAKS:Lf(y,A)===!1&&Cl(A,y.PATTERN)))});let f,h,g,T;r("Misc Mapping #2",()=>{f=O(n,If),h=O(a,ZS),g=ze(n,(A,y)=>{let L=y.GROUP;return Ve(L)&&L!==Ne.SKIPPED&&(A[L]=[]),A},{}),T=O(a,(A,y)=>({pattern:a[y],longerAlt:l[y],canLineTerminator:p[y],isCustom:f[y],short:h[y],group:o[y],push:c[y],pop:u[y],tokenTypeIdx:s[y],tokenType:n[y]}))});let x=!0,v=[];return t.safeMode||r("First Char Optimization",()=>{v=ze(n,(A,y,L)=>{if(typeof y.PATTERN=="string"){let S=y.PATTERN.charCodeAt(0),N=nr(S);Qo(A,N,T[L])}else if(V(y.START_CHARS_HINT)){let S;C(y.START_CHARS_HINT,N=>{let X=typeof N=="string"?N.charCodeAt(0):N,G=nr(X);S!==G&&(S=G,Qo(A,G,T[L]))})}else if(Mt(y.PATTERN))if(y.PATTERN.unicode)x=!1,t.ensureOptimizations&&il(`${Ui} Unable to analyze < ${y.PATTERN.toString()} > pattern.
|
|
23
|
+
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
24
|
+
This will disable the lexer's first char optimizations.
|
|
25
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let S=NS(y.PATTERN,t.ensureOptimizations);Z(S)&&(x=!1),C(S,N=>{Qo(A,N,T[L])})}else t.ensureOptimizations&&il(`${Ui} TokenType: <${y.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
26
|
+
This will disable the lexer's first char optimizations.
|
|
27
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),x=!1;return A},[])}),{emptyGroups:g,patternIdxToConfig:T,charCodeToPatternIdxToConfig:v,hasCustom:i,canBeOptimized:x}}function kS(e,t){let r=[],n=RS(e);r=r.concat(n.errors);let i=FS(n.valid),a=i.valid;return r=r.concat(i.errors),r=r.concat(CS(a)),r=r.concat(KS(a)),r=r.concat(qS(a,t)),r=r.concat(zS(a)),r}function CS(e){let t=[],r=rt(e,n=>Mt(n[xr]));return t=t.concat(DS(r)),t=t.concat($S(r)),t=t.concat(VS(r)),t=t.concat(HS(r)),t=t.concat(jS(r)),t}function RS(e){let t=rt(e,i=>!w(i,xr)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:le.MISSING_PATTERN,tokenTypes:[i]})),n=ma(e,t);return{errors:r,valid:n}}function FS(e){let t=rt(e,i=>{let a=i[xr];return!Mt(a)&&!Gt(a)&&!w(a,"exec")&&!Ve(a)}),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:le.INVALID_PATTERN,tokenTypes:[i]})),n=ma(e,t);return{errors:r,valid:n}}var MS=/[^\\][$]/;function DS(e){class t extends kl{constructor(){super(...arguments),this.found=!1}visitEndAnchor(a){this.found=!0}}let r=rt(e,i=>{let a=i.PATTERN;try{let s=ya(a),o=new t;return o.visit(s),o.found}catch(s){return MS.test(a.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
28
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
29
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:le.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function jS(e){let t=rt(e,n=>n.PATTERN.test(""));return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:le.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}var GS=/[^\\[][\^]|^\^/;function $S(e){class t extends kl{constructor(){super(...arguments),this.found=!1}visitStartAnchor(a){this.found=!0}}let r=rt(e,i=>{let a=i.PATTERN;try{let s=ya(a),o=new t;return o.visit(s),o.found}catch(s){return GS.test(a.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
30
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
31
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:le.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function VS(e){let t=rt(e,n=>{let i=n[xr];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:le.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function HS(e){let t=[],r=O(e,a=>ze(e,(s,o)=>(a.PATTERN.source===o.PATTERN.source&&!De(t,o)&&o.PATTERN!==Ne.NA&&(t.push(o),s.push(o)),s),[]));r=Jn(r);let n=rt(r,a=>a.length>1);return O(n,a=>{let s=O(a,l=>l.name);return{message:`The same RegExp pattern ->${dt(a).PATTERN}<-has been used in all of the following Token Types: ${s.join(", ")} <-`,type:le.DUPLICATE_PATTERNS_FOUND,tokenTypes:a}})}function KS(e){let t=rt(e,n=>{if(!w(n,"GROUP"))return!1;let i=n.GROUP;return i!==Ne.SKIPPED&&i!==Ne.NA&&!Ve(i)});return O(t,n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:le.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function qS(e,t){let r=rt(e,i=>i.PUSH_MODE!==void 0&&!De(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:le.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function zS(e){let t=[],r=ze(e,(n,i,a)=>{let s=i.PATTERN;return s===Ne.NA||(Ve(s)?n.push({str:s,idx:a,tokenType:i}):Mt(s)&&YS(s)&&n.push({str:s.source,idx:a,tokenType:i})),n},[]);return C(e,(n,i)=>{C(r,({str:a,idx:s,tokenType:o})=>{if(i<s&&WS(a,n.PATTERN)){let l=`Token: ->${o.name}<- can never be matched.
|
|
32
|
+
Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
|
|
33
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:l,type:le.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function WS(e,t){if(Mt(t)){if(QS(t))return!1;let r=t.exec(e);return r!==null&&r.index===0}else{if(Gt(t))return t(e,0,[],{});if(w(t,"exec"))return t.exec(e,0,[],{});if(typeof t=="string")return t===e;throw Error("non exhaustive match")}}function YS(e){return Kr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function QS(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}function dd(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function XS(e,t,r){let n=[];return w(e,Cn)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Cn+`> property in its definition
|
|
34
|
+
`,type:le.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),w(e,Gi)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Gi+`> property in its definition
|
|
35
|
+
`,type:le.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),w(e,Gi)&&w(e,Cn)&&!w(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${Cn}: <${e.defaultMode}>which does not exist
|
|
36
|
+
`,type:le.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),w(e,Gi)&&C(e.modes,(i,a)=>{C(i,(s,o)=>{if(Dt(s))n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${a}> at index: <${o}>
|
|
37
|
+
`,type:le.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(w(s,"LONGER_ALT")){let l=V(s.LONGER_ALT)?s.LONGER_ALT:[s.LONGER_ALT];C(l,c=>{!Dt(c)&&!De(i,c)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${c.name}> on token <${s.name}> outside of mode <${a}>
|
|
38
|
+
`,type:le.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function BS(e,t,r){let n=[],i=!1,a=Jn(ct(ve(e.modes))),s=ga(a,l=>l[xr]===Ne.NA),o=Pf(r);return t&&C(s,l=>{let c=Lf(l,o);if(c!==!1){let p={message:ew(l,c),type:c.issue,tokenType:l};n.push(p)}else w(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):Cl(o,l.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
|
|
39
|
+
This Lexer has been defined to track line and column information,
|
|
40
|
+
But none of the Token Types can be identified as matching a line terminator.
|
|
41
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
42
|
+
for details.`,type:le.NO_LINE_BREAKS_FLAGS}),n}function JS(e){let t={},r=Ke(e);return C(r,n=>{let i=e[n];if(V(i))t[n]=[];else throw Error("non exhaustive match")}),t}function If(e){let t=e.PATTERN;if(Mt(t))return!1;if(Gt(t))return!0;if(w(t,"exec"))return!0;if(Ve(t))return!1;throw Error("non exhaustive match")}function ZS(e){return Ve(e)&&e.length===1?e.charCodeAt(0):!1}var US={test:function(e){let t=e.length;for(let r=this.lastIndex;r<t;r++){let n=e.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return e.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function Lf(e,t){if(w(e,"LINE_BREAKS"))return!1;if(Mt(e.PATTERN)){try{Cl(t,e.PATTERN)}catch(r){return{issue:le.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(Ve(e.PATTERN))return!1;if(If(e))return{issue:le.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function ew(e,t){if(t.issue===le.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
43
|
+
The problem is in the <${e.name}> Token Type
|
|
44
|
+
Root cause: ${t.errMsg}.
|
|
45
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===le.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
46
|
+
The problem is in the <${e.name}> Token Type
|
|
47
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Pf(e){return O(e,r=>Ve(r)?r.charCodeAt(0):r)}function Qo(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var Rn=256,qi=[];function nr(e){return e<Rn?e:qi[e]}function tw(){if(Z(qi)){qi=new Array(65536);for(let e=0;e<65536;e++)qi[e]=e>255?255+~~(e/255):e}}function Un(e,t){let r=e.tokenTypeIdx;return r===t.tokenTypeIdx?!0:t.isParent===!0&&t.categoryMatchesMap[r]===!0}function ea(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var fd=1,_f={};function ei(e){let t=rw(e);nw(t),aw(t),iw(t),C(t,r=>{r.isParent=r.categoryMatches.length>0})}function rw(e){let t=$e(e),r=e,n=!0;for(;n;){r=Jn(ct(O(r,a=>a.CATEGORIES)));let i=ma(r,t);t=t.concat(i),Z(i)?n=!1:r=i}return t}function nw(e){C(e,t=>{Of(t)||(_f[fd]=t,t.tokenTypeIdx=fd++),hd(t)&&!V(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),hd(t)||(t.CATEGORIES=[]),sw(t)||(t.categoryMatches=[]),ow(t)||(t.categoryMatchesMap={})})}function iw(e){C(e,t=>{t.categoryMatches=[],C(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(_f[n].tokenTypeIdx)})})}function aw(e){C(e,t=>{Nf([],t)})}function Nf(e,t){C(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),C(t.CATEGORIES,r=>{let n=e.concat(t);De(n,r)||Nf(n,r)})}function Of(e){return w(e,"tokenTypeIdx")}function hd(e){return w(e,"CATEGORIES")}function sw(e){return w(e,"categoryMatches")}function ow(e){return w(e,"categoryMatchesMap")}function lw(e){return w(e,"tokenTypeIdx")}var cw={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,r,n,i,a){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters.`}},le;(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"})(le||(le={}));var Fn={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
48
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:cw,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Fn);var Ne=class{constructor(e,t=Fn){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 a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${a}--> <${n}>`);let{time:s,value:o}=vf(i),l=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${a}<-- <${n}> time: ${s}ms`),this.traceInitIndent--,o}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
49
|
+
a boolean 2nd argument is no longer supported`);this.config=qe({},Fn,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===Fn.lineTerminatorsPattern)this.config.lineTerminatorsPattern=US;else if(this.config.lineTerminatorCharacters===Fn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
50
|
+
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),V(e)?n={modes:{defaultMode:$e(e)},defaultMode:Cn}:(i=!1,n=$e(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(XS(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(BS(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},C(n.modes,(s,o)=>{n.modes[o]=ga(s,l=>Dt(l))});let a=Ke(n.modes);if(C(n.modes,(s,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(kS(s,a))}),Z(this.lexerDefinitionErrors)){ei(s);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=wS(s,{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=qe({},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(`-----------------------
|
|
51
|
+
`);throw new Error(`Errors detected in definition of Lexer:
|
|
52
|
+
`+o)}C(this.lexerDefinitionWarning,s=>{bf(s.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=Ee),this.trackStartLines===!1&&(this.computeNewColumn=zn),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=Ee),/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 <positionTracking> 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 s=ze(this.canModeBeOptimized,(o,l,c)=>(l===!1&&o.push(c),o),[]);if(t.ensureOptimizations&&!Z(s))throw Error(`Lexer Modes: < ${s.join(", ")} > cannot be optimized.
|
|
53
|
+
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
54
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{_S()}),this.TRACE_INIT("toFastProperties",()=>{xf(this)})})}tokenize(e,t=this.defaultMode){if(!Z(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`-----------------------
|
|
55
|
+
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
56
|
+
`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,a,s,o,l,c,u,p,f,h,g,T,x,v=e,A=v.length,y=0,L=0,S=this.hasCustom?0:Math.floor(e.length/10),N=new Array(S),X=[],G=this.trackStartLines?1:void 0,B=this.trackStartLines?1:void 0,te=JS(this.emptyGroups),Y=this.trackStartLines,pe=this.config.lineTerminatorsPattern,ye=0,z=[],be=[],we=[],Le=[];Object.freeze(Le);let Ae=!1,Re=re=>{if(we.length===1&&re.tokenType.PUSH_MODE===void 0){let he=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(re);X.push({offset:re.startOffset,line:re.startLine,column:re.startColumn,length:re.image.length,message:he})}else{we.pop();let he=vr(we);z=this.patternIdxToConfig[he],be=this.charCodeToPatternIdxToConfig[he],ye=z.length;let xt=this.canModeBeOptimized[he]&&this.config.safeMode===!1;be&&xt?Ae=!0:Ae=!1}};function Zt(re){we.push(re),be=this.charCodeToPatternIdxToConfig[re],z=this.patternIdxToConfig[re],ye=z.length,ye=z.length;let he=this.canModeBeOptimized[re]&&this.config.safeMode===!1;be&&he?Ae=!0:Ae=!1}Zt.call(this,t);let Pe,Ut=this.config.recoveryEnabled;for(;y<A;){o=null,u=-1;let re=v.charCodeAt(y),he;if(Ae){let me=nr(re),Fe=be[me];he=Fe!==void 0?Fe:Le}else he=z;let xt=he.length;for(r=0;r<xt;r++){Pe=he[r];let me=Pe.pattern;l=null;let Fe=Pe.short;if(Fe!==!1?re===Fe&&(u=1,o=me):Pe.isCustom===!0?(x=me.exec(v,y,N,te),x!==null?(o=x[0],u=o.length,x.payload!==void 0&&(l=x.payload)):o=null):(me.lastIndex=y,u=this.matchLength(me,e,y)),u!==-1){if(s=Pe.longerAlt,s!==void 0){o=e.substring(y,y+u);let er=s.length;for(i=0;i<er;i++){let Ft=z[s[i]],gr=Ft.pattern;if(c=null,Ft.isCustom===!0?(x=gr.exec(v,y,N,te),x!==null?(a=x[0],x.payload!==void 0&&(c=x.payload)):a=null):(gr.lastIndex=y,a=this.match(gr,e,y)),a&&a.length>o.length){o=a,u=a.length,l=c,Pe=Ft;break}}}break}}if(u!==-1){if(p=Pe.group,p!==void 0&&(o=o!==null?o:e.substring(y,y+u),f=Pe.tokenTypeIdx,h=this.createTokenInstance(o,y,f,Pe.tokenType,G,B,u),this.handlePayload(h,l),p===!1?L=this.addToken(N,L,h):te[p].push(h)),Y===!0&&Pe.canLineTerminator===!0){let me=0,Fe,er;pe.lastIndex=0;do o=o!==null?o:e.substring(y,y+u),Fe=pe.test(o),Fe===!0&&(er=pe.lastIndex-1,me++);while(Fe===!0);me!==0?(G=G+me,B=u-er,this.updateTokenEndLineColumnLocation(h,p,er,me,G,B,u)):B=this.computeNewColumn(B,u)}else B=this.computeNewColumn(B,u);y=y+u,this.handleModes(Pe,Re,Zt,h)}else{let me=y,Fe=G,er=B,Ft=Ut===!1;for(;Ft===!1&&y<A;)for(y++,n=0;n<ye;n++){let gr=z[n],$o=gr.pattern,pp=gr.short;if(pp!==!1?v.charCodeAt(y)===pp&&(Ft=!0):gr.isCustom===!0?Ft=$o.exec(v,y,N,te)!==null:($o.lastIndex=y,Ft=$o.exec(e)!==null),Ft===!0)break}if(g=y-me,B=this.computeNewColumn(B,g),T=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(v,me,g,Fe,er,vr(we)),X.push({offset:me,line:Fe,column:er,length:g,message:T}),Ut===!1)break}}return this.hasCustom||(N.length=L),{tokens:N,groups:te,errors:X}}handleModes(e,t,r,n){if(e.pop===!0){let i=e.push;t(n),i!==void 0&&r.call(this,i)}else e.push!==void 0&&r.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,r,n,i,a,s){let o,l;t!==void 0&&(o=r===s-1,l=o?-1:0,n===1&&o===!0||(e.endLine=i+l,e.endColumn=a-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,r,n){return{image:e,startOffset:t,tokenTypeIdx:r,tokenType:n}}createStartOnlyToken(e,t,r,n,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:r,tokenType:n}}createFullToken(e,t,r,n,i,a,s){return{image:e,startOffset:t,endOffset:t+s-1,startLine:i,endLine:i,startColumn:a,endColumn:a+s-1,tokenTypeIdx:r,tokenType:n}}addTokenUsingPush(e,t,r){return e.push(r),t}addTokenUsingMemberAccess(e,t,r){return e[t]=r,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,r){return e.test(t)===!0?t.substring(r,e.lastIndex):null}matchLength(e,t,r){return e.test(t)===!0?e.lastIndex-r:-1}};Ne.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";Ne.NA=/NOT_APPLICABLE/;function jn(e){return Sf(e)?e.LABEL:e.name}function Sf(e){return Ve(e.LABEL)&&e.LABEL!==""}var uw="parent",md="categories",gd="label",Td="group",yd="push_mode",bd="pop_mode",vd="longer_alt",xd="line_breaks",Ad="start_chars_hint";function ba(e){return pw(e)}function pw(e){let t=e.pattern,r={};if(r.name=e.name,Dt(t)||(r.PATTERN=t),w(e,uw))throw`The parent property is no longer supported.
|
|
57
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return w(e,md)&&(r.CATEGORIES=e[md]),ei([r]),w(e,gd)&&(r.LABEL=e[gd]),w(e,Td)&&(r.GROUP=e[Td]),w(e,bd)&&(r.POP_MODE=e[bd]),w(e,yd)&&(r.PUSH_MODE=e[yd]),w(e,vd)&&(r.LONGER_ALT=e[vd]),w(e,xd)&&(r.LINE_BREAKS=e[xd]),w(e,Ad)&&(r.START_CHARS_HINT=e[Ad]),r}var Ar=ba({name:"EOF",pattern:Ne.NA});ei([Ar]);function Rl(e,t,r,n,i,a,s,o){return{image:t,startOffset:r,endOffset:n,startLine:i,endLine:a,startColumn:s,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function dw(e,t){return Un(e,t)}var wf={buildMismatchTokenMessage({expected:e,actual:t,previous:r,ruleName:n}){return`Expecting ${Sf(e)?`--> ${jn(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 a="Expecting: ",o=`
|
|
58
|
+
but found: '`+dt(t).image+"'";if(n)return a+n+o;{let l=ze(e,(f,h)=>f.concat(h),[]),c=O(l,f=>`[${O(f,h=>jn(h)).join(", ")}]`),p=`one of these possible Token sequences:
|
|
59
|
+
${O(c,(f,h)=>` ${h+1}. ${f}`).join(`
|
|
60
|
+
`)}`;return a+p+o}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",s=`
|
|
61
|
+
but found: '`+dt(t).image+"'";if(r)return i+r+s;{let l=`expecting at least one iteration which starts with one of these possible Token sequences::
|
|
62
|
+
<${O(e,c=>`[${O(c,u=>jn(u)).join(",")}]`).join(" ,")}>`;return i+l+s}}};Object.freeze(wf);var fw={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<-
|
|
63
|
+
inside top level rule: ->`+e.name+"<-"}},br={buildDuplicateFoundError(e,t){function r(u){return u instanceof ae?u.terminalType.name:u instanceof We?u.nonTerminalName:""}let n=e.name,i=dt(t),a=i.idx,s=At(i),o=r(i),l=a>0,c=`->${s}${l?a:""}<- ${o?`with argument: ->${o}<-`:""}
|
|
64
|
+
appears more than once (${t.length} times) in the top level rule: ->${n}<-.
|
|
65
|
+
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
66
|
+
`;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,`
|
|
67
|
+
`),c},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.
|
|
68
|
+
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
|
|
69
|
+
To resolve this make sure each Terminal and Non-Terminal names are unique
|
|
70
|
+
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|
71
|
+
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=O(e.prefixPath,i=>jn(i)).join(", "),r=e.alternation.idx===0?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
|
|
72
|
+
in <OR${r}> inside <${e.topLevelRule.name}> Rule,
|
|
73
|
+
<${t}> may appears as a prefix path in all these alternatives.
|
|
74
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|
75
|
+
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 <OR${t}> inside <${e.topLevelRule.name}> Rule,
|
|
76
|
+
`;if(r)n+=`These alternatives are all empty (match no tokens), making them indistinguishable.
|
|
77
|
+
Only the last alternative may be empty.
|
|
78
|
+
`;else{let i=O(e.prefixPath,a=>jn(a)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives.
|
|
79
|
+
`}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
80
|
+
For Further details.`,n},buildEmptyRepetitionError(e){let t=At(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
|
|
81
|
+
This could lead to an infinite loop.`},buildTokenNameError(e){return"deprecated"},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|
82
|
+
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:
|
|
83
|
+
<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
|
|
84
|
+
has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name,r=O(e.leftRecursionPath,a=>a.name),n=`${t} --> ${r.concat([t]).join(" --> ")}`;return`Left Recursion found in grammar.
|
|
85
|
+
rule: <${t}> can be invoked from itself (directly or indirectly)
|
|
86
|
+
without consuming any Tokens. The grammar path that causes this is:
|
|
87
|
+
${n}
|
|
88
|
+
To fix this refactor your grammar to remove the left recursion.
|
|
89
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let t;return e.topLevelRule instanceof Xr?t=e.topLevelRule.name:t=e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function hw(e,t){let r=new mw(e,t);return r.resolveRefs(),r.errors}var mw=class extends Br{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){C(ve(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:Me.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},gw=class extends Ta{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())}},Tw=class extends gw{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 He({definition:n});this.possibleTokTypes=Zn(i),this.found=!0}}},va=class extends Ta{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}},yw=class extends va{walkMany(e,t,r){if(e.idx===this.occurrence){let n=dt(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof ae&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,t,r)}},Ed=class extends va{walkManySep(e,t,r){if(e.idx===this.occurrence){let n=dt(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof ae&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,t,r)}},bw=class extends va{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){let n=dt(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof ae&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,t,r)}},Id=class extends va{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){let n=dt(t.concat(r));this.result.isEndOfRule=n===void 0,n instanceof ae&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,t,r)}};function ol(e,t,r=[]){r=$e(r);let n=[],i=0;function a(o){return o.concat(_e(e,i+1))}function s(o){let l=ol(a(o),t,r);return n.concat(l)}for(;r.length<t&&i<e.length;){let o=e[i];if(o instanceof He)return s(o.definition);if(o instanceof We)return s(o.definition);if(o instanceof Ge)n=s(o.definition);else if(o instanceof _t){let l=o.definition.concat([new xe({definition:o.definition})]);return s(l)}else if(o instanceof Nt){let l=[new He({definition:o.definition}),new xe({definition:[new ae({terminalType:o.separator})].concat(o.definition)})];return s(l)}else if(o instanceof ht){let l=o.definition.concat([new xe({definition:[new ae({terminalType:o.separator})].concat(o.definition)})]);n=s(l)}else if(o instanceof xe){let l=o.definition.concat([new xe({definition:o.definition})]);n=s(l)}else{if(o instanceof mt)return C(o.definition,l=>{Z(l.definition)===!1&&(n=s(l.definition))}),n;if(o instanceof ae)r.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:r,suffixDef:_e(e,i)}),n}function kf(e,t,r,n){let i="EXIT_NONE_TERMINAL",a=[i],s="EXIT_ALTERNATIVE",o=!1,l=t.length,c=l-n-1,u=[],p=[];for(p.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!Z(p);){let f=p.pop();if(f===s){o&&vr(p).idx<=c&&p.pop();continue}let h=f.def,g=f.idx,T=f.ruleStack,x=f.occurrenceStack;if(Z(h))continue;let v=h[0];if(v===i){let A={idx:g,def:_e(h),ruleStack:Hn(T),occurrenceStack:Hn(x)};p.push(A)}else if(v instanceof ae)if(g<l-1){let A=g+1,y=t[A];if(r(y,v.terminalType)){let L={idx:A,def:_e(h),ruleStack:T,occurrenceStack:x};p.push(L)}}else if(g===l-1)u.push({nextTokenType:v.terminalType,nextTokenOccurrence:v.idx,ruleStack:T,occurrenceStack:x}),o=!0;else throw Error("non exhaustive match");else if(v instanceof We){let A=$e(T);A.push(v.nonTerminalName);let y=$e(x);y.push(v.idx);let L={idx:g,def:v.definition.concat(a,_e(h)),ruleStack:A,occurrenceStack:y};p.push(L)}else if(v instanceof Ge){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:x};p.push(A),p.push(s);let y={idx:g,def:v.definition.concat(_e(h)),ruleStack:T,occurrenceStack:x};p.push(y)}else if(v instanceof _t){let A=new xe({definition:v.definition,idx:v.idx}),y=v.definition.concat([A],_e(h)),L={idx:g,def:y,ruleStack:T,occurrenceStack:x};p.push(L)}else if(v instanceof Nt){let A=new ae({terminalType:v.separator}),y=new xe({definition:[A].concat(v.definition),idx:v.idx}),L=v.definition.concat([y],_e(h)),S={idx:g,def:L,ruleStack:T,occurrenceStack:x};p.push(S)}else if(v instanceof ht){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:x};p.push(A),p.push(s);let y=new ae({terminalType:v.separator}),L=new xe({definition:[y].concat(v.definition),idx:v.idx}),S=v.definition.concat([L],_e(h)),N={idx:g,def:S,ruleStack:T,occurrenceStack:x};p.push(N)}else if(v instanceof xe){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:x};p.push(A),p.push(s);let y=new xe({definition:v.definition,idx:v.idx}),L=v.definition.concat([y],_e(h)),S={idx:g,def:L,ruleStack:T,occurrenceStack:x};p.push(S)}else if(v instanceof mt)for(let A=v.definition.length-1;A>=0;A--){let y=v.definition[A],L={idx:g,def:y.definition.concat(_e(h)),ruleStack:T,occurrenceStack:x};p.push(L),p.push(s)}else if(v instanceof He)p.push({idx:g,def:v.definition.concat(_e(h)),ruleStack:T,occurrenceStack:x});else if(v instanceof Xr)p.push(vw(v,g,T,x));else throw Error("non exhaustive match")}return u}function vw(e,t,r,n){let i=$e(r);i.push(e.name);let a=$e(n);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var oe;(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"})(oe||(oe={}));function Cf(e){if(e instanceof Ge||e==="Option")return oe.OPTION;if(e instanceof xe||e==="Repetition")return oe.REPETITION;if(e instanceof _t||e==="RepetitionMandatory")return oe.REPETITION_MANDATORY;if(e instanceof Nt||e==="RepetitionMandatoryWithSeparator")return oe.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof ht||e==="RepetitionWithSeparator")return oe.REPETITION_WITH_SEPARATOR;if(e instanceof mt||e==="Alternation")return oe.ALTERNATION;throw Error("non exhaustive match")}function xw(e,t,r,n,i,a){let s=Fl(e,t,r),o=Mf(s)?ea:Un;return a(s,n,o,i)}function Aw(e,t,r,n,i,a){let s=Ml(e,t,i,r),o=Mf(s)?ea:Un;return a(s[0],o,n)}function Ew(e,t,r,n){let i=e.length,a=ut(e,s=>ut(s,o=>o.length===1));if(t)return function(s){let o=O(s,l=>l.GATE);for(let l=0;l<i;l++){let c=e[l],u=c.length,p=o[l];if(!(p!==void 0&&p.call(this)===!1))e:for(let f=0;f<u;f++){let h=c[f],g=h.length;for(let T=0;T<g;T++){let x=this.LA_FAST(T+1);if(r(x,h[T])===!1)continue e}return l}}};if(a&&!n){let s=O(e,l=>ct(l)),o=ze(s,(l,c,u)=>(C(c,p=>{w(l,p.tokenTypeIdx)||(l[p.tokenTypeIdx]=u),C(p.categoryMatches,f=>{w(l,f)||(l[f]=u)})}),l),{});return function(){let l=this.LA_FAST(1);return o[l.tokenTypeIdx]}}else return function(){for(let s=0;s<i;s++){let o=e[s],l=o.length;e:for(let c=0;c<l;c++){let u=o[c],p=u.length;for(let f=0;f<p;f++){let h=this.LA_FAST(f+1);if(r(h,u[f])===!1)continue e}return s}}}}function Iw(e,t,r){let n=ut(e,a=>a.length===1),i=e.length;if(n&&!r){let a=ct(e);if(a.length===1&&Z(a[0].categoryMatches)){let o=a[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{let s=ze(a,(o,l,c)=>(o[l.tokenTypeIdx]=!0,C(l.categoryMatches,u=>{o[u]=!0}),o),[]);return function(){let o=this.LA_FAST(1);return s[o.tokenTypeIdx]===!0}}}else return function(){e:for(let a=0;a<i;a++){let s=e[a],o=s.length;for(let l=0;l<o;l++){let c=this.LA_FAST(l+1);if(t(c,s[l])===!1)continue e}return!0}return!1}}var Lw=class extends Ta{constructor(e,t,r){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=r}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,r,n){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=r.concat(n),!0):!1}walkOption(e,t,r){this.checkIsTarget(e,oe.OPTION,t,r)||super.walkOption(e,t,r)}walkAtLeastOne(e,t,r){this.checkIsTarget(e,oe.REPETITION_MANDATORY,t,r)||super.walkOption(e,t,r)}walkAtLeastOneSep(e,t,r){this.checkIsTarget(e,oe.REPETITION_MANDATORY_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}walkMany(e,t,r){this.checkIsTarget(e,oe.REPETITION,t,r)||super.walkOption(e,t,r)}walkManySep(e,t,r){this.checkIsTarget(e,oe.REPETITION_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}},Rf=class extends Br{constructor(e,t,r){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=r,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,oe.OPTION)}visitRepetition(e){this.checkIsTarget(e,oe.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,oe.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,oe.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,oe.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,oe.ALTERNATION)}};function Ld(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function Xo(e){let t=[""];for(let r=0;r<e.length;r++){let n=e[r],i=[];for(let a=0;a<t.length;a++){let s=t[a];i.push(s+"_"+n.tokenTypeIdx);for(let o=0;o<n.categoryMatches.length;o++){let l="_"+n.categoryMatches[o];i.push(s+l)}}t=i}return t}function Pw(e,t,r){for(let n=0;n<e.length;n++){if(n===r)continue;let i=e[n];for(let a=0;a<t.length;a++){let s=t[a];if(i[s]===!0)return!1}}return!0}function Ff(e,t){let r=O(e,s=>ol([s],1)),n=Ld(r.length),i=O(r,s=>{let o={};return C(s,l=>{let c=Xo(l.partialPath);C(c,u=>{o[u]=!0})}),o}),a=r;for(let s=1;s<=t;s++){let o=a;a=Ld(o.length);for(let l=0;l<o.length;l++){let c=o[l];for(let u=0;u<c.length;u++){let p=c[u].partialPath,f=c[u].suffixDef,h=Xo(p);if(Pw(i,h,l)||Z(f)||p.length===t){let T=n[l];if(ll(T,p)===!1){T.push(p);for(let x=0;x<h.length;x++){let v=h[x];i[l][v]=!0}}}else{let T=ol(f,s+1,p);a[l]=a[l].concat(T),C(T,x=>{let v=Xo(x.partialPath);C(v,A=>{i[l][A]=!0})})}}}}return n}function Fl(e,t,r,n){let i=new Rf(e,oe.ALTERNATION,n);return t.accept(i),Ff(i.result,r)}function Ml(e,t,r,n){let i=new Rf(e,r);t.accept(i);let a=i.result,o=new Lw(t,e,r).startWalking(),l=new He({definition:a}),c=new He({definition:o});return Ff([l,c],n)}function ll(e,t){e:for(let r=0;r<e.length;r++){let n=e[r];if(n.length===t.length){for(let i=0;i<n.length;i++){let a=t[i],s=n[i];if((a===s||s.categoryMatchesMap[a.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function _w(e,t){return e.length<t.length&&ut(e,(r,n)=>{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function Mf(e){return ut(e,t=>ut(t,r=>ut(r,n=>Z(n.categoryMatches))))}function Nw(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return O(t,r=>Object.assign({type:Me.CUSTOM_LOOKAHEAD_VALIDATION},r))}function Ow(e,t,r,n){let i=Ue(e,l=>Sw(l,r)),a=Hw(e,t,r),s=Ue(e,l=>jw(l,r)),o=Ue(e,l=>Cw(l,e,n,r));return i.concat(a,s,o)}function Sw(e,t){let r=new kw;e.accept(r);let n=r.allProductions,i=bO(n,ww),a=ft(i,o=>o.length>1);return O(ve(a),o=>{let l=dt(o),c=t.buildDuplicateFoundError(e,o),u=At(l),p={message:c,type:Me.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:u,occurrence:l.idx},f=Df(l);return f&&(p.parameter=f),p})}function ww(e){return`${At(e)}_#_${e.idx}_#_${Df(e)}`}function Df(e){return e instanceof ae?e.terminalType.name:e instanceof We?e.nonTerminalName:""}var kw=class extends Br{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 Cw(e,t,r,n){let i=[];if(ze(t,(s,o)=>o.name===e.name?s+1:s,0)>1){let s=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:r});i.push({message:s,type:Me.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function Rw(e,t,r){let n=[],i;return De(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:Me.INVALID_RULE_OVERRIDE,ruleName:e})),n}function jf(e,t,r,n=[]){let i=[],a=zi(t.definition);if(Z(a))return[];{let s=e.name;De(a,e)&&i.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:Me.LEFT_RECURSION,ruleName:s});let l=ma(a,n.concat([e])),c=Ue(l,u=>{let p=$e(n);return p.push(u),jf(e,u,r,p)});return i.concat(c)}}function zi(e){let t=[];if(Z(e))return t;let r=dt(e);if(r instanceof We)t.push(r.referencedRule);else if(r instanceof He||r instanceof Ge||r instanceof _t||r instanceof Nt||r instanceof ht||r instanceof xe)t=t.concat(zi(r.definition));else if(r instanceof mt)t=ct(O(r.definition,a=>zi(a.definition)));else if(!(r instanceof ae))throw Error("non exhaustive match");let n=Bi(r),i=e.length>1;if(n&&i){let a=_e(e);return t.concat(zi(a))}else return t}var Dl=class extends Br{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Fw(e,t){let r=new Dl;e.accept(r);let n=r.alternations;return Ue(n,a=>{let s=Hn(a.definition);return Ue(s,(o,l)=>{let c=kf([o],[],Un,1);return Z(c)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:a,emptyChoiceIdx:l}),type:Me.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:a.idx,alternative:l+1}]:[]})})}function Mw(e,t,r){let n=new Dl;e.accept(n);let i=n.alternations;return i=ga(i,s=>s.ignoreAmbiguities===!0),Ue(i,s=>{let o=s.idx,l=s.maxLookahead||t,c=Fl(o,e,l,s),u=$w(c,s,e,r),p=Vw(c,s,e,r);return u.concat(p)})}var Dw=class extends Br{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 jw(e,t){let r=new Dl;e.accept(r);let n=r.alternations;return Ue(n,a=>a.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:a}),type:Me.TOO_MANY_ALTS,ruleName:e.name,occurrence:a.idx}]:[])}function Gw(e,t,r){let n=[];return C(e,i=>{let a=new Dw;i.accept(a);let s=a.allProductions;C(s,o=>{let l=Cf(o),c=o.maxLookahead||t,u=o.idx,f=Ml(u,i,l,c)[0];if(Z(ct(f))){let h=r.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:h,type:Me.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function $w(e,t,r,n){let i=[],a=ze(e,(o,l,c)=>(t.definition[c].ignoreAmbiguities===!0||C(l,u=>{let p=[c];C(e,(f,h)=>{c!==h&&ll(f,u)&&t.definition[h].ignoreAmbiguities!==!0&&p.push(h)}),p.length>1&&!ll(i,u)&&(i.push(u),o.push({alts:p,path:u}))}),o),[]);return O(a,o=>{let l=O(o.alts,u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:l,prefixPath:o.path}),type:Me.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:t.idx,alternatives:o.alts}})}function Vw(e,t,r,n){let i=ze(e,(s,o,l)=>{let c=O(o,u=>({idx:l,path:u}));return s.concat(c)},[]);return Jn(Ue(i,s=>{if(t.definition[s.idx].ignoreAmbiguities===!0)return[];let l=s.idx,c=s.path,u=rt(i,f=>t.definition[f.idx].ignoreAmbiguities!==!0&&f.idx<l&&_w(f.path,c));return O(u,f=>{let h=[f.idx+1,l+1],g=t.idx===0?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:t,ambiguityIndices:h,prefixPath:f.path}),type:Me.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:g,alternatives:h}})}))}function Hw(e,t,r){let n=[],i=O(t,a=>a.name);return C(e,a=>{let s=a.name;if(De(i,s)){let o=r.buildNamespaceConflictError(a);n.push({message:o,type:Me.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:s})}}),n}function Kw(e){let t=Sl(e,{errMsgProvider:fw}),r={};return C(e.rules,n=>{r[n.name]=n}),hw(r,t.errMsgProvider)}function qw(e){return e=Sl(e,{errMsgProvider:br}),Ow(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Gf="MismatchedTokenException",$f="NoViableAltException",Vf="EarlyExitException",Hf="NotAllInputParsedException",Kf=[Gf,$f,Vf,Hf];Object.freeze(Kf);function ta(e){return De(Kf,e.name)}var xa=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)}},qf=class extends xa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Gf}},zw=class extends xa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=$f}},Ww=class extends xa{constructor(e,t){super(e,t),this.name=Hf}},Yw=class extends xa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Vf}},Bo={},zf="InRuleRecoveryException",Qw=class extends Error{constructor(e){super(e),this.name=zf}},Xw=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=w(e,"recoveryEnabled")?e.recoveryEnabled:jt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Bw)}getTokenToInsert(e){let t=Rl(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(),a=this.exportLexerState(),s=[],o=!1,l=this.LA_FAST(1),c=this.LA_FAST(1),u=()=>{let p=this.LA(0),f=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:l,previous:p,ruleName:this.getCurrRuleFullName()}),h=new qf(f,l,this.LA(0));h.resyncedTokens=Hn(s),this.SAVE_ERROR(h)};for(;!o;)if(this.tokenMatcher(c,n)){u();return}else if(r.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(c,i)?o=!0:(c=this.SKIP_TOKEN(),this.addToResyncTokens(c,s));this.importLexerState(a)}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 Qw("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 Kr(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 De(r,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),r=2;for(;;){let n=Kr(e,i=>dw(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Bo;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;i<r;i++)i===0?n[i]=Bo:n[i]={ruleName:this.shortRuleNameToFullName(e[i]),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])};return n}flattenFollowSet(){let e=O(this.buildFullFollowKeyStack(),t=>this.getFollowSetFromFollowKey(t));return ct(e)}getFollowSetFromFollowKey(e){if(e===Bo)return[Ar];let t=e.ruleName+e.idxInCallingRule+Af+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ar)||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 Hn(t)}attemptInRepetitionRecovery(e,t,r,n,i,a,s){}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;r<e;r++)t[r]=this.shortRuleNameToFullName(this.RULE_STACK[r]);return t}};function Bw(e,t,r,n,i,a,s){let o=this.getKeyForAutomaticLookahead(n,i),l=this.firstAfterRepMap[o];if(l===void 0){let f=this.getCurrRuleFullName(),h=this.getGAstProductions()[f];l=new a(h,i).startWalking(),this.firstAfterRepMap[o]=l}let c=l.token,u=l.occurrence,p=l.isEndOfRule;this.RULE_STACK_IDX===0&&p&&c===void 0&&(c=Ar,u=1),!(c===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(c,u,s)&&this.tryInRepetitionRecovery(e,t,r,c)}var Jw=4,ar=8,Zw=8,Wf=1<<ar,Yf=2<<ar,cl=3<<ar,ul=4<<ar,pl=5<<ar,Wi=6<<ar;function Jo(e,t,r){return r|t|e}var XC=32-Zw,Uw=class{constructor(e){var t;this.maxLookahead=(t=e==null?void 0:e.maxLookahead)!==null&&t!==void 0?t:jt.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(Z(t)){let r=this.validateEmptyOrAlternatives(e.rules),n=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...r,...n,...i]}return t}validateNoLeftRecursion(e){return Ue(e,t=>jf(t,t,br))}validateEmptyOrAlternatives(e){return Ue(e,t=>Fw(t,br))}validateAmbiguousAlternationAlternatives(e,t){return Ue(e,r=>Mw(r,t,br))}validateSomeNonEmptyLookaheadPath(e,t){return Gw(e,t,br)}buildLookaheadForAlternation(e){return xw(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Ew)}buildLookaheadForOptional(e){return Aw(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Cf(e.prodType),Iw)}},ek=class{initLooksAhead(e){this.dynamicTokensEnabled=w(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:jt.dynamicTokensEnabled,this.maxLookahead=w(e,"maxLookahead")?e.maxLookahead:jt.maxLookahead,this.lookaheadStrategy=w(e,"lookaheadStrategy")?e.lookaheadStrategy:new Uw({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){C(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:r,repetition:n,option:i,repetitionMandatory:a,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:o}=rk(t);C(r,l=>{let c=l.idx===0?"":l.idx;this.TRACE_INIT(`${At(l)}${c}`,()=>{let u=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:t,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),p=Jo(this.fullRuleNameToShort[t.name],Wf,l.idx);this.setLaFuncCache(p,u)})}),C(n,l=>{this.computeLookaheadFunc(t,l.idx,cl,"Repetition",l.maxLookahead,At(l))}),C(i,l=>{this.computeLookaheadFunc(t,l.idx,Yf,"Option",l.maxLookahead,At(l))}),C(a,l=>{this.computeLookaheadFunc(t,l.idx,ul,"RepetitionMandatory",l.maxLookahead,At(l))}),C(s,l=>{this.computeLookaheadFunc(t,l.idx,Wi,"RepetitionMandatoryWithSeparator",l.maxLookahead,At(l))}),C(o,l=>{this.computeLookaheadFunc(t,l.idx,pl,"RepetitionWithSeparator",l.maxLookahead,At(l))})})})}computeLookaheadFunc(e,t,r,n,i,a){this.TRACE_INIT(`${a}${t===0?"":t}`,()=>{let s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),o=Jo(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,s)})}getKeyForAutomaticLookahead(e,t){return Jo(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},tk=class extends Br{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)}},$i=new tk;function rk(e){$i.reset(),e.accept($i);let t=$i.dslMethods;return $i.reset(),t}function Pd(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function _d(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function nk(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function ik(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var ak="name";function Qf(e,t){Object.defineProperty(e,ak,{enumerable:!1,configurable:!0,writable:!1,value:t})}function sk(e,t){let r=Ke(e),n=r.length;for(let i=0;i<n;i++){let a=r[i],s=e[a],o=s.length;for(let l=0;l<o;l++){let c=s[l];c.tokenTypeIdx===void 0&&this[c.name](c.children,t)}}}function ok(e,t){let r=function(){};Qf(r,e+"BaseSemantics");let n={visit:function(i,a){if(V(i)&&(i=i[0]),!Dt(i))return this[i.name](i.children,a)},validateVisitor:function(){let i=ck(this,t);if(!Z(i)){let a=O(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
90
|
+
${a.join(`
|
|
91
|
+
|
|
92
|
+
`).replace(/\n/g,`
|
|
93
|
+
`)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function lk(e,t,r){let n=function(){};Qf(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return C(t,a=>{i[a]=sk}),n.prototype=i,n.prototype.constructor=n,n}var dl;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(dl||(dl={}));function ck(e,t){return uk(e,t)}function uk(e,t){let r=rt(t,i=>Gt(e[i])===!1),n=O(r,i=>({msg:`Missing visitor method: <${i}> on ${e.constructor.name} CST Visitor.`,type:dl.MISSING_METHOD,methodName:i}));return Jn(n)}var pk=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=w(e,"nodeLocationTracking")?e.nodeLocationTracking:jt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=Ee,this.cstFinallyStateUpdate=Ee,this.cstPostTerminal=Ee,this.cstPostNonTerminal=Ee,this.cstPostRule=Ee;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=_d,this.setNodeLocationFromNode=_d,this.cstPostRule=Ee,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=Ee,this.setNodeLocationFromNode=Ee,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Pd,this.setNodeLocationFromNode=Pd,this.cstPostRule=Ee,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=Ee,this.setNodeLocationFromNode=Ee,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=Ee,this.setNodeLocationFromNode=Ee,this.cstPostRule=Ee,this.setInitialNodeLocation=Ee;else throw Error(`Invalid <nodeLocationTracking> 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];nk(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];ik(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(Dt(this.baseCstVisitorConstructor)){let e=ok(this.className,Ke(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Dt(this.baseCstVisitorWithDefaultsConstructor)){let e=lk(this.className,Ke(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]}},dk=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> 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)):qr}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?qr: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()}},fk=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=na){if(De(this.definedRulesNames,e)){let a={message:br.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:Me.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);let n=this.defineRule(e,t,r);return this[e]=n,n}OVERRIDE_RULE(e,t,r=na){let n=Rw(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(a){if(ta(a))return!1;throw a}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return hS(ve(this.gastProductionsCache))}},hk=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=ea,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={},w(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
94
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
95
|
+
For Further details.`);if(V(e)){if(Z(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
96
|
+
Note that the first argument for the parser constructor
|
|
97
|
+
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.
|
|
98
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
99
|
+
For Further details.`)}if(V(e))this.tokensMap=ze(e,(i,a)=>(i[a.name]=a,i),{});else if(w(e,"modes")&&ut(ct(ve(e.modes)),lw)){let i=ct(ve(e.modes)),a=wl(i);this.tokensMap=ze(a,(s,o)=>(s[o.name]=o,s),{})}else if(tt(e))this.tokensMap=$e(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Ar;let r=w(e,"modes")?ct(ve(e.modes)):ve(e),n=ut(r,i=>Z(i.categoryMatches));this.tokenMatcher=n?ea:Un,ei(ve(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'
|
|
100
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=w(r,"resyncEnabled")?r.resyncEnabled:na.resyncEnabled,i=w(r,"recoveryValueFunc")?r.recoveryValueFunc:na.recoveryValueFunc,a=this.ruleShortNameIdx<<Jw+ar;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let s;return this.outputCst===!0?s=function(...u){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u);let p=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(p),p}catch(p){return this.invokeRuleCatch(p,n,i)}finally{this.ruleFinallyStateUpdate()}}:s=function(...u){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u)}catch(p){return this.invokeRuleCatch(p,n,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...u){this.onBeforeParse(e);try{return s.apply(this,u)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:s})}invokeRuleCatch(e,t,r){let n=this.RULE_STACK_IDX===0,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(ta(e)){let a=e;if(i){let s=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(s))if(a.resyncedTokens=this.reSyncTo(s),this.outputCst){let o=this.CST_STACK[this.CST_STACK.length-1];return o.recoveredNode=!0,o}else return r(e);else{if(this.outputCst){let o=this.CST_STACK[this.CST_STACK.length-1];o.recoveredNode=!0,a.partialCstResult=o}throw a}}else{if(n)return this.moveToTerminatedState(),r(e);throw a}}else throw e}optionInternal(e,t){let r=this.getKeyForAutomaticLookahead(Yf,t);return this.optionInternalLogic(e,t,r)}optionInternalLogic(e,t,r){let n=this.getLaFuncFromCache(r),i;if(typeof e!="function"){i=e.DEF;let a=e.GATE;if(a!==void 0){let s=n;n=()=>a.call(this)&&s.call(this)}}else i=e;if(n.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let r=this.getKeyForAutomaticLookahead(ul,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 a=t.GATE;if(a!==void 0){let s=n;n=()=>a.call(this)&&s.call(this)}}else i=t;if(n.call(this)===!0){let a=this.doSingleRepetition(i);for(;n.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,oe.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,ul,e,bw)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Wi,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 s=()=>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,s,n,Id],s,Wi,e,Id)}else throw this.raiseEarlyExitException(e,oe.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(cl,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 s=t.GATE;if(s!==void 0){let o=n;n=()=>s.call(this)&&o.call(this)}}else i=t;let a=!0;for(;n.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,cl,e,yw,a)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(pl,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 s=()=>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,s,n,Ed],s,pl,e,Ed)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,Wi,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Wf,t),n=V(e)?e:e.DEF,a=this.getLaFuncFromCache(r).call(this,n);if(a!==void 0)return n[a].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 ta(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 qf(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===zf?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<t.length;r++)this.RULE_STACK[r]=t[r];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=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),Ar)}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<this.maxLookahead+1;t++)this.tokVector.push(qr)}onAfterParse(e){if(this.isAtEndOfInput()===!1){let t=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Ww(r,t))}for(;this.tokVector.at(-1)===qr;)this.tokVector.pop()}},mk=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=w(e,"errorMessageProvider")?e.errorMessageProvider:jt.errorMessageProvider}SAVE_ERROR(e){if(ta(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return $e(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,r){let n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],s=Ml(e,i,t,this.maxLookahead)[0],o=[];for(let c=1;c<=this.maxLookahead;c++)o.push(this.LA(c));let l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:s,actual:o,previous:this.LA(0),customUserDescription:r,ruleName:n});throw this.SAVE_ERROR(new Yw(l,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let r=this.getCurrRuleFullName(),n=this.getGAstProductions()[r],i=Fl(e,n,this.maxLookahead),a=[];for(let l=1;l<=this.maxLookahead;l++)a.push(this.LA(l));let s=this.LA(0),o=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:s,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new zw(o,this.LA(1),s))}},gk=class{initContentAssist(){}computeContentAssist(e,t){let r=this.gastProductionsCache[e];if(Dt(r))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return kf([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=dt(e.ruleStack),n=this.getGAstProductions()[t];return new Tw(n,e).startWalking()}},Aa={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Aa);var Nd=!0,Od=Math.pow(2,ar)-1,Xf=ba({name:"RECORDING_PHASE_TOKEN",pattern:Ne.NA});ei([Xf]);var Bf=Rl(Xf,`This IToken indicates the Parser is in Recording Phase
|
|
101
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Bf);var Tk={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
102
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},yk=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 qr}topLevelRuleRecord(e,t){try{let r=new Xr({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+`
|
|
103
|
+
This error was thrown during the "grammar recording phase" For more info see:
|
|
104
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(n){throw r}throw r}}optionInternalRecord(e,t){return kn.call(this,Ge,e,t)}atLeastOneInternalRecord(e,t){kn.call(this,_t,t,e)}atLeastOneSepFirstInternalRecord(e,t){kn.call(this,Nt,t,e,Nd)}manyInternalRecord(e,t){kn.call(this,xe,t,e)}manySepFirstInternalRecord(e,t){kn.call(this,ht,t,e,Nd)}orInternalRecord(e,t){return bk.call(this,e,t)}subruleInternalRecord(e,t,r){if(ra(t),!e||w(e,"ruleName")===!1){let s=new Error(`<SUBRULE${Sd(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|
105
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=vr(this.recordingProdStack),i=e.ruleName,a=new We({idx:t,nonTerminalName:i,label:r==null?void 0:r.LABEL,referencedRule:void 0});return n.definition.push(a),this.outputCst?Tk:Aa}consumeInternalRecord(e,t,r){if(ra(t),!Of(e)){let a=new Error(`<CONSUME${Sd(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|
106
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=vr(this.recordingProdStack),i=new ae({idx:t,terminalType:e,label:r==null?void 0:r.LABEL});return n.definition.push(i),Bf}};function kn(e,t,r,n=!1){ra(r);let i=vr(this.recordingProdStack),a=Gt(t)?t:t.DEF,s=new e({definition:[],idx:r});return n&&(s.separator=t.SEP),w(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(s),a.call(this),i.definition.push(s),this.recordingProdStack.pop(),Aa}function bk(e,t){ra(t);let r=vr(this.recordingProdStack),n=V(e)===!1,i=n===!1?e:e.DEF,a=new mt({definition:[],idx:t,ignoreAmbiguities:n&&e.IGNORE_AMBIGUITIES===!0});w(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD);let s=yf(i,o=>Gt(o.GATE));return a.hasPredicates=s,r.definition.push(a),C(i,o=>{let l=new He({definition:[]});a.definition.push(l),w(o,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:w(o,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),o.ALT.call(this),this.recordingProdStack.pop()}),Aa}function Sd(e){return e===0?"":`${e}`}function ra(e){if(e<0||e>Od){let t=new Error(`Invalid DSL Method idx value: <${e}>
|
|
107
|
+
Idx value must be a none negative value smaller than ${Od+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var vk=class{initPerformanceTracer(e){if(w(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=jt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${r}--> <${e}>`);let{time:n,value:i}=vf(t),a=n>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${r}<-- <${e}> time: ${n}ms`),this.traceInitIndent--,i}else return t()}};function xk(e,t){t.forEach(r=>{let n=r.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;let a=Object.getOwnPropertyDescriptor(n,i);a&&(a.get||a.set)?Object.defineProperty(e.prototype,i,a):e.prototype[i]=r.prototype[i]})})}var qr=Rl(Ar,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(qr);var jt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:wf,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),na=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0}),Me;(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"})(Me||(Me={}));var jl=class Jf{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",()=>{xf(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),C(this.definedRulesNames,i=>{let s=this[i].originalGrammarAction,o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,s)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Kw({rules:ve(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(Z(n)&&this.skipValidations===!1){let i=qw({rules:ve(this.gastProductionsCache),tokenTypes:ve(this.tokensMap),errMsgProvider:br,grammarName:r}),a=Nw({lookaheadStrategy:this.lookaheadStrategy,rules:ve(this.gastProductionsCache),tokenTypes:ve(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,a)}}),Z(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=xS(ve(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,a;(a=(i=this.lookaheadStrategy).initialize)===null||a===void 0||a.call(i,{rules:ve(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(ve(this.gastProductionsCache))})),!Jf.DEFER_DEFINITION_ERRORS_HANDLING&&!Z(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
|
|
108
|
+
${t.join(`
|
|
109
|
+
-------------------------------
|
|
110
|
+
`)}`)})}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),w(r,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
111
|
+
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
112
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
113
|
+
For further details.`);this.skipValidations=w(r,"skipValidations")?r.skipValidations:jt.skipValidations}};jl.DEFER_DEFINITION_ERRORS_HANDLING=!1;xk(jl,[Xw,ek,pk,dk,hk,fk,mk,gk,yk,vk]);var Zf=class extends jl{constructor(e,t=jt){let r=$e(t);r.outputCst=!1,super(e,r)}};function ge(e){return e.charAt(0).toLowerCase()+e.slice(1)}function m(e){return ba(e)}var ce="When you use this string, you expect traqula to handle indentation after every newline";function Gl(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var Ea=class{constructor(t){H(this,"rules");H(this,"__context");H(this,"subrule",(t,...r)=>{let n=this.rules[t.name];if(!n)throw new Error(`Rule ${t.name} not found`);return n.fun({SUBRULE:this.subrule})(this.getSafeContext(),...r)});this.rules=t;for(let r of Object.values(t))this[r.name]=((n,...i)=>(this.setContext(n),this.subrule(r,...i)))}setContext(t){this.__context=t}getSafeContext(){return this.__context}};var Jr=class e{constructor(t){H(this,"rules");this.rules=t}static create(t){return Array.isArray(t)?new e(Gl(t)):new e({...t.rules})}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(`Function ${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,...Gl(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 a of Object.values(i))if(n[a.name]===void 0)n[a.name]=a;else if(n[a.name]!==a){let o=r.find(l=>l.name===a.name);if(o)n[a.name]=o;else throw new Error(`Function with name "${a.name}" already exists in the builder, specify an override to resolve conflict`)}return this.rules=n,this}build(){return new Ea(this.rules)}};var Oe=class e{constructor(t){H(this,"tokens");this.tokens=t!=null&&t.tokens?[...t.tokens]:[]}static create(t){return new e(t)}merge(t,r=[]){let n=t.tokens.filter(i=>{if(r.find(o=>o.name===i.name))return!1;let s=this.tokens.find(o=>o.name===i.name);if(s){if(s!==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 a of n){let s=this.tokens.indexOf(a);if(s===-1)throw new Error("Token not found");this.tokens.splice(s,1),this.tokens.splice(i,0,a)}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 Ne(this.tokens,{positionTracking:"onlyStart",recoveryEnabled:!1,ensureOptimizations:!0,...t})}get tokenVocabulary(){return this.tokens}};var Ia=class extends Zf{constructor(r,n,i={}){super(n,{maxLookahead:1,skipValidations:!0,dynamicTokensEnabled:!1,...i});H(this,"context");this.context=void 0;let s={...this.constructSelfRef(),cache:new WeakMap};for(let o of Object.values(r))this[o.name]=this.RULE(o.name,o.impl(s));this.performSelfAnalysis()}setContext(r){this.context=r}constructSelfRef(){let r=n=>((i,...a)=>n(this[i.name],{ARGS:[this.context,...a]}));return{CONSUME:(n,i)=>this.CONSUME(n,i),CONSUME1:(n,i)=>this.CONSUME1(n,i),CONSUME2:(n,i)=>this.CONSUME2(n,i),CONSUME3:(n,i)=>this.CONSUME3(n,i),CONSUME4:(n,i)=>this.CONSUME4(n,i),CONSUME5:(n,i)=>this.CONSUME5(n,i),CONSUME6:(n,i)=>this.CONSUME6(n,i),CONSUME7:(n,i)=>this.CONSUME7(n,i),CONSUME8:(n,i)=>this.CONSUME8(n,i),CONSUME9:(n,i)=>this.CONSUME9(n,i),OPTION:n=>this.OPTION(n),OPTION1:n=>this.OPTION1(n),OPTION2:n=>this.OPTION2(n),OPTION3:n=>this.OPTION3(n),OPTION4:n=>this.OPTION4(n),OPTION5:n=>this.OPTION5(n),OPTION6:n=>this.OPTION6(n),OPTION7:n=>this.OPTION7(n),OPTION8:n=>this.OPTION8(n),OPTION9:n=>this.OPTION9(n),OR:n=>this.OR(n),OR1:n=>this.OR1(n),OR2:n=>this.OR2(n),OR3:n=>this.OR3(n),OR4:n=>this.OR4(n),OR5:n=>this.OR5(n),OR6:n=>this.OR6(n),OR7:n=>this.OR7(n),OR8:n=>this.OR8(n),OR9:n=>this.OR9(n),MANY:n=>this.MANY(n),MANY1:n=>this.MANY1(n),MANY2:n=>this.MANY2(n),MANY3:n=>this.MANY3(n),MANY4:n=>this.MANY4(n),MANY5:n=>this.MANY5(n),MANY6:n=>this.MANY6(n),MANY7:n=>this.MANY7(n),MANY8:n=>this.MANY8(n),MANY9:n=>this.MANY9(n),MANY_SEP:n=>this.MANY_SEP(n),MANY_SEP1:n=>this.MANY_SEP1(n),MANY_SEP2:n=>this.MANY_SEP2(n),MANY_SEP3:n=>this.MANY_SEP3(n),MANY_SEP4:n=>this.MANY_SEP4(n),MANY_SEP5:n=>this.MANY_SEP5(n),MANY_SEP6:n=>this.MANY_SEP6(n),MANY_SEP7:n=>this.MANY_SEP7(n),MANY_SEP8:n=>this.MANY_SEP8(n),MANY_SEP9:n=>this.MANY_SEP9(n),AT_LEAST_ONE:n=>this.AT_LEAST_ONE(n),AT_LEAST_ONE1:n=>this.AT_LEAST_ONE1(n),AT_LEAST_ONE2:n=>this.AT_LEAST_ONE2(n),AT_LEAST_ONE3:n=>this.AT_LEAST_ONE3(n),AT_LEAST_ONE4:n=>this.AT_LEAST_ONE4(n),AT_LEAST_ONE5:n=>this.AT_LEAST_ONE5(n),AT_LEAST_ONE6:n=>this.AT_LEAST_ONE6(n),AT_LEAST_ONE7:n=>this.AT_LEAST_ONE7(n),AT_LEAST_ONE8:n=>this.AT_LEAST_ONE8(n),AT_LEAST_ONE9:n=>this.AT_LEAST_ONE9(n),AT_LEAST_ONE_SEP:n=>this.AT_LEAST_ONE_SEP(n),AT_LEAST_ONE_SEP1:n=>this.AT_LEAST_ONE_SEP1(n),AT_LEAST_ONE_SEP2:n=>this.AT_LEAST_ONE_SEP2(n),AT_LEAST_ONE_SEP3:n=>this.AT_LEAST_ONE_SEP3(n),AT_LEAST_ONE_SEP4:n=>this.AT_LEAST_ONE_SEP4(n),AT_LEAST_ONE_SEP5:n=>this.AT_LEAST_ONE_SEP5(n),AT_LEAST_ONE_SEP6:n=>this.AT_LEAST_ONE_SEP6(n),AT_LEAST_ONE_SEP7:n=>this.AT_LEAST_ONE_SEP7(n),AT_LEAST_ONE_SEP8:n=>this.AT_LEAST_ONE_SEP8(n),AT_LEAST_ONE_SEP9:n=>this.AT_LEAST_ONE_SEP9(n),ACTION:n=>this.ACTION(n),BACKTRACK:(n,...i)=>this.BACKTRACK(this[n.name],{ARGS:i}),SUBRULE:r((n,i)=>this.SUBRULE(n,i)),SUBRULE1:r((n,i)=>this.SUBRULE1(n,i)),SUBRULE2:r((n,i)=>this.SUBRULE2(n,i)),SUBRULE3:r((n,i)=>this.SUBRULE3(n,i)),SUBRULE4:r((n,i)=>this.SUBRULE4(n,i)),SUBRULE5:r((n,i)=>this.SUBRULE5(n,i)),SUBRULE6:r((n,i)=>this.SUBRULE6(n,i)),SUBRULE7:r((n,i)=>this.SUBRULE7(n,i)),SUBRULE8:r((n,i)=>this.SUBRULE8(n,i)),SUBRULE9:r((n,i)=>this.SUBRULE9(n,i))}}};function Uf(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var ue=class e{constructor(t){H(this,"rules");this.rules=t}static create(t){return Array.isArray(t)?new e(Uf(t)):new e({...t.rules})}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,...Uf(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 a of Object.values(i))if(n[a.name]===void 0)n[a.name]=a;else if(n[a.name]!==a){let o=r.find(l=>l.name===a.name);if(o)n[a.name]=o;else throw new Error(`Rule with name "${a.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"],a=n.token.startLine;if(a!==void 0&&!Number.isNaN(a)){let s=t.split(`
|
|
114
|
+
`)[a-1];i.push(` on line ${a}
|
|
115
|
+
${s}`);let o=n.token.startColumn;o!==void 0&&i.push(`
|
|
116
|
+
${"-".repeat(o-1)}^`)}throw i.push(`
|
|
117
|
+
${n.message}`),new Error(i.join(""))}build({tokenVocabulary:t,parserConfig:r={},lexerConfig:n={},queryPreProcessor:i=s=>s,errorHandler:a}){let s=Oe.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 c of Object.values(this.rules))l[c.name]=((u,p,...f)=>{let h=i(u),g=s.tokenize(h);if(g.errors.length>0)throw new Error(g.errors[0].message);o.input=g.tokens,o.setContext(p);let T=o[c.name](p,...f);return o.errors.length>0&&(a?a(o.errors):this.defaultErrorHandler(h,o.errors)),T});return l}consume({tokenVocabulary:t,config:r={}}){return new Ia(this.rules,t,r)}};function $t(e){return e instanceof Promise}var La=class e{constructor(t={}){H(this,"defaultContext");H(this,"maxStackSize",1e6);H(this,"maxNodeRewrites",1e3);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){var G,B,te;let a=this.defaultContext,s=(G=a.copy)!=null?G:!0,o=(B=a.continue)!=null?B:!0,l=a.ignoreKeys,c=a.shallowKeys,u=(te=a.shortcut)!=null?te:!1,p=!1,f={res:t},h=[t],g=[f],T=["res"],x=[],v=[],A=[],y=[],L=[];function S(){for(;h.length===x.at(-1);){x.pop();let Y=v.pop(),pe=A.pop(),ye=y.pop(),z=L.pop(),be=r(Y,pe);if(i&&$t(be))return be.then(we=>(ye[z]=we,S()));ye[z]=be}}let N=(Y,pe,ye,z)=>{var Zt,Pe,Ut,re,he;let be=(Zt=z.copy)!=null?Zt:s,we=(Pe=z.continue)!=null?Pe:o,Le=(Ut=z.ignoreKeys)!=null?Ut:l,Ae=(re=z.shallowKeys)!=null?re:c;p=(he=z.shortcut)!=null?he:u;let Re=be?this.cloneObj(Y):Y;if(x.push(h.length),v.push(Re),A.push(Y),y.push(pe),L.push(ye),we&&!p)for(let xt in Re){if(!Object.hasOwn(Re,xt))continue;let me=Re[xt],Fe=Ae&&(Ae==null?void 0:Ae.has(xt));Fe&&(Re[xt]=this.cloneObj(me)),!(Le&&Le.has(xt))&&!Fe&&me!==null&&typeof me=="object"&&(h.push(me),T.push(xt),g.push(Re))}},X=()=>{for(;h.length>0&&h.length<this.maxStackSize;){let Y=h.pop(),pe=g.pop(),ye=T.pop();if(!p){if(Array.isArray(Y)){let we=[...Y];x.push(h.length),v.push(we),A.push(Y),y.push(pe),L.push(ye);for(let Ae=Y.length-1;Ae>=0;Ae--){let Re=Y[Ae];Re!==null&&typeof Re=="object"&&(h.push(Re),g.push(we),T.push(Ae.toString()))}let Le=S();if(Le)return Le.then(X);continue}let be=n(Y);if(i&&$t(be))return be.then(we=>{N(Y,pe,ye,we);let Le=S();return Le?Le.then(X):X()});N(Y,pe,ye,be)}let z=S();if(z)return z.then(X)}if(h.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return f.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){var L,S,N,X;let i=this.defaultContext,a=(L=i.copy)!=null?L:!0,s=(S=i.continue)!=null?S:!0,o=i.ignoreKeys,l=i.shallowKeys,c=(N=i.shortcut)!=null?N:!1,u=(X=i.reTransform)!=null?X:!1,p=!1,f={res:t},h=[t],g=[f],T=["res"],x=[0];function v(G,B){for(let te=G.length-1;te>=0;te--){let Y=G[te];Y!==null&&typeof Y=="object"&&(h.push(Y),g.push(G),T.push(te.toString()),x.push(B))}}let A=(G,B,te,Y)=>{var Ae,Re,Zt,Pe,Ut;let pe=G.newValue;B[te]=pe;let ye=(Ae=G.continue)!=null?Ae:s,z=(Re=G.ignoreKeys)!=null?Re:o,be=(Zt=G.shallowKeys)!=null?Zt:l,we=(Pe=G.reTransform)!=null?Pe:u;if(p=(Ut=G.shortcut)!=null?Ut:c,!ye||p||pe===null||typeof pe!="object")return;if(Array.isArray(pe)){v(pe,Y+1);return}if(we){h.push(pe),g.push(B),T.push(te),x.push(Y+1);return}let Le=pe;for(let re in Le){if(!Object.hasOwn(Le,re)||z!=null&&z.has(re))continue;let he=Le[re];he!==null&&typeof he=="object"&&(be!=null&&be.has(re)?Le[re]=this.cloneObj(he):(h.push(he),g.push(Le),T.push(re),x.push(0)))}},y=()=>{for(;!p&&h.length>0&&h.length<this.maxStackSize;){let G=h.pop(),B=g.pop(),te=T.pop(),Y=x.pop();if(Y>=this.maxNodeRewrites)throw new Error(`Pre order transform did not converge: rewrote the same position ${this.maxNodeRewrites} times.`,{cause:G});if(Array.isArray(G)){let z=[...G];B[te]=z,v(z,Y);continue}let pe=a?this.cloneObj(G):G,ye=r(pe,G);if(n&&$t(ye))return ye.then(z=>(A(z,B,te,Y),y()));A(ye,B,te,Y)}if(h.length>=this.maxStackSize)throw new Error("Transform object stack overflowed");return f.res};return y()}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){var x,v;let a=this.defaultContext,s=(x=a.continue)!=null?x:!0,o=a.ignoreKeys,l=(v=a.shortcut)!=null?v:!1,c=!1,u=[t],p=[],f=[];function h(){for(;u.length===p.at(-1);){p.pop();let A=f.pop(),y=r(A);if(i&&$t(y))return y.then(()=>h())}}let g=(A,y)=>{var N,X,G;c=(N=y.shortcut)!=null?N:l;let L=(X=y.continue)!=null?X:s,S=(G=y.ignoreKeys)!=null?G:o;if(p.push(u.length),f.push(A),L&&!c)for(let B in A){if(!Object.hasOwn(A,B)||S&&S.has(B))continue;let te=A[B];te&&typeof te=="object"&&u.push(te)}},T=()=>{for(;u.length>0&&u.length<this.maxStackSize;){let A=u.pop();if(!c){if(Array.isArray(A)){for(let N=A.length-1;N>=0;N--){let X=A[N];X!==null&&typeof X=="object"&&u.push(X)}let S=h();if(S)return S.then(T);continue}let L=n(A);if(i&&$t(L))return L.then(S=>{g(A,S);let N=h();return N?N.then(T):T()});g(A,L)}let y=h();if(y)return y.then(T)}if(u.length>=this.maxStackSize)throw new Error("Transform object stack overflowed")};return T()}};var Pa=class e extends La{constructor(r={},n={}){super(r);H(this,"defaultNodePreVisitor");this.defaultNodePreVisitor=n}clone(r={},n={}){return new e({...this.defaultContext,...r},{...this.defaultNodePreVisitor,...n})}transformNode(r,n){let i=(o,l)=>{var p;let c,u=o;return u.type&&(c=(p=n[u.type])==null?void 0:p.transform),c?c(u,l):o},a=this.defaultNodePreVisitor,s=o=>{var p,f;let l,c={},u=o;return u.type&&(l=(p=n[u.type])==null?void 0:p.preVisitor,c=(f=a[u.type])!=null?f:c),l?{...c,...l(u)}:c};return this.transformObject(r,i,s)}transformNodeAsync(r,n){let i=(o,l)=>{var p;let c,u=o;return u.type&&(c=(p=n[u.type])==null?void 0:p.transform),c?c(u,l):o},a=this.defaultNodePreVisitor,s=o=>{var f,h;let l,c={},u=o;if(u.type&&(l=(f=n[u.type])==null?void 0:f.preVisitor,c=(h=a[u.type])!=null?h:c),!l)return c;let p=l(u);return $t(p)?p.then(g=>({...c,...g})):{...c,...p}};return this.transformObjectAsync(r,i,s)}transformNodePreOrder(r,n){let i=this.defaultNodePreVisitor,a=(s,o)=>{var p;let l,c={},u=s;return u.type&&(l=n[u.type],c=(p=i[u.type])!=null?p:c),l?{...c,...l(s,o)}:{...c,newValue:s,reTransform:!1}};return this.transformObjectPreOrder(r,a)}transformNodePreOrderAsync(r,n){let i=this.defaultNodePreVisitor,a=(s,o)=>{var f;let l,c={},u=s;if(u.type&&(l=n[u.type],c=(f=i[u.type])!=null?f:c),!l)return{...c,newValue:s,reTransform:!1};let p=l(s,o);return $t(p)?p.then(h=>({...c,...h})):{...c,...p}};return this.transformObjectPreOrderAsync(r,a)}visitNode(r,n){let i=o=>{var c;let l=o;if(l.type){let u=(c=n[l.type])==null?void 0:c.visitor;u&&u(l)}},a=this.defaultNodePreVisitor,s=o=>{var p,f;let l,c={},u=o;return u.type&&(l=(p=n[u.type])==null?void 0:p.preVisitor,c=(f=a[u.type])!=null?f:c),l?{...c,...l(u)}:c};return this.visitObject(r,i,s)}visitNodeAsync(r,n){let i=o=>{var c;let l=o;if(l.type){let u=(c=n[l.type])==null?void 0:c.visitor;if(u)return u(l)}},a=this.defaultNodePreVisitor,s=o=>{var f,h;let l,c={},u=o;if(u.type&&(l=(f=n[u.type])==null?void 0:f.preVisitor,c=(h=a[u.type])!=null?h:c),!l)return c;let p=l(u);return $t(p)?p.then(g=>({...c,...g})):{...c,...p}};return this.visitObjectAsync(r,i,s)}};var Pr=class e extends Pa{constructor(t={},r={}){super(t,r)}clone(t={},r={}){return new e({...this.defaultContext,...t},{...this.defaultNodePreVisitor,...r})}transformNodeSpecific(t,r,n){let i=(s,o)=>{var u,p;let l,c=s;if(c.type&&c.subType){let f=n[c.type];f&&(l=(u=f[c.subType])==null?void 0:u.transform),l||(l=(p=r[c.type])==null?void 0:p.transform)}return l?l(c,o):s},a=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.preVisitor),o||(o=(u=r[l.type])==null?void 0:u.preVisitor)}return o?o(l):{}};return this.transformObject(t,i,a)}transformNodeSpecificAsync(t,r,n){let i=(s,o)=>{var u,p;let l,c=s;if(c.type&&c.subType){let f=n[c.type];f&&(l=(u=f[c.subType])==null?void 0:u.transform),l||(l=(p=r[c.type])==null?void 0:p.transform)}return l?l(c,o):s},a=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.preVisitor),o||(o=(u=r[l.type])==null?void 0:u.preVisitor)}return o?o(l):{}};return this.transformObjectAsync(t,i,a)}transformNodeSpecificPreOrder(t,r,n){let i=(a,s)=>{let o,l=a;if(l.type&&l.subType){let c=n[l.type];c&&(o=c[l.subType]),o||(o=r[l.type])}return o?o(a,s):{newValue:a}};return this.transformObjectPreOrder(t,i)}transformNodeSpecificPreOrderAsync(t,r,n){let i=(a,s)=>{let o,l=a;if(l.type&&l.subType){let c=n[l.type];c&&(o=c[l.subType]),o||(o=r[l.type])}return o?o(a,s):{newValue:a}};return this.transformObjectPreOrderAsync(t,i)}visitNodeSpecific(t,r,n){let i=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.visitor),o||(o=(u=r[l.type])==null?void 0:u.visitor)}o&&o(l)},a=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.preVisitor),o||(o=(u=r[l.type])==null?void 0:u.preVisitor)}return o?o(l):{}};this.visitObject(t,i,a)}visitNodeSpecificAsync(t,r,n){let i=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.visitor),o||(o=(u=r[l.type])==null?void 0:u.visitor)}if(o)return o(l)},a=s=>{var c,u;let o,l=s;if(l.type&&l.subType){let p=n[l.type];p&&(o=(c=p[l.subType])==null?void 0:c.preVisitor),o||(o=(u=r[l.type])==null?void 0:u.preVisitor)}return o?o(l):{}};return this.visitObjectAsync(t,i,a)}};var d={};Ze(d,{add:()=>ou,additiveExpression:()=>fy,aggregate:()=>Rs,aggregateAvg:()=>NT,aggregateCount:()=>IT,aggregateGroup_concat:()=>ST,aggregateMax:()=>_T,aggregateMin:()=>PT,aggregateSample:()=>OT,aggregateSum:()=>LT,argList:()=>ln,askQuery:()=>yi,baseAggregateFunc:()=>Cr,baseDecl:()=>Tc,bind:()=>Dc,blankNode:()=>Ns,blankNodePropertyList:()=>ny,blankNodePropertyListPath:()=>Sc,booleanLiteral:()=>wr,brackettedExpression:()=>cn,builtInAbs:()=>kg,builtInBnodeSparqlJs:()=>Sg,builtInBound:()=>_g,builtInCall:()=>qt,builtInCallList:()=>yT,builtInCeil:()=>Cg,builtInCoalesce:()=>lT,builtInConcat:()=>Mg,builtInContains:()=>Vg,builtInDatatype:()=>Pg,builtInDay:()=>Qg,builtInEncode_for_uri:()=>$g,builtInFloor:()=>Rg,builtInHours:()=>Xg,builtInIf:()=>cT,builtInIri:()=>Ng,builtInIsblank:()=>mT,builtInIsiri:()=>fT,builtInIsliteral:()=>gT,builtInIsnumeric:()=>TT,builtInIsuri:()=>hT,builtInLang:()=>Ig,builtInLangmatches:()=>Lg,builtInLcase:()=>Gg,builtInMd5:()=>nT,builtInMinutes:()=>Bg,builtInMonth:()=>Yg,builtInNow:()=>eT,builtInRand:()=>wg,builtInRound:()=>Fg,builtInSameterm:()=>dT,builtInSeconds:()=>Jg,builtInSha1:()=>iT,builtInSha256:()=>aT,builtInSha384:()=>sT,builtInSha512:()=>oT,builtInStr:()=>Eg,builtInStrafter:()=>zg,builtInStrbefore:()=>qg,builtInStrdt:()=>pT,builtInStrends:()=>Kg,builtInStrlang:()=>uT,builtInStrlen:()=>Dg,builtInStrstarts:()=>Hg,builtInStruuid:()=>rT,builtInTimezone:()=>Zg,builtInTz:()=>Ug,builtInUcase:()=>jg,builtInUri:()=>Og,builtInUuid:()=>tT,builtInYear:()=>Wg,canCreateBlankNodes:()=>Ik,clear:()=>iu,collection:()=>ey,collectionPath:()=>Oc,conditionalAndExpression:()=>qc,conditionalOrExpression:()=>py,constraint:()=>fi,constructQuery:()=>gi,constructTemplate:()=>ru,constructTriples:()=>Ty,copy:()=>cu,create:()=>su,dataBlock:()=>oy,dataBlockValue:()=>Hc,datasetClause:()=>bg,datasetClauseStar:()=>Tt,datasetClauseUsing:()=>xc,datasetClauseUsingStar:()=>Ac,defaultGraphClause:()=>vg,deleteClause:()=>by,deleteData:()=>pu,deleteWhere:()=>du,describeQuery:()=>Ti,drop:()=>au,existsFunc:()=>AT,expression:()=>F,expressionList:()=>Cs,filter:()=>$c,funcExpr1:()=>D,funcExpr2:()=>yt,funcExpr2or3:()=>ws,funcExpr3:()=>an,funcExpr3or4:()=>Pc,funcExprList1:()=>Ss,funcExprOrNil1:()=>Lc,funcGroupGraphPattern:()=>ks,funcNil1:()=>sn,funcVar1:()=>Ic,functionCall:()=>Gs,generatePattern:()=>ay,graphGraphPattern:()=>Fc,graphNode:()=>Cc,graphNodePath:()=>St,graphOrDefault:()=>mu,graphPatternNotTriples:()=>Vc,graphRef:()=>vi,graphRefAll:()=>Fr,graphTerm:()=>bc,groupClause:()=>Bc,groupCondition:()=>hy,groupGraphPattern:()=>ne,groupGraphPatternSub:()=>sy,groupOrUnionGraphPattern:()=>Gc,havingClause:()=>Jc,havingCondition:()=>my,inlineData:()=>on,inlineDataFull:()=>cy,inlineDataOneVar:()=>ly,insertClause:()=>hu,insertData:()=>uu,iri:()=>K,iriFull:()=>nn,iriOrFunction:()=>Xc,limitClause:()=>eu,limitOffsetClauses:()=>Uc,load:()=>nu,minusGraphPattern:()=>jc,modify:()=>fu,move:()=>lu,multiplicativeExpression:()=>Yc,namedGraphClause:()=>Ag,notExistsFunc:()=>ET,numericExpression:()=>Wc,numericLiteral:()=>Sr,numericLiteralNegative:()=>Ps,numericLiteralPositive:()=>Ls,numericLiteralUnsigned:()=>yg,object:()=>JT,objectList:()=>QT,objectListPath:()=>XT,objectPath:()=>ZT,offsetClause:()=>tu,optionalGraphPattern:()=>Rc,orderClause:()=>Zc,orderCondition:()=>gy,path:()=>Ms,pathAlternative:()=>CT,pathChainHelper:()=>Nc,pathElt:()=>_c,pathEltOrInverse:()=>wT,pathGenerator:()=>zt,pathMod:()=>RT,pathNegatedPropertySet:()=>MT,pathOneInPropertySet:()=>Fs,pathPrimary:()=>FT,pathSequence:()=>kT,prefixDecl:()=>yc,prefixedName:()=>gc,primaryExpression:()=>Qc,prologue:()=>it,propertyList:()=>HT,propertyListNotEmpty:()=>Ds,propertyListPath:()=>KT,propertyListPathNotEmpty:()=>js,quadData:()=>yu,quadPattern:()=>Ks,quads:()=>dn,quadsNotTriples:()=>gu,query:()=>un,queryOrUpdate:()=>Ok,queryUnit:()=>_k,rdfLiteral:()=>pr,regexExpression:()=>bT,relationalExpression:()=>dy,selectClause:()=>Vs,selectQuery:()=>mi,serviceGraphPattern:()=>Mc,solutionModifier:()=>st,sourceSelector:()=>Ec,strReplaceExpression:()=>xT,string:()=>_s,stringEscapedLexical:()=>di,subSelect:()=>Kc,substringExpression:()=>vT,triplesBlock:()=>wt,triplesNode:()=>wc,triplesNodePath:()=>kc,triplesSameSubject:()=>GT,triplesSameSubjectPath:()=>$T,triplesTemplate:()=>Rr,unaryExpression:()=>$s,update:()=>Hs,update1:()=>pn,updateUnit:()=>Nk,usingClause:()=>xg,usingClauseStar:()=>Os,valueLogical:()=>zc,valuesClause:()=>bi,varOrIri:()=>Kt,varOrTerm:()=>Se,var_:()=>ee,verb:()=>vc,verbA:()=>kr,verbPath:()=>zT,verbSimple:()=>WT,whereClause:()=>at});var q={};Ze(q,{a:()=>en,add:()=>ts,allBaseTokens:()=>og,as:()=>sr,ask:()=>Va,baseDecl:()=>Fa,bind:()=>hs,builtIn:()=>I,by:()=>oi,clear:()=>Za,construct:()=>Ga,copy:()=>is,create:()=>es,deleteClause:()=>ls,deleteDataClause:()=>ss,deleteWhereClause:()=>os,describe:()=>$a,distinct:()=>gt,drop:()=>Ua,false_:()=>vs,filter:()=>ys,from:()=>Ha,graph:()=>ke,groupByGroup:()=>si,having:()=>Ka,in_:()=>xs,insertClause:()=>us,insertDataClause:()=>cs,limit:()=>Ya,load:()=>Ba,loadInto:()=>Ja,minus:()=>gs,modifyWith:()=>as,move:()=>ns,notIn:()=>As,offset:()=>Qa,optional:()=>ds,order:()=>qa,orderAsc:()=>za,orderDesc:()=>Wa,patterns:()=>Ra,prefixDecl:()=>Ma,reduced:()=>ja,select:()=>Da,separator:()=>Es,service:()=>fs,silent:()=>Vt,sparql11LexerBuilder:()=>Ak,symbols:()=>b,terminals:()=>M,to:()=>rs,true_:()=>bs,undef:()=>ms,union:()=>Ts,usingClause:()=>ps,values:()=>Xa,where:()=>or});var I={};Ze(I,{BuiltInCalls:()=>P,abs:()=>ch,allBuiltInCalls:()=>$l,avg:()=>_a,bnode:()=>oh,bound:()=>ih,ceil:()=>uh,coalesce:()=>Gh,concat:()=>fh,contains:()=>yh,count:()=>em,datatype:()=>nh,day:()=>Lh,encode_for_uri:()=>Th,exists:()=>Zh,floor:()=>ph,groupConcat:()=>Na,hours:()=>Ph,if_:()=>$h,iri:()=>ah,isblank:()=>Wh,isiri:()=>qh,isliteral:()=>Yh,isnumeric:()=>Qh,isuri:()=>zh,lang:()=>th,langmatches:()=>rh,lcase:()=>gh,max:()=>nm,md5:()=>Rh,min:()=>rm,minutes:()=>_h,month:()=>Ih,notexists:()=>Uh,now:()=>wh,rand:()=>lh,regex:()=>Xh,replace:()=>Jh,round:()=>dh,sameterm:()=>Kh,sample:()=>im,seconds:()=>Nh,sha1:()=>Fh,sha256:()=>Mh,sha384:()=>Dh,sha512:()=>jh,str:()=>eh,strafter:()=>Ah,strbefore:()=>xh,strdt:()=>Hh,strends:()=>vh,strlang:()=>Vh,strlen:()=>hh,strstarts:()=>bh,struuid:()=>Ch,substr:()=>Bh,sum:()=>tm,timezone:()=>Oh,tz:()=>Sh,ucase:()=>mh,uri:()=>sh,uuid:()=>kh,year:()=>Eh});var P;(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"})(P||(P={}));function _(e){return e.charAt(0).toUpperCase()+e.slice(1)}var eh=m({name:_(P.Str),pattern:/str/i,label:"STR"}),th=m({name:_(P.Lang),pattern:/lang/i,label:"LANG"}),rh=m({name:_(P.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),nh=m({name:_(P.Datatype),pattern:/datatype/i,label:"DATATYPE"}),ih=m({name:_(P.Bound),pattern:/bound/i,label:"BOUND"}),ah=m({name:_(P.Iri),pattern:/iri/i,label:"IRI"}),sh=m({name:_(P.Uri),pattern:/uri/i,label:"URI"}),oh=m({name:_(P.Bnode),pattern:/bnode/i,label:"BNODE"}),lh=m({name:_(P.Rand),pattern:/rand/i,label:"RAND"}),ch=m({name:_(P.Abs),pattern:/abs/i,label:"ABS"}),uh=m({name:_(P.Ceil),pattern:/ceil/i,label:"CEIL"}),ph=m({name:_(P.Floor),pattern:/floor/i,label:"FLOOR"}),dh=m({name:_(P.Round),pattern:/round/i,label:"ROUND"}),fh=m({name:_(P.Concat),pattern:/concat/i,label:"CONCAT"}),hh=m({name:_(P.Strlen),pattern:/strlen/i,label:"STRLEN"}),mh=m({name:_(P.Ucase),pattern:/ucase/i,label:"UCASE"}),gh=m({name:_(P.Lcase),pattern:/lcase/i,label:"LCASE"}),Th=m({name:_(P.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),yh=m({name:_(P.Contains),pattern:/contains/i,label:"CONTAINS"}),bh=m({name:_(P.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),vh=m({name:_(P.Strends),pattern:/strends/i,label:"STRENDS"}),xh=m({name:_(P.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),Ah=m({name:_(P.Strafter),pattern:/strafter/i,label:"STRAFTER"}),Eh=m({name:_(P.Year),pattern:/year/i,label:"YEAR"}),Ih=m({name:_(P.Month),pattern:/month/i,label:"MONTH"}),Lh=m({name:_(P.Day),pattern:/day/i,label:"DAY"}),Ph=m({name:_(P.Hours),pattern:/hours/i,label:"HOURS"}),_h=m({name:_(P.Minutes),pattern:/minutes/i,label:"MINUTES"}),Nh=m({name:_(P.Seconds),pattern:/seconds/i,label:"SECONDS"}),Oh=m({name:_(P.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),Sh=m({name:_(P.Tz),pattern:/tz/i,label:"TZ"}),wh=m({name:_(P.Now),pattern:/now/i,label:"NOW"}),kh=m({name:_(P.Uuid),pattern:/uuid/i,label:"UUID"}),Ch=m({name:_(P.Struuid),pattern:/struuid/i,label:"STRUUID"}),Rh=m({name:_(P.Md5),pattern:/md5/i,label:"MD5"}),Fh=m({name:_(P.Sha1),pattern:/sha1/i,label:"SHA1"}),Mh=m({name:_(P.Sha256),pattern:/sha256/i,label:"SHA256"}),Dh=m({name:_(P.Sha384),pattern:/sha384/i,label:"SHA384"}),jh=m({name:_(P.Sha512),pattern:/sha512/i,label:"SHA512"}),Gh=m({name:_(P.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),$h=m({name:_(P.If),pattern:/if/i,label:"IF"}),Vh=m({name:_(P.Strlang),pattern:/strlang/i,label:"STRLANG"}),Hh=m({name:_(P.Strdt),pattern:/strdt/i,label:"STRDT"}),Kh=m({name:_(P.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),qh=m({name:_(P.Isiri),pattern:/isiri/i,label:"ISIRI"}),zh=m({name:_(P.Isuri),pattern:/isuri/i,label:"ISURI"}),Wh=m({name:_(P.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Yh=m({name:_(P.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Qh=m({name:_(P.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),Xh=m({name:_(P.Regex),pattern:/regex/i,label:"REGEX"}),Bh=m({name:_(P.Substr),pattern:/substr/i,label:"SUBSTR"}),Jh=m({name:_(P.Replace),pattern:/replace/i,label:"REPLACE"}),Zh=m({name:_(P.Exists),pattern:/exists/i,label:"EXISTS"}),Uh=m({name:_(P.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),em=m({name:_(P.Count),pattern:/count/i,label:"COUNT"}),tm=m({name:_(P.Sum),pattern:/sum/i,label:"SUM"}),rm=m({name:_(P.Min),pattern:/min/i,label:"MIN"}),nm=m({name:_(P.Max),pattern:/max/i,label:"MAX"}),_a=m({name:_(P.Avg),pattern:/avg/i,label:"AVG"}),im=m({name:_(P.Sample),pattern:/sample/i,label:"SAMPLE"}),Na=m({name:_(P.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),$l=Oe.create().add(rh,nh,th,ih,ah,sh,oh,lh,ch,uh,ph,dh,fh,hh,mh,gh,Th,yh,bh,vh,xh,Ah,Eh,Ih,Lh,Ph,_h,Nh,Oh,Sh,wh,kh,Ch,Rh,Fh,Mh,Dh,jh,Gh,$h,Vh,Hh,Kh,qh,zh,Wh,Yh,Qh,Xh,Bh,Jh,Zh,Uh,em,tm,rm,nm,_a,im,Na,eh);var ke={};Ze(ke,{allGraphTokens:()=>Vl,default_:()=>sm,graph:()=>om,graphAll:()=>Oa,named:()=>am});var am=m({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),sm=m({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),om=m({name:"Graph",pattern:/graph/i,label:"GRAPH"}),Oa=m({name:"GraphAll",pattern:/all/i,label:"ALL"}),Vl=Oe.create().add(am,sm,om,Oa);var Ra={};Ze(Ra,{anonPattern:()=>oc,atLeastOneBlankPattern:()=>ai,blankNodeLabelPattern:()=>Wl,commentPattern:()=>Ca,decimalNegativePattern:()=>ec,decimalPattern:()=>ri,decimalPositivePattern:()=>Jl,doubleNegativePattern:()=>tc,doublePattern:()=>ni,doublePositivePattern:()=>Zl,echarPattern:()=>ii,exponentPattern:()=>wa,integerNegativePattern:()=>Ul,integerPattern:()=>ti,integerPositivePattern:()=>Bl,iriRefPattern:()=>ql,langTagPattern:()=>Xl,nilPattern:()=>sc,pNameLnPattern:()=>zl,pNameNsPattern:()=>ka,percentPattern:()=>cm,plxPattern:()=>Sa,pnCharsBasePattern:()=>Hl,pnCharsPattern:()=>_r,pnCharsUPattern:()=>Zr,pnLocalEscPattern:()=>um,pnLocalPattern:()=>pm,pnPrefixPattern:()=>lm,stringLiteral1Pattern:()=>rc,stringLiteral2Pattern:()=>nc,stringLiteralLong1Pattern:()=>ic,stringLiteralLong2Pattern:()=>ac,var1Pattern:()=>Yl,var2Pattern:()=>Ql,varNamePattern:()=>Kl,wsPattern:()=>Ur});var Hl=/[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]/,Zr=new RegExp(`(${Hl.source})|_`),Kl=new RegExp(`((${Zr.source})|[0-9])((${Zr.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),ql=/<([^\u0000-\u0020"<>\\^`{|}])*>/,_r=new RegExp(`(${Zr.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),lm=new RegExp(`(${Hl.source})(((${_r.source})|\\.)*(${_r.source}))?`),ka=new RegExp(`(${lm.source})?:`),cm=/%[\dA-Fa-f]{2}/,um=/\\[!#$%&'()*+,./;=?@_~-]/,Sa=new RegExp(`(${cm.source})|(${um.source})`),pm=new RegExp(`((${Zr.source})|:|[0-9]|(${Sa.source}))(((${_r.source})|\\.|:|(${Sa.source}))*((${_r.source})|:|(${Sa.source})))?`),zl=new RegExp(`(${ka.source})(${pm.source})`),Wl=new RegExp(`_:((${Zr.source})|[0-9])(((${_r.source})|\\.)*(${_r.source}))?`),Yl=new RegExp(`\\?(${Kl.source})`),Ql=new RegExp(`\\$(${Kl.source})`),Xl=/@[A-Za-z]+(-[\dA-Za-z]+)*/,ti=/\d+/,ri=/\d+\.\d+/,wa=/[Ee][+-]?\d+/,ni=new RegExp(`([0-9]+\\.[0-9]*(${wa.source}))|(\\.[0-9]+(${wa.source}))|([0-9]+(${wa.source}))`),Bl=new RegExp(`\\+(${ti.source})`),Jl=new RegExp(`\\+(${ri.source})`),Zl=new RegExp(`\\+(${ni.source})`),Ul=new RegExp(`-(${ti.source})`),ec=new RegExp(`-(${ri.source})`),tc=new RegExp(`-(${ni.source})`),ii=/\\["'\\bfnrt]/,rc=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${ii.source}))*'`),nc=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${ii.source}))*"`),ic=new RegExp(`'''(('|(''))?([^'\\\\]|(${ii.source})))*'''`),ac=new RegExp(`"""(("|(""))?([^"\\\\]|(${ii.source})))*"""`),Ur=/[\u0009\u000A\u000D ]/,sc=new RegExp(`\\((${Ur.source})*\\)`),oc=new RegExp(`\\[(${Ur.source})*\\]`),Ca=/#[^\n]*/,ai=new RegExp(`(((${Ur.source})+)|((${Ca.source})
|
|
118
|
+
))+`);var b={};Ze(b,{LCurly:()=>dm,LParen:()=>Tm,LSquare:()=>bm,RCurly:()=>fm,RParen:()=>ym,RSquare:()=>vm,allSymbols:()=>lc,comma:()=>mm,dot:()=>hm,equal:()=>wm,exclamation:()=>Nm,greaterThan:()=>Rm,greaterThanEqual:()=>Mm,hat:()=>Em,hathat:()=>Dm,lessThan:()=>Cm,lessThanEqual:()=>Fm,logicAnd:()=>Om,logicOr:()=>Sm,notEqual:()=>km,opMinus:()=>_m,opPlus:()=>Pm,pipe:()=>xm,question:()=>Im,semi:()=>gm,slash:()=>Am,star:()=>Lm});var dm=m({name:"LCurly",pattern:"{",label:"{"}),fm=m({name:"RCurly",pattern:"}",label:"}"}),hm=m({name:"Dot",pattern:".",label:"."}),mm=m({name:"Comma",pattern:",",label:","}),gm=m({name:"Semi",pattern:";",label:";"}),Tm=m({name:"LParen",pattern:"(",label:"("}),ym=m({name:"RParen",pattern:")",label:")"}),bm=m({name:"LSquare",pattern:"[",label:"["}),vm=m({name:"RSquare",pattern:"]",label:"]"}),xm=m({name:"Pipe",pattern:"|",label:"|"}),Am=m({name:"Slash",pattern:"/",label:"/"}),Em=m({name:"Hat",pattern:"^",label:"^"}),Im=m({name:"Question",pattern:"?",label:"?"}),Lm=m({name:"Star",pattern:"*",label:"*"}),Pm=m({name:"OpPlus",pattern:"+",label:"+"}),_m=m({name:"OpMinus",pattern:"-",label:"-"}),Nm=m({name:"Exclamation",pattern:"!",label:"!"}),Om=m({name:"LogicAnd",pattern:"&&",label:"&&"}),Sm=m({name:"LogicOr",pattern:"||",label:"||"}),wm=m({name:"Equal",pattern:"=",label:"="}),km=m({name:"NotEqual",pattern:"!=",label:"!="}),Cm=m({name:"LessThan",pattern:"<",label:"<"}),Rm=m({name:"GreaterThan",pattern:">",label:">"}),Fm=m({name:"LessThanEqual",pattern:"<=",label:"<="}),Mm=m({name:"GreaterThanEqual",pattern:">=",label:">="}),Dm=m({name:"Hathat",pattern:"^^",label:"^^"}),lc=Oe.create().add(Om,Sm,km,Fm,Mm,dm,fm,hm,mm,gm,Tm,ym,bm,vm,xm,Am,Dm,Em,Im,Lm,Pm,_m,Nm,wm,Cm,Rm);var M={};Ze(M,{allTerminals:()=>uc,anon:()=>sg,blankNodeLabel:()=>$m,comment:()=>ig,decimal:()=>zm,decimalNegative:()=>Jm,decimalPositive:()=>Qm,double:()=>Wm,doubleNegative:()=>Zm,doublePositive:()=>Xm,integer:()=>qm,integerNegative:()=>Bm,integerPositive:()=>Ym,iriRef:()=>jm,langTag:()=>Km,nil:()=>ag,pNameLn:()=>cc,pNameNs:()=>Gm,stringLiteral1:()=>Um,stringLiteral2:()=>eg,stringLiteralLong1:()=>tg,stringLiteralLong2:()=>rg,var1:()=>Vm,var2:()=>Hm,ws:()=>ng});var jm=m({name:"IriRef",pattern:ql}),cc=m({name:"PNameLn",pattern:zl}),Gm=m({name:"PNameNs",pattern:ka,longer_alt:[cc]}),$m=m({name:"BlankNodeLabel",pattern:Wl}),Vm=m({name:"Var1",pattern:Yl}),Hm=m({name:"Var2",pattern:Ql}),Km=m({name:"LangTag",pattern:Xl}),qm=m({name:"Integer",pattern:ti}),zm=m({name:"Decimal",pattern:ri}),Wm=m({name:"Double",pattern:ni}),Ym=m({name:"IntegerPositive",pattern:Bl}),Qm=m({name:"DecimalPositive",pattern:Jl}),Xm=m({name:"DoublePositive",pattern:Zl}),Bm=m({name:"IntegerNegative",pattern:Ul}),Jm=m({name:"DecimalNegative",pattern:ec}),Zm=m({name:"DoubleNegative",pattern:tc}),Um=m({name:"StringLiteral1",pattern:rc}),eg=m({name:"StringLiteral2",pattern:nc}),tg=m({name:"StringLiteralLong1",pattern:ic}),rg=m({name:"StringLiteralLong2",pattern:ac}),ng=m({name:"Ws",pattern:Ur,group:Ne.SKIPPED}),ig=m({name:"Comment",pattern:Ca,group:Ne.SKIPPED}),ag=m({name:"Nil",pattern:sc}),sg=m({name:"Anon",pattern:oc}),uc=Oe.create().add(jm,Gm,cc,$m,Vm,Hm,Km,Wm,zm,qm,Xm,Qm,Ym,Zm,Jm,Bm,tg,rg,Um,eg,ng,ig,ag,sg);var Fa=m({name:"BaseDecl",pattern:/base/i,label:"BASE"}),Ma=m({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),Da=m({name:"Select",pattern:/select/i,label:"SELECT"}),gt=m({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),ja=m({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),sr=m({name:"As",pattern:/as/i,label:"AS"}),Ga=m({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),$a=m({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),Va=m({name:"Ask",pattern:/ask/i,label:"ASK"}),Ha=m({name:"From",pattern:/from/i,label:"FROM"}),or=m({name:"Where",pattern:/where/i,label:"WHERE"}),si=m({name:"GroupByGroup",pattern:/group/i,label:"_GROUP_ BY"}),oi=m({name:"By",pattern:/by/i,label:"BY"}),Ka=m({name:"Having",pattern:/having/i,label:"HAVING"}),qa=m({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),za=m({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Wa=m({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),Ya=m({name:"Limit",pattern:/limit/i,label:"LIMIT"}),Qa=m({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Xa=m({name:"Values",pattern:/values/i,label:"VALUES"}),Ba=m({name:"Load",pattern:/load/i,label:"LOAD"}),Vt=m({name:"Silent",pattern:/silent/i,label:"SILENT"}),Ja=m({name:"LoadInto",pattern:/into/i,label:"INTO"}),Za=m({name:"Clear",pattern:/clear/i,label:"CLEAR"}),Ua=m({name:"Drop",pattern:/drop/i,label:"DROP"}),es=m({name:"Create",pattern:/create/i,label:"CREATE"}),ts=m({name:"Add",pattern:/add/i,label:"ADD"}),rs=m({name:"To",pattern:/to/i,label:"TO"}),ns=m({name:"Move",pattern:/move/i,label:"MOVE"}),is=m({name:"Copy",pattern:/copy/i,label:"COPY"}),as=m({name:"ModifyWith",pattern:/with/i,label:"WITH"}),ss=m({name:"DeleteDataClause",pattern:new RegExp(`delete(${ai.source})data`,"i"),label:"DELETE DATA"}),os=m({name:"DeleteWhereClause",pattern:new RegExp(`delete(${ai.source})where`,"i"),label:"DELETE WHERE"}),ls=m({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),cs=m({name:"InsertDataClause",pattern:new RegExp(`insert(${ai.source})data`,"i"),label:"INSERT DATA"}),us=m({name:"InsertClause",pattern:/insert/i,label:"insert"}),ps=m({name:"UsingClause",pattern:/using/i,label:"USING"}),ds=m({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),fs=m({name:"Service",pattern:/service/i,label:"SERVICE"}),hs=m({name:"Bind",pattern:/bind/i,label:"BIND"}),ms=m({name:"Undef",pattern:/undef/i,label:"UNDEF"}),gs=m({name:"Minus",pattern:/minus/i,label:"MINUS"}),Ts=m({name:"Union",pattern:/union/i,label:"UNION"}),ys=m({name:"Filter",pattern:/filter/i,label:"FILTER"}),en=m({name:"a",pattern:"a",label:"type declaration 'a'"}),bs=m({name:"True",pattern:/true/i,label:"true"}),vs=m({name:"False",pattern:/false/i,label:"false"}),xs=m({name:"In",pattern:/in/i,label:"IN"}),As=m({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),Es=m({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),og=Oe.create().add(Fa,Ma,Da,gt,ja,Ga,$a,Va,Ha,or,Ka,si,oi,qa,za,Wa,Ya,Qa,Xa,Ba,Vt,Ja,Za,Ua,es,ts,rs,ns,is,as,os,ss,ls,cs,us,ps,ds,fs,hs,ms,gs,Ts,ys,sr,en,bs,vs,xs,As,Es),Ak=Oe.create(uc).merge(og).merge($l).merge(Vl).merge(lc).moveAfter(_a,en).moveBefore(en,Oa).moveAfter(Na,si);var pi={};Ze(pi,{checkBlankNodeBGPScope:()=>mc,checkNote13:()=>hc,findPatternBoundedVars:()=>ci,getAggregatesOfExpression:()=>Or,getExpressionId:()=>ur,getVariablesFromExpression:()=>li,queryProjectionIsGood:()=>fc,updateNoReuseBlankNodeLabels:()=>ui});var pc="contextDef";function lg(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:pc,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,pc,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,pc,"base")}}}var Ot="expression";function cg(e){return class extends e{isExpressionPure(r){return this.isOfType(r,Ot)}formatOperator(r){return r.toLowerCase().replaceAll(" ","")}expressionOperation(r,n,i){return{type:Ot,subType:"operation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionOperator(r){return this.isOfSubType(r,Ot,"operation")}expressionFunctionCall(r,n,i,a){return{type:"expression",subType:"functionCall",function:r,args:n,distinct:i,loc:a}}isExpressionFunctionCall(r){return this.isOfSubType(r,Ot,"functionCall")}expressionPatternOperation(r,n,i){return{type:Ot,subType:"patternOperation",operator:this.formatOperator(r),args:n,loc:i}}isExpressionPatternOperation(r){return this.isOfSubType(r,Ot,"patternOperation")}aggregate(r,n,i,a,s){let o={type:"expression",subType:"aggregate",aggregation:this.formatOperator(r),distinct:n,loc:s};return this.isOfType(i,"wildcard")?{...o,expression:[i]}:a===void 0?{...o,expression:[i]}:{...o,expression:[i],separator:a}}isExpressionAggregate(r){return this.isOfSubType(r,Ot,"aggregate")}isExpressionAggregateSeparator(r){return this.isOfSubType(r,Ot,"aggregate")&&typeof r.separator=="string"}isExpressionAggregateOnWildcard(r){let n=r;return this.isOfSubType(r,Ot,"aggregate")&&Array.isArray(n.expression)&&n.expression.length===1&&this.isOfType(n.expression[0],"wildcard")}isExpressionAggregateDefault(r){let n=r;return this.isOfSubType(r,Ot,"operation")&&Array.isArray(n.expression)&&n.expression.length===1&&!this.isOfType(n.expression[0],"wildcard")}}}var Ht="graphRef";function ug(e){return class extends e{isGraphRef(r){return this.isOfType(r,Ht)}graphRefDefault(r){return{type:Ht,subType:"default",loc:r}}isGraphRefDefault(r){return this.isOfSubType(r,Ht,"default")}graphRefNamed(r){return{type:Ht,subType:"named",loc:r}}isGraphRefNamed(r){return this.isOfSubType(r,Ht,"named")}graphRefAll(r){return{type:Ht,subType:"all",loc:r}}isGraphRefAll(r){return this.isOfSubType(r,Ht,"all")}graphRefSpecific(r,n){return{type:Ht,subType:"specific",graph:r,loc:n}}isGraphRefSpecific(r){return this.isOfSubType(r,Ht,"specific")}}}function pg(e){return new dc(e)}var dc=class{constructor(t){H(this,"input");this.input=t}call(t){return this.input=t(this.input),this}returns(){return this.input}};var nt="path";function dg(e){return class extends e{isPathPure(r){return this.isOfType(r,nt)}path(r,n,i){let a={type:nt,loc:i,items:n};if(r==="|"||r==="/")return{...a,subType:r};if((r==="?"||r==="*"||r==="+"||r==="^"&&this.isPathPure(n[0]))&&n.length===1)return{...a,subType:r,items:n};if(r==="^"&&n.length===1&&!this.isPathPure(n[0]))return{...a,subType:r,items:n};if(r==="!"&&n.length===1&&(this.isPathAlternativeLimited(n[0])||!this.isPathPure(n[0])||this.isPathNegatedElt(n[0])))return{...a,subType:r,items:n};throw new Error("Invalid path type")}isPathOfType(r,n){return this.isOfType(r,nt)&&n.includes(r.subType)}isPathChain(r){return this.isOfSubType(r,nt,"/")||this.isOfSubType(r,nt,"|")}isPathModified(r){return this.isOfSubType(r,nt,"?")||this.isOfSubType(r,nt,"*")||this.isOfSubType(r,nt,"+")||this.isOfSubType(r,nt,"^")}isPathNegatedElt(r){let n=r;return this.isOfSubType(r,nt,"^")&&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,nt,"!")}isPathAlternativeLimited(r){let n=r;return this.isOfSubType(r,nt,"|")&&Array.isArray(n.items)&&n.items.every(i=>!this.isPathPure(i)||this.isPathNegatedElt(i))}}}var de="pattern";function fg(e){return class extends e{isPattern(r){return this.isOfType(r,de)}patternBgp(r,n){return{type:de,subType:"bgp",triples:r,loc:n}}isPatternBgp(r){return this.isOfSubType(r,de,"bgp")}patternGroup(r,n){return{type:de,subType:"group",patterns:r,loc:n}}isPatternGroup(r){return this.isOfSubType(r,de,"group")}patternGraph(r,n,i){return{type:de,subType:"graph",name:r,patterns:n,loc:i}}isPatternGraph(r){return this.isOfSubType(r,de,"graph")}patternOptional(r,n){return{type:de,subType:"optional",patterns:r,loc:n}}isPatternOptional(r){return this.isOfSubType(r,de,"optional")}patternValues(r,n,i){return{type:de,subType:"values",variables:r,values:n,loc:i}}isPatternValues(r){return this.isOfSubType(r,de,"values")}patternFilter(r,n){return{type:de,subType:"filter",expression:r,loc:n}}isPatternFilter(r){return this.isOfSubType(r,de,"filter")}patternBind(r,n,i){return{type:de,subType:"bind",expression:r,variable:n,loc:i}}isPatternBind(r){return this.isOfSubType(r,de,"bind")}patternUnion(r,n){return{type:de,subType:"union",patterns:r,loc:n}}isPatternUnion(r){return this.isOfSubType(r,de,"union")}patternMinus(r,n){return{type:de,subType:"minus",patterns:r,loc:n}}isPatternMinus(r){return this.isOfSubType(r,de,"minus")}patternService(r,n,i,a){return{type:de,subType:"service",silent:i,name:r,patterns:n,loc:a}}isPatternService(r){return this.isOfSubType(r,de,"service")}}}var tn="query";function hg(e){return class extends e{isQuery(r){return this.isOfType(r,tn)}isQuerySelect(r){return this.isOfSubType(r,tn,"select")}queryConstruct(r,n,i,a,s,o,l){return{type:"query",subType:"construct",context:n,template:i,where:a,solutionModifiers:s,datasets:o,values:l,loc:r}}isQueryConstruct(r){return this.isOfSubType(r,tn,"construct")}isQueryDescribe(r){return this.isOfSubType(r,tn,"describe")}isQueryAsk(r){return this.isOfSubType(r,tn,"ask")}querySelect(r,n){return{type:tn,subType:"select",...r,loc:n}}}}var lr="solutionModifier";function mg(e){return class extends e{isSolutionModifier(r){return this.isOfType(r,lr)}solutionModifierHaving(r,n){return{type:lr,subType:"having",having:r,loc:n}}isSolutionModifierHaving(r){return this.isOfSubType(r,lr,"having")}solutionModifierOrder(r,n){return{type:lr,subType:"order",orderDefs:r,loc:n}}isSolutionModifierOrder(r){return this.isOfSubType(r,lr,"order")}solutionModifierLimitOffset(r,n,i){return{type:lr,subType:"limitOffset",limit:r,offset:n,loc:i}}isSolutionModifierLimitOffset(r){return this.isOfSubType(r,lr,"limitOffset")}solutionModifierGroup(r,n){return{type:"solutionModifier",subType:"group",groupings:r,loc:n}}isSolutionModifierGroup(r){return this.isOfSubType(r,lr,"group")}}}var Nr="term";function gg(e){return class extends e{constructor(){super(...arguments);H(this,"__blankNodeCounter",0)}resetBlankNodeCounter(){this.__blankNodeCounter=0}isTerm(n){return this.isOfType(n,"term")}termBlank(n,i){let a={type:"term",subType:"blankNode",loc:i};return n===void 0?{...a,label:`g_${this.__blankNodeCounter++}`}:{...a,label:`e_${n}`}}isTermBlank(n){return this.isOfSubType(n,Nr,"blankNode")}termLiteral(n,i,a){return{type:Nr,subType:"literal",value:i,langOrIri:a,loc:n}}isTermLiteral(n){return this.isOfSubType(n,Nr,"literal")}isTermLiteralLangStr(n){return this.isTermLiteral(n)&&typeof n.langOrIri=="string"}isTermLiteralStr(n){return this.isTermLiteral(n)&&typeof n.langOrIri=="undefined"}isTermLiteralTyped(n){let i=n;return this.isTermLiteral(n)&&typeof i.langOrIri=="object"&&i.langOrIri!==null&&this.isTermNamed(i.langOrIri)}termVariable(n,i){return{type:Nr,subType:"variable",value:n,loc:i}}isTermVariable(n){return this.isOfSubType(n,Nr,"variable")}termNamed(n,i,a){let s={type:Nr,subType:"namedNode",value:i,loc:n};return a===void 0?s:{...s,prefix:a}}isTermNamed(n){return this.isOfSubType(n,Nr,"namedNode")}isTermNamedPrefixed(n){let i=n;return this.isTermNamed(n)&&typeof i.prefix=="string"}}}var Ye="updateOperation";function Tg(e){return class extends e{isUpdateOperation(r){return this.isOfType(r,Ye)}updateOperationLoad(r,n,i,a){return{type:Ye,subType:"load",silent:i,source:n,...a&&{destination:a},loc:r}}isUpdateOperationLoad(r){return this.isOfSubType(r,Ye,"load")}updateOperationClearDrop(r,n,i,a){return{type:"updateOperation",subType:r,silent:n,destination:i,loc:a}}updateOperationClear(r,n,i){return this.updateOperationClearDrop("clear",n,r,i)}isUpdateOperationClear(r){return this.isOfSubType(r,Ye,"clear")}updateOperationDrop(r,n,i){return this.updateOperationClearDrop("drop",n,r,i)}isUpdateOperationDrop(r){return this.isOfSubType(r,Ye,"drop")}updateOperationCreate(r,n,i){return{type:"updateOperation",subType:"create",silent:n,destination:r,loc:i}}isUpdateOperationCreate(r){return this.isOfSubType(r,Ye,"create")}updateOperationAddMoveCopy(r,n,i,a,s){return{type:"updateOperation",subType:r,silent:a,source:n,destination:i,loc:s}}updateOperationAdd(r,n,i,a){return this.updateOperationAddMoveCopy("add",r,n,i,a)}isUpdateOperationAdd(r){return this.isOfSubType(r,Ye,"add")}updateOperationMove(r,n,i,a){return this.updateOperationAddMoveCopy("move",r,n,i,a)}isUpdateOperationMove(r){return this.isOfSubType(r,Ye,"move")}updateOperationCopy(r,n,i,a){return this.updateOperationAddMoveCopy("copy",r,n,i,a)}isUpdateOperationCopy(r){return this.isOfSubType(r,Ye,"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,Ye,"insertdata")}updateOperationDeleteData(r,n){return this.updateOperationInsDelDataWhere("deletedata",r,n)}isUpdateOperationDeleteData(r){return this.isOfSubType(r,Ye,"deletedata")}updateOperationDeleteWhere(r,n){return this.updateOperationInsDelDataWhere("deletewhere",r,n)}isUpdateOperationDeleteWhere(r){return this.isOfSubType(r,Ye,"deletewhere")}updateOperationModify(r,n,i,a,s,o){return{type:"updateOperation",subType:"modify",insert:n!=null?n:[],delete:i!=null?i:[],graph:o,where:a,from:s,loc:r}}isUpdateOperationModify(r){return this.isOfSubType(r,Ye,"modify")}}}var cr=class extends pg(Ri).call(lg).call(cg).call(ug).call(dg).call(fg).call(hg).call(mg).call(gg).call(Tg).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!=null?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")}};var se;(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"})(se||(se={}));var rn=class extends Pr{};var j=new cr,Is=new rn;function Or(e){if(j.isExpressionAggregate(e))return[e];if(j.isExpressionOperator(e)){let t=[];for(let r of e.args)t.push(...Or(r));return t}return[]}function ur(e){return j.isTerm(e)&&j.isTermVariable(e)?e.value:j.isExpression(e)?j.isExpressionAggregate(e)&&j.isTermVariable(e.expression[0])?e.expression[0].value:void 0:e.variable.value}function li(e,t){if(j.isExpressionOperator(e))for(let r of e.args)li(r,t);else j.isTerm(e)&&j.isTermVariable(e)&&t.add(e.value)}function fc(e){if(e.variables.length===1&&j.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(a=>j.isTerm(a)?[]:Or(a.expression)).some(a=>a.aggregation==="count"&&!a.expression.some(s=>j.isWildcard(s))),n=e.solutionModifiers.group;if(r||n){for(let a of t)if(j.isTerm(a)){if(!n||!n.groupings.map(s=>ur(s)).includes(ur(a)))throw new Error("Variable not allowed in projection")}else if(Or(a.expression).length===0){let s=new Set;li(a.expression,s);for(let o of s)if(!n||!n.groupings.map(l=>ur(l)).includes(o))throw new Error(`Use of ungrouped variable in projection of operation (?${o})`)}}let i=e.where.patterns.filter(a=>a.type==="query");if(i.length>0){let a=new Set;for(let l of t)"variable"in l&&a.add(l.variable.value);let s=i.flatMap(l=>l.variables).map(l=>j.isTerm(l)?l.value:j.isWildcard(l)?"*":l.variable.value),o=new Set(s);for(let l of a)if(o.has(l))throw new Error(`Target id of 'AS' (?${l}) already used in subquery`)}}function ci(e,t){var n;function r(i){ci(i,t)}if(e!==void 0)if(Array.isArray(e))for(let i of e)r(i);else if(j.isQuery(e))j.isQuerySelect(e)||j.isQueryDescribe(e)?r([...e.variables.some(i=>j.isWildcard(i))?[e.where]:e.variables,e.solutionModifiers.group,e.values]):r(e.solutionModifiers.group);else if(j.isTriple(e))r([e.subject,e.predicate,e.object]);else if(j.isPathPure(e))r(e.items);else if(j.isTripleCollection(e))r([e.identifier,...e.triples]);else if(j.isSolutionModifierGroup(e))r(e.groupings.filter(i=>"variable"in i).map(i=>i.variable));else if(j.isSolutionModifierHaving(e))r(e.having);else if(j.isSolutionModifierOrder(e))r(e.orderDefs.map(i=>i.expression));else if(j.isPatternValues(e))for(let i of Object.keys((n=e.values.at(0))!=null?n:{}))t.add(i);else j.isPatternBgp(e)?r(e.triples):j.isPatternGroup(e)||j.isPatternUnion(e)||j.isPatternOptional(e)?r(e.patterns):j.isPatternService(e)||j.isPatternGraph(e)?r([e.name,...e.patterns]):j.isPatternBind(e)?r(e.variable):j.isTermVariable(e)&&t.add(e.value)}function hc(e){for(let[r,n]of e.entries())if(j.isPatternBind(n)&&r>0&&j.isPatternBgp(e[r-1])){let i=e[r-1],a=[];if(Is.visitNodeSpecific(i,{},{term:{variable:{visitor:s=>{a.push(s)}}}}),a.some(s=>s.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(j.isPatternBind(r)){if(t.has(r.variable.value))throw new Error(`Variable used to bind is already bound (?${r.variable.value})`)}else ci(r,t)}function ui(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;Is.visitNodeSpecific(n,{},{term:{blankNode:{visitor:a=>{if(i.add(a.label),t.has(a.label))throw new Error("Detected reuse blank node across different INSERT DATA clauses")}}}});for(let a of i)t.add(a)}}}function mc(e){let t=new Map,r=[{}],n=()=>r.at(-1);function i(s){let o=new Set;return Is.visitNodeSpecific(s,{},{term:{blankNode:{visitor:l=>{o.add(l.label)}}}}),o}let a={preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop(),r[r.length-1]={}}};Is.visitNodeSpecific(e,{query:{preVisitor:()=>({continue:!1})},pattern:a},{pattern:{bgp:{preVisitor:s=>{let o=n();for(let l of i(s)){let c=t.get(l);if(c!==void 0&&c!==o)throw new Error(`Detected reuse of blank node across two different basic graph patterns (_:${l.replace(/^[eg]_/u,"")})`);t.set(l,o)}return{continue:!1}},visitor:()=>{}},filter:{preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop()}}}})}var Ek={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function di(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>Ek[r])}"`}var pr={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>a=>{var o;let s=t(_s);return(o=n(()=>i([{ALT:()=>{let l=r(M.langTag);return e(()=>a.astFactory.termLiteral(a.astFactory.sourceLocation(s,l),s.value,l.image.slice(1).toLowerCase()))}},{ALT:()=>{r(b.hathat);let l=t(K);return e(()=>a.astFactory.termLiteral(a.astFactory.sourceLocation(s,l),s.value,l))}}])))!=null?o:s},gImpl:({SUBRULE:e,PRINT:t,PRINT_WORD:r})=>(n,{astFactory:i})=>{!n.langOrIri||typeof n.langOrIri=="string"?(i.printFilter(n,()=>{r(""),t(di(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(di(n.value),"^^")}),e(K,n.langOrIri))}},Sr={name:"numericLiteral",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(yg)},{ALT:()=>e(Ls)},{ALT:()=>e(Ps)}])},yg={name:"numericLiteralUnsigned",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(M.integer),se.INTEGER]},{ALT:()=>[t(M.decimal),se.DECIMAL]},{ALT:()=>[t(M.double),se.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Ls={name:"numericLiteralPositive",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(M.integerPositive),se.INTEGER]},{ALT:()=>[t(M.decimalPositive),se.DECIMAL]},{ALT:()=>[t(M.doublePositive),se.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},Ps={name:"numericLiteralNegative",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>[t(M.integerNegative),se.INTEGER]},{ALT:()=>[t(M.decimalNegative),se.DECIMAL]},{ALT:()=>[t(M.doubleNegative),se.DOUBLE]}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i[0]),i[0].image,n.astFactory.termNamed(n.astFactory.sourceLocation(),i[1])))}},wr={name:"booleanLiteral",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(bs)},{ALT:()=>t(vs)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),se.BOOLEAN)))}},_s={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let a=t(M.stringLiteral1);return[a,a.image.slice(1,-1)]}},{ALT:()=>{let a=t(M.stringLiteral2);return[a,a.image.slice(1,-1)]}},{ALT:()=>{let a=t(M.stringLiteralLong1);return[a,a.image.slice(3,-3)]}},{ALT:()=>{let a=t(M.stringLiteralLong2);return[a,a.image.slice(3,-3)]}}]);return e(()=>{let a=n.astFactory,s=i[1].replaceAll(/\\([tnrbf"'\\])/gu,(o,l)=>{switch(l){case"t":return" ";case"n":return`
|
|
119
|
+
`;case"r":return"\r";case"b":return"\b";case"f":return"\f";default:return l}});return a.termLiteral(a.sourceLocation(i[0]),s)})}},K={name:"iri",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(nn)},{ALT:()=>e(gc)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(gc,t):e(nn,t)},nn={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(M.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,">"))}},gc={name:"prefixedName",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{function i(a){if(!n.skipValidation&&n.prefixes[a]===void 0)throw new Error(`Unknown prefix: ${a}`)}return r([{ALT:()=>{let a=t(M.pNameLn);return e(()=>{let s=a.image.indexOf(":"),o=a.image.slice(0,s),l=a.image.slice(s+1);return i(o),n.astFactory.termNamed(n.astFactory.sourceLocation(a),l,o)})}},{ALT:()=>{let a=t(M.pNameNs);return e(()=>{let s=a.image.slice(0,-1);return i(s),n.astFactory.termNamed(n.astFactory.sourceLocation(a),"",s)})}}])},gImpl:({PRINT:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>e(t.prefix,":",t.value))}},Ik=Symbol("canCreateBlankNodes"),Ns={name:"blankNode",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let a=t(M.blankNodeLabel);return e(()=>n.astFactory.termBlank(a.image.slice(2),n.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=t(M.anon);return e(()=>n.astFactory.termBlank(void 0,n.astFactory.sourceLocation(a)))}}]);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,"")))}},kr={name:"VerbA",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(en);return e(()=>r.astFactory.termNamed(r.astFactory.sourceLocation(n),se.TYPE,void 0))}};var it={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(Tc))},{ALT:()=>n.push(e(yc))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(Tc,n):e(yc,n)}},Tc={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Fa),a=r(nn);return e(()=>n.astFactory.contextDefinitionBase(n.astFactory.sourceLocation(i,a),a))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BASE ")),e(K,n.value),i.printFilter(n,()=>r())}},yc={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Ma),a=t(M.pNameNs).image.slice(0,-1),s=r(nn);return e(()=>(n.prefixes[a]=s.value,n.astFactory.contextDefinitionPrefix(n.astFactory.sourceLocation(i,s),a,s)))},gImpl:({SUBRULE:e,PRINT_ON_EMPTY:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("PREFIX ",`${n.key}: `)}),e(K,n.value),i.printFilter(n,()=>r())}},vc={name:"verb",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Kt)},{ALT:()=>e(kr)}])},Se={name:"varOrTerm",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(ee)},{ALT:()=>e(bc)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(ee,t):e(bc,t)},Kt={name:"varOrIri",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(ee)},{ALT:()=>e(K)}])},ee={name:"var",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(M.var1)},{ALT:()=>t(M.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}`))}},bc={name:"graphTerm",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(K)},{ALT:()=>t(pr)},{ALT:()=>t(Sr)},{ALT:()=>t(wr)},{GATE:()=>i.parseMode.has("canCreateBlankNodes"),ALT:()=>t(Ns)},{ALT:()=>{let a=r(M.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(a),se.NIL))}}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(K,t):r.isTermLiteral(t)?e(pr,t):e(Ns,t)}};function xc(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i,OR:a})=>s=>{let o=i(t);return a([{ALT:()=>{let l=n(vg);return r(()=>s.astFactory.wrap({clauseType:"default",value:l},s.astFactory.sourceLocation(o,l)))}},{ALT:()=>{let l=n(Ag);return r(()=>s.astFactory.wrap({clauseType:"named",value:l.val},s.astFactory.sourceLocation(o,l)))}}])}}}var bg=xc("datasetClause",Ha),vg={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(Ec)},xg=xc("usingClause",ps);function Ac(e,t,r){return{name:e,impl:({ACTION:n,MANY:i,SUBRULE:a})=>s=>{let o=[];return i(()=>{let l=a(t);o.push(l)}),n(()=>s.astFactory.datasetClauses(o.map(l=>l.val),s.astFactory.sourceLocation(...o)))},gImpl:({SUBRULE:n,PRINT_WORD:i})=>(a,{astFactory:s})=>{for(let o of a.clauses)s.printFilter(a,()=>i(r)),o.clauseType==="named"&&s.printFilter(a,()=>i("NAMED")),n(K,o.value)}}}var Tt=Ac("datasetClauses",bg,"FROM"),Os=Ac("usingClauses",xg,"USING"),Ag={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ke.named),a=t(Ec);return e(()=>n.astFactory.wrap(a,n.astFactory.sourceLocation(i,a)))}},Ec={name:"sourceSelector",impl:({SUBRULE:e})=>()=>e(K)};function D(e){return{name:ge(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let a=n(e);n(b.LParen);let s=r(F),o=n(b.RParen);return t(()=>i.astFactory.expressionOperation(a.image,[s],i.astFactory.sourceLocation(a,o)))}}}function yt(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>a=>{let s=r(e);r(b.LParen);let o=n(F);r(b.comma);let l=i(F),c=r(b.RParen);return t(()=>a.astFactory.expressionOperation(s.image,[o,l],a.astFactory.sourceLocation(s,c)))}}}function an(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,CONSUME1:n,CONSUME2:i,SUBRULE1:a,SUBRULE2:s,SUBRULE3:o})=>l=>{let c=r(e);r(b.LParen);let u=a(F);n(b.comma);let p=s(F);i(b.comma);let f=o(F),h=r(b.RParen);return t(()=>l.astFactory.expressionOperation(c.image,[u,p,f],l.astFactory.sourceLocation(c,h)))}}}function Ic(e){return{name:ge(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let a=n(e);n(b.LParen);let s=r(ee),o=n(b.RParen);return t(()=>i.astFactory.expressionOperation(a.image,[s],i.astFactory.sourceLocation(a,o)))}}}function Lc(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,OR:n,SUBRULE:i})=>a=>{let s=r(e);return n([{ALT:()=>{r(b.LParen);let o=i(F),l=r(b.RParen);return t(()=>a.astFactory.expressionOperation(s.image,[o],a.astFactory.sourceLocation(s,l)))}},{ALT:()=>{let o=r(M.nil);return t(()=>a.astFactory.expressionOperation(s.image,[],a.astFactory.sourceLocation(s,o)))}}])}}}function sn(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r})=>n=>{let i=r(e),a=r(M.nil);return t(()=>n.astFactory.expressionOperation(i.image,[],n.astFactory.sourceLocation(i,a)))}}}function Ss(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let a=r(e),s=n(Cs);return t(()=>i.astFactory.expressionOperation(a.image,s.val,i.astFactory.sourceLocation(a,s)))}}}function ws(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:a,CONSUME1:s,OPTION:o,CONSUME2:l})=>c=>{let u=r(e);r(b.LParen);let p=n(F);s(b.comma);let f=i(F),h=o(()=>(l(b.comma),a(F))),g=r(b.RParen);return t(()=>c.astFactory.expressionOperation(u.image,h?[p,f,h]:[p,f],c.astFactory.sourceLocation(u,g)))}}}function Pc(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,SUBRULE3:a,SUBRULE4:s,CONSUME1:o,OPTION:l,CONSUME2:c,CONSUME3:u})=>p=>{let f=r(e);r(b.LParen);let h=n(F);o(b.comma);let g=i(F);c(b.comma);let T=a(F),x=l(()=>(u(b.comma),s(F))),v=r(b.RParen);return t(()=>p.astFactory.expressionOperation(f.image,x?[h,g,T,x]:[h,g,T],p.astFactory.sourceLocation(f,v)))}}}function ks(e){return{name:ge(e.name),impl:({ACTION:t,SUBRULE:r,CONSUME:n})=>i=>{let a=n(e),s=r(ne);return t(()=>i.astFactory.expressionPatternOperation(a.image,s,i.astFactory.sourceLocation(a,s)))}}}function Cr(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n,OPTION:i})=>a=>{let s=r(e);r(b.LParen);let o=i(()=>r(gt)),l=n(F),c=r(b.RParen);return t(()=>a.astFactory.aggregate(s.image,o!==void 0,l,void 0,a.astFactory.sourceLocation(s,c)))}}}var Eg=D(I.str),Ig=D(I.lang),Lg=yt(I.langmatches),Pg=D(I.datatype),_g=Ic(I.bound),Ng=D(I.iri),Og=D(I.uri),Sg=Lc(I.bnode),wg=sn(I.rand),kg=D(I.abs),Cg=D(I.ceil),Rg=D(I.floor),Fg=D(I.round),Mg=Ss(I.concat),Dg=D(I.strlen),jg=D(I.ucase),Gg=D(I.lcase),$g=D(I.encode_for_uri),Vg=yt(I.contains),Hg=yt(I.strstarts),Kg=yt(I.strends),qg=yt(I.strbefore),zg=yt(I.strafter),Wg=D(I.year),Yg=D(I.month),Qg=D(I.day),Xg=D(I.hours),Bg=D(I.minutes),Jg=D(I.seconds),Zg=D(I.timezone),Ug=D(I.tz),eT=sn(I.now),tT=sn(I.uuid),rT=sn(I.struuid),nT=D(I.md5),iT=D(I.sha1),aT=D(I.sha256),sT=D(I.sha384),oT=D(I.sha512),lT=Ss(I.coalesce),cT=an(I.if_),uT=yt(I.strlang),pT=yt(I.strdt),dT=yt(I.sameterm),fT=D(I.isiri),hT=D(I.isuri),mT=D(I.isblank),gT=D(I.isliteral),TT=D(I.isnumeric);function yT(e){return[{ALT:()=>e(Rs)},{ALT:()=>e(Eg)},{ALT:()=>e(Ig)},{ALT:()=>e(Lg)},{ALT:()=>e(Pg)},{ALT:()=>e(_g)},{ALT:()=>e(Ng)},{ALT:()=>e(Og)},{ALT:()=>e(Sg)},{ALT:()=>e(wg)},{ALT:()=>e(kg)},{ALT:()=>e(Cg)},{ALT:()=>e(Rg)},{ALT:()=>e(Fg)},{ALT:()=>e(Mg)},{ALT:()=>e(vT)},{ALT:()=>e(Dg)},{ALT:()=>e(xT)},{ALT:()=>e(jg)},{ALT:()=>e(Gg)},{ALT:()=>e($g)},{ALT:()=>e(Vg)},{ALT:()=>e(Hg)},{ALT:()=>e(Kg)},{ALT:()=>e(qg)},{ALT:()=>e(zg)},{ALT:()=>e(Wg)},{ALT:()=>e(Yg)},{ALT:()=>e(Qg)},{ALT:()=>e(Xg)},{ALT:()=>e(Bg)},{ALT:()=>e(Jg)},{ALT:()=>e(Zg)},{ALT:()=>e(Ug)},{ALT:()=>e(eT)},{ALT:()=>e(tT)},{ALT:()=>e(rT)},{ALT:()=>e(nT)},{ALT:()=>e(iT)},{ALT:()=>e(aT)},{ALT:()=>e(sT)},{ALT:()=>e(oT)},{ALT:()=>e(lT)},{ALT:()=>e(cT)},{ALT:()=>e(uT)},{ALT:()=>e(pT)},{ALT:()=>e(dT)},{ALT:()=>e(fT)},{ALT:()=>e(hT)},{ALT:()=>e(mT)},{ALT:()=>e(gT)},{ALT:()=>e(TT)},{ALT:()=>e(bT)},{ALT:()=>e(AT)},{ALT:()=>e(ET)}]}var qt={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(qt);if(n)return e(n);let i=yT(t);return r.set(qt,i),e(i)}},bT=ws(I.regex),vT=ws(I.substr),xT=Pc(I.replace),AT=ks(I.exists),ET=ks(I.notexists),IT={name:ge(I.count.name),impl:({ACTION:e,CONSUME:t,SUBRULE:r,OR:n,OPTION:i})=>a=>{let s=t(I.count);t(b.LParen);let o=i(()=>t(gt)),l=n([{ALT:()=>{let u=t(b.star);return e(()=>a.astFactory.wildcard(a.astFactory.sourceLocation(u)))}},{ALT:()=>r(F)}]),c=t(b.RParen);return e(()=>{let u=a.astFactory;return a.astFactory.isWildcard(l),u.aggregate(s.image,!!o,l,void 0,a.astFactory.sourceLocation(s,c))})}},LT=Cr(I.sum),PT=Cr(I.min),_T=Cr(I.max),NT=Cr(I.avg),OT=Cr(I.sample),ST={name:ge(I.groupConcat.name),impl:({ACTION:e,CONSUME:t,OPTION1:r,SUBRULE:n,OPTION2:i})=>a=>{let s=t(I.groupConcat);t(b.LParen);let o=r(()=>t(gt)),l=n(F),c=i(()=>(t(b.semi),t(Es),t(b.equal),n(_s))),u=t(b.RParen);return e(()=>{var f;let p=a.astFactory;return p.aggregate(s.image,!!o,l,(f=c==null?void 0:c.value)!=null?f:" ",p.sourceLocation(s,u))})}},Rs={name:"aggregate",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=e(()=>n.parseMode.has("inAggregate"));e(()=>n.parseMode.add("inAggregate"));let a=r([{ALT:()=>t(IT)},{ALT:()=>t(LT)},{ALT:()=>t(PT)},{ALT:()=>t(_T)},{ALT:()=>t(NT)},{ALT:()=>t(OT)},{ALT:()=>t(ST)}]);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.")}),a},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(F,i),n.isExpressionAggregateSeparator(r)&&n.printFilter(r,()=>t(";","SEPARATOR","=",di(r.separator))),n.printFilter(r,()=>t(")"))}};var Ms={name:"path",impl:({SUBRULE:e})=>()=>e(CT)},zt={name:"path",gImpl:({PRINT:e,SUBRULE:t})=>(r,{astFactory:n},i=!0)=>{if(n.isTerm(r)&&n.isTermNamed(r))t(K,r);else{switch(n.printFilter(r,()=>i&&e("(")),r.subType){case"|":case"/":{let[a,...s]=r.items;t(zt,a,i);for(let o of s)n.printFilter(r,()=>e(r.subType)),t(zt,o,i);break}case"^":n.printFilter(r,()=>e("^")),t(zt,r.items[0],i);break;case"?":case"*":case"+":t(zt,r.items[0],i),n.printFilter(r,()=>e(r.subType));break;case"!":n.printFilter(r,()=>e("!")),n.printFilter(r,()=>e("(")),t(zt,r.items[0],!1),n.printFilter(r,()=>e(")"));break}n.printFilter(r,()=>i&&e(")"))}}};function Nc(e,t,r,n){return{name:e,impl:({ACTION:i,CONSUME:a,SUBRULE1:s,SUBRULE2:o,MANY:l})=>c=>{let u=s(n),p=u,f=[];return l(()=>{a(t),p=o(n),f.push(p)}),i(()=>f.length===0?u:c.astFactory.path(r,[u,...f],c.astFactory.sourceLocation(u,p)))}}}var wT={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>a=>i([{ALT:()=>r(_c)},{ALT:()=>{let s=t(b.hat),o=n(_c);return e(()=>a.astFactory.path("^",[o],a.astFactory.sourceLocation(s,o)))}}])},kT=Nc("pathSequence",b.slash,"/",wT),CT=Nc("pathAlternative",b.pipe,"|",kT),_c={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(FT),a=r(()=>t(RT));return e(()=>a===void 0?i:n.astFactory.path(a.image,[i],n.astFactory.sourceLocation(i,a)))}},RT={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(b.question)},{ALT:()=>e(b.star)},{ALT:()=>e(b.opPlus)}])},FT={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(K)},{ALT:()=>e(kr)},{ALT:()=>e(MT)},{ALT:()=>{t(b.LParen);let n=e(Ms);return t(b.RParen),n}}])},MT={name:"pathNegatedPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,SUBRULE3:i,OR:a,MANY:s})=>o=>{let l=t(b.exclamation);return a([{ALT:()=>{let c=r(Fs);return e(()=>o.astFactory.path("!",[c],o.astFactory.sourceLocation(l,c)))}},{ALT:()=>{let c=t(b.LParen),u=n(Fs),p=[];s(()=>{t(b.pipe);let h=i(Fs);p.push(h)});let f=t(b.RParen);return e(()=>{let h=o.astFactory;return p.length===0?h.path("!",[u],h.sourceLocation(l,f)):h.path("!",[h.path("|",[u,...p],h.sourceLocation(c,f))],h.sourceLocation(l,f))})}}])}},Fs={name:"pathOneInPropertySet",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:a})=>s=>i([{ALT:()=>r(K)},{ALT:()=>r(kr)},{ALT:()=>{let o=t(b.hat),l=a([{ALT:()=>n(K)},{ALT:()=>n(kr)}]);return e(()=>s.astFactory.path("^",[l],s.astFactory.sourceLocation(o,l)))}}])};function DT(e){return({ACTION:t,AT_LEAST_ONE:r,SUBRULE:n,CONSUME:i,OPTION:a})=>s=>{let o=[],l=!0,c;return r({GATE:()=>l,DEF:()=>{l=!1;let u=n(e);t(()=>{o.push(...u)}),a(()=>{c=i(b.dot),l=!0})}}),t(()=>s.astFactory.patternBgp(o,s.astFactory.sourceLocation(...o,c)))}}var wt={name:"triplesBlock",impl:e=>t=>DT($T)(e)(t),gImpl:({SUBRULE:e,PRINT_WORD:t,HANDLE_LOC:r,NEW_LINE:n})=>(i,{astFactory:a})=>{for(let[s,o]of i.triples.entries())r(o,()=>{let l=i.triples.at(s+1);a.isTripleCollection(o)?(e(St,o),a.printFilter(o,()=>{t("."),n()})):(e(St,o.subject),a.printFilter(o,()=>t("")),a.isTerm(o.predicate)&&a.isTermVariable(o.predicate)?e(Se,o.predicate):e(zt,o.predicate,void 0),a.printFilter(o,()=>t("")),e(St,o.object),l===void 0||a.isTripleCollection(l)||!a.isSourceLocationNoMaterialize(l.subject.loc)?a.printFilter(i,()=>{t("."),n()}):a.isSourceLocationNoMaterialize(l.predicate.loc)?a.printFilter(i,()=>t(",")):a.printFilter(i,()=>{t(";"),n()}))})}};function jT(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>a=>i([{ALT:()=>{let s=n(Se),o=n(t?js:Ds,r(()=>a.astFactory.dematerialized(s)));return r(()=>(o[0].subject=s,o[0].loc=a.astFactory.sourceLocation(s,o[0]),o))}},{ALT:()=>{let s=n(t?kc:wc),o=n(t?KT:HT,r(()=>a.astFactory.graphNodeIdentifier(s)));return r(()=>o.length===0?[s]:(o[0].subject=s,o[0].loc=a.astFactory.sourceLocation(s,o[0]),o))}}])}}var GT=jT("triplesSameSubject",!1),$T=jT("triplesSameSubjectPath",!0),Rr={name:"triplesTemplate",impl:DT(GT)};function VT(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,a)=>{var s;return(s=n(()=>r(t?js:Ds,a)))!=null?s:[]}}}var HT=VT("propertyList",!1),KT=VT("propertyListPath",!0);function qT(e,t){return{name:e,impl:({ACTION:r,CONSUME:n,AT_LEAST_ONE:i,SUBRULE1:a,MANY2:s,OR1:o})=>(l,c)=>{let u=[],p=!0;return i({GATE:()=>p,DEF:()=>{p=!1;let f=t?o([{ALT:()=>a(zT)},{ALT:()=>a(WT)}]):a(vc),h=a(t?XT:QT,c,f);s(()=>{n(b.semi),p=!0}),r(()=>{u.push(...h)})}}),u}}}var Ds=qT("propertyListNotEmpty",!1),js=qT("propertyListPathNotEmpty",!0),zT={name:"verbPath",impl:({SUBRULE:e})=>()=>e(Ms)},WT={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(ee)};function YT(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,AT_LEAST_ONE_SEP:i})=>(a,s,o)=>{let l=[];return i({SEP:b.comma,DEF:()=>{let c=n(t?ZT:JT,s,o);r(()=>{l.push(c)})}}),l}}}var QT=YT("objectList",!1),XT=YT("objectListPath",!0);function BT(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,a,s)=>{let o=n(t?St:Cc);return r(()=>i.astFactory.triple(a,s,o))}}}var JT=BT("object",!1),ZT=BT("objectPath",!0);function UT(e,t){return{name:e,impl:({ACTION:r,AT_LEAST_ONE:n,SUBRULE:i,CONSUME:a})=>s=>{let o=[],l=a(b.LParen);n(()=>{o.push(i(t?St:Cc))});let c=a(b.RParen);return r(()=>{let u=s.astFactory,p=[],f=u.termNamed(u.sourceLocation(),se.FIRST,void 0),h=u.termNamed(u.sourceLocation(),se.REST,void 0),g=u.termNamed(u.sourceLocation(),se.NIL,void 0),T=u.termBlank(void 0,u.sourceLocation()),x=T;for(let[v,A]of o.entries()){let y=v===o.length-1,L=u.triple(x,f,A);if(p.push(L),y){let S=u.triple(x,h,g);p.push(S)}else{let S=u.termBlank(void 0,u.sourceLocation()),N=u.triple(x,h,S);p.push(N),x=S}}return u.tripleCollectionList(T,p,u.sourceLocation(l,c))})},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:a})=>{a.printFilter(i,()=>n("("));for(let[s,o]of i.triples.entries())s%2===0&&(a.printFilter(i,()=>n("")),r(St,o.object));a.printFilter(i,()=>n(")"))}}}var ey=UT("collection",!1),Oc=UT("collectionPath",!0);function ty(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?Oc:ey)},{ALT:()=>r(t?Sc:ny)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(Oc,n):r(Sc,n)}}var wc=ty("triplesNode",!1),kc=ty("triplesNodePath",!0);function ry(e,t){let r=t?js:Ds;return{name:e,impl:({ACTION:n,SUBRULE:i,CONSUME:a})=>s=>{let o=a(b.LSquare),l=n(()=>s.astFactory.termBlank(void 0,s.astFactory.sourceLocation())),c=i(r,l),u=a(b.RSquare);return n(()=>s.astFactory.tripleCollectionBlankNodeProperties(l,c,s.astFactory.sourceLocation(o,u)))},gImpl:({SUBRULE:n,PRINT:i,PRINT_WORD:a,HANDLE_LOC:s,PRINT_ON_EMPTY:o,NEW_LINE:l})=>(c,u)=>{let{astFactory:p,indentInc:f}=u;p.printFilter(c,()=>{u[ce]+=f,i("["),l()});for(let h of c.triples)s(h,()=>{p.isTerm(h.predicate)&&p.isTermVariable(h.predicate)?n(Se,h.predicate):n(zt,h.predicate,void 0),p.printFilter(h,()=>a("")),n(St,h.object),p.printFilter(c,()=>{a(";"),l()})});p.printFilter(c,()=>{u[ce]-=f,o("]")})}}}var ny=ry("blankNodePropertyList",!1),Sc=ry("blankNodePropertyListPath",!0);function iy(e,t){let r=t?kc:wc;return{name:e,impl:({SUBRULE:n,OR:i})=>a=>i([{ALT:()=>n(Se)},{GATE:()=>a.parseMode.has("canCreateBlankNodes"),ALT:()=>n(r)}]),gImpl:({SUBRULE:n})=>(i,{astFactory:a})=>{a.isTerm(i)?n(Se,i):n(r,i)}}}var Cc=iy("graphNode",!1),St=iy("graphNodePath",!0);var at={name:"whereClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OPTION:n})=>i=>{let a=n(()=>r(or)),s=t(ne);return e(()=>i.astFactory.wrap(s,i.astFactory.sourceLocation(a,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("WHERE")),e(ne,r.val)}},ne={name:"groupGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>{let a=r(b.LCurly),s=n([{ALT:()=>[t(Kc)]},{ALT:()=>t(sy)}]),o=r(b.RCurly);return e(()=>!i.skipValidation&&mc(s)),e(()=>i.astFactory.patternGroup(s,i.astFactory.sourceLocation(a,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,a)=>{let{astFactory:s,indentInc:o}=a;s.printFilter(i,()=>{a[ce]+=o,t("{"),r()});for(let l of i.patterns)e(ay,l);s.printFilter(i,()=>{a[ce]-=o,n("}")})}},ay={name:"generatePattern",gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{t.type==="query"?e(un,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(ne,t):t.subType==="bgp"?e(wt,t):e(Vc,t)}},sy={name:"groupGraphPatternSub",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:a,OPTION1:s,OPTION2:o,OPTION3:l})=>c=>{let u=[],p=s(()=>i(wt));return p&&u.push(p),n(()=>{let f=t(Vc);u.push(f),o(()=>r(b.dot));let h=l(()=>a(wt));h&&u.push(h)}),e(()=>!c.skipValidation&&hc(u)),u}},Vc={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(Gc)},{ALT:()=>e(Rc)},{ALT:()=>e(jc)},{ALT:()=>e(Fc)},{ALT:()=>e(Mc)},{ALT:()=>e($c)},{ALT:()=>e(Dc)},{ALT:()=>e(on)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e(Gc,t);break;case"optional":e(Rc,t);break;case"minus":e(jc,t);break;case"graph":e(Fc,t);break;case"service":e(Mc,t);break;case"filter":e($c,t);break;case"bind":e(Dc,t);break;case"values":e(on,t);break}}},Rc={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ds),a=t(ne);return e(()=>n.astFactory.patternOptional(a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("OPTIONAL")),e(ne,n.patternGroup(r.patterns,r.loc))}},Fc={name:"graphGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ke.graph),a=t(Kt),s=t(ne);return e(()=>n.astFactory.patternGraph(a,s.patterns,n.astFactory.sourceLocation(i,s)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(Se,r.name),e(ne,n.patternGroup(r.patterns,r.loc))}},Mc={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{var c;let a=r(fs),s=(c=n(()=>(r(Vt),!0)))!=null?c:!1,o=t(Kt),l=t(ne);return e(()=>i.astFactory.patternService(o,l.patterns,s,i.astFactory.sourceLocation(a,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("SERVICE"),r.silent&&t("SILENT")}),e(Se,r.name),e(ne,n.patternGroup(r.patterns,r.loc))}},Dc={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(hs);r(b.LParen);let a=t(F);r(sr);let s=t(ee),o=r(b.RParen);return e(()=>n.astFactory.patternBind(a,s,n.astFactory.sourceLocation(i,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("BIND","(")),e(F,n.expression),i.printFilter(n,()=>t("AS")),e(ee,n.variable),i.printFilter(n,()=>{t(")"),r()})}},on={name:"inlineData",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Xa),a=t(oy);return e(()=>(a.loc=n.astFactory.sourceLocation(i,a),a))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,NEW_LINE:n,PRINT_ON_OWN_LINE:i})=>(a,s)=>{let{astFactory:o,indentInc:l}=s,c=a.variables,u=c.length===1;o.printFilter(a,()=>{r("VALUES",u?"":"( ")});for(let p of c)o.printFilter(a,()=>t("")),e(Se,p),o.printFilter(a,()=>t(""));o.printFilter(a,()=>{s[ce]+=l,t(u?"":")","{"),n()});for(let p of a.values){o.printFilter(a,()=>!u&&t("("));for(let f of c){let h=f.value;p[h]===void 0?o.printFilter(a,()=>t("UNDEF")):(e(St,p[h]),o.printFilter(a,()=>t("")))}o.printFilter(a,()=>{t(u?"":")"),n()})}o.printFilter(a,()=>{s[ce]-=l,i("}")})}},oy={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(ly)},{ALT:()=>e(cy)}])},ly={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let a=[],s=t(ee);r(b.LCurly),n(()=>{let l=t(Hc);e(()=>{a.push(Object.assign(Object.create(null),{[s.value]:l}))})});let o=r(b.RCurly);return e(()=>i.astFactory.patternValues([s],a,i.astFactory.sourceLocation(s,o)))}},cy={name:"inlineDataFull",impl:({ACTION:e,OR:t,MANY1:r,MANY2:n,MANY3:i,MANY4:a,SUBRULE:s,CONSUME1:o,CONSUME2:l})=>c=>{let u=[],p=[];return t([{ALT:()=>{let f=o(M.nil);o(b.LCurly),r(()=>{l(M.nil),u.push(Object.create(null))});let h=o(b.RCurly);return e(()=>c.astFactory.patternValues(p,u,c.astFactory.sourceLocation(f,h)))}},{ALT:()=>{let f=o(b.LParen);n(()=>{p.push(s(ee))}),o(b.RParen),l(b.LCurly),i(()=>{let g=0,T=Object.create(null);l(b.LParen),a(()=>{e(()=>{if(!c.skipValidation&&g>=p.length)throw new Error("Number of dataBlockValues does not match number of variables. Too much values.")});let x=s(Hc);e(()=>{T[p[g].value]=x,g++})}),l(b.RParen),e(()=>{if(u.push(T),!c.skipValidation&&p.length!==g)throw new Error("Number of dataBlockValues does not match number of variables. Too few values.")})});let h=l(b.RCurly);return e(()=>c.astFactory.patternValues(p,u,c.astFactory.sourceLocation(f,h)))}}])}},Hc={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(K)},{ALT:()=>e(pr)},{ALT:()=>e(Sr)},{ALT:()=>e(wr)},{ALT:()=>{t(ms)}}])},jc={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(gs),a=t(ne);return e(()=>n.astFactory.patternMinus(a.patterns,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("MINUS")),e(ne,n.patternGroup(r.patterns,r.loc))}},Gc={name:"groupOrUnionGraphPattern",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>a=>{let s=[],o=r(ne);return s.push(o),t(()=>{i(Ts);let l=n(ne);s.push(l)}),e(()=>s.length===1?s[0]:a.astFactory.patternUnion(s,a.astFactory.sourceLocation(o,s.at(-1))))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isPatternUnion(r)){let[i,...a]=r.patterns;e(ne,i);for(let s of a)n.printFilter(r,()=>t("UNION")),e(ne,s)}else e(ne,r)}},$c={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ys),a=t(fi);return e(()=>n.astFactory.patternFilter(a,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>t("FILTER (")),e(F,n.expression),i.printFilter(n,()=>{t(")"),r()})}},fi={name:"constraint",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(cn)},{ALT:()=>e(qt)},{ALT:()=>e(Gs)}])},Gs={name:"functionCall",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(K),i=t(ln);return e(()=>r.astFactory.expressionFunctionCall(n,i.val.args,i.val.distinct,r.astFactory.sourceLocation(n,i)))}};var ln={name:"argList",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,OPTION:n,OR:i,AT_LEAST_ONE_SEP:a})=>s=>i([{ALT:()=>{let o=t(M.nil);return e(()=>s.astFactory.wrap({args:[],distinct:!1},s.astFactory.sourceLocation(o)))}},{ALT:()=>{var p;let o=[],l=t(b.LParen),c=(p=n(()=>(t(gt),!0)))!=null?p:!1;a({SEP:b.comma,DEF:()=>{let f=r(F);o.push(f)}});let u=t(b.RParen);return e(()=>s.astFactory.wrap({args:o,distinct:c},s.astFactory.sourceLocation(l,u)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{t("("),r.val.distinct&&t("DISTINCT")});let[i,...a]=r.val.args;i&&e(F,i);for(let s of a)n.printFilter(r,()=>t(",")),e(F,s);n.printFilter(r,()=>t(")"))}},Cs={name:"expressionList",impl:({ACTION:e,CONSUME:t,MANY:r,OR:n,SUBRULE1:i,SUBRULE2:a})=>s=>n([{ALT:()=>{let o=t(M.nil);return e(()=>s.astFactory.wrap([],s.astFactory.sourceLocation(o)))}},{ALT:()=>{let o=t(b.LParen),c=[i(F)];r(()=>{t(b.comma);let p=a(F);c.push(p)});let u=t(b.RParen);return e(()=>s.astFactory.wrap(c,s.astFactory.sourceLocation(o,u)))}}])},Lk=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),Pk=new Set(["in","notin","||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),uy={"!":"",uplus:"+",uminus:"-"},F={name:"expression",impl:({SUBRULE:e})=>()=>e(py),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{if(n.isTerm(r))e(Se,r);else if(n.isExpressionPatternOperation(r)){let i=r.args;n.printFilter(r,()=>t(r.operator==="exists"?"EXISTS":"NOT EXISTS")),e(ne,i)}else if(n.isExpressionFunctionCall(r))e(Xc,r);else if(n.isExpressionAggregate(r))e(Rs,r);else if(Pk.has(r.operator)){let[i,...a]=r.args;n.printFilter(r,()=>t("(")),e(F,i),n.printFilter(r,()=>{r.operator==="notin"?t("NOT IN"):r.operator==="in"?t("IN"):t(r.operator.toUpperCase())}),a.length===1&&Lk.has(r.operator)?e(F,a[0]):e(ln,n.wrap({args:a,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(typeof uy[r.operator]=="string"){let[i]=r.args;n.printFilter(r,()=>t(uy[r.operator]||r.operator.toUpperCase())),e(F,i)}else{n.printFilter(r,()=>t(r.operator.toUpperCase(),"("));let[i,...a]=r.args;i&&e(F,i);for(let s of a)n.printFilter(r,()=>t(",")),e(F,s);n.printFilter(r,()=>t(")"))}}};function hi(e,t,r,n){let i=e();return n(()=>{let a=t();r(()=>{i=a(i)})}),i}var py={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>a=>hi(()=>n(qc),()=>{r(b.logicOr);let s=i(qc);return o=>e(()=>a.astFactory.expressionOperation("||",[o,s],a.astFactory.sourceLocation(o,s)))},e,t)},qc={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>a=>hi(()=>r(zc),()=>{i(b.logicAnd);let s=n(zc);return o=>e(()=>a.astFactory.expressionOperation("&&",[o,s],a.astFactory.sourceLocation(o,s)))},e,t)},zc={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(dy)},dy={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:a,OR2:s,OR3:o})=>l=>{let c=r(Wc),u=i(()=>a([{ALT:()=>{let p=s([{ALT:()=>t(b.equal)},{ALT:()=>t(b.notEqual)},{ALT:()=>t(b.lessThan)},{ALT:()=>t(b.greaterThan)},{ALT:()=>t(b.lessThanEqual)},{ALT:()=>t(b.greaterThanEqual)}]),f=n(Wc);return e(()=>l.astFactory.expressionOperation(p.image,[c,f],l.astFactory.sourceLocation(c,f)))}},{ALT:()=>{let p=o([{ALT:()=>t(xs)},{ALT:()=>t(As)}]),f=r(Cs);return e(()=>l.astFactory.expressionOperation(p.image,[c,...f.val],l.astFactory.sourceLocation(c,f)))}}]));return u!=null?u:c}},Wc={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(fy)},fy={name:"additiveExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,MANY1:a,MANY2:s,OR1:o,OR2:l,OR3:c,OR4:u})=>p=>hi(()=>n(Yc),()=>o([{ALT:()=>{let f=l([{ALT:()=>r(b.opPlus)},{ALT:()=>r(b.opMinus)}]),h=i(Yc);return e(()=>g=>p.astFactory.expressionOperation(f.image,[g,h],p.astFactory.sourceLocation(g,h)))}},{ALT:()=>{let{operator:f,startInt:h}=c([{ALT:()=>{let T=t(Ls);return e(()=>(T.value=T.value.replace(/^\+/u,""),{operator:"+",startInt:T}))}},{ALT:()=>{let T=t(Ps);return e(()=>(T.value=T.value.replace(/^-/u,""),{operator:"-",startInt:T}))}}]),g=hi(()=>e(()=>h),()=>{let T=u([{ALT:()=>r(b.star)},{ALT:()=>r(b.slash)}]),x=n($s);return v=>e(()=>p.astFactory.expressionOperation(T.image,[v,x],p.astFactory.sourceLocation(v,x)))},e,s);return T=>p.astFactory.expressionOperation(f,[T,g],p.astFactory.sourceLocation(T,g))}}]),e,a)},Yc={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:a})=>s=>hi(()=>n($s),()=>{let o=a([{ALT:()=>t(b.star)},{ALT:()=>t(b.slash)}]),l=i($s);return c=>({type:"expression",subType:"operation",operator:o.image,args:[c,l],loc:s.astFactory.sourceLocation(c,l)})},e,r)},$s={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:a})=>s=>i([{ALT:()=>r(Qc)},{ALT:()=>{let o=a([{ALT:()=>t(b.exclamation)},{ALT:()=>t(b.opPlus)},{ALT:()=>t(b.opMinus)}]),l=n(Qc);return e(()=>s.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[l],s.astFactory.sourceLocation(o,l)))}}])},Qc={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(cn)},{ALT:()=>e(qt)},{ALT:()=>e(Xc)},{ALT:()=>e(pr)},{ALT:()=>e(Sr)},{ALT:()=>e(wr)},{ALT:()=>e(ee)}])},cn={name:"brackettedExpression",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(b.LParen),a=t(F),s=r(b.RParen);return e(()=>(a.loc=n.astFactory.sourceLocation(i,s),a))}},Xc={name:"iriOrFunction",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(K),a=r(()=>{let s=t(ln);return e(()=>{let o=s.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:s.val.args,distinct:o,loc:n.astFactory.sourceLocation(i,s)}})});return a!=null?a:i},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isTermNamed(t)?e(K,t):(e(K,t.function),e(ln,r.wrap({args:t.args,distinct:t.distinct},t.loc)))}};var st={name:"solutionModifier",impl:({ACTION:e,SUBRULE:t,OPTION1:r,OPTION2:n,OPTION3:i,OPTION4:a})=>()=>{let s=r(()=>t(Bc)),o=n(()=>t(Jc)),l=i(()=>t(Zc)),c=a(()=>t(Uc));return e(()=>({...c&&{limitOffset:c},...s&&{group:s},...o&&{having:o},...l&&{order:l}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(Bc,t.group),t.having&&e(Jc,t.having),t.order&&e(Zc,t.order),t.limitOffset&&e(Uc,t.limitOffset)}},Bc={name:"groupClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let a=[],s=n(si);return n(oi),t(()=>{a.push(r(hy))}),e(()=>({type:"solutionModifier",subType:"group",groupings:a,loc:i.astFactory.sourceLocation(s,a.at(-1))}))},gImpl:({PRINT_WORDS:e,SUBRULE:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("GROUP BY ")});for(let a of n.groupings)i.printFilter(n,()=>e("")),i.isExpression(a)?t(F,a):(i.printFilter(n,()=>e("(")),t(F,a.value),i.printFilter(n,()=>e("AS")),t(ee,a.variable),i.printFilter(n,()=>e(")")))}},hy={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:a,OR:s})=>o=>s([{ALT:()=>t(qt)},{ALT:()=>t(Gs)},{ALT:()=>i(ee)},{ALT:()=>{let l=r(b.LParen),c=t(F),u=a(()=>(r(sr),n(ee))),p=r(b.RParen);return e(()=>u!==void 0?{variable:u,value:c,loc:o.astFactory.sourceLocation(l,p)}:c)}}])},Jc={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let a=n(Ka),s=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{s.push(r(my))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierHaving(s,i.astFactory.sourceLocation(a,s.at(-1))))},gImpl:({PRINT_ON_EMPTY:e,SUBRULE:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>{e("HAVING ")});for(let i of r.having)t(F,i)}},my={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(fi)},Zc={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let a=n(qa);n(oi);let s=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{s.push(r(gy))}),e(()=>!o&&i.parseMode.delete("canParseAggregate")),e(()=>i.astFactory.solutionModifierOrder(s,i.astFactory.sourceLocation(a,s.at(-1))))},gImpl:({PRINT_WORDS:e,PRINT_ON_EMPTY:t,SUBRULE:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{t("ORDER BY ")});for(let a of n.orderDefs)a.descending?i.printFilter(n,()=>e("DESC")):i.printFilter(n,()=>e("ASC")),i.printFilter(n,()=>e("(")),r(F,a.expression),i.printFilter(n,()=>e(")"))}},gy={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>a=>n([{ALT:()=>{let s=i([{ALT:()=>[!1,r(za)]},{ALT:()=>[!0,r(Wa)]}]),o=t(cn);return e(()=>({expression:o,descending:s[0],loc:a.astFactory.sourceLocation(s[1],o)}))}},{ALT:()=>{let s=t(fi);return e(()=>({expression:s,descending:!1,loc:s.loc}))}},{ALT:()=>{let s=t(ee);return e(()=>({expression:s,descending:!1,loc:s.loc}))}}])},Uc={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:a})=>s=>a([{ALT:()=>{let o=t(eu),l=n(()=>t(tu));return e(()=>s.astFactory.solutionModifierLimitOffset(o.val,l==null?void 0:l.val,s.astFactory.sourceLocation(o,...l?[l]:[])))}},{ALT:()=>{let o=r(tu),l=i(()=>r(eu));return e(()=>s.astFactory.solutionModifierLimitOffset(l==null?void 0:l.val,o.val,s.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))})}},eu={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Ya),i=t(M.integer),a=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(a,r.astFactory.sourceLocation(n,i)))}},tu={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(Qa),i=e(M.integer),a=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(a,r.astFactory.sourceLocation(n,i)))}};var _k={name:"queryUnit",impl:({SUBRULE:e})=>()=>e(un)},un={name:"query",impl:({ACTION:e,SUBRULE:t,OR:r})=>n=>{let i=t(it),a=r([{ALT:()=>t(mi)},{ALT:()=>t(gi)},{ALT:()=>t(Ti)},{ALT:()=>t(yi)}]),s=t(bi);return e(()=>{let o={context:i,...a,type:"query",loc:n.astFactory.sourceLocation(i.at(0),a,s)};return s&&(o.values=s),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(it,t.context),r.isQuerySelect(t)?e(mi,t):r.isQueryConstruct(t)?e(gi,t):r.isQueryDescribe(t)?e(Ti,t):e(yi,t),t.values&&e(on,t.values)}},mi={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Vs),i=t(Tt),a=t(at),s=t(st);return e(()=>{let o={subType:"select",where:a.val,solutionModifiers:s,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,a,s.group,s.having,s.order,s.limitOffset)};return r.skipValidation||fc(o),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Vs,r.wrap({variables:t.variables,distinct:t.distinct,reduced:t.reduced},r.sourceLocation(...t.variables))),e(Tt,t.datasets),e(at,r.wrap(t.where,t.where.loc)),e(st,t.solutionModifiers)}},Kc={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Vs),i=t(at),a=t(st),s=t(bi);return e(()=>r.astFactory.querySelect({where:i.val,datasets:r.astFactory.datasetClauses([],r.astFactory.sourceLocation()),context:[],solutionModifiers:a,...n.val,...s&&{values:s}},r.astFactory.sourceLocation(n,i,a.group,a.having,a.order,a.limitOffset,s)))}},Vs={name:"selectClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION:a,OR1:s,OR2:o,OR3:l})=>c=>{var x;let u=i(Da),p=e(()=>c.parseMode.has("canParseAggregate")||!c.parseMode.add("canParseAggregate")),f=(x=a(()=>s([{ALT:()=>(i(gt),[!0,!1])},{ALT:()=>(i(ja),[!1,!0])}])))!=null?x:[!1,!1],h=e(()=>{let[v,A]=f;return{...v&&{distinct:v},...A&&{reduced:A}}}),g,T=o([{ALT:()=>{let v=i(b.star);return e(()=>(g=v,{variables:[c.astFactory.wildcard(c.astFactory.sourceLocation(v))],...h}))}},{ALT:()=>{let v=[],A=[];return t(()=>l([{ALT:()=>{let y=r(ee);e(()=>{if(!c.skipValidation&&v.some(L=>L.value===y.value))throw new Error(`Variable ${y.value} used more than once in SELECT clause`);v.push(y),A.push(y),g=y})}},{ALT:()=>{let y=i(b.LParen),L=r(F);i(sr);let S=n(ee),N=i(b.RParen);e(()=>{if(g=N,!c.skipValidation&&v.some(X=>X.value===S.value))throw new Error(`Variable ${S.value} used more than once in SELECT clause`);v.push(S),A.push(c.astFactory.patternBind(L,S,c.astFactory.sourceLocation(y,g)))})}}])),{variables:A,...h}}}]);return e(()=>!p&&c.parseMode.delete("canParseAggregate")),e(()=>c.astFactory.wrap(T,c.astFactory.sourceLocation(u,g)))},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 a of n.val.variables)i.isWildcard(a)?i.printFilter(n,()=>t("*")):i.isTerm(a)?e(ee,a):(i.printFilter(n,()=>t("(")),e(F,a.expression),i.printFilter(n,()=>t("AS")),e(ee,a.variable),i.printFilter(n,()=>t(")"))),i.printFilter(n,()=>t(""));i.printFilter(n,()=>t(""))}},gi={name:"constructQuery",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,CONSUME:n,OR:i})=>a=>{let s=n(Ga);return i([{ALT:()=>{let o=t(ru),l=t(Tt),c=t(at),u=t(st);return e(()=>({subType:"construct",template:o.val,datasets:l,where:c.val,solutionModifiers:u,loc:a.astFactory.sourceLocation(s,c,u.group,u.having,u.order,u.limitOffset)}))}},{ALT:()=>{let o=r(Tt);n(or);let l=r(ru),c=r(st);return e(()=>({subType:"construct",template:l.val,datasets:o,where:a.astFactory.patternGroup([l.val],a.astFactory.sourceLocation()),solutionModifiers:c,loc:a.astFactory.sourceLocation(s,l,c.group,c.having,c.order,c.limitOffset)}))}}])},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r,PRINT_ON_OWN_LINE:n,NEW_LINE:i})=>(a,s)=>{let{astFactory:o,indentInc:l}=s;o.printFilter(a,()=>r("CONSTRUCT ")),o.isSourceLocationNoMaterialize(a.where.loc)||(o.printFilter(a,()=>{s[ce]+=l,t("{"),i()}),e(wt,a.template),o.printFilter(a,()=>{s[ce]-=l,n("}")})),e(Tt,a.datasets),o.isSourceLocationNoMaterialize(a.where.loc)?e(at,o.wrap(o.patternGroup([a.template],a.template.loc),a.template.loc)):e(at,o.wrap(a.where,a.where.loc)),e(st,a.solutionModifiers)}},Ti={name:"describeQuery",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n,OPTION:i,OR:a})=>s=>{let o=n($a),l=a([{ALT:()=>{let f=[];return t(()=>{f.push(r(Kt))}),f}},{ALT:()=>{let f=n(b.star);return[e(()=>s.astFactory.wildcard(s.astFactory.sourceLocation(f)))]}}]),c=r(Tt),u=i(()=>r(at)),p=r(st);return e(()=>({subType:"describe",variables:l,datasets:c,...u&&{where:u.val},solutionModifiers:p,loc:s.astFactory.sourceLocation(o,...l,c,u,p.group,p.having,p.order,p.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 a of n.variables)i.printFilter(n,()=>t("")),e(Se,a);e(Tt,n.datasets),n.where&&e(at,i.wrap(n.where,n.loc)),e(st,n.solutionModifiers)}},yi={name:"askQuery",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Va),a=t(Tt),s=t(at),o=t(st);return e(()=>({subType:"ask",datasets:a,where:s.val,solutionModifiers:o,loc:n.astFactory.sourceLocation(i,a,s,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(at,n.wrap(r.where,r.loc)),e(st,r.solutionModifiers)}},bi={name:"valuesClause",impl:({OPTION:e,SUBRULE:t})=>()=>e(()=>t(on))},ru={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let a=r(b.LCurly),s=n(()=>t(Ty)),o=r(b.RCurly);return e(()=>i.astFactory.wrap(s!=null?s:i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(a,o)))}},Ty={name:"constructTriples",impl:Rr.impl};var Nk={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(Hs)},Hs={name:"update",impl:({ACTION:e,SUBRULE:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i,OPTION1:a,MANY:s})=>o=>{let l=[],c=r(it);l.push({context:c});let u=!0;return s({GATE:()=>u,DEF:()=>{u=!1,l.at(-1).operation=t(pn),a(()=>{i(b.semi),u=!0;let p=n(it);l.push({context:p})})}}),e(()=>{let p={type:"update",updates:l,loc:o.astFactory.sourceLocation(...l.flatMap(f=>[...f.context,f.operation]))};return o.skipValidation||ui(p),p})},gImpl:({SUBRULE:e,PRINT:t,NEW_LINE:r})=>(n,{astFactory:i})=>{let[a,...s]=n.updates;a&&(e(it,a.context),a.operation&&e(pn,a.operation));for(let o of s)i.printFilter(n,()=>{t(";"),r()}),e(it,o.context),o.operation&&e(pn,o.operation)}},pn={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(nu)},{ALT:()=>e(iu)},{ALT:()=>e(au)},{ALT:()=>e(ou)},{ALT:()=>e(lu)},{ALT:()=>e(cu)},{ALT:()=>e(su)},{ALT:()=>e(uu)},{ALT:()=>e(pu)},{ALT:()=>e(du)},{ALT:()=>e(fu)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(nu,t);break;case"clear":e(iu,t);break;case"drop":e(au,t);break;case"add":e(ou,t);break;case"move":e(lu,t);break;case"copy":e(cu,t);break;case"create":e(su,t);break;case"insertdata":e(uu,t);break;case"deletedata":e(pu,t);break;case"deletewhere":e(du,t);break;case"modify":e(fu,t);break}}},nu={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>a=>{let s=r(Ba),o=n(()=>r(Vt)),l=t(K),c=i(()=>(r(Ja),t(vi)));return e(()=>a.astFactory.updateOperationLoad(a.astFactory.sourceLocation(s,l,c),l,!!o,c))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("LOAD "),n.silent&&t("SILENT")}),e(K,n.source),n.destination&&(i.printFilter(n,()=>t("INTO")),e(Fr,n.destination))}};function yy(e){return{name:ge(e.name),impl:({ACTION:t,SUBRULE1:r,CONSUME:n,OPTION:i})=>a=>{let s=n(e),o=i(()=>n(Vt)),l=r(Fr);return t(()=>a.astFactory.updateOperationClearDrop(ge(e.name),!!o,l,a.astFactory.sourceLocation(s,l)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:a})=>{a.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Fr,i.destination)}}}var iu=yy(Za),au=yy(Ua),su={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let a=r(es),s=n(()=>r(Vt)),o=t(vi);return e(()=>i.astFactory.updateOperationCreate(o,!!s,i.astFactory.sourceLocation(a,o)))},gImpl:({SUBRULE:e,PRINT_WORD:t,PRINT_ON_EMPTY:r})=>(n,{astFactory:i})=>{i.printFilter(n,()=>{r("CREATE "),n.silent&&t("SILENT")}),e(Fr,n.destination)}};function Tu(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:a})=>s=>{let o=r(e),l=a(()=>r(Vt)),c=n(mu);r(rs);let u=i(mu);return t(()=>s.astFactory.updateOperationAddMoveCopy(ge(e.name),c,u,!!l,s.astFactory.sourceLocation(o,u)))},gImpl:({SUBRULE:t,PRINT_WORD:r,PRINT_ON_EMPTY:n})=>(i,{astFactory:a})=>{a.printFilter(i,()=>{n(e.name.toUpperCase()," "),i.silent&&r("SILENT")}),t(Fr,i.source),a.printFilter(i,()=>r("TO")),t(Fr,i.destination)}}}var ou=Tu(ts),lu=Tu(ns),cu=Tu(is),Ks={name:"quadPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(b.LCurly),a=t(dn),s=r(b.RCurly);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,s)))}},yu={name:"quadData",impl:({ACTION:e,SUBRULE1:t,CONSUME:r})=>n=>{let i=r(b.LCurly),a=e(()=>n.parseMode.delete("canParseVars")),s=t(dn);e(()=>a&&n.parseMode.add("canParseVars"));let o=r(b.RCurly);return e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,o)))}};function bu(e,t,r,n){return{name:e,impl:({ACTION:i,SUBRULE1:a,CONSUME:s})=>o=>{let l=s(r),c=!0;e!=="insertData"&&(c=i(()=>o.parseMode.delete("canCreateBlankNodes")));let u=a(n);return e!=="insertData"&&i(()=>c&&o.parseMode.add("canCreateBlankNodes")),i(()=>o.astFactory.updateOperationInsDelDataWhere(t,u.val,o.astFactory.sourceLocation(l,u)))},gImpl:({SUBRULE:i,PRINT_WORD:a,PRINT_ON_EMPTY:s,PRINT_ON_OWN_LINE:o,NEW_LINE:l})=>(c,u)=>{let{astFactory:p,indentInc:f}=u;p.printFilter(c,()=>{s(t==="insertdata"?"INSERT DATA ":t==="deletedata"?"DELETE DATA ":"DELETE WHERE "),u[ce]+=f,a("{"),l()}),i(dn,p.wrap(c.data,c.loc)),p.printFilter(c,()=>{u[ce]-=f,o("}")})}}}var uu=bu("insertData","insertdata",cs,yu),pu=bu("deleteData","deletedata",ss,yu),du=bu("deleteWhere","deletewhere",os,Ks),fu={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:a,OR:s})=>o=>{let l=i(()=>{let h=t(as),g=r(K);return{withToken:h,graph:g}}),{insert:c,del:u}=s([{ALT:()=>{let h=r(by),g=a(()=>r(hu));return{del:h,insert:g}}},{ALT:()=>({insert:n(hu),del:void 0})}]),p=r(Os);t(or);let f=r(ne);return e(()=>{var h,g;return o.astFactory.updateOperationModify(o.astFactory.sourceLocation(l==null?void 0:l.withToken,u,c,f),(h=c==null?void 0:c.val)!=null?h:[],(g=u==null?void 0:u.val)!=null?g:[],f,p,l==null?void 0:l.graph)})},gImpl:({SUBRULE:e,PRINT_WORDS:t,PRINT_ON_EMPTY:r,NEW_LINE:n})=>(i,a)=>{let{astFactory:s,indentInc:o}=a;i.graph&&(s.printFilter(i,()=>t("WITH")),e(K,i.graph)),i.delete.length>0&&(s.printFilter(i,()=>{a[ce]+=o,t("DELETE","{"),n()}),e(dn,s.wrap(i.delete,i.loc)),s.printFilter(i,()=>{a[ce]-=o,r("}"),n()})),i.insert.length>0&&(s.printFilter(i,()=>{a[ce]+=o,t("INSERT","{"),n()}),e(dn,s.wrap(i.insert,i.loc)),s.printFilter(i,()=>{a[ce]-=o,r("} "),n()})),e(Os,i.from),s.printFilter(i,()=>t("WHERE")),e(ne,i.where)}},by={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ls),a=e(()=>n.parseMode.delete("canCreateBlankNodes")),s=t(Ks);return e(()=>a&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},hu={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(us),a=t(Ks);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},mu={name:"graphOrDefault",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>a=>i([{ALT:()=>{let s=r(ke.default_);return e(()=>a.astFactory.graphRefDefault(a.astFactory.sourceLocation(s)))}},{ALT:()=>{let s=n(()=>r(ke.graph)),o=t(K);return e(()=>a.astFactory.graphRefSpecific(o,a.astFactory.sourceLocation(s,o)))}}])},vi={name:"graphRef",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ke.graph),a=t(K);return e(()=>n.astFactory.graphRefSpecific(a,n.astFactory.sourceLocation(i,a)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("GRAPH")),e(K,r.graph)}},Fr={name:"graphRefAll",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR:n})=>i=>n([{ALT:()=>t(vi)},{ALT:()=>{let a=r(ke.default_);return e(()=>i.astFactory.graphRefDefault(i.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=r(ke.named);return e(()=>i.astFactory.graphRefNamed(i.astFactory.sourceLocation(a)))}},{ALT:()=>{let a=r(ke.graphAll);return e(()=>i.astFactory.graphRefAll(i.astFactory.sourceLocation(a)))}}]),gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.isGraphRefSpecific(r)?e(vi,r):n.isGraphRefDefault(r)?n.printFilter(r,()=>t("DEFAULT")):n.isGraphRefNamed(r)?n.printFilter(r,()=>t("NAMED")):n.printFilter(r,()=>t("ALL"))}},dn={name:"quads",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n,SUBRULE1:i,SUBRULE2:a,OPTION1:s,OPTION2:o,OPTION3:l})=>c=>{let u=[],p;return s(()=>{let f=i(Rr);p=f,e(()=>u.push(f))}),n(()=>{let f=t(gu);p=f,u.push(f),o(()=>{let h=r(b.dot);return p=h,h}),l(()=>{let h=a(Rr);p=h,e(()=>u.push(h))})}),e(()=>c.astFactory.wrap(u,c.astFactory.sourceLocation(u.at(0),p)))},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t.val)r.isPattern(n)?e(wt,n):e(gu,n)}},gu={name:"quadsNotTriples",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let a=r(ke.graph),s=t(Kt);r(b.LCurly);let o=n(()=>t(Rr)),l=r(b.RCurly);return e(()=>i.astFactory.graphQuads(s,o!=null?o:i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(a,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,PRINT_ON_OWN_LINE:n})=>(i,a)=>{let{astFactory:s,indentInc:o}=a;s.printFilter(i,()=>t("GRAPH")),e(Se,i.graph),s.printFilter(i,()=>{a[ce]+=o,t("{"),r()}),e(wt,i.triples),s.printFilter(i,()=>{a[ce]-=o,n("}")})}};var Ok={name:"queryOrUpdate",impl:({ACTION:e,SUBRULE:t,OR1:r,OR2:n,MANY:i,OPTION1:a,CONSUME:s,SUBRULE2:o})=>l=>{let c=t(it);return r([{ALT:()=>{let u=n([{ALT:()=>t(mi)},{ALT:()=>t(gi)},{ALT:()=>t(Ti)},{ALT:()=>t(yi)}]),p=t(bi);return e(()=>({context:c,...u,type:"query",...p&&{values:p},loc:l.astFactory.sourceLocation(c.at(0),u,p)}))}},{ALT:()=>{let u=[];u.push({context:c});let p=!0;return i({GATE:()=>p,DEF:()=>{p=!1,u.at(-1).operation=t(pn),a(()=>{s(b.semi),p=!0;let f=o(it);u.push({context:f})})}}),e(()=>{let f={type:"update",updates:u,loc:l.astFactory.sourceLocation(...u.flatMap(h=>[...h.context,h.operation]))};return l.skipValidation||ui(f),f})}}])},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{r.isQuery(t)?e(un,t):e(Hs,t)}};var Sk=[d.expression,d.conditionalOrExpression,d.conditionalAndExpression,d.valueLogical,d.relationalExpression,d.numericExpression,d.expressionList,d.additiveExpression,d.multiplicativeExpression,d.unaryExpression,d.primaryExpression,d.brackettedExpression,d.iriOrFunction,d.rdfLiteral,d.numericLiteral,d.numericLiteralUnsigned,d.numericLiteralPositive,d.numericLiteralNegative,d.booleanLiteral,d.var_,d.builtInStr,d.builtInLang,d.builtInLangmatches,d.builtInDatatype,d.builtInBound,d.builtInIri,d.builtInUri,d.builtInBnodeSparqlJs,d.builtInRand,d.builtInAbs,d.builtInCeil,d.builtInFloor,d.builtInRound,d.builtInConcat,d.builtInStrlen,d.builtInUcase,d.builtInLcase,d.builtInEncode_for_uri],wk={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(d.builtInCallList(t).slice(0,-2))},vy=ue.create(Sk).addMany(d.builtInContains,d.builtInStrstarts,d.builtInStrends,d.builtInStrbefore,d.builtInStrafter,d.builtInYear,d.builtInMonth,d.builtInDay,d.builtInHours,d.builtInMinutes,d.builtInSeconds,d.builtInTimezone,d.builtInTz,d.builtInNow,d.builtInUuid,d.builtInStruuid,d.builtInMd5,d.builtInSha1,d.builtInSha256,d.builtInSha384,d.builtInSha512,d.builtInCoalesce,d.builtInIf,d.builtInStrlang,d.builtInStrdt,d.builtInSameterm,d.builtInIsiri,d.builtInIsuri,d.builtInIsblank,d.builtInIsliteral,d.builtInIsnumeric,d.regexExpression,d.substringExpression,d.strReplaceExpression,d.aggregateCount,d.aggregateSum,d.aggregateMin,d.aggregateMax,d.aggregateAvg,d.aggregateSample,d.aggregateGroup_concat,d.aggregate,d.iri,d.iriFull,d.prefixedName,d.argList,d.string).addRule(wk);var kk=[d.objectList,d.object,d.graphNode,d.varOrTerm,d.triplesNode,d.collection,d.blankNodePropertyList,d.propertyListNotEmpty,d.verb,d.verbA,d.varOrIri,d.var_,d.iri,d.iriFull,d.prefixedName,d.graphTerm,d.rdfLiteral,d.numericLiteral,d.booleanLiteral,d.blankNode,d.string,d.numericLiteralUnsigned,d.numericLiteralPositive,d.numericLiteralNegative],qs=ue.create(kk);var xy=ue.create([d.triplesBlock,d.triplesSameSubjectPath,d.propertyListPathNotEmpty,d.triplesNodePath,d.propertyListPath,d.verbPath,d.verbSimple,d.objectListPath]).merge(qs,[]).addMany(d.path,d.pathAlternative,d.pathSequence,d.pathEltOrInverse,d.pathElt,d.pathPrimary,d.pathMod,d.pathNegatedPropertySet,d.pathOneInPropertySet,d.objectPath,d.graphNodePath,d.collectionPath,d.blankNodePropertyListPath);var Ck=[d.subSelect,d.selectClause,d.whereClause,d.solutionModifier,d.valuesClause],zs=ue.create(Ck).merge(vy,[]).patchRule(d.builtInCall).addMany(d.existsFunc,d.notExistsFunc,d.groupGraphPattern,d.groupGraphPatternSub).merge(xy,[]).addMany(d.graphPatternNotTriples,d.groupOrUnionGraphPattern,d.optionalGraphPattern,d.minusGraphPattern,d.graphGraphPattern,d.serviceGraphPattern,d.filter,d.bind,d.inlineData,d.constraint,d.functionCall,d.dataBlock,d.inlineDataOneVar,d.inlineDataFull,d.dataBlockValue,d.groupClause,d.havingClause,d.orderClause,d.limitOffsetClauses,d.groupCondition,d.havingCondition,d.orderCondition,d.limitClause,d.offsetClause);var Rk=[d.triplesTemplate,d.triplesSameSubject,d.varOrTerm,d.propertyListNotEmpty,d.triplesNode,d.propertyList,d.var_,d.graphTerm,d.iri,d.iriFull,d.prefixedName,d.rdfLiteral,d.string,d.numericLiteral,d.numericLiteralUnsigned,d.numericLiteralPositive,d.numericLiteralNegative,d.booleanLiteral,d.blankNode,d.verb,d.verbA,d.varOrIri,d.objectList,d.object,d.collection,d.blankNodePropertyList,d.graphNode],Ws=ue.create(Rk);var Fk=[d.queryUnit,d.query,d.prologue,d.selectQuery,d.constructQuery,d.describeQuery,d.askQuery,d.valuesClause,d.baseDecl,d.prefixDecl],Ay=ue.create(Fk).merge(zs,[]).addRule(d.datasetClause).addRule(d.datasetClauseStar).addRule(d.defaultGraphClause).addRule(d.namedGraphClause).addRule(d.sourceSelector).addRule(d.constructTemplate).merge(Ws,[]).addRule(d.constructTriples);var Mk={name:"update1",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(d.load)},{ALT:()=>e(d.clear)},{ALT:()=>e(d.drop)},{ALT:()=>e(d.add)},{ALT:()=>e(d.move)},{ALT:()=>e(d.copy)},{ALT:()=>e(d.create)},{ALT:()=>e(d.insertData)},{ALT:()=>e(d.deleteData)},{ALT:()=>e(d.deleteWhere)}]),gImpl:d.update1.gImpl},Dk=[d.updateUnit,d.update,d.prologue,d.baseDecl,d.prefixDecl,d.load,d.clear,d.drop,d.add,d.move,d.copy,d.create,d.insertData,d.deleteData,d.deleteWhere,d.iri,d.prefixedName,d.graphRef,d.graphRefAll,d.graphOrDefault,d.quadData,d.quads],Ey=ue.create(Dk).addRule(Mk).merge(Ws,[]).addRule(d.quadPattern).addRule(d.quadsNotTriples);var Iy=ue.create(Ey).patchRule(d.update1).addMany(d.modify,d.deleteClause,d.insertClause,d.usingClause,d.defaultGraphClause,d.namedGraphClause,d.sourceSelector,d.usingClauseStar,d.groupGraphPattern).merge(qs,[]).merge(zs,[]);var Ly=ue.create(Ay).merge(Iy,[]).addRule(d.queryOrUpdate);var Au={};Ze(Au,{findPatternBoundedVars:()=>Te,langTagHasCorrectRange:()=>vu,queryProjectionIsGood:()=>xu});var dr=class extends cr{constructor(){super(...arguments);H(this,"triple",(r,n,i,a)=>({type:"triple",subject:r,predicate:n,object:i,annotations:[],loc:a!=null?a:this.sourceLocation(r,n,i)}))}termTriple(r,n,i,a){return{type:"term",subType:"triple",subject:r,predicate:n,object:i,loc:a}}isTermTriple(r){return this.isOfSubType(r,"term","triple")}tripleCollectionReifiedTriple(r,n,i,a,s){return{type:"tripleCollection",subType:"reifiedTriple",triples:[this.triple(n,i,a)],identifier:s!=null?s:this.termBlank(void 0,this.sourceLocation()),loc:r}}isTripleCollectionReifiedTriple(r){return this.isOfSubType(r,"tripleCollection","reifiedTriple")}tripleCollectionBlankNodeProperties(r,n,i){return{type:"tripleCollection",subType:"blankNodeProperties",triples:n,identifier:r,loc:i}}annotatedTriple(r,n,i,a,s){return{type:"triple",subject:r,predicate:n,object:i,annotations:a!=null?a:[],loc:s!=null?s:this.sourceLocation(r,n,i,...a!=null?a:[])}}contextDefinitionVersion(r,n){return{type:"contextDef",subType:"version",version:r,loc:n}}isContextDefinitionVersion(r){return this.isOfSubType(r,"contextDef","version")}};var W=new dr;function jk(e){return e==="ltr"||e==="rtl"}function vu(e){if(W.isTermLiteralLangStr(e)){let t=e.langOrIri.split("--");if(t.length>1){let[r,n]=t;if(!jk(n))throw new Error(`language direction "${n}" of literal "${JSON.stringify(e)}" is not is required range 'ltr' | 'rtl'.`)}}}function Te(e,t){var r,n,i;if(W.isQuery(e)||W.isUpdate(e)){if(W.isQuerySelect(e)||W.isQueryDescribe(e)){if(e.where&&e.variables.some(a=>W.isWildcard(a)))Te(e.where,t);else for(let a of e.variables)Te(a,t);if(e.solutionModifiers.group){let a=e.solutionModifiers.group;for(let s of a.groupings)"variable"in s&&Te(s.variable,t)}if((r=e.values)!=null&&r.values&&e.values.values.length>0){let a=e.values.values;for(let s of Object.keys(a[0]))t.add(s)}}}else if(W.isTerm(e))W.isTermVariable(e)&&t.add(e.value),W.isTermTriple(e)&&(Te(e.subject,t),Te(e.predicate,t),Te(e.object,t));else if(W.isTriple(e)){Te(e.subject,t),Te(e.predicate,t),Te(e.object,t);for(let a of(n=e.annotations)!=null?n:[])Te(W.isTripleCollection(a)?a:a.val,t)}else if(W.isPath(e))for(let a of e.items)Te(a,t);else if(W.isTripleCollection(e)||W.isPatternBgp(e))for(let a of e.triples)Te(a,t);else if(W.isPatternGroup(e)||W.isPatternUnion(e)||W.isPatternOptional(e)||W.isPatternService(e)){for(let a of e.patterns)Te(a,t);W.isPatternService(e)&&Te(e.name,t)}else if(W.isPatternBind(e))Te(e.variable,t);else if(W.isPatternValues(e))for(let a of Object.keys((i=e.values.at(0))!=null?i:{}))t.add(a);else if(W.isPatternGraph(e)){Te(e.name,t);for(let a of e.patterns)Te(a,t)}}function xu(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(a=>W.isTerm(a)?[]:Or(a.expression)).some(a=>a.aggregation==="count"&&!a.expression.some(s=>W.isWildcard(s))),n=e.solutionModifiers.group;if(r||n){let a=new Set;for(let s of t){if(W.isTerm(s)){if(!n||!n.groupings.map(o=>ur(o)).includes(ur(s)))throw new Error("Variable not allowed in projection")}else if(Or(s.expression).length===0){let o=new Set;li(s.expression,o);for(let l of o)if(!a.has(l)&&(!n||!n.groupings.map(c=>ur(c)).includes(l)))throw new Error(`Use of ungrouped variable in projection of operation (?${l})`)}W.isTerm(s)||a.add(s.variable.value)}}let i=e.where.patterns.filter(a=>a.type==="query");if(i.length>0){let a=new Set;for(let l of t)"variable"in l&&a.add(l.variable.value);let s=i.flatMap(l=>l.variables).map(l=>W.isTerm(l)?l.value:W.isWildcard(l)?"*":l.variable.value),o=new Set(s);for(let l of a)if(o.has(l))throw new Error(`Target id of 'AS' (?${l}) already used in subquery`)}}var k={};Ze(k,{annotation:()=>Fy,annotationBlock:()=>Dy,annotationBlockPath:()=>Pu,annotationPath:()=>ho,buildInHasLang:()=>Yy,buildInHasLangDir:()=>Qy,buildInIsTriple:()=>Xy,buildInLangDir:()=>zy,buildInLangStrDir:()=>Wy,buildInObject:()=>Uy,buildInPredicate:()=>Zy,buildInSubject:()=>Jy,buildInTriple:()=>By,builtInCall:()=>Bk,dataBlockValue:()=>qk,exprTripleTerm:()=>ku,exprTripleTermObject:()=>qy,exprTripleTermSubject:()=>Ky,generateGraphTerm:()=>eC,generateTriplesBlock:()=>Uk,graphNode:()=>jy,graphNodePath:()=>je,iriFull:()=>Zk,object:()=>Yk,objectPath:()=>Qk,primaryExpression:()=>_u,prologue:()=>Kk,rdfLiteral:()=>Tn,reifiedTriple:()=>gn,reifiedTripleBlock:()=>Oy,reifiedTripleBlockPath:()=>Sy,reifiedTripleObject:()=>Gy,reifiedTripleSubject:()=>Ou,reifier:()=>Nu,selectQuery:()=>Hk,string:()=>Jk,tripleTerm:()=>Ii,tripleTermData:()=>wu,tripleTermDataObject:()=>Hy,tripleTermDataSubject:()=>Vy,tripleTermObject:()=>$y,tripleTermSubject:()=>Su,triplesSameSubject:()=>zk,triplesSameSubjectPath:()=>Wk,unaryExpression:()=>eb,varOrReifierId:()=>wy,varOrTerm:()=>Xk,versionDecl:()=>Lu,versionSpecifier:()=>_y});var mn={};Ze(mn,{LANG_DIR:()=>lo,annotationClose:()=>Bs,annotationOpen:()=>Xs,buildInHasLang:()=>to,buildInHasLangDir:()=>ro,buildInIsTRIPLE:()=>no,buildInLangDir:()=>Us,buildInOBJECT:()=>oo,buildInPREDICATE:()=>so,buildInSUBJECT:()=>ao,buildInStrLangDir:()=>eo,buildInTRIPLE:()=>io,iriRef:()=>uo,reificationClose:()=>Zs,reificationOpen:()=>Js,sparql12LexerBuilder:()=>$k,stringLiteral1:()=>Ai,stringLiteral2:()=>Ei,stringLiteralLong1:()=>po,stringLiteralLong2:()=>fo,tilde:()=>Qs,tripleTermClose:()=>hn,tripleTermOpen:()=>fn,version:()=>Ys});var Ys=m({name:"Version",pattern:/version/i,label:"version identifier"}),Qs=m({name:"Tilde",pattern:"~",label:"~"}),Xs=m({name:"AnnotationOpen",pattern:"{|",label:"Annotation Open: {|"}),Bs=m({name:"AnnotationClose",pattern:"|}",label:"Annotation Close |}"}),Js=m({name:"ReificationOpen",pattern:"<<",label:"Reification open <<"}),Zs=m({name:"ReificationClose",pattern:">>",label:"Reification close >>"}),fn=m({name:"TripleTermOpen",pattern:"<<(",label:"Triple Term Open <<("}),hn=m({name:"TripleTermClose",pattern:")>>",label:"Triple Term Close )>>"}),Us=m({name:"BuiltInLangdir",pattern:/langdir/i,label:"LANGDIR"}),eo=m({name:"BuiltInStrLangdir",pattern:/strlangdir/i,label:"STRLANGDIR"}),to=m({name:"BuiltInHasLang",pattern:/haslang/i,label:"hasLANG"}),ro=m({name:"BuiltInHasLangdir",pattern:/haslangdir/i,label:"hasLANGDIR"}),no=m({name:"BuiltInIsTriple",pattern:/istriple/i,label:"isTRIPLE"}),io=m({name:"BuiltInTriple",pattern:/triple/i,label:"TRIPLE"}),ao=m({name:"BuiltInSubject",pattern:/subject/i,label:"SUBJECT"}),so=m({name:"BuiltInPredicate",pattern:/predicate/i,label:"PREDICATE"}),oo=m({name:"BuiltInObject",pattern:/object/i,label:"OBJECT"}),lo=m({name:"LANG_DIR",pattern:/@[a-z]+(?:-[\da-z]+)*(?:--[a-z]+)?/i,label:"LANG_DIR"}),xi=/\\u[\dA-Fa-f]{4}|\\U[\dA-Fa-f]{8}/.source,co=/\\["'\\bfnrt]/.source,Gk=/[^\u0000-\u0020"<>\\^`{|}]/.source,uo=m({name:"IriRef",pattern:new RegExp(`<((${Gk})|(${xi}))*>`)}),Ai=m({name:"StringLiteral1",pattern:new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${co})|(${xi}))*'`)}),Ei=m({name:"StringLiteral2",pattern:new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${co})|(${xi}))*"`)}),po=m({name:"StringLiteralLong1",pattern:new RegExp(`'''(('|(''))?([^'\\\\]|(${co})|(${xi})))*'''`)}),fo=m({name:"StringLiteralLong2",pattern:new RegExp(`"""(("|(""))?([^"\\\\]|(${co})|(${xi})))*"""`)}),$k=Oe.create(q.sparql11LexerBuilder).addBefore(q.symbols.logicAnd,Qs,Xs,Bs,fn,hn,Js,Zs,Ys).addBefore(q.builtIn.langmatches,Us,eo,ro,to,no,io,ao,so,oo).addBefore(q.terminals.langTag,lo).deleteToken(q.terminals.langTag.name).replace(uo).replace(Ai).replace(Ei).replace(po).replace(fo);function Vk(e){return e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(t,r,n)=>Eu(r!=null?r:n))}function Eu(e){let t=Number.parseInt(e,16);if(t>=55296&&t<=57343)throw new Error(`Illegal codepoint escape: surrogate code point U+${e.toUpperCase()}`);return String.fromCodePoint(t)}function Py(e){var t,r,n;return{astFactory:(t=e.astFactory)!=null?t:new dr({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:(r=e.skipValidation)!=null?r:!1,codepointEscape:(n=e.codepointEscape)!=null?n:Vk}}function Iu(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var Lu={name:"versionDecl",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ys),a=t(_y);return e(()=>n.astFactory.contextDefinitionVersion(a.val,n.astFactory.sourceLocation(i,a)))},gImpl:({PRINT_ON_OWN_LINE:e})=>(t,{astFactory:r})=>{r.printFilter(t,()=>{e("VERSION ",`${d.stringEscapedLexical(t.version)}`)})}},Hk={name:"selectQuery",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(d.selectClause),i=t(d.datasetClauseStar),a=t(d.whereClause),s=t(d.solutionModifier);return e(()=>{let o={subType:"select",where:a.val,solutionModifiers:s,datasets:i,...n.val,loc:r.astFactory.sourceLocation(n,a,s.group,s.having,s.order,s.limitOffset)};return r.skipValidation||xu(o),o})}},_y={name:"versionSpecifier",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>t(Ai)},{ALT:()=>t(Ei)}]);return e(()=>n.astFactory.wrap(i.image.slice(1,-1),n.astFactory.sourceLocation(i)))}},Kk={name:"prologue",impl:({SUBRULE:e,MANY:t,OR:r})=>()=>{let n=[];return t(()=>r([{ALT:()=>n.push(e(d.baseDecl))},{ALT:()=>n.push(e(d.prefixDecl))},{ALT:()=>n.push(e(Lu))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(d.baseDecl,n):r.isContextDefinitionPrefix(n)?e(d.prefixDecl,n):e(Lu,n)}};function Ny(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>i=>{let a=n(gn),s=n(t?d.propertyListPath:d.propertyList,r(()=>i.astFactory.dematerialized(a.identifier)));return r(()=>[a,...s])}}}var Oy=Ny("reifiedTripleBlock",!1),Sy=Ny("reifiedTripleBlockPath",!0),qk={name:"dataBlockValue",impl:e=>t=>e.OR2([{ALT:()=>d.dataBlockValue.impl(e)(t)},{ALT:()=>e.SUBRULE(wu)}])},Nu={name:"reifier",impl:({ACTION:e,CONSUME:t,SUBRULE:r,OPTION:n})=>i=>{let a=t(Qs),s=n(()=>r(wy));return e(()=>{if(s===void 0&&!i.parseMode.has("canCreateBlankNodes"))throw new Error("Cannot create blanknodes in current parse mode");return i.astFactory.wrap(s!=null?s:i.astFactory.termBlank(void 0,i.astFactory.sourceLocation()),i.astFactory.sourceLocation(a,s))})}},wy={name:"varOrReifierId",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(d.var_)},{ALT:()=>e(d.iri)},{ALT:()=>e(d.blankNode)}])};function ky(e,t){return{name:e,impl:r=>n=>r.OR2([{ALT:()=>t?d.triplesSameSubjectPath.impl(r)(n):d.triplesSameSubject.impl(r)(n)},{ALT:()=>r.SUBRULE(t?Sy:Oy)}])}}var zk=ky("triplesSameSubject",!1),Wk=ky("triplesSameSubjectPath",!0);function Cy(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,a,s)=>{let o=n(t?je:jy),l=n(t?ho:Fy);return r(()=>{let c=i.astFactory;if(c.isPathPure(s)&&l.length>0)throw new Error("Note 17 violation");return c.annotatedTriple(a,s,o,l)})}}}var Yk=Cy("object",!1),Qk=Cy("objectPath",!0);function Ry(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i,MANY:a})=>s=>{let o=[],l;return a(()=>{i([{ALT:()=>{let c=n(Nu);o.push(c),l=c.val}},{ALT:()=>{r(()=>{if(!l&&!s.parseMode.has("canCreateBlankNodes"))throw new Error("Cannot create blanknodes in current parse mode");l=l!=null?l:s.astFactory.termBlank(void 0,s.astFactory.sourceLocation())});let c=n(t?Pu:Dy,l);r(()=>{o.push(c),l=void 0})}}])}),o},gImpl:({SUBRULE:r,PRINT_WORD:n})=>(i,{astFactory:a})=>{for(let s of i)a.isTripleCollectionBlankNodeProperties(s)?r(Pu,s):(a.printFilter(s,()=>n("~")),r(je,s.val))}}}var ho=Ry("annotationPath",!0),Fy=Ry("annotation",!1);function My(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i})=>(a,s)=>{let o=i(Xs),l=n(t?d.propertyListPathNotEmpty:d.propertyListNotEmpty,s),c=i(Bs);return r(()=>a.astFactory.tripleCollectionBlankNodeProperties(s,l,a.astFactory.sourceLocation(o,c)))},gImpl:({SUBRULE:r,PRINT_WORD:n,HANDLE_LOC:i,NEW_LINE:a,PRINT_ON_OWN_LINE:s})=>(o,l)=>{let{astFactory:c,indentInc:u}=l;c.printFilter(o,()=>{n("{|"),o.triples.length>1&&(l[ce]+=u,a())});function p(g){i(g,()=>{c.isTerm(g.predicate)?r(je,g.predicate):r(d.pathGenerator,g.predicate,void 0),c.printFilter(g,()=>n("")),r(je,g.object)})}let[f,...h]=o.triples;p(f);for(let g of h)c.printFilter(o,()=>{n(";"),a()}),p(g);c.printFilter(o,()=>{o.triples.length>1?s("|}"):n("|}")})}}}var Pu=My("annotationBlockPath",!0),Dy=My("annotationBlock",!1),jy={name:"graphNode",impl:e=>t=>e.OR2([{ALT:()=>d.graphNode.impl(e)(t)},{ALT:()=>e.SUBRULE(gn)}])},je={name:"graphNodePath",impl:e=>t=>e.OR2([{ALT:()=>d.graphNodePath.impl(e)(t)},{ALT:()=>e.SUBRULE(gn)}]),gImpl:e=>(t,r)=>{r.astFactory.isTripleCollectionReifiedTriple(t)?e.SUBRULE(gn,t):d.graphNodePath.gImpl(e)(t,r)}},Xk={name:"varOrTerm",impl:({ACTION:e,SUBRULE:t,OR:r,CONSUME:n})=>i=>r([{GATE:()=>i.parseMode.has("canParseVars"),ALT:()=>t(d.var_)},{ALT:()=>t(d.iri)},{ALT:()=>t(Tn)},{ALT:()=>t(d.numericLiteral)},{ALT:()=>t(d.booleanLiteral)},{ALT:()=>t(d.blankNode)},{ALT:()=>{let a=n(q.terminals.nil);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(a),se.NIL))}},{ALT:()=>t(Ii)}])},gn={name:"reifiedTriple",impl:({ACTION:e,CONSUME:t,SUBRULE:r,OPTION:n})=>i=>{let a=t(Js),s=r(Ou),o=r(d.verb),l=r(Gy),c=n(()=>r(Nu)),u=t(Zs);return e(()=>{if(c===void 0&&!i.parseMode.has("canCreateBlankNodes"))throw new Error("Cannot create blanknodes in current parse mode");return i.astFactory.tripleCollectionReifiedTriple(i.astFactory.sourceLocation(a,u),s,o,l,c==null?void 0:c.val)})},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("<<"));let i=r.triples[0];e(je,i.subject),n.printFilter(r,()=>t("")),n.isPathPure(i.predicate)?e(d.pathGenerator,i.predicate,void 0):e(je,i.predicate),n.printFilter(r,()=>t("")),e(je,i.object),e(ho,[n.wrap(r.identifier,r.identifier.loc)]),n.printFilter(r,()=>t(">>"))}},Ou={name:"reifiedTripleSubject",impl:({OR:e,SUBRULE:t})=>r=>e([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>t(d.var_)},{ALT:()=>t(d.iri)},{ALT:()=>t(Tn)},{ALT:()=>t(d.numericLiteral)},{ALT:()=>t(d.booleanLiteral)},{ALT:()=>t(d.blankNode)},{ALT:()=>t(gn)},{ALT:()=>t(Ii)}])},Gy={name:"reifiedTripleObject",impl:Ou.impl},Ii={name:"tripleTerm",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(fn),a=r(Su),s=r(d.verb),o=r($y),l=t(hn);return e(()=>n.astFactory.termTriple(a,s,o,n.astFactory.sourceLocation(i,l)))},gImpl:({SUBRULE:e,PRINT_WORD:t})=>(r,{astFactory:n})=>{n.printFilter(r,()=>t("<<(")),e(je,r.subject),n.printFilter(r,()=>t("")),e(je,r.predicate),n.printFilter(r,()=>t("")),e(je,r.object),n.printFilter(r,()=>t(")>>"))}},Su={name:"tripleTermSubject",impl:({SUBRULE:e,OR:t})=>r=>t([{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>e(d.var_)},{ALT:()=>e(d.iri)},{ALT:()=>e(Tn)},{ALT:()=>e(d.numericLiteral)},{ALT:()=>e(d.booleanLiteral)},{ALT:()=>e(d.blankNode)},{ALT:()=>e(Ii)}])},$y={name:"tripleTermObject",impl:Su.impl},wu={name:"tripleTermData",impl:({ACTION:e,CONSUME:t,OR:r,SUBRULE:n})=>i=>{let a=t(fn),s=n(Vy),o=r([{ALT:()=>n(d.iri)},{ALT:()=>{let u=t(q.a);return e(()=>i.astFactory.termNamed(i.astFactory.sourceLocation(u),se.TYPE))}}]),l=n(Hy),c=t(hn);return e(()=>i.astFactory.termTriple(s,o,l,i.astFactory.sourceLocation(a,c)))}},Vy={name:"tripleTermDataSubject",impl:({OR:e,SUBRULE:t})=>()=>e([{ALT:()=>t(d.iri)}])},Hy={name:"tripleTermDataObject",impl:({OR:e,SUBRULE:t})=>()=>e([{ALT:()=>t(d.iri)},{ALT:()=>t(Tn)},{ALT:()=>t(d.numericLiteral)},{ALT:()=>t(d.booleanLiteral)},{ALT:()=>t(wu)}])},_u={name:"primaryExpression",impl:e=>t=>e.OR2([{ALT:()=>d.primaryExpression.impl(e)(t)},{ALT:()=>e.SUBRULE(ku)}])},ku={name:"exprTripleTerm",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(fn),a=r(Ky),s=r(d.verb),o=r(qy),l=t(hn);return e(()=>n.astFactory.termTriple(a,s,o,n.astFactory.sourceLocation(i,l)))}},Ky={name:"exprTripleTermSubject",impl:({OR:e,SUBRULE:t})=>r=>e([{ALT:()=>t(d.iri)},{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>t(d.var_)}])},qy={name:"exprTripleTermObject",impl:({OR:e,SUBRULE:t})=>r=>e([{ALT:()=>t(d.iri)},{ALT:()=>t(Tn)},{ALT:()=>t(d.numericLiteral)},{ALT:()=>t(d.booleanLiteral)},{GATE:()=>r.parseMode.has("canParseVars"),ALT:()=>t(d.var_)},{ALT:()=>t(ku)}])},zy=D(Us),Wy=an(eo),Yy=D(to),Qy=D(ro),Xy=D(no),By=an(io),Jy=D(ao),Zy=D(so),Uy=D(oo),Bk={name:"builtInCall",impl:e=>t=>e.OR2([{ALT:()=>d.builtInCall.impl(e)(t)},{ALT:()=>e.SUBRULE(zy)},{ALT:()=>e.SUBRULE(Wy)},{ALT:()=>e.SUBRULE(Yy)},{ALT:()=>e.SUBRULE(Qy)},{ALT:()=>e.SUBRULE(Xy)},{ALT:()=>e.SUBRULE(By)},{ALT:()=>e.SUBRULE(Jy)},{ALT:()=>e.SUBRULE(Zy)},{ALT:()=>e.SUBRULE(Uy)}])},Tn={name:"rdfLiteral",impl:({ACTION:e,SUBRULE:t,OPTION:r,CONSUME:n,OR:i})=>a=>{var o;let s=t(d.string);return(o=r(()=>i([{ALT:()=>{let l=n(lo);return e(()=>{let c=a.astFactory.termLiteral(a.astFactory.sourceLocation(s,l),s.value,l.image.slice(1).toLowerCase());return vu(c),c})}},{ALT:()=>{n(q.symbols.hathat);let l=t(d.iri);return e(()=>a.astFactory.termLiteral(a.astFactory.sourceLocation(s,l),s.value,l))}}])))!=null?o:s}},Jk={name:"string",impl:({ACTION:e,CONSUME:t,OR:r})=>n=>{let i=r([{ALT:()=>{let a=t(Ai);return[a,a.image.slice(1,-1)]}},{ALT:()=>{let a=t(Ei);return[a,a.image.slice(1,-1)]}},{ALT:()=>{let a=t(po);return[a,a.image.slice(3,-3)]}},{ALT:()=>{let a=t(fo);return[a,a.image.slice(3,-3)]}}]);return e(()=>{let[a,s]=i,o=n.astFactory,l={t:" ",n:`
|
|
120
|
+
`,r:"\r",b:"\b",f:"\f",'"':'"',"'":"'","\\":"\\"},c=s.replaceAll(/\\u([\dA-Fa-f]{4})|\\U([\dA-Fa-f]{8})|\\(.)/gsu,(u,p,f,h)=>p!==void 0||f!==void 0?Eu(p!=null?p:f):l[h]);if(/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(c))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint");return o.termLiteral(o.sourceLocation(a),c)})}},Zk={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(uo);return e(()=>{let i=n.image.slice(1,-1);return r.astFactory.termNamed(r.astFactory.sourceLocation(n),r.codepointEscape(i))})}},eb={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:a})=>s=>i([{ALT:()=>r(_u)},{ALT:()=>{let o=t(q.symbols.exclamation),l=r(eb);return e(()=>s.astFactory.expressionOperation("!",[l],s.astFactory.sourceLocation(o,l)))}},{ALT:()=>{let o=a([{ALT:()=>t(q.symbols.opPlus)},{ALT:()=>t(q.symbols.opMinus)}]),l=n(_u);return e(()=>s.astFactory.expressionOperation(o.image==="+"?"UPLUS":"UMINUS",[l],s.astFactory.sourceLocation(o,l)))}}])},Uk={name:"triplesBlock",gImpl:({SUBRULE:e,PRINT_WORD:t,NEW_LINE:r,HANDLE_LOC:n})=>(i,{astFactory:a})=>{for(let[s,o]of i.triples.entries())n(o,()=>{var c;let l=i.triples.at(s+1);a.isTripleCollection(o)?(e(je,o),(l==null?void 0:l.type)==="triple"&&a.isSourceLocationNoMaterialize(l.subject.loc)||a.printFilter(o,()=>{t("."),r()})):(e(je,o.subject),a.printFilter(i,()=>t("")),a.isPathPure(o.predicate)?e(d.pathGenerator,o.predicate,void 0):e(je,o.predicate),a.printFilter(i,()=>t("")),e(je,o.object),e(ho,(c=o.annotations)!=null?c:[]),l===void 0||a.isTripleCollection(l)||!a.isSourceLocationNoMaterialize(l.subject.loc)?a.printFilter(i,()=>{t("."),r()}):a.isSourceLocationNoMaterialize(l.predicate.loc)?a.printFilter(i,()=>t(",")):a.printFilter(i,()=>{t(";"),r()}))})}},eC={name:"graphTerm",gImpl:e=>(t,r)=>{r.astFactory.isTermTriple(t)?e.SUBRULE(Ii,t):d.graphTerm.gImpl(e)(t,r)}};var aD={...pi,...Au};var tC=ue.create(Ly).widenContext().typePatch().addMany(k.reifiedTripleBlock,k.reifiedTripleBlockPath,k.reifier,k.varOrReifierId,k.annotation,k.annotationPath,k.annotationBlockPath,k.annotationBlock,k.reifiedTriple,k.reifiedTripleSubject,k.reifiedTripleObject,k.tripleTerm,k.tripleTermSubject,k.tripleTermObject,k.tripleTermData,k.tripleTermDataSubject,k.tripleTermDataObject,k.exprTripleTerm,k.exprTripleTermSubject,k.exprTripleTermObject).addMany(k.versionDecl,k.versionSpecifier).addMany(k.buildInLangDir,k.buildInLangStrDir,k.buildInHasLang,k.buildInHasLangDir,k.buildInIsTriple,k.buildInTriple,k.buildInSubject,k.buildInPredicate,k.buildInObject).patchRule(k.selectQuery).patchRule(k.dataBlockValue).patchRule(k.triplesSameSubject).patchRule(k.triplesSameSubjectPath).patchRule(k.object).patchRule(k.objectPath).patchRule(k.graphNode).patchRule(k.graphNodePath).patchRule(k.varOrTerm).patchRule(k.primaryExpression).patchRule(k.builtInCall).patchRule(k.rdfLiteral).patchRule(k.unaryExpression).patchRule(k.prologue).patchRule(k.string).patchRule(k.iriFull).deleteRule(d.graphTerm.name),mo=class{constructor(t={}){H(this,"parser");H(this,"defaultContext");var r;this.parser=tC.build({...t,tokenVocabulary:mn.sparql12LexerBuilder.tokenVocabulary}),this.defaultContext=Py((r=t.defaultContext)!=null?r:{})}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Iu({...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,Iu({...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 bb=_n(rb(),1);var E;(function(e){e.ASK="ask",e.BGP="bgp",e.CONSTRUCT="construct",e.DESCRIBE="describe",e.DISTINCT="distinct",e.EXPRESSION="expression",e.EXTEND="extend",e.FILTER="filter",e.FROM="from",e.GRAPH="graph",e.GROUP="group",e.JOIN="join",e.LEFT_JOIN="leftjoin",e.MINUS="minus",e.NOP="nop",e.ORDER_BY="orderby",e.PATTERN="pattern",e.PROJECT="project",e.REDUCED="reduced",e.SERVICE="service",e.SLICE="slice",e.UNION="union",e.VALUES="values",e.COMPOSITE_UPDATE="compositeupdate",e.DELETE_INSERT="deleteinsert",e.LOAD="load",e.CLEAR="clear",e.CREATE="create",e.DROP="drop",e.ADD="add",e.MOVE="move",e.COPY="copy",e.PATH="path",e.ALT="alt",e.INV="inv",e.LINK="link",e.ONE_OR_MORE_PATH="OneOrMorePath",e.SEQ="seq",e.NPS="nps",e.ZERO_OR_MORE_PATH="ZeroOrMorePath",e.ZERO_OR_ONE_PATH="ZeroOrOnePath"})(E||(E={}));var bt;(function(e){e.AGGREGATE="aggregate",e.EXISTENCE="existence",e.NAMED="named",e.OPERATOR="operator",e.TERM="term",e.WILDCARD="wildcard"})(bt||(bt={}));var ie=new Pr({},{[E.PATTERN]:{ignoreKeys:new Set(["subject","predicate","object","graph"])},[E.EXPRESSION]:{ignoreKeys:new Set(["name","term","wildcard","variable"])},[E.DESCRIBE]:{ignoreKeys:new Set(["terms"])},[E.EXTEND]:{ignoreKeys:new Set(["variable"])},[E.FROM]:{ignoreKeys:new Set(["default","named"])},[E.GRAPH]:{ignoreKeys:new Set(["name"])},[E.GROUP]:{ignoreKeys:new Set(["variables"])},[E.LINK]:{ignoreKeys:new Set(["iri"])},[E.NPS]:{ignoreKeys:new Set(["iris"])},[E.PATH]:{ignoreKeys:new Set(["subject","object","graph"])},[E.PROJECT]:{ignoreKeys:new Set(["variables"])},[E.SERVICE]:{ignoreKeys:new Set(["name"])},[E.VALUES]:{ignoreKeys:new Set(["variables","bindings"])},[E.LOAD]:{ignoreKeys:new Set(["source","destination"])},[E.CLEAR]:{ignoreKeys:new Set(["source"])},[E.CREATE]:{ignoreKeys:new Set(["source"])},[E.DROP]:{ignoreKeys:new Set(["source"])},[E.ADD]:{ignoreKeys:new Set(["source","destination"])},[E.MOVE]:{ignoreKeys:new Set(["source","destination"])},[E.COPY]:{ignoreKeys:new Set(["source","destination"])}}),nb=ie.transformNode.bind(ie),xD=ie.transformNodeAsync.bind(ie),AD=ie.transformNodePreOrder.bind(ie),ED=ie.transformNodePreOrderAsync.bind(ie),ID=ie.transformNodeSpecific.bind(ie),LD=ie.transformNodeSpecificAsync.bind(ie),PD=ie.transformNodeSpecificPreOrder.bind(ie),_D=ie.transformNodeSpecificPreOrderAsync.bind(ie),ND=ie.visitNode.bind(ie),OD=ie.visitNodeAsync.bind(ie),SD=ie.visitNodeSpecific.bind(ie),wD=ie.visitNodeSpecificAsync.bind(ie),rC=/^[a-z][\d+.a-z-]*:/iu,nC=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su,iC=/^(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su;function go(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),a=i===-1?t:t.slice(0,i);r+=a,t=t.slice(a.length)}return r}function ib(e,t){if(rC.test(e))return e;if(!t)throw new Error(`Cannot resolve relative IRI ${e} because no base IRI was set.`);let[,r,n,i,a]=iC.exec(e),[,s,o,l,c]=nC.exec(t),u,p,f;r===void 0?(n===""?(p=l,f=i!=null?i:c):(n.startsWith("/")?p=go(n):o!==void 0&&l===""?p=go(`/${n}`):p=go(l.slice(0,l.lastIndexOf("/")+1)+n),f=i),u=o):(u=r,p=go(n),f=i);let h=s===void 0?"":`${s}:`;return u!==void 0&&(h+=`//${u}`),h+=p,f!==void 0&&(h+=`?${f}`),a!==void 0&&(h+=`#${a}`),h}var sC=new RegExp(q.patterns.pnLocalEscPattern.source,"gu"),fe={name:"translateNamed",fun:()=>({astFactory:e,currentPrefixes:t,currentBase:r,dataFactory:n},i)=>{let a=i.value;if(e.isTermNamedPrefixed(i)){let s=t[i.prefix];if(!s)throw new Error(`Unknown prefix: ${i.prefix}`);a=s+i.value.replaceAll(sC,o=>o.slice(1))}return n.namedNode(ib(a,r))}},Q={name:"translateTerm",fun:({SUBRULE:e})=>({astFactory:t,dataFactory:r},n)=>{if(t.isTermNamed(n))return e(fe,n);if(t.isTermBlank(n))return r.blankNode(n.label);if(t.isTermVariable(n))return r.variable(n.value);if(t.isTermLiteral(n)){let i=typeof n.langOrIri=="object"?e(fe,n.langOrIri):n.langOrIri;return r.literal(n.value,i)}throw new Error(`Unexpected term: ${JSON.stringify(n)}`)}},bn={name:"registerContextDefinitions",fun:({SUBRULE:e})=>(t,r)=>{let{astFactory:n,currentPrefixes:i}=t;for(let a of r)n.isContextDefinitionPrefix(a)&&(i[a.key]=e(Q,a.value).value),n.isContextDefinitionBase(a)&&(t.currentBase=e(Q,a.value).value)}},vn={name:"translateInlineData",fun:({SUBRULE:e})=>({algebraFactory:t},r)=>{let n=r.variables.map(a=>e(Q,a)),i=r.values.map(a=>{let s={};for(let[o,l]of Object.entries(a))l!==void 0&&(s[o]=e(Q,l));return s});return t.createValues(n,i)}},xn={name:"translateDatasetClause",fun:({SUBRULE:e})=>(t,r)=>({default:r.clauses.filter(n=>n.clauseType==="default").map(n=>e(fe,n.value)),named:r.clauses.filter(n=>n.clauseType==="named").map(n=>e(fe,n.value))})},yn={name:"translateBlankNodesToVariables",fun:({SUBRULE:e})=>({algebraFactory:t,variables:r},n)=>{let i={},a=new Set(r);function s(l){let c=0,u=l;for(;r.has(u);)u=`${l}${c++}`;return t.dataFactory.variable(u)}function o(l){if(l.termType==="BlankNode"){let c=i[l.value];return c||(c=s(l.value),a.add(c.value),i[l.value]=c),c}return l.termType==="Quad"?t.dataFactory.quad(o(l.subject),o(l.predicate),o(l.object),o(l.graph)):l}return nb(n,{[E.PATH]:{preVisitor:()=>({continue:!1}),transform:l=>t.createPath(o(l.subject),l.predicate,o(l.object),o(l.graph))},[E.PATTERN]:{preVisitor:()=>({continue:!1}),transform:l=>t.createPattern(o(l.subject),o(l.predicate),o(l.object),o(l.graph))},[E.CONSTRUCT]:{preVisitor:()=>({continue:!1}),transform:l=>t.createConstruct(e(yn,l.input),l.template)},[E.DELETE_INSERT]:{preVisitor:()=>({continue:!1}),transform:l=>t.createDeleteInsert(l.delete,l.insert,l.where&&e(yn,l.where))}})}},To={name:"findAllVariables",fun:()=>({transformer:e,variables:t},r)=>{e.visitNodeSpecific(r,{},{term:{variable:{visitor:n=>{t.add(n.value)}}}})}},Li={name:"inScopeVariables",fun:()=>(e,t)=>{let r=new Set;return ci(t,r),r}},kt={name:"generateFreshVar",fun:()=>e=>{let t=`var${e.varCount++}`;for(;e.variables.has(t);)t=`var${e.varCount++}`;return e.variables.add(t),e.dataFactory.variable(t)}};var mb=_n(Po(),1);var fb=_n(Po(),1),hb=_n(zu(),1);var _o=class{constructor(t){H(this,"dataFactory");H(this,"stringType");this.dataFactory=t!=null?t:new fb.DataFactory,this.stringType=this.createTerm("http://www.w3.org/2001/XMLSchema#string")}createAlt(t,r=!0){return this.flattenMulti({type:E.ALT,input:t},r)}createAsk(t){return{type:E.ASK,input:t}}createBoundAggregate(t,r,n,i,a){let s=this.createAggregateExpression(r,n,i,a);return s.variable=t,s}createBgp(t){return{type:E.BGP,patterns:t}}createConstruct(t,r){return{type:E.CONSTRUCT,input:t,template:r}}createDescribe(t,r){return{type:E.DESCRIBE,input:t,terms:r}}createDistinct(t){return{type:E.DISTINCT,input:t}}createExtend(t,r,n){return{type:E.EXTEND,input:t,variable:r,expression:n}}createFrom(t,r,n){return{type:E.FROM,input:t,default:r,named:n}}createFilter(t,r){return{type:E.FILTER,input:t,expression:r}}createGraph(t,r){return{type:E.GRAPH,input:t,name:r}}createGroup(t,r,n){return{type:E.GROUP,input:t,variables:r,aggregates:n}}createInv(t){return{type:E.INV,path:t}}createJoin(t,r=!0){return this.flattenMulti({type:E.JOIN,input:t},r)}createLeftJoin(t,r,n){return n?{type:E.LEFT_JOIN,input:[t,r],expression:n}:{type:E.LEFT_JOIN,input:[t,r]}}createLink(t){return{type:E.LINK,iri:t}}createMinus(t,r){return{type:E.MINUS,input:[t,r]}}createNop(){return{type:E.NOP}}createNps(t){return{type:E.NPS,iris:t}}createOneOrMorePath(t){return{type:E.ONE_OR_MORE_PATH,path:t}}createOrderBy(t,r){return{type:E.ORDER_BY,input:t,expressions:r}}createPath(t,r,n,i){return i?{type:E.PATH,subject:t,predicate:r,object:n,graph:i}:{type:E.PATH,subject:t,predicate:r,object:n,graph:this.dataFactory.defaultGraph()}}createPattern(t,r,n,i){let a=this.dataFactory.quad(t,r,n,i);return a.type=E.PATTERN,a}createProject(t,r){return{type:E.PROJECT,input:t,variables:r}}createReduced(t){return{type:E.REDUCED,input:t}}createSeq(t,r=!0){return this.flattenMulti({type:E.SEQ,input:t},r)}createService(t,r,n){return{type:E.SERVICE,input:t,name:r,silent:!!n}}createSlice(t,r,n){return r=r||0,n!==void 0?{type:E.SLICE,input:t,start:r,length:n}:{type:E.SLICE,input:t,start:r}}createUnion(t,r=!0){return this.flattenMulti({type:E.UNION,input:t},r)}createValues(t,r){return{type:E.VALUES,variables:t,bindings:r}}createZeroOrMorePath(t){return{type:E.ZERO_OR_MORE_PATH,path:t}}createZeroOrOnePath(t){return{type:E.ZERO_OR_ONE_PATH,path:t}}createAggregateExpression(t,r,n,i){return i!==void 0?{type:E.EXPRESSION,subType:bt.AGGREGATE,aggregator:t,expression:r,separator:i,distinct:n}:{type:E.EXPRESSION,subType:bt.AGGREGATE,aggregator:t,expression:r,distinct:n}}createExistenceExpression(t,r){return{type:E.EXPRESSION,subType:bt.EXISTENCE,not:t,input:r}}createNamedExpression(t,r){return{type:E.EXPRESSION,subType:bt.NAMED,name:t,args:r}}createOperatorExpression(t,r){return{type:E.EXPRESSION,subType:bt.OPERATOR,operator:t,args:r}}createTermExpression(t){return{type:E.EXPRESSION,subType:bt.TERM,term:t}}createWildcardExpression(){return{type:E.EXPRESSION,subType:bt.WILDCARD,wildcard:{type:"wildcard"}}}createTerm(t){return t.startsWith("$")&&(t=t.replace("$","?")),(0,hb.stringToTerm)(t,this.dataFactory)}createCompositeUpdate(t){return{type:E.COMPOSITE_UPDATE,updates:t}}createDeleteInsert(t,r,n){let i={type:E.DELETE_INSERT};return t&&(i.delete=t),r&&(i.insert=r),n&&(i.where=n),i}createLoad(t,r,n){let i={type:E.LOAD,source:t};return r&&(i.destination=r),this.addSilent(i,!!n)}createClear(t,r){return this.addSilent({type:E.CLEAR,source:t},!!r)}createCreate(t,r){return this.addSilent({type:E.CREATE,source:t},!!r)}createDrop(t,r){return this.addSilent({type:E.DROP,source:t},!!r)}createAdd(t,r,n){return this.addSilent({type:E.ADD,source:t,destination:r},!!n)}createMove(t,r,n){return this.addSilent({type:E.MOVE,source:t,destination:r},!!n)}createCopy(t,r,n){return this.addSilent({type:E.COPY,source:t,destination:r},!!n)}addSilent(t,r){return r&&(t.silent=r),t}flattenMulti(t,r){if(!r)return t;let n=t.type,i=t.subType,a=t.input,s=[];for(let o of a)o.type===n&&(!i||i===o.subType)?s.push(...o.input):s.push(o);return t.input=s,t}};function Wu(e){var r;let t=(r=e.dataFactory)!=null?r:new mb.DataFactory;return{variables:new Set,varCount:0,useQuads:!1,transformer:new rn,astFactory:new cr,dataFactory:t,algebraFactory:new _o(t),currentBase:e.baseIRI,currentPrefixes:Object.assign(Object.create(null),e.prefixes)}}var Ce=E,gb=Object.values(Ce);function Tb(e){return!!(e!=null&&e.termType)}function yb(e){return(e==null?void 0:e.termType)==="Variable"}var No={name:"translatePath",fun:({SUBRULE:e})=>(t,r)=>{let n=r.subject,i=e(Rt,r.predicate),a=r.object;return e(En,n,i,a)}},Rt={name:"translatePathPredicate",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n)=>{if(t.isTerm(n))return e(Rt,e(fe,n));if(Tb(n))return r.createLink(n);if(n.subType==="^")return r.createInv(e(Rt,n.items[0]));if(n.subType==="!"){let i=[],a=[],s=n.items[0],o;t.isPathPure(s)&&s.subType==="|"?o=s.items:o=[s];for(let u of o)if(t.isTerm(u))i.push(u);else if(u.subType==="^")a.push(u.items[0]);else throw new Error(`Unexpected item: ${JSON.stringify(u)}`);let l=r.createNps(i.map(u=>e(fe,u))),c=r.createInv(r.createNps(a.map(u=>e(fe,u))));return a.length===0?l:i.length===0?c:r.createAlt([l,c])}if(n.subType==="/")return r.createSeq(n.items.map(i=>e(Rt,i)));if(n.subType==="|")return r.createAlt(n.items.map(i=>e(Rt,i)));if(n.subType==="*")return r.createZeroOrMorePath(e(Rt,n.items[0]));if(n.subType==="+")return r.createOneOrMorePath(e(Rt,n.items[0]));if(n.subType==="?")return r.createZeroOrOnePath(e(Rt,n.items[0]));throw new Error(`Unable to translate path expression ${JSON.stringify(n)}`)}},En={name:"simplifyPath",fun:({SUBRULE:e})=>({algebraFactory:t},r,n,i)=>{if(n.type===E.LINK)return[t.createPattern(r,n.iri,i)];if(n.type===E.INV)return e(En,i,n.path,r);if(n.type===E.SEQ){let a=r,s=[];for(let o of n.input.slice(0,-1)){let l=e(kt);s.push(...e(En,a,o,l)),a=l}return s.push(...e(En,a,n.input.at(-1),i)),s}return[t.createPath(r,n,i)]}};var Dr={name:"translateTripleCollection",fun:({SUBRULE:e})=>(t,r,n)=>{e(Qt,r.triples,n)}},Qt={name:"translateBasicGraphPattern",fun:({SUBRULE:e})=>({astFactory:t},r,n)=>{for(let i of r)t.isTripleCollection(i)?e(Dr,i,n):e(_i,i,n)}},_i={name:"translateTripleNesting",fun:({SUBRULE:e})=>({astFactory:t},r,n)=>{let i,a,s;t.isTripleCollection(r.subject)?(e(Dr,r.subject,n),i=e(Q,r.subject.identifier)):i=e(Q,r.subject),t.isPathPure(r.predicate)?a=r.predicate:a=e(Q,r.predicate),t.isTripleCollection(r.object)?(e(Dr,r.object,n),s=e(Q,r.object.identifier)):s=e(Q,r.object),n.push({subject:i,predicate:a,object:s})}},Xe={name:"recurseGraph",fun:({SUBRULE:e})=>(t,r,n,i)=>{if(r.type===Ce.GRAPH){if(i)throw new Error("Recursing through nested GRAPH statements with a replacement is impossible.");r=e(Xe,r.input,r.name,void 0)}else if(r.type!==Ce.SERVICE)if(r.type===Ce.BGP)r.patterns=r.patterns.map(a=>(i&&(a.subject.equals(n)&&(a.subject=i),a.predicate.equals(n)&&(a.predicate=i),a.object.equals(n)&&(a.object=i)),a.graph.termType==="DefaultGraph"&&(a.graph=n),a));else if(r.type===Ce.PATH)i&&(r.subject.equals(n)&&(r.subject=i),r.object.equals(n)&&(r.object=i)),r.graph.termType==="DefaultGraph"&&(r.graph=n);else if(r.type===Ce.PROJECT&&!i)r.variables.some(a=>a.equals(n))||(i=e(kt)),r.input=e(Xe,r.input,n,i);else if(r.type===Ce.EXTEND&&!i)r.variable.equals(n)&&(i=e(kt)),r.input=e(Xe,r.input,n,i);else if(r.type===Ce.MINUS&&n.termType==="Variable")r.graphScopeVar=n,r.input=[e(Xe,r.input[0],n,i),e(Xe,r.input[1],n,i)];else for(let[a,s]of Object.entries(r)){let o=a;Array.isArray(s)?r[o]=s.map(l=>e(Xe,l,n,i)):gb.includes(s.type)?r[o]=e(Xe,s,n,i):i&&yb(s)&&s.equals(n)&&(r[o]=i)}return r}},hr={name:"translateQuad",fun:()=>({astFactory:e,algebraFactory:t},r)=>{if(e.isPathPure(r.predicate))throw new Error("Trying to translate property path to quad.");return t.createPattern(r.subject,r.predicate,r.object,r.graph)}};var Oo={name:"translateUpdate",fun:({SUBRULE:e})=>({algebraFactory:t},r)=>{let n=r.updates.flatMap(i=>(e(bn,i.context),i.operation?[e(Yu,i.operation)]:[]));return n.length===0?t.createNop():n.length===1?n[0]:t.createCompositeUpdate(n)}},Yu={name:"translateSingleUpdate",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n)=>{if(t.isUpdateOperationLoad(n))return e(Bu,n);if(t.isUpdateOperationClear(n))return r.createClear(e(Ni,n.destination),n.silent);if(t.isUpdateOperationCreate(n))return r.createCreate(e(Ni,n.destination),n.silent);if(t.isUpdateOperationDrop(n))return r.createDrop(e(Ni,n.destination),n.silent);if(t.isUpdateOperationAdd(n))return r.createAdd(e(Xt,n.source),e(Xt,n.destination),n.silent);if(t.isUpdateOperationCopy(n))return r.createCopy(e(Xt,n.source),e(Xt,n.destination),n.silent);if(t.isUpdateOperationMove(n))return r.createMove(e(Xt,n.source),e(Xt,n.destination),n.silent);if(t.isUpdateOperationInsertData(n)||t.isUpdateOperationDeleteData(n)||t.isUpdateOperationDeleteWhere(n)||t.isUpdateOperationModify(n))return e(Qu,n);throw new Error(`Unknown update type ${JSON.stringify(n)}`)}},Qu={name:"translateInsertDelete",fun:({SUBRULE:e})=>({useQuads:t,algebraFactory:r,astFactory:n},i)=>{if(!t)throw new Error("INSERT/DELETE operations are only supported with quads option enabled");let a=[],s=[],o;if(n.isUpdateOperationDeleteData(i)||n.isUpdateOperationDeleteWhere(i))a.push(...i.data.flatMap(l=>e(In,l,void 0))),n.isUpdateOperationDeleteWhere(i)&&(o=r.createBgp(a));else if(n.isUpdateOperationInsertData(i))s.push(...i.data.flatMap(l=>e(In,l,void 0)));else if(a.push(...i.delete.flatMap(l=>e(In,l,i.graph?e(fe,i.graph):i.graph))),s.push(...i.insert.flatMap(l=>e(In,l,i.graph?e(fe,i.graph):i.graph))),i.where.patterns.length>0){o=e(Be,i.where);let l=e(xn,i.from);l.default.length>0||l.named.length>0?o=r.createFrom(o,l.default,l.named):n.isUpdateOperationModify(i)&&i.graph&&(o=e(Xe,o,e(fe,i.graph),void 0))}return r.createDeleteInsert(a.length>0?a:void 0,s.length>0?s:void 0,o)}},In={name:"translateUpdateTriplesBlock",fun:({SUBRULE:e})=>(t,r,n)=>{let i=t.astFactory,a=n,s;i.isGraphQuads(r)?(a=e(Q,r.graph),s=r.triples):s=r;let o=[];return e(Qt,s.triples,o),a&&(o=o.map(l=>Object.assign(l,{graph:a}))),o.map(l=>e(hr,l))}},Xu={name:"translateGraphRefSpecific",fun:({SUBRULE:e})=>(t,r)=>e(fe,r.graph)},Xt={name:"translateGraphRefDefSpec",fun:({SUBRULE:e})=>({astFactory:t},r)=>t.isGraphRefDefault(r)?"DEFAULT":e(Xu,r)},Ni={name:"translateGraphRef",fun:({SUBRULE:e})=>(t,r)=>{let n=t.astFactory;return n.isGraphRefAll(r)?"ALL":n.isGraphRefNamed(r)?"NAMED":e(Xt,r)}},Bu={name:"translateUpdateGraphLoad",fun:({SUBRULE:e})=>({algebraFactory:t},r)=>t.createLoad(e(fe,r.source),r.destination?e(fe,r.destination.graph):void 0,r.silent)};var So={name:"translateQuery",fun:({SUBRULE:e})=>(t,r,n,i)=>{var o;let a=t.astFactory;t.variables=new Set,t.varCount=0,t.useQuads=n!=null?n:!1;let s;if(e(To,r),a.isQuery(r)){e(bn,r.context);let l=(o=r.where)!=null?o:a.patternGroup([],a.gen());s=e(Be,l),s=e(wo,r,s)}else s=e(Oo,r);return i&&(s=e(yn,s)),s}};var Je={name:"translateExpression",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n)=>{if(t.isTerm(n))return r.createTermExpression(e(Q,n));if(t.isWildcard(n))return r.createWildcardExpression();if(t.isExpressionAggregate(n))return r.createAggregateExpression(n.aggregation,e(Je,n.expression[0]),n.distinct,t.isExpressionAggregateSeparator(n)?n.separator:void 0);if(t.isExpressionFunctionCall(n))return r.createNamedExpression(e(fe,n.function),n.args.map(i=>e(Je,i)));if(t.isExpressionOperator(n))return r.createOperatorExpression(n.operator,n.args.map(i=>e(Je,i)));if(t.isExpressionPatternOperation(n))return r.createExistenceExpression(n.operator==="notexists",e(Be,n.args));throw new Error(`Unknown expression: ${JSON.stringify(n)}`)}},Be={name:"translateGraphPattern",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r,useQuads:n},i)=>{if(t.isPatternBgp(i))return e(Ju,i);if(t.isPatternUnion(i))return r.createUnion(i.patterns.map(a=>e(Be,a)));if(t.isPatternGraph(i)){let a=t.patternGroup(i.patterns,i.loc),s=e(Be,a);return n?s=e(Xe,s,e(Q,i.name),void 0):s=r.createGraph(s,e(Q,i.name)),s}if(t.isPatternValues(i))return e(vn,i);if(t.isQuerySelect(i))return e(So,i,n,!1);if(t.isPatternGroup(i)){let a=[],s=[];for(let c of i.patterns)t.isPatternFilter(c)?a.push(c):s.push(c);let o=r.createBgp([]);for(let c of s)o=e(Zu,o,c);let l=a.map(c=>e(Je,c.expression));if(l.length>0){let c=l[0];for(let u of l.slice(1))c=r.createOperatorExpression("&&",[c,u]);o=r.createFilter(o,c)}return o}throw new Error(`Unexpected pattern: ${i.subType}`)}},Ju={name:"translateBgp",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n)=>{let i=[],a=[],s=[];e(Qt,n.triples,s);for(let o of s)if(t.isPathPure(o.predicate)){let c=e(No,o);for(let u of c)u.type===Ce.PATH?(i.length>0&&a.push(r.createBgp(i)),i=[],a.push(u)):i.push(u)}else i.push(e(hr,o));return i.length>0&&a.push(r.createBgp(i)),a.length===1?a[0]:r.createJoin(a)}},Zu={name:"accumulateGroupGraphPattern",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n,i)=>{if(t.isPatternOptional(i)){let s=e(Be,t.patternGroup(i.patterns,i.loc));return s.type===Ce.FILTER&&i.patterns.some(o=>t.isPatternFilter(o))?r.createLeftJoin(n,s.input,s.expression):r.createLeftJoin(n,s)}if(t.isPatternMinus(i)){let s=e(Be,t.patternGroup(i.patterns,i.loc));return r.createMinus(n,s)}if(t.isPatternBind(i))return r.createExtend(n,e(Q,i.variable),e(Je,i.expression));if(t.isPatternService(i)){let s=t.patternGroup(i.patterns,i.loc),o=r.createService(e(Be,s),e(Q,i.name),i.silent);return e(ko,n,o)}let a=e(Be,i);return e(ko,n,a)}},ko={name:"simplifiedJoin",fun:()=>({algebraFactory:e},t,r)=>(t.type===Ce.BGP&&r.type===Ce.BGP?t=e.createBgp([...t.patterns,...r.patterns]):t.type===Ce.BGP&&t.patterns.length===0?t=r:r.type===Ce.BGP&&r.patterns.length===0||(t=e.createJoin([t,r])),t)};var wo={name:"translateAggregates",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r,dataFactory:n},i,a)=>{var h,g;let s=[],o={},l=t.isQuerySelect(i)||t.isQueryDescribe(i)?i.variables.map(T=>e(jr,T,o)):void 0,c=i.solutionModifiers.having?i.solutionModifiers.having.having.map(T=>e(jr,T,o)):void 0,u=i.solutionModifiers.order?i.solutionModifiers.order.orderDefs.map(T=>e(jr,T,o)):void 0;if((h=i.solutionModifiers.group)!=null?h:Object.keys(o).length>0){let T=Object.keys(o).map(v=>e(Uu,o[v],n.variable(v))),x=[];if(i.solutionModifiers.group)for(let v of i.solutionModifiers.group.groupings)if(t.isTerm(v))x.push(e(Q,v));else{let A,y;"variable"in v?(A=e(Q,v.variable),y=v.value):(A=e(kt),y=v),a=r.createExtend(a,A,e(Je,y)),x.push(A)}a=r.createGroup(a,x,T)}if(c)for(let T of c)a=r.createFilter(a,e(Je,T));i.values&&(a=r.createJoin([a,e(vn,i.values)]));let p=[];if(l)if(l.some(T=>t.isWildcard(T)))p=[...e(Li,i).values()].map(T=>n.variable(T)).sort((T,x)=>T.value.localeCompare(x.value));else for(let T of l)t.isTerm(T)?p.push(e(Q,T)):(p.push(e(Q,T.variable)),s.push(T));for(let T of s)a=r.createExtend(a,e(Q,T.variable),e(Je,T.expression));if(u&&(a=r.createOrderBy(a,u.map(T=>{let x=e(Je,T.expression);return T.descending&&(x=r.createOperatorExpression("desc",[x])),x}))),t.isQuerySelect(i)&&(a=r.createProject(a,p)),i.distinct&&(a=r.createDistinct(a)),i.reduced&&(a=r.createReduced(a)),t.isQueryConstruct(i)){let T=[];e(Qt,i.template.triples,T),a=r.createConstruct(a,T.map(x=>e(hr,x)))}else t.isQueryAsk(i)?a=r.createAsk(a):t.isQueryDescribe(i)&&(a=r.createDescribe(a,p));let f=i.solutionModifiers.limitOffset;if(((f==null?void 0:f.limit)!==void 0||f!=null&&f.offset)&&(a=r.createSlice(a,(g=f.offset)!=null?g:0,f.limit)),i.datasets.clauses.length>0){let T=e(xn,i.datasets);a=r.createFrom(a,T.default,T.named)}return a}},jr={name:"mapAggregate",fun:({SUBRULE:e})=>({astFactory:t},r,n)=>{if(t.isExpressionAggregate(r)){let i=t.forcedAutoGenTree(r),a;for(let[o,l]of Object.entries(n))if((0,bb.default)(l,i)){a=t.termVariable(o,t.sourceLocation());break}if(a!==void 0)return a;let s=e(kt);return n[s.value]=i,t.termVariable(s.value,t.sourceLocation())}return t.isExpressionPure(r)&&!t.isExpressionPatternOperation(r)?{...r,args:r.args.map(i=>e(jr,i,n))}:"expression"in r&&r.expression?{...r,expression:e(jr,r.expression,n)}:r}},Uu={name:"translateBoundAggregate",fun:({SUBRULE:e})=>(t,r,n)=>({...e(Je,r),variable:n})};var vb=Jr.create([wo,jr,Uu]).addMany(fe,Q,bn,vn,xn,yn,To,Li,kt,No,Rt,En,Je,Be,Ju,Zu,ko,Dr,Qt,_i,Xe,hr,Oo,Yu,Qu,In,Xu,Xt,Ni,Bu,So);var ep=_n(zu(),1),xb="http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies",mr={name:"translateTerm",fun:e=>(t,r)=>{if(t.astFactory.isTermTriple(r))return t.dataFactory.quad(e.SUBRULE(mr,r.subject),e.SUBRULE(mr,r.predicate),e.SUBRULE(mr,r.object));if(t.astFactory.isTermLiteral(r)){if(!r.langOrIri)return t.dataFactory.literal(r.value);if(typeof r.langOrIri=="object"){let a=e.SUBRULE(fe,r.langOrIri);return t.dataFactory.literal(r.value,a)}let[n,i]=r.langOrIri.split("--");return i&&(i===""||i==="ltr"||i==="rtl")?t.dataFactory.literal(r.value,{language:n,direction:i}):t.dataFactory.literal(r.value,r.langOrIri)}return Q.fun(e)(t,r)}},tp={name:"translateTripleCollection",fun:e=>(t,r,n)=>{if(t.astFactory.isTripleCollectionReifiedTriple(r)){let{SUBRULE:i}=e,{dataFactory:a}=t,s=i(mr,r.identifier);i(rp,r.triples[0],n);let{subject:o,predicate:l,object:c}=n.pop(),u=a.quad(o,l,c);n.push({subject:s,predicate:a.namedNode(xb),object:u})}else Dr.fun(e)(t,r,n)}},rp={name:"translateTripleNesting",fun:e=>(t,r,n)=>{_i.fun(e)(t,r,n);let i=e.SUBRULE,{subject:a,predicate:s,object:o}=n.at(-1),{astFactory:l,dataFactory:c}=t;if(r.annotations&&r.annotations.length>0){let u=c.quad(a,s,o),p=new Set;for(let f of r.annotations){let h,g=l.isTripleCollection(f);g?h=i(mr,f.identifier):h=i(mr,f.val),p.has((0,ep.termToString)(h))||n.push({subject:h,predicate:c.namedNode(xb),object:u}),p.add((0,ep.termToString)(h)),g&&i(tp,f,n)}}}},Ab={name:"inScopeVariables",fun:()=>(e,t)=>{let r=new Set;return Te(t,r),r}};function Eb(e){return{...Wu(e),astFactory:new dr}}var TC=Jr.create(vb).widenContext().patchRule(mr).patchRule(tp).patchRule(rp).patchRule(Ab).typePatch();function np(e,t={}){let r=Eb(t);return TC.build().translateQuery(r,e,t.quads,t.blankToVariable)}var yC="http://base/",Bt=class extends Error{constructor(t){super(t),this.name="AlgebraError"}},ip;function Co(e,t={}){if(!e||!e.trim())throw new Bt("The query is empty.");ip||(ip=new mo);let r,n=t.baseIRI||yC;try{r=ip.parse(e,{baseIRI:n})}catch(i){throw new Bt(bC(i))}try{return np(r,{quads:!1,baseIRI:n})}catch(i){try{return np(r,{quads:!0,baseIRI:n})}catch(a){throw new Bt(i instanceof Error?i.message:String(i))}}}function bC(e){let t=e instanceof Error?e.message:String(e),r=t.split(`
|
|
121
|
+
`).map(i=>i.trimEnd()),n=[];for(let i of r)if(/^\s*<\[/.test(i)||/^\s*\[/.test(i)||(n.push(i),n.length>=4))break;return n.join(`
|
|
122
|
+
`).replace(/::\s*$/,".").trim()||t}var Oi="http://www.w3.org/2001/XMLSchema#",vC=new Set([`${Oi}integer`,`${Oi}decimal`,`${Oi}double`,`${Oi}boolean`]);function Ib(e,t={}){let r;for(let[n,i]of Object.entries(t))!i||!e.startsWith(i)||(!r||i.length>r[1].length)&&(r=[n,i]);if(r){let n=e.slice(r[1].length);if(/^[A-Za-z0-9_\-.:%]*$/.test(n)&&!n.endsWith("."))return`${r[0]}:${n}`}return`<${e}>`}function $(e,t={}){var r;if(e==null)return"";if(typeof e=="string")return e;switch(e.termType){case"Variable":return`?${e.value}`;case"NamedNode":return Ib(e.value,t);case"BlankNode":return`_:${e.value}`;case"DefaultGraph":return"";case"Literal":{let n=JSON.stringify(String(e.value)),i=e.language||e["xml:lang"];if(i)return`${n}@${i}`;let a=(r=e.datatype)==null?void 0:r.value;return!a||a===`${Oi}string`?n:vC.has(a)&&/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$|^(true|false)$/.test(e.value)?String(e.value):`${n}^^${Ib(a,t)}`}case"Quad":return ot(e,t);default:return typeof e.value=="string"?e.value:JSON.stringify(e)}}function ot(e,t={}){let r=[ap(e.subject,t),ap(e.predicate,t),ap(e.object,t)];return e.graph&&e.graph.termType!=="DefaultGraph"&&r.push(`@ ${$(e.graph,t)}`),r.join(" ")}function ap(e,t){return e&&typeof e=="object"&&!("termType"in e)&&typeof e.type=="string"?Ro(e,t):$(e,t)}function Ro(e,t={},r=void 0){if(!e||typeof e!="object")return String(e);if("termType"in e)return $(e,t);let n=(s,o)=>Ro(s,t,o),i;switch(e.type){case"link":return $(e.iri,t);case"inv":return`^${n(e.path,"unary")}`;case"seq":i=(e.input||[]).map(s=>n(s,"seq")).join("/");break;case"alt":i=(e.input||[]).map(s=>n(s,"alt")).join("|");break;case"ZeroOrMorePath":return`${n(e.path,"unary")}*`;case"OneOrMorePath":return`${n(e.path,"unary")}+`;case"ZeroOrOnePath":return`${n(e.path,"unary")}?`;case"nps":return`!(${(e.iris||[]).map(s=>$(s,t)).join("|")})`;default:return e.type}return r==="unary"||r==="seq"&&e.type==="alt"?`(${i})`:i}function vt(e,t={}){var r;if(e==null)return"";if(typeof e!="object")return String(e);if("termType"in e)return $(e,t);switch((r=e.subType)!=null?r:e.expressionType){case"term":return $(e.term,t);case"operator":{let n=(e.args||[]).map(i=>vt(i,t));return`(${e.operator} ${n.join(" ")})`.replace(" )",")")}case"named":{let n=(e.args||[]).map(i=>vt(i,t));return`(${$(e.name,t)} ${n.join(" ")})`.replace(" )",")")}case"aggregate":{let n=e.expression?vt(e.expression,t):"*",i=e.distinct?"distinct ":"",a=e.aggregator==="group_concat"&&e.separator!==void 0?` ${JSON.stringify(e.separator)}`:"";return`(${e.aggregator} ${i}${n}${a})`}case"existence":return`(${e.not?"notexists":"exists"} ...)`;case"wildcard":return"*";default:return e.operator?`(${e.operator})`:JSON.stringify(e)}}function Si(e,t){return`(${(e||[]).map(t).join(" ")})`}function sp(e,t){return(e||[]).map(r=>$(r,t)).join(" ")}function Ln(e,t={}){let r=(i,a,s=[],o)=>({operator:i,args:a||void 0,details:o&&o.length?o:void 0,children:s.filter(Boolean).map(l=>Ln(l,t))});if(!e||typeof e!="object")return r(String(e));let n=Array.isArray(e.input)?e.input:e.input?[e.input]:[];switch(e.type){case"bgp":return r("bgp",void 0,[],(e.patterns||[]).map(i=>ot(i,t)));case"path":return r("path",void 0,[],[ot({...e,predicate:e.predicate},t)]);case"join":case"union":case"minus":case"distinct":case"reduced":case"ask":return r(e.type,void 0,n);case"leftjoin":return r("leftjoin",e.expression?vt(e.expression,t):void 0,n);case"filter":return r("filter",vt(e.expression,t),n);case"extend":return r("extend",`${$(e.variable,t)} := ${vt(e.expression,t)}`,n);case"project":return r("project",sp(e.variables,t),n);case"orderby":return r("orderby",(e.expressions||[]).map(i=>vt(i,t)).join(" "),n);case"slice":{let i=[];return e.start&&i.push(`offset ${e.start}`),e.length!==void 0&&i.push(`limit ${e.length}`),r("slice",i.join(" "),n)}case"group":{let i=(e.aggregates||[]).map(a=>`${$(a.variable,t)} := ${vt(a,t)}`);return r("group",sp(e.variables,t),n,i)}case"graph":return r("graph",$(e.name,t),n);case"service":return r("service",`${e.silent?"silent ":""}${$(e.name,t)}`,n);case"values":{let i=(e.variables||[]).map(s=>$(s,t)),a=(e.bindings||[]).map(s=>`[${i.map(o=>{let l=s[o.slice(1)];return l===void 0?"UNDEF":$(l,t)}).join(" ")}]`);return r("values",i.join(" "),[],a)}case"from":{let i=[];for(let a of e.default||[])i.push(`from ${$(a,t)}`);for(let a of e.named||[])i.push(`from named ${$(a,t)}`);return r("dataset",void 0,n,i)}case"construct":return r("construct",void 0,n,(e.template||[]).map(i=>ot(i,t)));case"describe":return r("describe",sp(e.terms,t),n);case"deleteinsert":{let i=[];for(let a of e.delete||[])i.push(`delete ${ot(a,t)}`);for(let a of e.insert||[])i.push(`insert ${ot(a,t)}`);return r("modify",void 0,e.where?[e.where]:[],i)}case"compositeupdate":return r("update",void 0,e.updates||[]);case"load":return r("load",`${e.silent?"silent ":""}${$(e.source,t)}`+(e.destination?` into ${$(e.destination,t)}`:""));case"clear":case"drop":case"create":return r(e.type,`${e.silent?"silent ":""}${typeof e.source=="string"?e.source:$(e.source,t)}`);case"add":case"move":case"copy":return r(e.type,`${e.silent?"silent ":""}${Lb(e.source,t)} to ${Lb(e.destination,t)}`);case"nop":return r("nop");default:{let i=[];for(let[a,s]of Object.entries(e))a==="type"||a==="input"||a==="loc"||a==="RTT"||i.push(`${a}: ${Pb(s,t)}`);return r(String(e.type||"unknown"),void 0,n,i)}}}function Lb(e,t){return typeof e=="string"?e:$(e,t)}function Pb(e,t){return Array.isArray(e)?e.map(r=>Pb(r,t)).join(", "):e&&typeof e=="object"?"termType"in e?$(e,t):e.subType||e.expressionType?vt(e,t):typeof e.type=="string"&&/path|link|inv|seq|alt|nps/i.test(e.type)?Ro(e,t):JSON.stringify(e):String(e)}function Mo(e,t={}){let r=[];return Fo(e,t,0,r),r.join(`
|
|
123
|
+
`)}function Fo(e,t,r,n){var c,u;let i=" ".repeat(r),a=p=>n.push(i+p);if(!e||typeof e!="object"){a(String(e));return}let s=Array.isArray(e.input)?e.input:e.input?[e.input]:[],o=(p,f=s)=>{if(f.length===0){a(`(${p})`);return}a(`(${p}`);for(let h of f)Fo(h,t,r+1,n);n[n.length-1]+=")"},l=p=>vt(p,t);switch(e.type){case"bgp":if(!((c=e.patterns)!=null&&c.length)){a("(bgp)");return}a("(bgp");for(let p of e.patterns)n.push(`${i} (triple ${ot(p,t)})`);n[n.length-1]+=")";return;case"path":a(`(path ${ot(e,t)})`);return;case"join":case"union":case"minus":case"distinct":case"reduced":case"ask":o(e.type);return;case"leftjoin":o(e.expression?`leftjoin ${l(e.expression)}`:"leftjoin");return;case"filter":o(`filter ${l(e.expression)}`);return;case"extend":o(`extend ((${$(e.variable,t)} ${l(e.expression)}))`);return;case"project":o(`project ${Si(e.variables,p=>$(p,t))}`);return;case"orderby":o(`order ${Si(e.expressions,l)}`);return;case"slice":o(`slice ${(u=e.start)!=null?u:0} ${e.length===void 0?"_":e.length}`);return;case"group":o(`group ${Si(e.variables,p=>$(p,t))} ${Si(e.aggregates,p=>`(${$(p.variable,t)} ${l(p)})`)}`);return;case"graph":o(`graph ${$(e.name,t)}`);return;case"service":o(`service ${e.silent?"silent ":""}${$(e.name,t)}`);return;case"values":{let p=(e.variables||[]).map(f=>$(f,t));a(`(table (vars ${p.join(" ")})`);for(let f of e.bindings||[]){let h=p.map(g=>{let T=f[g.slice(1)];return T===void 0?void 0:`[${g} ${$(T,t)}]`}).filter(Boolean);n.push(`${i} (row ${h.join(" ")})`.replace("(row )","(row)"))}n[n.length-1]+=")";return}case"from":{let p=[...(e.default||[]).map(f=>$(f,t)),...(e.named||[]).map(f=>`(named ${$(f,t)})`)];o(`dataset (${p.join(" ")})`);return}case"construct":a("(construct");for(let p of e.template||[])n.push(`${i} (triple ${ot(p,t)})`);for(let p of s)Fo(p,t,r+1,n);n[n.length-1]+=")";return;case"describe":o(`describe ${Si(e.terms,p=>$(p,t))}`);return;case"deleteinsert":a("(modify");for(let p of e.delete||[])n.push(`${i} (delete (triple ${ot(p,t)}))`);for(let p of e.insert||[])n.push(`${i} (insert (triple ${ot(p,t)}))`);e.where&&Fo(e.where,t,r+1,n),n[n.length-1]+=")";return;case"compositeupdate":o("update",e.updates||[]);return;default:{let p=Ln(e,t);o([p.operator,p.args,...p.details||[]].filter(Boolean).join(" "))}}}var xC={"list-tree":'<path d="M21 12h-8"/><path d="M21 6H8"/><path d="M21 18h-8"/><path d="M3 6v4c0 1.1.9 2 2 2h3"/><path d="M3 10v6c0 1.1.9 2 2 2h3"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',"chevron-right":'<path d="m9 18 6-6-6-6"/>',copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',"rotate-ccw":'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>',"unfold-vertical":'<path d="M12 22v-6"/><path d="M12 8V2"/><path d="M4 12H2"/><path d="M10 12H8"/><path d="M16 12h-2"/><path d="M22 12h-2"/><path d="m15 19-3 3-3-3"/><path d="m15 5-3-3-3 3"/>',"fold-vertical":'<path d="M12 22v-6"/><path d="M12 8V2"/><path d="M4 12H2"/><path d="M10 12H8"/><path d="M16 12h-2"/><path d="M22 12h-2"/><path d="m15 19-3-3-3 3"/><path d="m15 5-3 3-3-3"/>'};function AC(e,t=16,r=1.75){return`<svg xmlns="http://www.w3.org/2000/svg" class="explain-icon explain-icon-${e}" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${r}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${xC[e]}</svg>`}function Gr(e,t,r){let n=document.createElement("template");return n.innerHTML=AC(e,t,r),n.content.firstElementChild}function wi(e,t,r,n){let i=document.createElement("button");i.type="button",i.className="explain-button",t&&i.appendChild(Gr(t,14));let a=document.createElement("span");return a.textContent=e,i.appendChild(a),n&&(i.title=n),i.addEventListener("click",r),i}async function EC(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){}try{let r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();let n=document.execCommand("copy");return r.remove(),n}catch(r){return!1}}function op(e,t="Copy"){let r=wi(t,"copy",async()=>{let n=await EC(e()),i=r.querySelector("span");i&&(i.textContent=n?"Copied":"Copy failed",setTimeout(()=>i.textContent=t,1500))});return r}function lp(e,t=!1){let r=document.createElement("section");r.className="explain-section";let n=document.createElement("div");n.className="explain-section-header";let i=document.createElement("button");i.type="button",i.className="explain-section-toggle",i.setAttribute("aria-expanded",String(!t)),i.appendChild(Gr("chevron-down",16));let a=document.createElement("span");a.className="explain-section-title",a.textContent=e,i.appendChild(a);let s=document.createElement("span");s.className="explain-section-status";let o=document.createElement("div");o.className="explain-section-actions",n.append(i,s,o);let l=document.createElement("div");return l.className="explain-section-body",r.append(n,l),r.classList.toggle("explain-section--collapsed",t),i.addEventListener("click",()=>{let c=r.classList.toggle("explain-section--collapsed");i.setAttribute("aria-expanded",String(!c))}),{root:r,body:l,actions:o,setStatus(c,u="muted"){s.textContent=c,s.className=`explain-section-status explain-section-status--${u}`}}}function Jt(e,t="muted"){let r=document.createElement("div");return r.className=`explain-message explain-message--${t}`,r.textContent=e,r}function Do(e){return e>=1e4?`${(e/1e3).toFixed(1)} s`:e>=100?`${Math.round(e)} ms`:e>=10?`${e.toFixed(1)} ms`:`${e.toFixed(2)} ms`}function _b(e){return e.toLocaleString("en-US")}function Nb(e){var r;let t=(r=e.timeMs)!=null?r:0;for(let n of e.children)t=Math.max(t,Nb(n));return t}function jo(e){return 1+e.children.reduce((t,r)=>t+jo(r),0)}function IC(e,t){let r=document.createElement("div");if(r.className="explain-plan",t&&t.length){let c=document.createElement("div");c.className="explain-summary";for(let u of t){let p=document.createElement("span");p.textContent=u,c.appendChild(p)}r.appendChild(c)}let n=Nb(e),i=n>0,a=document.createElement("div");a.className="explain-tree",a.setAttribute("role","tree");let s=[],o=i?Ob(e,n):void 0,l=(c,u,p)=>{let f=document.createElement("div");f.className="explain-node",f.setAttribute("role","treeitem"),c.cached&&f.classList.add("explain-node--cached"),c===o&&f.classList.add("explain-node--slowest"),c.status&&/not started|lazily|skipped/i.test(c.status)&&f.classList.add("explain-node--inactive");let h=document.createElement("div");h.className="explain-row",h.style.setProperty("--explain-depth",String(u));let g=document.createElement("button");g.type="button",g.className="explain-toggle",c.children.length?(g.appendChild(Gr("chevron-down",14)),g.setAttribute("aria-label","Collapse"),g.addEventListener("click",()=>{let N=f.classList.toggle("explain-node--collapsed");g.setAttribute("aria-label",N?"Expand":"Collapse"),f.setAttribute("aria-expanded",String(!N))}),f.setAttribute("aria-expanded","true")):(g.classList.add("explain-toggle--leaf"),g.tabIndex=-1),h.appendChild(g);let T=document.createElement("div");T.className="explain-row-main";let x=document.createElement("div");if(x.className="explain-label",x.textContent=c.label,c.cached){let N=document.createElement("span");N.className="explain-badge",N.textContent="cached",x.appendChild(N)}if(c.status&&!/^(completed|fully materialized)$/i.test(c.status)){let N=document.createElement("span");N.className="explain-badge explain-badge--status",N.textContent=c.status,x.appendChild(N)}T.appendChild(x);let v=[];if(c.columns&&c.columns.length&&v.push(c.columns.join(" ")),c.details&&c.details.length&&v.push(...c.details),v.length){let N=document.createElement("div");N.className="explain-meta";for(let X of v){let G=document.createElement("span");G.textContent=X,N.appendChild(G)}T.appendChild(N)}h.appendChild(T);let A=document.createElement("div");A.className="explain-stats";let y=document.createElement("span");y.className="explain-rows",y.textContent=c.rows!==void 0?`${_b(c.rows)} rows`:"";let L=document.createElement("span");L.className="explain-time",c.timeMs!==void 0&&(L.textContent=Do(c.timeMs),c.totalMs!==void 0&&c.totalMs!==c.timeMs&&(L.title=`This operation: ${Do(c.timeMs)}. With its children: ${Do(c.totalMs)}.`));let S=document.createElement("span");if(S.className="explain-bar",i&&c.timeMs!==void 0){let N=document.createElement("span");N.className="explain-bar-fill",N.style.width=`${Math.max(1,Math.round(c.timeMs/n*100))}%`,S.appendChild(N)}if(A.append(y,L,S),h.appendChild(A),f.appendChild(h),s.push(f),c.children.length){let N=document.createElement("div");N.className="explain-children",N.setAttribute("role","group");for(let X of c.children)l(X,u+1,N);f.appendChild(N)}p.appendChild(f)};return l(e,0,a),r.appendChild(a),i||r.classList.add("explain-plan--no-times"),{root:r,expandAll:()=>s.forEach(c=>c.classList.remove("explain-node--collapsed")),collapseAll:()=>s.forEach(c=>{c.querySelector(":scope > .explain-children")&&c.classList.add("explain-node--collapsed")})}}function Ob(e,t){if(e.timeMs===t&&!e.cached)return e;for(let r of e.children){let n=Ob(r,t);if(n)return n}return e.timeMs===t?e:void 0}function LC(e){let t=document.createElement("pre");return t.className="explain-text",t.textContent=e,t}function PC(e){let t=document.createElement("iframe");return t.className="explain-frame",t.setAttribute("sandbox",""),t.setAttribute("referrerpolicy","no-referrer"),t.title="Execution plan",t.srcdoc=e,t}function Sb(e){let t=document.createElement("div");t.className="explain-tree explain-algebra",t.setAttribute("role","tree");let r=[],n=(i,a,s)=>{let o=document.createElement("div");o.className="explain-node",o.setAttribute("role","treeitem");let l=document.createElement("div");l.className="explain-row",l.style.setProperty("--explain-depth",String(a));let c=document.createElement("button");c.type="button",c.className="explain-toggle",i.children.length?(c.appendChild(Gr("chevron-down",14)),c.setAttribute("aria-label","Collapse"),c.addEventListener("click",()=>{let h=o.classList.toggle("explain-node--collapsed");c.setAttribute("aria-label",h?"Expand":"Collapse"),o.setAttribute("aria-expanded",String(!h))}),o.setAttribute("aria-expanded","true")):(c.classList.add("explain-toggle--leaf"),c.tabIndex=-1),l.appendChild(c);let u=document.createElement("div");u.className="explain-row-main";let p=document.createElement("div");p.className="explain-label";let f=document.createElement("span");if(f.className="explain-operator",f.textContent=i.operator,p.appendChild(f),i.args){let h=document.createElement("span");h.className="explain-args",h.textContent=i.args,p.appendChild(h)}if(u.appendChild(p),i.details&&i.details.length){let h=document.createElement("div");h.className="explain-meta explain-meta--code";for(let g of i.details){let T=document.createElement("span");T.textContent=g,h.appendChild(T)}u.appendChild(h)}if(l.appendChild(u),o.appendChild(l),r.push(o),i.children.length){let h=document.createElement("div");h.className="explain-children",h.setAttribute("role","group");for(let g of i.children)n(g,a+1,h);o.appendChild(h)}s.appendChild(o)};return n(e,0,t),{root:t,expandAll:()=>r.forEach(i=>i.classList.remove("explain-node--collapsed")),collapseAll:()=>r.forEach(i=>{i.querySelector(":scope > .explain-children")&&i.classList.add("explain-node--collapsed")})}}function wb(e){switch(e.kind){case"tree":{let t=IC(e.root,e.summary);return{root:t.root,tree:t,text:cp(e.root,e.summary)}}case"text":return{root:LC(e.text),text:e.text};case"html":return{root:PC(e.html),text:e.html}}}function cp(e,t){let r=[];t&&t.length&&r.push(...t,"");let n=(i,a)=>{let s=[];i.rows!==void 0&&s.push(`${_b(i.rows)} rows`),i.timeMs!==void 0&&s.push(Do(i.timeMs)),i.cached&&s.push("cached"),i.status&&!/^(completed|fully materialized)$/i.test(i.status)&&s.push(i.status),r.push(`${" ".repeat(a)}${i.label}${s.length?` [${s.join(", ")}]`:""}`);for(let o of i.details||[])r.push(`${" ".repeat(a+1)}${o}`);for(let o of i.children)n(o,a+1)};return n(e,0),r.join(`
|
|
124
|
+
`)}var _C={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",xsd:"http://www.w3.org/2001/XMLSchema#",owl:"http://www.w3.org/2002/07/owl#"},up=class{constructor(t,r={}){this.priority=1;this.label="Explain";this.helpReference="https://github.com/Matdata-eu/yasgui-explain-plugin#readme";this.container=null;this.hostToolbarNodes=[];this.abortController=null;this.planCache=new Map;this.planState=null;this.planSection=null;this.yasr=t,this.options=r}setOptions(t){this.options={...this.options,...t}}static get label(){return"Explain"}static get priority(){return 1}getIcon(){let t=Gr("list-tree",18);return t.setAttribute("aria-label","Explain view"),t}canHandleResults(){return!!this.yasr.results}getPluginName(){let t=this.yasr.plugins||{};for(let[r,n]of Object.entries(t))if(n===this)return r;return"Explain"}getOptions(){var r,n,i;let t=(i=(n=(r=this.yasr.config)==null?void 0:r.plugins)==null?void 0:n[this.getPluginName()])==null?void 0:i.dynamicConfig;return{...this.options,...t&&typeof t=="object"?t:{}}}getPrefixes(){var r;let t={};try{if(typeof this.yasr.getPrefixes=="function")t=this.yasr.getPrefixes()||{};else{let n=(r=this.yasr.config)==null?void 0:r.prefixes;typeof n=="function"?t=n()||{}:n&&typeof n=="object"&&(t=n)}}catch(n){}return{..._C,...t}}readQueryAndEndpoint(t){var n,i;let r=_p(this.yasr);this.query=(n=t.getQuery?t.getQuery():void 0)!=null?n:r.query,this.endpoint=(i=t.getEndpoint?t.getEndpoint():void 0)!=null?i:r.endpoint}serverHeader(){var t,r,n,i,a,s,o;try{let l=(a=(r=(t=this.yasr.results)==null?void 0:t.res)==null?void 0:r.headers)!=null?a:(i=(n=this.yasr.results)==null?void 0:n.getHeaders)==null?void 0:i.call(n);if(l&&typeof l.get=="function")return l.get("server");if(l&&typeof l=="object")return(o=(s=l.server)!=null?s:l.Server)!=null?o:null}catch(l){}return null}resolveEngine(t){let r=Ko(this.endpoint);return vp(r,this.endpoint,this.serverHeader(),t.engine)}draw(){this.cleanup();let t=this.getOptions();this.readQueryAndEndpoint(t);let r=document.createElement("div");r.className="yasgui-explain-plugin",this.container=r;let n=this.resolveEngine(t);this.drawToolbar(r,t,n),this.planSection=lp("Execution plan"),r.appendChild(this.planSection.root),this.drawPlanSection(t,n),r.appendChild(this.drawAlgebraSection(t)),this.yasr.resultsEl.appendChild(r)}drawToolbar(t,r,n){let i=Ip(this.yasr),a=!!i,s=[],o=document.createElement("label");o.className=a?"yasr_toolbarSelect":"explain-field";let l=document.createElement("span");l.textContent="Engine";let c=document.createElement("select");c.className=a?"":"explain-select",c.setAttribute("aria-label","Engine of the endpoint");let u=(g,T)=>{let x=document.createElement("option");x.value=g,x.textContent=T,c.appendChild(x)},p=n.source==="detected"&&n.engine?` (${n.engine.label})`:"";u("auto",`Detect${p}`);for(let g of r.engines||Ci)tr[g]&&u(g,tr[g].label);u("none","No plan");let f=r.engine&&r.engine!=="auto"?r.engine:Ko(this.endpoint);c.value=On(f)?f:"auto",c.disabled=!!r.engine&&r.engine!=="auto",c.addEventListener("change",()=>{let g=c.value;On(g)&&(Ep(this.endpoint,g),this.draw())}),o.append(l,c),s.push(o);let h=wi("Refresh plan","rotate-ccw",()=>{this.planState&&this.planCache.delete(this.planState.key),this.draw()},"Ask the engine for the plan again");if(a&&(h.className="yasr_toolbarButton"),h.disabled=!n.engine,s.push(h),i){for(let g of s)i.appendChild(g);this.hostToolbarNodes=s}else{let g=document.createElement("div");g.className="explain-toolbar";for(let T of s)g.appendChild(T);t.appendChild(g)}}drawPlanSection(t,r){let n=this.planSection;if(!n)return;if(n.body.replaceChildren(),n.actions.replaceChildren(),this.planState=null,!r.engine){n.setStatus(""),n.body.appendChild(Jt(r.source==="none"?"No engine recognised for this endpoint. Pick it in the Engine list when it is QLever, GraphDB, Stardog, Blazegraph or Neptune; other engines publish no plan over the SPARQL protocol.":"No plan is asked for this endpoint. Pick an engine in the Engine list to fetch one."));return}if(!this.query||!this.endpoint){n.setStatus(""),n.body.appendChild(Jt("The plugin cannot read the query and the endpoint of this tab."));return}let i=r.engine,a=`${i.id}
|
|
125
|
+
${this.endpoint}
|
|
126
|
+
${this.query}`;n.setStatus(i.label);let s=this.planCache.get(a);if(s){this.showPlan({engine:i,key:a,status:"done",plan:s});return}if(t.autoFetch===!1){this.planState={engine:i,key:a,status:"error"},n.body.appendChild(Jt(`Press "Refresh plan" to ask ${i.label} for the plan.`));return}this.fetchPlan(i,a)}async fetchPlan(t,r){var s;let n=this.planSection;if(!n||!this.query||!this.endpoint)return;(s=this.abortController)==null||s.abort();let i=new AbortController;this.abortController=i,this.planState={engine:t,key:r,status:"loading"},n.body.replaceChildren(Jt(`Asking ${t.label} for the plan\u2026`,"info"));let a;try{a=t.buildRequest(this.query,this.endpoint)}catch(o){this.showPlan({engine:t,key:r,status:"error",error:o instanceof Error?o.message:String(o)});return}try{let o=await this.runRequest(t,a,i.signal);if(i.signal.aborted)return;let{body:l,contentType:c,status:u}=await NC(o);if(u!==void 0&&u>=400){let f=a.endpoint?` from ${a.endpoint}`:"",h=u===404&&a.endpoint?" The server does not expose this explain URL; a proxy in front of the endpoint may only forward queries.":"";throw new Error(`HTTP ${u}${f}${l?`: ${l.slice(0,500)}`:""}.${h}`.replace("..","."))}let p=t.parse(l,c);if(this.planCache.set(r,p),i.signal.aborted)return;this.showPlan({engine:t,key:r,status:"done",plan:p})}catch(o){if(i.signal.aborted)return;let l=o instanceof Error?o.message:String(o);this.showPlan({engine:t,key:r,status:"error",error:l})}finally{this.abortController===i&&(this.abortController=null)}}async runRequest(t,r,n){let i=this.getOptions().requestPlan;if(i)return i(r,n);if(Pp(this.yasr)&&(!t.needsRequestOptions||Lp(this.yasr)))return this.yasr.executeQuery(r.query,{acceptHeader:r.accept,signal:n,extraArgs:r.extraArgs,endpoint:r.endpoint});let a=r.endpoint||this.endpoint,s=new URLSearchParams;s.set("query",r.query);for(let[c,u]of Object.entries(r.extraArgs||{}))s.set(c,u);let o=await fetch(a,{method:"POST",headers:{Accept:r.accept,"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),signal:n,mode:"cors"}),l=await o.text();return{status:o.status,headers:o.headers,content:l}}showPlan(t){let r=this.planSection;if(!r)return;if(this.planState=t,r.body.replaceChildren(),r.actions.replaceChildren(),t.status==="error"||!t.plan){r.setStatus(`${t.engine.label}: failed`,"error"),r.body.appendChild(Jt(t.error||"No plan.","error")),r.body.appendChild(Jt(t.engine.description));return}let n=wb(t.plan),i=t.plan.kind==="tree"?jo(t.plan.root):void 0;r.setStatus(i!==void 0?`${t.engine.label} \xB7 ${i} operations`:t.engine.label),n.tree&&this.addTreeActions(r.actions,n.tree),n.text!==void 0&&t.plan.kind!=="html"&&r.actions.appendChild(op(()=>n.text||"")),r.body.appendChild(n.root)}addTreeActions(t,r){t.appendChild(wi("Expand all","unfold-vertical",()=>r.expandAll())),t.appendChild(wi("Collapse all","fold-vertical",()=>r.collapseAll()))}drawAlgebraSection(t){let r=lp("Algebra");if(this.algebra=void 0,this.algebraError=void 0,this.algebraText=void 0,!this.query)return r.body.appendChild(Jt("The plugin cannot read the query of this tab.")),r.root;let n=this.getPrefixes(),i;try{this.algebra=Co(this.query,{baseIRI:t.baseIRI}),i=Ln(this.algebra,n),this.algebraText=Mo(this.algebra,n)}catch(s){return this.algebraError=s instanceof Bt?s.message:String(s),r.setStatus("syntax error","error"),r.body.appendChild(Jt(this.algebraError,"error")),r.root}r.setStatus(`${jo(i)} operations`);let a=Sb(i);return this.addTreeActions(r.actions,a),r.actions.appendChild(op(()=>this.algebraText||"","Copy")),r.body.appendChild(a.root),r.root}download(t){var i;let r=[];if((i=this.planState)!=null&&i.plan){r.push(`# Execution plan (${this.planState.engine.label})`,"");let a=this.planState.plan;r.push(a.kind==="tree"?cp(a.root,a.summary):a.kind==="text"?a.text:a.html),r.push("")}if(this.algebraText&&r.push("# Algebra","",this.algebraText,""),r.length===0)return;let n=(t||"query").replace(/\.[a-z0-9]+$/i,"");return{getData:()=>r.join(`
|
|
127
|
+
`),contentType:"text/plain",filename:`${n}-explain.txt`,title:"Download the plan and the algebra"}}cleanup(){var t,r;(t=this.abortController)==null||t.abort(),this.abortController=null;for(let n of this.hostToolbarNodes)n.remove();this.hostToolbarNodes=[],(r=this.container)==null||r.remove(),this.container=null,this.planSection=null}destroy(){this.cleanup(),this.planCache.clear()}};async function NC(e){let t=typeof(e==null?void 0:e.content)=="string"?e.content:void 0;t===void 0&&typeof(e==null?void 0:e.data)=="string"&&(t=e.data),t===void 0&&typeof(e==null?void 0:e.text)=="function"&&(t=await e.text()),t===void 0&&e&&typeof e=="object"&&!("status"in e)&&(t=JSON.stringify(e));let r,n=e==null?void 0:e.headers;return n&&typeof n.get=="function"?r=n.get("content-type")||void 0:n&&typeof n=="object"&&(r=n["content-type"]||n["Content-Type"]),{body:t!=null?t:"",contentType:r,status:e==null?void 0:e.status}}var Go=up;typeof window!="undefined"&&window.Yasgui&&window.Yasgui.Yasr&&window.Yasgui.Yasr.registerPlugin("Explain",Go);var OC=Go;return jb(SC);})();
|
|
128
|
+
/*! Bundled license information:
|
|
129
|
+
|
|
130
|
+
@traqula/chevrotain/dist/esm/lib/index.js:
|
|
131
|
+
(*! Bundled license information:
|
|
132
|
+
|
|
133
|
+
lodash-es/lodash.js:
|
|
134
|
+
(**
|
|
135
|
+
* @license
|
|
136
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
137
|
+
* Build: `lodash modularize exports="es" --repo lodash/lodash#4.18.1 -o ./`
|
|
138
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
139
|
+
* Released under MIT license <https://lodash.com/license>
|
|
140
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
141
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
142
|
+
*)
|
|
143
|
+
*)
|
|
144
|
+
*/
|
|
145
|
+
YasguiExplainPlugin = YasguiExplainPlugin.default;
|
|
146
|
+
//# sourceMappingURL=yasgui-explain-plugin.min.js.map
|