@matdata/yasgui-explain-plugin 1.0.0 → 1.1.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/README.md +5 -4
- package/dist/ExplainPlugin.d.ts +1 -1
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/tripletrail.d.ts +18 -0
- package/dist/engines/tripletrail.d.ts.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/yasgui-explain-plugin.cjs.js +91 -8
- package/dist/yasgui-explain-plugin.cjs.js.map +4 -4
- package/dist/yasgui-explain-plugin.esm.js +91 -8
- package/dist/yasgui-explain-plugin.esm.js.map +4 -4
- package/dist/yasgui-explain-plugin.min.js +55 -54
- package/dist/yasgui-explain-plugin.min.js.map +4 -4
- package/package.json +5 -4
|
@@ -1,65 +1,66 @@
|
|
|
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=
|
|
3
|
-
`)return a;a++}return e.length}function
|
|
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")]}}
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
`:case"\r":case"\u2028":case"\u2029":
|
|
10
|
-
`:case"\r":case"\u2028":case"\u2029":case"
|
|
1
|
+
"use strict";var YasguiExplainPlugin=(()=>{var Mb=Object.create;var Pn=Object.defineProperty;var Db=Object.getOwnPropertyDescriptor;var jb=Object.getOwnPropertyNames;var Gb=Object.getPrototypeOf,$b=Object.prototype.hasOwnProperty;var Vb=(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})},fp=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jb(t))!$b.call(e,i)&&i!==r&&Pn(e,i,{get:()=>t[i],enumerable:!(n=Db(t,i))||n.enumerable});return e};var _n=(e,t,r)=>(r=e!=null?Mb(Gb(e)):{},fp(t||!e||!e.__esModule?Pn(r,"default",{value:e,enumerable:!0}):r,e)),Hb=e=>fp(Pn({},"__esModule",{value:!0}),e);var H=(e,t,r)=>Vb(e,typeof t!="symbol"?t+"":t,r);var sb=lt((PD,ab)=>{"use strict";ab.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 Mu=lt(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.BlankNode=void 0;var Fu=class{constructor(t){this.termType="BlankNode",this.value=t}equals(t){return!!t&&t.termType==="BlankNode"&&t.value===this.value}};bo.BlankNode=Fu});var Du=lt(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.DefaultGraph=void 0;var Pi=class{constructor(){this.termType="DefaultGraph",this.value=""}equals(t){return!!t&&t.termType==="DefaultGraph"}};xo.DefaultGraph=Pi;Pi.INSTANCE=new Pi});var Ao=lt(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.NamedNode=void 0;var ju=class{constructor(t){this.termType="NamedNode",this.value=t}equals(t){return!!t&&t.termType==="NamedNode"&&t.value===this.value}};vo.NamedNode=ju});var $u=lt(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.Literal=void 0;var Gu=Ao(),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)}};Eo.Literal=An;An.RDF_LANGUAGE_STRING=new Gu.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");An.RDF_DIRECTIONAL_LANGUAGE_STRING=new Gu.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString");An.XSD_STRING=new Gu.NamedNode("http://www.w3.org/2001/XMLSchema#string")});var Hu=lt(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.Quad=void 0;var Vu=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)}};Io.Quad=Vu});var qu=lt(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.Variable=void 0;var Ku=class{constructor(t){this.termType="Variable",this.value=t}equals(t){return!!t&&t.termType==="Variable"&&t.value===this.value}};Lo.Variable=Ku});var ub=lt(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.DataFactory=void 0;var fC=Mu(),hC=Du(),cb=$u(),mC=Ao(),gC=Hu(),TC=qu(),yC=0,zu=class{constructor(t){var r;this.blankNodeCounter=0,t=t!=null?t:{},this.blankNodePrefix=(r=t.blankNodePrefix)!==null&&r!==void 0?r:`df_${yC++}_`}namedNode(t){return new mC.NamedNode(t)}blankNode(t){return new fC.BlankNode(t!=null?t:`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(t,r){return new cb.Literal(t,r)}variable(t){return new TC.Variable(t)}defaultGraph(){return hC.DefaultGraph.INSTANCE}quad(t,r,n,i){return new gC.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(cb.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}};Po.DataFactory=zu});var _o=lt(Qe=>{"use strict";var bC=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)&&bC(t,e,r)};Object.defineProperty(Qe,"__esModule",{value:!0});Mr(Mu(),Qe);Mr(ub(),Qe);Mr(Du(),Qe);Mr($u(),Qe);Mr(Ao(),Qe);Mr(Hu(),Qe);Mr(qu(),Qe)});var gb=lt(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.termToString=Wt;Ct.getLiteralValue=db;Ct.getLiteralType=fb;Ct.getLiteralLanguage=hb;Ct.getLiteralDirection=mb;Ct.stringToTerm=Yt;Ct.quadToStringQuad=vC;Ct.stringQuadToQuad=AC;var xC=_o(),pb=new xC.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 db(e){let t=/^"([^]*)"/.exec(e);if(!t)throw new Error(e+" is not a literal");return t[1]}function fb(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 hb(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 mb(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||pb,!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=hb(e),n=mb(e),i=t.namedNode(fb(e));return t.literal(db(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 vC(e){return{subject:Wt(e.subject),predicate:Wt(e.predicate),object:Wt(e.object),graph:Wt(e.graph)}}function AC(e,t){return t=t||pb,t.quad(Yt(e.subject,t),Yt(e.predicate,t),Yt(e.object,t),Yt(e.graph,t))}});var Wu=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=gb();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 MC={};Ze(MC,{AlgebraError:()=>Bt,ENGINES:()=>tr,ENGINE_IDS:()=>Ri,ExplainPlugin:()=>$o,default:()=>FC,detectEngine:()=>Ho,toSExpression:()=>Do,toTree:()=>Ln,translate:()=>Ro});var Kb="application/qlever-results+json";function Tr(e){return typeof e=="number"&&Number.isFinite(e)}function ki(e){return e.toLocaleString("en-US")}function qb(e,t){return t&&typeof t=="object"?`${e}: ${JSON.stringify(t)}`:`${e}: ${String(t)}`}function hp(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(qb(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(hp):[]}}function Nn(e){if(Tr(e))return`${ki(e)} ms`;if(typeof e=="string")return e}function zb(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:hp(n),summary:i}}var mp={id:"qlever",label:"QLever",description:"The operations QLever executed, with the time and rows of each.",needsRequestOptions:!1,buildRequest(e){return{query:e,accept:Kb,extraArgs:{send:"1"}}},parse(e){return zb(e)}};var Wb="http://www.ontotext.com/explain";function Yb(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 <${Wb}>`,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=Xb(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 Xb(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 Bb(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 gp={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:Yb(e),accept:"text/plain, application/sparql-results+json;q=0.9, */*;q=0.1"}},parse(e,t){return Bb(e,t)}};function Jb(e){let[t,r]=Zb(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 Zb(e){let t=e.search(/[?#]/);return t<0?[e,""]:[e.slice(0,t),e.slice(t)]}function Ub(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 Tp={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:Jb(t)}},parse(e){return Ub(e)}};function ex(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 yp={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 ex(e,t)}};function tx(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 bp={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 tx(e,t)}};function rx(e){let t=e.search(/[?#]/),[r,n]=t<0?[e,""]:[e.slice(0,t),e.slice(t)],i=r.replace(/\/+$/,"");return/\/(sparql|query|update)$/i.test(i)?i.replace(/\/(sparql|query|update)$/i,"/explain")+n:/\/explain$/i.test(i)?i+n:`${i}/explain${n}`}var Ci=e=>typeof e=="number"&&Number.isFinite(e),xp=e=>Ci(e)?e*1e3:void 0;function vp(e){return{label:String((e==null?void 0:e.name)||"step").replace(/\s+/g," ").trim(),rows:Ci(e==null?void 0:e["number of results"])?e["number of results"]:void 0,timeMs:xp(e==null?void 0:e["duration in seconds"]),children:Array.isArray(e==null?void 0:e.children)?e.children.map(vp):[]}}function nx(e){var o;let t=e.trim();if(!t)throw new Error("TripleTrail returned an empty response.");let r;try{r=JSON.parse(t)}catch(l){throw new Error("TripleTrail did not return JSON. Is this endpoint a TripleTrail server?")}if(!r||typeof r!="object"||r.head||r.results||"boolean"in r)throw new Error("The endpoint returned results instead of a plan. Is this endpoint a TripleTrail server?");let n=[];Ci(r.rows)&&n.push(`Result size: ${r.rows.toLocaleString("en-US")} rows`);let i=xp((o=r.plan)==null?void 0:o["planning duration in seconds"]);i!==void 0&&n.push(`Query planning: ${i.toFixed(2)} ms`);let a=r.spatial&&typeof r.spatial=="object"?r.spatial:{};if(a.filters||a.joins){let l=Ci(a.lookup_ms)?`, index lookup ${a.lookup_ms.toFixed(1)} ms`:"";n.push(`Spatial: ${a.filters||0} filters, ${a.joins||0} joins, ${a.candidates||0} candidates${l}`)}if(Array.isArray(a.decisions))for(let l of a.decisions)n.push(`Spatial rewrite: ${String(l)}`);let s=r.plan&&(r.plan.plan||(r.plan.name?r.plan:void 0));return s&&typeof s=="object"?{kind:"tree",root:vp(s),summary:n}:(r.restricted&&n.push("The plan is left out: you may read only some of the graphs, and the plan is chosen from all of them."),{kind:"text",text:n.join(`
|
|
5
|
+
`)||"No plan."})}var Ap={id:"tripletrail",label:"TripleTrail",description:"The plan TripleTrail ran, with the rows and time of each step.",needsRequestOptions:!0,buildRequest(e,t){return{query:e,accept:"application/json",endpoint:rx(t)}},parse(e){return nx(e)}};var tr={qlever:mp,graphdb:gp,stardog:Tp,blazegraph:yp,neptune:bp,tripletrail:Ap},Ri=["qlever","graphdb","stardog","blazegraph","neptune","tripletrail"];function Ep(e){return typeof e=="string"&&e in tr}function On(e){return e==="auto"||e==="none"||Ep(e)}function Ho(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(r.includes("tripletrail"))return"tripletrail";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 Ip(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(Ep(i))return{engine:tr[i],source:a};let s=Ho(t,r);return s?{engine:tr[s],source:"detected"}:{engine:void 0,source:"none"}}var Lp="yasgui-explain-plugin:engines";function Pp(){try{let e=window.localStorage.getItem(Lp);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 qo(e){var t;return e&&(t=Pp()[Ko(e)])!=null?t:"auto"}function _p(e,t){if(e)try{let r=Pp();t==="auto"?delete r[Ko(e)]:r[Ko(e)]=t,window.localStorage.setItem(Lp,JSON.stringify(r))}catch(r){}}function Ko(e){return e.trim().replace(/\/+$/,"")}function Np(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 Op(e){var t;return!!((t=e==null?void 0:e.hostApi)!=null&&t.queryRequest)&&typeof e.executeQuery=="function"}function Sp(e){return typeof(e==null?void 0:e.executeQuery)=="function"}function wp(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 Fi=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 ix=typeof global=="object"&&global&&global.Object===Object&&global,Fd=ix,ax=typeof self=="object"&&self&&self.Object===Object&&self,sx=Fd||ax||Function("return this")(),Et=sx,ox=Et.Symbol,et=ox,Md=Object.prototype,lx=Md.hasOwnProperty,cx=Md.toString,Sn=et?et.toStringTag:void 0;function ux(e){var t=lx.call(e,Sn),r=e[Sn];try{e[Sn]=void 0;var n=!0}catch(a){}var i=cx.call(e);return n&&(t?e[Sn]=r:delete e[Sn]),i}var px=ux,dx=Object.prototype,fx=dx.toString;function hx(e){return fx.call(e)}var mx=hx,gx="[object Null]",Tx="[object Undefined]",kp=et?et.toStringTag:void 0;function yx(e){return e==null?e===void 0?Tx:gx:kp&&kp in Object(e)?px(e):mx(e)}var ir=yx;function bx(e){return e!=null&&typeof e=="object"}var pt=bx,xx="[object Symbol]";function vx(e){return typeof e=="symbol"||pt(e)&&ir(e)==xx}var aa=vx;function Ax(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=Ax,Ex=Array.isArray,V=Ex,Ix=1/0,Cp=et?et.prototype:void 0,Rp=Cp?Cp.toString:void 0;function Dd(e){if(typeof e=="string")return e;if(V(e))return Kn(e,Dd)+"";if(aa(e))return Rp?Rp.call(e):"";var t=e+"";return t=="0"&&1/e==-Ix?"-0":t}var Lx=Dd,Px=/\s/;function _x(e){for(var t=e.length;t--&&Px.test(e.charAt(t)););return t}var Nx=_x,Ox=/^\s+/;function Sx(e){return e&&e.slice(0,Nx(e)+1).replace(Ox,"")}var wx=Sx;function kx(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var tt=kx,Fp=NaN,Cx=/^[-+]0x[0-9a-f]+$/i,Rx=/^0b[01]+$/i,Fx=/^0o[0-7]+$/i,Mx=parseInt;function Dx(e){if(typeof e=="number")return e;if(aa(e))return Fp;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=wx(e);var r=Rx.test(e);return r||Fx.test(e)?Mx(e.slice(2),r?2:8):Cx.test(e)?Fp:+e}var jx=Dx,Mp=1/0,Gx=17976931348623157e292;function $x(e){if(!e)return e===0?e:0;if(e=jx(e),e===Mp||e===-Mp){var t=e<0?-1:1;return t*Gx}return e===e?e:0}var Vx=$x;function Hx(e){var t=Vx(e),r=t%1;return t===t?r?t-r:t:0}var qn=Hx;function Kx(e){return e}var zn=Kx,qx="[object AsyncFunction]",zx="[object Function]",Wx="[object GeneratorFunction]",Yx="[object Proxy]";function Qx(e){if(!tt(e))return!1;var t=ir(e);return t==zx||t==Wx||t==qx||t==Yx}var Gt=Qx,Xx=Et["__core-js_shared__"],zo=Xx,Dp=(function(){var e=/[^.]+$/.exec(zo&&zo.keys&&zo.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Bx(e){return!!Dp&&Dp in e}var Jx=Bx,Zx=Function.prototype,Ux=Zx.toString;function ev(e){if(e!=null){try{return Ux.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var Er=ev,tv=/[\\^$.*+?()[\]{}|]/g,rv=/^\[object .+?Constructor\]$/,nv=Function.prototype,iv=Object.prototype,av=nv.toString,sv=iv.hasOwnProperty,ov=RegExp("^"+av.call(sv).replace(tv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lv(e){if(!tt(e)||Jx(e))return!1;var t=Gt(e)?ov:rv;return t.test(Er(e))}var cv=lv;function uv(e,t){return e==null?void 0:e[t]}var pv=uv;function dv(e,t){var r=pv(e,t);return cv(r)?r:void 0}var Ir=dv,fv=Ir(Et,"WeakMap"),Uo=fv,jp=Object.create,hv=(function(){function e(){}return function(t){if(!tt(t))return{};if(jp)return jp(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),mv=hv;function gv(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 Tv=gv;function yv(){}var Ee=yv;function bv(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var xv=bv,vv=800,Av=16,Ev=Date.now;function Iv(e){var t=0,r=0;return function(){var n=Ev(),i=Av-(n-r);if(r=n,i>0){if(++t>=vv)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Lv=Iv;function Pv(e){return function(){return e}}var _v=Pv,Nv=(function(){try{var e=Ir(Object,"defineProperty");return e({},"",{}),e}catch(t){}})(),Qi=Nv,Ov=Qi?function(e,t){return Qi(e,"toString",{configurable:!0,enumerable:!1,value:_v(t),writable:!0})}:zn,Sv=Ov,wv=Lv(Sv),kv=wv;function Cv(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var jd=Cv;function Rv(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 Gd=Rv;function Fv(e){return e!==e}var Mv=Fv;function Dv(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var jv=Dv;function Gv(e,t,r){return t===t?jv(e,t,r):Gd(e,Mv,r)}var hl=Gv;function $v(e,t){var r=e==null?0:e.length;return!!r&&hl(e,t,0)>-1}var $d=$v,Vv=9007199254740991,Hv=/^(?:0|[1-9]\d*)$/;function Kv(e,t){var r=typeof e;return t=t==null?Vv:t,!!t&&(r=="number"||r!="symbol"&&Hv.test(e))&&e>-1&&e%1==0&&e<t}var sa=Kv;function qv(e,t,r){t=="__proto__"&&Qi?Qi(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var ml=qv;function zv(e,t){return e===t||e!==e&&t!==t}var Wn=zv,Wv=Object.prototype,Yv=Wv.hasOwnProperty;function Qv(e,t,r){var n=e[t];(!(Yv.call(e,t)&&Wn(n,r))||r===void 0&&!(t in e))&&ml(e,t,r)}var oa=Qv;function Xv(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?ml(r,o,l):oa(r,o,l)}return r}var Yn=Xv,Gp=Math.max;function Bv(e,t,r){return t=Gp(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=Gp(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),Tv(e,this,o)}}var Jv=Bv;function Zv(e,t){return kv(Jv(e,t,zn),e+"")}var gl=Zv,Uv=9007199254740991;function eA(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Uv}var Tl=eA;function tA(e){return e!=null&&Tl(e.length)&&!Gt(e)}var It=tA;function rA(e,t,r){if(!tt(r))return!1;var n=typeof t;return(n=="number"?It(r)&&sa(t,r.length):n=="string"&&t in r)?Wn(r[t],e):!1}var la=rA;function nA(e){return gl(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&&la(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 iA=nA,aA=Object.prototype;function sA(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||aA;return e===r}var Qn=sA;function oA(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var lA=oA,cA="[object Arguments]";function uA(e){return pt(e)&&ir(e)==cA}var $p=uA,Vd=Object.prototype,pA=Vd.hasOwnProperty,dA=Vd.propertyIsEnumerable,fA=$p((function(){return arguments})())?$p:function(e){return pt(e)&&pA.call(e,"callee")&&!dA.call(e,"callee")},ca=fA;function hA(){return!1}var mA=hA,Hd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vp=Hd&&typeof module=="object"&&module&&!module.nodeType&&module,gA=Vp&&Vp.exports===Hd,Hp=gA?Et.Buffer:void 0,TA=Hp?Hp.isBuffer:void 0,yA=TA||mA,Gn=yA,bA="[object Arguments]",xA="[object Array]",vA="[object Boolean]",AA="[object Date]",EA="[object Error]",IA="[object Function]",LA="[object Map]",PA="[object Number]",_A="[object Object]",NA="[object RegExp]",OA="[object Set]",SA="[object String]",wA="[object WeakMap]",kA="[object ArrayBuffer]",CA="[object DataView]",RA="[object Float32Array]",FA="[object Float64Array]",MA="[object Int8Array]",DA="[object Int16Array]",jA="[object Int32Array]",GA="[object Uint8Array]",$A="[object Uint8ClampedArray]",VA="[object Uint16Array]",HA="[object Uint32Array]",U={};U[RA]=U[FA]=U[MA]=U[DA]=U[jA]=U[GA]=U[$A]=U[VA]=U[HA]=!0;U[bA]=U[xA]=U[kA]=U[vA]=U[CA]=U[AA]=U[EA]=U[IA]=U[LA]=U[PA]=U[_A]=U[NA]=U[OA]=U[SA]=U[wA]=!1;function KA(e){return pt(e)&&Tl(e.length)&&!!U[ir(e)]}var qA=KA;function zA(e){return function(t){return e(t)}}var Xn=zA,Kd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mn=Kd&&typeof module=="object"&&module&&!module.nodeType&&module,WA=Mn&&Mn.exports===Kd,Wo=WA&&Fd.process,YA=(function(){try{var e=Mn&&Mn.require&&Mn.require("util").types;return e||Wo&&Wo.binding&&Wo.binding("util")}catch(t){}})(),rr=YA,Kp=rr&&rr.isTypedArray,QA=Kp?Xn(Kp):qA,yl=QA,XA=Object.prototype,BA=XA.hasOwnProperty;function JA(e,t){var r=V(e),n=!r&&ca(e),i=!r&&!n&&Gn(e),a=!r&&!n&&!i&&yl(e),s=r||n||i||a,o=s?lA(e.length,String):[],l=o.length;for(var c in e)(t||BA.call(e,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||sa(c,l)))&&o.push(c);return o}var qd=JA;function ZA(e,t){return function(r){return e(t(r))}}var zd=ZA,UA=zd(Object.keys,Object),eE=UA,tE=Object.prototype,rE=tE.hasOwnProperty;function nE(e){if(!Qn(e))return eE(e);var t=[];for(var r in Object(e))rE.call(e,r)&&r!="constructor"&&t.push(r);return t}var Wd=nE;function iE(e){return It(e)?qd(e):Wd(e)}var Ke=iE,aE=Object.prototype,sE=aE.hasOwnProperty,oE=iA(function(e,t){if(Qn(t)||It(t)){Yn(t,Ke(t),e);return}for(var r in t)sE.call(t,r)&&oa(e,r,t[r])}),qe=oE;function lE(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var cE=lE,uE=Object.prototype,pE=uE.hasOwnProperty;function dE(e){if(!tt(e))return cE(e);var t=Qn(e),r=[];for(var n in e)n=="constructor"&&(t||!pE.call(e,n))||r.push(n);return r}var fE=dE;function hE(e){return It(e)?qd(e,!0):fE(e)}var ua=hE,mE=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gE=/^\w*$/;function TE(e,t){if(V(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||aa(e)?!0:gE.test(e)||!mE.test(e)||t!=null&&e in Object(t)}var bl=TE,yE=Ir(Object,"create"),$n=yE;function bE(){this.__data__=$n?$n(null):{},this.size=0}var xE=bE;function vE(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var AE=vE,EE="__lodash_hash_undefined__",IE=Object.prototype,LE=IE.hasOwnProperty;function PE(e){var t=this.__data__;if($n){var r=t[e];return r===EE?void 0:r}return LE.call(t,e)?t[e]:void 0}var _E=PE,NE=Object.prototype,OE=NE.hasOwnProperty;function SE(e){var t=this.__data__;return $n?t[e]!==void 0:OE.call(t,e)}var wE=SE,kE="__lodash_hash_undefined__";function CE(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=$n&&t===void 0?kE:t,this}var RE=CE;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=xE;zr.prototype.delete=AE;zr.prototype.get=_E;zr.prototype.has=wE;zr.prototype.set=RE;var qp=zr;function FE(){this.__data__=[],this.size=0}var ME=FE;function DE(e,t){for(var r=e.length;r--;)if(Wn(e[r][0],t))return r;return-1}var pa=DE,jE=Array.prototype,GE=jE.splice;function $E(e){var t=this.__data__,r=pa(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():GE.call(t,r,1),--this.size,!0}var VE=$E;function HE(e){var t=this.__data__,r=pa(t,e);return r<0?void 0:t[r][1]}var KE=HE;function qE(e){return pa(this.__data__,e)>-1}var zE=qE;function WE(e,t){var r=this.__data__,n=pa(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var YE=WE;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=ME;Wr.prototype.delete=VE;Wr.prototype.get=KE;Wr.prototype.has=zE;Wr.prototype.set=YE;var da=Wr,QE=Ir(Et,"Map"),Vn=QE;function XE(){this.size=0,this.__data__={hash:new qp,map:new(Vn||da),string:new qp}}var BE=XE;function JE(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ZE=JE;function UE(e,t){var r=e.__data__;return ZE(t)?r[typeof t=="string"?"string":"hash"]:r.map}var fa=UE;function eI(e){var t=fa(this,e).delete(e);return this.size-=t?1:0,t}var tI=eI;function rI(e){return fa(this,e).get(e)}var nI=rI;function iI(e){return fa(this,e).has(e)}var aI=iI;function sI(e,t){var r=fa(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var oI=sI;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=BE;Yr.prototype.delete=tI;Yr.prototype.get=nI;Yr.prototype.has=aI;Yr.prototype.set=oI;var ha=Yr,lI="Expected a function";function xl(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(lI);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(xl.Cache||ha),r}xl.Cache=ha;var cI=xl,uI=500;function pI(e){var t=cI(e,function(n){return r.size===uI&&r.clear(),n}),r=t.cache;return t}var dI=pI,fI=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,hI=/\\(\\)?/g,mI=dI(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(fI,function(r,n,i,a){t.push(i?a.replace(hI,"$1"):n||r)}),t}),gI=mI;function TI(e){return e==null?"":Lx(e)}var Yd=TI;function yI(e,t){return V(e)?e:bl(e,t)?[e]:gI(Yd(e))}var ma=yI,bI=1/0;function xI(e){if(typeof e=="string"||aa(e))return e;var t=e+"";return t=="0"&&1/e==-bI?"-0":t}var Bn=xI;function vI(e,t){t=ma(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=vI;function AI(e,t,r){var n=e==null?void 0:vl(e,t);return n===void 0?r:n}var EI=AI;function II(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Al=II,zp=et?et.isConcatSpreadable:void 0;function LI(e){return V(e)||ca(e)||!!(zp&&e&&e[zp])}var PI=LI;function Qd(e,t,r,n,i){var a=-1,s=e.length;for(r||(r=PI),i||(i=[]);++a<s;){var o=e[a];t>0&&r(o)?t>1?Qd(o,t-1,r,n,i):Al(i,o):n||(i[i.length]=o)}return i}var El=Qd;function _I(e){var t=e==null?0:e.length;return t?El(e,1):[]}var ct=_I,NI=zd(Object.getPrototypeOf,Object),Xd=NI;function OI(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 Il=OI;function SI(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:Il(e,t,r)}var wI=SI,kI="\\ud800-\\udfff",CI="\\u0300-\\u036f",RI="\\ufe20-\\ufe2f",FI="\\u20d0-\\u20ff",MI=CI+RI+FI,DI="\\ufe0e\\ufe0f",jI="\\u200d",GI=RegExp("["+jI+kI+MI+DI+"]");function $I(e){return GI.test(e)}var Bd=$I;function VI(e){return e.split("")}var HI=VI,Jd="\\ud800-\\udfff",KI="\\u0300-\\u036f",qI="\\ufe20-\\ufe2f",zI="\\u20d0-\\u20ff",WI=KI+qI+zI,YI="\\ufe0e\\ufe0f",QI="["+Jd+"]",el="["+WI+"]",tl="\\ud83c[\\udffb-\\udfff]",XI="(?:"+el+"|"+tl+")",Zd="[^"+Jd+"]",Ud="(?:\\ud83c[\\udde6-\\uddff]){2}",ef="[\\ud800-\\udbff][\\udc00-\\udfff]",BI="\\u200d",tf=XI+"?",rf="["+YI+"]?",JI="(?:"+BI+"(?:"+[Zd,Ud,ef].join("|")+")"+rf+tf+")*",ZI=rf+tf+JI,UI="(?:"+[Zd+el+"?",el,Ud,ef,QI].join("|")+")",eL=RegExp(tl+"(?="+tl+")|"+UI+ZI,"g");function tL(e){return e.match(eL)||[]}var rL=tL;function nL(e){return Bd(e)?rL(e):HI(e)}var iL=nL;function aL(e){return function(t){t=Yd(t);var r=Bd(t)?iL(t):void 0,n=r?r[0]:t.charAt(0),i=r?wI(r,1).join(""):t.slice(1);return n[e]()+i}}var sL=aL,rR=sL("toUpperCase");function oL(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 lL=oL;function cL(){this.__data__=new da,this.size=0}var uL=cL;function pL(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var dL=pL;function fL(e){return this.__data__.get(e)}var hL=fL;function mL(e){return this.__data__.has(e)}var gL=mL,TL=200;function yL(e,t){var r=this.__data__;if(r instanceof da){var n=r.__data__;if(!Vn||n.length<TL-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new ha(n)}return r.set(e,t),this.size=r.size,this}var bL=yL;function Qr(e){var t=this.__data__=new da(e);this.size=t.size}Qr.prototype.clear=uL;Qr.prototype.delete=dL;Qr.prototype.get=hL;Qr.prototype.has=gL;Qr.prototype.set=bL;var Dn=Qr;function xL(e,t){return e&&Yn(t,Ke(t),e)}var vL=xL;function AL(e,t){return e&&Yn(t,ua(t),e)}var EL=AL,nf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wp=nf&&typeof module=="object"&&module&&!module.nodeType&&module,IL=Wp&&Wp.exports===nf,Yp=IL?Et.Buffer:void 0,Qp=Yp?Yp.allocUnsafe:void 0;function LL(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 PL=LL;function _L(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 Ll=_L;function NL(){return[]}var af=NL,OL=Object.prototype,SL=OL.propertyIsEnumerable,Xp=Object.getOwnPropertySymbols,wL=Xp?function(e){return e==null?[]:(e=Object(e),Ll(Xp(e),function(t){return SL.call(e,t)}))}:af,Pl=wL;function kL(e,t){return Yn(e,Pl(e),t)}var CL=kL,RL=Object.getOwnPropertySymbols,FL=RL?function(e){for(var t=[];e;)Al(t,Pl(e)),e=Xd(e);return t}:af,sf=FL;function ML(e,t){return Yn(e,sf(e),t)}var DL=ML;function jL(e,t,r){var n=t(e);return V(e)?n:Al(n,r(e))}var of=jL;function GL(e){return of(e,Ke,Pl)}var rl=GL;function $L(e){return of(e,ua,sf)}var lf=$L,VL=Ir(Et,"DataView"),nl=VL,HL=Ir(Et,"Promise"),il=HL,KL=Ir(Et,"Set"),Vr=KL,Bp="[object Map]",qL="[object Object]",Jp="[object Promise]",Zp="[object Set]",Up="[object WeakMap]",ed="[object DataView]",zL=Er(nl),WL=Er(Vn),YL=Er(il),QL=Er(Vr),XL=Er(Uo),yr=ir;(nl&&yr(new nl(new ArrayBuffer(1)))!=ed||Vn&&yr(new Vn)!=Bp||il&&yr(il.resolve())!=Jp||Vr&&yr(new Vr)!=Zp||Uo&&yr(new Uo)!=Up)&&(yr=function(e){var t=ir(e),r=t==qL?e.constructor:void 0,n=r?Er(r):"";if(n)switch(n){case zL:return ed;case WL:return Bp;case YL:return Jp;case QL:return Zp;case XL:return Up}return t});var Hr=yr,BL=Object.prototype,JL=BL.hasOwnProperty;function ZL(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&JL.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var UL=ZL,eP=Et.Uint8Array,Xi=eP;function tP(e){var t=new e.constructor(e.byteLength);return new Xi(t).set(new Xi(e)),t}var _l=tP;function rP(e,t){var r=t?_l(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var nP=rP,iP=/\w*$/;function aP(e){var t=new e.constructor(e.source,iP.exec(e));return t.lastIndex=e.lastIndex,t}var sP=aP,td=et?et.prototype:void 0,rd=td?td.valueOf:void 0;function oP(e){return rd?Object(rd.call(e)):{}}var lP=oP;function cP(e,t){var r=t?_l(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var uP=cP,pP="[object Boolean]",dP="[object Date]",fP="[object Map]",hP="[object Number]",mP="[object RegExp]",gP="[object Set]",TP="[object String]",yP="[object Symbol]",bP="[object ArrayBuffer]",xP="[object DataView]",vP="[object Float32Array]",AP="[object Float64Array]",EP="[object Int8Array]",IP="[object Int16Array]",LP="[object Int32Array]",PP="[object Uint8Array]",_P="[object Uint8ClampedArray]",NP="[object Uint16Array]",OP="[object Uint32Array]";function SP(e,t,r){var n=e.constructor;switch(t){case bP:return _l(e);case pP:case dP:return new n(+e);case xP:return nP(e,r);case vP:case AP:case EP:case IP:case LP:case PP:case _P:case NP:case OP:return uP(e,r);case fP:return new n;case hP:case TP:return new n(e);case mP:return sP(e);case gP:return new n;case yP:return lP(e)}}var wP=SP;function kP(e){return typeof e.constructor=="function"&&!Qn(e)?mv(Xd(e)):{}}var CP=kP,RP="[object Map]";function FP(e){return pt(e)&&Hr(e)==RP}var MP=FP,nd=rr&&rr.isMap,DP=nd?Xn(nd):MP,jP=DP,GP="[object Set]";function $P(e){return pt(e)&&Hr(e)==GP}var VP=$P,id=rr&&rr.isSet,HP=id?Xn(id):VP,KP=HP,qP=1,zP=2,WP=4,cf="[object Arguments]",YP="[object Array]",QP="[object Boolean]",XP="[object Date]",BP="[object Error]",uf="[object Function]",JP="[object GeneratorFunction]",ZP="[object Map]",UP="[object Number]",pf="[object Object]",e_="[object RegExp]",t_="[object Set]",r_="[object String]",n_="[object Symbol]",i_="[object WeakMap]",a_="[object ArrayBuffer]",s_="[object DataView]",o_="[object Float32Array]",l_="[object Float64Array]",c_="[object Int8Array]",u_="[object Int16Array]",p_="[object Int32Array]",d_="[object Uint8Array]",f_="[object Uint8ClampedArray]",h_="[object Uint16Array]",m_="[object Uint32Array]",J={};J[cf]=J[YP]=J[a_]=J[s_]=J[QP]=J[XP]=J[o_]=J[l_]=J[c_]=J[u_]=J[p_]=J[ZP]=J[UP]=J[pf]=J[e_]=J[t_]=J[r_]=J[n_]=J[d_]=J[f_]=J[h_]=J[m_]=!0;J[BP]=J[uf]=J[i_]=!1;function Hi(e,t,r,n,i,a){var s,o=t&qP,l=t&zP,c=t&WP;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=UL(e),!o)return xv(e,s)}else{var p=Hr(e),f=p==uf||p==JP;if(Gn(e))return PL(e,o);if(p==pf||p==cf||f&&!i){if(s=l||f?{}:CP(e),!o)return l?DL(e,EL(s,e)):CL(e,vL(s,e))}else{if(!J[p])return i?e:{};s=wP(e,p,o)}}a||(a=new Dn);var h=a.get(e);if(h)return h;a.set(e,s),KP(e)?e.forEach(function(v){s.add(Hi(v,t,r,v,e,a))}):jP(e)&&e.forEach(function(v,x){s.set(x,Hi(v,t,r,x,e,a))});var g=c?l?lf:rl:l?ua:Ke,T=u?void 0:g(e);return jd(T||e,function(v,x){T&&(x=v,v=e[x]),oa(s,x,Hi(v,t,r,x,e,a))}),s}var g_=Hi,T_=4;function y_(e){return g_(e,T_)}var $e=y_;function b_(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=b_,x_="__lodash_hash_undefined__";function v_(e){return this.__data__.set(e,x_),this}var A_=v_;function E_(e){return this.__data__.has(e)}var I_=E_;function Bi(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new ha;++t<r;)this.add(e[t])}Bi.prototype.add=Bi.prototype.push=A_;Bi.prototype.has=I_;var Nl=Bi;function L_(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 df=L_;function P_(e,t){return e.has(t)}var Ol=P_,__=1,N_=2;function O_(e,t,r,n,i,a){var s=r&__,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&N_?new Nl:void 0;for(a.set(e,t),a.set(t,e);++p<o;){var g=e[p],T=t[p];if(n)var v=s?n(T,g,p,t,e,a):n(g,T,p,e,t,a);if(v!==void 0){if(v)continue;f=!1;break}if(h){if(!df(t,function(x,A){if(!Ol(h,A)&&(g===x||i(g,x,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 ff=O_;function S_(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var w_=S_;function k_(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Sl=k_,C_=1,R_=2,F_="[object Boolean]",M_="[object Date]",D_="[object Error]",j_="[object Map]",G_="[object Number]",$_="[object RegExp]",V_="[object Set]",H_="[object String]",K_="[object Symbol]",q_="[object ArrayBuffer]",z_="[object DataView]",ad=et?et.prototype:void 0,Yo=ad?ad.valueOf:void 0;function W_(e,t,r,n,i,a,s){switch(r){case z_:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case q_:return!(e.byteLength!=t.byteLength||!a(new Xi(e),new Xi(t)));case F_:case M_:case G_:return Wn(+e,+t);case D_:return e.name==t.name&&e.message==t.message;case $_:case H_:return e==t+"";case j_:var o=w_;case V_:var l=n&C_;if(o||(o=Sl),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;n|=R_,s.set(e,t);var u=ff(o(e),o(t),n,i,a,s);return s.delete(e),u;case K_:if(Yo)return Yo.call(e)==Yo.call(t)}return!1}var Y_=W_,Q_=1,X_=Object.prototype,B_=X_.hasOwnProperty;function J_(e,t,r,n,i,a){var s=r&Q_,o=rl(e),l=o.length,c=rl(t),u=c.length;if(l!=u&&!s)return!1;for(var p=l;p--;){var f=o[p];if(!(s?f in t:B_.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 v=s;++p<l;){f=o[p];var x=e[f],A=t[f];if(n)var y=s?n(A,x,f,t,e,a):n(x,A,f,e,t,a);if(!(y===void 0?x===A||i(x,A,r,n,a):y)){T=!1;break}v||(v=f=="constructor")}if(T&&!v){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 Z_=J_,U_=1,sd="[object Arguments]",od="[object Array]",Mi="[object Object]",eN=Object.prototype,ld=eN.hasOwnProperty;function tN(e,t,r,n,i,a){var s=V(e),o=V(t),l=s?od:Hr(e),c=o?od:Hr(t);l=l==sd?Mi:l,c=c==sd?Mi:c;var u=l==Mi,p=c==Mi,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||yl(e)?ff(e,t,r,n,i,a):Y_(e,t,l,r,n,i,a);if(!(r&U_)){var h=u&&ld.call(e,"__wrapped__"),g=p&&ld.call(t,"__wrapped__");if(h||g){var T=h?e.value():e,v=g?t.value():t;return a||(a=new Dn),i(T,v,r,n,a)}}return f?(a||(a=new Dn),Z_(e,t,r,n,i,a)):!1}var rN=tN;function hf(e,t,r,n,i){return e===t?!0:e==null||t==null||!pt(e)&&!pt(t)?e!==e&&t!==t:rN(e,t,r,n,hf,i)}var mf=hf,nN=1,iN=2;function aN(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?mf(u,c,nN|iN,n,p):f))return!1}}return!0}var sN=aN;function oN(e){return e===e&&!tt(e)}var gf=oN;function lN(e){for(var t=Ke(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,gf(i)]}return t}var cN=lN;function uN(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Tf=uN;function pN(e){var t=cN(e);return t.length==1&&t[0][2]?Tf(t[0][0],t[0][1]):function(r){return r===e||sN(r,e,t)}}var dN=pN;function fN(e,t){return e!=null&&t in Object(e)}var hN=fN;function mN(e,t,r){t=ma(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&&Tl(i)&&sa(s,i)&&(V(e)||ca(e)))}var yf=mN;function gN(e,t){return e!=null&&yf(e,t,hN)}var TN=gN,yN=1,bN=2;function xN(e,t){return bl(e)&&gf(t)?Tf(Bn(e),t):function(r){var n=EI(r,e);return n===void 0&&n===t?TN(r,e):mf(t,n,yN|bN)}}var vN=xN;function AN(e){return function(t){return t==null?void 0:t[e]}}var EN=AN;function IN(e){return function(t){return vl(t,e)}}var LN=IN;function PN(e){return bl(e)?EN(Bn(e)):LN(e)}var _N=PN;function NN(e){return typeof e=="function"?e:e==null?zn:typeof e=="object"?V(e)?vN(e[0],e[1]):dN(e):_N(e)}var Lt=NN;function ON(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 SN=ON;function wN(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 kN=wN,CN=kN(),RN=CN;function FN(e,t){return e&&RN(e,t,Ke)}var MN=FN;function DN(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 jN=DN,GN=jN(MN),Lr=GN;function $N(e,t,r,n){return Lr(e,function(i,a,s){t(n,i,r(i),s)}),n}var VN=$N;function HN(e,t){return function(r,n){var i=V(r)?SN:VN,a=t?t():{};return i(r,e,Lt(n,2),a)}}var KN=HN,bf=Object.prototype,qN=bf.hasOwnProperty,zN=gl(function(e,t){e=Object(e);var r=-1,n=t.length,i=n>2?t[2]:void 0;for(i&&la(t[0],t[1],i)&&(n=1);++r<n;)for(var a=t[r],s=ua(a),o=-1,l=s.length;++o<l;){var c=s[o],u=e[c];(u===void 0||Wn(u,bf[c])&&!qN.call(e,c))&&(e[c]=a[c])}return e}),wl=zN;function WN(e){return pt(e)&&It(e)}var cd=WN;function YN(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 xf=YN,QN=200;function XN(e,t,r,n){var i=-1,a=$d,s=!0,o=e.length,l=[],c=t.length;if(!o)return l;r&&(t=Kn(t,Xn(r))),n?(a=xf,s=!1):t.length>=QN&&(a=Ol,s=!1,t=new Nl(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 BN=XN,JN=gl(function(e,t){return cd(e)?BN(e,El(t,1,cd,!0)):[]}),ga=JN;function ZN(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var xr=ZN;function UN(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:qn(t),Il(e,t<0?0:t,n)):[]}var _e=UN;function eO(e,t,r){var n=e==null?0:e.length;return n?(t=r||t===void 0?1:qn(t),t=n-t,Il(e,0,t<0?0:t)):[]}var Hn=eO;function tO(e){return typeof e=="function"?e:zn}var rO=tO;function nO(e,t){var r=V(e)?jd:Lr;return r(e,rO(t))}var C=nO;function iO(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 aO=iO;function sO(e,t){var r=!0;return Lr(e,function(n,i,a){return r=!!t(n,i,a),r}),r}var oO=sO;function lO(e,t,r){var n=V(e)?aO:oO;return r&&la(e,t,r)&&(t=void 0),n(e,Lt(t,3))}var ut=lO;function cO(e,t){var r=[];return Lr(e,function(n,i,a){t(n,i,a)&&r.push(n)}),r}var vf=cO;function uO(e,t){var r=V(e)?Ll:vf;return r(e,Lt(t,3))}var rt=uO;function pO(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 dO=pO,fO=Math.max;function hO(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=fO(n+i,0)),Gd(e,Lt(t,3),i)}var mO=hO,gO=dO(mO),Kr=gO;function TO(e){return e&&e.length?e[0]:void 0}var dt=TO;function yO(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 bO=yO;function xO(e,t){var r=V(e)?Kn:bO;return r(e,Lt(t,3))}var O=xO;function vO(e,t){return El(O(e,t),1)}var Ue=vO,AO=Object.prototype,EO=AO.hasOwnProperty,IO=KN(function(e,t,r){EO.call(e,r)?e[r].push(t):ml(e,r,[t])}),LO=IO,PO=Object.prototype,_O=PO.hasOwnProperty;function NO(e,t){return e!=null&&_O.call(e,t)}var OO=NO;function SO(e,t){return e!=null&&yf(e,t,OO)}var w=SO,wO="[object String]";function kO(e){return typeof e=="string"||!V(e)&&pt(e)&&ir(e)==wO}var Ve=kO;function CO(e,t){return Kn(t,function(r){return e[r]})}var RO=CO;function FO(e){return e==null?[]:RO(e,Ke(e))}var xe=FO,MO=Math.max;function DO(e,t,r,n){e=It(e)?e:xe(e),r=r&&!n?qn(r):0;var i=e.length;return r<0&&(r=MO(i+r,0)),Ve(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&hl(e,t,r)>-1}var De=DO,jO=Math.max;function GO(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=jO(n+i,0)),hl(e,t,i)}var ud=GO,$O="[object Map]",VO="[object Set]",HO=Object.prototype,KO=HO.hasOwnProperty;function qO(e){if(e==null)return!0;if(It(e)&&(V(e)||typeof e=="string"||typeof e.splice=="function"||Gn(e)||yl(e)||ca(e)))return!e.length;var t=Hr(e);if(t==$O||t==VO)return!e.size;if(Qn(e))return!Wd(e).length;for(var r in e)if(KO.call(e,r))return!1;return!0}var Z=qO,zO="[object RegExp]";function WO(e){return pt(e)&&ir(e)==zO}var YO=WO,pd=rr&&rr.isRegExp,QO=pd?Xn(pd):YO,Mt=QO;function XO(e){return e===void 0}var Dt=XO,BO="Expected a function";function JO(e){if(typeof e!="function")throw new TypeError(BO);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 ZO=JO;function UO(e,t,r,n){if(!tt(e))return e;t=ma(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:sa(t[i+1])?[]:{})}oa(o,l,c),o=o[l]}return e}var eS=UO;function tS(e,t,r){for(var n=-1,i=t.length,a={};++n<i;){var s=t[n],o=vl(e,s);r(o,s)&&eS(a,ma(s,e),o)}return a}var rS=tS;function nS(e,t){if(e==null)return{};var r=Kn(lf(e),function(n){return[n]});return t=Lt(t),rS(e,r,function(n,i){return t(n,i[0])})}var ft=nS;function iS(e,t,r,n,i){return i(e,function(a,s,o){r=n?(n=!1,a):t(r,a,s,o)}),r}var aS=iS;function sS(e,t,r){var n=V(e)?lL:aS,i=arguments.length<3;return n(e,Lt(t,4),r,i,Lr)}var ze=sS;function oS(e,t){var r=V(e)?Ll:vf;return r(e,ZO(Lt(t,3)))}var Ta=oS;function lS(e,t){var r;return Lr(e,function(n,i,a){return r=t(n,i,a),!r}),!!r}var cS=lS;function uS(e,t,r){var n=V(e)?df:cS;return r&&la(e,t,r)&&(t=void 0),n(e,Lt(t,3))}var Af=uS,pS=1/0,dS=Vr&&1/Sl(new Vr([,-0]))[1]==pS?function(e){return new Vr(e)}:Ee,fS=dS,hS=200;function mS(e,t,r){var n=-1,i=$d,a=e.length,s=!0,o=[],l=o;if(r)s=!1,i=xf;else if(a>=hS){var c=t?null:fS(e);if(c)return Sl(c);s=!1,i=Ol,l=new Nl}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 gS=mS;function TS(e){return e&&e.length?gS(e):[]}var kl=TS;function al(e){console&&console.error&&console.error(`Error: ${e}`)}function Ef(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function If(e){let t=new Date().getTime(),r=e();return{time:new Date().getTime()-t,value:r}}function Lf(e){function t(){}t.prototype=e;let r=new t;function n(){return typeof r.bar}return n(),n(),e;(0,eval)(e)}function yS(e){return bS(e)?e.LABEL:e.name}function bS(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))}},ve=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 xS(e){return O(e,Ki)}function Ki(e){function t(r){return O(r,Ki)}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:Ki(new ae({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ht)return{type:"RepetitionWithSeparator",idx:e.idx,separator:Ki(new ae({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ve)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:yS(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 ve: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 vS(e){return e instanceof He||e instanceof Ge||e instanceof ve||e instanceof _t||e instanceof Nt||e instanceof ht||e instanceof ae||e instanceof Xr}function Ji(e,t=[]){return e instanceof Ge||e instanceof ve||e instanceof ht?!0:e instanceof mt?Af(e.definition,n=>Ji(n,t)):e instanceof We&&De(t,e)?!1:e instanceof Pt?(e instanceof We&&t.push(e),ut(e.definition,n=>Ji(n,t))):!1}function AS(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 ve)return"MANY";if(e instanceof ae)return"CONSUME";throw Error("non exhaustive match")}var ya=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 ve)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=dd(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=dd(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 dd(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 LS(e);if(vS(e))return ES(e);if(AS(e))return IS(e);throw Error("non exhaustive match")}function ES(e){let t=[],r=e.definition,n=0,i=r.length>n,a,s=!0;for(;i&&s;)a=r[n],s=Ji(a),t=t.concat(Zn(a)),n=n+1,i=r.length>n;return kl(t)}function IS(e){let t=O(e.definition,r=>Zn(r));return kl(ct(t))}function LS(e){return[e.terminalType]}var Pf="_~IN~_",PS=class extends ya{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=NS(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(r),a=new He({definition:i}),s=Zn(a);this.follows[n]=s}};function _S(e){let t={};return C(e,r=>{let n=new PS(r).startWalking();qe(t,n)}),t}function NS(e,t){return e.name+t+Pf}function R(e){return e.charCodeAt(0)}function Qo(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 Di(){throw Error("Internal Error - Should never get here!")}function fd(e){return e.type==="Character"}var Zi=[];for(let e=R("0");e<=R("9");e++)Zi.push(e);var Ui=[R("_")].concat(Zi);for(let e=R("a");e<=R("z");e++)Ui.push(e);for(let e=R("A");e<=R("Z");e++)Ui.push(e);var hd=[R(" "),R("\f"),R(`
|
|
6
|
+
`),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")],OS=/[0-9a-fA-F]/,ji=/[0-9]/,SS=/[1-9]/,wS=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 Di()}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):Di()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[R(`
|
|
7
|
+
`),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=Zi;break;case"D":e=Zi,t=!0;break;case"s":e=hd;break;case"S":e=hd,t=!0;break;case"w":e=Ui;break;case"W":e=Ui,t=!0;break}return $r(e)?{type:"Set",value:e,complement:t}:Di()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=R("\f");break;case"n":e=R(`
|
|
8
|
+
`);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}:Di()}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`
|
|
9
|
+
`: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(fd(r)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),a=i.type==="Character";if(fd(i)){if(i.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:i.value})}else Qo(r.value,e),e.push(R("-")),Qo(i.value,e)}else Qo(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
10
|
+
`: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(SS.test(e)===!1)throw Error("Expecting a positive integer");for(;ji.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(ji.test(e)===!1)throw Error("Expecting an integer");for(;ji.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|
11
|
+
`: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 ji.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
11
12
|
`: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(
|
|
13
|
-
`;function
|
|
13
|
+
`: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(OS.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}}},Cl=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){}},qi={},kS=new wS;function ba(e){let t=e.toString();if(qi.hasOwnProperty(t))return qi[t];{let r=kS.pattern(t);return qi[t]=r,r}}function CS(){qi={}}var _f="Complement Sets are not supported for first char optimization",ea=`Unable to use "first char" lexer optimizations:
|
|
14
|
+
`;function RS(e,t=!1){try{let r=ba(e);return sl(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===_f)t&&Ef(`${ea} Unable to optimize: < ${e.toString()} >
|
|
14
15
|
Complement Sets cannot be automatically optimized.
|
|
15
16
|
This will disable the lexer's first char optimizations.
|
|
16
17
|
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n=`
|
|
17
18
|
This will disable the lexer's first char optimizations.
|
|
18
|
-
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),
|
|
19
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),al(`${ea}
|
|
19
20
|
Failed parsing: < ${e.toString()} >
|
|
20
21
|
Using the @chevrotain/regexp-to-ast library
|
|
21
|
-
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function
|
|
22
|
-
`],tracer:(A,y)=>y()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{
|
|
22
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function sl(e,t,r){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)sl(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":Gi(s.value,t,r);break;case"Set":if(s.complement===!0)throw Error(_f);C(s.value,l=>{if(typeof l=="number")Gi(l,t,r);else{let c=l;if(r===!0)for(let u=c.from;u<=c.to;u++)Gi(u,t,r);else{for(let u=c.from;u<=c.to&&u<Rn;u++)Gi(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":sl(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"&&ol(s)===!1||s.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return xe(t)}function Gi(e,t,r){let n=nr(e);t[n]=n,r===!0&&FS(e,t)}function FS(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 md(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 ol(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?V(e.value)?ut(e.value,ol):ol(e.value):!1}var MS=class extends Cl{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?md(e,this.targetCharCodes)===void 0&&(this.found=!0):md(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Rl(e,t){if(t instanceof RegExp){let r=ba(t),n=new MS(e);return n.visit(r),n.found}else return Kr(t,r=>De(e,r.charCodeAt(0)))!==void 0}var vr="PATTERN",Cn="defaultMode",$i="modes";function DS(e,t){t=wl(t,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
23
|
+
`],tracer:(A,y)=>y()});let r=t.tracer;r("initCharCodeToOptimizedIndexMap",()=>{ow()});let n;r("Reject Lexer.NA",()=>{n=Ta(e,A=>A[vr]===Ne.NA)});let i=!1,a;r("Transform Patterns",()=>{i=!1,a=O(n,A=>{let y=A[vr];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]:gd(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 gd(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=>ud(n,S)):[ud(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=Sf(t.lineTerminatorCharacters);p=O(n,y=>!1),t.positionTracking!=="onlyOffset"&&(p=O(n,y=>w(y,"LINE_BREAKS")?!!y.LINE_BREAKS:Of(y,A)===!1&&Rl(A,y.PATTERN)))});let f,h,g,T;r("Misc Mapping #2",()=>{f=O(n,Nf),h=O(a,iw),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 v=!0,x=[];return t.safeMode||r("First Char Optimization",()=>{x=ze(n,(A,y,L)=>{if(typeof y.PATTERN=="string"){let S=y.PATTERN.charCodeAt(0),N=nr(S);Xo(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,Xo(A,G,T[L]))})}else if(Mt(y.PATTERN))if(y.PATTERN.unicode)v=!1,t.ensureOptimizations&&al(`${ea} Unable to analyze < ${y.PATTERN.toString()} > pattern.
|
|
23
24
|
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
24
25
|
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=
|
|
26
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let S=RS(y.PATTERN,t.ensureOptimizations);Z(S)&&(v=!1),C(S,N=>{Xo(A,N,T[L])})}else t.ensureOptimizations&&al(`${ea} TokenType: <${y.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
26
27
|
This will disable the lexer's first char optimizations.
|
|
27
|
-
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),
|
|
28
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),v=!1;return A},[])}),{emptyGroups:g,patternIdxToConfig:T,charCodeToPatternIdxToConfig:x,hasCustom:i,canBeOptimized:v}}function jS(e,t){let r=[],n=$S(e);r=r.concat(n.errors);let i=VS(n.valid),a=i.valid;return r=r.concat(i.errors),r=r.concat(GS(a)),r=r.concat(XS(a)),r=r.concat(BS(a,t)),r=r.concat(JS(a)),r}function GS(e){let t=[],r=rt(e,n=>Mt(n[vr]));return t=t.concat(KS(r)),t=t.concat(WS(r)),t=t.concat(YS(r)),t=t.concat(QS(r)),t=t.concat(qS(r)),t}function $S(e){let t=rt(e,i=>!w(i,vr)),r=O(t,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:le.MISSING_PATTERN,tokenTypes:[i]})),n=ga(e,t);return{errors:r,valid:n}}function VS(e){let t=rt(e,i=>{let a=i[vr];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=ga(e,t);return{errors:r,valid:n}}var HS=/[^\\][$]/;function KS(e){class t extends Cl{constructor(){super(...arguments),this.found=!1}visitEndAnchor(a){this.found=!0}}let r=rt(e,i=>{let a=i.PATTERN;try{let s=ba(a),o=new t;return o.visit(s),o.found}catch(s){return HS.test(a.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
28
29
|
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
|
|
30
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:le.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function qS(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 zS=/[^\\[][\^]|^\^/;function WS(e){class t extends Cl{constructor(){super(...arguments),this.found=!1}visitStartAnchor(a){this.found=!0}}let r=rt(e,i=>{let a=i.PATTERN;try{let s=ba(a),o=new t;return o.visit(s),o.found}catch(s){return zS.test(a.source)}});return O(r,i=>({message:`Unexpected RegExp Anchor Error:
|
|
30
31
|
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
|
|
32
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:le.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function YS(e){let t=rt(e,n=>{let i=n[vr];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 QS(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 XS(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 BS(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 JS(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)&&US(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&&ZS(a,n.PATTERN)){let l=`Token: ->${o.name}<- can never be matched.
|
|
32
33
|
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
|
|
34
|
-
`,type:le.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),w(e
|
|
35
|
-
`,type:le.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),w(e
|
|
36
|
-
`,type:le.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),w(e
|
|
34
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:l,type:le.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),t}function ZS(e,t){if(Mt(t)){if(ew(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 US(e){return Kr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>e.source.indexOf(r)!==-1)===void 0}function ew(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}function gd(e){let t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function tw(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
|
|
35
|
+
`,type:le.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),w(e,$i)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+$i+`> property in its definition
|
|
36
|
+
`,type:le.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),w(e,$i)&&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
|
|
37
|
+
`,type:le.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),w(e,$i)&&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
38
|
`,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
|
|
39
|
+
`,type:le.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),n}function rw(e,t,r){let n=[],i=!1,a=Jn(ct(xe(e.modes))),s=Ta(a,l=>l[vr]===Ne.NA),o=Sf(r);return t&&C(s,l=>{let c=Of(l,o);if(c!==!1){let p={message:sw(l,c),type:c.issue,tokenType:l};n.push(p)}else w(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):Rl(o,l.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
|
|
39
40
|
This Lexer has been defined to track line and column information,
|
|
40
41
|
But none of the Token Types can be identified as matching a line terminator.
|
|
41
42
|
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
42
|
-
for details.`,type:le.NO_LINE_BREAKS_FLAGS}),n}function
|
|
43
|
+
for details.`,type:le.NO_LINE_BREAKS_FLAGS}),n}function nw(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 Nf(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 iw(e){return Ve(e)&&e.length===1?e.charCodeAt(0):!1}var aw={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 Of(e,t){if(w(e,"LINE_BREAKS"))return!1;if(Mt(e.PATTERN)){try{Rl(t,e.PATTERN)}catch(r){return{issue:le.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(Ve(e.PATTERN))return!1;if(Nf(e))return{issue:le.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function sw(e,t){if(t.issue===le.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
43
44
|
The problem is in the <${e.name}> Token Type
|
|
44
45
|
Root cause: ${t.errMsg}.
|
|
45
46
|
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
47
|
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
|
|
48
|
-
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:
|
|
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=
|
|
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(
|
|
48
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Sf(e){return O(e,r=>Ve(r)?r.charCodeAt(0):r)}function Xo(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}var Rn=256,zi=[];function nr(e){return e<Rn?e:zi[e]}function ow(){if(Z(zi)){zi=new Array(65536);for(let e=0;e<65536;e++)zi[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 ta(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Td=1,wf={};function ei(e){let t=lw(e);cw(t),pw(t),uw(t),C(t,r=>{r.isParent=r.categoryMatches.length>0})}function lw(e){let t=$e(e),r=e,n=!0;for(;n;){r=Jn(ct(O(r,a=>a.CATEGORIES)));let i=ga(r,t);t=t.concat(i),Z(i)?n=!1:r=i}return t}function cw(e){C(e,t=>{Cf(t)||(wf[Td]=t,t.tokenTypeIdx=Td++),yd(t)&&!V(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),yd(t)||(t.CATEGORIES=[]),dw(t)||(t.categoryMatches=[]),fw(t)||(t.categoryMatchesMap={})})}function uw(e){C(e,t=>{t.categoryMatches=[],C(t.categoryMatchesMap,(r,n)=>{t.categoryMatches.push(wf[n].tokenTypeIdx)})})}function pw(e){C(e,t=>{kf([],t)})}function kf(e,t){C(e,r=>{t.categoryMatchesMap[r.tokenTypeIdx]=!0}),C(t.CATEGORIES,r=>{let n=e.concat(t);De(n,r)||kf(n,r)})}function Cf(e){return w(e,"tokenTypeIdx")}function yd(e){return w(e,"CATEGORIES")}function dw(e){return w(e,"categoryMatches")}function fw(e){return w(e,"categoryMatchesMap")}function hw(e){return w(e,"tokenTypeIdx")}var mw={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:[`
|
|
49
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:mw,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}=If(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.
|
|
50
|
+
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=aw;else if(this.config.lineTerminatorCharacters===Fn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
51
|
+
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(tw(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(rw(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},C(n.modes,(s,o)=>{n.modes[o]=Ta(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(jS(s,a))}),Z(this.lexerDefinitionErrors)){ei(s);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=DS(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
52
|
`);throw new Error(`Errors detected in definition of Lexer:
|
|
52
|
-
`+o)}C(this.lexerDefinitionWarning,s=>{
|
|
53
|
+
`+o)}C(this.lexerDefinitionWarning,s=>{Ef(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
54
|
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",()=>{
|
|
55
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{CS()}),this.TRACE_INIT("toFastProperties",()=>{Lf(this)})})}tokenize(e,t=this.defaultMode){if(!Z(this.lexerDefinitionErrors)){let n=O(this.lexerDefinitionErrors,i=>i.message).join(`-----------------------
|
|
55
56
|
`);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
|
|
57
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return w(e,
|
|
57
|
+
`+n)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,n,i,a,s,o,l,c,u,p,f,h,g,T,v,x=e,A=x.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=nw(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=xr(we);z=this.patternIdxToConfig[he],be=this.charCodeToPatternIdxToConfig[he],ye=z.length;let vt=this.canModeBeOptimized[he]&&this.config.safeMode===!1;be&&vt?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=x.charCodeAt(y),he;if(Ae){let me=nr(re),Fe=be[me];he=Fe!==void 0?Fe:Le}else he=z;let vt=he.length;for(r=0;r<vt;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?(v=me.exec(x,y,N,te),v!==null?(o=v[0],u=o.length,v.payload!==void 0&&(l=v.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?(v=gr.exec(x,y,N,te),v!==null?(a=v[0],v.payload!==void 0&&(c=v.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],Vo=gr.pattern,dp=gr.short;if(dp!==!1?x.charCodeAt(y)===dp&&(Ft=!0):gr.isCustom===!0?Ft=Vo.exec(x,y,N,te)!==null:(Vo.lastIndex=y,Ft=Vo.exec(e)!==null),Ft===!0)break}if(g=y-me,B=this.computeNewColumn(B,g),T=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(x,me,g,Fe,er,xr(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 Rf(e)?e.LABEL:e.name}function Rf(e){return Ve(e.LABEL)&&e.LABEL!==""}var gw="parent",bd="categories",xd="label",vd="group",Ad="push_mode",Ed="pop_mode",Id="longer_alt",Ld="line_breaks",Pd="start_chars_hint";function xa(e){return Tw(e)}function Tw(e){let t=e.pattern,r={};if(r.name=e.name,Dt(t)||(r.PATTERN=t),w(e,gw))throw`The parent property is no longer supported.
|
|
58
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return w(e,bd)&&(r.CATEGORIES=e[bd]),ei([r]),w(e,xd)&&(r.LABEL=e[xd]),w(e,vd)&&(r.GROUP=e[vd]),w(e,Ed)&&(r.POP_MODE=e[Ed]),w(e,Ad)&&(r.PUSH_MODE=e[Ad]),w(e,Id)&&(r.LONGER_ALT=e[Id]),w(e,Ld)&&(r.LINE_BREAKS=e[Ld]),w(e,Pd)&&(r.START_CHARS_HINT=e[Pd]),r}var Ar=xa({name:"EOF",pattern:Ne.NA});ei([Ar]);function Fl(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 yw(e,t){return Un(e,t)}var Ff={buildMismatchTokenMessage({expected:e,actual:t,previous:r,ruleName:n}){return`Expecting ${Rf(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
59
|
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
60
|
${O(c,(f,h)=>` ${h+1}. ${f}`).join(`
|
|
60
61
|
`)}`;return a+p+o}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:r,ruleName:n}){let i="Expecting: ",s=`
|
|
61
62
|
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(
|
|
63
|
+
<${O(e,c=>`[${O(c,u=>jn(u)).join(",")}]`).join(" ,")}>`;return i+l+s}}};Object.freeze(Ff);var bw={buildRuleNotFoundError(e,t){return"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+`<-
|
|
63
64
|
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
65
|
appears more than once (${t.length} times) in the top level rule: ->${n}<-.
|
|
65
66
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
@@ -86,45 +87,45 @@ rule: <${t}> can be invoked from itself (directly or indirectly)
|
|
|
86
87
|
without consuming any Tokens. The grammar path that causes this is:
|
|
87
88
|
${n}
|
|
88
89
|
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
|
+
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 xw(e,t){let r=new vw(e,t);return r.resolveRefs(),r.errors}var vw=class extends Br{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){C(xe(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})}}},Aw=class extends ya{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())}},Ew=class extends Aw{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 ya{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}},Iw=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)}},_d=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)}},Lw=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)}},Nd=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 ll(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=ll(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 ve({definition:o.definition})]);return s(l)}else if(o instanceof Nt){let l=[new He({definition:o.definition}),new ve({definition:[new ae({terminalType:o.separator})].concat(o.definition)})];return s(l)}else if(o instanceof ht){let l=o.definition.concat([new ve({definition:[new ae({terminalType:o.separator})].concat(o.definition)})]);n=s(l)}else if(o instanceof ve){let l=o.definition.concat([new ve({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 Mf(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&&xr(p).idx<=c&&p.pop();continue}let h=f.def,g=f.idx,T=f.ruleStack,v=f.occurrenceStack;if(Z(h))continue;let x=h[0];if(x===i){let A={idx:g,def:_e(h),ruleStack:Hn(T),occurrenceStack:Hn(v)};p.push(A)}else if(x instanceof ae)if(g<l-1){let A=g+1,y=t[A];if(r(y,x.terminalType)){let L={idx:A,def:_e(h),ruleStack:T,occurrenceStack:v};p.push(L)}}else if(g===l-1)u.push({nextTokenType:x.terminalType,nextTokenOccurrence:x.idx,ruleStack:T,occurrenceStack:v}),o=!0;else throw Error("non exhaustive match");else if(x instanceof We){let A=$e(T);A.push(x.nonTerminalName);let y=$e(v);y.push(x.idx);let L={idx:g,def:x.definition.concat(a,_e(h)),ruleStack:A,occurrenceStack:y};p.push(L)}else if(x instanceof Ge){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:v};p.push(A),p.push(s);let y={idx:g,def:x.definition.concat(_e(h)),ruleStack:T,occurrenceStack:v};p.push(y)}else if(x instanceof _t){let A=new ve({definition:x.definition,idx:x.idx}),y=x.definition.concat([A],_e(h)),L={idx:g,def:y,ruleStack:T,occurrenceStack:v};p.push(L)}else if(x instanceof Nt){let A=new ae({terminalType:x.separator}),y=new ve({definition:[A].concat(x.definition),idx:x.idx}),L=x.definition.concat([y],_e(h)),S={idx:g,def:L,ruleStack:T,occurrenceStack:v};p.push(S)}else if(x instanceof ht){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:v};p.push(A),p.push(s);let y=new ae({terminalType:x.separator}),L=new ve({definition:[y].concat(x.definition),idx:x.idx}),S=x.definition.concat([L],_e(h)),N={idx:g,def:S,ruleStack:T,occurrenceStack:v};p.push(N)}else if(x instanceof ve){let A={idx:g,def:_e(h),ruleStack:T,occurrenceStack:v};p.push(A),p.push(s);let y=new ve({definition:x.definition,idx:x.idx}),L=x.definition.concat([y],_e(h)),S={idx:g,def:L,ruleStack:T,occurrenceStack:v};p.push(S)}else if(x instanceof mt)for(let A=x.definition.length-1;A>=0;A--){let y=x.definition[A],L={idx:g,def:y.definition.concat(_e(h)),ruleStack:T,occurrenceStack:v};p.push(L),p.push(s)}else if(x instanceof He)p.push({idx:g,def:x.definition.concat(_e(h)),ruleStack:T,occurrenceStack:v});else if(x instanceof Xr)p.push(Pw(x,g,T,v));else throw Error("non exhaustive match")}return u}function Pw(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 Df(e){if(e instanceof Ge||e==="Option")return oe.OPTION;if(e instanceof ve||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 _w(e,t,r,n,i,a){let s=Ml(e,t,r),o=$f(s)?ta:Un;return a(s,n,o,i)}function Nw(e,t,r,n,i,a){let s=Dl(e,t,i,r),o=$f(s)?ta:Un;return a(s[0],o,n)}function Ow(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 v=this.LA_FAST(T+1);if(r(v,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 Sw(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 ww=class extends ya{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)}},jf=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 Od(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=[];return t}function Bo(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 kw(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 Gf(e,t){let r=O(e,s=>ll([s],1)),n=Od(r.length),i=O(r,s=>{let o={};return C(s,l=>{let c=Bo(l.partialPath);C(c,u=>{o[u]=!0})}),o}),a=r;for(let s=1;s<=t;s++){let o=a;a=Od(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=Bo(p);if(kw(i,h,l)||Z(f)||p.length===t){let T=n[l];if(cl(T,p)===!1){T.push(p);for(let v=0;v<h.length;v++){let x=h[v];i[l][x]=!0}}}else{let T=ll(f,s+1,p);a[l]=a[l].concat(T),C(T,v=>{let x=Bo(v.partialPath);C(x,A=>{i[l][A]=!0})})}}}}return n}function Ml(e,t,r,n){let i=new jf(e,oe.ALTERNATION,n);return t.accept(i),Gf(i.result,r)}function Dl(e,t,r,n){let i=new jf(e,r);t.accept(i);let a=i.result,o=new ww(t,e,r).startWalking(),l=new He({definition:a}),c=new He({definition:o});return Gf([l,c],n)}function cl(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 Cw(e,t){return e.length<t.length&&ut(e,(r,n)=>{let i=t[n];return r===i||i.categoryMatchesMap[r.tokenTypeIdx]})}function $f(e){return ut(e,t=>ut(t,r=>ut(r,n=>Z(n.categoryMatches))))}function Rw(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 Fw(e,t,r,n){let i=Ue(e,l=>Mw(l,r)),a=Qw(e,t,r),s=Ue(e,l=>qw(l,r)),o=Ue(e,l=>Gw(l,e,n,r));return i.concat(a,s,o)}function Mw(e,t){let r=new jw;e.accept(r);let n=r.allProductions,i=LO(n,Dw),a=ft(i,o=>o.length>1);return O(xe(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=Vf(l);return f&&(p.parameter=f),p})}function Dw(e){return`${At(e)}_#_${e.idx}_#_${Vf(e)}`}function Vf(e){return e instanceof ae?e.terminalType.name:e instanceof We?e.nonTerminalName:""}var jw=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 Gw(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 $w(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 Hf(e,t,r,n=[]){let i=[],a=Wi(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=ga(a,n.concat([e])),c=Ue(l,u=>{let p=$e(n);return p.push(u),Hf(e,u,r,p)});return i.concat(c)}}function Wi(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 ve)t=t.concat(Wi(r.definition));else if(r instanceof mt)t=ct(O(r.definition,a=>Wi(a.definition)));else if(!(r instanceof ae))throw Error("non exhaustive match");let n=Ji(r),i=e.length>1;if(n&&i){let a=_e(e);return t.concat(Wi(a))}else return t}var jl=class extends Br{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Vw(e,t){let r=new jl;e.accept(r);let n=r.alternations;return Ue(n,a=>{let s=Hn(a.definition);return Ue(s,(o,l)=>{let c=Mf([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 Hw(e,t,r){let n=new jl;e.accept(n);let i=n.alternations;return i=Ta(i,s=>s.ignoreAmbiguities===!0),Ue(i,s=>{let o=s.idx,l=s.maxLookahead||t,c=Ml(o,e,l,s),u=Ww(c,s,e,r),p=Yw(c,s,e,r);return u.concat(p)})}var Kw=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 qw(e,t){let r=new jl;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 zw(e,t,r){let n=[];return C(e,i=>{let a=new Kw;i.accept(a);let s=a.allProductions;C(s,o=>{let l=Df(o),c=o.maxLookahead||t,u=o.idx,f=Dl(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 Ww(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&&cl(f,u)&&t.definition[h].ignoreAmbiguities!==!0&&p.push(h)}),p.length>1&&!cl(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 Yw(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&&Cw(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 Qw(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 Xw(e){let t=wl(e,{errMsgProvider:bw}),r={};return C(e.rules,n=>{r[n.name]=n}),xw(r,t.errMsgProvider)}function Bw(e){return e=wl(e,{errMsgProvider:br}),Fw(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Kf="MismatchedTokenException",qf="NoViableAltException",zf="EarlyExitException",Wf="NotAllInputParsedException",Yf=[Kf,qf,zf,Wf];Object.freeze(Yf);function ra(e){return De(Yf,e.name)}var Aa=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 Aa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Kf}},Jw=class extends Aa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=qf}},Zw=class extends Aa{constructor(e,t){super(e,t),this.name=Wf}},Uw=class extends Aa{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=zf}},Jo={},Xf="InRuleRecoveryException",ek=class extends Error{constructor(e){super(e),this.name=Xf}},tk=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=w(e,"recoveryEnabled")?e.recoveryEnabled:jt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=rk)}getTokenToInsert(e){let t=Fl(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 ek("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=>yw(t,i));if(n!==void 0)return n;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Jo;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]=Jo: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===Jo)return[Ar];let t=e.ruleName+e.idxInCallingRule+Pf+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 rk(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 nk=4,ar=8,ik=8,Bf=1<<ar,Jf=2<<ar,ul=3<<ar,pl=4<<ar,dl=5<<ar,Yi=6<<ar;function Zo(e,t,r){return r|t|e}var nR=32-ik,ak=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=>Hf(t,t,br))}validateEmptyOrAlternatives(e){return Ue(e,t=>Vw(t,br))}validateAmbiguousAlternationAlternatives(e,t){return Ue(e,r=>Hw(r,t,br))}validateSomeNonEmptyLookaheadPath(e,t){return zw(e,t,br)}buildLookaheadForAlternation(e){return _w(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Ow)}buildLookaheadForOptional(e){return Nw(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Df(e.prodType),Sw)}},sk=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 ak({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}=lk(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=Zo(this.fullRuleNameToShort[t.name],Bf,l.idx);this.setLaFuncCache(p,u)})}),C(n,l=>{this.computeLookaheadFunc(t,l.idx,ul,"Repetition",l.maxLookahead,At(l))}),C(i,l=>{this.computeLookaheadFunc(t,l.idx,Jf,"Option",l.maxLookahead,At(l))}),C(a,l=>{this.computeLookaheadFunc(t,l.idx,pl,"RepetitionMandatory",l.maxLookahead,At(l))}),C(s,l=>{this.computeLookaheadFunc(t,l.idx,Yi,"RepetitionMandatoryWithSeparator",l.maxLookahead,At(l))}),C(o,l=>{this.computeLookaheadFunc(t,l.idx,dl,"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=Zo(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(o,s)})}getKeyForAutomaticLookahead(e,t){return Zo(this.currRuleShortName,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},ok=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)}},Vi=new ok;function lk(e){Vi.reset(),e.accept(Vi);let t=Vi.dslMethods;return Vi.reset(),t}function Sd(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function wd(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 ck(e,t,r){e.children[r]===void 0?e.children[r]=[t]:e.children[r].push(t)}function uk(e,t,r){e.children[t]===void 0?e.children[t]=[r]:e.children[t].push(r)}var pk="name";function Zf(e,t){Object.defineProperty(e,pk,{enumerable:!1,configurable:!0,writable:!1,value:t})}function dk(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 fk(e,t){let r=function(){};Zf(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=mk(this,t);if(!Z(i)){let a=O(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
90
91
|
${a.join(`
|
|
91
92
|
|
|
92
93
|
`).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
|
+
`)}`)}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=t,r}function hk(e,t,r){let n=function(){};Zf(n,e+"BaseSemanticsWithDefaults");let i=Object.create(r.prototype);return C(t,a=>{i[a]=dk}),n.prototype=i,n.prototype.constructor=n,n}var fl;(function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"})(fl||(fl={}));function mk(e,t){return gk(e,t)}function gk(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:fl.MISSING_METHOD,methodName:i}));return Jn(n)}var Tk=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=wd,this.setNodeLocationFromNode=wd,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=Sd,this.setNodeLocationFromNode=Sd,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];ck(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){let r=this.CST_STACK[this.CST_STACK.length-1];uk(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(Dt(this.baseCstVisitorConstructor)){let e=fk(this.className,Ke(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Dt(this.baseCstVisitorWithDefaultsConstructor)){let e=hk(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]}},yk=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()}},bk=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=ia){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=ia){let n=$w(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(ra(a))return!1;throw a}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return xS(xe(this.gastProductionsCache))}},xk=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=ta,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
95
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
95
96
|
For Further details.`);if(V(e)){if(Z(e))throw Error(`A Token Vocabulary cannot be empty.
|
|
96
97
|
Note that the first argument for the parser constructor
|
|
97
98
|
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
99
|
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(
|
|
100
|
-
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=w(r,"resyncEnabled")?r.resyncEnabled:
|
|
101
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(
|
|
102
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},
|
|
100
|
+
For Further details.`)}if(V(e))this.tokensMap=ze(e,(i,a)=>(i[a.name]=a,i),{});else if(w(e,"modes")&&ut(ct(xe(e.modes)),hw)){let i=ct(xe(e.modes)),a=kl(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(xe(e.modes)):xe(e),n=ut(r,i=>Z(i.categoryMatches));this.tokenMatcher=n?ta:Un,ei(xe(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'
|
|
101
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=w(r,"resyncEnabled")?r.resyncEnabled:ia.resyncEnabled,i=w(r,"recoveryValueFunc")?r.recoveryValueFunc:ia.recoveryValueFunc,a=this.ruleShortNameIdx<<nk+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(ra(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(Jf,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(pl,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,pl,e,Lw)}atLeastOneSepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(Yi,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,Nd],s,Yi,e,Nd)}else throw this.raiseEarlyExitException(e,oe.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let r=this.getKeyForAutomaticLookahead(ul,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,ul,e,Iw,a)}manySepFirstInternal(e,t){let r=this.getKeyForAutomaticLookahead(dl,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,_d],s,dl,e,_d)}}repetitionSepSecondInternal(e,t,r,n,i){for(;r();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,n,i],r,Yi,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let r=this.getKeyForAutomaticLookahead(Bf,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 ra(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===Xf?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 Zw(r,t))}for(;this.tokVector.at(-1)===qr;)this.tokVector.pop()}},vk=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=w(e,"errorMessageProvider")?e.errorMessageProvider:jt.errorMessageProvider}SAVE_ERROR(e){if(ra(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=Dl(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 Uw(l,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let r=this.getCurrRuleFullName(),n=this.getGAstProductions()[r],i=Ml(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 Jw(o,this.LA(1),s))}},Ak=class{initContentAssist(){}computeContentAssist(e,t){let r=this.gastProductionsCache[e];if(Dt(r))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Mf([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=dt(e.ruleStack),n=this.getGAstProductions()[t];return new Ew(n,e).startWalking()}},Ea={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ea);var kd=!0,Cd=Math.pow(2,ar)-1,Uf=xa({name:"RECORDING_PHASE_TOKEN",pattern:Ne.NA});ei([Uf]);var eh=Fl(Uf,`This IToken indicates the Parser is in Recording Phase
|
|
102
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(eh);var Ek={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
103
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Ik=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
104
|
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,
|
|
105
|
-
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=
|
|
106
|
-
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=
|
|
107
|
-
Idx value must be a none negative value smaller than ${
|
|
105
|
+
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,kd)}manyInternalRecord(e,t){kn.call(this,ve,t,e)}manySepFirstInternalRecord(e,t){kn.call(this,ht,t,e,kd)}orInternalRecord(e,t){return Lk.call(this,e,t)}subruleInternalRecord(e,t,r){if(na(t),!e||w(e,"ruleName")===!1){let s=new Error(`<SUBRULE${Rd(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|
106
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let n=xr(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?Ek:Ea}consumeInternalRecord(e,t,r){if(na(t),!Cf(e)){let a=new Error(`<CONSUME${Rd(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|
107
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}let n=xr(this.recordingProdStack),i=new ae({idx:t,terminalType:e,label:r==null?void 0:r.LABEL});return n.definition.push(i),eh}};function kn(e,t,r,n=!1){na(r);let i=xr(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(),Ea}function Lk(e,t){na(t);let r=xr(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=Af(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()}),Ea}function Rd(e){return e===0?"":`${e}`}function na(e){if(e<0||e>Cd){let t=new Error(`Invalid DSL Method idx value: <${e}>
|
|
108
|
+
Idx value must be a none negative value smaller than ${Cd+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Pk=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}=If(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 _k(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=Fl(Ar,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(qr);var jt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Ff,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ia=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 Gl=class th{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",()=>{Lf(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=Xw({rules:xe(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(Z(n)&&this.skipValidations===!1){let i=Bw({rules:xe(this.gastProductionsCache),tokenTypes:xe(this.tokensMap),errMsgProvider:br,grammarName:r}),a=Rw({lookaheadStrategy:this.lookaheadStrategy,rules:xe(this.gastProductionsCache),tokenTypes:xe(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(i,a)}}),Z(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let i=_S(xe(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:xe(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(xe(this.gastProductionsCache))})),!th.DEFER_DEFINITION_ERRORS_HANDLING&&!Z(this.definitionErrors))throw t=O(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
|
|
108
109
|
${t.join(`
|
|
109
110
|
-------------------------------
|
|
110
111
|
`)}`)})}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
112
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
112
113
|
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}};
|
|
114
|
+
For further details.`);this.skipValidations=w(r,"skipValidations")?r.skipValidations:jt.skipValidations}};Gl.DEFER_DEFINITION_ERRORS_HANDLING=!1;_k(Gl,[tk,sk,Tk,yk,xk,bk,vk,Ak,Ik,Pk]);var rh=class extends Gl{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 xa(e)}var ce="When you use this string, you expect traqula to handle indentation after every newline";function $l(e){let t=Object.create(null);for(let r of e)t[r.name]=r;return t}var Ia=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($l(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,...$l(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 Ia(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 La=class extends rh{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 nh(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(nh(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,...nh(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
115
|
`)[a-1];i.push(` on line ${a}
|
|
115
116
|
${s}`);let o=n.token.startColumn;o!==void 0&&i.push(`
|
|
116
117
|
${"-".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(`
|
|
118
|
+
${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 La(this.rules,t,r)}};function $t(e){return e instanceof Promise}var Pa=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"],v=[],x=[],A=[],y=[],L=[];function S(){for(;h.length===v.at(-1);){v.pop();let Y=x.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(v.push(h.length),x.push(Re),A.push(Y),y.push(pe),L.push(ye),we&&!p)for(let vt in Re){if(!Object.hasOwn(Re,vt))continue;let me=Re[vt],Fe=Ae&&(Ae==null?void 0:Ae.has(vt));Fe&&(Re[vt]=this.cloneObj(me)),!(Le&&Le.has(vt))&&!Fe&&me!==null&&typeof me=="object"&&(h.push(me),T.push(vt),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];v.push(h.length),x.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"],v=[0];function x(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()),v.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)){x(pe,Y+1);return}if(we){h.push(pe),g.push(B),T.push(te),v.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),v.push(0)))}},y=()=>{for(;!p&&h.length>0&&h.length<this.maxStackSize;){let G=h.pop(),B=g.pop(),te=T.pop(),Y=v.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,x(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 v,x;let a=this.defaultContext,s=(v=a.continue)!=null?v:!0,o=a.ignoreKeys,l=(x=a.shortcut)!=null?x:!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 _a=class e extends Pa{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 _a{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:()=>lu,additiveExpression:()=>Ty,aggregate:()=>Fs,aggregateAvg:()=>kT,aggregateCount:()=>NT,aggregateGroup_concat:()=>RT,aggregateMax:()=>wT,aggregateMin:()=>ST,aggregateSample:()=>CT,aggregateSum:()=>OT,argList:()=>ln,askQuery:()=>yi,baseAggregateFunc:()=>Cr,baseDecl:()=>yc,bind:()=>jc,blankNode:()=>Os,blankNodePropertyList:()=>oy,blankNodePropertyListPath:()=>wc,booleanLiteral:()=>wr,brackettedExpression:()=>cn,builtInAbs:()=>Mg,builtInBnodeSparqlJs:()=>Rg,builtInBound:()=>wg,builtInCall:()=>qt,builtInCallList:()=>AT,builtInCeil:()=>Dg,builtInCoalesce:()=>dT,builtInConcat:()=>$g,builtInContains:()=>zg,builtInDatatype:()=>Sg,builtInDay:()=>Zg,builtInEncode_for_uri:()=>qg,builtInFloor:()=>jg,builtInHours:()=>Ug,builtInIf:()=>fT,builtInIri:()=>kg,builtInIsblank:()=>bT,builtInIsiri:()=>TT,builtInIsliteral:()=>xT,builtInIsnumeric:()=>vT,builtInIsuri:()=>yT,builtInLang:()=>Ng,builtInLangmatches:()=>Og,builtInLcase:()=>Kg,builtInMd5:()=>oT,builtInMinutes:()=>eT,builtInMonth:()=>Jg,builtInNow:()=>iT,builtInRand:()=>Fg,builtInRound:()=>Gg,builtInSameterm:()=>gT,builtInSeconds:()=>tT,builtInSha1:()=>lT,builtInSha256:()=>cT,builtInSha384:()=>uT,builtInSha512:()=>pT,builtInStr:()=>_g,builtInStrafter:()=>Xg,builtInStrbefore:()=>Qg,builtInStrdt:()=>mT,builtInStrends:()=>Yg,builtInStrlang:()=>hT,builtInStrlen:()=>Vg,builtInStrstarts:()=>Wg,builtInStruuid:()=>sT,builtInTimezone:()=>rT,builtInTz:()=>nT,builtInUcase:()=>Hg,builtInUri:()=>Cg,builtInUuid:()=>aT,builtInYear:()=>Bg,canCreateBlankNodes:()=>Sk,clear:()=>au,collection:()=>iy,collectionPath:()=>Sc,conditionalAndExpression:()=>zc,conditionalOrExpression:()=>my,constraint:()=>fi,constructQuery:()=>gi,constructTemplate:()=>nu,constructTriples:()=>vy,copy:()=>uu,create:()=>ou,dataBlock:()=>py,dataBlockValue:()=>Kc,datasetClause:()=>Eg,datasetClauseStar:()=>Tt,datasetClauseUsing:()=>Ac,datasetClauseUsingStar:()=>Ec,defaultGraphClause:()=>Ig,deleteClause:()=>Ey,deleteData:()=>du,deleteWhere:()=>fu,describeQuery:()=>Ti,drop:()=>su,existsFunc:()=>PT,expression:()=>F,expressionList:()=>Rs,filter:()=>Vc,funcExpr1:()=>D,funcExpr2:()=>yt,funcExpr2or3:()=>ks,funcExpr3:()=>an,funcExpr3or4:()=>_c,funcExprList1:()=>ws,funcExprOrNil1:()=>Pc,funcGroupGraphPattern:()=>Cs,funcNil1:()=>sn,funcVar1:()=>Lc,functionCall:()=>$s,generatePattern:()=>cy,graphGraphPattern:()=>Mc,graphNode:()=>Rc,graphNodePath:()=>St,graphOrDefault:()=>gu,graphPatternNotTriples:()=>Hc,graphRef:()=>xi,graphRefAll:()=>Fr,graphTerm:()=>xc,groupClause:()=>Jc,groupCondition:()=>yy,groupGraphPattern:()=>ne,groupGraphPatternSub:()=>uy,groupOrUnionGraphPattern:()=>$c,havingClause:()=>Zc,havingCondition:()=>by,inlineData:()=>on,inlineDataFull:()=>fy,inlineDataOneVar:()=>dy,insertClause:()=>mu,insertData:()=>pu,iri:()=>K,iriFull:()=>nn,iriOrFunction:()=>Bc,limitClause:()=>tu,limitOffsetClauses:()=>eu,load:()=>iu,minusGraphPattern:()=>Gc,modify:()=>hu,move:()=>cu,multiplicativeExpression:()=>Qc,namedGraphClause:()=>Pg,notExistsFunc:()=>_T,numericExpression:()=>Yc,numericLiteral:()=>Sr,numericLiteralNegative:()=>_s,numericLiteralPositive:()=>Ps,numericLiteralUnsigned:()=>Ag,object:()=>ty,objectList:()=>ZT,objectListPath:()=>UT,objectPath:()=>ry,offsetClause:()=>ru,optionalGraphPattern:()=>Fc,orderClause:()=>Uc,orderCondition:()=>xy,path:()=>Ds,pathAlternative:()=>DT,pathChainHelper:()=>Oc,pathElt:()=>Nc,pathEltOrInverse:()=>FT,pathGenerator:()=>zt,pathMod:()=>jT,pathNegatedPropertySet:()=>$T,pathOneInPropertySet:()=>Ms,pathPrimary:()=>GT,pathSequence:()=>MT,prefixDecl:()=>bc,prefixedName:()=>Tc,primaryExpression:()=>Xc,prologue:()=>it,propertyList:()=>WT,propertyListNotEmpty:()=>js,propertyListPath:()=>YT,propertyListPathNotEmpty:()=>Gs,quadData:()=>bu,quadPattern:()=>qs,quads:()=>dn,quadsNotTriples:()=>Tu,query:()=>un,queryOrUpdate:()=>Fk,queryUnit:()=>Ck,rdfLiteral:()=>pr,regexExpression:()=>ET,relationalExpression:()=>gy,selectClause:()=>Hs,selectQuery:()=>mi,serviceGraphPattern:()=>Dc,solutionModifier:()=>st,sourceSelector:()=>Ic,strReplaceExpression:()=>LT,string:()=>Ns,stringEscapedLexical:()=>di,subSelect:()=>qc,substringExpression:()=>IT,triplesBlock:()=>wt,triplesNode:()=>kc,triplesNodePath:()=>Cc,triplesSameSubject:()=>KT,triplesSameSubjectPath:()=>qT,triplesTemplate:()=>Rr,unaryExpression:()=>Vs,update:()=>Ks,update1:()=>pn,updateUnit:()=>Rk,usingClause:()=>Lg,usingClauseStar:()=>Ss,valueLogical:()=>Wc,valuesClause:()=>bi,varOrIri:()=>Kt,varOrTerm:()=>Se,var_:()=>ee,verb:()=>vc,verbA:()=>kr,verbPath:()=>XT,verbSimple:()=>BT,whereClause:()=>at});var q={};Ze(q,{a:()=>en,add:()=>rs,allBaseTokens:()=>pg,as:()=>sr,ask:()=>Ha,baseDecl:()=>Ma,bind:()=>ms,builtIn:()=>I,by:()=>oi,clear:()=>Ua,construct:()=>$a,copy:()=>as,create:()=>ts,deleteClause:()=>cs,deleteDataClause:()=>os,deleteWhereClause:()=>ls,describe:()=>Va,distinct:()=>gt,drop:()=>es,false_:()=>vs,filter:()=>bs,from:()=>Ka,graph:()=>ke,groupByGroup:()=>si,having:()=>qa,in_:()=>As,insertClause:()=>ps,insertDataClause:()=>us,limit:()=>Qa,load:()=>Ja,loadInto:()=>Za,minus:()=>Ts,modifyWith:()=>ss,move:()=>is,notIn:()=>Es,offset:()=>Xa,optional:()=>fs,order:()=>za,orderAsc:()=>Wa,orderDesc:()=>Ya,patterns:()=>Fa,prefixDecl:()=>Da,reduced:()=>Ga,select:()=>ja,separator:()=>Is,service:()=>hs,silent:()=>Vt,sparql11LexerBuilder:()=>Nk,symbols:()=>b,terminals:()=>M,to:()=>ns,true_:()=>xs,undef:()=>gs,union:()=>ys,usingClause:()=>ds,values:()=>Ba,where:()=>or});var I={};Ze(I,{BuiltInCalls:()=>P,abs:()=>fh,allBuiltInCalls:()=>Vl,avg:()=>Na,bnode:()=>ph,bound:()=>lh,ceil:()=>hh,coalesce:()=>Kh,concat:()=>Th,contains:()=>Ah,count:()=>im,datatype:()=>oh,day:()=>Oh,encode_for_uri:()=>vh,exists:()=>rm,floor:()=>mh,groupConcat:()=>Oa,hours:()=>Sh,if_:()=>qh,iri:()=>ch,isblank:()=>Bh,isiri:()=>Qh,isliteral:()=>Jh,isnumeric:()=>Zh,isuri:()=>Xh,lang:()=>ah,langmatches:()=>sh,lcase:()=>xh,max:()=>om,md5:()=>jh,min:()=>sm,minutes:()=>wh,month:()=>Nh,notexists:()=>nm,now:()=>Fh,rand:()=>dh,regex:()=>Uh,replace:()=>tm,round:()=>gh,sameterm:()=>Yh,sample:()=>lm,seconds:()=>kh,sha1:()=>Gh,sha256:()=>$h,sha384:()=>Vh,sha512:()=>Hh,str:()=>ih,strafter:()=>Ph,strbefore:()=>Lh,strdt:()=>Wh,strends:()=>Ih,strlang:()=>zh,strlen:()=>yh,strstarts:()=>Eh,struuid:()=>Dh,substr:()=>em,sum:()=>am,timezone:()=>Ch,tz:()=>Rh,ucase:()=>bh,uri:()=>uh,uuid:()=>Mh,year:()=>_h});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 ih=m({name:_(P.Str),pattern:/str/i,label:"STR"}),ah=m({name:_(P.Lang),pattern:/lang/i,label:"LANG"}),sh=m({name:_(P.Langmatches),pattern:/langmatches/i,label:"LANGMATCHES"}),oh=m({name:_(P.Datatype),pattern:/datatype/i,label:"DATATYPE"}),lh=m({name:_(P.Bound),pattern:/bound/i,label:"BOUND"}),ch=m({name:_(P.Iri),pattern:/iri/i,label:"IRI"}),uh=m({name:_(P.Uri),pattern:/uri/i,label:"URI"}),ph=m({name:_(P.Bnode),pattern:/bnode/i,label:"BNODE"}),dh=m({name:_(P.Rand),pattern:/rand/i,label:"RAND"}),fh=m({name:_(P.Abs),pattern:/abs/i,label:"ABS"}),hh=m({name:_(P.Ceil),pattern:/ceil/i,label:"CEIL"}),mh=m({name:_(P.Floor),pattern:/floor/i,label:"FLOOR"}),gh=m({name:_(P.Round),pattern:/round/i,label:"ROUND"}),Th=m({name:_(P.Concat),pattern:/concat/i,label:"CONCAT"}),yh=m({name:_(P.Strlen),pattern:/strlen/i,label:"STRLEN"}),bh=m({name:_(P.Ucase),pattern:/ucase/i,label:"UCASE"}),xh=m({name:_(P.Lcase),pattern:/lcase/i,label:"LCASE"}),vh=m({name:_(P.Encode_for_uri),pattern:/encode_for_uri/i,label:"ENCODE_FOR_URI"}),Ah=m({name:_(P.Contains),pattern:/contains/i,label:"CONTAINS"}),Eh=m({name:_(P.Strstarts),pattern:/strstarts/i,label:"STRSTARTS"}),Ih=m({name:_(P.Strends),pattern:/strends/i,label:"STRENDS"}),Lh=m({name:_(P.Strbefore),pattern:/strbefore/i,label:"STRBEFORE"}),Ph=m({name:_(P.Strafter),pattern:/strafter/i,label:"STRAFTER"}),_h=m({name:_(P.Year),pattern:/year/i,label:"YEAR"}),Nh=m({name:_(P.Month),pattern:/month/i,label:"MONTH"}),Oh=m({name:_(P.Day),pattern:/day/i,label:"DAY"}),Sh=m({name:_(P.Hours),pattern:/hours/i,label:"HOURS"}),wh=m({name:_(P.Minutes),pattern:/minutes/i,label:"MINUTES"}),kh=m({name:_(P.Seconds),pattern:/seconds/i,label:"SECONDS"}),Ch=m({name:_(P.Timezone),pattern:/timezone/i,label:"TIMEZONE"}),Rh=m({name:_(P.Tz),pattern:/tz/i,label:"TZ"}),Fh=m({name:_(P.Now),pattern:/now/i,label:"NOW"}),Mh=m({name:_(P.Uuid),pattern:/uuid/i,label:"UUID"}),Dh=m({name:_(P.Struuid),pattern:/struuid/i,label:"STRUUID"}),jh=m({name:_(P.Md5),pattern:/md5/i,label:"MD5"}),Gh=m({name:_(P.Sha1),pattern:/sha1/i,label:"SHA1"}),$h=m({name:_(P.Sha256),pattern:/sha256/i,label:"SHA256"}),Vh=m({name:_(P.Sha384),pattern:/sha384/i,label:"SHA384"}),Hh=m({name:_(P.Sha512),pattern:/sha512/i,label:"SHA512"}),Kh=m({name:_(P.Coalesce),pattern:/coalesce/i,label:"COALESCE"}),qh=m({name:_(P.If),pattern:/if/i,label:"IF"}),zh=m({name:_(P.Strlang),pattern:/strlang/i,label:"STRLANG"}),Wh=m({name:_(P.Strdt),pattern:/strdt/i,label:"STRDT"}),Yh=m({name:_(P.Sameterm),pattern:/sameterm/i,label:"SAMETERM"}),Qh=m({name:_(P.Isiri),pattern:/isiri/i,label:"ISIRI"}),Xh=m({name:_(P.Isuri),pattern:/isuri/i,label:"ISURI"}),Bh=m({name:_(P.Isblank),pattern:/isblank/i,label:"ISBLANK"}),Jh=m({name:_(P.Isliteral),pattern:/isliteral/i,label:"ISLITERAL"}),Zh=m({name:_(P.Isnumeric),pattern:/isnumeric/i,label:"ISNUMERIC"}),Uh=m({name:_(P.Regex),pattern:/regex/i,label:"REGEX"}),em=m({name:_(P.Substr),pattern:/substr/i,label:"SUBSTR"}),tm=m({name:_(P.Replace),pattern:/replace/i,label:"REPLACE"}),rm=m({name:_(P.Exists),pattern:/exists/i,label:"EXISTS"}),nm=m({name:_(P.Notexists),pattern:/not exists/i,label:"NOT EXISTS"}),im=m({name:_(P.Count),pattern:/count/i,label:"COUNT"}),am=m({name:_(P.Sum),pattern:/sum/i,label:"SUM"}),sm=m({name:_(P.Min),pattern:/min/i,label:"MIN"}),om=m({name:_(P.Max),pattern:/max/i,label:"MAX"}),Na=m({name:_(P.Avg),pattern:/avg/i,label:"AVG"}),lm=m({name:_(P.Sample),pattern:/sample/i,label:"SAMPLE"}),Oa=m({name:_(P.Group_concat),pattern:/group_concat/i,label:"GROUP_CONCAT"}),Vl=Oe.create().add(sh,oh,ah,lh,ch,uh,ph,dh,fh,hh,mh,gh,Th,yh,bh,xh,vh,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,im,am,sm,om,Na,lm,Oa,ih);var ke={};Ze(ke,{allGraphTokens:()=>Hl,default_:()=>um,graph:()=>pm,graphAll:()=>Sa,named:()=>cm});var cm=m({name:"NamedGraph",pattern:/named/i,label:"NAMED"}),um=m({name:"DefaultGraph",pattern:/default/i,label:"DEFAULT"}),pm=m({name:"Graph",pattern:/graph/i,label:"GRAPH"}),Sa=m({name:"GraphAll",pattern:/all/i,label:"ALL"}),Hl=Oe.create().add(cm,um,pm,Sa);var Fa={};Ze(Fa,{anonPattern:()=>lc,atLeastOneBlankPattern:()=>ai,blankNodeLabelPattern:()=>Yl,commentPattern:()=>Ra,decimalNegativePattern:()=>tc,decimalPattern:()=>ri,decimalPositivePattern:()=>Zl,doubleNegativePattern:()=>rc,doublePattern:()=>ni,doublePositivePattern:()=>Ul,echarPattern:()=>ii,exponentPattern:()=>ka,integerNegativePattern:()=>ec,integerPattern:()=>ti,integerPositivePattern:()=>Jl,iriRefPattern:()=>zl,langTagPattern:()=>Bl,nilPattern:()=>oc,pNameLnPattern:()=>Wl,pNameNsPattern:()=>Ca,percentPattern:()=>fm,plxPattern:()=>wa,pnCharsBasePattern:()=>Kl,pnCharsPattern:()=>_r,pnCharsUPattern:()=>Zr,pnLocalEscPattern:()=>hm,pnLocalPattern:()=>mm,pnPrefixPattern:()=>dm,stringLiteral1Pattern:()=>nc,stringLiteral2Pattern:()=>ic,stringLiteralLong1Pattern:()=>ac,stringLiteralLong2Pattern:()=>sc,var1Pattern:()=>Ql,var2Pattern:()=>Xl,varNamePattern:()=>ql,wsPattern:()=>Ur});var Kl=/[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(`(${Kl.source})|_`),ql=new RegExp(`((${Zr.source})|[0-9])((${Zr.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`),zl=/<([^\u0000-\u0020"<>\\^`{|}])*>/,_r=new RegExp(`(${Zr.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`),dm=new RegExp(`(${Kl.source})(((${_r.source})|\\.)*(${_r.source}))?`),Ca=new RegExp(`(${dm.source})?:`),fm=/%[\dA-Fa-f]{2}/,hm=/\\[!#$%&'()*+,./;=?@_~-]/,wa=new RegExp(`(${fm.source})|(${hm.source})`),mm=new RegExp(`((${Zr.source})|:|[0-9]|(${wa.source}))(((${_r.source})|\\.|:|(${wa.source}))*((${_r.source})|:|(${wa.source})))?`),Wl=new RegExp(`(${Ca.source})(${mm.source})`),Yl=new RegExp(`_:((${Zr.source})|[0-9])(((${_r.source})|\\.)*(${_r.source}))?`),Ql=new RegExp(`\\?(${ql.source})`),Xl=new RegExp(`\\$(${ql.source})`),Bl=/@[A-Za-z]+(-[\dA-Za-z]+)*/,ti=/\d+/,ri=/\d+\.\d+/,ka=/[Ee][+-]?\d+/,ni=new RegExp(`([0-9]+\\.[0-9]*(${ka.source}))|(\\.[0-9]+(${ka.source}))|([0-9]+(${ka.source}))`),Jl=new RegExp(`\\+(${ti.source})`),Zl=new RegExp(`\\+(${ri.source})`),Ul=new RegExp(`\\+(${ni.source})`),ec=new RegExp(`-(${ti.source})`),tc=new RegExp(`-(${ri.source})`),rc=new RegExp(`-(${ni.source})`),ii=/\\["'\\bfnrt]/,nc=new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${ii.source}))*'`),ic=new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${ii.source}))*"`),ac=new RegExp(`'''(('|(''))?([^'\\\\]|(${ii.source})))*'''`),sc=new RegExp(`"""(("|(""))?([^"\\\\]|(${ii.source})))*"""`),Ur=/[\u0009\u000A\u000D ]/,oc=new RegExp(`\\((${Ur.source})*\\)`),lc=new RegExp(`\\[(${Ur.source})*\\]`),Ra=/#[^\n]*/,ai=new RegExp(`(((${Ur.source})+)|((${Ra.source})
|
|
119
|
+
))+`);var b={};Ze(b,{LCurly:()=>gm,LParen:()=>vm,LSquare:()=>Em,RCurly:()=>Tm,RParen:()=>Am,RSquare:()=>Im,allSymbols:()=>cc,comma:()=>bm,dot:()=>ym,equal:()=>Fm,exclamation:()=>km,greaterThan:()=>jm,greaterThanEqual:()=>$m,hat:()=>_m,hathat:()=>Vm,lessThan:()=>Dm,lessThanEqual:()=>Gm,logicAnd:()=>Cm,logicOr:()=>Rm,notEqual:()=>Mm,opMinus:()=>wm,opPlus:()=>Sm,pipe:()=>Lm,question:()=>Nm,semi:()=>xm,slash:()=>Pm,star:()=>Om});var gm=m({name:"LCurly",pattern:"{",label:"{"}),Tm=m({name:"RCurly",pattern:"}",label:"}"}),ym=m({name:"Dot",pattern:".",label:"."}),bm=m({name:"Comma",pattern:",",label:","}),xm=m({name:"Semi",pattern:";",label:";"}),vm=m({name:"LParen",pattern:"(",label:"("}),Am=m({name:"RParen",pattern:")",label:")"}),Em=m({name:"LSquare",pattern:"[",label:"["}),Im=m({name:"RSquare",pattern:"]",label:"]"}),Lm=m({name:"Pipe",pattern:"|",label:"|"}),Pm=m({name:"Slash",pattern:"/",label:"/"}),_m=m({name:"Hat",pattern:"^",label:"^"}),Nm=m({name:"Question",pattern:"?",label:"?"}),Om=m({name:"Star",pattern:"*",label:"*"}),Sm=m({name:"OpPlus",pattern:"+",label:"+"}),wm=m({name:"OpMinus",pattern:"-",label:"-"}),km=m({name:"Exclamation",pattern:"!",label:"!"}),Cm=m({name:"LogicAnd",pattern:"&&",label:"&&"}),Rm=m({name:"LogicOr",pattern:"||",label:"||"}),Fm=m({name:"Equal",pattern:"=",label:"="}),Mm=m({name:"NotEqual",pattern:"!=",label:"!="}),Dm=m({name:"LessThan",pattern:"<",label:"<"}),jm=m({name:"GreaterThan",pattern:">",label:">"}),Gm=m({name:"LessThanEqual",pattern:"<=",label:"<="}),$m=m({name:"GreaterThanEqual",pattern:">=",label:">="}),Vm=m({name:"Hathat",pattern:"^^",label:"^^"}),cc=Oe.create().add(Cm,Rm,Mm,Gm,$m,gm,Tm,ym,bm,xm,vm,Am,Em,Im,Lm,Pm,Vm,_m,Nm,Om,Sm,wm,km,Fm,Dm,jm);var M={};Ze(M,{allTerminals:()=>pc,anon:()=>ug,blankNodeLabel:()=>qm,comment:()=>lg,decimal:()=>Xm,decimalNegative:()=>tg,decimalPositive:()=>Zm,double:()=>Bm,doubleNegative:()=>rg,doublePositive:()=>Um,integer:()=>Qm,integerNegative:()=>eg,integerPositive:()=>Jm,iriRef:()=>Hm,langTag:()=>Ym,nil:()=>cg,pNameLn:()=>uc,pNameNs:()=>Km,stringLiteral1:()=>ng,stringLiteral2:()=>ig,stringLiteralLong1:()=>ag,stringLiteralLong2:()=>sg,var1:()=>zm,var2:()=>Wm,ws:()=>og});var Hm=m({name:"IriRef",pattern:zl}),uc=m({name:"PNameLn",pattern:Wl}),Km=m({name:"PNameNs",pattern:Ca,longer_alt:[uc]}),qm=m({name:"BlankNodeLabel",pattern:Yl}),zm=m({name:"Var1",pattern:Ql}),Wm=m({name:"Var2",pattern:Xl}),Ym=m({name:"LangTag",pattern:Bl}),Qm=m({name:"Integer",pattern:ti}),Xm=m({name:"Decimal",pattern:ri}),Bm=m({name:"Double",pattern:ni}),Jm=m({name:"IntegerPositive",pattern:Jl}),Zm=m({name:"DecimalPositive",pattern:Zl}),Um=m({name:"DoublePositive",pattern:Ul}),eg=m({name:"IntegerNegative",pattern:ec}),tg=m({name:"DecimalNegative",pattern:tc}),rg=m({name:"DoubleNegative",pattern:rc}),ng=m({name:"StringLiteral1",pattern:nc}),ig=m({name:"StringLiteral2",pattern:ic}),ag=m({name:"StringLiteralLong1",pattern:ac}),sg=m({name:"StringLiteralLong2",pattern:sc}),og=m({name:"Ws",pattern:Ur,group:Ne.SKIPPED}),lg=m({name:"Comment",pattern:Ra,group:Ne.SKIPPED}),cg=m({name:"Nil",pattern:oc}),ug=m({name:"Anon",pattern:lc}),pc=Oe.create().add(Hm,Km,uc,qm,zm,Wm,Ym,Bm,Xm,Qm,Um,Zm,Jm,rg,tg,eg,ag,sg,ng,ig,og,lg,cg,ug);var Ma=m({name:"BaseDecl",pattern:/base/i,label:"BASE"}),Da=m({name:"PrefixDecl",pattern:/prefix/i,label:"PREFIX"}),ja=m({name:"Select",pattern:/select/i,label:"SELECT"}),gt=m({name:"Distinct",pattern:/distinct/i,label:"DISTINCT"}),Ga=m({name:"Reduced",pattern:/reduced/i,label:"REDUCED"}),sr=m({name:"As",pattern:/as/i,label:"AS"}),$a=m({name:"Construct",pattern:/construct/i,label:"CONSTRUCT"}),Va=m({name:"Describe",pattern:/describe/i,label:"DESCRIBE"}),Ha=m({name:"Ask",pattern:/ask/i,label:"ASK"}),Ka=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"}),qa=m({name:"Having",pattern:/having/i,label:"HAVING"}),za=m({name:"Order",pattern:/order/i,label:"_ORDER_ BY"}),Wa=m({name:"OrderAsc",pattern:/asc/i,label:"ASC"}),Ya=m({name:"OrderDesc",pattern:/desc/i,label:"DESC"}),Qa=m({name:"Limit",pattern:/limit/i,label:"LIMIT"}),Xa=m({name:"Offset",pattern:/offset/i,label:"OFFSET"}),Ba=m({name:"Values",pattern:/values/i,label:"VALUES"}),Ja=m({name:"Load",pattern:/load/i,label:"LOAD"}),Vt=m({name:"Silent",pattern:/silent/i,label:"SILENT"}),Za=m({name:"LoadInto",pattern:/into/i,label:"INTO"}),Ua=m({name:"Clear",pattern:/clear/i,label:"CLEAR"}),es=m({name:"Drop",pattern:/drop/i,label:"DROP"}),ts=m({name:"Create",pattern:/create/i,label:"CREATE"}),rs=m({name:"Add",pattern:/add/i,label:"ADD"}),ns=m({name:"To",pattern:/to/i,label:"TO"}),is=m({name:"Move",pattern:/move/i,label:"MOVE"}),as=m({name:"Copy",pattern:/copy/i,label:"COPY"}),ss=m({name:"ModifyWith",pattern:/with/i,label:"WITH"}),os=m({name:"DeleteDataClause",pattern:new RegExp(`delete(${ai.source})data`,"i"),label:"DELETE DATA"}),ls=m({name:"DeleteWhereClause",pattern:new RegExp(`delete(${ai.source})where`,"i"),label:"DELETE WHERE"}),cs=m({name:"DeleteClause",pattern:/delete/i,label:"DELETE"}),us=m({name:"InsertDataClause",pattern:new RegExp(`insert(${ai.source})data`,"i"),label:"INSERT DATA"}),ps=m({name:"InsertClause",pattern:/insert/i,label:"insert"}),ds=m({name:"UsingClause",pattern:/using/i,label:"USING"}),fs=m({name:"Optional",pattern:/optional/i,label:"OPTIONAL"}),hs=m({name:"Service",pattern:/service/i,label:"SERVICE"}),ms=m({name:"Bind",pattern:/bind/i,label:"BIND"}),gs=m({name:"Undef",pattern:/undef/i,label:"UNDEF"}),Ts=m({name:"Minus",pattern:/minus/i,label:"MINUS"}),ys=m({name:"Union",pattern:/union/i,label:"UNION"}),bs=m({name:"Filter",pattern:/filter/i,label:"FILTER"}),en=m({name:"a",pattern:"a",label:"type declaration 'a'"}),xs=m({name:"True",pattern:/true/i,label:"true"}),vs=m({name:"False",pattern:/false/i,label:"false"}),As=m({name:"In",pattern:/in/i,label:"IN"}),Es=m({name:"NotIn",pattern:/not[\u0020\u0009\u000D\u000A]+in/i,label:"NOT IN"}),Is=m({name:"Separator",pattern:/separator/i,label:"SEPARATOR"}),pg=Oe.create().add(Ma,Da,ja,gt,Ga,$a,Va,Ha,Ka,or,qa,si,oi,za,Wa,Ya,Qa,Xa,Ba,Ja,Vt,Za,Ua,es,ts,rs,ns,is,as,ss,ls,os,cs,us,ps,ds,fs,hs,ms,gs,Ts,ys,bs,sr,en,xs,vs,As,Es,Is),Nk=Oe.create(pc).merge(pg).merge(Vl).merge(Hl).merge(cc).moveAfter(Na,en).moveBefore(en,Sa).moveAfter(Oa,si);var pi={};Ze(pi,{checkBlankNodeBGPScope:()=>gc,checkNote13:()=>mc,findPatternBoundedVars:()=>ci,getAggregatesOfExpression:()=>Or,getExpressionId:()=>ur,getVariablesFromExpression:()=>li,queryProjectionIsGood:()=>hc,updateNoReuseBlankNodeLabels:()=>ui});var dc="contextDef";function dg(e){return class extends e{contextDefinitionPrefix(r,n,i){return{type:dc,subType:"prefix",key:n,value:i,loc:r}}isContextDefinitionPrefix(r){return this.isOfSubType(r,dc,"prefix")}contextDefinitionBase(r,n){return{type:"contextDef",subType:"base",value:n,loc:r}}isContextDefinitionBase(r){return this.isOfSubType(r,dc,"base")}}}var Ot="expression";function fg(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 hg(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 mg(e){return new fc(e)}var fc=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 gg(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 Tg(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 yg(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 bg(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 xg(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 vg(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 mg(Fi).call(dg).call(fg).call(hg).call(gg).call(Tg).call(yg).call(bg).call(xg).call(vg).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,Ls=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 hc(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 mc(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(Ls.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;Ls.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 gc(e){let t=new Map,r=[{}],n=()=>r.at(-1);function i(s){let o=new Set;return Ls.visitNodeSpecific(s,{},{term:{blankNode:{visitor:l=>{o.add(l.label)}}}}),o}let a={preVisitor:()=>(r.push({}),{}),visitor:()=>{r.pop(),r[r.length-1]={}}};Ls.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 Ok={" ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f",'"':'\\"',"\\":"\\\\"};function di(e){return`"${e.replaceAll(/["\\\t\n\r\b\f]/gu,r=>Ok[r])}"`}var pr={name:"rdfLiteral",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n,OR:i})=>a=>{var o;let s=t(Ns);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(Ag)},{ALT:()=>e(Ps)},{ALT:()=>e(_s)}])},Ag={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])))}},Ps={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])))}},_s={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(xs)},{ALT:()=>t(vs)}]);return e(()=>n.astFactory.termLiteral(n.astFactory.sourceLocation(i),i.image.toLowerCase(),n.astFactory.termNamed(n.astFactory.sourceLocation(),se.BOOLEAN)))}},Ns={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`
|
|
120
|
+
`;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(Tc)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermNamedPrefixed(t)?e(Tc,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,">"))}},Tc={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))}},Sk=Symbol("canCreateBlankNodes"),Os={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(yc))},{ALT:()=>n.push(e(bc))}])),n},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{for(let n of t)r.isContextDefinitionBase(n)?e(yc,n):e(bc,n)}},yc={name:"baseDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Ma),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())}},bc={name:"prefixDecl",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(Da),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(xc)}]),gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>r.isTermVariable(t)?e(ee,t):e(xc,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}`))}},xc={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(Os)},{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(Os,t)}};function Ac(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(Ig);return r(()=>s.astFactory.wrap({clauseType:"default",value:l},s.astFactory.sourceLocation(o,l)))}},{ALT:()=>{let l=n(Pg);return r(()=>s.astFactory.wrap({clauseType:"named",value:l.val},s.astFactory.sourceLocation(o,l)))}}])}}}var Eg=Ac("datasetClause",Ka),Ig={name:"defaultGraphClause",impl:({SUBRULE:e})=>()=>e(Ic)},Lg=Ac("usingClause",ds);function Ec(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=Ec("datasetClauses",Eg,"FROM"),Ss=Ec("usingClauses",Lg,"USING"),Pg={name:"namedGraphClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ke.named),a=t(Ic);return e(()=>n.astFactory.wrap(a,n.astFactory.sourceLocation(i,a)))}},Ic={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 Lc(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 Pc(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 ws(e){return{name:ge(e.name),impl:({ACTION:t,CONSUME:r,SUBRULE:n})=>i=>{let a=r(e),s=n(Rs);return t(()=>i.astFactory.expressionOperation(a.image,s.val,i.astFactory.sourceLocation(a,s)))}}}function ks(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 _c(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),v=l(()=>(u(b.comma),s(F))),x=r(b.RParen);return t(()=>p.astFactory.expressionOperation(f.image,v?[h,g,T,v]:[h,g,T],p.astFactory.sourceLocation(f,x)))}}}function Cs(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 _g=D(I.str),Ng=D(I.lang),Og=yt(I.langmatches),Sg=D(I.datatype),wg=Lc(I.bound),kg=D(I.iri),Cg=D(I.uri),Rg=Pc(I.bnode),Fg=sn(I.rand),Mg=D(I.abs),Dg=D(I.ceil),jg=D(I.floor),Gg=D(I.round),$g=ws(I.concat),Vg=D(I.strlen),Hg=D(I.ucase),Kg=D(I.lcase),qg=D(I.encode_for_uri),zg=yt(I.contains),Wg=yt(I.strstarts),Yg=yt(I.strends),Qg=yt(I.strbefore),Xg=yt(I.strafter),Bg=D(I.year),Jg=D(I.month),Zg=D(I.day),Ug=D(I.hours),eT=D(I.minutes),tT=D(I.seconds),rT=D(I.timezone),nT=D(I.tz),iT=sn(I.now),aT=sn(I.uuid),sT=sn(I.struuid),oT=D(I.md5),lT=D(I.sha1),cT=D(I.sha256),uT=D(I.sha384),pT=D(I.sha512),dT=ws(I.coalesce),fT=an(I.if_),hT=yt(I.strlang),mT=yt(I.strdt),gT=yt(I.sameterm),TT=D(I.isiri),yT=D(I.isuri),bT=D(I.isblank),xT=D(I.isliteral),vT=D(I.isnumeric);function AT(e){return[{ALT:()=>e(Fs)},{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(Dg)},{ALT:()=>e(jg)},{ALT:()=>e(Gg)},{ALT:()=>e($g)},{ALT:()=>e(IT)},{ALT:()=>e(Vg)},{ALT:()=>e(LT)},{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(yT)},{ALT:()=>e(bT)},{ALT:()=>e(xT)},{ALT:()=>e(vT)},{ALT:()=>e(ET)},{ALT:()=>e(PT)},{ALT:()=>e(_T)}]}var qt={name:"builtInCall",impl:({OR:e,SUBRULE:t,cache:r})=>()=>{let n=r.get(qt);if(n)return e(n);let i=AT(t);return r.set(qt,i),e(i)}},ET=ks(I.regex),IT=ks(I.substr),LT=_c(I.replace),PT=Cs(I.exists),_T=Cs(I.notexists),NT={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))})}},OT=Cr(I.sum),ST=Cr(I.min),wT=Cr(I.max),kT=Cr(I.avg),CT=Cr(I.sample),RT={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(Is),t(b.equal),n(Ns))),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))})}},Fs={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(NT)},{ALT:()=>t(OT)},{ALT:()=>t(ST)},{ALT:()=>t(wT)},{ALT:()=>t(kT)},{ALT:()=>t(CT)},{ALT:()=>t(RT)}]);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 Ds={name:"path",impl:({SUBRULE:e})=>()=>e(DT)},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 Oc(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 FT={name:"pathEltOrInverse",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR:i})=>a=>i([{ALT:()=>r(Nc)},{ALT:()=>{let s=t(b.hat),o=n(Nc);return e(()=>a.astFactory.path("^",[o],a.astFactory.sourceLocation(s,o)))}}])},MT=Oc("pathSequence",b.slash,"/",FT),DT=Oc("pathAlternative",b.pipe,"|",MT),Nc={name:"pathElt",impl:({ACTION:e,SUBRULE:t,OPTION:r})=>n=>{let i=t(GT),a=r(()=>t(jT));return e(()=>a===void 0?i:n.astFactory.path(a.image,[i],n.astFactory.sourceLocation(i,a)))}},jT={name:"pathMod",impl:({CONSUME:e,OR:t})=>()=>t([{ALT:()=>e(b.question)},{ALT:()=>e(b.star)},{ALT:()=>e(b.opPlus)}])},GT={name:"pathPrimary",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(K)},{ALT:()=>e(kr)},{ALT:()=>e($T)},{ALT:()=>{t(b.LParen);let n=e(Ds);return t(b.RParen),n}}])},$T={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(Ms);return e(()=>o.astFactory.path("!",[c],o.astFactory.sourceLocation(l,c)))}},{ALT:()=>{let c=t(b.LParen),u=n(Ms),p=[];s(()=>{t(b.pipe);let h=i(Ms);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))})}}])}},Ms={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 VT(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=>VT(qT)(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 HT(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,OR:i})=>a=>i([{ALT:()=>{let s=n(Se),o=n(t?Gs:js,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?Cc:kc),o=n(t?YT:WT,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 KT=HT("triplesSameSubject",!1),qT=HT("triplesSameSubjectPath",!0),Rr={name:"triplesTemplate",impl:VT(KT)};function zT(e,t){return{name:e,impl:({SUBRULE:r,OPTION:n})=>(i,a)=>{var s;return(s=n(()=>r(t?Gs:js,a)))!=null?s:[]}}}var WT=zT("propertyList",!1),YT=zT("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(XT)},{ALT:()=>a(BT)}]):a(vc),h=a(t?UT:ZT,c,f);s(()=>{n(b.semi),p=!0}),r(()=>{u.push(...h)})}}),u}}}var js=QT("propertyListNotEmpty",!1),Gs=QT("propertyListPathNotEmpty",!0),XT={name:"verbPath",impl:({SUBRULE:e})=>()=>e(Ds)},BT={name:"verbSimple",impl:({SUBRULE:e})=>()=>e(ee)};function JT(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?ry:ty,s,o);r(()=>{l.push(c)})}}),l}}}var ZT=JT("objectList",!1),UT=JT("objectListPath",!0);function ey(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,a,s)=>{let o=n(t?St:Rc);return r(()=>i.astFactory.triple(a,s,o))}}}var ty=ey("object",!1),ry=ey("objectPath",!0);function ny(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:Rc))});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()),v=T;for(let[x,A]of o.entries()){let y=x===o.length-1,L=u.triple(v,f,A);if(p.push(L),y){let S=u.triple(v,h,g);p.push(S)}else{let S=u.termBlank(void 0,u.sourceLocation()),N=u.triple(v,h,S);p.push(N),v=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 iy=ny("collection",!1),Sc=ny("collectionPath",!0);function ay(e,t){return{name:e,impl:({SUBRULE:r,OR:n})=>()=>n([{ALT:()=>r(t?Sc:iy)},{ALT:()=>r(t?wc:oy)}]),gImpl:({SUBRULE:r})=>n=>n.subType==="list"?r(Sc,n):r(wc,n)}}var kc=ay("triplesNode",!1),Cc=ay("triplesNodePath",!0);function sy(e,t){let r=t?Gs:js;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 oy=sy("blankNodePropertyList",!1),wc=sy("blankNodePropertyListPath",!0);function ly(e,t){let r=t?Cc:kc;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 Rc=ly("graphNode",!1),St=ly("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(qc)]},{ALT:()=>t(uy)}]),o=r(b.RCurly);return e(()=>!i.skipValidation&&gc(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(cy,l);s.printFilter(i,()=>{a[ce]-=o,n("}")})}},cy={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(Hc,t)}},uy={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(Hc);u.push(f),o(()=>r(b.dot));let h=l(()=>a(wt));h&&u.push(h)}),e(()=>!c.skipValidation&&mc(u)),u}},Hc={name:"graphPatternNotTriples",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e($c)},{ALT:()=>e(Fc)},{ALT:()=>e(Gc)},{ALT:()=>e(Mc)},{ALT:()=>e(Dc)},{ALT:()=>e(Vc)},{ALT:()=>e(jc)},{ALT:()=>e(on)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"group":case"union":e($c,t);break;case"optional":e(Fc,t);break;case"minus":e(Gc,t);break;case"graph":e(Mc,t);break;case"service":e(Dc,t);break;case"filter":e(Vc,t);break;case"bind":e(jc,t);break;case"values":e(on,t);break}}},Fc={name:"optionalGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(fs),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))}},Mc={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))}},Dc={name:"serviceGraphPattern",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{var c;let a=r(hs),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))}},jc={name:"bind",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ms);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(Ba),a=t(py);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("}")})}},py={name:"dataBlock",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(dy)},{ALT:()=>e(fy)}])},dy={name:"inlineDataOneVar",impl:({ACTION:e,SUBRULE:t,CONSUME:r,MANY:n})=>i=>{let a=[],s=t(ee);r(b.LCurly),n(()=>{let l=t(Kc);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)))}},fy={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 v=s(Kc);e(()=>{T[p[g].value]=v,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)))}}])}},Kc={name:"dataBlockValue",impl:({SUBRULE:e,CONSUME:t,OR:r})=>()=>r([{ALT:()=>e(K)},{ALT:()=>e(pr)},{ALT:()=>e(Sr)},{ALT:()=>e(wr)},{ALT:()=>{t(gs)}}])},Gc={name:"minusGraphPattern",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Ts),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))}},$c={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(ys);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)}},Vc={name:"filter",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(bs),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($s)}])},$s={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(")"))}},Rs={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)))}}])},wk=new Set(["||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),kk=new Set(["in","notin","||","&&","=","!=","<",">","<=",">=","+","-","*","/"]),hy={"!":"",uplus:"+",uminus:"-"},F={name:"expression",impl:({SUBRULE:e})=>()=>e(my),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(Bc,r);else if(n.isExpressionAggregate(r))e(Fs,r);else if(kk.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&&wk.has(r.operator)?e(F,a[0]):e(ln,n.wrap({args:a,distinct:!1},r.loc)),n.printFilter(r,()=>t(")"))}else if(typeof hy[r.operator]=="string"){let[i]=r.args;n.printFilter(r,()=>t(hy[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 my={name:"conditionalOrExpression",impl:({ACTION:e,MANY:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i})=>a=>hi(()=>n(zc),()=>{r(b.logicOr);let s=i(zc);return o=>e(()=>a.astFactory.expressionOperation("||",[o,s],a.astFactory.sourceLocation(o,s)))},e,t)},zc={name:"conditionalAndExpression",impl:({ACTION:e,MANY:t,SUBRULE1:r,SUBRULE2:n,CONSUME:i})=>a=>hi(()=>r(Wc),()=>{i(b.logicAnd);let s=n(Wc);return o=>e(()=>a.astFactory.expressionOperation("&&",[o,s],a.astFactory.sourceLocation(o,s)))},e,t)},Wc={name:"valueLogical",impl:({SUBRULE:e})=>()=>e(gy)},gy={name:"relationalExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION:i,OR1:a,OR2:s,OR3:o})=>l=>{let c=r(Yc),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(Yc);return e(()=>l.astFactory.expressionOperation(p.image,[c,f],l.astFactory.sourceLocation(c,f)))}},{ALT:()=>{let p=o([{ALT:()=>t(As)},{ALT:()=>t(Es)}]),f=r(Rs);return e(()=>l.astFactory.expressionOperation(p.image,[c,...f.val],l.astFactory.sourceLocation(c,f)))}}]));return u!=null?u:c}},Yc={name:"numericExpression",impl:({SUBRULE:e})=>()=>e(Ty)},Ty={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(Qc),()=>o([{ALT:()=>{let f=l([{ALT:()=>r(b.opPlus)},{ALT:()=>r(b.opMinus)}]),h=i(Qc);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(Ps);return e(()=>(T.value=T.value.replace(/^\+/u,""),{operator:"+",startInt:T}))}},{ALT:()=>{let T=t(_s);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)}]),v=n(Vs);return x=>e(()=>p.astFactory.expressionOperation(T.image,[x,v],p.astFactory.sourceLocation(x,v)))},e,s);return T=>p.astFactory.expressionOperation(f,[T,g],p.astFactory.sourceLocation(T,g))}}]),e,a)},Qc={name:"multiplicativeExpression",impl:({ACTION:e,CONSUME:t,MANY:r,SUBRULE1:n,SUBRULE2:i,OR:a})=>s=>hi(()=>n(Vs),()=>{let o=a([{ALT:()=>t(b.star)},{ALT:()=>t(b.slash)}]),l=i(Vs);return c=>({type:"expression",subType:"operation",operator:o.image,args:[c,l],loc:s.astFactory.sourceLocation(c,l)})},e,r)},Vs={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:a})=>s=>i([{ALT:()=>r(Xc)},{ALT:()=>{let o=a([{ALT:()=>t(b.exclamation)},{ALT:()=>t(b.opPlus)},{ALT:()=>t(b.opMinus)}]),l=n(Xc);return e(()=>s.astFactory.expressionOperation(o.image==="!"?"!":o.image==="+"?"UPLUS":"UMINUS",[l],s.astFactory.sourceLocation(o,l)))}}])},Xc={name:"primaryExpression",impl:({SUBRULE:e,OR:t})=>()=>t([{ALT:()=>e(cn)},{ALT:()=>e(qt)},{ALT:()=>e(Bc)},{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))}},Bc={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(Jc)),o=n(()=>t(Zc)),l=i(()=>t(Uc)),c=a(()=>t(eu));return e(()=>({...c&&{limitOffset:c},...s&&{group:s},...o&&{having:o},...l&&{order:l}}))},gImpl:({SUBRULE:e})=>t=>{t.group&&e(Jc,t.group),t.having&&e(Zc,t.having),t.order&&e(Uc,t.order),t.limitOffset&&e(eu,t.limitOffset)}},Jc={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(yy))}),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(")")))}},yy={name:"groupCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,SUBRULE1:n,SUBRULE2:i,OPTION:a,OR:s})=>o=>s([{ALT:()=>t(qt)},{ALT:()=>t($s)},{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)}}])},Zc={name:"havingClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE:r,CONSUME:n})=>i=>{let a=n(qa),s=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{s.push(r(by))}),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)}},by={name:"havingCondition",impl:({SUBRULE:e})=>()=>e(fi)},Uc={name:"orderClause",impl:({ACTION:e,AT_LEAST_ONE:t,SUBRULE1:r,CONSUME:n})=>i=>{let a=n(za);n(oi);let s=[],o=e(()=>i.parseMode.has("canParseAggregate")||!i.parseMode.add("canParseAggregate"));return t(()=>{s.push(r(xy))}),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(")"))}},xy={name:"orderCondition",impl:({ACTION:e,SUBRULE:t,CONSUME:r,OR1:n,OR2:i})=>a=>n([{ALT:()=>{let s=i([{ALT:()=>[!1,r(Wa)]},{ALT:()=>[!0,r(Ya)]}]),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}))}}])},eu={name:"limitOffsetClauses",impl:({ACTION:e,SUBRULE1:t,SUBRULE2:r,OPTION1:n,OPTION2:i,OR:a})=>s=>a([{ALT:()=>{let o=t(tu),l=n(()=>t(ru));return e(()=>s.astFactory.solutionModifierLimitOffset(o.val,l==null?void 0:l.val,s.astFactory.sourceLocation(o,...l?[l]:[])))}},{ALT:()=>{let o=r(ru),l=i(()=>r(tu));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))})}},tu={name:"limitClause",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(Qa),i=t(M.integer),a=Number.parseInt(i.image,10);return e(()=>r.astFactory.wrap(a,r.astFactory.sourceLocation(n,i)))}},ru={name:"offsetClause",impl:({CONSUME:e,ACTION:t})=>r=>{let n=e(Xa),i=e(M.integer),a=Number.parseInt(i.image,10);return t(()=>r.astFactory.wrap(a,r.astFactory.sourceLocation(n,i)))}};var Ck={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(Hs),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||hc(o),o})},gImpl:({SUBRULE:e})=>(t,{astFactory:r})=>{e(Hs,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)}},qc={name:"subSelect",impl:({ACTION:e,SUBRULE:t})=>r=>{let n=t(Hs),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)))}},Hs={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 v;let u=i(ja),p=e(()=>c.parseMode.has("canParseAggregate")||!c.parseMode.add("canParseAggregate")),f=(v=a(()=>s([{ALT:()=>(i(gt),[!0,!1])},{ALT:()=>(i(Ga),[!1,!0])}])))!=null?v:[!1,!1],h=e(()=>{let[x,A]=f;return{...x&&{distinct:x},...A&&{reduced:A}}}),g,T=o([{ALT:()=>{let x=i(b.star);return e(()=>(g=x,{variables:[c.astFactory.wildcard(c.astFactory.sourceLocation(x))],...h}))}},{ALT:()=>{let x=[],A=[];return t(()=>l([{ALT:()=>{let y=r(ee);e(()=>{if(!c.skipValidation&&x.some(L=>L.value===y.value))throw new Error(`Variable ${y.value} used more than once in SELECT clause`);x.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&&x.some(X=>X.value===S.value))throw new Error(`Variable ${S.value} used more than once in SELECT clause`);x.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($a);return i([{ALT:()=>{let o=t(nu),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(nu),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(Va),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(Ha),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))},nu={name:"constructTemplate",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let a=r(b.LCurly),s=n(()=>t(vy)),o=r(b.RCurly);return e(()=>i.astFactory.wrap(s!=null?s:i.astFactory.patternBgp([],i.astFactory.sourceLocation()),i.astFactory.sourceLocation(a,o)))}},vy={name:"constructTriples",impl:Rr.impl};var Rk={name:"updateUnit",impl:({SUBRULE:e})=>()=>e(Ks)},Ks={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(iu)},{ALT:()=>e(au)},{ALT:()=>e(su)},{ALT:()=>e(lu)},{ALT:()=>e(cu)},{ALT:()=>e(uu)},{ALT:()=>e(ou)},{ALT:()=>e(pu)},{ALT:()=>e(du)},{ALT:()=>e(fu)},{ALT:()=>e(hu)}]),gImpl:({SUBRULE:e})=>t=>{switch(t.subType){case"load":e(iu,t);break;case"clear":e(au,t);break;case"drop":e(su,t);break;case"add":e(lu,t);break;case"move":e(cu,t);break;case"copy":e(uu,t);break;case"create":e(ou,t);break;case"insertdata":e(pu,t);break;case"deletedata":e(du,t);break;case"deletewhere":e(fu,t);break;case"modify":e(hu,t);break}}},iu={name:"load",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION1:n,OPTION2:i})=>a=>{let s=r(Ja),o=n(()=>r(Vt)),l=t(K),c=i(()=>(r(Za),t(xi)));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 Ay(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 au=Ay(Ua),su=Ay(es),ou={name:"create",impl:({ACTION:e,SUBRULE1:t,CONSUME:r,OPTION:n})=>i=>{let a=r(ts),s=n(()=>r(Vt)),o=t(xi);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 yu(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(gu);r(ns);let u=i(gu);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 lu=yu(rs),cu=yu(is),uu=yu(as),qs={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)))}},bu={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 xu(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 pu=xu("insertData","insertdata",us,bu),du=xu("deleteData","deletedata",os,bu),fu=xu("deleteWhere","deletewhere",ls,qs),hu={name:"modify",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OPTION1:i,OPTION2:a,OR:s})=>o=>{let l=i(()=>{let h=t(ss),g=r(K);return{withToken:h,graph:g}}),{insert:c,del:u}=s([{ALT:()=>{let h=r(Ey),g=a(()=>r(mu));return{del:h,insert:g}}},{ALT:()=>({insert:n(mu),del:void 0})}]),p=r(Ss);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(Ss,i.from),s.printFilter(i,()=>t("WHERE")),e(ne,i.where)}},Ey={name:"deleteClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(cs),a=e(()=>n.parseMode.delete("canCreateBlankNodes")),s=t(qs);return e(()=>a&&n.parseMode.add("canCreateBlankNodes")),e(()=>n.astFactory.wrap(s.val,n.astFactory.sourceLocation(i,s)))}},mu={name:"insertClause",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(ps),a=t(qs);return e(()=>n.astFactory.wrap(a.val,n.astFactory.sourceLocation(i,a)))}},gu={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)))}}])},xi={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(xi)},{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(xi,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(Tu);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(Tu,n)}},Tu={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 Fk={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(Ks,t)}};var Mk=[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],Dk={name:"builtInCall",impl:({OR:e,SUBRULE:t})=>()=>e(d.builtInCallList(t).slice(0,-2))},Iy=ue.create(Mk).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(Dk);var jk=[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],zs=ue.create(jk);var Ly=ue.create([d.triplesBlock,d.triplesSameSubjectPath,d.propertyListPathNotEmpty,d.triplesNodePath,d.propertyListPath,d.verbPath,d.verbSimple,d.objectListPath]).merge(zs,[]).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 Gk=[d.subSelect,d.selectClause,d.whereClause,d.solutionModifier,d.valuesClause],Ws=ue.create(Gk).merge(Iy,[]).patchRule(d.builtInCall).addMany(d.existsFunc,d.notExistsFunc,d.groupGraphPattern,d.groupGraphPatternSub).merge(Ly,[]).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 $k=[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],Ys=ue.create($k);var Vk=[d.queryUnit,d.query,d.prologue,d.selectQuery,d.constructQuery,d.describeQuery,d.askQuery,d.valuesClause,d.baseDecl,d.prefixDecl],Py=ue.create(Vk).merge(Ws,[]).addRule(d.datasetClause).addRule(d.datasetClauseStar).addRule(d.defaultGraphClause).addRule(d.namedGraphClause).addRule(d.sourceSelector).addRule(d.constructTemplate).merge(Ys,[]).addRule(d.constructTriples);var Hk={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},Kk=[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],_y=ue.create(Kk).addRule(Hk).merge(Ys,[]).addRule(d.quadPattern).addRule(d.quadsNotTriples);var Ny=ue.create(_y).patchRule(d.update1).addMany(d.modify,d.deleteClause,d.insertClause,d.usingClause,d.defaultGraphClause,d.namedGraphClause,d.sourceSelector,d.usingClauseStar,d.groupGraphPattern).merge(zs,[]).merge(Ws,[]);var Oy=ue.create(Py).merge(Ny,[]).addRule(d.queryOrUpdate);var Eu={};Ze(Eu,{findPatternBoundedVars:()=>Te,langTagHasCorrectRange:()=>vu,queryProjectionIsGood:()=>Au});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 qk(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(!qk(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 Au(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:()=>Gy,annotationBlock:()=>Vy,annotationBlockPath:()=>_u,annotationPath:()=>mo,buildInHasLang:()=>Jy,buildInHasLangDir:()=>Zy,buildInIsTriple:()=>Uy,buildInLangDir:()=>Xy,buildInLangStrDir:()=>By,buildInObject:()=>nb,buildInPredicate:()=>rb,buildInSubject:()=>tb,buildInTriple:()=>eb,builtInCall:()=>rC,dataBlockValue:()=>Bk,exprTripleTerm:()=>Cu,exprTripleTermObject:()=>Qy,exprTripleTermSubject:()=>Yy,generateGraphTerm:()=>sC,generateTriplesBlock:()=>aC,graphNode:()=>Hy,graphNodePath:()=>je,iriFull:()=>iC,object:()=>Uk,objectPath:()=>eC,primaryExpression:()=>Nu,prologue:()=>Xk,rdfLiteral:()=>Tn,reifiedTriple:()=>gn,reifiedTripleBlock:()=>Cy,reifiedTripleBlockPath:()=>Ry,reifiedTripleObject:()=>Ky,reifiedTripleSubject:()=>Su,reifier:()=>Ou,selectQuery:()=>Qk,string:()=>nC,tripleTerm:()=>Ii,tripleTermData:()=>ku,tripleTermDataObject:()=>Wy,tripleTermDataSubject:()=>zy,tripleTermObject:()=>qy,tripleTermSubject:()=>wu,triplesSameSubject:()=>Jk,triplesSameSubjectPath:()=>Zk,unaryExpression:()=>ib,varOrReifierId:()=>Fy,varOrTerm:()=>tC,versionDecl:()=>Pu,versionSpecifier:()=>wy});var mn={};Ze(mn,{LANG_DIR:()=>co,annotationClose:()=>Js,annotationOpen:()=>Bs,buildInHasLang:()=>ro,buildInHasLangDir:()=>no,buildInIsTRIPLE:()=>io,buildInLangDir:()=>eo,buildInOBJECT:()=>lo,buildInPREDICATE:()=>oo,buildInSUBJECT:()=>so,buildInStrLangDir:()=>to,buildInTRIPLE:()=>ao,iriRef:()=>po,reificationClose:()=>Us,reificationOpen:()=>Zs,sparql12LexerBuilder:()=>Wk,stringLiteral1:()=>Ai,stringLiteral2:()=>Ei,stringLiteralLong1:()=>fo,stringLiteralLong2:()=>ho,tilde:()=>Xs,tripleTermClose:()=>hn,tripleTermOpen:()=>fn,version:()=>Qs});var Qs=m({name:"Version",pattern:/version/i,label:"version identifier"}),Xs=m({name:"Tilde",pattern:"~",label:"~"}),Bs=m({name:"AnnotationOpen",pattern:"{|",label:"Annotation Open: {|"}),Js=m({name:"AnnotationClose",pattern:"|}",label:"Annotation Close |}"}),Zs=m({name:"ReificationOpen",pattern:"<<",label:"Reification open <<"}),Us=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 )>>"}),eo=m({name:"BuiltInLangdir",pattern:/langdir/i,label:"LANGDIR"}),to=m({name:"BuiltInStrLangdir",pattern:/strlangdir/i,label:"STRLANGDIR"}),ro=m({name:"BuiltInHasLang",pattern:/haslang/i,label:"hasLANG"}),no=m({name:"BuiltInHasLangdir",pattern:/haslangdir/i,label:"hasLANGDIR"}),io=m({name:"BuiltInIsTriple",pattern:/istriple/i,label:"isTRIPLE"}),ao=m({name:"BuiltInTriple",pattern:/triple/i,label:"TRIPLE"}),so=m({name:"BuiltInSubject",pattern:/subject/i,label:"SUBJECT"}),oo=m({name:"BuiltInPredicate",pattern:/predicate/i,label:"PREDICATE"}),lo=m({name:"BuiltInObject",pattern:/object/i,label:"OBJECT"}),co=m({name:"LANG_DIR",pattern:/@[a-z]+(?:-[\da-z]+)*(?:--[a-z]+)?/i,label:"LANG_DIR"}),vi=/\\u[\dA-Fa-f]{4}|\\U[\dA-Fa-f]{8}/.source,uo=/\\["'\\bfnrt]/.source,zk=/[^\u0000-\u0020"<>\\^`{|}]/.source,po=m({name:"IriRef",pattern:new RegExp(`<((${zk})|(${vi}))*>`)}),Ai=m({name:"StringLiteral1",pattern:new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${uo})|(${vi}))*'`)}),Ei=m({name:"StringLiteral2",pattern:new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${uo})|(${vi}))*"`)}),fo=m({name:"StringLiteralLong1",pattern:new RegExp(`'''(('|(''))?([^'\\\\]|(${uo})|(${vi})))*'''`)}),ho=m({name:"StringLiteralLong2",pattern:new RegExp(`"""(("|(""))?([^"\\\\]|(${uo})|(${vi})))*"""`)}),Wk=Oe.create(q.sparql11LexerBuilder).addBefore(q.symbols.logicAnd,Xs,Bs,Js,fn,hn,Zs,Us,Qs).addBefore(q.builtIn.langmatches,eo,to,no,ro,io,ao,so,oo,lo).addBefore(q.terminals.langTag,co).deleteToken(q.terminals.langTag.name).replace(po).replace(Ai).replace(Ei).replace(fo).replace(ho);function Yk(e){return e.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,(t,r,n)=>Iu(r!=null?r:n))}function Iu(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 Sy(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:Yk}}function Lu(e){return{...e,prefixes:Object.assign(Object.create(null),e.prefixes),parseMode:new Set(e.parseMode)}}var Pu={name:"versionDecl",impl:({ACTION:e,SUBRULE:t,CONSUME:r})=>n=>{let i=r(Qs),a=t(wy);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)}`)})}},Qk={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||Au(o),o})}},wy={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)))}},Xk={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(Pu))}])),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(Pu,n)}};function ky(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 Cy=ky("reifiedTripleBlock",!1),Ry=ky("reifiedTripleBlockPath",!0),Bk={name:"dataBlockValue",impl:e=>t=>e.OR2([{ALT:()=>d.dataBlockValue.impl(e)(t)},{ALT:()=>e.SUBRULE(ku)}])},Ou={name:"reifier",impl:({ACTION:e,CONSUME:t,SUBRULE:r,OPTION:n})=>i=>{let a=t(Xs),s=n(()=>r(Fy));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))})}},Fy={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 My(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?Ry:Cy)}])}}var Jk=My("triplesSameSubject",!1),Zk=My("triplesSameSubjectPath",!0);function Dy(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n})=>(i,a,s)=>{let o=n(t?je:Hy),l=n(t?mo:Gy);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 Uk=Dy("object",!1),eC=Dy("objectPath",!0);function jy(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(Ou);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?_u:Vy,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(_u,s):(a.printFilter(s,()=>n("~")),r(je,s.val))}}}var mo=jy("annotationPath",!0),Gy=jy("annotation",!1);function $y(e,t){return{name:e,impl:({ACTION:r,SUBRULE:n,CONSUME:i})=>(a,s)=>{let o=i(Bs),l=n(t?d.propertyListPathNotEmpty:d.propertyListNotEmpty,s),c=i(Js);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 _u=$y("annotationBlockPath",!0),Vy=$y("annotationBlock",!1),Hy={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)}},tC={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(Zs),s=r(Su),o=r(d.verb),l=r(Ky),c=n(()=>r(Ou)),u=t(Us);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(mo,[n.wrap(r.identifier,r.identifier.loc)]),n.printFilter(r,()=>t(">>"))}},Su={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)}])},Ky={name:"reifiedTripleObject",impl:Su.impl},Ii={name:"tripleTerm",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(fn),a=r(wu),s=r(d.verb),o=r(qy),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(")>>"))}},wu={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)}])},qy={name:"tripleTermObject",impl:wu.impl},ku={name:"tripleTermData",impl:({ACTION:e,CONSUME:t,OR:r,SUBRULE:n})=>i=>{let a=t(fn),s=n(zy),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(Wy),c=t(hn);return e(()=>i.astFactory.termTriple(s,o,l,i.astFactory.sourceLocation(a,c)))}},zy={name:"tripleTermDataSubject",impl:({OR:e,SUBRULE:t})=>()=>e([{ALT:()=>t(d.iri)}])},Wy={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(ku)}])},Nu={name:"primaryExpression",impl:e=>t=>e.OR2([{ALT:()=>d.primaryExpression.impl(e)(t)},{ALT:()=>e.SUBRULE(Cu)}])},Cu={name:"exprTripleTerm",impl:({ACTION:e,CONSUME:t,SUBRULE:r})=>n=>{let i=t(fn),a=r(Yy),s=r(d.verb),o=r(Qy),l=t(hn);return e(()=>n.astFactory.termTriple(a,s,o,n.astFactory.sourceLocation(i,l)))}},Yy={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(Cu)}])},Xy=D(eo),By=an(to),Jy=D(ro),Zy=D(no),Uy=D(io),eb=an(ao),tb=D(so),rb=D(oo),nb=D(lo),rC={name:"builtInCall",impl:e=>t=>e.OR2([{ALT:()=>d.builtInCall.impl(e)(t)},{ALT:()=>e.SUBRULE(Xy)},{ALT:()=>e.SUBRULE(By)},{ALT:()=>e.SUBRULE(Jy)},{ALT:()=>e.SUBRULE(Zy)},{ALT:()=>e.SUBRULE(Uy)},{ALT:()=>e.SUBRULE(eb)},{ALT:()=>e.SUBRULE(tb)},{ALT:()=>e.SUBRULE(rb)},{ALT:()=>e.SUBRULE(nb)}])},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(co);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}},nC={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(fo);return[a,a.image.slice(3,-3)]}},{ALT:()=>{let a=t(ho);return[a,a.image.slice(3,-3)]}}]);return e(()=>{let[a,s]=i,o=n.astFactory,l={t:" ",n:`
|
|
121
|
+
`,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?Iu(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)})}},iC={name:"iriFull",impl:({ACTION:e,CONSUME:t})=>r=>{let n=t(po);return e(()=>{let i=n.image.slice(1,-1);return r.astFactory.termNamed(r.astFactory.sourceLocation(n),r.codepointEscape(i))})}},ib={name:"unaryExpression",impl:({ACTION:e,CONSUME:t,SUBRULE1:r,SUBRULE2:n,OR1:i,OR2:a})=>s=>i([{ALT:()=>r(Nu)},{ALT:()=>{let o=t(q.symbols.exclamation),l=r(ib);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(Nu);return e(()=>s.astFactory.expressionOperation(o.image==="+"?"UPLUS":"UMINUS",[l],s.astFactory.sourceLocation(o,l)))}}])},aC={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(mo,(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()}))})}},sC={name:"graphTerm",gImpl:e=>(t,r)=>{r.astFactory.isTermTriple(t)?e.SUBRULE(Ii,t):d.graphTerm.gImpl(e)(t,r)}};var fD={...pi,...Eu};var oC=ue.create(Oy).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),go=class{constructor(t={}){H(this,"parser");H(this,"defaultContext");var r;this.parser=oC.build({...t,tokenVocabulary:mn.sparql12LexerBuilder.tokenVocabulary}),this.defaultContext=Sy((r=t.defaultContext)!=null?r:{})}parse(t,r={}){let n=this.parser.queryOrUpdate(t,Lu({...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,Lu({...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 Eb=_n(sb(),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"])}}),ob=ie.transformNode.bind(ie),OD=ie.transformNodeAsync.bind(ie),SD=ie.transformNodePreOrder.bind(ie),wD=ie.transformNodePreOrderAsync.bind(ie),kD=ie.transformNodeSpecific.bind(ie),CD=ie.transformNodeSpecificAsync.bind(ie),RD=ie.transformNodeSpecificPreOrder.bind(ie),FD=ie.transformNodeSpecificPreOrderAsync.bind(ie),MD=ie.visitNode.bind(ie),DD=ie.visitNodeAsync.bind(ie),jD=ie.visitNodeSpecific.bind(ie),GD=ie.visitNodeSpecificAsync.bind(ie),lC=/^[a-z][\d+.a-z-]*:/iu,cC=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su,uC=/^(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/su;function To(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 lb(e,t){if(lC.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]=uC.exec(e),[,s,o,l,c]=cC.exec(t),u,p,f;r===void 0?(n===""?(p=l,f=i!=null?i:c):(n.startsWith("/")?p=To(n):o!==void 0&&l===""?p=To(`/${n}`):p=To(l.slice(0,l.lastIndexOf("/")+1)+n),f=i),u=o):(u=r,p=To(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 dC=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(dC,o=>o.slice(1))}return n.namedNode(lb(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)}},xn={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)}},vn={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 ob(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))}})}},yo={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 bb=_n(_o(),1);var Tb=_n(_o(),1),yb=_n(Wu(),1);var No=class{constructor(t){H(this,"dataFactory");H(this,"stringType");this.dataFactory=t!=null?t:new Tb.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,yb.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 Yu(e){var r;let t=(r=e.dataFactory)!=null?r:new bb.DataFactory;return{variables:new Set,varCount:0,useQuads:!1,transformer:new rn,astFactory:new cr,dataFactory:t,algebraFactory:new No(t),currentBase:e.baseIRI,currentPrefixes:Object.assign(Object.create(null),e.prefixes)}}var Ce=E,xb=Object.values(Ce);function vb(e){return!!(e!=null&&e.termType)}function Ab(e){return(e==null?void 0:e.termType)==="Variable"}var Oo={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(vb(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)):xb.includes(s.type)?r[o]=e(Xe,s,n,i):i&&Ab(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 So={name:"translateUpdate",fun:({SUBRULE:e})=>({algebraFactory:t},r)=>{let n=r.updates.flatMap(i=>(e(bn,i.context),i.operation?[e(Qu,i.operation)]:[]));return n.length===0?t.createNop():n.length===1?n[0]:t.createCompositeUpdate(n)}},Qu={name:"translateSingleUpdate",fun:({SUBRULE:e})=>({astFactory:t,algebraFactory:r},n)=>{if(t.isUpdateOperationLoad(n))return e(Ju,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(Xu,n);throw new Error(`Unknown update type ${JSON.stringify(n)}`)}},Xu={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(vn,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))}},Bu={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(Bu,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)}},Ju={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 wo={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(yo,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(ko,r,s)}else s=e(So,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(Zu,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(xn,i);if(t.isQuerySelect(i))return e(wo,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(Uu,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}`)}},Zu={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(Oo,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)}},Uu={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(Co,n,o)}let a=e(Be,i);return e(Co,n,a)}},Co={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 ko={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(x=>e(ep,o[x],n.variable(x))),v=[];if(i.solutionModifiers.group)for(let x of i.solutionModifiers.group.groupings)if(t.isTerm(x))v.push(e(Q,x));else{let A,y;"variable"in x?(A=e(Q,x.variable),y=x.value):(A=e(kt),y=x),a=r.createExtend(a,A,e(Je,y)),v.push(A)}a=r.createGroup(a,v,T)}if(c)for(let T of c)a=r.createFilter(a,e(Je,T));i.values&&(a=r.createJoin([a,e(xn,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,v)=>T.value.localeCompare(v.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 v=e(Je,T.expression);return T.descending&&(v=r.createOperatorExpression("desc",[v])),v}))),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(v=>e(hr,v)))}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(vn,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,Eb.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}},ep={name:"translateBoundAggregate",fun:({SUBRULE:e})=>(t,r,n)=>({...e(Je,r),variable:n})};var Ib=Jr.create([ko,jr,ep]).addMany(fe,Q,bn,xn,vn,yn,yo,Li,kt,Oo,Rt,En,Je,Be,Zu,Uu,Co,Dr,Qt,_i,Xe,hr,So,Qu,Xu,In,Bu,Xt,Ni,Ju,wo);var tp=_n(Wu(),1),Lb="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)}},rp={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(np,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(Lb),object:u})}else Dr.fun(e)(t,r,n)}},np={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,tp.termToString)(h))||n.push({subject:h,predicate:c.namedNode(Lb),object:u}),p.add((0,tp.termToString)(h)),g&&i(rp,f,n)}}}},Pb={name:"inScopeVariables",fun:()=>(e,t)=>{let r=new Set;return Te(t,r),r}};function _b(e){return{...Yu(e),astFactory:new dr}}var EC=Jr.create(Ib).widenContext().patchRule(mr).patchRule(rp).patchRule(np).patchRule(Pb).typePatch();function ip(e,t={}){let r=_b(t);return EC.build().translateQuery(r,e,t.quads,t.blankToVariable)}var IC="http://base/",Bt=class extends Error{constructor(t){super(t),this.name="AlgebraError"}},ap;function Ro(e,t={}){if(!e||!e.trim())throw new Bt("The query is empty.");ap||(ap=new go);let r,n=t.baseIRI||IC;try{r=ap.parse(e,{baseIRI:n})}catch(i){throw new Bt(LC(i))}try{return ip(r,{quads:!1,baseIRI:n})}catch(i){try{return ip(r,{quads:!0,baseIRI:n})}catch(a){throw new Bt(i instanceof Error?i.message:String(i))}}}function LC(e){let t=e instanceof Error?e.message:String(e),r=t.split(`
|
|
121
122
|
`).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#",
|
|
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
|
|
123
|
+
`).replace(/::\s*$/,".").trim()||t}var Oi="http://www.w3.org/2001/XMLSchema#",PC=new Set([`${Oi}integer`,`${Oi}decimal`,`${Oi}double`,`${Oi}boolean`]);function Nb(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 Nb(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:PC.has(a)&&/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$|^(true|false)$/.test(e.value)?String(e.value):`${n}^^${Nb(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=[sp(e.subject,t),sp(e.predicate,t),sp(e.object,t)];return e.graph&&e.graph.termType!=="DefaultGraph"&&r.push(`@ ${$(e.graph,t)}`),r.join(" ")}function sp(e,t){return e&&typeof e=="object"&&!("termType"in e)&&typeof e.type=="string"?Fo(e,t):$(e,t)}function Fo(e,t={},r=void 0){if(!e||typeof e!="object")return String(e);if("termType"in e)return $(e,t);let n=(s,o)=>Fo(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 xt(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=>xt(i,t));return`(${e.operator} ${n.join(" ")})`.replace(" )",")")}case"named":{let n=(e.args||[]).map(i=>xt(i,t));return`(${$(e.name,t)} ${n.join(" ")})`.replace(" )",")")}case"aggregate":{let n=e.expression?xt(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 op(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?xt(e.expression,t):void 0,n);case"filter":return r("filter",xt(e.expression,t),n);case"extend":return r("extend",`${$(e.variable,t)} := ${xt(e.expression,t)}`,n);case"project":return r("project",op(e.variables,t),n);case"orderby":return r("orderby",(e.expressions||[]).map(i=>xt(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)} := ${xt(a,t)}`);return r("group",op(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",op(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 ":""}${Ob(e.source,t)} to ${Ob(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}: ${Sb(s,t)}`);return r(String(e.type||"unknown"),void 0,n,i)}}}function Ob(e,t){return typeof e=="string"?e:$(e,t)}function Sb(e,t){return Array.isArray(e)?e.map(r=>Sb(r,t)).join(", "):e&&typeof e=="object"?"termType"in e?$(e,t):e.subType||e.expressionType?xt(e,t):typeof e.type=="string"&&/path|link|inv|seq|alt|nps/i.test(e.type)?Fo(e,t):JSON.stringify(e):String(e)}function Do(e,t={}){let r=[];return Mo(e,t,0,r),r.join(`
|
|
124
|
+
`)}function Mo(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)Mo(h,t,r+1,n);n[n.length-1]+=")"},l=p=>xt(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)Mo(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&&Mo(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 _C={"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 NC(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">${_C[e]}</svg>`}function Gr(e,t,r){let n=document.createElement("template");return n.innerHTML=NC(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 OC(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 lp(e,t="Copy"){let r=wi(t,"copy",async()=>{let n=await OC(e()),i=r.querySelector("span");i&&(i.textContent=n?"Copied":"Copy failed",setTimeout(()=>i.textContent=t,1500))});return r}function cp(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 jo(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 wb(e){return e.toLocaleString("en-US")}function kb(e){var r;let t=(r=e.timeMs)!=null?r:0;for(let n of e.children)t=Math.max(t,kb(n));return t}function Go(e){return 1+e.children.reduce((t,r)=>t+Go(r),0)}function SC(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=kb(e),i=n>0,a=document.createElement("div");a.className="explain-tree",a.setAttribute("role","tree");let s=[],o=i?Cb(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 v=document.createElement("div");if(v.className="explain-label",v.textContent=c.label,c.cached){let N=document.createElement("span");N.className="explain-badge",N.textContent="cached",v.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,v.appendChild(N)}T.appendChild(v);let x=[];if(c.columns&&c.columns.length&&x.push(c.columns.join(" ")),c.details&&c.details.length&&x.push(...c.details),x.length){let N=document.createElement("div");N.className="explain-meta";for(let X of x){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?`${wb(c.rows)} rows`:"";let L=document.createElement("span");L.className="explain-time",c.timeMs!==void 0&&(L.textContent=jo(c.timeMs),c.totalMs!==void 0&&c.totalMs!==c.timeMs&&(L.title=`This operation: ${jo(c.timeMs)}. With its children: ${jo(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 Cb(e,t){if(e.timeMs===t&&!e.cached)return e;for(let r of e.children){let n=Cb(r,t);if(n)return n}return e.timeMs===t?e:void 0}function wC(e){let t=document.createElement("pre");return t.className="explain-text",t.textContent=e,t}function kC(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 Rb(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 Fb(e){switch(e.kind){case"tree":{let t=SC(e.root,e.summary);return{root:t.root,tree:t,text:up(e.root,e.summary)}}case"text":return{root:wC(e.text),text:e.text};case"html":return{root:kC(e.html),text:e.html}}}function up(e,t){let r=[];t&&t.length&&r.push(...t,"");let n=(i,a)=>{let s=[];i.rows!==void 0&&s.push(`${wb(i.rows)} rows`),i.timeMs!==void 0&&s.push(jo(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(`
|
|
125
|
+
`)}var CC={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#"},pp=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{...CC,...t}}readQueryAndEndpoint(t){var n,i;let r=wp(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=qo(this.endpoint);return Ip(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=cp("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=Np(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 v=document.createElement("option");v.value=g,v.textContent=T,c.appendChild(v)},p=n.source==="detected"&&n.engine?` (${n.engine.label})`:"";u("auto",`Detect${p}`);for(let g of r.engines||Ri)tr[g]&&u(g,tr[g].label);u("none","No plan");let f=r.engine&&r.engine!=="auto"?r.engine:qo(this.endpoint);c.value=On(f)?f:"auto",c.disabled=!!r.engine&&r.engine!=="auto",c.addEventListener("change",()=>{let g=c.value;On(g)&&(_p(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, Neptune or TripleTrail; 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
126
|
${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
|
|
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
|
|
127
|
+
${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 RC(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(Sp(this.yasr)&&(!t.needsRequestOptions||Op(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=Fb(t.plan),i=t.plan.kind==="tree"?Go(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(lp(()=>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=cp("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=Ro(this.query,{baseIRI:t.baseIRI}),i=Ln(this.algebra,n),this.algebraText=Do(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(`${Go(i)} operations`);let a=Rb(i);return this.addTreeActions(r.actions,a),r.actions.appendChild(lp(()=>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"?up(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(`
|
|
128
|
+
`),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 RC(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 $o=pp;typeof window!="undefined"&&window.Yasgui&&window.Yasgui.Yasr&&window.Yasgui.Yasr.registerPlugin("Explain",$o);var FC=$o;return Hb(MC);})();
|
|
128
129
|
/*! Bundled license information:
|
|
129
130
|
|
|
130
131
|
@traqula/chevrotain/dist/esm/lib/index.js:
|