notations 1.0.2 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/notations.umd.js +4234 -12211
- package/dist/notations.umd.min.js +2 -3
- package/dist/notations.umd.min.js.map +1 -1
- package/lib/cjs/block.d.ts +4 -0
- package/lib/cjs/block.js +24 -0
- package/lib/cjs/block.js.map +1 -1
- package/lib/cjs/core.d.ts +15 -0
- package/lib/cjs/core.js +144 -4
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/entity.d.ts +4 -0
- package/lib/cjs/entity.js +12 -0
- package/lib/cjs/entity.js.map +1 -1
- package/lib/cjs/events.d.ts +56 -0
- package/lib/cjs/events.js +27 -0
- package/lib/cjs/events.js.map +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/parser.js +1 -1
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.d.ts +11 -0
- package/lib/cjs/shapes.js +25 -2
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/cjs/web/components/DockViewPlayground.js +364 -0
- package/lib/cjs/web/components/DockViewPlayground.js.map +1 -0
- package/lib/cjs/web/components/NotationBlock.d.ts +35 -0
- package/lib/cjs/web/components/NotationBlock.js +219 -0
- package/lib/cjs/web/components/NotationBlock.js.map +1 -0
- package/lib/cjs/web/components/NotebookCell.d.ts +41 -0
- package/lib/cjs/web/components/NotebookCell.js +269 -0
- package/lib/cjs/web/components/NotebookCell.js.map +1 -0
- package/lib/cjs/web/components/NotebookView.d.ts +37 -0
- package/lib/cjs/web/components/NotebookView.js +379 -0
- package/lib/cjs/web/components/NotebookView.js.map +1 -0
- package/lib/cjs/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/cjs/web/components/SideBySideEditor.js +171 -0
- package/lib/cjs/web/components/SideBySideEditor.js.map +1 -0
- package/lib/cjs/web/dockview.d.ts +2 -0
- package/lib/cjs/web/dockview.js +11 -0
- package/lib/cjs/web/dockview.js.map +1 -0
- package/lib/cjs/web/index.d.ts +8 -0
- package/lib/cjs/web/index.js +34 -0
- package/lib/cjs/web/index.js.map +1 -0
- package/lib/cjs/web/types/notebook.d.ts +64 -0
- package/lib/cjs/web/types/notebook.js +56 -0
- package/lib/cjs/web/types/notebook.js.map +1 -0
- package/lib/cjs/web/utils/cellFactory.d.ts +16 -0
- package/lib/cjs/web/utils/cellFactory.js +137 -0
- package/lib/cjs/web/utils/cellFactory.js.map +1 -0
- package/lib/cjs/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/cjs/web/utils/sourceSerializer.js +162 -0
- package/lib/cjs/web/utils/sourceSerializer.js.map +1 -0
- package/lib/esm/block.d.ts +4 -0
- package/lib/esm/block.js +24 -0
- package/lib/esm/block.js.map +1 -1
- package/lib/esm/core.d.ts +15 -0
- package/lib/esm/core.js +144 -4
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/entity.d.ts +4 -0
- package/lib/esm/entity.js +12 -0
- package/lib/esm/entity.js.map +1 -1
- package/lib/esm/events.d.ts +56 -0
- package/lib/esm/events.js +24 -0
- package/lib/esm/events.js.map +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/parser.js +1 -1
- package/lib/esm/parser.js.map +1 -1
- package/lib/esm/shapes.d.ts +11 -0
- package/lib/esm/shapes.js +24 -2
- package/lib/esm/shapes.js.map +1 -1
- package/lib/esm/web/components/DockViewPlayground.d.ts +51 -0
- package/lib/esm/web/components/DockViewPlayground.js +358 -0
- package/lib/esm/web/components/DockViewPlayground.js.map +1 -0
- package/lib/esm/web/components/NotationBlock.d.ts +35 -0
- package/lib/esm/web/components/NotationBlock.js +216 -0
- package/lib/esm/web/components/NotationBlock.js.map +1 -0
- package/lib/esm/web/components/NotebookCell.d.ts +41 -0
- package/lib/esm/web/components/NotebookCell.js +266 -0
- package/lib/esm/web/components/NotebookCell.js.map +1 -0
- package/lib/esm/web/components/NotebookView.d.ts +37 -0
- package/lib/esm/web/components/NotebookView.js +376 -0
- package/lib/esm/web/components/NotebookView.js.map +1 -0
- package/lib/esm/web/components/SideBySideEditor.d.ts +47 -0
- package/lib/esm/web/components/SideBySideEditor.js +168 -0
- package/lib/esm/web/components/SideBySideEditor.js.map +1 -0
- package/lib/esm/web/dockview.d.ts +2 -0
- package/lib/esm/web/dockview.js +3 -0
- package/lib/esm/web/dockview.js.map +1 -0
- package/lib/esm/web/index.d.ts +8 -0
- package/lib/esm/web/index.js +9 -0
- package/lib/esm/web/index.js.map +1 -0
- package/lib/esm/web/types/notebook.d.ts +64 -0
- package/lib/esm/web/types/notebook.js +50 -0
- package/lib/esm/web/types/notebook.js.map +1 -0
- package/lib/esm/web/utils/cellFactory.d.ts +16 -0
- package/lib/esm/web/utils/cellFactory.js +127 -0
- package/lib/esm/web/utils/cellFactory.js.map +1 -0
- package/lib/esm/web/utils/sourceSerializer.d.ts +19 -0
- package/lib/esm/web/utils/sourceSerializer.js +154 -0
- package/lib/esm/web/utils/sourceSerializer.js.map +1 -0
- package/package.json +43 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/*! For license information please see notations.umd.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Notations=e():t.Notations=e()}(this,()=>(()=>{var t={24:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,l=u>>1,c=-7,h=r?i-1:0,f=r?-1:1,p=t[e+h];for(h+=f,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=f,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=l}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,l=8*o-i-1,c=(1<<l)-1,h=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;t[r+p]=255&s,p+=d,s/=256,l-=8);t[r+p-d]|=128*g}},80:(t,e,r)=>{"use strict";var n=r(922).hp;function i(t,e){return function(){return t.apply(e,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:s}=Object,{iterator:a,toStringTag:u}=Symbol,l=(c=Object.create(null),t=>{const e=o.call(t);return c[e]||(c[e]=e.slice(8,-1).toLowerCase())});var c;const h=t=>(t=t.toLowerCase(),e=>l(e)===t),f=t=>e=>typeof e===t,{isArray:p}=Array,d=f("undefined");function g(t){return null!==t&&!d(t)&&null!==t.constructor&&!d(t.constructor)&&v(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const y=h("ArrayBuffer"),m=f("string"),v=f("function"),b=f("number"),w=t=>null!==t&&"object"==typeof t,S=t=>{if("object"!==l(t))return!1;const e=s(t);return!(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e)||u in t||a in t)},E=h("Date"),C=h("File"),_=h("Blob"),x=h("FileList"),O=h("URLSearchParams"),[A,T,N,R]=["ReadableStream","Request","Response","Headers"].map(h);function I(t,e,{allOwnKeys:r=!1}={}){if(null==t)return;let n,i;if("object"!=typeof t&&(t=[t]),p(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{if(g(t))return;const i=r?Object.getOwnPropertyNames(t):Object.keys(t),o=i.length;let s;for(n=0;n<o;n++)s=i[n],e.call(null,t[s],s,t)}}function k(t,e){if(g(t))return null;e=e.toLowerCase();const r=Object.keys(t);let n,i=r.length;for(;i-- >0;)if(n=r[i],e===n.toLowerCase())return n;return null}const L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,P=t=>!d(t)&&t!==L,B=(j="undefined"!=typeof Uint8Array&&s(Uint8Array),t=>j&&t instanceof j);var j;const M=h("HTMLFormElement"),D=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),U=h("RegExp"),F=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};I(r,(r,i)=>{let o;!1!==(o=e(r,i,t))&&(n[i]=o||r)}),Object.defineProperties(t,n)},$=h("AsyncFunction"),V=(z="function"==typeof setImmediate,G=v(L.postMessage),z?setImmediate:G?(q=`axios@${Math.random()}`,W=[],L.addEventListener("message",({source:t,data:e})=>{t===L&&e===q&&W.length&&W.shift()()},!1),t=>{W.push(t),L.postMessage(q,"*")}):t=>setTimeout(t));var z,G,q,W;const H="undefined"!=typeof queueMicrotask?queueMicrotask.bind(L):"undefined"!=typeof process&&process.nextTick||V;var K={isArray:p,isArrayBuffer:y,isBuffer:g,isFormData:t=>{let e;return t&&("function"==typeof FormData&&t instanceof FormData||v(t.append)&&("formdata"===(e=l(t))||"object"===e&&v(t.toString)&&"[object FormData]"===t.toString()))},isArrayBufferView:function(t){let e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&y(t.buffer),e},isString:m,isNumber:b,isBoolean:t=>!0===t||!1===t,isObject:w,isPlainObject:S,isEmptyObject:t=>{if(!w(t)||g(t))return!1;try{return 0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return!1}},isReadableStream:A,isRequest:T,isResponse:N,isHeaders:R,isUndefined:d,isDate:E,isFile:C,isBlob:_,isRegExp:U,isFunction:v,isStream:t=>w(t)&&v(t.pipe),isURLSearchParams:O,isTypedArray:B,isFileList:x,forEach:I,merge:function t(){const{caseless:e,skipUndefined:r}=P(this)&&this||{},n={},i=(i,o)=>{const s=e&&k(n,o)||o;S(n[s])&&S(i)?n[s]=t(n[s],i):S(i)?n[s]=t({},i):p(i)?n[s]=i.slice():r&&d(i)||(n[s]=i)};for(let t=0,e=arguments.length;t<e;t++)arguments[t]&&I(arguments[t],i);return n},extend:(t,e,r,{allOwnKeys:n}={})=>(I(e,(e,n)=>{r&&v(e)?t[n]=i(e,r):t[n]=e},{allOwnKeys:n}),t),trim:t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:t=>(65279===t.charCodeAt(0)&&(t=t.slice(1)),t),inherits:(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},toFlatObject:(t,e,r,n)=>{let i,o,a;const u={};if(e=e||{},null==t)return e;do{for(i=Object.getOwnPropertyNames(t),o=i.length;o-- >0;)a=i[o],n&&!n(a,t,e)||u[a]||(e[a]=t[a],u[a]=!0);t=!1!==r&&s(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:l,kindOfTest:h,endsWith:(t,e,r)=>{t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return-1!==n&&n===r},toArray:t=>{if(!t)return null;if(p(t))return t;let e=t.length;if(!b(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},forEachEntry:(t,e)=>{const r=(t&&t[a]).call(t);let n;for(;(n=r.next())&&!n.done;){const r=n.value;e.call(t,r[0],r[1])}},matchAll:(t,e)=>{let r;const n=[];for(;null!==(r=t.exec(e));)n.push(r);return n},isHTMLForm:M,hasOwnProperty:D,hasOwnProp:D,reduceDescriptors:F,freezeMethods:t=>{F(t,(e,r)=>{if(v(t)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=t[r];v(n)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(t,e)=>{const r={},n=t=>{t.forEach(t=>{r[t]=!0})};return p(t)?n(t):n(String(t).split(e)),r},toCamelCase:t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,r){return e.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(t,e)=>null!=t&&Number.isFinite(t=+t)?t:e,findKey:k,global:L,isContextDefined:P,isSpecCompliantForm:function(t){return!!(t&&v(t.append)&&"FormData"===t[u]&&t[a])},toJSONObject:t=>{const e=new Array(10),r=(t,n)=>{if(w(t)){if(e.indexOf(t)>=0)return;if(g(t))return t;if(!("toJSON"in t)){e[n]=t;const i=p(t)?[]:{};return I(t,(t,e)=>{const o=r(t,n+1);!d(o)&&(i[e]=o)}),e[n]=void 0,i}}return t};return r(t,0)},isAsyncFn:$,isThenable:t=>t&&(w(t)||v(t))&&v(t.then)&&v(t.catch),setImmediate:V,asap:H,isIterable:t=>null!=t&&v(t[a])};function J(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}K.inherits(J,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:K.toJSONObject(this.config),code:this.code,status:this.status}}});const Q=J.prototype,Y={};function X(t){return K.isPlainObject(t)||K.isArray(t)}function Z(t){return K.endsWith(t,"[]")?t.slice(0,-2):t}function tt(t,e,r){return t?t.concat(e).map(function(t,e){return t=Z(t),!r&&e?"["+t+"]":t}).join(r?".":""):e}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Y[t]={value:t}}),Object.defineProperties(J,Y),Object.defineProperty(Q,"isAxiosError",{value:!0}),J.from=(t,e,r,n,i,o)=>{const s=Object.create(Q);K.toFlatObject(t,s,function(t){return t!==Error.prototype},t=>"isAxiosError"!==t);const a=t&&t.message?t.message:"Error",u=null==e&&t?t.code:e;return J.call(s,a,u,r,n,i),t&&null==s.cause&&Object.defineProperty(s,"cause",{value:t,configurable:!0}),s.name=t&&t.name||"Error",o&&Object.assign(s,o),s};const et=K.toFlatObject(K,{},null,function(t){return/^is[A-Z]/.test(t)});function rt(t,e,r){if(!K.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const i=(r=K.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,e){return!K.isUndefined(e[t])})).metaTokens,o=r.visitor||c,s=r.dots,a=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&K.isSpecCompliantForm(e);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function l(t){if(null===t)return"";if(K.isDate(t))return t.toISOString();if(K.isBoolean(t))return t.toString();if(!u&&K.isBlob(t))throw new J("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(t)||K.isTypedArray(t)?u&&"function"==typeof Blob?new Blob([t]):n.from(t):t}function c(t,r,n){let o=t;if(t&&!n&&"object"==typeof t)if(K.endsWith(r,"{}"))r=i?r:r.slice(0,-2),t=JSON.stringify(t);else if(K.isArray(t)&&function(t){return K.isArray(t)&&!t.some(X)}(t)||(K.isFileList(t)||K.endsWith(r,"[]"))&&(o=K.toArray(t)))return r=Z(r),o.forEach(function(t,n){!K.isUndefined(t)&&null!==t&&e.append(!0===a?tt([r],n,s):null===a?r:r+"[]",l(t))}),!1;return!!X(t)||(e.append(tt(n,r,s),l(t)),!1)}const h=[],f=Object.assign(et,{defaultVisitor:c,convertValue:l,isVisitable:X});if(!K.isObject(t))throw new TypeError("data must be an object");return function t(r,n){if(!K.isUndefined(r)){if(-1!==h.indexOf(r))throw Error("Circular reference detected in "+n.join("."));h.push(r),K.forEach(r,function(r,i){!0===(!(K.isUndefined(r)||null===r)&&o.call(e,r,K.isString(i)?i.trim():i,n,f))&&t(r,n?n.concat(i):[i])}),h.pop()}}(t),e}function nt(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function it(t,e){this._pairs=[],t&&rt(t,this,e)}const ot=it.prototype;function st(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function at(t,e,r){if(!e)return t;const n=r&&r.encode||st;K.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let o;if(o=i?i(e,r):K.isURLSearchParams(e)?e.toString():new it(e,r).toString(n),o){const e=t.indexOf("#");-1!==e&&(t=t.slice(0,e)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}ot.append=function(t,e){this._pairs.push([t,e])},ot.toString=function(t){const e=t?function(e){return t.call(this,e,nt)}:nt;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};var ut=class{constructor(){this.handlers=[]}use(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){K.forEach(this.handlers,function(e){null!==e&&t(e)})}},lt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ct={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:it,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ht="undefined"!=typeof window&&"undefined"!=typeof document,ft="object"==typeof navigator&&navigator||void 0,pt=ht&&(!ft||["ReactNative","NativeScript","NS"].indexOf(ft.product)<0),dt="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,gt=ht&&window.location.href||"http://localhost";var yt={...Object.freeze({__proto__:null,hasBrowserEnv:ht,hasStandardBrowserWebWorkerEnv:dt,hasStandardBrowserEnv:pt,navigator:ft,origin:gt}),...ct};function mt(t){function e(t,r,n,i){let o=t[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=t.length;return o=!o&&K.isArray(n)?n.length:o,a?(K.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r,!s):(n[o]&&K.isObject(n[o])||(n[o]=[]),e(t,r,n[o],i)&&K.isArray(n[o])&&(n[o]=function(t){const e={},r=Object.keys(t);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],e[o]=t[o];return e}(n[o])),!s)}if(K.isFormData(t)&&K.isFunction(t.entries)){const r={};return K.forEachEntry(t,(t,n)=>{e(function(t){return K.matchAll(/\w+|\[(\w*)]/g,t).map(t=>"[]"===t[0]?"":t[1]||t[0])}(t),n,r,0)}),r}return null}const vt={transitional:lt,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const r=e.getContentType()||"",n=r.indexOf("application/json")>-1,i=K.isObject(t);if(i&&K.isHTMLForm(t)&&(t=new FormData(t)),K.isFormData(t))return n?JSON.stringify(mt(t)):t;if(K.isArrayBuffer(t)||K.isBuffer(t)||K.isStream(t)||K.isFile(t)||K.isBlob(t)||K.isReadableStream(t))return t;if(K.isArrayBufferView(t))return t.buffer;if(K.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(t,e){return rt(t,new yt.classes.URLSearchParams,{visitor:function(t,e,r,n){return yt.isNode&&K.isBuffer(t)?(this.append(e,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...e})}(t,this.formSerializer).toString();if((o=K.isFileList(t))||r.indexOf("multipart/form-data")>-1){const e=this.env&&this.env.FormData;return rt(o?{"files[]":t}:t,e&&new e,this.formSerializer)}}return i||n?(e.setContentType("application/json",!1),function(t){if(K.isString(t))try{return(0,JSON.parse)(t),K.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(0,JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){const e=this.transitional||vt.transitional,r=e&&e.forcedJSONParsing,n="json"===this.responseType;if(K.isResponse(t)||K.isReadableStream(t))return t;if(t&&K.isString(t)&&(r&&!this.responseType||n)){const r=!(e&&e.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(t){if(r){if("SyntaxError"===t.name)throw J.from(t,J.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:yt.classes.FormData,Blob:yt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],t=>{vt.headers[t]={}});var bt=vt;const wt=K.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),St=Symbol("internals");function Et(t){return t&&String(t).trim().toLowerCase()}function Ct(t){return!1===t||null==t?t:K.isArray(t)?t.map(Ct):String(t)}function _t(t,e,r,n,i){return K.isFunction(n)?n.call(this,e,r):(i&&(e=r),K.isString(e)?K.isString(n)?-1!==e.indexOf(n):K.isRegExp(n)?n.test(e):void 0:void 0)}class xt{constructor(t){t&&this.set(t)}set(t,e,r){const n=this;function i(t,e,r){const i=Et(e);if(!i)throw new Error("header name must be a non-empty string");const o=K.findKey(n,i);(!o||void 0===n[o]||!0===r||void 0===r&&!1!==n[o])&&(n[o||e]=Ct(t))}const o=(t,e)=>K.forEach(t,(t,r)=>i(t,r,e));if(K.isPlainObject(t)||t instanceof this.constructor)o(t,e);else if(K.isString(t)&&(t=t.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()))o((t=>{const e={};let r,n,i;return t&&t.split("\n").forEach(function(t){i=t.indexOf(":"),r=t.substring(0,i).trim().toLowerCase(),n=t.substring(i+1).trim(),!r||e[r]&&wt[r]||("set-cookie"===r?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e})(t),e);else if(K.isObject(t)&&K.isIterable(t)){let r,n,i={};for(const e of t){if(!K.isArray(e))throw TypeError("Object iterator must return a key-value pair");i[n=e[0]]=(r=i[n])?K.isArray(r)?[...r,e[1]]:[r,e[1]]:e[1]}o(i,e)}else null!=t&&i(e,t,r);return this}get(t,e){if(t=Et(t)){const r=K.findKey(this,t);if(r){const t=this[r];if(!e)return t;if(!0===e)return function(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}(t);if(K.isFunction(e))return e.call(this,t,r);if(K.isRegExp(e))return e.exec(t);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=Et(t)){const r=K.findKey(this,t);return!(!r||void 0===this[r]||e&&!_t(0,this[r],r,e))}return!1}delete(t,e){const r=this;let n=!1;function i(t){if(t=Et(t)){const i=K.findKey(r,t);!i||e&&!_t(0,r[i],i,e)||(delete r[i],n=!0)}}return K.isArray(t)?t.forEach(i):i(t),n}clear(t){const e=Object.keys(this);let r=e.length,n=!1;for(;r--;){const i=e[r];t&&!_t(0,this[i],i,t,!0)||(delete this[i],n=!0)}return n}normalize(t){const e=this,r={};return K.forEach(this,(n,i)=>{const o=K.findKey(r,i);if(o)return e[o]=Ct(n),void delete e[i];const s=t?function(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,r)=>e.toUpperCase()+r)}(i):String(i).trim();s!==i&&delete e[i],e[s]=Ct(n),r[s]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return K.forEach(this,(r,n)=>{null!=r&&!1!==r&&(e[n]=t&&K.isArray(r)?r.join(", "):r)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const r=new this(t);return e.forEach(t=>r.set(t)),r}static accessor(t){const e=(this[St]=this[St]={accessors:{}}).accessors,r=this.prototype;function n(t){const n=Et(t);e[n]||(function(t,e){const r=K.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(t,r,i){return this[n].call(this,e,t,r,i)},configurable:!0})})}(r,t),e[n]=!0)}return K.isArray(t)?t.forEach(n):n(t),this}}xt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),K.reduceDescriptors(xt.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[r]=t}}}),K.freezeMethods(xt);var Ot=xt;function At(t,e){const r=this||bt,n=e||r,i=Ot.from(n.headers);let o=n.data;return K.forEach(t,function(t){o=t.call(r,o,i.normalize(),e?e.status:void 0)}),i.normalize(),o}function Tt(t){return!(!t||!t.__CANCEL__)}function Nt(t,e,r){J.call(this,null==t?"canceled":t,J.ERR_CANCELED,e,r),this.name="CanceledError"}function Rt(t,e,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(new J("Request failed with status code "+r.status,[J.ERR_BAD_REQUEST,J.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}K.inherits(Nt,J,{__CANCEL__:!0});const It=(t,e,r=3)=>{let n=0;const i=function(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i,o=0,s=0;return e=void 0!==e?e:1e3,function(a){const u=Date.now(),l=n[s];i||(i=u),r[o]=a,n[o]=u;let c=s,h=0;for(;c!==o;)h+=r[c++],c%=t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),u-i<e)return;const f=l&&u-l;return f?Math.round(1e3*h/f):void 0}}(50,250);return function(r,o){let s,a,u=0,l=1e3/o;const c=(r,o=Date.now())=>{u=o,s=null,a&&(clearTimeout(a),a=null),(r=>{const o=r.loaded,s=r.lengthComputable?r.total:void 0,a=o-n,u=i(a);n=o,t({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:u||void 0,estimated:u&&s&&o<=s?(s-o)/u:void 0,event:r,lengthComputable:null!=s,[e?"download":"upload"]:!0})})(...r)};return[(...t)=>{const e=Date.now(),r=e-u;r>=l?c(t,e):(s=t,a||(a=setTimeout(()=>{a=null,c(s)},l-r)))},()=>s&&c(s)]}(0,r)},kt=(t,e)=>{const r=null!=t;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},Lt=t=>(...e)=>K.asap(()=>t(...e));var Pt=yt.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,yt.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(yt.origin),yt.navigator&&/(msie|trident)/i.test(yt.navigator.userAgent)):()=>!0,Bt=yt.hasStandardBrowserEnv?{write(t,e,r,n,i,o,s){if("undefined"==typeof document)return;const a=[`${t}=${encodeURIComponent(e)}`];K.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),K.isString(n)&&a.push(`path=${n}`),K.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),K.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(t){if("undefined"==typeof document)return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function jt(t,e,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);return t&&(n||0==r)?function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}(t,e):e}const Mt=t=>t instanceof Ot?{...t}:t;function Dt(t,e){e=e||{};const r={};function n(t,e,r,n){return K.isPlainObject(t)&&K.isPlainObject(e)?K.merge.call({caseless:n},t,e):K.isPlainObject(e)?K.merge({},e):K.isArray(e)?e.slice():e}function i(t,e,r,i){return K.isUndefined(e)?K.isUndefined(t)?void 0:n(void 0,t,0,i):n(t,e,0,i)}function o(t,e){if(!K.isUndefined(e))return n(void 0,e)}function s(t,e){return K.isUndefined(e)?K.isUndefined(t)?void 0:n(void 0,t):n(void 0,e)}function a(r,i,o){return o in e?n(r,i):o in t?n(void 0,r):void 0}const u={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(t,e,r)=>i(Mt(t),Mt(e),0,!0)};return K.forEach(Object.keys({...t,...e}),function(n){const o=u[n]||i,s=o(t[n],e[n],n);K.isUndefined(s)&&o!==a||(r[n]=s)}),r}var Ut=t=>{const e=Dt({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=e;if(e.headers=s=Ot.from(s),e.url=at(jt(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),K.isFormData(r))if(yt.hasStandardBrowserEnv||yt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(K.isFunction(r.getHeaders)){const t=r.getHeaders(),e=["content-type","content-length"];Object.entries(t).forEach(([t,r])=>{e.includes(t.toLowerCase())&&s.set(t,r)})}if(yt.hasStandardBrowserEnv&&(n&&K.isFunction(n)&&(n=n(e)),n||!1!==n&&Pt(e.url))){const t=i&&o&&Bt.read(o);t&&s.set(i,t)}return e},Ft="undefined"!=typeof XMLHttpRequest&&function(t){return new Promise(function(e,r){const n=Ut(t);let i=n.data;const o=Ot.from(n.headers).normalize();let s,a,u,l,c,{responseType:h,onUploadProgress:f,onDownloadProgress:p}=n;function d(){l&&l(),c&&c(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let g=new XMLHttpRequest;function y(){if(!g)return;const n=Ot.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Rt(function(t){e(t),d()},function(t){r(t),d()},{data:h&&"text"!==h&&"json"!==h?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:t,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(y)},g.onabort=function(){g&&(r(new J("Request aborted",J.ECONNABORTED,t,g)),g=null)},g.onerror=function(e){const n=new J(e&&e.message?e.message:"Network Error",J.ERR_NETWORK,t,g);n.event=e||null,r(n),g=null},g.ontimeout=function(){let e=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||lt;n.timeoutErrorMessage&&(e=n.timeoutErrorMessage),r(new J(e,i.clarifyTimeoutError?J.ETIMEDOUT:J.ECONNABORTED,t,g)),g=null},void 0===i&&o.setContentType(null),"setRequestHeader"in g&&K.forEach(o.toJSON(),function(t,e){g.setRequestHeader(e,t)}),K.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),h&&"json"!==h&&(g.responseType=n.responseType),p&&([u,c]=It(p,!0),g.addEventListener("progress",u)),f&&g.upload&&([a,l]=It(f),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(s=e=>{g&&(r(!e||e.type?new Nt(null,t,g):e),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const m=function(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}(n.url);m&&-1===yt.protocols.indexOf(m)?r(new J("Unsupported protocol "+m+":",J.ERR_BAD_REQUEST,t)):g.send(i||null)})},$t=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let r,n=new AbortController;const i=function(t){if(!r){r=!0,s();const e=t instanceof Error?t:this.reason;n.abort(e instanceof J?e:new Nt(e instanceof Error?e.message:e))}};let o=e&&setTimeout(()=>{o=null,i(new J(`timeout ${e} of ms exceeded`,J.ETIMEDOUT))},e);const s=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(t=>{t.unsubscribe?t.unsubscribe(i):t.removeEventListener("abort",i)}),t=null)};t.forEach(t=>t.addEventListener("abort",i));const{signal:a}=n;return a.unsubscribe=()=>K.asap(s),a}};const Vt=function*(t,e){let r=t.byteLength;if(!e||r<e)return void(yield t);let n,i=0;for(;i<r;)n=i+e,yield t.slice(i,n),i=n},zt=(t,e,r,n)=>{const i=async function*(t,e){for await(const r of async function*(t){if(t[Symbol.asyncIterator])return void(yield*t);const e=t.getReader();try{for(;;){const{done:t,value:r}=await e.read();if(t)break;yield r}}finally{await e.cancel()}}(t))yield*Vt(r,e)}(t,e);let o,s=0,a=t=>{o||(o=!0,n&&n(t))};return new ReadableStream({async pull(t){try{const{done:e,value:n}=await i.next();if(e)return a(),void t.close();let o=n.byteLength;if(r){let t=s+=o;r(t)}t.enqueue(new Uint8Array(n))}catch(t){throw a(t),t}},cancel:t=>(a(t),i.return())},{highWaterMark:2})},{isFunction:Gt}=K,qt=(({Request:t,Response:e})=>({Request:t,Response:e}))(K.global),{ReadableStream:Wt,TextEncoder:Ht}=K.global,Kt=(t,...e)=>{try{return!!t(...e)}catch(t){return!1}},Jt=t=>{t=K.merge.call({skipUndefined:!0},qt,t);const{fetch:e,Request:r,Response:n}=t,i=e?Gt(e):"function"==typeof fetch,o=Gt(r),s=Gt(n);if(!i)return!1;const a=i&&Gt(Wt),u=i&&("function"==typeof Ht?(l=new Ht,t=>l.encode(t)):async t=>new Uint8Array(await new r(t).arrayBuffer()));var l;const c=o&&a&&Kt(()=>{let t=!1;const e=new r(yt.origin,{body:new Wt,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),h=s&&a&&Kt(()=>K.isReadableStream(new n("").body)),f={stream:h&&(t=>t.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!f[t]&&(f[t]=(e,r)=>{let n=e&&e[t];if(n)return n.call(e);throw new J(`Response type '${t}' is not supported`,J.ERR_NOT_SUPPORT,r)})});return async t=>{let{url:i,method:s,data:a,signal:l,cancelToken:p,timeout:d,onDownloadProgress:g,onUploadProgress:y,responseType:m,headers:v,withCredentials:b="same-origin",fetchOptions:w}=Ut(t),S=e||fetch;m=m?(m+"").toLowerCase():"text";let E=$t([l,p&&p.toAbortSignal()],d),C=null;const _=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let x;try{if(y&&c&&"get"!==s&&"head"!==s&&0!==(x=await(async(t,e)=>{const n=K.toFiniteNumber(t.getContentLength());return null==n?(async t=>{if(null==t)return 0;if(K.isBlob(t))return t.size;if(K.isSpecCompliantForm(t)){const e=new r(yt.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}return K.isArrayBufferView(t)||K.isArrayBuffer(t)?t.byteLength:(K.isURLSearchParams(t)&&(t+=""),K.isString(t)?(await u(t)).byteLength:void 0)})(e):n})(v,a))){let t,e=new r(i,{method:"POST",body:a,duplex:"half"});if(K.isFormData(a)&&(t=e.headers.get("content-type"))&&v.setContentType(t),e.body){const[t,r]=kt(x,It(Lt(y)));a=zt(e.body,65536,t,r)}}K.isString(b)||(b=b?"include":"omit");const e=o&&"credentials"in r.prototype,l={...w,signal:E,method:s.toUpperCase(),headers:v.normalize().toJSON(),body:a,duplex:"half",credentials:e?b:void 0};C=o&&new r(i,l);let p=await(o?S(C,w):S(i,l));const d=h&&("stream"===m||"response"===m);if(h&&(g||d&&_)){const t={};["status","statusText","headers"].forEach(e=>{t[e]=p[e]});const e=K.toFiniteNumber(p.headers.get("content-length")),[r,i]=g&&kt(e,It(Lt(g),!0))||[];p=new n(zt(p.body,65536,r,()=>{i&&i(),_&&_()}),t)}m=m||"text";let O=await f[K.findKey(f,m)||"text"](p,t);return!d&&_&&_(),await new Promise((e,r)=>{Rt(e,r,{data:O,headers:Ot.from(p.headers),status:p.status,statusText:p.statusText,config:t,request:C})})}catch(e){if(_&&_(),e&&"TypeError"===e.name&&/Load failed|fetch/i.test(e.message))throw Object.assign(new J("Network Error",J.ERR_NETWORK,t,C),{cause:e.cause||e});throw J.from(e,e&&e.code,t,C)}}},Qt=new Map,Yt=t=>{let e=t&&t.env||{};const{fetch:r,Request:n,Response:i}=e,o=[n,i,r];let s,a,u=o.length,l=Qt;for(;u--;)s=o[u],a=l.get(s),void 0===a&&l.set(s,a=u?new Map:Jt(e)),l=a;return a};Yt();const Xt={http:null,xhr:Ft,fetch:{get:Yt}};K.forEach(Xt,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}});const Zt=t=>`- ${t}`,te=t=>K.isFunction(t)||null===t||!1===t;var ee=function(t,e){t=K.isArray(t)?t:[t];const{length:r}=t;let n,i;const o={};for(let s=0;s<r;s++){let r;if(n=t[s],i=n,!te(n)&&(i=Xt[(r=String(n)).toLowerCase()],void 0===i))throw new J(`Unknown adapter '${r}'`);if(i&&(K.isFunction(i)||(i=i.get(e))))break;o[r||"#"+s]=i}if(!i){const t=Object.entries(o).map(([t,e])=>`adapter ${t} `+(!1===e?"is not supported by the environment":"is not available in the build"));throw new J("There is no suitable adapter to dispatch the request "+(r?t.length>1?"since :\n"+t.map(Zt).join("\n"):" "+Zt(t[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function re(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Nt(null,t)}function ne(t){return re(t),t.headers=Ot.from(t.headers),t.data=At.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),ee(t.adapter||bt.adapter,t)(t).then(function(e){return re(t),e.data=At.call(t,t.transformResponse,e),e.headers=Ot.from(e.headers),e},function(e){return Tt(e)||(re(t),e&&e.response&&(e.response.data=At.call(t,t.transformResponse,e.response),e.response.headers=Ot.from(e.response.headers))),Promise.reject(e)})}const ie="1.13.2",oe={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{oe[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const se={};oe.transitional=function(t,e,r){function n(t,e){return"[Axios v"+ie+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return(r,i,o)=>{if(!1===t)throw new J(n(i," has been removed"+(e?" in "+e:"")),J.ERR_DEPRECATED);return e&&!se[i]&&(se[i]=!0,console.warn(n(i," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,i,o)}},oe.spelling=function(t){return(e,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};var ae={assertOptions:function(t,e,r){if("object"!=typeof t)throw new J("options must be an object",J.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const o=n[i],s=e[o];if(s){const e=t[o],r=void 0===e||s(e,o,t);if(!0!==r)throw new J("option "+o+" must be "+r,J.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new J("Unknown option "+o,J.ERR_BAD_OPTION)}},validators:oe};const ue=ae.validators;class le{constructor(t){this.defaults=t||{},this.interceptors={request:new ut,response:new ut}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const r=e.stack?e.stack.replace(/^.+\n/,""):"";try{t.stack?r&&!String(t.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(t.stack+="\n"+r):t.stack=r}catch(t){}}throw t}}_request(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},e=Dt(this.defaults,e);const{transitional:r,paramsSerializer:n,headers:i}=e;void 0!==r&&ae.assertOptions(r,{silentJSONParsing:ue.transitional(ue.boolean),forcedJSONParsing:ue.transitional(ue.boolean),clarifyTimeoutError:ue.transitional(ue.boolean)},!1),null!=n&&(K.isFunction(n)?e.paramsSerializer={serialize:n}:ae.assertOptions(n,{encode:ue.function,serialize:ue.function},!0)),void 0!==e.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),ae.assertOptions(e,{baseUrl:ue.spelling("baseURL"),withXsrfToken:ue.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let o=i&&K.merge(i.common,i[e.method]);i&&K.forEach(["delete","get","head","post","put","patch","common"],t=>{delete i[t]}),e.headers=Ot.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(a=a&&t.synchronous,s.unshift(t.fulfilled,t.rejected))});const u=[];let l;this.interceptors.response.forEach(function(t){u.push(t.fulfilled,t.rejected)});let c,h=0;if(!a){const t=[ne.bind(this),void 0];for(t.unshift(...s),t.push(...u),c=t.length,l=Promise.resolve(e);h<c;)l=l.then(t[h++],t[h++]);return l}c=s.length;let f=e;for(;h<c;){const t=s[h++],e=s[h++];try{f=t(f)}catch(t){e.call(this,t);break}}try{l=ne.call(this,f)}catch(t){return Promise.reject(t)}for(h=0,c=u.length;h<c;)l=l.then(u[h++],u[h++]);return l}getUri(t){return at(jt((t=Dt(this.defaults,t)).baseURL,t.url,t.allowAbsoluteUrls),t.params,t.paramsSerializer)}}K.forEach(["delete","get","head","options"],function(t){le.prototype[t]=function(e,r){return this.request(Dt(r||{},{method:t,url:e,data:(r||{}).data}))}}),K.forEach(["post","put","patch"],function(t){function e(e){return function(r,n,i){return this.request(Dt(i||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}le.prototype[t]=e(),le.prototype[t+"Form"]=e(!0)});var ce=le;class he{constructor(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(t){e=t});const r=this;this.promise.then(t=>{if(!r._listeners)return;let e=r._listeners.length;for(;e-- >0;)r._listeners[e](t);r._listeners=null}),this.promise.then=t=>{let e;const n=new Promise(t=>{r.subscribe(t),e=t}).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t(function(t,n,i){r.reason||(r.reason=new Nt(t,n,i),e(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=e=>{t.abort(e)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new he(function(e){t=e}),cancel:t}}}var fe=he;const pe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(pe).forEach(([t,e])=>{pe[e]=t});var de=pe;const ge=function t(e){const r=new ce(e),n=i(ce.prototype.request,r);return K.extend(n,ce.prototype,r,{allOwnKeys:!0}),K.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return t(Dt(e,r))},n}(bt);ge.Axios=ce,ge.CanceledError=Nt,ge.CancelToken=fe,ge.isCancel=Tt,ge.VERSION=ie,ge.toFormData=rt,ge.AxiosError=J,ge.Cancel=ge.CanceledError,ge.all=function(t){return Promise.all(t)},ge.spread=function(t){return function(e){return t.apply(null,e)}},ge.isAxiosError=function(t){return K.isObject(t)&&!0===t.isAxiosError},ge.mergeConfig=Dt,ge.AxiosHeaders=Ot,ge.formToJSON=t=>mt(K.isHTMLForm(t)?new FormData(t):t),ge.getAdapter=ee,ge.HttpStatusCode=de,ge.default=ge,t.exports=ge},922:(t,e,r)=>{"use strict";var n=r(961),i=r(24);e.hp=a,e.IS=50;var o=2147483647;function s(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=a.prototype,e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=s(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return h(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return(n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r)).__proto__=a.prototype,n}(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);var i=function(t){if(a.isBuffer(t)){var e=0|f(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||V(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return l(t),s(t<0?0:0|f(t))}function h(t){for(var e=t.length<0?0:0|f(t.length),r=s(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t){if(t>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function p(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(t).length;default:if(i)return n?-1:D(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var c=-1;for(o=r;o<a;o++)if(l(t,o)===l(e,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var h=!0,f=0;f<u;f++)if(l(t,o+f)!==l(e,f)){h=!1;break}if(h)return o}return-1}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(V(a))return s;t[r+s]=a}return s}function b(t,e,r,n){return F(D(e,t.length-r),t,r,n)}function w(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function S(t,e,r,n){return w(t,e,r,n)}function E(t,e,r,n){return F(U(e),t,r,n)}function C(t,e,r,n){return F(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,u,l=t[i],c=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h<=r)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=O));return r}(n)}a.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(t,e,r){return u(t,e,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return c(t)},a.allocUnsafeSlow=function(t){return c(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),$(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=a.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if($(o,Uint8Array)&&(o=a.from(o)),!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},a.byteLength=p,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):d.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},a.prototype.compare=function(t,e,r,n,i){if($(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(o,s),l=this.slice(n,i),c=t.slice(e,r),h=0;h<u;++h)if(l[h]!==c[h]){o=l[h],s=c[h];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return S(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var O=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function N(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=M(t[o]);return i}function R(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function I(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function B(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return n.__proto__=a.prototype,n},a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s|0)-a&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s|0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return B(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return B(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i=n-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,r,n);else if(this===t&&r<e&&e<n)for(var o=i-1;o>=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=a.isBuffer(t)?t:a.from(t,n),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%u]}return this};var j=/[^+/0-9A-Za-z-_]/g;function M(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function V(t){return t!=t}},961:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],u=o[1],l=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),c=0,h=u>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;a<u;a+=s)o.push(l(t,a,a+s>u?u:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function l(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};return(()=>{"use strict";r.d(n,{aq:()=>S,YJ:()=>N});class t{constructor(e=null){if(this.TYPE="Entity",this.uuid=t.counter++,this._parent=null,(e=e||{}).metadata)throw new Error("See where metadata is being passed")}get parent(){return this._parent}setParent(t){this._parent=t}debugValue(){return{type:this.TYPE}}toString(){return`Entity(id = ${this.uuid})`}equals(t,e=!1){return this.TYPE==t.TYPE}clone(){const t=this.newInstance();return this.copyTo(t),t}copyTo(t){}newInstance(){return new this.constructor}}t.counter=0;class e extends t{constructor(){super(...arguments),this.TYPE="TimedEntity"}equals(t){return super.equals(t)&&this.duration.equals(t.duration)}}function i(t,e){if(!t)throw new Error(e)}r(80).default;const o=Math.pow(2,32);Math.pow(2,64);class s{constructor(t,e,r){this.uuid=s.counter++,this._spawnedFrom=null,this.sourceState=null,this.cancelled=!1,this.timeStamp=-1,this.children=[],this.name=t,this.source=e,this.payload=r}get spawnedFrom(){return this._spawnedFrom}setSpawnedFrom(t){this._spawnedFrom=t,this._rootEvent=null==t?this:t.rootEvent}spawn(t,e,r){const n=new s(t,e,r);return n.setSpawnedFrom(this),this.children.push(n),n}get rootEvent(){return this._rootEvent}}s.counter=0;class a{constructor(){this.stateData=null,this.id=a.counter++}get name(){return this.constructor.name}enter(t){this.stateData=t}handle(t){}}a.counter=0;class u{constructor(){this._eventHub=new l}get eventHub(){return this._eventHub}set eventHub(t){const e=this._eventHub;this._eventHub=t,this.eventHubChanged(e)}eventHubChanged(t){console.log("WARNING - EventHub Change Listener not implemented: ",this.constructor.name)}}class l{constructor(){this._handlers={},this._events=[],this._inBatchMode=!1}on(t,e){return this._addHandler(t,this._handlers,e)}removeOn(t,e){return this._removeHandler(t,this._handlers,e)}_ensurestrings(t){return"string"==typeof t&&(t=t.split(",")),t.map(function(t){return t.trim()})}_addHandler(t,e,r){return this._ensurestrings(t).forEach(function(t){e[t]=e[t]||[],e[t].push(r)}),this}_removeHandler(t,e,r){return this._ensurestrings(t).forEach(function(t){const n=e[t]||[];for(let t=0;t<n.length;t++)if(n[t]==r){n.splice(t,1);break}}),this}emit(t,e,r){const n=new s(t,e,r);return this._inBatchMode?(this._events.push(n),!0):this.dispatchEvent(n)}dispatchEvent(t){const e=this._handlers[t.name]||[];for(const r of e)if(r(t),t.cancelled)return!1;return!0}startBatchMode(){return this._inBatchMode||(this._inBatchMode=!0),this}cancelBatch(){this._inBatchMode=!1,this._events=[]}commitBatch(){this._inBatchMode=!1,this.emit(l.BATCH_EVENTS,this,this._events),this._events=[]}}l.BATCH_EVENTS="BatchEvents";class c{constructor(...t){this._firstChild=null,this._lastChild=null,this._size=0;for(const e of t)this.pushBack(e)}toJSON(){return Array.from(this.values())}forEach(t){let e=this._firstChild,r=0;for(;null!=e&&0!=t(e);)r++,e=e.nextSibling;return r}equals(t,e){if(this.size!=t.size)return!1;let r=this.first,n=t.first;for(;null!=r&&null!=n;r=r.nextSibling,n=n.nextSibling)if(!e(r,n))return!1;return null==r&&null==n}get isEmpty(){return 0==this._size}get size(){return this._size}get first(){return this._firstChild}get last(){return this._lastChild}*reversedValues(){let t=this._lastChild;for(;null!=t;)yield t,t=t.prevSibling}*values(){let t=this._firstChild;for(;null!=t;)yield t,t=t.nextSibling}add(t,e=null){if(null!=t.nextSibling||null!=t.prevSibling)throw new Error("New node already added to a list. Remove it first");if(t.nextSibling=t.prevSibling=null,this._size++,null==this._firstChild||null==this._lastChild)this._firstChild=this._lastChild=t;else if(null==e)t.prevSibling=this._lastChild,t.nextSibling=null,this._lastChild.nextSibling=t,this._lastChild=t;else if(e==this._firstChild)t.nextSibling=e,t.prevSibling=null,this._firstChild.prevSibling=t,this._firstChild=t;else{const r=e.prevSibling;t.nextSibling=e,e.prevSibling=t,t.prevSibling=r,null!=r&&(r.nextSibling=t)}return this}pushFront(t){return this.add(t,this._firstChild)}pushBack(t){return this.add(t)}remove(t){const e=t.nextSibling,r=t.prevSibling;return null==e?(this._lastChild=r,null==r&&(this._firstChild=null)):e.prevSibling=r,null==r?(this._firstChild=e,null==e&&(this._lastChild=null)):r.nextSibling=e,this._size--,t.prevSibling=t.nextSibling=null,this}popBack(){if(null==this._lastChild)throw new Error("No children");const t=this._lastChild;return this.remove(t),t}popFront(){if(null==this._firstChild)throw new Error("No children");const t=this._firstChild;return this.remove(t),t}}class h{}function f(t,e){for(t=Math.abs(t),e=Math.abs(e);e>0;){const r=e;e=t%e,t=r}return t}h.IS_EXPLORER=()=>navigator&&navigator.userAgent.indexOf("MSIE")>-1,h.IS_FIREFOX=()=>navigator&&navigator.userAgent.indexOf("Firefox")>-1,h.IS_OPERA=()=>navigator&&navigator.userAgent.toLowerCase().indexOf("op")>-1,h.UAHasChrome=()=>navigator&&navigator.userAgent.indexOf("Chrome")>-1,h.UAHasSafari=()=>navigator&&navigator.userAgent.indexOf("Safari")>-1,h.IS_SAFARI=()=>navigator&&h.UAHasSafari()&&(!h.UAHasChrome()||!h.UAHasSafari()),h.IS_CHROME=()=>navigator&&h.UAHasChrome()&&(!h.UAHasChrome()||!h.IS_OPERA());class p{constructor(t=0,e=1,r=!1){if(isNaN(t)||isNaN(e))throw new Error(`Invalid numerator(${t}) or denminator(${e})`);if(r){const r=f(t,e);t/=r,e/=r}this.num=t,this.den=e}static parse(t,e=!1){const r=t.trim().split("/").map(t=>t.trim());let n=1,i=1;if(1==r.length)n=parseInt(r[0]);else{if(2!=r.length)throw new Error("Invalid fraction string: "+t);r[0].length>0&&(n=parseInt(r[0])),r[1].length>0&&(i=parseInt(r[1]))}if(isNaN(n)||isNaN(i))throw new Error("Invalid fraction string: "+t);return new p(n,i,e)}get isWhole(){return this.num%this.den==0}get isZero(){return 0==this.num}get isInfinity(){return 0==this.den}get isOne(){return this.num==this.den}get ceil(){return this.num%this.den==0?this.num/this.den:1+Math.floor(this.num/this.den)}get floor(){return this.num%this.den==0?this.num/this.den:Math.floor(this.num/this.den)}plus(t,e=!1){return new p(this.num*t.den+this.den*t.num,this.den*t.den,e)}plusNum(t,e=!1){return new p(this.num+this.den*t,this.den,e)}minus(t,e=!1){return new p(this.num*t.den-this.den*t.num,this.den*t.den,e)}minusNum(t,e=!1){return new p(this.num-this.den*t,this.den,e)}times(t,e=!1){return new p(this.num*t.num,this.den*t.den,e)}timesNum(t,e=!1){return new p(this.num*t,this.den,e)}divby(t,e=!1){return new p(this.num*t.den,this.den*t.num,e)}divbyNum(t,e=!1){return new p(this.num,this.den*t,e)}numDivby(t,e=!1){return new p(this.den*t,this.num,e)}mod(t){const e=this.divby(t),r=Math.floor(e.num/e.den);return this.minus(t.timesNum(r))}modNum(t){const e=this.divbyNum(t),r=Math.floor(e.num/e.den);return this.minusNum(t*r)}get inverse(){return new p(this.den,this.num)}get factorized(){const t=f(this.num,this.den);return new p(this.num/t,this.den/t)}equals(t){return this.num*t.den==this.den*t.num}equalsNum(t){return this.num==this.den*t}cmp(t){return this.num*t.den-this.den*t.num}cmpNum(t){return this.num-this.den*t}isLT(t){return this.cmp(t)<0}isLTE(t){return this.cmp(t)<=0}isLTNum(t){return this.cmpNum(t)<0}isLTENum(t){return this.cmpNum(t)<=0}isGT(t){return this.cmp(t)>0}isGTE(t){return this.cmp(t)>=0}isGTNum(t){return this.cmpNum(t)>0}isGTENum(t){return this.cmpNum(t)>=0}toString(){return this.num+"/"+this.den}static max(t,e){return t.cmp(e)>0?t:e}static min(t,e){return t.cmp(e)<0?t:e}}p.ZERO=new p,p.ONE=new p(1,1),p.INFINITY=new p(1,0);const d=(t=0,e=1,r=!1)=>new p(t,e,r),g=p.ZERO;p.ONE;class y{constructor(t,e=0,r=0,n=0){this.cycle=t,this.barIndex=e,this.beatIndex=r,this.instance=n}get next(){const t=this.cycle.bars[this.barIndex],e=[[this.barIndex,this.beatIndex,this.instance],t.beatLengths[this.beatIndex]];return this.instance++,(!t.beatCounts[this.beatIndex]||this.instance>=t.beatCounts[this.beatIndex])&&(this.instance=0,this.beatIndex++,this.beatIndex>=t.beatLengths.length&&(this.beatIndex=0,this.barIndex++,this.barIndex>=this.cycle.bars.length&&(this.barIndex=0))),e}get prev(){const t=this.cycle.bars[this.barIndex],e=[[this.barIndex,this.beatIndex,this.instance],t.beatLengths[this.beatIndex]];return this.instance--,this.instance<0&&(this.beatIndex--,this.beatIndex<0&&(this.barIndex--,this.barIndex<0&&(this.barIndex=this.cycle.bars.length-1),this.beatIndex=this.cycle.bars[this.barIndex].beatCount-1),this.instance=(this.cycle.bars[this.barIndex].beatCounts[this.beatIndex]||1)-1),e}}class m extends e{constructor(t=null){super(t=t||{}),this.TYPE="Bar",this.beatLengths=[],this.beatCounts=[],this.name=t.name||"";for(const e of t.beatLengths||[])"number"==typeof e?this.beatLengths.push(d(e)):this.beatLengths.push(e);for(const e of t.beatCounts||[])this.beatCounts.push(e);for(;this.beatCounts.length<this.beatLengths.length;)this.beatCounts.push(1)}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{name,beatLengths:this.beatLengths})}equals(t){if(!super.equals(t))return!1;if(this.beatLengths.length!=t.beatLengths.length)return!1;if(this.beatCounts.length!=t.beatCounts.length)return!1;for(let e=0;e<this.beatLengths.length;e++)if(!this.beatLengths[e].equals(t.beatLengths[e]))return!1;for(let e=0;e<this.beatCounts.length;e++)if(this.beatCounts[e]!=t.beatCounts[e])return!1;return!0}copyTo(t){super.copyTo(t),t.name=this.name,t.beatLengths=[...this.beatLengths],t.beatCounts=[...this.beatCounts]}instanceCount(t){return t>this.beatCounts.length?1:this.beatCounts[t]}get beatCount(){return this.beatLengths.length}get totalBeatCount(){let t=0;for(let e=0;e<this.beatLengths.length;e++)t+=this.beatCounts[e]||1;return t}get duration(){let t=g;for(let e=0;e<this.beatLengths.length;e++)t=t.plus(this.beatLengths[e].timesNum(this.beatCounts[e]||1));return t}}class v extends e{constructor(t=null){super(t=t||{}),this.TYPE="Cycle",this.name=t.name||"",this.bars=t.bars||[]}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{name,bars:this.bars.map(t=>t.debugValue())})}children(){return this.bars}equals(t){if(!super.equals(t))return!1;if(this.bars.length!=t.bars.length)return!1;for(let e=0;e<this.bars.length;e++)if(!this.bars[e].equals(t.bars[e]))return!1;return!0}getAtIndex(t){let e=0;for(;t<0;)t+=this.totalBeatCount,e--;t>=this.totalBeatCount&&(e=Math.floor(t/this.totalBeatCount)),t%=this.totalBeatCount;let r=g;for(let n=0;n<this.bars.length;n++){const i=this.bars[n];if(t>=i.totalBeatCount)t-=i.totalBeatCount,r=r.plus(i.duration);else for(let o=0;o<i.beatCount;o++){const s=i.beatLengths[o],a=i.beatCounts[o]||1;if(!(t>=a)){const i=t;return[e,[n,o,i],r.plus(s.timesNum(i))]}t-=a,r=r.plus(s.timesNum(a))}}throw new Error("Should not be here!")}getPosition(t){const e=this.duration;let r=0;if(t.isLT(g))for(;t.isLT(g);)r--,t=t.plus(e);else if(t.isGTE(e)){const n=t.mod(e);i((t=t.minus(n).divby(e)).isWhole),r=t.floor,t=n}let n=0;for(let e=0;e<this.bars.length;e++){const i=this.bars[e],o=i.duration;if(t.isGTE(o))t=t.minus(o);else for(let o=0;o<i.beatCount;o++){const s=i.beatLengths[o],a=i.beatCounts[o]||1;for(let i=0;i<a;i++,n++){if(!t.isGTE(s))return[r,[e,o,i],t,n];t=t.minus(s)}}n+=i.totalBeatCount}throw new Error("Should not be here!")}*iterateBeats(t=0,e=0,r=0){let n=t,i=e,o=r;for(;;){const t=this.bars[n];yield[[n,i,o],t.beatLengths[i]],o++,(!t.beatCounts[i]||o>=t.beatCounts[i])&&(o=0,i++,i>=t.beatLengths.length&&(i=0,n++,n>=this.bars.length&&(n=0)))}}copyTo(t){super.copyTo(t),t.name=this.name,t.bars=this.bars.map(t=>t.clone())}get beatCount(){let t=0;for(const e of this.bars)t+=e.beatCount;return t}get totalBeatCount(){let t=0;for(const e of this.bars)t+=e.totalBeatCount;return t}get duration(){return this.bars.reduce((t,e)=>t.plus(e.duration),g)}}v.DEFAULT=new v({name:"Adi Thalam",bars:[new m({name:"Laghu",beatLengths:[1,1,1,1]}),new m({name:"Dhrutam",beatLengths:[1,1]}),new m({name:"Dhrutam",beatLengths:[1,1]})]});const b=p.ZERO,w=p.ONE;var S,E;(E=S||(S={})).NOTE="Note",E.LITERAL="Literal",E.SYLLABLE="Syllable",E.SPACE="Space",E.GROUP="Group",E.LABEL="Label",E.REST="Rest",E.MARKER="Marker";class C extends e{constructor(t=w){super(),this.TYPE="Atom",this.nextSibling=null,this.prevSibling=null,this.parentGroup=null,this.isContinuation=!1,this._duration=t||w}debugValue(){const t=super.debugValue();return this.duration.isOne||(t.duration=this.duration.factorized.toString()),this.isContinuation&&(t.isContinuation=!0),(this.markersBefore||[]).length>0&&(t.mbef=this.markersBefore.map(t=>t.debugValue())),(this.markersAfter||[]).length>0&&(t.maft=this.markersAfter.map(t=>t.debugValue())),t}copyTo(t){super.copyTo(t),t._duration=new p(this.duration.num,this.duration.den)}get duration(){return this._duration}set duration(t){this._duration=t}}class _ extends C{constructor(){super(...arguments),this.TYPE="LeafAtom",this.beforeRest=!1}splitAt(t){if(this.duration.cmp(t)>0){const e=this.createSpilloverSpace(this.duration.minus(t));return e.isContinuation=!0,this.duration=t,e}return null}createSpilloverSpace(t){return new O(t)}debugValue(){return this.beforeRest?Object.assign(Object.assign({},super.debugValue()),{beforeRest:!0}):super.debugValue()}}class x extends t{constructor(t,e=!0){super(),this.text=t,this.isBefore=e,this.TYPE="Marker"}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{text:this.text,before:this.isBefore})}toString(){return`Marker(${this.text}-${this.isBefore})`}}class O extends _{constructor(t=w,e=!1){super(t),this.TYPE="Space",this.isSilent=!1,this.isSilent=e}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{isSilent:this.isSilent})}toString(){return`Space(${this.duration}-${this.isSilent})`}copyTo(t){super.copyTo(t),t.isSilent=this.isSilent}equals(t){return super.equals(t)&&this.isSilent==t.isSilent}createSpilloverSpace(t){const e=super.createSpilloverSpace(t);return e.isSilent=this.isSilent,e}}class A extends _{constructor(t,e=w){super(e),this.value=t,this.TYPE="Literal",this.embelishments=[]}debugValue(){const t=Object.assign(Object.assign({},super.debugValue()),{value:this.value});return this.embelishments.length>0&&(t.embs=this.embelishments.map(t=>"debugValue"in t?t.debugValue():t)),t}toString(){return`Lit(${this.duration}-${this.value})`}equals(t){return super.equals(t)&&this.value==t.value}copyTo(t){super.copyTo(t),t.value=this.value}}class T extends A{constructor(t,e=w,r=0,n=0){super(t,e),this.TYPE="Note",this.octave=0,this.shift=0,this.octave=r,this.shift=n}static fromLit(t){if(t.TYPE==S.NOTE)return t;const e=new T(t.value,t.duration);return e.embelishments=t.embelishments,e.beforeRest=t.beforeRest,e}debugValue(){const t=Object.assign({},super.debugValue());return 0!=this.octave&&(t.octave=this.octave),0!=this.shift&&(t.shift=this.shift),t}toString(){return`Note(${this.duration}-${this.value}-${this.octave})`}equals(t){return super.equals(t)&&this.octave==t.octave&&this.shift==t.shift}copyTo(t){super.copyTo(t),t.octave=this.octave,t.shift=this.shift}}class N extends C{constructor(...t){super(0==t.length?b:w),this.TYPE="Group",this.durationIsMultiplier=!1,this.atoms=new c,this.addAtoms(!1,...t)}equals(t,e=!1){return!!super.equals(t)&&this.atoms.equals(t.atoms,(t,e)=>t.equals(e))}copyTo(t){super.copyTo(t),t.durationIsMultiplier=this.durationIsMultiplier,this.atoms.forEach(e=>t.atoms.add(e.clone()))}get duration(){return this.durationIsMultiplier?this.totalChildDuration.divby(this._duration):this._duration}setDurationAsMultiplier(t=!0){return this.durationIsMultiplier=t,this}setDuration(t,e=!1){return this._duration=t,this.durationIsMultiplier=e,this}debugValue(){const t=Object.assign(Object.assign({},super.debugValue()),{atoms:Array.from(this.atoms.values(),t=>t.debugValue())});return this.durationIsMultiplier&&(t.durationIsMultiplier=!0),t}splitAt(t){if(this.duration.isLTE(t)||t.isLTE(b))return null;const e=new N;this.durationIsMultiplier&&(e.durationIsMultiplier=!0,e._duration=this._duration);let r=this.duration;const n=this.totalChildDuration,i=this.durationIsMultiplier?w.divby(this._duration):this._duration.divby(n,!0);for(;r.isGT(t)&&this.atoms.last;){const n=this.atoms.last,o=n.duration.times(i),s=r.minus(o);if(!s.isGTE(t)){const r=t.minus(s,!0).divby(i,!0),o=n.splitAt(r);if(null==o)throw new Error("Spill over cannot be null here");if(this.durationIsMultiplier){if(this._duration.isZero)throw new Error("How can this be?")}else this._duration=t;return o.isContinuation=!0,e.insertAtomsAt(e.atoms.first,!0,o),e}if(this.removeAtoms(!0,n),e.insertAtomsAt(e.atoms.first,!0,n),s.equals(t))return e;r=s}return e}get totalChildDuration(){let t=b;return this.atoms.forEach(e=>t=t.plus(e.duration)),t}insertAtomsAt(t,e=!1,...r){const n=(e=e&&!this.durationIsMultiplier)?this.totalChildDuration:w;for(const e of r){if(null!=e.parentGroup){if(e.parentGroup!=this)throw new Error("Atom belongs to another parent. Remove it first");e.parentGroup.removeAtoms(!1,e)}if(e.TYPE==S.REST){const t=this.atoms.last;t&&t.TYPE!=S.GROUP&&t.TYPE!=S.LABEL&&(t.beforeRest=!0)}else e.parentGroup=this,this.atoms.add(e,t)}if(e)if(this._duration.isZero){if(this.durationIsMultiplier)throw new Error("How can this be?");this._duration=this.totalChildDuration}else{const t=this.totalChildDuration.divby(n);this._duration=this._duration.times(t,!0)}return this}addAtoms(t=!1,...e){return this.insertAtomsAt(null,t,...e)}removeAtoms(t=!1,...e){const r=(t=t&&!this.durationIsMultiplier)?this.totalChildDuration:w;for(const t of e)if(t.parentGroup==this)this.atoms.remove(t),t.parentGroup=null;else if(null!=t.parentGroup)throw new Error("Atom cannot be removed as it does not belong to this group");if(t)if(this._duration.isZero){if(this.durationIsMultiplier)throw new Error("How can this be?");this._duration=this.totalChildDuration}else{const t=this.totalChildDuration.divby(r);this._duration=this._duration.times(t,!0)}return this}}const R=p.ZERO;class I{constructor(t){this.uuid=I.counter++,t=t||{},this.beatDuration=t.beatDuration||1,"cycle"in t&&(this.cycle=t.cycle),this.cycle&&!this.cycle.duration.isZero||(this.cycle=v.DEFAULT),this._rowStartOffsets=[],this._rowEndOffsets=[],this._rowDurations=[],this._totalLayoutDuration=R,this._totalBeats=0,this._beatLayouts=[],this.lineBreaks=t.lineBreaks||t.layout||[]}equals(t){return this.beatDuration==t.beatDuration&&this.cycle.equals(t.cycle)&&this.lineBreaksEqual(t._lineBreaks)}lineBreaksEqual(t){return this._lineBreaks.length==t.length&&this._lineBreaks.every((e,r)=>e==t[r])}debugValue(){var t;return{cycle:null===(t=this.cycle)||void 0===t?void 0:t.debugValue(),beatDuration:this.beatDuration,lineBreaks:this._lineBreaks}}getBeatLocation(t){const e=t.index%this.totalBeats;let r=0;for(let n=0;n<this._lineBreaks.length;n++){if(e<r+this._lineBreaks[n]){let i=R;if(e>r){const n=new y(this.cycle,t.barIndex,t.beatIndex,t.instance);let[,o]=n.prev;for(let t=r;t<e;t++)[,o]=n.prev,i=i.plus(o.timesNum(this.beatDuration))}return[n,e-r,i]}r+=this._lineBreaks[n]}throw new Error("Invalid beat index: "+t.index)}get lineBreaks(){return this._lineBreaks&&0!=this._lineBreaks.length||(this.lineBreaks=[this.cycle.beatCount]),this._lineBreaks}set lineBreaks(t){this._lineBreaks=t,this.refreshLayout()}get beatLayouts(){return(!this._beatLayouts||this._beatLayouts.length<this.lineBreaks.length)&&this.refreshLayout(),this._beatLayouts}get totalBeats(){return this.beatLayouts,this._totalBeats}get totalLayoutDuration(){return this.beatLayouts,this._totalLayoutDuration}refreshLayout(){const t=this.cycle.iterateBeats(),e=this.beatDuration;this._beatLayouts=this.lineBreaks.map((r,n)=>{const i=[];for(let n=0;n<r;n++){const r=t.next().value;r[1]=r[1].timesNum(e),i.push(r)}return i}),this._totalBeats=this.lineBreaks.reduce((t,e)=>t+e,0),this._rowDurations=this._beatLayouts.map(t=>t.reduce((t,e)=>t.plus(e[1]),R)),this._rowDurations.forEach((t,e)=>{this._rowStartOffsets[e]=0==e?R:this._rowStartOffsets[e-1].plus(t)}),this._rowEndOffsets=this._rowDurations.map((t,e)=>this._rowStartOffsets[e].plus(t)),this._totalLayoutDuration=this._rowDurations.reduce((t,e)=>t.plus(e),R)}}I.counter=0;class k extends u{constructor(){super(...arguments),this.uuid=k.idCounter++,this.lastUpdatedAt=0,this.rows=[],this.rowAligns=new Map,this.colAligns=new Map}debugValue(){return{rows:this.rows.map(t=>t.debugValue()),lastUpdatedAt:this.lastUpdatedAt}}get firstRow(){for(const t of this.rows)if(t.numCells>0)return t.rowIndex;return-1}get firstCol(){let t=-1;for(const e of this.rows){const r=e.firstCol;r>=0&&(t<0||r<t)&&(t=r)}return t}cellsInRow(t){const e=[],r=this.rows[t];if(r)for(const t of r.cells)(null==t?void 0:t.value)&&e.push(t);return e}cellsInCol(t){const e=[];for(const r of this.rows){const n=r.cellAt(t);(null==n?void 0:n.value)&&e.push(n)}return e}addRowAlign(t){this.rowAligns.set(t.uuid,t)}addColAlign(t){this.colAligns.set(t.uuid,t)}addRows(t=-1,e=1){t<0&&(t=this.rows.length);let r=this.rows[t]||null;const n=this.rows[t-1]||null;for(let i=e-1;i>=0;i--){const e=new B(this,t+i);this.rows.splice(t,0,e),null!=r&&e.defaultRowAlign.addSuccessor(r.defaultRowAlign),0==i&&t>0&&n.defaultRowAlign.addSuccessor(e.defaultRowAlign),r=e}for(let r=t+e;r<this.rows.length;r++)this.rows[r].rowIndex+=e;return this}getRow(t){return t>=this.rows.length&&this.addRows(-1,1+t-this.rows.length),this.rows[t]}setValue(t,e,r,n){var i,o;const s=this.getRow(t);if(n||(n=(t,e)=>new P(t,e)),null==r){const t=s.clearCellAt(e);return null!=t&&(null===(i=this.eventHub)||void 0===i||i.emit(L.CLEARED,this,{loc:t.location})),t}{const t=s.cellAt(e,n),i=t.value;return null===(o=this.eventHub)||void 0===o||o.emit(L.UPDATED,this,{loc:t.location,cell:t,oldValue:t.value}),t.value=r,i}}eventHubChanged(){console.log("Event Hub Changed for GridModel")}}var L;k.idCounter=0,function(t){t.ADDED="CellAdded",t.CLEARED="CellCleared",t.REMOVED="CellRemoved",t.UPDATED="CellUpdated",t.MOVED="CellMoved"}(L||(L={}));class P{constructor(t,e,r=null){this.gridRow=t,this.colIndex=e,this.value=r,this.uuid=P.idCounter++,this.rowAlign=t.defaultRowAlign}get rowAlign(){return this._rowAlign}set rowAlign(t){t.addCell(this),this._rowAlign=t}get colAlign(){return this._colAlign}set colAlign(t){t.addCell(this),this._colAlign=t}get location(){return this.gridRow.rowIndex+":"+this.colIndex}get grid(){return this.gridRow.grid}get rowIndex(){return this.gridRow.rowIndex}debugValue(){const t={r:this.gridRow.rowIndex,c:this.colIndex,value:this.value,y:this.rowAlign.coordOffset,h:this.rowAlign.maxLength};return this.colAlign&&(t.x=this.colAlign.coordOffset,t.w=this.colAlign.maxLength),t}}P.idCounter=0;class B{constructor(t,e){this.grid=t,this.rowIndex=e,this.cells=[],this.defaultRowAlign=new M,this.grid.addRowAlign(this.defaultRowAlign)}get firstCol(){var t;for(let e=0;e<this.cells.length;e++)if(null===(t=this.cells[e])||void 0===t?void 0:t.value)return e;return-1}get numCols(){return this.cells.length}get numCells(){let t=0;for(const e of this.cells)null!=e&&null!=e.value&&t++;return t}cellAt(t,e){let r=this.cells[t]||null;return!r&&e&&(this.cells[t]=r=e(this,t),r.gridRow=this,r.colIndex=t,r.rowAlign&&this.grid.addRowAlign(r.rowAlign),r.colAlign&&this.grid.addColAlign(r.colAlign)),r}clearCellAt(t){const e=this.cells[t]||null;return e&&(this.cells[t]=null),e}debugValue(){return{r:this.rowIndex,cells:this.cells.filter(t=>t).map(t=>null==t?void 0:t.debugValue())}}}class j{constructor(){this.uuid=j.idCounter++,this.needsLayout=!1,this._coordOffset=0,this._maxLength=0,this.paddingBefore=5,this.paddingAfter=5,this.cells=[],this.prevLines=[],this.nextLines=[]}get coordOffset(){return this._coordOffset}get maxLength(){return this._maxLength+this.paddingBefore+this.paddingAfter}setMaxLength(t){this._maxLength=t}setPadding(t,e){t>=0&&(this.paddingBefore=t),e>=0&&(this.paddingAfter=e)}addCell(t){return this.beforeAddingCell(t)&&this.cells.push(t),this}removeCell(t){if(this.beforeRemovingCell(t))for(let e=0;e<this.cells.length;e++)if(this.cells[e].uuid==t.uuid){this.cells.splice(e,1);break}return this}addSuccessor(t){for(const e of this.nextLines)if(e==t)return;this.nextLines.push(t),t.prevLines.push(this)}}j.idCounter=0;class M extends j{setOffset(t){this._coordOffset=t;for(const e of this.cells)if(e.value){const r=this.getCellView(e);this._maxLength<=0&&this.evalMaxLength(),r.setBounds(null,t,null,this.maxLength,!0)}}evalMaxLength(t=[]){this._maxLength=0;for(const t of this.cells)if(t.value){const e=this.getCellView(t);this._maxLength=Math.max(e.minSize.height,this._maxLength)}return this._maxLength}beforeAddingCell(t){return t.rowAlign&&t.rowAlign!=this&&t.rowAlign.removeCell(t),t.rowAlign!=this}beforeRemovingCell(t){return t.rowAlign==this}}p.ZERO;const D=p.ONE;class U{constructor(t,e,r,n,i,o,s,a,u){this.index=t,this.role=e,this.offset=r,this.duration=n,this.barIndex=i,this.beatIndex=o,this.instance=s,this.prevBeat=a,this.nextBeat=u,this.uuid=U.idCounter++,this.atomIsPlaceholder=!1}debugValue(){return{index:this.index,role:this.role.name,offset:this.offset.toString(),duration:this.duration.toString(),barIndex:this.barIndex,beatIndex:this.beatIndex,instance:this.instance,atom:this.atom.debugValue()}}get endOffset(){return this.offset.plus(this.duration)}get filled(){return this.remaining.isZero}get remaining(){return this.atom?this.duration.minus(this.atom.duration,!0):this.duration}add(t){return!(this.remaining.cmp(t.duration)<0||(this.atom?(this.atomIsPlaceholder||(this.atomIsPlaceholder=!0,this.atom=new N(this.atom).setDuration(D,!0)),this.atom.addAtoms(!0,t)):this.atom=t,0))}get preMarkers(){const t=[];let e=this.atom;for(;null!=e;){for(const r of e.markersBefore||[])t.push(r);e=e.TYPE==S.GROUP?e.atoms.first:null}return t}get postMarkers(){const t=[];let e=this.atom;for(;null!=e;)t.splice(0,0,...e.markersAfter||[]),e=e.TYPE==S.GROUP?e.atoms.last:null;return t}}U.idCounter=0;var F=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},$=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},V=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function z(t,e,r){var n=[],o={};return t.forEach(function(t){var s,a;if(!(e(t)in o))for(var u=t,l={},c=[[t,[]]];c.length>0;){for(var h=[],f=0;f<c.length;f++){var p=F(c[f],2),d=p[0],g=p[1];i(null!=d);var y=r(d),m=$([],F(g),!1);try{for(var v=(s=void 0,V(y)),b=v.next();!b.done;b=v.next()){var w=F(b.value,2),S=w[0],E=w[1];S==u?(m.push([E,S]),m.forEach(function(t,e){var r=F(t,2),n=(r[0],r[1]);return o[n]=!0}),n.push([u,m]),m=m.slice(0,m.length-1)):e(S)in l||(l[e(S)]=!0,h.push([S,$($([],F(m),!1),[[E,S]],!1)]))}}catch(t){s={error:t}}finally{try{b&&!b.done&&(a=v.return)&&a.call(v)}finally{if(s)throw s.error}}}c=h}}),n}var G,q,W=(G=function(t,e){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},G(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}G(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),H=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},J=function(t){return t.key},Q=(function(){function t(t){this.root=new Q,this.keyFunc=t}t.prototype.add=function(t,e){void 0===e&&(e=0);for(var r=this.root,n=e;n<t.length;n++){var i=this.keyFunc(t[n]);if(r.children.has(i))r=r.children.get(i);else{var o=new Q;o.value=t[n],o.parent=r,r.children.set(i,o),r=o}}return r.isLeaf=!0,r},Object.defineProperty(t.prototype,"debugValue",{get:function(){return this.root.debugValue},enumerable:!1,configurable:!0})}(),function(){function t(){this.isLeaf=!1,this.value=null,this.parent=null,this.children=new Map}return Object.defineProperty(t.prototype,"debugValue",{get:function(){var t,e,r={value:this.value,children:{}};this.isLeaf&&(r.isLeaf=!0);try{for(var n=H(this.children.entries()),i=n.next();!i.done;i=n.next()){var o=K(i.value,2),s=o[0],a=o[1];r.children[s]=a.debugValue}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),t}()),Y=function(){function t(t){void 0===t&&(t=J),this._entries=[],this._entriesByKey={},this.keyFunc=t}return t.prototype.clear=function(){this._entries=[],this._entriesByKey={}},t.prototype.remove=function(t){var e=[];this._entriesByKey={};for(var r=!1,n=0;n<this._entries.length;n++){var i=this._entries[n];t(i)?r=!0:(i.id=e.length,e.push(i),this._entriesByKey[this.keyFunc(i)]=i)}return this._entries=e,r},Object.defineProperty(t.prototype,"entries",{get:function(){return this._entries},enumerable:!1,configurable:!0}),t.prototype.get=function(t){return i(t>=0&&t<this._entries.length),this._entries[t]},t.prototype.getByKey=function(t){return this._entriesByKey[t]||null},t.prototype.ensure=function(t,e){if(void 0===e&&(e=!1),this.has(t)){if(e)throw new Error("Entry ".concat(this.keyFunc(t)," already exists"));return this._entriesByKey[this.keyFunc(t)]}return this._entriesByKey[this.keyFunc(t)]=t,t.id=this._entries.length,this._entries.push(t),t},t.prototype.has=function(t){return this.keyFunc(t)in this._entriesByKey},Object.defineProperty(t.prototype,"size",{get:function(){return this._entries.length},enumerable:!1,configurable:!0}),t}(),X=function(){function t(t,e){void 0===e&&(e=!0),this.entries=new Set,this.hasNull=!1,this.grammar=t,this.enforceSymbolType=e}return Object.defineProperty(t.prototype,"debugString",{get:function(){return"<"+this.labels().sort().join(", ")+">"},enumerable:!1,configurable:!0}),t.prototype.labels=function(t){var e,r;void 0===t&&(t=!1);var n=[];try{for(var o=H(this.entries),s=o.next();!s.done;s=o.next()){var a=s.value,u=this.grammar.getSymById(a);i(null!=u),t&&u.isAuxiliary||n.push(u.label)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return this.hasNull&&n.push(""),n},t.prototype.addFrom=function(t,e){return void 0===e&&(e=!0),t.addTo(this,e)},t.prototype.addTo=function(t,e){var r,n;void 0===e&&(e=!0);var i=t.entries.size;try{for(var o=H(this.entries),s=o.next();!s.done;s=o.next()){var a=s.value;t.entries.add(a)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return e&&(t.hasNull=this.hasNull||t.hasNull),t.entries.size-i},t.prototype.has=function(t){return this.entries.has(t.id)},t.prototype.add=function(t){return i(null==this.enforceSymbolType||this.enforceSymbolType==t.isTerminal,"Terminal types being enforced: ".concat(this.enforceSymbolType)),this.entries.add(t.id),this},t.prototype.delete=function(t){return this.entries.delete(t.id)},Object.defineProperty(t.prototype,"size",{get:function(){return this.entries.size+(this.hasNull?1:0)},enumerable:!1,configurable:!0}),t}(),Z=function(){function t(t){this.grammar=t,this.refresh()}return Object.defineProperty(t.prototype,"nonterms",{get:function(){var t=this,e=[];return this.entries.forEach(function(r){var n=t.grammar.getSymById(r);i(null!=n&&!n.isTerminal),e.push(n)}),e},enumerable:!1,configurable:!0}),t.prototype.refresh=function(){var t=this;this.entries=new Set,this.visited={};var e=0;do{e=this.entries.size,this.grammar.allNonTerminals.forEach(function(e){return t.visit(e)})}while(e!=this.entries.size)},t.prototype.visit=function(t){var e,r;try{for(var n=H(this.grammar.rulesForNT(t)),i=n.next();!i.done;i=n.next()){var o=i.value;if(this.isStrNullable(o.rhs)){this.add(t);break}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},t.prototype.isNullable=function(t){return!t.isTerminal&&this.entries.has(t.id)},t.prototype.isStrNullable=function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=null),null==r&&(r=t.length-1);for(var n=e;n<=r;n++)if(!this.isNullable(t.syms[n]))return!1;return!0},t.prototype.add=function(t){i(!t.isTerminal),this.entries.add(t.id)},t}(),tt=function(){function t(t){this.entries={},this._count=0,this.grammar=t}return t.prototype.refresh=function(){this.entries={},this._count=0},t.prototype.forEachTerm=function(t,e){var r=this,n=this.entriesFor(t);n.entries.forEach(function(t){var n=r.grammar.getSymById(t);i(null!=n&&n.isTerminal),e(n)}),n.hasNull&&e(null)},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t={};for(var e in this.entries)t[this.grammar.getSymById(e).label]=this.entries[e].debugString;return t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){var t=0;for(var e in this.entries)t+=this.entries[e].size;return t},enumerable:!1,configurable:!0}),t.prototype.entriesFor=function(t){if(t.id in this.entries)return this.entries[t.id];var e=new X(this.grammar);return this.entries[t.id]=e,e},t.prototype.addNull=function(t){var e=this.entriesFor(t);return!e.hasNull&&(e.hasNull=!0,!0)},t.prototype.add=function(t,e,r){void 0===r&&(r=!0),t.isTerminal&&i(!1,"Should not be here");var n=this.entriesFor(t);if(e.isTerminal){if(n.has(e))return!1;n.add(e),this._count++}else{var o=this.entriesFor(e),s=this.entriesFor(t),a=o.addTo(s,r);this._count+=a}return!0},t}(),et=function(t){function e(e,r){var n=t.call(this,e)||this;return r||(r=new Z(e)),n.nullables=r,n.refresh(),n}return W(e,t),e.prototype.forEachTermIn=function(t,e,r){void 0===e&&(e=0);for(var n=t.syms,i={},o=!0,s=e;o&&s<n.length;s++){var a=n[s];if(a.isTerminal)r(a),o=!1;else{var u=a;this.forEachTerm(u,function(t){null==t||t.id in i||(i[t.id]=!0,r(t))}),this.nullables.isNullable(a)||(o=!1)}}o&&r(null)},e.prototype.refresh=function(){var e=this;t.prototype.refresh.call(this);var r=0;do{r=this.count,this.grammar.forEachRule(null,function(t){e.processRule(t)})}while(r!=this.count)},e.prototype.processRule=function(t){var e,r,n=this.nullables,i=!0;try{for(var o=H(t.rhs.syms),s=o.next();!s.done;s=o.next()){var a=s.value;if(this.add(t.nt,a,!1),a.isTerminal||!n.isNullable(a)){i=!1;break}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}i&&this.addNull(t.nt)},e}(tt),rt=function(t){function e(e,r){var n=t.call(this,e)||this;return n.firstSets=r||new et(e),n.refresh(),n}return W(e,t),Object.defineProperty(e.prototype,"nullables",{get:function(){return this.firstSets.nullables},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){var e=this;t.prototype.refresh.call(this);var r=this.grammar;i(null!=r.startSymbol,"Select start symbol of the grammar"),this.add(r.startSymbol,r.Eof);var n=0;do{n=this.count,this.grammar.forEachRule(null,function(t){return e.processRule(t)})}while(n!=this.count)},e.prototype.processRule=function(t){for(var e=this,r=t.rhs.syms,n=this.firstSets,i=this.firstSets.nullables,o=function(i){var o=r[i];if(o.isTerminal)return"continue";n.forEachTermIn(t.rhs,i+1,function(t){null!=t&&e.add(o,t)})},s=0;s<r.length;s++)o(s);for(s=r.length-1;s>=0;s--)if(!r[s].isTerminal){for(var a=!0,u=s+1;u<r.length;u++){var l=r[u];if(l.isTerminal||!i.isNullable(l)){a=!1;break}}a&&this.add(r[s],t.nt)}},e}(tt),nt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},it=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},ot=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},st=function(){function t(e,r,n,i){void 0===i&&(i=null),this.grammar=e,this.label=r,this.isTerminal=n,this.isAuxiliary=!1,this.auxType=null,this.precedence=1,this.assocLeft=!0,this.creationId=-1,this.isTerminal=n,this.label=r,this.id=null==i?t.idCounter--:i}return t.prototype.compareTo=function(t){return this.label.localeCompare(t.label)},t.prototype.equals=function(t){return this.label==t.label},t.prototype.toString=function(){return this.label},t.idCounter=-1,t}(),at=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.syms=t||[]}return t.prototype.append=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{for(var i=nt(r),o=i.next();!o.done;o=i.next()){var s=o.value;this.syms.push(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return this},t.prototype.extend=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{for(var i=nt(r),o=i.next();!o.done;o=i.next()){var s=o.value;this.append.apply(this,ot([],it(s.syms),!1))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return this},t.prototype.copy=function(){return new(t.bind.apply(t,ot([void 0],it(this.syms),!1)))},t.prototype.add=function(t){this.syms.push(t)},t.prototype.isTerminal=function(t){return this.syms[t].isTerminal},Object.defineProperty(t.prototype,"length",{get:function(){return this.syms.length},enumerable:!1,configurable:!0}),t.prototype.toString=function(){return this.syms.map(function(t){return t.toString()}).join(" ")},t.prototype.slice=function(e,r){return new(t.bind.apply(t,ot([void 0],it(this.syms.slice(e,r)),!1)))},t.prototype.splice=function(t,e){for(var r,n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return(r=this.syms).splice.apply(r,ot([t,e],it(n),!1)),this},t.prototype.compareTo=function(t){for(var e=0;e<this.syms.length&&e<t.syms.length;e++){var r=this.syms[e].compareTo(t.syms[e]);if(0!=r)return r}return this.syms.length-t.syms.length},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.containsAt=function(t,e){for(var r=0;r<e.length&&t+r<this.syms.length;r++)if(!this.syms[t+r].equals(e.syms[r]))return!1;return r==e.length},Object.defineProperty(t.prototype,"debugString",{get:function(){return this.syms.map(function(t){return t.label}).join(" ")},enumerable:!1,configurable:!0}),t}(),ut=function(){function t(t){this.value=t}return Object.defineProperty(t.prototype,"isFunction",{get:function(){return"string"==typeof this.value},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isChildPosition",{get:function(){return"number"==typeof this.value},enumerable:!1,configurable:!0}),t}(),lt=function(){function t(t,e,r){if(void 0===r&&(r=null),this.nt=t,this.rhs=e,this.action=r,t.isTerminal)throw new Error("Cannot add rules to a terminal")}return Object.defineProperty(t.prototype,"debugString",{get:function(){return"".concat(this.nt.label," -> ").concat(this.rhs.debugString)},enumerable:!1,configurable:!0}),t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.compareTo=function(t){i(!isNaN(this.id));var e=this.nt.compareTo(t.nt);return 0==e&&this.rhs.compareTo(t.rhs),e},t}(),ct=function(){function t(t){this.startSymbol=null,this.modified=!0,this.symbolSet=new Y(function(t){return t.label}),this.allRules=[],this._rulesForNT=null,this._followSets=null,this._hasNull=!1,this.auxNTCount=0,t=t||{},this.auxNTPrefix=t.auxNTPrefix||"$",this.Null=this.newTerm(""),this.Eof=this.newTerm("$end")}return t.make=function(e){var r=new t;return e(r),r},t.prototype.rulesForNT=function(t){var e,r;if(i(!t.isTerminal),null==this._rulesForNT){this._rulesForNT={};try{for(var n=nt(this.allRules),o=n.next();!o.done;o=n.next()){var s=o.value;s.nt.label in this._rulesForNT||(this._rulesForNT[s.nt.label]=[]),this._rulesForNT[s.nt.label].push(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}return t.label in this._rulesForNT||(this._rulesForNT[t.label]=[]),this._rulesForNT[t.label]},Object.defineProperty(t.prototype,"nullables",{get:function(){return this.firstSets.nullables},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"firstSets",{get:function(){return this.followSets.firstSets},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"followSets",{get:function(){return(this.modified||null==this._followSets)&&this.refresh(),i(null!=this._followSets),this._followSets},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"augStartRule",{get:function(){return this._AugStartRule},enumerable:!1,configurable:!0}),t.prototype.augmentStartSymbol=function(t){void 0===t&&(t="$accept"),i(null==this._AugStartRule,"Ensure this grammar has not yet been augmented."),i(null!=this.startSymbol,"Start symbol not yet set");var e=this.newNT(t);return this._AugStartRule=new lt(e,new at(this.startSymbol)),this.addRule(this._AugStartRule,0),this},t.prototype.refresh=function(){return this.symbolSet.entries.forEach(function(t,e){return t.id=e}),this._rulesForNT=null,this.allRules.forEach(function(t,e){t.id=e}),this._followSets=new rt(this),this.modified=!1,this},t.prototype.addTerminals=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{for(var i=nt(r),o=i.next();!o.done;o=i.next()){var s=o.value;this.newTerm(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}},Object.defineProperty(t.prototype,"terminals",{get:function(){return this.symbolSet.entries.filter(function(t){return t.isTerminal})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"allNonTerminals",{get:function(){return this.symbolSet.entries.filter(function(t){return!t.isTerminal})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nonTerminals",{get:function(){return this.symbolSet.entries.filter(function(t){return!t.isTerminal&&!t.isAuxiliary})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"auxNonTerminals",{get:function(){return this.symbolSet.entries.filter(function(t){return t.isAuxiliary})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"allSymbols",{get:function(){return this.symbolSet.entries},enumerable:!1,configurable:!0}),t.prototype.forEachNT=function(t){var e,r;try{for(var n=nt(this.symbolSet.entries),i=n.next();!i.done;i=n.next()){var o=i.value;if(!o.isTerminal&&0==t(o))return}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},t.prototype.forEachRule=function(t,e){for(var r=null==t?this.allRules:this.rulesForNT(t)||[],n=0;n<r.length;n++)if(0==e(r[n],n))return!1;return!0},t.prototype.getRule=function(t,e){return"string"==typeof t&&(t=this.getSym(t)),i(null!=t),this.rulesForNT(t)[e]},t.prototype.findRule=function(t,e){return this.rulesForNT(t).findIndex(function(r){return r.nt==t&&r.rhs.equals(e)})},t.prototype.add=function(t,e,r){void 0===r&&(r=null);var n=null;return"string"==typeof t?null==(n=this.getSym(t))&&(n=this.newNT(t)):n=this.ensureSym(t),this.addRule(new lt(n,e,r))},t.prototype.addRule=function(t,e){if(void 0===e&&(e=-1),this.findRule(t.nt,t.rhs)>=0)throw new Error("Duplicate rule: "+t.debugString);return t.id=this.allRules.length,0==t.rhs.length&&(this._hasNull=!0),e<0?this.allRules.push(t):this.allRules.splice(e,0,t),this._rulesForNT=null,this.modified=!0,t},t.prototype.removeRules=function(t){return this.allRules=this.allRules.filter(function(e){return!t(e)}),this._rulesForNT=null,this.modified=!0,!0},t.prototype.removeSymbols=function(t){var e=!1,r=[];return this.allRules.forEach(function(n){if(!t(n.nt))if(0==n.rhs.length)r.push(n);else{var i=new(at.bind.apply(at,ot([void 0],it(n.rhs.syms.filter(function(e){return!t(e)})),!1)));e=e||n.rhs.length!=i.length,i.length>0&&r.push(new lt(n.nt,i))}}),this.allRules=r,e=this.symbolSet.remove(t)||e,this.modified=this.modified||e,e},t.prototype.getSymById=function(t){return this.symbolSet.get(t)},t.prototype.getSym=function(t){return this.symbolSet.getByKey(t)},t.prototype.ensureSym=function(t,e){void 0===e&&(e=!1);var r=this.symbolSet.ensure(t,e);return t==r?r.creationId<0&&(r.creationId=this.symbolSet.size):i(!e,"Should have already thrown error"),r},t.prototype.T=function(t,e){void 0===e&&(e=!1);var r=this.getSym(t);if(null!=r){if(e)throw new Error("Terminal ".concat(t," is already exists"));if(!r.isTerminal)throw new Error("Symbol (".concat(t,") already exists as a non-terminal"))}else r=new st(this,t,!0),r=this.ensureSym(r,!0);return r},t.prototype.NT=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=!1);var n=this.getSym(t);if(null!=n){if(r)throw new Error("Non-terminal ".concat(t," is already exists"));if(n.isTerminal)throw new Error("Symbol (".concat(t,") already exists as a terminal"))}else(n=new st(this,t,!1)).isAuxiliary=e,n=this.ensureSym(n,!0),e||null!=this.startSymbol||(this.startSymbol=n);return n},t.prototype.newTerm=function(t){return this.T(t,!0)},t.prototype.newNT=function(t,e){return void 0===e&&(e=!1),this.NT(t,e,!0)},t.prototype.isTerminal=function(t){var e=this.getSym(t);return null!=e&&e.isTerminal},t.prototype.isNT=function(t){var e=this.getSym(t);return null!=e&&!e.isTerminal&&!e.isAuxiliary},t.prototype.isAuxNT=function(t){var e=this.getSym(t);return null!=e&&!e.isTerminal&&e.isAuxiliary},t.prototype.seq=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(1==r.length)return this.normalizeRule(r[0]);var i=new at;try{for(var o=nt(r),s=o.next();!s.done;s=o.next())for(var a=s.value,u=this.normalizeRule(a),l=0;l<u.length;l++)i.add(u.syms[l])}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return i},t.prototype.anyof=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return 1==e.length?this.normalizeRule(e[0]):new at(this.ensureAuxNT.apply(this,ot([],it(e.map(function(e){return t.normalizeRule(e)})),!1)))},t.prototype.opt=function(t){var e=this.anyof(t,new at),r=e.syms[0];return i(1==e.syms.length&&r.isAuxiliary,"NT must be an auxiliary symbol"),r.auxType="opt",e},t.prototype.atleast0=function(t,e){var r=this;void 0===e&&(e=!0);var n=this.normalizeRule(t),i=this.findAuxNT(function(e){var i=r.rulesForNT(e);if(2!=i.length)return!1;var o=0;if(0==i[0].rhs.length)o=1;else{if(0!=i[1].rhs.length)return!1;o=0}var s=i[o].rhs;return s.length==1+t.length&&(s.syms[0].equals(e)?s.containsAt(1,n):!!s.syms[s.length-1].equals(e)&&s.containsAt(0,n))});return null==i&&((i=this.newAuxNT()).auxType=e?"atleast0:left":"atleast0",this.add(i,new at),e?this.add(i,new at(i).extend(n)):this.add(i,n.copy().append(i))),new at(i)},t.prototype.atleast1=function(t,e){var r=this;void 0===e&&(e=!0);var n=this.normalizeRule(t),i=this.findAuxNT(function(e){var i=r.rulesForNT(e);if(2!=i.length)return!1;var o=0;if(i[0].rhs.equals(n))o=1;else{if(!i[1].rhs.equals(n))return!1;o=0}var s=i[o].rhs;return s.length==1+t.length&&(s.syms[0].equals(e)?s.containsAt(1,n):!!s.syms[s.length-1].equals(e)&&s.containsAt(0,n))});return null==i&&((i=this.newAuxNT()).auxType=e?"atleast1:left":"atleast1",this.add(i,n),e?this.add(i,new at(i).extend(n)):this.add(i,n.copy().append(i))),new at(i)},t.prototype.normalizeRule=function(t){if("string"==typeof t){var e=this.getSym(t);if(null==e)throw new Error("Invalid symbol: '".concat(t,"'"));return new at(e)}return t},t.prototype.newAuxNTName=function(){return this.auxNTPrefix+this.auxNTCount++},t.prototype.newAuxNT=function(t){return void 0===t&&(t=""),""==t&&(t=this.newAuxNTName()),this.newNT(t,!0)},t.prototype.ensureAuxNT=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=this.findAuxNTByRules.apply(this,ot([],it(r),!1));if(null==i){(i=this.newAuxNT()).auxType="anyof";try{for(var o=nt(r),s=o.next();!s.done;s=o.next()){var a=s.value;this.add(i,a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}}return i},t.prototype.findAuxNT=function(t){var e,r;try{for(var n=nt(this.symbolSet.entries),i=n.next();!i.done;i=n.next()){var o=i.value;if(o.isAuxiliary&&t(o))return o}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return null},t.prototype.findAuxNTByRules=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this.findAuxNT(function(r){var n=t.rulesForNT(r);if(n.length!=e.length)return!1;for(var i=0;i<n.length;i++)if(!n[i].rhs.equals(e[i]))return!1;return!0})},t.prototype.print=function(t){void 0===t&&(t=null);var e=(t=t||{}).ruleSep||"->",r=t.includeSemiColon||!1,n=t.lambdaSymbol||"",i=[];return this.forEachRule(null,function(t,o){var s="".concat(t.nt.label," ").concat(e," ");t.rhs.length>0?s+=t.rhs.debugString:s+=n,r&&(s+=" ;"),i.push(s)}),i},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t=[];return this.forEachRule(null,function(e,r){t.push("".concat(e.nt.label," -> ").concat(e.rhs.debugString))}),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"terminalDerivingSymbols",{get:function(){for(var t,e,r,n,i=new X(this,null),o=-1,s=!0;0!=o;){o=0;try{for(var a=(t=void 0,nt(this.allRules)),u=a.next();!u.done;u=a.next()){var l=u.value;s=!0;try{for(var c=(r=void 0,nt(l.rhs.syms)),h=c.next();!h.done;h=c.next()){var f=h.value;i.has(f)||(f.isTerminal?(i.add(f),o++):s=!1)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}s&&!i.has(l.nt)&&(i.add(l.nt),o++)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}}return i},enumerable:!1,configurable:!0}),t.prototype.reachableSymbols=function(t){var e,r,n,o,s,a;void 0===t&&(t=null),null==t&&(t=this._AugStartRule?this._AugStartRule.nt:this.startSymbol),i(null!=t,"Start symbol does not exist");for(var u=new X(this,!1).add(t),l=[t];l.length>0;){var c=[];try{for(var h=(e=void 0,nt(l)),f=h.next();!f.done;f=h.next()){var p=f.value;try{for(var d=(n=void 0,nt(this.rulesForNT(p))),g=d.next();!g.done;g=d.next()){var y=g.value;try{for(var m=(s=void 0,nt(y.rhs.syms)),v=m.next();!v.done;v=m.next()){var b=v.value;b.isTerminal||u.has(b)||(c.push(b),u.add(b))}}catch(t){s={error:t}}finally{try{v&&!v.done&&(a=m.return)&&a.call(m)}finally{if(s)throw s.error}}}}catch(t){n={error:t}}finally{try{g&&!g.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{f&&!f.done&&(r=h.return)&&r.call(h)}finally{if(e)throw e.error}}l=c}return u},Object.defineProperty(t.prototype,"cycles",{get:function(){var t=this;return z(this.allNonTerminals,function(t){return t.label},function(e){var r=[];return t.forEachRule(e,function(n,i){n.rhs.syms.forEach(function(o,s){o.isTerminal||t.nullables.isStrNullable(n.rhs,0,s-1)&&t.nullables.isStrNullable(n.rhs,s+1)&&r.push([o,[e,i]])})}),r})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftRecursion",{get:function(){var t=this;return z(this.allNonTerminals,function(t){return t.id},function(e){var r=[];return t.forEachRule(e,function(e,n){e.rhs.syms.forEach(function(e,i){if(!e.isTerminal)return r.push([e,n]),t.nullables.isNullable(e)})}),r})},enumerable:!1,configurable:!0}),t}(),ht=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!function(t){t[t.WORD_CHAR=0]="WORD_CHAR",t[t.DIGITS=1]="DIGITS",t[t.SPACES=2]="SPACES"}(q||(q={}));var ft,pt,dt="0".charCodeAt(0),gt="9".charCodeAt(0),yt="a".charCodeAt(0),mt="z".charCodeAt(0),vt="A".charCodeAt(0),bt="Z".charCodeAt(0),wt="_".charCodeAt(0),St=function(){function t(){}return t.prototype.matches=function(t,e){var r=this.match(t);return e?!r:r},t}(),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ht(e,t),e.prototype.match=function(t){if(t>=8192&&t<=8202)return!0;for(var e=0;e<14;e++)if(" \f\n\r\t\v \u2028\u2029 \ufeff".charCodeAt(e)==t)return!0;return!1},e.prototype.reString=function(t){return t?"\\S":"\\s"},e}(St),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ht(e,t),e.prototype.match=function(t){return t>=dt&&t<=gt},e.prototype.reString=function(t){return t?"\\D":"\\d"},e}(St),_t=[new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ht(e,t),e.prototype.match=function(t){return t==wt||t>=dt&&t<=gt||t>=yt&&t<=mt||t>=vt&&t<=bt},e.prototype.reString=function(t){return t?"\\W":"\\w"},e}(St)),new Ct,new Et];!function(t){t[t.gc=0]="gc",t[t.General_Category=0]="General_Category",t[t.sc=1]="sc",t[t.Script=1]="Script",t[t.scx=2]="scx",t[t.Script_Extension=2]="Script_Extension",t[t.Any=3]="Any",t[t.ASCII=4]="ASCII",t[t.AHex=5]="AHex",t[t.ASCII_Hex_Digit=5]="ASCII_Hex_Digit",t[t.Alpha=6]="Alpha",t[t.Alphabetic=6]="Alphabetic",t[t.Bidi_M=7]="Bidi_M",t[t.Bidi_Mirrored=7]="Bidi_Mirrored",t[t.Bidi_C=8]="Bidi_C",t[t.Bidi_Control=8]="Bidi_Control",t[t.CI=9]="CI",t[t.Case_Ignorable=9]="Case_Ignorable",t[t.Cased=10]="Cased",t[t.CWCF=11]="CWCF",t[t.Changes_When_Casefolded=11]="Changes_When_Casefolded",t[t.CWCM=12]="CWCM",t[t.Changes_When_Casemapped=12]="Changes_When_Casemapped",t[t.CWL=13]="CWL",t[t.Changes_When_Lowercased=13]="Changes_When_Lowercased",t[t.CWKCF=14]="CWKCF",t[t.Changes_When_NFKC_Casefolded=14]="Changes_When_NFKC_Casefolded",t[t.CWT=15]="CWT",t[t.Changes_When_Titlecased=15]="Changes_When_Titlecased",t[t.CWU=16]="CWU",t[t.Changes_When_Uppercased=16]="Changes_When_Uppercased",t[t.Dash=17]="Dash",t[t.DI=18]="DI",t[t.Default_Ignorable_Code_Point=18]="Default_Ignorable_Code_Point",t[t.Dep=19]="Dep",t[t.Deprecated=19]="Deprecated",t[t.Dia=20]="Dia",t[t.Diacritic=20]="Diacritic",t[t.Emoji=21]="Emoji",t[t.Emoji_Component=22]="Emoji_Component",t[t.Emoji_Modifier=23]="Emoji_Modifier",t[t.Emoji_Modifier_Base=24]="Emoji_Modifier_Base",t[t.Emoji_Presentation=25]="Emoji_Presentation",t[t.Ext=26]="Ext",t[t.Extender=26]="Extender",t[t.Gr_Base=27]="Gr_Base",t[t.Grapheme_Base=27]="Grapheme_Base",t[t.Gr_Ext=28]="Gr_Ext",t[t.Grapheme_Extend=28]="Grapheme_Extend",t[t.Hex=29]="Hex",t[t.Hex_Digit=29]="Hex_Digit",t[t.IDSB=30]="IDSB",t[t.IDS_Binary_Operator=30]="IDS_Binary_Operator",t[t.IDST=31]="IDST",t[t.IDS_Trinary_Operator=31]="IDS_Trinary_Operator",t[t.IDC=32]="IDC",t[t.ID_Continue=32]="ID_Continue",t[t.IDS=33]="IDS",t[t.ID_Start=33]="ID_Start",t[t.Ideo=34]="Ideo",t[t.Ideographic=34]="Ideographic",t[t.Join_C=35]="Join_C",t[t.Join_Control=35]="Join_Control",t[t.LOE=36]="LOE",t[t.Logical_Order_Exception=36]="Logical_Order_Exception",t[t.Lower=37]="Lower",t[t.Lowercase=37]="Lowercase",t[t.Math=38]="Math",t[t.NChar=39]="NChar",t[t.Noncharacter_Code_Point=39]="Noncharacter_Code_Point",t[t.Pat_Syn=40]="Pat_Syn",t[t.Pattern_Syntax=40]="Pattern_Syntax",t[t.Pat_WS=41]="Pat_WS",t[t.Pattern_White_Space=41]="Pattern_White_Space",t[t.QMark=42]="QMark",t[t.Quotation_Mark=42]="Quotation_Mark",t[t.Radical=43]="Radical",t[t.RI=44]="RI",t[t.Regional_Indicator=44]="Regional_Indicator",t[t.STerm=45]="STerm",t[t.Sentence_Terminal=45]="Sentence_Terminal",t[t.SD=46]="SD",t[t.Soft_Dotted=46]="Soft_Dotted",t[t.Term=47]="Term",t[t.Terminal_Punctuation=47]="Terminal_Punctuation",t[t.UIdeo=48]="UIdeo",t[t.Unified_Ideograph=48]="Unified_Ideograph",t[t.Upper=49]="Upper",t[t.Uppercase=49]="Uppercase",t[t.VS=50]="VS",t[t.Variation_Selector=50]="Variation_Selector",t[t.space=51]="space",t[t.White_Space=51]="White_Space",t[t.XIDC=52]="XIDC",t[t.XID_Continue=52]="XID_Continue",t[t.XIDS=53]="XIDS",t[t.XID_Start=53]="XID_Start"}(ft||(ft={})),function(t){t[t.LC=0]="LC",t[t.Cased_Letter=0]="Cased_Letter",t[t.Pe=1]="Pe",t[t.Close_Punctuation=1]="Close_Punctuation",t[t.Pc=2]="Pc",t[t.Connector_Punctuation=2]="Connector_Punctuation",t[t.Cc=3]="Cc",t[t.cntrl=3]="cntrl",t[t.Control=3]="Control",t[t.Sc=4]="Sc",t[t.Currency_Symbol=4]="Currency_Symbol",t[t.Pd=5]="Pd",t[t.Dash_Punctuation=5]="Dash_Punctuation",t[t.Nd=6]="Nd",t[t.digit=6]="digit",t[t.Decimal_Number=6]="Decimal_Number",t[t.Me=7]="Me",t[t.Enclosing_Mark=7]="Enclosing_Mark",t[t.Pf=8]="Pf",t[t.Final_Punctuation=8]="Final_Punctuation",t[t.Cf=9]="Cf",t[t.Format=9]="Format",t[t.Pi=10]="Pi",t[t.Initial_Punctuation=10]="Initial_Punctuation",t[t.L=11]="L",t[t.Letter=11]="Letter",t[t.Nl=12]="Nl",t[t.Letter_Number=12]="Letter_Number",t[t.Zl=13]="Zl",t[t.Line_Separator=13]="Line_Separator",t[t.Ll=14]="Ll",t[t.Lowercase_Letter=14]="Lowercase_Letter",t[t.M=15]="M",t[t.Combining_Mark=15]="Combining_Mark",t[t.Mark=16]="Mark",t[t.Sm=17]="Sm",t[t.Math_Symbol=17]="Math_Symbol",t[t.Lm=18]="Lm",t[t.Modifier_Letter=18]="Modifier_Letter",t[t.Sk=19]="Sk",t[t.Modifier_Symbol=19]="Modifier_Symbol",t[t.Mn=20]="Mn",t[t.Nonspacing_Mark=20]="Nonspacing_Mark",t[t.N=21]="N",t[t.Number=21]="Number",t[t.Ps=22]="Ps",t[t.Open_Punctuation=22]="Open_Punctuation",t[t.C=23]="C",t[t.Other=23]="Other",t[t.Lo=24]="Lo",t[t.Other_Letter=24]="Other_Letter",t[t.No=25]="No",t[t.Other_Number=25]="Other_Number",t[t.Po=26]="Po",t[t.Other_Punctuation=26]="Other_Punctuation",t[t.So=27]="So",t[t.Other_Symbol=27]="Other_Symbol",t[t.Zp=28]="Zp",t[t.Paragraph_Separator=28]="Paragraph_Separator",t[t.Co=29]="Co",t[t.Private_Use=29]="Private_Use",t[t.P=30]="P",t[t.punct=30]="punct",t[t.Punctuation=30]="Punctuation",t[t.Z=31]="Z",t[t.Separator=31]="Separator",t[t.Zs=32]="Zs",t[t.Space_Separator=32]="Space_Separator",t[t.Mc=33]="Mc",t[t.Spacing_Mark=33]="Spacing_Mark",t[t.Cs=34]="Cs",t[t.Surrogate=34]="Surrogate",t[t.S=35]="S",t[t.Symbol=35]="Symbol",t[t.Lt=36]="Lt",t[t.Titlecase_Letter=36]="Titlecase_Letter",t[t.Cn=37]="Cn",t[t.Unassigned=37]="Unassigned",t[t.Lu=38]="Lu",t[t.Uppercase_Letter=38]="Uppercase_Letter"}(pt||(pt={}));var xt,Ot=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),At=function(){return At=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},At.apply(this,arguments)},Tt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Nt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Rt=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};!function(t){t[t.START_OF_INPUT=0]="START_OF_INPUT",t[t.END_OF_INPUT=1]="END_OF_INPUT",t[t.START_OF_WORD=2]="START_OF_WORD",t[t.END_OF_WORD=3]="END_OF_WORD",t[t.UNION=4]="UNION",t[t.CAT=5]="CAT",t[t.VAR=6]="VAR",t[t.BACK_NAMED_REF=7]="BACK_NAMED_REF",t[t.BACK_NUM_REF=8]="BACK_NUM_REF",t[t.QUANT=9]="QUANT",t[t.LOOK_AHEAD=10]="LOOK_AHEAD",t[t.LOOK_BACK=11]="LOOK_BACK",t[t.CHAR=12]="CHAR"}(xt||(xt={}));var It,kt=function(){function t(){this.parent=null,this.reString=null,this.groupIndex=-1,this.groupName=null,this.groupIsSilent=!1,this.ignoreCase=null,this.dotAll=null,this.multiline=null}return t.prototype.setOptions=function(t){return"dotAll"in t&&(this.dotAll=t.dotAll),"ignoreCase"in t&&(this.ignoreCase=t.ignoreCase),"groupIndex"in t&&(this.groupIndex=t.groupIndex),"multiline"in t&&(this.multiline=t.multiline),this},t.prototype.debugValue=function(){var t={};return this.dotAll&&(t.dotAll=!0),this.ignoreCase&&(t.ignoreCase=!0),this.multiline&&(t.multiline=!0),this.groupIndex>=0&&(t.groupIndex=this.groupIndex),t},Object.defineProperty(t.prototype,"isVariable",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toString",{get:function(){return null==this.reString&&(this.reString=this.evalREString()),this.reString},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"modifiers",{get:function(){var t="";return this.dotAll&&(t+="d"),this.ignoreCase&&(t+="i"),this.multiline&&(t+="m"),this.groupIndex>=0&&(t+="g:"+this.groupIndex),0==t.length?t:"<"+t+">"},enumerable:!1,configurable:!0}),t}(),Lt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.START_OF_INPUT,e}return Ot(e,t),e.prototype.debugValue=function(){return"^"},e.prototype.reverse=function(){return this},e.prototype.evalREString=function(){return"^"},e}(kt),Pt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.END_OF_INPUT,e}return Ot(e,t),e.prototype.debugValue=function(){return"$"},e.prototype.evalREString=function(){return"$"},e.prototype.reverse=function(){return this},e}(kt),Bt=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.START_OF_WORD,e}Ot(e,t),e.prototype.debugValue=function(){return"\\b"},e.prototype.reverse=function(){return this},e.prototype.evalREString=function(){return"\\b"}}(kt),function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.END_OF_WORD,e}Ot(e,t),e.prototype.debugValue=function(){return"\\b"},e.prototype.reverse=function(){return this},e.prototype.evalREString=function(){return"\\b"}}(kt),function(t){function e(e,r,n){void 0===n&&(n=!1);var i=t.call(this)||this;return i.expr=e,i.cond=r,i.negate=n,i}return Ot(e,t),e}(kt)),jt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.LOOK_AHEAD,e}return Ot(e,t),e.prototype.evalREString=function(){return"".concat(this.expr.toString,"(?").concat(this.negate?"!":"=").concat(this.cond.toString,")")},e.prototype.debugValue=function(){return["LookAhead",At(At({},t.prototype.debugValue.call(this)),{negate:this.negate,expr:this.expr.debugValue(),cond:this.cond.debugValue()})]},e.prototype.reverse=function(){return new Mt(this.expr.reverse(),this.cond.reverse(),this.negate)},e}(Bt),Mt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tag=xt.LOOK_BACK,e}return Ot(e,t),e.prototype.evalREString=function(){return"(?<".concat(this.negate?"!":"=").concat(this.cond.toString,")").concat(this.expr.toString)},e.prototype.debugValue=function(){return["LookBack",At(At({},t.prototype.debugValue.call(this)),{negate:this.negate,expr:this.expr.debugValue(),cond:this.cond.debugValue()})]},e.prototype.reverse=function(){return new jt(this.expr.reverse(),this.cond.reverse(),this.negate)},e}(Bt),Dt=function(t){function e(e,r,n,i){void 0===r&&(r=1),void 0===n&&(n=1),void 0===i&&(i=!0);var o=t.call(this)||this;return o.expr=e,o.minCount=r,o.maxCount=n,o.greedy=i,o.tag=xt.QUANT,o}return Ot(e,t),Object.defineProperty(e.prototype,"isUnlimited",{get:function(){return this.maxCount<0||this.maxCount==o},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVariable",{get:function(){return this.minCount!=this.maxCount||!this.expr.isVariable},enumerable:!1,configurable:!0}),e.prototype.reverse=function(){return new e(this.expr.reverse(),this.minCount,this.maxCount,this.greedy)},e.prototype.evalREString=function(){var t="*";return 1==this.minCount&&this.isUnlimited?t="+":0==this.minCount&&this.isUnlimited?t="*":0==this.minCount&&1==this.maxCount?t="?":1==this.minCount&&1==this.maxCount||(t=this.minCount==this.maxCount?"{".concat(this.minCount,"}"):"{".concat(this.minCount,",").concat(this.isUnlimited?"":this.maxCount,"}")),"".concat(this.expr.toString).concat(t)},e.prototype.debugValue=function(){var e="*";return 1==this.minCount&&this.isUnlimited?e=this.greedy?"+?":"+":0==this.minCount&&this.isUnlimited?e=this.greedy?"*?":"*":0==this.minCount&&1==this.maxCount?e=this.greedy?"??":"?":1==this.minCount&&1==this.maxCount||(e=this.minCount==this.maxCount?"{".concat(this.minCount,"}")+(this.greedy?"?":""):"{".concat(this.minCount,",").concat(this.maxCount,"}")+(this.greedy?"?":"")),[e,t.prototype.debugValue.call(this),this.expr.debugValue()]},e}(kt),Ut=function(t){function e(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=t.call(this)||this;o.tag=xt.CAT,o.children=[];try{for(var s=Tt(n),a=s.next();!a.done;a=s.next()){var u=a.value;o.add(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return o}return Ot(e,t),Object.defineProperty(e.prototype,"isVariable",{get:function(){var t,e;try{for(var r=Tt(this.children),n=r.next();!n.done;n=r.next())if(n.value.isVariable)return!0}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return!1},enumerable:!1,configurable:!0}),e.prototype.evalREString=function(){var t=this.children.map(function(t){return t.toString}).join("");return this.children.length>1?"("+t+")":t},e.prototype.reverse=function(){var t=this.children.map(function(t){return t.reverse()});return t.reverse(),new(e.bind.apply(e,Rt([void 0],Nt(t),!1)))},e.prototype.add=function(t){var e,r;if(t.tag!=xt.CAT||t.groupIndex>=0)this.children.push(t);else try{for(var n=Tt(t.children),i=n.next();!i.done;i=n.next()){var o=i.value;this.add(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return this},e.prototype.debugValue=function(){return["Cat",At({},t.prototype.debugValue.call(this)),this.children.map(function(t){return t.debugValue()})]},e}(kt),Ft=function(t){function e(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=t.call(this)||this;o.tag=xt.UNION,o.options=[];try{for(var s=Tt(n),a=s.next();!a.done;a=s.next()){var u=a.value;o.add(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return o}return Ot(e,t),Object.defineProperty(e.prototype,"isVariable",{get:function(){var t,e;try{for(var r=Tt(this.options),n=r.next();!n.done;n=r.next())if(n.value.isVariable)return!0}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}return!1},enumerable:!1,configurable:!0}),e.prototype.evalREString=function(){var t=this.options.map(function(t){return t.toString}).join("|");return this.options.length>1?"("+t+")":t},e.prototype.reverse=function(){var t=this.options.map(function(t){return t.reverse()});return new(e.bind.apply(e,Rt([void 0],Nt(t),!1)))},e.prototype.add=function(t){var e,r;if(t.tag!=xt.UNION||t.groupIndex>=0)this.options.push(t);else try{for(var n=Tt(t.options),i=n.next();!i.done;i=n.next()){var o=i.value;this.add(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return this},e.prototype.debugValue=function(){return["Union",At({},t.prototype.debugValue.call(this)),this.options.map(function(t){return t.debugValue()})]},e}(kt);!function(t){t[t.AnyChar=1]="AnyChar",t[t.SingleChar=2]="SingleChar",t[t.CharRange=3]="CharRange",t[t.PropertyEscape=4]="PropertyEscape",t[t.CharClass=5]="CharClass",t[t.Union=6]="Union",t[t.Intersection=7]="Intersection"}(It||(It={}));var $t=function(t){function e(e,r){void 0===r&&(r=!1);var n=t.call(this)||this;return n.op=e,n.neg=r,n.tag=xt.CHAR,n}return Ot(e,t),e.prototype.match=function(t){var e=this.matchChar(t);return e&&!this.neg||this.neg&&!e},e.prototype.reverse=function(){return this},e.prototype.debugValue=function(){return this.toString+this.modifiers},e}(kt),Vt=function(t){function e(e,r,n){void 0===r&&(r=!1),void 0===n&&(n=[]);var i=t.call(this,e,r)||this;return i.op=e,i.neg=r,i.args=n,i}return Ot(e,t),e.Any=function(t){return void 0===t&&(t=!1),new e(It.AnyChar,t)},e.Class=function(t,r){return void 0===r&&(r=!1),new e(It.CharClass,r,[t])},e.Single=function(t,r){return void 0===r&&(r=!1),"string"==typeof t&&(t=t.charCodeAt(0)),new e(It.SingleChar,r,[t])},e.PropertyEscape=function(t,r,n){return void 0===n&&(n=!1),"string"==typeof t&&(t=function(t){if(!((t=t.trim())in ft))throw new SyntaxError("Invalid property name: "+t);return ft[t]}(t)),"string"==typeof r&&(r=function(t){if(!((t=t.trim())in pt))throw new SyntaxError("Invalid property value: "+t);return pt[t]}(r)),new e(It.PropertyEscape,n,[t,r])},e.prototype.matchChar=function(t){var e=this.args;switch(this.op){case It.SingleChar:return t==this.args[0];case It.CharClass:return _t[e[0]].matches(t,!1);case It.PropertyEscape:throw new Error("Property Escape Matching - TBD");default:throw new Error("Custom Chars - TBD i: "+this.op)}return!1},e.prototype.compareTo=function(t){if(this.op!=t.op)return this.op-t.op;for(var e=0;e<this.args.length&&e<t.args.length;e++)if(this.args[e]!=t.args[e])return this.args[e]-t.args[e];return this.args.length-t.args.length},e.prototype.evalREString=function(){return this.op==It.AnyChar?".":this.op==It.SingleChar?(t=this.args[0],String.fromCharCode(t).replace("\n","\\n").replace("\0","\\0").replace("\r","\\r").replace("\t","\\t").replace("\f","\\f").replace("\b","\\b")):this.op==It.CharClass?_t[this.args[0]].reString(this.neg):this.op==It.PropertyEscape?this.neg?"\\P{":"\\p{}":"Custom "+this.args.join(" ");var t},e}($t),zt=function(t){function e(e,r,n){void 0===r&&(r=!1),void 0===n&&(n=[]);var i=t.call(this,e,r)||this;return i.op=e,i.neg=r,i.chars=n,i}return Ot(e,t),e.prototype.compareTo=function(t){if(this.op!=t.op)return this.op-t.op;for(var e=0;e<this.chars.length&&e<t.chars.length;e++){var r=this.chars[e].compareTo(t.chars[e]);if(0!=r)return r}return this.chars.length-t.chars.length},e.prototype.matchChar=function(t){var e=this.chars;switch(this.op){case It.CharRange:return t>=e[0].args[0]&&t<=e[1].args[0];case It.Union:for(var r=0;r<e.length;r++)if(e[r].match(t))return!0;return!1;case It.Intersection:for(r=0;r<e.length;r++)if(!e[r].match(t))return!1;return!0;default:throw new Error("Custom CharGroup - TBD i: "+this.op)}return!1},e.prototype.evalREString=function(){var t=this.chars.map(function(t){return t.debugValue()}).join("");return this.op==It.CharRange?"".concat(this.chars[0].toString,"-").concat(this.chars[1].toString):this.op==It.Union||this.op==It.Intersection?t.length>1?(this.neg?"[^":"[")+t+"]":t:"Custom "+this.chars.join(" ")},e.Range=function(t,r,n){return void 0===n&&(n=!1),new e(It.CharRange,n,[t,r])},e.Union=function(t,r){return void 0===t&&(t=!1),new e(It.Union,t,r)},e.Intersection=function(t,r){return void 0===t&&(t=!1),new e(It.Intersection,t,r)},e}($t),Gt=function(t){function e(e,r){void 0===r&&(r=!1);var n=t.call(this)||this;return n.name=e,n.reversed=r,n.tag=xt.VAR,n}return Ot(e,t),e.prototype.reverse=function(){return new e(this.name,!this.reversed)},e.prototype.evalREString=function(){return"<"+this.name+">"},e.prototype.debugValue=function(){return["V:"+this.name,At({},t.prototype.debugValue.call(this))]},e}(kt),qt=function(t){function e(e,r){void 0===r&&(r=!1);var n=t.call(this)||this;return n.name=e,n.reversed=r,n.tag=xt.BACK_NAMED_REF,n}return Ot(e,t),e.prototype.reverse=function(){return new e(this.name,!this.reversed)},e.prototype.evalREString=function(){return"\\k<"+this.name+">"},e.prototype.debugValue=function(){return At(At({},t.prototype.debugValue),{BackRef:this.name})},e}(kt),Wt=function(t){function e(e,r){void 0===r&&(r=!1);var n=t.call(this)||this;return n.num=e,n.reversed=r,n.tag=xt.BACK_NUM_REF,n}return Ot(e,t),e.prototype.reverse=function(){return new e(this.num,!this.reversed)},e.prototype.evalREString=function(){return"\\"+this.num},e.prototype.debugValue=function(){return"\\"+this.num},e}(kt),Ht=function(){function t(t,e){this.expr=t,this.skip=!1,e=e||{},this.tag=e.tag||null,0==e.priority?this.priority=0:this.priority=e.priority||10,0==e.matchIndex?this.matchIndex=0:this.matchIndex=e.matchIndex||-1,this.skip=e.skip||!1,this.activeStates=e.activeStates||null}return t.prototype.stateCanActivate=function(t){return null==this.activeStates||0==this.activeStates.size||this.activeStates.has("*")||this.activeStates.has(t)},Object.defineProperty(t.prototype,"needsSpecificStates",{get:function(){return null!=this.activeStates&&this.activeStates.size>0&&!this.activeStates.has("*")},enumerable:!1,configurable:!0}),t}(),Kt=function(){return Kt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Kt.apply(this,arguments)},Jt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Qt=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};function Yt(t){return"\r"==t||"\n"==t||"\u2028"==t||"\u2029"==t}var Xt,Zt=function(t,e,r,n){void 0===t&&(t=10),void 0===e&&(e=-1),void 0===r&&(r=-1),void 0===n&&(n=-1),this.priority=t,this.matchIndex=e,this.start=r,this.end=n,this.groups=[],this.positions=[]};!function(t){t[t.Any=0]="Any",t[t.AnyNonNL=1]="AnyNonNL",t[t.Char=2]="Char",t[t.CIChar=3]="CIChar",t[t.Match=4]="Match",t[t.Noop=5]="Noop",t[t.Save=6]="Save",t[t.Split=7]="Split",t[t.Jump=8]="Jump",t[t.Begin=9]="Begin",t[t.RBegin=10]="RBegin",t[t.End=11]="End",t[t.StartingChar=12]="StartingChar",t[t.EndingChar=13]="EndingChar",t[t.MLStartingChar=14]="MLStartingChar",t[t.MLEndingChar=15]="MLEndingChar",t[t.StartOfWord=16]="StartOfWord",t[t.EndOfWord=17]="EndOfWord",t[t.GroupStart=18]="GroupStart",t[t.GroupEnd=19]="GroupEnd",t[t.EnsureState=20]="EnsureState"}(Xt||(Xt={}));var te=function(){function t(t,e){void 0===t&&(t="INITIAL"),void 0===e&&(e=!0),this.startCondition=t,this.scIsInclusive=e,this.instrs=[],this.stateMapping=new Map,this.registerState("INITIAL"),this.registerState(t)}return Object.defineProperty(t.prototype,"length",{get:function(){return this.instrs.length},enumerable:!1,configurable:!0}),t.prototype.registerState=function(t){return this.stateMapping.has(t)||this.stateMapping.set(t,this.stateMapping.size),this.stateMapping.get(t)||-1},t.prototype.add=function(t,e){var r;void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var o=(r=new ee(t,e)).add.apply(r,Qt([],Jt(n),!1));return o.offset=this.instrs.length,this.instrs.push(o),o},t.with=function(e){var r=new t;return e(r),r},t.prototype.debugValue=function(t){return void 0===t&&(t=ie),t?this.instrs.map(function(e,r){return e.comment.trim().length>0?"L".concat(r,": ").concat(t(e)," # ").concat(e.comment):"L".concat(r,": ").concat(t(e))}):this.instrs.map(function(t,e){return"L".concat(e,": ").concat(t.debugValue)})},t}(),ee=function(){function t(t,e){void 0===e&&(e=null),this.opcode=t,this.char=e,this.offset=0,this.comment="",this.args=[],this.char=e}return t.prototype.add=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return(t=this.args).push.apply(t,Qt([],Jt(e),!1)),this},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t=this.comment.trim();return t.length>0&&(t=" # "+t),"".concat(this.opcode," ").concat(this.args.join(" ")," ").concat(this.char||""," ").concat(t)},enumerable:!1,configurable:!0}),t}(),re=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.offset=t,this.gen=e,this.parentId=-1,this.id=0,this.priority=0,this.groups=[],this.positions=[],this.registers={}}return t.prototype.regIncr=function(t){if(!(t in this.registers))throw new Error("Register at offset ".concat(t," is invalid"));this.registers[t]++},t.prototype.regAcquire=function(t){if(t in this.registers)throw new Error("Register at offset ".concat(t," already acquired. Release it first"));this.registers[t]=0},t.prototype.regRelease=function(t){if(!(t in this.registers))throw new Error("Register at offset ".concat(t," is invalid"));delete this.registers[t]},t.prototype.regValue=function(t){if(!(t in this.registers))throw new Error("Register at offset ".concat(t," is invalid"));return this.registers[t]},t}(),ne=function(){function t(t,e,r,n,i){void 0===e&&(e=0),void 0===r&&(r=-1),void 0===n&&(n=!0),void 0===i&&(i={}),this.prog=t,this.start=e,this.end=r,this.forward=n,this.threadCounter=0,this.currThreads=[],this.nextThreads=[],this.startPos=0,this.currState=0,this.gen=0,this.genForOffset={},r<0&&(r=t.length-1),this.end=r}return t.prototype.savePosition=function(t,e,r){for(;t.positions.length<=e;)t.positions.push(-1);t.positions[e]=r},t.prototype.jumpBy=function(t,e){return void 0===e&&(e=1),this.jumpTo(t,t.offset+e)},t.prototype.jumpTo=function(t,e){var r=new re(e,this.gen);return r.id=t.id,r.parentId=t.parentId,r.priority=t.priority,r.positions=t.positions,r.groups=t.groups,r.registers=t.registers,r},t.prototype.forkTo=function(t,e){var r=new re(e,this.gen);return r.id=++this.threadCounter,r.parentId=t.id,r.priority=t.priority,r.positions=Qt([],Jt(t.positions),!1),r.groups=Qt([],Jt(t.groups),!1),r.registers=Kt({},t.registers),r},t.prototype.startGroup=function(t,e,r){var n=this.forkTo(t,t.offset+1);return n.groups.push([e,r]),n},t.prototype.endGroup=function(t,e,r){var n=this.forkTo(t,t.offset+1);return n.groups.push([-e,r]),n},t.prototype.addThread=function(t,e,r,n){var i,o;if(void 0===n&&(n=0),!(t.offset<this.start||t.offset>this.end||this.genForOffset[t.offset-this.start]==this.gen)){this.genForOffset[t.offset-this.start]=this.gen;var s,a,u,l=this.prog.instrs[t.offset],c=l.opcode;switch(c){case Xt.Jump:u=this.jumpTo(t,l.args[0]),this.addThread(u,e,r,n);break;case Xt.Split:for(var h=0;h<l.args.length;h++){var f=l.args[h],p=0==h?this.jumpTo(t,f):this.forkTo(t,f);this.addThread(p,e,r,n)}break;case Xt.Save:u=this.jumpTo(t,t.offset+1),this.savePosition(u,l.args[0],r.index+n),this.tracer&&this.tracer.threadQueued(t,r.index+n),this.addThread(u,e,r,n);break;case Xt.GroupStart:u=this.startGroup(t,l.args[0],r.index+n),this.tracer&&this.tracer.threadQueued(t,r.index+n),this.addThread(u,e,r,n);break;case Xt.GroupEnd:u=this.endGroup(t,l.args[0],r.index+n),this.tracer&&this.tracer.threadQueued(t,r.index+n),this.addThread(u,e,r,n);break;case Xt.StartingChar:case Xt.MLStartingChar:a=this.prevCh(r),(0==r.index||c==Xt.MLStartingChar&&Yt(a))&&this.addThread(this.jumpBy(t,1),e,r,n);break;case Xt.EndingChar:case Xt.MLEndingChar:(""==(s=this.nextCh(r))||c==Xt.MLEndingChar&&Yt(s))&&this.addThread(this.jumpBy(t,1),e,r,n);break;case Xt.StartOfWord:case Xt.EndOfWord:break;case Xt.RBegin:var d=Jt(l.args,3),g=d[0],y=d[1],m=d[2],v=2*(1+g),b=t.positions[v],w=Jt(this.recurseMatch(r,b-1,l.offset+1,m,!1,1==y),2),S=w[0];w[1],S&&this.addThread(this.jumpTo(t,m+1),e,r,n);break;case Xt.Begin:var E=Jt(l.args,3),C=E[0],_=E[1],x=E[2];if(1==C)this.tracer&&this.tracer.threadQueued(t,r.index),e.push(t);else{var O=Jt(this.recurseMatch(r,r.index+1,l.offset+1,x,!0,1==_),2);S=O[0],O[1],S&&this.addThread(this.jumpTo(t,x+1),e,r,n)}break;case Xt.EnsureState:var A=l.args;try{for(var T=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(A),N=T.next();!N.done;N=T.next()){var R=N.value;if(this.currState==R){this.addThread(this.jumpBy(t,1),e,r,n);break}}}catch(t){i={error:t}}finally{try{N&&!N.done&&(o=T.return)&&o.call(T)}finally{if(i)throw i.error}}break;default:this.tracer&&this.tracer.threadQueued(t,r.index),e.push(t)}}},t.prototype.matchCurrPos=function(t,e,r){return void 0===r&&(r=!1),r?e.match(t.currChCodeLower)||e.match(t.currChCodeUpper):e.match(t.currChCode)},t.prototype.hasMore=function(t){return this.forward?t.hasMore:t.index>=0},t.prototype.nextCh=function(t){var e=t.index+(this.forward?1:-1);return t.charAt(e)},t.prototype.prevCh=function(t){return t.charAt(t.index-(this.forward?1:-1))},t.prototype.match=function(t){if(this.end<this.start)return null;this.startMatching(t);for(var e=null;this.currThreads.length>0;)e=this.stepChar(t,e);return null!=e&&(t.index=e.end),e},t.prototype.recurseMatch=function(e,r,n,i,o,s){void 0===o&&(o=!0),void 0===s&&(s=!1);var a=e.index;if(!e.canAdvance(o?1:-1))return[s,-1];e.index=r;var u=new t(this.prog,n,i,o).match(e),l=e.index;return e.index=a,[null!=u&&!s||null==u&&s,l]},t.prototype.startMatching=function(t){this.currThreads=[],this.nextThreads=[],this.gen++,this.addThread(new re(this.start,this.gen),this.currThreads,t),this.startPos=t.index},t.prototype.stepChar=function(t,e){void 0===e&&(e=null),this.gen++;for(var r=0;r<this.currThreads.length;r++){var n=this.currThreads[r],i=this.stepThread(t,n);if(null!=i&&(null==e||i.priority>e.priority||i.priority==e.priority&&i.end>e.end)){e=i;break}}return this.hasMore(t)&&t.advance(this.forward?1:-1),this.currThreads=this.nextThreads,this.nextThreads=[],e},t.prototype.stepThread=function(t,e){this.tracer&&this.tracer.threadStepped(e,t.index,this.gen);var r=null,n=this.prog.instrs[e.offset],o=n.opcode,s=(n.args,this.forward?1:-1),a=!1;switch(o){case Xt.RBegin:throw new Error("Invalid state. Reverse matches must be handled in addThread");case Xt.Begin:var u=Jt(n.args,3),l=u[0],c=u[1],h=u[2];i(1==l,"Plain lookahead cannot be here");var f=Jt(this.recurseMatch(t,t.index,n.offset+1,h,!0,1==c),2),p=f[0];f[1],p&&this.addThread(this.jumpTo(e,h+1),this.nextThreads,t);break;case Xt.End:var d=new Zt(-1,-1,this.startPos,t.index);return d.groups=e.groups,d.positions=e.positions,d;case Xt.Match:if(t.index>this.startPos){var g=n.args[0],y=n.args[1];(r=new Zt).start=this.startPos,r.end=t.index,r.priority=g,r.matchIndex=y,r.groups=e.groups,r.positions=e.positions}break;case Xt.Char:case Xt.CIChar:this.hasMore(t)&&(a=this.matchCurrPos(t,n.char,o==Xt.CIChar));break;case Xt.AnyNonNL:case Xt.Any:this.hasMore(t)&&(a=o==Xt.Any||!Yt(t.currCh))}return a&&this.addThread(this.jumpBy(e,1),this.nextThreads,t,s),r},t}();function ie(t){switch(t.opcode){case Xt.Match:return"Match ".concat(t.args[0]," ").concat(t.args[1]);case Xt.Char:case Xt.CIChar:return"".concat(Xt[t.opcode].toString()," ")+"".concat(t.char.debugValue());case Xt.Any:return".";case Xt.AnyNonNL:return"NL.";case Xt.StartingChar:return"^";case Xt.MLStartingChar:return"NL^";case Xt.EndingChar:return"$NL";case Xt.MLEndingChar:return"$NL_MultiLine";case Xt.Save:return"Save ".concat(t.args[0]);case Xt.GroupStart:return"GroupStart ".concat(t.args[0]);case Xt.GroupEnd:return"GroupEnd ".concat(t.args[0]);case Xt.Split:return"Split ".concat(t.args.join(", "));case Xt.Jump:return"Jump ".concat(t.args[0]);case Xt.Begin:return"Begin ".concat(t.args.join(" "));case Xt.RBegin:return"RBegin ".concat(t.args.join(" "));case Xt.End:return"End ".concat(t.args.join(" "));case Xt.EnsureState:return"EnsureState ".concat(t.args.join(" "));default:throw new Error("Invalid Opcode: "+t.opcode)}}var oe=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},se=function(){function t(t,e){void 0===e&&(e=null),this.regexResolver=t,this.listener=e,this.emitGroups=!1,this.emitPosition=!0}return t.prototype.compile=function(t){var e=this,r=new te,n=t.length<=1?new ee(Xt.Split):r.add(Xt.Split,null);return t.forEach(function(t,i){n.add(r.instrs.length);var o=null!=t.expr.ignoreCase&&t.expr.ignoreCase,s=null==t.expr.dotAll||t.expr.dotAll,a=null==t.expr.multiline||t.expr.multiline;if(t.needsSpecificStates&&null!=t.activeStates){var u=r.add(Xt.EnsureState,null);t.activeStates.forEach(function(t){var e=r.registerState(t);u.add(e)})}e.compileExpr(t.expr,r,o,s,a),r.add(Xt.Match,null).add(t.priority,t.matchIndex>=0?t.matchIndex:i)}),r},t.prototype.compileExpr=function(t,e,r,n,i){var o=e.length,s=e.length;if(t.groupIndex>=0&&(this.emitPosition&&e.add(Xt.Save).add(2*(1+t.groupIndex)),this.emitGroups&&e.add(Xt.GroupStart).add(1+t.groupIndex)),t.tag==xt.CHAR)this.compileChar(t,e,r,n,i);else if(t.tag==xt.START_OF_INPUT){var a=null==t.multiline?i:t.multiline;e.add(a?Xt.MLStartingChar:Xt.StartingChar)}else if(t.tag==xt.END_OF_INPUT)a=null==t.multiline?i:t.multiline,e.add(a?Xt.MLEndingChar:Xt.EndingChar);else if(t.tag==xt.START_OF_WORD)e.add(Xt.StartOfWord);else if(t.tag==xt.END_OF_WORD)e.add(Xt.EndOfWord);else if(t.tag==xt.CAT)this.compileCat(t,e,r,n,i);else if(t.tag==xt.UNION)this.compileUnion(t,e,r,n,i);else if(t.tag==xt.QUANT)this.compileQuant(t,e,r,n,i);else if(t.tag==xt.VAR)this.compileVar(t,e,r,n,i);else if(t.tag==xt.BACK_NAMED_REF)this.compileBackNamedRef(t,e,r,n,i);else if(t.tag==xt.BACK_NUM_REF)this.compileBackNumRef(t,e,r,n,i);else if(t.tag==xt.LOOK_AHEAD)this.compileLookAhead(t,e,r,n,i);else{if(t.tag!=xt.LOOK_BACK)throw new Error("Regex Type not yet supported: "+t.tag);this.compileLookBack(t,e,r,n,i)}return t.groupIndex>=0&&(this.emitGroups&&e.add(Xt.GroupEnd).add(1+t.groupIndex),this.emitPosition&&e.add(Xt.Save).add(2*(1+t.groupIndex)+1)),this.listener&&e.length>s&&this.listener(t,e,s,e.length-s),e.length-o},t.prototype.compileChar=function(t,e,r,n,i){t.op==It.AnyChar?e.add(n?Xt.Any:Xt.AnyNonNL):e.add(r?Xt.CIChar:Xt.Char).char=t},t.prototype.compileCat=function(t,e,r,n,i){var o,s;try{for(var a=oe(t.children),u=a.next();!u.done;u=a.next()){var l=u.value;this.compileExpr(l,e,r,n,i)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(s=a.return)&&s.call(a)}finally{if(o)throw o.error}}},t.prototype.compileBackNumRef=function(t,e,r,n,i){throw new Error("BackNumRef Not Implemented")},t.prototype.compileBackNamedRef=function(t,e,r,n,i){throw new Error("BackNameRef Not Implemented")},t.prototype.compileVar=function(t,e,r,n,i){var o=t.name.trim(),s=this.regexResolver?this.regexResolver(o):null;if(null==s)throw new Error("Cannot find expression: ".concat(o));this.compileExpr(s,e,r,n,i)},t.prototype.compileUnion=function(t,e,r,n,i){for(var o,s,a=e.add(Xt.Split),u=[],l=0;l<t.options.length;l++)a.add(e.length),this.compileExpr(t.options[l],e,r,n,i),l<t.options.length-1&&u.push(e.add(Xt.Jump));try{for(var c=oe(u),h=c.next();!h.done;h=c.next())h.value.add(e.length)}catch(t){o={error:t}}finally{try{h&&!h.done&&(s=c.return)&&s.call(c)}finally{if(o)throw o.error}}},t.prototype.compileQuant=function(t,e,r,n,i){if(0==t.minCount&&t.maxCount==o)this.compileAtleast0(t.expr,e,t.greedy,r,n,i);else if(1==t.minCount&&t.maxCount==o)this.compileAtleast1(t.expr,e,t.greedy,r,n,i);else if(0==t.minCount&&1==t.maxCount)this.compileOptional(t.expr,e,t.greedy,r,n,i);else{for(var s=0;s<t.minCount;s++)this.compileExpr(t.expr,e,r,n,i);if(t.isUnlimited)this.compileAtleast0(t.expr,e,t.greedy,r,n,i);else for(s=t.minCount;s<t.maxCount;s++)this.compileOptional(t.expr,e,t.greedy,r,n,i)}},t.prototype.compileAtleast1=function(t,e,r,n,i,o){void 0===r&&(r=!0);var s=e.length;this.compileExpr(t,e,n,i,o);var a=e.add(Xt.Split),u=e.length;r?a.add(s,u):a.add(u,s)},t.prototype.compileAtleast0=function(t,e,r,n,i,o){var s=e.add(Xt.Split),a=s.offset,u=e.length;this.compileExpr(t,e,n,i,o),e.add(Xt.Jump).add(a);var l=e.length;r?s.add(u,l):s.add(l,u)},t.prototype.compileOptional=function(t,e,r,n,i,o){var s=e.add(Xt.Split),a=e.length;this.compileExpr(t,e,n,i,o);var u=e.length;r?s.add(a,u):s.add(u,a)},t.prototype.compileLookAhead=function(t,e,r,n,i){this.compileExpr(t.expr,e,r,n,i);var o=e.add(Xt.Begin).add(0,t.negate?1:0);this.compileExpr(t.cond,e,r,n,i);var s=e.add(Xt.End).add(o.offset);o.add(s.offset)},t.prototype.compileLookBack=function(t,e,r,n,o){this.compileExpr(t.expr,e,r,n,o),i(t.expr.groupIndex>=0,"LookBack Assertion requires expression to have a group Index");var s=e.add(Xt.RBegin).add(t.expr.groupIndex,t.negate?1:0);this.compileExpr(t.cond.reverse(),e,r,n,o);var a=e.add(Xt.End).add(s.offset);s.add(a.offset)},t}(),ae=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ue=function(t){function e(e,r,n,i,o){void 0===o&&(o=null);var s=this.constructor,a=t.call(this,e)||this;return a.offset=r,a.length=n,a.type=i,a.value=o,a.name="TokenizerError",Object.setPrototypeOf(a,s.prototype),a}return ae(e,t),e}(Error),le=function(t){function e(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=t.call(this,"Found Token: ".concat((null==e?void 0:e.tag)||"EOF"," (").concat((null==e?void 0:e.value)||"","), Expected: ").concat(r.join(", ")))||this;return i.foundToken=e,i.name="UnexpectedTokenError",i.expectedTokens=r,i}return ae(e,t),e}(Error),ce=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),he=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},fe=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},pe=function(t){function e(e,r){void 0===r&&(r=!0);var n=t.call(this,r)||this;return n.forward=r,n._rawInput=e,n.input=fe([],he(e),!1),n}return ce(e,t),e.prototype.push=function(t){var e;this._rawInput+=t,(e=this.input).push.apply(e,fe([],he(t),!1))},e.prototype.substring=function(t,e){return this._rawInput.substring(t,e)},e.prototype.hasIndex=function(t){return t>=0&&t<this.input.length},e.prototype.charAt=function(t){return t<0||t>=this.input.length?"":this.input[t]},e}(function(){function t(t){void 0===t&&(t=!0),this.forward=t,this.index=0}return t.prototype.advance=function(t){void 0===t&&(t=1);var e=this.forward?this.index+t:this.index-t;return this.index=e,!0},t.prototype.canAdvance=function(t){void 0===t&&(t=1);var e=this.forward?this.index+t:this.index-t;return this.hasIndex(e)},Object.defineProperty(t.prototype,"hasMore",{get:function(){var t=this.forward?this.index:this.index-1;return this.hasIndex(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currCh",{get:function(){return this.charAt(this.index)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"prevCh",{get:function(){return this.charAt(this.index-(this.forward?1:-1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nextCh",{get:function(){var t=this.index+(this.forward?1:-1);return this.charAt(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currChCode",{get:function(){return this.hasMore?this.currCh.charCodeAt(0):-1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currChCodeLower",{get:function(){return this.hasMore?this.currCh.toLowerCase().charCodeAt(0):-1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currChCodeUpper",{get:function(){return this.hasMore?this.currCh.toUpperCase().charCodeAt(0):-1},enumerable:!1,configurable:!0}),t.prototype.charCodeAt=function(t){return this.hasIndex(t)?this.charAt(t).charCodeAt(0):-1},t.prototype.charCodeAtLower=function(t){return this.hasIndex(t)?this.charAt(t).toLowerCase().charCodeAt(0):-1},t.prototype.charCodeAtUpper=function(t){return this.hasIndex(t)?this.charAt(t).toUpperCase().charCodeAt(0):-1},t}()),de=function(){function t(){}return t.advanceAfter=function(e,r,n){void 0===n&&(n=!0);var i=t.advanceTo(e,r,n);return i>=0&&(i+=r.length,e.index=i),i},t.advanceTo=function(e,r,n){void 0===n&&(n=!0);for(var i=e.index;e.hasMore;){var o=e.index;if(t.matches(e,r)){var s=e.index;e.index=o;var a=0;if(n)for(var u=s-1;u>=0&&"\\"==e.charAt(u);u--)a++;if(a%2==0)return e.index}e.advance(1)}throw e.index=i,new Error("Unexpected end of input before (".concat(r,")"))},t.matches=function(t,e,r){void 0===r&&(r=!0);for(var n=t.index,i=0,o=!0;i<e.length;i++){if(e[i]!=t.currCh){o=!1;break}t.advance(1)}return r&&o||(t.index=n),o},t}(),ge=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ye=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},me=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},ve=function(){function t(e,r,n,i){this.tag=e,this.matchIndex=r,this.start=n,this.end=i,this.id=t.idCounter++,this.value=null,this.groups={},this.positions={}}return t.prototype.isOneOf=function(){for(var t,e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{for(var i=ge(r),o=i.next();!o.done;o=i.next()){var s=o.value;if(this.tag==s)return!0}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return!1},t.idCounter=0,t}(),be=function(){function t(t,e){this.nextToken=t,this.tokenizerContext=e,this.buffer=[]}return t.prototype.next=function(t){var e=this.peek(t);return null!=e&&this.consume(),e},t.prototype.peek=function(t,e){for(void 0===e&&(e=0);this.buffer.length<=e;){var r=this.nextToken(t,this.tokenizerContext);if(null==r)return null;this.buffer.push(r)}return this.buffer[e]},t.prototype.match=function(t,e,r,n,i){void 0===r&&(r=!1),void 0===n&&(n=!0);var o=this.peek(t);if(null!=o){if(!e(o)){if(r)throw new le(o);return null}i&&null!=i&&i(o),n&&this.consume()}else if(r)throw new ue("Unexpected end of input",-1,0,"UnexpectedEndOfInput");return o},t.prototype.consume=function(){this.buffer.splice(0,1)},t.prototype.consumeIf=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.match(t,function(t){return t.isOneOf.apply(t,me([],ye(e),!1))})},t.prototype.expectToken=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.match(t,function(t){return t.isOneOf.apply(t,me([],ye(e),!1))},!0,!0)},t.prototype.ensureToken=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return this.match(t,function(t){return t.isOneOf.apply(t,me([],ye(e),!1))},!0,!1)},t.prototype.nextMatches=function(t){for(var e,r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var o=this.peek(t);if(null==o)return null;try{for(var s=ge(n),a=s.next();!a.done;a=s.next()){var u=a.value;if(o.tag==u)return o}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return null},t}(),we=function(){function t(){this.value=-1}return t.prototype.next=function(){return++this.value},Object.defineProperty(t.prototype,"current",{get:function(){return this.value},enumerable:!1,configurable:!0}),t}();function Se(t){return" "==t||"\t"==t||"\n"==t||"\r"==t}var Ee=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Ce=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},_e=function(){function t(t,e){this.pattern=t,this.counter=new we,this.unicode=(null==e?void 0:e.unicode)||!1}return t.prototype.reduceLeft=function(t){var e=1==t.length?t[0]:new(Ut.bind.apply(Ut,Ce([void 0],Ee(t),!1)));return t.splice(0),e},t.prototype.throwError=function(t){throw new SyntaxError("Error in JS RE '".concat(this.pattern,"': ").concat(t))},t.prototype.parse=function(t,e){void 0===t&&(t=0),void 0===e&&(e=-1);var r=this.pattern,n=[];for(e<0&&(e=r.length-1);t<=e;){var i=r[t];if("."==i)n.push(Vt.Any()),t++;else if("\\"==i&&r[t+1]>="1"&&r[t+1]<="9"){t++;for(var o="";t<=e&&r[t]>="0"&&r[t]<="9";)o+=r[t++];var s=parseInt(o);s>this.counter.current+1&&this.throwError("Invalid reference: "+s),n.push(new Wt(s))}else if("\\"==i&&"k"==r[t+1]&&"<"==r[t+2]){for(var a=t+=3;a<=e&&">"!=r[a];)a++;a>e&&this.throwError("Expected '>' found EOI");var u=r.substring(t,a);""==u.trim()&&this.throwError("Expected name"),n.push(new qt(u)),t=a+1}else if("["==i){for(var l=t+1;l<=e&&"]"!=r[l];)"\\"==r[l]&&l++,l++;l>e&&this.throwError("Expected ']' found EOI"),n.push(this.parseCharGroup(t+1,l-1)),t=l+1}else if("^"==i)n.push(new Lt),t++;else if("$"==i)n.push(new Pt),t++;else if("|"==i){if(t+1<=e){var c=this.reduceLeft(n),h=this.parse(t+1,e);return new Ft(c,h)}t=e+1}else if("("==i)t=this.parseGroup(n,t,e);else if(")"==i||"]"==i||"}"==i)this.throwError("Unmatched ".concat(i,". Try using \\").concat(i));else if("*"==r[t]||"?"==r[t]||"+"==r[t]||"{"==r[t])t=this.parseQuant(n,t,e);else{var f=Ee(this.parseChar(t,e),2),p=f[0],d=f[1];n.push(p),t+=d}}return n.length,1==n.length?n[0]:new(Ut.bind.apply(Ut,Ce([void 0],Ee(n),!1)))},t.prototype.parseGroup=function(t,e,r){for(var n=e+1,i=0,o=this.pattern;n<=r&&(")"!=o[n]||i>0);)"("==o[n]?i++:")"==o[n]&&i--,"\\"==o[n]&&n++,n++;var s;if(n>r&&this.throwError("Expected ')' found EOI"),"?"==o[++e])if(":"==o[++e])t.push(this.parse(e+1,n-1));else if("<"==o[e]&&"!"!=o[e+1]&&"="!=o[e+1]){for(var a=this.counter.next(),u="",l=e+1;l<=r&&">"!=o[l];)u+=o[l],l++;(s=this.parse(l+1,n-1)).groupIndex=a,u.length>0&&(s.groupName=u)}else{var c=!0;"<"==o[e]&&(e++,c=!1);var h="!"==o[e++],f=this.parse(e,n-1);if(!c){var p=this.parse(n+1,r);return p.groupIndex<0&&(p.groupIndex=this.counter.next(),p.groupIsSilent=!0),t.push(new Mt(p,f,h)),r+1}t.length;var d=new jt(this.reduceLeft(t),f,h);t.push(d)}else a=this.counter.next(),h=!1,"^"==o[e]&&(h=!0,e++),(s=this.parse(e,n-1)).groupIndex>=0&&(s=new Ut(s)),s.groupIndex=a,t.push(s);return n+1},t.prototype.parseCharGroup=function(t,e){var r=[],n=t,i=!1,o=this.pattern;for("^"==o[n]&&(i=!0,n++);n<=e;){var s=Ee(this.parseChar(n,e),2),a=s[0];if((n+=s[1])<o.length&&"-"==o[n])if("]"==o[++n]||"["==o[n])r.push(a),r.push(Vt.Single("-"));else if(n<=e){var u=Ee(this.parseChar(n,e),2),l=u[0],c=u[1];a.op==It.SingleChar&&l.op==It.SingleChar||this.throwError("Char range cannot start or end in a char class"),l.args[0]<a.args[0]&&this.throwError("End cannot be less than start"),r.push(zt.Range(a,l)),n+=c}else this.throwError("Unterminated char class");else r.push(a)}return zt.Union(i,r)},t.prototype.parseChar=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),"\\"==this.pattern[t]?this.parseEscapeChar(t,e):this.parseSingleChar(t,e)},t.prototype.parseSingleChar=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var r=this.pattern.charCodeAt(t);return[Vt.Single(r),1]},t.prototype.parsePropertyEscape=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var r=this.pattern;r[t]+1!="{"&&this.throwError("Invalid property escape");for(var n=t+=2,i=-1;n<=e&&"}"!=r[n];)"="==r[n]&&(i=n),n++;n>e&&this.throwError("Invalid property escape");var o=r.substring(t,n),s="General_Category",a=o;if(i>=0){var u=o.split("=");2!=u.length&&this.throwError("Invalid property escape"),s=u[0].trim(),a=u[1].trim()}return[Vt.PropertyEscape(s,a),2+n+1-t]},t.prototype.parseEscapeChar=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var r=this.pattern;i("\\"==r[t],"Expected '\\'"),++t>e&&this.throwError("Encounted unexpected end of input after \\");var n=r[t];if(this.unicode&&"p"==n||"P"==n)return this.parsePropertyEscape(t,e);switch(n){case"w":return[Vt.Class(q.WORD_CHAR),2];case"W":return[Vt.Class(q.WORD_CHAR,!0),2];case"d":return[Vt.Class(q.DIGITS),2];case"D":return[Vt.Class(q.DIGITS,!0),2];case"s":return[Vt.Class(q.SPACES),2];case"S":return[Vt.Class(q.SPACES,!0),2];case"0":return r[t+1]>="0"&&r[t+1]<="9"&&this.unicode&&this.throwError("Invalid decimal escape"),[Vt.Single("\0"),2];case"r":return[Vt.Single("\r"),2];case"n":return[Vt.Single("\n"),2];case"f":return[Vt.Single("\f"),2];case"b":return[Vt.Single("\b"),2];case"v":return[Vt.Single("\v"),2];case"t":return[Vt.Single("\t"),2];case"c":(this.unicode||t>=e)&&this.throwError("Invalid char sequence at ".concat(t,", ").concat(e));var o=r.charCodeAt(t+1)%32;return[Vt.Single(o),3];case"x":++t>=e&&this.throwError("Invalid hex sequence at ".concat(t,", ").concat(e));var s=r.substring(t,t+2),a=parseInt(s,16);return i(!isNaN(a),"Invalid hex sequence: '".concat(s,"'")),[Vt.Single(a),4];case"u":++t>e-3&&this.throwError("Invalid unicode sequence at ".concat(t));var u=r.substring(t,t+4),l=parseInt(u,16);return isNaN(l)&&this.throwError("Invalid unicode sequence: '".concat(u,"'")),[Vt.Single(l),6];case"^":case"$":case".":case"*":case"+":case"?":case"\\":case"'":case'"':case"(":case")":case"[":case"]":case"{":case"}":case"|":case"/":return[Vt.Single(n),2];default:return this.unicode&&this.throwError("Invalid escape character: "+n),[Vt.Single(n),2]}},t.prototype.parseQuant=function(t,e,r){var n=this.pattern,i=n[e-1],s=1,a=1;if("*"==n[e])s=0,a=o;else if("+"==n[e])s=Math.min(s,1),a=o;else if("?"==n[e])s=0,a=Math.max(a,1);else{if("{"!=n[e])throw new Error("Here?");var u=n.indexOf("}",e+1);(u<=e||u>r)&&this.throwError("Unexpected end of input while looking for '}'");var l=n.substring(e+1,u).trim(),c=l.split(",").map(function(t){return parseInt(t.trim())});if(e=u,1==c.length){if(isNaN(c[0])){if(l.trim().length>0)return t.push(new Gt(l.trim())),e+1;this.throwError("Invalid quantifier: /".concat(l,"/"))}s=a=c[0]}else 2==c.length?(s=isNaN(c[0])?0:c[0])>(a=isNaN(c[1])?o:c[1])&&this.throwError("Invalid Quant /".concat(l,"/: Min must be <= Max")):c.length>2&&this.throwError('Invalid quantifier spec: "{'.concat(l,'}"'))}t.length<=0&&this.throwError("Quantifier cannot appear before an expression");var h=t[t.length-1];h.tag!=xt.QUANT||"*"!=i&&"?"!=i&&"+"!=i&&"}"!=i||this.throwError("Nothing to repeat"),!this.unicode||h.tag!=xt.LOOK_AHEAD&&h.tag!=xt.LOOK_BACK||this.throwError("Cannot have quantifier on assertion in unicode mode");var f=t[t.length-1]=new Dt(h);return f.minCount=s,f.maxCount=a,++e<=r&&"?"==n[e]&&f.greedy&&(e++,f.greedy=!1),e},t}(),xe=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Oe=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};function Ae(t,e){for(var r=t.index,n=0;n<e.length;n++){if(t.currCh!=e.charAt(n))return t.index=r,!1;t.advance(1)}return!0}var Te=function(){function t(){this.counter=new we}return t.prototype.parse=function(t,e,r){void 0===e&&(e=!1),void 0===r&&(r=0);for(var n=[];t.hasMore;){var o=t.currCh;if(Ae(t,"."))n.push(Vt.Any());else if(Ae(t,"^"))(s=new Lt).multiline=!0,n.push(s);else if(Ae(t,"$")){var s;(s=new Pt).multiline=!0,n.push(s)}else{if(Ae(t,"|")){var a=this.reduceLeft(n),u=this.parse(t,e,r);return new Ft(a,u)}if("["==o)n.push(this.parseCharGroup(t));else if("*"==o||"?"==o||"+"==o||"{"==o)this.parseQuant(t,n);else if(e&&Se(o))t.advance(1);else if(e&&Ae(t,"/*")){for(;"*"!=t.currCh||"/"!=t.nextCh;)t.hasMore||this.throwError(t,"Unterminated comment"),t.advance(1);t.advance(2)}else{if(Ae(t,"{-}"))throw new Error("Intersection Not yet supported");if(Ae(t,"{+}"))throw new Error("Union Not yet supported");if(Ae(t,"("))if(Ae(t,"?"))if(Ae(t,"#")){for(;t.hasMore&&")"!=t.currCh;)t.advance(1);i(Ae(t,")"),"Expected ')'")}else{for(var l=!1,c=!1,h=e,f=!1;t.hasMore&&":"!=t.currCh;)"i"==t.currCh?l=!f:"s"==t.currCh?c=!f:"x"==t.currCh?h=!f:"-"==t.currCh&&(f=!0),t.advance(1);i(Ae(t,":"),"Expected ':'");var p=this.counter.next();(d=this.parse(t,h,r+1)).groupIndex>=0&&(d=new Ut(d)),d.dotAll=c,d.ignoreCase=l,d.groupIndex=p,n.push(d),i(Ae(t,")"),"Expected ')'")}else{var d;p=this.counter.next(),(d=this.parse(t,e,r+1)).groupIndex>=0&&(d=new Ut(d)),d.groupIndex=p,n.push(d),i(Ae(t,")"),"Expected ')'")}else{if(")"==o){0==r&&this.throwError(t,"Unmatched ".concat(o,". Try using \\").concat(o));break}if("]"==o||"}"==o)this.throwError(t,"Unmatched ".concat(o,". Try using \\").concat(o));else{if(Ae(t,"/"))return a=this.reduceLeft(n),u=this.parse(t,e,r),new jt(a,u,!1);if(Ae(t,'"')){for(;'"'!=t.currCh;)t.hasMore||this.throwError(t,"Unterminated string"),n.push(this.parseChar(t));t.advance(1)}else n.push(this.parseChar(t))}}}}}return 1==n.length?n[0]:new(Ut.bind.apply(Ut,Oe([void 0],xe(n),!1)))},t.prototype.parseQuant=function(t,e){var r=1,n=1;if(Ae(t,"*"))r=0,n=o;else if(Ae(t,"+"))r=Math.min(r,1),n=o;else if(Ae(t,"?"))r=0,n=Math.max(n,1);else if(Ae(t,"{")){for(var i=!1,s="",a="";t.hasMore&&"}"!=t.currCh;)","==t.currCh?i=!0:i?a+=t.currCh:s+=t.currCh,t.advance(1);t.hasMore||this.throwError(t,"Invalid property escape"),s=s.trim(),a=a.trim(),t.advance(1);var u=parseInt(s),l=parseInt(a);if(i)(r=isNaN(u)?0:u)>(n=isNaN(l)?o:l)&&this.throwError(t,"Invalid Quant /".concat(s,",").concat(a,"/: Min must be <= Max"));else if(isNaN(u)){if(s.length>0)return void e.push(new Gt(s));this.throwError(t,"Invalid quantifier: /".concat(s,"/")),r=n=1}else r=n=u}else this.throwError(t,"Expected '{', '*', '?' or '+', Found: "+t.currCh);e.length<=0&&this.throwError(t,"Quantifier cannot appear before an expression");var c,h=e[e.length-1];h.tag==xt.QUANT&&h.groupIndex<0?((c=h).minCount=Math.min(r,c.minCount),c.maxCount=Math.max(n,c.maxCount)):((c=e[e.length-1]=new Dt(h)).minCount=r,c.maxCount=n),c.greedy&&Ae(t,"?")&&(c.greedy=!1)},t.prototype.parseCharGroup=function(t){var e=[];i(Ae(t,"["),"Expected '['");for(var r=Ae(t,"^");"]"!=t.currCh;){var n=this.parseChar(t);if(Ae(t,"-"))if(t.hasMore)if("]"==t.currCh||"["==t.currCh)e.push(n),e.push(Vt.Single("-"));else{var o=this.parseChar(t);n.op==It.SingleChar&&o.op==It.SingleChar||this.throwError(t,"Char range cannot start or end in a char class"),o.args[0]<n.args[0]&&this.throwError(t,"End cannot be less than start"),e.push(zt.Range(n,o))}else this.throwError(t,"Unterminated char class");else e.push(n)}return i(Ae(t,"]"),"']' expected"),zt.Union(r,e)},t.prototype.parseChar=function(t){return"\\"==t.currCh?this.parseEscapeChar(t):this.parseSingleChar(t)},t.prototype.parseSingleChar=function(t){var e=t.currCh;return t.advance(1),Vt.Single(e)},t.prototype.parsePropertyEscape=function(t){i(Ae(t,"\\{"),"Invalid property escape"),t.advance(2);for(var e=!1,r="",n="";t.hasMore&&"}"!=t.currCh;)"="==t.currCh?e=!0:e?n+=t.currCh:r+=t.currCh,t.advance(1);return t.hasMore||this.throwError(t,"Invalid property escape"),r=r.trim(),n=n.trim(),e||(n=r,r="General_Category"),t.advance(1),Vt.PropertyEscape(r,n)},t.prototype.parseEscapeChar=function(t){if(i(Ae(t,"\\"),"Expected '\\'"),t.hasMore||this.throwError(t,"Encounted unexpected end of input after \\"),Ae(t,"w"))return Vt.Class(q.WORD_CHAR);if(Ae(t,"W"))return Vt.Class(q.WORD_CHAR,!0);if(Ae(t,"d"))return Vt.Class(q.DIGITS);if(Ae(t,"D"))return Vt.Class(q.DIGITS,!0);if(Ae(t,"s"))return Vt.Class(q.SPACES);if(Ae(t,"S"))return Vt.Class(q.SPACES,!0);if(Ae(t,"0"))return Vt.Single("\0");if(Ae(t,"r"))return Vt.Single("\r");if(Ae(t,"n"))return Vt.Single("\n");if(Ae(t,"f"))return Vt.Single("\f");if(Ae(t,"b"))return Vt.Single("\b");if(Ae(t,"v"))return Vt.Single("\v");if(Ae(t,"t"))return Vt.Single("\t");if(Ae(t,"\\"))return Vt.Single("\\");if(Ae(t,"'"))return Vt.Single("'");if(Ae(t,'"'))return Vt.Single('"');if(Ae(t,"x")){t.hasMore||this.throwError(t,"Invalid hex sequence at ".concat(t.index));var e=t.currCh+t.nextCh,r=parseInt(e,16);return i(!isNaN(r),"Invalid hex sequence: '".concat(e,"'")),t.advance(2),Vt.Single(r)}if(Ae(t,"u")){t.canAdvance(3)||this.throwError(t,"Invalid unicode sequence at ".concat(t.index));var n=t.substring(t.index,t.index+4),o=parseInt(n,16);return isNaN(o)&&this.throwError(t,"Invalid unicode sequence: '".concat(n,"'")),t.advance(4),Vt.Single(o)}var s=t.currCh;return t.advance(1),Vt.Single(s)},t.prototype.reduceLeft=function(t){var e=1==t.length?t[0]:new(Ut.bind.apply(Ut,Oe([void 0],xe(t),!1)));return t.splice(0),e},t.prototype.throwError=function(t,e){throw new Error(e)},t}();function Ne(t,e){var r;return"string"==typeof t?((r=new Ht(Ie(t,e),e)).pattern=t,r):"RegExp"==t.constructor.name?((r=new Ht(Ie(t,e),e)).pattern=t.source,r):new Ht(t,e)}function Re(t){var e=new Te;try{var r=e.parse(new pe(t));return null==r.dotAll&&(r.dotAll=!1),null==r.multiline&&(r.multiline=!1),r}catch(e){throw console.log("Error in FLEX RE: ",t),e}}function Ie(t,e){e=e||{};var r="string"!=typeof t,n="string"==typeof t?t:t.source;r&&(e.unicode=t.unicode);var i=new _e(n,e).parse();return"string"!=typeof t&&(i.dotAll=t.dotAll,i.ignoreCase=t.ignoreCase,i.multiline=t.multiline),i}function ke(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return Re(String.raw.apply(String,function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([t],function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}(e),!1)))}var Le,Pe,Be,je,Me,De,Ue=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Fe=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},$e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.idCounter=0,e}return Ue(e,t),e.prototype.next=function(t,e){if(!t.hasMore)return null;var r=t.index,n=t.currCh,i=this.vm.match(t);if(null==i){var o=null;if(o=t.index==r+1?new ue("Unexpected Character: ".concat(n),r,1,"UnexpectedCharacter",n):new ue("Unexpected Symbol: ".concat(t.substring(r,t.index)),r,t.index-r,"UnexpectedLexeme"),this.onError&&(o=this.onError(o,t,r)),null!=o)throw o;return this.next(t,e)}var s=this.allRules[i.matchIndex],a=function(t,e,r){for(var n,i,o=new ve(t,e.matchIndex,e.start,e.end),s=0;s<e.positions.length;s+=2)e.positions[s]>=0&&(o.positions[Math.floor(s/2)]=[e.positions[s],e.positions[s+1]]);try{for(var a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.groups),u=a.next();!u.done;u=a.next()){var l=Fe(u.value,2),c=l[0],h=l[1],f=Math.abs(c);f in o.groups||(o.groups[f]=[]),o.groups[f].push(h)}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return null!=r&&(o.value=r.substring(e.start,e.end)),o}(s.tag,i,t);a.id=this.idCounter++;var u=this.onMatchHandlers[i.matchIndex];if(u||(u=this.matchHandlersByValue[s.tag]),u){if(null==(a=u(s,t,a,e)))return this.next(t,e)}else if(s.skip)return this.next(t,e);return a},e.prototype.tokenize=function(t,e){void 0===e&&(e=null);var r=[];"string"==typeof t&&(t=new pe(t));for(var n=this.next(t,e);n;){r.push(n);try{n=this.next(t,e)}catch(t){r.push({tag:"ERROR",start:t.offset,end:t.offset+t.length,value:t.message});break}}return r},e}(function(){function t(){var t=this;this._prog=null,this._vm=null,this.onError=null,this.allRules=[],this.onMatchHandlers=[],this.matchHandlersByValue={},this.variables=new Map,this.compiler=new se(function(e){var r,n=t.variables.get(e)||null;if(null==n&&(n=(null===(r=t.findRuleByValue(e))||void 0===r?void 0:r.expr)||null),null==n)throw new Error("Invalid regex reference: ".concat(e));return n})}return t.prototype.getVar=function(t){return this.variables.get(t)||null},t.prototype.addVar=function(t,e){var r=this.variables.get(t)||null;return r=null==r?e:new Ft(r,e),this.variables.set(t,e),this},t.prototype.findRuleByValue=function(t){return this.allRules.find(function(e){return e.tag==t})||null},t.prototype.add=function(t,e,r){return void 0===r&&(r=null),"function"==typeof e&&(r=e,e=null),this.addRule(Ne(t,e),r)},t.prototype.addRule=function(t,e){return void 0===e&&(e=null),t.matchIndex=this.allRules.length,this.allRules.push(t),this.onMatchHandlers.push(e),this._prog=null,this._vm=null,this},t.prototype.on=function(t,e){return this.matchHandlersByValue[t]=e,this},Object.defineProperty(t.prototype,"prog",{get:function(){if(null==this._prog){var t=this.sortRules();this._prog=this.compiler.compile(t)}return this._prog},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vm",{get:function(){return null==this._vm&&(this._vm=new ne(this.prog)),this._vm},enumerable:!1,configurable:!0}),t.prototype.sortRules=function(){var t=this.allRules.map(function(t){return t});return t.sort(function(t,e){return t.priority!=e.priority?e.priority-t.priority:t.matchIndex-e.matchIndex}),t},t}()),Ve=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},ze=(function(){function t(t){this.peekedToken=null,this.literals=[],this.matchers=[],"string"==typeof t&&(t=new pe(t)),this.tape=t}t.prototype.addMatcher=function(t,e){return void 0===e&&(e=!1),this.matchers.push([t,e]),this},t.prototype.addLiteral=function(t,e){var r=this.literals.findIndex(function(e){return e[0]==t});if(r<0)return this.literals.push([t,e]),this.literals.length-1;if(this.literals[r][1]!=e)throw new Error("Literal '".concat(t,"' already registered as ").concat(e));return r},t.prototype.nextToken=function(){if(!this.tape.hasMore)return null;for(var t=this.tape.index,e=0;e<this.literals.length;e++){var r=Ve(this.literals[e],2),n=r[0],i=r[1];if(de.matches(this.tape,n)){var o=new ve(i,e,t,this.tape.index);return o.value=n,o}}for(e=0;e<this.matchers.length;e++){var s=Ve(this.matchers[e],2),a=s[0],u=s[1],l=a(this.tape,t);if(null!=l)return u?this.nextToken():(l.start=t,l.end=this.tape.index,l)}throw new ue("Invalid Character",this.tape.index,1,"InvalidCharacter",this.tape.currCh)}}(),function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}),Ge=ke(Le||(Le=ze(['["]([^"\\\n]|\\.|\\\n)*["]'],['["]([^"\\\\\\n]|\\\\.|\\\\\\n)*["]']))),qe=ke(Pe||(Pe=ze(["[']([^'\\\n]|\\.|\\\n)*[']"],["[']([^'\\\\\\n]|\\\\.|\\\\\\n)*[']"]))),We=(String.raw(Be||(Be=ze(["/([^\\/]|\\.)*/([imus]*)"],["/([^\\\\/]|\\\\.)*/([imus]*)"]))),String.raw(je||(je=ze(["/(.+?(?<!\\))/([imus]*)"],["/(.+?(?<!\\\\))/([imus]*)"])))),He=function(){return He=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},He.apply(this,arguments)},Ke=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Je=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},Qe=function(t){return"number"==typeof t?""+t:t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")};!function(t){t.STRING="STRING",t.REGEX="REGEX",t.NUMBER="NUMBER",t.SPACES="SPACES",t.IDENT="IDENT",t.PCT_IDENT="PCT_IDENT",t.STAR="STAR",t.PLUS="PLUS",t.QMARK="QMARK",t.PIPE="PIPE",t.DOLLAR_NUM="DOLLAR_NUM",t.DOLLAR_IDENT="DOLLAR_IDENT",t.OPEN_PAREN="OPEN_PAREN",t.CLOSE_PAREN="CLOSE_PAREN",t.OPEN_BRACE="OPEN_BRACE",t.CLOSE_BRACE="CLOSE_BRACE",t.OPEN_SQ="OPEN_SQ",t.CLOSE_SQ="CLOSE_SQ",t.COMMENT="COMMENT",t.ARROW="ARROW",t.COLCOLHYPHEN="COLCOLHYPHEN",t.COLON="COLON",t.SEMI_COLON="SEMI_COLON"}(Me||(Me={})),function(t){t.GRAMMAR="GRAMMAR",t.DECL="DECL",t.RULE="RULE",t.PROD_NULL="PROD_NULL",t.PROD_STR="PROD_STR",t.PROD_UNION="PROD_UNION",t.PROD_NAME="PROD_NAME",t.PROD_STRING="PROD_STRING",t.PROD_NUM="PROD_NUM",t.PROD_IDENT="PROD_IDENT",t.PROD_STAR="PROD_STAR",t.PROD_PLUS="PROD_PLUS",t.PROD_OPTIONAL="PROD_OPTIONAL",t.IDENT="IDENT",t.ERROR="ERROR",t.COMMENT="COMMENT"}(De||(De={}));var Ye=function(){function t(t,e){this.leftRecursive=!1,this.generatedTokenizer=new $e,this.regexSyntax="js",e=e||{},this.symbolsByLabel={},this.grammar=e.grammar||new ct,this.leftRecursive=!("leftRecursive"in e)||e.leftRecursive||!1,this.newSymbolCallback=e.newSymbolCallback||null,this.tokenHandlers=e.tokenHandlers||{},this.parse(t)}return t.prototype.symbolForLabel=function(t){return this.symbolsByLabel[t]||null},t.prototype.registerSymbol=function(t,e){i(!(t in this.symbolsByLabel),"".concat(t," is already registered")),this.symbolsByLabel[t]=e},t.prototype.ensureSymbol=function(t,e){var r=this.symbolForLabel(t);return null!=r||(this.newSymbolCallback&&(r=this.newSymbolCallback(t,e)||null),null==r&&(r=e?this.grammar.newTerm(t):this.grammar.newNT(t)),this.registerSymbol(t,r)),r},t.prototype.parse=function(t){var e,r=this,n=((e=new $e).add(/->/,{tag:Me.ARROW}),e.add(/\[/,{tag:Me.OPEN_SQ}),e.add(/\]/,{tag:Me.CLOSE_SQ}),e.add(/\(/,{tag:Me.OPEN_PAREN}),e.add(/\)/,{tag:Me.CLOSE_PAREN}),e.add(/\{/,{tag:Me.OPEN_BRACE}),e.add(/\}/,{tag:Me.CLOSE_BRACE}),e.add(/\*/,{tag:Me.STAR}),e.add(/\+/,{tag:Me.PLUS}),e.add(/\?/,{tag:Me.QMARK}),e.add(/;/,{tag:Me.SEMI_COLON}),e.add(/:/,{tag:Me.COLON}),e.add(/\|/,{tag:Me.PIPE}),e.add(/\s+/m,{tag:Me.SPACES},function(){return null}),e.add(/\/\*.*?\*\//s,{tag:Me.COMMENT},function(){return null}),e.add(/\/\/.*$/m,{tag:Me.COMMENT},function(){return null}),e.add(qe,{tag:Me.STRING},function(t,e,r){return r.value=e.substring(r.start+1,r.end-1),r}),e.add(Ge,{tag:Me.STRING},function(t,e,r){return r.value=e.substring(r.start+1,r.end-1),r}),e.add(We,{tag:Me.REGEX},function(t,e,r){var n=e.substring(r.positions[1][0],r.positions[1][1]),i=e.substring(r.positions[3][0],r.positions[3][1]);return r.value=[n,i],r}),e.add(/\d+/,{tag:Me.NUMBER},function(t,e,r){return r.value=parseInt(e.substring(r.start,r.end)),r}),e.add(/%([\w][\w\d_]*)/,{tag:Me.PCT_IDENT},function(t,e,r){return r.value=e.substring(r.start+1,r.end),r}),e.add(/\$\d+/,{tag:Me.DOLLAR_NUM},function(t,e,r){return r.value=parseInt(e.substring(r.start+1,r.end)),r}),e.add(/\$([\w][\w\d_]*)/,{tag:Me.DOLLAR_IDENT},function(t,e,r){return r.value=e.substring(r.start+1,r.end),r}),e.add(/[\w][\w\d_]*/,{tag:Me.IDENT}),e);this.tokenizer=new be(function(t,e){return n.next(t,r)},this),this.parseGrammar(new pe(t))},t.prototype.parseRegex=function(t,e,r,n){if(void 0===r&&(r=0),void 0===n&&(n=""),""==n&&(n=this.regexSyntax),"js"==n){var i=this.tokenizer.expectToken(t,Me.STRING,Me.NUMBER,Me.REGEX),o=void 0;if(e&&0!=e.length||(e="/"+i.value[0]+"/"+i.value[1]),i.tag==Me.STRING||i.tag==Me.NUMBER)o=Ne(Qe(i.value),{tag:e,priority:r+20});else{if(i.tag!=Me.REGEX)throw new le(i);var s=i.value[0];i.value[1].length>0&&(s=new RegExp(i.value[0],i.value[1])),o=Ne(s,{tag:e,priority:r+10})}return o}for(var a="";t.hasMore&&"\n"!=t.currCh;)a+=t.currCh,t.advance();return a=a.trim(),e&&0!=e.length||(e="/"+a+"/"),new Ht(Re(a),{tag:e,priority:r})},t.prototype.parseGrammar=function(t){for(var e=this.tokenizer.peek(t);null!=e;){if(e.tag==Me.IDENT)this.parseDecl(t);else{if(e.tag!=Me.PCT_IDENT)throw new SyntaxError("Declaration must start with IDENT or PCT_IDENT. Found: '".concat(e.value,"' instead."));this.tokenizer.next(t),this.parseDirective(t,e.value)}e=this.tokenizer.peek(t)}},t.prototype.parseDirective=function(t,e){var r=this;if("start"==e){var n=this.tokenizer.expectToken(t,Me.IDENT);this.grammar.startSymbol=this.ensureSymbol(n.value,!1)}else if("resyntax"==e){if("js"!=(n=this.tokenizer.expectToken(t,Me.IDENT)).value&&"flex"!=n.value)throw new SyntaxError("Invalid regex syntax: "+n.value);this.regexSyntax=n.value}else if(e.startsWith("skip")){var i=this.parseRegex(t,"",30,e.endsWith("flex")?"flex":""),o=this.parseTokenHandler(t);o?this.generatedTokenizer.addRule(i,function(t,e,n){return o(t,e,n,r),null}):this.generatedTokenizer.addRule(i,function(){return null})}else{if(!e.startsWith("token")&&!e.startsWith("define"))throw new Error("Invalid directive: "+e);var s=e.startsWith("define"),a=this.tokenizer.expectToken(t,Me.IDENT,Me.STRING),u=a.value;if(a.tag!=Me.STRING&&a.tag!=Me.NUMBER||(u='"'.concat(a.value,'"')),i=this.parseRegex(t,u,0,e.endsWith("flex")?"flex":""),s)this.generatedTokenizer.addVar(u,i.expr);else{var l=this.parseTokenHandler(t);this.generatedTokenizer.addRule(i,l),this.ensureSymbol(u,!0)}}},t.prototype.parseTokenHandler=function(t){var e=this;if(!this.tokenizer.consumeIf(t,Me.OPEN_BRACE))return null;var r=this.tokenizer.expectToken(t,Me.IDENT);return this.tokenizer.expectToken(t,Me.CLOSE_BRACE),function(t,n,i,o){var s=e.tokenHandlers[r.value];if(!s)throw new Error("Handler method not found: "+r.value);return s(i,n,o)}},t.prototype.parseDecl=function(t){var e,r,n=this.tokenizer.expectToken(t,Me.IDENT);if(this.tokenizer.consumeIf(t,Me.ARROW,Me.COLON)){var i=this.ensureSymbol(n.value,!1);if(i.isTerminal)i.isTerminal=!1;else if(i.isAuxiliary)throw new Error("NT is already auxiliary and cannot be reused.");try{for(var o=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.parseProductions(t,this.grammar,i)),s=o.next();!s.done;s=o.next()){var a=Ke(s.value,2),u=a[0],l=a[1];this.grammar.add(i,u,l)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}this.tokenizer.expectToken(t,Me.SEMI_COLON)}},t.prototype.parseProductions=function(t,e,r){for(var n=[];null!=this.tokenizer.peek(t);){var i=this.parseProd(t,e);if(n.push(i),!this.tokenizer.consumeIf(t,Me.PIPE)&&this.tokenizer.nextMatches(t,Me.CLOSE_SQ,Me.CLOSE_PAREN,Me.SEMI_COLON))break}return n},t.prototype.parseProd=function(t,e){for(var r=new at;!this.tokenizer.nextMatches(t,Me.CLOSE_PAREN,Me.CLOSE_SQ,Me.SEMI_COLON,Me.PIPE,Me.OPEN_BRACE);){var n=null;if(this.tokenizer.consumeIf(t,Me.OPEN_PAREN))0==(i=this.parseProductions(t,e,null)).length||(n=1==i.length?i[0][0]:e.anyof.apply(e,Je([],Ke(i.map(function(t){return t[0]})),!1))),this.tokenizer.expectToken(t,Me.CLOSE_PAREN);else if(this.tokenizer.consumeIf(t,Me.OPEN_SQ)){var i;0==(i=this.parseProductions(t,e,null)).length||(n=1==i.length?e.opt(i[0][0]):e.opt(e.anyof.apply(e,Je([],Ke(i.map(function(t){return t[0]})),!1)))),this.tokenizer.expectToken(t,Me.CLOSE_SQ)}else{if(!this.tokenizer.nextMatches(t,Me.IDENT,Me.STRING,Me.NUMBER,Me.REGEX))throw new le(this.tokenizer.peek(t));var o=this.tokenizer.next(t),s=o.value;if(o.tag==Me.STRING||o.tag==Me.NUMBER){s='"'.concat(o.value,'"');var a=Ne(Qe(o.value),{tag:s,priority:20});this.generatedTokenizer.addRule(a)}else if(o.tag==Me.REGEX){s="/"+o.value[0]+"/"+o.value[1];var u=o.value[0];o.value[1].length>0&&(u=new RegExp(o.value[0],o.value[1])),a=Ne(u,{tag:s,priority:10}),this.generatedTokenizer.addRule(a)}var l=this.ensureSymbol(s,!0);n=new at(l)}if(null==n)throw new Error("Could not determine node");this.tokenizer.consumeIf(t,Me.STAR)?n=e.atleast0(n,this.leftRecursive):this.tokenizer.consumeIf(t,Me.PLUS)?n=e.atleast1(n,this.leftRecursive):this.tokenizer.consumeIf(t,Me.QMARK)&&(n=e.opt(n)),r.extend(n)}var c=null;if(this.tokenizer.consumeIf(t,Me.OPEN_BRACE)){var h=this.tokenizer.expectToken(t,Me.DOLLAR_NUM,Me.IDENT);c=new ut(h.value),this.tokenizer.expectToken(t,Me.CLOSE_BRACE)}return[r,c]},t}(),Xe=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ze=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},tr=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},er=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.parent=null,e}return Xe(e,t),e.prototype.add=function(e,r){return void 0===r&&(r=-1),t.prototype.add.call(this,e,r),e.parent=this,this},e.prototype.splice=function(e,r){for(var n,i,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];try{for(var a=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(o),u=a.next();!u.done;u=a.next())u.value.parent=this}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return t.prototype.splice.apply(this,tr([e,r],Ze(o),!1))},e}(function(){function t(t,e,r){for(var n=[],i=3;i<arguments.length;i++)n[i-3]=arguments[i];this.id=t,this.sym=e,this.value=r,this.children=[],this.children=n||[]}return Object.defineProperty(t.prototype,"childCount",{get:function(){return this.children.length},enumerable:!1,configurable:!0}),t.prototype.childAt=function(t){return t<0?this.children[this.children.length+t]:this.children[t]},Object.defineProperty(t.prototype,"isTerminal",{get:function(){return this.sym.isTerminal},enumerable:!1,configurable:!0}),t.prototype.add=function(t,e){if(void 0===e&&(e=-1),this.isTerminal)throw new Error("Cannot add children (".concat(t.sym.label,") to a terminal node: ").concat(this.sym.label));return e<0?this.children.push(t):this.children.splice(e,0,t),this},t.prototype.splice=function(t,e){for(var r,n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return(r=this.children).splice.apply(r,tr([t,e],Ze(n),!1)),this},Object.defineProperty(t.prototype,"reprString",{get:function(){return this.debugValue(!1).join("\n")},enumerable:!1,configurable:!0}),t.prototype.debugValue=function(t){if(void 0===t&&(t=!0),t){var e=[this.sym.label];return this.value&&e.push(this.value),this.children.length>0&&e.push(this.children.map(function(e){return e.debugValue(t)})),e}var r=[];return this.value,r.push(null==this.value?this.sym.label:this.sym.label+" - "+this.value),this.children.forEach(function(e){return e.debugValue(t).forEach(function(t){return r.push(" "+t)})}),r},t}()),rr=function(){function t(){}return t.prototype.setTokenizer=function(t){return this.tokenbuffer=new be(t,null),this},t.prototype.getSym=function(t){var e=this.grammar.getSym(t.tag);if(null==e)throw new Error("Invalid token tag: "+t.tag+", Value: "+t.value);return e},t}(),nr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Xe(e,t),e.prototype.parse=function(t,e){return void 0===e&&(e=null),"string"==typeof t&&(t=new pe(t)),this.parseInput(t,e)},e}(rr);function ir(t,e,r){return void 0===r&&(r=!0),e.debugString}!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Xe(e,t),e.prototype.parse=function(t,e){return void 0===e&&(e=null),"string"==typeof t&&(t=new pe(t)),this.parseInput(t,e)}}(rr);var or,sr,ar=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ur=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},lr=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},cr=(function(){function t(t){this.grammar=t,this.refresh()}t.prototype.refresh=function(){var t=this;return this.entries=new Map,this.grammar.followSets.refresh(),this.grammar.forEachRule(null,function(e,r){t.processRule(e,r)}),function(t,e){void 0===e&&(e=!0);var r="";t.forEachNT(function(n){e&&n.isAuxiliary||(r+=n.label+" -> ",r+=function(t,e,r){void 0===r&&(r=!0);for(var n="",i=" ",o=0;o<e.length;o++)o>0&&(r||(n+="\n",n+=i),n+=" | "),n+=ir(0,e[o].rhs,r);return r||(n+="\n",n+=i),n+" ;"}(0,t.rulesForNT(n),e)+"\n\n")})}(this.grammar,!1),this.grammar.cycles,this.grammar.leftRecursion,this},Object.defineProperty(t.prototype,"count",{get:function(){var t,e,r,n,i=0;try{for(var o=ur(this.entries.values()),s=o.next();!s.done;s=o.next()){var a=s.value;try{for(var u=(r=void 0,ur(a.values())),l=u.next();!l.done;l=u.next())i+=l.value.length}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return i},enumerable:!1,configurable:!0}),t.prototype.ensureEntry=function(t,e){i(!t.isTerminal&&e.isTerminal);var r=this.entries.get(t.id);r||(r=new Map,this.entries.set(t.id,r));var n=r.get(e.id);return n||(n=[],r.set(e.id,n)),n},t.prototype.add=function(t,e,r){var n=this.ensureEntry(t,e);return n.findIndex(function(t){return t.equals(r)})<0&&n.push(r),1==n.length},t.prototype.get=function(t,e){return this.ensureEntry(t,e)},t.prototype.forEachEntry=function(t){var e,r,n,o;try{for(var s=ur(this.entries.keys()),a=s.next();!a.done;a=s.next()){var u=a.value,l=this.entries.get(u)||null;i(null!=l);var c=this.grammar.getSymById(u);i(null!=c);try{for(var h=(n=void 0,ur(l.keys())),f=h.next();!f.done;f=h.next()){var p=f.value,d=this.grammar.getSymById(p);if(i(null!=d),0==t(c,d,l.get(p)||[]))return}}catch(t){n={error:t}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t={};return this.forEachEntry(function(e,r,n){var i,o;t[e.label]=t[e.label]||{},t[e.label][r.label]=t[e.label][r.label]||[];var s=t[e.label][r.label];try{for(var a=ur(n),u=a.next();!u.done;u=a.next()){var l=u.value;s.push(l.debugString)}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}}),t},enumerable:!1,configurable:!0}),t.prototype.processRule=function(t,e){var r=this,n=this.grammar.firstSets,o=!1;n.forEachTermIn(t.rhs,0,function(e){null==e?o=!0:r.add(t.nt,e,t)}),o&&this.grammar.followSets.forEachTerm(t.nt,function(e){i(null!=e,"Follow sets cannot have null"),r.add(t.nt,e,t)})}}(),function(){function t(t){this.idCounter=0,this.parseTable=t,this.stack=[];var e=t.grammar;i(null!=e.startSymbol,"Start symbol not selected"),this.docNode=this.push(e.Eof,new er(this.idCounter++,new st(e,"<DOC>",!1),null)),this.rootNode=this.push(e.startSymbol),this.docNode.add(this.rootNode)}return Object.defineProperty(t.prototype,"debugString",{get:function(){return"Stack: ["+this.stack.map(function(t){return t[0].label}).join(", ")+"]"},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){return void 0===e&&(e=null),e||(e=new er(this.idCounter++,t,null)),this.stack.push([t,e]),e},t.prototype.top=function(){return this.stack[this.stack.length-1]},t.prototype.pop=function(){return 0==this.stack.length&&i(!1,"Stacks are empty"),this.stack.pop()},Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0==this.stack.length},enumerable:!1,configurable:!0}),t}()),hr=(function(t){function e(e){var r=t.call(this)||this;return r.parseTable=e,i(null!=e.grammar.startSymbol,"Start symbol not selected"),r}ar(e,t),Object.defineProperty(e.prototype,"grammar",{get:function(){return this.parseTable.grammar},enumerable:!1,configurable:!0}),e.prototype.parseInput=function(t,e){var r,n;void 0===e&&(e=null),this.stack=new cr(this.parseTable);var o,s,a,u=this.tokenbuffer,l=this.stack,c=this.grammar;do{o=u.peek(t),s=(r=lr(l.top(),2))[0],a=r[1];var h=null==o?c.Eof:this.getSym(o),f=null==o?null:o.value;if(s.isTerminal)s==h?this.consumeTokenAndPop(t,h,o):this.processInvalidToken(h,o);else{var p=this.parseTable.get(s,h);if(1!=p.length)console.log("TopItem: ",s),console.log("nextSym: ",h),this.processInvalidReductions(a,s,h,f,p);else{var d=lr(this.stack.pop(),2),g=d[0],y=d[1];i(y==a),i(g==p[0].nt),i(y.sym==g),this.popSymAndPushRule(y,p[0])}}s=(n=lr(l.top(),2))[0],a=n[1]}while(s!=c.Eof);return l.rootNode},e.prototype.popSymAndPushRule=function(t,e){for(var r=e.rhs.syms.length-1;r>=0;r--){var n=e.rhs.syms[r],i=this.stack.push(n);t.add(i,0)}},e.prototype.consumeTokenAndPop=function(t,e,r){var n=lr(this.stack.top(),2),o=n[0],s=n[1];i(o==e),i(s.sym==e),s.value=r.value,this.tokenbuffer.next(t),this.stack.pop()},e.prototype.processInvalidToken=function(t,e){throw new Error("Invalid token: "+t.label)},e.prototype.processInvalidReductions=function(t,e,r,n,i){throw new Error("Invalid # reductions ".concat(i.length," found ").concat(e.label," -> ").concat(r.label))}}(nr),function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}()),fr=function(t){function e(e,r,n){void 0===n&&(n=null);var i=this.constructor,o=t.call(this,e)||this;return o.type=r,o.value=n,Object.setPrototypeOf(o,i.prototype),o}return hr(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this.constructor.name},enumerable:!1,configurable:!0}),e}(Error),pr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),dr=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},gr=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},yr=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};(sr=or||(or={}))[sr.ACCEPT=0]="ACCEPT",sr[sr.SHIFT=1]="SHIFT",sr[sr.REDUCE=2]="REDUCE",sr[sr.GOTO=3]="GOTO";var mr=function(){function t(){this.gotoState=null,this.rule=null}return t.prototype.toString=function(){return this.tag==or.ACCEPT?"Acc":this.tag==or.SHIFT?"S"+this.gotoState:this.tag==or.REDUCE?"R "+this.rule.id:""+this.gotoState},t.prototype.equals=function(t){return this.tag==t.tag&&this.gotoState==t.gotoState&&this.rule==t.rule},t.Shift=function(e){var r=new t;return r.tag=or.SHIFT,r.gotoState=e,r},t.Reduce=function(e){var r=new t;return r.tag=or.REDUCE,r.rule=e,r},t.Goto=function(e){var r=new t;return r.tag=or.GOTO,r.gotoState=e,r},t.Accept=function(){var e=new t;return e.tag=or.ACCEPT,e},t}(),vr=function(){function t(t){this.grammar=t,this.conflictActions={},this.actions={}}return Object.defineProperty(t.prototype,"hasConflicts",{get:function(){return Object.keys(this.conflictActions).length>0},enumerable:!1,configurable:!0}),t.prototype.getActions=function(t,e,r){var n;if(void 0===r&&(r=!1),t in this.actions)n=this.actions[t];else{if(!r)return[];n=this.actions[t]={}}return e.id in n?n[e.id]:r?n[e.id]=[]:[]},t.prototype.addAction=function(t,e,r){var n=this.getActions(t,e,!0);return n.findIndex(function(t){return t.equals(r)})<0&&n.push(r),n.length>1&&(this.conflictActions[t]=this.conflictActions[t]||{},this.conflictActions[t][e.label]=!0),this},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t={};for(var e in this.actions)for(var r in t[e]={},this.actions[e]){var n=this.grammar.getSymById(r),i=this.actions[e][n.id]||[];i.length>0&&(t[e][n.label]=i.map(function(t){return t.toString()}))}return t},enumerable:!1,configurable:!0}),t}(),br=function(){function t(){this.stateStack=[],this.nodeStack=[]}return t.prototype.push=function(t,e){this.stateStack.push(t),this.nodeStack.push(e)},t.prototype.top=function(t){return void 0===t&&(t=0),[this.stateStack[this.stateStack.length-1-t],this.nodeStack[this.nodeStack.length-1-t]]},t.prototype.pop=function(){var t=this.top();return this.stateStack.pop(),this.nodeStack.pop(),t},t.prototype.popN=function(t){void 0===t&&(t=1);var e=this.stateStack.length;this.stateStack.splice(e-t,t),this.nodeStack.splice(e-t,t)},Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0==this.stateStack.length||0==this.nodeStack.length},enumerable:!1,configurable:!0}),t}(),wr=function(t){function e(e,r){void 0===r&&(r={});var n=t.call(this)||this;return n.parseTable=e,n}return pr(e,t),Object.defineProperty(e.prototype,"grammar",{get:function(){return this.parseTable.grammar},enumerable:!1,configurable:!0}),e.prototype.parseInput=function(t,e){var r,n,o;e=e||{},this.tokenbuffer.tokenizerContext=e.tokenizerContext,0!=e.buildParseTree&&(e.buildParseTree=!0),0!=e.copySingleChild&&(e.copySingleChild=!0);var s=0,a=new br;a.push(0,new er(s++,this.grammar.augStartRule.nt,null));var u=this.tokenbuffer,l=this.grammar,c=null;function h(t){if(null==e?void 0:e.actionResolver)return e.actionResolver(t,a,u);if(t.length>1)throw new Error("Multiple actions found.");return t[0]}function f(){try{return u.peek(t)}catch(r){if(!(null==e?void 0:e.onTokenError)||!(null==e?void 0:e.onTokenError(r,t)))throw r;return f()}}for(;;){var p=f();if(null==p){if(a.isEmpty)break}else e.onNextToken&&(p=e.onNextToken(p));var d=null==p?l.Eof:this.getSym(p),g=null==p?null:p.value,y=dr(a.top(),2),m=y[0],v=(y[1],this.parseTable.getActions(m,d));if(null==v||0==v.length)throw new fr("Unexpected Token: '".concat(d.label,"'"),"UnexpectedToken",{state:m,token:p,nextSym:d});var b=h(v);if(b.tag==or.ACCEPT)break;if(b.tag==or.SHIFT){u.next(t);var w=new er(s++,d,g);a.push(b.gotoState,w)}else{i(null!=b.rule,"Nonterm and ruleindex must be provided for a reduction action");var S=b.rule.rhs.length;if(w=new er(s++,b.rule.nt,null),e.buildParseTree)for(var E=S-1;E>=0;E--){var C=a.top(E)[1];if(e.beforeAddingChildNode)try{for(var _=(r=void 0,gr(e.beforeAddingChildNode(w,C))),x=_.next();!x.done;x=_.next()){var O=x.value;w.add(O)}}catch(t){r={error:t}}finally{try{x&&!x.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}else null!=C&&w.add(C)}if(b.rule.action)if(b.rule.action.isFunction){var A=b.rule.action.value,T=e.ruleHandlers[A];if(!T)throw new Error("Action handler not found: "+A);w.value=T.apply(void 0,yr([b.rule,w],dr(w.children),!1))}else w.value=w.children[b.rule.action.value-1].value;else e.onReduction?w=e.onReduction(w,b.rule):1==w.children.length&&e.copySingleChild&&(w.value=w.children[0].value);a.popN(S),m=(o=dr(a.top(),2))[0],o[1];var N=h(this.parseTable.getActions(m,b.rule.nt));i(null!=N&&null!=N.gotoState,"Top item does not have an action."),a.push(N.gotoState,w),c=w}}return c},e}(nr),Sr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Er=function(){return Er=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Er.apply(this,arguments)},Cr=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},_r=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},xr=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Or=function(){function t(t,e){void 0===e&&(e=0),this.id=0,this.rule=t,this.position=e}return t.prototype.advance=function(){return i(this.position<this.rule.rhs.length),new t(this.rule,this.position+1)},t.prototype.copy=function(){return new t(this.rule,this.position)},Object.defineProperty(t.prototype,"key",{get:function(){return i(!isNaN(this.rule.id),"Rule's ID is not yet set."),this.rule.id+":"+this.position},enumerable:!1,configurable:!0}),t.prototype.compareTo=function(t){var e=this.rule.id-t.rule.id;return 0==e&&(e=this.position-t.position),e},t.prototype.equals=function(t){return 0==this.compareTo(t)},Object.defineProperty(t.prototype,"debugString",{get:function(){var t=this.rule,e=this.position,r=t.rhs.syms.slice(0,e).join(" "),n=t.rhs.syms.slice(e).join(" ");return"".concat(t.id," - ").concat(t.nt," -> ").concat(r," • ").concat(n)},enumerable:!1,configurable:!0}),t}(),Ar=function(){function t(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.id=0,this._key=null,this._lookaheads={},this._hasLookAheads=!1,this.itemGraph=t,this.values=e}return t.prototype.copy=function(){var e=new(t.bind.apply(t,_r([void 0,this.itemGraph],Cr(this.values),!1)));return e._lookaheads=Er({},this._lookaheads),e._hasLookAheads=this._hasLookAheads,e},t.prototype.addLookAhead=function(t,e){var r,n;t.id in this._lookaheads||(this._lookaheads[t.id]=[]);try{for(var i=xr(this._lookaheads[t.id]),o=i.next();!o.done;o=i.next())if(o.value==e)return!1}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return this._hasLookAheads=!0,this._key=null,this._lookaheads[t.id].push(e),this._lookaheads[t.id].sort(function(t,e){return t.id-e.id}),!0},t.prototype.clearLookAheads=function(){this._lookaheads={}},t.prototype.getLookAheads=function(t){return this._lookaheads[t.id]||[]},Object.defineProperty(t.prototype,"key",{get:function(){return null==this._key&&(this._key=this.revalKey()),this._key},enumerable:!1,configurable:!0}),t.prototype.revalKey=function(){var t=this;return this.hasLookAheads?(this.values.sort(),this.values.map(function(e){return e+"["+(t._lookaheads[e]||[]).map(function(t){return t.id}).join(",")+"]"}).join("/")):(this.values.sort(),this.values.join("/"))},t.prototype.has=function(t){return this.values.indexOf(t)>=0},t.prototype.equals=function(t){return this.key==t.key},t.prototype.add=function(t){return this.has(t)||(this.values.push(t),this._key=null),this},Object.defineProperty(t.prototype,"size",{get:function(){return this.values.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugString",{get:function(){return this.debugValue.join("\n")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasLookAheads",{get:function(){return this._hasLookAheads},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugValue",{get:function(){var t,e=this;return this.hasLookAheads?((t=this.values.map(function(t){return e.itemGraph.items.get(t)})).sort(function(t,e){return t.compareTo(e)}),t.map(function(t){var r=e.getLookAheads(t).map(function(t){return t.label}).sort(function(t,e){return t.localeCompare(e)}).join(", ");return r.length>0?"".concat(t.debugString," / ( ").concat(r," )"):t.debugString})):((t=this.values.map(function(t){return e.itemGraph.items.get(t)})).sort(function(t,e){return t.compareTo(e)}),t.map(function(t){return t.debugString}))},enumerable:!1,configurable:!0}),t}(),Tr=function(){function t(t){this.grammar=t,this.gotoSets={},this.items=new Y,this.itemSets=new Y}return t.prototype.startItem=function(){return i(null!=this.grammar.startSymbol,"Start symbol must be set"),i(null!=(this.grammar.augStartRule||null),"Grammar is not augmented"),this.items.ensure(new Or(this.grammar.augStartRule))},t.prototype.reset=function(){this.grammar.refresh(),this.gotoSets={},this.items.clear(),this.itemSets.clear(),this.startSet()},t.prototype.refresh=function(){return this.reset(),this.grammar.refresh(),this.evalGotoSets(),this},t.prototype.evalGotoSets=function(){for(var t,e,r=this.itemSets,n=0;n<r.size;n++){var i=r.get(n);try{for(var o=(t=void 0,xr(this.grammar.allSymbols)),s=o.next();!s.done;s=o.next()){var a=s.value;if(a!=this.grammar.Null){var u=this.goto(i,a);u.size>0&&this.setGoto(i,a,u)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}}},t.prototype.goto=function(t,e){var r,n,i=this.newItemSet();try{for(var o=xr(t.values),s=o.next();!s.done;s=o.next()){var a=s.value,u=this.items.get(a),l=u.rule;u.position<l.rhs.length&&l.rhs.syms[u.position]==e&&this.advanceItemAndAdd(u,t,i)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return this.closure(i)},t.prototype.advanceItemAndAdd=function(t,e,r){var n,i,o=this.items.ensure(t.advance());r.add(o.id);try{for(var s=xr(e.getLookAheads(t)),a=s.next();!a.done;a=s.next()){var u=a.value;r.addLookAhead(o,u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}},t.prototype.newItemSet=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(Ar.bind.apply(Ar,_r([void 0,this],Cr(t.map(function(t){return t.id})),!1)))},Object.defineProperty(t.prototype,"size",{get:function(){return this.itemSets.size},enumerable:!1,configurable:!0}),t.prototype.ensureGotoSet=function(t){return t.id in this.gotoSets||(this.gotoSets[t.id]={}),this.gotoSets[t.id]},t.prototype.setGoto=function(t,e,r){this.ensureGotoSet(t)[e.id]=r},t.prototype.getGoto=function(t,e){return(this.gotoSets[t.id]||{})[e.id]||null},t.prototype.forEachGoto=function(t,e){var r=this.gotoSets[t.id]||{};for(var n in r)if(0==e(this.grammar.getSymById(n),r[n]))break},t.prototype.gotoSetFor=function(t){return this.gotoSets[t.id]||{}},Object.defineProperty(t.prototype,"debugValue",{get:function(){var t=this,e={};return this.itemSets.entries.forEach(function(r){e[r.id]={items:[],goto:{}},e[r.id].items=r.debugValue;var n=t.gotoSets[r.id];for(var i in n){var o=t.grammar.getSymById(i);e[r.id].goto=e[r.id].goto||{},e[r.id].goto[o.label]=n[i].id}}),e},enumerable:!1,configurable:!0}),t}(),Nr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Sr(e,t),e.prototype.startSet=function(){var t=this.startItem(),e=this.newItemSet(t);return this.closure(e)},e.prototype.closure=function(t){for(var e,r,n=new(Ar.bind.apply(Ar,_r([void 0,this],Cr(t.values),!1))),i=0;i<n.values.length;i++){var o=n.values[i],s=this.items.get(o),a=s.rule;if(s.position<a.rhs.length){var u=a.rhs.syms[s.position];if(!u.isTerminal)try{for(var l=(e=void 0,xr(this.grammar.rulesForNT(u))),c=l.next();!c.done;c=l.next()){var h=c.value,f=this.items.ensure(new Or(h,0));n.add(f.id)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}}}return 0==n.size?n:this.itemSets.ensure(n)},e}(Tr),Rr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Sr(e,t),e.prototype.startSet=function(){var t=this.startItem(),e=this.newItemSet(t);return e.addLookAhead(t,this.grammar.Eof),this.closure(e)},e.prototype.closure=function(t){for(var e=this,r=t.copy(),n=function(t){var n,o,s=r.values[t],a=i.items.get(s);if(a.position>=a.rule.rhs.length)return"continue";var u=a.rule.rhs,l=u.syms[a.position];if(l.isTerminal)return"continue";try{for(var c=(n=void 0,xr(r.getLookAheads(a))),h=c.next();!h.done;h=c.next()){var f=h.value,p=u.copy().append(f);i.grammar.firstSets.forEachTermIn(p,a.position+1,function(t){var n,i;if(null!=t){var o=e.grammar.rulesForNT(l);try{for(var s=(n=void 0,xr(o)),a=s.next();!a.done;a=s.next()){var u=a.value,c=e.items.ensure(new Or(u,0));r.add(c.id),r.addLookAhead(c,t)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}})}}catch(t){n={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}},i=this,o=0;o<r.values.length;o++)n(o);return 0==r.size?r:this.itemSets.ensure(r)},e}(Tr),Ir=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},kr=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};function Lr(t,e){switch(void 0===e&&(e="lr1"),e){case"lr1":return[jr(n=new Rr(r=t).refresh(),r),n];case"lalr":return function(t){var e=kr(Pr(t),2),r=e[0],n=e[1];if(!r.hasConflicts)return[r,n];var o=function(t,e){var r=new ct;function n(t,n){var i="[".concat(t,":").concat(n.label,"]"),o=r.ensureSym(new st(r,i,n.isTerminal),!1);return 0!=t||e.startSymbol!=n||e.startSymbol==o||n.isTerminal||(r.startSymbol=o),o}for(var o in t.gotoSets){var s=t.gotoSets[o];for(var a in s){var u=e.getSymById(a);n(o,u)}}function l(e,r,o){var s=e,a=o.rhs.syms.map(function(e,r){var o=n(s,e),a=t.gotoSets[s][e.id]||null;return i(null!=a,"Next set transition *must* be valid"),s=a.id,o});return new(at.bind.apply(at,function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([void 0],kr(a),!1)))}for(var o in t.gotoSets){s=t.gotoSets[o];var c=function(t){var i=e.getSymById(t),s=o;if(!i.isTerminal){var a=n(s,i);e.forEachRule(i,function(t,e){var n=l(s,0,t),i=new lt(a,n);r.addRule(i)})}};for(var a in s)c(a)}return r}(n,t),s={};for(var a in n.gotoSets)for(var u in n.gotoSets[a]){var l=n.gotoSets[a][u];l.id in s||(s[l.id]={}),u in s[l.id]||(s[l.id][u]=new Set),s[l.id][u].add(a)}for(var a in r.conflictActions){var c=n.itemSets.get(a);Mr(t,o,n,c,s)}return[jr(n,t),n]}(t)}var r,n;return Pr(t)}function Pr(t){var e=function(t){var e,r,n=new Nr(t).refresh();try{for(var i=Ir(n.itemSets.entries),o=i.next();!o.done;o=i.next())Br(t,n,o.value)}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}(t);return[jr(e,t),e]}function Br(t,e,r){var n,o,s=function(n){var o=e.items.get(n),s=o.rule;o.position>=s.rhs.length&&t.followSets.forEachTerm(s.nt,function(t){null!=t&&(i(t.isTerminal),r.addLookAhead(o,t))})};try{for(var a=Ir(r.values),u=a.next();!u.done;u=a.next())s(u.value)}catch(t){n={error:t}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}}function jr(t,e){var r,n,i=new vr(e),o=function(r){var n,o,s,a;try{for(var u=(n=void 0,Ir(r.values)),l=u.next();!l.done;l=u.next()){var c=l.value,h=t.items.get(c),f=h.rule;if(h.position<f.rhs.length){var p=f.rhs.syms[h.position];if(p.isTerminal){var d=t.getGoto(r,p);d&&i.addAction(r.id,p,mr.Shift(d.id))}}else if(!f.nt.equals(e.augStartRule.nt)){var g=r.getLookAheads(h);try{for(var y=(s=void 0,Ir(g)),m=y.next();!m.done;m=y.next()){var v=m.value;i.addAction(r.id,v,mr.Reduce(f))}}catch(t){s={error:t}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(s)throw s.error}}}}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}t.forEachGoto(r,function(t,e){null==t||t.isTerminal||i.addAction(r.id,t,mr.Goto(e.id))});var b=t.items.ensure(new Or(e.augStartRule,1));r.addLookAhead(b,e.Eof),r.has(b.id)&&i.addAction(r.id,e.Eof,mr.Accept())};try{for(var s=Ir(t.itemSets.entries),a=s.next();!a.done;a=s.next())o(a.value)}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}function Mr(t,e,r,n,o){var s,a;function u(t,e,n,s){if(e<0)i(null!=(r.gotoSets[n][t.nt.id]||null),"Transition on rule.nt missing from start state"),s.add(n);else{var a=t.rhs.syms[e],l=o[n][a.id]||null;i(null!=l,"Prev set should not be null"),l.forEach(function(r){return u(t,e-1,r,s)})}}n.clearLookAheads();var l=function(o){var s=r.items.get(o),a=s.rule;if(s.position>=a.rhs.length){var l=new Set;u(a,a.rhs.length-1,n.id,l),l.forEach(function(r){var o="[".concat(r,":").concat(a.nt.label,"]"),u=e.getSym(o);i(null!=u,"Augmented grammar symbol [p:A] not found"),e.followSets.forEachTerm(u,function(r){if(null!=r&&r!=e.Eof){i(r.isTerminal);var o=r.label.substring(r.label.indexOf(":")+1,r.label.length-1).trim(),a=t.getSym(o);i(null!=a,"T (".concat(o,") in [r:T] cannot be null")),n.addLookAhead(s,a)}})})}};try{for(var c=Ir(n.values),h=c.next();!h.done;h=c.next())l(h.value)}catch(t){s={error:t}}finally{try{h&&!h.done&&(a=c.return)&&a.call(c)}finally{if(s)throw s.error}}}var Dr=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};const Ur=Symbol.for("yaml.alias"),Fr=Symbol.for("yaml.document"),$r=Symbol.for("yaml.map"),Vr=Symbol.for("yaml.pair"),zr=Symbol.for("yaml.scalar"),Gr=Symbol.for("yaml.seq"),qr=Symbol.for("yaml.node.type"),Wr=t=>!!t&&"object"==typeof t&&t[qr]===Ur,Hr=t=>!!t&&"object"==typeof t&&t[qr]===Fr,Kr=t=>!!t&&"object"==typeof t&&t[qr]===$r,Jr=t=>!!t&&"object"==typeof t&&t[qr]===Vr,Qr=t=>!!t&&"object"==typeof t&&t[qr]===zr,Yr=t=>!!t&&"object"==typeof t&&t[qr]===Gr;function Xr(t){if(t&&"object"==typeof t)switch(t[qr]){case $r:case Gr:return!0}return!1}function Zr(t){if(t&&"object"==typeof t)switch(t[qr]){case Ur:case $r:case zr:case Gr:return!0}return!1}const tn=t=>(Qr(t)||Xr(t))&&!!t.anchor,en=Symbol("break visit"),rn=Symbol("skip children"),nn=Symbol("remove node");function on(t,e){const r=ln(e);Hr(t)?sn(null,t.contents,r,Object.freeze([t]))===nn&&(t.contents=null):sn(null,t,r,Object.freeze([]))}function sn(t,e,r,n){const i=cn(t,e,r,n);if(Zr(i)||Jr(i))return hn(t,n,i),sn(t,i,r,n);if("symbol"!=typeof i)if(Xr(e)){n=Object.freeze(n.concat(e));for(let t=0;t<e.items.length;++t){const i=sn(t,e.items[t],r,n);if("number"==typeof i)t=i-1;else{if(i===en)return en;i===nn&&(e.items.splice(t,1),t-=1)}}}else if(Jr(e)){n=Object.freeze(n.concat(e));const t=sn("key",e.key,r,n);if(t===en)return en;t===nn&&(e.key=null);const i=sn("value",e.value,r,n);if(i===en)return en;i===nn&&(e.value=null)}return i}async function an(t,e){const r=ln(e);Hr(t)?await un(null,t.contents,r,Object.freeze([t]))===nn&&(t.contents=null):await un(null,t,r,Object.freeze([]))}async function un(t,e,r,n){const i=await cn(t,e,r,n);if(Zr(i)||Jr(i))return hn(t,n,i),un(t,i,r,n);if("symbol"!=typeof i)if(Xr(e)){n=Object.freeze(n.concat(e));for(let t=0;t<e.items.length;++t){const i=await un(t,e.items[t],r,n);if("number"==typeof i)t=i-1;else{if(i===en)return en;i===nn&&(e.items.splice(t,1),t-=1)}}}else if(Jr(e)){n=Object.freeze(n.concat(e));const t=await un("key",e.key,r,n);if(t===en)return en;t===nn&&(e.key=null);const i=await un("value",e.value,r,n);if(i===en)return en;i===nn&&(e.value=null)}return i}function ln(t){return"object"==typeof t&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function cn(t,e,r,n){return"function"==typeof r?r(t,e,n):Kr(e)?r.Map?.(t,e,n):Yr(e)?r.Seq?.(t,e,n):Jr(e)?r.Pair?.(t,e,n):Qr(e)?r.Scalar?.(t,e,n):Wr(e)?r.Alias?.(t,e,n):void 0}function hn(t,e,r){const n=e[e.length-1];if(Xr(n))n.items[t]=r;else if(Jr(n))"key"===t?n.key=r:n.value=r;else{if(!Hr(n)){const t=Wr(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${t} parent`)}n.contents=r}}on.BREAK=en,on.SKIP=rn,on.REMOVE=nn,an.BREAK=en,an.SKIP=rn,an.REMOVE=nn;const fn={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},pn=t=>t.replace(/[!,[\]{}]/g,t=>fn[t]);class dn{constructor(t,e){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},dn.defaultYaml,t),this.tags=Object.assign({},dn.defaultTags,e)}clone(){const t=new dn(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new dn(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:dn.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},dn.defaultTags)}return t}add(t,e){this.atNextDocument&&(this.yaml={explicit:dn.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},dn.defaultTags),this.atNextDocument=!1);const r=t.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(2!==r.length&&(e(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[t,n]=r;return this.tags[t]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==r.length)return e(0,"%YAML directive should contain exactly one part"),!1;const[t]=r;return"1.1"===t||"1.2"===t?(this.yaml.version=t,!0):(e(6,`Unsupported YAML version ${t}`,/^\d+\.\d+$/.test(t)),!1)}default:return e(0,`Unknown directive ${n}`,!0),!1}}tagName(t,e){if("!"===t)return"!";if("!"!==t[0])return e(`Not a valid tag: ${t}`),null;if("<"===t[1]){const r=t.slice(2,-1);return"!"===r||"!!"===r?(e(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(">"!==t[t.length-1]&&e("Verbatim tags must end with a >"),r)}const[,r,n]=t.match(/^(.*!)([^!]*)$/s);n||e(`The ${t} tag has no suffix`);const i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(t){return e(String(t)),null}return"!"===r?t:(e(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[e,r]of Object.entries(this.tags))if(t.startsWith(r))return e+pn(t.substring(r.length));return"!"===t[0]?t:`!<${t}>`}toString(t){const e=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let n;if(t&&r.length>0&&Zr(t.contents)){const e={};on(t.contents,(t,r)=>{Zr(r)&&r.tag&&(e[r.tag]=!0)}),n=Object.keys(e)}else n=[];for(const[i,o]of r)"!!"===i&&"tag:yaml.org,2002:"===o||t&&!n.some(t=>t.startsWith(o))||e.push(`%TAG ${i} ${o}`);return e.join("\n")}}function gn(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){const e=JSON.stringify(t);throw new Error(`Anchor must not contain whitespace or control characters: ${e}`)}return!0}function yn(t,e,r,n){if(n&&"object"==typeof n)if(Array.isArray(n))for(let e=0,r=n.length;e<r;++e){const r=n[e],i=yn(t,n,String(e),r);void 0===i?delete n[e]:i!==r&&(n[e]=i)}else if(n instanceof Map)for(const e of Array.from(n.keys())){const r=n.get(e),i=yn(t,n,e,r);void 0===i?n.delete(e):i!==r&&n.set(e,i)}else if(n instanceof Set)for(const e of Array.from(n)){const r=yn(t,n,e,e);void 0===r?n.delete(e):r!==e&&(n.delete(e),n.add(r))}else for(const[e,r]of Object.entries(n)){const i=yn(t,n,e,r);void 0===i?delete n[e]:i!==r&&(n[e]=i)}return t.call(e,r,n)}function mn(t,e,r){if(Array.isArray(t))return t.map((t,e)=>mn(t,String(e),r));if(t&&"function"==typeof t.toJSON){if(!r||!tn(t))return t.toJSON(e,r);const n={aliasCount:0,count:1,res:void 0};r.anchors.set(t,n),r.onCreate=t=>{n.res=t,delete r.onCreate};const i=t.toJSON(e,r);return r.onCreate&&r.onCreate(i),i}return"bigint"!=typeof t||r?.keep?t:Number(t)}dn.defaultYaml={explicit:!1,version:"1.2"},dn.defaultTags={"!!":"tag:yaml.org,2002:"};class vn{constructor(t){Object.defineProperty(this,qr,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:e,maxAliasCount:r,onAnchor:n,reviver:i}={}){if(!Hr(t))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:t,keep:!0,mapAsMap:!0===e,mapKeyWarned:!1,maxAliasCount:"number"==typeof r?r:100},s=mn(this,"",o);if("function"==typeof n)for(const{count:t,res:e}of o.anchors.values())n(e,t);return"function"==typeof i?yn(i,{"":s},"",s):s}}class bn extends vn{constructor(t){super(Ur),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,e){let r,n;e?.aliasResolveCache?r=e.aliasResolveCache:(r=[],on(t,{Node:(t,e)=>{(Wr(e)||tn(e))&&r.push(e)}}),e&&(e.aliasResolveCache=r));for(const t of r){if(t===this)break;t.anchor===this.source&&(n=t)}return n}toJSON(t,e){if(!e)return{source:this.source};const{anchors:r,doc:n,maxAliasCount:i}=e,o=this.resolve(n,e);if(!o){const t=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(t)}let s=r.get(o);if(s||(mn(o,null,e),s=r.get(o)),void 0===s?.res)throw new ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0&&(s.count+=1,0===s.aliasCount&&(s.aliasCount=wn(n,o,r)),s.count*s.aliasCount>i))throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack");return s.res}toString(t,e,r){const n=`*${this.source}`;if(t){if(gn(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const t=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(t)}if(t.implicitKey)return`${n} `}return n}}function wn(t,e,r){if(Wr(e)){const n=e.resolve(t),i=r&&n&&r.get(n);return i?i.count*i.aliasCount:0}if(Xr(e)){let n=0;for(const i of e.items){const e=wn(t,i,r);e>n&&(n=e)}return n}if(Jr(e)){const n=wn(t,e.key,r),i=wn(t,e.value,r);return Math.max(n,i)}return 1}const Sn=t=>!t||"function"!=typeof t&&"object"!=typeof t;class En extends vn{constructor(t){super(zr),this.value=t}toJSON(t,e){return e?.keep?this.value:mn(this.value,t,e)}toString(){return String(this.value)}}function Cn(t,e,r){if(Hr(t)&&(t=t.contents),Zr(t))return t;if(Jr(t)){const e=r.schema[$r].createNode?.(r.schema,null,r);return e.items.push(t),e}(t instanceof String||t instanceof Number||t instanceof Boolean||"undefined"!=typeof BigInt&&t instanceof BigInt)&&(t=t.valueOf());const{aliasDuplicateObjects:n,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=r;let u;if(n&&t&&"object"==typeof t){if(u=a.get(t),u)return u.anchor??(u.anchor=i(t)),new bn(u.anchor);u={anchor:null,node:null},a.set(t,u)}e?.startsWith("!!")&&(e="tag:yaml.org,2002:"+e.slice(2));let l=function(t,e,r){if(e){const t=r.filter(t=>t.tag===e),n=t.find(t=>!t.format)??t[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return r.find(e=>e.identify?.(t)&&!e.format)}(t,e,s.tags);if(!l){if(t&&"function"==typeof t.toJSON&&(t=t.toJSON()),!t||"object"!=typeof t){const e=new En(t);return u&&(u.node=e),e}l=t instanceof Map?s[$r]:Symbol.iterator in Object(t)?s[Gr]:s[$r]}o&&(o(l),delete r.onTagObj);const c=l?.createNode?l.createNode(r.schema,t,r):"function"==typeof l?.nodeClass?.from?l.nodeClass.from(r.schema,t,r):new En(t);return e?c.tag=e:l.default||(c.tag=l.tag),u&&(u.node=c),c}function _n(t,e,r){let n=r;for(let t=e.length-1;t>=0;--t){const r=e[t];if("number"==typeof r&&Number.isInteger(r)&&r>=0){const t=[];t[r]=n,n=t}else n=new Map([[r,n]])}return Cn(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}En.BLOCK_FOLDED="BLOCK_FOLDED",En.BLOCK_LITERAL="BLOCK_LITERAL",En.PLAIN="PLAIN",En.QUOTE_DOUBLE="QUOTE_DOUBLE",En.QUOTE_SINGLE="QUOTE_SINGLE";class xn extends vn{constructor(t,e){super(t),Object.defineProperty(this,"schema",{value:e,configurable:!0,enumerable:!1,writable:!0})}clone(t){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(e.schema=t),e.items=e.items.map(e=>Zr(e)||Jr(e)?e.clone(t):e),this.range&&(e.range=this.range.slice()),e}addIn(t,e){if((t=>null==t||"object"==typeof t&&!!t[Symbol.iterator]().next().done)(t))this.add(e);else{const[r,...n]=t,i=this.get(r,!0);if(Xr(i))i.addIn(n,e);else{if(void 0!==i||!this.schema)throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`);this.set(r,_n(this.schema,n,e))}}}deleteIn(t){const[e,...r]=t;if(0===r.length)return this.delete(e);const n=this.get(e,!0);if(Xr(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${e}. Remaining path: ${r}`)}getIn(t,e){const[r,...n]=t,i=this.get(r,!0);return 0===n.length?!e&&Qr(i)?i.value:i:Xr(i)?i.getIn(n,e):void 0}hasAllNullValues(t){return this.items.every(e=>{if(!Jr(e))return!1;const r=e.value;return null==r||t&&Qr(r)&&null==r.value&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){const[e,...r]=t;if(0===r.length)return this.has(e);const n=this.get(e,!0);return!!Xr(n)&&n.hasIn(r)}setIn(t,e){const[r,...n]=t;if(0===n.length)this.set(r,e);else{const t=this.get(r,!0);if(Xr(t))t.setIn(n,e);else{if(void 0!==t||!this.schema)throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`);this.set(r,_n(this.schema,n,e))}}}}const On=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function An(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}const Tn=(t,e,r)=>t.endsWith("\n")?An(r,e):r.includes("\n")?"\n"+An(r,e):(t.endsWith(" ")?"":" ")+r,Nn="flow",Rn="block",In="quoted";function kn(t,e,r="flow",{indentAtStart:n,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return t;i<o&&(o=0);const u=Math.max(1+o,1+i-e.length);if(t.length<=u)return t;const l=[],c={};let h,f,p=i-e.length;"number"==typeof n&&(n>i-Math.max(2,o)?l.push(0):p=i-n);let d=!1,g=-1,y=-1,m=-1;r===Rn&&(g=Ln(t,g,e.length),-1!==g&&(p=g+u));for(let n;n=t[g+=1];){if(r===In&&"\\"===n){switch(y=g,t[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}m=g}if("\n"===n)r===Rn&&(g=Ln(t,g,e.length)),p=g+e.length+u,h=void 0;else{if(" "===n&&f&&" "!==f&&"\n"!==f&&"\t"!==f){const e=t[g+1];e&&" "!==e&&"\n"!==e&&"\t"!==e&&(h=g)}if(g>=p)if(h)l.push(h),p=h+u,h=void 0;else if(r===In){for(;" "===f||"\t"===f;)f=n,n=t[g+=1],d=!0;const e=g>m+1?g-2:y-1;if(c[e])return t;l.push(e),c[e]=!0,p=e+u,h=void 0}else d=!0}f=n}if(d&&a&&a(),0===l.length)return t;s&&s();let v=t.slice(0,l[0]);for(let n=0;n<l.length;++n){const i=l[n],o=l[n+1]||t.length;0===i?v=`\n${e}${t.slice(0,o)}`:(r===In&&c[i]&&(v+=`${t[i]}\\`),v+=`\n${e}${t.slice(i+1,o)}`)}return v}function Ln(t,e,r){let n=e,i=e+1,o=t[i];for(;" "===o||"\t"===o;)if(e<i+r)o=t[++e];else{do{o=t[++e]}while(o&&"\n"!==o);n=e,i=e+1,o=t[i]}return n}const Pn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Bn=t=>/^(%|---|\.\.\.)/m.test(t);function jn(t,e){const r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;const{implicitKey:n}=e,i=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Bn(t)?" ":"");let s="",a=0;for(let t=0,e=r[t];e;e=r[++t])if(" "===e&&"\\"===r[t+1]&&"n"===r[t+2]&&(s+=r.slice(a,t)+"\\ ",t+=1,a=t,e="\\"),"\\"===e)switch(r[t+1]){case"u":{s+=r.slice(a,t);const e=r.substr(t+2,4);switch(e){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:"00"===e.substr(0,2)?s+="\\x"+e.substr(2):s+=r.substr(t,6)}t+=5,a=t+1}break;case"n":if(n||'"'===r[t+2]||r.length<i)t+=1;else{for(s+=r.slice(a,t)+"\n\n";"\\"===r[t+2]&&"n"===r[t+3]&&'"'!==r[t+4];)s+="\n",t+=2;s+=o," "===r[t+2]&&(s+="\\"),t+=1,a=t+1}break;default:t+=1}return s=a?s+r.slice(a):r,n?s:kn(s,o,In,Pn(e,!1))}function Mn(t,e){if(!1===e.options.singleQuote||e.implicitKey&&t.includes("\n")||/[ \t]\n|\n[ \t]/.test(t))return jn(t,e);const r=e.indent||(Bn(t)?" ":""),n="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&\n${r}`)+"'";return e.implicitKey?n:kn(n,r,Nn,Pn(e,!1))}function Dn(t,e){const{singleQuote:r}=e.options;let n;if(!1===r)n=jn;else{const e=t.includes('"'),i=t.includes("'");n=e&&!i?Mn:i&&!e?jn:r?Mn:jn}return n(t,e)}let Un;try{Un=new RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{Un=/\n+(?!\n|$)/g}function Fn({comment:t,type:e,value:r},n,i,o){const{blockQuote:s,commentString:a,lineWidth:u}=n.options;if(!s||/\n[\t ]+$/.test(r))return Dn(r,n);const l=n.indent||(n.forceBlockIndent||Bn(r)?" ":""),c="literal"===s||"folded"!==s&&e!==En.BLOCK_FOLDED&&(e===En.BLOCK_LITERAL||!function(t,e,r){if(!e||e<0)return!1;const n=e-r,i=t.length;if(i<=n)return!1;for(let e=0,r=0;e<i;++e)if("\n"===t[e]){if(e-r>n)return!0;if(r=e+1,i-r<=n)return!1}return!0}(r,u,l.length));if(!r)return c?"|\n":">\n";let h,f;for(f=r.length;f>0;--f){const t=r[f-1];if("\n"!==t&&"\t"!==t&&" "!==t)break}let p=r.substring(f);const d=p.indexOf("\n");-1===d?h="-":r===p||d!==p.length-1?(h="+",o&&o()):h="",p&&(r=r.slice(0,-p.length),"\n"===p[p.length-1]&&(p=p.slice(0,-1)),p=p.replace(Un,`$&${l}`));let g,y=!1,m=-1;for(g=0;g<r.length;++g){const t=r[g];if(" "===t)y=!0;else{if("\n"!==t)break;m=g}}let v=r.substring(0,m<g?m+1:g);v&&(r=r.substring(v.length),v=v.replace(/\n+/g,`$&${l}`));let b=(y?l?"2":"1":"")+h;if(t&&(b+=" "+a(t.replace(/ ?[\r\n]+/g," ")),i&&i()),!c){const t=r.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`);let i=!1;const o=Pn(n,!0);"folded"!==s&&e!==En.BLOCK_FOLDED&&(o.onOverflow=()=>{i=!0});const a=kn(`${v}${t}${p}`,l,Rn,o);if(!i)return`>${b}\n${l}${a}`}return`|${b}\n${l}${v}${r=r.replace(/\n+/g,`$&${l}`)}${p}`}function $n(t,e,r,n){const{implicitKey:i,inFlow:o}=e,s="string"==typeof t.value?t:Object.assign({},t,{value:String(t.value)});let{type:a}=t;a!==En.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=En.QUOTE_DOUBLE);const u=t=>{switch(t){case En.BLOCK_FOLDED:case En.BLOCK_LITERAL:return i||o?Dn(s.value,e):Fn(s,e,r,n);case En.QUOTE_DOUBLE:return jn(s.value,e);case En.QUOTE_SINGLE:return Mn(s.value,e);case En.PLAIN:return function(t,e,r,n){const{type:i,value:o}=t,{actualString:s,implicitKey:a,indent:u,indentStep:l,inFlow:c}=e;if(a&&o.includes("\n")||c&&/[[\]{},]/.test(o))return Dn(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||c||!o.includes("\n")?Dn(o,e):Fn(t,e,r,n);if(!a&&!c&&i!==En.PLAIN&&o.includes("\n"))return Fn(t,e,r,n);if(Bn(o)){if(""===u)return e.forceBlockIndent=!0,Fn(t,e,r,n);if(a&&u===l)return Dn(o,e)}const h=o.replace(/\n+/g,`$&\n${u}`);if(s){const t=t=>t.default&&"tag:yaml.org,2002:str"!==t.tag&&t.test?.test(h),{compat:r,tags:n}=e.doc.schema;if(n.some(t)||r?.some(t))return Dn(o,e)}return a?h:kn(h,u,Nn,Pn(e,!1))}(s,e,r,n);default:return null}};let l=u(a);if(null===l){const{defaultKeyType:t,defaultStringType:r}=e.options,n=i&&t||r;if(l=u(n),null===l)throw new Error(`Unsupported default string type ${n}`)}return l}function Vn(t,e,r,n){if(Jr(t))return t.toString(e,r,n);if(Wr(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let i;const o=Zr(t)?t:e.doc.createNode(t,{onTagObj:t=>i=t});i??(i=function(t,e){if(e.tag){const r=t.filter(t=>t.tag===e.tag);if(r.length>0)return r.find(t=>t.format===e.format)??r[0]}let r,n;if(Qr(e)){n=e.value;let i=t.filter(t=>t.identify?.(n));if(i.length>1){const t=i.filter(t=>t.test);t.length>0&&(i=t)}r=i.find(t=>t.format===e.format)??i.find(t=>!t.format)}else n=e,r=t.find(t=>t.nodeClass&&n instanceof t.nodeClass);if(!r)throw new Error(`Tag not resolved for ${n?.constructor?.name??(null===n?"null":typeof n)} value`);return r}(e.doc.schema.tags,o));const s=function(t,e,{anchors:r,doc:n}){if(!n.directives)return"";const i=[],o=(Qr(t)||Xr(t))&&t.anchor;o&&gn(o)&&(r.add(o),i.push(`&${o}`));const s=t.tag??(e.default?null:e.tag);return s&&i.push(n.directives.tagString(s)),i.join(" ")}(o,i,e);s.length>0&&(e.indentAtStart=(e.indentAtStart??0)+s.length+1);const a="function"==typeof i.stringify?i.stringify(o,e,r,n):Qr(o)?$n(o,e,r,n):o.toString(e,r,n);return s?Qr(o)||"{"===a[0]||"["===a[0]?`${s} ${a}`:`${s}\n${e.indent}${a}`:a}const zn="<<",Gn={identify:t=>t===zn||"symbol"==typeof t&&t.description===zn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new En(Symbol(zn)),{addToJSMap:qn}),stringify:()=>zn};function qn(t,e,r){if(r=t&&Wr(r)?r.resolve(t.doc):r,Yr(r))for(const n of r.items)Wn(t,e,n);else if(Array.isArray(r))for(const n of r)Wn(t,e,n);else Wn(t,e,r)}function Wn(t,e,r){const n=t&&Wr(r)?r.resolve(t.doc):r;if(!Kr(n))throw new Error("Merge sources must be maps or map aliases");const i=n.toJSON(null,t,Map);for(const[t,r]of i)e instanceof Map?e.has(t)||e.set(t,r):e instanceof Set?e.add(t):Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0});return e}function Hn(t,e,{key:r,value:n}){if(Zr(r)&&r.addToJSMap)r.addToJSMap(t,e,n);else if(((t,e)=>(Gn.identify(e)||Qr(e)&&(!e.type||e.type===En.PLAIN)&&Gn.identify(e.value))&&t?.doc.schema.tags.some(t=>t.tag===Gn.tag&&t.default))(t,r))qn(t,e,n);else{const i=mn(r,"",t);if(e instanceof Map)e.set(i,mn(n,i,t));else if(e instanceof Set)e.add(i);else{const o=function(t,e,r){if(null===e)return"";if("object"!=typeof e)return String(e);if(Zr(t)&&r?.doc){const e=function(t){const e=Object.assign({blockQuote:!0,commentString:On,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,{});let r;switch(e.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:e.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof e.indent?" ".repeat(e.indent):" ",inFlow:r,options:e}}(r.doc);e.anchors=new Set;for(const t of r.anchors.keys())e.anchors.add(t.anchor);e.inFlow=!0,e.inStringifyKey=!0;const o=t.toString(e);if(!r.mapKeyWarned){let t=JSON.stringify(o);t.length>40&&(t=t.substring(0,36)+'..."'),i=`Keys with collection values will be stringified due to JS Object restrictions: ${t}. Set mapAsMap: true to use object keys.`,"debug"!==(n=r.doc.options.logLevel)&&"warn"!==n||console.warn(i),r.mapKeyWarned=!0}return o}var n,i;return JSON.stringify(e)}(r,i,t),s=mn(n,o,t);o in e?Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):e[o]=s}}return e}function Kn(t,e,r){const n=Cn(t,void 0,r),i=Cn(e,void 0,r);return new Jn(n,i)}class Jn{constructor(t,e=null){Object.defineProperty(this,qr,{value:Vr}),this.key=t,this.value=e}clone(t){let{key:e,value:r}=this;return Zr(e)&&(e=e.clone(t)),Zr(r)&&(r=r.clone(t)),new Jn(e,r)}toJSON(t,e){return Hn(e,e?.mapAsMap?new Map:{},this)}toString(t,e,r){return t?.doc?function({key:t,value:e},r,n,i){const{allNullValues:o,doc:s,indent:a,indentStep:u,options:{commentString:l,indentSeq:c,simpleKeys:h}}=r;let f=Zr(t)&&t.comment||null;if(h){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Xr(t)||!Zr(t)&&"object"==typeof t)throw new Error("With simple keys, collection cannot be used as a key value")}let p=!h&&(!t||f&&null==e&&!r.inFlow||Xr(t)||(Qr(t)?t.type===En.BLOCK_FOLDED||t.type===En.BLOCK_LITERAL:"object"==typeof t));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(h||!o),indent:a+u});let d,g,y,m=!1,v=!1,b=Vn(t,r,()=>m=!0,()=>v=!0);if(!p&&!r.inFlow&&b.length>1024){if(h)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(o||null==e)return m&&n&&n(),""===b?"?":p?`? ${b}`:b}else if(o&&!h||null==e&&p)return b=`? ${b}`,f&&!m?b+=Tn(b,r.indent,l(f)):v&&i&&i(),b;m&&(f=null),p?(f&&(b+=Tn(b,r.indent,l(f))),b=`? ${b}\n${a}:`):(b=`${b}:`,f&&(b+=Tn(b,r.indent,l(f)))),Zr(e)?(d=!!e.spaceBefore,g=e.commentBefore,y=e.comment):(d=!1,g=null,y=null,e&&"object"==typeof e&&(e=s.createNode(e))),r.implicitKey=!1,p||f||!Qr(e)||(r.indentAtStart=b.length+1),v=!1,c||!(u.length>=2)||r.inFlow||p||!Yr(e)||e.flow||e.tag||e.anchor||(r.indent=r.indent.substring(2));let w=!1;const S=Vn(e,r,()=>w=!0,()=>v=!0);let E=" ";if(f||d||g)E=d?"\n":"",g&&(E+=`\n${An(l(g),r.indent)}`),""!==S||r.inFlow?E+=`\n${r.indent}`:"\n"===E&&y&&(E="\n\n");else if(!p&&Xr(e)){const t=S[0],n=S.indexOf("\n"),i=-1!==n,o=r.inFlow??e.flow??0===e.items.length;if(i||!o){let e=!1;if(i&&("&"===t||"!"===t)){let r=S.indexOf(" ");"&"===t&&-1!==r&&r<n&&"!"===S[r+1]&&(r=S.indexOf(" ",r+1)),(-1===r||n<r)&&(e=!0)}e||(E=`\n${r.indent}`)}}else""!==S&&"\n"!==S[0]||(E="");return b+=E+S,r.inFlow?w&&n&&n():y&&!w?b+=Tn(b,r.indent,l(y)):v&&i&&i(),b}(this,t,e,r):JSON.stringify(this)}}function Qn(t,e,r){return(e.inFlow??t.flow?Xn:Yn)(t,e,r)}function Yn({comment:t,items:e},r,{blockItemPrefix:n,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){const{indent:u,options:{commentString:l}}=r,c=Object.assign({},r,{indent:o,type:null});let h=!1;const f=[];for(let t=0;t<e.length;++t){const i=e[t];let s=null;if(Zr(i))!h&&i.spaceBefore&&f.push(""),Zn(r,f,i.commentBefore,h),i.comment&&(s=i.comment);else if(Jr(i)){const t=Zr(i.key)?i.key:null;t&&(!h&&t.spaceBefore&&f.push(""),Zn(r,f,t.commentBefore,h))}h=!1;let a=Vn(i,c,()=>s=null,()=>h=!0);s&&(a+=Tn(a,o,l(s))),h&&s&&(h=!1),f.push(n+a)}let p;if(0===f.length)p=i.start+i.end;else{p=f[0];for(let t=1;t<f.length;++t){const e=f[t];p+=e?`\n${u}${e}`:"\n"}}return t?(p+="\n"+An(l(t),u),a&&a()):h&&s&&s(),p}function Xn({items:t},e,{flowChars:r,itemIndent:n}){const{indent:i,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=e;n+=o;const u=Object.assign({},e,{indent:n,inFlow:!0,type:null});let l=!1,c=0;const h=[];for(let r=0;r<t.length;++r){const i=t[r];let o=null;if(Zr(i))i.spaceBefore&&h.push(""),Zn(e,h,i.commentBefore,!1),i.comment&&(o=i.comment);else if(Jr(i)){const t=Zr(i.key)?i.key:null;t&&(t.spaceBefore&&h.push(""),Zn(e,h,t.commentBefore,!1),t.comment&&(l=!0));const r=Zr(i.value)?i.value:null;r?(r.comment&&(o=r.comment),r.commentBefore&&(l=!0)):null==i.value&&t?.comment&&(o=t.comment)}o&&(l=!0);let s=Vn(i,u,()=>o=null);r<t.length-1&&(s+=","),o&&(s+=Tn(s,n,a(o))),!l&&(h.length>c||s.includes("\n"))&&(l=!0),h.push(s),c=h.length}const{start:f,end:p}=r;if(0===h.length)return f+p;if(!l){const t=h.reduce((t,e)=>t+e.length+2,2);l=e.options.lineWidth>0&&t>e.options.lineWidth}if(l){let t=f;for(const e of h)t+=e?`\n${o}${i}${e}`:"\n";return`${t}\n${i}${p}`}return`${f}${s}${h.join(" ")}${s}${p}`}function Zn({indent:t,options:{commentString:e}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){const i=An(e(n),t);r.push(i.trimStart())}}function ti(t,e){const r=Qr(e)?e.value:e;for(const n of t)if(Jr(n)){if(n.key===e||n.key===r)return n;if(Qr(n.key)&&n.key.value===r)return n}}class ei extends xn{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super($r,t),this.items=[]}static from(t,e,r){const{keepUndefined:n,replacer:i}=r,o=new this(t),s=(t,s)=>{if("function"==typeof i)s=i.call(e,t,s);else if(Array.isArray(i)&&!i.includes(t))return;(void 0!==s||n)&&o.items.push(Kn(t,s,r))};if(e instanceof Map)for(const[t,r]of e)s(t,r);else if(e&&"object"==typeof e)for(const t of Object.keys(e))s(t,e[t]);return"function"==typeof t.sortMapEntries&&o.items.sort(t.sortMapEntries),o}add(t,e){let r;r=Jr(t)?t:t&&"object"==typeof t&&"key"in t?new Jn(t.key,t.value):new Jn(t,t?.value);const n=ti(this.items,r.key),i=this.schema?.sortMapEntries;if(n){if(!e)throw new Error(`Key ${r.key} already set`);Qr(n.value)&&Sn(r.value)?n.value.value=r.value:n.value=r.value}else if(i){const t=this.items.findIndex(t=>i(r,t)<0);-1===t?this.items.push(r):this.items.splice(t,0,r)}else this.items.push(r)}delete(t){const e=ti(this.items,t);return!!e&&this.items.splice(this.items.indexOf(e),1).length>0}get(t,e){const r=ti(this.items,t),n=r?.value;return(!e&&Qr(n)?n.value:n)??void 0}has(t){return!!ti(this.items,t)}set(t,e){this.add(new Jn(t,e),!0)}toJSON(t,e,r){const n=r?new r:e?.mapAsMap?new Map:{};e?.onCreate&&e.onCreate(n);for(const t of this.items)Hn(e,n,t);return n}toString(t,e,r){if(!t)return JSON.stringify(this);for(const t of this.items)if(!Jr(t))throw new Error(`Map items must all be pairs; found ${JSON.stringify(t)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Qn(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:e})}}const ri={collection:"map",default:!0,nodeClass:ei,tag:"tag:yaml.org,2002:map",resolve:(t,e)=>(Kr(t)||e("Expected a mapping for this tag"),t),createNode:(t,e,r)=>ei.from(t,e,r)};class ni extends xn{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Gr,t),this.items=[]}add(t){this.items.push(t)}delete(t){const e=ii(t);return"number"==typeof e&&this.items.splice(e,1).length>0}get(t,e){const r=ii(t);if("number"!=typeof r)return;const n=this.items[r];return!e&&Qr(n)?n.value:n}has(t){const e=ii(t);return"number"==typeof e&&e<this.items.length}set(t,e){const r=ii(t);if("number"!=typeof r)throw new Error(`Expected a valid index, not ${t}.`);const n=this.items[r];Qr(n)&&Sn(e)?n.value=e:this.items[r]=e}toJSON(t,e){const r=[];e?.onCreate&&e.onCreate(r);let n=0;for(const t of this.items)r.push(mn(t,String(n++),e));return r}toString(t,e,r){return t?Qn(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:e}):JSON.stringify(this)}static from(t,e,r){const{replacer:n}=r,i=new this(t);if(e&&Symbol.iterator in Object(e)){let t=0;for(let o of e){if("function"==typeof n){const r=e instanceof Set?o:String(t++);o=n.call(e,r,o)}i.items.push(Cn(o,void 0,r))}}return i}}function ii(t){let e=Qr(t)?t.value:t;return e&&"string"==typeof e&&(e=Number(e)),"number"==typeof e&&Number.isInteger(e)&&e>=0?e:null}const oi={collection:"seq",default:!0,nodeClass:ni,tag:"tag:yaml.org,2002:seq",resolve:(t,e)=>(Yr(t)||e("Expected a sequence for this tag"),t),createNode:(t,e,r)=>ni.from(t,e,r)},si={identify:t=>"string"==typeof t,default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:(t,e,r,n)=>$n(t,e=Object.assign({actualString:!0},e),r,n)},ai={identify:t=>null==t,createNode:()=>new En(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new En(null),stringify:({source:t},e)=>"string"==typeof t&&ai.test.test(t)?t:e.options.nullStr},ui={identify:t=>"boolean"==typeof t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new En("t"===t[0]||"T"===t[0]),stringify:({source:t,value:e},r)=>t&&ui.test.test(t)&&e===("t"===t[0]||"T"===t[0])?t:e?r.options.trueStr:r.options.falseStr};function li({format:t,minFractionDigits:e,tag:r,value:n}){if("bigint"==typeof n)return String(n);const i="number"==typeof n?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!t&&e&&(!r||"tag:yaml.org,2002:float"===r)&&/^\d/.test(o)){let t=o.indexOf(".");t<0&&(t=o.length,o+=".");let r=e-(o.length-t-1);for(;r-- >0;)o+="0"}return o}const ci={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>"nan"===t.slice(-3).toLowerCase()?NaN:"-"===t[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:li},hi={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){const e=Number(t.value);return isFinite(e)?e.toExponential():li(t)}},fi=t=>"bigint"==typeof t||Number.isInteger(t),pi=(t,e,r,{intAsBigInt:n})=>n?BigInt(t):parseInt(t.substring(e),r);function di(t,e,r){const{value:n}=t;return fi(n)&&n>=0?r+n.toString(e):li(t)}const gi=[ri,oi,si,ai,ui,{identify:t=>fi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>pi(t,2,8,r),stringify:t=>di(t,8,"0o")},{identify:fi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>pi(t,0,10,r),stringify:li},{identify:t=>fi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>pi(t,2,16,r),stringify:t=>di(t,16,"0x")},ci,hi,{identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){const e=new En(parseFloat(t)),r=t.indexOf(".");return-1!==r&&"0"===t[t.length-1]&&(e.minFractionDigits=t.length-r-1),e},stringify:li}];function yi(t){return"bigint"==typeof t||Number.isInteger(t)}const mi=({value:t})=>JSON.stringify(t),vi=[ri,oi].concat([{identify:t=>"string"==typeof t,default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:mi},{identify:t=>null==t,createNode:()=>new En(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:mi},{identify:t=>"boolean"==typeof t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>"true"===t,stringify:mi},{identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>yi(t)?t.toString():JSON.stringify(t)},{identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:mi}],{default:!0,tag:"",test:/^/,resolve:(t,e)=>(e(`Unresolved plain scalar ${JSON.stringify(t)}`),t)}),bi={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if("function"==typeof atob){const e=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(e.length);for(let t=0;t<e.length;++t)r[t]=e.charCodeAt(t);return r}return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},n,i,o){if(!r)return"";const s=r;let a;if("function"!=typeof btoa)throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");{let t="";for(let e=0;e<s.length;++e)t+=String.fromCharCode(s[e]);a=btoa(t)}if(e??(e=En.BLOCK_LITERAL),e!==En.QUOTE_DOUBLE){const t=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),r=Math.ceil(a.length/t),i=new Array(r);for(let e=0,n=0;e<r;++e,n+=t)i[e]=a.substr(n,t);a=i.join(e===En.BLOCK_LITERAL?"\n":" ")}return $n({comment:t,type:e,value:a},n,i,o)}};function wi(t,e){if(Yr(t))for(let r=0;r<t.items.length;++r){let n=t.items[r];if(!Jr(n)){if(Kr(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");const t=n.items[0]||new Jn(new En(null));if(n.commentBefore&&(t.key.commentBefore=t.key.commentBefore?`${n.commentBefore}\n${t.key.commentBefore}`:n.commentBefore),n.comment){const e=t.value??t.key;e.comment=e.comment?`${n.comment}\n${e.comment}`:n.comment}n=t}t.items[r]=Jr(n)?n:new Jn(n)}}else e("Expected a sequence for this tag");return t}function Si(t,e,r){const{replacer:n}=r,i=new ni(t);i.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let t of e){let s,a;if("function"==typeof n&&(t=n.call(e,String(o++),t)),Array.isArray(t)){if(2!==t.length)throw new TypeError(`Expected [key, value] tuple: ${t}`);s=t[0],a=t[1]}else if(t&&t instanceof Object){const e=Object.keys(t);if(1!==e.length)throw new TypeError(`Expected tuple with one key, not ${e.length} keys`);s=e[0],a=t[s]}else s=t;i.items.push(Kn(s,a,r))}return i}const Ei={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:wi,createNode:Si};class Ci extends ni{constructor(){super(),this.add=ei.prototype.add.bind(this),this.delete=ei.prototype.delete.bind(this),this.get=ei.prototype.get.bind(this),this.has=ei.prototype.has.bind(this),this.set=ei.prototype.set.bind(this),this.tag=Ci.tag}toJSON(t,e){if(!e)return super.toJSON(t);const r=new Map;e?.onCreate&&e.onCreate(r);for(const t of this.items){let n,i;if(Jr(t)?(n=mn(t.key,"",e),i=mn(t.value,n,e)):n=mn(t,"",e),r.has(n))throw new Error("Ordered maps must not include duplicate keys");r.set(n,i)}return r}static from(t,e,r){const n=Si(t,e,r),i=new this;return i.items=n.items,i}}Ci.tag="tag:yaml.org,2002:omap";const _i={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ci,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){const r=wi(t,e),n=[];for(const{key:t}of r.items)Qr(t)&&(n.includes(t.value)?e(`Ordered maps must not include duplicate keys: ${t.value}`):n.push(t.value));return Object.assign(new Ci,r)},createNode:(t,e,r)=>Ci.from(t,e,r)};function xi({value:t,source:e},r){return e&&(t?Oi:Ai).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}const Oi={identify:t=>!0===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new En(!0),stringify:xi},Ai={identify:t=>!1===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new En(!1),stringify:xi},Ti={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>"nan"===t.slice(-3).toLowerCase()?NaN:"-"===t[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:li},Ni={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){const e=Number(t.value);return isFinite(e)?e.toExponential():li(t)}},Ri={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){const e=new En(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(-1!==r){const n=t.substring(r+1).replace(/_/g,"");"0"===n[n.length-1]&&(e.minFractionDigits=n.length)}return e},stringify:li},Ii=t=>"bigint"==typeof t||Number.isInteger(t);function ki(t,e,r,{intAsBigInt:n}){const i=t[0];if("-"!==i&&"+"!==i||(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`}const e=BigInt(t);return"-"===i?BigInt(-1)*e:e}const o=parseInt(t,r);return"-"===i?-1*o:o}function Li(t,e,r){const{value:n}=t;if(Ii(n)){const t=n.toString(e);return n<0?"-"+r+t.substr(1):r+t}return li(t)}const Pi={identify:Ii,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>ki(t,2,2,r),stringify:t=>Li(t,2,"0b")},Bi={identify:Ii,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>ki(t,1,8,r),stringify:t=>Li(t,8,"0")},ji={identify:Ii,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>ki(t,0,10,r),stringify:li},Mi={identify:Ii,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>ki(t,2,16,r),stringify:t=>Li(t,16,"0x")};class Di extends ei{constructor(t){super(t),this.tag=Di.tag}add(t){let e;e=Jr(t)?t:t&&"object"==typeof t&&"key"in t&&"value"in t&&null===t.value?new Jn(t.key,null):new Jn(t,null),ti(this.items,e.key)||this.items.push(e)}get(t,e){const r=ti(this.items,t);return!e&&Jr(r)?Qr(r.key)?r.key.value:r.key:r}set(t,e){if("boolean"!=typeof e)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof e);const r=ti(this.items,t);r&&!e?this.items.splice(this.items.indexOf(r),1):!r&&e&&this.items.push(new Jn(t))}toJSON(t,e){return super.toJSON(t,e,Set)}toString(t,e,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),e,r);throw new Error("Set items must all have null values")}static from(t,e,r){const{replacer:n}=r,i=new this(t);if(e&&Symbol.iterator in Object(e))for(let t of e)"function"==typeof n&&(t=n.call(e,t,t)),i.items.push(Kn(t,null,r));return i}}Di.tag="tag:yaml.org,2002:set";const Ui={collection:"map",identify:t=>t instanceof Set,nodeClass:Di,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Di.from(t,e,r),resolve(t,e){if(Kr(t)){if(t.hasAllNullValues(!0))return Object.assign(new Di,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function Fi(t,e){const r=t[0],n="-"===r||"+"===r?t.substring(1):t,i=t=>e?BigInt(t):Number(t),o=n.replace(/_/g,"").split(":").reduce((t,e)=>t*i(60)+i(e),i(0));return"-"===r?i(-1)*o:o}function $i(t){let{value:e}=t,r=t=>t;if("bigint"==typeof e)r=t=>BigInt(t);else if(isNaN(e)||!isFinite(e))return li(t);let n="";e<0&&(n="-",e*=r(-1));const i=r(60),o=[e%i];return e<60?o.unshift(0):(e=(e-o[0])/i,o.unshift(e%i),e>=60&&(e=(e-o[0])/i,o.unshift(e))),n+o.map(t=>String(t).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Vi={identify:t=>"bigint"==typeof t||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>Fi(t,r),stringify:$i},zi={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Fi(t,!1),stringify:$i},Gi={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){const e=t.match(Gi.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,r,n,i,o,s,a]=e.map(Number),u=e[7]?Number((e[7]+"00").substr(1,3)):0;let l=Date.UTC(r,n-1,i,o||0,s||0,a||0,u);const c=e[8];if(c&&"Z"!==c){let t=Fi(c,!1);Math.abs(t)<30&&(t*=60),l-=6e4*t}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},qi=[ri,oi,si,ai,Oi,Ai,Pi,Bi,ji,Mi,Ti,Ni,Ri,bi,Gn,_i,Ei,Ui,Vi,zi,Gi];new Map([["core",gi],["failsafe",[ri,oi,si]],["json",vi],["yaml11",qi],["yaml-1.1",qi]]),Error;const Wi=Symbol("break visit"),Hi=Symbol("skip children"),Ki=Symbol("remove item");function Ji(t,e){"type"in t&&"document"===t.type&&(t={start:t.start,value:t.value}),Qi(Object.freeze([]),t,e)}function Qi(t,e,r){let n=r(e,t);if("symbol"==typeof n)return n;for(const i of["key","value"]){const o=e[i];if(o&&"items"in o){for(let e=0;e<o.items.length;++e){const n=Qi(Object.freeze(t.concat([[i,e]])),o.items[e],r);if("number"==typeof n)e=n-1;else{if(n===Wi)return Wi;n===Ki&&(o.items.splice(e,1),e-=1)}}"function"==typeof n&&"key"===i&&(n=n(e,t))}}return"function"==typeof n?n(e,t):n}var Yi;Ji.BREAK=Wi,Ji.SKIP=Hi,Ji.REMOVE=Ki,Ji.itemAtPath=(t,e)=>{let r=t;for(const[t,n]of e){const e=r?.[t];if(!e||!("items"in e))return;r=e.items[n]}return r},Ji.parentCollection=(t,e)=>{const r=Ji.itemAtPath(t,e.slice(0,-1)),n=e[e.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw new Error("Parent collection not found")},new Set("0123456789ABCDEFabcdef"),new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),new Set(",[]{}"),new Set(" ,[]{}\n\r\t"),p.ONE,function(t){t.Kampitham="Kampitham",t.Nokku="Nokku",t.Spuritham="Spuritham",t.Prathyagatham="Prathyagatham",t.Aahaatam_Raavi="Raavi",t.Aahaatam_Kandippu="Kandippu",t.Vaali="Vaali",t.Odukkal="Odukkal",t.Jaaru_Eetra="EetraJaaru",t.Jaaru_Irakka="IrakkaJaaru",t.Orikkai="Orikkai"}(Yi||(Yi={}));class Xi{constructor(){this.shapeId=Xi.idCounter++,this._x=null,this._y=null,this._width=null,this._height=null,this.parentShape=null,this.children=[]}get bbox(){return this._bbox||(this._bbox=this.refreshBBox()),this._bbox}get minSize(){return this._minSize||(this._minSize=this.refreshMinSize()),this._minSize}invalidateBounds(){this._minSize=null,this._bbox=null}setBounds(t,e,r,n,i=!1){null!=t&&(isNaN(t)?this._x=null:this._x=t),null!=e&&(isNaN(e)?this._y=null:this._y=e),null!=r&&(isNaN(r)?this._width=null:this._width=r),null!=n&&(isNaN(n)?this._height=null:this._height=n);const[o,s,a,u]=this.updateBounds(t,e,r,n);return null!=o&&(isNaN(o)?this._x=null:this._x=o),null!=s&&(isNaN(s)?this._y=null:this._y=s),null!=a&&(isNaN(a)?this._width=null:this._width=a),null!=u&&(isNaN(u)?this._height=null:this._height=u),i&&this.refreshLayout(),[o,s,a,u]}get hasX(){return null!=this._x&&!isNaN(this._x)}get hasY(){return null!=this._y&&!isNaN(this._y)}get hasWidth(){return null!=this._width&&!isNaN(this._width)}get hasHeight(){return null!=this._height&&!isNaN(this._height)}get x(){return this._x||0}set x(t){this.setBounds(null==t?NaN:t,null,null,null)}get y(){return null!=this._y?this._y:0}set y(t){this.setBounds(null,null==t?NaN:t,null,null)}get width(){return null!=this._width?this._width:0}set width(t){this.setBounds(null,null,null==t?NaN:t,null)}get height(){return null!=this._height?this._height:0}set height(t){this.setBounds(null,null,null,null==t?NaN:t)}refreshLayout(){}}Xi.idCounter=0;const Zi=p.ONE,[to]=(Zi.timesNum(2),function(t,e){void 0===e&&(e=null);var r=Dr(function(t,e){void 0===e&&(e=null);var r=Dr(function(t,e){var r=new ct((e=e||{}).grammar||{}),n=new Ye(t,He(He({},e),{grammar:r})),i=n.generatedTokenizer.next.bind(n.generatedTokenizer);return(e.debug||"").split("|").findIndex(function(t){return"all"==t||"lexer"==t})>=0&&console.log("Prog: \n","".concat(n.generatedTokenizer.vm.prog.debugValue().join("\n"))),[r,i]}(t,e=e||{}),2),n=r[0],i=r[1];n.augmentStartSymbol();var o=Dr(Lr(n,e.type),2);return[o[0],i,o[1]]}(t,e),3),n=r[0],i=r[1],o=r[2],s=new wr(n);return(e.tokenizer||i)&&s.setTokenizer(e.tokenizer||i),(e.debug||"").split("|").findIndex(function(t){return"all"==t||"parser"==t})>=0&&function(t,e){var r=t.grammar,n=t.parseTable;console.log("===============================\nGrammar (as default): \n",r.debugValue.map(function(t,e){return"".concat(e+1," - ").concat(t)}),"===============================\nGrammar (as Bison): \n",r.debugValue.map(function(t,e){return"".concat(t.replace("->",":")," ; \n")}).join(""),"===============================\nParseTable: \n",JSON.stringify(function(t,e){var r={},n=t.debugValue,i=null==e?void 0:e.debugValue;for(var o in n){var s=n[o];if(e){var a=i[o];r[o]={items:a.items,actions:s,goto:a.goto}}else r[o]=s}return r}(n,e),null,4),"===============================\nConflicts: \n",n.conflictActions)}(s,o),[s,i,o]}(String.raw`
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Notations=e():t.Notations=e()}(this,()=>(()=>{"use strict";var t,e,s,n={d:(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};n.d(r,{aq:()=>_,YJ:()=>k});class i{constructor(t=null){if(this.TYPE="Entity",this.uuid=i.counter++,this._parent=null,this._eventsEnabled=!1,(t=t||{}).metadata)throw new Error("See where metadata is being passed")}enableEvents(){return this._eventsEnabled=!0,this}disableEvents(){return this._eventsEnabled=!1,this}get eventsEnabled(){return this._eventsEnabled}get parent(){return this._parent}setParent(t){this._parent=t}debugValue(){return{type:this.TYPE}}toString(){return`Entity(id = ${this.uuid})`}equals(t,e=!1){return this.TYPE==t.TYPE}clone(){const t=this.newInstance();return this.copyTo(t),t}copyTo(t){}newInstance(){return new this.constructor}}i.counter=0;class o extends i{constructor(){super(...arguments),this.TYPE="TimedEntity"}equals(t){return super.equals(t)&&this.duration.equals(t.duration)}}function a(t,e){if(!t)throw new Error(e)}!function(t){t.ADD="add",t.INSERT="insert",t.REMOVE="remove",t.UPDATE="update"}(t||(t={})),function(t){t.ADD="add",t.REMOVE="remove"}(e||(e={})),function(t){t.ADD="add",t.REMOVE="remove"}(s||(s={}));const l=Math.pow(2,32);Math.pow(2,64);class h{constructor(t,e,s){this.uuid=h.counter++,this._spawnedFrom=null,this.sourceState=null,this.cancelled=!1,this.timeStamp=-1,this.children=[],this.name=t,this.source=e,this.payload=s}get spawnedFrom(){return this._spawnedFrom}setSpawnedFrom(t){this._spawnedFrom=t,this._rootEvent=null==t?this:t.rootEvent}spawn(t,e,s){const n=new h(t,e,s);return n.setSpawnedFrom(this),this.children.push(n),n}get rootEvent(){return this._rootEvent}}h.counter=0;class u{constructor(){this.stateData=null,this.id=u.counter++}get name(){return this.constructor.name}enter(t){this.stateData=t}handle(t){}}u.counter=0;class c{constructor(){this._eventHub=new d}get eventHub(){return this._eventHub}set eventHub(t){const e=this._eventHub;this._eventHub=t,this.eventHubChanged(e)}eventHubChanged(t){console.log("WARNING - EventHub Change Listener not implemented: ",this.constructor.name)}}class d{constructor(){this._handlers={},this._events=[],this._inBatchMode=!1}on(t,e){return this._addHandler(t,this._handlers,e)}removeOn(t,e){return this._removeHandler(t,this._handlers,e)}_ensurestrings(t){return"string"==typeof t&&(t=t.split(",")),t.map(function(t){return t.trim()})}_addHandler(t,e,s){return this._ensurestrings(t).forEach(function(t){e[t]=e[t]||[],e[t].push(s)}),this}_removeHandler(t,e,s){return this._ensurestrings(t).forEach(function(t){const n=e[t]||[];for(let t=0;t<n.length;t++)if(n[t]==s){n.splice(t,1);break}}),this}emit(t,e,s){const n=new h(t,e,s);return this._inBatchMode?(this._events.push(n),!0):this.dispatchEvent(n)}dispatchEvent(t){const e=this._handlers[t.name]||[];for(const s of e)if(s(t),t.cancelled)return!1;return!0}startBatchMode(){return this._inBatchMode||(this._inBatchMode=!0),this}cancelBatch(){this._inBatchMode=!1,this._events=[]}commitBatch(){this._inBatchMode=!1,this.emit(d.BATCH_EVENTS,this,this._events),this._events=[]}}d.BATCH_EVENTS="BatchEvents";class f{constructor(...t){this._firstChild=null,this._lastChild=null,this._size=0;for(const e of t)this.pushBack(e)}toJSON(){return Array.from(this.values())}forEach(t){let e=this._firstChild,s=0;for(;null!=e&&0!=t(e);)s++,e=e.nextSibling;return s}equals(t,e){if(this.size!=t.size)return!1;let s=this.first,n=t.first;for(;null!=s&&null!=n;s=s.nextSibling,n=n.nextSibling)if(!e(s,n))return!1;return null==s&&null==n}get isEmpty(){return 0==this._size}get size(){return this._size}get first(){return this._firstChild}get last(){return this._lastChild}*reversedValues(){let t=this._lastChild;for(;null!=t;)yield t,t=t.prevSibling}*values(){let t=this._firstChild;for(;null!=t;)yield t,t=t.nextSibling}add(t,e=null){if(null!=t.nextSibling||null!=t.prevSibling)throw new Error("New node already added to a list. Remove it first");if(t.nextSibling=t.prevSibling=null,this._size++,null==this._firstChild||null==this._lastChild)this._firstChild=this._lastChild=t;else if(null==e)t.prevSibling=this._lastChild,t.nextSibling=null,this._lastChild.nextSibling=t,this._lastChild=t;else if(e==this._firstChild)t.nextSibling=e,t.prevSibling=null,this._firstChild.prevSibling=t,this._firstChild=t;else{const s=e.prevSibling;t.nextSibling=e,e.prevSibling=t,t.prevSibling=s,null!=s&&(s.nextSibling=t)}return this}pushFront(t){return this.add(t,this._firstChild)}pushBack(t){return this.add(t)}remove(t){const e=t.nextSibling,s=t.prevSibling;return null==e?(this._lastChild=s,null==s&&(this._firstChild=null)):e.prevSibling=s,null==s?(this._firstChild=e,null==e&&(this._lastChild=null)):s.nextSibling=e,this._size--,t.prevSibling=t.nextSibling=null,this}popBack(){if(null==this._lastChild)throw new Error("No children");const t=this._lastChild;return this.remove(t),t}popFront(){if(null==this._firstChild)throw new Error("No children");const t=this._firstChild;return this.remove(t),t}}class g{}function m(t,e){for(t=Math.abs(t),e=Math.abs(e);e>0;){const s=e;e=t%e,t=s}return t}g.IS_EXPLORER=()=>navigator&&navigator.userAgent.indexOf("MSIE")>-1,g.IS_FIREFOX=()=>navigator&&navigator.userAgent.indexOf("Firefox")>-1,g.IS_OPERA=()=>navigator&&navigator.userAgent.toLowerCase().indexOf("op")>-1,g.UAHasChrome=()=>navigator&&navigator.userAgent.indexOf("Chrome")>-1,g.UAHasSafari=()=>navigator&&navigator.userAgent.indexOf("Safari")>-1,g.IS_SAFARI=()=>navigator&&g.UAHasSafari()&&(!g.UAHasChrome()||!g.UAHasSafari()),g.IS_CHROME=()=>navigator&&g.UAHasChrome()&&(!g.UAHasChrome()||!g.IS_OPERA());class p{constructor(t=0,e=1,s=!1){if(isNaN(t)||isNaN(e))throw new Error(`Invalid numerator(${t}) or denminator(${e})`);if(s){const s=m(t,e);t/=s,e/=s}this.num=t,this.den=e}static parse(t,e=!1){const s=t.trim().split("/").map(t=>t.trim());let n=1,r=1;if(1==s.length)n=parseInt(s[0]);else{if(2!=s.length)throw new Error("Invalid fraction string: "+t);s[0].length>0&&(n=parseInt(s[0])),s[1].length>0&&(r=parseInt(s[1]))}if(isNaN(n)||isNaN(r))throw new Error("Invalid fraction string: "+t);return new p(n,r,e)}get isWhole(){return this.num%this.den==0}get isZero(){return 0==this.num}get isInfinity(){return 0==this.den}get isOne(){return this.num==this.den}get ceil(){return this.num%this.den==0?this.num/this.den:1+Math.floor(this.num/this.den)}get floor(){return this.num%this.den==0?this.num/this.den:Math.floor(this.num/this.den)}plus(t,e=!1){return new p(this.num*t.den+this.den*t.num,this.den*t.den,e)}plusNum(t,e=!1){return new p(this.num+this.den*t,this.den,e)}minus(t,e=!1){return new p(this.num*t.den-this.den*t.num,this.den*t.den,e)}minusNum(t,e=!1){return new p(this.num-this.den*t,this.den,e)}times(t,e=!1){return new p(this.num*t.num,this.den*t.den,e)}timesNum(t,e=!1){return new p(this.num*t,this.den,e)}divby(t,e=!1){return new p(this.num*t.den,this.den*t.num,e)}divbyNum(t,e=!1){return new p(this.num,this.den*t,e)}numDivby(t,e=!1){return new p(this.den*t,this.num,e)}mod(t){const e=this.divby(t),s=Math.floor(e.num/e.den);return this.minus(t.timesNum(s))}modNum(t){const e=this.divbyNum(t),s=Math.floor(e.num/e.den);return this.minusNum(t*s)}get inverse(){return new p(this.den,this.num)}get factorized(){const t=m(this.num,this.den);return new p(this.num/t,this.den/t)}equals(t){return this.num*t.den==this.den*t.num}equalsNum(t){return this.num==this.den*t}cmp(t){return this.num*t.den-this.den*t.num}cmpNum(t){return this.num-this.den*t}isLT(t){return this.cmp(t)<0}isLTE(t){return this.cmp(t)<=0}isLTNum(t){return this.cmpNum(t)<0}isLTENum(t){return this.cmpNum(t)<=0}isGT(t){return this.cmp(t)>0}isGTE(t){return this.cmp(t)>=0}isGTNum(t){return this.cmpNum(t)>0}isGTENum(t){return this.cmpNum(t)>=0}toString(){return this.num+"/"+this.den}static max(t,e){return t.cmp(e)>0?t:e}static min(t,e){return t.cmp(e)<0?t:e}}p.ZERO=new p,p.ONE=new p(1,1),p.INFINITY=new p(1,0);const b=(t=0,e=1,s=!1)=>new p(t,e,s),y=p.ZERO;p.ONE;class S{constructor(t,e=0,s=0,n=0){this.cycle=t,this.barIndex=e,this.beatIndex=s,this.instance=n}get next(){const t=this.cycle.bars[this.barIndex],e=[[this.barIndex,this.beatIndex,this.instance],t.beatLengths[this.beatIndex]];return this.instance++,(!t.beatCounts[this.beatIndex]||this.instance>=t.beatCounts[this.beatIndex])&&(this.instance=0,this.beatIndex++,this.beatIndex>=t.beatLengths.length&&(this.beatIndex=0,this.barIndex++,this.barIndex>=this.cycle.bars.length&&(this.barIndex=0))),e}get prev(){const t=this.cycle.bars[this.barIndex],e=[[this.barIndex,this.beatIndex,this.instance],t.beatLengths[this.beatIndex]];return this.instance--,this.instance<0&&(this.beatIndex--,this.beatIndex<0&&(this.barIndex--,this.barIndex<0&&(this.barIndex=this.cycle.bars.length-1),this.beatIndex=this.cycle.bars[this.barIndex].beatCount-1),this.instance=(this.cycle.bars[this.barIndex].beatCounts[this.beatIndex]||1)-1),e}}class E extends o{constructor(t=null){super(t=t||{}),this.TYPE="Bar",this.beatLengths=[],this.beatCounts=[],this.name=t.name||"";for(const e of t.beatLengths||[])"number"==typeof e?this.beatLengths.push(b(e)):this.beatLengths.push(e);for(const e of t.beatCounts||[])this.beatCounts.push(e);for(;this.beatCounts.length<this.beatLengths.length;)this.beatCounts.push(1)}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{name,beatLengths:this.beatLengths})}equals(t){if(!super.equals(t))return!1;if(this.beatLengths.length!=t.beatLengths.length)return!1;if(this.beatCounts.length!=t.beatCounts.length)return!1;for(let e=0;e<this.beatLengths.length;e++)if(!this.beatLengths[e].equals(t.beatLengths[e]))return!1;for(let e=0;e<this.beatCounts.length;e++)if(this.beatCounts[e]!=t.beatCounts[e])return!1;return!0}copyTo(t){super.copyTo(t),t.name=this.name,t.beatLengths=[...this.beatLengths],t.beatCounts=[...this.beatCounts]}instanceCount(t){return t>this.beatCounts.length?1:this.beatCounts[t]}get beatCount(){return this.beatLengths.length}get totalBeatCount(){let t=0;for(let e=0;e<this.beatLengths.length;e++)t+=this.beatCounts[e]||1;return t}get duration(){let t=y;for(let e=0;e<this.beatLengths.length;e++)t=t.plus(this.beatLengths[e].timesNum(this.beatCounts[e]||1));return t}}class C extends o{constructor(t=null){super(t=t||{}),this.TYPE="Cycle",this.name=t.name||"",this.bars=t.bars||[]}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{name,bars:this.bars.map(t=>t.debugValue())})}children(){return this.bars}equals(t){if(!super.equals(t))return!1;if(this.bars.length!=t.bars.length)return!1;for(let e=0;e<this.bars.length;e++)if(!this.bars[e].equals(t.bars[e]))return!1;return!0}getAtIndex(t){let e=0;for(;t<0;)t+=this.totalBeatCount,e--;t>=this.totalBeatCount&&(e=Math.floor(t/this.totalBeatCount)),t%=this.totalBeatCount;let s=y;for(let n=0;n<this.bars.length;n++){const r=this.bars[n];if(t>=r.totalBeatCount)t-=r.totalBeatCount,s=s.plus(r.duration);else for(let i=0;i<r.beatCount;i++){const o=r.beatLengths[i],a=r.beatCounts[i]||1;if(!(t>=a)){const r=t;return[e,[n,i,r],s.plus(o.timesNum(r))]}t-=a,s=s.plus(o.timesNum(a))}}throw new Error("Should not be here!")}getPosition(t){const e=this.duration;let s=0;if(t.isLT(y))for(;t.isLT(y);)s--,t=t.plus(e);else if(t.isGTE(e)){const n=t.mod(e);a((t=t.minus(n).divby(e)).isWhole),s=t.floor,t=n}let n=0;for(let e=0;e<this.bars.length;e++){const r=this.bars[e],i=r.duration;if(t.isGTE(i))t=t.minus(i);else for(let i=0;i<r.beatCount;i++){const o=r.beatLengths[i],a=r.beatCounts[i]||1;for(let r=0;r<a;r++,n++){if(!t.isGTE(o))return[s,[e,i,r],t,n];t=t.minus(o)}}n+=r.totalBeatCount}throw new Error("Should not be here!")}*iterateBeats(t=0,e=0,s=0){let n=t,r=e,i=s;for(;;){const t=this.bars[n];yield[[n,r,i],t.beatLengths[r]],i++,(!t.beatCounts[r]||i>=t.beatCounts[r])&&(i=0,r++,r>=t.beatLengths.length&&(r=0,n++,n>=this.bars.length&&(n=0)))}}copyTo(t){super.copyTo(t),t.name=this.name,t.bars=this.bars.map(t=>t.clone())}get beatCount(){let t=0;for(const e of this.bars)t+=e.beatCount;return t}get totalBeatCount(){let t=0;for(const e of this.bars)t+=e.totalBeatCount;return t}get duration(){return this.bars.reduce((t,e)=>t.plus(e.duration),y)}}C.DEFAULT=new C({name:"Adi Thalam",bars:[new E({name:"Laghu",beatLengths:[1,1,1,1]}),new E({name:"Dhrutam",beatLengths:[1,1]}),new E({name:"Dhrutam",beatLengths:[1,1]})]});const w=p.ZERO,v=p.ONE;var _,x;(x=_||(_={})).NOTE="Note",x.LITERAL="Literal",x.SYLLABLE="Syllable",x.SPACE="Space",x.GROUP="Group",x.LABEL="Label",x.REST="Rest",x.MARKER="Marker";class N extends o{constructor(t=v){super(),this.TYPE="Atom",this.nextSibling=null,this.prevSibling=null,this.parentGroup=null,this.isContinuation=!1,this._duration=t||v}debugValue(){const t=super.debugValue();return this.duration.isOne||(t.duration=this.duration.factorized.toString()),this.isContinuation&&(t.isContinuation=!0),(this.markersBefore||[]).length>0&&(t.mbef=this.markersBefore.map(t=>t.debugValue())),(this.markersAfter||[]).length>0&&(t.maft=this.markersAfter.map(t=>t.debugValue())),t}copyTo(t){super.copyTo(t),t._duration=new p(this.duration.num,this.duration.den)}get duration(){return this._duration}set duration(t){this._duration=t}}class A extends N{constructor(){super(...arguments),this.TYPE="LeafAtom",this.beforeRest=!1}splitAt(t){if(this.duration.cmp(t)>0){const e=this.createSpilloverSpace(this.duration.minus(t));return e.isContinuation=!0,this.duration=t,e}return null}createSpilloverSpace(t){return new I(t)}debugValue(){return this.beforeRest?Object.assign(Object.assign({},super.debugValue()),{beforeRest:!0}):super.debugValue()}}class T extends i{constructor(t,e=!0){super(),this.text=t,this.isBefore=e,this.TYPE="Marker"}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{text:this.text,before:this.isBefore})}toString(){return`Marker(${this.text}-${this.isBefore})`}}class I extends A{constructor(t=v,e=!1){super(t),this.TYPE="Space",this.isSilent=!1,this.isSilent=e}debugValue(){return Object.assign(Object.assign({},super.debugValue()),{isSilent:this.isSilent})}toString(){return`Space(${this.duration}-${this.isSilent})`}copyTo(t){super.copyTo(t),t.isSilent=this.isSilent}equals(t){return super.equals(t)&&this.isSilent==t.isSilent}createSpilloverSpace(t){const e=super.createSpilloverSpace(t);return e.isSilent=this.isSilent,e}}class O extends A{constructor(t,e=v){super(e),this.value=t,this.TYPE="Literal",this.embelishments=[]}debugValue(){const t=Object.assign(Object.assign({},super.debugValue()),{value:this.value});return this.embelishments.length>0&&(t.embs=this.embelishments.map(t=>"debugValue"in t?t.debugValue():t)),t}toString(){return`Lit(${this.duration}-${this.value})`}equals(t){return super.equals(t)&&this.value==t.value}copyTo(t){super.copyTo(t),t.value=this.value}}class R extends O{constructor(t,e=v,s=0,n=0){super(t,e),this.TYPE="Note",this.octave=0,this.shift=0,this.octave=s,this.shift=n}static fromLit(t){if(t.TYPE==_.NOTE)return t;const e=new R(t.value,t.duration);return e.embelishments=t.embelishments,e.beforeRest=t.beforeRest,e}debugValue(){const t=Object.assign({},super.debugValue());return 0!=this.octave&&(t.octave=this.octave),0!=this.shift&&(t.shift=this.shift),t}toString(){return`Note(${this.duration}-${this.value}-${this.octave})`}equals(t){return super.equals(t)&&this.octave==t.octave&&this.shift==t.shift}copyTo(t){super.copyTo(t),t.octave=this.octave,t.shift=this.shift}}class k extends N{constructor(...t){super(0==t.length?w:v),this.TYPE="Group",this.durationIsMultiplier=!1,this.atoms=new f,this._observers=[],this.addAtoms(!1,...t)}addObserver(t){return this._observers.push(t),()=>this.removeObserver(t)}removeObserver(t){const e=this._observers.indexOf(t);e>=0&&this._observers.splice(e,1)}notifyObservers(e,s,n){var r,i,o;if(this._eventsEnabled)for(const a of this._observers)switch(e){case t.ADD:null===(r=a.onAtomsAdded)||void 0===r||r.call(a,this,s,n);break;case t.INSERT:null===(i=a.onAtomsInserted)||void 0===i||i.call(a,this,s,n);break;case t.REMOVE:null===(o=a.onAtomsRemoved)||void 0===o||o.call(a,this,s)}}equals(t,e=!1){return!!super.equals(t)&&this.atoms.equals(t.atoms,(t,e)=>t.equals(e))}copyTo(t){super.copyTo(t),t.durationIsMultiplier=this.durationIsMultiplier;for(const e of this.atoms.values())t.atoms.add(e.clone())}get duration(){return this.durationIsMultiplier?this.totalChildDuration.divby(this._duration):this._duration}setDurationAsMultiplier(t=!0){return this.durationIsMultiplier=t,this}setDuration(t,e=!1){return this._duration=t,this.durationIsMultiplier=e,this}debugValue(){const t=Object.assign(Object.assign({},super.debugValue()),{atoms:Array.from(this.atoms.values(),t=>t.debugValue())});return this.durationIsMultiplier&&(t.durationIsMultiplier=!0),t}splitAt(t){if(this.duration.isLTE(t)||t.isLTE(w))return null;const e=new k;this.durationIsMultiplier&&(e.durationIsMultiplier=!0,e._duration=this._duration);let s=this.duration;const n=this.totalChildDuration,r=this.durationIsMultiplier?v.divby(this._duration):this._duration.divby(n,!0);for(;s.isGT(t)&&this.atoms.last;){const n=this.atoms.last,i=n.duration.times(r),o=s.minus(i);if(!o.isGTE(t)){const s=t.minus(o,!0).divby(r,!0),i=n.splitAt(s);if(null==i)throw new Error("Spill over cannot be null here");if(this.durationIsMultiplier){if(this._duration.isZero)throw new Error("How can this be?")}else this._duration=t;return i.isContinuation=!0,e.insertAtomsAt(e.atoms.first,!0,i),e}if(this.removeAtoms(!0,n),e.insertAtomsAt(e.atoms.first,!0,n),o.equals(t))return e;s=o}return e}get totalChildDuration(){let t=w;for(const e of this.atoms.values())t=t.plus(e.duration);return t}insertAtomsAt(e,s=!1,...n){const r=(s=s&&!this.durationIsMultiplier)?this.totalChildDuration:v;let i;if(e){i=0;for(const t of this.atoms.values()){if(t===e)break;i++}}else i=this.atoms.size;const o=[];for(const t of n){if(null!=t.parentGroup){if(t.parentGroup!=this)throw new Error("Atom belongs to another parent. Remove it first");t.parentGroup.removeAtoms(!1,t)}if(t.TYPE==_.REST){const t=this.atoms.last;t&&t.TYPE!=_.GROUP&&t.TYPE!=_.LABEL&&(t.beforeRest=!0)}else t.parentGroup=this,this.atoms.add(t,e),o.push(t)}if(s)if(this._duration.isZero){if(this.durationIsMultiplier)throw new Error("How can this be?");this._duration=this.totalChildDuration}else{const t=this.totalChildDuration.divby(r);this._duration=this._duration.times(t,!0)}if(o.length>0){const s=e?t.INSERT:t.ADD;this.notifyObservers(s,o,i)}return this}addAtoms(t=!1,...e){return this.insertAtomsAt(null,t,...e)}removeAtoms(e=!1,...s){const n=(e=e&&!this.durationIsMultiplier)?this.totalChildDuration:v,r=[];for(const t of s)if(t.parentGroup==this)this.atoms.remove(t),t.parentGroup=null,r.push(t);else if(null!=t.parentGroup)throw new Error("Atom cannot be removed as it does not belong to this group");if(e)if(this._duration.isZero){if(this.durationIsMultiplier)throw new Error("How can this be?");this._duration=this.totalChildDuration}else{const t=this.totalChildDuration.divby(n);this._duration=this._duration.times(t,!0)}return r.length>0&&this.notifyObservers(t.REMOVE,r,-1),this}}const L=p.ZERO;class M{constructor(t){this.uuid=M.counter++,t=t||{},this.beatDuration=t.beatDuration||1,"cycle"in t&&(this.cycle=t.cycle),this.cycle&&!this.cycle.duration.isZero||(this.cycle=C.DEFAULT),this._rowStartOffsets=[],this._rowEndOffsets=[],this._rowDurations=[],this._totalLayoutDuration=L,this._totalBeats=0,this._beatLayouts=[],this.lineBreaks=t.lineBreaks||t.layout||[]}equals(t){return this.beatDuration==t.beatDuration&&this.cycle.equals(t.cycle)&&this.lineBreaksEqual(t._lineBreaks)}lineBreaksEqual(t){return this._lineBreaks.length==t.length&&this._lineBreaks.every((e,s)=>e==t[s])}debugValue(){var t;return{cycle:null===(t=this.cycle)||void 0===t?void 0:t.debugValue(),beatDuration:this.beatDuration,lineBreaks:this._lineBreaks}}getBeatLocation(t){const e=t.index%this.totalBeats;let s=0;for(let n=0;n<this._lineBreaks.length;n++){if(e<s+this._lineBreaks[n]){let r=L;if(e>s){const n=new S(this.cycle,t.barIndex,t.beatIndex,t.instance);let[,i]=n.prev;for(let t=s;t<e;t++)[,i]=n.prev,r=r.plus(i.timesNum(this.beatDuration))}return[n,e-s,r]}s+=this._lineBreaks[n]}throw new Error("Invalid beat index: "+t.index)}get lineBreaks(){return this._lineBreaks&&0!=this._lineBreaks.length||(this.lineBreaks=[this.cycle.beatCount]),this._lineBreaks}set lineBreaks(t){this._lineBreaks=t,this.refreshLayout()}get beatLayouts(){return(!this._beatLayouts||this._beatLayouts.length<this.lineBreaks.length)&&this.refreshLayout(),this._beatLayouts}get totalBeats(){return this.beatLayouts,this._totalBeats}get totalLayoutDuration(){return this.beatLayouts,this._totalLayoutDuration}refreshLayout(){const t=this.cycle.iterateBeats(),e=this.beatDuration;this._beatLayouts=this.lineBreaks.map((s,n)=>{const r=[];for(let n=0;n<s;n++){const s=t.next().value;s[1]=s[1].timesNum(e),r.push(s)}return r}),this._totalBeats=this.lineBreaks.reduce((t,e)=>t+e,0),this._rowDurations=this._beatLayouts.map(t=>t.reduce((t,e)=>t.plus(e[1]),L)),this._rowDurations.forEach((t,e)=>{this._rowStartOffsets[e]=0==e?L:this._rowStartOffsets[e-1].plus(t)}),this._rowEndOffsets=this._rowDurations.map((t,e)=>this._rowStartOffsets[e].plus(t)),this._totalLayoutDuration=this._rowDurations.reduce((t,e)=>t.plus(e),L)}}M.counter=0;class P extends c{constructor(){super(...arguments),this.uuid=P.idCounter++,this.lastUpdatedAt=0,this.rows=[],this.rowAligns=new Map,this.colAligns=new Map}debugValue(){return{rows:this.rows.map(t=>t.debugValue()),lastUpdatedAt:this.lastUpdatedAt}}get firstRow(){for(const t of this.rows)if(t.numCells>0)return t.rowIndex;return-1}get firstCol(){let t=-1;for(const e of this.rows){const s=e.firstCol;s>=0&&(t<0||s<t)&&(t=s)}return t}cellsInRow(t){const e=[],s=this.rows[t];if(s)for(const t of s.cells)(null==t?void 0:t.value)&&e.push(t);return e}cellsInCol(t){const e=[];for(const s of this.rows){const n=s.cellAt(t);(null==n?void 0:n.value)&&e.push(n)}return e}addRowAlign(t){this.rowAligns.set(t.uuid,t)}addColAlign(t){this.colAligns.set(t.uuid,t)}addRows(t=-1,e=1){t<0&&(t=this.rows.length);let s=this.rows[t]||null;const n=this.rows[t-1]||null;for(let r=e-1;r>=0;r--){const e=new D(this,t+r);this.rows.splice(t,0,e),null!=s&&e.defaultRowAlign.addSuccessor(s.defaultRowAlign),0==r&&t>0&&n.defaultRowAlign.addSuccessor(e.defaultRowAlign),s=e}for(let s=t+e;s<this.rows.length;s++)this.rows[s].rowIndex+=e;return this}getRow(t){return t>=this.rows.length&&this.addRows(-1,1+t-this.rows.length),this.rows[t]}setValue(t,e,s,n){var r,i;const o=this.getRow(t);if(n||(n=(t,e)=>new $(t,e)),null==s){const t=o.clearCellAt(e);return null!=t&&(null===(r=this.eventHub)||void 0===r||r.emit(B.CLEARED,this,{loc:t.location})),t}{const t=o.cellAt(e,n),r=t.value;return null===(i=this.eventHub)||void 0===i||i.emit(B.UPDATED,this,{loc:t.location,cell:t,oldValue:t.value}),t.value=s,r}}eventHubChanged(){console.log("Event Hub Changed for GridModel")}}var B;P.idCounter=0,function(t){t.ADDED="CellAdded",t.CLEARED="CellCleared",t.REMOVED="CellRemoved",t.UPDATED="CellUpdated",t.MOVED="CellMoved"}(B||(B={}));class ${constructor(t,e,s=null){this.gridRow=t,this.colIndex=e,this.value=s,this.uuid=$.idCounter++,this.rowAlign=t.defaultRowAlign}get rowAlign(){return this._rowAlign}set rowAlign(t){t.addCell(this),this._rowAlign=t}get colAlign(){return this._colAlign}set colAlign(t){t.addCell(this),this._colAlign=t}get location(){return this.gridRow.rowIndex+":"+this.colIndex}get grid(){return this.gridRow.grid}get rowIndex(){return this.gridRow.rowIndex}debugValue(){const t={r:this.gridRow.rowIndex,c:this.colIndex,value:this.value,y:this.rowAlign.coordOffset,h:this.rowAlign.maxLength};return this.colAlign&&(t.x=this.colAlign.coordOffset,t.w=this.colAlign.maxLength),t}}$.idCounter=0;class D{constructor(t,e){this.grid=t,this.rowIndex=e,this.cells=[],this.defaultRowAlign=new F,this.grid.addRowAlign(this.defaultRowAlign)}get firstCol(){var t;for(let e=0;e<this.cells.length;e++)if(null===(t=this.cells[e])||void 0===t?void 0:t.value)return e;return-1}get numCols(){return this.cells.length}get numCells(){let t=0;for(const e of this.cells)null!=e&&null!=e.value&&t++;return t}cellAt(t,e){let s=this.cells[t]||null;return!s&&e&&(this.cells[t]=s=e(this,t),s.gridRow=this,s.colIndex=t,s.rowAlign&&this.grid.addRowAlign(s.rowAlign),s.colAlign&&this.grid.addColAlign(s.colAlign)),s}clearCellAt(t){const e=this.cells[t]||null;return e&&(this.cells[t]=null),e}debugValue(){return{r:this.rowIndex,cells:this.cells.filter(t=>t).map(t=>null==t?void 0:t.debugValue())}}}class U{constructor(){this.uuid=U.idCounter++,this.needsLayout=!1,this._coordOffset=0,this._maxLength=0,this.paddingBefore=5,this.paddingAfter=5,this.cells=[],this.prevLines=[],this.nextLines=[]}get coordOffset(){return this._coordOffset}get maxLength(){return this._maxLength+this.paddingBefore+this.paddingAfter}setMaxLength(t){this._maxLength=t}setPadding(t,e){t>=0&&(this.paddingBefore=t),e>=0&&(this.paddingAfter=e)}addCell(t){return this.beforeAddingCell(t)&&this.cells.push(t),this}removeCell(t){if(this.beforeRemovingCell(t))for(let e=0;e<this.cells.length;e++)if(this.cells[e].uuid==t.uuid){this.cells.splice(e,1);break}return this}addSuccessor(t){for(const e of this.nextLines)if(e==t)return;this.nextLines.push(t),t.prevLines.push(this)}}U.idCounter=0;class F extends U{setOffset(t){this._coordOffset=t;for(const e of this.cells)if(e.value){const s=this.getCellView(e);this._maxLength<=0&&this.evalMaxLength(),s.setBounds(null,t,null,this.maxLength,!0)}}evalMaxLength(t=[]){this._maxLength=0;for(const t of this.cells)if(t.value){const e=this.getCellView(t);this._maxLength=Math.max(e.minSize.height,this._maxLength)}return this._maxLength}beforeAddingCell(t){return t.rowAlign&&t.rowAlign!=this&&t.rowAlign.removeCell(t),t.rowAlign!=this}beforeRemovingCell(t){return t.rowAlign==this}}p.ZERO;const j=p.ONE;class V{constructor(t,e,s,n,r,i,o,a,l){this.index=t,this.role=e,this.offset=s,this.duration=n,this.barIndex=r,this.beatIndex=i,this.instance=o,this.prevBeat=a,this.nextBeat=l,this.uuid=V.idCounter++,this.atomIsPlaceholder=!1}debugValue(){return{index:this.index,role:this.role.name,offset:this.offset.toString(),duration:this.duration.toString(),barIndex:this.barIndex,beatIndex:this.beatIndex,instance:this.instance,atom:this.atom.debugValue()}}get endOffset(){return this.offset.plus(this.duration)}get filled(){return this.remaining.isZero}get remaining(){return this.atom?this.duration.minus(this.atom.duration,!0):this.duration}add(t){return!(this.remaining.cmp(t.duration)<0||(this.atom?(this.atomIsPlaceholder||(this.atomIsPlaceholder=!0,this.atom=new k(this.atom).setDuration(j,!0)),this.atom.addAtoms(!0,t)):this.atom=t,0))}get preMarkers(){const t=[];let e=this.atom;for(;null!=e;){for(const s of e.markersBefore||[])t.push(s);e=e.TYPE==_.GROUP?e.atoms.first:null}return t}get postMarkers(){const t=[];let e=this.atom;for(;null!=e;)t.splice(0,0,...e.markersAfter||[]),e=e.TYPE==_.GROUP?e.atoms.last:null;return t}}function G(t,e,s){const n=[],r={};return t.forEach(t=>{if(!(e(t)in r)){const i=t,o={};let l=[[t,[]]];for(;l.length>0;){const t=[];for(let h=0;h<l.length;h++){const[u,c]=l[h];a(null!=u);const d=s(u);let f=[...c];for(const[s,a]of d)s==i?(f.push([a,s]),f.forEach(([t,e],s)=>r[e]=!0),n.push([i,f]),f=f.slice(0,f.length-1)):e(s)in o||(o[e(s)]=!0,t.push([s,[...f,[a,s]]]))}l=t}}}),n}V.idCounter=0;const z=t=>t.key;class W{constructor(t=z){this._entries=[],this._entriesByKey={},this.keyFunc=t}clear(){this._entries=[],this._entriesByKey={}}remove(t){const e=[];this._entriesByKey={};let s=!1;for(let n=0;n<this._entries.length;n++){const r=this._entries[n];t(r)?s=!0:(r.id=e.length,e.push(r),this._entriesByKey[this.keyFunc(r)]=r)}return this._entries=e,s}get entries(){return this._entries}get(t){return a(t>=0&&t<this._entries.length),this._entries[t]}getByKey(t){return this._entriesByKey[t]||null}ensure(t,e=!1){if(this.has(t)){if(e)throw new Error(`Entry ${this.keyFunc(t)} already exists`);return this._entriesByKey[this.keyFunc(t)]}return this._entriesByKey[this.keyFunc(t)]=t,t.id=this._entries.length,this._entries.push(t),t}has(t){return this.keyFunc(t)in this._entriesByKey}get size(){return this._entries.length}}class K{constructor(t,e=!0){this.entries=new Set,this.hasNull=!1,this.grammar=t,this.enforceSymbolType=e}get debugString(){return"<"+this.labels().sort().join(", ")+">"}labels(t=!1){const e=[];for(const s of this.entries){const n=this.grammar.getSymById(s);a(null!=n),t&&n.isAuxiliary||e.push(n.label)}return this.hasNull&&e.push(""),e}addFrom(t,e=!0){return t.addTo(this,e)}addTo(t,e=!0){const s=t.entries.size;for(const e of this.entries)t.entries.add(e);return e&&(t.hasNull=this.hasNull||t.hasNull),t.entries.size-s}has(t){return this.entries.has(t.id)}add(t){return a(null==this.enforceSymbolType||this.enforceSymbolType==t.isTerminal,`Terminal types being enforced: ${this.enforceSymbolType}`),this.entries.add(t.id),this}delete(t){return this.entries.delete(t.id)}get size(){return this.entries.size+(this.hasNull?1:0)}}class H{constructor(t){this.grammar=t,this.refresh()}get nonterms(){const t=[];return this.entries.forEach(e=>{const s=this.grammar.getSymById(e);a(null!=s&&!s.isTerminal),t.push(s)}),t}refresh(){this.entries=new Set,this.visited={};let t=0;do{t=this.entries.size,this.grammar.allNonTerminals.forEach(t=>this.visit(t))}while(t!=this.entries.size)}visit(t){for(const e of this.grammar.rulesForNT(t))if(this.isStrNullable(e.rhs)){this.add(t);break}}isNullable(t){return!t.isTerminal&&this.entries.has(t.id)}isStrNullable(t,e=0,s=null){null==s&&(s=t.length-1);for(let n=e;n<=s;n++)if(!this.isNullable(t.syms[n]))return!1;return!0}add(t){a(!t.isTerminal),this.entries.add(t.id)}}class q{constructor(t){this.entries={},this._count=0,this.grammar=t}refresh(){this.entries={},this._count=0}forEachTerm(t,e){const s=this.entriesFor(t);s.entries.forEach(t=>{const s=this.grammar.getSymById(t);a(null!=s&&s.isTerminal),e(s)}),s.hasNull&&e(null)}get debugValue(){const t={};for(const e in this.entries)t[this.grammar.getSymById(e).label]=this.entries[e].debugString;return t}get count(){let t=0;for(const e in this.entries)t+=this.entries[e].size;return t}entriesFor(t){if(t.id in this.entries)return this.entries[t.id];{const e=new K(this.grammar);return this.entries[t.id]=e,e}}addNull(t){const e=this.entriesFor(t);return!e.hasNull&&(e.hasNull=!0,!0)}add(t,e,s=!0){t.isTerminal&&a(!1,"Should not be here");const n=this.entriesFor(t);if(e.isTerminal){if(n.has(e))return!1;n.add(e),this._count++}else{const n=this.entriesFor(e),r=this.entriesFor(t),i=n.addTo(r,s);this._count+=i}return!0}}class Q extends q{constructor(t,e){super(t),e||(e=new H(t)),this.nullables=e,this.refresh()}forEachTermIn(t,e=0,s){const n=t.syms,r={};let i=!0;for(let t=e;i&&t<n.length;t++){const e=n[t];if(e.isTerminal)s(e),i=!1;else{const t=e;this.forEachTerm(t,t=>{null==t||t.id in r||(r[t.id]=!0,s(t))}),this.nullables.isNullable(e)||(i=!1)}}i&&s(null)}refresh(){super.refresh();let t=0;do{t=this.count,this.grammar.forEachRule(null,t=>{this.processRule(t)})}while(t!=this.count)}processRule(t){const e=this.nullables;let s=!0;for(const n of t.rhs.syms)if(this.add(t.nt,n,!1),n.isTerminal||!e.isNullable(n)){s=!1;break}s&&this.addNull(t.nt)}}class J extends q{constructor(t,e){super(t),this.firstSets=e||new Q(t),this.refresh()}get nullables(){return this.firstSets.nullables}refresh(){super.refresh();const t=this.grammar;a(null!=t.startSymbol,"Select start symbol of the grammar"),this.add(t.startSymbol,t.Eof);let e=0;do{e=this.count,this.grammar.forEachRule(null,t=>this.processRule(t))}while(e!=this.count)}processRule(t){const e=t.rhs.syms,s=this.firstSets,n=this.firstSets.nullables;for(let n=0;n<e.length;n++){const r=e[n];r.isTerminal||s.forEachTermIn(t.rhs,n+1,t=>{null!=t&&this.add(r,t)})}for(let s=e.length-1;s>=0;s--){if(e[s].isTerminal)continue;let r=!0;for(let t=s+1;t<e.length;t++){const s=e[t];if(s.isTerminal||!n.isNullable(s)){r=!1;break}}r&&this.add(e[s],t.nt)}}}class Y{constructor(t,e,s,n=null){this.grammar=t,this.label=e,this.isTerminal=s,this.isAuxiliary=!1,this.auxType=null,this.precedence=1,this.assocLeft=!0,this.creationId=-1,this.isTerminal=s,this.label=e,this.id=null==n?Y.idCounter--:n}compareTo(t){return this.label.localeCompare(t.label)}equals(t){return this.label==t.label}toString(){return this.label}}Y.idCounter=-1;class X{constructor(...t){this.syms=t||[]}append(...t){for(const e of t)this.syms.push(e);return this}extend(...t){for(const e of t)this.append(...e.syms);return this}copy(){return new X(...this.syms)}add(t){this.syms.push(t)}isTerminal(t){return this.syms[t].isTerminal}get length(){return this.syms.length}toString(){return this.syms.map(t=>t.toString()).join(" ")}slice(t,e){return new X(...this.syms.slice(t,e))}splice(t,e,...s){return this.syms.splice(t,e,...s),this}compareTo(t){for(let e=0;e<this.syms.length&&e<t.syms.length;e++){const s=this.syms[e].compareTo(t.syms[e]);if(0!=s)return s}return this.syms.length-t.syms.length}equals(t){return 0==this.compareTo(t)}containsAt(t,e){let s=0;for(;s<e.length&&t+s<this.syms.length;s++)if(!this.syms[t+s].equals(e.syms[s]))return!1;return s==e.length}get debugString(){return this.syms.map(t=>t.label).join(" ")}}class Z{constructor(t){this.value=t}get isFunction(){return"string"==typeof this.value}get isChildPosition(){return"number"==typeof this.value}}class tt{constructor(t,e,s=null){if(this.nt=t,this.rhs=e,this.action=s,t.isTerminal)throw new Error("Cannot add rules to a terminal")}get debugString(){return`${this.nt.label} -> ${this.rhs.debugString}`}equals(t){return 0==this.compareTo(t)}compareTo(t){a(!isNaN(this.id));const e=this.nt.compareTo(t.nt);return 0==e&&this.rhs.compareTo(t.rhs),e}}class et{static make(t){const e=new et;return t(e),e}constructor(t){this.startSymbol=null,this.modified=!0,this.symbolSet=new W(t=>t.label),this.allRules=[],this._rulesForNT=null,this._followSets=null,this._hasNull=!1,this.auxNTCount=0,t=t||{},this.auxNTPrefix=t.auxNTPrefix||"$",this.Null=this.newTerm(""),this.Eof=this.newTerm("$end")}rulesForNT(t){if(a(!t.isTerminal),null==this._rulesForNT){this._rulesForNT={};for(const t of this.allRules)t.nt.label in this._rulesForNT||(this._rulesForNT[t.nt.label]=[]),this._rulesForNT[t.nt.label].push(t)}return t.label in this._rulesForNT||(this._rulesForNT[t.label]=[]),this._rulesForNT[t.label]}get nullables(){return this.firstSets.nullables}get firstSets(){return this.followSets.firstSets}get followSets(){return(this.modified||null==this._followSets)&&this.refresh(),a(null!=this._followSets),this._followSets}get augStartRule(){return this._AugStartRule}augmentStartSymbol(t="$accept"){a(null==this._AugStartRule,"Ensure this grammar has not yet been augmented."),a(null!=this.startSymbol,"Start symbol not yet set");const e=this.newNT(t);return this._AugStartRule=new tt(e,new X(this.startSymbol)),this.addRule(this._AugStartRule,0),this}refresh(){return this.symbolSet.entries.forEach((t,e)=>t.id=e),this._rulesForNT=null,this.allRules.forEach((t,e)=>{t.id=e}),this._followSets=new J(this),this.modified=!1,this}addTerminals(...t){for(const e of t)this.newTerm(e)}get terminals(){return this.symbolSet.entries.filter(t=>t.isTerminal)}get allNonTerminals(){return this.symbolSet.entries.filter(t=>!t.isTerminal)}get nonTerminals(){return this.symbolSet.entries.filter(t=>!t.isTerminal&&!t.isAuxiliary)}get auxNonTerminals(){return this.symbolSet.entries.filter(t=>t.isAuxiliary)}get allSymbols(){return this.symbolSet.entries}forEachNT(t){for(const e of this.symbolSet.entries)if(!e.isTerminal&&0==t(e))return}forEachRule(t,e){const s=null==t?this.allRules:this.rulesForNT(t)||[];for(let t=0;t<s.length;t++)if(0==e(s[t],t))return!1;return!0}getRule(t,e){return"string"==typeof t&&(t=this.getSym(t)),a(null!=t),this.rulesForNT(t)[e]}findRule(t,e){return this.rulesForNT(t).findIndex(s=>s.nt==t&&s.rhs.equals(e))}add(t,e,s=null){let n=null;return"string"==typeof t?(n=this.getSym(t),null==n&&(n=this.newNT(t))):n=this.ensureSym(t),this.addRule(new tt(n,e,s))}addRule(t,e=-1){if(this.findRule(t.nt,t.rhs)>=0)throw new Error("Duplicate rule: "+t.debugString);return t.id=this.allRules.length,0==t.rhs.length&&(this._hasNull=!0),e<0?this.allRules.push(t):this.allRules.splice(e,0,t),this._rulesForNT=null,this.modified=!0,t}removeRules(t){return this.allRules=this.allRules.filter(e=>!t(e)),this._rulesForNT=null,this.modified=!0,!0}removeSymbols(t){let e=!1;const s=[];return this.allRules.forEach(n=>{if(!t(n.nt))if(0==n.rhs.length)s.push(n);else{const r=new X(...n.rhs.syms.filter(e=>!t(e)));e=e||n.rhs.length!=r.length,r.length>0&&s.push(new tt(n.nt,r))}}),this.allRules=s,e=this.symbolSet.remove(t)||e,this.modified=this.modified||e,e}getSymById(t){return this.symbolSet.get(t)}getSym(t){return this.symbolSet.getByKey(t)}ensureSym(t,e=!1){const s=this.symbolSet.ensure(t,e);return t==s?s.creationId<0&&(s.creationId=this.symbolSet.size):a(!e,"Should have already thrown error"),s}T(t,e=!1){let s=this.getSym(t);if(null!=s){if(e)throw new Error(`Terminal ${t} is already exists`);if(!s.isTerminal)throw new Error(`Symbol (${t}) already exists as a non-terminal`)}else s=new Y(this,t,!0),s=this.ensureSym(s,!0);return s}NT(t,e=!1,s=!1){let n=this.getSym(t);if(null!=n){if(s)throw new Error(`Non-terminal ${t} is already exists`);if(n.isTerminal)throw new Error(`Symbol (${t}) already exists as a terminal`)}else n=new Y(this,t,!1),n.isAuxiliary=e,n=this.ensureSym(n,!0),e||null!=this.startSymbol||(this.startSymbol=n);return n}newTerm(t){return this.T(t,!0)}newNT(t,e=!1){return this.NT(t,e,!0)}isTerminal(t){const e=this.getSym(t);return null!=e&&e.isTerminal}isNT(t){const e=this.getSym(t);return null!=e&&!e.isTerminal&&!e.isAuxiliary}isAuxNT(t){const e=this.getSym(t);return null!=e&&!e.isTerminal&&e.isAuxiliary}seq(...t){if(1==t.length)return this.normalizeRule(t[0]);{const e=new X;for(const s of t){const t=this.normalizeRule(s);for(let s=0;s<t.length;s++)e.add(t.syms[s])}return e}}anyof(...t){return 1==t.length?this.normalizeRule(t[0]):new X(this.ensureAuxNT(...t.map(t=>this.normalizeRule(t))))}opt(t){const e=this.anyof(t,new X),s=e.syms[0];return a(1==e.syms.length&&s.isAuxiliary,"NT must be an auxiliary symbol"),s.auxType="opt",e}atleast0(t,e=!0){const s=this.normalizeRule(t);let n=this.findAuxNT(e=>{const n=this.rulesForNT(e);if(2!=n.length)return!1;let r=0;if(0==n[0].rhs.length)r=1;else{if(0!=n[1].rhs.length)return!1;r=0}const i=n[r].rhs;return i.length==1+t.length&&(i.syms[0].equals(e)?i.containsAt(1,s):!!i.syms[i.length-1].equals(e)&&i.containsAt(0,s))});return null==n&&(n=this.newAuxNT(),n.auxType=e?"atleast0:left":"atleast0",this.add(n,new X),e?this.add(n,new X(n).extend(s)):this.add(n,s.copy().append(n))),new X(n)}atleast1(t,e=!0){const s=this.normalizeRule(t);let n=this.findAuxNT(e=>{const n=this.rulesForNT(e);if(2!=n.length)return!1;let r=0;if(n[0].rhs.equals(s))r=1;else{if(!n[1].rhs.equals(s))return!1;r=0}const i=n[r].rhs;return i.length==1+t.length&&(i.syms[0].equals(e)?i.containsAt(1,s):!!i.syms[i.length-1].equals(e)&&i.containsAt(0,s))});return null==n&&(n=this.newAuxNT(),n.auxType=e?"atleast1:left":"atleast1",this.add(n,s),e?this.add(n,new X(n).extend(s)):this.add(n,s.copy().append(n))),new X(n)}normalizeRule(t){if("string"==typeof t){const e=this.getSym(t);if(null==e)throw new Error(`Invalid symbol: '${t}'`);return new X(e)}return t}newAuxNTName(){return this.auxNTPrefix+this.auxNTCount++}newAuxNT(t=""){return""==t&&(t=this.newAuxNTName()),this.newNT(t,!0)}ensureAuxNT(...t){let e=this.findAuxNTByRules(...t);if(null==e){e=this.newAuxNT(),e.auxType="anyof";for(const s of t)this.add(e,s)}return e}findAuxNT(t){for(const e of this.symbolSet.entries)if(e.isAuxiliary&&t(e))return e;return null}findAuxNTByRules(...t){return this.findAuxNT(e=>{const s=this.rulesForNT(e);if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++)if(!s[e].rhs.equals(t[e]))return!1;return!0})}print(t=null){const e=(t=t||{}).ruleSep||"->",s=t.includeSemiColon||!1,n=t.lambdaSymbol||"",r=[];return this.forEachRule(null,(t,i)=>{let o=`${t.nt.label} ${e} `;t.rhs.length>0?o+=t.rhs.debugString:o+=n,s&&(o+=" ;"),r.push(o)}),r}get debugValue(){const t=[];return this.forEachRule(null,(e,s)=>{t.push(`${e.nt.label} -> ${e.rhs.debugString}`)}),t}get terminalDerivingSymbols(){const t=new K(this,null);let e=-1,s=!0;for(;0!=e;){e=0;for(const n of this.allRules){s=!0;for(const r of n.rhs.syms)t.has(r)||(r.isTerminal?(t.add(r),e++):s=!1);s&&!t.has(n.nt)&&(t.add(n.nt),e++)}}return t}reachableSymbols(t=null){null==t&&(t=this._AugStartRule?this._AugStartRule.nt:this.startSymbol),a(null!=t,"Start symbol does not exist");const e=new K(this,!1).add(t);let s=[t];for(;s.length>0;){const t=[];for(const n of s)for(const s of this.rulesForNT(n))for(const n of s.rhs.syms)n.isTerminal||e.has(n)||(t.push(n),e.add(n));s=t}return e}get cycles(){return G(this.allNonTerminals,t=>t.label,t=>{const e=[];return this.forEachRule(t,(s,n)=>{s.rhs.syms.forEach((r,i)=>{r.isTerminal||this.nullables.isStrNullable(s.rhs,0,i-1)&&this.nullables.isStrNullable(s.rhs,i+1)&&e.push([r,[t,n]])})}),e})}get leftRecursion(){return G(this.allNonTerminals,t=>t.id,t=>{const e=[];return this.forEachRule(t,(t,s)=>{t.rhs.syms.forEach((t,n)=>{if(!t.isTerminal)return e.push([t,s]),this.nullables.isNullable(t)})}),e})}}var st;!function(t){t[t.WORD_CHAR=0]="WORD_CHAR",t[t.DIGITS=1]="DIGITS",t[t.SPACES=2]="SPACES"}(st||(st={}));const nt="0".charCodeAt(0),rt="9".charCodeAt(0),it="a".charCodeAt(0),ot="z".charCodeAt(0),at="A".charCodeAt(0),lt="Z".charCodeAt(0),ht="_".charCodeAt(0);class ut{matches(t,e){const s=this.match(t);return e?!s:s}}const ct=[new class extends ut{match(t){return t==ht||t>=nt&&t<=rt||t>=it&&t<=ot||t>=at&&t<=lt}reString(t){return t?"\\W":"\\w"}},new class extends ut{match(t){return t>=nt&&t<=rt}reString(t){return t?"\\D":"\\d"}},new class extends ut{match(t){if(t>=8192&&t<=8202)return!0;for(let e=0;e<14;e++)if(" \f\n\r\t\v \u2028\u2029 \ufeff".charCodeAt(e)==t)return!0;return!1}reString(t){return t?"\\S":"\\s"}}];var dt,ft,gt,mt,pt;!function(t){t[t.gc=0]="gc",t[t.General_Category=0]="General_Category",t[t.sc=1]="sc",t[t.Script=1]="Script",t[t.scx=2]="scx",t[t.Script_Extension=2]="Script_Extension",t[t.Any=3]="Any",t[t.ASCII=4]="ASCII",t[t.AHex=5]="AHex",t[t.ASCII_Hex_Digit=5]="ASCII_Hex_Digit",t[t.Alpha=6]="Alpha",t[t.Alphabetic=6]="Alphabetic",t[t.Bidi_M=7]="Bidi_M",t[t.Bidi_Mirrored=7]="Bidi_Mirrored",t[t.Bidi_C=8]="Bidi_C",t[t.Bidi_Control=8]="Bidi_Control",t[t.CI=9]="CI",t[t.Case_Ignorable=9]="Case_Ignorable",t[t.Cased=10]="Cased",t[t.CWCF=11]="CWCF",t[t.Changes_When_Casefolded=11]="Changes_When_Casefolded",t[t.CWCM=12]="CWCM",t[t.Changes_When_Casemapped=12]="Changes_When_Casemapped",t[t.CWL=13]="CWL",t[t.Changes_When_Lowercased=13]="Changes_When_Lowercased",t[t.CWKCF=14]="CWKCF",t[t.Changes_When_NFKC_Casefolded=14]="Changes_When_NFKC_Casefolded",t[t.CWT=15]="CWT",t[t.Changes_When_Titlecased=15]="Changes_When_Titlecased",t[t.CWU=16]="CWU",t[t.Changes_When_Uppercased=16]="Changes_When_Uppercased",t[t.Dash=17]="Dash",t[t.DI=18]="DI",t[t.Default_Ignorable_Code_Point=18]="Default_Ignorable_Code_Point",t[t.Dep=19]="Dep",t[t.Deprecated=19]="Deprecated",t[t.Dia=20]="Dia",t[t.Diacritic=20]="Diacritic",t[t.Emoji=21]="Emoji",t[t.Emoji_Component=22]="Emoji_Component",t[t.Emoji_Modifier=23]="Emoji_Modifier",t[t.Emoji_Modifier_Base=24]="Emoji_Modifier_Base",t[t.Emoji_Presentation=25]="Emoji_Presentation",t[t.Ext=26]="Ext",t[t.Extender=26]="Extender",t[t.Gr_Base=27]="Gr_Base",t[t.Grapheme_Base=27]="Grapheme_Base",t[t.Gr_Ext=28]="Gr_Ext",t[t.Grapheme_Extend=28]="Grapheme_Extend",t[t.Hex=29]="Hex",t[t.Hex_Digit=29]="Hex_Digit",t[t.IDSB=30]="IDSB",t[t.IDS_Binary_Operator=30]="IDS_Binary_Operator",t[t.IDST=31]="IDST",t[t.IDS_Trinary_Operator=31]="IDS_Trinary_Operator",t[t.IDC=32]="IDC",t[t.ID_Continue=32]="ID_Continue",t[t.IDS=33]="IDS",t[t.ID_Start=33]="ID_Start",t[t.Ideo=34]="Ideo",t[t.Ideographic=34]="Ideographic",t[t.Join_C=35]="Join_C",t[t.Join_Control=35]="Join_Control",t[t.LOE=36]="LOE",t[t.Logical_Order_Exception=36]="Logical_Order_Exception",t[t.Lower=37]="Lower",t[t.Lowercase=37]="Lowercase",t[t.Math=38]="Math",t[t.NChar=39]="NChar",t[t.Noncharacter_Code_Point=39]="Noncharacter_Code_Point",t[t.Pat_Syn=40]="Pat_Syn",t[t.Pattern_Syntax=40]="Pattern_Syntax",t[t.Pat_WS=41]="Pat_WS",t[t.Pattern_White_Space=41]="Pattern_White_Space",t[t.QMark=42]="QMark",t[t.Quotation_Mark=42]="Quotation_Mark",t[t.Radical=43]="Radical",t[t.RI=44]="RI",t[t.Regional_Indicator=44]="Regional_Indicator",t[t.STerm=45]="STerm",t[t.Sentence_Terminal=45]="Sentence_Terminal",t[t.SD=46]="SD",t[t.Soft_Dotted=46]="Soft_Dotted",t[t.Term=47]="Term",t[t.Terminal_Punctuation=47]="Terminal_Punctuation",t[t.UIdeo=48]="UIdeo",t[t.Unified_Ideograph=48]="Unified_Ideograph",t[t.Upper=49]="Upper",t[t.Uppercase=49]="Uppercase",t[t.VS=50]="VS",t[t.Variation_Selector=50]="Variation_Selector",t[t.space=51]="space",t[t.White_Space=51]="White_Space",t[t.XIDC=52]="XIDC",t[t.XID_Continue=52]="XID_Continue",t[t.XIDS=53]="XIDS",t[t.XID_Start=53]="XID_Start"}(dt||(dt={})),function(t){t[t.LC=0]="LC",t[t.Cased_Letter=0]="Cased_Letter",t[t.Pe=1]="Pe",t[t.Close_Punctuation=1]="Close_Punctuation",t[t.Pc=2]="Pc",t[t.Connector_Punctuation=2]="Connector_Punctuation",t[t.Cc=3]="Cc",t[t.cntrl=3]="cntrl",t[t.Control=3]="Control",t[t.Sc=4]="Sc",t[t.Currency_Symbol=4]="Currency_Symbol",t[t.Pd=5]="Pd",t[t.Dash_Punctuation=5]="Dash_Punctuation",t[t.Nd=6]="Nd",t[t.digit=6]="digit",t[t.Decimal_Number=6]="Decimal_Number",t[t.Me=7]="Me",t[t.Enclosing_Mark=7]="Enclosing_Mark",t[t.Pf=8]="Pf",t[t.Final_Punctuation=8]="Final_Punctuation",t[t.Cf=9]="Cf",t[t.Format=9]="Format",t[t.Pi=10]="Pi",t[t.Initial_Punctuation=10]="Initial_Punctuation",t[t.L=11]="L",t[t.Letter=11]="Letter",t[t.Nl=12]="Nl",t[t.Letter_Number=12]="Letter_Number",t[t.Zl=13]="Zl",t[t.Line_Separator=13]="Line_Separator",t[t.Ll=14]="Ll",t[t.Lowercase_Letter=14]="Lowercase_Letter",t[t.M=15]="M",t[t.Combining_Mark=15]="Combining_Mark",t[t.Mark=16]="Mark",t[t.Sm=17]="Sm",t[t.Math_Symbol=17]="Math_Symbol",t[t.Lm=18]="Lm",t[t.Modifier_Letter=18]="Modifier_Letter",t[t.Sk=19]="Sk",t[t.Modifier_Symbol=19]="Modifier_Symbol",t[t.Mn=20]="Mn",t[t.Nonspacing_Mark=20]="Nonspacing_Mark",t[t.N=21]="N",t[t.Number=21]="Number",t[t.Ps=22]="Ps",t[t.Open_Punctuation=22]="Open_Punctuation",t[t.C=23]="C",t[t.Other=23]="Other",t[t.Lo=24]="Lo",t[t.Other_Letter=24]="Other_Letter",t[t.No=25]="No",t[t.Other_Number=25]="Other_Number",t[t.Po=26]="Po",t[t.Other_Punctuation=26]="Other_Punctuation",t[t.So=27]="So",t[t.Other_Symbol=27]="Other_Symbol",t[t.Zp=28]="Zp",t[t.Paragraph_Separator=28]="Paragraph_Separator",t[t.Co=29]="Co",t[t.Private_Use=29]="Private_Use",t[t.P=30]="P",t[t.punct=30]="punct",t[t.Punctuation=30]="Punctuation",t[t.Z=31]="Z",t[t.Separator=31]="Separator",t[t.Zs=32]="Zs",t[t.Space_Separator=32]="Space_Separator",t[t.Mc=33]="Mc",t[t.Spacing_Mark=33]="Spacing_Mark",t[t.Cs=34]="Cs",t[t.Surrogate=34]="Surrogate",t[t.S=35]="S",t[t.Symbol=35]="Symbol",t[t.Lt=36]="Lt",t[t.Titlecase_Letter=36]="Titlecase_Letter",t[t.Cn=37]="Cn",t[t.Unassigned=37]="Unassigned",t[t.Lu=38]="Lu",t[t.Uppercase_Letter=38]="Uppercase_Letter"}(ft||(ft={})),function(t){t[t.START_OF_INPUT=0]="START_OF_INPUT",t[t.END_OF_INPUT=1]="END_OF_INPUT",t[t.START_OF_WORD=2]="START_OF_WORD",t[t.END_OF_WORD=3]="END_OF_WORD",t[t.UNION=4]="UNION",t[t.CAT=5]="CAT",t[t.VAR=6]="VAR",t[t.BACK_NAMED_REF=7]="BACK_NAMED_REF",t[t.BACK_NUM_REF=8]="BACK_NUM_REF",t[t.QUANT=9]="QUANT",t[t.LOOK_AHEAD=10]="LOOK_AHEAD",t[t.LOOK_BACK=11]="LOOK_BACK",t[t.CHAR=12]="CHAR"}(gt||(gt={}));class bt{constructor(){this.parent=null,this.reString=null,this.groupIndex=-1,this.groupName=null,this.groupIsSilent=!1,this.ignoreCase=null,this.dotAll=null,this.multiline=null}setOptions(t){return"dotAll"in t&&(this.dotAll=t.dotAll),"ignoreCase"in t&&(this.ignoreCase=t.ignoreCase),"groupIndex"in t&&(this.groupIndex=t.groupIndex),"multiline"in t&&(this.multiline=t.multiline),this}debugValue(){const t={};return this.dotAll&&(t.dotAll=!0),this.ignoreCase&&(t.ignoreCase=!0),this.multiline&&(t.multiline=!0),this.groupIndex>=0&&(t.groupIndex=this.groupIndex),t}get isVariable(){return!1}get toString(){return null==this.reString&&(this.reString=this.evalREString()),this.reString}get modifiers(){let t="";return this.dotAll&&(t+="d"),this.ignoreCase&&(t+="i"),this.multiline&&(t+="m"),this.groupIndex>=0&&(t+="g:"+this.groupIndex),0==t.length?t:"<"+t+">"}}class yt extends bt{constructor(){super(...arguments),this.tag=gt.START_OF_INPUT}debugValue(){return"^"}reverse(){return this}evalREString(){return"^"}}class St extends bt{constructor(){super(...arguments),this.tag=gt.END_OF_INPUT}debugValue(){return"$"}evalREString(){return"$"}reverse(){return this}}class Et extends bt{constructor(t,e,s=!1){super(),this.expr=t,this.cond=e,this.negate=s}}class Ct extends Et{constructor(){super(...arguments),this.tag=gt.LOOK_AHEAD}evalREString(){return`${this.expr.toString}(?${this.negate?"!":"="}${this.cond.toString})`}debugValue(){return["LookAhead",{...super.debugValue(),negate:this.negate,expr:this.expr.debugValue(),cond:this.cond.debugValue()}]}reverse(){return new wt(this.expr.reverse(),this.cond.reverse(),this.negate)}}class wt extends Et{constructor(){super(...arguments),this.tag=gt.LOOK_BACK}evalREString(){return`(?<${this.negate?"!":"="}${this.cond.toString})${this.expr.toString}`}debugValue(){return["LookBack",{...super.debugValue(),negate:this.negate,expr:this.expr.debugValue(),cond:this.cond.debugValue()}]}reverse(){return new Ct(this.expr.reverse(),this.cond.reverse(),this.negate)}}class vt extends bt{constructor(t,e=1,s=1,n=!0){super(),this.expr=t,this.minCount=e,this.maxCount=s,this.greedy=n,this.tag=gt.QUANT}get isUnlimited(){return this.maxCount<0||this.maxCount==l}get isVariable(){return this.minCount!=this.maxCount||!this.expr.isVariable}reverse(){return new vt(this.expr.reverse(),this.minCount,this.maxCount,this.greedy)}evalREString(){let t="*";return 1==this.minCount&&this.isUnlimited?t="+":0==this.minCount&&this.isUnlimited?t="*":0==this.minCount&&1==this.maxCount?t="?":1==this.minCount&&1==this.maxCount||(t=this.minCount==this.maxCount?`{${this.minCount}}`:`{${this.minCount},${this.isUnlimited?"":this.maxCount}}`),`${this.expr.toString}${t}`}debugValue(){let t="*";return 1==this.minCount&&this.isUnlimited?t=this.greedy?"+?":"+":0==this.minCount&&this.isUnlimited?t=this.greedy?"*?":"*":0==this.minCount&&1==this.maxCount?t=this.greedy?"??":"?":1==this.minCount&&1==this.maxCount||(t=this.minCount==this.maxCount?`{${this.minCount}}`+(this.greedy?"?":""):`{${this.minCount},${this.maxCount}}`+(this.greedy?"?":"")),[t,super.debugValue(),this.expr.debugValue()]}}class _t extends bt{constructor(...t){super(),this.tag=gt.CAT,this.children=[];for(const e of t)this.add(e)}get isVariable(){for(const t of this.children)if(t.isVariable)return!0;return!1}evalREString(){const t=this.children.map(t=>t.toString).join("");return this.children.length>1?"("+t+")":t}reverse(){const t=this.children.map(t=>t.reverse());return t.reverse(),new _t(...t)}add(t){if(t.tag!=gt.CAT||t.groupIndex>=0)this.children.push(t);else for(const e of t.children)this.add(e);return this}debugValue(){return["Cat",{...super.debugValue()},this.children.map(t=>t.debugValue())]}}class xt extends bt{constructor(...t){super(),this.tag=gt.UNION,this.options=[];for(const e of t)this.add(e)}get isVariable(){for(const t of this.options)if(t.isVariable)return!0;return!1}evalREString(){const t=this.options.map(t=>t.toString).join("|");return this.options.length>1?"("+t+")":t}reverse(){const t=this.options.map(t=>t.reverse());return new xt(...t)}add(t){if(t.tag!=gt.UNION||t.groupIndex>=0)this.options.push(t);else for(const e of t.options)this.add(e);return this}debugValue(){return["Union",{...super.debugValue()},this.options.map(t=>t.debugValue())]}}!function(t){t[t.AnyChar=1]="AnyChar",t[t.SingleChar=2]="SingleChar",t[t.CharRange=3]="CharRange",t[t.PropertyEscape=4]="PropertyEscape",t[t.CharClass=5]="CharClass",t[t.Union=6]="Union",t[t.Intersection=7]="Intersection"}(mt||(mt={}));class Nt extends bt{constructor(t,e=!1){super(),this.op=t,this.neg=e,this.tag=gt.CHAR}match(t){const e=this.matchChar(t);return e&&!this.neg||this.neg&&!e}reverse(){return this}debugValue(){return this.toString+this.modifiers}}class At extends Nt{constructor(t,e=!1,s=[]){super(t,e),this.op=t,this.neg=e,this.args=s}static Any(t=!1){return new At(mt.AnyChar,t)}static Class(t,e=!1){return new At(mt.CharClass,e,[t])}static Single(t,e=!1){return"string"==typeof t&&(t=t.charCodeAt(0)),new At(mt.SingleChar,e,[t])}static PropertyEscape(t,e,s=!1){return"string"==typeof t&&(t=function(t){if(!((t=t.trim())in dt))throw new SyntaxError("Invalid property name: "+t);return dt[t]}(t)),"string"==typeof e&&(e=function(t){if(!((t=t.trim())in ft))throw new SyntaxError("Invalid property value: "+t);return ft[t]}(e)),new At(mt.PropertyEscape,s,[t,e])}matchChar(t){const e=this.args;switch(this.op){case mt.SingleChar:return t==this.args[0];case mt.CharClass:return ct[e[0]].matches(t,!1);case mt.PropertyEscape:throw new Error("Property Escape Matching - TBD");default:throw new Error("Custom Chars - TBD i: "+this.op)}return!1}compareTo(t){if(this.op!=t.op)return this.op-t.op;for(let e=0;e<this.args.length&&e<t.args.length;e++)if(this.args[e]!=t.args[e])return this.args[e]-t.args[e];return this.args.length-t.args.length}evalREString(){return this.op==mt.AnyChar?".":this.op==mt.SingleChar?(t=this.args[0],String.fromCharCode(t).replace("\n","\\n").replace("\0","\\0").replace("\r","\\r").replace("\t","\\t").replace("\f","\\f").replace("\b","\\b")):this.op==mt.CharClass?ct[this.args[0]].reString(this.neg):this.op==mt.PropertyEscape?this.neg?"\\P{":"\\p{}":"Custom "+this.args.join(" ");var t}}class Tt extends Nt{constructor(t,e=!1,s=[]){super(t,e),this.op=t,this.neg=e,this.chars=s}compareTo(t){if(this.op!=t.op)return this.op-t.op;for(let e=0;e<this.chars.length&&e<t.chars.length;e++){const s=this.chars[e].compareTo(t.chars[e]);if(0!=s)return s}return this.chars.length-t.chars.length}matchChar(t){const e=this.chars;switch(this.op){case mt.CharRange:return t>=e[0].args[0]&&t<=e[1].args[0];case mt.Union:for(let s=0;s<e.length;s++)if(e[s].match(t))return!0;return!1;case mt.Intersection:for(let s=0;s<e.length;s++)if(!e[s].match(t))return!1;return!0;default:throw new Error("Custom CharGroup - TBD i: "+this.op)}return!1}evalREString(){const t=this.chars.map(t=>t.debugValue()).join("");return this.op==mt.CharRange?`${this.chars[0].toString}-${this.chars[1].toString}`:this.op==mt.Union||this.op==mt.Intersection?t.length>1?(this.neg?"[^":"[")+t+"]":t:"Custom "+this.chars.join(" ")}static Range(t,e,s=!1){return new Tt(mt.CharRange,s,[t,e])}static Union(t=!1,e){return new Tt(mt.Union,t,e)}static Intersection(t=!1,e){return new Tt(mt.Intersection,t,e)}}class It extends bt{constructor(t,e=!1){super(),this.name=t,this.reversed=e,this.tag=gt.VAR}reverse(){return new It(this.name,!this.reversed)}evalREString(){return"<"+this.name+">"}debugValue(){return["V:"+this.name,{...super.debugValue()}]}}class Ot extends bt{constructor(t,e=!1){super(),this.name=t,this.reversed=e,this.tag=gt.BACK_NAMED_REF}reverse(){return new Ot(this.name,!this.reversed)}evalREString(){return"\\k<"+this.name+">"}debugValue(){return{...super.debugValue,BackRef:this.name}}}class Rt extends bt{constructor(t,e=!1){super(),this.num=t,this.reversed=e,this.tag=gt.BACK_NUM_REF}reverse(){return new Rt(this.num,!this.reversed)}evalREString(){return"\\"+this.num}debugValue(){return"\\"+this.num}}class kt{constructor(t,e){this.expr=t,this.skip=!1,e=e||{},this.tag=e.tag||null,0==e.priority?this.priority=0:this.priority=e.priority||10,0==e.matchIndex?this.matchIndex=0:this.matchIndex=e.matchIndex||-1,this.skip=e.skip||!1,this.activeStates=e.activeStates||null}stateCanActivate(t){return null==this.activeStates||0==this.activeStates.size||this.activeStates.has("*")||this.activeStates.has(t)}get needsSpecificStates(){return null!=this.activeStates&&this.activeStates.size>0&&!this.activeStates.has("*")}}function Lt(t){return"\r"==t||"\n"==t||"\u2028"==t||"\u2029"==t}class Mt{constructor(t=10,e=-1,s=-1,n=-1){this.priority=t,this.matchIndex=e,this.start=s,this.end=n,this.groups=[],this.positions=[]}}!function(t){t[t.Any=0]="Any",t[t.AnyNonNL=1]="AnyNonNL",t[t.Char=2]="Char",t[t.CIChar=3]="CIChar",t[t.Match=4]="Match",t[t.Noop=5]="Noop",t[t.Save=6]="Save",t[t.Split=7]="Split",t[t.Jump=8]="Jump",t[t.Begin=9]="Begin",t[t.RBegin=10]="RBegin",t[t.End=11]="End",t[t.StartingChar=12]="StartingChar",t[t.EndingChar=13]="EndingChar",t[t.MLStartingChar=14]="MLStartingChar",t[t.MLEndingChar=15]="MLEndingChar",t[t.StartOfWord=16]="StartOfWord",t[t.EndOfWord=17]="EndOfWord",t[t.GroupStart=18]="GroupStart",t[t.GroupEnd=19]="GroupEnd",t[t.EnsureState=20]="EnsureState"}(pt||(pt={}));class Pt{constructor(t="INITIAL",e=!0){this.startCondition=t,this.scIsInclusive=e,this.instrs=[],this.stateMapping=new Map,this.registerState("INITIAL"),this.registerState(t)}get length(){return this.instrs.length}registerState(t){return this.stateMapping.has(t)||this.stateMapping.set(t,this.stateMapping.size),this.stateMapping.get(t)||-1}add(t,e=null,...s){const n=new Bt(t,e).add(...s);return n.offset=this.instrs.length,this.instrs.push(n),n}static with(t){const e=new Pt;return t(e),e}debugValue(t=Ut){return t?this.instrs.map((e,s)=>e.comment.trim().length>0?`L${s}: ${t(e)} # ${e.comment}`:`L${s}: ${t(e)}`):this.instrs.map((t,e)=>`L${e}: ${t.debugValue}`)}}class Bt{constructor(t,e=null){this.opcode=t,this.char=e,this.offset=0,this.comment="",this.args=[],this.char=e}add(...t){return this.args.push(...t),this}get debugValue(){let t=this.comment.trim();return t.length>0&&(t=" # "+t),`${this.opcode} ${this.args.join(" ")} ${this.char||""} ${t}`}}class $t{constructor(t=0,e=0){this.offset=t,this.gen=e,this.parentId=-1,this.id=0,this.priority=0,this.groups=[],this.positions=[],this.registers={}}regIncr(t){if(!(t in this.registers))throw new Error(`Register at offset ${t} is invalid`);this.registers[t]++}regAcquire(t){if(t in this.registers)throw new Error(`Register at offset ${t} already acquired. Release it first`);this.registers[t]=0}regRelease(t){if(!(t in this.registers))throw new Error(`Register at offset ${t} is invalid`);delete this.registers[t]}regValue(t){if(!(t in this.registers))throw new Error(`Register at offset ${t} is invalid`);return this.registers[t]}}class Dt{getState(){return this.currState}setState(t){this.currState=t}constructor(t,e=0,s=-1,n=!0,r={}){this.prog=t,this.start=e,this.end=s,this.forward=n,this.threadCounter=0,this.currThreads=[],this.nextThreads=[],this.startPos=0,this.currState=0,this.gen=0,this.genForOffset={},s<0&&(s=t.length-1),this.end=s}savePosition(t,e,s){for(;t.positions.length<=e;)t.positions.push(-1);t.positions[e]=s}jumpBy(t,e=1){return this.jumpTo(t,t.offset+e)}jumpTo(t,e){const s=new $t(e,this.gen);return s.id=t.id,s.parentId=t.parentId,s.priority=t.priority,s.positions=t.positions,s.groups=t.groups,s.registers=t.registers,s}forkTo(t,e){const s=new $t(e,this.gen);return s.id=++this.threadCounter,s.parentId=t.id,s.priority=t.priority,s.positions=[...t.positions],s.groups=[...t.groups],s.registers={...t.registers},s}startGroup(t,e,s){const n=this.forkTo(t,t.offset+1);return n.groups.push([e,s]),n}endGroup(t,e,s){const n=this.forkTo(t,t.offset+1);return n.groups.push([-e,s]),n}addThread(t,e,s,n=0){if(t.offset<this.start||t.offset>this.end||this.genForOffset[t.offset-this.start]==this.gen)return;this.genForOffset[t.offset-this.start]=this.gen;const r=this.prog.instrs[t.offset];let i,o,a;const l=r.opcode;switch(l){case pt.Jump:a=this.jumpTo(t,r.args[0]),this.addThread(a,e,s,n);break;case pt.Split:for(let i=0;i<r.args.length;i++){const o=r.args[i],a=0==i?this.jumpTo(t,o):this.forkTo(t,o);this.addThread(a,e,s,n)}break;case pt.Save:a=this.jumpTo(t,t.offset+1),this.savePosition(a,r.args[0],s.index+n),this.tracer&&this.tracer.threadQueued(t,s.index+n),this.addThread(a,e,s,n);break;case pt.GroupStart:a=this.startGroup(t,r.args[0],s.index+n),this.tracer&&this.tracer.threadQueued(t,s.index+n),this.addThread(a,e,s,n);break;case pt.GroupEnd:a=this.endGroup(t,r.args[0],s.index+n),this.tracer&&this.tracer.threadQueued(t,s.index+n),this.addThread(a,e,s,n);break;case pt.StartingChar:case pt.MLStartingChar:o=this.prevCh(s),(0==s.index||l==pt.MLStartingChar&&Lt(o))&&this.addThread(this.jumpBy(t,1),e,s,n);break;case pt.EndingChar:case pt.MLEndingChar:i=this.nextCh(s),(""==i||l==pt.MLEndingChar&&Lt(i))&&this.addThread(this.jumpBy(t,1),e,s,n);break;case pt.StartOfWord:case pt.EndOfWord:break;case pt.RBegin:{const[i,o,a]=r.args,l=2*(1+i),h=t.positions[l],[u,c]=this.recurseMatch(s,h-1,r.offset+1,a,!1,1==o);u&&this.addThread(this.jumpTo(t,a+1),e,s,n)}break;case pt.Begin:const[h,u,c]=r.args;if(1==h)this.tracer&&this.tracer.threadQueued(t,s.index),e.push(t);else{const[i,o]=this.recurseMatch(s,s.index+1,r.offset+1,c,!0,1==u);i&&this.addThread(this.jumpTo(t,c+1),e,s,n)}break;case pt.EnsureState:const d=r.args;for(const r of d)if(this.currState==r){this.addThread(this.jumpBy(t,1),e,s,n);break}break;default:this.tracer&&this.tracer.threadQueued(t,s.index),e.push(t)}}matchCurrPos(t,e,s=!1){return s?e.match(t.currChCodeLower)||e.match(t.currChCodeUpper):e.match(t.currChCode)}hasMore(t){return this.forward?t.hasMore:t.index>=0}nextCh(t){const e=t.index+(this.forward?1:-1);return t.charAt(e)}prevCh(t){return t.charAt(t.index-(this.forward?1:-1))}match(t){if(this.end<this.start)return null;this.startMatching(t);let e=null;for(;this.currThreads.length>0;)e=this.stepChar(t,e);return null!=e&&(t.index=e.end),e}recurseMatch(t,e,s,n,r=!0,i=!1){const o=t.index;if(!t.canAdvance(r?1:-1))return[i,-1];t.index=e;const a=new Dt(this.prog,s,n,r).match(t),l=t.index;return t.index=o,[null!=a&&!i||null==a&&i,l]}startMatching(t){this.currThreads=[],this.nextThreads=[],this.gen++,this.addThread(new $t(this.start,this.gen),this.currThreads,t),this.startPos=t.index}stepChar(t,e=null){this.gen++;for(let s=0;s<this.currThreads.length;s++){const n=this.currThreads[s],r=this.stepThread(t,n);if(null!=r&&(null==e||r.priority>e.priority||r.priority==e.priority&&r.end>e.end)){e=r;break}}return this.hasMore(t)&&t.advance(this.forward?1:-1),this.currThreads=this.nextThreads,this.nextThreads=[],e}stepThread(t,e){this.tracer&&this.tracer.threadStepped(e,t.index,this.gen);let s=null;const n=this.prog.instrs[e.offset],r=n.opcode,i=(n.args,this.forward?1:-1);let o=!1;switch(r){case pt.RBegin:throw new Error("Invalid state. Reverse matches must be handled in addThread");case pt.Begin:const[i,l,h]=n.args;a(1==i,"Plain lookahead cannot be here");const[u,c]=this.recurseMatch(t,t.index,n.offset+1,h,!0,1==l);u&&this.addThread(this.jumpTo(e,h+1),this.nextThreads,t);break;case pt.End:const d=new Mt(-1,-1,this.startPos,t.index);return d.groups=e.groups,d.positions=e.positions,d;case pt.Match:if(t.index>this.startPos){const r=n.args[0],i=n.args[1];s=new Mt,s.start=this.startPos,s.end=t.index,s.priority=r,s.matchIndex=i,s.groups=e.groups,s.positions=e.positions}break;case pt.Char:case pt.CIChar:this.hasMore(t)&&(o=this.matchCurrPos(t,n.char,r==pt.CIChar));break;case pt.AnyNonNL:case pt.Any:this.hasMore(t)&&(o=r==pt.Any||!Lt(t.currCh))}return o&&this.addThread(this.jumpBy(e,1),this.nextThreads,t,i),s}}function Ut(t){switch(t.opcode){case pt.Match:return`Match ${t.args[0]} ${t.args[1]}`;case pt.Char:case pt.CIChar:{let e=`${pt[t.opcode].toString()} `;return e+=`${t.char.debugValue()}`,e}case pt.Any:return".";case pt.AnyNonNL:return"NL.";case pt.StartingChar:return"^";case pt.MLStartingChar:return"NL^";case pt.EndingChar:return"$NL";case pt.MLEndingChar:return"$NL_MultiLine";case pt.Save:return`Save ${t.args[0]}`;case pt.GroupStart:return`GroupStart ${t.args[0]}`;case pt.GroupEnd:return`GroupEnd ${t.args[0]}`;case pt.Split:return`Split ${t.args.join(", ")}`;case pt.Jump:return`Jump ${t.args[0]}`;case pt.Begin:return`Begin ${t.args.join(" ")}`;case pt.RBegin:return`RBegin ${t.args.join(" ")}`;case pt.End:return`End ${t.args.join(" ")}`;case pt.EnsureState:return`EnsureState ${t.args.join(" ")}`;default:throw new Error("Invalid Opcode: "+t.opcode)}}class Ft{constructor(t,e=null){this.regexResolver=t,this.listener=e,this.emitGroups=!1,this.emitPosition=!0}compile(t){const e=new Pt,s=t.length<=1?new Bt(pt.Split):e.add(pt.Split,null);return t.forEach((t,n)=>{s.add(e.instrs.length);const r=null!=t.expr.ignoreCase&&t.expr.ignoreCase,i=null==t.expr.dotAll||t.expr.dotAll,o=null==t.expr.multiline||t.expr.multiline;if(t.needsSpecificStates&&null!=t.activeStates){const s=e.add(pt.EnsureState,null);t.activeStates.forEach(t=>{const n=e.registerState(t);s.add(n)})}this.compileExpr(t.expr,e,r,i,o),e.add(pt.Match,null).add(t.priority,t.matchIndex>=0?t.matchIndex:n)}),e}compileExpr(t,e,s,n,r){const i=e.length,o=e.length;if(t.groupIndex>=0&&(this.emitPosition&&e.add(pt.Save).add(2*(1+t.groupIndex)),this.emitGroups&&e.add(pt.GroupStart).add(1+t.groupIndex)),t.tag==gt.CHAR)this.compileChar(t,e,s,n,r);else if(t.tag==gt.START_OF_INPUT){const s=null==t.multiline?r:t.multiline;e.add(s?pt.MLStartingChar:pt.StartingChar)}else if(t.tag==gt.END_OF_INPUT){const s=null==t.multiline?r:t.multiline;e.add(s?pt.MLEndingChar:pt.EndingChar)}else if(t.tag==gt.START_OF_WORD)e.add(pt.StartOfWord);else if(t.tag==gt.END_OF_WORD)e.add(pt.EndOfWord);else if(t.tag==gt.CAT)this.compileCat(t,e,s,n,r);else if(t.tag==gt.UNION)this.compileUnion(t,e,s,n,r);else if(t.tag==gt.QUANT)this.compileQuant(t,e,s,n,r);else if(t.tag==gt.VAR)this.compileVar(t,e,s,n,r);else if(t.tag==gt.BACK_NAMED_REF)this.compileBackNamedRef(t,e,s,n,r);else if(t.tag==gt.BACK_NUM_REF)this.compileBackNumRef(t,e,s,n,r);else if(t.tag==gt.LOOK_AHEAD)this.compileLookAhead(t,e,s,n,r);else{if(t.tag!=gt.LOOK_BACK)throw new Error("Regex Type not yet supported: "+t.tag);this.compileLookBack(t,e,s,n,r)}return t.groupIndex>=0&&(this.emitGroups&&e.add(pt.GroupEnd).add(1+t.groupIndex),this.emitPosition&&e.add(pt.Save).add(2*(1+t.groupIndex)+1)),this.listener&&e.length>o&&this.listener(t,e,o,e.length-o),e.length-i}compileChar(t,e,s,n,r){t.op==mt.AnyChar?e.add(n?pt.Any:pt.AnyNonNL):e.add(s?pt.CIChar:pt.Char).char=t}compileCat(t,e,s,n,r){for(const i of t.children)this.compileExpr(i,e,s,n,r)}compileBackNumRef(t,e,s,n,r){throw new Error("BackNumRef Not Implemented")}compileBackNamedRef(t,e,s,n,r){throw new Error("BackNameRef Not Implemented")}compileVar(t,e,s,n,r){const i=t.name.trim(),o=this.regexResolver?this.regexResolver(i):null;if(null==o)throw new Error(`Cannot find expression: ${i}`);this.compileExpr(o,e,s,n,r)}compileUnion(t,e,s,n,r){const i=e.add(pt.Split),o=[];for(let a=0;a<t.options.length;a++)i.add(e.length),this.compileExpr(t.options[a],e,s,n,r),a<t.options.length-1&&o.push(e.add(pt.Jump));for(const t of o)t.add(e.length)}compileQuant(t,e,s,n,r){if(0==t.minCount&&t.maxCount==l)this.compileAtleast0(t.expr,e,t.greedy,s,n,r);else if(1==t.minCount&&t.maxCount==l)this.compileAtleast1(t.expr,e,t.greedy,s,n,r);else if(0==t.minCount&&1==t.maxCount)this.compileOptional(t.expr,e,t.greedy,s,n,r);else{for(let i=0;i<t.minCount;i++)this.compileExpr(t.expr,e,s,n,r);if(t.isUnlimited)this.compileAtleast0(t.expr,e,t.greedy,s,n,r);else for(let i=t.minCount;i<t.maxCount;i++)this.compileOptional(t.expr,e,t.greedy,s,n,r)}}compileAtleast1(t,e,s=!0,n,r,i){const o=e.length;this.compileExpr(t,e,n,r,i);const a=e.add(pt.Split),l=e.length;s?a.add(o,l):a.add(l,o)}compileAtleast0(t,e,s,n,r,i){const o=e.add(pt.Split),a=o.offset,l=e.length;this.compileExpr(t,e,n,r,i),e.add(pt.Jump).add(a);const h=e.length;s?o.add(l,h):o.add(h,l)}compileOptional(t,e,s,n,r,i){const o=e.add(pt.Split),a=e.length;this.compileExpr(t,e,n,r,i);const l=e.length;s?o.add(a,l):o.add(l,a)}compileLookAhead(t,e,s,n,r){this.compileExpr(t.expr,e,s,n,r);const i=e.add(pt.Begin).add(0,t.negate?1:0);this.compileExpr(t.cond,e,s,n,r);const o=e.add(pt.End).add(i.offset);i.add(o.offset)}compileLookBack(t,e,s,n,r){this.compileExpr(t.expr,e,s,n,r),a(t.expr.groupIndex>=0,"LookBack Assertion requires expression to have a group Index");const i=e.add(pt.RBegin).add(t.expr.groupIndex,t.negate?1:0);this.compileExpr(t.cond.reverse(),e,s,n,r);const o=e.add(pt.End).add(i.offset);i.add(o.offset)}}class jt extends Error{constructor(t,e,s,n,r=null){super(t),this.offset=e,this.length=s,this.type=n,this.value=r,this.name="TokenizerError",Object.setPrototypeOf(this,new.target.prototype)}}class Vt extends Error{constructor(t,...e){super(`Found Token: ${t?.tag||"EOF"} (${t?.value||""}), Expected: ${e.join(", ")}`),this.foundToken=t,this.name="UnexpectedTokenError",this.expectedTokens=e}}class Gt{constructor(t=!0){this.forward=t,this.index=0}advance(t=1){const e=this.forward?this.index+t:this.index-t;return this.index=e,!0}canAdvance(t=1){const e=this.forward?this.index+t:this.index-t;return this.hasIndex(e)}get hasMore(){const t=this.forward?this.index:this.index-1;return this.hasIndex(t)}get currCh(){return this.charAt(this.index)}get prevCh(){return this.charAt(this.index-(this.forward?1:-1))}get nextCh(){const t=this.index+(this.forward?1:-1);return this.charAt(t)}get currChCode(){return this.hasMore?this.currCh.charCodeAt(0):-1}get currChCodeLower(){return this.hasMore?this.currCh.toLowerCase().charCodeAt(0):-1}get currChCodeUpper(){return this.hasMore?this.currCh.toUpperCase().charCodeAt(0):-1}charCodeAt(t){return this.hasIndex(t)?this.charAt(t).charCodeAt(0):-1}charCodeAtLower(t){return this.hasIndex(t)?this.charAt(t).toLowerCase().charCodeAt(0):-1}charCodeAtUpper(t){return this.hasIndex(t)?this.charAt(t).toUpperCase().charCodeAt(0):-1}}class zt extends Gt{constructor(t,e=!0){super(e),this.forward=e,this._rawInput=t,this.input=[...t]}push(t){this._rawInput+=t,this.input.push(...t)}substring(t,e){return this._rawInput.substring(t,e)}hasIndex(t){return t>=0&&t<this.input.length}charAt(t){return t<0||t>=this.input.length?"":this.input[t]}}class Wt{static advanceAfter(t,e,s=!0){let n=Wt.advanceTo(t,e,s);return n>=0&&(n+=e.length,t.index=n),n}static advanceTo(t,e,s=!0){const n=t.index;for(;t.hasMore;){const n=t.index;if(Wt.matches(t,e)){const e=t.index;t.index=n;let r=0;if(s)for(let s=e-1;s>=0&&"\\"==t.charAt(s);s--)r++;if(r%2==0)return t.index}t.advance(1)}throw t.index=n,new Error(`Unexpected end of input before (${e})`)}static matches(t,e,s=!0){const n=t.index;let r=0,i=!0;for(;r<e.length;r++){if(e[r]!=t.currCh){i=!1;break}t.advance(1)}return s&&i||(t.index=n),i}}class Kt{constructor(t,e,s,n){this.tag=t,this.matchIndex=e,this.start=s,this.end=n,this.id=Kt.idCounter++,this.value=null,this.groups={},this.positions={},this.state=0,this.lookahead=1,this.lookback=1}isOneOf(...t){for(const e of t)if(this.tag==e)return!0;return!1}}Kt.idCounter=0;class Ht{constructor(t,e){this.nextToken=t,this.tokenizerContext=e,this.buffer=[]}next(t){const e=this.peek(t);return null!=e&&this.consume(),e}peek(t,e=0){for(;this.buffer.length<=e;){const e=this.nextToken(t,this.tokenizerContext);if(null==e)return null;this.buffer.push(e)}return this.buffer[e]}match(t,e,s=!1,n=!0,r){const i=this.peek(t);if(null!=i){if(!e(i)){if(s)throw new Vt(i);return null}r&&null!=r&&r(i),n&&this.consume()}else if(s)throw new jt("Unexpected end of input",-1,0,"UnexpectedEndOfInput");return i}consume(){this.buffer.splice(0,1)}consumeIf(t,...e){return this.match(t,t=>t.isOneOf(...e))}expectToken(t,...e){return this.match(t,t=>t.isOneOf(...e),!0,!0)}ensureToken(t,...e){return this.match(t,t=>t.isOneOf(...e),!0,!1)}nextMatches(t,...e){const s=this.peek(t);if(null==s)return null;for(const t of e)if(s.tag==t)return s;return null}}class qt{constructor(){this.value=-1}next(){return++this.value}get current(){return this.value}}function Qt(t){return" "==t||"\t"==t||"\n"==t||"\r"==t}class Jt{constructor(t,e){this.pattern=t,this.counter=new qt,this.unicode=e?.unicode||!1}reduceLeft(t){const e=1==t.length?t[0]:new _t(...t);return t.splice(0),e}throwError(t){throw new SyntaxError(`Error in JS RE '${this.pattern}': ${t}`)}parse(t=0,e=-1){const s=this.pattern,n=[];for(e<0&&(e=s.length-1);t<=e;){const r=s[t];if("."==r)n.push(At.Any()),t++;else if("\\"==r&&s[t+1]>="1"&&s[t+1]<="9"){t++;let r="";for(;t<=e&&s[t]>="0"&&s[t]<="9";)r+=s[t++];const i=parseInt(r);i>this.counter.current+1&&this.throwError("Invalid reference: "+i),n.push(new Rt(i))}else if("\\"==r&&"k"==s[t+1]&&"<"==s[t+2]){let r=t+=3;for(;r<=e&&">"!=s[r];)r++;r>e&&this.throwError("Expected '>' found EOI");const i=s.substring(t,r);""==i.trim()&&this.throwError("Expected name"),n.push(new Ot(i)),t=r+1}else if("["==r){let r=t+1;for(;r<=e&&"]"!=s[r];)"\\"==s[r]&&r++,r++;r>e&&this.throwError("Expected ']' found EOI"),n.push(this.parseCharGroup(t+1,r-1)),t=r+1}else if("^"==r)n.push(new yt),t++;else if("$"==r)n.push(new St),t++;else if("|"==r){if(t+1<=e){const s=this.reduceLeft(n),r=this.parse(t+1,e);return new xt(s,r)}t=e+1}else if("("==r)t=this.parseGroup(n,t,e);else if(")"==r||"]"==r||"}"==r)this.throwError(`Unmatched ${r}. Try using \\${r}`);else if("*"==s[t]||"?"==s[t]||"+"==s[t]||"{"==s[t])t=this.parseQuant(n,t,e);else{const[s,r]=this.parseChar(t,e);n.push(s),t+=r}}return n.length,1==n.length?n[0]:new _t(...n)}parseGroup(t,e,s){let n=e+1,r=0;const i=this.pattern;for(;n<=s&&(")"!=i[n]||r>0);)"("==i[n]?r++:")"==i[n]&&r--,"\\"==i[n]&&n++,n++;if(n>s&&this.throwError("Expected ')' found EOI"),"?"==i[++e])if(":"==i[++e])t.push(this.parse(e+1,n-1));else if("<"==i[e]&&"!"!=i[e+1]&&"="!=i[e+1]){const t=this.counter.next();let r="",o=e+1;for(;o<=s&&">"!=i[o];)r+=i[o],o++;const a=this.parse(o+1,n-1);a.groupIndex=t,r.length>0&&(a.groupName=r)}else{let r=!0;"<"==i[e]&&(e++,r=!1);const o="!"==i[e++],a=this.parse(e,n-1);if(!r){const e=this.parse(n+1,s);return e.groupIndex<0&&(e.groupIndex=this.counter.next(),e.groupIsSilent=!0),t.push(new wt(e,a,o)),s+1}{t.length;const e=new Ct(this.reduceLeft(t),a,o);t.push(e)}}else{const s=this.counter.next();let r=!1;"^"==i[e]&&(r=!0,e++);let o=this.parse(e,n-1);o.groupIndex>=0&&(o=new _t(o)),o.groupIndex=s,t.push(o)}return n+1}parseCharGroup(t,e){const s=[];let n=t,r=!1;const i=this.pattern;for("^"==i[n]&&(r=!0,n++);n<=e;){const[t,r]=this.parseChar(n,e);if(n+=r,n<i.length&&"-"==i[n])if(n++,"]"==i[n]||"["==i[n])s.push(t),s.push(At.Single("-"));else if(n<=e){const[r,i]=this.parseChar(n,e);t.op==mt.SingleChar&&r.op==mt.SingleChar||this.throwError("Char range cannot start or end in a char class"),r.args[0]<t.args[0]&&this.throwError("End cannot be less than start"),s.push(Tt.Range(t,r)),n+=i}else this.throwError("Unterminated char class");else s.push(t)}return Tt.Union(r,s)}parseChar(t=0,e=0){return"\\"==this.pattern[t]?this.parseEscapeChar(t,e):this.parseSingleChar(t,e)}parseSingleChar(t=0,e=0){const s=this.pattern.charCodeAt(t);return[At.Single(s),1]}parsePropertyEscape(t=0,e=0){const s=this.pattern;s[t]+1!="{"&&this.throwError("Invalid property escape");let n=t+=2,r=-1;for(;n<=e&&"}"!=s[n];)"="==s[n]&&(r=n),n++;n>e&&this.throwError("Invalid property escape");const i=s.substring(t,n);let o="General_Category",a=i;if(r>=0){const t=i.split("=");2!=t.length&&this.throwError("Invalid property escape"),o=t[0].trim(),a=t[1].trim()}return[At.PropertyEscape(o,a),2+n+1-t]}parseEscapeChar(t=0,e=0){const s=this.pattern;a("\\"==s[t],"Expected '\\'"),++t>e&&this.throwError("Encounted unexpected end of input after \\");const n=s[t];if(this.unicode&&"p"==n||"P"==n)return this.parsePropertyEscape(t,e);switch(n){case"w":return[At.Class(st.WORD_CHAR),2];case"W":return[At.Class(st.WORD_CHAR,!0),2];case"d":return[At.Class(st.DIGITS),2];case"D":return[At.Class(st.DIGITS,!0),2];case"s":return[At.Class(st.SPACES),2];case"S":return[At.Class(st.SPACES,!0),2];case"0":return s[t+1]>="0"&&s[t+1]<="9"&&this.unicode&&this.throwError("Invalid decimal escape"),[At.Single("\0"),2];case"r":return[At.Single("\r"),2];case"n":return[At.Single("\n"),2];case"f":return[At.Single("\f"),2];case"b":return[At.Single("\b"),2];case"v":return[At.Single("\v"),2];case"t":return[At.Single("\t"),2];case"c":(this.unicode||t>=e)&&this.throwError(`Invalid char sequence at ${t}, ${e}`);const r=s.charCodeAt(t+1)%32;return[At.Single(r),3];case"x":++t>=e&&this.throwError(`Invalid hex sequence at ${t}, ${e}`);const i=s.substring(t,t+2),o=parseInt(i,16);return a(!isNaN(o),`Invalid hex sequence: '${i}'`),[At.Single(o),4];case"u":++t>e-3&&this.throwError(`Invalid unicode sequence at ${t}`);const l=s.substring(t,t+4),h=parseInt(l,16);return isNaN(h)&&this.throwError(`Invalid unicode sequence: '${l}'`),[At.Single(h),6];case"^":case"$":case".":case"*":case"+":case"?":case"\\":case"'":case'"':case"(":case")":case"[":case"]":case"{":case"}":case"|":case"/":return[At.Single(n),2];default:return this.unicode&&this.throwError("Invalid escape character: "+n),[At.Single(n),2]}}parseQuant(t,e,s){const n=this.pattern,r=n[e-1];let i=1,o=1;if("*"==n[e])i=0,o=l;else if("+"==n[e])i=Math.min(i,1),o=l;else if("?"==n[e])i=0,o=Math.max(o,1);else{if("{"!=n[e])throw new Error("Here?");{const r=n.indexOf("}",e+1);(r<=e||r>s)&&this.throwError("Unexpected end of input while looking for '}'");const a=n.substring(e+1,r).trim(),h=a.split(",").map(t=>parseInt(t.trim()));if(e=r,1==h.length){if(isNaN(h[0])){if(a.trim().length>0)return t.push(new It(a.trim())),e+1;this.throwError(`Invalid quantifier: /${a}/`)}i=o=h[0]}else 2==h.length?(i=isNaN(h[0])?0:h[0],o=isNaN(h[1])?l:h[1],i>o&&this.throwError(`Invalid Quant /${a}/: Min must be <= Max`)):h.length>2&&this.throwError(`Invalid quantifier spec: "{${a}}"`)}}t.length<=0&&this.throwError("Quantifier cannot appear before an expression");const a=t[t.length-1];a.tag!=gt.QUANT||"*"!=r&&"?"!=r&&"+"!=r&&"}"!=r||this.throwError("Nothing to repeat"),!this.unicode||a.tag!=gt.LOOK_AHEAD&&a.tag!=gt.LOOK_BACK||this.throwError("Cannot have quantifier on assertion in unicode mode");const h=t[t.length-1]=new vt(a);return h.minCount=i,h.maxCount=o,++e<=s&&"?"==n[e]&&h.greedy&&(e++,h.greedy=!1),e}}function Yt(t,e){const s=t.index;for(let n=0;n<e.length;n++){if(t.currCh!=e.charAt(n))return t.index=s,!1;t.advance(1)}return!0}class Xt{constructor(){this.counter=new qt}parse(t,e=!1,s=0){const n=[];for(;t.hasMore;){const r=t.currCh;if(Yt(t,"."))n.push(At.Any());else if(Yt(t,"^")){const t=new yt;t.multiline=!0,n.push(t)}else if(Yt(t,"$")){const t=new St;t.multiline=!0,n.push(t)}else{if(Yt(t,"|")){const r=this.reduceLeft(n),i=this.parse(t,e,s);return new xt(r,i)}if("["==r)n.push(this.parseCharGroup(t));else if("*"==r||"?"==r||"+"==r||"{"==r)this.parseQuant(t,n);else if(e&&Qt(r))t.advance(1);else if(e&&Yt(t,"/*")){for(;"*"!=t.currCh||"/"!=t.nextCh;)t.hasMore||this.throwError(t,"Unterminated comment"),t.advance(1);t.advance(2)}else{if(Yt(t,"{-}"))throw new Error("Intersection Not yet supported");if(Yt(t,"{+}"))throw new Error("Union Not yet supported");if(Yt(t,"("))if(Yt(t,"?"))if(Yt(t,"#")){for(;t.hasMore&&")"!=t.currCh;)t.advance(1);a(Yt(t,")"),"Expected ')'")}else{let r=!1,i=!1,o=e,l=!1;for(;t.hasMore&&":"!=t.currCh;)"i"==t.currCh?r=!l:"s"==t.currCh?i=!l:"x"==t.currCh?o=!l:"-"==t.currCh&&(l=!0),t.advance(1);a(Yt(t,":"),"Expected ':'");const h=this.counter.next();let u=this.parse(t,o,s+1);u.groupIndex>=0&&(u=new _t(u)),u.dotAll=i,u.ignoreCase=r,u.groupIndex=h,n.push(u),a(Yt(t,")"),"Expected ')'")}else{const r=this.counter.next();let i=this.parse(t,e,s+1);i.groupIndex>=0&&(i=new _t(i)),i.groupIndex=r,n.push(i),a(Yt(t,")"),"Expected ')'")}else{if(")"==r){0==s&&this.throwError(t,`Unmatched ${r}. Try using \\${r}`);break}if("]"==r||"}"==r)this.throwError(t,`Unmatched ${r}. Try using \\${r}`);else{if(Yt(t,"/")){const r=this.reduceLeft(n),i=this.parse(t,e,s);return new Ct(r,i,!1)}if(Yt(t,'"')){for(;'"'!=t.currCh;)t.hasMore||this.throwError(t,"Unterminated string"),n.push(this.parseChar(t));t.advance(1)}else n.push(this.parseChar(t))}}}}}return 1==n.length?n[0]:new _t(...n)}parseQuant(t,e){let s=1,n=1;if(Yt(t,"*"))s=0,n=l;else if(Yt(t,"+"))s=Math.min(s,1),n=l;else if(Yt(t,"?"))s=0,n=Math.max(n,1);else if(Yt(t,"{")){let r=!1,i="",o="";for(;t.hasMore&&"}"!=t.currCh;)","==t.currCh?r=!0:r?o+=t.currCh:i+=t.currCh,t.advance(1);t.hasMore||this.throwError(t,"Invalid property escape"),i=i.trim(),o=o.trim(),t.advance(1);const a=parseInt(i),h=parseInt(o);if(r)s=isNaN(a)?0:a,n=isNaN(h)?l:h,s>n&&this.throwError(t,`Invalid Quant /${i},${o}/: Min must be <= Max`);else if(isNaN(a)){if(i.length>0)return void e.push(new It(i));this.throwError(t,`Invalid quantifier: /${i}/`),s=n=1}else s=n=a}else this.throwError(t,"Expected '{', '*', '?' or '+', Found: "+t.currCh);e.length<=0&&this.throwError(t,"Quantifier cannot appear before an expression");const r=e[e.length-1];let i;r.tag==gt.QUANT&&r.groupIndex<0?(i=r,i.minCount=Math.min(s,i.minCount),i.maxCount=Math.max(n,i.maxCount)):(i=e[e.length-1]=new vt(r),i.minCount=s,i.maxCount=n),i.greedy&&Yt(t,"?")&&(i.greedy=!1)}parseCharGroup(t){const e=[];a(Yt(t,"["),"Expected '['");const s=Yt(t,"^");for(;"]"!=t.currCh;){const s=this.parseChar(t);if(Yt(t,"-"))if(t.hasMore)if("]"==t.currCh||"["==t.currCh)e.push(s),e.push(At.Single("-"));else{const n=this.parseChar(t);s.op==mt.SingleChar&&n.op==mt.SingleChar||this.throwError(t,"Char range cannot start or end in a char class"),n.args[0]<s.args[0]&&this.throwError(t,"End cannot be less than start"),e.push(Tt.Range(s,n))}else this.throwError(t,"Unterminated char class");else e.push(s)}return a(Yt(t,"]"),"']' expected"),Tt.Union(s,e)}parseChar(t){return"\\"==t.currCh?this.parseEscapeChar(t):this.parseSingleChar(t)}parseSingleChar(t){const e=t.currCh;return t.advance(1),At.Single(e)}parsePropertyEscape(t){a(Yt(t,"\\{"),"Invalid property escape"),t.advance(2);let e=!1,s="",n="";for(;t.hasMore&&"}"!=t.currCh;)"="==t.currCh?e=!0:e?n+=t.currCh:s+=t.currCh,t.advance(1);return t.hasMore||this.throwError(t,"Invalid property escape"),s=s.trim(),n=n.trim(),e||(n=s,s="General_Category"),t.advance(1),At.PropertyEscape(s,n)}parseEscapeChar(t){if(a(Yt(t,"\\"),"Expected '\\'"),t.hasMore||this.throwError(t,"Encounted unexpected end of input after \\"),Yt(t,"w"))return At.Class(st.WORD_CHAR);if(Yt(t,"W"))return At.Class(st.WORD_CHAR,!0);if(Yt(t,"d"))return At.Class(st.DIGITS);if(Yt(t,"D"))return At.Class(st.DIGITS,!0);if(Yt(t,"s"))return At.Class(st.SPACES);if(Yt(t,"S"))return At.Class(st.SPACES,!0);if(Yt(t,"0"))return At.Single("\0");if(Yt(t,"r"))return At.Single("\r");if(Yt(t,"n"))return At.Single("\n");if(Yt(t,"f"))return At.Single("\f");if(Yt(t,"b"))return At.Single("\b");if(Yt(t,"v"))return At.Single("\v");if(Yt(t,"t"))return At.Single("\t");if(Yt(t,"\\"))return At.Single("\\");if(Yt(t,"'"))return At.Single("'");if(Yt(t,'"'))return At.Single('"');if(Yt(t,"x")){t.hasMore||this.throwError(t,`Invalid hex sequence at ${t.index}`);const e=t.currCh+t.nextCh,s=parseInt(e,16);return a(!isNaN(s),`Invalid hex sequence: '${e}'`),t.advance(2),At.Single(s)}if(Yt(t,"u")){t.canAdvance(3)||this.throwError(t,`Invalid unicode sequence at ${t.index}`);const e=t.substring(t.index,t.index+4),s=parseInt(e,16);return isNaN(s)&&this.throwError(t,`Invalid unicode sequence: '${e}'`),t.advance(4),At.Single(s)}const e=t.currCh;return t.advance(1),At.Single(e)}reduceLeft(t){const e=1==t.length?t[0]:new _t(...t);return t.splice(0),e}throwError(t,e){throw new Error(e)}}function Zt(t,e){if("string"==typeof t){const s=new kt(ee(t,e),e);return s.pattern=t,s}if("RegExp"==t.constructor.name){const s=new kt(ee(t,e),e);return s.pattern=t.source,s}return new kt(t,e)}function te(t){const e=new Xt;try{const s=e.parse(new zt(t));return null==s.dotAll&&(s.dotAll=!1),null==s.multiline&&(s.multiline=!1),s}catch(e){throw console.log("Error in FLEX RE: ",t),e}}function ee(t,e){e=e||{};const s="string"!=typeof t,n="string"==typeof t?t:t.source;s&&(e.unicode=t.unicode);const r=new Jt(n,e).parse();return"string"!=typeof t&&(r.dotAll=t.dotAll,r.ignoreCase=t.ignoreCase,r.multiline=t.multiline),r}function se(t,...e){return te(String.raw(t,...e))}class ne{constructor(){this._prog=null,this._vm=null,this.onError=null,this.allRules=[],this.onMatchHandlers=[],this.matchHandlersByValue={},this.variables=new Map,this.compiler=new Ft(t=>{let e=this.variables.get(t)||null;if(null==e&&(e=this.findRuleByValue(t)?.expr||null),null==e)throw new Error(`Invalid regex reference: ${t}`);return e})}getVar(t){return this.variables.get(t)||null}addVar(t,e){let s=this.variables.get(t)||null;return s=null==s?e:new xt(s,e),this.variables.set(t,e),this}findRuleByValue(t){return this.allRules.find(e=>e.tag==t)||null}add(t,e,s=null){return"function"==typeof e&&(s=e,e=null),this.addRule(Zt(t,e),s)}addRule(t,e=null){return t.matchIndex=this.allRules.length,this.allRules.push(t),this.onMatchHandlers.push(e),this._prog=null,this._vm=null,this}on(t,e){return this.matchHandlersByValue[t]=e,this}get prog(){if(null==this._prog){const t=this.sortRules();this._prog=this.compiler.compile(t)}return this._prog}get vm(){return null==this._vm&&(this._vm=new Dt(this.prog)),this._vm}sortRules(){const t=this.allRules.map(t=>t);return t.sort((t,e)=>t.priority!=e.priority?e.priority-t.priority:t.matchIndex-e.matchIndex),t}}class re extends ne{constructor(){super(...arguments),this.idCounter=0}getState(){return this.vm.getState()}setState(t){this.vm.setState(t)}reset(){this.idCounter=0,this._vm&&this._vm.setState(0)}next(t,e){if(!t.hasMore)return null;const s=t.index,n=t.currCh,r=this.vm.match(t);if(null==r){let r=null;if(r=t.index==s+1?new jt(`Unexpected Character: ${n}`,s,1,"UnexpectedCharacter",n):new jt(`Unexpected Symbol: ${t.substring(s,t.index)}`,s,t.index-s,"UnexpectedLexeme"),this.onError&&(r=this.onError(r,t,s)),null!=r)throw r;return this.next(t,e)}const i=this.allRules[r.matchIndex];let o=function(t,e,s){const n=new Kt(t,e.matchIndex,e.start,e.end);for(let t=0;t<e.positions.length;t+=2)e.positions[t]>=0&&(n.positions[Math.floor(t/2)]=[e.positions[t],e.positions[t+1]]);for(const[t,s]of e.groups){const e=Math.abs(t);e in n.groups||(n.groups[e]=[]),n.groups[e].push(s)}return null!=s&&(n.value=s.substring(e.start,e.end)),n}(i.tag,r,t);o.id=this.idCounter++;let a=this.onMatchHandlers[r.matchIndex];if(a||(a=this.matchHandlersByValue[i.tag]),a){if(o=a(i,t,o,e),null==o)return this.next(t,e)}else if(i.skip)return this.next(t,e);return o}tokenize(t,e=null){const s=[];"string"==typeof t&&(t=new zt(t));let n=this.next(t,e);for(;n;){s.push(n);try{n=this.next(t,e)}catch(t){s.push({tag:"ERROR",start:t.offset,end:t.offset+t.length,value:t.message});break}}return s}}const ie=se`["]([^"\\\n]|\\.|\\\n)*["]`,oe=se`[']([^'\\\n]|\\.|\\\n)*[']`,ae=String.raw`/(.+?(?<!\\))/([imus]*)`,le=t=>"number"==typeof t?""+t:t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var he,ue,ce,de;!function(t){t.STRING="STRING",t.REGEX="REGEX",t.NUMBER="NUMBER",t.SPACES="SPACES",t.IDENT="IDENT",t.PCT_IDENT="PCT_IDENT",t.STAR="STAR",t.PLUS="PLUS",t.QMARK="QMARK",t.PIPE="PIPE",t.DOLLAR_NUM="DOLLAR_NUM",t.DOLLAR_IDENT="DOLLAR_IDENT",t.OPEN_PAREN="OPEN_PAREN",t.CLOSE_PAREN="CLOSE_PAREN",t.OPEN_BRACE="OPEN_BRACE",t.CLOSE_BRACE="CLOSE_BRACE",t.OPEN_SQ="OPEN_SQ",t.CLOSE_SQ="CLOSE_SQ",t.COMMENT="COMMENT",t.ARROW="ARROW",t.COLCOLHYPHEN="COLCOLHYPHEN",t.COLON="COLON",t.SEMI_COLON="SEMI_COLON"}(he||(he={})),function(t){t.GRAMMAR="GRAMMAR",t.DECL="DECL",t.RULE="RULE",t.PROD_NULL="PROD_NULL",t.PROD_STR="PROD_STR",t.PROD_UNION="PROD_UNION",t.PROD_NAME="PROD_NAME",t.PROD_STRING="PROD_STRING",t.PROD_NUM="PROD_NUM",t.PROD_IDENT="PROD_IDENT",t.PROD_STAR="PROD_STAR",t.PROD_PLUS="PROD_PLUS",t.PROD_OPTIONAL="PROD_OPTIONAL",t.IDENT="IDENT",t.ERROR="ERROR",t.COMMENT="COMMENT"}(ue||(ue={}));class fe{constructor(t,e){this.leftRecursive=!1,this.generatedTokenizer=new re,this.regexSyntax="js",e=e||{},this.symbolsByLabel={},this.grammar=e.grammar||new et,this.leftRecursive=!("leftRecursive"in e)||e.leftRecursive||!1,this.newSymbolCallback=e.newSymbolCallback||null,this.tokenHandlers=e.tokenHandlers||{},this.parse(t)}symbolForLabel(t){return this.symbolsByLabel[t]||null}registerSymbol(t,e){a(!(t in this.symbolsByLabel),`${t} is already registered`),this.symbolsByLabel[t]=e}ensureSymbol(t,e){let s=this.symbolForLabel(t);return null!=s||(this.newSymbolCallback&&(s=this.newSymbolCallback(t,e)||null),null==s&&(s=e?this.grammar.newTerm(t):this.grammar.newNT(t)),this.registerSymbol(t,s)),s}parse(t){const e=function(){const t=new re;return t.add(/->/,{tag:he.ARROW}),t.add(/\[/,{tag:he.OPEN_SQ}),t.add(/\]/,{tag:he.CLOSE_SQ}),t.add(/\(/,{tag:he.OPEN_PAREN}),t.add(/\)/,{tag:he.CLOSE_PAREN}),t.add(/\{/,{tag:he.OPEN_BRACE}),t.add(/\}/,{tag:he.CLOSE_BRACE}),t.add(/\*/,{tag:he.STAR}),t.add(/\+/,{tag:he.PLUS}),t.add(/\?/,{tag:he.QMARK}),t.add(/;/,{tag:he.SEMI_COLON}),t.add(/:/,{tag:he.COLON}),t.add(/\|/,{tag:he.PIPE}),t.add(/\s+/m,{tag:he.SPACES},()=>null),t.add(/\/\*.*?\*\//s,{tag:he.COMMENT},()=>null),t.add(/\/\/.*$/m,{tag:he.COMMENT},()=>null),t.add(oe,{tag:he.STRING},(t,e,s)=>(s.value=e.substring(s.start+1,s.end-1),s)),t.add(ie,{tag:he.STRING},(t,e,s)=>(s.value=e.substring(s.start+1,s.end-1),s)),t.add(ae,{tag:he.REGEX},(t,e,s)=>{const n=e.substring(s.positions[1][0],s.positions[1][1]),r=e.substring(s.positions[3][0],s.positions[3][1]);return s.value=[n,r],s}),t.add(/\d+/,{tag:he.NUMBER},(t,e,s)=>(s.value=parseInt(e.substring(s.start,s.end)),s)),t.add(/%([\w][\w\d_]*)/,{tag:he.PCT_IDENT},(t,e,s)=>(s.value=e.substring(s.start+1,s.end),s)),t.add(/\$\d+/,{tag:he.DOLLAR_NUM},(t,e,s)=>(s.value=parseInt(e.substring(s.start+1,s.end)),s)),t.add(/\$([\w][\w\d_]*)/,{tag:he.DOLLAR_IDENT},(t,e,s)=>(s.value=e.substring(s.start+1,s.end),s)),t.add(/[\w][\w\d_]*/,{tag:he.IDENT}),t}();this.tokenizer=new Ht((t,s)=>e.next(t,this),this),this.parseGrammar(new zt(t))}parseRegex(t,e,s=0,n=""){if(""==n&&(n=this.regexSyntax),"js"==n){const n=this.tokenizer.expectToken(t,he.STRING,he.NUMBER,he.REGEX);let r;if(e&&0!=e.length||(e="/"+n.value[0]+"/"+n.value[1]),n.tag==he.STRING||n.tag==he.NUMBER)r=Zt(le(n.value),{tag:e,priority:s+20});else{if(n.tag!=he.REGEX)throw new Vt(n);{let t=n.value[0];n.value[1].length>0&&(t=new RegExp(n.value[0],n.value[1])),r=Zt(t,{tag:e,priority:s+10})}}return r}{let n="";for(;t.hasMore&&"\n"!=t.currCh;)n+=t.currCh,t.advance();return n=n.trim(),e&&0!=e.length||(e="/"+n+"/"),new kt(te(n),{tag:e,priority:s})}}parseGrammar(t){let e=this.tokenizer.peek(t);for(;null!=e;){if(e.tag==he.IDENT)this.parseDecl(t);else{if(e.tag!=he.PCT_IDENT)throw new SyntaxError(`Declaration must start with IDENT or PCT_IDENT. Found: '${e.value}' instead.`);this.tokenizer.next(t),this.parseDirective(t,e.value)}e=this.tokenizer.peek(t)}}parseDirective(t,e){if("start"==e){const e=this.tokenizer.expectToken(t,he.IDENT);this.grammar.startSymbol=this.ensureSymbol(e.value,!1)}else if("resyntax"==e){const e=this.tokenizer.expectToken(t,he.IDENT);if("js"!=e.value&&"flex"!=e.value)throw new SyntaxError("Invalid regex syntax: "+e.value);this.regexSyntax=e.value}else if(e.startsWith("skip")){const s=this.parseRegex(t,"",30,e.endsWith("flex")?"flex":""),n=this.parseTokenHandler(t);n?this.generatedTokenizer.addRule(s,(t,e,s)=>(n(t,e,s,this),null)):this.generatedTokenizer.addRule(s,()=>null)}else{if(!e.startsWith("token")&&!e.startsWith("define"))throw new Error("Invalid directive: "+e);{const s=e.startsWith("define"),n=this.tokenizer.expectToken(t,he.IDENT,he.STRING);let r=n.value;n.tag!=he.STRING&&n.tag!=he.NUMBER||(r=`"${n.value}"`);const i=this.parseRegex(t,r,0,e.endsWith("flex")?"flex":"");if(s)this.generatedTokenizer.addVar(r,i.expr);else{const e=this.parseTokenHandler(t);this.generatedTokenizer.addRule(i,e),this.ensureSymbol(r,!0)}}}}parseTokenHandler(t){if(!this.tokenizer.consumeIf(t,he.OPEN_BRACE))return null;const e=this.tokenizer.expectToken(t,he.IDENT);return this.tokenizer.expectToken(t,he.CLOSE_BRACE),(t,s,n,r)=>{const i=this.tokenHandlers[e.value];if(!i)throw new Error("Handler method not found: "+e.value);return i(n,s,r)}}parseDecl(t){const e=this.tokenizer.expectToken(t,he.IDENT);if(this.tokenizer.consumeIf(t,he.ARROW,he.COLON)){const s=this.ensureSymbol(e.value,!1);if(s.isTerminal)s.isTerminal=!1;else if(s.isAuxiliary)throw new Error("NT is already auxiliary and cannot be reused.");for(const[e,n]of this.parseProductions(t,this.grammar,s))this.grammar.add(s,e,n);this.tokenizer.expectToken(t,he.SEMI_COLON)}}parseProductions(t,e,s){const n=[];for(;null!=this.tokenizer.peek(t);){const s=this.parseProd(t,e);if(n.push(s),!this.tokenizer.consumeIf(t,he.PIPE)&&this.tokenizer.nextMatches(t,he.CLOSE_SQ,he.CLOSE_PAREN,he.SEMI_COLON))break}return n}parseProd(t,e){const s=new X;for(;!this.tokenizer.nextMatches(t,he.CLOSE_PAREN,he.CLOSE_SQ,he.SEMI_COLON,he.PIPE,he.OPEN_BRACE);){let n=null;if(this.tokenizer.consumeIf(t,he.OPEN_PAREN)){const s=this.parseProductions(t,e,null);0==s.length||(n=1==s.length?s[0][0]:e.anyof(...s.map(t=>t[0]))),this.tokenizer.expectToken(t,he.CLOSE_PAREN)}else if(this.tokenizer.consumeIf(t,he.OPEN_SQ)){const s=this.parseProductions(t,e,null);0==s.length||(n=1==s.length?e.opt(s[0][0]):e.opt(e.anyof(...s.map(t=>t[0])))),this.tokenizer.expectToken(t,he.CLOSE_SQ)}else{if(!this.tokenizer.nextMatches(t,he.IDENT,he.STRING,he.NUMBER,he.REGEX))throw new Vt(this.tokenizer.peek(t));{const e=this.tokenizer.next(t);let s=e.value;if(e.tag==he.STRING||e.tag==he.NUMBER){s=`"${e.value}"`;const t=Zt(le(e.value),{tag:s,priority:20});this.generatedTokenizer.addRule(t)}else if(e.tag==he.REGEX){s="/"+e.value[0]+"/"+e.value[1];let t=e.value[0];e.value[1].length>0&&(t=new RegExp(e.value[0],e.value[1]));const n=Zt(t,{tag:s,priority:10});this.generatedTokenizer.addRule(n)}const r=this.ensureSymbol(s,!0);n=new X(r)}}if(null==n)throw new Error("Could not determine node");this.tokenizer.consumeIf(t,he.STAR)?n=e.atleast0(n,this.leftRecursive):this.tokenizer.consumeIf(t,he.PLUS)?n=e.atleast1(n,this.leftRecursive):this.tokenizer.consumeIf(t,he.QMARK)&&(n=e.opt(n)),s.extend(n)}let n=null;if(this.tokenizer.consumeIf(t,he.OPEN_BRACE)){const e=this.tokenizer.expectToken(t,he.DOLLAR_NUM,he.IDENT);n=new Z(e.value),this.tokenizer.expectToken(t,he.CLOSE_BRACE)}return[s,n]}}class ge{constructor(t,e,s,...n){this.id=t,this.sym=e,this.value=s,this.children=[],this.children=n||[]}get childCount(){return this.children.length}childAt(t){return t<0?this.children[this.children.length+t]:this.children[t]}get isTerminal(){return this.sym.isTerminal}add(t,e=-1){if(this.isTerminal)throw new Error(`Cannot add children (${t.sym.label}) to a terminal node: ${this.sym.label}`);return e<0?this.children.push(t):this.children.splice(e,0,t),this}splice(t,e,...s){return this.children.splice(t,e,...s),this}get reprString(){return this.debugValue(!1).join("\n")}debugValue(t=!0){if(t){const e=[this.sym.label];return this.value&&e.push(this.value),this.children.length>0&&e.push(this.children.map(e=>e.debugValue(t))),e}{const e=[];return this.value,e.push(null==this.value?this.sym.label:this.sym.label+" - "+this.value),this.children.forEach(s=>s.debugValue(t).forEach(t=>e.push(" "+t))),e}}}class me extends ge{constructor(){super(...arguments),this.parent=null}add(t,e=-1){return super.add(t,e),t.parent=this,this}splice(t,e,...s){for(const t of s)t.parent=this;return super.splice(t,e,...s)}}class pe{setTokenizer(t){return this.tokenbuffer=new Ht(t,null),this}getSym(t){const e=this.grammar.getSym(t.tag);if(null==e)throw new Error("Invalid token tag: "+t.tag+", Value: "+t.value);return e}}class be extends pe{parse(t,e=null){return"string"==typeof t&&(t=new zt(t)),this.parseInput(t,e)}}class ye extends Error{constructor(t,e,s=null){super(t),this.type=e,this.value=s,Object.setPrototypeOf(this,new.target.prototype)}get name(){return this.constructor.name}}(de=ce||(ce={}))[de.ACCEPT=0]="ACCEPT",de[de.SHIFT=1]="SHIFT",de[de.REDUCE=2]="REDUCE",de[de.GOTO=3]="GOTO";class Se{constructor(){this.gotoState=null,this.rule=null}toString(){return this.tag==ce.ACCEPT?"Acc":this.tag==ce.SHIFT?"S"+this.gotoState:this.tag==ce.REDUCE?"R "+this.rule.id:""+this.gotoState}equals(t){return this.tag==t.tag&&this.gotoState==t.gotoState&&this.rule==t.rule}static Shift(t){const e=new Se;return e.tag=ce.SHIFT,e.gotoState=t,e}static Reduce(t){const e=new Se;return e.tag=ce.REDUCE,e.rule=t,e}static Goto(t){const e=new Se;return e.tag=ce.GOTO,e.gotoState=t,e}static Accept(){const t=new Se;return t.tag=ce.ACCEPT,t}}class Ee{constructor(t){this.grammar=t,this.conflictActions={},this.actions={}}get hasConflicts(){return Object.keys(this.conflictActions).length>0}getActions(t,e,s=!1){let n;if(t in this.actions)n=this.actions[t];else{if(!s)return[];n=this.actions[t]={}}return e.id in n?n[e.id]:s?n[e.id]=[]:[]}addAction(t,e,s){const n=this.getActions(t,e,!0);return n.findIndex(t=>t.equals(s))<0&&n.push(s),n.length>1&&(this.conflictActions[t]=this.conflictActions[t]||{},this.conflictActions[t][e.label]=!0),this}get debugValue(){const t={};for(const e in this.actions){t[e]={};for(const s in this.actions[e]){const n=this.grammar.getSymById(s),r=this.actions[e][n.id]||[];r.length>0&&(t[e][n.label]=r.map(t=>t.toString()))}}return t}}class Ce{constructor(){this.stateStack=[],this.nodeStack=[]}push(t,e){this.stateStack.push(t),this.nodeStack.push(e)}top(t=0){return[this.stateStack[this.stateStack.length-1-t],this.nodeStack[this.nodeStack.length-1-t]]}pop(){const t=this.top();return this.stateStack.pop(),this.nodeStack.pop(),t}popN(t=1){const e=this.stateStack.length;this.stateStack.splice(e-t,t),this.nodeStack.splice(e-t,t)}get isEmpty(){return 0==this.stateStack.length||0==this.nodeStack.length}}class we extends be{constructor(t,e={}){super(),this.parseTable=t}get grammar(){return this.parseTable.grammar}parseInput(t,e){e=e||{},this.tokenbuffer.tokenizerContext=e.tokenizerContext,0!=e.buildParseTree&&(e.buildParseTree=!0),0!=e.copySingleChild&&(e.copySingleChild=!0);let s=0;const n=new Ce;n.push(0,new me(s++,this.grammar.augStartRule.nt,null));const r=this.tokenbuffer,i=this.grammar;let o=null;function l(t){if(e?.actionResolver)return e.actionResolver(t,n,r);if(t.length>1)throw new Error("Multiple actions found.");return t[0]}function h(){try{return r.peek(t)}catch(s){if(!e?.onTokenError||!e?.onTokenError(s,t))throw s;return h()}}for(;;){let u=h();if(null==u){if(n.isEmpty)break}else e.onNextToken&&(u=e.onNextToken(u));const c=null==u?i.Eof:this.getSym(u),d=null==u?null:u.value;let[f,g]=n.top();const m=this.parseTable.getActions(f,c);if(null==m||0==m.length)throw new ye(`Unexpected Token: '${c.label}'`,"UnexpectedToken",{state:f,token:u,nextSym:c});const p=l(m);if(p.tag==ce.ACCEPT)break;if(p.tag==ce.SHIFT){r.next(t);const e=new me(s++,c,d);n.push(p.gotoState,e)}else{a(null!=p.rule,"Nonterm and ruleindex must be provided for a reduction action");const t=p.rule.rhs.length;let r=new me(s++,p.rule.nt,null);if(e.buildParseTree)for(let s=t-1;s>=0;s--){const t=n.top(s)[1];if(e.beforeAddingChildNode)for(const s of e.beforeAddingChildNode(r,t))r.add(s);else null!=t&&r.add(t)}if(p.rule.action)if(p.rule.action.isFunction){const t=p.rule.action.value,s=e.ruleHandlers[t];if(!s)throw new Error("Action handler not found: "+t);r.value=s(p.rule,r,...r.children)}else r.value=r.children[p.rule.action.value-1].value;else e.onReduction?r=e.onReduction(r,p.rule):1==r.children.length&&e.copySingleChild&&(r.value=r.children[0].value);n.popN(t),[f,g]=n.top();const i=l(this.parseTable.getActions(f,p.rule.nt));a(null!=i&&null!=i.gotoState,"Top item does not have an action."),n.push(i.gotoState,r),o=r}}return o}}class ve{constructor(t,e=0){this.id=0,this.rule=t,this.position=e}advance(){return a(this.position<this.rule.rhs.length),new ve(this.rule,this.position+1)}copy(){return new ve(this.rule,this.position)}get key(){return a(!isNaN(this.rule.id),"Rule's ID is not yet set."),this.rule.id+":"+this.position}compareTo(t){let e=this.rule.id-t.rule.id;return 0==e&&(e=this.position-t.position),e}equals(t){return 0==this.compareTo(t)}get debugString(){const t=this.rule,e=this.position,s=t.rhs.syms.slice(0,e).join(" "),n=t.rhs.syms.slice(e).join(" ");return`${t.id} - ${t.nt} -> ${s} • ${n}`}}class _e{constructor(t,...e){this.id=0,this._key=null,this._lookaheads={},this._hasLookAheads=!1,this.itemGraph=t,this.values=e}copy(){const t=new _e(this.itemGraph,...this.values);return t._lookaheads={...this._lookaheads},t._hasLookAheads=this._hasLookAheads,t}addLookAhead(t,e){t.id in this._lookaheads||(this._lookaheads[t.id]=[]);for(const s of this._lookaheads[t.id])if(s==e)return!1;return this._hasLookAheads=!0,this._key=null,this._lookaheads[t.id].push(e),this._lookaheads[t.id].sort((t,e)=>t.id-e.id),!0}clearLookAheads(){this._lookaheads={}}getLookAheads(t){return this._lookaheads[t.id]||[]}get key(){return null==this._key&&(this._key=this.revalKey()),this._key}revalKey(){return this.hasLookAheads?(this.values.sort(),this.values.map(t=>t+"["+(this._lookaheads[t]||[]).map(t=>t.id).join(",")+"]").join("/")):(this.values.sort(),this.values.join("/"))}has(t){return this.values.indexOf(t)>=0}equals(t){return this.key==t.key}add(t){return this.has(t)||(this.values.push(t),this._key=null),this}get size(){return this.values.length}get debugString(){return this.debugValue.join("\n")}get hasLookAheads(){return this._hasLookAheads}get debugValue(){if(this.hasLookAheads){const t=this.values.map(t=>this.itemGraph.items.get(t));return t.sort((t,e)=>t.compareTo(e)),t.map(t=>{const e=this.getLookAheads(t).map(t=>t.label).sort((t,e)=>t.localeCompare(e)).join(", ");return e.length>0?`${t.debugString} / ( ${e} )`:t.debugString})}{const t=this.values.map(t=>this.itemGraph.items.get(t));return t.sort((t,e)=>t.compareTo(e)),t.map(t=>t.debugString)}}}class xe{constructor(t){this.grammar=t,this.gotoSets={},this.items=new W,this.itemSets=new W}startItem(){return a(null!=this.grammar.startSymbol,"Start symbol must be set"),a(null!=(this.grammar.augStartRule||null),"Grammar is not augmented"),this.items.ensure(new ve(this.grammar.augStartRule))}reset(){this.grammar.refresh(),this.gotoSets={},this.items.clear(),this.itemSets.clear(),this.startSet()}refresh(){return this.reset(),this.grammar.refresh(),this.evalGotoSets(),this}evalGotoSets(){const t=this.itemSets;for(let e=0;e<t.size;e++){const s=t.get(e);for(const t of this.grammar.allSymbols)if(t!=this.grammar.Null){const e=this.goto(s,t);e.size>0&&this.setGoto(s,t,e)}}}goto(t,e){const s=this.newItemSet();for(const n of t.values){const r=this.items.get(n),i=r.rule;r.position<i.rhs.length&&i.rhs.syms[r.position]==e&&this.advanceItemAndAdd(r,t,s)}return this.closure(s)}advanceItemAndAdd(t,e,s){const n=this.items.ensure(t.advance());s.add(n.id);for(const r of e.getLookAheads(t))s.addLookAhead(n,r)}newItemSet(...t){return new _e(this,...t.map(t=>t.id))}get size(){return this.itemSets.size}ensureGotoSet(t){return t.id in this.gotoSets||(this.gotoSets[t.id]={}),this.gotoSets[t.id]}setGoto(t,e,s){this.ensureGotoSet(t)[e.id]=s}getGoto(t,e){return(this.gotoSets[t.id]||{})[e.id]||null}forEachGoto(t,e){const s=this.gotoSets[t.id]||{};for(const t in s)if(0==e(this.grammar.getSymById(t),s[t]))break}gotoSetFor(t){return this.gotoSets[t.id]||{}}get debugValue(){const t={};return this.itemSets.entries.forEach(e=>{t[e.id]={items:[],goto:{}},t[e.id].items=e.debugValue;const s=this.gotoSets[e.id];for(const n in s){const r=this.grammar.getSymById(n);t[e.id].goto=t[e.id].goto||{},t[e.id].goto[r.label]=s[n].id}}),t}}class Ne extends xe{startSet(){const t=this.startItem(),e=this.newItemSet(t);return this.closure(e)}closure(t){const e=new _e(this,...t.values);for(let t=0;t<e.values.length;t++){const s=e.values[t],n=this.items.get(s),r=n.rule;if(n.position<r.rhs.length){const t=r.rhs.syms[n.position];if(!t.isTerminal)for(const s of this.grammar.rulesForNT(t)){const t=this.items.ensure(new ve(s,0));e.add(t.id)}}}return 0==e.size?e:this.itemSets.ensure(e)}}class Ae extends xe{startSet(){const t=this.startItem(),e=this.newItemSet(t);return e.addLookAhead(t,this.grammar.Eof),this.closure(e)}closure(t){const e=t.copy();for(let t=0;t<e.values.length;t++){const s=e.values[t],n=this.items.get(s);if(n.position>=n.rule.rhs.length)continue;const r=n.rule.rhs,i=r.syms[n.position];if(!i.isTerminal)for(const t of e.getLookAheads(n)){const s=r.copy().append(t);this.grammar.firstSets.forEachTermIn(s,n.position+1,t=>{if(null!=t){const s=this.grammar.rulesForNT(i);for(const n of s){const s=this.items.ensure(new ve(n,0));e.add(s.id),e.addLookAhead(s,t)}}})}}return 0==e.size?e:this.itemSets.ensure(e)}}function Te(t){const e=function(t){const e=new Ne(t).refresh();for(const s of e.itemSets.entries)Ie(t,e,s);return e}(t);return[Oe(e,t),e]}function Ie(t,e,s){for(const n of s.values){const r=e.items.get(n),i=r.rule;r.position>=i.rhs.length&&t.followSets.forEachTerm(i.nt,t=>{null!=t&&(a(t.isTerminal),s.addLookAhead(r,t))})}}function Oe(t,e){const s=new Ee(e);for(const n of t.itemSets.entries){for(const r of n.values){const i=t.items.get(r),o=i.rule;if(i.position<o.rhs.length){const e=o.rhs.syms[i.position];if(e.isTerminal){const r=t.getGoto(n,e);r&&s.addAction(n.id,e,Se.Shift(r.id))}}else if(!o.nt.equals(e.augStartRule.nt)){const t=n.getLookAheads(i);for(const e of t)s.addAction(n.id,e,Se.Reduce(o))}}t.forEachGoto(n,(t,e)=>{null==t||t.isTerminal||s.addAction(n.id,t,Se.Goto(e.id))});const r=t.items.ensure(new ve(e.augStartRule,1));n.addLookAhead(r,e.Eof),n.has(r.id)&&s.addAction(n.id,e.Eof,Se.Accept())}return s}function Re(t,e,s,n,r){function i(t,e,n,o){if(e<0)a(null!=(s.gotoSets[n][t.nt.id]||null),"Transition on rule.nt missing from start state"),o.add(n);else{const s=t.rhs.syms[e],l=r[n][s.id]||null;a(null!=l,"Prev set should not be null"),l.forEach(s=>i(t,e-1,s,o))}}n.clearLookAheads();for(const r of n.values){const o=s.items.get(r),l=o.rule;if(o.position>=l.rhs.length){const s=new Set;i(l,l.rhs.length-1,n.id,s),s.forEach(s=>{const r=`[${s}:${l.nt.label}]`,i=e.getSym(r);a(null!=i,"Augmented grammar symbol [p:A] not found"),e.followSets.forEachTerm(i,s=>{if(null!=s&&s!=e.Eof){a(s.isTerminal);const e=s.label.substring(s.label.indexOf(":")+1,s.label.length-1).trim(),r=t.getSym(e);a(null!=r,`T (${e}) in [r:T] cannot be null`),n.addLookAhead(o,r)}})})}}}const ke=Symbol.for("yaml.alias"),Le=Symbol.for("yaml.document"),Me=Symbol.for("yaml.map"),Pe=Symbol.for("yaml.pair"),Be=Symbol.for("yaml.scalar"),$e=Symbol.for("yaml.seq"),De=Symbol.for("yaml.node.type"),Ue=t=>!!t&&"object"==typeof t&&t[De]===ke,Fe=t=>!!t&&"object"==typeof t&&t[De]===Le,je=t=>!!t&&"object"==typeof t&&t[De]===Me,Ve=t=>!!t&&"object"==typeof t&&t[De]===Pe,Ge=t=>!!t&&"object"==typeof t&&t[De]===Be,ze=t=>!!t&&"object"==typeof t&&t[De]===$e;function We(t){if(t&&"object"==typeof t)switch(t[De]){case Me:case $e:return!0}return!1}function Ke(t){if(t&&"object"==typeof t)switch(t[De]){case ke:case Me:case Be:case $e:return!0}return!1}const He=t=>(Ge(t)||We(t))&&!!t.anchor,qe=Symbol("break visit"),Qe=Symbol("skip children"),Je=Symbol("remove node");function Ye(t,e){const s=es(e);Fe(t)?Xe(null,t.contents,s,Object.freeze([t]))===Je&&(t.contents=null):Xe(null,t,s,Object.freeze([]))}function Xe(t,e,s,n){const r=ss(t,e,s,n);if(Ke(r)||Ve(r))return ns(t,n,r),Xe(t,r,s,n);if("symbol"!=typeof r)if(We(e)){n=Object.freeze(n.concat(e));for(let t=0;t<e.items.length;++t){const r=Xe(t,e.items[t],s,n);if("number"==typeof r)t=r-1;else{if(r===qe)return qe;r===Je&&(e.items.splice(t,1),t-=1)}}}else if(Ve(e)){n=Object.freeze(n.concat(e));const t=Xe("key",e.key,s,n);if(t===qe)return qe;t===Je&&(e.key=null);const r=Xe("value",e.value,s,n);if(r===qe)return qe;r===Je&&(e.value=null)}return r}async function Ze(t,e){const s=es(e);Fe(t)?await ts(null,t.contents,s,Object.freeze([t]))===Je&&(t.contents=null):await ts(null,t,s,Object.freeze([]))}async function ts(t,e,s,n){const r=await ss(t,e,s,n);if(Ke(r)||Ve(r))return ns(t,n,r),ts(t,r,s,n);if("symbol"!=typeof r)if(We(e)){n=Object.freeze(n.concat(e));for(let t=0;t<e.items.length;++t){const r=await ts(t,e.items[t],s,n);if("number"==typeof r)t=r-1;else{if(r===qe)return qe;r===Je&&(e.items.splice(t,1),t-=1)}}}else if(Ve(e)){n=Object.freeze(n.concat(e));const t=await ts("key",e.key,s,n);if(t===qe)return qe;t===Je&&(e.key=null);const r=await ts("value",e.value,s,n);if(r===qe)return qe;r===Je&&(e.value=null)}return r}function es(t){return"object"==typeof t&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function ss(t,e,s,n){return"function"==typeof s?s(t,e,n):je(e)?s.Map?.(t,e,n):ze(e)?s.Seq?.(t,e,n):Ve(e)?s.Pair?.(t,e,n):Ge(e)?s.Scalar?.(t,e,n):Ue(e)?s.Alias?.(t,e,n):void 0}function ns(t,e,s){const n=e[e.length-1];if(We(n))n.items[t]=s;else if(Ve(n))"key"===t?n.key=s:n.value=s;else{if(!Fe(n)){const t=Ue(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${t} parent`)}n.contents=s}}Ye.BREAK=qe,Ye.SKIP=Qe,Ye.REMOVE=Je,Ze.BREAK=qe,Ze.SKIP=Qe,Ze.REMOVE=Je;const rs={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},is=t=>t.replace(/[!,[\]{}]/g,t=>rs[t]);class os{constructor(t,e){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},os.defaultYaml,t),this.tags=Object.assign({},os.defaultTags,e)}clone(){const t=new os(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new os(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:os.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},os.defaultTags)}return t}add(t,e){this.atNextDocument&&(this.yaml={explicit:os.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},os.defaultTags),this.atNextDocument=!1);const s=t.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(2!==s.length&&(e(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;const[t,n]=s;return this.tags[t]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==s.length)return e(0,"%YAML directive should contain exactly one part"),!1;const[t]=s;return"1.1"===t||"1.2"===t?(this.yaml.version=t,!0):(e(6,`Unsupported YAML version ${t}`,/^\d+\.\d+$/.test(t)),!1)}default:return e(0,`Unknown directive ${n}`,!0),!1}}tagName(t,e){if("!"===t)return"!";if("!"!==t[0])return e(`Not a valid tag: ${t}`),null;if("<"===t[1]){const s=t.slice(2,-1);return"!"===s||"!!"===s?(e(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(">"!==t[t.length-1]&&e("Verbatim tags must end with a >"),s)}const[,s,n]=t.match(/^(.*!)([^!]*)$/s);n||e(`The ${t} tag has no suffix`);const r=this.tags[s];if(r)try{return r+decodeURIComponent(n)}catch(t){return e(String(t)),null}return"!"===s?t:(e(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[e,s]of Object.entries(this.tags))if(t.startsWith(s))return e+is(t.substring(s.length));return"!"===t[0]?t:`!<${t}>`}toString(t){const e=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);let n;if(t&&s.length>0&&Ke(t.contents)){const e={};Ye(t.contents,(t,s)=>{Ke(s)&&s.tag&&(e[s.tag]=!0)}),n=Object.keys(e)}else n=[];for(const[r,i]of s)"!!"===r&&"tag:yaml.org,2002:"===i||t&&!n.some(t=>t.startsWith(i))||e.push(`%TAG ${r} ${i}`);return e.join("\n")}}function as(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){const e=JSON.stringify(t);throw new Error(`Anchor must not contain whitespace or control characters: ${e}`)}return!0}function ls(t,e,s,n){if(n&&"object"==typeof n)if(Array.isArray(n))for(let e=0,s=n.length;e<s;++e){const s=n[e],r=ls(t,n,String(e),s);void 0===r?delete n[e]:r!==s&&(n[e]=r)}else if(n instanceof Map)for(const e of Array.from(n.keys())){const s=n.get(e),r=ls(t,n,e,s);void 0===r?n.delete(e):r!==s&&n.set(e,r)}else if(n instanceof Set)for(const e of Array.from(n)){const s=ls(t,n,e,e);void 0===s?n.delete(e):s!==e&&(n.delete(e),n.add(s))}else for(const[e,s]of Object.entries(n)){const r=ls(t,n,e,s);void 0===r?delete n[e]:r!==s&&(n[e]=r)}return t.call(e,s,n)}function hs(t,e,s){if(Array.isArray(t))return t.map((t,e)=>hs(t,String(e),s));if(t&&"function"==typeof t.toJSON){if(!s||!He(t))return t.toJSON(e,s);const n={aliasCount:0,count:1,res:void 0};s.anchors.set(t,n),s.onCreate=t=>{n.res=t,delete s.onCreate};const r=t.toJSON(e,s);return s.onCreate&&s.onCreate(r),r}return"bigint"!=typeof t||s?.keep?t:Number(t)}os.defaultYaml={explicit:!1,version:"1.2"},os.defaultTags={"!!":"tag:yaml.org,2002:"};class us{constructor(t){Object.defineProperty(this,De,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:e,maxAliasCount:s,onAnchor:n,reviver:r}={}){if(!Fe(t))throw new TypeError("A document argument is required");const i={anchors:new Map,doc:t,keep:!0,mapAsMap:!0===e,mapKeyWarned:!1,maxAliasCount:"number"==typeof s?s:100},o=hs(this,"",i);if("function"==typeof n)for(const{count:t,res:e}of i.anchors.values())n(e,t);return"function"==typeof r?ls(r,{"":o},"",o):o}}class cs extends us{constructor(t){super(ke),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,e){let s,n;e?.aliasResolveCache?s=e.aliasResolveCache:(s=[],Ye(t,{Node:(t,e)=>{(Ue(e)||He(e))&&s.push(e)}}),e&&(e.aliasResolveCache=s));for(const t of s){if(t===this)break;t.anchor===this.source&&(n=t)}return n}toJSON(t,e){if(!e)return{source:this.source};const{anchors:s,doc:n,maxAliasCount:r}=e,i=this.resolve(n,e);if(!i){const t=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(t)}let o=s.get(i);if(o||(hs(i,null,e),o=s.get(i)),void 0===o?.res)throw new ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0&&(o.count+=1,0===o.aliasCount&&(o.aliasCount=ds(n,i,s)),o.count*o.aliasCount>r))throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack");return o.res}toString(t,e,s){const n=`*${this.source}`;if(t){if(as(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const t=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(t)}if(t.implicitKey)return`${n} `}return n}}function ds(t,e,s){if(Ue(e)){const n=e.resolve(t),r=s&&n&&s.get(n);return r?r.count*r.aliasCount:0}if(We(e)){let n=0;for(const r of e.items){const e=ds(t,r,s);e>n&&(n=e)}return n}if(Ve(e)){const n=ds(t,e.key,s),r=ds(t,e.value,s);return Math.max(n,r)}return 1}const fs=t=>!t||"function"!=typeof t&&"object"!=typeof t;class gs extends us{constructor(t){super(Be),this.value=t}toJSON(t,e){return e?.keep?this.value:hs(this.value,t,e)}toString(){return String(this.value)}}function ms(t,e,s){if(Fe(t)&&(t=t.contents),Ke(t))return t;if(Ve(t)){const e=s.schema[Me].createNode?.(s.schema,null,s);return e.items.push(t),e}(t instanceof String||t instanceof Number||t instanceof Boolean||"undefined"!=typeof BigInt&&t instanceof BigInt)&&(t=t.valueOf());const{aliasDuplicateObjects:n,onAnchor:r,onTagObj:i,schema:o,sourceObjects:a}=s;let l;if(n&&t&&"object"==typeof t){if(l=a.get(t),l)return l.anchor??(l.anchor=r(t)),new cs(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e="tag:yaml.org,2002:"+e.slice(2));let h=function(t,e,s){if(e){const t=s.filter(t=>t.tag===e),n=t.find(t=>!t.format)??t[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return s.find(e=>e.identify?.(t)&&!e.format)}(t,e,o.tags);if(!h){if(t&&"function"==typeof t.toJSON&&(t=t.toJSON()),!t||"object"!=typeof t){const e=new gs(t);return l&&(l.node=e),e}h=t instanceof Map?o[Me]:Symbol.iterator in Object(t)?o[$e]:o[Me]}i&&(i(h),delete s.onTagObj);const u=h?.createNode?h.createNode(s.schema,t,s):"function"==typeof h?.nodeClass?.from?h.nodeClass.from(s.schema,t,s):new gs(t);return e?u.tag=e:h.default||(u.tag=h.tag),l&&(l.node=u),u}function ps(t,e,s){let n=s;for(let t=e.length-1;t>=0;--t){const s=e[t];if("number"==typeof s&&Number.isInteger(s)&&s>=0){const t=[];t[s]=n,n=t}else n=new Map([[s,n]])}return ms(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}gs.BLOCK_FOLDED="BLOCK_FOLDED",gs.BLOCK_LITERAL="BLOCK_LITERAL",gs.PLAIN="PLAIN",gs.QUOTE_DOUBLE="QUOTE_DOUBLE",gs.QUOTE_SINGLE="QUOTE_SINGLE";class bs extends us{constructor(t,e){super(t),Object.defineProperty(this,"schema",{value:e,configurable:!0,enumerable:!1,writable:!0})}clone(t){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(e.schema=t),e.items=e.items.map(e=>Ke(e)||Ve(e)?e.clone(t):e),this.range&&(e.range=this.range.slice()),e}addIn(t,e){if((t=>null==t||"object"==typeof t&&!!t[Symbol.iterator]().next().done)(t))this.add(e);else{const[s,...n]=t,r=this.get(s,!0);if(We(r))r.addIn(n,e);else{if(void 0!==r||!this.schema)throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`);this.set(s,ps(this.schema,n,e))}}}deleteIn(t){const[e,...s]=t;if(0===s.length)return this.delete(e);const n=this.get(e,!0);if(We(n))return n.deleteIn(s);throw new Error(`Expected YAML collection at ${e}. Remaining path: ${s}`)}getIn(t,e){const[s,...n]=t,r=this.get(s,!0);return 0===n.length?!e&&Ge(r)?r.value:r:We(r)?r.getIn(n,e):void 0}hasAllNullValues(t){return this.items.every(e=>{if(!Ve(e))return!1;const s=e.value;return null==s||t&&Ge(s)&&null==s.value&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(t){const[e,...s]=t;if(0===s.length)return this.has(e);const n=this.get(e,!0);return!!We(n)&&n.hasIn(s)}setIn(t,e){const[s,...n]=t;if(0===n.length)this.set(s,e);else{const t=this.get(s,!0);if(We(t))t.setIn(n,e);else{if(void 0!==t||!this.schema)throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`);this.set(s,ps(this.schema,n,e))}}}}const ys=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Ss(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}const Es=(t,e,s)=>t.endsWith("\n")?Ss(s,e):s.includes("\n")?"\n"+Ss(s,e):(t.endsWith(" ")?"":" ")+s,Cs="flow",ws="block",vs="quoted";function _s(t,e,s="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return t;r<i&&(i=0);const l=Math.max(1+i,1+r-e.length);if(t.length<=l)return t;const h=[],u={};let c,d,f=r-e.length;"number"==typeof n&&(n>r-Math.max(2,i)?h.push(0):f=r-n);let g=!1,m=-1,p=-1,b=-1;s===ws&&(m=xs(t,m,e.length),-1!==m&&(f=m+l));for(let n;n=t[m+=1];){if(s===vs&&"\\"===n){switch(p=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if("\n"===n)s===ws&&(m=xs(t,m,e.length)),f=m+e.length+l,c=void 0;else{if(" "===n&&d&&" "!==d&&"\n"!==d&&"\t"!==d){const e=t[m+1];e&&" "!==e&&"\n"!==e&&"\t"!==e&&(c=m)}if(m>=f)if(c)h.push(c),f=c+l,c=void 0;else if(s===vs){for(;" "===d||"\t"===d;)d=n,n=t[m+=1],g=!0;const e=m>b+1?m-2:p-1;if(u[e])return t;h.push(e),u[e]=!0,f=e+l,c=void 0}else g=!0}d=n}if(g&&a&&a(),0===h.length)return t;o&&o();let y=t.slice(0,h[0]);for(let n=0;n<h.length;++n){const r=h[n],i=h[n+1]||t.length;0===r?y=`\n${e}${t.slice(0,i)}`:(s===vs&&u[r]&&(y+=`${t[r]}\\`),y+=`\n${e}${t.slice(r+1,i)}`)}return y}function xs(t,e,s){let n=e,r=e+1,i=t[r];for(;" "===i||"\t"===i;)if(e<r+s)i=t[++e];else{do{i=t[++e]}while(i&&"\n"!==i);n=e,r=e+1,i=t[r]}return n}const Ns=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),As=t=>/^(%|---|\.\.\.)/m.test(t);function Ts(t,e){const s=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return s;const{implicitKey:n}=e,r=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(As(t)?" ":"");let o="",a=0;for(let t=0,e=s[t];e;e=s[++t])if(" "===e&&"\\"===s[t+1]&&"n"===s[t+2]&&(o+=s.slice(a,t)+"\\ ",t+=1,a=t,e="\\"),"\\"===e)switch(s[t+1]){case"u":{o+=s.slice(a,t);const e=s.substr(t+2,4);switch(e){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:"00"===e.substr(0,2)?o+="\\x"+e.substr(2):o+=s.substr(t,6)}t+=5,a=t+1}break;case"n":if(n||'"'===s[t+2]||s.length<r)t+=1;else{for(o+=s.slice(a,t)+"\n\n";"\\"===s[t+2]&&"n"===s[t+3]&&'"'!==s[t+4];)o+="\n",t+=2;o+=i," "===s[t+2]&&(o+="\\"),t+=1,a=t+1}break;default:t+=1}return o=a?o+s.slice(a):s,n?o:_s(o,i,vs,Ns(e,!1))}function Is(t,e){if(!1===e.options.singleQuote||e.implicitKey&&t.includes("\n")||/[ \t]\n|\n[ \t]/.test(t))return Ts(t,e);const s=e.indent||(As(t)?" ":""),n="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&\n${s}`)+"'";return e.implicitKey?n:_s(n,s,Cs,Ns(e,!1))}function Os(t,e){const{singleQuote:s}=e.options;let n;if(!1===s)n=Ts;else{const e=t.includes('"'),r=t.includes("'");n=e&&!r?Is:r&&!e?Ts:s?Is:Ts}return n(t,e)}let Rs;try{Rs=new RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{Rs=/\n+(?!\n|$)/g}function ks({comment:t,type:e,value:s},n,r,i){const{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(s))return Os(s,n);const h=n.indent||(n.forceBlockIndent||As(s)?" ":""),u="literal"===o||"folded"!==o&&e!==gs.BLOCK_FOLDED&&(e===gs.BLOCK_LITERAL||!function(t,e,s){if(!e||e<0)return!1;const n=e-s,r=t.length;if(r<=n)return!1;for(let e=0,s=0;e<r;++e)if("\n"===t[e]){if(e-s>n)return!0;if(s=e+1,r-s<=n)return!1}return!0}(s,l,h.length));if(!s)return u?"|\n":">\n";let c,d;for(d=s.length;d>0;--d){const t=s[d-1];if("\n"!==t&&"\t"!==t&&" "!==t)break}let f=s.substring(d);const g=f.indexOf("\n");-1===g?c="-":s===f||g!==f.length-1?(c="+",i&&i()):c="",f&&(s=s.slice(0,-f.length),"\n"===f[f.length-1]&&(f=f.slice(0,-1)),f=f.replace(Rs,`$&${h}`));let m,p=!1,b=-1;for(m=0;m<s.length;++m){const t=s[m];if(" "===t)p=!0;else{if("\n"!==t)break;b=m}}let y=s.substring(0,b<m?b+1:m);y&&(s=s.substring(y.length),y=y.replace(/\n+/g,`$&${h}`));let S=(p?h?"2":"1":"")+c;if(t&&(S+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!u){const t=s.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${h}`);let r=!1;const i=Ns(n,!0);"folded"!==o&&e!==gs.BLOCK_FOLDED&&(i.onOverflow=()=>{r=!0});const a=_s(`${y}${t}${f}`,h,ws,i);if(!r)return`>${S}\n${h}${a}`}return`|${S}\n${h}${y}${s=s.replace(/\n+/g,`$&${h}`)}${f}`}function Ls(t,e,s,n){const{implicitKey:r,inFlow:i}=e,o="string"==typeof t.value?t:Object.assign({},t,{value:String(t.value)});let{type:a}=t;a!==gs.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=gs.QUOTE_DOUBLE);const l=t=>{switch(t){case gs.BLOCK_FOLDED:case gs.BLOCK_LITERAL:return r||i?Os(o.value,e):ks(o,e,s,n);case gs.QUOTE_DOUBLE:return Ts(o.value,e);case gs.QUOTE_SINGLE:return Is(o.value,e);case gs.PLAIN:return function(t,e,s,n){const{type:r,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:h,inFlow:u}=e;if(a&&i.includes("\n")||u&&/[[\]{},]/.test(i))return Os(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes("\n")?Os(i,e):ks(t,e,s,n);if(!a&&!u&&r!==gs.PLAIN&&i.includes("\n"))return ks(t,e,s,n);if(As(i)){if(""===l)return e.forceBlockIndent=!0,ks(t,e,s,n);if(a&&l===h)return Os(i,e)}const c=i.replace(/\n+/g,`$&\n${l}`);if(o){const t=t=>t.default&&"tag:yaml.org,2002:str"!==t.tag&&t.test?.test(c),{compat:s,tags:n}=e.doc.schema;if(n.some(t)||s?.some(t))return Os(i,e)}return a?c:_s(c,l,Cs,Ns(e,!1))}(o,e,s,n);default:return null}};let h=l(a);if(null===h){const{defaultKeyType:t,defaultStringType:s}=e.options,n=r&&t||s;if(h=l(n),null===h)throw new Error(`Unsupported default string type ${n}`)}return h}function Ms(t,e,s,n){if(Ve(t))return t.toString(e,s,n);if(Ue(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let r;const i=Ke(t)?t:e.doc.createNode(t,{onTagObj:t=>r=t});r??(r=function(t,e){if(e.tag){const s=t.filter(t=>t.tag===e.tag);if(s.length>0)return s.find(t=>t.format===e.format)??s[0]}let s,n;if(Ge(e)){n=e.value;let r=t.filter(t=>t.identify?.(n));if(r.length>1){const t=r.filter(t=>t.test);t.length>0&&(r=t)}s=r.find(t=>t.format===e.format)??r.find(t=>!t.format)}else n=e,s=t.find(t=>t.nodeClass&&n instanceof t.nodeClass);if(!s)throw new Error(`Tag not resolved for ${n?.constructor?.name??(null===n?"null":typeof n)} value`);return s}(e.doc.schema.tags,i));const o=function(t,e,{anchors:s,doc:n}){if(!n.directives)return"";const r=[],i=(Ge(t)||We(t))&&t.anchor;i&&as(i)&&(s.add(i),r.push(`&${i}`));const o=t.tag??(e.default?null:e.tag);return o&&r.push(n.directives.tagString(o)),r.join(" ")}(i,r,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const a="function"==typeof r.stringify?r.stringify(i,e,s,n):Ge(i)?Ls(i,e,s,n):i.toString(e,s,n);return o?Ge(i)||"{"===a[0]||"["===a[0]?`${o} ${a}`:`${o}\n${e.indent}${a}`:a}const Ps="<<",Bs={identify:t=>t===Ps||"symbol"==typeof t&&t.description===Ps,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new gs(Symbol(Ps)),{addToJSMap:$s}),stringify:()=>Ps};function $s(t,e,s){if(s=t&&Ue(s)?s.resolve(t.doc):s,ze(s))for(const n of s.items)Ds(t,e,n);else if(Array.isArray(s))for(const n of s)Ds(t,e,n);else Ds(t,e,s)}function Ds(t,e,s){const n=t&&Ue(s)?s.resolve(t.doc):s;if(!je(n))throw new Error("Merge sources must be maps or map aliases");const r=n.toJSON(null,t,Map);for(const[t,s]of r)e instanceof Map?e.has(t)||e.set(t,s):e instanceof Set?e.add(t):Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0});return e}function Us(t,e,{key:s,value:n}){if(Ke(s)&&s.addToJSMap)s.addToJSMap(t,e,n);else if(((t,e)=>(Bs.identify(e)||Ge(e)&&(!e.type||e.type===gs.PLAIN)&&Bs.identify(e.value))&&t?.doc.schema.tags.some(t=>t.tag===Bs.tag&&t.default))(t,s))$s(t,e,n);else{const r=hs(s,"",t);if(e instanceof Map)e.set(r,hs(n,r,t));else if(e instanceof Set)e.add(r);else{const i=function(t,e,s){if(null===e)return"";if("object"!=typeof e)return String(e);if(Ke(t)&&s?.doc){const e=function(t){const e=Object.assign({blockQuote:!0,commentString:ys,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,{});let s;switch(e.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:t,flowCollectionPadding:e.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof e.indent?" ".repeat(e.indent):" ",inFlow:s,options:e}}(s.doc);e.anchors=new Set;for(const t of s.anchors.keys())e.anchors.add(t.anchor);e.inFlow=!0,e.inStringifyKey=!0;const i=t.toString(e);if(!s.mapKeyWarned){let t=JSON.stringify(i);t.length>40&&(t=t.substring(0,36)+'..."'),r=`Keys with collection values will be stringified due to JS Object restrictions: ${t}. Set mapAsMap: true to use object keys.`,"debug"!==(n=s.doc.options.logLevel)&&"warn"!==n||console.warn(r),s.mapKeyWarned=!0}return i}var n,r;return JSON.stringify(e)}(s,r,t),o=hs(n,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function Fs(t,e,s){const n=ms(t,void 0,s),r=ms(e,void 0,s);return new js(n,r)}class js{constructor(t,e=null){Object.defineProperty(this,De,{value:Pe}),this.key=t,this.value=e}clone(t){let{key:e,value:s}=this;return Ke(e)&&(e=e.clone(t)),Ke(s)&&(s=s.clone(t)),new js(e,s)}toJSON(t,e){return Us(e,e?.mapAsMap?new Map:{},this)}toString(t,e,s){return t?.doc?function({key:t,value:e},s,n,r){const{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:h,indentSeq:u,simpleKeys:c}}=s;let d=Ke(t)&&t.comment||null;if(c){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(We(t)||!Ke(t)&&"object"==typeof t)throw new Error("With simple keys, collection cannot be used as a key value")}let f=!c&&(!t||d&&null==e&&!s.inFlow||We(t)||(Ge(t)?t.type===gs.BLOCK_FOLDED||t.type===gs.BLOCK_LITERAL:"object"==typeof t));s=Object.assign({},s,{allNullValues:!1,implicitKey:!f&&(c||!i),indent:a+l});let g,m,p,b=!1,y=!1,S=Ms(t,s,()=>b=!0,()=>y=!0);if(!f&&!s.inFlow&&S.length>1024){if(c)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(s.inFlow){if(i||null==e)return b&&n&&n(),""===S?"?":f?`? ${S}`:S}else if(i&&!c||null==e&&f)return S=`? ${S}`,d&&!b?S+=Es(S,s.indent,h(d)):y&&r&&r(),S;b&&(d=null),f?(d&&(S+=Es(S,s.indent,h(d))),S=`? ${S}\n${a}:`):(S=`${S}:`,d&&(S+=Es(S,s.indent,h(d)))),Ke(e)?(g=!!e.spaceBefore,m=e.commentBefore,p=e.comment):(g=!1,m=null,p=null,e&&"object"==typeof e&&(e=o.createNode(e))),s.implicitKey=!1,f||d||!Ge(e)||(s.indentAtStart=S.length+1),y=!1,u||!(l.length>=2)||s.inFlow||f||!ze(e)||e.flow||e.tag||e.anchor||(s.indent=s.indent.substring(2));let E=!1;const C=Ms(e,s,()=>E=!0,()=>y=!0);let w=" ";if(d||g||m)w=g?"\n":"",m&&(w+=`\n${Ss(h(m),s.indent)}`),""!==C||s.inFlow?w+=`\n${s.indent}`:"\n"===w&&p&&(w="\n\n");else if(!f&&We(e)){const t=C[0],n=C.indexOf("\n"),r=-1!==n,i=s.inFlow??e.flow??0===e.items.length;if(r||!i){let e=!1;if(r&&("&"===t||"!"===t)){let s=C.indexOf(" ");"&"===t&&-1!==s&&s<n&&"!"===C[s+1]&&(s=C.indexOf(" ",s+1)),(-1===s||n<s)&&(e=!0)}e||(w=`\n${s.indent}`)}}else""!==C&&"\n"!==C[0]||(w="");return S+=w+C,s.inFlow?E&&n&&n():p&&!E?S+=Es(S,s.indent,h(p)):y&&r&&r(),S}(this,t,e,s):JSON.stringify(this)}}function Vs(t,e,s){return(e.inFlow??t.flow?zs:Gs)(t,e,s)}function Gs({comment:t,items:e},s,{blockItemPrefix:n,flowChars:r,itemIndent:i,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:h}}=s,u=Object.assign({},s,{indent:i,type:null});let c=!1;const d=[];for(let t=0;t<e.length;++t){const r=e[t];let o=null;if(Ke(r))!c&&r.spaceBefore&&d.push(""),Ws(s,d,r.commentBefore,c),r.comment&&(o=r.comment);else if(Ve(r)){const t=Ke(r.key)?r.key:null;t&&(!c&&t.spaceBefore&&d.push(""),Ws(s,d,t.commentBefore,c))}c=!1;let a=Ms(r,u,()=>o=null,()=>c=!0);o&&(a+=Es(a,i,h(o))),c&&o&&(c=!1),d.push(n+a)}let f;if(0===d.length)f=r.start+r.end;else{f=d[0];for(let t=1;t<d.length;++t){const e=d[t];f+=e?`\n${l}${e}`:"\n"}}return t?(f+="\n"+Ss(h(t),l),a&&a()):c&&o&&o(),f}function zs({items:t},e,{flowChars:s,itemIndent:n}){const{indent:r,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;n+=i;const l=Object.assign({},e,{indent:n,inFlow:!0,type:null});let h=!1,u=0;const c=[];for(let s=0;s<t.length;++s){const r=t[s];let i=null;if(Ke(r))r.spaceBefore&&c.push(""),Ws(e,c,r.commentBefore,!1),r.comment&&(i=r.comment);else if(Ve(r)){const t=Ke(r.key)?r.key:null;t&&(t.spaceBefore&&c.push(""),Ws(e,c,t.commentBefore,!1),t.comment&&(h=!0));const s=Ke(r.value)?r.value:null;s?(s.comment&&(i=s.comment),s.commentBefore&&(h=!0)):null==r.value&&t?.comment&&(i=t.comment)}i&&(h=!0);let o=Ms(r,l,()=>i=null);s<t.length-1&&(o+=","),i&&(o+=Es(o,n,a(i))),!h&&(c.length>u||o.includes("\n"))&&(h=!0),c.push(o),u=c.length}const{start:d,end:f}=s;if(0===c.length)return d+f;if(!h){const t=c.reduce((t,e)=>t+e.length+2,2);h=e.options.lineWidth>0&&t>e.options.lineWidth}if(h){let t=d;for(const e of c)t+=e?`\n${i}${r}${e}`:"\n";return`${t}\n${r}${f}`}return`${d}${o}${c.join(" ")}${o}${f}`}function Ws({indent:t,options:{commentString:e}},s,n,r){if(n&&r&&(n=n.replace(/^\n+/,"")),n){const r=Ss(e(n),t);s.push(r.trimStart())}}function Ks(t,e){const s=Ge(e)?e.value:e;for(const n of t)if(Ve(n)){if(n.key===e||n.key===s)return n;if(Ge(n.key)&&n.key.value===s)return n}}class Hs extends bs{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Me,t),this.items=[]}static from(t,e,s){const{keepUndefined:n,replacer:r}=s,i=new this(t),o=(t,o)=>{if("function"==typeof r)o=r.call(e,t,o);else if(Array.isArray(r)&&!r.includes(t))return;(void 0!==o||n)&&i.items.push(Fs(t,o,s))};if(e instanceof Map)for(const[t,s]of e)o(t,s);else if(e&&"object"==typeof e)for(const t of Object.keys(e))o(t,e[t]);return"function"==typeof t.sortMapEntries&&i.items.sort(t.sortMapEntries),i}add(t,e){let s;s=Ve(t)?t:t&&"object"==typeof t&&"key"in t?new js(t.key,t.value):new js(t,t?.value);const n=Ks(this.items,s.key),r=this.schema?.sortMapEntries;if(n){if(!e)throw new Error(`Key ${s.key} already set`);Ge(n.value)&&fs(s.value)?n.value.value=s.value:n.value=s.value}else if(r){const t=this.items.findIndex(t=>r(s,t)<0);-1===t?this.items.push(s):this.items.splice(t,0,s)}else this.items.push(s)}delete(t){const e=Ks(this.items,t);return!!e&&this.items.splice(this.items.indexOf(e),1).length>0}get(t,e){const s=Ks(this.items,t),n=s?.value;return(!e&&Ge(n)?n.value:n)??void 0}has(t){return!!Ks(this.items,t)}set(t,e){this.add(new js(t,e),!0)}toJSON(t,e,s){const n=s?new s:e?.mapAsMap?new Map:{};e?.onCreate&&e.onCreate(n);for(const t of this.items)Us(e,n,t);return n}toString(t,e,s){if(!t)return JSON.stringify(this);for(const t of this.items)if(!Ve(t))throw new Error(`Map items must all be pairs; found ${JSON.stringify(t)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Vs(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:s,onComment:e})}}const qs={collection:"map",default:!0,nodeClass:Hs,tag:"tag:yaml.org,2002:map",resolve:(t,e)=>(je(t)||e("Expected a mapping for this tag"),t),createNode:(t,e,s)=>Hs.from(t,e,s)};class Qs extends bs{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super($e,t),this.items=[]}add(t){this.items.push(t)}delete(t){const e=Js(t);return"number"==typeof e&&this.items.splice(e,1).length>0}get(t,e){const s=Js(t);if("number"!=typeof s)return;const n=this.items[s];return!e&&Ge(n)?n.value:n}has(t){const e=Js(t);return"number"==typeof e&&e<this.items.length}set(t,e){const s=Js(t);if("number"!=typeof s)throw new Error(`Expected a valid index, not ${t}.`);const n=this.items[s];Ge(n)&&fs(e)?n.value=e:this.items[s]=e}toJSON(t,e){const s=[];e?.onCreate&&e.onCreate(s);let n=0;for(const t of this.items)s.push(hs(t,String(n++),e));return s}toString(t,e,s){return t?Vs(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:s,onComment:e}):JSON.stringify(this)}static from(t,e,s){const{replacer:n}=s,r=new this(t);if(e&&Symbol.iterator in Object(e)){let t=0;for(let i of e){if("function"==typeof n){const s=e instanceof Set?i:String(t++);i=n.call(e,s,i)}r.items.push(ms(i,void 0,s))}}return r}}function Js(t){let e=Ge(t)?t.value:t;return e&&"string"==typeof e&&(e=Number(e)),"number"==typeof e&&Number.isInteger(e)&&e>=0?e:null}const Ys={collection:"seq",default:!0,nodeClass:Qs,tag:"tag:yaml.org,2002:seq",resolve:(t,e)=>(ze(t)||e("Expected a sequence for this tag"),t),createNode:(t,e,s)=>Qs.from(t,e,s)},Xs={identify:t=>"string"==typeof t,default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:(t,e,s,n)=>Ls(t,e=Object.assign({actualString:!0},e),s,n)},Zs={identify:t=>null==t,createNode:()=>new gs(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new gs(null),stringify:({source:t},e)=>"string"==typeof t&&Zs.test.test(t)?t:e.options.nullStr},tn={identify:t=>"boolean"==typeof t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new gs("t"===t[0]||"T"===t[0]),stringify:({source:t,value:e},s)=>t&&tn.test.test(t)&&e===("t"===t[0]||"T"===t[0])?t:e?s.options.trueStr:s.options.falseStr};function en({format:t,minFractionDigits:e,tag:s,value:n}){if("bigint"==typeof n)return String(n);const r="number"==typeof n?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!t&&e&&(!s||"tag:yaml.org,2002:float"===s)&&/^\d/.test(i)){let t=i.indexOf(".");t<0&&(t=i.length,i+=".");let s=e-(i.length-t-1);for(;s-- >0;)i+="0"}return i}const sn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>"nan"===t.slice(-3).toLowerCase()?NaN:"-"===t[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:en},nn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){const e=Number(t.value);return isFinite(e)?e.toExponential():en(t)}},rn=t=>"bigint"==typeof t||Number.isInteger(t),on=(t,e,s,{intAsBigInt:n})=>n?BigInt(t):parseInt(t.substring(e),s);function an(t,e,s){const{value:n}=t;return rn(n)&&n>=0?s+n.toString(e):en(t)}const ln=[qs,Ys,Xs,Zs,tn,{identify:t=>rn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,s)=>on(t,2,8,s),stringify:t=>an(t,8,"0o")},{identify:rn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,s)=>on(t,0,10,s),stringify:en},{identify:t=>rn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,s)=>on(t,2,16,s),stringify:t=>an(t,16,"0x")},sn,nn,{identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){const e=new gs(parseFloat(t)),s=t.indexOf(".");return-1!==s&&"0"===t[t.length-1]&&(e.minFractionDigits=t.length-s-1),e},stringify:en}];function hn(t){return"bigint"==typeof t||Number.isInteger(t)}const un=({value:t})=>JSON.stringify(t),cn=[qs,Ys].concat([{identify:t=>"string"==typeof t,default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:un},{identify:t=>null==t,createNode:()=>new gs(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:un},{identify:t=>"boolean"==typeof t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>"true"===t,stringify:un},{identify:hn,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:s})=>s?BigInt(t):parseInt(t,10),stringify:({value:t})=>hn(t)?t.toString():JSON.stringify(t)},{identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:un}],{default:!0,tag:"",test:/^/,resolve:(t,e)=>(e(`Unresolved plain scalar ${JSON.stringify(t)}`),t)}),dn={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if("function"==typeof atob){const e=atob(t.replace(/[\n\r]/g,"")),s=new Uint8Array(e.length);for(let t=0;t<e.length;++t)s[t]=e.charCodeAt(t);return s}return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:s},n,r,i){if(!s)return"";const o=s;let a;if("function"!=typeof btoa)throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");{let t="";for(let e=0;e<o.length;++e)t+=String.fromCharCode(o[e]);a=btoa(t)}if(e??(e=gs.BLOCK_LITERAL),e!==gs.QUOTE_DOUBLE){const t=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),s=Math.ceil(a.length/t),r=new Array(s);for(let e=0,n=0;e<s;++e,n+=t)r[e]=a.substr(n,t);a=r.join(e===gs.BLOCK_LITERAL?"\n":" ")}return Ls({comment:t,type:e,value:a},n,r,i)}};function fn(t,e){if(ze(t))for(let s=0;s<t.items.length;++s){let n=t.items[s];if(!Ve(n)){if(je(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");const t=n.items[0]||new js(new gs(null));if(n.commentBefore&&(t.key.commentBefore=t.key.commentBefore?`${n.commentBefore}\n${t.key.commentBefore}`:n.commentBefore),n.comment){const e=t.value??t.key;e.comment=e.comment?`${n.comment}\n${e.comment}`:n.comment}n=t}t.items[s]=Ve(n)?n:new js(n)}}else e("Expected a sequence for this tag");return t}function gn(t,e,s){const{replacer:n}=s,r=new Qs(t);r.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let t of e){let o,a;if("function"==typeof n&&(t=n.call(e,String(i++),t)),Array.isArray(t)){if(2!==t.length)throw new TypeError(`Expected [key, value] tuple: ${t}`);o=t[0],a=t[1]}else if(t&&t instanceof Object){const e=Object.keys(t);if(1!==e.length)throw new TypeError(`Expected tuple with one key, not ${e.length} keys`);o=e[0],a=t[o]}else o=t;r.items.push(Fs(o,a,s))}return r}const mn={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:fn,createNode:gn};class pn extends Qs{constructor(){super(),this.add=Hs.prototype.add.bind(this),this.delete=Hs.prototype.delete.bind(this),this.get=Hs.prototype.get.bind(this),this.has=Hs.prototype.has.bind(this),this.set=Hs.prototype.set.bind(this),this.tag=pn.tag}toJSON(t,e){if(!e)return super.toJSON(t);const s=new Map;e?.onCreate&&e.onCreate(s);for(const t of this.items){let n,r;if(Ve(t)?(n=hs(t.key,"",e),r=hs(t.value,n,e)):n=hs(t,"",e),s.has(n))throw new Error("Ordered maps must not include duplicate keys");s.set(n,r)}return s}static from(t,e,s){const n=gn(t,e,s),r=new this;return r.items=n.items,r}}pn.tag="tag:yaml.org,2002:omap";const bn={collection:"seq",identify:t=>t instanceof Map,nodeClass:pn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){const s=fn(t,e),n=[];for(const{key:t}of s.items)Ge(t)&&(n.includes(t.value)?e(`Ordered maps must not include duplicate keys: ${t.value}`):n.push(t.value));return Object.assign(new pn,s)},createNode:(t,e,s)=>pn.from(t,e,s)};function yn({value:t,source:e},s){return e&&(t?Sn:En).test.test(e)?e:t?s.options.trueStr:s.options.falseStr}const Sn={identify:t=>!0===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new gs(!0),stringify:yn},En={identify:t=>!1===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new gs(!1),stringify:yn},Cn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>"nan"===t.slice(-3).toLowerCase()?NaN:"-"===t[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:en},wn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){const e=Number(t.value);return isFinite(e)?e.toExponential():en(t)}},vn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){const e=new gs(parseFloat(t.replace(/_/g,""))),s=t.indexOf(".");if(-1!==s){const n=t.substring(s+1).replace(/_/g,"");"0"===n[n.length-1]&&(e.minFractionDigits=n.length)}return e},stringify:en},_n=t=>"bigint"==typeof t||Number.isInteger(t);function xn(t,e,s,{intAsBigInt:n}){const r=t[0];if("-"!==r&&"+"!==r||(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(s){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`}const e=BigInt(t);return"-"===r?BigInt(-1)*e:e}const i=parseInt(t,s);return"-"===r?-1*i:i}function Nn(t,e,s){const{value:n}=t;if(_n(n)){const t=n.toString(e);return n<0?"-"+s+t.substr(1):s+t}return en(t)}const An={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,s)=>xn(t,2,2,s),stringify:t=>Nn(t,2,"0b")},Tn={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,s)=>xn(t,1,8,s),stringify:t=>Nn(t,8,"0")},In={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,s)=>xn(t,0,10,s),stringify:en},On={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,s)=>xn(t,2,16,s),stringify:t=>Nn(t,16,"0x")};class Rn extends Hs{constructor(t){super(t),this.tag=Rn.tag}add(t){let e;e=Ve(t)?t:t&&"object"==typeof t&&"key"in t&&"value"in t&&null===t.value?new js(t.key,null):new js(t,null),Ks(this.items,e.key)||this.items.push(e)}get(t,e){const s=Ks(this.items,t);return!e&&Ve(s)?Ge(s.key)?s.key.value:s.key:s}set(t,e){if("boolean"!=typeof e)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof e);const s=Ks(this.items,t);s&&!e?this.items.splice(this.items.indexOf(s),1):!s&&e&&this.items.push(new js(t))}toJSON(t,e){return super.toJSON(t,e,Set)}toString(t,e,s){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),e,s);throw new Error("Set items must all have null values")}static from(t,e,s){const{replacer:n}=s,r=new this(t);if(e&&Symbol.iterator in Object(e))for(let t of e)"function"==typeof n&&(t=n.call(e,t,t)),r.items.push(Fs(t,null,s));return r}}Rn.tag="tag:yaml.org,2002:set";const kn={collection:"map",identify:t=>t instanceof Set,nodeClass:Rn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,s)=>Rn.from(t,e,s),resolve(t,e){if(je(t)){if(t.hasAllNullValues(!0))return Object.assign(new Rn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function Ln(t,e){const s=t[0],n="-"===s||"+"===s?t.substring(1):t,r=t=>e?BigInt(t):Number(t),i=n.replace(/_/g,"").split(":").reduce((t,e)=>t*r(60)+r(e),r(0));return"-"===s?r(-1)*i:i}function Mn(t){let{value:e}=t,s=t=>t;if("bigint"==typeof e)s=t=>BigInt(t);else if(isNaN(e)||!isFinite(e))return en(t);let n="";e<0&&(n="-",e*=s(-1));const r=s(60),i=[e%r];return e<60?i.unshift(0):(e=(e-i[0])/r,i.unshift(e%r),e>=60&&(e=(e-i[0])/r,i.unshift(e))),n+i.map(t=>String(t).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Pn={identify:t=>"bigint"==typeof t||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:s})=>Ln(t,s),stringify:Mn},Bn={identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Ln(t,!1),stringify:Mn},$n={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){const e=t.match($n.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,s,n,r,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0;let h=Date.UTC(s,n-1,r,i||0,o||0,a||0,l);const u=e[8];if(u&&"Z"!==u){let t=Ln(u,!1);Math.abs(t)<30&&(t*=60),h-=6e4*t}return new Date(h)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Dn=[qs,Ys,Xs,Zs,Sn,En,An,Tn,In,On,Cn,wn,vn,dn,Bs,bn,mn,kn,Pn,Bn,$n];new Map([["core",ln],["failsafe",[qs,Ys,Xs]],["json",cn],["yaml11",Dn],["yaml-1.1",Dn]]),Error;const Un=Symbol("break visit"),Fn=Symbol("skip children"),jn=Symbol("remove item");function Vn(t,e){"type"in t&&"document"===t.type&&(t={start:t.start,value:t.value}),Gn(Object.freeze([]),t,e)}function Gn(t,e,s){let n=s(e,t);if("symbol"==typeof n)return n;for(const r of["key","value"]){const i=e[r];if(i&&"items"in i){for(let e=0;e<i.items.length;++e){const n=Gn(Object.freeze(t.concat([[r,e]])),i.items[e],s);if("number"==typeof n)e=n-1;else{if(n===Un)return Un;n===jn&&(i.items.splice(e,1),e-=1)}}"function"==typeof n&&"key"===r&&(n=n(e,t))}}return"function"==typeof n?n(e,t):n}var zn;Vn.BREAK=Un,Vn.SKIP=Fn,Vn.REMOVE=jn,Vn.itemAtPath=(t,e)=>{let s=t;for(const[t,n]of e){const e=s?.[t];if(!e||!("items"in e))return;s=e.items[n]}return s},Vn.parentCollection=(t,e)=>{const s=Vn.itemAtPath(t,e.slice(0,-1)),n=e[e.length-1][0],r=s?.[n];if(r&&"items"in r)return r;throw new Error("Parent collection not found")},new Set("0123456789ABCDEFabcdef"),new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),new Set(",[]{}"),new Set(" ,[]{}\n\r\t"),p.ONE,function(t){t.Kampitham="Kampitham",t.Nokku="Nokku",t.Spuritham="Spuritham",t.Prathyagatham="Prathyagatham",t.Aahaatam_Raavi="Raavi",t.Aahaatam_Kandippu="Kandippu",t.Vaali="Vaali",t.Odukkal="Odukkal",t.Jaaru_Eetra="EetraJaaru",t.Jaaru_Irakka="IrakkaJaaru",t.Orikkai="Orikkai"}(zn||(zn={}));class Wn{constructor(){this.shapeId=Wn.idCounter++,this._x=null,this._y=null,this._width=null,this._height=null,this.parentShape=null,this.children=[]}get bbox(){return this._bbox||(this._bbox=this.refreshBBox()),this._bbox}get minSize(){return this._minSize||(this._minSize=this.refreshMinSize()),this._minSize}invalidateBounds(){this._minSize=null,this._bbox=null}setBounds(t,e,s,n,r=!1){null!=t&&(isNaN(t)?this._x=null:this._x=t),null!=e&&(isNaN(e)?this._y=null:this._y=e),null!=s&&(isNaN(s)?this._width=null:this._width=s),null!=n&&(isNaN(n)?this._height=null:this._height=n);const[i,o,a,l]=this.updateBounds(t,e,s,n);return null!=i&&(isNaN(i)?this._x=null:this._x=i),null!=o&&(isNaN(o)?this._y=null:this._y=o),null!=a&&(isNaN(a)?this._width=null:this._width=a),null!=l&&(isNaN(l)?this._height=null:this._height=l),r&&this.refreshLayout(),[i,o,a,l]}get hasX(){return null!=this._x&&!isNaN(this._x)}get hasY(){return null!=this._y&&!isNaN(this._y)}get hasWidth(){return null!=this._width&&!isNaN(this._width)}get hasHeight(){return null!=this._height&&!isNaN(this._height)}get x(){return this._x||0}set x(t){this.setBounds(null==t?NaN:t,null,null,null)}get y(){return null!=this._y?this._y:0}set y(t){this.setBounds(null,null==t?NaN:t,null,null)}get width(){return null!=this._width?this._width:0}set width(t){this.setBounds(null,null,null==t?NaN:t,null)}get height(){return null!=this._height?this._height:0}set height(t){this.setBounds(null,null,null,null==t?NaN:t)}refreshLayout(){}}Wn.idCounter=0;const Kn=p.ONE,[Hn]=(Kn.timesNum(2),function(t,e=null){const s=e||{},[n,r,i]=function(t,e=null){const s=e||{},[n,r]=function(t,e){const s=new et((e=e||{}).grammar||{}),n=new fe(t,{...e,grammar:s}),r=n.generatedTokenizer.next.bind(n.generatedTokenizer);return(e.debug||"").split("|").findIndex(t=>"all"==t||"lexer"==t)>=0&&console.log("Prog: \n",`${n.generatedTokenizer.vm.prog.debugValue().join("\n")}`),[s,r]}(t,s);n.augmentStartSymbol();const[i,o]=function(t,e="lr1"){switch(e){case"lr1":return function(t){const e=new Ae(t).refresh();return[Oe(e,t),e]}(t);case"lalr":return function(t){const[e,s]=Te(t);if(!e.hasConflicts)return[e,s];const n=function(t,e){const s=new et;function n(t,n){const r=`[${t}:${n.label}]`,i=s.ensureSym(new Y(s,r,n.isTerminal),!1);return 0!=t||e.startSymbol!=n||e.startSymbol==i||n.isTerminal||(s.startSymbol=i),i}for(const s in t.gotoSets){const r=t.gotoSets[s];for(const t in r)n(s,e.getSymById(t))}function r(e,s,r){let i=e;const o=r.rhs.syms.map((e,s)=>{const r=n(i,e),o=t.gotoSets[i][e.id]||null;return a(null!=o,"Next set transition *must* be valid"),i=o.id,r});return new X(...o)}for(const i in t.gotoSets){const o=t.gotoSets[i];for(const t in o){const o=e.getSymById(t),a=i;if(!o.isTerminal){const t=n(a,o);e.forEachRule(o,(e,n)=>{const i=r(a,0,e),o=new tt(t,i);s.addRule(o)})}}}return s}(s,t),r={};for(const t in s.gotoSets)for(const e in s.gotoSets[t]){const n=s.gotoSets[t][e];n.id in r||(r[n.id]={}),e in r[n.id]||(r[n.id][e]=new Set),r[n.id][e].add(t)}for(const i in e.conflictActions){const e=s.itemSets.get(i);Re(t,n,s,e,r)}return[Oe(s,t),s]}(t)}return Te(t)}(n,s.type);return[i,r,o]}(t,s),o=new we(n);return(s.tokenizer||r)&&o.setTokenizer(s.tokenizer||r),(s.debug||"").split("|").findIndex(t=>"all"==t||"parser"==t)>=0&&function(t,e){const s=t.grammar,n=t.parseTable;console.log("===============================\nGrammar (as default): \n",s.debugValue.map((t,e)=>`${e+1} - ${t}`),"===============================\nGrammar (as Bison): \n",s.debugValue.map((t,e)=>`${t.replace("->",":")} ; \n`).join(""),"===============================\nParseTable: \n",JSON.stringify(function(t,e){const s={},n=t.debugValue,r=e?.debugValue;for(const t in n){const i=n[t];if(e){const e=r[t];s[t]={items:e.items,actions:i,goto:e.goto}}else s[t]=i}return s}(n,e),null,4),"===============================\nConflicts: \n",n.conflictActions)}(o,i),[o,r,i]}(String.raw`
|
|
3
2
|
%define IdentChar /[^%!@$#&\^|\[\]={}()<>+\-,;~: \t\f\r\n\v\\\.\'\"]/
|
|
4
3
|
|
|
5
4
|
%token BSLASH "\\"
|
|
@@ -113,5 +112,5 @@
|
|
|
113
112
|
|
|
114
113
|
Duration -> Fraction | NUMBER;
|
|
115
114
|
Fraction -> NUMBER SLASH NUMBER { newFraction } ;
|
|
116
|
-
`,{
|
|
115
|
+
`,{debug:"",type:"lalr",leftRecursive:!0,tokenHandlers:{toEmbelishment:(t,e,s)=>{const[n,r]=s.parseEmbelishment(t.value);return null==n?(console.log("Skipping Embelishment: ",t.value),s.errors.push(new jt(`Invalid embelishment: ${t.value}`,t.start,1+t.end-t.start,"InvalidEmbelishment",t.value)),null):(t.value=n,t.tag=r?"PRE_EMB":"POST_EMB",t)},toCommandName:(t,e,s)=>(t.value=t.value.substring(1),t),toBoolean:(t,e,s)=>(t.value="true"==t.value,t),toNumber:(t,e,s)=>(t.value=parseInt(t.value),t),toString:(t,e,s)=>(t.value=t.value.substring(1,t.value.length-1),t),toMarker:(t,e,s)=>{if("PRE_MARKER"!=t.tag&&"POST_MARKER"!=t.tag)throw new Error("Invalid token for converting to note: "+t.tag);const n="PRE_MARKER"==t.tag,r=n?t.value.substring(1,t.value.length-3):t.value.substring(3,t.value.length-1);return t.value=new T(r,n),t},toOctavedNote:(t,e,s)=>{if("DOTS_IDENT"==t.tag){const e=t.positions[1][1]-t.positions[1][0],s=t.value.substring(e);t.value=new R(s,Kn,-e)}else{if("IDENT_DOTS"!=t.tag)throw new Error("Invalid token for converting to note: "+t.tag);{const e=t.positions[2][1]-t.positions[2][0],s=t.value.substring(0,t.value.length-e);t.value=new R(s,Kn,e)}}return t},toRoleSelector:(t,e,s)=>(t.value=t.value.substring(0,t.value.length-1),t),toLineAnnotation:(t,e,s)=>(t.value=t.value.substring(1),t),toSingleLineRawString:(t,e,s)=>(t.value=t.value.substring(1),t),toMultiLineRawString:(t,e,s)=>{const n='"'+e.substring(t.positions[1][0],t.positions[1][1]),r=e.index,i=Wt.advanceAfter(e,n)-n.length;if(i<0)throw new Error("EOF expected while finding end of Raw String Literal: '"+n+"'");return t.value=e.substring(r,i),t},toFrontMatter:(t,e,s)=>{const n=e.index,r=Wt.advanceAfter(e,"\n---")-4;if(r<0)throw new Error("EOF expected while finding end of front matter");return t.value=e.substring(n,r),t}}}));return r.default})());
|
|
117
116
|
//# sourceMappingURL=notations.umd.min.js.map
|