@mongodb-js/compass-web 0.36.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/106.e50960c29b57a8b92ec5.mjs +2 -0
  2. package/dist/{20.f2c2353886886939e128.mjs.LICENSE.txt → 106.e50960c29b57a8b92ec5.mjs.LICENSE.txt} +6 -0
  3. package/dist/128.2ec06394c7c1718c925f.mjs +1 -0
  4. package/dist/14.ee5055b184ec8814d6f7.mjs +2 -0
  5. package/dist/{938.e127bbcdd0ce0eab8722.mjs.LICENSE.txt → 14.ee5055b184ec8814d6f7.mjs.LICENSE.txt} +5 -17
  6. package/dist/260.52fdf61d69ac2a2921dc.mjs +2 -0
  7. package/dist/260.52fdf61d69ac2a2921dc.mjs.LICENSE.txt +13 -0
  8. package/dist/302.34205d8fa79ef45d79b5.mjs +1 -0
  9. package/dist/318.ca5407b8a126de079455.mjs +2 -0
  10. package/dist/318.ca5407b8a126de079455.mjs.LICENSE.txt +34 -0
  11. package/dist/560.e85e11aa098b341006f3.mjs +23 -0
  12. package/dist/568.5af0b00ce345e98d8b78.mjs +1 -0
  13. package/dist/714.fde8d188a97cdddc2703.mjs +344 -0
  14. package/dist/717.e27dd37bf389fe1e1fe3.mjs +1 -0
  15. package/dist/810.c52538ab1ee7a0892ac8.mjs +2 -0
  16. package/dist/{832.a6fb147f7fd965a7f30c.mjs.LICENSE.txt → 810.c52538ab1ee7a0892ac8.mjs.LICENSE.txt} +0 -7
  17. package/dist/assets-manifest.json +13 -11
  18. package/dist/compass-web.d.ts +8 -291
  19. package/dist/compass-web.mjs +20 -48
  20. package/dist/index-0b9a48a6.e104f028edf21b1c2537.mjs +29 -0
  21. package/dist/index-bde52cb3.96252163ac8fa874fc4c.mjs +1 -0
  22. package/package.json +40 -40
  23. package/dist/149.abccc0e903c0f5ea7354.mjs +0 -372
  24. package/dist/20.f2c2353886886939e128.mjs +0 -2
  25. package/dist/207.d69541eff41412663f35.mjs +0 -2
  26. package/dist/207.d69541eff41412663f35.mjs.LICENSE.txt +0 -8
  27. package/dist/563.mjs +0 -1
  28. package/dist/566.513352a4be9e2a46530b.mjs +0 -23
  29. package/dist/68.f1ca0ed16b5fa27e2cf1.mjs +0 -1
  30. package/dist/69.mjs +0 -1
  31. package/dist/724.8aae14d079e334751961.mjs +0 -8
  32. package/dist/724.8aae14d079e334751961.mjs.LICENSE.txt +0 -5
  33. package/dist/737.mjs +0 -1
  34. package/dist/745.mjs +0 -1
  35. package/dist/832.a6fb147f7fd965a7f30c.mjs +0 -2
  36. package/dist/938.e127bbcdd0ce0eab8722.mjs +0 -2
  37. package/dist/965.3c1bdf715c3551cfe1ba.mjs +0 -1
  38. package/dist/995.c3bb8ac49cdffa0211da.mjs +0 -2
  39. package/dist/995.c3bb8ac49cdffa0211da.mjs.LICENSE.txt +0 -11
  40. package/dist/index-bde52cb3.a964d5743a224d2efb82.mjs +0 -1
  41. /package/dist/{566.513352a4be9e2a46530b.mjs.LICENSE.txt → 560.e85e11aa098b341006f3.mjs.LICENSE.txt} +0 -0
  42. /package/dist/{149.abccc0e903c0f5ea7354.mjs.LICENSE.txt → 714.fde8d188a97cdddc2703.mjs.LICENSE.txt} +0 -0
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 810.c52538ab1ee7a0892ac8.mjs.LICENSE.txt */
2
+ export const __webpack_esm_id__=810;export const __webpack_esm_ids__=[810];export const __webpack_esm_modules__={162:(t,e,r)=>{var n=r(86291).Token,o=r(43125).q,i=r(43125).X;function s(){return this._listeners=[o.INSTANCE],this._interp=null,this._stateNumber=-1,this}s.tokenTypeMapCache={},s.ruleIndexMapCache={},s.prototype.checkVersion=function(t){"4.7.2"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.7.2!="+t)},s.prototype.addErrorListener=function(t){this._listeners.push(t)},s.prototype.removeErrorListeners=function(){this._listeners=[]},s.prototype.getTokenTypeMap=function(){var t=this.getTokenNames();if(null===t)throw"The current recognizer does not provide a list of token names.";var e=this.tokenTypeMapCache[t];return void 0===e&&((e=t.reduce((function(t,e,r){t[e]=r}))).EOF=n.EOF,this.tokenTypeMapCache[t]=e),e},s.prototype.getRuleIndexMap=function(){var t=this.ruleNames;if(null===t)throw"The current recognizer does not provide a list of rule names.";var e=this.ruleIndexMapCache[t];return void 0===e&&(e=t.reduce((function(t,e,r){t[e]=r})),this.ruleIndexMapCache[t]=e),e},s.prototype.getTokenType=function(t){var e=this.getTokenTypeMap()[t];return void 0!==e?e:n.INVALID_TYPE},s.prototype.getErrorHeader=function(t){return"line "+t.getOffendingToken().line+":"+t.getOffendingToken().column},s.prototype.getTokenErrorDisplay=function(t){if(null===t)return"<no token>";var e=t.text;return null===e&&(e=t.type===n.EOF?"<EOF>":"<"+t.type+">"),"'"+(e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"))+"'"},s.prototype.getErrorListenerDispatch=function(){return new i(this._listeners)},s.prototype.sempred=function(t,e,r){return!0},s.prototype.precpred=function(t,e){return!0},Object.defineProperty(s.prototype,"state",{get:function(){return this._stateNumber},set:function(t){this._stateNumber=t}}),e.f=s},441:(t,e)=>{function r(){}r.LEXER=0,r.PARSER=1,e.E=r},512:()=>{var t,e,r,n;String.fromCodePoint||(t=function(){try{var t={},e=Object.defineProperty,r=e(t,t,t)&&e}catch(t){}return r}(),e=String.fromCharCode,r=Math.floor,n=function(t){var n,o,i=[],s=-1,a=arguments.length;if(!a)return"";for(var l="";++s<a;){var u=Number(arguments[s]);if(!isFinite(u)||u<0||u>1114111||r(u)!=u)throw RangeError("Invalid code point: "+u);u<=65535?i.push(u):(n=55296+((u-=65536)>>10),o=u%1024+56320,i.push(n,o)),(s+1==a||i.length>16384)&&(l+=e.apply(null,i),i.length=0)}return l},t?t(String,"fromCodePoint",{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n)},1754:(t,e,r)=>{var n=r(56975).m,o=r(5527).Hash;function i(t){this.cachedHashCode=t}function s(){return this.cache={},this}function a(t,e){var r=0;if(null!==t){var n=new o;n.update(t,e),r=n.finish()}i.call(this,r),this.parentCtx=t,this.returnState=e}function l(){return a.call(this,null,i.EMPTY_RETURN_STATE),this}function u(t,e){var r=new o;r.update(t,e);var n=r.finish();return i.call(this,n),this.parents=t,this.returnStates=e,this}i.EMPTY=null,i.EMPTY_RETURN_STATE=2147483647,i.globalNodeCount=1,i.id=i.globalNodeCount,i.prototype.isEmpty=function(){return this===i.EMPTY},i.prototype.hasEmptyPath=function(){return this.getReturnState(this.length-1)===i.EMPTY_RETURN_STATE},i.prototype.hashCode=function(){return this.cachedHashCode},i.prototype.updateHashCode=function(t){t.update(this.cachedHashCode)},s.prototype.add=function(t){if(t===i.EMPTY)return i.EMPTY;var e=this.cache[t]||null;return null!==e?e:(this.cache[t]=t,t)},s.prototype.get=function(t){return this.cache[t]||null},Object.defineProperty(s.prototype,"length",{get:function(){return this.cache.length}}),a.prototype=Object.create(i.prototype),a.prototype.contructor=a,a.create=function(t,e){return e===i.EMPTY_RETURN_STATE&&null===t?i.EMPTY:new a(t,e)},Object.defineProperty(a.prototype,"length",{get:function(){return 1}}),a.prototype.getParent=function(t){return this.parentCtx},a.prototype.getReturnState=function(t){return this.returnState},a.prototype.equals=function(t){return this===t||t instanceof a&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))},a.prototype.toString=function(){var t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===i.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.isEmpty=function(){return!0},l.prototype.getParent=function(t){return null},l.prototype.getReturnState=function(t){return this.returnState},l.prototype.equals=function(t){return this===t},l.prototype.toString=function(){return"$"},i.EMPTY=new l,u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.isEmpty=function(){return this.returnStates[0]===i.EMPTY_RETURN_STATE},Object.defineProperty(u.prototype,"length",{get:function(){return this.returnStates.length}}),u.prototype.getParent=function(t){return this.parents[t]},u.prototype.getReturnState=function(t){return this.returnStates[t]},u.prototype.equals=function(t){return this===t||t instanceof u&&this.hashCode()===t.hashCode()&&this.returnStates===t.returnStates&&this.parents===t.parents},u.prototype.toString=function(){if(this.isEmpty())return"[]";for(var t="[",e=0;e<this.returnStates.length;e++)e>0&&(t+=", "),this.returnStates[e]!==i.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"},e.merge=function t(e,r,n,o){if(e===r)return e;if(e instanceof a&&r instanceof a)return function(e,r,n,o){if(null!==o){var s=o.get(e,r);if(null!==s)return s;if(null!==(s=o.get(r,e)))return s}var l=function(t,e,r){if(r){if(t===i.EMPTY)return i.EMPTY;if(e===i.EMPTY)return i.EMPTY}else{if(t===i.EMPTY&&e===i.EMPTY)return i.EMPTY;if(t===i.EMPTY){var n=[e.returnState,i.EMPTY_RETURN_STATE];return new u([e.parentCtx,null],n)}if(e===i.EMPTY)return n=[t.returnState,i.EMPTY_RETURN_STATE],new u([t.parentCtx,null],n)}return null}(e,r,n);if(null!==l)return null!==o&&o.set(e,r,l),l;if(e.returnState===r.returnState){var p=t(e.parentCtx,r.parentCtx,n,o);if(p===e.parentCtx)return e;if(p===r.parentCtx)return r;var c=a.create(p,e.returnState);return null!==o&&o.set(e,r,c),c}var h=null;if((e===r||null!==e.parentCtx&&e.parentCtx===r.parentCtx)&&(h=e.parentCtx),null!==h){var d=[e.returnState,r.returnState];e.returnState>r.returnState&&(d[0]=r.returnState,d[1]=e.returnState);var f=new u(m=[h,h],d);return null!==o&&o.set(e,r,f),f}d=[e.returnState,r.returnState];var m=[e.parentCtx,r.parentCtx];e.returnState>r.returnState&&(d[0]=r.returnState,d[1]=e.returnState,m=[r.parentCtx,e.parentCtx]);var g=new u(m,d);return null!==o&&o.set(e,r,g),g}(e,r,n,o);if(n){if(e instanceof l)return e;if(r instanceof l)return r}return e instanceof a&&(e=new u([e.getParent()],[e.returnState])),r instanceof a&&(r=new u([r.getParent()],[r.returnState])),function(e,r,n,o){if(null!==o){var s=o.get(e,r);if(null!==s)return s;if(null!==(s=o.get(r,e)))return s}for(var l=0,p=0,c=0,h=[],d=[];l<e.returnStates.length&&p<r.returnStates.length;){var f=e.parents[l],m=r.parents[p];if(e.returnStates[l]===r.returnStates[p]){var g=e.returnStates[l];if(g===i.EMPTY_RETURN_STATE&&null===f&&null===m||null!==f&&null!==m&&f===m)d[c]=f,h[c]=g;else{var y=t(f,m,n,o);d[c]=y,h[c]=g}l+=1,p+=1}else e.returnStates[l]<r.returnStates[p]?(d[c]=f,h[c]=e.returnStates[l],l+=1):(d[c]=m,h[c]=r.returnStates[p],p+=1);c+=1}if(l<e.returnStates.length)for(var v=l;v<e.returnStates.length;v++)d[c]=e.parents[v],h[c]=e.returnStates[v],c+=1;else for(v=p;v<r.returnStates.length;v++)d[c]=r.parents[v],h[c]=r.returnStates[v],c+=1;if(c<d.length){if(1===c){var x=a.create(d[0],h[0]);return null!==o&&o.set(e,r,x),x}d=d.slice(0,c),h=h.slice(0,c)}var T=new u(d,h);return T===e?(null!==o&&o.set(e,r,e),e):T===r?(null!==o&&o.set(e,r,r),r):(function(t){for(var e={},r=0;r<t.length;r++){var n=t[r];n in e||(e[n]=n)}for(var o=0;o<t.length;o++)t[o]=e[t[o]]}(d),null!==o&&o.set(e,r,T),T)}(e,r,n,o)},e.PredictionContext=i,e.PredictionContextCache=s,e.SingletonPredictionContext=a,e.predictionContextFromRuleContext=function t(e,r){if(null==r&&(r=n.EMPTY),null===r.parentCtx||r===n.EMPTY)return i.EMPTY;var o=t(e,r.parentCtx),s=e.states[r.invokingState].transitions[0];return a.create(o,s.followState.stateNumber)},e.getCachedPredictionContext=function t(e,r,n){if(e.isEmpty())return e;var o=n[e]||null;if(null!==o)return o;if(null!==(o=r.get(e)))return n[e]=o,o;for(var s=!1,l=[],p=0;p<l.length;p++){var c=t(e.getParent(p),r,n);if(s||c!==e.getParent(p)){if(!s){l=[];for(var h=0;h<e.length;h++)l[h]=e.getParent(h);s=!0}l[p]=c}}if(!s)return r.add(e),n[e]=e,e;var d;return d=0===l.length?i.EMPTY:1===l.length?a.create(l[0],e.getReturnState(0)):new u(l,e.returnStates),r.add(d),n[d]=d,n[e]=d,d}},4579:(t,e,r)=>{var n=r(34411),o=r(31311),i=r(48271),s=r(92183),a=r(17393),l=[].slice;function u(t,e){if(e||(e={}),e.model&&(this.model=e.model),e.comparator&&(this.comparator=e.comparator),e.parent&&(this.parent=e.parent),!this.mainIndex){var r=this.model&&this.model.prototype&&this.model.prototype.idAttribute;this.mainIndex=r||"id"}this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,a({silent:!0},e))}a(u.prototype,n,{initialize:function(){},isModel:function(t){return this.model&&t instanceof this.model},add:function(t,e){return this.set(t,a({merge:!1,add:!0,remove:!1},e))},parse:function(t,e){return t},serialize:function(){return this.map((function(t){if(t.serialize)return t.serialize();var e={};return a(e,t),delete e.collection,e}))},toJSON:function(){return this.serialize()},set:function(t,e){(e=a({add:!0,remove:!0,merge:!0},e)).parse&&(t=this.parse(t,e));var r,n,o,s,l,u,p,c=!i(t);t=c?t?[t]:[]:t.slice();var h=e.at,d=this.comparator&&null==h&&!1!==e.sort,f="string"==typeof this.comparator?this.comparator:null,m=[],g=[],y={},v=e.add,x=e.merge,T=e.remove,S=!(d||!v||!T)&&[],_=this.model&&this.model.prototype||Object.prototype;for(u=0,p=t.length;u<p;u++){if(o=t[u]||{},this.isModel(o)?r=n=o:_.generateId?r=_.generateId(o):void 0===(r=o[this.mainIndex])&&this._isDerivedIndex(_)&&(r=_._derived[this.mainIndex].fn.call(o)),s=this.get(r))T&&(y[s.cid||s[this.mainIndex]]=!0),x&&(o=o===n?n.attributes:o,e.parse&&(o=s.parse(o,e)),s.set?(s.set(o,e),d&&!l&&s.hasChanged(f)&&(l=!0)):a(s,o)),t[u]=s;else if(v){if(!(n=t[u]=this._prepareModel(o,e)))continue;m.push(n),this._addReference(n,e)}(n=s||n)&&(S&&(n.isNew&&n.isNew()||!n[this.mainIndex]||!y[n.cid||n[this.mainIndex]])&&S.push(n),y[n[this.mainIndex]]=!0)}if(T){for(u=0,p=this.length;u<p;u++)y[(n=this.models[u]).cid||n[this.mainIndex]]||g.push(n);for(g.length&&this.remove(g,e),u=0,p=m.length;u<p;u++)this._index(m[u])}if(m.length||S&&S.length)if(d&&(l=!0),null!=h)for(u=0,p=m.length;u<p;u++)this.models.splice(h+u,0,m[u]);else{var b=S||m;for(u=0,p=b.length;u<p;u++)this.models.push(b[u])}if(l&&this.sort({silent:!0}),!e.silent){for(u=0,p=m.length;u<p;u++)(n=m[u]).trigger?n.trigger("add",n,this,e):this.trigger("add",n,this,e);(l||S&&S.length)&&this.trigger("sort",this,e)}return c?t[0]:t},get:function(t,e){if(null!=t){var r=this.mainIndex,n=this._indexes[e||r];return n&&(n[t]||void 0!==t[r]&&n[t[r]])||this._indexes.cid[t]||this._indexes.cid[t.cid]}},at:function(t){return this.models[t]},remove:function(t,e){var r,n,o,s,a=!i(t);for(e||(e={}),r=0,n=(t=a?[t]:l.call(t)).length;r<n;r++)(o=t[r]=this.get(t[r]))&&(this._deIndex(o),s=this.models.indexOf(o),this.models.splice(s,1),e.silent||(e.index=s,o.trigger?o.trigger("remove",o,this,e):this.trigger("remove",o,this,e)),this._removeReference(o,e));return a?t[0]:t},reset:function(t,e){e||(e={});for(var r=0,n=this.models.length;r<n;r++)this._removeReference(this.models[r],e);return e.previousModels=this.models,this._reset(),t=this.add(t,a({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},sort:function(t){var e=this;if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return t||(t={}),"string"==typeof this.comparator?this.models.sort((function(t,r){return t.get?(t=t.get(e.comparator),r=r.get(e.comparator)):(t=t[e.comparator],r=r[e.comparator]),t>r||void 0===t?1:t<r||void 0===r?-1:0})):1===this.comparator.length?this.models.sort((function(t,r){return(t=e.comparator(t))>(r=e.comparator(r))||void 0===t?1:t<r||void 0===r?-1:0})):this.models.sort(s(this.comparator,this)),t.silent||this.trigger("sort",this,t),this},_reset:function(){var t=l.call(this.indexes||[]),e=0;t.push(this.mainIndex),t.push("cid");var r=t.length;for(this.models=[],this._indexes={};e<r;e++)this._indexes[t[e]]={}},_prepareModel:function(t,e){if(!this.model)return t;if(this.isModel(t))return t.collection||(t.collection=this),t;(e=e?a({},e):{}).collection=this;var r=new this.model(t,e);return r.validationError?(this.trigger("invalid",this,r.validationError,e),!1):r},_deIndex:function(t,e,r){var n;if(void 0===e)for(var o in this._indexes)n=t.hasOwnProperty(o)?t[o]:t.get&&t.get(o),delete this._indexes[o][n];else{if(void 0===this._indexes[e])throw new Error("Given attribute is not an index");delete this._indexes[e][r]}},_index:function(t,e){var r;if(void 0===e)for(var n in this._indexes)null!=(r=t.hasOwnProperty(n)?t[n]:t.get&&t.get(n))&&(this._indexes[n][r]=t);else{if(void 0===this._indexes[e])throw new Error("Given attribute is not an index");(r=t[e]||t.get&&t.get(e))&&(this._indexes[e][r]=t)}},_isDerivedIndex:function(t){return!(!t||"object"!=typeof t._derived)&&Object.keys(t._derived).indexOf(this.mainIndex)>=0},_addReference:function(t,e){this._index(t),t.collection||(t.collection=this),t.on&&t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){this===t.collection&&delete t.collection,this._deIndex(t),t.off&&t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,r,n){var o=t.split(":")[0],i=t.split(":")[1];("add"!==o&&"remove"!==o||r===this)&&("destroy"===o&&this.remove(e,n),e&&"change"===o&&i&&this._indexes[i]&&(this._deIndex(e,i,e.previousAttributes()[i]),this._index(e,i)),this.trigger.apply(this,arguments))}}),Object.defineProperties(u.prototype,{length:{get:function(){return this.models.length}},isCollection:{get:function(){return!0}}}),["indexOf","lastIndexOf","every","some","forEach","map","filter","reduce","reduceRight"].forEach((function(t){u.prototype[t]=function(){return this.models[t].apply(this.models,arguments)}})),u.prototype.each=u.prototype.forEach,u.extend=o,t.exports=u},5389:(t,e,r)=>{var n=r(70758),o=r(91136),i=r(17393),s=r(28015),a=r(73163),l=r(72833),u=function(t,e){var r=e.error;e.error=function(n){r&&r(t,n,e),t.trigger("error",t,n,e)}},p=n.extend({save:function(t,e,r){var n,o;if(null==t||"object"==typeof t?(n=t,r=e):(n={})[t]=e,r=i({validate:!0},r),n&&!r.wait){if(!this.set(n,r))return!1}else if(!this._validate(n,r))return!1;void 0===r.parse&&(r.parse=!0);var a=this,l=r.success;r.success=function(t){var e=a.parse(t,r);if(r.wait&&(e=i(n||{},e)),s(e)&&!a.set(e,r))return!1;l&&l(a,t,r),a.trigger("sync",a,t,r)},u(this,r),"patch"==(o=this.isNew()?"create":r.patch?"patch":"update")&&(r.attrs=n),r.wait&&"patch"!==o&&(r.attrs=i(a.serialize(),n));var p=this.sync(o,this,r);return r.xhr=p,p},fetch:function(t){void 0===(t=t?a(t):{}).parse&&(t.parse=!0);var e=this,r=t.success;t.success=function(n){if(!e.set(e.parse(n,t),t))return!1;r&&r(e,n,t),e.trigger("sync",e,n,t)},u(this,t);var n=this.sync("read",this,t);return t.xhr=n,n},destroy:function(t){t=t?a(t):{};var e=this,r=t.success,n=function(){e.trigger("destroy",e,e.collection,t)};if(t.success=function(o){(t.wait||e.isNew())&&n(),r&&r(e,o,t),e.isNew()||e.trigger("sync",e,o,t)},this.isNew())return t.success(),!1;u(this,t);var o=this.sync("delete",this,t);return t.xhr=o,t.wait||n(),o},sync:function(){return o.apply(this,arguments)},url:function(){var t=l(this,"urlRoot")||l(this.collection,"url")||function(){throw new Error('A "url" property or function must be specified')}();return this.isNew()?t:t+("/"===t.charAt(t.length-1)?"":"/")+encodeURIComponent(this.getId())}});t.exports=p},5527:(t,e)=>{function r(t){return"["+t.join(", ")+"]"}function n(t,e){return t.equals(e)}function o(t){return t.hashCode()}function i(t,e){return this.data={},this.hashFunction=t||o,this.equalsFunction=e||n,this}function s(){return this.data=[],this}function a(t,e){return this.data={},this.hashFunction=t||o,this.equalsFunction=e||n,this}function l(){return this.data={},this}function u(){return this}function p(){return this.count=0,this.hash=0,this}String.prototype.seed=String.prototype.seed||Math.round(Math.random()*Math.pow(2,32)),String.prototype.hashCode=function(){var t,e,r,n,o,i,s,a,l=this.toString();for(t=3&l.length,e=l.length-t,r=String.prototype.seed,o=3432918353,i=461845907,a=0;a<e;)s=255&l.charCodeAt(a)|(255&l.charCodeAt(++a))<<8|(255&l.charCodeAt(++a))<<16|(255&l.charCodeAt(++a))<<24,++a,r=27492+(65535&(n=5*(65535&(r=(r^=s=(65535&(s=(s=(65535&s)*o+(((s>>>16)*o&65535)<<16)&4294967295)<<15|s>>>17))*i+(((s>>>16)*i&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(s=0,t){case 3:s^=(255&l.charCodeAt(a+2))<<16;case 2:s^=(255&l.charCodeAt(a+1))<<8;case 1:r^=s=(65535&(s=(s=(65535&(s^=255&l.charCodeAt(a)))*o+(((s>>>16)*o&65535)<<16)&4294967295)<<15|s>>>17))*i+(((s>>>16)*i&65535)<<16)&4294967295}return r^=l.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0},Object.defineProperty(i.prototype,"length",{get:function(){var t=0;for(var e in this.data)0===e.indexOf("hash_")&&(t+=this.data[e].length);return t}}),i.prototype.add=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data){for(var r=this.data[e],n=0;n<r.length;n++)if(this.equalsFunction(t,r[n]))return r[n];return r.push(t),t}return this.data[e]=[t],t},i.prototype.contains=function(t){return null!=this.get(t)},i.prototype.get=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data)for(var r=this.data[e],n=0;n<r.length;n++)if(this.equalsFunction(t,r[n]))return r[n];return null},i.prototype.values=function(){var t=[];for(var e in this.data)0===e.indexOf("hash_")&&(t=t.concat(this.data[e]));return t},i.prototype.toString=function(){return r(this.values())},s.prototype.add=function(t){this.data[t]=!0},s.prototype.or=function(t){var e=this;Object.keys(t.data).map((function(t){e.add(t)}))},s.prototype.remove=function(t){delete this.data[t]},s.prototype.contains=function(t){return!0===this.data[t]},s.prototype.values=function(){return Object.keys(this.data)},s.prototype.minValue=function(){return Math.min.apply(null,this.values())},s.prototype.hashCode=function(){var t=new p;return t.update(this.values()),t.finish()},s.prototype.equals=function(t){return t instanceof s&&this.hashCode()===t.hashCode()},Object.defineProperty(s.prototype,"length",{get:function(){return this.values().length}}),s.prototype.toString=function(){return"{"+this.values().join(", ")+"}"},Object.defineProperty(a.prototype,"length",{get:function(){var t=0;for(var e in this.data)0===e.indexOf("hash_")&&(t+=this.data[e].length);return t}}),a.prototype.put=function(t,e){var r="hash_"+this.hashFunction(t);if(r in this.data){for(var n=this.data[r],o=0;o<n.length;o++){var i=n[o];if(this.equalsFunction(t,i.key)){var s=i.value;return i.value=e,s}}return n.push({key:t,value:e}),e}return this.data[r]=[{key:t,value:e}],e},a.prototype.containsKey=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data)for(var r=this.data[e],n=0;n<r.length;n++){var o=r[n];if(this.equalsFunction(t,o.key))return!0}return!1},a.prototype.get=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data)for(var r=this.data[e],n=0;n<r.length;n++){var o=r[n];if(this.equalsFunction(t,o.key))return o.value}return null},a.prototype.entries=function(){var t=[];for(var e in this.data)0===e.indexOf("hash_")&&(t=t.concat(this.data[e]));return t},a.prototype.getKeys=function(){return this.entries().map((function(t){return t.key}))},a.prototype.getValues=function(){return this.entries().map((function(t){return t.value}))},a.prototype.toString=function(){return"["+this.entries().map((function(t){return"{"+t.key+":"+t.value+"}"})).join(", ")+"]"},l.prototype.get=function(t){return(t="k-"+t)in this.data?this.data[t]:null},l.prototype.put=function(t,e){t="k-"+t,this.data[t]=e},l.prototype.values=function(){var t=this.data;return Object.keys(this.data).map((function(e){return t[e]}))},p.prototype.update=function(){for(var t=0;t<arguments.length;t++){var e=arguments[t];if(null!=e)if(Array.isArray(e))this.update.apply(e);else{var r=0;switch(typeof e){case"undefined":case"function":continue;case"number":case"boolean":r=e;break;case"string":r=e.hashCode();break;default:e.updateHashCode(this);continue}r=(r*=3432918353)<<15|r>>>17,r*=461845907,this.count=this.count+1;var n=this.hash^r;n=5*(n=n<<13|n>>>19)+3864292196,this.hash=n}}},p.prototype.finish=function(){var t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,(t*=3266489909)^t>>>16},u.prototype.get=function(t,e){var r=this[t]||null;return null===r?null:r[e]||null},u.prototype.set=function(t,e,r){var n=this[t]||null;null===n&&(n={},this[t]=n),n[e]=r},e.Hash=p,e.Set=i,e.Map=a,e.BitSet=s,e.AltDict=l,e.DoubleDict=u,e.hashStuff=function(){var t=new p;return t.update.apply(arguments),t.finish()},e.escapeWhitespace=function(t,e){return t=t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),e&&(t=t.replace(/ /g,"·")),t},e.arrayToString=r,e.titleCase=function(t){return t.replace(/\w\S*/g,(function(t){return t.charAt(0).toUpperCase()+t.substr(1)}))},e.equalArrays=function(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t==e)return!0;if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!=e[r]&&!t[r].equals(e[r]))return!1;return!0}},5648:(t,e,r)=>{var n=r(46324),o=r(40046),i=o.base,s=o.bignum,a=o.constants.der;function l(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){i.Node.call(this,"der",t)}function p(t,e){var r=t.readUInt8(e);if(t.isError(r))return r;var n=a.tagClass[r>>6],o=!(32&r);if(31&~r)r&=31;else{var i=r;for(r=0;!(128&~i);){if(i=t.readUInt8(e),t.isError(i))return i;r<<=7,r|=127&i}}return{cls:n,primitive:o,tag:r,tagStr:a.tag[r]}}function c(t,e,r){var n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(!(128&n))return n;var o=127&n;if(o>4)return t.error("length octect is too long");n=0;for(var i=0;i<o;i++){n<<=8;var s=t.readUInt8(r);if(t.isError(s))return s;n|=s}return n}t.exports=l,l.prototype.decode=function(t,e){return t instanceof i.DecoderBuffer||(t=new i.DecoderBuffer(t,e)),this.tree._decode(t,e)},n(u,i.Node),u.prototype._peekTag=function(t,e,r){if(t.isEmpty())return!1;var n=t.save(),o=p(t,'Failed to peek tag: "'+e+'"');return t.isError(o)?o:(t.restore(n),o.tag===e||o.tagStr===e||o.tagStr+"of"===e||r)},u.prototype._decodeTag=function(t,e,r){var n=p(t,'Failed to decode tag of "'+e+'"');if(t.isError(n))return n;var o=c(t,n.primitive,'Failed to get length of "'+e+'"');if(t.isError(o))return o;if(!r&&n.tag!==e&&n.tagStr!==e&&n.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(n.primitive||null!==o)return t.skip(o,'Failed to match body of: "'+e+'"');var i=t.save(),s=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(s)?s:(o=t.offset-i.offset,t.restore(i),t.skip(o,'Failed to match body of: "'+e+'"'))},u.prototype._skipUntilEnd=function(t,e){for(;;){var r=p(t,e);if(t.isError(r))return r;var n,o=c(t,r.primitive,e);if(t.isError(o))return o;if(n=r.primitive||null!==o?t.skip(o):this._skipUntilEnd(t,e),t.isError(n))return n;if("end"===r.tagStr)break}},u.prototype._decodeList=function(t,e,r,n){for(var o=[];!t.isEmpty();){var i=this._peekTag(t,"end");if(t.isError(i))return i;var s=r.decode(t,"der",n);if(t.isError(s)&&i)break;o.push(s)}return o},u.prototype._decodeStr=function(t,e){if("bitstr"===e){var r=t.readUInt8();return t.isError(r)?r:{unused:r,data:t.raw()}}if("bmpstr"===e){var n=t.raw();if(n.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var o="",i=0;i<n.length/2;i++)o+=String.fromCharCode(n.readUInt16BE(2*i));return o}if("numstr"===e){var s=t.raw().toString("ascii");return this._isNumstr(s)?s:t.error("Decoding of string type: numstr unsupported characters")}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var a=t.raw().toString("ascii");return this._isPrintstr(a)?a:t.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported")},u.prototype._decodeObjid=function(t,e,r){for(var n,o=[],i=0;!t.isEmpty();){var s=t.readUInt8();i<<=7,i|=127&s,128&s||(o.push(i),i=0)}128&s&&o.push(i);var a=o[0]/40|0,l=o[0]%40;if(n=r?o:[a,l].concat(o.slice(1)),e){var u=e[n.join(" ")];void 0===u&&(u=e[n.join(".")]),void 0!==u&&(n=u)}return n},u.prototype._decodeTime=function(t,e){var r=t.raw().toString();if("gentime"===e)var n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),l=0|r.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),l=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,l,0)},u.prototype._decodeNull=function(t){return null},u.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e},u.prototype._decodeInt=function(t,e){var r=t.raw(),n=new s(r);return e&&(n=e[n.toString(10)]||n),n},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree}},6415:(t,e,r)=>{var n=r(98750);function o(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0}function i(t){return r.g.Buffer&&"function"==typeof r.g.Buffer.isBuffer?r.g.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var s=r(13390),a=Object.prototype.hasOwnProperty,l=Array.prototype.slice,u="foo"===function(){}.name;function p(t){return Object.prototype.toString.call(t)}function c(t){return!i(t)&&"function"==typeof r.g.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer)))}var h=t.exports=v,d=/\s*function\s+([^\(\s]*)\s*/;function f(t){if(s.isFunction(t)){if(u)return t.name;var e=t.toString().match(d);return e&&e[1]}}function m(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function g(t){if(u||!s.isFunction(t))return s.inspect(t);var e=f(t);return"[Function"+(e?": "+e:"")+"]"}function y(t,e,r,n,o){throw new h.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:o})}function v(t,e){t||y(t,!0,e,"==",h.ok)}function x(t,e,r,n){if(t===e)return!0;if(i(t)&&i(e))return 0===o(t,e);if(s.isDate(t)&&s.isDate(e))return t.getTime()===e.getTime();if(s.isRegExp(t)&&s.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(c(t)&&c(e)&&p(t)===p(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===o(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(i(t)!==i(e))return!1;var a=(n=n||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===n.expected.indexOf(e)||(n.actual.push(t),n.expected.push(e),function(t,e,r,n){if(null==t||null==e)return!1;if(s.isPrimitive(t)||s.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var o=T(t),i=T(e);if(o&&!i||!o&&i)return!1;if(o)return x(t=l.call(t),e=l.call(e),r);var a,u,p=b(t),c=b(e);if(p.length!==c.length)return!1;for(p.sort(),c.sort(),u=p.length-1;u>=0;u--)if(p[u]!==c[u])return!1;for(u=p.length-1;u>=0;u--)if(!x(t[a=p[u]],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function T(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function S(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function _(t,e,r,n){var o;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),o=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!o&&y(o,r,"Missing expected exception"+n);var i="string"==typeof n,a=!t&&o&&!r;if((!t&&s.isError(o)&&i&&S(o,r)||a)&&y(o,r,"Got unwanted exception"+n),t&&o&&r&&!S(o,r)||!t&&o)throw o}h.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=m(g(this.actual),128)+" "+this.operator+" "+m(g(this.expected),128),this.generatedMessage=!0);var e=t.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,o=f(e),i=n.indexOf("\n"+o);if(i>=0){var s=n.indexOf("\n",i+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(h.AssertionError,Error),h.fail=y,h.ok=v,h.equal=function(t,e,r){t!=e&&y(t,e,r,"==",h.equal)},h.notEqual=function(t,e,r){t==e&&y(t,e,r,"!=",h.notEqual)},h.deepEqual=function(t,e,r){x(t,e,!1)||y(t,e,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(t,e,r){x(t,e,!0)||y(t,e,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(t,e,r){x(t,e,!1)&&y(t,e,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function t(e,r,n){x(e,r,!0)&&y(e,r,n,"notDeepStrictEqual",t)},h.strictEqual=function(t,e,r){t!==e&&y(t,e,r,"===",h.strictEqual)},h.notStrictEqual=function(t,e,r){t===e&&y(t,e,r,"!==",h.notStrictEqual)},h.throws=function(t,e,r){_(!0,t,e,r)},h.doesNotThrow=function(t,e,r){_(!1,t,e,r)},h.ifError=function(t){if(t)throw t},h.strict=n((function t(e,r){e||y(e,!0,r,"==",t)}),h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var b=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}},8541:(t,e,r)=>{var n=r(5527).hashStuff,o=r(66380).LexerIndexedCustomAction;function i(t){return this.lexerActions=null===t?[]:t,this.cachedHashCode=n(t),this}i.append=function(t,e){return new i(null===t?[e]:t.lexerActions.concat([e]))},i.prototype.fixOffsetBeforeMatch=function(t){for(var e=null,r=0;r<this.lexerActions.length;r++)!this.lexerActions[r].isPositionDependent||this.lexerActions[r]instanceof o||(null===e&&(e=this.lexerActions.concat([])),e[r]=new o(t,this.lexerActions[r]));return null===e?this:new i(e)},i.prototype.execute=function(t,e,r){var n=!1,i=e.index;try{for(var s=0;s<this.lexerActions.length;s++){var a=this.lexerActions[s];if(a instanceof o){var l=a.offset;e.seek(r+l),a=a.action,n=r+l!==i}else a.isPositionDependent&&(e.seek(i),n=!1);a.execute(t)}}finally{n&&e.seek(i)}},i.prototype.hashCode=function(){return this.cachedHashCode},i.prototype.updateHashCode=function(t){t.update(this.cachedHashCode)},i.prototype.equals=function(t){if(this===t)return!0;if(t instanceof i){if(this.cachedHashCode!=t.cachedHashCode)return!1;if(this.lexerActions.length!=t.lexerActions.length)return!1;for(var e=this.lexerActions.length,r=0;r<e;++r)if(!this.lexerActions[r].equals(t.lexerActions[r]))return!1;return!0}return!1},e.I=i},9858:(t,e,r)=>{var n=r(47186),o=/\s+/;e.triggerEvents=function(t,e){var r,n=-1,o=t.length,i=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++n<o;)(r=t[n]).callback.call(r.ctx);return;case 1:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i);return;case 2:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s);return;case 3:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s,a);return;default:for(;++n<o;)(r=t[n]).callback.apply(r.ctx,e);return}},e.eventsApi=function(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(var i in r)t[e].apply(t,[i,r[i]].concat(n));return!1}if(o.test(r)){for(var s=r.split(o),a=0,l=s.length;a<l;a++)t[e].apply(t,[s[a]].concat(n));return!1}return!0},e.createListenMethod=function(t){return function(e,r,o){if(!e)throw new Error("Trying to listenTo event: '"+r+"' but the target object is undefined");if((this._listeningTo||(this._listeningTo={}))[e._listenId||(e._listenId=n("l"))]=e,o||"object"!=typeof r||(o=this),"function"!=typeof e[t])throw new Error("Trying to listenTo event: '"+r+"' on object: "+e.toString()+" but it does not have an 'on' method so is unbindable");return e[t](r,o,this),this}}},10732:(t,e,r)=>{var n=r(5527),o=n.Set,i=n.BitSet,s=n.DoubleDict,a=r(94841).ATN,l=r(49832).ATNState,u=r(46775).G,p=r(90975).Q,c=r(86291).Token,h=r(23952).X,d=r(23952).PredPrediction,f=r(53223).e,m=r(37864).PredictionMode,g=r(56975).m,y=(r(37170).ParserRuleContext,r(81675).Ij),v=(r(49832).StarLoopEntryState,r(49832).RuleStopState),x=r(1754).PredictionContext,T=r(34065).Interval,S=r(45977),_=S.Transition,b=S.SetTransition,E=S.NotSetTransition,w=S.RuleTransition,I=S.ActionTransition,C=r(64116).NoViableAltException,M=r(1754).SingletonPredictionContext,k=r(1754).predictionContextFromRuleContext;function A(t,e,r,n){return f.call(this,e,n),this.parser=t,this.decisionToDFA=r,this.predictionMode=m.LL,this._input=null,this._startIndex=0,this._outerContext=null,this._dfa=null,this.mergeCache=null,this}A.prototype=Object.create(f.prototype),A.prototype.constructor=A,A.prototype.debug=!1,A.prototype.debug_closure=!1,A.prototype.debug_add=!1,A.prototype.debug_list_atn_decisions=!1,A.prototype.dfa_debug=!1,A.prototype.retry_debug=!1,A.prototype.reset=function(){},A.prototype.adaptivePredict=function(t,e,r){(this.debug||this.debug_list_atn_decisions)&&console.log("adaptivePredict decision "+e+" exec LA(1)=="+this.getLookaheadName(t)+" line "+t.LT(1).line+":"+t.LT(1).column),this._input=t,this._startIndex=t.index,this._outerContext=r;var n=this.decisionToDFA[e];this._dfa=n;var o=t.mark(),i=t.index;try{var s;if(null===(s=n.precedenceDfa?n.getPrecedenceStartState(this.parser.getPrecedence()):n.s0)){null===r&&(r=g.EMPTY),(this.debug||this.debug_list_atn_decisions)&&console.log("predictATN decision "+n.decision+" exec LA(1)=="+this.getLookaheadName(t)+", outerContext="+r.toString(this.parser.ruleNames));var a=this.computeStartState(n.atnStartState,g.EMPTY,!1);n.precedenceDfa?(n.s0.configs=a,a=this.applyPrecedenceFilter(a),s=this.addDFAState(n,new h(null,a)),n.setPrecedenceStartState(this.parser.getPrecedence(),s)):(s=this.addDFAState(n,new h(null,a)),n.s0=s)}var l=this.execATN(n,s,t,i,r);return this.debug&&console.log("DFA after predictATN: "+n.toString(this.parser.literalNames)),l}finally{this._dfa=null,this.mergeCache=null,t.seek(i),t.release(o)}},A.prototype.execATN=function(t,e,r,n,o){var i;(this.debug||this.debug_list_atn_decisions)&&console.log("execATN decision "+t.decision+" exec LA(1)=="+this.getLookaheadName(r)+" line "+r.LT(1).line+":"+r.LT(1).column);var s=e;this.debug&&console.log("s0 = "+e);for(var l=r.LA(1);;){var u=this.getExistingTargetState(s,l);if(null===u&&(u=this.computeTargetState(t,s,l)),u===f.ERROR){var p=this.noViableAlt(r,o,s.configs,n);if(r.seek(n),(i=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(s.configs,o))!==a.INVALID_ALT_NUMBER)return i;throw p}if(u.requiresFullContext&&this.predictionMode!==m.SLL){var h=null;if(null!==u.predicates){this.debug&&console.log("DFA state has preds in DFA sim LL failover");var d=r.index;if(d!==n&&r.seek(n),1===(h=this.evalSemanticContext(u.predicates,o,!0)).length)return this.debug&&console.log("Full LL avoided"),h.minValue();d!==n&&r.seek(d)}this.dfa_debug&&console.log("ctx sensitive state "+o+" in "+u);var g=this.computeStartState(t.atnStartState,o,!0);return this.reportAttemptingFullContext(t,h,u.configs,n,r.index),this.execATNWithFullContext(t,u,g,r,n,o)}if(u.isAcceptState){if(null===u.predicates)return u.prediction;var y=r.index;r.seek(n);var v=this.evalSemanticContext(u.predicates,o,!0);if(0===v.length)throw this.noViableAlt(r,o,u.configs,n);return 1===v.length||this.reportAmbiguity(t,u,n,y,!1,v,u.configs),v.minValue()}s=u,l!==c.EOF&&(r.consume(),l=r.LA(1))}},A.prototype.getExistingTargetState=function(t,e){var r=t.edges;return null===r?null:r[e+1]||null},A.prototype.computeTargetState=function(t,e,r){var o=this.computeReachSet(e.configs,r,!1);if(null===o)return this.addDFAEdge(t,e,r,f.ERROR),f.ERROR;var i=new h(null,o),s=this.getUniqueAlt(o);if(this.debug){var l=m.getConflictingAltSubsets(o);console.log("SLL altSubSets="+n.arrayToString(l)+", previous="+e.configs+", configs="+o+", predict="+s+", allSubsetsConflict="+m.allSubsetsConflict(l)+", conflictingAlts="+this.getConflictingAlts(o))}return s!==a.INVALID_ALT_NUMBER?(i.isAcceptState=!0,i.configs.uniqueAlt=s,i.prediction=s):m.hasSLLConflictTerminatingPrediction(this.predictionMode,o)&&(i.configs.conflictingAlts=this.getConflictingAlts(o),i.requiresFullContext=!0,i.isAcceptState=!0,i.prediction=i.configs.conflictingAlts.minValue()),i.isAcceptState&&i.configs.hasSemanticContext&&(this.predicateDFAState(i,this.atn.getDecisionState(t.decision)),null!==i.predicates&&(i.prediction=a.INVALID_ALT_NUMBER)),this.addDFAEdge(t,e,r,i)},A.prototype.predicateDFAState=function(t,e){var r=e.transitions.length,n=this.getConflictingAltsOrUniqueAlt(t.configs),o=this.getPredsForAmbigAlts(n,t.configs,r);null!==o?(t.predicates=this.getPredicatePredictions(n,o),t.prediction=a.INVALID_ALT_NUMBER):t.prediction=n.minValue()},A.prototype.execATNWithFullContext=function(t,e,r,n,o,i){(this.debug||this.debug_list_atn_decisions)&&console.log("execATNWithFullContext "+r);var s=!1,l=null,u=r;n.seek(o);for(var p=n.LA(1),h=-1;;){if(null===(l=this.computeReachSet(u,p,!0))){var d=this.noViableAlt(n,i,u,o);n.seek(o);var f=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(u,i);if(f!==a.INVALID_ALT_NUMBER)return f;throw d}var g=m.getConflictingAltSubsets(l);if(this.debug&&console.log("LL altSubSets="+g+", predict="+m.getUniqueAlt(g)+", resolvesToJustOneViableAlt="+m.resolvesToJustOneViableAlt(g)),l.uniqueAlt=this.getUniqueAlt(l),l.uniqueAlt!==a.INVALID_ALT_NUMBER){h=l.uniqueAlt;break}if(this.predictionMode!==m.LL_EXACT_AMBIG_DETECTION){if((h=m.resolvesToJustOneViableAlt(g))!==a.INVALID_ALT_NUMBER)break}else if(m.allSubsetsConflict(g)&&m.allSubsetsEqual(g)){s=!0,h=m.getSingleViableAlt(g);break}u=l,p!==c.EOF&&(n.consume(),p=n.LA(1))}return l.uniqueAlt!==a.INVALID_ALT_NUMBER?(this.reportContextSensitivity(t,h,l,o,n.index),h):(this.reportAmbiguity(t,e,o,n.index,s,null,l),h)},A.prototype.computeReachSet=function(t,e,r){this.debug&&console.log("in computeReachSet, starting closure: "+t),null===this.mergeCache&&(this.mergeCache=new s);for(var n=new p(r),i=null,l=0;l<t.items.length;l++){var h=t.items[l];if(this.debug_add&&console.log("testing "+this.getTokenName(e)+" at "+h),h.state instanceof v)(r||e===c.EOF)&&(null===i&&(i=[]),i.push(h),this.debug_add&&console.log("added "+h+" to skippedStopStates"));else for(var d=0;d<h.state.transitions.length;d++){var f=h.state.transitions[d],g=this.getReachableTarget(f,e);if(null!==g){var y=new u({state:g},h);n.add(y,this.mergeCache),this.debug_add&&console.log("added "+y+" to intermediate")}}}var x=null;if(null===i&&e!==c.EOF&&(1===n.items.length||this.getUniqueAlt(n)!==a.INVALID_ALT_NUMBER)&&(x=n),null===x){x=new p(r);for(var T=new o,S=e===c.EOF,_=0;_<n.items.length;_++)this.closure(n.items[_],x,T,!1,r,S)}if(e===c.EOF&&(x=this.removeAllConfigsNotInRuleStopState(x,x===n)),!(null===i||r&&m.hasConfigInRuleStopState(x)))for(var b=0;b<i.length;b++)x.add(i[b],this.mergeCache);return 0===x.items.length?null:x},A.prototype.removeAllConfigsNotInRuleStopState=function(t,e){if(m.allConfigsInRuleStopStates(t))return t;for(var r=new p(t.fullCtx),n=0;n<t.items.length;n++){var o=t.items[n];if(o.state instanceof v)r.add(o,this.mergeCache);else if(e&&o.state.epsilonOnlyTransitions&&this.atn.nextTokens(o.state).contains(c.EPSILON)){var i=this.atn.ruleToStopState[o.state.ruleIndex];r.add(new u({state:i},o),this.mergeCache)}}return r},A.prototype.computeStartState=function(t,e,r){for(var n=k(this.atn,e),i=new p(r),s=0;s<t.transitions.length;s++){var a=t.transitions[s].target,l=new u({state:a,alt:s+1,context:n},null),c=new o;this.closure(l,i,c,!0,r,!1)}return i},A.prototype.applyPrecedenceFilter=function(t){for(var e,r=[],n=new p(t.fullCtx),o=0;o<t.items.length;o++)if(1===(e=t.items[o]).alt){var i=e.semanticContext.evalPrecedence(this.parser,this._outerContext);null!==i&&(r[e.state.stateNumber]=e.context,i!==e.semanticContext?n.add(new u({semanticContext:i},e),this.mergeCache):n.add(e,this.mergeCache))}for(o=0;o<t.items.length;o++)if(1!==(e=t.items[o]).alt){if(!e.precedenceFilterSuppressed){var s=r[e.state.stateNumber]||null;if(null!==s&&s.equals(e.context))continue}n.add(e,this.mergeCache)}return n},A.prototype.getReachableTarget=function(t,e){return t.matches(e,0,this.atn.maxTokenType)?t.target:null},A.prototype.getPredsForAmbigAlts=function(t,e,r){for(var o=[],i=0;i<e.items.length;i++){var s=e.items[i];t.contains(s.alt)&&(o[s.alt]=y.orContext(o[s.alt]||null,s.semanticContext))}var a=0;for(i=1;i<r+1;i++){var l=o[i]||null;null===l?o[i]=y.NONE:l!==y.NONE&&(a+=1)}return 0===a&&(o=null),this.debug&&console.log("getPredsForAmbigAlts result "+n.arrayToString(o)),o},A.prototype.getPredicatePredictions=function(t,e){for(var r=[],n=!1,o=1;o<e.length;o++){var i=e[o];null!==t&&t.contains(o)&&r.push(new d(i,o)),i!==y.NONE&&(n=!0)}return n?r:null},A.prototype.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule=function(t,e){var r=this.splitAccordingToSemanticValidity(t,e),n=r[0],o=r[1],i=this.getAltThatFinishedDecisionEntryRule(n);return i!==a.INVALID_ALT_NUMBER||o.items.length>0&&(i=this.getAltThatFinishedDecisionEntryRule(o))!==a.INVALID_ALT_NUMBER?i:a.INVALID_ALT_NUMBER},A.prototype.getAltThatFinishedDecisionEntryRule=function(t){for(var e=[],r=0;r<t.items.length;r++){var n=t.items[r];(n.reachesIntoOuterContext>0||n.state instanceof v&&n.context.hasEmptyPath())&&e.indexOf(n.alt)<0&&e.push(n.alt)}return 0===e.length?a.INVALID_ALT_NUMBER:Math.min.apply(null,e)},A.prototype.splitAccordingToSemanticValidity=function(t,e){for(var r=new p(t.fullCtx),n=new p(t.fullCtx),o=0;o<t.items.length;o++){var i=t.items[o];i.semanticContext!==y.NONE?i.semanticContext.evaluate(this.parser,e)?r.add(i):n.add(i):r.add(i)}return[r,n]},A.prototype.evalSemanticContext=function(t,e,r){for(var n=new i,o=0;o<t.length;o++){var s=t[o];if(s.pred!==y.NONE){var a=s.pred.evaluate(this.parser,e);if((this.debug||this.dfa_debug)&&console.log("eval pred "+s+"="+a),a&&((this.debug||this.dfa_debug)&&console.log("PREDICT "+s.alt),n.add(s.alt),!r))break}else if(n.add(s.alt),!r)break}return n},A.prototype.closure=function(t,e,r,n,o,i){this.closureCheckingStopState(t,e,r,n,o,0,i)},A.prototype.closureCheckingStopState=function(t,e,r,n,o,i,s){if((this.debug||this.debug_closure)&&(console.log("closure("+t.toString(this.parser,!0)+")"),t.reachesIntoOuterContext>50))throw"problem";if(t.state instanceof v){if(!t.context.isEmpty()){for(var a=0;a<t.context.length;a++)if(t.context.getReturnState(a)!==x.EMPTY_RETURN_STATE){var l=this.atn.states[t.context.getReturnState(a)],p=t.context.getParent(a),c={state:l,alt:t.alt,context:p,semanticContext:t.semanticContext},h=new u(c,null);h.reachesIntoOuterContext=t.reachesIntoOuterContext,this.closureCheckingStopState(h,e,r,n,o,i-1,s)}else{if(o){e.add(new u({state:t.state,context:x.EMPTY},t),this.mergeCache);continue}this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex)),this.closure_(t,e,r,n,o,i,s)}return}if(o)return void e.add(t,this.mergeCache);this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex))}this.closure_(t,e,r,n,o,i,s)},A.prototype.closure_=function(t,e,r,n,o,i,s){var a=t.state;a.epsilonOnlyTransitions||e.add(t,this.mergeCache);for(var l=0;l<a.transitions.length;l++)if(0!=l||!this.canDropLoopEntryEdgeInLeftRecursiveRule(t)){var u=a.transitions[l],p=n&&!(u instanceof I),c=this.getEpsilonTarget(t,u,p,0===i,o,s);if(null!==c){var h=i;if(t.state instanceof v){if(null!==this._dfa&&this._dfa.precedenceDfa&&u.outermostPrecedenceReturn===this._dfa.atnStartState.ruleIndex&&(c.precedenceFilterSuppressed=!0),c.reachesIntoOuterContext+=1,r.add(c)!==c)continue;e.dipsIntoOuterContext=!0,h-=1,this.debug&&console.log("dips into outer ctx: "+c)}else{if(!u.isEpsilon&&r.add(c)!==c)continue;u instanceof w&&h>=0&&(h+=1)}this.closureCheckingStopState(c,e,r,p,o,h,s)}}},A.prototype.canDropLoopEntryEdgeInLeftRecursiveRule=function(t){var e=t.state;if(e.stateType!=l.STAR_LOOP_ENTRY)return!1;if(e.stateType!=l.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;for(var r=t.context.length,n=0;n<r;n++)if((s=this.atn.states[t.context.getReturnState(n)]).ruleIndex!=e.ruleIndex)return!1;var o=e.transitions[0].target.endState.stateNumber,i=this.atn.states[o];for(n=0;n<r;n++){var s,a=t.context.getReturnState(n);if(1!=(s=this.atn.states[a]).transitions.length||!s.transitions[0].isEpsilon)return!1;var u=s.transitions[0].target;if(!(s.stateType==l.BLOCK_END&&u==e||s==i||u==i||u.stateType==l.BLOCK_END&&1==u.transitions.length&&u.transitions[0].isEpsilon&&u.transitions[0].target==e))return!1}return!0},A.prototype.getRuleName=function(t){return null!==this.parser&&t>=0?this.parser.ruleNames[t]:"<rule "+t+">"},A.prototype.getEpsilonTarget=function(t,e,r,n,o,i){switch(e.serializationType){case _.RULE:return this.ruleTransition(t,e);case _.PRECEDENCE:return this.precedenceTransition(t,e,r,n,o);case _.PREDICATE:return this.predTransition(t,e,r,n,o);case _.ACTION:return this.actionTransition(t,e);case _.EPSILON:return new u({state:e.target},t);case _.ATOM:case _.RANGE:case _.SET:return i&&e.matches(c.EOF,0,1)?new u({state:e.target},t):null;default:return null}},A.prototype.actionTransition=function(t,e){if(this.debug){var r=-1==e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+r)}return new u({state:e.target},t)},A.prototype.precedenceTransition=function(t,e,r,o,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+n.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(r&&o)if(i){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var p=y.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:p},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},A.prototype.predTransition=function(t,e,r,o,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+n.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(r&&(e.isCtxDependent&&o||!e.isCtxDependent))if(i){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var p=y.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:p},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},A.prototype.ruleTransition=function(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);var r=e.followState,n=M.create(t.context,r.stateNumber);return new u({state:e.target,context:n},t)},A.prototype.getConflictingAlts=function(t){var e=m.getConflictingAltSubsets(t);return m.getAlts(e)},A.prototype.getConflictingAltsOrUniqueAlt=function(t){var e=null;return t.uniqueAlt!==a.INVALID_ALT_NUMBER?(e=new i).add(t.uniqueAlt):e=t.conflictingAlts,e},A.prototype.getTokenName=function(t){if(t===c.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t},A.prototype.getLookaheadName=function(t){return this.getTokenName(t.LA(1))},A.prototype.dumpDeadEndConfigs=function(t){console.log("dead end configs: ");for(var e=t.getDeadEndConfigs(),r=0;r<e.length;r++){var n=e[r],o="no edges";if(n.state.transitions.length>0){var i=n.state.transitions[0];i instanceof AtomTransition?o="Atom "+this.getTokenName(i.label):i instanceof b&&(o=(i instanceof E?"~":"")+"Set "+i.set)}console.error(n.toString(this.parser,!0)+":"+o)}},A.prototype.noViableAlt=function(t,e,r,n){return new C(this.parser,t,t.get(n),t.LT(1),r,e)},A.prototype.getUniqueAlt=function(t){for(var e=a.INVALID_ALT_NUMBER,r=0;r<t.items.length;r++){var n=t.items[r];if(e===a.INVALID_ALT_NUMBER)e=n.alt;else if(n.alt!==e)return a.INVALID_ALT_NUMBER}return e},A.prototype.addDFAEdge=function(t,e,r,n){if(this.debug&&console.log("EDGE "+e+" -> "+n+" upon "+this.getTokenName(r)),null===n)return null;if(n=this.addDFAState(t,n),null===e||r<-1||r>this.atn.maxTokenType)return n;if(null===e.edges&&(e.edges=[]),e.edges[r+1]=n,this.debug){var o=null===this.parser?null:this.parser.literalNames,i=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(o,i))}return n},A.prototype.addDFAState=function(t,e){if(e==f.ERROR)return e;var r=t.states.get(e);return null!==r?r:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)},A.prototype.reportAttemptingFullContext=function(t,e,r,n,o){if(this.debug||this.retry_debug){var i=new T(n,o+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(i))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,n,o,e,r)},A.prototype.reportContextSensitivity=function(t,e,r,n,o){if(this.debug||this.retry_debug){var i=new T(n,o+1);console.log("reportContextSensitivity decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(i))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,n,o,e,r)},A.prototype.reportAmbiguity=function(t,e,r,n,o,i,s){if(this.debug||this.retry_debug){var a=new T(r,n+1);console.log("reportAmbiguity "+i+":"+s+", input="+this.parser.getTokenStream().getText(a))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,r,n,o,i,s)},e.ParserATNSimulator=A},11593:(t,e,r)=>{var n=r(46324),o=r(17871).Reporter,i=r(34110).Buffer;function s(t,e){o.call(this,e),i.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function a(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return t instanceof a||(t=new a(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=i.byteLength(t);else{if(!i.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}n(s,o),e.t=s,s.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},s.prototype.restore=function(t){var e=new s(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,o.prototype.restore.call(this,t.reporter),e},s.prototype.isEmpty=function(){return this.offset===this.length},s.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},s.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");var r=new s(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},s.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},e.d=a,a.prototype.join=function(t,e){return t||(t=new i(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(t,e),e+=r.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):i.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t}},13048:(t,e,r)=>{var n=r(86291).Token,o=r(162).f,i=r(50540).p,s=r(64116).RecognitionException,a=r(64116).LexerNoViableAltException;function l(t){return o.call(this),this._input=t,this._factory=i.DEFAULT,this._tokenFactorySourcePair=[this,t],this._interp=null,this._token=null,this._tokenStartCharIndex=-1,this._tokenStartLine=-1,this._tokenStartColumn=-1,this._hitEOF=!1,this._channel=n.DEFAULT_CHANNEL,this._type=n.INVALID_TYPE,this._modeStack=[],this._mode=l.DEFAULT_MODE,this._text=null,this}l.prototype=Object.create(o.prototype),l.prototype.constructor=l,l.DEFAULT_MODE=0,l.MORE=-2,l.SKIP=-3,l.DEFAULT_TOKEN_CHANNEL=n.DEFAULT_CHANNEL,l.HIDDEN=n.HIDDEN_CHANNEL,l.MIN_CHAR_VALUE=0,l.MAX_CHAR_VALUE=1114111,l.prototype.reset=function(){null!==this._input&&this._input.seek(0),this._token=null,this._type=n.INVALID_TYPE,this._channel=n.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=l.DEFAULT_MODE,this._modeStack=[],this._interp.reset()},l.prototype.nextToken=function(){if(null===this._input)throw"nextToken requires a non-null input stream.";var t=this._input.mark();try{for(;;){if(this._hitEOF)return this.emitEOF(),this._token;this._token=null,this._channel=n.DEFAULT_CHANNEL,this._tokenStartCharIndex=this._input.index,this._tokenStartColumn=this._interp.column,this._tokenStartLine=this._interp.line,this._text=null;for(var e=!1;;){this._type=n.INVALID_TYPE;var r=l.SKIP;try{r=this._interp.match(this._input,this._mode)}catch(t){if(!(t instanceof s))throw console.log(t.stack),t;this.notifyListeners(t),this.recover(t)}if(this._input.LA(1)===n.EOF&&(this._hitEOF=!0),this._type===n.INVALID_TYPE&&(this._type=r),this._type===l.SKIP){e=!0;break}if(this._type!==l.MORE)break}if(!e)return null===this._token&&this.emit(),this._token}}finally{this._input.release(t)}},l.prototype.skip=function(){this._type=l.SKIP},l.prototype.more=function(){this._type=l.MORE},l.prototype.mode=function(t){this._mode=t},l.prototype.pushMode=function(t){this._interp.debug&&console.log("pushMode "+t),this._modeStack.push(this._mode),this.mode(t)},l.prototype.popMode=function(){if(0===this._modeStack.length)throw"Empty Stack";return this._interp.debug&&console.log("popMode back to "+this._modeStack.slice(0,-1)),this.mode(this._modeStack.pop()),this._mode},Object.defineProperty(l.prototype,"inputStream",{get:function(){return this._input},set:function(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}}),Object.defineProperty(l.prototype,"sourceName",{get:function(){return this._input.sourceName}}),l.prototype.emitToken=function(t){this._token=t},l.prototype.emit=function(){var t=this._factory.create(this._tokenFactorySourcePair,this._type,this._text,this._channel,this._tokenStartCharIndex,this.getCharIndex()-1,this._tokenStartLine,this._tokenStartColumn);return this.emitToken(t),t},l.prototype.emitEOF=function(){var t=this.column,e=this.line,r=this._factory.create(this._tokenFactorySourcePair,n.EOF,null,n.DEFAULT_CHANNEL,this._input.index,this._input.index-1,e,t);return this.emitToken(r),r},Object.defineProperty(l.prototype,"type",{get:function(){return this.type},set:function(t){this._type=t}}),Object.defineProperty(l.prototype,"line",{get:function(){return this._interp.line},set:function(t){this._interp.line=t}}),Object.defineProperty(l.prototype,"column",{get:function(){return this._interp.column},set:function(t){this._interp.column=t}}),l.prototype.getCharIndex=function(){return this._input.index},Object.defineProperty(l.prototype,"text",{get:function(){return null!==this._text?this._text:this._interp.getText(this._input)},set:function(t){this._text=t}}),l.prototype.getAllTokens=function(){for(var t=[],e=this.nextToken();e.type!==n.EOF;)t.push(e),e=this.nextToken();return t},l.prototype.notifyListeners=function(t){var e=this._tokenStartCharIndex,r=this._input.index,n=this._input.getText(e,r),o="token recognition error at: '"+this.getErrorDisplay(n)+"'";this.getErrorListenerDispatch().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,o,t)},l.prototype.getErrorDisplay=function(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r]);return e.join("")},l.prototype.getErrorDisplayForChar=function(t){return t.charCodeAt(0)===n.EOF?"<EOF>":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t},l.prototype.getCharErrorDisplay=function(t){return"'"+this.getErrorDisplayForChar(t)+"'"},l.prototype.recover=function(t){this._input.LA(1)!==n.EOF&&(t instanceof a?this._interp.consume(this._input):this._input.consume())},e.Lexer=l},13126:(t,e,r)=>{var n=r(86291).Token,o=r(94841).ATN,i=r(441).E,s=r(49832),a=s.ATNState,l=s.BasicState,u=s.DecisionState,p=s.BlockStartState,c=s.BlockEndState,h=s.LoopEndState,d=s.RuleStartState,f=s.RuleStopState,m=s.TokensStartState,g=s.PlusLoopbackState,y=s.StarLoopbackState,v=s.StarLoopEntryState,x=s.PlusBlockStartState,T=s.StarBlockStartState,S=s.BasicBlockStartState,_=r(45977),b=_.Transition,E=_.AtomTransition,w=_.SetTransition,I=_.NotSetTransition,C=_.RuleTransition,M=_.RangeTransition,k=_.ActionTransition,A=_.EpsilonTransition,N=_.WildcardTransition,O=_.PredicateTransition,R=_.PrecedencePredicateTransition,L=r(34065).m,P=(r(34065).Interval,r(85076).$),D=r(66380),j=D.LexerActionType,F=D.LexerSkipAction,q=D.LexerChannelAction,B=D.LexerCustomAction,Y=D.LexerMoreAction,U=D.LexerTypeAction,z=D.LexerPushModeAction,V=D.LexerPopModeAction,K=D.LexerModeAction,$="59627784-3BE5-417A-B9EB-8131A7286089",H=["AADB8D7E-AEEF-4415-AD2B-8204D6CF042E",$],W=$;function Z(t,e){var r=[];return r[t-1]=e,r.map((function(t){return e}))}function G(t){return null==t&&(t=P.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null,this}G.prototype.isFeatureSupported=function(t,e){var r=H.indexOf(t);return!(r<0)&&H.indexOf(e)>=r},G.prototype.deserialize=function(t){this.reset(t),this.checkVersion(),this.checkUUID();var e=this.readATN();this.readStates(e),this.readRules(e),this.readModes(e);var r=[];return this.readSets(e,r,this.readInt.bind(this)),this.isFeatureSupported($,this.uuid)&&this.readSets(e,r,this.readInt32.bind(this)),this.readEdges(e,r),this.readDecisions(e),this.readLexerActions(e),this.markPrecedenceDecisions(e),this.verifyATN(e),this.deserializationOptions.generateRuleBypassTransitions&&e.grammarType===i.PARSER&&(this.generateRuleBypassTransitions(e),this.verifyATN(e)),e},G.prototype.reset=function(t){var e=t.split("").map((function(t){var e=t.charCodeAt(0);return e>1?e-2:e+65533}));e[0]=t.charCodeAt(0),this.data=e,this.pos=0},G.prototype.checkVersion=function(){var t=this.readInt();if(3!==t)throw"Could not deserialize ATN with version "+t+" (expected 3)."},G.prototype.checkUUID=function(){var t=this.readUUID();if(H.indexOf(t)<0)throw W;this.uuid=t},G.prototype.readATN=function(){var t=this.readInt(),e=this.readInt();return new o(t,e)},G.prototype.readStates=function(t){for(var e,r,n,o=[],i=[],s=this.readInt(),l=0;l<s;l++){var u=this.readInt();if(u!==a.INVALID_TYPE){var c=this.readInt();65535===c&&(c=-1);var h=this.stateFactory(u,c);if(u===a.LOOP_END){var d=this.readInt();o.push([h,d])}else if(h instanceof p){var f=this.readInt();i.push([h,f])}t.addState(h)}else t.addState(null)}for(e=0;e<o.length;e++)(r=o[e])[0].loopBackState=t.states[r[1]];for(e=0;e<i.length;e++)(r=i[e])[0].endState=t.states[r[1]];var m=this.readInt();for(e=0;e<m;e++)n=this.readInt(),t.states[n].nonGreedy=!0;var g=this.readInt();for(e=0;e<g;e++)n=this.readInt(),t.states[n].isPrecedenceRule=!0},G.prototype.readRules=function(t){var e,r=this.readInt();for(t.grammarType===i.LEXER&&(t.ruleToTokenType=Z(r,0)),t.ruleToStartState=Z(r,0),e=0;e<r;e++){var o=this.readInt(),s=t.states[o];if(t.ruleToStartState[e]=s,t.grammarType===i.LEXER){var a=this.readInt();65535===a&&(a=n.EOF),t.ruleToTokenType[e]=a}}for(t.ruleToStopState=Z(r,0),e=0;e<t.states.length;e++){var l=t.states[e];l instanceof f&&(t.ruleToStopState[l.ruleIndex]=l,t.ruleToStartState[l.ruleIndex].stopState=l)}},G.prototype.readModes=function(t){for(var e=this.readInt(),r=0;r<e;r++){var n=this.readInt();t.modeToStartState.push(t.states[n])}},G.prototype.readSets=function(t,e,r){for(var n=this.readInt(),o=0;o<n;o++){var i=new L;e.push(i);var s=this.readInt();0!==this.readInt()&&i.addOne(-1);for(var a=0;a<s;a++){var l=r(),u=r();i.addRange(l,u)}}},G.prototype.readEdges=function(t,e){var r,n,o,i,s,a=this.readInt();for(r=0;r<a;r++){var l=this.readInt(),u=this.readInt(),c=this.readInt(),h=this.readInt(),d=this.readInt(),f=this.readInt();i=this.edgeFactory(t,c,l,u,h,d,f,e),t.states[l].addTransition(i)}for(r=0;r<t.states.length;r++)for(o=t.states[r],n=0;n<o.transitions.length;n++){var m=o.transitions[n];if(m instanceof C){var T=-1;t.ruleToStartState[m.target.ruleIndex].isPrecedenceRule&&0===m.precedence&&(T=m.target.ruleIndex),i=new A(m.followState,T),t.ruleToStopState[m.target.ruleIndex].addTransition(i)}}for(r=0;r<t.states.length;r++){if((o=t.states[r])instanceof p){if(null===o.endState)throw"IllegalState";if(null!==o.endState.startState)throw"IllegalState";o.endState.startState=o}if(o instanceof g)for(n=0;n<o.transitions.length;n++)(s=o.transitions[n].target)instanceof x&&(s.loopBackState=o);else if(o instanceof y)for(n=0;n<o.transitions.length;n++)(s=o.transitions[n].target)instanceof v&&(s.loopBackState=o)}},G.prototype.readDecisions=function(t){for(var e=this.readInt(),r=0;r<e;r++){var n=this.readInt(),o=t.states[n];t.decisionToState.push(o),o.decision=r}},G.prototype.readLexerActions=function(t){if(t.grammarType===i.LEXER){var e=this.readInt();t.lexerActions=Z(e,null);for(var r=0;r<e;r++){var n=this.readInt(),o=this.readInt();65535===o&&(o=-1);var s=this.readInt();65535===s&&(s=-1);var a=this.lexerActionFactory(n,o,s);t.lexerActions[r]=a}}},G.prototype.generateRuleBypassTransitions=function(t){var e,r=t.ruleToStartState.length;for(e=0;e<r;e++)t.ruleToTokenType[e]=t.maxTokenType+e+1;for(e=0;e<r;e++)this.generateRuleBypassTransition(t,e)},G.prototype.generateRuleBypassTransition=function(t,e){var r,n,o=new S;o.ruleIndex=e,t.addState(o);var i=new c;i.ruleIndex=e,t.addState(i),o.endState=i,t.defineDecisionState(o),i.startState=o;var s=null,a=null;if(t.ruleToStartState[e].isPrecedenceRule){for(a=null,r=0;r<t.states.length;r++)if(n=t.states[r],this.stateIsEndStateFor(n,e)){a=n,s=n.loopBackState.transitions[0];break}if(null===s)throw"Couldn't identify final state of the precedence rule prefix section."}else a=t.ruleToStopState[e];for(r=0;r<t.states.length;r++){n=t.states[r];for(var u=0;u<n.transitions.length;u++){var p=n.transitions[u];p!==s&&p.target===a&&(p.target=i)}}for(var h=t.ruleToStartState[e],d=h.transitions.length;d>0;)o.addTransition(h.transitions[d-1]),h.transitions=h.transitions.slice(-1);t.ruleToStartState[e].addTransition(new A(o)),i.addTransition(new A(a));var f=new l;t.addState(f),f.addTransition(new E(i,t.ruleToTokenType[e])),o.addTransition(new A(f))},G.prototype.stateIsEndStateFor=function(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof v))return null;var r=t.transitions[t.transitions.length-1].target;return r instanceof h&&r.epsilonOnlyTransitions&&r.transitions[0].target instanceof f?t:null},G.prototype.markPrecedenceDecisions=function(t){for(var e=0;e<t.states.length;e++){var r=t.states[e];if(r instanceof v&&t.ruleToStartState[r.ruleIndex].isPrecedenceRule){var n=r.transitions[r.transitions.length-1].target;n instanceof h&&n.epsilonOnlyTransitions&&n.transitions[0].target instanceof f&&(r.isPrecedenceDecision=!0)}}},G.prototype.verifyATN=function(t){if(this.deserializationOptions.verifyATN)for(var e=0;e<t.states.length;e++){var r=t.states[e];if(null!==r)if(this.checkCondition(r.epsilonOnlyTransitions||r.transitions.length<=1),r instanceof x)this.checkCondition(null!==r.loopBackState);else if(r instanceof v)if(this.checkCondition(null!==r.loopBackState),this.checkCondition(2===r.transitions.length),r.transitions[0].target instanceof T)this.checkCondition(r.transitions[1].target instanceof h),this.checkCondition(!r.nonGreedy);else{if(!(r.transitions[0].target instanceof h))throw"IllegalState";this.checkCondition(r.transitions[1].target instanceof T),this.checkCondition(r.nonGreedy)}else r instanceof y?(this.checkCondition(1===r.transitions.length),this.checkCondition(r.transitions[0].target instanceof v)):r instanceof h?this.checkCondition(null!==r.loopBackState):r instanceof d?this.checkCondition(null!==r.stopState):r instanceof p?this.checkCondition(null!==r.endState):r instanceof c?this.checkCondition(null!==r.startState):r instanceof u?this.checkCondition(r.transitions.length<=1||r.decision>=0):this.checkCondition(r.transitions.length<=1||r instanceof f)}},G.prototype.checkCondition=function(t,e){if(!t)throw null==e&&(e="IllegalState"),e},G.prototype.readInt=function(){return this.data[this.pos++]},G.prototype.readInt32=function(){return this.readInt()|this.readInt()<<16},G.prototype.readLong=function(){return 4294967295&this.readInt32()|this.readInt32()<<32};var J=function(){for(var t=[],e=0;e<256;e++)t[e]=(e+256).toString(16).substr(1).toUpperCase();return t}();G.prototype.readUUID=function(){for(var t=[],e=7;e>=0;e--){var r=this.readInt();t[2*e+1]=255&r,t[2*e]=r>>8&255}return J[t[0]]+J[t[1]]+J[t[2]]+J[t[3]]+"-"+J[t[4]]+J[t[5]]+"-"+J[t[6]]+J[t[7]]+"-"+J[t[8]]+J[t[9]]+"-"+J[t[10]]+J[t[11]]+J[t[12]]+J[t[13]]+J[t[14]]+J[t[15]]},G.prototype.edgeFactory=function(t,e,r,o,i,s,a,l){var u=t.states[o];switch(e){case b.EPSILON:return new A(u);case b.RANGE:return new M(u,0!==a?n.EOF:i,s);case b.RULE:return new C(t.states[i],s,a,u);case b.PREDICATE:return new O(u,i,s,0!==a);case b.PRECEDENCE:return new R(u,i);case b.ATOM:return new E(u,0!==a?n.EOF:i);case b.ACTION:return new k(u,i,s,0!==a);case b.SET:return new w(u,l[i]);case b.NOT_SET:return new I(u,l[i]);case b.WILDCARD:return new N(u);default:throw"The specified transition type: "+e+" is not valid."}},G.prototype.stateFactory=function(t,e){if(null===this.stateFactories){var r=[];r[a.INVALID_TYPE]=null,r[a.BASIC]=function(){return new l},r[a.RULE_START]=function(){return new d},r[a.BLOCK_START]=function(){return new S},r[a.PLUS_BLOCK_START]=function(){return new x},r[a.STAR_BLOCK_START]=function(){return new T},r[a.TOKEN_START]=function(){return new m},r[a.RULE_STOP]=function(){return new f},r[a.BLOCK_END]=function(){return new c},r[a.STAR_LOOP_BACK]=function(){return new y},r[a.STAR_LOOP_ENTRY]=function(){return new v},r[a.PLUS_LOOP_BACK]=function(){return new g},r[a.LOOP_END]=function(){return new h},this.stateFactories=r}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";var n=this.stateFactories[t]();if(null!==n)return n.ruleIndex=e,n},G.prototype.lexerActionFactory=function(t,e,r){if(null===this.actionFactories){var n=[];n[j.CHANNEL]=function(t,e){return new q(t)},n[j.CUSTOM]=function(t,e){return new B(t,e)},n[j.MODE]=function(t,e){return new K(t)},n[j.MORE]=function(t,e){return Y.INSTANCE},n[j.POP_MODE]=function(t,e){return V.INSTANCE},n[j.PUSH_MODE]=function(t,e){return new z(t)},n[j.SKIP]=function(t,e){return F.INSTANCE},n[j.TYPE]=function(t,e){return new U(t)},this.actionFactories=n}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,r)},e.ATNDeserializer=G},16679:(t,e,r)=>{var n=e;n.der=r(91684),n.pem=r(95989)},17436:(t,e,r)=>{var n=r(86291).Token,o=r(64116),i=o.NoViableAltException,s=o.InputMismatchException,a=o.FailedPredicateException,l=o.ParseCancellationException,u=r(49832).ATNState,p=r(34065).Interval,c=r(34065).m;function h(){}function d(){return h.call(this),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this}function f(){return d.call(this),this}h.prototype.reset=function(t){},h.prototype.recoverInline=function(t){},h.prototype.recover=function(t,e){},h.prototype.sync=function(t){},h.prototype.inErrorRecoveryMode=function(t){},h.prototype.reportError=function(t){},d.prototype=Object.create(h.prototype),d.prototype.constructor=d,d.prototype.reset=function(t){this.endErrorCondition(t)},d.prototype.beginErrorCondition=function(t){this.errorRecoveryMode=!0},d.prototype.inErrorRecoveryMode=function(t){return this.errorRecoveryMode},d.prototype.endErrorCondition=function(t){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1},d.prototype.reportMatch=function(t){this.endErrorCondition(t)},d.prototype.reportError=function(t,e){this.inErrorRecoveryMode(t)||(this.beginErrorCondition(t),e instanceof i?this.reportNoViableAlternative(t,e):e instanceof s?this.reportInputMismatch(t,e):e instanceof a?this.reportFailedPredicate(t,e):(console.log("unknown recognition error type: "+e.constructor.name),console.log(e.stack),t.notifyErrorListeners(e.getOffendingToken(),e.getMessage(),e)))},d.prototype.recover=function(t,e){this.lastErrorIndex===t.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(t.state)>=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);var r=this.getErrorRecoverySet(t);this.consumeUntil(t,r)},d.prototype.sync=function(t){if(!this.inErrorRecoveryMode(t)){var e=t._interp.atn.states[t.state],r=t.getTokenStream().LA(1),o=t.atn.nextTokens(e);if(!o.contains(n.EPSILON)&&!o.contains(r))switch(e.stateType){case u.BLOCK_START:case u.STAR_BLOCK_START:case u.PLUS_BLOCK_START:case u.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new s(t);case u.PLUS_LOOP_BACK:case u.STAR_LOOP_BACK:this.reportUnwantedToken(t);var i=new c;i.addSet(t.getExpectedTokens());var a=i.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,a)}}},d.prototype.reportNoViableAlternative=function(t,e){var r,o=t.getTokenStream();r=null!==o?e.startToken.type===n.EOF?"<EOF>":o.getText(new p(e.startToken.tokenIndex,e.offendingToken.tokenIndex)):"<unknown input>";var i="no viable alternative at input "+this.escapeWSAndQuote(r);t.notifyErrorListeners(i,e.offendingToken,e)},d.prototype.reportInputMismatch=function(t,e){var r="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e.offendingToken,e)},d.prototype.reportFailedPredicate=function(t,e){var r="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(r,e.offendingToken,e)},d.prototype.reportUnwantedToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),r="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e,null)}},d.prototype.reportMissingToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),r="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(r,e,null)}},d.prototype.recoverInline=function(t){var e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new s(t)},d.prototype.singleTokenInsertion=function(t){var e=t.getTokenStream().LA(1),r=t._interp.atn,n=r.states[t.state].transitions[0].target;return!!r.nextTokens(n,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)},d.prototype.singleTokenDeletion=function(t){var e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();var r=t.getCurrentToken();return this.reportMatch(t),r}return null},d.prototype.getMissingSymbol=function(t){var e,r=t.getCurrentToken(),o=this.getExpectedTokens(t).first();e=o===n.EOF?"<missing EOF>":"<missing "+t.literalNames[o]+">";var i=r,s=t.getTokenStream().LT(-1);return i.type===n.EOF&&null!==s&&(i=s),t.getTokenFactory().create(i.source,o,e,n.DEFAULT_CHANNEL,-1,-1,i.line,i.column)},d.prototype.getExpectedTokens=function(t){return t.getExpectedTokens()},d.prototype.getTokenErrorDisplay=function(t){if(null===t)return"<no token>";var e=t.text;return null===e&&(e=t.type===n.EOF?"<EOF>":"<"+t.type+">"),this.escapeWSAndQuote(e)},d.prototype.escapeWSAndQuote=function(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"},d.prototype.getErrorRecoverySet=function(t){for(var e=t._interp.atn,r=t._ctx,o=new c;null!==r&&r.invokingState>=0;){var i=e.states[r.invokingState].transitions[0],s=e.nextTokens(i.followState);o.addSet(s),r=r.parentCtx}return o.removeOne(n.EPSILON),o},d.prototype.consumeUntil=function(t,e){for(var r=t.getTokenStream().LA(1);r!==n.EOF&&!e.contains(r);)t.consume(),r=t.getTokenStream().LA(1)},f.prototype=Object.create(d.prototype),f.prototype.constructor=f,f.prototype.recover=function(t,e){for(var r=t._ctx;null!==r;)r.exception=e,r=r.parentCtx;throw new l(e)},f.prototype.recoverInline=function(t){this.recover(t,new s(t))},f.prototype.sync=function(t){},e.BailErrorStrategy=f,e.$=d},17871:(t,e,r)=>{var n=e;n.Reporter=r(26906).a,n.DecoderBuffer=r(11593).t,n.EncoderBuffer=r(11593).d,n.Node=r(25759)},20369:(t,e,r)=>{var n=r(5527).Set,o=r(23952).X,i=r(49832).StarLoopEntryState,s=r(90975).Q,a=r(20509).DFASerializer,l=r(20509).LexerDFASerializer;function u(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new n,this.s0=null,this.precedenceDfa=!1,t instanceof i&&t.isPrecedenceDecision){this.precedenceDfa=!0;var r=new o(null,new s);r.edges=[],r.isAcceptState=!1,r.requiresFullContext=!1,this.s0=r}return this}u.prototype.getPrecedenceStartState=function(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null},u.prototype.setPrecedenceStartState=function(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)},u.prototype.setPrecedenceDfa=function(t){if(this.precedenceDfa!==t){if(this._states=new DFAStatesSet,t){var e=new o(null,new s);e.edges=[],e.isAcceptState=!1,e.requiresFullContext=!1,this.s0=e}else this.s0=null;this.precedenceDfa=t}},Object.defineProperty(u.prototype,"states",{get:function(){return this._states}}),u.prototype.sortedStates=function(){return this._states.values().sort((function(t,e){return t.stateNumber-e.stateNumber}))},u.prototype.toString=function(t,e){return t=t||null,e=e||null,null===this.s0?"":new a(this,t,e).toString()},u.prototype.toLexerString=function(){return null===this.s0?"":new l(this).toString()},e.DFA=u},20509:(t,e)=>{function r(t,e,r){return this.dfa=t,this.literalNames=e||[],this.symbolicNames=r||[],this}function n(t){return r.call(this,t,null),this}r.prototype.toString=function(){if(null===this.dfa.s0)return null;for(var t="",e=this.dfa.sortedStates(),r=0;r<e.length;r++){var n=e[r];if(null!==n.edges)for(var o=n.edges.length,i=0;i<o;i++){var s=n.edges[i]||null;null!==s&&2147483647!==s.stateNumber&&(t=(t=(t=(t=(t=(t=t.concat(this.getStateString(n))).concat("-")).concat(this.getEdgeLabel(i))).concat("->")).concat(this.getStateString(s))).concat("\n"))}}return 0===t.length?null:t},r.prototype.getEdgeLabel=function(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)},r.prototype.getStateString=function(t){var e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+t.predicates.toString():e+"=>"+t.prediction.toString():e},n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.prototype.getEdgeLabel=function(t){return"'"+String.fromCharCode(t)+"'"},e.DFASerializer=r,e.LexerDFASerializer=n},23952:(t,e,r)=>{var n=r(90975).Q,o=r(5527),i=o.Hash,s=o.Set;function a(t,e){return this.alt=e,this.pred=t,this}function l(t,e){return null===t&&(t=-1),null===e&&(e=new n),this.stateNumber=t,this.configs=e,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}a.prototype.toString=function(){return"("+this.pred+", "+this.alt+")"},l.prototype.getAltSet=function(){var t=new s;if(null!==this.configs)for(var e=0;e<this.configs.length;e++){var r=this.configs[e];t.add(r.alt)}return 0===t.length?null:t},l.prototype.equals=function(t){return this===t||t instanceof l&&this.configs.equals(t.configs)},l.prototype.toString=function(){var t=this.stateNumber+":"+this.configs;return this.isAcceptState&&(t+="=>",null!==this.predicates?t+=this.predicates:t+=this.prediction),t},l.prototype.hashCode=function(){var t=new i;return t.update(this.configs),this.isAcceptState&&(null!==this.predicates?t.update(this.predicates):t.update(this.prediction)),t.finish()},e.X=l,e.PredPrediction=a},25759:(t,e,r)=>{var n=r(17871).Reporter,o=r(17871).EncoderBuffer,i=r(17871).DecoderBuffer,s=r(85527),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],l=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function u(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=u;var p=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){var t=this._baseState,e={};p.forEach((function(r){e[r]=t[r]}));var r=new this.constructor(e.parent);return r._baseState=e,r},u.prototype._wrap=function(){var t=this._baseState;l.forEach((function(e){this[e]=function(){var r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}}),this)},u.prototype._init=function(t){var e=this._baseState;s(null===e.parent),t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this),s.equal(e.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(t){var e=this._baseState,r=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==r.length&&(s(null===e.children),e.children=r,r.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(s(null===e.args),e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;var e={};return Object.keys(t).forEach((function(r){r==(0|r)&&(r|=0);var n=t[r];e[n]=r})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){u.prototype[t]=function(){var e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),a.forEach((function(t){u.prototype[t]=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===e.tag),e.tag=t,this._useArgs(r),this}})),u.prototype.use=function(t){s(t);var e=this._baseState;return s(null===e.use),e.use=t,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(t){var e=this._baseState;return s(null===e.default),e.default=t,e.optional=!0,this},u.prototype.explicit=function(t){var e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.explicit=t,this},u.prototype.implicit=function(t){var e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.implicit=t,this},u.prototype.obj=function(){var t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},u.prototype.key=function(t){var e=this._baseState;return s(null===e.key),e.key=t,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(t){var e=this._baseState;return s(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},u.prototype.contains=function(t){var e=this._baseState;return s(null===e.use),e.contains=t,this},u.prototype._decode=function(t,e){var r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));var n,o=r.default,s=!0,a=null;if(null!==r.key&&(a=t.enterKey(r.key)),r.optional){var l=null;if(null!==r.explicit?l=r.explicit:null!==r.implicit?l=r.implicit:null!==r.tag&&(l=r.tag),null!==l||r.any){if(s=this._peekTag(t,l,r.any),t.isError(s))return s}else{var u=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),s=!0}catch(t){s=!1}t.restore(u)}}if(r.obj&&s&&(n=t.enterObject()),s){if(null!==r.explicit){var p=this._decodeTag(t,r.explicit);if(t.isError(p))return p;t=p}var c=t.offset;if(null===r.use&&null===r.choice){r.any&&(u=t.save());var h=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(h))return h;r.any?o=t.raw(u):t=h}if(e&&e.track&&null!==r.tag&&e.track(t.path(),c,t.length,"tagged"),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,"content"),r.any||(o=null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e)),t.isError(o))return o;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(t,e)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var d=new i(o);o=this._getUse(r.contains,t._reporterState.obj)._decode(d,e)}}return r.obj&&s&&(o=t.leaveObject(n)),null===r.key||null===o&&!0!==s?null!==a&&t.exitKey(a):t.leaveKey(a,r.key,o),o},u.prototype._decodeGeneric=function(t,e,r){var n=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,n.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):"objid"===t&&n.args?this._decodeObjid(e,n.args[0],n.args[1],r):"objid"===t?this._decodeObjid(e,null,null,r):"gentime"===t||"utctime"===t?this._decodeTime(e,t,r):"null_"===t?this._decodeNull(e,r):"bool"===t?this._decodeBool(e,r):"objDesc"===t?this._decodeStr(e,t,r):"int"===t||"enum"===t?this._decodeInt(e,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,e._reporterState.obj)._decode(e,r):e.error("unknown tag: "+t)},u.prototype._getUse=function(t,e){var r=this._baseState;return r.useDecoder=this._use(t,e),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},u.prototype._decodeChoice=function(t,e){var r=this._baseState,n=null,o=!1;return Object.keys(r.choice).some((function(i){var s=t.save(),a=r.choice[i];try{var l=a._decode(t,e);if(t.isError(l))return!1;n={type:i,value:l},o=!0}catch(e){return t.restore(s),!1}return!0}),this),o?n:t.error("Choice not matched")},u.prototype._createEncoderBuffer=function(t){return new o(t,this.reporter)},u.prototype._encode=function(t,e,r){var n=this._baseState;if(null===n.default||n.default!==t){var o=this._encodeValue(t,e,r);if(void 0!==o&&!this._skipDefault(o,e,r))return o}},u.prototype._encodeValue=function(t,e,r){var o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,e||new n);var i=null;if(this.reporter=e,o.optional&&void 0===t){if(null===o.default)return;t=o.default}var s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,e);else if(o.contains)s=this._getUse(o.contains,r)._encode(t,e),a=!0;else if(o.children)s=o.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error("Child should have a key");var n=e.enterKey(r._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");var o=r._encode(t[r._baseState.key],e,t);return e.leaveKey(n),o}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return e.error("Too many args for : "+o.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");var l=this.clone();l._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(r){var n=this._baseState;return this._getUse(n.args[0],t)._encode(r,e)}),l))}else null!==o.use?i=this._getUse(o.use,r)._encode(t,e):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){var u=null!==o.implicit?o.implicit:o.tag,p=null===o.implicit?"universal":"context";null===u?null===o.use&&e.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(u,a,p,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},u.prototype._encodeChoice=function(t,e){var r=this._baseState,n=r.choice[t.type];return n||s(!1,t.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(t.value,e)},u.prototype._encodePrimitive=function(t,e){var r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},u.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},u.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(t)}},26906:(t,e,r)=>{var n=r(46324);function o(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function i(t,e){this.path=t,this.rethrow(e)}e.a=o,o.prototype.isError=function(t){return t instanceof i},o.prototype.save=function(){var t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},o.prototype.restore=function(t){var e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},o.prototype.enterKey=function(t){return this._reporterState.path.push(t)},o.prototype.exitKey=function(t){var e=this._reporterState;e.path=e.path.slice(0,t-1)},o.prototype.leaveKey=function(t,e,r){var n=this._reporterState;this.exitKey(t),null!==n.obj&&(n.obj[e]=r)},o.prototype.path=function(){return this._reporterState.path.join("/")},o.prototype.enterObject=function(){var t=this._reporterState,e=t.obj;return t.obj={},e},o.prototype.leaveObject=function(t){var e=this._reporterState,r=e.obj;return e.obj=t,r},o.prototype.error=function(t){var e,r=this._reporterState,n=t instanceof i;if(e=n?t:new i(r.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!r.options.partial)throw e;return n||r.errors.push(e),e},o.prototype.wrapResult=function(t){var e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},n(i,Error),i.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}},28118:(t,e,r)=>{e.atn=r(68567),e.codepointat=r(88221),e.dfa=r(31732),e.fromcodepoint=r(512),e.tree=r(35671),e.error=r(45659),e.Token=r(86291).Token,e.CharStreams=r(39635).CharStreams,e.CommonToken=r(86291).CommonToken,e.InputStream=r(46550).InputStream,e.FileStream=r(82722).FileStream,e.CommonTokenStream=r(76488).CommonTokenStream,e.Lexer=r(13048).Lexer,e.Parser=r(33431).Parser;var n=r(1754);e.PredictionContextCache=n.PredictionContextCache,e.ParserRuleContext=r(37170).ParserRuleContext,e.Interval=r(34065).Interval,e.Utils=r(5527)},28226:(t,e,r)=>{r.d(e,{Sd:()=>vr,gM:()=>ur,ut:()=>cr,vl:()=>yr});var n,o=r(33997),i=r(86637),s=r(74770),a=r(42343),l=r(42528),u=r(78590),p=r(92346),c=r(21655).URL,h=r(15088).process,d=Object.defineProperty,f="AI_InvalidArgumentError",m=`vercel.ai.error.${f}`,g=Symbol.for(m),y=class extends i.bD{constructor({parameter:t,value:e,message:r}){super({name:f,message:`Invalid argument for parameter ${t}: ${r}`}),this[n]=!0,this.parameter=t,this.value=e}static isInstance(t){return i.bD.hasMarker(t,m)}};n=g;var v=Symbol.for("vercel.ai.error.AI_InvalidStreamPartError");i.bD;var x,T="AI_InvalidToolApprovalError",S=`vercel.ai.error.${T}`,_=Symbol.for(S),b=class extends i.bD{constructor({approvalId:t}){super({name:T,message:`Tool approval response references unknown approvalId: "${t}". No matching tool-approval-request found in message history.`}),this[x]=!0,this.approvalId=t}static isInstance(t){return i.bD.hasMarker(t,S)}};x=_;var E,w="AI_InvalidToolInputError",I=`vercel.ai.error.${w}`,C=Symbol.for(I),M=class extends i.bD{constructor({toolInput:t,toolName:e,cause:r,message:n=`Invalid input for tool ${e}: ${(0,i.u1)(r)}`}){super({name:w,message:n,cause:r}),this[E]=!0,this.toolInput=t,this.toolName=e}static isInstance(t){return i.bD.hasMarker(t,I)}};E=C;var k,A="AI_ToolCallNotFoundForApprovalError",N=`vercel.ai.error.${A}`,O=Symbol.for(N),R=class extends i.bD{constructor({toolCallId:t,approvalId:e}){super({name:A,message:`Tool call "${t}" not found for approval request "${e}".`}),this[k]=!0,this.toolCallId=t,this.approvalId=e}static isInstance(t){return i.bD.hasMarker(t,N)}};k=O;var L,P="AI_MissingToolResultsError",D=`vercel.ai.error.${P}`,j=Symbol.for(D),F=class extends i.bD{constructor({toolCallIds:t}){super({name:P,message:`Tool result${t.length>1?"s are":" is"} missing for tool call${t.length>1?"s":""} ${t.join(", ")}.`}),this[L]=!0,this.toolCallIds=t}static isInstance(t){return i.bD.hasMarker(t,D)}};L=j;var q=Symbol.for("vercel.ai.error.AI_NoImageGeneratedError");i.bD;var B,Y="AI_NoObjectGeneratedError",U=`vercel.ai.error.${Y}`,z=Symbol.for(U),V=class extends i.bD{constructor({message:t="No object generated.",cause:e,text:r,response:n,usage:o,finishReason:i}){super({name:Y,message:t,cause:e}),this[B]=!0,this.text=r,this.response=n,this.usage=o,this.finishReason=i}static isInstance(t){return i.bD.hasMarker(t,U)}};B=z;var K,$="AI_NoOutputGeneratedError",H=`vercel.ai.error.${$}`,W=Symbol.for(H),Z=class extends i.bD{constructor({message:t="No output generated.",cause:e}={}){super({name:$,message:t,cause:e}),this[K]=!0}static isInstance(t){return i.bD.hasMarker(t,H)}};K=W;var G=Symbol.for("vercel.ai.error.AI_NoSpeechGeneratedError");i.bD;var J=Symbol.for("vercel.ai.error.AI_NoTranscriptGeneratedError");i.bD;var X=Symbol.for("vercel.ai.error.AI_NoVideoGeneratedError");i.bD;var Q,tt="AI_NoSuchToolError",et=`vercel.ai.error.${tt}`,rt=Symbol.for(et),nt=class extends i.bD{constructor({toolName:t,availableTools:e,message:r=`Model tried to call unavailable tool '${t}'. ${void 0===e?"No tools are available.":`Available tools: ${e.join(", ")}.`}`}){super({name:tt,message:r}),this[Q]=!0,this.toolName=t,this.availableTools=e}static isInstance(t){return i.bD.hasMarker(t,et)}};Q=rt;var ot,it="AI_ToolCallRepairError",st=`vercel.ai.error.${it}`,at=Symbol.for(st),lt=class extends i.bD{constructor({cause:t,originalError:e,message:r=`Error repairing tool call: ${(0,i.u1)(t)}`}){super({name:it,message:r,cause:t}),this[ot]=!0,this.originalError=e}static isInstance(t){return i.bD.hasMarker(t,st)}};ot=at;var ut,pt=class extends i.bD{constructor(t){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${t.version} for provider "${t.provider}" and model "${t.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=t.version,this.provider=t.provider,this.modelId=t.modelId}},ct="AI_UIMessageStreamError",ht=`vercel.ai.error.${ct}`,dt=Symbol.for(ht),ft=class extends i.bD{constructor({chunkType:t,chunkId:e,message:r}){super({name:ct,message:r}),this[ut]=!0,this.chunkType=t,this.chunkId=e}static isInstance(t){return i.bD.hasMarker(t,ht)}};ut=dt;var mt=Symbol.for("vercel.ai.error.AI_InvalidDataContentError");i.bD;var gt,yt="AI_InvalidMessageRoleError",vt=`vercel.ai.error.${yt}`,xt=Symbol.for(vt),Tt=class extends i.bD{constructor({role:t,message:e=`Invalid message role: '${t}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:yt,message:e}),this[gt]=!0,this.role=t}static isInstance(t){return i.bD.hasMarker(t,vt)}};gt=xt;var St,_t="AI_MessageConversionError",bt=`vercel.ai.error.${_t}`,Et=Symbol.for(bt),wt=class extends i.bD{constructor({originalMessage:t,message:e}){super({name:_t,message:e}),this[St]=!0,this.originalMessage=t}static isInstance(t){return i.bD.hasMarker(t,bt)}};St=Et;var It,Ct="AI_RetryError",Mt=`vercel.ai.error.${Ct}`,kt=Symbol.for(Mt),At=class extends i.bD{constructor({message:t,reason:e,errors:r}){super({name:Ct,message:t}),this[It]=!0,this.reason=e,this.errors=r,this.lastError=r[r.length-1]}static isInstance(t){return i.bD.hasMarker(t,Mt)}};function Nt({warning:t,provider:e,model:r}){const n=`AI SDK Warning (${e} / ${r}):`;switch(t.type){case"unsupported":{let e=`${n} The feature "${t.feature}" is not supported.`;return t.details&&(e+=` ${t.details}`),e}case"compatibility":{let e=`${n} The feature "${t.feature}" is used in a compatibility mode.`;return t.details&&(e+=` ${t.details}`),e}case"other":return`${n} ${t.message}`;default:return`${n} ${JSON.stringify(t,null,2)}`}}It=kt;var Ot=!1,Rt=t=>{if(0===t.warnings.length)return;const e=globalThis.AI_SDK_LOG_WARNINGS;if(!1!==e)if("function"!=typeof e){Ot||(Ot=!0,console.info("AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false."));for(const e of t.warnings)console.warn(Nt({warning:e,provider:t.provider,model:t.model}))}else e(t)};function Lt(t){return"v3"===t.specificationVersion?t:(function({provider:t,modelId:e}){Rt({warnings:[{type:"compatibility",feature:"specificationVersion",details:"Using v2 specification compatibility mode. Some features may not be available."}],provider:t,model:e})}({provider:t.provider,modelId:t.modelId}),new Proxy(t,{get(t,e){switch(e){case"specificationVersion":return"v3";case"doGenerate":return async(...e)=>{const r=await t.doGenerate(...e);return{...r,finishReason:Pt(r.finishReason),usage:Dt(r.usage)}};case"doStream":return async(...e)=>{const r=await t.doStream(...e);return{...r,stream:(n=r.stream,n.pipeThrough(new TransformStream({transform(t,e){"finish"===t.type?e.enqueue({...t,finishReason:Pt(t.finishReason),usage:Dt(t.usage)}):e.enqueue(t)}})))};var n};default:return t[e]}}}))}function Pt(t){return{unified:"unknown"===t?"other":t,raw:void 0}}function Dt(t){return{inputTokens:{total:t.inputTokens,noCache:void 0,cacheRead:t.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:t.outputTokens,text:void 0,reasoning:t.reasoningTokens}}}function jt(t){if("string"!=typeof t){if("v3"!==t.specificationVersion&&"v2"!==t.specificationVersion){const e=t;throw new pt({version:e.specificationVersion,provider:e.provider,modelId:e.modelId})}return Lt(t)}return(null!=(e=globalThis.AI_SDK_DEFAULT_PROVIDER)?e:s.JS).languageModel(t);var e}function Ft(t){if(null!=t)return"number"==typeof t?t:t.totalMs}var qt=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],Bt=t=>{const e="string"==typeof t?(0,o.Z9)(t):t,r=(127&e[6])<<21|(127&e[7])<<14|(127&e[8])<<7|127&e[9];return e.slice(r+10)};var Yt="6.0.86",Ut=async({url:t,maxBytes:e,abortSignal:r})=>{var n;const i=t.toString();try{const t=await fetch(i,{headers:(0,o.WZ)({},`ai-sdk/${Yt}`,(0,o.G1)()),signal:r});if(!t.ok)throw new o.nV({url:i,statusCode:t.status,statusText:t.statusText});return{data:await(0,o.cS)({response:t,url:i,maxBytes:null!=e?e:o.W}),mediaType:null!=(n=t.headers.get("content-type"))?n:void 0}}catch(t){if(o.nV.isInstance(t))throw t;throw new o.nV({url:i,cause:t})}},zt=(t=Ut)=>e=>Promise.all(e.map((async e=>e.isUrlSupportedByModel?null:t(e))));var Vt=a.KC([a.Yj(),a.Nl(Uint8Array),a.Nl(ArrayBuffer),a.Ie((t=>{var e,r;return null!=(r=null==(e=globalThis.Buffer)?void 0:e.isBuffer(t))&&r}),{message:"Must be a Buffer"})]);function Kt(t){if(t instanceof Uint8Array)return{data:t,mediaType:void 0};if(t instanceof ArrayBuffer)return{data:new Uint8Array(t),mediaType:void 0};if("string"==typeof t)try{t=new c(t)}catch(t){}if(t instanceof c&&"data:"===t.protocol){const{mediaType:e,base64Content:r}=function(t){try{const[e,r]=t.split(",");return{mediaType:e.split(";")[0].split(":")[1],base64Content:r}}catch(t){return{mediaType:void 0,base64Content:void 0}}}(t.toString());if(null==e||null==r)throw new i.bD({name:"InvalidDataContentError",message:`Invalid data URL format in content ${t.toString()}`});return{data:r,mediaType:e}}return{data:t,mediaType:void 0}}function $t(t){return void 0===t?[]:Array.isArray(t)?t:[t]}async function Ht({prompt:t,supportedUrls:e,download:r=zt()}){const n=await async function(t,e,r){const n=t.filter((t=>"user"===t.role)).map((t=>t.content)).filter((t=>Array.isArray(t))).flat().filter((t=>"image"===t.type||"file"===t.type)).map((t=>{var e;const r=null!=(e=t.mediaType)?e:"image"===t.type?"image/*":void 0;let n="image"===t.type?t.image:t.data;if("string"==typeof n)try{n=new c(n)}catch(t){}return{mediaType:r,data:n}})).filter((t=>t.data instanceof c)).map((t=>({url:t.data,isUrlSupportedByModel:null!=t.mediaType&&(0,o.qs)({url:t.data.toString(),mediaType:t.mediaType,supportedUrls:r})}))),i=await e(n);return Object.fromEntries(i.map(((t,e)=>null==t?null:[n[e].url.toString(),{data:t.data,mediaType:t.mediaType}])).filter((t=>null!=t)))}(t.messages,r,e),i=new Map;for(const e of t.messages)if("assistant"===e.role&&Array.isArray(e.content))for(const t of e.content)"tool-approval-request"===t.type&&"approvalId"in t&&"toolCallId"in t&&i.set(t.approvalId,t.toolCallId);const s=new Set;for(const e of t.messages)if("tool"===e.role)for(const t of e.content)if("tool-approval-response"===t.type){const e=i.get(t.approvalId);e&&s.add(e)}const a=[...null!=t.system?"string"==typeof t.system?[{role:"system",content:t.system}]:$t(t.system).map((t=>({role:"system",content:t.content,providerOptions:t.providerOptions}))):[],...t.messages.map((t=>function({message:t,downloadedAssets:e}){const r=t.role;switch(r){case"system":return{role:"system",content:t.content,providerOptions:t.providerOptions};case"user":return"string"==typeof t.content?{role:"user",content:[{type:"text",text:t.content}],providerOptions:t.providerOptions}:{role:"user",content:t.content.map((t=>function(t,e){var r;if("text"===t.type)return{type:"text",text:t.text,providerOptions:t.providerOptions};let n;const i=t.type;switch(i){case"image":n=t.image;break;case"file":n=t.data;break;default:throw new Error(`Unsupported part type: ${i}`)}const{data:s,mediaType:a}=Kt(n);let l=null!=a?a:t.mediaType,u=s;if(u instanceof c){const t=e[u.toString()];t&&(u=t.data,null!=l||(l=t.mediaType))}switch(i){case"image":return(u instanceof Uint8Array||"string"==typeof u)&&(l=null!=(r=function({data:t,signatures:e}){const r=function(t){return"string"==typeof t&&t.startsWith("SUQz")||"string"!=typeof t&&t.length>10&&73===t[0]&&68===t[1]&&51===t[2]?Bt(t):t}(t),n="string"==typeof r?(0,o.Z9)(r.substring(0,Math.min(r.length,24))):r;for(const t of e)if(n.length>=t.bytesPrefix.length&&t.bytesPrefix.every(((t,e)=>null===t||n[e]===t)))return t.mediaType}({data:u,signatures:qt}))?r:l),{type:"file",mediaType:null!=l?l:"image/*",filename:void 0,data:u,providerOptions:t.providerOptions};case"file":if(null==l)throw new Error("Media type is missing for file part");return{type:"file",mediaType:l,filename:t.filename,data:u,providerOptions:t.providerOptions}}}(t,e))).filter((t=>"text"!==t.type||""!==t.text)),providerOptions:t.providerOptions};case"assistant":return"string"==typeof t.content?{role:"assistant",content:[{type:"text",text:t.content}],providerOptions:t.providerOptions}:{role:"assistant",content:t.content.filter((t=>"text"!==t.type||""!==t.text||null!=t.providerOptions)).filter((t=>"tool-approval-request"!==t.type)).map((t=>{const e=t.providerOptions;switch(t.type){case"file":{const{data:r,mediaType:n}=Kt(t.data);return{type:"file",data:r,filename:t.filename,mediaType:null!=n?n:t.mediaType,providerOptions:e}}case"reasoning":return{type:"reasoning",text:t.text,providerOptions:e};case"text":return{type:"text",text:t.text,providerOptions:e};case"tool-call":return{type:"tool-call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,providerExecuted:t.providerExecuted,providerOptions:e};case"tool-result":return{type:"tool-result",toolCallId:t.toolCallId,toolName:t.toolName,output:Wt(t.output),providerOptions:e}}})),providerOptions:t.providerOptions};case"tool":return{role:"tool",content:t.content.filter((t=>"tool-approval-response"!==t.type||t.providerExecuted)).map((t=>{switch(t.type){case"tool-result":return{type:"tool-result",toolCallId:t.toolCallId,toolName:t.toolName,output:Wt(t.output),providerOptions:t.providerOptions};case"tool-approval-response":return{type:"tool-approval-response",approvalId:t.approvalId,approved:t.approved,reason:t.reason}}})),providerOptions:t.providerOptions};default:throw new Tt({role:r})}}({message:t,downloadedAssets:n})))],l=[];for(const t of a){if("tool"!==t.role){l.push(t);continue}const e=l.at(-1);"tool"===(null==e?void 0:e.role)?e.content.push(...t.content):l.push(t)}const u=new Set;for(const t of l)switch(t.role){case"assistant":for(const e of t.content)"tool-call"!==e.type||e.providerExecuted||u.add(e.toolCallId);break;case"tool":for(const e of t.content)"tool-result"===e.type&&u.delete(e.toolCallId);break;case"user":case"system":for(const t of s)u.delete(t);if(u.size>0)throw new F({toolCallIds:Array.from(u)})}for(const t of s)u.delete(t);if(u.size>0)throw new F({toolCallIds:Array.from(u)});return l.filter((t=>"tool"!==t.role||t.content.length>0))}function Wt(t){return"content"!==t.type?t:{type:"content",value:t.value.map((t=>"media"!==t.type?t:t.mediaType.startsWith("image/")?{type:"image-data",data:t.data,mediaType:t.mediaType}:{type:"file-data",data:t.data,mediaType:t.mediaType}))}}async function Zt({toolCallId:t,input:e,output:r,tool:n,errorMode:o}){return"text"===o?{type:"error-text",value:(0,i.u1)(r)}:"json"===o?{type:"error-json",value:Gt(r)}:(null==n?void 0:n.toModelOutput)?await n.toModelOutput({toolCallId:t,input:e,output:r}):"string"==typeof r?{type:"text",value:r}:{type:"json",value:Gt(r)}}function Gt(t){return void 0===t?null:t}var Jt=a.RZ((()=>a.KC([a.ch(),a.Yj(),a.ai(),a.zM(),a.g1(a.Yj(),Jt.optional()),a.YO(Jt)]))),Xt=a.g1(a.Yj(),a.g1(a.Yj(),Jt.optional())),Qt=a.Ik({type:a.eu("text"),text:a.Yj(),providerOptions:Xt.optional()}),te=a.Ik({type:a.eu("image"),image:a.KC([Vt,a.Nl(c)]),mediaType:a.Yj().optional(),providerOptions:Xt.optional()}),ee=a.Ik({type:a.eu("file"),data:a.KC([Vt,a.Nl(c)]),filename:a.Yj().optional(),mediaType:a.Yj(),providerOptions:Xt.optional()}),re=a.Ik({type:a.eu("reasoning"),text:a.Yj(),providerOptions:Xt.optional()}),ne=a.Ik({type:a.eu("tool-call"),toolCallId:a.Yj(),toolName:a.Yj(),input:a.L5(),providerOptions:Xt.optional(),providerExecuted:a.zM().optional()}),oe=a.gM("type",[a.Ik({type:a.eu("text"),value:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("json"),value:Jt,providerOptions:Xt.optional()}),a.Ik({type:a.eu("execution-denied"),reason:a.Yj().optional(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("error-text"),value:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("error-json"),value:Jt,providerOptions:Xt.optional()}),a.Ik({type:a.eu("content"),value:a.YO(a.KC([a.Ik({type:a.eu("text"),text:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("media"),data:a.Yj(),mediaType:a.Yj()}),a.Ik({type:a.eu("file-data"),data:a.Yj(),mediaType:a.Yj(),filename:a.Yj().optional(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("file-url"),url:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("file-id"),fileId:a.KC([a.Yj(),a.g1(a.Yj(),a.Yj())]),providerOptions:Xt.optional()}),a.Ik({type:a.eu("image-data"),data:a.Yj(),mediaType:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("image-url"),url:a.Yj(),providerOptions:Xt.optional()}),a.Ik({type:a.eu("image-file-id"),fileId:a.KC([a.Yj(),a.g1(a.Yj(),a.Yj())]),providerOptions:Xt.optional()}),a.Ik({type:a.eu("custom"),providerOptions:Xt.optional()})]))})]),ie=a.Ik({type:a.eu("tool-result"),toolCallId:a.Yj(),toolName:a.Yj(),output:oe,providerOptions:Xt.optional()}),se=a.Ik({type:a.eu("tool-approval-request"),approvalId:a.Yj(),toolCallId:a.Yj()}),ae=a.Ik({type:a.eu("tool-approval-response"),approvalId:a.Yj(),approved:a.zM(),reason:a.Yj().optional()}),le=a.Ik({role:a.eu("system"),content:a.Yj(),providerOptions:Xt.optional()}),ue=a.Ik({role:a.eu("user"),content:a.KC([a.Yj(),a.YO(a.KC([Qt,te,ee]))]),providerOptions:Xt.optional()}),pe=a.Ik({role:a.eu("assistant"),content:a.KC([a.Yj(),a.YO(a.KC([Qt,ee,re,ne,ie,se]))]),providerOptions:Xt.optional()}),ce=a.Ik({role:a.eu("tool"),content:a.YO(a.KC([ie,ae])),providerOptions:Xt.optional()}),he=a.KC([le,ue,pe,ce]);function de(t){if(!s.jN.isInstance(t))return t;const e="https://ai-sdk.dev/unauthenticated-ai-gateway";return"production"===(null==h?void 0:"production")?new i.bD({name:"GatewayError",message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${e}`}):Object.assign(new Error(`Unauthenticated request to AI Gateway.\n\nTo authenticate, set the AI_GATEWAY_API_KEY environment variable with your API key.\n\nAlternatively, you can use a provider module instead of the AI Gateway.\n\nLearn more: ${e}\n\n`),{name:"GatewayAuthenticationError"})}function fe({operationId:t,telemetry:e}){return{"operation.name":`${t}${null!=(null==e?void 0:e.functionId)?` ${e.functionId}`:""}`,"resource.name":null==e?void 0:e.functionId,"ai.operationId":t,"ai.telemetry.functionId":null==e?void 0:e.functionId}}var me={startSpan:()=>ge,startActiveSpan:(t,e,r,n)=>"function"==typeof e?e(ge):"function"==typeof r?r(ge):"function"==typeof n?n(ge):void 0},ge={spanContext:()=>ye,setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording:()=>!1,recordException(){return this}},ye={traceId:"",spanId:"",traceFlags:0};async function ve({name:t,tracer:e,attributes:r,fn:n,endWhenDone:o=!0}){return e.startActiveSpan(t,{attributes:await r},(async t=>{const e=p._.active();try{const r=await p._.with(e,(()=>n(t)));return o&&t.end(),r}catch(e){try{xe(t,e)}finally{t.end()}throw e}}))}function xe(t,e){e instanceof Error?(t.recordException({name:e.name,message:e.message,stack:e.stack}),t.setStatus({code:u.s.ERROR,message:e.message})):t.setStatus({code:u.s.ERROR})}async function Te({telemetry:t,attributes:e}){if(!0!==(null==t?void 0:t.isEnabled))return{};const r={};for(const[n,o]of Object.entries(e))if(null!=o)if("object"==typeof o&&"input"in o&&"function"==typeof o.input){if(!1===(null==t?void 0:t.recordInputs))continue;const e=await o.input();null!=e&&(r[n]=e)}else if("object"==typeof o&&"output"in o&&"function"==typeof o.output){if(!1===(null==t?void 0:t.recordOutputs))continue;const e=await o.output();null!=e&&(r[n]=e)}else r[n]=o;return r}function Se(t){return{inputTokens:t.inputTokens.total,inputTokenDetails:{noCacheTokens:t.inputTokens.noCache,cacheReadTokens:t.inputTokens.cacheRead,cacheWriteTokens:t.inputTokens.cacheWrite},outputTokens:t.outputTokens.total,outputTokenDetails:{textTokens:t.outputTokens.text,reasoningTokens:t.outputTokens.reasoning},totalTokens:_e(t.inputTokens.total,t.outputTokens.total),raw:t.raw,reasoningTokens:t.outputTokens.reasoning,cachedInputTokens:t.inputTokens.cacheRead}}function _e(t,e){return null==t&&null==e?void 0:(null!=t?t:0)+(null!=e?e:0)}function be(t,e){if(void 0===t&&void 0===e)return;if(void 0===t)return e;if(void 0===e)return t;const r={...t};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const o=e[n];if(void 0===o)continue;const i=n in t?t[n]:void 0,s=!(null===o||"object"!=typeof o||Array.isArray(o)||o instanceof Date||o instanceof RegExp),a=!(null==i||"object"!=typeof i||Array.isArray(i)||i instanceof Date||i instanceof RegExp);r[n]=s&&a?be(i,o):o}return r}var Ee=({maxRetries:t=2,initialDelayInMs:e=2e3,backoffFactor:r=2,abortSignal:n}={})=>async o=>we(o,{maxRetries:t,delayInMs:e,backoffFactor:r,abortSignal:n});async function we(t,{maxRetries:e,delayInMs:r,backoffFactor:n,abortSignal:s},a=[]){try{return await t()}catch(l){if((0,o.zf)(l))throw l;if(0===e)throw l;const u=(0,o.u1)(l),p=[...a,l],c=p.length;if(c>e)throw new At({message:`Failed after ${c} attempts. Last error: ${u}`,reason:"maxRetriesExceeded",errors:p});if(l instanceof Error&&i.hL.isInstance(l)&&!0===l.isRetryable&&c<=e)return await(0,o.cb)(function({error:t,exponentialBackoffDelay:e}){const r=t.responseHeaders;if(!r)return e;let n;const o=r["retry-after-ms"];if(o){const t=parseFloat(o);Number.isNaN(t)||(n=t)}const i=r["retry-after"];if(i&&void 0===n){const t=parseFloat(i);n=Number.isNaN(t)?Date.parse(i)-Date.now():1e3*t}return null!=n&&!Number.isNaN(n)&&0<=n&&(n<6e4||n<e)?n:e}({error:l,exponentialBackoffDelay:r}),{abortSignal:s}),we(t,{maxRetries:e,delayInMs:n*r,backoffFactor:n,abortSignal:s},p);if(1===c)throw l;throw new At({message:`Failed after ${c} attempts with non-retryable error: '${u}'`,reason:"errorNotRetryable",errors:p})}}async function Ie({toolCall:t,tools:e,tracer:r,telemetry:n,messages:i,abortSignal:s,experimental_context:a,onPreliminaryToolResult:l}){const{toolName:u,toolCallId:p,input:c}=t,h=null==e?void 0:e[u];if(null!=(null==h?void 0:h.execute))return ve({name:"ai.toolCall",attributes:Te({telemetry:n,attributes:{...fe({operationId:"ai.toolCall",telemetry:n}),"ai.toolCall.name":u,"ai.toolCall.id":p,"ai.toolCall.args":{output:()=>JSON.stringify(c)}}}),tracer:r,fn:async e=>{let r;try{const e=(0,o.o8)({execute:h.execute.bind(h),input:c,options:{toolCallId:p,messages:i,abortSignal:s,experimental_context:a}});for await(const n of e)"preliminary"===n.type?null==l||l({...t,type:"tool-result",output:n.output,preliminary:!0}):r=n.output}catch(r){return xe(e,r),{type:"tool-error",toolCallId:p,toolName:u,input:c,error:r,dynamic:"dynamic"===h.type,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}}}try{e.setAttributes(await Te({telemetry:n,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(r)}}}))}catch(t){}return{type:"tool-result",toolCallId:p,toolName:u,input:c,output:r,dynamic:"dynamic"===h.type,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}}}})}var Ce=class{constructor({data:t,mediaType:e}){const r=t instanceof Uint8Array;this.base64Data=r?void 0:t,this.uint8ArrayData=r?t:void 0,this.mediaType=e}get base64(){return null==this.base64Data&&(this.base64Data=(0,o.n_)(this.uint8ArrayData)),this.base64Data}get uint8Array(){return null==this.uint8ArrayData&&(this.uint8ArrayData=(0,o.Z9)(this.base64Data)),this.uint8ArrayData}},Me=class extends Ce{constructor(t){super(t),this.type="file"}};function ke(t){const e=["ROOT"];let r=-1,n=null;function o(t,o,i){switch(t){case'"':r=o,e.pop(),e.push(i),e.push("INSIDE_STRING");break;case"f":case"t":case"n":r=o,n=o,e.pop(),e.push(i),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(i),e.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=o,e.pop(),e.push(i),e.push("INSIDE_NUMBER");break;case"{":r=o,e.pop(),e.push(i),e.push("INSIDE_OBJECT_START");break;case"[":r=o,e.pop(),e.push(i),e.push("INSIDE_ARRAY_START")}}function i(t,n){switch(t){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":r=n,e.pop()}}function s(t,n){switch(t){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=n,e.pop()}}for(let a=0;a<t.length;a++){const l=t[a];switch(e[e.length-1]){case"ROOT":o(l,a,"FINISH");break;case"INSIDE_OBJECT_START":switch(l){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY");break;case"}":r=a,e.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":'"'===l&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break;case"INSIDE_OBJECT_KEY":'"'===l&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break;case"INSIDE_OBJECT_AFTER_KEY":":"===l&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":o(l,a,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":i(l,a);break;case"INSIDE_STRING":switch(l){case'"':e.pop(),r=a;break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:r=a}break;case"INSIDE_ARRAY_START":"]"===l?(r=a,e.pop()):(r=a,o(l,a,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(l){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=a,e.pop();break;default:r=a}break;case"INSIDE_ARRAY_AFTER_COMMA":o(l,a,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":e.pop(),r=a;break;case"INSIDE_NUMBER":switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=a;break;case"e":case"E":case"-":case".":break;case",":e.pop(),"INSIDE_ARRAY_AFTER_VALUE"===e[e.length-1]&&s(l,a),"INSIDE_OBJECT_AFTER_VALUE"===e[e.length-1]&&i(l,a);break;case"}":e.pop(),"INSIDE_OBJECT_AFTER_VALUE"===e[e.length-1]&&i(l,a);break;case"]":e.pop(),"INSIDE_ARRAY_AFTER_VALUE"===e[e.length-1]&&s(l,a);break;default:e.pop()}break;case"INSIDE_LITERAL":{const o=t.substring(n,a+1);"false".startsWith(o)||"true".startsWith(o)||"null".startsWith(o)?r=a:(e.pop(),"INSIDE_OBJECT_AFTER_VALUE"===e[e.length-1]?i(l,a):"INSIDE_ARRAY_AFTER_VALUE"===e[e.length-1]&&s(l,a));break}}}let a=t.slice(0,r+1);for(let r=e.length-1;r>=0;r--)switch(e[r]){case"INSIDE_STRING":a+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":a+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":a+="]";break;case"INSIDE_LITERAL":{const e=t.substring(n,t.length);"true".startsWith(e)?a+="true".slice(e.length):"false".startsWith(e)?a+="false".slice(e.length):"null".startsWith(e)&&(a+="null".slice(e.length))}}return a}async function Ae(t){if(void 0===t)return{value:void 0,state:"undefined-input"};let e=await(0,o.N8)({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await(0,o.N8)({text:ke(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}((t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})})({},{array:()=>Re,choice:()=>Le,json:()=>Pe,object:()=>Oe,text:()=>Ne});var Ne=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),parseCompleteOutput:async({text:t})=>t,parsePartialOutput:async({text:t})=>({partial:t}),createElementStreamTransform(){}}),Oe=({schema:t,name:e,description:r})=>{const n=(0,o.mD)(t);return{name:"object",responseFormat:(0,o.hd)(n.jsonSchema).then((t=>({type:"json",schema:t,...null!=e&&{name:e},...null!=r&&{description:r}}))),async parseCompleteOutput({text:t},e){const r=await(0,o.N8)({text:t});if(!r.success)throw new V({message:"No object generated: could not parse the response.",cause:r.error,text:t,response:e.response,usage:e.usage,finishReason:e.finishReason});const i=await(0,o.ZZ)({value:r.value,schema:n});if(!i.success)throw new V({message:"No object generated: response did not match schema.",cause:i.error,text:t,response:e.response,usage:e.usage,finishReason:e.finishReason});return i.value},async parsePartialOutput({text:t}){const e=await Ae(t);switch(e.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:e.value}}},createElementStreamTransform(){}}},Re=({element:t,name:e,description:r})=>{const n=(0,o.mD)(t);return{name:"array",responseFormat:(0,o.hd)(n.jsonSchema).then((t=>{const{$schema:n,...o}=t;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:o}},required:["elements"],additionalProperties:!1},...null!=e&&{name:e},...null!=r&&{description:r}}})),async parseCompleteOutput({text:t},e){const r=await(0,o.N8)({text:t});if(!r.success)throw new V({message:"No object generated: could not parse the response.",cause:r.error,text:t,response:e.response,usage:e.usage,finishReason:e.finishReason});const s=r.value;if(null==s||"object"!=typeof s||!("elements"in s)||!Array.isArray(s.elements))throw new V({message:"No object generated: response did not match schema.",cause:new i.iM({value:s,cause:"response must be an object with an elements array"}),text:t,response:e.response,usage:e.usage,finishReason:e.finishReason});for(const r of s.elements){const i=await(0,o.ZZ)({value:r,schema:n});if(!i.success)throw new V({message:"No object generated: response did not match schema.",cause:i.error,text:t,response:e.response,usage:e.usage,finishReason:e.finishReason})}return s.elements},async parsePartialOutput({text:t}){const e=await Ae(t);switch(e.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const t=e.value;if(null==t||"object"!=typeof t||!("elements"in t)||!Array.isArray(t.elements))return;const r="repaired-parse"===e.state&&t.elements.length>0?t.elements.slice(0,-1):t.elements,i=[];for(const t of r){const e=await(0,o.ZZ)({value:t,schema:n});e.success&&i.push(e.value)}return{partial:i}}}},createElementStreamTransform(){let t=0;return new TransformStream({transform({partialOutput:e},r){if(null!=e)for(;t<e.length;t++)r.enqueue(e[t])}})}}},Le=({options:t,name:e,description:r})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...null!=e&&{name:e},...null!=r&&{description:r}}),async parseCompleteOutput({text:e},r){const n=await(0,o.N8)({text:e});if(!n.success)throw new V({message:"No object generated: could not parse the response.",cause:n.error,text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});const s=n.value;if(null==s||"object"!=typeof s||!("result"in s)||"string"!=typeof s.result||!t.includes(s.result))throw new V({message:"No object generated: response did not match schema.",cause:new i.iM({value:s,cause:"response must be an object that contains a choice value."}),text:e,response:r.response,usage:r.usage,finishReason:r.finishReason});return s.result},async parsePartialOutput({text:e}){const r=await Ae(e);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const e=r.value;if(null==e||"object"!=typeof e||!("result"in e)||"string"!=typeof e.result)return;const n=t.filter((t=>t.startsWith(e.result)));return"successful-parse"===r.state?n.includes(e.result)?{partial:e.result}:void 0:1===n.length?{partial:n[0]}:void 0}}},createElementStreamTransform(){}}),Pe=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...null!=t&&{name:t},...null!=e&&{description:e}}),async parseCompleteOutput({text:t},e){const r=await(0,o.N8)({text:t});if(!r.success)throw new V({message:"No object generated: could not parse the response.",cause:r.error,text:t,response:e.response,usage:e.usage,finishReason:e.finishReason});return r.value},async parsePartialOutput({text:t}){const e=await Ae(t);switch(e.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return void 0===e.value?void 0:{partial:e.value}}},createElementStreamTransform(){}});async function De(t){const e=""===t.input.trim()?{success:!0,value:{}}:await(0,o.N8)({text:t.input});if(!1===e.success)throw new M({toolName:t.toolName,toolInput:t.input,cause:e.error});return{type:"tool-call",toolCallId:t.toolCallId,toolName:t.toolName,input:e.value,providerExecuted:!0,dynamic:!0,providerMetadata:t.providerMetadata}}async function je({toolCall:t,tools:e}){const r=t.toolName,n=e[r];if(null==n){if(t.providerExecuted&&t.dynamic)return await De(t);throw new nt({toolName:t.toolName,availableTools:Object.keys(e)})}const i=(0,o.mD)(n.inputSchema),s=""===t.input.trim()?await(0,o.ZZ)({value:{},schema:i}):await(0,o.N8)({text:t.input,schema:i});if(!1===s.success)throw new M({toolName:r,toolInput:t.input,cause:s.error});return"dynamic"===n.type?{type:"tool-call",toolCallId:t.toolCallId,toolName:t.toolName,input:s.value,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata,dynamic:!0,title:n.title}:{type:"tool-call",toolCallId:t.toolCallId,toolName:r,input:s.value,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata,title:n.title}}var Fe=class{constructor({content:t,finishReason:e,rawFinishReason:r,usage:n,warnings:o,request:i,response:s,providerMetadata:a}){this.content=t,this.finishReason=e,this.rawFinishReason=r,this.usage=n,this.warnings=o,this.request=i,this.response=s,this.providerMetadata=a}get text(){return this.content.filter((t=>"text"===t.type)).map((t=>t.text)).join("")}get reasoning(){return this.content.filter((t=>"reasoning"===t.type))}get reasoningText(){return 0===this.reasoning.length?void 0:this.reasoning.map((t=>t.text)).join("")}get files(){return this.content.filter((t=>"file"===t.type)).map((t=>t.file))}get sources(){return this.content.filter((t=>"source"===t.type))}get toolCalls(){return this.content.filter((t=>"tool-call"===t.type))}get staticToolCalls(){return this.toolCalls.filter((t=>!0!==t.dynamic))}get dynamicToolCalls(){return this.toolCalls.filter((t=>!0===t.dynamic))}get toolResults(){return this.content.filter((t=>"tool-result"===t.type))}get staticToolResults(){return this.toolResults.filter((t=>!0!==t.dynamic))}get dynamicToolResults(){return this.toolResults.filter((t=>!0===t.dynamic))}};function qe(t){return({steps:e})=>e.length===t}async function Be({content:t,tools:e}){const r=[],n=[];for(const r of t)if("source"!==r.type&&("tool-result"!==r.type&&"tool-error"!==r.type||r.providerExecuted)&&("text"!==r.type||0!==r.text.length))switch(r.type){case"text":n.push({type:"text",text:r.text,providerOptions:r.providerMetadata});break;case"reasoning":n.push({type:"reasoning",text:r.text,providerOptions:r.providerMetadata});break;case"file":n.push({type:"file",data:r.file.base64,mediaType:r.file.mediaType,providerOptions:r.providerMetadata});break;case"tool-call":n.push({type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName,input:r.input,providerExecuted:r.providerExecuted,providerOptions:r.providerMetadata});break;case"tool-result":{const t=await Zt({toolCallId:r.toolCallId,input:r.input,tool:null==e?void 0:e[r.toolName],output:r.output,errorMode:"none"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:t,providerOptions:r.providerMetadata});break}case"tool-error":{const t=await Zt({toolCallId:r.toolCallId,input:r.input,tool:null==e?void 0:e[r.toolName],output:r.error,errorMode:"json"});n.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:t,providerOptions:r.providerMetadata});break}case"tool-approval-request":n.push({type:"tool-approval-request",approvalId:r.approvalId,toolCallId:r.toolCall.toolCallId})}n.length>0&&r.push({role:"assistant",content:n});const o=[];for(const r of t){if("tool-result"!==r.type&&"tool-error"!==r.type||r.providerExecuted)continue;const t=await Zt({toolCallId:r.toolCallId,input:r.input,tool:null==e?void 0:e[r.toolName],output:"tool-result"===r.type?r.output:r.error,errorMode:"tool-error"===r.type?"text":"none"});o.push({type:"tool-result",toolCallId:r.toolCallId,toolName:r.toolName,output:t,...null!=r.providerMetadata?{providerOptions:r.providerMetadata}:{}})}return o.length>0&&r.push({role:"tool",content:o}),r}function Ye(...t){const e=t.filter((t=>null!=t));if(0===e.length)return;if(1===e.length)return e[0];const r=new AbortController;for(const t of e){if(t.aborted)return r.abort(t.reason),r.signal;t.addEventListener("abort",(()=>{r.abort(t.reason)}),{once:!0})}return r.signal}function Ue(t,e){const r=new Headers(null!=t?t:{});for(const[t,n]of Object.entries(e))r.has(t)||r.set(t,n);return r}function ze({response:t,status:e,statusText:r,headers:n,stream:o}){const i=null!=e?e:200;void 0!==r?t.writeHead(i,r,n):t.writeHead(i,n);const s=o.getReader();(async()=>{try{for(;;){const{done:e,value:r}=await s.read();if(e)break;t.write(r)||await new Promise((e=>{t.once("drain",e)}))}}catch(t){throw t}finally{t.end()}})()}(0,o.hK)({prefix:"aitxt",size:24});var Ve=class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}\n\n`)},flush(t){t.enqueue("data: [DONE]\n\n")}})}},Ke={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};var $e=(0,o.ID)((()=>(0,o.jN)(a.KC([a.re({type:a.eu("text-start"),id:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("text-delta"),id:a.Yj(),delta:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("text-end"),id:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("error"),errorText:a.Yj()}),a.re({type:a.eu("tool-input-start"),toolCallId:a.Yj(),toolName:a.Yj(),providerExecuted:a.zM().optional(),providerMetadata:Xt.optional(),dynamic:a.zM().optional(),title:a.Yj().optional()}),a.re({type:a.eu("tool-input-delta"),toolCallId:a.Yj(),inputTextDelta:a.Yj()}),a.re({type:a.eu("tool-input-available"),toolCallId:a.Yj(),toolName:a.Yj(),input:a.L5(),providerExecuted:a.zM().optional(),providerMetadata:Xt.optional(),dynamic:a.zM().optional(),title:a.Yj().optional()}),a.re({type:a.eu("tool-input-error"),toolCallId:a.Yj(),toolName:a.Yj(),input:a.L5(),providerExecuted:a.zM().optional(),providerMetadata:Xt.optional(),dynamic:a.zM().optional(),errorText:a.Yj(),title:a.Yj().optional()}),a.re({type:a.eu("tool-approval-request"),approvalId:a.Yj(),toolCallId:a.Yj()}),a.re({type:a.eu("tool-output-available"),toolCallId:a.Yj(),output:a.L5(),providerExecuted:a.zM().optional(),dynamic:a.zM().optional(),preliminary:a.zM().optional()}),a.re({type:a.eu("tool-output-error"),toolCallId:a.Yj(),errorText:a.Yj(),providerExecuted:a.zM().optional(),dynamic:a.zM().optional()}),a.re({type:a.eu("tool-output-denied"),toolCallId:a.Yj()}),a.re({type:a.eu("reasoning-start"),id:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("reasoning-delta"),id:a.Yj(),delta:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("reasoning-end"),id:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.eu("source-url"),sourceId:a.Yj(),url:a.Yj(),title:a.Yj().optional(),providerMetadata:Xt.optional()}),a.re({type:a.eu("source-document"),sourceId:a.Yj(),mediaType:a.Yj(),title:a.Yj(),filename:a.Yj().optional(),providerMetadata:Xt.optional()}),a.re({type:a.eu("file"),url:a.Yj(),mediaType:a.Yj(),providerMetadata:Xt.optional()}),a.re({type:a.Ie((t=>"string"==typeof t&&t.startsWith("data-")),{message:'Type must start with "data-"'}),id:a.Yj().optional(),data:a.L5(),transient:a.zM().optional()}),a.re({type:a.eu("start-step")}),a.re({type:a.eu("finish-step")}),a.re({type:a.eu("start"),messageId:a.Yj().optional(),messageMetadata:a.L5().optional()}),a.re({type:a.eu("finish"),finishReason:a.k5(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:a.L5().optional()}),a.re({type:a.eu("abort"),reason:a.Yj().optional()}),a.re({type:a.eu("message-metadata"),messageMetadata:a.L5()})]))));function He(t){return t.type.startsWith("data-")}function We(t){return"text"===t.type}function Ze(t){return"file"===t.type}function Ge(t){return"reasoning"===t.type}function Je(t){return t.type.startsWith("tool-")}function Xe(t){return"dynamic-tool"===t.type}function Qe(t){return Je(t)||Xe(t)}function tr(t){return t.type.split("-").slice(1).join("-")}function er(t){return Xe(t)?t.toolName:tr(t)}function rr({lastMessage:t,messageId:e}){return{message:"assistant"===(null==t?void 0:t.role)?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function nr({stream:t,messageMetadataSchema:e,dataPartSchemas:r,runUpdateMessageJob:n,onError:i,onToolCall:s,onData:a}){return t.pipeThrough(new TransformStream({async transform(t,l){await n((async({state:n,write:u})=>{var p,c,h,d;function f(t){const e=n.message.parts.filter(Qe).find((e=>e.toolCallId===t));if(null==e)throw new ft({chunkType:"tool-invocation",chunkId:t,message:`No tool invocation found for tool call ID "${t}".`});return e}function m(t){var e;const r=n.message.parts.find((e=>Je(e)&&e.toolCallId===t.toolCallId)),o=t,i=r;null!=r?(r.state=t.state,i.input=o.input,i.output=o.output,i.errorText=o.errorText,i.rawInput=o.rawInput,i.preliminary=o.preliminary,void 0!==t.title&&(i.title=t.title),i.providerExecuted=null!=(e=o.providerExecuted)?e:r.providerExecuted,null!=o.providerMetadata&&(r.callProviderMetadata=o.providerMetadata)):n.message.parts.push({type:`tool-${t.toolName}`,toolCallId:t.toolCallId,state:t.state,title:t.title,input:o.input,output:o.output,rawInput:o.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,preliminary:o.preliminary,...null!=o.providerMetadata?{callProviderMetadata:o.providerMetadata}:{}})}function g(t){var e,r;const o=n.message.parts.find((e=>"dynamic-tool"===e.type&&e.toolCallId===t.toolCallId)),i=t,s=o;null!=o?(o.state=t.state,s.toolName=t.toolName,s.input=i.input,s.output=i.output,s.errorText=i.errorText,s.rawInput=null!=(e=i.rawInput)?e:s.rawInput,s.preliminary=i.preliminary,void 0!==t.title&&(s.title=t.title),s.providerExecuted=null!=(r=i.providerExecuted)?r:o.providerExecuted,null!=i.providerMetadata&&(o.callProviderMetadata=i.providerMetadata)):n.message.parts.push({type:"dynamic-tool",toolName:t.toolName,toolCallId:t.toolCallId,state:t.state,input:i.input,output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:t.title,...null!=i.providerMetadata?{callProviderMetadata:i.providerMetadata}:{}})}async function y(t){if(null!=t){const r=null!=n.message.metadata?be(n.message.metadata,t):t;null!=e&&await(0,o.k5)({value:r,schema:e,context:{field:"message.metadata",entityId:n.message.id}}),n.message.metadata=r}}switch(t.type){case"text-start":{const e={type:"text",text:"",providerMetadata:t.providerMetadata,state:"streaming"};n.activeTextParts[t.id]=e,n.message.parts.push(e),u();break}case"text-delta":{const e=n.activeTextParts[t.id];if(null==e)throw new ft({chunkType:"text-delta",chunkId:t.id,message:`Received text-delta for missing text part with ID "${t.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});e.text+=t.delta,e.providerMetadata=null!=(p=t.providerMetadata)?p:e.providerMetadata,u();break}case"text-end":{const e=n.activeTextParts[t.id];if(null==e)throw new ft({chunkType:"text-end",chunkId:t.id,message:`Received text-end for missing text part with ID "${t.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});e.state="done",e.providerMetadata=null!=(c=t.providerMetadata)?c:e.providerMetadata,delete n.activeTextParts[t.id],u();break}case"reasoning-start":{const e={type:"reasoning",text:"",providerMetadata:t.providerMetadata,state:"streaming"};n.activeReasoningParts[t.id]=e,n.message.parts.push(e),u();break}case"reasoning-delta":{const e=n.activeReasoningParts[t.id];if(null==e)throw new ft({chunkType:"reasoning-delta",chunkId:t.id,message:`Received reasoning-delta for missing reasoning part with ID "${t.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});e.text+=t.delta,e.providerMetadata=null!=(h=t.providerMetadata)?h:e.providerMetadata,u();break}case"reasoning-end":{const e=n.activeReasoningParts[t.id];if(null==e)throw new ft({chunkType:"reasoning-end",chunkId:t.id,message:`Received reasoning-end for missing reasoning part with ID "${t.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});e.providerMetadata=null!=(d=t.providerMetadata)?d:e.providerMetadata,e.state="done",delete n.activeReasoningParts[t.id],u();break}case"file":n.message.parts.push({type:"file",mediaType:t.mediaType,url:t.url}),u();break;case"source-url":n.message.parts.push({type:"source-url",sourceId:t.sourceId,url:t.url,title:t.title,providerMetadata:t.providerMetadata}),u();break;case"source-document":n.message.parts.push({type:"source-document",sourceId:t.sourceId,mediaType:t.mediaType,title:t.title,filename:t.filename,providerMetadata:t.providerMetadata}),u();break;case"tool-input-start":{const e=n.message.parts.filter(Je);n.partialToolCalls[t.toolCallId]={text:"",toolName:t.toolName,index:e.length,dynamic:t.dynamic,title:t.title},t.dynamic?g({toolCallId:t.toolCallId,toolName:t.toolName,state:"input-streaming",input:void 0,providerExecuted:t.providerExecuted,title:t.title,providerMetadata:t.providerMetadata}):m({toolCallId:t.toolCallId,toolName:t.toolName,state:"input-streaming",input:void 0,providerExecuted:t.providerExecuted,title:t.title,providerMetadata:t.providerMetadata}),u();break}case"tool-input-delta":{const e=n.partialToolCalls[t.toolCallId];if(null==e)throw new ft({chunkType:"tool-input-delta",chunkId:t.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${t.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});e.text+=t.inputTextDelta;const{value:r}=await Ae(e.text);e.dynamic?g({toolCallId:t.toolCallId,toolName:e.toolName,state:"input-streaming",input:r,title:e.title}):m({toolCallId:t.toolCallId,toolName:e.toolName,state:"input-streaming",input:r,title:e.title}),u();break}case"tool-input-available":t.dynamic?g({toolCallId:t.toolCallId,toolName:t.toolName,state:"input-available",input:t.input,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata,title:t.title}):m({toolCallId:t.toolCallId,toolName:t.toolName,state:"input-available",input:t.input,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata,title:t.title}),u(),s&&!t.providerExecuted&&await s({toolCall:t});break;case"tool-input-error":t.dynamic?g({toolCallId:t.toolCallId,toolName:t.toolName,state:"output-error",input:t.input,errorText:t.errorText,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata}):m({toolCallId:t.toolCallId,toolName:t.toolName,state:"output-error",input:void 0,rawInput:t.input,errorText:t.errorText,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata}),u();break;case"tool-approval-request":{const e=f(t.toolCallId);e.state="approval-requested",e.approval={id:t.approvalId},u();break}case"tool-output-denied":f(t.toolCallId).state="output-denied",u();break;case"tool-output-available":{const e=f(t.toolCallId);"dynamic-tool"===e.type?g({toolCallId:t.toolCallId,toolName:e.toolName,state:"output-available",input:e.input,output:t.output,preliminary:t.preliminary,providerExecuted:t.providerExecuted,title:e.title}):m({toolCallId:t.toolCallId,toolName:tr(e),state:"output-available",input:e.input,output:t.output,providerExecuted:t.providerExecuted,preliminary:t.preliminary,title:e.title}),u();break}case"tool-output-error":{const e=f(t.toolCallId);"dynamic-tool"===e.type?g({toolCallId:t.toolCallId,toolName:e.toolName,state:"output-error",input:e.input,errorText:t.errorText,providerExecuted:t.providerExecuted,title:e.title}):m({toolCallId:t.toolCallId,toolName:tr(e),state:"output-error",input:e.input,rawInput:e.rawInput,errorText:t.errorText,providerExecuted:t.providerExecuted,title:e.title}),u();break}case"start-step":n.message.parts.push({type:"step-start"});break;case"finish-step":n.activeTextParts={},n.activeReasoningParts={};break;case"start":null!=t.messageId&&(n.message.id=t.messageId),await y(t.messageMetadata),null==t.messageId&&null==t.messageMetadata||u();break;case"finish":null!=t.finishReason&&(n.finishReason=t.finishReason),await y(t.messageMetadata),null!=t.messageMetadata&&u();break;case"message-metadata":await y(t.messageMetadata),null!=t.messageMetadata&&u();break;case"error":null==i||i(new Error(t.errorText));break;default:if(function(t){return t.type.startsWith("data-")}(t)){if(null!=(null==r?void 0:r[t.type])){const e=n.message.parts.findIndex((e=>"id"in e&&"data"in e&&e.id===t.id&&e.type===t.type)),i=e>=0?e:n.message.parts.length;await(0,o.k5)({value:t.data,schema:r[t.type],context:{field:`message.parts[${i}].data`,entityName:t.type,entityId:t.id}})}const e=t;if(e.transient){null==a||a(e);break}const i=null!=e.id?n.message.parts.find((t=>e.type===t.type&&e.id===t.id)):void 0;null!=i?i.data=e.data:n.message.parts.push(e),null==a||a(e),u()}}l.enqueue(t)}))}}))}function or(t){const e=t.pipeThrough(new TransformStream);return e[Symbol.asyncIterator]=function(){const t=this.getReader();let e=!1;async function r(r){var n;if(!e){e=!0;try{r&&await(null==(n=t.cancel)?void 0:n.call(t))}finally{try{t.releaseLock()}catch(t){}}}}return{async next(){if(e)return{done:!0,value:void 0};const{done:n,value:o}=await t.read();return n?(await r(!0),{done:!0,value:void 0}):{done:!1,value:o}},return:async()=>(await r(!0),{done:!0,value:void 0}),async throw(t){throw await r(!0),t}}},e}async function ir({stream:t,onError:e}){const r=t.getReader();try{for(;;){const{done:t}=await r.read();if(t)break}}catch(t){null==e||e(t)}finally{r.releaseLock()}}function sr(){let t,e;return{promise:new Promise(((r,n)=>{t=r,e=n})),resolve:t,reject:e}}function ar(){var t,e;return null!=(e=null==(t=null==globalThis?void 0:globalThis.performance)?void 0:t.now())?e:Date.now()}var lr=(0,o.hK)({prefix:"aitxt",size:24});function ur({model:t,tools:e,toolChoice:r,system:n,prompt:o,messages:i,maxRetries:s,abortSignal:a,timeout:l,headers:u,stopWhen:p=qe(1),experimental_output:c,output:h=c,experimental_telemetry:d,prepareStep:f,providerOptions:m,experimental_activeTools:g,activeTools:y=g,experimental_repairToolCall:v,experimental_transform:x,experimental_download:T,includeRawChunks:S=!1,onChunk:_,onError:b=({error:t})=>{console.error(t)},onFinish:E,onAbort:w,onStepFinish:I,experimental_context:C,experimental_include:M,_internal:{now:k=ar,generateId:A=lr}={},...N}){const O=Ft(l),R=function(t){if(null!=t&&"number"!=typeof t)return t.stepMs}(l),L=function(t){if(null!=t&&"number"!=typeof t)return t.chunkMs}(l),P=null!=R?new AbortController:void 0,D=null!=L?new AbortController:void 0;return new pr({model:jt(t),telemetry:d,headers:u,settings:N,maxRetries:s,abortSignal:Ye(a,null!=O?AbortSignal.timeout(O):void 0,null==P?void 0:P.signal,null==D?void 0:D.signal),stepTimeoutMs:R,stepAbortController:P,chunkTimeoutMs:L,chunkAbortController:D,system:n,prompt:o,messages:i,tools:e,toolChoice:r,transforms:$t(x),activeTools:y,repairToolCall:v,stopConditions:$t(p),output:h,providerOptions:m,prepareStep:f,includeRawChunks:S,onChunk:_,onError:b,onFinish:E,onAbort:w,onStepFinish:I,now:k,generateId:A,experimental_context:C,download:T,include:M})}var pr=class{constructor({model:t,telemetry:e,headers:r,settings:n,maxRetries:s,abortSignal:u,stepTimeoutMs:p,stepAbortController:c,chunkTimeoutMs:h,chunkAbortController:d,system:f,prompt:m,messages:g,tools:v,toolChoice:x,transforms:T,activeTools:S,repairToolCall:_,stopConditions:E,output:w,providerOptions:I,prepareStep:C,includeRawChunks:k,now:A,generateId:N,onChunk:O,onError:L,onFinish:P,onAbort:D,onStepFinish:j,experimental_context:F,download:q,include:B}){let Y;this._totalUsage=new o.e1,this._finishReason=new o.e1,this._rawFinishReason=new o.e1,this._steps=new o.e1,this.outputSpecification=w,this.includeRawChunks=k,this.tools=v;let U=[];const z=[];let V,K,$,H={},W=[];const G=[],J=new Map;let X,Q={},tt={};const et=new TransformStream({async transform(e,r){var n,o,i,s;r.enqueue(e);const{part:a}=e;if("text-delta"!==a.type&&"reasoning-delta"!==a.type&&"source"!==a.type&&"tool-call"!==a.type&&"tool-result"!==a.type&&"tool-input-start"!==a.type&&"tool-input-delta"!==a.type&&"raw"!==a.type||await(null==O?void 0:O({chunk:a})),"error"===a.type&&await L({error:de(a.error)}),"text-start"===a.type&&(Q[a.id]={type:"text",text:"",providerMetadata:a.providerMetadata},U.push(Q[a.id])),"text-delta"===a.type){const t=Q[a.id];if(null==t)return void r.enqueue({part:{type:"error",error:`text part ${a.id} not found`},partialOutput:void 0});t.text+=a.text,t.providerMetadata=null!=(n=a.providerMetadata)?n:t.providerMetadata}if("text-end"===a.type){const t=Q[a.id];if(null==t)return void r.enqueue({part:{type:"error",error:`text part ${a.id} not found`},partialOutput:void 0});t.providerMetadata=null!=(o=a.providerMetadata)?o:t.providerMetadata,delete Q[a.id]}if("reasoning-start"===a.type&&(tt[a.id]={type:"reasoning",text:"",providerMetadata:a.providerMetadata},U.push(tt[a.id])),"reasoning-delta"===a.type){const t=tt[a.id];if(null==t)return void r.enqueue({part:{type:"error",error:`reasoning part ${a.id} not found`},partialOutput:void 0});t.text+=a.text,t.providerMetadata=null!=(i=a.providerMetadata)?i:t.providerMetadata}if("reasoning-end"===a.type){const t=tt[a.id];if(null==t)return void r.enqueue({part:{type:"error",error:`reasoning part ${a.id} not found`},partialOutput:void 0});t.providerMetadata=null!=(s=a.providerMetadata)?s:t.providerMetadata,delete tt[a.id]}if("file"===a.type&&U.push({type:"file",file:a.file}),"source"===a.type&&U.push(a),"tool-call"===a.type&&U.push(a),"tool-result"!==a.type||a.preliminary||U.push(a),"tool-approval-request"===a.type&&U.push(a),"tool-error"===a.type&&U.push(a),"start-step"===a.type&&(U=[],tt={},Q={},H=a.request,W=a.warnings),"finish-step"===a.type){const e=await Be({content:U,tools:v}),r=new Fe({content:U,finishReason:a.finishReason,rawFinishReason:a.rawFinishReason,usage:a.usage,warnings:W,request:H,response:{...a.response,messages:[...z,...e]},providerMetadata:a.providerMetadata});await(null==j?void 0:j(r)),Rt({warnings:W,provider:t.provider,model:t.modelId}),G.push(r),z.push(...e),Y.resolve()}"finish"===a.type&&($=a.totalUsage,V=a.finishReason,K=a.rawFinishReason)},async flush(t){try{if(0===G.length){const t=(null==u?void 0:u.aborted)?u.reason:new Z({message:"No output generated. Check the stream for errors."});return ht._finishReason.reject(t),ht._rawFinishReason.reject(t),ht._totalUsage.reject(t),void ht._steps.reject(t)}const t=null!=V?V:"other",r=null!=$?$:{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0};ht._finishReason.resolve(t),ht._rawFinishReason.resolve(K),ht._totalUsage.resolve(r),ht._steps.resolve(G);const n=G[G.length-1];await(null==P?void 0:P({finishReason:n.finishReason,rawFinishReason:n.rawFinishReason,totalUsage:r,usage:n.usage,content:n.content,text:n.text,reasoningText:n.reasoningText,reasoning:n.reasoning,files:n.files,sources:n.sources,toolCalls:n.toolCalls,staticToolCalls:n.staticToolCalls,dynamicToolCalls:n.dynamicToolCalls,toolResults:n.toolResults,staticToolResults:n.staticToolResults,dynamicToolResults:n.dynamicToolResults,request:n.request,response:n.response,warnings:n.warnings,providerMetadata:n.providerMetadata,steps:G,experimental_context:F})),X.setAttributes(await Te({telemetry:e,attributes:{"ai.response.finishReason":t,"ai.response.text":{output:()=>n.text},"ai.response.reasoning":{output:()=>n.reasoningText},"ai.response.toolCalls":{output:()=>{var t;return(null==(t=n.toolCalls)?void 0:t.length)?JSON.stringify(n.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(n.providerMetadata),"ai.usage.inputTokens":r.inputTokens,"ai.usage.outputTokens":r.outputTokens,"ai.usage.totalTokens":r.totalTokens,"ai.usage.reasoningTokens":r.reasoningTokens,"ai.usage.cachedInputTokens":r.cachedInputTokens}}))}catch(e){t.error(e)}finally{X.end()}}}),rt=function(){let t=[],e=null,r=!1,n=sr();const o=()=>{r=!0,n.resolve(),t.forEach((t=>t.cancel())),t=[],null==e||e.close()},i=async()=>{if(r&&0===t.length)null==e||e.close();else{if(0===t.length)return n=sr(),await n.promise,i();try{const{value:n,done:o}=await t[0].read();o?(t.shift(),0===t.length&&r?null==e||e.close():await i()):null==e||e.enqueue(n)}catch(r){null==e||e.error(r),t.shift(),o()}}};return{stream:new ReadableStream({start(t){e=t},pull:i,async cancel(){for(const e of t)await e.cancel();t=[],r=!0}}),addStream:e=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");t.push(e.getReader()),n.resolve()},close:()=>{r=!0,n.resolve(),0===t.length&&(null==e||e.close())},terminate:o}}();this.addStream=rt.addStream,this.closeStream=rt.close;const ot=rt.stream.getReader();let it=new ReadableStream({async start(t){t.enqueue({type:"start"})},async pull(t){function e(){null==D||D({steps:G}),t.enqueue({type:"abort",...void 0!==(null==u?void 0:u.reason)?{reason:(0,i.u1)(u.reason)}:{}}),t.close()}try{const{done:r,value:n}=await ot.read();if(r)return void t.close();if(null==u?void 0:u.aborted)return void e();t.enqueue(n)}catch(r){(0,o.zf)(r)&&(null==u?void 0:u.aborted)?e():t.error(r)}},cancel:t=>rt.stream.cancel(t)});for(const t of T)it=it.pipeThrough(t({tools:v,stopStream(){rt.terminate()}}));this.baseStream=it.pipeThrough(function(t){let e,r,n="",o="",i="";function s({controller:t,partialOutput:n}){t.enqueue({part:{type:"text-delta",id:e,text:o,providerMetadata:r},partialOutput:n}),o=""}return new TransformStream({async transform(a,l){var u;if("finish-step"===a.type&&o.length>0&&s({controller:l}),"text-delta"!==a.type&&"text-start"!==a.type&&"text-end"!==a.type)return void l.enqueue({part:a,partialOutput:void 0});if(null==e)e=a.id;else if(a.id!==e)return void l.enqueue({part:a,partialOutput:void 0});if("text-start"===a.type)return void l.enqueue({part:a,partialOutput:void 0});if("text-end"===a.type)return o.length>0&&s({controller:l}),void l.enqueue({part:a,partialOutput:void 0});n+=a.text,o+=a.text,r=null!=(u=a.providerMetadata)?u:r;const p=await t.parsePartialOutput({text:n});if(void 0!==p){const t=JSON.stringify(p.partial);t!==i&&(s({controller:l,partialOutput:p.partial}),i=t)}}})}(null!=w?w:Ne())).pipeThrough(et);const{maxRetries:st,retry:at}=function({maxRetries:t,abortSignal:e}){if(null!=t){if(!Number.isInteger(t))throw new y({parameter:"maxRetries",value:t,message:"maxRetries must be an integer"});if(t<0)throw new y({parameter:"maxRetries",value:t,message:"maxRetries must be >= 0"})}const r=null!=t?t:2;return{maxRetries:r,retry:Ee({maxRetries:r,abortSignal:e})}}({maxRetries:s,abortSignal:u}),ut=function({isEnabled:t=!1,tracer:e}={}){return t?e||l.u.getTracer("ai"):me}(e),pt=function({maxOutputTokens:t,temperature:e,topP:r,topK:n,presencePenalty:o,frequencyPenalty:i,seed:s,stopSequences:a}){if(null!=t){if(!Number.isInteger(t))throw new y({parameter:"maxOutputTokens",value:t,message:"maxOutputTokens must be an integer"});if(t<1)throw new y({parameter:"maxOutputTokens",value:t,message:"maxOutputTokens must be >= 1"})}if(null!=e&&"number"!=typeof e)throw new y({parameter:"temperature",value:e,message:"temperature must be a number"});if(null!=r&&"number"!=typeof r)throw new y({parameter:"topP",value:r,message:"topP must be a number"});if(null!=n&&"number"!=typeof n)throw new y({parameter:"topK",value:n,message:"topK must be a number"});if(null!=o&&"number"!=typeof o)throw new y({parameter:"presencePenalty",value:o,message:"presencePenalty must be a number"});if(null!=i&&"number"!=typeof i)throw new y({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(null!=s&&!Number.isInteger(s))throw new y({parameter:"seed",value:s,message:"seed must be an integer"});return{maxOutputTokens:t,temperature:e,topP:r,topK:n,presencePenalty:o,frequencyPenalty:i,stopSequences:a,seed:s}}(n),ct=function({model:t,settings:e,telemetry:r,headers:n}){var o;return{"ai.model.provider":t.provider,"ai.model.id":t.modelId,...Object.entries(e).reduce(((t,[e,r])=>{if("timeout"===e){const n=Ft(r);null!=n&&(t[`ai.settings.${e}`]=n)}else t[`ai.settings.${e}`]=r;return t}),{}),...Object.entries(null!=(o=null==r?void 0:r.metadata)?o:{}).reduce(((t,[e,r])=>(t[`ai.telemetry.metadata.${e}`]=r,t)),{}),...Object.entries(null!=n?n:{}).reduce(((t,[e,r])=>(void 0!==r&&(t[`ai.request.headers.${e}`]=r),t)),{})}}({model:t,telemetry:e,headers:r,settings:{...pt,maxRetries:st}}),ht=this;ve({name:"ai.streamText",attributes:Te({telemetry:e,attributes:{...fe({operationId:"ai.streamText",telemetry:e}),...ct,"ai.prompt":{input:()=>JSON.stringify({system:f,prompt:m,messages:g})}}}),tracer:ut,endWhenDone:!1,fn:async n=>{X=n;const s=await async function(t){if(null==t.prompt&&null==t.messages)throw new i.M3({prompt:t,message:"prompt or messages must be defined"});if(null!=t.prompt&&null!=t.messages)throw new i.M3({prompt:t,message:"prompt and messages cannot be defined at the same time"});if(null!=t.system&&"string"!=typeof t.system&&!$t(t.system).every((t=>"object"==typeof t&&null!==t&&"role"in t&&"system"===t.role)))throw new i.M3({prompt:t,message:"system must be a string, SystemModelMessage, or array of SystemModelMessage"});let e;if(null!=t.prompt&&"string"==typeof t.prompt)e=[{role:"user",content:t.prompt}];else if(null!=t.prompt&&Array.isArray(t.prompt))e=t.prompt;else{if(null==t.messages)throw new i.M3({prompt:t,message:"prompt or messages must be defined"});e=t.messages}if(0===e.length)throw new i.M3({prompt:t,message:"messages must not be empty"});const r=await(0,o.ZZ)({value:e,schema:a.YO(he)});if(!r.success)throw new i.M3({prompt:t,message:"The messages do not match the ModelMessage[] schema.",cause:r.error});return{messages:e,system:t.system}}({system:f,prompt:m,messages:g}),l=s.messages,y=[],{approvedToolApprovals:T,deniedToolApprovals:k}=function({messages:t}){const e=t.at(-1);if("tool"!=(null==e?void 0:e.role))return{approvedToolApprovals:[],deniedToolApprovals:[]};const r={};for(const e of t)if("assistant"===e.role&&"string"!=typeof e.content){const t=e.content;for(const e of t)"tool-call"===e.type&&(r[e.toolCallId]=e)}const n={};for(const e of t)if("assistant"===e.role&&"string"!=typeof e.content){const t=e.content;for(const e of t)"tool-approval-request"===e.type&&(n[e.approvalId]=e)}const o={};for(const t of e.content)"tool-result"===t.type&&(o[t.toolCallId]=t);const i=[],s=[],a=e.content.filter((t=>"tool-approval-response"===t.type));for(const t of a){const e=n[t.approvalId];if(null==e)throw new b({approvalId:t.approvalId});if(null!=o[e.toolCallId])continue;const a=r[e.toolCallId];if(null==a)throw new R({toolCallId:e.toolCallId,approvalId:e.approvalId});const l={approvalRequest:e,approvalResponse:t,toolCall:a};t.approved?i.push(l):s.push(l)}return{approvedToolApprovals:i,deniedToolApprovals:s}}({messages:l});if(k.length>0||T.length>0){const t=[...T,...k].filter((t=>t.toolCall.providerExecuted)),r=T.filter((t=>!t.toolCall.providerExecuted)),n=k.filter((t=>!t.toolCall.providerExecuted)),o=k.filter((t=>t.toolCall.providerExecuted));let i;const s=new ReadableStream({start(t){i=t}});ht.addStream(s);try{for(const t of[...n,...o])null==i||i.enqueue({type:"tool-output-denied",toolCallId:t.toolCall.toolCallId,toolName:t.toolCall.toolName});const s=[];if(await Promise.all(r.map((async t=>{const r=await Ie({toolCall:t.toolCall,tools:v,tracer:ut,telemetry:e,messages:l,abortSignal:u,experimental_context:F,onPreliminaryToolResult:t=>{null==i||i.enqueue(t)}});null!=r&&(null==i||i.enqueue(r),s.push(r))}))),t.length>0&&y.push({role:"tool",content:t.map((t=>({type:"tool-approval-response",approvalId:t.approvalResponse.approvalId,approved:t.approvalResponse.approved,reason:t.approvalResponse.reason,providerExecuted:!0})))}),s.length>0||n.length>0){const t=[];for(const e of s)t.push({type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:await Zt({toolCallId:e.toolCallId,input:e.input,tool:null==v?void 0:v[e.toolName],output:"tool-result"===e.type?e.output:e.error,errorMode:"tool-error"===e.type?"json":"none"})});for(const e of n)t.push({type:"tool-result",toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName,output:{type:"execution-denied",reason:e.approvalResponse.reason}});y.push({role:"tool",content:t})}}finally{null==i||i.close()}}z.push(...y),await async function n({currentStep:i,responseMessages:a,usage:m}){var g,y,T,b,k,O,L;const P=ht.includeRawChunks,D=null!=p?setTimeout((()=>c.abort()),p):void 0;let j;function z(){null!=j&&(clearTimeout(j),j=void 0)}function V(){null!=D&&clearTimeout(D)}try{Y=new o.e1;const p=[...l,...a],c=await(null==C?void 0:C({model:t,steps:G,stepNumber:G.length,messages:p,experimental_context:F})),D=jt(null!=(g=null==c?void 0:c.model)?g:t),K=await Ht({prompt:{system:null!=(y=null==c?void 0:c.system)?y:s.system,messages:null!=(T=null==c?void 0:c.messages)?T:p},supportedUrls:await D.supportedUrls,download:q}),{toolChoice:$,tools:H}=await async function({tools:t,toolChoice:e,activeTools:r}){if(!(null!=(n=t)&&Object.keys(n).length>0))return{tools:void 0,toolChoice:void 0};var n;const i=null!=r?Object.entries(t).filter((([t])=>r.includes(t))):Object.entries(t),s=[];for(const[t,e]of i){const r=e.type;switch(r){case void 0:case"dynamic":case"function":s.push({type:"function",name:t,description:e.description,inputSchema:await(0,o.mD)(e.inputSchema).jsonSchema,...null!=e.inputExamples?{inputExamples:e.inputExamples}:{},providerOptions:e.providerOptions,...null!=e.strict?{strict:e.strict}:{}});break;case"provider":s.push({type:"provider",name:t,id:e.id,args:e.args});break;default:throw new Error(`Unsupported tool type: ${r}`)}}return{tools:s,toolChoice:null==e?{type:"auto"}:"string"==typeof e?{type:e}:{type:"tool",toolName:e.toolName}}}({tools:v,toolChoice:null!=(b=null==c?void 0:c.toolChoice)?b:x,activeTools:null!=(k=null==c?void 0:c.activeTools)?k:S});F=null!=(O=null==c?void 0:c.experimental_context)?O:F;const W=be(I,null==c?void 0:c.providerOptions),{result:{stream:Z,response:X,request:Q},doStreamSpan:tt,startTimestampMs:et}=await at((()=>ve({name:"ai.streamText.doStream",attributes:Te({telemetry:e,attributes:{...fe({operationId:"ai.streamText.doStream",telemetry:e}),...ct,"ai.model.provider":D.provider,"ai.model.id":D.modelId,"ai.prompt.messages":{input:()=>function(t){return JSON.stringify(t.map((t=>({...t,content:"string"==typeof t.content?t.content:t.content.map((t=>{return"file"===t.type?{...t,data:t.data instanceof Uint8Array?(e=t.data,"string"==typeof e?e:e instanceof ArrayBuffer?(0,o.n_)(new Uint8Array(e)):(0,o.n_)(e)):t.data}:t;var e}))}))))}(K)},"ai.prompt.tools":{input:()=>null==H?void 0:H.map((t=>JSON.stringify(t)))},"ai.prompt.toolChoice":{input:()=>null!=$?JSON.stringify($):void 0},"gen_ai.system":D.provider,"gen_ai.request.model":D.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:ut,endWhenDone:!1,fn:async t=>({startTimestampMs:A(),doStreamSpan:t,result:await D.doStream({...pt,tools:H,toolChoice:$,responseFormat:await(null==w?void 0:w.responseFormat),prompt:K,providerOptions:W,abortSignal:u,headers:r,includeRawChunks:P})})}))),rt=function({tools:t,generatorStream:e,tracer:r,telemetry:n,system:i,messages:s,abortSignal:a,repairToolCall:l,experimental_context:u,generateId:p}){let c=null;const h=new ReadableStream({start(t){c=t}}),d=new Set,f=new Map,m=new Map;let g,y=!1;function v(){y&&0===d.size&&(null!=g&&c.enqueue(g),c.close())}const x=new TransformStream({async transform(e,h){const y=e.type;switch(y){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":h.enqueue(e);break;case"file":h.enqueue({type:"file",file:new Me({data:e.data,mediaType:e.mediaType})});break;case"finish":g={type:"finish",finishReason:e.finishReason.unified,rawFinishReason:e.finishReason.raw,usage:Se(e.usage),providerMetadata:e.providerMetadata};break;case"tool-approval-request":{const t=m.get(e.toolCallId);if(null==t){c.enqueue({type:"error",error:new R({toolCallId:e.toolCallId,approvalId:e.approvalId})});break}h.enqueue({type:"tool-approval-request",approvalId:e.approvalId,toolCall:t});break}case"tool-call":try{const g=await async function({toolCall:t,tools:e,repairToolCall:r,system:n,messages:i}){var s;try{if(null==e){if(t.providerExecuted&&t.dynamic)return await De(t);throw new nt({toolName:t.toolName})}try{return await je({toolCall:t,tools:e})}catch(s){if(null==r||!nt.isInstance(s)&&!M.isInstance(s))throw s;let a=null;try{a=await r({toolCall:t,tools:e,inputSchema:async({toolName:t})=>{const{inputSchema:r}=e[t];return await(0,o.mD)(r).jsonSchema},system:n,messages:i,error:s})}catch(t){throw new lt({cause:t,originalError:s})}if(null==a)throw s;return await je({toolCall:a,tools:e})}}catch(r){const n=await(0,o.N8)({text:t.input}),i=n.success?n.value:t.input;return{type:"tool-call",toolCallId:t.toolCallId,toolName:t.toolName,input:i,dynamic:!0,invalid:!0,error:r,title:null==(s=null==e?void 0:e[t.toolName])?void 0:s.title,providerExecuted:t.providerExecuted,providerMetadata:t.providerMetadata}}}({toolCall:e,tools:t,repairToolCall:l,system:i,messages:s});if(m.set(g.toolCallId,g),h.enqueue(g),g.invalid){c.enqueue({type:"tool-error",toolCallId:g.toolCallId,toolName:g.toolName,input:g.input,error:(0,o.u1)(g.error),dynamic:!0,title:g.title});break}const y=null==t?void 0:t[g.toolName];if(null==y)break;if(null!=y.onInputAvailable&&await y.onInputAvailable({input:g.input,toolCallId:g.toolCallId,messages:s,abortSignal:a,experimental_context:u}),await async function({tool:t,toolCall:e,messages:r,experimental_context:n}){return null!=t.needsApproval&&("boolean"==typeof t.needsApproval?t.needsApproval:await t.needsApproval(e.input,{toolCallId:e.toolCallId,messages:r,experimental_context:n}))}({tool:y,toolCall:g,messages:s,experimental_context:u})){c.enqueue({type:"tool-approval-request",approvalId:p(),toolCall:g});break}if(f.set(g.toolCallId,g.input),null!=y.execute&&!0!==g.providerExecuted){const e=p();d.add(e),Ie({toolCall:g,tools:t,tracer:r,telemetry:n,messages:s,abortSignal:a,experimental_context:u,onPreliminaryToolResult:t=>{c.enqueue(t)}}).then((t=>{c.enqueue(t)})).catch((t=>{c.enqueue({type:"error",error:t})})).finally((()=>{d.delete(e),v()}))}}catch(t){c.enqueue({type:"error",error:t})}break;case"tool-result":{const t=e.toolName;e.isError?c.enqueue({type:"tool-error",toolCallId:e.toolCallId,toolName:t,input:f.get(e.toolCallId),providerExecuted:!0,error:e.result,dynamic:e.dynamic}):h.enqueue({type:"tool-result",toolCallId:e.toolCallId,toolName:t,input:f.get(e.toolCallId),output:e.result,providerExecuted:!0,dynamic:e.dynamic});break}default:throw new Error(`Unhandled chunk type: ${y}`)}},flush(){y=!0,v()}});return new ReadableStream({start:async t=>Promise.all([e.pipeThrough(x).pipeTo(new WritableStream({write(e){t.enqueue(e)},close(){}})),h.pipeTo(new WritableStream({write(e){t.enqueue(e)},close(){t.close()}}))])})}({tools:v,generatorStream:Z,tracer:ut,telemetry:e,system:f,messages:p,repairToolCall:_,abortSignal:u,experimental_context:F,generateId:N}),ot=null==(L=null==B?void 0:B.requestBody)||L?null!=Q?Q:{}:{...Q,body:void 0},it=[],st=[];let dt;const ft={};let mt,gt,yt="other",vt={inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0},xt=!0,Tt={id:N(),timestamp:new Date,modelId:t.modelId},St="";ht.addStream(rt.pipeThrough(new TransformStream({async transform(t,e){var r,n,o,i,s;if(null!=h&&(null!=j&&clearTimeout(j),j=setTimeout((()=>d.abort()),h)),"stream-start"===t.type)return void(dt=t.warnings);if(xt){const t=A()-et;xt=!1,tt.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":t}),tt.setAttributes({"ai.response.msToFirstChunk":t}),e.enqueue({type:"start-step",request:ot,warnings:null!=dt?dt:[]})}const a=t.type;switch(a){case"tool-approval-request":case"text-start":case"text-end":case"reasoning-start":case"reasoning-end":case"file":case"source":e.enqueue(t);break;case"text-delta":t.delta.length>0&&(e.enqueue({type:"text-delta",id:t.id,text:t.delta,providerMetadata:t.providerMetadata}),St+=t.delta);break;case"reasoning-delta":e.enqueue({type:"reasoning-delta",id:t.id,text:t.delta,providerMetadata:t.providerMetadata});break;case"tool-call":e.enqueue(t),it.push(t);break;case"tool-result":e.enqueue(t),t.preliminary||st.push(t);break;case"tool-error":e.enqueue(t),st.push(t);break;case"response-metadata":Tt={id:null!=(r=t.id)?r:Tt.id,timestamp:null!=(n=t.timestamp)?n:Tt.timestamp,modelId:null!=(o=t.modelId)?o:Tt.modelId};break;case"finish":{vt=t.usage,yt=t.finishReason,mt=t.rawFinishReason,gt=t.providerMetadata;const e=A()-et;tt.addEvent("ai.stream.finish"),tt.setAttributes({"ai.response.msToFinish":e,"ai.response.avgOutputTokensPerSecond":1e3*(null!=(i=vt.outputTokens)?i:0)/e});break}case"tool-input-start":{ft[t.id]=t.toolName;const r=null==v?void 0:v[t.toolName];null!=(null==r?void 0:r.onInputStart)&&await r.onInputStart({toolCallId:t.id,messages:p,abortSignal:u,experimental_context:F}),e.enqueue({...t,dynamic:null!=(s=t.dynamic)?s:"dynamic"===(null==r?void 0:r.type),title:null==r?void 0:r.title});break}case"tool-input-end":delete ft[t.id],e.enqueue(t);break;case"tool-input-delta":{const r=ft[t.id],n=null==v?void 0:v[r];null!=(null==n?void 0:n.onInputDelta)&&await n.onInputDelta({inputTextDelta:t.delta,toolCallId:t.id,messages:p,abortSignal:u,experimental_context:F}),e.enqueue(t);break}case"error":e.enqueue(t),yt="error";break;case"raw":P&&e.enqueue(t);break;default:throw new Error(`Unknown chunk type: ${a}`)}},async flush(t){const r=it.length>0?JSON.stringify(it):void 0;try{tt.setAttributes(await Te({telemetry:e,attributes:{"ai.response.finishReason":yt,"ai.response.text":{output:()=>St},"ai.response.reasoning":{output:()=>{const t=U.filter((t=>"reasoning"===t.type));return t.length>0?t.map((t=>t.text)).join("\n"):void 0}},"ai.response.toolCalls":{output:()=>r},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(gt),"ai.usage.inputTokens":vt.inputTokens,"ai.usage.outputTokens":vt.outputTokens,"ai.usage.totalTokens":vt.totalTokens,"ai.usage.reasoningTokens":vt.reasoningTokens,"ai.usage.cachedInputTokens":vt.cachedInputTokens,"gen_ai.response.finish_reasons":[yt],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":vt.inputTokens,"gen_ai.usage.output_tokens":vt.outputTokens}}))}catch(t){}finally{tt.end()}t.enqueue({type:"finish-step",finishReason:yt,rawFinishReason:mt,usage:vt,providerMetadata:gt,response:{...Tt,headers:null==X?void 0:X.headers}});const o=function(t,e){var r,n,o,i,s,a,l,u,p,c;return{inputTokens:_e(t.inputTokens,e.inputTokens),inputTokenDetails:{noCacheTokens:_e(null==(r=t.inputTokenDetails)?void 0:r.noCacheTokens,null==(n=e.inputTokenDetails)?void 0:n.noCacheTokens),cacheReadTokens:_e(null==(o=t.inputTokenDetails)?void 0:o.cacheReadTokens,null==(i=e.inputTokenDetails)?void 0:i.cacheReadTokens),cacheWriteTokens:_e(null==(s=t.inputTokenDetails)?void 0:s.cacheWriteTokens,null==(a=e.inputTokenDetails)?void 0:a.cacheWriteTokens)},outputTokens:_e(t.outputTokens,e.outputTokens),outputTokenDetails:{textTokens:_e(null==(l=t.outputTokenDetails)?void 0:l.textTokens,null==(u=e.outputTokenDetails)?void 0:u.textTokens),reasoningTokens:_e(null==(p=t.outputTokenDetails)?void 0:p.reasoningTokens,null==(c=e.outputTokenDetails)?void 0:c.reasoningTokens)},totalTokens:_e(t.totalTokens,e.totalTokens),reasoningTokens:_e(t.reasoningTokens,e.reasoningTokens),cachedInputTokens:_e(t.cachedInputTokens,e.cachedInputTokens)}}(m,vt);await Y.promise;const s=it.filter((t=>!0!==t.providerExecuted)),l=st.filter((t=>!0!==t.providerExecuted));for(const t of it){if(!0!==t.providerExecuted)continue;const e=null==v?void 0:v[t.toolName];"provider"===(null==e?void 0:e.type)&&e.supportsDeferredResults&&(st.some((e=>("tool-result"===e.type||"tool-error"===e.type)&&e.toolCallId===t.toolCallId))||J.set(t.toolCallId,{toolName:t.toolName}))}for(const t of st)"tool-result"!==t.type&&"tool-error"!==t.type||J.delete(t.toolCallId);if(V(),z(),(s.length>0&&l.length===s.length||J.size>0)&&!await async function({stopConditions:t,steps:e}){return(await Promise.all(t.map((t=>t({steps:e}))))).some((t=>t))}({stopConditions:E,steps:G})){a.push(...await Be({content:G[G.length-1].content,tools:v}));try{await n({currentStep:i+1,responseMessages:a,usage:o})}catch(e){t.enqueue({type:"error",error:e}),ht.closeStream()}}else t.enqueue({type:"finish",finishReason:yt,rawFinishReason:mt,totalUsage:o}),ht.closeStream()}})))}finally{V(),z()}}({currentStep:0,responseMessages:y,usage:{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}})}}).catch((t=>{ht.addStream(new ReadableStream({start(e){e.enqueue({type:"error",error:t}),e.close()}})),ht.closeStream()}))}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then((t=>t[t.length-1]))}get content(){return this.finalStep.then((t=>t.content))}get warnings(){return this.finalStep.then((t=>t.warnings))}get providerMetadata(){return this.finalStep.then((t=>t.providerMetadata))}get text(){return this.finalStep.then((t=>t.text))}get reasoningText(){return this.finalStep.then((t=>t.reasoningText))}get reasoning(){return this.finalStep.then((t=>t.reasoning))}get sources(){return this.finalStep.then((t=>t.sources))}get files(){return this.finalStep.then((t=>t.files))}get toolCalls(){return this.finalStep.then((t=>t.toolCalls))}get staticToolCalls(){return this.finalStep.then((t=>t.staticToolCalls))}get dynamicToolCalls(){return this.finalStep.then((t=>t.dynamicToolCalls))}get toolResults(){return this.finalStep.then((t=>t.toolResults))}get staticToolResults(){return this.finalStep.then((t=>t.staticToolResults))}get dynamicToolResults(){return this.finalStep.then((t=>t.dynamicToolResults))}get usage(){return this.finalStep.then((t=>t.usage))}get request(){return this.finalStep.then((t=>t.request))}get response(){return this.finalStep.then((t=>t.response))}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){const[t,e]=this.baseStream.tee();return this.baseStream=e,t}get textStream(){return or(this.teeStream().pipeThrough(new TransformStream({transform({part:t},e){"text-delta"===t.type&&e.enqueue(t.text)}})))}get fullStream(){return or(this.teeStream().pipeThrough(new TransformStream({transform({part:t},e){e.enqueue(t)}})))}async consumeStream(t){var e;try{await ir({stream:this.fullStream,onError:null==t?void 0:t.onError})}catch(r){null==(e=null==t?void 0:t.onError)||e.call(t,r)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return or(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:t},e){null!=t&&e.enqueue(t)}})))}get elementStream(){var t,e,r;const n=null==(t=this.outputSpecification)?void 0:t.createElementStreamTransform();if(null==n)throw new i.b8({functionality:`element streams in ${null!=(r=null==(e=this.outputSpecification)?void 0:e.name)?r:"text"} mode`});return or(this.teeStream().pipeThrough(n))}get output(){return this.finalStep.then((t=>{var e;return(null!=(e=this.outputSpecification)?e:Ne()).parseCompleteOutput({text:t.text},{response:t.response,usage:t.usage,finishReason:t.finishReason})}))}toUIMessageStream({originalMessages:t,generateMessageId:e,onFinish:r,messageMetadata:n,sendReasoning:o=!0,sendSources:s=!1,sendStart:a=!0,sendFinish:l=!0,onError:u=i.u1}={}){const p=null!=e?function({originalMessages:t,responseMessageId:e}){if(null==t)return;const r=t[t.length-1];return"assistant"===(null==r?void 0:r.role)?r.id:"function"==typeof e?e():e}({originalMessages:t,responseMessageId:e}):void 0,c=t=>{var e;const r=null==(e=this.tools)?void 0:e[t.toolName];return null==r?t.dynamic:"dynamic"===(null==r?void 0:r.type)||void 0};return or(function({messageId:t,originalMessages:e=[],onStepFinish:r,onFinish:n,onError:o,stream:i}){let s=null==e?void 0:e[e.length-1];"assistant"!==(null==s?void 0:s.role)?s=void 0:t=s.id;let a=!1;const l=i.pipeThrough(new TransformStream({transform(e,r){if("start"===e.type){const r=e;null==r.messageId&&null!=t&&(r.messageId=t)}"abort"===e.type&&(a=!0),r.enqueue(e)}}));if(null==n&&null==r)return l;const u=rr({lastMessage:s?structuredClone(s):void 0,messageId:null!=t?t:""});let p=!1;const c=async()=>{if(p||!n)return;p=!0;const t=u.message.id===(null==s?void 0:s.id);await n({isAborted:a,isContinuation:t,responseMessage:u.message,messages:[...t?e.slice(0,-1):e,u.message],finishReason:u.finishReason})};return nr({stream:l,runUpdateMessageJob:async t=>{await t({state:u,write:()=>{}})},onError:o}).pipeThrough(new TransformStream({async transform(t,n){"finish-step"===t.type&&await(async()=>{if(!r)return;const t=u.message.id===(null==s?void 0:s.id);try{await r({isContinuation:t,responseMessage:structuredClone(u.message),messages:[...t?e.slice(0,-1):e,structuredClone(u.message)]})}catch(t){o(t)}})(),n.enqueue(t)},async cancel(){await c()},async flush(){await c()}}))}({stream:this.fullStream.pipeThrough(new TransformStream({transform:async(t,e)=>{const r=null==n?void 0:n({part:t}),i=t.type;switch(i){case"text-start":e.enqueue({type:"text-start",id:t.id,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"text-delta":e.enqueue({type:"text-delta",id:t.id,delta:t.text,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"text-end":e.enqueue({type:"text-end",id:t.id,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"reasoning-start":e.enqueue({type:"reasoning-start",id:t.id,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"reasoning-delta":o&&e.enqueue({type:"reasoning-delta",id:t.id,delta:t.text,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"reasoning-end":e.enqueue({type:"reasoning-end",id:t.id,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"file":e.enqueue({type:"file",mediaType:t.file.mediaType,url:`data:${t.file.mediaType};base64,${t.file.base64}`});break;case"source":s&&"url"===t.sourceType&&e.enqueue({type:"source-url",sourceId:t.id,url:t.url,title:t.title,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}}),s&&"document"===t.sourceType&&e.enqueue({type:"source-document",sourceId:t.id,mediaType:t.mediaType,title:t.title,filename:t.filename,...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{}});break;case"tool-input-start":{const r=c(t);e.enqueue({type:"tool-input-start",toolCallId:t.id,toolName:t.toolName,...null!=t.providerExecuted?{providerExecuted:t.providerExecuted}:{},...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{},...null!=r?{dynamic:r}:{},...null!=t.title?{title:t.title}:{}});break}case"tool-input-delta":e.enqueue({type:"tool-input-delta",toolCallId:t.id,inputTextDelta:t.delta});break;case"tool-call":{const r=c(t);t.invalid?e.enqueue({type:"tool-input-error",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,...null!=t.providerExecuted?{providerExecuted:t.providerExecuted}:{},...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{},...null!=r?{dynamic:r}:{},errorText:u(t.error),...null!=t.title?{title:t.title}:{}}):e.enqueue({type:"tool-input-available",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,...null!=t.providerExecuted?{providerExecuted:t.providerExecuted}:{},...null!=t.providerMetadata?{providerMetadata:t.providerMetadata}:{},...null!=r?{dynamic:r}:{},...null!=t.title?{title:t.title}:{}});break}case"tool-approval-request":e.enqueue({type:"tool-approval-request",approvalId:t.approvalId,toolCallId:t.toolCall.toolCallId});break;case"tool-result":{const r=c(t);e.enqueue({type:"tool-output-available",toolCallId:t.toolCallId,output:t.output,...null!=t.providerExecuted?{providerExecuted:t.providerExecuted}:{},...null!=t.preliminary?{preliminary:t.preliminary}:{},...null!=r?{dynamic:r}:{}});break}case"tool-error":{const r=c(t);e.enqueue({type:"tool-output-error",toolCallId:t.toolCallId,errorText:u(t.error),...null!=t.providerExecuted?{providerExecuted:t.providerExecuted}:{},...null!=r?{dynamic:r}:{}});break}case"tool-output-denied":e.enqueue({type:"tool-output-denied",toolCallId:t.toolCallId});break;case"error":e.enqueue({type:"error",errorText:u(t.error)});break;case"start-step":e.enqueue({type:"start-step"});break;case"finish-step":e.enqueue({type:"finish-step"});break;case"start":a&&e.enqueue({type:"start",...null!=r?{messageMetadata:r}:{},...null!=p?{messageId:p}:{}});break;case"finish":l&&e.enqueue({type:"finish",finishReason:t.finishReason,...null!=r?{messageMetadata:r}:{}});break;case"abort":e.enqueue(t);break;case"tool-input-end":case"raw":break;default:throw new Error(`Unknown chunk type: ${i}`)}null!=r&&"start"!==i&&"finish"!==i&&e.enqueue({type:"message-metadata",messageMetadata:r})}})),messageId:null!=p?p:null==e?void 0:e(),originalMessages:t,onFinish:r,onError:u}))}pipeUIMessageStreamToResponse(t,{originalMessages:e,generateMessageId:r,onFinish:n,messageMetadata:o,sendReasoning:i,sendSources:s,sendFinish:a,sendStart:l,onError:u,...p}={}){!function({response:t,status:e,statusText:r,headers:n,stream:o,consumeSseStream:i}){let s=o.pipeThrough(new Ve);if(i){const[t,e]=s.tee();s=t,i({stream:e})}ze({response:t,status:e,statusText:r,headers:Object.fromEntries(Ue(n,Ke).entries()),stream:s.pipeThrough(new TextEncoderStream)})}({response:t,stream:this.toUIMessageStream({originalMessages:e,generateMessageId:r,onFinish:n,messageMetadata:o,sendReasoning:i,sendSources:s,sendFinish:a,sendStart:l,onError:u}),...p})}pipeTextStreamToResponse(t,e){!function({response:t,status:e,statusText:r,headers:n,textStream:o}){ze({response:t,status:e,statusText:r,headers:Object.fromEntries(Ue(n,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:o.pipeThrough(new TextEncoderStream)})}({response:t,textStream:this.textStream,...e})}toUIMessageStreamResponse({originalMessages:t,generateMessageId:e,onFinish:r,messageMetadata:n,sendReasoning:o,sendSources:i,sendFinish:s,sendStart:a,onError:l,...u}={}){return function({status:t,statusText:e,headers:r,stream:n,consumeSseStream:o}){let i=n.pipeThrough(new Ve);if(o){const[t,e]=i.tee();i=t,o({stream:e})}return new Response(i.pipeThrough(new TextEncoderStream),{status:t,statusText:e,headers:Ue(r,Ke)})}({stream:this.toUIMessageStream({originalMessages:t,generateMessageId:e,onFinish:r,messageMetadata:n,sendReasoning:o,sendSources:i,sendFinish:s,sendStart:a,onError:l}),...u})}toTextStreamResponse(t){return function({status:t,statusText:e,headers:r,textStream:n}){return new Response(n.pipeThrough(new TextEncoderStream),{status:null!=t?t:200,statusText:e,headers:Ue(r,{"content-type":"text/plain; charset=utf-8"})})}({textStream:this.textStream,...t})}};async function cr(t,e){const r=[];(null==e?void 0:e.ignoreIncompleteToolCalls)&&(t=t.map((t=>({...t,parts:t.parts.filter((t=>!Qe(t)||"input-streaming"!==t.state&&"input-available"!==t.state))}))));for(const n of t)switch(n.role){case"system":{const i=n.parts.filter((t=>"text"===t.type)),s=i.reduce(((t,e)=>null!=e.providerMetadata?{...t,...e.providerMetadata}:t),{});r.push({role:"system",content:i.map((t=>t.text)).join(""),...Object.keys(s).length>0?{providerOptions:s}:{}});break}case"user":r.push({role:"user",content:n.parts.map((t=>{var r;return We(t)?{type:"text",text:t.text,...null!=t.providerMetadata?{providerOptions:t.providerMetadata}:{}}:Ze(t)?{type:"file",mediaType:t.mediaType,filename:t.filename,data:t.url,...null!=t.providerMetadata?{providerOptions:t.providerMetadata}:{}}:He(t)?null==(r=null==e?void 0:e.convertDataPart)?void 0:r.call(e,t):void 0})).filter(o.R)});break;case"assistant":if(null!=n.parts){let a=[];async function l(){var t,n,o,i,s,l;if(0===a.length)return;const u=[];for(const r of a)if(We(r))u.push({type:"text",text:r.text,...null!=r.providerMetadata?{providerOptions:r.providerMetadata}:{}});else if(Ze(r))u.push({type:"file",mediaType:r.mediaType,filename:r.filename,data:r.url});else if(Ge(r))u.push({type:"reasoning",text:r.text,providerOptions:r.providerMetadata});else if(Qe(r)){const o=er(r);"input-streaming"!==r.state&&(u.push({type:"tool-call",toolCallId:r.toolCallId,toolName:o,input:"output-error"===r.state?null!=(t=r.input)?t:"rawInput"in r?r.rawInput:void 0:r.input,providerExecuted:r.providerExecuted,...null!=r.callProviderMetadata?{providerOptions:r.callProviderMetadata}:{}}),null!=r.approval&&u.push({type:"tool-approval-request",approvalId:r.approval.id,toolCallId:r.toolCallId}),!0!==r.providerExecuted||"approval-responded"===r.state||"output-available"!==r.state&&"output-error"!==r.state||u.push({type:"tool-result",toolCallId:r.toolCallId,toolName:o,output:await Zt({toolCallId:r.toolCallId,input:r.input,output:"output-error"===r.state?r.errorText:r.output,tool:null==(n=null==e?void 0:e.tools)?void 0:n[o],errorMode:"output-error"===r.state?"json":"none"}),...null!=r.callProviderMetadata?{providerOptions:r.callProviderMetadata}:{}}))}else{if(!He(r))throw new Error(`Unsupported part: ${r}`);{const t=null==(o=null==e?void 0:e.convertDataPart)?void 0:o.call(e,r);null!=t&&u.push(t)}}r.push({role:"assistant",content:u});const p=a.filter((t=>{var e;return Qe(t)&&(!0!==t.providerExecuted||null!=(null==(e=t.approval)?void 0:e.approved))}));if(p.length>0){const t=[];for(const r of p)if(null!=(null==(i=r.approval)?void 0:i.approved)&&t.push({type:"tool-approval-response",approvalId:r.approval.id,approved:r.approval.approved,reason:r.approval.reason,providerExecuted:r.providerExecuted}),!0!==r.providerExecuted)switch(r.state){case"output-denied":t.push({type:"tool-result",toolCallId:r.toolCallId,toolName:er(r),output:{type:"error-text",value:null!=(s=r.approval.reason)?s:"Tool execution denied."},...null!=r.callProviderMetadata?{providerOptions:r.callProviderMetadata}:{}});break;case"output-error":case"output-available":{const n=er(r);t.push({type:"tool-result",toolCallId:r.toolCallId,toolName:n,output:await Zt({toolCallId:r.toolCallId,input:r.input,output:"output-error"===r.state?r.errorText:r.output,tool:null==(l=null==e?void 0:e.tools)?void 0:l[n],errorMode:"output-error"===r.state?"text":"none"}),...null!=r.callProviderMetadata?{providerOptions:r.callProviderMetadata}:{}});break}}t.length>0&&r.push({role:"tool",content:t})}a=[]}for(const u of n.parts)We(u)||Ge(u)||Ze(u)||Qe(u)||He(u)?a.push(u):"step-start"===u.type&&await l();await l();break}break;default:{const p=n.role;throw new wt({originalMessage:n,message:`Unsupported role: ${p}`})}}return r}function hr(t){return({url:e,abortSignal:r})=>Ut({url:e,maxBytes:null==t?void 0:t.maxBytes,abortSignal:r})}(0,o.ID)((()=>(0,o.jN)(a.YO(a.Ik({id:a.Yj(),role:a.k5(["system","user","assistant"]),metadata:a.L5().optional(),parts:a.YO(a.KC([a.Ik({type:a.eu("text"),text:a.Yj(),state:a.k5(["streaming","done"]).optional(),providerMetadata:Xt.optional()}),a.Ik({type:a.eu("reasoning"),text:a.Yj(),state:a.k5(["streaming","done"]).optional(),providerMetadata:Xt.optional()}),a.Ik({type:a.eu("source-url"),sourceId:a.Yj(),url:a.Yj(),title:a.Yj().optional(),providerMetadata:Xt.optional()}),a.Ik({type:a.eu("source-document"),sourceId:a.Yj(),mediaType:a.Yj(),title:a.Yj(),filename:a.Yj().optional(),providerMetadata:Xt.optional()}),a.Ik({type:a.eu("file"),mediaType:a.Yj(),filename:a.Yj().optional(),url:a.Yj(),providerMetadata:Xt.optional()}),a.Ik({type:a.eu("step-start")}),a.Ik({type:a.Yj().startsWith("data-"),id:a.Yj().optional(),data:a.L5()}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("input-streaming"),input:a.L5().optional(),providerExecuted:a.zM().optional(),callProviderMetadata:Xt.optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),approval:a.Zm().optional()}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("input-available"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Zm().optional()}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("approval-requested"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.Zm().optional(),reason:a.Zm().optional()})}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("approval-responded"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.zM(),reason:a.Yj().optional()})}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("output-available"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.L5(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),preliminary:a.zM().optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!0),reason:a.Yj().optional()}).optional()}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("output-error"),input:a.L5(),rawInput:a.L5().optional(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Yj(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!0),reason:a.Yj().optional()}).optional()}),a.Ik({type:a.eu("dynamic-tool"),toolName:a.Yj(),toolCallId:a.Yj(),state:a.eu("output-denied"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!1),reason:a.Yj().optional()})}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("input-streaming"),providerExecuted:a.zM().optional(),callProviderMetadata:Xt.optional(),input:a.L5().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),approval:a.Zm().optional()}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("input-available"),providerExecuted:a.zM().optional(),input:a.L5(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Zm().optional()}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("approval-requested"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.Zm().optional(),reason:a.Zm().optional()})}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("approval-responded"),input:a.L5(),providerExecuted:a.zM().optional(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.zM(),reason:a.Yj().optional()})}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("output-available"),providerExecuted:a.zM().optional(),input:a.L5(),output:a.L5(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),preliminary:a.zM().optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!0),reason:a.Yj().optional()}).optional()}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("output-error"),providerExecuted:a.zM().optional(),input:a.L5(),rawInput:a.L5().optional(),output:a.Zm().optional(),errorText:a.Yj(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!0),reason:a.Yj().optional()}).optional()}),a.Ik({type:a.Yj().startsWith("tool-"),toolCallId:a.Yj(),state:a.eu("output-denied"),providerExecuted:a.zM().optional(),input:a.L5(),output:a.Zm().optional(),errorText:a.Zm().optional(),callProviderMetadata:Xt.optional(),approval:a.Ik({id:a.Yj(),approved:a.eu(!1),reason:a.Yj().optional()})})])).nonempty("Message must contain at least one part")})).nonempty("Messages array must not be empty")))),(0,o.hK)({prefix:"aiobj",size:24});var dr=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise(((e,r)=>{this.queue.push((async()=>{try{await t(),e()}catch(t){r(t)}})),this.processQueue()}))}};(0,o.hK)({prefix:"aiobj",size:24}),hr();var fr=Symbol.for("vercel.ai.error.AI_NoSuchProviderError");i.eM,hr();var mr=class{constructor({api:t="/api/chat",credentials:e,headers:r,body:n,fetch:o,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:s}){this.api=t,this.credentials=e,this.headers=r,this.body=n,this.fetch=o,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=s}async sendMessages({abortSignal:t,...e}){var r,n,i,s,a;const l=await(0,o.hd)(this.body),u=await(0,o.hd)(this.headers),p=await(0,o.hd)(this.credentials),c={...(0,o.qx)(u),...(0,o.qx)(e.headers)},h=await(null==(r=this.prepareSendMessagesRequest)?void 0:r.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...l,...e.body},headers:c,credentials:p,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),d=null!=(n=null==h?void 0:h.api)?n:this.api,f=void 0!==(null==h?void 0:h.headers)?(0,o.qx)(h.headers):c,m=void 0!==(null==h?void 0:h.body)?h.body:{...l,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},g=null!=(i=null==h?void 0:h.credentials)?i:p,y=null!=(s=this.fetch)?s:globalThis.fetch,v=await y(d,{method:"POST",headers:(0,o.WZ)({"Content-Type":"application/json",...f},`ai-sdk/${Yt}`,(0,o.G1)()),body:JSON.stringify(m),credentials:g,signal:t});if(!v.ok)throw new Error(null!=(a=await v.text())?a:"Failed to fetch the chat response.");if(!v.body)throw new Error("The response body is empty.");return this.processResponseStream(v.body)}async reconnectToStream(t){var e,r,n,i,s;const a=await(0,o.hd)(this.body),l=await(0,o.hd)(this.headers),u=await(0,o.hd)(this.credentials),p={...(0,o.qx)(l),...(0,o.qx)(t.headers)},c=await(null==(e=this.prepareReconnectToStreamRequest)?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...a,...t.body},headers:p,credentials:u,requestMetadata:t.metadata})),h=null!=(r=null==c?void 0:c.api)?r:`${this.api}/${t.chatId}/stream`,d=void 0!==(null==c?void 0:c.headers)?(0,o.qx)(c.headers):p,f=null!=(n=null==c?void 0:c.credentials)?n:u,m=null!=(i=this.fetch)?i:globalThis.fetch,g=await m(h,{method:"GET",headers:(0,o.WZ)(d,`ai-sdk/${Yt}`,(0,o.G1)()),credentials:f});if(204===g.status)return null;if(!g.ok)throw new Error(null!=(s=await g.text())?s:"Failed to fetch the chat response.");if(!g.body)throw new Error("The response body is empty.");return this.processResponseStream(g.body)}},gr=class extends mr{constructor(t={}){super(t)}processResponseStream(t){return(0,o._Z)({stream:t,schema:$e}).pipeThrough(new TransformStream({async transform(t,e){if(!t.success)throw t.error;e.enqueue(t.value)}}))}},yr=class{constructor({generateId:t=o.$C,id:e=t(),transport:r=new gr,messageMetadataSchema:n,dataPartSchemas:i,state:s,onError:a,onToolCall:l,onFinish:u,onData:p,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new dr,this.sendMessage=async(t,e)=>{var r,n,o,i;if(null==t)return void await this.makeRequest({trigger:"submit-message",messageId:null==(r=this.lastMessage)?void 0:r.id,...e});let s;if("text"in t||"files"in t){const e=Array.isArray(t.files)?t.files:await async function(t){if(null==t)return[];if(!(globalThis.FileList&&t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map((async t=>{const{name:e,type:r}=t;return{type:"file",mediaType:r,filename:e,url:await new Promise(((e,r)=>{const n=new FileReader;n.onload=t=>{var r;e(null==(r=t.target)?void 0:r.result)},n.onerror=t=>r(t),n.readAsDataURL(t)}))}})))}(t.files);s={parts:[...e,..."text"in t&&null!=t.text?[{type:"text",text:t.text}]:[]]}}else s=t;if(null!=t.messageId){const e=this.state.messages.findIndex((e=>e.id===t.messageId));if(-1===e)throw new Error(`message with id ${t.messageId} not found`);if("user"!==this.state.messages[e].role)throw new Error(`message with id ${t.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,e+1),this.state.replaceMessage(e,{...s,id:t.messageId,role:null!=(n=s.role)?n:"user",metadata:t.metadata})}else this.state.pushMessage({...s,id:null!=(o=s.id)?o:this.generateId(),role:null!=(i=s.role)?i:"user",metadata:t.metadata});await this.makeRequest({trigger:"submit-message",messageId:t.messageId,...e})},this.regenerate=async({messageId:t,...e}={})=>{const r=null==t?this.state.messages.length-1:this.state.messages.findIndex((e=>e.id===t));if(-1===r)throw new Error(`message ${t} not found`);this.state.messages=this.state.messages.slice(0,"assistant"===this.messages[r].role?r:r+1),await this.makeRequest({trigger:"regenerate-message",messageId:t,...e})},this.resumeStream=async(t={})=>{await this.makeRequest({trigger:"resume-stream",...t})},this.clearError=()=>{"error"===this.status&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:t,approved:e,reason:r})=>this.jobExecutor.run((async()=>{const n=this.state.messages,o=n[n.length-1],i=n=>Qe(n)&&"approval-requested"===n.state&&n.approval.id===t?{...n,state:"approval-responded",approval:{id:t,approved:e,reason:r}}:n;this.state.replaceMessage(n.length-1,{...o,parts:o.parts.map(i)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(i)),"streaming"!==this.status&&"submitted"!==this.status&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then((t=>{var e;t&&this.makeRequest({trigger:"submit-message",messageId:null==(e=this.lastMessage)?void 0:e.id})}))})),this.addToolOutput=async({state:t="output-available",tool:e,toolCallId:r,output:n,errorText:o})=>this.jobExecutor.run((async()=>{const e=this.state.messages,i=e[e.length-1],s=e=>Qe(e)&&e.toolCallId===r?{...e,state:t,output:n,errorText:o}:e;this.state.replaceMessage(e.length-1,{...i,parts:i.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),"streaming"!==this.status&&"submitted"!==this.status&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then((t=>{var e;t&&this.makeRequest({trigger:"submit-message",messageId:null==(e=this.lastMessage)?void 0:e.id})}))})),this.addToolResult=this.addToolOutput,this.stop=async()=>{var t;"streaming"!==this.status&&"submitted"!==this.status||(null==(t=this.activeResponse)?void 0:t.abortController)&&this.activeResponse.abortController.abort()},this.id=e,this.transport=r,this.generateId=t,this.messageMetadataSchema=n,this.dataPartSchemas=i,this.state=s,this.onError=a,this.onToolCall=l,this.onFinish=u,this.onData=p,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const t=this.sendAutomaticallyWhen({messages:this.state.messages});return t&&"object"==typeof t&&"then"in t?await t:t}async makeRequest({trigger:t,metadata:e,headers:r,body:n,messageId:o}){var i,s,a;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let u=!1,p=!1,c=!1;try{const i={state:rr({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};let s;if(i.abortController.signal.addEventListener("abort",(()=>{u=!0})),this.activeResponse=i,"resume-stream"===t){const t=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:r,body:n});if(null==t)return void this.setStatus({status:"ready"});s=t}else s=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:i.abortController.signal,metadata:e,headers:r,body:n,trigger:t,messageId:o});const a=t=>this.jobExecutor.run((()=>t({state:i.state,write:()=>{var t;this.setStatus({status:"streaming"}),i.state.message.id===(null==(t=this.lastMessage)?void 0:t.id)?this.state.replaceMessage(this.state.messages.length-1,i.state.message):this.state.pushMessage(i.state.message)}})));await ir({stream:nr({stream:s,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:a,onError:t=>{throw t}}),onError:t=>{throw t}}),this.setStatus({status:"ready"})}catch(t){if(u||"AbortError"===t.name)return u=!0,this.setStatus({status:"ready"}),null;c=!0,t instanceof TypeError&&(t.message.toLowerCase().includes("fetch")||t.message.toLowerCase().includes("network"))&&(p=!0),this.onError&&t instanceof Error&&this.onError(t),this.setStatus({status:"error",error:t})}finally{try{null==(s=this.onFinish)||s.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:u,isDisconnect:p,isError:c,finishReason:null==(i=this.activeResponse)?void 0:i.state.finishReason})}catch(t){console.error(t)}this.activeResponse=void 0}!c&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:null==(a=this.lastMessage)?void 0:a.id,metadata:e,headers:r,body:n})}};function vr({messages:t}){const e=t[t.length-1];if(!e)return!1;if("assistant"!==e.role)return!1;const r=e.parts.reduce(((t,e,r)=>"step-start"===e.type?r:t),-1),n=e.parts.slice(r+1).filter(Qe).filter((t=>!t.providerExecuted));return n.filter((t=>"approval-responded"===t.state)).length>0&&n.every((t=>"output-available"===t.state||"output-error"===t.state||"approval-responded"===t.state))}},31311:(t,e,r)=>{var n=r(17393);t.exports=function(t){var e,r=this,o=[].slice.call(arguments);e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return r.apply(this,arguments)},n(e,r);var i=function(){this.constructor=e};return i.prototype=r.prototype,e.prototype=new i,t&&(o.unshift(e.prototype),n.apply(null,o)),e.__super__=r.prototype,e}},31732:(t,e,r)=>{e.DFA=r(20369).DFA,e.DFASerializer=r(20509).DFASerializer,e.LexerDFASerializer=r(20509).LexerDFASerializer,e.PredPrediction=r(23952).PredPrediction},33431:(t,e,r)=>{var n=r(86291).Token,o=r(66603).ParseTreeListener,i=r(162).f,s=r(17436).$,a=r(13126).ATNDeserializer,l=r(85076).$,u=r(66603).TerminalNode,p=r(66603).ErrorNode;function c(t){return o.call(this),this.parser=t,this}function h(t){return i.call(this),this._input=null,this._errHandler=new s,this._precedenceStack=[],this._precedenceStack.push(0),this._ctx=null,this.buildParseTrees=!0,this._tracer=null,this._parseListeners=null,this._syntaxErrors=0,this.setInputStream(t),this}c.prototype=Object.create(o.prototype),c.prototype.constructor=c,c.prototype.enterEveryRule=function(t){console.log("enter "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)},c.prototype.visitTerminal=function(t){console.log("consume "+t.symbol+" rule "+this.parser.ruleNames[this.parser._ctx.ruleIndex])},c.prototype.exitEveryRule=function(t){console.log("exit "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)},h.prototype=Object.create(i.prototype),h.prototype.contructor=h,h.bypassAltsAtnCache={},h.prototype.reset=function(){null!==this._input&&this._input.seek(0),this._errHandler.reset(this),this._ctx=null,this._syntaxErrors=0,this.setTrace(!1),this._precedenceStack=[],this._precedenceStack.push(0),null!==this._interp&&this._interp.reset()},h.prototype.match=function(t){var e=this.getCurrentToken();return e.type===t?(this._errHandler.reportMatch(this),this.consume()):(e=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===e.tokenIndex&&this._ctx.addErrorNode(e)),e},h.prototype.matchWildcard=function(){var t=this.getCurrentToken();return t.type>0?(this._errHandler.reportMatch(this),this.consume()):(t=this._errHandler.recoverInline(this),this._buildParseTrees&&-1===t.tokenIndex&&this._ctx.addErrorNode(t)),t},h.prototype.getParseListeners=function(){return this._parseListeners||[]},h.prototype.addParseListener=function(t){if(null===t)throw"listener";null===this._parseListeners&&(this._parseListeners=[]),this._parseListeners.push(t)},h.prototype.removeParseListener=function(t){if(null!==this._parseListeners){var e=this._parseListeners.indexOf(t);e>=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}},h.prototype.removeParseListeners=function(){this._parseListeners=null},h.prototype.triggerEnterRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.map((function(e){e.enterEveryRule(t),t.enterRule(e)}))}},h.prototype.triggerExitRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.slice(0).reverse().map((function(e){t.exitRule(e),e.exitEveryRule(t)}))}},h.prototype.getTokenFactory=function(){return this._input.tokenSource._factory},h.prototype.setTokenFactory=function(t){this._input.tokenSource._factory=t},h.prototype.getATNWithBypassAlts=function(){var t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";var e=this.bypassAltsAtnCache[t];if(null===e){var r=new l;r.generateRuleBypassTransitions=!0,e=new a(r).deserialize(t),this.bypassAltsAtnCache[t]=e}return e};var d=r(13048).Lexer;h.prototype.compileParseTreePattern=function(t,e,r){if(null===(r=r||null)&&null!==this.getTokenStream()){var n=this.getTokenStream().tokenSource;n instanceof d&&(r=n)}if(null===r)throw"Parser can't discover a lexer to use";return new ParseTreePatternMatcher(r,this).compile(t,e)},h.prototype.getInputStream=function(){return this.getTokenStream()},h.prototype.setInputStream=function(t){this.setTokenStream(t)},h.prototype.getTokenStream=function(){return this._input},h.prototype.setTokenStream=function(t){this._input=null,this.reset(),this._input=t},h.prototype.getCurrentToken=function(){return this._input.LT(1)},h.prototype.notifyErrorListeners=function(t,e,r){r=r||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;var n=e.line,o=e.column;this.getErrorListenerDispatch().syntaxError(this,e,n,o,t,r)},h.prototype.consume=function(){var t=this.getCurrentToken();t.type!==n.EOF&&this.getInputStream().consume();var e,r=null!==this._parseListeners&&this._parseListeners.length>0;return(this.buildParseTrees||r)&&((e=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t)).invokingState=this.state,r&&this._parseListeners.map((function(t){e instanceof p||void 0!==e.isErrorNode&&e.isErrorNode()?t.visitErrorNode(e):e instanceof u&&t.visitTerminal(e)}))),t},h.prototype.addContextToParseTree=function(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)},h.prototype.enterRule=function(t,e,r){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),null!==this._parseListeners&&this.triggerEnterRuleEvent()},h.prototype.exitRule=function(){this._ctx.stop=this._input.LT(-1),null!==this._parseListeners&&this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx},h.prototype.enterOuterAlt=function(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t},h.prototype.getPrecedence=function(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]},h.prototype.enterRecursionRule=function(t,e,r,n){this.state=e,this._precedenceStack.push(n),this._ctx=t,this._ctx.start=this._input.LT(1),null!==this._parseListeners&&this.triggerEnterRuleEvent()},h.prototype.pushNewRecursionContext=function(t,e,r){var n=this._ctx;n.parentCtx=t,n.invokingState=e,n.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=n.start,this.buildParseTrees&&this._ctx.addChild(n),null!==this._parseListeners&&this.triggerEnterRuleEvent()},h.prototype.unrollRecursionContexts=function(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);var e=this._ctx;if(null!==this._parseListeners)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)},h.prototype.getInvokingContext=function(t){for(var e=this._ctx;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null},h.prototype.precpred=function(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]},h.prototype.inContext=function(t){return!1},h.prototype.isExpectedToken=function(t){var e=this._interp.atn,r=this._ctx,o=e.states[this.state],i=e.nextTokens(o);if(i.contains(t))return!0;if(!i.contains(n.EPSILON))return!1;for(;null!==r&&r.invokingState>=0&&i.contains(n.EPSILON);){var s=e.states[r.invokingState].transitions[0];if((i=e.nextTokens(s.followState)).contains(t))return!0;r=r.parentCtx}return!(!i.contains(n.EPSILON)||t!==n.EOF)},h.prototype.getExpectedTokens=function(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)},h.prototype.getExpectedTokensWithinCurrentRule=function(){var t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)},h.prototype.getRuleIndex=function(t){var e=this.getRuleIndexMap()[t];return null!==e?e:-1},h.prototype.getRuleInvocationStack=function(t){null===(t=t||null)&&(t=this._ctx);for(var e=[];null!==t;){var r=t.ruleIndex;r<0?e.push("n/a"):e.push(this.ruleNames[r]),t=t.parentCtx}return e},h.prototype.getDFAStrings=function(){return this._interp.decisionToDFA.toString()},h.prototype.dumpDFA=function(){for(var t=!1,e=0;e<this._interp.decisionToDFA.length;e++){var r=this._interp.decisionToDFA[e];r.states.length>0&&(t&&console.log(),this.printer.println("Decision "+r.decision+":"),this.printer.print(r.toString(this.literalNames,this.symbolicNames)),t=!0)}},h.prototype.getSourceName=function(){return this._input.sourceName},h.prototype.setTrace=function(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new c(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)},e.Parser=h},34065:(t,e,r)=>{var n=r(86291).Token;function o(t,e){return this.start=t,this.stop=e,this}function i(){this.intervals=null,this.readOnly=!1}o.prototype.contains=function(t){return t>=this.start&&t<this.stop},o.prototype.toString=function(){return this.start===this.stop-1?this.start.toString():this.start.toString()+".."+(this.stop-1).toString()},Object.defineProperty(o.prototype,"length",{get:function(){return this.stop-this.start}}),i.prototype.first=function(t){return null===this.intervals||0===this.intervals.length?n.INVALID_TYPE:this.intervals[0].start},i.prototype.addOne=function(t){this.addInterval(new o(t,t+1))},i.prototype.addRange=function(t,e){this.addInterval(new o(t,e+1))},i.prototype.addInterval=function(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t);else{for(var e=0;e<this.intervals.length;e++){var r=this.intervals[e];if(t.stop<r.start)return void this.intervals.splice(e,0,t);if(t.stop===r.start)return void(this.intervals[e].start=t.start);if(t.start<=r.stop)return this.intervals[e]=new o(Math.min(r.start,t.start),Math.max(r.stop,t.stop)),void this.reduce(e)}this.intervals.push(t)}},i.prototype.addSet=function(t){if(null!==t.intervals)for(var e=0;e<t.intervals.length;e++){var r=t.intervals[e];this.addInterval(new o(r.start,r.stop))}return this},i.prototype.reduce=function(t){if(t<this.intervalslength-1){var e=this.intervals[t],r=this.intervals[t+1];e.stop>=r.stop?(this.intervals.pop(t+1),this.reduce(t)):e.stop>=r.start&&(this.intervals[t]=new o(e.start,r.stop),this.intervals.pop(t+1))}},i.prototype.complement=function(t,e){var r=new i;r.addInterval(new o(t,e+1));for(var n=0;n<this.intervals.length;n++)r.removeRange(this.intervals[n]);return r},i.prototype.contains=function(t){if(null===this.intervals)return!1;for(var e=0;e<this.intervals.length;e++)if(this.intervals[e].contains(t))return!0;return!1},Object.defineProperty(i.prototype,"length",{get:function(){var t=0;return this.intervals.map((function(e){t+=e.length})),t}}),i.prototype.removeRange=function(t){if(t.start===t.stop-1)this.removeOne(t.start);else if(null!==this.intervals)for(var e=0,r=0;r<this.intervals.length;r++){var n=this.intervals[e];if(t.stop<=n.start)return;if(t.start>n.start&&t.stop<n.stop){this.intervals[e]=new o(n.start,t.start);var i=new o(t.stop,n.stop);return void this.intervals.splice(e,0,i)}t.start<=n.start&&t.stop>=n.stop?(this.intervals.splice(e,1),e-=1):t.start<n.stop?this.intervals[e]=new o(n.start,t.start):t.stop<n.stop&&(this.intervals[e]=new o(t.stop,n.stop)),e+=1}},i.prototype.removeOne=function(t){if(null!==this.intervals)for(var e=0;e<this.intervals.length;e++){var r=this.intervals[e];if(t<r.start)return;if(t===r.start&&t===r.stop-1)return void this.intervals.splice(e,1);if(t===r.start)return void(this.intervals[e]=new o(r.start+1,r.stop));if(t===r.stop-1)return void(this.intervals[e]=new o(r.start,r.stop-1));if(t<r.stop-1){var n=new o(r.start,t);return r.start=t+1,void this.intervals.splice(e,0,n)}}},i.prototype.toString=function(t,e,r){return t=t||null,e=e||null,r=r||!1,null===this.intervals?"{}":null!==t||null!==e?this.toTokenString(t,e):r?this.toCharString():this.toIndexString()},i.prototype.toCharString=function(){for(var t=[],e=0;e<this.intervals.length;e++){var r=this.intervals[e];r.stop===r.start+1?r.start===n.EOF?t.push("<EOF>"):t.push("'"+String.fromCharCode(r.start)+"'"):t.push("'"+String.fromCharCode(r.start)+"'..'"+String.fromCharCode(r.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]},i.prototype.toIndexString=function(){for(var t=[],e=0;e<this.intervals.length;e++){var r=this.intervals[e];r.stop===r.start+1?r.start===n.EOF?t.push("<EOF>"):t.push(r.start.toString()):t.push(r.start.toString()+".."+(r.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]},i.prototype.toTokenString=function(t,e){for(var r=[],n=0;n<this.intervals.length;n++)for(var o=this.intervals[n],i=o.start;i<o.stop;i++)r.push(this.elementName(t,e,i));return r.length>1?"{"+r.join(", ")+"}":r[0]},i.prototype.elementName=function(t,e,r){return r===n.EOF?"<EOF>":r===n.EPSILON?"<EPSILON>":t[r]||e[r]},e.Interval=o,e.m=i},34411:(t,e,r)=>{var n=r(85749),o=r(91460),i=r(92143),s=r(17393),a=r(7236),l=Array.prototype.slice,u=r(9858),p={on:function(t,e,r){return u.eventsApi(this,"on",t,[e,r])&&e?(this._events||(this._events={}),(this._events[t]||(this._events[t]=[])).push({callback:e,context:r,ctx:r||this}),this):this},once:function(t,e,r){if(!u.eventsApi(this,"once",t,[e,r])||!e)return this;var o=this,i=n((function(){o.off(t,i),e.apply(this,arguments)}));return i._callback=e,this.on(t,i,r)},off:function(t,e,r){var n,i,s,a,l,p,c,h;if(!this._events||!u.eventsApi(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._events=void 0,this;for(l=0,p=(a=t?[t]:o(this._events)).length;l<p;l++)if(t=a[l],s=this._events[t]){if(this._events[t]=n=[],e||r)for(c=0,h=s.length;c<h;c++)i=s[c],(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&n.push(i);n.length||delete this._events[t]}return this},trigger:function(t){if(!this._events)return this;var e=l.call(arguments,1);if(!u.eventsApi(this,"trigger",t,e))return this;var r=this._events[t],n=this._events.all;return r&&u.triggerEvents(r,e),n&&u.triggerEvents(n,arguments),this},stopListening:function(t,e,r){var n=this._listeningTo;if(!n)return this;var o=!e&&!r;r||"object"!=typeof e||(r=this),t&&((n={})[t._listenId]=t);var s=this;return a(n,(function(t,n){t.off(e,r,s),(o||i(t._events))&&delete s._listeningTo[n]})),this},createEmitter:function(t){return s(t||{},p)},listenTo:u.createListenMethod("on"),listenToOnce:u.createListenMethod("once"),listenToAndRun:function(t,e,r){return this.listenTo.apply(this,arguments),r||"object"!=typeof e||(r=this),r.apply(this),this}};p.bind=p.on,p.unbind=p.off,p.removeListener=p.off,p.removeAllListeners=p.off,p.emit=p.trigger,t.exports=p},35671:(t,e,r)=>{var n=r(66603);e.Trees=r(77598).Trees,e.RuleNode=n.RuleNode,e.ParseTreeListener=n.ParseTreeListener,e.ParseTreeVisitor=n.ParseTreeVisitor,e.ParseTreeWalker=n.ParseTreeWalker},36307:(t,e,r)=>{var n=r(86291).Token,o=r(13048).Lexer,i=r(94841).ATN,s=r(53223).e,a=r(23952).X,l=(r(90975).Q,r(90975).F),u=r(1754).PredictionContext,p=r(1754).SingletonPredictionContext,c=r(49832).RuleStopState,h=r(46775).I,d=r(45977).Transition,f=r(8541).I,m=r(64116).LexerNoViableAltException;function g(t){t.index=-1,t.line=0,t.column=-1,t.dfaState=null}function y(){return g(this),this}function v(t,e,r,n){return s.call(this,e,n),this.decisionToDFA=r,this.recog=t,this.startIndex=-1,this.line=1,this.column=0,this.mode=o.DEFAULT_MODE,this.prevAccept=new y,this}y.prototype.reset=function(){g(this)},v.prototype=Object.create(s.prototype),v.prototype.constructor=v,v.debug=!1,v.dfa_debug=!1,v.MIN_DFA_EDGE=0,v.MAX_DFA_EDGE=127,v.match_calls=0,v.prototype.copyState=function(t){this.column=t.column,this.line=t.line,this.mode=t.mode,this.startIndex=t.startIndex},v.prototype.match=function(t,e){this.match_calls+=1,this.mode=e;var r=t.mark();try{this.startIndex=t.index,this.prevAccept.reset();var n=this.decisionToDFA[e];return null===n.s0?this.matchATN(t):this.execATN(t,n.s0)}finally{t.release(r)}},v.prototype.reset=function(){this.prevAccept.reset(),this.startIndex=-1,this.line=1,this.column=0,this.mode=o.DEFAULT_MODE},v.prototype.matchATN=function(t){var e=this.atn.modeToStartState[this.mode];v.debug&&console.log("matchATN mode "+this.mode+" start: "+e);var r=this.mode,n=this.computeStartState(t,e),o=n.hasSemanticContext;n.hasSemanticContext=!1;var i=this.addDFAState(n);o||(this.decisionToDFA[this.mode].s0=i);var s=this.execATN(t,i);return v.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[r].toLexerString()),s},v.prototype.execATN=function(t,e){v.debug&&console.log("start state closure="+e.configs),e.isAcceptState&&this.captureSimState(this.prevAccept,t,e);for(var r=t.LA(1),o=e;;){v.debug&&console.log("execATN loop starting closure: "+o.configs);var i=this.getExistingTargetState(o,r);if(null===i&&(i=this.computeTargetState(t,o,r)),i===s.ERROR)break;if(r!==n.EOF&&this.consume(t),i.isAcceptState&&(this.captureSimState(this.prevAccept,t,i),r===n.EOF))break;r=t.LA(1),o=i}return this.failOrAccept(this.prevAccept,t,o.configs,r)},v.prototype.getExistingTargetState=function(t,e){if(null===t.edges||e<v.MIN_DFA_EDGE||e>v.MAX_DFA_EDGE)return null;var r=t.edges[e-v.MIN_DFA_EDGE];return void 0===r&&(r=null),v.debug&&null!==r&&console.log("reuse state "+t.stateNumber+" edge to "+r.stateNumber),r},v.prototype.computeTargetState=function(t,e,r){var n=new l;return this.getReachableConfigSet(t,e.configs,n,r),0===n.items.length?(n.hasSemanticContext||this.addDFAEdge(e,r,s.ERROR),s.ERROR):this.addDFAEdge(e,r,null,n)},v.prototype.failOrAccept=function(t,e,r,o){if(null!==this.prevAccept.dfaState){var i=t.dfaState.lexerActionExecutor;return this.accept(e,i,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(o===n.EOF&&e.index===this.startIndex)return n.EOF;throw new m(this.recog,e,this.startIndex,r)},v.prototype.getReachableConfigSet=function(t,e,r,o){for(var s=i.INVALID_ALT_NUMBER,a=0;a<e.items.length;a++){var l=e.items[a],u=l.alt===s;if(!u||!l.passedThroughNonGreedyDecision){v.debug&&console.log("testing %s at %s\n",this.getTokenName(o),l.toString(this.recog,!0));for(var p=0;p<l.state.transitions.length;p++){var c=l.state.transitions[p],d=this.getReachableTarget(c,o);if(null!==d){var f=l.lexerActionExecutor;null!==f&&(f=f.fixOffsetBeforeMatch(t.index-this.startIndex));var m=o===n.EOF,g=new h({state:d,lexerActionExecutor:f},l);this.closure(t,g,r,u,!0,m)&&(s=l.alt)}}}}},v.prototype.accept=function(t,e,r,n,o,i){v.debug&&console.log("ACTION %s\n",e),t.seek(n),this.line=o,this.column=i,null!==e&&null!==this.recog&&e.execute(this.recog,t,r)},v.prototype.getReachableTarget=function(t,e){return t.matches(e,0,o.MAX_CHAR_VALUE)?t.target:null},v.prototype.computeStartState=function(t,e){for(var r=u.EMPTY,n=new l,o=0;o<e.transitions.length;o++){var i=e.transitions[o].target,s=new h({state:i,alt:o+1,context:r},null);this.closure(t,s,n,!1,!1,!1)}return n},v.prototype.closure=function(t,e,r,n,o,i){var s=null;if(v.debug&&console.log("closure("+e.toString(this.recog,!0)+")"),e.state instanceof c){if(v.debug&&(null!==this.recog?console.log("closure at %s rule stop %s\n",this.recog.ruleNames[e.state.ruleIndex],e):console.log("closure at rule stop %s\n",e)),null===e.context||e.context.hasEmptyPath()){if(null===e.context||e.context.isEmpty())return r.add(e),!0;r.add(new h({state:e.state,context:u.EMPTY},e)),n=!0}if(null!==e.context&&!e.context.isEmpty())for(var a=0;a<e.context.length;a++)if(e.context.getReturnState(a)!==u.EMPTY_RETURN_STATE){var l=e.context.getParent(a),p=this.atn.states[e.context.getReturnState(a)];s=new h({state:p,context:l},e),n=this.closure(t,s,r,n,o,i)}return n}e.state.epsilonOnlyTransitions||n&&e.passedThroughNonGreedyDecision||r.add(e);for(var d=0;d<e.state.transitions.length;d++){var f=e.state.transitions[d];null!==(s=this.getEpsilonTarget(t,e,f,r,o,i))&&(n=this.closure(t,s,r,n,o,i))}return n},v.prototype.getEpsilonTarget=function(t,e,r,i,s,a){var l=null;if(r.serializationType===d.RULE){var u=p.create(e.context,r.followState.stateNumber);l=new h({state:r.target,context:u},e)}else{if(r.serializationType===d.PRECEDENCE)throw"Precedence predicates are not supported in lexers.";if(r.serializationType===d.PREDICATE)v.debug&&console.log("EVAL rule "+r.ruleIndex+":"+r.predIndex),i.hasSemanticContext=!0,this.evaluatePredicate(t,r.ruleIndex,r.predIndex,s)&&(l=new h({state:r.target},e));else if(r.serializationType===d.ACTION)if(null===e.context||e.context.hasEmptyPath()){var c=f.append(e.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);l=new h({state:r.target,lexerActionExecutor:c},e)}else l=new h({state:r.target},e);else r.serializationType===d.EPSILON?l=new h({state:r.target},e):r.serializationType!==d.ATOM&&r.serializationType!==d.RANGE&&r.serializationType!==d.SET||a&&r.matches(n.EOF,0,o.MAX_CHAR_VALUE)&&(l=new h({state:r.target},e))}return l},v.prototype.evaluatePredicate=function(t,e,r,n){if(null===this.recog)return!0;if(!n)return this.recog.sempred(null,e,r);var o=this.column,i=this.line,s=t.index,a=t.mark();try{return this.consume(t),this.recog.sempred(null,e,r)}finally{this.column=o,this.line=i,t.seek(s),t.release(a)}},v.prototype.captureSimState=function(t,e,r){t.index=e.index,t.line=this.line,t.column=this.column,t.dfaState=r},v.prototype.addDFAEdge=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),null===r&&null!==n){var o=n.hasSemanticContext;if(n.hasSemanticContext=!1,r=this.addDFAState(n),o)return r}return e<v.MIN_DFA_EDGE||e>v.MAX_DFA_EDGE||(v.debug&&console.log("EDGE "+t+" -> "+r+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-v.MIN_DFA_EDGE]=r),r},v.prototype.addDFAState=function(t){for(var e=new a(null,t),r=null,n=0;n<t.items.length;n++){var o=t.items[n];if(o.state instanceof c){r=o;break}}null!==r&&(e.isAcceptState=!0,e.lexerActionExecutor=r.lexerActionExecutor,e.prediction=this.atn.ruleToTokenType[r.state.ruleIndex]);var i=this.decisionToDFA[this.mode],s=i.states.get(e);if(null!==s)return s;var l=e;return l.stateNumber=i.states.length,t.setReadonly(!0),l.configs=t,i.states.add(l),l},v.prototype.getDFA=function(t){return this.decisionToDFA[t]},v.prototype.getText=function(t){return t.getText(this.startIndex,t.index-1)},v.prototype.consume=function(t){t.LA(1)==="\n".charCodeAt(0)?(this.line+=1,this.column=0):this.column+=1,t.consume()},v.prototype.getTokenName=function(t){return-1===t?"EOF":"'"+String.fromCharCode(t)+"'"},e.LexerATNSimulator=v},37170:(t,e,r)=>{var n=r(56975).m,o=r(66603),i=o.INVALID_INTERVAL,s=o.TerminalNode,a=o.TerminalNodeImpl,l=o.ErrorNodeImpl,u=r(34065).Interval;function p(t,e){t=t||null,e=e||null,n.call(this,t,e),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}function c(t,e,r){return p.call(t,e),this.ruleIndex=r,this}p.prototype=Object.create(n.prototype),p.prototype.constructor=p,p.prototype.copyFrom=function(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map((function(t){t instanceof l&&(this.children.push(t),t.parentCtx=this)}),this))},p.prototype.enterRule=function(t){},p.prototype.exitRule=function(t){},p.prototype.addChild=function(t){return null===this.children&&(this.children=[]),this.children.push(t),t},p.prototype.removeLastChild=function(){null!==this.children&&this.children.pop()},p.prototype.addTokenNode=function(t){var e=new a(t);return this.addChild(e),e.parentCtx=this,e},p.prototype.addErrorNode=function(t){var e=new l(t);return this.addChild(e),e.parentCtx=this,e},p.prototype.getChild=function(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(var r=0;r<this.children.length;r++){var n=this.children[r];if(n instanceof e){if(0===t)return n;t-=1}}return null},p.prototype.getToken=function(t,e){if(null===this.children||e<0||e>=this.children.length)return null;for(var r=0;r<this.children.length;r++){var n=this.children[r];if(n instanceof s&&n.symbol.type===t){if(0===e)return n;e-=1}}return null},p.prototype.getTokens=function(t){if(null===this.children)return[];for(var e=[],r=0;r<this.children.length;r++){var n=this.children[r];n instanceof s&&n.symbol.type===t&&e.push(n)}return e},p.prototype.getTypedRuleContext=function(t,e){return this.getChild(e,t)},p.prototype.getTypedRuleContexts=function(t){if(null===this.children)return[];for(var e=[],r=0;r<this.children.length;r++){var n=this.children[r];n instanceof t&&e.push(n)}return e},p.prototype.getChildCount=function(){return null===this.children?0:this.children.length},p.prototype.getSourceInterval=function(){return null===this.start||null===this.stop?i:new u(this.start.tokenIndex,this.stop.tokenIndex)},n.EMPTY=new p,c.prototype=Object.create(p.prototype),c.prototype.constructor=c,e.ParserRuleContext=p},37864:(t,e,r)=>{r(5527).Set;var n=r(5527).Map,o=r(5527).BitSet,i=r(5527).AltDict,s=r(94841).ATN,a=r(49832).RuleStopState,l=r(90975).Q,u=r(46775).G,p=r(81675).Ij,c=(r(5527).Hash,r(5527).hashStuff);function h(){return this}r(5527).equalArrays,h.SLL=0,h.LL=1,h.LL_EXACT_AMBIG_DETECTION=2,h.hasSLLConflictTerminatingPrediction=function(t,e){if(h.allConfigsInRuleStopStates(e))return!0;if(t===h.SLL&&e.hasSemanticContext){for(var r=new l,n=0;n<e.items.length;n++){var o=e.items[n];o=new u({semanticContext:p.NONE},o),r.add(o)}e=r}var i=h.getConflictingAltSubsets(e);return h.hasConflictingAltSet(i)&&!h.hasStateAssociatedWithOneAlt(e)},h.hasConfigInRuleStopState=function(t){for(var e=0;e<t.items.length;e++)if(t.items[e].state instanceof a)return!0;return!1},h.allConfigsInRuleStopStates=function(t){for(var e=0;e<t.items.length;e++)if(!(t.items[e].state instanceof a))return!1;return!0},h.resolvesToJustOneViableAlt=function(t){return h.getSingleViableAlt(t)},h.allSubsetsConflict=function(t){return!h.hasNonConflictingAltSet(t)},h.hasNonConflictingAltSet=function(t){for(var e=0;e<t.length;e++)if(1===t[e].length)return!0;return!1},h.hasConflictingAltSet=function(t){for(var e=0;e<t.length;e++)if(t[e].length>1)return!0;return!1},h.allSubsetsEqual=function(t){for(var e=null,r=0;r<t.length;r++){var n=t[r];if(null===e)e=n;else if(n!==e)return!1}return!0},h.getUniqueAlt=function(t){var e=h.getAlts(t);return 1===e.length?e.minValue():s.INVALID_ALT_NUMBER},h.getAlts=function(t){var e=new o;return t.map((function(t){e.or(t)})),e},h.getConflictingAltSubsets=function(t){var e=new n;return e.hashFunction=function(t){c(t.state.stateNumber,t.context)},e.equalsFunction=function(t,e){return t.state.stateNumber==e.state.stateNumber&&t.context.equals(e.context)},t.items.map((function(t){var r=e.get(t);null===r&&(r=new o,e.put(t,r)),r.add(t.alt)})),e.getValues()},h.getStateToAltMap=function(t){var e=new i;return t.items.map((function(t){var r=e.get(t.state);null===r&&(r=new o,e.put(t.state,r)),r.add(t.alt)})),e},h.hasStateAssociatedWithOneAlt=function(t){for(var e=h.getStateToAltMap(t).values(),r=0;r<e.length;r++)if(1===e[r].length)return!0;return!1},h.getSingleViableAlt=function(t){for(var e=null,r=0;r<t.length;r++){var n=t[r].minValue();if(null===e)e=n;else if(e!==n)return s.INVALID_ALT_NUMBER}return e},e.PredictionMode=h},39635:(t,e,r)=>{var n=r(46550).InputStream,o="undefined"==typeof window&&"undefined"==typeof importScripts?r(4308):null,i={fromString:function(t){return new n(t,!0)},fromBlob:function(t,e,r,o){var i=FileReader();i.onload=function(t){var e=new n(t.target.result,!0);r(e)},i.onerror=o,i.readAsText(t,e)},fromBuffer:function(t,e){return new n(t.toString(e),!0)},fromPath:function(t,e,r){o.readFile(t,e,(function(t,e){var o=null;null!==e&&(o=new n(e,!0)),r(t,o)}))},fromPathSync:function(t,e){var r=o.readFileSync(t,e);return new n(r,!0)}};e.CharStreams=i},40046:(t,e,r)=>{var n=e;n.bignum=r(83986),n.define=r(99693).define,n.base=r(17871),n.constants=r(85195),n.decoders=r(49995),n.encoders=r(16679)},41825:(t,e,r)=>{var n=r(46324),o=r(34110).Buffer,i=r(5648);function s(t){i.call(this,t),this.enc="pem"}n(s,i),t.exports=s,s.prototype.decode=function(t,e){for(var r=t.toString().split(/[\r\n]+/g),n=e.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/,a=-1,l=-1,u=0;u<r.length;u++){var p=r[u].match(s);if(null!==p&&p[2]===n){if(-1!==a){if("END"!==p[1])break;l=u;break}if("BEGIN"!==p[1])break;a=u}}if(-1===a||-1===l)throw new Error("PEM section not found for: "+n);var c=r.slice(a+1,l).join("");c.replace(/[^a-z0-9\+\/=]+/gi,"");var h=new o(c,"base64");return i.prototype.decode.call(this,h,e)}},43024:(t,e,r)=>{var n=r(85195);e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=n._reverse(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=n._reverse(e.tag)},43125:(t,e)=>{function r(){return this}function n(){return r.call(this),this}function o(t){if(r.call(this),null===t)throw"delegates";return this.delegates=t,this}r.prototype.syntaxError=function(t,e,r,n,o,i){},r.prototype.reportAmbiguity=function(t,e,r,n,o,i,s){},r.prototype.reportAttemptingFullContext=function(t,e,r,n,o,i){},r.prototype.reportContextSensitivity=function(t,e,r,n,o,i){},n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.INSTANCE=new n,n.prototype.syntaxError=function(t,e,r,n,o,i){console.error("line "+r+":"+n+" "+o)},o.prototype=Object.create(r.prototype),o.prototype.constructor=o,o.prototype.syntaxError=function(t,e,r,n,o,i){this.delegates.map((function(s){s.syntaxError(t,e,r,n,o,i)}))},o.prototype.reportAmbiguity=function(t,e,r,n,o,i,s){this.delegates.map((function(a){a.reportAmbiguity(t,e,r,n,o,i,s)}))},o.prototype.reportAttemptingFullContext=function(t,e,r,n,o,i){this.delegates.map((function(s){s.reportAttemptingFullContext(t,e,r,n,o,i)}))},o.prototype.reportContextSensitivity=function(t,e,r,n,o,i){this.delegates.map((function(s){s.reportContextSensitivity(t,e,r,n,o,i)}))},e.ErrorListener=r,e.q=n,e.X=o},44748:(t,e,r)=>{var n=r(5527).BitSet,o=r(43125).ErrorListener,i=r(34065).Interval;function s(t){return o.call(this),t=t||!0,this.exactOnly=t,this}s.prototype=Object.create(o.prototype),s.prototype.constructor=s,s.prototype.reportAmbiguity=function(t,e,r,n,o,s,a){if(!this.exactOnly||o){var l="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(s,a)+", input='"+t.getTokenStream().getText(new i(r,n))+"'";t.notifyErrorListeners(l)}},s.prototype.reportAttemptingFullContext=function(t,e,r,n,o,s){var a="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new i(r,n))+"'";t.notifyErrorListeners(a)},s.prototype.reportContextSensitivity=function(t,e,r,n,o,s){var a="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new i(r,n))+"'";t.notifyErrorListeners(a)},s.prototype.getDecisionDescription=function(t,e){var r=e.decision,n=e.atnStartState.ruleIndex,o=t.ruleNames;if(n<0||n>=o.length)return""+r;var i=o[n]||null;return null===i||0===i.length?""+r:r+" ("+i+")"},s.prototype.getConflictingAlts=function(t,e){if(null!==t)return t;for(var r=new n,o=0;o<e.items.length;o++)r.add(e.items[o].alt);return"{"+r.values().join(", ")+"}"},e.DiagnosticErrorListener=s},45659:(t,e,r)=>{e.RecognitionException=r(64116).RecognitionException,e.NoViableAltException=r(64116).NoViableAltException,e.LexerNoViableAltException=r(64116).LexerNoViableAltException,e.InputMismatchException=r(64116).InputMismatchException,e.FailedPredicateException=r(64116).FailedPredicateException,e.DiagnosticErrorListener=r(44748).DiagnosticErrorListener,e.BailErrorStrategy=r(17436).BailErrorStrategy,e.ErrorListener=r(43125).ErrorListener},45977:(t,e,r)=>{var n=r(86291).Token,o=(r(34065).Interval,r(34065).m),i=r(81675).mT,s=r(81675).Yi;function a(t){if(null==t)throw"target cannot be null.";return this.target=t,this.isEpsilon=!1,this.label=null,this}function l(t,e){return a.call(this,t),this.label_=e,this.label=this.makeLabel(),this.serializationType=a.ATOM,this}function u(t,e,r,n){return a.call(this,t),this.ruleIndex=e,this.precedence=r,this.followState=n,this.serializationType=a.RULE,this.isEpsilon=!0,this}function p(t,e){return a.call(this,t),this.serializationType=a.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e,this}function c(t,e,r){return a.call(this,t),this.serializationType=a.RANGE,this.start=e,this.stop=r,this.label=this.makeLabel(),this}function h(t){return a.call(this,t),this}function d(t,e,r,n){return h.call(this,t),this.serializationType=a.PREDICATE,this.ruleIndex=e,this.predIndex=r,this.isCtxDependent=n,this.isEpsilon=!0,this}function f(t,e,r,n){return a.call(this,t),this.serializationType=a.ACTION,this.ruleIndex=e,this.actionIndex=void 0===r?-1:r,this.isCtxDependent=void 0!==n&&n,this.isEpsilon=!0,this}function m(t,e){return a.call(this,t),this.serializationType=a.SET,null!=e?this.label=e:(this.label=new o,this.label.addOne(n.INVALID_TYPE)),this}function g(t,e){return m.call(this,t,e),this.serializationType=a.NOT_SET,this}function y(t){return a.call(this,t),this.serializationType=a.WILDCARD,this}function v(t,e){return h.call(this,t),this.serializationType=a.PRECEDENCE,this.precedence=e,this.isEpsilon=!0,this}a.EPSILON=1,a.RANGE=2,a.RULE=3,a.PREDICATE=4,a.ATOM=5,a.ACTION=6,a.SET=7,a.NOT_SET=8,a.WILDCARD=9,a.PRECEDENCE=10,a.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],a.serializationTypes={EpsilonTransition:a.EPSILON,RangeTransition:a.RANGE,RuleTransition:a.RULE,PredicateTransition:a.PREDICATE,AtomTransition:a.ATOM,ActionTransition:a.ACTION,SetTransition:a.SET,NotSetTransition:a.NOT_SET,WildcardTransition:a.WILDCARD,PrecedencePredicateTransition:a.PRECEDENCE},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.makeLabel=function(){var t=new o;return t.addOne(this.label_),t},l.prototype.matches=function(t,e,r){return this.label_===t},l.prototype.toString=function(){return this.label_},u.prototype=Object.create(a.prototype),u.prototype.constructor=u,u.prototype.matches=function(t,e,r){return!1},p.prototype=Object.create(a.prototype),p.prototype.constructor=p,p.prototype.matches=function(t,e,r){return!1},p.prototype.toString=function(){return"epsilon"},c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.makeLabel=function(){var t=new o;return t.addRange(this.start,this.stop),t},c.prototype.matches=function(t,e,r){return t>=this.start&&t<=this.stop},c.prototype.toString=function(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"},h.prototype=Object.create(a.prototype),h.prototype.constructor=h,d.prototype=Object.create(h.prototype),d.prototype.constructor=d,d.prototype.matches=function(t,e,r){return!1},d.prototype.getPredicate=function(){return new i(this.ruleIndex,this.predIndex,this.isCtxDependent)},d.prototype.toString=function(){return"pred_"+this.ruleIndex+":"+this.predIndex},f.prototype=Object.create(a.prototype),f.prototype.constructor=f,f.prototype.matches=function(t,e,r){return!1},f.prototype.toString=function(){return"action_"+this.ruleIndex+":"+this.actionIndex},m.prototype=Object.create(a.prototype),m.prototype.constructor=m,m.prototype.matches=function(t,e,r){return this.label.contains(t)},m.prototype.toString=function(){return this.label.toString()},g.prototype=Object.create(m.prototype),g.prototype.constructor=g,g.prototype.matches=function(t,e,r){return t>=e&&t<=r&&!m.prototype.matches.call(this,t,e,r)},g.prototype.toString=function(){return"~"+m.prototype.toString.call(this)},y.prototype=Object.create(a.prototype),y.prototype.constructor=y,y.prototype.matches=function(t,e,r){return t>=e&&t<=r},y.prototype.toString=function(){return"."},v.prototype=Object.create(h.prototype),v.prototype.constructor=v,v.prototype.matches=function(t,e,r){return!1},v.prototype.getPredicate=function(){return new s(this.precedence)},v.prototype.toString=function(){return this.precedence+" >= _p"},e.Transition=a,e.AtomTransition=l,e.SetTransition=m,e.NotSetTransition=g,e.RuleTransition=u,e.ActionTransition=f,e.EpsilonTransition=p,e.RangeTransition=c,e.WildcardTransition=y,e.PredicateTransition=d,e.PrecedencePredicateTransition=v,e.AbstractPredicateTransition=h},46550:(t,e,r)=>{var n=r(86291).Token;function o(t,e){return this.name="<empty>",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,function(t){if(t._index=0,t.data=[],t.decodeToUnicodeCodePoints)for(var e=0;e<t.strdata.length;){var r=t.strdata.codePointAt(e);t.data.push(r),e+=r<=65535?1:2}else for(e=0;e<t.strdata.length;e++){var n=t.strdata.charCodeAt(e);t.data.push(n)}t._size=t.data.length}(this),this}r(88221),r(512),Object.defineProperty(o.prototype,"index",{get:function(){return this._index}}),Object.defineProperty(o.prototype,"size",{get:function(){return this._size}}),o.prototype.reset=function(){this._index=0},o.prototype.consume=function(){if(this._index>=this._size)throw"cannot consume EOF";this._index+=1},o.prototype.LA=function(t){if(0===t)return 0;t<0&&(t+=1);var e=this._index+t-1;return e<0||e>=this._size?n.EOF:this.data[e]},o.prototype.LT=function(t){return this.LA(t)},o.prototype.mark=function(){return-1},o.prototype.release=function(t){},o.prototype.seek=function(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)},o.prototype.getText=function(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){for(var r="",n=t;n<=e;n++)r+=String.fromCodePoint(this.data[n]);return r}return this.strdata.slice(t,e+1)},o.prototype.toString=function(){return this.strdata},e.InputStream=o},46775:(t,e,r)=>{var n=r(49832).DecisionState,o=r(81675).Ij,i=r(5527).Hash;function s(t,e){if(null===t){var r={state:null,alt:null,context:null,semanticContext:null};return e&&(r.reachesIntoOuterContext=0),r}var n={};return n.state=t.state||null,n.alt=void 0===t.alt?null:t.alt,n.context=t.context||null,n.semanticContext=t.semanticContext||null,e&&(n.reachesIntoOuterContext=t.reachesIntoOuterContext||0,n.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),n}function a(t,e){return this.checkContext(t,e),t=s(t),e=s(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:o.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed,this}function l(t,e){a.call(this,t,e);var r=t.lexerActionExecutor||null;return this.lexerActionExecutor=r||(null!==e?e.lexerActionExecutor:null),this.passedThroughNonGreedyDecision=null!==e&&this.checkNonGreedyDecision(e,this.state),this}a.prototype.checkContext=function(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)},a.prototype.hashCode=function(){var t=new i;return this.updateHashCode(t),t.finish()},a.prototype.updateHashCode=function(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)},a.prototype.equals=function(t){return this===t||t instanceof a&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed},a.prototype.hashCodeForConfigSet=function(){var t=new i;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()},a.prototype.equalsForConfigSet=function(t){return this===t||t instanceof a&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)},a.prototype.toString=function(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==o.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.updateHashCode=function(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)},l.prototype.equals=function(t){return this===t||t instanceof l&&this.passedThroughNonGreedyDecision==t.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(t.lexerActionExecutor):!t.lexerActionExecutor)&&a.prototype.equals.call(this,t)},l.prototype.hashCodeForConfigSet=l.prototype.hashCode,l.prototype.equalsForConfigSet=l.prototype.equals,l.prototype.checkNonGreedyDecision=function(t,e){return t.passedThroughNonGreedyDecision||e instanceof n&&e.nonGreedy},e.G=a,e.I=l},49832:(t,e)=>{function r(){return this.atn=null,this.stateNumber=r.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null,this}function n(){return r.call(this),this.stateType=r.BASIC,this}function o(){return r.call(this),this.decision=-1,this.nonGreedy=!1,this}function i(){return o.call(this),this.endState=null,this}function s(){return i.call(this),this.stateType=r.BLOCK_START,this}function a(){return r.call(this),this.stateType=r.BLOCK_END,this.startState=null,this}function l(){return r.call(this),this.stateType=r.RULE_STOP,this}function u(){return r.call(this),this.stateType=r.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}function p(){return o.call(this),this.stateType=r.PLUS_LOOP_BACK,this}function c(){return i.call(this),this.stateType=r.PLUS_BLOCK_START,this.loopBackState=null,this}function h(){return i.call(this),this.stateType=r.STAR_BLOCK_START,this}function d(){return r.call(this),this.stateType=r.STAR_LOOP_BACK,this}function f(){return o.call(this),this.stateType=r.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}function m(){return r.call(this),this.stateType=r.LOOP_END,this.loopBackState=null,this}function g(){return o.call(this),this.stateType=r.TOKEN_START,this}r.INVALID_TYPE=0,r.BASIC=1,r.RULE_START=2,r.BLOCK_START=3,r.PLUS_BLOCK_START=4,r.STAR_BLOCK_START=5,r.TOKEN_START=6,r.RULE_STOP=7,r.BLOCK_END=8,r.STAR_LOOP_BACK=9,r.STAR_LOOP_ENTRY=10,r.PLUS_LOOP_BACK=11,r.LOOP_END=12,r.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],r.INVALID_STATE_NUMBER=-1,r.prototype.toString=function(){return this.stateNumber},r.prototype.equals=function(t){return t instanceof r&&this.stateNumber===t.stateNumber},r.prototype.isNonGreedyExitState=function(){return!1},r.prototype.addTransition=function(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)},n.prototype=Object.create(r.prototype),n.prototype.constructor=n,o.prototype=Object.create(r.prototype),o.prototype.constructor=o,i.prototype=Object.create(o.prototype),i.prototype.constructor=i,s.prototype=Object.create(i.prototype),s.prototype.constructor=s,a.prototype=Object.create(r.prototype),a.prototype.constructor=a,l.prototype=Object.create(r.prototype),l.prototype.constructor=l,u.prototype=Object.create(r.prototype),u.prototype.constructor=u,p.prototype=Object.create(o.prototype),p.prototype.constructor=p,c.prototype=Object.create(i.prototype),c.prototype.constructor=c,h.prototype=Object.create(i.prototype),h.prototype.constructor=h,d.prototype=Object.create(r.prototype),d.prototype.constructor=d,f.prototype=Object.create(o.prototype),f.prototype.constructor=f,m.prototype=Object.create(r.prototype),m.prototype.constructor=m,g.prototype=Object.create(o.prototype),g.prototype.constructor=g,e.ATNState=r,e.BasicState=n,e.DecisionState=o,e.BlockStartState=i,e.BlockEndState=a,e.LoopEndState=m,e.RuleStartState=u,e.RuleStopState=l,e.TokensStartState=g,e.PlusLoopbackState=p,e.StarLoopbackState=d,e.StarLoopEntryState=f,e.PlusBlockStartState=c,e.StarBlockStartState=h,e.BasicBlockStartState=s},49995:(t,e,r)=>{var n=e;n.der=r(5648),n.pem=r(41825)},50540:(t,e,r)=>{var n=r(86291).CommonToken;function o(){return this}function i(t){return o.call(this),this.copyText=void 0!==t&&t,this}i.prototype=Object.create(o.prototype),i.prototype.constructor=i,i.DEFAULT=new i,i.prototype.create=function(t,e,r,o,i,s,a,l){var u=new n(t,e,o,i,s);return u.line=a,u.column=l,null!==r?u.text=r:this.copyText&&null!==t[1]&&(u.text=t[1].getText(i,s)),u},i.prototype.createThin=function(t,e){var r=new n(null,t);return r.text=e,r},e.p=i},53223:(t,e,r)=>{var n=r(23952).X,o=r(90975).Q,i=r(1754).getCachedPredictionContext;function s(t,e){return this.atn=t,this.sharedContextCache=e,this}s.ERROR=new n(2147483647,new o),s.prototype.getCachedContext=function(t){return null===this.sharedContextCache?t:i(t,this.sharedContextCache,{})},e.e=s},56975:(t,e,r)=>{var n=r(66603).RuleNode,o=r(66603).INVALID_INTERVAL,i=r(94841).INVALID_ALT_NUMBER;function s(t,e){return n.call(this),this.parentCtx=t||null,this.invokingState=e||-1,this}s.prototype=Object.create(n.prototype),s.prototype.constructor=s,s.prototype.depth=function(){for(var t=0,e=this;null!==e;)e=e.parentCtx,t+=1;return t},s.prototype.isEmpty=function(){return-1===this.invokingState},s.prototype.getSourceInterval=function(){return o},s.prototype.getRuleContext=function(){return this},s.prototype.getPayload=function(){return this},s.prototype.getText=function(){return 0===this.getChildCount()?"":this.children.map((function(t){return t.getText()})).join("")},s.prototype.getAltNumber=function(){return i},s.prototype.setAltNumber=function(t){},s.prototype.getChild=function(t){return null},s.prototype.getChildCount=function(){return 0},s.prototype.accept=function(t){return t.visitChildren(this)},e.m=s;var a=r(77598).Trees;s.prototype.toStringTree=function(t,e){return a.toStringTree(this,t,e)},s.prototype.toString=function(t,e){t=t||null,e=e||null;for(var r=this,n="[";null!==r&&r!==e;){if(null===t)r.isEmpty()||(n+=r.invokingState);else{var o=r.ruleIndex;n+=o>=0&&o<t.length?t[o]:""+o}null===r.parentCtx||null===t&&r.parentCtx.isEmpty()||(n+=" "),r=r.parentCtx}return n+"]"}},57914:(t,e,r)=>{var n=r(86291).Token,o=r(13048).Lexer,i=r(34065).Interval;function s(){return this}function a(t){return s.call(this),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1,this}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.prototype.mark=function(){return 0},a.prototype.release=function(t){},a.prototype.reset=function(){this.seek(0)},a.prototype.seek=function(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)},a.prototype.get=function(t){return this.lazyInit(),this.tokens[t]},a.prototype.consume=function(){if(!(this.index>=0&&(this.fetchedEOF?this.index<this.tokens.length-1:this.index<this.tokens.length))&&this.LA(1)===n.EOF)throw"cannot consume EOF";this.sync(this.index+1)&&(this.index=this.adjustSeekIndex(this.index+1))},a.prototype.sync=function(t){var e=t-this.tokens.length+1;return!(e>0)||this.fetch(e)>=e},a.prototype.fetch=function(t){if(this.fetchedEOF)return 0;for(var e=0;e<t;e++){var r=this.tokenSource.nextToken();if(r.tokenIndex=this.tokens.length,this.tokens.push(r),r.type===n.EOF)return this.fetchedEOF=!0,e+1}return t},a.prototype.getTokens=function(t,e,r){if(void 0===r&&(r=null),t<0||e<0)return null;this.lazyInit();var o=[];e>=this.tokens.length&&(e=this.tokens.length-1);for(var i=t;i<e;i++){var s=this.tokens[i];if(s.type===n.EOF)break;(null===r||r.contains(s.type))&&o.push(s)}return o},a.prototype.LA=function(t){return this.LT(t).type},a.prototype.LB=function(t){return this.index-t<0?null:this.tokens[this.index-t]},a.prototype.LT=function(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);var e=this.index+t-1;return this.sync(e),e>=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]},a.prototype.adjustSeekIndex=function(t){return t},a.prototype.lazyInit=function(){-1===this.index&&this.setup()},a.prototype.setup=function(){this.sync(0),this.index=this.adjustSeekIndex(0)},a.prototype.setTokenSource=function(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1},a.prototype.nextTokenOnChannel=function(t,e){if(this.sync(t),t>=this.tokens.length)return-1;for(var r=this.tokens[t];r.channel!==this.channel;){if(r.type===n.EOF)return-1;t+=1,this.sync(t),r=this.tokens[t]}return t},a.prototype.previousTokenOnChannel=function(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t},a.prototype.getHiddenTokensToRight=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var r=this.nextTokenOnChannel(t+1,o.DEFAULT_TOKEN_CHANNEL),n=t+1,i=-1===r?this.tokens.length-1:r;return this.filterForChannel(n,i,e)},a.prototype.getHiddenTokensToLeft=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var r=this.previousTokenOnChannel(t-1,o.DEFAULT_TOKEN_CHANNEL);if(r===t-1)return null;var n=r+1,i=t-1;return this.filterForChannel(n,i,e)},a.prototype.filterForChannel=function(t,e,r){for(var n=[],i=t;i<e+1;i++){var s=this.tokens[i];-1===r?s.channel!==o.DEFAULT_TOKEN_CHANNEL&&n.push(s):s.channel===r&&n.push(s)}return 0===n.length?null:n},a.prototype.getSourceName=function(){return this.tokenSource.getSourceName()},a.prototype.getText=function(t){this.lazyInit(),this.fill(),null==t&&(t=new i(0,this.tokens.length-1));var e=t.start;e instanceof n&&(e=e.tokenIndex);var r=t.stop;if(r instanceof n&&(r=r.tokenIndex),null===e||null===r||e<0||r<0)return"";r>=this.tokens.length&&(r=this.tokens.length-1);for(var o="",s=e;s<r+1;s++){var a=this.tokens[s];if(a.type===n.EOF)break;o+=a.text}return o},a.prototype.fill=function(){for(this.lazyInit();1e3===this.fetch(1e3););},e.f=a},59639:(t,e,r)=>{var n=r(5527).Set,o=r(5527).BitSet,i=r(86291).Token,s=r(46775).G,a=(r(34065).Interval,r(34065).m),l=r(49832).RuleStopState,u=r(45977).RuleTransition,p=r(45977).NotSetTransition,c=r(45977).WildcardTransition,h=r(45977).AbstractPredicateTransition,d=r(1754),f=d.predictionContextFromRuleContext,m=d.PredictionContext,g=d.SingletonPredictionContext;function y(t){this.atn=t}y.HIT_PRED=i.INVALID_TYPE,y.prototype.getDecisionLookahead=function(t){if(null===t)return null;for(var e=t.transitions.length,r=[],i=0;i<e;i++){r[i]=new a;var s=new n;this._LOOK(t.transition(i).target,null,m.EMPTY,r[i],s,new o,!1,!1),(0===r[i].length||r[i].contains(y.HIT_PRED))&&(r[i]=null)}return r},y.prototype.LOOK=function(t,e,r){var i=new a,s=null!==(r=r||null)?f(t.atn,r):null;return this._LOOK(t,e,s,i,new n,new o,!0,!0),i},y.prototype._LOOK=function(t,e,r,n,o,a,d,f){var v=new s({state:t,alt:0,context:r},null);if(!o.contains(v)){if(o.add(v),t===e){if(null===r)return void n.addOne(i.EPSILON);if(r.isEmpty()&&f)return void n.addOne(i.EOF)}if(t instanceof l){if(null===r)return void n.addOne(i.EPSILON);if(r.isEmpty()&&f)return void n.addOne(i.EOF);if(r!==m.EMPTY){for(var x=0;x<r.length;x++){var T=this.atn.states[r.getReturnState(x)],S=a.contains(T.ruleIndex);try{a.remove(T.ruleIndex),this._LOOK(T,e,r.getParent(x),n,o,a,d,f)}finally{S&&a.add(T.ruleIndex)}}return}}for(var _=0;_<t.transitions.length;_++){var b=t.transitions[_];if(b.constructor===u){if(a.contains(b.target.ruleIndex))continue;var E=g.create(r,b.followState.stateNumber);try{a.add(b.target.ruleIndex),this._LOOK(b.target,e,E,n,o,a,d,f)}finally{a.remove(b.target.ruleIndex)}}else if(b instanceof h)d?this._LOOK(b.target,e,r,n,o,a,d,f):n.addOne(y.HIT_PRED);else if(b.isEpsilon)this._LOOK(b.target,e,r,n,o,a,d,f);else if(b.constructor===c)n.addRange(i.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);else{var w=b.label;null!==w&&(b instanceof p&&(w=w.complement(i.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),n.addSet(w))}}}},e.a=y},59661:t=>{t.exports=function(t,e){var r=t.length,n=t.indexOf(e)+1;return n>r-1&&(n=0),t[n]}},64116:(t,e,r)=>{var n=r(45977).PredicateTransition;function o(t){return Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,o):(new Error).stack,this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state),this}function i(t,e,r,n){return o.call(this,{message:"",recognizer:t,input:e,ctx:null}),this.startIndex=r,this.deadEndConfigs=n,this}function s(t,e,r,n,i,s){s=s||t._ctx,n=n||t.getCurrentToken(),r=r||t.getCurrentToken(),e=e||t.getInputStream(),o.call(this,{message:"",recognizer:t,input:e,ctx:s}),this.deadEndConfigs=i,this.startToken=r,this.offendingToken=n}function a(t){o.call(this,{message:"",recognizer:t,input:t.getInputStream(),ctx:t._ctx}),this.offendingToken=t.getCurrentToken()}function l(t,e,r){o.call(this,{message:this.formatMessage(e,r||null),recognizer:t,input:t.getInputStream(),ctx:t._ctx});var i=t._interp.atn.states[t.state].transitions[0];return i instanceof n?(this.ruleIndex=i.ruleIndex,this.predicateIndex=i.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=e,this.offendingToken=t.getCurrentToken(),this}function u(){return Error.call(this),Error.captureStackTrace(this,u),this}o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,o.prototype.getExpectedTokens=function(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null},o.prototype.toString=function(){return this.message},i.prototype=Object.create(o.prototype),i.prototype.constructor=i,i.prototype.toString=function(){var t="";return this.startIndex>=0&&this.startIndex<this.input.size&&(t=this.input.getText((this.startIndex,this.startIndex))),"LexerNoViableAltException"+t},s.prototype=Object.create(o.prototype),s.prototype.constructor=s,a.prototype=Object.create(o.prototype),a.prototype.constructor=a,l.prototype=Object.create(o.prototype),l.prototype.constructor=l,l.prototype.formatMessage=function(t,e){return null!==e?e:"failed predicate: {"+t+"}?"},u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,e.RecognitionException=o,e.NoViableAltException=s,e.LexerNoViableAltException=i,e.InputMismatchException=a,e.FailedPredicateException=l,e.ParseCancellationException=u},64315:(t,e,r)=>{var n=r(47186),o=/\s+/;e.triggerEvents=function(t,e){var r,n=-1,o=t.length,i=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++n<o;)(r=t[n]).callback.call(r.ctx);return;case 1:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i);return;case 2:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s);return;case 3:for(;++n<o;)(r=t[n]).callback.call(r.ctx,i,s,a);return;default:for(;++n<o;)(r=t[n]).callback.apply(r.ctx,e);return}},e.eventsApi=function(t,e,r,n){if(!r)return!0;if("object"==typeof r){for(var i in r)t[e].apply(t,[i,r[i]].concat(n));return!1}if(o.test(r)){for(var s=r.split(o),a=0,l=s.length;a<l;a++)t[e].apply(t,[s[a]].concat(n));return!1}return!0},e.createListenMethod=function(t){return function(e,r,o){if(!e)throw new Error("Trying to listenTo event: '"+r+"' but the target object is undefined");if((this._listeningTo||(this._listeningTo={}))[e._listenId||(e._listenId=n("l"))]=e,o||"object"!=typeof r||(o=this),"function"!=typeof e[t])throw new Error("Trying to listenTo event: '"+r+"' on object: "+e.toString()+" but it does not have an 'on' method so is unbindable");return e[t](r,o,this),this}}},66380:(t,e)=>{function r(){}function n(t){return this.actionType=t,this.isPositionDependent=!1,this}function o(){return n.call(this,r.SKIP),this}function i(t){return n.call(this,r.TYPE),this.type=t,this}function s(t){return n.call(this,r.PUSH_MODE),this.mode=t,this}function a(){return n.call(this,r.POP_MODE),this}function l(){return n.call(this,r.MORE),this}function u(t){return n.call(this,r.MODE),this.mode=t,this}function p(t,e){return n.call(this,r.CUSTOM),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0,this}function c(t){return n.call(this,r.CHANNEL),this.channel=t,this}function h(t,e){return n.call(this,e.actionType),this.offset=t,this.action=e,this.isPositionDependent=!0,this}r.CHANNEL=0,r.CUSTOM=1,r.MODE=2,r.MORE=3,r.POP_MODE=4,r.PUSH_MODE=5,r.SKIP=6,r.TYPE=7,n.prototype.hashCode=function(){var t=new Hash;return this.updateHashCode(t),t.finish()},n.prototype.updateHashCode=function(t){t.update(this.actionType)},n.prototype.equals=function(t){return this===t},o.prototype=Object.create(n.prototype),o.prototype.constructor=o,o.INSTANCE=new o,o.prototype.execute=function(t){t.skip()},o.prototype.toString=function(){return"skip"},i.prototype=Object.create(n.prototype),i.prototype.constructor=i,i.prototype.execute=function(t){t.type=this.type},i.prototype.updateHashCode=function(t){t.update(this.actionType,this.type)},i.prototype.equals=function(t){return this===t||t instanceof i&&this.type===t.type},i.prototype.toString=function(){return"type("+this.type+")"},s.prototype=Object.create(n.prototype),s.prototype.constructor=s,s.prototype.execute=function(t){t.pushMode(this.mode)},s.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},s.prototype.equals=function(t){return this===t||t instanceof s&&this.mode===t.mode},s.prototype.toString=function(){return"pushMode("+this.mode+")"},a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.INSTANCE=new a,a.prototype.execute=function(t){t.popMode()},a.prototype.toString=function(){return"popMode"},l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.INSTANCE=new l,l.prototype.execute=function(t){t.more()},l.prototype.toString=function(){return"more"},u.prototype=Object.create(n.prototype),u.prototype.constructor=u,u.prototype.execute=function(t){t.mode(this.mode)},u.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},u.prototype.equals=function(t){return this===t||t instanceof u&&this.mode===t.mode},u.prototype.toString=function(){return"mode("+this.mode+")"},p.prototype=Object.create(n.prototype),p.prototype.constructor=p,p.prototype.execute=function(t){t.action(null,this.ruleIndex,this.actionIndex)},p.prototype.updateHashCode=function(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)},p.prototype.equals=function(t){return this===t||t instanceof p&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex},c.prototype=Object.create(n.prototype),c.prototype.constructor=c,c.prototype.execute=function(t){t._channel=this.channel},c.prototype.updateHashCode=function(t){t.update(this.actionType,this.channel)},c.prototype.equals=function(t){return this===t||t instanceof c&&this.channel===t.channel},c.prototype.toString=function(){return"channel("+this.channel+")"},h.prototype=Object.create(n.prototype),h.prototype.constructor=h,h.prototype.execute=function(t){this.action.execute(t)},h.prototype.updateHashCode=function(t){t.update(this.actionType,this.offset,this.action)},h.prototype.equals=function(t){return this===t||t instanceof h&&this.offset===t.offset&&this.action===t.action},e.LexerActionType=r,e.LexerSkipAction=o,e.LexerChannelAction=c,e.LexerCustomAction=p,e.LexerIndexedCustomAction=h,e.LexerMoreAction=l,e.LexerTypeAction=i,e.LexerPushModeAction=s,e.LexerPopModeAction=a,e.LexerModeAction=u},66603:(t,e,r)=>{var n=r(86291).Token,o=r(34065).Interval,i=new o(-1,-2);function s(){return this}function a(){return s.call(this),this}function l(){return a.call(this),this}function u(){return l.call(this),this}function p(){return l.call(this),this}function c(){return p.call(this),this}function h(){return this}function d(){return this}function f(t){return p.call(this),this.parentCtx=null,this.symbol=t,this}function m(t){return f.call(this,t),this}function g(){return this}r(5527),a.prototype=Object.create(s.prototype),a.prototype.constructor=a,l.prototype=Object.create(a.prototype),l.prototype.constructor=l,u.prototype=Object.create(l.prototype),u.prototype.constructor=u,p.prototype=Object.create(l.prototype),p.prototype.constructor=p,c.prototype=Object.create(p.prototype),c.prototype.constructor=c,h.prototype.visit=function(t){return Array.isArray(t)?t.map((function(t){return t.accept(this)}),this):t.accept(this)},h.prototype.visitChildren=function(t){return t.children?this.visit(t.children):null},h.prototype.visitTerminal=function(t){},h.prototype.visitErrorNode=function(t){},d.prototype.visitTerminal=function(t){},d.prototype.visitErrorNode=function(t){},d.prototype.enterEveryRule=function(t){},d.prototype.exitEveryRule=function(t){},f.prototype=Object.create(p.prototype),f.prototype.constructor=f,f.prototype.getChild=function(t){return null},f.prototype.getSymbol=function(){return this.symbol},f.prototype.getParent=function(){return this.parentCtx},f.prototype.getPayload=function(){return this.symbol},f.prototype.getSourceInterval=function(){if(null===this.symbol)return i;var t=this.symbol.tokenIndex;return new o(t,t)},f.prototype.getChildCount=function(){return 0},f.prototype.accept=function(t){return t.visitTerminal(this)},f.prototype.getText=function(){return this.symbol.text},f.prototype.toString=function(){return this.symbol.type===n.EOF?"<EOF>":this.symbol.text},m.prototype=Object.create(f.prototype),m.prototype.constructor=m,m.prototype.isErrorNode=function(){return!0},m.prototype.accept=function(t){return t.visitErrorNode(this)},g.prototype.walk=function(t,e){if(e instanceof c||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof p)t.visitTerminal(e);else{this.enterRule(t,e);for(var r=0;r<e.getChildCount();r++){var n=e.getChild(r);this.walk(t,n)}this.exitRule(t,e)}},g.prototype.enterRule=function(t,e){var r=e.getRuleContext();t.enterEveryRule(r),r.enterRule(t)},g.prototype.exitRule=function(t,e){var r=e.getRuleContext();r.exitRule(t),t.exitEveryRule(r)},g.DEFAULT=new g,e.RuleNode=u,e.ErrorNode=c,e.TerminalNode=p,e.ErrorNodeImpl=m,e.TerminalNodeImpl=f,e.ParseTreeListener=d,e.ParseTreeVisitor=h,e.ParseTreeWalker=g,e.INVALID_INTERVAL=i},68567:(t,e,r)=>{e.ATN=r(94841).ATN,e.ATNDeserializer=r(13126).ATNDeserializer,e.LexerATNSimulator=r(36307).LexerATNSimulator,e.ParserATNSimulator=r(10732).ParserATNSimulator,e.PredictionMode=r(37864).PredictionMode},70758:(t,e,r)=>{var n=r(47186),o=r(17393),i=function(t){return o({},t)},s=r(28885),a=r(87951),l=r(5901),u=r(6437),p=r(36441),c=r(28015),h=r(56796),d=r(86088),f=r(32050),m=r(23510),g=r(72833),y=r(68425),v=r(91566),x=r(99783),T=r(59661),S=/^change:/,_=function(){};function b(t,e){e||(e={}),this.cid||(this.cid=n("state")),this._events={},this._values={},this._eventBubblingHandlerCache={},this._definition=Object.create(this._definition),e.parse&&(t=this.parse(t,e)),this.parent=e.parent,this.collection=e.collection,this._keyTree=new x,this._initCollections(),this._initChildren(),this._cache={},this._previousAttributes={},t&&this.set(t,o({silent:!0,initial:!0},e)),this._changed={},this._derived&&this._initDerived(),!1!==e.init&&this.initialize.apply(this,arguments)}function E(t,e,r,n){var o,i,s=t._definition[e]={};if(p(r))(o=t._ensureValidType(r))&&(s.type=o);else{if(Array.isArray(r)&&(r={type:(i=r)[0],required:i[1],default:i[2]}),(o=t._ensureValidType(r.type))&&(s.type=o),r.required&&(s.required=!0),r.default&&"object"==typeof r.default)throw new TypeError("The default value for "+e+" cannot be an object/array, must be a value or a function which returns a value/object/array");s.default=r.default,s.allowNull=!!r.allowNull&&r.allowNull,r.setOnce&&(s.setOnce=!0),s.required&&void 0===s.default&&!s.setOnce&&(s.default=t._getDefaultForType(o)),s.test=r.test,s.values=r.values}return n&&(s.session=!0),o||(o=p(r)?r:r.type,console.warn("Invalid data type of `"+o+"` for `"+e+"` property. Use one of the default types or define your own")),Object.defineProperty(t,e,{set:function(t){this.set(e,t)},get:function(){if(!this._values)throw Error('You may be trying to `extend` a state object with "'+e+'" which has been defined in `props` on the object being extended');var t=this._values[e],r=this._dataTypes[s.type];if(void 0!==t)return r&&r.get&&(t=r.get(t)),t;var n=g(s,"default");return this._values[e]=n,void 0!==n&&this._getOnChangeForType(s.type)(n,t,e),n}}),s}function w(t,e,r){(t._derived[e]={fn:d(r)?r:r.fn,cache:!1!==r.cache,depList:r.deps||[]}).depList.forEach((function(r){t._deps[r]=y(t._deps[r]||[],[e])})),Object.defineProperty(t,e,{get:function(){return this._getDerivedProperty(e)},set:function(){throw new TypeError("`"+e+"` is a derived property, it can't be set directly.")}})}o(b.prototype,v,{extraProperties:"ignore",idAttribute:"id",namespaceAttribute:"namespace",typeAttribute:"modelType",initialize:function(){return this},getId:function(){return this[this.idAttribute]},getNamespace:function(){return this[this.namespaceAttribute]},getType:function(){return this[this.typeAttribute]},isNew:function(){return null==this.getId()},escape:function(t){return a(this.get(t))},isValid:function(t){return this._validate({},o(t||{},{validate:!0}))},parse:function(t,e){return t},serialize:function(t){var e=o({props:!0},t),r=this.getAttributes(e,!0),n=function(t,e){r[e]=this[e].serialize()}.bind(this);return l(this._children,n),l(this._collections,n),r},set:function(t,e,r){var n,o,i,s,a,l,p,h,d,f,m,y,v,x,T,S,_,b=this,E=this.extraProperties;if(c(t)||null===t?(d=t,r=e):(d={})[t]=e,r=r||{},!this._validate(d,r))return!1;y=r.unset,m=r.silent,x=r.initial,n=this._changing,this._changing=!0,o=[],x?this._previousAttributes={}:n||(this._previousAttributes=this.attributes,this._changed={});for(var w=0,I=Object.keys(d),C=I.length;w<C;w++){if(i=typeof(s=d[h=I[w]]),v=this._values[h],!(a=this._definition[h])){if(this._children[h]||this._collections[h]){c(s)||(s={}),this[h].set(s,r);continue}if("ignore"===E)continue;if("reject"===E)throw new TypeError('No "'+h+'" property defined on '+(this.type||"this")+' model and extraProperties not set to "ignore" or "allow"');if("allow"===E)a=this._createPropertyDefinition(h,"any");else if(E)throw new TypeError('Invalid value for extraProperties: "'+E+'"')}if(S=this._getCompareForType(a.type),_=this._getOnChangeForType(a.type),(f=this._dataTypes[a.type])&&f.set&&(s=(l=f.set(s)).val,i=l.type),a.test&&(p=a.test.call(this,s,i)))throw new TypeError("Property '"+h+"' failed validation with error: "+p);if(void 0===s&&a.required)throw new TypeError("Required property '"+h+"' must be of type "+a.type+". Tried to set "+s);if(null===s&&a.required&&!a.allowNull)throw new TypeError("Property '"+h+"' must be of type "+a.type+" (cannot be null). Tried to set "+s);if(a.type&&"any"!==a.type&&a.type!==i&&null!=s)throw new TypeError("Property '"+h+"' must be of type "+a.type+". Tried to set "+s);if(a.values&&!u(a.values,s)){var M=g(a,"default");if(y&&void 0!==M)s=M;else if(!y||y&&void 0!==s)throw new TypeError("Property '"+h+"' must be one of values: "+a.values.join(", ")+". Tried to set "+s)}if(T=x||!S(v,s,h),a.setOnce&&void 0!==v&&T)throw new TypeError("Property '"+h+"' can only be set once.");T?(_(s,v,h),x||(this._changed[h]=s,this._previousAttributes[h]=v,y&&delete this._values[h],m||o.push({prev:v,val:s,key:h})),y||(this._values[h]=s)):delete this._changed[h]}if(o.length&&(this._pending=!0),o.forEach((function(t){b.trigger("change:"+t.key,b,t.val,r)})),n)return this;for(;this._pending;)this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},get:function(t){return this[t]},toggle:function(t){var e=this._definition[t];if("boolean"===e.type)this[t]=!this[t];else{if(!e||!e.values)throw new TypeError("Can only toggle properties that are type `boolean` or have `values` array.");this[t]=T(e.values,this[t])}return this},previousAttributes:function(){return i(this._previousAttributes)},hasChanged:function(t){return null==t?!!Object.keys(this._changed).length:m(this._derived,t)?this._derived[t].depList.some((function(t){return this.hasChanged(t)}),this):m(this._changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&i(this._changed);var e,r,n=!1,o=this._changing?this._previousAttributes:this.attributes;for(var s in t)(r=this._definition[s])&&(this._getCompareForType(r.type)(o[s],e=t[s])||((n||(n={}))[s]=e));return n},toJSON:function(){return this.serialize()},unset:function(t,e){var r=this;(t=Array.isArray(t)?t:[t]).forEach((function(t){var n,i=r._definition[t];if(i)return i.required?(n=g(i,"default"),r.set(t,n,e)):r.set(t,n,o({},e,{unset:!0}))}))},clear:function(t){var e=this;return Object.keys(this.attributes).forEach((function(r){e.unset(r,t)})),this},previous:function(t){return null!=t&&Object.keys(this._previousAttributes).length?this._previousAttributes[t]:null},_getDefaultForType:function(t){var e=this._dataTypes[t];return e&&e.default},_getCompareForType:function(t){var e=this._dataTypes[t];return e&&e.compare?e.compare.bind(this):f},_getOnChangeForType:function(t){var e=this._dataTypes[t];return e&&e.onChange?e.onChange.bind(this):_},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=o({},this.attributes,t);var r=this.validationError=this.validate(t,e)||null;return!r||(this.trigger("invalid",this,r,o(e||{},{validationError:r})),!1)},_createPropertyDefinition:function(t,e,r){return E(this,t,e,r)},_ensureValidType:function(t){return u(["string","number","boolean","array","object","date","state","any"].concat(Object.keys(this._dataTypes)),t)?t:void 0},getAttributes:function(t,e){t=o({session:!1,props:!1,derived:!1},t||{});var r,n,i={};for(var s in this._definition)n=this._definition[s],(t.session&&n.session||t.props&&!n.session)&&(r=e?this._values[s]:this[s],e&&r&&d(r.serialize)&&(r=r.serialize()),void 0===r&&(r=g(n,"default")),void 0!==r&&(i[s]=r));if(t.derived)for(var a in this._derived)i[a]=this[a];return i},_initDerived:function(){var t=this;l(this._derived,(function(e,r){var n=t._derived[r];n.deps=n.depList;var o=function(){var e=n.fn.call(t);t._cache[r]===e&&n.cache||(n.cache&&(t._previousAttributes[r]=t._cache[r]),t._cache[r]=e,t.trigger("change:"+r,t,t._cache[r]))};n.deps.forEach((function(e){t._keyTree.add(e,o)}))})),this.on("all",(function(e){S.test(e)&&t._keyTree.get(e.split(":")[1]).forEach((function(t){t()}))}),this)},_getDerivedProperty:function(t,e){return this._derived[t].cache?(!e&&this._cache.hasOwnProperty(t)||(this._cache[t]=this._derived[t].fn.apply(this)),this._cache[t]):this._derived[t].fn.apply(this)},_initCollections:function(){var t;if(this._collections)for(t in this._collections)this._safeSet(t,new this._collections[t](null,{parent:this}))},_initChildren:function(){var t;if(this._children)for(t in this._children)this._safeSet(t,new this._children[t]({},{parent:this})),this.listenTo(this[t],"all",this._getCachedEventBubblingHandler(t))},_getCachedEventBubblingHandler:function(t){return this._eventBubblingHandlerCache[t]||(this._eventBubblingHandlerCache[t]=function(e,r,n){S.test(e)?this.trigger("change:"+t+"."+e.split(":")[1],r,n):"change"===e&&this.trigger("change",this)}.bind(this)),this._eventBubblingHandlerCache[t]},_verifyRequired:function(){var t=this.attributes;for(var e in this._definition)if(this._definition[e].required&&void 0===t[e])return!1;return!0},_safeSet:function(t,e){if(t in this)throw new Error("Encountered namespace collision while setting instance property `"+t+"`");return this[t]=e,this}}),Object.defineProperties(b.prototype,{attributes:{get:function(){return this.getAttributes({props:!0,session:!0})}},all:{get:function(){return this.getAttributes({session:!0,props:!0,derived:!0})}},isState:{get:function(){return!0},set:function(){}}});var I={string:{default:function(){return""}},date:{set:function(t){var e;if(null==t)e="object";else if(h(t))e="date",t=t.valueOf();else{var r=null,n=new Date(t).valueOf();isNaN(n)&&(n=new Date(parseInt(t,10)).valueOf(),isNaN(n)&&(r=!0)),t=n,e="date",r&&(e=typeof t)}return{val:t,type:e}},get:function(t){return null==t?t:new Date(t)},default:function(){return new Date}},array:{set:function(t){return{val:t,type:Array.isArray(t)?"array":typeof t}},default:function(){return[]}},object:{set:function(t){var e=typeof t;return"object"!==e&&void 0===t&&(t=null,e="object"),{val:t,type:e}},default:function(){return{}}},state:{set:function(t){return t instanceof b||t&&t.isState?{val:t,type:"state"}:{val:t,type:typeof t}},compare:function(t,e){return t===e},onChange:function(t,e,r){e&&this.stopListening(e,"all",this._getCachedEventBubblingHandler(r)),null!=t&&this.listenTo(t,"all",this._getCachedEventBubblingHandler(r))}}};b.extend=function(t){var e,r=this;e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return r.apply(this,arguments)},o(e,r);var n=function(){this.constructor=e};if(n.prototype=r.prototype,e.prototype=new n,e.prototype._derived=o({},r.prototype._derived),e.prototype._deps=o({},r.prototype._deps),e.prototype._definition=o({},r.prototype._definition),e.prototype._collections=o({},r.prototype._collections),e.prototype._children=o({},r.prototype._children),e.prototype._dataTypes=o({},r.prototype._dataTypes||I),t)for(var i=["dataTypes","props","session","derived","collections","children"],a=0;a<arguments.length;a++){var u=arguments[a];u.dataTypes&&l(u.dataTypes,(function(t,r){e.prototype._dataTypes[r]=t})),u.props&&l(u.props,(function(t,r){E(e.prototype,r,t)})),u.session&&l(u.session,(function(t,r){E(e.prototype,r,t,!0)})),u.derived&&l(u.derived,(function(t,r){w(e.prototype,r,t)})),u.collections&&l(u.collections,(function(t,r){e.prototype._collections[r]=t})),u.children&&l(u.children,(function(t,r){e.prototype._children[r]=t})),o(e.prototype,s(u,i))}return e.__super__=r.prototype,e},t.exports=b},76488:(t,e,r)=>{var n=r(86291).Token,o=r(57914).f;function i(t,e){return o.call(this,t),this.channel=void 0===e?n.DEFAULT_CHANNEL:e,this}i.prototype=Object.create(o.prototype),i.prototype.constructor=i,i.prototype.adjustSeekIndex=function(t){return this.nextTokenOnChannel(t,this.channel)},i.prototype.LB=function(t){if(0===t||this.index-t<0)return null;for(var e=this.index,r=1;r<=t;)e=this.previousTokenOnChannel(e-1,this.channel),r+=1;return e<0?null:this.tokens[e]},i.prototype.LT=function(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);for(var e=this.index,r=1;r<t;)this.sync(e+1)&&(e=this.nextTokenOnChannel(e+1,this.channel)),r+=1;return this.tokens[e]},i.prototype.getNumberOfOnChannelTokens=function(){var t=0;this.fill();for(var e=0;e<this.tokens.length;e++){var r=this.tokens[e];if(r.channel===this.channel&&(t+=1),r.type===n.EOF)break}return t},e.CommonTokenStream=i},77598:(t,e,r)=>{var n=r(5527),o=r(86291).Token,i=(r(66603).RuleNode,r(66603).ErrorNode),s=r(66603).TerminalNode,a=r(37170).ParserRuleContext,l=r(56975).m,u=r(94841).INVALID_ALT_NUMBER;function p(){}p.toStringTree=function(t,e,r){e=e||null,null!==(r=r||null)&&(e=r.ruleNames);var o=p.getNodeText(t,e);o=n.escapeWhitespace(o,!1);var i=t.getChildCount();if(0===i)return o;var s="("+o+" ";i>0&&(o=p.toStringTree(t.getChild(0),e),s=s.concat(o));for(var a=1;a<i;a++)o=p.toStringTree(t.getChild(a),e),s=s.concat(" "+o);return s.concat(")")},p.getNodeText=function(t,e,r){if(e=e||null,null!==(r=r||null)&&(e=r.ruleNames),null!==e){if(t instanceof l){var n=t.getAltNumber();return n!=u?e[t.ruleIndex]+":"+n:e[t.ruleIndex]}if(t instanceof i)return t.toString();if(t instanceof s&&null!==t.symbol)return t.symbol.text}var a=t.getPayload();return a instanceof o?a.text:t.getPayload().toString()},p.getChildren=function(t){for(var e=[],r=0;r<t.getChildCount();r++)e.push(t.getChild(r));return e},p.getAncestors=function(t){var e=[];for(t=t.getParent();null!==t;)e=[t].concat(e),t=t.getParent();return e},p.findAllTokenNodes=function(t,e){return p.findAllNodes(t,e,!0)},p.findAllRuleNodes=function(t,e){return p.findAllNodes(t,e,!1)},p.findAllNodes=function(t,e,r){var n=[];return p._findAllNodes(t,e,r,n),n},p._findAllNodes=function(t,e,r,n){r&&t instanceof s?t.symbol.type===e&&n.push(t):!r&&t instanceof a&&t.ruleIndex===e&&n.push(t);for(var o=0;o<t.getChildCount();o++)p._findAllNodes(t.getChild(o),e,r,n)},p.descendants=function(t){for(var e=[t],r=0;r<t.getChildCount();r++)e=e.concat(p.descendants(t.getChild(r)));return e},e.Trees=p},81675:(t,e,r)=>{var n=r(5527).Set,o=r(5527).Hash;function i(){return this}function s(t,e,r){return i.call(this),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==r&&r,this}function a(t){i.call(this),this.precedence=void 0===t?0:t}function l(t,e){i.call(this);var r=new n;t instanceof l?t.opnds.map((function(t){r.add(t)})):r.add(t),e instanceof l?e.opnds.map((function(t){r.add(t)})):r.add(e);var o=a.filterPrecedencePredicates(r);if(o.length>0){var s=null;o.map((function(t){(null===s||t.precedence<s.precedence)&&(s=t)})),r.add(s)}return this.opnds=r.values(),this}function u(t,e){i.call(this);var r=new n;t instanceof u?t.opnds.map((function(t){r.add(t)})):r.add(t),e instanceof u?e.opnds.map((function(t){r.add(t)})):r.add(e);var o=a.filterPrecedencePredicates(r);if(o.length>0){var s=o.sort((function(t,e){return t.compareTo(e)})),l=s[s.length-1];r.add(l)}return this.opnds=r.values(),this}i.prototype.hashCode=function(){var t=new o;return this.updateHashCode(t),t.finish()},i.prototype.evaluate=function(t,e){},i.prototype.evalPrecedence=function(t,e){return this},i.andContext=function(t,e){if(null===t||t===i.NONE)return e;if(null===e||e===i.NONE)return t;var r=new l(t,e);return 1===r.opnds.length?r.opnds[0]:r},i.orContext=function(t,e){if(null===t)return e;if(null===e)return t;if(t===i.NONE||e===i.NONE)return i.NONE;var r=new u(t,e);return 1===r.opnds.length?r.opnds[0]:r},s.prototype=Object.create(i.prototype),s.prototype.constructor=s,i.NONE=new s,s.prototype.evaluate=function(t,e){var r=this.isCtxDependent?e:null;return t.sempred(r,this.ruleIndex,this.predIndex)},s.prototype.updateHashCode=function(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)},s.prototype.equals=function(t){return this===t||t instanceof s&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent},s.prototype.toString=function(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"},a.prototype=Object.create(i.prototype),a.prototype.constructor=a,a.prototype.evaluate=function(t,e){return t.precpred(e,this.precedence)},a.prototype.evalPrecedence=function(t,e){return t.precpred(e,this.precedence)?i.NONE:null},a.prototype.compareTo=function(t){return this.precedence-t.precedence},a.prototype.updateHashCode=function(t){t.update(31)},a.prototype.equals=function(t){return this===t||t instanceof a&&this.precedence===t.precedence},a.prototype.toString=function(){return"{"+this.precedence+">=prec}?"},a.filterPrecedencePredicates=function(t){var e=[];return t.values().map((function(t){t instanceof a&&e.push(t)})),e},l.prototype=Object.create(i.prototype),l.prototype.constructor=l,l.prototype.equals=function(t){return this===t||t instanceof l&&this.opnds===t.opnds},l.prototype.updateHashCode=function(t){t.update(this.opnds,"AND")},l.prototype.evaluate=function(t,e){for(var r=0;r<this.opnds.length;r++)if(!this.opnds[r].evaluate(t,e))return!1;return!0},l.prototype.evalPrecedence=function(t,e){for(var r=!1,n=[],o=0;o<this.opnds.length;o++){var s=this.opnds[o],a=s.evalPrecedence(t,e);if(r|=a!==s,null===a)return null;a!==i.NONE&&n.push(a)}if(!r)return this;if(0===n.length)return i.NONE;var l=null;return n.map((function(t){l=null===l?t:i.andContext(l,t)})),l},l.prototype.toString=function(){var t="";return this.opnds.map((function(e){t+="&& "+e.toString()})),t.length>3?t.slice(3):t},u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.constructor=function(t){return this===t||t instanceof u&&this.opnds===t.opnds},u.prototype.updateHashCode=function(t){t.update(this.opnds,"OR")},u.prototype.evaluate=function(t,e){for(var r=0;r<this.opnds.length;r++)if(this.opnds[r].evaluate(t,e))return!0;return!1},u.prototype.evalPrecedence=function(t,e){for(var r=!1,n=[],o=0;o<this.opnds.length;o++){var s=this.opnds[o],a=s.evalPrecedence(t,e);if(r|=a!==s,a===i.NONE)return i.NONE;null!==a&&n.push(a)}if(!r)return this;if(0===n.length)return null;return n.map((function(t){return t})),null},u.prototype.toString=function(){var t="";return this.opnds.map((function(e){t+="|| "+e.toString()})),t.length>3?t.slice(3):t},e.Ij=i,e.Yi=a,e.mT=s},82722:(t,e,r)=>{var n=r(46550).InputStream,o="undefined"==typeof window&&"undefined"==typeof importScripts?r(4308):null;function i(t,e){var r=o.readFileSync(t,"utf8");return n.call(this,r,e),this.fileName=t,this}i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.FileStream=i},83986:function(t,e,r){!function(t,e){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function o(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(34110).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function l(t,e,r){var n=a(t,r);return r-1>=e&&(n|=a(t,r-1)<<4),n}function u(t,e,r,n){for(var o=0,i=Math.min(t.length,r),s=e;s<i;s++){var a=t.charCodeAt(s)-48;o*=n,o+=a>=49?a-49+10:a>=17?a-17+10:a}return o}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var o=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<t.length&&(16===e?this._parseHex(t,o,r):(this._parseBase(t,e,o),"le"===r&&this._initArray(this.toArray(),e,r)))},i.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,s,a=0;if("be"===r)for(o=t.length-1,i=0;o>=0;o-=3)s=t[o]|t[o-1]<<8|t[o-2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);else if("le"===r)for(o=0,i=0;o<t.length;o+=3)s=t[o]|t[o+1]<<8|t[o+2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,i=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)o=l(t,e,n)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)o=l(t,e,n)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,o=1;o<=67108863;o*=e)n++;n--,o=o/e|0;for(var i=t.length-r,s=i%n,a=Math.min(i,i-s)+r,l=0,p=r;p<a;p+=n)l=u(t,p,p+n,e),this.imuln(o),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l);if(0!==s){var c=1;for(l=u(t,p,t.length,e),p=0;p<s;p++)c*=e;this.imuln(c),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var o=0|t.words[0],i=0|e.words[0],s=o*i,a=67108863&s,l=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var p=l>>>26,c=67108863&l,h=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=h;d++){var f=u-d|0;p+=(s=(o=0|t.words[f])*(i=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[u]=0|c,l=0|p}return 0!==l?r.words[u]=0|l:r.length--,r.strip()}i.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var o=0,i=0,s=0;s<this.length;s++){var a=this.words[s],l=(16777215&(a<<o|i)).toString(16);r=0!=(i=a>>>24-o&16777215)||s!==this.length-1?p[6-l.length]+l+r:l+r,(o+=2)>=26&&(o-=26,s--)}for(0!==i&&(r=i.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=c[t],d=h[t];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var m=f.modn(d).toString(t);r=(f=f.idivn(d)).isZero()?m+r:p[u-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return n(void 0!==s),this.toArrayLike(s,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,r){var o=this.byteLength(),i=r||Math.max(1,o);n(o<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0"),this.strip();var s,a,l="le"===e,u=new t(i),p=this.clone();if(l){for(a=0;!p.isZero();a++)s=p.andln(255),p.iushrn(8),u[a]=s;for(;a<i;a++)u[a]=0}else{for(a=0;a<i-o;a++)u[a]=0;for(a=0;!p.isZero();a++)s=p.andln(255),p.iushrn(8),u[i-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return n(!(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return n(!(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return n(!(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var o=0;o<e;o++)this.words[o]=67108863&~this.words[o];return r>0&&(this.words[o]=~this.words[o]&67108863>>26-r),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,o=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<o:this.words[r]&~(1<<o),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var o=0,i=0;i<n.length;i++)e=(0|r.words[i])+(0|n.words[i])+o,this.words[i]=67108863&e,o=e>>>26;for(;0!==o&&i<r.length;i++)e=(0|r.words[i])+o,this.words[i]=67108863&e,o=e>>>26;if(this.length=r.length,0!==o)this.words[this.length]=o,this.length++;else if(r!==this)for(;i<r.length;i++)this.words[i]=r.words[i];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,o=this.cmp(t);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s<n.length;s++)i=(e=(0|r.words[s])-(0|n.words[s])+i)>>26,this.words[s]=67108863&e;for(;0!==i&&s<r.length;s++)i=(e=(0|r.words[s])+i)>>26,this.words[s]=67108863&e;if(0===i&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var f=function(t,e,r){var n,o,i,s=t.words,a=e.words,l=r.words,u=0,p=0|s[0],c=8191&p,h=p>>>13,d=0|s[1],f=8191&d,m=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,x=0|s[3],T=8191&x,S=x>>>13,_=0|s[4],b=8191&_,E=_>>>13,w=0|s[5],I=8191&w,C=w>>>13,M=0|s[6],k=8191&M,A=M>>>13,N=0|s[7],O=8191&N,R=N>>>13,L=0|s[8],P=8191&L,D=L>>>13,j=0|s[9],F=8191&j,q=j>>>13,B=0|a[0],Y=8191&B,U=B>>>13,z=0|a[1],V=8191&z,K=z>>>13,$=0|a[2],H=8191&$,W=$>>>13,Z=0|a[3],G=8191&Z,J=Z>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,ot=0|a[6],it=8191&ot,st=ot>>>13,at=0|a[7],lt=8191&at,ut=at>>>13,pt=0|a[8],ct=8191&pt,ht=pt>>>13,dt=0|a[9],ft=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(c,Y))|0)+((8191&(o=(o=Math.imul(c,U))+Math.imul(h,Y)|0))<<13)|0;u=((i=Math.imul(h,U))+(o>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(f,Y),o=(o=Math.imul(f,U))+Math.imul(m,Y)|0,i=Math.imul(m,U);var yt=(u+(n=n+Math.imul(c,V)|0)|0)+((8191&(o=(o=o+Math.imul(c,K)|0)+Math.imul(h,V)|0))<<13)|0;u=((i=i+Math.imul(h,K)|0)+(o>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,Y),o=(o=Math.imul(y,U))+Math.imul(v,Y)|0,i=Math.imul(v,U),n=n+Math.imul(f,V)|0,o=(o=o+Math.imul(f,K)|0)+Math.imul(m,V)|0,i=i+Math.imul(m,K)|0;var vt=(u+(n=n+Math.imul(c,H)|0)|0)+((8191&(o=(o=o+Math.imul(c,W)|0)+Math.imul(h,H)|0))<<13)|0;u=((i=i+Math.imul(h,W)|0)+(o>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(T,Y),o=(o=Math.imul(T,U))+Math.imul(S,Y)|0,i=Math.imul(S,U),n=n+Math.imul(y,V)|0,o=(o=o+Math.imul(y,K)|0)+Math.imul(v,V)|0,i=i+Math.imul(v,K)|0,n=n+Math.imul(f,H)|0,o=(o=o+Math.imul(f,W)|0)+Math.imul(m,H)|0,i=i+Math.imul(m,W)|0;var xt=(u+(n=n+Math.imul(c,G)|0)|0)+((8191&(o=(o=o+Math.imul(c,J)|0)+Math.imul(h,G)|0))<<13)|0;u=((i=i+Math.imul(h,J)|0)+(o>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(b,Y),o=(o=Math.imul(b,U))+Math.imul(E,Y)|0,i=Math.imul(E,U),n=n+Math.imul(T,V)|0,o=(o=o+Math.imul(T,K)|0)+Math.imul(S,V)|0,i=i+Math.imul(S,K)|0,n=n+Math.imul(y,H)|0,o=(o=o+Math.imul(y,W)|0)+Math.imul(v,H)|0,i=i+Math.imul(v,W)|0,n=n+Math.imul(f,G)|0,o=(o=o+Math.imul(f,J)|0)+Math.imul(m,G)|0,i=i+Math.imul(m,J)|0;var Tt=(u+(n=n+Math.imul(c,Q)|0)|0)+((8191&(o=(o=o+Math.imul(c,tt)|0)+Math.imul(h,Q)|0))<<13)|0;u=((i=i+Math.imul(h,tt)|0)+(o>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(I,Y),o=(o=Math.imul(I,U))+Math.imul(C,Y)|0,i=Math.imul(C,U),n=n+Math.imul(b,V)|0,o=(o=o+Math.imul(b,K)|0)+Math.imul(E,V)|0,i=i+Math.imul(E,K)|0,n=n+Math.imul(T,H)|0,o=(o=o+Math.imul(T,W)|0)+Math.imul(S,H)|0,i=i+Math.imul(S,W)|0,n=n+Math.imul(y,G)|0,o=(o=o+Math.imul(y,J)|0)+Math.imul(v,G)|0,i=i+Math.imul(v,J)|0,n=n+Math.imul(f,Q)|0,o=(o=o+Math.imul(f,tt)|0)+Math.imul(m,Q)|0,i=i+Math.imul(m,tt)|0;var St=(u+(n=n+Math.imul(c,rt)|0)|0)+((8191&(o=(o=o+Math.imul(c,nt)|0)+Math.imul(h,rt)|0))<<13)|0;u=((i=i+Math.imul(h,nt)|0)+(o>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(k,Y),o=(o=Math.imul(k,U))+Math.imul(A,Y)|0,i=Math.imul(A,U),n=n+Math.imul(I,V)|0,o=(o=o+Math.imul(I,K)|0)+Math.imul(C,V)|0,i=i+Math.imul(C,K)|0,n=n+Math.imul(b,H)|0,o=(o=o+Math.imul(b,W)|0)+Math.imul(E,H)|0,i=i+Math.imul(E,W)|0,n=n+Math.imul(T,G)|0,o=(o=o+Math.imul(T,J)|0)+Math.imul(S,G)|0,i=i+Math.imul(S,J)|0,n=n+Math.imul(y,Q)|0,o=(o=o+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,i=i+Math.imul(v,tt)|0,n=n+Math.imul(f,rt)|0,o=(o=o+Math.imul(f,nt)|0)+Math.imul(m,rt)|0,i=i+Math.imul(m,nt)|0;var _t=(u+(n=n+Math.imul(c,it)|0)|0)+((8191&(o=(o=o+Math.imul(c,st)|0)+Math.imul(h,it)|0))<<13)|0;u=((i=i+Math.imul(h,st)|0)+(o>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(O,Y),o=(o=Math.imul(O,U))+Math.imul(R,Y)|0,i=Math.imul(R,U),n=n+Math.imul(k,V)|0,o=(o=o+Math.imul(k,K)|0)+Math.imul(A,V)|0,i=i+Math.imul(A,K)|0,n=n+Math.imul(I,H)|0,o=(o=o+Math.imul(I,W)|0)+Math.imul(C,H)|0,i=i+Math.imul(C,W)|0,n=n+Math.imul(b,G)|0,o=(o=o+Math.imul(b,J)|0)+Math.imul(E,G)|0,i=i+Math.imul(E,J)|0,n=n+Math.imul(T,Q)|0,o=(o=o+Math.imul(T,tt)|0)+Math.imul(S,Q)|0,i=i+Math.imul(S,tt)|0,n=n+Math.imul(y,rt)|0,o=(o=o+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,i=i+Math.imul(v,nt)|0,n=n+Math.imul(f,it)|0,o=(o=o+Math.imul(f,st)|0)+Math.imul(m,it)|0,i=i+Math.imul(m,st)|0;var bt=(u+(n=n+Math.imul(c,lt)|0)|0)+((8191&(o=(o=o+Math.imul(c,ut)|0)+Math.imul(h,lt)|0))<<13)|0;u=((i=i+Math.imul(h,ut)|0)+(o>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(P,Y),o=(o=Math.imul(P,U))+Math.imul(D,Y)|0,i=Math.imul(D,U),n=n+Math.imul(O,V)|0,o=(o=o+Math.imul(O,K)|0)+Math.imul(R,V)|0,i=i+Math.imul(R,K)|0,n=n+Math.imul(k,H)|0,o=(o=o+Math.imul(k,W)|0)+Math.imul(A,H)|0,i=i+Math.imul(A,W)|0,n=n+Math.imul(I,G)|0,o=(o=o+Math.imul(I,J)|0)+Math.imul(C,G)|0,i=i+Math.imul(C,J)|0,n=n+Math.imul(b,Q)|0,o=(o=o+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,i=i+Math.imul(E,tt)|0,n=n+Math.imul(T,rt)|0,o=(o=o+Math.imul(T,nt)|0)+Math.imul(S,rt)|0,i=i+Math.imul(S,nt)|0,n=n+Math.imul(y,it)|0,o=(o=o+Math.imul(y,st)|0)+Math.imul(v,it)|0,i=i+Math.imul(v,st)|0,n=n+Math.imul(f,lt)|0,o=(o=o+Math.imul(f,ut)|0)+Math.imul(m,lt)|0,i=i+Math.imul(m,ut)|0;var Et=(u+(n=n+Math.imul(c,ct)|0)|0)+((8191&(o=(o=o+Math.imul(c,ht)|0)+Math.imul(h,ct)|0))<<13)|0;u=((i=i+Math.imul(h,ht)|0)+(o>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(F,Y),o=(o=Math.imul(F,U))+Math.imul(q,Y)|0,i=Math.imul(q,U),n=n+Math.imul(P,V)|0,o=(o=o+Math.imul(P,K)|0)+Math.imul(D,V)|0,i=i+Math.imul(D,K)|0,n=n+Math.imul(O,H)|0,o=(o=o+Math.imul(O,W)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,W)|0,n=n+Math.imul(k,G)|0,o=(o=o+Math.imul(k,J)|0)+Math.imul(A,G)|0,i=i+Math.imul(A,J)|0,n=n+Math.imul(I,Q)|0,o=(o=o+Math.imul(I,tt)|0)+Math.imul(C,Q)|0,i=i+Math.imul(C,tt)|0,n=n+Math.imul(b,rt)|0,o=(o=o+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,i=i+Math.imul(E,nt)|0,n=n+Math.imul(T,it)|0,o=(o=o+Math.imul(T,st)|0)+Math.imul(S,it)|0,i=i+Math.imul(S,st)|0,n=n+Math.imul(y,lt)|0,o=(o=o+Math.imul(y,ut)|0)+Math.imul(v,lt)|0,i=i+Math.imul(v,ut)|0,n=n+Math.imul(f,ct)|0,o=(o=o+Math.imul(f,ht)|0)+Math.imul(m,ct)|0,i=i+Math.imul(m,ht)|0;var wt=(u+(n=n+Math.imul(c,ft)|0)|0)+((8191&(o=(o=o+Math.imul(c,mt)|0)+Math.imul(h,ft)|0))<<13)|0;u=((i=i+Math.imul(h,mt)|0)+(o>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(F,V),o=(o=Math.imul(F,K))+Math.imul(q,V)|0,i=Math.imul(q,K),n=n+Math.imul(P,H)|0,o=(o=o+Math.imul(P,W)|0)+Math.imul(D,H)|0,i=i+Math.imul(D,W)|0,n=n+Math.imul(O,G)|0,o=(o=o+Math.imul(O,J)|0)+Math.imul(R,G)|0,i=i+Math.imul(R,J)|0,n=n+Math.imul(k,Q)|0,o=(o=o+Math.imul(k,tt)|0)+Math.imul(A,Q)|0,i=i+Math.imul(A,tt)|0,n=n+Math.imul(I,rt)|0,o=(o=o+Math.imul(I,nt)|0)+Math.imul(C,rt)|0,i=i+Math.imul(C,nt)|0,n=n+Math.imul(b,it)|0,o=(o=o+Math.imul(b,st)|0)+Math.imul(E,it)|0,i=i+Math.imul(E,st)|0,n=n+Math.imul(T,lt)|0,o=(o=o+Math.imul(T,ut)|0)+Math.imul(S,lt)|0,i=i+Math.imul(S,ut)|0,n=n+Math.imul(y,ct)|0,o=(o=o+Math.imul(y,ht)|0)+Math.imul(v,ct)|0,i=i+Math.imul(v,ht)|0;var It=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(o=(o=o+Math.imul(f,mt)|0)+Math.imul(m,ft)|0))<<13)|0;u=((i=i+Math.imul(m,mt)|0)+(o>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(F,H),o=(o=Math.imul(F,W))+Math.imul(q,H)|0,i=Math.imul(q,W),n=n+Math.imul(P,G)|0,o=(o=o+Math.imul(P,J)|0)+Math.imul(D,G)|0,i=i+Math.imul(D,J)|0,n=n+Math.imul(O,Q)|0,o=(o=o+Math.imul(O,tt)|0)+Math.imul(R,Q)|0,i=i+Math.imul(R,tt)|0,n=n+Math.imul(k,rt)|0,o=(o=o+Math.imul(k,nt)|0)+Math.imul(A,rt)|0,i=i+Math.imul(A,nt)|0,n=n+Math.imul(I,it)|0,o=(o=o+Math.imul(I,st)|0)+Math.imul(C,it)|0,i=i+Math.imul(C,st)|0,n=n+Math.imul(b,lt)|0,o=(o=o+Math.imul(b,ut)|0)+Math.imul(E,lt)|0,i=i+Math.imul(E,ut)|0,n=n+Math.imul(T,ct)|0,o=(o=o+Math.imul(T,ht)|0)+Math.imul(S,ct)|0,i=i+Math.imul(S,ht)|0;var Ct=(u+(n=n+Math.imul(y,ft)|0)|0)+((8191&(o=(o=o+Math.imul(y,mt)|0)+Math.imul(v,ft)|0))<<13)|0;u=((i=i+Math.imul(v,mt)|0)+(o>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(F,G),o=(o=Math.imul(F,J))+Math.imul(q,G)|0,i=Math.imul(q,J),n=n+Math.imul(P,Q)|0,o=(o=o+Math.imul(P,tt)|0)+Math.imul(D,Q)|0,i=i+Math.imul(D,tt)|0,n=n+Math.imul(O,rt)|0,o=(o=o+Math.imul(O,nt)|0)+Math.imul(R,rt)|0,i=i+Math.imul(R,nt)|0,n=n+Math.imul(k,it)|0,o=(o=o+Math.imul(k,st)|0)+Math.imul(A,it)|0,i=i+Math.imul(A,st)|0,n=n+Math.imul(I,lt)|0,o=(o=o+Math.imul(I,ut)|0)+Math.imul(C,lt)|0,i=i+Math.imul(C,ut)|0,n=n+Math.imul(b,ct)|0,o=(o=o+Math.imul(b,ht)|0)+Math.imul(E,ct)|0,i=i+Math.imul(E,ht)|0;var Mt=(u+(n=n+Math.imul(T,ft)|0)|0)+((8191&(o=(o=o+Math.imul(T,mt)|0)+Math.imul(S,ft)|0))<<13)|0;u=((i=i+Math.imul(S,mt)|0)+(o>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(F,Q),o=(o=Math.imul(F,tt))+Math.imul(q,Q)|0,i=Math.imul(q,tt),n=n+Math.imul(P,rt)|0,o=(o=o+Math.imul(P,nt)|0)+Math.imul(D,rt)|0,i=i+Math.imul(D,nt)|0,n=n+Math.imul(O,it)|0,o=(o=o+Math.imul(O,st)|0)+Math.imul(R,it)|0,i=i+Math.imul(R,st)|0,n=n+Math.imul(k,lt)|0,o=(o=o+Math.imul(k,ut)|0)+Math.imul(A,lt)|0,i=i+Math.imul(A,ut)|0,n=n+Math.imul(I,ct)|0,o=(o=o+Math.imul(I,ht)|0)+Math.imul(C,ct)|0,i=i+Math.imul(C,ht)|0;var kt=(u+(n=n+Math.imul(b,ft)|0)|0)+((8191&(o=(o=o+Math.imul(b,mt)|0)+Math.imul(E,ft)|0))<<13)|0;u=((i=i+Math.imul(E,mt)|0)+(o>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(F,rt),o=(o=Math.imul(F,nt))+Math.imul(q,rt)|0,i=Math.imul(q,nt),n=n+Math.imul(P,it)|0,o=(o=o+Math.imul(P,st)|0)+Math.imul(D,it)|0,i=i+Math.imul(D,st)|0,n=n+Math.imul(O,lt)|0,o=(o=o+Math.imul(O,ut)|0)+Math.imul(R,lt)|0,i=i+Math.imul(R,ut)|0,n=n+Math.imul(k,ct)|0,o=(o=o+Math.imul(k,ht)|0)+Math.imul(A,ct)|0,i=i+Math.imul(A,ht)|0;var At=(u+(n=n+Math.imul(I,ft)|0)|0)+((8191&(o=(o=o+Math.imul(I,mt)|0)+Math.imul(C,ft)|0))<<13)|0;u=((i=i+Math.imul(C,mt)|0)+(o>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(F,it),o=(o=Math.imul(F,st))+Math.imul(q,it)|0,i=Math.imul(q,st),n=n+Math.imul(P,lt)|0,o=(o=o+Math.imul(P,ut)|0)+Math.imul(D,lt)|0,i=i+Math.imul(D,ut)|0,n=n+Math.imul(O,ct)|0,o=(o=o+Math.imul(O,ht)|0)+Math.imul(R,ct)|0,i=i+Math.imul(R,ht)|0;var Nt=(u+(n=n+Math.imul(k,ft)|0)|0)+((8191&(o=(o=o+Math.imul(k,mt)|0)+Math.imul(A,ft)|0))<<13)|0;u=((i=i+Math.imul(A,mt)|0)+(o>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(F,lt),o=(o=Math.imul(F,ut))+Math.imul(q,lt)|0,i=Math.imul(q,ut),n=n+Math.imul(P,ct)|0,o=(o=o+Math.imul(P,ht)|0)+Math.imul(D,ct)|0,i=i+Math.imul(D,ht)|0;var Ot=(u+(n=n+Math.imul(O,ft)|0)|0)+((8191&(o=(o=o+Math.imul(O,mt)|0)+Math.imul(R,ft)|0))<<13)|0;u=((i=i+Math.imul(R,mt)|0)+(o>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(F,ct),o=(o=Math.imul(F,ht))+Math.imul(q,ct)|0,i=Math.imul(q,ht);var Rt=(u+(n=n+Math.imul(P,ft)|0)|0)+((8191&(o=(o=o+Math.imul(P,mt)|0)+Math.imul(D,ft)|0))<<13)|0;u=((i=i+Math.imul(D,mt)|0)+(o>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Lt=(u+(n=Math.imul(F,ft))|0)+((8191&(o=(o=Math.imul(F,mt))+Math.imul(q,ft)|0))<<13)|0;return u=((i=Math.imul(q,mt))+(o>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,l[0]=gt,l[1]=yt,l[2]=vt,l[3]=xt,l[4]=Tt,l[5]=St,l[6]=_t,l[7]=bt,l[8]=Et,l[9]=wt,l[10]=It,l[11]=Ct,l[12]=Mt,l[13]=kt,l[14]=At,l[15]=Nt,l[16]=Ot,l[17]=Rt,l[18]=Lt,0!==u&&(l[19]=u,r.length++),r};function m(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(f=d),i.prototype.mulTo=function(t,e){var r,n=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):n<63?d(this,t,e):n<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,o=0,i=0;i<r.length-1;i++){var s=o;o=0;for(var a=67108863&n,l=Math.min(i,e.length-1),u=Math.max(0,i-t.length+1);u<=l;u++){var p=i-u,c=(0|t.words[p])*(0|e.words[u]),h=67108863&c;a=67108863&(h=h+a|0),o+=(s=(s=s+(c/67108864|0)|0)+(h>>>26)|0)>>>26,s&=67108863}r.words[i]=a,n=s,s=o}return 0!==n?r.words[i]=n:r.length--,r.strip()}(this,t,e):m(this,t,e),r},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,o=0;o<e;o++)n|=(1&t)<<e-o-1,t>>=1;return n},g.prototype.permute=function(t,e,r,n,o,i){for(var s=0;s<i;s++)n[s]=e[t[s]],o[s]=r[t[s]]},g.prototype.transform=function(t,e,r,n,o,i){this.permute(i,t,e,r,n,o);for(var s=1;s<o;s<<=1)for(var a=s<<1,l=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),p=0;p<o;p+=a)for(var c=l,h=u,d=0;d<s;d++){var f=r[p+d],m=n[p+d],g=r[p+d+s],y=n[p+d+s],v=c*g-h*y;y=c*y+h*g,g=v,r[p+d]=f+g,n[p+d]=m+y,r[p+d+s]=f-g,n[p+d+s]=m-y,d!==a&&(v=l*c-u*h,h=l*h+u*c,c=v)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,o=0;for(r=r/2|0;r;r>>>=1)o++;return 1<<o+1+n},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var o=t[n];t[n]=t[r-n-1],t[r-n-1]=o,o=e[n],e[n]=-e[r-n-1],e[r-n-1]=-o}},g.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var o=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&o,r=o<67108864?0:o/67108864|0}return t},g.prototype.convert13b=function(t,e,r,o){for(var i=0,s=0;s<e;s++)i+=0|t[s],r[2*s]=8191&i,i>>>=13,r[2*s+1]=8191&i,i>>>=13;for(s=2*e;s<o;++s)r[s]=0;n(0===i),n(!(-8192&i))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),o=this.makeRBT(n),i=this.stub(n),s=new Array(n),a=new Array(n),l=new Array(n),u=new Array(n),p=new Array(n),c=new Array(n),h=r.words;h.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,i,a,l,n,o),this.transform(u,i,p,c,n,o);for(var d=0;d<n;d++){var f=a[d]*p[d]-l[d]*c[d];l[d]=a[d]*c[d]+l[d]*p[d],a[d]=f}return this.conjugate(a,l,n),this.transform(a,l,h,i,n,o),this.conjugate(h,i,n),this.normalize13b(h,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){n("number"==typeof t),n(t<67108864);for(var e=0,r=0;r<this.length;r++){var o=(0|this.words[r])*t,i=(67108863&o)+(67108863&e);e>>=26,e+=o/67108864|0,e+=i>>>26,this.words[r]=67108863&i}return 0!==e&&(this.words[r]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,o=r%26;e[r]=(t.words[n]&1<<o)>>>o}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,o=(t-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&i,l=(0|this.words[e])-a<<r;this.words[e]=l|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==o){for(e=this.length-1;e>=0;e--)this.words[e+o]=this.words[e];for(e=0;e<o;e++)this.words[e]=0;this.length+=o}return this.strip()},i.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,r){var o;n("number"==typeof t&&t>=0),o=e?(e-e%26)/26:0;var i=t%26,s=Math.min((t-i)/26,this.length),a=67108863^67108863>>>i<<i,l=r;if(o-=s,o=Math.max(0,o),l){for(var u=0;u<s;u++)l.words[u]=this.words[u];l.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var p=0;for(u=this.length-1;u>=0&&(0!==p||u>=o);u--){var c=0|this.words[u];this.words[u]=p<<26-i|c>>>i,p=c&a}return l&&0!==p&&(l.words[l.length++]=p),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,o=1<<e;return!(this.length<=r||!(this.words[r]&o))},i.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var o=67108863^67108863>>>e<<e;this.words[this.length-1]&=o}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,r){var o,i,s=t.length+r;this._expand(s);var a=0;for(o=0;o<t.length;o++){i=(0|this.words[o+r])+a;var l=(0|t.words[o])*e;a=((i-=67108863&l)>>26)-(l/67108864|0),this.words[o+r]=67108863&i}for(;o<this.length-r;o++)a=(i=(0|this.words[o+r])+a)>>26,this.words[o+r]=67108863&i;if(0===a)return this.strip();for(n(-1===a),a=0,o=0;o<this.length;o++)a=(i=-(0|this.words[o])+a)>>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,l=n.length-o.length;if("mod"!==e){(a=new i(null)).length=l+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var p=n.clone()._ishlnsubmul(o,1,l);0===p.negative&&(n=p,a&&(a.words[l]=1));for(var c=l-1;c>=0;c--){var h=67108864*(0|n.words[o.length+c])+(0|n.words[o.length+c-1]);for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(o,h,c);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,c),n.isZero()||(n.negative^=1);a&&(a.words[c]=h)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),o=t.andln(1),i=r.cmp(n);return i<0||1===o&&0===i?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,o=this.length-1;o>=0;o--)r=(e*r+(0|this.words[o]))%t;return r},i.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var o=(0|this.words[r])+67108864*e;this.words[r]=o/t|0,e=o%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),l=new i(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var p=r.clone(),c=e.clone();!e.isZero();){for(var h=0,d=1;!(e.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(e.iushrn(h);h-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(p),s.isub(c)),o.iushrn(1),s.iushrn(1);for(var f=0,m=1;!(r.words[0]&m)&&f<26;++f,m<<=1);if(f>0)for(r.iushrn(f);f-- >0;)(a.isOdd()||l.isOdd())&&(a.iadd(p),l.isub(c)),a.iushrn(1),l.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a),s.isub(l)):(r.isub(e),a.isub(o),l.isub(s))}return{a,b:l,gcd:r.iushln(u)}},i.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),l=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,p=1;!(e.words[0]&p)&&u<26;++u,p<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(l),s.iushrn(1);for(var c=0,h=1;!(r.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(r.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(l),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var o=e.cmp(r);if(o<0){var i=e;e=r,r=i}else if(0===o||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,o=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=o,this;for(var i=o,s=r;0!==i&&s<this.length;s++){var a=0|this.words[s];i=(a+=i)>>>26,a&=67108863,this.words[s]=a}return 0!==i&&(this.words[s]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var o=0|this.words[0];e=o===t?0:o<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],o=0|t.words[r];if(n!==o){n<o?e=-1:n>o&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new b(t)},i.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function x(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function T(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function E(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},o(x,v),x.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),o=0;o<n;o++)e.words[o]=t.words[o];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=i&r,o=10;o<t.length;o++){var s=0|t.words[o];t.words[o-10]=(s&r)<<4|i>>>22,i=s}i>>>=22,t.words[o-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},x.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},o(T,v),o(S,v),o(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,o=67108863&n;n>>>=26,t.words[r]=o,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new x;else if("p224"===t)e=new T;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},b.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,e){n(!(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},b.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},b.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new i(1)).iushrn(2);return this.pow(t,r)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);n(!o.isZero());var a=new i(1).toRed(this),l=a.redNeg(),u=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new i(2*p*p).toRed(this);0!==this.pow(p,u).cmp(l);)p.redIAdd(l);for(var c=this.pow(p,o),h=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),f=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();n(g<f);var y=this.pow(c,new i(1).iushln(f-g-1));h=h.redMul(y),c=y.redSqr(),d=d.redMul(c),f=g}return h},b.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},b.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,l=e.bitLength()%26;for(0===l&&(l=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],p=l-1;p>=0;p--){var c=u>>p&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==s?(s<<=1,s|=c,(4==++a||0===n&&0===p)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}l=26}return o},b.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},b.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new E(t)},o(E,b),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},85076:(t,e)=>{function r(t){return void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions,this}r.defaultOptions=new r,r.defaultOptions.readOnly=!0,e.$=r},85195:(t,e,r)=>{var n=e;n._reverse=function(t){var e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);var n=t[r];e[n]=r})),e},n.der=r(43024)},86291:(t,e)=>{function r(){return this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null,this}function n(t,e,o,i,s){return r.call(this),this.source=void 0!==t?t:n.EMPTY_SOURCE,this.type=void 0!==e?e:null,this.channel=void 0!==o?o:r.DEFAULT_CHANNEL,this.start=void 0!==i?i:-1,this.stop=void 0!==s?s:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=t[0].line,this.column=t[0].column):this.column=-1,this}r.INVALID_TYPE=0,r.EPSILON=-2,r.MIN_USER_TOKEN_TYPE=1,r.EOF=-1,r.DEFAULT_CHANNEL=0,r.HIDDEN_CHANNEL=1,Object.defineProperty(r.prototype,"text",{get:function(){return this._text},set:function(t){this._text=t}}),r.prototype.getTokenSource=function(){return this.source[0]},r.prototype.getInputStream=function(){return this.source[1]},n.prototype=Object.create(r.prototype),n.prototype.constructor=n,n.EMPTY_SOURCE=[null,null],n.prototype.clone=function(){var t=new n(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t},Object.defineProperty(n.prototype,"text",{get:function(){if(null!==this._text)return this._text;var t=this.getInputStream();if(null===t)return null;var e=t.size;return this.start<e&&this.stop<e?t.getText(this.start,this.stop):"<EOF>"},set:function(t){this._text=t}}),n.prototype.toString=function(){var t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"<no text>","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"},e.Token=r,e.CommonToken=n},88221:()=>{var t,e;String.prototype.codePointAt||(e=function(t){if(null==this)throw TypeError();var e=String(this),r=e.length,n=t?Number(t):0;if(n!=n&&(n=0),!(n<0||n>=r)){var o,i=e.charCodeAt(n);return i>=55296&&i<=56319&&r>n+1&&(o=e.charCodeAt(n+1))>=56320&&o<=57343?1024*(i-55296)+o-56320+65536:i}},(t=function(){try{var t={},e=Object.defineProperty,r=e(t,t,t)&&e}catch(t){}return r}())?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e)},90975:(t,e,r)=>{var n=r(94841).ATN,o=r(5527),i=o.Hash,s=o.Set,a=r(81675).Ij,l=r(1754).merge;function u(t){return t.hashCodeForConfigSet()}function p(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}function c(t){return this.configLookup=new s(u,p),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1,this}function h(){return c.call(this),this.configLookup=new s,this}c.prototype.add=function(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==a.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);var r=this.configLookup.add(t);if(r===t)return this.cachedHashCode=-1,this.configs.push(t),!0;var n=!this.fullCtx,o=l(r.context,t.context,n,e);return r.reachesIntoOuterContext=Math.max(r.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(r.precedenceFilterSuppressed=!0),r.context=o,!0},c.prototype.getStates=function(){for(var t=new s,e=0;e<this.configs.length;e++)t.add(this.configs[e].state);return t},c.prototype.getPredicates=function(){for(var t=[],e=0;e<this.configs.length;e++){var r=this.configs[e].semanticContext;r!==a.NONE&&t.push(r.semanticContext)}return t},Object.defineProperty(c.prototype,"items",{get:function(){return this.configs}}),c.prototype.optimizeConfigs=function(t){if(this.readOnly)throw"This set is readonly";if(0!==this.configLookup.length)for(var e=0;e<this.configs.length;e++){var r=this.configs[e];r.context=t.getCachedContext(r.context)}},c.prototype.addAll=function(t){for(var e=0;e<t.length;e++)this.add(t[e]);return!1},c.prototype.equals=function(t){return this===t||t instanceof c&&o.equalArrays(this.configs,t.configs)&&this.fullCtx===t.fullCtx&&this.uniqueAlt===t.uniqueAlt&&this.conflictingAlts===t.conflictingAlts&&this.hasSemanticContext===t.hasSemanticContext&&this.dipsIntoOuterContext===t.dipsIntoOuterContext},c.prototype.hashCode=function(){var t=new i;return this.updateHashCode(t),t.finish()},c.prototype.updateHashCode=function(t){this.readOnly?(-1===this.cachedHashCode&&((t=new i).update(this.configs),this.cachedHashCode=t.finish()),t.update(this.cachedHashCode)):t.update(this.configs)},Object.defineProperty(c.prototype,"length",{get:function(){return this.configs.length}}),c.prototype.isEmpty=function(){return 0===this.configs.length},c.prototype.contains=function(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.contains(t)},c.prototype.containsFast=function(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.containsFast(t)},c.prototype.clear=function(){if(this.readOnly)throw"This set is readonly";this.configs=[],this.cachedHashCode=-1,this.configLookup=new s},c.prototype.setReadonly=function(t){this.readOnly=t,t&&(this.configLookup=null)},c.prototype.toString=function(){return o.arrayToString(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==n.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(null!==this.conflictingAlts?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")},h.prototype=Object.create(c.prototype),h.prototype.constructor=h,e.Q=c,e.F=h},91566:(t,e,r)=>{var n=r(85749),o=r(91460),i=r(92143),s=r(17393),a=r(7236),l=Array.prototype.slice,u=r(64315),p={on:function(t,e,r){return u.eventsApi(this,"on",t,[e,r])&&e?(this._events||(this._events={}),(this._events[t]||(this._events[t]=[])).push({callback:e,context:r,ctx:r||this}),this):this},once:function(t,e,r){if(!u.eventsApi(this,"once",t,[e,r])||!e)return this;var o=this,i=n((function(){o.off(t,i),e.apply(this,arguments)}));return i._callback=e,this.on(t,i,r)},off:function(t,e,r){var n,i,s,a,l,p,c,h;if(!this._events||!u.eventsApi(this,"off",t,[e,r]))return this;if(!t&&!e&&!r)return this._events=void 0,this;for(l=0,p=(a=t?[t]:o(this._events)).length;l<p;l++)if(t=a[l],s=this._events[t]){if(this._events[t]=n=[],e||r)for(c=0,h=s.length;c<h;c++)i=s[c],(e&&e!==i.callback&&e!==i.callback._callback||r&&r!==i.context)&&n.push(i);n.length||delete this._events[t]}return this},trigger:function(t){if(!this._events)return this;var e=l.call(arguments,1);if(!u.eventsApi(this,"trigger",t,e))return this;var r=this._events[t],n=this._events.all;return r&&u.triggerEvents(r,e),n&&u.triggerEvents(n,arguments),this},stopListening:function(t,e,r){var n=this._listeningTo;if(!n)return this;var o=!e&&!r;r||"object"!=typeof e||(r=this),t&&((n={})[t._listenId]=t);var s=this;return a(n,(function(t,n){t.off(e,r,s),(o||i(t._events))&&delete s._listeningTo[n]})),this},createEmitter:function(t){return s(t||{},p)},listenTo:u.createListenMethod("on"),listenToOnce:u.createListenMethod("once"),listenToAndRun:function(t,e,r){return this.listenTo.apply(this,arguments),r||"object"!=typeof e||(r=this),r.apply(this),this}};p.bind=p.on,p.unbind=p.off,p.removeListener=p.off,p.removeAllListeners=p.off,p.emit=p.trigger,t.exports=p},91684:(t,e,r)=>{var n=r(46324),o=r(34110).Buffer,i=r(40046),s=i.base,a=i.constants.der;function l(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u,this.tree._init(t.body)}function u(t){s.Node.call(this,"der",t)}function p(t){return t<10?"0"+t:t}t.exports=l,l.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},n(u,s.Node),u.prototype._encodeComposite=function(t,e,r,n){var i,s=function(t,e,r,n){var o;if("seqof"===t?t="seq":"setof"===t&&(t="set"),a.tagByName.hasOwnProperty(t))o=a.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return n.error("Unknown tag: "+t);o=t}return o>=31?n.error("Multi-octet tag encoding unsupported"):(e||(o|=32),o|=a.tagClassByName[r||"universal"]<<6)}(t,e,r,this.reporter);if(n.length<128)return(i=new o(2))[0]=s,i[1]=n.length,this._createEncoderBuffer([i,n]);for(var l=1,u=n.length;u>=256;u>>=8)l++;(i=new o(2+l))[0]=s,i[1]=128|l,u=1+l;for(var p=n.length;p>0;u--,p>>=8)i[u]=255&p;return this._createEncoderBuffer([i,n])},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var r=new o(2*t.length),n=0;n<t.length;n++)r.writeUInt16BE(t.charCodeAt(n),2*n);return this._createEncoderBuffer(r)}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported")},u.prototype._encodeObjid=function(t,e,r){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s\.]+/g);for(var n=0;n<t.length;n++)t[n]|=0}else if(Array.isArray(t))for(t=t.slice(),n=0;n<t.length;n++)t[n]|=0;if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!r){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}var i=0;for(n=0;n<t.length;n++){var s=t[n];for(i++;s>=128;s>>=7)i++}var a=new o(i),l=a.length-1;for(n=t.length-1;n>=0;n--)for(s=t[n],a[l--]=127&s;(s>>=7)>0;)a[l--]=128|127&s;return this._createEncoderBuffer(a)},u.prototype._encodeTime=function(t,e){var r,n=new Date(t);return"gentime"===e?r=[p(n.getFullYear()),p(n.getUTCMonth()+1),p(n.getUTCDate()),p(n.getUTCHours()),p(n.getUTCMinutes()),p(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[p(n.getFullYear()%100),p(n.getUTCMonth()+1),p(n.getUTCDate()),p(n.getUTCHours()),p(n.getUTCMinutes()),p(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},u.prototype._encodeNull=function(){return this._createEncoderBuffer("")},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!o.isBuffer(t)){var r=t.toArray();!t.sign&&128&r[0]&&r.unshift(0),t=new o(r)}if(o.isBuffer(t)){var n=t.length;0===t.length&&n++;var i=new o(n);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);n=1;for(var s=t;s>=256;s>>=8)n++;for(s=(i=new Array(n)).length-1;s>=0;s--)i[s]=255&t,t>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new o(i))},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},u.prototype._skipDefault=function(t,e,r){var n,o=this._baseState;if(null===o.default)return!1;var i=t.join();if(void 0===o.defaultBuffer&&(o.defaultBuffer=this._encodeValue(o.default,e,r).join()),i.length!==o.defaultBuffer.length)return!1;for(n=0;n<i.length;n++)if(i[n]!==o.defaultBuffer[n])return!1;return!0}},94841:(t,e,r)=>{var n=r(59639).a,o=r(34065).m;function i(t,e){return this.grammarType=t,this.maxTokenType=e,this.states=[],this.decisionToState=[],this.ruleToStartState=[],this.ruleToStopState=null,this.modeNameToStartState={},this.ruleToTokenType=null,this.lexerActions=null,this.modeToStartState=[],this}i.prototype.nextTokensInContext=function(t,e){return new n(this).LOOK(t,null,e)},i.prototype.nextTokensNoContext=function(t){return null!==t.nextTokenWithinRule||(t.nextTokenWithinRule=this.nextTokensInContext(t,null),t.nextTokenWithinRule.readOnly=!0),t.nextTokenWithinRule},i.prototype.nextTokens=function(t,e){return void 0===e?this.nextTokensNoContext(t):this.nextTokensInContext(t,e)},i.prototype.addState=function(t){null!==t&&(t.atn=this,t.stateNumber=this.states.length),this.states.push(t)},i.prototype.removeState=function(t){this.states[t.stateNumber]=null},i.prototype.defineDecisionState=function(t){return this.decisionToState.push(t),t.decision=this.decisionToState.length-1,t.decision},i.prototype.getDecisionState=function(t){return 0===this.decisionToState.length?null:this.decisionToState[t]};var s=r(86291).Token;i.prototype.getExpectedTokens=function(t,e){if(t<0||t>=this.states.length)throw"Invalid state number.";var r=this.states[t],n=this.nextTokens(r);if(!n.contains(s.EPSILON))return n;var i=new o;for(i.addSet(n),i.removeOne(s.EPSILON);null!==e&&e.invokingState>=0&&n.contains(s.EPSILON);){var a=this.states[e.invokingState].transitions[0];n=this.nextTokens(a.followState),i.addSet(n),i.removeOne(s.EPSILON),e=e.parentCtx}return n.contains(s.EPSILON)&&i.addOne(s.EOF),i},i.INVALID_ALT_NUMBER=0,e.ATN=i},95989:(t,e,r)=>{var n=r(46324),o=r(91684);function i(t){o.call(this,t),this.enc="pem"}n(i,o),t.exports=i,i.prototype.encode=function(t,e){for(var r=o.prototype.encode.call(this,t).toString("base64"),n=["-----BEGIN "+e.label+"-----"],i=0;i<r.length;i+=64)n.push(r.slice(i,i+64));return n.push("-----END "+e.label+"-----"),n.join("\n")}},99693:(t,e,r)=>{var n=r(40046),o=r(46324);function i(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}e.define=function(t,e){return new i(t,e)},i.prototype._createNamed=function(t){var e;try{e=r(30091).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(t){e=function(t){this._initNamed(t)}}return o(e,t),e.prototype._initNamed=function(e){t.call(this,e)},new e(this)},i.prototype._getDecoder=function(t){return t=t||"der",this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(n.decoders[t])),this.decoders[t]},i.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},i.prototype._getEncoder=function(t){return t=t||"der",this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(n.encoders[t])),this.encoders[t]},i.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}}};