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.
2 lines • 230 kB
JavaScript
/*! For license information please see filament.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Filament={})}(this,(function(t){"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var u={exports:{}};!function(t,e){window,t.exports=function(t){var e={};function u(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,u),n.l=!0,n.exports}return u.m=t,u.c=e,u.d=function(t,e,r){u.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},u.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},u.t=function(t,e){if(1&e&&(t=u(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(u.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)u.d(r,n,function(e){return t[e]}.bind(null,n));return r},u.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return u.d(e,"a",e),e},u.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},u.p="",u(u.s=4)}([function(t,e,u){for(var r=u(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",e.abstract=function(t){var e=t||"";return function(){throw new Error("this method "+e+" is abstract! (it has no implementation in class "+this.constructor.name+")")}},e.assert=function(t,e){if(!t)throw new Error(e)},e.defineLazyProperty=function(t,e,u){var r;Object.defineProperty(t,e,{get:function(){return r||(r=u.call(this)),r}})},e.clone=function(t){return t?r({},t):t},e.extend=r,e.repeatFn=function(t,e){for(var u=[];e-- >0;)u.push(t());return u},e.repeatStr=function(t,e){return new Array(e+1).join(t)},e.repeat=function(t,u){return e.repeatFn((function(){return t}),u)},e.getDuplicates=function(t){for(var e=[],u=0;u<t.length;u++){var r=t[u];t.lastIndexOf(r)!==u&&e.indexOf(r)<0&&e.push(r)}return e},e.copyWithoutDuplicates=function(t){var e=[];return t.forEach((function(t){e.indexOf(t)<0&&e.push(t)})),e},e.isSyntactic=function(t){var e=t[0];return e===e.toUpperCase()},e.isLexical=function(t){return!e.isSyntactic(t)},e.padLeft=function(t,u,r){var n=r||" ";return t.length<u?e.repeatStr(n,u-t.length)+t:t},e.StringBuffer=function(){this.strings=[]},e.StringBuffer.prototype.append=function(t){this.strings.push(t)},e.StringBuffer.prototype.contents=function(){return this.strings.join("")},e.escapeChar=function(t,u){var r=t.charCodeAt(0);return'"'!==t&&"'"!==t||!u||t===u?r<128?n[r]:128<=r&&r<256?"\\x"+e.padLeft(r.toString(16),2,"0"):"\\u"+e.padLeft(r.toString(16),4,"0"):t},e.unescapeChar=function(t){if("\\"!==t.charAt(0))return t;switch(t.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(t.substring(2,4),16));case"u":return String.fromCharCode(parseInt(t.substring(2,6),16));default:return t.charAt(1)}},e.unexpectedObjToString=function(t){if(null==t)return String(t);var e=Object.prototype.toString.call(t);try{return(t.constructor&&t.constructor.name?t.constructor.name:0===e.indexOf("[object ")?e.slice(8,-1):typeof t)+": "+JSON.stringify(String(t))}catch(t){return e}}},function(t,e,u){var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u])})(t,e)},function(t,e){function u(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(u.prototype=e.prototype,new u)}),i=this&&this.__spreadArrays||function(){for(var t=0,e=0,u=arguments.length;e<u;e++)t+=arguments[e].length;var r=Array(t),n=0;for(e=0;e<u;e++)for(var i=arguments[e],a=0,o=i.length;a<o;a++,n++)r[n]=i[a];return r},a=u(18),o=u(0),s=function(){function t(){if(this.constructor===t)throw new Error("PExpr cannot be instantiated -- it's abstract")}return t.prototype.withSource=function(t){return t&&(this.source=t.trimmed()),this},t}(),c=Object.create(s.prototype),l=Object.create(s.prototype),p=function(t){function e(e){var u=t.call(this)||this;return u.obj=e,u}return n(e,t),e}(s),h=function(t){function e(e,u){var r=t.call(this)||this;return r.from=e,r.to=u,r}return n(e,t),e}(s),f=function(t){function e(e){var u=t.call(this)||this;return u.index=e,u}return n(e,t),e}(s),D=function(t){function e(e){var u=t.call(this)||this;return u.terms=e,u}return n(e,t),e}(s),m=function(t){function e(e,u,r){var n=this,i=e.rules[u].body;return(n=t.call(this,[r,i])||this).superGrammar=e,n.name=u,n.body=r,n}return n(e,t),e}(D),d=function(t){function e(e,u,r,n){var a=this,o=e.rules[u].body;return(a=t.call(this,i(r,[o],n))||this).superGrammar=e,a.ruleName=u,a.expansionPos=r.length,a}return n(e,t),e}(D),A=function(t){function e(e){var u=t.call(this)||this;return u.factors=e,u}return n(e,t),e}(s),E=function(t){function e(e){var u=t.call(this)||this;return u.expr=e,u}return n(e,t),e}(s),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(E),g=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(E),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(E);C.prototype.operator="*",g.prototype.operator="+",v.prototype.operator="?",C.prototype.minNumMatches=0,g.prototype.minNumMatches=1,v.prototype.minNumMatches=0,C.prototype.maxNumMatches=Number.POSITIVE_INFINITY,g.prototype.maxNumMatches=Number.POSITIVE_INFINITY,v.prototype.maxNumMatches=1;var F=function(t){function e(e){var u=t.call(this)||this;return u.expr=e,u}return n(e,t),e}(s),y=function(t){function e(e){var u=t.call(this)||this;return u.expr=e,u}return n(e,t),e}(s),w=function(t){function e(e){var u=t.call(this)||this;return u.expr=e,u}return n(e,t),e}(s),x=function(t){function e(e,u){void 0===u&&(u=[]);var r=t.call(this)||this;return r.ruleName=e,r.args=u,r}return n(e,t),e.prototype.isSyntactic=function(){return o.isSyntactic(this.ruleName)},e.prototype.toMemoKey=function(){return this._memoKey||Object.defineProperty(this,"_memoKey",{value:this.toString()}),this._memoKey},e}(s),B=function(t){function e(e){var u=t.call(this)||this;return u.category=e,u.pattern=a[e],u}return n(e,t),e}(s);e.PExpr=s,e.any=c,e.end=l,e.Terminal=p,e.Range=h,e.Param=f,e.Alt=D,e.Extend=m,e.Splice=d,e.Seq=A,e.Iter=E,e.Star=C,e.Plus=g,e.Opt=v,e.Not=F,e.Lookahead=y,e.Lex=w,e.Apply=x,e.UnicodeChar=B,u(19),u(20),u(21),u(22),u(23),u(24),u(25),u(26),u(27),u(28),u(29),u(30),u(31),u(32),u(33),u(34)},function(t,e,u){var r=u(1),n=u(12);function i(t,e){var u;return e?((u=new Error(e.getLineAndColumnMessage()+t)).shortMessage=t,u.interval=e):u=new Error(t),u}t.exports={applicationOfSyntacticRuleFromLexicalContext:function(t,e){return i("Cannot apply syntactic rule "+t+" from here (inside a lexical context)",e.source)},cannotExtendUndeclaredRule:function(t,e,u){return i("Cannot extend rule "+t+" because it is not declared in "+e,u)},cannotOverrideUndeclaredRule:function(t,e,u){return i("Cannot override rule "+t+" because it is not declared in "+e,u)},duplicateGrammarDeclaration:function(t,e){return i("Grammar "+t.name+" is already declared in this namespace")},duplicateParameterNames:function(t,e,u){return i("Duplicate parameter names in rule "+t+": "+e.join(", "),u)},duplicatePropertyNames:function(t){return i("Object pattern has duplicate property names: "+t.join(", "))},duplicateRuleDeclaration:function(t,e,u,r){var n="Duplicate declaration for rule '"+t+"' in grammar '"+e+"'";return e!==u&&(n+=" (originally declared in '"+u+"')"),i(n,r)},inconsistentArity:function(t,e,u,r){return i("Rule "+t+" involves an alternation which has inconsistent arity (expected "+e+", got "+u+")",r.source)},incorrectArgumentType:function(t,e){return i("Incorrect argument type: expected "+t,e.source)},intervalSourcesDontMatch:function(){return i("Interval sources don't match")},invalidConstructorCall:function(t,e,u){return i("Attempt to invoke constructor "+e+" with invalid or unexpected arguments")},invalidParameter:function(t,e){return i("Invalid parameter to rule "+t+": "+e+" has arity "+e.getArity()+", but parameter expressions must have arity 1",e.source)},grammarSyntaxError:function(t){var e=new Error;return Object.defineProperty(e,"message",{enumerable:!0,get:function(){return t.message}}),Object.defineProperty(e,"shortMessage",{enumerable:!0,get:function(){return"Expected "+t.getExpectedText()}}),e.interval=t.getInterval(),e},kleeneExprHasNullableOperand:function(t,e){var u=e.length>0?e[e.length-1].args:[],n="Nullable expression "+t.expr.substituteParams(u)+" is not allowed inside '"+t.operator+"' (possible infinite loop)";return e.length>0&&(n+="\nApplication stack (most recent application last):\n"+e.map((function(t){return new r.Apply(t.ruleName,t.args)})).join("\n")),i(n,t.expr.source)},missingSemanticAction:function(t,e,u,r){var n=r.slice(0,-1).map((function(t){var e=" "+t[0].name+" > "+t[1];return 3===t.length?e+" for '"+t[2]+"'":e})).join("\n"),a=i("Missing semantic action for '"+t+"' in "+u+" '"+e+"'\nAction stack (most recent call last):\n"+(n+="\n "+e+" > "+t));return a.name="missingSemanticAction",a},multipleSuperSplices:function(t){return i("'...' can appear at most once in a rule body",t.source)},undeclaredGrammar:function(t,e,u){return i(e?"Grammar "+t+" is not declared in namespace "+n.toString(e):"Undeclared grammar "+t,u)},undeclaredRule:function(t,e,u){return i("Rule "+t+" is not declared in grammar "+e,u)},wrongNumberOfArguments:function(t,e,u,r){return i("Wrong number of arguments for rule "+t+" (expected "+e+", got "+u+")",r.source)},wrongNumberOfParameters:function(t,e,u,r){return i("Wrong number of parameters for rule "+t+" (expected "+e+", got "+u+")",r)},throwErrors:function(t){if(1===t.length)throw t[0];if(t.length>1)throw function(t){var e=t.map((function(t){return t.message}));return i(["Errors:"].concat(e).join("\n- "),t[0].interval)}(t)}}},function(t,e,u){var r=u(0);function n(t,e,u){var r=t.length;return(t.slice(0,u)+e+t.slice(u+e.length)).substr(0,r)}function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var u=this,i=u.offset,a=r.repeatStr,o=new r.StringBuffer;o.append("Line "+u.lineNum+", col "+u.colNum+":\n");var s=function(t){var e=0;return t.map((function(t){var u=t.toString();return e=Math.max(e,u.length),u})).map((function(t){return r.padLeft(t,e)}))}([null==u.prevLine?0:u.lineNum-1,u.lineNum,null==u.nextLine?0:u.lineNum+1]),c=function(t,e,u){o.append(u+s[t]+" | "+e+"\n")};null!=u.prevLine&&c(0,u.prevLine," "),c(1,u.line,"> ");for(var l=u.line.length,p=a(" ",l+1),h=0;h<t.length;++h){var f=t[h][0],D=t[h][1];r.assert(f>=0&&f<=D,"range start must be >= 0 and <= end");var m=i-u.colNum+1;f=Math.max(0,f-m),p=n(p,a("~",(D=Math.min(D-m,l))-f),f)}var d=2+s[1].length+3;return o.append(a(" ",d)),p=n(p,"^",u.colNum-1),o.append(p.replace(/ +$/,"")+"\n"),null!=u.nextLine&&c(2,u.nextLine," "),o.contents()}var a,o=[];e.awaitBuiltInRules=function(t){o.push(t)},e.announceBuiltInRules=function(t){o.forEach((function(e){e(t)})),o=null},e.getLineAndColumn=function(t,e){for(var u=1,r=1,n=0,a=0,o=null,s=null,c=-1;n<e;){var l=t.charAt(n++);"\n"===l?(u++,r=1,c=a,a=n):"\r"!==l&&r++}var p=t.indexOf("\n",a);if(-1===p)p=t.length;else{var h=t.indexOf("\n",p+1);o=(o=-1===h?t.slice(p):t.slice(p,h)).replace(/^\r?\n/,"").replace(/\r$/,"")}return c>=0&&(s=t.slice(c,a).replace(/\r?\n$/,"")),{offset:e,lineNum:u,colNum:r,line:t.slice(a,p).replace(/\r$/,""),prevLine:s,nextLine:o,toString:i}},e.getLineAndColumnMessage=function(t,u){for(var r,n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return(r=e.getLineAndColumn(t,u)).toString.apply(r,n)},e.uniqueId=(a=0,function(t){return""+t+a++})},function(t,e,u){var r,n=u(15),i=u(6),a=u(12),o=u(0),s=u(2),c=u(1),l=u(3),p=u(40),h=u(41),f={querySelector:function(t){return document.querySelector(t)},querySelectorAll:function(t){return document.querySelectorAll(t)}},D=Object.create(c.PExpr.prototype);function m(t){return!(!t||1!==t.nodeType)}function d(t){return void 0===t}var A=Math.pow(2,53)-1;function E(t,e,u){var a,l,p,h=new n,f=!1;return(u||r).createSemantics().addOperation("visit",{Grammar:function(t,u,r,n,i){var o=t.visit();a=h.newGrammar(o,e),u.visit(),n.visit();var c=a.build();if(c.source=this.source.trimmed(),o in e)throw s.duplicateGrammarDeclaration(c,e);return e[o]=c,c},SuperGrammar:function(t,u){var r=u.visit();if("null"===r)a.withSuperGrammar(null);else{if(!e||!(r in e))throw s.undeclaredGrammar(r,e,u.source);a.withSuperGrammar(e[r])}},Rule_define:function(t,e,u,r,n){l=t.visit(),p=e.visit()[0]||[],a.defaultStartRule||a.ensureSuperGrammar()===i.ProtoBuiltInRules||a.withDefaultStartRule(l);var o=n.visit(),s=u.visit()[0],c=this.source.trimmed();return a.define(l,p,o,s,c)},Rule_override:function(t,e,u,r){l=t.visit(),p=e.visit()[0]||[];var n=this.source.trimmed();a.ensureSuperGrammarRuleForOverriding(l,n),f=!0;var i=r.visit();return f=!1,a.override(l,p,i,null,n)},Rule_extend:function(t,e,u,r){l=t.visit(),p=e.visit()[0]||[];var n=r.visit(),i=this.source.trimmed();return a.extend(l,p,n,null,i)},RuleBody:function(t,e){var u=e.visit();return h.alt.apply(h,u).withSource(this.source)},OverrideRuleBody:function(t,e){var u=e.visit(),r=u.indexOf(D);if(r>=0){var n=u.slice(0,r),i=u.slice(r+1);return i.forEach((function(t){if(t===D)throw s.multipleSuperSplices(t)})),new c.Splice(a.superGrammar,l,n,i).withSource(this.source)}return h.alt.apply(h,u).withSource(this.source)},Formals:function(t,e,u){return e.visit()},Params:function(t,e,u){return e.visit()},Alt:function(t){var e=t.visit();return h.alt.apply(h,e).withSource(this.source)},TopLevelTerm_inline:function(t,e){var u=l+"_"+e.visit(),r=t.visit(),n=this.source.trimmed(),i=!(a.superGrammar&&a.superGrammar.rules[u]);f&&!i?a.override(u,p,r,null,n):a.define(u,p,r,null,n);var o=p.map((function(t){return h.app(t)}));return h.app(u,o).withSource(r.source)},OverrideTopLevelTerm_superSplice:function(t){return D},Seq:function(t){return h.seq.apply(h,t.visit()).withSource(this.source)},Iter_star:function(t,e){return h.star(t.visit()).withSource(this.source)},Iter_plus:function(t,e){return h.plus(t.visit()).withSource(this.source)},Iter_opt:function(t,e){return h.opt(t.visit()).withSource(this.source)},Pred_not:function(t,e){return h.not(e.visit()).withSource(this.source)},Pred_lookahead:function(t,e){return h.lookahead(e.visit()).withSource(this.source)},Lex_lex:function(t,e){return h.lex(e.visit()).withSource(this.source)},Base_application:function(t,e){return h.app(t.visit(),e.visit()[0]||[]).withSource(this.source)},Base_range:function(t,e,u){return h.range(t.visit(),u.visit()).withSource(this.source)},Base_terminal:function(t){return h.terminal(t.visit()).withSource(this.source)},Base_paren:function(t,e,u){return e.visit()},ruleDescr:function(t,e,u){return e.visit()},ruleDescrText:function(t){return this.sourceString.trim()},caseName:function(t,e,u,r,n){return u.visit()},name:function(t,e){return this.sourceString},nameFirst:function(t){},nameRest:function(t){},terminal:function(t,e,u){return e.visit().join("")},oneCharTerminal:function(t,e,u){return e.visit()},terminalChar:function(t){return o.unescapeChar(this.sourceString)},escapeChar:function(t){return this.sourceString},NonemptyListOf:function(t,e,u){return[t.visit()].concat(u.visit())},EmptyListOf:function(){return[]},_terminal:function(){return this.primitiveValue}})(t).visit()}function C(t){if(!m(t))throw new TypeError("Expected a DOM Node, got "+o.unexpectedObjToString(t));if("text/ohm-js"!==t.type)throw new Error('Expected a script tag with type="text/ohm-js", got '+t);return t.getAttribute("src")?function(t){var e=new XMLHttpRequest;e.open("GET",t,!1);try{if(e.send(),0===e.status||200===e.status)return e.responseText}catch(t){}throw new Error("unable to load url "+t)}(t.getAttribute("src")):t.innerHTML}function g(t,e){var u=v(t,e),r=Object.keys(u);if(0===r.length)throw new Error("Missing grammar definition");if(r.length>1){var n=u[r[1]].source;throw new Error(l.getLineAndColumnMessage(n.sourceString,n.startIdx)+"Found more than one grammar definition -- use ohm.grammars() instead.")}return u[r[0]]}function v(t,e){var u=a.extend(a.asNamespace(e));if("string"!=typeof t){if(!h(t))throw new TypeError("Expected string as first argument, got "+o.unexpectedObjToString(t));t=t.toString()}return function(t,e){var u=r.match(t,"Grammars");if(u.failed())throw s.grammarSyntaxError(u);E(u,e)}(t,u),u}t.exports={createNamespace:a.createNamespace,grammar:g,grammars:v,grammarFromScriptElement:function(t){var e=t;if(d(e)){var u=f.querySelectorAll('script[type="text/ohm-js"]');if(1!==u.length)throw new Error('Expected exactly one script tag with type="text/ohm-js", found '+u.length);e=u[0]}return g(C(e))},grammarsFromScriptElements:function(t){if(m(t))return v(t);var e=t;if(d(e))e=f.querySelectorAll('script[type="text/ohm-js"]');else if("string"==typeof e||!m(e)&&!function(t){if(null==t)return!1;var e=t.length;return"number"==typeof e&&e>=0&&e<=A}(e))throw new TypeError("Expected a Node, NodeList, or Array, but got "+e);for(var u=a.createNamespace(),r=0;r<e.length;++r)o.extend(u,v(C(e[r]),u));return u},makeRecipe:function(t){return"function"==typeof t?t.call(new n):("string"==typeof t&&(t=JSON.parse(t)),(new n).fromRecipe(t))},ohmGrammar:null,pexprs:c,util:l,extras:u(42),version:p},t.exports._buildGrammar=E,t.exports._setDocumentInterfaceForTesting=function(t){f=t},i.BuiltInRules=u(44),l.announceBuiltInRules(i.BuiltInRules),t.exports.ohmGrammar=r=u(45),i.initApplicationParser(r,E)},function(t,e,u){var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u])})(t,e)},function(t,e){function u(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(u.prototype=e.prototype,new u)}),i=u(0),a=function(){function t(t,e,u){this.grammar=t,this.ctorName=e,this.matchLength=u}return t.prototype.numChildren=function(){return this.children?this.children.length:0},t.prototype.childAt=function(t){if(this.children)return this.children[t]},t.prototype.indexOfChild=function(t){return this.children.indexOf(t)},t.prototype.hasChildren=function(){return this.numChildren()>0},t.prototype.hasNoChildren=function(){return!this.hasChildren()},t.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()},t.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)},t.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)},t.prototype.childBefore=function(t){var e=this.indexOfChild(t);if(e<0)throw new Error("Node.childBefore() called w/ an argument that is not a child");if(0===e)throw new Error("cannot get child before first child");return this.childAt(e-1)},t.prototype.childAfter=function(t){var e=this.indexOfChild(t);if(e<0)throw new Error("Node.childAfter() called w/ an argument that is not a child");if(e===this.numChildren()-1)throw new Error("cannot get child after last child");return this.childAt(e+1)},t.prototype.isTerminal=function(){return!1},t.prototype.isNonterminal=function(){return!1},t.prototype.isIteration=function(){return!1},t.prototype.isOptional=function(){return!1},t.prototype.toJSON=function(){var t;return(t={})[this.ctorName]=this.children,t},t}(),o=function(t){function e(e,u){var r=this,n=u?u.length:0;return(r=t.call(this,e,"_terminal",n)||this).primitiveValue=u,r}return n(e,t),e.prototype.isTerminal=function(){return!0},e.prototype.toJSON=function(){var t;return(t={})[this.ctorName]=this.primitiveValue,t},e}(a),s=function(t){function e(e,u,r,n,i){var a=t.call(this,e,u,i)||this;return a.children=r,a.childOffsets=n,a}return n(e,t),e.prototype.isNonterminal=function(){return!0},e.prototype.isLexical=function(){return i.isLexical(this.ctorName)},e.prototype.isSyntactic=function(){return i.isSyntactic(this.ctorName)},e}(a),c=function(t){function e(e,u,r,n,i){var a=t.call(this,e,"_iter",n)||this;return a.children=u,a.childOffsets=r,a.optional=i,a}return n(e,t),e.prototype.isIteration=function(){return!0},e.prototype.isOptional=function(){return this.optional},e}(a);t.exports={Node:a,TerminalNode:o,NonterminalNode:s,IterationNode:c}},function(t,e,u){var r,n,i=u(17),a=u(35),o=u(38),s=u(0),c=u(2),l=u(1);function p(t){return Object.keys(t.rules).sort().map((function(e){return t.rules[e]}))}function h(t,e,u,r){if(this.name=t,this.superGrammar=e,this.rules=u,r){if(!(r in u))throw new Error("Invalid start rule: '"+r+"' is not a rule in grammar '"+t+"'");this.defaultStartRule=r}}h.initApplicationParser=function(t,e){r=t,n=e},h.prototype={matcher:function(){return new a(this)},isBuiltIn:function(){return this===h.ProtoBuiltInRules||this===h.BuiltInRules},equals:function(t){if(this===t)return!0;if(null==t||this.name!==t.name||this.defaultStartRule!==t.defaultStartRule||this.superGrammar!==t.superGrammar&&!this.superGrammar.equals(t.superGrammar))return!1;var e=p(this),u=p(t);return e.length===u.length&&e.every((function(t,e){return t.description===u[e].description&&t.formals.join(",")===u[e].formals.join(",")&&t.body.toString()===u[e].body.toString()}))},match:function(t,e){var u=this.matcher();return u.replaceInputRange(0,0,t),u.match(e)},trace:function(t,e){var u=this.matcher();return u.replaceInputRange(0,0,t),u.trace(e)},semantics:function(){throw new Error("semantics() is deprecated -- use createSemantics() instead.")},createSemantics:function(){return o.createSemantics(this)},extendSemantics:function(t){return o.createSemantics(this,t._getSemantics())},_checkTopDownActionDict:function(t,e,u){var r,n=[];for(var i in u){var a=u[i];if("_iter"===(r=i)||"_terminal"===r||"_nonterminal"===r||"_default"===r||i in this.rules)if("function"!=typeof a)n.push("'"+i+"' must be a function in an action dictionary for '"+this.name+"'");else{var o=a.length,s=this._topDownActionArity(i);o!==s&&n.push("Semantic action '"+i+"' has the wrong arity: expected "+s+", got "+o)}else n.push("'"+i+"' is not a valid semantic action for '"+this.name+"'")}if(n.length>0){var c=n.map((function(t){return"- "+t})),l=new Error("Found errors in the action dictionary of the '"+e+"' "+t+":\n"+c.join("\n"));throw l.problems=n,l}},_topDownActionArity:function(t){return"_iter"===t||"_nonterminal"===t||"_default"===t?1:"_terminal"===t?0:this.rules[t].body.getArity()},_inheritsFrom:function(t){for(var e=this.superGrammar;e;){if(e.equals(t,!0))return!0;e=e.superGrammar}return!1},toRecipe:function(t){var e={};this.source&&(e.source=this.source.contents);var u=null;this.superGrammar&&!this.superGrammar.isBuiltIn()&&(u=JSON.parse(this.superGrammar.toRecipe()));var r=null;this.defaultStartRule&&(r=this.defaultStartRule);var n={},i=this;return Object.keys(this.rules).forEach((function(t){var e,u=i.rules[t],r=u.body,a=!i.superGrammar||!i.superGrammar.rules[t];e=a?"define":r instanceof l.Extend?"extend":"override";var o={};if(u.source&&i.source){var s=u.source.relativeTo(i.source);o.sourceInterval=[s.startIdx,s.endIdx]}var c=a?u.description:null,p=r.outputRecipe(u.formals,i.source);n[t]=[e,o,c,u.formals,p]})),JSON.stringify(["grammar",e,this.name,u,r,n])},toOperationActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},toAttributeActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},_toOperationOrAttributeActionDictionaryTemplate:function(){var t=new s.StringBuffer;t.append("{");var e=!0;for(var u in this.rules){var r=this.rules[u].body;e?e=!1:t.append(","),t.append("\n"),t.append(" "),this.addSemanticActionTemplate(u,r,t)}return t.append("\n}"),t.contents()},addSemanticActionTemplate:function(t,e,u){u.append(t),u.append(": function(");var r=this._topDownActionArity(t);u.append(s.repeat("_",r).join(", ")),u.append(") {\n"),u.append(" }")},parseApplication:function(t){var e;if(-1===t.indexOf("<"))e=new l.Apply(t);else{var u=r.match(t,"Base_application");e=n(u,{})}if(!(e.ruleName in this.rules))throw c.undeclaredRule(e.ruleName,this.name);var i=this.rules[e.ruleName].formals;if(i.length!==e.args.length){var a=this.rules[e.ruleName].source;throw c.wrongNumberOfParameters(e.ruleName,i.length,e.args.length,a)}return e}},h.ProtoBuiltInRules=new h("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"}}),t.exports=h},function(t,e){t.exports=function(t,e){if(!e||"object"!=typeof e)return t;for(var u=Object.keys(e),r=u.length;r--;)t[u[r]]=e[u[r]];return t}},function(t,e,u){var r=u(0).assert,n=u(2),i=u(3);function a(t,e,u){this.sourceString=t,this.startIdx=e,this.endIdx=u}a.coverage=function(){for(var t=arguments[0].sourceString,e=arguments[0].startIdx,u=arguments[0].endIdx,r=1;r<arguments.length;r++){if(arguments[r].sourceString!==t)throw n.intervalSourcesDontMatch();e=Math.min(e,arguments[r].startIdx),u=Math.max(u,arguments[r].endIdx)}return new a(t,e,u)},a.prototype={coverageWith:function(){var t=Array.prototype.slice.call(arguments);return t.push(this),a.coverage.apply(void 0,t)},collapsedLeft:function(){return new a(this.sourceString,this.startIdx,this.startIdx)},collapsedRight:function(){return new a(this.sourceString,this.endIdx,this.endIdx)},getLineAndColumn:function(){return i.getLineAndColumn(this.sourceString,this.startIdx)},getLineAndColumnMessage:function(){var t=[this.startIdx,this.endIdx];return i.getLineAndColumnMessage(this.sourceString,this.startIdx,t)},minus:function(t){if(this.sourceString!==t.sourceString)throw n.intervalSourcesDontMatch();return this.startIdx===t.startIdx&&this.endIdx===t.endIdx?[]:this.startIdx<t.startIdx&&t.endIdx<this.endIdx?[new a(this.sourceString,this.startIdx,t.startIdx),new a(this.sourceString,t.endIdx,this.endIdx)]:this.startIdx<t.endIdx&&t.endIdx<this.endIdx?[new a(this.sourceString,t.endIdx,this.endIdx)]:this.startIdx<t.startIdx&&t.startIdx<this.endIdx?[new a(this.sourceString,this.startIdx,t.startIdx)]:[this]},relativeTo:function(t){if(this.sourceString!==t.sourceString)throw n.intervalSourcesDontMatch();return r(this.startIdx>=t.startIdx&&this.endIdx<=t.endIdx,"other interval does not cover this one"),new a(this.sourceString,this.startIdx-t.startIdx,this.endIdx-t.startIdx)},trimmed:function(){var t=this.contents,e=this.startIdx+t.match(/^\s*/)[0].length,u=this.endIdx-t.match(/\s*$/)[0].length;return new a(this.sourceString,e,u)},subInterval:function(t,e){var u=this.startIdx+t;return new a(this.sourceString,u,u+e)}},Object.defineProperties(a.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}}),t.exports=a},function(t,e,u){var r=u(8);function n(t){this.source=t,this.pos=0,this.examinedLength=0}n.prototype={atEnd:function(){var t=this.pos===this.source.length;return this.examinedLength=Math.max(this.examinedLength,this.pos+1),t},next:function(){var t=this.source[this.pos++];return this.examinedLength=Math.max(this.examinedLength,this.pos),t},matchString:function(t,e){var u;if(e){for(u=0;u<t.length;u++){var r=this.next(),n=t[u];if(null==r||r.toUpperCase()!==n.toUpperCase())return!1}return!0}for(u=0;u<t.length;u++)if(this.next()!==t[u])return!1;return!0},sourceSlice:function(t,e){return this.source.slice(t,e)},interval:function(t,e){return new r(this.source,t,e||this.pos)}},t.exports=n},function(t,e,u){var r=u(0),n=u(3),i=u(8);function a(t,e,u,i,a,o,s){this.matcher=t,this.input=e,this.startExpr=u,this._cst=i,this._cstOffset=a,this._rightmostFailurePosition=o,this._rightmostFailures=s,this.failed()&&(r.defineLazyProperty(this,"message",(function(){var t="Expected "+this.getExpectedText();return n.getLineAndColumnMessage(this.input,this.getRightmostFailurePosition())+t})),r.defineLazyProperty(this,"shortMessage",(function(){var t="expected "+this.getExpectedText(),e=n.getLineAndColumn(this.input,this.getRightmostFailurePosition());return"Line "+e.lineNum+", col "+e.colNum+": "+t})))}a.prototype.succeeded=function(){return!!this._cst},a.prototype.failed=function(){return!this.succeeded()},a.prototype.getRightmostFailurePosition=function(){return this._rightmostFailurePosition},a.prototype.getRightmostFailures=function(){if(!this._rightmostFailures){this.matcher.setInput(this.input);var t=this.matcher._match(this.startExpr,!1,this.getRightmostFailurePosition());this._rightmostFailures=t.getRightmostFailures()}return this._rightmostFailures},a.prototype.toString=function(){return this.succeeded()?"[match succeeded]":"[match failed at position "+this.getRightmostFailurePosition()+"]"},a.prototype.getExpectedText=function(){if(this.succeeded())throw new Error("cannot get expected text of a successful MatchResult");var t=new r.StringBuffer,e=this.getRightmostFailures();e=e.filter((function(t){return!t.isFluffy()}));for(var u=0;u<e.length;u++)u>0&&(u===e.length-1?t.append(e.length>2?", or ":" or "):t.append(", ")),t.append(e[u].toString());return t.contents()},a.prototype.getInterval=function(){var t=this.getRightmostFailurePosition();return new i(this.input,t,t)},t.exports=a},function(t,e,u){function r(t,e,u){if(!function(t){return"description"===t||"string"===t||"code"===t}(u))throw new Error("invalid Failure type: "+u);this.pexpr=t,this.text=e,this.type=u,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(t){return this.getText()===t.getText()&&this.type===t.type&&(!this.isFluffy()||this.isFluffy()&&t.isFluffy())},r.prototype.toString=function(){return"string"===this.type?JSON.stringify(this.getText()):this.getText()},r.prototype.clone=function(){var t=new r(this.pexpr,this.text,this.type);return this.isFluffy()&&t.makeFluffy(),t},r.prototype.toKey=function(){return this.toString()+"#"+this.type},t.exports=r},function(t,e,u){var r=u(7);function n(){}n.prototype=Object.create(null),n.asNamespace=function(t){return t instanceof n?t:n.createNamespace(t)},n.createNamespace=function(t){return n.extend(n.prototype,t)},n.extend=function(t,e){if(t!==n.prototype&&!(t instanceof n))throw new TypeError("not a Namespace object: "+t);var u=Object.create(t,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}});return r(u,e)},n.toString=function(t){return Object.prototype.toString.call(t)},t.exports=n},function(t,e,u){var r=u(8),n=u(0),i={succeeded:1,isRootNode:2,isImplicitSpaces:4,isMemoized:8,isHeadOfLeftRecursion:16,terminatesLR:32};function a(t){return"string"==typeof t?t.replace(/ /g,"⋅").replace(/\t/g,"␉").replace(/\n/g,"␊").replace(/\r/g,"␍"):String(t)}function o(t,e,u,n,a,o,s){this.input=t,this.pos=this.pos1=e,this.pos2=u,this.source=new r(t,e,u),this.expr=n,this.bindings=o,this.children=s||[],this.terminatingLREntry=null,this._flags=a?i.succeeded:0}o.prototype.SKIP={},Object.defineProperty(o.prototype,"displayString",{get:function(){return this.expr.toDisplayString()}}),Object.keys(i).forEach((function(t){var e=i[t];Object.defineProperty(o.prototype,t,{get:function(){return!!(this._flags&e)},set:function(t){t?this._flags|=e:this._flags&=~e}})})),o.prototype.clone=function(){return this.cloneWithExpr(this.expr)},o.prototype.cloneWithExpr=function(t){var e=new o(this.input,this.pos,this.pos2,t,this.succeeded,this.bindings,this.children);return e.isHeadOfLeftRecursion=this.isHeadOfLeftRecursion,e.isImplicitSpaces=this.isImplicitSpaces,e.isMemoized=this.isMemoized,e.isRootNode=this.isRootNode,e.terminatesLR=this.terminatesLR,e.terminatingLREntry=this.terminatingLREntry,e},o.prototype.recordLRTermination=function(t,e){this.terminatingLREntry=new o(this.input,this.pos,this.pos2,this.expr,!1,[e],[t]),this.terminatingLREntry.terminatesLR=!0},o.prototype.walk=function(t,e){var u=t;function r(t,n,i){var a=!0;u.enter&&u.enter.call(e,t,n,i)===o.prototype.SKIP&&(a=!1),a&&(t.children.forEach((function(e){r(e,t,i+1)})),u.exit&&u.exit.call(e,t,n,i))}"function"==typeof u&&(u={enter:u}),this.isRootNode?this.children.forEach((function(t){r(t,null,0)})):r(this,null,0)},o.prototype.toString=function(){var t=this,e=new n.StringBuffer;return this.walk((function(u,r,i){if(!u)return t.SKIP;if("Alt"!==u.expr.constructor.name){var o,s,c,l;if(e.append((s=u.input,c=u.pos,10,((l=a(s.slice(c,c+10))).length<10?l+n.repeat(" ",10-l.length).join(""):l)+(o=2*i+1,n.repeat(" ",o).join("")))),e.append((u.succeeded?"✓":"✗")+" "+u.displayString),u.isHeadOfLeftRecursion&&e.append(" (LR)"),u.succeeded){var p=a(u.source.contents);e.append(" ⇒ "),e.append("string"==typeof p?'"'+p+'"':p)}e.append("\n")}})),e.contents()},t.exports=o},function(t,e,u){var r=u(1),n=u(10),i=u(6),a=u(7),o={_terminal:function(){return this.primitiveValue},_nonterminal:function(t){var e=this._node.ctorName,u=this.args.mapping;if(!u.hasOwnProperty(e)){if(this._node instanceof r.Alt||this._node instanceof r.Apply)return t[0].toAST(u);if(this.isLexical())return this.sourceString;var n=t.filter((function(t){return!t.isTerminal()}));if(1===n.length)return n[0].toAST(u)}if("number"==typeof u[e])return t[u[e]].toAST(u);var i=u[e]||t,a={type:e};for(var o in i){var s=u[e]&&u[e][o];"number"==typeof s?a[o]=t[s].toAST(u):"string"==typeof s||"boolean"==typeof s||null===s?a[o]=s:"object"==typeof s&&s instanceof Number?a[o]=Number(s):"function"==typeof s?a[o]=s.call(this,t):void 0===s&&(t[o]&&!t[o].isTerminal()?a[o]=t[o].toAST(u):delete a[o])}return a},_iter:function(t){return this._node.isOptional()?0===this.numChildren?null:t[0].toAST(this.args.mapping):t.map((function(t){return t.toAST(this.args.mapping)}),this)},NonemptyListOf:function(t,e,u){return[t.toAST(this.args.mapping)].concat(u.toAST(this.args.mapping))},EmptyListOf:function(){return[]}};t.exports={helper:function(t,e){if(!(t instanceof n)||t.failed())throw new Error("toAST() expects a succesfull MatchResult as first parameter");e=a({},e);var u=a({},o);for(var r in e)"function"==typeof e[r]&&(u[r]=e[r],delete e[r]);return t._cst.grammar.createSemantics().addOperation("toAST(mapping)",u)(t).toAST(e)},semantics:function(t){if(!(t instanceof i))throw new Error("semanticsToAST() expects a Grammar as parameter");return t.createSemantics().addOperation("toAST(mapping)",o)}}},function(t,e,u){var r=u(16),n=u(1);function i(){}i.prototype={currentDecl:null,currentRuleName:null,newGrammar:function(t){return new r(t)},grammar:function(t,e,u,n,i){var a=this,o=new r(e);return u&&o.withSuperGrammar(this.fromRecipe(u)),n&&o.withDefaultStartRule(n),t&&t.source&&o.withSource(t.source),this.currentDecl=o,Object.keys(i).forEach((function(t){a.currentRuleName=t;var e,u=i[t],r=u[0],n=u[1],s=u[2],c=u[3],l=a.fromRecipe(u[4]);o.source&&n&&n.sourceInterval&&(e=o.source.subInterval(n.sourceInterval[0],n.sourceInterval[1]-n.sourceInterval[0])),o[r](t,c,l,s,e)})),this.currentRuleName=this.currentDecl=null,o.build()},terminal:function(t){return new n.Terminal(t)},range:function(t,e){return new n.Range(t,e)},param:function(t){return new n.Param(t)},alt:function(){for(var t=[],e=0;e<arguments.length;e++){var u=arguments[e];u instanceof n.PExpr||(u=this.fromRecipe(u)),u instanceof n.Alt?t=t.concat(u.terms):t.push(u)}return 1===t.length?t[0]:new n.Alt(t)},seq:function(){for(var t=[],e=0;e<arguments.length;e++){var u=arguments[e];u instanceof n.PExpr||(u=this.fromRecipe(u)),u instanceof n.Seq?t=t.concat(u.factors):t.push(u)}return 1===t.length?t[0]:new n.Seq(t)},star:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Star(t)},plus:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Plus(t)},opt:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Opt(t)},not:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Not(t)},la:function(t){return this.lookahead(t)},lookahead:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Lookahead(t)},lex:function(t){return t instanceof n.PExpr||(t=this.fromRecipe(t)),new n.Lex(t)},app:function(t,e){return e&&e.length>0&&(e=e.map((function(t){return t instanceof n.PExpr?t:this.fromRecipe(t)}),this)),new n.Apply(t,e)},splice:function(t,e){var u=this;return new n.Splice(this.currentDecl.superGrammar,this.currentRuleName,t.map((function(t){return u.fromRecipe(t)})),e.map((function(t){return u.fromRecipe(t)})))},fromRecipe:function(t){var e=this[t[0]].apply(this,"grammar"===t[0]?t.slice(1):t.slice(2)),u=t[1];return u&&u.sourceInterval&&this.currentDecl&&e.withSource(this.currentDecl.sourceInterval.apply(this.currentDecl,u.sourceInterval)),e}},t.exports=i},function(t,e,u){var r=u(6),n=u(9),i=u(0),a=u(2),o=u(1);function s(t){this.name=t}s.prototype.sourceInterval=function(t,e){return this.source.subInterval(t,e-t)},s.prototype.ensureSuperGrammar=function(){return this.superGrammar||this.withSuperGrammar("BuiltInRules"===this.name?r.ProtoBuiltInRules:r.BuiltInRules),this.superGrammar},s.prototype.ensureSuperGrammarRuleForOverriding=function(t,e){var u=this.ensureSuperGrammar().rules[t];if(!u)throw a.cannotOverrideUndeclaredRule(t,this.superGrammar.name,e);return u},s.prototype.installOverriddenOrExtendedRule=function(t,e,u,r){var n=i.getDuplicates(e);if(n.length>0)throw a.duplicateParameterNames(t,n,r);var o=this.ensureSuperGrammar().rules[t],s=o.formals,c=s?s.length:0;if(e.length!==c)throw a.wrongNumberOfParameters(t,c,e.length,r);return this.install(t,e,u,o.description,r)},s.prototype.install=function(t,e,u,r,n){return this.rules[t]={body:u.introduceParams(e),formals:e,description:r,source:n},this},s.prototype.withSuperGrammar=function(t){if(this.superGrammar)throw new Error("the super grammar of a GrammarDecl cannot be set more than once");return this.superGrammar=t,this.rules=Object.create(t.rules),t.isBuiltIn()||(this.defaultStartRule=t.defaultStartRule),this},s.prototype.withDefaultStartRule=function(t){return this.defaultStartRule=t,this},s.prototype.withSource=function(t){return this.source=new n(t).interval(0,t.length),this},s.prototype.build=function(){var t=new r(this.name,this.ensureSuperGrammar(),this.rules,this.defaultStartRule),e=[],u=!1;return Object.keys(t.rules).forEach((function(r){var n=t.rules[r].body;try{n.assertChoicesHaveUniformArity(r)}catch(t){e.push(t)}try{n.assertAllApplicationsAreValid(r,t)}catch(t){e.push(t),u=!0}})),u||Object.keys(t.rules).forEach((function(u){var r=t.rules[u].body;try{r.assertIteratedExprsAreNotNullable(t,[])}catch(t){e.push(t)}})),e.length>0&&a.throwErrors(e),this.source&&(t.source=this.source),t},s.prototype.define=function(t,e,u,r,n){if(this.ensureSuperGrammar(),this.superGrammar.rules[t])throw a.duplicateRuleDeclaration(t,this.name,this.superGrammar.name,n);if(this.rules[t])throw a.duplicateRuleDeclaration(t,this.name,this.name,n);var o=i.getDuplicates(e);if(o.length>0)throw a.duplicateParameterNames(t,o,n);return this.install(t,e,u,r,n)},s.prototype.override=function(t,e,u,r,n){return this.ensureSuperGrammarRuleForOverriding(t,n),this.installOverriddenOrExtendedRule(t,e,u,n),this},s.prototype.extend=function(t,e,u,r,n){if(!this.ensureSuperGrammar().rules[t])throw a.cannotExtendUndeclaredRule(t,this.superGrammar.name,n);var i=new o.Extend(this.superGrammar,t,u);return i.source=u.source,this.installOverriddenOrExtendedRule(t,e,i,n),this},t.exports=s},function(t,e,u){var r,n=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u])})(t,e)},function(t,e){function u(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(u.prototype=e.prototype,new u)}),i=u(11),a=u(5).TerminalNode,o=u(0).assert,s=u(1),c=s.PExpr,l=s.Terminal,p=function(t){function e(e){var u=t.call(this)||this;return u.obj=e,u}return n(e,t),e.prototype._getString=function(t){var e=t.currentApplication().args[this.obj.index];return o(e instanceof l,"expected a Terminal expression"),e.obj},e.prototype.allowsSkippingPrecedingSpace=function(){return!0},e.prototype.eval=function(t){var e=t.inputStream,u=e.pos,r=this._getString(t);return e.matchString(r,!0)?(t.pushBinding(new a(t.grammar,r),u),!0):(t.processFailure(u,this),!1)},e.prototype.generateExample=function(t,e,u,r){for(var n=this.obj.generateExample(t,e,u,r).value,i="",a=0;a<n.length;++a)i+=Math.random()<.5?n[a].toLocaleLowerCase():n[a].toLocaleUpperCase();return{value:i}},e.prototype.getArity=function(){return 1},e.prototype.substituteParams=function(t){return new e(this.obj.substituteParams(t))},e.prototype.toDisplayString=function(){return this.obj.toDisplayString()+" (case-insensitive)"},e.prototype.toFailure=function(t){return new i(this,this.obj.toFailure(t)+" (case-insensitive)","description")},e.prototype._isNullable=function(t,e){return this.obj._isNullable(t,e)},e}(c);t.exports=p},function(t,e){t.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\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u