UNPKG

smartdown

Version:

A library for translating, rendering and interacting with Smartdown documents. Smartdown is an extension of Markdown that provides richer media support and reactive programming capability.

14 lines (11 loc) 431 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Filament = {})); }(this, (function (exports) { 'use strict'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } var ohm_min = {exports: {}}; (function (module, exports) { !function(u,t){module.exports=t();}(window,(function(){return function(u){var t={};function e(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return u[r].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=u,e.c=t,e.d=function(u,t,r){e.o(u,t)||Object.defineProperty(u,t,{enumerable:!0,get:r});},e.r=function(u){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0});},e.t=function(u,t){if(1&t&&(u=e(u)),8&t)return u;if(4&t&&"object"==typeof u&&u&&u.__esModule)return u;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:u}),2&t&&"string"!=typeof u)for(var n in u)e.d(r,n,function(t){return u[t]}.bind(null,n));return r},e.n=function(u){var t=u&&u.__esModule?function(){return u.default}:function(){return u};return e.d(t,"a",t),t},e.o=function(u,t){return Object.prototype.hasOwnProperty.call(u,t)},e.p="",e(e.s=4)}([function(u,t,e){for(var r=e(7),n={},i=0;i<128;i++)n[i]=String.fromCharCode(i);n["'".charCodeAt(0)]="\\'",n['"'.charCodeAt(0)]='\\"',n["\\".charCodeAt(0)]="\\\\",n["\b".charCodeAt(0)]="\\b",n["\f".charCodeAt(0)]="\\f",n["\n".charCodeAt(0)]="\\n",n["\r".charCodeAt(0)]="\\r",n["\t".charCodeAt(0)]="\\t",n["\v".charCodeAt(0)]="\\v",t.abstract=function(u){var t=u||"";return function(){throw new Error("this method "+t+" is abstract! (it has no implementation in class "+this.constructor.name+")")}},t.assert=function(u,t){if(!u)throw new Error(t)},t.defineLazyProperty=function(u,t,e){var r;Object.defineProperty(u,t,{get:function(){return r||(r=e.call(this)),r}});},t.clone=function(u){return u?r({},u):u},t.extend=r,t.repeatFn=function(u,t){for(var e=[];t-- >0;)e.push(u());return e},t.repeatStr=function(u,t){return new Array(t+1).join(u)},t.repeat=function(u,e){return t.repeatFn((function(){return u}),e)},t.getDuplicates=function(u){for(var t=[],e=0;e<u.length;e++){var r=u[e];u.lastIndexOf(r)!==e&&t.indexOf(r)<0&&t.push(r);}return t},t.copyWithoutDuplicates=function(u){var t=[];return u.forEach((function(u){t.indexOf(u)<0&&t.push(u);})),t},t.isSyntactic=function(u){var t=u[0];return t===t.toUpperCase()},t.isLexical=function(u){return !t.isSyntactic(u)},t.padLeft=function(u,e,r){var n=r||" ";return u.length<e?t.repeatStr(n,e-u.length)+u:u},t.StringBuffer=function(){this.strings=[];},t.StringBuffer.prototype.append=function(u){this.strings.push(u);},t.StringBuffer.prototype.contents=function(){return this.strings.join("")},t.escapeChar=function(u,e){var r=u.charCodeAt(0);return '"'!==u&&"'"!==u||!e||u===e?r<128?n[r]:128<=r&&r<256?"\\x"+t.padLeft(r.toString(16),2,"0"):"\\u"+t.padLeft(r.toString(16),4,"0"):u},t.unescapeChar=function(u){if("\\"!==u.charAt(0))return u;switch(u.charAt(1)){case"b":return "\b";case"f":return "\f";case"n":return "\n";case"r":return "\r";case"t":return "\t";case"v":return "\v";case"x":return String.fromCharCode(parseInt(u.substring(2,4),16));case"u":return String.fromCharCode(parseInt(u.substring(2,6),16));default:return u.charAt(1)}},t.unexpectedObjToString=function(u){if(null==u)return String(u);var t=Object.prototype.toString.call(u);try{return (u.constructor&&u.constructor.name?u.constructor.name:0===t.indexOf("[object ")?t.slice(8,-1):typeof u)+": "+JSON.stringify(String(u))}catch(u){return t}};},function(u,t,e){var r,n=this&&this.__extends||(r=function(u,t){return (r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,t){u.__proto__=t;}||function(u,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(u[e]=t[e]);})(u,t)},function(u,t){function e(){this.constructor=u;}r(u,t),u.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e);}),i=this&&this.__spreadArrays||function(){for(var u=0,t=0,e=arguments.length;t<e;t++)u+=arguments[t].length;var r=Array(u),n=0;for(t=0;t<e;t++)for(var i=arguments[t],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r},o=e(18),a=e(0),s=function(){function u(){if(this.constructor===u)throw new Error("PExpr cannot be instantiated -- it's abstract")}return u.prototype.withSource=function(u){return u&&(this.source=u.trimmed()),this},u}(),c=Object.create(s.prototype),l=Object.create(s.prototype),p=function(u){function t(t){var e=u.call(this)||this;return e.obj=t,e}return n(t,u),t}(s),D=function(u){function t(t,e){var r=u.call(this)||this;return r.from=t,r.to=e,r}return n(t,u),t}(s),h=function(u){function t(t){var e=u.call(this)||this;return e.index=t,e}return n(t,u),t}(s),A=function(u){function t(t){var e=u.call(this)||this;return e.terms=t,e}return n(t,u),t}(s),f=function(u){function t(t,e,r){var n=this,i=t.rules[e].body;return (n=u.call(this,[r,i])||this).superGrammar=t,n.name=e,n.body=r,n}return n(t,u),t}(A),m=function(u){function t(t,e,r,n){var o=this,a=t.rules[e].body;return (o=u.call(this,i(r,[a],n))||this).superGrammar=t,o.ruleName=e,o.expansionPos=r.length,o}return n(t,u),t}(A),E=function(u){function t(t){var e=u.call(this)||this;return e.factors=t,e}return n(t,u),t}(s),C=function(u){function t(t){var e=u.call(this)||this;return e.expr=t,e}return n(t,u),t}(s),F=function(u){function t(){return null!==u&&u.apply(this,arguments)||this}return n(t,u),t}(C),d=function(u){function t(){return null!==u&&u.apply(this,arguments)||this}return n(t,u),t}(C),v=function(u){function t(){return null!==u&&u.apply(this,arguments)||this}return n(t,u),t}(C);F.prototype.operator="*",d.prototype.operator="+",v.prototype.operator="?",F.prototype.minNumMatches=0,d.prototype.minNumMatches=1,v.prototype.minNumMatches=0,F.prototype.maxNumMatches=Number.POSITIVE_INFINITY,d.prototype.maxNumMatches=Number.POSITIVE_INFINITY,v.prototype.maxNumMatches=1;var B=function(u){function t(t){var e=u.call(this)||this;return e.expr=t,e}return n(t,u),t}(s),g=function(u){function t(t){var e=u.call(this)||this;return e.expr=t,e}return n(t,u),t}(s),y=function(u){function t(t){var e=u.call(this)||this;return e.expr=t,e}return n(t,u),t}(s),I=function(u){function t(t,e){void 0===e&&(e=[]);var r=u.call(this)||this;return r.ruleName=t,r.args=e,r}return n(t,u),t.prototype.isSyntactic=function(){return a.isSyntactic(this.ruleName)},t.prototype.toMemoKey=function(){return this._memoKey||Object.defineProperty(this,"_memoKey",{value:this.toString()}),this._memoKey},t}(s),x=function(u){function t(t){var e=u.call(this)||this;return e.category=t,e.pattern=o[t],e}return n(t,u),t}(s);t.PExpr=s,t.any=c,t.end=l,t.Terminal=p,t.Range=D,t.Param=h,t.Alt=A,t.Extend=f,t.Splice=m,t.Seq=E,t.Iter=C,t.Star=F,t.Plus=d,t.Opt=v,t.Not=B,t.Lookahead=g,t.Lex=y,t.Apply=I,t.UnicodeChar=x,e(19),e(20),e(21),e(22),e(23),e(24),e(25),e(26),e(27),e(28),e(29),e(30),e(31),e(32),e(33),e(34);},function(u,t,e){var r=e(1),n=e(12);function i(u,t){var e;return t?((e=new Error(t.getLineAndColumnMessage()+u)).shortMessage=u,e.interval=t):e=new Error(u),e}u.exports={applicationOfSyntacticRuleFromLexicalContext:function(u,t){return i("Cannot apply syntactic rule "+u+" from here (inside a lexical context)",t.source)},cannotExtendUndeclaredRule:function(u,t,e){return i("Cannot extend rule "+u+" because it is not declared in "+t,e)},cannotOverrideUndeclaredRule:function(u,t,e){return i("Cannot override rule "+u+" because it is not declared in "+t,e)},duplicateGrammarDeclaration:function(u,t){return i("Grammar "+u.name+" is already declared in this namespace")},duplicateParameterNames:function(u,t,e){return i("Duplicate parameter names in rule "+u+": "+t.join(", "),e)},duplicatePropertyNames:function(u){return i("Object pattern has duplicate property names: "+u.join(", "))},duplicateRuleDeclaration:function(u,t,e,r){var n="Duplicate declaration for rule '"+u+"' in grammar '"+t+"'";return t!==e&&(n+=" (originally declared in '"+e+"')"),i(n,r)},inconsistentArity:function(u,t,e,r){return i("Rule "+u+" involves an alternation which has inconsistent arity (expected "+t+", got "+e+")",r.source)},incorrectArgumentType:function(u,t){return i("Incorrect argument type: expected "+u,t.source)},intervalSourcesDontMatch:function(){return i("Interval sources don't match")},invalidConstructorCall:function(u,t,e){return i("Attempt to invoke constructor "+t+" with invalid or unexpected arguments")},invalidParameter:function(u,t){return i("Invalid parameter to rule "+u+": "+t+" has arity "+t.getArity()+", but parameter expressions must have arity 1",t.source)},grammarSyntaxError:function(u){var t=new Error;return Object.defineProperty(t,"message",{enumerable:!0,get:function(){return u.message}}),Object.defineProperty(t,"shortMessage",{enumerable:!0,get:function(){return "Expected "+u.getExpectedText()}}),t.interval=u.getInterval(),t},kleeneExprHasNullableOperand:function(u,t){var e=t.length>0?t[t.length-1].args:[],n="Nullable expression "+u.expr.substituteParams(e)+" is not allowed inside '"+u.operator+"' (possible infinite loop)";return t.length>0&&(n+="\nApplication stack (most recent application last):\n"+t.map((function(u){return new r.Apply(u.ruleName,u.args)})).join("\n")),i(n,u.expr.source)},missingSemanticAction:function(u,t,e,r){var n=r.slice(0,-1).map((function(u){var t=" "+u[0].name+" > "+u[1];return 3===u.length?t+" for '"+u[2]+"'":t})).join("\n"),o=i("Missing semantic action for '"+u+"' in "+(e+" '"+t+"'")+"\nAction stack (most recent call last):\n"+(n+="\n "+t+" > "+u));return o.name="missingSemanticAction",o},multipleSuperSplices:function(u){return i("'...' can appear at most once in a rule body",u.source)},undeclaredGrammar:function(u,t,e){return i(t?"Grammar "+u+" is not declared in namespace "+n.toString(t):"Undeclared grammar "+u,e)},undeclaredRule:function(u,t,e){return i("Rule "+u+" is not declared in grammar "+t,e)},wrongNumberOfArguments:function(u,t,e,r){return i("Wrong number of arguments for rule "+u+" (expected "+t+", got "+e+")",r.source)},wrongNumberOfParameters:function(u,t,e,r){return i("Wrong number of parameters for rule "+u+" (expected "+t+", got "+e+")",r)},throwErrors:function(u){if(1===u.length)throw u[0];if(u.length>1)throw function(u){var t=u.map((function(u){return u.message}));return i(["Errors:"].concat(t).join("\n- "),u[0].interval)}(u)}};},function(u,t,e){var r=e(0);function n(u){var t=0;return u.map((function(u){var e=u.toString();return t=Math.max(t,e.length),e})).map((function(u){return r.padLeft(u,t)}))}function i(u,t,e){var r=u.length;return (u.slice(0,e)+t+u.slice(e+t.length)).substr(0,r)}function o(){for(var u=[],t=0;t<arguments.length;t++)u[t]=arguments[t];var e=this,o=e.offset,a=r.repeatStr,s=new r.StringBuffer;s.append("Line "+e.lineNum+", col "+e.colNum+":\n");var c=n([null==e.prevLine?0:e.lineNum-1,e.lineNum,null==e.nextLine?0:e.lineNum+1]),l=function(u,t,e){s.append(e+c[u]+" | "+t+"\n");};null!=e.prevLine&&l(0,e.prevLine," "),l(1,e.line,"> ");for(var p=e.line.length,D=a(" ",p+1),h=0;h<u.length;++h){var A=u[h][0],f=u[h][1];r.assert(A>=0&&A<=f,"range start must be >= 0 and <= end");var m=o-e.colNum+1;A=Math.max(0,A-m),D=i(D,a("~",(f=Math.min(f-m,p))-A),A);}var E=2+c[1].length+3;return s.append(a(" ",E)),D=i(D,"^",e.colNum-1),s.append(D.replace(/ +$/,"")+"\n"),null!=e.nextLine&&l(2,e.nextLine," "),s.contents()}var a,s=[];t.awaitBuiltInRules=function(u){s.push(u);},t.announceBuiltInRules=function(u){s.forEach((function(t){t(u);})),s=null;},t.getLineAndColumn=function(u,t){for(var e=1,r=1,n=0,i=0,a=null,s=null,c=-1;n<t;){var l=u.charAt(n++);"\n"===l?(e++,r=1,c=i,i=n):"\r"!==l&&r++;}var p=u.indexOf("\n",i);if(-1===p)p=u.length;else {var D=u.indexOf("\n",p+1);a=(a=-1===D?u.slice(p):u.slice(p,D)).replace(/^\r?\n/,"").replace(/\r$/,"");}return c>=0&&(s=u.slice(c,i).replace(/\r?\n$/,"")),{offset:t,lineNum:e,colNum:r,line:u.slice(i,p).replace(/\r$/,""),prevLine:s,nextLine:a,toString:o}},t.getLineAndColumnMessage=function(u,e){for(var r,n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return (r=t.getLineAndColumn(u,e)).toString.apply(r,n)},t.uniqueId=(a=0,function(u){return ""+u+a++});},function(u,t,e){var r,n=e(15),i=e(6),o=e(12),a=e(0),s=e(2),c=e(1),l=e(3),p=e(40),D=e(41),h={querySelector:function(u){return document.querySelector(u)},querySelectorAll:function(u){return document.querySelectorAll(u)}},A=Object.create(c.PExpr.prototype);function f(u){return !(!u||1!==u.nodeType)}function m(u){return void 0===u}var E=Math.pow(2,53)-1;function C(u,t,e){var o,l,p,D=new n,h=!1;return (e||r).createSemantics().addOperation("visit",{Grammar:function(u,e,r,n,i){var a=u.visit();o=D.newGrammar(a,t),e.visit(),n.visit();var c=o.build();if(c.source=this.source.trimmed(),a in t)throw s.duplicateGrammarDeclaration(c,t);return t[a]=c,c},SuperGrammar:function(u,e){var r=e.visit();if("null"===r)o.withSuperGrammar(null);else {if(!t||!(r in t))throw s.undeclaredGrammar(r,t,e.source);o.withSuperGrammar(t[r]);}},Rule_define:function(u,t,e,r,n){l=u.visit(),p=t.visit()[0]||[],o.defaultStartRule||o.ensureSuperGrammar()===i.ProtoBuiltInRules||o.withDefaultStartRule(l);var a=n.visit(),s=e.visit()[0],c=this.source.trimmed();return o.define(l,p,a,s,c)},Rule_override:function(u,t,e,r){l=u.visit(),p=t.visit()[0]||[];var n=this.source.trimmed();o.ensureSuperGrammarRuleForOverriding(l,n),h=!0;var i=r.visit();return h=!1,o.override(l,p,i,null,n)},Rule_extend:function(u,t,e,r){l=u.visit(),p=t.visit()[0]||[];var n=r.visit(),i=this.source.trimmed();return o.extend(l,p,n,null,i)},RuleBody:function(u,t){var e=t.visit();return D.alt.apply(D,e).withSource(this.source)},OverrideRuleBody:function(u,t){var e=t.visit(),r=e.indexOf(A);if(r>=0){var n=e.slice(0,r),i=e.slice(r+1);return i.forEach((function(u){if(u===A)throw s.multipleSuperSplices(u)})),new c.Splice(o.superGrammar,l,n,i).withSource(this.source)}return D.alt.apply(D,e).withSource(this.source)},Formals:function(u,t,e){return t.visit()},Params:function(u,t,e){return t.visit()},Alt:function(u){var t=u.visit();return D.alt.apply(D,t).withSource(this.source)},TopLevelTerm_inline:function(u,t){var e=l+"_"+t.visit(),r=u.visit(),n=this.source.trimmed(),i=!(o.superGrammar&&o.superGrammar.rules[e]);h&&!i?o.override(e,p,r,null,n):o.define(e,p,r,null,n);var a=p.map((function(u){return D.app(u)}));return D.app(e,a).withSource(r.source)},OverrideTopLevelTerm_superSplice:function(u){return A},Seq:function(u){return D.seq.apply(D,u.visit()).withSource(this.source)},Iter_star:function(u,t){return D.star(u.visit()).withSource(this.source)},Iter_plus:function(u,t){return D.plus(u.visit()).withSource(this.source)},Iter_opt:function(u,t){return D.opt(u.visit()).withSource(this.source)},Pred_not:function(u,t){return D.not(t.visit()).withSource(this.source)},Pred_lookahead:function(u,t){return D.lookahead(t.visit()).withSource(this.source)},Lex_lex:function(u,t){return D.lex(t.visit()).withSource(this.source)},Base_application:function(u,t){return D.app(u.visit(),t.visit()[0]||[]).withSource(this.source)},Base_range:function(u,t,e){return D.range(u.visit(),e.visit()).withSource(this.source)},Base_terminal:function(u){return D.terminal(u.visit()).withSource(this.source)},Base_paren:function(u,t,e){return t.visit()},ruleDescr:function(u,t,e){return t.visit()},ruleDescrText:function(u){return this.sourceString.trim()},caseName:function(u,t,e,r,n){return e.visit()},name:function(u,t){return this.sourceString},nameFirst:function(u){},nameRest:function(u){},terminal:function(u,t,e){return t.visit().join("")},oneCharTerminal:function(u,t,e){return t.visit()},terminalChar:function(u){return a.unescapeChar(this.sourceString)},escapeChar:function(u){return this.sourceString},NonemptyListOf:function(u,t,e){return [u.visit()].concat(e.visit())},EmptyListOf:function(){return []},_terminal:function(){return this.primitiveValue}})(u).visit()}function F(u){if(!f(u))throw new TypeError("Expected a DOM Node, got "+a.unexpectedObjToString(u));if("text/ohm-js"!==u.type)throw new Error('Expected a script tag with type="text/ohm-js", got '+u);return u.getAttribute("src")?function(u){var t=new XMLHttpRequest;t.open("GET",u,!1);try{if(t.send(),0===t.status||200===t.status)return t.responseText}catch(u){}throw new Error("unable to load url "+u)}(u.getAttribute("src")):u.innerHTML}function d(u,t){var e=v(u,t),r=Object.keys(e);if(0===r.length)throw new Error("Missing grammar definition");if(r.length>1){var n=e[r[1]].source;throw new Error(l.getLineAndColumnMessage(n.sourceString,n.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return e[r[0]]}function v(u,t){var e=o.extend(o.asNamespace(t));if("string"!=typeof u){if(!D(u))throw new TypeError("Expected string as first argument, got "+a.unexpectedObjToString(u));u=u.toString();}return function(u,t){var e=r.match(u,"Grammars");if(e.failed())throw s.grammarSyntaxError(e);C(e,t);}(u,e),e}u.exports={createNamespace:o.createNamespace,grammar:d,grammars:v,grammarFromScriptElement:function(u){var t=u;if(m(t)){var e=h.querySelectorAll('script[type="text/ohm-js"]');if(1!==e.length)throw new Error('Expected exactly one script tag with type="text/ohm-js", found '+e.length);t=e[0];}return d(F(t))},grammarsFromScriptElements:function(u){if(f(u))return v(u);var t=u;if(m(t))t=h.querySelectorAll('script[type="text/ohm-js"]');else if("string"==typeof t||!f(t)&&!function(u){if(null==u)return !1;var t=u.length;return "number"==typeof t&&t>=0&&t<=E}(t))throw new TypeError("Expected a Node, NodeList, or Array, but got "+t);for(var e=o.createNamespace(),r=0;r<t.length;++r)a.extend(e,v(F(t[r]),e));return e},makeRecipe:function(u){return "function"==typeof u?u.call(new n):("string"==typeof u&&(u=JSON.parse(u)),(new n).fromRecipe(u))},ohmGrammar:null,pexprs:c,util:l,extras:e(42),version:p},u.exports._buildGrammar=C,u.exports._setDocumentInterfaceForTesting=function(u){h=u;},i.BuiltInRules=e(44),l.announceBuiltInRules(i.BuiltInRules),u.exports.ohmGrammar=r=e(45),i.initApplicationParser(r,C);},function(u,t,e){var r,n=this&&this.__extends||(r=function(u,t){return (r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,t){u.__proto__=t;}||function(u,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(u[e]=t[e]);})(u,t)},function(u,t){function e(){this.constructor=u;}r(u,t),u.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e);}),i=e(0),o=function(){function u(u,t,e){this.grammar=u,this.ctorName=t,this.matchLength=e;}return u.prototype.numChildren=function(){return this.children?this.children.length:0},u.prototype.childAt=function(u){if(this.children)return this.children[u]},u.prototype.indexOfChild=function(u){return this.children.indexOf(u)},u.prototype.hasChildren=function(){return this.numChildren()>0},u.prototype.hasNoChildren=function(){return !this.hasChildren()},u.prototype.onlyChild=function(){if(1!==this.numChildren())throw new Error("cannot get only child of a node of type "+this.ctorName+" (it has "+this.numChildren()+" children)");return this.firstChild()},u.prototype.firstChild=function(){if(this.hasNoChildren())throw new Error("cannot get first child of a "+this.ctorName+" node, which has no children");return this.childAt(0)},u.prototype.lastChild=function(){if(this.hasNoChildren())throw new Error("cannot get last child of a "+this.ctorName+" node, which has no children");return this.childAt(this.numChildren()-1)},u.prototype.childBefore=function(u){var t=this.indexOfChild(u);if(t<0)throw new Error("Node.childBefore() called w/ an argument that is not a child");if(0===t)throw new Error("cannot get child before first child");return this.childAt(t-1)},u.prototype.childAfter=function(u){var t=this.indexOfChild(u);if(t<0)throw new Error("Node.childAfter() called w/ an argument that is not a child");if(t===this.numChildren()-1)throw new Error("cannot get child after last child");return this.childAt(t+1)},u.prototype.isTerminal=function(){return !1},u.prototype.isNonterminal=function(){return !1},u.prototype.isIteration=function(){return !1},u.prototype.isOptional=function(){return !1},u.prototype.toJSON=function(){var u;return (u={})[this.ctorName]=this.children,u},u}(),a=function(u){function t(t,e){var r=this,n=e?e.length:0;return (r=u.call(this,t,"_terminal",n)||this).primitiveValue=e,r}return n(t,u),t.prototype.isTerminal=function(){return !0},t.prototype.toJSON=function(){var u;return (u={})[this.ctorName]=this.primitiveValue,u},t}(o),s=function(u){function t(t,e,r,n,i){var o=u.call(this,t,e,i)||this;return o.children=r,o.childOffsets=n,o}return n(t,u),t.prototype.isNonterminal=function(){return !0},t.prototype.isLexical=function(){return i.isLexical(this.ctorName)},t.prototype.isSyntactic=function(){return i.isSyntactic(this.ctorName)},t}(o),c=function(u){function t(t,e,r,n,i){var o=u.call(this,t,"_iter",n)||this;return o.children=e,o.childOffsets=r,o.optional=i,o}return n(t,u),t.prototype.isIteration=function(){return !0},t.prototype.isOptional=function(){return this.optional},t}(o);u.exports={Node:o,TerminalNode:a,NonterminalNode:s,IterationNode:c};},function(u,t,e){var r,n,i=e(17),o=e(35),a=e(38),s=e(0),c=e(2),l=e(1);function p(u){return Object.keys(u.rules).sort().map((function(t){return u.rules[t]}))}function D(u,t,e,r){if(this.name=u,this.superGrammar=t,this.rules=e,r){if(!(r in e))throw new Error("Invalid start rule: '"+r+"' is not a rule in grammar '"+u+"'");this.defaultStartRule=r;}}D.initApplicationParser=function(u,t){r=u,n=t;},D.prototype={matcher:function(){return new o(this)},isBuiltIn:function(){return this===D.ProtoBuiltInRules||this===D.BuiltInRules},equals:function(u){if(this===u)return !0;if(null==u||this.name!==u.name||this.defaultStartRule!==u.defaultStartRule||this.superGrammar!==u.superGrammar&&!this.superGrammar.equals(u.superGrammar))return !1;var t=p(this),e=p(u);return t.length===e.length&&t.every((function(u,t){return u.description===e[t].description&&u.formals.join(",")===e[t].formals.join(",")&&u.body.toString()===e[t].body.toString()}))},match:function(u,t){var e=this.matcher();return e.replaceInputRange(0,0,u),e.match(t)},trace:function(u,t){var e=this.matcher();return e.replaceInputRange(0,0,u),e.trace(t)},semantics:function(){throw new Error("semantics() is deprecated -- use createSemantics() instead.")},createSemantics:function(){return a.createSemantics(this)},extendSemantics:function(u){return a.createSemantics(this,u._getSemantics())},_checkTopDownActionDict:function(u,t,e){var r,n=[];for(var i in e){var o=e[i];if("_iter"===(r=i)||"_terminal"===r||"_nonterminal"===r||"_default"===r||i in this.rules)if("function"!=typeof o)n.push("'"+i+"' must be a function in an action dictionary for '"+this.name+"'");else {var a=o.length,s=this._topDownActionArity(i);a!==s&&n.push("Semantic action '"+i+"' has the wrong arity: expected "+s+", got "+a);}else n.push("'"+i+"' is not a valid semantic action for '"+this.name+"'");}if(n.length>0){var c=n.map((function(u){return "- "+u})),l=new Error("Found errors in the action dictionary of the '"+t+"' "+u+":\n"+c.join("\n"));throw l.problems=n,l}},_topDownActionArity:function(u){return "_iter"===u||"_nonterminal"===u||"_default"===u?1:"_terminal"===u?0:this.rules[u].body.getArity()},_inheritsFrom:function(u){for(var t=this.superGrammar;t;){if(t.equals(u,!0))return !0;t=t.superGrammar;}return !1},toRecipe:function(u){var t={};this.source&&(t.source=this.source.contents);var e=null;this.superGrammar&&!this.superGrammar.isBuiltIn()&&(e=JSON.parse(this.superGrammar.toRecipe()));var r=null;this.defaultStartRule&&(r=this.defaultStartRule);var n={},i=this;return Object.keys(this.rules).forEach((function(u){var t,e=i.rules[u],r=e.body,o=!i.superGrammar||!i.superGrammar.rules[u];t=o?"define":r instanceof l.Extend?"extend":"override";var a={};if(e.source&&i.source){var s=e.source.relativeTo(i.source);a.sourceInterval=[s.startIdx,s.endIdx];}var c=o?e.description:null,p=r.outputRecipe(e.formals,i.source);n[u]=[t,a,c,e.formals,p];})),JSON.stringify(["grammar",t,this.name,e,r,n])},toOperationActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},toAttributeActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},_toOperationOrAttributeActionDictionaryTemplate:function(){var u=new s.StringBuffer;u.append("{");var t=!0;for(var e in this.rules){var r=this.rules[e].body;t?t=!1:u.append(","),u.append("\n"),u.append(" "),this.addSemanticActionTemplate(e,r,u);}return u.append("\n}"),u.contents()},addSemanticActionTemplate:function(u,t,e){e.append(u),e.append(": function(");var r=this._topDownActionArity(u);e.append(s.repeat("_",r).join(", ")),e.append(") {\n"),e.append(" }");},parseApplication:function(u){var t;if(-1===u.indexOf("<"))t=new l.Apply(u);else {var e=r.match(u,"Base_application");t=n(e,{});}if(!(t.ruleName in this.rules))throw c.undeclaredRule(t.ruleName,this.name);var i=this.rules[t.ruleName].formals;if(i.length!==t.args.length){var o=this.rules[t.ruleName].source;throw c.wrongNumberOfParameters(t.ruleName,i.length,t.args.length,o)}return t}},D.ProtoBuiltInRules=new D("ProtoBuiltInRules",void 0,{any:{body:l.any,formals:[],description:"any character",primitive:!0},end:{body:l.end,formals:[],description:"end of input",primitive:!0},caseInsensitive:{body:new i(new l.Param(0)),formals:["str"],primitive:!0},lower:{body:new l.UnicodeChar("Ll"),formals:[],description:"a lowercase letter",primitive:!0},upper:{body:new l.UnicodeChar("Lu"),formals:[],description:"an uppercase letter",primitive:!0},unicodeLtmo:{body:new l.UnicodeChar("Ltmo"),formals:[],description:"a Unicode character in Lt, Lm, or Lo",primitive:!0},spaces:{body:new l.Star(new l.Apply("space")),formals:[]},space:{body:new l.Range("\0"," "),formals:[],description:"a space"}}),u.exports=D;},function(u,t){u.exports=function(u,t){if(!t||"object"!=typeof t)return u;var e=Object.keys(t),r=e.length;for(;r--;)u[e[r]]=t[e[r]];return u};},function(u,t,e){var r=e(0).assert,n=e(2),i=e(3);function o(u,t,e){this.sourceString=u,this.startIdx=t,this.endIdx=e;}o.coverage=function(){for(var u=arguments[0].sourceString,t=arguments[0].startIdx,e=arguments[0].endIdx,r=1;r<arguments.length;r++){var i=arguments[r];if(i.sourceString!==u)throw n.intervalSourcesDontMatch();t=Math.min(t,arguments[r].startIdx),e=Math.max(e,arguments[r].endIdx);}return new o(u,t,e)},o.prototype={coverageWith:function(){var u=Array.prototype.slice.call(arguments);return u.push(this),o.coverage.apply(void 0,u)},collapsedLeft:function(){return new o(this.sourceString,this.startIdx,this.startIdx)},collapsedRight:function(){return new o(this.sourceString,this.endIdx,this.endIdx)},getLineAndColumn:function(){return i.getLineAndColumn(this.sourceString,this.startIdx)},getLineAndColumnMessage:function(){var u=[this.startIdx,this.endIdx];return i.getLineAndColumnMessage(this.sourceString,this.startIdx,u)},minus:function(u){if(this.sourceString!==u.sourceString)throw n.intervalSourcesDontMatch();return this.startIdx===u.startIdx&&this.endIdx===u.endIdx?[]:this.startIdx<u.startIdx&&u.endIdx<this.endIdx?[new o(this.sourceString,this.startIdx,u.startIdx),new o(this.sourceString,u.endIdx,this.endIdx)]:this.startIdx<u.endIdx&&u.endIdx<this.endIdx?[new o(this.sourceString,u.endIdx,this.endIdx)]:this.startIdx<u.startIdx&&u.startIdx<this.endIdx?[new o(this.sourceString,this.startIdx,u.startIdx)]:[this]},relativeTo:function(u){if(this.sourceString!==u.sourceString)throw n.intervalSourcesDontMatch();return r(this.startIdx>=u.startIdx&&this.endIdx<=u.endIdx,"other interval does not cover this one"),new o(this.sourceString,this.startIdx-u.startIdx,this.endIdx-u.startIdx)},trimmed:function(){var u=this.contents,t=this.startIdx+u.match(/^\s*/)[0].length,e=this.endIdx-u.match(/\s*$/)[0].length;return new o(this.sourceString,t,e)},subInterval:function(u,t){var e=this.startIdx+u;return new o(this.sourceString,e,e+t)}},Object.defineProperties(o.prototype,{contents:{get:function(){return void 0===this._contents&&(this._contents=this.sourceString.slice(this.startIdx,this.endIdx)),this._contents},enumerable:!0},length:{get:function(){return this.endIdx-this.startIdx},enumerable:!0}}),u.exports=o;},function(u,t,e){var r=e(8);function n(u){this.source=u,this.pos=0,this.examinedLength=0;}n.prototype={atEnd:function(){var u=this.pos===this.source.length;return this.examinedLength=Math.max(this.examinedLength,this.pos+1),u},next:function(){var u=this.source[this.pos++];return this.examinedLength=Math.max(this.examinedLength,this.pos),u},matchString:function(u,t){var e;if(t){for(e=0;e<u.length;e++){var r=this.next(),n=u[e];if(null==r||r.toUpperCase()!==n.toUpperCase())return !1}return !0}for(e=0;e<u.length;e++)if(this.next()!==u[e])return !1;return !0},sourceSlice:function(u,t){return this.source.slice(u,t)},interval:function(u,t){return new r(this.source,u,t||this.pos)}},u.exports=n;},function(u,t,e){var r=e(0),n=e(3),i=e(8);function o(u,t,e,i,o,a,s){this.matcher=u,this.input=t,this.startExpr=e,this._cst=i,this._cstOffset=o,this._rightmostFailurePosition=a,this._rightmostFailures=s,this.failed()&&(r.defineLazyProperty(this,"message",(function(){var u="Expected "+this.getExpectedText();return n.getLineAndColumnMessage(this.input,this.getRightmostFailurePosition())+u})),r.defineLazyProperty(this,"shortMessage",(function(){var u="expected "+this.getExpectedText(),t=n.getLineAndColumn(this.input,this.getRightmostFailurePosition());return "Line "+t.lineNum+", col "+t.colNum+": "+u})));}o.prototype.succeeded=function(){return !!this._cst},o.prototype.failed=function(){return !this.succeeded()},o.prototype.getRightmostFailurePosition=function(){return this._rightmostFailurePosition},o.prototype.getRightmostFailures=function(){if(!this._rightmostFailures){this.matcher.setInput(this.input);var u=this.matcher._match(this.startExpr,!1,this.getRightmostFailurePosition());this._rightmostFailures=u.getRightmostFailures();}return this._rightmostFailures},o.prototype.toString=function(){return this.succeeded()?"[match succeeded]":"[match failed at position "+this.getRightmostFailurePosition()+"]"},o.prototype.getExpectedText=function(){if(this.succeeded())throw new Error("cannot get expected text of a successful MatchResult");var u=new r.StringBuffer,t=this.getRightmostFailures();t=t.filter((function(u){return !u.isFluffy()}));for(var e=0;e<t.length;e++)e>0&&(e===t.length-1?u.append(t.length>2?", or ":" or "):u.append(", ")),u.append(t[e].toString());return u.contents()},o.prototype.getInterval=function(){var u=this.getRightmostFailurePosition();return new i(this.input,u,u)},u.exports=o;},function(u,t,e){function r(u,t,e){if(!function(u){return "description"===u||"string"===u||"code"===u}(e))throw new Error("invalid Failure type: "+e);this.pexpr=u,this.text=t,this.type=e,this.fluffy=!1;}r.prototype.getPExpr=function(){return this.pexpr},r.prototype.getText=function(){return this.text},r.prototype.getType=function(){return this.type},r.prototype.isDescription=function(){return "description"===this.type},r.prototype.isStringTerminal=function(){return "string"===this.type},r.prototype.isCode=function(){return "code"===this.type},r.prototype.isFluffy=function(){return this.fluffy},r.prototype.makeFluffy=function(){this.fluffy=!0;},r.prototype.clearFluffy=function(){this.fluffy=!1;},r.prototype.subsumes=function(u){return this.getText()===u.getText()&&this.type===u.type&&(!this.isFluffy()||this.isFluffy()&&u.isFluffy())},r.prototype.toString=function(){return "string"===this.type?JSON.stringify(this.getText()):this.getText()},r.prototype.clone=function(){var u=new r(this.pexpr,this.text,this.type);return this.isFluffy()&&u.makeFluffy(),u},r.prototype.toKey=function(){return this.toString()+"#"+this.type},u.exports=r;},function(u,t,e){var r=e(7);function n(){}n.prototype=Object.create(null),n.asNamespace=function(u){return u instanceof n?u:n.createNamespace(u)},n.createNamespace=function(u){return n.extend(n.prototype,u)},n.extend=function(u,t){if(u!==n.prototype&&!(u instanceof n))throw new TypeError("not a Namespace object: "+u);var e=Object.create(u,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}});return r(e,t)},n.toString=function(u){return Object.prototype.toString.call(u)},u.exports=n;},function(u,t,e){var r=e(8),n=e(0),i={succeeded:1,isRootNode:2,isImplicitSpaces:4,isMemoized:8,isHeadOfLeftRecursion:16,terminatesLR:32};function o(u){return "string"==typeof u?u.replace(/ /g,"⋅").replace(/\t/g,"␉").replace(/\n/g,"␊").replace(/\r/g,"␍"):String(u)}function a(u,t,e,n,o,a,s){this.input=u,this.pos=this.pos1=t,this.pos2=e,this.source=new r(u,t,e),this.expr=n,this.bindings=a,this.children=s||[],this.terminatingLREntry=null,this._flags=o?i.succeeded:0;}a.prototype.SKIP={},Object.defineProperty(a.prototype,"displayString",{get:function(){return this.expr.toDisplayString()}}),Object.keys(i).forEach((function(u){var t=i[u];Object.defineProperty(a.prototype,u,{get:function(){return 0!=(this._flags&t)},set:function(u){u?this._flags|=t:this._flags&=~t;}});})),a.prototype.clone=function(){return this.cloneWithExpr(this.expr)},a.prototype.cloneWithExpr=function(u){var t=new a(this.input,this.pos,this.pos2,u,this.succeeded,this.bindings,this.children);return t.isHeadOfLeftRecursion=this.isHeadOfLeftRecursion,t.isImplicitSpaces=this.isImplicitSpaces,t.isMemoized=this.isMemoized,t.isRootNode=this.isRootNode,t.terminatesLR=this.terminatesLR,t.terminatingLREntry=this.terminatingLREntry,t},a.prototype.recordLRTermination=function(u,t){this.terminatingLREntry=new a(this.input,this.pos,this.pos2,this.expr,!1,[t],[u]),this.terminatingLREntry.terminatesLR=!0;},a.prototype.walk=function(u,t){var e=u;function r(u,n,i){var o=!0;e.enter&&e.enter.call(t,u,n,i)===a.prototype.SKIP&&(o=!1),o&&(u.children.forEach((function(t){r(t,u,i+1);})),e.exit&&e.exit.call(t,u,n,i));}"function"==typeof e&&(e={enter:e}),this.isRootNode?this.children.forEach((function(u){r(u,null,0);})):r(this,null,0);},a.prototype.toString=function(){var u=this,t=new n.StringBuffer;return this.walk((function(e,r,i){if(!e)return u.SKIP;if("Alt"!==e.expr.constructor.name){var a,s,c,l,p;if(t.append((s=e.input,c=e.pos,l=10,((p=o(s.slice(c,c+l))).length<l?p+n.repeat(" ",l-p.length).join(""):p)+(a=2*i+1,n.repeat(" ",a).join("")))),t.append((e.succeeded?"✓":"✗")+" "+e.displayString),e.isHeadOfLeftRecursion&&t.append(" (LR)"),e.succeeded){var D=o(e.source.contents);t.append(" ⇒ "),t.append("string"==typeof D?'"'+D+'"':D);}t.append("\n");}})),t.contents()},u.exports=a;},function(u,t,e){var r=e(1),n=e(10),i=e(6),o=e(7),a={_terminal:function(){return this.primitiveValue},_nonterminal:function(u){var t=this._node.ctorName,e=this.args.mapping;if(!e.hasOwnProperty(t)){if(this._node instanceof r.Alt||this._node instanceof r.Apply)return u[0].toAST(e);if(this.isLexical())return this.sourceString;var n=u.filter((function(u){return !u.isTerminal()}));if(1===n.length)return n[0].toAST(e)}if("number"==typeof e[t])return u[e[t]].toAST(e);var i=e[t]||u,o={type:t};for(var a in i){var s=e[t]&&e[t][a];"number"==typeof s?o[a]=u[s].toAST(e):"string"==typeof s||"boolean"==typeof s||null===s?o[a]=s:"object"==typeof s&&s instanceof Number?o[a]=Number(s):"function"==typeof s?o[a]=s.call(this,u):void 0===s&&(u[a]&&!u[a].isTerminal()?o[a]=u[a].toAST(e):delete o[a]);}return o},_iter:function(u){return this._node.isOptional()?0===this.numChildren?null:u[0].toAST(this.args.mapping):u.map((function(u){return u.toAST(this.args.mapping)}),this)},NonemptyListOf:function(u,t,e){return [u.toAST(this.args.mapping)].concat(e.toAST(this.args.mapping))},EmptyListOf:function(){return []}};u.exports={helper:function(u,t){if(!(u instanceof n)||u.failed())throw new Error("toAST() expects a succesfull MatchResult as first parameter");t=o({},t);var e=o({},a);for(var r in t)"function"==typeof t[r]&&(e[r]=t[r],delete t[r]);return u._cst.grammar.createSemantics().addOperation("toAST(mapping)",e)(u).toAST(t)},semantics:function(u){if(!(u instanceof i))throw new Error("semanticsToAST() expects a Grammar as parameter");return u.createSemantics().addOperation("toAST(mapping)",a)}};},function(u,t,e){var r=e(16),n=e(1);function i(){}i.prototype={currentDecl:null,currentRuleName:null,newGrammar:function(u){return new r(u)},grammar:function(u,t,e,n,i){var o=this,a=new r(t);return e&&a.withSuperGrammar(this.fromRecipe(e)),n&&a.withDefaultStartRule(n),u&&u.source&&a.withSource(u.source),this.currentDecl=a,Object.keys(i).forEach((function(u){o.currentRuleName=u;var t,e=i[u],r=e[0],n=e[1],s=e[2],c=e[3],l=o.fromRecipe(e[4]);a.source&&n&&n.sourceInterval&&(t=a.source.subInterval(n.sourceInterval[0],n.sourceInterval[1]-n.sourceInterval[0])),a[r](u,c,l,s,t);})),this.currentRuleName=this.currentDecl=null,a.build()},terminal:function(u){return new n.Terminal(u)},range:function(u,t){return new n.Range(u,t)},param:function(u){return new n.Param(u)},alt:function(){for(var u=[],t=0;t<arguments.length;t++){var e=arguments[t];e instanceof n.PExpr||(e=this.fromRecipe(e)),e instanceof n.Alt?u=u.concat(e.terms):u.push(e);}return 1===u.length?u[0]:new n.Alt(u)},seq:function(){for(var u=[],t=0;t<arguments.length;t++){var e=arguments[t];e instanceof n.PExpr||(e=this.fromRecipe(e)),e instanceof n.Seq?u=u.concat(e.factors):u.push(e);}return 1===u.length?u[0]:new n.Seq(u)},star:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Star(u)},plus:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Plus(u)},opt:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Opt(u)},not:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Not(u)},la:function(u){return this.lookahead(u)},lookahead:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Lookahead(u)},lex:function(u){return u instanceof n.PExpr||(u=this.fromRecipe(u)),new n.Lex(u)},app:function(u,t){return t&&t.length>0&&(t=t.map((function(u){return u instanceof n.PExpr?u:this.fromRecipe(u)}),this)),new n.Apply(u,t)},splice:function(u,t){var e=this;return new n.Splice(this.currentDecl.superGrammar,this.currentRuleName,u.map((function(u){return e.fromRecipe(u)})),t.map((function(u){return e.fromRecipe(u)})))},fromRecipe:function(u){var t=this[u[0]].apply(this,"grammar"===u[0]?u.slice(1):u.slice(2)),e=u[1];return e&&e.sourceInterval&&this.currentDecl&&t.withSource(this.currentDecl.sourceInterval.apply(this.currentDecl,e.sourceInterval)),t}},u.exports=i;},function(u,t,e){var r=e(6),n=e(9),i=e(0),o=e(2),a=e(1);function s(u){this.name=u;}s.prototype.sourceInterval=function(u,t){return this.source.subInterval(u,t-u)},s.prototype.ensureSuperGrammar=function(){return this.superGrammar||this.withSuperGrammar("BuiltInRules"===this.name?r.ProtoBuiltInRules:r.BuiltInRules),this.superGrammar},s.prototype.ensureSuperGrammarRuleForOverriding=function(u,t){var e=this.ensureSuperGrammar().rules[u];if(!e)throw o.cannotOverrideUndeclaredRule(u,this.superGrammar.name,t);return e},s.prototype.installOverriddenOrExtendedRule=function(u,t,e,r){var n=i.getDuplicates(t);if(n.length>0)throw o.duplicateParameterNames(u,n,r);var a=this.ensureSuperGrammar().rules[u],s=a.formals,c=s?s.length:0;if(t.length!==c)throw o.wrongNumberOfParameters(u,c,t.length,r);return this.install(u,t,e,a.description,r)},s.prototype.install=function(u,t,e,r,n){return this.rules[u]={body:e.introduceParams(t),formals:t,description:r,source:n},this},s.prototype.withSuperGrammar=function(u){if(this.superGrammar)throw new Error("the super grammar of a GrammarDecl cannot be set more than once");return this.superGrammar=u,this.rules=Object.create(u.rules),u.isBuiltIn()||(this.defaultStartRule=u.defaultStartRule),this},s.prototype.withDefaultStartRule=function(u){return this.defaultStartRule=u,this},s.prototype.withSource=function(u){return this.source=new n(u).interval(0,u.length),this},s.prototype.build=function(){var u=new r(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule),t=[],e=!1;return Object.keys(u.rules).forEach((function(r){var n=u.rules[r].body;try{n.assertChoicesHaveUniformArity(r);}catch(u){t.push(u);}try{n.assertAllApplicationsAreValid(r,u);}catch(u){t.push(u),e=!0;}})),e||Object.keys(u.rules).forEach((function(e){var r=u.rules[e].body;try{r.assertIteratedExprsAreNotNullable(u,[]);}catch(u){t.push(u);}})),t.length>0&&o.throwErrors(t),this.source&&(u.source=this.source),u},s.prototype.define=function(u,t,e,r,n){if(this.ensureSuperGrammar(),this.superGrammar.rules[u])throw o.duplicateRuleDeclaration(u,this.name,this.superGrammar.name,n);if(this.rules[u])throw o.duplicateRuleDeclaration(u,this.name,this.name,n);var a=i.getDuplicates(t);if(a.length>0)throw o.duplicateParameterNames(u,a,n);return this.install(u,t,e,r,n)},s.prototype.override=function(u,t,e,r,n){return this.ensureSuperGrammarRuleForOverriding(u,n),this.installOverriddenOrExtendedRule(u,t,e,n),this},s.prototype.extend=function(u,t,e,r,n){if(!this.ensureSuperGrammar().rules[u])throw o.cannotExtendUndeclaredRule(u,this.superGrammar.name,n);var i=new a.Extend(this.superGrammar,u,e);return i.source=e.source,this.installOverriddenOrExtendedRule(u,t,i,n),this},u.exports=s;},function(u,t,e){var r,n=this&&this.__extends||(r=function(u,t){return (r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,t){u.__proto__=t;}||function(u,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(u[e]=t[e]);})(u,t)},function(u,t){function e(){this.constructor=u;}r(u,t),u.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e);}),i=e(11),o=e(5).TerminalNode,a=e(0).assert,s=e(1),c=s.PExpr,l=s.Terminal,p=function(u){function t(t){var e=u.call(this)||this;return e.obj=t,e}return n(t,u),t.prototype._getString=function(u){var t=u.currentApplication().args[this.obj.index];return a(t instanceof l,"expected a Terminal expression"),t.obj},t.prototype.allowsSkippingPrecedingSpace=function(){return !0},t.prototype.eval=function(u){var t=u.inputStream,e=t.pos,r=this._getString(u);return t.matchString(r,!0)?(u.pushBinding(new o(u.grammar,r),e),!0):(u.processFailure(e,this),!1)},t.prototype.generateExample=function(u,t,e,r){for(var n=this.obj.generateExample(u,t,e,r).value,i="",o=0;o<n.length;++o)i+=Math.random()<.5?n[o].toLocaleLowerCase():n[o].toLocaleUpperCase();return {value:i}},t.prototype.getArity=function(){return 1},t.prototype.substituteParams=function(u){return new t(this.obj.substituteParams(u))},t.prototype.toDisplayString=function(){return this.obj.toDisplayString()+" (case-insensitive)"},t.prototype.toFailure=function(u){return new i(this,this.obj.toFailure(u)+" (case-insensitive)","description")},t.prototype._isNullable=function(u,t){return this.obj._isNullable(u,t)},t}(c);u.exports=p;},function(u,t){u.exports={Lu:/[A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AE\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A]|\uD801[\uDC00-\uDC27\uDCB0-\uDCD3]|\uD803[\uDC80-\uDCB2]|\uD806[\uDCA0-\uDCBF]|\uD835[\uDC00-\uDC19\uDC34-\uDC4D\uDC68-\uDC81\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB5\uDCD0-\uDCE9\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD38\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD6C-\uDD85\uDDA0-\uDDB9\uDDD4-\uDDED\uDE08-\uDE21\uDE3C-\uDE55\uDE70-\uDE89\uDEA8-\uDEC0\uDEE2-\uDEFA\uDF1C-\uDF34\uDF56-\uDF6E\uDF90-\uDFA8\uDFCA]|\uD83A[\uDD00-\uDD21]/,Ll:/[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F3