0)for(;e--;l[r++]=0);for(e=f-1;n>a;){if(l[--n]=0;){for(r=0,d=O[i]%w,v=O[i]/w|0,o=i+(s=u);o>i;)r=((c=d*(c=E[--s]%w)+(a=v*c+(l=E[s]/w|0)*d)%w*w+g[o]+r)/m|0)+(a/w|0)+v*l,g[o--]=c%m;g[o]=r}return r?++n:g.splice(0,1),z(t,g,n)},k.negated=function(){var t=new K(this);return t.s=-t.s||null,t},k.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new K(t,e)).s,!i||!e)return new K(NaN);if(i!=e)return t.s=-e,n.minus(t);var o=n.e/h,s=t.e/h,a=n.c,u=t.c;if(!o||!s){if(!a||!u)return new K(i/0);if(!a[0]||!u[0])return u[0]?t:new K(a[0]?n:0*i)}if(o=b(o),s=b(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=u):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=u.length)<0&&(r=u,u=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+u[e]+i)/f|0,a[e]=f===a[e]?0:a[e]%f;return i&&(a=[i].concat(a),++s),z(t,a,s)},k.precision=k.sd=function(t,e){var r,n,i,o=this;if(null!=t&&t!==!!t)return w(t,1,v),null==e?e=C:w(e,0,8),W(new K(o),t,e);if(!(r=o.c))return null;if(n=(i=r.length-1)*h+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&o.e+1>n&&(n=o.e+1),n},k.shiftedBy=function(t){return w(t,-9007199254740991,p),this.times("1e"+t)},k.squareRoot=k.sqrt=function(){var t,e,n,i,o,s=this,a=s.c,u=s.s,c=s.e,l=N+4,f=new K("0.5");if(1!==u||!a||!a[0])return new K(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+Y(s)))||u==1/0?(((e=g(a)).length+c)%2==0&&(e+="0"),u=Math.sqrt(+e),c=b((c+1)/2)-(c<0||c%2),n=new K(e=u==1/0?"5e"+c:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+c)):n=new K(u+""),n.c[0])for((u=(c=n.e)+l)<3&&(u=0);;)if(o=n,n=f.times(o.plus(r(s,o,l,1))),g(o.c).slice(0,u)===(e=g(n.c)).slice(0,u)){if(n.e0&&y>0){for(o=y%a||a,f=d.substr(0,o);o0&&(f+=l+d.slice(o)),p&&(f="-"+f)}n=h?f+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):f}return(r.prefix||"")+n+(r.suffix||"")},k.toFraction=function(t){var e,n,i,o,s,a,u,l,f,p,y,v,b=this,m=b.c;if(null!=t&&(!(u=new K(t)).isInteger()&&(u.c||1!==u.s)||u.lt(I)))throw Error(c+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+Y(u));if(!m)return new K(b);for(e=new K(I),f=n=new K(I),i=l=new K(I),v=g(m),s=e.e=v.length-b.e-1,e.c[0]=d[(a=s%h)<0?h+a:a],t=!t||u.comparedTo(e)>0?s>0?e:f:u,a=D,D=1/0,u=new K(v),l.c[0]=0;p=r(u,e,0,1),1!=(o=n.plus(p.times(i))).comparedTo(t);)n=i,i=o,f=l.plus(p.times(o=f)),l=o,e=u.minus(p.times(o=e)),u=o;return o=r(t.minus(n),i,0,1),l=l.plus(o.times(f)),n=n.plus(o.times(i)),l.s=f.s=b.s,y=r(f,i,s*=2,C).minus(b).abs().comparedTo(r(l,n,s,C).minus(b).abs())<1?[f,i]:[l,n],D=a,y},k.toNumber=function(){return+Y(this)},k.toPrecision=function(t,e){return null!=t&&w(t,1,v),G(this,t,e,2)},k.toString=function(t){var e,r=this,i=r.s,o=r.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=j||o>=L?E(g(r.c),o):O(g(r.c),o,"0"):10===t?e=O(g((r=W(new K(r),N+o+1,C)).c),r.e,"0"):(w(t,2,V.length,"Base"),e=n(O(g(r.c),o,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},k.valueOf=k.toJSON=function(){return Y(this)},k._isBigNumber=!0,null!=e&&K.set(e),K}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(e,r,e,t))||(t.exports=n)}()},function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},function(t,e,r){"use strict";(function(e){var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=c;var i=r(136),o=r(140);r(14)(c,i);for(var s=n(o.prototype),a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},function(t,e,r){"use strict";r.r(e),r.d(e,"audit",(function(){return o})),r.d(e,"auditTime",(function(){return l})),r.d(e,"buffer",(function(){return f})),r.d(e,"bufferCount",(function(){return y})),r.d(e,"bufferTime",(function(){return w})),r.d(e,"bufferToggle",(function(){return k})),r.d(e,"bufferWhen",(function(){return C})),r.d(e,"catchError",(function(){return M})),r.d(e,"combineAll",(function(){return F})),r.d(e,"combineLatest",(function(){return K})),r.d(e,"concat",(function(){return q})),r.d(e,"concatAll",(function(){return z.a})),r.d(e,"concatMap",(function(){return Y})),r.d(e,"concatMapTo",(function(){return J})),r.d(e,"count",(function(){return $})),r.d(e,"debounce",(function(){return Q})),r.d(e,"debounceTime",(function(){return rt})),r.d(e,"defaultIfEmpty",(function(){return st})),r.d(e,"delay",(function(){return ft})),r.d(e,"delayWhen",(function(){return vt})),r.d(e,"dematerialize",(function(){return _t})),r.d(e,"distinct",(function(){return St})),r.d(e,"distinctUntilChanged",(function(){return At})),r.d(e,"distinctUntilKeyChanged",(function(){return kt})),r.d(e,"elementAt",(function(){return Vt})),r.d(e,"endWith",(function(){return Gt})),r.d(e,"every",(function(){return qt})),r.d(e,"exhaust",(function(){return Yt})),r.d(e,"exhaustMap",(function(){return Zt})),r.d(e,"expand",(function(){return ee})),r.d(e,"filter",(function(){return Nt.a})),r.d(e,"finalize",(function(){return ie})),r.d(e,"find",(function(){return ae})),r.d(e,"findIndex",(function(){return le})),r.d(e,"first",(function(){return he})),r.d(e,"groupBy",(function(){return pe.b})),r.d(e,"ignoreElements",(function(){return de})),r.d(e,"isEmpty",(function(){return be})),r.d(e,"last",(function(){return Oe})),r.d(e,"map",(function(){return Xt.a})),r.d(e,"mapTo",(function(){return Se})),r.d(e,"materialize",(function(){return Ae})),r.d(e,"max",(function(){return Le})),r.d(e,"merge",(function(){return De})),r.d(e,"mergeAll",(function(){return Ue.a})),r.d(e,"mergeMap",(function(){return W.b})),r.d(e,"flatMap",(function(){return W.a})),r.d(e,"mergeMapTo",(function(){return Be})),r.d(e,"mergeScan",(function(){return Fe})),r.d(e,"min",(function(){return Ke})),r.d(e,"multicast",(function(){return qe})),r.d(e,"observeOn",(function(){return We.b})),r.d(e,"onErrorResumeNext",(function(){return Ye})),r.d(e,"pairwise",(function(){return Xe})),r.d(e,"partition",(function(){return er})),r.d(e,"pluck",(function(){return rr})),r.d(e,"publish",(function(){return or})),r.d(e,"publishBehavior",(function(){return ar})),r.d(e,"publishLast",(function(){return cr})),r.d(e,"publishReplay",(function(){return fr})),r.d(e,"race",(function(){return pr})),r.d(e,"reduce",(function(){return je})),r.d(e,"repeat",(function(){return dr})),r.d(e,"repeatWhen",(function(){return br})),r.d(e,"retry",(function(){return wr})),r.d(e,"retryWhen",(function(){return Or})),r.d(e,"refCount",(function(){return Tr.a})),r.d(e,"sample",(function(){return Ar})),r.d(e,"sampleTime",(function(){return kr})),r.d(e,"scan",(function(){return ke})),r.d(e,"sequenceEqual",(function(){return jr})),r.d(e,"share",(function(){return Br})),r.d(e,"shareReplay",(function(){return Fr})),r.d(e,"single",(function(){return Hr})),r.d(e,"skip",(function(){return Gr})),r.d(e,"skipLast",(function(){return Wr})),r.d(e,"skipUntil",(function(){return $r})),r.d(e,"skipWhile",(function(){return Qr})),r.d(e,"startWith",(function(){return rn})),r.d(e,"subscribeOn",(function(){return an})),r.d(e,"switchAll",(function(){return hn})),r.d(e,"switchMap",(function(){return cn})),r.d(e,"switchMapTo",(function(){return pn})),r.d(e,"take",(function(){return Bt})),r.d(e,"takeLast",(function(){return we})),r.d(e,"takeUntil",(function(){return dn})),r.d(e,"takeWhile",(function(){return bn})),r.d(e,"tap",(function(){return En})),r.d(e,"throttle",(function(){return Tn})),r.d(e,"throttleTime",(function(){return Rn})),r.d(e,"throwIfEmpty",(function(){return jt})),r.d(e,"timeInterval",(function(){return jn})),r.d(e,"timeout",(function(){return Hn})),r.d(e,"timeoutWith",(function(){return Dn})),r.d(e,"timestamp",(function(){return Vn})),r.d(e,"toArray",(function(){return qn})),r.d(e,"window",(function(){return zn})),r.d(e,"windowCount",(function(){return Jn})),r.d(e,"windowTime",(function(){return Zn})),r.d(e,"windowToggle",(function(){return oi})),r.d(e,"windowWhen",(function(){return ui})),r.d(e,"withLatestFrom",(function(){return fi})),r.d(e,"zip",(function(){return yi})),r.d(e,"zipAll",(function(){return vi}));var n=r(0),i=r(2);function o(t){return function(e){return e.lift(new s(t))}}var s=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.durationSelector))},t}(),a=function(t){function e(e,r){var n=t.call(this,e)||this;return n.durationSelector=r,n.hasValue=!1,n}return n.a(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var r=Object(i.c)(e,new i.a(this));!r||r.closed?this.clearThrottle():this.add(this.throttled=r)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,r=t.hasValue,n=t.throttled;n&&(this.remove(n),this.throttled=void 0,n.unsubscribe()),r&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(i.b),u=r(6),c=r(97);function l(t,e){return void 0===e&&(e=u.a),o((function(){return Object(c.a)(t,e)}))}function f(t){return function(e){return e.lift(new h(t))}}var h=function(){function t(t){this.closingNotifier=t}return t.prototype.call=function(t,e){return e.subscribe(new p(t,this.closingNotifier))},t}(),p=function(t){function e(e,r){var n=t.call(this,e)||this;return n.buffer=[],n.add(Object(i.c)(r,new i.a(n))),n}return n.a(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype.notifyNext=function(){var t=this.buffer;this.buffer=[],this.destination.next(t)},e}(i.b),d=r(1);function y(t,e){return void 0===e&&(e=null),function(r){return r.lift(new v(t,e))}}var v=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?g:b}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),b=function(t){function e(e,r){var n=t.call(this,e)||this;return n.bufferSize=r,n.buffer=[],n}return n.a(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(d.a),g=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.bufferSize=r,i.startBufferEvery=n,i.buffers=[],i.count=0,i}return n.a(e,t),e.prototype._next=function(t){var e=this,r=e.bufferSize,n=e.startBufferEvery,i=e.buffers,o=e.count;this.count++,o%n==0&&i.push([]);for(var s=i.length;s--;){var a=i[s];a.push(t),a.length===r&&(i.splice(s,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,r=this.destination;e.length>0;){var n=e.shift();n.length>0&&r.next(n)}t.prototype._complete.call(this)},e}(d.a),m=r(9);function w(t){var e=arguments.length,r=u.a;Object(m.a)(arguments[arguments.length-1])&&(r=arguments[arguments.length-1],e--);var n=null;e>=2&&(n=arguments[1]);var i=Number.POSITIVE_INFINITY;return e>=3&&(i=arguments[2]),function(e){return e.lift(new _(t,n,i,r))}}var _=function(){function t(t,e,r,n){this.bufferTimeSpan=t,this.bufferCreationInterval=e,this.maxBufferSize=r,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new O(t,this.bufferTimeSpan,this.bufferCreationInterval,this.maxBufferSize,this.scheduler))},t}(),E=function(){return function(){this.buffer=[]}}(),O=function(t){function e(e,r,n,i,o){var s=t.call(this,e)||this;s.bufferTimeSpan=r,s.bufferCreationInterval=n,s.maxBufferSize=i,s.scheduler=o,s.contexts=[];var a=s.openContext();if(s.timespanOnly=null==n||n<0,s.timespanOnly){var u={subscriber:s,context:a,bufferTimeSpan:r};s.add(a.closeAction=o.schedule(S,r,u))}else{var c={subscriber:s,context:a},l={bufferTimeSpan:r,bufferCreationInterval:n,subscriber:s,scheduler:o};s.add(a.closeAction=o.schedule(T,r,c)),s.add(o.schedule(x,n,l))}return s}return n.a(e,t),e.prototype._next=function(t){for(var e,r=this.contexts,n=r.length,i=0;i0;){var n=e.shift();r.next(n.buffer)}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.contexts=null},e.prototype.onBufferFull=function(t){this.closeContext(t);var e=t.closeAction;if(e.unsubscribe(),this.remove(e),!this.closed&&this.timespanOnly){t=this.openContext();var r=this.bufferTimeSpan,n={subscriber:this,context:t,bufferTimeSpan:r};this.add(t.closeAction=this.scheduler.schedule(S,r,n))}},e.prototype.openContext=function(){var t=new E;return this.contexts.push(t),t},e.prototype.closeContext=function(t){this.destination.next(t.buffer);var e=this.contexts;(e?e.indexOf(t):-1)>=0&&e.splice(e.indexOf(t),1)},e}(d.a);function S(t){var e=t.subscriber,r=t.context;r&&e.closeContext(r),e.closed||(t.context=e.openContext(),t.context.closeAction=this.schedule(t,t.bufferTimeSpan))}function x(t){var e=t.bufferCreationInterval,r=t.bufferTimeSpan,n=t.subscriber,i=t.scheduler,o=n.openContext();n.closed||(n.add(o.closeAction=i.schedule(T,r,{subscriber:n,context:o})),this.schedule(t,e))}function T(t){var e=t.subscriber,r=t.context;e.closeContext(r)}var A=r(4),P=r(15),R=r(19);function k(t,e){return function(r){return r.lift(new I(t,e))}}var I=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new N(t,this.openings,this.closingSelector))},t}(),N=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.closingSelector=n,i.contexts=[],i.add(Object(P.a)(i,r)),i}return n.a(e,t),e.prototype._next=function(t){for(var e=this.contexts,r=e.length,n=0;n0;){var n=r.shift();n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts;e.length>0;){var r=e.shift();this.destination.next(r.buffer),r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e){t?this.closeBuffer(t):this.openBuffer(e)},e.prototype.notifyComplete=function(t){this.closeBuffer(t.context)},e.prototype.openBuffer=function(t){try{var e=this.closingSelector.call(this,t);e&&this.trySubscribe(e)}catch(t){this._error(t)}},e.prototype.closeBuffer=function(t){var e=this.contexts;if(e&&t){var r=t.buffer,n=t.subscription;this.destination.next(r),e.splice(e.indexOf(t),1),this.remove(n),n.unsubscribe()}},e.prototype.trySubscribe=function(t){var e=this.contexts,r=new A.a,n={buffer:[],subscription:r};e.push(n);var i=Object(P.a)(this,t,n);!i||i.closed?this.closeBuffer(n):(i.context=n,this.add(i),r.add(i))},e}(R.a);function C(t){return function(e){return e.lift(new j(t))}}var j=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new L(t,this.closingSelector))},t}(),L=function(t){function e(e,r){var n=t.call(this,e)||this;return n.closingSelector=r,n.subscribing=!1,n.openBuffer(),n}return n.a(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,r=this.buffer;this.buffer&&this.destination.next(r),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new A.a,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add(Object(i.c)(e,new i.a(this))),this.subscribing=!1},e}(i.b);function M(t){return function(e){var r=new D(t),n=e.lift(r);return r.caught=n}}var D=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new U(t,this.selector,this.caught))},t}(),U=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.selector=r,i.caught=n,i}return n.a(e,t),e.prototype.error=function(e){if(!this.isStopped){var r=void 0;try{r=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var n=new i.a(this);this.add(n);var o=Object(i.c)(r,n);o!==n&&this.add(o)}},e}(i.b),B=r(61);function F(t){return function(e){return e.lift(new B.a(t))}}var H=r(7),V=r(12);function K(){for(var t=[],e=0;e0&&r[0].time-n.now()<=0;)r.shift().notification.observe(i);if(r.length>0){var o=Math.max(0,r[0].time-n.now());this.schedule(t,o)}else this.unsubscribe(),e.active=!1},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,r=new dt(e.now()+this.delay,t);this.queue.push(r),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(lt.a.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.scheduleNotification(lt.a.createComplete()),this.unsubscribe()},e}(d.a),dt=function(){return function(t,e){this.time=t,this.notification=e}}(),yt=r(3);function vt(t,e){return e?function(r){return new mt(r,e).lift(new bt(t))}:function(e){return e.lift(new bt(t))}}var bt=function(){function t(t){this.delayDurationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new gt(t,this.delayDurationSelector))},t}(),gt=function(t){function e(e,r){var n=t.call(this,e)||this;return n.delayDurationSelector=r,n.completed=!1,n.delayNotifierSubscriptions=[],n.index=0,n}return n.a(e,t),e.prototype.notifyNext=function(t,e,r,n,i){this.destination.next(t),this.removeSubscription(i),this.tryComplete()},e.prototype.notifyError=function(t,e){this._error(t)},e.prototype.notifyComplete=function(t){var e=this.removeSubscription(t);e&&this.destination.next(e),this.tryComplete()},e.prototype._next=function(t){var e=this.index++;try{var r=this.delayDurationSelector(t,e);r&&this.tryDelay(r,t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.completed=!0,this.tryComplete(),this.unsubscribe()},e.prototype.removeSubscription=function(t){t.unsubscribe();var e=this.delayNotifierSubscriptions.indexOf(t);return-1!==e&&this.delayNotifierSubscriptions.splice(e,1),t.outerValue},e.prototype.tryDelay=function(t,e){var r=Object(P.a)(this,t,e);r&&!r.closed&&(this.destination.add(r),this.delayNotifierSubscriptions.push(r))},e.prototype.tryComplete=function(){this.completed&&0===this.delayNotifierSubscriptions.length&&this.destination.complete()},e}(R.a),mt=function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subscriptionDelay=r,n}return n.a(e,t),e.prototype._subscribe=function(t){this.subscriptionDelay.subscribe(new wt(t,this.source))},e}(yt.a),wt=function(t){function e(e,r){var n=t.call(this)||this;return n.parent=e,n.source=r,n.sourceSubscribed=!1,n}return n.a(e,t),e.prototype._next=function(t){this.subscribeToSource()},e.prototype._error=function(t){this.unsubscribe(),this.parent.error(t)},e.prototype._complete=function(){this.unsubscribe(),this.subscribeToSource()},e.prototype.subscribeToSource=function(){this.sourceSubscribed||(this.sourceSubscribed=!0,this.unsubscribe(),this.source.subscribe(this.parent))},e}(d.a);function _t(){return function(t){return t.lift(new Et)}}var Et=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Ot(t))},t}(),Ot=function(t){function e(e){return t.call(this,e)||this}return n.a(e,t),e.prototype._next=function(t){t.observe(this.destination)},e}(d.a);function St(t,e){return function(r){return r.lift(new xt(t,e))}}var xt=function(){function t(t,e){this.keySelector=t,this.flushes=e}return t.prototype.call=function(t,e){return e.subscribe(new Tt(t,this.keySelector,this.flushes))},t}(),Tt=function(t){function e(e,r,n){var o=t.call(this,e)||this;return o.keySelector=r,o.values=new Set,n&&o.add(Object(i.c)(n,new i.a(o))),o}return n.a(e,t),e.prototype.notifyNext=function(){this.values.clear()},e.prototype.notifyError=function(t){this._error(t)},e.prototype._next=function(t){this.keySelector?this._useKeySelector(t):this._finalizeNext(t,t)},e.prototype._useKeySelector=function(t){var e,r=this.destination;try{e=this.keySelector(t)}catch(t){return void r.error(t)}this._finalizeNext(e,t)},e.prototype._finalizeNext=function(t,e){var r=this.values;r.has(t)||(r.add(t),this.destination.next(e))},e}(i.b);function At(t,e){return function(r){return r.lift(new Pt(t,e))}}var Pt=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new Rt(t,this.compare,this.keySelector))},t}(),Rt=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.keySelector=n,i.hasKey=!1,"function"==typeof r&&(i.compare=r),i}return n.a(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var r=this.keySelector;e=r?r(t):t}catch(t){return this.destination.error(t)}var n=!1;if(this.hasKey)try{n=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;n||(this.key=e,this.destination.next(t))},e}(d.a);function kt(t,e){return At((function(r,n){return e?e(r[t],n[t]):r[t]===n[t]}))}var It=r(31),Nt=r(20),Ct=r(34);function jt(t){return void 0===t&&(t=Dt),function(e){return e.lift(new Lt(t))}}var Lt=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new Mt(t,this.errorFactory))},t}(),Mt=function(t){function e(e,r){var n=t.call(this,e)||this;return n.errorFactory=r,n.hasValue=!1,n}return n.a(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(d.a);function Dt(){return new Ct.a}var Ut=r(10);function Bt(t){return function(e){return 0===t?Object(Ut.b)():e.lift(new Ft(t))}}var Ft=function(){function t(t){if(this.total=t,this.total<0)throw new It.a}return t.prototype.call=function(t,e){return e.subscribe(new Ht(t,this.total))},t}(),Ht=function(t){function e(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return n.a(e,t),e.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},e}(d.a);function Vt(t,e){if(t<0)throw new It.a;var r=arguments.length>=2;return function(n){return n.pipe(Object(Nt.a)((function(e,r){return r===t})),Bt(1),r?st(e):jt((function(){return new It.a})))}}var Kt=r(46);function Gt(){for(var t=[],e=0;e0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(i.b);function ie(t){return function(e){return e.lift(new oe(t))}}var oe=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new se(t,this.callback))},t}(),se=function(t){function e(e,r){var n=t.call(this,e)||this;return n.add(new A.a(r)),n}return n.a(e,t),e}(d.a);function ae(t,e){if("function"!=typeof t)throw new TypeError("predicate is not a function");return function(r){return r.lift(new ue(t,r,!1,e))}}var ue=function(){function t(t,e,r,n){this.predicate=t,this.source=e,this.yieldIndex=r,this.thisArg=n}return t.prototype.call=function(t,e){return e.subscribe(new ce(t,this.predicate,this.source,this.yieldIndex,this.thisArg))},t}(),ce=function(t){function e(e,r,n,i,o){var s=t.call(this,e)||this;return s.predicate=r,s.source=n,s.yieldIndex=i,s.thisArg=o,s.index=0,s}return n.a(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete(),this.unsubscribe()},e.prototype._next=function(t){var e=this.predicate,r=this.thisArg,n=this.index++;try{e.call(r||this,t,n,this.source)&&this.notifyComplete(this.yieldIndex?n:t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){this.notifyComplete(this.yieldIndex?-1:void 0)},e}(d.a);function le(t,e){return function(r){return r.lift(new ue(t,r,!0,e))}}var fe=r(18);function he(t,e){var r=arguments.length>=2;return function(n){return n.pipe(t?Object(Nt.a)((function(e,r){return t(e,r,n)})):fe.a,Bt(1),r?st(e):jt((function(){return new Ct.a})))}}var pe=r(85);function de(){return function(t){return t.lift(new ye)}}var ye=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new ve(t))},t}(),ve=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n.a(e,t),e.prototype._next=function(t){},e}(d.a);function be(){return function(t){return t.lift(new ge)}}var ge=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new me(t))},t}(),me=function(t){function e(e){return t.call(this,e)||this}return n.a(e,t),e.prototype.notifyComplete=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype._next=function(t){this.notifyComplete(!1)},e.prototype._complete=function(){this.notifyComplete(!0)},e}(d.a);function we(t){return function(e){return 0===t?Object(Ut.b)():e.lift(new _e(t))}}var _e=function(){function t(t){if(this.total=t,this.total<0)throw new It.a}return t.prototype.call=function(t,e){return e.subscribe(new Ee(t,this.total))},t}(),Ee=function(t){function e(e,r){var n=t.call(this,e)||this;return n.total=r,n.ring=new Array,n.count=0,n}return n.a(e,t),e.prototype._next=function(t){var e=this.ring,r=this.total,n=this.count++;e.length0)for(var r=this.count>=this.total?this.total:this.count,n=this.ring,i=0;i=2;return function(n){return n.pipe(t?Object(Nt.a)((function(e,r){return t(e,r,n)})):fe.a,we(1),r?st(e):jt((function(){return new Ct.a})))}}function Se(t){return function(e){return e.lift(new xe(t))}}var xe=function(){function t(t){this.value=t}return t.prototype.call=function(t,e){return e.subscribe(new Te(t,this.value))},t}(),Te=function(t){function e(e,r){var n=t.call(this,e)||this;return n.value=r,n}return n.a(e,t),e.prototype._next=function(t){this.destination.next(this.value)},e}(d.a);function Ae(){return function(t){return t.lift(new Pe)}}var Pe=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Re(t))},t}(),Re=function(t){function e(e){return t.call(this,e)||this}return n.a(e,t),e.prototype._next=function(t){this.destination.next(lt.a.createNext(t))},e.prototype._error=function(t){var e=this.destination;e.next(lt.a.createError(t)),e.complete()},e.prototype._complete=function(){var t=this.destination;t.next(lt.a.createComplete()),t.complete()},e}(d.a);function ke(t,e){var r=!1;return arguments.length>=2&&(r=!0),function(n){return n.lift(new Ie(t,e,r))}}var Ie=function(){function t(t,e,r){void 0===r&&(r=!1),this.accumulator=t,this.seed=e,this.hasSeed=r}return t.prototype.call=function(t,e){return e.subscribe(new Ne(t,this.accumulator,this.seed,this.hasSeed))},t}(),Ne=function(t){function e(e,r,n,i){var o=t.call(this,e)||this;return o.accumulator=r,o._seed=n,o.hasSeed=i,o.index=0,o}return n.a(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,r=this.index++;try{e=this.accumulator(this.seed,t,r)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(d.a),Ce=r(49);function je(t,e){return arguments.length>=2?function(r){return Object(Ce.a)(ke(t,e),we(1),st(e))(r)}:function(e){return Object(Ce.a)(ke((function(e,r,n){return t(e,r,n+1)})),we(1))(e)}}function Le(t){return je("function"==typeof t?function(e,r){return t(e,r)>0?e:r}:function(t,e){return t>e?t:e})}var Me=r(95);function De(){for(var t=[],e=0;e0?this._next(t.shift()):0===this.active&&this.hasCompleted&&(!1===this.hasValue&&this.destination.next(this.acc),this.destination.complete())},e}(i.b);function Ke(t){return je("function"==typeof t?function(e,r){return t(e,r)<0?e:r}:function(t,e){return t-1&&(this.count=r-1),e.subscribe(this._unsubscribeAndRecycle())}},e}(d.a);function br(t){return function(e){return e.lift(new gr(t))}}var gr=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){return e.subscribe(new mr(t,this.notifier,e))},t}(),mr=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.notifier=r,i.source=n,i.sourceIsBeingSubscribedTo=!0,i}return n.a(e,t),e.prototype.notifyNext=function(){this.sourceIsBeingSubscribedTo=!0,this.source.subscribe(this)},e.prototype.notifyComplete=function(){if(!1===this.sourceIsBeingSubscribedTo)return t.prototype.complete.call(this)},e.prototype.complete=function(){if(this.sourceIsBeingSubscribedTo=!1,!this.isStopped){if(this.retries||this.subscribeToRetries(),!this.retriesSubscription||this.retriesSubscription.closed)return t.prototype.complete.call(this);this._unsubscribeAndRecycle(),this.notifications.next(void 0)}},e.prototype._unsubscribe=function(){var t=this.notifications,e=this.retriesSubscription;t&&(t.unsubscribe(),this.notifications=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype._unsubscribeAndRecycle=function(){var e=this._unsubscribe;return this._unsubscribe=null,t.prototype._unsubscribeAndRecycle.call(this),this._unsubscribe=e,this},e.prototype.subscribeToRetries=function(){var e;this.notifications=new ir.a;try{e=(0,this.notifier)(this.notifications)}catch(e){return t.prototype.complete.call(this)}this.retries=e,this.retriesSubscription=Object(i.c)(e,new i.a(this))},e}(i.b);function wr(t){return void 0===t&&(t=-1),function(e){return e.lift(new _r(t,e))}}var _r=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Er(t,this.count,this.source))},t}(),Er=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.count=r,i.source=n,i}return n.a(e,t),e.prototype.error=function(e){if(!this.isStopped){var r=this.source,n=this.count;if(0===n)return t.prototype.error.call(this,e);n>-1&&(this.count=n-1),r.subscribe(this._unsubscribeAndRecycle())}},e}(d.a);function Or(t){return function(e){return e.lift(new Sr(t,e))}}var Sr=function(){function t(t,e){this.notifier=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new xr(t,this.notifier,this.source))},t}(),xr=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.notifier=r,i.source=n,i}return n.a(e,t),e.prototype.error=function(e){if(!this.isStopped){var r=this.errors,n=this.retries,o=this.retriesSubscription;if(n)this.errors=void 0,this.retriesSubscription=void 0;else{r=new ir.a;try{n=(0,this.notifier)(r)}catch(e){return t.prototype.error.call(this,e)}o=Object(i.c)(n,new i.a(this))}this._unsubscribeAndRecycle(),this.errors=r,this.retries=n,this.retriesSubscription=o,r.next(e)}},e.prototype._unsubscribe=function(){var t=this.errors,e=this.retriesSubscription;t&&(t.unsubscribe(),this.errors=void 0),e&&(e.unsubscribe(),this.retriesSubscription=void 0),this.retries=void 0},e.prototype.notifyNext=function(){var t=this._unsubscribe;this._unsubscribe=null,this._unsubscribeAndRecycle(),this._unsubscribe=t,this.source.subscribe(this)},e}(i.b),Tr=r(58);function Ar(t){return function(e){return e.lift(new Pr(t))}}var Pr=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var r=new Rr(t),n=e.subscribe(r);return n.add(Object(i.c)(this.notifier,new i.a(r))),n},t}(),Rr=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return n.a(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(i.b);function kr(t,e){return void 0===e&&(e=u.a),function(r){return r.lift(new Ir(t,e))}}var Ir=function(){function t(t,e){this.period=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new Nr(t,this.period,this.scheduler))},t}(),Nr=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.period=r,i.scheduler=n,i.hasValue=!1,i.add(n.schedule(Cr,r,{subscriber:i,period:r})),i}return n.a(e,t),e.prototype._next=function(t){this.lastValue=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.lastValue))},e}(d.a);function Cr(t){var e=t.subscriber,r=t.period;e.notifyNext(),this.schedule(t,r)}function jr(t,e){return function(r){return r.lift(new Lr(t,e))}}var Lr=function(){function t(t,e){this.compareTo=t,this.comparator=e}return t.prototype.call=function(t,e){return e.subscribe(new Mr(t,this.compareTo,this.comparator))},t}(),Mr=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.compareTo=r,i.comparator=n,i._a=[],i._b=[],i._oneComplete=!1,i.destination.add(r.subscribe(new Dr(e,i))),i}return n.a(e,t),e.prototype._next=function(t){this._oneComplete&&0===this._b.length?this.emit(!1):(this._a.push(t),this.checkValues())},e.prototype._complete=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0,this.unsubscribe()},e.prototype.checkValues=function(){for(var t=this,e=t._a,r=t._b,n=t.comparator;e.length>0&&r.length>0;){var i=e.shift(),o=r.shift(),s=!1;try{s=n?n(i,o):i===o}catch(t){this.destination.error(t)}s||this.emit(!1)}},e.prototype.emit=function(t){var e=this.destination;e.next(t),e.complete()},e.prototype.nextB=function(t){this._oneComplete&&0===this._a.length?this.emit(!1):(this._b.push(t),this.checkValues())},e.prototype.completeB=function(){this._oneComplete?this.emit(0===this._a.length&&0===this._b.length):this._oneComplete=!0},e}(d.a),Dr=function(t){function e(e,r){var n=t.call(this,e)||this;return n.parent=r,n}return n.a(e,t),e.prototype._next=function(t){this.parent.nextB(t)},e.prototype._error=function(t){this.parent.error(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.completeB(),this.unsubscribe()},e}(d.a);function Ur(){return new ir.a}function Br(){return function(t){return Object(Tr.a)()(qe(Ur)(t))}}function Fr(t,e,r){var n;return n=t&&"object"==typeof t?t:{bufferSize:t,windowTime:e,refCount:!1,scheduler:r},function(t){return t.lift(function(t){var e,r,n=t.bufferSize,i=void 0===n?Number.POSITIVE_INFINITY:n,o=t.windowTime,s=void 0===o?Number.POSITIVE_INFINITY:o,a=t.refCount,u=t.scheduler,c=0,l=!1,f=!1;return function(t){var n;c++,!e||l?(l=!1,e=new lr.a(i,s,u),n=e.subscribe(this),r=t.subscribe({next:function(t){e.next(t)},error:function(t){l=!0,e.error(t)},complete:function(){f=!0,r=void 0,e.complete()}})):n=e.subscribe(this),this.add((function(){c--,n.unsubscribe(),r&&!f&&a&&0===c&&(r.unsubscribe(),r=void 0,e=void 0)}))}}(n))}}function Hr(t){return function(e){return e.lift(new Vr(t,e))}}var Vr=function(){function t(t,e){this.predicate=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new Kr(t,this.predicate,this.source))},t}(),Kr=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.predicate=r,i.source=n,i.seenValue=!1,i.index=0,i}return n.a(e,t),e.prototype.applySingleValue=function(t){this.seenValue?this.destination.error("Sequence contains more than one element"):(this.seenValue=!0,this.singleValue=t)},e.prototype._next=function(t){var e=this.index++;this.predicate?this.tryNext(t,e):this.applySingleValue(t)},e.prototype.tryNext=function(t,e){try{this.predicate(t,e,this.source)&&this.applySingleValue(t)}catch(t){this.destination.error(t)}},e.prototype._complete=function(){var t=this.destination;this.index>0?(t.next(this.seenValue?this.singleValue:void 0),t.complete()):t.error(new Ct.a)},e}(d.a);function Gr(t){return function(e){return e.lift(new qr(t))}}var qr=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new zr(t,this.total))},t}(),zr=function(t){function e(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return n.a(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(d.a);function Wr(t){return function(e){return e.lift(new Yr(t))}}var Yr=function(){function t(t){if(this._skipCount=t,this._skipCount<0)throw new It.a}return t.prototype.call=function(t,e){return 0===this._skipCount?e.subscribe(new d.a(t)):e.subscribe(new Jr(t,this._skipCount))},t}(),Jr=function(t){function e(e,r){var n=t.call(this,e)||this;return n._skipCount=r,n._count=0,n._ring=new Array(r),n}return n.a(e,t),e.prototype._next=function(t){var e=this._skipCount,r=this._count++;if(r0?this.startWindowEvery:this.windowSize,r=this.destination,n=this.windowSize,i=this.windows,o=i.length,s=0;s=0&&a%e==0&&!this.closed&&i.shift().complete(),++this.count%e==0&&!this.closed){var u=new ir.a;i.push(u),r.next(u)}},e.prototype._error=function(t){var e=this.windows;if(e)for(;e.length>0&&!this.closed;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){var t=this.windows;if(t)for(;t.length>0&&!this.closed;)t.shift().complete();this.destination.complete()},e.prototype._unsubscribe=function(){this.count=0,this.windows=null},e}(d.a);function Zn(t){var e=u.a,r=null,n=Number.POSITIVE_INFINITY;return Object(m.a)(arguments[3])&&(e=arguments[3]),Object(m.a)(arguments[2])?e=arguments[2]:Object(on.a)(arguments[2])&&(n=Number(arguments[2])),Object(m.a)(arguments[1])?e=arguments[1]:Object(on.a)(arguments[1])&&(r=Number(arguments[1])),function(i){return i.lift(new Qn(t,r,n,e))}}var Qn=function(){function t(t,e,r,n){this.windowTimeSpan=t,this.windowCreationInterval=e,this.maxWindowSize=r,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new ei(t,this.windowTimeSpan,this.windowCreationInterval,this.maxWindowSize,this.scheduler))},t}(),ti=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._numberOfNextedValues=0,e}return n.a(e,t),e.prototype.next=function(e){this._numberOfNextedValues++,t.prototype.next.call(this,e)},Object.defineProperty(e.prototype,"numberOfNextedValues",{get:function(){return this._numberOfNextedValues},enumerable:!0,configurable:!0}),e}(ir.a),ei=function(t){function e(e,r,n,i,o){var s=t.call(this,e)||this;s.destination=e,s.windowTimeSpan=r,s.windowCreationInterval=n,s.maxWindowSize=i,s.scheduler=o,s.windows=[];var a=s.openWindow();if(null!==n&&n>=0){var u={subscriber:s,window:a,context:null},c={windowTimeSpan:r,windowCreationInterval:n,subscriber:s,scheduler:o};s.add(o.schedule(ii,r,u)),s.add(o.schedule(ni,n,c))}else{var l={subscriber:s,window:a,windowTimeSpan:r};s.add(o.schedule(ri,r,l))}return s}return n.a(e,t),e.prototype._next=function(t){for(var e=this.windows,r=e.length,n=0;n=this.maxWindowSize&&this.closeWindow(i))}},e.prototype._error=function(t){for(var e=this.windows;e.length>0;)e.shift().error(t);this.destination.error(t)},e.prototype._complete=function(){for(var t=this.windows;t.length>0;){var e=t.shift();e.closed||e.complete()}this.destination.complete()},e.prototype.openWindow=function(){var t=new ti;return this.windows.push(t),this.destination.next(t),t},e.prototype.closeWindow=function(t){t.complete();var e=this.windows;e.splice(e.indexOf(t),1)},e}(d.a);function ri(t){var e=t.subscriber,r=t.windowTimeSpan,n=t.window;n&&e.closeWindow(n),t.window=e.openWindow(),this.schedule(t,r)}function ni(t){var e=t.windowTimeSpan,r=t.subscriber,n=t.scheduler,i=t.windowCreationInterval,o=r.openWindow(),s=this,a={action:s,subscription:null},u={subscriber:r,window:o,context:a};a.subscription=n.schedule(ii,e,u),s.add(a.subscription),s.schedule(t,i)}function ii(t){var e=t.subscriber,r=t.window,n=t.context;n&&n.action&&n.subscription&&n.action.remove(n.subscription),e.closeWindow(r)}function oi(t,e){return function(r){return r.lift(new si(t,e))}}var si=function(){function t(t,e){this.openings=t,this.closingSelector=e}return t.prototype.call=function(t,e){return e.subscribe(new ai(t,this.openings,this.closingSelector))},t}(),ai=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.openings=r,i.closingSelector=n,i.contexts=[],i.add(i.openSubscription=Object(P.a)(i,r,r)),i}return n.a(e,t),e.prototype._next=function(t){var e=this.contexts;if(e)for(var r=e.length,n=0;n0){var i=n.indexOf(r);-1!==i&&n.splice(i,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(R.a),di=r(64);function yi(){for(var t=[],e=0;e1)this.connection=null;else{var r=this.connection,n=t._connection;this.connection=null,!n||r&&n!==r||n.unsubscribe()}}else this.connection=null},e}(i.a)},function(t,e,r){"use strict";r.d(e,"a",(function(){return l}));var n=r(0),i=r(5),o=r(79),s=r(4),a=r(92),u=r(29),c=r(99),l=function(t){function e(e,r,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=n,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return n.a(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new f(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,n=r?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,o=n.length;if(this.closed)throw new u.a;if(this.isStopped||this.hasError?e=s.a.EMPTY:(this.observers.push(t),e=new c.a(this,t)),i&&t.add(t=new a.a(t,i)),r)for(var l=0;le&&(o=Math.max(o,i-e)),o>0&&n.splice(0,o),n},e}(i.a),f=function(){return function(t,e){this.time=t,this.value=e}}()},function(t,e,r){"use strict";r.d(e,"a",(function(){return i}));var n=r(3);function i(t,e){return e?new n.a((function(r){return e.schedule(o,0,{error:t,subscriber:r})})):new n.a((function(e){return e.error(t)}))}function o(t){var e=t.error;t.subscriber.error(e)}},function(t,e,r){"use strict";r.d(e,"b",(function(){return l})),r.d(e,"a",(function(){return f}));var n=r(0),i=r(9),o=r(7),s=r(19),a=r(15),u=r(36),c={};function l(){for(var t=[],e=0;ethis.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),d=function(t){function e(e,r,n){var i=t.call(this,e)||this;return i.parent=r,i.observable=n,i.stillUnsubscribed=!0,i.buffer=[],i.isComplete=!1,i}return n.a(e,t),e.prototype[a.a]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return Object(u.c)(this.observable,new u.a(this))},e}(u.b)},function(t,e,r){"use strict";r.r(e),function(t){var n;r.d(e,"HttpBackend",(function(){return u})),r.d(e,"HttpRequestFailed",(function(){return a})),r.d(e,"HttpResponseError",(function(){return s})),r.d(e,"STATUS_CODE",(function(){return n})),r.d(e,"VERSION",(function(){return i})),function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.ALREADY_REPORTED=208]="ALREADY_REPORTED",t[t.IM_USED=226]="IM_USED",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.SWITCH_PROXY=306]="SWITCH_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.URI_TOO_LONG=414]="URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.RANGE_NOT_SATISFIABLE=416]="RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.LOOP_DETECTED=508]="LOOP_DETECTED",t[t.NOT_EXTENDED=510]="NOT_EXTENDED",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"}(n||(n={}));var i={commitHash:"672d0dd2a20104bf148e55a78550ca2abda4e652",version:"9.1.1"},o=void 0!==t&&null!=t.versions&&null!=t.versions.node?r(158).XMLHttpRequest:XMLHttpRequest,s=function(t,e,r,n,i){this.message=t,this.status=e,this.statusText=r,this.body=n,this.url=i,this.name="HttpResponse"},a=function(t,e){this.url=t,this.innerEvent=e,this.name="HttpRequestFailed",this.message="Request to "+t+" failed"},u=function(){function t(){}return t.prototype.serialize=function(t){if(!t)return"";var e=[],r=function(r){if(t.hasOwnProperty(r)&&void 0!==t[r]){var n="function"==typeof t[r].toJSON?t[r].toJSON():t[r];if(null===n)return e.push(encodeURIComponent(r)),"continue";if(Array.isArray(n))return n.forEach((function(t){e.push(encodeURIComponent(r)+"="+encodeURIComponent(t))})),"continue";e.push(encodeURIComponent(r)+"="+encodeURIComponent(n))}};for(var n in t)r(n);var i=e.join("&");return i?"?"+i:""},t.prototype.createXHR=function(){return new o},t.prototype.createRequest=function(t,e){var r=this,n=t.url,i=t.method,o=t.timeout,u=t.query,c=t.headers,l=void 0===c?{}:c,f=t.json,h=void 0===f||f,p=t.mimeType,d=void 0===p?void 0:p;return new Promise((function(t,c){var f=r.createXHR();for(var p in f.open(i||"GET",""+n+r.serialize(u)),l["Content-Type"]||f.setRequestHeader("Content-Type","application/json"),d&&f.overrideMimeType(""+d),l)f.setRequestHeader(p,l[p]);if(f.timeout=o||3e4,f.onload=function(){if(this.status>=200&&this.status<300)if(h)try{t(JSON.parse(f.response))}catch(t){c(new Error("Unable to parse response: "+f.response))}else t(f.response);else c(new s("Http error response: ("+this.status+") "+f.response,this.status,f.statusText,f.response,n))},f.ontimeout=function(){c(new Error("Request timed out after: "+f.timeout+"ms"))},f.onerror=function(t){c(new a(n,t))},e){var y=JSON.stringify(e);f.send(y)}else f.send()}))},t}()}.call(this,r(22))},function(t,e,r){"use strict";function n(t){return null!==t&&"object"==typeof t}r.d(e,"a",(function(){return n}))},function(t,e,r){"use strict";r.d(e,"a",(function(){return i}));var n=r(1);function i(t){for(;t;){var e=t,r=e.closed,i=e.destination,o=e.isStopped;if(r||o)return!1;t=i&&i instanceof n.a?i:null}return!0}},function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var n=r(3),i=r(4);function o(t,e){return new n.a((function(r){var n=new i.a,o=0;return n.add(e.schedule((function(){o!==t.length?(r.next(t[o++]),r.closed||n.add(this.schedule())):r.complete()}))),n}))}},function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var n=r(16),i=r(43),o={closed:!0,next:function(t){},error:function(t){if(n.a.useDeprecatedSynchronousErrorHandling)throw t;Object(i.a)(t)},complete:function(){}}},function(t,e,r){(e=t.exports=r(121)).Stream=e,e.Readable=e,e.Writable=r(105),e.Duplex=r(47),e.Transform=r(124),e.PassThrough=r(170)},function(t,e,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise((function(r,n){function i(){void 0!==o&&t.removeListener("error",o),r([].slice.call(arguments))}var o;"error"!==e&&(o=function(r){t.removeListener(e,i),n(r)},t.once("error",o)),t.once(e,i)}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,o,s,a;if(c(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(t))>0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function d(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=i[t];if(void 0===u)return!1;if("function"==typeof u)o(u,this,e);else{var c=u.length,l=v(u,c);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return d(this,t,!0)},a.prototype.rawListeners=function(t){return d(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},a.prototype.listenerCount=y,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,r){(function(t){function r(t){return Object.prototype.toString.call(t)}e.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===r(t)},e.isBoolean=function(t){return"boolean"==typeof t},e.isNull=function(t){return null===t},e.isNullOrUndefined=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isString=function(t){return"string"==typeof t},e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=function(t){return void 0===t},e.isRegExp=function(t){return"[object RegExp]"===r(t)},e.isObject=function(t){return"object"==typeof t&&null!==t},e.isDate=function(t){return"[object Date]"===r(t)},e.isError=function(t){return"[object Error]"===r(t)||t instanceof Error},e.isFunction=function(t){return"function"==typeof t},e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=t.isBuffer}).call(this,r(13).Buffer)},function(t,e,r){"use strict";var n=r(169).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},s=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(e,"__esModule",{value:!0}),e.WalletOperation=e.MissedBlockDuringConfirmationError=void 0;var a=r(78),u=r(57),c=r(233),l=function(){this.name="MissedBlockDuringConfirmationError",this.message="Taquito missed a block while waiting for operation confirmation and was not able to find the operation"};e.MissedBlockDuringConfirmationError=l;var f=function(){function t(t,e,r){var n=this;this.opHash=t,this.context=e,this._newHead$=r,this._operationResult=new a.ReplaySubject(1),this._includedInBlock=new a.ReplaySubject(1),this._included=!1,this.newHead$=this._newHead$.pipe(u.tap((function(t){if(!n._included&&n.lastHead&&t.header.level-n.lastHead.header.level>1)throw new l;n.lastHead=t})),u.shareReplay({bufferSize:1,refCount:!0})),this.confirmed$=this.newHead$.pipe(u.map((function(t){var e,r,i,s;try{for(var a=o(t.operations),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var l=(i=void 0,o(c)),f=l.next();!f.done;f=l.next()){var h=f.value;if(h.hash===n.opHash)return n._included=!0,n._includedInBlock.next(t),n._operationResult.next(h.contents),t}}catch(t){i={error:t}}finally{try{f&&!f.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}})),u.filter((function(t){return void 0!==t})),u.first(),u.shareReplay({bufferSize:1,refCount:!0})),this.confirmed$.pipe(u.first()).subscribe()}return t.prototype.operationResults=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this._operationResult.pipe(u.first()).toPromise()]}))}))},t.prototype.receipt=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=c.receiptFromOperation,[4,this.operationResults()];case 1:return[2,t.apply(void 0,[e.sent()])]}}))}))},t.prototype.getCurrentConfirmation=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){return this._included?[2,a.combineLatest([this._includedInBlock,a.from(this.context.rpc.getBlock())]).pipe(u.map((function(t){var e=s(t,2),r=e[0];return e[1].header.level-r.header.level+1})),u.first()).toPromise()]:[2,0]}))}))},t.prototype.isInCurrentBranch=function(t){return void 0===t&&(t="head"),n(this,void 0,void 0,(function(){var e,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:return this._included?[4,this.context.rpc.getBlockHeader({block:t})]:[2,!0];case 1:return e=i.sent(),[4,this._includedInBlock.pipe(u.first()).toPromise()];case 2:return r=i.sent(),(n=e.level-r.header.level)<=0?[2,!0]:(o=Math.min(r.header.level+n,r.header.level+60),s=Set.bind,[4,this.context.rpc.getLiveBlocks({block:String(o)})]);case 3:return[2,(new(s.apply(Set,[void 0,i.sent()]))).has(r.hash)]}}))}))},t.prototype.confirmationObservable=function(t){var e=this;if(void 0!==t&&t<1)throw new Error("Confirmation count must be at least 1");var r=this.context.config.defaultConfirmationCount,n=void 0!==t?t:r;if(void 0===n)throw new Error("Default confirmation count can not be undefined!");return a.combineLatest([this._includedInBlock,this.newHead$]).pipe(u.distinctUntilChanged((function(t,e){var r=s(t,2)[1],n=s(e,2)[1];return r.hash===n.hash})),u.map((function(t){var r=s(t,2),i=r[0],o=r[1];return{block:o,expectedConfirmation:n,currentConfirmation:o.header.level-i.header.level+1,completed:o.header.level-i.header.level>=n-1,isInCurrentBranch:function(){return e.isInCurrentBranch(o.hash)}}})),u.takeWhile((function(t){return!t.completed}),!0))},t.prototype.confirmation=function(t){return this.confirmationObservable(t).toPromise()},t}();e.WalletOperation=f},function(t,e,r){"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ChainIds=e.DefaultLambdaAddresses=e.protocols=e.Protocols=e.DEFAULT_STORAGE_LIMIT=e.DEFAULT_FEE=e.DEFAULT_GAS_LIMIT=void 0,function(t){t[t.DELEGATION=10600]="DELEGATION",t[t.ORIGINATION=10600]="ORIGINATION",t[t.TRANSFER=10600]="TRANSFER",t[t.REVEAL=10600]="REVEAL"}(e.DEFAULT_GAS_LIMIT||(e.DEFAULT_GAS_LIMIT={})),function(t){t[t.DELEGATION=1257]="DELEGATION",t[t.ORIGINATION=1e4]="ORIGINATION",t[t.TRANSFER=1e4]="TRANSFER",t[t.REVEAL=1420]="REVEAL"}(e.DEFAULT_FEE||(e.DEFAULT_FEE={})),function(t){t[t.DELEGATION=0]="DELEGATION",t[t.ORIGINATION=257]="ORIGINATION",t[t.TRANSFER=257]="TRANSFER",t[t.REVEAL=0]="REVEAL"}(e.DEFAULT_STORAGE_LIMIT||(e.DEFAULT_STORAGE_LIMIT={})),function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i"}(n=e.Protocols||(e.Protocols={})),e.protocols={"004":[n.Pt24m4xi],"005":[n.PsBABY5H,n.PsBabyM1],"006":[n.PsCARTHA],"007":[n.PsDELPH1],"008":[n.PtEdo2Zk],"009":[n.PsFLorena]},function(t){t.MAINNET="KT1CPuTzwC7h7uLXd5WQmpMFso1HxrLBUtpE",t.CARTHAGENET="KT1VAy1o1FGiXYfD3YT7x7k5eF5HSHhmc1u6",t.DELPHINET="KT19abMFs3haqyKYwqdLjK9GbtofryZLvpiK",t.EDONET="KT1A64nVZDccAHGAsf1ZyVajXZcbiwjV3SnN",t.FLORENCENET="KT1KCe3YqGnudsiCWb5twbe2DH5T3EMdLpSE"}(e.DefaultLambdaAddresses||(e.DefaultLambdaAddresses={})),function(t){t.MAINNET="NetXdQprcVkpaWU",t.CARTHAGENET="NetXjD3HPJJjmcd",t.DELPHINET="NetXm8tYqnMWky1",t.EDONET="NetXSgo1ZT2DRUG",t.FLORENCENET="NetXxkAx4woPLyu"}(e.ChainIds||(e.ChainIds={}))},function(t,e,r){"use strict";r.r(e),r.d(e,"AddressValidationError",(function(){return I})),r.d(e,"BigMapValidationError",(function(){return E})),r.d(e,"BytesValidationError",(function(){return V})),r.d(e,"ChainIDValidationError",(function(){return ot})),r.d(e,"ContractValidationError",(function(){return M})),r.d(e,"EncodeTicketError",(function(){return at})),r.d(e,"IntValidationError",(function(){return z})),r.d(e,"KeyHashValidationError",(function(){return X})),r.d(e,"KeyValidationError",(function(){return J})),r.d(e,"ListValidationError",(function(){return U})),r.d(e,"MapTypecheckError",(function(){return b})),r.d(e,"MapValidationError",(function(){return C})),r.d(e,"MichelsonMap",(function(){return g})),r.d(e,"MutezValidationError",(function(){return F})),r.d(e,"NatValidationError",(function(){return P})),r.d(e,"ParameterSchema",(function(){return wt})),r.d(e,"Schema",(function(){return mt})),r.d(e,"SetValidationError",(function(){return nt})),r.d(e,"SignatureValidationError",(function(){return Q})),r.d(e,"UnitValue",(function(){return Et})),r.d(e,"VERSION",(function(){return _t}));var n=r(156),i=r.n(n),o=r(33),s=r.n(o),a=r(11),u=function(t,e){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function c(t,e){function r(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var l,f=function(){return(f=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function y(){for(var t=[],e=0;e0?this.val.annots[0]:String(this.idx)).replace(/(%|\:)(_Liq_entry_)?/,"")},t.prototype.hasAnnotations=function(){return Array.isArray(this.val.annots)&&this.val.annots.length},t.prototype.ExtractSignature=function(){return[[this.ExtractSchema()]]},t}(),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return c(e,t),e.prototype.compare=function(t,e){return t===e?0:t2?[t.args[0],{prim:e,args:t.args.slice(1)}]:[t.args[0],t.args[1]]}var T,A=function(t){function e(r,n,i){return t.call(this,Array.isArray(r)?{prim:e.prim,args:r}:r,n,i)||this}return c(e,t),e.prototype.args=function(){return x(this.val)},e.prototype.tokens=function(){var t=this,r=0;return this.args().map((function(n){var i=t.createToken(n,t.idx+r);return i instanceof e?r+=Object.keys(i.ExtractSchema()).length:r++,i}))},e.prototype.Encode=function(t){return{prim:"Pair",args:this.tokens().map((function(e){return e.Encode(t)}))}},e.prototype.ExtractSignature=function(){var t,e,r,n,i=this.args(),o=this.createToken(i[0],this.idx),s=1;o instanceof S&&(s=Object.keys(o.ExtractSchema()).length);var a=this.createToken(i[1],this.idx+s),u=[];try{for(var c=p(o.ExtractSignature()),l=c.next();!l.done;l=c.next()){var f=l.value;try{for(var h=(r=void 0,p(a.ExtractSignature())),d=h.next();!d.done;d=h.next()){var v=d.value;u.push(y(f,v))}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}return u},e.prototype.ToBigMapKey=function(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}},e.prototype.ToKey=function(t){return this.Execute(t)},e.prototype.EncodeObject=function(t){var r,n,i=d(this.tokens(),2),o=i[0],s=i[1];return r=o instanceof e&&!o.hasAnnotations()?t:t[o.annot()],n=s instanceof e&&!s.hasAnnotations()?t:t[s.annot()],{prim:"Pair",args:[o.EncodeObject(r),s.EncodeObject(n)]}},e.prototype.traversal=function(t,r){var n,i,o,s=this.args(),a=this.createToken(s[0],this.idx),u=1;a instanceof e&&!a.hasAnnotations()?(o=t(a),u=Object.keys(a.ExtractSchema()).length):((n={})[a.annot()]=t(a),o=n);var c,l=this.createToken(s[1],this.idx+u);return l instanceof e&&!l.hasAnnotations()?c=r(l):((i={})[l.annot()]=r(l),c=i),f(f({},o),c)},e.prototype.Execute=function(t,e){var r=x(t,"Pair");return this.traversal((function(t){return t.Execute(r[0],e)}),(function(t){return t.Execute(r[1],e)}))},e.prototype.ExtractSchema=function(){return this.traversal((function(t){return t.ExtractSchema()}),(function(t){return t.ExtractSchema()}))},e.prototype.compare=function(t,r){var n=d(this.tokens(),2),i=n[0],o=n[1],s=function(t,r){return t instanceof e&&!t.hasAnnotations()?r:r[t.annot()]};if(i instanceof _&&o instanceof _){var a=i.compare(s(i,t),s(i,r));return 0===a?o.compare(s(o,t),s(o,r)):a}throw new Error("Not a comparable pair")},e.prim="pair",e}(_),P=function(t){function e(e,r,n){var i=t.call(this,e,r,n)||this;return i.value=e,i.token=r,i.name="NatValidationError",i}return c(e,t),e}(m),R=function(t){function e(e,r,n){var i=t.call(this,e,r,n)||this;return i.val=e,i.idx=r,i.fac=n,i}return c(e,t),e.prototype.Execute=function(t){return new s.a(t[Object.keys(t)[0]])},e.prototype.Encode=function(t){var e=t.pop(),r=this.isValid(e);if(r)throw r;return{int:new s.a(e).toFixed()}},e.prototype.isValid=function(t){var e=new s.a(t);return e.isNaN()?new P(t,this,"Value is not a number: "+t):e.isNegative()?new P(t,this,"Value cannot be negative: "+t):null},e.prototype.EncodeObject=function(t){var e=this.isValid(t);if(e)throw e;return{int:new s.a(t).toFixed()}},e.prototype.ExtractSchema=function(){return e.prim},e.prototype.ToBigMapKey=function(t){return{key:{int:String(t)},type:{prim:e.prim}}},e.prototype.ToKey=function(t){return t.int},e.prototype.compare=function(t,e){var r=Number(t),n=Number(e);return r===n?0:r2?f(f({},t),{args:[t.args[0],{prim:e,args:null===(n=t.args)||void 0===n?void 0:n.slice(1)}]}):t}function gt(t,e){var r=bt(t),n=bt(e);return r.prim===n.prim&&(void 0===r.args&&void 0===n.args||void 0!==r.args&&void 0!==n.args&&r.args.length===n.args.length&&r.args.every((function(t,e){var r;return gt(t,null===(r=n.args)||void 0===r?void 0:r[e])})))&&(void 0===r.annots&&void 0===n.annots||void 0!==r.annots&&void 0!==n.annots&&r.annots.length===n.annots.length&&r.annots.every((function(t,e){var r;return t===(null===(r=n.annots)||void 0===r?void 0:r[e])})))}var mt=function(){function t(t){if(this[T]=!0,this.root=yt(t,0),this.root instanceof O)this.bigMap=this.root;else if(this.isExpressionExtended(t)&&"pair"===t.prim){var e=t.args[0];this.isExpressionExtended(e)&&"big_map"===e.prim&&(this.bigMap=new O(e,0,yt))}}return t.isSchema=function(t){return t&&!0===t[vt]},t.fromRPCResponse=function(e){var r=e&&e.script&&Array.isArray(e.script.code)&&e.script.code.find((function(t){return"storage"===t.prim}));if(!r||!Array.isArray(r.args))throw new Error("Invalid rpc response passed as arguments");return new t(r.args[0])},t.prototype.isExpressionExtended=function(t){return"prim"in t&&Array.isArray(t.args)},t.prototype.removeTopLevelAnnotation=function(t){return(this.root instanceof A||this.root instanceof S)&&this.root.hasAnnotations()&&"object"==typeof t&&1===Object.keys(t).length?t[Object.keys(t)[0]]:t},t.prototype.Execute=function(t,e){var r=this.root.Execute(t,e);return this.removeTopLevelAnnotation(r)},t.prototype.Typecheck=function(t){if(this.root instanceof O&&Number.isInteger(Number(t)))return!0;try{return this.root.EncodeObject(t),!0}catch(t){return!1}},t.prototype.ExecuteOnBigMapDiff=function(t,e){if(!this.bigMap)throw new Error("No big map schema");if(!Array.isArray(t))throw new Error("Invalid big map diff. It must be an array");var r=t.map((function(t){return{args:[t.key,t.value]}}));return this.bigMap.Execute(r,e)},t.prototype.ExecuteOnBigMapValue=function(t,e){if(!this.bigMap)throw new Error("No big map schema");return this.bigMap.ValueSchema.Execute(t,e)},t.prototype.EncodeBigMapKey=function(t){if(!this.bigMap)throw new Error("No big map schema");try{return this.bigMap.KeySchema.ToBigMapKey(t)}catch(t){throw new Error("Unable to encode big map key: "+t)}},t.prototype.Encode=function(t){try{return this.root.EncodeObject(t)}catch(t){if(t instanceof m)throw t;throw new Error("Unable to encode storage object. "+t)}},t.prototype.ExtractSchema=function(){return this.removeTopLevelAnnotation(this.root.ExtractSchema())},t.prototype.ComputeState=function(t,e){var r,n=this;if(!this.bigMap)throw new Error("No big map schema");var i=t.reduce((function(t,e){return f(f({},t),n.ExecuteOnBigMapDiff(e.contents[0].metadata.operation_result.big_map_diff))}),{});return f(f({},this.Execute(e)),((r={})[this.bigMap.annot()]=i,r))},t.prototype.FindFirstInTopLevelPair=function(t,e){return this.findValue(this.root.val,t,e)},t.prototype.findValue=function(t,e,r){if(gt(r,t))return e;if(Array.isArray(t)||"pair"===t.prim){var n=bt(t),i=bt(e,"Pair");if(void 0===n.args||void 0===i.args)throw new Error("Tokens have no arguments");return this.findValue(n.args[0],i.args[0],r)||this.findValue(n.args[1],i.args[1],r)}},t}();T=vt;var wt=function(){function t(t){this.root=yt(t,0)}return t.fromRPCResponse=function(e){var r=e&&e.script&&Array.isArray(e.script.code)&&e.script.code.find((function(t){return"parameter"===t.prim}));if(!r||!Array.isArray(r.args))throw new Error("Invalid rpc response passed as arguments");return new t(r.args[0])},Object.defineProperty(t.prototype,"isMultipleEntryPoint",{get:function(){return this.root instanceof S||this.root instanceof G&&this.root.subToken()instanceof S},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasAnnotation",{get:function(){return!this.isMultipleEntryPoint||"0"!==Object.keys(this.ExtractSchema())[0]},enumerable:!1,configurable:!0}),t.prototype.Execute=function(t,e){return this.root.Execute(t,e)},t.prototype.Encode=function(){for(var t=[],e=0;e0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,r,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);0===e.actions.length&&(cancelAnimationFrame(r),e.scheduled=void 0)},e}(y.a),b=r(37),g=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return d.a(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,n=-1,i=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++ne.index?1:-1:t.delay>e.delay?1:-1},e}(y.a),E=r(80),O=r(4),S=r(1),x=r(21),T=r(49),A=r(24),P=r(18);function R(t){return!!t&&(t instanceof n.a||"function"==typeof t.lift&&"function"==typeof t.subscribe)}var k=r(31),I=r(34),N=r(29),C=r(52),j=r(93),L=r(8),M=r(67),D=r(7),U=r(9);function B(t,e,r){if(e){if(!Object(U.a)(e))return function(){for(var n=[],i=0;i1?n.next(Array.prototype.slice.call(arguments)):n.next(t)}),n,r)}))}function rt(t,e,r,n,i){var o;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var s=t;t.addEventListener(e,r,i),o=function(){return s.removeEventListener(e,r,i)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,r),o=function(){return a.off(e,r)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var u=t;t.addListener(e,r),o=function(){return u.removeListener(e,r)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var c=0,l=t.length;c=e){n.complete();break}if(n.next(o++),n.closed)break}}))}function Ot(t){var e=t.start,r=t.index,n=t.count,i=t.subscriber;r>=n?i.complete():(i.next(e),i.closed||(t.index=r+1,t.start=e+1,this.schedule(t)))}var St=r(60),xt=r(97);function Tt(t,e){return new n.a((function(r){var n,i;try{n=t()}catch(t){return void r.error(t)}try{i=e(n)}catch(t){return void r.error(t)}var o=(i?Object(X.a)(i):J.a).subscribe(r);return function(){o.unsubscribe(),n&&n.unsubscribe()}}))}var At=r(64),Pt=r(98),Rt=r(16)},function(t,e,r){"use strict";r.d(e,"b",(function(){return o})),r.d(e,"a",(function(){return s}));var n=r(0),i=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return n.a(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):e.flush(this)},e}(r(39).a),o=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n.a(e,t),e}(r(37).a))(i),s=o},function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));var n=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=function(){return Date.now()},t}()},function(t,e,r){"use strict";(function(e){void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,n)}));case 4:return e.nextTick((function(){t.call(null,r,n,i)}));default:for(o=new Array(a-1),s=0;s0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},u=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},c=this&&this.__spread||function(){for(var t=[],e=0;e0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.RPCBatchProvider=e.OperationBatch=e.BATCH_KINDS=void 0;var c=r(87),l=r(146),f=r(86),h=r(26),p=r(25);e.BATCH_KINDS=[p.OpKind.ACTIVATION,p.OpKind.ORIGINATION,p.OpKind.TRANSACTION,p.OpKind.DELEGATION];var d=function(t){function e(e,r){var n=t.call(this,e)||this;return n.estimator=r,n.operations=[],n}return i(e,t),e.prototype.withTransfer=function(t){return this.operations.push(o({kind:p.OpKind.TRANSACTION},t)),this},e.prototype.withContractCall=function(t){return this.withTransfer(t.toTransferParams())},e.prototype.withDelegation=function(t){return this.operations.push(o({kind:p.OpKind.DELEGATION},t)),this},e.prototype.withActivation=function(t){var e=t.pkh,r=t.secret;return this.operations.push({kind:p.OpKind.ACTIVATION,pkh:e,secret:r}),this},e.prototype.withOrigination=function(t){return this.operations.push(o({kind:p.OpKind.ORIGINATION},t)),this},e.prototype.getRPCOp=function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(r){switch(r.label){case 0:switch(t.kind){case p.OpKind.TRANSACTION:return[3,1];case p.OpKind.ORIGINATION:return[3,2];case p.OpKind.DELEGATION:return[3,4];case p.OpKind.ACTIVATION:return[3,5]}return[3,6];case 1:return[2,c.createTransferOperation(o({},t))];case 2:return e=c.createOriginationOperation,[4,this.context.parser.prepareCodeOrigination(o({},t))];case 3:return[2,e.apply(void 0,[r.sent()])];case 4:return[2,c.createSetDelegateOperation(o({},t))];case 5:return[2,o({},t)];case 6:throw new Error("Unsupported operation kind: "+t.kind)}}))}))},e.prototype.with=function(t){var e,r;try{for(var n=u(t),i=n.next();!i.done;i=n.next()){var o=i.value;switch(o.kind){case p.OpKind.TRANSACTION:this.withTransfer(o);break;case p.OpKind.ORIGINATION:this.withOrigination(o);break;case p.OpKind.DELEGATION:this.withDelegation(o);break;case p.OpKind.ACTIVATION:this.withActivation(o);break;default:throw new Error("Unsupported operation kind: "+o.kind)}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return this},e.prototype.send=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,f,d,y,v,b,g,m,w,_,E,O,S,x,T,A,P,R,k,I,N,C,j,L,M=this;return a(this,(function(D){switch(D.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return e=D.sent(),[4,this.signer.publicKey()];case 2:return r=D.sent(),[4,this.estimator.batch(this.operations)];case 3:return n=D.sent(),[4,this.isRevealOpNeeded(this.operations,e)];case 4:i=D.sent(),f=i?1:0,d=[],D.label=5;case 5:D.trys.push([5,13,14,15]),y=u(this.operations),v=y.next(),D.label=6;case 6:return v.done?[3,12]:(b=v.value,h.isOpWithFee(b)?[4,this.estimate(b,(function(){return s(M,void 0,void 0,(function(){return a(this,(function(t){return[2,n[f]]}))}))}))]:[3,9]);case 7:return g=D.sent(),w=(m=d).push,[4,this.getRPCOp(o(o({},b),g))];case 8:return w.apply(m,[D.sent()]),[3,10];case 9:d.push(o({},b)),D.label=10;case 10:f++,D.label=11;case 11:return v=y.next(),[3,6];case 12:return[3,15];case 13:return _=D.sent(),j={error:_},[3,15];case 14:try{v&&!v.done&&(L=y.return)&&L.call(y)}finally{if(j)throw j.error}return[7];case 15:return i?(E={kind:p.OpKind.REVEAL},[4,this.estimate(E,(function(){return s(M,void 0,void 0,(function(){return a(this,(function(t){return[2,n[0]]}))}))}))]):[3,18];case 16:return O=D.sent(),x=(S=d).unshift,[4,c.createRevealOperation(o({},O),e,r)];case 17:x.apply(S,[D.sent()]),D.label=18;case 18:return T=t&&t.source||e,[4,this.prepareOperation({operation:d,source:T})];case 19:return A=D.sent(),[4,this.forge(A)];case 20:return P=D.sent(),[4,this.signAndInject(P)];case 21:return R=D.sent(),k=R.hash,I=R.context,N=R.forgedBytes,C=R.opResponse,[2,new l.BatchOperation(k,d,T,N,C,I)]}}))}))},e}(f.OperationEmitter);e.OperationBatch=d;var y=function(){function t(t,e){this.context=t,this.estimator=e}return t.prototype.batch=function(t){var e=new d(this.context,this.estimator);return Array.isArray(t)&&e.with(t),e},t}();e.RPCBatchProvider=y},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(268),e),i(r(74),e),i(r(133),e),i(r(132),e),i(r(131),e),i(r(273),e),i(r(274),e)},function(t,e,r){"use strict";r.d(e,"a",(function(){return c})),r.d(e,"b",(function(){return l}));var n=r(0),i=r(5),o=r(3),s=r(1),a=r(4),u=r(58),c=function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._refCount=0,n._isComplete=!1,n}return n.a(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a.a).add(this.source.subscribe(new f(this.getSubject(),this))),t.closed&&(this._connection=null,t=a.a.EMPTY)),t},e.prototype.refCount=function(){return Object(u.a)()(this)},e}(o.a),l=function(){var t=c.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),f=function(t){function e(e,r){var n=t.call(this,e)||this;return n.connectable=r,n}return n.a(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(i.b);s.a},function(t,e,r){"use strict";r.d(e,"a",(function(){return s}));var n=r(0),i=r(5),o=r(29),s=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return n.a(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new o.a;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(i.a)},function(t,e,r){"use strict";r.d(e,"b",(function(){return s})),r.d(e,"a",(function(){return u}));var n=r(0),i=r(1),o=r(21);function s(t,e){return void 0===e&&(e=0),function(r){return r.lift(new a(t,e))}}var a=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.scheduler,this.delay))},t}(),u=function(t){function e(e,r,n){void 0===n&&(n=0);var i=t.call(this,e)||this;return i.scheduler=r,i.delay=n,i}return n.a(e,t),e.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new c(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(o.a.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(o.a.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(o.a.createComplete()),this.unsubscribe()},e}(i.a),c=function(){return function(t,e){this.notification=t,this.destination=e}}()},function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));var n=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}()},function(t,e,r){"use strict";r.d(e,"a",(function(){return i}));var n=r(62);function i(){return Object(n.a)(1)}},function(t,e,r){"use strict";r.d(e,"a",(function(){return a}));var n=r(3),i=r(9),o=r(62),s=r(36);function a(){for(var t=[],e=0;e1&&"number"==typeof t[t.length-1]&&(r=t.pop())):"number"==typeof u&&(r=t.pop()),null===a&&1===t.length&&t[0]instanceof n.a?t[0]:Object(o.a)(r)(Object(s.a)(t,a))}},function(t,e,r){"use strict";r.d(e,"a",(function(){return u}));var n=r(0),i=r(7),o=r(36),s=r(19),a=r(15);function u(){for(var t=[],e=0;e-1?n:o.nextTick;g.WritableState=b;var c=Object.create(r(72));c.inherits=r(44);var l={deprecate:r(168)},f=r(122),h=r(104).Buffer,p=i.Uint8Array||function(){};var d,y=r(123);function v(){}function b(t,e){a=a||r(47),t=t||{};var n=e instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,c=t.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===t.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=E(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||_(t,r),n?u(w,t,r,s,i):w(t,r,s,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(t){if(a=a||r(47),!(d.call(g,this)||this instanceof a))return new g(t);this._writableState=new b(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function m(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function w(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function _(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,m(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(m(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function E(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function O(t,e){t._final((function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)}))}function S(t,e){var r=E(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(O,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(g,f),b.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(b.prototype,"buffer",{get:l.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===g&&(t&&t._writableState instanceof b)}})):d=function(t){return t instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,h.isBuffer(n)||n instanceof p);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=v),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),g.prototype.destroy=y.destroy,g.prototype._undestroy=y.undestroy,g.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,r(22),r(166).setImmediate,r(17))},function(t,e,r){"use strict";var n=r(174),i=r(176);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=m,e.resolve=function(t,e){return m(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?m(t,!1,!0).resolveObject(e):e},e.format=function(t){i.isString(t)&&(t=m(t));return t instanceof o?t.format():o.prototype.format.call(t)},e.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(177);function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?C+="x":C+=N[j];if(!C.match(p)){var M=k.slice(0,A),D=k.slice(A+1),U=N.match(d);U&&(M.push(U[1]),D.unshift(U[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=M.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=n.toASCII(this.hostname));var B=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+B,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!y[E])for(A=0,I=l.length;A0)&&r.host.split("@"))&&(r.auth=R.shift(),r.host=r.hostname=R.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!O.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=O.slice(-1)[0],T=(r.host||t.host||O.length>1)&&("."===x||".."===x)||""===x,A=0,P=O.length;P>=0;P--)"."===(x=O[P])?O.splice(P,1):".."===x?(O.splice(P,1),A++):A&&(O.splice(P,1),A--);if(!_&&!E)for(;A--;A)O.unshift("..");!_||""===O[0]||O[0]&&"/"===O[0].charAt(0)||O.unshift(""),T&&"/"!==O.join("/").substr(-1)&&O.push("");var R,k=""===O[0]||O[0]&&"/"===O[0].charAt(0);S&&(r.hostname=r.host=k?"":O.length?O.shift():"",(R=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=R.shift(),r.host=r.hostname=R.shift()));return(_=_||r.host&&O.length)&&!k&&O.unshift(""),O.length?r.pathname=O.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){this.listeners={}}return t.prototype.addEventListener=function(t,e){t=t.toLowerCase(),this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e.handleEvent||e)},t.prototype.removeEventListener=function(t,e){if(t=t.toLowerCase(),this.listeners[t]){var r=this.listeners[t].indexOf(e.handleEvent||e);r<0||this.listeners[t].splice(r,1)}},t.prototype.dispatchEvent=function(t){var e=t.type.toLowerCase();if(t.target=this,this.listeners[e])for(var r=0,n=this.listeners[e];r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]t._pos){var o=r.substr(t._pos);if("x-user-defined"===t._charset){for(var s=new n(o.length),a=0;at._pos&&(t.push(new n(new Uint8Array(c.result.slice(t._pos)))),t._pos=c.result.byteLength)},c.onload=function(){t.push(null)},c.readAsArrayBuffer(r)}t._xhr.readyState===u.DONE&&"ms-stream"!==t._mode&&t.push(null)}}).call(this,r(22),r(13).Buffer,r(17))},function(t,e,r){"use strict";(function(e,n){var i=r(81);t.exports=m;var o,s=r(117);m.ReadableState=g;r(71).EventEmitter;var a=function(t,e){return t.listeners(e).length},u=r(122),c=r(104).Buffer,l=e.Uint8Array||function(){};var f=Object.create(r(72));f.inherits=r(44);var h=r(163),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var d,y=r(164),v=r(123);f.inherits(m,u);var b=["error","close","destroy","pause","resume"];function g(t,e){t=t||{};var n=e instanceof(o=o||r(47));this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,s=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new y,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=r(73).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function m(t){if(o=o||r(47),!(this instanceof m))return new m(t);this._readableState=new g(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),u.call(this)}function w(t,e,r,n,i){var o,s=t._readableState;null===e?(s.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,S(t)}(t,s)):(i||(o=function(t,e){var r;n=e,c.isBuffer(n)||n instanceof l||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(s,e)),o?t.emit("error",o):s.objectMode||e&&e.length>0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):_(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?_(t,s,e,!1):T(t,s)):_(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=E?t=E:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(x,t):x(t))}function x(t){p("emit readable"),t.emit("readable"),k(t)}function T(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(A,t,e))}function A(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=c.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function N(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function j(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):S(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},m.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(t,e){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?l:m;function c(e,n){p("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),t.removeListener("close",b),t.removeListener("finish",g),t.removeListener("drain",f),t.removeListener("error",v),t.removeListener("unpipe",c),r.removeListener("end",l),r.removeListener("end",m),r.removeListener("data",y),h=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function l(){p("onend"),t.end()}o.endEmitted?i.nextTick(u):r.once("end",u),t.on("unpipe",c);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,k(t))}}(r);t.on("drain",f);var h=!1;var d=!1;function y(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==j(o.pipes,t))&&!h&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function v(e){p("onerror",e),m(),t.removeListener("error",v),0===a(t,"error")&&t.emit("error",e)}function b(){t.removeListener("finish",g),m()}function g(){p("onfinish"),t.removeListener("close",b),m()}function m(){p("unpipe"),r.unpipe(t)}return r.on("data",y),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",v),t.once("close",b),t.once("finish",g),t.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),t},m.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},function(t,e,r){"use strict";(function(e,n){var i;t.exports=x,x.ReadableState=S;r(71).EventEmitter;var o=function(t,e){return t.listeners(e).length},s=r(137),a=r(13).Buffer,u=e.Uint8Array||function(){};var c,l=r(240);c=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(241),y=r(138),v=r(139).getHighWaterMark,b=r(54).codes,g=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,w=b.ERR_METHOD_NOT_IMPLEMENTED,_=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(14)(x,s);var E=y.errorOrDestroy,O=["error","close","destroy","pause","resume"];function S(t,e,n){i=i||r(55),t=t||{},"boolean"!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(73).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function x(t){if(i=i||r(55),!(this instanceof x))return new x(t);var e=this instanceof i;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function T(t,e,r,n,i){c("readableAddChunk",e);var o,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?k(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}(t,s);else if(i||(o=function(t,e){var r;n=e,a.isBuffer(n)||n instanceof u||"string"==typeof e||void 0===e||t.objectMode||(r=new g("chunk",["string","Buffer","Uint8Array"],e));var n;return r}(s,e)),o)E(t,o);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),n)s.endEmitted?E(t,new _):A(t,s,e,!0);else if(s.ended)E(t,new m);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):N(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,N(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=P?t=P:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,n.nextTick(I,t))}function I(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function N(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function L(t){c("readable nexttick read 0"),t.read(0)}function M(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function U(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function B(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,n.nextTick(F,e,t))}function F(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?B(this):k(this),null;if(0===(t=R(t,e))&&e.ended)return 0===e.length&&B(this),null;var n,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t0?U(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&B(this)),null!==n&&this.emit("data",n),n},x.prototype._read=function(t){E(this,new w("_read()"))},x.prototype.pipe=function(t,e){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?u:v;function a(e,n){c("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",y),t.removeListener("drain",l),t.removeListener("error",p),t.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",v),r.removeListener("data",h),f=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function u(){c("onend"),t.end()}i.endEmitted?n.nextTick(s):r.once("end",s),t.on("unpipe",a);var l=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",l);var f=!1;function h(e){c("ondata");var n=t.write(e);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!f&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function p(e){c("onerror",e),v(),t.removeListener("error",p),0===o(t,"error")&&E(t,e)}function d(){t.removeListener("finish",y),v()}function y(){c("onfinish"),t.removeListener("close",d),v()}function v(){c("unpipe"),r.unpipe(t)}return r.on("data",h),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",p),t.once("close",d),t.once("finish",y),t.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),t},x.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?k(this):i.reading||n.nextTick(L,this))),r},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&n.nextTick(j,this),r},x.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||n.nextTick(j,this),e},x.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(M,t,e))}(this,t)),t.paused=!1,this},x.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(x.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(x.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),x.prototype._write=function(t,e,r){r(new y("_write()"))},x.prototype._writev=null,x.prototype.end=function(t,e,r){var i=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,I(t,e),r&&(e.finished?n.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(x.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),x.prototype.destroy=f.destroy,x.prototype._undestroy=f.undestroy,x.prototype._destroy=function(t,e){e(t)}}).call(this,r(17),r(22))},function(t,e,r){"use strict";t.exports=l;var n=r(54).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(55);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,y=0|this._g,v=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var g=0;g<64;++g){var m=v+h(u)+c(u,d,y)+s[g]+r[g]|0,w=f(n)+l(n,i,o)|0;v=y,y=d,d=u,u=a+m|0,a=o,o=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=v+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},function(t,e,r){var n=r(14),i=r(56),o=r(27).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function u(){this.init(),this._w=a,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function v(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,u=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,O=0|this._dl,S=0|this._el,x=0|this._fl,T=0|this._gl,A=0|this._hl,P=0;P<32;P+=2)e[P]=t.readInt32BE(4*P),e[P+1]=t.readInt32BE(4*P+4);for(;P<160;P+=2){var R=e[P-30],k=e[P-30+1],I=p(R,k),N=d(k,R),C=y(R=e[P-4],k=e[P-4+1]),j=v(k,R),L=e[P-14],M=e[P-14+1],D=e[P-32],U=e[P-32+1],B=N+M|0,F=I+L+b(B,N)|0;F=(F=F+C+b(B=B+j|0,j)|0)+D+b(B=B+U|0,U)|0,e[P]=F,e[P+1]=B}for(var H=0;H<160;H+=2){F=e[H],B=e[H+1];var V=l(r,n,i),K=l(w,_,E),G=f(r,w),q=f(w,r),z=h(a,S),W=h(S,a),Y=s[H],J=s[H+1],$=c(a,u,g),X=c(S,x,T),Z=A+W|0,Q=m+z+b(Z,A)|0;Q=(Q=(Q=Q+$+b(Z=Z+X|0,X)|0)+Y+b(Z=Z+J|0,J)|0)+F+b(Z=Z+B|0,B)|0;var tt=q+K|0,et=G+V+b(tt,q)|0;m=g,A=T,g=u,T=x,u=a,x=S,a=o+Q+b(S=O+Z|0,O)|0,o=i,O=E,i=n,E=_,n=r,_=w,r=Q+et+b(w=Z+tt|0,Z)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+O|0,this._el=this._el+S|0,this._fl=this._fl+x|0,this._gl=this._gl+T|0,this._hl=this._hl+A|0,this._ah=this._ah+r+b(this._al,w)|0,this._bh=this._bh+n+b(this._bl,_)|0,this._ch=this._ch+i+b(this._cl,E)|0,this._dh=this._dh+o+b(this._dl,O)|0,this._eh=this._eh+a+b(this._el,S)|0,this._fh=this._fh+u+b(this._fl,x)|0,this._gh=this._gh+g+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,A)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},function(t,e,r){(function(e){function r(t){return(4294967296+t).toString(16).substring(1)}t.exports={normalizeInput:function(t){var r;if(t instanceof Uint8Array)r=t;else if(t instanceof e)r=new Uint8Array(t);else{if("string"!=typeof t)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(e.from(t,"utf8"))}return r},toHex:function(t){return Array.prototype.map.call(t,(function(t){return(t<16?"0":"")+t.toString(16)})).join("")},debugPrint:function(t,e,n){for(var i="\n"+t+" = ",o=0;o0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spread||function(){for(var t=[],e=0;e0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function l(){for(var t=[],e=0;e1&&"0x"===t.substr(r,2)))return[3,5];for(r+=2;r1&&"/*"===t.substr(r,2)))return[3,15];for(r+=2;r1&&"*/"===t.substr(r,2));)r++;if(r===t.length)throw new h(t,r,"Unterminated C style comment");return r+=2,e?[4,{t:f.Comment,v:t.slice(i,r),first:i,last:r}]:[3,14];case 13:a.sent(),a.label=14;case 14:return[3,18];case 15:return"("!==n&&")"!==n&&"{"!==n&&"}"!==n&&";"!==n?[3,17]:(r++,[4,{t:n,v:n,first:i,last:r}]);case 16:return a.sent(),[3,18];case 17:throw new h(t,r,"Invalid character at offset "+r+": `"+n+"'");case 18:return[3,1];case 19:return[2]}}))}var m,w=Symbol("ref_contract");!function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i"}(m||(m={}));var _=m.PsDELPH1,E=function(t){function e(r,n){var i=t.call(this,n)||this;return i.prim=r,Object.setPrototypeOf(i,e.prototype),i}return o(e,t),e}(Error);function O(t,e){var r,n;if(0===e&&void 0===t.args||(null===(r=t.args)||void 0===r?void 0:r.length)===e)return!0;throw new E(t,"macro "+t.prim+" expects "+e+" arguments, was given "+(null===(n=t.args)||void 0===n?void 0:n.length))}function S(t){if(void 0===t.annots)return!0;throw new E(t,"unexpected annotation on macro "+t.prim+": "+t.annots)}function x(t,e){if("int"in e)return!0;throw new E(t,"macro "+t.prim+" expects int argument")}function T(t,e,r,n){var i,o=0,s=0,a=[null,null];if(o===e.length)throw new E(t,"unexpected end: "+t.prim);var u,l=e[o++];switch(l){case"P":var f=T(t,e.slice(o),r.slice(s),n);i=p=f.r,o+=d=f.n,s+=y=f.an;break;case"A":s!==r.length&&(a[0]=r[s++]);break;default:throw new E(t,t.prim+": unexpected character: "+l)}if(o===e.length)throw new E(t,"unexpected end: "+t.prim);switch(l=e[o++]){case"P":var h=T(t,e.slice(o),r.slice(s),n),p=h.r,d=h.n,y=h.an;u=p.map((function(t){var e=c(t,2);return[e[0]+1,e[1]]})),o+=d,s+=y;break;case"I":s!==r.length&&(a[1]=r[s++]);break;default:throw new E(t,t.prim+": unexpected character: "+l)}return{r:n(i,u,[0,a]),n:o,an:s}}function A(t,e,r,n){var i=e[0];switch(i){case"A":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CAR",annots:["@%%"]},A(t,e.slice(1),[],n)]]},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:l(["%@","%@"],r)}]:n.a;case"D":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CDR",annots:["@%%"]},A(t,e.slice(1),[],n)]]},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:l(["%@","%@"],r)}]:n.d;default:throw new E(t,t.prim+": unexpected character: "+i)}}function P(t){var e,r,n=[],i=[];if(void 0!==t)try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;(0!==a.length&&"%"===a[0]?n:i).push(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return{fields:n,rest:i}}function R(t){var e=t.prim,r=t.annots,n=t.args;return s(s({prim:e},r&&{annots:r}),n&&{args:n})}var k=/^P[PAI]{3,}R$/,I=/^UNP[PAI]{2,}R$/,N=/^C[AD]{2,}R$/,C=/^SET_C[AD]+R$/,j=/^MAP_C[AD]+R$/,L=/^DI{2,}P$/,M=/^DU+P$/;var D=function(t){function e(r,n){var i=t.call(this,n)||this;return i.token=r,Object.setPrototypeOf(i,e.prototype),i}return o(e,t),e}(Error),U=function(t){function e(r,n){var i=t.call(this,n)||this;return i.node=r,Object.setPrototypeOf(i,e.prototype),i}return o(e,t),e}(Error),B=new D(null,"Unexpected EOF");function F(t){return t.t===f.Ident&&("@"===t.v[0]||"%"===t.v[0]||":"===t.v[0])}var H=new RegExp("^-?[0-9]+$"),V=new RegExp("^([0-9a-fA-F]{2})*$"),K=function(){function t(t){this.opt=t}return t.prototype.expand=function(t){var e,r;if(void 0===(null===(e=this.opt)||void 0===e?void 0:e.expandMacros)||(null===(r=this.opt)||void 0===r?void 0:r.expandMacros)){var i=function(t,e){var r=(null==e?void 0:e.protocol)||_;function n(t){return void 0!==t?[{prim:"RENAME",annots:t}]:[]}switch(t.prim){case"CMPEQ":case"CMPNEQ":case"CMPLT":case"CMPGT":case"CMPLE":case"CMPGE":if(O(t,0))return[{prim:"COMPARE"},R({prim:t.prim.slice(3),annots:t.annots})];break;case"IFEQ":case"IFNEQ":case"IFLT":case"IFGT":case"IFLE":case"IFGE":if(O(t,2))return[{prim:t.prim.slice(2)},R({prim:"IF",annots:t.annots,args:t.args})];break;case"IFCMPEQ":case"IFCMPNEQ":case"IFCMPLT":case"IFCMPGT":case"IFCMPLE":case"IFCMPGE":if(O(t,2))return[{prim:"COMPARE"},{prim:t.prim.slice(5)},R({prim:"IF",annots:t.annots,args:t.args})];break;case"FAIL":if(O(t,0)&&S(t))return[{prim:"UNIT"},{prim:"FAILWITH"}];break;case"ASSERT":if(O(t,0)&&S(t))return[{prim:"IF",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_EQ":case"ASSERT_NEQ":case"ASSERT_LT":case"ASSERT_GT":case"ASSERT_LE":case"ASSERT_GE":if(O(t,0)&&S(t))return[{prim:t.prim.slice(7)},{prim:"IF",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_CMPEQ":case"ASSERT_CMPNEQ":case"ASSERT_CMPLT":case"ASSERT_CMPGT":case"ASSERT_CMPLE":case"ASSERT_CMPGE":if(O(t,0)&&S(t))return[[{prim:"COMPARE"},{prim:t.prim.slice(10)}],{prim:"IF",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_NONE":if(O(t,0)&&S(t))return[{prim:"IF_NONE",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_SOME":if(O(t,0))return[{prim:"IF_NONE",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"ASSERT_LEFT":if(O(t,0))return[{prim:"IF_LEFT",args:[n(t.annots),[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_RIGHT":if(O(t,0))return[{prim:"IF_LEFT",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"IF_SOME":if(O(t,2))return[R({prim:"IF_NONE",annots:t.annots,args:[t.args[1],t.args[0]]})];break;case"IF_RIGHT":if(O(t,2))return[R({prim:"IF_LEFT",annots:t.annots,args:[t.args[1],t.args[0]]})];break;case"CAR":case"CDR":if(void 0===t.args)return t;if(O(t,1)&&x(t,t.args[0])){var i=parseInt(t.args[0].int,10);return R({prim:"GET",args:[{int:"CAR"===t.prim?String(2*i+1):String(2*i)}],annots:t.annots})}}if(k.test(t.prim)&&O(t,0)){var o=P(t.annots),s=o.fields,a=o.rest,u=T(t,t.prim.slice(1),s,(function(t,e,r){return l(t||[],e||[],[r])})).r;return u.map((function(t,e){var r=c(t,2),n=r[0],i=l(function(t,e){for(var r=t.length;r>0&&t[r-1]===e;)r--;return t.slice(0,r)}(r[1],null).map((function(t){return null===t?"%":t})),0===n&&e===u.length-1?a:[]),o=R({prim:"PAIR",annots:0!==i.length?i:void 0});return 0===n?o:{prim:"DIP",args:1===n?[[o]]:[{int:String(n)},[o]]}}))}if(I.test(t.prim))if(r===m.PtEdo2Zk||r===m.PsFLorena){if("UNPAIR"===t.prim)return t;if(O(t,0))return T(t,t.prim.slice(3),[],(function(t,e,r){return l([r],e||[],t||[])})).r.map((function(t){var e=c(t,1)[0],r=R({prim:"UNPAIR"});return 0===e?r:{prim:"DIP",args:1===e?[[r]]:[{int:String(e)},[r]]}}))}else if(O(t,0))return T(t,t.prim.slice(3),t.annots||[],(function(t,e,r){return l([r],e||[],t||[])})).r.map((function(t){var e=c(t,2),r=e[0],n=e[1],i=[{prim:"DUP"},R({prim:"CAR",annots:null!==n[0]?[n[0]]:void 0}),{prim:"DIP",args:[[R({prim:"CDR",annots:null!==n[1]?[n[1]]:void 0})]]}];return 0===r?i:{prim:"DIP",args:1===r?[[i]]:[{int:String(r)},[i]]}}));if(N.test(t.prim)&&O(t,0)){var f=l(t.prim.slice(1,t.prim.length-1));return f.map((function(e,r){var n=r===f.length-1?t.annots:void 0;switch(e){case"A":return R({prim:"CAR",annots:n});case"D":return R({prim:"CDR",annots:n});default:throw new E(t,"unexpected character: "+e)}}))}if(C.test(t.prim)&&O(t,0)){var h=P(t.annots),p=(s=h.fields,h.rest);if(s.length>1)throw new E(t,"unexpected annotation on macro "+t.prim+": "+s);var d=0!==s.length?{a:[{prim:"DUP"},{prim:"CAR",annots:s},{prim:"DROP"},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:[s[0],"%@"]}],d:[{prim:"DUP"},{prim:"CDR",annots:s},{prim:"DROP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",s[0]]}]}:{a:[{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:["%","%@"]}],d:[{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@","%"]}]};return A(t,t.prim.slice(5,t.prim.length-1),p,d)}if(j.test(t.prim)&&O(t,1)){if((s=P(t.annots).fields).length>1)throw new E(t,"unexpected annotation on macro "+t.prim+": "+s);return d={a:[{prim:"DUP"},{prim:"CDR",annots:["@%%"]},{prim:"DIP",args:[[R({prim:"CAR",annots:0!==s.length?["@"+s[0].slice(1)]:void 0}),t.args[0]]]},{prim:"SWAP"},{prim:"PAIR",annots:[0!==s.length?s[0]:"%","%@"]}],d:[{prim:"DUP"},R({prim:"CDR",annots:0!==s.length?["@"+s[0].slice(1)]:void 0}),t.args[0],{prim:"SWAP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",0!==s.length?s[0]:"%"]}]},A(t,t.prim.slice(5,t.prim.length-1),[],d)}if(L.test(t.prim)&&O(t,1)){for(i=0;"I"===t.prim[1+i];)i++;return R({prim:"DIP",args:[{int:String(i)},t.args[0]]})}if(M.test(t.prim)){for(i=0;"U"===t.prim[1+i];)i++;if(r!==m.PtEdo2Zk&&r!==m.PsFLorena){if(1===i){if(void 0===t.args)return t;O(t,1)&&x(t,t.args[0])&&(i=parseInt(t.args[0].int,10))}else O(t,0);return 1===i?[R({prim:"DUP",annots:t.annots})]:2===i?[{prim:"DIP",args:[[R({prim:"DUP",annots:t.annots})]]},{prim:"SWAP"}]:[{prim:"DIP",args:[{int:String(i-1)},[R({prim:"DUP",annots:t.annots})]]},{prim:"DIG",args:[{int:String(i)}]}]}if(1===i)return t;if(O(t,0))return R({prim:"DUP",args:[{int:String(i)}],annots:t.annots})}return t}(t,this.opt);return i!==t&&(i[n]=s(s({},t[n]||{first:0,last:0}),{macro:t})),i}return t},t.prototype.parseListExpr=function(t,e){var r,i,o,s={first:e.first,last:e.last},a="("===e.t;if(a){if((o=t.next()).done)throw B;s.last=o.value.last}else o={value:e};if(o.value.t!==f.Ident)throw new D(o.value,"not an identifier: "+o.value.v);for(var u=((r={prim:o.value.v})[n]=s,r);;){var c=t.next();if(c.done){if(a)throw B;break}if(")"===c.value.t){if(!a)throw new D(c.value,"unexpected closing bracket");s.last=c.value.last;break}if(F(c.value))u.annots=u.annots||[],u.annots.push(c.value.v),s.last=c.value.last;else{u.args=u.args||[];var l=this.parseExpr(t,c.value);s.last=(null===(i=l[n])||void 0===i?void 0:i.last)||s.last,u.args.push(l)}}return this.expand(u)},t.prototype.parseArgs=function(t,e){for(var r,i,o={first:e.first,last:e.last},s=((r={prim:e.v})[n]=o,r);;){var a=t.next();if(a.done||"}"===a.value.t||";"===a.value.t)return[s,a];if(F(a.value))o.last=a.value.last,s.annots=s.annots||[],s.annots.push(a.value.v);else{var u=this.parseExpr(t,a.value);o.last=(null===(i=u[n])||void 0===i?void 0:i.last)||o.last,s.args=s.args||[],s.args.push(u)}}},t.prototype.parseSequenceExpr=function(t,e){var r,i,o={first:e.first,last:e.last},s=[];s[n]=o;for(var a="{"===e.t,u="{"===e.t?null:{value:e};;){if(null===u&&((u=t.next()).done||(o.last=u.value.last)),u.done){if(a)throw B;return s}if("}"===u.value.t){if(a)return s;throw new D(u.value,"unexpected closing bracket")}if(u.value.t===f.Ident){var l=c(this.parseArgs(t,u.value),2),h=l[0],p=l[1];o.last=(null===(r=h[n])||void 0===r?void 0:r.last)||o.last,s.push(this.expand(h)),u=p}else{var d=this.parseExpr(t,u.value);o.last=(null===(i=d[n])||void 0===i?void 0:i.last)||o.last,s.push(d),u=null}null===u&&((u=t.next()).done||(o.last=u.value.last)),u.done||";"!==u.value.t||(u=null)}},t.prototype.parseExpr=function(t,e){var r,i,o,s;switch(e.t){case f.Ident:return this.expand(((r={prim:e.v})[n]={first:e.first,last:e.last},r));case f.Number:return(i={int:e.v})[n]={first:e.first,last:e.last},i;case f.String:return(o={string:JSON.parse(e.v)})[n]={first:e.first,last:e.last},o;case f.Bytes:return(s={bytes:e.v.slice(2)})[n]={first:e.first,last:e.last},s;case"{":return this.parseSequenceExpr(t,e);default:return this.parseListExpr(t,e)}},t.prototype.parseSequence=function(t){if("string"!=typeof t)throw new TypeError("string type was expected, got "+typeof t+" instead");var e=g(t),r=e.next();return r.done?null:this.parseSequenceExpr(e,r.value)},t.prototype.parseList=function(t){if("string"!=typeof t)throw new TypeError("string type was expected, got "+typeof t+" instead");var e=g(t),r=e.next();return r.done?null:this.parseListExpr(e,r.value)},t.prototype.parseMichelineExpression=function(t){if("string"!=typeof t)throw new TypeError("string type was expected, got "+typeof t+" instead");var e=g(t),r=e.next();return r.done?null:this.parseExpr(e,r.value)},t.prototype.parseScript=function(t){return this.parseSequence(t)},t.prototype.parseData=function(t){return this.parseList(t)},t.prototype.parseJSON=function(t){var e,r,n,i,o,s;if("object"!=typeof t)throw new TypeError("object type was expected, got "+typeof t+" instead");if(Array.isArray(t)){var a=[];try{for(var c=u(t),l=c.next();!l.done;l=c.next()){var f=l.value;if(null===f||"object"!=typeof f)throw new U(f,"unexpected sequence element: "+f);a.push(this.parseJSON(f))}}catch(t){e={error:t}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}return a}if("prim"in t){var h=t;if("string"==typeof h.prim&&(void 0===h.annots||Array.isArray(h.annots))&&(void 0===h.args||Array.isArray(h.args))){a={prim:h.prim};if(void 0!==h.annots){try{for(var p=u(h.annots),d=p.next();!d.done;d=p.next()){if("string"!=typeof(b=d.value))throw new U(b,"string expected: "+b)}}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}a.annots=h.annots}if(void 0!==h.args){a.args=[];try{for(var y=u(h.args),v=y.next();!v.done;v=y.next()){var b;if(null===(b=v.value)||"object"!=typeof b)throw new U(b,"unexpected argument: "+b);a.args.push(this.parseJSON(b))}}catch(t){o={error:t}}finally{try{v&&!v.done&&(s=y.return)&&s.call(y)}finally{if(o)throw o.error}}}return this.expand(a)}throw new U(t,"malformed prim expression: "+t)}if("string"in t){if("string"==typeof t.string)return{string:t.string};throw new U(t,"malformed string literal: "+t)}if("int"in t){if("string"==typeof t.int&&H.test(t.int))return{int:t.int};throw new U(t,"malformed int literal: "+t)}if("bytes"in t){if("string"==typeof t.bytes&&V.test(t.bytes))return{bytes:t.bytes};throw new U(t,"malformed bytes literal: "+t)}throw new U(t,"unexpected object: "+t)},t}(),G=function(){function t(t,e){void 0===e&&(e=0),this.opt=t,this.lev=e}return t.prototype.indent=function(t){var e;void 0===t&&(t=0);var r="";if(void 0!==(null===(e=this.opt)||void 0===e?void 0:e.indent))for(var n=this.lev+t;n>0;n--)r+=this.opt.indent;return r},Object.defineProperty(t.prototype,"lf",{get:function(){var t;return(null===(t=this.opt)||void 0===t?void 0:t.newline)||""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lfsp",{get:function(){var t;return(null===(t=this.opt)||void 0===t?void 0:t.newline)||" "},enumerable:!1,configurable:!0}),t.prototype.down=function(e){return new t(this.opt,this.lev+e)},t}();function q(t){return"prim"in t&&(void 0!==t.annots&&0!==t.annots.length||void 0!==t.args&&0!==t.args.length)}function z(t){var e,r;if(void 0!==t.args)try{for(var n=u(t.args),i=n.next();!i.done;i=n.next()){var o=i.value;if(Array.isArray(o)||q(o))return!0}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!1}function W(t,e,r){var i,o,s,a,c,l=null===(c=t[n])||void 0===c?void 0:c.macro;if(r&&l)return W(l,e,r);if(Array.isArray(t))return function(t,e,r){var n,i,o,s,a,c,l="{"+e.lf,f=t.length;try{for(var h=u(t),p=h.next();!p.done;p=h.next()){var d=p.value;if(l+=e.indent(1),"prim"in d){if(l+=d.prim,void 0!==d.annots)try{for(var y=(o=void 0,u(d.annots)),v=y.next();!v.done;v=y.next()){l+=" "+(w=v.value)}}catch(t){o={error:t}}finally{try{v&&!v.done&&(s=y.return)&&s.call(y)}finally{if(o)throw o.error}}if(void 0!==d.args){var b=z(d);try{for(var g=(a=void 0,u(d.args)),m=g.next();!m.done;m=g.next()){var w=m.value;l+=b?e.lfsp+e.indent(2)+W(w,e.down(2),r):" "+W(w,e,r)}}catch(t){a={error:t}}finally{try{m&&!m.done&&(c=g.return)&&c.call(g)}finally{if(a)throw a.error}}}}else l+=W(d,e.down(1),r);l+=f>1?";"+e.lfsp:e.lf,f--}}catch(t){n={error:t}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}return l+e.indent()+"}"}(t,e,r);if("string"in t)return JSON.stringify(t.string);if("int"in t)return t.int;if("bytes"in t)return"0x"+t.bytes;if(!(void 0!==t.annots&&0!==t.annots.length||void 0!==t.args&&0!==t.args.length))return t.prim;var f="("+t.prim;if(void 0!==t.annots)try{for(var h=u(t.annots),p=h.next();!p.done;p=h.next()){f+=" "+(b=p.value)}}catch(t){i={error:t}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}if(void 0!==t.args){var d=z(t);try{for(var y=u(t.args),v=y.next();!v.done;v=y.next()){var b=v.value;f+=d?e.lfsp+e.indent(1)+W(b,e.down(1),r):" "+W(b,e,r)}}catch(t){s={error:t}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(s)throw s.error}}}return f+")"}function Y(t,e,r){if(void 0===r&&(r=!1),"object"!=typeof t)throw new TypeError("object type was expected, got "+typeof t+" instead");return W(t,new G(e),r)}var J=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],$=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function X(t){var e,r,n=(t.length+9)%64,i=0===n?0:64-n;if(t.length>268435455)throw new Error("sha256: message length is too big: "+t.length);var o=t.length<<3,s=l(t,[128],new Array(i).fill(0),[0,0,0,0,o>>24&255,o>>16&255,o>>8&255,255&o]);function a(t,e){return t>>>e|t<<32-e}for(var c=l(J),f=new Array(64),h=new Array(8),p=0;p>>3,b=a(f[y-2],17)^a(f[y-2],19)^f[y-2]>>>10;f[y]=(0|b)+f[y-7]+v+f[y-16]|0,y++}for(var g=0;g<8;g++)h[g]=c[g];for(var m=0;m<64;m++){var w=a(h[0],2)^a(h[0],13)^a(h[0],22),_=a(h[4],6)^a(h[4],11)^a(h[4],25),E=h[7]+_+(h[4]&h[5]^~h[4]&h[6])+$[m]+f[m]|0,O=w+(h[0]&h[1]^h[0]&h[2]^h[1]&h[2])|0;h[7]=h[6],h[6]=h[5],h[5]=h[4],h[4]=h[3]+E|0,h[3]=h[2],h[2]=h[1],h[1]=h[0],h[0]=E+O|0}for(var S=0;S<8;S++)c[S]=c[S]+h[S]|0}var x=[];try{for(var T=u(c),A=T.next();!A.done;A=T.next()){var P=A.value;x.push(P>>24&255),x.push(P>>16&255),x.push(P>>8&255),x.push(255&P)}}catch(t){e={error:t}}finally{try{A&&!A.done&&(r=T.return)&&r.call(T)}finally{if(e)throw e.error}}return x}var Z=[0,1,2,3,4,5,6,7,8,-1,-1,-1,-1,-1,-1,-1,9,10,11,12,13,14,15,16,-1,17,18,19,20,21,-1,22,23,24,25,26,27,28,29,30,31,32,-1,-1,-1,-1,-1,-1,33,34,35,36,37,38,39,40,41,42,43,-1,44,45,46,47,48,49,50,51,52,53,54,55,56,57],Q=[0,1,2,3,4,5,6,7,8,16,17,18,19,20,21,22,23,25,26,27,28,29,31,32,33,34,35,36,37,38,39,40,41,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65,66,67,68,69,70,71,72,73];function tt(t,e){var r=t.charCodeAt(e)-49;if(r>=Z.length||-1===Z[r])throw new Error("Base58 decoding error: unexpected character at position "+e+": "+t[e]);return Z[r]}function et(t){var e=function(t){for(var e=[],r=0;r0;)e.push(0);return e.reverse()}(t);if(e.length<4)throw new Error("Base58Check decoding error: data is too short "+e.length);var r=e.slice(0,e.length-4),n=e.slice(e.length-4),i=X(X(r));if(n[0]!==i[0]||n[1]!==i[1]||n[2]!==i[2]||n[3]!==i[3])throw new Error("Base58Check decoding error: invalid checksum");return r}function rt(t){return function(t){for(var e=[],r=0;r0;)e.push(0);return e.reverse(),String.fromCharCode.apply(String,l(e.map((function(t){return Q[t]+49}))))}(l(t,X(X(t)).slice(0,4)))}var nt=function(t){function e(r,n){var i=t.call(this,n)||this;return i.val=r,Object.setPrototypeOf(i,e.prototype),i}return o(e,t),e}(Error);function it(t){return t instanceof nt}var ot=function(t){function e(r,n,i){var o=t.call(this,r,i)||this;return void 0!==n&&(o.data=n),Object.setPrototypeOf(o,e.prototype),o}return o(e,t),e}(nt),st=function(){function t(t){if(this.neg=!1,this.buf=[],void 0!==t)if("string"==typeof t)for(var e=0;e57)throw new Error("unexpected character in integer constant: "+t[e]);this.append(r-48)}}else t<0?(this.neg=!0,this.append(-t)):this.append(t)}return t.prototype.append=function(t){for(var e=0;0!==t||e=0&&this.buf[r]===t.buf[r];)r--;e=r<0?0:this.buf[r]=0}catch(t){return!1}}var ft=/^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z\.%@]*)?)$/;function ht(t,e){var r,n,i,o,s;if(Array.isArray(t))return{};if(void 0!==t.annots)try{for(var a=u(t.annots),c=a.next();!c.done;c=a.next()){var l=c.value;if(0!==l.length){if(!ft.test(l)||!(null==e?void 0:e.specialVar)&&("@%"===l||"@%%"===l)||!(null==e?void 0:e.specialFields)&&"%@"===l)throw new nt(t,t.prim+": unexpected annotation: "+l);switch(l[0]){case"%":((null==e?void 0:e.emptyFields)||l.length>1)&&(i=i||[]).push(l);break;case":":l.length>1&&(o=o||[]).push(l);break;case"@":((null==e?void 0:e.emptyVar)||l.length>1)&&(s=s||[]).push(l)}}}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return{f:i,t:o,v:s}}var pt={BlockHash:[32,[1,52]],OperationHash:[32,[5,116]],OperationListHash:[32,[133,233]],OperationListListHash:[32,[29,159,109]],ProtocolHash:[32,[2,170]],ContextHash:[32,[79,199]],ED25519PublicKeyHash:[20,[6,161,159]],SECP256K1PublicKeyHash:[20,[6,161,161]],P256PublicKeyHash:[20,[6,161,164]],ContractHash:[20,[2,90,121]],CryptoboxPublicKeyHash:[16,[153,103]],ED25519Seed:[32,[13,15,58,7]],ED25519PublicKey:[32,[13,15,37,217]],SECP256K1SecretKey:[32,[17,162,224,201]],P256SecretKey:[32,[16,81,238,189]],ED25519EncryptedSeed:[56,[7,90,60,179,41]],SECP256K1EncryptedSecretKey:[56,[9,237,241,174,150]],P256EncryptedSecretKey:[56,[9,48,57,115,171]],SECP256K1PublicKey:[33,[3,254,226,86]],P256PublicKey:[33,[3,178,139,127]],SECP256K1Scalar:[33,[38,248,136]],SECP256K1Element:[33,[5,92,0]],ED25519SecretKey:[64,[43,246,78,7]],ED25519Signature:[64,[9,245,205,134,18]],SECP256K1Signature:[64,[13,115,101,19,63]],P256Signature:[64,[54,240,44,52]],GenericSignature:[64,[4,130,43]],ChainID:[4,[87,82,0]]};function dt(t){for(var e,r,n=[],i=1;i>4&15).toString(16)+(15&t).toString(16)})).join("")}var Et={ABS:!0,ADD:!0,ADDRESS:!0,AMOUNT:!0,AND:!0,APPLY:!0,BALANCE:!0,BLAKE2B:!0,CAR:!0,CDR:!0,CHAIN_ID:!0,CHECK_SIGNATURE:!0,COMPARE:!0,CONCAT:!0,CONS:!0,EDIV:!0,EQ:!0,EXEC:!0,FAILWITH:!0,GE:!0,GET_AND_UPDATE:!0,GT:!0,HASH_KEY:!0,IMPLICIT_ACCOUNT:!0,INT:!0,ISNAT:!0,JOIN_TICKETS:!0,KECCAK:!0,LE:!0,LEVEL:!0,LSL:!0,LSR:!0,LT:!0,MEM:!0,MUL:!0,NEG:!0,NEQ:!0,NEVER:!0,NOT:!0,NOW:!0,OR:!0,PACK:!0,PAIRING_CHECK:!0,READ_TICKET:!0,SAPLING_VERIFY_UPDATE:!0,SELF:!0,SELF_ADDRESS:!0,SENDER:!0,SET_DELEGATE:!0,SHA256:!0,SHA3:!0,SHA512:!0,SIZE:!0,SLICE:!0,SOME:!0,SOURCE:!0,SPLIT_TICKET:!0,SUB:!0,SWAP:!0,TICKET:!0,TOTAL_VOTING_POWER:!0,TRANSFER_TOKENS:!0,UNIT:!0,VOTING_POWER:!0,XOR:!0,RENAME:!0},Ot=Object.assign({},Et,{CONTRACT:!0,CREATE_CONTRACT:!0,DIG:!0,DIP:!0,DROP:!0,DUG:!0,DUP:!0,EMPTY_BIG_MAP:!0,EMPTY_MAP:!0,EMPTY_SET:!0,GET:!0,IF:!0,IF_CONS:!0,IF_LEFT:!0,IF_NONE:!0,ITER:!0,LAMBDA:!0,LEFT:!0,LOOP:!0,LOOP_LEFT:!0,MAP:!0,NIL:!0,NONE:!0,PAIR:!0,PUSH:!0,RIGHT:!0,SAPLING_EMPTY_STATE:!0,UNPACK:!0,UNPAIR:!0,UPDATE:!0,CAST:!0}),St={unit:!0,never:!0,bool:!0,int:!0,nat:!0,string:!0,chain_id:!0,bytes:!0,mutez:!0,key_hash:!0,key:!0,signature:!0,timestamp:!0,address:!0},xt=Object.assign({},St,{or:!0,pair:!0,set:!0,big_map:!0,contract:!0,lambda:!0,list:!0,map:!0,operation:!0,option:!0,bls12_381_g1:!0,bls12_381_g2:!0,bls12_381_fr:!0,sapling_transaction:!0,sapling_state:!0,ticket:!0}),Tt=function(t){function e(r,n){var i=t.call(this,r,n)||this;return i.val=r,Object.setPrototypeOf(i,e.prototype),i}return o(e,t),e}(nt);function At(t){return"prim"in t}function Pt(t){if(At(t))return!0;throw new Tt(t,"prim expression expected")}function Rt(t){if(Array.isArray(t))return!0;throw new Tt(t,"sequence expression expected")}function kt(t){if(function(t){return Array.isArray(t)||"prim"in t}(t))return!0;throw new Tt(t,"prim or sequence expression expected")}function It(t){if("-"===t.int[0])throw new Tt(t,"natural number expected")}function Nt(t){if("int"in t)return!0;throw new Tt(t,"int literal expected")}function Ct(t,e){var r;if(0===e&&void 0===t.args||(null===(r=t.args)||void 0===r?void 0:r.length)===e)return!0;throw new Tt(t,e+" arguments expected")}function jt(t){var e,r,n,i;if(Array.isArray(t)){try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(!Array.isArray(a)&&!At(a))throw new Tt(t,"sequence or prim expected");jt(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return!0}if(Pt(t)){if(Object.prototype.hasOwnProperty.call(Et,t.prim))return Ct(t,0),!0;switch(t.prim){case"DROP":case"PAIR":case"UNPAIR":case"DUP":case"UPDATE":case"GET":void 0!==t.args&&Ct(t,1)&&Nt(t.args[0])&&It(t.args[0]);break;case"DIG":case"DUG":case"SAPLING_EMPTY_STATE":Ct(t,1)&&Nt(t.args[0])&&It(t.args[0]);break;case"NONE":case"LEFT":case"RIGHT":case"NIL":case"CAST":Ct(t,1)&&Ht(t.args[0]);break;case"UNPACK":Ct(t,1)&&Mt(t.args[0]);break;case"CONTRACT":Ct(t,1)&&Bt(t.args[0]);break;case"IF_NONE":case"IF_LEFT":case"IF_CONS":case"IF":Ct(t,2)&&(Rt(t.args[0])&&jt(t.args[0]),Rt(t.args[1])&&jt(t.args[1]));break;case"MAP":case"ITER":case"LOOP":case"LOOP_LEFT":Ct(t,1)&&jt(t.args[0]);break;case"CREATE_CONTRACT":Ct(t,1)&&Gt(t.args[0]);break;case"DIP":if(2===(null===(n=t.args)||void 0===n?void 0:n.length))Nt(t.args[0])&&It(t.args[0]),Rt(t.args[1])&&jt(t.args[1]);else{if(1!==(null===(i=t.args)||void 0===i?void 0:i.length))throw new Tt(t,"1 or 2 arguments expected");Rt(t.args[0])&&jt(t.args[0])}break;case"PUSH":Ct(t,2)&&(Dt(t.args[0]),Kt(t.args[1]));break;case"EMPTY_SET":Ct(t,1)&&Lt(t.args[0]);break;case"EMPTY_MAP":Ct(t,2)&&(Lt(t.args[0]),Ht(t.args[1]));break;case"EMPTY_BIG_MAP":Ct(t,2)&&(Lt(t.args[0]),Ft(t.args[1]));break;case"LAMBDA":Ct(t,3)&&(Ht(t.args[0]),Ht(t.args[1]),Rt(t.args[2])&&jt(t.args[2]));break;default:throw new Tt(t,"instruction expected")}}return!0}function Lt(t){if(kt(t))if(Array.isArray(t)||"pair"===t.prim||"or"===t.prim||"option"===t.prim)Vt(t,(function(t){return Lt(t)}));else if(!Object.prototype.hasOwnProperty.call(St,t.prim))throw new Tt(t,t.prim+": type is not comparable");return!0}function Mt(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim)throw new Tt(t,t.prim+": type can't be used inside PACK/UNPACK instructions");Vt(t,(function(t){return Mt(t)}))}return!0}function Dt(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim||"contract"===t.prim)throw new Tt(t,t.prim+": type can't be pushed");Vt(t,(function(t){return Dt(t)}))}return!0}function Ut(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim)||"operation"===t.prim||"contract"===t.prim)throw new Tt(t,t.prim+": type can't be used as part of a storage");Vt(t,(function(t){return Ut(t)}))}return!0}function Bt(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim)||"operation"===t.prim)throw new Tt(t,t.prim+": type can't be used as part of a parameter");Vt(t,(function(t){return Bt(t)}))}return!0}function Ft(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim)throw new Tt(t,t.prim+": type can't be used inside a big_map");Vt(t,(function(t){return Ft(t)}))}return!0}function Ht(t){if(kt(t)&&At(t)){if(!Object.prototype.hasOwnProperty.call(xt,t.prim))throw new Tt(t,"type expected");Vt(t,(function(t){return Ht(t)}))}return!0}function Vt(t,e){if(Array.isArray(t)||"pair"===t.prim){var r=Array.isArray(t)?t:t.args;if(void 0===r||r.length<2)throw new Tt(t,"at least 2 arguments expected");return r.forEach((function(t){kt(t)&&e(t)})),!0}switch(t.prim){case"option":case"list":Ct(t,1)&&kt(t.args[0])&&e(t.args[0]);break;case"contract":Ct(t,1)&&Bt(t.args[0]);break;case"or":Ct(t,2)&&kt(t.args[0])&&kt(t.args[1])&&(e(t.args[0]),e(t.args[1]));break;case"lambda":Ct(t,2)&&(Ht(t.args[0]),Ht(t.args[1]));break;case"set":Ct(t,1)&&Lt(t.args[0]);break;case"map":Ct(t,2)&&kt(t.args[0])&&kt(t.args[1])&&(Lt(t.args[0]),e(t.args[1]));break;case"big_map":Ct(t,2)&&kt(t.args[0])&&kt(t.args[1])&&(Lt(t.args[0]),Ft(t.args[1]),e(t.args[1]));break;case"ticket":Ct(t,1)&&kt(t.args[0])&&Lt(t.args[0]);break;case"sapling_state":case"sapling_transaction":Ct(t,1)&&Nt(t.args[0]);break;default:Ct(t,0)}return!0}function Kt(t){var e,r,n,i;if("int"in t||"string"in t||"bytes"in t)return!0;if(Array.isArray(t)){var o=0;try{for(var s=u(t),a=s.next();!a.done;a=s.next()){var c=a.value;At(c)&&"Elt"===c.prim?(Ct(c,2)&&(Kt(c.args[0]),Kt(c.args[1])),o++):Kt(c)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}if(0!==o&&o!==t.length)throw new Tt(t,"data entries and map elements can't be intermixed");return!0}if(!At(t))throw new Tt(t,"data entry expected");switch(t.prim){case"Unit":case"True":case"False":case"None":Ct(t,0);break;case"Pair":if(void 0===t.args||t.args.length<2)throw new Tt(t,"at least 2 arguments expected");try{for(var l=u(t.args),f=l.next();!f.done;f=l.next()){Kt(f.value)}}catch(t){n={error:t}}finally{try{f&&!f.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}break;case"Left":case"Right":case"Some":Ct(t,1)&&Kt(t.args[0]);break;default:if(!Object.prototype.hasOwnProperty.call(Ot,t.prim))throw new Tt(t,"data entry or instruction expected");jt(t)}return!0}function Gt(t){var e,r;if(Rt(t)){var n={};try{for(var i=u(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(Pt(s)){if("code"!==s.prim&&"parameter"!==s.prim&&"storage"!==s.prim)throw new Tt(t,"unexpected contract section: "+s.prim);if(s.prim in n)throw new Tt(t,"duplicate contract section: "+s.prim);if(n[s.prim]=!0,Ct(s,1))switch(s.prim){case"code":Rt(s.args[0])&&jt(s.args[0]);break;case"parameter":Bt(s.args[0]);break;case"storage":Ut(s.args[0])}}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}return!0}function qt(t){try{return Gt(t),!0}catch(t){return!1}}function zt(t){try{return Kt(t),!0}catch(t){return!1}}function Wt(t){try{return jt(t),!0}catch(t){return!1}}function Yt(t){try{return Ht(t),!0}catch(t){return!1}}function Jt(t){return Object.prototype.hasOwnProperty.call(Ot,t.prim)}function $t(t){var e,r;if(!Array.isArray(t))return!1;try{for(var n=u(t),i=n.next();!i.done;i=n.next()){var o=i.value;if("prim"in o){if(Jt(o))throw new nt(t,"Instruction outside of a lambda: "+JSON.stringify(t));if("Elt"===o.prim)throw new nt(t,"Elt item outside of a map literal: "+JSON.stringify(t))}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0}var Xt,Zt=["parameter","storage","code","False","Elt","Left","None","Pair","Right","Some","True","Unit","PACK","UNPACK","BLAKE2B","SHA256","SHA512","ABS","ADD","AMOUNT","AND","BALANCE","CAR","CDR","CHECK_SIGNATURE","COMPARE","CONCAT","CONS","CREATE_ACCOUNT","CREATE_CONTRACT","IMPLICIT_ACCOUNT","DIP","DROP","DUP","EDIV","EMPTY_MAP","EMPTY_SET","EQ","EXEC","FAILWITH","GE","GET","GT","HASH_KEY","IF","IF_CONS","IF_LEFT","IF_NONE","INT","LAMBDA","LE","LEFT","LOOP","LSL","LSR","LT","MAP","MEM","MUL","NEG","NEQ","NIL","NONE","NOT","NOW","OR","PAIR","PUSH","RIGHT","SIZE","SOME","SOURCE","SENDER","SELF","STEPS_TO_QUOTA","SUB","SWAP","TRANSFER_TOKENS","SET_DELEGATE","UNIT","UPDATE","XOR","ITER","LOOP_LEFT","ADDRESS","CONTRACT","ISNAT","CAST","RENAME","bool","contract","int","key","key_hash","lambda","list","map","big_map","nat","option","or","pair","set","signature","string","bytes","mutez","timestamp","unit","operation","address","SLICE","DIG","DUG","EMPTY_BIG_MAP","APPLY","chain_id","CHAIN_ID","LEVEL","SELF_ADDRESS","never","NEVER","UNPAIR","VOTING_POWER","TOTAL_VOTING_POWER","KECCAK","SHA3","PAIRING_CHECK","bls12_381_g1","bls12_381_g2","bls12_381_fr","sapling_state","sapling_transaction","SAPLING_EMPTY_STATE","SAPLING_VERIFY_UPDATE","ticket","TICKET","READ_TICKET","SPLIT_TICKET","JOIN_TICKETS","GET_AND_UPDATE"],Qt=Object.assign.apply(Object,l([{}],Zt.map((function(t,e){var r;return(r={})[t]=e,r}))));!function(t){t[t.Int=0]="Int",t[t.String=1]="String",t[t.Sequence=2]="Sequence",t[t.Prim0=3]="Prim0",t[t.Prim0Annot=4]="Prim0Annot",t[t.Prim1=5]="Prim1",t[t.Prim1Annot=6]="Prim1Annot",t[t.Prim2=7]="Prim2",t[t.Prim2Annot=8]="Prim2Annot",t[t.Prim=9]="Prim",t[t.Bytes=10]="Bytes"}(Xt||(Xt={}));var te,ee,re,ne=function(){function t(){this.buffer=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.buffer.length},enumerable:!1,configurable:!0}),t.prototype.writeBytes=function(t){var e;(e=this.buffer).push.apply(e,l(t.map((function(t){return 255&t}))))},t.prototype.writeUint8=function(t){var e=0|t;this.buffer.push(255&e)},t.prototype.writeUint16=function(t){var e=0|t;this.buffer.push(e>>8&255),this.buffer.push(255&e)},t.prototype.writeUint32=function(t){var e=0|t;this.buffer.push(e>>24&255),this.buffer.push(e>>16&255),this.buffer.push(e>>8&255),this.buffer.push(255&e)},t.prototype.writeInt8=function(t){this.writeUint8(t)},t.prototype.writeInt16=function(t){this.writeUint16(t)},t.prototype.writeInt32=function(t){this.writeUint32(t)},t}(),ie=new Error("bounds out of range"),oe=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=t.length),this.buffer=t,this.idx=e,this.cap=r}return Object.defineProperty(t.prototype,"length",{get:function(){return this.cap-this.idx},enumerable:!1,configurable:!0}),t.prototype.readBytes=function(t){if(this.cap-this.idx>>0},t.prototype.readUint16=function(){if(this.cap-this.idx<2)throw ie;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0},t.prototype.readUint32=function(){if(this.cap-this.idx<4)throw ie;return(this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0},t.prototype.readInt8=function(){if(this.cap-this.idx<1)throw ie;return this.buffer[this.idx++]<<24>>24},t.prototype.readInt16=function(){if(this.cap-this.idx<2)throw ie;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])<<16>>16},t.prototype.readInt32=function(){if(this.cap-this.idx<4)throw ie;return this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++]},t}();function se(t){var e,r=t.readUint8();switch(r){case ee.ED25519:e="ED25519PublicKeyHash";break;case ee.SECP256K1:e="SECP256K1PublicKeyHash";break;case ee.P256:e="P256PublicKeyHash";break;default:throw new Error("unknown public key hash tag: "+r)}return{type:e,hash:t.readBytes(20)}}function ae(t){var e,r=t.readUint8();switch(r){case te.Implicit:e=se(t);break;case te.Originated:e={type:"ContractHash",hash:t.readBytes(20)},t.readBytes(1);break;default:throw new Error("unknown address tag: "+r)}if(0!==t.length){var n=new TextDecoder;e.entryPoint=n.decode(new Uint8Array(t.readBytes(t.length)))}return e}function ue(t,e){var r;switch(t.type){case"ED25519PublicKeyHash":r=ee.ED25519;break;case"SECP256K1PublicKeyHash":r=ee.SECP256K1;break;case"P256PublicKeyHash":r=ee.P256;break;default:throw new Error("unexpected address type: "+t.type)}e.writeUint8(r),e.writeBytes(Array.from(t.hash))}function ce(t){var e,r,n=t.readUint8();switch(n){case re.ED25519:r="ED25519PublicKey",e=32;break;case re.SECP256K1:r="SECP256K1PublicKey",e=33;break;case re.P256:r="P256PublicKey",e=33;break;default:throw new Error("unknown public key tag: "+n)}return{type:r,publicKey:t.readBytes(e)}}function le(t,e,r){var n,i,o,s,a,l,f,h,p=c(r(t),2),d=p[0],y=p[1];if(Array.isArray(d)){var v=new ne;try{for(var b=u(d),g=b.next();!g.done;g=b.next()){var m=g.value;if((N=y.next()).done)throw new Error("REPORT ME: iterator is done");le(m,v,N.value)}}catch(t){n={error:t}}finally{try{g&&!g.done&&(i=b.return)&&i.call(b)}finally{if(n)throw n.error}}return e.writeUint8(Xt.Sequence),e.writeUint32(v.length),void e.writeBytes(v.buffer)}if("string"in d){var w=(new TextEncoder).encode(d.string);return e.writeUint8(Xt.String),e.writeUint32(w.length),void e.writeBytes(Array.from(w))}if("int"in d){e.writeUint8(Xt.Int);var _=BigInt(d.int),E=_<0;E&&(_=-_);var O=0;do{var S=0===O?BigInt(6):BigInt(7),x=_&(BigInt(1)<>=S)&&(x|=BigInt(128)),0===O&&E&&(x|=BigInt(64)),e.writeUint8(Number(x)),O++}while(_)}else{if("bytes"in d){w=function(t){for(var e=[],r=0;r=3&&e.writeUint32(0)}}function fe(t,e){function r(){return a(this,(function(t){switch(t.label){case 0:return[4,we];case 1:return t.sent(),[3,0];case 2:return[2]}}))}var n=c(e,2),i=n[0],o=n[1],s=t.readUint8();switch(s){case Xt.Int:var u=[],l=void 0;do{l=t.readInt8(),u.push(l)}while(0!=(128&l));for(var f=BigInt(0),h=!1,p=u.length-1;p>=0;p--){var d=0===p?BigInt(6):BigInt(7),y=BigInt(u[p]);f<<=d,f|=y&(BigInt(1)<0;){if((k=E.next()).done)throw new Error("REPORT ME: iterator is done");w.push(fe(S,k.value))}E=i(w),_=t}return o(w);default:if(s>9)throw new Error("Unknown tag: "+s);var x=t.readUint8();if(x>=Zt.length)throw new Error("Unknown primitive tag: "+x);var T=Zt[x],A=s-3>>1,P=(w={prim:T},r());for(_=t.copy(),O=0;O<2;O++){if(w={prim:T},A<3)for(p=0;p0;){var k;if((k=P.next()).done)throw new Error("REPORT ME: iterator is done");w.args.push(fe(S,k.value))}}P=i(w),_=t}if(1==(s-3&1)||3===A){var I=t.readUint32();if(0!==I){b=t.readBytes(I);var N=new TextDecoder;w.annots=N.decode(new Uint8Array(b)).split(" ")}}return o(w)}}!function(t){t[t.Implicit=0]="Implicit",t[t.Originated=1]="Originated"}(te||(te={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(ee||(ee={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(re||(re={}));var he=function(t){return"prim"in t&&("Left"===t.prim||"Right"===t.prim)},pe=function(t){return"prim"in t&&("Some"===t.prim||"None"===t.prim)},de=function(t){if(bt(t))return function(e){if(!gt(e))throw new ot(t,e,"pair expected: "+JSON.stringify(e));$t(e);var r=vt("pair",t);return[vt("Pair",e),function(){var t,e,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),t=u(r.args),e=t.next(),a.label=1;case 1:return e.done?[3,4]:(n=e.value,[4,de(n)]);case 2:a.sent(),a.label=3;case 3:return e=t.next(),[3,1];case 4:return[3,7];case 5:return i=a.sent(),o={error:i},[3,7];case 6:try{e&&!e.done&&(s=t.return)&&s.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()]};switch(t.prim){case"or":return function(e){if(!he(e))throw new ot(t,e,"or expected: "+JSON.stringify(e));return[e,function(){return a(this,(function(r){switch(r.label){case 0:return[4,de(t.args["Left"===e.prim?0:1])];case 1:return r.sent(),[2]}}))}()]};case"option":return function(e){if(!pe(e))throw new ot(t,e,"option expected: "+JSON.stringify(e));return[e,function(){return a(this,(function(r){switch(r.label){case 0:return"Some"!==e.prim?[3,2]:[4,de(t.args[0])];case 1:r.sent(),r.label=2;case 2:return[2]}}))}()]};case"list":case"set":return function(e){if(!Array.isArray(e))throw new ot(t,e,t.prim+" expected: "+JSON.stringify(e));return[e,function(){var r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),r=u(e),n=r.next(),a.label=1;case 1:return n.done?[3,4]:(n.value,[4,de(t.args[0])]);case 2:a.sent(),a.label=3;case 3:return n=r.next(),[3,1];case 4:return[3,7];case 5:return i=a.sent(),o={error:i},[3,7];case 6:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()]};case"map":return function(e){if(!Array.isArray(e))throw new ot(t,e,"map expected: "+JSON.stringify(e));return[e,function(){var r,n,i,o,s;return a(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,7]),r=u(e),n=r.next(),c.label=1;case 1:return n.done?[3,4]:(n.value,[4,function(e){if(!("prim"in e)||"Elt"!==e.prim)throw new ot(t,e,"map element expected: "+JSON.stringify(e));return[e,function(){var e,r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=u(t.args),r=e.next(),a.label=1;case 1:return r.done?[3,4]:(n=r.value,[4,de(n)]);case 2:a.sent(),a.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=a.sent(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()]}]);case 2:c.sent(),c.label=3;case 3:return n=r.next(),[3,1];case 4:return[3,7];case 5:return i=c.sent(),o={error:i},[3,7];case 6:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()]};case"chain_id":return function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"chain id expected: "+JSON.stringify(e));var r;if("string"in e){var n=dt(e.string,"ChainID");if(null===n)throw new ot(t,e,"chain id base58 expected: "+e.string);r={bytes:_t(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"signature":return function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"signature expected: "+JSON.stringify(e));var r;if("string"in e){var n=dt(e.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature");if(null===n)throw new ot(t,e,"signature base58 expected: "+e.string);r={bytes:_t(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"key_hash":return function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"key hash expected: "+JSON.stringify(e));var r;if("string"in e){var n=dt(e.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash");if(null===n)throw new ot(t,e,"key hash base58 expected: "+e.string);var i=new ne;ue({type:n[0],hash:n[1]},i),r={bytes:_t(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"key":return function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"public key expected: "+JSON.stringify(e));var r;if("string"in e){var n=dt(e.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey");if(null===n)throw new ot(t,e,"public key base58 expected: "+e.string);var i=new ne;!function(t,e){var r;switch(t.type){case"ED25519PublicKey":r=re.ED25519;break;case"SECP256K1PublicKey":r=re.SECP256K1;break;case"P256PublicKey":r=re.P256;break;default:throw new Error("unexpected public key type: "+t.type)}e.writeUint8(r),e.writeBytes(Array.from(t.publicKey))}({type:n[0],publicKey:n[1]},i),r={bytes:_t(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"address":return function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"address expected: "+JSON.stringify(e));var r;if("string"in e){var n=e.string.split("%"),i=dt(n[0],"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash");if(null===i)throw new ot(t,e,"address base58 expected: "+e.string);var o=new ne;!function(t,e){if("ContractHash"===t.type?(e.writeUint8(te.Originated),e.writeBytes(Array.from(t.hash)),e.writeUint8(0)):(e.writeUint8(te.Implicit),ue(t,e)),void 0!==t.entryPoint&&""!==t.entryPoint&&"default"!==t.entryPoint){var r=(new TextEncoder).encode(t.entryPoint);e.writeBytes(Array.from(r))}}({type:i[0],hash:i[1],entryPoint:n.length>1?n[1]:void 0},o),r={bytes:_t(o.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"timestamp":return function(e){if(!("string"in e)&&!("int"in e))throw new ot(t,e,"timestamp expected: "+JSON.stringify(e));var r;if("string"in e){var n=wt(e);if(null===n)throw new ot(t,e,"can't parse date: "+e.string);r={int:String(Math.floor(n.getTime()/1e3))}}else r=e;return[r,[][Symbol.iterator]()]};default:return ve}},ye=function(t){return"prim"in t&&"PUSH"===t.prim},ve=function(t){return ye(t)?(jt(t),[t,function(){return a(this,(function(e){switch(e.label){case 0:return[4,ve];case 1:return e.sent(),[4,de(t.args[0])];case 2:return e.sent(),[2]}}))}()]):[t,function(){return a(this,(function(t){switch(t.label){case 0:return[4,ve];case 1:return t.sent(),[3,0];case 2:return[2]}}))}()]};function be(t,e){var r=new ne;return r.writeUint8(5),le(t,r,void 0!==e?de(e):ve),r.buffer}function ge(t,e){return{bytes:_t(be(t,e))}}var me=function(t){if(bt(t)){var e=Array.isArray(t)?t:t.args;return[function(r){if(!gt(r))throw new ot(t,r,"pair expected: "+JSON.stringify(r));return function(){var t,r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),t=u(e),r=t.next(),a.label=1;case 1:return r.done?[3,4]:(n=r.value,[4,me(n)]);case 2:a.sent(),a.label=3;case 3:return r=t.next(),[3,1];case 4:return[3,7];case 5:return i=a.sent(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=t.return)&&s.call(t)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()},function(t){return t}]}switch(t.prim){case"or":return[function(e){if(!he(e))throw new ot(t,e,"or expected: "+JSON.stringify(e));return function(){return a(this,(function(r){switch(r.label){case 0:return[4,me(t.args["Left"===e.prim?0:1])];case 1:return r.sent(),[2]}}))}()},function(t){return t}];case"option":return[function(e){if(!pe(e))throw new ot(t,e,"option expected: "+JSON.stringify(e));return function(){return a(this,(function(r){switch(r.label){case 0:return"Some"!==e.prim?[3,2]:[4,me(t.args[0])];case 1:r.sent(),r.label=2;case 2:return[2]}}))}()},function(t){return t}];case"list":case"set":return[function(e){if(!Array.isArray(e))throw new ot(t,e,t.prim+" expected: "+JSON.stringify(e));return function(){return a(this,(function(e){switch(e.label){case 0:return[4,me(t.args[0])];case 1:return e.sent(),[3,0];case 2:return[2]}}))}()},function(t){return t}];case"map":return[function(e){if(!Array.isArray(e))throw new ot(t,e,"map expected: "+JSON.stringify(e));return function(){return a(this,(function(e){switch(e.label){case 0:return[4,[function(e){if(!("prim"in e)||"Elt"!==e.prim)throw new ot(t,e,"map element expected: "+JSON.stringify(e));return function(){var e,r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,5,6,7]),e=u(t.args),r=e.next(),a.label=1;case 1:return r.done?[3,4]:(n=r.value,[4,me(n)]);case 2:a.sent(),a.label=3;case 3:return r=e.next(),[3,1];case 4:return[3,7];case 5:return i=a.sent(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}return[7];case 7:return[2]}}))}()},function(t){return t}]];case 1:return e.sent(),[3,0];case 2:return[2]}}))}()},function(t){return t}];case"chain_id":return[function(){return[][Symbol.iterator]()},function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"chain id expected: "+JSON.stringify(e));if("string"in e)return e;var r=at(e.bytes);if(null===r)throw new ot(t,e,"can't parse bytes: "+e.bytes);return{string:yt("ChainID",r)}}];case"signature":return[function(){return[][Symbol.iterator]()},function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"signature expected: "+JSON.stringify(e));if("string"in e)return e;var r=at(e.bytes);if(null===r)throw new ot(t,e,"can't parse bytes: "+e.bytes);return{string:yt("GenericSignature",r)}}];case"key_hash":return[function(){return[][Symbol.iterator]()},function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"key hash expected: "+JSON.stringify(e));if("string"in e)return e;var r=at(e.bytes);if(null===r)throw new ot(t,e,"can't parse bytes: "+e.bytes);var n=se(new oe(new Uint8Array(r)));return{string:yt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"key":return[function(){return[][Symbol.iterator]()},function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"public key expected: "+JSON.stringify(e));if("string"in e)return e;var r=at(e.bytes);if(null===r)throw new ot(t,e,"can't parse bytes: "+e.bytes);var n=ce(new oe(new Uint8Array(r)));return{string:yt(n.type,n.publicKey)}}];case"address":return[function(){return[][Symbol.iterator]()},function(e){if(!("bytes"in e)&&!("string"in e))throw new ot(t,e,"address expected: "+JSON.stringify(e));if("string"in e)return e;var r=at(e.bytes);if(null===r)throw new ot(t,e,"can't parse bytes: "+e.bytes);var n=ae(new oe(new Uint8Array(r)));return{string:yt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"timestamp":return[function(){return[][Symbol.iterator]()},function(e){if(!("int"in e)&&!("string"in e))throw new ot(t,e,"address expected: "+JSON.stringify(e));return"string"in e?e:{string:new Date(1e3*parseInt(e.int,10)).toISOString().slice(0,19)+"Z"}}];default:return we}},we=[function(t){return ye(t)?(jt(t),function(){return a(this,(function(e){switch(e.label){case 0:return[4,we];case 1:return e.sent(),[4,me(t.args[0])];case 2:return e.sent(),[2]}}))}()):function(){return a(this,(function(t){switch(t.label){case 0:return[4,we];case 1:return t.sent(),[3,0];case 2:return[2]}}))}()},function(t){return t}];function _e(t,e){var r=new oe(t);if(5!==r.readUint8())throw new Error("incorrect packed data magic number");var n=fe(r,void 0!==e?me(e):we);if(Kt(n))return n;throw new Error}function Ee(t,e){var r=at(t.bytes);if(null===r)throw new Error("can't parse bytes: \""+t.bytes+'"');return _e(r,e)}function Oe(t){var e=at(t.bytes);if(null===e)throw new Error("can't parse bytes: \""+t.bytes+'"');return ae(new oe(new Uint8Array(e)))}function Se(t){var e=at(t.bytes);if(null===e)throw new Error("can't parse bytes: \""+t.bytes+'"');return se(new oe(new Uint8Array(e)))}function xe(t){var e=at(t.bytes);if(null===e)throw new Error("can't parse bytes: \""+t.bytes+'"');return ce(new oe(new Uint8Array(e)))}var Te=function(t){function e(r,n,i){var o=t.call(this,r,i)||this;return o.stackState=n,Object.setPrototypeOf(o,e.prototype),o}return o(e,t),e}(nt);function Ae(t){return Array.isArray(t)?"pair":t.prim}function Pe(t){return"prim"in t?t.args:t}function Re(t,e,r){if(void 0===r&&(r=!1),Ae(t)!==Ae(e))throw new ot(t,void 0,"types mismatch: "+Ae(t)+" != "+Ae(e));var n=[ht(t),ht(e)];if(n[0].t&&n[1].t&&n[0].t[0]!==n[1].t[0])throw new ot(t,void 0,Ae(t)+": type names mismatch: "+n[0].t[0]+" != "+n[1].t[0]);if(r&&n[0].f&&n[1].f&&n[0].f[0]!==n[1].f[0])throw new ot(t,void 0,Ae(t)+": field names mismatch: "+n[0].f[0]+" != "+n[1].f);if(bt(t)){var i=vt("pair",t),o=vt("pair",e);return Re(i.args[0],o.args[0],!0),void Re(i.args[1],o.args[1],!0)}switch(t.prim){case"option":case"list":case"contract":case"set":case"ticket":Re(t.args[0],e.args[0]);break;case"or":Re(t.args[0],e.args[0],!0),Re(t.args[1],e.args[1],!0);break;case"lambda":case"map":case"big_map":Re(t.args[0],e.args[0]),Re(t.args[1],e.args[1]);break;case"sapling_state":case"sapling_transaction":if(parseInt(t.args[0].int,10)!==parseInt(e.args[0].int,10))throw new ot(t,void 0,Ae(t)+": type argument mismatch: "+t.args[0].int+" != "+e.args[0].int)}}function ke(t,e){if(t.length!==e.length)throw new ot(t,void 0,"stack length mismatch: "+t.length+" != "+e.length);for(var r=0;r1)throw new ot(t,void 0,t.prim+": at most one type annotation allowed: "+t.annots);if(e){if(((null===(a=l.f)||void 0===a?void 0:a.length)||0)>1)throw new ot(t,void 0,t.prim+": at most one field annotation allowed: "+t.annots)}else if(((null===(c=l.f)||void 0===c?void 0:c.length)||0)>0)throw new ot(t,void 0,t.prim+": field annotations aren't allowed: "+t.annots)}if(bt(t)){var f=Pe(t);try{for(var h=u(f),p=h.next();!p.done;p=h.next()){Ie(p.value,!0)}}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}}else switch(t.prim){case"option":case"list":case"contract":case"set":Ie(t.args[0]);break;case"or":try{for(var d=u(t.args),y=d.next();!y.done;y=d.next()){Ie(y.value,!0)}}catch(t){i={error:t}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}break;case"lambda":case"map":case"big_map":Ie(t.args[0]),Ie(t.args[1])}}function Ne(t,e,r){if(bt(t)){if(gt(e)&>(r)){$t(e),$t(r);var n=vt("pair",t),i=vt("Pair",e),o=vt("Pair",r);return 0!==(u=Ne(n.args[0],i.args[0],o.args[0]))?u:Ne(n.args[0],i.args[1],o.args[1])}}else switch(t.prim){case"int":case"nat":case"mutez":if("int"in e&&"int"in r)return new st(e.int).cmp(new st(r.int));break;case"string":if("string"in e&&"string"in r)return(u=e.string.localeCompare(r.string))<0?-1:u>0?1:0;break;case"bytes":if("bytes"in e&&"bytes"in r){var s=at(e.bytes),a=at(r.bytes);if(null!==s&&null!==a)return ut(s,a)}break;case"bool":if("prim"in e&&"prim"in r&&("True"===e.prim||"False"===e.prim)&&("True"===r.prim||"False"===r.prim))return e.prim===r.prim?0:"False"===e.prim?-1:1;break;case"key":case"key_hash":case"address":case"signature":case"chain_id":if(("string"in e||"bytes"in e)&&("string"in r||"bytes"in r))return ut("string"in e?et(e.string):at(e.bytes)||[],"string"in r?et(r.string):at(r.bytes)||[]);break;case"timestamp":if(("string"in e||"int"in e)&&("string"in r||"int"in r)){var u;s=wt(e),a=wt(r);if(null!==s&&null!==a)return(u=s.valueOf()-a.valueOf())<0?-1:u>0?1:0}break;case"unit":if("prim"in e&&"prim"in r&&"Unit"===e.prim&&"Unit"===r.prim)return 0}throw new ot(t,void 0,Ae(t)+": not comparable values: "+JSON.stringify(e)+", "+JSON.stringify(r))}function Ce(t){var e,r;if(!Array.isArray(t))return!1;try{for(var n=u(t),i=n.next();!i.done;i=n.next()){var o=i.value;if(!(Array.isArray(o)&&Ce(o)||"prim"in o&&Jt(o)))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0}function je(t,e,r){var n,i,o,s;if(bt(e)){if(gt(t)){$t(t);var a=vt("Pair",t),c=vt("pair",e);return je(a.args[0],c.args[0],r),void je(a.args[1],c.args[1],r)}throw new ot(e,t,"pair expected: "+JSON.stringify(t))}switch(e.prim){case"int":if("int"in t&&ct(t.int))return;throw new ot(e,t,"integer value expected: "+JSON.stringify(t));case"nat":case"mutez":if("int"in t&<(t.int))return;throw new ot(e,t,"natural value expected: "+JSON.stringify(t));case"string":if("string"in t)return;throw new ot(e,t,"string value expected: "+JSON.stringify(t));case"bytes":case"bls12_381_g1":case"bls12_381_g2":if("bytes"in t&&null!==at(t.bytes))return;throw new ot(e,t,"bytes value expected: "+JSON.stringify(t));case"bool":if("prim"in t&&("True"===t.prim||"False"===t.prim))return;throw new ot(e,t,"boolean value expected: "+JSON.stringify(t));case"key_hash":if("string"in t&&null!==dt(t.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash"))return;if("bytes"in t)try{return void Se(t)}catch(t){}throw new ot(e,t,"key hash expected: "+JSON.stringify(t));case"timestamp":if(("string"in t||"int"in t)&&null!==wt(t))return;throw new ot(e,t,"timestamp expected: "+JSON.stringify(t));case"address":if("string"in t){var l=t.string,f=t.string.indexOf("%");if(f>=0&&(l=t.string.slice(0,f)),null!==dt(l,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash"))return}else if("bytes"in t)try{return void Oe(t)}catch(t){}throw new ot(e,t,"address expected: "+JSON.stringify(t));case"key":if("string"in t&&null!==dt(t.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey"))return;if("bytes"in t)try{return void xe(t)}catch(t){}throw new ot(e,t,"public key expected: "+JSON.stringify(t));case"unit":if("prim"in t&&"Unit"===t.prim)return;throw new ot(e,t,"unit value expected: "+JSON.stringify(t));case"signature":if("bytes"in t||"string"in t&&null!==dt(t.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature"))return;throw new ot(e,t,"signature expected: "+JSON.stringify(t));case"chain_id":if("bytes"in t||"string"in t)if(null!==("string"in t?et(t.string):at(t.bytes)))return;throw new ot(e,t,"chain id expected: "+JSON.stringify(t));case"operation":throw new ot(e,t,"operation type can't be represented as a literal value");case"contract":throw new ot(e,t,"contract type can't be represented as a literal value");case"option":if("prim"in t){if("None"===t.prim)return;if("Some"===t.prim)return void je(t.args[0],e.args[0],r)}throw new ot(e,t,"option expected: "+JSON.stringify(t));case"list":case"set":if($t(t)){var h=void 0;try{for(var p=u(t),d=p.next();!d.done;d=p.next()){if(je(g=d.value,e.args[0],r),"set"===e.prim)if(void 0===h)h=g;else if(Ne(e.args[0],h,g)>0)throw new ot(e,t,"set elements must be ordered: "+JSON.stringify(t))}}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}return}throw new ot(e,t,e.prim+" expected: "+JSON.stringify(t));case"or":if("prim"in t){if("Left"===t.prim)return void je(t.args[0],e.args[0],r);if("Right"===t.prim)return void je(t.args[0],e.args[1],r)}throw new ot(e,t,"union (or) expected: "+JSON.stringify(t));case"lambda":if(Ce(t)){var y=Le(t,[e.args[0]],r);if("failed"in y)throw new ot(e,t,"function is failed with error type: "+y.failed);if(1!==y.length)throw new ot(e,t,"function must return a value");return void Re(e.args[1],y[0])}throw new ot(e,t,"function expected: "+JSON.stringify(t));case"map":case"big_map":if(Array.isArray(t)){h=void 0;try{for(var v=u(t),b=v.next();!b.done;b=v.next()){var g;if(!("prim"in(g=b.value))||"Elt"!==g.prim)throw new ot(e,t,"map elements expected: "+JSON.stringify(t));if(je(g.args[0],e.args[0],r),je(g.args[1],e.args[1],r),void 0===h)h=g;else if(Ne(e.args[0],h.args[0],g.args[0])>0)throw new ot(e,t,"map elements must be ordered: "+JSON.stringify(t))}}catch(t){o={error:t}}finally{try{b&&!b.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}return}throw new ot(e,t,e.prim+" expected: "+JSON.stringify(t));case"bls12_381_fr":if("int"in t&&ct(t.int)||"bytes"in t&&null!==at(t.bytes))return;throw new ot(e,t,"BLS12-381 element expected: "+JSON.stringify(t));case"sapling_state":if(Array.isArray(t))return;throw new ot(e,t,"sapling state expected: "+JSON.stringify(t));case"ticket":return void je(t,{prim:"pair",args:[{prim:"address"},e.args[0],{prim:"nat"}]},r);default:throw new ot(e,t,"unexpected type: "+Ae(e))}}function Le(t,e,r){var n=(null==r?void 0:r.protocol)||_;if(Array.isArray(t))return function(t,e,r){var n,i,o=e,s=e,a=0;try{for(var c=u(t),l=c.next();!l.done;l=c.next()){var f=Le(l.value,s,r);if(o=f,"failed"in f)break;s=f,a++}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}if("failed"in o&&a!==t.length-1)throw new Te(t,o,"FAIL must appear in a tail position");if(void 0!==(null==r?void 0:r.traceCallback)){var h={op:t,in:e,out:o};r.traceCallback(h)}return o}(t,e,r);var i=t;function o(t){for(var r,n,o=[],s=1;s1,emptyVar:void 0!==t.v&&t.v>1})),o=function(t,r,n){if(t&&t.length>(r||0))throw new Te(i,e,i.prim+": at most "+(r||0)+" "+n+" annotations allowed")};return o(n.f,t.f,"field"),o(n.t,t.t,"type"),o(n.v,t.v,"variable"),n}function O(t,e){var r=t,n=Array.isArray(r)?{prim:"pair",args:r}:r,i=f(n),o=void 0!==e.v||void 0!==e.t||void 0!==e.f?l((null===e.v?i.v:e.v)||[],(null===e.t?i.t:e.t)||[],(null===e.f?i.f:e.f)||[]):void 0;n.annots;var a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i0?e+1:1)},U=L.map((function(t,e){var r,n=f(t);return O(t,{v:null,t:null,f:M.f&&M.f.length>e&&"%"!==M.f[e]?"%@"===M.f[e]?n.v?["%"+D((null===(r=n.v)||void 0===r?void 0:r[0])||"")]:void 0:[M.f[e]]:void 0})}));return l([O({prim:"pair",args:U},{t:M.t,v:M.v})],e.slice(G));case"UNPAIR":if((G=t.args?parseInt(t.args[0].int,10):2)<2)throw new Te(t,e,"UNPAIR "+G+" is forbidden");var B=o(0,["pair"])[0],F=E({f:2,v:2},{specialVar:!0});return l(T(B,G).map((function(t,e){return x(B,t,F,e,0===e?"car":"cdr")})),e.slice(1));case"CAR":case"CDR":var H=vt("pair",o(0,["pair"])[0]);return l([x(H,H.args["CAR"===t.prim?0:1],$=E({f:1,v:1},{specialVar:!0}),0,t.prim.toLocaleLowerCase())],e.slice(1));case"CONS":var V=o(0,null,["list"]);return p(V[0],V[1].args[0]),l([S({prim:"list",args:[V[1].args[0]]})],e.slice(2));case"SIZE":return o(0,["string","list","set","map","bytes"]),l([S({prim:"nat"})],e.slice(1));case"MEM":var K=o(0,null,["set","map","big_map"]);return d(K[0]),p(K[0],K[1].args[0]),l([S({prim:"bool"})],e.slice(2));case"GET":if(t.args){var G=parseInt(t.args[0].int,10);return l([S(A(o(0,["pair"])[0],G))],e.slice(1))}var q=o(0,null,["map","big_map"]);return d(q[0]),p(q[0],q[1].args[0]),l([S({prim:"option",args:[q[1].args[1]]})],e.slice(2));case"UPDATE":if(t.args){G=parseInt(t.args[0].int,10);var z=o(0,null,["pair"]);return l([S(P(z[1],z[0],G))],e.slice(2))}var W=o(0,null,["bool","option"]);if(d(W[0]),"bool"===W[1].prim){var Y=o(2,["set"]);return p(W[0],Y[0].args[0]),l([S({prim:"set",args:[O(W[0],{t:null})]})],e.slice(3))}var J=o(2,["map","big_map"]);return p(W[0],J[0].args[0]),"map"===J[0].prim?l([S({prim:"map",args:[O(W[0],{t:null}),O(W[1].args[0],{t:null})]})],e.slice(3)):(g(W[1].args[0]),l([S({prim:"big_map",args:[O(W[0],{t:null}),O(W[1].args[0],{t:null})]})],e.slice(3)));case"GET_AND_UPDATE":var $=E({v:2}),X=o(0,null,["option"],["map","big_map"]);d(X[0]),p(X[0],X[2].args[0]),p(X[1].args[0],X[2].args[1]);var Z=null===(u=$.v)||void 0===u?void 0:u.map((function(t){return"@"!==t?[t]:void 0}));return"map"===X[2].prim?l([O({prim:"option",args:[X[2].args[1]]},{v:null==Z?void 0:Z[0]}),O({prim:"map",args:[O(X[0],{t:null}),O(X[1].args[0],{t:null})]},{v:null==Z?void 0:Z[1]})],e.slice(3)):(g(X[1].args[0]),l([O({prim:"option",args:[X[2].args[1]]},{v:null==Z?void 0:Z[0]}),O({prim:"big_map",args:[O(X[0],{t:null}),O(X[1].args[0],{t:null})]},{v:null==Z?void 0:Z[1]})],e.slice(3)));case"EXEC":var Q=o(0,null,["lambda"]);return p(Q[0],Q[1].args[0]),l([S(Q[1].args[1])],e.slice(2));case"APPLY":var tt=o(0,null,["lambda"]);if(v(tt[0]),b(tt[0]),!bt(tt[1].args[0]))throw new Te(t,e,t.prim+": function's argument must be a pair: "+Ae(tt[1].args[0]));var et=tt[1].args[0];return p(tt[0],Pe(et)[0]),l([S({prim:"lambda",args:[Pe(et)[1],tt[1].args[1]]})],e.slice(2));case"FAILWITH":var rt=o(0,null)[0];return n!==m.PtEdo2Zk&&n!==m.PsFLorena||y(rt),{failed:rt};case"NEVER":return o(0,["never"]),{failed:{prim:"never"}};case"RENAME":return l([S(o(0,null)[0])],e.slice(1));case"CONCAT":if("list"===(W=o(0,["string","list","bytes"]))[0].prim){if("string"!==Ae(W[0].args[0])&&"bytes"!==Ae(W[0].args[0]))throw new Te(t,e,t.prim+": can't concatenate list of "+Ae(W[0].args[0])+"'s");return l([S(W[0].args[0])],e.slice(1))}J=o(1,["string","bytes"]);if(W[0].prim!==J[0].prim)throw new Te(t,e,t.prim+": can't concatenate "+W[0].prim+" with "+J[0].prim);return l([S(J[0])],e.slice(2));case"SLICE":return l([S({prim:"option",args:[o(0,["nat"],["nat"],["string","bytes"])[2]]},"@slice")],e.slice(3));case"PACK":var it=o(0,null)[0];return y(it),l([S({prim:"bytes"},"@packed")],e.slice(1));case"ADD":var ot=o(0,["nat","int","timestamp","mutez","bls12_381_g1","bls12_381_g2","bls12_381_fr"],["nat","int","timestamp","mutez","bls12_381_g1","bls12_381_g2","bls12_381_fr"]);if("nat"===ot[0].prim&&"int"===ot[1].prim||"int"===ot[0].prim&&"nat"===ot[1].prim)return l([S({prim:"int"})],e.slice(2));if("int"===ot[0].prim&&"timestamp"===ot[1].prim||"timestamp"===ot[0].prim&&"int"===ot[1].prim)return l([S({prim:"timestamp"})],e.slice(2));if(("int"===ot[0].prim||"nat"===ot[0].prim||"mutez"===ot[0].prim||"bls12_381_g1"===ot[0].prim||"bls12_381_g2"===ot[0].prim||"bls12_381_fr"===ot[0].prim)&&ot[0].prim===ot[1].prim)return l([S(ot[0])],e.slice(2));throw new Te(t,e,t.prim+": can't add "+ot[0].prim+" to "+ot[1].prim);case"SUB":var st=o(0,["nat","int","timestamp","mutez"],["nat","int","timestamp","mutez"]);if(("nat"===st[0].prim||"int"===st[0].prim)&&("nat"===st[1].prim||"int"===st[1].prim)||"timestamp"===st[0].prim&&"timestamp"===st[1].prim)return l([S({prim:"int"})],e.slice(2));if("timestamp"===st[0].prim&&"int"===st[1].prim)return l([S({prim:"timestamp"})],e.slice(2));if("mutez"===st[0].prim&&"mutez"===st[1].prim)return l([S({prim:"mutez"})],e.slice(2));throw new Te(t,e,t.prim+": can't subtract "+st[0].prim+" from "+st[1].prim);case"MUL":var at=o(0,["nat","int","mutez","bls12_381_g1","bls12_381_g2","bls12_381_fr"],["nat","int","mutez","bls12_381_g1","bls12_381_g2","bls12_381_fr"]);if("nat"===at[0].prim&&"int"===at[1].prim||"int"===at[0].prim&&"nat"===at[1].prim)return l([S({prim:"int"})],e.slice(2));if("nat"===at[0].prim&&"mutez"===at[1].prim||"mutez"===at[0].prim&&"nat"===at[1].prim)return l([S({prim:"mutez"})],e.slice(2));if(("bls12_381_g1"===at[0].prim||"bls12_381_g2"===at[0].prim||"bls12_381_fr"===at[0].prim)&&"bls12_381_fr"===at[1].prim||("nat"===at[0].prim||"int"===at[0].prim)&&at[0].prim===at[1].prim)return l([S(at[0])],e.slice(2));if(("nat"===at[0].prim||"int"===at[0].prim)&&"bls12_381_fr"===at[1].prim||("nat"===at[1].prim||"int"===at[1].prim)&&"bls12_381_fr"===at[0].prim)return l([S({prim:"bls12_381_fr"})],e.slice(2));throw new Te(t,e,t.prim+": can't multiply "+at[0].prim+" by "+at[1].prim);case"EDIV":var ut=function(t,e){return{prim:"option",args:[{prim:"pair",args:[{prim:t},{prim:e}]}]}},ct=o(0,["nat","int","mutez"],["nat","int","mutez"]);if("nat"===ct[0].prim&&"nat"===ct[1].prim)return l([S(ut("nat","nat"))],e.slice(2));if(!("nat"!==ct[0].prim&&"int"!==ct[0].prim||"nat"!==ct[1].prim&&"int"!==ct[1].prim))return l([S(ut("int","nat"))],e.slice(2));if("mutez"===ct[0].prim&&"nat"===ct[1].prim)return l([S(ut("mutez","mutez"))],e.slice(2));if("mutez"===ct[0].prim&&"mutez"===ct[1].prim)return l([S(ut("nat","mutez"))],e.slice(2));throw new Te(t,e,t.prim+": can't euclideally divide "+ct[0].prim+" by "+ct[1].prim);case"ABS":return o(0,["int"]),l([S({prim:"nat"})],e.slice(1));case"ISNAT":return o(0,["int"]),l([S({prim:"option",args:[{prim:"nat"}]})],e.slice(1));case"INT":return o(0,["nat","bls12_381_fr"]),l([S({prim:"int"})],e.slice(1));case"NEG":var lt=o(0,["nat","int","bls12_381_g1","bls12_381_g2","bls12_381_fr"])[0];return"nat"===lt.prim||"int"===lt.prim?l([S({prim:"int"})],e.slice(1)):l([S(lt)],e.slice(1));case"LSL":case"LSR":return o(0,["nat"],["nat"]),l([S({prim:"nat"})],e.slice(2));case"OR":case"XOR":var ft=o(0,["nat","bool"],["nat","bool"]);if(ft[0].prim!==ft[1].prim)throw new Te(t,e,t.prim+": both arguments must be of the same type: "+ft[0].prim+", "+ft[1].prim);return l([S(ft[1])],e.slice(2));case"AND":var ht=o(0,["nat","bool","int"],["nat","bool"]);if(("int"!==ht[0].prim||"nat"!==ht[1].prim)&&ht[0].prim!==ht[1].prim)throw new Te(t,e,t.prim+": both arguments must be of the same type: "+ht[0].prim+", "+ht[1].prim);return l([S(ht[1])],e.slice(2));case"NOT":return"bool"===o(0,["nat","bool","int"])[0].prim?l([S({prim:"bool"})],e.slice(1)):l([S({prim:"int"})],e.slice(1));case"COMPARE":var pt=o(0,null,null);return d(pt[0]),d(pt[1]),l([S({prim:"int"})],e.slice(2));case"EQ":case"NEQ":case"LT":case"GT":case"LE":case"GE":return o(0,["int"]),l([S({prim:"bool"})],e.slice(1));case"SELF":if(void 0===(null==r?void 0:r.contract))throw new Te(t,e,t.prim+": contract required");$=E({f:1,v:1});if(null===(St=Ue(r.contract,null===(c=$.f)||void 0===c?void 0:c[0])))throw new Te(t,e,t.prim+": contract has no entrypoint "+St);return l([O({prim:"contract",args:[St]},{v:$.v?$.v:["@self"]})],e);case"TRANSFER_TOKENS":var dt=o(0,null,["mutez"],["contract"]);return p(dt[0],dt[2].args[0]),l([S({prim:"operation"})],e.slice(3));case"SET_DELEGATE":var yt=o(0,["option"])[0];if("key_hash"!==Ae(yt.args[0]))throw new Te(t,e,t.prim+": key hash expected: "+Ae(yt.args[0]));return l([S({prim:"operation"})],e.slice(1));case"IMPLICIT_ACCOUNT":return o(0,["key_hash"]),l([S({prim:"contract",args:[{prim:"unit"}]})],e.slice(1));case"NOW":return l([S({prim:"timestamp"},"@now")],e);case"AMOUNT":return l([S({prim:"mutez"},"@amount")],e);case"BALANCE":return l([S({prim:"mutez"},"@balance")],e);case"CHECK_SIGNATURE":return o(0,["key"],["signature"],["bytes"]),l([S({prim:"bool"})],e.slice(3));case"BLAKE2B":case"SHA256":case"SHA512":case"KECCAK":case"SHA3":return o(0,["bytes"]),l([S({prim:"bytes"})],e.slice(1));case"HASH_KEY":return o(0,["key"]),l([S({prim:"key_hash"})],e.slice(1));case"SOURCE":return l([S({prim:"address"},"@source")],e);case"SENDER":return l([S({prim:"address"},"@sender")],e);case"ADDRESS":var gt=o(0,["contract"])[0];$=E({v:1});return l([O((i={prim:"address"},i[w]=gt,i),{v:$.v?$.v:R(f(gt),"address")})],e.slice(1));case"SELF_ADDRESS":var mt={prim:"address"};return void 0!==(null==r?void 0:r.contract)&&(mt[w]={prim:"contract",args:[Me(r.contract,"parameter").args[0]]}),l([S(mt,"@address")],e);case"CHAIN_ID":return l([S({prim:"chain_id"})],e);case"DROP":return E({}),o((G=void 0!==t.args?parseInt(t.args[0].int,10):1)-1,null),e.slice(G);case"DIG":return E({}),l([o(G=parseInt(t.args[0].int,10),null)[0]],e.slice(0,G),e.slice(G+1));case"DUG":E({});G=parseInt(t.args[0].int,10);return l(e.slice(1,G+1),[o(0,null)[0]],e.slice(G+1));case"NONE":return Ie(t.args[0]),l([O({prim:"option",args:[t.args[0]]},E({t:1,v:1}))],e);case"LEFT":case"RIGHT":var wt=o(0,null)[0],_t=($=E({f:2,t:1,v:1},{specialFields:!0}),Z=f(wt),[O(wt,{t:null,v:null,f:$.f&&$.f.length>0&&"%"!==$.f[0]?"%@"===$.f[0]?Z.v?["%"+Z.v[0].slice(1)]:void 0:$.f:void 0}),O(t.args[0],{t:null,f:$.f&&$.f.length>1&&"%"!==$.f[1]?$.f:void 0})]);return l([O({prim:"or",args:"LEFT"===t.prim?_t:[_t[1],_t[0]]},{t:$.t,v:$.v})],e.slice(1));case"NIL":return Ie(t.args[0]),l([O({prim:"list",args:[t.args[0]]},E({t:1,v:1}))],e);case"UNPACK":return o(0,["bytes"]),Ie(t.args[0]),l([S({prim:"option",args:[t.args[0]]},"@unpacked")],e.slice(1));case"CONTRACT":var Et=o(0,["address"])[0];Ie(t.args[0]);$=E({v:1,f:1});var Ot=Et[w];if(void 0!==Ot){var St;if(null===(St=Ue(Ot,null===(_=$.f)||void 0===_?void 0:_[0])))throw new Te(t,e,t.prim+": contract has no entrypoint "+St);p(St,t.args[0])}return l([O({prim:"option",args:[{prim:"contract",args:[t.args[0]]}]},{v:$.v?$.v:R(f(Et),"contract")})],e.slice(1));case"CAST":E({});var xt=o(0,null)[0];return Ie(t.args[0]),p(t.args[0],xt),l([t.args[0]],e.slice(1));case"IF_NONE":E({});var Tt=o(0,["option"])[0],At=e.slice(1);return k(Le(t.args[0],At,r),Le(t.args[1],l([O(Tt.args[0],{t:null,v:R(f(Tt),"some")})],At),r));case"IF_LEFT":E({});var Pt=o(0,["or"])[0],Rt=(Z=f(Pt),f(Pt.args[0])),kt=f(Pt.args[1]);At=e.slice(1);return k(Le(t.args[0],l([O(Pt.args[0],{t:null,v:R(Z,Rt.f?Rt.f[0].slice(1):"left")})],At),r),Le(t.args[1],l([O(Pt.args[1],{t:null,v:R(Z,kt.f?kt.f[0].slice(1):"right")})],At),r));case"IF_CONS":E({});var It=o(0,["list"])[0];Z=f(It),At=e.slice(1);return k(Le(t.args[0],l([O(It.args[0],{t:null,v:R(Z,"hd")}),O(It,{t:null,v:R(Z,"tl")})],At),r),Le(t.args[1],At,r));case"IF":E({}),o(0,["bool"]);At=e.slice(1);return k(Le(t.args[0],At,r),Le(t.args[1],At,r));case"MAP":var Nt=o(0,["list","map"])[0],Ct=(At=e.slice(1),"map"===Nt.prim?{prim:"pair",args:Nt.args}:Nt.args[0]);if("failed"in(Ut=Le(t.args[0],l([O(Ct,{t:null,v:R(f(Nt),"elt")})],At),r)))return Ut;if(Ut.length<1)throw new Te(t,e,t.prim+": function must return a value");return h(Ut.slice(1),At),"list"===Nt.prim?l([S({prim:"list",args:[Ut[0]]})],At):l([S({prim:"map",args:[Nt.args[0],Ut[0]]})],At);case"ITER":E({});var jt=o(0,["set","list","map"])[0];At=e.slice(1),Ct="map"===jt.prim?{prim:"pair",args:jt.args}:jt.args[0];return"failed"in(Ut=Le(t.args[0],l([O(Ct,{t:null,v:R(f(jt),"elt")})],At),r))?Ut:(h(Ut,At),At);case"LOOP":E({}),o(0,["bool"]);At=e.slice(1);return"failed"in(Ut=Le(t.args[0],At,r))?Ut:(h(Ut,l([{prim:"bool"}],At)),At);case"LOOP_LEFT":E({});var Lt=o(0,["or"])[0];At=e.slice(1);return"failed"in(Ut=Le(t.args[0],l([O(Lt.args[0],{t:null,v:R(f(Lt),"left")})],At),r))?Ut:(h(Ut,l([Lt],At)),l([O(Lt.args[1],{t:null,v:E({v:1}).v})],At));case"DIP":E({}),o((G=2===t.args.length?parseInt(t.args[0].int,10):1)-1,null);var Mt=e.slice(0,G);At=e.slice(G);return"failed"in(Ut=2===t.args.length?Le(t.args[1],At,r):Le(t.args[0],At,r))?Ut:l(Mt,Ut);case"CREATE_CONTRACT":$=E({v:2});var Dt=o(0,["option"],["mutez"],null);if("key_hash"!==Ae(Dt[0].args[0]))throw new Te(t,e,t.prim+": key hash expected: "+Ae(Dt[0].args[0]));return v(Dt[2])&&(Fe(t.args[0]),Re(Me(t.args[0],"storage").args[0],Dt[2])),l([O({prim:"operation"},{v:null==(Z=null===(I=$.v)||void 0===I?void 0:I.map((function(t){return"@"!==t?[t]:void 0})))?void 0:Z[0]}),O((a={prim:"address"},a[w]={prim:"contract",args:[Me(t.args[0],"parameter").args[0]]},a),{v:null==Z?void 0:Z[1]})],e.slice(3));case"PUSH":return Ie(t.args[0]),je(t.args[1],t.args[0],s(s({},r),{contract:void 0})),l([S(t.args[0])],e);case"EMPTY_SET":return Ie(t.args[0]),d(t.args[0]),l([O({prim:"set",args:t.args},E({t:1,v:1}))],e);case"EMPTY_MAP":return Ie(t.args[0]),d(t.args[0]),Ie(t.args[1]),l([O({prim:"map",args:t.args},E({t:1,v:1}))],e);case"EMPTY_BIG_MAP":return Ie(t.args[0]),d(t.args[0]),Ie(t.args[1]),g(t.args[0]),l([O({prim:"big_map",args:t.args},E({t:1,v:1}))],e);case"LAMBDA":var Ut;if(Ie(t.args[0]),Ie(t.args[1]),"failed"in(Ut=Le(t.args[2],[t.args[0]],s(s({},r),{contract:void 0}))))return Ut;if(1!==Ut.length)throw new Te(t,e,t.prim+": function must return a value");return p(t.args[1],Ut[0]),l([S({prim:"lambda",args:[t.args[0],t.args[1]]})],e);case"LEVEL":return l([S({prim:"nat"},"@level")],e);case"TOTAL_VOTING_POWER":return l([S({prim:"nat"})],e);case"VOTING_POWER":return o(0,["key_hash"]),l([S({prim:"nat"})],e.slice(1));case"TICKET":var Bt=o(0,null,["nat"])[0];return d(Bt),l([O({prim:"ticket",args:[Bt]},E({t:1,v:1}))],e.slice(2));case"JOIN_TICKETS":var Ft=vt("pair",o(0,["pair"])[0]);if("ticket"!==Ae(Ft.args[0]))throw new Te(t,e,t.prim+": ticket expected: "+Ae(Ft.args[0]));return p(Ft.args[0],Ft.args[1]),l([S({prim:"option",args:[O(Ft.args[0],{t:null})]})],e.slice(1));case"SPLIT_TICKET":var Ht=o(0,["ticket"],["pair"]);if("nat"!==Ae((Kt=vt("pair",Ht[1])).args[0]))throw new Te(t,e,t.prim+": nat expected: "+Ae(Kt.args[0]));return p(Kt.args[0],Kt.args[1]),l([S({prim:"option",args:[{prim:"pair",args:[O(Ht[0],{t:null}),O(Ht[0],{t:null})]}]})],e.slice(2));case"READ_TICKET":$=E({v:2});var Vt=o(0,["ticket"])[0];Z=null===(N=$.v)||void 0===N?void 0:N.map((function(t){return"@"!==t?[t]:void 0}));return l([O({prim:"pair",args:[{prim:"address"},O(Vt.args[0],{t:null}),{prim:"nat"}]},{v:null==Z?void 0:Z[0]}),O(Vt,{v:null==Z?void 0:Z[1],t:null})],e.slice(1));case"PAIRING_CHECK":var Kt;if(!bt(Kt=o(0,["list"])[0].args[0]))throw new Te(t,e,t.prim+": pair expected: "+Ae(Kt));var Gt=vt("pair",Kt);if("bls12_381_g1"!==Ae(Gt.args[0]))throw new Te(t,e,t.prim+": bls12_381_g1 expected: "+Ae(Gt.args[0]));if("bls12_381_g2"!==Ae(Gt.args[1]))throw new Te(t,e,t.prim+": bls12_381_g2 expected: "+Ae(Gt.args[1]));return l([S({prim:"bool"})],e.slice(1));case"SAPLING_EMPTY_STATE":return l([O({prim:"sapling_state",args:[t.args[0]]},E({v:1,t:1}))],e);case"SAPLING_VERIFY_UPDATE":var qt=o(0,["sapling_transaction"],["sapling_state"]);if(parseInt(qt[0].args[0].int,10)!==parseInt(qt[1].args[0].int,10))throw new Te(t,e,t.prim+": sapling memo size mismatch: "+qt[0].args[0].int+" != "+qt[1].args[0].int);return l([S({prim:"option",args:[{prim:"pair",args:[{prim:"int"},O(qt[1],{t:null})]}]})],e.slice(2));default:throw new nt(t,"unexpected instruction: "+t.prim)}}(i);if(void 0!==(null==r?void 0:r.traceCallback)){var N={op:i,in:e,out:I};r.traceCallback(N)}return I}function Me(t,e){var r,n;try{for(var i=u(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(s.prim===e)return s}}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}throw new nt(t,"missing contract section: "+e)}function De(t){var e,r;if(Array.isArray(t))try{for(var n=u(t),i=n.next();!i.done;i=n.next()){var o=i.value;if("prim"in o&&("parameter"===o.prim||"storage"===o.prim||"code"===o.prim))return!0}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!1}function Ue(t,e){e=e||"%default";var r=Be(t).find((function(t){return t[0]===e}));return void 0!==r?r[1]:"%default"===e?De(t)?Me(t,"parameter").args[0]:t:null}function Be(t){if(De(t)){var e=Me(t,"parameter"),r=Be(e.args[0]),n=ht(e);return n.f?l([[n.f[0],e.args[0]]],r):r}if(s=t,Array.isArray(s)||"or"===s.prim){var i=Pe(t),o=function(t){var e=ht(i[t]);if("or"===Ae(i[t])){var r=Be(i[t]);return e.f?l([[e.f[0],i[t]]],r):r}return e.f?[[e.f[0],i[t]]]:[]};return l(o(0),o(1))}var s;return[]}function Fe(t,e){var r=Me(t,"parameter").args[0];Ie(r,!0);var n=Me(t,"storage").args[0];Ie(n);var i={prim:"pair",args:[s(s({},r),{annots:["@parameter"]}),s(s({},n),{annots:["@storage"]})]},o=Me(t,"code").args[0],a=Le(o,[i],s(s({},e),{contract:t}));if("failed"in a)return a;var u={prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},n]};try{ke(a,[u])}catch(t){throw t instanceof nt?new Te(o,a,t.message):t}return a}function He(t,e,r){Ie(e),je(t,e,r||null)}function Ve(t,e,r){var n,i,o,s;try{for(var a=u(e),c=a.next();!c.done;c=a.next()){Ie(c.value)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}if(void 0!==(null==r?void 0:r.contract))try{for(var l=u(["parameter","storage"]),f=l.next();!f.done;f=l.next()){var h=f.value;Ie(Me(r.contract,h).args[0])}}catch(t){o={error:t}}finally{try{f&&!f.done&&(s=l.return)&&s.call(l)}finally{if(o)throw o.error}}return Le(t,e,r||null)}function Ke(t,e,r){var n,i,o,s;if(void 0===r&&(r=!1),Array.isArray(t)){try{for(var a=u(t),c=a.next();!c.done;c=a.next()){Ie(c.value)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}try{for(var l=u(e),f=l.next();!f.done;f=l.next()){Ie(f.value)}}catch(t){o={error:t}}finally{try{f&&!f.done&&(s=l.return)&&s.call(l)}finally{if(o)throw o.error}}}else Ie(t),Ie(e);Re(t,e,r)}function Ge(t,e){void 0===e&&(e=!1);try{return Ie(t,e),!0}catch(t){return!1}}function qe(t,e){try{return Fe(t,e)}catch(t){return null}}function ze(t,e,r){try{return He(t,e,r),!0}catch(t){return!1}}function We(t,e,r){void 0===r&&(r=!1);try{return Ke(t,e,r),!0}catch(t){return!1}}var Ye=function(){function t(t,e){this.contract=t,this.ctx=s({contract:t},e),this.output=Fe(t,this.ctx)}return t.parse=function(e,r){var n=new K(r),i="string"==typeof e?n.parseScript(e):n.parseJSON(e);if(null===i)throw new Error("empty contract");if(Gt(i))return new t(i,r)},t.parseTypeExpression=function(t,e){var r=new K(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new Error("empty type expression");if(Ht(n)&&Ie(n))return n;throw void 0},t.parseDataExpression=function(t,e){var r=new K(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new Error("empty data expression");if(Kt(n))return n;throw void 0},t.prototype.section=function(t){return Me(this.contract,t)},t.prototype.entryPoints=function(){return Be(this.contract)},t.prototype.entryPoint=function(t){return Ue(this.contract,t)},t.prototype.assertDataValid=function(t,e){He(t,e,this.ctx)},t.prototype.isDataValid=function(t,e){return ze(t,e,this.ctx)},t.prototype.assertParameterValid=function(t,e){var r=this.entryPoint(t||void 0);if(null===r)throw new Error("contract has no entrypoint named "+t);this.assertDataValid(e,r)},t.prototype.isParameterValid=function(t,e){try{return this.assertParameterValid(t,e),!0}catch(t){return!1}},t.prototype.functionType=function(t,e){return Ve(t,e,this.ctx)},t}(),Je=new Ye([{prim:"parameter",args:[{prim:"unit"}]},{prim:"storage",args:[{prim:"unit"}]},{prim:"code",args:[[{prim:"CAR"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PAIR"}]]}]);function $e(t){return"failed"in t?"[FAILED: "+Y(t.failed)+"]":t.map((function(t,e){var r=ht(t);return"["+e+(r.v?"/"+r.v[0]:"")+"]: "+Y(t)})).join("\n")}function Xe(t,e){return function(r){var i;if(!Array.isArray(r)||t){var o=null===(i=r.op[n])||void 0===i?void 0:i.macro,s=(o?"Macro":"Op")+": "+(o?Y(o,void 0,!0)+" / ":"")+Y(r.op)+"\nInput:\n"+$e(r.in)+"\nOutput:\n"+$e(r.out)+"\n";e(s)}}}function Ze(t){var e;if(t instanceof Te){var r=null===(e=t.val[n])||void 0===e?void 0:e.macro;return(r?"Macro":"Op")+": "+(r?Y(r,void 0,!0)+" / ":"")+Y(t.val)+"\nStack:\n"+$e(t.stackState)+"\n"}return t instanceof ot?"Type: "+(Array.isArray(t.val)?"["+t.val.map((function(t,e){return"["+e+"]: "+Y(t)})).join("; ")+"]":Y(t.val))+"\n"+(t.data?"Data: "+Y(t.data)+"\n":"")+"\n":"Value: "+Y(t.val)}var Qe={commitHash:"672d0dd2a20104bf148e55a78550ca2abda4e652",version:"9.1.1"}},function(t,e,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.PollingSubscribeProvider=void 0;var o=r(78),s=r(57),a=r(277),u=r(278),c=function(t){return o.from(t.rpc.getBlock()).pipe(s.first())},l=function(){function t(t,e){var r=this;void 0===e&&(e=2e4),this.context=t,this.POLL_INTERVAL=e,this.newBlock$=o.timer(0,this.POLL_INTERVAL).pipe(s.map((function(){return r.context})),s.switchMap(c),s.distinctUntilKeyChanged("hash"),s.publishReplay(),s.refCount())}return t.prototype.subscribe=function(t){return new u.ObservableSubscription(this.newBlock$.pipe(s.pluck("hash")),this.context.config.shouldObservableSubscriptionRetry,this.context.config.observableSubscriptionRetryFunction)},t.prototype.subscribeOperation=function(t){return new u.ObservableSubscription(this.newBlock$.pipe(function(t){return s.concatMap((function(e){return new o.Observable((function(r){var o,s,u,c,l,f;try{for(var h=i(e.operations),p=h.next();!p.done;p=h.next()){var d=p.value;try{for(var y=(u=void 0,i(d)),v=y.next();!v.done;v=y.next()){var b=v.value;try{for(var g=(l=void 0,i(b.contents)),m=g.next();!m.done;m=g.next()){var w=m.value;a.evaluateFilter(n({hash:b.hash},w),t)&&r.next(n({hash:b.hash},w))}}catch(t){l={error:t}}finally{try{m&&!m.done&&(f=g.return)&&f.call(g)}finally{if(l)throw l.error}}}}catch(t){u={error:t}}finally{try{v&&!v.done&&(c=y.return)&&c.call(y)}finally{if(u)throw u.error}}}}catch(t){o={error:t}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(o)throw o.error}}r.complete()}))}))}(t)),this.context.config.shouldObservableSubscriptionRetry,this.context.config.observableSubscriptionRetryFunction)},t}();e.PollingSubscribeProvider=l},function(t,e,r){"use strict";t.exports=function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var r,n="boolean"==typeof e.cycles&&e.cycles,i=e.cmp&&(r=e.cmp,function(t){return function(e,n){var i={key:e,value:t[e]},o={key:n,value:t[n]};return r(i,o)}}),o=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var r,s;if(Array.isArray(e)){for(s="[",r=0;r0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spread||function(){for(var t=[],e=0;e=0)return this._url=this._parseUrl(e.headers.location),this._method="GET",this._loweredHeaders["content-type"]&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),null!=this._headers["Content-Type"]&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest();this._response=e,this._response.on("data",(function(t){return n._onHttpResponseData(e,t)})),this._response.on("end",(function(){return n._onHttpResponseEnd(e)})),this._response.on("close",(function(){return n._onHttpResponseClose(e)})),this.responseUrl=this._url.href.split("#")[0],this.status=e.statusCode,this.statusText=a.STATUS_CODES[this.status],this._parseResponseHeaders(e);var i=this._responseHeaders["content-length"]||"";this._totalBytes=+i,this._lengthComputable=!!i,this._setReadyState(r.HEADERS_RECEIVED)}},r.prototype._onHttpResponseData=function(t,e){this._response===t&&(this._responseParts.push(new n(e)),this._loadedBytes+=e.length,this.readyState!==r.LOADING&&this._setReadyState(r.LOADING),this._dispatchProgress("progress"))},r.prototype._onHttpResponseEnd=function(t){this._response===t&&(this._parseResponse(),this._request=null,this._response=null,this._setReadyState(r.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend"))},r.prototype._onHttpResponseClose=function(t){if(this._response===t){var e=this._request;this._setError(),e.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")}},r.prototype._onHttpTimeout=function(t){this._request===t&&(this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend"))},r.prototype._onHttpRequestError=function(t,e){this._request===t&&(this._setError(),t.abort(),this._setReadyState(r.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend"))},r.prototype._dispatchProgress=function(t){var e=new r.ProgressEvent(t);e.lengthComputable=this._lengthComputable,e.loaded=this._loadedBytes,e.total=this._totalBytes,this.dispatchEvent(e)},r.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},r.prototype._parseUrl=function(t,e,r){var n=null==this.nodejsBaseUrl?t:l.resolve(this.nodejsBaseUrl,t),i=l.parse(n,!1,!0);i.hash=null;var o=(i.auth||"").split(":"),s=o[0],a=o[1];return(s||a||e||r)&&(i.auth=(e||s||"")+":"+(r||a||"")),i},r.prototype._parseResponseHeaders=function(t){for(var e in this._responseHeaders={},t.headers){var r=e.toLowerCase();this._privateHeaders[r]||(this._responseHeaders[r]=t.headers[e])}null!=this._mimeOverride&&(this._responseHeaders["content-type"]=this._mimeOverride)},r.prototype._parseResponse=function(){var t=n.concat(this._responseParts);switch(this._responseParts=null,this.responseType){case"json":this.responseText=null;try{this.response=JSON.parse(t.toString("utf-8"))}catch(t){this.response=null}return;case"buffer":return this.responseText=null,void(this.response=t);case"arraybuffer":this.responseText=null;for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),i=0;i0?s-4:s;for(r=0;r>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,u=r-i;au?u:a+s));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function l(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*y}},function(t,e,r){(function(e,n,i){var o=r(119),s=r(44),a=r(120),u=r(70),c=r(171),l=a.IncomingMessage,f=a.readyStates;var h=t.exports=function(t){var r,n=this;u.Writable.call(n),n._opts=t,n._body=[],n._headers={},t.auth&&n.setHeader("Authorization","Basic "+new e(t.auth).toString("base64")),Object.keys(t.headers).forEach((function(e){n.setHeader(e,t.headers[e])}));var i=!0;if("disable-fetch"===t.mode||"requestTimeout"in t&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===t.mode)r=!1;else if("allow-wrong-content-type"===t.mode)r=!o.overrideMimeType;else{if(t.mode&&"default"!==t.mode&&"prefer-fast"!==t.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=function(t,e){return o.fetch&&e?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&t?"arraybuffer":o.vbArray&&t?"text:vbarray":"text"}(r,i),n._fetchTimer=null,n.on("finish",(function(){n._onFinish()}))};s(h,u.Writable),h.prototype.setHeader=function(t,e){var r=t.toLowerCase();-1===p.indexOf(r)&&(this._headers[r]={name:t,value:e})},h.prototype.getHeader=function(t){var e=this._headers[t.toLowerCase()];return e?e.value:null},h.prototype.removeHeader=function(t){delete this._headers[t.toLowerCase()]},h.prototype._onFinish=function(){var t=this;if(!t._destroyed){var r=t._opts,s=t._headers,a=null;"GET"!==r.method&&"HEAD"!==r.method&&(a=o.arraybuffer?c(e.concat(t._body)):o.blobConstructor?new n.Blob(t._body.map((function(t){return c(t)})),{type:(s["content-type"]||{}).value||""}):e.concat(t._body).toString());var u=[];if(Object.keys(s).forEach((function(t){var e=s[t].name,r=s[t].value;Array.isArray(r)?r.forEach((function(t){u.push([e,t])})):u.push([e,r])})),"fetch"===t._mode){var l=null;if(o.abortController){var h=new AbortController;l=h.signal,t._fetchAbortController=h,"requestTimeout"in r&&0!==r.requestTimeout&&(t._fetchTimer=n.setTimeout((function(){t.emit("requestTimeout"),t._fetchAbortController&&t._fetchAbortController.abort()}),r.requestTimeout))}n.fetch(t._opts.url,{method:t._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:r.withCredentials?"include":"same-origin",signal:l}).then((function(e){t._fetchResponse=e,t._connect()}),(function(e){n.clearTimeout(t._fetchTimer),t._destroyed||t.emit("error",e)}))}else{var p=t._xhr=new n.XMLHttpRequest;try{p.open(t._opts.method,t._opts.url,!0)}catch(e){return void i.nextTick((function(){t.emit("error",e)}))}"responseType"in p&&(p.responseType=t._mode.split(":")[0]),"withCredentials"in p&&(p.withCredentials=!!r.withCredentials),"text"===t._mode&&"overrideMimeType"in p&&p.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in r&&(p.timeout=r.requestTimeout,p.ontimeout=function(){t.emit("requestTimeout")}),u.forEach((function(t){p.setRequestHeader(t[0],t[1])})),t._response=null,p.onreadystatechange=function(){switch(p.readyState){case f.LOADING:case f.DONE:t._onXHRProgress()}},"moz-chunked-arraybuffer"===t._mode&&(p.onprogress=function(){t._onXHRProgress()}),p.onerror=function(){t._destroyed||t.emit("error",new Error("XHR error"))};try{p.send(a)}catch(e){return void i.nextTick((function(){t.emit("error",e)}))}}}},h.prototype._onXHRProgress=function(){var t=this;(function(t){try{var e=t.status;return null!==e&&0!==e}catch(t){return!1}})(t._xhr)&&!t._destroyed&&(t._response||t._connect(),t._response._onXHRProgress())},h.prototype._connect=function(){var t=this;t._destroyed||(t._response=new l(t._xhr,t._fetchResponse,t._mode,t._fetchTimer),t._response.on("error",(function(e){t.emit("error",e)})),t.emit("response",t._response))},h.prototype._write=function(t,e,r){this._body.push(t),r()},h.prototype.abort=h.prototype.destroy=function(){var t=this;t._destroyed=!0,n.clearTimeout(t._fetchTimer),t._response&&(t._response._destroyed=!0),t._xhr?t._xhr.abort():t._fetchAbortController&&t._fetchAbortController.abort()},h.prototype.end=function(t,e,r){"function"==typeof t&&(r=t,t=void 0),u.Writable.prototype.end.call(this,t,e,r)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var p=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,r(13).Buffer,r(17),r(22))},function(t,e){},function(t,e,r){"use strict";var n=r(104).Buffer,i=r(165);t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,r,i,o=n.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,r=o,i=a,e.copy(r,i),a+=s.data.length,s=s.next;return o},t}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,r){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(167),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(17))},function(t,e,r){(function(t,e){!function(t,r){"use strict";if(!t.setImmediate){var n,i,o,s,a,u=1,c={},l=!1,f=t.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(t);h=h&&h.setTimeout?h:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick((function(){d(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=r,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){d(t.data)},n=function(t){o.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,n=function(t){var e=f.createElement("script");e.onreadystatechange=function(){d(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):n=function(t){setTimeout(d,0,t)}:(s="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(s)&&d(+e.data.slice(s.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),n=function(e){t.postMessage(s+e,"*")}),h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},d=Math.floor,y=String.fromCharCode;function v(t){throw new RangeError(p[t])}function b(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function g(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+b((t=t.replace(h,".")).split("."),e).join(".")}function m(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=y((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=y(t)})).join("")}function _(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function E(t,e,r){var n=0;for(t=r?d(t/700):t>>1,t+=d(t/e);t>455;n+=c)t=d(t/35);return d(n+36*t/(t+38))}function O(t){var e,r,n,i,o,s,a,l,f,h,p,y=[],b=t.length,g=0,m=128,_=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&v("not-basic"),y.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=b&&v("invalid-input"),((l=(p=t.charCodeAt(i++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:c)>=c||l>d((u-g)/s))&&v("overflow"),g+=l*s,!(l<(f=a<=_?1:a>=_+26?26:a-_));a+=c)s>d(u/(h=c-f))&&v("overflow"),s*=h;_=E(g-o,e=y.length+1,0==o),d(g/e)>u-m&&v("overflow"),m+=d(g/e),g%=e,y.splice(g++,0,m)}return w(y)}function S(t){var e,r,n,i,o,s,a,l,f,h,p,b,g,w,O,S=[];for(b=(t=m(t)).length,e=128,r=0,o=72,s=0;s=e&&pd((u-r)/(g=n+1))&&v("overflow"),r+=(a-e)*g,e=a,s=0;su&&v("overflow"),p==e){for(l=r,f=c;!(l<(h=f<=o?1:f>=o+26?26:f-o));f+=c)O=l-h,w=c-h,S.push(y(_(h+O%w,0))),l=d(O/w);S.push(y(_(l,0))),o=E(r,g,n==i),r=0,++n}++r,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:m,encode:w},decode:O,encode:S,toASCII:function(t){return g(t,(function(t){return f.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return g(t,(function(t){return l.test(t)?O(t.slice(4).toLowerCase()):t}))}},void 0===(i=function(){return a}.call(e,r,e,t))||(t.exports=i)}()}).call(this,r(175)(t),r(17))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){"use strict";e.decode=e.parse=r(178),e.encode=e.stringify=r(179)},function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=y.substr(0,v),h=y.substr(v+1)):(f=y,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),n(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),(function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],(function(t){return a+encodeURIComponent(n(t))})).join(e):a+encodeURIComponent(n(t[s]))})).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n-1}},function(t,e,r){var n=r(83);t.exports=function(t,e){var r=this.__data__,i=n(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}},function(t,e,r){var n=r(112)(r(111),"Map");t.exports=n},function(t,e,r){var n=r(84);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},function(t,e){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},function(t,e,r){var n=r(84);t.exports=function(t){return n(this,t).get(t)}},function(t,e,r){var n=r(84);t.exports=function(t){return n(this,t).has(t)}},function(t,e,r){var n=r(84);t.exports=function(t,e){var r=n(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}},function(t,e,r){var n=r(223);t.exports=function(t){return null==t?"":n(t)}},function(t,e,r){var n=r(110),i=r(224),o=r(108),s=r(109),a=n?n.prototype:void 0,u=a?a.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(o(e))return i(e,t)+"";if(s(e))return u?u.call(e):"";var r=e+"";return"0"==r&&1/e==-Infinity?"-0":r}},function(t,e){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r-1&&t%1==0&&t0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},s=this&&this.__spread||function(){for(var t=[],e=0;e0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},l=this&&this.__spread||function(){for(var t=[],e=0;e=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.RPCEstimateProvider=void 0;var h=r(25),p=r(53),d=r(75),y=r(86),v=r(45),b=r(26),g=r(236),m=r(87),w=function(t,e){return{fee:void 0===t.fee?e.fee:t.fee,gasLimit:void 0===t.gasLimit?e.gasLimit:t.gasLimit,storageLimit:void 0===t.storageLimit?e.storageLimit:t.storageLimit}},_=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ALLOCATION_STORAGE=257,e.ORIGINATION_STORAGE=257,e.OP_SIZE_REVEAL=128,e}return i(e,t),e.prototype.getAccountLimits=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,o;return a(this,(function(s){switch(s.label){case 0:return[4,this.rpc.getBalance(t)];case 1:return e=s.sent(),[4,this.rpc.getConstants()];case 2:return r=s.sent(),n=r.hard_gas_limit_per_operation,i=r.hard_storage_limit_per_operation,o=r.cost_per_byte,[2,{fee:0,gasLimit:n.toNumber(),storageLimit:Math.floor(p.default.min(e.dividedBy(o),i).toNumber())}]}}))}))},e.prototype.getEstimationPropertiesFromOperationContent=function(t,e,r){var n=this,i=v.flattenOperationResult({contents:[t]}),o=0,s=0,a=0;return i.forEach((function(t){a+="originated_contracts"in t&&void 0!==t.originated_contracts?t.originated_contracts.length*n.ORIGINATION_STORAGE:0,a+="allocated_destination_contract"in t?n.ALLOCATION_STORAGE:0,o+=Number(t.consumed_gas)||0,s+=Number(t.consumed_milligas)||0,a+="paid_storage_size_diff"in t&&Number(t.paid_storage_size_diff)||0})),0!==o&&0===s&&(s=1e3*o),b.isOpWithFee(t)?{milligasLimit:s||0,storageLimit:Number(a||0),opSize:e,minimalFeePerStorageByteMutez:r.toNumber()}:{milligasLimit:0,storageLimit:0,opSize:e,minimalFeePerStorageByteMutez:r.toNumber(),baseFeeMutez:0}},e.prototype.prepareEstimate=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,o,s,u,c,f,h,p,d,y=this;return a(this,(function(a){switch(a.label){case 0:return[4,this.prepareOperation(t)];case 1:return e=a.sent(),[4,this.forge(e)];case 2:return r=a.sent(),n=r.opbytes,i=r.opOb,o=i.branch,s=i.contents,d={operation:{branch:o,contents:s,signature:"edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg"}},[4,this.rpc.getChainId()];case 3:return d.chain_id=a.sent(),u=d,[4,this.simulate(u)];case 4:return c=a.sent().opResponse,[4,this.rpc.getConstants()];case 5:if(f=a.sent().cost_per_byte,(h=l(v.flattenErrors(c,"backtracked"),v.flattenErrors(c))).length)throw new v.TezosOperationError(h);return p=1,Array.isArray(t.operation)&&t.operation.length>1&&(p="reveal"===c.contents[0].kind?t.operation.length-1:t.operation.length),[2,c.contents.map((function(t){return y.getEstimationPropertiesFromOperationContent(t,"reveal"===t.kind?y.OP_SIZE_REVEAL/2:n.length/2/p,f)}))]}}))}))},e.prototype.originate=function(t){var e=t.fee,r=t.storageLimit,n=t.gasLimit,i=u(t,["fee","storageLimit","gasLimit"]);return s(this,void 0,void 0,(function(){var t,s,u,c,l,f,h,p;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return t=a.sent(),[4,this.getAccountLimits(t)];case 2:return s=a.sent(),c=m.createOriginationOperation,[4,this.context.parser.prepareCodeOrigination(o(o({},i),w({fee:e,storageLimit:r,gasLimit:n},s)))];case 3:return[4,c.apply(void 0,[a.sent()])];case 4:return u=a.sent(),[4,this.isRevealOpNeeded([u],t)];case 5:return(l=a.sent())?[4,this.addRevealOp([u],t)]:[3,7];case 6:return h=a.sent(),[3,8];case 7:h=u,a.label=8;case 8:return f=h,[4,this.prepareEstimate({operation:f,source:t})];case 9:return p=a.sent(),l&&p.shift(),[2,g.Estimate.createEstimateInstanceFromProperties(p)]}}))}))},e.prototype.transfer=function(t){var e=t.fee,r=t.storageLimit,n=t.gasLimit,i=u(t,["fee","storageLimit","gasLimit"]);return s(this,void 0,void 0,(function(){var t,s,u,c,l,f,h;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return t=a.sent(),[4,this.getAccountLimits(t)];case 2:return s=a.sent(),[4,m.createTransferOperation(o(o({},i),w({fee:e,storageLimit:r,gasLimit:n},s)))];case 3:return u=a.sent(),[4,this.isRevealOpNeeded([u],t)];case 4:return(c=a.sent())?[4,this.addRevealOp([u],t)]:[3,6];case 5:return f=a.sent(),[3,7];case 6:f=u,a.label=7;case 7:return l=f,[4,this.prepareEstimate({operation:l,source:t})];case 8:return h=a.sent(),c&&h.shift(),[2,g.Estimate.createEstimateInstanceFromProperties(h)]}}))}))},e.prototype.setDelegate=function(t){var e=t.fee,r=t.gasLimit,n=t.storageLimit,i=u(t,["fee","gasLimit","storageLimit"]);return s(this,void 0,void 0,(function(){var t,s,u,c,l,f,h,p;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return t=a.sent(),s=i.source||t,[4,this.getAccountLimits(s)];case 2:return u=a.sent(),[4,m.createSetDelegateOperation(o(o({},i),w({fee:e,storageLimit:n,gasLimit:r},u)))];case 3:return c=a.sent(),[4,this.isRevealOpNeeded([c],t)];case 4:return(l=a.sent())?[4,this.addRevealOp([c],t)]:[3,6];case 5:return h=a.sent(),[3,7];case 6:h=c,a.label=7;case 7:return f=h,[4,this.prepareEstimate({operation:f,source:t})];case 8:return p=a.sent(),l&&p.shift(),[2,g.Estimate.createEstimateInstanceFromProperties(p)]}}))}))},e.prototype.batch=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,s,u,c,l,p,d,y,v,b,_,E,O,S,x;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return e=a.sent(),r=[],[4,this.getAccountLimits(e)];case 2:n=a.sent(),a.label=3;case 3:a.trys.push([3,16,17,18]),i=f(t),s=i.next(),a.label=4;case 4:if(s.done)return[3,15];switch(u=s.value,u.kind){case h.OpKind.TRANSACTION:return[3,5];case h.OpKind.ORIGINATION:return[3,7];case h.OpKind.DELEGATION:return[3,10];case h.OpKind.ACTIVATION:return[3,12]}return[3,13];case 5:return l=(c=r).push,[4,m.createTransferOperation(o(o({},u),w(u,n)))];case 6:return l.apply(c,[a.sent()]),[3,14];case 7:return d=(p=r).push,y=m.createOriginationOperation,[4,this.context.parser.prepareCodeOrigination(o(o({},u),w(u,n)))];case 8:return[4,y.apply(void 0,[a.sent()])];case 9:return d.apply(p,[a.sent()]),[3,14];case 10:return b=(v=r).push,[4,m.createSetDelegateOperation(o(o({},u),w(u,n)))];case 11:return b.apply(v,[a.sent()]),[3,14];case 12:return r.push(o(o({},u),n)),[3,14];case 13:throw new Error("Unsupported operation kind: "+u.kind);case 14:return s=i.next(),[3,4];case 15:return[3,18];case 16:return _=a.sent(),S={error:_},[3,18];case 17:try{s&&!s.done&&(x=i.return)&&x.call(i)}finally{if(S)throw S.error}return[7];case 18:return[4,this.isRevealOpNeeded(r,e)];case 19:return a.sent()?[4,this.addRevealOp(r,e)]:[3,21];case 20:return E=a.sent(),[3,22];case 21:E=r,a.label=22;case 22:return r=E,[4,this.prepareEstimate({operation:r,source:e})];case 23:return O=a.sent(),[2,g.Estimate.createArrayEstimateInstancesFromProperties(O)]}}))}))},e.prototype.registerDelegate=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,s,u,c;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return e=a.sent(),[4,this.getAccountLimits(e)];case 2:return r=a.sent(),[4,m.createRegisterDelegateOperation(o(o({},t),r),e)];case 3:return n=a.sent(),[4,this.isRevealOpNeeded([n],e)];case 4:return(i=a.sent())?[4,this.addRevealOp([n],e)]:[3,6];case 5:return u=a.sent(),[3,7];case 6:u=n,a.label=7;case 7:return s=u,[4,this.prepareEstimate({operation:s,source:e})];case 8:return c=a.sent(),i&&c.shift(),[2,g.Estimate.createEstimateInstanceFromProperties(c)]}}))}))},e.prototype.reveal=function(t){return s(this,void 0,void 0,(function(){var e,r,n,i,s,u;return a(this,(function(a){switch(a.label){case 0:return[4,this.signer.publicKeyHash()];case 1:return e=a.sent(),[4,this.isAccountRevealRequired(e)];case 2:return a.sent()?[4,this.getAccountLimits(e)]:[3,7];case 3:return r=a.sent(),i=m.createRevealOperation,s=[o(o({},t),r),e],[4,this.signer.publicKey()];case 4:return[4,i.apply(void 0,s.concat([a.sent()]))];case 5:return n=a.sent(),[4,this.prepareEstimate({operation:n,source:e})];case 6:return u=a.sent(),[2,g.Estimate.createEstimateInstanceFromProperties(u)];case 7:return[2]}}))}))},e.prototype.addRevealOp=function(t,e){return s(this,void 0,void 0,(function(){var r,n,i,s;return a(this,(function(a){switch(a.label){case 0:return n=(r=t).unshift,i=m.createRevealOperation,s=[o({fee:d.DEFAULT_FEE.REVEAL,gasLimit:d.DEFAULT_GAS_LIMIT.REVEAL,storageLimit:d.DEFAULT_STORAGE_LIMIT.REVEAL}),e],[4,this.signer.publicKey()];case 1:return[4,i.apply(void 0,s.concat([a.sent()]))];case 2:return n.apply(r,[a.sent()]),[2,t]}}))}))},e}(y.OperationEmitter);e.RPCEstimateProvider=_},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Estimate=void 0;var n=100,i=function(){function t(t,e,r,i,o){void 0===o&&(o=n),this._milligasLimit=t,this._storageLimit=e,this.opSize=r,this.minimalFeePerStorageByteMutez=i,this.baseFeeMutez=o}return Object.defineProperty(t.prototype,"burnFeeMutez",{get:function(){return this.roundUp(Number(this.storageLimit)*Number(this.minimalFeePerStorageByteMutez))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storageLimit",{get:function(){var t=Math.max(Number(this._storageLimit),0);return t>0?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gasLimit",{get:function(){return this.roundUp(Number(this._milligasLimit)/1e3+100)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"operationFeeMutez",{get:function(){return.1*(Number(this._milligasLimit)/1e3+100)+1*Number(this.opSize)},enumerable:!1,configurable:!0}),t.prototype.roundUp=function(t){return Math.ceil(Number(t))},Object.defineProperty(t.prototype,"minimalFeeMutez",{get:function(){return this.roundUp(n+this.operationFeeMutez)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"suggestedFeeMutez",{get:function(){return this.roundUp(this.operationFeeMutez+200)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usingBaseFeeMutez",{get:function(){return Math.max(Number(this.baseFeeMutez),n)+this.roundUp(this.operationFeeMutez)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalCost",{get:function(){return this.minimalFeeMutez+this.burnFeeMutez},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"consumedMilligas",{get:function(){return Number(this._milligasLimit)},enumerable:!1,configurable:!0}),t.createEstimateInstanceFromProperties=function(e){var r,n=0,i=0,o=0,s=0;return e.forEach((function(t){n+=t.milligasLimit,i+=t.storageLimit,o+=t.opSize,s=Math.max(t.minimalFeePerStorageByteMutez,s),t.baseFeeMutez&&(r=r?r+t.baseFeeMutez:t.baseFeeMutez)})),new t(n,i,o,s,r)},t.createArrayEstimateInstancesFromProperties=function(e){return e.map((function(e){return new t(e.milligasLimit,e.storageLimit,e.opSize,e.minimalFeePerStorageByteMutez,e.baseFeeMutez)}))},t}();e.Estimate=i},function(t,e,r){"use strict";var n=r(14),i=r(238),o=r(248),s=r(249),a=r(254);function u(t){a.call(this,"digest"),this._hash=t}n(u,a),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(s(t))}},function(t,e,r){"use strict";var n=r(14),i=r(135),o=r(27).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(t,e){return t<>>32-e}function c(t,e,r,n,i,o,s){return u(t+(e&r|~e&n)+i+o|0,s)+e|0}function l(t,e,r,n,i,o,s){return u(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return u(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return u(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=c(r,n,i,o,t[0],3614090360,7),o=c(o,r,n,i,t[1],3905402710,12),i=c(i,o,r,n,t[2],606105819,17),n=c(n,i,o,r,t[3],3250441966,22),r=c(r,n,i,o,t[4],4118548399,7),o=c(o,r,n,i,t[5],1200080426,12),i=c(i,o,r,n,t[6],2821735955,17),n=c(n,i,o,r,t[7],4249261313,22),r=c(r,n,i,o,t[8],1770035416,7),o=c(o,r,n,i,t[9],2336552879,12),i=c(i,o,r,n,t[10],4294925233,17),n=c(n,i,o,r,t[11],2304563134,22),r=c(r,n,i,o,t[12],1804603682,7),o=c(o,r,n,i,t[13],4254626195,12),i=c(i,o,r,n,t[14],2792965006,17),r=l(r,n=c(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=l(o,r,n,i,t[6],3225465664,9),i=l(i,o,r,n,t[11],643717713,14),n=l(n,i,o,r,t[0],3921069994,20),r=l(r,n,i,o,t[5],3593408605,5),o=l(o,r,n,i,t[10],38016083,9),i=l(i,o,r,n,t[15],3634488961,14),n=l(n,i,o,r,t[4],3889429448,20),r=l(r,n,i,o,t[9],568446438,5),o=l(o,r,n,i,t[14],3275163606,9),i=l(i,o,r,n,t[3],4107603335,14),n=l(n,i,o,r,t[8],1163531501,20),r=l(r,n,i,o,t[13],2850285829,5),o=l(o,r,n,i,t[2],4243563512,9),i=l(i,o,r,n,t[7],1735328473,14),r=f(r,n=l(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=f(o,r,n,i,t[8],2272392833,11),i=f(i,o,r,n,t[11],1839030562,16),n=f(n,i,o,r,t[14],4259657740,23),r=f(r,n,i,o,t[1],2763975236,4),o=f(o,r,n,i,t[4],1272893353,11),i=f(i,o,r,n,t[7],4139469664,16),n=f(n,i,o,r,t[10],3200236656,23),r=f(r,n,i,o,t[13],681279174,4),o=f(o,r,n,i,t[0],3936430074,11),i=f(i,o,r,n,t[3],3572445317,16),n=f(n,i,o,r,t[6],76029189,23),r=f(r,n,i,o,t[9],3654602809,4),o=f(o,r,n,i,t[12],3873151461,11),i=f(i,o,r,n,t[15],530742520,16),r=h(r,n=f(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=h(o,r,n,i,t[7],1126891415,10),i=h(i,o,r,n,t[14],2878612391,15),n=h(n,i,o,r,t[5],4237533241,21),r=h(r,n,i,o,t[12],1700485571,6),o=h(o,r,n,i,t[3],2399980690,10),i=h(i,o,r,n,t[10],4293915773,15),n=h(n,i,o,r,t[1],2240044497,21),r=h(r,n,i,o,t[8],1873313359,6),o=h(o,r,n,i,t[15],4264355552,10),i=h(i,o,r,n,t[6],2734768916,15),n=h(n,i,o,r,t[13],1309151649,21),r=h(r,n,i,o,t[4],4149444226,6),o=h(o,r,n,i,t[11],3174756917,10),i=h(i,o,r,n,t[2],718787259,15),n=h(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},function(t,e,r){(e=t.exports=r(136)).Stream=e,e.Readable=e,e.Writable=r(140),e.Duplex=r(55),e.Transform=r(141),e.PassThrough=r(246),e.finished=r(115),e.pipeline=r(247)},function(t,e){},function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return s.alloc(0);for(var e,r,n,i=s.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,r=i,n=a,s.prototype.copy.call(e,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=s.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:u,value:function(t,e){return a(this,function(t){for(var e=1;e0,(function(t){n||(n=t),t&&s.forEach(c),o||(s.forEach(c),i(n))}))}));return e.reduce(l)}},function(t,e,r){"use strict";var n=r(13).Buffer,i=r(14),o=r(135),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],u=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,O=0|this._d,S=0|this._e,x=0;x<80;x+=1){var T,A;x<16?(T=y(r,n,i,o,p,t[a[x]],f[0],c[x]),A=m(w,_,E,O,S,t[u[x]],h[0],l[x])):x<32?(T=v(r,n,i,o,p,t[a[x]],f[1],c[x]),A=g(w,_,E,O,S,t[u[x]],h[1],l[x])):x<48?(T=b(r,n,i,o,p,t[a[x]],f[2],c[x]),A=b(w,_,E,O,S,t[u[x]],h[2],l[x])):x<64?(T=g(r,n,i,o,p,t[a[x]],f[3],c[x]),A=v(w,_,E,O,S,t[u[x]],h[3],l[x])):(T=m(r,n,i,o,p,t[a[x]],f[4],c[x]),A=y(w,_,E,O,S,t[u[x]],h[4],l[x])),r=p,p=o,o=d(i,10),i=n,n=T,w=S,S=O,O=d(E,10),E=_,_=A}var P=this._b+i+O|0;this._b=this._c+o+S|0,this._c=this._d+p+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=P},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},function(t,e,r){(e=t.exports=function(t){t=t.toLowerCase();var r=e[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r}).sha=r(250),e.sha1=r(251),e.sha224=r(252),e.sha256=r(142),e.sha384=r(253),e.sha512=r(143)},function(t,e,r){var n=r(14),i=r(56),o=r(27).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=t.readInt32BE(4*f);for(;f<80;++f)r[f]=r[f-3]^r[f-8]^r[f-14]^r[f-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+l(p,i,o,a)+u+r[h]+s[p];u=a,a=o,o=c(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},function(t,e,r){var n=r(14),i=r(56),o=r(27).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=(e=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=c(n)+f(d,i,o,a)+u+r[p]+s[d]|0;u=a,a=o,o=l(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},function(t,e,r){var n=r(14),i=r(142),o=r(56),s=r(27).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},function(t,e,r){var n=r(14),i=r(143),o=r(56),s=r(27).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},function(t,e,r){var n=r(27).Buffer,i=r(255).Transform,o=r(73).StringDecoder;function s(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(14)(s,i),s.prototype.update=function(t,e,r){"string"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},function(t,e,r){t.exports=i;var n=r(71).EventEmitter;function i(){n.call(this)}r(44)(i,n),i.Readable=r(70),i.Writable=r(256),i.Duplex=r(257),i.Transform=r(258),i.PassThrough=r(259),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),t.removeListener("close",l)}return r.on("error",c),t.on("error",c),r.on("end",l),r.on("close",l),t.on("close",l),t.emit("pipe",r),t}},function(t,e,r){t.exports=r(105)},function(t,e,r){t.exports=r(47)},function(t,e,r){t.exports=r(70).Transform},function(t,e,r){t.exports=r(70).PassThrough},function(t,e,r){"use strict";var n=r(261),i=r(27).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},function(t,e,r){var n=r(262);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e,r){"use strict";var n=r(27).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,l=new Uint8Array(s);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,p=s-1;(0!==f||h>>0,l[p]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,r++}if(" "!==t[r]){for(var d=s-o;d!==s&&0===l[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var v=i;d!==s;)y[v++]=l[d++];return y}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*l+1>>>0,f=new Uint8Array(c);o!==s;){for(var h=e[o],p=0,d=c-1;(0!==h||p>>0,f[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===f[y];)y++;for(var v=u.repeat(r);y=4294967296&&i++,t[e]=n,t[e+1]=i}function o(t,e,r,n){var i=t[e]+r;r<0&&(i+=4294967296);var o=t[e+1]+n;i>=4294967296&&o++,t[e]=i,t[e+1]=o}function s(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function a(t,e,r,n,s,a){var u=f[s],c=f[s+1],h=f[a],p=f[a+1];i(l,t,e),o(l,t,u,c);var d=l[n]^l[t],y=l[n+1]^l[t+1];l[n]=y,l[n+1]=d,i(l,r,n),d=l[e]^l[r],y=l[e+1]^l[r+1],l[e]=d>>>24^y<<8,l[e+1]=y>>>24^d<<8,i(l,t,e),o(l,t,h,p),d=l[n]^l[t],y=l[n+1]^l[t+1],l[n]=d>>>16^y<<16,l[n+1]=y>>>16^d<<16,i(l,r,n),d=l[e]^l[r],y=l[e+1]^l[r+1],l[e]=y>>>31^d<<1,l[e+1]=d>>>31^y<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(t){return 2*t}))),l=new Uint32Array(32),f=new Uint32Array(32);function h(t,e){var r=0;for(r=0;r<16;r++)l[r]=t.h[r],l[r+16]=u[r];for(l[24]=l[24]^t.t,l[25]=l[25]^t.t/4294967296,e&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)f[r]=s(t.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,c[16*r+0],c[16*r+1]),a(2,10,18,26,c[16*r+2],c[16*r+3]),a(4,12,20,28,c[16*r+4],c[16*r+5]),a(6,14,22,30,c[16*r+6],c[16*r+7]),a(0,10,20,30,c[16*r+8],c[16*r+9]),a(2,12,22,24,c[16*r+10],c[16*r+11]),a(4,14,16,26,c[16*r+12],c[16*r+13]),a(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^l[r]^l[r+16]}function p(t,e){if(0===t||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(e&&e.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t},n=0;n<16;n++)r.h[n]=u[n];var i=e?e.length:0;return r.h[0]^=16842752^i<<8^t,e&&(d(r,e),r.c=128),r}function d(t,e){for(var r=0;r>2]>>8*(3&r);return e}function v(t,e,r){r=r||64,t=n.normalizeInput(t);var i=p(r,e);return d(i,t),y(i)}t.exports={blake2b:v,blake2bHex:function(t,e,r){var i=v(t,e,r);return n.toHex(i)},blake2bInit:p,blake2bUpdate:d,blake2bFinal:y}},function(t,e,r){var n=r(144);function i(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function o(t,e,r,n,i,o){c[t]=c[t]+c[e]+i,c[n]=s(c[n]^c[t],16),c[r]=c[r]+c[n],c[e]=s(c[e]^c[r],12),c[t]=c[t]+c[e]+o,c[n]=s(c[n]^c[t],8),c[r]=c[r]+c[n],c[e]=s(c[e]^c[r],7)}function s(t,e){return t>>>e^t<<32-e}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),l=new Uint32Array(16);function f(t,e){var r=0;for(r=0;r<8;r++)c[r]=t.h[r],c[r+8]=a[r];for(c[12]^=t.t,c[13]^=t.t/4294967296,e&&(c[14]=~c[14]),r=0;r<16;r++)l[r]=i(t.b,4*r);for(r=0;r<10;r++)o(0,4,8,12,l[u[16*r+0]],l[u[16*r+1]]),o(1,5,9,13,l[u[16*r+2]],l[u[16*r+3]]),o(2,6,10,14,l[u[16*r+4]],l[u[16*r+5]]),o(3,7,11,15,l[u[16*r+6]],l[u[16*r+7]]),o(0,5,10,15,l[u[16*r+8]],l[u[16*r+9]]),o(1,6,11,12,l[u[16*r+10]],l[u[16*r+11]]),o(2,7,8,13,l[u[16*r+12]],l[u[16*r+13]]),o(3,4,9,14,l[u[16*r+14]],l[u[16*r+15]]);for(r=0;r<8;r++)t.h[r]^=c[r]^c[r+8]}function h(t,e){if(!(t>0&&t<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=e?e.length:0;if(e&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:t};return n.h[0]^=16842752^r<<8^t,r>0&&(p(n,e),n.c=64),n}function p(t,e){for(var r=0;r>2]>>8*(3&r)&255;return e}function y(t,e,r){r=r||32,t=n.normalizeInput(t);var i=h(r,e);return p(i,t),d(i)}t.exports={blake2s:y,blake2sHex:function(t,e,r){var i=y(t,e,r);return n.toHex(i)},blake2sInit:h,blake2sUpdate:p,blake2sFinal:d}},function(t,e,r){"use strict";var n,i=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},c=this&&this.__spread||function(){for(var t=[],e=0;e0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Wallet=e.WalletOperationBatch=void 0;var a=r(151),u=r(26),c=function(){function t(t,e){this.walletProvider=t,this.context=e,this.operations=[]}return t.prototype.withTransfer=function(t){return this.operations.push(n({kind:u.OpKind.TRANSACTION},t)),this},t.prototype.withContractCall=function(t){return this.withTransfer(t.toTransferParams())},t.prototype.withDelegation=function(t){return this.operations.push(n({kind:u.OpKind.DELEGATION},t)),this},t.prototype.withOrigination=function(t){return this.operations.push(n({kind:u.OpKind.ORIGINATION},t)),this},t.prototype.mapOperation=function(t){return i(this,void 0,void 0,(function(){var e,r;return o(this,(function(i){switch(i.label){case 0:switch(t.kind){case u.OpKind.TRANSACTION:return[3,1];case u.OpKind.ORIGINATION:return[3,2];case u.OpKind.DELEGATION:return[3,4]}return[3,5];case 1:return[2,this.walletProvider.mapTransferParamsToWalletParams(n({},t))];case 2:return r=(e=this.walletProvider).mapOriginateParamsToWalletParams,[4,this.context.parser.prepareCodeOrigination(n({},t))];case 3:return[2,r.apply(e,[i.sent()])];case 4:return[2,this.walletProvider.mapDelegateParamsToWalletParams(n({},t))];case 5:throw new Error("Unsupported operation kind: "+t.kind)}}))}))},t.prototype.with=function(t){var e,r;try{for(var n=s(t),i=n.next();!i.done;i=n.next()){var o=i.value;switch(o.kind){case u.OpKind.TRANSACTION:this.withTransfer(o);break;case u.OpKind.ORIGINATION:this.withOrigination(o);break;case u.OpKind.DELEGATION:this.withDelegation(o);break;default:throw new Error("Unsupported operation kind: "+o.kind)}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return this},t.prototype.send=function(){return i(this,void 0,void 0,(function(){var t,e,r,n,i,a,u,c,l,f;return o(this,(function(o){switch(o.label){case 0:t=[],o.label=1;case 1:o.trys.push([1,6,7,8]),e=s(this.operations),r=e.next(),o.label=2;case 2:return r.done?[3,5]:(n=r.value,a=(i=t).push,[4,this.mapOperation(n)]);case 3:a.apply(i,[o.sent()]),o.label=4;case 4:return r=e.next(),[3,2];case 5:return[3,8];case 6:return u=o.sent(),l={error:u},[3,8];case 7:try{r&&!r.done&&(f=e.return)&&f.call(e)}finally{if(l)throw l.error}return[7];case 8:return[4,this.walletProvider.sendOperations(t)];case 9:return c=o.sent(),[2,this.context.operationFactory.createOperation(c)]}}))}))},t}();e.WalletOperationBatch=c;var l=function(){function t(t){this.context=t,this.walletCommand=function(t){return{send:t}}}return Object.defineProperty(t.prototype,"walletProvider",{get:function(){return this.context.walletProvider},enumerable:!1,configurable:!0}),t.prototype.pkh=function(t){var e=(void 0===t?{}:t).forceRefetch;return i(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return this._pkh&&!e?[3,2]:(t=this,[4,this.walletProvider.getPKH()]);case 1:t._pkh=r.sent(),r.label=2;case 2:return[2,this._pkh]}}))}))},t.prototype.originate=function(t){var e=this;return this.walletCommand((function(){return i(e,void 0,void 0,(function(){var e,r,i,s,a;return o(this,(function(o){switch(o.label){case 0:return i=(r=this.walletProvider).mapOriginateParamsToWalletParams,[4,this.context.parser.prepareCodeOrigination(n({},t))];case 1:return[4,i.apply(r,[o.sent()])];case 2:return e=o.sent(),[4,this.walletProvider.sendOperations([e])];case 3:return s=o.sent(),this.context.proto?[3,5]:(a=this.context,[4,this.context.rpc.getBlock()]);case 4:a.proto=o.sent().protocol,o.label=5;case 5:return[2,this.context.operationFactory.createOriginationOperation(s)]}}))}))}))},t.prototype.setDelegate=function(t){var e=this;return this.walletCommand((function(){return i(e,void 0,void 0,(function(){var e,r;return o(this,(function(i){switch(i.label){case 0:return[4,this.walletProvider.mapDelegateParamsToWalletParams(n({},t))];case 1:return e=i.sent(),[4,this.walletProvider.sendOperations([e])];case 2:return r=i.sent(),[2,this.context.operationFactory.createDelegationOperation(r)]}}))}))}))},t.prototype.registerDelegate=function(){var t=this;return this.walletCommand((function(){return i(t,void 0,void 0,(function(){var t,e,r,n,i;return o(this,(function(o){switch(o.label){case 0:return r=(e=this.walletProvider).mapDelegateParamsToWalletParams,i={},[4,this.pkh()];case 1:return[4,r.apply(e,[(i.delegate=o.sent(),i)])];case 2:return t=o.sent(),[4,this.walletProvider.sendOperations([t])];case 3:return n=o.sent(),[2,this.context.operationFactory.createDelegationOperation(n)]}}))}))}))},t.prototype.transfer=function(t){var e=this;return this.walletCommand((function(){return i(e,void 0,void 0,(function(){var e,r;return o(this,(function(n){switch(n.label){case 0:return[4,this.walletProvider.mapTransferParamsToWalletParams(t)];case 1:return e=n.sent(),[4,this.walletProvider.sendOperations([e])];case 2:return r=n.sent(),[2,this.context.operationFactory.createTransactionOperation(r)]}}))}))}))},t.prototype.batch=function(t){var e=new c(this.walletProvider,this.context);return Array.isArray(t)&&e.with(t),e},t.prototype.at=function(t,e){return void 0===e&&(e=function(t){return t}),i(this,void 0,void 0,(function(){var r,n,i,s,u;return o(this,(function(o){switch(o.label){case 0:return[4,this.context.rpc.getScript(t)];case 1:return r=o.sent(),[4,this.context.rpc.getEntrypoints(t)];case 2:return n=o.sent(),[4,this.context.rpc.getBlockHeader()];case 3:return i=o.sent(),s=i.chain_id,u=new a.ContractAbstraction(t,r,this,this.context.contract,n,s),[2,e(u,this.context)]}}))}))},t}();e.Wallet=l},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MANAGER_LAMBDA=void 0;e.MANAGER_LAMBDA={setDelegate:function(t){return[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PUSH",args:[{prim:"key_hash"},{string:t}]},{prim:"SOME"},{prim:"SET_DELEGATE"},{prim:"CONS"}]},removeDelegate:function(){return[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"NONE",args:[{prim:"key_hash"}]},{prim:"SET_DELEGATE"},{prim:"CONS"}]},transferImplicit:function(t,e){return[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PUSH",args:[{prim:"key_hash"},{string:t}]},{prim:"IMPLICIT_ACCOUNT"},{prim:"PUSH",args:[{prim:"mutez"},{int:""+e}]},{prim:"UNIT"},{prim:"TRANSFER_TOKENS"},{prim:"CONS"}]},transferToContract:function(t,e){return[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PUSH",args:[{prim:"address"},{string:t}]},{prim:"CONTRACT",args:[{prim:"unit"}]},[{prim:"IF_NONE",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],[]]}],{prim:"PUSH",args:[{prim:"mutez"},{int:""+e}]},{prim:"UNIT"},{prim:"TRANSFER_TOKENS"},{prim:"CONS"}]}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VIEW_LAMBDA=void 0;e.VIEW_LAMBDA={code:[{prim:"parameter",args:[{prim:"lambda",args:[{prim:"unit"},{prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},{prim:"unit"}]}]}]},{prim:"storage",args:[{prim:"unit"}]},{prim:"code",args:[[{prim:"CAR"},{prim:"UNIT"},{prim:"EXEC"}]]}],storage:"Unit"}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.compose=void 0,e.compose=function(t,e){return function(r,n){return e(t(r,n),n)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s};Object.defineProperty(e,"__esModule",{value:!0});var s=r(45),a=function(){function t(t,e,r,n){void 0===r&&(r="default"),void 0===n&&(n={prim:"Unit"}),this.lambdaContract=t,this.viewContract=e,this.viewMethod=r,this.contractParameter=n,this.voidLambda=this.createVoidLambda()}return t.prototype.execute=function(){return n(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.lambdaContract.methods.default(this.voidLambda).send()];case 1:return r.sent(),[3,3];case 2:if((t=r.sent())instanceof s.TezosOperationError)return e=t.errors[t.errors.length-1],[2,e.with];throw t;case 3:return[2]}}))}))},t.prototype.createVoidLambda=function(){var t=o(this.getView(),2),e=t[0],r=t[1],n=[{prim:"pair",args:[e,{prim:"contract",args:[r]}]}];return"default"===this.viewMethod&&(n=[{string:"%default"}].concat(n)),[{prim:"PUSH",args:[{prim:"mutez"},{int:"0"}]},{prim:"NONE",args:[{prim:"key_hash"}]},{prim:"CREATE_CONTRACT",args:[[{prim:"parameter",args:[r]},{prim:"storage",args:[{prim:"unit"}]},{prim:"code",args:[[{prim:"CAR"},{prim:"FAILWITH"}]]}]]},{prim:"DIP",args:[[{prim:"DIP",args:[[{prim:"LAMBDA",args:[{prim:"pair",args:[{prim:"address"},{prim:"unit"}]},{prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},{prim:"unit"}]},[{prim:"CAR"},{prim:"CONTRACT",args:[r]},{prim:"IF_NONE",args:[[{prim:"PUSH",args:[{prim:"string"},{string:"Callback type unmatched"}]},{prim:"FAILWITH"}],[]]},{prim:"PUSH",args:[e,this.contractParameter]},{prim:"PAIR"},{prim:"DIP",args:[[{prim:"PUSH",args:[{prim:"address"},{string:this.viewContract.address+"%"+this.viewMethod}]},{prim:"DUP"},{prim:"CONTRACT",args:n},{prim:"IF_NONE",args:[[{prim:"PUSH",args:[{prim:"string"},{string:"Contract does not exist"}]},{prim:"FAILWITH"}],[{prim:"DIP",args:[[{prim:"DROP"}]]}]]},{prim:"PUSH",args:[{prim:"mutez"},{int:"0"}]}]]},{prim:"TRANSFER_TOKENS"},{prim:"DIP",args:[[{prim:"NIL",args:[{prim:"operation"}]}]]},{prim:"CONS"},{prim:"DIP",args:[[{prim:"UNIT"}]]},{prim:"PAIR"}]]}]]},{prim:"APPLY"},{prim:"DIP",args:[[{prim:"PUSH",args:[{prim:"address"},{string:this.lambdaContract.address}]},{prim:"DUP"},{prim:"CONTRACT",args:[{prim:"lambda",args:[{prim:"unit"},{prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},{prim:"unit"}]}]}]},{prim:"IF_NONE",args:[[{prim:"PUSH",args:[{prim:"string"},{string:"Contract does not exists"}]},{prim:"FAILWITH"}],[{prim:"DIP",args:[[{prim:"DROP"}]]}]]},{prim:"PUSH",args:[{prim:"mutez"},{int:"0"}]}]]},{prim:"TRANSFER_TOKENS"},{prim:"DIP",args:[[{prim:"NIL",args:[{prim:"operation"}]}]]},{prim:"CONS"}]]},{prim:"CONS"},{prim:"DIP",args:[[{prim:"UNIT"}]]},{prim:"PAIR"}]},t.prototype.getView=function(){var t=this.viewContract.entrypoints.entrypoints[this.viewMethod];if(!t)throw Error("Contract at "+this.viewContract.address+" does not have entrypoint: "+this.viewMethod);if(!("prim"in t)||!t.args)throw Error("Entrypoint args undefined");var e,r=Array.from(t.args),n=o(r,2),i=n[0],s=n[1];if("annots"in i&&delete i.annots,!("prim"in s)||!s.args)throw Error("Callback contract args undefined");if("pair"!==t.prim?e="Expected {'prim': 'pair', ..} but found {'prim': "+t.prim+", ..}":2!==r.length?e="Expected an Array of length 2, but found: "+r:"contract"!==s.prim?e="Expected a {prim: 'contract', ...}, but found: "+s.prim:s.args&&1!==s.args.length&&(e="Expected a single argument to 'contract', but found: "+s.args),e)throw Error(e);return[i,s.args[0]]},t}();e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.smartContractAbstractionSemantic=void 0;var n=r(76),i=r(152),o=r(53);e.smartContractAbstractionSemantic=function(t){return{big_map:function(e,r){if(e&&"int"in e&&void 0!==e.int){var s=new n.Schema(r);return new i.BigMapAbstraction(new o.default(e.int),s,t)}return{}}}}},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spread||function(){for(var t=[],e=0;e=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.ObservableSubscription=void 0;var i=r(78),o=r(57),s=function(){function t(t,e,r){var n=this;void 0===e&&(e=!1),void 0===r&&(r=o.retry()),this.shouldRetry=e,this.operatorFunction=r,this.errorListeners=[],this.messageListeners=[],this.closeListeners=[],this.completed$=new i.Subject,t.pipe(o.takeUntil(this.completed$),o.tap((function(t){n.call(n.messageListeners,t)}),(function(t){n.call(n.errorListeners,t)}),(function(){n.call(n.closeListeners)})),this.shouldRetry?r:o.tap(),o.catchError((function(){return i.NEVER}))).subscribe()}return t.prototype.call=function(t,e){var r,i;try{for(var o=n(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{a(e)}catch(t){console.error(t)}}}catch(t){r={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}},t.prototype.remove=function(t,e){var r=t.indexOf(e);-1!==r&&t.splice(r,1)},t.prototype.on=function(t,e){switch(t){case"data":this.messageListeners.push(e);break;case"error":this.errorListeners.push(e);break;case"close":this.closeListeners.push(e);break;default:throw new Error("Trying to register on an unsupported event: "+t)}},t.prototype.off=function(t,e){switch(t){case"data":this.remove(this.messageListeners,e);break;case"error":this.remove(this.errorListeners,e);break;case"close":this.remove(this.closeListeners,e);break;default:throw new Error("Trying to unregister on an unsupported event: "+t)}},t.prototype.close=function(){this.completed$.next()},t}();e.ObservableSubscription=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION={commitHash:"672d0dd2a20104bf148e55a78550ca2abda4e652",version:"9.1.1"}},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]now});this.requestCounter.push(now);return[2,this.requestCounter.length>this.rateLimit]})})};Client.prototype.init=function(transport){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:if(!(this._transport.status===exposed_promise_1.ExposedPromiseStatus.RESOLVED))return[3,2];return[4,this.transport];case 1:return[2,_a.sent().type];case 2:return[4,this.setTransport(transport)];case 3:_a.sent();return[2,transport.type]}})})};Client.prototype.getOwnAppMetadata=function(){return __awaiter(this,void 0,void 0,function(){var _a,_b;return __generator(this,function(_c){switch(_c.label){case 0:_a={};_b=get_sender_id_1.getSenderId;return[4,this.beaconId];case 1:return[4,_b.apply(void 0,[_c.sent()])];case 2:return[2,(_a.senderId=_c.sent(),_a.name=this.name,_a.icon=this.iconUrl,_a)]}})})};Client.prototype.getPeers=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.transport];case 1:return[2,_a.sent().getPeers()]}})})};Client.prototype.addPeer=function(peer){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,this.transport];case 1:return[2,_a.sent().addPeer(peer)]}})})};Client.prototype.destroy=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:if(!(this._transport.status===exposed_promise_1.ExposedPromiseStatus.RESOLVED))return[3,3];return[4,this.transport];case 1:return[4,_a.sent().disconnect()];case 2:_a.sent();_a.label=3;case 3:return[4,_super.prototype.destroy.call(this)];case 4:_a.sent();return[2]}})})};Client.prototype.setTransport=function(transport){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:if(transport){if(this._transport.isSettled()){this._transport=exposed_promise_1.ExposedPromise.resolve(transport)}else{this._transport.resolve(transport)}}else{if(this._transport.isSettled()){this._transport=new exposed_promise_1.ExposedPromise}}return[4,this.events.emit(events_1.BeaconEvent.ACTIVE_TRANSPORT_SET,transport)];case 1:_a.sent();return[2]}})})};Client.prototype.addListener=function(transport){return __awaiter(this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){transport.addListener(function(message,connectionInfo){return __awaiter(_this,void 0,void 0,function(){var deserializedMessage;return __generator(this,function(_a){switch(_a.label){case 0:if(!(typeof message==="string"))return[3,2];return[4,(new __1.Serializer).deserialize(message)];case 1:deserializedMessage=_a.sent();this.handleResponse(deserializedMessage,connectionInfo);_a.label=2;case 2:return[2]}})})}).catch(function(error){return logger.error("addListener",error)});return[2]})})};Client.prototype.sendDisconnectToPeer=function(peer,transport){return __awaiter(this,void 0,void 0,function(){var request,_a,_b,payload,selectedTransport,_c;return __generator(this,function(_d){switch(_d.label){case 0:_a={};return[4,generate_uuid_1.generateGUID()];case 1:_a.id=_d.sent(),_a.version=constants_1.BEACON_VERSION;_b=get_sender_id_1.getSenderId;return[4,this.beaconId];case 2:return[4,_b.apply(void 0,[_d.sent()])];case 3:request=(_a.senderId=_d.sent(),_a.type=__1.BeaconMessageType.Disconnect,_a);return[4,(new __1.Serializer).serialize(request)];case 4:payload=_d.sent();if(!(transport!==null&&transport!==void 0))return[3,5];_c=transport;return[3,7];case 5:return[4,this.transport];case 6:_c=_d.sent();_d.label=7;case 7:selectedTransport=_c;return[4,selectedTransport.send(payload,peer)];case 8:_d.sent();return[2]}})})};return Client}(BeaconClient_1.BeaconClient);exports.Client=Client},{"../..":24,"../../constants":9,"../../events":23,"../../managers/AccountManager":27,"../../utils/Logger":79,"../../utils/exposed-promise":84,"../../utils/generate-uuid":85,"../../utils/get-sender-id":87,"../beacon-client/BeaconClient":4}],6:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();var __assign=this&&this.__assign||function(){__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]'+JSON.stringify(this.data,undefined,2)+"
"},enumerable:false,configurable:true});return TransactionInvalidBeaconError}(__1.BeaconError);exports.TransactionInvalidBeaconError=TransactionInvalidBeaconError},{"..":24}],22:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.UnknownBeaconError=void 0;var __1=require("..");var UnknownBeaconError=function(_super){__extends(UnknownBeaconError,_super);function UnknownBeaconError(){var _this=_super.call(this,__1.BeaconErrorType.UNKNOWN_ERROR,"An unknown error occured. Please try again or report it to a developer.")||this;_this.name="UnknownBeaconError";_this.title="Error";return _this}return UnknownBeaconError}(__1.BeaconError);exports.UnknownBeaconError=UnknownBeaconError},{"..":24}],23:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]"+error.title+""},{text:error.description}];if(response.errorResponse.errorType===BeaconErrorType_1.BeaconErrorType.TRANSACTION_INVALID_ERROR&&response.errorResponse.errorData){actions.push({text:"",actionText:"Show Details",actionCallback:function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Toast_1.closeToast()];case 1:_a.sent();return[4,Alert_1.openAlert({title:error.title,body:error.fullDescription,buttons:buttons})];case 2:_a.sent();return[2]}})})}})}return[4,Toast_1.openToast({body:"{{wallet}} has returned an error",timer:response.errorResponse.errorType===BeaconErrorType_1.BeaconErrorType.ABORTED_ERROR?SUCCESS_TIMER:undefined,state:"finished",walletInfo:response.walletInfo,actions:actions})];case 1:_a.sent();return[2]}})})};var showRateLimitReached=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){Alert_1.openAlert({title:"Error",body:"Rate limit reached. Please slow down",buttons:[{text:"Done",style:"outline"}],timer:3e3}).catch(function(toastError){return console.error(toastError)});return[2]})})};var showExtensionConnectedAlert=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Alert_1.closeAlerts()];case 1:_a.sent();return[2]}})})};var showChannelClosedAlert=function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return[4,Alert_1.openAlert({title:"Channel closed",body:"Your peer has closed the connection.",buttons:[{text:"Done",style:"outline"}],timer:1500})];case 1:_a.sent();return[2]}})})};var showInternalErrorAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var alertConfig;return __generator(this,function(_a){switch(_a.label){case 0:alertConfig={title:"Internal Error",body:""+data,buttons:[{text:"Done",style:"outline"}]};return[4,Alert_1.openAlert(alertConfig)];case 1:_a.sent();return[2]}})})};var showPairAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var p2pBase58encoded,postmessageBase58encoded,alertConfig;return __generator(this,function(_a){switch(_a.label){case 0:return[4,serializer.serialize(data.p2pPeerInfo)];case 1:p2pBase58encoded=_a.sent();return[4,serializer.serialize(data.postmessagePeerInfo)];case 2:postmessageBase58encoded=_a.sent();alertConfig={title:"Choose your preferred wallet",body:"",pairingPayload:{p2pSyncCode:p2pBase58encoded,postmessageSyncCode:postmessageBase58encoded,preferredNetwork:data.preferredNetwork},closeButtonCallback:data.abortedHandler};return[4,Alert_1.openAlert(alertConfig)];case 3:_a.sent();return[2]}})})};var showPermissionSuccessAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var output;return __generator(this,function(_a){switch(_a.label){case 0:output=data.output;return[4,Toast_1.openToast({body:"{{wallet}} has granted permission",timer:SUCCESS_TIMER,walletInfo:data.walletInfo,state:"finished",actions:[{text:"Address",actionText:""+shorten_string_1.shortenString(output.address)+""},{text:"Network",actionText:""+output.network.type},{text:"Permissions",actionText:output.scopes.join(", ")}]})];case 1:_a.sent();return[2]}})})};var showOperationSuccessAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var account,output,blockExplorer;return __generator(this,function(_a){switch(_a.label){case 0:account=data.account,output=data.output,blockExplorer=data.blockExplorer;return[4,Toast_1.openToast({body:"{{wallet}} successfully submitted operation",timer:SUCCESS_TIMER,state:"finished",walletInfo:data.walletInfo,actions:[{text:""+shorten_string_1.shortenString(output.transactionHash)+"",actionText:"Open Blockexplorer "+SVG_EXTERNAL,actionCallback:function(){return __awaiter(void 0,void 0,void 0,function(){var link;return __generator(this,function(_a){switch(_a.label){case 0:return[4,blockExplorer.getTransactionLink(output.transactionHash,account.network)];case 1:link=_a.sent();window.open(link,"_blank");return[4,Toast_1.closeToast()];case 2:_a.sent();return[2]}})})}}]})];case 1:_a.sent();return[2]}})})};var showSignSuccessAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var output;return __generator(this,function(_a){switch(_a.label){case 0:output=data.output;return[4,Toast_1.openToast({body:"{{wallet}} successfully signed payload",timer:SUCCESS_TIMER,state:"finished",walletInfo:data.walletInfo,actions:[{text:"Signature: "+shorten_string_1.shortenString(output.signature)+"",actionText:"Copy to clipboard",actionCallback:function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:navigator.clipboard.writeText(output.signature).then(function(){logger.log("showSignSuccessAlert","Copying to clipboard was successful!")},function(err){logger.error("showSignSuccessAlert","Could not copy text to clipboard: ",err)});return[4,Toast_1.closeToast()];case 1:_a.sent();return[2]}})})}}]})];case 1:_a.sent();return[2]}})})};var showBroadcastSuccessAlert=function(data){return __awaiter(void 0,void 0,void 0,function(){var network,output,blockExplorer;return __generator(this,function(_a){switch(_a.label){case 0:network=data.network,output=data.output,blockExplorer=data.blockExplorer;return[4,Toast_1.openToast({body:"{{wallet}} successfully injected operation",timer:SUCCESS_TIMER,state:"finished",walletInfo:data.walletInfo,actions:[{text:""+shorten_string_1.shortenString(output.transactionHash)+"",actionText:"Open Blockexplorer "+SVG_EXTERNAL,actionCallback:function(){return __awaiter(void 0,void 0,void 0,function(){var link;return __generator(this,function(_a){switch(_a.label){case 0:return[4,blockExplorer.getTransactionLink(output.transactionHash,network)];case 1:link=_a.sent();window.open(link,"_blank");return[4,Toast_1.closeToast()];case 2:_a.sent();return[2]}})})}}]})];case 1:_a.sent();return[2]}})})};var emptyHandler=function(){return function(){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(_a){return[2]})})}};exports.defaultEventCallbacks=(_a={},_a[BeaconEvent.PERMISSION_REQUEST_SENT]=showSentToast,_a[BeaconEvent.PERMISSION_REQUEST_SUCCESS]=showPermissionSuccessAlert,_a[BeaconEvent.PERMISSION_REQUEST_ERROR]=showErrorToast,_a[BeaconEvent.OPERATION_REQUEST_SENT]=showSentToast,_a[BeaconEvent.OPERATION_REQUEST_SUCCESS]=showOperationSuccessAlert,_a[BeaconEvent.OPERATION_REQUEST_ERROR]=showErrorToast,_a[BeaconEvent.SIGN_REQUEST_SENT]=showSentToast,_a[BeaconEvent.SIGN_REQUEST_SUCCESS]=showSignSuccessAlert,_a[BeaconEvent.SIGN_REQUEST_ERROR]=showErrorToast,_a[BeaconEvent.BROADCAST_REQUEST_SENT]=showSentToast,_a[BeaconEvent.BROADCAST_REQUEST_SUCCESS]=showBroadcastSuccessAlert,_a[BeaconEvent.BROADCAST_REQUEST_ERROR]=showErrorToast,_a[BeaconEvent.ACKNOWLEDGE_RECEIVED]=showAcknowledgedToast,_a[BeaconEvent.LOCAL_RATE_LIMIT_REACHED]=showRateLimitReached,_a[BeaconEvent.NO_PERMISSIONS]=showNoPermissionAlert,_a[BeaconEvent.ACTIVE_ACCOUNT_SET]=emptyHandler(),_a[BeaconEvent.ACTIVE_TRANSPORT_SET]=emptyHandler(),_a[BeaconEvent.PAIR_INIT]=showPairAlert,_a[BeaconEvent.PAIR_SUCCESS]=showExtensionConnectedAlert,_a[BeaconEvent.CHANNEL_CLOSED]=showChannelClosedAlert,_a[BeaconEvent.INTERNAL_ERROR]=showInternalErrorAlert,_a[BeaconEvent.UNKNOWN]=emptyHandler(),_a);var BeaconEventHandler=function(){function BeaconEventHandler(eventsToOverride,overrideAll){var _a;if(eventsToOverride===void 0){eventsToOverride={}}this.callbackMap=(_a={},_a[BeaconEvent.PERMISSION_REQUEST_SENT]=[exports.defaultEventCallbacks.PERMISSION_REQUEST_SENT],_a[BeaconEvent.PERMISSION_REQUEST_SUCCESS]=[exports.defaultEventCallbacks.PERMISSION_REQUEST_SUCCESS],_a[BeaconEvent.PERMISSION_REQUEST_ERROR]=[exports.defaultEventCallbacks.PERMISSION_REQUEST_ERROR],_a[BeaconEvent.OPERATION_REQUEST_SENT]=[exports.defaultEventCallbacks.OPERATION_REQUEST_SENT],_a[BeaconEvent.OPERATION_REQUEST_SUCCESS]=[exports.defaultEventCallbacks.OPERATION_REQUEST_SUCCESS],_a[BeaconEvent.OPERATION_REQUEST_ERROR]=[exports.defaultEventCallbacks.OPERATION_REQUEST_ERROR],_a[BeaconEvent.SIGN_REQUEST_SENT]=[exports.defaultEventCallbacks.SIGN_REQUEST_SENT],_a[BeaconEvent.SIGN_REQUEST_SUCCESS]=[exports.defaultEventCallbacks.SIGN_REQUEST_SUCCESS],_a[BeaconEvent.SIGN_REQUEST_ERROR]=[exports.defaultEventCallbacks.SIGN_REQUEST_ERROR],_a[BeaconEvent.BROADCAST_REQUEST_SENT]=[exports.defaultEventCallbacks.BROADCAST_REQUEST_SENT],_a[BeaconEvent.BROADCAST_REQUEST_SUCCESS]=[exports.defaultEventCallbacks.BROADCAST_REQUEST_SUCCESS],_a[BeaconEvent.BROADCAST_REQUEST_ERROR]=[exports.defaultEventCallbacks.BROADCAST_REQUEST_ERROR],_a[BeaconEvent.ACKNOWLEDGE_RECEIVED]=[exports.defaultEventCallbacks.ACKNOWLEDGE_RECEIVED],_a[BeaconEvent.LOCAL_RATE_LIMIT_REACHED]=[exports.defaultEventCallbacks.LOCAL_RATE_LIMIT_REACHED],_a[BeaconEvent.NO_PERMISSIONS]=[exports.defaultEventCallbacks.NO_PERMISSIONS],_a[BeaconEvent.ACTIVE_ACCOUNT_SET]=[exports.defaultEventCallbacks.ACTIVE_ACCOUNT_SET],_a[BeaconEvent.ACTIVE_TRANSPORT_SET]=[exports.defaultEventCallbacks.ACTIVE_TRANSPORT_SET],_a[BeaconEvent.PAIR_INIT]=[exports.defaultEventCallbacks.PAIR_INIT],_a[BeaconEvent.PAIR_SUCCESS]=[exports.defaultEventCallbacks.PAIR_SUCCESS],_a[BeaconEvent.CHANNEL_CLOSED]=[exports.defaultEventCallbacks.CHANNEL_CLOSED],_a[BeaconEvent.INTERNAL_ERROR]=[exports.defaultEventCallbacks.INTERNAL_ERROR],_a[BeaconEvent.UNKNOWN]=[exports.defaultEventCallbacks.UNKNOWN],_a);if(overrideAll){this.setAllHandlers()}this.overrideDefaults(eventsToOverride)}BeaconEventHandler.prototype.on=function(event,eventCallback){return __awaiter(this,void 0,void 0,function(){var listeners;return __generator(this,function(_a){listeners=this.callbackMap[event]||[];listeners.push(eventCallback);this.callbackMap[event]=listeners;return[2]})})};BeaconEventHandler.prototype.emit=function(event,data,eventCallback){return __awaiter(this,void 0,void 0,function(){var listeners;var _this=this;return __generator(this,function(_a){listeners=this.callbackMap[event];if(listeners&&listeners.length>0){listeners.forEach(function(listener){return __awaiter(_this,void 0,void 0,function(){var listenerError_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,2,,3]);return[4,listener(data,eventCallback)];case 1:_a.sent();return[3,3];case 2:listenerError_1=_a.sent();logger.error("error handling event "+event,listenerError_1);return[3,3];case 3:return[2]}})})})}return[2]})})};BeaconEventHandler.prototype.overrideDefaults=function(eventsToOverride){var _this=this;Object.keys(eventsToOverride).forEach(function(untypedEvent){var eventType=untypedEvent;var event=eventsToOverride[eventType];if(event){_this.callbackMap[eventType]=[event.handler]}})};BeaconEventHandler.prototype.setAllHandlers=function(handler){var _this=this;Object.keys(this.callbackMap).forEach(function(untypedEvent){var eventType=untypedEvent;_this.callbackMap[eventType]=[];if(handler){_this.callbackMap[eventType].push(handler)}else{_this.callbackMap[eventType].push(function(){var data=[];for(var _i=0;_i0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]