peggy
Version:
Parser generator for JavaScript
8 lines (7 loc) • 104 kB
JavaScript
// peggy 5.0.3
//
// https://peggyjs.org/
//
// Copyright (c) 2025- the Peggy authors
// Licensed under the MIT License.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).peggy=t()}(this,(function(){"use strict";function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var grammarLocation,hasRequiredGrammarLocation,grammarError,hasRequiredGrammarError,visitor_1,hasRequiredVisitor,asts_1,hasRequiredAsts,addImportedRules_1,hasRequiredAddImportedRules,fixLibraryNumbers_1,hasRequiredFixLibraryNumbers,opcodes_1,hasRequiredOpcodes,intern,hasRequiredIntern,inferenceMatchResult_1,hasRequiredInferenceMatchResult,generateBytecode_1,hasRequiredGenerateBytecode;function requireGrammarLocation(){return hasRequiredGrammarLocation?grammarLocation:(hasRequiredGrammarLocation=1,grammarLocation=class{constructor(e,t){this.source=e,this.start=t}toString(){return String(this.source)}offset(e){return{line:e.line+this.start.line-1,column:1===e.line?e.column+this.start.column-1:e.column,offset:e.offset+this.start.offset}}static offsetStart(e){return e.source&&"function"==typeof e.source.offset?e.source.offset(e.start):e.start}static offsetEnd(e){return e.source&&"function"==typeof e.source.offset?e.source.offset(e.end):e.end}})}function requireGrammarError(){if(hasRequiredGrammarError)return grammarError;hasRequiredGrammarError=1;const GrammarLocation=requireGrammarLocation();class e extends SyntaxError{constructor(e,t,r){super(e),this.name="GrammarError",this.location=t,void 0===r&&(r=[]),this.diagnostics=r,this.stage=null,this.problems=[["error",e,t,r]]}toString(){let e=super.toString();this.location&&(e+="\n at ",void 0!==this.location.source&&null!==this.location.source&&(e+=`${this.location.source}:`),e+=`${this.location.start.line}:${this.location.start.column}`);for(const t of this.diagnostics)e+="\n from ",void 0!==t.location.source&&null!==t.location.source&&(e+=`${t.location.source}:`),e+=`${t.location.start.line}:${t.location.start.column}: ${t.message}`;return e}format(e){const t=e.map((({source:e,text:t})=>({source:e,text:null!=t?String(t).split(/\r\n|\n|\r/g):[]})));function r(e,r,n=""){let o="";const s=t.find((({source:t})=>t===e.source)),i=e.start,a=GrammarLocation.offsetStart(e);if(s){const t=e.end,u=s.text[i.line-1],c=(i.line===t.line?t.column:u.length+1)-i.column||1;n&&(o+=`\nnote: ${n}`),o+=`\n --\x3e ${e.source}:${a.line}:${a.column}\n${"".padEnd(r)} |\n${a.line.toString().padStart(r)} | ${u}\n${"".padEnd(r)} | ${"".padEnd(i.column-1)}${"".padEnd(c,"^")}`}else o+=`\n at ${e.source}:${a.line}:${a.column}`,n&&(o+=`: ${n}`);return o}return this.problems.filter((e=>"info"!==e[0])).map((e=>function(e,t,n,o=[]){let s=-1/0;s=n?o.reduce(((e,{location:t})=>Math.max(e,GrammarLocation.offsetStart(t).line)),n.start.line):Math.max.apply(null,o.map((e=>e.location.start.line))),s=s.toString().length;let i=`${e}: ${t}`;n&&(i+=r(n,s));for(const e of o)i+=r(e.location,s,e.message);return i}(...e))).join("\n\n")}}return grammarError=e}function requireVisitor(){return hasRequiredVisitor?visitor_1:(hasRequiredVisitor=1,visitor_1={build(e){function t(t,...r){return e[t.type](t,...r)}function r(){}function n(e,...r){return t(e.expression,...r)}function o(e){return function(r,...n){r[e].forEach((e=>t(e,...n)))}}const s={grammar(e,...r){for(const n of e.imports)t(n,...r);if(e.topLevelInitializer)if(Array.isArray(e.topLevelInitializer))for(const n of e.topLevelInitializer)t(n,...r);else t(e.topLevelInitializer,...r);if(e.initializer)if(Array.isArray(e.initializer))for(const n of e.initializer)t(n,...r);else t(e.initializer,...r);e.rules.forEach((e=>t(e,...r)))},grammar_import:r,top_level_initializer:r,initializer:r,rule:n,named:n,choice:o("alternatives"),action:n,sequence:o("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,repeated:(e,...r)=>(e.delimiter&&t(e.delimiter,...r),t(e.expression,...r)),group:n,semantic_and:r,semantic_not:r,rule_ref:r,library_ref:r,literal:r,class:r,any:r};return Object.keys(s).forEach((t=>{Object.prototype.hasOwnProperty.call(e,t)||(e[t]=s[t])})),t}})}function requireAsts(){if(hasRequiredAsts)return asts_1;hasRequiredAsts=1;const e=requireVisitor();function t(e,t){if(!e||!t)return e||t;const r=Array.isArray(e)?e:[e];return r.push(t),r}const r={findRule(e,t){for(let r=0;r<e.rules.length;r++)if(e.rules[r].name===t)return e.rules[r]},indexOfRule(e,t){for(let r=0;r<e.rules.length;r++)if(e.rules[r].name===t)return r;return-1},alwaysConsumesOnSuccess(t,n){function o(){return!0}function s(){return!1}const i=e.build({choice:e=>e.alternatives.every(i),sequence:e=>e.elements.some(i),simple_and:s,simple_not:s,optional:s,zero_or_more:s,repeated(e){const t=e.min?e.min:e.max;return!("constant"!==t.type||0===t.value||!i(e.expression)&&!(t.value>1&&e.delimiter&&i(e.delimiter)))},semantic_and:s,semantic_not:s,rule_ref(e){const n=r.findRule(t,e.name);return n?i(n):void 0},library_ref:s,literal:e=>""!==e.value,class:o,any:o});return i(n)},combine:e=>e.reduce(((e,r)=>(e.topLevelInitializer=t(e.topLevelInitializer,r.topLevelInitializer),e.initializer=t(e.initializer,r.initializer),e.rules=e.rules.concat(r.rules),e)))};return asts_1=r}function requireAddImportedRules(){return hasRequiredAddImportedRules?addImportedRules_1:(hasRequiredAddImportedRules=1,addImportedRules_1=function(e){let t=0;for(const r of e.imports){for(const n of r.what){let o;switch(n.type){case"import_binding_all":continue;case"import_binding_default":break;case"import_binding":o=n.binding;break;case"import_binding_rename":o=n.rename;break;default:throw new TypeError("Unknown binding type")}e.rules.push({type:"rule",name:n.binding,nameLocation:n.location,expression:{type:"library_ref",name:o,library:r.from.module,libraryNumber:t,location:n.location},location:r.from.location})}t++}})}function requireFixLibraryNumbers(){if(hasRequiredFixLibraryNumbers)return fixLibraryNumbers_1;hasRequiredFixLibraryNumbers=1;const e=requireVisitor();return fixLibraryNumbers_1=function(t,r,n){const o=e.build({library_ref(e){-1===e.libraryNumber&&(e.libraryNumber=function(e,t){let r=0;for(const n of e.imports){for(const e of n.what)if("import_binding_all"===e.type&&e.binding===t)return r;r++}return-1}(t,e.library),-1===e.libraryNumber&&n.error(`Unknown module "${e.library}"`,e.location))}});o(t)},fixLibraryNumbers_1}function requireOpcodes(){return hasRequiredOpcodes?opcodes_1:(hasRequiredOpcodes=1,opcodes_1={PUSH:0,PUSH_EMPTY_STRING:35,PUSH_UNDEFINED:1,PUSH_NULL:2,PUSH_FAILED:3,PUSH_EMPTY_ARRAY:4,PUSH_CURR_POS:5,POP:6,POP_CURR_POS:7,POP_N:8,NIP:9,APPEND:10,WRAP:11,TEXT:12,PLUCK:36,IF:13,IF_ERROR:14,IF_NOT_ERROR:15,IF_LT:30,IF_GE:31,IF_LT_DYNAMIC:32,IF_GE_DYNAMIC:33,WHILE_NOT_ERROR:16,MATCH_ANY:17,MATCH_STRING:18,MATCH_STRING_IC:19,MATCH_CHAR_CLASS:20,MATCH_UNICODE_CLASS:42,MATCH_REGEXP:20,ACCEPT_N:21,ACCEPT_STRING:22,FAIL:23,LOAD_SAVED_POS:24,UPDATE_SAVED_POS:25,CALL:26,RULE:27,LIBRARY_RULE:41,SILENT_FAILS_ON:28,SILENT_FAILS_OFF:29,SOURCE_MAP_PUSH:37,SOURCE_MAP_POP:38,SOURCE_MAP_LABEL_PUSH:39,SOURCE_MAP_LABEL_POP:40})}function requireIntern(){return hasRequiredIntern?intern:(hasRequiredIntern=1,intern=class{constructor(e){this.options={stringify:String,convert:e=>e,...e},this.items=[],this.offsets=Object.create(null)}add(e){const t=this.options.convert(e);if(!t)return-1;const r=this.options.stringify(t);let n=this.offsets[r];return void 0===n&&(n=this.items.push(t)-1,this.offsets[r]=n),n}get(e){return this.items[e]}map(e){return this.items.map(e)}})}function requireInferenceMatchResult(){if(hasRequiredInferenceMatchResult)return inferenceMatchResult_1;hasRequiredInferenceMatchResult=1;const e=requireVisitor(),t=requireAsts(),r=requireGrammarError(),n=-1;function o(o){function s(e){return e.match=0}function i(e){return c(e.expression),e.match=1}function a(e){return e.match=c(e.expression)}function u(e,t){const r=e.length;let o=0,s=0;for(let t=0;t<r;++t){const r=c(e[t]);1===r&&++o,r===n&&++s}return o===r?1:t?s===r?n:0:s>0?n:0}const c=e.build({rule(e){let t,n=0;if(void 0===e.match){e.match=0;do{if(t=e.match,e.match=c(e.expression),++n>6)throw new r("Infinity cycle detected when trying to evaluate node match result",e.location)}while(t!==e.match)}return e.match},named:a,choice:e=>e.match=u(e.alternatives,!0),action:a,sequence:e=>e.match=u(e.elements,!1),labeled:a,text:a,simple_and:a,simple_not:e=>e.match=-c(e.expression),optional:i,zero_or_more:i,one_or_more:a,repeated(e){const t=c(e.expression),r=e.delimiter?c(e.delimiter):n,o=e.min?e.min:e.max;return"constant"!==o.type||"constant"!==e.max.type?e.match=0:0===e.max.value||null!==e.max.value&&o.value>e.max.value?e.match=n:t===n?e.match=0===o.value?1:n:1===t?e.delimiter&&o.value>=2?e.match=r:e.match=1:e.delimiter&&o.value>=2?e.match=r===n?n:0:e.match=0===o.value?1:0},group:a,semantic_and:s,semantic_not:s,rule_ref(e){const r=t.findRule(o,e.name);return r?e.match=c(r):0},library_ref:()=>0,literal(e){const t=0===e.value.length?1:0;return e.match=t},class(e){const t=0===e.parts.length?n:0;return e.match=t},any:s});c(o)}return o.ALWAYS_MATCH=1,o.SOMETIMES_MATCH=0,o.NEVER_MATCH=n,inferenceMatchResult_1=o}function requireGenerateBytecode(){if(hasRequiredGenerateBytecode)return generateBytecode_1;hasRequiredGenerateBytecode=1;const e=requireAsts(),t=requireOpcodes(),r=requireVisitor(),n=requireIntern(),{ALWAYS_MATCH:o,SOMETIMES_MATCH:s,NEVER_MATCH:i}=requireInferenceMatchResult();return generateBytecode_1=function(a,u){const c=new n,l=new n({stringify:JSON.stringify,convert:e=>({value:e.parts,inverted:e.inverted,ignoreCase:e.ignoreCase,unicode:e.unicode})}),p=new n({stringify:JSON.stringify}),h=new n,d=[],f=[];function m(e,t,r){const n={predicate:e,params:t,body:r.code,location:r.codeLocation},o=JSON.stringify(n),s=d.findIndex((e=>JSON.stringify(e)===o));return-1===s?d.push(n)-1:s}function g(e){return f.push(e)-1}function _(e){const t={};return Object.keys(e).forEach((r=>{t[r]=e[r]})),t}function R(e,...t){return e.concat(...t)}function y(e,t,r,n){return e===o?r:e===i?n:t.concat([r.length,n.length],r,n)}function b(e,r,n,o){const s=Object.keys(n).map((e=>o-n[e]));return[t.CALL,e,r,s.length].concat(s)}function S(e,r,n){const o=e.match||0;return R([t.PUSH_CURR_POS],[t.SILENT_FAILS_ON],v(e,{sp:n.sp+1,env:_(n.env),action:null}),[t.SILENT_FAILS_OFF],y(r?-o:o,[r?t.IF_ERROR:t.IF_NOT_ERROR],R([t.POP],[r?t.POP:t.POP_CURR_POS],[t.PUSH_UNDEFINED]),R([t.POP],[r?t.POP_CURR_POS:t.POP],[t.PUSH_FAILED])))}function P(e,r,n){const o=m(!0,Object.keys(n.env),e);return R([t.UPDATE_SAVED_POS],b(o,0,n.env,n.sp),y(e.match||0,[t.IF],R([t.POP],r?[t.PUSH_FAILED]:[t.PUSH_UNDEFINED]),R([t.POP],r?[t.PUSH_UNDEFINED]:[t.PUSH_FAILED])))}function x(e){return r=[t.WHILE_NOT_ERROR],n=R([t.APPEND],e),r.concat([n.length],n);var r,n}function A(e,r,n,o){switch(e.type){case"constant":return{pre:[],post:[],sp:n};case"variable":return e.sp=o+n-r[e.value],{pre:[],post:[],sp:n};case"function":return e.sp=o,{pre:b(m(!0,Object.keys(r),{code:e.value,codeLocation:e.codeLocation}),0,r,n),post:[t.NIP],sp:n+1};default:throw function(e){return new Error(`Unknown boundary type "${e.type}" for the "repeated" node`)}(e)}}function C(e,r){if(null!==r.value){const n="constant"===r.type?[t.IF_GE,r.value]:[t.IF_GE_DYNAMIC,r.sp||0];return y(s,n,[t.PUSH_FAILED],e)}return e}const v=(E={grammar(e){e.rules.forEach(v),e.literals=c.items,e.classes=l.items,e.expectations=p.items,e.importedNames=h.items,e.functions=d,e.locations=f},rule(e){e.bytecode=v(e.expression,{sp:-1,env:{},pluck:[],action:null})},named(e,r){const n=e.match||0,s=n===o?-1:p.add({type:"rule",value:e.name});return R([t.SILENT_FAILS_ON],v(e.expression,r),[t.SILENT_FAILS_OFF],y(-n,[t.IF_ERROR],[t.FAIL,s],[]))},choice:(e,r)=>function e(r,n){const i=r[0].match||0,a=v(r[0],{sp:n.sp,env:_(n.env),action:null});return i===o?a:R(a,r.length>1?y(s,[t.IF_ERROR],R([t.POP],e(r.slice(1),n)),[]):[])}(e.alternatives,r),action(e,r){const n=_(r.env),o="sequence"!==e.expression.type||0===e.expression.elements.length,s=v(e.expression,{sp:r.sp+(o?1:0),env:n,action:e}),a=e.expression.match||0,u=o&&a!==i?m(!1,Object.keys(n),e):-1;return o?R([t.PUSH_CURR_POS],s,y(a,[t.IF_NOT_ERROR],R([t.LOAD_SAVED_POS,1],b(u,1,n,r.sp+2)),[]),[t.NIP]):s},sequence:(e,r)=>R([t.PUSH_CURR_POS],function r(n,o){if(n.length>0){const s=e.elements.length-n.length+1;return R(v(n[0],{sp:o.sp,env:o.env,pluck:o.pluck,action:null}),y(n[0].match||0,[t.IF_NOT_ERROR],r(n.slice(1),{sp:o.sp+1,env:o.env,pluck:o.pluck,action:o.action}),R(s>1?[t.POP_N,s]:[t.POP],[t.POP_CURR_POS],[t.PUSH_FAILED])))}if(o.pluck&&o.pluck.length>0)return R([t.PLUCK,e.elements.length+1,o.pluck.length],o.pluck.map((e=>o.sp-e)));if(o.action){const r=m(!1,Object.keys(o.env),o.action);return R([t.LOAD_SAVED_POS,e.elements.length],b(r,e.elements.length+1,o.env,o.sp))}return R([t.WRAP,e.elements.length],[t.NIP])}(e.elements,{sp:r.sp+1,env:r.env,pluck:[],action:r.action})),labeled(e,r){let n=r.env;const o=e.label,s=r.sp+1;o&&(n=_(r.env),r.env[o]=s),e.pick&&r.pluck.push(s);const i=v(e.expression,{sp:r.sp,env:n,action:null});return o&&e.labelLocation&&u&&"source-and-map"===u.output?R([t.SOURCE_MAP_LABEL_PUSH,s,c.add(o),g(e.labelLocation)],i,[t.SOURCE_MAP_LABEL_POP,s]):i},text:(e,r)=>R([t.PUSH_CURR_POS],v(e.expression,{sp:r.sp+1,env:_(r.env),action:null}),y(e.match||0,[t.IF_NOT_ERROR],R([t.POP],[t.TEXT]),[t.NIP])),simple_and:(e,t)=>S(e.expression,!1,t),simple_not:(e,t)=>S(e.expression,!0,t),optional:(e,r)=>R(v(e.expression,{sp:r.sp,env:_(r.env),action:null}),y(-(e.expression.match||0),[t.IF_ERROR],R([t.POP],[t.PUSH_NULL]),[])),zero_or_more(e,r){const n=v(e.expression,{sp:r.sp+1,env:_(r.env),action:null});return R([t.PUSH_EMPTY_ARRAY],n,x(n),[t.POP])},one_or_more(e,r){const n=v(e.expression,{sp:r.sp+1,env:_(r.env),action:null});return R([t.PUSH_EMPTY_ARRAY],n,y(e.expression.match||0,[t.IF_NOT_ERROR],R(x(n),[t.POP]),R([t.POP],[t.POP],[t.PUSH_FAILED])))},repeated(e,r){const n=e.min?e.min:e.max,o="constant"!==n.type||n.value>0,i="constant"!==e.max.type&&null!==e.max.value,a=o?2:1,u=e.min?A(e.min,r.env,r.sp,2+("function"===e.max.type?1:0)):{pre:[],post:[],sp:r.sp},c=A(e.max,r.env,u.sp,a),l=v(e.expression,{sp:c.sp+a,env:_(r.env),action:null}),p=null!==e.delimiter?v(e.expression,{sp:c.sp+a+1,env:_(r.env),action:null}):l,h=function(e,r,n,o,s){return e?R([t.PUSH_CURR_POS],v(e,{sp:o.sp+s+1,env:_(o.env),action:null}),y(e.match||0,[t.IF_NOT_ERROR],R([t.POP],n,y(-r,[t.IF_ERROR],[t.POP,t.POP_CURR_POS,t.PUSH_FAILED],[t.NIP])),[t.NIP])):n}(e.delimiter,e.expression.match||0,p,r,a),d=C(h,e.max),f=i?C(l,e.max):l,m=R(o?[t.PUSH_CURR_POS]:[],[t.PUSH_EMPTY_ARRAY],f,x(d),[t.POP]);return R(u.pre,c.pre,o?function(e,r){const n="constant"===r.type?[t.IF_LT,r.value]:[t.IF_LT_DYNAMIC,r.sp||0];return R(e,y(s,n,[t.POP,t.POP_CURR_POS,t.PUSH_FAILED],[t.NIP]))}(m,n):m,c.post,u.post)},group:(e,t)=>v(e.expression,{sp:t.sp,env:_(t.env),action:null}),semantic_and:(e,t)=>P(e,!1,t),semantic_not:(e,t)=>P(e,!0,t),rule_ref:r=>[t.RULE,e.indexOfRule(a,r.name)],library_ref:e=>[t.LIBRARY_RULE,e.libraryNumber,h.add(e.name)],literal(e){if(e.value.length>0){const r=e.match||0,n=r===s||r===o&&!e.ignoreCase?c.add(e.ignoreCase?e.value.toLowerCase():e.value):-1,i=r!==o?p.add({type:"literal",value:e.value,ignoreCase:e.ignoreCase}):-1;return y(r,e.ignoreCase?[t.MATCH_STRING_IC,n]:[t.MATCH_STRING,n],e.ignoreCase?[t.ACCEPT_N,e.value.length]:[t.ACCEPT_STRING,n],[t.FAIL,i])}return[t.PUSH_EMPTY_STRING]},class(e){const r=e.match||0,n=r===s?l.add(e):-1,i=r!==o?p.add({type:"class",value:e.parts,inverted:e.inverted,ignoreCase:e.ignoreCase,unicode:e.unicode}):-1;return y(r,[e.unicode?t.MATCH_UNICODE_CLASS:t.MATCH_CHAR_CLASS,n],[t.ACCEPT_N,e.unicode?-1:1],[t.FAIL,i])},any(e){const r=e.match||0,n=r!==o?p.add({type:"any"}):-1;return y(r,[t.MATCH_ANY],[t.ACCEPT_N,1],[t.FAIL,n])}},u&&"source-and-map"===u.output&&Object.keys(E).forEach((e=>{const r=E[e];E[e]=function(e,...n){const o=r(e,...n);return void 0!==o&&e.location?R([t.SOURCE_MAP_PUSH,g(e.location)],o,[t.SOURCE_MAP_POP]):o}})),r.build(E));var E;v(a)}}var sourceMap={},sourceMapGenerator={},base64Vlq={},base64={},hasRequiredBase64,hasRequiredBase64Vlq;function requireBase64(){if(hasRequiredBase64)return base64;hasRequiredBase64=1;const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return base64.encode=function(t){if(0<=t&&t<e.length)return e[t];throw new TypeError("Must be between 0 and 63: "+t)},base64}function requireBase64Vlq(){if(hasRequiredBase64Vlq)return base64Vlq;hasRequiredBase64Vlq=1;const e=requireBase64();return base64Vlq.encode=function(t){let r,n="",o=function(e){return e<0?1+(-e<<1):0+(e<<1)}(t);do{r=31&o,o>>>=5,o>0&&(r|=32),n+=e.encode(r)}while(o>0);return n},base64Vlq}var util={},hasRequiredUtil;function requireUtil(){if(hasRequiredUtil)return util;hasRequiredUtil=1,util.getArg=function(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')};const e=!("__proto__"in Object.create(null));function t(e){return e}function r(e){if(!e)return!1;const t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(let r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function n(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}util.toSetString=e?t:function(e){return r(e)?"$"+e:e},util.fromSetString=e?t:function(e){return r(e)?e.slice(1):e},util.compareByGeneratedPositionsInflated=function(e,t){let r=e.generatedLine-t.generatedLine;return 0!==r?r:(r=e.generatedColumn-t.generatedColumn,0!==r?r:(r=n(e.source,t.source),0!==r?r:(r=e.originalLine-t.originalLine,0!==r?r:(r=e.originalColumn-t.originalColumn,0!==r?r:n(e.name,t.name)))))};const o="http://host";function s(e){return t=>{const r=c(t),n=a(t),o=new URL(t,n);e(o);const s=o.toString();return"absolute"===r?s:"scheme-relative"===r?s.slice(5):"path-absolute"===r?s.slice(11):l(n,s)}}function i(e,t){return new URL(e,t).toString()}function a(e){const t=e.split("..").length-1,r=function(e,t){let r=0;for(;;){const e="p"+r++;if(-1===t.indexOf(e))return e}}(0,e);let n=`${o}/`;for(let e=0;e<t;e++)n+=`${r}/`;return n}const u=/^[A-Za-z0-9\+\-\.]+:/;function c(e){return"/"===e[0]?"/"===e[1]?"scheme-relative":"path-absolute":u.test(e)?"absolute":"path-relative"}function l(e,t){"string"==typeof e&&(e=new URL(e)),"string"==typeof t&&(t=new URL(t));const r=t.pathname.split("/"),n=e.pathname.split("/");for(n.length>0&&!n[n.length-1]&&n.pop();r.length>0&&n.length>0&&r[0]===n[0];)r.shift(),n.shift();return n.map((()=>"..")).concat(r).join("/")+t.search+t.hash}const p=s((e=>{e.pathname=e.pathname.replace(/\/?$/,"/")})),h=s((e=>{}));return util.normalize=h,util.join=function(e,t){const r=c(t),n=c(e);if(e=p(e),"absolute"===r)return i(t,void 0);if("absolute"===n)return i(t,e);if("scheme-relative"===r)return h(t);if("scheme-relative"===n)return i(t,i(e,o)).slice(5);if("path-absolute"===r)return h(t);if("path-absolute"===n)return i(t,i(e,o)).slice(11);const s=a(t+e);return l(s,i(t,i(e,s)))},util.relative=function(e,t){const r=function(e,t){if(c(e)!==c(t))return null;const r=a(e+t),n=new URL(e,r),o=new URL(t,r);try{new URL("",o.toString())}catch(e){return null}return o.protocol!==n.protocol||o.user!==n.user||o.password!==n.password||o.hostname!==n.hostname||o.port!==n.port?null:l(n,o)}(e,t);return"string"==typeof r?r:h(t)},util}var arraySet={},hasRequiredArraySet;function requireArraySet(){if(hasRequiredArraySet)return arraySet;hasRequiredArraySet=1;class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){const n=new e;for(let e=0,o=t.length;e<o;e++)n.add(t[e],r);return n}size(){return this._set.size}add(e,t){const r=this.has(e),n=this._array.length;r&&!t||this._array.push(e),r||this._set.set(e,n)}has(e){return this._set.has(e)}indexOf(e){const t=this._set.get(e);if(t>=0)return t;throw new Error('"'+e+'" is not in the set.')}at(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)}toArray(){return this._array.slice()}}return arraySet.ArraySet=e,arraySet}var mappingList={},hasRequiredMappingList,hasRequiredSourceMapGenerator;function requireMappingList(){if(hasRequiredMappingList)return mappingList;hasRequiredMappingList=1;const e=requireUtil();return mappingList.MappingList=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(e,t){this._array.forEach(e,t)}add(t){!function(t,r){const n=t.generatedLine,o=r.generatedLine,s=t.generatedColumn,i=r.generatedColumn;return o>n||o==n&&i>=s||e.compareByGeneratedPositionsInflated(t,r)<=0}(this._last,t)?(this._sorted=!1,this._array.push(t)):(this._last=t,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}},mappingList}function requireSourceMapGenerator(){if(hasRequiredSourceMapGenerator)return sourceMapGenerator;hasRequiredSourceMapGenerator=1;const e=requireBase64Vlq(),t=requireUtil(),r=requireArraySet().ArraySet,n=requireMappingList().MappingList;class o{constructor(e){e||(e={}),this._file=t.getArg(e,"file",null),this._sourceRoot=t.getArg(e,"sourceRoot",null),this._skipValidation=t.getArg(e,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new n,this._sourcesContents=null}static fromSourceMap(e){const r=e.sourceRoot,n=new o({file:e.file,sourceRoot:r});return e.eachMapping((function(e){const o={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(o.source=e.source,null!=r&&(o.source=t.relative(r,o.source)),o.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(o.name=e.name)),n.addMapping(o)})),e.sources.forEach((function(o){let s=o;null!=r&&(s=t.relative(r,o)),n._sources.has(s)||n._sources.add(s);const i=e.sourceContentFor(o);null!=i&&n.setSourceContent(o,i)})),n}addMapping(e){const r=t.getArg(e,"generated"),n=t.getArg(e,"original",null);let o=t.getArg(e,"source",null),s=t.getArg(e,"name",null);this._skipValidation||this._validateMapping(r,n,o,s),null!=o&&(o=String(o),this._sources.has(o)||this._sources.add(o)),null!=s&&(s=String(s),this._names.has(s)||this._names.add(s)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:o,name:s})}setSourceContent(e,r){let n=e;null!=this._sourceRoot&&(n=t.relative(this._sourceRoot,n)),null!=r?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))}applySourceMap(e,n,o){let s=n;if(null==n){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');s=e.file}const i=this._sourceRoot;null!=i&&(s=t.relative(i,s));const a=this._mappings.toArray().length>0?new r:this._sources,u=new r;this._mappings.unsortedForEach((function(r){if(r.source===s&&null!=r.originalLine){const n=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});null!=n.source&&(r.source=n.source,null!=o&&(r.source=t.join(o,r.source)),null!=i&&(r.source=t.relative(i,r.source)),r.originalLine=n.line,r.originalColumn=n.column,null!=n.name&&(r.name=n.name))}const n=r.source;null==n||a.has(n)||a.add(n);const c=r.name;null==c||u.has(c)||u.add(c)}),this),this._sources=a,this._names=u,e.sources.forEach((function(r){const n=e.sourceContentFor(r);null!=n&&(null!=o&&(r=t.join(o,r)),null!=i&&(r=t.relative(i,r)),this.setSourceContent(r,n))}),this)}_validateMapping(e,t,r,n){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!t&&!r&&!n);else if(!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:n}))}_serializeMappings(){let r,n,o,s,i=0,a=1,u=0,c=0,l=0,p=0,h="";const d=this._mappings.toArray();for(let f=0,m=d.length;f<m;f++){if(n=d[f],r="",n.generatedLine!==a)for(i=0;n.generatedLine!==a;)r+=";",a++;else if(f>0){if(!t.compareByGeneratedPositionsInflated(n,d[f-1]))continue;r+=","}r+=e.encode(n.generatedColumn-i),i=n.generatedColumn,null!=n.source&&(s=this._sources.indexOf(n.source),r+=e.encode(s-p),p=s,r+=e.encode(n.originalLine-1-c),c=n.originalLine-1,r+=e.encode(n.originalColumn-u),u=n.originalColumn,null!=n.name&&(o=this._names.indexOf(n.name),r+=e.encode(o-l),l=o)),h+=r}return h}_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents)return null;null!=r&&(e=t.relative(r,e));const n=t.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)}toJSON(){const e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e}toString(){return JSON.stringify(this.toJSON())}}return o.prototype._version=3,sourceMapGenerator.SourceMapGenerator=o,sourceMapGenerator}var sourceNode={},hasRequiredSourceNode,hasRequiredSourceMap,stack,hasRequiredStack;function requireSourceNode(){if(hasRequiredSourceNode)return sourceNode;hasRequiredSourceNode=1;const e=requireSourceMapGenerator().SourceMapGenerator,t=requireUtil(),r=/(\r?\n)/,n="$$$isSourceNode$$$";class o{constructor(e,t,r,o,s){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==r?null:r,this.name=null==s?null:s,this[n]=!0,null!=o&&this.add(o)}static fromStringWithSourceMap(e,n,s){const i=new o,a=e.split(r);let u=0;const c=function(){return e()+(e()||"");function e(){return u<a.length?a[u++]:void 0}};let l,p=1,h=0,d=null;return n.eachMapping((function(e){if(null!==d){if(!(p<e.generatedLine)){l=a[u]||"";const t=l.substr(0,e.generatedColumn-h);return a[u]=l.substr(e.generatedColumn-h),h=e.generatedColumn,f(d,t),void(d=e)}f(d,c()),p++,h=0}for(;p<e.generatedLine;)i.add(c()),p++;h<e.generatedColumn&&(l=a[u]||"",i.add(l.substr(0,e.generatedColumn)),a[u]=l.substr(e.generatedColumn),h=e.generatedColumn),d=e}),this),u<a.length&&(d&&f(d,c()),i.add(a.splice(u).join(""))),n.sources.forEach((function(e){const r=n.sourceContentFor(e);null!=r&&(null!=s&&(e=t.join(s,e)),i.setSourceContent(e,r))})),i;function f(e,r){if(null===e||void 0===e.source)i.add(r);else{const n=s?t.join(s,e.source):e.source;i.add(new o(e.originalLine,e.originalColumn,n,r,e.name))}}}add(e){if(Array.isArray(e))e.forEach((function(e){this.add(e)}),this);else{if(!e[n]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this}prepend(e){if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[n]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this}walk(e){let t;for(let r=0,o=this.children.length;r<o;r++)t=this.children[r],t[n]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})}join(e){let t,r;const n=this.children.length;if(n>0){for(t=[],r=0;r<n-1;r++)t.push(this.children[r]),t.push(e);t.push(this.children[r]),this.children=t}return this}replaceRight(e,t){const r=this.children[this.children.length-1];return r[n]?r.replaceRight(e,t):"string"==typeof r?this.children[this.children.length-1]=r.replace(e,t):this.children.push("".replace(e,t)),this}setSourceContent(e,r){this.sourceContents[t.toSetString(e)]=r}walkSourceContents(e){for(let t=0,r=this.children.length;t<r;t++)this.children[t][n]&&this.children[t].walkSourceContents(e);const r=Object.keys(this.sourceContents);for(let n=0,o=r.length;n<o;n++)e(t.fromSetString(r[n]),this.sourceContents[r[n]])}toString(){let e="";return this.walk((function(t){e+=t})),e}toStringWithSourceMap(t){const r={code:"",line:1,column:0},n=new e(t);let o=!1,s=null,i=null,a=null,u=null;return this.walk((function(e,t){r.code+=e,null!==t.source&&null!==t.line&&null!==t.column?(s===t.source&&i===t.line&&a===t.column&&u===t.name||n.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name}),s=t.source,i=t.line,a=t.column,u=t.name,o=!0):o&&(n.addMapping({generated:{line:r.line,column:r.column}}),s=null,o=!1);for(let i=0,a=e.length;i<a;i++)10===e.charCodeAt(i)?(r.line++,r.column=0,i+1===a?(s=null,o=!1):o&&n.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name})):r.column++})),this.walkSourceContents((function(e,t){n.setSourceContent(e,t)})),{code:r.code,map:n}}}return sourceNode.SourceNode=o,sourceNode}function requireSourceMap(){return hasRequiredSourceMap||(hasRequiredSourceMap=1,sourceMap.SourceMapGenerator=requireSourceMapGenerator().SourceMapGenerator,sourceMap.SourceNode=requireSourceNode().SourceNode),sourceMap}function requireStack(){if(hasRequiredStack)return stack;hasRequiredStack=1;const{SourceNode:e}=requireSourceMap(),GrammarLocation=requireGrammarLocation();class t{constructor(e,t,r,n){this.sp=-1,this.maxSp=-1,this.varName=t,this.ruleName=e,this.type=r,this.bytecode=n,this.labels={},this.sourceMapStack=[]}name(e){if(e<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack underflow: attempt to use a variable '${this.varName}<x>' at an index ${e}.\nBytecode: ${this.bytecode}`);return this.varName+e}static sourceNode(t,r,n){const o=GrammarLocation.offsetStart(t);return new e(o.line,o.column?o.column-1:null,String(t.source),r,n)}push(r){++this.sp>this.maxSp&&(this.maxSp=this.sp);const n=this.labels[this.sp],o=[this.name(this.sp)," = ",r,";"];if(n){if(this.sourceMapStack.length){const r=t.sourceNode(n.location,o.splice(0,2),n.label),{parts:s,location:i}=this.sourceMapPopInternal(),a=i.start.offset<n.location.end.offset?{start:n.location.end,end:i.end,source:i.source}:i,u=t.sourceNode(a,o.concat("\n"));return this.sourceMapStack.push([s,s.length+1,i]),new e(null,null,n.location.source,[r,u])}return t.sourceNode(n.location,o.concat("\n"))}return o.join("")}pop(e){return void 0!==e?(this.sp-=e,Array.from({length:e},((e,t)=>this.name(this.sp+1+t)))):this.name(this.sp--)}top(){return this.name(this.sp)}index(e){if(e<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${e}.\nBytecode: ${this.bytecode}`);return this.name(this.sp-e)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result.\nBytecode: ${this.bytecode}`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},((e,t)=>this.name(t))).join(", ")+";"}checkedIf(e,t,r){const n=this.sp,o=t();if(!r)return[o];const s=this.sp;this.sp=n;const i=r();if(s!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+e+": Branches of a condition can't move the stack pointer differently (before: "+n+", after then: "+s+", after else: "+this.sp+"). Bytecode: "+this.bytecode);return[o,i]}checkedLoop(e,t){const r=this.sp,n=t();if(r!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+e+": Body of a loop can't move the stack pointer (before: "+r+", after: "+this.sp+"). Bytecode: "+this.bytecode);return n}sourceMapPush(e,t){if(this.sourceMapStack.length){const e=this.sourceMapStack[this.sourceMapStack.length-1];e[2].start.offset===t.start.offset&&e[2].end.offset>t.end.offset&&(e[2]={start:t.end,end:e[2].end,source:e[2].source})}this.sourceMapStack.push([e,e.length,t])}sourceMapPopInternal(){const t=this.sourceMapStack.pop();if(!t)throw new RangeError(`Rule '${this.ruleName}': Attempting to pop an empty source map stack.\nBytecode: ${this.bytecode}`);const[r,n,o]=t,s=r.splice(n).map((t=>t instanceof e?t:t+"\n"));if(s.length){const t=GrammarLocation.offsetStart(o);r.push(new e(t.line,t.column-1,String(o.source),s))}return{parts:r,location:o}}sourceMapPop(e){const{location:t}=this.sourceMapPopInternal();if(this.sourceMapStack.length&&t.end.offset<this.sourceMapStack[this.sourceMapStack.length-1][2].end.offset){const{parts:r,location:n}=this.sourceMapPopInternal(),o=n.start.offset<t.end.offset?{start:t.end,end:n.end,source:n.source}:n;this.sourceMapStack.push([r,r.length+(e||0),o])}}}return stack=t}var version={},hasRequiredVersion;function requireVersion(){return hasRequiredVersion||(hasRequiredVersion=1,version.version="5.0.3"),version}var utils={},hasRequiredUtils,parser,hasRequiredParser,generateJs,hasRequiredGenerateJs,removeProxyRules_1,hasRequiredRemoveProxyRules,mergeCharacterClasses_1,hasRequiredMergeCharacterClasses,removeUnusedRules_1,hasRequiredRemoveUnusedRules,reportDuplicateImports_1,hasRequiredReportDuplicateImports,reportDuplicateLabels_1,hasRequiredReportDuplicateLabels,reportDuplicateRules_1,hasRequiredReportDuplicateRules,reportInfiniteRecursion_1,hasRequiredReportInfiniteRecursion,reportInfiniteRepetition_1,hasRequiredReportInfiniteRepetition,reportUndefinedRules_1,hasRequiredReportUndefinedRules,reportIncorrectPlucking_1,hasRequiredReportIncorrectPlucking,reportUnreachable_1,hasRequiredReportUnreachable,session,hasRequiredSession,compiler_1,hasRequiredCompiler,peg_1,hasRequiredPeg;function requireUtils(){if(hasRequiredUtils)return utils;function e(e){return e.codePointAt(0).toString(16).toUpperCase()}return hasRequiredUtils=1,utils.hex=e,utils.stringEscape=function(t){return"object"==typeof t?`\\\\${t.value}`:t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\u{10000}-\u{10FFFF}]/gu,(t=>`\\u{${e(t)}}`)).replace(/[\x00-\x0F]/g,(t=>"\\x0"+e(t))).replace(/[\x10-\x1F\x7F-\xFF]/g,(t=>"\\x"+e(t))).replace(/[\u0100-\u0FFF]/g,(t=>"\\u0"+e(t))).replace(/[\u1000-\uFFFF]/g,(t=>"\\u"+e(t)))},utils.regexpClassEscape=function(t){return"object"==typeof t?`\\${t.value}`:t.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(t=>"\\x0"+e(t))).replace(/[\x10-\x1F\x7F-\xFF]/g,(t=>"\\x"+e(t))).replace(/[\u{10000}-\u{10FFFF}]/gu,(t=>"\\u{"+e(t)+"}")).replace(/[\u0100-\u0FFF]/g,(t=>"\\u0"+e(t))).replace(/[\u1000-\uFFFF]/g,(t=>"\\u"+e(t)))},utils.base64=function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e.length%3,n=e.length-r;let o="";for(let r=0;r<n;r+=3)o+=t[e[r]>>2],o+=t[(3&e[r])<<4|e[r+1]>>4],o+=t[(15&e[r+1])<<2|e[r+2]>>6],o+=t[63&e[r+2]];return 1===r?(o+=t[e[n]>>2],o+=t[(3&e[n])<<4],o+="=="):2===r&&(o+=t[e[n]>>2],o+=t[(3&e[n])<<4|e[n+1]>>4],o+=t[(15&e[n+1])<<2],o+="="),o},utils.codePointLen1=function(e){const t=e[Symbol.iterator](),r=t.next();return r.done?-1:t.next().done?r.value.codePointAt(0):-1},utils}function requireParser(){if(hasRequiredParser)return parser;hasRequiredParser=1;const e={$:"text","&":"simple_and","!":"simple_not"},t={"?":"optional","*":"zero_or_more","+":"one_or_more"},r={"&":"semantic_and","!":"semantic_not"};class n extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null;const n=e.find((e=>e.source===this.location.source));n&&(r=n.text.split(/\r\n|\n|\r/g));const o=this.location.start,s=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,i=this.location.source+":"+s.line+":"+s.column;if(r){const e=this.location.end,n="".padEnd(s.line.toString().length," "),a=r[o.line-1],u=(o.line===e.line?e.column:a.length+1)-o.column||1;t+="\n --\x3e "+i+"\n"+n+" |\n"+s.line+" | "+a+"\n"+n+" | "+"".padEnd(o.column-1," ")+"".padEnd(u,"^")}else t+="\n at "+i}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function o(e){return n?e.replace(n,(e=>"\\u{"+r(e)+"}")):e}function s(e){return o(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(e=>"\\x0"+r(e))).replace(/[\x10-\x1F\x7F-\x9F]/g,(e=>"\\x"+r(e))))}function i(e){return o(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(e=>"\\x0"+r(e))).replace(/[\x10-\x1F\x7F-\x9F]/g,(e=>"\\x"+r(e))))}const a={literal:e=>'"'+s(e.text)+'"',class(e){const t=e.parts.map((e=>Array.isArray(e)?i(e[0])+"-"+i(e[1]):i(e)));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function u(e){return a[e.type](e)}return"Expected "+function(e){const t=e.map(u);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+s(e)+'"':"end of input"}(t)+" found."}}return parser={StartRules:["Grammar","ImportsAndSource"],SyntaxError:n,parse:function(o,s){const i={},a=(s=void 0!==s?s:{}).grammarSource,u={Grammar:Kt,ImportsAndSource:function(){let e,t,r;return e=kt,t=function(){let e,t;return e=kt,t=kt,Zt(),t=o.substring(t,kt),Ut=e,t={type:"top_level_initializer",code:t,codeLocation:Gt()},e=t,e}(),r=function(){let e,t,r,n;for(e=kt,t=kt,r=[],o.length>kt?(n=o.charAt(kt),kt++):(n=i,0===jt&&Xt(Re));n!==i;)r.push(n),o.length>kt?(n=o.charAt(kt),kt++):(n=i,0===jt&&Xt(Re));return t=o.substring(t,kt),Ut=e,t={type:"top_level_initializer",code:t,codeLocation:Gt()},e=t,e}(),Ut=e,e=[t,r],e}};let c=Kt;const l="import",p=";",h=",",d="*",f="as",m="{",g="}",_="from",R="=",y="/",b="@",S=":",P="|",x="..",A="(",C=")",v=".",E="\n",$="\r\n",w="/*",L="*/",q="//",I="\\",O="i",F='"',k="'",U="[",M="^",N="]",D="p",T="_",j="u",G="-",H="0",V="b",B="f",z="n",Y="r",J="t",W="v",X="x",K=/^[!$&]/,Z=/^[*-+?]/,Q=/^[!&]/,ee=/^[\0-\uD7FF\uE000-\uFFFF]/,te=/^[\uD800-\uDBFF]/,re=/^[\uDC00-\uDFFF]/,ne=/^[\uD800-\uDFFF]/,oe=/^[\t\v-\f \p{Zs}\xA0\uFEFF]/u,se=/^[\n\r\u2028\u2029]/,ie=/^[\r\u2028-\u2029]/,ae=/^[\p{ID_Start}_]/u,ue=/^[$\p{ID_Continue}]/u,ce=/^[\n\r"\\\u2028-\u2029]/,le=/^[\n\r'\\\u2028-\u2029]/,pe=/^[a-z]/i,he=/^[\n\r\\-\]\u2028-\u2029]/,de=/^["'\\]/,fe=/^[0-9pux]/,me=/^[0-9]/,ge=/^[0-9a-f]/i,_e=/^[{}]/,Re={type:"any"},ye=Bt("import",!1),be=Bt(";",!1),Se=Bt(",",!1),Pe=Bt("*",!1),xe=Bt("as",!1),Ae=Bt("{",!1),Ce=Bt("}",!1),ve=Bt("from",!1),Ee=Bt("=",!1),$e=Bt("/",!1),we=Bt("@",!1),Le=Bt(":",!1),qe=zt(["!","$","&"],!1,!1,!1),Ie=zt([["*","+"],"?"],!1,!1,!1),Oe=Bt("|",!1),Fe=Bt("..",!1),ke=Bt("(",!1),Ue=Bt(")",!1),Me=Bt(".",!1),Ne=zt(["!","&"],!1,!1,!1),De=zt([["\0",""],["",""]],!1,!1,!1),Te=zt([["\ud800","\udbff"]],!1,!1,!1),je=zt([["\udc00","\udfff"]],!1,!1,!1),Ge=zt([["\ud800","\udfff"]],!1,!1,!1),He=Yt("whitespace"),Ve=zt(["\t",["\v","\f"]," ","\\p{Zs}"," ","\ufeff"],!1,!1,!0),Be=zt(["\n","\r","\u2028","\u2029"],!1,!1,!1),ze=Yt("end of line"),Ye=Bt("\n",!1),Je=Bt("\r\n",!1),We=zt(["\r",["\u2028","\u2029"]],!1,!1,!1),Xe=Yt("comment"),Ke=Bt("/*",!1),Ze=Bt("*/",!1),Qe=Bt("//",!1),et=Yt("identifier"),tt=zt(["\\p{ID_Start}","_"],!1,!1,!0),rt=Bt("\\",!1),nt=zt(["$","\\p{ID_Continue}"],!1,!1,!0),ot=Yt("literal"),st=Bt("i",!1),it=Yt("string"),at=Bt('"',!1),ut=Bt("'",!1),ct=zt(["\n","\r",'"',"\\",["\u2028","\u2029"]],!1,!1,!1),lt=zt(["\n","\r","'","\\",["\u2028","\u2029"]],!1,!1,!1),pt=Yt("character class"),ht=Bt("[",!1),dt=Bt("^",!1),ft=Bt("]",!1),mt=Bt("p",!0),gt=Bt("_",!1),_t=zt([["a","z"]],!1,!0,!1),Rt=Bt("u",!1),yt=Bt("-",!1),bt=zt(["\n","\r",["\\","]"],["\u2028","\u2029"]],!1,!1,!1),St=Bt("0",!1),Pt=zt(['"',"'","\\"],!1,!1,!1),xt=Bt("b",!1),At=Bt("f",!1),Ct=Bt("n",!1),vt=Bt("r",!1),Et=Bt("t",!1),$t=Bt("v",!1),wt=zt([["0","9"],"p","u","x"],!1,!1,!1),Lt=Bt("x",!1),qt=zt([["0","9"]],!1,!1,!1),It=zt([["0","9"],["a","f"]],!1,!0,!1),Ot=Yt("code block"),Ft=zt(["{","}"],!1,!1,!1);let kt=0|s.peg$currPos,Ut=kt;const Mt=[{line:1,column:1}];let Nt,Dt=kt,Tt=s.peg$maxFailExpected||[],jt=0|s.peg$silentFails;if(s.startRule){if(!(s.startRule in u))throw new Error("Can't start parsing from rule \""+s.startRule+'".');c=u[s.startRule]}function Gt(){return Wt(Ut,kt)}function Ht(e,t){throw function(e,t){return new n(e,null,null,t)}(e,t=void 0!==t?t:Wt(Ut,kt))}function Vt(e=kt){const t=o.codePointAt(e);return void 0===t?"":String.fromCodePoint(t)}function Bt(e,t){return{type:"literal",text:e,ignoreCase:t}}function zt(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function Yt(e){return{type:"other",description:e}}function Jt(e){let t,r=Mt[e];if(r)return r;if(e>=Mt.length)t=Mt.length-1;else for(t=e;!Mt[--t];);for(r=Mt[t],r={line:r.line,column:r.column};t<e;)10===o.charCodeAt(t)?(r.line++,r.column=1):r.column++,t++;return Mt[e]=r,r}function Wt(e,t,r){const n=Jt(e),o=Jt(t);return{source:a,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:o.line,column:o.column}}}function Xt(e){kt<Dt||(kt>Dt&&(Dt=kt,Tt=[]),Tt.push(e))}function Kt(){let e,t,r,n,s,a,u,c;if(e=kt,t=Zt(),r=kt,n=Tr(),s=function(){let e,t,r,n,s;var a;return e=kt,123===o.charCodeAt(kt)?(t=m,kt++):(t=i,0===jt&&Xt(Ae)),t!==i?(r=Nr(),r!==i?(125===o.charCodeAt(kt)?(n=g,kt++):(n=i,0===jt&&Xt(Ce)),n!==i?(s=jr(),s!==i?(Ut=e,e={type:"top_level_initializer",code:(a=r)[0],codeLocation:a[1],location:Gt()}):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e}(),s!==i?r=s:(kt=r,r=i),r===i&&(r=null),n=kt,s=Tr(),a=function(){let e,t,r;var n;return e=kt,t=Nr(),t!==i?(r=jr(),r!==i?(Ut=e,e={type:"initializer",code:(n=t)[0],codeLocation:n[1],location:Gt()}):(kt=e,e=i)):(kt=e,e=i),e}(),a!==i?n=a:(kt=n,n=i),n===i&&(n=null),s=Tr(),a=[],u=kt,c=sr(),c!==i?(Tr(),u=c):(kt=u,u=i),u!==i)for(;u!==i;)a.push(u),u=kt,c=sr(),c!==i?(Tr(),u=c):(kt=u,u=i);else a=i;return a!==i?(Ut=e,e={type:"grammar",imports:t,topLevelInitializer:r,initializer:n,rules:a,location:Gt()}):(kt=e,e=i),e}function Zt(){let e,t;for(e=[],t=Qt();t!==i;)e.push(t),t=Qt();return e}function Qt(){let e,t,r,n,s,a,u,c;return e=kt,Tr(),o.substr(kt,6)===l?(t=l,kt+=6):(t=i,0===jt&&Xt(ye)),t!==i?(Tr(),r=function(){let e,t,r,n,s;var a,u;return e=er(),e===i&&(e=tr(),e===i&&(e=kt,t=function(){let e,t;var r;return e=kt,t=or(),t!==i&&(Ut=e,t={type:"import_binding_default",binding:(r=t)[0],location:r[1]}),e=t,e}(),t!==i?(r=kt,Tr(),44===o.charCodeAt(kt)?(n=h,kt++):(n=i,0===jt&&Xt(Se)),n!==i?(Tr(),s=er(),s===i&&(s=tr()),s!==i?r=s:(kt=r,r=i)):(kt=r,r=i),r===i&&(r=null),Ut=e,a=t,e=(u=r)?(u.unshift(a),u):[a]):(kt=e,e=i))),e}(),r!==i?(n=Tr(),s=function(){let e,t,r;return e=kt,o.substr(kt,4)===_?(t=_,kt+=4):(t=i,0===jt&&Xt(ve)),t!==i?(Tr(),r=nr(),r!==i?e=r:(kt=e,e=i)):(kt=e,e=i),e}(),s!==i?(a=kt,u=Tr(),59===o.charCodeAt(kt)?(c=p,kt++):(c=i,0===jt&&Xt(be)),c!==i?(u=[u,c],a=u):(kt=a,a=i),a===i&&(a=null),Ut=e,e={type:"grammar_import",what:r,from:s,location:Gt()}):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=kt,Tr(),o.substr(kt,6)===l?(t=l,kt+=6):(t=i,0===jt&&Xt(ye)),t!==i?(Tr(),r=nr(),r!==i?(n=kt,s=Tr(),59===o.charCodeAt(kt)?(a=p,kt++):(a=i,0===jt&&Xt(be)),a!==i?(s=[s,a],n=s):(kt=n,n=i),n===i&&(n=null),Ut=e,e={type:"grammar_import",what:[],from:r,location:Gt()}):(kt=e,e=i)):(kt=e,e=i)),e}function er(){let e,t,r,n;var s;return e=kt,42===o.charCodeAt(kt)?(t=d,kt++):(t=i,0===jt&&Xt(Pe)),t!==i?(Tr(),o.substr(kt,2)===f?(r=f,kt+=2):(r=i,0===jt&&Xt(xe)),r!==i?(Tr(),n=or(),n!==i?(Ut=e,e=[{type:"import_binding_all",binding:(s=n)[0],location:s[1]}]):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e}function tr(){let e,t,r,n,s,a;return e=kt,123===o.charCodeAt(kt)?(t=m,kt++):(t=i,0===jt&&Xt(Ae)),t!==i?(Tr(),125===o.charCodeAt(kt)?(r=g,kt++):(r=i,0===jt&&Xt(Ce)),r!==i?(Ut=e,e=[]):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=kt,123===o.charCodeAt(kt)?(t=m,kt++):(t=i,0===jt&&Xt(Ae)),t!==i?(Tr(),r=function(){let e,t,r,n,s,a,u;for(e=kt,t=[],r=rr();r!==i;)t.push(r),r=kt,n=kt,s=Tr(),44===o.charCodeAt(kt)?(a=h,kt++):(a=i,0===jt&&Xt(Se)),a!==i?(u=Tr(),s=[s,a,u],n=s):(kt=n,n=i),n!==i?(n=rr(),n===i?(kt=r,r=i):r=n):r=n;return t.length<1?(kt=e,e=i):e=t,e}(),r!==i?(Tr(),n=kt,44===o.charCodeAt(kt)?(s=h,kt++):(s=i,0===jt&&Xt(Se)),s!==i?(a=Tr(),s=[s,a],n=s):(kt=n,n=i),n===i&&(n=null),125===o.charCodeAt(kt)?(s=g,kt++):(s=i,0===jt&&Xt(Ce)),s!==i?e=r:(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i)),e}function rr(){let e,t,r,n;var s,a;return e=kt,t=function(){let e,t;return e=Sr(),e===i&&(e=kt,t=xr(),t!==i&&(Ut=e,t=[t,Gt()]),e=t),e}(),t!==i?(Tr(),o.substr(kt,2)===f?(r=f,kt+=2):(r=i,0===jt&&Xt(xe)),r!==i?(Tr(),n=or(),n!==i?(Ut=e,a=n,e={type:"import_binding_rename",rename:(s=t)[0],renameLocation:s[1],binding:a[0],location:a[1]}):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=kt,t=or(),t!==i&&(Ut=e,t=function(e){return{type:"import_binding",binding:e[0],location:e[1]}}(t)),e=t),e}function nr(){let e,t;return e=kt,t=xr(),t!==i&&(Ut=e,t=function(e){return{type:"import_module_specifier",module:e,location:Gt()}}(t)),e=t,e}function or(){let e,t;return e=kt,t=function(){let e,t;var r;return e=kt,t=Sr(),t!==i&&(Ut=e,r=t,Gr.has(r[0])&&Ht(`Binding identifier can't be a reserved word "${r[0]}"`,r[1]),t=r[0]),e=t,e}(),t!==i&&(Ut=e,t=[t,Gt()]),e=t,e}function sr(){let e,t,r,n,s,a;var u,c,l;return e=kt,t=Sr(),t!==i?(Tr(),r=kt,n=xr(),n!==i?(Tr(),r=n):(kt=r,r=i),r===i&&(r=null),61===o.charCodeAt(kt)?(n=R,kt++):(n=i,0===jt&&Xt(Ee)),n!==i?(Tr(),s=ir(),s!==i?(a=jr(),a!==i?(Ut=e,c=r,l=s,e={type:"rule",name:(u=t)[0],nameLocation:u[1],expression:null!==c?{type:"named",name:c,expression:l,location:Gt()}:l,location:Gt()}):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e}function ir(){let e,t,r,n,s,a;if(e=kt,t=ar(),t!==i){for(r=[],n=kt,Tr(),47===o.charCodeAt(kt)?(s=y,kt++):(s=i,0===jt&&Xt($e)),s!==i?(Tr(),a=ar(),a!==i?n=a:(kt=n,n=i)):(kt=n,n=i);n!==i;)r.push(n),n=kt,Tr(),47===o.charCodeAt(kt)?(s=y,kt++):(s=i,0===jt&&Xt($e)),s!==i?(Tr(),a=ar(),a!==i?n=a:(kt=n,n=i)):(kt=n,n=i);Ut=e,u=t,e=(c=r).length>0?{type:"choice",alternatives:[u].concat(c),location:Gt()}:u}else kt=e,e=i;var u,c;return e}function ar(){let e,t,r,n;var o,s;return e=kt,t=function(){let e,t,r,n,o;if(e=kt,t=ur(),t!==i){for(r=[],n=kt,Tr(),o=ur(),o!==i?n=o:(kt=n,n=i);n!==i;)r.push(n),n=kt,Tr(),o=ur(),o!==i?n=o:(kt=n,n=i);Ut=e,s=t,e=(a=r).length>0||"labeled"===s.type&&s.pick?{type:"sequence",elements:[s].concat(a),location:Gt()}:s}else kt=e,e=i;var s,a;return e}(),t!==i?(r=kt,Tr(),n=Nr(),n!==i?r=n:(kt=r,r=i),r===i&&(r=null),Ut=e,o=t,e=null!==(s=r)?{type:"action",expression:o,code:s[0],codeLocation:s[1],location:Gt()}:o):(kt=e,e=i),e}function ur(){let e,t,r,n;var s,a,u;return e=kt,t=function(){let e,t;return e=kt,64===o.charCodeAt(kt)?(t=b,kt++):(t=i,0===jt&&Xt(we)),t!==i&&(Ut=e,t=Gt()),e=t,e}(),t!==i?(r=cr(),r===i&&(r=null),n=lr(),n!==i?(Ut=e,s=t,a=r,(u=n).type.startsWith("semantic_")&&Ht('"@" cannot be used on a semantic predicate',s),e={type:"labeled",label:null!==a?a[0]:null,labelLocation:null!==a?a[1]:s,pick:!0,expression:u,location:Gt()}):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=kt,t=cr(),t!==i?(r=lr(),r!==i?(Ut=e,e=function(e,t){return{type:"labeled",label:e[0],labelLocation:e[1],expression:t,location:Gt()}}(t,r)):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=lr())),e}function cr(){let e,t,r;var n;return e=kt,t=Sr(),t!==i?(Tr(),58===o.charCodeAt(kt)?(r=S,kt++):(r=i,0===jt&&Xt(Le)),r!==i?(Tr(),Ut=e,n=t,Gr.has(n[0])&&Ht(`Label can't be a reserved word "${n[0]}"`,n[1]),e=n):(kt=e,e=i)):(kt=e,e=i),e}function lr(){let t,r,n;return t=kt,r=function(){let e;return e=o.charAt(kt),K.test(e)?kt++:(e=i,0===jt&&Xt(qe)),e}(),r!==i?(Tr(),n=pr(),n!==i?(Ut=t,t={type:e[r],expression:n,location:Gt()}):(kt=t,t=i)):(kt=t,t=i),t===i&&(t=pr()),t}function pr(){let e,r,n;return e=kt,r=dr(),r!==i?(Tr(),n=function(){let e;return e=o.charAt(kt),Z.test(e)?kt++:(e=i,0===jt&&Xt(Ie)),e}(),n!==i?(Ut=e,e={type:t[n],expression:r,location:Gt()}):(kt=e,e=i)):(kt=e,e=i),e===i&&(e=function(){let e,t,r,n,s,a,u;return e=kt,t=dr(),t!==i?(Tr(),124===o.charCodeAt(kt)?(r=P,kt++):(r=i,0===jt&&Xt(Oe)),r!==i?(Tr(),n=function(){let e,t,r,n;var s,a;return e=kt,t=hr(),t===i&&(t=null),Tr(),o.substr(kt,2)===x?(r=x,kt+=2):(r=i,0===jt&&Xt(Fe)),r!==i?(Tr(),n=hr(),n===i&&(n=null),Ut=e,e=[null!==(s=t)?s:{type:"constant",value:0},null!==(a=n)?a:{type:"constant",value:null}]):(kt=e,e=i),e===i&&(e=kt,t=hr(),t!==i&&(Ut=e,t=[null,t]),e=t),e}(),n!==i?(Tr(),s=kt,44===o.charCodeAt(kt)?(a=h,kt++):(a=i,0===jt&&Xt(Se)),a!==i?(Tr(),u=ir(),u!==i?(Tr(),s=u):(kt=s,s=i)):(kt=s,s=i),s===i&&(s=null),124===o.charCodeAt(kt)?(a=P,kt++):(a=i,0===jt&&Xt(Oe)),a!==i?(Ut=e,e=function(e,t,r){const n=t[0],o=t[1];return"constant"===o.type&&0===o.value&&Ht("The maximum count of repetitions of the rule must be > 0",o.location),{type:"repeated",min:n,max:o,expression:e,delimiter:r,location:Gt()}}(t,n,s)):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i)):(kt=e,e=i),e}(),e===i&&(e=dr())),e}function hr(){let e,t;return e=kt,t=functio