@taquito/taquito 25.0.0-beta.1 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/estimate/errors.js +11 -1
- package/dist/lib/estimate/rpc-estimate-provider.js +171 -10
- package/dist/lib/version.js +2 -2
- package/dist/taquito.es6.js +183 -13
- package/dist/taquito.es6.js.map +1 -1
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.min.js.LICENSE.txt +0 -2
- package/dist/taquito.umd.js +183 -12
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/estimate/errors.d.ts +5 -0
- package/dist/types/estimate/rpc-estimate-provider.d.ts +9 -0
- package/package.json +9 -9
package/dist/taquito.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see taquito.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.taquito=e():t.taquito=e()}(self,()=>(()=>{var t={3447(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6411);function i(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}function s(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}function o(t,e){return void 0===e&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function a(t,e){return void 0===e&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function c(t,e){return void 0===e&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t,e){return void 0===e&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}function l(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}function h(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}function f(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),l(t/4294967296>>>0,e,r),l(t>>>0,e,r+4),e}function d(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),h(t>>>0,e,r),h(t/4294967296>>>0,e,r+4),e}e.readInt16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16},e.readUint16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])>>>0},e.readInt16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])<<16>>16},e.readUint16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])>>>0},e.writeUint16BE=i,e.writeInt16BE=i,e.writeUint16LE=s,e.writeInt16LE=s,e.readInt32BE=o,e.readUint32BE=a,e.readInt32LE=c,e.readUint32LE=u,e.writeUint32BE=l,e.writeInt32BE=l,e.writeUint32LE=h,e.writeInt32LE=h,e.readInt64BE=function(t,e){void 0===e&&(e=0);var r=o(t,e),n=o(t,e+4);return 4294967296*r+n-4294967296*(n>>31)},e.readUint64BE=function(t,e){return void 0===e&&(e=0),4294967296*a(t,e)+a(t,e+4)},e.readInt64LE=function(t,e){void 0===e&&(e=0);var r=c(t,e);return 4294967296*c(t,e+4)+r-4294967296*(r>>31)},e.readUint64LE=function(t,e){void 0===e&&(e=0);var r=u(t,e);return 4294967296*u(t,e+4)+r},e.writeUint64BE=f,e.writeInt64BE=f,e.writeUint64LE=d,e.writeInt64LE=d,e.readUintBE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n},e.readUintLE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n},e.writeUintBE=function(t,e,r,i){if(void 0===r&&(r=new Uint8Array(t/8)),void 0===i&&(i=0),t%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!n.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var s=1,o=t/8+i-1;o>=i;o--)r[o]=e/s&255,s*=256;return r},e.writeUintLE=function(t,e,r,i){if(void 0===r&&(r=new Uint8Array(t/8)),void 0===i&&(i=0),t%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!n.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var s=1,o=i;o<i+t/8;o++)r[o]=e/s&255,s*=256;return r},e.readFloat32BE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e)},e.readFloat32LE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e,!0)},e.readFloat64BE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e)},e.readFloat64LE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e,!0)},e.writeFloat32BE=function(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(r,t),e},e.writeFloat32LE=function(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(r,t,!0),e},e.writeFloat64BE=function(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(r,t),e},e.writeFloat64LE=function(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(r,t,!0),e}},2591(t,e){"use strict";function r(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Object.defineProperty(e,"__esModule",{value:!0}),e.select=function(t,e,r){return~(t-1)&e|t-1&r},e.lessOrEqual=function(t,e){return(0|t)-(0|e)-1>>>31&1},e.compare=r,e.equal=function(t,e){return 0!==t.length&&0!==e.length&&0!==r(t,e)}},6411(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(t,e){var r=65535&t,n=65535&e;return r*n+((t>>>16&65535)*n+r*(e>>>16&65535)<<16>>>0)|0},e.add=function(t,e){return t+e|0},e.sub=function(t,e){return t-e|0},e.rotl=function(t,e){return t<<e|t>>>32-e},e.rotr=function(t,e){return t<<32-e|t>>>e},e.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}},702(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.openBox=e.box=e.precomputeSharedKey=e.generateKeyPair=void 0;const n=r(8877),i=r(1125),s=r(9026),o=r(8767);var a=r(8877);Object.defineProperty(e,"generateKeyPair",{enumerable:!0,get:function(){return a.generateKeyPair}});const c=new Uint8Array(16);function u(t,e){const r=(0,n.scalarMult)(e,t);return(0,i.hsalsa)(r,c,r),r}e.precomputeSharedKey=u,e.box=function(t,e,r,n){const i=u(t,e),a=(0,s.secretBox)(i,r,n);return(0,o.wipe)(i),a},e.openBox=function(t,e,r,n){const i=u(t,e),a=(0,s.openSecretBox)(i,r,n);return(0,o.wipe)(i),a}},2613(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(702),e),i(r(9026),e)},9026(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateKey=e.openSecretBox=e.secretBox=void 0;const n=r(1125),i=r(7591),s=r(8767),o=r(7687);e.secretBox=function(t,e,r){if(24!==e.length)throw new Error("secretBox nonce must be 24 bytes");const o=new Uint8Array(64),a=new Uint8Array(32);a.set(e),(0,n.stream)(t,a,o,8);const c=new Uint8Array(16+r.length);for(let t=0;t<32&&t<r.length;t++)c[16+t]=r[t]^o[32+t];r.length>32&&(0,n.streamXOR)(t,a,r.subarray(32),c.subarray(48),8);const u=(0,i.oneTimeAuth)(o.subarray(0,32),c.subarray(16));for(let t=0;t<u.length;t++)c[t]=u[t];return(0,s.wipe)(u),(0,s.wipe)(o),(0,s.wipe)(a),c},e.openSecretBox=function(t,e,r){if(24!==e.length)throw new Error("secretBox nonce must be 24 bytes");if(r.length<16)throw new Error("secretBox data must be at least 16 bytes");const o=new Uint8Array(64),a=new Uint8Array(32);a.set(e),(0,n.stream)(t,a,o,8);const c=(0,i.oneTimeAuth)(o.subarray(0,32),r.subarray(16));if(!(0,i.equal)(c,r.subarray(0,16)))return null;const u=r.subarray(16),l=new Uint8Array(u.length);for(let t=0;t<32&&t<u.length;t++)l[t]=u[t]^o[32+t];return u.length>32&&(0,n.streamXOR)(t,a,u.subarray(32),l.subarray(32),8),(0,s.wipe)(c),(0,s.wipe)(o),(0,s.wipe)(a),l},e.generateKey=function(t){return(0,o.randomBytes)(32,t)}},7591(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2591),i=r(8767);e.DIGEST_LENGTH=16;var s=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var n=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=t[4]|t[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(t,e,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],l=this._h[6],h=this._h[7],f=this._h[8],d=this._h[9],p=this._r[0],g=this._r[1],m=this._r[2],y=this._r[3],b=this._r[4],v=this._r[5],w=this._r[6],E=this._r[7],_=this._r[8],A=this._r[9];r>=16;){var O=t[e+0]|t[e+1]<<8;i+=8191&O;var S=t[e+2]|t[e+3]<<8;s+=8191&(O>>>13|S<<3);var T=t[e+4]|t[e+5]<<8;o+=8191&(S>>>10|T<<6);var P=t[e+6]|t[e+7]<<8;a+=8191&(T>>>7|P<<9);var R=t[e+8]|t[e+9]<<8;c+=8191&(P>>>4|R<<12),u+=R>>>1&8191;var x=t[e+10]|t[e+11]<<8;l+=8191&(R>>>14|x<<2);var I=t[e+12]|t[e+13]<<8;h+=8191&(x>>>11|I<<5);var N=t[e+14]|t[e+15]<<8,k=0,L=k;L+=i*p,L+=s*(5*A),L+=o*(5*_),L+=a*(5*E),k=(L+=c*(5*w))>>>13,L&=8191,L+=u*(5*v),L+=l*(5*b),L+=h*(5*y),L+=(f+=8191&(I>>>8|N<<8))*(5*m);var C=k+=(L+=(d+=N>>>5|n)*(5*g))>>>13;C+=i*g,C+=s*p,C+=o*(5*A),C+=a*(5*_),k=(C+=c*(5*E))>>>13,C&=8191,C+=u*(5*w),C+=l*(5*v),C+=h*(5*b),C+=f*(5*y),k+=(C+=d*(5*m))>>>13,C&=8191;var M=k;M+=i*m,M+=s*g,M+=o*p,M+=a*(5*A),k=(M+=c*(5*_))>>>13,M&=8191,M+=u*(5*E),M+=l*(5*w),M+=h*(5*v),M+=f*(5*b);var B=k+=(M+=d*(5*y))>>>13;B+=i*y,B+=s*m,B+=o*g,B+=a*p,k=(B+=c*(5*A))>>>13,B&=8191,B+=u*(5*_),B+=l*(5*E),B+=h*(5*w),B+=f*(5*v);var D=k+=(B+=d*(5*b))>>>13;D+=i*b,D+=s*y,D+=o*m,D+=a*g,k=(D+=c*p)>>>13,D&=8191,D+=u*(5*A),D+=l*(5*_),D+=h*(5*E),D+=f*(5*w);var U=k+=(D+=d*(5*v))>>>13;U+=i*v,U+=s*b,U+=o*y,U+=a*m,k=(U+=c*g)>>>13,U&=8191,U+=u*p,U+=l*(5*A),U+=h*(5*_),U+=f*(5*E);var K=k+=(U+=d*(5*w))>>>13;K+=i*w,K+=s*v,K+=o*b,K+=a*y,k=(K+=c*m)>>>13,K&=8191,K+=u*g,K+=l*p,K+=h*(5*A),K+=f*(5*_);var H=k+=(K+=d*(5*E))>>>13;H+=i*E,H+=s*w,H+=o*v,H+=a*b,k=(H+=c*y)>>>13,H&=8191,H+=u*m,H+=l*g,H+=h*p,H+=f*(5*A);var F=k+=(H+=d*(5*_))>>>13;F+=i*_,F+=s*E,F+=o*w,F+=a*v,k=(F+=c*b)>>>13,F&=8191,F+=u*y,F+=l*m,F+=h*g,F+=f*p;var G=k+=(F+=d*(5*A))>>>13;G+=i*A,G+=s*_,G+=o*E,G+=a*w,k=(G+=c*v)>>>13,G&=8191,G+=u*b,G+=l*y,G+=h*m,G+=f*g,i=L=8191&(k=(k=((k+=(G+=d*p)>>>13)<<2)+k|0)+(L&=8191)|0),s=C+=k>>>=13,o=M&=8191,a=B&=8191,c=D&=8191,u=U&=8191,l=K&=8191,h=H&=8191,f=F&=8191,d=G&=8191,e+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=l,this._h[7]=h,this._h[8]=f,this._h[9]=d},t.prototype.finish=function(t,e){void 0===e&&(e=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return t[e+0]=this._h[0]>>>0,t[e+1]=this._h[0]>>>8,t[e+2]=this._h[1]>>>0,t[e+3]=this._h[1]>>>8,t[e+4]=this._h[2]>>>0,t[e+5]=this._h[2]>>>8,t[e+6]=this._h[3]>>>0,t[e+7]=this._h[3]>>>8,t[e+8]=this._h[4]>>>0,t[e+9]=this._h[4]>>>8,t[e+10]=this._h[5]>>>0,t[e+11]=this._h[5]>>>8,t[e+12]=this._h[6]>>>0,t[e+13]=this._h[6]>>>8,t[e+14]=this._h[7]>>>0,t[e+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(t){var e,r=0,n=t.length;if(this._leftover){(e=16-this._leftover)>n&&(e=n);for(var i=0;i<e;i++)this._buffer[this._leftover+i]=t[r+i];if(n-=e,r+=e,this._leftover+=e,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(e=n-n%16,this._blocks(t,r,e),r+=e,n-=e),n){for(i=0;i<n;i++)this._buffer[this._leftover+i]=t[r+i];this._leftover+=n}return this},t.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var t=new Uint8Array(16);return this.finish(t),t},t.prototype.clean=function(){return i.wipe(this._buffer),i.wipe(this._r),i.wipe(this._h),i.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},t}();e.Poly1305=s,e.oneTimeAuth=function(t,e){var r=new s(t);r.update(e);var n=r.digest();return r.clean(),n},e.equal=function(t,r){return t.length===e.DIGEST_LENGTH&&r.length===e.DIGEST_LENGTH&&n.equal(t,r)}},7687(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const n=r(7841),i=r(3447),s=r(8767);function o(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new n.SystemRandomSource,e.randomBytes=o,e.randomUint32=function(t=e.defaultRandomSource){const r=o(4,t),n=(0,i.readUint32LE)(r);return(0,s.wipe)(r),n};const a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(t,r=a,n=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let i="";const c=r.length,u=256-256%c;for(;t>0;){const e=o(Math.ceil(256*t/u),n);for(let n=0;n<e.length&&t>0;n++){const s=e[n];s<u&&(i+=r.charAt(s%c),t--)}(0,s.wipe)(e)}return i}e.randomString=c,e.randomStringForEntropy=function(t,r=a,n=e.defaultRandomSource){return c(Math.ceil(t/(Math.log(r.length)/Math.LN2)),r,n)}},4262(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserRandomSource=void 0;e.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&void 0!==t.getRandomValues&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let t=0;t<e.length;t+=65536)this._crypto.getRandomValues(e.subarray(t,t+Math.min(e.length-t,65536)));return e}}},1052(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NodeRandomSource=void 0;const n=r(8767);e.NodeRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const t=r(5423);t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(t);for(let t=0;t<r.length;t++)r[t]=e[t];return(0,n.wipe)(e),r}}},7841(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SystemRandomSource=void 0;const n=r(4262),i=r(1052);e.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new n.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}},775(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3447),i=r(8767);function s(t,e,r){for(var i,s=1634760805,o=r[3]<<24|r[2]<<16|r[1]<<8|r[0],a=r[7]<<24|r[6]<<16|r[5]<<8|r[4],c=r[11]<<24|r[10]<<16|r[9]<<8|r[8],u=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=857760878,h=e[3]<<24|e[2]<<16|e[1]<<8|e[0],f=e[7]<<24|e[6]<<16|e[5]<<8|e[4],d=e[11]<<24|e[10]<<16|e[9]<<8|e[8],p=e[15]<<24|e[14]<<16|e[13]<<8|e[12],g=2036477234,m=r[19]<<24|r[18]<<16|r[17]<<8|r[16],y=r[23]<<24|r[22]<<16|r[21]<<8|r[20],b=r[27]<<24|r[26]<<16|r[25]<<8|r[24],v=r[31]<<24|r[30]<<16|r[29]<<8|r[28],w=1797285236,E=s,_=o,A=a,O=c,S=u,T=l,P=h,R=f,x=d,I=p,N=g,k=m,L=y,C=b,M=v,B=w,D=0;D<20;D+=2)E^=(i=(L^=(i=(x^=(i=(S^=(i=E+L|0)<<7|i>>>25)+E|0)<<9|i>>>23)+S|0)<<13|i>>>19)+x|0)<<18|i>>>14,T^=(i=(_^=(i=(C^=(i=(I^=(i=T+_|0)<<7|i>>>25)+T|0)<<9|i>>>23)+I|0)<<13|i>>>19)+C|0)<<18|i>>>14,N^=(i=(P^=(i=(A^=(i=(M^=(i=N+P|0)<<7|i>>>25)+N|0)<<9|i>>>23)+M|0)<<13|i>>>19)+A|0)<<18|i>>>14,B^=(i=(k^=(i=(R^=(i=(O^=(i=B+k|0)<<7|i>>>25)+B|0)<<9|i>>>23)+O|0)<<13|i>>>19)+R|0)<<18|i>>>14,E^=(i=(O^=(i=(A^=(i=(_^=(i=E+O|0)<<7|i>>>25)+E|0)<<9|i>>>23)+_|0)<<13|i>>>19)+A|0)<<18|i>>>14,T^=(i=(S^=(i=(R^=(i=(P^=(i=T+S|0)<<7|i>>>25)+T|0)<<9|i>>>23)+P|0)<<13|i>>>19)+R|0)<<18|i>>>14,N^=(i=(I^=(i=(x^=(i=(k^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+k|0)<<13|i>>>19)+x|0)<<18|i>>>14,B^=(i=(M^=(i=(C^=(i=(L^=(i=B+M|0)<<7|i>>>25)+B|0)<<9|i>>>23)+L|0)<<13|i>>>19)+C|0)<<18|i>>>14;n.writeUint32LE(E+s|0,t,0),n.writeUint32LE(_+o|0,t,4),n.writeUint32LE(A+a|0,t,8),n.writeUint32LE(O+c|0,t,12),n.writeUint32LE(S+u|0,t,16),n.writeUint32LE(T+l|0,t,20),n.writeUint32LE(P+h|0,t,24),n.writeUint32LE(R+f|0,t,28),n.writeUint32LE(x+d|0,t,32),n.writeUint32LE(I+p|0,t,36),n.writeUint32LE(N+g|0,t,40),n.writeUint32LE(k+m|0,t,44),n.writeUint32LE(L+y|0,t,48),n.writeUint32LE(C+b|0,t,52),n.writeUint32LE(M+v|0,t,56),n.writeUint32LE(B+w|0,t,60)}function o(t,e,r,n,o){if(void 0===o&&(o=0),32!==t.length)throw new Error("Salsa20: key size must be 32 bytes");if(n.length<r.length)throw new Error("Salsa20: destination is shorter than source");var c,u;if(0===o){if(8!==e.length)throw new Error("Salsa20 nonce must be 8 bytes");(c=new Uint8Array(16)).set(e),u=e.length}else{if(16!==e.length)throw new Error("Salsa20 nonce with counter must be 16 bytes");c=e,u=16-o}for(var l=new Uint8Array(64),h=0;h<r.length;h+=64){s(l,c,t);for(var f=h;f<h+64&&f<r.length;f++)n[f]=r[f]^l[f-h];a(c,u,c.length-u)}return i.wipe(l),0===o&&i.wipe(c),n}function a(t,e,r){for(var n=1;r--;)n=n+(255&t[e])|0,t[e]=255&n,n>>>=8,e++;if(n>0)throw new Error("Salsa20: counter overflow")}e.streamXOR=o,e.stream=function(t,e,r,n){return void 0===n&&(n=0),i.wipe(r),o(t,e,r,r,n)}},8767(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.wipe=function(t){for(var e=0;e<t.length;e++)t[e]=0;return t}},8877(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sharedKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.scalarMultBase=e.scalarMult=e.SHARED_KEY_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=void 0;const n=r(7687),i=r(8767);function s(t){const e=new Float64Array(16);if(t)for(let r=0;r<t.length;r++)e[r]=t[r];return e}e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=32,e.SHARED_KEY_LENGTH=32;const o=new Uint8Array(32);o[0]=9;const a=s([56129,1]);function c(t){let e=1;for(let r=0;r<16;r++){let n=t[r]+e+65535;e=Math.floor(n/65536),t[r]=n-65536*e}t[0]+=e-1+37*(e-1)}function u(t,e,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(t[r]^e[r]);t[r]^=i,e[r]^=i}}function l(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]+r[n]}function h(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]-r[n]}function f(t,e,r){let n,i,s=0,o=0,a=0,c=0,u=0,l=0,h=0,f=0,d=0,p=0,g=0,m=0,y=0,b=0,v=0,w=0,E=0,_=0,A=0,O=0,S=0,T=0,P=0,R=0,x=0,I=0,N=0,k=0,L=0,C=0,M=0,B=r[0],D=r[1],U=r[2],K=r[3],H=r[4],F=r[5],G=r[6],V=r[7],j=r[8],$=r[9],z=r[10],q=r[11],W=r[12],Z=r[13],Y=r[14],X=r[15];n=e[0],s+=n*B,o+=n*D,a+=n*U,c+=n*K,u+=n*H,l+=n*F,h+=n*G,f+=n*V,d+=n*j,p+=n*$,g+=n*z,m+=n*q,y+=n*W,b+=n*Z,v+=n*Y,w+=n*X,n=e[1],o+=n*B,a+=n*D,c+=n*U,u+=n*K,l+=n*H,h+=n*F,f+=n*G,d+=n*V,p+=n*j,g+=n*$,m+=n*z,y+=n*q,b+=n*W,v+=n*Z,w+=n*Y,E+=n*X,n=e[2],a+=n*B,c+=n*D,u+=n*U,l+=n*K,h+=n*H,f+=n*F,d+=n*G,p+=n*V,g+=n*j,m+=n*$,y+=n*z,b+=n*q,v+=n*W,w+=n*Z,E+=n*Y,_+=n*X,n=e[3],c+=n*B,u+=n*D,l+=n*U,h+=n*K,f+=n*H,d+=n*F,p+=n*G,g+=n*V,m+=n*j,y+=n*$,b+=n*z,v+=n*q,w+=n*W,E+=n*Z,_+=n*Y,A+=n*X,n=e[4],u+=n*B,l+=n*D,h+=n*U,f+=n*K,d+=n*H,p+=n*F,g+=n*G,m+=n*V,y+=n*j,b+=n*$,v+=n*z,w+=n*q,E+=n*W,_+=n*Z,A+=n*Y,O+=n*X,n=e[5],l+=n*B,h+=n*D,f+=n*U,d+=n*K,p+=n*H,g+=n*F,m+=n*G,y+=n*V,b+=n*j,v+=n*$,w+=n*z,E+=n*q,_+=n*W,A+=n*Z,O+=n*Y,S+=n*X,n=e[6],h+=n*B,f+=n*D,d+=n*U,p+=n*K,g+=n*H,m+=n*F,y+=n*G,b+=n*V,v+=n*j,w+=n*$,E+=n*z,_+=n*q,A+=n*W,O+=n*Z,S+=n*Y,T+=n*X,n=e[7],f+=n*B,d+=n*D,p+=n*U,g+=n*K,m+=n*H,y+=n*F,b+=n*G,v+=n*V,w+=n*j,E+=n*$,_+=n*z,A+=n*q,O+=n*W,S+=n*Z,T+=n*Y,P+=n*X,n=e[8],d+=n*B,p+=n*D,g+=n*U,m+=n*K,y+=n*H,b+=n*F,v+=n*G,w+=n*V,E+=n*j,_+=n*$,A+=n*z,O+=n*q,S+=n*W,T+=n*Z,P+=n*Y,R+=n*X,n=e[9],p+=n*B,g+=n*D,m+=n*U,y+=n*K,b+=n*H,v+=n*F,w+=n*G,E+=n*V,_+=n*j,A+=n*$,O+=n*z,S+=n*q,T+=n*W,P+=n*Z,R+=n*Y,x+=n*X,n=e[10],g+=n*B,m+=n*D,y+=n*U,b+=n*K,v+=n*H,w+=n*F,E+=n*G,_+=n*V,A+=n*j,O+=n*$,S+=n*z,T+=n*q,P+=n*W,R+=n*Z,x+=n*Y,I+=n*X,n=e[11],m+=n*B,y+=n*D,b+=n*U,v+=n*K,w+=n*H,E+=n*F,_+=n*G,A+=n*V,O+=n*j,S+=n*$,T+=n*z,P+=n*q,R+=n*W,x+=n*Z,I+=n*Y,N+=n*X,n=e[12],y+=n*B,b+=n*D,v+=n*U,w+=n*K,E+=n*H,_+=n*F,A+=n*G,O+=n*V,S+=n*j,T+=n*$,P+=n*z,R+=n*q,x+=n*W,I+=n*Z,N+=n*Y,k+=n*X,n=e[13],b+=n*B,v+=n*D,w+=n*U,E+=n*K,_+=n*H,A+=n*F,O+=n*G,S+=n*V,T+=n*j,P+=n*$,R+=n*z,x+=n*q,I+=n*W,N+=n*Z,k+=n*Y,L+=n*X,n=e[14],v+=n*B,w+=n*D,E+=n*U,_+=n*K,A+=n*H,O+=n*F,S+=n*G,T+=n*V,P+=n*j,R+=n*$,x+=n*z,I+=n*q,N+=n*W,k+=n*Z,L+=n*Y,C+=n*X,n=e[15],w+=n*B,E+=n*D,_+=n*U,A+=n*K,O+=n*H,S+=n*F,T+=n*G,P+=n*V,R+=n*j,x+=n*$,I+=n*z,N+=n*q,k+=n*W,L+=n*Z,C+=n*Y,M+=n*X,s+=38*E,o+=38*_,a+=38*A,c+=38*O,u+=38*S,l+=38*T,h+=38*P,f+=38*R,d+=38*x,p+=38*I,g+=38*N,m+=38*k,y+=38*L,b+=38*C,v+=38*M,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=u,t[5]=l,t[6]=h,t[7]=f,t[8]=d,t[9]=p,t[10]=g,t[11]=m,t[12]=y,t[13]=b,t[14]=v,t[15]=w}function d(t,e){f(t,e,e)}function p(t,e){const r=new Uint8Array(32),n=new Float64Array(80),i=s(),o=s(),p=s(),g=s(),m=s(),y=s();for(let e=0;e<31;e++)r[e]=t[e];r[31]=127&t[31]|64,r[0]&=248,function(t,e){for(let r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}(n,e);for(let t=0;t<16;t++)o[t]=n[t];i[0]=g[0]=1;for(let t=254;t>=0;--t){const e=r[t>>>3]>>>(7&t)&1;u(i,o,e),u(p,g,e),l(m,i,p),h(i,i,p),l(p,o,g),h(o,o,g),d(g,m),d(y,i),f(i,p,i),f(p,o,m),l(m,i,p),h(i,i,p),d(o,i),h(p,g,y),f(i,p,a),l(i,i,g),f(p,p,i),f(i,g,y),f(g,o,n),d(o,m),u(i,o,e),u(p,g,e)}for(let t=0;t<16;t++)n[t+16]=i[t],n[t+32]=p[t],n[t+48]=o[t],n[t+64]=g[t];const b=n.subarray(32),v=n.subarray(16);!function(t,e){const r=s();for(let t=0;t<16;t++)r[t]=e[t];for(let t=253;t>=0;t--)d(r,r),2!==t&&4!==t&&f(r,r,e);for(let e=0;e<16;e++)t[e]=r[e]}(b,b),f(v,v,b);const w=new Uint8Array(32);return function(t,e){const r=s(),n=s();for(let t=0;t<16;t++)n[t]=e[t];c(n),c(n),c(n);for(let t=0;t<2;t++){r[0]=n[0]-65517;for(let t=1;t<15;t++)r[t]=n[t]-65535-(r[t-1]>>16&1),r[t-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const t=r[15]>>16&1;r[14]&=65535,u(n,r,1-t)}for(let e=0;e<16;e++)t[2*e]=255&n[e],t[2*e+1]=n[e]>>8}(w,v),w}function g(t){return p(t,o)}function m(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${e.SECRET_KEY_LENGTH} bytes`);const r=new Uint8Array(t);return{publicKey:g(r),secretKey:r}}e.scalarMult=p,e.scalarMultBase=g,e.generateKeyPairFromSeed=m,e.generateKeyPair=function(t){const e=(0,n.randomBytes)(32,t),r=m(e);return(0,i.wipe)(e),r},e.sharedKey=function(t,r,n=!1){if(t.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const i=p(t,r);if(n){let t=0;for(let e=0;e<i.length;e++)t|=i[e];if(0===t)throw new Error("X25519: invalid shared key")}return i}},1125(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3447),i=r(775),s=r(8767);function o(t,e,r,n,o){if(void 0===o&&(o=0),0===o){if(24!==e.length)throw new Error("XSalsa20 nonce must be 24 bytes")}else if(32!==e.length)throw new Error("XSalsa20 nonce with counter must be 32 bytes");var c=a(t,e.subarray(0,16),new Uint8Array(32)),u=i.streamXOR(c,e.subarray(16),r,n,o);return s.wipe(c),u}e.streamXOR=o,e.stream=function(t,e,r,n){return void 0===n&&(n=0),s.wipe(r),o(t,e,r,r,n)};function a(t,e,r){for(var i,s=1634760805,o=t[3]<<24|t[2]<<16|t[1]<<8|t[0],a=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],u=t[15]<<24|t[14]<<16|t[13]<<8|t[12],l=857760878,h=e[3]<<24|e[2]<<16|e[1]<<8|e[0],f=e[7]<<24|e[6]<<16|e[5]<<8|e[4],d=e[11]<<24|e[10]<<16|e[9]<<8|e[8],p=e[15]<<24|e[14]<<16|e[13]<<8|e[12],g=2036477234,m=t[19]<<24|t[18]<<16|t[17]<<8|t[16],y=t[23]<<24|t[22]<<16|t[21]<<8|t[20],b=t[27]<<24|t[26]<<16|t[25]<<8|t[24],v=t[31]<<24|t[30]<<16|t[29]<<8|t[28],w=1797285236,E=0;E<20;E+=2)s^=(i=(y^=(i=(d^=(i=(u^=(i=s+y|0)<<7|i>>>25)+s|0)<<9|i>>>23)+u|0)<<13|i>>>19)+d|0)<<18|i>>>14,l^=(i=(o^=(i=(b^=(i=(p^=(i=l+o|0)<<7|i>>>25)+l|0)<<9|i>>>23)+p|0)<<13|i>>>19)+b|0)<<18|i>>>14,g^=(i=(h^=(i=(a^=(i=(v^=(i=g+h|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(m^=(i=(f^=(i=(c^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,l^=(i=(u^=(i=(f^=(i=(h^=(i=l+u|0)<<7|i>>>25)+l|0)<<9|i>>>23)+h|0)<<13|i>>>19)+f|0)<<18|i>>>14,g^=(i=(p^=(i=(d^=(i=(m^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+d|0)<<18|i>>>14,w^=(i=(v^=(i=(b^=(i=(y^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+y|0)<<13|i>>>19)+b|0)<<18|i>>>14;return n.writeUint32LE(s,r,0),n.writeUint32LE(l,r,4),n.writeUint32LE(g,r,8),n.writeUint32LE(w,r,12),n.writeUint32LE(h,r,16),n.writeUint32LE(f,r,20),n.writeUint32LE(d,r,24),n.writeUint32LE(p,r,28),r}e.hsalsa=a},7403(t){"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),s=i.charCodeAt(0);if(255!==e[s])throw new TypeError(i+" is ambiguous");e[s]=n}var o=t.length,a=t.charAt(0),c=Math.log(o)/Math.log(256),u=Math.log(256)/Math.log(o);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var s=(t.length-r)*c+1>>>0,u=new Uint8Array(s);t[r];){var l=t.charCodeAt(r);if(l>255)return;var h=e[l];if(255===h)return;for(var f=0,d=s-1;(0!==h||f<i)&&-1!==d;d--,f++)h+=o*u[d]>>>0,u[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=f,r++}for(var p=s-i;p!==s&&0===u[p];)p++;for(var g=new Uint8Array(n+(s-p)),m=n;p!==s;)g[m++]=u[p++];return g}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,s=e.length;i!==s&&0===e[i];)i++,r++;for(var c=(s-i)*u+1>>>0,l=new Uint8Array(c);i!==s;){for(var h=e[i],f=0,d=c-1;(0!==h||f<n)&&-1!==d;d--,f++)h+=256*l[d]>>>0,l[d]=h%o>>>0,h=h/o>>>0;if(0!==h)throw new Error("Non-zero carry");n=f,i++}for(var p=c-n;p!==c&&0===l[p];)p++;for(var g=a.repeat(r);p<c;++p)g+=t.charAt(l[p]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+o+" character")}}}},2823(t,e,r){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8379).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function c(t,e,r){var n=a(t,r);return r-1>=e&&(n|=a(t,r-1)<<4),n}function u(t,e,r,i){for(var s=0,o=0,a=Math.min(t.length,r),c=e;c<a;c++){var u=t.charCodeAt(c)-48;s*=i,o=u>=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&o<i,"Invalid character"),s+=o}return s}function l(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var s,o,a=0;if("be"===r)for(i=t.length-1,s=0;i>=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(i=0,s=0;i<t.length;i+=3)o=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,s=0,o=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=c(t,e,n)<<s,this.words[o]|=67108863&i,s>=18?(s-=18,o+=1,this.words[o]|=i>>>26):s+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=c(t,e,n)<<s,this.words[o]|=67108863&i,s>=18?(s-=18,o+=1,this.words[o]|=i>>>26):s+=8;this._strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,c=0,l=r;l<a;l+=n)c=u(t,l,l+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==o){var h=1;for(c=u(t,l,t.length,e),l=0;l<o;l++)h*=e;this.imuln(h),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype._move=function(t){l(t,this)},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){s.prototype.inspect=h}else s.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,s=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<i|s)).toString(16);s=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,o--),r=0!==s||o!==this.length-1?f[6-c.length]+c+r:c+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=p[t];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var g=h.modrn(l).toString(t);r=(h=h.idivn(l)).isZero()?g+r:f[u-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function g(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=c>>>26,h=67108863&c,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(o=(i=0|t.words[p])*(s=0|e.words[d])+h)/67108864|0,h=67108863&o}r.words[u]=0|h,c=0|l}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}s.prototype.toArrayLike=function(t,e,r){this._strip();var i=this.byteLength(),s=r||Math.max(1,i);n(i<=s,"byte array longer than desired length"),n(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,i),o},s.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,s=0;i<this.length;i++){var o=this.words[i]<<s|n;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===s?(r<t.length&&(t[r++]=o>>24&255),n=0,s=0):(n=o>>>24,s+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},s.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,s=0;i<this.length;i++){var o=this.words[i]<<s|n;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),n=0,s=0):(n=o>>>24,s+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},s.prototype.ior=function(t){return n(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},s.prototype.iand=function(t){return n(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},s.prototype.ixor=function(t){return n(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this._strip()},s.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s<n.length;s++)e=(0|r.words[s])+(0|n.words[s])+i,this.words[s]=67108863&e,i=e>>>26;for(;0!==i&&s<r.length;s++)e=(0|r.words[s])+i,this.words[s]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o<n.length;o++)s=(e=(0|r.words[o])-(0|n.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var n,i,s,o=t.words,a=e.words,c=r.words,u=0,l=0|o[0],h=8191&l,f=l>>>13,d=0|o[1],p=8191&d,g=d>>>13,m=0|o[2],y=8191&m,b=m>>>13,v=0|o[3],w=8191&v,E=v>>>13,_=0|o[4],A=8191&_,O=_>>>13,S=0|o[5],T=8191&S,P=S>>>13,R=0|o[6],x=8191&R,I=R>>>13,N=0|o[7],k=8191&N,L=N>>>13,C=0|o[8],M=8191&C,B=C>>>13,D=0|o[9],U=8191&D,K=D>>>13,H=0|a[0],F=8191&H,G=H>>>13,V=0|a[1],j=8191&V,$=V>>>13,z=0|a[2],q=8191&z,W=z>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,lt=0|a[8],ht=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(n=Math.imul(h,F))|0)+((8191&(i=(i=Math.imul(h,G))+Math.imul(f,F)|0))<<13)|0;u=((s=Math.imul(f,G))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(p,F),i=(i=Math.imul(p,G))+Math.imul(g,F)|0,s=Math.imul(g,G);var yt=(u+(n=n+Math.imul(h,j)|0)|0)+((8191&(i=(i=i+Math.imul(h,$)|0)+Math.imul(f,j)|0))<<13)|0;u=((s=s+Math.imul(f,$)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,F),i=(i=Math.imul(y,G))+Math.imul(b,F)|0,s=Math.imul(b,G),n=n+Math.imul(p,j)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,j)|0,s=s+Math.imul(g,$)|0;var bt=(u+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(f,q)|0))<<13)|0;u=((s=s+Math.imul(f,W)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(w,F),i=(i=Math.imul(w,G))+Math.imul(E,F)|0,s=Math.imul(E,G),n=n+Math.imul(y,j)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(b,j)|0,s=s+Math.imul(b,$)|0,n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,q)|0,s=s+Math.imul(g,W)|0;var vt=(u+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,X)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,F),i=(i=Math.imul(A,G))+Math.imul(O,F)|0,s=Math.imul(O,G),n=n+Math.imul(w,j)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,j)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(b,q)|0,s=s+Math.imul(b,W)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(f,Q)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(T,F),i=(i=Math.imul(T,G))+Math.imul(P,F)|0,s=Math.imul(P,G),n=n+Math.imul(A,j)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(O,j)|0,s=s+Math.imul(O,$)|0,n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(E,q)|0,s=s+Math.imul(E,W)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,s=s+Math.imul(g,tt)|0;var Et=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(x,F),i=(i=Math.imul(x,G))+Math.imul(I,F)|0,s=Math.imul(I,G),n=n+Math.imul(T,j)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(P,j)|0,s=s+Math.imul(P,$)|0,n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(O,q)|0,s=s+Math.imul(O,W)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,nt)|0;var _t=(u+(n=n+Math.imul(h,st)|0)|0)+((8191&(i=(i=i+Math.imul(h,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(k,F),i=(i=Math.imul(k,G))+Math.imul(L,F)|0,s=Math.imul(L,G),n=n+Math.imul(x,j)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(I,j)|0,s=s+Math.imul(I,$)|0,n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,W)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var At=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(f,ct)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(M,F),i=(i=Math.imul(M,G))+Math.imul(B,F)|0,s=Math.imul(B,G),n=n+Math.imul(k,j)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(L,j)|0,s=s+Math.imul(L,$)|0,n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,W)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,nt)|0,n=n+Math.imul(y,st)|0,i=(i=i+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(g,ct)|0,s=s+Math.imul(g,ut)|0;var Ot=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,ft)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(U,F),i=(i=Math.imul(U,G))+Math.imul(K,F)|0,s=Math.imul(K,G),n=n+Math.imul(M,j)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(B,j)|0,s=s+Math.imul(B,$)|0,n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(L,q)|0,s=s+Math.imul(L,W)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,n=n+Math.imul(y,ct)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(b,ct)|0,s=s+Math.imul(b,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(g,ht)|0,s=s+Math.imul(g,ft)|0;var St=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,gt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(U,j),i=(i=Math.imul(U,$))+Math.imul(K,j)|0,s=Math.imul(K,$),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,s=s+Math.imul(B,W)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(L,Y)|0,s=s+Math.imul(L,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,nt)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(E,ct)|0,s=s+Math.imul(E,ut)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ft)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ft)|0;var Tt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((s=s+Math.imul(g,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(U,q),i=(i=Math.imul(U,W))+Math.imul(K,q)|0,s=Math.imul(K,W),n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(B,Y)|0,s=s+Math.imul(B,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(L,Q)|0,s=s+Math.imul(L,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,nt)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,n=n+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(O,ct)|0,s=s+Math.imul(O,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,ft)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ft)|0;var Pt=(u+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(U,Y),i=(i=Math.imul(U,X))+Math.imul(K,Y)|0,s=Math.imul(K,X),n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,Q)|0,s=s+Math.imul(B,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(L,rt)|0,s=s+Math.imul(L,nt)|0,n=n+Math.imul(x,st)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,n=n+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(P,ct)|0,s=s+Math.imul(P,ut)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ft)|0;var Rt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(U,Q),i=(i=Math.imul(U,tt))+Math.imul(K,Q)|0,s=Math.imul(K,tt),n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,s=s+Math.imul(B,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(L,st)|0,s=s+Math.imul(L,ot)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ut)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ft)|0;var xt=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,gt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,gt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(U,rt),i=(i=Math.imul(U,nt))+Math.imul(K,rt)|0,s=Math.imul(K,nt),n=n+Math.imul(M,st)|0,i=(i=i+Math.imul(M,ot)|0)+Math.imul(B,st)|0,s=s+Math.imul(B,ot)|0,n=n+Math.imul(k,ct)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(L,ct)|0,s=s+Math.imul(L,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,ft)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ft)|0;var It=(u+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(U,st),i=(i=Math.imul(U,ot))+Math.imul(K,st)|0,s=Math.imul(K,ot),n=n+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(B,ct)|0,s=s+Math.imul(B,ut)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ft)|0)+Math.imul(L,ht)|0,s=s+Math.imul(L,ft)|0;var Nt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,gt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,gt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(U,ct),i=(i=Math.imul(U,ut))+Math.imul(K,ct)|0,s=Math.imul(K,ut),n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(B,ht)|0,s=s+Math.imul(B,ft)|0;var kt=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((s=s+Math.imul(L,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(U,ht),i=(i=Math.imul(U,ft))+Math.imul(K,ht)|0,s=Math.imul(K,ft);var Lt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,gt)|0)+Math.imul(B,pt)|0))<<13)|0;u=((s=s+Math.imul(B,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var Ct=(u+(n=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,gt))+Math.imul(K,pt)|0))<<13)|0;return u=((s=Math.imul(K,gt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,c[0]=mt,c[1]=yt,c[2]=bt,c[3]=vt,c[4]=wt,c[5]=Et,c[6]=_t,c[7]=At,c[8]=Ot,c[9]=St,c[10]=Tt,c[11]=Pt,c[12]=Rt,c[13]=xt,c[14]=It,c[15]=Nt,c[16]=kt,c[17]=Lt,c[18]=Ct,0!==u&&(c[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s<r.length-1;s++){var o=i;i=0;for(var a=67108863&n,c=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=c;u++){var l=s-u,h=(0|t.words[l])*(0|e.words[u]),f=67108863&h;a=67108863&(f=f+a|0),i+=(o=(o=o+(h/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r._strip()}function b(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=g),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?g(this,t,e):r<1024?y(this,t,e):b(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},v.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o<s;o++)n[o]=e[t[o]],i[o]=r[t[o]]},v.prototype.transform=function(t,e,r,n,i,s){this.permute(s,t,e,r,n,i);for(var o=1;o<i;o<<=1)for(var a=o<<1,c=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var h=c,f=u,d=0;d<o;d++){var p=r[l+d],g=n[l+d],m=r[l+d+o],y=n[l+d+o],b=h*m-f*y;y=h*y+f*m,m=b,r[l+d]=p+m,n[l+d]=g+y,r[l+d+o]=p-m,n[l+d+o]=g-y,d!==a&&(b=c*h-u*f,f=c*f+u*h,h=b)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},v.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},v.prototype.convert13b=function(t,e,r,i){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<i;++o)r[o]=0;n(0===s),n(!(-8192&s))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),s=this.stub(n),o=new Array(n),a=new Array(n),c=new Array(n),u=new Array(n),l=new Array(n),h=new Array(n),f=r.words;f.length=n,this.convert13b(t.words,t.length,o,n),this.convert13b(e.words,e.length,u,n),this.transform(o,s,a,c,n,i),this.transform(u,s,l,h,n,i);for(var d=0;d<n;d++){var p=a[d]*l[d]-c[d]*h[d];c[d]=a[d]*h[d]+c[d]*l[d],a[d]=p}return this.conjugate(a,c,n),this.transform(a,c,f,s,n,i),this.conjugate(f,s,n),this.normalize13b(f,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),b(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,i=0;i<this.length;i++){var s=(0|this.words[i])*t,o=(67108863&s)+(67108863&r);r>>=26,r+=s/67108864|0,r+=o>>>26,this.words[i]=67108863&o}return 0!==r&&(this.words[i]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r},s.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,c=(0|this.words[e])-a<<r;this.words[e]=c|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},s.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,c=r;if(i-=o,i=Math.max(0,i),c){for(var u=0;u<o;u++)c.words[u]=this.words[u];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var h=0|this.words[u];this.words[u]=l<<26-s|h>>>s,l=h&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},s.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return 0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var i,s,o=t.length+r;this._expand(o);var a=0;for(i=0;i<t.length;i++){s=(0|this.words[i+r])+a;var c=(0|t.words[i])*e;a=((s-=67108863&c)>>26)-(c/67108864|0),this.words[i+r]=67108863&s}for(;i<this.length-r;i++)a=(s=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&s;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(s=-(0|this.words[i])+a)>>26,this.words[i]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==e){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(i,1,c);0===l.negative&&(n=l,a&&(a.words[c]=1));for(var h=c-1;h>=0;h--){var f=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(f=Math.min(f/o|0,67108863),n._ishlnsubmul(i,f,h);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=f)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,s=this.length-1;s>=0;s--)i=(r*i+(0|this.words[s]))%t;return e?-i:i},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var s=(0|this.words[i])+67108864*r;this.words[i]=s/t|0,r=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),h=e.clone();!e.isZero();){for(var f=0,d=1;0===(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(l),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var p=0,g=1;0===(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),o.isub(c)):(r.isub(e),a.isub(i),c.isub(o))}return{a,b:c,gcd:r.iushln(u)}},s.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0===(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var h=0,f=1;0===(r.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var s=i,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new T(t)},s.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function E(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function O(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function T(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function P(t){T.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}E.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},E.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},E.prototype.split=function(t,e){t.iushrn(this.n,0,e)},E.prototype.imulK=function(t){return t.imul(this.k)},i(_,E),_.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[i-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(A,E),i(O,E),i(S,E),S.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new A;else if("p192"===t)e=new O;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return w[t]=e,e},T.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},T.prototype._verify2=function(t,e){n(0===(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},T.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},T.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},T.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},T.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},T.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},T.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},T.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},T.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},T.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},T.prototype.isqr=function(t){return this.imul(t,t.clone())},T.prototype.sqr=function(t){return this.mul(t,t)},T.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var h=this.pow(l,i),f=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();n(m<p);var y=this.pow(h,new s(1).iushln(p-m-1));f=f.redMul(y),h=y.redSqr(),d=d.redMul(h),p=m}return f},T.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},T.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],o=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=c-1;l>=0;l--){var h=u>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==o?(o<<=1,o|=h,(4===++a||0===n&&0===l)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}c=26}return i},T.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},T.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new P(t)},i(P,T),P.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},P.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},P.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},P.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},9216(t,e,r){const n=r(7403);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},7639(t,e,r){"use strict";var n=r(9216);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=Uint8Array.from(e),i=t(r),s=r.length+4,o=new Uint8Array(s);return o.set(r,0),o.set(i.subarray(0,4),r.length),n.encode(o,s)},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)}}}},9848(t,e,r){"use strict";var{sha256:n}=r(2001),i=r(7639);t.exports=i(function(t){return n(n(t))})},6075(t){"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]},s={key:n,value:t[n]};return r(i,s)}}),s=[];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,o;if(Array.isArray(e)){for(o="[",r=0;r<e.length;r++)r&&(o+=","),o+=t(e[r])||"null";return o+"]"}if(null===e)return"null";if(-1!==s.indexOf(e)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(e)-1,c=Object.keys(e).sort(i&&i(e));for(o="",r=0;r<c.length;r++){var u=c[r],l=t(e[u]);l&&(o&&(o+=","),o+=JSON.stringify(u)+":"+l)}return s.splice(a,1),"{"+o+"}"}}(t)}},3737(t,e,r){!function(t){"use strict";function e(t){for(var e=0,r=Math.min(65536,t.length+1),n=new Uint16Array(r),i=[],s=0;;){var o=e<t.length;if(!o||s>=r-1){var a=n.subarray(0,s);if(i.push(String.fromCharCode.apply(null,a)),!o)return i.join("");t=t.subarray(e),e=0,s=0}var c=t[e++];if(128&c){if(192==(224&c)){var u=63&t[e++];n[s++]=(31&c)<<6|u}else if(224==(240&c)){u=63&t[e++];var l=63&t[e++];n[s++]=(31&c)<<12|u<<6|l}else if(240==(248&c)){var h=(7&c)<<18|(u=63&t[e++])<<12|(l=63&t[e++])<<6|63&t[e++];h>65535&&(h-=65536,n[s++]=h>>>10&1023|55296,h=56320|1023&h),n[s++]=h}}else n[s++]=c}}var r="Failed to ",n=function(t,e,n){if(t)throw new Error("".concat(r).concat(e,": the '").concat(n,"' option is unsupported."))},i="function"==typeof Buffer&&Buffer.from,s=i?function(t){return Buffer.from(t)}:function(t){for(var e=0,r=t.length,n=0,i=Math.max(32,r+(r>>>1)+7),s=new Uint8Array(i>>>3<<3);e<r;){var o=t.charCodeAt(e++);if(o>=55296&&o<=56319){if(e<r){var a=t.charCodeAt(e);56320==(64512&a)&&(++e,o=((1023&o)<<10)+(1023&a)+65536)}if(o>=55296&&o<=56319)continue}if(n+4>s.length){i+=8,i=(i*=1+e/t.length*2)>>>3<<3;var c=new Uint8Array(i);c.set(s),s=c}if(4294967168&o){if(4294965248&o)if(4294901760&o){if(4292870144&o)continue;s[n++]=o>>>18&7|240,s[n++]=o>>>12&63|128,s[n++]=o>>>6&63|128}else s[n++]=o>>>12&15|224,s[n++]=o>>>6&63|128;else s[n++]=o>>>6&31|192;s[n++]=63&o|128}else s[n++]=o}return s.slice?s.slice(0,n):s.subarray(0,n)};function o(){this.encoding="utf-8"}o.prototype.encode=function(t,e){return n(e&&e.stream,"encode","stream"),s(t)};var a=!i&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,c=["utf-8","utf8","unicode-1-1-utf-8"],u=e;i?u=function(t,e){return(t instanceof Buffer?t:Buffer.from(t.buffer,t.byteOffset,t.byteLength)).toString(e)}:a&&(u=function(t){try{return function(t){var e;try{var r=new Blob([t],{type:"text/plain;charset=UTF-8"});e=URL.createObjectURL(r);var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(),n.responseText}finally{e&&URL.revokeObjectURL(e)}}(t)}catch(r){return e(t)}});var l="construct 'TextDecoder'",h="".concat(r," ").concat(l,": the ");function f(t,e){if(n(e&&e.fatal,l,"fatal"),t=t||"utf-8",!(i?Buffer.isEncoding(t):-1!==c.indexOf(t.toLowerCase())))throw new RangeError("".concat(h," encoding label provided ('").concat(t,"') is invalid."));this.encoding=t,this.fatal=!1,this.ignoreBOM=!1}f.prototype.decode=function(t,e){var r;return n(e&&e.stream,"decode","stream"),r=t instanceof Uint8Array?t:t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer):new Uint8Array(t),u(r,this.encoding)},t.TextEncoder=t.TextEncoder||o,t.TextDecoder=t.TextDecoder||f}("undefined"!=typeof window?window:void 0!==r.g?r.g:this)},1948(t,e,r){"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>J.k,AsyncSubject:()=>y.h,BehaviorSubject:()=>g.t,ConnectableObservable:()=>i.G,EMPTY:()=>yt.w,EmptyError:()=>Z.G,NEVER:()=>Ut,NotFoundError:()=>Q.m,Notification:()=>V.Eg,NotificationKind:()=>V.Ij,ObjectUnsubscribedError:()=>tt.P,Observable:()=>n.c,ReplaySubject:()=>m.m,Scheduler:()=>F._,SequenceError:()=>et.I,Subject:()=>p.B,Subscriber:()=>G.vU,Subscription:()=>c.yU,TimeoutError:()=>rt.M,UnsubscriptionError:()=>nt.Z,VirtualAction:()=>H,VirtualTimeScheduler:()=>K,animationFrame:()=>U,animationFrameScheduler:()=>D,animationFrames:()=>l,asap:()=>x,asapScheduler:()=>R,async:()=>I.b,asyncScheduler:()=>I.E,audit:()=>te.s,auditTime:()=>ee.Z,bindCallback:()=>ut,bindNodeCallback:()=>lt,buffer:()=>re.r,bufferCount:()=>ne.S,bufferTime:()=>ie.w,bufferToggle:()=>se.H,bufferWhen:()=>oe.n,catchError:()=>ae.W,combineAll:()=>ce.p,combineLatest:()=>ht.z,combineLatestAll:()=>ue.A,combineLatestWith:()=>le.v,concat:()=>ft.x,concatAll:()=>he.K,concatMap:()=>fe.H,concatMapTo:()=>de.S,concatWith:()=>pe.$,config:()=>Qt.$,connect:()=>ge.N,connectable:()=>mt,count:()=>me.U,debounce:()=>ye.s,debounceTime:()=>be.B,defaultIfEmpty:()=>ve.U,defer:()=>pt,delay:()=>we.c,delayWhen:()=>Ee.o,dematerialize:()=>_e.Z,distinct:()=>Ae.d,distinctUntilChanged:()=>Oe.F,distinctUntilKeyChanged:()=>Se.w,elementAt:()=>Te.s,empty:()=>yt.I,endWith:()=>Pe.q,every:()=>Re.S,exhaust:()=>xe.B,exhaustAll:()=>Ie.C,exhaustMap:()=>Ne.p,expand:()=>ke.f,filter:()=>jt.p,finalize:()=>Le.j,find:()=>Ce.I,findIndex:()=>Me.S,first:()=>Be.$,firstValueFrom:()=>X,flatMap:()=>$e.q,forkJoin:()=>_t,from:()=>At.H,fromEvent:()=>xt,fromEventPattern:()=>Nt,generate:()=>Lt,groupBy:()=>De.$,identity:()=>z.D,ignoreElements:()=>Ue.w,iif:()=>Ct,interval:()=>Mt.Y,isEmpty:()=>Ke.I,isObservable:()=>W,last:()=>He.H,lastValueFrom:()=>Y,map:()=>Fe.T,mapTo:()=>Ge.u,materialize:()=>Ve.O,max:()=>je.T,merge:()=>Dt,mergeAll:()=>Bt.U,mergeMap:()=>Ot.Z,mergeMapTo:()=>ze.C,mergeScan:()=>qe.i,mergeWith:()=>We.X,min:()=>Ze.j,multicast:()=>Ye.f,never:()=>Kt,noop:()=>$.l,observable:()=>s.s,observeOn:()=>at.Q,of:()=>Ht.of,onErrorResumeNext:()=>Ft.g,onErrorResumeNextWith:()=>Xe.w,pairs:()=>Gt,pairwise:()=>Je.J,partition:()=>$t,pipe:()=>j.F,pluck:()=>Qe.E,publish:()=>tr.m,publishBehavior:()=>er.K,publishLast:()=>rr.k,publishReplay:()=>nr.H,queue:()=>C,queueScheduler:()=>L,race:()=>zt.O,raceWith:()=>ir.w,range:()=>qt,reduce:()=>sr.T,refCount:()=>lr.B,repeat:()=>or.u,repeatWhen:()=>ar.Y,retry:()=>cr.L,retryWhen:()=>ur.l,sample:()=>hr.X,sampleTime:()=>fr.q,scan:()=>dr.S,scheduled:()=>Jt.c,sequenceEqual:()=>pr.m,share:()=>gr.u,shareReplay:()=>mr.t,single:()=>yr.J,skip:()=>br.i,skipLast:()=>vr.G,skipUntil:()=>wr.U,skipWhile:()=>Er.j,startWith:()=>_r.Z,subscribeOn:()=>st._,switchAll:()=>Ar.w,switchMap:()=>Or.n,switchMapTo:()=>Sr.K,switchScan:()=>Tr.m,take:()=>Pr.s,takeLast:()=>Rr.o,takeUntil:()=>xr.Q,takeWhile:()=>Ir.v,tap:()=>Nr.M,throttle:()=>kr.n,throttleTime:()=>Lr.c,throwError:()=>Wt.$,throwIfEmpty:()=>Cr.v,timeInterval:()=>Mr.f,timeout:()=>rt.w,timeoutWith:()=>Br.o,timer:()=>Zt.O,timestamp:()=>Dr.v,toArray:()=>Ur.$,using:()=>Yt,window:()=>Kr.x,windowCount:()=>Hr.k,windowTime:()=>Fr.s,windowToggle:()=>Gr.J,windowWhen:()=>Vr.p,withLatestFrom:()=>jr.E,zip:()=>Xt.y,zipAll:()=>$r.x,zipWith:()=>zr.O});var n=r(1824),i=r(5900),s=r(9805),o={now:function(){return(o.delegate||performance).now()},delegate:void 0},a=r(5608),c=r(1868),u={schedule:function(t){var e=requestAnimationFrame,r=cancelAnimationFrame,n=u.delegate;n&&(e=n.requestAnimationFrame,r=n.cancelAnimationFrame);var i=e(function(e){r=void 0,t(e)});return new c.yU(function(){return null==r?void 0:r(i)})},requestAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=u.delegate;return((null==r?void 0:r.requestAnimationFrame)||requestAnimationFrame).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},cancelAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=u.delegate;return((null==r?void 0:r.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},delegate:void 0};function l(t){return t?h(t):d}function h(t){return new n.c(function(e){var r=t||o,n=r.now(),i=0,s=function(){e.closed||(i=u.requestAnimationFrame(function(o){i=0;var a=r.now();e.next({timestamp:t?a:o,elapsed:a-n}),s()}))};return s(),function(){i&&u.cancelAnimationFrame(i)}})}var f,d=h(),p=r(9097),g=r(5923),m=r(5404),y=r(5445),b=r(7771),v=1,w={};function E(t){return t in w&&(delete w[t],!0)}var _=function(t){var e=v++;return w[e]=!0,f||(f=Promise.resolve()),f.then(function(){return E(e)&&t()}),e},A=function(t){E(t)},O={setImmediate:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=O.delegate;return((null==r?void 0:r.setImmediate)||_).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},clearImmediate:function(t){var e=O.delegate;return((null==e?void 0:e.clearImmediate)||A)(t)},delegate:void 0},S=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=O.setImmediate(e.flush.bind(e,void 0))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var s=e.actions;null!=r&&(null===(i=s[s.length-1])||void 0===i?void 0:i.id)!==r&&(O.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},e}(b.R),T=r(7042),P=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e.prototype.flush=function(t){this._active=!0;var e=this._scheduled;this._scheduled=void 0;var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(T.q),R=new P(S),x=R,I=r(4611),N=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(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),0)},e}(b.R),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e}(T.q),L=new k(N),C=L,M=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=u.requestAnimationFrame(function(){return e.flush(void 0)})))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var s=e.actions;null!=r&&r===e._scheduled&&(null===(i=s[s.length-1])||void 0===i?void 0:i.id)!==r&&(u.cancelAnimationFrame(r),e._scheduled=void 0)},e}(b.R),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e.prototype.flush=function(t){var e;this._active=!0,t?e=t.id:(e=this._scheduled,this._scheduled=void 0);var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(T.q),D=new B(M),U=D,K=function(t){function e(e,r){void 0===e&&(e=H),void 0===r&&(r=1/0);var n=t.call(this,e,function(){return n.frame})||this;return n.maxFrames=r,n.frame=0,n.index=-1,n}return(0,a.C6)(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,n=this.maxFrames;(e=r[0])&&e.delay<=n&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(T.q),H=function(t){function e(e,r,n){void 0===n&&(n=e.index+=1);var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.index=n,i.active=!0,i.index=e.index=n,i}return(0,a.C6)(e,t),e.prototype.schedule=function(r,n){if(void 0===n&&(n=0),Number.isFinite(n)){if(!this.id)return t.prototype.schedule.call(this,r,n);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(r,n)}return c.yU.EMPTY},e.prototype.requestAsyncId=function(t,r,n){void 0===n&&(n=0),this.delay=t.frame+n;var i=t.actions;return i.push(this),i.sort(e.sortActions),1},e.prototype.recycleAsyncId=function(t,e,r){void 0===r&&(r=0)},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(b.R),F=r(4644),G=r(557),V=r(8666),j=r(3404),$=r(2508),z=r(4254),q=r(4460);function W(t){return!!t&&(t instanceof n.c||(0,q.T)(t.lift)&&(0,q.T)(t.subscribe))}var Z=r(1585);function Y(t,e){var r="object"==typeof e;return new Promise(function(n,i){var s,o=!1;t.subscribe({next:function(t){s=t,o=!0},error:i,complete:function(){o?n(s):r?n(e.defaultValue):i(new Z.G)}})})}function X(t,e){var r="object"==typeof e;return new Promise(function(n,i){var s=new G.Ms({next:function(t){n(t),s.unsubscribe()},error:i,complete:function(){r?n(e.defaultValue):i(new Z.G)}});t.subscribe(s)})}var J=r(5339),Q=r(1753),tt=r(8032),et=r(6611),rt=r(3572),nt=r(402),it=r(1867),st=r(6518),ot=r(4981),at=r(5106);function ct(t,e,r,i){if(r){if(!(0,it.m)(r))return function(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];return ct(t,e,i).apply(this,n).pipe((0,ot.I)(r))};i=r}return i?function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return ct(t,e).apply(this,r).pipe((0,st._)(i),(0,at.Q)(i))}:function(){for(var r=this,i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var o=new y.h,c=!0;return new n.c(function(n){var s=o.subscribe(n);if(c){c=!1;var u=!1,l=!1;e.apply(r,(0,a.fX)((0,a.fX)([],(0,a.zs)(i)),[function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(t){var n=e.shift();if(null!=n)return void o.error(n)}o.next(1<e.length?e:e[0]),l=!0,u&&o.complete()}])),l&&o.complete(),u=!0}return s})}}function ut(t,e,r){return ct(!1,t,e,r)}function lt(t,e,r){return ct(!0,t,e,r)}var ht=r(4817),ft=r(7083),dt=r(6195);function pt(t){return new n.c(function(e){(0,dt.Tg)(t()).subscribe(e)})}var gt={connector:function(){return new p.B},resetOnDisconnect:!0};function mt(t,e){void 0===e&&(e=gt);var r=null,i=e.connector,s=e.resetOnDisconnect,o=void 0===s||s,a=i(),c=new n.c(function(t){return a.subscribe(t)});return c.connect=function(){return r&&!r.closed||(r=pt(function(){return t}).subscribe(a),o&&r.add(function(){return a=i()})),r},c}var yt=r(1166),bt=r(1854),vt=r(5361),wt=r(869),Et=r(9407);function _t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,vt.ms)(t),i=(0,bt.D)(t),s=i.args,o=i.keys,a=new n.c(function(t){var e=s.length;if(e)for(var r=new Array(e),n=e,i=e,a=function(e){var a=!1;(0,dt.Tg)(s[e]).subscribe((0,wt._)(t,function(t){a||(a=!0,i--),r[e]=t},function(){return n--},void 0,function(){n&&a||(i||t.next(o?(0,Et.e)(o,r):r),t.complete())}))},c=0;c<e;c++)a(c);else t.complete()});return r?a.pipe((0,ot.I)(r)):a}var At=r(5315),Ot=r(6961),St=r(1604),Tt=["addListener","removeListener"],Pt=["addEventListener","removeEventListener"],Rt=["on","off"];function xt(t,e,r,i){if((0,q.T)(r)&&(i=r,r=void 0),i)return xt(t,e,r).pipe((0,ot.I)(i));var s=(0,a.zs)(function(t){return(0,q.T)(t.addEventListener)&&(0,q.T)(t.removeEventListener)}(t)?Pt.map(function(n){return function(i){return t[n](e,i,r)}}):function(t){return(0,q.T)(t.addListener)&&(0,q.T)(t.removeListener)}(t)?Tt.map(It(t,e)):function(t){return(0,q.T)(t.on)&&(0,q.T)(t.off)}(t)?Rt.map(It(t,e)):[],2),o=s[0],c=s[1];if(!o&&(0,St.X)(t))return(0,Ot.Z)(function(t){return xt(t,e,r)})((0,dt.Tg)(t));if(!o)throw new TypeError("Invalid event target");return new n.c(function(t){var e=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.next(1<e.length?e:e[0])};return o(e),function(){return c(e)}})}function It(t,e){return function(r){return function(n){return t[r](e,n)}}}function Nt(t,e,r){return r?Nt(t,e).pipe((0,ot.I)(r)):new n.c(function(r){var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.next(1===t.length?t[0]:t)},i=t(n);return(0,q.T)(e)?function(){return e(n,i)}:void 0})}var kt=r(9862);function Lt(t,e,r,n,i){var s,o,c,u;function l(){var t;return(0,a.YH)(this,function(n){switch(n.label){case 0:t=u,n.label=1;case 1:return e&&!e(t)?[3,4]:[4,c(t)];case 2:n.sent(),n.label=3;case 3:return t=r(t),[3,1];case 4:return[2]}})}return 1===arguments.length?(u=(s=t).initialState,e=s.condition,r=s.iterate,o=s.resultSelector,c=void 0===o?z.D:o,i=s.scheduler):(u=t,!n||(0,it.m)(n)?(c=z.D,i=n):c=n),pt(i?function(){return(0,kt.S)(l(),i)}:l)}function Ct(t,e,r){return pt(function(){return t()?e:r})}var Mt=r(6726),Bt=r(9904);function Dt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,vt.lI)(t),n=(0,vt.R0)(t,1/0),i=t;return i.length?1===i.length?(0,dt.Tg)(i[0]):(0,Bt.U)(n)((0,At.H)(i,r)):yt.w}var Ut=new n.c($.l);function Kt(){return Ut}var Ht=r(5118),Ft=r(6864);function Gt(t,e){return(0,At.H)(Object.entries(t),e)}var Vt=r(8371),jt=r(465);function $t(t,e,r){return[(0,jt.p)(e,r)((0,dt.Tg)(t)),(0,jt.p)((0,Vt.A)(e,r))((0,dt.Tg)(t))]}var zt=r(6394);function qt(t,e,r){if(null==e&&(e=t,t=0),e<=0)return yt.w;var i=e+t;return new n.c(r?function(e){var n=t;return r.schedule(function(){n<i?(e.next(n++),this.schedule()):e.complete()})}:function(e){for(var r=t;r<i&&!e.closed;)e.next(r++);e.complete()})}var Wt=r(5933),Zt=r(6302);function Yt(t,e){return new n.c(function(r){var n=t(),i=e(n);return(i?(0,dt.Tg)(i):yt.w).subscribe(r),function(){n&&n.unsubscribe()}})}var Xt=r(9568),Jt=r(489),Qt=r(747),te=r(4168),ee=r(7013),re=r(9801),ne=r(9542),ie=r(3132),se=r(6145),oe=r(6689),ae=r(672),ce=r(8363),ue=r(9142),le=r(8957),he=r(2348),fe=r(949),de=r(4292),pe=r(4011),ge=r(1715),me=r(6456),ye=r(9780),be=r(5833),ve=r(4228),we=r(2840),Ee=r(6660),_e=r(1023),Ae=r(7435),Oe=r(5519),Se=r(5538),Te=r(6026),Pe=r(7566),Re=r(5060),xe=r(8017),Ie=r(5598),Ne=r(5711),ke=r(2467),Le=r(8553),Ce=r(4732),Me=r(5206),Be=r(4053),De=r(7333),Ue=r(9756),Ke=r(3694),He=r(2187),Fe=r(8045),Ge=r(3692),Ve=r(6326),je=r(7877),$e=r(9016),ze=r(2720),qe=r(26),We=r(6343),Ze=r(8287),Ye=r(3045),Xe=r(1264),Je=r(9127),Qe=r(8614),tr=r(1996),er=r(9514),rr=r(2812),nr=r(4679),ir=r(8702),sr=r(8933),or=r(744),ar=r(1204),cr=r(9185),ur=r(1478),lr=r(8815),hr=r(7073),fr=r(84),dr=r(510),pr=r(4112),gr=r(1452),mr=r(4103),yr=r(4623),br=r(3616),vr=r(5152),wr=r(3430),Er=r(9955),_r=r(8263),Ar=r(5056),Or=r(8737),Sr=r(1200),Tr=r(2570),Pr=r(5172),Rr=r(3172),xr=r(1762),Ir=r(247),Nr=r(8322),kr=r(8359),Lr=r(626),Cr=r(5007),Mr=r(5223),Br=r(3868),Dr=r(6715),Ur=r(2033),Kr=r(6063),Hr=r(1252),Fr=r(8442),Gr=r(8771),Vr=r(63),jr=r(6248),$r=r(137),zr=r(464)},5445(t,e,r){"use strict";r.d(e,{h:()=>i});var n=r(5608),i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return(0,n.C6)(e,t),e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e._hasValue,i=e._value,s=e.thrownError,o=e.isStopped,a=e._isComplete;r?t.error(s):(o||a)&&(n&&t.next(i),t.complete())},e.prototype.next=function(t){this.isStopped||(this._value=t,this._hasValue=!0)},e.prototype.complete=function(){var e=this,r=e._hasValue,n=e._value;e._isComplete||(this._isComplete=!0,r&&t.prototype.next.call(this,n),t.prototype.complete.call(this))},e}(r(9097).B)},5923(t,e,r){"use strict";r.d(e,{t:()=>i});var n=r(5608),i=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return(0,n.C6)(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(r(9097).B)},8666(t,e,r){"use strict";r.d(e,{Eg:()=>c,Ij:()=>n,gV:()=>u});var n,i=r(1166),s=r(5118),o=r(5933),a=r(4460);!function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"}(n||(n={}));var c=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){return u(this,t)},t.prototype.do=function(t,e,r){var n=this,i=n.kind,s=n.value,o=n.error;return"N"===i?null==t?void 0:t(s):"E"===i?null==e?void 0:e(o):null==r?void 0:r()},t.prototype.accept=function(t,e,r){var n;return(0,a.T)(null===(n=t)||void 0===n?void 0:n.next)?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){var t=this,e=t.kind,r=t.value,n=t.error,a="N"===e?(0,s.of)(r):"E"===e?(0,o.$)(function(){return n}):"C"===e?i.w:0;if(!a)throw new TypeError("Unexpected notification kind "+e);return a},t.createNext=function(e){return new t("N",e)},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t}();function u(t,e){var r,n,i,s=t,o=s.kind,a=s.value,c=s.error;if("string"!=typeof o)throw new TypeError('Invalid notification, missing "kind"');"N"===o?null===(r=e.next)||void 0===r||r.call(e,a):"E"===o?null===(n=e.error)||void 0===n||n.call(e,c):null===(i=e.complete)||void 0===i||i.call(e)}},1824(t,e,r){"use strict";r.d(e,{c:()=>l});var n=r(557),i=r(1868),s=r(9805),o=r(3404),a=r(747),c=r(4460),u=r(7861),l=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var s,o=this,a=(s=t)&&s instanceof n.vU||function(t){return t&&(0,c.T)(t.next)&&(0,c.T)(t.error)&&(0,c.T)(t.complete)}(s)&&(0,i.Uv)(s)?t:new n.Ms(t,e,r);return(0,u.Y)(function(){var t=o,e=t.operator,r=t.source;a.add(e?e.call(a,r):r?o._subscribe(a):o._trySubscribe(a))}),a},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=h(e))(function(e,i){var s=new n.Ms({next:function(e){try{t(e)}catch(t){i(t),s.unsubscribe()}},error:i,complete:e});r.subscribe(s)})},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[s.s]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,o.m)(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=h(t))(function(t,r){var n;e.subscribe(function(t){return n=t},function(t){return r(t)},function(){return t(n)})})},t.create=function(e){return new t(e)},t}();function h(t){var e;return null!==(e=null!=t?t:a.$.Promise)&&void 0!==e?e:Promise}},5404(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(5608),i=r(9097),s=r(8154),o=function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=s.U);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}return(0,n.C6)(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,o=r._timestampProvider,a=r._windowTime;n||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,s=(i?1:2)*e;if(e<1/0&&s<n.length&&n.splice(0,n.length-s),!i){for(var o=r.now(),a=0,c=1;c<n.length&&n[c]<=o;c+=2)a=c;a&&n.splice(0,a+1)}},e}(i.B)},4644(t,e,r){"use strict";r.d(e,{_:()=>i});var n=r(8154),i=function(){function t(e,r){void 0===r&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},t.now=n.U.now,t}()},9097(t,e,r){"use strict";r.d(e,{B:()=>u});var n=r(5608),i=r(1824),s=r(1868),o=r(8032),a=r(1601),c=r(7861),u=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return(0,n.C6)(e,t),e.prototype.lift=function(t){var e=new l(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new o.P},e.prototype.next=function(t){var e=this;(0,c.Y)(function(){var r,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var s=(0,n.Ju)(e.currentObservers),o=s.next();!o.done;o=s.next()){o.value.next(t)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}})},e.prototype.error=function(t){var e=this;(0,c.Y)(function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}})},e.prototype.complete=function(){var t=this;(0,c.Y)(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?s.Kn:(this.currentObservers=null,o.push(t),new s.yU(function(){e.currentObservers=null,(0,a.o)(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new i.c;return t.source=this,t},e.create=function(t,e){return new l(t,e)},e}(i.c),l=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return(0,n.C6)(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:s.Kn},e}(u)},557(t,e,r){"use strict";r.d(e,{Ms:()=>y,vU:()=>d});var n=r(5608),i=r(4460),s=r(1868),o=r(747),a=r(3585),c=r(2508),u=l("C",void 0,void 0);function l(t,e,r){return{kind:t,value:e,error:r}}var h=r(533),f=r(7861),d=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,(0,s.Uv)(e)&&e.add(r)):r.destination=w,r}return(0,n.C6)(e,t),e.create=function(t,e,r){return new y(t,e,r)},e.prototype.next=function(t){this.isStopped?v(function(t){return l("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?v(l("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?v(u,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(s.yU),p=Function.prototype.bind;function g(t,e){return p.call(t,e)}var m=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){b(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){b(t)}else b(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){b(t)}},t}(),y=function(t){function e(e,r,n){var s,a,c=t.call(this)||this;(0,i.T)(e)||!e?s={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:c&&o.$.useDeprecatedNextContext?((a=Object.create(e)).unsubscribe=function(){return c.unsubscribe()},s={next:e.next&&g(e.next,a),error:e.error&&g(e.error,a),complete:e.complete&&g(e.complete,a)}):s=e;return c.destination=new m(s),c}return(0,n.C6)(e,t),e}(d);function b(t){o.$.useDeprecatedSynchronousErrorHandling?(0,f.l)(t):(0,a.m)(t)}function v(t,e){var r=o.$.onStoppedNotification;r&&h.f.setTimeout(function(){return r(t,e)})}var w={closed:!0,next:c.l,error:function(t){throw t},complete:c.l}},1868(t,e,r){"use strict";r.d(e,{Kn:()=>c,Uv:()=>u,yU:()=>a});var n=r(5608),i=r(4460),s=r(402),o=r(1601),a=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return t.prototype.unsubscribe=function(){var t,e,r,o,a;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var u=(0,n.Ju)(c),h=u.next();!h.done;h=u.next()){h.value.remove(this)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}else c.remove(this);var f=this.initialTeardown;if((0,i.T)(f))try{f()}catch(t){a=t instanceof s.Z?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=(0,n.Ju)(d),g=p.next();!g.done;g=p.next()){var m=g.value;try{l(m)}catch(t){a=null!=a?a:[],t instanceof s.Z?a=(0,n.fX)((0,n.fX)([],(0,n.zs)(a)),(0,n.zs)(t.errors)):a.push(t)}}}catch(t){r={error:t}}finally{try{g&&!g.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}if(a)throw new s.Z(a)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)l(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&(0,o.o)(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&(0,o.o)(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t}(),c=a.EMPTY;function u(t){return t instanceof a||t&&"closed"in t&&(0,i.T)(t.remove)&&(0,i.T)(t.add)&&(0,i.T)(t.unsubscribe)}function l(t){(0,i.T)(t)?t():t.unsubscribe()}},747(t,e,r){"use strict";r.d(e,{$:()=>n});var n={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},5900(t,e,r){"use strict";r.d(e,{G:()=>u});var n=r(5608),i=r(1824),s=r(1868),o=r(8815),a=r(869),c=r(2185),u=function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,(0,c.S)(e)&&(n.lift=e.lift),n}return(0,n.C6)(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._teardown=function(){this._refCount=0;var t=this._connection;this._subject=this._connection=null,null==t||t.unsubscribe()},e.prototype.connect=function(){var t=this,e=this._connection;if(!e){e=this._connection=new s.yU;var r=this.getSubject();e.add(this.source.subscribe((0,a._)(r,void 0,function(){t._teardown(),r.complete()},function(e){t._teardown(),r.error(e)},function(){return t._teardown()}))),e.closed&&(this._connection=null,e=s.yU.EMPTY)}return e},e.prototype.refCount=function(){return(0,o.B)()(this)},e}(i.c)},4817(t,e,r){"use strict";r.d(e,{P:()=>d,z:()=>f});var n=r(1824),i=r(1854),s=r(5315),o=r(4254),a=r(4981),c=r(5361),u=r(9407),l=r(869),h=r(4184);function f(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,c.lI)(t),l=(0,c.ms)(t),h=(0,i.D)(t),f=h.args,p=h.keys;if(0===f.length)return(0,s.H)([],r);var g=new n.c(d(f,r,p?function(t){return(0,u.e)(p,t)}:o.D));return l?g.pipe((0,a.I)(l)):g}function d(t,e,r){return void 0===r&&(r=o.D),function(n){p(e,function(){for(var i=t.length,o=new Array(i),a=i,c=i,u=function(i){p(e,function(){var u=(0,s.H)(t[i],e),h=!1;u.subscribe((0,l._)(n,function(t){o[i]=t,h||(h=!0,c--),c||n.next(r(o.slice()))},function(){--a||n.complete()}))},n)},h=0;h<i;h++)u(h)},n)}}function p(t,e,r){t?(0,h.N)(r,t,e):e()}},7083(t,e,r){"use strict";r.d(e,{x:()=>o});var n=r(2348),i=r(5361),s=r(5315);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,n.K)()((0,s.H)(t,(0,i.lI)(t)))}},1166(t,e,r){"use strict";r.d(e,{I:()=>s,w:()=>i});var n=r(1824),i=new n.c(function(t){return t.complete()});function s(t){return t?function(t){return new n.c(function(e){return t.schedule(function(){return e.complete()})})}(t):i}},5315(t,e,r){"use strict";r.d(e,{H:()=>s});var n=r(489),i=r(6195);function s(t,e){return e?(0,n.c)(t,e):(0,i.Tg)(t)}},6195(t,e,r){"use strict";r.d(e,{Tg:()=>g});var n=r(5608),i=r(1604),s=r(6691),o=r(1824),a=r(3330),c=r(4956),u=r(4904),l=r(3206),h=r(8523),f=r(4460),d=r(3585),p=r(9805);function g(t){if(t instanceof o.c)return t;if(null!=t){if((0,a.l)(t))return b=t,new o.c(function(t){var e=b[p.s]();if((0,f.T)(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if((0,i.X)(t))return y=t,new o.c(function(t){for(var e=0;e<y.length&&!t.closed;e++)t.next(y[e]);t.complete()});if((0,s.y)(t))return g=t,new o.c(function(t){g.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,d.m)});if((0,c.T)(t))return m(t);if((0,l.x)(t))return r=t,new o.c(function(t){var e,i;try{for(var s=(0,n.Ju)(r),o=s.next();!o.done;o=s.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}t.complete()});if((0,h.U)(t))return e=t,m((0,h.C)(e))}var e,r,g,y,b;throw(0,u.L)(t)}function m(t){return new o.c(function(e){(function(t,e){var r,i,s,o;return(0,n.sH)(this,void 0,void 0,function(){var a,c;return(0,n.YH)(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=(0,n.xN)(t),u.label=1;case 1:return[4,r.next()];case 2:if((i=u.sent()).done)return[3,4];if(a=i.value,e.next(a),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),i&&!i.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})})(t,e).catch(function(t){return e.error(t)})})}},6726(t,e,r){"use strict";r.d(e,{Y:()=>s});var n=r(4611),i=r(6302);function s(t,e){return void 0===t&&(t=0),void 0===e&&(e=n.E),t<0&&(t=0),(0,i.O)(t,t,e)}},5118(t,e,r){"use strict";r.d(e,{of:()=>s});var n=r(5361),i=r(5315);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,n.lI)(t);return(0,i.H)(t,r)}},6864(t,e,r){"use strict";r.d(e,{g:()=>c});var n=r(1824),i=r(7589),s=r(869),o=r(2508),a=r(6195);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.K)(t);return new n.c(function(t){var e=0,n=function(){if(e<r.length){var i=void 0;try{i=(0,a.Tg)(r[e++])}catch(t){return void n()}var c=new s.H(t,void 0,o.l,o.l);i.subscribe(c),c.add(n)}else t.complete()};n()})}},6394(t,e,r){"use strict";r.d(e,{O:()=>a,w:()=>c});var n=r(1824),i=r(6195),s=r(7589),o=r(869);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===(t=(0,s.K)(t)).length?(0,i.Tg)(t[0]):new n.c(c(t))}function c(t){return function(e){for(var r=[],n=function(n){r.push((0,i.Tg)(t[n]).subscribe((0,o._)(e,function(t){if(r){for(var i=0;i<r.length;i++)i!==n&&r[i].unsubscribe();r=null}e.next(t)})))},s=0;r&&!e.closed&&s<t.length;s++)n(s)}}},5933(t,e,r){"use strict";r.d(e,{$:()=>s});var n=r(1824),i=r(4460);function s(t,e){var r=(0,i.T)(t)?t:function(){return t},s=function(t){return t.error(r())};return new n.c(e?function(t){return e.schedule(s,0,t)}:s)}},6302(t,e,r){"use strict";r.d(e,{O:()=>a});var n=r(1824),i=r(4611),s=r(1867),o=r(1592);function a(t,e,r){void 0===t&&(t=0),void 0===r&&(r=i.b);var a=-1;return null!=e&&((0,s.m)(e)?r=e:a=e),new n.c(function(e){var n=(0,o.v)(t)?+t-r.now():t;n<0&&(n=0);var i=0;return r.schedule(function(){e.closed||(e.next(i++),0<=a?this.schedule(void 0,a):e.complete())},n)})}},9568(t,e,r){"use strict";r.d(e,{y:()=>l});var n=r(5608),i=r(1824),s=r(6195),o=r(7589),a=r(1166),c=r(869),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t),l=(0,o.K)(t);return l.length?new i.c(function(t){var e=l.map(function(){return[]}),i=l.map(function(){return!1});t.add(function(){e=i=null});for(var o=function(o){(0,s.Tg)(l[o]).subscribe((0,c._)(t,function(s){if(e[o].push(s),e.every(function(t){return t.length})){var a=e.map(function(t){return t.shift()});t.next(r?r.apply(void 0,(0,n.fX)([],(0,n.zs)(a))):a),e.some(function(t,e){return!t.length&&i[e]})&&t.complete()}},function(){i[o]=!0,!e[o].length&&t.complete()}))},a=0;!t.closed&&a<l.length;a++)o(a);return function(){e=i=null}}):a.w}},869(t,e,r){"use strict";r.d(e,{H:()=>s,_:()=>i});var n=r(5608);function i(t,e,r,n,i){return new s(t,e,r,n,i)}var s=function(t){function e(e,r,n,i,s,o){var a=t.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return(0,n.C6)(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(r(557).vU)},4168(t,e,r){"use strict";r.d(e,{s:()=>o});var n=r(2185),i=r(6195),s=r(869);function o(t){return(0,n.N)(function(e,r){var n=!1,o=null,a=null,c=!1,u=function(){if(null==a||a.unsubscribe(),a=null,n){n=!1;var t=o;o=null,r.next(t)}c&&r.complete()},l=function(){a=null,c&&r.complete()};e.subscribe((0,s._)(r,function(e){n=!0,o=e,a||(0,i.Tg)(t(e)).subscribe(a=(0,s._)(r,u,l))},function(){c=!0,(!n||!a||a.closed)&&r.complete()}))})}},7013(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(4611),i=r(4168),s=r(6302);function o(t,e){return void 0===e&&(e=n.E),(0,i.s)(function(){return(0,s.O)(t,e)})}},9801(t,e,r){"use strict";r.d(e,{r:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=[];return e.subscribe((0,s._)(r,function(t){return n.push(t)},function(){r.next(n),r.complete()})),(0,o.Tg)(t).subscribe((0,s._)(r,function(){var t=n;n=[],r.next(t)},i.l)),function(){n=null}})}},9542(t,e,r){"use strict";r.d(e,{S:()=>a});var n=r(5608),i=r(2185),s=r(869),o=r(1601);function a(t,e){return void 0===e&&(e=null),e=null!=e?e:t,(0,i.N)(function(r,i){var a=[],c=0;r.subscribe((0,s._)(i,function(r){var s,u,l,h,f=null;c++%e===0&&a.push([]);try{for(var d=(0,n.Ju)(a),p=d.next();!p.done;p=d.next()){(y=p.value).push(r),t<=y.length&&(f=null!=f?f:[]).push(y)}}catch(t){s={error:t}}finally{try{p&&!p.done&&(u=d.return)&&u.call(d)}finally{if(s)throw s.error}}if(f)try{for(var g=(0,n.Ju)(f),m=g.next();!m.done;m=g.next()){var y=m.value;(0,o.o)(a,y),i.next(y)}}catch(t){l={error:t}}finally{try{m&&!m.done&&(h=g.return)&&h.call(g)}finally{if(l)throw l.error}}},function(){var t,e;try{for(var r=(0,n.Ju)(a),s=r.next();!s.done;s=r.next()){var o=s.value;i.next(o)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}i.complete()},void 0,function(){a=null}))})}},3132(t,e,r){"use strict";r.d(e,{w:()=>h});var n=r(5608),i=r(1868),s=r(2185),o=r(869),a=r(1601),c=r(4611),u=r(5361),l=r(4184);function h(t){for(var e,r,h=[],f=1;f<arguments.length;f++)h[f-1]=arguments[f];var d=null!==(e=(0,u.lI)(h))&&void 0!==e?e:c.E,p=null!==(r=h[0])&&void 0!==r?r:null,g=h[1]||1/0;return(0,s.N)(function(e,r){var s=[],c=!1,u=function(t){var e=t.buffer;t.subs.unsubscribe(),(0,a.o)(s,t),r.next(e),c&&h()},h=function(){if(s){var e=new i.yU;r.add(e);var n={buffer:[],subs:e};s.push(n),(0,l.N)(e,d,function(){return u(n)},t)}};null!==p&&p>=0?(0,l.N)(r,d,h,p,!0):c=!0,h();var f=(0,o._)(r,function(t){var e,r,i=s.slice();try{for(var o=(0,n.Ju)(i),a=o.next();!a.done;a=o.next()){var c=a.value,l=c.buffer;l.push(t),g<=l.length&&u(c)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},function(){for(;null==s?void 0:s.length;)r.next(s.shift().buffer);null==f||f.unsubscribe(),r.complete(),r.unsubscribe()},void 0,function(){return s=null});e.subscribe(f)})}},6145(t,e,r){"use strict";r.d(e,{H:()=>l});var n=r(5608),i=r(1868),s=r(2185),o=r(6195),a=r(869),c=r(2508),u=r(1601);function l(t,e){return(0,s.N)(function(r,s){var l=[];(0,o.Tg)(t).subscribe((0,a._)(s,function(t){var r=[];l.push(r);var n=new i.yU;n.add((0,o.Tg)(e(t)).subscribe((0,a._)(s,function(){(0,u.o)(l,r),s.next(r),n.unsubscribe()},c.l)))},c.l)),r.subscribe((0,a._)(s,function(t){var e,r;try{for(var i=(0,n.Ju)(l),s=i.next();!s.done;s=i.next()){s.value.push(t)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}},function(){for(;l.length>0;)s.next(l.shift());s.complete()}))})}},6689(t,e,r){"use strict";r.d(e,{n:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=null,a=null,c=function(){null==a||a.unsubscribe();var e=n;n=[],e&&r.next(e),(0,o.Tg)(t()).subscribe(a=(0,s._)(r,c,i.l))};c(),e.subscribe((0,s._)(r,function(t){return null==n?void 0:n.push(t)},function(){n&&r.next(n),r.complete()},void 0,function(){return n=a=null}))})}},672(t,e,r){"use strict";r.d(e,{W:()=>o});var n=r(6195),i=r(869),s=r(2185);function o(t){return(0,s.N)(function(e,r){var s,a=null,c=!1;a=e.subscribe((0,i._)(r,void 0,void 0,function(i){s=(0,n.Tg)(t(i,o(t)(e))),a?(a.unsubscribe(),a=null,s.subscribe(r)):c=!0})),c&&(a.unsubscribe(),a=null,s.subscribe(r))})}},8363(t,e,r){"use strict";r.d(e,{p:()=>n});var n=r(9142).A},1481(t,e,r){"use strict";r.d(e,{z:()=>l});var n=r(5608),i=r(4817),s=r(2185),o=r(7589),a=r(4981),c=r(3404),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t);return r?(0,c.F)(l.apply(void 0,(0,n.fX)([],(0,n.zs)(t))),(0,a.I)(r)):(0,s.N)(function(e,r){(0,i.P)((0,n.fX)([e],(0,n.zs)((0,o.K)(t))))(r)})}},9142(t,e,r){"use strict";r.d(e,{A:()=>s});var n=r(4817),i=r(9732);function s(t){return(0,i.q)(n.z,t)}},8957(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(5608),i=r(1481);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.z.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},3267(t,e,r){"use strict";r.d(e,{x:()=>c});var n=r(5608),i=r(2185),s=r(2348),o=r(5361),a=r(5315);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,o.lI)(t);return(0,i.N)(function(e,i){(0,s.K)()((0,a.H)((0,n.fX)([e],(0,n.zs)(t)),r)).subscribe(i)})}},2348(t,e,r){"use strict";r.d(e,{K:()=>i});var n=r(9904);function i(){return(0,n.U)(1)}},949(t,e,r){"use strict";r.d(e,{H:()=>s});var n=r(6961),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.Z)(t,e,1):(0,n.Z)(t,1)}},4292(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(949),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.H)(function(){return t},e):(0,n.H)(function(){return t})}},4011(t,e,r){"use strict";r.d(e,{$:()=>s});var n=r(5608),i=r(3267);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.x.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},1715(t,e,r){"use strict";r.d(e,{N:()=>c});var n=r(9097),i=r(6195),s=r(2185),o=r(1824);var a={connector:function(){return new n.B}};function c(t,e){void 0===e&&(e=a);var r=e.connector;return(0,s.N)(function(e,n){var s,a=r();(0,i.Tg)(t((s=a,new o.c(function(t){return s.subscribe(t)})))).subscribe(n),n.add(e.subscribe(a))})}},6456(t,e,r){"use strict";r.d(e,{U:()=>i});var n=r(8933);function i(t){return(0,n.T)(function(e,r,n){return!t||t(r,n)?e+1:e},0)}},9780(t,e,r){"use strict";r.d(e,{s:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=!1,a=null,c=null,u=function(){if(null==c||c.unsubscribe(),c=null,n){n=!1;var t=a;a=null,r.next(t)}};e.subscribe((0,s._)(r,function(e){null==c||c.unsubscribe(),n=!0,a=e,c=(0,s._)(r,u,i.l),(0,o.Tg)(t(e)).subscribe(c)},function(){u(),r.complete()},void 0,function(){a=c=null}))})}},5833(t,e,r){"use strict";r.d(e,{B:()=>o});var n=r(4611),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=n.E),(0,i.N)(function(r,n){var i=null,o=null,a=null,c=function(){if(i){i.unsubscribe(),i=null;var t=o;o=null,n.next(t)}};function u(){var r=a+t,s=e.now();if(s<r)return i=this.schedule(void 0,r-s),void n.add(i);c()}r.subscribe((0,s._)(n,function(r){o=r,a=e.now(),i||(i=e.schedule(u,t),n.add(i))},function(){c(),n.complete()},void 0,function(){o=i=null}))})}},4228(t,e,r){"use strict";r.d(e,{U:()=>s});var n=r(2185),i=r(869);function s(t){return(0,n.N)(function(e,r){var n=!1;e.subscribe((0,i._)(r,function(t){n=!0,r.next(t)},function(){n||r.next(t),r.complete()}))})}},2840(t,e,r){"use strict";r.d(e,{c:()=>o});var n=r(4611),i=r(6660),s=r(6302);function o(t,e){void 0===e&&(e=n.E);var r=(0,s.O)(t,e);return(0,i.o)(function(){return r})}},6660(t,e,r){"use strict";r.d(e,{o:()=>u});var n=r(7083),i=r(5172),s=r(9756),o=r(3692),a=r(6961),c=r(6195);function u(t,e){return e?function(r){return(0,n.x)(e.pipe((0,i.s)(1),(0,s.w)()),r.pipe(u(t)))}:(0,a.Z)(function(e,r){return(0,c.Tg)(t(e,r)).pipe((0,i.s)(1),(0,o.u)(e))})}},1023(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(8666),i=r(2185),s=r(869);function o(){return(0,i.N)(function(t,e){t.subscribe((0,s._)(e,function(t){return(0,n.gV)(t,e)}))})}},7435(t,e,r){"use strict";r.d(e,{d:()=>a});var n=r(2185),i=r(869),s=r(2508),o=r(6195);function a(t,e){return(0,n.N)(function(r,n){var a=new Set;r.subscribe((0,i._)(n,function(e){var r=t?t(e):e;a.has(r)||(a.add(r),n.next(e))})),e&&(0,o.Tg)(e).subscribe((0,i._)(n,function(){return a.clear()},s.l))})}},5519(t,e,r){"use strict";r.d(e,{F:()=>o});var n=r(4254),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=n.D),t=null!=t?t:a,(0,i.N)(function(r,n){var i,o=!0;r.subscribe((0,s._)(n,function(r){var s=e(r);!o&&t(i,s)||(o=!1,i=s,n.next(r))}))})}function a(t,e){return t===e}},5538(t,e,r){"use strict";r.d(e,{w:()=>i});var n=r(5519);function i(t,e){return(0,n.F)(function(r,n){return e?e(r[t],n[t]):r[t]===n[t]})}},6026(t,e,r){"use strict";r.d(e,{s:()=>c});var n=r(5339),i=r(465),s=r(5007),o=r(4228),a=r(5172);function c(t,e){if(t<0)throw new n.k;var r=arguments.length>=2;return function(c){return c.pipe((0,i.p)(function(e,r){return r===t}),(0,a.s)(1),r?(0,o.U)(e):(0,s.v)(function(){return new n.k}))}}},7566(t,e,r){"use strict";r.d(e,{q:()=>o});var n=r(5608),i=r(7083),s=r(5118);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return(0,i.x)(e,s.of.apply(void 0,(0,n.fX)([],(0,n.zs)(t))))}}},5060(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(i){t.call(e,i,s++,r)||(n.next(!1),n.complete())},function(){n.next(!0),n.complete()}))})}},8017(t,e,r){"use strict";r.d(e,{B:()=>n});var n=r(5598).C},5598(t,e,r){"use strict";r.d(e,{C:()=>s});var n=r(5711),i=r(4254);function s(){return(0,n.p)(i.D)}},5711(t,e,r){"use strict";r.d(e,{p:()=>a});var n=r(8045),i=r(6195),s=r(2185),o=r(869);function a(t,e){return e?function(r){return r.pipe(a(function(r,s){return(0,i.Tg)(t(r,s)).pipe((0,n.T)(function(t,n){return e(r,t,s,n)}))}))}:(0,s.N)(function(e,r){var n=0,s=null,a=!1;e.subscribe((0,o._)(r,function(e){s||(s=(0,o._)(r,void 0,function(){s=null,a&&r.complete()}),(0,i.Tg)(t(e,n++)).subscribe(s))},function(){a=!0,!s&&r.complete()}))})}},2467(t,e,r){"use strict";r.d(e,{f:()=>s});var n=r(2185),i=r(8001);function s(t,e,r){return void 0===e&&(e=1/0),e=(e||0)<1?1/0:e,(0,n.N)(function(n,s){return(0,i.h)(n,s,t,e,void 0,!0,r)})}},465(t,e,r){"use strict";r.d(e,{p:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){return t.call(e,r,s++)&&n.next(r)}))})}},8553(t,e,r){"use strict";r.d(e,{j:()=>i});var n=r(2185);function i(t){return(0,n.N)(function(e,r){try{e.subscribe(r)}finally{r.add(t)}})}},4732(t,e,r){"use strict";r.d(e,{I:()=>s,k:()=>o});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(o(t,e,"value"))}function o(t,e,r){var n="index"===r;return function(r,s){var o=0;r.subscribe((0,i._)(s,function(i){var a=o++;t.call(e,i,a,r)&&(s.next(n?a:i),s.complete())},function(){s.next(n?-1:void 0),s.complete()}))}}},5206(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(4732);function s(t,e){return(0,n.N)((0,i.k)(t,e,"index"))}},4053(t,e,r){"use strict";r.d(e,{$:()=>u});var n=r(1585),i=r(465),s=r(5172),o=r(4228),a=r(5007),c=r(4254);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,i.p)(function(e,r){return t(e,r,u)}):c.D,(0,s.s)(1),r?(0,o.U)(e):(0,a.v)(function(){return new n.G}))}}},9016(t,e,r){"use strict";r.d(e,{q:()=>n});var n=r(6961).Z},7333(t,e,r){"use strict";r.d(e,{$:()=>c});var n=r(1824),i=r(6195),s=r(9097),o=r(2185),a=r(869);function c(t,e,r,c){return(0,o.N)(function(o,u){var l;e&&"function"!=typeof e?(r=e.duration,l=e.element,c=e.connector):l=e;var h=new Map,f=function(t){h.forEach(t),t(u)},d=function(t){return f(function(e){return e.error(t)})},p=0,g=!1,m=new a.H(u,function(e){try{var o=t(e),f=h.get(o);if(!f){h.set(o,f=c?c():new s.B);var y=(v=o,w=f,(E=new n.c(function(t){p++;var e=w.subscribe(t);return function(){e.unsubscribe(),0===--p&&g&&m.unsubscribe()}})).key=v,E);if(u.next(y),r){var b=(0,a._)(f,function(){f.complete(),null==b||b.unsubscribe()},void 0,void 0,function(){return h.delete(o)});m.add((0,i.Tg)(r(y)).subscribe(b))}}f.next(l?l(e):e)}catch(t){d(t)}var v,w,E},function(){return f(function(t){return t.complete()})},d,function(){return h.clear()},function(){return g=!0,0===p});o.subscribe(m)})}},9756(t,e,r){"use strict";r.d(e,{w:()=>o});var n=r(2185),i=r(869),s=r(2508);function o(){return(0,n.N)(function(t,e){t.subscribe((0,i._)(e,s.l))})}},3694(t,e,r){"use strict";r.d(e,{I:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){t.subscribe((0,i._)(e,function(){e.next(!1),e.complete()},function(){e.next(!0),e.complete()}))})}},9732(t,e,r){"use strict";r.d(e,{q:()=>c});var n=r(4254),i=r(4981),s=r(3404),o=r(6961),a=r(2033);function c(t,e){return(0,s.F)((0,a.$)(),(0,o.Z)(function(e){return t(e)}),e?(0,i.I)(e):n.D)}},2187(t,e,r){"use strict";r.d(e,{H:()=>u});var n=r(1585),i=r(465),s=r(3172),o=r(5007),a=r(4228),c=r(4254);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,i.p)(function(e,r){return t(e,r,u)}):c.D,(0,s.o)(1),r?(0,a.U)(e):(0,o.v)(function(){return new n.G}))}}},8045(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){n.next(t.call(e,r,s++))}))})}},3692(t,e,r){"use strict";r.d(e,{u:()=>i});var n=r(8045);function i(t){return(0,n.T)(function(){return t})}},6326(t,e,r){"use strict";r.d(e,{O:()=>o});var n=r(8666),i=r(2185),s=r(869);function o(){return(0,i.N)(function(t,e){t.subscribe((0,s._)(e,function(t){e.next(n.Eg.createNext(t))},function(){e.next(n.Eg.createComplete()),e.complete()},function(t){e.next(n.Eg.createError(t)),e.complete()}))})}},7877(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(8933),i=r(4460);function s(t){return(0,n.T)((0,i.T)(t)?function(e,r){return t(e,r)>0?e:r}:function(t,e){return t>e?t:e})}},3375(t,e,r){"use strict";r.d(e,{h:()=>c});var n=r(5608),i=r(2185),s=r(9904),o=r(5361),a=r(5315);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,o.lI)(t),c=(0,o.R0)(t,1/0);return(0,i.N)(function(e,i){(0,s.U)(c)((0,a.H)((0,n.fX)([e],(0,n.zs)(t)),r)).subscribe(i)})}},9904(t,e,r){"use strict";r.d(e,{U:()=>s});var n=r(6961),i=r(4254);function s(t){return void 0===t&&(t=1/0),(0,n.Z)(i.D,t)}},8001(t,e,r){"use strict";r.d(e,{h:()=>o});var n=r(6195),i=r(4184),s=r(869);function o(t,e,r,o,a,c,u,l){var h=[],f=0,d=0,p=!1,g=function(){!p||h.length||f||e.complete()},m=function(t){return f<o?y(t):h.push(t)},y=function(t){c&&e.next(t),f++;var l=!1;(0,n.Tg)(r(t,d++)).subscribe((0,s._)(e,function(t){null==a||a(t),c?m(t):e.next(t)},function(){l=!0},void 0,function(){if(l)try{f--;for(var t=function(){var t=h.shift();u?(0,i.N)(e,u,function(){return y(t)}):y(t)};h.length&&f<o;)t();g()}catch(t){e.error(t)}}))};return t.subscribe((0,s._)(e,m,function(){p=!0,g()})),function(){null==l||l()}}},6961(t,e,r){"use strict";r.d(e,{Z:()=>c});var n=r(8045),i=r(6195),s=r(2185),o=r(8001),a=r(4460);function c(t,e,r){return void 0===r&&(r=1/0),(0,a.T)(e)?c(function(r,s){return(0,n.T)(function(t,n){return e(r,t,s,n)})((0,i.Tg)(t(r,s)))},r):("number"==typeof e&&(r=e),(0,s.N)(function(e,n){return(0,o.h)(e,n,t,r)}))}},2720(t,e,r){"use strict";r.d(e,{C:()=>s});var n=r(6961),i=r(4460);function s(t,e,r){return void 0===r&&(r=1/0),(0,i.T)(e)?(0,n.Z)(function(){return t},e,r):("number"==typeof e&&(r=e),(0,n.Z)(function(){return t},r))}},26(t,e,r){"use strict";r.d(e,{i:()=>s});var n=r(2185),i=r(8001);function s(t,e,r){return void 0===r&&(r=1/0),(0,n.N)(function(n,s){var o=e;return(0,i.h)(n,s,function(e,r){return t(o,e,r)},r,function(t){o=t},!1,void 0,function(){return o=null})})}},6343(t,e,r){"use strict";r.d(e,{X:()=>s});var n=r(5608),i=r(3375);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.h.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},8287(t,e,r){"use strict";r.d(e,{j:()=>s});var n=r(8933),i=r(4460);function s(t){return(0,n.T)((0,i.T)(t)?function(e,r){return t(e,r)<0?e:r}:function(t,e){return t<e?t:e})}},3045(t,e,r){"use strict";r.d(e,{f:()=>o});var n=r(5900),i=r(4460),s=r(1715);function o(t,e){var r=(0,i.T)(t)?t:function(){return t};return(0,i.T)(e)?(0,s.N)(e,{connector:r}):function(t){return new n.G(t,r)}}},5106(t,e,r){"use strict";r.d(e,{Q:()=>o});var n=r(4184),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=0),(0,i.N)(function(r,i){r.subscribe((0,s._)(i,function(r){return(0,n.N)(i,t,function(){return i.next(r)},e)},function(){return(0,n.N)(i,t,function(){return i.complete()},e)},function(r){return(0,n.N)(i,t,function(){return i.error(r)},e)}))})}},1264(t,e,r){"use strict";r.d(e,{g:()=>a,w:()=>o});var n=r(5608),i=r(7589),s=r(6864);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.K)(t);return function(t){return s.g.apply(void 0,(0,n.fX)([t],(0,n.zs)(r)))}}var a=o},9127(t,e,r){"use strict";r.d(e,{J:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){var r,n=!1;t.subscribe((0,i._)(e,function(t){var i=r;r=t,n&&e.next([i,t]),n=!0}))})}},8614(t,e,r){"use strict";r.d(e,{E:()=>i});var n=r(8045);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.length;if(0===r)throw new Error("list of properties cannot be empty.");return(0,n.T)(function(e){for(var n=e,i=0;i<r;i++){var s=null==n?void 0:n[t[i]];if(void 0===s)return;n=s}return n})}},1996(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(9097),i=r(3045),s=r(1715);function o(t){return t?function(e){return(0,s.N)(t)(e)}:function(t){return(0,i.f)(new n.B)(t)}}},9514(t,e,r){"use strict";r.d(e,{K:()=>s});var n=r(5923),i=r(5900);function s(t){return function(e){var r=new n.t(t);return new i.G(e,function(){return r})}}},2812(t,e,r){"use strict";r.d(e,{k:()=>s});var n=r(5445),i=r(5900);function s(){return function(t){var e=new n.h;return new i.G(t,function(){return e})}}},4679(t,e,r){"use strict";r.d(e,{H:()=>o});var n=r(5404),i=r(3045),s=r(4460);function o(t,e,r,o){r&&!(0,s.T)(r)&&(o=r);var a=(0,s.T)(r)?r:void 0;return function(r){return(0,i.f)(new n.m(t,e,o),a)(r)}}},8702(t,e,r){"use strict";r.d(e,{w:()=>a});var n=r(5608),i=r(6394),s=r(2185),o=r(4254);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.length?(0,s.N)(function(e,r){(0,i.w)((0,n.fX)([e],(0,n.zs)(t)))(r)}):o.D}},8933(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(8906),i=r(2185);function s(t,e){return(0,i.N)((0,n.S)(t,e,arguments.length>=2,!1,!0))}},8815(t,e,r){"use strict";r.d(e,{B:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){var r=null;t._refCount++;var n=(0,i._)(e,void 0,void 0,void 0,function(){if(!t||t._refCount<=0||0<--t._refCount)r=null;else{var n=t._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),e.unsubscribe()}});t.subscribe(n),n.closed||(r=t.connect())})}},744(t,e,r){"use strict";r.d(e,{u:()=>c});var n=r(1166),i=r(2185),s=r(869),o=r(6195),a=r(6302);function c(t){var e,r,c=1/0;return null!=t&&("object"==typeof t?(e=t.count,c=void 0===e?1/0:e,r=t.delay):c=t),c<=0?function(){return n.w}:(0,i.N)(function(t,e){var n,i=0,u=function(){if(null==n||n.unsubscribe(),n=null,null!=r){var t="number"==typeof r?(0,a.O)(r):(0,o.Tg)(r(i)),c=(0,s._)(e,function(){c.unsubscribe(),l()});t.subscribe(c)}else l()},l=function(){var r=!1;n=t.subscribe((0,s._)(e,void 0,function(){++i<c?n?u():r=!0:e.complete()})),r&&u()};l()})}},1204(t,e,r){"use strict";r.d(e,{Y:()=>a});var n=r(6195),i=r(9097),s=r(2185),o=r(869);function a(t){return(0,s.N)(function(e,r){var s,a,c=!1,u=!1,l=!1,h=function(){return l&&u&&(r.complete(),!0)},f=function(){l=!1,s=e.subscribe((0,o._)(r,void 0,function(){l=!0,!h()&&(a||(a=new i.B,(0,n.Tg)(t(a)).subscribe((0,o._)(r,function(){s?f():c=!0},function(){u=!0,h()}))),a).next()})),c&&(s.unsubscribe(),s=null,c=!1,f())};f()})}},9185(t,e,r){"use strict";r.d(e,{L:()=>c});var n=r(2185),i=r(869),s=r(4254),o=r(6302),a=r(6195);function c(t){var e;void 0===t&&(t=1/0);var r=(e=t&&"object"==typeof t?t:{count:t}).count,c=void 0===r?1/0:r,u=e.delay,l=e.resetOnSuccess,h=void 0!==l&&l;return c<=0?s.D:(0,n.N)(function(t,e){var r,n=0,s=function(){var l=!1;r=t.subscribe((0,i._)(e,function(t){h&&(n=0),e.next(t)},void 0,function(t){if(n++<c){var h=function(){r?(r.unsubscribe(),r=null,s()):l=!0};if(null!=u){var f="number"==typeof u?(0,o.O)(u):(0,a.Tg)(u(t,n)),d=(0,i._)(e,function(){d.unsubscribe(),h()},function(){e.complete()});f.subscribe(d)}else h()}else e.error(t)})),l&&(r.unsubscribe(),r=null,s())};s()})}},1478(t,e,r){"use strict";r.d(e,{l:()=>a});var n=r(6195),i=r(9097),s=r(2185),o=r(869);function a(t){return(0,s.N)(function(e,r){var s,a,c=!1,u=function(){s=e.subscribe((0,o._)(r,void 0,void 0,function(e){a||(a=new i.B,(0,n.Tg)(t(a)).subscribe((0,o._)(r,function(){return s?u():c=!0}))),a&&a.next(e)})),c&&(s.unsubscribe(),s=null,c=!1,u())};u()})}},7073(t,e,r){"use strict";r.d(e,{X:()=>a});var n=r(6195),i=r(2185),s=r(2508),o=r(869);function a(t){return(0,i.N)(function(e,r){var i=!1,a=null;e.subscribe((0,o._)(r,function(t){i=!0,a=t})),(0,n.Tg)(t).subscribe((0,o._)(r,function(){if(i){i=!1;var t=a;a=null,r.next(t)}},s.l))})}},84(t,e,r){"use strict";r.d(e,{q:()=>o});var n=r(4611),i=r(7073),s=r(6726);function o(t,e){return void 0===e&&(e=n.E),(0,i.X)((0,s.Y)(t,e))}},510(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(8906);function s(t,e){return(0,n.N)((0,i.S)(t,e,arguments.length>=2,!0))}},8906(t,e,r){"use strict";r.d(e,{S:()=>i});var n=r(869);function i(t,e,r,i,s){return function(o,a){var c=r,u=e,l=0;o.subscribe((0,n._)(a,function(e){var r=l++;u=c?t(u,e,r):(c=!0,e),i&&a.next(u)},s&&function(){c&&a.next(u),a.complete()}))}}},4112(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(2185),i=r(869),s=r(6195);function o(t,e){return void 0===e&&(e=function(t,e){return t===e}),(0,n.N)(function(r,n){var o={buffer:[],complete:!1},a={buffer:[],complete:!1},c=function(t){n.next(t),n.complete()},u=function(t,r){var s=(0,i._)(n,function(n){var i=r.buffer,s=r.complete;0===i.length?s?c(!1):t.buffer.push(n):!e(n,i.shift())&&c(!1)},function(){t.complete=!0;var e=r.complete,n=r.buffer;e&&c(0===n.length),null==s||s.unsubscribe()});return s};r.subscribe(u(o,a)),(0,s.Tg)(t).subscribe(u(a,o))})}},1452(t,e,r){"use strict";r.d(e,{u:()=>c});var n=r(5608),i=r(6195),s=r(9097),o=r(557),a=r(2185);function c(t){void 0===t&&(t={});var e=t.connector,r=void 0===e?function(){return new s.B}:e,n=t.resetOnError,c=void 0===n||n,l=t.resetOnComplete,h=void 0===l||l,f=t.resetOnRefCountZero,d=void 0===f||f;return function(t){var e,n,s,l=0,f=!1,p=!1,g=function(){null==n||n.unsubscribe(),n=void 0},m=function(){g(),e=s=void 0,f=p=!1},y=function(){var t=e;m(),null==t||t.unsubscribe()};return(0,a.N)(function(t,a){l++,p||f||g();var b=s=null!=s?s:r();a.add(function(){0!==--l||p||f||(n=u(y,d))}),b.subscribe(a),!e&&l>0&&(e=new o.Ms({next:function(t){return b.next(t)},error:function(t){p=!0,g(),n=u(m,c,t),b.error(t)},complete:function(){f=!0,g(),n=u(m,h),b.complete()}}),(0,i.Tg)(t).subscribe(e))})(t)}}function u(t,e){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];if(!0!==e){if(!1!==e){var a=new o.Ms({next:function(){a.unsubscribe(),t()}});return(0,i.Tg)(e.apply(void 0,(0,n.fX)([],(0,n.zs)(r)))).subscribe(a)}}else t()}},4103(t,e,r){"use strict";r.d(e,{t:()=>s});var n=r(5404),i=r(1452);function s(t,e,r){var s,o,a,c,u=!1;return t&&"object"==typeof t?(s=t.bufferSize,c=void 0===s?1/0:s,o=t.windowTime,e=void 0===o?1/0:o,u=void 0!==(a=t.refCount)&&a,r=t.scheduler):c=null!=t?t:1/0,(0,i.u)({connector:function(){return new n.m(c,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:u})}},4623(t,e,r){"use strict";r.d(e,{J:()=>c});var n=r(1585),i=r(6611),s=r(1753),o=r(2185),a=r(869);function c(t){return(0,o.N)(function(e,r){var o,c=!1,u=!1,l=0;e.subscribe((0,a._)(r,function(n){u=!0,t&&!t(n,l++,e)||(c&&r.error(new i.I("Too many matching values")),c=!0,o=n)},function(){c?(r.next(o),r.complete()):r.error(u?new s.m("No matching values"):new n.G)}))})}},3616(t,e,r){"use strict";r.d(e,{i:()=>i});var n=r(465);function i(t){return(0,n.p)(function(e,r){return t<=r})}},5152(t,e,r){"use strict";r.d(e,{G:()=>o});var n=r(4254),i=r(2185),s=r(869);function o(t){return t<=0?n.D:(0,i.N)(function(e,r){var n=new Array(t),i=0;return e.subscribe((0,s._)(r,function(e){var s=i++;if(s<t)n[s]=e;else{var o=s%t,a=n[o];n[o]=e,r.next(a)}})),function(){n=null}})}},3430(t,e,r){"use strict";r.d(e,{U:()=>a});var n=r(2185),i=r(869),s=r(6195),o=r(2508);function a(t){return(0,n.N)(function(e,r){var n=!1,a=(0,i._)(r,function(){null==a||a.unsubscribe(),n=!0},o.l);(0,s.Tg)(t).subscribe(a),e.subscribe((0,i._)(r,function(t){return n&&r.next(t)}))})}},9955(t,e,r){"use strict";r.d(e,{j:()=>s});var n=r(2185),i=r(869);function s(t){return(0,n.N)(function(e,r){var n=!1,s=0;e.subscribe((0,i._)(r,function(e){return(n||(n=!t(e,s++)))&&r.next(e)}))})}},8263(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(7083),i=r(5361),s=r(2185);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.lI)(t);return(0,s.N)(function(e,i){(r?(0,n.x)(t,e,r):(0,n.x)(t,e)).subscribe(i)})}},6518(t,e,r){"use strict";r.d(e,{_:()=>i});var n=r(2185);function i(t,e){return void 0===e&&(e=0),(0,n.N)(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}},5056(t,e,r){"use strict";r.d(e,{w:()=>s});var n=r(8737),i=r(4254);function s(){return(0,n.n)(i.D)}},8737(t,e,r){"use strict";r.d(e,{n:()=>o});var n=r(6195),i=r(2185),s=r(869);function o(t,e){return(0,i.N)(function(r,i){var o=null,a=0,c=!1,u=function(){return c&&!o&&i.complete()};r.subscribe((0,s._)(i,function(r){null==o||o.unsubscribe();var c=0,l=a++;(0,n.Tg)(t(r,l)).subscribe(o=(0,s._)(i,function(t){return i.next(e?e(r,t,l,c++):t)},function(){o=null,u()}))},function(){c=!0,u()}))})}},1200(t,e,r){"use strict";r.d(e,{K:()=>s});var n=r(8737),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.n)(function(){return t},e):(0,n.n)(function(){return t})}},2570(t,e,r){"use strict";r.d(e,{m:()=>s});var n=r(8737),i=r(2185);function s(t,e){return(0,i.N)(function(r,i){var s=e;return(0,n.n)(function(e,r){return t(s,e,r)},function(t,e){return s=e,e})(r).subscribe(i),function(){s=null}})}},5172(t,e,r){"use strict";r.d(e,{s:()=>o});var n=r(1166),i=r(2185),s=r(869);function o(t){return t<=0?function(){return n.w}:(0,i.N)(function(e,r){var n=0;e.subscribe((0,s._)(r,function(e){++n<=t&&(r.next(e),t<=n&&r.complete())}))})}},3172(t,e,r){"use strict";r.d(e,{o:()=>a});var n=r(5608),i=r(1166),s=r(2185),o=r(869);function a(t){return t<=0?function(){return i.w}:(0,s.N)(function(e,r){var i=[];e.subscribe((0,o._)(r,function(e){i.push(e),t<i.length&&i.shift()},function(){var t,e;try{for(var s=(0,n.Ju)(i),o=s.next();!o.done;o=s.next()){var a=o.value;r.next(a)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}r.complete()},void 0,function(){i=null}))})}},1762(t,e,r){"use strict";r.d(e,{Q:()=>a});var n=r(2185),i=r(869),s=r(6195),o=r(2508);function a(t){return(0,n.N)(function(e,r){(0,s.Tg)(t).subscribe((0,i._)(r,function(){return r.complete()},o.l)),!r.closed&&e.subscribe(r)})}},247(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(2185),i=r(869);function s(t,e){return void 0===e&&(e=!1),(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){var i=t(r,s++);(i||e)&&n.next(r),!i&&n.complete()}))})}},8322(t,e,r){"use strict";r.d(e,{M:()=>a});var n=r(4460),i=r(2185),s=r(869),o=r(4254);function a(t,e,r){var a=(0,n.T)(t)||e||r?{next:t,error:e,complete:r}:t;return a?(0,i.N)(function(t,e){var r;null===(r=a.subscribe)||void 0===r||r.call(a);var n=!0;t.subscribe((0,s._)(e,function(t){var r;null===(r=a.next)||void 0===r||r.call(a,t),e.next(t)},function(){var t;n=!1,null===(t=a.complete)||void 0===t||t.call(a),e.complete()},function(t){var r;n=!1,null===(r=a.error)||void 0===r||r.call(a,t),e.error(t)},function(){var t,e;n&&(null===(t=a.unsubscribe)||void 0===t||t.call(a)),null===(e=a.finalize)||void 0===e||e.call(a)}))}):o.D}},8359(t,e,r){"use strict";r.d(e,{n:()=>o});var n=r(2185),i=r(869),s=r(6195);function o(t,e){return(0,n.N)(function(r,n){var o=null!=e?e:{},a=o.leading,c=void 0===a||a,u=o.trailing,l=void 0!==u&&u,h=!1,f=null,d=null,p=!1,g=function(){null==d||d.unsubscribe(),d=null,l&&(b(),p&&n.complete())},m=function(){d=null,p&&n.complete()},y=function(e){return d=(0,s.Tg)(t(e)).subscribe((0,i._)(n,g,m))},b=function(){if(h){h=!1;var t=f;f=null,n.next(t),!p&&y(t)}};r.subscribe((0,i._)(n,function(t){h=!0,f=t,(!d||d.closed)&&(c?b():y(t))},function(){p=!0,(!(l&&h&&d)||d.closed)&&n.complete()}))})}},626(t,e,r){"use strict";r.d(e,{c:()=>o});var n=r(4611),i=r(8359),s=r(6302);function o(t,e,r){void 0===e&&(e=n.E);var o=(0,s.O)(t,e);return(0,i.n)(function(){return o},r)}},5007(t,e,r){"use strict";r.d(e,{v:()=>o});var n=r(1585),i=r(2185),s=r(869);function o(t){return void 0===t&&(t=a),(0,i.N)(function(e,r){var n=!1;e.subscribe((0,s._)(r,function(t){n=!0,r.next(t)},function(){return n?r.complete():r.error(t())}))})}function a(){return new n.G}},5223(t,e,r){"use strict";r.d(e,{f:()=>o});var n=r(4611),i=r(2185),s=r(869);function o(t){return void 0===t&&(t=n.E),(0,i.N)(function(e,r){var n=t.now();e.subscribe((0,s._)(r,function(e){var i=t.now(),s=i-n;n=i,r.next(new a(e,s))}))})}var a=function(t,e){this.value=t,this.interval=e}},3572(t,e,r){"use strict";r.d(e,{M:()=>l,w:()=>h});var n=r(4611),i=r(1592),s=r(2185),o=r(6195),a=r(4166),c=r(869),u=r(4184),l=(0,a.L)(function(t){return function(e){void 0===e&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function h(t,e){var r=(0,i.v)(t)?{first:t}:"number"==typeof t?{each:t}:t,a=r.first,l=r.each,h=r.with,d=void 0===h?f:h,p=r.scheduler,g=void 0===p?null!=e?e:n.E:p,m=r.meta,y=void 0===m?null:m;if(null==a&&null==l)throw new TypeError("No timeout provided.");return(0,s.N)(function(t,e){var r,n,i=null,s=0,h=function(t){n=(0,u.N)(e,g,function(){try{r.unsubscribe(),(0,o.Tg)(d({meta:y,lastValue:i,seen:s})).subscribe(e)}catch(t){e.error(t)}},t)};r=t.subscribe((0,c._)(e,function(t){null==n||n.unsubscribe(),s++,e.next(i=t),l>0&&h(l)},void 0,void 0,function(){(null==n?void 0:n.closed)||null==n||n.unsubscribe(),i=null})),!s&&h(null!=a?"number"==typeof a?a:+a-g.now():l)})}function f(t){throw new l(t)}},3868(t,e,r){"use strict";r.d(e,{o:()=>o});var n=r(4611),i=r(1592),s=r(3572);function o(t,e,r){var o,a,c;if(r=null!=r?r:n.b,(0,i.v)(t)?o=t:"number"==typeof t&&(a=t),!e)throw new TypeError("No observable provided to switch to");if(c=function(){return e},null==o&&null==a)throw new TypeError("No timeout provided.");return(0,s.w)({first:o,each:a,scheduler:r,with:c})}},6715(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(8154),i=r(8045);function s(t){return void 0===t&&(t=n.U),(0,i.T)(function(e){return{value:e,timestamp:t.now()}})}},2033(t,e,r){"use strict";r.d(e,{$:()=>o});var n=r(8933),i=r(2185),s=function(t,e){return t.push(e),t};function o(){return(0,i.N)(function(t,e){(0,n.T)(s,[])(t).subscribe(e)})}},6063(t,e,r){"use strict";r.d(e,{x:()=>c});var n=r(9097),i=r(2185),s=r(869),o=r(2508),a=r(6195);function c(t){return(0,i.N)(function(e,r){var i=new n.B;r.next(i.asObservable());var c=function(t){i.error(t),r.error(t)};return e.subscribe((0,s._)(r,function(t){return null==i?void 0:i.next(t)},function(){i.complete(),r.complete()},c)),(0,a.Tg)(t).subscribe((0,s._)(r,function(){i.complete(),r.next(i=new n.B)},o.l,c)),function(){null==i||i.unsubscribe(),i=null}})}},1252(t,e,r){"use strict";r.d(e,{k:()=>a});var n=r(5608),i=r(9097),s=r(2185),o=r(869);function a(t,e){void 0===e&&(e=0);var r=e>0?e:t;return(0,s.N)(function(e,s){var a=[new i.B],c=0;s.next(a[0].asObservable()),e.subscribe((0,o._)(s,function(e){var o,u;try{for(var l=(0,n.Ju)(a),h=l.next();!h.done;h=l.next()){h.value.next(e)}}catch(t){o={error:t}}finally{try{h&&!h.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}var f=c-t+1;if(f>=0&&f%r===0&&a.shift().complete(),++c%r===0){var d=new i.B;a.push(d),s.next(d.asObservable())}},function(){for(;a.length>0;)a.shift().complete();s.complete()},function(t){for(;a.length>0;)a.shift().error(t);s.error(t)},function(){a=null}))})}},8442(t,e,r){"use strict";r.d(e,{s:()=>h});var n=r(9097),i=r(4611),s=r(1868),o=r(2185),a=r(869),c=r(1601),u=r(5361),l=r(4184);function h(t){for(var e,r,h=[],f=1;f<arguments.length;f++)h[f-1]=arguments[f];var d=null!==(e=(0,u.lI)(h))&&void 0!==e?e:i.E,p=null!==(r=h[0])&&void 0!==r?r:null,g=h[1]||1/0;return(0,o.N)(function(e,r){var i=[],o=!1,u=function(t){var e=t.window,r=t.subs;e.complete(),r.unsubscribe(),(0,c.o)(i,t),o&&h()},h=function(){if(i){var e=new s.yU;r.add(e);var o=new n.B,a={window:o,subs:e,seen:0};i.push(a),r.next(o.asObservable()),(0,l.N)(e,d,function(){return u(a)},t)}};null!==p&&p>=0?(0,l.N)(r,d,h,p,!0):o=!0,h();var f=function(t){return i.slice().forEach(t)},m=function(t){f(function(e){var r=e.window;return t(r)}),t(r),r.unsubscribe()};return e.subscribe((0,a._)(r,function(t){f(function(e){e.window.next(t),g<=++e.seen&&u(e)})},function(){return m(function(t){return t.complete()})},function(t){return m(function(e){return e.error(t)})})),function(){i=null}})}},8771(t,e,r){"use strict";r.d(e,{J:()=>h});var n=r(5608),i=r(9097),s=r(1868),o=r(2185),a=r(6195),c=r(869),u=r(2508),l=r(1601);function h(t,e){return(0,o.N)(function(r,o){var h=[],f=function(t){for(;0<h.length;)h.shift().error(t);o.error(t)};(0,a.Tg)(t).subscribe((0,c._)(o,function(t){var r=new i.B;h.push(r);var n,d=new s.yU;try{n=(0,a.Tg)(e(t))}catch(t){return void f(t)}o.next(r.asObservable()),d.add(n.subscribe((0,c._)(o,function(){(0,l.o)(h,r),r.complete(),d.unsubscribe()},u.l,f)))},u.l)),r.subscribe((0,c._)(o,function(t){var e,r,i=h.slice();try{for(var s=(0,n.Ju)(i),o=s.next();!o.done;o=s.next()){o.value.next(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}},function(){for(;0<h.length;)h.shift().complete();o.complete()},f,function(){for(;0<h.length;)h.shift().unsubscribe()}))})}},63(t,e,r){"use strict";r.d(e,{p:()=>a});var n=r(9097),i=r(2185),s=r(869),o=r(6195);function a(t){return(0,i.N)(function(e,r){var i,a,c=function(t){i.error(t),r.error(t)},u=function(){var e;null==a||a.unsubscribe(),null==i||i.complete(),i=new n.B,r.next(i.asObservable());try{e=(0,o.Tg)(t())}catch(t){return void c(t)}e.subscribe(a=(0,s._)(r,u,u,c))};u(),e.subscribe((0,s._)(r,function(t){return i.next(t)},function(){i.complete(),r.complete()},c,function(){null==a||a.unsubscribe(),i=null}))})}},6248(t,e,r){"use strict";r.d(e,{E:()=>l});var n=r(5608),i=r(2185),s=r(869),o=r(6195),a=r(4254),c=r(2508),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t);return(0,i.N)(function(e,i){for(var u=t.length,l=new Array(u),h=t.map(function(){return!1}),f=!1,d=function(e){(0,o.Tg)(t[e]).subscribe((0,s._)(i,function(t){l[e]=t,f||h[e]||(h[e]=!0,(f=h.every(a.D))&&(h=null))},c.l))},p=0;p<u;p++)d(p);e.subscribe((0,s._)(i,function(t){if(f){var e=(0,n.fX)([t],(0,n.zs)(l));i.next(r?r.apply(void 0,(0,n.fX)([],(0,n.zs)(e))):e)}}))})}},2440(t,e,r){"use strict";r.d(e,{y:()=>o});var n=r(5608),i=r(9568),s=r(2185);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,s.N)(function(e,r){i.y.apply(void 0,(0,n.fX)([e],(0,n.zs)(t))).subscribe(r)})}},137(t,e,r){"use strict";r.d(e,{x:()=>s});var n=r(9568),i=r(9732);function s(t){return(0,i.q)(n.y,t)}},464(t,e,r){"use strict";r.d(e,{O:()=>s});var n=r(5608),i=r(2440);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.y.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},9862(t,e,r){"use strict";r.d(e,{S:()=>a});var n=r(1824),i=r(9758),s=r(4460),o=r(4184);function a(t,e){return new n.c(function(r){var n;return(0,o.N)(r,e,function(){n=t[i.l](),(0,o.N)(r,e,function(){var t,e,i;try{e=(t=n.next()).value,i=t.done}catch(t){return void r.error(t)}i?r.complete():r.next(e)},0,!0)}),function(){return(0,s.T)(null==n?void 0:n.return)&&n.return()}})}},489(t,e,r){"use strict";r.d(e,{c:()=>y});var n=r(6195),i=r(5106),s=r(6518);var o=r(1824);var a=r(9862),c=r(4184);function u(t,e){if(!t)throw new Error("Iterable cannot be null");return new o.c(function(r){(0,c.N)(r,e,function(){var n=t[Symbol.asyncIterator]();(0,c.N)(r,e,function(){n.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}var l=r(3330),h=r(6691),f=r(1604),d=r(3206),p=r(4956),g=r(4904),m=r(8523);function y(t,e){if(null!=t){if((0,l.l)(t))return function(t,e){return(0,n.Tg)(t).pipe((0,s._)(e),(0,i.Q)(e))}(t,e);if((0,f.X)(t))return function(t,e){return new o.c(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}(t,e);if((0,h.y)(t))return function(t,e){return(0,n.Tg)(t).pipe((0,s._)(e),(0,i.Q)(e))}(t,e);if((0,p.T)(t))return u(t,e);if((0,d.x)(t))return(0,a.S)(t,e);if((0,m.U)(t))return function(t,e){return u((0,m.C)(t),e)}(t,e)}throw(0,g.L)(t)}},7771(t,e,r){"use strict";r.d(e,{R:()=>a});var n=r(5608),i=function(t){function e(e,r){return t.call(this)||this}return(0,n.C6)(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(r(1868).yU),s={setInterval:function(t,e){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var o=s.delegate;return(null==o?void 0:o.setInterval)?o.setInterval.apply(o,(0,n.fX)([t,e],(0,n.zs)(r))):setInterval.apply(void 0,(0,n.fX)([t,e],(0,n.zs)(r)))},clearInterval:function(t){var e=s.delegate;return((null==e?void 0:e.clearInterval)||clearInterval)(t)},delegate:void 0},o=r(1601),a=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return(0,n.C6)(e,t),e.prototype.schedule=function(t,e){var r;if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,e)),this.pending=!0,this.delay=e,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),s.setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return e;null!=e&&s.clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r,n=!1;try{this.work(t)}catch(t){n=!0,r=t||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},e.prototype.unsubscribe=function(){if(!this.closed){var e=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,(0,o.o)(n,this),null!=e&&(this.id=this.recycleAsyncId(r,e,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(i)},7042(t,e,r){"use strict";r.d(e,{q:()=>s});var n=r(5608),i=r(4644),s=function(t){function e(e,r){void 0===r&&(r=i._.now);var n=t.call(this,e,r)||this;return n.actions=[],n._active=!1,n}return(0,n.C6)(e,t),e.prototype.flush=function(t){var e=this.actions;if(this._active)e.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this._active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(i._)},4611(t,e,r){"use strict";r.d(e,{E:()=>i,b:()=>s});var n=r(7771),i=new(r(7042).q)(n.R),s=i},8154(t,e,r){"use strict";r.d(e,{U:()=>n});var n={now:function(){return(n.delegate||Date).now()},delegate:void 0}},533(t,e,r){"use strict";r.d(e,{f:()=>i});var n=r(5608),i={setTimeout:function(t,e){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];var o=i.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,(0,n.fX)([t,e],(0,n.zs)(r))):setTimeout.apply(void 0,(0,n.fX)([t,e],(0,n.zs)(r)))},clearTimeout:function(t){var e=i.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0}},9758(t,e,r){"use strict";r.d(e,{l:()=>n});var n="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"},9805(t,e,r){"use strict";r.d(e,{s:()=>n});var n="function"==typeof Symbol&&Symbol.observable||"@@observable"},5339(t,e,r){"use strict";r.d(e,{k:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})},1585(t,e,r){"use strict";r.d(e,{G:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})},1753(t,e,r){"use strict";r.d(e,{m:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})},8032(t,e,r){"use strict";r.d(e,{P:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})},6611(t,e,r){"use strict";r.d(e,{I:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})},402(t,e,r){"use strict";r.d(e,{Z:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}})},5361(t,e,r){"use strict";r.d(e,{R0:()=>c,lI:()=>a,ms:()=>o});var n=r(4460),i=r(1867);function s(t){return t[t.length-1]}function o(t){return(0,n.T)(s(t))?t.pop():void 0}function a(t){return(0,i.m)(s(t))?t.pop():void 0}function c(t,e){return"number"==typeof s(t)?t.pop():e}},1854(t,e,r){"use strict";r.d(e,{D:()=>a});var n=Array.isArray,i=Object.getPrototypeOf,s=Object.prototype,o=Object.keys;function a(t){if(1===t.length){var e=t[0];if(n(e))return{args:e,keys:null};if((a=e)&&"object"==typeof a&&i(a)===s){var r=o(e);return{args:r.map(function(t){return e[t]}),keys:r}}}var a;return{args:t,keys:null}}},7589(t,e,r){"use strict";r.d(e,{K:()=>i});var n=Array.isArray;function i(t){return 1===t.length&&n(t[0])?t[0]:t}},1601(t,e,r){"use strict";function n(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}r.d(e,{o:()=>n})},4166(t,e,r){"use strict";function n(t){var e=t(function(t){Error.call(t),t.stack=(new Error).stack});return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}r.d(e,{L:()=>n})},9407(t,e,r){"use strict";function n(t,e){return t.reduce(function(t,r,n){return t[r]=e[n],t},{})}r.d(e,{e:()=>n})},7861(t,e,r){"use strict";r.d(e,{Y:()=>s,l:()=>o});var n=r(747),i=null;function s(t){if(n.$.useDeprecatedSynchronousErrorHandling){var e=!i;if(e&&(i={errorThrown:!1,error:null}),t(),e){var r=i,s=r.errorThrown,o=r.error;if(i=null,s)throw o}}else t()}function o(t){n.$.useDeprecatedSynchronousErrorHandling&&i&&(i.errorThrown=!0,i.error=t)}},4184(t,e,r){"use strict";function n(t,e,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var s=e.schedule(function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(s),!i)return s}r.d(e,{N:()=>n})},4254(t,e,r){"use strict";function n(t){return t}r.d(e,{D:()=>n})},1604(t,e,r){"use strict";r.d(e,{X:()=>n});var n=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},4956(t,e,r){"use strict";r.d(e,{T:()=>i});var n=r(4460);function i(t){return Symbol.asyncIterator&&(0,n.T)(null==t?void 0:t[Symbol.asyncIterator])}},1592(t,e,r){"use strict";function n(t){return t instanceof Date&&!isNaN(t)}r.d(e,{v:()=>n})},4460(t,e,r){"use strict";function n(t){return"function"==typeof t}r.d(e,{T:()=>n})},3330(t,e,r){"use strict";r.d(e,{l:()=>s});var n=r(9805),i=r(4460);function s(t){return(0,i.T)(t[n.s])}},3206(t,e,r){"use strict";r.d(e,{x:()=>s});var n=r(9758),i=r(4460);function s(t){return(0,i.T)(null==t?void 0:t[n.l])}},6691(t,e,r){"use strict";r.d(e,{y:()=>i});var n=r(4460);function i(t){return(0,n.T)(null==t?void 0:t.then)}},8523(t,e,r){"use strict";r.d(e,{C:()=>s,U:()=>o});var n=r(5608),i=r(4460);function s(t){return(0,n.AQ)(this,arguments,function(){var e,r,i;return(0,n.YH)(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,(0,n.N3)(e.read())];case 3:return r=s.sent(),i=r.value,r.done?[4,(0,n.N3)(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,(0,n.N3)(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function o(t){return(0,i.T)(null==t?void 0:t.getReader)}},1867(t,e,r){"use strict";r.d(e,{m:()=>i});var n=r(4460);function i(t){return t&&(0,n.T)(t.schedule)}},2185(t,e,r){"use strict";r.d(e,{N:()=>s,S:()=>i});var n=r(4460);function i(t){return(0,n.T)(null==t?void 0:t.lift)}function s(t){return function(e){if(i(e))return e.lift(function(e){try{return t(e,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}},4981(t,e,r){"use strict";r.d(e,{I:()=>o});var n=r(5608),i=r(8045),s=Array.isArray;function o(t){return(0,i.T)(function(e){return function(t,e){return s(e)?t.apply(void 0,(0,n.fX)([],(0,n.zs)(e))):t(e)}(t,e)})}},2508(t,e,r){"use strict";function n(){}r.d(e,{l:()=>n})},8371(t,e,r){"use strict";function n(t,e){return function(r,n){return!t.call(e,r,n)}}r.d(e,{A:()=>n})},3404(t,e,r){"use strict";r.d(e,{F:()=>i,m:()=>s});var n=r(4254);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(t)}function s(t){return 0===t.length?n.D:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}},3585(t,e,r){"use strict";r.d(e,{m:()=>s});var n=r(747),i=r(533);function s(t){i.f.setTimeout(function(){var e=n.$.onUnhandledError;if(!e)throw t;e(t)})}},4904(t,e,r){"use strict";function n(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}r.d(e,{L:()=>n})},1018(t,e,r){"use strict";r.r(e),r.d(e,{audit:()=>n.s,auditTime:()=>i.Z,buffer:()=>s.r,bufferCount:()=>o.S,bufferTime:()=>a.w,bufferToggle:()=>c.H,bufferWhen:()=>u.n,catchError:()=>l.W,combineAll:()=>h.p,combineLatest:()=>d.z,combineLatestAll:()=>f.A,combineLatestWith:()=>p.v,concat:()=>g.x,concatAll:()=>m.K,concatMap:()=>y.H,concatMapTo:()=>b.S,concatWith:()=>v.$,connect:()=>w.N,count:()=>E.U,debounce:()=>_.s,debounceTime:()=>A.B,defaultIfEmpty:()=>O.U,delay:()=>S.c,delayWhen:()=>T.o,dematerialize:()=>P.Z,distinct:()=>R.d,distinctUntilChanged:()=>x.F,distinctUntilKeyChanged:()=>I.w,elementAt:()=>N.s,endWith:()=>k.q,every:()=>L.S,exhaust:()=>C.B,exhaustAll:()=>M.C,exhaustMap:()=>B.p,expand:()=>D.f,filter:()=>U.p,finalize:()=>K.j,find:()=>H.I,findIndex:()=>F.S,first:()=>G.$,flatMap:()=>Q.q,groupBy:()=>V.$,ignoreElements:()=>j.w,isEmpty:()=>$.I,last:()=>z.H,map:()=>q.T,mapTo:()=>W.u,materialize:()=>Z.O,max:()=>Y.T,merge:()=>X.h,mergeAll:()=>J.U,mergeMap:()=>tt.Z,mergeMapTo:()=>et.C,mergeScan:()=>rt.i,mergeWith:()=>nt.X,min:()=>it.j,multicast:()=>st.f,observeOn:()=>ot.Q,onErrorResumeNext:()=>at.g,pairwise:()=>ct.J,partition:()=>lt,pluck:()=>ht.E,publish:()=>ft.m,publishBehavior:()=>dt.K,publishLast:()=>pt.k,publishReplay:()=>gt.H,race:()=>vt,raceWith:()=>bt.w,reduce:()=>wt.T,refCount:()=>St.B,repeat:()=>Et.u,repeatWhen:()=>_t.Y,retry:()=>At.L,retryWhen:()=>Ot.l,sample:()=>Tt.X,sampleTime:()=>Pt.q,scan:()=>Rt.S,sequenceEqual:()=>xt.m,share:()=>It.u,shareReplay:()=>Nt.t,single:()=>kt.J,skip:()=>Lt.i,skipLast:()=>Ct.G,skipUntil:()=>Mt.U,skipWhile:()=>Bt.j,startWith:()=>Dt.Z,subscribeOn:()=>Ut._,switchAll:()=>Kt.w,switchMap:()=>Ht.n,switchMapTo:()=>Ft.K,switchScan:()=>Gt.m,take:()=>Vt.s,takeLast:()=>jt.o,takeUntil:()=>$t.Q,takeWhile:()=>zt.v,tap:()=>qt.M,throttle:()=>Wt.n,throttleTime:()=>Zt.c,throwIfEmpty:()=>Yt.v,timeInterval:()=>Xt.f,timeout:()=>Jt.w,timeoutWith:()=>Qt.o,timestamp:()=>te.v,toArray:()=>ee.$,window:()=>re.x,windowCount:()=>ne.k,windowTime:()=>ie.s,windowToggle:()=>se.J,windowWhen:()=>oe.p,withLatestFrom:()=>ae.E,zip:()=>ce.y,zipAll:()=>ue.x,zipWith:()=>le.O});var n=r(4168),i=r(7013),s=r(9801),o=r(9542),a=r(3132),c=r(6145),u=r(6689),l=r(672),h=r(8363),f=r(9142),d=r(1481),p=r(8957),g=r(3267),m=r(2348),y=r(949),b=r(4292),v=r(4011),w=r(1715),E=r(6456),_=r(9780),A=r(5833),O=r(4228),S=r(2840),T=r(6660),P=r(1023),R=r(7435),x=r(5519),I=r(5538),N=r(6026),k=r(7566),L=r(5060),C=r(8017),M=r(5598),B=r(5711),D=r(2467),U=r(465),K=r(8553),H=r(4732),F=r(5206),G=r(4053),V=r(7333),j=r(9756),$=r(3694),z=r(2187),q=r(8045),W=r(3692),Z=r(6326),Y=r(7877),X=r(3375),J=r(9904),Q=r(9016),tt=r(6961),et=r(2720),rt=r(26),nt=r(6343),it=r(8287),st=r(3045),ot=r(5106),at=r(1264),ct=r(9127),ut=r(8371);function lt(t,e){return function(r){return[(0,U.p)(t,e)(r),(0,U.p)((0,ut.A)(t,e))(r)]}}var ht=r(8614),ft=r(1996),dt=r(9514),pt=r(2812),gt=r(4679),mt=r(5608),yt=r(7589),bt=r(8702);function vt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bt.w.apply(void 0,(0,mt.fX)([],(0,mt.zs)((0,yt.K)(t))))}var wt=r(8933),Et=r(744),_t=r(1204),At=r(9185),Ot=r(1478),St=r(8815),Tt=r(7073),Pt=r(84),Rt=r(510),xt=r(4112),It=r(1452),Nt=r(4103),kt=r(4623),Lt=r(3616),Ct=r(5152),Mt=r(3430),Bt=r(9955),Dt=r(8263),Ut=r(6518),Kt=r(5056),Ht=r(8737),Ft=r(1200),Gt=r(2570),Vt=r(5172),jt=r(3172),$t=r(1762),zt=r(247),qt=r(8322),Wt=r(8359),Zt=r(626),Yt=r(5007),Xt=r(5223),Jt=r(3572),Qt=r(3868),te=r(6715),ee=r(2033),re=r(6063),ne=r(1252),ie=r(8442),se=r(8771),oe=r(63),ae=r(6248),ce=r(2440),ue=r(137),le=r(464)},2100(t){t.exports=function(t){return ArrayBuffer.isView(t)?Buffer.from(t.buffer,t.byteOffset,t.byteLength):Buffer.from(t)}},6571(t,e,r){"use strict";var n;r.r(e),r.d(e,{DeprecationError:()=>I,InvalidAddressError:()=>f,InvalidAmountError:()=>y,InvalidBlockHashError:()=>m,InvalidChainIdError:()=>T,InvalidContractAddressError:()=>S,InvalidDerivationPathError:()=>b,InvalidFinalizeUnstakeAmountError:()=>g,InvalidHexStringError:()=>v,InvalidKeyError:()=>_,InvalidKeyHashError:()=>P,InvalidMessageError:()=>w,InvalidOperationHashError:()=>R,InvalidOperationKindError:()=>x,InvalidProofError:()=>d,InvalidPublicKeyError:()=>A,InvalidSignatureError:()=>O,InvalidStakingAddressError:()=>p,InvalidViewParameterError:()=>E,NetworkError:()=>l,ParameterValidationError:()=>o,PermissionDeniedError:()=>h,ProhibitedActionError:()=>N,PublicKeyNotFoundError:()=>k,RpcError:()=>a,TaquitoError:()=>s,TezosToolkitConfigError:()=>c,UnsupportedActionError:()=>u,ValidationResult:()=>n}),function(t){t[t.NO_PREFIX_MATCHED=0]="NO_PREFIX_MATCHED",t[t.INVALID_CHECKSUM=1]="INVALID_CHECKSUM",t[t.INVALID_LENGTH=2]="INVALID_LENGTH",t[t.VALID=3]="VALID",t[t.PREFIX_NOT_ALLOWED=4]="PREFIX_NOT_ALLOWED",t[t.INVALID_ENCODING=5]="INVALID_ENCODING",t[t.OTHER=6]="OTHER"}(n||(n={}));const i={[n.NO_PREFIX_MATCHED]:"unsupported Base58 prefix",[n.INVALID_CHECKSUM]:"invalid checksum",[n.INVALID_LENGTH]:"invalid length",[n.PREFIX_NOT_ALLOWED]:"Base58 prefix not allowed in this context",[n.INVALID_ENCODING]:"invalid Base58 encoding"};class s extends Error{}class o extends s{constructor(t,e,r){let n,s,o;void 0!==t&&("string"==typeof t?(o=t,void 0!==e&&("string"==typeof e?n=e:(s=e,n=void 0!==r?r:i[e]))):(s=t,n=i[t],o=n)),super(o),this.name=this.constructor.name,this.result=s,this.errorDetail=n}}class a extends s{}class c extends s{}class u extends s{}class l extends s{}class h extends s{}class f extends o{constructor(t,e){super(`Invalid address "${t}"`,e),this.address=t,this.name=this.constructor.name}}class d extends o{constructor(t,e){super(`Invalid proof "${t}"`,e),this.proof=t,this.name=this.constructor.name}}class p extends o{constructor(t,e){super(`Invalid staking address "${t}", you can only set destination as your own address`,e),this.address=t,this.name=this.constructor.name}}class g extends o{constructor(t,e){super("The amount can only be 0 when finalizing an unstake",e),this.address=t,this.name=this.constructor.name}}class m extends o{constructor(t,e){super(`Invalid block hash "${t}"`,e),this.blockHash=t,this.name=this.constructor.name}}class y extends o{constructor(t,e){super(`Invalid amount "${t}"`,e),this.amount=t,this.name=this.constructor.name}}class b extends o{constructor(t,e){super(`Invalid derivation path "${t}"`,e),this.derivationPath=t,this.name=this.constructor.name}}class v extends o{constructor(t,e){super(`Invalid hex string "${t}"`,e),this.hexString=t,this.name=this.constructor.name}}class w extends o{constructor(t,e){super(`Invalid message "${t}"`,e),this.msg=t,this.name=this.constructor.name}}class E extends o{constructor(t,e,r,n,i){super(`Invalid view arguments ${JSON.stringify(r)} received for name "${t}" expecting one of the following signatures ${JSON.stringify(e)}.`,i),this.viewName=t,this.sigs=e,this.args=r,this.cause=n,this.name=this.constructor.name}}class _ extends o{constructor(t){super("Invalid private key",t),this.name=this.constructor.name}}class A extends o{constructor(t,e){super(void 0!==t?`Invalid public key "${t}"`:"Invalid public key",e),this.publicKey=t,this.name=this.constructor.name}}class O extends o{constructor(t,e){super(`Invalid signature "${t}"`,e),this.signature=t,this.name=this.constructor.name}}class S extends o{constructor(t,e){super(`Invalid contract address "${t}"`,e),this.contractAddress=t,this.name=this.constructor.name}}class T extends o{constructor(t,e){super(`Invalid chain id "${t}"`,e),this.chainId=t,this.name=this.constructor.name}}class P extends o{constructor(t,e){super(`Invalid public key hash "${t}"`,e),this.keyHash=t,this.name=this.constructor.name}}class R extends o{constructor(t,e){super(`Invalid operation hash "${t}"`,e),this.operationHash=t,this.name=this.constructor.name}}class x extends o{constructor(t,e){super(`Invalid operation kind "${t}"`,e),this.operationKind=t,this.name=this.constructor.name}}class I extends u{constructor(t){super(t),this.name=this.constructor.name}}class N extends u{constructor(t){super(t),this.name=this.constructor.name}}class k extends s{constructor(t,e){super(`Public key not found of this address "${t}" in either wallet or contract API.`),this.pkh=t,this.cause=e,this.name=this.constructor.name}}},2211(t,e,r){"use strict";r.r(e),r.d(e,{HttpBackend:()=>P,HttpRequestFailed:()=>i,HttpResponseError:()=>s,HttpTimeoutError:()=>o,STATUS_CODE:()=>f,VERSION:()=>d,classifyTransportError:()=>h});var n=r(6571);class i extends n.NetworkError{constructor(t,e,r,n){super(),this.method=t,this.url=e,this.cause=r,this.name="HttpRequestFailed";const i=function(t){let e=t,r=0;for(;!(r>=10);){const t=e.cause;if(!(t instanceof Error)){if("object"==typeof t&&null!==t&&"string"==typeof t.message){const r=t;e={message:r.message,code:"string"==typeof r.code?r.code:void 0};break}break}e=t,r++}return e}(r),s=i.code,o=i!==r?`${i.message}${s?` [${s}]`:""}`:r.message,a=n?` (${n.kind})`:"";this.message=`${t} ${e}${a}: ${o}`,this.transportError=n}}class s extends n.NetworkError{constructor(t,e,r,n,i){super(),this.message=t,this.status=e,this.statusText=r,this.body=n,this.url=i,this.name="HttpResponseError"}}class o extends n.NetworkError{constructor(t,e){super(),this.timeout=t,this.url=e,this.name="HttpTimeoutError",this.message=`HTTP request timeout of ${t}ms exceeded`}}const a={abort:!1,dns:!1,connect:!1,socket:!0,tls:!1,timeout:!0,network:!0};function c(t){if("object"!=typeof t||null===t)return;const e=t.code;return"string"==typeof e?e:void 0}function u(t){if("object"==typeof t&&null!==t)return t.cause}function l(t,e){return{kind:t,mayHaveReachedServer:a[t],original:e}}function h(t){if(!(t instanceof Error))return;const e=c(t),r=function(t){return c(u(t))}(t),n=t.message.toLowerCase(),i=function(t){const e=u(t);if("object"==typeof e&&null!==e){const t=e.message;if("string"==typeof t)return t.toLowerCase()}return""}(t);if("AbortError"===t.name)return l("abort",t);if("ENOTFOUND"===e||"EAI_AGAIN"===e||"ENOTFOUND"===r||"EAI_AGAIN"===r||n.includes("enotfound")||n.includes("eai_again"))return l("dns",t);if("ECONNREFUSED"===e||"ECONNREFUSED"===r||"UND_ERR_CONNECT_TIMEOUT"===r||n.includes("econnrefused"))return l("connect",t);if(n.includes("certificate")||n.includes("self signed")||n.includes("ssl")||n.includes("handshake")||i.includes("certificate")||i.includes("self signed")||i.includes("ssl")||i.includes("handshake"))return l("tls",t);if("ETIMEDOUT"===e||"ETIMEDOUT"===r||"UND_ERR_HEADERS_TIMEOUT"===r||"UND_ERR_BODY_TIMEOUT"===r||n.includes("etimedout")||n.includes("timed out"))return l("timeout",t);if("ECONNRESET"===e||"ECONNRESET"===r||"UND_ERR_SOCKET"===r||n.includes("econnreset")||n.includes("socket hang up")||n.includes("other side closed")||n.includes("closed unexpectedly")||n.includes("connection reset"))return l("socket",t);if(t instanceof TypeError&&(n.includes("fetch failed")||n.includes("failed to fetch")||n.includes("network error")||n.includes("error sending request")||"terminated"===n))return l("network",t);if("FetchError"===t.name){const e=t.type;return"request-timeout"===e||"body-timeout"===e?l("timeout",t):"system"===e?l("network",t):void 0}}var f;!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"}(f||(f={}));const d={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"};if("function"!=typeof globalThis.fetch)throw new Error("No fetch implementation available. Requires Node.js >= 22 or a browser environment.");const p="undefined"!=typeof process?process.env:void 0,g=/^(1|true)$/i.test(p?.TAQUITO_HTTP_TRACE??"")||"1"===p?.RUNNER_DEBUG,m=Number(p?.TAQUITO_HTTP_RETRY_COUNT??"1"),y=Number.isFinite(m)&&m>=0?Math.floor(m):1,b=Number(p?.TAQUITO_HTTP_RETRY_BASE_MS??"100"),v=Number.isFinite(b)&&b>=0?b:100,w=t=>{try{const e=new URL(t);return`${e.origin}${e.pathname}`}catch{return t.split("?")[0]}},E=t=>{g&&console.log(`[taquito:http-trace] ${JSON.stringify(t)}`)},_=t=>t.cause,A=t=>{const e=t.code;return"string"==typeof e?e:void 0},O=t=>{if(!(t instanceof Error))return String(t);const e=[`${t.name}: ${t.message}`];let r=_(t),n=0;for(;n<10;){if(r instanceof Error){const t=A(r),i=t?` [${t}]`:"";e.push(`${r.name}: ${r.message}${i}`),r=_(r),n++;continue}if("object"==typeof r&&null!==r&&"string"==typeof r.message){const t=r,n="string"==typeof t.code?t.code:void 0,i=n?` [${n}]`:"";e.push(`${t.message}${i}`)}break}return e.join(" → ")},S=(t,e)=>{const r=t.toUpperCase();if("GET"===r)return!0;if("POST"!==r)return!1;const n=w(e);return n.endsWith("/helpers/forge/operations")||n.endsWith("/helpers/preapply/operations")||n.endsWith("/helpers/scripts/simulate_operation")||n.endsWith("/helpers/scripts/run_operation")||n.endsWith("/injection/operation")},T=t=>new Promise(e=>setTimeout(e,t));class P{constructor(t=3e4){this.timeout=t}serialize(t){if(!t)return"";const e=[];for(const r in t)if(t.hasOwnProperty(r)&&void 0!==t[r]){const n=t[r];if(null===n){e.push(encodeURIComponent(r));continue}const i="function"==typeof n.toJSON?n.toJSON():n;if(null===i){e.push(encodeURIComponent(r));continue}if(Array.isArray(i)){i.forEach(t=>{e.push(encodeURIComponent(r)+"="+encodeURIComponent(t))});continue}e.push(encodeURIComponent(r)+"="+encodeURIComponent(i))}const r=e.join("&");return r?`?${r}`:""}async createRequest({url:t,method:e,timeout:r=this.timeout,query:n,headers:a={},json:c=!0},u){const l=t+this.serialize(n),f=String(e??"GET");let d;a["Content-Type"]||(a["Content-Type"]="application/json");let p=!1;for(let t=0;t<=y;t++){const n=new AbortController,g=setTimeout(()=>n.abort(),r),m=Date.now();try{p||(d=JSON.stringify(u),p=!0);const t=await globalThis.fetch(l,{method:e,headers:a,body:d,signal:n.signal});if(void 0===t)throw new Error("Response is undefined");if(t.status>=400){const e=await t.text();throw E({stage:"response-error",method:f,url:w(l),status:t.status,elapsedMs:Date.now()-m}),new s(`Http error response: (${t.status}) ${e}`,t.status,t.statusText,e,l)}return E({stage:"response-ok",method:f,url:w(l),status:t.status,elapsedMs:Date.now()-m}),c?t.json():t.text()}catch(e){if(e instanceof s)throw E({stage:"http-response-error",method:f,url:w(l),elapsedMs:Date.now()-m,status:e.status}),e;const n=e instanceof Error?h(e):void 0,a=void 0!==n&&"abort"!==n.kind&&"tls"!==n.kind;if(t<y&&S(f,l)&&a){const r=v*Math.pow(2,t)+Math.floor(Math.random()*v);E({stage:"request-retry",method:f,url:w(l),elapsedMs:Date.now()-m,attempt:t+1,maxAttempts:y+1,retryDelayMs:r,error:O(e),transportKind:n?.kind}),await T(r);continue}if("abort"===n?.kind)throw E({stage:"timeout",method:f,url:w(l),elapsedMs:Date.now()-m,timeoutMs:r}),new o(r,l);{E({stage:"request-failed",method:f,url:w(l),elapsedMs:Date.now()-m,error:O(e),transportKind:n?.kind});const t=e instanceof Error?e:new Error(String(e));throw new i(f,l,t,n)}}finally{clearTimeout(g)}}throw new Error("Unexpected request retry flow")}}},8175(t,e,r){"use strict";r.r(e),r.d(e,{CODEC:()=>T,LocalForger:()=>oe,ProtocolsHash:()=>re,Uint8ArrayConsumer:()=>z,VERSION:()=>ne,decoders:()=>Xt,encoders:()=>Jt,getCodec:()=>se,localForger:()=>ae,opMapping:()=>P,opMappingReverse:()=>R});r(3737);var n=r(2403),i=r(6571),s=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,a,c,l,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!o.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(u+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(c<0&&(c=l),c+=+d.slice(l+1),d=d.substring(0,l)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(u+"String expected: "+t);for(v(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=l=0,f=d.length;l<f;l++)if(r.indexOf(s=d.charAt(l))<0){if("."==s){if(l>c){c=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,l=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(l=0;48===d.charCodeAt(l);l++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(l,++f))if(f-=l,(c=c-l-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],l=(c+1)%h,c<0&&(l+=h),l<f){for(l&&g.c.push(+d.slice(0,l)),f-=h;l<f;)g.c.push(+d.slice(l,l+=h));l=h-(d=d.slice(l)).length}else l-=f;for(;l--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=y(t.c),c=1==n||2==n&&(o<=T||o>=P)?E(c,o):_(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=E(c,s)}else if(e-=o+(2===n&&s>o),c=_(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=b(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*h-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,u,f,p,g,m=t.c,y=d;if(m){t:{for(i=1,u=m[0];u>=10;u/=10,i++);if((s=e-i)<0)s+=h,o=e,f=m[p=0],g=c(f/y[i-o-1]%10);else if((p=a((s+1)/h))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));f=g=0,i=1,o=(s%=h)-h+1}else{for(f=u=m[p],i=1;u>=10;u/=10,i++);g=(o=(s%=h)-h+i)<0?0:c(f/y[i-o-1]%10)}if(n=n||e<0||null!=m[p+1]||(o<0?f:f%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?f/y[i-o]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(h-e%h)%h],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,u=1,p--):(m.length=p+1,u=y[h-s],m[p]=o>0?c(f/y[i-o]%y[o])*u:0),n)for(;;){if(0==p){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[p]+=u,m[p]!=l)break;m[p--]=0,u=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=y(t.c),e=r<=T||r>=P?E(e,r):_(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,g,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-g,0,e),v(r[1],0,g,e),T=r[0],P=r[1]):(v(r,-g,g,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-g,-1,e),v(r[1],1,g,e),R=r[0],x=r[1];else{if(v(r,-g,g,e),!r)throw Error(u+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(u+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,g,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-g||i>g||i!==c(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%h)<1&&(e+=h),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=l||r!==c(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return c(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,o,l=0,f=[],p=new M(A);if(null==t?t=O:v(t,0,g),s=a(t/h),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(o=131072*r[l]+(r[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[l]=n[0],r[l+1]=n[1]):(f.push(o%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);l<s;)(o=281474976710656*(31&r[l])+1099511627776*r[l+1]+4294967296*r[l+2]+16777216*r[l+3]+(r[l+4]<<16)+(r[l+5]<<8)+r[l+6])>=9e15?crypto.randomBytes(7).copy(r,l):(f.push(o%1e14),l+=7);l=s/7}if(!I)for(;l<s;)(o=e())<9e15&&(f[l++]=o%1e14);for(s=f[--l],t%=h,s&&t&&(o=d[h-t],f[l]=c(s/o)*o);0===f[l];f.pop(),l--);if(l<0)f=[i=0];else{for(i=-1;0===f[0];f.splice(0,1),i-=h);for(l=1,o=f[0];o>=10;o/=10,l++);l<h&&(i-=h-l)}return p.e=i,p.c=f,p}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),b=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(_(y(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),m=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?_(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=_(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%p)+(n=l*s+(o=t[c]/p|0)*u)%p*p+a)/r|0)+(n/p|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var u,f,d,p,g,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),x=x/h|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=c(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(u=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=c(A/T))>1)for(g>=a&&(g=a-1),b=(y=t(N,g,a)).length,_=E.length;1==e(y,E,b,_);)g--,r(y,P<b?R:N,b,a),b=y.length,u=1;else 0==g&&(u=g=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,a),_=E.length,-1==u)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===u&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==l){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*h-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,c);throw Error(u+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return b(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return v(t,0,g),null==e?e=S:v(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,o,l,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),o=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),o?t.s*(2-w(t)):+F(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||o&&p.c[1]>=24e7:p.c[0]<8e13||o&&p.c[0]<=9999975e7)))return s=p.s<0&&w(t)?-0:0,p.e>-1&&(s=1/s),new M(l?1/s:s);k&&(s=a(k/h+2))}for(o?(r=new M(.5),l&&(t.s=1),f=w(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=w(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(l&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:v(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===b(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return b(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=b(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return b(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=b(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/h,u=t.e/h,f=o.c,d=t.c;if(!c||!u){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=m(c),u=m(u),f=f.slice(),a=c-u){for((s=a<0)?(a=-a,i=f):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=l-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--u);return f[0]?K(t,f,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,f,d,g,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=m(E.e/h)+m(t.e/h),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=l,w=p,i=d;--i>=0;){for(r=0,g=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((u=g*(u=_[--o]%w)+(a=y*u+(f=_[o]/w|0)*g)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/h,o=t.e/h,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=m(s),o=m(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/l|0,a[e]=l===a[e]?0:a[e]%l;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return v(t,1,g),null==e?e=S:v(e,0,8),H(new M(s),t,e);if(!(r=s.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&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return v(t,-9007199254740991,f),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=y(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=m((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(v(t,0,g),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(v(t,0,g),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);c>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,o,a,c,l,f,p,g,m,b=this,v=b.c;if(null!=t&&(!(c=new M(t)).isInteger()&&(c.c||1!==c.s)||c.lt(A)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+F(c));if(!v)return new M(b);for(e=new M(A),f=n=new M(A),i=l=new M(A),m=y(v),o=e.e=m.length-b.e-1,e.c[0]=d[(a=o%h)<0?h+a:a],t=!t||c.comparedTo(e)>0?o>0?e:f:c,a=x,x=1/0,c=new M(m),l.c[0]=0;p=r(c,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,f=l.plus(p.times(s=f)),l=s,e=c.minus(p.times(s=e)),c=s;return s=r(t.minus(n),i,0,1),l=l.plus(s.times(f)),n=n.plus(s.times(i)),l.s=f.s=b.s,g=r(f,i,o*=2,S).minus(b).abs().comparedTo(r(l,n,o,S).minus(b).abs())<1?[f,i]:[l,n],x=a,g},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&v(t,1,g),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?E(y(r.c),s):_(y(r.c),s,"0"):(v(t,2,C.length,"Base"),e=n(_(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=1e14,h=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function m(t){var e=0|t;return t>0||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=h-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function w(t){var e=t.c.length-1;return m(t.e/h)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function _(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const A=s,O=t=>t.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),S=(t,e=8)=>t.toString(16).padStart(e,"0");var T;!function(t){t.SECRET="secret",t.RAW="raw",t.TZ1="tz1",t.BRANCH="branch",t.ZARITH="zarith",t.PUBLIC_KEY="public_key",t.PKH="pkh",t.PKH_ARR="pkhArr",t.DELEGATE="delegate",t.SCRIPT="script",t.BALLOT_STATEMENT="ballotStmt",t.PROPOSAL="proposal",t.PROPOSAL_ARR="proposalArr",t.INT32="int32",t.INT16="int16",t.PARAMETERS="parameters",t.ADDRESS="address",t.SMART_CONTRACT_ADDRESS="smart_contract_address",t.SMART_ROLLUP_ADDRESS="smart_rollup_address",t.SMART_ROLLUP_COMMITMENT_HASH="smart_rollup_commitment_hash",t.VALUE="value",t.PADDED_BYTES="padded_bytes",t.SMART_ROLLUP_MESSAGE="smart_rollup_message",t.MANAGER="manager",t.BLOCK_PAYLOAD_HASH="blockPayloadHash",t.ENTRYPOINT="entrypoint",t.OPERATION="operation",t.OP_ACTIVATE_ACCOUNT="activate_account",t.OP_DELEGATION="delegation",t.OP_TRANSACTION="transaction",t.OP_ORIGINATION="origination",t.OP_BALLOT="ballot",t.OP_FAILING_NOOP="failing_noop",t.OP_ATTESTATION="attestation",t.OP_ATTESTATION_WITH_DAL="attestation_with_dal",t.OP_SEED_NONCE_REVELATION="seed_nonce_revelation",t.OP_REVEAL="reveal",t.OP_PROPOSALS="proposals",t.OP_REGISTER_GLOBAL_CONSTANT="register_global_constant",t.OP_TRANSFER_TICKET="transfer_ticket",t.BURN_LIMIT="burn_limit",t.OP_INCREASE_PAID_STORAGE="increase_paid_storage",t.OP_UPDATE_CONSENSUS_KEY="update_consensus_key",t.OP_UPDATE_COMPANION_KEY="update_companion_key",t.SIGNATURE_PROOF="signature_proof",t.OP_DRAIN_DELEGATE="drain_delegate",t.DEPOSITS_LIMIT="deposits_limit",t.OP_SET_DEPOSITS_LIMIT="set_deposits_limit",t.OP_SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.PVM_KIND="pvm_kind",t.OP_SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.OP_DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.SLOT_HEADER="slot_header"}(T||(T={}));const P={"00":"parameter","01":"storage","02":"code","03":"False","04":"Elt","05":"Left","06":"None","07":"Pair","08":"Right","09":"Some","0a":"True","0b":"Unit","0c":"PACK","0d":"UNPACK","0e":"BLAKE2B","0f":"SHA256",10:"SHA512",11:"ABS",12:"ADD",13:"AMOUNT",14:"AND",15:"BALANCE",16:"CAR",17:"CDR",18:"CHECK_SIGNATURE",19:"COMPARE","1a":"CONCAT","1b":"CONS","1c":"CREATE_ACCOUNT","1d":"CREATE_CONTRACT","1e":"IMPLICIT_ACCOUNT","1f":"DIP",20:"DROP",21:"DUP",22:"EDIV",23:"EMPTY_MAP",24:"EMPTY_SET",25:"EQ",26:"EXEC",27:"FAILWITH",28:"GE",29:"GET","2a":"GT","2b":"HASH_KEY","2c":"IF","2d":"IF_CONS","2e":"IF_LEFT","2f":"IF_NONE",30:"INT",31:"LAMBDA",32:"LE",33:"LEFT",34:"LOOP",35:"LSL",36:"LSR",37:"LT",38:"MAP",39:"MEM","3a":"MUL","3b":"NEG","3c":"NEQ","3d":"NIL","3e":"NONE","3f":"NOT",40:"NOW",41:"OR",42:"PAIR",43:"PUSH",44:"RIGHT",45:"SIZE",46:"SOME",47:"SOURCE",48:"SENDER",49:"SELF","4a":"STEPS_TO_QUOTA","4b":"SUB","4c":"SWAP","4d":"TRANSFER_TOKENS","4e":"SET_DELEGATE","4f":"UNIT",50:"UPDATE",51:"XOR",52:"ITER",53:"LOOP_LEFT",54:"ADDRESS",55:"CONTRACT",56:"ISNAT",57:"CAST",58:"RENAME",59:"bool","5a":"contract","5b":"int","5c":"key","5d":"key_hash","5e":"lambda","5f":"list",60:"map",61:"big_map",62:"nat",63:"option",64:"or",65:"pair",66:"set",67:"signature",68:"string",69:"bytes","6a":"mutez","6b":"timestamp","6c":"unit","6d":"operation","6e":"address","6f":"SLICE",70:"DIG",71:"DUG",72:"EMPTY_BIG_MAP",73:"APPLY",74:"chain_id",75:"CHAIN_ID",76:"LEVEL",77:"SELF_ADDRESS",78:"never",79:"NEVER","7a":"UNPAIR","7b":"VOTING_POWER","7c":"TOTAL_VOTING_POWER","7d":"KECCAK","7e":"SHA3","7f":"PAIRING_CHECK",80:"bls12_381_g1",81:"bls12_381_g2",82:"bls12_381_fr",83:"sapling_state",84:"sapling_transaction_deprecated",85:"SAPLING_EMPTY_STATE",86:"SAPLING_VERIFY_UPDATE",87:"ticket",88:"TICKET_DEPRECATED",89:"READ_TICKET","8a":"SPLIT_TICKET","8b":"JOIN_TICKETS","8c":"GET_AND_UPDATE","8d":"chest","8e":"chest_key","8f":"OPEN_CHEST",90:"VIEW",91:"view",92:"constant",93:"SUB_MUTEZ",94:"tx_rollup_l2_address",95:"MIN_BLOCK_TIME",96:"sapling_transaction",97:"EMIT",98:"Lambda_rec",99:"LAMBDA_REC","9a":"TICKET","9b":"BYTES","9c":"NAT","9d":"Ticket","9e":"IS_IMPLICIT_ACCOUNT","9f":"INDEX_ADDRESS",a0:"GET_ADDRESS_INDEX"},R=(()=>{const t={};return Object.keys(P).forEach(e=>{t[P[e]]=e}),t})(),x={4:"activate_account",107:"reveal",110:"delegation",108:"transaction",109:"origination",6:"ballot",21:"attestation",23:"attestation_with_dal",1:"seed_nonce_revelation",5:"proposals",111:"register_global_constant",158:"transfer_ticket",112:"set_deposits_limit",113:"increase_paid_storage",114:"update_consensus_key",115:"update_companion_key",9:"drain_delegate",200:"smart_rollup_originate",201:"smart_rollup_add_messages",206:"smart_rollup_execute_outbox_message",230:"dal_publish_commitment",17:"failing_noop"},I=(()=>{const t={};return Object.keys(x).forEach(e=>{const r="string"==typeof e?parseInt(e,10):e;t[x[r]]=S(r,2)}),t})(),N={"00":"default","01":"root","02":"do","03":"set_delegate","04":"remove_delegate","05":"deposit","06":"stake","07":"unstake","08":"finalize_unstake","09":"set_delegate_parameters"},k=(()=>{const t={};return Object.keys(N).forEach(e=>{t[N[e]]=e}),t})();class L extends i.ParameterValidationError{constructor(t,e){super(),this.operation=t,this.errorDetail=e,this.name="InvalidOperationSchemaError",this.message="Invalid operation content recevied",e&&(this.message+=` ${e}.`)}}class C extends i.ParameterValidationError{constructor(t){super(),this.entrypoint=t,this.name="OversizedEntryPointError",this.message=`Invalid entrypoint length "${t.length}", maximum length is "31".`}}class M extends i.ParameterValidationError{constructor(t){super(),this.ballotValue=t,this.name="InvalidBallotValueError",this.message=`Invalid ballot value "${t}" expecting one of the following: "yay", "nay", "pass".`}}class B extends i.ParameterValidationError{constructor(t){super(),this.ballotValue=t,this.name="DecodeBallotValueError",this.message=`Invalid ballot value "${t}", cannot be decoded.`}}class D extends i.ParameterValidationError{constructor(t){super(),this.value=t,this.name="UnexpectedMichelsonValueError",this.message=`Invalid Michelson value "${t}", unalbe to encode.`}}class U extends i.ParameterValidationError{constructor(t){super(),this.message=t,this.name="OperationDecodingError"}}class K extends i.ParameterValidationError{constructor(t){super(),this.message=t,this.name="OperationEncodingError"}}class H extends i.ParameterValidationError{constructor(t){super(),this.op=t,this.name="UnsupportedOperationError",this.message=`Unsupported operation "${t}", can submit an issue on our github for feature request.`}}class F extends i.ParameterValidationError{constructor(t){super(),this.pvm=t,this.name="UnsupportedPvmKindError",this.message=`Invalid Pvm kind "${t}" expecting either "arith" or "wasm_2_0_0".`}}class G extends i.ParameterValidationError{constructor(t){super(),this.pvm=t,this.name="DecodePvmKindError",this.message=`Invalid Pvm kind "${t}", cannot be decoded.`}}class V extends i.ParameterValidationError{constructor(t,e){super(),this.address=t,this.errorDetail=e,this.name="InvalidSmartRollupAddress",this.message=`Invalid smart rollup address "${t}"`,e&&(this.message+=` ${e}.`)}}class j extends i.ParameterValidationError{constructor(t,e){super(),this.hash=t,this.errorDetail=e,this.name="InvalidSmartRollupCommitmentHashError",this.message=`Invalid smart rollup commitment hash "${t}"`,e&&(this.message+=` ${e}.`)}}class $ extends i.ParameterValidationError{constructor(t,e){super(),this.commitment=t,this.errorDetail=e,this.name="InvalidDalCommitmentError",this.message=`Invalid dal commitment "${t}"`,e&&(this.message+=` ${e}.`)}}class z{static fromHexString(t){const e=t.toLowerCase();if(/^(([a-f]|\d){2})*$/.test(e)){const t=new Uint8Array((e.match(/([a-z]|\d){2}/g)||[]).map(t=>parseInt(t,16)));return new z(t)}throw new i.InvalidHexStringError(e)}constructor(t,e=0){this.arr=t,this.offset=e}consume(t){const e=this.arr.subarray(this.offset,this.offset+t);return this.offset+=t,e}get(t){return this.arr[this.offset+t]}length(){return this.arr.length-this.offset}slice(t,e){return new z(this.arr.slice(t,e))}}const q=t=>{if(Array.isArray(t)){const e=t.map(t=>q(t)).join(""),r=e.length/2;return`02${S(r)}${e}`}if((t=>"prim"in t)(t))return rt(t);if((t=>"bytes"in t&&"string"==typeof t.bytes)(t))return Y(t);if((t=>"string"in t&&"string"==typeof t.string)(t))return J(t);if((t=>"int"in t&&"string"==typeof t.int)(t))return tt(t);throw new D(JSON.stringify(t))},W=t=>{const e=t.consume(1);switch(e[0]){case 10:return X(t);case 1:return Q(t);case 0:return et(t);case 2:{const e=new z(Z(t)),r=[];for(;e.length()>0;)r.push(W(e));return r}default:return nt(t,e)}},Z=(t,e=4)=>{const r=t.consume(e),n=parseInt(Buffer.from(r).toString("hex"),16);return t.consume(n)},Y=t=>{if(!/^([A-Fa-f0-9]{2})*$/.test(t.bytes))throw new i.InvalidHexStringError(t.bytes);const e=t.bytes.length/2;return`0a${S(e)}${t.bytes}`},X=t=>{const e=Z(t);return{bytes:Buffer.from(e).toString("hex")}},J=t=>{const e=Buffer.from(t.string,"utf8").toString("hex"),r=e.length/2;return`01${S(r)}${e}`},Q=t=>{const e=Z(t);return{string:Buffer.from(e).toString("utf8")}},tt=({int:t})=>{const e=new A(t,10),r="-"===e.toString(2)[0]?"1":"0",n=e.toString(2).replace(/-/g,""),i=n.length<=6?6:(n.length-6)%7?n.length+7-(n.length-6)%7:n.length,s=n.padStart(i,"0").match(/\d{6,7}/g).reverse();s[0]=r+s[0];return`00${s.map((t,e)=>parseInt((e===s.length-1?"0":"1")+t,2).toString(16).padStart(2,"0")).join("")}`},et=t=>{let e=t.consume(1)[0];const r=[];for(;128&e;)r.push(e),e=t.consume(1)[0];r.push(e);const n=!!(64&r[0]);r[0]=127&r[0];const i=r.map((t,e)=>t.toString(2).slice(0===e?-6:-7).padStart(0===e?6:7,"0")).reverse();let s=new A(i.join(""),2);return n&&(s=s.times(-1)),{int:s.toFixed()}},rt=t=>{const e=+Array.isArray(t.annots),r=Array.isArray(t.args)?t.args.length:0,n=S(Math.min(2*r+e+3,9),2),i=R[t.prim];let s=(t.args||[]).map(t=>q(t)).join("");const o=Array.isArray(t.annots)?ot(t.annots):"";return"LAMBDA"!==t.prim&&"LAMBDA_REC"!==t.prim||!r||(s=S(s.length/2)+s+S(0)),("pair"===t.prim||"Pair"===t.prim)&&r>2&&(s=""===o?S(s.length/2)+s+S(0):S(s.length/2)+s),"view"===t.prim&&t.args&&(s=S(s.length/2)+s+S(0)),`${n}${i}${s}${o}`},nt=(t,e)=>{const r=(e[0]-3)%2==1;let n=Math.floor((e[0]-3)/2);const i=t.consume(1)[0].toString(16).padStart(2,"0"),s={prim:P[i]};if("LAMBDA"!==P[i]&&"LAMBDA_REC"!==P[i]||t.consume(4),"view"===P[i])return 0!=n?it(t,s):s;let o,a;("pair"===P[i]||"Pair"===P[i])&&n>2&&(o=st(t),n=0,a=at(t));const c=new Array(n).fill(0).map(()=>W(t));return"LAMBDA"!==P[i]&&"LAMBDA_REC"!==P[i]||t.consume(4),o?s.args=o:c.length&&(s.args=c),a&&""!==a[0]?s.annots=a:r&&(s.annots=at(t)),s},it=(t,e)=>(t.consume(4),e.args=new Array(4).fill(0).map(()=>W(t)),t.consume(4),e),st=t=>{const e=new z(Z(t)),r=[];for(;e.length()>0;)r.push(W(e));return r},ot=t=>{const e=t.map(t=>Buffer.from(t,"utf8").toString("hex")).join("20"),r=e.length/2;return`${S(r)}${e}`},at=t=>{const e=t.consume(4),r=parseInt(Buffer.from(e).toString("hex"),16),n=t.consume(r);return Buffer.from(n).toString("hex").split("20").map(t=>Buffer.from(t,"hex").toString("utf8"))},ct=t=>e=>{const[r]=(0,n.b58DecodeAndCheckPrefix)(e,[t]);return(0,n.buf2hex)(r)},ut=t=>e=>{const r=e.consume(n.payloadLength[t]);return(0,n.b58Encode)(r,t)},lt=ut(n.PrefixV2.Ed25519PublicKeyHash),ht=ut(n.PrefixV2.BlockHash),ft=t=>{const e=t.consume(1);return 0===e[0]?ut(n.PrefixV2.Ed25519PublicKeyHash)(t):1===e[0]?ut(n.PrefixV2.Secp256k1PublicKeyHash)(t):2===e[0]?ut(n.PrefixV2.P256PublicKeyHash)(t):3===e[0]?ut(n.PrefixV2.BLS12_381PublicKeyHash)(t):void 0},dt=ct(n.PrefixV2.BlockHash),pt=ct(n.PrefixV2.Ed25519PublicKeyHash),gt=t=>t?"ff":"00",mt=t=>ct(n.PrefixV2.ProtocolHash)(t),yt=t=>ut(n.PrefixV2.ProtocolHash)(t),bt=t=>255===t.consume(1)[0],vt=t=>{try{return(0,n.b58DecodePublicKeyHash)(t)}catch(e){throw new i.InvalidKeyHashError(t,e instanceof i.ParameterValidationError?e.result:void 0)}},wt=t=>{const e=[];let r=new A(t,10);if(r.isNaN())throw new TypeError(`Invalid zarith number ${t}`);for(;;){if(r.lt(128)){r.lt(16)&&e.push("0"),e.push(r.toString(16));break}{let t=r.mod(128);r=r.minus(t),r=r.dividedBy(128),t=t.plus(128),e.push(t.toString(16))}}return e.join("")},Et=t=>{let e=0;for(;e<t.length()&&128&t.get(e);)e+=1;let r=new A(0);for(let n=e;n>=0;n-=1){const e=127&t.get(n);r=r.multipliedBy(128),r=r.plus(e)}return t.consume(e+1),new A(r).toString()},_t=ct(n.PrefixV2.ValueHash),At=ut(n.PrefixV2.ValueHash),Ot=(t,e=8)=>`${S(t.length/2,e)}${t}`,St=t=>ut(n.PrefixV2.SlotHeader)(t),Tt={branch:T.BRANCH,contents:[T.OPERATION]},Pt={pkh:T.TZ1,secret:T.SECRET},Rt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,public_key:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},xt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,delegate:T.DELEGATE},It={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,amount:T.ZARITH,destination:T.ADDRESS,parameters:T.PARAMETERS},Nt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,balance:T.ZARITH,delegate:T.DELEGATE,script:T.SCRIPT},kt={source:T.PKH,period:T.INT32,proposal:T.PROPOSAL,ballot:T.BALLOT_STATEMENT},Lt={slot:T.INT16,level:T.INT32,round:T.INT32,block_payload_hash:T.BLOCK_PAYLOAD_HASH},Ct={slot:T.INT16,level:T.INT32,round:T.INT32,block_payload_hash:T.BLOCK_PAYLOAD_HASH,dal_attestation:T.ZARITH},Mt={level:T.INT32,nonce:T.RAW},Bt={source:T.PKH,period:T.INT32,proposals:T.PROPOSAL_ARR},Dt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,value:T.VALUE},Ut={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,ticket_contents:T.VALUE,ticket_ty:T.VALUE,ticket_ticketer:T.ADDRESS,ticket_amount:T.ZARITH,destination:T.ADDRESS,entrypoint:T.ENTRYPOINT},Kt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,amount:T.ZARITH,destination:T.SMART_CONTRACT_ADDRESS},Ht={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pk:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},Ft={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pk:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},Gt={consensus_key:T.PKH,delegate:T.PKH,destination:T.PKH},Vt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,limit:T.DEPOSITS_LIMIT},jt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pvm_kind:T.PVM_KIND,kernel:T.PADDED_BYTES,parameters_ty:T.VALUE,whitelist:T.PKH_ARR},$t={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,message:T.SMART_ROLLUP_MESSAGE},zt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,rollup:T.SMART_ROLLUP_ADDRESS,cemented_commitment:T.SMART_ROLLUP_COMMITMENT_HASH,output_proof:T.PADDED_BYTES},qt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,slot_header:T.SLOT_HEADER},Wt={arbitrary:T.PADDED_BYTES},Zt=t=>e=>r=>Object.keys(e).reduce((n,i)=>{const s=e[i];if(r&&Array.isArray(s)){const e=t[s[0]],o=r[i];if(!Array.isArray(o))throw new K(`Invalid operation value "${JSON.stringify(o)}" of key "${i}, expected value to be Array.`);return n+o.reduce((t,r)=>t+e(r),"")}return n+(0,t[s])(r[i])},""),Yt=t=>e=>r=>Object.keys(e).reduce((n,i)=>{const s=e[i];if(Array.isArray(s)){const e=t[s[0]],o=[],a=r.length();for(;r.length()>0;)if(o.push(e(r)),a===r.length())throw new U("Unable to decode value");return{...n,[i]:o}}{const e=(0,t[s])(r);return void 0!==e?{...n,[i]:e}:{...n}}},{}),Xt={[T.SECRET]:t=>O(t.consume(20)),[T.RAW]:t=>O(t.consume(32)),[T.TZ1]:lt,[T.BRANCH]:ht,[T.ZARITH]:Et,[T.PUBLIC_KEY]:t=>{switch(t.consume(1)[0]){case 0:return ut(n.PrefixV2.Ed25519PublicKey)(t);case 1:return ut(n.PrefixV2.Secp256k1PublicKey)(t);case 2:return ut(n.PrefixV2.P256PublicKey)(t);case 3:return ut(n.PrefixV2.BLS12_381PublicKey)(t);default:throw new n.InvalidPublicKeyError(void 0,n.ValidationResult.NO_PREFIX_MATCHED)}},[T.PKH]:ft,[T.PKH_ARR]:t=>{if(!bt(t))return;const e=[];for(t.consume(4);t.length()>0;)e.push(ft(t));return e},[T.DELEGATE]:t=>{if(bt(t))return ft(t)},[T.INT32]:t=>{const e=t.consume(4);let r=0;for(let t=0;t<e.length;t++)r|=e[t]<<8*(e.length-(t+1));return r},[T.SCRIPT]:t=>{const e=Z(t),r=Z(t);return{code:W(new z(e)),storage:W(new z(r))}},[T.BALLOT_STATEMENT]:t=>{const e=t.consume(1);switch(e[0]){case 0:return"yay";case 1:return"nay";case 2:return"pass";default:throw new B(e[0].toString())}},[T.PROPOSAL]:yt,[T.PROPOSAL_ARR]:t=>{const e=[];for(t.consume(4);t.length()>0;)e.push(yt(t));return e},[T.PARAMETERS]:t=>{if(0!==t.consume(1)[0]){const e=(t=>{const e=S(t.consume(1)[0],2);if(e in N)return N[e];{const e=Z(t,1),r=Buffer.from(e).toString("utf8");if(r.length>31)throw new C(r);return r}})(t),r=Z(t);return{entrypoint:e,value:W(new z(r))}}},[T.ADDRESS]:t=>{switch(t.consume(1)[0]){case 0:return ft(t);case 1:{const e=ut(n.PrefixV2.ContractHash)(t);return t.consume(1),e}default:throw new i.InvalidAddressError(t.toString(),": Unable to decode.")}},[T.SMART_ROLLUP_ADDRESS]:t=>ut(n.PrefixV2.SmartRollupHash)(t),[T.SMART_CONTRACT_ADDRESS]:t=>{if(1===t.consume(1)[0]){const e=ut(n.PrefixV2.ContractHash)(t);return t.consume(1),e}throw new i.InvalidContractAddressError(t.toString(),n.ValidationResult.NO_PREFIX_MATCHED)},[T.SMART_ROLLUP_COMMITMENT_HASH]:t=>ut(n.PrefixV2.SmartRollupCommitmentHash)(t),[T.VALUE]:t=>{const e=Z(t);return W(new z(e))},[T.INT16]:t=>{const e=t.consume(2);let r=0;for(let t=0;t<e.length;t++)r|=e[t]<<8*(e.length-(t+1));return r},[T.BLOCK_PAYLOAD_HASH]:At,[T.ENTRYPOINT]:t=>{const e=Z(t);return Buffer.from(e).toString("utf8")},[T.BURN_LIMIT]:t=>{const e=t.consume(1);if("00"!==Buffer.from(e).toString("hex"))return Et(t)},[T.DEPOSITS_LIMIT]:t=>{const e=t.consume(1);if("00"!==Buffer.from(e).toString("hex"))return Et(t)},[T.SIGNATURE_PROOF]:t=>{if(bt(t))return(t=>{if(t.consume(4),"96"===t.length().toString())return ut(n.PrefixV2.BLS12_381Signature)(t);throw new i.ProhibitedActionError("we only support decoding of BLSIG signatures")})(t)},[T.PVM_KIND]:t=>{const e=t.consume(1);switch(e[0]){case 0:return"arith";case 1:return"wasm_2_0_0";case 2:return"riscv";default:throw new G(e[0].toString())}},[T.PADDED_BYTES]:t=>{const e=Z(t);return Buffer.from(e).toString("hex")},[T.SMART_ROLLUP_MESSAGE]:t=>{const e=Z(t);return((t,e=4)=>{const r=[];let n=t;for(;n.length();){const t=n.consume(e),i=parseInt(Buffer.from(t).toString("hex"),16);r.push(n.consume(i)),n=n.slice(i+e)}return r})(new z(e)).map(t=>Buffer.from(t).toString("hex"))},[T.SLOT_HEADER]:t=>{const e=t.consume(1);return{slot_index:Number(e[0].toString(10)),commitment:St(t),commitment_proof:O(t.consume(96))}}};Xt[T.OPERATION]=(t=>e=>{const r=e.consume(1),n=x[r[0]];if(void 0===n)throw new H(r[0].toString());const i=t[n](e);if("object"!=typeof i)throw new U("Invalid operation, cannot be decoded.");return{kind:n,...i}})(Xt),Xt[T.OP_ACTIVATE_ACCOUNT]=t=>Yt(Xt)(Pt)(t),Xt[T.OP_FAILING_NOOP]=t=>Yt(Xt)(Wt)(t),Xt[T.OP_DELEGATION]=t=>Yt(Xt)(xt)(t),Xt[T.OP_TRANSACTION]=t=>Yt(Xt)(It)(t),Xt[T.OP_ORIGINATION]=t=>Yt(Xt)(Nt)(t),Xt[T.OP_BALLOT]=t=>Yt(Xt)(kt)(t),Xt[T.OP_ATTESTATION]=t=>Yt(Xt)(Lt)(t),Xt[T.OP_ATTESTATION_WITH_DAL]=t=>Yt(Xt)(Ct)(t),Xt[T.OP_SEED_NONCE_REVELATION]=t=>Yt(Xt)(Mt)(t),Xt[T.OP_PROPOSALS]=t=>Yt(Xt)(Bt)(t),Xt[T.OP_REVEAL]=t=>Yt(Xt)(Rt)(t),Xt[T.OP_REGISTER_GLOBAL_CONSTANT]=t=>Yt(Xt)(Dt)(t),Xt[T.OP_TRANSFER_TICKET]=t=>Yt(Xt)(Ut)(t),Xt[T.OP_INCREASE_PAID_STORAGE]=t=>Yt(Xt)(Kt)(t),Xt[T.OP_UPDATE_CONSENSUS_KEY]=t=>Yt(Xt)(Ht)(t),Xt[T.OP_UPDATE_COMPANION_KEY]=t=>Yt(Xt)(Ft)(t),Xt[T.OP_DRAIN_DELEGATE]=t=>Yt(Xt)(Gt)(t),Xt[T.OP_SMART_ROLLUP_ORIGINATE]=t=>Yt(Xt)(jt)(t),Xt[T.OP_SMART_ROLLUP_ADD_MESSAGES]=t=>Yt(Xt)($t)(t),Xt[T.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]=t=>Yt(Xt)(zt)(t),Xt[T.OP_DAL_PUBLISH_COMMITMENT]=t=>Yt(Xt)(qt)(t),Xt[T.MANAGER]=Yt(Xt)(Tt),Xt[T.OP_SET_DEPOSITS_LIMIT]=t=>Yt(Xt)(Vt)(t);const Jt={[T.SECRET]:t=>t,[T.RAW]:t=>t,[T.TZ1]:pt,[T.BRANCH]:dt,[T.ZARITH]:wt,[T.PUBLIC_KEY]:t=>{try{return(0,n.b58DecodePublicKey)(t)}catch(e){throw new n.InvalidPublicKeyError(t,e instanceof i.ParameterValidationError?e.result:void 0)}},[T.PKH]:vt,[T.PKH_ARR]:t=>{if(!t)return gt(!1);if(0===t.length)return gt(!0)+S(0);const e=t.reduce((t,e)=>t+vt(e),"");return gt(!0)+S(e.length/2)+e},[T.DELEGATE]:t=>t?gt(!0)+vt(t):gt(!1),[T.SCRIPT]:t=>{const e=q(t.code),r=q(t.storage);return`${S(e.length/2,8)}${e}${S(r.length/2,8)}${r}`},[T.BALLOT_STATEMENT]:t=>{switch(t){case"yay":return"00";case"nay":return"01";case"pass":return"02";default:throw new M(t)}},[T.PROPOSAL]:mt,[T.PROPOSAL_ARR]:t=>S(32*t.length)+t.map(t=>mt(t)).join(""),[T.INT32]:t=>{const e=parseInt(String(t),10),r=[];for(let t=0;t<4;t++){const n=8*(4-(t+1));r.push((e&255<<n)>>n)}return Buffer.from(r).toString("hex")},[T.PARAMETERS]:t=>{if(!t||"default"===t.entrypoint&&"prim"in t.value&&"Unit"===t.value.prim)return"00";const e=(t=>{if(t in k)return`${k[t]}`;if(t.length>31)throw new C(t);return`ff${q({string:t}).slice(8)}`})(t.entrypoint),r=q(t.value);return`ff${e}${S(r.length/2)}${r}`},[T.ADDRESS]:t=>(0,n.b58DecodeAddress)(t),[T.SMART_ROLLUP_ADDRESS]:t=>{try{return ct(n.PrefixV2.SmartRollupHash)(t)}catch(e){throw e instanceof i.ParameterValidationError?new V(t):e}},[T.SMART_CONTRACT_ADDRESS]:t=>(0,n.b58DecodeAddress)(t),[T.SMART_ROLLUP_COMMITMENT_HASH]:t=>{try{return ct(n.PrefixV2.SmartRollupCommitmentHash)(t)}catch(e){throw e instanceof i.ParameterValidationError?new j(t):e}},[T.VALUE]:t=>{const e=q(t);return`${S(e.length/2)}${e}`},[T.INT16]:t=>{const e=parseInt(String(t),10),r=[];for(let t=0;t<2;t++){const n=8*(2-(t+1));r.push((e&255<<n)>>n)}return Buffer.from(r).toString("hex")},[T.BLOCK_PAYLOAD_HASH]:_t,[T.ENTRYPOINT]:t=>`${q({string:t}).slice(2)}`,[T.BURN_LIMIT]:t=>t?`ff${wt(t)}`:"00",[T.DEPOSITS_LIMIT]:t=>t?`ff${wt(t)}`:"00",[T.SIGNATURE_PROOF]:t=>t?gt(!0)+(t=>{try{const[e,r]=(0,n.b58DecodeAndCheckPrefix)(t,n.signaturePrefixes);if(r===n.PrefixV2.BLS12_381Signature)return Ot((0,n.buf2hex)(e));throw new i.ProhibitedActionError("we only support encoding of BLSIG signatures from protocol Seoul")}catch(e){throw e instanceof i.ParameterValidationError?new i.InvalidSignatureError(t,e.result):e}})(t):gt(!1),[T.PVM_KIND]:t=>{switch(t){case"arith":return"00";case"wasm_2_0_0":return"01";case"riscv":return"02";default:throw new F(t)}},[T.PADDED_BYTES]:Ot,[T.SMART_ROLLUP_MESSAGE]:t=>{const e=t.reduce((t,e)=>t+`${S(e.length/2)}${e}`,"");return`${S(e.length/2)}${e}`},[T.SLOT_HEADER]:t=>S(t.slot_index,2)+(t=>{try{return ct(n.PrefixV2.SlotHeader)(t)}catch(e){throw e instanceof i.ParameterValidationError?new $(t):e}})(t.commitment)+t.commitment_proof};Jt[T.OPERATION]=(t=>e=>{if(!(e.kind in t)||!(e.kind in I))throw new i.InvalidOperationKindError(e.kind);return I[e.kind]+t[e.kind](e)})(Jt),Jt[T.OP_ACTIVATE_ACCOUNT]=t=>Zt(Jt)(Pt)(t),Jt[T.OP_DELEGATION]=t=>Zt(Jt)(xt)(t),Jt[T.OP_TRANSACTION]=t=>Zt(Jt)(It)(t),Jt[T.OP_ORIGINATION]=t=>Zt(Jt)(Nt)(t),Jt[T.OP_BALLOT]=t=>Zt(Jt)(kt)(t),Jt[T.OP_ATTESTATION]=t=>Zt(Jt)(Lt)(t),Jt[T.OP_ATTESTATION_WITH_DAL]=t=>Zt(Jt)(Ct)(t),Jt[T.OP_SEED_NONCE_REVELATION]=t=>Zt(Jt)(Mt)(t),Jt[T.OP_PROPOSALS]=t=>Zt(Jt)(Bt)(t),Jt[T.OP_REVEAL]=t=>Zt(Jt)(Rt)(t),Jt[T.OP_REGISTER_GLOBAL_CONSTANT]=t=>Zt(Jt)(Dt)(t),Jt[T.OP_TRANSFER_TICKET]=t=>Zt(Jt)(Ut)(t),Jt[T.OP_INCREASE_PAID_STORAGE]=t=>Zt(Jt)(Kt)(t),Jt[T.OP_UPDATE_CONSENSUS_KEY]=t=>Zt(Jt)(Ht)(t),Jt[T.OP_UPDATE_COMPANION_KEY]=t=>Zt(Jt)(Ft)(t),Jt[T.OP_DRAIN_DELEGATE]=t=>Zt(Jt)(Gt)(t),Jt[T.OP_SMART_ROLLUP_ORIGINATE]=t=>Zt(Jt)(jt)(t),Jt[T.OP_SMART_ROLLUP_ADD_MESSAGES]=t=>Zt(Jt)($t)(t),Jt[T.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]=t=>Zt(Jt)(zt)(t),Jt[T.OP_DAL_PUBLISH_COMMITMENT]=t=>Zt(Jt)(qt)(t),Jt[T.MANAGER]=Zt(Jt)(Tt),Jt[T.OP_SET_DEPOSITS_LIMIT]=t=>Zt(Jt)(Vt)(t),Jt[T.OP_FAILING_NOOP]=t=>Zt(Jt)(Wt)(t);const Qt={activate_account:Pt,reveal:Rt,delegation:xt,transaction:It,origination:Nt,ballot:kt,attestation:Lt,attestation_with_dal:Ct,seed_nonce_revelation:Mt,proposals:Bt,register_global_constant:Dt,transfer_ticket:Ut,increase_paid_storage:Kt,update_consensus_key:Ht,update_companion_key:Ft,drain_delegate:Gt,set_deposits_limit:Vt,smart_rollup_originate:jt,smart_rollup_add_messages:$t,smart_rollup_execute_outbox_message:zt,dal_publish_commitment:qt,failing_noop:Wt},te=t=>Object.keys(Qt).includes(t),ee=t=>{const e=t.kind,r=Object.keys(t),n=(i="kind",r.filter(t=>t!==i));var i;const s=Object.keys(Qt[e]);return o=n,s.filter(t=>!o.includes(t));var o};var re;!function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(re||(re={}));const ne={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"};void 0===globalThis.TextEncoder&&(globalThis.TextEncoder=TextEncoder),void 0===globalThis.TextDecoder&&(globalThis.TextDecoder=TextDecoder);const ie=re.PsUshuai9;function se(t,e){return{encoder:Jt[t],decoder:e=>{const r=z.fromHexString(e);return Xt[t](r)}}}class oe{constructor(t=ie){this.protocolHash=t,this.codec=se(T.MANAGER,this.protocolHash)}forge(t){const e=(0,n.validateBlock)(t.branch);if(e!==n.ValidationResult.VALID)throw new i.InvalidBlockHashError(t.branch,e);for(const e of t.contents){if(!te(e.kind))throw new i.InvalidOperationKindError(e.kind);const t=ee(e);if(1===t.length){if("delegation"===e.kind&&"delegate"===t[0])continue;if("origination"===e.kind&&"delegate"===t[0])continue;if("transaction"===e.kind&&"parameters"===t[0])continue;if("set_deposits_limit"===e.kind&&"limit"===t[0])continue;if("smart_rollup_originate"===e.kind&&"whitelist"===t[0])continue;if("update_consensus_key"===e.kind&&"proof"===t[0])continue;if("update_companion_key"===e.kind&&"proof"===t[0])continue;if("reveal"===e.kind&&"proof"===t[0])continue;throw new L(e,`missing properties "${t.join(", ")}"`)}if(t.length>1)throw new L(e,`missing properties "${t.join(", ")}"`)}const r=this.codec.encoder(t).toLowerCase();return Promise.resolve(r)}parse(t){return Promise.resolve(this.codec.decoder(t))}}const ae=new oe},5899(t,e,r){"use strict";r.r(e),r.d(e,{Contract:()=>rr,DefaultProtocol:()=>g,JSONParseError:()=>B,MacroError:()=>v,MichelineParseError:()=>M,MichelsonError:()=>ut,MichelsonInstructionError:()=>Ce,MichelsonTypeError:()=>ht,MichelsonValidationError:()=>Nt,Parser:()=>F,ProtoGreaterOrEqual:()=>y,ProtoInferiorTo:()=>b,Protocol:()=>p,VERSION:()=>ar,assertContractValid:()=>We,assertDataListIfAny:()=>ie,assertDataValid:()=>Ze,assertMichelsonBigMapStorableType:()=>zt,assertMichelsonComparableType:()=>Ft,assertMichelsonContract:()=>Jt,assertMichelsonData:()=>Xt,assertMichelsonInstruction:()=>Ht,assertMichelsonPackableType:()=>Gt,assertMichelsonPassableType:()=>$t,assertMichelsonPushableType:()=>Vt,assertMichelsonStorableType:()=>jt,assertMichelsonType:()=>Zt,assertTypeAnnotationsValid:()=>Ke,assertTypesEqual:()=>Xe,assertViewNameValid:()=>Wt,contractEntryPoint:()=>ze,contractEntryPoints:()=>qe,contractSection:()=>Ve,contractViews:()=>je,decodeAddressBytes:()=>Ne,decodePublicKeyBytes:()=>Le,decodePublicKeyHashBytes:()=>ke,dummyContract:()=>nr,emitMicheline:()=>z,formatError:()=>or,formatStack:()=>ir,functionType:()=>Ye,instructionIDs:()=>Rt,isContractValid:()=>Qe,isDataValid:()=>tr,isInstruction:()=>ne,isMichelsonCode:()=>ee,isMichelsonData:()=>te,isMichelsonError:()=>lt,isMichelsonScript:()=>Qt,isMichelsonType:()=>re,isTypeAnnotationsValid:()=>Je,isTypeEqual:()=>er,packData:()=>Se,packDataBytes:()=>Te,refContract:()=>d,sourceReference:()=>i,traceDumpFunc:()=>sr,unpackData:()=>xe,unpackDataBytes:()=>Ie});var n=r(6571);const i=Symbol("source_reference");class s extends n.TaquitoError{constructor(t,e,r){super(),this.src=t,this.idx=e,this.message=r,this.name="ScanError"}}var o;!function(t){t[t.Comment=0]="Comment",t[t.Number=1]="Number",t[t.String=2]="String",t[t.Bytes=3]="Bytes",t[t.Ident=4]="Ident"}(o||(o={}));const a=new RegExp("\\s"),c=new RegExp("[:@%_A-Za-z]"),u=new RegExp("[@%_\\.A-Za-z0-9]"),l=new RegExp("[0-9]"),h=new RegExp("[0-9a-fA-F]");function*f(t,e=!1){let r=0;for(;r<t.length;){for(;r<t.length&&a.test(t[r]);)r++;if(r===t.length)return;const n=t[r],i=r;if(c.test(n)){for(r++;r<t.length&&u.test(t[r]);)r++;yield{t:o.Ident,v:t.slice(i,r),first:i,last:r}}else if(t.length-r>1&&"0x"===t.substring(r,r+2)){for(r+=2;r<t.length&&h.test(t[r]);)r++;if(r-i&1)throw new s(t,r,"Bytes literal length is expected to be power of two");yield{t:o.Bytes,v:t.slice(i,r),first:i,last:r}}else if(l.test(n)||"-"===n){"-"===n&&r++;const e=r;for(;r<t.length&&l.test(t[r]);)r++;if(e===r)throw new s(t,r,"Number literal is too short");yield{t:o.Number,v:t.slice(i,r),first:i,last:r}}else if('"'===n){r++;let e=!1;for(;r<t.length&&(e||'"'!==t[r]);r++)e=!e&&"\\"===t[r];if(r===t.length)throw new s(t,r,"Unterminated string literal");r++,yield{t:o.String,v:t.slice(i,r),first:i,last:r}}else if("#"===n){for(r++;r<t.length&&"\n"!==t[r];)r++;e&&(yield{t:o.Comment,v:t.slice(i,r),first:i,last:r})}else if(t.length-r>1&&"/*"===t.substring(r,r+2)){for(r+=2;r<t.length&&!(t.length-r>1&&"*/"===t.substring(r,r+2));)r++;if(r===t.length)throw new s(t,r,"Unterminated C style comment");r+=2,e&&(yield{t:o.Comment,v:t.slice(i,r),first:i,last:r})}else{if("("!==n&&")"!==n&&"{"!==n&&"}"!==n&&";"!==n)throw new s(t,r,`Invalid character at offset ${r}: \`${n}'`);r++,yield{t:n,v:n,first:i,last:r}}}}const d=Symbol("ref_contract");var p;!function(t){t.Ps9mPmXa="Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P",t.PtCJ7pwo="PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY",t.PsYLVpVv="PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt",t.PsddFKi3="PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP",t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdoTez="PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangzH="PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.PsiThaCa="PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakarta="PtJakartaiDz69SfDDLXJSiuZqTSeSKRDbKVZC8MNzJnvRjvnGw",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(p||(p={}));const g=p.PsUshuai9,m={Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P:0,PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY:1,PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt:2,PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP:3,Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd:4,PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU:5,PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS:5,PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb:6,PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo:7,PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq:8,PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA:8,PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i:9,PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV:10,PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r:11,PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx:11,PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP:12,Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A:12,PtJakartaiDz69SfDDLXJSiuZqTSeSKRDbKVZC8MNzJnvRjvnGw:13,PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY:13,PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg:14,PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW:15,PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc:16,PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1:16,PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf:17,ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH:19,PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ:20,PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi:20,PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg:21,PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7:22,PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh:23,PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu:24,PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY:25,ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK:26};function y(t,e){return m[t]>=m[e]}function b(t,e){return m[t]<m[e]}class v extends n.TaquitoError{constructor(t,e){super(),this.prim=t,this.message=e,this.name="MacroError"}}function w(t,e){if(0===e&&void 0===t.args||t.args?.length===e)return!0;throw new v(t,`macro ${t.prim} expects ${e} arguments, was given ${t.args?.length}`)}function E(t){if(void 0===t.annots)return!0;throw new v(t,`unexpected annotation on macro ${t.prim}: ${t.annots}`)}function _(t,e){if("int"in e)return!0;throw new v(t,`macro ${t.prim} expects int argument`)}function A(t,e,r,n){let i=0,s=0;const o=[null,null];let a;if(i===e.length)throw new v(t,`unexpected end: ${t.prim}`);let c,u=e[i++];switch(u){case"P":{const{r:o,n:c,an:u}=A(t,e.slice(i),r.slice(s),n);a=o,i+=c,s+=u;break}case"A":s!==r.length&&(o[0]=r[s++]);break;default:throw new v(t,`${t.prim}: unexpected character: ${u}`)}if(i===e.length)throw new v(t,`unexpected end: ${t.prim}`);switch(u=e[i++],u){case"P":{const{r:o,n:a,an:u}=A(t,e.slice(i),r.slice(s),n);c=o.map(([t,e])=>[t+1,e]),i+=a,s+=u;break}case"I":s!==r.length&&(o[1]=r[s++]);break;default:throw new v(t,`${t.prim}: unexpected character: ${u}`)}return{r:n(a,c,[0,o]),n:i,an:s}}function O(t,e,r,n){const i=e[0];switch(i){case"A":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CAR",annots:["@%%"]},O(t,e.slice(1),[],n)]]},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:["%@","%@",...r]}]:n.a;case"D":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CDR",annots:["@%%"]},O(t,e.slice(1),[],n)]]},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@","%@",...r]}]:n.d;default:throw new v(t,`${t.prim}: unexpected character: ${i}`)}}function S(t,e){let r=t.length;for(;r>0&&t[r-1]===e;)r--;return t.slice(0,r)}function T(t){const e=[],r=[];if(void 0!==t)for(const n of t)(0!==n.length&&"%"===n[0]?e:r).push(n);return{fields:e,rest:r}}function P({prim:t,annots:e,args:r}){return{prim:t,...e&&{annots:e},...r&&{args:r}}}const R=/^P[PAI]{3,}R$/,x=/^UNP[PAI]{2,}R$/,I=/^C[AD]{2,}R$/,N=/^SET_C[AD]+R$/,k=/^MAP_C[AD]+R$/,L=/^DI{2,}P$/,C=/^DU+P$/;class M extends n.TaquitoError{constructor(t,e){super(),this.token=t,this.message=e,this.name="MichelineParseError"}}class B extends n.TaquitoError{constructor(t,e){super(),this.node=t,this.message=e,this.name="JSONParseError"}}const D=new M(null,"Unexpected EOF");function U(t){return t.t===o.Ident&&("@"===t.v[0]||"%"===t.v[0]||":"===t.v[0])}const K=new RegExp("^-?[0-9]+$"),H=new RegExp("^([0-9a-fA-F]{2})*$");class F{constructor(t){this.opt=t}expand(t){if(void 0!==this.opt?.expandGlobalConstant&&"constant"===t.prim){const e=function(t,e){return void 0!==t.args&&1===t.args.length&&"string"in t.args[0]&&t.args[0].string in e?e[t.args[0].string]:t}(t,this.opt.expandGlobalConstant);return e!==t&&(e[i]={...t[i]||{first:0,last:0},globalConstant:t}),e}if(void 0===this.opt?.expandMacros||this.opt?.expandMacros){const e=function(t,e){const r=e?.protocol||g;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(w(t,0))return[{prim:"COMPARE"},P({prim:t.prim.slice(3),annots:t.annots})];break;case"IFEQ":case"IFNEQ":case"IFLT":case"IFGT":case"IFLE":case"IFGE":if(w(t,2))return[{prim:t.prim.slice(2)},P({prim:"IF",annots:t.annots,args:t.args})];break;case"IFCMPEQ":case"IFCMPNEQ":case"IFCMPLT":case"IFCMPGT":case"IFCMPLE":case"IFCMPGE":if(w(t,2))return[{prim:"COMPARE"},{prim:t.prim.slice(5)},P({prim:"IF",annots:t.annots,args:t.args})];break;case"FAIL":if(w(t,0)&&E(t))return[{prim:"UNIT"},{prim:"FAILWITH"}];break;case"ASSERT":if(w(t,0)&&E(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(w(t,0)&&E(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(w(t,0)&&E(t))return[[{prim:"COMPARE"},{prim:t.prim.slice(10)}],{prim:"IF",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_NONE":if(w(t,0)&&E(t))return[{prim:"IF_NONE",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_SOME":if(w(t,0))return[{prim:"IF_NONE",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"ASSERT_LEFT":if(w(t,0))return[{prim:"IF_LEFT",args:[n(t.annots),[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_RIGHT":if(w(t,0))return[{prim:"IF_LEFT",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"IF_SOME":if(w(t,2))return[P({prim:"IF_NONE",annots:t.annots,args:[t.args[1],t.args[0]]})];break;case"IF_RIGHT":if(w(t,2))return[P({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(w(t,1)&&_(t,t.args[0])){const e=parseInt(t.args[0].int,10);return P({prim:"GET",args:[{int:"CAR"===t.prim?String(2*e+1):String(2*e)}],annots:t.annots})}}if(R.test(t.prim)&&w(t,0)){const{fields:e,rest:r}=T(t.annots),{r:n}=A(t,t.prim.slice(1),e,(t,e,r)=>[...t||[],...e||[],r]);return n.map(([t,e],i)=>{const s=[...S(e,null).map(t=>null===t?"%":t),...0===t&&i===n.length-1?r:[]],o=P({prim:"PAIR",annots:0!==s.length?s:void 0});return 0===t?o:{prim:"DIP",args:1===t?[[o]]:[{int:String(t)},[o]]}})}if(x.test(t.prim)){if(b(r,p.PtEdo2Zk)&&w(t,0)){const{r:e}=A(t,t.prim.slice(3),t.annots||[],(t,e,r)=>[r,...e||[],...t||[]]);return e.map(([t,e])=>{const r=[{prim:"DUP"},P({prim:"CAR",annots:null!==e[0]?[e[0]]:void 0}),{prim:"DIP",args:[[P({prim:"CDR",annots:null!==e[1]?[e[1]]:void 0})]]}];return 0===t?r:{prim:"DIP",args:1===t?[[r]]:[{int:String(t)},[r]]}})}if("UNPAIR"===t.prim)return t;if(w(t,0)){const{r:e}=A(t,t.prim.slice(3),[],(t,e,r)=>[r,...e||[],...t||[]]);return e.map(([t])=>{const e=P({prim:"UNPAIR"});return 0===t?e:{prim:"DIP",args:1===t?[[e]]:[{int:String(t)},[e]]}})}}if(I.test(t.prim)&&w(t,0)){const e=[...t.prim.slice(1,t.prim.length-1)];return e.map((r,n)=>{const i=n===e.length-1?t.annots:void 0;switch(r){case"A":return P({prim:"CAR",annots:i});case"D":return P({prim:"CDR",annots:i});default:throw new v(t,`unexpected character: ${r}`)}})}if(N.test(t.prim)&&w(t,0)){const{fields:e,rest:r}=T(t.annots);if(e.length>1)throw new v(t,`unexpected annotation on macro ${t.prim}: ${e}`);const n=0!==e.length?{a:[{prim:"DUP"},{prim:"CAR",annots:e},{prim:"DROP"},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:[e[0],"%@"]}],d:[{prim:"DUP"},{prim:"CDR",annots:e},{prim:"DROP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",e[0]]}]}:{a:[{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:["%","%@"]}],d:[{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@","%"]}]};return O(t,t.prim.slice(5,t.prim.length-1),r,n)}if(k.test(t.prim)&&w(t,1)){const{fields:e}=T(t.annots);if(e.length>1)throw new v(t,`unexpected annotation on macro ${t.prim}: ${e}`);const r={a:[{prim:"DUP"},{prim:"CDR",annots:["@%%"]},{prim:"DIP",args:[[P({prim:"CAR",annots:0!==e.length?["@"+e[0].slice(1)]:void 0}),t.args[0]]]},{prim:"SWAP"},{prim:"PAIR",annots:[0!==e.length?e[0]:"%","%@"]}],d:[{prim:"DUP"},P({prim:"CDR",annots:0!==e.length?["@"+e[0].slice(1)]:void 0}),t.args[0],{prim:"SWAP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",0!==e.length?e[0]:"%"]}]};return O(t,t.prim.slice(5,t.prim.length-1),[],r)}if(L.test(t.prim)&&w(t,1)){let e=0;for(;"I"===t.prim[1+e];)e++;return P({prim:"DIP",args:[{int:String(e)},t.args[0]]})}if(C.test(t.prim)){let e=0;for(;"U"===t.prim[1+e];)e++;if(b(r,p.PtEdo2Zk)){if(1===e){if(void 0===t.args)return t;w(t,1)&&_(t,t.args[0])&&(e=parseInt(t.args[0].int,10))}else w(t,0);return 1===e?[P({prim:"DUP",annots:t.annots})]:2===e?[{prim:"DIP",args:[[P({prim:"DUP",annots:t.annots})]]},{prim:"SWAP"}]:[{prim:"DIP",args:[{int:String(e-1)},[P({prim:"DUP",annots:t.annots})]]},{prim:"DIG",args:[{int:String(e)}]}]}if(1===e)return t;if(w(t,0))return P({prim:"DUP",args:[{int:String(e)}],annots:t.annots})}return t}(t,this.opt);return e!==t&&(e[i]={...t[i]||{first:0,last:0},macro:t}),e}return t}parseListExpr(t,e){const r={first:e.first,last:e.last},n="("===e.t;let s;if(n){if(s=t.next(),s.done)throw D;r.last=s.value.last}else s={value:e};if(s.value.t!==o.Ident)throw new M(s.value,`not an identifier: ${s.value.v}`);const a={prim:s.value.v,[i]:r};for(;;){const e=t.next();if(e.done){if(n)throw D;break}if(")"===e.value.t){if(!n)throw new M(e.value,"unexpected closing bracket");r.last=e.value.last;break}if(U(e.value))a.annots=a.annots||[],a.annots.push(e.value.v),r.last=e.value.last;else{a.args=a.args||[];const n=this.parseExpr(t,e.value);r.last=n[i]?.last||r.last,a.args.push(n)}}return this.expand(a)}parseArgs(t,e){const r={first:e.first,last:e.last},n={prim:e.v,[i]:r};for(;;){const e=t.next();if(e.done||"}"===e.value.t||";"===e.value.t)return[n,e];if(U(e.value))r.last=e.value.last,n.annots=n.annots||[],n.annots.push(e.value.v);else{const s=this.parseExpr(t,e.value);r.last=s[i]?.last||r.last,n.args=n.args||[],n.args.push(s)}}}parseSequenceExpr(t,e){const r={first:e.first,last:e.last},n=[];n[i]=r;const s="{"===e.t;let a="{"===e.t?null:{value:e};for(;;){if(null===a&&(a=t.next(),a.done||(r.last=a.value.last)),a.done){if(s)throw D;return n}if("}"===a.value.t){if(s)return n;throw new M(a.value,"unexpected closing bracket")}if(a.value.t===o.Ident){const[e,s]=this.parseArgs(t,a.value);r.last=e[i]?.last||r.last,n.push(this.expand(e)),a=s}else{const e=this.parseExpr(t,a.value);r.last=e[i]?.last||r.last,n.push(e),a=null}null===a&&(a=t.next(),a.done||(r.last=a.value.last)),a.done||";"!==a.value.t||(a=null)}}parseExpr(t,e){switch(e.t){case o.Ident:return this.expand({prim:e.v,[i]:{first:e.first,last:e.last}});case o.Number:return{int:e.v,[i]:{first:e.first,last:e.last}};case o.String:return{string:JSON.parse(e.v),[i]:{first:e.first,last:e.last}};case o.Bytes:return{bytes:e.v.slice(2),[i]:{first:e.first,last:e.last}};case"{":return this.parseSequenceExpr(t,e);default:return this.parseListExpr(t,e)}}parseSequence(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseSequenceExpr(e,r.value)}parseList(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseListExpr(e,r.value)}parseMichelineExpression(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseExpr(e,r.value)}parseScript(t){return this.parseSequence(t)}parseData(t){return this.parseList(t)}parseJSON(t){if("object"!=typeof t)throw new TypeError(`object type was expected, got ${typeof t} instead`);if(Array.isArray(t)){const e=[];for(const r of t){if(null===r||"object"!=typeof r)throw new B(r,`unexpected sequence element: ${r}`);e.push(this.parseJSON(r))}return e}if("prim"in t){const e=t;if("string"==typeof e.prim&&(void 0===e.annots||Array.isArray(e.annots))&&(void 0===e.args||Array.isArray(e.args))){const t={prim:e.prim};if(void 0!==e.annots){for(const t of e.annots)if("string"!=typeof t)throw new B(t,`string expected: ${t}`);t.annots=e.annots}if(void 0!==e.args){t.args=[];for(const r of e.args){if(null===r||"object"!=typeof r)throw new B(r,`unexpected argument: ${r}`);t.args.push(this.parseJSON(r))}}return this.expand(t)}throw new B(t,`malformed prim expression: ${t}`)}if("string"in t){if("string"==typeof t.string)return{string:t.string};throw new B(t,`malformed string literal: ${t}`)}if("int"in t){if("string"==typeof t.int&&K.test(t.int))return{int:t.int};throw new B(t,`malformed int literal: ${t}`)}if("bytes"in t){if("string"==typeof t.bytes&&H.test(t.bytes))return{bytes:t.bytes};throw new B(t,`malformed bytes literal: ${t}`)}throw new B(t,`unexpected object: ${t}`)}}class G{constructor(t,e=0){this.opt=t,this.lev=e}indent(t=0){let e="";if(void 0!==this.opt?.indent)for(let r=this.lev+t;r>0;r--)e+=this.opt.indent;return e}get lf(){return this.opt?.newline||""}get lfsp(){return this.opt?.newline||" "}down(t){return new G(this.opt,this.lev+t)}}function V(t){return"prim"in t&&(void 0!==t.annots&&0!==t.annots.length||void 0!==t.args&&0!==t.args.length)}function j(t){if(void 0!==t.args)for(const e of t.args)if(Array.isArray(e)||V(e))return!0;return!1}function $(t,e,r){const n=t[i]?.macro;if(r&&n)return $(n,e,r);if(Array.isArray(t))return function(t,e,r){let n="{"+e.lf,i=t.length;for(const s of t){if(n+=e.indent(1),"prim"in s){if(n+=s.prim,void 0!==s.annots)for(const t of s.annots)n+=" "+t;if(void 0!==s.args){const t=j(s);for(const i of s.args)n+=t?e.lfsp+e.indent(2)+$(i,e.down(2),r):" "+$(i,e,r)}}else n+=$(s,e.down(1),r);n+=i>1?";"+e.lfsp:e.lf,i--}return n+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;let n="("+t.prim;if(void 0!==t.annots)for(const e of t.annots)n+=" "+e;if(void 0!==t.args){const i=j(t);for(const s of t.args)n+=i?e.lfsp+e.indent(1)+$(s,e.down(1),r):" "+$(s,e,r)}return n+")"}}function z(t,e,r=!1){if("object"!=typeof t)throw new TypeError(`object type was expected, got ${typeof t} instead`);return $(t,new G(e),r)}const q=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],W=[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];class Z extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="Base58DecodingError"}}function Y(t){const e=(t.length+9)%64,r=0===e?0:64-e;if(t.length>268435455)throw new n.InvalidMessageError("",`: Invalid length ${t.length} is too big -- SHA-256.`);const i=t.length<<3,s=[...t,128,...new Array(r).fill(0),0,0,0,0,i>>24&255,i>>16&255,i>>8&255,255&i];function o(t,e){return t>>>e|t<<32-e}const a=[...q],c=new Array(64),u=new Array(8);for(let t=0;t<s.length;t+=64){let e=t,r=0;for(;r<16;)c[r]=s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3],e+=4,r++;for(;r<64;){const t=o(c[r-15],7)^o(c[r-15],18)^c[r-15]>>>3,e=o(c[r-2],17)^o(c[r-2],19)^c[r-2]>>>10;c[r]=(0|e)+c[r-7]+t+c[r-16]|0,r++}for(let t=0;t<8;t++)u[t]=a[t];for(let t=0;t<64;t++){const e=o(u[0],2)^o(u[0],13)^o(u[0],22),r=o(u[4],6)^o(u[4],11)^o(u[4],25),n=u[7]+r+(u[4]&u[5]^~u[4]&u[6])+W[t]+c[t]|0,i=e+(u[0]&u[1]^u[0]&u[2]^u[1]&u[2])|0;u[7]=u[6],u[6]=u[5],u[5]=u[4],u[4]=u[3]+n|0,u[3]=u[2],u[2]=u[1],u[1]=u[0],u[0]=n+i|0}for(let t=0;t<8;t++)a[t]=a[t]+u[t]|0}const l=[];for(const t of a)l.push(t>>24&255),l.push(t>>16&255),l.push(t>>8&255),l.push(255&t);return l}const X=[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],J=[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 Q(t,e){const r=t.charCodeAt(e)-49;if(r>=X.length||-1===X[r])throw new Z(`Unexpected character at position ${e}: ${t[e]}`);return X[r]}function tt(t){const e=function(t){const e=[];let r=0;for(;r<t.length&&0===Q(t,r);)r++;let n=r;for(;r<t.length;){let n=Q(t,r++),i=0;for(;0!==n||i<e.length;){const t=58*(e[i]||0)+n;e[i++]=t%256,n=Math.floor(t/256)}}for(;n-- >0;)e.push(0);return e.reverse()}(t);if(e.length<4)throw new Z(`Data is too short ${e.length}`);const r=e.slice(0,e.length-4),n=e.slice(e.length-4),i=Y(Y(r));if(n[0]!==i[0]||n[1]!==i[1]||n[2]!==i[2]||n[3]!==i[3])throw new Z("Invalid checksum");return r}function et(t){const e=Y(Y(t));return function(t){const e=[];let r=0;for(;r<t.length&&0===t[r];)r++;let n=r;for(;r<t.length;){let n=t[r++],i=0;for(;0!==n||i<e.length;){const t=256*(e[i]||0)+n;e[i++]=t%58,n=Math.floor(t/58)}}for(;n-- >0;)e.push(0);return e.reverse(),String.fromCharCode(...e.map(t=>J[t]+49))}([...t,...e.slice(0,4)])}class rt extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidMichelsonError"}}class nt extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidTypeExpressionError"}}class it extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidDataExpressionError"}}class st extends n.ParameterValidationError{constructor(t){super(),this.entrypoint=t,this.name="InvalidEntrypointError",this.message=`Contract has no entrypoint named: "${t}"`}}class ot extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="TezosIdEncodeError"}}class at extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="LongIntegerError"}}class ct extends n.TaquitoError{constructor(t){super(),this.hexByte=t,this.name="HexParseError",this.message=`Unable to parse hex byte "${t}"`}}class ut extends n.TaquitoError{constructor(t,e){super(),this.val=t,this.message=e,this.name="MichelsonError"}}function lt(t){return t instanceof ut}class ht extends ut{constructor(t,e,r){super(t,e),this.val=t,this.message=e,this.name="MichelsonTypeError",void 0!==r&&(this.data=r)}}class ft{append(t){let e=0;for(;0!==t||e<this.buf.length;){const r=10*(this.buf[e]||0)+t;this.buf[e++]=r%256,t=Math.floor(r/256)}}constructor(t){if(this.neg=!1,this.buf=[],void 0!==t)if("string"==typeof t)for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(0===e&&45===r)this.neg=!0;else{if(r<48||r>57)throw new at(`unexpected character in integer constant "${t[e]}"`);this.append(r-48)}}else t<0?(this.neg=!0,this.append(-t)):this.append(t)}cmp(t){if(this.neg!==t.neg)return(t.neg?1:0)-(this.neg?1:0);{let e=0;if(this.buf.length!==t.buf.length)e=this.buf.length<t.buf.length?-1:1;else if(0!==this.buf.length){let r=t.buf.length-1;for(;r>=0&&this.buf[r]===t.buf[r];)r--;e=r<0?0:this.buf[r]<t.buf[r]?-1:1}return this.neg?0===e?0:-e:e}}get sign(){return 0===this.buf.length?0:this.neg?-1:1}}function dt(t){const e=[];for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);if(Number.isNaN(n))return null;e.push(n)}return e}function pt(t){try{return new ft(t),!0}catch{return!1}}function gt(t){try{return new ft(t).sign>=0}catch{return!1}}const mt=/^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;function yt(t,e){if(Array.isArray(t))return{};let r,n,i;if(void 0!==t.annots)for(const s of t.annots)if(0!==s.length){if(!mt.test(s)||!e?.specialVar&&("@%"===s||"@%%"===s)||!e?.specialFields&&"%@"===s)throw new ut(t,`${t.prim}: unexpected annotation: ${s}`);switch(s[0]){case"%":(e?.emptyFields||s.length>1)&&(r=r||[],r.push(s));break;case":":s.length>1&&(n=n||[],n.push(s));break;case"@":(e?.emptyVar||s.length>1)&&(i=i||[],i.push(s))}}return{f:r,t:n,v:i}}const bt={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]],RollupAddress:[20,[1,128,120,31]]};function vt(t,...e){const r=tt(t);for(const t of e){const[e,n]=bt[t];if(r.length===e+n.length){let e=0;for(;e<n.length&&r[e]===n[e];)e++;if(e===n.length)return[t,r.slice(n.length)]}}return null}function wt(t,e){const[r,n]=bt[t];if(e.length!==r)throw new ot(`Incorrect data length for ${t}: ${e.length}`);return et([...n,...e])}function Et(t,e){const r=e,n=Array.isArray(r)?r:r.args;if(2===n.length){return"pair"===t?{prim:"pair",args:n}:{prim:"Pair",args:n}}return{...Array.isArray(r)?{prim:t}:r,args:[n[0],{prim:t,args:n.slice(1)}]}}function _t(t){return Array.isArray(t)||"pair"===t.prim}function At(t){return Array.isArray(t)||"prim"in t&&"Pair"===t.prim}const Ot=/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[T ]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):([0-5][0-9]))$/;function St(t){if("string"in t){if(gt(t.string))return new Date(parseInt(t.string,10));if(Ot.test(t.string)){const e=new Date(t.string);if(!Number.isNaN(e.valueOf))return e}}else if(pt(t.int))return new Date(parseInt(t.int,10));return null}function Tt(t){return t.map(t=>(t>>4&15).toString(16)+(15&t).toString(16)).join("")}const Pt={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,TICKET_DEPRECATED:!0,TOTAL_VOTING_POWER:!0,TRANSFER_TOKENS:!0,UNIT:!0,VOTING_POWER:!0,XOR:!0,RENAME:!0,OPEN_CHEST:!0,SUB_MUTEZ:!0,MIN_BLOCK_TIME:!0,BYTES:!0,NAT:!0,IS_IMPLICIT_ACCOUNT:!0,INDEX_ADDRESS:!0,GET_ADDRESS_INDEX:!0},Rt=Object.assign({},Pt,{CONTRACT:!0,CREATE_CONTRACT:!0,DIG:!0,DIP:!0,DROP:!0,DUG:!0,DUP:!0,EMIT:!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,LAMBDA_REC:!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,VIEW:!0}),xt={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,tx_rollup_l2_address:!0},It=Object.assign({},xt,{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_transaction_deprecated:!0,sapling_state:!0,ticket:!0,chest_key:!0,chest:!0});class Nt extends ut{constructor(t,e){super(t,e),this.val=t,this.message=e,this.name="MichelsonValidationError"}}function kt(t){return"prim"in t}function Lt(t){if(kt(t))return!0;throw new Nt(t,"prim expression expected")}function Ct(t){if(Array.isArray(t))return!0;throw new Nt(t,"sequence expression expected")}function Mt(t){if(function(t){return Array.isArray(t)||"prim"in t}(t))return!0;throw new Nt(t,"prim or sequence expression expected")}function Bt(t){if("-"===t.int[0])throw new Nt(t,"natural number expected")}function Dt(t){if("int"in t)return!0;throw new Nt(t,"int literal expected")}function Ut(t){if("string"in t)return!0;throw new Nt(t,"string literal expected")}function Kt(t,e){if(0===e&&void 0===t.args||t.args?.length===e)return!0;throw new Nt(t,`${e} arguments expected`)}function Ht(t){if(Array.isArray(t)){for(const e of t){if(!Array.isArray(e)&&!kt(e))throw new Nt(t,"sequence or prim expected");Ht(e)}return!0}if(Lt(t)){if(Object.prototype.hasOwnProperty.call(Pt,t.prim))return Kt(t,0),!0;switch(t.prim){case"DROP":case"PAIR":case"UNPAIR":case"DUP":case"UPDATE":case"GET":void 0!==t.args&&Kt(t,1)&&Dt(t.args[0])&&Bt(t.args[0]);break;case"DIG":case"DUG":case"SAPLING_EMPTY_STATE":Kt(t,1)&&Dt(t.args[0])&&Bt(t.args[0]);break;case"NONE":case"LEFT":case"RIGHT":case"NIL":case"CAST":Kt(t,1)&&Zt(t.args[0]);break;case"UNPACK":Kt(t,1)&&Gt(t.args[0]);break;case"CONTRACT":Kt(t,1)&&$t(t.args[0]);break;case"IF_NONE":case"IF_LEFT":case"IF_CONS":case"IF":Kt(t,2)&&(Ct(t.args[0])&&Ht(t.args[0]),Ct(t.args[1])&&Ht(t.args[1]));break;case"MAP":case"ITER":case"LOOP":case"LOOP_LEFT":Kt(t,1)&&Ht(t.args[0]);break;case"CREATE_CONTRACT":Kt(t,1)&&Jt(t.args[0]);break;case"DIP":if(2===t.args?.length)Dt(t.args[0])&&Bt(t.args[0]),Ct(t.args[1])&&Ht(t.args[1]);else{if(1!==t.args?.length)throw new Nt(t,"1 or 2 arguments expected");Ct(t.args[0])&&Ht(t.args[0])}break;case"PUSH":Kt(t,2)&&(Vt(t.args[0]),Xt(t.args[1]));break;case"EMPTY_SET":Kt(t,1)&&Ft(t.args[0]);break;case"EMPTY_MAP":Kt(t,2)&&(Ft(t.args[0]),Zt(t.args[1]));break;case"EMPTY_BIG_MAP":Kt(t,2)&&(Ft(t.args[0]),zt(t.args[1]));break;case"LAMBDA_REC":case"LAMBDA":Kt(t,3)&&(Zt(t.args[0]),Zt(t.args[1]),Ct(t.args[2])&&Ht(t.args[2]));break;case"VIEW":Kt(t,2)&&(Ut(t.args[0])&&Wt(t.args[0]),Zt(t.args[1])&&Vt(t.args[1]));break;case"EMIT":t.args&&t.args.length>0?Kt(t,1):Kt(t,0);break;default:throw new Nt(t,"instruction expected")}}return!0}function Ft(t){if(Mt(t))if(Array.isArray(t)||"pair"===t.prim||"or"===t.prim||"option"===t.prim)Yt(t,t=>Ft(t));else if(!Object.prototype.hasOwnProperty.call(xt,t.prim))throw new Nt(t,`${t.prim}: type is not comparable`);return!0}function Gt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim)throw new Nt(t,`${t.prim}: type can't be used inside PACK/UNPACK instructions`);Yt(t,t=>Gt(t))}return!0}function Vt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim||"contract"===t.prim)throw new Nt(t,`${t.prim}: type can't be pushed`);Yt(t,t=>Vt(t))}return!0}function jt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"operation"===t.prim||"contract"===t.prim)throw new Nt(t,`${t.prim}: type can't be used as part of a storage`);Yt(t,t=>jt(t))}return!0}function $t(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"operation"===t.prim)throw new Nt(t,`${t.prim}: type can't be used as part of a parameter`);Yt(t,t=>$t(t))}return!0}function zt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim)throw new Nt(t,`${t.prim}: type can't be used inside a big_map`);Yt(t,t=>zt(t))}return!0}const qt=new RegExp("^[a-zA-Z0-9_.%@]*$");function Wt(t){if(t.string.length>31)throw new Nt(t,`view name too long: ${t.string}`);if(!qt.test(t.string))throw new Nt(t,`invalid character(s) in view name: ${t.string}`)}function Zt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim))throw new Nt(t,"type expected");Yt(t,t=>Zt(t))}return!0}function Yt(t,e){if(Array.isArray(t)||"pair"===t.prim){const r=Array.isArray(t)?t:t.args;if(void 0===r||r.length<2)throw new Nt(t,"at least 2 arguments expected");return r.forEach(t=>{Mt(t)&&e(t)}),!0}switch(t.prim){case"option":case"list":Kt(t,1)&&Mt(t.args[0])&&e(t.args[0]);break;case"contract":Kt(t,1)&&$t(t.args[0]);break;case"or":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(e(t.args[0]),e(t.args[1]));break;case"lambda":Kt(t,2)&&(Zt(t.args[0]),Zt(t.args[1]));break;case"set":Kt(t,1)&&Ft(t.args[0]);break;case"map":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(Ft(t.args[0]),e(t.args[1]));break;case"big_map":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(Ft(t.args[0]),zt(t.args[1]),e(t.args[1]));break;case"ticket":Kt(t,1)&&Mt(t.args[0])&&Ft(t.args[0]);break;case"sapling_state":case"sapling_transaction":Kt(t,1)&&Dt(t.args[0]);break;default:Kt(t,0)}return!0}function Xt(t){if("int"in t||"string"in t||"bytes"in t)return!0;if(Array.isArray(t)){let e=0;for(const r of t)kt(r)&&"Elt"===r.prim?(Kt(r,2)&&(Xt(r.args[0]),Xt(r.args[1])),e++):Xt(r);if(0!==e&&e!==t.length)throw new Nt(t,"data entries and map elements can't be intermixed");return!0}if(!kt(t))throw new Nt(t,"data entry expected");switch(t.prim){case"Unit":case"True":case"False":case"None":Kt(t,0);break;case"Pair":if(void 0===t.args||t.args.length<2)throw new Nt(t,"at least 2 arguments expected");for(const e of t.args)Xt(e);break;case"Left":case"Right":case"Some":Kt(t,1)&&Xt(t.args[0]);break;case"Lambda_rec":t.args&&Ht(t.args);break;case"Ticket":Kt(t,4)&&(!function(t){if("string"in t||"bytes"in t)return!0;throw new Nt(t,"string or bytes literal expected")}(t.args[0]),Zt(t.args[1]),Xt(t.args[2]),Dt(t.args[3]));break;default:if(!Object.prototype.hasOwnProperty.call(Rt,t.prim))throw new Nt(t,"data entry or instruction expected");Ht(t)}return!0}function Jt(t){if(Ct(t)){const e={},r={};for(const n of t)if(Lt(n)){if("view"!==n.prim){if(n.prim in e)throw new Nt(t,`duplicate contract section: ${n.prim}`);e[n.prim]=!0}switch(n.prim){case"code":Kt(n,1)&&Ct(n.args[0])&&Ht(n.args[0]);break;case"parameter":if(Kt(n,1)&&$t(n.args[0]),n.annots)throw new Nt(n,"Annotation must be part of the parameter type");break;case"storage":Kt(n,1)&&jt(n.args[0]);break;case"view":if(Kt(n,4)){if(Ut(n.args[0])){const e=n.args[0];if(e.string in r)throw new Nt(t,`duplicate view name: ${e.string}`);r[e.string]=!0,Wt(e)}Vt(n.args[1]),Vt(n.args[2]),Ct(n.args[3])&&Ht(n.args[3])}break;default:throw new Nt(t,`unexpected contract section: ${n.prim}`)}}}return!0}function Qt(t){try{return Jt(t),!0}catch{return!1}}function te(t){try{return Xt(t),!0}catch{return!1}}function ee(t){try{return Ht(t),!0}catch{return!1}}function re(t){try{return Zt(t),!0}catch{return!1}}function ne(t){return Object.prototype.hasOwnProperty.call(Rt,t.prim)}function ie(t){if(!Array.isArray(t))return!1;for(const e of t)if("prim"in e){if(ne(e))throw new ut(t,`Instruction outside of a lambda: ${JSON.stringify(t)}`);if("Elt"===e.prim)throw new ut(t,`Elt item outside of a map literal: ${JSON.stringify(t)}`)}return!0}const se=["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_deprecated","SAPLING_EMPTY_STATE","SAPLING_VERIFY_UPDATE","ticket","TICKET_DEPRECATED","READ_TICKET","SPLIT_TICKET","JOIN_TICKETS","GET_AND_UPDATE","chest","chest_key","OPEN_CHEST","VIEW","view","constant","SUB_MUTEZ","tx_rollup_l2_address","MIN_BLOCK_TIME","sapling_transaction","EMIT","Lambda_rec","LAMBDA_REC","TICKET","BYTES","NAT","Ticket","IS_IMPLICIT_ACCOUNT","INDEX_ADDRESS","GET_ADDRESS_INDEX"],oe=Object.assign({},...se.map((t,e)=>({[t]:e})));var ae;!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"}(ae||(ae={}));class ce{constructor(){this.buffer=[]}get length(){return this.buffer.length}writeBytes(t){this.buffer.push(...t.map(t=>255&t))}writeUint8(t){const e=0|t;this.buffer.push(255&e)}writeUint16(t){const e=0|t;this.buffer.push(e>>8&255),this.buffer.push(255&e)}writeUint32(t){const 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)}writeInt8(t){this.writeUint8(t)}writeInt16(t){this.writeUint16(t)}writeInt32(t){this.writeUint32(t)}}const ue=new Error("bounds out of range");class le{constructor(t,e=0,r=t.length){this.buffer=t,this.idx=e,this.cap=r}get length(){return this.cap-this.idx}readBytes(t){if(this.cap-this.idx<t)throw ue;const e=this.buffer.slice(this.idx,this.idx+t);return this.idx+=t,e}reader(t){if(this.cap-this.idx<t)throw ue;const e=new le(this.buffer,this.idx,this.idx+t);return this.idx+=t,e}copy(){return new le(this.buffer,this.idx,this.cap)}readUint8(){if(this.cap-this.idx<1)throw ue;return this.buffer[this.idx++]>>>0}readUint16(){if(this.cap-this.idx<2)throw ue;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0}readUint32(){if(this.cap-this.idx<4)throw ue;return(this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0}readInt8(){if(this.cap-this.idx<1)throw ue;return this.buffer[this.idx++]<<24>>24}readInt16(){if(this.cap-this.idx<2)throw ue;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])<<16>>16}readInt32(){if(this.cap-this.idx<4)throw ue;return this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++]}}var he,fe,de;function pe(t){let e;const r=t.readUint8();switch(r){case fe.ED25519:e="ED25519PublicKeyHash";break;case fe.SECP256K1:e="SECP256K1PublicKeyHash";break;case fe.P256:e="P256PublicKeyHash";break;default:throw new Error(`unknown public key hash tag: ${r}`)}return{type:e,hash:t.readBytes(20)}}function ge(t){let e;const r=t.readUint8();switch(r){case he.Implicit:e=pe(t);break;case he.Originated:e={type:"ContractHash",hash:t.readBytes(20)},t.readBytes(1);break;default:throw new Error(`unknown address tag: ${r}`)}if(0!==t.length){const r=new TextDecoder;e.entryPoint=r.decode(new Uint8Array(t.readBytes(t.length)))}return e}function me(t,e){let r;switch(t.type){case"ED25519PublicKeyHash":r=fe.ED25519;break;case"SECP256K1PublicKeyHash":r=fe.SECP256K1;break;case"P256PublicKeyHash":r=fe.P256;break;default:throw new Error(`unexpected address type: ${t.type}`)}e.writeUint8(r),e.writeBytes(Array.from(t.hash))}function ye(t){let e,r;const n=t.readUint8();switch(n){case de.ED25519:r="ED25519PublicKey",e=32;break;case de.SECP256K1:r="SECP256K1PublicKey",e=33;break;case de.P256:r="P256PublicKey",e=33;break;default:throw new Error(`unknown public key tag: ${n}`)}return{type:r,publicKey:t.readBytes(e)}}function be(t,e,r){const[n,i]=r(t);if(Array.isArray(n)){const t=new ce;for(const e of n){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(e,t,r.value)}return e.writeUint8(ae.Sequence),e.writeUint32(t.length),void e.writeBytes(t.buffer)}if("string"in n){const t=(new TextEncoder).encode(n.string);return e.writeUint8(ae.String),e.writeUint32(t.length),void e.writeBytes(Array.from(t))}if("int"in n){e.writeUint8(ae.Int);let t=BigInt(n.int);const r=t<0;r&&(t=-t);let i=0;do{const n=0===i?BigInt(6):BigInt(7);let s=t&(BigInt(1)<<n)-BigInt(1);t>>=n,t&&(s|=BigInt(128)),0===i&&r&&(s|=BigInt(64)),e.writeUint8(Number(s)),i++}while(t);return}if("bytes"in n){const t=function(t){const e=[];for(let r=0;r<t.length;r+=2){const n=t.slice(r,r+2),i=parseInt(n,16);if(Number.isNaN(i))throw new ct(n);e.push(i)}return e}(n.bytes);return e.writeUint8(ae.Bytes),e.writeUint32(t.length),void e.writeBytes(t)}const s=oe[n.prim];if(void 0===s)throw new TypeError(`Can't encode primary: ${n.prim}`);const o=(n.args?.length||0)<3?ae.Prim0+2*(n.args?.length||0)+(void 0===n.annots||0===n.annots.length?0:1):ae.Prim;if(e.writeUint8(o),e.writeUint8(s),void 0!==n.args)if(n.args.length<3)for(const t of n.args){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(t,e,r.value)}else{const t=new ce;for(const e of n.args){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(e,t,r.value)}e.writeUint32(t.length),e.writeBytes(t.buffer)}if(void 0!==n.annots&&0!==n.annots.length){const t=(new TextEncoder).encode(n.annots.join(" "));e.writeUint32(t.length),e.writeBytes(Array.from(t))}else void 0!==n.args&&n.args.length>=3&&e.writeUint32(0)}function ve(t,e){function*r(){for(;;)yield Re}const[n,i]=e,s=t.readUint8();switch(s){case ae.Int:{const e=[];let r;do{r=t.readInt8(),e.push(r)}while(128&r);let n=BigInt(0),s=!1;for(let t=e.length-1;t>=0;t--){const r=0===t?BigInt(6):BigInt(7),i=BigInt(e[t]);n<<=r,n|=i&(BigInt(1)<<r)-BigInt(1),0===t&&(s=!!(i&BigInt(64)))}return s&&(n=-n),i({int:String(n)})}case ae.String:{const e=t.readUint32(),r=t.readBytes(e);return i({string:(new TextDecoder).decode(new Uint8Array(r))})}case ae.Bytes:{const e=t.readUint32(),r=t.readBytes(e);return i({bytes:Tt(Array.from(r))})}case ae.Sequence:{const e=t.readUint32();let s=[],o=t.copy(),a=r();for(let r=0;r<2;r++){const r=o.reader(e);for(s=[];r.length>0;){const t=a.next();if(t.done)throw new Error("REPORT ME: iterator is done");s.push(ve(r,t.value))}a=n(s),o=t}return i(s)}default:{if(s>9)throw new Error(`Unknown tag: ${s}`);const e=t.readUint8();if(e>=se.length)throw new Error(`Unknown primitive tag: ${e}`);const o=se[e],a=s-3>>1;let c={prim:o},u=r(),l=t.copy();for(let e=0;e<2;e++){if(c={prim:o},a<3)for(let t=0;t<a;t++){const t=u.next();if(t.done)throw new Error("REPORT ME: iterator is done");c.args=c.args||[],c.args.push(ve(l,t.value))}else{c.args=c.args||[];const t=l.readUint32(),e=l.reader(t);for(;e.length>0;){const t=u.next();if(t.done)throw new Error("REPORT ME: iterator is done");c.args.push(ve(e,t.value))}}u=n(c),l=t}if(1==(s-3&1)||3===a){const e=t.readUint32();if(0!==e){const r=t.readBytes(e),n=new TextDecoder;c.annots=n.decode(new Uint8Array(r)).split(" ")}}return i(c)}}}!function(t){t[t.Implicit=0]="Implicit",t[t.Originated=1]="Originated"}(he||(he={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(fe||(fe={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(de||(de={}));const we=t=>"prim"in t&&("Left"===t.prim||"Right"===t.prim),Ee=t=>"prim"in t&&("Some"===t.prim||"None"===t.prim),_e=t=>{if(_t(t))return e=>{if(!At(e))throw new ht(t,`pair expected: ${JSON.stringify(e)}`,e);ie(e);const r=Et("pair",t);return[Et("Pair",e),function*(){for(const t of r.args)yield _e(t)}()]};switch(t.prim){case"or":return e=>{if(!we(e))throw new ht(t,`or expected: ${JSON.stringify(e)}`,e);return[e,function*(){yield _e(t.args["Left"===e.prim?0:1])}()]};case"option":return e=>{if(!Ee(e))throw new ht(t,`option expected: ${JSON.stringify(e)}`,e);return[e,function*(){"Some"===e.prim&&(yield _e(t.args[0]))}()]};case"list":case"set":return e=>{if(!Array.isArray(e))throw new ht(t,`${t.prim} expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const r of e)yield _e(t.args[0])}()]};case"map":return e=>{if(!Array.isArray(e))throw new ht(t,`map expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const r of e)yield e=>{if(!("prim"in e)||"Elt"!==e.prim)throw new ht(t,`map element expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const e of t.args)yield _e(e)}()]}}()]};case"chain_id":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`chain id expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ChainID");if(null===n)throw new ht(t,`chain id base58 expected: ${e.string}`,e);r={bytes:Tt(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"signature":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`signature expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature");if(null===n)throw new ht(t,`signature base58 expected: ${e.string}`,e);r={bytes:Tt(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"key_hash":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`key hash expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash");if(null===n)throw new ht(t,`key hash base58 expected: ${e.string}`,e);const i=new ce;me({type:n[0],hash:n[1]},i),r={bytes:Tt(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"key":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`public key expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey");if(null===n)throw new ht(t,`public key base58 expected: ${e.string}`,e);const i=new ce;!function(t,e){let r;switch(t.type){case"ED25519PublicKey":r=de.ED25519;break;case"SECP256K1PublicKey":r=de.SECP256K1;break;case"P256PublicKey":r=de.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:Tt(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"address":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=e.string.split("%"),i=vt(n[0],"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash");if(null===i)throw new ht(t,`address base58 expected: ${e.string}`,e);const s=new ce;!function(t,e){if("ContractHash"===t.type?(e.writeUint8(he.Originated),e.writeBytes(Array.from(t.hash)),e.writeUint8(0)):(e.writeUint8(he.Implicit),me(t,e)),void 0!==t.entryPoint&&""!==t.entryPoint&&"default"!==t.entryPoint){const 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},s),r={bytes:Tt(s.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"timestamp":return e=>{if(!("string"in e)&&!("int"in e))throw new ht(t,`timestamp expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=St(e);if(null===n)throw new ht(t,`can't parse date: ${e.string}`,e);r={int:String(Math.floor(n.getTime()/1e3))}}else r=e;return[r,[][Symbol.iterator]()]};default:return Oe}},Ae=t=>"prim"in t&&"PUSH"===t.prim,Oe=t=>Ae(t)?(Ht(t),[t,function*(){yield Oe,yield _e(t.args[0])}()]):[t,function*(){for(;;)yield Oe}()];function Se(t,e){const r=new ce;return r.writeUint8(5),be(t,r,void 0!==e?_e(e):Oe),r.buffer}function Te(t,e){return{bytes:Tt(Se(t,e))}}const Pe=t=>{if(_t(t))return[e=>{if(!At(e))throw new ht(t,`pair expected: ${JSON.stringify(e)}`,e);const r=Et("pair",t);return function*(){for(const t of r.args)yield Pe(t)}()},t=>t];switch(t.prim){case"or":return[e=>{if(!we(e))throw new ht(t,`or expected: ${JSON.stringify(e)}`,e);return function*(){yield Pe(t.args["Left"===e.prim?0:1])}()},t=>t];case"option":return[e=>{if(!Ee(e))throw new ht(t,`option expected: ${JSON.stringify(e)}`,e);return function*(){"Some"===e.prim&&(yield Pe(t.args[0]))}()},t=>t];case"list":case"set":return[e=>{if(!Array.isArray(e))throw new ht(t,`${t.prim} expected: ${JSON.stringify(e)}`,e);return function*(){for(;;)yield Pe(t.args[0])}()},t=>t];case"map":return[e=>{if(!Array.isArray(e))throw new ht(t,`map expected: ${JSON.stringify(e)}`,e);return function*(){for(;;)yield[e=>{if(!("prim"in e)||"Elt"!==e.prim)throw new ht(t,`map element expected: ${JSON.stringify(e)}`,e);return function*(){for(const e of t.args)yield Pe(e)}()},t=>t]}()},t=>t];case"chain_id":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`chain id expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);return{string:wt("ChainID",r)}}];case"signature":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`signature expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);return{string:wt("GenericSignature",r)}}];case"key_hash":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`key hash expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=pe(new le(new Uint8Array(r)));return{string:wt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"key":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`public key expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=ye(new le(new Uint8Array(r)));return{string:wt(n.type,n.publicKey)}}];case"address":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=ge(new le(new Uint8Array(r)));return{string:wt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"timestamp":return[()=>[][Symbol.iterator](),e=>{if(!("int"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;return{string:new Date(1e3*parseInt(e.int,10)).toISOString().slice(0,19)+"Z"}}];default:return Re}},Re=[t=>Ae(t)?(Ht(t),function*(){yield Re,yield Pe(t.args[0])}()):function*(){for(;;)yield Re}(),t=>t];function xe(t,e){const r=new le(t);if(5!==r.readUint8())throw new Error("incorrect packed data magic number");const n=ve(r,void 0!==e?Pe(e):Re);if(Xt(n))return n;throw new Error}function Ie(t,e){const r=dt(t.bytes);if(null===r)throw new Error(`can't parse bytes: "${t.bytes}"`);return xe(r,e)}function Ne(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return ge(new le(new Uint8Array(e)))}function ke(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return pe(new le(new Uint8Array(e)))}function Le(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return ye(new le(new Uint8Array(e)))}class Ce extends ut{constructor(t,e,r){super(t,r),this.val=t,this.stackState=e,this.message=r,this.name="MichelsonInstructionError"}}function Me(t){return Array.isArray(t)?"pair":t.prim}function Be(t){return"prim"in t?t.args:t}function De(t,e,r=!1){if(Me(t)!==Me(e))throw new ht(t,`types mismatch: ${Me(t)} != ${Me(e)}`,void 0);const n=[yt(t),yt(e)];if(n[0].t&&n[1].t&&n[0].t[0]!==n[1].t[0])throw new ht(t,`${Me(t)}: type names mismatch: ${n[0].t[0]} != ${n[1].t[0]}`,void 0);if(r&&n[0].f&&n[1].f&&n[0].f[0]!==n[1].f[0])throw new ht(t,`${Me(t)}: field names mismatch: ${n[0].f[0]} != ${n[1].f}`,void 0);if(_t(t)){const r=Et("pair",t),n=Et("pair",e);return De(r.args[0],n.args[0],!0),void De(r.args[1],n.args[1],!0)}switch(t.prim){case"option":case"list":case"contract":case"set":case"ticket":De(t.args[0],e.args[0]);break;case"or":De(t.args[0],e.args[0],!0),De(t.args[1],e.args[1],!0);break;case"lambda":case"map":case"big_map":De(t.args[0],e.args[0]),De(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 ht(t,`${Me(t)}: type argument mismatch: ${t.args[0].int} != ${e.args[0].int}`,void 0)}}function Ue(t,e){if(t.length!==e.length)throw new ht(t,`stack length mismatch: ${t.length} != ${e.length}`,void 0);for(let r=0;r<t.length;r++)De(t[r],e[r])}function Ke(t,e=!1){if(!Array.isArray(t)){const r=yt(t);if((r.t?.length||0)>1)throw new ht(t,`${t.prim}: at most one type annotation allowed: ${t.annots}`,void 0);if(e){if((r.f?.length||0)>1)throw new ht(t,`${t.prim}: at most one field annotation allowed: ${t.annots}`,void 0)}else if((r.f?.length||0)>0)throw new ht(t,`${t.prim}: field annotations aren't allowed: ${t.annots}`,void 0)}if(_t(t)){const e=Be(t);for(const t of e)Ke(t,!0);return}switch(t.prim){case"option":case"list":case"contract":case"set":Ke(t.args[0]);break;case"or":for(const e of t.args)Ke(e,!0);break;case"lambda":case"map":case"big_map":Ke(t.args[0]),Ke(t.args[1])}}function He(t){if(!Array.isArray(t))return!1;for(const e of t)if(!(Array.isArray(e)&&He(e)||"prim"in e&&ne(e)))return!1;return!0}function Fe(t,e,r){if(_t(e)){if(At(t)){ie(t);const n=Et("Pair",t),i=Et("pair",e);return Fe(n.args[0],i.args[0],r),void Fe(n.args[1],i.args[1],r)}throw new ht(e,`pair expected: ${JSON.stringify(t)}`,t)}switch(e.prim){case"int":if("int"in t&&pt(t.int))return;throw new ht(e,`integer value expected: ${JSON.stringify(t)}`,t);case"nat":case"mutez":if("int"in t&>(t.int))return;throw new ht(e,`natural value expected: ${JSON.stringify(t)}`,t);case"string":if("string"in t)return;throw new ht(e,`string value expected: ${JSON.stringify(t)}`,t);case"bytes":case"bls12_381_g1":case"bls12_381_g2":if("bytes"in t&&null!==dt(t.bytes))return;throw new ht(e,`bytes value expected: ${JSON.stringify(t)}`,t);case"bool":if("prim"in t&&("True"===t.prim||"False"===t.prim))return;throw new ht(e,`boolean value expected: ${JSON.stringify(t)}`,t);case"key_hash":if("string"in t&&null!==vt(t.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash"))return;if("bytes"in t)try{return void ke(t)}catch(t){}throw new ht(e,`key hash expected: ${JSON.stringify(t)}`,t);case"timestamp":if(("string"in t||"int"in t)&&null!==St(t))return;throw new ht(e,`timestamp expected: ${JSON.stringify(t)}`,t);case"address":if("string"in t){let e=t.string;const r=t.string.indexOf("%");if(r>=0&&(e=t.string.slice(0,r)),null!==vt(e,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash","RollupAddress"))return}else if("bytes"in t)try{return void Ne(t)}catch(t){}throw new ht(e,`address expected: ${JSON.stringify(t)}`,t);case"key":if("string"in t&&null!==vt(t.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey"))return;if("bytes"in t)try{return void Le(t)}catch(t){}throw new ht(e,`public key expected: ${JSON.stringify(t)}`,t);case"unit":if("prim"in t&&"Unit"===t.prim)return;throw new ht(e,`unit value expected: ${JSON.stringify(t)}`,t);case"signature":if("bytes"in t||"string"in t&&null!==vt(t.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature"))return;throw new ht(e,`signature expected: ${JSON.stringify(t)}`,t);case"chain_id":if("bytes"in t||"string"in t){if(null!==("string"in t?tt(t.string):dt(t.bytes)))return}throw new ht(e,`chain id expected: ${JSON.stringify(t)}`,t);case"option":if("prim"in t){if("None"===t.prim)return;if("Some"===t.prim)return void Fe(t.args[0],e.args[0],r)}throw new ht(e,`option expected: ${JSON.stringify(t)}`,t);case"list":case"set":if(ie(t)){for(const n of t)Fe(n,e.args[0],r);return}throw new ht(e,`${e.prim} expected: ${JSON.stringify(t)}`,t);case"or":if("prim"in t){if("Left"===t.prim)return void Fe(t.args[0],e.args[0],r);if("Right"===t.prim)return void Fe(t.args[0],e.args[1],r)}throw new ht(e,`union (or) expected: ${JSON.stringify(t)}`,t);case"lambda":if(He(t)){const n=Ge(t,[e.args[0]],r);if("failed"in n)throw new ht(e,`function is failed with error type: ${n.failed}`,t);if(1!==n.length)throw new ht(e,"function must return a value",t);return void De(e.args[1],n[0])}throw new ht(e,`function expected: ${JSON.stringify(t)}`,t);case"map":case"big_map":if(Array.isArray(t)){for(const n of t){if(!("prim"in n)||"Elt"!==n.prim)throw new ht(e,`map elements expected: ${JSON.stringify(t)}`,t);Fe(n.args[0],e.args[0],r),Fe(n.args[1],e.args[1],r)}return}throw new ht(e,`${e.prim} expected: ${JSON.stringify(t)}`,t);case"bls12_381_fr":if("int"in t&&pt(t.int)||"bytes"in t&&null!==dt(t.bytes))return;throw new ht(e,`BLS12-381 element expected: ${JSON.stringify(t)}`,t);case"sapling_state":if(Array.isArray(t))return;throw new ht(e,`sapling state expected: ${JSON.stringify(t)}`,t);case"ticket":if("prim"in t&&"Ticket"===t.prim)return Fe(t.args[0],{prim:"address"},r),Xe(t.args[1],e.args[0]),Fe(t.args[2],e.args[0],r),void Fe(t.args[3],{prim:"nat"},r);if(At(t))return void Fe(t,{prim:"pair",args:[{prim:"address"},e.args[0],{prim:"nat"}]},r);throw new ht(e,`ticket expected: ${JSON.stringify(t)}`,t);default:throw new ht(e,`type ${Me(e)} don't have Michelson literal representation`,t)}}function Ge(t,e,r){const n=r?.protocol||g;if(Array.isArray(t))return function(t,e,r){let n=e,i=e,s=0;for(const e of t){const t=Ge(e,i,r);if(n=t,"failed"in t)break;i=t,s++}if("failed"in n&&0==n.level&&(!("prim"in n.failed)||"never"!==n.failed.prim)&&s!==t.length-1)throw new Ce(t,n,"FAIL must appear in a tail position");if(void 0!==r?.traceCallback){const i={op:t,in:e,out:n};r.traceCallback(i)}return"failed"in n?{failed:n.failed,level:n.level+1}:n}(t,e,r);const i=t;function s(t,...r){if(e.length<r.length+t)throw new Ce(i,e,`${i.prim}: stack must have at least ${r.length} element(s)`);let n=t;for(const t of r){if(null!==t&&0!==t.length){let r=0;for(;r<t.length&&t[r]!==Me(e[n]);)r++;if(r===t.length)throw new Ce(i,e,`${i.prim}: stack type mismatch: [${n}] expected to be ${t}, got ${Me(e[n])} instead`)}n++}return e.slice(t,r.length+t)}function o(t){return(...r)=>{try{return t(...r)}catch(t){throw t instanceof ut?new Ce(i,e,t.message):t}}}function a(t){return r=>{try{return t(r)}catch(t){throw t instanceof ut?new Ce(i,e,t.message):t}}}const c=o(yt),u=o(Ue),l=o(De),h=a(Ft),f=a(Gt),m=a(jt),y=a(Vt),v=a(zt);function w(t,r){const n=c(i,{...r,emptyFields:void 0!==t.f&&t.f>1,emptyVar:void 0!==t.v&&t.v>1}),s=(t,r,n)=>{if(t&&t.length>(r||0))throw new Ce(i,e,`${i.prim}: at most ${r||0} ${n} annotations allowed`)};return s(n.f,t.f,"field"),s(n.t,t.t,"type"),s(n.v,t.v,"variable"),n}function E(t,e){const r=t,n=Array.isArray(r)?{prim:"pair",args:r}:r,i=c(n),s=void 0!==e.v||void 0!==e.t||void 0!==e.f?[...(null===e.v?i.v:e.v)||[],...(null===e.t?i.t:e.t)||[],...(null===e.f?i.f:e.f)||[]]:void 0,{annots:o,...a}=n;return{...a,...s&&0!==s.length&&{annots:s}}}function _(t,e){const r=w({v:1});return E(t,{v:void 0!==r.v?r.v:void 0!==e?[e]:null,t:null})}function A(t,r,n,s,o){const a=c(r).f?.[0],u=n.f?.[s];if(void 0!==u&&"%"!==u&&void 0!==a&&u!==a)throw new Ce(i,e,`${i.prim}: field names doesn't match: ${u} !== ${a}`);const l=n.v?.[s],h=c(t).v?.[0];return E(r,{t:null,v:l?"@%"===l?a?["@"+a.slice(1)]:void 0:"@%%"===l?h?["@"+h.slice(1)+"."+(a?a.slice(1):o)]:a?["@"+a.slice(1)]:void 0:[l]:null})}function O(t,r,n=r){const s=Et("pair",t);if(1===n)return[s.args[0]];if(2===n)return s.args;const o=s.args[1];if(_t(o))return[s.args[0],...O(o,r,n-1)];throw new Ce(i,e,`${i.prim}: at least ${r} fields are expected`)}function S(t,r,n=r){if(0===n)return t;const s=Et("pair",t);if(1===n)return s.args[0];const o=s.args[1];if(_t(o))return S(o,r,n-2);if(2===n)return o;throw new Ce(i,e,`${i.prim}: at least ${r+1} fields are expected`)}function T(t,r,n,s=n){if(0===s)return r;const o=Et("pair",t);if(1===s)return{...o,args:[r,o.args[1]]};const a=o.args[1];if(_t(a))return{...o,args:[o.args[0],T(a,r,n,s-2)]};if(2===s)return{...o,args:[o.args[0],r]};throw new Ce(i,e,`${i.prim}: at least ${n+1} fields are expected`)}const P=(t,e)=>["@"+(t.v?t.v[0].slice(1)+".":"")+e];function R(t,e){return"failed"in t||"failed"in e?"failed"in t?e:t:(u(t,e),t)}const x=(t=>{switch(t.prim){case"DUP":{const r=t.args?parseInt(t.args[0].int,10):1;if(0===r)throw new Ce(t,e,"DUP 0 is forbidden");const n=s(r-1,null)[0];if("ticket"===Me(n))throw new Ce(t,e,"ticket can't be DUPed");return[n,...e]}case"SWAP":{const t=s(0,null,null);return w({}),[t[1],t[0],...e.slice(2)]}case"SOME":return[E({prim:"option",args:[s(0,null)[0]]},w({t:1,v:1})),...e.slice(1)];case"UNIT":return[E({prim:"unit"},w({v:1,t:1})),...e];case"PAIR":{const r=t.args?parseInt(t.args[0].int,10):2;if(r<2)throw new Ce(t,e,`PAIR ${r} is forbidden`);const n=s(0,...new Array(r).fill(null)),i=w({f:r,t:1,v:1},{specialFields:!0}),o=t=>{const e=t.lastIndexOf(".");return t.slice(e>0?e+1:1)},a=n.map((t,e)=>{const r=c(t);return E(t,{v:null,t:null,f:i.f&&i.f.length>e&&"%"!==i.f[e]?"%@"===i.f[e]?r.v?["%"+o(r.v?.[0]||"")]:void 0:[i.f[e]]:void 0})});return[E({prim:"pair",args:a},{t:i.t,v:i.v}),...e.slice(r)]}case"UNPAIR":{const r=t.args?parseInt(t.args[0].int,10):2;if(r<2)throw new Ce(t,e,`UNPAIR ${r} is forbidden`);const n=s(0,["pair"])[0],i=w({f:2,v:2},{specialVar:!0});return[...O(n,r).map((t,e)=>A(n,t,i,e,0===e?"car":"cdr")),...e.slice(1)]}case"CAR":case"CDR":{const r=Et("pair",s(0,["pair"])[0]);return[A(r,r.args["CAR"===t.prim?0:1],w({f:1,v:1},{specialVar:!0}),0,t.prim.toLocaleLowerCase()),...e.slice(1)]}case"CONS":{const t=s(0,null,["list"]);return l(t[0],t[1].args[0]),[_({prim:"list",args:[t[1].args[0]]}),...e.slice(2)]}case"SIZE":return s(0,["string","list","set","map","bytes"]),[_({prim:"nat"}),...e.slice(1)];case"MEM":{const t=s(0,null,["set","map","big_map"]);return h(t[0]),l(t[0],t[1].args[0]),[_({prim:"bool"}),...e.slice(2)]}case"GET":if(t.args){const r=parseInt(t.args[0].int,10);return[_(S(s(0,["pair"])[0],r)),...e.slice(1)]}{const t=s(0,null,["map","big_map"]);return h(t[0]),l(t[0],t[1].args[0]),[_({prim:"option",args:[t[1].args[1]]}),...e.slice(2)]}case"UPDATE":if(t.args){const r=parseInt(t.args[0].int,10),n=s(0,null,["pair"]);return[_(T(n[1],n[0],r)),...e.slice(2)]}{const t=s(0,null,["bool","option"]);if(h(t[0]),"bool"===t[1].prim){const r=s(2,["set"]);return l(t[0],r[0].args[0]),[_({prim:"set",args:[E(t[0],{t:null})]}),...e.slice(3)]}const r=s(2,["map","big_map"]);return l(t[0],r[0].args[0]),"map"===r[0].prim?[_({prim:"map",args:[E(t[0],{t:null}),E(t[1].args[0],{t:null})]}),...e.slice(3)]:(v(t[1].args[0]),[_({prim:"big_map",args:[E(t[0],{t:null}),E(t[1].args[0],{t:null})]}),...e.slice(3)])}case"GET_AND_UPDATE":{const t=w({v:2}),r=s(0,null,["option"],["map","big_map"]);h(r[0]),l(r[0],r[2].args[0]),l(r[1].args[0],r[2].args[1]);const n=t.v?.map(t=>"@"!==t?[t]:void 0);return"map"===r[2].prim?[E({prim:"option",args:[r[2].args[1]]},{v:n?.[0]}),E({prim:"map",args:[E(r[0],{t:null}),E(r[1].args[0],{t:null})]},{v:n?.[1]}),...e.slice(3)]:(v(r[1].args[0]),[E({prim:"option",args:[r[2].args[1]]},{v:n?.[0]}),E({prim:"big_map",args:[E(r[0],{t:null}),E(r[1].args[0],{t:null})]},{v:n?.[1]}),...e.slice(3)])}case"EXEC":{const t=s(0,null,["lambda"]);return l(t[0],t[1].args[0]),[_(t[1].args[1]),...e.slice(2)]}case"APPLY":{const r=s(0,null,["lambda"]);if(m(r[0]),y(r[0]),!_t(r[1].args[0]))throw new Ce(t,e,`${t.prim}: function's argument must be a pair: ${Me(r[1].args[0])}`);const n=r[1].args[0];return l(r[0],Be(n)[0]),[_({prim:"lambda",args:[Be(n)[1],r[1].args[1]]}),...e.slice(2)]}case"FAILWITH":{const t=s(0,null)[0];return b(n,p.PtEdo2Zk)||f(t),{failed:t,level:0}}case"NEVER":return s(0,["never"]),{failed:{prim:"never"},level:0};case"RENAME":return[_(s(0,null)[0]),...e.slice(1)];case"CONCAT":{const r=s(0,["string","list","bytes"]);if("list"===r[0].prim){if("string"!==Me(r[0].args[0])&&"bytes"!==Me(r[0].args[0]))throw new Ce(t,e,`${t.prim}: can't concatenate list of ${Me(r[0].args[0])}'s`);return[_(r[0].args[0]),...e.slice(1)]}const n=s(1,["string","bytes"]);if(r[0].prim!==n[0].prim)throw new Ce(t,e,`${t.prim}: can't concatenate ${r[0].prim} with ${n[0].prim}`);return[_(n[0]),...e.slice(2)]}case"SLICE":return[_({prim:"option",args:[s(0,["nat"],["nat"],["string","bytes"])[2]]},"@slice"),...e.slice(3)];case"PACK":{const t=s(0,null)[0];return f(t),[_({prim:"bytes"},"@packed"),...e.slice(1)]}case"ADD":{const r=s(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"===r[0].prim&&"int"===r[1].prim||"int"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("int"===r[0].prim&&"timestamp"===r[1].prim||"timestamp"===r[0].prim&&"int"===r[1].prim)return[_({prim:"timestamp"}),...e.slice(2)];if(("int"===r[0].prim||"nat"===r[0].prim||"mutez"===r[0].prim||"bls12_381_g1"===r[0].prim||"bls12_381_g2"===r[0].prim||"bls12_381_fr"===r[0].prim)&&r[0].prim===r[1].prim)return[_(r[0]),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't add ${r[0].prim} to ${r[1].prim}`)}case"SUB":{const r=b(n,p.PsiThaCa)?s(0,["nat","int","timestamp","mutez"],["nat","int","timestamp","mutez"]):s(0,["nat","int","timestamp"],["nat","int","timestamp"]);if(("nat"===r[0].prim||"int"===r[0].prim)&&("nat"===r[1].prim||"int"===r[1].prim)||"timestamp"===r[0].prim&&"timestamp"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("timestamp"===r[0].prim&&"int"===r[1].prim)return[_({prim:"timestamp"}),...e.slice(2)];if("mutez"===r[0].prim&&"mutez"===r[1].prim)return[_({prim:"mutez"}),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't subtract ${r[0].prim} from ${r[1].prim}`)}case"SUB_MUTEZ":return s(0,["mutez"],["mutez"]),[_({prim:"option",args:[{prim:"mutez"}]}),...e.slice(2)];case"MUL":{const r=s(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"===r[0].prim&&"int"===r[1].prim||"int"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("nat"===r[0].prim&&"mutez"===r[1].prim||"mutez"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"mutez"}),...e.slice(2)];if(("bls12_381_g1"===r[0].prim||"bls12_381_g2"===r[0].prim||"bls12_381_fr"===r[0].prim)&&"bls12_381_fr"===r[1].prim||("nat"===r[0].prim||"int"===r[0].prim)&&r[0].prim===r[1].prim)return[_(r[0]),...e.slice(2)];if(("nat"===r[0].prim||"int"===r[0].prim)&&"bls12_381_fr"===r[1].prim||("nat"===r[1].prim||"int"===r[1].prim)&&"bls12_381_fr"===r[0].prim)return[_({prim:"bls12_381_fr"}),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't multiply ${r[0].prim} by ${r[1].prim}`)}case"EDIV":{const r=(t,e)=>({prim:"option",args:[{prim:"pair",args:[{prim:t},{prim:e}]}]}),n=s(0,["nat","int","mutez"],["nat","int","mutez"]);if("nat"===n[0].prim&&"nat"===n[1].prim)return[_(r("nat","nat")),...e.slice(2)];if(!("nat"!==n[0].prim&&"int"!==n[0].prim||"nat"!==n[1].prim&&"int"!==n[1].prim))return[_(r("int","nat")),...e.slice(2)];if("mutez"===n[0].prim&&"nat"===n[1].prim)return[_(r("mutez","mutez")),...e.slice(2)];if("mutez"===n[0].prim&&"mutez"===n[1].prim)return[_(r("nat","mutez")),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't euclideally divide ${n[0].prim} by ${n[1].prim}`)}case"ABS":return s(0,["int"]),[_({prim:"nat"}),...e.slice(1)];case"ISNAT":return s(0,["int"]),[_({prim:"option",args:[{prim:"nat"}]}),...e.slice(1)];case"INT":return s(0,["nat","bls12_381_fr","bytes"]),[_({prim:"int"}),...e.slice(1)];case"BYTES":return s(0,["nat","int"]),[_({prim:"bytes"}),...e.slice(1)];case"NAT":return s(0,["bytes"]),[_({prim:"nat"}),...e.slice(1)];case"NEG":{const t=s(0,["nat","int","bls12_381_g1","bls12_381_g2","bls12_381_fr"])[0];return"nat"===t.prim||"int"===t.prim?[_({prim:"int"}),...e.slice(1)]:[_(t),...e.slice(1)]}case"LSL":case"LSR":return s(0,["nat","bytes"],["nat","bytes"]),[_({prim:"nat"}),...e.slice(2)];case"OR":case"XOR":{const r=s(0,["nat","bytes","bool"],["nat","bytes","bool"]);if(r[0].prim!==r[1].prim)throw new Ce(t,e,`${t.prim}: both arguments must be of the same type: ${r[0].prim}, ${r[1].prim}`);return[_(r[1]),...e.slice(2)]}case"AND":{const r=s(0,["nat","bytes","bool","int"],["nat","bytes","bool"]);if(("int"!==r[0].prim||"nat"!==r[1].prim)&&r[0].prim!==r[1].prim)throw new Ce(t,e,`${t.prim}: both arguments must be of the same type: ${r[0].prim}, ${r[1].prim}`);return[_(r[1]),...e.slice(2)]}case"NOT":return"bool"===s(0,["nat","bytes","bool","int"])[0].prim?[_({prim:"bool"}),...e.slice(1)]:[_({prim:"int"}),...e.slice(1)];case"COMPARE":{const t=s(0,null,null);return h(t[0]),h(t[1]),[_({prim:"int"}),...e.slice(2)]}case"EQ":case"NEQ":case"LT":case"GT":case"LE":case"GE":return s(0,["int"]),[_({prim:"bool"}),...e.slice(1)];case"SELF":{if(void 0===r?.contract)throw new Ce(t,e,`${t.prim}: contract required`);const n=w({f:1,v:1}),i=ze(r.contract,n.f?.[0]);if(null===i)throw new Ce(t,e,`${t.prim}: contract has no entrypoint ${i}`);return[E({prim:"contract",args:[i]},{v:n.v?n.v:["@self"]}),...e]}case"TRANSFER_TOKENS":{const t=s(0,null,["mutez"],["contract"]);return l(t[0],t[2].args[0]),[_({prim:"operation"}),...e.slice(3)]}case"SET_DELEGATE":{const r=s(0,["option"])[0];if("key_hash"!==Me(r.args[0]))throw new Ce(t,e,`${t.prim}: key hash expected: ${Me(r.args[0])}`);return[_({prim:"operation"}),...e.slice(1)]}case"IMPLICIT_ACCOUNT":return s(0,["key_hash"]),[_({prim:"contract",args:[{prim:"unit"}]}),...e.slice(1)];case"NOW":return[_({prim:"timestamp"},"@now"),...e];case"AMOUNT":return[_({prim:"mutez"},"@amount"),...e];case"BALANCE":return[_({prim:"mutez"},"@balance"),...e];case"CHECK_SIGNATURE":return s(0,["key"],["signature"],["bytes"]),[_({prim:"bool"}),...e.slice(3)];case"BLAKE2B":case"SHA256":case"SHA512":case"KECCAK":case"SHA3":return s(0,["bytes"]),[_({prim:"bytes"}),...e.slice(1)];case"HASH_KEY":return s(0,["key"]),[_({prim:"key_hash"}),...e.slice(1)];case"SOURCE":return[_({prim:"address"},"@source"),...e];case"SENDER":return[_({prim:"address"},"@sender"),...e];case"ADDRESS":{const t=s(0,["contract"])[0],r=w({v:1});return[E({prim:"address",[d]:t},{v:r.v?r.v:P(c(t),"address")}),...e.slice(1)]}case"SELF_ADDRESS":{const t={prim:"address"};return void 0!==r?.contract&&(t[d]={prim:"contract",args:[Ve(r.contract,"parameter").args[0]]}),[_(t,"@address"),...e]}case"CHAIN_ID":return[_({prim:"chain_id"}),...e];case"DROP":{w({});const r=void 0!==t.args?parseInt(t.args[0].int,10):1;return s(r-1,null),e.slice(r)}case"DIG":{w({});const r=parseInt(t.args[0].int,10);return[s(r,null)[0],...e.slice(0,r),...e.slice(r+1)]}case"DUG":{w({});const r=parseInt(t.args[0].int,10);return[...e.slice(1,r+1),s(0,null)[0],...e.slice(r+1)]}case"NONE":return Ke(t.args[0]),[E({prim:"option",args:[t.args[0]]},w({t:1,v:1})),...e];case"LEFT":case"RIGHT":{const r=s(0,null)[0],n=w({f:2,t:1,v:1},{specialFields:!0}),i=c(r),o=[E(r,{t:null,v:null,f:n.f&&n.f.length>0&&"%"!==n.f[0]?"%@"===n.f[0]?i.v?["%"+i.v[0].slice(1)]:void 0:n.f:void 0}),E(t.args[0],{t:null,f:n.f&&n.f.length>1&&"%"!==n.f[1]?n.f:void 0})];return[E({prim:"or",args:"LEFT"===t.prim?o:[o[1],o[0]]},{t:n.t,v:n.v}),...e.slice(1)]}case"NIL":return Ke(t.args[0]),[E({prim:"list",args:[t.args[0]]},w({t:1,v:1})),...e];case"UNPACK":return s(0,["bytes"]),Ke(t.args[0]),[_({prim:"option",args:[t.args[0]]},"@unpacked"),...e.slice(1)];case"CONTRACT":{const r=s(0,["address"])[0];Ke(t.args[0]);const n=w({v:1,f:1}),i=r[d];if(void 0!==i){const r=ze(i,n.f?.[0]);if(null===r)throw new Ce(t,e,`${t.prim}: contract has no entrypoint ${r}`);l(r,t.args[0])}return[E({prim:"option",args:[{prim:"contract",args:[t.args[0]]}]},{v:n.v?n.v:P(c(r),"contract")}),...e.slice(1)]}case"CAST":{w({});const r=s(0,null)[0];return Ke(t.args[0]),l(t.args[0],r),[t.args[0],...e.slice(1)]}case"IF_NONE":{w({});const n=s(0,["option"])[0],i=e.slice(1);return R(Ge(t.args[0],i,r),Ge(t.args[1],[E(n.args[0],{t:null,v:P(c(n),"some")}),...i],r))}case"IF_LEFT":{w({});const n=s(0,["or"])[0],i=c(n),o=c(n.args[0]),a=c(n.args[1]),u=e.slice(1);return R(Ge(t.args[0],[E(n.args[0],{t:null,v:P(i,o.f?o.f[0].slice(1):"left")}),...u],r),Ge(t.args[1],[E(n.args[1],{t:null,v:P(i,a.f?a.f[0].slice(1):"right")}),...u],r))}case"IF_CONS":{w({});const n=s(0,["list"])[0],i=c(n),o=e.slice(1);return R(Ge(t.args[0],[E(n.args[0],{t:null,v:P(i,"hd")}),E(n,{t:null,v:P(i,"tl")}),...o],r),Ge(t.args[1],o,r))}case"IF":{w({}),s(0,["bool"]);const n=e.slice(1);return R(Ge(t.args[0],n,r),Ge(t.args[1],n,r))}case"MAP":{const n=s(0,["list","map","option"])[0],i=e.slice(1),o="map"===n.prim?{prim:"pair",args:n.args}:n.args[0],a=Ge(t.args[0],[E(o,{t:null,v:P(c(n),"elt")}),...i],r);if("failed"in a){if(!("prim"in a.failed)||"never"!==a.failed.prim)throw new Ce(t,e,`${t.prim}: FAIL is not allowed in MAP`);return{failed:a.failed,level:a.level+1}}if(a.length<1)throw new Ce(t,e,`${t.prim}: function must return a value`);return u(a.slice(1),i),"list"===n.prim?[_({prim:"list",args:[a[0]]}),...i]:"map"===n.prim?[_({prim:"map",args:[n.args[0],a[0]]}),...i]:[_({prim:"option",args:[a[0]]}),...i]}case"ITER":{w({});const n=s(0,["set","list","map"])[0],i=e.slice(1),o="map"===n.prim?{prim:"pair",args:n.args}:n.args[0],a=Ge(t.args[0],[E(o,{t:null,v:P(c(n),"elt")}),...i],r);return"failed"in a?{failed:a.failed,level:a.level+1}:(u(a,i),i)}case"LOOP":{w({}),s(0,["bool"]);const n=e.slice(1),i=Ge(t.args[0],n,r);return"failed"in i?{failed:i.failed,level:i.level+1}:(u(i,[{prim:"bool"},...n]),n)}case"LOOP_LEFT":{w({});const n=s(0,["or"])[0],i=e.slice(1),o=Ge(t.args[0],[E(n.args[0],{t:null,v:P(c(n),"left")}),...i],r);return"failed"in o?{failed:o.failed,level:o.level+1}:(u(o,[n,...i]),[E(n.args[1],{t:null,v:w({v:1}).v}),...i])}case"DIP":{w({});const n=2===t.args.length?parseInt(t.args[0].int,10):1;s(n-1,null);const i=e.slice(0,n),o=e.slice(n),a=2===t.args.length?Ge(t.args[1],o,r):Ge(t.args[0],o,r);return"failed"in a?{failed:a.failed,level:a.level+1}:[...i,...a]}case"CREATE_CONTRACT":{const r=w({v:2}),n=s(0,["option"],["mutez"],null);if("key_hash"!==Me(n[0].args[0]))throw new Ce(t,e,`${t.prim}: key hash expected: ${Me(n[0].args[0])}`);m(n[2])&&(We(t.args[0]),De(Ve(t.args[0],"storage").args[0],n[2]));const i=r.v?.map(t=>"@"!==t?[t]:void 0);return[E({prim:"operation"},{v:i?.[0]}),E({prim:"address",[d]:{prim:"contract",args:[Ve(t.args[0],"parameter").args[0]]}},{v:i?.[1]}),...e.slice(3)]}case"PUSH":return Ke(t.args[0]),Fe(t.args[1],t.args[0],{...r,contract:void 0}),[_(t.args[0]),...e];case"EMPTY_SET":return Ke(t.args[0]),h(t.args[0]),[E({prim:"set",args:t.args},w({t:1,v:1})),...e];case"EMPTY_MAP":return Ke(t.args[0]),h(t.args[0]),Ke(t.args[1]),[E({prim:"map",args:t.args},w({t:1,v:1})),...e];case"EMPTY_BIG_MAP":return Ke(t.args[0]),h(t.args[0]),Ke(t.args[1]),v(t.args[0]),[E({prim:"big_map",args:t.args},w({t:1,v:1})),...e];case"LAMBDA_REC":case"LAMBDA":{Ke(t.args[0]),Ke(t.args[1]);const n=[t.args[0]];"LAMBDA_REC"===t.prim&&n.push({prim:"lambda",args:[t.args[0],t.args[1]]});const i=Ge(t.args[2],n,{...r,contract:void 0});if("failed"in i)return{failed:i.failed,level:i.level+1};if(1!==i.length)throw new Ce(t,e,`${t.prim}: function must return a value`);return l(t.args[1],i[0]),[_({prim:"lambda",args:[t.args[0],t.args[1]]}),...e]}case"LEVEL":return[_({prim:"nat"},"@level"),...e];case"TOTAL_VOTING_POWER":case"MIN_BLOCK_TIME":return[_({prim:"nat"}),...e];case"VOTING_POWER":return s(0,["key_hash"]),[_({prim:"nat"}),...e.slice(1)];case"TICKET":{const t=s(0,null,["nat"])[0];return h(t),b(n,p.PtLimaPtL)?[E({prim:"ticket",args:[t]},w({t:1,v:1})),...e.slice(2)]:[_({prim:"option",args:[E({prim:"ticket",args:[t]},w({t:1,v:1}))]}),...e.slice(2)]}case"JOIN_TICKETS":{const r=Et("pair",s(0,["pair"])[0]);if("ticket"!==Me(r.args[0]))throw new Ce(t,e,`${t.prim}: ticket expected: ${Me(r.args[0])}`);return l(r.args[0],r.args[1]),[_({prim:"option",args:[E(r.args[0],{t:null})]}),...e.slice(1)]}case"SPLIT_TICKET":{const r=s(0,["ticket"],["pair"]),n=Et("pair",r[1]);if("nat"!==Me(n.args[0]))throw new Ce(t,e,`${t.prim}: nat expected: ${Me(n.args[0])}`);return l(n.args[0],n.args[1]),[_({prim:"option",args:[{prim:"pair",args:[E(r[0],{t:null}),E(r[0],{t:null})]}]}),...e.slice(2)]}case"READ_TICKET":{const t=w({v:2}),r=s(0,["ticket"])[0],n=t.v?.map(t=>"@"!==t?[t]:void 0);return[E({prim:"pair",args:[{prim:"address"},E(r.args[0],{t:null}),{prim:"nat"}]},{v:n?.[0]}),E(r,{v:n?.[1],t:null}),...e.slice(1)]}case"PAIRING_CHECK":{const r=s(0,["list"])[0].args[0];if(!_t(r))throw new Ce(t,e,`${t.prim}: pair expected: ${Me(r)}`);const n=Et("pair",r);if("bls12_381_g1"!==Me(n.args[0]))throw new Ce(t,e,`${t.prim}: bls12_381_g1 expected: ${Me(n.args[0])}`);if("bls12_381_g2"!==Me(n.args[1]))throw new Ce(t,e,`${t.prim}: bls12_381_g2 expected: ${Me(n.args[1])}`);return[_({prim:"bool"}),...e.slice(1)]}case"SAPLING_EMPTY_STATE":return[E({prim:"sapling_state",args:[t.args[0]]},w({v:1,t:1})),...e];case"SAPLING_VERIFY_UPDATE":{const r=s(0,["sapling_transaction"],["sapling_state"]);if(parseInt(r[0].args[0].int,10)!==parseInt(r[1].args[0].int,10))throw new Ce(t,e,`${t.prim}: sapling memo size mismatch: ${r[0].args[0].int} != ${r[1].args[0].int}`);return b(n,p.PtJakarta)?[_({prim:"option",args:[{prim:"pair",args:[{prim:"int"},E(r[1],{t:null})]}]}),...e.slice(2)]:[_({prim:"option",args:[{prim:"pair",args:[{prim:"bytes"},{prim:"pair",args:[{prim:"int"},E(r[1],{t:null})]}]}]}),...e.slice(2)]}case"OPEN_CHEST":return s(0,["chest_key"],["chest"],["nat"]),[_({prim:"or",args:[{prim:"bytes"},{prim:"bool"}]}),...e.slice(3)];case"VIEW":{const r=s(0,null,["address"]);return y(r[0]),[_({prim:"option",args:[t.args[1]]}),...e.slice(2)]}case"EMIT":{const r=w({f:1,t:1});if(t.args){const n=s(0,null);return l(n[0],t.args[0]),[E({prim:"operation"},r),...e.slice(1)]}return[E({prim:"operation"},r),...e.slice(1)]}case"IS_IMPLICIT_ACCOUNT":return s(0,["address"]),[_({prim:"option",args:[{prim:"key_hash"}]}),...e.slice(1)];case"INDEX_ADDRESS":return s(0,["address"]),[_({prim:"nat"}),...e.slice(1)];case"GET_ADDRESS_INDEX":return s(0,["address"]),[_({prim:"option",args:[{prim:"nat"}]}),...e.slice(1)];default:throw new ut(t,`unexpected instruction: ${t.prim}`)}})(i);if(void 0!==r?.traceCallback){const t={op:i,in:e,out:x};r.traceCallback(t)}return x}function Ve(t,e){for(const r of t)if(r.prim===e)return r;throw new ut(t,`missing contract section: ${e}`)}function je(t){const e={};for(const r of t)"view"===r.prim&&(e[r.args[0].string]=r);return e}function $e(t){if(Array.isArray(t))for(const e of t)if("prim"in e&&("parameter"===e.prim||"storage"===e.prim||"code"===e.prim))return!0;return!1}function ze(t,e){e=e||"%default";const r=qe(t).find(t=>t[0]===e);return void 0!==r?r[1]:"%default"===e?$e(t)?Ve(t,"parameter").args[0]:t:null}function qe(t){if($e(t)){const e=Ve(t,"parameter"),r=qe(e.args[0]),n=yt(e);return n.f?[[n.f[0],e.args[0]],...r]:r}if(e=t,Array.isArray(e)||"or"===e.prim){const e=Be(t),r=t=>{const r=yt(e[t]);if("or"===Me(e[t])){const n=qe(e[t]);return r.f?[[r.f[0],e[t]],...n]:n}return r.f?[[r.f[0],e[t]]]:[]};return[...r(0),...r(1)]}var e;return[]}function We(t,e){const r=(r,n,i,s)=>{Ke(r,!0),Ke(n);const o=Ge(s,[{prim:"pair",args:[{...r,annots:["@parameter"]},{...n,annots:["@storage"]}]}],{...e,contract:t});if("failed"in o)return o;try{Ue(o,[i])}catch(t){throw t instanceof ut?new Ce(s,o,t.message):t}return o},n=Ve(t,"parameter").args[0],i=Ve(t,"storage").args[0],s=r(n,i,{prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},i]},Ve(t,"code").args[0]);for(const e of Object.values(je(t)))r(e.args[1],i,e.args[2],e.args[3]);return s}function Ze(t,e,r){Ke(e),Fe(t,e,r||null)}function Ye(t,e,r){for(const t of e)Ke(t);if(void 0!==r?.contract)for(const t of["parameter","storage"]){Ke(Ve(r.contract,t).args[0])}return Ge(t,e,r||null)}function Xe(t,e,r=!1){if(Array.isArray(t)){for(const e of t)Ke(e);for(const t of e)Ke(t)}else Ke(t),Ke(e);De(t,e,r)}function Je(t,e=!1){try{return Ke(t,e),!0}catch{return!1}}function Qe(t,e){try{return We(t,e)}catch{return null}}function tr(t,e,r){try{return Ze(t,e,r),!0}catch{return!1}}function er(t,e,r=!1){try{return Xe(t,e,r),!0}catch{return!1}}class rr{constructor(t,e){this.contract=t,this.ctx={contract:t,...e},this.output=We(t,this.ctx)}static parse(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new rt("empty Michelson");if(Jt(n))return new rr(n,e)}static parseTypeExpression(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new nt("empty type expression");if(Zt(n))return Ke(n),n}static parseDataExpression(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new it("empty data expression");if(Xt(n))return n;throw void 0}section(t){return Ve(this.contract,t)}entryPoints(){return qe(this.contract)}entryPoint(t){return ze(this.contract,t)}assertDataValid(t,e){Ze(t,e,this.ctx)}isDataValid(t,e){return tr(t,e,this.ctx)}assertParameterValid(t,e){const r=this.entryPoint(t||void 0);if(null===r)throw new st(t?.toString());this.assertDataValid(e,r)}isParameterValid(t,e){try{return this.assertParameterValid(t,e),!0}catch{return!1}}functionType(t,e){return Ye(t,e,this.ctx)}}const nr=new rr([{prim:"parameter",args:[{prim:"unit"}]},{prim:"storage",args:[{prim:"unit"}]},{prim:"code",args:[[{prim:"CAR"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PAIR"}]]}]);function ir(t){return"failed"in t?`[FAILED: ${z(t.failed)}]`:t.map((t,e)=>{const r=yt(t);return`[${e}${r.v?"/"+r.v[0]:""}]: ${z(t)}`}).join("\n")}function sr(t,e){return r=>{if(Array.isArray(r)&&!t)return;const n=r.op[i]?.macro,s=`${n?"Macro":"Op"}: ${n?z(n,void 0,!0)+" / ":""}${z(r.op)}\nInput:\n${ir(r.in)}\nOutput:\n${ir(r.out)}\n`;e(s)}}function or(t){if(t instanceof Ce){const e=t.val[i]?.macro;return`${e?"Macro":"Op"}: ${e?z(e,void 0,!0)+" / ":""}${z(t.val)}\nStack:\n${ir(t.stackState)}\n`}if(t instanceof ht){return`Type: ${Array.isArray(t.val)?"["+t.val.map((t,e)=>`[${e}]: ${z(t)}`).join("; ")+"]":z(t.val)}\n${t.data?`Data: ${z(t.data)}\n`:""}\n`}return`Value: ${z(t.val)}`}const ar={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"}},5602(t,e,r){"use strict";r.r(e),r.d(e,{AddressValidationError:()=>z,BigMapEncodingError:()=>ae,BigMapValidationError:()=>M,BytesValidationError:()=>nt,ChainIDValidationError:()=>_t,ContractValidationError:()=>X,EncodeTicketError:()=>Ot,EventSchema:()=>ye,IntValidationError:()=>at,InvalidBigMapDiffError:()=>oe,InvalidBigMapSchemaError:()=>se,InvalidMapTypeError:()=>R,InvalidRpcResponseError:()=>ie,InvalidScriptError:()=>ne,KeyHashValidationError:()=>pt,KeyValidationError:()=>ft,ListValidationError:()=>Q,MapTypecheckError:()=>I,MapValidationError:()=>W,MichelsonMap:()=>N,MissingArgumentError:()=>ue,MutezValidationError:()=>et,NatValidationError:()=>V,OrValidationError:()=>D,ParameterEncodingError:()=>re,ParameterSchema:()=>ge,SaplingStateValue:()=>lt,Schema:()=>pe,SetValidationError:()=>wt,SignatureValidationError:()=>mt,StorageEncodingError:()=>ce,Token:()=>L,TokenArgumentValidationError:()=>K,TokenComparisonError:()=>H,UnitValue:()=>ut,VERSION:()=>be,ViewSchema:()=>me,deepEqual:()=>de});var n=r(6075),i=r.n(n),s=r(6571),o=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},o=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,o,c,u,h,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,u=t;u>=10;u/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!a.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(l+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(u=d.search(/e/i))>0?(c<0&&(c=u),c+=+d.slice(u+1),d=d.substring(0,u)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(l+"String expected: "+t);for(w(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=u=0,h=d.length;u<h;u++)if(r.indexOf(s=d.charAt(u))<0){if("."==s){if(u>c){c=h;continue}}else if(!o&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){o=!0,u=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(u=0;48===d.charCodeAt(u);u++);for(h=d.length;48===d.charCodeAt(--h););if(d=d.slice(u,++h))if(h-=u,(c=c-u-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],u=(c+1)%f,c<0&&(u+=f),u<h){for(u&&g.c.push(+d.slice(0,u)),h-=f;u<h;)g.c.push(+d.slice(u,u+=f));u=f-(d=d.slice(u)).length}else u-=h;for(;u--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:w(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=b(t.c),c=1==n||2==n&&(o<=T||o>=P)?_(c,o):A(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=b(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=_(c,s)}else if(e-=o+(2===n&&s>o),c=A(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=v(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*f-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,a,l,d,g,m=t.c,y=p;if(m){t:{for(i=1,a=m[0];a>=10;a/=10,i++);if((s=e-i)<0)s+=f,o=e,l=m[d=0],g=u(l/y[i-o-1]%10);else if((d=c((s+1)/f))>=m.length){if(!n)break t;for(;m.length<=d;m.push(0));l=g=0,i=1,o=(s%=f)-f+1}else{for(l=a=m[d],i=1;a>=10;a/=10,i++);g=(o=(s%=f)-f+i)<0?0:u(l/y[i-o-1]%10)}if(n=n||e<0||null!=m[d+1]||(o<0?l:l%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?l/y[i-o]:0:m[d-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(f-e%f)%f],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=d,a=1,d--):(m.length=d+1,a=y[f-s],m[d]=o>0?u(l/y[i-o]%y[o])*a:0),n)for(;;){if(0==d){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=a,a=1;o>=10;o/=10,a++);s!=a&&(t.e++,m[0]==h&&(m[0]=1));break}if(m[d]+=a,m[d]!=h)break;m[d--]=0,a=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=b(t.c),e=r<=T||r>=P?_(e,r):A(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(l+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(w(r=t[e],0,m,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(w(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(w(r[0],-m,0,e),w(r[1],0,m,e),T=r[0],P=r[1]):(w(r,-m,m,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)w(r[0],-m,-1,e),w(r[1],1,m,e),R=r[0],x=r[1];else{if(w(r,-m,m,e),!r)throw Error(l+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(l+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(l+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(w(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(w(r=t[e],0,m,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(l+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(l+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-m||i>m||i!==u(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%f)<1&&(e+=f),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==u(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return u(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,a,h=0,d=[],g=new M(o);if(null==t?t=O:w(t,0,m),s=c(t/f),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));h<s;)(a=131072*r[h]+(r[h+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[h]=n[0],r[h+1]=n[1]):(d.push(a%1e14),h+=2);h=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(l+"crypto unavailable");for(r=crypto.randomBytes(s*=7);h<s;)(a=281474976710656*(31&r[h])+1099511627776*r[h+1]+4294967296*r[h+2]+16777216*r[h+3]+(r[h+4]<<16)+(r[h+5]<<8)+r[h+6])>=9e15?crypto.randomBytes(7).copy(r,h):(d.push(a%1e14),h+=7);h=s/7}if(!I)for(;h<s;)(a=e())<9e15&&(d[h++]=a%1e14);for(s=d[--h],t%=f,s&&t&&(a=p[f-t],d[h]=u(s/a)*a);0===d[h];d.pop(),h--);if(h<0)d=[i=0];else{for(i=-1;0===d[0];d.splice(0,1),i-=f);for(h=1,a=d[0];a>=10;a/=10,h++);h<f&&(i-=f-h)}return g.e=i,g.c=d,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),y=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(A(b(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,y,v,s)).c,f=d.r,l=d.e),m=p[u=l+y+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?A(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=A(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%g,l=e/g|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%g)+(n=l*s+(o=t[c]/g|0)*u)%g*g+a)/r|0)+(n/g|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var c,l,d,p,g,m,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(l=n.e-i.e)+1,a||(a=h,l=y(n.e/f)-y(i.e/f),x=x/f|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&l--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=u(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(c=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=u(A/T))>1)for(g>=a&&(g=a-1),b=(m=t(N,g,a)).length,_=E.length;1==e(m,E,b,_);)g--,r(m,P<b?R:N,b,a),b=m.length,c=1;else 0==g&&(c=g=1),b=(m=N.slice()).length;if(b<_&&(m=[0].concat(m)),r(E,m,_,a),_=E.length,-1==c)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===c&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==h){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+l*f-1)+1,o,p)}else v.e=l,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,u=o.replace(i,"");if(n.test(u))return s.s=isNaN(u)?null:u<0?-1:1,void(s.c=s.e=null);if(u=u.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,u=u.replace(e,"$1").replace(r,"0.$1")),o!=u)return new M(u,c);throw Error(l+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return v(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return w(t,0,m),null==e?e=S:w(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-y(this.e/f))*f,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,a,h,d,p,g=this;if((t=new M(t)).c&&!t.isInteger())throw Error(l+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),a=t.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!t.c||!t.c[0])return p=new M(Math.pow(+F(g),a?t.s*(2-E(t)):+F(t))),e?p.mod(e):p;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&g.isInteger()&&e.isInteger())&&(g=g.mod(e))}else{if(t.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||a&&g.c[1]>=24e7:g.c[0]<8e13||a&&g.c[0]<=9999975e7)))return s=g.s<0&&E(t)?-0:0,g.e>-1&&(s=1/s),new M(h?1/s:s);k&&(s=c(k/f+2))}for(a?(r=new M(.5),h&&(t.s=1),d=E(t)):d=(i=Math.abs(+F(t)))%2,p=new M(o);;){if(d){if(!(p=p.times(g)).c)break;s?p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}if(i){if(0===(i=u(i/2)))break;d=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)d=E(t);else{if(0===(i=+F(t)))break;d=i%2}g=g.times(g),s?g.c&&g.c.length>s&&(g.c.length=s):n&&(g=g.mod(e))}return n?p:(h&&(p=o.div(p)),e?p.mod(e):s?H(p,k,S,void 0):p)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:w(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===v(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return v(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=v(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&y(this.e/f)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return v(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=v(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/f,u=t.e/f,l=o.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new M(d?o:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new M(l[0]?o:3==S?-0:0)}if(c=y(c),u=y(u),l=l.slice(),a=c-u){for((s=a<0)?(a=-a,i=l):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=l.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(l[e]!=d[e]){s=l[e]<d[e];break}if(s&&(i=l,l=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>a;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?K(t,l,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,l,d,p,m,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=y(E.e/f)+y(t.e/f),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=h,w=g,i=d;--i>=0;){for(r=0,p=A[i]%w,m=A[i]/w|0,s=i+(o=c);s>i;)r=((u=p*(u=_[--o]%w)+(a=m*u+(l=_[o]/w|0)*p)%w*w+b[s]+r)/v|0)+(a/w|0)+m*l,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/f,o=t.e/f,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=y(s),o=y(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/h|0,a[e]=h===a[e]?0:a[e]%h;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return w(t,1,m),null==e?e=S:w(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*f+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return w(t,-9007199254740991,d),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=b(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=y((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),b(s.c).slice(0,c)===(e=b(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(w(t,0,m),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(w(t,0,m),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(l+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,u=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=u+p.substr(s,a);c>0&&(h+=u+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,a,c,u,h,d,g,m,y,v=this,w=v.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(o)))throw Error(l+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+F(u));if(!w)return new M(v);for(e=new M(o),d=n=new M(o),i=h=new M(o),y=b(w),a=e.e=y.length-v.e-1,e.c[0]=p[(c=a%f)<0?f+c:c],t=!t||u.comparedTo(e)>0?a>0?e:d:u,c=x,x=1/0,u=new M(y),h.c[0]=0;g=r(u,e,0,1),1!=(s=n.plus(g.times(i))).comparedTo(t);)n=i,i=s,d=h.plus(g.times(s=d)),h=s,e=u.minus(g.times(s=e)),u=s;return s=r(t.minus(n),i,0,1),h=h.plus(s.times(d)),n=n.plus(s.times(i)),h.s=d.s=v.s,m=r(d,i,a*=2,S).minus(v).abs().comparedTo(r(h,n,a,S).minus(v).abs())<1?[d,i]:[h,n],x=c,m},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&w(t,1,m),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?_(b(r.c),s):A(b(r.c),s,"0"):(w(t,2,C.length,"Base"),e=n(A(b(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,c=Math.ceil,u=Math.floor,l="[BigNumber Error] ",h=1e14,f=14,d=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,m=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function b(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function v(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function w(t,e,r,n){if(t<e||t>r||t!==u(t))throw Error(l+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function E(t){var e=t.c.length-1;return y(t.e/f)==e&&t.c[e]%2!=0}function _(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function A(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const O=o;var S,T=r(2403),P=r(8691);class R extends s.TaquitoError{constructor(t,e){super(),this.mapType=t,this.reason=e,this.message=`The map type '${JSON.stringify(t)}' is invalid. Reason: ${e}.`,this.name="InvalidMapTypeError"}}const x=Symbol.for("taquito-michelson-map-type-symbol");class I extends s.TaquitoError{constructor(t,e,r,n){super(),this.value=t,this.type=e,this.reason=n,this.name="MapTypecheckError",this.message=`The ${r} provided: ${JSON.stringify(t)} is not compatible with the expected michelson type: ${JSON.stringify(e)}. Reason: ${JSON.stringify(n)}.`,this.name="MapTypecheckError"}}class N{static isMichelsonMap(t){return t&&!0===t[x]}constructor(t){this.valueMap=new Map,this.keyMap=new Map,this[S]=!0,t&&this.setType(t)}setType(t){!function(t){if(!("prim"in t))throw new R(t,"Missing 'prim' field");if(!["map","big_map"].includes(t.prim))throw new R(t,"The prim field should be 'map' or 'big_map'");if(!("args"in t))throw new R(t,"Missing 'args' field");if(!Array.isArray(t.args))throw new R(t,"The 'args' field should be an array");if(2!==t.args.length)throw new R(t,"The 'args' field should have 2 elements")}(t),this.keySchema=new pe(t.args[0]),this.valueSchema=new pe(t.args[1])}removeType(){this.keySchema=void 0,this.valueSchema=void 0}static fromLiteral(t,e){const r=new N(e);return Object.keys(t).forEach(e=>{r.set(e,t[e])}),r}typecheckKey(t){if(this.keySchema&&!this.keySchema.Typecheck(t))throw new I(t,this.keySchema,"key","Type validation failed")}typecheckValue(t){if(this.valueSchema&&!this.valueSchema.Typecheck(t))throw new I(t,this.valueSchema,"value","Type validation failed")}assertTypecheckValue(t){this.typecheckValue(t)}assertTypecheckKey(t){this.typecheckKey(t)}serializeDeterministically(t){return i()(t)}*keys(){for(const[t]of this.entries())yield t}*values(){for(const[,t]of this.entries())yield t}*entries(){for(const t of this.valueMap.keys())yield[this.keyMap.get(t),this.valueMap.get(t)]}get(t){this.assertTypecheckKey(t);const e=this.serializeDeterministically(t);return this.valueMap.get(e)}set(t,e){this.assertTypecheckKey(t),this.assertTypecheckValue(e);const r=this.serializeDeterministically(t);this.keyMap.set(r,t),this.valueMap.set(r,e)}delete(t){this.assertTypecheckKey(t),this.keyMap.delete(this.serializeDeterministically(t)),this.valueMap.delete(this.serializeDeterministically(t))}has(t){this.assertTypecheckKey(t);const e=this.serializeDeterministically(t);return this.keyMap.has(e)&&this.valueMap.has(e)}clear(){this.keyMap.clear(),this.valueMap.clear()}get size(){return this.keyMap.size}forEach(t){for(const[e,r]of this.entries())t(r,e,this)}}S=x;class k extends s.TaquitoError{constructor(t,e,r){super(),this.value=t,this.token=e,this.name="TokenValidationError";const n=this.token.annot(),i=n?`[${n}] `:"";this.message=`${i}${r}`}}class L{static get fieldNumberingStrategy(){return L._fieldNumberingStrategy}static set fieldNumberingStrategy(t){L._fieldNumberingStrategy=t}constructor(t,e,r,n){this.val=t,this.idx=e,this.fac=r,this.parentTokenType=n,this.createToken=this.fac}typeWithoutAnnotations(){const t=e=>{if("object"==typeof e){if(Array.isArray(e)){return e.map(e=>t(e))}const r=e;return r.args?{prim:r.prim,args:r.args.map(e=>t(e))}:{prim:r.prim}}return e};return(e=this.val).args?{prim:e.prim,args:e.args.map(e=>t(e))}:{prim:e.prim};var e}annot(){return(Array.isArray(this.val.annots)&&this.val.annots.length>0?this.val.annots[0]:String(this.idx)).replace(/(%|:)(_Liq_entry_)?/,"")}hasAnnotations(){return Array.isArray(this.val.annots)&&this.val.annots.length}get tokenVal(){return this.val}ExtractSignature(){return[[this.generateSchema()]]}}L._fieldNumberingStrategy="Latest";class C extends L{compare(t,e){return t<e?-1:t>e?1:0}}class M extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="BigMapValidationError"}}class B extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get ValueSchema(){return this.createToken(this.val.args[1],0)}get KeySchema(){return this.createToken(this.val.args[0],0)}generateSchema(){return{__michelsonType:B.prim,schema:{key:this.KeySchema.generateSchema(),value:this.ValueSchema.generateSchema()}}}validate(t){if(!N.isMichelsonMap(t))throw new M(t,this,`Value ${JSON.stringify(t)} is not a MichelsonMap`)}objLitToMichelsonMap(t){return t instanceof N?t:"object"==typeof t?0===Object.keys(t).length?new N:N.fromLiteral(t):t}Encode(t){const e=this.objLitToMichelsonMap(t.pop());return this.validate(e),Array.from(e.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(e.get(t))]}))}EncodeObject(t,e){const r=this.objLitToMichelsonMap(t);return this.validate(r),e&&e[B.prim]?e[B.prim](r,this.val):Array.from(r.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(r.get(t))]}))}Execute(t,e){if(e&&e[B.prim])return e[B.prim](t,this.val);if(Array.isArray(t)){const e=new N(this.val);return t.forEach(t=>{e.set(this.KeySchema.ToKey(t.args[0]),this.ValueSchema.Execute(t.args[1]))}),e}if("int"in t)return t.int;throw new M(t,this,`Big map is expecting either an array (Athens) or an object with an int property (Babylon). Got ${JSON.stringify(t)}`)}findAndReturnTokens(t,e){return B.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),this.ValueSchema.findAndReturnTokens(t,e),e}}B.prim="big_map";class D extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="OrValidationError"}}class U extends C{constructor(t,e,r,n){super(t,e,r,n),this.val=t,this.idx=e,this.fac=r,this.parentTokenType=n}Encode(t){const e=t[t.length-1],r=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let n=1;r instanceof U&&(n=Object.keys(r.generateSchema().schema).length);const i=this.createToken(this.val.args[1],this.getIdxForChildren()+n,"Or");if(String(r.annot())!==String(e)||r instanceof U){if(String(i.annot())!==String(e)||i instanceof U){if(r instanceof U){const e=r.Encode(t);if(e)return{prim:"Left",args:[e]}}if(i instanceof U){const e=i.Encode(t);if(e)return{prim:"Right",args:[e]}}return null}return t.pop(),{prim:"Right",args:[i.Encode(t)]}}return t.pop(),{prim:"Left",args:[r.Encode(t)]}}ExtractSignature(){const t=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let e=1;t instanceof U&&(e=Object.keys(t.generateSchema().schema).length);const r=this.createToken(this.val.args[1],this.getIdxForChildren()+e,"Or"),n=[];if(t instanceof U)n.push(...t.ExtractSignature());else for(const e of t.ExtractSignature())n.push([t.annot(),...e]);if(r instanceof U)n.push(...r.ExtractSignature());else for(const t of r.ExtractSignature())n.push([r.annot(),...t]);return n}EncodeObject(t,e){this.validateJavascriptObject(t);const r=Object.keys(t)[0],n=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let i=1;n instanceof U&&(i=Object.keys(n.generateSchema().schema).length);const s=this.createToken(this.val.args[1],this.getIdxForChildren()+i,"Or");if(String(n.annot())!==String(r)||n instanceof U){if(String(s.annot())!==String(r)||s instanceof U){if(n instanceof U){const r=n.EncodeObject(t,e);if(r)return{prim:"Left",args:[r]}}if(s instanceof U){const r=s.EncodeObject(t,e);if(r)return{prim:"Right",args:[r]}}return null}return{prim:"Right",args:[s.EncodeObject(t[r],e)]}}return{prim:"Left",args:[n.EncodeObject(t[r],e)]}}validateJavascriptObject(t){if("object"!=typeof t||Array.isArray(t)||null===t||1!==Object.keys(t).length)throw new D(t,this,`EncodeObject expects an object with a single key but got: ${JSON.stringify(t)}`)}Execute(t,e){const r=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let n=1;r instanceof U&&(n=Object.keys(r.generateSchema().schema).length);const i=this.createToken(this.val.args[1],this.getIdxForChildren()+n,"Or");if("Right"===t.prim)return i instanceof U?i.Execute(t.args[0],e):{[i.annot()]:i.Execute(t.args[0],e)};if("Left"===t.prim)return r instanceof U?r.Execute(t.args[0],e):{[r.annot()]:r.Execute(t.args[0],e)};throw new D(t,this,`Was expecting Left or Right prim but got: ${JSON.stringify(t.prim)}`)}traversal(t,e,r){const n=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let i,s=1;n instanceof U?(i=t(n),s=Object.keys(n.generateSchema().schema).length):i={[n.annot()]:t(n)};const o=this.createToken(this.val.args[1],this.getIdxForChildren()+s,"Or");let a;a=o instanceof U?e(o):{[o.annot()]:e(o)};return r(i,a)}generateSchema(){return{__michelsonType:U.prim,schema:this.traversal(t=>t instanceof U?t.generateSchema().schema:t.generateSchema(),t=>t instanceof U?t.generateSchema().schema:t.generateSchema(),(t,e)=>({...t,...e}))}}findToken(t){const e=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let r=1;if(e instanceof U){const t=e.generateSchema();r=Object.keys(t.schema).length}const n=this.createToken(this.val.args[1],this.getIdxForChildren()+r,"Or");if(String(e.annot())===String(t)&&!(e instanceof U)&&e instanceof C)return e;if(String(n.annot())===String(t)&&!(n instanceof U)&&n instanceof C)return n;if(e instanceof U){const r=e.findToken(t);if(r)return r}if(n instanceof U){const e=n.findToken(t);if(e)return e}return null}compare(t,e){const r=Object.keys(t)[0];if(r!==Object.keys(e)[0]){return JSON.stringify(this.EncodeObject(t))<JSON.stringify(this.EncodeObject(e))?-1:1}{const n=this.findToken(r);if(n instanceof C)return n.compare(t[r],e[r])}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}findAndReturnTokens(t,e){return U.prim===t&&e.push(this),this.traversal(r=>r.findAndReturnTokens(t,e),r=>r.findAndReturnTokens(t,e),(t,e)=>({...t,...e})),e}getIdxForChildren(){return"Legacy"===L.fieldNumberingStrategy||"Or"===this.parentTokenType?this.idx:0}}U.prim="or";class K extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="TokenArgumentValidationError"}}class H extends s.TaquitoError{constructor(t,e){super(),this.val1=t,this.val2=e,this.name="TokenComparisonError",this.message=`Tokens ${JSON.stringify(t)} and ${JSON.stringify(e)} are not comparable`}}function F(t,e=G.prim){if(Array.isArray(t))return F({prim:e,args:t},e);if(void 0===t.args)throw new K(`The value ${JSON.stringify(t)} is an invalid PairToken with no arguments, a pair must have two or more arguments.`);return t.args.length>2?[t.args[0],{prim:e,args:t.args.slice(1)}]:[t.args[0],t.args[1]]}class G extends C{constructor(t,e,r,n){super(Array.isArray(t)?{prim:G.prim,args:t}:t.prim?t:{prim:G.prim,args:t},e,r,n)}args(){return F(this.val)}tokens(){let t=0;return this.args().map(e=>{const r=this.createToken(e,this.getIdxForChildren()+t,"Pair");return r instanceof G?t+=Object.keys(r.generateSchema()).length:t++,r})}Encode(t){return{prim:"Pair",args:this.tokens().map(e=>e.Encode(t))}}ExtractSignature(){const t=this.args(),e=this.createToken(t[0],this.getIdxForChildren(),"Pair");let r=1;e instanceof U&&(r=Object.keys(e.generateSchema()).length);const n=this.createToken(t[1],this.getIdxForChildren()+r,"Pair"),i=[];for(const t of e.ExtractSignature())for(const e of n.ExtractSignature())i.push([...t,...e]);return i}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}ToKey(t){return this.Execute(t)}EncodeObject(t,e){const[r,n]=this.tokens();let i,s;return i=r instanceof G&&!r.hasAnnotations()?t:t[r.annot()],s=n instanceof G&&!n.hasAnnotations()?t:t[n.annot()],{prim:"Pair",args:[r.EncodeObject(i,e),n.EncodeObject(s,e)]}}traversal(t,e){const r=this.args(),n=this.createToken(r[0],this.getIdxForChildren(),"Pair");let i,s=1;n instanceof G&&!n.hasAnnotations()?(i=t(n),n instanceof G&&(s=Object.keys(n.generateSchema()).length)):i={[n.annot()]:t(n)};const o=this.createToken(r[1],this.getIdxForChildren()+s,"Pair");let a;a=o instanceof G&&!o.hasAnnotations()?e(o):{[o.annot()]:e(o)};return{...i,...a}}Execute(t,e){const r=F(t,"Pair");return this.traversal(t=>t.Execute(r[0],e),t=>t.Execute(r[1],e))}generateSchema(){return{__michelsonType:G.prim,schema:this.traversal(t=>t instanceof G&&!t.hasAnnotations()?t.generateSchema().schema:t.generateSchema(),t=>t instanceof G&&!t.hasAnnotations()?t.generateSchema().schema:t.generateSchema())}}compare(t,e){const[r,n]=this.tokens(),i=(t,e)=>t instanceof G&&!t.hasAnnotations()?e:e[t.annot()];if(r instanceof C&&n instanceof C){const s=r.compare(i(r,t),i(r,e));return 0===s?n.compare(i(n,t),i(n,e)):s}throw new H(t,e)}findAndReturnTokens(t,e){return G.prim===t&&e.push(this),this.tokens().map(r=>r.findAndReturnTokens(t,e)),e}getIdxForChildren(){return"Legacy"===L.fieldNumberingStrategy||"Pair"===this.parentTokenType?this.idx:0}}G.prim="pair";class V extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="NatValidationError"}}class j extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}Encode(t){const e=t.pop();return this.validate(e),{int:new O(e).toFixed()}}validate(t){let e;try{e=new O(t)}catch{throw new V(t,this,`Value is not a number: ${JSON.stringify(t)}`)}if(e.isNaN())throw new V(t,this,`Value is not a number: ${JSON.stringify(t)}`);if(e.isNegative())throw new V(t,this,`Value cannot be negative: ${JSON.stringify(t)}`)}EncodeObject(t,e){return this.validate(t),e&&e[j.prim]?e[j.prim](t):{int:new O(t).toFixed()}}generateSchema(){return{__michelsonType:j.prim,schema:j.prim}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:j.prim}}}ToKey({int:t}){return new O(t)}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return j.prim===t&&e.push(this),e}}j.prim="nat";class $ extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t[Object.keys(t)[0]]}generateSchema(){return{__michelsonType:$.prim,schema:$.prim}}Encode(t){return{string:t.pop()}}EncodeObject(t,e){return e&&e[$.prim]?e[$.prim](t):{string:t}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:$.prim}}}findAndReturnTokens(t,e){return $.prim===t&&e.push(this),e}}$.prim="string";class z extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="AddressValidationError"}}class q extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}ToBigMapKey(t){return{key:{bytes:(0,T.b58DecodeAddress)(t)},type:{prim:"bytes"}}}validate(t){if("string"!=typeof t)throw new z(t,this,"Type error");if((0,T.validateAddress)(t)!==T.ValidationResult.VALID)throw new z(t,this,`Address is not valid: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[q.prim]?e[q.prim](t):{string:t}}Execute(t){if(t.string)return t.string;if(!t.bytes)throw new z(t,this,`cannot be missing both string and bytes: ${JSON.stringify(t)}`);return(0,T.encodeAddress)(t.bytes)}generateSchema(){return{__michelsonType:q.prim,schema:q.prim}}ToKey({bytes:t,string:e}){if(e)return e;if(!t)throw new z({bytes:t,string:e},this,`cannot be missing both string and bytes ${JSON.stringify({string:e,bytes:t})}`);return(0,T.encodeAddress)(t)}compare(t,e){const[r,n]=(0,T.splitAddress)(t),[i,s]=(0,T.splitAddress)(e),o=n||"",a=s||"",c=(0,T.b58DecodeAddress)(r,"array"),u=(0,T.b58DecodeAddress)(i,"array"),l=(0,T.compareArrays)(c,u);return 0===l?o<a?-1:o>a?1:0:l}findAndReturnTokens(t,e){return q.prim===t&&e.push(this),e}}q.prim="address";class W extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="MapValidationError"}}class Z extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get ValueSchema(){return this.createToken(this.val.args[1],0)}get KeySchema(){return this.createToken(this.val.args[0],0)}validate(t){if(!N.isMichelsonMap(t))throw new W(t,this,`Value ${JSON.stringify(t)} is not a valid MichelsonMap`)}Execute(t,e){const r=new N(this.val);return t.forEach(t=>{r.set(this.KeySchema.ToKey(t.args[0]),this.ValueSchema.Execute(t.args[1],e))}),r}objLitToMichelsonMap(t){return t instanceof N?t:"object"==typeof t?0===Object.keys(t).length?new N:N.fromLiteral(t):t}Encode(t){const e=this.objLitToMichelsonMap(t.pop());return this.validate(e),Array.from(e.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(e.get(t))]}))}EncodeObject(t,e){const r=this.objLitToMichelsonMap(t);return this.validate(r),e&&e[Z.prim]?e[Z.prim](r):Array.from(r.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(r.get(t))]}))}generateSchema(){return{__michelsonType:Z.prim,schema:{key:this.KeySchema.generateSchema(),value:this.ValueSchema.generateSchema()}}}findAndReturnTokens(t,e){return Z.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),this.ValueSchema.findAndReturnTokens(t,e),e}}Z.prim="map";class Y extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return"true"===String(t.prim).toLowerCase()}Encode(t){return{prim:t.pop()?"True":"False"}}EncodeObject(t,e){return e&&e[Y.prim]?e[Y.prim](t):{prim:t?"True":"False"}}generateSchema(){return{__michelsonType:Y.prim,schema:Y.prim}}ToBigMapKey(t){return{key:this.EncodeObject(t),type:{prim:Y.prim}}}ToKey(t){return this.EncodeObject(t)}compare(t,e){return t&&e||!t&&!e?0:t?1:-1}findAndReturnTokens(t,e){return Y.prim===t&&e.push(this),e}}Y.prim="bool";class X extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ContractValidationError"}}class J extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if("string"!=typeof t)throw new X(t,this,"Type error");if((0,T.validateAddress)(t)!==T.ValidationResult.VALID)throw new X(t,this,`Value ${JSON.stringify(t)} is not a valid contract address.`);return null}Execute(t){if(t.string)return t.string;if(!t.bytes)throw new X(t,this,`Value ${JSON.stringify(t)} is not a valid contract address. must contain bytes or string.`);return(0,T.encodeAddress)(t.bytes)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[J.prim]?e[J.prim](t):{string:t}}generateSchema(){const t=this.createToken(this.val.args[0],0);return{__michelsonType:J.prim,schema:{parameter:this.val.args[0]?t.generateSchema():{}}}}findAndReturnTokens(t,e){return J.prim===t&&e.push(this),e}}J.prim="contract";class Q extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ListValidationError"}}class tt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueSchema(){return this.createToken(this.val.args[0],this.idx)}validate(t){if(!Array.isArray(t))throw new Q(t,this,`Value ${JSON.stringify(t)} is not a valid array`)}Encode(t){const e=t.pop();this.validate(e);const r=this.createToken(this.val.args[0],0);return e.reduce((t,e)=>[...t,r.EncodeObject(e)],[])}Execute(t,e){const r=this.createToken(this.val.args[0],0);return this.validate(t),t.reduce((t,n)=>[...t,r.Execute(n,e)],[])}EncodeObject(t,e){const r=this.createToken(this.val.args[0],0);return this.validate(t),e&&e[tt.prim]?e[tt.prim](t):t.reduce((t,e)=>[...t,r.EncodeObject(e)],[])}generateSchema(){return{__michelsonType:tt.prim,schema:this.valueSchema.generateSchema()}}findAndReturnTokens(t,e){return tt.prim===t&&e.push(this),this.createToken(this.val.args[0],this.idx).findAndReturnTokens(t,e),e}}tt.prim="list";class et extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="MutezValidationError"}}class rt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}generateSchema(){return{__michelsonType:rt.prim,schema:rt.prim}}validate(t){let e;try{e=new O(t)}catch{throw new et(t,this,`Value is not a number: ${t}`)}if(e.isNaN())throw new et(t,this,`Value is not a number: ${t}`)}Encode(t){const e=t.pop();return this.validate(e),{int:String(e).toString()}}EncodeObject(t,e){return this.validate(t),e&&e[rt.prim]?e[rt.prim](t):{int:String(t).toString()}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:rt.prim}}}ToKey({int:t}){return t}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return rt.prim===t&&e.push(this),e}}rt.prim="mutez";class nt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="BytesValidationError"}}class it extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}ToBigMapKey(t){return{key:{bytes:t},type:{prim:it.prim}}}validate(t){if("string"!=typeof t||!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new nt(t,this,`Invalid bytes: ${t}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=(0,T.stripHexPrefix)(this.convertUint8ArrayToHexString(e)),this.validate(e),{bytes:String(e).toString()}}EncodeObject(t,e){return"string"==typeof(t=this.convertUint8ArrayToHexString(t))&&(t=(0,T.stripHexPrefix)(t)),this.validate(t),e&&e[it.prim]?e[it.prim](t):{bytes:String(t).toString()}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:it.prim,schema:it.prim}}ToKey({bytes:t,string:e}){return e||t}findAndReturnTokens(t,e){return it.prim===t&&e.push(this),e}}it.prim="bytes";class st extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}subToken(){return this.createToken(this.val.args[0],this.idx)}schema(){return this.createToken(this.val.args[0],0)}annot(){return Array.isArray(this.val.annots)?super.annot():this.createToken(this.val.args[0],this.idx).annot()}Encode(t){const e=t;return null==e?{prim:"None"}:!Array.isArray(e)||void 0!==e[e.length-1]&&null!==e[e.length-1]?{prim:"Some",args:[this.schema().Encode(t)]}:(e.pop(),{prim:"None"})}EncodeObject(t,e){let r=t;return null==r?{prim:"None"}:(r="object"==typeof r&&"Some"in r?r.Some:r,Array.isArray(r)&&1===r.length&&(r=r[0]),{prim:"Some",args:[this.schema().EncodeObject(r,e)]})}Execute(t,e){return"None"===t.prim?null:{Some:this.schema().Execute(t.args[0],e)}}generateSchema(){return{__michelsonType:st.prim,schema:this.schema().generateSchema()}}ExtractSignature(){return[...this.schema().ExtractSignature()]}get KeySchema(){return this.schema()}compare(t,e){return t?e?this.KeySchema.compare(t,e):1:-1}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}findAndReturnTokens(t,e){return st.prim===t&&e.push(this),this.subToken().findAndReturnTokens(t,e),e}}st.prim="option";class ot extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string&&/^\d+$/.test(t.string)?new Date(1e3*Number(t.string)).toISOString():t.string?new Date(t.string).toISOString():t.int?new Date(1e3*Number(t.int)).toISOString():void 0}Encode(t){const e=t.pop();return"number"==typeof e?{int:String(e)}:{string:e}}EncodeObject(t,e){return e&&e[ot.prim]?e[ot.prim](t):"number"==typeof t?{int:String(t)}:{string:t}}generateSchema(){return{__michelsonType:ot.prim,schema:ot.prim}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:ot.prim}}}findAndReturnTokens(t,e){return ot.prim===t&&e.push(this),e}}ot.prim="timestamp";class at extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="IntValidationError"}}class ct extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}generateSchema(){return{__michelsonType:ct.prim,schema:ct.prim}}validate(t){let e;try{e=new O(t)}catch{throw new at(t,this,`Value is not a number: ${JSON.stringify(t)}`)}if(e.isNaN())throw new at(t,this,`Value is not a number: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{int:new O(e).toFixed()}}EncodeObject(t,e){return this.validate(t),e&&e[ct.prim]?e[ct.prim](t):{int:new O(t).toFixed()}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:ct.prim}}}ToKey({int:t}){return t}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return ct.prim===t&&e.push(this),e}}ct.prim="int";const ut=Symbol(),lt={};class ht extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Encode(t){return t.pop(),{prim:"Unit"}}EncodeObject(t,e){return e&&e[ht.prim]?e[ht.prim](t):{prim:"Unit"}}Execute(t){return ut}generateSchema(){return{__michelsonType:ht.prim,schema:ht.prim}}compare(t,e){return 0}ToKey(t){return ut}ToBigMapKey(t){return{key:{prim:"Unit"},type:{prim:ht.prim}}}findAndReturnTokens(t,e){return ht.prim===t&&e.push(this),e}}ht.prim="unit";class ft extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="KeyValidationError"}}class dt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:(0,T.encodeKey)(t.bytes)}validate(t){if((0,T.validatePublicKey)(t)!==T.ValidationResult.VALID)throw new ft(t,this,"Key is not valid")}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[dt.prim]?e[dt.prim](t):{string:t}}generateSchema(){return{__michelsonType:dt.prim,schema:dt.prim}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:{string:t},type:{prim:dt.prim}}}compare(t,e){const r=(0,P.publicKeyFromString)(t),n=(0,P.publicKeyFromString)(e),i=r.toProtocol(),s=n.toProtocol();return i[0]===s[0]?r.compare(n):i[0]>s[0]?1:-1}findAndReturnTokens(t,e){return dt.prim===t&&e.push(this),e}}dt.prim="key";class pt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="KeyHashValidationError"}}class gt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:(0,T.encodeKeyHash)(t.bytes)}validate(t){if((0,T.validateKeyHash)(t)!==T.ValidationResult.VALID)throw new pt(t,this,`KeyHash is not valid: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[gt.prim]?e[gt.prim](t):{string:t}}generateSchema(){return{__michelsonType:gt.prim,schema:gt.prim}}ToKey({string:t,bytes:e}){return t||(0,T.encodeKeyHash)(e)}ToBigMapKey(t){return{key:{string:t},type:{prim:gt.prim}}}compare(t,e){const r=(0,T.b58DecodePublicKeyHash)(t,"array"),n=(0,T.b58DecodePublicKeyHash)(e,"array");return(0,T.compareArrays)(r,n)}findAndReturnTokens(t,e){return gt.prim===t&&e.push(this),e}}gt.prim="key_hash";class mt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SignatureValidationError"}}class yt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:t.bytes}validate(t){if((0,T.validateSignature)(t)!==T.ValidationResult.VALID)throw new mt(t,this,"Signature is not valid")}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[yt.prim]?e[yt.prim](t):{string:t}}generateSchema(){return{__michelsonType:yt.prim,schema:yt.prim}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:{string:t},type:{prim:yt.prim}}}findAndReturnTokens(t,e){return yt.prim===t&&e.push(this),e}}yt.prim="signature";class bt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get paramSchema(){return this.createToken(this.val.args[0],this.idx)}get returnSchema(){return this.createToken(this.val.args[1],this.idx+1)}Execute(t){return t.string?t.string:t}Encode(t){return t.pop()}EncodeObject(t,e){return e&&e[bt.prim]?e[bt.prim](t):t}generateSchema(){return{__michelsonType:bt.prim,schema:{parameters:this.paramSchema.generateSchema(),returns:this.returnSchema.generateSchema()}}}findAndReturnTokens(t,e){return bt.prim===t&&e.push(this),this.createToken(this.val.args[0],this.idx).findAndReturnTokens(t,e),this.createToken(this.val.args[1],this.idx).findAndReturnTokens(t,e),e}}bt.prim="lambda";class vt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string}Encode(...t){return{string:t.pop()}}EncodeObject(t,e){return e&&e[vt.prim]?e[vt.prim](t):{string:t}}generateSchema(){return{__michelsonType:vt.prim,schema:vt.prim}}findAndReturnTokens(t,e){return vt.prim===t&&e.push(this),e}}vt.prim="operation";class wt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SetValidationError"}}class Et extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get KeySchema(){return this.createToken(this.val.args[0],0)}validate(t){if(!Array.isArray(t))throw new wt(t,this,`Value ${JSON.stringify(t)} is not an array`)}Encode(t){const e=t.pop();return this.validate(e),e.sort((t,e)=>this.KeySchema.compare(t,e)).reduce((t,e)=>[...t,this.KeySchema.EncodeObject(e)],[])}Execute(t,e){return t.reduce((t,r)=>[...t,this.KeySchema.Execute(r,e)],[])}EncodeObject(t,e){return this.validate(t),e&&e[Et.prim]?e[Et.prim](t):t.sort((t,e)=>this.KeySchema.compare(t,e)).reduce((t,e)=>[...t,this.KeySchema.EncodeObject(e)],[])}generateSchema(){return{__michelsonType:Et.prim,schema:this.KeySchema.generateSchema()}}findAndReturnTokens(t,e){return Et.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),e}}Et.prim="set";class _t extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChainIDValidationError"}}class At extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if((0,T.validateChain)(t)!==T.ValidationResult.VALID)throw new _t(t,this,`Value ${JSON.stringify(t)} is not a valid ChainID`)}Execute(t){return t[Object.keys(t)[0]]}generateSchema(){return{__michelsonType:At.prim,schema:At.prim}}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[At.prim]?e[At.prim](t):{string:t}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:At.prim}}}findAndReturnTokens(t,e){return At.prim===t&&e.push(this),e}}At.prim="chain_id";class Ot extends s.TaquitoError{constructor(){super(),this.name="TicketEncodeError",this.message="Tickets cannot be sent to the blockchain; they are created on-chain"}}const St={prim:"contract"},Tt={prim:"int"};class Pt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueToken(){return this.createToken(this.val.args[0],this.idx)}Encode(t){throw new Ot}EncodeObject(t,e){if(e&&e[Pt.prim])return e[Pt.prim](t,this.val);throw new Ot}Execute(t,e){if(e&&e[Pt.prim])return e[Pt.prim](t,this.val);const r=this.createToken(St,this.idx),n=this.valueToken,i=this.createToken(Tt,this.idx);return void 0===t.args[2]&&void 0!==t.args[1].args?{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1].args[0],e),amount:i.Execute(t.args[1].args[1],e)}:{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1],e),amount:i.Execute(t.args[2],e)}}generateSchema(){return{__michelsonType:Pt.prim,schema:{value:this.valueToken.generateSchema(),ticketer:{__michelsonType:J.prim,schema:J.prim},amount:{__michelsonType:ct.prim,schema:ct.prim}}}}findAndReturnTokens(t,e){return Pt.prim===t&&e.push(this),this.valueToken.findAndReturnTokens(t,e),e}}Pt.prim="ticket";class Rt extends s.TaquitoError{constructor(){super(),this.name="TicketDeprecatedEncodeError",this.message="Ticket_deprecated cannot be sent to the blockchain; they are created on-chain"}}const xt={prim:"contract"},It={prim:"int"};class Nt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueToken(){return this.createToken(this.val.args[0],this.idx)}Encode(t){throw new Rt}EncodeObject(t,e){if(e&&e[Nt.prim])return e[Nt.prim](t,this.val);throw new Rt}Execute(t,e){if(e&&e[Nt.prim])return e[Nt.prim](t,this.val);const r=this.createToken(xt,this.idx),n=this.valueToken,i=this.createToken(It,this.idx);return void 0===t.args[2]&&void 0!==t.args[1].args?{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1].args[0],e),amount:i.Execute(t.args[1].args[1],e)}:{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1],e),amount:i.Execute(t.args[2],e)}}generateSchema(){return{__michelsonType:Nt.prim,schema:{value:this.valueToken.generateSchema(),ticketer:{__michelsonType:J.prim,schema:J.prim},amount:{__michelsonType:ct.prim,schema:ct.prim}}}}findAndReturnTokens(t,e){return Nt.prim===t&&e.push(this),this.valueToken.findAndReturnTokens(t,e),e}}Nt.prim="ticket_deprecated";class kt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="NeverTokenError"}}class Lt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Encode(t){const e=t.pop();throw new kt(e,this,`Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(e)}.`)}EncodeObject(t,e){if(e&&e[Lt.prim])return e[Lt.prim](t);throw new kt(t,this,`Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(t)}.`)}Execute(t){throw new kt(t,this,`There is no literal value for the type never. Trying to execute ${JSON.stringify(t)}.`)}generateSchema(){return{__michelsonType:Lt.prim,schema:Lt.prim}}findAndReturnTokens(t,e){return Lt.prim===t&&e.push(this),e}}Lt.prim="never";class Ct extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingStateValidationError"}}class Mt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}isValid(t){return"object"==typeof t&&0===Object.keys(t).length}Execute(t,e){if(e&&e[Mt.prim])return e[Mt.prim](t,this.val);if("int"in t)return t.int;throw new Ct(t,this,`Sapling state is expecting an object with an int property. Got ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();if(this.isValid(e))return[];throw new Ct(e,this,`Invalid sapling_state. Received: ${JSON.stringify(e)} while expecting: {}`)}EncodeObject(t,e){if(e&&e[Mt.prim])return e[Mt.prim](t);if(this.isValid(t))return[];throw new Ct(t,this,`Invalid sapling_state. Received: ${JSON.stringify(t)} while expecting: {}`)}generateSchema(){return{__michelsonType:Mt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Mt.prim===t&&e.push(this),e}}Mt.prim="sapling_state";class Bt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingTransactionValidationError"}}class Dt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){throw new Bt(t,this,`There is no literal value for the sapling_transaction type. Got: ${JSON.stringify(t)}.`)}validateBytes(t){const e=/^(0x|0X)?([0-9a-fA-F]*$)/.exec(t);if(e&&e[2].length%2==0)return e[2];throw new Bt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.validateBytes(this.convertUint8ArrayToHexString(e)),{bytes:String(e).toString()}}EncodeObject(t,e){return t=this.validateBytes(this.convertUint8ArrayToHexString(t)),e&&e[Dt.prim]?e[Dt.prim](t):{bytes:String(t).toString()}}generateSchema(){return{__michelsonType:Dt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Dt.prim===t&&e.push(this),e}}Dt.prim="sapling_transaction";class Ut extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingTransactionDeprecatedValidationError"}}class Kt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){throw new Ut(t,this,`There is no literal value for the sapling_transaction_deprecated type. Got: ${JSON.stringify(t)}.`)}validateBytes(t){const e=/^(0x|0X)?([0-9a-fA-F]*$)/.exec(t);if(e&&e[2].length%2==0)return e[2];throw new Ut(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.validateBytes(this.convertUint8ArrayToHexString(e)),{bytes:String(e).toString()}}EncodeObject(t,e){return t=this.validateBytes(this.convertUint8ArrayToHexString(t)),e&&e[Kt.prim]?e[Kt.prim](t):{bytes:String(t).toString()}}generateSchema(){return{__michelsonType:Kt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Kt.prim===t&&e.push(this),e}}Kt.prim="sapling_transaction_deprecated";class Ht extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381frValidationError"}}class Ft extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Ht(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return"number"==typeof e?{int:e.toString()}:(e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e})}EncodeObject(t,e){return e&&e[Ft.prim]?e[Ft.prim](t):"number"==typeof t?{int:t.toString()}:(t=this.convertUint8ArrayToHexString(t),this.validate(t),{bytes:t})}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Ft.prim,schema:Ft.prim}}findAndReturnTokens(t,e){return Ft.prim===t&&e.push(this),e}}Ft.prim="bls12_381_fr";class Gt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381g1ValidationError"}}class Vt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Gt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[Vt.prim]?e[Vt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Vt.prim,schema:Vt.prim}}findAndReturnTokens(t,e){return Vt.prim===t&&e.push(this),e}}Vt.prim="bls12_381_g1";class jt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381g2ValidationError"}}class $t extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new jt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[$t.prim]?e[$t.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:$t.prim,schema:$t.prim}}findAndReturnTokens(t,e){return $t.prim===t&&e.push(this),e}}$t.prim="bls12_381_g2";class zt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChestValidationError"}}class qt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new zt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[qt.prim]?e[qt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:qt.prim,schema:qt.prim}}findAndReturnTokens(t,e){return qt.prim===t&&e.push(this),e}}qt.prim="chest";class Wt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChestKeyValidationError"}}class Zt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Wt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[Zt.prim]?e[Zt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Zt.prim,schema:Zt.prim}}findAndReturnTokens(t,e){return Zt.prim===t&&e.push(this),e}}Zt.prim="chest_key";class Yt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="GlobalConstantEncodingError"}}class Xt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="GlobalConstantDecodingError"}}class Jt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t,e){if(e&&e[Jt.prim])return e[Jt.prim](t,this.val);throw new Xt(t,this,`Unable to decode a value represented by a global constants. Please provide an expanded script to the Michelson-Encoder or semantics for the decoding. The following global constant hash was encountered: ${this.val.args[0].string}.`)}Encode(t){throw new Yt(t,this,`Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0].string}.`)}EncodeObject(t,e){if(e&&e[Jt.prim])return e[Jt.prim](t);throw new Yt(t,this,`Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0].string}.`)}generateSchema(){return{__michelsonType:Jt.prim,schema:{hash:this.val.args[0].string}}}findAndReturnTokens(t,e){return Jt.prim===t&&e.push(this),e}}Jt.prim="constant";const Qt=[G,j,$,B,q,Z,Y,U,J,tt,rt,it,st,ot,ct,ht,dt,gt,yt,bt,vt,Et,At,Pt,Nt,Lt,Mt,Dt,Kt,Ft,Vt,$t,qt,Zt,Jt];class te extends s.TaquitoError{constructor(t,e){super(t),this.message=t,this.data=e,this.name="Invalid token error"}}function ee(t,e,r){if(Array.isArray(t))return new G(t,e,ee,r);const n=Qt.find(e=>e.prim===t.prim);if(!n)throw new te(`Malformed data: ${JSON.stringify(t)}. Expected a value with a valid prim property`,t);return new n(t,e,ee,r)}class re extends s.InvalidViewParameterError{constructor(t,e,r,n){super(t,e,r,n),this.viewName=t,this.sigs=e,this.args=r,this.cause=n,this.name="ParameterEncodingError",this.message=`Could not encode parameter ${JSON.stringify(r)} received for name "${t}" expecting one of the following signatures ${JSON.stringify(e)}`}}class ne extends s.TaquitoError{constructor(t,e){super(),this.script=t,this.reason=e,this.name="InvalidScriptError";let r="Invalid on-chain view found in the following script.";e&&(r+=` Reason: ${e}.`),r+=`Script: ${JSON.stringify(t)}`,this.message=r}}class ie extends s.TaquitoError{constructor(t,e){super(),this.script=t,this.reason=e,this.name="InvalidRpcResponseError";let r="Invalid RPC response passed as argument(s).";e&&(r+=` Reason: ${e}.`),r+=` Received: ${JSON.stringify(t)}`,this.message=r}}class se extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="InvalidBigMapSchemaError"}}class oe extends s.TaquitoError{constructor(t,e){super(t),this.message=t,this.value=e,this.name="InvalidBigMapDiffError"}}class ae extends s.TaquitoError{constructor(t,e,r,n){super(),this.details=e,this.schema=r,this.value=n,this.name="BigMapEncodingError",this.message=`Unable to encode the big map ${t}. Schema is: ${JSON.stringify(r)}. The ${t} is: ${JSON.stringify(n)}. Error details: ${e}`}}class ce extends s.TaquitoError{constructor(t,e,r,n,i){super(),this.details=e,this.schema=r,this.value=n,this.semantics=i,this.name="StorageEncodingError",this.message=`Unable to encode ${t}. The schema is: ${JSON.stringify(r)}, the value is: ${JSON.stringify(n)}.${i?`And the semantic is: ${JSON.stringify(i)}`:""}. Error details: ${e}`}}class ue extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="MissingArgumentError"}}var le;const he=Symbol.for("taquito-schema-type-symbol");function fe(t,e=G.prim){if(Array.isArray(t))return fe({prim:e,args:t},e);const r=t;return r.prim===e&&r.args&&r.args.length>2?{...r,args:[r.args?.[0],{prim:e,args:r.args?.slice(1)}]}:r}function de(t,e){if(void 0===t||void 0===e)return t===e;const r=fe(t),n=fe(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((t,e)=>de(t,n.args?.[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((t,e)=>t===n.annots?.[e]))}class pe{static isSchema(t){return t&&!0===t[he]}static fromRPCResponse(t){if(!t)throw new ie(t,"the RPC response is empty");if(!t.script)throw new ie(t,"the RPC response has no script");if(!Array.isArray(t.script.code))throw new ie(t,"The response.script.code should be an array");let e=t.script.code;for(;1===e.length&&Array.isArray(e[0]);)e=e[0];const r=e.find(t=>"prim"in t&&"storage"===t.prim);if(!r||!Array.isArray(r.args))throw new ie(t,'The response.script.code has an element of type {prim: "storage"}, but its args is not an array');return new pe(r.args[0])}isExpressionExtended(t){return"prim"in t&&Array.isArray(t.args)}constructor(t){if(this.val=t,this[le]=!0,this.root=ee(t,0),this.root instanceof B)this.bigMap=this.root;else if(this.isExpressionExtended(t)&&"pair"===t.prim){const e=t.args[0];this.isExpressionExtended(e)&&"big_map"===e.prim&&(this.bigMap=new B(e,0,ee))}}removeTopLevelAnnotation(t){return(this.root instanceof G||this.root instanceof U)&&this.root.hasAnnotations()&&"object"==typeof t&&1===Object.keys(t).length?t[Object.keys(t)[0]]:t}Execute(t,e){const r=this.root.Execute(t,e);return this.removeTopLevelAnnotation(r)}Typecheck(t){if(this.root instanceof B&&Number.isInteger(Number(t)))return!0;if(this.root instanceof Pt&&t.ticketer&&t.value&&t.amount)return!0;if(this.root instanceof Nt&&t.ticketer&&t.value&&t.amount)return!0;if(this.root instanceof Z&&this.root.ValueSchema instanceof B)return!0;try{return this.root.EncodeObject(t),!0}catch(t){return!1}}ExecuteOnBigMapDiff(t,e){if(!this.bigMap)throw new se("Big map schema is undefined");if(!Array.isArray(t))throw new oe(`Big map diff must be an array, got: ${JSON.stringify(t)}`,t);const r=t.map(({key:t,value:e})=>({args:[t,e]}));return this.bigMap.Execute(r,e)}ExecuteOnBigMapValue(t,e){if(!this.bigMap)throw new se("Big map schema is undefined");return this.bigMap.ValueSchema.Execute(t,e)}EncodeBigMapKey(t){if(!this.bigMap)throw new se("Big map schema is undefined");try{return this.bigMap.KeySchema.ToBigMapKey(t)}catch(e){throw new ae("key",e,this.bigMap.KeySchema,t)}}Encode(t,e){try{return this.root.EncodeObject(t,e)}catch(r){if(r instanceof k)throw r;throw new ce("storage object",r,this.root,t,e)}}generateSchema(){return this.removeTopLevelAnnotation(this.root.generateSchema())}FindFirstInTopLevelPair(t,e){return this.findValue(this.root.val,t,e)}findValue(t,e,r){if(de(r,t))return e;if(Array.isArray(t)||"pair"===t.prim){const n=fe(t),i=fe(e,"Pair");if(void 0===n.args||void 0===i.args)throw new ue("Tokens have no arguments");if(n.args[0])return this.findValue(n.args[0],i.args[0],r)||this.findValue(n.args[1],i.args[1],r)}}findToken(t){return this.root.findAndReturnTokens(t,[])}}le=he;class ge{static fromRPCResponse(t){if(!t)throw new ie(t,"the RPC response is empty");if(!t.script)throw new ie(t,"the RPC response has no script");if(!Array.isArray(t.script.code))throw new ie(t,"The response.script.code should be an array");const e=t.script.code.find(t=>"prim"in t&&"parameter"===t.prim);if(!e)throw new ie(t,'The response.script.code should have an element of type {prim: "parameter"}');if(!Array.isArray(e.args))throw new ie(t,'The response.script.code has an element of type {prim: "parameter"}, but its args is not an array');return new ge(e.args[0])}get isMultipleEntryPoint(){return this.root instanceof U||this.root instanceof st&&this.root.subToken()instanceof U}get hasAnnotation(){return!this.isMultipleEntryPoint||"0"!==Object.keys(this.generateSchema())[0]}constructor(t){this.root=ee(t,0)}Execute(t,e){return this.root.Execute(t,e)}Encode(...t){try{return this.root.Encode(t.reverse())}catch(e){if(e instanceof k)throw e;throw new re("Unable to encode parameter",this.root,t,e)}}EncodeObject(t,e){try{return this.root.EncodeObject(t,e)}catch(e){if(e instanceof k)throw e;throw new re("Unable to encode parameter object",this.root,t,e)}}generateSchema(){return this.root.generateSchema()}ExtractSignatures(){return this.root.ExtractSignature()}}class me{static fromRPCResponse(t){const e=[],r=t&&t.script&&Array.isArray(t.script.code)&&t.script.code.filter(t=>"view"===t.prim);return r&&r.forEach(t=>{e.push(new me(t.args))}),e}constructor(t){if(!t)throw new ne(t,"the args are not defined");if(4!==t.length)throw new ne(t,"there should be exactly 4 arguments");if(!("string"in t[0])||!t[0].string)throw new ne(t,"The first argument should be a string, representing the view name. It should be in the form: { string: 'viewName' }");this.viewName=t[0].string,this.viewArgsType=t[1],this.viewReturnType=t[2],this.instructions=t[3],this.rootArgsType=ee(this.viewArgsType,0),this.rootReturnType=ee(this.viewReturnType,0)}encodeViewArgs(t){try{return this.rootArgsType.EncodeObject(t)}catch(e){throw new re(this.viewName,void 0,t,e)}}decodeViewResult(t,e){return this.rootReturnType.Execute(t,e)}extractArgsSchema(){return this.rootArgsType.generateSchema()}extractResultSchema(){return this.rootReturnType.generateSchema()}}class ye{constructor(t,e){this.tag=t,this.type=e}static fromMichelineValue(t){return new ye(t.annots?.[0],t.args?.[0])}static fromRPCResponse(t){const e=[];return t.script.code.forEach(t=>{"prim"in t&&"code"===t.prim&&"args"in t&&t.args&&e.push(...ye.extractEventsRecursively(t.args))}),ye.removeDuplicates(e)}static removeDuplicates(t){const e=[];return t.forEach(t=>{-1===e.findIndex(e=>e.tag===t.tag&&de(e.type,t.type))&&e.push(t)}),e}static extractEventsRecursively(t){return Array.isArray(t)?t.flatMap(t=>ye.extractEventsRecursively(t)):"prim"in t?"EMIT"===t.prim?[ye.fromMichelineValue(t)]:"args"in t&&t.args?t.args.flatMap(t=>ye.extractEventsRecursively(t)):[]:[]}}const be={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"}},3157(t,e,r){"use strict";r.r(e),r.d(e,{METADATA_BALANCE_UPDATES_CATEGORY:()=>N,OPERATION_METADATA:()=>I,OpKind:()=>K,PvmKind:()=>k,RpcClient:()=>F,RpcClientCache:()=>x,SmartRollupInputProofKind:()=>C,SmartRollupRefutationOptions:()=>L,SmartRollupRefuteGameEndedPlayerOutcomes:()=>D,SmartRollupRefuteGameEndedReason:()=>U,SmartRollupRefuteGameStatusOptions:()=>B,SmartRollupRefuteRevealProofKind:()=>M,VERSION:()=>H,castToBigNumber:()=>R,defaultChain:()=>S,defaultRPCOptions:()=>T});var n=r(2211),i=function t(e){var r,n,i,_=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,o,a,u,h,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>x?g.c=g.e=null:(g.e=u,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!s.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(c+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(u=d.indexOf("."))>-1&&(d=d.replace(".","")),(h=d.search(/e/i))>0?(u<0&&(u=h),u+=+d.slice(h+1),d=d.substring(0,h)):u<0&&(u=d.length)}else{if("string"!=p)throw Error(c+"String expected: "+t);for(b(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),u=h=0,f=d.length;h<f;h++)if(r.indexOf(o=d.charAt(h))<0){if("."==o){if(h>u){u=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,h=-1,u=0;continue}return i(g,t,e)}(u=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):u=d.length}for(h=0;48===d.charCodeAt(h);h++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(h,++f))if(f-=h,(u=u-h-1)>x)g.c=g.e=null;else if(u<R)g.c=[g.e=0];else{if(g.e=u,g.c=[],h=(u+1)%l,u<0&&(h+=l),h<f){for(h&&g.c.push(+d.slice(0,h)),f-=l;h<f;)g.c.push(+d.slice(h,h+=l));h=l-(d=d.slice(h)).length}else h-=f;for(;h--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:b(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=m(t.c),c=1==n||2==n&&(o<=T||o>=P)?w(c,o):E(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=m(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=w(c,s)}else if(e-=o+(2===n&&s>o),c=E(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=y(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*l-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,c,h,d,p,g,m=t.c,y=f;if(m){t:{for(i=1,h=m[0];h>=10;h/=10,i++);if((s=e-i)<0)s+=l,c=e,d=m[p=0],g=a(d/y[i-c-1]%10);else if((p=o((s+1)/l))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));d=g=0,i=1,c=(s%=l)-l+1}else{for(d=h=m[p],i=1;h>=10;h/=10,i++);g=(c=(s%=l)-l+i)<0?0:a(d/y[i-c-1]%10)}if(n=n||e<0||null!=m[p+1]||(c<0?d:d%y[i-c-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?c>0?d/y[i-c]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(l-e%l)%l],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,h=1,p--):(m.length=p+1,h=y[l-s],m[p]=c>0?a(d/y[i-c]%y[c])*h:0),n)for(;;){if(0==p){for(s=1,c=m[0];c>=10;c/=10,s++);for(c=m[0]+=h,h=1;c>=10;c/=10,h++);s!=h&&(t.e++,m[0]==u&&(m[0]=1));break}if(m[p]+=h,m[p]!=u)break;m[p--]=0,h=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=T||r>=P?w(e,r):E(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(c+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(b(r=t[e],0,p,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(b(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(b(r[0],-p,0,e),b(r[1],0,p,e),T=r[0],P=r[1]):(b(r,-p,p,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)b(r[0],-p,-1,e),b(r[1],1,p,e),R=r[0],x=r[1];else{if(b(r,-p,p,e),!r)throw Error(c+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(c+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(c+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(b(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(b(r=t[e],0,p,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(c+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(c+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-p||i>p||i!==a(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%l)<1&&(e+=l),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=u||r!==a(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return a(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,u,h=0,d=[],g=new M(A);if(null==t?t=O:b(t,0,p),s=o(t/l),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));h<s;)(u=131072*r[h]+(r[h+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[h]=n[0],r[h+1]=n[1]):(d.push(u%1e14),h+=2);h=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(c+"crypto unavailable");for(r=crypto.randomBytes(s*=7);h<s;)(u=281474976710656*(31&r[h])+1099511627776*r[h+1]+4294967296*r[h+2]+16777216*r[h+3]+(r[h+4]<<16)+(r[h+5]<<8)+r[h+6])>=9e15?crypto.randomBytes(7).copy(r,h):(d.push(u%1e14),h+=7);h=s/7}if(!I)for(;h<s;)(u=e())<9e15&&(d[h++]=u%1e14);for(s=d[--h],t%=l,s&&t&&(u=f[l-t],d[h]=a(s/u)*u);0===d[h];d.pop(),h--);if(h<0)d=[i=0];else{for(i=-1;0===d[0];d.splice(0,1),i-=l);for(h=1,u=d[0];u>=10;u/=10,h++);h<l&&(i-=l-h)}return g.e=i,g.c=d,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,y=n.indexOf("."),b=O,v=S;for(y>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-y),k=h,g.c=e(E(m(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),y=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=y||f)&&(0==v||v==(d.s<0?3:2)):y>h||y==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?E(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=E(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%d,l=e/d|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%d)+(n=l*s+(o=t[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,c){var h,f,d,p,m,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,c||(c=u,f=g(n.e/l)-g(i.e/l),x=x/l|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(m=a(c/(N[0]+1)))>1&&(N=t(N,m,c),I=t(I,m,c),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=c/2&&T++;do{if(m=0,(h=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*c+(E[1]||0)),(m=a(A/T))>1)for(m>=c&&(m=c-1),b=(y=t(N,m,c)).length,_=E.length;1==e(y,E,b,_);)m--,r(y,P<b?R:N,b,c),b=y.length,h=1;else 0==m&&(h=m=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,c),_=E.length,-1==h)for(;e(N,E,P,_)<1;)m++,r(E,P<_?R:N,_,c),_=E.length}else 0===h&&(m++,E=[0]);w[d++]=m,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(c==u){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*l-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var u,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return u="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=u?t:e}),a&&(u=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,u);throw Error(c+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),_.absoluteValue=_.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return y(this,new M(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,s=this;if(null!=t)return b(t,0,p),null==e?e=S:b(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-g(this.e/l))*l,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new M(t,e),O,S)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new M(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,s,u,h,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(c+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),u=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),u?t.s*(2-v(t)):+F(t))),e?d.mod(e):d;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||u&&p.c[1]>=24e7:p.c[0]<8e13||u&&p.c[0]<=9999975e7)))return s=p.s<0&&v(t)?-0:0,p.e>-1&&(s=1/s),new M(h?1/s:s);k&&(s=o(k/l+2))}for(u?(r=new M(.5),h&&(t.s=1),f=v(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=a(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=v(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(h&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},_.integerValue=function(t){var e=new M(this);return null==t?t=S:b(t,0,8),H(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===y(this,new M(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return y(this,new M(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=y(this,new M(t,e)))||0===e},_.isInteger=function(){return!!this.c&&g(this.e/l)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return y(this,new M(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=y(this,new M(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/l,h=t.e/l,f=o.c,d=t.c;if(!c||!h){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=g(c),h=g(h),f=f.slice(),a=c-h){for((s=a<0)?(a=-a,i=f):(h=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=u-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=u}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--h);return f[0]?K(t,f,h):(t.s=3==S?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,s,o,a,c,h,f,p,m,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=g(E.e/l)+g(t.e/l),t.s*=E.s,(c=_.length)<(p=A.length)&&(b=_,_=A,A=b,i=c,c=p,p=i),i=c+p,b=[];i--;b.push(0));for(v=u,w=d,i=p;--i>=0;){for(r=0,m=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((h=m*(h=_[--o]%w)+(a=y*h+(f=_[o]/w|0)*m)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=h%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},_.negated=function(){var t=new M(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/l,o=t.e/l,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=g(s),o=g(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/u|0,a[e]=u===a[e]?0:a[e]%u;return i&&(a=[i].concat(a),++o),K(t,a,o)},_.precision=_.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return b(t,1,p),null==e?e=S:b(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*l+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},_.shiftedBy=function(t){return b(t,-9007199254740991,h),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=m(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=g((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),m(s.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},_.toExponential=function(t,e){return null!=t&&(b(t,0,p),t++),B(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(b(t,0,p),t=t+this.e+1),B(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(c+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,u=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(u&&(s=a,a=u,u=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);u>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,s,o,a,u,h,d,p,g,y,b=this,v=b.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(A)))throw Error(c+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+F(u));if(!v)return new M(b);for(e=new M(A),d=n=new M(A),i=h=new M(A),y=m(v),o=e.e=y.length-b.e-1,e.c[0]=f[(a=o%l)<0?l+a:a],t=!t||u.comparedTo(e)>0?o>0?e:d:u,a=x,x=1/0,u=new M(y),h.c[0]=0;p=r(u,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,d=h.plus(p.times(s=d)),h=s,e=u.minus(p.times(s=e)),u=s;return s=r(t.minus(n),i,0,1),h=h.plus(s.times(d)),n=n.plus(s.times(i)),h.s=d.s=b.s,g=r(d,i,o*=2,S).minus(b).abs().comparedTo(r(h,n,o,S).minus(b).abs())<1?[d,i]:[h,n],x=a,g},_.toNumber=function(){return+F(this)},_.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},_.toPrecision=function(t,e){return null!=t&&b(t,1,p),B(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?w(m(r.c),s):E(m(r.c),s,"0"):(b(t,2,C.length,"Base"),e=n(E(m(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return F(this)},_._isBigNumber=!0,null!=e&&M.set(e);return M}(),s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,a=Math.floor,c="[BigNumber Error] ",u=1e14,l=14,h=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,p=1e9;function g(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=l-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function y(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(t,e,r,n){if(t<e||t>r||t!==a(t))throw Error(c+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function v(t){var e=t.c.length-1;return g(t.e/l)==e&&t.c[e]%2!=0}function w(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function E(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const _=i;var A=r(2403),O=r(6571);const S="main",T={block:"head"};var P;function R(t,e){const r=Array.isArray(t);void 0===e&&(e=Object.keys(t));const n=r?[]:{};return e.forEach(e=>{const r=t[e];let i;if(void 0!==r){if(Array.isArray(r))return i=R(r),void(n[e]=i);i=new _(r),n[e]=i}}),n}!function(t){t.GET_BAKING_RIGHTS="getBakingRights",t.GET_BALLOTS="getBallots",t.GET_BALLOT_LIST="getBallotList",t.GET_BIG_MAP_EXPR="getBigMapExpr",t.GET_BLOCK_HASH="getBlockHash",t.GET_BLOCK="getBlock",t.GET_BLOCK_HEADER="getBlockHeader",t.GET_BLOCK_METADATA="getBlockMetadata",t.GET_BALANCE="getBalance",t.GET_SPENDABLE="getSpendable",t.GET_BALANCE_AND_FROZEN_BONDS="getBalanceAndFrozenBonds",t.GET_SPENDABLE_AND_FROZEN_BONDS="getSpendableAndFrozenBonds",t.GET_FULL_BALANCE="getFullBalance",t.GET_STAKED_BALANCE="getStakedBalance",t.GET_UNSTAKED_FINALIZABLE_BALANCE="getUnstakedFinalizableBalance",t.GET_UNSTAKED_FROZEN_BALANCE="getUnstakedFrozenBalance",t.GET_UNSTAKE_REQUESTS="getUnstakeRequests",t.GET_CHAIN_ID="getChainId",t.GET_CONSTANTS="getConstants",t.GET_CONTRACT="getContract",t.GET_CURRENT_PERIOD="getCurrentPeriod",t.GET_CURRENT_PROPOSAL="getCurrentProposal",t.GET_CURRENT_QUORUM="getCurrentQuorum",t.GET_DELEGATE="getDelegate",t.GET_ALL_DELEGATES="getAllDelegates",t.GET_DELEGATES="getDelegates",t.GET_VOTING_INFO="getVotingInfo",t.GET_ACTIVE_STAKING_PARAMETERS="getActiveStakingParameters",t.GET_PENDING_STAKING_PARAMETERS="getPendingStakingParameters",t.GET_ATTESTATION_RIGHTS="getAttestationRights",t.GET_ENTRYPOINTS="getEntrypoints",t.GET_LIVE_BLOCKS="getLiveBlocks",t.GET_MANAGER_KEY="getManagerKey",t.GET_NORMALIZED_SCRIPT="getNormalizedScript",t.GET_PROPOSALS="getProposals",t.GET_PROTOCOLS="getProtocols",t.GET_SAPLING_DIFF_BY_CONTRACT="getSaplingDiffByContract",t.GET_PROTOCOL_ACTIVATIONS="getProtocolActivations",t.GET_SAPLING_DIFF_BY_ID="getSaplingDiffById",t.GET_SCRIPT="getScript",t.GET_STORAGE="getStorage",t.GET_SUCCESSOR_PERIOD="getSuccessorPeriod",t.GET_VOTES_LISTINGS="getVotesListings",t.PACK_DATA="packData",t.GET_STORAGE_USED_SPACE="getStorageUsedSpace",t.GET_STORAGE_PAID_SPACE="getStoragePaidSpace",t.GET_TICKET_BALANCE="getTicketBalance",t.GET_ALL_TICKET_BALANCES="getAllTicketBalances",t.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE="getAdaptiveIssuanceLaunchCycle",t.GET_PENDING_OPERATIONS="getPendingOperations",t.GET_MEMPOOL_FILTER="getMempoolFilter",t.GET_DESTINATION_INDEX="getDestinationIndex"}(P||(P={}));class x{constructor(t,e=1e3){this.rpcClient=t,this.ttl=e,this._cache={}}getAllCachedData(){return this._cache}deleteAllCachedData(){for(const t in this._cache)delete this._cache[t]}formatCacheKey(t,e,r,n){let i="";return r.forEach(t=>{i="object"==typeof t?i+JSON.stringify(t)+"/":i+t+"/"}),n?`${t}/${e}/${i}${JSON.stringify(n)}/`:`${t}/${e}/${i}`}has(t){return t in this._cache}get(t){return this._cache[t].response}put(t,e){const r=setTimeout(()=>this.remove(t),this.ttl);Object.assign(this._cache,{[t]:{handle:r,response:e}})}remove(t){t in this._cache&&delete this._cache[t]}validateAddress(t){const e=(0,A.validateAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidAddressError(t,e)}validateContract(t){const e=(0,A.validateContractAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidContractAddressError(t,e)}async getBlockHash({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_HASH,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockHash({block:t});return this.put(e,r),r}}async getLiveBlocks({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_LIVE_BLOCKS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getLiveBlocks({block:t});return this.put(e,r),r}}async getBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBalance(t,{block:e});return this.put(r,n),n}}async getSpendable(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SPENDABLE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSpendable(t,{block:e});return this.put(r,n),n}}async getBalanceAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALANCE_AND_FROZEN_BONDS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBalanceAndFrozenBonds(t,{block:e});return this.put(r,n),n}}async getSpendableAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SPENDABLE_AND_FROZEN_BONDS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSpendableAndFrozenBonds(t,{block:e});return this.put(r,n),n}}async getFullBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_FULL_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getFullBalance(t,{block:e});return this.put(r,n),n}}async getStakedBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STAKED_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStakedBalance(t,{block:e});return this.put(r,n),n}}async getUnstakedFinalizableBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKED_FINALIZABLE_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakedFinalizableBalance(t,{block:e});return this.put(r,n),n}}async getUnstakedFrozenBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKED_FROZEN_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakedFrozenBalance(t,{block:e});return this.put(r,n),n}}async getUnstakeRequests(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKE_REQUESTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakeRequests(t,{block:e});return this.put(r,n),n}}async getStorage(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStorage(t,{block:e});return this.put(r,n),n}}async getScript(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SCRIPT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getScript(t,{block:e});return this.put(r,n),n}}async getNormalizedScript(t,e={unparsing_mode:"Readable"},{block:r}=T){this.validateContract(t);const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_NORMALIZED_SCRIPT,[r,t],e);if(this.has(n))return this.get(n);{const i=this.rpcClient.getNormalizedScript(t,e,{block:r});return this.put(n,i),i}}async getContract(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CONTRACT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getContract(t,{block:e});return this.put(r,n),n}}async getManagerKey(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_MANAGER_KEY,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getManagerKey(t,{block:e});return this.put(r,n),n}}async getDelegate(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DELEGATE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDelegate(t,{block:e});return this.put(r,n),n}}async getBigMapExpr(t,e,{block:r}=T){const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BIG_MAP_EXPR,[r,t,e]);if(this.has(n))return this.get(n);{const i=this.rpcClient.getBigMapExpr(t,e,{block:r});return this.put(n,i),i}}async getAllDelegates(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ALL_DELEGATES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAllDelegates(t,{block:e});return this.put(r,n),n}}async getDelegates(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DELEGATES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDelegates(t,{block:e});return this.put(r,n),n}}async getVotingInfo(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_VOTING_INFO,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getVotingInfo(t,{block:e});return this.put(r,n),n}}async getConstants({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CONSTANTS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getConstants({block:t});return this.put(e,r),r}}async getBlock({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlock({block:t});return this.put(e,r),r}}async getBlockHeader({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_HEADER,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockHeader({block:t});return this.put(e,r),r}}async getBlockMetadata({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_METADATA,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockMetadata({block:t});return this.put(e,r),r}}async getBakingRights(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BAKING_RIGHTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBakingRights(t,{block:e});return this.put(r,n),n}}async getAttestationRights(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ATTESTATION_RIGHTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAttestationRights(t,{block:e});return this.put(r,n),n}}async getBallotList({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALLOT_LIST,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBallotList({block:t});return this.put(e,r),r}}async getBallots({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALLOTS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBallots({block:t});return this.put(e,r),r}}async getCurrentProposal({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_PROPOSAL,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentProposal({block:t});return this.put(e,r),r}}async getCurrentQuorum({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_QUORUM,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentQuorum({block:t});return this.put(e,r),r}}async getVotesListings({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_VOTES_LISTINGS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getVotesListings({block:t});return this.put(e,r),r}}async getProposals({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROPOSALS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProposals({block:t});return this.put(e,r),r}}async forgeOperations(t,{block:e}=T){return this.rpcClient.forgeOperations(t,{block:e})}async injectOperation(t){return this.rpcClient.injectOperation(t)}async preapplyOperations(t,{block:e}=T){return this.rpcClient.preapplyOperations(t,{block:e})}async getEntrypoints(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ENTRYPOINTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getEntrypoints(t,{block:e});return this.put(r,n),n}}async simulateOperation(t,{block:e}=T){return this.rpcClient.simulateOperation(t,{block:e})}async runCode(t,{block:e}=T){return this.rpcClient.runCode(t,{block:e})}async runScriptView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.rpcClient.runScriptView({unparsing_mode:t,...e},{block:r})}async runView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.rpcClient.runView({unparsing_mode:t,...e},{block:r})}async getChainId(){const t=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CHAIN_ID,[]);if(this.has(t))return this.get(t);{const e=this.rpcClient.getChainId();return this.put(t,e),e}}async packData(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.PACK_DATA,[e],t);if(this.has(r))return this.get(r);{const n=this.rpcClient.packData(t,{block:e});return this.put(r,n),n}}getRpcUrl(){return this.rpcClient.getRpcUrl()}async getCurrentPeriod({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_PERIOD,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentPeriod({block:t});return this.put(e,r),r}}async getSuccessorPeriod({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SUCCESSOR_PERIOD,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getSuccessorPeriod({block:t});return this.put(e,r),r}}async getSaplingDiffById(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SAPLING_DIFF_BY_ID,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSaplingDiffById(t,{block:e});return this.put(r,n),n}}async getSaplingDiffByContract(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SAPLING_DIFF_BY_CONTRACT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSaplingDiffByContract(t,{block:e});return this.put(r,n),n}}async getProtocols({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROTOCOLS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProtocols({block:t});return this.put(e,r),r}}async getProtocolActivations(t=""){if(t){const e=(0,A.validateProtocol)(t);if(e!==A.ValidationResult.VALID)throw new A.InvalidProtocolHashError(t,e)}const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROTOCOL_ACTIVATIONS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProtocolActivations(t);return this.put(e,r),r}}async getStorageUsedSpace(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE_USED_SPACE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStorageUsedSpace(t,{block:e});return this.put(r,n),n}}async getStoragePaidSpace(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE_PAID_SPACE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStoragePaidSpace(t,{block:e});return this.put(r,n),n}}async getTicketBalance(t,e,{block:r}=T){const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_TICKET_BALANCE,[r,t],e);if(this.has(n))return this.get(n);{const i=this.rpcClient.getTicketBalance(t,e,{block:r});return this.put(n,i),i}}async getAllTicketBalances(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ALL_TICKET_BALANCES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAllTicketBalances(t,{block:e});return this.put(r,n),n}}async getAdaptiveIssuanceLaunchCycle({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getAdaptiveIssuanceLaunchCycle({block:t});return this.put(e,r),r}}async getPendingOperations(t={}){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PENDING_OPERATIONS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getPendingOperations(t);return this.put(e,r),r}}async getMempoolFilter(t={}){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_MEMPOOL_FILTER,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getMempoolFilter(t);return this.put(e,r),r}}async getActiveStakingParameters(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ACTIVE_STAKING_PARAMETERS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getActiveStakingParameters(t,{block:e});return this.put(r,n),n}}async getPendingStakingParameters(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PENDING_STAKING_PARAMETERS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getPendingStakingParameters(t,{block:e});return this.put(r,n),n}}async getDestinationIndex(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DESTINATION_INDEX,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDestinationIndex(t,{block:e});return this.put(r,n),n}}}var I,N,k,L,C,M,B,D,U,K;!function(t){t.TOO_LARGE="too large"}(I||(I={})),function(t){t.ACTIVATION="activation",t.ATTESTATION="attestation",t.ATTESTATIONS_AGGREGATE="attestations_aggregate",t.ATTESTATION_WITH_DAL="attestation_with_dal",t.ATTESTING_REWARDS="attesting rewards",t.BAKING_BONUSES="baking bonuses",t.BAKING_REWARDS="baking rewards",t.BALLOT="ballot",t.BLOCK_FEES="block fees",t.BONDS="bonds",t.BOOTSTRAP="bootstrap",t.BURNED="burned",t.COMMITMENT="commitment",t.DAL_ATTESTING_REWARDS="dal attesting rewards",t.DAL_ENTRAPMENT_EVIDENCE="dal_entrapment_evidence",t.DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.DELEGATE_DENOMINATOR="delegate_denominator",t.DELEGATION="delegation",t.DELEGATOR_NUMERATOR="delegator_numerator",t.DEPOSITS="deposits",t.DOUBLE_ATTESTATION_EVIDENCE="double_attestation_evidence",t.DOUBLE_BAKING_EVIDENCE="double_baking_evidence",t.DOUBLE_ENDORSEMENT_EVIDENCE="double_endorsement_evidence",t.DOUBLE_PREATTESTATION_EVIDENCE="double_preattestation_evidence",t.DOUBLE_PREENDORSEMENT_EVIDENCE="double_preendorsement_evidence",t.DRAIN_DELEGATE="drain_delegate",t.ENDORSEMENT="endorsement",t.ENDORSEMENT_WITH_DAL="endorsement_with_dal",t.EVENT="event",t.FAILING_NOOP="failing_noop",t.INCREASE_PAID_STORAGE="increase_paid_storage",t.INVOICE="invoice",t.LOST_ATTESTING_REWARDS="lost attesting rewards",t.LOST_DAL_ATTESTING_REWARDS="lost dal attesting rewards",t.MINTED="minted",t.NONCE_REVELATION_REWARDS="nonce revelation rewards",t.ORIGINATION="origination",t.PREATTESTATION="preattestation",t.PREATTESTATIONS_AGGREGATE="preattestations_aggregate",t.PREENDORSEMENT="preendorsement",t.PROPOSALS="proposals",t.PUNISHMENTS="punishments",t.REGISTER_GLOBAL_CONSTANT="register_global_constant",t.REVEAL="reveal",t.SEED_NONCE_REVELATION="seed_nonce_revelation",t.SET_DEPOSITS_LIMIT="set_deposits_limit",t.SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.SMART_ROLLUP_CEMENT="smart_rollup_cement",t.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.SMART_ROLLUP_PUBLISH="smart_rollup_publish",t.SMART_ROLLUP_RECOVER_BOND="smart_rollup_recover_bond",t.SMART_ROLLUP_REFUTATION_PUNISHMENTS="smart_rollup_refutation_punishments",t.SMART_ROLLUP_REFUTATION_REWARDS="smart_rollup_refutation_rewards",t.SMART_ROLLUP_REFUTE="smart_rollup_refute",t.SMART_ROLLUP_TIMEOUT="smart_rollup_timeout",t.STORAGE_FEES="storage fees",t.SUBSIDY="subsidy",t.TICKET_UPDATES="ticket_updates",t.TRANSACTION="transaction",t.TRANSFER_TICKET="transfer_ticket",t.UNSTAKED_DEPOSITS="unstaked_deposits",t.UPDATE_COMPANION_KEY="update_companion_key",t.UPDATE_CONSENSUS_KEY="update_consensus_key",t.VDF_REVELATION="vdf_revelation"}(N||(N={})),function(t){t.WASM2="wasm_2_0_0",t.ARITH="arith",t.RISCV="riscv"}(k||(k={})),function(t){t.START="start",t.MOVE="move"}(L||(L={})),function(t){t.INBOX_PROOF="inbox_proof",t.REVEAL_PROOF="reveal_proof",t.FIRST_INPUT="first_input"}(C||(C={})),function(t){t.RAW_DATA_PROOF="raw_data_proof",t.METADATA_PROOF="metadata_proof",t.DAL_PAGE_PROOF="dal_page_proof",t.DAL_PARAMETERS_PROOF="dal_parameters_proof"}(M||(M={})),function(t){t.ONGOING="ongoing",t.ENDED="ended"}(B||(B={})),function(t){t.LOSER="loser",t.DRAW="draw"}(D||(D={})),function(t){t.CONFLICT_RESOLVED="conflict_resolved",t.TIMEOUT="timeout"}(U||(U={})),function(t){t.ORIGINATION="origination",t.DELEGATION="delegation",t.REVEAL="reveal",t.TRANSACTION="transaction",t.ACTIVATION="activate_account",t.ATTESTATION="attestation",t.ENDORSEMENT="endorsement",t.PREATTESTATION="preattestation",t.PREENDORSEMENT="preendorsement",t.SET_DEPOSITS_LIMIT="set_deposits_limit",t.DOUBLE_PREATTESTATION_EVIDENCE="double_preattestation_evidence",t.DOUBLE_PREENDORSEMENT_EVIDENCE="double_preendorsement_evidence",t.ATTESTATION_WITH_DAL="attestation_with_dal",t.ENDORSEMENT_WITH_DAL="endorsement_with_dal",t.SEED_NONCE_REVELATION="seed_nonce_revelation",t.DOUBLE_ATTESTATION_EVIDENCE="double_attestation_evidence",t.DOUBLE_ENDORSEMENT_EVIDENCE="double_endorsement_evidence",t.DOUBLE_BAKING_EVIDENCE="double_baking_evidence",t.PROPOSALS="proposals",t.BALLOT="ballot",t.FAILING_NOOP="failing_noop",t.REGISTER_GLOBAL_CONSTANT="register_global_constant",t.TRANSFER_TICKET="transfer_ticket",t.INCREASE_PAID_STORAGE="increase_paid_storage",t.UPDATE_CONSENSUS_KEY="update_consensus_key",t.DRAIN_DELEGATE="drain_delegate",t.VDF_REVELATION="vdf_revelation",t.EVENT="event",t.TICKET_UPDATES="ticket_updates",t.SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.SMART_ROLLUP_PUBLISH="smart_rollup_publish",t.SMART_ROLLUP_CEMENT="smart_rollup_cement",t.SMART_ROLLUP_RECOVER_BOND="smart_rollup_recover_bond",t.SMART_ROLLUP_REFUTE="smart_rollup_refute",t.SMART_ROLLUP_TIMEOUT="smart_rollup_timeout",t.DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.DAL_ENTRAPMENT_EVIDENCE="dal_entrapment_evidence",t.PREATTESTATIONS_AGGREGATE="preattestations_aggregate",t.ATTESTATIONS_AGGREGATE="attestations_aggregate",t.UPDATE_COMPANION_KEY="update_companion_key",t.DOUBLE_CONSENSUS_OPERATION_EVIDENCE="double_consensus_operation_evidence"}(K||(K={}));const H={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"};class F{constructor(t,e=S,r=new n.HttpBackend){this.url=t,this.chain=e,this.httpBackend=r}createURL(t){let e=this.url;for(;e.endsWith("/");)e=e.slice(0,-1);return`${e}${t}`}validateAddress(t){const e=(0,A.validateAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidAddressError(t,e)}validateContract(t){const e=(0,A.validateContractAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidContractAddressError(t,e)}async getBlockHash({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/hash`),method:"GET"})}async getLiveBlocks({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/live_blocks`),method:"GET"})}async getBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/balance`),method:"GET"});return new _(r)}async getSpendable(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/spendable`),method:"GET"});return new _(r)}async getBalanceAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/balance_and_frozen_bonds`),method:"GET"});return new _(r)}async getSpendableAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/spendable_and_frozen_bonds`),method:"GET"});return new _(r)}async getFullBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/full_balance`),method:"GET"});return new _(r)}async getStakedBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/staked_balance`),method:"GET"});return new _(r)}async getUnstakedFinalizableBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstaked_finalizable_balance`),method:"GET"});return new _(r)}async getUnstakedFrozenBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstaked_frozen_balance`),method:"GET"});return new _(r)}async getUnstakeRequests(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstake_requests`),method:"GET"});return null===r?null:{finalizable:r.finalizable.map(({amount:t,...e})=>({...e,amount:R({amount:t},["amount"]).amount})),unfinalizable:{delegate:r.unfinalizable.delegate,requests:r.unfinalizable.requests.map(({amount:t,cycle:e})=>({cycle:e,amount:R({amount:t},["amount"]).amount}))}}}async getStorage(t,{block:e}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage`),method:"GET"})}async getScript(t,{block:e}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/script`),method:"GET"})}async getNormalizedScript(t,e={unparsing_mode:"Readable"},{block:r}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/contracts/${t}/script/normalized`),method:"POST"},e)}async getContract(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}`),method:"GET"});return{...r,balance:new _(r.balance)}}async getManagerKey(t,{block:e}=T){return this.validateAddress(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/manager_key`),method:"GET"})}async getDelegate(t,{block:e}=T){let r;this.validateAddress(t);try{r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/delegate`),method:"GET"})}catch(t){if(!(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND))throw t;r=null}return r}async getBigMapExpr(t,e,{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/big_maps/${t}/${e}`),method:"GET"})}async getAllDelegates(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates`),method:"GET",query:t})}async getDelegates(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}`),method:"GET"}),n=R(r,["balance","full_balance","current_frozen_deposits","frozen_deposits","frozen_balance","frozen_deposits_limit","staking_balance","delegated_balance","voting_power","total_delegated_stake","staking_denominator"]);return r.frozen_balance_by_cycle?{...r,...n,frozen_balance_by_cycle:r.frozen_balance_by_cycle.map(({deposit:t,deposits:e,fees:r,rewards:n,...i})=>{const s=R({deposit:t,deposits:e,fees:r,rewards:n},["deposit","deposits","fees","rewards"]);return{...i,deposit:s.deposit,deposits:s.deposits,fees:s.fees,rewards:s.rewards}})}:{...r,...n}}async getVotingInfo(t,{block:e}=T){return this.validateAddress(t),await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/voting_info`),method:"GET"})}async getConstants({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/context/constants`),method:"GET"}),r=R(e,["time_between_blocks","hard_gas_limit_per_operation","hard_gas_limit_per_block","proof_of_work_threshold","tokens_per_roll","seed_nonce_revelation_tip","block_security_deposit","endorsement_security_deposit","block_reward","endorsement_reward","cost_per_byte","hard_storage_limit_per_operation","test_chain_duration","baking_reward_per_endorsement","delay_per_missing_endorsement","minimal_block_delay","liquidity_baking_subsidy","cache_layout","baking_reward_fixed_portion","baking_reward_bonus_per_slot","endorsing_reward_per_slot","double_baking_punishment","delay_increment_per_round","tx_rollup_commitment_bond","vdf_difficulty","sc_rollup_stake_amount","minimal_stake"]);return{...e,...r}}async getBlock({block:t,version:e}=T){const r={url:this.createURL(`/chains/${this.chain}/blocks/${t}`),method:"GET"};return void 0!==e&&(r.query={version:e}),await this.httpBackend.createRequest(r)}async getBlockHeader({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/header`),method:"GET"})}async getBlockMetadata({block:t,version:e}=T){const r={url:this.createURL(`/chains/${this.chain}/blocks/${t}/metadata`),method:"GET"};return void 0!==e&&(r.query={version:e}),await this.httpBackend.createRequest(r)}async getBakingRights(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/baking_rights`),method:"GET",query:t})}async getAttestationRights(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/attestation_rights`),method:"GET",query:t})}async getBallotList({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/ballot_list`),method:"GET"})}async getBallots({block:t}=T){return R(await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/ballots`),method:"GET"}),["yay","nay","pass"])}async getCurrentProposal({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_proposal`),method:"GET"})}async getCurrentQuorum({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_quorum`),method:"GET"})}async getVotesListings({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/listings`),method:"GET"});return e.map(t=>(t.voting_power&&(t.voting_power=new _(t.voting_power)),t)),e}async getProposals({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/proposals`),method:"GET"});return e.map(t=>t[1]=new _(t[1])),e}async forgeOperations(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/forge/operations`),method:"POST"},t)}async injectOperation(t){return this.httpBackend.createRequest({url:this.createURL("/injection/operation"),method:"POST"},t)}async preapplyOperations(t,{block:e,version:r}=T){const n={url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/preapply/operations`),method:"POST"};return void 0!==r&&(n.query={version:r}),await this.httpBackend.createRequest(n,t)}async getEntrypoints(t,{block:e}=T){this.validateContract(t);return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/entrypoints`),method:"GET"})}async simulateOperation(t,{block:e,version:r}=T){const n={url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/simulate_operation`),method:"POST"};return void 0!==r&&(n.query={version:r}),await this.httpBackend.createRequest(n,t)}async runCode(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/run_code`),method:"POST"},t)}async runScriptView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/helpers/scripts/run_script_view`),method:"POST"},{unparsing_mode:t,...e})}async runView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/helpers/scripts/run_view`),method:"POST"},{unparsing_mode:t,...e})}async getChainId(){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/chain_id`),method:"GET"})}async packData(t,{block:e}=T){const{gas:r,...n}=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/pack_data`),method:"POST"},t);let i=r;if("string"==typeof r)try{i=new _(r)}catch{i=r}return{gas:i,...n}}getRpcUrl(){return this.url}async getCurrentPeriod({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_period`),method:"GET"})}async getSuccessorPeriod({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/successor_period`),method:"GET"})}async getSaplingDiffById(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/sapling/${t}/get_diff`),method:"GET"})}async getSaplingDiffByContract(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/single_sapling_get_diff`),method:"GET"})}async getProtocols({block:t}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/protocols`),method:"GET"})}async getProtocolActivations(t=""){if(t){const e=(0,A.validateProtocol)(t);if(e!==A.ValidationResult.VALID)throw new A.InvalidProtocolHashError(t,e)}return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/protocols/${t}`),method:"GET"})}async getStorageUsedSpace(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage/used_space`),method:"GET"})}async getStoragePaidSpace(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage/paid_space`),method:"GET"})}async getTicketBalance(t,e,{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/contracts/${t}/ticket_balance`),method:"POST"},e)}async getAllTicketBalances(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/all_ticket_balances`),method:"GET"})}async getAdaptiveIssuanceLaunchCycle({block:t}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/context/adaptive_issuance_launch_cycle`),method:"GET"})}async getPendingOperations(t={}){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/mempool/pending_operations`),method:"GET",query:t})}async getMempoolFilter(t={}){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/mempool/filter`),method:"GET",query:t})}async getActiveStakingParameters(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/active_staking_parameters`),method:"GET"})}async getPendingStakingParameters(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/pending_staking_parameters`),method:"GET"})}async getDestinationIndex(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/destination/${t}/index`),method:"GET"})}}},8691(t,e,r){"use strict";r.r(e),r.d(e,{ECDSA:()=>fe,Ed25519:()=>ue,Hard:()=>se,InMemorySigner:()=>Ae,InvalidPassphraseError:()=>bt,Path:()=>de,VERSION:()=>Se,generateSecretKey:()=>pe,publicKeyFromString:()=>Oe});var n=r(2613),i=r(2403),s=r(2100),o=r.n(s),a=r(1032),c=r(3156),u=r(404),l=r(6571),h=r(2823),f=r.n(h),d=r(1188);function p(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function g(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r}function m(t,e=""){if("number"!=typeof t){throw new TypeError(`${e&&`"${e}" `}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){throw new RangeError(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}}function y(t,e,r=""){const n=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&"BYTES_PER_ELEMENT"in i&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;if(!n||o&&s!==e){const i=(r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${s}`:"type="+typeof t);if(!n)throw new TypeError(i);throw new RangeError(i)}return t}function b(t){if("function"!=typeof t||"function"!=typeof t.create)throw new TypeError("Hash must wrapped by utils.createHasher");if(m(t.outputLen),m(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function v(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function w(t,e){y(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function E(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function _(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function A(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function O(t,e){return t<<32-e|t>>>e}"function"==typeof SuppressedError&&SuppressedError;const S=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function T(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const P=S?t=>t:t=>T(t)>>>0;const R=S?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=T(t[e]);return t};function x(t,e=""){return"string"==typeof t?function(t){if("string"!=typeof t)throw new TypeError("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t):y(t,void 0,e)}function I(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}const N=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])}),k=Uint8Array.from([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,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]);function L(t,e,r){return t&e^~t&r}function C(t,e,r){return t&e^t&r^e&r}class M{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,r,n){this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=A(this.buffer)}update(t){v(this),y(t);const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o===n){const e=A(t);for(;n<=i-s;s+=n)this.process(e,s);continue}r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){v(this),w(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,_(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let t=s;t<n;t++)e[t]=0;r.setBigUint64(n-8,BigInt(8*this.length),i),this.process(r,0);const o=A(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)o.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=i,t.length=n,t.pos=o,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const B=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),D=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),U=BigInt(2**32-1),K=BigInt(32);function H(t,e=!1){return e?{h:Number(t&U),l:Number(t>>K&U)}:{h:0|Number(t>>K&U),l:0|Number(t&U)}}const F=(t,e,r)=>t>>>r,G=(t,e,r)=>t<<32-r|e>>>r,V=(t,e,r)=>t>>>r|e<<32-r,j=(t,e,r)=>t<<32-r|e>>>r,$=(t,e,r)=>t<<64-r|e>>>r-32,z=(t,e,r)=>t>>>r-32|e<<64-r;function q(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const W=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Z=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Y=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),X=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,J=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Q=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,tt=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),et=new Uint32Array(32);function rt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=et[2*t],u=et[2*t+1],l=et[2*e],h=et[2*e+1],f=et[2*r],d=et[2*r+1],p=et[2*n],g=et[2*n+1],m=W(c,l,o);var y,b;u=Z(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:(b=p,b),Dl:(y=g,y)}),({h:d,l:f}=q(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:V(h,l,24),Bl:j(h,l,24)}),et[2*t]=c,et[2*t+1]=u,et[2*e]=l,et[2*e+1]=h,et[2*r]=f,et[2*r+1]=d,et[2*n]=p,et[2*n+1]=g}function nt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=et[2*t],u=et[2*t+1],l=et[2*e],h=et[2*e+1],f=et[2*r],d=et[2*r+1],p=et[2*n],g=et[2*n+1],m=W(c,l,o);u=Z(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:V(g,p,16),Dl:j(g,p,16)}),({h:d,l:f}=q(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:$(h,l,63),Bl:z(h,l,63)}),et[2*t]=c,et[2*t+1]=u,et[2*e]=l,et[2*e+1]=h,et[2*r]=f,et[2*r+1]=d,et[2*n]=p,et[2*n+1]=g}class it{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,e){m(t),m(e),this.blockLen=t,this.outputLen=e,this.buffer=new Uint8Array(t),this.buffer32=E(this.buffer)}update(t){v(this),y(t);const{blockLen:e,buffer:r,buffer32:n}=this,i=t.length,s=t.byteOffset,o=t.buffer;for(let a=0;a<i;){this.pos===e&&(R(n),this.compress(n,0,!1),R(n),this.pos=0);const c=Math.min(e-this.pos,i-a),u=s+a;if(c===e&&!(u%4)&&a+c<i){const t=new Uint32Array(o,u,Math.floor((i-a)/4));R(t);for(let r=0;a+e<i;r+=n.length,a+=e)this.length+=e,this.compress(t,r,!1);R(t);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,this.length+=c,a+=c}return this}digestInto(t){v(this),w(t,this);const{pos:e,buffer32:r}=this;if(this.finished=!0,_(this.buffer.subarray(e)),R(r),this.compress(r,0,!0),R(r),3&t.byteOffset)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const n=this.get(),i=E(t),s=Math.floor(this.outputLen/4);for(let t=0;t<s;t++)i[t]=P(n[t]);const o=this.outputLen%4;if(!o)return;const a=4*s,c=n[s];for(let e=0;e<o;e++)t[a+e]=c>>>8*e}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){const{buffer:e,length:r,finished:n,destroyed:i,outputLen:s,pos:o}=this;return t||=new this.constructor({dkLen:s}),t.set(...this.get()),t.buffer.set(e),t.destroyed=i,t.finished=n,t.length=r,t.pos=o,t.outputLen=s,t}clone(){return this._cloneInto()}}class st extends it{v0l=0|tt[0];v0h=0|tt[1];v1l=0|tt[2];v1h=0|tt[3];v2l=0|tt[4];v2h=0|tt[5];v3l=0|tt[6];v3h=0|tt[7];v4l=0|tt[8];v4h=0|tt[9];v5l=0|tt[10];v5h=0|tt[11];v6l=0|tt[12];v6h=0|tt[13];v7l=0|tt[14];v7h=0|tt[15];constructor(t={}){const e=void 0===t.dkLen?64:t.dkLen;super(128,e),function(t,e={},r,n,i){if(m(r),t<=0||t>r)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=e;if(void 0!==s&&(s.length<1||s.length>r))throw new Error('"key" expected to be undefined or of length=1..'+r);void 0!==o&&y(o,n,"salt"),void 0!==a&&y(a,i,"personalization")}(e,t,64,16,16);let{key:r,personalization:n,salt:i}=t,s=0;if(void 0!==r&&(y(r,void 0,"key"),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,void 0!==i){y(i,void 0,"salt");const t=E(i);this.v4l^=P(t[0]),this.v4h^=P(t[1]),this.v5l^=P(t[2]),this.v5h^=P(t[3])}if(void 0!==n){y(n,void 0,"personalization");const t=E(n);this.v6l^=P(t[0]),this.v6h^=P(t[1]),this.v7l^=P(t[2]),this.v7h^=P(t[3])}if(void 0!==r){const t=new Uint8Array(this.blockLen);t.set(r),this.update(t)}}get(){let{v0l:t,v0h:e,v1l:r,v1h:n,v2l:i,v2h:s,v3l:o,v3h:a,v4l:c,v4h:u,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.v0l=0|t,this.v0h=0|e,this.v1l=0|r,this.v1h=0|n,this.v2l=0|i,this.v2h=0|s,this.v3l=0|o,this.v3h=0|a,this.v4l=0|c,this.v4h=0|u,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|g}compress(t,e,r){this.get().forEach((t,e)=>et[e]=t),et.set(tt,16);let{h:n,l:i}=H(BigInt(this.length));et[24]=tt[8]^i,et[25]=tt[9]^n,r&&(et[28]=~et[28],et[29]=~et[29]);let s=0;const o=k;for(let r=0;r<12;r++)rt(0,4,8,12,t,e+2*o[s++]),nt(0,4,8,12,t,e+2*o[s++]),rt(1,5,9,13,t,e+2*o[s++]),nt(1,5,9,13,t,e+2*o[s++]),rt(2,6,10,14,t,e+2*o[s++]),nt(2,6,10,14,t,e+2*o[s++]),rt(3,7,11,15,t,e+2*o[s++]),nt(3,7,11,15,t,e+2*o[s++]),rt(0,5,10,15,t,e+2*o[s++]),nt(0,5,10,15,t,e+2*o[s++]),rt(1,6,11,12,t,e+2*o[s++]),nt(1,6,11,12,t,e+2*o[s++]),rt(2,7,8,13,t,e+2*o[s++]),nt(2,7,8,13,t,e+2*o[s++]),rt(3,4,9,14,t,e+2*o[s++]),nt(3,4,9,14,t,e+2*o[s++]);this.v0l^=et[0]^et[16],this.v0h^=et[1]^et[17],this.v1l^=et[2]^et[18],this.v1h^=et[3]^et[19],this.v2l^=et[4]^et[20],this.v2h^=et[5]^et[21],this.v3l^=et[6]^et[22],this.v3h^=et[7]^et[23],this.v4l^=et[8]^et[24],this.v4h^=et[9]^et[25],this.v5l^=et[10]^et[26],this.v5h^=et[11]^et[27],this.v6l^=et[12]^et[28],this.v6h^=et[13]^et[29],this.v7l^=et[14]^et[30],this.v7h^=et[15]^et[31],_(et)}destroy(){this.destroyed=!0,_(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ot=I(t=>new st(t));var at,ct,ut,lt;class ht{constructor(t,e){at.set(this,void 0);const r=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519SecretKey,i.PrefixV2.Ed25519EncryptedSeed,i.PrefixV2.Ed25519Seed]);let[n]=r;const[,s]=r;if(s===i.PrefixV2.Ed25519SecretKey)g(this,at,{secretKey:n,publicKey:n.slice(32)},"f");else{if(s===i.PrefixV2.Ed25519EncryptedSeed){if(void 0===e)throw new Error("decryption function is not provided");n=e(n)}g(this,at,function(t){const e=a.ev.getPublicKey(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{secretKey:r,publicKey:e}}(n),"f")}}sign(t){const e=ot(t,{dkLen:32}),r=p(this,at,"f").secretKey.subarray(0,32),n=a.ev.sign(e,r);return{rawSignature:n,sig:(0,i.b58Encode)(n,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(n,i.PrefixV2.Ed25519Signature)}}publicKey(){return new ft(p(this,at,"f").publicKey)}secretKey(){return(0,i.b58Encode)(p(this,at,"f").secretKey,i.PrefixV2.Ed25519SecretKey)}}at=new WeakMap;class ft{constructor(t){if(ct.set(this,void 0),"string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519PublicKey]);g(this,ct,e,"f")}else g(this,ct,t,"f")}compare(t){if(t instanceof ft)return(0,i.compareArrays)(this.bytes(),t.bytes());throw new i.InvalidPublicKeyError("EdDSA key expected")}hash(){return(0,i.b58Encode)(ot(p(this,ct,"f"),{dkLen:20}),i.PrefixV2.Ed25519PublicKeyHash)}bytes(){return p(this,ct,"f")}toProtocol(){const t=new Uint8Array(p(this,ct,"f").length+1);return t[0]=0,t.set(p(this,ct,"f"),1),t}toString(){return(0,i.b58Encode)(p(this,ct,"f"),i.PrefixV2.Ed25519PublicKey)}}ct=new WeakMap;class dt extends l.ParameterValidationError{constructor(t){super(),this.name="InvalidMnemonicError",this.message="Invalid mnemonic"}}class pt extends l.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidBitSize"}}class gt extends l.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidCurveError"}}class mt extends l.ParameterValidationError{constructor(t){super(),this.seedLength=t,this.name="InvalidSeedLengthError",this.message=`Invalid seed length "${t}" expecting length between 16 to 64.`}}class yt extends l.UnsupportedActionError{constructor(){super(),this.name="ToBeImplemented",this.message="This feature is under developement"}}class bt extends l.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidPassphraseError"}}const vt={p256:{pk:i.PrefixV2.P256PublicKey,sk:i.PrefixV2.P256SecretKey,pkh:i.PrefixV2.P256PublicKeyHash,sig:i.PrefixV2.P256Signature,tag:2},secp256k1:{pk:i.PrefixV2.Secp256k1PublicKey,sk:i.PrefixV2.Secp256k1SecretKey,pkh:i.PrefixV2.Secp256k1PublicKeyHash,sig:i.PrefixV2.Secp256k1Signature,tag:1}};class wt{constructor(t,e){ut.set(this,void 0);const[r,n]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Secp256k1EncryptedSecretKey,i.PrefixV2.P256EncryptedSecretKey,i.PrefixV2.Secp256k1SecretKey,i.PrefixV2.P256SecretKey]),[s,o]=(()=>{switch(n){case i.PrefixV2.Secp256k1EncryptedSecretKey:case i.PrefixV2.P256EncryptedSecretKey:if(void 0===e)throw new Error("decryption function is not provided");return[e(r),n===i.PrefixV2.Secp256k1EncryptedSecretKey?"secp256k1":"p256"];case i.PrefixV2.Secp256k1SecretKey:return[r,"secp256k1"];default:return[r,"p256"]}})();g(this,ut,{curve:o,secretKey:s,publicKey:"secp256k1"===o?c.bI.getPublicKey(s,!0):u.s9.getPublicKey(s,!0)},"f")}sign(t){const e=ot(t,{dkLen:32});let r;return r="secp256k1"===p(this,ut,"f").curve?c.bI.sign(e,p(this,ut,"f").secretKey,{lowS:!0}).toBytes("compact"):u.s9.sign(e,p(this,ut,"f").secretKey,{lowS:!0}).toBytes("compact"),{rawSignature:r,sig:(0,i.b58Encode)(r,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(r,vt[p(this,ut,"f").curve].sig)}}publicKey(){return new Et(p(this,ut,"f").publicKey,p(this,ut,"f").curve)}secretKey(){return(0,i.b58Encode)(p(this,ut,"f").secretKey,vt[p(this,ut,"f").curve].sk)}}ut=new WeakMap;class Et{constructor(t,e){lt.set(this,void 0);const[r,n]=(()=>{if("string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Secp256k1PublicKey,i.PrefixV2.P256PublicKey]);return[e,r===i.PrefixV2.Secp256k1PublicKey?"secp256k1":"p256"]}if(void 0!==e)return[t,e];throw new gt("missing curve type")})();g(this,lt,r,"f"),this.curve=n}compare(t){if(t instanceof Et){if(this.curve===t.curve){const e="secp256k1"===this.curve;return(0,i.compareArrays)(this.bytes(e),t.bytes(e))}return"secp256k1"===this.curve?-1:1}throw new i.InvalidPublicKeyError("ECDSA key expected")}hash(){const t=this.bytes();return(0,i.b58Encode)(ot(t,{dkLen:20}),vt[this.curve].pkh)}bytes(t=!0){if("secp256k1"===this.curve){return c.bI.Point.fromHex(p(this,lt,"f")).toBytes(t)}return u.s9.Point.fromHex(p(this,lt,"f")).toBytes(t)}toProtocol(){const t=this.bytes(),e=new Uint8Array(t.length+1);return e[0]=vt[this.curve].tag,e.set(t,1),e}toString(){const t=this.bytes();return(0,i.b58Encode)(t,vt[this.curve].pk)}}lt=new WeakMap;class _t{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(b(t),y(e,void 0,"key"),this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(e.length>r?t.create().update(e).digest():e);for(let t=0;t<n.length;t++)n[t]^=54;this.iHash.update(n),this.oHash=t.create();for(let t=0;t<n.length;t++)n[t]^=106;this.oHash.update(n),_(n)}update(t){return v(this),this.iHash.update(t),this}digestInto(t){v(this),w(t,this),this.finished=!0;const e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const At=(()=>{const t=(t,e,r)=>new _t(t,e).update(r).digest();return t.create=(t,e)=>new _t(t,e),t})();function Ot(t,e,r,n){b(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new TypeError("options must be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},n),{c:s,dkLen:o,asyncTick:a}=i;if(m(s,"c"),m(o,"dkLen"),m(a,"asyncTick"),s<1)throw new Error("iterations (c) must be >= 1");if(o<1)throw new Error('"dkLen" must be >= 1');if(o>(2**32-1)*t.outputLen)throw new Error("derived key too long");const c=x(e,"password"),u=x(r,"salt"),l=new Uint8Array(o),h=At.create(t,c),f=h._cloneInto().update(u);return{c:s,dkLen:o,asyncTick:a,DK:l,PRF:h,PRFSalt:f}}function St(t,e,r,n){const{c:i,dkLen:s,DK:o,PRF:a,PRFSalt:c}=Ot(t,e,r,n);let u;const l=new Uint8Array(4),h=A(l),f=new Uint8Array(a.outputLen);for(let t=1,e=0;e<s;t++,e+=a.outputLen){const r=o.subarray(e,e+a.outputLen);h.setInt32(0,t,!1),(u=c._cloneInto(u)).update(l).digestInto(f),r.set(f.subarray(0,r.length));for(let t=1;t<i;t++){a._cloneInto(u).update(f).digestInto(f);for(let t=0;t<r.length;t++)r[t]^=f[t]}}return function(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),_(i),r}(a,c,o,u,f)}const Tt=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Pt=new Uint32Array(64);class Rt extends M{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Pt[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Pt[t-15],r=Pt[t-2],n=O(e,7)^O(e,18)^e>>>3,i=O(r,17)^O(r,19)^r>>>10;Pt[t]=i+Pt[t-7]+n+Pt[t-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(O(o,6)^O(o,11)^O(o,25))+L(o,a,c)+Tt[t]+Pt[t]|0,l=(O(r,2)^O(r,13)^O(r,22))+C(r,n,i)|0;u=c,c=a,a=o,o=s+e|0,s=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,s,o,a,c,u)}roundClean(){_(Pt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),_(this.buffer)}}class xt extends Rt{A=0|B[0];B=0|B[1];C=0|B[2];D=0|B[3];E=0|B[4];F=0|B[5];G=0|B[6];H=0|B[7];constructor(){super(32)}}const It=(()=>function(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){const{h:r,l:o}=H(t[s],e);[n[s],i[s]]=[r,o]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),Nt=(()=>It[0])(),kt=(()=>It[1])(),Lt=new Uint32Array(80),Ct=new Uint32Array(80);class Mt extends M{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)Lt[r]=t.getUint32(e),Ct[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Lt[t-15],r=0|Ct[t-15],n=V(e,r,1)^V(e,r,8)^F(e,0,7),i=j(e,r,1)^j(e,r,8)^G(e,r,7),s=0|Lt[t-2],o=0|Ct[t-2],a=V(s,o,19)^$(s,o,61)^F(s,0,6),c=j(s,o,19)^z(s,o,61)^G(s,o,6),u=Y(i,c,Ct[t-7],Ct[t-16]),l=X(u,n,a,Lt[t-7],Lt[t-16]);Lt[t]=0|l,Ct[t]=0|u}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let t=0;t<80;t++){const e=V(l,h,14)^V(l,h,18)^$(l,h,41),b=j(l,h,14)^j(l,h,18)^z(l,h,41),v=l&f^~l&p,w=J(y,b,h&d^~h&g,kt[t],Ct[t]),E=Q(w,m,e,v,Nt[t],Lt[t]),_=0|w,A=V(r,n,28)^$(r,n,34)^$(r,n,39),O=j(r,n,28)^z(r,n,34)^z(r,n,39),S=r&i^r&o^i&o,T=n&s^n&a^s&a;m=0|p,y=0|g,p=0|f,g=0|d,f=0|l,d=0|h,({h:l,l:h}=q(0|c,0|u,0|E,0|_)),c=0|o,u=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const P=W(_,O,T);r=Z(P,E,A,S),n=0|P}({h:r,l:n}=q(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=q(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=q(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:u}=q(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=q(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=q(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:g}=q(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=q(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(r,n,i,s,o,a,c,u,l,h,f,d,p,g,m,y)}roundClean(){_(Lt,Ct)}destroy(){this.destroyed=!0,_(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Bt extends Mt{Ah=0|D[0];Al=0|D[1];Bh=0|D[2];Bl=0|D[3];Ch=0|D[4];Cl=0|D[5];Dh=0|D[6];Dl=0|D[7];Eh=0|D[8];El=0|D[9];Fh=0|D[10];Fl=0|D[11];Gh=0|D[12];Gl=0|D[13];Hh=0|D[14];Hl=0|D[15];constructor(){super(64)}}const Dt=I(()=>new xt,N(1)),Ut=I(()=>new Bt,N(3));function Kt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}function Ht(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function Ft(t,e){if("string"!=typeof e)throw new TypeError(`${t}: string expected`);return!0}function Gt(t){if("number"!=typeof t)throw new TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t))throw new RangeError(`invalid integer: ${t}`)}function Vt(t){if(!Array.isArray(t))throw new TypeError("array expected")}function jt(t,e){if(!Ht(!0,e))throw new TypeError(`${t}: array of strings expected`)}function $t(t,e){if(!Ht(!1,e))throw new TypeError(`${t}: array of numbers expected`)}function zt(t,e,r){if(e<2)throw new RangeError(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Vt(t),!t.length)return[];let n=0;const i=[],s=Array.from(t,t=>{if(Gt(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),o=s.length;for(;;){let t=0,a=!0;for(let i=n;i<o;i++){const o=s[i],c=e*t,u=c+o;if(!Number.isSafeInteger(u)||c/e!==t||u-o!==c)throw new Error("convertRadix: carry overflow");const l=u/r;t=u%r;const h=Math.floor(l);if(s[i]=h,!Number.isSafeInteger(h)||h*r+t!==u)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:n=i)}if(i.push(t),a)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const qt=(t,e)=>0===e?t:qt(e,t%e),Wt=(t,e)=>t+(e-qt(t,e)),Zt=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Yt(t,e,r,n){if(Vt(t),e<=0||e>32)throw new RangeError(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new RangeError(`convertRadix2: wrong to=${r}`);if(Wt(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Wt(e,r)}`);let i=0,s=0;const o=Zt[e],a=Zt[r]-1,c=[];for(const n of t){if(Gt(n),n>=o)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=r;s-=r)c.push((i>>s-r&a)>>>0);const t=Zt[s];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-s&a,!n&&s>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&s>0&&c.push(i>>>0),c}const Xt=Object.freeze({alphabet:function(t){const e="string"==typeof t?t.split(""):t,r=e.length;jt("alphabet",e);const n=new Map(e.map((t,e)=>[t,e]));return{encode:n=>(Vt(n),n.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]})),decode:e=>(Vt(e),e.map(e=>{Ft("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}},chain:function(...t){const e=t=>t,r=(t,e)=>r=>t(e(r));return{encode:t.map(t=>t.encode).reduceRight(r,e),decode:t.map(t=>t.decode).reduce(r,e)}},checksum:function(t,e){if(Gt(t),t<=0)throw new RangeError(`checksum length must be positive: ${t}`);!function(t){if("function"!=typeof t)throw new TypeError("function expected")}(e);const r=e;return{encode(e){if(!Kt(e))throw new TypeError("checksum.encode: input should be Uint8Array");const n=r(e).slice(0,t),i=new Uint8Array(e.length+t);return i.set(e),i.set(n,e.length),i},decode(e){if(!Kt(e))throw new TypeError("checksum.decode: input should be Uint8Array");const n=e.slice(0,-t),i=e.slice(-t),s=r(n).slice(0,t);for(let e=0;e<t;e++)if(s[e]!==i[e])throw new Error("Invalid checksum");return n}}},convertRadix:zt,convertRadix2:Yt,radix:function(t){return Gt(t),{encode:e=>{if(!Kt(e))throw new TypeError("radix.encode input should be Uint8Array");return zt(Array.from(e),256,t)},decode:e=>($t("radix.decode",e),Uint8Array.from(zt(e,t,256)))}},radix2:function(t,e=!1){if(Gt(t),t<=0||t>32)throw new RangeError("radix2: bits should be in (0..32]");if(Wt(8,t)>32||Wt(t,8)>32)throw new RangeError("radix2: carry overflow");return{encode:r=>{if(!Kt(r))throw new TypeError("radix2.encode input should be Uint8Array");return Yt(Array.from(r),8,t,!e)},decode:r=>($t("radix2.decode",r),Uint8Array.from(Yt(r,t,8,e)))}},join:function(t=""){return Ft("join",t),{encode:e=>(jt("join.decode",e),e.join(t)),decode:e=>(Ft("join.decode",e),e.split(t))}},padding:function(t,e="="){return Gt(t),Ft("padding",e),{encode(r){for(jt("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){jt("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--){if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding")}return r.slice(0,n)}}}});function Jt(t){if("string"!=typeof t)throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Qt(t){const e=Jt(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const te=t=>{const e=8-t.length/4;return new Uint8Array([Dt(t)[0]>>e<<e])};function ee(t,e){const{words:r}=Qt(t),n=function(t){if(!Array.isArray(t)||2048!==t.length||"string"!=typeof t[0])throw new TypeError("Wordlist: expected array of 2048 strings");return t.forEach(t=>{if("string"!=typeof t)throw new TypeError("wordlist: non-string element: "+t)}),Xt.chain(Xt.checksum(1,te),Xt.radix2(11,!0),Xt.alphabet(t))}(e).decode(r);return function(t){if(y(t),![16,20,24,28,32].includes(t.length))throw new RangeError("invalid entropy length")}(n),n}function re(t,e){try{ee(t,e)}catch(t){return!1}return!0}function ne(t,e=""){return St(Ut,Qt(t).nfkd,(t=>Jt("mnemonic"+t))(e),{c:2048,dkLen:64})}const ie=Object.freeze("abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n")),se=2147483648;function oe(t){const e=[];for(let r=0;r<t.length;r+=2){const n=t.slice(r,r+2),i=parseInt(n,16);if(Number.isNaN(i))throw new l.InvalidHexStringError(n);e.push(i)}return new Uint8Array(e)}function ae(t){const e=a.ev.getPublicKey(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{secretKey:r,publicKey:e}}let ce=class t{constructor(t,e){this.priv=t,this.chainCode=e}static fromSeed(e){const r="string"==typeof e?oe(e):e;if(r.length<16||r.length>64)throw new mt(r.length);const n=(new TextEncoder).encode("ed25519 seed"),i=At(Ut,n,r);return new t(ae(i.subarray(0,32)).secretKey,i.subarray(32))}seed(){return this.priv.subarray(0,32)}derive(e){if(0===(e&se))throw new l.InvalidDerivationPathError(e.toString(),": Non-hardened derivation path.");const r=new Uint8Array(37);r.set(this.seed(),1),new DataView(r.buffer).setUint32(33,e);const n=At(Ut,this.chainCode,r);return new t(ae(n.subarray(0,32)).secretKey,n.subarray(32))}derivePath(t){let e=this;for(const r of t)e=e.derive(r);return e}};var ue=Object.freeze({__proto__:null,PrivateKey:ce});const le={p256:"Nist256p1 seed",secp256k1:"Bitcoin seed"};class he{constructor(t,e){this.priv=t,this.chainCode=e;const r=t.secretKey.toArray("be",32),n=new Uint8Array(r),i="secp256k1"===t.curve?c.bI.getPublicKey(n,!0):u.s9.getPublicKey(n,!0);this.keyPair={curve:t.curve,secretKey:t.secretKey,publicKey:i}}static fromSeed(t,e){let r,n="string"==typeof t?oe(t):t;if(n.length<16||n.length>64)throw new mt(n.length);if(!Object.prototype.hasOwnProperty.call(le,e))throw new gt(`Unsupported curve "${e}" expecting either "p256" or "secp256k1"`);if(r="secp256k1"===e?new(f())(c.bI.Point.CURVE().n.toString()):new(f())(u.s9.Point.CURVE().n.toString()),256!==r.bitLength())throw new pt(`Invalid curve "${e}" with bit size "${r.bitLength()}" expecting bit size "256"`);const i=(new TextEncoder).encode(le[e]);let s=null,o=new Uint8Array,a=0;for(;0===a;){const t=At(Ut,i,n);s=new(f())(t.subarray(0,32)),o=t.subarray(32),s.isZero()||s.cmp(r)>=0?n=t:a++}return new he({curve:e,secretKey:s},o)}derive(t){const e=new Uint8Array(37);0!==(t&se)?e.set(this.keyPair.secretKey.toArray(),1):e.set(this.keyPair.publicKey,0),new DataView(e.buffer).setUint32(33,t);let r=new(f())(0),n=new Uint8Array,i=0;for(;0===i;){const t=At(Ut,this.chainCode,e);let s;r=new(f())(t.subarray(0,32)),n=t.subarray(32),s="secp256k1"===this.keyPair.curve?new(f())(c.bI.Point.CURVE().n.toString()):new(f())(u.s9.Point.CURVE().n.toString()),r.cmp(s)<0&&(r=r.add(this.keyPair.secretKey).mod(s),r.isZero()||i++),e.set(n,1),e[0]=1}return new he({curve:this.keyPair.curve,secretKey:r},n)}derivePath(t){let e=this;for(const r of t)e=e.derive(r);return e}bytes(){if(!this.keyPair.secretKey)throw new l.InvalidKeyError("missing private key");const t=this.keyPair.secretKey.toArray(),e=new Uint8Array(32);return e.set(t,e.length-t.length),e}}var fe=Object.freeze({__proto__:null,PrivateKey:he});class de extends Array{static from(t){return super.from(t).map(t=>t>>>0)}static fromString(t){if(0===t.length)return new de;let e=t.split("/");const r=[];"m"===e[0]&&(e=e.slice(1));for(let n of e){if(0===n.length)throw new l.InvalidDerivationPathError(t,": Invalid BIP32 path");let e=0;const i=n[n.length-1];"'"!==i&&"h"!==i&&"H"!==i||(e=se,n=n.slice(0,n.length-1));const s=(parseInt(n,10)|e)>>>0;r.push(s)}return de.from(r)}}const pe=(t,e,r)=>{const n=de.fromString(e);let s;switch(r){case"ed25519":s=ce.fromSeed(t).derivePath(n);return(0,i.b58Encode)(s.seed().slice(0,32),i.PrefixV2.Ed25519Seed);case"secp256k1":case"p256":{const e="secp256k1"===r?i.PrefixV2.Secp256k1SecretKey:i.PrefixV2.P256SecretKey;let s=he.fromSeed(t,r);s=s.derivePath(n);const o=new Uint8Array(s.keyPair.secretKey.toArray());return(0,i.b58Encode)(o,e)}case"bip25519":throw new yt;default:throw new gt(`Unsupported curve "${r}" expecting one of the following "ed25519", "secp256k1", "p256"`)}};function ge(t){return"provePossession"in t}var me,ye,be;const ve=d.A.longSignatures;class we{constructor(t,e){me.set(this,void 0),ye.set(this,void 0);const r=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.BLS12_381EncryptedSecretKey,i.PrefixV2.BLS12_381SecretKey]);let[n]=r;const[,s]=r;if(s===i.PrefixV2.BLS12_381EncryptedSecretKey){if(void 0===e)throw new Error("decryption function is not provided");n=e(n)}g(this,me,n,"f"),g(this,ye,ve.getPublicKey(this.sk()).toBytes(),"f")}sk(){return new Uint8Array(p(this,me,"f")).reverse()}signDst(t,e){const r=ve.hash(t,e),n=ve.sign(r,this.sk()).toBytes();return{rawSignature:n,sig:(0,i.b58Encode)(n,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(n,i.PrefixV2.BLS12_381Signature)}}sign(t){return this.signDst(t,i.BLS12_381_DST)}provePossession(){return this.signDst(p(this,ye,"f"),i.POP_DST)}publicKey(){return new Ee(p(this,ye,"f"))}secretKey(){return(0,i.b58Encode)(p(this,me,"f"),i.PrefixV2.BLS12_381SecretKey)}}me=new WeakMap,ye=new WeakMap;class Ee{constructor(t){if(be.set(this,void 0),"string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.BLS12_381PublicKey]);g(this,be,e,"f")}else g(this,be,t,"f")}compare(t){if(t instanceof Ee)return(0,i.compareArrays)(this.bytes(),t.bytes());throw new i.InvalidPublicKeyError("BLS key expected")}hash(){return(0,i.b58Encode)(ot(p(this,be,"f"),{dkLen:20}),i.PrefixV2.BLS12_381PublicKeyHash)}bytes(){return p(this,be,"f")}toProtocol(){const t=new Uint8Array(p(this,be,"f").length+1);return t[0]=3,t.set(p(this,be,"f"),1),t}toString(){return(0,i.b58Encode)(p(this,be,"f"),i.PrefixV2.BLS12_381PublicKey)}}var _e;be=new WeakMap;class Ae{static fromFundraiser(t,e,r){if(!re(r,ie))throw new dt;const n=ne(r,`${t}${e}`),s=(0,i.b58Encode)(n.subarray(0,32),i.PrefixV2.Ed25519Seed);return new Ae(s)}static async fromSecretKey(t,e){return new Ae(t,e)}static fromMnemonic({mnemonic:t,password:e="",derivationPath:r="44'/1729'/0'/0'",curve:n="ed25519"}){if(!re(t,ie))throw new dt;const i=ne(t,e),s=pe(i,r,n);return new Ae(s)}constructor(t,e){_e.set(this,void 0);const r=[i.PrefixV2.Ed25519EncryptedSeed,i.PrefixV2.Ed25519Seed,i.PrefixV2.Ed25519SecretKey,i.PrefixV2.Secp256k1EncryptedSecretKey,i.PrefixV2.Secp256k1SecretKey,i.PrefixV2.P256EncryptedSecretKey,i.PrefixV2.P256SecretKey,i.PrefixV2.BLS12_381EncryptedSecretKey,i.PrefixV2.BLS12_381SecretKey],s=(()=>{try{const[,e]=(0,i.b58DecodeAndCheckPrefix)(t,r);return e}catch{throw new l.InvalidKeyError(`Invalid private key, expecting one of the following prefixes '${r}'.`)}})();let a;if(s===i.PrefixV2.Ed25519EncryptedSeed||s===i.PrefixV2.Secp256k1EncryptedSecretKey||s===i.PrefixV2.P256EncryptedSecretKey||s===i.PrefixV2.BLS12_381EncryptedSecretKey){if(!e)throw new bt("No passphrase provided to decrypt encrypted key");a=t=>{const r=o()(t.slice(0,8)),i=t.slice(8),s=St(Ut,e,r,{c:32768,dkLen:32}),a=(0,n.openSecretBox)(new Uint8Array(s),new Uint8Array(24),new Uint8Array(i));if(!a)throw new Error("can't decrypt secret key");return a}}switch(s){case i.PrefixV2.Ed25519EncryptedSeed:case i.PrefixV2.Ed25519Seed:case i.PrefixV2.Ed25519SecretKey:g(this,_e,new ht(t,a),"f");break;case i.PrefixV2.Secp256k1EncryptedSecretKey:case i.PrefixV2.Secp256k1SecretKey:case i.PrefixV2.P256EncryptedSecretKey:case i.PrefixV2.P256SecretKey:g(this,_e,new wt(t,a),"f");break;case i.PrefixV2.BLS12_381EncryptedSecretKey:case i.PrefixV2.BLS12_381SecretKey:g(this,_e,new we(t,a),"f")}}async sign(t,e){const r="string"==typeof t?(0,i.hex2buf)(t):t,n=void 0!==e?(0,i.mergebuf)(e,r):r,{rawSignature:s,sig:o,prefixSig:a}=await p(this,_e,"f").sign(n);return{bytes:(0,i.buf2hex)(r),sig:o,prefixSig:a,sbytes:(0,i.buf2hex)((0,i.mergebuf)(r,ge(p(this,_e,"f"))?(0,i.mergebuf)(new Uint8Array([255,3]),s):s))}}async provePossession(){if(ge(p(this,_e,"f")))return p(this,_e,"f").provePossession();throw new l.ProhibitedActionError("Only BLS keys can prove possession")}get canProvePossession(){return ge(p(this,_e,"f"))}publicKey(){return Promise.resolve(String(p(this,_e,"f").publicKey()))}publicKeyHash(){return Promise.resolve(p(this,_e,"f").publicKey().hash())}secretKey(){return Promise.resolve(p(this,_e,"f").secretKey())}}function Oe(t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519PublicKey,i.PrefixV2.Secp256k1PublicKey,i.PrefixV2.P256PublicKey,i.PrefixV2.BLS12_381PublicKey]);switch(r){case i.PrefixV2.Ed25519PublicKey:return new ft(e);case i.PrefixV2.Secp256k1PublicKey:return new Et(e,"secp256k1");case i.PrefixV2.P256PublicKey:return new Et(e,"p256");case i.PrefixV2.BLS12_381PublicKey:return new Ee(e)}}_e=new WeakMap;const Se={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"}},2403(t,e,r){"use strict";r.r(e),r.d(e,{BLS12_381_DST:()=>We,DeprecationError:()=>O.DeprecationError,InvalidAddressError:()=>O.InvalidAddressError,InvalidBlockHashError:()=>O.InvalidBlockHashError,InvalidChainIdError:()=>O.InvalidChainIdError,InvalidContractAddressError:()=>O.InvalidContractAddressError,InvalidHexStringError:()=>O.InvalidHexStringError,InvalidKeyError:()=>O.InvalidKeyError,InvalidKeyHashError:()=>O.InvalidKeyHashError,InvalidMessageError:()=>O.InvalidMessageError,InvalidOperationHashError:()=>O.InvalidOperationHashError,InvalidOperationKindError:()=>O.InvalidOperationKindError,InvalidProtocolHashError:()=>Je,InvalidPublicKeyError:()=>O.InvalidPublicKeyError,InvalidSignatureError:()=>O.InvalidSignatureError,POP_DST:()=>Ze,PrefixV2:()=>_t,ProhibitedActionError:()=>O.ProhibitedActionError,VERSION:()=>qe,ValidationResult:()=>O.ValidationResult,ValueConversionError:()=>Qe,addressPrefixes:()=>ie,b58DecodeAddress:()=>fe,b58DecodeAndCheckPrefix:()=>ce,b58DecodeBlsAddress:()=>he,b58DecodePublicKey:()=>ue,b58DecodePublicKeyHash:()=>le,b58Encode:()=>pe,buf2hex:()=>Oe,bytesToString:()=>Te,compareArrays:()=>Le,encodeAddress:()=>ye,encodeBlsAddress:()=>be,encodeExpr:()=>ve,encodeKey:()=>ge,encodeKeyHash:()=>me,encodeOpHash:()=>we,format:()=>er,getPkhfromPk:()=>de,hex2Bytes:()=>Pe,hex2buf:()=>Ee,isValidPrefixedValue:()=>Ce,mergebuf:()=>_e,mic2arr:()=>Ae,num2PaddedHex:()=>Ie,numToHexBuffer:()=>xe,payloadLength:()=>It,publicKeyHashPrefixes:()=>oe,publicKeyPrefixes:()=>se,signaturePrefixes:()=>ae,splitAddress:()=>ke,stringToBytes:()=>Se,stripHexPrefix:()=>Ne,toHexBuf:()=>Re,validateAddress:()=>Be,validateBlock:()=>je,validateChain:()=>De,validateContractAddress:()=>Ue,validateKeyHash:()=>Ke,validateOperation:()=>Ge,validateProtocol:()=>Ve,validatePublicKey:()=>Fe,validateSignature:()=>He,validateSmartRollupAddress:()=>ze,validateSpendingKey:()=>$e,verifySignature:()=>Ye});var n=r(9848),i=r.n(n),s=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,a,c,l,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!o.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(u+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(c<0&&(c=l),c+=+d.slice(l+1),d=d.substring(0,l)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(u+"String expected: "+t);for(v(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=l=0,f=d.length;l<f;l++)if(r.indexOf(s=d.charAt(l))<0){if("."==s){if(l>c){c=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,l=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(l=0;48===d.charCodeAt(l);l++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(l,++f))if(f-=l,(c=c-l-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],l=(c+1)%h,c<0&&(l+=h),l<f){for(l&&g.c.push(+d.slice(0,l)),f-=h;l<f;)g.c.push(+d.slice(l,l+=h));l=h-(d=d.slice(l)).length}else l-=f;for(;l--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=y(t.c),c=1==n||2==n&&(o<=T||o>=P)?E(c,o):_(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=E(c,s)}else if(e-=o+(2===n&&s>o),c=_(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=b(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*h-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,u,f,p,g,m=t.c,y=d;if(m){t:{for(i=1,u=m[0];u>=10;u/=10,i++);if((s=e-i)<0)s+=h,o=e,f=m[p=0],g=c(f/y[i-o-1]%10);else if((p=a((s+1)/h))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));f=g=0,i=1,o=(s%=h)-h+1}else{for(f=u=m[p],i=1;u>=10;u/=10,i++);g=(o=(s%=h)-h+i)<0?0:c(f/y[i-o-1]%10)}if(n=n||e<0||null!=m[p+1]||(o<0?f:f%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?f/y[i-o]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(h-e%h)%h],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,u=1,p--):(m.length=p+1,u=y[h-s],m[p]=o>0?c(f/y[i-o]%y[o])*u:0),n)for(;;){if(0==p){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[p]+=u,m[p]!=l)break;m[p--]=0,u=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=y(t.c),e=r<=T||r>=P?E(e,r):_(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,g,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-g,0,e),v(r[1],0,g,e),T=r[0],P=r[1]):(v(r,-g,g,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-g,-1,e),v(r[1],1,g,e),R=r[0],x=r[1];else{if(v(r,-g,g,e),!r)throw Error(u+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(u+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,g,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-g||i>g||i!==c(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%h)<1&&(e+=h),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=l||r!==c(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return c(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,o,l=0,f=[],p=new M(A);if(null==t?t=O:v(t,0,g),s=a(t/h),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(o=131072*r[l]+(r[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[l]=n[0],r[l+1]=n[1]):(f.push(o%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);l<s;)(o=281474976710656*(31&r[l])+1099511627776*r[l+1]+4294967296*r[l+2]+16777216*r[l+3]+(r[l+4]<<16)+(r[l+5]<<8)+r[l+6])>=9e15?crypto.randomBytes(7).copy(r,l):(f.push(o%1e14),l+=7);l=s/7}if(!I)for(;l<s;)(o=e())<9e15&&(f[l++]=o%1e14);for(s=f[--l],t%=h,s&&t&&(o=d[h-t],f[l]=c(s/o)*o);0===f[l];f.pop(),l--);if(l<0)f=[i=0];else{for(i=-1;0===f[0];f.splice(0,1),i-=h);for(l=1,o=f[0];o>=10;o/=10,l++);l<h&&(i-=h-l)}return p.e=i,p.c=f,p}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),b=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(_(y(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),m=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?_(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=_(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%p)+(n=l*s+(o=t[c]/p|0)*u)%p*p+a)/r|0)+(n/p|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var u,f,d,p,g,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),x=x/h|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=c(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(u=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=c(A/T))>1)for(g>=a&&(g=a-1),b=(y=t(N,g,a)).length,_=E.length;1==e(y,E,b,_);)g--,r(y,P<b?R:N,b,a),b=y.length,u=1;else 0==g&&(u=g=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,a),_=E.length,-1==u)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===u&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==l){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*h-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,c);throw Error(u+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return b(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return v(t,0,g),null==e?e=S:v(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,o,l,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),o=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),o?t.s*(2-w(t)):+F(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||o&&p.c[1]>=24e7:p.c[0]<8e13||o&&p.c[0]<=9999975e7)))return s=p.s<0&&w(t)?-0:0,p.e>-1&&(s=1/s),new M(l?1/s:s);k&&(s=a(k/h+2))}for(o?(r=new M(.5),l&&(t.s=1),f=w(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=w(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(l&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:v(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===b(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return b(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=b(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return b(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=b(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/h,u=t.e/h,f=o.c,d=t.c;if(!c||!u){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=m(c),u=m(u),f=f.slice(),a=c-u){for((s=a<0)?(a=-a,i=f):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=l-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--u);return f[0]?K(t,f,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,f,d,g,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=m(E.e/h)+m(t.e/h),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=l,w=p,i=d;--i>=0;){for(r=0,g=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((u=g*(u=_[--o]%w)+(a=y*u+(f=_[o]/w|0)*g)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/h,o=t.e/h,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=m(s),o=m(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/l|0,a[e]=l===a[e]?0:a[e]%l;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return v(t,1,g),null==e?e=S:v(e,0,8),H(new M(s),t,e);if(!(r=s.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&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return v(t,-9007199254740991,f),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=y(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=m((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(v(t,0,g),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(v(t,0,g),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);c>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,o,a,c,l,f,p,g,m,b=this,v=b.c;if(null!=t&&(!(c=new M(t)).isInteger()&&(c.c||1!==c.s)||c.lt(A)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+F(c));if(!v)return new M(b);for(e=new M(A),f=n=new M(A),i=l=new M(A),m=y(v),o=e.e=m.length-b.e-1,e.c[0]=d[(a=o%h)<0?h+a:a],t=!t||c.comparedTo(e)>0?o>0?e:f:c,a=x,x=1/0,c=new M(m),l.c[0]=0;p=r(c,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,f=l.plus(p.times(s=f)),l=s,e=c.minus(p.times(s=e)),c=s;return s=r(t.minus(n),i,0,1),l=l.plus(s.times(f)),n=n.plus(s.times(i)),l.s=f.s=b.s,g=r(f,i,o*=2,S).minus(b).abs().comparedTo(r(l,n,o,S).minus(b).abs())<1?[f,i]:[l,n],x=a,g},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&v(t,1,g),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?E(y(r.c),s):_(y(r.c),s,"0"):(v(t,2,C.length,"Base"),e=n(_(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=1e14,h=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function m(t){var e=0|t;return t>0||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=h-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function w(t){var e=t.c.length-1;return m(t.e/h)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function _(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const A=s;var O=r(6571),S=r(1032),T=r(3156),P=r(404),R=r(1188),x=void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},I=[],N=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,L=!1;function C(){L=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)I[e]=t[e],N[t.charCodeAt(e)]=e;N["-".charCodeAt(0)]=62,N["_".charCodeAt(0)]=63}function M(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[63&t]}function B(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(M(n));return i.join("")}function D(t){var e;L||C();for(var r=t.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(B(t,a,a+o>c?c:a+o));return 1===n?(e=t[r-1],i+=I[e>>2],i+=I[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=I[e>>10],i+=I[e>>4&63],i+=I[e<<2&63],i+="="),s.push(i),s.join("")}function U(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+h],h+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)}function K(t,e,r,n,i,s){var o,a,c,u=8*s-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(o++,c/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}var H={}.toString,F=Array.isArray||function(t){return"[object Array]"==H.call(t)};function G(){return j.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(t,e){if(G()<e)throw new RangeError("Invalid typed array length");return j.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=j.prototype:(null===t&&(t=new j(e)),t.length=e),t}function j(t,e,r){if(!(j.TYPED_ARRAY_SUPPORT||this instanceof j))return new j(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return q(this,t)}return $(this,t,e,r)}function $(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);j.TYPED_ARRAY_SUPPORT?(t=e).__proto__=j.prototype:t=W(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!j.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|X(e,r);t=V(t,n);var i=t.write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(Y(e)){var r=0|Z(e.length);return 0===(t=V(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?V(t,0):W(t,e);if("Buffer"===e.type&&F(e.data))return W(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function z(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function q(t,e){if(z(e),t=V(t,e<0?0:0|Z(e)),!j.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function W(t,e){var r=e.length<0?0:0|Z(e.length);t=V(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function Z(t){if(t>=G())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+G().toString(16)+" bytes");return 0|t}function Y(t){return!(null==t||!t._isBuffer)}function X(t,e){if(Y(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return St(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Tt(t).length;default:if(n)return St(t).length;e=(""+e).toLowerCase(),n=!0}}function J(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return dt(this,e,r);case"utf8":case"utf-8":return ut(this,e,r);case"ascii":return ht(this,e,r);case"latin1":case"binary":return ft(this,e,r);case"base64":return ct(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Q(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function tt(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=j.from(e,n)),Y(e))return 0===e.length?-1:et(t,e,r,n,i);if("number"==typeof e)return e&=255,j.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):et(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function et(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var l=-1;for(s=r;s<a;s++)if(u(t,s)===u(e,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===c)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var h=!0,f=0;f<c;f++)if(u(t,s+f)!==u(e,f)){h=!1;break}if(h)return s}return-1}function rt(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function nt(t,e,r,n){return Pt(St(e,t.length-r),t,r,n)}function it(t,e,r,n){return Pt(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function st(t,e,r,n){return it(t,e,r,n)}function ot(t,e,r,n){return Pt(Tt(e),t,r,n)}function at(t,e,r,n){return Pt(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)n=(r=t.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function ct(t,e,r){return 0===e&&r===t.length?D(t):D(t.slice(e,r))}function ut(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,c,u=t[i],l=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(s=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(t){var e=t.length;if(e<=lt)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=lt));return r}(n)}j.TYPED_ARRAY_SUPPORT=void 0===x.TYPED_ARRAY_SUPPORT||x.TYPED_ARRAY_SUPPORT,G(),j.poolSize=8192,j._augment=function(t){return t.__proto__=j.prototype,t},j.from=function(t,e,r){return $(null,t,e,r)},j.TYPED_ARRAY_SUPPORT&&(j.prototype.__proto__=Uint8Array.prototype,j.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&j[Symbol.species]),j.alloc=function(t,e,r){return function(t,e,r,n){return z(e),e<=0?V(t,e):void 0!==r?"string"==typeof n?V(t,e).fill(r,n):V(t,e).fill(r):V(t,e)}(null,t,e,r)},j.allocUnsafe=function(t){return q(null,t)},j.allocUnsafeSlow=function(t){return q(null,t)},j.isBuffer=function(t){return null!=t&&(!!t._isBuffer||Rt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Rt(t.slice(0,0))}(t))},j.compare=function(t,e){if(!Y(t)||!Y(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},j.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},j.concat=function(t,e){if(!F(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return j.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=j.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var s=t[r];if(!Y(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},j.byteLength=X,j.prototype._isBuffer=!0,j.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Q(this,e,e+1);return this},j.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Q(this,e,e+3),Q(this,e+1,e+2);return this},j.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Q(this,e,e+7),Q(this,e+1,e+6),Q(this,e+2,e+5),Q(this,e+3,e+4);return this},j.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?ut(this,0,t):J.apply(this,arguments)},j.prototype.equals=function(t){if(!Y(t))throw new TypeError("Argument must be a Buffer");return this===t||0===j.compare(this,t)},j.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},j.prototype.compare=function(t,e,r,n,i){if(!Y(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),c=this.slice(n,i),u=t.slice(e,r),l=0;l<a;++l)if(c[l]!==u[l]){s=c[l],o=u[l];break}return s<o?-1:o<s?1:0},j.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},j.prototype.indexOf=function(t,e,r){return tt(this,t,e,r,!0)},j.prototype.lastIndexOf=function(t,e,r){return tt(this,t,e,r,!1)},j.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return rt(this,t,e,r);case"utf8":case"utf-8":return nt(this,t,e,r);case"ascii":return it(this,t,e,r);case"latin1":case"binary":return st(this,t,e,r);case"base64":return ot(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return at(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var lt=4096;function ht(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function ft(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function dt(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=Ot(t[s]);return i}function pt(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function gt(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function mt(t,e,r,n,i,s){if(!Y(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function yt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function bt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function vt(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function wt(t,e,r,n,i){return i||vt(t,0,r,4),K(t,e,r,n,23,4),r+4}function Et(t,e,r,n,i){return i||vt(t,0,r,8),K(t,e,r,n,52,8),r+8}j.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),j.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=j.prototype;else{var i=e-t;r=new j(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},j.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},j.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},j.prototype.readUInt8=function(t,e){return e||gt(t,1,this.length),this[t]},j.prototype.readUInt16LE=function(t,e){return e||gt(t,2,this.length),this[t]|this[t+1]<<8},j.prototype.readUInt16BE=function(t,e){return e||gt(t,2,this.length),this[t]<<8|this[t+1]},j.prototype.readUInt32LE=function(t,e){return e||gt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},j.prototype.readUInt32BE=function(t,e){return e||gt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},j.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},j.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},j.prototype.readInt8=function(t,e){return e||gt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},j.prototype.readInt16LE=function(t,e){e||gt(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},j.prototype.readInt16BE=function(t,e){e||gt(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},j.prototype.readInt32LE=function(t,e){return e||gt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},j.prototype.readInt32BE=function(t,e){return e||gt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},j.prototype.readFloatLE=function(t,e){return e||gt(t,4,this.length),U(this,t,!0,23,4)},j.prototype.readFloatBE=function(t,e){return e||gt(t,4,this.length),U(this,t,!1,23,4)},j.prototype.readDoubleLE=function(t,e){return e||gt(t,8,this.length),U(this,t,!0,52,8)},j.prototype.readDoubleBE=function(t,e){return e||gt(t,8,this.length),U(this,t,!1,52,8)},j.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},j.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},j.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,1,255,0),j.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},j.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yt(this,t,e,!0),e+2},j.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yt(this,t,e,!1),e+2},j.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):bt(this,t,e,!0),e+4},j.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):bt(this,t,e,!1),e+4},j.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);mt(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o|0)-a&255;return e+r},j.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);mt(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o|0)-a&255;return e+r},j.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,1,127,-128),j.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},j.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yt(this,t,e,!0),e+2},j.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yt(this,t,e,!1),e+2},j.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,2147483647,-2147483648),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):bt(this,t,e,!0),e+4},j.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):bt(this,t,e,!1),e+4},j.prototype.writeFloatLE=function(t,e,r){return wt(this,t,e,!0,r)},j.prototype.writeFloatBE=function(t,e,r){return wt(this,t,e,!1,r)},j.prototype.writeDoubleLE=function(t,e,r){return Et(this,t,e,!0,r)},j.prototype.writeDoubleBE=function(t,e,r){return Et(this,t,e,!1,r)},j.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!j.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},j.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!j.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=Y(t)?t:St(new j(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var _t,At=/[^+\/0-9A-Za-z-_]/g;function Ot(t){return t<16?"0"+t.toString(16):t.toString(16)}function St(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function Tt(t){return function(t){var e,r,n,i,s,o;L||C();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===t[a-2]?2:"="===t[a-1]?1:0,o=new k(3*a/4-s),n=s>0?a-4:a;var c=0;for(e=0,r=0;e<n;e+=4,r+=3)i=N[t.charCodeAt(e)]<<18|N[t.charCodeAt(e+1)]<<12|N[t.charCodeAt(e+2)]<<6|N[t.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=255&i;return 2===s?(i=N[t.charCodeAt(e)]<<2|N[t.charCodeAt(e+1)]>>4,o[c++]=255&i):1===s&&(i=N[t.charCodeAt(e)]<<10|N[t.charCodeAt(e+1)]<<4|N[t.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=255&i),o}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(At,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Pt(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Rt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(t){t.BlockHash="B",t.OperationHash="o",t.OperationListHash="Lo",t.OperationListListHash="LLo",t.ProtocolHash="P",t.ContextHash="Co",t.BlockMetadataHash="bm",t.OperationMetadataHash="r",t.OperationMetadataListHash="Lr",t.OperationMetadataListListHash="LLr",t.Ed25519PublicKeyHash="tz1",t.Secp256k1PublicKeyHash="tz2",t.P256PublicKeyHash="tz3",t.ContractHash="KT1",t.BlindedPublicKeyHash="btz1",t.BLS12_381PublicKeyHash="tz4",t.TXRollupAddress="txr1",t.ZkRollupHash="epx1",t.ScRollupHash="scr1",t.SmartRollupHash="sr1",t.CryptoboxPublicKeyHash="id",t.Ed25519Seed="edsk",t.Ed25519PublicKey="edpk",t.Secp256k1SecretKey="spsk",t.P256SecretKey="p2sk",t.BLS12_381SecretKey="BLsk",t.ValueHash="vh",t.CycleNonce="nce",t.ScriptExpr="expr",t.InboxHash="txi",t.MessageHash="txm",t.CommitmentHash="txc",t.MessageResultHash="txmr",t.MessageResultListHash="txM",t.WithdrawListHash="txw",t.ScRollupStateHash="scs1",t.ScRollupCommitmentHash="scc1",t.SmartRollupStateHash="srs1",t.SmartRollupCommitmentHash="src1",t.Ed25519EncryptedSeed="edesk",t.Secp256k1EncryptedSecretKey="spesk",t.P256EncryptedSecretKey="p2esk",t.BLS12_381EncryptedSecretKey="BLesk",t.Secp256k1EncryptedScalar="seesk",t.Secp256k1PublicKey="sppk",t.P256PublicKey="p2pk",t.Secp256k1Scalar="SSp",t.Secp256k1Element="GSp",t.Ed25519SecretKey="_edsk",t.Ed25519Signature="edsig",t.Secp256k1Signature="spsig1",t.P256Signature="p2sig",t.GenericSignature="sig",t.ChainID="Net",t.SaplingSpendingKey="sask",t.EncryptedSaplingSpendingKey="_sask",t.SaplingAddress="zet1",t.GenericAggregateSignature="asig",t.BLS12_381Signature="BLsig",t.BLS12_381PublicKey="BLpk",t.SlotHeader="sh"}(_t||(_t={}));const xt={[_t.BlockHash]:new Uint8Array([1,52]),[_t.OperationHash]:new Uint8Array([5,116]),[_t.OperationListHash]:new Uint8Array([133,233]),[_t.OperationListListHash]:new Uint8Array([29,159,109]),[_t.ProtocolHash]:new Uint8Array([2,170]),[_t.ContextHash]:new Uint8Array([79,199]),[_t.BlockMetadataHash]:new Uint8Array([234,249]),[_t.OperationMetadataHash]:new Uint8Array([5,183]),[_t.OperationMetadataListHash]:new Uint8Array([134,39]),[_t.OperationMetadataListListHash]:new Uint8Array([29,159,182]),[_t.Ed25519PublicKeyHash]:new Uint8Array([6,161,159]),[_t.Secp256k1PublicKeyHash]:new Uint8Array([6,161,161]),[_t.P256PublicKeyHash]:new Uint8Array([6,161,164]),[_t.ContractHash]:new Uint8Array([2,90,121]),[_t.BlindedPublicKeyHash]:new Uint8Array([1,2,49,223]),[_t.BLS12_381PublicKeyHash]:new Uint8Array([6,161,166]),[_t.TXRollupAddress]:new Uint8Array([1,128,120,31]),[_t.ZkRollupHash]:new Uint8Array([1,23,224,125]),[_t.ScRollupHash]:new Uint8Array([1,118,132,217]),[_t.SmartRollupHash]:new Uint8Array([6,124,117]),[_t.CryptoboxPublicKeyHash]:new Uint8Array([153,103]),[_t.Ed25519Seed]:new Uint8Array([13,15,58,7]),[_t.Ed25519PublicKey]:new Uint8Array([13,15,37,217]),[_t.Secp256k1SecretKey]:new Uint8Array([17,162,224,201]),[_t.P256SecretKey]:new Uint8Array([16,81,238,189]),[_t.BLS12_381SecretKey]:new Uint8Array([3,150,192,40]),[_t.ValueHash]:new Uint8Array([1,106,242]),[_t.CycleNonce]:new Uint8Array([69,220,169]),[_t.ScriptExpr]:new Uint8Array([13,44,64,27]),[_t.InboxHash]:new Uint8Array([79,148,196]),[_t.MessageHash]:new Uint8Array([79,149,30]),[_t.CommitmentHash]:new Uint8Array([79,148,17]),[_t.MessageResultHash]:new Uint8Array([18,7,206,87]),[_t.MessageResultListHash]:new Uint8Array([79,146,82]),[_t.WithdrawListHash]:new Uint8Array([79,150,72]),[_t.ScRollupStateHash]:new Uint8Array([17,144,122,202]),[_t.ScRollupCommitmentHash]:new Uint8Array([17,144,21,100]),[_t.SmartRollupStateHash]:new Uint8Array([17,165,235,240]),[_t.SmartRollupCommitmentHash]:new Uint8Array([17,165,134,138]),[_t.Ed25519EncryptedSeed]:new Uint8Array([7,90,60,179,41]),[_t.Secp256k1EncryptedSecretKey]:new Uint8Array([9,237,241,174,150]),[_t.P256EncryptedSecretKey]:new Uint8Array([9,48,57,115,171]),[_t.BLS12_381EncryptedSecretKey]:new Uint8Array([2,5,30,53,25]),[_t.Secp256k1EncryptedScalar]:new Uint8Array([1,131,36,86,248]),[_t.Secp256k1PublicKey]:new Uint8Array([3,254,226,86]),[_t.P256PublicKey]:new Uint8Array([3,178,139,127]),[_t.Secp256k1Scalar]:new Uint8Array([38,248,136]),[_t.Secp256k1Element]:new Uint8Array([5,92,0]),[_t.Ed25519SecretKey]:new Uint8Array([43,246,78,7]),[_t.Ed25519Signature]:new Uint8Array([9,245,205,134,18]),[_t.Secp256k1Signature]:new Uint8Array([13,115,101,19,63]),[_t.P256Signature]:new Uint8Array([54,240,44,52]),[_t.GenericSignature]:new Uint8Array([4,130,43]),[_t.ChainID]:new Uint8Array([87,82,0]),[_t.SaplingSpendingKey]:new Uint8Array([11,237,20,92]),[_t.EncryptedSaplingSpendingKey]:new Uint8Array([11,237,20,92]),[_t.SaplingAddress]:new Uint8Array([18,71,40,223]),[_t.GenericAggregateSignature]:new Uint8Array([2,75,234,101]),[_t.BLS12_381Signature]:new Uint8Array([40,171,64,207]),[_t.BLS12_381PublicKey]:new Uint8Array([6,149,135,204]),[_t.SlotHeader]:new Uint8Array([2,116,180])},It={[_t.BlockHash]:32,[_t.OperationHash]:32,[_t.OperationListHash]:32,[_t.OperationListListHash]:32,[_t.ProtocolHash]:32,[_t.ContextHash]:32,[_t.BlockMetadataHash]:32,[_t.OperationMetadataHash]:32,[_t.OperationMetadataListHash]:32,[_t.OperationMetadataListListHash]:32,[_t.Ed25519PublicKeyHash]:20,[_t.Secp256k1PublicKeyHash]:20,[_t.P256PublicKeyHash]:20,[_t.ContractHash]:20,[_t.BlindedPublicKeyHash]:20,[_t.BLS12_381PublicKeyHash]:20,[_t.TXRollupAddress]:20,[_t.ZkRollupHash]:20,[_t.ScRollupHash]:20,[_t.SmartRollupHash]:20,[_t.CryptoboxPublicKeyHash]:16,[_t.Ed25519Seed]:32,[_t.Ed25519PublicKey]:32,[_t.Secp256k1SecretKey]:32,[_t.P256SecretKey]:32,[_t.BLS12_381SecretKey]:32,[_t.ValueHash]:32,[_t.CycleNonce]:32,[_t.ScriptExpr]:32,[_t.InboxHash]:32,[_t.MessageHash]:32,[_t.CommitmentHash]:32,[_t.MessageResultHash]:32,[_t.MessageResultListHash]:32,[_t.WithdrawListHash]:32,[_t.ScRollupStateHash]:32,[_t.ScRollupCommitmentHash]:32,[_t.SmartRollupStateHash]:32,[_t.SmartRollupCommitmentHash]:32,[_t.Ed25519EncryptedSeed]:56,[_t.Secp256k1EncryptedSecretKey]:56,[_t.P256EncryptedSecretKey]:56,[_t.BLS12_381EncryptedSecretKey]:56,[_t.Secp256k1EncryptedScalar]:60,[_t.Secp256k1PublicKey]:33,[_t.P256PublicKey]:33,[_t.Secp256k1Scalar]:33,[_t.Secp256k1Element]:33,[_t.Ed25519SecretKey]:64,[_t.Ed25519Signature]:64,[_t.Secp256k1Signature]:64,[_t.P256Signature]:64,[_t.GenericSignature]:64,[_t.ChainID]:4,[_t.SaplingSpendingKey]:169,[_t.EncryptedSaplingSpendingKey]:193,[_t.SaplingAddress]:43,[_t.GenericAggregateSignature]:96,[_t.BLS12_381Signature]:96,[_t.BLS12_381PublicKey]:48,[_t.SlotHeader]:48};function Nt(t,e=""){if("number"!=typeof t){throw new TypeError(`${e&&`"${e}" `}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){throw new RangeError(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}}function kt(t,e,r=""){const n=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&"BYTES_PER_ELEMENT"in i&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;if(!n||o&&s!==e){const i=(r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${s}`:"type="+typeof t);if(!n)throw new TypeError(i);throw new RangeError(i)}return t}function Lt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ct(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Bt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Dt(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const Ut=Bt?t=>t:t=>Dt(t)>>>0;const Kt=Bt?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=Dt(t[e]);return t};function Ht(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}const Ft=Uint8Array.from([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,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]),Gt=BigInt(2**32-1),Vt=BigInt(32);const jt=(t,e,r)=>t>>>r|e<<32-r,$t=(t,e,r)=>t<<32-r|e>>>r,zt=(t,e,r)=>t>>>r-32|e<<64-r;function qt(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const Wt=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Zt=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Yt=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xt=new Uint32Array(32);function Jt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Xt[2*t],u=Xt[2*t+1],l=Xt[2*e],h=Xt[2*e+1],f=Xt[2*r],d=Xt[2*r+1],p=Xt[2*n],g=Xt[2*n+1],m=Wt(c,l,o);var y,b;u=Zt(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:(b=p,b),Dl:(y=g,y)}),({h:d,l:f}=qt(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:jt(h,l,24),Bl:$t(h,l,24)}),Xt[2*t]=c,Xt[2*t+1]=u,Xt[2*e]=l,Xt[2*e+1]=h,Xt[2*r]=f,Xt[2*r+1]=d,Xt[2*n]=p,Xt[2*n+1]=g}function Qt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Xt[2*t],u=Xt[2*t+1],l=Xt[2*e],h=Xt[2*e+1],f=Xt[2*r],d=Xt[2*r+1],p=Xt[2*n],g=Xt[2*n+1],m=Wt(c,l,o);var y,b,v;u=Zt(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:jt(g,p,16),Dl:$t(g,p,16)}),({h:d,l:f}=qt(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:(y=h,b=l,v=63,y<<64-v|b>>>v-32),Bl:zt(h,l,63)}),Xt[2*t]=c,Xt[2*t+1]=u,Xt[2*e]=l,Xt[2*e+1]=h,Xt[2*r]=f,Xt[2*r+1]=d,Xt[2*n]=p,Xt[2*n+1]=g}class te{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,e){Nt(t),Nt(e),this.blockLen=t,this.outputLen=e,this.buffer=new Uint8Array(t),this.buffer32=Ct(this.buffer)}update(t){Lt(this),kt(t);const{blockLen:e,buffer:r,buffer32:n}=this,i=t.length,s=t.byteOffset,o=t.buffer;for(let a=0;a<i;){this.pos===e&&(Kt(n),this.compress(n,0,!1),Kt(n),this.pos=0);const c=Math.min(e-this.pos,i-a),u=s+a;if(c===e&&!(u%4)&&a+c<i){const t=new Uint32Array(o,u,Math.floor((i-a)/4));Kt(t);for(let r=0;a+e<i;r+=n.length,a+=e)this.length+=e,this.compress(t,r,!1);Kt(t);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,this.length+=c,a+=c}return this}digestInto(t){Lt(this),function(t,e){kt(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}(t,this);const{pos:e,buffer32:r}=this;if(this.finished=!0,Mt(this.buffer.subarray(e)),Kt(r),this.compress(r,0,!0),Kt(r),3&t.byteOffset)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const n=this.get(),i=Ct(t),s=Math.floor(this.outputLen/4);for(let t=0;t<s;t++)i[t]=Ut(n[t]);const o=this.outputLen%4;if(!o)return;const a=4*s,c=n[s];for(let e=0;e<o;e++)t[a+e]=c>>>8*e}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){const{buffer:e,length:r,finished:n,destroyed:i,outputLen:s,pos:o}=this;return t||=new this.constructor({dkLen:s}),t.set(...this.get()),t.buffer.set(e),t.destroyed=i,t.finished=n,t.length=r,t.pos=o,t.outputLen=s,t}clone(){return this._cloneInto()}}class ee extends te{v0l=0|Yt[0];v0h=0|Yt[1];v1l=0|Yt[2];v1h=0|Yt[3];v2l=0|Yt[4];v2h=0|Yt[5];v3l=0|Yt[6];v3h=0|Yt[7];v4l=0|Yt[8];v4h=0|Yt[9];v5l=0|Yt[10];v5h=0|Yt[11];v6l=0|Yt[12];v6h=0|Yt[13];v7l=0|Yt[14];v7h=0|Yt[15];constructor(t={}){const e=void 0===t.dkLen?64:t.dkLen;super(128,e),function(t,e={},r,n,i){if(Nt(r),t<=0||t>r)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=e;if(void 0!==s&&(s.length<1||s.length>r))throw new Error('"key" expected to be undefined or of length=1..'+r);void 0!==o&&kt(o,n,"salt"),void 0!==a&&kt(a,i,"personalization")}(e,t,64,16,16);let{key:r,personalization:n,salt:i}=t,s=0;if(void 0!==r&&(kt(r,void 0,"key"),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,void 0!==i){kt(i,void 0,"salt");const t=Ct(i);this.v4l^=Ut(t[0]),this.v4h^=Ut(t[1]),this.v5l^=Ut(t[2]),this.v5h^=Ut(t[3])}if(void 0!==n){kt(n,void 0,"personalization");const t=Ct(n);this.v6l^=Ut(t[0]),this.v6h^=Ut(t[1]),this.v7l^=Ut(t[2]),this.v7h^=Ut(t[3])}if(void 0!==r){const t=new Uint8Array(this.blockLen);t.set(r),this.update(t)}}get(){let{v0l:t,v0h:e,v1l:r,v1h:n,v2l:i,v2h:s,v3l:o,v3h:a,v4l:c,v4h:u,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.v0l=0|t,this.v0h=0|e,this.v1l=0|r,this.v1h=0|n,this.v2l=0|i,this.v2h=0|s,this.v3l=0|o,this.v3h=0|a,this.v4l=0|c,this.v4h=0|u,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|g}compress(t,e,r){this.get().forEach((t,e)=>Xt[e]=t),Xt.set(Yt,16);let{h:n,l:i}=function(t,e=!1){return e?{h:Number(t&Gt),l:Number(t>>Vt&Gt)}:{h:0|Number(t>>Vt&Gt),l:0|Number(t&Gt)}}(BigInt(this.length));Xt[24]=Yt[8]^i,Xt[25]=Yt[9]^n,r&&(Xt[28]=~Xt[28],Xt[29]=~Xt[29]);let s=0;const o=Ft;for(let r=0;r<12;r++)Jt(0,4,8,12,t,e+2*o[s++]),Qt(0,4,8,12,t,e+2*o[s++]),Jt(1,5,9,13,t,e+2*o[s++]),Qt(1,5,9,13,t,e+2*o[s++]),Jt(2,6,10,14,t,e+2*o[s++]),Qt(2,6,10,14,t,e+2*o[s++]),Jt(3,7,11,15,t,e+2*o[s++]),Qt(3,7,11,15,t,e+2*o[s++]),Jt(0,5,10,15,t,e+2*o[s++]),Qt(0,5,10,15,t,e+2*o[s++]),Jt(1,6,11,12,t,e+2*o[s++]),Qt(1,6,11,12,t,e+2*o[s++]),Jt(2,7,8,13,t,e+2*o[s++]),Qt(2,7,8,13,t,e+2*o[s++]),Jt(3,4,9,14,t,e+2*o[s++]),Qt(3,4,9,14,t,e+2*o[s++]);this.v0l^=Xt[0]^Xt[16],this.v0h^=Xt[1]^Xt[17],this.v1l^=Xt[2]^Xt[18],this.v1h^=Xt[3]^Xt[19],this.v2l^=Xt[4]^Xt[20],this.v2h^=Xt[5]^Xt[21],this.v3l^=Xt[6]^Xt[22],this.v3h^=Xt[7]^Xt[23],this.v4l^=Xt[8]^Xt[24],this.v4h^=Xt[9]^Xt[25],this.v5l^=Xt[10]^Xt[26],this.v5h^=Xt[11]^Xt[27],this.v6l^=Xt[12]^Xt[28],this.v6h^=Xt[13]^Xt[29],this.v7l^=Xt[14]^Xt[30],this.v7h^=Xt[15]^Xt[31],Mt(Xt)}destroy(){this.destroyed=!0,Mt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const re=Ht(t=>new ee(t)),ne=A,ie=[_t.P256PublicKeyHash,_t.Secp256k1PublicKeyHash,_t.Ed25519PublicKeyHash,_t.BLS12_381PublicKeyHash,_t.ContractHash,_t.SmartRollupHash],se=[_t.P256PublicKey,_t.Secp256k1PublicKey,_t.Ed25519PublicKey,_t.BLS12_381PublicKey],oe=[_t.P256PublicKeyHash,_t.Secp256k1PublicKeyHash,_t.Ed25519PublicKeyHash,_t.BLS12_381PublicKeyHash],ae=[_t.P256Signature,_t.Secp256k1Signature,_t.Ed25519Signature,_t.BLS12_381Signature,_t.GenericSignature];function ce(t,e,r){const n=(()=>{try{return i().decode(t)}catch(t){throw t instanceof Error?t.message.includes("checksum")?new O.ParameterValidationError(O.ValidationResult.INVALID_CHECKSUM):new O.ParameterValidationError(O.ValidationResult.INVALID_ENCODING):t}})();let s;for(s in _t){const t=_t[s],i=xt[t];if(n.length===i.length+It[t]&&n.slice(0,i.length).every((t,e)=>t==i[e])){if(void 0!==e&&e.indexOf(t)<0)throw new O.ParameterValidationError(O.ValidationResult.PREFIX_NOT_ALLOWED);return r?n.slice(i.length):[n.slice(i.length),t]}}throw new O.ParameterValidationError(O.ValidationResult.NO_PREFIX_MATCHED)}function ue(t,e){const[r,n]=ce(t,se);let i;switch(n){case _t.Ed25519PublicKey:i=0;break;case _t.Secp256k1PublicKey:i=1;break;case _t.P256PublicKey:i=2;break;case _t.BLS12_381PublicKey:i=3;break;default:throw new O.InvalidKeyError(O.ValidationResult.NO_PREFIX_MATCHED)}const s=new Uint8Array(r.length+1);return s[0]=i,s.set(r,1),void 0!==e&&"array"===e?s:Oe(s)}function le(t,e){const[r,n]=ce(t,oe),i=new Uint8Array(21);let s;switch(n){case _t.Ed25519PublicKeyHash:s=0;break;case _t.Secp256k1PublicKeyHash:s=1;break;case _t.P256PublicKeyHash:s=2;break;case _t.BLS12_381PublicKeyHash:s=3;break;default:throw new O.InvalidAddressError(t,O.ValidationResult.NO_PREFIX_MATCHED)}return i[0]=s,i.set(r,1),void 0!==e&&"array"===e?i:Oe(i)}function he(t,e){const[r,n]=ce(t);if(n!==_t.BLS12_381PublicKeyHash)throw new O.InvalidKeyError(O.ValidationResult.NO_PREFIX_MATCHED);return void 0!==e&&"array"===e?r:Oe(r)}function fe(t,e){const r=t.indexOf("%");r>=0&&(t=t.slice(0,r));const[n,i]=ce(t,ie),s=new Uint8Array(22);if(i===_t.ContractHash||i===_t.SmartRollupHash||i===_t.ZkRollupHash){let t;switch(i){case _t.ContractHash:t=1;break;case _t.SmartRollupHash:t=3;break;case _t.ZkRollupHash:t=4}s[0]=t,s.set(n,1)}else{let e;switch(i){case _t.Ed25519PublicKeyHash:e=0;break;case _t.Secp256k1PublicKeyHash:e=1;break;case _t.P256PublicKeyHash:e=2;break;case _t.BLS12_381PublicKeyHash:e=3;break;default:throw new O.InvalidAddressError(t,O.ValidationResult.NO_PREFIX_MATCHED)}s[0]=0,s[1]=e,s.set(n,2)}return void 0!==e&&"array"===e?s:Oe(s)}function de(t){const[e,r]=ce(t);let n;switch(r){case _t.P256PublicKey:n=_t.P256PublicKeyHash;break;case _t.Secp256k1PublicKey:n=_t.Secp256k1PublicKeyHash;break;case _t.Ed25519PublicKey:n=_t.Ed25519PublicKeyHash;break;case _t.BLS12_381PublicKey:n=_t.BLS12_381PublicKeyHash;break;default:throw new O.InvalidPublicKeyError(t,O.ValidationResult.NO_PREFIX_MATCHED)}return pe(re(e,{dkLen:20}),n)}function pe(t,e){const r="string"==typeof t?Ee(t):t,n=xt[e],s=new Uint8Array(n.length+r.length);return s.set(n),s.set(r,n.length),i().encode(j.from(s.buffer,s.byteOffset,s.byteLength))}function ge(t){let e,r;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:r=_t.Ed25519PublicKey;break;case 1:r=_t.Secp256k1PublicKey;break;case 2:r=_t.P256PublicKey;break;case 3:r=_t.BLS12_381PublicKey;break;default:throw new Error("invalid address format")}return pe(e.slice(1),r)}function me(t){let e,r;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:r=_t.Ed25519PublicKeyHash;break;case 1:r=_t.Secp256k1PublicKeyHash;break;case 2:r=_t.P256PublicKeyHash;break;case 3:r=_t.BLS12_381PublicKeyHash;break;default:throw new Error("invalid address format")}return pe(e.slice(1,21),r)}function ye(t){let e;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:return me(e.slice(1));case 1:return pe(e.slice(1,21),_t.ContractHash);case 3:return pe(e.slice(1,21),_t.SmartRollupHash);case 4:return pe(e.slice(1,21),_t.ZkRollupHash);default:throw new Error("invalid address format")}}function be(t){return pe(t,_t.BLS12_381PublicKeyHash)}function ve(t){return pe(re(Ee(t),{dkLen:32}),_t.ScriptExpr)}function we(t){return pe(re(Ee(t),{dkLen:32}),_t.OperationHash)}function Ee(t){if((t=t.startsWith("0x")?t.slice(2):t).length%2!=0)throw new O.InvalidHexStringError(t,"Expecting even number of characters");if(!t.match(/^([\da-f]{2})*$/gi))throw new O.InvalidHexStringError(t,"Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'");const e=new Uint8Array(t.length/2);let r=0;for(let n=0;n<t.length;n+=2){const i=t.slice(n,n+2),s=parseInt(i,16);if(Number.isNaN(s))throw new O.InvalidHexStringError(t,"Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'");e[r++]=s}return e}function _e(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function Ae(t){let e=[];if(Object.prototype.hasOwnProperty.call(t,"prim"))"Pair"===t.prim?(e.push(Ae(t.args[0])),e=e.concat(Ae(t.args[1]))):"Elt"===t.prim?e={key:Ae(t.args[0]),val:Ae(t.args[1])}:"True"===t.prim?e=!0:"False"===t.prim&&(e=!1);else if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){const r=Ae(t[n]);void 0!==r.key?(Array.isArray(e)&&(e={keys:[],vals:[]}),e.keys.push(r.key),e.vals.push(r.val)):e.push(r)}}else e=Object.prototype.hasOwnProperty.call(t,"string")?t.string:Object.prototype.hasOwnProperty.call(t,"int")?parseInt(t.int,10):t;return e}function Oe(t){return Array.from(t).map(t=>(t>>4&15).toString(16)+(15&t).toString(16)).join("")}function Se(t){return j.from(t,"utf8").toString("hex")}function Te(t){return j.from(Ee(t)).toString("utf8")}function Pe(t){const e=Ne(t);if(!e.match(/^(0x)?([\da-f]{2})*$/gi))throw new O.InvalidHexStringError(t,"Expecting even number of characters: 0-9, a-z, A-Z, optionally prefixed with 0x");return j.from(e,"hex")}function Re(t,e=8){return j.from(Ie(t,e),"hex")}function xe(t,e=8){return j.from(Ie(t,e),"hex")}function Ie(t,e=8){if(new ne(t).isPositive()){const r=Math.ceil(e/4),n=t.toString(16);let i=n.length>=r?n.length:r;return i=i%2==0?i:i+1,function(t,e){const r="0";if(t.length>=e)return t;{const n=e-t.length;return r.repeat(n)+t}}(n,i)}return new ne(2).pow(e).minus(new ne(t).abs()).toString(16)}function Ne(t){return t.startsWith("0x")?t.slice(2):t}function ke(t){const e=t.indexOf("%");return e>=0?[t.slice(0,e),t.slice(e)]:[t,null]}function Le(t,e){let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];)r++;const n=r<t.length?t[r]:0,i=r<e.length?e[r]:0;return n<i?-1:n>i?1:0}function Ce(t,e){return Me(t,e)===O.ValidationResult.VALID}function Me(t,e){try{ce(t,e)}catch(t){return t instanceof O.ParameterValidationError&&void 0!==t.result?t.result:O.ValidationResult.OTHER}return O.ValidationResult.VALID}function Be(t){const[e]=ke(t??"");return Me(e,ie)}function De(t){return Me(t,[_t.ChainID])}function Ue(t){return Me(t,[_t.ContractHash])}function Ke(t){return Me(t,oe)}function He(t){return Me(t,ae)}function Fe(t){return Me(t,se)}function Ge(t){return Me(t,[_t.OperationHash])}function Ve(t){return Me(t,[_t.ProtocolHash])}function je(t){return Me(t,[_t.BlockHash])}function $e(t){return Me(t,[_t.SaplingSpendingKey])}function ze(t){return Me(t,[_t.SmartRollupHash])}const qe={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"},We="BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_",Ze="BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";function Ye(t,e,r,n,i){const[s,o]=(()=>{try{return ce(e,se)}catch(t){throw t instanceof O.ParameterValidationError?new O.InvalidPublicKeyError(e,t.result):t}})(),a=(()=>{try{const[t]=ce(r,ae);return t}catch(t){throw t instanceof O.ParameterValidationError?new O.InvalidSignatureError(r,t.result):t}})();let c;if(c="string"==typeof t?Ee(t):t,0===c.length)throw new O.InvalidMessageError(Oe(c),"can't be empty");if(void 0!==n&&(c=_e(n,c)),i)return function(t,e,r){try{const n=Xe.hash(e,Ze);return Xe.verify(t,n,r)}catch{return!1}}(a,c,s);switch(o){case _t.P256PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return P.s9.verify(t,n,r)}catch{return!1}}(a,c,s);case _t.Secp256k1PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return T.bI.verify(t,n,r)}catch{return!1}}(a,c,s);case _t.Ed25519PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return S.ev.verify(t,n,r)}catch{return!1}}(a,c,s);default:return function(t,e,r){try{const n=Xe.hash(e,We);return Xe.verify(t,n,r)}catch{return!1}}(a,c,s)}}const Xe=R.A.longSignatures;class Je extends O.ParameterValidationError{constructor(t,e){super(`The protocol hash '${t}' is invalid`,e),this.protocolHash=t,this.name="InvalidProtocolHashError",this.name=this.constructor.name}}class Qe extends O.UnsupportedActionError{constructor(t,e){super(`Unable to convert ${t} to a ${e}`),this.value=t,this.desiredType=e,this.name=this.constructor.name}}function tr(t){switch(t){case"tz":return 6;case"mtz":return 3;default:return 0}}function er(t="mutez",e="mutez",r){let n;try{n=new A(r)}catch{return r}return n.isNaN()?r:n.multipliedBy(Math.pow(10,tr(t))).dividedBy(Math.pow(10,tr(e)))}},268(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BATCH_KINDS=void 0;const n=r(3157);e.BATCH_KINDS=[n.OpKind.ACTIVATION,n.OpKind.ORIGINATION,n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET,n.OpKind.SMART_ROLLUP_ADD_MESSAGES,n.OpKind.SMART_ROLLUP_ORIGINATE,n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]},5025(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCBatchProvider=e.OperationBatch=e.BATCH_KINDS=void 0;const n=r(2654),i=r(7669),s=r(3157),o=r(2403),a=r(6571),c=r(5605),u=r(3682);var l=r(268);Object.defineProperty(e,"BATCH_KINDS",{enumerable:!0,get:function(){return l.BATCH_KINDS}});class h extends c.Provider{constructor(t,e){super(t),this.estimator=e,this.operations=[],this.prepare=new u.PrepareProvider(this.context)}withTransfer(t){const e=(0,o.validateAddress)(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.to,e);return this.operations.push({kind:s.OpKind.TRANSACTION,...t}),this}withTransferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.destination,e);return this.operations.push({kind:s.OpKind.TRANSFER_TICKET,...t}),this}withContractCall(t,e={}){return this.withTransfer(t.toTransferParams(e))}withDelegation(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);const r=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.delegate,r);return this.operations.push({kind:s.OpKind.DELEGATION,...t}),this}withActivation({pkh:t,secret:e}){const r=(0,o.validateKeyHash)(t);if(r!==o.ValidationResult.VALID)throw new a.InvalidKeyHashError(t,r);return this.operations.push({kind:s.OpKind.ACTIVATION,pkh:t,secret:e}),this}withOrigination(t){return this.operations.push({kind:s.OpKind.ORIGINATION,...t}),this}withRegisterGlobalConstant(t){return this.operations.push({kind:s.OpKind.REGISTER_GLOBAL_CONSTANT,...t}),this}withIncreasePaidStorage(t){return this.operations.push({kind:s.OpKind.INCREASE_PAID_STORAGE,...t}),this}withUpdateConsensusKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");return this.operations.push({kind:s.OpKind.UPDATE_CONSENSUS_KEY,...t}),this}withUpdateCompanionKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e!==o.PrefixV2.BLS12_381PublicKey)throw new a.ProhibitedActionError("companion key must be a bls account");if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as companion key ");return this.operations.push({kind:s.OpKind.UPDATE_COMPANION_KEY,...t}),this}withSmartRollupAddMessages(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_ADD_MESSAGES,...t}),this}withSmartRollupOriginate(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_ORIGINATE,...t}),this}withSmartRollupExecuteOutboxMessage(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,...t}),this}async getRPCOp(t){switch(t.kind){case s.OpKind.TRANSACTION:return(0,n.createTransferOperation)({...t});case s.OpKind.ORIGINATION:return(0,n.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...t}));case s.OpKind.DELEGATION:return(0,n.createSetDelegateOperation)({...t});case s.OpKind.REGISTER_GLOBAL_CONSTANT:return(0,n.createRegisterGlobalConstantOperation)({...t});case s.OpKind.INCREASE_PAID_STORAGE:return(0,n.createIncreasePaidStorageOperation)({...t});case s.OpKind.UPDATE_CONSENSUS_KEY:return(0,n.createUpdateConsensusKeyOperation)({...t});case s.OpKind.UPDATE_COMPANION_KEY:return(0,n.createUpdateCompanionKeyOperation)({...t});case s.OpKind.TRANSFER_TICKET:return(0,n.createTransferTicketOperation)({...t});case s.OpKind.SMART_ROLLUP_ADD_MESSAGES:return(0,n.createSmartRollupAddMessagesOperation)({...t});case s.OpKind.SMART_ROLLUP_ORIGINATE:return(0,n.createSmartRollupOriginateOperation)({...t});case s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return(0,n.createSmartRollupExecuteOutboxMessageOperation)({...t});default:throw new a.InvalidOperationKindError(JSON.stringify(t.kind))}}with(t){for(const e of t)switch(e.kind){case s.OpKind.TRANSACTION:this.withTransfer(e);break;case s.OpKind.ORIGINATION:this.withOrigination(e);break;case s.OpKind.DELEGATION:this.withDelegation(e);break;case s.OpKind.ACTIVATION:this.withActivation(e);break;case s.OpKind.REGISTER_GLOBAL_CONSTANT:this.withRegisterGlobalConstant(e);break;case s.OpKind.INCREASE_PAID_STORAGE:this.withIncreasePaidStorage(e);break;case s.OpKind.TRANSFER_TICKET:this.withTransferTicket(e);break;case s.OpKind.SMART_ROLLUP_ADD_MESSAGES:this.withSmartRollupAddMessages(e);break;case s.OpKind.SMART_ROLLUP_ORIGINATE:this.withSmartRollupOriginate(e);break;case s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:this.withSmartRollupExecuteOutboxMessage(e);break;default:throw new a.InvalidOperationKindError(JSON.stringify(e.kind))}return this}async send(t){const e=await this.signer.publicKeyHash(),r=t&&t.source||e,n=await this.estimator.batch(this.operations);n.length!==this.operations.length&&n.shift();const s=await this.prepare.batch(this.operations,n),o=await this.forge(s),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new i.BatchOperation(a,s.opOb.contents,r,u,l,c)}}e.OperationBatch=h;e.RPCBatchProvider=class{constructor(t,e){this.context=t,this.estimator=e}batch(t){const e=new h(this.context,this.estimator);return Array.isArray(t)&&e.with(t),e}}},5283(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getRevealFeeInternal=e.getRevealFee=e.getRevealGasLimit=e.ChainIds=e.protocols=e.Protocols=e.COST_PER_BYTE=e.ORIGINATION_SIZE=e.REVEAL_STORAGE_LIMIT=void 0;const r=171,n=157,i=447,s=3252,o=278,a=277,c=306,u=736;var l,h;e.REVEAL_STORAGE_LIMIT=0,e.ORIGINATION_SIZE=257,e.COST_PER_BYTE=250,function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.PsiThaCa="PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(l||(e.Protocols=l={})),e.protocols={"004":[l.Pt24m4xi],"005":[l.PsBABY5H,l.PsBabyM1],"006":[l.PsCARTHA],"007":[l.PsDELPH1],"008":[l.PtEdo2Zk],"009":[l.PsFLorena],"010":[l.PtGRANADs],"011":[l.PtHangz2],"012":[l.PsiThaCa,l.Psithaca2],"013":[l.PtJakart2],"014":[l.PtKathman],"015":[l.PtLimaPtL],"016":[l.PtMumbai2],"017":[l.PtNairobi],"019":[l.ProxfordY],"020":[l.PtParisBx,l.PsParisCZ],"021":[l.PsQuebecn],"022":[l.PsRiotuma],"023":[l.PtSeouLou],"024":[l.PtTALLiNt],"025":[l.PsUshuai9],"026":[l.ProtoALpha]},function(t){t.MAINNET="NetXdQprcVkpaWU",t.GHOSTNET="NetXnHfVqm9iesp",t.SHADOWNET="NetXsqzbfFenSTS",t.CARTHAGENET="NetXjD3HPJJjmcd",t.DELPHINET="NetXm8tYqnMWky1",t.EDONET="NetXSgo1ZT2DRUG",t.FLORENCENET="NetXxkAx4woPLyu",t.GRANADANET="NetXz969SFaFn8k",t.HANGZHOUNET="NetXZSsxBpMQeAT",t.ITHACANET="NetXbhmtAbMukLc",t.JAKARTANET2="NetXLH1uAxK7CCh",t.KATHMANDUNET="NetXazhm4yetmff",t.LIMANET="NetXizpkH94bocH",t.MUMBAINET="NetXQw6nWSnrJ5t",t.MUMBAINET2="NetXgbcrNtXD2yA",t.NAIROBINET="NetXyuzvDo2Ugzb",t.OXFORDNET2="NetXxWsskGahzQB",t.PARISBNET="NetXo8SqH1c38SS",t.PARISCNET="NetXXWAHLEvre9b",t.QUEBECNET="NetXuTeGinLEqxp",t.RIONET="NetXPdgaoabtBth",t.SEOULNET="NetXd56aBs1aeW3",t.TALLINNNET="NetXe8DbhW9A1eS",t.USHUAIANET="NetXpX8WSZkAZZA"}(h||(e.ChainIds=h={}));e.getRevealGasLimit=t=>Math.round(37*f(t)/10);const f=t=>{switch(t.substring(0,3)){case"tz1":return r;case"tz2":return n;case"tz3":return i;case"tz4":return s;default:throw new Error(`Cannot estimate reveal gas limit for ${t}`)}};e.getRevealFee=t=>Math.round(12*(0,e.getRevealFeeInternal)(t)/10);e.getRevealFeeInternal=t=>{switch(t.substring(0,3)){case"tz1":return o;case"tz2":return a;case"tz3":return c;case"tz4":return 1.7*u;default:throw new Error(`Cannot estimate reveal fee for ${t}`)}}},7021(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Context=e.defaultConfigConfirmation=void 0;const n=r(3157),i=r(2245),s=r(6425),o=r(808),a=r(8907),c=r(4019),u=r(3995),l=r(5025),h=r(1170),f=r(8541),d=r(577),p=r(1948),g=r(8320),m=r(4631),y=r(8648),b=r(8724),v=r(7583);e.defaultConfigConfirmation={defaultConfirmationCount:1,confirmationPollingTimeoutSecond:180};class w{constructor(t,r=new s.NoopSigner,w,E=new p.BehaviorSubject({...e.defaultConfigConfirmation}),_,A,O,S,T,P,R,x){this._rpc=t,this._signer=r,this._proto=w,this._config=E,this.providerDecorator=[],this.tz=new a.RpcTzProvider(this),this.estimate=new c.RPCEstimateProvider(this),this.contract=new u.RpcContractProvider(this,this.estimate),this.prepare=new v.PrepareProvider(this),this.batch=new l.RPCBatchProvider(this,this.estimate),this.wallet=new h.Wallet(this),this.withExtensions=()=>{let t=this.clone();return this.providerDecorator.forEach(e=>{t=e(t)}),t},"string"==typeof this._rpc?this._rpcClient=new n.RpcClient(this._rpc):this._rpcClient=this._rpc,this._forger=_||new b.TaquitoLocalForger(this),this._injector=A||new i.RpcInjector(this),this.operationFactory=new o.OperationFactory(this),this._walletProvider=S||new h.LegacyWalletProvider(this),this._parser=T||new f.MichelCodecParser(this),this._packer=O||new d.RpcPacker(this),this._globalConstantsProvider=P||new g.NoopGlobalConstantsProvider,this._readProvider=R||new m.RpcReadAdapter(this._rpcClient),this._stream=x||new y.PollingSubscribeProvider(this)}get config(){return this._config.getValue()}set config(t){this._config.next({...t})}setPartialConfig(t){this._config.next({...this._config.getValue(),...t})}get rpc(){return this._rpcClient}set rpc(t){this._rpcClient=t}get injector(){return this._injector}set injector(t){this._injector=t}get forger(){return this._forger}set forger(t){this._forger=t}get signer(){return this._signer}set signer(t){this._signer=t}get walletProvider(){return this._walletProvider}set walletProvider(t){this._walletProvider=t}set proto(t){this._proto=t}get proto(){return this._proto}get parser(){return this._parser}set parser(t){this._parser=t}get packer(){return this._packer}set packer(t){this._packer=t}get globalConstantsProvider(){return this._globalConstantsProvider}set globalConstantsProvider(t){this._globalConstantsProvider=t}get readProvider(){return this._readProvider}set readProvider(t){this._readProvider=t}get stream(){return this._stream}set stream(t){this._stream=t}async isAnyProtocolActive(t=[]){if(this._proto)return t.includes(this._proto);{const e=await this.readProvider.getNextProtocol("head");return t.includes(e)}}isAnySignerConfigured(){return!(this.signer instanceof s.NoopSigner)}clone(){return new w(this.rpc,this.signer,this.proto,this._config,this.forger,this._injector,this.packer,this._walletProvider,this._parser,this._globalConstantsProvider,this._readProvider,this._stream)}registerProviderDecorator(t){this.providerDecorator.push(t)}}e.Context=w},9676(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BigMapAbstraction=void 0;r(7873).default;const n=r(2211);e.BigMapAbstraction=class{constructor(t,e,r,n){this.id=t,this.schema=e,this.provider=r,this.defaultBlock=n}async get(t,e){try{return await this.provider.getBigMapKeyByID(this.id.toString(),t,this.schema,e??this.defaultBlock)}catch(t){if(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND)return;throw t}}async getMultipleValues(t,e,r=5){return this.provider.getBigMapKeysByID(this.id.toString(),t,this.schema,e??this.defaultBlock,r)}toJSON(){return this.id.toString()}toString(){return this.id.toString()}}},3369(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.compose=function(t,e){return(r,n)=>e(t(r,n),n)}},9828(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_SMART_CONTRACT_METHOD_NAME=void 0,e.DEFAULT_SMART_CONTRACT_METHOD_NAME="default"},1844(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractMethodFactory=void 0;const n=r(2291),i=r(3085);e.ContractMethodFactory=class{constructor(t,e){this.provider=t,this.contractAddress=e}createContractMethodObjectParam(t,e,r,i=!0,s=!1){return new n.ContractMethodObject(this.provider,this.contractAddress,t,e,r,i,s)}createContractViewObjectParam(t,e,r,n,s){return new i.OnChainView(t,e,this.contractAddress,r,n,s)}}},4749(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2291(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractMethodObject=void 0;const n=r(9828);e.ContractMethodObject=class{constructor(t,e,r,n,i="unit",s=!0,o=!1){this.provider=t,this.address=e,this.parameterSchema=r,this.name=n,this.args=i,this.isMultipleEntrypoint=s,this.isAnonymous=o}getSignature(){const t=this.parameterSchema.generateSchema();if(this.isAnonymous){const e=t.schema;return e?.[this.name]}return t}send(t={}){return this.provider&&"pkh"in this.provider?this.provider.transfer(this.toTransferParams(t)).send():this.provider.transfer(this.toTransferParams(t))}toTransferParams({fee:t,gasLimit:e,storageLimit:r,source:i,amount:s=0,mutez:o=!1}={}){return{to:this.address,amount:s,fee:t,mutez:o,source:i,gasLimit:e,storageLimit:r,parameter:{entrypoint:this.isMultipleEntrypoint?this.name:n.DEFAULT_SMART_CONTRACT_METHOD_NAME,value:this.isAnonymous?this.parameterSchema.EncodeObject({[this.name]:this.args}):this.parameterSchema.EncodeObject(this.args)}}}}},3085(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OnChainView=void 0;const n=r(2403),i=r(6645),s=r(6571);e.OnChainView=class{constructor(t,e,r,n,i,s="Unit"){this._rpc=t,this._readProvider=e,this._contractAddress=r,this._smartContractViewSchema=n,this._contractStorageType=i,this._args=s}getSignature(){return{parameter:this._smartContractViewSchema.extractArgsSchema(),result:this._smartContractViewSchema.extractResultSchema()}}async executeView(t){this.verifyContextExecution(t);const e=await this._readProvider.getChainId(),r=this.transformArgsToMichelson(),n={contract:this._contractAddress,view:this._smartContractViewSchema.viewName,input:r,chain_id:e,source:t.viewCaller};return t.source&&(n.payer=t.source),this.executeViewAndDecodeResult(n)}verifyContextExecution(t){if(t.source&&(0,n.validateAddress)(t.source)!==n.ValidationResult.VALID)throw new i.InvalidViewSimulationContext(`The source account who initialized the view execution is invalid: ${t.source}.`);if(!t.viewCaller||(0,n.validateAddress)(t.viewCaller)!==n.ValidationResult.VALID)throw new i.InvalidViewSimulationContext(`The contract which is the caller of view is invalid: ${t.viewCaller}.`)}transformArgsToMichelson(){try{return this._smartContractViewSchema.encodeViewArgs(this._args)}catch(t){throw new s.InvalidViewParameterError(this._smartContractViewSchema.viewName,this.getSignature(),this._args,t)}}adaptViewCodeToContext(t,e,r){const n={BALANCE:[{prim:"PUSH",args:[{prim:"mutez"},{int:r}]}],SENDER:[{prim:"PUSH",args:[{prim:"address"},{string:e}]}],SELF_ADDRESS:[{prim:"PUSH",args:[{prim:"address"},{string:this._contractAddress}]}],AMOUNT:[{prim:"PUSH",args:[{prim:"mutez"},{int:"0"}]}]};return t.forEach((i,s)=>{i.prim in n&&(t[s]=Object(n)[i.prim]),i.args&&0!==i.args.length?this.adaptViewCodeToContext(i.args,e,r):Array.isArray(i)&&this.adaptViewCodeToContext(i,e,r)}),t}async executeViewAndDecodeResult(t){let e;try{e=(await this._rpc.runScriptView(t)).data}catch(t){const e=(0,i.validateAndExtractFailwith)(t);throw e?new i.ViewSimulationError(`The simulation of the on-chain view named ${this._smartContractViewSchema.viewName} failed with: ${JSON.stringify(e)}`,this._smartContractViewSchema.viewName,e,t):t}return this._smartContractViewSchema.decodeViewResult(e)}}},9339(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractAbstraction=e.ContractView=e.DEFAULT_SMART_CONTRACT_METHOD_NAME=void 0;const n=r(5602),i=r(2403),s=r(1844),o=r(6645),a=r(6571),c=r(9828);Object.defineProperty(e,"DEFAULT_SMART_CONTRACT_METHOD_NAME",{enumerable:!0,get:function(){return c.DEFAULT_SMART_CONTRACT_METHOD_NAME}});const u=r(9281);class l{constructor(t,e,r,n,i,s,o){this.currentContract=t,this.name=e,this.callbackParametersSchema=r,this.parameterSchema=n,this.args=i,this.rpc=s,this.readProvider=o}async read(t){const e=(0,i.validateChain)(t??"");if((0,i.validateContractAddress)(t??"")==i.ValidationResult.VALID)throw new a.DeprecationError("Since version 12, the lambda view no longer depends on a lambda contract. The read method no longer accepts a contract address as a parameter.");if(t&&e!==i.ValidationResult.VALID)throw new a.InvalidChainIdError(t,e);const r=this.parameterSchema.Encode(...this.args),n=await this.rpc.runView({contract:this.currentContract.address,entrypoint:this.name,input:r,chain_id:t||await this.readProvider.getChainId()});return this.callbackParametersSchema.Execute(n.data)}}e.ContractView=l;e.ContractAbstraction=class{constructor(t,e,r,i,o,a,c,u="head"){this.address=t,this.script=e,this.storageProvider=i,this.entrypoints=o,this.rpc=a,this.readProvider=c,this.readBlock=u,this.methodsObject={},this.views={},this.contractViews={},this.contractMethodFactory=new s.ContractMethodFactory(r,t),this.schema=n.Schema.fromRPCResponse({script:this.script}),this.parameterSchema=n.ParameterSchema.fromRPCResponse({script:this.script}),this.viewSchema=n.ViewSchema.fromRPCResponse({script:this.script}),0!==this.viewSchema.length&&this._initializeOnChainViews(this,a,this.readProvider,this.viewSchema),this.eventSchema=n.EventSchema.fromRPCResponse({script:this.script}),this._initializeMethods(this,this.entrypoints.entrypoints,this.rpc,this.readProvider)}_initializeMethods(t,e,r,i){const s=this.parameterSchema,a=Object.keys(e);if(s.isMultipleEntryPoint){a.forEach(s=>{const a=new n.ParameterSchema(e[s]);if(this.methodsObject[s]=function(e){return t.contractMethodFactory.createContractMethodObjectParam(a,s,e)},(t=>{let e=!1;if("prim"in t&&"pair"===t.prim&&t.args){const r=t.args[t.args.length-1];"prim"in r&&"contract"===r.prim&&(e=!0)}return e})(e[s])){const a=function(...a){const c=e[s].args[0],u=new n.ParameterSchema(c),h=e[s].args[1].args[0],f=new n.ParameterSchema(h);return((t,e,r)=>{const n=e.ExtractSignatures();if(!n.find(e=>e.length===t.length))throw new o.InvalidParameterError(r,n,t)})(a,u,s),new l(t,s,f,u,a,r,i)};this.views[s]=a}});const c=s.generateSchema();(c.schema&&"object"==typeof c.schema?Object.keys(c.schema):[]).filter(t=>-1===Object.keys(e).indexOf(t)).forEach(e=>{this.methodsObject[e]=function(r){return t.contractMethodFactory.createContractMethodObjectParam(s,e,r,!1,!0)}})}else{const e=this.parameterSchema;this.methodsObject[c.DEFAULT_SMART_CONTRACT_METHOD_NAME]=function(r){return t.contractMethodFactory.createContractMethodObjectParam(e,c.DEFAULT_SMART_CONTRACT_METHOD_NAME,r,!1)}}}_initializeOnChainViews(t,e,r,n){const i=this.schema.val;n.forEach(n=>{this.contractViews[n.viewName]=function(s){return t.contractMethodFactory.createContractViewObjectParam(e,r,n,i,s)}})}async storage(){return"head"!==this.readBlock?this.schema.Execute(this.script.storage,(0,u.smartContractAbstractionSemantic)(this.storageProvider,this.readBlock)):this.storageProvider.getStorage(this.address,this.schema,this.readBlock)}}},6645(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidBalanceError=e.OriginationParameterError=e.RevealOperationError=e.InvalidViewSimulationContext=e.validateAndExtractFailwith=e.ViewSimulationError=e.InvalidInitParameter=e.InvalidCodeParameter=e.InvalidDelegationSource=e.InvalidParameterError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t,e,r){super(),this.smartContractMethodName=t,this.sigs=e,this.invalidParams=r,this.name="InvalidParameterError",this.message=`${t} Received ${r.length} arguments while expecting one of the following signatures (${JSON.stringify(e)})`}}e.InvalidParameterError=i;class s extends n.ParameterValidationError{constructor(t){super(),this.source=t,this.name="InvalidDelegationSource",this.message=`Since Babylon delegation source can no longer be a contract address ${t}. Please use the smart contract abstraction to set your delegate.`}}e.InvalidDelegationSource=s;class o extends n.ParameterValidationError{constructor(t,e){super(),this.message=t,this.data=e,this.name="InvalidCodeParameter"}}e.InvalidCodeParameter=o;class a extends n.ParameterValidationError{constructor(t,e){super(),this.message=t,this.data=e,this.name="InvalidInitParameter"}}e.InvalidInitParameter=a;class c extends n.RpcError{constructor(t,e,r,n){super(),this.message=t,this.viewName=e,this.failWith=r,this.cause=n,this.name="ViewSimulationError"}}e.ViewSimulationError=c;e.validateAndExtractFailwith=t=>{if(u(t.body)){const e=JSON.parse(t.body);if(Array.isArray(e)&&"with"in e[e.length-1])return e[e.length-1].with}};const u=t=>{try{JSON.parse(t)}catch(t){return!1}return!0};class l extends n.ParameterValidationError{constructor(t){super(),this.info=t,this.name="InvalidViewSimulationContext",this.message=`${t} Please configure the context of the view execution in the executeView method.`}}e.InvalidViewSimulationContext=l;class h extends n.RpcError{constructor(t){super(),this.message=t,this.name="RevealOperationError"}}e.RevealOperationError=h;class f extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name}}e.OriginationParameterError=f;class d extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidBalanceError"}}e.InvalidBalanceError=d},2445(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.smartContractAbstractionSemantic=e.compose=void 0,i(r(9339),e),i(r(6645),e),i(r(1966),e),i(r(1752),e),i(r(2654),e),i(r(6200),e);var s=r(3369);Object.defineProperty(e,"compose",{enumerable:!0,get:function(){return s.compose}}),i(r(4749),e),i(r(2291),e),i(r(3e3),e);var o=r(9281);Object.defineProperty(e,"smartContractAbstractionSemantic",{enumerable:!0,get:function(){return o.smartContractAbstractionSemantic}})},1966(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1752(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MANAGER_LAMBDA=void 0;e.MANAGER_LAMBDA={setDelegate:t=>[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PUSH",args:[{prim:"key_hash"},{string:t}]},{prim:"SOME"},{prim:"SET_DELEGATE"},{prim:"CONS"}],removeDelegate:()=>[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"NONE",args:[{prim:"key_hash"}]},{prim:"SET_DELEGATE"},{prim:"CONS"}],transferImplicit:(t,e)=>[{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:(t,e)=>[{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"}]}},1254(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.retryOnNotFound=e.isNotFoundError=void 0;const n=r(2211),i=[0,200,400,800],s=t=>new Promise(e=>{setTimeout(e,t)});e.isNotFoundError=t=>t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND;e.retryOnNotFound=async(t,r=i)=>{let n;for(const i of r){i>0&&await s(i);try{return await t()}catch(t){if(!(0,e.isNotFoundError)(t))throw t;n=t}}throw n}},2654(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createSmartRollupExecuteOutboxMessageOperation=e.createSmartRollupOriginateOperation=e.createSmartRollupAddMessagesOperation=e.createUpdateCompanionKeyOperation=e.createUpdateConsensusKeyOperation=e.createProposalsOperation=e.createBallotOperation=e.createDrainDelegateOperation=e.createIncreasePaidStorageOperation=e.createTransferTicketOperation=e.createRegisterGlobalConstantOperation=e.createRevealOperation=e.createRegisterDelegateOperation=e.createSetDelegateOperation=e.createTransferOperation=e.createOriginationOperation=e.createActivationOperation=void 0;const n=r(5602),i=r(3157),s=r(5283),o=r(2403),a=r(6645);e.createActivationOperation=async({pkh:t,secret:e})=>({kind:i.OpKind.ACTIVATION,pkh:t,secret:e});e.createOriginationOperation=async({code:t,init:e,balance:r="0",delegate:s,storage:c,fee:u,gasLimit:l,storageLimit:h,mutez:f=!1})=>{if(void 0!==c&&void 0!==e)throw new a.OriginationParameterError("Storage and Init cannot be set a the same time. Please either use storage or init but not both.");if(!Array.isArray(t))throw new a.InvalidCodeParameter("Wrong code parameter type, expected an array",t);let d;if(void 0!==c){const e=t.find(t=>"prim"in t&&"storage"===t.prim);if(void 0===e?.args)throw new a.InvalidCodeParameter("The storage section is missing from the script",t);d=new n.Schema(e.args[0]).Encode(c)}else{if(void 0===e||"object"!=typeof e)throw new a.InvalidInitParameter("Wrong init parameter type, expected JSON Michelson",e);d=e}const p={code:t,storage:d};if(isNaN(Number(r)))throw new a.InvalidBalanceError(`Invalid Balance "${r}", cannot be converted to a number`);const g={kind:i.OpKind.ORIGINATION,fee:u,gas_limit:l,storage_limit:h,balance:f?r.toString():(0,o.format)("tz","mutez",r).toString(),script:p};return s&&(g.delegate=s),g};e.createTransferOperation=async({to:t,amount:e,parameter:r,fee:n,gasLimit:s,storageLimit:a,mutez:c=!1})=>({kind:i.OpKind.TRANSACTION,fee:n,gas_limit:s,storage_limit:a,amount:c?e.toString():(0,o.format)("tz","mutez",e).toString(),destination:t,parameters:r});e.createSetDelegateOperation=async({delegate:t,source:e,fee:r,gasLimit:n,storageLimit:s})=>({kind:i.OpKind.DELEGATION,source:e,fee:r,gas_limit:n,storage_limit:s,delegate:t});e.createRegisterDelegateOperation=async({fee:t,gasLimit:e,storageLimit:r},n)=>({kind:i.OpKind.DELEGATION,fee:t,gas_limit:e,storage_limit:r,delegate:n});e.createRevealOperation=async({fee:t,gasLimit:e,storageLimit:r,proof:n},o,a)=>({kind:i.OpKind.REVEAL,fee:t,public_key:a,source:o,gas_limit:e??(0,s.getRevealGasLimit)(o),storage_limit:r,proof:n});e.createRegisterGlobalConstantOperation=async({value:t,source:e,fee:r,gasLimit:n,storageLimit:s})=>({kind:i.OpKind.REGISTER_GLOBAL_CONSTANT,value:t,fee:r,gas_limit:n,storage_limit:s,source:e});e.createTransferTicketOperation=async({ticketContents:t,ticketTy:e,ticketTicketer:r,ticketAmount:n,destination:s,entrypoint:o,source:a,fee:c,gasLimit:u,storageLimit:l})=>({kind:i.OpKind.TRANSFER_TICKET,fee:c,gas_limit:u,storage_limit:l,source:a,ticket_contents:t,ticket_ty:e,ticket_ticketer:r,ticket_amount:n,destination:s,entrypoint:o});e.createIncreasePaidStorageOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,amount:s,destination:o})=>({kind:i.OpKind.INCREASE_PAID_STORAGE,source:t,fee:e,gas_limit:r,storage_limit:n,amount:s,destination:o});e.createDrainDelegateOperation=async({consensus_key:t,delegate:e,destination:r})=>({kind:i.OpKind.DRAIN_DELEGATE,consensus_key:t,delegate:e,destination:r});e.createBallotOperation=async({source:t,proposal:e,ballot:r})=>({kind:i.OpKind.BALLOT,source:t,proposal:e,ballot:r});e.createProposalsOperation=async({source:t,proposals:e})=>({kind:i.OpKind.PROPOSALS,source:t,proposals:e});e.createUpdateConsensusKeyOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pk:s,proof:o})=>({kind:i.OpKind.UPDATE_CONSENSUS_KEY,source:t,fee:e,gas_limit:r,storage_limit:n,pk:s,proof:o});e.createUpdateCompanionKeyOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pk:s,proof:o})=>({kind:i.OpKind.UPDATE_COMPANION_KEY,source:t,fee:e,gas_limit:r,storage_limit:n,pk:s,proof:o});e.createSmartRollupAddMessagesOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,message:s})=>({kind:i.OpKind.SMART_ROLLUP_ADD_MESSAGES,source:t,fee:e,gas_limit:r,storage_limit:n,message:s});e.createSmartRollupOriginateOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pvmKind:s,kernel:o,parametersType:a})=>({kind:i.OpKind.SMART_ROLLUP_ORIGINATE,source:t,fee:e,gas_limit:r,storage_limit:n,pvm_kind:s,kernel:o,parameters_ty:a});e.createSmartRollupExecuteOutboxMessageOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,rollup:s,cementedCommitment:o,outputProof:a})=>({kind:i.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,source:t,fee:e,gas_limit:r,storage_limit:n,rollup:s,cemented_commitment:o,output_proof:a})},3995(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcContractProvider=void 0;const n=r(2211),i=r(5602),s=r(3157),o=r(2403),a=r(6571),c=r(5025),u=r(4410),l=r(2526),h=r(6759),f=r(4368),d=r(2741),p=r(9339),g=r(6645),m=r(9281),y=r(4371),b=r(1660),v=r(659),w=r(8835),E=r(5574),_=r(2552),A=r(5649),O=r(3118),S=r(408),T=r(5185),P=r(5605),R=r(3682),x=r(1254);class I extends P.Provider{constructor(t,e){super(t),this.estimator=e,this.contractProviderTypeSymbol=Symbol.for("taquito-contract-provider-type-symbol"),this.prepare=new R.PrepareProvider(this.context)}async getStorage(t,e,r="head"){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const s="head"===r?await(0,x.retryOnNotFound)(()=>this.context.readProvider.getScript(t,"head")):await this.context.readProvider.getScript(t,r);let c;return e||(e=s),c=i.Schema.isSchema(e)?e:i.Schema.fromRPCResponse({script:e}),c.Execute(s.storage,(0,m.smartContractAbstractionSemantic)(this,r))}async getBigMapKeyByID(t,e,r,n){const{key:i,type:s}=r.EncodeBigMapKey(e),{packed:a}=await this.context.packer.packData({data:i,type:s}),c=(0,o.encodeExpr)(a),u=n??"head",l=await this.context.readProvider.getBigMapValue({id:t.toString(),expr:c},u);return r.ExecuteOnBigMapValue(l,(0,m.smartContractAbstractionSemantic)(this,u))}async getBigMapKeysByID(t,e,r,n,s=5){const o=await this.getBlockForRequest(e,n),a=new i.MichelsonMap;let c=0,u=[];for(;c<e.length;){const n=e.slice(c,c+s).map(e=>this.getBigMapValueOrUndefined(e,t,r,o));u=[...u,...await Promise.all(n)],c+=s}for(let t=0;t<u.length;t++)a.set(e[t],u[t]);return a}async getBlockForRequest(t,e){return 1===t.length||void 0!==e?e:await this.context.readProvider.getBlockLevel("head")}async getBigMapValueOrUndefined(t,e,r,i){try{return await this.getBigMapKeyByID(e,t,r,i)}catch(t){if(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND)return;throw t}}async getSaplingDiffByID(t,e="head"){return this.context.readProvider.getSaplingDiffById({id:t.toString()},e)}async originate(t){const e=await this.estimate(t,this.estimator.originate.bind(this.estimator)),r=await this.prepare.originate({...t,...e}),n=r.opOb.contents.find(t=>t.kind===s.OpKind.ORIGINATION),i=await this.forge(r),{hash:o,context:a,forgedBytes:c,opResponse:u}=await this.signAndInject(i);return new l.OriginationOperation(o,n,c,u,a,this)}async setDelegate(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);const r=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.delegate,r);if(/^kt1/i.test(t.source??""))throw new g.InvalidDelegationSource(t.source??"");const n=await this.signer.publicKeyHash(),i=t.source||n,c=await this.estimate(t,this.estimator.setDelegate.bind(this.estimator)),l=await this.prepare.delegation({...t,...c}),h=l.opOb.contents.find(t=>t.kind===s.OpKind.DELEGATION),f=await this.forge(l),{hash:d,context:p,forgedBytes:m,opResponse:y}=await this.signAndInject(f);return new u.DelegateOperation(d,h,i,m,y,p)}async registerDelegate(t){const e=await this.estimate(t,this.estimator.registerDelegate.bind(this.estimator)),r=await this.signer.publicKeyHash(),n=await this.prepare.registerDelegate({...t,...e}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.DELEGATION),o=await this.forge(n),{hash:a,context:c,forgedBytes:l,opResponse:h}=await this.signAndInject(o);return new u.DelegateOperation(a,i,r,l,h,c)}async transfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.to,e);const r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const n=await this.signer.publicKeyHash(),i=await this.estimate(t,this.estimator.transfer.bind(this.estimator)),c=t.source||n,u=await this.prepare.transaction({...t,...i}),l=u.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),h=await this.forge(u),{hash:f,context:p,forgedBytes:g,opResponse:m}=await this.signAndInject(h);return new d.TransactionOperation(f,l,c,g,m,p)}async stake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.to&&t.to!==t.source)throw new a.InvalidStakingAddressError(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.stake.bind(this.estimator)),i=t.source||r,c=await this.prepare.stake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async unstake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.to&&t.to!==t.source)throw new a.InvalidStakingAddressError(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.unstake.bind(this.estimator)),i=t.source||r,c=await this.prepare.unstake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async finalizeUnstake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.amount||(t.amount=0),void 0!==t.amount&&t.amount>0)throw new a.InvalidFinalizeUnstakeAmountError("Amount must be 0 to finalize unstake.");const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.finalizeUnstake.bind(this.estimator)),i=t.source||r,c=await this.prepare.finalizeUnstake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async transferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.destination,e);const r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=await this.signer.publicKeyHash(),i=t.source??n,c=await this.estimate(t,this.estimator.transferTicket.bind(this.estimator)),u=await this.prepare.transferTicket({...t,...c}),l=u.opOb.contents.find(t=>t.kind===s.OpKind.TRANSFER_TICKET),h=await this.forge(u),{hash:f,context:d,forgedBytes:p,opResponse:g}=await this.signAndInject(h);return new y.TransferTicketOperation(f,l,i,p,g,d)}async reveal(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(e,o.publicKeyHashPrefixes);if(r===o.PrefixV2.BLS12_381PublicKeyHash)if(t.proof)(0,o.b58DecodeAndCheckPrefix)(t.proof,[o.PrefixV2.BLS12_381Signature]);else{const{prefixSig:e}=await this.signer.provePossession();t.proof=e}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const n=await this.estimator.reveal(t);if(n){const r=await this.estimate(t,async()=>n),i=await this.prepare.reveal({...t,...r}),o=i.opOb.contents.find(t=>t.kind===s.OpKind.REVEAL),a=await this.forge(i),{hash:c,context:u,forgedBytes:l,opResponse:h}=await this.signAndInject(a);return new f.RevealOperation(c,o,e,l,h,u)}throw new g.RevealOperationError(`The publicKeyHash '${e}' has already been revealed.`)}async registerGlobalConstant(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.registerGlobalConstant.bind(this.estimator)),n=await this.prepare.registerGlobalConstant({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.REGISTER_GLOBAL_CONSTANT),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new h.RegisterGlobalConstantOperation(a,i,e,u,l,c)}async increasePaidStorage(t){if(t.amount<=0)throw new a.InvalidAmountError(t.amount.toString());const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.increasePaidStorage.bind(this.estimator)),n=await this.prepare.increasePaidStorage({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.INCREASE_PAID_STORAGE),o=await this.forge(n),{hash:c,context:u,forgedBytes:l,opResponse:h}=await this.signAndInject(o);return new b.IncreasePaidStorageOperation(c,i,e,l,h,u)}async drainDelegate(t){const e=await this.prepare.drainDelegate(t),r=e.opOb.contents.find(t=>t.kind===s.OpKind.DRAIN_DELEGATE),n=await this.forge(e),{hash:i,context:o,forgedBytes:a,opResponse:c}=await this.signAndInject(n);return new w.DrainDelegateOperation(i,r,a,c,o)}async ballot(t){const e=await this.signer.publicKeyHash(),r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=t.source??e,i=await this.prepare.ballot({...t,source:n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.BALLOT),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new v.BallotOperation(l,c,e,f,d,h)}async proposals(t){const e=await this.signer.publicKeyHash(),r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=t.source??e,i=await this.prepare.proposals({...t,source:n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.PROPOSALS),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new E.ProposalsOperation(l,c,e,f,d,h)}async updateConsensusKey(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(r===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const n=await this.estimate(t,this.estimator.updateConsensusKey.bind(this.estimator)),i=await this.prepare.updateConsensusKey({...t,...n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.UPDATE_CONSENSUS_KEY),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new _.UpdateConsensusKeyOperation(l,c,e,f,d,h)}async updateCompanionKey(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(r!==o.PrefixV2.BLS12_381PublicKey)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as companion key");if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as companion key ");const n=await this.estimate(t,this.estimator.updateCompanionKey.bind(this.estimator)),i=await this.prepare.updateCompanionKey({...t,...n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.UPDATE_COMPANION_KEY),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new A.UpdateCompanionKeyOperation(l,c,e,f,d,h)}async smartRollupAddMessages(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupAddMessages.bind(this.estimator)),n=await this.prepare.smartRollupAddMessages({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_ADD_MESSAGES),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new O.SmartRollupAddMessagesOperation(a,i,e,u,l,c)}async smartRollupOriginate(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupOriginate.bind(this.estimator)),n=await this.prepare.smartRollupOriginate({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_ORIGINATE),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new S.SmartRollupOriginateOperation(a,i,e,u,l,c)}async smartRollupExecuteOutboxMessage(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupExecuteOutboxMessage.bind(this.estimator)),n=await this.prepare.smartRollupExecuteOutboxMessage({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new T.SmartRollupExecuteOutboxMessageOperation(a,i,e,u,l,c)}async failingNoop(t){const e={kind:s.OpKind.FAILING_NOOP,arbitrary:t.arbitrary},r=await this.context.readProvider.getBlockHash(t.basedOnBlock),n=await this.context.forger.forge({branch:r,contents:[e]}),{prefixSig:i}=await this.signer.sign(n,new Uint8Array([3]));return{signature:i,bytes:n,signedContent:{branch:r,contents:[{kind:s.OpKind.FAILING_NOOP,arbitrary:t.arbitrary}]}}}async at(t,e=t=>t,r="head"){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const i=this.context.withExtensions().rpc,s=this.context.withExtensions().readProvider,c=async e=>({script:await s.getScript(t,e),entrypoints:"head"===e?await s.getEntrypoints(t):await i.getEntrypoints(t,{block:String(e)})});let u;try{u=await c(r)}catch(t){if("head"===r||!(0,x.isNotFoundError)(t))throw t;u=await(0,x.retryOnNotFound)(()=>c("head"))}return e(new p.ContractAbstraction(t,u.script,this,this,u.entrypoints,i,s,"head"),this.context)}async atExactBlock(t,e=t=>t,r){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const i=this.context.withExtensions().rpc,s=this.context.withExtensions().readProvider,c=await s.getScript(t,r),u=await i.getEntrypoints(t,{block:String(r)});return e(new p.ContractAbstraction(t,c,this,this,u,i,s,r),this.context)}batch(t){const e=new c.OperationBatch(this.context,this.estimator);return Array.isArray(t)&&e.with(t),e}}e.RpcContractProvider=I},3e3(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SaplingStateAbstraction=void 0;r(7873).default;e.SaplingStateAbstraction=class{constructor(t,e,r){this.id=t,this.provider=e,this.defaultBlock=r}async getSaplingDiff(t){return this.provider.getSaplingDiffByID(this.id.toString(),t??this.defaultBlock)}getId(){return this.id.toString()}}},9281(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.smartContractAbstractionSemantic=void 0;const n=r(5602),i=r(9676),s=r(7873),o=r(3e3);e.smartContractAbstractionSemantic=(t,e)=>({big_map:(r,o)=>{if(r&&"int"in r&&void 0!==r.int){const a=new n.Schema(o);return new i.BigMapAbstraction(new s.default(r.int),a,t,e)}return{}},sapling_state:r=>r&&"int"in r&&void 0!==r.int?new o.SaplingStateAbstraction(new s.default(r.int),t,e):{}})},6200(t,e){"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"}},4359(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCResponseError=e.ConfirmationTimeoutError=e.InvalidConfirmationCountError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t){super(),this.invalidConfirmations=t,this.name="InvalidConfirmationCountError",this.message=`Invalid confirmation count ${t} expecting at least 1`}}e.InvalidConfirmationCountError=i;class s extends n.NetworkError{constructor(t){super(),this.message=t,this.name="ConfirmationTimeoutError"}}e.ConfirmationTimeoutError=s;class o extends n.RpcError{constructor(t,e){super(),this.message=t,this.cause=e,this.name="RPCResponseError"}}e.RPCResponseError=o},8710(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RevealEstimateError=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(){super(),this.name="RevealEstimateError",this.message="Public key is unknown, unable to estimate the reveal operation in Wallet API."}}e.RevealEstimateError=i},1263(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3771(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Estimate=e.feeParamsFromMempoolFilter=e.DEFAULT_FEE_PARAMS=void 0,e.DEFAULT_FEE_PARAMS={minimalFeeMutez:100,feePerGasMutez:.1,feePerByteMutez:1};const r=t=>{if(!Array.isArray(t)||t.length<2)return;const e=Number(t[0]),r=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(r)&&0!==r?e/r:void 0};e.feeParamsFromMempoolFilter=t=>{const n=Number(t?.minimal_fees),i=r(t?.minimal_nanotez_per_gas_unit),s=r(t?.minimal_nanotez_per_byte);return{minimalFeeMutez:Number.isFinite(n)?n:e.DEFAULT_FEE_PARAMS.minimalFeeMutez,feePerGasMutez:"number"==typeof i?i/1e3:e.DEFAULT_FEE_PARAMS.feePerGasMutez,feePerByteMutez:"number"==typeof s?s/1e3:e.DEFAULT_FEE_PARAMS.feePerByteMutez}};class n{constructor(t,r,n,i,s=e.DEFAULT_FEE_PARAMS.minimalFeeMutez,o=e.DEFAULT_FEE_PARAMS){this._milligasLimit=t,this._storageLimit=r,this.opSize=n,this.minimalFeePerStorageByteMutez=i,this.baseFeeMutez=s,this.feeParams=o}get burnFeeMutez(){return this.roundUp(Number(this.storageLimit)*Number(this.minimalFeePerStorageByteMutez))}get storageLimit(){return Math.max(Number(this._storageLimit),0)}get gasLimit(){return this.roundUp(Number(this._milligasLimit)/1e3)}get operationFeeMutez(){return this.gasLimit*this.feeParams.feePerGasMutez+Number(this.opSize)*this.feeParams.feePerByteMutez}roundUp(t){return Math.ceil(Number(t))}get minimalFeeMutez(){return this.roundUp(this.operationFeeMutez+this.feeParams.minimalFeeMutez)}get suggestedFeeMutez(){return this.roundUp(this.operationFeeMutez+1.2*this.feeParams.minimalFeeMutez)}get usingBaseFeeMutez(){return Math.max(Number(this.baseFeeMutez),this.feeParams.minimalFeeMutez)+this.roundUp(this.operationFeeMutez)}get totalCost(){return this.minimalFeeMutez+this.burnFeeMutez}get consumedMilligas(){return Number(this._milligasLimit)}static createEstimateInstanceFromProperties(t){let e,r=0,i=0,s=0,o=0;const a=t[0]?.feeParams;return t.forEach(t=>{r+=t.milligasLimit,i+=t.storageLimit,s+=t.opSize,o=Math.max(t.minimalFeePerStorageByteMutez,o),t.baseFeeMutez&&(e=e?e+t.baseFeeMutez:t.baseFeeMutez)}),new n(r,i,s,o,e,a)}static createArrayEstimateInstancesFromProperties(t){return t.map(t=>new n(t.milligasLimit,t.storageLimit,t.opSize,t.minimalFeePerStorageByteMutez,t.baseFeeMutez,t.feeParams))}}e.Estimate=n},5681(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(3771),e),i(r(1263),e),i(r(4019),e),i(r(8710),e)},4019(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCEstimateProvider=void 0;r(7873).default;const n=r(286),i=r(6568),s=r(3771),o=r(2403),a=r(8710),c=r(5605),u=r(7583),l=r(6571);class h extends c.Provider{constructor(){super(...arguments),this.REVEAL_LENGTH=324,this.REVEAL_LENGTH_TZ4=622,this.MILLIGAS_BUFFER=1e5,this.STORAGE_BUFFER=20,this.prepare=new u.PrepareProvider(this.context)}async getKeys(){const t=this.context.isAnySignerConfigured();return{publicKeyHash:t?await this.signer.publicKeyHash():await this.context.wallet.pkh(),publicKey:t?await this.signer.publicKey():await this.context.wallet.pk()}}getEstimationPropertiesFromOperationContent(t,e,r,s){const o=(0,n.flattenOperationResult)({contents:[t]});let a=0,c=0;return o.forEach(t=>{a+=Number(t.consumed_milligas)||0,c+="allocated_destination_contract"in t?s:0,c+="originated_contracts"in t&&Array.isArray(t.originated_contracts)?t.originated_contracts.length*s:0,c+="storage_size"in t&&"global_address"in t&&Number(t.storage_size)||0,c+="paid_storage_size_diff"in t&&Number(t.paid_storage_size_diff)||0,c+="genesis_commitment_hash"in t&&Number(t.size)||0}),(0,i.isOpWithFee)(t)?{milligasLimit:(0,i.isOpWithGasBuffer)(t)?a+Number(this.MILLIGAS_BUFFER):a,storageLimit:c>0?c+this.STORAGE_BUFFER:0,opSize:e,minimalFeePerStorageByteMutez:r.toNumber()}:{milligasLimit:0,storageLimit:0,opSize:e,minimalFeePerStorageByteMutez:r.toNumber(),baseFeeMutez:0}}async calculateEstimates(t,e){let r=s.DEFAULT_FEE_PARAMS;try{r=(0,s.feeParamsFromMempoolFilter)(await this.rpc.getMempoolFilter({include_default:!0}))}catch{}const{opbytes:i,opOb:{branch:a,contents:c}}=await this.forge(t),u={operation:{branch:a,contents:c,signature:"edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg"},chain_id:await this.context.readProvider.getChainId()},{opResponse:l}=await this.simulate(u,t),{cost_per_byte:h,origination_size:f}=e,d=[...(0,n.flattenErrors)(l,"backtracked"),...(0,n.flattenErrors)(l)];if(d.length)throw new n.TezosOperationError(d,"Error occurred during estimation",l.contents);let p=1;return Array.isArray(t.opOb.contents)&&t.opOb.contents.length>1&&(p="reveal"===l.contents[0].kind?t.opOb.contents.length-1:t.opOb.contents.length),l.contents.map(t=>{const e=t;let n,s;return e.source=e.source||"",e.source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?(n=this.REVEAL_LENGTH_TZ4/2,s=(i.length/2+o.payloadLength[o.PrefixV2.BLS12_381Signature])/p):(n=this.REVEAL_LENGTH/2,s=(i.length/2+o.payloadLength[o.PrefixV2.Ed25519Signature])/p),{...this.getEstimationPropertiesFromOperationContent(t,"reveal"===t.kind?n:s,h,f??257),feeParams:r}})}async originate(t){const e=await this.prepare.originate(t),r=await this.context.readProvider.getProtocolConstants("head"),n=await this.calculateEstimates(e,r);if("reveal"===e.opOb.contents[0].kind){const t=e.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n.shift(),n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async transfer({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.to);if(i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.to,i);const a=(0,o.validateAddress)(n.source??"");if(n.source&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,a);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const c=await this.prepare.transaction({fee:t,storageLimit:e,gasLimit:r,...n}),u=await this.context.readProvider.getProtocolConstants("head"),h=await this.calculateEstimates(c,u);if("reveal"===c.opOb.contents[0].kind){const t=c.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h.shift(),h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async stake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.to&&n.to!==n.source)throw new l.InvalidStakingAddressError(n.to);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const a=await this.prepare.stake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async unstake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.to&&n.to!==n.source)throw new l.InvalidStakingAddressError(n.to);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const a=await this.prepare.unstake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.amount||(n.amount=0),void 0!==n.amount&&0!==n.amount)throw new Error("Amount must be 0 for finalize_unstake operation");const a=await this.prepare.finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async transferTicket({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.destination);if(i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.destination,i);const a=(0,o.validateAddress)(n.source??"");if(n.source&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,a);const c=await this.context.readProvider.getProtocolConstants("head"),u=await this.prepare.transferTicket({fee:t,storageLimit:e,gasLimit:r,...n}),h=await this.calculateEstimates(u,c);if("reveal"===u.opOb.contents[0].kind){h.shift();const t=u.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async setDelegate({fee:t,gasLimit:e,storageLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);const a=(0,o.validateAddress)(n.delegate??"");if(n.delegate&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.delegate,a);const c=await this.prepare.delegation({fee:t,storageLimit:r,gasLimit:e,...n}),u=await this.context.readProvider.getProtocolConstants("head"),h=await this.calculateEstimates(c,u);if("reveal"===c.opOb.contents[0].kind){h.shift();const t=c.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async batch(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.batch(t),n=await this.calculateEstimates(r,e);return s.Estimate.createArrayEstimateInstancesFromProperties(n)}async registerDelegate({fee:t,storageLimit:e,gasLimit:r,...n},i){const a=(await this.getKeys()).publicKeyHash,c=await this.context.readProvider.getProtocolConstants("head"),u=i||a,l=await this.prepare.registerDelegate({fee:t,storageLimit:e,gasLimit:r,...n},u),h=await this.calculateEstimates(l,c);if("reveal"===l.opOb.contents[0].kind){h.shift();const t=l.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async reveal(t){const{publicKeyHash:e,publicKey:r}=await this.getKeys();if(!r)throw new a.RevealEstimateError;if(await this.isAccountRevealRequired(e)){const[,r]=(0,o.b58DecodeAndCheckPrefix)(e,o.publicKeyHashPrefixes);if(r===o.PrefixV2.BLS12_381PublicKeyHash)if(t&&t.proof)(0,o.b58DecodeAndCheckPrefix)(t.proof,[o.PrefixV2.BLS12_381Signature]);else{const{prefixSig:e}=await this.signer.provePossession();t={...t,proof:e}}else if(t&&t.proof)throw new l.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const n=await this.context.readProvider.getProtocolConstants("head"),i=t?await this.prepare.reveal(t):await this.prepare.reveal({}),a=await this.calculateEstimates(i,n);return s.Estimate.createEstimateInstanceFromProperties(a)}}async registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...n}){const i=await this.prepare.registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...n}),a=await this.context.readProvider.getProtocolConstants("head"),c=await this.calculateEstimates(i,a);if("reveal"===i.opOb.contents[0].kind){c.shift();const t=i.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;c[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(c)}async increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...n}){if(n.amount<=0)throw new l.InvalidAmountError(n.amount.toString());const i=await this.context.readProvider.getProtocolConstants("head"),a=await this.prepare.increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.calculateEstimates(a,i);if("reveal"===a.opOb.contents[0].kind){c.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;c[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(c)}async updateConsensusKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new l.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new l.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const r=await this.context.readProvider.getProtocolConstants("head"),n=await this.prepare.updateConsensusKey(t),i=await this.calculateEstimates(n,r);if("reveal"===n.opOb.contents[0].kind){i.shift();const t=n.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;i[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(i)}async updateCompanionKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e!==o.PrefixV2.BLS12_381PublicKey)throw new l.ProhibitedActionError("companion key must be a bls account");if(!t.proof)throw new l.InvalidProofError("Proof is required to set a bls account as companion key ");const r=await this.context.readProvider.getProtocolConstants("head"),n=await this.prepare.updateCompanionKey(t),i=await this.calculateEstimates(n,r);if("reveal"===n.opOb.contents[0].kind){i.shift();const t=n.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;i[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(i)}async smartRollupAddMessages(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupAddMessages(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async smartRollupOriginate(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupOriginate(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async smartRollupExecuteOutboxMessage(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupExecuteOutboxMessage(t),n=await this.calculateEstimates(r,e);return"reveal"===r.opOb.contents[0].kind&&n.shift(),s.Estimate.createEstimateInstanceFromProperties(n)}async contractCall(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.contractCall(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}}e.RPCEstimateProvider=h},3215(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CompositeForger=void 0;const n=r(8681);e.CompositeForger=class{constructor(t){if(this.forgers=t,0===t.length)throw new n.UnspecifiedForgerError}async forge({branch:t,contents:e}){const r=await Promise.all(this.forgers.map(r=>r.forge({branch:t,contents:e})));if(0===r.length)throw new n.UnspecifiedForgerError;let i=r.pop();for(;r.length;){const t=r.pop();if(t!==i)throw new n.ForgingMismatchError([i,t]);i=t}return i}}},8681(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnspecifiedForgerError=e.ForgingMismatchError=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(t){super(),this.results=t,this.name="ForgingMismatchError",this.message="Forging mismatch error"}}e.ForgingMismatchError=i;class s extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnspecifiedForgerError",this.message="No forger has been configured. Please configure new CompositeForger([rpcForger, localForger]) with your TezosToolkit instance."}}e.UnspecifiedForgerError=s},9719(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcForger=void 0;e.RpcForger=class{constructor(t){this.context=t}forge({branch:t,contents:e}){return this.context.rpc.forgeOperations({branch:t,contents:e})}}},8724(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TaquitoLocalForger=void 0;const n=r(8175);e.TaquitoLocalForger=class{constructor(t){this.context=t}async getNextProto(){if(!this.context.proto){const t=await this.context.readProvider.getNextProtocol("head");this.context.proto=t}return this.context.proto}async forge({branch:t,contents:e}){return new n.LocalForger(await this.getNextProto()).forge({branch:t,contents:e})}}},152(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultGlobalConstantsProvider=void 0;const n=r(1566);e.DefaultGlobalConstantsProvider=class{constructor(){this._globalConstantsLibrary={}}loadGlobalConstant(t){for(const e in t)Object.assign(this._globalConstantsLibrary,{[e]:t[e]})}async getGlobalConstantByHash(t){const e=this._globalConstantsLibrary[t];if(!e)throw new n.GlobalConstantNotFound(t);return e}}},1566(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnconfiguredGlobalConstantsProviderError=e.GlobalConstantNotFound=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(t){super(),this.hash=t,this.name="GlobalConstantNotFound",this.message=`Please load the value associated with the constant ${t} using the loadGlobalConstant method of the DefaultGlobalConstantsProvider.`}}e.GlobalConstantNotFound=i;class s extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnconfiguredGlobalConstantsProviderError",this.message="No global constants provider has been configured. Please configure one by calling setGlobalConstantsProvider({globalConstantsProvider}) on your TezosToolkit instance."}}e.UnconfiguredGlobalConstantsProviderError=s},7157(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},8320(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopGlobalConstantsProvider=void 0;const n=r(1566);e.NoopGlobalConstantsProvider=class{async getGlobalConstantByHash(t){throw new n.UnconfiguredGlobalConstantsProviderError}}},8763(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.importKey=async function(t,e,r,i,s){if(e&&r&&i&&s){const o=n.InMemorySigner.fromFundraiser(e,r,i);t.setProvider({signer:o});const a=await o.publicKeyHash();let c;try{c=await t.tz.activate(a,s)}catch(t){if(!(t&&t.body&&/Invalid activation/.test(t.body)))throw t}c&&await c.confirmation()}else{const i=await n.InMemorySigner.fromSecretKey(e,r);t.setProvider({signer:i})}};const n=r(8691)},5299(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorMessage=function(t,e){const r=JSON.parse(t.body);if(r[0]&&r[0].kind&&r[0].msg){const i=JSON.stringify({kind:r[0].kind,id:r[0].id,msg:r[0].msg.replace(e,"")});return new n.HttpResponseError(`Http error response: (${t.status}) ${i}`,t.status,t.statusText,i,t.url)}return t};const n=r(2211)},9164(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2245(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcInjector=void 0;const n=r(5299),i=r(2211);e.RpcInjector=class{constructor(t){this.context=t}async inject(t){let e;try{e=await this.context.rpc.injectOperation(t)}catch(t){const e=". You may want to use --replace to provide adequate fee and replace it";throw t instanceof i.HttpResponseError&&t.message.includes(e)?(0,n.formatErrorMessage)(t,e):t}return e}}},659(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BallotOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"ballot"===t.kind);return t||void 0}get period(){return this.operationResults?.period}get proposal(){return this.params.proposal}get ballot(){return this.params.ballot}}e.BallotOperation=i},7669(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchOperation=void 0;const n=r(7873).default,i=r(268),s=r(286),o=r(1859),a=r(6568);class c extends o.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}getOriginatedContractAddresses(){const t=this.results.filter(t=>"origination"===t.kind);let e=[];for(const r of t)r.metadata.operation_result.originated_contracts&&(e=[...e,...r.metadata.operation_result.originated_contracts]);return e}get status(){return this.results.filter(t=>-1!==i.BATCH_KINDS.indexOf(t.kind)).map(t=>{if((0,a.hasMetadataWithResult)(t)){return t.metadata.operation_result.status}return"unknown"})[0]||"unknown"}get fee(){return this.sumProp(this.params,"fee")}get gasLimit(){return this.sumProp(this.params,"gas_limit")}get storageLimit(){return this.sumProp(this.params,"storage_limit")}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),new n(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.results}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.results}),"paid_storage_size_diff"))}get errors(){return(0,s.flattenErrors)({contents:this.results})}}e.BatchOperation=c},4410(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DelegateOperation=void 0;const n=r(7873).default,i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"delegation"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get delegate(){return this.params.delegate}get isRegisterOperation(){return this.delegate===this.source}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.DelegateOperation=s},8835(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DrainDelegateOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i){super(t,r,n,i),this.params=e}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"drain_delegate"===t.kind),e=t&&t.metadata&&t.metadata.balance_updates;return e||void 0}get consensusKey(){return this.params.consensus_key}get delegate(){return this.params.delegate}get destination(){return this.params.destination}}e.DrainDelegateOperation=i},286(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidEstimateValueError=e.OriginationOperationError=e.flattenErrors=e.flattenOperationResult=e.TezosPreapplyFailureError=e.TezosOperationError=void 0;const n=r(6571),i=r(6568);class s extends n.RpcError{constructor(t,e,r){super(),this.errors=t,this.errorDetails=e,this.operationsWithResults=r,this.name="TezosOperationError",this.lastError=t[t.length-1],this.message=`(${this.kind}) ${this.id}`,"with"in this.lastError&&(this.lastError.with.string?this.message=this.lastError.with.string:this.lastError.with.int?this.message=this.lastError.with.int:this.message=JSON.stringify(this.lastError.with))}get id(){return this.lastError.id}get kind(){return this.lastError.kind}}e.TezosOperationError=s;class o extends Error{constructor(t){super(),this.result=t,this.name="TezosPreapplyFailureError",this.message="Preapply returned an unexpected result"}}e.TezosPreapplyFailureError=o;e.flattenOperationResult=t=>{const e=Array.isArray(t)?t:[t],r=[];for(let t=0;t<e.length;t++)for(let n=0;n<e[t].contents.length;n++){const s=e[t].contents[n];(0,i.hasMetadataWithResult)(s)&&"fee"in s&&(r.push({fee:s.fee,...s.metadata.operation_result}),Array.isArray(s.metadata.internal_operation_results)&&s.metadata.internal_operation_results.forEach(t=>r.push(t.result)))}return r};e.flattenErrors=(t,e="failed")=>{const r=Array.isArray(t)?t:[t];let n=[];for(let t=0;t<r.length;t++)for(let s=0;s<r[t].contents.length;s++){const o=r[t].contents[s];if((0,i.hasMetadata)(o)&&((0,i.hasMetadataWithResult)(o)&&o.metadata.operation_result.status===e&&(n=n.concat(o.metadata.operation_result.errors||[])),(0,i.hasMetadataWithInternalOperationResult)(o)&&Array.isArray(o.metadata.internal_operation_results)))for(const t of o.metadata.internal_operation_results)"result"in t&&t.result.status===e&&(n=n.concat(t.result.errors||[]))}return n};class a extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="OriginationOperationError"}}e.OriginationOperationError=a;class c extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidEstimateValueError"}}e.InvalidEstimateValueError=c},1660(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IncreasePaidStorageOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"increase_paid_storage"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get errors(){return this.operationResults?.errors}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get amount(){return this.params.amount}get destination(){return this.params.destination}}e.IncreasePaidStorageOperation=i},105(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.Operation=e.RevealOperation=e.ProposalsOperation=e.DrainDelegateOperation=e.BallotOperation=e.SmartRollupOriginateOperation=e.SmartRollupAddMessagesOperation=e.UpdateCompanionKeyOperation=e.UpdateConsensusKeyOperation=e.TransferTicketOperation=e.IncreasePaidStorageOperation=e.RegisterGlobalConstantOperation=e.TransactionOperation=e.DelegateOperation=e.OriginationOperation=e.BatchOperation=e.InvalidEstimateValueError=e.TezosPreapplyFailureError=e.TezosOperationError=void 0,i(r(6568),e);var s=r(286);Object.defineProperty(e,"TezosOperationError",{enumerable:!0,get:function(){return s.TezosOperationError}}),Object.defineProperty(e,"TezosPreapplyFailureError",{enumerable:!0,get:function(){return s.TezosPreapplyFailureError}}),Object.defineProperty(e,"InvalidEstimateValueError",{enumerable:!0,get:function(){return s.InvalidEstimateValueError}});var o=r(7669);Object.defineProperty(e,"BatchOperation",{enumerable:!0,get:function(){return o.BatchOperation}});var a=r(2526);Object.defineProperty(e,"OriginationOperation",{enumerable:!0,get:function(){return a.OriginationOperation}});var c=r(4410);Object.defineProperty(e,"DelegateOperation",{enumerable:!0,get:function(){return c.DelegateOperation}});var u=r(2741);Object.defineProperty(e,"TransactionOperation",{enumerable:!0,get:function(){return u.TransactionOperation}});var l=r(6759);Object.defineProperty(e,"RegisterGlobalConstantOperation",{enumerable:!0,get:function(){return l.RegisterGlobalConstantOperation}});var h=r(1660);Object.defineProperty(e,"IncreasePaidStorageOperation",{enumerable:!0,get:function(){return h.IncreasePaidStorageOperation}});var f=r(4371);Object.defineProperty(e,"TransferTicketOperation",{enumerable:!0,get:function(){return f.TransferTicketOperation}});var d=r(2552);Object.defineProperty(e,"UpdateConsensusKeyOperation",{enumerable:!0,get:function(){return d.UpdateConsensusKeyOperation}});var p=r(5649);Object.defineProperty(e,"UpdateCompanionKeyOperation",{enumerable:!0,get:function(){return p.UpdateCompanionKeyOperation}});var g=r(3118);Object.defineProperty(e,"SmartRollupAddMessagesOperation",{enumerable:!0,get:function(){return g.SmartRollupAddMessagesOperation}});var m=r(408);Object.defineProperty(e,"SmartRollupOriginateOperation",{enumerable:!0,get:function(){return m.SmartRollupOriginateOperation}});var y=r(659);Object.defineProperty(e,"BallotOperation",{enumerable:!0,get:function(){return y.BallotOperation}});var b=r(8835);Object.defineProperty(e,"DrainDelegateOperation",{enumerable:!0,get:function(){return b.DrainDelegateOperation}});var v=r(5574);Object.defineProperty(e,"ProposalsOperation",{enumerable:!0,get:function(){return v.ProposalsOperation}});var w=r(4368);Object.defineProperty(e,"RevealOperation",{enumerable:!0,get:function(){return w.RevealOperation}});var E=r(1859);Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return E.Operation}})},1859(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Operation=void 0;const n=r(1948),i=r(1018),s=r(6568),o=r(2403),a=r(9940),c=r(4359),u=r(6571),l="undefined"!=typeof process?process.env:void 0,h=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE??""),f=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE_VERBOSE??""),d=Number(l?.TAQUITO_OP_TRACE_SLOW_MS??"60000"),p=Number.isFinite(d)&&d>=0?d:6e4,g=t=>"object"==typeof t&&null!==t?t:void 0,m=t=>Array.isArray(t)?t:[],y=t=>t.map(t=>{const e=g(t)??{},r=g(e.metadata),n=g(r?.operation_result),i=r?.internal_operation_results,s=Array.isArray(i)?i.reduce((t,e)=>{const r=g(e),n=g(r?.result),i=n?.status;return"string"!=typeof i||"applied"===i||t.push({kind:"string"==typeof r?.kind?r.kind:"unknown",status:i,errors:m(n?.errors)}),t},[]):[];return{kind:"string"==typeof e.kind?e.kind:"unknown",status:"string"==typeof n?.status?n.status:"unknown",errors:m(n?.errors),consumed_milligas:"string"==typeof n?.consumed_milligas?n.consumed_milligas:void 0,internalFailures:s}}),b=t=>{h&&console.log(`[taquito:op-trace] ${JSON.stringify(t)}`)};e.Operation=class{get includedInBlock(){return this._foundAt}async getInclusionBlock(){const t=await this._includedInBlock.pipe((0,i.first)()).toPromise();if(!t)throw new Error("Inclusion block is undefined");return t}constructor(t,e,r,s){if(this.hash=t,this.raw=e,this.results=r,this.context=s,this._pollingConfig$=new n.ReplaySubject(1),this._includedInBlock=new n.ReplaySubject(1),this.currentHead$=this._pollingConfig$.pipe((0,i.switchMap)(t=>new n.BehaviorSubject(t).pipe((0,i.timeout)({each:1e3*t.timeout,with:()=>(0,n.throwError)(()=>new c.ConfirmationTimeoutError("Confirmation polling timed out"))}))),(0,i.switchMap)(()=>(0,n.defer)(()=>(0,a.createObservableFromSubscription)(this.context.stream.subscribeBlock("head"))).pipe((0,i.switchMap)(t=>{const e=this.lastHead?.header.level??t.header.level-1;return(0,n.range)(e+1,t.header.level-e-1).pipe((0,i.concatMap)(t=>this.context.readProvider.getBlock(t)),(0,i.endWith)(t))}),(0,i.tap)(t=>this.lastHead=t))),(0,i.shareReplay)({refCount:!0})),this.confirmed$=this.currentHead$.pipe((0,i.map)(t=>{for(let e=3;e>=0;e--)for(const r of t.operations[e])if(r.hash===this.hash)return this._foundAt=t.header.level,this._includedInBlock.next(t),this._foundAt;if(t.header.level-this._foundAt>=0)return this._foundAt}),(0,i.filter)(t=>void 0!==t),(0,i.first)(),(0,i.shareReplay)()),this._foundAt=Number.POSITIVE_INFINITY,(0,o.validateOperation)(this.hash)!==o.ValidationResult.VALID)throw new u.InvalidOperationHashError(this.hash);this.confirmed$.pipe((0,i.first)(),(0,i.catchError)(()=>(0,n.of)(n.EMPTY))).subscribe()}get revealOperation(){return Array.isArray(this.results)&&this.results.find(t=>"reveal"===t.kind)}get revealStatus(){return this.revealOperation?this.revealOperation.metadata.operation_result.status:"unknown"}get status(){return this.results.map(t=>(0,s.hasMetadataWithResult)(t)?t.metadata.operation_result.status:"unknown")[0]||"unknown"}async confirmation(t,e){if(void 0!==t&&t<1)throw new c.InvalidConfirmationCountError(t);const{defaultConfirmationCount:r,confirmationPollingTimeoutSecond:n}=this.context.config,s=e||n,o=Date.now();this._pollingConfig$.next({timeout:s});const a=void 0!==t?t:r;return new Promise((t,e)=>{this.confirmed$.pipe((0,i.switchMap)(()=>this.currentHead$),(0,i.filter)(t=>t.header.level-this._foundAt>=a-1),(0,i.first)()).subscribe({error:t=>{var r;b({stage:"confirmation-error",hash:this.hash,elapsedMs:Date.now()-o,expectedConfirmations:a,timeoutSec:s,includedInBlock:Number.isFinite(this._foundAt)?this._foundAt:null,status:this.status,error:(r=t,r instanceof Error?`${r.name}: ${r.message}`:String(r)),results:y(this.results)}),e(t)},complete:()=>{const e=Date.now()-o;(f||e>=p||"applied"!==this.status)&&b({stage:"confirmation-complete",hash:this.hash,elapsedMs:e,expectedConfirmations:a,timeoutSec:s,includedInBlock:Number.isFinite(this._foundAt)?this._foundAt:null,status:this.status,results:y(this.results)}),t(this._foundAt+(a-1))}})})}}},2526(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationOperation=void 0;const n=r(7873).default,i=r(3484),s=r(286),o=r(1859),a=r(6568);class c extends o.Operation{constructor(t,e,r,n,i,s){super(t,r,n,i),this.params=e,this.contractProvider=s;const o=this.operationResults&&this.operationResults.originated_contracts;Array.isArray(o)&&(this.contractAddress=o[0])}get status(){return this.operationResults?.status??"unknown"}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"origination"===t.kind),e=t&&(0,a.hasMetadataWithResult)(t)&&t.metadata.operation_result;return e||void 0}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get storageDiff(){const t=this.operationResults&&this.operationResults.paid_storage_size_diff;return t||void 0}get storageSize(){const t=this.operationResults&&this.operationResults.storage_size;return t||void 0}get errors(){return this.operationResults?.errors}async contract(t,e){if(!this.contractAddress)throw new s.OriginationOperationError("No contract was originated in this operation");if(await this.confirmation(t,e),!Number.isFinite(this.includedInBlock))throw new s.OriginationOperationError("Confirmation completed but includedInBlock was not set");const r=await this.getInclusionBlock();if(!(0,i.isBlockHashIdentifier)(r.hash))throw new s.OriginationOperationError("Confirmation completed but includedInBlock was not set");return this.contractProvider.at(this.contractAddress,void 0,r.hash)}}e.OriginationOperation=c},5574(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ProposalsOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"proposals"===t.kind);return t||void 0}get proposals(){return this.params.proposals}get period(){return this.operationResults?.period}}e.ProposalsOperation=i},6759(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegisterGlobalConstantOperation=void 0;const n=r(7873).default,i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r,this.globalConstantHash=this.operationResults&&this.operationResults.global_address}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"register_global_constant"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get registeredExpression(){return this.params.value}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get errors(){return this.operationResults?.errors}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}}e.RegisterGlobalConstantOperation=s},4368(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RevealOperation=void 0;const n=r(6571),i=r(7873).default,s=r(286),o=r(1859);class a extends o.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"reveal"===t.kind);return t?[t]:[]}get status(){const t=this.operationResults[0];return t?t.metadata.operation_result.status:"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get publicKey(){return this.params.public_key}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only BLS key has proof")}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}get consumedGas(){return i.config({DECIMAL_PLACES:0,ROUNDING_MODE:i.ROUND_UP}),new i(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"paid_storage_size_diff"))}get storageSize(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"storage_size"))}get errors(){return(0,s.flattenErrors)({contents:this.operationResults})}}e.RevealOperation=a},3118(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupAddMessagesOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"smart_rollup_add_messages"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get message(){return this.params.message}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.SmartRollupAddMessagesOperation=i},5185(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupExecuteOutboxMessageOperation=void 0;const n=r(3157),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get rollup(){return this.params.rollup}get cementedCommitment(){return this.params.cemented_commitment}get outputProof(){return this.params.output_proof}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.SmartRollupExecuteOutboxMessageOperation=s},408(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupOriginateOperation=void 0;const n=r(3157),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.SMART_ROLLUP_ORIGINATE),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get pvmKind(){return this.params.pvm_kind}get kernel(){return this.params.kernel}get errors(){return this.operationResults?.errors}}e.SmartRollupOriginateOperation=s},2741(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionOperation=void 0;const n=r(7873).default,i=r(286),s=r(1859);class o extends s.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"transaction"===t.kind);return t?[t]:[]}get status(){const t=this.operationResults[0];return t?t.metadata.operation_result.status:"unknown"}get amount(){return new n(this.params.amount)}get destination(){return this.params.destination}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),new n(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"paid_storage_size_diff"))}get storageSize(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"storage_size"))}get errors(){return(0,i.flattenErrors)({contents:this.operationResults})}}e.TransactionOperation=o},4371(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransferTicketOperation=void 0;const n=r(3157),i=r(7873).default,s=r(1859);class o extends s.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.TRANSFER_TICKET),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return i.config({DECIMAL_PLACES:0,ROUNDING_MODE:i.ROUND_UP}),this.consumedMilliGas?new i(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}}e.TransferTicketOperation=o},6568(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hasMetadataWithInternalOperationResult=e.hasMetadataWithResult=e.hasMetadata=e.isSourceOp=e.isOpRequireReveal=e.isOpWithFee=e.isOpWithGasBuffer=e.isKind=e.findWithKind=e.attachKind=e.OpKind=void 0;const n=r(3157);var i=r(3157);Object.defineProperty(e,"OpKind",{enumerable:!0,get:function(){return i.OpKind}});e.attachKind=(t,e)=>({...t,kind:e});e.findWithKind=(t,r)=>{if(Array.isArray(t)){const n=t.find(t=>t.kind===r);if(n&&(0,e.isKind)(n,r))return n}};e.isKind=(t,e)=>t.kind===e;const s=[n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.ORIGINATION,n.OpKind.REVEAL,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET,n.OpKind.UPDATE_CONSENSUS_KEY,n.OpKind.UPDATE_COMPANION_KEY,n.OpKind.SMART_ROLLUP_ADD_MESSAGES,n.OpKind.SMART_ROLLUP_ORIGINATE,n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE];e.isOpWithGasBuffer=t=>!(t.kind!==n.OpKind.TRANSACTION||!t.destination?.startsWith("KT1"))||-1!==["origination","register_global_constant","transfer_ticket","update_consensus_key","update_companion_key","smart_rollup_add_messages","smart_rollup_originate"].indexOf(t.kind);e.isOpWithFee=t=>s.includes(t.kind);e.isOpRequireReveal=t=>-1!==["transaction","delegation","origination","register_global_constant","increase_paid_storage","transfer_ticket","update_consensus_key","update_companion_key","smart_rollup_add_messages","smart_rollup_originate","smart_rollup_execute_outbox_message"].indexOf(t.kind);e.isSourceOp=t=>-1!==["transaction","delegation","origination","reveal","ballot"].indexOf(t.kind);e.hasMetadata=t=>"metadata"in t;e.hasMetadataWithResult=t=>(0,e.hasMetadata)(t)&&"operation_result"in t.metadata;e.hasMetadataWithInternalOperationResult=t=>(0,e.hasMetadata)(t)&&"internal_operation_results"in t.metadata},5649(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateCompanionKeyOperation=void 0;const n=r(6571),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"update_companion_key"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get pk(){return this.params.pk}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only updating companion key to a BLS account has proof")}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.UpdateCompanionKeyOperation=s},2552(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateConsensusKeyOperation=void 0;const n=r(6571),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"update_consensus_key"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get pk(){return this.params.pk}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only updating consensus key to a BLS account has proof")}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.UpdateConsensusKeyOperation=s},458(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4377(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MichelCodecPacker=void 0;const n=r(5899);e.MichelCodecPacker=class{async packData(t){const{bytes:e}=(0,n.packDataBytes)(t.data,t.type);return{packed:e}}}},577(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcPacker=void 0;e.RpcPacker=class{constructor(t){this.context=t}async packData(t){return this.context.rpc.packData(t)}}},3971(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},8541(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MichelCodecParser=void 0;const n=r(5899),i=r(6645),s=r(5602);e.MichelCodecParser=class{constructor(t){this.context=t}async getNextProto(){if(!this.context.proto){const t=await this.context.readProvider.getNextProtocol("head");this.context.proto=t}return this.context.proto}async parseScript(t){return new n.Parser({protocol:await this.getNextProto()}).parseScript(t)}async parseMichelineExpression(t){return new n.Parser({protocol:await this.getNextProto()}).parseMichelineExpression(t)}async parseJSON(t){return new n.Parser({protocol:await this.getNextProto()}).parseJSON(t)}async prepareCodeOrigination(t){const e=t;if(e.code=await this.formatCodeParam(t.code),t.init)e.init=await this.formatInitParam(t.init);else if(t.storage){const r=e.code.find(t=>"prim"in t&&"storage"===t.prim);if(!r?.args)throw new i.InvalidCodeParameter("The storage section is missing from the script",t.code);const o=new s.Schema(r.args[0]),a=await this.findGlobalConstantsHashAndValue(o);if(0!==Object.keys(a).length){const i=new n.Parser({expandGlobalConstant:a}).parseJSON(r.args[0]),o=new s.Schema(i);e.init=o.Encode(t.storage)}else e.init=o.Encode(t.storage);delete e.storage}return e}async formatCodeParam(t){let e;if("string"==typeof t){const r=await this.parseScript(t);if(null===r)throw new i.InvalidCodeParameter("Unable to parse",t);e=r}else{const r=await this.parseJSON(t),n=["parameter","storage","code"];e=r.sort((t,e)=>n.indexOf(t.prim)-n.indexOf(e.prim))}return e}async formatInitParam(t){let e;if("string"==typeof t){const r=await this.parseMichelineExpression(t);if(null===r)throw new i.InvalidInitParameter("Invalid init parameter",t);e=r}else e=await this.parseJSON(t);return e}async findGlobalConstantsHashAndValue(t){const e=t.findToken("constant"),r={};if(0!==e.length)for(const t of e){const e=t.tokenVal.args;if(e){const t=e[0];if(t.string){const e=t.string,n=await this.context.globalConstantsProvider.getGlobalConstantByHash(e);Object.assign(r,{[e]:n})}}}return r}}},6424(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopParser=void 0;e.NoopParser=class{async prepareCodeOrigination(t){return t}}},3682(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(261),e),i(r(7583),e)},261(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},7583(t,e,r){"use strict";var n,i=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0}),e.PrepareProvider=void 0;const o=r(3157),a=r(6568),c=r(5283),u=r(4359),l=r(6571),h=r(2445),f=r(5605),d=r(7873).default,p=r(2403),g=(t,e)=>({fee:t.fee??e.fee,gasLimit:t.gasLimit??e.gasLimit,storageLimit:t.storageLimit??e.storageLimit});class m extends f.Provider{constructor(t){super(t),this.context=t,n.set(this,void 0),i(this,n,{},"f")}async getBlockHash(t){return this.context.readProvider.getBlockHash(t??"head~2")}async getProtocolHash(){return this.context.readProvider.getNextProtocol("head")}async getHeadCounter(t){return this.context.readProvider.getCounter(t,"head")??"0"}adjustGasForManagerOperations(t,e,r,n=new d(0)){if(r<=0)return e;const i=t.minus(n);return i.lte(0)?new d(0):d.min(e,i.div(r).integerValue(d.ROUND_DOWN))}getOperationLimits(t,e={}){const{hard_gas_limit_per_operation:r,hard_gas_limit_per_block:n,hard_storage_limit_per_operation:i}=t;return{fee:0,gasLimit:this.adjustGasForManagerOperations(n,r,e.opsNeedingGasLimitPatch??0,e.explicitGasLimitTotal).toNumber(),storageLimit:i.toNumber()}}async getOperationLimitsForManagerOperation(t,e,r,n){const i=await this.isRevealOpNeeded([{kind:r}],e);return this.getOperationLimits(t,{opsNeedingGasLimitPatch:void 0===n?1:0,explicitGasLimitTotal:i?new d((0,c.getRevealGasLimit)(e)):void 0})}getFee(t,e,r){(!s(this,n,"f")[e]||s(this,n,"f")[e]<r)&&(s(this,n,"f")[e]=r);return{counter:`${++s(this,n,"f")[e]}`,fee:void 0===t.fee?"0":`${t.fee}`,gas_limit:void 0===t.gas_limit?"0":`${t.gas_limit}`,storage_limit:void 0===t.storage_limit?"0":`${t.storage_limit}`}}getSource(t,e,r){return{source:void 0===t.source?r||e:t.source}}async addRevealOperationIfNeeded(t,e){if((0,a.isOpRequireReveal)(t)){const r=[t],{publicKey:n,pkh:i}=await this.getKeys();if(await this.isAccountRevealRequired(e)){if(!n)throw new l.PublicKeyNotFoundError(i);const[,t]=(0,p.b58DecodeAndCheckPrefix)(i,p.publicKeyHashPrefixes);return r.unshift(await(0,h.createRevealOperation)({fee:(0,c.getRevealFee)(i),storageLimit:c.REVEAL_STORAGE_LIMIT,gasLimit:(0,c.getRevealGasLimit)(i),proof:t===p.PrefixV2.BLS12_381PublicKeyHash?(await this.signer.provePossession()).prefixSig:void 0},e,n)),r}}return t}async getKeys(){const t=this.context.isAnySignerConfigured();return{pkh:t?await this.signer.publicKeyHash():await this.context.wallet.pkh(),publicKey:t?await this.signer.publicKey():await this.context.wallet.pk()}}convertIntoArray(t){return Array.isArray(t)?[...t]:[t]}getSingleManagerOperationSimulation(t,e){if(void 0===e&&0!==t.length)return{gasLimitPatchableIndexes:[t.length-1]}}withSimulationMetadata(t,e){return e?(Object.defineProperty(t,"simulation",{value:e,configurable:!0,enumerable:!1,writable:!0}),t):t}constructOpContents(t,e,r,n,i){return t.map(t=>{switch(t.kind){case o.OpKind.ACTIVATION:case o.OpKind.DRAIN_DELEGATE:return{...t};case o.OpKind.ORIGINATION:return{...t,balance:void 0!==t.balance?`${t.balance}`:"0",...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.TRANSACTION:{const i={...t,amount:void 0!==t.amount?`${t.amount}`:"0",...this.getSource(t,r,n),...this.getFee(t,r,e)};if(i.source.toLowerCase().startsWith("kt1"))throw new l.DeprecationError(`KT1 addresses are not supported as source since ${c.Protocols.PsBabyM1}`);return i}case o.OpKind.REVEAL:case o.OpKind.DELEGATION:case o.OpKind.REGISTER_GLOBAL_CONSTANT:case o.OpKind.UPDATE_CONSENSUS_KEY:case o.OpKind.UPDATE_COMPANION_KEY:case o.OpKind.SMART_ROLLUP_ADD_MESSAGES:case o.OpKind.SMART_ROLLUP_ORIGINATE:case o.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return{...t,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.TRANSFER_TICKET:return{...t,ticket_amount:`${t.ticket_amount}`,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.INCREASE_PAID_STORAGE:return{...t,amount:`${t.amount}`,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.BALLOT:case o.OpKind.PROPOSALS:if(void 0===i)throw new u.RPCResponseError("Failed to get the current voting period index");return{...t,period:i?.voting_period.index,...this.getSource(t,r,n)};default:throw new l.InvalidOperationKindError(t.kind)}})}async activate({pkh:t,secret:e}){const r=await(0,h.createActivationOperation)({pkh:t,secret:e}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(t),10);return{opOb:{branch:o,contents:this.constructOpContents(s,c,t),protocol:a},counter:c}}async reveal({fee:t,gasLimit:e,storageLimit:r,proof:s}){const{pkh:o,publicKey:a}=await this.getKeys();if(!a)throw new l.PublicKeyNotFoundError(o);const[,c]=(0,p.b58DecodeAndCheckPrefix)(o,p.publicKeyHashPrefixes);if(c===p.PrefixV2.BLS12_381PublicKeyHash)if(s)(0,p.b58DecodeAndCheckPrefix)(s,[p.PrefixV2.BLS12_381Signature]);else{const{prefixSig:t}=await this.signer.provePossession();s=t}else if(s)throw new l.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const u=await this.context.readProvider.getProtocolConstants("head"),f=await this.getOperationLimits(u),d=g({fee:t,storageLimit:r,gasLimit:e},f),m=await(0,h.createRevealOperation)({fee:d.fee,gasLimit:d.gasLimit,storageLimit:d.storageLimit,proof:s},o,a),y=this.convertIntoArray(m),b=await this.getBlockHash(),v=await this.getProtocolHash();i(this,n,{},"f");const w=parseInt(await this.getHeadCounter(o),10);return{opOb:{branch:b,contents:this.constructOpContents(y,w,o),protocol:v},counter:w}}async originate({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,c,o.OpKind.ORIGINATION,r),f=await(0,h.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...s,...g({fee:t,storageLimit:e,gasLimit:r},l)})),d=await this.addRevealOperationIfNeeded(f,c),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(c),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,c,a),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async transaction({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async stake({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,to:a,...g({fee:t,storageLimit:e,gasLimit:r},u),parameter:{entrypoint:"stake",value:{prim:"Unit"}}}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async unstake({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,to:a,...g({fee:t,storageLimit:e,gasLimit:r},u),parameter:{entrypoint:"unstake",value:{prim:"Unit"}}}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,to:s,...a}){const{pkh:c}=await this.getKeys(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,c,o.OpKind.TRANSACTION,r),f=await(0,h.createTransferOperation)({...a,to:s||c,amount:0,...g({fee:t,storageLimit:e,gasLimit:r},l),parameter:{entrypoint:"finalize_unstake",value:{prim:"Unit"}}}),d=await this.addRevealOperationIfNeeded(f,c),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(c),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,c,a.source),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async delegation({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.DELEGATION,r),l=await(0,h.createSetDelegateOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async registerDelegate({fee:t,storageLimit:e,gasLimit:r},s){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.DELEGATION,r),l=g({fee:t,storageLimit:e,gasLimit:r},u),f=await(0,h.createRegisterDelegateOperation)({fee:l.fee,storageLimit:l.storageLimit,gasLimit:l.gasLimit},a),d=await this.addRevealOperationIfNeeded(f,a),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(a),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,a,s),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.REGISTER_GLOBAL_CONSTANT,r),l=await(0,h.createRegisterGlobalConstantOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async updateConsensusKey({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),[,u]=(0,p.b58DecodeAndCheckPrefix)(s.pk,p.publicKeyPrefixes);if(u===p.PrefixV2.BLS12_381PublicKey){if(!s.proof)throw new l.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(s.proof)throw new l.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const f=await this.context.readProvider.getProtocolConstants("head"),d=await this.getOperationLimitsForManagerOperation(f,c,o.OpKind.UPDATE_CONSENSUS_KEY,r),m=await(0,h.createUpdateConsensusKeyOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},d)}),y=await this.addRevealOperationIfNeeded(m,c),b=this.convertIntoArray(y),v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(c),10),_={opOb:{branch:v,contents:this.constructOpContents(b,E,c,a),protocol:w},counter:E};return this.withSimulationMetadata(_,this.getSingleManagerOperationSimulation(b,r))}async updateCompanionKey({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),[,u]=(0,p.b58DecodeAndCheckPrefix)(s.pk,p.publicKeyPrefixes);if(u!==p.PrefixV2.BLS12_381PublicKey)throw new l.ProhibitedActionError("companion key must be a bls account");if(!s.proof)throw new l.InvalidProofError("Proof is required to set a bls account as companion key ");const f=await this.context.readProvider.getProtocolConstants("head"),d=await this.getOperationLimitsForManagerOperation(f,c,o.OpKind.UPDATE_COMPANION_KEY,r),m=await(0,h.createUpdateCompanionKeyOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},d)}),y=await this.addRevealOperationIfNeeded(m,c),b=this.convertIntoArray(y),v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(c),10),_={opOb:{branch:v,contents:this.constructOpContents(b,E,c,a),protocol:w},counter:E};return this.withSimulationMetadata(_,this.getSingleManagerOperationSimulation(b,r))}async increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.INCREASE_PAID_STORAGE,r),l=await(0,h.createIncreasePaidStorageOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async ballot(t){const{pkh:e}=await this.getKeys(),r=await(0,h.createBallotOperation)({...t}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(e),10);let l;try{l=await this.rpc.getCurrentPeriod()}catch(t){throw new u.RPCResponseError("Failed to get the current voting period index")}return{opOb:{branch:o,contents:this.constructOpContents(s,c,e,t.source,l),protocol:a},counter:c}}async proposals(t){const{pkh:e}=await this.getKeys(),r=await(0,h.createProposalsOperation)({...t}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(e),10);let l;try{l=await this.rpc.getCurrentPeriod()}catch(t){throw new u.RPCResponseError("Failed to get the current voting period index")}return{opOb:{branch:o,contents:this.constructOpContents(s,c,e,t.source,l),protocol:a},counter:c}}async drainDelegate(t,e){const{pkh:r}=await this.getKeys(),s=await(0,h.createDrainDelegateOperation)({...t}),o=this.convertIntoArray(s),a=await this.getBlockHash(),c=await this.getProtocolHash();i(this,n,{},"f");const u=parseInt(await this.getHeadCounter(r),10);return{opOb:{branch:a,contents:this.constructOpContents(o,u,r,e),protocol:c},counter:u}}async transferTicket({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSFER_TICKET,r),l=await(0,h.createTransferTicketOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupAddMessages({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_ADD_MESSAGES,r),l=await(0,h.createSmartRollupAddMessagesOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupOriginate({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_ORIGINATE,r),l=await(0,h.createSmartRollupOriginateOperation)({...g({fee:t,storageLimit:e,gasLimit:r},u),...s}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupExecuteOutboxMessage({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,r),l=await(0,h.createSmartRollupExecuteOutboxMessageOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async batch(t,e){const{pkh:r,publicKey:s}=await this.getKeys(),o=await this.context.readProvider.getProtocolConstants("head"),u=await this.isRevealOpNeeded(t,r),f=t.reduce((t,e)=>(0,a.isOpWithFee)(e)&&void 0!==e.gasLimit?t.plus(e.gasLimit):t,new d(u?(0,c.getRevealGasLimit)(r):0)),m=this.getOperationLimits(o,{opsNeedingGasLimitPatch:t.filter(t=>(0,a.isOpWithFee)(t)&&void 0===t.gasLimit).length,explicitGasLimitTotal:f}),y=[],b=[];if(e)for(const r of t)if((0,a.isOpWithFee)(r)){const t=e.shift(),n=g(r,{fee:t.suggestedFeeMutez,storageLimit:t.storageLimit,gasLimit:t.gasLimit});y.push(await this.getRPCOp({...r,...n})),b.push(!1)}else y.push({...r}),b.push(!1);else for(const e of t)if((0,a.isOpWithFee)(e)){const t=g(e,m);y.push(await this.getRPCOp({...e,...t})),b.push(void 0===e.gasLimit)}else y.push({...e}),b.push(!1);if(u){if(!s)throw new l.PublicKeyNotFoundError(r);const[,t]=(0,p.b58DecodeAndCheckPrefix)(r,p.publicKeyHashPrefixes);y.unshift(await(0,h.createRevealOperation)({fee:(0,c.getRevealFee)(r),storageLimit:c.REVEAL_STORAGE_LIMIT,gasLimit:(0,c.getRevealGasLimit)(r),proof:t===p.PrefixV2.BLS12_381PublicKeyHash?(await this.signer.provePossession()).prefixSig:void 0},r,s)),b.unshift(!1)}const v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(r),10),_=this.constructOpContents(y,E,r),A=b.flatMap((t,e)=>t?[e]:[]);return{opOb:{branch:v,contents:_,protocol:w},counter:E,simulation:A.length>0?{gasLimitPatchableIndexes:A}:void 0}}async contractCall(t){const e=await this.getBlockHash(),r=await this.getProtocolHash(),{pkh:s}=await this.getKeys();i(this,n,{},"f");const a=parseInt(await this.getHeadCounter(s),10),c=t.toTransferParams(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,s,o.OpKind.TRANSACTION,c.gasLimit),h=g({fee:c.fee,storageLimit:c.storageLimit,gasLimit:c.gasLimit},l),f={kind:o.OpKind.TRANSACTION,fee:c.fee??h.fee,gas_limit:c.gasLimit??h.gasLimit,storage_limit:c.storageLimit??h.storageLimit,amount:String(c.amount),destination:c.to,parameters:c.parameter},d=await this.addRevealOperationIfNeeded(f,s),p=this.convertIntoArray(d),m={opOb:{branch:e,contents:this.constructOpContents(p,a,s),protocol:r},counter:a};return this.withSimulationMetadata(m,this.getSingleManagerOperationSimulation(p,c.gasLimit))}async toPreapply(t){const{opOb:{contents:e,branch:r,protocol:n}}=t,i=this.toForge(t),s=await this.context.forger.forge(i);return[{contents:e,branch:r,protocol:n,signature:(await this.context.signer.sign(s,new Uint8Array([3]))).prefixSig}]}toForge({opOb:{contents:t,branch:e}}){return{branch:e,contents:t}}}e.PrepareProvider=m,n=new WeakMap},5605(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Provider=void 0;const n=r(2211),i=r(6568),s=r(286),o=r(2654),a=r(3157),c=r(2403);e.Provider=class{clearRpcCache(){const t=this.context.rpc;"function"==typeof t.deleteAllCachedData&&t.deleteAllCachedData()}parseRpcErrors(t){if(!(t instanceof n.HttpResponseError))return[];let e;try{e=JSON.parse(t.body)}catch{return[]}return Array.isArray(e)?e.filter(t=>"object"==typeof t&&null!==t):[]}toBigInt(t){if("bigint"==typeof t)return t;if("number"==typeof t&&Number.isFinite(t)&&Number.isInteger(t))return BigInt(t);if("string"==typeof t&&/^-?\d+$/.test(t))return BigInt(t);if("object"==typeof t&&null!==t&&"toString"in t){const e=t.toString();if(/^-?\d+$/.test(e))return BigInt(e)}}parseCounterAdjustments(t){return this.parseRpcErrors(t).filter(t=>{const e=t.id,r=t.contract,n=t.expected,i=t.found;return"string"==typeof e&&(e.endsWith("contract.counter_in_the_past")||e.endsWith("contract.counter_in_the_future"))&&"string"==typeof r&&"string"==typeof n&&"string"==typeof i}).map(t=>({contract:t.contract,expected:BigInt(t.expected),found:BigInt(t.found)})).filter(t=>t.expected!==t.found)}hasGasLimitTooHighAndBlockExhausted(t){const e=this.parseRpcErrors(t).map(t=>t.id).filter(t=>"string"==typeof t);return e.some(t=>t.endsWith("gas_limit_too_high"))&&e.some(t=>t.endsWith("gas_exhausted.block"))}async patchSimulationGasLimits(t,e,r){if(!this.hasGasLimitTooHighAndBlockExhausted(e))return;if(!Array.isArray(t.operation.contents))return;const n=await this.context.readProvider.getProtocolConstants("head"),i=this.toBigInt(n.hard_gas_limit_per_operation),s=this.toBigInt(n.hard_gas_limit_per_block),o=BigInt(0);if(void 0===i||void 0===s||i<=o||s<=o)return;const a=t.operation.contents.map(t=>({...t})),c=r&&r.length>0?r.filter(t=>t>=0&&t<a.length):[];let u=o;for(const[t,e]of a.entries()){const r=e.kind,n=this.toBigInt(e.gas_limit);if(void 0!==n){if(0===c.length){if("reveal"!==r&&n>=i){c.push(t);continue}}else if(c.includes(t))continue;u+=n}}if(0===c.length)return;const l=s-u,h=l>o?l/BigInt(c.length):o,f=h>i?i:h;let d=!1;for(const t of c){const e=a[t];this.toBigInt(e.gas_limit)!==f&&(a[t].gas_limit=f.toString(),d=!0)}return d?{...t,operation:{...t.operation,contents:a}}:void 0}patchSimulationCounters(t,e){if(0===e.length)return;if(!Array.isArray(t.operation.contents))return;const r=t.operation.contents.map(t=>({...t}));let n=!1;for(const t of e){const e=t.expected-t.found;for(const i of r){const r=i.source,s=i.counter;if(r!==t.contract||void 0===s)continue;const o=BigInt(String(s));o<t.found||(i.counter=(o+e).toString(),n=!0)}}return n?{...t,operation:{...t.operation,contents:r}}:void 0}get rpc(){return this.context.rpc}get signer(){return this.context.signer}constructor(t){this.context=t}async forge({opOb:{branch:t,contents:e,protocol:r},counter:n}){return{opbytes:await this.context.forger.forge({branch:t,contents:e}),opOb:{branch:t,contents:e,protocol:r},counter:n}}async estimate({fee:t,gasLimit:e,storageLimit:r,...n},i){let o=t,a=e,c=r;if(o&&o%1!=0)throw new s.InvalidEstimateValueError(`Fee value must not be a decimal: ${o}`);if(a&&a%1!=0)throw new s.InvalidEstimateValueError(`Gas Limit value must not be a decimal: ${a}`);if(c&&c%1!=0)throw new s.InvalidEstimateValueError(`Storage Limit value must not be a decimal: ${c}`);if(void 0===t||void 0===e||void 0===r){const s=await i({fee:t,gasLimit:e,storageLimit:r,...n});o??(o=s.suggestedFeeMutez),a??(a=s.gasLimit),c??(c=s.storageLimit)}return{fee:o,gasLimit:a,storageLimit:c}}async getRPCOp(t){switch(t.kind){case a.OpKind.TRANSACTION:return(0,o.createTransferOperation)({...t});case a.OpKind.ORIGINATION:return(0,o.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...t}));case a.OpKind.DELEGATION:return(0,o.createSetDelegateOperation)({...t});case a.OpKind.REGISTER_GLOBAL_CONSTANT:return(0,o.createRegisterGlobalConstantOperation)({...t});case a.OpKind.INCREASE_PAID_STORAGE:return(0,o.createIncreasePaidStorageOperation)({...t});case a.OpKind.UPDATE_CONSENSUS_KEY:return(0,o.createUpdateConsensusKeyOperation)({...t});case a.OpKind.UPDATE_COMPANION_KEY:return(0,o.createUpdateCompanionKeyOperation)({...t});case a.OpKind.TRANSFER_TICKET:return(0,o.createTransferTicketOperation)({...t});case a.OpKind.SMART_ROLLUP_ADD_MESSAGES:return(0,o.createSmartRollupAddMessagesOperation)({...t});case a.OpKind.SMART_ROLLUP_ORIGINATE:return(0,o.createSmartRollupOriginateOperation)({...t});case a.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return(0,o.createSmartRollupExecuteOutboxMessageOperation)({...t});default:throw new c.InvalidOperationKindError(t.kind)}}async simulate(t,e){const r=e?.simulation?.gasLimitPatchableIndexes;try{return{opResponse:await this.rpc.simulateOperation(t),op:t,context:this.context.clone()}}catch(e){const n=this.parseCounterAdjustments(e),i=this.patchSimulationCounters(t,n);if(i)try{return{opResponse:await this.rpc.simulateOperation(i),op:i,context:this.context.clone()}}catch(t){const e=await this.patchSimulationGasLimits(i,t,r);if(!e)throw t;return{opResponse:await this.rpc.simulateOperation(e),op:e,context:this.context.clone()}}const s=await this.patchSimulationGasLimits(t,e,r);if(!s)throw e;return{opResponse:await this.rpc.simulateOperation(s),op:s,context:this.context.clone()}}}async isRevealOpNeeded(t,e){return!(!await this.isAccountRevealRequired(e)||!this.isRevealRequiredForOpType(t))}async isAccountRevealRequired(t){return!await this.context.readProvider.isAccountRevealed(t,"head")}isRevealRequiredForOpType(t){let e=!1;for(const r of t)(0,i.isOpRequireReveal)(r)&&(e=!0);return e}async signAndInject(t){let e=await this.signForgedBytes(t);const r=[];let n;try{n=await this.rpc.preapplyOperations([e.opOb])}catch(t){const r=this.parseCounterAdjustments(t),i=await this.patchForgedBytesCounters(e,r);if(!i)throw t;e=await this.signForgedBytes(i),n=await this.rpc.preapplyOperations([e.opOb])}if(!Array.isArray(n))throw new s.TezosPreapplyFailureError(n);for(let t=0;t<n.length;t++)for(let e=0;e<n[t].contents.length;e++)r.push(n[t].contents[e]);const i=(0,s.flattenErrors)(n);if(i.length)throw new s.TezosOperationError(i,"Error occurred during validation simulation of operation",r);const o=await this.context.injector.inject(e.opbytes);return this.clearRpcCache(),{hash:o,forgedBytes:e,opResponse:r,context:this.context.clone()}}async signForgedBytes(t){const e=await this.signer.sign(t.opbytes,new Uint8Array([3]));return{...t,opbytes:e.sbytes,opOb:{...t.opOb,signature:e.prefixSig}}}async patchForgedBytesCounters(t,e){if(0===e.length||!Array.isArray(t.opOb.contents))return;const r=t.opOb.branch;if("string"!=typeof r)return;const n=t.opOb.contents.map(t=>({...t}));let i=!1;for(const t of e){const e=t.expected-t.found;for(const r of n){const n=r.source,s=r.counter;if(n!==t.contract||void 0===s)continue;const o=BigInt(String(s));o<t.found||(r.counter=(o+e).toString(),i=!0)}}if(!i)return;const s=await this.context.forger.forge({branch:r,contents:n});return{...t,opbytes:s,opOb:{...t.opOb,contents:n}}}}},3484(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isBlockHashIdentifier=void 0;const n=r(2403);r(7873).default;e.isBlockHashIdentifier=t=>(0,n.validateBlock)(t)===n.ValidationResult.VALID},4631(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcReadAdapter=void 0;r(7873).default;e.RpcReadAdapter=class{constructor(t){this.rpc=t}async getBalance(t,e){return this.rpc.getBalance(t,{block:String(e)})}async getSpendable(t,e){return this.rpc.getSpendable(t,{block:String(e)})}async getDelegate(t,e){return this.rpc.getDelegate(t,{block:String(e)})}async getNextProtocol(t){return(await this.rpc.getProtocols({block:String(t)})).next_protocol}async getProtocolConstants(t){const{time_between_blocks:e,minimal_block_delay:r,hard_gas_limit_per_operation:n,hard_gas_limit_per_block:i,hard_storage_limit_per_operation:s,cost_per_byte:o,smart_rollup_origination_size:a}=await this.rpc.getConstants({block:String(t)});return{time_between_blocks:e,minimal_block_delay:r,hard_gas_limit_per_operation:n,hard_gas_limit_per_block:i,hard_storage_limit_per_operation:s,cost_per_byte:o,smart_rollup_origination_size:a}}async getScript(t,e){const{script:r}=await this.rpc.getContract(t,{block:String(e)});return r}async getStorage(t,e){return this.rpc.getStorage(t,{block:String(e)})}async getBlockHash(t){const{hash:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getBlockLevel(t){const{level:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getCounter(t,e){const{counter:r}=await this.rpc.getContract(t,{block:String(e)});return r||"0"}async getBlockTimestamp(t){const{timestamp:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getBigMapValue(t,e){return this.rpc.getBigMapExpr(t.id,t.expr,{block:String(e)})}async getSaplingDiffById(t,e){return this.rpc.getSaplingDiffById(t.id,{block:String(e)})}async getSaplingDiffByContract(t,e){return this.rpc.getSaplingDiffByContract(t,{block:String(e)})}async getEntrypoints(t){return this.rpc.getEntrypoints(t)}async getChainId(){return this.rpc.getChainId()}async isAccountRevealed(t,e){const r=await this.rpc.getManagerKey(t,{block:String(e)});return r&&"object"==typeof r?!!r.key:!!r}async getBlock(t){return this.rpc.getBlock({block:String(t)})}getLiveBlocks(t){return this.rpc.getLiveBlocks({block:String(t)})}getAdaptiveIssuanceLaunchCycle(t){return this.rpc.getAdaptiveIssuanceLaunchCycle({block:String(t)})}}},1102(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnconfiguredSignerError=void 0;const n=r(6571);class i extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnconfiguredSignerError",this.message="No signer has been configured. Please configure one by calling setProvider({signer}) on your TezosToolkit instance."}}e.UnconfiguredSignerError=i},6425(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopSigner=void 0;const n=r(1102);e.NoopSigner=class{async publicKey(){throw new n.UnconfiguredSignerError}async publicKeyHash(){throw new n.UnconfiguredSignerError}async secretKey(){throw new n.UnconfiguredSignerError}async sign(t,e){throw new n.UnconfiguredSignerError}}},9940(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createObservableFromSubscription=function(t){return new n.Observable(e=>(t.on("data",t=>{e.next(t)}),t.on("error",t=>{e.error(t)}),t.on("close",()=>{e.complete()}),()=>{t.close()}))};const n=r(1948)},4938(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidFilterExpressionError=e.UnsupportedEventError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t){super(),this.type=t,this.name="UnsupportedEventError",this.message=`Unsupported event type "${t}" expecting one of the "data", "error", or "close".`}}e.UnsupportedEventError=i;class s extends n.ParameterValidationError{constructor(t){super(),this.invalidExpression=t,this.name="InvalidFilterExpressionError",this.message="Invalid filter expression expecting the object to contain either and/or property"}}e.InvalidFilterExpressionError=s},8706(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFilter=e.evaluateExpression=e.evaluateOpFilter=e.eventFilter=void 0;const n=r(4938);e.eventFilter=(t,e,r,n)=>"event"===t.kind&&((!r||t.tag===r)&&((!e||t.source===e)&&(!n||"applied"===t.result.status)));e.evaluateOpFilter=(t,e)=>"opHash"in e?((t,e)=>t.hash===e.opHash)(t,e):"source"in e?((t,e)=>{switch(t.kind){case"attestation":return"metadata"in t&&t.metadata.delegate===e.source;case"activate_account":return"metadata"in t&&t.pkh===e.source;default:return"source"in t&&t.source===e.source}})(t,e):"kind"in e?((t,e)=>"kind"in t&&t.kind===e.kind)(t,e):"destination"in e&&((t,e)=>{switch(t.kind){case"delegation":return t.delegate===e.destination;case"origination":if("metadata"in t&&"operation_result"in t.metadata&&"originated_contracts"in t.metadata.operation_result&&Array.isArray(t.metadata.operation_result.originated_contracts))return t.metadata.operation_result.originated_contracts.some(t=>t===e.destination);break;case"transaction":return t.destination===e.destination;default:return!1}})(t,e);e.evaluateExpression=(t,r)=>{if(Array.isArray(r.and))return r.and.every(r=>(0,e.evaluateFilter)(t,r));if(Array.isArray(r.or))return r.or.some(r=>(0,e.evaluateFilter)(t,r));throw new n.InvalidFilterExpressionError(r)};e.evaluateFilter=(t,r)=>{const n=[];return Array.isArray(r)?n.push(...r):n.push(r),n.every(r=>"and"in r||"or"in r?(0,e.evaluateExpression)(t,r):(0,e.evaluateOpFilter)(t,r))}},2422(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4040(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ObservableSubscription=e.UnsupportedEventError=void 0;const n=r(1948),i=r(1018),s=r(4938);var o=r(4938);Object.defineProperty(e,"UnsupportedEventError",{enumerable:!0,get:function(){return o.UnsupportedEventError}});e.ObservableSubscription=class{constructor(t,e=!1,r=(0,i.retry)()){this.shouldRetry=e,this.operatorFunction=r,this.errorListeners=[],this.messageListeners=[],this.closeListeners=[],this.completed$=new n.Subject,t.pipe((0,i.takeUntil)(this.completed$),(0,i.tap)(t=>{this.call(this.messageListeners,t)},t=>{this.call(this.errorListeners,t)},()=>{this.call(this.closeListeners)}),this.shouldRetry?r:(0,i.tap)(),(0,i.catchError)(()=>n.NEVER)).subscribe()}call(t,e){for(const r of t)try{r(e)}catch(t){console.error(t)}}remove(t,e){const r=t.indexOf(e);-1!==r&&t.splice(r,1)}on(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 s.UnsupportedEventError(t)}}off(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 s.UnsupportedEventError(t)}}close(){this.completed$.next()}}},8648(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PollingSubscribeProvider=e.defaultConfigStreamer=void 0;const n=r(1948),i=r(1018),s=r(8706),o=r(4040),a=r(7873);e.defaultConfigStreamer={shouldObservableSubscriptionRetry:!1,observableSubscriptionRetryFunction:(0,i.retry)()};e.PollingSubscribeProvider=class{constructor(t,r={}){this.context=t,this._config$=new n.BehaviorSubject({...e.defaultConfigStreamer,...r}),this.timer$=this._config$.pipe((0,i.map)(t=>t?.pollingIntervalMilliseconds),(0,i.switchMap)(t=>t?(0,n.timer)(0,t):(0,n.from)(this.getConfirmationPollingInterval()).pipe((0,i.switchMap)(t=>(0,n.timer)(0,t))))),this.newBlock$=this.timer$.pipe((0,i.exhaustMap)(()=>(t=>(0,n.from)(t.rpc.getBlock()).pipe((0,i.first)()))(this.context)),(0,i.distinctUntilKeyChanged)("hash"),(0,i.share)({resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0}))}get config(){return this._config$.getValue()}async getConfirmationPollingInterval(){if(!this.config.pollingIntervalMilliseconds){const t=5e3,e=700;try{const r=await this.context.readProvider.getProtocolConstants("head"),n=(r.minimal_block_delay?r.minimal_block_delay.multipliedBy(1e3):new a.default(t)).dividedBy(3);this.config.pollingIntervalMilliseconds=0===n.toNumber()?e:Math.max(n.toNumber(),e)}catch(e){return t}}return this.config.pollingIntervalMilliseconds}subscribeBlock(t){return new o.ObservableSubscription(this.newBlock$,this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribe(t){return new o.ObservableSubscription(this.newBlock$.pipe((0,i.map)(t=>t?.hash)),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribeOperation(t){return new o.ObservableSubscription(this.newBlock$.pipe((t=>(0,i.concatMap)(e=>new n.Observable(r=>{for(const n of e.operations)for(const e of n)for(const n of e.contents)(0,s.evaluateFilter)({hash:e.hash,...n},t)&&r.next({hash:e.hash,...n});r.complete()})))(t)),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribeEvent(t){return new o.ObservableSubscription(this.newBlock$.pipe((e=t,(0,i.concatMap)(t=>new n.Observable(r=>{for(const n of t.operations)for(const i of n)for(const n of i.contents){const o=n.metadata.internal_operation_results;if(o)for(const n of o)(0,s.eventFilter)(n,e?.address,e?.tag,e?.excludeFailedOperations)&&r.next({opHash:i.hash,blockHash:t.hash,level:t.header.level,...n})}r.complete()})))),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction);var e}}},4779(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.TezosToolkit=e.importKey=e.TaquitoLocalForger=e.RpcReadAdapter=e.ObservableSubscription=e.PollingSubscribeProvider=e.OperationBatch=e.RpcForger=e.CompositeForger=e.UnitValue=e.MichelsonMap=e.Token=void 0;const s=r(3157),o=r(7021),a=r(2403),c=r(8320),u=r(577),l=r(4631),h=r(6425),f=r(8648),d=r(4982),p=r(1170),g=r(8724),m=r(8541),y=r(2245),b=r(5602);var v=r(5602);Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return v.Token}}),Object.defineProperty(e,"MichelsonMap",{enumerable:!0,get:function(){return v.MichelsonMap}}),Object.defineProperty(e,"UnitValue",{enumerable:!0,get:function(){return v.UnitValue}}),i(r(5283),e),i(r(7021),e),i(r(2445),e),i(r(9676),e);var w=r(3215);Object.defineProperty(e,"CompositeForger",{enumerable:!0,get:function(){return w.CompositeForger}});var E=r(9719);Object.defineProperty(e,"RpcForger",{enumerable:!0,get:function(){return E.RpcForger}}),i(r(105),e);var _=r(5025);Object.defineProperty(e,"OperationBatch",{enumerable:!0,get:function(){return _.OperationBatch}}),i(r(2422),e);var A=r(8648);Object.defineProperty(e,"PollingSubscribeProvider",{enumerable:!0,get:function(){return A.PollingSubscribeProvider}});var O=r(4040);Object.defineProperty(e,"ObservableSubscription",{enumerable:!0,get:function(){return O.ObservableSubscription}}),i(r(1174),e),i(r(1170),e),i(r(9164),e),i(r(2245),e),i(r(3971),e),i(r(8541),e),i(r(6424),e),i(r(458),e),i(r(4377),e),i(r(577),e),i(r(152),e),i(r(1566),e),i(r(7157),e);var S=r(4631);Object.defineProperty(e,"RpcReadAdapter",{enumerable:!0,get:function(){return S.RpcReadAdapter}}),i(r(5681),e);var T=r(8724);Object.defineProperty(e,"TaquitoLocalForger",{enumerable:!0,get:function(){return T.TaquitoLocalForger}}),i(r(3682),e);var P=r(8763);Object.defineProperty(e,"importKey",{enumerable:!0,get:function(){return P.importKey}});e.TezosToolkit=class{constructor(t){this._rpc=t,this._options={},this.format=a.format,"string"==typeof this._rpc?this._rpcClient=new s.RpcClient(this._rpc):this._rpcClient=this._rpc,this._context=new o.Context(t),this._wallet=new p.Wallet(this._context),this.setProvider({rpc:this._rpcClient})}setProvider({rpc:t,stream:e,signer:r,protocol:n,config:i,forger:s,wallet:o,packer:a,globalConstantsProvider:c,readProvider:u,parserProvider:l,injectorProvider:h}){this.setRpcProvider(t),this.setStreamProvider(e),this.setSignerProvider(r),this.setForgerProvider(s),this.setWalletProvider(o),this.setPackerProvider(a),this.setGlobalConstantsProvider(c),this.setReadProvider(u),this.setParserProvider(l),this.setInjectorProvider(h),this._context.proto=n,i&&this._context.setPartialConfig(i)}setSignerProvider(t){this._options.signer||void 0!==t?void 0!==t&&(this._context.signer=t,this._options.signer=t):(this._context.signer=new h.NoopSigner,this._options.signer=t)}setRpcProvider(t){"string"==typeof t?this._rpcClient=new s.RpcClient(t):void 0===t||(this._rpcClient=t),this._options.rpc=this._rpcClient,this._context.rpc=this._rpcClient}setForgerProvider(t){if(void 0!==t)this._options.forger=t,this._context.forger=t;else if(void 0===this._options.forger){const t=this.getFactory(g.TaquitoLocalForger)();this._options.forger=t,this._context.forger=t}}setStreamProvider(t){if("string"==typeof t){const e=new f.PollingSubscribeProvider(new o.Context(new s.RpcClient(t)));this._options.stream=e,this._context.stream=e}else if(void 0!==t)this._options.stream=t,this._context.stream=t;else if(void 0===this._options.stream){const t=this.getFactory(f.PollingSubscribeProvider)();this._options.stream=t,this._context.stream=t}}setWalletProvider(t){if(this._options.wallet||void 0!==t)void 0!==t&&(this._options.wallet=t,this._context.walletProvider=t);else{const t=this.getFactory(p.LegacyWalletProvider)();this._options.wallet=t,this._context.walletProvider=t}}setPackerProvider(t){if(this._options.packer||void 0!==t)void 0!==t&&(this._context.packer=t,this._options.packer=t);else{const t=this.getFactory(u.RpcPacker)();this._context.packer=t,this._options.packer=t}}setGlobalConstantsProvider(t){if(this._options.globalConstantsProvider||void 0!==t)void 0!==t&&(this._context.globalConstantsProvider=t,this._options.globalConstantsProvider=t);else{const t=new c.NoopGlobalConstantsProvider;this._context.globalConstantsProvider=t,this._options.globalConstantsProvider=t}}setReadProvider(t){const e=t||new l.RpcReadAdapter(this._context.rpc);this._options.readProvider=e,this._context.readProvider=e}setParserProvider(t){if(this._options.parserProvider||void 0!==t)void 0!==t&&(this._context.parser=t,this._options.parserProvider=t);else{const t=new m.MichelCodecParser(this._context);this._context.parser=t,this._options.parserProvider=t}}setInjectorProvider(t){if(this._options.injectorProvider||void 0!==t)void 0!==t&&(this._context.injector=t,this._options.injectorProvider=t);else{const t=new y.RpcInjector(this._context);this._context.injector=t,this._options.injectorProvider=t}}setFieldNumberingStrategy(t){b.Token.fieldNumberingStrategy=t}get tz(){return this._context.tz}get contract(){return this._context.contract}get prepare(){return this._context.prepare}get wallet(){return this._wallet}get operation(){return this._context.operationFactory}get estimate(){return this._context.estimate}get stream(){return this._context.stream}get rpc(){return this._context.rpc}get signer(){return this._context.signer}get globalConstants(){return this._context.globalConstantsProvider}addExtension(t){Array.isArray(t)?t.forEach(t=>t.configureContext(this._context)):t.configureContext(this._context)}getFactory(t){return(...e)=>new t(this._context,...e)}getVersionInfo(){return d.VERSION}}},1174(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});r(7873).default},8907(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcTzProvider=void 0;r(7873).default;const n=r(1859),i=r(2403),s=r(6571),o=r(5605),a=r(3682);class c extends o.Provider{constructor(t){super(t),this.prepare=new a.PrepareProvider(this.context)}async getBalance(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getBalance(t,"head")}async getSpendable(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getSpendable(t,"head")}async getDelegate(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getDelegate(t,"head")}async activate(t,e){const r=(0,i.validateKeyHash)(t);if(r!==i.ValidationResult.VALID)throw new i.InvalidKeyHashError(t,r);const s=await this.prepare.activate({pkh:t,secret:e}),o=await this.forge(s),a=`${o.opbytes}00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`;return new n.Operation(await this.rpc.injectOperation(a),{...o,opbytes:a},[],this.context.clone())}}e.RpcTzProvider=c},4982(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION={commitHash:"9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",version:"25.0.0-beta.1"}},2538(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchWalletOperation=e.WALLET_BATCH_KINDS=void 0;const n=r(3157),i=r(6568),s=r(3871),o=r(2599);e.WALLET_BATCH_KINDS=[n.OpKind.REVEAL,n.OpKind.ORIGINATION,n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET];class a extends s.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e,this.getOriginatedContractAddresses=async()=>{const t=await this.operationResults();if(t){const e=t.filter(t=>"origination"===t.kind);let r=[];for(const t of e)t.metadata.operation_result.originated_contracts&&(r=[...r,...t.metadata.operation_result.originated_contracts]);return r}throw new o.ObservableError("Unable to fetch operation results")}}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.REVEAL);throw new o.ObservableError("Unable to fetch operation results")}async status(){if(!this._included)return"pending";const t=await this.operationResults();if(t)return t.filter(t=>-1!==e.WALLET_BATCH_KINDS.indexOf(t.kind)).map(t=>{if((0,i.hasMetadataWithResult)(t)){return t.metadata.operation_result.status}return"unknown"})[0]||"unknown";throw new o.ObservableError("Unable to fetch operation results")}}e.BatchWalletOperation=a},9734(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DelegationWalletOperation=void 0;const n=r(3157),i=r(3871),s=r(2599);class o extends i.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.REVEAL);throw new s.ObservableError("Unable to fetch operation result")}async delegationOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.DELEGATION);throw new s.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.delegationOperation();return t?t.metadata.operation_result.status:"unknown"}}e.DelegationWalletOperation=o},2599(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationWalletOperationError=e.ObservableError=e.ConfirmationUndefinedError=void 0;const n=r(6571);class i extends n.TezosToolkitConfigError{constructor(){super(),this.name="ConfirmationUndefinedError",this.message="Default confirmation count can not be undefined"}}e.ConfirmationUndefinedError=i;class s extends n.NetworkError{constructor(t){super(),this.message=t,this.name="ObservableError"}}e.ObservableError=s;e.OriginationWalletOperationError=class extends s{constructor(t){super(t),this.message=t,this.name="OriginationWalletOperationError"}}},6583(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IncreasePaidStorageWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===i.OpKind.REVEAL);throw new s.ObservableError("Unable to fetch operation result")}async increasePaidStorageOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===i.OpKind.INCREASE_PAID_STORAGE);throw new s.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.increasePaidStorageOperation();return t?t.metadata.operation_result.status:"unknown"}}e.IncreasePaidStorageWalletOperation=o},1170(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(1593),e),i(r(3871),e),i(r(122),e),i(r(77),e),i(r(9734),e),i(r(9432),e),i(r(3026),e),i(r(6117),e),i(r(4723),e)},6117(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4723(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LegacyWalletProvider=void 0;const n=r(6568);e.LegacyWalletProvider=class{constructor(t){this.context=t}async getPKH(){return this.context.signer.publicKeyHash()}async getPK(){return this.context.signer.publicKey()}async mapTransferParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapStakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapUnstakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapFinalizeUnstakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapOriginateParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.ORIGINATION)}async mapDelegateParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.DELEGATION)}async mapIncreasePaidStorageWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.INCREASE_PAID_STORAGE)}async mapTransferTicketParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSFER_TICKET)}async mapRegisterGlobalConstantParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.REGISTER_GLOBAL_CONSTANT)}async sendOperations(t){return(await this.context.batch.batch(t).send()).hash}async sign(t,e){const{prefixSig:r}=await this.context.signer.sign(t,e);return r}}},808(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OperationFactory=e.createNewPollingBasedHeadObservable=void 0,e.timeoutAfter=g;const n=r(1948),i=r(1018),s=r(9940),o=r(2538),a=r(9734),c=r(6583),u=r(3871),l=r(77),h=r(122),f=r(9432),d=r(4359),p=r(3026);function g(t){return function(e){return new n.BehaviorSubject(null).pipe((0,i.timeout)({each:t,with:()=>(0,n.throwError)(()=>new d.ConfirmationTimeoutError("Confirmation polling timed out"))}),(0,i.mergeMap)(()=>e))}}e.createNewPollingBasedHeadObservable=(t,e,r)=>t.pipe(g(1e3*e.config.confirmationPollingTimeoutSecond),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0}));e.OperationFactory=class{constructor(t){this.context=t,this.sharedHeadObs=(0,n.defer)(()=>(0,s.createObservableFromSubscription)(this.context.stream.subscribeBlock("head")))}async createNewHeadObservable(){return(0,e.createNewPollingBasedHeadObservable)(this.sharedHeadObs,this.context)}createPastBlockWalker(t,e=1){return(0,n.from)(this.context.readProvider.getBlock(t)).pipe((0,i.switchMap)(t=>1===e?(0,n.of)(t):(0,n.range)(t.header.level,e-1).pipe((0,i.startWith)(t),(0,i.concatMap)(async t=>this.context.readProvider.getBlock("number"==typeof t?t:t.header.level)))))}async createHeadObservableFromConfig({blockIdentifier:t}){const e=[];return t&&e.push(this.createPastBlockWalker(t)),e.push(await this.createNewHeadObservable()),(0,n.concat)(...e)}async createOperation(t,e={}){return new u.WalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createBatchOperation(t,e={}){return new o.BatchWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createTransactionOperation(t,e={}){return new h.TransactionWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createTransferTicketOperation(t,e={}){return new f.TransferTicketWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createDelegationOperation(t,e={}){return new a.DelegationWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createOriginationOperation(t,e={}){return new l.OriginationWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createIncreasePaidStorageOperation(t,e={}){return new c.IncreasePaidStorageWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createRegisterGlobalConstantOperation(t,e={}){return new p.RegisterGlobalConstantWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}}},3871(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WalletOperation=void 0;const n=r(1948),i=r(1018),s=r(6854),o=r(2403),a=r(4359),c=r(2599),u=r(6571),l="undefined"!=typeof process?process.env:void 0,h=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE??""),f=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE_VERBOSE??""),d=Number(l?.TAQUITO_OP_TRACE_SLOW_MS??"60000"),p=Number.isFinite(d)&&d>=0?d:6e4,g=t=>"object"==typeof t&&null!==t?t:void 0,m=t=>Array.isArray(t)?t.map(t=>{const e=g(t)??{},r=g(e.metadata),n=g(r?.operation_result);return{kind:"string"==typeof e.kind?e.kind:"unknown",status:"string"==typeof n?.status?n.status:"unknown",errors:(i=n?.errors,Array.isArray(i)?i:[]),consumed_milligas:"string"==typeof n?.consumed_milligas?n.consumed_milligas:void 0};var i}):[],y=t=>t instanceof Error?`${t.name}: ${t.message}`:String(t),b=t=>{h&&console.log(`[taquito:wallet-op-trace] ${JSON.stringify(t)}`)};e.WalletOperation=class{async operationResults(){return this._operationResult.pipe((0,i.first)()).toPromise()}async getInclusionBlock(){const t=await this._includedInBlock.pipe((0,i.first)()).toPromise();if(!t)throw new c.ObservableError("Inclusion block is undefined");return t}async getOperationResultsIfIncluded(){if(this._included)return this.operationResults().catch(()=>{})}async receipt(){const t=await this.operationResults();if(!t)throw new c.ObservableError("Unable to get operation results");return(0,s.receiptFromOperation)(t)}constructor(t,e,r){if(this.opHash=t,this.context=e,this._newHead$=r,this._operationResult=new n.ReplaySubject(1),this._includedInBlock=new n.ReplaySubject(1),this._included=!1,this.newHead$=this._newHead$.pipe((0,i.switchMap)(t=>{const e=this.lastHead?.header.level??t.header.level-1;return(0,n.range)(e+1,t.header.level-e-1).pipe((0,i.concatMap)(t=>this.context.readProvider.getBlock(t)),(0,i.endWith)(t))}),(0,i.tap)(t=>this.lastHead=t),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0})),this.confirmed$=this.newHead$.pipe((0,i.map)(t=>{for(const e of t.operations)for(const r of e)if(r.hash===this.opHash)return this._included=!0,this._includedInBlock.next(t),this._operationResult.next(r.contents),t}),(0,i.filter)(t=>void 0!==t),(0,i.first)(),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0})),(0,o.validateOperation)(this.opHash)!==o.ValidationResult.VALID)throw new u.InvalidOperationHashError(this.opHash);this.confirmed$.pipe((0,i.first)(),(0,i.catchError)(()=>(0,n.of)(void 0))).subscribe()}async getCurrentConfirmation(){return this._included?(0,n.combineLatest)([this._includedInBlock,(0,n.from)(this.context.readProvider.getBlock("head"))]).pipe((0,i.map)(([t,e])=>e.header.level-t.header.level+1),(0,i.first)()).toPromise():0}async isInCurrentBranch(t="head"){if(!this._included)return!0;const e=await this.context.readProvider.getBlockLevel(t),r=await this.getInclusionBlock(),n=e-r.header.level;if(n<=0)return!0;const i=Math.min(r.header.level+n,r.header.level+60);return new Set(await this.context.readProvider.getLiveBlocks(i)).has(r.hash)}confirmationObservable(t){if(void 0!==t&&t<1)throw new a.InvalidConfirmationCountError(t);const{defaultConfirmationCount:e}=this.context.config,r=void 0!==t?t:e;if(void 0===r)throw new c.ConfirmationUndefinedError;return(0,n.combineLatest)([this._includedInBlock,this.newHead$]).pipe((0,i.distinctUntilChanged)(([,t],[,e])=>t.hash===e.hash),(0,i.map)(([t,e])=>({block:e,expectedConfirmation:r,currentConfirmation:e.header.level-t.header.level+1,completed:e.header.level-t.header.level>=r-1,isInCurrentBranch:()=>this.isInCurrentBranch(e.hash)})),(0,i.takeWhile)(({completed:t})=>!t,!0))}async confirmation(t){const e=Date.now(),r=t??this.context.config.defaultConfirmationCount;try{const n=await this.confirmationObservable(t).toPromise(),i=await this.getOperationResultsIfIncluded(),s=m(i),o=s.filter(t=>"applied"!==t.status).map(t=>t.status),a=Date.now()-e;return(f||a>=p||o.length>0)&&b({stage:"confirmation-complete",opHash:this.opHash,elapsedMs:a,expectedConfirmation:r,currentConfirmation:n?.currentConfirmation,completed:n?.completed,statuses:s.map(t=>t.status),results:s}),n}catch(t){const n=await this.getOperationResultsIfIncluded();throw b({stage:"confirmation-error",opHash:this.opHash,elapsedMs:Date.now()-e,expectedConfirmation:r,error:y(t),results:m(n)}),t}}}},77(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationWalletOperation=void 0;const n=r(3157),i=r(3484),s=r(6568),o=r(3871),a=r(2599);class c extends o.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async originationOperation(){const t=await this.operationResults();if(t)return(0,s.findWithKind)(t,n.OpKind.ORIGINATION);throw new a.ObservableError("Unable to fetch operation result")}async revealOperation(){const t=await this.operationResults();if(t)return(0,s.findWithKind)(t,n.OpKind.REVEAL);throw new a.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.originationOperation();return t?t.metadata.operation_result.status:"unknown"}async contract(){const t=await this.originationOperation(),e=(t?.metadata.operation_result.originated_contracts||[])[0];if(!e)throw new a.OriginationWalletOperationError("No contract was originated in this operation");await this.confirmation();const r=await this.getInclusionBlock();if(!(0,i.isBlockHashIdentifier)(r.hash))throw new a.OriginationWalletOperationError("Inclusion block hash is invalid");return this.context.wallet.at(e,void 0,r.hash)}}e.OriginationWalletOperation=c},6854(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.receiptFromOperation=void 0;const n=r(7873).default,i=r(5283),s=r(286);e.receiptFromOperation=(t,{ALLOCATION_BURN:e,ORIGINATION_BURN:r}={ALLOCATION_BURN:257,ORIGINATION_BURN:257})=>{n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP});const o=(0,s.flattenOperationResult)({contents:t});let a=new n(0),c=new n(0),u=new n(0),l=new n(0),h=new n(0),f=new n(0);return o.forEach(t=>{u=u.plus(t.fee||0),l=l.plus(Array.isArray(t.originated_contracts)?t.originated_contracts.length*r:0),h=h.plus("allocated_destination_contract"in t?e:0),a=a.plus(t.consumed_milligas||0),f=f.plus("paid_storage_size_diff"in t&&Number(t.paid_storage_size_diff)||0)}),c=c.plus(h).plus(l).plus(f),{totalFee:u,totalMilliGas:a,totalGas:a.dividedBy(1e3),totalStorage:c,totalAllocationBurn:h,totalOriginationBurn:l,totalPaidStorageDiff:f,totalStorageBurn:new n(c.multipliedBy(i.COST_PER_BYTE))}}},3026(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegisterGlobalConstantWalletOperation=void 0;const n=r(3157),i=r(6568),s=r(3871),o=r(2599);class a extends s.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new o.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===n.OpKind.REVEAL)}async registerGlobalConstantOperation(){const t=await this.operationResults();if(t)return(0,i.findWithKind)(t,n.OpKind.REGISTER_GLOBAL_CONSTANT);throw new o.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.registerGlobalConstantOperation();return t?t.metadata.operation_result.status:"unknown"}async globalConstantHash(){const t=await this.registerGlobalConstantOperation();return t?.metadata.operation_result.global_address}}e.RegisterGlobalConstantWalletOperation=a},122(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.REVEAL)}async transactionOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.TRANSACTION)}async status(){if(!this._included)return"pending";const t=await this.transactionOperation();return t?t.metadata.operation_result.status:"unknown"}}e.TransactionWalletOperation=o},9432(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransferTicketWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.REVEAL)}async transferTicketOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.TRANSFER_TICKET)}async status(){if(!this._included)return"pending";const t=await this.transferTicketOperation();return t?t.metadata.operation_result.status:"unknown"}}e.TransferTicketWalletOperation=o},1593(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Wallet=e.WalletOperationBatch=void 0;const n=r(9339),i=r(6568),s=r(6571),o=r(2403),a=r(1254);class c{constructor(t,e){this.walletProvider=t,this.context=e,this.operations=[]}withTransfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.to,e);return this.operations.push({kind:i.OpKind.TRANSACTION,...t}),this}withContractCall(t,e={}){return this.withTransfer(t.toTransferParams(e))}withDelegation(t){const e=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.delegate,e);return this.operations.push({kind:i.OpKind.DELEGATION,...t}),this}withOrigination(t){return this.operations.push({kind:i.OpKind.ORIGINATION,...t}),this}withIncreasePaidStorage(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.operations.push({kind:i.OpKind.INCREASE_PAID_STORAGE,...t}),this}withTransferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.operations.push({kind:i.OpKind.TRANSFER_TICKET,...t}),this}withRegisterGlobalConstant(t){return this.operations.push({kind:i.OpKind.REGISTER_GLOBAL_CONSTANT,...t}),this}async mapOperation(t){switch(t.kind){case i.OpKind.TRANSACTION:return this.walletProvider.mapTransferParamsToWalletParams(async()=>t);case i.OpKind.ORIGINATION:return this.walletProvider.mapOriginateParamsToWalletParams(async()=>this.context.parser.prepareCodeOrigination({...t}));case i.OpKind.DELEGATION:return this.walletProvider.mapDelegateParamsToWalletParams(async()=>t);case i.OpKind.INCREASE_PAID_STORAGE:return this.walletProvider.mapIncreasePaidStorageWalletParams(async()=>t);case i.OpKind.REGISTER_GLOBAL_CONSTANT:return this.walletProvider.mapRegisterGlobalConstantParamsToWalletParams(async()=>t);case i.OpKind.TRANSFER_TICKET:return this.walletProvider.mapTransferTicketParamsToWalletParams(async()=>t);default:throw new s.InvalidOperationKindError(JSON.stringify(t.kind))}}with(t){for(const e of t)switch(e.kind){case i.OpKind.TRANSACTION:this.withTransfer(e);break;case i.OpKind.ORIGINATION:this.withOrigination(e);break;case i.OpKind.DELEGATION:this.withDelegation(e);break;case i.OpKind.INCREASE_PAID_STORAGE:this.withIncreasePaidStorage(e);break;case i.OpKind.REGISTER_GLOBAL_CONSTANT:this.withRegisterGlobalConstant(e);break;case i.OpKind.TRANSFER_TICKET:this.withTransferTicket(e);break;default:throw new s.InvalidOperationKindError(JSON.stringify(e.kind))}return this}async send(){const t=[];for(const e of this.operations)t.push(await this.mapOperation(e));const e=await this.walletProvider.sendOperations(t);return this.context.operationFactory.createBatchOperation(e)}}e.WalletOperationBatch=c;e.Wallet=class{constructor(t){this.context=t,this.walletCommand=t=>({send:t})}get walletProvider(){return this.context.walletProvider}async pkh({forceRefetch:t}={}){return this._pkh&&!t||(this._pkh=await this.walletProvider.getPKH()),this._pkh}async pk({forceRefetch:t}={}){return this._pk&&!t||(this._pk=await this.walletProvider.getPK()),this._pk}originate(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapOriginateParamsToWalletParams(()=>this.context.parser.prepareCodeOrigination({...t})),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createOriginationOperation(r)})}setDelegate(t){const e=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.delegate,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapDelegateParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createDelegationOperation(r)})}async signFailingNoop(t){const e={kind:i.OpKind.FAILING_NOOP,arbitrary:t.arbitrary},r=await this.context.readProvider.getBlockHash(t.basedOnBlock),n=await this.context.forger.forge({branch:r,contents:[e]});return{signature:await this.walletProvider.sign(n,Uint8Array.from([3])),bytes:n,signedContent:{branch:r,contents:[{kind:i.OpKind.FAILING_NOOP,arbitrary:t.arbitrary}]}}}registerDelegate(){return this.walletCommand(async()=>{const t=await this.walletProvider.mapDelegateParamsToWalletParams(async()=>({delegate:await this.pkh()})),e=await this.walletProvider.sendOperations([t]);return this.context.operationFactory.createDelegationOperation(e)})}transfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.to,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapTransferParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransactionOperation(r)})}transferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapTransferTicketParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransferTicketOperation(r)})}stake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapStakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.to!==e)throw new s.InvalidStakingAddressError(t.to);return t.parameter={entrypoint:"stake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransactionOperation(r)})}unstake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapUnstakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.to!==e)throw new s.InvalidStakingAddressError(t.to);return t.parameter={entrypoint:"unstake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return await this.context.operationFactory.createTransactionOperation(r)})}finalizeUnstake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapFinalizeUnstakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.amount||(t.amount=0),0!==t.amount)throw new s.InvalidFinalizeUnstakeAmountError("Amount must be 0 to finalize unstake.");return t.parameter={entrypoint:"finalize_unstake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return await this.context.operationFactory.createTransactionOperation(r)})}increasePaidStorage(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapIncreasePaidStorageWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createIncreasePaidStorageOperation(r)})}registerGlobalConstant(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapRegisterGlobalConstantParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createRegisterGlobalConstantOperation(r)})}batch(t){const e=new c(this.walletProvider,this.context);return Array.isArray(t)&&e.with(t),e}async at(t,e=t=>t,r="head"){const i=(0,o.validateContractAddress)(t);if(i!==o.ValidationResult.VALID)throw new s.InvalidContractAddressError(t,i);const c=this.context.withExtensions().rpc,u=this.context.withExtensions().readProvider,l=async e=>({script:await u.getScript(t,e),entrypoints:"head"===e?await u.getEntrypoints(t):await c.getEntrypoints(t,{block:String(e)})});let h;try{h=await l(r)}catch(t){if("head"===r||!(0,a.isNotFoundError)(t))throw t;h=await(0,a.retryOnNotFound)(()=>l("head"))}return e(new n.ContractAbstraction(t,h.script,this,this.context.contract,h.entrypoints,c,u,"head"),this.context)}async atExactBlock(t,e=t=>t,r){const i=(0,o.validateContractAddress)(t);if(i!==o.ValidationResult.VALID)throw new s.InvalidContractAddressError(t,i);const a=this.context.withExtensions().rpc,c=this.context.withExtensions().readProvider,u=await c.getScript(t,r),l=await a.getEntrypoints(t,{block:String(r)});return e(new n.ContractAbstraction(t,u,this,this.context.contract,l,a,c,r),this.context)}}},5423(){},8379(){},8552(t,e,r){"use strict";r.d(e,{s:()=>i});var n=r(5603);function i(t,e){const r=e=>(0,n.x3)({...t,hash:e});return{...r(e),create:r}}},3556(t,e,r){"use strict";r.d(e,{Ak:()=>c,UT:()=>_,Xf:()=>w,fH:()=>v,hT:()=>b,u0:()=>a});var n=r(1633),i=r(6681);const s=BigInt(0),o=BigInt(1);function a(t,e){const r=e.negate();return t?r:e}function c(t,e){const r=(0,i.pS)(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function u(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function l(t,e){u(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:(0,n.OG)(t),maxNumber:r,shiftBy:BigInt(t)}}function h(t,e,r){const{windowSize:n,mask:i,maxNumber:s,shiftBy:a}=r;let c=Number(t&i),u=t>>a;c>n&&(c-=s,u+=o);const l=e*n;return{nextN:u,offset:l+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:e%2!=0,offsetF:l}}function f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function d(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const p=new WeakMap,g=new WeakMap;function m(t){return g.get(t)||1}function y(t){if(t!==s)throw new Error("invalid wNAF")}class b{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>s;)e&o&&(r=r.add(n)),n=n.double(),e>>=o;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=l(e,this.bits),i=[];let s=t,o=s;for(let t=0;t<r;t++){o=s,i.push(o);for(let t=1;t<n;t++)o=o.add(s),i.push(o);s=o.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const s=l(t,this.bits);for(let t=0;t<s.windows;t++){const{nextN:o,offset:c,isZero:u,isNeg:l,isNegF:f,offsetF:d}=h(r,t,s);r=o,u?i=i.add(a(f,e[d])):n=n.add(a(l,e[c]))}return y(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=l(t,this.bits);for(let t=0;t<i.windows&&r!==s;t++){const{nextN:s,offset:o,isZero:a,isNeg:c}=h(r,t,i);if(r=s,!a){const t=e[o];n=n.add(c?t.negate():t)}}return y(r),n}getPrecomputes(t,e,r){let n=p.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),p.set(e,n))),n}cached(t,e,r){const n=m(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=m(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){u(e,this.bits),g.set(t,e),p.delete(t)}hasCache(t){return 1!==m(t)}}function v(t,e,r,n){let i=e,a=t.ZERO,c=t.ZERO;for(;r>s||n>s;)r&o&&(a=a.add(i)),n&o&&(c=c.add(i)),i=i.double(),r>>=o,n>>=o;return{p1:a,p2:c}}function w(t,e,r,i){f(r,t),d(i,e);const s=r.length,o=i.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const a=t.ZERO,c=(0,n.dJ)(BigInt(s));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const l=(0,n.OG)(u),h=new Array(Number(l)+1).fill(a);let p=a;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){h.fill(a);for(let e=0;e<o;e++){const n=i[e],s=Number(n>>BigInt(t)&l);h[s]=h[s].add(r[e])}let e=a;for(let t=h.length-1,r=a;t>0;t--)r=r.add(h[t]),e=e.add(r);if(p=p.add(e),0!==t)for(let t=0;t<u;t++)p=p.double()}return p}function E(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,i.jr)(e),e}return(0,i.D0)(t,{isLE:r})}function _(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>s))throw new Error(`CURVE.${t} must be positive bigint`)}const i=E(e.p,r.Fp,n),o=E(e.n,r.Fn,n),a=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of a)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:o}}},9991(t,e,r){"use strict";r.d(e,{FL:()=>d,Tq:()=>h,qX:()=>p,qj:()=>g});var n=r(1633),i=r(36),s=r(6681);const o=n.Ph;function a(t,e){if(u(t),u(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function c(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function u(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function l(t){if(!(0,i.aY)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,i.AI)(t):t}function h(t,e,r,n){(0,i.DO)(t),u(r),(e=l(e)).length>255&&(e=n((0,i.Id)((0,i.AI)("H2C-OVERSIZE-DST-"),e)));const{outputLen:s,blockLen:o}=n,h=Math.ceil(r/s);if(r>65535||h>255)throw new Error("expand_message_xmd: invalid lenInBytes");const f=(0,i.Id)(e,a(e.length,1)),d=a(0,o),p=a(r,2),g=new Array(h),m=n((0,i.Id)(d,t,p,a(0,1),f));g[0]=n((0,i.Id)(m,a(1,1),f));for(let t=1;t<=h;t++){const e=[c(m,g[t-1]),a(t+1,1),f];g[t]=n((0,i.Id)(...e))}return(0,i.Id)(...g).slice(0,r)}function f(t,e,r){(0,n.DS)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:c,k:f,m:d,hash:p,expand:g,DST:m}=r;if(!(0,n.jN)(r.hash))throw new Error("expected valid hash");(0,i.DO)(t),u(e);const y=c.toString(2).length,b=Math.ceil((y+f)/8),v=e*d*b;let w;if("xmd"===g)w=h(t,m,v,p);else if("xof"===g)w=function(t,e,r,n,s){if((0,i.DO)(t),u(r),(e=l(e)).length>255){const t=Math.ceil(2*n/8);e=s.create({dkLen:t}).update((0,i.AI)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}(t,m,v,f,p);else{if("_internal_pass"!==g)throw new Error('expand must be "xmd" or "xof"');w=t}const E=new Array(e);for(let t=0;t<e;t++){const e=new Array(d);for(let r=0;r<d;r++){const n=b*(r+t*d),i=w.subarray(n,n+b);e[r]=(0,s.zi)(o(i),c)}E[t]=e}return E}function d(t,e){const r=e.map(t=>Array.from(t).reverse());return(e,n)=>{const[i,o,a,c]=r.map(r=>r.reduce((r,n)=>t.add(t.mul(r,e),n))),[u,l]=(0,s.pS)(t,[o,c],!0);return e=t.mul(i,u),n=t.mul(n,t.mul(a,l)),{x:e,y:n}}}const p=(0,i.AI)("HashToScalar-");function g(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");function n(r){return t.fromAffine(e(r))}function i(e){const r=e.clearCofactor();return r.equals(t.ZERO)?t.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(t,e){const s=f(t,2,Object.assign({},r,e)),o=n(s[0]),a=n(s[1]);return i(o.add(a))},encodeToCurve(t,e){const s=r.encodeDST?{DST:r.encodeDST}:{};return i(n(f(t,1,Object.assign({},r,s,e))[0]))},mapToCurve(t){if(!Array.isArray(t))throw new Error("expected array of bigints");for(const e of t)if("bigint"!=typeof e)throw new Error("expected array of bigints");return i(n(t))},hashToScalar(e,n){const i=t.Fn.ORDER;return f(e,1,Object.assign({},r,{p:i,m:1,DST:p},n))[0][0]}}}},6681(t,e,r){"use strict";r.d(e,{D0:()=>I,LH:()=>x,Tp:()=>k,dQ:()=>A,f4:()=>T,jr:()=>S,pS:()=>P,qy:()=>L,tB:()=>R,zH:()=>m,zi:()=>g});var n=r(1633),i=r(36);const s=BigInt(0),o=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(4),l=BigInt(5),h=BigInt(7),f=BigInt(8),d=BigInt(9),p=BigInt(16);function g(t,e){const r=t%e;return r>=s?r:e+r}function m(t,e,r){let n=t;for(;e-- >s;)n*=n,n%=r;return n}function y(t,e){if(t===s)throw new Error("invert: expected non-zero number");if(e<=s)throw new Error("invert: expected positive modulus, got "+e);let r=g(t,e),n=e,i=s,a=o,c=o,u=s;for(;r!==s;){const t=n/r,e=n%r,s=i-c*t,o=a-u*t;n=r,r=e,i=c,a=u,c=s,u=o}if(n!==o)throw new Error("invert: does not exist");return g(i,e)}function b(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function v(t,e){const r=(t.ORDER+o)/u,n=t.pow(e,r);return b(t,n,e),n}function w(t,e){const r=(t.ORDER-l)/f,n=t.mul(e,a),i=t.pow(n,r),s=t.mul(e,i),o=t.mul(t.mul(s,a),i),c=t.mul(s,t.sub(o,t.ONE));return b(t,c,e),c}function E(t){if(t<c)throw new Error("sqrt is not defined for small field");let e=t-o,r=0;for(;e%a===s;)e/=a,r++;let n=a;const i=I(t);for(;1===R(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return v;let u=i.pow(n,e);const l=(e+o)/a;return function(t,n){if(t.is0(n))return n;if(1!==R(t,n))throw new Error("Cannot find square root");let i=r,s=t.mul(t.ONE,u),a=t.pow(n,e),c=t.pow(n,l);for(;!t.eql(a,t.ONE);){if(t.is0(a))return t.ZERO;let e=1,r=t.sqr(a);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=o<<BigInt(i-e-1),u=t.pow(s,n);i=e,s=t.sqr(u),a=t.mul(a,s),c=t.mul(c,u)}return c}}function _(t){return t%u===c?v:t%f===l?w:t%p===d?function(t){const e=I(t),r=E(t),n=r(e,e.neg(e.ONE)),i=r(e,n),s=r(e,e.neg(n)),o=(t+h)/p;return(t,e)=>{let r=t.pow(e,o),a=t.mul(r,n);const c=t.mul(r,i),u=t.mul(r,s),l=t.eql(t.sqr(a),e),h=t.eql(t.sqr(c),e);r=t.cmov(r,a,l),a=t.cmov(u,c,h);const f=t.eql(t.sqr(a),e),d=t.cmov(r,a,f);return b(t,d,e),d}}(t):E(t)}const A=(t,e)=>(g(t,e)&o)===o,O=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function S(t){const e=O.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,n.DS)(t,e),t}function T(t,e,r){if(r<s)throw new Error("invalid exponent, negatives unsupported");if(r===s)return t.ONE;if(r===o)return e;let n=t.ONE,i=e;for(;r>s;)r&o&&(n=t.mul(n,i)),i=t.sqr(i),r>>=o;return n}function P(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),s=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),s),n}function R(t,e){const r=(t.ORDER-o)/a,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),c=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function x(t,e){void 0!==e&&(0,i.Fe)(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function I(t,e,r=!1,i={}){if(t<=s)throw new Error("invalid field: expected ORDER > 0, got "+t);let a,c,u,l=!1;if("object"==typeof e&&null!=e){if(i.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(a=t.BITS),t.sqrt&&(c=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(l=t.modFromBytes),u=t.allowedLengths}else"number"==typeof e&&(a=e),i.sqrt&&(c=i.sqrt);const{nBitLength:h,nByteLength:f}=x(t,a);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const p=Object.freeze({ORDER:t,isLE:r,BITS:h,BYTES:f,MASK:(0,n.OG)(h),ZERO:s,ONE:o,allowedLengths:u,create:e=>g(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return s<=e&&e<t},is0:t=>t===s,isValidNot0:t=>!p.is0(t)&&p.isValid(t),isOdd:t=>(t&o)===o,neg:e=>g(-e,t),eql:(t,e)=>t===e,sqr:e=>g(e*e,t),add:(e,r)=>g(e+r,t),sub:(e,r)=>g(e-r,t),mul:(e,r)=>g(e*r,t),pow:(t,e)=>T(p,t,e),div:(e,r)=>g(e*y(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>y(e,t),sqrt:c||(e=>(d||(d=_(t)),d(p,e))),toBytes:t=>r?(0,n.z)(t,f):(0,n.lq)(t,f),fromBytes:(e,i=!0)=>{if(u){if(!u.includes(e.length)||e.length>f)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+e.length);const t=new Uint8Array(f);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==f)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+e.length);let s=r?(0,n.lX)(e):(0,n.Ph)(e);if(l&&(s=g(s,t)),!i&&!p.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:t=>P(p,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(p)}function N(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function k(t){const e=N(t);return e+Math.ceil(e/2)}function L(t,e,r=!1){const i=t.length,s=N(e),a=k(e);if(i<16||i<a||i>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+i);const c=g(r?(0,n.lX)(t):(0,n.Ph)(t),e-o)+o;return r?(0,n.z)(c,s):(0,n.lq)(c,s)}},5603(t,e,r){"use strict";r.d(e,{y6:()=>v,Is:()=>_,x3:()=>P,gx:()=>S});var n=r(36);class i extends n.Vw{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.sd)(t);const r=(0,n.ZJ)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),(0,n.uH)(s)}update(t){return(0,n.CC)(this),this.iHash.update(t),this}digestInto(t){(0,n.CC)(this),(0,n.DO)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const s=(t,e,r)=>new i(t,e).update(r).digest();s.create=(t,e)=>new i(t,e);var o=r(1633),a=r(3556),c=r(6681);const u=(t,e)=>(t+(t>=0?e:-e)/m)/e;function l(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function h(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return(0,o.d6)(r.lowS,"lowS"),(0,o.d6)(r.prehash,"prehash"),void 0!==r.format&&l(r.format),r}class f extends Error{constructor(t=""){super(t)}}const d={Err:f,_tlv:{encode:(t,e)=>{const{Err:r}=d;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=(0,o.zW)(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?(0,o.zW)(i.length/2|128):"";return(0,o.zW)(t)+s+i+e},decode(t,e){const{Err:r}=d;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++];let s=0;if(!!(128&i)){const t=127&i;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const o=e.subarray(n,n+t);if(o.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of o)s=s<<8|t;if(n+=t,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=i;const o=e.subarray(n,n+s);if(o.length!==s)throw new r("tlv.decode: wrong value length");return{v:o,l:e.subarray(n+s)}}},_int:{encode(t){const{Err:e}=d;if(t<p)throw new e("integer: negative integers are not allowed");let r=(0,o.zW)(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=d;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return(0,o.Ph)(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=d,i=(0,o.qj)("signature",t),{v:s,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:u}=n.decode(2,s),{v:l,l:h}=n.decode(2,u);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(t){const{_tlv:e,_int:r}=d,n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},p=BigInt(0),g=BigInt(1),m=BigInt(2),y=BigInt(3),b=BigInt(4);function v(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=(0,o.qj)("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function w(t,e={}){const r=(0,a.UT)("weierstrass",t,e),{Fp:i,Fn:s}=r;let c=r.CURVE;const{h:l,n:h}=c;(0,o.DS)(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=e;if(f&&(!i.is0(c.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=A(i,s);function m(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const w=e.toBytes||function(t,e,r){const{x:s,y:a}=e.toAffine(),c=i.toBytes(s);if((0,o.d6)(r,"isCompressed"),r){m();const t=!i.isOdd(a);return(0,n.Id)(E(t),c)}return(0,n.Id)(Uint8Array.of(4),c,i.toBytes(a))},_=e.fromBytes||function(t){(0,o.eV)(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=d,n=t.length,s=t[0],a=t.subarray(1);if(n!==e||2!==s&&3!==s){if(n===r&&4===s){const t=i.BYTES,e=i.fromBytes(a.subarray(0,t)),r=i.fromBytes(a.subarray(t,2*t));if(!S(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${n}, expected compressed=${e} or uncompressed=${r}`)}{const t=i.fromBytes(a);if(!i.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=O(t);let r;try{r=i.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}m();return!(1&~s)!==i.isOdd(r)&&(r=i.neg(r)),{x:t,y:r}}};function O(t){const e=i.sqr(t),r=i.mul(e,t);return i.add(i.add(r,i.mul(t,c.a)),c.b)}function S(t,e){const r=i.sqr(e),n=O(t);return i.eql(r,n)}if(!S(c.Gx,c.Gy))throw new Error("bad curve params: generator point");const T=i.mul(i.pow(c.a,y),b),P=i.mul(i.sqr(c.b),BigInt(27));if(i.is0(i.add(T,P)))throw new Error("bad curve params: a or b");function R(t,e,r=!1){if(!i.isValid(e)||r&&i.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function x(t){if(!(t instanceof C))throw new Error("ProjectivePoint expected")}function I(t){if(!f||!f.basises)throw new Error("no endo");return function(t,e,r){const[[n,i],[s,a]]=e,c=u(a*t,r),l=u(-i*t,r);let h=t-c*n-l*s,f=-c*i-l*a;const d=h<p,m=f<p;d&&(h=-h),m&&(f=-f);const y=(0,o.OG)(Math.ceil((0,o.dJ)(r)/2))+g;if(h<p||h>=y||f<p||f>=y)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:h,k2neg:m,k2:f}}(t,f.basises,s.ORDER)}const N=(0,o.x)((t,e)=>{const{X:r,Y:n,Z:s}=t;if(i.eql(s,i.ONE))return{x:r,y:n};const o=t.is0();null==e&&(e=o?i.ONE:i.inv(s));const a=i.mul(r,e),c=i.mul(n,e),u=i.mul(s,e);if(o)return{x:i.ZERO,y:i.ZERO};if(!i.eql(u,i.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),k=(0,o.x)(t=>{if(t.is0()){if(e.allowInfinityPoint&&!i.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:n}=t.toAffine();if(!i.isValid(r)||!i.isValid(n))throw new Error("bad point: x or y not field elements");if(!S(r,n))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(t,e,r,n,s){return r=new C(i.mul(r.X,t),r.Y,r.Z),e=(0,a.u0)(n,e),r=(0,a.u0)(s,r),e.add(r)}class C{constructor(t,e,r){this.X=R("x",t),this.Y=R("y",e,!0),this.Z=R("z",r),Object.freeze(this)}static CURVE(){return c}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!i.isValid(e)||!i.isValid(r))throw new Error("invalid affine point");if(t instanceof C)throw new Error("projective point not allowed");return i.is0(e)&&i.is0(r)?C.ZERO:new C(e,r,i.ONE)}static fromBytes(t){const e=C.fromAffine(_((0,o.eV)(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return C.fromBytes((0,o.qj)("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return B.createCache(this,t),e||this.multiply(y),this}assertValidity(){k(this)}hasEvenY(){const{y:t}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(t)}equals(t){x(t);const{X:e,Y:r,Z:n}=this,{X:s,Y:o,Z:a}=t,c=i.eql(i.mul(e,a),i.mul(s,n)),u=i.eql(i.mul(r,a),i.mul(o,n));return c&&u}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:t,b:e}=c,r=i.mul(e,y),{X:n,Y:s,Z:o}=this;let a=i.ZERO,u=i.ZERO,l=i.ZERO,h=i.mul(n,n),f=i.mul(s,s),d=i.mul(o,o),p=i.mul(n,s);return p=i.add(p,p),l=i.mul(n,o),l=i.add(l,l),a=i.mul(t,l),u=i.mul(r,d),u=i.add(a,u),a=i.sub(f,u),u=i.add(f,u),u=i.mul(a,u),a=i.mul(p,a),l=i.mul(r,l),d=i.mul(t,d),p=i.sub(h,d),p=i.mul(t,p),p=i.add(p,l),l=i.add(h,h),h=i.add(l,h),h=i.add(h,d),h=i.mul(h,p),u=i.add(u,h),d=i.mul(s,o),d=i.add(d,d),h=i.mul(d,p),a=i.sub(a,h),l=i.mul(d,f),l=i.add(l,l),l=i.add(l,l),new C(a,u,l)}add(t){x(t);const{X:e,Y:r,Z:n}=this,{X:s,Y:o,Z:a}=t;let u=i.ZERO,l=i.ZERO,h=i.ZERO;const f=c.a,d=i.mul(c.b,y);let p=i.mul(e,s),g=i.mul(r,o),m=i.mul(n,a),b=i.add(e,r),v=i.add(s,o);b=i.mul(b,v),v=i.add(p,g),b=i.sub(b,v),v=i.add(e,n);let w=i.add(s,a);return v=i.mul(v,w),w=i.add(p,m),v=i.sub(v,w),w=i.add(r,n),u=i.add(o,a),w=i.mul(w,u),u=i.add(g,m),w=i.sub(w,u),h=i.mul(f,v),u=i.mul(d,m),h=i.add(u,h),u=i.sub(g,h),h=i.add(g,h),l=i.mul(u,h),g=i.add(p,p),g=i.add(g,p),m=i.mul(f,m),v=i.mul(d,v),g=i.add(g,m),m=i.sub(p,m),m=i.mul(f,m),v=i.add(v,m),p=i.mul(g,v),l=i.add(l,p),p=i.mul(w,v),u=i.mul(b,u),u=i.sub(u,p),p=i.mul(b,g),h=i.mul(w,h),h=i.add(h,p),new C(u,l,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(C.ZERO)}multiply(t){const{endo:r}=e;if(!s.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,i;const o=t=>B.cached(this,t,t=>(0,a.Ak)(C,t));if(r){const{k1neg:e,k1:s,k2neg:a,k2:c}=I(t),{p:u,f:l}=o(s),{p:h,f}=o(c);i=l.add(f),n=L(r.beta,u,h,e,a)}else{const{p:e,f:r}=o(t);n=e,i=r}return(0,a.Ak)(C,[n,i])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!s.isValid(t))throw new Error("invalid scalar: out of range");if(t===p||n.is0())return C.ZERO;if(t===g)return n;if(B.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:s,k2:o}=I(t),{p1:c,p2:u}=(0,a.fH)(C,n,i,o);return L(r.beta,c,u,e,s)}return B.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return N(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return l===g||(t?t(C,this):B.unsafe(this,h).is0())}clearCofactor(){const{clearCofactor:t}=e;return l===g?this:t?t(C,this):this.multiplyUnsafe(l)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}toBytes(t=!0){return(0,o.d6)(t,"isCompressed"),this.assertValidity(),w(C,this,t)}toHex(t=!0){return(0,n.My)(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return(0,a.Ak)(C,t)}static msm(t,e){return(0,a.Xf)(C,s,t,e)}static fromPrivateKey(t){return C.BASE.multiply(v(s,t))}}C.BASE=new C(c.Gx,c.Gy,i.ONE),C.ZERO=new C(i.ZERO,i.ONE,i.ZERO),C.Fp=i,C.Fn=s;const M=s.BITS,B=new a.hT(C,e.endo?Math.ceil(M/2):M);return C.BASE.precompute(8),C}function E(t){return Uint8Array.of(t?2:3)}function _(t,e){(0,c.jr)(t);const{A:r,B:n,Z:i}=e;if(!t.isValid(r)||!t.isValid(n)||!t.isValid(i))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=function(t,e){const r=t.ORDER;let n=p;for(let t=r-g;t%m===p;t/=m)n+=g;const i=n,s=m<<i-g-g,o=s*m,a=(r-g)/o,c=(a-g)/m,u=o-g,l=s,h=t.pow(e,a),f=t.pow(e,(a+g)/m);let d=(e,r)=>{let n=h,s=t.pow(r,u),o=t.sqr(s);o=t.mul(o,r);let a=t.mul(e,o);a=t.pow(a,c),a=t.mul(a,s),s=t.mul(a,r),o=t.mul(a,e);let d=t.mul(o,s);a=t.pow(d,l);let p=t.eql(a,t.ONE);s=t.mul(o,f),a=t.mul(d,n),o=t.cmov(s,o,p),d=t.cmov(a,d,p);for(let e=i;e>g;e--){let r=e-m;r=m<<r-g;let i=t.pow(d,r);const a=t.eql(i,t.ONE);s=t.mul(o,n),n=t.mul(n,n),i=t.mul(d,n),o=t.cmov(s,o,a),d=t.cmov(i,d,a)}return{isValid:p,value:o}};if(t.ORDER%b===y){const r=(t.ORDER-y)/b,n=t.sqrt(t.neg(e));d=(e,i)=>{let s=t.sqr(i);const o=t.mul(e,i);s=t.mul(s,o);let a=t.pow(s,r);a=t.mul(a,o);const c=t.mul(a,n),u=t.mul(t.sqr(a),i),l=t.eql(u,e);return{isValid:l,value:t.cmov(c,a,l)}}}return d}(t,i);if(!t.isOdd)throw new Error("Field does not have .isOdd()");return e=>{let o,a,u,l,h,f,d,p;o=t.sqr(e),o=t.mul(o,i),a=t.sqr(o),a=t.add(a,o),u=t.add(a,t.ONE),u=t.mul(u,n),l=t.cmov(i,t.neg(a),!t.eql(a,t.ZERO)),l=t.mul(l,r),a=t.sqr(u),f=t.sqr(l),h=t.mul(f,r),a=t.add(a,h),a=t.mul(a,u),f=t.mul(f,l),h=t.mul(f,n),a=t.add(a,h),d=t.mul(o,u);const{isValid:g,value:m}=s(a,f);p=t.mul(o,e),p=t.mul(p,m),d=t.cmov(d,u,g),p=t.cmov(p,m,g);const y=t.isOdd(e)===t.isOdd(p);p=t.cmov(t.neg(p),p,y);const b=(0,c.pS)(t,[l],!0)[0];return d=t.mul(d,b),{x:d,y:p}}}function A(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function O(t,e,r={}){(0,n.sd)(e),(0,o.DS)(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=r.randomBytes||n.po,a=r.hmac||((t,...r)=>s(e,t,(0,n.Id)(...r))),{Fp:u,Fn:f}=t,{ORDER:y,BITS:b}=f,{keygen:w,getPublicKey:_,getSharedSecret:O,utils:S,lengths:T}=function(t,e={}){const{Fn:r}=t,i=e.randomBytes||n.po,s=Object.assign(A(t.Fp,r),{seed:(0,c.Tp)(r.ORDER)});function a(t){try{return!!v(r,t)}catch(t){return!1}}function u(t=i(s.seed)){return(0,c.qy)((0,o.eV)(t,s.seed,"seed"),r.ORDER)}function l(e,n=!0){return t.BASE.multiply(v(r,e)).toBytes(n)}function h(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:i,publicKeyUncompressed:a}=s;if(r.allowedLengths||n===i)return;const c=(0,o.qj)("key",e).length;return c===i||c===a}const f={isValidSecretKey:a,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:i}=s;try{const s=e.length;return!(!0===r&&s!==n||!1===r&&s!==i||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:u,isValidPrivateKey:a,randomPrivateKey:u,normPrivateKeyToScalar:t=>v(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:l,getSharedSecret:function(e,n,i=!0){if(!0===h(e))throw new Error("first arg must be private key");if(!1===h(n))throw new Error("second arg must be public key");const s=v(r,e);return t.fromHex(n).multiply(s).toBytes(i)},keygen:function(t){const e=u(t);return{secretKey:e,publicKey:l(e)}},Point:t,utils:f,lengths:s})}(t,r),P={prehash:!1,lowS:"boolean"==typeof r.lowS&&r.lowS,format:void 0,extraEntropy:!1},R="compact";function x(t){return t>y>>g}function I(t,e){if(!f.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class N{constructor(t,e,r){this.r=I("r",t),this.s=I("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,e=R){let r;if(function(t,e){l(e);const r=T.signature,n="compact"===e?r:"recovered"===e?r+1:void 0;(0,o.eV)(t,n,`${e} signature`)}(t,e),"der"===e){const{r:e,s:r}=d.toSig((0,o.eV)(t));return new N(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=f.BYTES,i=t.subarray(0,n),s=t.subarray(n,2*n);return new N(f.fromBytes(i),f.fromBytes(s),r)}static fromHex(t,e){return this.fromBytes((0,n.aT)(t),e)}addRecoveryBit(t){return new N(this.r,this.s,t)}recoverPublicKey(e){const r=u.ORDER,{r:i,s,recovery:a}=this;if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");if(y*m<r&&a>1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===a||3===a?i+y:i;if(!u.isValid(c))throw new Error("recovery id 2 or 3 invalid");const l=u.toBytes(c),h=t.fromBytes((0,n.Id)(E(!(1&a)),l)),d=f.inv(c),p=L((0,o.qj)("msgHash",e)),g=f.create(-p*d),b=f.create(s*d),v=t.BASE.multiplyUnsafe(g).add(h.multiplyUnsafe(b));if(v.is0())throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return x(this.s)}toBytes(t=R){if(l(t),"der"===t)return(0,n.aT)(d.hexFromSig(this));const e=f.toBytes(this.r),r=f.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,n.Id)(Uint8Array.of(this.recovery),e,r)}return(0,n.Id)(e,r)}toHex(t){return(0,n.My)(this.toBytes(t))}assertValidity(){}static fromCompact(t){return N.fromBytes((0,o.qj)("sig",t),"compact")}static fromDER(t){return N.fromBytes((0,o.qj)("sig",t),"der")}normalizeS(){return this.hasHighS()?new N(this.r,f.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,n.My)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,n.My)(this.toBytes("compact"))}}const k=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=(0,o.Ph)(t),r=8*t.length-b;return r>0?e>>BigInt(r):e},L=r.bits2int_modN||function(t){return f.create(k(t))},C=(0,o.OG)(b);function M(t){return(0,o.aK)("num < 2^"+b,t,p,C),f.toBytes(t)}function B(t,r){return(0,o.eV)(t,void 0,"message"),r?(0,o.eV)(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:w,getPublicKey:_,getSharedSecret:O,utils:S,lengths:T,Point:t,sign:function(r,s,c={}){r=(0,o.qj)("message",r);const{seed:u,k2sig:l}=function(e,r,s){if(["recovered","canonical"].some(t=>t in s))throw new Error("sign() legacy options not supported");const{lowS:a,prehash:c,extraEntropy:u}=h(s,P);e=B(e,c);const l=L(e),d=v(f,r),m=[M(d),M(l)];if(null!=u&&!1!==u){const t=!0===u?i(T.secretKey):u;m.push((0,o.qj)("extraEntropy",t))}const y=(0,n.Id)(...m),b=l;return{seed:y,k2sig:function(e){const r=k(e);if(!f.isValidNot0(r))return;const n=f.inv(r),i=t.BASE.multiply(r).toAffine(),s=f.create(i.x);if(s===p)return;const o=f.create(n*f.create(b+s*d));if(o===p)return;let c=(i.x===s?0:2)|Number(i.y&g),u=o;return a&&x(o)&&(u=f.neg(o),c^=1),new N(s,u,c)}}}(r,s,c);return(0,o.fg)(e.outputLen,f.BYTES,a)(u,l)},verify:function(e,r,i,s={}){const{lowS:a,prehash:c,format:u}=h(s,P);if(i=(0,o.qj)("publicKey",i),r=B((0,o.qj)("message",r),c),"strict"in s)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(t){let e;const r="string"==typeof t||(0,n.aY)(t),i=!r&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!r&&!i)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(i)e=new N(t.r,t.s);else if(r){try{e=N.fromBytes((0,o.qj)("sig",t),"der")}catch(t){if(!(t instanceof d.Err))throw t}if(!e)try{e=N.fromBytes((0,o.qj)("sig",t),"compact")}catch(t){return!1}}return e||!1}(e):N.fromBytes((0,o.qj)("sig",e),u);if(!1===l)return!1;try{const e=t.fromBytes(i);if(a&&l.hasHighS())return!1;const{r:n,s}=l,o=L(r),c=f.inv(s),u=f.create(o*c),h=f.create(n*c),d=t.BASE.multiplyUnsafe(u).add(e.multiplyUnsafe(h));if(d.is0())return!1;return f.create(d.x)===n}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=h(r,P);return e=B(e,n),N.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:N,hash:e})}function S(t){const{CURVE:e,curveOpts:r}=T(t);return function(t,e){const{Fp:r,Fn:n}=e;function i(t){return(0,o.r4)(t,g,n.ORDER)}const s=function(t,e,r){function n(n){const i=t.sqr(n),s=t.mul(i,n);return t.add(t.add(s,t.mul(n,e)),r)}return n}(r,t.a,t.b);return Object.assign({},{CURVE:t,Point:e,ProjectivePoint:e,normPrivateKeyToScalar:t=>v(n,t),weierstrassEquation:s,isWithinCurveOrder:i})}(t,w(e,r))}function T(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:(0,c.D0)(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}function P(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=T(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,(0,c.LH)(r.Fn.ORDER,r.Fn.BITS))})}(t,O(w(e,r),n,i))}},1188(t,e,r){"use strict";r.d(e,{A:()=>Y});var n=r(733),i=r(1633),s=r(36),o=r(3556),a=r(9991),c=r(6681),u=r(5603);const l=BigInt(0),h=BigInt(1),f=BigInt(2),d=BigInt(3);function p(t){if(!Array.isArray(t)||0===t.length)throw new Error("expected non-empty array")}function g(t,e,r,n){const{Fp2:s,Fp12:a}=t,{twistType:c,ateLoopSize:u,xNegative:p,postPrecompute:g}=n;let m;if("multiplicative"===c)m=(t,e,r,n,i,o)=>a.mul014(n,t,s.mul(e,i),s.mul(r,o));else{if("divisive"!==c)throw new Error("bls: unknown twist type");m=(t,e,r,n,i,o)=>a.mul034(n,s.mul(r,o),s.mul(e,i),t)}const y=s.div(s.ONE,s.mul(s.ONE,f));function b(t,e,r,n){const i=s.sqr(r),o=s.sqr(n),a=s.mulByB(s.mul(o,d)),c=s.mul(a,d),u=s.sub(s.sub(s.sqr(s.add(r,n)),o),i),l=s.sub(a,i),h=s.mul(s.sqr(e),d),f=s.neg(u);return t.push([l,h,f]),{Rx:e=s.mul(s.mul(s.mul(s.sub(i,c),e),r),y),Ry:r=s.sub(s.sqr(s.mul(s.add(i,c),y)),s.mul(s.sqr(a),d)),Rz:n=s.mul(i,u)}}function v(t,e,r,n,i,o){const a=s.sub(r,s.mul(o,n)),c=s.sub(e,s.mul(i,n)),u=s.sub(s.mul(a,i),s.mul(c,o)),l=s.neg(a),h=c;t.push([u,l,h]);const d=s.sqr(c),p=s.mul(d,c),g=s.mul(d,e),m=s.add(s.sub(p,s.mul(g,f)),s.mul(s.sqr(a),n));return{Rx:e=s.mul(c,m),Ry:r=s.sub(s.mul(s.sub(g,m),a),s.mul(p,r)),Rz:n=s.mul(n,p)}}const w=function(t){const e=[];for(;t>h;t>>=h)(t&h)===l?e.unshift(0):(t&d)===d?(e.unshift(-1),t+=h):e.unshift(1);return e}(u),E=(0,i.x)(t=>{const e=t,{x:r,y:n}=e.toAffine(),i=r,o=n,a=s.neg(n);let c=i,u=o,l=s.ONE;const h=[];for(const t of w){const e=[];({Rx:c,Ry:u,Rz:l}=b(e,c,u,l)),t&&({Rx:c,Ry:u,Rz:l}=v(e,c,u,l,i,-1===t?a:o)),h.push(e)}if(g){const t=h[h.length-1];g(c,u,l,i,o,v.bind(null,t))}return h});function _(t,e=!1){let r=a.ONE;if(t.length){const e=t[0][0].length;for(let n=0;n<e;n++){r=a.sqr(r);for(const[e,i,s]of t)for(const[t,o,a]of e[n])r=m(t,o,a,r,i,s)}}return p&&(r=a.conjugate(r)),e?a.finalExponentiate(r):r}function A(t,n=!0){const i=[];(0,o.Ak)(e,t.map(({g1:t})=>t)),(0,o.Ak)(r,t.map(({g2:t})=>t));for(const{g1:e,g2:r}of t){if(e.is0()||r.is0())throw new Error("pairing is not available for ZERO point");e.assertValidity(),r.assertValidity();const t=e.toAffine();i.push([E(r),t.x,t.y])}return _(i,n)}return{Fp12:a,millerLoopBatch:_,pairing:function(t,e,r=!0){return A([{g1:t,g2:e}],r)},pairingBatch:A,calcPairingPrecomputes:E}}function m(t,e,r,n,i){const{Fp12:o,pairingBatch:a}=t;function c(t){return t instanceof e.Point?t:e.Point.fromHex(t)}function l(t){return t instanceof r.Point?t:r.Point.fromHex(t)}function h(t){if(!(t instanceof r.Point))throw new Error(`expected valid message hashed to ${i?"G1":"G2"} curve`);return t}const f=i?(t,e)=>({g1:e,g2:t}):(t,e)=>({g1:t,g2:e});return{getPublicKey(t){const r=(0,u.y6)(e.Point.Fn,t);return e.Point.BASE.multiply(r)},sign(t,r,n){if(null!=n)throw new Error("sign() expects 2 arguments");const i=(0,u.y6)(e.Point.Fn,r);return h(t).assertValidity(),t.multiply(i)},verify(t,r,n,i){if(null!=i)throw new Error("verify() expects 3 arguments");t=l(t);const s=(n=c(n)).negate(),u=e.Point.BASE,d=h(r),p=t,g=a([f(s,d),f(u,p)]);return o.eql(g,o.ONE)},verifyBatch(t,r,n){if(p(r),n.length!==r.length)throw new Error("amount of public keys and messages should be equal");const i=l(t),s=r,u=n.map(c),h=new Map;for(let t=0;t<u.length;t++){const e=u[t],r=s[t];let n=h.get(r);void 0===n&&(n=[],h.set(r,n)),n.push(e)}const d=[],g=e.Point.BASE;try{for(const[t,e]of h){const r=e.reduce((t,e)=>t.add(e));d.push(f(r,t))}return d.push(f(g.negate(),i)),o.eql(a(d),o.ONE)}catch{return!1}},aggregatePublicKeys(t){p(t);const r=(t=t.map(t=>c(t))).reduce((t,e)=>t.add(e),e.Point.ZERO);return r.assertValidity(),r},aggregateSignatures(t){p(t);const e=(t=t.map(t=>l(t))).reduce((t,e)=>t.add(e),r.Point.ZERO);return e.assertValidity(),e},hash(t,e){(0,s.DO)(t);const n=e?{DST:e}:void 0;return r.hashToCurve(t,n)},Signature:n}}const y=BigInt(0),b=BigInt(1),v=BigInt(2),w=BigInt(3);function E(t,e,r,n,i=1,s){const o=BigInt(void 0===s?n:s),a=r**BigInt(n),c=[];for(let s=0;s<i;s++){const i=BigInt(s+1),u=[];for(let s=0,c=b;s<n;s++){const n=(i*c-i)/o%a;u.push(t.pow(e,n)),c*=r}c.push(u)}return c}const _=(t,e)=>{if(2!==e.length)throw new Error("invalid tuple");const r=e.map(e=>t.create(e));return{c0:r[0],c1:r[1]}};class A{constructor(t,e={}){this.MASK=b;const r=t.ORDER,n=r*r;this.Fp=t,this.ORDER=n,this.BITS=(0,i.dJ)(n),this.BYTES=Math.ceil((0,i.dJ)(n)/8),this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO},this.Fp_NONRESIDUE=t.create(e.NONRESIDUE||BigInt(-1)),this.Fp_div2=t.div(t.ONE,v),this.NONRESIDUE=_(t,e.FP2_NONRESIDUE),this.FROBENIUS_COEFFICIENTS=E(t,this.Fp_NONRESIDUE,t.ORDER,2)[0],this.mulByB=e.Fp2mulByB,Object.seal(this)}fromBigTuple(t){return _(this.Fp,t)}create(t){return t}isValid({c0:t,c1:e}){function r(t,e){return"bigint"==typeof t&&y<=t&&t<e}return r(t,this.ORDER)&&r(e,this.ORDER)}is0({c0:t,c1:e}){return this.Fp.is0(t)&&this.Fp.is0(e)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}eql({c0:t,c1:e},{c0:r,c1:n}){return this.Fp.eql(t,r)&&this.Fp.eql(e,n)}neg({c0:t,c1:e}){return{c0:this.Fp.neg(t),c1:this.Fp.neg(e)}}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}add(t,e){const{c0:r,c1:n}=t,{c0:i,c1:s}=e;return{c0:this.Fp.add(r,i),c1:this.Fp.add(n,s)}}sub({c0:t,c1:e},{c0:r,c1:n}){return{c0:this.Fp.sub(t,r),c1:this.Fp.sub(e,n)}}mul({c0:t,c1:e},r){const{Fp:n}=this;if("bigint"==typeof r)return{c0:n.mul(t,r),c1:n.mul(e,r)};const{c0:i,c1:s}=r;let o=n.mul(t,i),a=n.mul(e,s);return{c0:n.sub(o,a),c1:n.sub(n.mul(n.add(t,e),n.add(i,s)),n.add(o,a))}}sqr({c0:t,c1:e}){const{Fp:r}=this,n=r.add(t,e),i=r.sub(t,e),s=r.add(t,t);return{c0:r.mul(n,i),c1:r.mul(s,e)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}div(t,e){const{Fp:r}=this;return this.mul(t,"bigint"==typeof e?r.inv(r.create(e)):this.inv(e))}inv({c0:t,c1:e}){const{Fp:r}=this,n=r.inv(r.create(t*t+e*e));return{c0:r.mul(n,r.create(t)),c1:r.mul(n,r.create(-e))}}sqrt(t){const{Fp:e}=this,r=this,{c0:n,c1:i}=t;if(e.is0(i))return 1===c.tB(e,n)?r.create({c0:e.sqrt(n),c1:e.ZERO}):r.create({c0:e.ZERO,c1:e.sqrt(e.div(n,this.Fp_NONRESIDUE))});const s=e.sqrt(e.sub(e.sqr(n),e.mul(e.sqr(i),this.Fp_NONRESIDUE)));let o=e.mul(e.add(s,n),this.Fp_div2);-1===c.tB(e,o)&&(o=e.sub(o,s));const a=e.sqrt(o),u=r.create({c0:a,c1:e.div(e.mul(i,this.Fp_div2),a)});if(!r.eql(r.sqr(u),t))throw new Error("Cannot find square root");const l=u,h=r.neg(l),{re:f,im:d}=r.reim(l),{re:p,im:g}=r.reim(h);return d>g||d===g&&f>p?l:h}isOdd(t){const{re:e,im:r}=this.reim(t);return BigInt(e%v||e===y&&r%v)==b}fromBytes(t){const{Fp:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);return{c0:e.fromBytes(t.subarray(0,e.BYTES)),c1:e.fromBytes(t.subarray(e.BYTES))}}toBytes({c0:t,c1:e}){return(0,s.Id)(this.Fp.toBytes(t),this.Fp.toBytes(e))}cmov({c0:t,c1:e},{c0:r,c1:n},i){return{c0:this.Fp.cmov(t,r,i),c1:this.Fp.cmov(e,n,i)}}reim({c0:t,c1:e}){return{re:t,im:e}}Fp4Square(t,e){const r=this,n=r.sqr(t),i=r.sqr(e);return{first:r.add(r.mulByNonresidue(i),n),second:r.sub(r.sub(r.sqr(r.add(t,e)),n),i)}}mulByNonresidue({c0:t,c1:e}){return this.mul({c0:t,c1:e},this.NONRESIDUE)}frobeniusMap({c0:t,c1:e},r){return{c0:t,c1:this.Fp.mul(e,this.FROBENIUS_COEFFICIENTS[r%2])}}}class O{constructor(t){this.MASK=b,this.Fp2=t,this.ORDER=t.ORDER,this.BITS=3*t.BITS,this.BYTES=3*t.BYTES,this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO,c2:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO,c2:t.ZERO};const{Fp:e}=t,r=E(t,t.NONRESIDUE,e.ORDER,6,2,3);this.FROBENIUS_COEFFICIENTS_1=r[0],this.FROBENIUS_COEFFICIENTS_2=r[1],Object.seal(this)}add({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return{c0:o.add(t,n),c1:o.add(e,i),c2:o.add(r,s)}}sub({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return{c0:o.sub(t,n),c1:o.sub(e,i),c2:o.sub(r,s)}}mul({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;if("bigint"==typeof n)return{c0:i.mul(t,n),c1:i.mul(e,n),c2:i.mul(r,n)};const{c0:s,c1:o,c2:a}=n,c=i.mul(t,s),u=i.mul(e,o),l=i.mul(r,a);return{c0:i.add(c,i.mulByNonresidue(i.sub(i.mul(i.add(e,r),i.add(o,a)),i.add(u,l)))),c1:i.add(i.sub(i.mul(i.add(t,e),i.add(s,o)),i.add(c,u)),i.mulByNonresidue(l)),c2:i.sub(i.add(u,i.mul(i.add(t,r),i.add(s,a))),i.add(c,l))}}sqr({c0:t,c1:e,c2:r}){const{Fp2:n}=this;let i=n.sqr(t),s=n.mul(n.mul(t,e),v),o=n.mul(n.mul(e,r),v),a=n.sqr(r);return{c0:n.add(n.mulByNonresidue(o),i),c1:n.add(n.mulByNonresidue(a),s),c2:n.sub(n.sub(n.add(n.add(s,n.sqr(n.add(n.sub(t,e),r))),o),i),a)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}create(t){return t}isValid({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return n.isValid(t)&&n.isValid(e)&&n.isValid(r)}is0({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return n.is0(t)&&n.is0(e)&&n.is0(r)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}neg({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return{c0:n.neg(t),c1:n.neg(e),c2:n.neg(r)}}eql({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return o.eql(t,n)&&o.eql(e,i)&&o.eql(r,s)}sqrt(t){return(0,i.SJ)()}div(t,e){const{Fp2:r}=this,{Fp:n}=r;return this.mul(t,"bigint"==typeof e?n.inv(n.create(e)):this.inv(e))}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}inv({c0:t,c1:e,c2:r}){const{Fp2:n}=this;let i=n.sub(n.sqr(t),n.mulByNonresidue(n.mul(r,e))),s=n.sub(n.mulByNonresidue(n.sqr(r)),n.mul(t,e)),o=n.sub(n.sqr(e),n.mul(t,r)),a=n.inv(n.add(n.mulByNonresidue(n.add(n.mul(r,s),n.mul(e,o))),n.mul(t,i)));return{c0:n.mul(a,i),c1:n.mul(a,s),c2:n.mul(a,o)}}fromBytes(t){const{Fp2:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);const r=e.BYTES;return{c0:e.fromBytes(t.subarray(0,r)),c1:e.fromBytes(t.subarray(r,2*r)),c2:e.fromBytes(t.subarray(2*r))}}toBytes({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return(0,s.Id)(n.toBytes(t),n.toBytes(e),n.toBytes(r))}cmov({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o){const{Fp2:a}=this;return{c0:a.cmov(t,n,o),c1:a.cmov(e,i,o),c2:a.cmov(r,s,o)}}fromBigSix(t){const{Fp2:e}=this;if(!Array.isArray(t)||6!==t.length)throw new Error("invalid Fp6 usage");return{c0:e.fromBigTuple(t.slice(0,2)),c1:e.fromBigTuple(t.slice(2,4)),c2:e.fromBigTuple(t.slice(4,6))}}frobeniusMap({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.frobeniusMap(t,n),c1:i.mul(i.frobeniusMap(e,n),this.FROBENIUS_COEFFICIENTS_1[n%6]),c2:i.mul(i.frobeniusMap(r,n),this.FROBENIUS_COEFFICIENTS_2[n%6])}}mulByFp2({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.mul(t,n),c1:i.mul(e,n),c2:i.mul(r,n)}}mulByNonresidue({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return{c0:n.mulByNonresidue(r),c1:t,c2:e}}mul1({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.mulByNonresidue(i.mul(r,n)),c1:i.mul(t,n),c2:i.mul(e,n)}}mul01({c0:t,c1:e,c2:r},n,i){const{Fp2:s}=this;let o=s.mul(t,n),a=s.mul(e,i);return{c0:s.add(s.mulByNonresidue(s.sub(s.mul(s.add(e,r),i),a)),o),c1:s.sub(s.sub(s.mul(s.add(n,i),s.add(t,e)),o),a),c2:s.add(s.sub(s.mul(s.add(t,r),n),o),a)}}}class S{constructor(t,e){this.MASK=b;const{Fp2:r}=t,{Fp:n}=r;this.Fp6=t,this.ORDER=r.ORDER,this.BITS=2*t.BITS,this.BYTES=2*t.BYTES,this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO},this.FROBENIUS_COEFFICIENTS=E(r,r.NONRESIDUE,n.ORDER,12,1,6)[0],this.X_LEN=e.X_LEN,this.finalExponentiate=e.Fp12finalExponentiate}create(t){return t}isValid({c0:t,c1:e}){const{Fp6:r}=this;return r.isValid(t)&&r.isValid(e)}is0({c0:t,c1:e}){const{Fp6:r}=this;return r.is0(t)&&r.is0(e)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}neg({c0:t,c1:e}){const{Fp6:r}=this;return{c0:r.neg(t),c1:r.neg(e)}}eql({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return i.eql(t,r)&&i.eql(e,n)}sqrt(t){(0,i.SJ)()}inv({c0:t,c1:e}){const{Fp6:r}=this;let n=r.inv(r.sub(r.sqr(t),r.mulByNonresidue(r.sqr(e))));return{c0:r.mul(t,n),c1:r.neg(r.mul(e,n))}}div(t,e){const{Fp6:r}=this,{Fp2:n}=r,{Fp:i}=n;return this.mul(t,"bigint"==typeof e?i.inv(i.create(e)):this.inv(e))}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}add({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return{c0:i.add(t,r),c1:i.add(e,n)}}sub({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return{c0:i.sub(t,r),c1:i.sub(e,n)}}mul({c0:t,c1:e},r){const{Fp6:n}=this;if("bigint"==typeof r)return{c0:n.mul(t,r),c1:n.mul(e,r)};let{c0:i,c1:s}=r,o=n.mul(t,i),a=n.mul(e,s);return{c0:n.add(o,n.mulByNonresidue(a)),c1:n.sub(n.mul(n.add(t,e),n.add(i,s)),n.add(o,a))}}sqr({c0:t,c1:e}){const{Fp6:r}=this;let n=r.mul(t,e);return{c0:r.sub(r.sub(r.mul(r.add(r.mulByNonresidue(e),t),r.add(t,e)),n),r.mulByNonresidue(n)),c1:r.add(n,n)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}fromBytes(t){const{Fp6:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);return{c0:e.fromBytes(t.subarray(0,e.BYTES)),c1:e.fromBytes(t.subarray(e.BYTES))}}toBytes({c0:t,c1:e}){const{Fp6:r}=this;return(0,s.Id)(r.toBytes(t),r.toBytes(e))}cmov({c0:t,c1:e},{c0:r,c1:n},i){const{Fp6:s}=this;return{c0:s.cmov(t,r,i),c1:s.cmov(e,n,i)}}fromBigTwelve(t){const{Fp6:e}=this;return{c0:e.fromBigSix(t.slice(0,6)),c1:e.fromBigSix(t.slice(6,12))}}frobeniusMap(t,e){const{Fp6:r}=this,{Fp2:n}=r,{c0:i,c1:s,c2:o}=r.frobeniusMap(t.c1,e),a=this.FROBENIUS_COEFFICIENTS[e%12];return{c0:r.frobeniusMap(t.c0,e),c1:r.create({c0:n.mul(i,a),c1:n.mul(s,a),c2:n.mul(o,a)})}}mulByFp2({c0:t,c1:e},r){const{Fp6:n}=this;return{c0:n.mulByFp2(t,r),c1:n.mulByFp2(e,r)}}conjugate({c0:t,c1:e}){return{c0:t,c1:this.Fp6.neg(e)}}mul014({c0:t,c1:e},r,n,i){const{Fp6:s}=this,{Fp2:o}=s;let a=s.mul01(t,r,n),c=s.mul1(e,i);return{c0:s.add(s.mulByNonresidue(c),a),c1:s.sub(s.sub(s.mul01(s.add(e,t),r,o.add(n,i)),a),c)}}mul034({c0:t,c1:e},r,n,i){const{Fp6:s}=this,{Fp2:o}=s,a=s.create({c0:o.mul(t.c0,r),c1:o.mul(t.c1,r),c2:o.mul(t.c2,r)}),c=s.mul01(e,n,i),u=s.mul01(s.add(t,e),o.add(r,n),i);return{c0:s.add(s.mulByNonresidue(c),a),c1:s.sub(u,s.add(a,c))}}_cyclotomicSquare({c0:t,c1:e}){const{Fp6:r}=this,{Fp2:n}=r,{c0:i,c1:s,c2:o}=t,{c0:a,c1:c,c2:u}=e,{first:l,second:h}=n.Fp4Square(i,c),{first:f,second:d}=n.Fp4Square(a,o),{first:p,second:g}=n.Fp4Square(s,u),m=n.mulByNonresidue(g);return{c0:r.create({c0:n.add(n.mul(n.sub(l,i),v),l),c1:n.add(n.mul(n.sub(f,s),v),f),c2:n.add(n.mul(n.sub(p,o),v),p)}),c1:r.create({c0:n.add(n.mul(n.add(m,a),v),m),c1:n.add(n.mul(n.add(h,c),v),h),c2:n.add(n.mul(n.add(d,u),v),d)})}}_cyclotomicExp(t,e){let r=this.ONE;for(let n=this.X_LEN-1;n>=0;n--)r=this._cyclotomicSquare(r),(0,i.GU)(e,n)&&(r=this.mul(r,t));return r}}const T=BigInt(0),P=BigInt(1),R=BigInt(2),x=BigInt(3),I=BigInt(4),N=BigInt("0xd201000000010000"),k=(0,i.dJ)(N),L={p:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),n:BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),a:T,b:I,Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")},C=(0,c.D0)(L.n,{modFromBytes:!0,isLE:!0}),{Fp:M,Fp2:B,Fp6:D,Fp12:U}=function(t){const e=c.D0(t.ORDER),r=new A(e,t),n=new O(r);return{Fp:e,Fp2:r,Fp6:n,Fp12:new S(n,t)}}({ORDER:L.p,X_LEN:k,FP2_NONRESIDUE:[P,P],Fp2mulByB:({c0:t,c1:e})=>{const r=M.mul(t,I),n=M.mul(e,I);return{c0:M.sub(r,n),c1:M.add(r,n)}},Fp12finalExponentiate:t=>{const e=N,r=U.div(U.frobeniusMap(t,6),t),n=U.mul(U.frobeniusMap(r,2),r),i=U.conjugate(U._cyclotomicExp(n,e)),s=U.mul(U.conjugate(U._cyclotomicSquare(n)),i),o=U.conjugate(U._cyclotomicExp(s,e)),a=U.conjugate(U._cyclotomicExp(o,e)),c=U.mul(U.conjugate(U._cyclotomicExp(a,e)),U._cyclotomicSquare(i)),u=U.conjugate(U._cyclotomicExp(c,e)),l=U.frobeniusMap(U.mul(i,a),2),h=U.frobeniusMap(U.mul(o,n),3),f=U.frobeniusMap(U.mul(c,U.conjugate(n)),1),d=U.mul(U.mul(u,U.conjugate(s)),n);return U.mul(U.mul(U.mul(l,h),f),d)}}),{G2psi:K,G2psi2:H}=function(t,e,r){const n=e.pow(r,(t.ORDER-b)/w),i=e.pow(r,(t.ORDER-b)/v);function s(t,r){return[e.mul(e.frobeniusMap(t,1),n),e.mul(e.frobeniusMap(r,1),i)]}const o=e.pow(r,(t.ORDER**v-b)/w),a=e.pow(r,(t.ORDER**v-b)/v);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(t,r){return[e.mul(t,o),e.neg(r)]}const u=t=>(e,r)=>{const n=r.toAffine(),i=t(n.x,n.y);return e.fromAffine({x:i[0],y:i[1]})};return{psi:s,psi2:c,G2psi:u(s),G2psi2:u(c),PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}(M,B,B.div(B.ONE,B.NONRESIDUE)),F=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:M.ORDER,m:2,k:128,expand:"xmd",hash:n.sc}),G={p:B.ORDER,n:L.n,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),a:B.ZERO,b:B.fromBigTuple([I,I]),Gx:B.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:B.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")])},V=$(M.toBytes(T),{infinity:!0,compressed:!0});function j(t){const e=224&(t=t.slice())[0],r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function $(t,e){if(224&t[0])throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function z(t){t.assertValidity();const{BYTES:e,ORDER:r}=M,{x:n,y:s}=t.toAffine();if(t.is0())return V.slice();const o=Boolean(s*R/r);return $((0,i.lq)(n,e),{compressed:!0,sort:o})}function q(t){const{infinity:e,sort:r,value:n}=j((0,i.qj)("signatureHex",t,48)),s=M.ORDER,o=Y.G1.Point,a=(0,i.Ph)(n);if(e)return o.ZERO;const c=M.create(a&(0,i.OG)(M.BITS)),u=M.add(M.pow(c,x),M.create(L.b));let l=M.sqrt(u);if(!l)throw new Error("invalid G1 point: compressed");const h=BigInt(r);l*R/s!==h&&(l=M.neg(l));const f=o.fromAffine({x:c,y:l});return f.assertValidity(),f}function W(t){t.assertValidity();const{BYTES:e}=M;if(t.is0())return(0,s.Id)(V,(0,i.lq)(T,e));const{x:r,y:n}=t.toAffine(),{re:o,im:a}=B.reim(r),{re:c,im:u}=B.reim(n),l=Boolean((u>T?u*R:c*R)/M.ORDER&P),h=o;return(0,s.Id)($((0,i.lq)(a,e),{sort:l,compressed:!0}),(0,i.lq)(h,e))}function Z(t){const{ORDER:e}=M,{infinity:r,sort:n,value:s}=j((0,i.qj)("signatureHex",t)),o=Y.G2.Point,a=s.length/2;if(48!==a&&96!==a)throw new Error("invalid compressed signature length, expected 96/192 bytes");const c=(0,i.Ph)(s.slice(0,a)),u=(0,i.Ph)(s.slice(a));if(r)return o.ZERO;const l=M.create(c&(0,i.OG)(M.BITS)),h=M.create(u),f=B.create({c0:h,c1:l}),d=B.add(B.pow(f,x),G.b);let p=B.sqrt(d);if(!p)throw new Error("Failed to find a square root");const{re:g,im:m}=B.reim(p),y=BigInt(n);(m>T&&m*R/e!==y||m===T&&g*R/e!==y)&&(p=B.neg(p));const b=o.fromAffine({x:f,y:p});return b.assertValidity(),b}const Y=function(t){const{Fp:e,Fr:r,Fp2:n,Fp6:o,Fp12:l}=t.fields,h=(0,u.gx)(t.G1),f=Object.assign(h,(0,a.qj)(h.Point,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,u.gx)(t.G2),p=Object.assign(d,(0,a.qj)(d.Point,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),y=g(t.fields,f.Point,p.Point,{...t.params,postPrecompute:t.postPrecompute}),{millerLoopBatch:b,pairing:v,pairingBatch:w,calcPairingPrecomputes:E}=y,_=m(y,f,p,t.G2.Signature,!1),A=m(y,p,f,t.G1.ShortSignature,!0),O=t.randomBytes||s.po,S=()=>{const t=(0,c.Tp)(r.ORDER);return(0,c.qy)(O(t),r.ORDER)},T={randomSecretKey:S,randomPrivateKey:S,calcPairingPrecomputes:E},{ShortSignature:P}=t.G1,{Signature:R}=t.G2;function x(t,e){return t instanceof f.Point?t:A.hash((0,i.qj)("point",t),e?.DST)}function I(t,e){return t instanceof p.Point?t:_.hash((0,i.qj)("point",t),e?.DST)}return f.Point.BASE.precompute(4),{longSignatures:_,shortSignatures:A,millerLoopBatch:b,pairing:v,pairingBatch:w,verifyBatch:function(t,e,r,n){const i=e.map(t=>I(t,n));return _.verifyBatch(t,i,r)},fields:{Fr:r,Fp:e,Fp2:n,Fp6:o,Fp12:l},params:{ateLoopSize:t.params.ateLoopSize,twistType:t.params.twistType,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:T,getPublicKey:function(t){return _.getPublicKey(t).toBytes(!0)},getPublicKeyForShortSignatures:function(t){return A.getPublicKey(t).toBytes(!0)},sign:function(t,e,r){const n=I(t,r),i=_.sign(n,e);return t instanceof p.Point?i:R.toBytes(i)},signShortSignature:function(t,e,r){const n=x(t,r),i=A.sign(n,e);return t instanceof f.Point?i:P.toBytes(i)},verify:function(t,e,r,n){const i=I(e,n);return _.verify(t,i,r)},verifyShortSignature:function(t,e,r,n){const i=x(e,n);return A.verify(t,i,r)},aggregatePublicKeys:function(t){const e=_.aggregatePublicKeys(t);return t[0]instanceof f.Point?e:e.toBytes(!0)},aggregateSignatures:function(t){const e=_.aggregateSignatures(t);return t[0]instanceof p.Point?e:R.toBytes(e)},aggregateShortSignatures:function(t){const e=A.aggregateSignatures(t);return t[0]instanceof f.Point?e:P.toBytes(e)},G1:f,G2:p,Signature:R,ShortSignature:P}}({fields:{Fp:M,Fp2:B,Fp6:D,Fp12:U,Fr:C},G1:{...L,Fp:M,htfDefaults:{...F,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(M.mul(e.X,r),e.Y,e.Z);return e.multiplyUnsafe(N).negate().multiplyUnsafe(N).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(N).add(e),mapToCurve:function(t){const{x:e,y:r}=Q(M.create(t[0]));return J(e,r)},fromBytes:function(t){const{compressed:e,infinity:r,sort:n,value:s}=j(t),{BYTES:o,ORDER:a}=M;if(48===s.length&&e){const t=(0,i.Ph)(s),e=M.create(t&(0,i.OG)(M.BITS));if(r){if(e!==T)throw new Error("invalid G1 point: non-empty, at infinity, with compression");return{x:T,y:T}}const o=M.add(M.pow(e,x),M.create(L.b));let c=M.sqrt(o);if(!c)throw new Error("invalid G1 point: compressed point");return c*R/a!==BigInt(n)&&(c=M.neg(c)),{x:M.create(e),y:M.create(c)}}if(96!==s.length||e)throw new Error("invalid G1 point: expected 48/96 bytes");{const t=(0,i.Ph)(s.subarray(0,o)),e=(0,i.Ph)(s.subarray(o));if(r){if(t!==T||e!==T)throw new Error("G1: non-empty point at infinity");return Y.G1.Point.ZERO.toAffine()}return{x:M.create(t),y:M.create(e)}}},toBytes:function(t,e,r){const{BYTES:n,ORDER:o}=M,a=e.is0(),{x:c,y:u}=e.toAffine();if(r){if(a)return V.slice();const t=Boolean(u*R/o);return $((0,i.lq)(c,n),{compressed:!0,sort:t})}return a?(0,s.Id)(Uint8Array.of(64),new Uint8Array(2*n-1)):(0,s.Id)((0,i.lq)(c,n),(0,i.lq)(u,n))},ShortSignature:{fromBytes:t=>((0,s.DO)(t),q(t)),fromHex:t=>q(t),toBytes:t=>z(t),toRawBytes:t=>z(t),toHex:t=>(0,s.My)(z(t))}},G2:{...G,Fp:B,hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...F},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:function(t){const{x:e,y:r}=tt(B.fromBigTuple(t));return X(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(N).negate().equals(K(t,e)),clearCofactor:(t,e)=>{const r=N;let n=e.multiplyUnsafe(r).negate(),i=K(t,e),s=e.double();s=H(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n);return s.subtract(e)},fromBytes:function(t){const{BYTES:e,ORDER:r}=M,{compressed:n,infinity:s,sort:o,value:a}=j(t);if(!n&&!s&&o||!n&&s&&o||o&&s&&n)throw new Error("invalid encoding flag: "+(224&t[0]));const c=(t,e,r)=>(0,i.Ph)(t.slice(e,r));if(96===a.length&&n){if(s){if(a.reduce((t,e)=>0!==t?e+1:e,0)>0)throw new Error("invalid G2 point: compressed");return{x:B.ZERO,y:B.ZERO}}const t=c(a,0,e),n=c(a,e,2*e),i=B.create({c0:M.create(n),c1:M.create(t)}),u=B.add(B.pow(i,x),G.b);let l=B.sqrt(u);const h=l.c1===T?l.c0*R/r:l.c1*R/r?P:T;return l=o&&h>0?l:B.neg(l),{x:i,y:l}}if(192!==a.length||n)throw new Error("invalid G2 point: expected 96/192 bytes");{if(s){if(a.reduce((t,e)=>0!==t?e+1:e,0)>0)throw new Error("invalid G2 point: uncompressed");return{x:B.ZERO,y:B.ZERO}}const t=c(a,0*e,1*e),r=c(a,1*e,2*e),n=c(a,2*e,3*e),i=c(a,3*e,4*e);return{x:B.fromBigTuple([r,t]),y:B.fromBigTuple([i,n])}}},toBytes:function(t,e,r){const{BYTES:n,ORDER:o}=M,a=e.is0(),{x:c,y:u}=e.toAffine();if(r){if(a)return(0,s.Id)(V,(0,i.lq)(T,n));const t=Boolean(u.c1===T?u.c0*R/o:u.c1*R/o);return(0,s.Id)($((0,i.lq)(c.c1,n),{compressed:!0,sort:t}),(0,i.lq)(c.c0,n))}{if(a)return(0,s.Id)(Uint8Array.of(64),new Uint8Array(4*n-1));const{re:t,im:e}=B.reim(c),{re:r,im:o}=B.reim(u);return(0,s.Id)((0,i.lq)(e,n),(0,i.lq)(t,n),(0,i.lq)(o,n),(0,i.lq)(r,n))}},Signature:{fromBytes:t=>((0,s.DO)(t),Z(t)),fromHex:t=>Z(t),toBytes:t=>W(t),toRawBytes:t=>W(t),toHex:t=>(0,s.My)(W(t))}},params:{ateLoopSize:N,r:L.n,xNegative:!0,twistType:"multiplicative"},htfDefaults:F,hash:n.sc}),X=(0,a.FL)(B,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(t=>B.fromBigTuple(t.map(BigInt))))),J=(0,a.FL)(M,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(t=>BigInt(t)))),Q=(0,u.Is)(M,{A:M.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:M.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:M.create(BigInt(11))}),tt=(0,u.Is)(B,{A:B.create({c0:M.create(T),c1:M.create(BigInt(240))}),B:B.create({c0:M.create(BigInt(1012)),c1:M.create(BigInt(1012))}),Z:B.create({c0:M.create(BigInt(-2)),c1:M.create(BigInt(-1))})})},1032(t,e,r){"use strict";r.d(e,{ev:()=>x});var n=r(733),i=r(36),s=r(3556),o=r(1633),a=r(6681);const c=BigInt(0),u=BigInt(1),l=BigInt(2),h=BigInt(8);class f{constructor(t){this.ep=t}static fromBytes(t){(0,o.SJ)()}static fromHex(t){(0,o.SJ)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return(0,i.My)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.init(this.ep.precompute(t,e))}toRawBytes(){return this.toBytes()}}function d(t,e,r={}){if("function"!=typeof e)throw new Error('"hash" function param is required');(0,o.DS)(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=r,{BASE:s,Fp:a,Fn:c}=t,l=r.randomBytes||i.po,h=r.adjustScalarBytes||(t=>t),f=r.domain||((t,e,r)=>{if((0,o.d6)(r,"phflag"),e.length||r)throw new Error("Contexts/pre-hash are not supported");return t});function d(t){return c.create((0,o.lX)(t))}function p(t){const{head:r,prefix:n,scalar:i}=function(t){const r=v.secretKey;t=(0,o.qj)("private key",t,r);const n=(0,o.qj)("hashed private key",e(t),2*r),i=h(n.slice(0,r));return{head:i,prefix:n.slice(r,2*r),scalar:d(i)}}(t),a=s.multiply(i),c=a.toBytes();return{head:r,prefix:n,scalar:i,point:a,pointBytes:c}}function g(t){return p(t).pointBytes}function m(t=Uint8Array.of(),...r){const s=(0,i.Id)(...r);return d(e(f(s,(0,o.qj)("context",t),!!n)))}const y={zip215:!0};const b=a.BYTES,v={secretKey:b,publicKey:b,signature:2*b,seed:b};function w(t=l(v.seed)){return(0,o.eV)(t,v.seed,"seed")}const E={getExtendedPublicKey:p,randomSecretKey:w,isValidSecretKey:function(t){return(0,i.aY)(t)&&t.length===c.BYTES},isValidPublicKey:function(e,r){try{return!!t.fromBytes(e,r)}catch(t){return!1}},toMontgomery(e){const{y:r}=t.fromBytes(e),n=v.publicKey,i=32===n;if(!i&&57!==n)throw new Error("only defined for 25519 and 448");const s=i?a.div(u+r,u-r):a.div(r-u,r+u);return a.toBytes(s)},toMontgomerySecret(t){const r=v.secretKey;(0,o.eV)(t,r);const n=e(t.subarray(0,r));return h(n).subarray(0,r)},randomPrivateKey:w,precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({keygen:function(t){const e=E.randomSecretKey(t);return{secretKey:e,publicKey:g(e)}},getPublicKey:g,sign:function(t,e,r={}){t=(0,o.qj)("message",t),n&&(t=n(t));const{prefix:a,scalar:u,pointBytes:l}=p(e),h=m(r.context,a,t),f=s.multiply(h).toBytes(),d=m(r.context,f,l,t),g=c.create(h+d*u);if(!c.isValid(g))throw new Error("sign failed: invalid s");const y=(0,i.Id)(f,c.toBytes(g));return(0,o.eV)(y,v.signature,"result")},verify:function(e,r,i,a=y){const{context:c,zip215:u}=a,l=v.signature;e=(0,o.qj)("signature",e,l),r=(0,o.qj)("message",r),i=(0,o.qj)("publicKey",i,v.publicKey),void 0!==u&&(0,o.d6)(u,"zip215"),n&&(r=n(r));const h=l/2,f=e.subarray(0,h),d=(0,o.lX)(e.subarray(h,l));let p,g,b;try{p=t.fromBytes(i,u),g=t.fromBytes(f,u),b=s.multiplyUnsafe(d)}catch(t){return!1}if(!u&&p.isSmallOrder())return!1;const w=m(c,g.toBytes(),p.toBytes(),r);return g.add(p.multiplyUnsafe(w)).subtract(b).clearCofactor().is0()},utils:E,Point:t,lengths:v})}function p(t){const{CURVE:e,curveOpts:r,hash:n,eddsaOpts:f}=function(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r={Fp:t.Fp,Fn:(0,a.D0)(e.n,t.nBitLength,!0),uvRatio:t.uvRatio},n={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:r,hash:t.hash,eddsaOpts:n}}(t),p=function(t,e={}){const r=(0,s.UT)("edwards",t,e,e.FpFnLE),{Fp:n,Fn:a}=r;let f=r.CURVE;const{h:d}=f;(0,o.DS)(e,{},{uvRatio:"function"});const p=l<<BigInt(8*a.BYTES)-u,g=t=>n.create(t),m=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:n.sqrt(n.div(t,e))}}catch(t){return{isValid:!1,value:c}}});if(!function(t,e,r,n){const i=t.sqr(r),s=t.sqr(n),o=t.add(t.mul(e.a,i),s),a=t.add(t.ONE,t.mul(e.d,t.mul(i,s)));return t.eql(o,a)}(n,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function y(t,e,r=!1){const n=r?u:c;return(0,o.aK)("coordinate "+t,e,n,p),e}function b(t){if(!(t instanceof E))throw new Error("ExtendedPoint expected")}const v=(0,o.x)((t,e)=>{const{X:r,Y:i,Z:s}=t,o=t.is0();null==e&&(e=o?h:n.inv(s));const a=g(r*e),l=g(i*e),f=n.mul(s,e);if(o)return{x:c,y:u};if(f!==u)throw new Error("invZ was invalid");return{x:a,y:l}}),w=(0,o.x)(t=>{const{a:e,d:r}=f;if(t.is0())throw new Error("bad point: ZERO");const{X:n,Y:i,Z:s,T:o}=t,a=g(n*n),c=g(i*i),u=g(s*s),l=g(u*u),h=g(a*e);if(g(u*g(h+c))!==g(l+g(r*g(a*c))))throw new Error("bad point: equation left != right (1)");if(g(n*i)!==g(s*o))throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(t,e,r,n){this.X=y("x",t),this.Y=y("y",e),this.Z=y("z",r,!0),this.T=y("t",n),Object.freeze(this)}static CURVE(){return f}static fromAffine(t){if(t instanceof E)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};return y("x",e),y("y",r),new E(e,r,u,g(e*r))}static fromBytes(t,e=!1){const r=n.BYTES,{a:i,d:s}=f;t=(0,o.nC)((0,o.eV)(t,r,"point")),(0,o.d6)(e,"zip215");const a=(0,o.nC)(t),l=t[r-1];a[r-1]=-129&l;const h=(0,o.lX)(a),d=e?p:n.ORDER;(0,o.aK)("point.y",h,c,d);const y=g(h*h),b=g(y-u),v=g(s*y-i);let{isValid:w,value:_}=m(b,v);if(!w)throw new Error("bad point: invalid y coordinate");const A=(_&u)===u,O=!!(128&l);if(!e&&_===c&&O)throw new Error("bad point: x=0 and x_0=1");return O!==A&&(_=g(-_)),E.fromAffine({x:_,y:h})}static fromHex(t,e=!1){return E.fromBytes((0,o.qj)("point",t),e)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return _.createCache(this,t),e||this.multiply(l),this}assertValidity(){w(this)}equals(t){b(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=t,a=g(e*o),c=g(i*n),u=g(r*o),l=g(s*n);return a===c&&u===l}is0(){return this.equals(E.ZERO)}negate(){return new E(g(-this.X),this.Y,this.Z,g(-this.T))}double(){const{a:t}=f,{X:e,Y:r,Z:n}=this,i=g(e*e),s=g(r*r),o=g(l*g(n*n)),a=g(t*i),c=e+r,u=g(g(c*c)-i-s),h=a+s,d=h-o,p=a-s,m=g(u*d),y=g(h*p),b=g(u*p),v=g(d*h);return new E(m,y,v,b)}add(t){b(t);const{a:e,d:r}=f,{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:c,Z:u,T:l}=t,h=g(n*a),d=g(i*c),p=g(o*r*l),m=g(s*u),y=g((n+i)*(a+c)-h-d),v=m-p,w=m+p,_=g(d-e*h),A=g(y*v),O=g(w*_),S=g(y*_),T=g(v*w);return new E(A,O,T,S)}subtract(t){return this.add(t.negate())}multiply(t){if(!a.isValidNot0(t))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:e,f:r}=_.cached(this,t,t=>(0,s.Ak)(E,t));return(0,s.Ak)(E,[e,r])[0]}multiplyUnsafe(t,e=E.ZERO){if(!a.isValid(t))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return t===c?E.ZERO:this.is0()||t===u?this:_.unsafe(this,t,t=>(0,s.Ak)(E,t),e)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return _.unsafe(this,f.n).is0()}toAffine(t){return v(this,t)}clearCofactor(){return d===u?this:this.multiplyUnsafe(d)}toBytes(){const{x:t,y:e}=this.toAffine(),r=n.toBytes(e);return r[r.length-1]|=t&u?128:0,r}toHex(){return(0,i.My)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(t){return(0,s.Ak)(E,t)}static msm(t,e){return(0,s.Xf)(E,a,t,e)}_setWindowSize(t){this.precompute(t)}toRawBytes(){return this.toBytes()}}E.BASE=new E(f.Gx,f.Gy,u,g(f.Gx*f.Gy)),E.ZERO=new E(c,u,u,c),E.Fp=n,E.Fn=a;const _=new s.hT(E,a.BITS);return E.BASE.precompute(8),E}(e,r);return function(t,e){const r=e.Point;return Object.assign({},e,{ExtendedPoint:r,CURVE:t,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}(t,d(p,n,f))}r(9991);const g=BigInt(0),m=BigInt(1),y=BigInt(2),b=(BigInt(3),BigInt(5)),v=BigInt(8),w=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),E=(()=>({p:w,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:v,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function _(t){const e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=w,o=t*t%s*t%s,c=(0,a.zH)(o,y,s)*o%s,u=(0,a.zH)(c,m,s)*t%s,l=(0,a.zH)(u,b,s)*u%s,h=(0,a.zH)(l,e,s)*l%s,f=(0,a.zH)(h,r,s)*h%s,d=(0,a.zH)(f,n,s)*f%s,p=(0,a.zH)(d,i,s)*d%s,g=(0,a.zH)(p,i,s)*d%s,v=(0,a.zH)(g,e,s)*l%s;return{pow_p_5_8:(0,a.zH)(v,y,s)*t%s,b2:o}}function A(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const O=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function S(t,e){const r=w,n=(0,a.zi)(e*e*e,r),i=_(t*(0,a.zi)(n*n*e,r)).pow_p_5_8;let s=(0,a.zi)(t*n*i,r);const o=(0,a.zi)(e*s*s,r),c=s,u=(0,a.zi)(s*O,r),l=o===t,h=o===(0,a.zi)(-t,r),f=o===(0,a.zi)(-t*O,r);return l&&(s=c),(h||f)&&(s=u),(0,a.dQ)(s,r)&&(s=(0,a.zi)(-s,r)),{isValid:l||h,value:s}}const T=(()=>(0,a.D0)(E.p,{isLE:!0}))(),P=(()=>(0,a.D0)(E.n,{isLE:!0}))(),R=(()=>({...E,Fp:T,hash:n.Zf,adjustScalarBytes:A,uvRatio:S}))(),x=(()=>p(R))();const I=O,N=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),k=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),L=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),C=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),M=t=>S(m,t),B=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),D=t=>x.Point.Fp.create((0,o.lX)(t)&B);function U(t){const{d:e}=E,r=w,n=t=>T.create(t),i=n(I*t*t),s=n((i+m)*L);let o=BigInt(-1);const c=n((o-e*i)*n(i+e));let{isValid:u,value:l}=S(s,c),h=n(l*t);(0,a.dQ)(h,r)||(h=n(-h)),u||(l=h),u||(o=i);const f=n(o*(i-m)*C-c),d=l*l,p=n((l+l)*c),g=n(f*N),y=n(m-d),b=n(m+d);return new x.Point(n(p*b),n(y*g),n(g*b),n(p*y))}function K(t){(0,i.DO)(t,64);const e=U(D(t.subarray(0,32))),r=U(D(t.subarray(32,64)));return new H(e.add(r))}class H extends f{constructor(t){super(t)}static fromAffine(t){return new H(x.Point.fromAffine(t))}assertSame(t){if(!(t instanceof H))throw new Error("RistrettoPoint expected")}init(t){return new H(t)}static hashToCurve(t){return K((0,o.qj)("ristrettoHash",t,64))}static fromBytes(t){(0,i.DO)(t,32);const{a:e,d:r}=E,n=w,s=t=>T.create(t),c=D(t);if(!(0,o.ex)(T.toBytes(c),t)||(0,a.dQ)(c,n))throw new Error("invalid ristretto255 encoding 1");const u=s(c*c),l=s(m+e*u),h=s(m-e*u),f=s(l*l),d=s(h*h),p=s(e*r*f-d),{isValid:y,value:b}=M(s(p*d)),v=s(b*h),_=s(b*v*p);let A=s((c+c)*v);(0,a.dQ)(A,n)&&(A=s(-A));const O=s(l*_),S=s(A*O);if(!y||(0,a.dQ)(S,n)||O===g)throw new Error("invalid ristretto255 encoding 2");return new H(new x.Point(A,O,m,S))}static fromHex(t){return H.fromBytes((0,o.qj)("ristrettoHex",t,32))}static msm(t,e){return(0,s.Xf)(H,x.Point.Fn,t,e)}toBytes(){let{X:t,Y:e,Z:r,T:n}=this.ep;const i=w,s=t=>T.create(t),o=s(s(r+e)*s(r-e)),c=s(t*e),u=s(c*c),{value:l}=M(s(o*u)),h=s(l*o),f=s(l*c),d=s(h*f*n);let p;if((0,a.dQ)(n*d,i)){let r=s(e*I),n=s(t*I);t=r,e=n,p=s(h*k)}else p=f;(0,a.dQ)(t*d,i)&&(e=s(-e));let g=s((r-e)*p);return(0,a.dQ)(g,i)&&(g=s(-g)),T.toBytes(g)}equals(t){this.assertSame(t);const{X:e,Y:r}=this.ep,{X:n,Y:i}=t.ep,s=t=>T.create(t),o=s(e*i)===s(r*n),a=s(r*i)===s(e*n);return o||a}is0(){return this.equals(H.ZERO)}}H.BASE=(()=>new H(x.Point.BASE))(),H.ZERO=(()=>new H(x.Point.ZERO))(),H.Fp=(()=>T)(),H.Fn=(()=>P)()},404(t,e,r){"use strict";r.d(e,{s9:()=>f});var n=r(733),i=r(8552),s=r(6681);const o={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},a={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},c={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},u=(0,s.D0)(o.p),l=(0,s.D0)(a.p),h=(0,s.D0)(c.p);const f=(0,i.s)({...o,Fp:u,lowS:!1},n.sc);(0,i.s)({...a,Fp:l,lowS:!1},n.qt),(0,i.s)({...c,Fp:h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},n.Zf)},3156(t,e,r){"use strict";r.d(e,{bI:()=>l});var n=r(733),i=r(8552),s=r(6681);const o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},a={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},c=BigInt(2);const u=(0,s.D0)(o.p,{sqrt:function(t){const e=o.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),a=BigInt(22),l=BigInt(23),h=BigInt(44),f=BigInt(88),d=t*t*t%e,p=d*d*t%e,g=(0,s.zH)(p,r,e)*p%e,m=(0,s.zH)(g,r,e)*p%e,y=(0,s.zH)(m,c,e)*d%e,b=(0,s.zH)(y,i,e)*y%e,v=(0,s.zH)(b,a,e)*b%e,w=(0,s.zH)(v,h,e)*v%e,E=(0,s.zH)(w,f,e)*w%e,_=(0,s.zH)(E,h,e)*v%e,A=(0,s.zH)(_,r,e)*p%e,O=(0,s.zH)(A,l,e)*b%e,S=(0,s.zH)(O,n,e)*d%e,T=(0,s.zH)(S,c,e);if(!u.eql(u.sqr(T),t))throw new Error("Cannot find square root");return T}}),l=(0,i.s)({...o,Fp:u,lowS:!0,endo:a},n.sc)},1633(t,e,r){"use strict";r.d(e,{DS:()=>S,GU:()=>E,OG:()=>_,Ph:()=>l,SJ:()=>T,aK:()=>v,d6:()=>o,dJ:()=>w,eV:()=>a,ex:()=>g,fg:()=>A,jN:()=>O,lX:()=>h,lq:()=>f,nC:()=>m,qj:()=>p,r4:()=>b,x:()=>P,z:()=>d,zW:()=>c});var n=r(36);const i=BigInt(0),s=BigInt(1);function o(t,e=""){if("boolean"!=typeof t){throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t)}return t}function a(t,e,r=""){const i=(0,n.aY)(t),s=t?.length,o=void 0!==e;if(!i||o&&s!==e){throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(i?`length=${s}`:"type="+typeof t))}return t}function c(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function u(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?i:BigInt("0x"+t)}function l(t){return u((0,n.My)(t))}function h(t){return(0,n.DO)(t),u((0,n.My)(Uint8Array.from(t).reverse()))}function f(t,e){return(0,n.aT)(t.toString(16).padStart(2*e,"0"))}function d(t,e){return f(t,e).reverse()}function p(t,e,r){let i;if("string"==typeof e)try{i=(0,n.aT)(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!(0,n.aY)(e))throw new Error(t+" must be hex string or Uint8Array");i=Uint8Array.from(e)}const s=i.length;if("number"==typeof r&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}function g(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r}function m(t){return Uint8Array.from(t)}const y=t=>"bigint"==typeof t&&i<=t;function b(t,e,r){return y(t)&&y(e)&&y(r)&&e<=t&&t<r}function v(t,e,r,n){if(!b(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function w(t){let e;for(e=0;t>i;t>>=s,e+=1);return e}function E(t,e){return t>>BigInt(e)&s}const _=t=>(s<<BigInt(t))-s;function A(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const i=t=>new Uint8Array(t),s=t=>Uint8Array.of(t);let o=i(t),a=i(t),c=0;const u=()=>{o.fill(1),a.fill(0),c=0},l=(...t)=>r(a,o,...t),h=(t=i(0))=>{a=l(s(0),t),o=l(),0!==t.length&&(a=l(s(1),t),o=l())},f=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){o=l();const e=o.slice();r.push(e),t+=o.length}return(0,n.Id)(...r)};return(t,e)=>{let r;for(u(),h(t);!(r=e(f()));)h();return u(),r}}function O(t){return"function"==typeof t&&Number.isSafeInteger(t.outputLen)}function S(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const s=typeof i;if(s!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${s}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))}const T=()=>{throw new Error("not implemented")};function P(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const s=t(r,...n);return e.set(r,s),s}}},733(t,e,r){"use strict";r.d(e,{tn:()=>N,aD:()=>I,ZT:()=>H,sc:()=>K,qt:()=>G,Zf:()=>F});var n=r(36);function i(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}class o extends n.Vw{constructor(t,e,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=(0,n.O8)(this.buffer)}update(t){(0,n.CC)(this),t=(0,n.ZJ)(t),(0,n.DO)(t);const{view:e,buffer:r,blockLen:i}=this,s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const e=(0,n.O8)(t);for(;i<=s-o;o+=i)this.process(e,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.CC)(this),(0,n.Ht)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,(0,n.uH)(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(r,0),o=0);for(let t=o;t<i;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,u=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+u,a,n)}(r,i-8,BigInt(8*this.length),s),this.process(r,0);const a=(0,n.O8)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,l[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=i,t.length=n,t.pos=o,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const a=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),u=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),l=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),h=BigInt(2**32-1),f=BigInt(32);function d(t,e=!1){return e?{h:Number(t&h),l:Number(t>>f&h)}:{h:0|Number(t>>f&h),l:0|Number(t&h)}}function p(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){const{h:r,l:o}=d(t[s],e);[n[s],i[s]]=[r,o]}return[n,i]}const g=(t,e,r)=>t>>>r,m=(t,e,r)=>t<<32-r|e>>>r,y=(t,e,r)=>t>>>r|e<<32-r,b=(t,e,r)=>t<<32-r|e>>>r,v=(t,e,r)=>t<<64-r|e>>>r-32,w=(t,e,r)=>t>>>r-32|e<<64-r;function E(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const _=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),A=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,O=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,T=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),P=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;const R=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),x=new Uint32Array(64);class I extends o{constructor(t=32){super(64,t,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)x[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=x[t-15],r=x[t-2],i=(0,n.Ow)(e,7)^(0,n.Ow)(e,18)^e>>>3,s=(0,n.Ow)(r,17)^(0,n.Ow)(r,19)^r>>>10;x[t]=s+x[t-7]+i+x[t-16]|0}let{A:r,B:o,C:a,D:c,E:u,F:l,G:h,H:f}=this;for(let t=0;t<64;t++){const e=f+((0,n.Ow)(u,6)^(0,n.Ow)(u,11)^(0,n.Ow)(u,25))+i(u,l,h)+R[t]+x[t]|0,d=((0,n.Ow)(r,2)^(0,n.Ow)(r,13)^(0,n.Ow)(r,22))+s(r,o,a)|0;f=h,h=l,l=u,u=c+e|0,c=a,a=o,o=r,r=e+d|0}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,l=l+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(r,o,a,c,u,l,h,f)}roundClean(){(0,n.uH)(x)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,n.uH)(this.buffer)}}class N extends I{constructor(){super(28),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4],this.F=0|c[5],this.G=0|c[6],this.H=0|c[7]}}const k=(()=>p(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),L=(()=>k[0])(),C=(()=>k[1])(),M=new Uint32Array(80),B=new Uint32Array(80);class D extends o{constructor(t=64){super(128,t,16,!1),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)M[r]=t.getUint32(e),B[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|M[t-15],r=0|B[t-15],n=y(e,r,1)^y(e,r,8)^g(e,0,7),i=b(e,r,1)^b(e,r,8)^m(e,r,7),s=0|M[t-2],o=0|B[t-2],a=y(s,o,19)^v(s,o,61)^g(s,0,6),c=b(s,o,19)^w(s,o,61)^m(s,o,6),u=O(i,c,B[t-7],B[t-16]),l=S(u,n,a,M[t-7],M[t-16]);M[t]=0|l,B[t]=0|u}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:R,Hh:x,Hl:I}=this;for(let t=0;t<80;t++){const e=y(l,h,14)^y(l,h,18)^v(l,h,41),g=b(l,h,14)^b(l,h,18)^w(l,h,41),m=l&f^~l&p,O=T(I,g,h&d^~h&R,C[t],B[t]),S=P(O,x,e,m,L[t],M[t]),N=0|O,k=y(r,n,28)^v(r,n,34)^v(r,n,39),D=b(r,n,28)^w(r,n,34)^w(r,n,39),U=r&i^r&o^i&o,K=n&s^n&a^s&a;x=0|p,I=0|R,p=0|f,R=0|d,f=0|l,d=0|h,({h:l,l:h}=E(0|c,0|u,0|S,0|N)),c=0|o,u=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const H=_(N,D,K);r=A(H,S,k,U),n=0|H}({h:r,l:n}=E(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=E(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=E(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:u}=E(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=E(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=E(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:R}=E(0|this.Gh,0|this.Gl,0|p,0|R)),({h:x,l:I}=E(0|this.Hh,0|this.Hl,0|x,0|I)),this.set(r,n,i,s,o,a,c,u,l,h,f,d,p,R,x,I)}roundClean(){(0,n.uH)(M,B)}destroy(){(0,n.uH)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class U extends D{constructor(){super(48),this.Ah=0|u[0],this.Al=0|u[1],this.Bh=0|u[2],this.Bl=0|u[3],this.Ch=0|u[4],this.Cl=0|u[5],this.Dh=0|u[6],this.Dl=0|u[7],this.Eh=0|u[8],this.El=0|u[9],this.Fh=0|u[10],this.Fl=0|u[11],this.Gh=0|u[12],this.Gl=0|u[13],this.Hh=0|u[14],this.Hl=0|u[15]}}const K=(0,n.qj)(()=>new I),H=(0,n.qj)(()=>new N),F=(0,n.qj)(()=>new D),G=(0,n.qj)(()=>new U)},2001(t,e,r){"use strict";r.r(e),r.d(e,{SHA224:()=>o,SHA256:()=>i,sha224:()=>a,sha256:()=>s});var n=r(733);const i=n.aD,s=n.sc,o=n.tn,a=n.ZT},36(t,e,r){"use strict";r.d(e,{Vw:()=>P,DO:()=>o,CC:()=>c,sd:()=>a,Fe:()=>s,Ht:()=>u,My:()=>g,uH:()=>l,Id:()=>T,qj:()=>R,O8:()=>h,aT:()=>A,aY:()=>i,po:()=>x,Ow:()=>f,ZJ:()=>S,AI:()=>O});const n="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function a(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");s(t.outputLen),s(t.blockLen)}function c(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function l(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function h(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function f(t,e){return t<<32-e|t>>>e}const d=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function g(t){if(o(t),d)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=p[t[r]];return e}const m=48,y=57,b=65,v=70,w=97,E=102;function _(t){return t>=m&&t<=y?t-m:t>=b&&t<=v?t-(b-10):t>=w&&t<=E?t-(w-10):void 0}function A(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(d)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=_(t.charCodeAt(i)),s=_(t.charCodeAt(i+1));if(void 0===r||void 0===s){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+s}return n}function O(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function S(t){return"string"==typeof t&&(t=O(t)),o(t),t}function T(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];o(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}class P{}function R(t){const e=e=>t().update(S(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function x(t=32){if(n&&"function"==typeof n.getRandomValues)return n.getRandomValues(new Uint8Array(t));if(n&&"function"==typeof n.randomBytes)return Uint8Array.from(n.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}},5608(t,e,r){"use strict";r.d(e,{AQ:()=>h,C6:()=>i,Ju:()=>a,N3:()=>l,YH:()=>o,fX:()=>u,sH:()=>s,xN:()=>f,zs:()=>c});var 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])},n(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function s(t,e,r,n){return new(r||(r=Promise))(function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(o,a)}c((n=n.apply(t,e||[])).next())})}function o(t,e){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}Object.create;function a(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function u(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function l(t){return this instanceof l?(this.v=t,this):new l(t)}function h(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(t){return function(e){return Promise.resolve(e).then(t,u)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(t,e){i[t]&&(n[t]=function(e){return new Promise(function(r,n){s.push([t,e,r,n])>1||a(t,e)})},e&&(n[t]=e(n[t])))}function a(t,e){try{(r=i[t](e)).value instanceof l?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(t){h(s[0][3],t)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function f(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=a(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise(function(n,i){(function(t,e,r,n){Promise.resolve(n).then(function(e){t({value:e,done:r})},e)})(n,i,(e=t[r](e)).done,e.value)})}}}Object.create;"function"==typeof SuppressedError&&SuppressedError},7873(t,e,r){"use strict";r.r(e),r.d(e,{BigNumber:()=>n,default:()=>E});var n=function t(e){var r,n,E,_=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,o,c,l,h,f,d,p=this;if(!(p instanceof M))return new M(t,e);if(d=typeof t,null==e){if(D(t))return p.s=t.s,void(!t.c||t.e>x?p.c=p.e=null:t.e<R?p.c=[p.e=0]:(p.e=t.e,p.c=t.c.slice()));if("number"==d){if(0*t!=0)return p.s=isNaN(t)?null:t<0?-1:1,void(p.c=p.e=null);if(p.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?p.c=p.e=null:(p.e=c,p.c=[t]))}f=String(t)}else{if("string"==d){if(f=t,!i.test(f))return E(p,f)}else{if("bigint"!=d)throw Error(a+"Invalid argument: "+t);f=String(t)}p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(c=f.indexOf("."))>-1&&(f=f.replace(".","")),(l=f.search(/e/i))>0?(c<0&&(c=l),c+=+f.slice(l+1),f=f.substring(0,l)):c<0&&(c=f.length)}else{if("string"!=d)throw Error(a+"String expected: "+t);for(y(e,2,C.length,"Base"),f=t,p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1,r=C.slice(0,e),c=l=0,h=f.length;l<h;l++)if(r.indexOf(s=f.charAt(l))<0){if("."==s){if(l>c){c=h;continue}}else if(!o&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){o=!0,l=-1,c=0;continue}return E(p,t,e)}(c=(f=n(f,e,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):c=f.length}for(l=0;48===f.charCodeAt(l);l++);for(h=f.length;48===f.charCodeAt(--h););if(f=f.slice(l,++h))if(h-=l,(c=c-l-1)>x)p.c=p.e=null;else if(c<R)p.c=[p.e=0];else{if(p.e=c,p.c=[],l=(c+1)%u,c<0&&(l+=u),l<h){for(l&&p.c.push(+f.slice(0,l)),h-=u;l<h;)p.c.push(+f.slice(l,l+=u));l=u-(f=f.slice(l)).length}else l-=h;for(;l--;f+="0");p.c.push(+f)}else p.c=[p.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:y(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=g(t.c),c=1==n||2==n&&(o<=T||o>=P)?v(c,o):w(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=g(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=v(c,s)}else if(e-=o+(2===n&&s>o),c=w(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=m(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*u-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,a,l,f,d,p,g,m=t.c,y=h;if(m){t:{for(i=1,f=m[0];f>=10;f/=10,i++);if((a=e-i)<0)a+=u,l=e,d=m[p=0],g=o(d/y[i-l-1]%10);else if((p=s((a+1)/u))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));d=g=0,i=1,l=(a%=u)-u+1}else{for(d=f=m[p],i=1;f>=10;f/=10,i++);g=(l=(a%=u)-u+i)<0?0:o(d/y[i-l-1]%10)}if(n=n||e<0||null!=m[p+1]||(l<0?d:d%y[i-l-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(a>0?l>0?d/y[i-l]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(u-e%u)%u],t.e=-e||0):m[0]=t.e=0,t;if(0==a?(m.length=p,f=1,p--):(m.length=p+1,f=y[u-a],m[p]=l>0?o(d/y[i-l]%y[l])*f:0),n)for(;;){if(0==p){for(a=1,l=m[0];l>=10;l/=10,a++);for(l=m[0]+=f,f=1;l>=10;l/=10,f++);a!=f&&(t.e++,m[0]==c&&(m[0]=1));break}if(m[p]+=f,m[p]!=c)break;m[p--]=0,f=1}for(a=m.length;0===m[--a];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=g(t.c),e=r<=T||r>=P?v(e,r):w(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(a+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(y(r=t[e],0,d,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(y(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(y(r[0],-d,0,e),y(r[1],0,d,e),T=r[0],P=r[1]):(y(r,-d,d,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)y(r[0],-d,-1,e),y(r[1],1,d,e),R=r[0],x=r[1];else{if(y(r,-d,d,e),!r)throw Error(a+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(a+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(a+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(y(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(y(r=t[e],0,d,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(a+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(a+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-d||i>d||i!==o(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%u)<1&&(e+=u),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=c||r!==o(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return o(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,c,l,f=0,p=[],g=new M(A);if(null==t?t=O:y(t,0,d),c=s(t/u),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(c*=2));f<c;)(l=131072*r[f]+(r[f+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[f]=n[0],r[f+1]=n[1]):(p.push(l%1e14),f+=2);f=c/2}else{if(!crypto.randomBytes)throw I=!1,Error(a+"crypto unavailable");for(r=crypto.randomBytes(c*=7);f<c;)(l=281474976710656*(31&r[f])+1099511627776*r[f+1]+4294967296*r[f+2]+16777216*r[f+3]+(r[f+4]<<16)+(r[f+5]<<8)+r[f+6])>=9e15?crypto.randomBytes(7).copy(r,f):(p.push(l%1e14),f+=7);f=c/7}if(!I)for(;f<c;)(l=e())<9e15&&(p[f++]=l%1e14);for(c=p[--f],t%=u,c&&t&&(l=h[u-t],p[f]=o(c/l)*l);0===p[f];p.pop(),f--);if(f<0)p=[i=0];else{for(i=-1;0===p[0];p.splice(0,1),i-=u);for(f=1,l=p[0];l>=10;l/=10,f++);f<u&&(i-=u-f)}return g.e=i,g.c=p,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,m,y=n.indexOf("."),b=O,v=S;for(y>=0&&(h=k,k=0,n=n.replace(".",""),d=(m=new M(i)).pow(n.length-y),k=h,m.c=e(w(g(d.c),d.e,"0"),10,s,t),m.e=m.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,m,b,v,s)).c,f=d.r,l=d.e),y=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=y||f)&&(0==v||v==(d.s<0?3:2)):y>h||y==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?w(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=w(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%f,l=e/f|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%f)+(n=l*s+(o=t[c]/f|0)*u)%f*f+a)/r|0)+(n/f|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,a,l){var h,f,d,g,m,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,l||(l=c,f=p(n.e/u)-p(i.e/u),x=x/u|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),g=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(m=o(l/(N[0]+1)))>1&&(N=t(N,m,l),I=t(I,m,l),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=l/2&&T++;do{if(m=0,(h=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*l+(E[1]||0)),(m=o(A/T))>1)for(m>=l&&(m=l-1),b=(y=t(N,m,l)).length,_=E.length;1==e(y,E,b,_);)m--,r(y,P<b?R:N,b,l),b=y.length,h=1;else 0==m&&(h=m=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,l),_=E.length,-1==h)for(;e(N,E,P,_)<1;)m++,r(E,P<_?R:N,_,l),_=E.length}else 0===h&&(m++,E=[0]);w[d++]=m,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);g=null!=E[0],w[0]||w.splice(0,1)}if(l==c){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*u-1)+1,a,g)}else v.e=f,v.r=+g;return v}}(),E=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,c){var u,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return u="x"==(r=r.toLowerCase())?16:"b"==r?2:8,c&&c!=u?t:e}),c&&(u=c,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,u);throw Error(a+"Not a"+(c?" base "+c:"")+" number: "+o)}}(),_.absoluteValue=_.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return m(this,new M(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,s=this;if(null!=t)return y(t,0,d),null==e?e=S:y(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-p(this.e/u))*u,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new M(t,e),O,S)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new M(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,c,l,h,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(a+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),l=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),l?t.s*(2-b(t)):+F(t))),e?d.mod(e):d;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return c=p.s<0&&b(t)?-0:0,p.e>-1&&(c=1/c),new M(h?1/c:c);k&&(c=s(k/u+2))}for(l?(r=new M(.5),h&&(t.s=1),f=b(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;c?d.c.length>c&&(d.c.length=c):n&&(d=d.mod(e))}if(i){if(0===(i=o(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=b(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(e))}return n?d:(h&&(d=A.div(d)),e?d.mod(e):c?H(d,k,S,void 0):d)},_.integerValue=function(t){var e=new M(this);return null==t?t=S:y(t,0,8),H(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===m(this,new M(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return m(this,new M(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=m(this,new M(t,e)))||0===e},_.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return m(this,new M(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=m(this,new M(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var l=o.e/u,h=t.e/u,f=o.c,d=t.c;if(!l||!h){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(l=p(l),h=p(h),f=f.slice(),a=l-h){for((s=a<0)?(a=-a,i=f):(h=l,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=c-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=c}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--h);return f[0]?K(t,f,h):(t.s=3==S?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,s,o,a,l,h,d,g,m,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=p(E.e/u)+p(t.e/u),t.s*=E.s,(l=_.length)<(g=A.length)&&(b=_,_=A,A=b,i=l,l=g,g=i),i=l+g,b=[];i--;b.push(0));for(v=c,w=f,i=g;--i>=0;){for(r=0,m=A[i]%w,y=A[i]/w|0,s=i+(o=l);s>i;)r=((h=m*(h=_[--o]%w)+(a=y*h+(d=_[o]/w|0)*m)%w*w+b[s]+r)/v|0)+(a/w|0)+y*d,b[s--]=h%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},_.negated=function(){var t=new M(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/u,o=t.e/u,a=n.c,l=t.c;if(!s||!o){if(!a||!l)return new M(i/0);if(!a[0]||!l[0])return l[0]?t:new M(a[0]?n:0*i)}if(s=p(s),o=p(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=l):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=l.length)<0&&(r=l,l=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+l[e]+i)/c|0,a[e]=c===a[e]?0:a[e]%c;return i&&(a=[i].concat(a),++o),K(t,a,o)},_.precision=_.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return y(t,1,d),null==e?e=S:y(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*u+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},_.shiftedBy=function(t){return y(t,-9007199254740991,l),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=g(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=p((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),g(s.c).slice(0,c)===(e=g(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},_.toExponential=function(t,e){return null!=t&&(y(t,0,d),t++),B(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(y(t,0,d),t=t+this.e+1),B(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(a+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(u&&(s=c,c=u,u=s,g-=s),c>0&&g>0){for(s=g%c||c,h=p.substr(0,s);s<g;s+=c)h+=l+p.substr(s,c);u>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,s,o,c,l,f,d,p,m,y,b=this,v=b.c;if(null!=t&&(!(l=new M(t)).isInteger()&&(l.c||1!==l.s)||l.lt(A)))throw Error(a+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+F(l));if(!v)return new M(b);for(e=new M(A),d=n=new M(A),i=f=new M(A),y=g(v),o=e.e=y.length-b.e-1,e.c[0]=h[(c=o%u)<0?u+c:c],t=!t||l.comparedTo(e)>0?o>0?e:d:l,c=x,x=1/0,l=new M(y),f.c[0]=0;p=r(l,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,d=f.plus(p.times(s=d)),f=s,e=l.minus(p.times(s=e)),l=s;return s=r(t.minus(n),i,0,1),f=f.plus(s.times(d)),n=n.plus(s.times(i)),f.s=d.s=b.s,m=r(d,i,o*=2,S).minus(b).abs().comparedTo(r(f,n,o,S).minus(b).abs())<1?[d,i]:[f,n],x=c,m},_.toNumber=function(){return+F(this)},_.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},_.toPrecision=function(t,e){return null!=t&&y(t,1,d),B(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?v(g(r.c),s):w(g(r.c),s,"0"):(y(t,2,C.length,"Base"),e=n(w(g(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return F(this)},_._isBigNumber=!0,null!=e&&M.set(e);return M}(),i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,o=Math.floor,a="[BigNumber Error] ",c=1e14,u=14,l=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,d=1e9;function p(t){var e=0|t;return t>0||t===e?e:e-1}function g(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=u-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function m(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function y(t,e,r,n){if(t<e||t>r||t!==o(t))throw Error(a+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function b(t){var e=t.c.length-1;return p(t.e/u)==e&&t.c[e]%2!=0}function v(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function w(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const E=n}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r(4779)})());
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.taquito=e():t.taquito=e()}(self,()=>(()=>{var t={3447(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(6411);function i(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}function s(t,e,r){return void 0===e&&(e=new Uint8Array(2)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}function o(t,e){return void 0===e&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function a(t,e){return void 0===e&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function c(t,e){return void 0===e&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t,e){return void 0===e&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}function l(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}function h(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}function f(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),l(t/4294967296>>>0,e,r),l(t>>>0,e,r+4),e}function d(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),h(t>>>0,e,r),h(t/4294967296>>>0,e,r+4),e}e.readInt16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16},e.readUint16BE=function(t,e){return void 0===e&&(e=0),(t[e+0]<<8|t[e+1])>>>0},e.readInt16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])<<16>>16},e.readUint16LE=function(t,e){return void 0===e&&(e=0),(t[e+1]<<8|t[e])>>>0},e.writeUint16BE=i,e.writeInt16BE=i,e.writeUint16LE=s,e.writeInt16LE=s,e.readInt32BE=o,e.readUint32BE=a,e.readInt32LE=c,e.readUint32LE=u,e.writeUint32BE=l,e.writeInt32BE=l,e.writeUint32LE=h,e.writeInt32LE=h,e.readInt64BE=function(t,e){void 0===e&&(e=0);var r=o(t,e),n=o(t,e+4);return 4294967296*r+n-4294967296*(n>>31)},e.readUint64BE=function(t,e){return void 0===e&&(e=0),4294967296*a(t,e)+a(t,e+4)},e.readInt64LE=function(t,e){void 0===e&&(e=0);var r=c(t,e);return 4294967296*c(t,e+4)+r-4294967296*(r>>31)},e.readUint64LE=function(t,e){void 0===e&&(e=0);var r=u(t,e);return 4294967296*u(t,e+4)+r},e.writeUint64BE=f,e.writeInt64BE=f,e.writeUint64LE=d,e.writeInt64LE=d,e.readUintBE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n},e.readUintLE=function(t,e,r){if(void 0===r&&(r=0),t%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n},e.writeUintBE=function(t,e,r,i){if(void 0===r&&(r=new Uint8Array(t/8)),void 0===i&&(i=0),t%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!n.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var s=1,o=t/8+i-1;o>=i;o--)r[o]=e/s&255,s*=256;return r},e.writeUintLE=function(t,e,r,i){if(void 0===r&&(r=new Uint8Array(t/8)),void 0===i&&(i=0),t%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!n.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var s=1,o=i;o<i+t/8;o++)r[o]=e/s&255,s*=256;return r},e.readFloat32BE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e)},e.readFloat32LE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(e,!0)},e.readFloat64BE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e)},e.readFloat64LE=function(t,e){return void 0===e&&(e=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(e,!0)},e.writeFloat32BE=function(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(r,t),e},e.writeFloat32LE=function(t,e,r){return void 0===e&&(e=new Uint8Array(4)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(r,t,!0),e},e.writeFloat64BE=function(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(r,t),e},e.writeFloat64LE=function(t,e,r){return void 0===e&&(e=new Uint8Array(8)),void 0===r&&(r=0),new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(r,t,!0),e}},2591(t,e){"use strict";function r(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}Object.defineProperty(e,"__esModule",{value:!0}),e.select=function(t,e,r){return~(t-1)&e|t-1&r},e.lessOrEqual=function(t,e){return(0|t)-(0|e)-1>>>31&1},e.compare=r,e.equal=function(t,e){return 0!==t.length&&0!==e.length&&0!==r(t,e)}},6411(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(t,e){var r=65535&t,n=65535&e;return r*n+((t>>>16&65535)*n+r*(e>>>16&65535)<<16>>>0)|0},e.add=function(t,e){return t+e|0},e.sub=function(t,e){return t-e|0},e.rotl=function(t,e){return t<<e|t>>>32-e},e.rotr=function(t,e){return t<<32-e|t>>>e},e.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}},702(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.openBox=e.box=e.precomputeSharedKey=e.generateKeyPair=void 0;const n=r(8877),i=r(1125),s=r(9026),o=r(8767);var a=r(8877);Object.defineProperty(e,"generateKeyPair",{enumerable:!0,get:function(){return a.generateKeyPair}});const c=new Uint8Array(16);function u(t,e){const r=(0,n.scalarMult)(e,t);return(0,i.hsalsa)(r,c,r),r}e.precomputeSharedKey=u,e.box=function(t,e,r,n){const i=u(t,e),a=(0,s.secretBox)(i,r,n);return(0,o.wipe)(i),a},e.openBox=function(t,e,r,n){const i=u(t,e),a=(0,s.openSecretBox)(i,r,n);return(0,o.wipe)(i),a}},2613(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(702),e),i(r(9026),e)},9026(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateKey=e.openSecretBox=e.secretBox=void 0;const n=r(1125),i=r(7591),s=r(8767),o=r(7687);e.secretBox=function(t,e,r){if(24!==e.length)throw new Error("secretBox nonce must be 24 bytes");const o=new Uint8Array(64),a=new Uint8Array(32);a.set(e),(0,n.stream)(t,a,o,8);const c=new Uint8Array(16+r.length);for(let t=0;t<32&&t<r.length;t++)c[16+t]=r[t]^o[32+t];r.length>32&&(0,n.streamXOR)(t,a,r.subarray(32),c.subarray(48),8);const u=(0,i.oneTimeAuth)(o.subarray(0,32),c.subarray(16));for(let t=0;t<u.length;t++)c[t]=u[t];return(0,s.wipe)(u),(0,s.wipe)(o),(0,s.wipe)(a),c},e.openSecretBox=function(t,e,r){if(24!==e.length)throw new Error("secretBox nonce must be 24 bytes");if(r.length<16)throw new Error("secretBox data must be at least 16 bytes");const o=new Uint8Array(64),a=new Uint8Array(32);a.set(e),(0,n.stream)(t,a,o,8);const c=(0,i.oneTimeAuth)(o.subarray(0,32),r.subarray(16));if(!(0,i.equal)(c,r.subarray(0,16)))return null;const u=r.subarray(16),l=new Uint8Array(u.length);for(let t=0;t<32&&t<u.length;t++)l[t]=u[t]^o[32+t];return u.length>32&&(0,n.streamXOR)(t,a,u.subarray(32),l.subarray(32),8),(0,s.wipe)(c),(0,s.wipe)(o),(0,s.wipe)(a),l},e.generateKey=function(t){return(0,o.randomBytes)(32,t)}},7591(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2591),i=r(8767);e.DIGEST_LENGTH=16;var s=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var n=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=t[4]|t[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(t,e,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],l=this._h[6],h=this._h[7],f=this._h[8],d=this._h[9],p=this._r[0],g=this._r[1],m=this._r[2],y=this._r[3],b=this._r[4],v=this._r[5],w=this._r[6],E=this._r[7],_=this._r[8],A=this._r[9];r>=16;){var O=t[e+0]|t[e+1]<<8;i+=8191&O;var S=t[e+2]|t[e+3]<<8;s+=8191&(O>>>13|S<<3);var T=t[e+4]|t[e+5]<<8;o+=8191&(S>>>10|T<<6);var P=t[e+6]|t[e+7]<<8;a+=8191&(T>>>7|P<<9);var R=t[e+8]|t[e+9]<<8;c+=8191&(P>>>4|R<<12),u+=R>>>1&8191;var x=t[e+10]|t[e+11]<<8;l+=8191&(R>>>14|x<<2);var I=t[e+12]|t[e+13]<<8;h+=8191&(x>>>11|I<<5);var N=t[e+14]|t[e+15]<<8,k=0,L=k;L+=i*p,L+=s*(5*A),L+=o*(5*_),L+=a*(5*E),k=(L+=c*(5*w))>>>13,L&=8191,L+=u*(5*v),L+=l*(5*b),L+=h*(5*y),L+=(f+=8191&(I>>>8|N<<8))*(5*m);var C=k+=(L+=(d+=N>>>5|n)*(5*g))>>>13;C+=i*g,C+=s*p,C+=o*(5*A),C+=a*(5*_),k=(C+=c*(5*E))>>>13,C&=8191,C+=u*(5*w),C+=l*(5*v),C+=h*(5*b),C+=f*(5*y),k+=(C+=d*(5*m))>>>13,C&=8191;var M=k;M+=i*m,M+=s*g,M+=o*p,M+=a*(5*A),k=(M+=c*(5*_))>>>13,M&=8191,M+=u*(5*E),M+=l*(5*w),M+=h*(5*v),M+=f*(5*b);var B=k+=(M+=d*(5*y))>>>13;B+=i*y,B+=s*m,B+=o*g,B+=a*p,k=(B+=c*(5*A))>>>13,B&=8191,B+=u*(5*_),B+=l*(5*E),B+=h*(5*w),B+=f*(5*v);var D=k+=(B+=d*(5*b))>>>13;D+=i*b,D+=s*y,D+=o*m,D+=a*g,k=(D+=c*p)>>>13,D&=8191,D+=u*(5*A),D+=l*(5*_),D+=h*(5*E),D+=f*(5*w);var U=k+=(D+=d*(5*v))>>>13;U+=i*v,U+=s*b,U+=o*y,U+=a*m,k=(U+=c*g)>>>13,U&=8191,U+=u*p,U+=l*(5*A),U+=h*(5*_),U+=f*(5*E);var K=k+=(U+=d*(5*w))>>>13;K+=i*w,K+=s*v,K+=o*b,K+=a*y,k=(K+=c*m)>>>13,K&=8191,K+=u*g,K+=l*p,K+=h*(5*A),K+=f*(5*_);var H=k+=(K+=d*(5*E))>>>13;H+=i*E,H+=s*w,H+=o*v,H+=a*b,k=(H+=c*y)>>>13,H&=8191,H+=u*m,H+=l*g,H+=h*p,H+=f*(5*A);var F=k+=(H+=d*(5*_))>>>13;F+=i*_,F+=s*E,F+=o*w,F+=a*v,k=(F+=c*b)>>>13,F&=8191,F+=u*y,F+=l*m,F+=h*g,F+=f*p;var G=k+=(F+=d*(5*A))>>>13;G+=i*A,G+=s*_,G+=o*E,G+=a*w,k=(G+=c*v)>>>13,G&=8191,G+=u*b,G+=l*y,G+=h*m,G+=f*g,i=L=8191&(k=(k=((k+=(G+=d*p)>>>13)<<2)+k|0)+(L&=8191)|0),s=C+=k>>>=13,o=M&=8191,a=B&=8191,c=D&=8191,u=U&=8191,l=K&=8191,h=H&=8191,f=F&=8191,d=G&=8191,e+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=l,this._h[7]=h,this._h[8]=f,this._h[9]=d},t.prototype.finish=function(t,e){void 0===e&&(e=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return t[e+0]=this._h[0]>>>0,t[e+1]=this._h[0]>>>8,t[e+2]=this._h[1]>>>0,t[e+3]=this._h[1]>>>8,t[e+4]=this._h[2]>>>0,t[e+5]=this._h[2]>>>8,t[e+6]=this._h[3]>>>0,t[e+7]=this._h[3]>>>8,t[e+8]=this._h[4]>>>0,t[e+9]=this._h[4]>>>8,t[e+10]=this._h[5]>>>0,t[e+11]=this._h[5]>>>8,t[e+12]=this._h[6]>>>0,t[e+13]=this._h[6]>>>8,t[e+14]=this._h[7]>>>0,t[e+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(t){var e,r=0,n=t.length;if(this._leftover){(e=16-this._leftover)>n&&(e=n);for(var i=0;i<e;i++)this._buffer[this._leftover+i]=t[r+i];if(n-=e,r+=e,this._leftover+=e,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(e=n-n%16,this._blocks(t,r,e),r+=e,n-=e),n){for(i=0;i<n;i++)this._buffer[this._leftover+i]=t[r+i];this._leftover+=n}return this},t.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var t=new Uint8Array(16);return this.finish(t),t},t.prototype.clean=function(){return i.wipe(this._buffer),i.wipe(this._r),i.wipe(this._h),i.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},t}();e.Poly1305=s,e.oneTimeAuth=function(t,e){var r=new s(t);r.update(e);var n=r.digest();return r.clean(),n},e.equal=function(t,r){return t.length===e.DIGEST_LENGTH&&r.length===e.DIGEST_LENGTH&&n.equal(t,r)}},7687(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const n=r(7841),i=r(3447),s=r(8767);function o(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new n.SystemRandomSource,e.randomBytes=o,e.randomUint32=function(t=e.defaultRandomSource){const r=o(4,t),n=(0,i.readUint32LE)(r);return(0,s.wipe)(r),n};const a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(t,r=a,n=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let i="";const c=r.length,u=256-256%c;for(;t>0;){const e=o(Math.ceil(256*t/u),n);for(let n=0;n<e.length&&t>0;n++){const s=e[n];s<u&&(i+=r.charAt(s%c),t--)}(0,s.wipe)(e)}return i}e.randomString=c,e.randomStringForEntropy=function(t,r=a,n=e.defaultRandomSource){return c(Math.ceil(t/(Math.log(r.length)/Math.LN2)),r,n)}},4262(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserRandomSource=void 0;e.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&void 0!==t.getRandomValues&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let t=0;t<e.length;t+=65536)this._crypto.getRandomValues(e.subarray(t,t+Math.min(e.length-t,65536)));return e}}},1052(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NodeRandomSource=void 0;const n=r(8767);e.NodeRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const t=r(5423);t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(t);for(let t=0;t<r.length;t++)r[t]=e[t];return(0,n.wipe)(e),r}}},7841(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SystemRandomSource=void 0;const n=r(4262),i=r(1052);e.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new n.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}},775(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3447),i=r(8767);function s(t,e,r){for(var i,s=1634760805,o=r[3]<<24|r[2]<<16|r[1]<<8|r[0],a=r[7]<<24|r[6]<<16|r[5]<<8|r[4],c=r[11]<<24|r[10]<<16|r[9]<<8|r[8],u=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=857760878,h=e[3]<<24|e[2]<<16|e[1]<<8|e[0],f=e[7]<<24|e[6]<<16|e[5]<<8|e[4],d=e[11]<<24|e[10]<<16|e[9]<<8|e[8],p=e[15]<<24|e[14]<<16|e[13]<<8|e[12],g=2036477234,m=r[19]<<24|r[18]<<16|r[17]<<8|r[16],y=r[23]<<24|r[22]<<16|r[21]<<8|r[20],b=r[27]<<24|r[26]<<16|r[25]<<8|r[24],v=r[31]<<24|r[30]<<16|r[29]<<8|r[28],w=1797285236,E=s,_=o,A=a,O=c,S=u,T=l,P=h,R=f,x=d,I=p,N=g,k=m,L=y,C=b,M=v,B=w,D=0;D<20;D+=2)E^=(i=(L^=(i=(x^=(i=(S^=(i=E+L|0)<<7|i>>>25)+E|0)<<9|i>>>23)+S|0)<<13|i>>>19)+x|0)<<18|i>>>14,T^=(i=(_^=(i=(C^=(i=(I^=(i=T+_|0)<<7|i>>>25)+T|0)<<9|i>>>23)+I|0)<<13|i>>>19)+C|0)<<18|i>>>14,N^=(i=(P^=(i=(A^=(i=(M^=(i=N+P|0)<<7|i>>>25)+N|0)<<9|i>>>23)+M|0)<<13|i>>>19)+A|0)<<18|i>>>14,B^=(i=(k^=(i=(R^=(i=(O^=(i=B+k|0)<<7|i>>>25)+B|0)<<9|i>>>23)+O|0)<<13|i>>>19)+R|0)<<18|i>>>14,E^=(i=(O^=(i=(A^=(i=(_^=(i=E+O|0)<<7|i>>>25)+E|0)<<9|i>>>23)+_|0)<<13|i>>>19)+A|0)<<18|i>>>14,T^=(i=(S^=(i=(R^=(i=(P^=(i=T+S|0)<<7|i>>>25)+T|0)<<9|i>>>23)+P|0)<<13|i>>>19)+R|0)<<18|i>>>14,N^=(i=(I^=(i=(x^=(i=(k^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+k|0)<<13|i>>>19)+x|0)<<18|i>>>14,B^=(i=(M^=(i=(C^=(i=(L^=(i=B+M|0)<<7|i>>>25)+B|0)<<9|i>>>23)+L|0)<<13|i>>>19)+C|0)<<18|i>>>14;n.writeUint32LE(E+s|0,t,0),n.writeUint32LE(_+o|0,t,4),n.writeUint32LE(A+a|0,t,8),n.writeUint32LE(O+c|0,t,12),n.writeUint32LE(S+u|0,t,16),n.writeUint32LE(T+l|0,t,20),n.writeUint32LE(P+h|0,t,24),n.writeUint32LE(R+f|0,t,28),n.writeUint32LE(x+d|0,t,32),n.writeUint32LE(I+p|0,t,36),n.writeUint32LE(N+g|0,t,40),n.writeUint32LE(k+m|0,t,44),n.writeUint32LE(L+y|0,t,48),n.writeUint32LE(C+b|0,t,52),n.writeUint32LE(M+v|0,t,56),n.writeUint32LE(B+w|0,t,60)}function o(t,e,r,n,o){if(void 0===o&&(o=0),32!==t.length)throw new Error("Salsa20: key size must be 32 bytes");if(n.length<r.length)throw new Error("Salsa20: destination is shorter than source");var c,u;if(0===o){if(8!==e.length)throw new Error("Salsa20 nonce must be 8 bytes");(c=new Uint8Array(16)).set(e),u=e.length}else{if(16!==e.length)throw new Error("Salsa20 nonce with counter must be 16 bytes");c=e,u=16-o}for(var l=new Uint8Array(64),h=0;h<r.length;h+=64){s(l,c,t);for(var f=h;f<h+64&&f<r.length;f++)n[f]=r[f]^l[f-h];a(c,u,c.length-u)}return i.wipe(l),0===o&&i.wipe(c),n}function a(t,e,r){for(var n=1;r--;)n=n+(255&t[e])|0,t[e]=255&n,n>>>=8,e++;if(n>0)throw new Error("Salsa20: counter overflow")}e.streamXOR=o,e.stream=function(t,e,r,n){return void 0===n&&(n=0),i.wipe(r),o(t,e,r,r,n)}},8767(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.wipe=function(t){for(var e=0;e<t.length;e++)t[e]=0;return t}},8877(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sharedKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.scalarMultBase=e.scalarMult=e.SHARED_KEY_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=void 0;const n=r(7687),i=r(8767);function s(t){const e=new Float64Array(16);if(t)for(let r=0;r<t.length;r++)e[r]=t[r];return e}e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=32,e.SHARED_KEY_LENGTH=32;const o=new Uint8Array(32);o[0]=9;const a=s([56129,1]);function c(t){let e=1;for(let r=0;r<16;r++){let n=t[r]+e+65535;e=Math.floor(n/65536),t[r]=n-65536*e}t[0]+=e-1+37*(e-1)}function u(t,e,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(t[r]^e[r]);t[r]^=i,e[r]^=i}}function l(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]+r[n]}function h(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]-r[n]}function f(t,e,r){let n,i,s=0,o=0,a=0,c=0,u=0,l=0,h=0,f=0,d=0,p=0,g=0,m=0,y=0,b=0,v=0,w=0,E=0,_=0,A=0,O=0,S=0,T=0,P=0,R=0,x=0,I=0,N=0,k=0,L=0,C=0,M=0,B=r[0],D=r[1],U=r[2],K=r[3],H=r[4],F=r[5],G=r[6],V=r[7],j=r[8],$=r[9],z=r[10],q=r[11],W=r[12],Z=r[13],Y=r[14],X=r[15];n=e[0],s+=n*B,o+=n*D,a+=n*U,c+=n*K,u+=n*H,l+=n*F,h+=n*G,f+=n*V,d+=n*j,p+=n*$,g+=n*z,m+=n*q,y+=n*W,b+=n*Z,v+=n*Y,w+=n*X,n=e[1],o+=n*B,a+=n*D,c+=n*U,u+=n*K,l+=n*H,h+=n*F,f+=n*G,d+=n*V,p+=n*j,g+=n*$,m+=n*z,y+=n*q,b+=n*W,v+=n*Z,w+=n*Y,E+=n*X,n=e[2],a+=n*B,c+=n*D,u+=n*U,l+=n*K,h+=n*H,f+=n*F,d+=n*G,p+=n*V,g+=n*j,m+=n*$,y+=n*z,b+=n*q,v+=n*W,w+=n*Z,E+=n*Y,_+=n*X,n=e[3],c+=n*B,u+=n*D,l+=n*U,h+=n*K,f+=n*H,d+=n*F,p+=n*G,g+=n*V,m+=n*j,y+=n*$,b+=n*z,v+=n*q,w+=n*W,E+=n*Z,_+=n*Y,A+=n*X,n=e[4],u+=n*B,l+=n*D,h+=n*U,f+=n*K,d+=n*H,p+=n*F,g+=n*G,m+=n*V,y+=n*j,b+=n*$,v+=n*z,w+=n*q,E+=n*W,_+=n*Z,A+=n*Y,O+=n*X,n=e[5],l+=n*B,h+=n*D,f+=n*U,d+=n*K,p+=n*H,g+=n*F,m+=n*G,y+=n*V,b+=n*j,v+=n*$,w+=n*z,E+=n*q,_+=n*W,A+=n*Z,O+=n*Y,S+=n*X,n=e[6],h+=n*B,f+=n*D,d+=n*U,p+=n*K,g+=n*H,m+=n*F,y+=n*G,b+=n*V,v+=n*j,w+=n*$,E+=n*z,_+=n*q,A+=n*W,O+=n*Z,S+=n*Y,T+=n*X,n=e[7],f+=n*B,d+=n*D,p+=n*U,g+=n*K,m+=n*H,y+=n*F,b+=n*G,v+=n*V,w+=n*j,E+=n*$,_+=n*z,A+=n*q,O+=n*W,S+=n*Z,T+=n*Y,P+=n*X,n=e[8],d+=n*B,p+=n*D,g+=n*U,m+=n*K,y+=n*H,b+=n*F,v+=n*G,w+=n*V,E+=n*j,_+=n*$,A+=n*z,O+=n*q,S+=n*W,T+=n*Z,P+=n*Y,R+=n*X,n=e[9],p+=n*B,g+=n*D,m+=n*U,y+=n*K,b+=n*H,v+=n*F,w+=n*G,E+=n*V,_+=n*j,A+=n*$,O+=n*z,S+=n*q,T+=n*W,P+=n*Z,R+=n*Y,x+=n*X,n=e[10],g+=n*B,m+=n*D,y+=n*U,b+=n*K,v+=n*H,w+=n*F,E+=n*G,_+=n*V,A+=n*j,O+=n*$,S+=n*z,T+=n*q,P+=n*W,R+=n*Z,x+=n*Y,I+=n*X,n=e[11],m+=n*B,y+=n*D,b+=n*U,v+=n*K,w+=n*H,E+=n*F,_+=n*G,A+=n*V,O+=n*j,S+=n*$,T+=n*z,P+=n*q,R+=n*W,x+=n*Z,I+=n*Y,N+=n*X,n=e[12],y+=n*B,b+=n*D,v+=n*U,w+=n*K,E+=n*H,_+=n*F,A+=n*G,O+=n*V,S+=n*j,T+=n*$,P+=n*z,R+=n*q,x+=n*W,I+=n*Z,N+=n*Y,k+=n*X,n=e[13],b+=n*B,v+=n*D,w+=n*U,E+=n*K,_+=n*H,A+=n*F,O+=n*G,S+=n*V,T+=n*j,P+=n*$,R+=n*z,x+=n*q,I+=n*W,N+=n*Z,k+=n*Y,L+=n*X,n=e[14],v+=n*B,w+=n*D,E+=n*U,_+=n*K,A+=n*H,O+=n*F,S+=n*G,T+=n*V,P+=n*j,R+=n*$,x+=n*z,I+=n*q,N+=n*W,k+=n*Z,L+=n*Y,C+=n*X,n=e[15],w+=n*B,E+=n*D,_+=n*U,A+=n*K,O+=n*H,S+=n*F,T+=n*G,P+=n*V,R+=n*j,x+=n*$,I+=n*z,N+=n*q,k+=n*W,L+=n*Z,C+=n*Y,M+=n*X,s+=38*E,o+=38*_,a+=38*A,c+=38*O,u+=38*S,l+=38*T,h+=38*P,f+=38*R,d+=38*x,p+=38*I,g+=38*N,m+=38*k,y+=38*L,b+=38*C,v+=38*M,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=u,t[5]=l,t[6]=h,t[7]=f,t[8]=d,t[9]=p,t[10]=g,t[11]=m,t[12]=y,t[13]=b,t[14]=v,t[15]=w}function d(t,e){f(t,e,e)}function p(t,e){const r=new Uint8Array(32),n=new Float64Array(80),i=s(),o=s(),p=s(),g=s(),m=s(),y=s();for(let e=0;e<31;e++)r[e]=t[e];r[31]=127&t[31]|64,r[0]&=248,function(t,e){for(let r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}(n,e);for(let t=0;t<16;t++)o[t]=n[t];i[0]=g[0]=1;for(let t=254;t>=0;--t){const e=r[t>>>3]>>>(7&t)&1;u(i,o,e),u(p,g,e),l(m,i,p),h(i,i,p),l(p,o,g),h(o,o,g),d(g,m),d(y,i),f(i,p,i),f(p,o,m),l(m,i,p),h(i,i,p),d(o,i),h(p,g,y),f(i,p,a),l(i,i,g),f(p,p,i),f(i,g,y),f(g,o,n),d(o,m),u(i,o,e),u(p,g,e)}for(let t=0;t<16;t++)n[t+16]=i[t],n[t+32]=p[t],n[t+48]=o[t],n[t+64]=g[t];const b=n.subarray(32),v=n.subarray(16);!function(t,e){const r=s();for(let t=0;t<16;t++)r[t]=e[t];for(let t=253;t>=0;t--)d(r,r),2!==t&&4!==t&&f(r,r,e);for(let e=0;e<16;e++)t[e]=r[e]}(b,b),f(v,v,b);const w=new Uint8Array(32);return function(t,e){const r=s(),n=s();for(let t=0;t<16;t++)n[t]=e[t];c(n),c(n),c(n);for(let t=0;t<2;t++){r[0]=n[0]-65517;for(let t=1;t<15;t++)r[t]=n[t]-65535-(r[t-1]>>16&1),r[t-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const t=r[15]>>16&1;r[14]&=65535,u(n,r,1-t)}for(let e=0;e<16;e++)t[2*e]=255&n[e],t[2*e+1]=n[e]>>8}(w,v),w}function g(t){return p(t,o)}function m(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${e.SECRET_KEY_LENGTH} bytes`);const r=new Uint8Array(t);return{publicKey:g(r),secretKey:r}}e.scalarMult=p,e.scalarMultBase=g,e.generateKeyPairFromSeed=m,e.generateKeyPair=function(t){const e=(0,n.randomBytes)(32,t),r=m(e);return(0,i.wipe)(e),r},e.sharedKey=function(t,r,n=!1){if(t.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const i=p(t,r);if(n){let t=0;for(let e=0;e<i.length;e++)t|=i[e];if(0===t)throw new Error("X25519: invalid shared key")}return i}},1125(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3447),i=r(775),s=r(8767);function o(t,e,r,n,o){if(void 0===o&&(o=0),0===o){if(24!==e.length)throw new Error("XSalsa20 nonce must be 24 bytes")}else if(32!==e.length)throw new Error("XSalsa20 nonce with counter must be 32 bytes");var c=a(t,e.subarray(0,16),new Uint8Array(32)),u=i.streamXOR(c,e.subarray(16),r,n,o);return s.wipe(c),u}e.streamXOR=o,e.stream=function(t,e,r,n){return void 0===n&&(n=0),s.wipe(r),o(t,e,r,r,n)};function a(t,e,r){for(var i,s=1634760805,o=t[3]<<24|t[2]<<16|t[1]<<8|t[0],a=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],u=t[15]<<24|t[14]<<16|t[13]<<8|t[12],l=857760878,h=e[3]<<24|e[2]<<16|e[1]<<8|e[0],f=e[7]<<24|e[6]<<16|e[5]<<8|e[4],d=e[11]<<24|e[10]<<16|e[9]<<8|e[8],p=e[15]<<24|e[14]<<16|e[13]<<8|e[12],g=2036477234,m=t[19]<<24|t[18]<<16|t[17]<<8|t[16],y=t[23]<<24|t[22]<<16|t[21]<<8|t[20],b=t[27]<<24|t[26]<<16|t[25]<<8|t[24],v=t[31]<<24|t[30]<<16|t[29]<<8|t[28],w=1797285236,E=0;E<20;E+=2)s^=(i=(y^=(i=(d^=(i=(u^=(i=s+y|0)<<7|i>>>25)+s|0)<<9|i>>>23)+u|0)<<13|i>>>19)+d|0)<<18|i>>>14,l^=(i=(o^=(i=(b^=(i=(p^=(i=l+o|0)<<7|i>>>25)+l|0)<<9|i>>>23)+p|0)<<13|i>>>19)+b|0)<<18|i>>>14,g^=(i=(h^=(i=(a^=(i=(v^=(i=g+h|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(m^=(i=(f^=(i=(c^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,l^=(i=(u^=(i=(f^=(i=(h^=(i=l+u|0)<<7|i>>>25)+l|0)<<9|i>>>23)+h|0)<<13|i>>>19)+f|0)<<18|i>>>14,g^=(i=(p^=(i=(d^=(i=(m^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+d|0)<<18|i>>>14,w^=(i=(v^=(i=(b^=(i=(y^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+y|0)<<13|i>>>19)+b|0)<<18|i>>>14;return n.writeUint32LE(s,r,0),n.writeUint32LE(l,r,4),n.writeUint32LE(g,r,8),n.writeUint32LE(w,r,12),n.writeUint32LE(h,r,16),n.writeUint32LE(f,r,20),n.writeUint32LE(d,r,24),n.writeUint32LE(p,r,28),r}e.hsalsa=a},7403(t){"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),s=i.charCodeAt(0);if(255!==e[s])throw new TypeError(i+" is ambiguous");e[s]=n}var o=t.length,a=t.charAt(0),c=Math.log(o)/Math.log(256),u=Math.log(256)/Math.log(o);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var s=(t.length-r)*c+1>>>0,u=new Uint8Array(s);t[r];){var l=t.charCodeAt(r);if(l>255)return;var h=e[l];if(255===h)return;for(var f=0,d=s-1;(0!==h||f<i)&&-1!==d;d--,f++)h+=o*u[d]>>>0,u[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=f,r++}for(var p=s-i;p!==s&&0===u[p];)p++;for(var g=new Uint8Array(n+(s-p)),m=n;p!==s;)g[m++]=u[p++];return g}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,s=e.length;i!==s&&0===e[i];)i++,r++;for(var c=(s-i)*u+1>>>0,l=new Uint8Array(c);i!==s;){for(var h=e[i],f=0,d=c-1;(0!==h||f<n)&&-1!==d;d--,f++)h+=256*l[d]>>>0,l[d]=h%o>>>0,h=h/o>>>0;if(0!==h)throw new Error("Non-zero carry");n=f,i++}for(var p=c-n;p!==c&&0===l[p];)p++;for(var g=a.repeat(r);p<c;++p)g+=t.charAt(l[p]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+o+" character")}}}},2823(t,e,r){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8379).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function c(t,e,r){var n=a(t,r);return r-1>=e&&(n|=a(t,r-1)<<4),n}function u(t,e,r,i){for(var s=0,o=0,a=Math.min(t.length,r),c=e;c<a;c++){var u=t.charCodeAt(c)-48;s*=i,o=u>=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&o<i,"Invalid character"),s+=o}return s}function l(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)))},s.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},s.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var s,o,a=0;if("be"===r)for(i=t.length-1,s=0;i>=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(i=0,s=0;i<t.length;i+=3)o=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,s=0,o=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=c(t,e,n)<<s,this.words[o]|=67108863&i,s>=18?(s-=18,o+=1,this.words[o]|=i>>>26):s+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=c(t,e,n)<<s,this.words[o]|=67108863&i,s>=18?(s-=18,o+=1,this.words[o]|=i>>>26):s+=8;this._strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,c=0,l=r;l<a;l+=n)c=u(t,l,l+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==o){var h=1;for(c=u(t,l,t.length,e),l=0;l<o;l++)h*=e;this.imuln(h),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype._move=function(t){l(t,this)},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){s.prototype.inspect=h}else s.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,s=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<i|s)).toString(16);s=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,o--),r=0!==s||o!==this.length-1?f[6-c.length]+c+r:c+r}for(0!==s&&(r=s.toString(16)+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=p[t];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var g=h.modrn(l).toString(t);r=(h=h.idivn(l)).isZero()?g+r:f[u-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function g(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=c>>>26,h=67108863&c,f=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=f;d++){var p=u-d|0;l+=(o=(i=0|t.words[p])*(s=0|e.words[d])+h)/67108864|0,h=67108863&o}r.words[u]=0|h,c=0|l}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}s.prototype.toArrayLike=function(t,e,r){this._strip();var i=this.byteLength(),s=r||Math.max(1,i);n(i<=s,"byte array longer than desired length"),n(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,i),o},s.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,s=0;i<this.length;i++){var o=this.words[i]<<s|n;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===s?(r<t.length&&(t[r++]=o>>24&255),n=0,s=0):(n=o>>>24,s+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},s.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,s=0;i<this.length;i++){var o=this.words[i]<<s|n;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===s?(r>=0&&(t[r--]=o>>24&255),n=0,s=0):(n=o>>>24,s+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},s.prototype.ior=function(t){return n(0===(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},s.prototype.iand=function(t){return n(0===(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},s.prototype.ixor=function(t){return n(0===(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this._strip()},s.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s<n.length;s++)e=(0|r.words[s])+(0|n.words[s])+i,this.words[s]=67108863&e,i=e>>>26;for(;0!==i&&s<r.length;s++)e=(0|r.words[s])+i,this.words[s]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o<n.length;o++)s=(e=(0|r.words[o])-(0|n.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=(0|r.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var m=function(t,e,r){var n,i,s,o=t.words,a=e.words,c=r.words,u=0,l=0|o[0],h=8191&l,f=l>>>13,d=0|o[1],p=8191&d,g=d>>>13,m=0|o[2],y=8191&m,b=m>>>13,v=0|o[3],w=8191&v,E=v>>>13,_=0|o[4],A=8191&_,O=_>>>13,S=0|o[5],T=8191&S,P=S>>>13,R=0|o[6],x=8191&R,I=R>>>13,N=0|o[7],k=8191&N,L=N>>>13,C=0|o[8],M=8191&C,B=C>>>13,D=0|o[9],U=8191&D,K=D>>>13,H=0|a[0],F=8191&H,G=H>>>13,V=0|a[1],j=8191&V,$=V>>>13,z=0|a[2],q=8191&z,W=z>>>13,Z=0|a[3],Y=8191&Z,X=Z>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,lt=0|a[8],ht=8191<,ft=lt>>>13,dt=0|a[9],pt=8191&dt,gt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(n=Math.imul(h,F))|0)+((8191&(i=(i=Math.imul(h,G))+Math.imul(f,F)|0))<<13)|0;u=((s=Math.imul(f,G))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(p,F),i=(i=Math.imul(p,G))+Math.imul(g,F)|0,s=Math.imul(g,G);var yt=(u+(n=n+Math.imul(h,j)|0)|0)+((8191&(i=(i=i+Math.imul(h,$)|0)+Math.imul(f,j)|0))<<13)|0;u=((s=s+Math.imul(f,$)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,F),i=(i=Math.imul(y,G))+Math.imul(b,F)|0,s=Math.imul(b,G),n=n+Math.imul(p,j)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,j)|0,s=s+Math.imul(g,$)|0;var bt=(u+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(f,q)|0))<<13)|0;u=((s=s+Math.imul(f,W)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(w,F),i=(i=Math.imul(w,G))+Math.imul(E,F)|0,s=Math.imul(E,G),n=n+Math.imul(y,j)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(b,j)|0,s=s+Math.imul(b,$)|0,n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,q)|0,s=s+Math.imul(g,W)|0;var vt=(u+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(f,Y)|0))<<13)|0;u=((s=s+Math.imul(f,X)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,F),i=(i=Math.imul(A,G))+Math.imul(O,F)|0,s=Math.imul(O,G),n=n+Math.imul(w,j)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,j)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(b,q)|0,s=s+Math.imul(b,W)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(g,Y)|0,s=s+Math.imul(g,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(f,Q)|0))<<13)|0;u=((s=s+Math.imul(f,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(T,F),i=(i=Math.imul(T,G))+Math.imul(P,F)|0,s=Math.imul(P,G),n=n+Math.imul(A,j)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(O,j)|0,s=s+Math.imul(O,$)|0,n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(E,q)|0,s=s+Math.imul(E,W)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,s=s+Math.imul(g,tt)|0;var Et=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(f,rt)|0))<<13)|0;u=((s=s+Math.imul(f,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(x,F),i=(i=Math.imul(x,G))+Math.imul(I,F)|0,s=Math.imul(I,G),n=n+Math.imul(T,j)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(P,j)|0,s=s+Math.imul(P,$)|0,n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(O,q)|0,s=s+Math.imul(O,W)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(g,rt)|0,s=s+Math.imul(g,nt)|0;var _t=(u+(n=n+Math.imul(h,st)|0)|0)+((8191&(i=(i=i+Math.imul(h,ot)|0)+Math.imul(f,st)|0))<<13)|0;u=((s=s+Math.imul(f,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(k,F),i=(i=Math.imul(k,G))+Math.imul(L,F)|0,s=Math.imul(L,G),n=n+Math.imul(x,j)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(I,j)|0,s=s+Math.imul(I,$)|0,n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,W)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(O,Y)|0,s=s+Math.imul(O,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(b,rt)|0,s=s+Math.imul(b,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(g,st)|0,s=s+Math.imul(g,ot)|0;var At=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(f,ct)|0))<<13)|0;u=((s=s+Math.imul(f,ut)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(M,F),i=(i=Math.imul(M,G))+Math.imul(B,F)|0,s=Math.imul(B,G),n=n+Math.imul(k,j)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(L,j)|0,s=s+Math.imul(L,$)|0,n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,W)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,nt)|0,n=n+Math.imul(y,st)|0,i=(i=i+Math.imul(y,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(g,ct)|0,s=s+Math.imul(g,ut)|0;var Ot=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,ft)|0)+Math.imul(f,ht)|0))<<13)|0;u=((s=s+Math.imul(f,ft)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(U,F),i=(i=Math.imul(U,G))+Math.imul(K,F)|0,s=Math.imul(K,G),n=n+Math.imul(M,j)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(B,j)|0,s=s+Math.imul(B,$)|0,n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(L,q)|0,s=s+Math.imul(L,W)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,X)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(O,rt)|0,s=s+Math.imul(O,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,n=n+Math.imul(y,ct)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(b,ct)|0,s=s+Math.imul(b,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(g,ht)|0,s=s+Math.imul(g,ft)|0;var St=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,gt)|0)+Math.imul(f,pt)|0))<<13)|0;u=((s=s+Math.imul(f,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(U,j),i=(i=Math.imul(U,$))+Math.imul(K,j)|0,s=Math.imul(K,$),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,s=s+Math.imul(B,W)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(L,Y)|0,s=s+Math.imul(L,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,nt)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(E,ct)|0,s=s+Math.imul(E,ut)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ft)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ft)|0;var Tt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((s=s+Math.imul(g,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(U,q),i=(i=Math.imul(U,W))+Math.imul(K,q)|0,s=Math.imul(K,W),n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(B,Y)|0,s=s+Math.imul(B,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(L,Q)|0,s=s+Math.imul(L,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,nt)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,n=n+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(O,ct)|0,s=s+Math.imul(O,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,ft)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ft)|0;var Pt=(u+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(U,Y),i=(i=Math.imul(U,X))+Math.imul(K,Y)|0,s=Math.imul(K,X),n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,Q)|0,s=s+Math.imul(B,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(L,rt)|0,s=s+Math.imul(L,nt)|0,n=n+Math.imul(x,st)|0,i=(i=i+Math.imul(x,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,n=n+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(P,ct)|0,s=s+Math.imul(P,ut)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(O,ht)|0,s=s+Math.imul(O,ft)|0;var Rt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,gt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(U,Q),i=(i=Math.imul(U,tt))+Math.imul(K,Q)|0,s=Math.imul(K,tt),n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,s=s+Math.imul(B,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(L,st)|0,s=s+Math.imul(L,ot)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(I,ct)|0,s=s+Math.imul(I,ut)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ft)|0;var xt=(u+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,gt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,gt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(U,rt),i=(i=Math.imul(U,nt))+Math.imul(K,rt)|0,s=Math.imul(K,nt),n=n+Math.imul(M,st)|0,i=(i=i+Math.imul(M,ot)|0)+Math.imul(B,st)|0,s=s+Math.imul(B,ot)|0,n=n+Math.imul(k,ct)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(L,ct)|0,s=s+Math.imul(L,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,ft)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ft)|0;var It=(u+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,gt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(U,st),i=(i=Math.imul(U,ot))+Math.imul(K,st)|0,s=Math.imul(K,ot),n=n+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(B,ct)|0,s=s+Math.imul(B,ut)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ft)|0)+Math.imul(L,ht)|0,s=s+Math.imul(L,ft)|0;var Nt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,gt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,gt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(U,ct),i=(i=Math.imul(U,ut))+Math.imul(K,ct)|0,s=Math.imul(K,ut),n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(B,ht)|0,s=s+Math.imul(B,ft)|0;var kt=(u+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((s=s+Math.imul(L,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(U,ht),i=(i=Math.imul(U,ft))+Math.imul(K,ht)|0,s=Math.imul(K,ft);var Lt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,gt)|0)+Math.imul(B,pt)|0))<<13)|0;u=((s=s+Math.imul(B,gt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var Ct=(u+(n=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,gt))+Math.imul(K,pt)|0))<<13)|0;return u=((s=Math.imul(K,gt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,c[0]=mt,c[1]=yt,c[2]=bt,c[3]=vt,c[4]=wt,c[5]=Et,c[6]=_t,c[7]=At,c[8]=Ot,c[9]=St,c[10]=Tt,c[11]=Pt,c[12]=Rt,c[13]=xt,c[14]=It,c[15]=Nt,c[16]=kt,c[17]=Lt,c[18]=Ct,0!==u&&(c[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s<r.length-1;s++){var o=i;i=0;for(var a=67108863&n,c=Math.min(s,e.length-1),u=Math.max(0,s-t.length+1);u<=c;u++){var l=s-u,h=(0|t.words[l])*(0|e.words[u]),f=67108863&h;a=67108863&(f=f+a|0),i+=(o=(o=o+(h/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r._strip()}function b(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=g),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?g(this,t,e):r<1024?y(this,t,e):b(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},v.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o<s;o++)n[o]=e[t[o]],i[o]=r[t[o]]},v.prototype.transform=function(t,e,r,n,i,s){this.permute(s,t,e,r,n,i);for(var o=1;o<i;o<<=1)for(var a=o<<1,c=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var h=c,f=u,d=0;d<o;d++){var p=r[l+d],g=n[l+d],m=r[l+d+o],y=n[l+d+o],b=h*m-f*y;y=h*y+f*m,m=b,r[l+d]=p+m,n[l+d]=g+y,r[l+d+o]=p-m,n[l+d+o]=g-y,d!==a&&(b=c*h-u*f,f=c*f+u*h,h=b)}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},v.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},v.prototype.convert13b=function(t,e,r,i){for(var s=0,o=0;o<e;o++)s+=0|t[o],r[2*o]=8191&s,s>>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<i;++o)r[o]=0;n(0===s),n(!(-8192&s))},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},v.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),s=this.stub(n),o=new Array(n),a=new Array(n),c=new Array(n),u=new Array(n),l=new Array(n),h=new Array(n),f=r.words;f.length=n,this.convert13b(t.words,t.length,o,n),this.convert13b(e.words,e.length,u,n),this.transform(o,s,a,c,n,i),this.transform(u,s,l,h,n,i);for(var d=0;d<n;d++){var p=a[d]*l[d]-c[d]*h[d];c[d]=a[d]*h[d]+c[d]*l[d],a[d]=p}return this.conjugate(a,c,n),this.transform(a,c,f,s,n,i),this.conjugate(f,s,n),this.normalize13b(f,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),b(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,i=0;i<this.length;i++){var s=(0|this.words[i])*t,o=(67108863&s)+(67108863&r);r>>=26,r+=s/67108864|0,r+=o>>>26,this.words[i]=67108863&o}return 0!==r&&(this.words[i]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r},s.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,c=(0|this.words[e])-a<<r;this.words[e]=c|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},s.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,c=r;if(i-=o,i=Math.max(0,i),c){for(var u=0;u<o;u++)c.words[u]=this.words[u];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var h=0|this.words[u];this.words[u]=l<<26-s|h>>>s,l=h&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},s.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return 0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,r){var i,s,o=t.length+r;this._expand(o);var a=0;for(i=0;i<t.length;i++){s=(0|this.words[i+r])+a;var c=(0|t.words[i])*e;a=((s-=67108863&c)>>26)-(c/67108864|0),this.words[i+r]=67108863&s}for(;i<this.length-r;i++)a=(s=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&s;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(s=-(0|this.words[i])+a)>>26,this.words[i]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==e){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(i,1,c);0===l.negative&&(n=l,a&&(a.words[c]=1));for(var h=c-1;h>=0;h--){var f=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(f=Math.min(f/o|0,67108863),n._ishlnsubmul(i,f,h);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=f)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!==(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,s=this.length-1;s>=0;s--)i=(r*i+(0|this.words[s]))%t;return e?-i:i},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var s=(0|this.words[i])+67108864*r;this.words[i]=s/t|0,r=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),h=e.clone();!e.isZero();){for(var f=0,d=1;0===(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(l),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var p=0,g=1;0===(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),o.isub(c)):(r.isub(e),a.isub(i),c.isub(o))}return{a,b:c,gcd:r.iushln(u)}},s.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0===(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var h=0,f=1;0===(r.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a)):(r.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return!(1&this.words[0])},s.prototype.isOdd=function(){return!(1&~this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var s=i,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new T(t)},s.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function E(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){E.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){E.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function O(){E.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){E.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function T(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function P(t){T.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}E.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},E.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},E.prototype.split=function(t,e){t.iushrn(this.n,0,e)},E.prototype.imulK=function(t){return t.imul(this.k)},i(_,E),_.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(e.words[e.length++]=s&r,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(o&r)<<4|s>>>22,s=o}s>>>=22,t.words[i-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(A,E),i(O,E),i(S,E),S.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new A;else if("p192"===t)e=new O;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return w[t]=e,e},T.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},T.prototype._verify2=function(t,e){n(0===(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},T.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},T.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},T.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},T.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},T.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},T.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},T.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},T.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},T.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},T.prototype.isqr=function(t){return this.imul(t,t.clone())},T.prototype.sqr=function(t){return this.mul(t,t)},T.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new s(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var h=this.pow(l,i),f=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();n(m<p);var y=this.pow(h,new s(1).iushln(p-m-1));f=f.redMul(y),h=y.redSqr(),d=d.redMul(h),p=m}return f},T.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},T.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new s(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],o=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=c-1;l>=0;l--){var h=u>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==o?(o<<=1,o|=h,(4===++a||0===n&&0===l)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}c=26}return i},T.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},T.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new P(t)},i(P,T),P.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},P.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},P.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},P.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t=r.nmd(t),this)},9216(t,e,r){const n=r(7403);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},7639(t,e,r){"use strict";var n=r(9216);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=Uint8Array.from(e),i=t(r),s=r.length+4,o=new Uint8Array(s);return o.set(r,0),o.set(i.subarray(0,4),r.length),n.encode(o,s)},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)}}}},9848(t,e,r){"use strict";var{sha256:n}=r(2001),i=r(7639);t.exports=i(function(t){return n(n(t))})},6075(t){"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]},s={key:n,value:t[n]};return r(i,s)}}),s=[];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,o;if(Array.isArray(e)){for(o="[",r=0;r<e.length;r++)r&&(o+=","),o+=t(e[r])||"null";return o+"]"}if(null===e)return"null";if(-1!==s.indexOf(e)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(e)-1,c=Object.keys(e).sort(i&&i(e));for(o="",r=0;r<c.length;r++){var u=c[r],l=t(e[u]);l&&(o&&(o+=","),o+=JSON.stringify(u)+":"+l)}return s.splice(a,1),"{"+o+"}"}}(t)}},3737(t,e,r){!function(t){"use strict";function e(t){for(var e=0,r=Math.min(65536,t.length+1),n=new Uint16Array(r),i=[],s=0;;){var o=e<t.length;if(!o||s>=r-1){var a=n.subarray(0,s);if(i.push(String.fromCharCode.apply(null,a)),!o)return i.join("");t=t.subarray(e),e=0,s=0}var c=t[e++];if(128&c){if(192==(224&c)){var u=63&t[e++];n[s++]=(31&c)<<6|u}else if(224==(240&c)){u=63&t[e++];var l=63&t[e++];n[s++]=(31&c)<<12|u<<6|l}else if(240==(248&c)){var h=(7&c)<<18|(u=63&t[e++])<<12|(l=63&t[e++])<<6|63&t[e++];h>65535&&(h-=65536,n[s++]=h>>>10&1023|55296,h=56320|1023&h),n[s++]=h}}else n[s++]=c}}var r="Failed to ",n=function(t,e,n){if(t)throw new Error("".concat(r).concat(e,": the '").concat(n,"' option is unsupported."))},i="function"==typeof Buffer&&Buffer.from,s=i?function(t){return Buffer.from(t)}:function(t){for(var e=0,r=t.length,n=0,i=Math.max(32,r+(r>>>1)+7),s=new Uint8Array(i>>>3<<3);e<r;){var o=t.charCodeAt(e++);if(o>=55296&&o<=56319){if(e<r){var a=t.charCodeAt(e);56320==(64512&a)&&(++e,o=((1023&o)<<10)+(1023&a)+65536)}if(o>=55296&&o<=56319)continue}if(n+4>s.length){i+=8,i=(i*=1+e/t.length*2)>>>3<<3;var c=new Uint8Array(i);c.set(s),s=c}if(4294967168&o){if(4294965248&o)if(4294901760&o){if(4292870144&o)continue;s[n++]=o>>>18&7|240,s[n++]=o>>>12&63|128,s[n++]=o>>>6&63|128}else s[n++]=o>>>12&15|224,s[n++]=o>>>6&63|128;else s[n++]=o>>>6&31|192;s[n++]=63&o|128}else s[n++]=o}return s.slice?s.slice(0,n):s.subarray(0,n)};function o(){this.encoding="utf-8"}o.prototype.encode=function(t,e){return n(e&&e.stream,"encode","stream"),s(t)};var a=!i&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,c=["utf-8","utf8","unicode-1-1-utf-8"],u=e;i?u=function(t,e){return(t instanceof Buffer?t:Buffer.from(t.buffer,t.byteOffset,t.byteLength)).toString(e)}:a&&(u=function(t){try{return function(t){var e;try{var r=new Blob([t],{type:"text/plain;charset=UTF-8"});e=URL.createObjectURL(r);var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(),n.responseText}finally{e&&URL.revokeObjectURL(e)}}(t)}catch(r){return e(t)}});var l="construct 'TextDecoder'",h="".concat(r," ").concat(l,": the ");function f(t,e){if(n(e&&e.fatal,l,"fatal"),t=t||"utf-8",!(i?Buffer.isEncoding(t):-1!==c.indexOf(t.toLowerCase())))throw new RangeError("".concat(h," encoding label provided ('").concat(t,"') is invalid."));this.encoding=t,this.fatal=!1,this.ignoreBOM=!1}f.prototype.decode=function(t,e){var r;return n(e&&e.stream,"decode","stream"),r=t instanceof Uint8Array?t:t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer):new Uint8Array(t),u(r,this.encoding)},t.TextEncoder=t.TextEncoder||o,t.TextDecoder=t.TextDecoder||f}("undefined"!=typeof window?window:void 0!==r.g?r.g:this)},1948(t,e,r){"use strict";r.r(e),r.d(e,{ArgumentOutOfRangeError:()=>J.k,AsyncSubject:()=>y.h,BehaviorSubject:()=>g.t,ConnectableObservable:()=>i.G,EMPTY:()=>yt.w,EmptyError:()=>Z.G,NEVER:()=>Ut,NotFoundError:()=>Q.m,Notification:()=>V.Eg,NotificationKind:()=>V.Ij,ObjectUnsubscribedError:()=>tt.P,Observable:()=>n.c,ReplaySubject:()=>m.m,Scheduler:()=>F._,SequenceError:()=>et.I,Subject:()=>p.B,Subscriber:()=>G.vU,Subscription:()=>c.yU,TimeoutError:()=>rt.M,UnsubscriptionError:()=>nt.Z,VirtualAction:()=>H,VirtualTimeScheduler:()=>K,animationFrame:()=>U,animationFrameScheduler:()=>D,animationFrames:()=>l,asap:()=>x,asapScheduler:()=>R,async:()=>I.b,asyncScheduler:()=>I.E,audit:()=>te.s,auditTime:()=>ee.Z,bindCallback:()=>ut,bindNodeCallback:()=>lt,buffer:()=>re.r,bufferCount:()=>ne.S,bufferTime:()=>ie.w,bufferToggle:()=>se.H,bufferWhen:()=>oe.n,catchError:()=>ae.W,combineAll:()=>ce.p,combineLatest:()=>ht.z,combineLatestAll:()=>ue.A,combineLatestWith:()=>le.v,concat:()=>ft.x,concatAll:()=>he.K,concatMap:()=>fe.H,concatMapTo:()=>de.S,concatWith:()=>pe.$,config:()=>Qt.$,connect:()=>ge.N,connectable:()=>mt,count:()=>me.U,debounce:()=>ye.s,debounceTime:()=>be.B,defaultIfEmpty:()=>ve.U,defer:()=>pt,delay:()=>we.c,delayWhen:()=>Ee.o,dematerialize:()=>_e.Z,distinct:()=>Ae.d,distinctUntilChanged:()=>Oe.F,distinctUntilKeyChanged:()=>Se.w,elementAt:()=>Te.s,empty:()=>yt.I,endWith:()=>Pe.q,every:()=>Re.S,exhaust:()=>xe.B,exhaustAll:()=>Ie.C,exhaustMap:()=>Ne.p,expand:()=>ke.f,filter:()=>jt.p,finalize:()=>Le.j,find:()=>Ce.I,findIndex:()=>Me.S,first:()=>Be.$,firstValueFrom:()=>X,flatMap:()=>$e.q,forkJoin:()=>_t,from:()=>At.H,fromEvent:()=>xt,fromEventPattern:()=>Nt,generate:()=>Lt,groupBy:()=>De.$,identity:()=>z.D,ignoreElements:()=>Ue.w,iif:()=>Ct,interval:()=>Mt.Y,isEmpty:()=>Ke.I,isObservable:()=>W,last:()=>He.H,lastValueFrom:()=>Y,map:()=>Fe.T,mapTo:()=>Ge.u,materialize:()=>Ve.O,max:()=>je.T,merge:()=>Dt,mergeAll:()=>Bt.U,mergeMap:()=>Ot.Z,mergeMapTo:()=>ze.C,mergeScan:()=>qe.i,mergeWith:()=>We.X,min:()=>Ze.j,multicast:()=>Ye.f,never:()=>Kt,noop:()=>$.l,observable:()=>s.s,observeOn:()=>at.Q,of:()=>Ht.of,onErrorResumeNext:()=>Ft.g,onErrorResumeNextWith:()=>Xe.w,pairs:()=>Gt,pairwise:()=>Je.J,partition:()=>$t,pipe:()=>j.F,pluck:()=>Qe.E,publish:()=>tr.m,publishBehavior:()=>er.K,publishLast:()=>rr.k,publishReplay:()=>nr.H,queue:()=>C,queueScheduler:()=>L,race:()=>zt.O,raceWith:()=>ir.w,range:()=>qt,reduce:()=>sr.T,refCount:()=>lr.B,repeat:()=>or.u,repeatWhen:()=>ar.Y,retry:()=>cr.L,retryWhen:()=>ur.l,sample:()=>hr.X,sampleTime:()=>fr.q,scan:()=>dr.S,scheduled:()=>Jt.c,sequenceEqual:()=>pr.m,share:()=>gr.u,shareReplay:()=>mr.t,single:()=>yr.J,skip:()=>br.i,skipLast:()=>vr.G,skipUntil:()=>wr.U,skipWhile:()=>Er.j,startWith:()=>_r.Z,subscribeOn:()=>st._,switchAll:()=>Ar.w,switchMap:()=>Or.n,switchMapTo:()=>Sr.K,switchScan:()=>Tr.m,take:()=>Pr.s,takeLast:()=>Rr.o,takeUntil:()=>xr.Q,takeWhile:()=>Ir.v,tap:()=>Nr.M,throttle:()=>kr.n,throttleTime:()=>Lr.c,throwError:()=>Wt.$,throwIfEmpty:()=>Cr.v,timeInterval:()=>Mr.f,timeout:()=>rt.w,timeoutWith:()=>Br.o,timer:()=>Zt.O,timestamp:()=>Dr.v,toArray:()=>Ur.$,using:()=>Yt,window:()=>Kr.x,windowCount:()=>Hr.k,windowTime:()=>Fr.s,windowToggle:()=>Gr.J,windowWhen:()=>Vr.p,withLatestFrom:()=>jr.E,zip:()=>Xt.y,zipAll:()=>$r.x,zipWith:()=>zr.O});var n=r(1824),i=r(5900),s=r(9805),o={now:function(){return(o.delegate||performance).now()},delegate:void 0},a=r(5608),c=r(1868),u={schedule:function(t){var e=requestAnimationFrame,r=cancelAnimationFrame,n=u.delegate;n&&(e=n.requestAnimationFrame,r=n.cancelAnimationFrame);var i=e(function(e){r=void 0,t(e)});return new c.yU(function(){return null==r?void 0:r(i)})},requestAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=u.delegate;return((null==r?void 0:r.requestAnimationFrame)||requestAnimationFrame).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},cancelAnimationFrame:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=u.delegate;return((null==r?void 0:r.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},delegate:void 0};function l(t){return t?h(t):d}function h(t){return new n.c(function(e){var r=t||o,n=r.now(),i=0,s=function(){e.closed||(i=u.requestAnimationFrame(function(o){i=0;var a=r.now();e.next({timestamp:t?a:o,elapsed:a-n}),s()}))};return s(),function(){i&&u.cancelAnimationFrame(i)}})}var f,d=h(),p=r(9097),g=r(5923),m=r(5404),y=r(5445),b=r(7771),v=1,w={};function E(t){return t in w&&(delete w[t],!0)}var _=function(t){var e=v++;return w[e]=!0,f||(f=Promise.resolve()),f.then(function(){return E(e)&&t()}),e},A=function(t){E(t)},O={setImmediate:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=O.delegate;return((null==r?void 0:r.setImmediate)||_).apply(void 0,(0,a.fX)([],(0,a.zs)(t)))},clearImmediate:function(t){var e=O.delegate;return((null==e?void 0:e.clearImmediate)||A)(t)},delegate:void 0},S=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=O.setImmediate(e.flush.bind(e,void 0))))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var s=e.actions;null!=r&&(null===(i=s[s.length-1])||void 0===i?void 0:i.id)!==r&&(O.clearImmediate(r),e._scheduled===r&&(e._scheduled=void 0))},e}(b.R),T=r(7042),P=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e.prototype.flush=function(t){this._active=!0;var e=this._scheduled;this._scheduled=void 0;var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(T.q),R=new P(S),x=R,I=r(4611),N=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(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),0)},e}(b.R),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e}(T.q),L=new k(N),C=L,M=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return(0,a.C6)(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e._scheduled||(e._scheduled=u.requestAnimationFrame(function(){return e.flush(void 0)})))},e.prototype.recycleAsyncId=function(e,r,n){var i;if(void 0===n&&(n=0),null!=n?n>0:this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);var s=e.actions;null!=r&&r===e._scheduled&&(null===(i=s[s.length-1])||void 0===i?void 0:i.id)!==r&&(u.cancelAnimationFrame(r),e._scheduled=void 0)},e}(b.R),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,a.C6)(e,t),e.prototype.flush=function(t){var e;this._active=!0,t?e=t.id:(e=this._scheduled,this._scheduled=void 0);var r,n=this.actions;t=t||n.shift();do{if(r=t.execute(t.state,t.delay))break}while((t=n[0])&&t.id===e&&n.shift());if(this._active=!1,r){for(;(t=n[0])&&t.id===e&&n.shift();)t.unsubscribe();throw r}},e}(T.q),D=new B(M),U=D,K=function(t){function e(e,r){void 0===e&&(e=H),void 0===r&&(r=1/0);var n=t.call(this,e,function(){return n.frame})||this;return n.maxFrames=r,n.frame=0,n.index=-1,n}return(0,a.C6)(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,n=this.maxFrames;(e=r[0])&&e.delay<=n&&(r.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(T.q),H=function(t){function e(e,r,n){void 0===n&&(n=e.index+=1);var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.index=n,i.active=!0,i.index=e.index=n,i}return(0,a.C6)(e,t),e.prototype.schedule=function(r,n){if(void 0===n&&(n=0),Number.isFinite(n)){if(!this.id)return t.prototype.schedule.call(this,r,n);this.active=!1;var i=new e(this.scheduler,this.work);return this.add(i),i.schedule(r,n)}return c.yU.EMPTY},e.prototype.requestAsyncId=function(t,r,n){void 0===n&&(n=0),this.delay=t.frame+n;var i=t.actions;return i.push(this),i.sort(e.sortActions),1},e.prototype.recycleAsyncId=function(t,e,r){void 0===r&&(r=0)},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(b.R),F=r(4644),G=r(557),V=r(8666),j=r(3404),$=r(2508),z=r(4254),q=r(4460);function W(t){return!!t&&(t instanceof n.c||(0,q.T)(t.lift)&&(0,q.T)(t.subscribe))}var Z=r(1585);function Y(t,e){var r="object"==typeof e;return new Promise(function(n,i){var s,o=!1;t.subscribe({next:function(t){s=t,o=!0},error:i,complete:function(){o?n(s):r?n(e.defaultValue):i(new Z.G)}})})}function X(t,e){var r="object"==typeof e;return new Promise(function(n,i){var s=new G.Ms({next:function(t){n(t),s.unsubscribe()},error:i,complete:function(){r?n(e.defaultValue):i(new Z.G)}});t.subscribe(s)})}var J=r(5339),Q=r(1753),tt=r(8032),et=r(6611),rt=r(3572),nt=r(402),it=r(1867),st=r(6518),ot=r(4981),at=r(5106);function ct(t,e,r,i){if(r){if(!(0,it.m)(r))return function(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];return ct(t,e,i).apply(this,n).pipe((0,ot.I)(r))};i=r}return i?function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return ct(t,e).apply(this,r).pipe((0,st._)(i),(0,at.Q)(i))}:function(){for(var r=this,i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];var o=new y.h,c=!0;return new n.c(function(n){var s=o.subscribe(n);if(c){c=!1;var u=!1,l=!1;e.apply(r,(0,a.fX)((0,a.fX)([],(0,a.zs)(i)),[function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(t){var n=e.shift();if(null!=n)return void o.error(n)}o.next(1<e.length?e:e[0]),l=!0,u&&o.complete()}])),l&&o.complete(),u=!0}return s})}}function ut(t,e,r){return ct(!1,t,e,r)}function lt(t,e,r){return ct(!0,t,e,r)}var ht=r(4817),ft=r(7083),dt=r(6195);function pt(t){return new n.c(function(e){(0,dt.Tg)(t()).subscribe(e)})}var gt={connector:function(){return new p.B},resetOnDisconnect:!0};function mt(t,e){void 0===e&&(e=gt);var r=null,i=e.connector,s=e.resetOnDisconnect,o=void 0===s||s,a=i(),c=new n.c(function(t){return a.subscribe(t)});return c.connect=function(){return r&&!r.closed||(r=pt(function(){return t}).subscribe(a),o&&r.add(function(){return a=i()})),r},c}var yt=r(1166),bt=r(1854),vt=r(5361),wt=r(869),Et=r(9407);function _t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,vt.ms)(t),i=(0,bt.D)(t),s=i.args,o=i.keys,a=new n.c(function(t){var e=s.length;if(e)for(var r=new Array(e),n=e,i=e,a=function(e){var a=!1;(0,dt.Tg)(s[e]).subscribe((0,wt._)(t,function(t){a||(a=!0,i--),r[e]=t},function(){return n--},void 0,function(){n&&a||(i||t.next(o?(0,Et.e)(o,r):r),t.complete())}))},c=0;c<e;c++)a(c);else t.complete()});return r?a.pipe((0,ot.I)(r)):a}var At=r(5315),Ot=r(6961),St=r(1604),Tt=["addListener","removeListener"],Pt=["addEventListener","removeEventListener"],Rt=["on","off"];function xt(t,e,r,i){if((0,q.T)(r)&&(i=r,r=void 0),i)return xt(t,e,r).pipe((0,ot.I)(i));var s=(0,a.zs)(function(t){return(0,q.T)(t.addEventListener)&&(0,q.T)(t.removeEventListener)}(t)?Pt.map(function(n){return function(i){return t[n](e,i,r)}}):function(t){return(0,q.T)(t.addListener)&&(0,q.T)(t.removeListener)}(t)?Tt.map(It(t,e)):function(t){return(0,q.T)(t.on)&&(0,q.T)(t.off)}(t)?Rt.map(It(t,e)):[],2),o=s[0],c=s[1];if(!o&&(0,St.X)(t))return(0,Ot.Z)(function(t){return xt(t,e,r)})((0,dt.Tg)(t));if(!o)throw new TypeError("Invalid event target");return new n.c(function(t){var e=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.next(1<e.length?e:e[0])};return o(e),function(){return c(e)}})}function It(t,e){return function(r){return function(n){return t[r](e,n)}}}function Nt(t,e,r){return r?Nt(t,e).pipe((0,ot.I)(r)):new n.c(function(r){var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.next(1===t.length?t[0]:t)},i=t(n);return(0,q.T)(e)?function(){return e(n,i)}:void 0})}var kt=r(9862);function Lt(t,e,r,n,i){var s,o,c,u;function l(){var t;return(0,a.YH)(this,function(n){switch(n.label){case 0:t=u,n.label=1;case 1:return e&&!e(t)?[3,4]:[4,c(t)];case 2:n.sent(),n.label=3;case 3:return t=r(t),[3,1];case 4:return[2]}})}return 1===arguments.length?(u=(s=t).initialState,e=s.condition,r=s.iterate,o=s.resultSelector,c=void 0===o?z.D:o,i=s.scheduler):(u=t,!n||(0,it.m)(n)?(c=z.D,i=n):c=n),pt(i?function(){return(0,kt.S)(l(),i)}:l)}function Ct(t,e,r){return pt(function(){return t()?e:r})}var Mt=r(6726),Bt=r(9904);function Dt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,vt.lI)(t),n=(0,vt.R0)(t,1/0),i=t;return i.length?1===i.length?(0,dt.Tg)(i[0]):(0,Bt.U)(n)((0,At.H)(i,r)):yt.w}var Ut=new n.c($.l);function Kt(){return Ut}var Ht=r(5118),Ft=r(6864);function Gt(t,e){return(0,At.H)(Object.entries(t),e)}var Vt=r(8371),jt=r(465);function $t(t,e,r){return[(0,jt.p)(e,r)((0,dt.Tg)(t)),(0,jt.p)((0,Vt.A)(e,r))((0,dt.Tg)(t))]}var zt=r(6394);function qt(t,e,r){if(null==e&&(e=t,t=0),e<=0)return yt.w;var i=e+t;return new n.c(r?function(e){var n=t;return r.schedule(function(){n<i?(e.next(n++),this.schedule()):e.complete()})}:function(e){for(var r=t;r<i&&!e.closed;)e.next(r++);e.complete()})}var Wt=r(5933),Zt=r(6302);function Yt(t,e){return new n.c(function(r){var n=t(),i=e(n);return(i?(0,dt.Tg)(i):yt.w).subscribe(r),function(){n&&n.unsubscribe()}})}var Xt=r(9568),Jt=r(489),Qt=r(747),te=r(4168),ee=r(7013),re=r(9801),ne=r(9542),ie=r(3132),se=r(6145),oe=r(6689),ae=r(672),ce=r(8363),ue=r(9142),le=r(8957),he=r(2348),fe=r(949),de=r(4292),pe=r(4011),ge=r(1715),me=r(6456),ye=r(9780),be=r(5833),ve=r(4228),we=r(2840),Ee=r(6660),_e=r(1023),Ae=r(7435),Oe=r(5519),Se=r(5538),Te=r(6026),Pe=r(7566),Re=r(5060),xe=r(8017),Ie=r(5598),Ne=r(5711),ke=r(2467),Le=r(8553),Ce=r(4732),Me=r(5206),Be=r(4053),De=r(7333),Ue=r(9756),Ke=r(3694),He=r(2187),Fe=r(8045),Ge=r(3692),Ve=r(6326),je=r(7877),$e=r(9016),ze=r(2720),qe=r(26),We=r(6343),Ze=r(8287),Ye=r(3045),Xe=r(1264),Je=r(9127),Qe=r(8614),tr=r(1996),er=r(9514),rr=r(2812),nr=r(4679),ir=r(8702),sr=r(8933),or=r(744),ar=r(1204),cr=r(9185),ur=r(1478),lr=r(8815),hr=r(7073),fr=r(84),dr=r(510),pr=r(4112),gr=r(1452),mr=r(4103),yr=r(4623),br=r(3616),vr=r(5152),wr=r(3430),Er=r(9955),_r=r(8263),Ar=r(5056),Or=r(8737),Sr=r(1200),Tr=r(2570),Pr=r(5172),Rr=r(3172),xr=r(1762),Ir=r(247),Nr=r(8322),kr=r(8359),Lr=r(626),Cr=r(5007),Mr=r(5223),Br=r(3868),Dr=r(6715),Ur=r(2033),Kr=r(6063),Hr=r(1252),Fr=r(8442),Gr=r(8771),Vr=r(63),jr=r(6248),$r=r(137),zr=r(464)},5445(t,e,r){"use strict";r.d(e,{h:()=>i});var n=r(5608),i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._value=null,e._hasValue=!1,e._isComplete=!1,e}return(0,n.C6)(e,t),e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e._hasValue,i=e._value,s=e.thrownError,o=e.isStopped,a=e._isComplete;r?t.error(s):(o||a)&&(n&&t.next(i),t.complete())},e.prototype.next=function(t){this.isStopped||(this._value=t,this._hasValue=!0)},e.prototype.complete=function(){var e=this,r=e._hasValue,n=e._value;e._isComplete||(this._isComplete=!0,r&&t.prototype.next.call(this,n),t.prototype.complete.call(this))},e}(r(9097).B)},5923(t,e,r){"use strict";r.d(e,{t:()=>i});var n=r(5608),i=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return(0,n.C6)(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){var t=this,e=t.hasError,r=t.thrownError,n=t._value;if(e)throw r;return this._throwIfClosed(),n},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(r(9097).B)},8666(t,e,r){"use strict";r.d(e,{Eg:()=>c,Ij:()=>n,gV:()=>u});var n,i=r(1166),s=r(5118),o=r(5933),a=r(4460);!function(t){t.NEXT="N",t.ERROR="E",t.COMPLETE="C"}(n||(n={}));var c=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){return u(this,t)},t.prototype.do=function(t,e,r){var n=this,i=n.kind,s=n.value,o=n.error;return"N"===i?null==t?void 0:t(s):"E"===i?null==e?void 0:e(o):null==r?void 0:r()},t.prototype.accept=function(t,e,r){var n;return(0,a.T)(null===(n=t)||void 0===n?void 0:n.next)?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){var t=this,e=t.kind,r=t.value,n=t.error,a="N"===e?(0,s.of)(r):"E"===e?(0,o.$)(function(){return n}):"C"===e?i.w:0;if(!a)throw new TypeError("Unexpected notification kind "+e);return a},t.createNext=function(e){return new t("N",e)},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t}();function u(t,e){var r,n,i,s=t,o=s.kind,a=s.value,c=s.error;if("string"!=typeof o)throw new TypeError('Invalid notification, missing "kind"');"N"===o?null===(r=e.next)||void 0===r||r.call(e,a):"E"===o?null===(n=e.error)||void 0===n||n.call(e,c):null===(i=e.complete)||void 0===i||i.call(e)}},1824(t,e,r){"use strict";r.d(e,{c:()=>l});var n=r(557),i=r(1868),s=r(9805),o=r(3404),a=r(747),c=r(4460),u=r(7861),l=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var s,o=this,a=(s=t)&&s instanceof n.vU||function(t){return t&&(0,c.T)(t.next)&&(0,c.T)(t.error)&&(0,c.T)(t.complete)}(s)&&(0,i.Uv)(s)?t:new n.Ms(t,e,r);return(0,u.Y)(function(){var t=o,e=t.operator,r=t.source;a.add(e?e.call(a,r):r?o._subscribe(a):o._trySubscribe(a))}),a},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=h(e))(function(e,i){var s=new n.Ms({next:function(e){try{t(e)}catch(t){i(t),s.unsubscribe()}},error:i,complete:e});r.subscribe(s)})},t.prototype._subscribe=function(t){var e;return null===(e=this.source)||void 0===e?void 0:e.subscribe(t)},t.prototype[s.s]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,o.m)(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=h(t))(function(t,r){var n;e.subscribe(function(t){return n=t},function(t){return r(t)},function(){return t(n)})})},t.create=function(e){return new t(e)},t}();function h(t){var e;return null!==(e=null!=t?t:a.$.Promise)&&void 0!==e?e:Promise}},5404(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(5608),i=r(9097),s=r(8154),o=function(t){function e(e,r,n){void 0===e&&(e=1/0),void 0===r&&(r=1/0),void 0===n&&(n=s.U);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,r),i}return(0,n.C6)(e,t),e.prototype.next=function(e){var r=this,n=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,o=r._timestampProvider,a=r._windowTime;n||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!t.closed;i+=r?1:2)t.next(n[i]);return this._checkFinalizedStatuses(t),e},e.prototype._trimBuffer=function(){var t=this,e=t._bufferSize,r=t._timestampProvider,n=t._buffer,i=t._infiniteTimeWindow,s=(i?1:2)*e;if(e<1/0&&s<n.length&&n.splice(0,n.length-s),!i){for(var o=r.now(),a=0,c=1;c<n.length&&n[c]<=o;c+=2)a=c;a&&n.splice(0,a+1)}},e}(i.B)},4644(t,e,r){"use strict";r.d(e,{_:()=>i});var n=r(8154),i=function(){function t(e,r){void 0===r&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},t.now=n.U.now,t}()},9097(t,e,r){"use strict";r.d(e,{B:()=>u});var n=r(5608),i=r(1824),s=r(1868),o=r(8032),a=r(1601),c=r(7861),u=function(t){function e(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return(0,n.C6)(e,t),e.prototype.lift=function(t){var e=new l(this,this);return e.operator=t,e},e.prototype._throwIfClosed=function(){if(this.closed)throw new o.P},e.prototype.next=function(t){var e=this;(0,c.Y)(function(){var r,i;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var s=(0,n.Ju)(e.currentObservers),o=s.next();!o.done;o=s.next()){o.value.next(t)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}})},e.prototype.error=function(t){var e=this;(0,c.Y)(function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=t;for(var r=e.observers;r.length;)r.shift().error(t)}})},e.prototype.complete=function(){var t=this;(0,c.Y)(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var e=t.observers;e.length;)e.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?s.Kn:(this.currentObservers=null,o.push(t),new s.yU(function(){e.currentObservers=null,(0,a.o)(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var e=this,r=e.hasError,n=e.thrownError,i=e.isStopped;r?t.error(n):i&&t.complete()},e.prototype.asObservable=function(){var t=new i.c;return t.source=this,t},e.create=function(t,e){return new l(t,e)},e}(i.c),l=function(t){function e(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return(0,n.C6)(e,t),e.prototype.next=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===r||r.call(e,t)},e.prototype.error=function(t){var e,r;null===(r=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===r||r.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,r;return null!==(r=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==r?r:s.Kn},e}(u)},557(t,e,r){"use strict";r.d(e,{Ms:()=>y,vU:()=>d});var n=r(5608),i=r(4460),s=r(1868),o=r(747),a=r(3585),c=r(2508),u=l("C",void 0,void 0);function l(t,e,r){return{kind:t,value:e,error:r}}var h=r(533),f=r(7861),d=function(t){function e(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,(0,s.Uv)(e)&&e.add(r)):r.destination=w,r}return(0,n.C6)(e,t),e.create=function(t,e,r){return new y(t,e,r)},e.prototype.next=function(t){this.isStopped?v(function(t){return l("N",t,void 0)}(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?v(l("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?v(u,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(s.yU),p=Function.prototype.bind;function g(t,e){return p.call(t,e)}var m=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){b(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){b(t)}else b(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){b(t)}},t}(),y=function(t){function e(e,r,n){var s,a,c=t.call(this)||this;(0,i.T)(e)||!e?s={next:null!=e?e:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:c&&o.$.useDeprecatedNextContext?((a=Object.create(e)).unsubscribe=function(){return c.unsubscribe()},s={next:e.next&&g(e.next,a),error:e.error&&g(e.error,a),complete:e.complete&&g(e.complete,a)}):s=e;return c.destination=new m(s),c}return(0,n.C6)(e,t),e}(d);function b(t){o.$.useDeprecatedSynchronousErrorHandling?(0,f.l)(t):(0,a.m)(t)}function v(t,e){var r=o.$.onStoppedNotification;r&&h.f.setTimeout(function(){return r(t,e)})}var w={closed:!0,next:c.l,error:function(t){throw t},complete:c.l}},1868(t,e,r){"use strict";r.d(e,{Kn:()=>c,Uv:()=>u,yU:()=>a});var n=r(5608),i=r(4460),s=r(402),o=r(1601),a=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var e;return t.prototype.unsubscribe=function(){var t,e,r,o,a;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var u=(0,n.Ju)(c),h=u.next();!h.done;h=u.next()){h.value.remove(this)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}else c.remove(this);var f=this.initialTeardown;if((0,i.T)(f))try{f()}catch(t){a=t instanceof s.Z?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=(0,n.Ju)(d),g=p.next();!g.done;g=p.next()){var m=g.value;try{l(m)}catch(t){a=null!=a?a:[],t instanceof s.Z?a=(0,n.fX)((0,n.fX)([],(0,n.zs)(a)),(0,n.zs)(t.errors)):a.push(t)}}}catch(t){r={error:t}}finally{try{g&&!g.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}if(a)throw new s.Z(a)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)l(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(e)}},t.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},t.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},t.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&(0,o.o)(e,t)},t.prototype.remove=function(e){var r=this._finalizers;r&&(0,o.o)(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=((e=new t).closed=!0,e),t}(),c=a.EMPTY;function u(t){return t instanceof a||t&&"closed"in t&&(0,i.T)(t.remove)&&(0,i.T)(t.add)&&(0,i.T)(t.unsubscribe)}function l(t){(0,i.T)(t)?t():t.unsubscribe()}},747(t,e,r){"use strict";r.d(e,{$:()=>n});var n={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},5900(t,e,r){"use strict";r.d(e,{G:()=>u});var n=r(5608),i=r(1824),s=r(1868),o=r(8815),a=r(869),c=r(2185),u=function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,(0,c.S)(e)&&(n.lift=e.lift),n}return(0,n.C6)(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._teardown=function(){this._refCount=0;var t=this._connection;this._subject=this._connection=null,null==t||t.unsubscribe()},e.prototype.connect=function(){var t=this,e=this._connection;if(!e){e=this._connection=new s.yU;var r=this.getSubject();e.add(this.source.subscribe((0,a._)(r,void 0,function(){t._teardown(),r.complete()},function(e){t._teardown(),r.error(e)},function(){return t._teardown()}))),e.closed&&(this._connection=null,e=s.yU.EMPTY)}return e},e.prototype.refCount=function(){return(0,o.B)()(this)},e}(i.c)},4817(t,e,r){"use strict";r.d(e,{P:()=>d,z:()=>f});var n=r(1824),i=r(1854),s=r(5315),o=r(4254),a=r(4981),c=r(5361),u=r(9407),l=r(869),h=r(4184);function f(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,c.lI)(t),l=(0,c.ms)(t),h=(0,i.D)(t),f=h.args,p=h.keys;if(0===f.length)return(0,s.H)([],r);var g=new n.c(d(f,r,p?function(t){return(0,u.e)(p,t)}:o.D));return l?g.pipe((0,a.I)(l)):g}function d(t,e,r){return void 0===r&&(r=o.D),function(n){p(e,function(){for(var i=t.length,o=new Array(i),a=i,c=i,u=function(i){p(e,function(){var u=(0,s.H)(t[i],e),h=!1;u.subscribe((0,l._)(n,function(t){o[i]=t,h||(h=!0,c--),c||n.next(r(o.slice()))},function(){--a||n.complete()}))},n)},h=0;h<i;h++)u(h)},n)}}function p(t,e,r){t?(0,h.N)(r,t,e):e()}},7083(t,e,r){"use strict";r.d(e,{x:()=>o});var n=r(2348),i=r(5361),s=r(5315);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,n.K)()((0,s.H)(t,(0,i.lI)(t)))}},1166(t,e,r){"use strict";r.d(e,{I:()=>s,w:()=>i});var n=r(1824),i=new n.c(function(t){return t.complete()});function s(t){return t?function(t){return new n.c(function(e){return t.schedule(function(){return e.complete()})})}(t):i}},5315(t,e,r){"use strict";r.d(e,{H:()=>s});var n=r(489),i=r(6195);function s(t,e){return e?(0,n.c)(t,e):(0,i.Tg)(t)}},6195(t,e,r){"use strict";r.d(e,{Tg:()=>g});var n=r(5608),i=r(1604),s=r(6691),o=r(1824),a=r(3330),c=r(4956),u=r(4904),l=r(3206),h=r(8523),f=r(4460),d=r(3585),p=r(9805);function g(t){if(t instanceof o.c)return t;if(null!=t){if((0,a.l)(t))return b=t,new o.c(function(t){var e=b[p.s]();if((0,f.T)(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if((0,i.X)(t))return y=t,new o.c(function(t){for(var e=0;e<y.length&&!t.closed;e++)t.next(y[e]);t.complete()});if((0,s.y)(t))return g=t,new o.c(function(t){g.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,d.m)});if((0,c.T)(t))return m(t);if((0,l.x)(t))return r=t,new o.c(function(t){var e,i;try{for(var s=(0,n.Ju)(r),o=s.next();!o.done;o=s.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}t.complete()});if((0,h.U)(t))return e=t,m((0,h.C)(e))}var e,r,g,y,b;throw(0,u.L)(t)}function m(t){return new o.c(function(e){(function(t,e){var r,i,s,o;return(0,n.sH)(this,void 0,void 0,function(){var a,c;return(0,n.YH)(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=(0,n.xN)(t),u.label=1;case 1:return[4,r.next()];case 2:if((i=u.sent()).done)return[3,4];if(a=i.value,e.next(a),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),i&&!i.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})})(t,e).catch(function(t){return e.error(t)})})}},6726(t,e,r){"use strict";r.d(e,{Y:()=>s});var n=r(4611),i=r(6302);function s(t,e){return void 0===t&&(t=0),void 0===e&&(e=n.E),t<0&&(t=0),(0,i.O)(t,t,e)}},5118(t,e,r){"use strict";r.d(e,{of:()=>s});var n=r(5361),i=r(5315);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,n.lI)(t);return(0,i.H)(t,r)}},6864(t,e,r){"use strict";r.d(e,{g:()=>c});var n=r(1824),i=r(7589),s=r(869),o=r(2508),a=r(6195);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.K)(t);return new n.c(function(t){var e=0,n=function(){if(e<r.length){var i=void 0;try{i=(0,a.Tg)(r[e++])}catch(t){return void n()}var c=new s.H(t,void 0,o.l,o.l);i.subscribe(c),c.add(n)}else t.complete()};n()})}},6394(t,e,r){"use strict";r.d(e,{O:()=>a,w:()=>c});var n=r(1824),i=r(6195),s=r(7589),o=r(869);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 1===(t=(0,s.K)(t)).length?(0,i.Tg)(t[0]):new n.c(c(t))}function c(t){return function(e){for(var r=[],n=function(n){r.push((0,i.Tg)(t[n]).subscribe((0,o._)(e,function(t){if(r){for(var i=0;i<r.length;i++)i!==n&&r[i].unsubscribe();r=null}e.next(t)})))},s=0;r&&!e.closed&&s<t.length;s++)n(s)}}},5933(t,e,r){"use strict";r.d(e,{$:()=>s});var n=r(1824),i=r(4460);function s(t,e){var r=(0,i.T)(t)?t:function(){return t},s=function(t){return t.error(r())};return new n.c(e?function(t){return e.schedule(s,0,t)}:s)}},6302(t,e,r){"use strict";r.d(e,{O:()=>a});var n=r(1824),i=r(4611),s=r(1867),o=r(1592);function a(t,e,r){void 0===t&&(t=0),void 0===r&&(r=i.b);var a=-1;return null!=e&&((0,s.m)(e)?r=e:a=e),new n.c(function(e){var n=(0,o.v)(t)?+t-r.now():t;n<0&&(n=0);var i=0;return r.schedule(function(){e.closed||(e.next(i++),0<=a?this.schedule(void 0,a):e.complete())},n)})}},9568(t,e,r){"use strict";r.d(e,{y:()=>l});var n=r(5608),i=r(1824),s=r(6195),o=r(7589),a=r(1166),c=r(869),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t),l=(0,o.K)(t);return l.length?new i.c(function(t){var e=l.map(function(){return[]}),i=l.map(function(){return!1});t.add(function(){e=i=null});for(var o=function(o){(0,s.Tg)(l[o]).subscribe((0,c._)(t,function(s){if(e[o].push(s),e.every(function(t){return t.length})){var a=e.map(function(t){return t.shift()});t.next(r?r.apply(void 0,(0,n.fX)([],(0,n.zs)(a))):a),e.some(function(t,e){return!t.length&&i[e]})&&t.complete()}},function(){i[o]=!0,!e[o].length&&t.complete()}))},a=0;!t.closed&&a<l.length;a++)o(a);return function(){e=i=null}}):a.w}},869(t,e,r){"use strict";r.d(e,{H:()=>s,_:()=>i});var n=r(5608);function i(t,e,r,n,i){return new s(t,e,r,n,i)}var s=function(t){function e(e,r,n,i,s,o){var a=t.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=o,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=i?function(t){try{i(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return(0,n.C6)(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}},e}(r(557).vU)},4168(t,e,r){"use strict";r.d(e,{s:()=>o});var n=r(2185),i=r(6195),s=r(869);function o(t){return(0,n.N)(function(e,r){var n=!1,o=null,a=null,c=!1,u=function(){if(null==a||a.unsubscribe(),a=null,n){n=!1;var t=o;o=null,r.next(t)}c&&r.complete()},l=function(){a=null,c&&r.complete()};e.subscribe((0,s._)(r,function(e){n=!0,o=e,a||(0,i.Tg)(t(e)).subscribe(a=(0,s._)(r,u,l))},function(){c=!0,(!n||!a||a.closed)&&r.complete()}))})}},7013(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(4611),i=r(4168),s=r(6302);function o(t,e){return void 0===e&&(e=n.E),(0,i.s)(function(){return(0,s.O)(t,e)})}},9801(t,e,r){"use strict";r.d(e,{r:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=[];return e.subscribe((0,s._)(r,function(t){return n.push(t)},function(){r.next(n),r.complete()})),(0,o.Tg)(t).subscribe((0,s._)(r,function(){var t=n;n=[],r.next(t)},i.l)),function(){n=null}})}},9542(t,e,r){"use strict";r.d(e,{S:()=>a});var n=r(5608),i=r(2185),s=r(869),o=r(1601);function a(t,e){return void 0===e&&(e=null),e=null!=e?e:t,(0,i.N)(function(r,i){var a=[],c=0;r.subscribe((0,s._)(i,function(r){var s,u,l,h,f=null;c++%e===0&&a.push([]);try{for(var d=(0,n.Ju)(a),p=d.next();!p.done;p=d.next()){(y=p.value).push(r),t<=y.length&&(f=null!=f?f:[]).push(y)}}catch(t){s={error:t}}finally{try{p&&!p.done&&(u=d.return)&&u.call(d)}finally{if(s)throw s.error}}if(f)try{for(var g=(0,n.Ju)(f),m=g.next();!m.done;m=g.next()){var y=m.value;(0,o.o)(a,y),i.next(y)}}catch(t){l={error:t}}finally{try{m&&!m.done&&(h=g.return)&&h.call(g)}finally{if(l)throw l.error}}},function(){var t,e;try{for(var r=(0,n.Ju)(a),s=r.next();!s.done;s=r.next()){var o=s.value;i.next(o)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}i.complete()},void 0,function(){a=null}))})}},3132(t,e,r){"use strict";r.d(e,{w:()=>h});var n=r(5608),i=r(1868),s=r(2185),o=r(869),a=r(1601),c=r(4611),u=r(5361),l=r(4184);function h(t){for(var e,r,h=[],f=1;f<arguments.length;f++)h[f-1]=arguments[f];var d=null!==(e=(0,u.lI)(h))&&void 0!==e?e:c.E,p=null!==(r=h[0])&&void 0!==r?r:null,g=h[1]||1/0;return(0,s.N)(function(e,r){var s=[],c=!1,u=function(t){var e=t.buffer;t.subs.unsubscribe(),(0,a.o)(s,t),r.next(e),c&&h()},h=function(){if(s){var e=new i.yU;r.add(e);var n={buffer:[],subs:e};s.push(n),(0,l.N)(e,d,function(){return u(n)},t)}};null!==p&&p>=0?(0,l.N)(r,d,h,p,!0):c=!0,h();var f=(0,o._)(r,function(t){var e,r,i=s.slice();try{for(var o=(0,n.Ju)(i),a=o.next();!a.done;a=o.next()){var c=a.value,l=c.buffer;l.push(t),g<=l.length&&u(c)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},function(){for(;null==s?void 0:s.length;)r.next(s.shift().buffer);null==f||f.unsubscribe(),r.complete(),r.unsubscribe()},void 0,function(){return s=null});e.subscribe(f)})}},6145(t,e,r){"use strict";r.d(e,{H:()=>l});var n=r(5608),i=r(1868),s=r(2185),o=r(6195),a=r(869),c=r(2508),u=r(1601);function l(t,e){return(0,s.N)(function(r,s){var l=[];(0,o.Tg)(t).subscribe((0,a._)(s,function(t){var r=[];l.push(r);var n=new i.yU;n.add((0,o.Tg)(e(t)).subscribe((0,a._)(s,function(){(0,u.o)(l,r),s.next(r),n.unsubscribe()},c.l)))},c.l)),r.subscribe((0,a._)(s,function(t){var e,r;try{for(var i=(0,n.Ju)(l),s=i.next();!s.done;s=i.next()){s.value.push(t)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}},function(){for(;l.length>0;)s.next(l.shift());s.complete()}))})}},6689(t,e,r){"use strict";r.d(e,{n:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=null,a=null,c=function(){null==a||a.unsubscribe();var e=n;n=[],e&&r.next(e),(0,o.Tg)(t()).subscribe(a=(0,s._)(r,c,i.l))};c(),e.subscribe((0,s._)(r,function(t){return null==n?void 0:n.push(t)},function(){n&&r.next(n),r.complete()},void 0,function(){return n=a=null}))})}},672(t,e,r){"use strict";r.d(e,{W:()=>o});var n=r(6195),i=r(869),s=r(2185);function o(t){return(0,s.N)(function(e,r){var s,a=null,c=!1;a=e.subscribe((0,i._)(r,void 0,void 0,function(i){s=(0,n.Tg)(t(i,o(t)(e))),a?(a.unsubscribe(),a=null,s.subscribe(r)):c=!0})),c&&(a.unsubscribe(),a=null,s.subscribe(r))})}},8363(t,e,r){"use strict";r.d(e,{p:()=>n});var n=r(9142).A},1481(t,e,r){"use strict";r.d(e,{z:()=>l});var n=r(5608),i=r(4817),s=r(2185),o=r(7589),a=r(4981),c=r(3404),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t);return r?(0,c.F)(l.apply(void 0,(0,n.fX)([],(0,n.zs)(t))),(0,a.I)(r)):(0,s.N)(function(e,r){(0,i.P)((0,n.fX)([e],(0,n.zs)((0,o.K)(t))))(r)})}},9142(t,e,r){"use strict";r.d(e,{A:()=>s});var n=r(4817),i=r(9732);function s(t){return(0,i.q)(n.z,t)}},8957(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(5608),i=r(1481);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.z.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},3267(t,e,r){"use strict";r.d(e,{x:()=>c});var n=r(5608),i=r(2185),s=r(2348),o=r(5361),a=r(5315);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,o.lI)(t);return(0,i.N)(function(e,i){(0,s.K)()((0,a.H)((0,n.fX)([e],(0,n.zs)(t)),r)).subscribe(i)})}},2348(t,e,r){"use strict";r.d(e,{K:()=>i});var n=r(9904);function i(){return(0,n.U)(1)}},949(t,e,r){"use strict";r.d(e,{H:()=>s});var n=r(6961),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.Z)(t,e,1):(0,n.Z)(t,1)}},4292(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(949),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.H)(function(){return t},e):(0,n.H)(function(){return t})}},4011(t,e,r){"use strict";r.d(e,{$:()=>s});var n=r(5608),i=r(3267);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.x.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},1715(t,e,r){"use strict";r.d(e,{N:()=>c});var n=r(9097),i=r(6195),s=r(2185),o=r(1824);var a={connector:function(){return new n.B}};function c(t,e){void 0===e&&(e=a);var r=e.connector;return(0,s.N)(function(e,n){var s,a=r();(0,i.Tg)(t((s=a,new o.c(function(t){return s.subscribe(t)})))).subscribe(n),n.add(e.subscribe(a))})}},6456(t,e,r){"use strict";r.d(e,{U:()=>i});var n=r(8933);function i(t){return(0,n.T)(function(e,r,n){return!t||t(r,n)?e+1:e},0)}},9780(t,e,r){"use strict";r.d(e,{s:()=>a});var n=r(2185),i=r(2508),s=r(869),o=r(6195);function a(t){return(0,n.N)(function(e,r){var n=!1,a=null,c=null,u=function(){if(null==c||c.unsubscribe(),c=null,n){n=!1;var t=a;a=null,r.next(t)}};e.subscribe((0,s._)(r,function(e){null==c||c.unsubscribe(),n=!0,a=e,c=(0,s._)(r,u,i.l),(0,o.Tg)(t(e)).subscribe(c)},function(){u(),r.complete()},void 0,function(){a=c=null}))})}},5833(t,e,r){"use strict";r.d(e,{B:()=>o});var n=r(4611),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=n.E),(0,i.N)(function(r,n){var i=null,o=null,a=null,c=function(){if(i){i.unsubscribe(),i=null;var t=o;o=null,n.next(t)}};function u(){var r=a+t,s=e.now();if(s<r)return i=this.schedule(void 0,r-s),void n.add(i);c()}r.subscribe((0,s._)(n,function(r){o=r,a=e.now(),i||(i=e.schedule(u,t),n.add(i))},function(){c(),n.complete()},void 0,function(){o=i=null}))})}},4228(t,e,r){"use strict";r.d(e,{U:()=>s});var n=r(2185),i=r(869);function s(t){return(0,n.N)(function(e,r){var n=!1;e.subscribe((0,i._)(r,function(t){n=!0,r.next(t)},function(){n||r.next(t),r.complete()}))})}},2840(t,e,r){"use strict";r.d(e,{c:()=>o});var n=r(4611),i=r(6660),s=r(6302);function o(t,e){void 0===e&&(e=n.E);var r=(0,s.O)(t,e);return(0,i.o)(function(){return r})}},6660(t,e,r){"use strict";r.d(e,{o:()=>u});var n=r(7083),i=r(5172),s=r(9756),o=r(3692),a=r(6961),c=r(6195);function u(t,e){return e?function(r){return(0,n.x)(e.pipe((0,i.s)(1),(0,s.w)()),r.pipe(u(t)))}:(0,a.Z)(function(e,r){return(0,c.Tg)(t(e,r)).pipe((0,i.s)(1),(0,o.u)(e))})}},1023(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(8666),i=r(2185),s=r(869);function o(){return(0,i.N)(function(t,e){t.subscribe((0,s._)(e,function(t){return(0,n.gV)(t,e)}))})}},7435(t,e,r){"use strict";r.d(e,{d:()=>a});var n=r(2185),i=r(869),s=r(2508),o=r(6195);function a(t,e){return(0,n.N)(function(r,n){var a=new Set;r.subscribe((0,i._)(n,function(e){var r=t?t(e):e;a.has(r)||(a.add(r),n.next(e))})),e&&(0,o.Tg)(e).subscribe((0,i._)(n,function(){return a.clear()},s.l))})}},5519(t,e,r){"use strict";r.d(e,{F:()=>o});var n=r(4254),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=n.D),t=null!=t?t:a,(0,i.N)(function(r,n){var i,o=!0;r.subscribe((0,s._)(n,function(r){var s=e(r);!o&&t(i,s)||(o=!1,i=s,n.next(r))}))})}function a(t,e){return t===e}},5538(t,e,r){"use strict";r.d(e,{w:()=>i});var n=r(5519);function i(t,e){return(0,n.F)(function(r,n){return e?e(r[t],n[t]):r[t]===n[t]})}},6026(t,e,r){"use strict";r.d(e,{s:()=>c});var n=r(5339),i=r(465),s=r(5007),o=r(4228),a=r(5172);function c(t,e){if(t<0)throw new n.k;var r=arguments.length>=2;return function(c){return c.pipe((0,i.p)(function(e,r){return r===t}),(0,a.s)(1),r?(0,o.U)(e):(0,s.v)(function(){return new n.k}))}}},7566(t,e,r){"use strict";r.d(e,{q:()=>o});var n=r(5608),i=r(7083),s=r(5118);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return(0,i.x)(e,s.of.apply(void 0,(0,n.fX)([],(0,n.zs)(t))))}}},5060(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(i){t.call(e,i,s++,r)||(n.next(!1),n.complete())},function(){n.next(!0),n.complete()}))})}},8017(t,e,r){"use strict";r.d(e,{B:()=>n});var n=r(5598).C},5598(t,e,r){"use strict";r.d(e,{C:()=>s});var n=r(5711),i=r(4254);function s(){return(0,n.p)(i.D)}},5711(t,e,r){"use strict";r.d(e,{p:()=>a});var n=r(8045),i=r(6195),s=r(2185),o=r(869);function a(t,e){return e?function(r){return r.pipe(a(function(r,s){return(0,i.Tg)(t(r,s)).pipe((0,n.T)(function(t,n){return e(r,t,s,n)}))}))}:(0,s.N)(function(e,r){var n=0,s=null,a=!1;e.subscribe((0,o._)(r,function(e){s||(s=(0,o._)(r,void 0,function(){s=null,a&&r.complete()}),(0,i.Tg)(t(e,n++)).subscribe(s))},function(){a=!0,!s&&r.complete()}))})}},2467(t,e,r){"use strict";r.d(e,{f:()=>s});var n=r(2185),i=r(8001);function s(t,e,r){return void 0===e&&(e=1/0),e=(e||0)<1?1/0:e,(0,n.N)(function(n,s){return(0,i.h)(n,s,t,e,void 0,!0,r)})}},465(t,e,r){"use strict";r.d(e,{p:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){return t.call(e,r,s++)&&n.next(r)}))})}},8553(t,e,r){"use strict";r.d(e,{j:()=>i});var n=r(2185);function i(t){return(0,n.N)(function(e,r){try{e.subscribe(r)}finally{r.add(t)}})}},4732(t,e,r){"use strict";r.d(e,{I:()=>s,k:()=>o});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(o(t,e,"value"))}function o(t,e,r){var n="index"===r;return function(r,s){var o=0;r.subscribe((0,i._)(s,function(i){var a=o++;t.call(e,i,a,r)&&(s.next(n?a:i),s.complete())},function(){s.next(n?-1:void 0),s.complete()}))}}},5206(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(4732);function s(t,e){return(0,n.N)((0,i.k)(t,e,"index"))}},4053(t,e,r){"use strict";r.d(e,{$:()=>u});var n=r(1585),i=r(465),s=r(5172),o=r(4228),a=r(5007),c=r(4254);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,i.p)(function(e,r){return t(e,r,u)}):c.D,(0,s.s)(1),r?(0,o.U)(e):(0,a.v)(function(){return new n.G}))}}},9016(t,e,r){"use strict";r.d(e,{q:()=>n});var n=r(6961).Z},7333(t,e,r){"use strict";r.d(e,{$:()=>c});var n=r(1824),i=r(6195),s=r(9097),o=r(2185),a=r(869);function c(t,e,r,c){return(0,o.N)(function(o,u){var l;e&&"function"!=typeof e?(r=e.duration,l=e.element,c=e.connector):l=e;var h=new Map,f=function(t){h.forEach(t),t(u)},d=function(t){return f(function(e){return e.error(t)})},p=0,g=!1,m=new a.H(u,function(e){try{var o=t(e),f=h.get(o);if(!f){h.set(o,f=c?c():new s.B);var y=(v=o,w=f,(E=new n.c(function(t){p++;var e=w.subscribe(t);return function(){e.unsubscribe(),0===--p&&g&&m.unsubscribe()}})).key=v,E);if(u.next(y),r){var b=(0,a._)(f,function(){f.complete(),null==b||b.unsubscribe()},void 0,void 0,function(){return h.delete(o)});m.add((0,i.Tg)(r(y)).subscribe(b))}}f.next(l?l(e):e)}catch(t){d(t)}var v,w,E},function(){return f(function(t){return t.complete()})},d,function(){return h.clear()},function(){return g=!0,0===p});o.subscribe(m)})}},9756(t,e,r){"use strict";r.d(e,{w:()=>o});var n=r(2185),i=r(869),s=r(2508);function o(){return(0,n.N)(function(t,e){t.subscribe((0,i._)(e,s.l))})}},3694(t,e,r){"use strict";r.d(e,{I:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){t.subscribe((0,i._)(e,function(){e.next(!1),e.complete()},function(){e.next(!0),e.complete()}))})}},9732(t,e,r){"use strict";r.d(e,{q:()=>c});var n=r(4254),i=r(4981),s=r(3404),o=r(6961),a=r(2033);function c(t,e){return(0,s.F)((0,a.$)(),(0,o.Z)(function(e){return t(e)}),e?(0,i.I)(e):n.D)}},2187(t,e,r){"use strict";r.d(e,{H:()=>u});var n=r(1585),i=r(465),s=r(3172),o=r(5007),a=r(4228),c=r(4254);function u(t,e){var r=arguments.length>=2;return function(u){return u.pipe(t?(0,i.p)(function(e,r){return t(e,r,u)}):c.D,(0,s.o)(1),r?(0,a.U)(e):(0,o.v)(function(){return new n.G}))}}},8045(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(2185),i=r(869);function s(t,e){return(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){n.next(t.call(e,r,s++))}))})}},3692(t,e,r){"use strict";r.d(e,{u:()=>i});var n=r(8045);function i(t){return(0,n.T)(function(){return t})}},6326(t,e,r){"use strict";r.d(e,{O:()=>o});var n=r(8666),i=r(2185),s=r(869);function o(){return(0,i.N)(function(t,e){t.subscribe((0,s._)(e,function(t){e.next(n.Eg.createNext(t))},function(){e.next(n.Eg.createComplete()),e.complete()},function(t){e.next(n.Eg.createError(t)),e.complete()}))})}},7877(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(8933),i=r(4460);function s(t){return(0,n.T)((0,i.T)(t)?function(e,r){return t(e,r)>0?e:r}:function(t,e){return t>e?t:e})}},3375(t,e,r){"use strict";r.d(e,{h:()=>c});var n=r(5608),i=r(2185),s=r(9904),o=r(5361),a=r(5315);function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,o.lI)(t),c=(0,o.R0)(t,1/0);return(0,i.N)(function(e,i){(0,s.U)(c)((0,a.H)((0,n.fX)([e],(0,n.zs)(t)),r)).subscribe(i)})}},9904(t,e,r){"use strict";r.d(e,{U:()=>s});var n=r(6961),i=r(4254);function s(t){return void 0===t&&(t=1/0),(0,n.Z)(i.D,t)}},8001(t,e,r){"use strict";r.d(e,{h:()=>o});var n=r(6195),i=r(4184),s=r(869);function o(t,e,r,o,a,c,u,l){var h=[],f=0,d=0,p=!1,g=function(){!p||h.length||f||e.complete()},m=function(t){return f<o?y(t):h.push(t)},y=function(t){c&&e.next(t),f++;var l=!1;(0,n.Tg)(r(t,d++)).subscribe((0,s._)(e,function(t){null==a||a(t),c?m(t):e.next(t)},function(){l=!0},void 0,function(){if(l)try{f--;for(var t=function(){var t=h.shift();u?(0,i.N)(e,u,function(){return y(t)}):y(t)};h.length&&f<o;)t();g()}catch(t){e.error(t)}}))};return t.subscribe((0,s._)(e,m,function(){p=!0,g()})),function(){null==l||l()}}},6961(t,e,r){"use strict";r.d(e,{Z:()=>c});var n=r(8045),i=r(6195),s=r(2185),o=r(8001),a=r(4460);function c(t,e,r){return void 0===r&&(r=1/0),(0,a.T)(e)?c(function(r,s){return(0,n.T)(function(t,n){return e(r,t,s,n)})((0,i.Tg)(t(r,s)))},r):("number"==typeof e&&(r=e),(0,s.N)(function(e,n){return(0,o.h)(e,n,t,r)}))}},2720(t,e,r){"use strict";r.d(e,{C:()=>s});var n=r(6961),i=r(4460);function s(t,e,r){return void 0===r&&(r=1/0),(0,i.T)(e)?(0,n.Z)(function(){return t},e,r):("number"==typeof e&&(r=e),(0,n.Z)(function(){return t},r))}},26(t,e,r){"use strict";r.d(e,{i:()=>s});var n=r(2185),i=r(8001);function s(t,e,r){return void 0===r&&(r=1/0),(0,n.N)(function(n,s){var o=e;return(0,i.h)(n,s,function(e,r){return t(o,e,r)},r,function(t){o=t},!1,void 0,function(){return o=null})})}},6343(t,e,r){"use strict";r.d(e,{X:()=>s});var n=r(5608),i=r(3375);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.h.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},8287(t,e,r){"use strict";r.d(e,{j:()=>s});var n=r(8933),i=r(4460);function s(t){return(0,n.T)((0,i.T)(t)?function(e,r){return t(e,r)<0?e:r}:function(t,e){return t<e?t:e})}},3045(t,e,r){"use strict";r.d(e,{f:()=>o});var n=r(5900),i=r(4460),s=r(1715);function o(t,e){var r=(0,i.T)(t)?t:function(){return t};return(0,i.T)(e)?(0,s.N)(e,{connector:r}):function(t){return new n.G(t,r)}}},5106(t,e,r){"use strict";r.d(e,{Q:()=>o});var n=r(4184),i=r(2185),s=r(869);function o(t,e){return void 0===e&&(e=0),(0,i.N)(function(r,i){r.subscribe((0,s._)(i,function(r){return(0,n.N)(i,t,function(){return i.next(r)},e)},function(){return(0,n.N)(i,t,function(){return i.complete()},e)},function(r){return(0,n.N)(i,t,function(){return i.error(r)},e)}))})}},1264(t,e,r){"use strict";r.d(e,{g:()=>a,w:()=>o});var n=r(5608),i=r(7589),s=r(6864);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.K)(t);return function(t){return s.g.apply(void 0,(0,n.fX)([t],(0,n.zs)(r)))}}var a=o},9127(t,e,r){"use strict";r.d(e,{J:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){var r,n=!1;t.subscribe((0,i._)(e,function(t){var i=r;r=t,n&&e.next([i,t]),n=!0}))})}},8614(t,e,r){"use strict";r.d(e,{E:()=>i});var n=r(8045);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.length;if(0===r)throw new Error("list of properties cannot be empty.");return(0,n.T)(function(e){for(var n=e,i=0;i<r;i++){var s=null==n?void 0:n[t[i]];if(void 0===s)return;n=s}return n})}},1996(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(9097),i=r(3045),s=r(1715);function o(t){return t?function(e){return(0,s.N)(t)(e)}:function(t){return(0,i.f)(new n.B)(t)}}},9514(t,e,r){"use strict";r.d(e,{K:()=>s});var n=r(5923),i=r(5900);function s(t){return function(e){var r=new n.t(t);return new i.G(e,function(){return r})}}},2812(t,e,r){"use strict";r.d(e,{k:()=>s});var n=r(5445),i=r(5900);function s(){return function(t){var e=new n.h;return new i.G(t,function(){return e})}}},4679(t,e,r){"use strict";r.d(e,{H:()=>o});var n=r(5404),i=r(3045),s=r(4460);function o(t,e,r,o){r&&!(0,s.T)(r)&&(o=r);var a=(0,s.T)(r)?r:void 0;return function(r){return(0,i.f)(new n.m(t,e,o),a)(r)}}},8702(t,e,r){"use strict";r.d(e,{w:()=>a});var n=r(5608),i=r(6394),s=r(2185),o=r(4254);function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.length?(0,s.N)(function(e,r){(0,i.w)((0,n.fX)([e],(0,n.zs)(t)))(r)}):o.D}},8933(t,e,r){"use strict";r.d(e,{T:()=>s});var n=r(8906),i=r(2185);function s(t,e){return(0,i.N)((0,n.S)(t,e,arguments.length>=2,!1,!0))}},8815(t,e,r){"use strict";r.d(e,{B:()=>s});var n=r(2185),i=r(869);function s(){return(0,n.N)(function(t,e){var r=null;t._refCount++;var n=(0,i._)(e,void 0,void 0,void 0,function(){if(!t||t._refCount<=0||0<--t._refCount)r=null;else{var n=t._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),e.unsubscribe()}});t.subscribe(n),n.closed||(r=t.connect())})}},744(t,e,r){"use strict";r.d(e,{u:()=>c});var n=r(1166),i=r(2185),s=r(869),o=r(6195),a=r(6302);function c(t){var e,r,c=1/0;return null!=t&&("object"==typeof t?(e=t.count,c=void 0===e?1/0:e,r=t.delay):c=t),c<=0?function(){return n.w}:(0,i.N)(function(t,e){var n,i=0,u=function(){if(null==n||n.unsubscribe(),n=null,null!=r){var t="number"==typeof r?(0,a.O)(r):(0,o.Tg)(r(i)),c=(0,s._)(e,function(){c.unsubscribe(),l()});t.subscribe(c)}else l()},l=function(){var r=!1;n=t.subscribe((0,s._)(e,void 0,function(){++i<c?n?u():r=!0:e.complete()})),r&&u()};l()})}},1204(t,e,r){"use strict";r.d(e,{Y:()=>a});var n=r(6195),i=r(9097),s=r(2185),o=r(869);function a(t){return(0,s.N)(function(e,r){var s,a,c=!1,u=!1,l=!1,h=function(){return l&&u&&(r.complete(),!0)},f=function(){l=!1,s=e.subscribe((0,o._)(r,void 0,function(){l=!0,!h()&&(a||(a=new i.B,(0,n.Tg)(t(a)).subscribe((0,o._)(r,function(){s?f():c=!0},function(){u=!0,h()}))),a).next()})),c&&(s.unsubscribe(),s=null,c=!1,f())};f()})}},9185(t,e,r){"use strict";r.d(e,{L:()=>c});var n=r(2185),i=r(869),s=r(4254),o=r(6302),a=r(6195);function c(t){var e;void 0===t&&(t=1/0);var r=(e=t&&"object"==typeof t?t:{count:t}).count,c=void 0===r?1/0:r,u=e.delay,l=e.resetOnSuccess,h=void 0!==l&&l;return c<=0?s.D:(0,n.N)(function(t,e){var r,n=0,s=function(){var l=!1;r=t.subscribe((0,i._)(e,function(t){h&&(n=0),e.next(t)},void 0,function(t){if(n++<c){var h=function(){r?(r.unsubscribe(),r=null,s()):l=!0};if(null!=u){var f="number"==typeof u?(0,o.O)(u):(0,a.Tg)(u(t,n)),d=(0,i._)(e,function(){d.unsubscribe(),h()},function(){e.complete()});f.subscribe(d)}else h()}else e.error(t)})),l&&(r.unsubscribe(),r=null,s())};s()})}},1478(t,e,r){"use strict";r.d(e,{l:()=>a});var n=r(6195),i=r(9097),s=r(2185),o=r(869);function a(t){return(0,s.N)(function(e,r){var s,a,c=!1,u=function(){s=e.subscribe((0,o._)(r,void 0,void 0,function(e){a||(a=new i.B,(0,n.Tg)(t(a)).subscribe((0,o._)(r,function(){return s?u():c=!0}))),a&&a.next(e)})),c&&(s.unsubscribe(),s=null,c=!1,u())};u()})}},7073(t,e,r){"use strict";r.d(e,{X:()=>a});var n=r(6195),i=r(2185),s=r(2508),o=r(869);function a(t){return(0,i.N)(function(e,r){var i=!1,a=null;e.subscribe((0,o._)(r,function(t){i=!0,a=t})),(0,n.Tg)(t).subscribe((0,o._)(r,function(){if(i){i=!1;var t=a;a=null,r.next(t)}},s.l))})}},84(t,e,r){"use strict";r.d(e,{q:()=>o});var n=r(4611),i=r(7073),s=r(6726);function o(t,e){return void 0===e&&(e=n.E),(0,i.X)((0,s.Y)(t,e))}},510(t,e,r){"use strict";r.d(e,{S:()=>s});var n=r(2185),i=r(8906);function s(t,e){return(0,n.N)((0,i.S)(t,e,arguments.length>=2,!0))}},8906(t,e,r){"use strict";r.d(e,{S:()=>i});var n=r(869);function i(t,e,r,i,s){return function(o,a){var c=r,u=e,l=0;o.subscribe((0,n._)(a,function(e){var r=l++;u=c?t(u,e,r):(c=!0,e),i&&a.next(u)},s&&function(){c&&a.next(u),a.complete()}))}}},4112(t,e,r){"use strict";r.d(e,{m:()=>o});var n=r(2185),i=r(869),s=r(6195);function o(t,e){return void 0===e&&(e=function(t,e){return t===e}),(0,n.N)(function(r,n){var o={buffer:[],complete:!1},a={buffer:[],complete:!1},c=function(t){n.next(t),n.complete()},u=function(t,r){var s=(0,i._)(n,function(n){var i=r.buffer,s=r.complete;0===i.length?s?c(!1):t.buffer.push(n):!e(n,i.shift())&&c(!1)},function(){t.complete=!0;var e=r.complete,n=r.buffer;e&&c(0===n.length),null==s||s.unsubscribe()});return s};r.subscribe(u(o,a)),(0,s.Tg)(t).subscribe(u(a,o))})}},1452(t,e,r){"use strict";r.d(e,{u:()=>c});var n=r(5608),i=r(6195),s=r(9097),o=r(557),a=r(2185);function c(t){void 0===t&&(t={});var e=t.connector,r=void 0===e?function(){return new s.B}:e,n=t.resetOnError,c=void 0===n||n,l=t.resetOnComplete,h=void 0===l||l,f=t.resetOnRefCountZero,d=void 0===f||f;return function(t){var e,n,s,l=0,f=!1,p=!1,g=function(){null==n||n.unsubscribe(),n=void 0},m=function(){g(),e=s=void 0,f=p=!1},y=function(){var t=e;m(),null==t||t.unsubscribe()};return(0,a.N)(function(t,a){l++,p||f||g();var b=s=null!=s?s:r();a.add(function(){0!==--l||p||f||(n=u(y,d))}),b.subscribe(a),!e&&l>0&&(e=new o.Ms({next:function(t){return b.next(t)},error:function(t){p=!0,g(),n=u(m,c,t),b.error(t)},complete:function(){f=!0,g(),n=u(m,h),b.complete()}}),(0,i.Tg)(t).subscribe(e))})(t)}}function u(t,e){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];if(!0!==e){if(!1!==e){var a=new o.Ms({next:function(){a.unsubscribe(),t()}});return(0,i.Tg)(e.apply(void 0,(0,n.fX)([],(0,n.zs)(r)))).subscribe(a)}}else t()}},4103(t,e,r){"use strict";r.d(e,{t:()=>s});var n=r(5404),i=r(1452);function s(t,e,r){var s,o,a,c,u=!1;return t&&"object"==typeof t?(s=t.bufferSize,c=void 0===s?1/0:s,o=t.windowTime,e=void 0===o?1/0:o,u=void 0!==(a=t.refCount)&&a,r=t.scheduler):c=null!=t?t:1/0,(0,i.u)({connector:function(){return new n.m(c,e,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:u})}},4623(t,e,r){"use strict";r.d(e,{J:()=>c});var n=r(1585),i=r(6611),s=r(1753),o=r(2185),a=r(869);function c(t){return(0,o.N)(function(e,r){var o,c=!1,u=!1,l=0;e.subscribe((0,a._)(r,function(n){u=!0,t&&!t(n,l++,e)||(c&&r.error(new i.I("Too many matching values")),c=!0,o=n)},function(){c?(r.next(o),r.complete()):r.error(u?new s.m("No matching values"):new n.G)}))})}},3616(t,e,r){"use strict";r.d(e,{i:()=>i});var n=r(465);function i(t){return(0,n.p)(function(e,r){return t<=r})}},5152(t,e,r){"use strict";r.d(e,{G:()=>o});var n=r(4254),i=r(2185),s=r(869);function o(t){return t<=0?n.D:(0,i.N)(function(e,r){var n=new Array(t),i=0;return e.subscribe((0,s._)(r,function(e){var s=i++;if(s<t)n[s]=e;else{var o=s%t,a=n[o];n[o]=e,r.next(a)}})),function(){n=null}})}},3430(t,e,r){"use strict";r.d(e,{U:()=>a});var n=r(2185),i=r(869),s=r(6195),o=r(2508);function a(t){return(0,n.N)(function(e,r){var n=!1,a=(0,i._)(r,function(){null==a||a.unsubscribe(),n=!0},o.l);(0,s.Tg)(t).subscribe(a),e.subscribe((0,i._)(r,function(t){return n&&r.next(t)}))})}},9955(t,e,r){"use strict";r.d(e,{j:()=>s});var n=r(2185),i=r(869);function s(t){return(0,n.N)(function(e,r){var n=!1,s=0;e.subscribe((0,i._)(r,function(e){return(n||(n=!t(e,s++)))&&r.next(e)}))})}},8263(t,e,r){"use strict";r.d(e,{Z:()=>o});var n=r(7083),i=r(5361),s=r(2185);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,i.lI)(t);return(0,s.N)(function(e,i){(r?(0,n.x)(t,e,r):(0,n.x)(t,e)).subscribe(i)})}},6518(t,e,r){"use strict";r.d(e,{_:()=>i});var n=r(2185);function i(t,e){return void 0===e&&(e=0),(0,n.N)(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}},5056(t,e,r){"use strict";r.d(e,{w:()=>s});var n=r(8737),i=r(4254);function s(){return(0,n.n)(i.D)}},8737(t,e,r){"use strict";r.d(e,{n:()=>o});var n=r(6195),i=r(2185),s=r(869);function o(t,e){return(0,i.N)(function(r,i){var o=null,a=0,c=!1,u=function(){return c&&!o&&i.complete()};r.subscribe((0,s._)(i,function(r){null==o||o.unsubscribe();var c=0,l=a++;(0,n.Tg)(t(r,l)).subscribe(o=(0,s._)(i,function(t){return i.next(e?e(r,t,l,c++):t)},function(){o=null,u()}))},function(){c=!0,u()}))})}},1200(t,e,r){"use strict";r.d(e,{K:()=>s});var n=r(8737),i=r(4460);function s(t,e){return(0,i.T)(e)?(0,n.n)(function(){return t},e):(0,n.n)(function(){return t})}},2570(t,e,r){"use strict";r.d(e,{m:()=>s});var n=r(8737),i=r(2185);function s(t,e){return(0,i.N)(function(r,i){var s=e;return(0,n.n)(function(e,r){return t(s,e,r)},function(t,e){return s=e,e})(r).subscribe(i),function(){s=null}})}},5172(t,e,r){"use strict";r.d(e,{s:()=>o});var n=r(1166),i=r(2185),s=r(869);function o(t){return t<=0?function(){return n.w}:(0,i.N)(function(e,r){var n=0;e.subscribe((0,s._)(r,function(e){++n<=t&&(r.next(e),t<=n&&r.complete())}))})}},3172(t,e,r){"use strict";r.d(e,{o:()=>a});var n=r(5608),i=r(1166),s=r(2185),o=r(869);function a(t){return t<=0?function(){return i.w}:(0,s.N)(function(e,r){var i=[];e.subscribe((0,o._)(r,function(e){i.push(e),t<i.length&&i.shift()},function(){var t,e;try{for(var s=(0,n.Ju)(i),o=s.next();!o.done;o=s.next()){var a=o.value;r.next(a)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}r.complete()},void 0,function(){i=null}))})}},1762(t,e,r){"use strict";r.d(e,{Q:()=>a});var n=r(2185),i=r(869),s=r(6195),o=r(2508);function a(t){return(0,n.N)(function(e,r){(0,s.Tg)(t).subscribe((0,i._)(r,function(){return r.complete()},o.l)),!r.closed&&e.subscribe(r)})}},247(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(2185),i=r(869);function s(t,e){return void 0===e&&(e=!1),(0,n.N)(function(r,n){var s=0;r.subscribe((0,i._)(n,function(r){var i=t(r,s++);(i||e)&&n.next(r),!i&&n.complete()}))})}},8322(t,e,r){"use strict";r.d(e,{M:()=>a});var n=r(4460),i=r(2185),s=r(869),o=r(4254);function a(t,e,r){var a=(0,n.T)(t)||e||r?{next:t,error:e,complete:r}:t;return a?(0,i.N)(function(t,e){var r;null===(r=a.subscribe)||void 0===r||r.call(a);var n=!0;t.subscribe((0,s._)(e,function(t){var r;null===(r=a.next)||void 0===r||r.call(a,t),e.next(t)},function(){var t;n=!1,null===(t=a.complete)||void 0===t||t.call(a),e.complete()},function(t){var r;n=!1,null===(r=a.error)||void 0===r||r.call(a,t),e.error(t)},function(){var t,e;n&&(null===(t=a.unsubscribe)||void 0===t||t.call(a)),null===(e=a.finalize)||void 0===e||e.call(a)}))}):o.D}},8359(t,e,r){"use strict";r.d(e,{n:()=>o});var n=r(2185),i=r(869),s=r(6195);function o(t,e){return(0,n.N)(function(r,n){var o=null!=e?e:{},a=o.leading,c=void 0===a||a,u=o.trailing,l=void 0!==u&&u,h=!1,f=null,d=null,p=!1,g=function(){null==d||d.unsubscribe(),d=null,l&&(b(),p&&n.complete())},m=function(){d=null,p&&n.complete()},y=function(e){return d=(0,s.Tg)(t(e)).subscribe((0,i._)(n,g,m))},b=function(){if(h){h=!1;var t=f;f=null,n.next(t),!p&&y(t)}};r.subscribe((0,i._)(n,function(t){h=!0,f=t,(!d||d.closed)&&(c?b():y(t))},function(){p=!0,(!(l&&h&&d)||d.closed)&&n.complete()}))})}},626(t,e,r){"use strict";r.d(e,{c:()=>o});var n=r(4611),i=r(8359),s=r(6302);function o(t,e,r){void 0===e&&(e=n.E);var o=(0,s.O)(t,e);return(0,i.n)(function(){return o},r)}},5007(t,e,r){"use strict";r.d(e,{v:()=>o});var n=r(1585),i=r(2185),s=r(869);function o(t){return void 0===t&&(t=a),(0,i.N)(function(e,r){var n=!1;e.subscribe((0,s._)(r,function(t){n=!0,r.next(t)},function(){return n?r.complete():r.error(t())}))})}function a(){return new n.G}},5223(t,e,r){"use strict";r.d(e,{f:()=>o});var n=r(4611),i=r(2185),s=r(869);function o(t){return void 0===t&&(t=n.E),(0,i.N)(function(e,r){var n=t.now();e.subscribe((0,s._)(r,function(e){var i=t.now(),s=i-n;n=i,r.next(new a(e,s))}))})}var a=function(t,e){this.value=t,this.interval=e}},3572(t,e,r){"use strict";r.d(e,{M:()=>l,w:()=>h});var n=r(4611),i=r(1592),s=r(2185),o=r(6195),a=r(4166),c=r(869),u=r(4184),l=(0,a.L)(function(t){return function(e){void 0===e&&(e=null),t(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function h(t,e){var r=(0,i.v)(t)?{first:t}:"number"==typeof t?{each:t}:t,a=r.first,l=r.each,h=r.with,d=void 0===h?f:h,p=r.scheduler,g=void 0===p?null!=e?e:n.E:p,m=r.meta,y=void 0===m?null:m;if(null==a&&null==l)throw new TypeError("No timeout provided.");return(0,s.N)(function(t,e){var r,n,i=null,s=0,h=function(t){n=(0,u.N)(e,g,function(){try{r.unsubscribe(),(0,o.Tg)(d({meta:y,lastValue:i,seen:s})).subscribe(e)}catch(t){e.error(t)}},t)};r=t.subscribe((0,c._)(e,function(t){null==n||n.unsubscribe(),s++,e.next(i=t),l>0&&h(l)},void 0,void 0,function(){(null==n?void 0:n.closed)||null==n||n.unsubscribe(),i=null})),!s&&h(null!=a?"number"==typeof a?a:+a-g.now():l)})}function f(t){throw new l(t)}},3868(t,e,r){"use strict";r.d(e,{o:()=>o});var n=r(4611),i=r(1592),s=r(3572);function o(t,e,r){var o,a,c;if(r=null!=r?r:n.b,(0,i.v)(t)?o=t:"number"==typeof t&&(a=t),!e)throw new TypeError("No observable provided to switch to");if(c=function(){return e},null==o&&null==a)throw new TypeError("No timeout provided.");return(0,s.w)({first:o,each:a,scheduler:r,with:c})}},6715(t,e,r){"use strict";r.d(e,{v:()=>s});var n=r(8154),i=r(8045);function s(t){return void 0===t&&(t=n.U),(0,i.T)(function(e){return{value:e,timestamp:t.now()}})}},2033(t,e,r){"use strict";r.d(e,{$:()=>o});var n=r(8933),i=r(2185),s=function(t,e){return t.push(e),t};function o(){return(0,i.N)(function(t,e){(0,n.T)(s,[])(t).subscribe(e)})}},6063(t,e,r){"use strict";r.d(e,{x:()=>c});var n=r(9097),i=r(2185),s=r(869),o=r(2508),a=r(6195);function c(t){return(0,i.N)(function(e,r){var i=new n.B;r.next(i.asObservable());var c=function(t){i.error(t),r.error(t)};return e.subscribe((0,s._)(r,function(t){return null==i?void 0:i.next(t)},function(){i.complete(),r.complete()},c)),(0,a.Tg)(t).subscribe((0,s._)(r,function(){i.complete(),r.next(i=new n.B)},o.l,c)),function(){null==i||i.unsubscribe(),i=null}})}},1252(t,e,r){"use strict";r.d(e,{k:()=>a});var n=r(5608),i=r(9097),s=r(2185),o=r(869);function a(t,e){void 0===e&&(e=0);var r=e>0?e:t;return(0,s.N)(function(e,s){var a=[new i.B],c=0;s.next(a[0].asObservable()),e.subscribe((0,o._)(s,function(e){var o,u;try{for(var l=(0,n.Ju)(a),h=l.next();!h.done;h=l.next()){h.value.next(e)}}catch(t){o={error:t}}finally{try{h&&!h.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}var f=c-t+1;if(f>=0&&f%r===0&&a.shift().complete(),++c%r===0){var d=new i.B;a.push(d),s.next(d.asObservable())}},function(){for(;a.length>0;)a.shift().complete();s.complete()},function(t){for(;a.length>0;)a.shift().error(t);s.error(t)},function(){a=null}))})}},8442(t,e,r){"use strict";r.d(e,{s:()=>h});var n=r(9097),i=r(4611),s=r(1868),o=r(2185),a=r(869),c=r(1601),u=r(5361),l=r(4184);function h(t){for(var e,r,h=[],f=1;f<arguments.length;f++)h[f-1]=arguments[f];var d=null!==(e=(0,u.lI)(h))&&void 0!==e?e:i.E,p=null!==(r=h[0])&&void 0!==r?r:null,g=h[1]||1/0;return(0,o.N)(function(e,r){var i=[],o=!1,u=function(t){var e=t.window,r=t.subs;e.complete(),r.unsubscribe(),(0,c.o)(i,t),o&&h()},h=function(){if(i){var e=new s.yU;r.add(e);var o=new n.B,a={window:o,subs:e,seen:0};i.push(a),r.next(o.asObservable()),(0,l.N)(e,d,function(){return u(a)},t)}};null!==p&&p>=0?(0,l.N)(r,d,h,p,!0):o=!0,h();var f=function(t){return i.slice().forEach(t)},m=function(t){f(function(e){var r=e.window;return t(r)}),t(r),r.unsubscribe()};return e.subscribe((0,a._)(r,function(t){f(function(e){e.window.next(t),g<=++e.seen&&u(e)})},function(){return m(function(t){return t.complete()})},function(t){return m(function(e){return e.error(t)})})),function(){i=null}})}},8771(t,e,r){"use strict";r.d(e,{J:()=>h});var n=r(5608),i=r(9097),s=r(1868),o=r(2185),a=r(6195),c=r(869),u=r(2508),l=r(1601);function h(t,e){return(0,o.N)(function(r,o){var h=[],f=function(t){for(;0<h.length;)h.shift().error(t);o.error(t)};(0,a.Tg)(t).subscribe((0,c._)(o,function(t){var r=new i.B;h.push(r);var n,d=new s.yU;try{n=(0,a.Tg)(e(t))}catch(t){return void f(t)}o.next(r.asObservable()),d.add(n.subscribe((0,c._)(o,function(){(0,l.o)(h,r),r.complete(),d.unsubscribe()},u.l,f)))},u.l)),r.subscribe((0,c._)(o,function(t){var e,r,i=h.slice();try{for(var s=(0,n.Ju)(i),o=s.next();!o.done;o=s.next()){o.value.next(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}},function(){for(;0<h.length;)h.shift().complete();o.complete()},f,function(){for(;0<h.length;)h.shift().unsubscribe()}))})}},63(t,e,r){"use strict";r.d(e,{p:()=>a});var n=r(9097),i=r(2185),s=r(869),o=r(6195);function a(t){return(0,i.N)(function(e,r){var i,a,c=function(t){i.error(t),r.error(t)},u=function(){var e;null==a||a.unsubscribe(),null==i||i.complete(),i=new n.B,r.next(i.asObservable());try{e=(0,o.Tg)(t())}catch(t){return void c(t)}e.subscribe(a=(0,s._)(r,u,u,c))};u(),e.subscribe((0,s._)(r,function(t){return i.next(t)},function(){i.complete(),r.complete()},c,function(){null==a||a.unsubscribe(),i=null}))})}},6248(t,e,r){"use strict";r.d(e,{E:()=>l});var n=r(5608),i=r(2185),s=r(869),o=r(6195),a=r(4254),c=r(2508),u=r(5361);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=(0,u.ms)(t);return(0,i.N)(function(e,i){for(var u=t.length,l=new Array(u),h=t.map(function(){return!1}),f=!1,d=function(e){(0,o.Tg)(t[e]).subscribe((0,s._)(i,function(t){l[e]=t,f||h[e]||(h[e]=!0,(f=h.every(a.D))&&(h=null))},c.l))},p=0;p<u;p++)d(p);e.subscribe((0,s._)(i,function(t){if(f){var e=(0,n.fX)([t],(0,n.zs)(l));i.next(r?r.apply(void 0,(0,n.fX)([],(0,n.zs)(e))):e)}}))})}},2440(t,e,r){"use strict";r.d(e,{y:()=>o});var n=r(5608),i=r(9568),s=r(2185);function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,s.N)(function(e,r){i.y.apply(void 0,(0,n.fX)([e],(0,n.zs)(t))).subscribe(r)})}},137(t,e,r){"use strict";r.d(e,{x:()=>s});var n=r(9568),i=r(9732);function s(t){return(0,i.q)(n.y,t)}},464(t,e,r){"use strict";r.d(e,{O:()=>s});var n=r(5608),i=r(2440);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.y.apply(void 0,(0,n.fX)([],(0,n.zs)(t)))}},9862(t,e,r){"use strict";r.d(e,{S:()=>a});var n=r(1824),i=r(9758),s=r(4460),o=r(4184);function a(t,e){return new n.c(function(r){var n;return(0,o.N)(r,e,function(){n=t[i.l](),(0,o.N)(r,e,function(){var t,e,i;try{e=(t=n.next()).value,i=t.done}catch(t){return void r.error(t)}i?r.complete():r.next(e)},0,!0)}),function(){return(0,s.T)(null==n?void 0:n.return)&&n.return()}})}},489(t,e,r){"use strict";r.d(e,{c:()=>y});var n=r(6195),i=r(5106),s=r(6518);var o=r(1824);var a=r(9862),c=r(4184);function u(t,e){if(!t)throw new Error("Iterable cannot be null");return new o.c(function(r){(0,c.N)(r,e,function(){var n=t[Symbol.asyncIterator]();(0,c.N)(r,e,function(){n.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}var l=r(3330),h=r(6691),f=r(1604),d=r(3206),p=r(4956),g=r(4904),m=r(8523);function y(t,e){if(null!=t){if((0,l.l)(t))return function(t,e){return(0,n.Tg)(t).pipe((0,s._)(e),(0,i.Q)(e))}(t,e);if((0,f.X)(t))return function(t,e){return new o.c(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}(t,e);if((0,h.y)(t))return function(t,e){return(0,n.Tg)(t).pipe((0,s._)(e),(0,i.Q)(e))}(t,e);if((0,p.T)(t))return u(t,e);if((0,d.x)(t))return(0,a.S)(t,e);if((0,m.U)(t))return function(t,e){return u((0,m.C)(t),e)}(t,e)}throw(0,g.L)(t)}},7771(t,e,r){"use strict";r.d(e,{R:()=>a});var n=r(5608),i=function(t){function e(e,r){return t.call(this)||this}return(0,n.C6)(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(r(1868).yU),s={setInterval:function(t,e){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var o=s.delegate;return(null==o?void 0:o.setInterval)?o.setInterval.apply(o,(0,n.fX)([t,e],(0,n.zs)(r))):setInterval.apply(void 0,(0,n.fX)([t,e],(0,n.zs)(r)))},clearInterval:function(t){var e=s.delegate;return((null==e?void 0:e.clearInterval)||clearInterval)(t)},delegate:void 0},o=r(1601),a=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return(0,n.C6)(e,t),e.prototype.schedule=function(t,e){var r;if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,e)),this.pending=!0,this.delay=e,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),s.setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return e;null!=e&&s.clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r,n=!1;try{this.work(t)}catch(t){n=!0,r=t||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},e.prototype.unsubscribe=function(){if(!this.closed){var e=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,(0,o.o)(n,this),null!=e&&(this.id=this.recycleAsyncId(r,e,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(i)},7042(t,e,r){"use strict";r.d(e,{q:()=>s});var n=r(5608),i=r(4644),s=function(t){function e(e,r){void 0===r&&(r=i._.now);var n=t.call(this,e,r)||this;return n.actions=[],n._active=!1,n}return(0,n.C6)(e,t),e.prototype.flush=function(t){var e=this.actions;if(this._active)e.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this._active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(i._)},4611(t,e,r){"use strict";r.d(e,{E:()=>i,b:()=>s});var n=r(7771),i=new(r(7042).q)(n.R),s=i},8154(t,e,r){"use strict";r.d(e,{U:()=>n});var n={now:function(){return(n.delegate||Date).now()},delegate:void 0}},533(t,e,r){"use strict";r.d(e,{f:()=>i});var n=r(5608),i={setTimeout:function(t,e){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];var o=i.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,(0,n.fX)([t,e],(0,n.zs)(r))):setTimeout.apply(void 0,(0,n.fX)([t,e],(0,n.zs)(r)))},clearTimeout:function(t){var e=i.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0}},9758(t,e,r){"use strict";r.d(e,{l:()=>n});var n="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"},9805(t,e,r){"use strict";r.d(e,{s:()=>n});var n="function"==typeof Symbol&&Symbol.observable||"@@observable"},5339(t,e,r){"use strict";r.d(e,{k:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}})},1585(t,e,r){"use strict";r.d(e,{G:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}})},1753(t,e,r){"use strict";r.d(e,{m:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.name="NotFoundError",this.message=e}})},8032(t,e,r){"use strict";r.d(e,{P:()=>n});var n=(0,r(4166).L)(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})},6611(t,e,r){"use strict";r.d(e,{I:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.name="SequenceError",this.message=e}})},402(t,e,r){"use strict";r.d(e,{Z:()=>n});var n=(0,r(4166).L)(function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}})},5361(t,e,r){"use strict";r.d(e,{R0:()=>c,lI:()=>a,ms:()=>o});var n=r(4460),i=r(1867);function s(t){return t[t.length-1]}function o(t){return(0,n.T)(s(t))?t.pop():void 0}function a(t){return(0,i.m)(s(t))?t.pop():void 0}function c(t,e){return"number"==typeof s(t)?t.pop():e}},1854(t,e,r){"use strict";r.d(e,{D:()=>a});var n=Array.isArray,i=Object.getPrototypeOf,s=Object.prototype,o=Object.keys;function a(t){if(1===t.length){var e=t[0];if(n(e))return{args:e,keys:null};if((a=e)&&"object"==typeof a&&i(a)===s){var r=o(e);return{args:r.map(function(t){return e[t]}),keys:r}}}var a;return{args:t,keys:null}}},7589(t,e,r){"use strict";r.d(e,{K:()=>i});var n=Array.isArray;function i(t){return 1===t.length&&n(t[0])?t[0]:t}},1601(t,e,r){"use strict";function n(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}r.d(e,{o:()=>n})},4166(t,e,r){"use strict";function n(t){var e=t(function(t){Error.call(t),t.stack=(new Error).stack});return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}r.d(e,{L:()=>n})},9407(t,e,r){"use strict";function n(t,e){return t.reduce(function(t,r,n){return t[r]=e[n],t},{})}r.d(e,{e:()=>n})},7861(t,e,r){"use strict";r.d(e,{Y:()=>s,l:()=>o});var n=r(747),i=null;function s(t){if(n.$.useDeprecatedSynchronousErrorHandling){var e=!i;if(e&&(i={errorThrown:!1,error:null}),t(),e){var r=i,s=r.errorThrown,o=r.error;if(i=null,s)throw o}}else t()}function o(t){n.$.useDeprecatedSynchronousErrorHandling&&i&&(i.errorThrown=!0,i.error=t)}},4184(t,e,r){"use strict";function n(t,e,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var s=e.schedule(function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(s),!i)return s}r.d(e,{N:()=>n})},4254(t,e,r){"use strict";function n(t){return t}r.d(e,{D:()=>n})},1604(t,e,r){"use strict";r.d(e,{X:()=>n});var n=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t}},4956(t,e,r){"use strict";r.d(e,{T:()=>i});var n=r(4460);function i(t){return Symbol.asyncIterator&&(0,n.T)(null==t?void 0:t[Symbol.asyncIterator])}},1592(t,e,r){"use strict";function n(t){return t instanceof Date&&!isNaN(t)}r.d(e,{v:()=>n})},4460(t,e,r){"use strict";function n(t){return"function"==typeof t}r.d(e,{T:()=>n})},3330(t,e,r){"use strict";r.d(e,{l:()=>s});var n=r(9805),i=r(4460);function s(t){return(0,i.T)(t[n.s])}},3206(t,e,r){"use strict";r.d(e,{x:()=>s});var n=r(9758),i=r(4460);function s(t){return(0,i.T)(null==t?void 0:t[n.l])}},6691(t,e,r){"use strict";r.d(e,{y:()=>i});var n=r(4460);function i(t){return(0,n.T)(null==t?void 0:t.then)}},8523(t,e,r){"use strict";r.d(e,{C:()=>s,U:()=>o});var n=r(5608),i=r(4460);function s(t){return(0,n.AQ)(this,arguments,function(){var e,r,i;return(0,n.YH)(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,(0,n.N3)(e.read())];case 3:return r=s.sent(),i=r.value,r.done?[4,(0,n.N3)(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,(0,n.N3)(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function o(t){return(0,i.T)(null==t?void 0:t.getReader)}},1867(t,e,r){"use strict";r.d(e,{m:()=>i});var n=r(4460);function i(t){return t&&(0,n.T)(t.schedule)}},2185(t,e,r){"use strict";r.d(e,{N:()=>s,S:()=>i});var n=r(4460);function i(t){return(0,n.T)(null==t?void 0:t.lift)}function s(t){return function(e){if(i(e))return e.lift(function(e){try{return t(e,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}},4981(t,e,r){"use strict";r.d(e,{I:()=>o});var n=r(5608),i=r(8045),s=Array.isArray;function o(t){return(0,i.T)(function(e){return function(t,e){return s(e)?t.apply(void 0,(0,n.fX)([],(0,n.zs)(e))):t(e)}(t,e)})}},2508(t,e,r){"use strict";function n(){}r.d(e,{l:()=>n})},8371(t,e,r){"use strict";function n(t,e){return function(r,n){return!t.call(e,r,n)}}r.d(e,{A:()=>n})},3404(t,e,r){"use strict";r.d(e,{F:()=>i,m:()=>s});var n=r(4254);function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(t)}function s(t){return 0===t.length?n.D:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}},3585(t,e,r){"use strict";r.d(e,{m:()=>s});var n=r(747),i=r(533);function s(t){i.f.setTimeout(function(){var e=n.$.onUnhandledError;if(!e)throw t;e(t)})}},4904(t,e,r){"use strict";function n(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}r.d(e,{L:()=>n})},1018(t,e,r){"use strict";r.r(e),r.d(e,{audit:()=>n.s,auditTime:()=>i.Z,buffer:()=>s.r,bufferCount:()=>o.S,bufferTime:()=>a.w,bufferToggle:()=>c.H,bufferWhen:()=>u.n,catchError:()=>l.W,combineAll:()=>h.p,combineLatest:()=>d.z,combineLatestAll:()=>f.A,combineLatestWith:()=>p.v,concat:()=>g.x,concatAll:()=>m.K,concatMap:()=>y.H,concatMapTo:()=>b.S,concatWith:()=>v.$,connect:()=>w.N,count:()=>E.U,debounce:()=>_.s,debounceTime:()=>A.B,defaultIfEmpty:()=>O.U,delay:()=>S.c,delayWhen:()=>T.o,dematerialize:()=>P.Z,distinct:()=>R.d,distinctUntilChanged:()=>x.F,distinctUntilKeyChanged:()=>I.w,elementAt:()=>N.s,endWith:()=>k.q,every:()=>L.S,exhaust:()=>C.B,exhaustAll:()=>M.C,exhaustMap:()=>B.p,expand:()=>D.f,filter:()=>U.p,finalize:()=>K.j,find:()=>H.I,findIndex:()=>F.S,first:()=>G.$,flatMap:()=>Q.q,groupBy:()=>V.$,ignoreElements:()=>j.w,isEmpty:()=>$.I,last:()=>z.H,map:()=>q.T,mapTo:()=>W.u,materialize:()=>Z.O,max:()=>Y.T,merge:()=>X.h,mergeAll:()=>J.U,mergeMap:()=>tt.Z,mergeMapTo:()=>et.C,mergeScan:()=>rt.i,mergeWith:()=>nt.X,min:()=>it.j,multicast:()=>st.f,observeOn:()=>ot.Q,onErrorResumeNext:()=>at.g,pairwise:()=>ct.J,partition:()=>lt,pluck:()=>ht.E,publish:()=>ft.m,publishBehavior:()=>dt.K,publishLast:()=>pt.k,publishReplay:()=>gt.H,race:()=>vt,raceWith:()=>bt.w,reduce:()=>wt.T,refCount:()=>St.B,repeat:()=>Et.u,repeatWhen:()=>_t.Y,retry:()=>At.L,retryWhen:()=>Ot.l,sample:()=>Tt.X,sampleTime:()=>Pt.q,scan:()=>Rt.S,sequenceEqual:()=>xt.m,share:()=>It.u,shareReplay:()=>Nt.t,single:()=>kt.J,skip:()=>Lt.i,skipLast:()=>Ct.G,skipUntil:()=>Mt.U,skipWhile:()=>Bt.j,startWith:()=>Dt.Z,subscribeOn:()=>Ut._,switchAll:()=>Kt.w,switchMap:()=>Ht.n,switchMapTo:()=>Ft.K,switchScan:()=>Gt.m,take:()=>Vt.s,takeLast:()=>jt.o,takeUntil:()=>$t.Q,takeWhile:()=>zt.v,tap:()=>qt.M,throttle:()=>Wt.n,throttleTime:()=>Zt.c,throwIfEmpty:()=>Yt.v,timeInterval:()=>Xt.f,timeout:()=>Jt.w,timeoutWith:()=>Qt.o,timestamp:()=>te.v,toArray:()=>ee.$,window:()=>re.x,windowCount:()=>ne.k,windowTime:()=>ie.s,windowToggle:()=>se.J,windowWhen:()=>oe.p,withLatestFrom:()=>ae.E,zip:()=>ce.y,zipAll:()=>ue.x,zipWith:()=>le.O});var n=r(4168),i=r(7013),s=r(9801),o=r(9542),a=r(3132),c=r(6145),u=r(6689),l=r(672),h=r(8363),f=r(9142),d=r(1481),p=r(8957),g=r(3267),m=r(2348),y=r(949),b=r(4292),v=r(4011),w=r(1715),E=r(6456),_=r(9780),A=r(5833),O=r(4228),S=r(2840),T=r(6660),P=r(1023),R=r(7435),x=r(5519),I=r(5538),N=r(6026),k=r(7566),L=r(5060),C=r(8017),M=r(5598),B=r(5711),D=r(2467),U=r(465),K=r(8553),H=r(4732),F=r(5206),G=r(4053),V=r(7333),j=r(9756),$=r(3694),z=r(2187),q=r(8045),W=r(3692),Z=r(6326),Y=r(7877),X=r(3375),J=r(9904),Q=r(9016),tt=r(6961),et=r(2720),rt=r(26),nt=r(6343),it=r(8287),st=r(3045),ot=r(5106),at=r(1264),ct=r(9127),ut=r(8371);function lt(t,e){return function(r){return[(0,U.p)(t,e)(r),(0,U.p)((0,ut.A)(t,e))(r)]}}var ht=r(8614),ft=r(1996),dt=r(9514),pt=r(2812),gt=r(4679),mt=r(5608),yt=r(7589),bt=r(8702);function vt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bt.w.apply(void 0,(0,mt.fX)([],(0,mt.zs)((0,yt.K)(t))))}var wt=r(8933),Et=r(744),_t=r(1204),At=r(9185),Ot=r(1478),St=r(8815),Tt=r(7073),Pt=r(84),Rt=r(510),xt=r(4112),It=r(1452),Nt=r(4103),kt=r(4623),Lt=r(3616),Ct=r(5152),Mt=r(3430),Bt=r(9955),Dt=r(8263),Ut=r(6518),Kt=r(5056),Ht=r(8737),Ft=r(1200),Gt=r(2570),Vt=r(5172),jt=r(3172),$t=r(1762),zt=r(247),qt=r(8322),Wt=r(8359),Zt=r(626),Yt=r(5007),Xt=r(5223),Jt=r(3572),Qt=r(3868),te=r(6715),ee=r(2033),re=r(6063),ne=r(1252),ie=r(8442),se=r(8771),oe=r(63),ae=r(6248),ce=r(2440),ue=r(137),le=r(464)},6571(t,e,r){"use strict";var n;r.r(e),r.d(e,{DeprecationError:()=>I,InvalidAddressError:()=>f,InvalidAmountError:()=>y,InvalidBlockHashError:()=>m,InvalidChainIdError:()=>T,InvalidContractAddressError:()=>S,InvalidDerivationPathError:()=>b,InvalidFinalizeUnstakeAmountError:()=>g,InvalidHexStringError:()=>v,InvalidKeyError:()=>_,InvalidKeyHashError:()=>P,InvalidMessageError:()=>w,InvalidOperationHashError:()=>R,InvalidOperationKindError:()=>x,InvalidProofError:()=>d,InvalidPublicKeyError:()=>A,InvalidSignatureError:()=>O,InvalidStakingAddressError:()=>p,InvalidViewParameterError:()=>E,NetworkError:()=>l,ParameterValidationError:()=>o,PermissionDeniedError:()=>h,ProhibitedActionError:()=>N,PublicKeyNotFoundError:()=>k,RpcError:()=>a,TaquitoError:()=>s,TezosToolkitConfigError:()=>c,UnsupportedActionError:()=>u,ValidationResult:()=>n}),function(t){t[t.NO_PREFIX_MATCHED=0]="NO_PREFIX_MATCHED",t[t.INVALID_CHECKSUM=1]="INVALID_CHECKSUM",t[t.INVALID_LENGTH=2]="INVALID_LENGTH",t[t.VALID=3]="VALID",t[t.PREFIX_NOT_ALLOWED=4]="PREFIX_NOT_ALLOWED",t[t.INVALID_ENCODING=5]="INVALID_ENCODING",t[t.OTHER=6]="OTHER"}(n||(n={}));const i={[n.NO_PREFIX_MATCHED]:"unsupported Base58 prefix",[n.INVALID_CHECKSUM]:"invalid checksum",[n.INVALID_LENGTH]:"invalid length",[n.PREFIX_NOT_ALLOWED]:"Base58 prefix not allowed in this context",[n.INVALID_ENCODING]:"invalid Base58 encoding"};class s extends Error{}class o extends s{constructor(t,e,r){let n,s,o;void 0!==t&&("string"==typeof t?(o=t,void 0!==e&&("string"==typeof e?n=e:(s=e,n=void 0!==r?r:i[e]))):(s=t,n=i[t],o=n)),super(o),this.name=this.constructor.name,this.result=s,this.errorDetail=n}}class a extends s{}class c extends s{}class u extends s{}class l extends s{}class h extends s{}class f extends o{constructor(t,e){super(`Invalid address "${t}"`,e),this.address=t,this.name=this.constructor.name}}class d extends o{constructor(t,e){super(`Invalid proof "${t}"`,e),this.proof=t,this.name=this.constructor.name}}class p extends o{constructor(t,e){super(`Invalid staking address "${t}", you can only set destination as your own address`,e),this.address=t,this.name=this.constructor.name}}class g extends o{constructor(t,e){super("The amount can only be 0 when finalizing an unstake",e),this.address=t,this.name=this.constructor.name}}class m extends o{constructor(t,e){super(`Invalid block hash "${t}"`,e),this.blockHash=t,this.name=this.constructor.name}}class y extends o{constructor(t,e){super(`Invalid amount "${t}"`,e),this.amount=t,this.name=this.constructor.name}}class b extends o{constructor(t,e){super(`Invalid derivation path "${t}"`,e),this.derivationPath=t,this.name=this.constructor.name}}class v extends o{constructor(t,e){super(`Invalid hex string "${t}"`,e),this.hexString=t,this.name=this.constructor.name}}class w extends o{constructor(t,e){super(`Invalid message "${t}"`,e),this.msg=t,this.name=this.constructor.name}}class E extends o{constructor(t,e,r,n,i){super(`Invalid view arguments ${JSON.stringify(r)} received for name "${t}" expecting one of the following signatures ${JSON.stringify(e)}.`,i),this.viewName=t,this.sigs=e,this.args=r,this.cause=n,this.name=this.constructor.name}}class _ extends o{constructor(t){super("Invalid private key",t),this.name=this.constructor.name}}class A extends o{constructor(t,e){super(void 0!==t?`Invalid public key "${t}"`:"Invalid public key",e),this.publicKey=t,this.name=this.constructor.name}}class O extends o{constructor(t,e){super(`Invalid signature "${t}"`,e),this.signature=t,this.name=this.constructor.name}}class S extends o{constructor(t,e){super(`Invalid contract address "${t}"`,e),this.contractAddress=t,this.name=this.constructor.name}}class T extends o{constructor(t,e){super(`Invalid chain id "${t}"`,e),this.chainId=t,this.name=this.constructor.name}}class P extends o{constructor(t,e){super(`Invalid public key hash "${t}"`,e),this.keyHash=t,this.name=this.constructor.name}}class R extends o{constructor(t,e){super(`Invalid operation hash "${t}"`,e),this.operationHash=t,this.name=this.constructor.name}}class x extends o{constructor(t,e){super(`Invalid operation kind "${t}"`,e),this.operationKind=t,this.name=this.constructor.name}}class I extends u{constructor(t){super(t),this.name=this.constructor.name}}class N extends u{constructor(t){super(t),this.name=this.constructor.name}}class k extends s{constructor(t,e){super(`Public key not found of this address "${t}" in either wallet or contract API.`),this.pkh=t,this.cause=e,this.name=this.constructor.name}}},2211(t,e,r){"use strict";r.r(e),r.d(e,{HttpBackend:()=>P,HttpRequestFailed:()=>i,HttpResponseError:()=>s,HttpTimeoutError:()=>o,STATUS_CODE:()=>f,VERSION:()=>d,classifyTransportError:()=>h});var n=r(6571);class i extends n.NetworkError{constructor(t,e,r,n){super(),this.method=t,this.url=e,this.cause=r,this.name="HttpRequestFailed";const i=function(t){let e=t,r=0;for(;!(r>=10);){const t=e.cause;if(!(t instanceof Error)){if("object"==typeof t&&null!==t&&"string"==typeof t.message){const r=t;e={message:r.message,code:"string"==typeof r.code?r.code:void 0};break}break}e=t,r++}return e}(r),s=i.code,o=i!==r?`${i.message}${s?` [${s}]`:""}`:r.message,a=n?` (${n.kind})`:"";this.message=`${t} ${e}${a}: ${o}`,this.transportError=n}}class s extends n.NetworkError{constructor(t,e,r,n,i){super(),this.message=t,this.status=e,this.statusText=r,this.body=n,this.url=i,this.name="HttpResponseError"}}class o extends n.NetworkError{constructor(t,e){super(),this.timeout=t,this.url=e,this.name="HttpTimeoutError",this.message=`HTTP request timeout of ${t}ms exceeded`}}const a={abort:!1,dns:!1,connect:!1,socket:!0,tls:!1,timeout:!0,network:!0};function c(t){if("object"!=typeof t||null===t)return;const e=t.code;return"string"==typeof e?e:void 0}function u(t){if("object"==typeof t&&null!==t)return t.cause}function l(t,e){return{kind:t,mayHaveReachedServer:a[t],original:e}}function h(t){if(!(t instanceof Error))return;const e=c(t),r=function(t){return c(u(t))}(t),n=t.message.toLowerCase(),i=function(t){const e=u(t);if("object"==typeof e&&null!==e){const t=e.message;if("string"==typeof t)return t.toLowerCase()}return""}(t);if("AbortError"===t.name)return l("abort",t);if("ENOTFOUND"===e||"EAI_AGAIN"===e||"ENOTFOUND"===r||"EAI_AGAIN"===r||n.includes("enotfound")||n.includes("eai_again"))return l("dns",t);if("ECONNREFUSED"===e||"ECONNREFUSED"===r||"UND_ERR_CONNECT_TIMEOUT"===r||n.includes("econnrefused"))return l("connect",t);if(n.includes("certificate")||n.includes("self signed")||n.includes("ssl")||n.includes("handshake")||i.includes("certificate")||i.includes("self signed")||i.includes("ssl")||i.includes("handshake"))return l("tls",t);if("ETIMEDOUT"===e||"ETIMEDOUT"===r||"UND_ERR_HEADERS_TIMEOUT"===r||"UND_ERR_BODY_TIMEOUT"===r||n.includes("etimedout")||n.includes("timed out"))return l("timeout",t);if("ECONNRESET"===e||"ECONNRESET"===r||"UND_ERR_SOCKET"===r||n.includes("econnreset")||n.includes("socket hang up")||n.includes("other side closed")||n.includes("closed unexpectedly")||n.includes("connection reset"))return l("socket",t);if(t instanceof TypeError&&(n.includes("fetch failed")||n.includes("failed to fetch")||n.includes("network error")||n.includes("error sending request")||"terminated"===n))return l("network",t);if("FetchError"===t.name){const e=t.type;return"request-timeout"===e||"body-timeout"===e?l("timeout",t):"system"===e?l("network",t):void 0}}var f;!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"}(f||(f={}));const d={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"};if("function"!=typeof globalThis.fetch)throw new Error("No fetch implementation available. Requires Node.js >= 22 or a browser environment.");const p="undefined"!=typeof process?process.env:void 0,g=/^(1|true)$/i.test(p?.TAQUITO_HTTP_TRACE??"")||"1"===p?.RUNNER_DEBUG,m=Number(p?.TAQUITO_HTTP_RETRY_COUNT??"1"),y=Number.isFinite(m)&&m>=0?Math.floor(m):1,b=Number(p?.TAQUITO_HTTP_RETRY_BASE_MS??"100"),v=Number.isFinite(b)&&b>=0?b:100,w=t=>{try{const e=new URL(t);return`${e.origin}${e.pathname}`}catch{return t.split("?")[0]}},E=t=>{g&&console.log(`[taquito:http-trace] ${JSON.stringify(t)}`)},_=t=>t.cause,A=t=>{const e=t.code;return"string"==typeof e?e:void 0},O=t=>{if(!(t instanceof Error))return String(t);const e=[`${t.name}: ${t.message}`];let r=_(t),n=0;for(;n<10;){if(r instanceof Error){const t=A(r),i=t?` [${t}]`:"";e.push(`${r.name}: ${r.message}${i}`),r=_(r),n++;continue}if("object"==typeof r&&null!==r&&"string"==typeof r.message){const t=r,n="string"==typeof t.code?t.code:void 0,i=n?` [${n}]`:"";e.push(`${t.message}${i}`)}break}return e.join(" → ")},S=(t,e)=>{const r=t.toUpperCase();if("GET"===r)return!0;if("POST"!==r)return!1;const n=w(e);return n.endsWith("/helpers/forge/operations")||n.endsWith("/helpers/preapply/operations")||n.endsWith("/helpers/scripts/simulate_operation")||n.endsWith("/helpers/scripts/run_operation")||n.endsWith("/injection/operation")},T=t=>new Promise(e=>setTimeout(e,t));class P{constructor(t=3e4){this.timeout=t}serialize(t){if(!t)return"";const e=[];for(const r in t)if(t.hasOwnProperty(r)&&void 0!==t[r]){const n=t[r];if(null===n){e.push(encodeURIComponent(r));continue}const i="function"==typeof n.toJSON?n.toJSON():n;if(null===i){e.push(encodeURIComponent(r));continue}if(Array.isArray(i)){i.forEach(t=>{e.push(encodeURIComponent(r)+"="+encodeURIComponent(t))});continue}e.push(encodeURIComponent(r)+"="+encodeURIComponent(i))}const r=e.join("&");return r?`?${r}`:""}async createRequest({url:t,method:e,timeout:r=this.timeout,query:n,headers:a={},json:c=!0},u){const l=t+this.serialize(n),f=String(e??"GET");let d;a["Content-Type"]||(a["Content-Type"]="application/json");let p=!1;for(let t=0;t<=y;t++){const n=new AbortController,g=setTimeout(()=>n.abort(),r),m=Date.now();try{p||(d=JSON.stringify(u),p=!0);const t=await globalThis.fetch(l,{method:e,headers:a,body:d,signal:n.signal});if(void 0===t)throw new Error("Response is undefined");if(t.status>=400){const e=await t.text();throw E({stage:"response-error",method:f,url:w(l),status:t.status,elapsedMs:Date.now()-m}),new s(`Http error response: (${t.status}) ${e}`,t.status,t.statusText,e,l)}return E({stage:"response-ok",method:f,url:w(l),status:t.status,elapsedMs:Date.now()-m}),c?t.json():t.text()}catch(e){if(e instanceof s)throw E({stage:"http-response-error",method:f,url:w(l),elapsedMs:Date.now()-m,status:e.status}),e;const n=e instanceof Error?h(e):void 0,a=void 0!==n&&"abort"!==n.kind&&"tls"!==n.kind;if(t<y&&S(f,l)&&a){const r=v*Math.pow(2,t)+Math.floor(Math.random()*v);E({stage:"request-retry",method:f,url:w(l),elapsedMs:Date.now()-m,attempt:t+1,maxAttempts:y+1,retryDelayMs:r,error:O(e),transportKind:n?.kind}),await T(r);continue}if("abort"===n?.kind)throw E({stage:"timeout",method:f,url:w(l),elapsedMs:Date.now()-m,timeoutMs:r}),new o(r,l);{E({stage:"request-failed",method:f,url:w(l),elapsedMs:Date.now()-m,error:O(e),transportKind:n?.kind});const t=e instanceof Error?e:new Error(String(e));throw new i(f,l,t,n)}}finally{clearTimeout(g)}}throw new Error("Unexpected request retry flow")}}},8175(t,e,r){"use strict";r.r(e),r.d(e,{CODEC:()=>T,LocalForger:()=>oe,ProtocolsHash:()=>re,Uint8ArrayConsumer:()=>z,VERSION:()=>ne,decoders:()=>Xt,encoders:()=>Jt,getCodec:()=>se,localForger:()=>ae,opMapping:()=>P,opMappingReverse:()=>R});r(3737);var n=r(2403),i=r(6571),s=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,a,c,l,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!o.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(u+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(c<0&&(c=l),c+=+d.slice(l+1),d=d.substring(0,l)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(u+"String expected: "+t);for(v(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=l=0,f=d.length;l<f;l++)if(r.indexOf(s=d.charAt(l))<0){if("."==s){if(l>c){c=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,l=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(l=0;48===d.charCodeAt(l);l++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(l,++f))if(f-=l,(c=c-l-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],l=(c+1)%h,c<0&&(l+=h),l<f){for(l&&g.c.push(+d.slice(0,l)),f-=h;l<f;)g.c.push(+d.slice(l,l+=h));l=h-(d=d.slice(l)).length}else l-=f;for(;l--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=y(t.c),c=1==n||2==n&&(o<=T||o>=P)?E(c,o):_(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=E(c,s)}else if(e-=o+(2===n&&s>o),c=_(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=b(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*h-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,u,f,p,g,m=t.c,y=d;if(m){t:{for(i=1,u=m[0];u>=10;u/=10,i++);if((s=e-i)<0)s+=h,o=e,f=m[p=0],g=c(f/y[i-o-1]%10);else if((p=a((s+1)/h))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));f=g=0,i=1,o=(s%=h)-h+1}else{for(f=u=m[p],i=1;u>=10;u/=10,i++);g=(o=(s%=h)-h+i)<0?0:c(f/y[i-o-1]%10)}if(n=n||e<0||null!=m[p+1]||(o<0?f:f%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?f/y[i-o]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(h-e%h)%h],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,u=1,p--):(m.length=p+1,u=y[h-s],m[p]=o>0?c(f/y[i-o]%y[o])*u:0),n)for(;;){if(0==p){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[p]+=u,m[p]!=l)break;m[p--]=0,u=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=y(t.c),e=r<=T||r>=P?E(e,r):_(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,g,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-g,0,e),v(r[1],0,g,e),T=r[0],P=r[1]):(v(r,-g,g,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-g,-1,e),v(r[1],1,g,e),R=r[0],x=r[1];else{if(v(r,-g,g,e),!r)throw Error(u+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(u+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,g,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-g||i>g||i!==c(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%h)<1&&(e+=h),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=l||r!==c(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return c(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,o,l=0,f=[],p=new M(A);if(null==t?t=O:v(t,0,g),s=a(t/h),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(o=131072*r[l]+(r[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[l]=n[0],r[l+1]=n[1]):(f.push(o%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);l<s;)(o=281474976710656*(31&r[l])+1099511627776*r[l+1]+4294967296*r[l+2]+16777216*r[l+3]+(r[l+4]<<16)+(r[l+5]<<8)+r[l+6])>=9e15?crypto.randomBytes(7).copy(r,l):(f.push(o%1e14),l+=7);l=s/7}if(!I)for(;l<s;)(o=e())<9e15&&(f[l++]=o%1e14);for(s=f[--l],t%=h,s&&t&&(o=d[h-t],f[l]=c(s/o)*o);0===f[l];f.pop(),l--);if(l<0)f=[i=0];else{for(i=-1;0===f[0];f.splice(0,1),i-=h);for(l=1,o=f[0];o>=10;o/=10,l++);l<h&&(i-=h-l)}return p.e=i,p.c=f,p}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),b=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(_(y(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),m=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?_(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=_(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%p)+(n=l*s+(o=t[c]/p|0)*u)%p*p+a)/r|0)+(n/p|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var u,f,d,p,g,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),x=x/h|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=c(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(u=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=c(A/T))>1)for(g>=a&&(g=a-1),b=(y=t(N,g,a)).length,_=E.length;1==e(y,E,b,_);)g--,r(y,P<b?R:N,b,a),b=y.length,u=1;else 0==g&&(u=g=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,a),_=E.length,-1==u)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===u&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==l){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*h-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,c);throw Error(u+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return b(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return v(t,0,g),null==e?e=S:v(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,o,l,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),o=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),o?t.s*(2-w(t)):+F(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||o&&p.c[1]>=24e7:p.c[0]<8e13||o&&p.c[0]<=9999975e7)))return s=p.s<0&&w(t)?-0:0,p.e>-1&&(s=1/s),new M(l?1/s:s);k&&(s=a(k/h+2))}for(o?(r=new M(.5),l&&(t.s=1),f=w(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=w(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(l&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:v(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===b(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return b(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=b(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return b(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=b(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/h,u=t.e/h,f=o.c,d=t.c;if(!c||!u){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=m(c),u=m(u),f=f.slice(),a=c-u){for((s=a<0)?(a=-a,i=f):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=l-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--u);return f[0]?K(t,f,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,f,d,g,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=m(E.e/h)+m(t.e/h),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=l,w=p,i=d;--i>=0;){for(r=0,g=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((u=g*(u=_[--o]%w)+(a=y*u+(f=_[o]/w|0)*g)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/h,o=t.e/h,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=m(s),o=m(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/l|0,a[e]=l===a[e]?0:a[e]%l;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return v(t,1,g),null==e?e=S:v(e,0,8),H(new M(s),t,e);if(!(r=s.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&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return v(t,-9007199254740991,f),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=y(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=m((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(v(t,0,g),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(v(t,0,g),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);c>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,o,a,c,l,f,p,g,m,b=this,v=b.c;if(null!=t&&(!(c=new M(t)).isInteger()&&(c.c||1!==c.s)||c.lt(A)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+F(c));if(!v)return new M(b);for(e=new M(A),f=n=new M(A),i=l=new M(A),m=y(v),o=e.e=m.length-b.e-1,e.c[0]=d[(a=o%h)<0?h+a:a],t=!t||c.comparedTo(e)>0?o>0?e:f:c,a=x,x=1/0,c=new M(m),l.c[0]=0;p=r(c,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,f=l.plus(p.times(s=f)),l=s,e=c.minus(p.times(s=e)),c=s;return s=r(t.minus(n),i,0,1),l=l.plus(s.times(f)),n=n.plus(s.times(i)),l.s=f.s=b.s,g=r(f,i,o*=2,S).minus(b).abs().comparedTo(r(l,n,o,S).minus(b).abs())<1?[f,i]:[l,n],x=a,g},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&v(t,1,g),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?E(y(r.c),s):_(y(r.c),s,"0"):(v(t,2,C.length,"Base"),e=n(_(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=1e14,h=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function m(t){var e=0|t;return t>0||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=h-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function w(t){var e=t.c.length-1;return m(t.e/h)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function _(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const A=s,O=t=>t.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),S=(t,e=8)=>t.toString(16).padStart(e,"0");var T;!function(t){t.SECRET="secret",t.RAW="raw",t.TZ1="tz1",t.BRANCH="branch",t.ZARITH="zarith",t.PUBLIC_KEY="public_key",t.PKH="pkh",t.PKH_ARR="pkhArr",t.DELEGATE="delegate",t.SCRIPT="script",t.BALLOT_STATEMENT="ballotStmt",t.PROPOSAL="proposal",t.PROPOSAL_ARR="proposalArr",t.INT32="int32",t.INT16="int16",t.PARAMETERS="parameters",t.ADDRESS="address",t.SMART_CONTRACT_ADDRESS="smart_contract_address",t.SMART_ROLLUP_ADDRESS="smart_rollup_address",t.SMART_ROLLUP_COMMITMENT_HASH="smart_rollup_commitment_hash",t.VALUE="value",t.PADDED_BYTES="padded_bytes",t.SMART_ROLLUP_MESSAGE="smart_rollup_message",t.MANAGER="manager",t.BLOCK_PAYLOAD_HASH="blockPayloadHash",t.ENTRYPOINT="entrypoint",t.OPERATION="operation",t.OP_ACTIVATE_ACCOUNT="activate_account",t.OP_DELEGATION="delegation",t.OP_TRANSACTION="transaction",t.OP_ORIGINATION="origination",t.OP_BALLOT="ballot",t.OP_FAILING_NOOP="failing_noop",t.OP_ATTESTATION="attestation",t.OP_ATTESTATION_WITH_DAL="attestation_with_dal",t.OP_SEED_NONCE_REVELATION="seed_nonce_revelation",t.OP_REVEAL="reveal",t.OP_PROPOSALS="proposals",t.OP_REGISTER_GLOBAL_CONSTANT="register_global_constant",t.OP_TRANSFER_TICKET="transfer_ticket",t.BURN_LIMIT="burn_limit",t.OP_INCREASE_PAID_STORAGE="increase_paid_storage",t.OP_UPDATE_CONSENSUS_KEY="update_consensus_key",t.OP_UPDATE_COMPANION_KEY="update_companion_key",t.SIGNATURE_PROOF="signature_proof",t.OP_DRAIN_DELEGATE="drain_delegate",t.DEPOSITS_LIMIT="deposits_limit",t.OP_SET_DEPOSITS_LIMIT="set_deposits_limit",t.OP_SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.PVM_KIND="pvm_kind",t.OP_SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.OP_DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.SLOT_HEADER="slot_header"}(T||(T={}));const P={"00":"parameter","01":"storage","02":"code","03":"False","04":"Elt","05":"Left","06":"None","07":"Pair","08":"Right","09":"Some","0a":"True","0b":"Unit","0c":"PACK","0d":"UNPACK","0e":"BLAKE2B","0f":"SHA256",10:"SHA512",11:"ABS",12:"ADD",13:"AMOUNT",14:"AND",15:"BALANCE",16:"CAR",17:"CDR",18:"CHECK_SIGNATURE",19:"COMPARE","1a":"CONCAT","1b":"CONS","1c":"CREATE_ACCOUNT","1d":"CREATE_CONTRACT","1e":"IMPLICIT_ACCOUNT","1f":"DIP",20:"DROP",21:"DUP",22:"EDIV",23:"EMPTY_MAP",24:"EMPTY_SET",25:"EQ",26:"EXEC",27:"FAILWITH",28:"GE",29:"GET","2a":"GT","2b":"HASH_KEY","2c":"IF","2d":"IF_CONS","2e":"IF_LEFT","2f":"IF_NONE",30:"INT",31:"LAMBDA",32:"LE",33:"LEFT",34:"LOOP",35:"LSL",36:"LSR",37:"LT",38:"MAP",39:"MEM","3a":"MUL","3b":"NEG","3c":"NEQ","3d":"NIL","3e":"NONE","3f":"NOT",40:"NOW",41:"OR",42:"PAIR",43:"PUSH",44:"RIGHT",45:"SIZE",46:"SOME",47:"SOURCE",48:"SENDER",49:"SELF","4a":"STEPS_TO_QUOTA","4b":"SUB","4c":"SWAP","4d":"TRANSFER_TOKENS","4e":"SET_DELEGATE","4f":"UNIT",50:"UPDATE",51:"XOR",52:"ITER",53:"LOOP_LEFT",54:"ADDRESS",55:"CONTRACT",56:"ISNAT",57:"CAST",58:"RENAME",59:"bool","5a":"contract","5b":"int","5c":"key","5d":"key_hash","5e":"lambda","5f":"list",60:"map",61:"big_map",62:"nat",63:"option",64:"or",65:"pair",66:"set",67:"signature",68:"string",69:"bytes","6a":"mutez","6b":"timestamp","6c":"unit","6d":"operation","6e":"address","6f":"SLICE",70:"DIG",71:"DUG",72:"EMPTY_BIG_MAP",73:"APPLY",74:"chain_id",75:"CHAIN_ID",76:"LEVEL",77:"SELF_ADDRESS",78:"never",79:"NEVER","7a":"UNPAIR","7b":"VOTING_POWER","7c":"TOTAL_VOTING_POWER","7d":"KECCAK","7e":"SHA3","7f":"PAIRING_CHECK",80:"bls12_381_g1",81:"bls12_381_g2",82:"bls12_381_fr",83:"sapling_state",84:"sapling_transaction_deprecated",85:"SAPLING_EMPTY_STATE",86:"SAPLING_VERIFY_UPDATE",87:"ticket",88:"TICKET_DEPRECATED",89:"READ_TICKET","8a":"SPLIT_TICKET","8b":"JOIN_TICKETS","8c":"GET_AND_UPDATE","8d":"chest","8e":"chest_key","8f":"OPEN_CHEST",90:"VIEW",91:"view",92:"constant",93:"SUB_MUTEZ",94:"tx_rollup_l2_address",95:"MIN_BLOCK_TIME",96:"sapling_transaction",97:"EMIT",98:"Lambda_rec",99:"LAMBDA_REC","9a":"TICKET","9b":"BYTES","9c":"NAT","9d":"Ticket","9e":"IS_IMPLICIT_ACCOUNT","9f":"INDEX_ADDRESS",a0:"GET_ADDRESS_INDEX"},R=(()=>{const t={};return Object.keys(P).forEach(e=>{t[P[e]]=e}),t})(),x={4:"activate_account",107:"reveal",110:"delegation",108:"transaction",109:"origination",6:"ballot",21:"attestation",23:"attestation_with_dal",1:"seed_nonce_revelation",5:"proposals",111:"register_global_constant",158:"transfer_ticket",112:"set_deposits_limit",113:"increase_paid_storage",114:"update_consensus_key",115:"update_companion_key",9:"drain_delegate",200:"smart_rollup_originate",201:"smart_rollup_add_messages",206:"smart_rollup_execute_outbox_message",230:"dal_publish_commitment",17:"failing_noop"},I=(()=>{const t={};return Object.keys(x).forEach(e=>{const r="string"==typeof e?parseInt(e,10):e;t[x[r]]=S(r,2)}),t})(),N={"00":"default","01":"root","02":"do","03":"set_delegate","04":"remove_delegate","05":"deposit","06":"stake","07":"unstake","08":"finalize_unstake","09":"set_delegate_parameters"},k=(()=>{const t={};return Object.keys(N).forEach(e=>{t[N[e]]=e}),t})();class L extends i.ParameterValidationError{constructor(t,e){super(),this.operation=t,this.errorDetail=e,this.name="InvalidOperationSchemaError",this.message="Invalid operation content recevied",e&&(this.message+=` ${e}.`)}}class C extends i.ParameterValidationError{constructor(t){super(),this.entrypoint=t,this.name="OversizedEntryPointError",this.message=`Invalid entrypoint length "${t.length}", maximum length is "31".`}}class M extends i.ParameterValidationError{constructor(t){super(),this.ballotValue=t,this.name="InvalidBallotValueError",this.message=`Invalid ballot value "${t}" expecting one of the following: "yay", "nay", "pass".`}}class B extends i.ParameterValidationError{constructor(t){super(),this.ballotValue=t,this.name="DecodeBallotValueError",this.message=`Invalid ballot value "${t}", cannot be decoded.`}}class D extends i.ParameterValidationError{constructor(t){super(),this.value=t,this.name="UnexpectedMichelsonValueError",this.message=`Invalid Michelson value "${t}", unalbe to encode.`}}class U extends i.ParameterValidationError{constructor(t){super(),this.message=t,this.name="OperationDecodingError"}}class K extends i.ParameterValidationError{constructor(t){super(),this.message=t,this.name="OperationEncodingError"}}class H extends i.ParameterValidationError{constructor(t){super(),this.op=t,this.name="UnsupportedOperationError",this.message=`Unsupported operation "${t}", can submit an issue on our github for feature request.`}}class F extends i.ParameterValidationError{constructor(t){super(),this.pvm=t,this.name="UnsupportedPvmKindError",this.message=`Invalid Pvm kind "${t}" expecting either "arith" or "wasm_2_0_0".`}}class G extends i.ParameterValidationError{constructor(t){super(),this.pvm=t,this.name="DecodePvmKindError",this.message=`Invalid Pvm kind "${t}", cannot be decoded.`}}class V extends i.ParameterValidationError{constructor(t,e){super(),this.address=t,this.errorDetail=e,this.name="InvalidSmartRollupAddress",this.message=`Invalid smart rollup address "${t}"`,e&&(this.message+=` ${e}.`)}}class j extends i.ParameterValidationError{constructor(t,e){super(),this.hash=t,this.errorDetail=e,this.name="InvalidSmartRollupCommitmentHashError",this.message=`Invalid smart rollup commitment hash "${t}"`,e&&(this.message+=` ${e}.`)}}class $ extends i.ParameterValidationError{constructor(t,e){super(),this.commitment=t,this.errorDetail=e,this.name="InvalidDalCommitmentError",this.message=`Invalid dal commitment "${t}"`,e&&(this.message+=` ${e}.`)}}class z{static fromHexString(t){const e=t.toLowerCase();if(/^(([a-f]|\d){2})*$/.test(e)){const t=new Uint8Array((e.match(/([a-z]|\d){2}/g)||[]).map(t=>parseInt(t,16)));return new z(t)}throw new i.InvalidHexStringError(e)}constructor(t,e=0){this.arr=t,this.offset=e}consume(t){const e=this.arr.subarray(this.offset,this.offset+t);return this.offset+=t,e}get(t){return this.arr[this.offset+t]}length(){return this.arr.length-this.offset}slice(t,e){return new z(this.arr.slice(t,e))}}const q=t=>{if(Array.isArray(t)){const e=t.map(t=>q(t)).join(""),r=e.length/2;return`02${S(r)}${e}`}if((t=>"prim"in t)(t))return rt(t);if((t=>"bytes"in t&&"string"==typeof t.bytes)(t))return Y(t);if((t=>"string"in t&&"string"==typeof t.string)(t))return J(t);if((t=>"int"in t&&"string"==typeof t.int)(t))return tt(t);throw new D(JSON.stringify(t))},W=t=>{const e=t.consume(1);switch(e[0]){case 10:return X(t);case 1:return Q(t);case 0:return et(t);case 2:{const e=new z(Z(t)),r=[];for(;e.length()>0;)r.push(W(e));return r}default:return nt(t,e)}},Z=(t,e=4)=>{const r=t.consume(e),n=parseInt(Buffer.from(r).toString("hex"),16);return t.consume(n)},Y=t=>{if(!/^([A-Fa-f0-9]{2})*$/.test(t.bytes))throw new i.InvalidHexStringError(t.bytes);const e=t.bytes.length/2;return`0a${S(e)}${t.bytes}`},X=t=>{const e=Z(t);return{bytes:Buffer.from(e).toString("hex")}},J=t=>{const e=Buffer.from(t.string,"utf8").toString("hex"),r=e.length/2;return`01${S(r)}${e}`},Q=t=>{const e=Z(t);return{string:Buffer.from(e).toString("utf8")}},tt=({int:t})=>{const e=new A(t,10),r="-"===e.toString(2)[0]?"1":"0",n=e.toString(2).replace(/-/g,""),i=n.length<=6?6:(n.length-6)%7?n.length+7-(n.length-6)%7:n.length,s=n.padStart(i,"0").match(/\d{6,7}/g).reverse();s[0]=r+s[0];return`00${s.map((t,e)=>parseInt((e===s.length-1?"0":"1")+t,2).toString(16).padStart(2,"0")).join("")}`},et=t=>{let e=t.consume(1)[0];const r=[];for(;128&e;)r.push(e),e=t.consume(1)[0];r.push(e);const n=!!(64&r[0]);r[0]=127&r[0];const i=r.map((t,e)=>t.toString(2).slice(0===e?-6:-7).padStart(0===e?6:7,"0")).reverse();let s=new A(i.join(""),2);return n&&(s=s.times(-1)),{int:s.toFixed()}},rt=t=>{const e=+Array.isArray(t.annots),r=Array.isArray(t.args)?t.args.length:0,n=S(Math.min(2*r+e+3,9),2),i=R[t.prim];let s=(t.args||[]).map(t=>q(t)).join("");const o=Array.isArray(t.annots)?ot(t.annots):"";return"LAMBDA"!==t.prim&&"LAMBDA_REC"!==t.prim||!r||(s=S(s.length/2)+s+S(0)),("pair"===t.prim||"Pair"===t.prim)&&r>2&&(s=""===o?S(s.length/2)+s+S(0):S(s.length/2)+s),"view"===t.prim&&t.args&&(s=S(s.length/2)+s+S(0)),`${n}${i}${s}${o}`},nt=(t,e)=>{const r=(e[0]-3)%2==1;let n=Math.floor((e[0]-3)/2);const i=t.consume(1)[0].toString(16).padStart(2,"0"),s={prim:P[i]};if("LAMBDA"!==P[i]&&"LAMBDA_REC"!==P[i]||t.consume(4),"view"===P[i])return 0!=n?it(t,s):s;let o,a;("pair"===P[i]||"Pair"===P[i])&&n>2&&(o=st(t),n=0,a=at(t));const c=new Array(n).fill(0).map(()=>W(t));return"LAMBDA"!==P[i]&&"LAMBDA_REC"!==P[i]||t.consume(4),o?s.args=o:c.length&&(s.args=c),a&&""!==a[0]?s.annots=a:r&&(s.annots=at(t)),s},it=(t,e)=>(t.consume(4),e.args=new Array(4).fill(0).map(()=>W(t)),t.consume(4),e),st=t=>{const e=new z(Z(t)),r=[];for(;e.length()>0;)r.push(W(e));return r},ot=t=>{const e=t.map(t=>Buffer.from(t,"utf8").toString("hex")).join("20"),r=e.length/2;return`${S(r)}${e}`},at=t=>{const e=t.consume(4),r=parseInt(Buffer.from(e).toString("hex"),16),n=t.consume(r);return Buffer.from(n).toString("hex").split("20").map(t=>Buffer.from(t,"hex").toString("utf8"))},ct=t=>e=>{const[r]=(0,n.b58DecodeAndCheckPrefix)(e,[t]);return(0,n.buf2hex)(r)},ut=t=>e=>{const r=e.consume(n.payloadLength[t]);return(0,n.b58Encode)(r,t)},lt=ut(n.PrefixV2.Ed25519PublicKeyHash),ht=ut(n.PrefixV2.BlockHash),ft=t=>{const e=t.consume(1);return 0===e[0]?ut(n.PrefixV2.Ed25519PublicKeyHash)(t):1===e[0]?ut(n.PrefixV2.Secp256k1PublicKeyHash)(t):2===e[0]?ut(n.PrefixV2.P256PublicKeyHash)(t):3===e[0]?ut(n.PrefixV2.BLS12_381PublicKeyHash)(t):void 0},dt=ct(n.PrefixV2.BlockHash),pt=ct(n.PrefixV2.Ed25519PublicKeyHash),gt=t=>t?"ff":"00",mt=t=>ct(n.PrefixV2.ProtocolHash)(t),yt=t=>ut(n.PrefixV2.ProtocolHash)(t),bt=t=>255===t.consume(1)[0],vt=t=>{try{return(0,n.b58DecodePublicKeyHash)(t)}catch(e){throw new i.InvalidKeyHashError(t,e instanceof i.ParameterValidationError?e.result:void 0)}},wt=t=>{const e=[];let r=new A(t,10);if(r.isNaN())throw new TypeError(`Invalid zarith number ${t}`);for(;;){if(r.lt(128)){r.lt(16)&&e.push("0"),e.push(r.toString(16));break}{let t=r.mod(128);r=r.minus(t),r=r.dividedBy(128),t=t.plus(128),e.push(t.toString(16))}}return e.join("")},Et=t=>{let e=0;for(;e<t.length()&&128&t.get(e);)e+=1;let r=new A(0);for(let n=e;n>=0;n-=1){const e=127&t.get(n);r=r.multipliedBy(128),r=r.plus(e)}return t.consume(e+1),new A(r).toString()},_t=ct(n.PrefixV2.ValueHash),At=ut(n.PrefixV2.ValueHash),Ot=(t,e=8)=>`${S(t.length/2,e)}${t}`,St=t=>ut(n.PrefixV2.SlotHeader)(t),Tt={branch:T.BRANCH,contents:[T.OPERATION]},Pt={pkh:T.TZ1,secret:T.SECRET},Rt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,public_key:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},xt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,delegate:T.DELEGATE},It={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,amount:T.ZARITH,destination:T.ADDRESS,parameters:T.PARAMETERS},Nt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,balance:T.ZARITH,delegate:T.DELEGATE,script:T.SCRIPT},kt={source:T.PKH,period:T.INT32,proposal:T.PROPOSAL,ballot:T.BALLOT_STATEMENT},Lt={slot:T.INT16,level:T.INT32,round:T.INT32,block_payload_hash:T.BLOCK_PAYLOAD_HASH},Ct={slot:T.INT16,level:T.INT32,round:T.INT32,block_payload_hash:T.BLOCK_PAYLOAD_HASH,dal_attestation:T.ZARITH},Mt={level:T.INT32,nonce:T.RAW},Bt={source:T.PKH,period:T.INT32,proposals:T.PROPOSAL_ARR},Dt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,value:T.VALUE},Ut={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,ticket_contents:T.VALUE,ticket_ty:T.VALUE,ticket_ticketer:T.ADDRESS,ticket_amount:T.ZARITH,destination:T.ADDRESS,entrypoint:T.ENTRYPOINT},Kt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,amount:T.ZARITH,destination:T.SMART_CONTRACT_ADDRESS},Ht={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pk:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},Ft={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pk:T.PUBLIC_KEY,proof:T.SIGNATURE_PROOF},Gt={consensus_key:T.PKH,delegate:T.PKH,destination:T.PKH},Vt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,limit:T.DEPOSITS_LIMIT},jt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,pvm_kind:T.PVM_KIND,kernel:T.PADDED_BYTES,parameters_ty:T.VALUE,whitelist:T.PKH_ARR},$t={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,message:T.SMART_ROLLUP_MESSAGE},zt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,rollup:T.SMART_ROLLUP_ADDRESS,cemented_commitment:T.SMART_ROLLUP_COMMITMENT_HASH,output_proof:T.PADDED_BYTES},qt={source:T.PKH,fee:T.ZARITH,counter:T.ZARITH,gas_limit:T.ZARITH,storage_limit:T.ZARITH,slot_header:T.SLOT_HEADER},Wt={arbitrary:T.PADDED_BYTES},Zt=t=>e=>r=>Object.keys(e).reduce((n,i)=>{const s=e[i];if(r&&Array.isArray(s)){const e=t[s[0]],o=r[i];if(!Array.isArray(o))throw new K(`Invalid operation value "${JSON.stringify(o)}" of key "${i}, expected value to be Array.`);return n+o.reduce((t,r)=>t+e(r),"")}return n+(0,t[s])(r[i])},""),Yt=t=>e=>r=>Object.keys(e).reduce((n,i)=>{const s=e[i];if(Array.isArray(s)){const e=t[s[0]],o=[],a=r.length();for(;r.length()>0;)if(o.push(e(r)),a===r.length())throw new U("Unable to decode value");return{...n,[i]:o}}{const e=(0,t[s])(r);return void 0!==e?{...n,[i]:e}:{...n}}},{}),Xt={[T.SECRET]:t=>O(t.consume(20)),[T.RAW]:t=>O(t.consume(32)),[T.TZ1]:lt,[T.BRANCH]:ht,[T.ZARITH]:Et,[T.PUBLIC_KEY]:t=>{switch(t.consume(1)[0]){case 0:return ut(n.PrefixV2.Ed25519PublicKey)(t);case 1:return ut(n.PrefixV2.Secp256k1PublicKey)(t);case 2:return ut(n.PrefixV2.P256PublicKey)(t);case 3:return ut(n.PrefixV2.BLS12_381PublicKey)(t);default:throw new n.InvalidPublicKeyError(void 0,n.ValidationResult.NO_PREFIX_MATCHED)}},[T.PKH]:ft,[T.PKH_ARR]:t=>{if(!bt(t))return;const e=[];for(t.consume(4);t.length()>0;)e.push(ft(t));return e},[T.DELEGATE]:t=>{if(bt(t))return ft(t)},[T.INT32]:t=>{const e=t.consume(4);let r=0;for(let t=0;t<e.length;t++)r|=e[t]<<8*(e.length-(t+1));return r},[T.SCRIPT]:t=>{const e=Z(t),r=Z(t);return{code:W(new z(e)),storage:W(new z(r))}},[T.BALLOT_STATEMENT]:t=>{const e=t.consume(1);switch(e[0]){case 0:return"yay";case 1:return"nay";case 2:return"pass";default:throw new B(e[0].toString())}},[T.PROPOSAL]:yt,[T.PROPOSAL_ARR]:t=>{const e=[];for(t.consume(4);t.length()>0;)e.push(yt(t));return e},[T.PARAMETERS]:t=>{if(0!==t.consume(1)[0]){const e=(t=>{const e=S(t.consume(1)[0],2);if(e in N)return N[e];{const e=Z(t,1),r=Buffer.from(e).toString("utf8");if(r.length>31)throw new C(r);return r}})(t),r=Z(t);return{entrypoint:e,value:W(new z(r))}}},[T.ADDRESS]:t=>{switch(t.consume(1)[0]){case 0:return ft(t);case 1:{const e=ut(n.PrefixV2.ContractHash)(t);return t.consume(1),e}default:throw new i.InvalidAddressError(t.toString(),": Unable to decode.")}},[T.SMART_ROLLUP_ADDRESS]:t=>ut(n.PrefixV2.SmartRollupHash)(t),[T.SMART_CONTRACT_ADDRESS]:t=>{if(1===t.consume(1)[0]){const e=ut(n.PrefixV2.ContractHash)(t);return t.consume(1),e}throw new i.InvalidContractAddressError(t.toString(),n.ValidationResult.NO_PREFIX_MATCHED)},[T.SMART_ROLLUP_COMMITMENT_HASH]:t=>ut(n.PrefixV2.SmartRollupCommitmentHash)(t),[T.VALUE]:t=>{const e=Z(t);return W(new z(e))},[T.INT16]:t=>{const e=t.consume(2);let r=0;for(let t=0;t<e.length;t++)r|=e[t]<<8*(e.length-(t+1));return r},[T.BLOCK_PAYLOAD_HASH]:At,[T.ENTRYPOINT]:t=>{const e=Z(t);return Buffer.from(e).toString("utf8")},[T.BURN_LIMIT]:t=>{const e=t.consume(1);if("00"!==Buffer.from(e).toString("hex"))return Et(t)},[T.DEPOSITS_LIMIT]:t=>{const e=t.consume(1);if("00"!==Buffer.from(e).toString("hex"))return Et(t)},[T.SIGNATURE_PROOF]:t=>{if(bt(t))return(t=>{if(t.consume(4),"96"===t.length().toString())return ut(n.PrefixV2.BLS12_381Signature)(t);throw new i.ProhibitedActionError("we only support decoding of BLSIG signatures")})(t)},[T.PVM_KIND]:t=>{const e=t.consume(1);switch(e[0]){case 0:return"arith";case 1:return"wasm_2_0_0";case 2:return"riscv";default:throw new G(e[0].toString())}},[T.PADDED_BYTES]:t=>{const e=Z(t);return Buffer.from(e).toString("hex")},[T.SMART_ROLLUP_MESSAGE]:t=>{const e=Z(t);return((t,e=4)=>{const r=[];let n=t;for(;n.length();){const t=n.consume(e),i=parseInt(Buffer.from(t).toString("hex"),16);r.push(n.consume(i)),n=n.slice(i+e)}return r})(new z(e)).map(t=>Buffer.from(t).toString("hex"))},[T.SLOT_HEADER]:t=>{const e=t.consume(1);return{slot_index:Number(e[0].toString(10)),commitment:St(t),commitment_proof:O(t.consume(96))}}};Xt[T.OPERATION]=(t=>e=>{const r=e.consume(1),n=x[r[0]];if(void 0===n)throw new H(r[0].toString());const i=t[n](e);if("object"!=typeof i)throw new U("Invalid operation, cannot be decoded.");return{kind:n,...i}})(Xt),Xt[T.OP_ACTIVATE_ACCOUNT]=t=>Yt(Xt)(Pt)(t),Xt[T.OP_FAILING_NOOP]=t=>Yt(Xt)(Wt)(t),Xt[T.OP_DELEGATION]=t=>Yt(Xt)(xt)(t),Xt[T.OP_TRANSACTION]=t=>Yt(Xt)(It)(t),Xt[T.OP_ORIGINATION]=t=>Yt(Xt)(Nt)(t),Xt[T.OP_BALLOT]=t=>Yt(Xt)(kt)(t),Xt[T.OP_ATTESTATION]=t=>Yt(Xt)(Lt)(t),Xt[T.OP_ATTESTATION_WITH_DAL]=t=>Yt(Xt)(Ct)(t),Xt[T.OP_SEED_NONCE_REVELATION]=t=>Yt(Xt)(Mt)(t),Xt[T.OP_PROPOSALS]=t=>Yt(Xt)(Bt)(t),Xt[T.OP_REVEAL]=t=>Yt(Xt)(Rt)(t),Xt[T.OP_REGISTER_GLOBAL_CONSTANT]=t=>Yt(Xt)(Dt)(t),Xt[T.OP_TRANSFER_TICKET]=t=>Yt(Xt)(Ut)(t),Xt[T.OP_INCREASE_PAID_STORAGE]=t=>Yt(Xt)(Kt)(t),Xt[T.OP_UPDATE_CONSENSUS_KEY]=t=>Yt(Xt)(Ht)(t),Xt[T.OP_UPDATE_COMPANION_KEY]=t=>Yt(Xt)(Ft)(t),Xt[T.OP_DRAIN_DELEGATE]=t=>Yt(Xt)(Gt)(t),Xt[T.OP_SMART_ROLLUP_ORIGINATE]=t=>Yt(Xt)(jt)(t),Xt[T.OP_SMART_ROLLUP_ADD_MESSAGES]=t=>Yt(Xt)($t)(t),Xt[T.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]=t=>Yt(Xt)(zt)(t),Xt[T.OP_DAL_PUBLISH_COMMITMENT]=t=>Yt(Xt)(qt)(t),Xt[T.MANAGER]=Yt(Xt)(Tt),Xt[T.OP_SET_DEPOSITS_LIMIT]=t=>Yt(Xt)(Vt)(t);const Jt={[T.SECRET]:t=>t,[T.RAW]:t=>t,[T.TZ1]:pt,[T.BRANCH]:dt,[T.ZARITH]:wt,[T.PUBLIC_KEY]:t=>{try{return(0,n.b58DecodePublicKey)(t)}catch(e){throw new n.InvalidPublicKeyError(t,e instanceof i.ParameterValidationError?e.result:void 0)}},[T.PKH]:vt,[T.PKH_ARR]:t=>{if(!t)return gt(!1);if(0===t.length)return gt(!0)+S(0);const e=t.reduce((t,e)=>t+vt(e),"");return gt(!0)+S(e.length/2)+e},[T.DELEGATE]:t=>t?gt(!0)+vt(t):gt(!1),[T.SCRIPT]:t=>{const e=q(t.code),r=q(t.storage);return`${S(e.length/2,8)}${e}${S(r.length/2,8)}${r}`},[T.BALLOT_STATEMENT]:t=>{switch(t){case"yay":return"00";case"nay":return"01";case"pass":return"02";default:throw new M(t)}},[T.PROPOSAL]:mt,[T.PROPOSAL_ARR]:t=>S(32*t.length)+t.map(t=>mt(t)).join(""),[T.INT32]:t=>{const e=parseInt(String(t),10),r=[];for(let t=0;t<4;t++){const n=8*(4-(t+1));r.push((e&255<<n)>>n)}return Buffer.from(r).toString("hex")},[T.PARAMETERS]:t=>{if(!t||"default"===t.entrypoint&&"prim"in t.value&&"Unit"===t.value.prim)return"00";const e=(t=>{if(t in k)return`${k[t]}`;if(t.length>31)throw new C(t);return`ff${q({string:t}).slice(8)}`})(t.entrypoint),r=q(t.value);return`ff${e}${S(r.length/2)}${r}`},[T.ADDRESS]:t=>(0,n.b58DecodeAddress)(t),[T.SMART_ROLLUP_ADDRESS]:t=>{try{return ct(n.PrefixV2.SmartRollupHash)(t)}catch(e){throw e instanceof i.ParameterValidationError?new V(t):e}},[T.SMART_CONTRACT_ADDRESS]:t=>(0,n.b58DecodeAddress)(t),[T.SMART_ROLLUP_COMMITMENT_HASH]:t=>{try{return ct(n.PrefixV2.SmartRollupCommitmentHash)(t)}catch(e){throw e instanceof i.ParameterValidationError?new j(t):e}},[T.VALUE]:t=>{const e=q(t);return`${S(e.length/2)}${e}`},[T.INT16]:t=>{const e=parseInt(String(t),10),r=[];for(let t=0;t<2;t++){const n=8*(2-(t+1));r.push((e&255<<n)>>n)}return Buffer.from(r).toString("hex")},[T.BLOCK_PAYLOAD_HASH]:_t,[T.ENTRYPOINT]:t=>`${q({string:t}).slice(2)}`,[T.BURN_LIMIT]:t=>t?`ff${wt(t)}`:"00",[T.DEPOSITS_LIMIT]:t=>t?`ff${wt(t)}`:"00",[T.SIGNATURE_PROOF]:t=>t?gt(!0)+(t=>{try{const[e,r]=(0,n.b58DecodeAndCheckPrefix)(t,n.signaturePrefixes);if(r===n.PrefixV2.BLS12_381Signature)return Ot((0,n.buf2hex)(e));throw new i.ProhibitedActionError("we only support encoding of BLSIG signatures from protocol Seoul")}catch(e){throw e instanceof i.ParameterValidationError?new i.InvalidSignatureError(t,e.result):e}})(t):gt(!1),[T.PVM_KIND]:t=>{switch(t){case"arith":return"00";case"wasm_2_0_0":return"01";case"riscv":return"02";default:throw new F(t)}},[T.PADDED_BYTES]:Ot,[T.SMART_ROLLUP_MESSAGE]:t=>{const e=t.reduce((t,e)=>t+`${S(e.length/2)}${e}`,"");return`${S(e.length/2)}${e}`},[T.SLOT_HEADER]:t=>S(t.slot_index,2)+(t=>{try{return ct(n.PrefixV2.SlotHeader)(t)}catch(e){throw e instanceof i.ParameterValidationError?new $(t):e}})(t.commitment)+t.commitment_proof};Jt[T.OPERATION]=(t=>e=>{if(!(e.kind in t)||!(e.kind in I))throw new i.InvalidOperationKindError(e.kind);return I[e.kind]+t[e.kind](e)})(Jt),Jt[T.OP_ACTIVATE_ACCOUNT]=t=>Zt(Jt)(Pt)(t),Jt[T.OP_DELEGATION]=t=>Zt(Jt)(xt)(t),Jt[T.OP_TRANSACTION]=t=>Zt(Jt)(It)(t),Jt[T.OP_ORIGINATION]=t=>Zt(Jt)(Nt)(t),Jt[T.OP_BALLOT]=t=>Zt(Jt)(kt)(t),Jt[T.OP_ATTESTATION]=t=>Zt(Jt)(Lt)(t),Jt[T.OP_ATTESTATION_WITH_DAL]=t=>Zt(Jt)(Ct)(t),Jt[T.OP_SEED_NONCE_REVELATION]=t=>Zt(Jt)(Mt)(t),Jt[T.OP_PROPOSALS]=t=>Zt(Jt)(Bt)(t),Jt[T.OP_REVEAL]=t=>Zt(Jt)(Rt)(t),Jt[T.OP_REGISTER_GLOBAL_CONSTANT]=t=>Zt(Jt)(Dt)(t),Jt[T.OP_TRANSFER_TICKET]=t=>Zt(Jt)(Ut)(t),Jt[T.OP_INCREASE_PAID_STORAGE]=t=>Zt(Jt)(Kt)(t),Jt[T.OP_UPDATE_CONSENSUS_KEY]=t=>Zt(Jt)(Ht)(t),Jt[T.OP_UPDATE_COMPANION_KEY]=t=>Zt(Jt)(Ft)(t),Jt[T.OP_DRAIN_DELEGATE]=t=>Zt(Jt)(Gt)(t),Jt[T.OP_SMART_ROLLUP_ORIGINATE]=t=>Zt(Jt)(jt)(t),Jt[T.OP_SMART_ROLLUP_ADD_MESSAGES]=t=>Zt(Jt)($t)(t),Jt[T.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]=t=>Zt(Jt)(zt)(t),Jt[T.OP_DAL_PUBLISH_COMMITMENT]=t=>Zt(Jt)(qt)(t),Jt[T.MANAGER]=Zt(Jt)(Tt),Jt[T.OP_SET_DEPOSITS_LIMIT]=t=>Zt(Jt)(Vt)(t),Jt[T.OP_FAILING_NOOP]=t=>Zt(Jt)(Wt)(t);const Qt={activate_account:Pt,reveal:Rt,delegation:xt,transaction:It,origination:Nt,ballot:kt,attestation:Lt,attestation_with_dal:Ct,seed_nonce_revelation:Mt,proposals:Bt,register_global_constant:Dt,transfer_ticket:Ut,increase_paid_storage:Kt,update_consensus_key:Ht,update_companion_key:Ft,drain_delegate:Gt,set_deposits_limit:Vt,smart_rollup_originate:jt,smart_rollup_add_messages:$t,smart_rollup_execute_outbox_message:zt,dal_publish_commitment:qt,failing_noop:Wt},te=t=>Object.keys(Qt).includes(t),ee=t=>{const e=t.kind,r=Object.keys(t),n=(i="kind",r.filter(t=>t!==i));var i;const s=Object.keys(Qt[e]);return o=n,s.filter(t=>!o.includes(t));var o};var re;!function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(re||(re={}));const ne={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"};void 0===globalThis.TextEncoder&&(globalThis.TextEncoder=TextEncoder),void 0===globalThis.TextDecoder&&(globalThis.TextDecoder=TextDecoder);const ie=re.PsUshuai9;function se(t,e){return{encoder:Jt[t],decoder:e=>{const r=z.fromHexString(e);return Xt[t](r)}}}class oe{constructor(t=ie){this.protocolHash=t,this.codec=se(T.MANAGER,this.protocolHash)}forge(t){const e=(0,n.validateBlock)(t.branch);if(e!==n.ValidationResult.VALID)throw new i.InvalidBlockHashError(t.branch,e);for(const e of t.contents){if(!te(e.kind))throw new i.InvalidOperationKindError(e.kind);const t=ee(e);if(1===t.length){if("delegation"===e.kind&&"delegate"===t[0])continue;if("origination"===e.kind&&"delegate"===t[0])continue;if("transaction"===e.kind&&"parameters"===t[0])continue;if("set_deposits_limit"===e.kind&&"limit"===t[0])continue;if("smart_rollup_originate"===e.kind&&"whitelist"===t[0])continue;if("update_consensus_key"===e.kind&&"proof"===t[0])continue;if("update_companion_key"===e.kind&&"proof"===t[0])continue;if("reveal"===e.kind&&"proof"===t[0])continue;throw new L(e,`missing properties "${t.join(", ")}"`)}if(t.length>1)throw new L(e,`missing properties "${t.join(", ")}"`)}const r=this.codec.encoder(t).toLowerCase();return Promise.resolve(r)}parse(t){return Promise.resolve(this.codec.decoder(t))}}const ae=new oe},5899(t,e,r){"use strict";r.r(e),r.d(e,{Contract:()=>rr,DefaultProtocol:()=>g,JSONParseError:()=>B,MacroError:()=>v,MichelineParseError:()=>M,MichelsonError:()=>ut,MichelsonInstructionError:()=>Ce,MichelsonTypeError:()=>ht,MichelsonValidationError:()=>Nt,Parser:()=>F,ProtoGreaterOrEqual:()=>y,ProtoInferiorTo:()=>b,Protocol:()=>p,VERSION:()=>ar,assertContractValid:()=>We,assertDataListIfAny:()=>ie,assertDataValid:()=>Ze,assertMichelsonBigMapStorableType:()=>zt,assertMichelsonComparableType:()=>Ft,assertMichelsonContract:()=>Jt,assertMichelsonData:()=>Xt,assertMichelsonInstruction:()=>Ht,assertMichelsonPackableType:()=>Gt,assertMichelsonPassableType:()=>$t,assertMichelsonPushableType:()=>Vt,assertMichelsonStorableType:()=>jt,assertMichelsonType:()=>Zt,assertTypeAnnotationsValid:()=>Ke,assertTypesEqual:()=>Xe,assertViewNameValid:()=>Wt,contractEntryPoint:()=>ze,contractEntryPoints:()=>qe,contractSection:()=>Ve,contractViews:()=>je,decodeAddressBytes:()=>Ne,decodePublicKeyBytes:()=>Le,decodePublicKeyHashBytes:()=>ke,dummyContract:()=>nr,emitMicheline:()=>z,formatError:()=>or,formatStack:()=>ir,functionType:()=>Ye,instructionIDs:()=>Rt,isContractValid:()=>Qe,isDataValid:()=>tr,isInstruction:()=>ne,isMichelsonCode:()=>ee,isMichelsonData:()=>te,isMichelsonError:()=>lt,isMichelsonScript:()=>Qt,isMichelsonType:()=>re,isTypeAnnotationsValid:()=>Je,isTypeEqual:()=>er,packData:()=>Se,packDataBytes:()=>Te,refContract:()=>d,sourceReference:()=>i,traceDumpFunc:()=>sr,unpackData:()=>xe,unpackDataBytes:()=>Ie});var n=r(6571);const i=Symbol("source_reference");class s extends n.TaquitoError{constructor(t,e,r){super(),this.src=t,this.idx=e,this.message=r,this.name="ScanError"}}var o;!function(t){t[t.Comment=0]="Comment",t[t.Number=1]="Number",t[t.String=2]="String",t[t.Bytes=3]="Bytes",t[t.Ident=4]="Ident"}(o||(o={}));const a=new RegExp("\\s"),c=new RegExp("[:@%_A-Za-z]"),u=new RegExp("[@%_\\.A-Za-z0-9]"),l=new RegExp("[0-9]"),h=new RegExp("[0-9a-fA-F]");function*f(t,e=!1){let r=0;for(;r<t.length;){for(;r<t.length&&a.test(t[r]);)r++;if(r===t.length)return;const n=t[r],i=r;if(c.test(n)){for(r++;r<t.length&&u.test(t[r]);)r++;yield{t:o.Ident,v:t.slice(i,r),first:i,last:r}}else if(t.length-r>1&&"0x"===t.substring(r,r+2)){for(r+=2;r<t.length&&h.test(t[r]);)r++;if(r-i&1)throw new s(t,r,"Bytes literal length is expected to be power of two");yield{t:o.Bytes,v:t.slice(i,r),first:i,last:r}}else if(l.test(n)||"-"===n){"-"===n&&r++;const e=r;for(;r<t.length&&l.test(t[r]);)r++;if(e===r)throw new s(t,r,"Number literal is too short");yield{t:o.Number,v:t.slice(i,r),first:i,last:r}}else if('"'===n){r++;let e=!1;for(;r<t.length&&(e||'"'!==t[r]);r++)e=!e&&"\\"===t[r];if(r===t.length)throw new s(t,r,"Unterminated string literal");r++,yield{t:o.String,v:t.slice(i,r),first:i,last:r}}else if("#"===n){for(r++;r<t.length&&"\n"!==t[r];)r++;e&&(yield{t:o.Comment,v:t.slice(i,r),first:i,last:r})}else if(t.length-r>1&&"/*"===t.substring(r,r+2)){for(r+=2;r<t.length&&!(t.length-r>1&&"*/"===t.substring(r,r+2));)r++;if(r===t.length)throw new s(t,r,"Unterminated C style comment");r+=2,e&&(yield{t:o.Comment,v:t.slice(i,r),first:i,last:r})}else{if("("!==n&&")"!==n&&"{"!==n&&"}"!==n&&";"!==n)throw new s(t,r,`Invalid character at offset ${r}: \`${n}'`);r++,yield{t:n,v:n,first:i,last:r}}}}const d=Symbol("ref_contract");var p;!function(t){t.Ps9mPmXa="Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P",t.PtCJ7pwo="PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY",t.PsYLVpVv="PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt",t.PsddFKi3="PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP",t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdoTez="PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangzH="PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.PsiThaCa="PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakarta="PtJakartaiDz69SfDDLXJSiuZqTSeSKRDbKVZC8MNzJnvRjvnGw",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(p||(p={}));const g=p.PsUshuai9,m={Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P:0,PtCJ7pwoxe8JasnHY8YonnLYjcVHmhiARPJvqcC6VfHT5s8k8sY:1,PsYLVpVvgbLhAhoqAkMFUo6gudkJ9weNXhUYCiLDzcUpFpkk8Wt:2,PsddFKi32cMJ2qPjf43Qv5GDWLDPZb3T3bF6fLKiF5HtvHNU7aP:3,Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd:4,PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU:5,PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS:5,PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb:6,PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo:7,PtEdoTezd3RHSC31mpxxo1npxFjoWWcFgQtxapi51Z8TLu6v6Uq:8,PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA:8,PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i:9,PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV:10,PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r:11,PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx:11,PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP:12,Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A:12,PtJakartaiDz69SfDDLXJSiuZqTSeSKRDbKVZC8MNzJnvRjvnGw:13,PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY:13,PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg:14,PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW:15,PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc:16,PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1:16,PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf:17,ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH:19,PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ:20,PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi:20,PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg:21,PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7:22,PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh:23,PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu:24,PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY:25,ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK:26};function y(t,e){return m[t]>=m[e]}function b(t,e){return m[t]<m[e]}class v extends n.TaquitoError{constructor(t,e){super(),this.prim=t,this.message=e,this.name="MacroError"}}function w(t,e){if(0===e&&void 0===t.args||t.args?.length===e)return!0;throw new v(t,`macro ${t.prim} expects ${e} arguments, was given ${t.args?.length}`)}function E(t){if(void 0===t.annots)return!0;throw new v(t,`unexpected annotation on macro ${t.prim}: ${t.annots}`)}function _(t,e){if("int"in e)return!0;throw new v(t,`macro ${t.prim} expects int argument`)}function A(t,e,r,n){let i=0,s=0;const o=[null,null];let a;if(i===e.length)throw new v(t,`unexpected end: ${t.prim}`);let c,u=e[i++];switch(u){case"P":{const{r:o,n:c,an:u}=A(t,e.slice(i),r.slice(s),n);a=o,i+=c,s+=u;break}case"A":s!==r.length&&(o[0]=r[s++]);break;default:throw new v(t,`${t.prim}: unexpected character: ${u}`)}if(i===e.length)throw new v(t,`unexpected end: ${t.prim}`);switch(u=e[i++],u){case"P":{const{r:o,n:a,an:u}=A(t,e.slice(i),r.slice(s),n);c=o.map(([t,e])=>[t+1,e]),i+=a,s+=u;break}case"I":s!==r.length&&(o[1]=r[s++]);break;default:throw new v(t,`${t.prim}: unexpected character: ${u}`)}return{r:n(a,c,[0,o]),n:i,an:s}}function O(t,e,r,n){const i=e[0];switch(i){case"A":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CAR",annots:["@%%"]},O(t,e.slice(1),[],n)]]},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:["%@","%@",...r]}]:n.a;case"D":return e.length>1?[{prim:"DUP"},{prim:"DIP",args:[[{prim:"CDR",annots:["@%%"]},O(t,e.slice(1),[],n)]]},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@","%@",...r]}]:n.d;default:throw new v(t,`${t.prim}: unexpected character: ${i}`)}}function S(t,e){let r=t.length;for(;r>0&&t[r-1]===e;)r--;return t.slice(0,r)}function T(t){const e=[],r=[];if(void 0!==t)for(const n of t)(0!==n.length&&"%"===n[0]?e:r).push(n);return{fields:e,rest:r}}function P({prim:t,annots:e,args:r}){return{prim:t,...e&&{annots:e},...r&&{args:r}}}const R=/^P[PAI]{3,}R$/,x=/^UNP[PAI]{2,}R$/,I=/^C[AD]{2,}R$/,N=/^SET_C[AD]+R$/,k=/^MAP_C[AD]+R$/,L=/^DI{2,}P$/,C=/^DU+P$/;class M extends n.TaquitoError{constructor(t,e){super(),this.token=t,this.message=e,this.name="MichelineParseError"}}class B extends n.TaquitoError{constructor(t,e){super(),this.node=t,this.message=e,this.name="JSONParseError"}}const D=new M(null,"Unexpected EOF");function U(t){return t.t===o.Ident&&("@"===t.v[0]||"%"===t.v[0]||":"===t.v[0])}const K=new RegExp("^-?[0-9]+$"),H=new RegExp("^([0-9a-fA-F]{2})*$");class F{constructor(t){this.opt=t}expand(t){if(void 0!==this.opt?.expandGlobalConstant&&"constant"===t.prim){const e=function(t,e){return void 0!==t.args&&1===t.args.length&&"string"in t.args[0]&&t.args[0].string in e?e[t.args[0].string]:t}(t,this.opt.expandGlobalConstant);return e!==t&&(e[i]={...t[i]||{first:0,last:0},globalConstant:t}),e}if(void 0===this.opt?.expandMacros||this.opt?.expandMacros){const e=function(t,e){const r=e?.protocol||g;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(w(t,0))return[{prim:"COMPARE"},P({prim:t.prim.slice(3),annots:t.annots})];break;case"IFEQ":case"IFNEQ":case"IFLT":case"IFGT":case"IFLE":case"IFGE":if(w(t,2))return[{prim:t.prim.slice(2)},P({prim:"IF",annots:t.annots,args:t.args})];break;case"IFCMPEQ":case"IFCMPNEQ":case"IFCMPLT":case"IFCMPGT":case"IFCMPLE":case"IFCMPGE":if(w(t,2))return[{prim:"COMPARE"},{prim:t.prim.slice(5)},P({prim:"IF",annots:t.annots,args:t.args})];break;case"FAIL":if(w(t,0)&&E(t))return[{prim:"UNIT"},{prim:"FAILWITH"}];break;case"ASSERT":if(w(t,0)&&E(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(w(t,0)&&E(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(w(t,0)&&E(t))return[[{prim:"COMPARE"},{prim:t.prim.slice(10)}],{prim:"IF",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_NONE":if(w(t,0)&&E(t))return[{prim:"IF_NONE",args:[[],[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_SOME":if(w(t,0))return[{prim:"IF_NONE",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"ASSERT_LEFT":if(w(t,0))return[{prim:"IF_LEFT",args:[n(t.annots),[[{prim:"UNIT"},{prim:"FAILWITH"}]]]}];break;case"ASSERT_RIGHT":if(w(t,0))return[{prim:"IF_LEFT",args:[[[{prim:"UNIT"},{prim:"FAILWITH"}]],n(t.annots)]}];break;case"IF_SOME":if(w(t,2))return[P({prim:"IF_NONE",annots:t.annots,args:[t.args[1],t.args[0]]})];break;case"IF_RIGHT":if(w(t,2))return[P({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(w(t,1)&&_(t,t.args[0])){const e=parseInt(t.args[0].int,10);return P({prim:"GET",args:[{int:"CAR"===t.prim?String(2*e+1):String(2*e)}],annots:t.annots})}}if(R.test(t.prim)&&w(t,0)){const{fields:e,rest:r}=T(t.annots),{r:n}=A(t,t.prim.slice(1),e,(t,e,r)=>[...t||[],...e||[],r]);return n.map(([t,e],i)=>{const s=[...S(e,null).map(t=>null===t?"%":t),...0===t&&i===n.length-1?r:[]],o=P({prim:"PAIR",annots:0!==s.length?s:void 0});return 0===t?o:{prim:"DIP",args:1===t?[[o]]:[{int:String(t)},[o]]}})}if(x.test(t.prim)){if(b(r,p.PtEdo2Zk)&&w(t,0)){const{r:e}=A(t,t.prim.slice(3),t.annots||[],(t,e,r)=>[r,...e||[],...t||[]]);return e.map(([t,e])=>{const r=[{prim:"DUP"},P({prim:"CAR",annots:null!==e[0]?[e[0]]:void 0}),{prim:"DIP",args:[[P({prim:"CDR",annots:null!==e[1]?[e[1]]:void 0})]]}];return 0===t?r:{prim:"DIP",args:1===t?[[r]]:[{int:String(t)},[r]]}})}if("UNPAIR"===t.prim)return t;if(w(t,0)){const{r:e}=A(t,t.prim.slice(3),[],(t,e,r)=>[r,...e||[],...t||[]]);return e.map(([t])=>{const e=P({prim:"UNPAIR"});return 0===t?e:{prim:"DIP",args:1===t?[[e]]:[{int:String(t)},[e]]}})}}if(I.test(t.prim)&&w(t,0)){const e=[...t.prim.slice(1,t.prim.length-1)];return e.map((r,n)=>{const i=n===e.length-1?t.annots:void 0;switch(r){case"A":return P({prim:"CAR",annots:i});case"D":return P({prim:"CDR",annots:i});default:throw new v(t,`unexpected character: ${r}`)}})}if(N.test(t.prim)&&w(t,0)){const{fields:e,rest:r}=T(t.annots);if(e.length>1)throw new v(t,`unexpected annotation on macro ${t.prim}: ${e}`);const n=0!==e.length?{a:[{prim:"DUP"},{prim:"CAR",annots:e},{prim:"DROP"},{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:[e[0],"%@"]}],d:[{prim:"DUP"},{prim:"CDR",annots:e},{prim:"DROP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",e[0]]}]}:{a:[{prim:"CDR",annots:["@%%"]},{prim:"SWAP"},{prim:"PAIR",annots:["%","%@"]}],d:[{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@","%"]}]};return O(t,t.prim.slice(5,t.prim.length-1),r,n)}if(k.test(t.prim)&&w(t,1)){const{fields:e}=T(t.annots);if(e.length>1)throw new v(t,`unexpected annotation on macro ${t.prim}: ${e}`);const r={a:[{prim:"DUP"},{prim:"CDR",annots:["@%%"]},{prim:"DIP",args:[[P({prim:"CAR",annots:0!==e.length?["@"+e[0].slice(1)]:void 0}),t.args[0]]]},{prim:"SWAP"},{prim:"PAIR",annots:[0!==e.length?e[0]:"%","%@"]}],d:[{prim:"DUP"},P({prim:"CDR",annots:0!==e.length?["@"+e[0].slice(1)]:void 0}),t.args[0],{prim:"SWAP"},{prim:"CAR",annots:["@%%"]},{prim:"PAIR",annots:["%@",0!==e.length?e[0]:"%"]}]};return O(t,t.prim.slice(5,t.prim.length-1),[],r)}if(L.test(t.prim)&&w(t,1)){let e=0;for(;"I"===t.prim[1+e];)e++;return P({prim:"DIP",args:[{int:String(e)},t.args[0]]})}if(C.test(t.prim)){let e=0;for(;"U"===t.prim[1+e];)e++;if(b(r,p.PtEdo2Zk)){if(1===e){if(void 0===t.args)return t;w(t,1)&&_(t,t.args[0])&&(e=parseInt(t.args[0].int,10))}else w(t,0);return 1===e?[P({prim:"DUP",annots:t.annots})]:2===e?[{prim:"DIP",args:[[P({prim:"DUP",annots:t.annots})]]},{prim:"SWAP"}]:[{prim:"DIP",args:[{int:String(e-1)},[P({prim:"DUP",annots:t.annots})]]},{prim:"DIG",args:[{int:String(e)}]}]}if(1===e)return t;if(w(t,0))return P({prim:"DUP",args:[{int:String(e)}],annots:t.annots})}return t}(t,this.opt);return e!==t&&(e[i]={...t[i]||{first:0,last:0},macro:t}),e}return t}parseListExpr(t,e){const r={first:e.first,last:e.last},n="("===e.t;let s;if(n){if(s=t.next(),s.done)throw D;r.last=s.value.last}else s={value:e};if(s.value.t!==o.Ident)throw new M(s.value,`not an identifier: ${s.value.v}`);const a={prim:s.value.v,[i]:r};for(;;){const e=t.next();if(e.done){if(n)throw D;break}if(")"===e.value.t){if(!n)throw new M(e.value,"unexpected closing bracket");r.last=e.value.last;break}if(U(e.value))a.annots=a.annots||[],a.annots.push(e.value.v),r.last=e.value.last;else{a.args=a.args||[];const n=this.parseExpr(t,e.value);r.last=n[i]?.last||r.last,a.args.push(n)}}return this.expand(a)}parseArgs(t,e){const r={first:e.first,last:e.last},n={prim:e.v,[i]:r};for(;;){const e=t.next();if(e.done||"}"===e.value.t||";"===e.value.t)return[n,e];if(U(e.value))r.last=e.value.last,n.annots=n.annots||[],n.annots.push(e.value.v);else{const s=this.parseExpr(t,e.value);r.last=s[i]?.last||r.last,n.args=n.args||[],n.args.push(s)}}}parseSequenceExpr(t,e){const r={first:e.first,last:e.last},n=[];n[i]=r;const s="{"===e.t;let a="{"===e.t?null:{value:e};for(;;){if(null===a&&(a=t.next(),a.done||(r.last=a.value.last)),a.done){if(s)throw D;return n}if("}"===a.value.t){if(s)return n;throw new M(a.value,"unexpected closing bracket")}if(a.value.t===o.Ident){const[e,s]=this.parseArgs(t,a.value);r.last=e[i]?.last||r.last,n.push(this.expand(e)),a=s}else{const e=this.parseExpr(t,a.value);r.last=e[i]?.last||r.last,n.push(e),a=null}null===a&&(a=t.next(),a.done||(r.last=a.value.last)),a.done||";"!==a.value.t||(a=null)}}parseExpr(t,e){switch(e.t){case o.Ident:return this.expand({prim:e.v,[i]:{first:e.first,last:e.last}});case o.Number:return{int:e.v,[i]:{first:e.first,last:e.last}};case o.String:return{string:JSON.parse(e.v),[i]:{first:e.first,last:e.last}};case o.Bytes:return{bytes:e.v.slice(2),[i]:{first:e.first,last:e.last}};case"{":return this.parseSequenceExpr(t,e);default:return this.parseListExpr(t,e)}}parseSequence(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseSequenceExpr(e,r.value)}parseList(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseListExpr(e,r.value)}parseMichelineExpression(t){if("string"!=typeof t)throw new TypeError(`string type was expected, got ${typeof t} instead`);const e=f(t),r=e.next();return r.done?null:this.parseExpr(e,r.value)}parseScript(t){return this.parseSequence(t)}parseData(t){return this.parseList(t)}parseJSON(t){if("object"!=typeof t)throw new TypeError(`object type was expected, got ${typeof t} instead`);if(Array.isArray(t)){const e=[];for(const r of t){if(null===r||"object"!=typeof r)throw new B(r,`unexpected sequence element: ${r}`);e.push(this.parseJSON(r))}return e}if("prim"in t){const e=t;if("string"==typeof e.prim&&(void 0===e.annots||Array.isArray(e.annots))&&(void 0===e.args||Array.isArray(e.args))){const t={prim:e.prim};if(void 0!==e.annots){for(const t of e.annots)if("string"!=typeof t)throw new B(t,`string expected: ${t}`);t.annots=e.annots}if(void 0!==e.args){t.args=[];for(const r of e.args){if(null===r||"object"!=typeof r)throw new B(r,`unexpected argument: ${r}`);t.args.push(this.parseJSON(r))}}return this.expand(t)}throw new B(t,`malformed prim expression: ${t}`)}if("string"in t){if("string"==typeof t.string)return{string:t.string};throw new B(t,`malformed string literal: ${t}`)}if("int"in t){if("string"==typeof t.int&&K.test(t.int))return{int:t.int};throw new B(t,`malformed int literal: ${t}`)}if("bytes"in t){if("string"==typeof t.bytes&&H.test(t.bytes))return{bytes:t.bytes};throw new B(t,`malformed bytes literal: ${t}`)}throw new B(t,`unexpected object: ${t}`)}}class G{constructor(t,e=0){this.opt=t,this.lev=e}indent(t=0){let e="";if(void 0!==this.opt?.indent)for(let r=this.lev+t;r>0;r--)e+=this.opt.indent;return e}get lf(){return this.opt?.newline||""}get lfsp(){return this.opt?.newline||" "}down(t){return new G(this.opt,this.lev+t)}}function V(t){return"prim"in t&&(void 0!==t.annots&&0!==t.annots.length||void 0!==t.args&&0!==t.args.length)}function j(t){if(void 0!==t.args)for(const e of t.args)if(Array.isArray(e)||V(e))return!0;return!1}function $(t,e,r){const n=t[i]?.macro;if(r&&n)return $(n,e,r);if(Array.isArray(t))return function(t,e,r){let n="{"+e.lf,i=t.length;for(const s of t){if(n+=e.indent(1),"prim"in s){if(n+=s.prim,void 0!==s.annots)for(const t of s.annots)n+=" "+t;if(void 0!==s.args){const t=j(s);for(const i of s.args)n+=t?e.lfsp+e.indent(2)+$(i,e.down(2),r):" "+$(i,e,r)}}else n+=$(s,e.down(1),r);n+=i>1?";"+e.lfsp:e.lf,i--}return n+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;let n="("+t.prim;if(void 0!==t.annots)for(const e of t.annots)n+=" "+e;if(void 0!==t.args){const i=j(t);for(const s of t.args)n+=i?e.lfsp+e.indent(1)+$(s,e.down(1),r):" "+$(s,e,r)}return n+")"}}function z(t,e,r=!1){if("object"!=typeof t)throw new TypeError(`object type was expected, got ${typeof t} instead`);return $(t,new G(e),r)}const q=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],W=[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];class Z extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="Base58DecodingError"}}function Y(t){const e=(t.length+9)%64,r=0===e?0:64-e;if(t.length>268435455)throw new n.InvalidMessageError("",`: Invalid length ${t.length} is too big -- SHA-256.`);const i=t.length<<3,s=[...t,128,...new Array(r).fill(0),0,0,0,0,i>>24&255,i>>16&255,i>>8&255,255&i];function o(t,e){return t>>>e|t<<32-e}const a=[...q],c=new Array(64),u=new Array(8);for(let t=0;t<s.length;t+=64){let e=t,r=0;for(;r<16;)c[r]=s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3],e+=4,r++;for(;r<64;){const t=o(c[r-15],7)^o(c[r-15],18)^c[r-15]>>>3,e=o(c[r-2],17)^o(c[r-2],19)^c[r-2]>>>10;c[r]=(0|e)+c[r-7]+t+c[r-16]|0,r++}for(let t=0;t<8;t++)u[t]=a[t];for(let t=0;t<64;t++){const e=o(u[0],2)^o(u[0],13)^o(u[0],22),r=o(u[4],6)^o(u[4],11)^o(u[4],25),n=u[7]+r+(u[4]&u[5]^~u[4]&u[6])+W[t]+c[t]|0,i=e+(u[0]&u[1]^u[0]&u[2]^u[1]&u[2])|0;u[7]=u[6],u[6]=u[5],u[5]=u[4],u[4]=u[3]+n|0,u[3]=u[2],u[2]=u[1],u[1]=u[0],u[0]=n+i|0}for(let t=0;t<8;t++)a[t]=a[t]+u[t]|0}const l=[];for(const t of a)l.push(t>>24&255),l.push(t>>16&255),l.push(t>>8&255),l.push(255&t);return l}const X=[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],J=[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 Q(t,e){const r=t.charCodeAt(e)-49;if(r>=X.length||-1===X[r])throw new Z(`Unexpected character at position ${e}: ${t[e]}`);return X[r]}function tt(t){const e=function(t){const e=[];let r=0;for(;r<t.length&&0===Q(t,r);)r++;let n=r;for(;r<t.length;){let n=Q(t,r++),i=0;for(;0!==n||i<e.length;){const t=58*(e[i]||0)+n;e[i++]=t%256,n=Math.floor(t/256)}}for(;n-- >0;)e.push(0);return e.reverse()}(t);if(e.length<4)throw new Z(`Data is too short ${e.length}`);const r=e.slice(0,e.length-4),n=e.slice(e.length-4),i=Y(Y(r));if(n[0]!==i[0]||n[1]!==i[1]||n[2]!==i[2]||n[3]!==i[3])throw new Z("Invalid checksum");return r}function et(t){const e=Y(Y(t));return function(t){const e=[];let r=0;for(;r<t.length&&0===t[r];)r++;let n=r;for(;r<t.length;){let n=t[r++],i=0;for(;0!==n||i<e.length;){const t=256*(e[i]||0)+n;e[i++]=t%58,n=Math.floor(t/58)}}for(;n-- >0;)e.push(0);return e.reverse(),String.fromCharCode(...e.map(t=>J[t]+49))}([...t,...e.slice(0,4)])}class rt extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidMichelsonError"}}class nt extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidTypeExpressionError"}}class it extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidDataExpressionError"}}class st extends n.ParameterValidationError{constructor(t){super(),this.entrypoint=t,this.name="InvalidEntrypointError",this.message=`Contract has no entrypoint named: "${t}"`}}class ot extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="TezosIdEncodeError"}}class at extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="LongIntegerError"}}class ct extends n.TaquitoError{constructor(t){super(),this.hexByte=t,this.name="HexParseError",this.message=`Unable to parse hex byte "${t}"`}}class ut extends n.TaquitoError{constructor(t,e){super(),this.val=t,this.message=e,this.name="MichelsonError"}}function lt(t){return t instanceof ut}class ht extends ut{constructor(t,e,r){super(t,e),this.val=t,this.message=e,this.name="MichelsonTypeError",void 0!==r&&(this.data=r)}}class ft{append(t){let e=0;for(;0!==t||e<this.buf.length;){const r=10*(this.buf[e]||0)+t;this.buf[e++]=r%256,t=Math.floor(r/256)}}constructor(t){if(this.neg=!1,this.buf=[],void 0!==t)if("string"==typeof t)for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(0===e&&45===r)this.neg=!0;else{if(r<48||r>57)throw new at(`unexpected character in integer constant "${t[e]}"`);this.append(r-48)}}else t<0?(this.neg=!0,this.append(-t)):this.append(t)}cmp(t){if(this.neg!==t.neg)return(t.neg?1:0)-(this.neg?1:0);{let e=0;if(this.buf.length!==t.buf.length)e=this.buf.length<t.buf.length?-1:1;else if(0!==this.buf.length){let r=t.buf.length-1;for(;r>=0&&this.buf[r]===t.buf[r];)r--;e=r<0?0:this.buf[r]<t.buf[r]?-1:1}return this.neg?0===e?0:-e:e}}get sign(){return 0===this.buf.length?0:this.neg?-1:1}}function dt(t){const e=[];for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);if(Number.isNaN(n))return null;e.push(n)}return e}function pt(t){try{return new ft(t),!0}catch{return!1}}function gt(t){try{return new ft(t).sign>=0}catch{return!1}}const mt=/^(@%|@%%|%@|[@:%]([_0-9a-zA-Z][_0-9a-zA-Z.%@]*)?)$/;function yt(t,e){if(Array.isArray(t))return{};let r,n,i;if(void 0!==t.annots)for(const s of t.annots)if(0!==s.length){if(!mt.test(s)||!e?.specialVar&&("@%"===s||"@%%"===s)||!e?.specialFields&&"%@"===s)throw new ut(t,`${t.prim}: unexpected annotation: ${s}`);switch(s[0]){case"%":(e?.emptyFields||s.length>1)&&(r=r||[],r.push(s));break;case":":s.length>1&&(n=n||[],n.push(s));break;case"@":(e?.emptyVar||s.length>1)&&(i=i||[],i.push(s))}}return{f:r,t:n,v:i}}const bt={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]],RollupAddress:[20,[1,128,120,31]]};function vt(t,...e){const r=tt(t);for(const t of e){const[e,n]=bt[t];if(r.length===e+n.length){let e=0;for(;e<n.length&&r[e]===n[e];)e++;if(e===n.length)return[t,r.slice(n.length)]}}return null}function wt(t,e){const[r,n]=bt[t];if(e.length!==r)throw new ot(`Incorrect data length for ${t}: ${e.length}`);return et([...n,...e])}function Et(t,e){const r=e,n=Array.isArray(r)?r:r.args;if(2===n.length){return"pair"===t?{prim:"pair",args:n}:{prim:"Pair",args:n}}return{...Array.isArray(r)?{prim:t}:r,args:[n[0],{prim:t,args:n.slice(1)}]}}function _t(t){return Array.isArray(t)||"pair"===t.prim}function At(t){return Array.isArray(t)||"prim"in t&&"Pair"===t.prim}const Ot=/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[T ]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):([0-5][0-9]))$/;function St(t){if("string"in t){if(gt(t.string))return new Date(parseInt(t.string,10));if(Ot.test(t.string)){const e=new Date(t.string);if(!Number.isNaN(e.valueOf))return e}}else if(pt(t.int))return new Date(parseInt(t.int,10));return null}function Tt(t){return t.map(t=>(t>>4&15).toString(16)+(15&t).toString(16)).join("")}const Pt={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,TICKET_DEPRECATED:!0,TOTAL_VOTING_POWER:!0,TRANSFER_TOKENS:!0,UNIT:!0,VOTING_POWER:!0,XOR:!0,RENAME:!0,OPEN_CHEST:!0,SUB_MUTEZ:!0,MIN_BLOCK_TIME:!0,BYTES:!0,NAT:!0,IS_IMPLICIT_ACCOUNT:!0,INDEX_ADDRESS:!0,GET_ADDRESS_INDEX:!0},Rt=Object.assign({},Pt,{CONTRACT:!0,CREATE_CONTRACT:!0,DIG:!0,DIP:!0,DROP:!0,DUG:!0,DUP:!0,EMIT:!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,LAMBDA_REC:!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,VIEW:!0}),xt={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,tx_rollup_l2_address:!0},It=Object.assign({},xt,{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_transaction_deprecated:!0,sapling_state:!0,ticket:!0,chest_key:!0,chest:!0});class Nt extends ut{constructor(t,e){super(t,e),this.val=t,this.message=e,this.name="MichelsonValidationError"}}function kt(t){return"prim"in t}function Lt(t){if(kt(t))return!0;throw new Nt(t,"prim expression expected")}function Ct(t){if(Array.isArray(t))return!0;throw new Nt(t,"sequence expression expected")}function Mt(t){if(function(t){return Array.isArray(t)||"prim"in t}(t))return!0;throw new Nt(t,"prim or sequence expression expected")}function Bt(t){if("-"===t.int[0])throw new Nt(t,"natural number expected")}function Dt(t){if("int"in t)return!0;throw new Nt(t,"int literal expected")}function Ut(t){if("string"in t)return!0;throw new Nt(t,"string literal expected")}function Kt(t,e){if(0===e&&void 0===t.args||t.args?.length===e)return!0;throw new Nt(t,`${e} arguments expected`)}function Ht(t){if(Array.isArray(t)){for(const e of t){if(!Array.isArray(e)&&!kt(e))throw new Nt(t,"sequence or prim expected");Ht(e)}return!0}if(Lt(t)){if(Object.prototype.hasOwnProperty.call(Pt,t.prim))return Kt(t,0),!0;switch(t.prim){case"DROP":case"PAIR":case"UNPAIR":case"DUP":case"UPDATE":case"GET":void 0!==t.args&&Kt(t,1)&&Dt(t.args[0])&&Bt(t.args[0]);break;case"DIG":case"DUG":case"SAPLING_EMPTY_STATE":Kt(t,1)&&Dt(t.args[0])&&Bt(t.args[0]);break;case"NONE":case"LEFT":case"RIGHT":case"NIL":case"CAST":Kt(t,1)&&Zt(t.args[0]);break;case"UNPACK":Kt(t,1)&&Gt(t.args[0]);break;case"CONTRACT":Kt(t,1)&&$t(t.args[0]);break;case"IF_NONE":case"IF_LEFT":case"IF_CONS":case"IF":Kt(t,2)&&(Ct(t.args[0])&&Ht(t.args[0]),Ct(t.args[1])&&Ht(t.args[1]));break;case"MAP":case"ITER":case"LOOP":case"LOOP_LEFT":Kt(t,1)&&Ht(t.args[0]);break;case"CREATE_CONTRACT":Kt(t,1)&&Jt(t.args[0]);break;case"DIP":if(2===t.args?.length)Dt(t.args[0])&&Bt(t.args[0]),Ct(t.args[1])&&Ht(t.args[1]);else{if(1!==t.args?.length)throw new Nt(t,"1 or 2 arguments expected");Ct(t.args[0])&&Ht(t.args[0])}break;case"PUSH":Kt(t,2)&&(Vt(t.args[0]),Xt(t.args[1]));break;case"EMPTY_SET":Kt(t,1)&&Ft(t.args[0]);break;case"EMPTY_MAP":Kt(t,2)&&(Ft(t.args[0]),Zt(t.args[1]));break;case"EMPTY_BIG_MAP":Kt(t,2)&&(Ft(t.args[0]),zt(t.args[1]));break;case"LAMBDA_REC":case"LAMBDA":Kt(t,3)&&(Zt(t.args[0]),Zt(t.args[1]),Ct(t.args[2])&&Ht(t.args[2]));break;case"VIEW":Kt(t,2)&&(Ut(t.args[0])&&Wt(t.args[0]),Zt(t.args[1])&&Vt(t.args[1]));break;case"EMIT":t.args&&t.args.length>0?Kt(t,1):Kt(t,0);break;default:throw new Nt(t,"instruction expected")}}return!0}function Ft(t){if(Mt(t))if(Array.isArray(t)||"pair"===t.prim||"or"===t.prim||"option"===t.prim)Yt(t,t=>Ft(t));else if(!Object.prototype.hasOwnProperty.call(xt,t.prim))throw new Nt(t,`${t.prim}: type is not comparable`);return!0}function Gt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim)throw new Nt(t,`${t.prim}: type can't be used inside PACK/UNPACK instructions`);Yt(t,t=>Gt(t))}return!0}function Vt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim||"ticket"===t.prim||"contract"===t.prim)throw new Nt(t,`${t.prim}: type can't be pushed`);Yt(t,t=>Vt(t))}return!0}function jt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"operation"===t.prim||"contract"===t.prim)throw new Nt(t,`${t.prim}: type can't be used as part of a storage`);Yt(t,t=>jt(t))}return!0}function $t(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"operation"===t.prim)throw new Nt(t,`${t.prim}: type can't be used as part of a parameter`);Yt(t,t=>$t(t))}return!0}function zt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim)||"big_map"===t.prim||"operation"===t.prim||"sapling_state"===t.prim)throw new Nt(t,`${t.prim}: type can't be used inside a big_map`);Yt(t,t=>zt(t))}return!0}const qt=new RegExp("^[a-zA-Z0-9_.%@]*$");function Wt(t){if(t.string.length>31)throw new Nt(t,`view name too long: ${t.string}`);if(!qt.test(t.string))throw new Nt(t,`invalid character(s) in view name: ${t.string}`)}function Zt(t){if(Mt(t)&&kt(t)){if(!Object.prototype.hasOwnProperty.call(It,t.prim))throw new Nt(t,"type expected");Yt(t,t=>Zt(t))}return!0}function Yt(t,e){if(Array.isArray(t)||"pair"===t.prim){const r=Array.isArray(t)?t:t.args;if(void 0===r||r.length<2)throw new Nt(t,"at least 2 arguments expected");return r.forEach(t=>{Mt(t)&&e(t)}),!0}switch(t.prim){case"option":case"list":Kt(t,1)&&Mt(t.args[0])&&e(t.args[0]);break;case"contract":Kt(t,1)&&$t(t.args[0]);break;case"or":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(e(t.args[0]),e(t.args[1]));break;case"lambda":Kt(t,2)&&(Zt(t.args[0]),Zt(t.args[1]));break;case"set":Kt(t,1)&&Ft(t.args[0]);break;case"map":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(Ft(t.args[0]),e(t.args[1]));break;case"big_map":Kt(t,2)&&Mt(t.args[0])&&Mt(t.args[1])&&(Ft(t.args[0]),zt(t.args[1]),e(t.args[1]));break;case"ticket":Kt(t,1)&&Mt(t.args[0])&&Ft(t.args[0]);break;case"sapling_state":case"sapling_transaction":Kt(t,1)&&Dt(t.args[0]);break;default:Kt(t,0)}return!0}function Xt(t){if("int"in t||"string"in t||"bytes"in t)return!0;if(Array.isArray(t)){let e=0;for(const r of t)kt(r)&&"Elt"===r.prim?(Kt(r,2)&&(Xt(r.args[0]),Xt(r.args[1])),e++):Xt(r);if(0!==e&&e!==t.length)throw new Nt(t,"data entries and map elements can't be intermixed");return!0}if(!kt(t))throw new Nt(t,"data entry expected");switch(t.prim){case"Unit":case"True":case"False":case"None":Kt(t,0);break;case"Pair":if(void 0===t.args||t.args.length<2)throw new Nt(t,"at least 2 arguments expected");for(const e of t.args)Xt(e);break;case"Left":case"Right":case"Some":Kt(t,1)&&Xt(t.args[0]);break;case"Lambda_rec":t.args&&Ht(t.args);break;case"Ticket":Kt(t,4)&&(!function(t){if("string"in t||"bytes"in t)return!0;throw new Nt(t,"string or bytes literal expected")}(t.args[0]),Zt(t.args[1]),Xt(t.args[2]),Dt(t.args[3]));break;default:if(!Object.prototype.hasOwnProperty.call(Rt,t.prim))throw new Nt(t,"data entry or instruction expected");Ht(t)}return!0}function Jt(t){if(Ct(t)){const e={},r={};for(const n of t)if(Lt(n)){if("view"!==n.prim){if(n.prim in e)throw new Nt(t,`duplicate contract section: ${n.prim}`);e[n.prim]=!0}switch(n.prim){case"code":Kt(n,1)&&Ct(n.args[0])&&Ht(n.args[0]);break;case"parameter":if(Kt(n,1)&&$t(n.args[0]),n.annots)throw new Nt(n,"Annotation must be part of the parameter type");break;case"storage":Kt(n,1)&&jt(n.args[0]);break;case"view":if(Kt(n,4)){if(Ut(n.args[0])){const e=n.args[0];if(e.string in r)throw new Nt(t,`duplicate view name: ${e.string}`);r[e.string]=!0,Wt(e)}Vt(n.args[1]),Vt(n.args[2]),Ct(n.args[3])&&Ht(n.args[3])}break;default:throw new Nt(t,`unexpected contract section: ${n.prim}`)}}}return!0}function Qt(t){try{return Jt(t),!0}catch{return!1}}function te(t){try{return Xt(t),!0}catch{return!1}}function ee(t){try{return Ht(t),!0}catch{return!1}}function re(t){try{return Zt(t),!0}catch{return!1}}function ne(t){return Object.prototype.hasOwnProperty.call(Rt,t.prim)}function ie(t){if(!Array.isArray(t))return!1;for(const e of t)if("prim"in e){if(ne(e))throw new ut(t,`Instruction outside of a lambda: ${JSON.stringify(t)}`);if("Elt"===e.prim)throw new ut(t,`Elt item outside of a map literal: ${JSON.stringify(t)}`)}return!0}const se=["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_deprecated","SAPLING_EMPTY_STATE","SAPLING_VERIFY_UPDATE","ticket","TICKET_DEPRECATED","READ_TICKET","SPLIT_TICKET","JOIN_TICKETS","GET_AND_UPDATE","chest","chest_key","OPEN_CHEST","VIEW","view","constant","SUB_MUTEZ","tx_rollup_l2_address","MIN_BLOCK_TIME","sapling_transaction","EMIT","Lambda_rec","LAMBDA_REC","TICKET","BYTES","NAT","Ticket","IS_IMPLICIT_ACCOUNT","INDEX_ADDRESS","GET_ADDRESS_INDEX"],oe=Object.assign({},...se.map((t,e)=>({[t]:e})));var ae;!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"}(ae||(ae={}));class ce{constructor(){this.buffer=[]}get length(){return this.buffer.length}writeBytes(t){this.buffer.push(...t.map(t=>255&t))}writeUint8(t){const e=0|t;this.buffer.push(255&e)}writeUint16(t){const e=0|t;this.buffer.push(e>>8&255),this.buffer.push(255&e)}writeUint32(t){const 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)}writeInt8(t){this.writeUint8(t)}writeInt16(t){this.writeUint16(t)}writeInt32(t){this.writeUint32(t)}}const ue=new Error("bounds out of range");class le{constructor(t,e=0,r=t.length){this.buffer=t,this.idx=e,this.cap=r}get length(){return this.cap-this.idx}readBytes(t){if(this.cap-this.idx<t)throw ue;const e=this.buffer.slice(this.idx,this.idx+t);return this.idx+=t,e}reader(t){if(this.cap-this.idx<t)throw ue;const e=new le(this.buffer,this.idx,this.idx+t);return this.idx+=t,e}copy(){return new le(this.buffer,this.idx,this.cap)}readUint8(){if(this.cap-this.idx<1)throw ue;return this.buffer[this.idx++]>>>0}readUint16(){if(this.cap-this.idx<2)throw ue;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0}readUint32(){if(this.cap-this.idx<4)throw ue;return(this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++])>>>0}readInt8(){if(this.cap-this.idx<1)throw ue;return this.buffer[this.idx++]<<24>>24}readInt16(){if(this.cap-this.idx<2)throw ue;return(this.buffer[this.idx++]<<8|this.buffer[this.idx++])<<16>>16}readInt32(){if(this.cap-this.idx<4)throw ue;return this.buffer[this.idx++]<<24|this.buffer[this.idx++]<<16|this.buffer[this.idx++]<<8|this.buffer[this.idx++]}}var he,fe,de;function pe(t){let e;const r=t.readUint8();switch(r){case fe.ED25519:e="ED25519PublicKeyHash";break;case fe.SECP256K1:e="SECP256K1PublicKeyHash";break;case fe.P256:e="P256PublicKeyHash";break;default:throw new Error(`unknown public key hash tag: ${r}`)}return{type:e,hash:t.readBytes(20)}}function ge(t){let e;const r=t.readUint8();switch(r){case he.Implicit:e=pe(t);break;case he.Originated:e={type:"ContractHash",hash:t.readBytes(20)},t.readBytes(1);break;default:throw new Error(`unknown address tag: ${r}`)}if(0!==t.length){const r=new TextDecoder;e.entryPoint=r.decode(new Uint8Array(t.readBytes(t.length)))}return e}function me(t,e){let r;switch(t.type){case"ED25519PublicKeyHash":r=fe.ED25519;break;case"SECP256K1PublicKeyHash":r=fe.SECP256K1;break;case"P256PublicKeyHash":r=fe.P256;break;default:throw new Error(`unexpected address type: ${t.type}`)}e.writeUint8(r),e.writeBytes(Array.from(t.hash))}function ye(t){let e,r;const n=t.readUint8();switch(n){case de.ED25519:r="ED25519PublicKey",e=32;break;case de.SECP256K1:r="SECP256K1PublicKey",e=33;break;case de.P256:r="P256PublicKey",e=33;break;default:throw new Error(`unknown public key tag: ${n}`)}return{type:r,publicKey:t.readBytes(e)}}function be(t,e,r){const[n,i]=r(t);if(Array.isArray(n)){const t=new ce;for(const e of n){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(e,t,r.value)}return e.writeUint8(ae.Sequence),e.writeUint32(t.length),void e.writeBytes(t.buffer)}if("string"in n){const t=(new TextEncoder).encode(n.string);return e.writeUint8(ae.String),e.writeUint32(t.length),void e.writeBytes(Array.from(t))}if("int"in n){e.writeUint8(ae.Int);let t=BigInt(n.int);const r=t<0;r&&(t=-t);let i=0;do{const n=0===i?BigInt(6):BigInt(7);let s=t&(BigInt(1)<<n)-BigInt(1);t>>=n,t&&(s|=BigInt(128)),0===i&&r&&(s|=BigInt(64)),e.writeUint8(Number(s)),i++}while(t);return}if("bytes"in n){const t=function(t){const e=[];for(let r=0;r<t.length;r+=2){const n=t.slice(r,r+2),i=parseInt(n,16);if(Number.isNaN(i))throw new ct(n);e.push(i)}return e}(n.bytes);return e.writeUint8(ae.Bytes),e.writeUint32(t.length),void e.writeBytes(t)}const s=oe[n.prim];if(void 0===s)throw new TypeError(`Can't encode primary: ${n.prim}`);const o=(n.args?.length||0)<3?ae.Prim0+2*(n.args?.length||0)+(void 0===n.annots||0===n.annots.length?0:1):ae.Prim;if(e.writeUint8(o),e.writeUint8(s),void 0!==n.args)if(n.args.length<3)for(const t of n.args){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(t,e,r.value)}else{const t=new ce;for(const e of n.args){const r=i.next();if(r.done)throw new Error("REPORT ME: iterator is done");be(e,t,r.value)}e.writeUint32(t.length),e.writeBytes(t.buffer)}if(void 0!==n.annots&&0!==n.annots.length){const t=(new TextEncoder).encode(n.annots.join(" "));e.writeUint32(t.length),e.writeBytes(Array.from(t))}else void 0!==n.args&&n.args.length>=3&&e.writeUint32(0)}function ve(t,e){function*r(){for(;;)yield Re}const[n,i]=e,s=t.readUint8();switch(s){case ae.Int:{const e=[];let r;do{r=t.readInt8(),e.push(r)}while(128&r);let n=BigInt(0),s=!1;for(let t=e.length-1;t>=0;t--){const r=0===t?BigInt(6):BigInt(7),i=BigInt(e[t]);n<<=r,n|=i&(BigInt(1)<<r)-BigInt(1),0===t&&(s=!!(i&BigInt(64)))}return s&&(n=-n),i({int:String(n)})}case ae.String:{const e=t.readUint32(),r=t.readBytes(e);return i({string:(new TextDecoder).decode(new Uint8Array(r))})}case ae.Bytes:{const e=t.readUint32(),r=t.readBytes(e);return i({bytes:Tt(Array.from(r))})}case ae.Sequence:{const e=t.readUint32();let s=[],o=t.copy(),a=r();for(let r=0;r<2;r++){const r=o.reader(e);for(s=[];r.length>0;){const t=a.next();if(t.done)throw new Error("REPORT ME: iterator is done");s.push(ve(r,t.value))}a=n(s),o=t}return i(s)}default:{if(s>9)throw new Error(`Unknown tag: ${s}`);const e=t.readUint8();if(e>=se.length)throw new Error(`Unknown primitive tag: ${e}`);const o=se[e],a=s-3>>1;let c={prim:o},u=r(),l=t.copy();for(let e=0;e<2;e++){if(c={prim:o},a<3)for(let t=0;t<a;t++){const t=u.next();if(t.done)throw new Error("REPORT ME: iterator is done");c.args=c.args||[],c.args.push(ve(l,t.value))}else{c.args=c.args||[];const t=l.readUint32(),e=l.reader(t);for(;e.length>0;){const t=u.next();if(t.done)throw new Error("REPORT ME: iterator is done");c.args.push(ve(e,t.value))}}u=n(c),l=t}if(1==(s-3&1)||3===a){const e=t.readUint32();if(0!==e){const r=t.readBytes(e),n=new TextDecoder;c.annots=n.decode(new Uint8Array(r)).split(" ")}}return i(c)}}}!function(t){t[t.Implicit=0]="Implicit",t[t.Originated=1]="Originated"}(he||(he={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(fe||(fe={})),function(t){t[t.ED25519=0]="ED25519",t[t.SECP256K1=1]="SECP256K1",t[t.P256=2]="P256"}(de||(de={}));const we=t=>"prim"in t&&("Left"===t.prim||"Right"===t.prim),Ee=t=>"prim"in t&&("Some"===t.prim||"None"===t.prim),_e=t=>{if(_t(t))return e=>{if(!At(e))throw new ht(t,`pair expected: ${JSON.stringify(e)}`,e);ie(e);const r=Et("pair",t);return[Et("Pair",e),function*(){for(const t of r.args)yield _e(t)}()]};switch(t.prim){case"or":return e=>{if(!we(e))throw new ht(t,`or expected: ${JSON.stringify(e)}`,e);return[e,function*(){yield _e(t.args["Left"===e.prim?0:1])}()]};case"option":return e=>{if(!Ee(e))throw new ht(t,`option expected: ${JSON.stringify(e)}`,e);return[e,function*(){"Some"===e.prim&&(yield _e(t.args[0]))}()]};case"list":case"set":return e=>{if(!Array.isArray(e))throw new ht(t,`${t.prim} expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const r of e)yield _e(t.args[0])}()]};case"map":return e=>{if(!Array.isArray(e))throw new ht(t,`map expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const r of e)yield e=>{if(!("prim"in e)||"Elt"!==e.prim)throw new ht(t,`map element expected: ${JSON.stringify(e)}`,e);return[e,function*(){for(const e of t.args)yield _e(e)}()]}}()]};case"chain_id":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`chain id expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ChainID");if(null===n)throw new ht(t,`chain id base58 expected: ${e.string}`,e);r={bytes:Tt(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"signature":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`signature expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature");if(null===n)throw new ht(t,`signature base58 expected: ${e.string}`,e);r={bytes:Tt(n[1])}}else r=e;return[r,[][Symbol.iterator]()]};case"key_hash":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`key hash expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash");if(null===n)throw new ht(t,`key hash base58 expected: ${e.string}`,e);const i=new ce;me({type:n[0],hash:n[1]},i),r={bytes:Tt(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"key":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`public key expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=vt(e.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey");if(null===n)throw new ht(t,`public key base58 expected: ${e.string}`,e);const i=new ce;!function(t,e){let r;switch(t.type){case"ED25519PublicKey":r=de.ED25519;break;case"SECP256K1PublicKey":r=de.SECP256K1;break;case"P256PublicKey":r=de.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:Tt(i.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"address":return e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=e.string.split("%"),i=vt(n[0],"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash");if(null===i)throw new ht(t,`address base58 expected: ${e.string}`,e);const s=new ce;!function(t,e){if("ContractHash"===t.type?(e.writeUint8(he.Originated),e.writeBytes(Array.from(t.hash)),e.writeUint8(0)):(e.writeUint8(he.Implicit),me(t,e)),void 0!==t.entryPoint&&""!==t.entryPoint&&"default"!==t.entryPoint){const 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},s),r={bytes:Tt(s.buffer)}}else r=e;return[r,[][Symbol.iterator]()]};case"timestamp":return e=>{if(!("string"in e)&&!("int"in e))throw new ht(t,`timestamp expected: ${JSON.stringify(e)}`,e);let r;if("string"in e){const n=St(e);if(null===n)throw new ht(t,`can't parse date: ${e.string}`,e);r={int:String(Math.floor(n.getTime()/1e3))}}else r=e;return[r,[][Symbol.iterator]()]};default:return Oe}},Ae=t=>"prim"in t&&"PUSH"===t.prim,Oe=t=>Ae(t)?(Ht(t),[t,function*(){yield Oe,yield _e(t.args[0])}()]):[t,function*(){for(;;)yield Oe}()];function Se(t,e){const r=new ce;return r.writeUint8(5),be(t,r,void 0!==e?_e(e):Oe),r.buffer}function Te(t,e){return{bytes:Tt(Se(t,e))}}const Pe=t=>{if(_t(t))return[e=>{if(!At(e))throw new ht(t,`pair expected: ${JSON.stringify(e)}`,e);const r=Et("pair",t);return function*(){for(const t of r.args)yield Pe(t)}()},t=>t];switch(t.prim){case"or":return[e=>{if(!we(e))throw new ht(t,`or expected: ${JSON.stringify(e)}`,e);return function*(){yield Pe(t.args["Left"===e.prim?0:1])}()},t=>t];case"option":return[e=>{if(!Ee(e))throw new ht(t,`option expected: ${JSON.stringify(e)}`,e);return function*(){"Some"===e.prim&&(yield Pe(t.args[0]))}()},t=>t];case"list":case"set":return[e=>{if(!Array.isArray(e))throw new ht(t,`${t.prim} expected: ${JSON.stringify(e)}`,e);return function*(){for(;;)yield Pe(t.args[0])}()},t=>t];case"map":return[e=>{if(!Array.isArray(e))throw new ht(t,`map expected: ${JSON.stringify(e)}`,e);return function*(){for(;;)yield[e=>{if(!("prim"in e)||"Elt"!==e.prim)throw new ht(t,`map element expected: ${JSON.stringify(e)}`,e);return function*(){for(const e of t.args)yield Pe(e)}()},t=>t]}()},t=>t];case"chain_id":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`chain id expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);return{string:wt("ChainID",r)}}];case"signature":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`signature expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);return{string:wt("GenericSignature",r)}}];case"key_hash":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`key hash expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=pe(new le(new Uint8Array(r)));return{string:wt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"key":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`public key expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=ye(new le(new Uint8Array(r)));return{string:wt(n.type,n.publicKey)}}];case"address":return[()=>[][Symbol.iterator](),e=>{if(!("bytes"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;const r=dt(e.bytes);if(null===r)throw new ht(t,`can't parse bytes: ${e.bytes}`,e);const n=ge(new le(new Uint8Array(r)));return{string:wt(n.type,n.hash)+(n.entryPoint?"%"+n.entryPoint:"")}}];case"timestamp":return[()=>[][Symbol.iterator](),e=>{if(!("int"in e)&&!("string"in e))throw new ht(t,`address expected: ${JSON.stringify(e)}`,e);if("string"in e)return e;return{string:new Date(1e3*parseInt(e.int,10)).toISOString().slice(0,19)+"Z"}}];default:return Re}},Re=[t=>Ae(t)?(Ht(t),function*(){yield Re,yield Pe(t.args[0])}()):function*(){for(;;)yield Re}(),t=>t];function xe(t,e){const r=new le(t);if(5!==r.readUint8())throw new Error("incorrect packed data magic number");const n=ve(r,void 0!==e?Pe(e):Re);if(Xt(n))return n;throw new Error}function Ie(t,e){const r=dt(t.bytes);if(null===r)throw new Error(`can't parse bytes: "${t.bytes}"`);return xe(r,e)}function Ne(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return ge(new le(new Uint8Array(e)))}function ke(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return pe(new le(new Uint8Array(e)))}function Le(t){const e=dt(t.bytes);if(null===e)throw new Error(`can't parse bytes: "${t.bytes}"`);return ye(new le(new Uint8Array(e)))}class Ce extends ut{constructor(t,e,r){super(t,r),this.val=t,this.stackState=e,this.message=r,this.name="MichelsonInstructionError"}}function Me(t){return Array.isArray(t)?"pair":t.prim}function Be(t){return"prim"in t?t.args:t}function De(t,e,r=!1){if(Me(t)!==Me(e))throw new ht(t,`types mismatch: ${Me(t)} != ${Me(e)}`,void 0);const n=[yt(t),yt(e)];if(n[0].t&&n[1].t&&n[0].t[0]!==n[1].t[0])throw new ht(t,`${Me(t)}: type names mismatch: ${n[0].t[0]} != ${n[1].t[0]}`,void 0);if(r&&n[0].f&&n[1].f&&n[0].f[0]!==n[1].f[0])throw new ht(t,`${Me(t)}: field names mismatch: ${n[0].f[0]} != ${n[1].f}`,void 0);if(_t(t)){const r=Et("pair",t),n=Et("pair",e);return De(r.args[0],n.args[0],!0),void De(r.args[1],n.args[1],!0)}switch(t.prim){case"option":case"list":case"contract":case"set":case"ticket":De(t.args[0],e.args[0]);break;case"or":De(t.args[0],e.args[0],!0),De(t.args[1],e.args[1],!0);break;case"lambda":case"map":case"big_map":De(t.args[0],e.args[0]),De(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 ht(t,`${Me(t)}: type argument mismatch: ${t.args[0].int} != ${e.args[0].int}`,void 0)}}function Ue(t,e){if(t.length!==e.length)throw new ht(t,`stack length mismatch: ${t.length} != ${e.length}`,void 0);for(let r=0;r<t.length;r++)De(t[r],e[r])}function Ke(t,e=!1){if(!Array.isArray(t)){const r=yt(t);if((r.t?.length||0)>1)throw new ht(t,`${t.prim}: at most one type annotation allowed: ${t.annots}`,void 0);if(e){if((r.f?.length||0)>1)throw new ht(t,`${t.prim}: at most one field annotation allowed: ${t.annots}`,void 0)}else if((r.f?.length||0)>0)throw new ht(t,`${t.prim}: field annotations aren't allowed: ${t.annots}`,void 0)}if(_t(t)){const e=Be(t);for(const t of e)Ke(t,!0);return}switch(t.prim){case"option":case"list":case"contract":case"set":Ke(t.args[0]);break;case"or":for(const e of t.args)Ke(e,!0);break;case"lambda":case"map":case"big_map":Ke(t.args[0]),Ke(t.args[1])}}function He(t){if(!Array.isArray(t))return!1;for(const e of t)if(!(Array.isArray(e)&&He(e)||"prim"in e&&ne(e)))return!1;return!0}function Fe(t,e,r){if(_t(e)){if(At(t)){ie(t);const n=Et("Pair",t),i=Et("pair",e);return Fe(n.args[0],i.args[0],r),void Fe(n.args[1],i.args[1],r)}throw new ht(e,`pair expected: ${JSON.stringify(t)}`,t)}switch(e.prim){case"int":if("int"in t&&pt(t.int))return;throw new ht(e,`integer value expected: ${JSON.stringify(t)}`,t);case"nat":case"mutez":if("int"in t&>(t.int))return;throw new ht(e,`natural value expected: ${JSON.stringify(t)}`,t);case"string":if("string"in t)return;throw new ht(e,`string value expected: ${JSON.stringify(t)}`,t);case"bytes":case"bls12_381_g1":case"bls12_381_g2":if("bytes"in t&&null!==dt(t.bytes))return;throw new ht(e,`bytes value expected: ${JSON.stringify(t)}`,t);case"bool":if("prim"in t&&("True"===t.prim||"False"===t.prim))return;throw new ht(e,`boolean value expected: ${JSON.stringify(t)}`,t);case"key_hash":if("string"in t&&null!==vt(t.string,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash"))return;if("bytes"in t)try{return void ke(t)}catch(t){}throw new ht(e,`key hash expected: ${JSON.stringify(t)}`,t);case"timestamp":if(("string"in t||"int"in t)&&null!==St(t))return;throw new ht(e,`timestamp expected: ${JSON.stringify(t)}`,t);case"address":if("string"in t){let e=t.string;const r=t.string.indexOf("%");if(r>=0&&(e=t.string.slice(0,r)),null!==vt(e,"ED25519PublicKeyHash","SECP256K1PublicKeyHash","P256PublicKeyHash","ContractHash","RollupAddress"))return}else if("bytes"in t)try{return void Ne(t)}catch(t){}throw new ht(e,`address expected: ${JSON.stringify(t)}`,t);case"key":if("string"in t&&null!==vt(t.string,"ED25519PublicKey","SECP256K1PublicKey","P256PublicKey"))return;if("bytes"in t)try{return void Le(t)}catch(t){}throw new ht(e,`public key expected: ${JSON.stringify(t)}`,t);case"unit":if("prim"in t&&"Unit"===t.prim)return;throw new ht(e,`unit value expected: ${JSON.stringify(t)}`,t);case"signature":if("bytes"in t||"string"in t&&null!==vt(t.string,"ED25519Signature","SECP256K1Signature","P256Signature","GenericSignature"))return;throw new ht(e,`signature expected: ${JSON.stringify(t)}`,t);case"chain_id":if("bytes"in t||"string"in t){if(null!==("string"in t?tt(t.string):dt(t.bytes)))return}throw new ht(e,`chain id expected: ${JSON.stringify(t)}`,t);case"option":if("prim"in t){if("None"===t.prim)return;if("Some"===t.prim)return void Fe(t.args[0],e.args[0],r)}throw new ht(e,`option expected: ${JSON.stringify(t)}`,t);case"list":case"set":if(ie(t)){for(const n of t)Fe(n,e.args[0],r);return}throw new ht(e,`${e.prim} expected: ${JSON.stringify(t)}`,t);case"or":if("prim"in t){if("Left"===t.prim)return void Fe(t.args[0],e.args[0],r);if("Right"===t.prim)return void Fe(t.args[0],e.args[1],r)}throw new ht(e,`union (or) expected: ${JSON.stringify(t)}`,t);case"lambda":if(He(t)){const n=Ge(t,[e.args[0]],r);if("failed"in n)throw new ht(e,`function is failed with error type: ${n.failed}`,t);if(1!==n.length)throw new ht(e,"function must return a value",t);return void De(e.args[1],n[0])}throw new ht(e,`function expected: ${JSON.stringify(t)}`,t);case"map":case"big_map":if(Array.isArray(t)){for(const n of t){if(!("prim"in n)||"Elt"!==n.prim)throw new ht(e,`map elements expected: ${JSON.stringify(t)}`,t);Fe(n.args[0],e.args[0],r),Fe(n.args[1],e.args[1],r)}return}throw new ht(e,`${e.prim} expected: ${JSON.stringify(t)}`,t);case"bls12_381_fr":if("int"in t&&pt(t.int)||"bytes"in t&&null!==dt(t.bytes))return;throw new ht(e,`BLS12-381 element expected: ${JSON.stringify(t)}`,t);case"sapling_state":if(Array.isArray(t))return;throw new ht(e,`sapling state expected: ${JSON.stringify(t)}`,t);case"ticket":if("prim"in t&&"Ticket"===t.prim)return Fe(t.args[0],{prim:"address"},r),Xe(t.args[1],e.args[0]),Fe(t.args[2],e.args[0],r),void Fe(t.args[3],{prim:"nat"},r);if(At(t))return void Fe(t,{prim:"pair",args:[{prim:"address"},e.args[0],{prim:"nat"}]},r);throw new ht(e,`ticket expected: ${JSON.stringify(t)}`,t);default:throw new ht(e,`type ${Me(e)} don't have Michelson literal representation`,t)}}function Ge(t,e,r){const n=r?.protocol||g;if(Array.isArray(t))return function(t,e,r){let n=e,i=e,s=0;for(const e of t){const t=Ge(e,i,r);if(n=t,"failed"in t)break;i=t,s++}if("failed"in n&&0==n.level&&(!("prim"in n.failed)||"never"!==n.failed.prim)&&s!==t.length-1)throw new Ce(t,n,"FAIL must appear in a tail position");if(void 0!==r?.traceCallback){const i={op:t,in:e,out:n};r.traceCallback(i)}return"failed"in n?{failed:n.failed,level:n.level+1}:n}(t,e,r);const i=t;function s(t,...r){if(e.length<r.length+t)throw new Ce(i,e,`${i.prim}: stack must have at least ${r.length} element(s)`);let n=t;for(const t of r){if(null!==t&&0!==t.length){let r=0;for(;r<t.length&&t[r]!==Me(e[n]);)r++;if(r===t.length)throw new Ce(i,e,`${i.prim}: stack type mismatch: [${n}] expected to be ${t}, got ${Me(e[n])} instead`)}n++}return e.slice(t,r.length+t)}function o(t){return(...r)=>{try{return t(...r)}catch(t){throw t instanceof ut?new Ce(i,e,t.message):t}}}function a(t){return r=>{try{return t(r)}catch(t){throw t instanceof ut?new Ce(i,e,t.message):t}}}const c=o(yt),u=o(Ue),l=o(De),h=a(Ft),f=a(Gt),m=a(jt),y=a(Vt),v=a(zt);function w(t,r){const n=c(i,{...r,emptyFields:void 0!==t.f&&t.f>1,emptyVar:void 0!==t.v&&t.v>1}),s=(t,r,n)=>{if(t&&t.length>(r||0))throw new Ce(i,e,`${i.prim}: at most ${r||0} ${n} annotations allowed`)};return s(n.f,t.f,"field"),s(n.t,t.t,"type"),s(n.v,t.v,"variable"),n}function E(t,e){const r=t,n=Array.isArray(r)?{prim:"pair",args:r}:r,i=c(n),s=void 0!==e.v||void 0!==e.t||void 0!==e.f?[...(null===e.v?i.v:e.v)||[],...(null===e.t?i.t:e.t)||[],...(null===e.f?i.f:e.f)||[]]:void 0,{annots:o,...a}=n;return{...a,...s&&0!==s.length&&{annots:s}}}function _(t,e){const r=w({v:1});return E(t,{v:void 0!==r.v?r.v:void 0!==e?[e]:null,t:null})}function A(t,r,n,s,o){const a=c(r).f?.[0],u=n.f?.[s];if(void 0!==u&&"%"!==u&&void 0!==a&&u!==a)throw new Ce(i,e,`${i.prim}: field names doesn't match: ${u} !== ${a}`);const l=n.v?.[s],h=c(t).v?.[0];return E(r,{t:null,v:l?"@%"===l?a?["@"+a.slice(1)]:void 0:"@%%"===l?h?["@"+h.slice(1)+"."+(a?a.slice(1):o)]:a?["@"+a.slice(1)]:void 0:[l]:null})}function O(t,r,n=r){const s=Et("pair",t);if(1===n)return[s.args[0]];if(2===n)return s.args;const o=s.args[1];if(_t(o))return[s.args[0],...O(o,r,n-1)];throw new Ce(i,e,`${i.prim}: at least ${r} fields are expected`)}function S(t,r,n=r){if(0===n)return t;const s=Et("pair",t);if(1===n)return s.args[0];const o=s.args[1];if(_t(o))return S(o,r,n-2);if(2===n)return o;throw new Ce(i,e,`${i.prim}: at least ${r+1} fields are expected`)}function T(t,r,n,s=n){if(0===s)return r;const o=Et("pair",t);if(1===s)return{...o,args:[r,o.args[1]]};const a=o.args[1];if(_t(a))return{...o,args:[o.args[0],T(a,r,n,s-2)]};if(2===s)return{...o,args:[o.args[0],r]};throw new Ce(i,e,`${i.prim}: at least ${n+1} fields are expected`)}const P=(t,e)=>["@"+(t.v?t.v[0].slice(1)+".":"")+e];function R(t,e){return"failed"in t||"failed"in e?"failed"in t?e:t:(u(t,e),t)}const x=(t=>{switch(t.prim){case"DUP":{const r=t.args?parseInt(t.args[0].int,10):1;if(0===r)throw new Ce(t,e,"DUP 0 is forbidden");const n=s(r-1,null)[0];if("ticket"===Me(n))throw new Ce(t,e,"ticket can't be DUPed");return[n,...e]}case"SWAP":{const t=s(0,null,null);return w({}),[t[1],t[0],...e.slice(2)]}case"SOME":return[E({prim:"option",args:[s(0,null)[0]]},w({t:1,v:1})),...e.slice(1)];case"UNIT":return[E({prim:"unit"},w({v:1,t:1})),...e];case"PAIR":{const r=t.args?parseInt(t.args[0].int,10):2;if(r<2)throw new Ce(t,e,`PAIR ${r} is forbidden`);const n=s(0,...new Array(r).fill(null)),i=w({f:r,t:1,v:1},{specialFields:!0}),o=t=>{const e=t.lastIndexOf(".");return t.slice(e>0?e+1:1)},a=n.map((t,e)=>{const r=c(t);return E(t,{v:null,t:null,f:i.f&&i.f.length>e&&"%"!==i.f[e]?"%@"===i.f[e]?r.v?["%"+o(r.v?.[0]||"")]:void 0:[i.f[e]]:void 0})});return[E({prim:"pair",args:a},{t:i.t,v:i.v}),...e.slice(r)]}case"UNPAIR":{const r=t.args?parseInt(t.args[0].int,10):2;if(r<2)throw new Ce(t,e,`UNPAIR ${r} is forbidden`);const n=s(0,["pair"])[0],i=w({f:2,v:2},{specialVar:!0});return[...O(n,r).map((t,e)=>A(n,t,i,e,0===e?"car":"cdr")),...e.slice(1)]}case"CAR":case"CDR":{const r=Et("pair",s(0,["pair"])[0]);return[A(r,r.args["CAR"===t.prim?0:1],w({f:1,v:1},{specialVar:!0}),0,t.prim.toLocaleLowerCase()),...e.slice(1)]}case"CONS":{const t=s(0,null,["list"]);return l(t[0],t[1].args[0]),[_({prim:"list",args:[t[1].args[0]]}),...e.slice(2)]}case"SIZE":return s(0,["string","list","set","map","bytes"]),[_({prim:"nat"}),...e.slice(1)];case"MEM":{const t=s(0,null,["set","map","big_map"]);return h(t[0]),l(t[0],t[1].args[0]),[_({prim:"bool"}),...e.slice(2)]}case"GET":if(t.args){const r=parseInt(t.args[0].int,10);return[_(S(s(0,["pair"])[0],r)),...e.slice(1)]}{const t=s(0,null,["map","big_map"]);return h(t[0]),l(t[0],t[1].args[0]),[_({prim:"option",args:[t[1].args[1]]}),...e.slice(2)]}case"UPDATE":if(t.args){const r=parseInt(t.args[0].int,10),n=s(0,null,["pair"]);return[_(T(n[1],n[0],r)),...e.slice(2)]}{const t=s(0,null,["bool","option"]);if(h(t[0]),"bool"===t[1].prim){const r=s(2,["set"]);return l(t[0],r[0].args[0]),[_({prim:"set",args:[E(t[0],{t:null})]}),...e.slice(3)]}const r=s(2,["map","big_map"]);return l(t[0],r[0].args[0]),"map"===r[0].prim?[_({prim:"map",args:[E(t[0],{t:null}),E(t[1].args[0],{t:null})]}),...e.slice(3)]:(v(t[1].args[0]),[_({prim:"big_map",args:[E(t[0],{t:null}),E(t[1].args[0],{t:null})]}),...e.slice(3)])}case"GET_AND_UPDATE":{const t=w({v:2}),r=s(0,null,["option"],["map","big_map"]);h(r[0]),l(r[0],r[2].args[0]),l(r[1].args[0],r[2].args[1]);const n=t.v?.map(t=>"@"!==t?[t]:void 0);return"map"===r[2].prim?[E({prim:"option",args:[r[2].args[1]]},{v:n?.[0]}),E({prim:"map",args:[E(r[0],{t:null}),E(r[1].args[0],{t:null})]},{v:n?.[1]}),...e.slice(3)]:(v(r[1].args[0]),[E({prim:"option",args:[r[2].args[1]]},{v:n?.[0]}),E({prim:"big_map",args:[E(r[0],{t:null}),E(r[1].args[0],{t:null})]},{v:n?.[1]}),...e.slice(3)])}case"EXEC":{const t=s(0,null,["lambda"]);return l(t[0],t[1].args[0]),[_(t[1].args[1]),...e.slice(2)]}case"APPLY":{const r=s(0,null,["lambda"]);if(m(r[0]),y(r[0]),!_t(r[1].args[0]))throw new Ce(t,e,`${t.prim}: function's argument must be a pair: ${Me(r[1].args[0])}`);const n=r[1].args[0];return l(r[0],Be(n)[0]),[_({prim:"lambda",args:[Be(n)[1],r[1].args[1]]}),...e.slice(2)]}case"FAILWITH":{const t=s(0,null)[0];return b(n,p.PtEdo2Zk)||f(t),{failed:t,level:0}}case"NEVER":return s(0,["never"]),{failed:{prim:"never"},level:0};case"RENAME":return[_(s(0,null)[0]),...e.slice(1)];case"CONCAT":{const r=s(0,["string","list","bytes"]);if("list"===r[0].prim){if("string"!==Me(r[0].args[0])&&"bytes"!==Me(r[0].args[0]))throw new Ce(t,e,`${t.prim}: can't concatenate list of ${Me(r[0].args[0])}'s`);return[_(r[0].args[0]),...e.slice(1)]}const n=s(1,["string","bytes"]);if(r[0].prim!==n[0].prim)throw new Ce(t,e,`${t.prim}: can't concatenate ${r[0].prim} with ${n[0].prim}`);return[_(n[0]),...e.slice(2)]}case"SLICE":return[_({prim:"option",args:[s(0,["nat"],["nat"],["string","bytes"])[2]]},"@slice"),...e.slice(3)];case"PACK":{const t=s(0,null)[0];return f(t),[_({prim:"bytes"},"@packed"),...e.slice(1)]}case"ADD":{const r=s(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"===r[0].prim&&"int"===r[1].prim||"int"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("int"===r[0].prim&&"timestamp"===r[1].prim||"timestamp"===r[0].prim&&"int"===r[1].prim)return[_({prim:"timestamp"}),...e.slice(2)];if(("int"===r[0].prim||"nat"===r[0].prim||"mutez"===r[0].prim||"bls12_381_g1"===r[0].prim||"bls12_381_g2"===r[0].prim||"bls12_381_fr"===r[0].prim)&&r[0].prim===r[1].prim)return[_(r[0]),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't add ${r[0].prim} to ${r[1].prim}`)}case"SUB":{const r=b(n,p.PsiThaCa)?s(0,["nat","int","timestamp","mutez"],["nat","int","timestamp","mutez"]):s(0,["nat","int","timestamp"],["nat","int","timestamp"]);if(("nat"===r[0].prim||"int"===r[0].prim)&&("nat"===r[1].prim||"int"===r[1].prim)||"timestamp"===r[0].prim&&"timestamp"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("timestamp"===r[0].prim&&"int"===r[1].prim)return[_({prim:"timestamp"}),...e.slice(2)];if("mutez"===r[0].prim&&"mutez"===r[1].prim)return[_({prim:"mutez"}),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't subtract ${r[0].prim} from ${r[1].prim}`)}case"SUB_MUTEZ":return s(0,["mutez"],["mutez"]),[_({prim:"option",args:[{prim:"mutez"}]}),...e.slice(2)];case"MUL":{const r=s(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"===r[0].prim&&"int"===r[1].prim||"int"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"int"}),...e.slice(2)];if("nat"===r[0].prim&&"mutez"===r[1].prim||"mutez"===r[0].prim&&"nat"===r[1].prim)return[_({prim:"mutez"}),...e.slice(2)];if(("bls12_381_g1"===r[0].prim||"bls12_381_g2"===r[0].prim||"bls12_381_fr"===r[0].prim)&&"bls12_381_fr"===r[1].prim||("nat"===r[0].prim||"int"===r[0].prim)&&r[0].prim===r[1].prim)return[_(r[0]),...e.slice(2)];if(("nat"===r[0].prim||"int"===r[0].prim)&&"bls12_381_fr"===r[1].prim||("nat"===r[1].prim||"int"===r[1].prim)&&"bls12_381_fr"===r[0].prim)return[_({prim:"bls12_381_fr"}),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't multiply ${r[0].prim} by ${r[1].prim}`)}case"EDIV":{const r=(t,e)=>({prim:"option",args:[{prim:"pair",args:[{prim:t},{prim:e}]}]}),n=s(0,["nat","int","mutez"],["nat","int","mutez"]);if("nat"===n[0].prim&&"nat"===n[1].prim)return[_(r("nat","nat")),...e.slice(2)];if(!("nat"!==n[0].prim&&"int"!==n[0].prim||"nat"!==n[1].prim&&"int"!==n[1].prim))return[_(r("int","nat")),...e.slice(2)];if("mutez"===n[0].prim&&"nat"===n[1].prim)return[_(r("mutez","mutez")),...e.slice(2)];if("mutez"===n[0].prim&&"mutez"===n[1].prim)return[_(r("nat","mutez")),...e.slice(2)];throw new Ce(t,e,`${t.prim}: can't euclideally divide ${n[0].prim} by ${n[1].prim}`)}case"ABS":return s(0,["int"]),[_({prim:"nat"}),...e.slice(1)];case"ISNAT":return s(0,["int"]),[_({prim:"option",args:[{prim:"nat"}]}),...e.slice(1)];case"INT":return s(0,["nat","bls12_381_fr","bytes"]),[_({prim:"int"}),...e.slice(1)];case"BYTES":return s(0,["nat","int"]),[_({prim:"bytes"}),...e.slice(1)];case"NAT":return s(0,["bytes"]),[_({prim:"nat"}),...e.slice(1)];case"NEG":{const t=s(0,["nat","int","bls12_381_g1","bls12_381_g2","bls12_381_fr"])[0];return"nat"===t.prim||"int"===t.prim?[_({prim:"int"}),...e.slice(1)]:[_(t),...e.slice(1)]}case"LSL":case"LSR":return s(0,["nat","bytes"],["nat","bytes"]),[_({prim:"nat"}),...e.slice(2)];case"OR":case"XOR":{const r=s(0,["nat","bytes","bool"],["nat","bytes","bool"]);if(r[0].prim!==r[1].prim)throw new Ce(t,e,`${t.prim}: both arguments must be of the same type: ${r[0].prim}, ${r[1].prim}`);return[_(r[1]),...e.slice(2)]}case"AND":{const r=s(0,["nat","bytes","bool","int"],["nat","bytes","bool"]);if(("int"!==r[0].prim||"nat"!==r[1].prim)&&r[0].prim!==r[1].prim)throw new Ce(t,e,`${t.prim}: both arguments must be of the same type: ${r[0].prim}, ${r[1].prim}`);return[_(r[1]),...e.slice(2)]}case"NOT":return"bool"===s(0,["nat","bytes","bool","int"])[0].prim?[_({prim:"bool"}),...e.slice(1)]:[_({prim:"int"}),...e.slice(1)];case"COMPARE":{const t=s(0,null,null);return h(t[0]),h(t[1]),[_({prim:"int"}),...e.slice(2)]}case"EQ":case"NEQ":case"LT":case"GT":case"LE":case"GE":return s(0,["int"]),[_({prim:"bool"}),...e.slice(1)];case"SELF":{if(void 0===r?.contract)throw new Ce(t,e,`${t.prim}: contract required`);const n=w({f:1,v:1}),i=ze(r.contract,n.f?.[0]);if(null===i)throw new Ce(t,e,`${t.prim}: contract has no entrypoint ${i}`);return[E({prim:"contract",args:[i]},{v:n.v?n.v:["@self"]}),...e]}case"TRANSFER_TOKENS":{const t=s(0,null,["mutez"],["contract"]);return l(t[0],t[2].args[0]),[_({prim:"operation"}),...e.slice(3)]}case"SET_DELEGATE":{const r=s(0,["option"])[0];if("key_hash"!==Me(r.args[0]))throw new Ce(t,e,`${t.prim}: key hash expected: ${Me(r.args[0])}`);return[_({prim:"operation"}),...e.slice(1)]}case"IMPLICIT_ACCOUNT":return s(0,["key_hash"]),[_({prim:"contract",args:[{prim:"unit"}]}),...e.slice(1)];case"NOW":return[_({prim:"timestamp"},"@now"),...e];case"AMOUNT":return[_({prim:"mutez"},"@amount"),...e];case"BALANCE":return[_({prim:"mutez"},"@balance"),...e];case"CHECK_SIGNATURE":return s(0,["key"],["signature"],["bytes"]),[_({prim:"bool"}),...e.slice(3)];case"BLAKE2B":case"SHA256":case"SHA512":case"KECCAK":case"SHA3":return s(0,["bytes"]),[_({prim:"bytes"}),...e.slice(1)];case"HASH_KEY":return s(0,["key"]),[_({prim:"key_hash"}),...e.slice(1)];case"SOURCE":return[_({prim:"address"},"@source"),...e];case"SENDER":return[_({prim:"address"},"@sender"),...e];case"ADDRESS":{const t=s(0,["contract"])[0],r=w({v:1});return[E({prim:"address",[d]:t},{v:r.v?r.v:P(c(t),"address")}),...e.slice(1)]}case"SELF_ADDRESS":{const t={prim:"address"};return void 0!==r?.contract&&(t[d]={prim:"contract",args:[Ve(r.contract,"parameter").args[0]]}),[_(t,"@address"),...e]}case"CHAIN_ID":return[_({prim:"chain_id"}),...e];case"DROP":{w({});const r=void 0!==t.args?parseInt(t.args[0].int,10):1;return s(r-1,null),e.slice(r)}case"DIG":{w({});const r=parseInt(t.args[0].int,10);return[s(r,null)[0],...e.slice(0,r),...e.slice(r+1)]}case"DUG":{w({});const r=parseInt(t.args[0].int,10);return[...e.slice(1,r+1),s(0,null)[0],...e.slice(r+1)]}case"NONE":return Ke(t.args[0]),[E({prim:"option",args:[t.args[0]]},w({t:1,v:1})),...e];case"LEFT":case"RIGHT":{const r=s(0,null)[0],n=w({f:2,t:1,v:1},{specialFields:!0}),i=c(r),o=[E(r,{t:null,v:null,f:n.f&&n.f.length>0&&"%"!==n.f[0]?"%@"===n.f[0]?i.v?["%"+i.v[0].slice(1)]:void 0:n.f:void 0}),E(t.args[0],{t:null,f:n.f&&n.f.length>1&&"%"!==n.f[1]?n.f:void 0})];return[E({prim:"or",args:"LEFT"===t.prim?o:[o[1],o[0]]},{t:n.t,v:n.v}),...e.slice(1)]}case"NIL":return Ke(t.args[0]),[E({prim:"list",args:[t.args[0]]},w({t:1,v:1})),...e];case"UNPACK":return s(0,["bytes"]),Ke(t.args[0]),[_({prim:"option",args:[t.args[0]]},"@unpacked"),...e.slice(1)];case"CONTRACT":{const r=s(0,["address"])[0];Ke(t.args[0]);const n=w({v:1,f:1}),i=r[d];if(void 0!==i){const r=ze(i,n.f?.[0]);if(null===r)throw new Ce(t,e,`${t.prim}: contract has no entrypoint ${r}`);l(r,t.args[0])}return[E({prim:"option",args:[{prim:"contract",args:[t.args[0]]}]},{v:n.v?n.v:P(c(r),"contract")}),...e.slice(1)]}case"CAST":{w({});const r=s(0,null)[0];return Ke(t.args[0]),l(t.args[0],r),[t.args[0],...e.slice(1)]}case"IF_NONE":{w({});const n=s(0,["option"])[0],i=e.slice(1);return R(Ge(t.args[0],i,r),Ge(t.args[1],[E(n.args[0],{t:null,v:P(c(n),"some")}),...i],r))}case"IF_LEFT":{w({});const n=s(0,["or"])[0],i=c(n),o=c(n.args[0]),a=c(n.args[1]),u=e.slice(1);return R(Ge(t.args[0],[E(n.args[0],{t:null,v:P(i,o.f?o.f[0].slice(1):"left")}),...u],r),Ge(t.args[1],[E(n.args[1],{t:null,v:P(i,a.f?a.f[0].slice(1):"right")}),...u],r))}case"IF_CONS":{w({});const n=s(0,["list"])[0],i=c(n),o=e.slice(1);return R(Ge(t.args[0],[E(n.args[0],{t:null,v:P(i,"hd")}),E(n,{t:null,v:P(i,"tl")}),...o],r),Ge(t.args[1],o,r))}case"IF":{w({}),s(0,["bool"]);const n=e.slice(1);return R(Ge(t.args[0],n,r),Ge(t.args[1],n,r))}case"MAP":{const n=s(0,["list","map","option"])[0],i=e.slice(1),o="map"===n.prim?{prim:"pair",args:n.args}:n.args[0],a=Ge(t.args[0],[E(o,{t:null,v:P(c(n),"elt")}),...i],r);if("failed"in a){if(!("prim"in a.failed)||"never"!==a.failed.prim)throw new Ce(t,e,`${t.prim}: FAIL is not allowed in MAP`);return{failed:a.failed,level:a.level+1}}if(a.length<1)throw new Ce(t,e,`${t.prim}: function must return a value`);return u(a.slice(1),i),"list"===n.prim?[_({prim:"list",args:[a[0]]}),...i]:"map"===n.prim?[_({prim:"map",args:[n.args[0],a[0]]}),...i]:[_({prim:"option",args:[a[0]]}),...i]}case"ITER":{w({});const n=s(0,["set","list","map"])[0],i=e.slice(1),o="map"===n.prim?{prim:"pair",args:n.args}:n.args[0],a=Ge(t.args[0],[E(o,{t:null,v:P(c(n),"elt")}),...i],r);return"failed"in a?{failed:a.failed,level:a.level+1}:(u(a,i),i)}case"LOOP":{w({}),s(0,["bool"]);const n=e.slice(1),i=Ge(t.args[0],n,r);return"failed"in i?{failed:i.failed,level:i.level+1}:(u(i,[{prim:"bool"},...n]),n)}case"LOOP_LEFT":{w({});const n=s(0,["or"])[0],i=e.slice(1),o=Ge(t.args[0],[E(n.args[0],{t:null,v:P(c(n),"left")}),...i],r);return"failed"in o?{failed:o.failed,level:o.level+1}:(u(o,[n,...i]),[E(n.args[1],{t:null,v:w({v:1}).v}),...i])}case"DIP":{w({});const n=2===t.args.length?parseInt(t.args[0].int,10):1;s(n-1,null);const i=e.slice(0,n),o=e.slice(n),a=2===t.args.length?Ge(t.args[1],o,r):Ge(t.args[0],o,r);return"failed"in a?{failed:a.failed,level:a.level+1}:[...i,...a]}case"CREATE_CONTRACT":{const r=w({v:2}),n=s(0,["option"],["mutez"],null);if("key_hash"!==Me(n[0].args[0]))throw new Ce(t,e,`${t.prim}: key hash expected: ${Me(n[0].args[0])}`);m(n[2])&&(We(t.args[0]),De(Ve(t.args[0],"storage").args[0],n[2]));const i=r.v?.map(t=>"@"!==t?[t]:void 0);return[E({prim:"operation"},{v:i?.[0]}),E({prim:"address",[d]:{prim:"contract",args:[Ve(t.args[0],"parameter").args[0]]}},{v:i?.[1]}),...e.slice(3)]}case"PUSH":return Ke(t.args[0]),Fe(t.args[1],t.args[0],{...r,contract:void 0}),[_(t.args[0]),...e];case"EMPTY_SET":return Ke(t.args[0]),h(t.args[0]),[E({prim:"set",args:t.args},w({t:1,v:1})),...e];case"EMPTY_MAP":return Ke(t.args[0]),h(t.args[0]),Ke(t.args[1]),[E({prim:"map",args:t.args},w({t:1,v:1})),...e];case"EMPTY_BIG_MAP":return Ke(t.args[0]),h(t.args[0]),Ke(t.args[1]),v(t.args[0]),[E({prim:"big_map",args:t.args},w({t:1,v:1})),...e];case"LAMBDA_REC":case"LAMBDA":{Ke(t.args[0]),Ke(t.args[1]);const n=[t.args[0]];"LAMBDA_REC"===t.prim&&n.push({prim:"lambda",args:[t.args[0],t.args[1]]});const i=Ge(t.args[2],n,{...r,contract:void 0});if("failed"in i)return{failed:i.failed,level:i.level+1};if(1!==i.length)throw new Ce(t,e,`${t.prim}: function must return a value`);return l(t.args[1],i[0]),[_({prim:"lambda",args:[t.args[0],t.args[1]]}),...e]}case"LEVEL":return[_({prim:"nat"},"@level"),...e];case"TOTAL_VOTING_POWER":case"MIN_BLOCK_TIME":return[_({prim:"nat"}),...e];case"VOTING_POWER":return s(0,["key_hash"]),[_({prim:"nat"}),...e.slice(1)];case"TICKET":{const t=s(0,null,["nat"])[0];return h(t),b(n,p.PtLimaPtL)?[E({prim:"ticket",args:[t]},w({t:1,v:1})),...e.slice(2)]:[_({prim:"option",args:[E({prim:"ticket",args:[t]},w({t:1,v:1}))]}),...e.slice(2)]}case"JOIN_TICKETS":{const r=Et("pair",s(0,["pair"])[0]);if("ticket"!==Me(r.args[0]))throw new Ce(t,e,`${t.prim}: ticket expected: ${Me(r.args[0])}`);return l(r.args[0],r.args[1]),[_({prim:"option",args:[E(r.args[0],{t:null})]}),...e.slice(1)]}case"SPLIT_TICKET":{const r=s(0,["ticket"],["pair"]),n=Et("pair",r[1]);if("nat"!==Me(n.args[0]))throw new Ce(t,e,`${t.prim}: nat expected: ${Me(n.args[0])}`);return l(n.args[0],n.args[1]),[_({prim:"option",args:[{prim:"pair",args:[E(r[0],{t:null}),E(r[0],{t:null})]}]}),...e.slice(2)]}case"READ_TICKET":{const t=w({v:2}),r=s(0,["ticket"])[0],n=t.v?.map(t=>"@"!==t?[t]:void 0);return[E({prim:"pair",args:[{prim:"address"},E(r.args[0],{t:null}),{prim:"nat"}]},{v:n?.[0]}),E(r,{v:n?.[1],t:null}),...e.slice(1)]}case"PAIRING_CHECK":{const r=s(0,["list"])[0].args[0];if(!_t(r))throw new Ce(t,e,`${t.prim}: pair expected: ${Me(r)}`);const n=Et("pair",r);if("bls12_381_g1"!==Me(n.args[0]))throw new Ce(t,e,`${t.prim}: bls12_381_g1 expected: ${Me(n.args[0])}`);if("bls12_381_g2"!==Me(n.args[1]))throw new Ce(t,e,`${t.prim}: bls12_381_g2 expected: ${Me(n.args[1])}`);return[_({prim:"bool"}),...e.slice(1)]}case"SAPLING_EMPTY_STATE":return[E({prim:"sapling_state",args:[t.args[0]]},w({v:1,t:1})),...e];case"SAPLING_VERIFY_UPDATE":{const r=s(0,["sapling_transaction"],["sapling_state"]);if(parseInt(r[0].args[0].int,10)!==parseInt(r[1].args[0].int,10))throw new Ce(t,e,`${t.prim}: sapling memo size mismatch: ${r[0].args[0].int} != ${r[1].args[0].int}`);return b(n,p.PtJakarta)?[_({prim:"option",args:[{prim:"pair",args:[{prim:"int"},E(r[1],{t:null})]}]}),...e.slice(2)]:[_({prim:"option",args:[{prim:"pair",args:[{prim:"bytes"},{prim:"pair",args:[{prim:"int"},E(r[1],{t:null})]}]}]}),...e.slice(2)]}case"OPEN_CHEST":return s(0,["chest_key"],["chest"],["nat"]),[_({prim:"or",args:[{prim:"bytes"},{prim:"bool"}]}),...e.slice(3)];case"VIEW":{const r=s(0,null,["address"]);return y(r[0]),[_({prim:"option",args:[t.args[1]]}),...e.slice(2)]}case"EMIT":{const r=w({f:1,t:1});if(t.args){const n=s(0,null);return l(n[0],t.args[0]),[E({prim:"operation"},r),...e.slice(1)]}return[E({prim:"operation"},r),...e.slice(1)]}case"IS_IMPLICIT_ACCOUNT":return s(0,["address"]),[_({prim:"option",args:[{prim:"key_hash"}]}),...e.slice(1)];case"INDEX_ADDRESS":return s(0,["address"]),[_({prim:"nat"}),...e.slice(1)];case"GET_ADDRESS_INDEX":return s(0,["address"]),[_({prim:"option",args:[{prim:"nat"}]}),...e.slice(1)];default:throw new ut(t,`unexpected instruction: ${t.prim}`)}})(i);if(void 0!==r?.traceCallback){const t={op:i,in:e,out:x};r.traceCallback(t)}return x}function Ve(t,e){for(const r of t)if(r.prim===e)return r;throw new ut(t,`missing contract section: ${e}`)}function je(t){const e={};for(const r of t)"view"===r.prim&&(e[r.args[0].string]=r);return e}function $e(t){if(Array.isArray(t))for(const e of t)if("prim"in e&&("parameter"===e.prim||"storage"===e.prim||"code"===e.prim))return!0;return!1}function ze(t,e){e=e||"%default";const r=qe(t).find(t=>t[0]===e);return void 0!==r?r[1]:"%default"===e?$e(t)?Ve(t,"parameter").args[0]:t:null}function qe(t){if($e(t)){const e=Ve(t,"parameter"),r=qe(e.args[0]),n=yt(e);return n.f?[[n.f[0],e.args[0]],...r]:r}if(e=t,Array.isArray(e)||"or"===e.prim){const e=Be(t),r=t=>{const r=yt(e[t]);if("or"===Me(e[t])){const n=qe(e[t]);return r.f?[[r.f[0],e[t]],...n]:n}return r.f?[[r.f[0],e[t]]]:[]};return[...r(0),...r(1)]}var e;return[]}function We(t,e){const r=(r,n,i,s)=>{Ke(r,!0),Ke(n);const o=Ge(s,[{prim:"pair",args:[{...r,annots:["@parameter"]},{...n,annots:["@storage"]}]}],{...e,contract:t});if("failed"in o)return o;try{Ue(o,[i])}catch(t){throw t instanceof ut?new Ce(s,o,t.message):t}return o},n=Ve(t,"parameter").args[0],i=Ve(t,"storage").args[0],s=r(n,i,{prim:"pair",args:[{prim:"list",args:[{prim:"operation"}]},i]},Ve(t,"code").args[0]);for(const e of Object.values(je(t)))r(e.args[1],i,e.args[2],e.args[3]);return s}function Ze(t,e,r){Ke(e),Fe(t,e,r||null)}function Ye(t,e,r){for(const t of e)Ke(t);if(void 0!==r?.contract)for(const t of["parameter","storage"]){Ke(Ve(r.contract,t).args[0])}return Ge(t,e,r||null)}function Xe(t,e,r=!1){if(Array.isArray(t)){for(const e of t)Ke(e);for(const t of e)Ke(t)}else Ke(t),Ke(e);De(t,e,r)}function Je(t,e=!1){try{return Ke(t,e),!0}catch{return!1}}function Qe(t,e){try{return We(t,e)}catch{return null}}function tr(t,e,r){try{return Ze(t,e,r),!0}catch{return!1}}function er(t,e,r=!1){try{return Xe(t,e,r),!0}catch{return!1}}class rr{constructor(t,e){this.contract=t,this.ctx={contract:t,...e},this.output=We(t,this.ctx)}static parse(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new rt("empty Michelson");if(Jt(n))return new rr(n,e)}static parseTypeExpression(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new nt("empty type expression");if(Zt(n))return Ke(n),n}static parseDataExpression(t,e){const r=new F(e),n="string"==typeof t?r.parseScript(t):r.parseJSON(t);if(null===n)throw new it("empty data expression");if(Xt(n))return n;throw void 0}section(t){return Ve(this.contract,t)}entryPoints(){return qe(this.contract)}entryPoint(t){return ze(this.contract,t)}assertDataValid(t,e){Ze(t,e,this.ctx)}isDataValid(t,e){return tr(t,e,this.ctx)}assertParameterValid(t,e){const r=this.entryPoint(t||void 0);if(null===r)throw new st(t?.toString());this.assertDataValid(e,r)}isParameterValid(t,e){try{return this.assertParameterValid(t,e),!0}catch{return!1}}functionType(t,e){return Ye(t,e,this.ctx)}}const nr=new rr([{prim:"parameter",args:[{prim:"unit"}]},{prim:"storage",args:[{prim:"unit"}]},{prim:"code",args:[[{prim:"CAR"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PAIR"}]]}]);function ir(t){return"failed"in t?`[FAILED: ${z(t.failed)}]`:t.map((t,e)=>{const r=yt(t);return`[${e}${r.v?"/"+r.v[0]:""}]: ${z(t)}`}).join("\n")}function sr(t,e){return r=>{if(Array.isArray(r)&&!t)return;const n=r.op[i]?.macro,s=`${n?"Macro":"Op"}: ${n?z(n,void 0,!0)+" / ":""}${z(r.op)}\nInput:\n${ir(r.in)}\nOutput:\n${ir(r.out)}\n`;e(s)}}function or(t){if(t instanceof Ce){const e=t.val[i]?.macro;return`${e?"Macro":"Op"}: ${e?z(e,void 0,!0)+" / ":""}${z(t.val)}\nStack:\n${ir(t.stackState)}\n`}if(t instanceof ht){return`Type: ${Array.isArray(t.val)?"["+t.val.map((t,e)=>`[${e}]: ${z(t)}`).join("; ")+"]":z(t.val)}\n${t.data?`Data: ${z(t.data)}\n`:""}\n`}return`Value: ${z(t.val)}`}const ar={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"}},5602(t,e,r){"use strict";r.r(e),r.d(e,{AddressValidationError:()=>z,BigMapEncodingError:()=>ae,BigMapValidationError:()=>M,BytesValidationError:()=>nt,ChainIDValidationError:()=>_t,ContractValidationError:()=>X,EncodeTicketError:()=>Ot,EventSchema:()=>ye,IntValidationError:()=>at,InvalidBigMapDiffError:()=>oe,InvalidBigMapSchemaError:()=>se,InvalidMapTypeError:()=>R,InvalidRpcResponseError:()=>ie,InvalidScriptError:()=>ne,KeyHashValidationError:()=>pt,KeyValidationError:()=>ft,ListValidationError:()=>Q,MapTypecheckError:()=>I,MapValidationError:()=>W,MichelsonMap:()=>N,MissingArgumentError:()=>ue,MutezValidationError:()=>et,NatValidationError:()=>V,OrValidationError:()=>D,ParameterEncodingError:()=>re,ParameterSchema:()=>ge,SaplingStateValue:()=>lt,Schema:()=>pe,SetValidationError:()=>wt,SignatureValidationError:()=>mt,StorageEncodingError:()=>ce,Token:()=>L,TokenArgumentValidationError:()=>K,TokenComparisonError:()=>H,UnitValue:()=>ut,VERSION:()=>be,ViewSchema:()=>me,deepEqual:()=>de});var n=r(6075),i=r.n(n),s=r(6571),o=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},o=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,o,c,u,h,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,u=t;u>=10;u/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!a.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(l+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(u=d.search(/e/i))>0?(c<0&&(c=u),c+=+d.slice(u+1),d=d.substring(0,u)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(l+"String expected: "+t);for(w(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=u=0,h=d.length;u<h;u++)if(r.indexOf(s=d.charAt(u))<0){if("."==s){if(u>c){c=h;continue}}else if(!o&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){o=!0,u=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(u=0;48===d.charCodeAt(u);u++);for(h=d.length;48===d.charCodeAt(--h););if(d=d.slice(u,++h))if(h-=u,(c=c-u-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],u=(c+1)%f,c<0&&(u+=f),u<h){for(u&&g.c.push(+d.slice(0,u)),h-=f;u<h;)g.c.push(+d.slice(u,u+=f));u=f-(d=d.slice(u)).length}else u-=h;for(;u--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:w(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=b(t.c),c=1==n||2==n&&(o<=T||o>=P)?_(c,o):A(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=b(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=_(c,s)}else if(e-=o+(2===n&&s>o),c=A(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=v(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*f-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,a,l,d,g,m=t.c,y=p;if(m){t:{for(i=1,a=m[0];a>=10;a/=10,i++);if((s=e-i)<0)s+=f,o=e,l=m[d=0],g=u(l/y[i-o-1]%10);else if((d=c((s+1)/f))>=m.length){if(!n)break t;for(;m.length<=d;m.push(0));l=g=0,i=1,o=(s%=f)-f+1}else{for(l=a=m[d],i=1;a>=10;a/=10,i++);g=(o=(s%=f)-f+i)<0?0:u(l/y[i-o-1]%10)}if(n=n||e<0||null!=m[d+1]||(o<0?l:l%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?l/y[i-o]:0:m[d-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(f-e%f)%f],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=d,a=1,d--):(m.length=d+1,a=y[f-s],m[d]=o>0?u(l/y[i-o]%y[o])*a:0),n)for(;;){if(0==d){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=a,a=1;o>=10;o/=10,a++);s!=a&&(t.e++,m[0]==h&&(m[0]=1));break}if(m[d]+=a,m[d]!=h)break;m[d--]=0,a=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=b(t.c),e=r<=T||r>=P?_(e,r):A(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(l+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(w(r=t[e],0,m,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(w(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(w(r[0],-m,0,e),w(r[1],0,m,e),T=r[0],P=r[1]):(w(r,-m,m,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)w(r[0],-m,-1,e),w(r[1],1,m,e),R=r[0],x=r[1];else{if(w(r,-m,m,e),!r)throw Error(l+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(l+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(l+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(w(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(w(r=t[e],0,m,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(l+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(l+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-m||i>m||i!==u(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%f)<1&&(e+=f),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==u(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return u(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,a,h=0,d=[],g=new M(o);if(null==t?t=O:w(t,0,m),s=c(t/f),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));h<s;)(a=131072*r[h]+(r[h+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[h]=n[0],r[h+1]=n[1]):(d.push(a%1e14),h+=2);h=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(l+"crypto unavailable");for(r=crypto.randomBytes(s*=7);h<s;)(a=281474976710656*(31&r[h])+1099511627776*r[h+1]+4294967296*r[h+2]+16777216*r[h+3]+(r[h+4]<<16)+(r[h+5]<<8)+r[h+6])>=9e15?crypto.randomBytes(7).copy(r,h):(d.push(a%1e14),h+=7);h=s/7}if(!I)for(;h<s;)(a=e())<9e15&&(d[h++]=a%1e14);for(s=d[--h],t%=f,s&&t&&(a=p[f-t],d[h]=u(s/a)*a);0===d[h];d.pop(),h--);if(h<0)d=[i=0];else{for(i=-1;0===d[0];d.splice(0,1),i-=f);for(h=1,a=d[0];a>=10;a/=10,h++);h<f&&(i-=f-h)}return g.e=i,g.c=d,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),y=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(A(b(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,y,v,s)).c,f=d.r,l=d.e),m=p[u=l+y+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?A(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=A(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%g,l=e/g|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%g)+(n=l*s+(o=t[c]/g|0)*u)%g*g+a)/r|0)+(n/g|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var c,l,d,p,g,m,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(l=n.e-i.e)+1,a||(a=h,l=y(n.e/f)-y(i.e/f),x=x/f|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&l--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=u(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(c=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=u(A/T))>1)for(g>=a&&(g=a-1),b=(m=t(N,g,a)).length,_=E.length;1==e(m,E,b,_);)g--,r(m,P<b?R:N,b,a),b=m.length,c=1;else 0==g&&(c=g=1),b=(m=N.slice()).length;if(b<_&&(m=[0].concat(m)),r(E,m,_,a),_=E.length,-1==c)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===c&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==h){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+l*f-1)+1,o,p)}else v.e=l,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,u=o.replace(i,"");if(n.test(u))return s.s=isNaN(u)?null:u<0?-1:1,void(s.c=s.e=null);if(u=u.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,u=u.replace(e,"$1").replace(r,"0.$1")),o!=u)return new M(u,c);throw Error(l+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return v(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return w(t,0,m),null==e?e=S:w(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-y(this.e/f))*f,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,a,h,d,p,g=this;if((t=new M(t)).c&&!t.isInteger())throw Error(l+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),a=t.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!t.c||!t.c[0])return p=new M(Math.pow(+F(g),a?t.s*(2-E(t)):+F(t))),e?p.mod(e):p;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&g.isInteger()&&e.isInteger())&&(g=g.mod(e))}else{if(t.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||a&&g.c[1]>=24e7:g.c[0]<8e13||a&&g.c[0]<=9999975e7)))return s=g.s<0&&E(t)?-0:0,g.e>-1&&(s=1/s),new M(h?1/s:s);k&&(s=c(k/f+2))}for(a?(r=new M(.5),h&&(t.s=1),d=E(t)):d=(i=Math.abs(+F(t)))%2,p=new M(o);;){if(d){if(!(p=p.times(g)).c)break;s?p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}if(i){if(0===(i=u(i/2)))break;d=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)d=E(t);else{if(0===(i=+F(t)))break;d=i%2}g=g.times(g),s?g.c&&g.c.length>s&&(g.c.length=s):n&&(g=g.mod(e))}return n?p:(h&&(p=o.div(p)),e?p.mod(e):s?H(p,k,S,void 0):p)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:w(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===v(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return v(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=v(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&y(this.e/f)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return v(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=v(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/f,u=t.e/f,l=o.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new M(d?o:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new M(l[0]?o:3==S?-0:0)}if(c=y(c),u=y(u),l=l.slice(),a=c-u){for((s=a<0)?(a=-a,i=l):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=l.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(l[e]!=d[e]){s=l[e]<d[e];break}if(s&&(i=l,l=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>a;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?K(t,l,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,l,d,p,m,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=y(E.e/f)+y(t.e/f),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=h,w=g,i=d;--i>=0;){for(r=0,p=A[i]%w,m=A[i]/w|0,s=i+(o=c);s>i;)r=((u=p*(u=_[--o]%w)+(a=m*u+(l=_[o]/w|0)*p)%w*w+b[s]+r)/v|0)+(a/w|0)+m*l,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/f,o=t.e/f,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=y(s),o=y(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/h|0,a[e]=h===a[e]?0:a[e]%h;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return w(t,1,m),null==e?e=S:w(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*f+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return w(t,-9007199254740991,d),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=b(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=y((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),b(s.c).slice(0,c)===(e=b(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(w(t,0,m),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(w(t,0,m),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(l+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,u=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=u+p.substr(s,a);c>0&&(h+=u+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,a,c,u,h,d,g,m,y,v=this,w=v.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(o)))throw Error(l+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+F(u));if(!w)return new M(v);for(e=new M(o),d=n=new M(o),i=h=new M(o),y=b(w),a=e.e=y.length-v.e-1,e.c[0]=p[(c=a%f)<0?f+c:c],t=!t||u.comparedTo(e)>0?a>0?e:d:u,c=x,x=1/0,u=new M(y),h.c[0]=0;g=r(u,e,0,1),1!=(s=n.plus(g.times(i))).comparedTo(t);)n=i,i=s,d=h.plus(g.times(s=d)),h=s,e=u.minus(g.times(s=e)),u=s;return s=r(t.minus(n),i,0,1),h=h.plus(s.times(d)),n=n.plus(s.times(i)),h.s=d.s=v.s,m=r(d,i,a*=2,S).minus(v).abs().comparedTo(r(h,n,a,S).minus(v).abs())<1?[d,i]:[h,n],x=c,m},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&w(t,1,m),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?_(b(r.c),s):A(b(r.c),s,"0"):(w(t,2,C.length,"Base"),e=n(A(b(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,c=Math.ceil,u=Math.floor,l="[BigNumber Error] ",h=1e14,f=14,d=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,m=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function b(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function v(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function w(t,e,r,n){if(t<e||t>r||t!==u(t))throw Error(l+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function E(t){var e=t.c.length-1;return y(t.e/f)==e&&t.c[e]%2!=0}function _(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function A(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const O=o;var S,T=r(2403),P=r(8691);class R extends s.TaquitoError{constructor(t,e){super(),this.mapType=t,this.reason=e,this.message=`The map type '${JSON.stringify(t)}' is invalid. Reason: ${e}.`,this.name="InvalidMapTypeError"}}const x=Symbol.for("taquito-michelson-map-type-symbol");class I extends s.TaquitoError{constructor(t,e,r,n){super(),this.value=t,this.type=e,this.reason=n,this.name="MapTypecheckError",this.message=`The ${r} provided: ${JSON.stringify(t)} is not compatible with the expected michelson type: ${JSON.stringify(e)}. Reason: ${JSON.stringify(n)}.`,this.name="MapTypecheckError"}}class N{static isMichelsonMap(t){return t&&!0===t[x]}constructor(t){this.valueMap=new Map,this.keyMap=new Map,this[S]=!0,t&&this.setType(t)}setType(t){!function(t){if(!("prim"in t))throw new R(t,"Missing 'prim' field");if(!["map","big_map"].includes(t.prim))throw new R(t,"The prim field should be 'map' or 'big_map'");if(!("args"in t))throw new R(t,"Missing 'args' field");if(!Array.isArray(t.args))throw new R(t,"The 'args' field should be an array");if(2!==t.args.length)throw new R(t,"The 'args' field should have 2 elements")}(t),this.keySchema=new pe(t.args[0]),this.valueSchema=new pe(t.args[1])}removeType(){this.keySchema=void 0,this.valueSchema=void 0}static fromLiteral(t,e){const r=new N(e);return Object.keys(t).forEach(e=>{r.set(e,t[e])}),r}typecheckKey(t){if(this.keySchema&&!this.keySchema.Typecheck(t))throw new I(t,this.keySchema,"key","Type validation failed")}typecheckValue(t){if(this.valueSchema&&!this.valueSchema.Typecheck(t))throw new I(t,this.valueSchema,"value","Type validation failed")}assertTypecheckValue(t){this.typecheckValue(t)}assertTypecheckKey(t){this.typecheckKey(t)}serializeDeterministically(t){return i()(t)}*keys(){for(const[t]of this.entries())yield t}*values(){for(const[,t]of this.entries())yield t}*entries(){for(const t of this.valueMap.keys())yield[this.keyMap.get(t),this.valueMap.get(t)]}get(t){this.assertTypecheckKey(t);const e=this.serializeDeterministically(t);return this.valueMap.get(e)}set(t,e){this.assertTypecheckKey(t),this.assertTypecheckValue(e);const r=this.serializeDeterministically(t);this.keyMap.set(r,t),this.valueMap.set(r,e)}delete(t){this.assertTypecheckKey(t),this.keyMap.delete(this.serializeDeterministically(t)),this.valueMap.delete(this.serializeDeterministically(t))}has(t){this.assertTypecheckKey(t);const e=this.serializeDeterministically(t);return this.keyMap.has(e)&&this.valueMap.has(e)}clear(){this.keyMap.clear(),this.valueMap.clear()}get size(){return this.keyMap.size}forEach(t){for(const[e,r]of this.entries())t(r,e,this)}}S=x;class k extends s.TaquitoError{constructor(t,e,r){super(),this.value=t,this.token=e,this.name="TokenValidationError";const n=this.token.annot(),i=n?`[${n}] `:"";this.message=`${i}${r}`}}class L{static get fieldNumberingStrategy(){return L._fieldNumberingStrategy}static set fieldNumberingStrategy(t){L._fieldNumberingStrategy=t}constructor(t,e,r,n){this.val=t,this.idx=e,this.fac=r,this.parentTokenType=n,this.createToken=this.fac}typeWithoutAnnotations(){const t=e=>{if("object"==typeof e){if(Array.isArray(e)){return e.map(e=>t(e))}const r=e;return r.args?{prim:r.prim,args:r.args.map(e=>t(e))}:{prim:r.prim}}return e};return(e=this.val).args?{prim:e.prim,args:e.args.map(e=>t(e))}:{prim:e.prim};var e}annot(){return(Array.isArray(this.val.annots)&&this.val.annots.length>0?this.val.annots[0]:String(this.idx)).replace(/(%|:)(_Liq_entry_)?/,"")}hasAnnotations(){return Array.isArray(this.val.annots)&&this.val.annots.length}get tokenVal(){return this.val}ExtractSignature(){return[[this.generateSchema()]]}}L._fieldNumberingStrategy="Latest";class C extends L{compare(t,e){return t<e?-1:t>e?1:0}}class M extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="BigMapValidationError"}}class B extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get ValueSchema(){return this.createToken(this.val.args[1],0)}get KeySchema(){return this.createToken(this.val.args[0],0)}generateSchema(){return{__michelsonType:B.prim,schema:{key:this.KeySchema.generateSchema(),value:this.ValueSchema.generateSchema()}}}validate(t){if(!N.isMichelsonMap(t))throw new M(t,this,`Value ${JSON.stringify(t)} is not a MichelsonMap`)}objLitToMichelsonMap(t){return t instanceof N?t:"object"==typeof t?0===Object.keys(t).length?new N:N.fromLiteral(t):t}Encode(t){const e=this.objLitToMichelsonMap(t.pop());return this.validate(e),Array.from(e.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(e.get(t))]}))}EncodeObject(t,e){const r=this.objLitToMichelsonMap(t);return this.validate(r),e&&e[B.prim]?e[B.prim](r,this.val):Array.from(r.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(r.get(t))]}))}Execute(t,e){if(e&&e[B.prim])return e[B.prim](t,this.val);if(Array.isArray(t)){const e=new N(this.val);return t.forEach(t=>{e.set(this.KeySchema.ToKey(t.args[0]),this.ValueSchema.Execute(t.args[1]))}),e}if("int"in t)return t.int;throw new M(t,this,`Big map is expecting either an array (Athens) or an object with an int property (Babylon). Got ${JSON.stringify(t)}`)}findAndReturnTokens(t,e){return B.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),this.ValueSchema.findAndReturnTokens(t,e),e}}B.prim="big_map";class D extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="OrValidationError"}}class U extends C{constructor(t,e,r,n){super(t,e,r,n),this.val=t,this.idx=e,this.fac=r,this.parentTokenType=n}Encode(t){const e=t[t.length-1],r=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let n=1;r instanceof U&&(n=Object.keys(r.generateSchema().schema).length);const i=this.createToken(this.val.args[1],this.getIdxForChildren()+n,"Or");if(String(r.annot())!==String(e)||r instanceof U){if(String(i.annot())!==String(e)||i instanceof U){if(r instanceof U){const e=r.Encode(t);if(e)return{prim:"Left",args:[e]}}if(i instanceof U){const e=i.Encode(t);if(e)return{prim:"Right",args:[e]}}return null}return t.pop(),{prim:"Right",args:[i.Encode(t)]}}return t.pop(),{prim:"Left",args:[r.Encode(t)]}}ExtractSignature(){const t=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let e=1;t instanceof U&&(e=Object.keys(t.generateSchema().schema).length);const r=this.createToken(this.val.args[1],this.getIdxForChildren()+e,"Or"),n=[];if(t instanceof U)n.push(...t.ExtractSignature());else for(const e of t.ExtractSignature())n.push([t.annot(),...e]);if(r instanceof U)n.push(...r.ExtractSignature());else for(const t of r.ExtractSignature())n.push([r.annot(),...t]);return n}EncodeObject(t,e){this.validateJavascriptObject(t);const r=Object.keys(t)[0],n=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let i=1;n instanceof U&&(i=Object.keys(n.generateSchema().schema).length);const s=this.createToken(this.val.args[1],this.getIdxForChildren()+i,"Or");if(String(n.annot())!==String(r)||n instanceof U){if(String(s.annot())!==String(r)||s instanceof U){if(n instanceof U){const r=n.EncodeObject(t,e);if(r)return{prim:"Left",args:[r]}}if(s instanceof U){const r=s.EncodeObject(t,e);if(r)return{prim:"Right",args:[r]}}return null}return{prim:"Right",args:[s.EncodeObject(t[r],e)]}}return{prim:"Left",args:[n.EncodeObject(t[r],e)]}}validateJavascriptObject(t){if("object"!=typeof t||Array.isArray(t)||null===t||1!==Object.keys(t).length)throw new D(t,this,`EncodeObject expects an object with a single key but got: ${JSON.stringify(t)}`)}Execute(t,e){const r=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let n=1;r instanceof U&&(n=Object.keys(r.generateSchema().schema).length);const i=this.createToken(this.val.args[1],this.getIdxForChildren()+n,"Or");if("Right"===t.prim)return i instanceof U?i.Execute(t.args[0],e):{[i.annot()]:i.Execute(t.args[0],e)};if("Left"===t.prim)return r instanceof U?r.Execute(t.args[0],e):{[r.annot()]:r.Execute(t.args[0],e)};throw new D(t,this,`Was expecting Left or Right prim but got: ${JSON.stringify(t.prim)}`)}traversal(t,e,r){const n=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let i,s=1;n instanceof U?(i=t(n),s=Object.keys(n.generateSchema().schema).length):i={[n.annot()]:t(n)};const o=this.createToken(this.val.args[1],this.getIdxForChildren()+s,"Or");let a;a=o instanceof U?e(o):{[o.annot()]:e(o)};return r(i,a)}generateSchema(){return{__michelsonType:U.prim,schema:this.traversal(t=>t instanceof U?t.generateSchema().schema:t.generateSchema(),t=>t instanceof U?t.generateSchema().schema:t.generateSchema(),(t,e)=>({...t,...e}))}}findToken(t){const e=this.createToken(this.val.args[0],this.getIdxForChildren(),"Or");let r=1;if(e instanceof U){const t=e.generateSchema();r=Object.keys(t.schema).length}const n=this.createToken(this.val.args[1],this.getIdxForChildren()+r,"Or");if(String(e.annot())===String(t)&&!(e instanceof U)&&e instanceof C)return e;if(String(n.annot())===String(t)&&!(n instanceof U)&&n instanceof C)return n;if(e instanceof U){const r=e.findToken(t);if(r)return r}if(n instanceof U){const e=n.findToken(t);if(e)return e}return null}compare(t,e){const r=Object.keys(t)[0];if(r!==Object.keys(e)[0]){return JSON.stringify(this.EncodeObject(t))<JSON.stringify(this.EncodeObject(e))?-1:1}{const n=this.findToken(r);if(n instanceof C)return n.compare(t[r],e[r])}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}findAndReturnTokens(t,e){return U.prim===t&&e.push(this),this.traversal(r=>r.findAndReturnTokens(t,e),r=>r.findAndReturnTokens(t,e),(t,e)=>({...t,...e})),e}getIdxForChildren(){return"Legacy"===L.fieldNumberingStrategy||"Or"===this.parentTokenType?this.idx:0}}U.prim="or";class K extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="TokenArgumentValidationError"}}class H extends s.TaquitoError{constructor(t,e){super(),this.val1=t,this.val2=e,this.name="TokenComparisonError",this.message=`Tokens ${JSON.stringify(t)} and ${JSON.stringify(e)} are not comparable`}}function F(t,e=G.prim){if(Array.isArray(t))return F({prim:e,args:t},e);if(void 0===t.args)throw new K(`The value ${JSON.stringify(t)} is an invalid PairToken with no arguments, a pair must have two or more arguments.`);return t.args.length>2?[t.args[0],{prim:e,args:t.args.slice(1)}]:[t.args[0],t.args[1]]}class G extends C{constructor(t,e,r,n){super(Array.isArray(t)?{prim:G.prim,args:t}:t.prim?t:{prim:G.prim,args:t},e,r,n)}args(){return F(this.val)}tokens(){let t=0;return this.args().map(e=>{const r=this.createToken(e,this.getIdxForChildren()+t,"Pair");return r instanceof G?t+=Object.keys(r.generateSchema()).length:t++,r})}Encode(t){return{prim:"Pair",args:this.tokens().map(e=>e.Encode(t))}}ExtractSignature(){const t=this.args(),e=this.createToken(t[0],this.getIdxForChildren(),"Pair");let r=1;e instanceof U&&(r=Object.keys(e.generateSchema()).length);const n=this.createToken(t[1],this.getIdxForChildren()+r,"Pair"),i=[];for(const t of e.ExtractSignature())for(const e of n.ExtractSignature())i.push([...t,...e]);return i}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}ToKey(t){return this.Execute(t)}EncodeObject(t,e){const[r,n]=this.tokens();let i,s;return i=r instanceof G&&!r.hasAnnotations()?t:t[r.annot()],s=n instanceof G&&!n.hasAnnotations()?t:t[n.annot()],{prim:"Pair",args:[r.EncodeObject(i,e),n.EncodeObject(s,e)]}}traversal(t,e){const r=this.args(),n=this.createToken(r[0],this.getIdxForChildren(),"Pair");let i,s=1;n instanceof G&&!n.hasAnnotations()?(i=t(n),n instanceof G&&(s=Object.keys(n.generateSchema()).length)):i={[n.annot()]:t(n)};const o=this.createToken(r[1],this.getIdxForChildren()+s,"Pair");let a;a=o instanceof G&&!o.hasAnnotations()?e(o):{[o.annot()]:e(o)};return{...i,...a}}Execute(t,e){const r=F(t,"Pair");return this.traversal(t=>t.Execute(r[0],e),t=>t.Execute(r[1],e))}generateSchema(){return{__michelsonType:G.prim,schema:this.traversal(t=>t instanceof G&&!t.hasAnnotations()?t.generateSchema().schema:t.generateSchema(),t=>t instanceof G&&!t.hasAnnotations()?t.generateSchema().schema:t.generateSchema())}}compare(t,e){const[r,n]=this.tokens(),i=(t,e)=>t instanceof G&&!t.hasAnnotations()?e:e[t.annot()];if(r instanceof C&&n instanceof C){const s=r.compare(i(r,t),i(r,e));return 0===s?n.compare(i(n,t),i(n,e)):s}throw new H(t,e)}findAndReturnTokens(t,e){return G.prim===t&&e.push(this),this.tokens().map(r=>r.findAndReturnTokens(t,e)),e}getIdxForChildren(){return"Legacy"===L.fieldNumberingStrategy||"Pair"===this.parentTokenType?this.idx:0}}G.prim="pair";class V extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="NatValidationError"}}class j extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}Encode(t){const e=t.pop();return this.validate(e),{int:new O(e).toFixed()}}validate(t){let e;try{e=new O(t)}catch{throw new V(t,this,`Value is not a number: ${JSON.stringify(t)}`)}if(e.isNaN())throw new V(t,this,`Value is not a number: ${JSON.stringify(t)}`);if(e.isNegative())throw new V(t,this,`Value cannot be negative: ${JSON.stringify(t)}`)}EncodeObject(t,e){return this.validate(t),e&&e[j.prim]?e[j.prim](t):{int:new O(t).toFixed()}}generateSchema(){return{__michelsonType:j.prim,schema:j.prim}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:j.prim}}}ToKey({int:t}){return new O(t)}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return j.prim===t&&e.push(this),e}}j.prim="nat";class $ extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t[Object.keys(t)[0]]}generateSchema(){return{__michelsonType:$.prim,schema:$.prim}}Encode(t){return{string:t.pop()}}EncodeObject(t,e){return e&&e[$.prim]?e[$.prim](t):{string:t}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:$.prim}}}findAndReturnTokens(t,e){return $.prim===t&&e.push(this),e}}$.prim="string";class z extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="AddressValidationError"}}class q extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}ToBigMapKey(t){return{key:{bytes:(0,T.b58DecodeAddress)(t)},type:{prim:"bytes"}}}validate(t){if("string"!=typeof t)throw new z(t,this,"Type error");if((0,T.validateAddress)(t)!==T.ValidationResult.VALID)throw new z(t,this,`Address is not valid: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[q.prim]?e[q.prim](t):{string:t}}Execute(t){if(t.string)return t.string;if(!t.bytes)throw new z(t,this,`cannot be missing both string and bytes: ${JSON.stringify(t)}`);return(0,T.encodeAddress)(t.bytes)}generateSchema(){return{__michelsonType:q.prim,schema:q.prim}}ToKey({bytes:t,string:e}){if(e)return e;if(!t)throw new z({bytes:t,string:e},this,`cannot be missing both string and bytes ${JSON.stringify({string:e,bytes:t})}`);return(0,T.encodeAddress)(t)}compare(t,e){const[r,n]=(0,T.splitAddress)(t),[i,s]=(0,T.splitAddress)(e),o=n||"",a=s||"",c=(0,T.b58DecodeAddress)(r,"array"),u=(0,T.b58DecodeAddress)(i,"array"),l=(0,T.compareArrays)(c,u);return 0===l?o<a?-1:o>a?1:0:l}findAndReturnTokens(t,e){return q.prim===t&&e.push(this),e}}q.prim="address";class W extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="MapValidationError"}}class Z extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get ValueSchema(){return this.createToken(this.val.args[1],0)}get KeySchema(){return this.createToken(this.val.args[0],0)}validate(t){if(!N.isMichelsonMap(t))throw new W(t,this,`Value ${JSON.stringify(t)} is not a valid MichelsonMap`)}Execute(t,e){const r=new N(this.val);return t.forEach(t=>{r.set(this.KeySchema.ToKey(t.args[0]),this.ValueSchema.Execute(t.args[1],e))}),r}objLitToMichelsonMap(t){return t instanceof N?t:"object"==typeof t?0===Object.keys(t).length?new N:N.fromLiteral(t):t}Encode(t){const e=this.objLitToMichelsonMap(t.pop());return this.validate(e),Array.from(e.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(e.get(t))]}))}EncodeObject(t,e){const r=this.objLitToMichelsonMap(t);return this.validate(r),e&&e[Z.prim]?e[Z.prim](r):Array.from(r.keys()).sort((t,e)=>this.KeySchema.compare(t,e)).map(t=>({prim:"Elt",args:[this.KeySchema.EncodeObject(t),this.ValueSchema.EncodeObject(r.get(t))]}))}generateSchema(){return{__michelsonType:Z.prim,schema:{key:this.KeySchema.generateSchema(),value:this.ValueSchema.generateSchema()}}}findAndReturnTokens(t,e){return Z.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),this.ValueSchema.findAndReturnTokens(t,e),e}}Z.prim="map";class Y extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return"true"===String(t.prim).toLowerCase()}Encode(t){return{prim:t.pop()?"True":"False"}}EncodeObject(t,e){return e&&e[Y.prim]?e[Y.prim](t):{prim:t?"True":"False"}}generateSchema(){return{__michelsonType:Y.prim,schema:Y.prim}}ToBigMapKey(t){return{key:this.EncodeObject(t),type:{prim:Y.prim}}}ToKey(t){return this.EncodeObject(t)}compare(t,e){return t&&e||!t&&!e?0:t?1:-1}findAndReturnTokens(t,e){return Y.prim===t&&e.push(this),e}}Y.prim="bool";class X extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ContractValidationError"}}class J extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if("string"!=typeof t)throw new X(t,this,"Type error");if((0,T.validateAddress)(t)!==T.ValidationResult.VALID)throw new X(t,this,`Value ${JSON.stringify(t)} is not a valid contract address.`);return null}Execute(t){if(t.string)return t.string;if(!t.bytes)throw new X(t,this,`Value ${JSON.stringify(t)} is not a valid contract address. must contain bytes or string.`);return(0,T.encodeAddress)(t.bytes)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[J.prim]?e[J.prim](t):{string:t}}generateSchema(){const t=this.createToken(this.val.args[0],0);return{__michelsonType:J.prim,schema:{parameter:this.val.args[0]?t.generateSchema():{}}}}findAndReturnTokens(t,e){return J.prim===t&&e.push(this),e}}J.prim="contract";class Q extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ListValidationError"}}class tt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueSchema(){return this.createToken(this.val.args[0],this.idx)}validate(t){if(!Array.isArray(t))throw new Q(t,this,`Value ${JSON.stringify(t)} is not a valid array`)}Encode(t){const e=t.pop();this.validate(e);const r=this.createToken(this.val.args[0],0);return e.reduce((t,e)=>[...t,r.EncodeObject(e)],[])}Execute(t,e){const r=this.createToken(this.val.args[0],0);return this.validate(t),t.reduce((t,n)=>[...t,r.Execute(n,e)],[])}EncodeObject(t,e){const r=this.createToken(this.val.args[0],0);return this.validate(t),e&&e[tt.prim]?e[tt.prim](t):t.reduce((t,e)=>[...t,r.EncodeObject(e)],[])}generateSchema(){return{__michelsonType:tt.prim,schema:this.valueSchema.generateSchema()}}findAndReturnTokens(t,e){return tt.prim===t&&e.push(this),this.createToken(this.val.args[0],this.idx).findAndReturnTokens(t,e),e}}tt.prim="list";class et extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="MutezValidationError"}}class rt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}generateSchema(){return{__michelsonType:rt.prim,schema:rt.prim}}validate(t){let e;try{e=new O(t)}catch{throw new et(t,this,`Value is not a number: ${t}`)}if(e.isNaN())throw new et(t,this,`Value is not a number: ${t}`)}Encode(t){const e=t.pop();return this.validate(e),{int:String(e).toString()}}EncodeObject(t,e){return this.validate(t),e&&e[rt.prim]?e[rt.prim](t):{int:String(t).toString()}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:rt.prim}}}ToKey({int:t}){return t}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return rt.prim===t&&e.push(this),e}}rt.prim="mutez";class nt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="BytesValidationError"}}class it extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}ToBigMapKey(t){return{key:{bytes:t},type:{prim:it.prim}}}validate(t){if("string"!=typeof t||!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new nt(t,this,`Invalid bytes: ${t}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=(0,T.stripHexPrefix)(this.convertUint8ArrayToHexString(e)),this.validate(e),{bytes:String(e).toString()}}EncodeObject(t,e){return"string"==typeof(t=this.convertUint8ArrayToHexString(t))&&(t=(0,T.stripHexPrefix)(t)),this.validate(t),e&&e[it.prim]?e[it.prim](t):{bytes:String(t).toString()}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:it.prim,schema:it.prim}}ToKey({bytes:t,string:e}){return e||t}findAndReturnTokens(t,e){return it.prim===t&&e.push(this),e}}it.prim="bytes";class st extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}subToken(){return this.createToken(this.val.args[0],this.idx)}schema(){return this.createToken(this.val.args[0],0)}annot(){return Array.isArray(this.val.annots)?super.annot():this.createToken(this.val.args[0],this.idx).annot()}Encode(t){const e=t;return null==e?{prim:"None"}:!Array.isArray(e)||void 0!==e[e.length-1]&&null!==e[e.length-1]?{prim:"Some",args:[this.schema().Encode(t)]}:(e.pop(),{prim:"None"})}EncodeObject(t,e){let r=t;return null==r?{prim:"None"}:(r="object"==typeof r&&"Some"in r?r.Some:r,Array.isArray(r)&&1===r.length&&(r=r[0]),{prim:"Some",args:[this.schema().EncodeObject(r,e)]})}Execute(t,e){return"None"===t.prim?null:{Some:this.schema().Execute(t.args[0],e)}}generateSchema(){return{__michelsonType:st.prim,schema:this.schema().generateSchema()}}ExtractSignature(){return[...this.schema().ExtractSignature()]}get KeySchema(){return this.schema()}compare(t,e){return t?e?this.KeySchema.compare(t,e):1:-1}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:this.EncodeObject(t),type:this.typeWithoutAnnotations()}}findAndReturnTokens(t,e){return st.prim===t&&e.push(this),this.subToken().findAndReturnTokens(t,e),e}}st.prim="option";class ot extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string&&/^\d+$/.test(t.string)?new Date(1e3*Number(t.string)).toISOString():t.string?new Date(t.string).toISOString():t.int?new Date(1e3*Number(t.int)).toISOString():void 0}Encode(t){const e=t.pop();return"number"==typeof e?{int:String(e)}:{string:e}}EncodeObject(t,e){return e&&e[ot.prim]?e[ot.prim](t):"number"==typeof t?{int:String(t)}:{string:t}}generateSchema(){return{__michelsonType:ot.prim,schema:ot.prim}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:ot.prim}}}findAndReturnTokens(t,e){return ot.prim===t&&e.push(this),e}}ot.prim="timestamp";class at extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="IntValidationError"}}class ct extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return new O(t[Object.keys(t)[0]])}generateSchema(){return{__michelsonType:ct.prim,schema:ct.prim}}validate(t){let e;try{e=new O(t)}catch{throw new at(t,this,`Value is not a number: ${JSON.stringify(t)}`)}if(e.isNaN())throw new at(t,this,`Value is not a number: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{int:new O(e).toFixed()}}EncodeObject(t,e){return this.validate(t),e&&e[ct.prim]?e[ct.prim](t):{int:new O(t).toFixed()}}ToBigMapKey(t){return{key:{int:String(t)},type:{prim:ct.prim}}}ToKey({int:t}){return t}compare(t,e){const r=Number(t),n=Number(e);return r===n?0:r<n?-1:1}findAndReturnTokens(t,e){return ct.prim===t&&e.push(this),e}}ct.prim="int";const ut=Symbol(),lt={};class ht extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Encode(t){return t.pop(),{prim:"Unit"}}EncodeObject(t,e){return e&&e[ht.prim]?e[ht.prim](t):{prim:"Unit"}}Execute(t){return ut}generateSchema(){return{__michelsonType:ht.prim,schema:ht.prim}}compare(t,e){return 0}ToKey(t){return ut}ToBigMapKey(t){return{key:{prim:"Unit"},type:{prim:ht.prim}}}findAndReturnTokens(t,e){return ht.prim===t&&e.push(this),e}}ht.prim="unit";class ft extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="KeyValidationError"}}class dt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:(0,T.encodeKey)(t.bytes)}validate(t){if((0,T.validatePublicKey)(t)!==T.ValidationResult.VALID)throw new ft(t,this,"Key is not valid")}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[dt.prim]?e[dt.prim](t):{string:t}}generateSchema(){return{__michelsonType:dt.prim,schema:dt.prim}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:{string:t},type:{prim:dt.prim}}}compare(t,e){const r=(0,P.publicKeyFromString)(t),n=(0,P.publicKeyFromString)(e),i=r.toProtocol(),s=n.toProtocol();return i[0]===s[0]?r.compare(n):i[0]>s[0]?1:-1}findAndReturnTokens(t,e){return dt.prim===t&&e.push(this),e}}dt.prim="key";class pt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="KeyHashValidationError"}}class gt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:(0,T.encodeKeyHash)(t.bytes)}validate(t){if((0,T.validateKeyHash)(t)!==T.ValidationResult.VALID)throw new pt(t,this,`KeyHash is not valid: ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[gt.prim]?e[gt.prim](t):{string:t}}generateSchema(){return{__michelsonType:gt.prim,schema:gt.prim}}ToKey({string:t,bytes:e}){return t||(0,T.encodeKeyHash)(e)}ToBigMapKey(t){return{key:{string:t},type:{prim:gt.prim}}}compare(t,e){const r=(0,T.b58DecodePublicKeyHash)(t,"array"),n=(0,T.b58DecodePublicKeyHash)(e,"array");return(0,T.compareArrays)(r,n)}findAndReturnTokens(t,e){return gt.prim===t&&e.push(this),e}}gt.prim="key_hash";class mt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SignatureValidationError"}}class yt extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string?t.string:t.bytes}validate(t){if((0,T.validateSignature)(t)!==T.ValidationResult.VALID)throw new mt(t,this,"Signature is not valid")}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[yt.prim]?e[yt.prim](t):{string:t}}generateSchema(){return{__michelsonType:yt.prim,schema:yt.prim}}ToKey(t){return this.Execute(t)}ToBigMapKey(t){return{key:{string:t},type:{prim:yt.prim}}}findAndReturnTokens(t,e){return yt.prim===t&&e.push(this),e}}yt.prim="signature";class bt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get paramSchema(){return this.createToken(this.val.args[0],this.idx)}get returnSchema(){return this.createToken(this.val.args[1],this.idx+1)}Execute(t){return t.string?t.string:t}Encode(t){return t.pop()}EncodeObject(t,e){return e&&e[bt.prim]?e[bt.prim](t):t}generateSchema(){return{__michelsonType:bt.prim,schema:{parameters:this.paramSchema.generateSchema(),returns:this.returnSchema.generateSchema()}}}findAndReturnTokens(t,e){return bt.prim===t&&e.push(this),this.createToken(this.val.args[0],this.idx).findAndReturnTokens(t,e),this.createToken(this.val.args[1],this.idx).findAndReturnTokens(t,e),e}}bt.prim="lambda";class vt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){return t.string}Encode(...t){return{string:t.pop()}}EncodeObject(t,e){return e&&e[vt.prim]?e[vt.prim](t):{string:t}}generateSchema(){return{__michelsonType:vt.prim,schema:vt.prim}}findAndReturnTokens(t,e){return vt.prim===t&&e.push(this),e}}vt.prim="operation";class wt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SetValidationError"}}class Et extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get KeySchema(){return this.createToken(this.val.args[0],0)}validate(t){if(!Array.isArray(t))throw new wt(t,this,`Value ${JSON.stringify(t)} is not an array`)}Encode(t){const e=t.pop();return this.validate(e),e.sort((t,e)=>this.KeySchema.compare(t,e)).reduce((t,e)=>[...t,this.KeySchema.EncodeObject(e)],[])}Execute(t,e){return t.reduce((t,r)=>[...t,this.KeySchema.Execute(r,e)],[])}EncodeObject(t,e){return this.validate(t),e&&e[Et.prim]?e[Et.prim](t):t.sort((t,e)=>this.KeySchema.compare(t,e)).reduce((t,e)=>[...t,this.KeySchema.EncodeObject(e)],[])}generateSchema(){return{__michelsonType:Et.prim,schema:this.KeySchema.generateSchema()}}findAndReturnTokens(t,e){return Et.prim===t&&e.push(this),this.KeySchema.findAndReturnTokens(t,e),e}}Et.prim="set";class _t extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChainIDValidationError"}}class At extends C{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if((0,T.validateChain)(t)!==T.ValidationResult.VALID)throw new _t(t,this,`Value ${JSON.stringify(t)} is not a valid ChainID`)}Execute(t){return t[Object.keys(t)[0]]}generateSchema(){return{__michelsonType:At.prim,schema:At.prim}}Encode(t){const e=t.pop();return this.validate(e),{string:e}}EncodeObject(t,e){return this.validate(t),e&&e[At.prim]?e[At.prim](t):{string:t}}ToKey({string:t}){return t}ToBigMapKey(t){return{key:{string:t},type:{prim:At.prim}}}findAndReturnTokens(t,e){return At.prim===t&&e.push(this),e}}At.prim="chain_id";class Ot extends s.TaquitoError{constructor(){super(),this.name="TicketEncodeError",this.message="Tickets cannot be sent to the blockchain; they are created on-chain"}}const St={prim:"contract"},Tt={prim:"int"};class Pt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueToken(){return this.createToken(this.val.args[0],this.idx)}Encode(t){throw new Ot}EncodeObject(t,e){if(e&&e[Pt.prim])return e[Pt.prim](t,this.val);throw new Ot}Execute(t,e){if(e&&e[Pt.prim])return e[Pt.prim](t,this.val);const r=this.createToken(St,this.idx),n=this.valueToken,i=this.createToken(Tt,this.idx);return void 0===t.args[2]&&void 0!==t.args[1].args?{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1].args[0],e),amount:i.Execute(t.args[1].args[1],e)}:{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1],e),amount:i.Execute(t.args[2],e)}}generateSchema(){return{__michelsonType:Pt.prim,schema:{value:this.valueToken.generateSchema(),ticketer:{__michelsonType:J.prim,schema:J.prim},amount:{__michelsonType:ct.prim,schema:ct.prim}}}}findAndReturnTokens(t,e){return Pt.prim===t&&e.push(this),this.valueToken.findAndReturnTokens(t,e),e}}Pt.prim="ticket";class Rt extends s.TaquitoError{constructor(){super(),this.name="TicketDeprecatedEncodeError",this.message="Ticket_deprecated cannot be sent to the blockchain; they are created on-chain"}}const xt={prim:"contract"},It={prim:"int"};class Nt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}get valueToken(){return this.createToken(this.val.args[0],this.idx)}Encode(t){throw new Rt}EncodeObject(t,e){if(e&&e[Nt.prim])return e[Nt.prim](t,this.val);throw new Rt}Execute(t,e){if(e&&e[Nt.prim])return e[Nt.prim](t,this.val);const r=this.createToken(xt,this.idx),n=this.valueToken,i=this.createToken(It,this.idx);return void 0===t.args[2]&&void 0!==t.args[1].args?{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1].args[0],e),amount:i.Execute(t.args[1].args[1],e)}:{ticketer:r.Execute(t.args[0],e),value:n.Execute(t.args[1],e),amount:i.Execute(t.args[2],e)}}generateSchema(){return{__michelsonType:Nt.prim,schema:{value:this.valueToken.generateSchema(),ticketer:{__michelsonType:J.prim,schema:J.prim},amount:{__michelsonType:ct.prim,schema:ct.prim}}}}findAndReturnTokens(t,e){return Nt.prim===t&&e.push(this),this.valueToken.findAndReturnTokens(t,e),e}}Nt.prim="ticket_deprecated";class kt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="NeverTokenError"}}class Lt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Encode(t){const e=t.pop();throw new kt(e,this,`Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(e)}.`)}EncodeObject(t,e){if(e&&e[Lt.prim])return e[Lt.prim](t);throw new kt(t,this,`Assigning a value to the type never is forbidden. Trying to assign ${JSON.stringify(t)}.`)}Execute(t){throw new kt(t,this,`There is no literal value for the type never. Trying to execute ${JSON.stringify(t)}.`)}generateSchema(){return{__michelsonType:Lt.prim,schema:Lt.prim}}findAndReturnTokens(t,e){return Lt.prim===t&&e.push(this),e}}Lt.prim="never";class Ct extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingStateValidationError"}}class Mt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}isValid(t){return"object"==typeof t&&0===Object.keys(t).length}Execute(t,e){if(e&&e[Mt.prim])return e[Mt.prim](t,this.val);if("int"in t)return t.int;throw new Ct(t,this,`Sapling state is expecting an object with an int property. Got ${JSON.stringify(t)}`)}Encode(t){const e=t.pop();if(this.isValid(e))return[];throw new Ct(e,this,`Invalid sapling_state. Received: ${JSON.stringify(e)} while expecting: {}`)}EncodeObject(t,e){if(e&&e[Mt.prim])return e[Mt.prim](t);if(this.isValid(t))return[];throw new Ct(t,this,`Invalid sapling_state. Received: ${JSON.stringify(t)} while expecting: {}`)}generateSchema(){return{__michelsonType:Mt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Mt.prim===t&&e.push(this),e}}Mt.prim="sapling_state";class Bt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingTransactionValidationError"}}class Dt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){throw new Bt(t,this,`There is no literal value for the sapling_transaction type. Got: ${JSON.stringify(t)}.`)}validateBytes(t){const e=/^(0x|0X)?([0-9a-fA-F]*$)/.exec(t);if(e&&e[2].length%2==0)return e[2];throw new Bt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.validateBytes(this.convertUint8ArrayToHexString(e)),{bytes:String(e).toString()}}EncodeObject(t,e){return t=this.validateBytes(this.convertUint8ArrayToHexString(t)),e&&e[Dt.prim]?e[Dt.prim](t):{bytes:String(t).toString()}}generateSchema(){return{__michelsonType:Dt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Dt.prim===t&&e.push(this),e}}Dt.prim="sapling_transaction";class Ut extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="SaplingTransactionDeprecatedValidationError"}}class Kt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t){throw new Ut(t,this,`There is no literal value for the sapling_transaction_deprecated type. Got: ${JSON.stringify(t)}.`)}validateBytes(t){const e=/^(0x|0X)?([0-9a-fA-F]*$)/.exec(t);if(e&&e[2].length%2==0)return e[2];throw new Ut(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.validateBytes(this.convertUint8ArrayToHexString(e)),{bytes:String(e).toString()}}EncodeObject(t,e){return t=this.validateBytes(this.convertUint8ArrayToHexString(t)),e&&e[Kt.prim]?e[Kt.prim](t):{bytes:String(t).toString()}}generateSchema(){return{__michelsonType:Kt.prim,schema:{memoSize:this.val.args[0].int}}}findAndReturnTokens(t,e){return Kt.prim===t&&e.push(this),e}}Kt.prim="sapling_transaction_deprecated";class Ht extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381frValidationError"}}class Ft extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Ht(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return"number"==typeof e?{int:e.toString()}:(e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e})}EncodeObject(t,e){return e&&e[Ft.prim]?e[Ft.prim](t):"number"==typeof t?{int:t.toString()}:(t=this.convertUint8ArrayToHexString(t),this.validate(t),{bytes:t})}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Ft.prim,schema:Ft.prim}}findAndReturnTokens(t,e){return Ft.prim===t&&e.push(this),e}}Ft.prim="bls12_381_fr";class Gt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381g1ValidationError"}}class Vt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Gt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[Vt.prim]?e[Vt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Vt.prim,schema:Vt.prim}}findAndReturnTokens(t,e){return Vt.prim===t&&e.push(this),e}}Vt.prim="bls12_381_g1";class jt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="Bls12381g2ValidationError"}}class $t extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new jt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[$t.prim]?e[$t.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:$t.prim,schema:$t.prim}}findAndReturnTokens(t,e){return $t.prim===t&&e.push(this),e}}$t.prim="bls12_381_g2";class zt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChestValidationError"}}class qt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new zt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[qt.prim]?e[qt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:qt.prim,schema:qt.prim}}findAndReturnTokens(t,e){return qt.prim===t&&e.push(this),e}}qt.prim="chest";class Wt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="ChestKeyValidationError"}}class Zt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}validate(t){if(!/^[0-9a-fA-F]*$/.test(t)||t.length%2!=0)throw new Wt(t,this,`Invalid bytes: ${JSON.stringify(t)}`)}convertUint8ArrayToHexString(t){return t.constructor===Uint8Array?(0,T.buf2hex)(t):t}Encode(t){let e=t.pop();return e=this.convertUint8ArrayToHexString(e),this.validate(e),{bytes:e}}EncodeObject(t,e){return t=this.convertUint8ArrayToHexString(t),this.validate(t),e&&e[Zt.prim]?e[Zt.prim](t):{bytes:t}}Execute(t){return t.bytes}generateSchema(){return{__michelsonType:Zt.prim,schema:Zt.prim}}findAndReturnTokens(t,e){return Zt.prim===t&&e.push(this),e}}Zt.prim="chest_key";class Yt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="GlobalConstantEncodingError"}}class Xt extends k{constructor(t,e,r){super(t,e,r),this.value=t,this.token=e,this.name="GlobalConstantDecodingError"}}class Jt extends L{constructor(t,e,r){super(t,e,r),this.val=t,this.idx=e,this.fac=r}Execute(t,e){if(e&&e[Jt.prim])return e[Jt.prim](t,this.val);throw new Xt(t,this,`Unable to decode a value represented by a global constants. Please provide an expanded script to the Michelson-Encoder or semantics for the decoding. The following global constant hash was encountered: ${this.val.args[0].string}.`)}Encode(t){throw new Yt(t,this,`Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0].string}.`)}EncodeObject(t,e){if(e&&e[Jt.prim])return e[Jt.prim](t);throw new Yt(t,this,`Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0].string}.`)}generateSchema(){return{__michelsonType:Jt.prim,schema:{hash:this.val.args[0].string}}}findAndReturnTokens(t,e){return Jt.prim===t&&e.push(this),e}}Jt.prim="constant";const Qt=[G,j,$,B,q,Z,Y,U,J,tt,rt,it,st,ot,ct,ht,dt,gt,yt,bt,vt,Et,At,Pt,Nt,Lt,Mt,Dt,Kt,Ft,Vt,$t,qt,Zt,Jt];class te extends s.TaquitoError{constructor(t,e){super(t),this.message=t,this.data=e,this.name="Invalid token error"}}function ee(t,e,r){if(Array.isArray(t))return new G(t,e,ee,r);const n=Qt.find(e=>e.prim===t.prim);if(!n)throw new te(`Malformed data: ${JSON.stringify(t)}. Expected a value with a valid prim property`,t);return new n(t,e,ee,r)}class re extends s.InvalidViewParameterError{constructor(t,e,r,n){super(t,e,r,n),this.viewName=t,this.sigs=e,this.args=r,this.cause=n,this.name="ParameterEncodingError",this.message=`Could not encode parameter ${JSON.stringify(r)} received for name "${t}" expecting one of the following signatures ${JSON.stringify(e)}`}}class ne extends s.TaquitoError{constructor(t,e){super(),this.script=t,this.reason=e,this.name="InvalidScriptError";let r="Invalid on-chain view found in the following script.";e&&(r+=` Reason: ${e}.`),r+=`Script: ${JSON.stringify(t)}`,this.message=r}}class ie extends s.TaquitoError{constructor(t,e){super(),this.script=t,this.reason=e,this.name="InvalidRpcResponseError";let r="Invalid RPC response passed as argument(s).";e&&(r+=` Reason: ${e}.`),r+=` Received: ${JSON.stringify(t)}`,this.message=r}}class se extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="InvalidBigMapSchemaError"}}class oe extends s.TaquitoError{constructor(t,e){super(t),this.message=t,this.value=e,this.name="InvalidBigMapDiffError"}}class ae extends s.TaquitoError{constructor(t,e,r,n){super(),this.details=e,this.schema=r,this.value=n,this.name="BigMapEncodingError",this.message=`Unable to encode the big map ${t}. Schema is: ${JSON.stringify(r)}. The ${t} is: ${JSON.stringify(n)}. Error details: ${e}`}}class ce extends s.TaquitoError{constructor(t,e,r,n,i){super(),this.details=e,this.schema=r,this.value=n,this.semantics=i,this.name="StorageEncodingError",this.message=`Unable to encode ${t}. The schema is: ${JSON.stringify(r)}, the value is: ${JSON.stringify(n)}.${i?`And the semantic is: ${JSON.stringify(i)}`:""}. Error details: ${e}`}}class ue extends s.TaquitoError{constructor(t){super(t),this.message=t,this.name="MissingArgumentError"}}var le;const he=Symbol.for("taquito-schema-type-symbol");function fe(t,e=G.prim){if(Array.isArray(t))return fe({prim:e,args:t},e);const r=t;return r.prim===e&&r.args&&r.args.length>2?{...r,args:[r.args?.[0],{prim:e,args:r.args?.slice(1)}]}:r}function de(t,e){if(void 0===t||void 0===e)return t===e;const r=fe(t),n=fe(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((t,e)=>de(t,n.args?.[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((t,e)=>t===n.annots?.[e]))}class pe{static isSchema(t){return t&&!0===t[he]}static fromRPCResponse(t){if(!t)throw new ie(t,"the RPC response is empty");if(!t.script)throw new ie(t,"the RPC response has no script");if(!Array.isArray(t.script.code))throw new ie(t,"The response.script.code should be an array");let e=t.script.code;for(;1===e.length&&Array.isArray(e[0]);)e=e[0];const r=e.find(t=>"prim"in t&&"storage"===t.prim);if(!r||!Array.isArray(r.args))throw new ie(t,'The response.script.code has an element of type {prim: "storage"}, but its args is not an array');return new pe(r.args[0])}isExpressionExtended(t){return"prim"in t&&Array.isArray(t.args)}constructor(t){if(this.val=t,this[le]=!0,this.root=ee(t,0),this.root instanceof B)this.bigMap=this.root;else if(this.isExpressionExtended(t)&&"pair"===t.prim){const e=t.args[0];this.isExpressionExtended(e)&&"big_map"===e.prim&&(this.bigMap=new B(e,0,ee))}}removeTopLevelAnnotation(t){return(this.root instanceof G||this.root instanceof U)&&this.root.hasAnnotations()&&"object"==typeof t&&1===Object.keys(t).length?t[Object.keys(t)[0]]:t}Execute(t,e){const r=this.root.Execute(t,e);return this.removeTopLevelAnnotation(r)}Typecheck(t){if(this.root instanceof B&&Number.isInteger(Number(t)))return!0;if(this.root instanceof Pt&&t.ticketer&&t.value&&t.amount)return!0;if(this.root instanceof Nt&&t.ticketer&&t.value&&t.amount)return!0;if(this.root instanceof Z&&this.root.ValueSchema instanceof B)return!0;try{return this.root.EncodeObject(t),!0}catch(t){return!1}}ExecuteOnBigMapDiff(t,e){if(!this.bigMap)throw new se("Big map schema is undefined");if(!Array.isArray(t))throw new oe(`Big map diff must be an array, got: ${JSON.stringify(t)}`,t);const r=t.map(({key:t,value:e})=>({args:[t,e]}));return this.bigMap.Execute(r,e)}ExecuteOnBigMapValue(t,e){if(!this.bigMap)throw new se("Big map schema is undefined");return this.bigMap.ValueSchema.Execute(t,e)}EncodeBigMapKey(t){if(!this.bigMap)throw new se("Big map schema is undefined");try{return this.bigMap.KeySchema.ToBigMapKey(t)}catch(e){throw new ae("key",e,this.bigMap.KeySchema,t)}}Encode(t,e){try{return this.root.EncodeObject(t,e)}catch(r){if(r instanceof k)throw r;throw new ce("storage object",r,this.root,t,e)}}generateSchema(){return this.removeTopLevelAnnotation(this.root.generateSchema())}FindFirstInTopLevelPair(t,e){return this.findValue(this.root.val,t,e)}findValue(t,e,r){if(de(r,t))return e;if(Array.isArray(t)||"pair"===t.prim){const n=fe(t),i=fe(e,"Pair");if(void 0===n.args||void 0===i.args)throw new ue("Tokens have no arguments");if(n.args[0])return this.findValue(n.args[0],i.args[0],r)||this.findValue(n.args[1],i.args[1],r)}}findToken(t){return this.root.findAndReturnTokens(t,[])}}le=he;class ge{static fromRPCResponse(t){if(!t)throw new ie(t,"the RPC response is empty");if(!t.script)throw new ie(t,"the RPC response has no script");if(!Array.isArray(t.script.code))throw new ie(t,"The response.script.code should be an array");const e=t.script.code.find(t=>"prim"in t&&"parameter"===t.prim);if(!e)throw new ie(t,'The response.script.code should have an element of type {prim: "parameter"}');if(!Array.isArray(e.args))throw new ie(t,'The response.script.code has an element of type {prim: "parameter"}, but its args is not an array');return new ge(e.args[0])}get isMultipleEntryPoint(){return this.root instanceof U||this.root instanceof st&&this.root.subToken()instanceof U}get hasAnnotation(){return!this.isMultipleEntryPoint||"0"!==Object.keys(this.generateSchema())[0]}constructor(t){this.root=ee(t,0)}Execute(t,e){return this.root.Execute(t,e)}Encode(...t){try{return this.root.Encode(t.reverse())}catch(e){if(e instanceof k)throw e;throw new re("Unable to encode parameter",this.root,t,e)}}EncodeObject(t,e){try{return this.root.EncodeObject(t,e)}catch(e){if(e instanceof k)throw e;throw new re("Unable to encode parameter object",this.root,t,e)}}generateSchema(){return this.root.generateSchema()}ExtractSignatures(){return this.root.ExtractSignature()}}class me{static fromRPCResponse(t){const e=[],r=t&&t.script&&Array.isArray(t.script.code)&&t.script.code.filter(t=>"view"===t.prim);return r&&r.forEach(t=>{e.push(new me(t.args))}),e}constructor(t){if(!t)throw new ne(t,"the args are not defined");if(4!==t.length)throw new ne(t,"there should be exactly 4 arguments");if(!("string"in t[0])||!t[0].string)throw new ne(t,"The first argument should be a string, representing the view name. It should be in the form: { string: 'viewName' }");this.viewName=t[0].string,this.viewArgsType=t[1],this.viewReturnType=t[2],this.instructions=t[3],this.rootArgsType=ee(this.viewArgsType,0),this.rootReturnType=ee(this.viewReturnType,0)}encodeViewArgs(t){try{return this.rootArgsType.EncodeObject(t)}catch(e){throw new re(this.viewName,void 0,t,e)}}decodeViewResult(t,e){return this.rootReturnType.Execute(t,e)}extractArgsSchema(){return this.rootArgsType.generateSchema()}extractResultSchema(){return this.rootReturnType.generateSchema()}}class ye{constructor(t,e){this.tag=t,this.type=e}static fromMichelineValue(t){return new ye(t.annots?.[0],t.args?.[0])}static fromRPCResponse(t){const e=[];return t.script.code.forEach(t=>{"prim"in t&&"code"===t.prim&&"args"in t&&t.args&&e.push(...ye.extractEventsRecursively(t.args))}),ye.removeDuplicates(e)}static removeDuplicates(t){const e=[];return t.forEach(t=>{-1===e.findIndex(e=>e.tag===t.tag&&de(e.type,t.type))&&e.push(t)}),e}static extractEventsRecursively(t){return Array.isArray(t)?t.flatMap(t=>ye.extractEventsRecursively(t)):"prim"in t?"EMIT"===t.prim?[ye.fromMichelineValue(t)]:"args"in t&&t.args?t.args.flatMap(t=>ye.extractEventsRecursively(t)):[]:[]}}const be={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"}},3157(t,e,r){"use strict";r.r(e),r.d(e,{METADATA_BALANCE_UPDATES_CATEGORY:()=>N,OPERATION_METADATA:()=>I,OpKind:()=>K,PvmKind:()=>k,RpcClient:()=>F,RpcClientCache:()=>x,SmartRollupInputProofKind:()=>C,SmartRollupRefutationOptions:()=>L,SmartRollupRefuteGameEndedPlayerOutcomes:()=>D,SmartRollupRefuteGameEndedReason:()=>U,SmartRollupRefuteGameStatusOptions:()=>B,SmartRollupRefuteRevealProofKind:()=>M,VERSION:()=>H,castToBigNumber:()=>R,defaultChain:()=>S,defaultRPCOptions:()=>T});var n=r(2211),i=function t(e){var r,n,i,_=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,o,a,u,h,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>x?g.c=g.e=null:(g.e=u,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!s.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(c+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(u=d.indexOf("."))>-1&&(d=d.replace(".","")),(h=d.search(/e/i))>0?(u<0&&(u=h),u+=+d.slice(h+1),d=d.substring(0,h)):u<0&&(u=d.length)}else{if("string"!=p)throw Error(c+"String expected: "+t);for(b(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),u=h=0,f=d.length;h<f;h++)if(r.indexOf(o=d.charAt(h))<0){if("."==o){if(h>u){u=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,h=-1,u=0;continue}return i(g,t,e)}(u=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):u=d.length}for(h=0;48===d.charCodeAt(h);h++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(h,++f))if(f-=h,(u=u-h-1)>x)g.c=g.e=null;else if(u<R)g.c=[g.e=0];else{if(g.e=u,g.c=[],h=(u+1)%l,u<0&&(h+=l),h<f){for(h&&g.c.push(+d.slice(0,h)),f-=l;h<f;)g.c.push(+d.slice(h,h+=l));h=l-(d=d.slice(h)).length}else h-=f;for(;h--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:b(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=m(t.c),c=1==n||2==n&&(o<=T||o>=P)?w(c,o):E(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=m(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=w(c,s)}else if(e-=o+(2===n&&s>o),c=E(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=y(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*l-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,c,h,d,p,g,m=t.c,y=f;if(m){t:{for(i=1,h=m[0];h>=10;h/=10,i++);if((s=e-i)<0)s+=l,c=e,d=m[p=0],g=a(d/y[i-c-1]%10);else if((p=o((s+1)/l))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));d=g=0,i=1,c=(s%=l)-l+1}else{for(d=h=m[p],i=1;h>=10;h/=10,i++);g=(c=(s%=l)-l+i)<0?0:a(d/y[i-c-1]%10)}if(n=n||e<0||null!=m[p+1]||(c<0?d:d%y[i-c-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?c>0?d/y[i-c]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(l-e%l)%l],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,h=1,p--):(m.length=p+1,h=y[l-s],m[p]=c>0?a(d/y[i-c]%y[c])*h:0),n)for(;;){if(0==p){for(s=1,c=m[0];c>=10;c/=10,s++);for(c=m[0]+=h,h=1;c>=10;c/=10,h++);s!=h&&(t.e++,m[0]==u&&(m[0]=1));break}if(m[p]+=h,m[p]!=u)break;m[p--]=0,h=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=T||r>=P?w(e,r):E(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(c+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(b(r=t[e],0,p,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(b(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(b(r[0],-p,0,e),b(r[1],0,p,e),T=r[0],P=r[1]):(b(r,-p,p,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)b(r[0],-p,-1,e),b(r[1],1,p,e),R=r[0],x=r[1];else{if(b(r,-p,p,e),!r)throw Error(c+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(c+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(c+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(b(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(b(r=t[e],0,p,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(c+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(c+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-p||i>p||i!==a(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%l)<1&&(e+=l),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=u||r!==a(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return a(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,u,h=0,d=[],g=new M(A);if(null==t?t=O:b(t,0,p),s=o(t/l),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));h<s;)(u=131072*r[h]+(r[h+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[h]=n[0],r[h+1]=n[1]):(d.push(u%1e14),h+=2);h=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(c+"crypto unavailable");for(r=crypto.randomBytes(s*=7);h<s;)(u=281474976710656*(31&r[h])+1099511627776*r[h+1]+4294967296*r[h+2]+16777216*r[h+3]+(r[h+4]<<16)+(r[h+5]<<8)+r[h+6])>=9e15?crypto.randomBytes(7).copy(r,h):(d.push(u%1e14),h+=7);h=s/7}if(!I)for(;h<s;)(u=e())<9e15&&(d[h++]=u%1e14);for(s=d[--h],t%=l,s&&t&&(u=f[l-t],d[h]=a(s/u)*u);0===d[h];d.pop(),h--);if(h<0)d=[i=0];else{for(i=-1;0===d[0];d.splice(0,1),i-=l);for(h=1,u=d[0];u>=10;u/=10,h++);h<l&&(i-=l-h)}return g.e=i,g.c=d,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,y=n.indexOf("."),b=O,v=S;for(y>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-y),k=h,g.c=e(E(m(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),y=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=y||f)&&(0==v||v==(d.s<0?3:2)):y>h||y==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?E(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=E(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%d,l=e/d|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%d)+(n=l*s+(o=t[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,c){var h,f,d,p,m,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,c||(c=u,f=g(n.e/l)-g(i.e/l),x=x/l|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(m=a(c/(N[0]+1)))>1&&(N=t(N,m,c),I=t(I,m,c),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=c/2&&T++;do{if(m=0,(h=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*c+(E[1]||0)),(m=a(A/T))>1)for(m>=c&&(m=c-1),b=(y=t(N,m,c)).length,_=E.length;1==e(y,E,b,_);)m--,r(y,P<b?R:N,b,c),b=y.length,h=1;else 0==m&&(h=m=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,c),_=E.length,-1==h)for(;e(N,E,P,_)<1;)m++,r(E,P<_?R:N,_,c),_=E.length}else 0===h&&(m++,E=[0]);w[d++]=m,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(c==u){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*l-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var u,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return u="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=u?t:e}),a&&(u=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,u);throw Error(c+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),_.absoluteValue=_.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return y(this,new M(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,s=this;if(null!=t)return b(t,0,p),null==e?e=S:b(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-g(this.e/l))*l,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new M(t,e),O,S)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new M(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,s,u,h,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(c+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),u=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),u?t.s*(2-v(t)):+F(t))),e?d.mod(e):d;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||u&&p.c[1]>=24e7:p.c[0]<8e13||u&&p.c[0]<=9999975e7)))return s=p.s<0&&v(t)?-0:0,p.e>-1&&(s=1/s),new M(h?1/s:s);k&&(s=o(k/l+2))}for(u?(r=new M(.5),h&&(t.s=1),f=v(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=a(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=v(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(h&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},_.integerValue=function(t){var e=new M(this);return null==t?t=S:b(t,0,8),H(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===y(this,new M(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return y(this,new M(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=y(this,new M(t,e)))||0===e},_.isInteger=function(){return!!this.c&&g(this.e/l)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return y(this,new M(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=y(this,new M(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/l,h=t.e/l,f=o.c,d=t.c;if(!c||!h){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=g(c),h=g(h),f=f.slice(),a=c-h){for((s=a<0)?(a=-a,i=f):(h=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=u-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=u}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--h);return f[0]?K(t,f,h):(t.s=3==S?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,s,o,a,c,h,f,p,m,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=g(E.e/l)+g(t.e/l),t.s*=E.s,(c=_.length)<(p=A.length)&&(b=_,_=A,A=b,i=c,c=p,p=i),i=c+p,b=[];i--;b.push(0));for(v=u,w=d,i=p;--i>=0;){for(r=0,m=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((h=m*(h=_[--o]%w)+(a=y*h+(f=_[o]/w|0)*m)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=h%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},_.negated=function(){var t=new M(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/l,o=t.e/l,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=g(s),o=g(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/u|0,a[e]=u===a[e]?0:a[e]%u;return i&&(a=[i].concat(a),++o),K(t,a,o)},_.precision=_.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return b(t,1,p),null==e?e=S:b(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*l+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},_.shiftedBy=function(t){return b(t,-9007199254740991,h),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=m(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=g((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),m(s.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},_.toExponential=function(t,e){return null!=t&&(b(t,0,p),t++),B(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(b(t,0,p),t=t+this.e+1),B(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(c+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,u=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(u&&(s=a,a=u,u=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);u>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,s,o,a,u,h,d,p,g,y,b=this,v=b.c;if(null!=t&&(!(u=new M(t)).isInteger()&&(u.c||1!==u.s)||u.lt(A)))throw Error(c+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+F(u));if(!v)return new M(b);for(e=new M(A),d=n=new M(A),i=h=new M(A),y=m(v),o=e.e=y.length-b.e-1,e.c[0]=f[(a=o%l)<0?l+a:a],t=!t||u.comparedTo(e)>0?o>0?e:d:u,a=x,x=1/0,u=new M(y),h.c[0]=0;p=r(u,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,d=h.plus(p.times(s=d)),h=s,e=u.minus(p.times(s=e)),u=s;return s=r(t.minus(n),i,0,1),h=h.plus(s.times(d)),n=n.plus(s.times(i)),h.s=d.s=b.s,g=r(d,i,o*=2,S).minus(b).abs().comparedTo(r(h,n,o,S).minus(b).abs())<1?[d,i]:[h,n],x=a,g},_.toNumber=function(){return+F(this)},_.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},_.toPrecision=function(t,e){return null!=t&&b(t,1,p),B(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?w(m(r.c),s):E(m(r.c),s,"0"):(b(t,2,C.length,"Base"),e=n(E(m(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return F(this)},_._isBigNumber=!0,null!=e&&M.set(e);return M}(),s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,a=Math.floor,c="[BigNumber Error] ",u=1e14,l=14,h=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,p=1e9;function g(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=l-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function y(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(t,e,r,n){if(t<e||t>r||t!==a(t))throw Error(c+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function v(t){var e=t.c.length-1;return g(t.e/l)==e&&t.c[e]%2!=0}function w(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function E(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const _=i;var A=r(2403),O=r(6571);const S="main",T={block:"head"};var P;function R(t,e){const r=Array.isArray(t);void 0===e&&(e=Object.keys(t));const n=r?[]:{};return e.forEach(e=>{const r=t[e];let i;if(void 0!==r){if(Array.isArray(r))return i=R(r),void(n[e]=i);i=new _(r),n[e]=i}}),n}!function(t){t.GET_BAKING_RIGHTS="getBakingRights",t.GET_BALLOTS="getBallots",t.GET_BALLOT_LIST="getBallotList",t.GET_BIG_MAP_EXPR="getBigMapExpr",t.GET_BLOCK_HASH="getBlockHash",t.GET_BLOCK="getBlock",t.GET_BLOCK_HEADER="getBlockHeader",t.GET_BLOCK_METADATA="getBlockMetadata",t.GET_BALANCE="getBalance",t.GET_SPENDABLE="getSpendable",t.GET_BALANCE_AND_FROZEN_BONDS="getBalanceAndFrozenBonds",t.GET_SPENDABLE_AND_FROZEN_BONDS="getSpendableAndFrozenBonds",t.GET_FULL_BALANCE="getFullBalance",t.GET_STAKED_BALANCE="getStakedBalance",t.GET_UNSTAKED_FINALIZABLE_BALANCE="getUnstakedFinalizableBalance",t.GET_UNSTAKED_FROZEN_BALANCE="getUnstakedFrozenBalance",t.GET_UNSTAKE_REQUESTS="getUnstakeRequests",t.GET_CHAIN_ID="getChainId",t.GET_CONSTANTS="getConstants",t.GET_CONTRACT="getContract",t.GET_CURRENT_PERIOD="getCurrentPeriod",t.GET_CURRENT_PROPOSAL="getCurrentProposal",t.GET_CURRENT_QUORUM="getCurrentQuorum",t.GET_DELEGATE="getDelegate",t.GET_ALL_DELEGATES="getAllDelegates",t.GET_DELEGATES="getDelegates",t.GET_VOTING_INFO="getVotingInfo",t.GET_ACTIVE_STAKING_PARAMETERS="getActiveStakingParameters",t.GET_PENDING_STAKING_PARAMETERS="getPendingStakingParameters",t.GET_ATTESTATION_RIGHTS="getAttestationRights",t.GET_ENTRYPOINTS="getEntrypoints",t.GET_LIVE_BLOCKS="getLiveBlocks",t.GET_MANAGER_KEY="getManagerKey",t.GET_NORMALIZED_SCRIPT="getNormalizedScript",t.GET_PROPOSALS="getProposals",t.GET_PROTOCOLS="getProtocols",t.GET_SAPLING_DIFF_BY_CONTRACT="getSaplingDiffByContract",t.GET_PROTOCOL_ACTIVATIONS="getProtocolActivations",t.GET_SAPLING_DIFF_BY_ID="getSaplingDiffById",t.GET_SCRIPT="getScript",t.GET_STORAGE="getStorage",t.GET_SUCCESSOR_PERIOD="getSuccessorPeriod",t.GET_VOTES_LISTINGS="getVotesListings",t.PACK_DATA="packData",t.GET_STORAGE_USED_SPACE="getStorageUsedSpace",t.GET_STORAGE_PAID_SPACE="getStoragePaidSpace",t.GET_TICKET_BALANCE="getTicketBalance",t.GET_ALL_TICKET_BALANCES="getAllTicketBalances",t.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE="getAdaptiveIssuanceLaunchCycle",t.GET_PENDING_OPERATIONS="getPendingOperations",t.GET_MEMPOOL_FILTER="getMempoolFilter",t.GET_DESTINATION_INDEX="getDestinationIndex"}(P||(P={}));class x{constructor(t,e=1e3){this.rpcClient=t,this.ttl=e,this._cache={}}getAllCachedData(){return this._cache}deleteAllCachedData(){for(const t in this._cache)delete this._cache[t]}formatCacheKey(t,e,r,n){let i="";return r.forEach(t=>{i="object"==typeof t?i+JSON.stringify(t)+"/":i+t+"/"}),n?`${t}/${e}/${i}${JSON.stringify(n)}/`:`${t}/${e}/${i}`}has(t){return t in this._cache}get(t){return this._cache[t].response}put(t,e){const r=setTimeout(()=>this.remove(t),this.ttl);Object.assign(this._cache,{[t]:{handle:r,response:e}})}remove(t){t in this._cache&&delete this._cache[t]}validateAddress(t){const e=(0,A.validateAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidAddressError(t,e)}validateContract(t){const e=(0,A.validateContractAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidContractAddressError(t,e)}async getBlockHash({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_HASH,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockHash({block:t});return this.put(e,r),r}}async getLiveBlocks({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_LIVE_BLOCKS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getLiveBlocks({block:t});return this.put(e,r),r}}async getBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBalance(t,{block:e});return this.put(r,n),n}}async getSpendable(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SPENDABLE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSpendable(t,{block:e});return this.put(r,n),n}}async getBalanceAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALANCE_AND_FROZEN_BONDS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBalanceAndFrozenBonds(t,{block:e});return this.put(r,n),n}}async getSpendableAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SPENDABLE_AND_FROZEN_BONDS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSpendableAndFrozenBonds(t,{block:e});return this.put(r,n),n}}async getFullBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_FULL_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getFullBalance(t,{block:e});return this.put(r,n),n}}async getStakedBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STAKED_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStakedBalance(t,{block:e});return this.put(r,n),n}}async getUnstakedFinalizableBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKED_FINALIZABLE_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakedFinalizableBalance(t,{block:e});return this.put(r,n),n}}async getUnstakedFrozenBalance(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKED_FROZEN_BALANCE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakedFrozenBalance(t,{block:e});return this.put(r,n),n}}async getUnstakeRequests(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_UNSTAKE_REQUESTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getUnstakeRequests(t,{block:e});return this.put(r,n),n}}async getStorage(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStorage(t,{block:e});return this.put(r,n),n}}async getScript(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SCRIPT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getScript(t,{block:e});return this.put(r,n),n}}async getNormalizedScript(t,e={unparsing_mode:"Readable"},{block:r}=T){this.validateContract(t);const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_NORMALIZED_SCRIPT,[r,t],e);if(this.has(n))return this.get(n);{const i=this.rpcClient.getNormalizedScript(t,e,{block:r});return this.put(n,i),i}}async getContract(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CONTRACT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getContract(t,{block:e});return this.put(r,n),n}}async getManagerKey(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_MANAGER_KEY,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getManagerKey(t,{block:e});return this.put(r,n),n}}async getDelegate(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DELEGATE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDelegate(t,{block:e});return this.put(r,n),n}}async getBigMapExpr(t,e,{block:r}=T){const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BIG_MAP_EXPR,[r,t,e]);if(this.has(n))return this.get(n);{const i=this.rpcClient.getBigMapExpr(t,e,{block:r});return this.put(n,i),i}}async getAllDelegates(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ALL_DELEGATES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAllDelegates(t,{block:e});return this.put(r,n),n}}async getDelegates(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DELEGATES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDelegates(t,{block:e});return this.put(r,n),n}}async getVotingInfo(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_VOTING_INFO,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getVotingInfo(t,{block:e});return this.put(r,n),n}}async getConstants({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CONSTANTS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getConstants({block:t});return this.put(e,r),r}}async getBlock({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlock({block:t});return this.put(e,r),r}}async getBlockHeader({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_HEADER,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockHeader({block:t});return this.put(e,r),r}}async getBlockMetadata({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BLOCK_METADATA,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBlockMetadata({block:t});return this.put(e,r),r}}async getBakingRights(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BAKING_RIGHTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getBakingRights(t,{block:e});return this.put(r,n),n}}async getAttestationRights(t={},{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ATTESTATION_RIGHTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAttestationRights(t,{block:e});return this.put(r,n),n}}async getBallotList({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALLOT_LIST,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBallotList({block:t});return this.put(e,r),r}}async getBallots({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_BALLOTS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getBallots({block:t});return this.put(e,r),r}}async getCurrentProposal({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_PROPOSAL,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentProposal({block:t});return this.put(e,r),r}}async getCurrentQuorum({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_QUORUM,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentQuorum({block:t});return this.put(e,r),r}}async getVotesListings({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_VOTES_LISTINGS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getVotesListings({block:t});return this.put(e,r),r}}async getProposals({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROPOSALS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProposals({block:t});return this.put(e,r),r}}async forgeOperations(t,{block:e}=T){return this.rpcClient.forgeOperations(t,{block:e})}async injectOperation(t){return this.rpcClient.injectOperation(t)}async preapplyOperations(t,{block:e}=T){return this.rpcClient.preapplyOperations(t,{block:e})}async getEntrypoints(t,{block:e}=T){this.validateContract(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ENTRYPOINTS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getEntrypoints(t,{block:e});return this.put(r,n),n}}async simulateOperation(t,{block:e}=T){return this.rpcClient.simulateOperation(t,{block:e})}async runCode(t,{block:e}=T){return this.rpcClient.runCode(t,{block:e})}async runScriptView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.rpcClient.runScriptView({unparsing_mode:t,...e},{block:r})}async runView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.rpcClient.runView({unparsing_mode:t,...e},{block:r})}async getChainId(){const t=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CHAIN_ID,[]);if(this.has(t))return this.get(t);{const e=this.rpcClient.getChainId();return this.put(t,e),e}}async packData(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.PACK_DATA,[e],t);if(this.has(r))return this.get(r);{const n=this.rpcClient.packData(t,{block:e});return this.put(r,n),n}}getRpcUrl(){return this.rpcClient.getRpcUrl()}async getCurrentPeriod({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_CURRENT_PERIOD,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getCurrentPeriod({block:t});return this.put(e,r),r}}async getSuccessorPeriod({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SUCCESSOR_PERIOD,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getSuccessorPeriod({block:t});return this.put(e,r),r}}async getSaplingDiffById(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SAPLING_DIFF_BY_ID,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSaplingDiffById(t,{block:e});return this.put(r,n),n}}async getSaplingDiffByContract(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_SAPLING_DIFF_BY_CONTRACT,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getSaplingDiffByContract(t,{block:e});return this.put(r,n),n}}async getProtocols({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROTOCOLS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProtocols({block:t});return this.put(e,r),r}}async getProtocolActivations(t=""){if(t){const e=(0,A.validateProtocol)(t);if(e!==A.ValidationResult.VALID)throw new A.InvalidProtocolHashError(t,e)}const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PROTOCOL_ACTIVATIONS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getProtocolActivations(t);return this.put(e,r),r}}async getStorageUsedSpace(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE_USED_SPACE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStorageUsedSpace(t,{block:e});return this.put(r,n),n}}async getStoragePaidSpace(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_STORAGE_PAID_SPACE,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getStoragePaidSpace(t,{block:e});return this.put(r,n),n}}async getTicketBalance(t,e,{block:r}=T){const n=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_TICKET_BALANCE,[r,t],e);if(this.has(n))return this.get(n);{const i=this.rpcClient.getTicketBalance(t,e,{block:r});return this.put(n,i),i}}async getAllTicketBalances(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ALL_TICKET_BALANCES,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getAllTicketBalances(t,{block:e});return this.put(r,n),n}}async getAdaptiveIssuanceLaunchCycle({block:t}=T){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ADAPTIVE_ISSUANCE_LAUNCH_CYCLE,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getAdaptiveIssuanceLaunchCycle({block:t});return this.put(e,r),r}}async getPendingOperations(t={}){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PENDING_OPERATIONS,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getPendingOperations(t);return this.put(e,r),r}}async getMempoolFilter(t={}){const e=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_MEMPOOL_FILTER,[t]);if(this.has(e))return this.get(e);{const r=this.rpcClient.getMempoolFilter(t);return this.put(e,r),r}}async getActiveStakingParameters(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_ACTIVE_STAKING_PARAMETERS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getActiveStakingParameters(t,{block:e});return this.put(r,n),n}}async getPendingStakingParameters(t,{block:e}=T){this.validateAddress(t);const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_PENDING_STAKING_PARAMETERS,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getPendingStakingParameters(t,{block:e});return this.put(r,n),n}}async getDestinationIndex(t,{block:e}=T){const r=this.formatCacheKey(this.rpcClient.getRpcUrl(),P.GET_DESTINATION_INDEX,[e,t]);if(this.has(r))return this.get(r);{const n=this.rpcClient.getDestinationIndex(t,{block:e});return this.put(r,n),n}}}var I,N,k,L,C,M,B,D,U,K;!function(t){t.TOO_LARGE="too large"}(I||(I={})),function(t){t.ACTIVATION="activation",t.ATTESTATION="attestation",t.ATTESTATIONS_AGGREGATE="attestations_aggregate",t.ATTESTATION_WITH_DAL="attestation_with_dal",t.ATTESTING_REWARDS="attesting rewards",t.BAKING_BONUSES="baking bonuses",t.BAKING_REWARDS="baking rewards",t.BALLOT="ballot",t.BLOCK_FEES="block fees",t.BONDS="bonds",t.BOOTSTRAP="bootstrap",t.BURNED="burned",t.COMMITMENT="commitment",t.DAL_ATTESTING_REWARDS="dal attesting rewards",t.DAL_ENTRAPMENT_EVIDENCE="dal_entrapment_evidence",t.DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.DELEGATE_DENOMINATOR="delegate_denominator",t.DELEGATION="delegation",t.DELEGATOR_NUMERATOR="delegator_numerator",t.DEPOSITS="deposits",t.DOUBLE_ATTESTATION_EVIDENCE="double_attestation_evidence",t.DOUBLE_BAKING_EVIDENCE="double_baking_evidence",t.DOUBLE_ENDORSEMENT_EVIDENCE="double_endorsement_evidence",t.DOUBLE_PREATTESTATION_EVIDENCE="double_preattestation_evidence",t.DOUBLE_PREENDORSEMENT_EVIDENCE="double_preendorsement_evidence",t.DRAIN_DELEGATE="drain_delegate",t.ENDORSEMENT="endorsement",t.ENDORSEMENT_WITH_DAL="endorsement_with_dal",t.EVENT="event",t.FAILING_NOOP="failing_noop",t.INCREASE_PAID_STORAGE="increase_paid_storage",t.INVOICE="invoice",t.LOST_ATTESTING_REWARDS="lost attesting rewards",t.LOST_DAL_ATTESTING_REWARDS="lost dal attesting rewards",t.MINTED="minted",t.NONCE_REVELATION_REWARDS="nonce revelation rewards",t.ORIGINATION="origination",t.PREATTESTATION="preattestation",t.PREATTESTATIONS_AGGREGATE="preattestations_aggregate",t.PREENDORSEMENT="preendorsement",t.PROPOSALS="proposals",t.PUNISHMENTS="punishments",t.REGISTER_GLOBAL_CONSTANT="register_global_constant",t.REVEAL="reveal",t.SEED_NONCE_REVELATION="seed_nonce_revelation",t.SET_DEPOSITS_LIMIT="set_deposits_limit",t.SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.SMART_ROLLUP_CEMENT="smart_rollup_cement",t.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.SMART_ROLLUP_PUBLISH="smart_rollup_publish",t.SMART_ROLLUP_RECOVER_BOND="smart_rollup_recover_bond",t.SMART_ROLLUP_REFUTATION_PUNISHMENTS="smart_rollup_refutation_punishments",t.SMART_ROLLUP_REFUTATION_REWARDS="smart_rollup_refutation_rewards",t.SMART_ROLLUP_REFUTE="smart_rollup_refute",t.SMART_ROLLUP_TIMEOUT="smart_rollup_timeout",t.STORAGE_FEES="storage fees",t.SUBSIDY="subsidy",t.TICKET_UPDATES="ticket_updates",t.TRANSACTION="transaction",t.TRANSFER_TICKET="transfer_ticket",t.UNSTAKED_DEPOSITS="unstaked_deposits",t.UPDATE_COMPANION_KEY="update_companion_key",t.UPDATE_CONSENSUS_KEY="update_consensus_key",t.VDF_REVELATION="vdf_revelation"}(N||(N={})),function(t){t.WASM2="wasm_2_0_0",t.ARITH="arith",t.RISCV="riscv"}(k||(k={})),function(t){t.START="start",t.MOVE="move"}(L||(L={})),function(t){t.INBOX_PROOF="inbox_proof",t.REVEAL_PROOF="reveal_proof",t.FIRST_INPUT="first_input"}(C||(C={})),function(t){t.RAW_DATA_PROOF="raw_data_proof",t.METADATA_PROOF="metadata_proof",t.DAL_PAGE_PROOF="dal_page_proof",t.DAL_PARAMETERS_PROOF="dal_parameters_proof"}(M||(M={})),function(t){t.ONGOING="ongoing",t.ENDED="ended"}(B||(B={})),function(t){t.LOSER="loser",t.DRAW="draw"}(D||(D={})),function(t){t.CONFLICT_RESOLVED="conflict_resolved",t.TIMEOUT="timeout"}(U||(U={})),function(t){t.ORIGINATION="origination",t.DELEGATION="delegation",t.REVEAL="reveal",t.TRANSACTION="transaction",t.ACTIVATION="activate_account",t.ATTESTATION="attestation",t.ENDORSEMENT="endorsement",t.PREATTESTATION="preattestation",t.PREENDORSEMENT="preendorsement",t.SET_DEPOSITS_LIMIT="set_deposits_limit",t.DOUBLE_PREATTESTATION_EVIDENCE="double_preattestation_evidence",t.DOUBLE_PREENDORSEMENT_EVIDENCE="double_preendorsement_evidence",t.ATTESTATION_WITH_DAL="attestation_with_dal",t.ENDORSEMENT_WITH_DAL="endorsement_with_dal",t.SEED_NONCE_REVELATION="seed_nonce_revelation",t.DOUBLE_ATTESTATION_EVIDENCE="double_attestation_evidence",t.DOUBLE_ENDORSEMENT_EVIDENCE="double_endorsement_evidence",t.DOUBLE_BAKING_EVIDENCE="double_baking_evidence",t.PROPOSALS="proposals",t.BALLOT="ballot",t.FAILING_NOOP="failing_noop",t.REGISTER_GLOBAL_CONSTANT="register_global_constant",t.TRANSFER_TICKET="transfer_ticket",t.INCREASE_PAID_STORAGE="increase_paid_storage",t.UPDATE_CONSENSUS_KEY="update_consensus_key",t.DRAIN_DELEGATE="drain_delegate",t.VDF_REVELATION="vdf_revelation",t.EVENT="event",t.TICKET_UPDATES="ticket_updates",t.SMART_ROLLUP_ORIGINATE="smart_rollup_originate",t.SMART_ROLLUP_ADD_MESSAGES="smart_rollup_add_messages",t.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE="smart_rollup_execute_outbox_message",t.SMART_ROLLUP_PUBLISH="smart_rollup_publish",t.SMART_ROLLUP_CEMENT="smart_rollup_cement",t.SMART_ROLLUP_RECOVER_BOND="smart_rollup_recover_bond",t.SMART_ROLLUP_REFUTE="smart_rollup_refute",t.SMART_ROLLUP_TIMEOUT="smart_rollup_timeout",t.DAL_PUBLISH_COMMITMENT="dal_publish_commitment",t.DAL_ENTRAPMENT_EVIDENCE="dal_entrapment_evidence",t.PREATTESTATIONS_AGGREGATE="preattestations_aggregate",t.ATTESTATIONS_AGGREGATE="attestations_aggregate",t.UPDATE_COMPANION_KEY="update_companion_key",t.DOUBLE_CONSENSUS_OPERATION_EVIDENCE="double_consensus_operation_evidence"}(K||(K={}));const H={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"};class F{constructor(t,e=S,r=new n.HttpBackend){this.url=t,this.chain=e,this.httpBackend=r}createURL(t){let e=this.url;for(;e.endsWith("/");)e=e.slice(0,-1);return`${e}${t}`}validateAddress(t){const e=(0,A.validateAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidAddressError(t,e)}validateContract(t){const e=(0,A.validateContractAddress)(t);if(e!==A.ValidationResult.VALID)throw new O.InvalidContractAddressError(t,e)}async getBlockHash({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/hash`),method:"GET"})}async getLiveBlocks({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/live_blocks`),method:"GET"})}async getBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/balance`),method:"GET"});return new _(r)}async getSpendable(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/spendable`),method:"GET"});return new _(r)}async getBalanceAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/balance_and_frozen_bonds`),method:"GET"});return new _(r)}async getSpendableAndFrozenBonds(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/spendable_and_frozen_bonds`),method:"GET"});return new _(r)}async getFullBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/full_balance`),method:"GET"});return new _(r)}async getStakedBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/staked_balance`),method:"GET"});return new _(r)}async getUnstakedFinalizableBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstaked_finalizable_balance`),method:"GET"});return new _(r)}async getUnstakedFrozenBalance(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstaked_frozen_balance`),method:"GET"});return new _(r)}async getUnstakeRequests(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/unstake_requests`),method:"GET"});return null===r?null:{finalizable:r.finalizable.map(({amount:t,...e})=>({...e,amount:R({amount:t},["amount"]).amount})),unfinalizable:{delegate:r.unfinalizable.delegate,requests:r.unfinalizable.requests.map(({amount:t,cycle:e})=>({cycle:e,amount:R({amount:t},["amount"]).amount}))}}}async getStorage(t,{block:e}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage`),method:"GET"})}async getScript(t,{block:e}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/script`),method:"GET"})}async getNormalizedScript(t,e={unparsing_mode:"Readable"},{block:r}=T){return this.validateContract(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/contracts/${t}/script/normalized`),method:"POST"},e)}async getContract(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}`),method:"GET"});return{...r,balance:new _(r.balance)}}async getManagerKey(t,{block:e}=T){return this.validateAddress(t),this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/manager_key`),method:"GET"})}async getDelegate(t,{block:e}=T){let r;this.validateAddress(t);try{r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/delegate`),method:"GET"})}catch(t){if(!(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND))throw t;r=null}return r}async getBigMapExpr(t,e,{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/big_maps/${t}/${e}`),method:"GET"})}async getAllDelegates(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates`),method:"GET",query:t})}async getDelegates(t,{block:e}=T){this.validateAddress(t);const r=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}`),method:"GET"}),n=R(r,["balance","full_balance","current_frozen_deposits","frozen_deposits","frozen_balance","frozen_deposits_limit","staking_balance","delegated_balance","voting_power","total_delegated_stake","staking_denominator"]);return r.frozen_balance_by_cycle?{...r,...n,frozen_balance_by_cycle:r.frozen_balance_by_cycle.map(({deposit:t,deposits:e,fees:r,rewards:n,...i})=>{const s=R({deposit:t,deposits:e,fees:r,rewards:n},["deposit","deposits","fees","rewards"]);return{...i,deposit:s.deposit,deposits:s.deposits,fees:s.fees,rewards:s.rewards}})}:{...r,...n}}async getVotingInfo(t,{block:e}=T){return this.validateAddress(t),await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/voting_info`),method:"GET"})}async getConstants({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/context/constants`),method:"GET"}),r=R(e,["time_between_blocks","hard_gas_limit_per_operation","hard_gas_limit_per_block","proof_of_work_threshold","tokens_per_roll","seed_nonce_revelation_tip","block_security_deposit","endorsement_security_deposit","block_reward","endorsement_reward","cost_per_byte","hard_storage_limit_per_operation","test_chain_duration","baking_reward_per_endorsement","delay_per_missing_endorsement","minimal_block_delay","liquidity_baking_subsidy","cache_layout","baking_reward_fixed_portion","baking_reward_bonus_per_slot","endorsing_reward_per_slot","double_baking_punishment","delay_increment_per_round","tx_rollup_commitment_bond","vdf_difficulty","sc_rollup_stake_amount","minimal_stake"]);return{...e,...r}}async getBlock({block:t,version:e}=T){const r={url:this.createURL(`/chains/${this.chain}/blocks/${t}`),method:"GET"};return void 0!==e&&(r.query={version:e}),await this.httpBackend.createRequest(r)}async getBlockHeader({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/header`),method:"GET"})}async getBlockMetadata({block:t,version:e}=T){const r={url:this.createURL(`/chains/${this.chain}/blocks/${t}/metadata`),method:"GET"};return void 0!==e&&(r.query={version:e}),await this.httpBackend.createRequest(r)}async getBakingRights(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/baking_rights`),method:"GET",query:t})}async getAttestationRights(t={},{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/attestation_rights`),method:"GET",query:t})}async getBallotList({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/ballot_list`),method:"GET"})}async getBallots({block:t}=T){return R(await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/ballots`),method:"GET"}),["yay","nay","pass"])}async getCurrentProposal({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_proposal`),method:"GET"})}async getCurrentQuorum({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_quorum`),method:"GET"})}async getVotesListings({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/listings`),method:"GET"});return e.map(t=>(t.voting_power&&(t.voting_power=new _(t.voting_power)),t)),e}async getProposals({block:t}=T){const e=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/proposals`),method:"GET"});return e.map(t=>t[1]=new _(t[1])),e}async forgeOperations(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/forge/operations`),method:"POST"},t)}async injectOperation(t){return this.httpBackend.createRequest({url:this.createURL("/injection/operation"),method:"POST"},t)}async preapplyOperations(t,{block:e,version:r}=T){const n={url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/preapply/operations`),method:"POST"};return void 0!==r&&(n.query={version:r}),await this.httpBackend.createRequest(n,t)}async getEntrypoints(t,{block:e}=T){this.validateContract(t);return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/entrypoints`),method:"GET"})}async simulateOperation(t,{block:e,version:r}=T){const n={url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/simulate_operation`),method:"POST"};return void 0!==r&&(n.query={version:r}),await this.httpBackend.createRequest(n,t)}async runCode(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/run_code`),method:"POST"},t)}async runScriptView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/helpers/scripts/run_script_view`),method:"POST"},{unparsing_mode:t,...e})}async runView({unparsing_mode:t="Readable",...e},{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/helpers/scripts/run_view`),method:"POST"},{unparsing_mode:t,...e})}async getChainId(){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/chain_id`),method:"GET"})}async packData(t,{block:e}=T){const{gas:r,...n}=await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/helpers/scripts/pack_data`),method:"POST"},t);let i=r;if("string"==typeof r)try{i=new _(r)}catch{i=r}return{gas:i,...n}}getRpcUrl(){return this.url}async getCurrentPeriod({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/current_period`),method:"GET"})}async getSuccessorPeriod({block:t}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/votes/successor_period`),method:"GET"})}async getSaplingDiffById(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/sapling/${t}/get_diff`),method:"GET"})}async getSaplingDiffByContract(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/single_sapling_get_diff`),method:"GET"})}async getProtocols({block:t}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/protocols`),method:"GET"})}async getProtocolActivations(t=""){if(t){const e=(0,A.validateProtocol)(t);if(e!==A.ValidationResult.VALID)throw new A.InvalidProtocolHashError(t,e)}return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/protocols/${t}`),method:"GET"})}async getStorageUsedSpace(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage/used_space`),method:"GET"})}async getStoragePaidSpace(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/storage/paid_space`),method:"GET"})}async getTicketBalance(t,e,{block:r}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${r}/context/contracts/${t}/ticket_balance`),method:"POST"},e)}async getAllTicketBalances(t,{block:e}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/contracts/${t}/all_ticket_balances`),method:"GET"})}async getAdaptiveIssuanceLaunchCycle({block:t}=T){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${t}/context/adaptive_issuance_launch_cycle`),method:"GET"})}async getPendingOperations(t={}){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/mempool/pending_operations`),method:"GET",query:t})}async getMempoolFilter(t={}){return this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/mempool/filter`),method:"GET",query:t})}async getActiveStakingParameters(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/active_staking_parameters`),method:"GET"})}async getPendingStakingParameters(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/delegates/${t}/pending_staking_parameters`),method:"GET"})}async getDestinationIndex(t,{block:e}=T){return await this.httpBackend.createRequest({url:this.createURL(`/chains/${this.chain}/blocks/${e}/context/destination/${t}/index`),method:"GET"})}}},8691(t,e,r){"use strict";r.r(e),r.d(e,{ECDSA:()=>le,Ed25519:()=>ae,Hard:()=>ne,InMemorySigner:()=>Ee,InvalidPassphraseError:()=>mt,Path:()=>he,VERSION:()=>Ae,generateSecretKey:()=>fe,publicKeyFromString:()=>_e});var n=r(2613),i=r(2403),s=r(1032),o=r(3156),a=r(404),c=r(6571),u=r(2823),l=r.n(u),h=r(1188);function f(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}function d(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r}function p(t,e=""){if("number"!=typeof t){throw new TypeError(`${e&&`"${e}" `}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){throw new RangeError(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}}function g(t,e,r=""){const n=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&"BYTES_PER_ELEMENT"in i&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;if(!n||o&&s!==e){const i=(r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${s}`:"type="+typeof t);if(!n)throw new TypeError(i);throw new RangeError(i)}return t}function m(t){if("function"!=typeof t||"function"!=typeof t.create)throw new TypeError("Hash must wrapped by utils.createHasher");if(p(t.outputLen),p(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function y(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function b(t,e){g(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function v(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function w(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function E(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function _(t,e){return t<<32-e|t>>>e}"function"==typeof SuppressedError&&SuppressedError;const A=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function O(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const S=A?t=>t:t=>O(t)>>>0;const T=A?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=O(t[e]);return t};function P(t,e=""){return"string"==typeof t?function(t){if("string"!=typeof t)throw new TypeError("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t):g(t,void 0,e)}function R(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}const x=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])}),I=Uint8Array.from([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,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]);function N(t,e,r){return t&e^~t&r}function k(t,e,r){return t&e^t&r^e&r}class L{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,r,n){this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(t),this.view=E(this.buffer)}update(t){y(this),g(t);const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o===n){const e=E(t);for(;n<=i-s;s+=n)this.process(e,s);continue}r.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){y(this),b(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,w(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let t=s;t<n;t++)e[t]=0;r.setBigUint64(n-8,BigInt(8*this.length),i),this.process(r,0);const o=E(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)o.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=i,t.length=n,t.pos=o,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const C=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),M=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),B=BigInt(2**32-1),D=BigInt(32);function U(t,e=!1){return e?{h:Number(t&B),l:Number(t>>D&B)}:{h:0|Number(t>>D&B),l:0|Number(t&B)}}const K=(t,e,r)=>t>>>r,H=(t,e,r)=>t<<32-r|e>>>r,F=(t,e,r)=>t>>>r|e<<32-r,G=(t,e,r)=>t<<32-r|e>>>r,V=(t,e,r)=>t<<64-r|e>>>r-32,j=(t,e,r)=>t>>>r-32|e<<64-r;function $(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const z=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),q=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,W=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Z=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,Y=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),X=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,J=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Q=new Uint32Array(32);function tt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Q[2*t],u=Q[2*t+1],l=Q[2*e],h=Q[2*e+1],f=Q[2*r],d=Q[2*r+1],p=Q[2*n],g=Q[2*n+1],m=z(c,l,o);var y,b;u=q(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:(b=p,b),Dl:(y=g,y)}),({h:d,l:f}=$(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:F(h,l,24),Bl:G(h,l,24)}),Q[2*t]=c,Q[2*t+1]=u,Q[2*e]=l,Q[2*e+1]=h,Q[2*r]=f,Q[2*r+1]=d,Q[2*n]=p,Q[2*n+1]=g}function et(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Q[2*t],u=Q[2*t+1],l=Q[2*e],h=Q[2*e+1],f=Q[2*r],d=Q[2*r+1],p=Q[2*n],g=Q[2*n+1],m=z(c,l,o);u=q(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:F(g,p,16),Dl:G(g,p,16)}),({h:d,l:f}=$(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:V(h,l,63),Bl:j(h,l,63)}),Q[2*t]=c,Q[2*t+1]=u,Q[2*e]=l,Q[2*e+1]=h,Q[2*r]=f,Q[2*r+1]=d,Q[2*n]=p,Q[2*n+1]=g}class rt{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,e){p(t),p(e),this.blockLen=t,this.outputLen=e,this.buffer=new Uint8Array(t),this.buffer32=v(this.buffer)}update(t){y(this),g(t);const{blockLen:e,buffer:r,buffer32:n}=this,i=t.length,s=t.byteOffset,o=t.buffer;for(let a=0;a<i;){this.pos===e&&(T(n),this.compress(n,0,!1),T(n),this.pos=0);const c=Math.min(e-this.pos,i-a),u=s+a;if(c===e&&!(u%4)&&a+c<i){const t=new Uint32Array(o,u,Math.floor((i-a)/4));T(t);for(let r=0;a+e<i;r+=n.length,a+=e)this.length+=e,this.compress(t,r,!1);T(t);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,this.length+=c,a+=c}return this}digestInto(t){y(this),b(t,this);const{pos:e,buffer32:r}=this;if(this.finished=!0,w(this.buffer.subarray(e)),T(r),this.compress(r,0,!0),T(r),3&t.byteOffset)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const n=this.get(),i=v(t),s=Math.floor(this.outputLen/4);for(let t=0;t<s;t++)i[t]=S(n[t]);const o=this.outputLen%4;if(!o)return;const a=4*s,c=n[s];for(let e=0;e<o;e++)t[a+e]=c>>>8*e}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){const{buffer:e,length:r,finished:n,destroyed:i,outputLen:s,pos:o}=this;return t||=new this.constructor({dkLen:s}),t.set(...this.get()),t.buffer.set(e),t.destroyed=i,t.finished=n,t.length=r,t.pos=o,t.outputLen=s,t}clone(){return this._cloneInto()}}class nt extends rt{v0l=0|J[0];v0h=0|J[1];v1l=0|J[2];v1h=0|J[3];v2l=0|J[4];v2h=0|J[5];v3l=0|J[6];v3h=0|J[7];v4l=0|J[8];v4h=0|J[9];v5l=0|J[10];v5h=0|J[11];v6l=0|J[12];v6h=0|J[13];v7l=0|J[14];v7h=0|J[15];constructor(t={}){const e=void 0===t.dkLen?64:t.dkLen;super(128,e),function(t,e={},r,n,i){if(p(r),t<=0||t>r)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=e;if(void 0!==s&&(s.length<1||s.length>r))throw new Error('"key" expected to be undefined or of length=1..'+r);void 0!==o&&g(o,n,"salt"),void 0!==a&&g(a,i,"personalization")}(e,t,64,16,16);let{key:r,personalization:n,salt:i}=t,s=0;if(void 0!==r&&(g(r,void 0,"key"),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,void 0!==i){g(i,void 0,"salt");const t=v(i);this.v4l^=S(t[0]),this.v4h^=S(t[1]),this.v5l^=S(t[2]),this.v5h^=S(t[3])}if(void 0!==n){g(n,void 0,"personalization");const t=v(n);this.v6l^=S(t[0]),this.v6h^=S(t[1]),this.v7l^=S(t[2]),this.v7h^=S(t[3])}if(void 0!==r){const t=new Uint8Array(this.blockLen);t.set(r),this.update(t)}}get(){let{v0l:t,v0h:e,v1l:r,v1h:n,v2l:i,v2h:s,v3l:o,v3h:a,v4l:c,v4h:u,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.v0l=0|t,this.v0h=0|e,this.v1l=0|r,this.v1h=0|n,this.v2l=0|i,this.v2h=0|s,this.v3l=0|o,this.v3h=0|a,this.v4l=0|c,this.v4h=0|u,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|g}compress(t,e,r){this.get().forEach((t,e)=>Q[e]=t),Q.set(J,16);let{h:n,l:i}=U(BigInt(this.length));Q[24]=J[8]^i,Q[25]=J[9]^n,r&&(Q[28]=~Q[28],Q[29]=~Q[29]);let s=0;const o=I;for(let r=0;r<12;r++)tt(0,4,8,12,t,e+2*o[s++]),et(0,4,8,12,t,e+2*o[s++]),tt(1,5,9,13,t,e+2*o[s++]),et(1,5,9,13,t,e+2*o[s++]),tt(2,6,10,14,t,e+2*o[s++]),et(2,6,10,14,t,e+2*o[s++]),tt(3,7,11,15,t,e+2*o[s++]),et(3,7,11,15,t,e+2*o[s++]),tt(0,5,10,15,t,e+2*o[s++]),et(0,5,10,15,t,e+2*o[s++]),tt(1,6,11,12,t,e+2*o[s++]),et(1,6,11,12,t,e+2*o[s++]),tt(2,7,8,13,t,e+2*o[s++]),et(2,7,8,13,t,e+2*o[s++]),tt(3,4,9,14,t,e+2*o[s++]),et(3,4,9,14,t,e+2*o[s++]);this.v0l^=Q[0]^Q[16],this.v0h^=Q[1]^Q[17],this.v1l^=Q[2]^Q[18],this.v1h^=Q[3]^Q[19],this.v2l^=Q[4]^Q[20],this.v2h^=Q[5]^Q[21],this.v3l^=Q[6]^Q[22],this.v3h^=Q[7]^Q[23],this.v4l^=Q[8]^Q[24],this.v4h^=Q[9]^Q[25],this.v5l^=Q[10]^Q[26],this.v5h^=Q[11]^Q[27],this.v6l^=Q[12]^Q[28],this.v6h^=Q[13]^Q[29],this.v7l^=Q[14]^Q[30],this.v7h^=Q[15]^Q[31],w(Q)}destroy(){this.destroyed=!0,w(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const it=R(t=>new nt(t));var st,ot,at,ct;class ut{constructor(t,e){st.set(this,void 0);const r=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519SecretKey,i.PrefixV2.Ed25519EncryptedSeed,i.PrefixV2.Ed25519Seed]);let[n]=r;const[,o]=r;if(o===i.PrefixV2.Ed25519SecretKey)d(this,st,{secretKey:n,publicKey:n.slice(32)},"f");else{if(o===i.PrefixV2.Ed25519EncryptedSeed){if(void 0===e)throw new Error("decryption function is not provided");n=e(n)}d(this,st,function(t){const e=s.ev.getPublicKey(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{secretKey:r,publicKey:e}}(n),"f")}}sign(t){const e=it(t,{dkLen:32}),r=f(this,st,"f").secretKey.subarray(0,32),n=s.ev.sign(e,r);return{rawSignature:n,sig:(0,i.b58Encode)(n,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(n,i.PrefixV2.Ed25519Signature)}}publicKey(){return new lt(f(this,st,"f").publicKey)}secretKey(){return(0,i.b58Encode)(f(this,st,"f").secretKey,i.PrefixV2.Ed25519SecretKey)}}st=new WeakMap;class lt{constructor(t){if(ot.set(this,void 0),"string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519PublicKey]);d(this,ot,e,"f")}else d(this,ot,t,"f")}compare(t){if(t instanceof lt)return(0,i.compareArrays)(this.bytes(),t.bytes());throw new i.InvalidPublicKeyError("EdDSA key expected")}hash(){return(0,i.b58Encode)(it(f(this,ot,"f"),{dkLen:20}),i.PrefixV2.Ed25519PublicKeyHash)}bytes(){return f(this,ot,"f")}toProtocol(){const t=new Uint8Array(f(this,ot,"f").length+1);return t[0]=0,t.set(f(this,ot,"f"),1),t}toString(){return(0,i.b58Encode)(f(this,ot,"f"),i.PrefixV2.Ed25519PublicKey)}}ot=new WeakMap;class ht extends c.ParameterValidationError{constructor(t){super(),this.name="InvalidMnemonicError",this.message="Invalid mnemonic"}}class ft extends c.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidBitSize"}}class dt extends c.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidCurveError"}}class pt extends c.ParameterValidationError{constructor(t){super(),this.seedLength=t,this.name="InvalidSeedLengthError",this.message=`Invalid seed length "${t}" expecting length between 16 to 64.`}}class gt extends c.UnsupportedActionError{constructor(){super(),this.name="ToBeImplemented",this.message="This feature is under developement"}}class mt extends c.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidPassphraseError"}}const yt={p256:{pk:i.PrefixV2.P256PublicKey,sk:i.PrefixV2.P256SecretKey,pkh:i.PrefixV2.P256PublicKeyHash,sig:i.PrefixV2.P256Signature,tag:2},secp256k1:{pk:i.PrefixV2.Secp256k1PublicKey,sk:i.PrefixV2.Secp256k1SecretKey,pkh:i.PrefixV2.Secp256k1PublicKeyHash,sig:i.PrefixV2.Secp256k1Signature,tag:1}};class bt{constructor(t,e){at.set(this,void 0);const[r,n]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Secp256k1EncryptedSecretKey,i.PrefixV2.P256EncryptedSecretKey,i.PrefixV2.Secp256k1SecretKey,i.PrefixV2.P256SecretKey]),[s,c]=(()=>{switch(n){case i.PrefixV2.Secp256k1EncryptedSecretKey:case i.PrefixV2.P256EncryptedSecretKey:if(void 0===e)throw new Error("decryption function is not provided");return[e(r),n===i.PrefixV2.Secp256k1EncryptedSecretKey?"secp256k1":"p256"];case i.PrefixV2.Secp256k1SecretKey:return[r,"secp256k1"];default:return[r,"p256"]}})();d(this,at,{curve:c,secretKey:s,publicKey:"secp256k1"===c?o.bI.getPublicKey(s,!0):a.s9.getPublicKey(s,!0)},"f")}sign(t){const e=it(t,{dkLen:32});let r;return r="secp256k1"===f(this,at,"f").curve?o.bI.sign(e,f(this,at,"f").secretKey,{lowS:!0}).toBytes("compact"):a.s9.sign(e,f(this,at,"f").secretKey,{lowS:!0}).toBytes("compact"),{rawSignature:r,sig:(0,i.b58Encode)(r,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(r,yt[f(this,at,"f").curve].sig)}}publicKey(){return new vt(f(this,at,"f").publicKey,f(this,at,"f").curve)}secretKey(){return(0,i.b58Encode)(f(this,at,"f").secretKey,yt[f(this,at,"f").curve].sk)}}at=new WeakMap;class vt{constructor(t,e){ct.set(this,void 0);const[r,n]=(()=>{if("string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Secp256k1PublicKey,i.PrefixV2.P256PublicKey]);return[e,r===i.PrefixV2.Secp256k1PublicKey?"secp256k1":"p256"]}if(void 0!==e)return[t,e];throw new dt("missing curve type")})();d(this,ct,r,"f"),this.curve=n}compare(t){if(t instanceof vt){if(this.curve===t.curve){const e="secp256k1"===this.curve;return(0,i.compareArrays)(this.bytes(e),t.bytes(e))}return"secp256k1"===this.curve?-1:1}throw new i.InvalidPublicKeyError("ECDSA key expected")}hash(){const t=this.bytes();return(0,i.b58Encode)(it(t,{dkLen:20}),yt[this.curve].pkh)}bytes(t=!0){if("secp256k1"===this.curve){return o.bI.Point.fromHex(f(this,ct,"f")).toBytes(t)}return a.s9.Point.fromHex(f(this,ct,"f")).toBytes(t)}toProtocol(){const t=this.bytes(),e=new Uint8Array(t.length+1);return e[0]=yt[this.curve].tag,e.set(t,1),e}toString(){const t=this.bytes();return(0,i.b58Encode)(t,yt[this.curve].pk)}}ct=new WeakMap;class wt{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(m(t),g(e,void 0,"key"),this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(e.length>r?t.create().update(e).digest():e);for(let t=0;t<n.length;t++)n[t]^=54;this.iHash.update(n),this.oHash=t.create();for(let t=0;t<n.length;t++)n[t]^=106;this.oHash.update(n),w(n)}update(t){return y(this),this.iHash.update(t),this}digestInto(t){y(this),b(t,this),this.finished=!0;const e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Et=(()=>{const t=(t,e,r)=>new wt(t,e).update(r).digest();return t.create=(t,e)=>new wt(t,e),t})();function _t(t,e,r,n){m(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new TypeError("options must be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},n),{c:s,dkLen:o,asyncTick:a}=i;if(p(s,"c"),p(o,"dkLen"),p(a,"asyncTick"),s<1)throw new Error("iterations (c) must be >= 1");if(o<1)throw new Error('"dkLen" must be >= 1');if(o>(2**32-1)*t.outputLen)throw new Error("derived key too long");const c=P(e,"password"),u=P(r,"salt"),l=new Uint8Array(o),h=Et.create(t,c),f=h._cloneInto().update(u);return{c:s,dkLen:o,asyncTick:a,DK:l,PRF:h,PRFSalt:f}}function At(t,e,r,n){const{c:i,dkLen:s,DK:o,PRF:a,PRFSalt:c}=_t(t,e,r,n);let u;const l=new Uint8Array(4),h=E(l),f=new Uint8Array(a.outputLen);for(let t=1,e=0;e<s;t++,e+=a.outputLen){const r=o.subarray(e,e+a.outputLen);h.setInt32(0,t,!1),(u=c._cloneInto(u)).update(l).digestInto(f),r.set(f.subarray(0,r.length));for(let t=1;t<i;t++){a._cloneInto(u).update(f).digestInto(f);for(let t=0;t<r.length;t++)r[t]^=f[t]}}return function(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),w(i),r}(a,c,o,u,f)}const Ot=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),St=new Uint32Array(64);class Tt extends L{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)St[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=St[t-15],r=St[t-2],n=_(e,7)^_(e,18)^e>>>3,i=_(r,17)^_(r,19)^r>>>10;St[t]=i+St[t-7]+n+St[t-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(_(o,6)^_(o,11)^_(o,25))+N(o,a,c)+Ot[t]+St[t]|0,l=(_(r,2)^_(r,13)^_(r,22))+k(r,n,i)|0;u=c,c=a,a=o,o=s+e|0,s=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,s,o,a,c,u)}roundClean(){w(St)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),w(this.buffer)}}class Pt extends Tt{A=0|C[0];B=0|C[1];C=0|C[2];D=0|C[3];E=0|C[4];F=0|C[5];G=0|C[6];H=0|C[7];constructor(){super(32)}}const Rt=(()=>function(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){const{h:r,l:o}=U(t[s],e);[n[s],i[s]]=[r,o]}return[n,i]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),xt=(()=>Rt[0])(),It=(()=>Rt[1])(),Nt=new Uint32Array(80),kt=new Uint32Array(80);class Lt extends L{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)Nt[r]=t.getUint32(e),kt[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Nt[t-15],r=0|kt[t-15],n=F(e,r,1)^F(e,r,8)^K(e,0,7),i=G(e,r,1)^G(e,r,8)^H(e,r,7),s=0|Nt[t-2],o=0|kt[t-2],a=F(s,o,19)^V(s,o,61)^K(s,0,6),c=G(s,o,19)^j(s,o,61)^H(s,o,6),u=W(i,c,kt[t-7],kt[t-16]),l=Z(u,n,a,Nt[t-7],Nt[t-16]);Nt[t]=0|l,kt[t]=0|u}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let t=0;t<80;t++){const e=F(l,h,14)^F(l,h,18)^V(l,h,41),b=G(l,h,14)^G(l,h,18)^j(l,h,41),v=l&f^~l&p,w=Y(y,b,h&d^~h&g,It[t],kt[t]),E=X(w,m,e,v,xt[t],Nt[t]),_=0|w,A=F(r,n,28)^V(r,n,34)^V(r,n,39),O=G(r,n,28)^j(r,n,34)^j(r,n,39),S=r&i^r&o^i&o,T=n&s^n&a^s&a;m=0|p,y=0|g,p=0|f,g=0|d,f=0|l,d=0|h,({h:l,l:h}=$(0|c,0|u,0|E,0|_)),c=0|o,u=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const P=z(_,O,T);r=q(P,E,A,S),n=0|P}({h:r,l:n}=$(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=$(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=$(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:u}=$(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=$(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=$(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:g}=$(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=$(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(r,n,i,s,o,a,c,u,l,h,f,d,p,g,m,y)}roundClean(){w(Nt,kt)}destroy(){this.destroyed=!0,w(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ct extends Lt{Ah=0|M[0];Al=0|M[1];Bh=0|M[2];Bl=0|M[3];Ch=0|M[4];Cl=0|M[5];Dh=0|M[6];Dl=0|M[7];Eh=0|M[8];El=0|M[9];Fh=0|M[10];Fl=0|M[11];Gh=0|M[12];Gl=0|M[13];Hh=0|M[14];Hl=0|M[15];constructor(){super(64)}}const Mt=R(()=>new Pt,x(1)),Bt=R(()=>new Ct,x(3));function Dt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}function Ut(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function Kt(t,e){if("string"!=typeof e)throw new TypeError(`${t}: string expected`);return!0}function Ht(t){if("number"!=typeof t)throw new TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t))throw new RangeError(`invalid integer: ${t}`)}function Ft(t){if(!Array.isArray(t))throw new TypeError("array expected")}function Gt(t,e){if(!Ut(!0,e))throw new TypeError(`${t}: array of strings expected`)}function Vt(t,e){if(!Ut(!1,e))throw new TypeError(`${t}: array of numbers expected`)}function jt(t,e,r){if(e<2)throw new RangeError(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ft(t),!t.length)return[];let n=0;const i=[],s=Array.from(t,t=>{if(Ht(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),o=s.length;for(;;){let t=0,a=!0;for(let i=n;i<o;i++){const o=s[i],c=e*t,u=c+o;if(!Number.isSafeInteger(u)||c/e!==t||u-o!==c)throw new Error("convertRadix: carry overflow");const l=u/r;t=u%r;const h=Math.floor(l);if(s[i]=h,!Number.isSafeInteger(h)||h*r+t!==u)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:n=i)}if(i.push(t),a)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const $t=(t,e)=>0===e?t:$t(e,t%e),zt=(t,e)=>t+(e-$t(t,e)),qt=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Wt(t,e,r,n){if(Ft(t),e<=0||e>32)throw new RangeError(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new RangeError(`convertRadix2: wrong to=${r}`);if(zt(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${zt(e,r)}`);let i=0,s=0;const o=qt[e],a=qt[r]-1,c=[];for(const n of t){if(Ht(n),n>=o)throw new Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=r;s-=r)c.push((i>>s-r&a)>>>0);const t=qt[s];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<r-s&a,!n&&s>=e)throw new Error("Excess padding");if(!n&&i>0)throw new Error(`Non-zero padding: ${i}`);return n&&s>0&&c.push(i>>>0),c}const Zt=Object.freeze({alphabet:function(t){const e="string"==typeof t?t.split(""):t,r=e.length;Gt("alphabet",e);const n=new Map(e.map((t,e)=>[t,e]));return{encode:n=>(Ft(n),n.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${t}`);return e[n]})),decode:e=>(Ft(e),e.map(e=>{Kt("alphabet.decode",e);const r=n.get(e);if(void 0===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}},chain:function(...t){const e=t=>t,r=(t,e)=>r=>t(e(r));return{encode:t.map(t=>t.encode).reduceRight(r,e),decode:t.map(t=>t.decode).reduce(r,e)}},checksum:function(t,e){if(Ht(t),t<=0)throw new RangeError(`checksum length must be positive: ${t}`);!function(t){if("function"!=typeof t)throw new TypeError("function expected")}(e);const r=e;return{encode(e){if(!Dt(e))throw new TypeError("checksum.encode: input should be Uint8Array");const n=r(e).slice(0,t),i=new Uint8Array(e.length+t);return i.set(e),i.set(n,e.length),i},decode(e){if(!Dt(e))throw new TypeError("checksum.decode: input should be Uint8Array");const n=e.slice(0,-t),i=e.slice(-t),s=r(n).slice(0,t);for(let e=0;e<t;e++)if(s[e]!==i[e])throw new Error("Invalid checksum");return n}}},convertRadix:jt,convertRadix2:Wt,radix:function(t){return Ht(t),{encode:e=>{if(!Dt(e))throw new TypeError("radix.encode input should be Uint8Array");return jt(Array.from(e),256,t)},decode:e=>(Vt("radix.decode",e),Uint8Array.from(jt(e,t,256)))}},radix2:function(t,e=!1){if(Ht(t),t<=0||t>32)throw new RangeError("radix2: bits should be in (0..32]");if(zt(8,t)>32||zt(t,8)>32)throw new RangeError("radix2: carry overflow");return{encode:r=>{if(!Dt(r))throw new TypeError("radix2.encode input should be Uint8Array");return Wt(Array.from(r),8,t,!e)},decode:r=>(Vt("radix2.decode",r),Uint8Array.from(Wt(r,t,8,e)))}},join:function(t=""){return Kt("join",t),{encode:e=>(Gt("join.decode",e),e.join(t)),decode:e=>(Kt("join.decode",e),e.split(t))}},padding:function(t,e="="){return Ht(t),Kt("padding",e),{encode(r){for(Gt("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){Gt("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--){if((n-1)*t%8==0)throw new Error("padding: invalid, string has too much padding")}return r.slice(0,n)}}}});function Yt(t){if("string"!=typeof t)throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Xt(t){const e=Yt(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const Jt=t=>{const e=8-t.length/4;return new Uint8Array([Mt(t)[0]>>e<<e])};function Qt(t,e){const{words:r}=Xt(t),n=function(t){if(!Array.isArray(t)||2048!==t.length||"string"!=typeof t[0])throw new TypeError("Wordlist: expected array of 2048 strings");return t.forEach(t=>{if("string"!=typeof t)throw new TypeError("wordlist: non-string element: "+t)}),Zt.chain(Zt.checksum(1,Jt),Zt.radix2(11,!0),Zt.alphabet(t))}(e).decode(r);return function(t){if(g(t),![16,20,24,28,32].includes(t.length))throw new RangeError("invalid entropy length")}(n),n}function te(t,e){try{Qt(t,e)}catch(t){return!1}return!0}function ee(t,e=""){return At(Bt,Xt(t).nfkd,(t=>Yt("mnemonic"+t))(e),{c:2048,dkLen:64})}const re=Object.freeze("abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n")),ne=2147483648;function ie(t){const e=[];for(let r=0;r<t.length;r+=2){const n=t.slice(r,r+2),i=parseInt(n,16);if(Number.isNaN(i))throw new c.InvalidHexStringError(n);e.push(i)}return new Uint8Array(e)}function se(t){const e=s.ev.getPublicKey(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{secretKey:r,publicKey:e}}let oe=class t{constructor(t,e){this.priv=t,this.chainCode=e}static fromSeed(e){const r="string"==typeof e?ie(e):e;if(r.length<16||r.length>64)throw new pt(r.length);const n=(new TextEncoder).encode("ed25519 seed"),i=Et(Bt,n,r);return new t(se(i.subarray(0,32)).secretKey,i.subarray(32))}seed(){return this.priv.subarray(0,32)}derive(e){if(0===(e&ne))throw new c.InvalidDerivationPathError(e.toString(),": Non-hardened derivation path.");const r=new Uint8Array(37);r.set(this.seed(),1),new DataView(r.buffer).setUint32(33,e);const n=Et(Bt,this.chainCode,r);return new t(se(n.subarray(0,32)).secretKey,n.subarray(32))}derivePath(t){let e=this;for(const r of t)e=e.derive(r);return e}};var ae=Object.freeze({__proto__:null,PrivateKey:oe});const ce={p256:"Nist256p1 seed",secp256k1:"Bitcoin seed"};class ue{constructor(t,e){this.priv=t,this.chainCode=e;const r=t.secretKey.toArray("be",32),n=new Uint8Array(r),i="secp256k1"===t.curve?o.bI.getPublicKey(n,!0):a.s9.getPublicKey(n,!0);this.keyPair={curve:t.curve,secretKey:t.secretKey,publicKey:i}}static fromSeed(t,e){let r,n="string"==typeof t?ie(t):t;if(n.length<16||n.length>64)throw new pt(n.length);if(!Object.prototype.hasOwnProperty.call(ce,e))throw new dt(`Unsupported curve "${e}" expecting either "p256" or "secp256k1"`);if(r="secp256k1"===e?new(l())(o.bI.Point.CURVE().n.toString()):new(l())(a.s9.Point.CURVE().n.toString()),256!==r.bitLength())throw new ft(`Invalid curve "${e}" with bit size "${r.bitLength()}" expecting bit size "256"`);const i=(new TextEncoder).encode(ce[e]);let s=null,c=new Uint8Array,u=0;for(;0===u;){const t=Et(Bt,i,n);s=new(l())(t.subarray(0,32)),c=t.subarray(32),s.isZero()||s.cmp(r)>=0?n=t:u++}return new ue({curve:e,secretKey:s},c)}derive(t){const e=new Uint8Array(37);0!==(t&ne)?e.set(this.keyPair.secretKey.toArray(),1):e.set(this.keyPair.publicKey,0),new DataView(e.buffer).setUint32(33,t);let r=new(l())(0),n=new Uint8Array,i=0;for(;0===i;){const t=Et(Bt,this.chainCode,e);let s;r=new(l())(t.subarray(0,32)),n=t.subarray(32),s="secp256k1"===this.keyPair.curve?new(l())(o.bI.Point.CURVE().n.toString()):new(l())(a.s9.Point.CURVE().n.toString()),r.cmp(s)<0&&(r=r.add(this.keyPair.secretKey).mod(s),r.isZero()||i++),e.set(n,1),e[0]=1}return new ue({curve:this.keyPair.curve,secretKey:r},n)}derivePath(t){let e=this;for(const r of t)e=e.derive(r);return e}bytes(){if(!this.keyPair.secretKey)throw new c.InvalidKeyError("missing private key");const t=this.keyPair.secretKey.toArray(),e=new Uint8Array(32);return e.set(t,e.length-t.length),e}}var le=Object.freeze({__proto__:null,PrivateKey:ue});class he extends Array{static from(t){return super.from(t).map(t=>t>>>0)}static fromString(t){if(0===t.length)return new he;let e=t.split("/");const r=[];"m"===e[0]&&(e=e.slice(1));for(let n of e){if(0===n.length)throw new c.InvalidDerivationPathError(t,": Invalid BIP32 path");let e=0;const i=n[n.length-1];"'"!==i&&"h"!==i&&"H"!==i||(e=ne,n=n.slice(0,n.length-1));const s=(parseInt(n,10)|e)>>>0;r.push(s)}return he.from(r)}}const fe=(t,e,r)=>{const n=he.fromString(e);let s;switch(r){case"ed25519":s=oe.fromSeed(t).derivePath(n);return(0,i.b58Encode)(s.seed().slice(0,32),i.PrefixV2.Ed25519Seed);case"secp256k1":case"p256":{const e="secp256k1"===r?i.PrefixV2.Secp256k1SecretKey:i.PrefixV2.P256SecretKey;let s=ue.fromSeed(t,r);s=s.derivePath(n);const o=new Uint8Array(s.keyPair.secretKey.toArray());return(0,i.b58Encode)(o,e)}case"bip25519":throw new gt;default:throw new dt(`Unsupported curve "${r}" expecting one of the following "ed25519", "secp256k1", "p256"`)}};function de(t){return"provePossession"in t}var pe,ge,me;const ye=h.A.longSignatures;class be{constructor(t,e){pe.set(this,void 0),ge.set(this,void 0);const r=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.BLS12_381EncryptedSecretKey,i.PrefixV2.BLS12_381SecretKey]);let[n]=r;const[,s]=r;if(s===i.PrefixV2.BLS12_381EncryptedSecretKey){if(void 0===e)throw new Error("decryption function is not provided");n=e(n)}d(this,pe,n,"f"),d(this,ge,ye.getPublicKey(this.sk()).toBytes(),"f")}sk(){return new Uint8Array(f(this,pe,"f")).reverse()}signDst(t,e){const r=ye.hash(t,e),n=ye.sign(r,this.sk()).toBytes();return{rawSignature:n,sig:(0,i.b58Encode)(n,i.PrefixV2.GenericSignature),prefixSig:(0,i.b58Encode)(n,i.PrefixV2.BLS12_381Signature)}}sign(t){return this.signDst(t,i.BLS12_381_DST)}provePossession(){return this.signDst(f(this,ge,"f"),i.POP_DST)}publicKey(){return new ve(f(this,ge,"f"))}secretKey(){return(0,i.b58Encode)(f(this,pe,"f"),i.PrefixV2.BLS12_381SecretKey)}}pe=new WeakMap,ge=new WeakMap;class ve{constructor(t){if(me.set(this,void 0),"string"==typeof t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.BLS12_381PublicKey]);d(this,me,e,"f")}else d(this,me,t,"f")}compare(t){if(t instanceof ve)return(0,i.compareArrays)(this.bytes(),t.bytes());throw new i.InvalidPublicKeyError("BLS key expected")}hash(){return(0,i.b58Encode)(it(f(this,me,"f"),{dkLen:20}),i.PrefixV2.BLS12_381PublicKeyHash)}bytes(){return f(this,me,"f")}toProtocol(){const t=new Uint8Array(f(this,me,"f").length+1);return t[0]=3,t.set(f(this,me,"f"),1),t}toString(){return(0,i.b58Encode)(f(this,me,"f"),i.PrefixV2.BLS12_381PublicKey)}}var we;me=new WeakMap;class Ee{static fromFundraiser(t,e,r){if(!te(r,re))throw new ht;const n=ee(r,`${t}${e}`),s=(0,i.b58Encode)(n.subarray(0,32),i.PrefixV2.Ed25519Seed);return new Ee(s)}static async fromSecretKey(t,e){return new Ee(t,e)}static fromMnemonic({mnemonic:t,password:e="",derivationPath:r="44'/1729'/0'/0'",curve:n="ed25519"}){if(!te(t,re))throw new ht;const i=ee(t,e),s=fe(i,r,n);return new Ee(s)}constructor(t,e){we.set(this,void 0);const r=[i.PrefixV2.Ed25519EncryptedSeed,i.PrefixV2.Ed25519Seed,i.PrefixV2.Ed25519SecretKey,i.PrefixV2.Secp256k1EncryptedSecretKey,i.PrefixV2.Secp256k1SecretKey,i.PrefixV2.P256EncryptedSecretKey,i.PrefixV2.P256SecretKey,i.PrefixV2.BLS12_381EncryptedSecretKey,i.PrefixV2.BLS12_381SecretKey],s=(()=>{try{const[,e]=(0,i.b58DecodeAndCheckPrefix)(t,r);return e}catch{throw new c.InvalidKeyError(`Invalid private key, expecting one of the following prefixes '${r}'.`)}})();let o;if(s===i.PrefixV2.Ed25519EncryptedSeed||s===i.PrefixV2.Secp256k1EncryptedSecretKey||s===i.PrefixV2.P256EncryptedSecretKey||s===i.PrefixV2.BLS12_381EncryptedSecretKey){if(!e)throw new mt("No passphrase provided to decrypt encrypted key");o=t=>{const r=Uint8Array.from(t.subarray(0,8)),i=t.subarray(8),s=At(Bt,e,r,{c:32768,dkLen:32}),o=(0,n.openSecretBox)(new Uint8Array(s),new Uint8Array(24),new Uint8Array(i));if(!o)throw new Error("can't decrypt secret key");return o}}switch(s){case i.PrefixV2.Ed25519EncryptedSeed:case i.PrefixV2.Ed25519Seed:case i.PrefixV2.Ed25519SecretKey:d(this,we,new ut(t,o),"f");break;case i.PrefixV2.Secp256k1EncryptedSecretKey:case i.PrefixV2.Secp256k1SecretKey:case i.PrefixV2.P256EncryptedSecretKey:case i.PrefixV2.P256SecretKey:d(this,we,new bt(t,o),"f");break;case i.PrefixV2.BLS12_381EncryptedSecretKey:case i.PrefixV2.BLS12_381SecretKey:d(this,we,new be(t,o),"f")}}async sign(t,e){const r="string"==typeof t?(0,i.hex2buf)(t):t,n=void 0!==e?(0,i.mergebuf)(e,r):r,{rawSignature:s,sig:o,prefixSig:a}=await f(this,we,"f").sign(n);return{bytes:(0,i.buf2hex)(r),sig:o,prefixSig:a,sbytes:(0,i.buf2hex)((0,i.mergebuf)(r,de(f(this,we,"f"))?(0,i.mergebuf)(new Uint8Array([255,3]),s):s))}}async provePossession(){if(de(f(this,we,"f")))return f(this,we,"f").provePossession();throw new c.ProhibitedActionError("Only BLS keys can prove possession")}get canProvePossession(){return de(f(this,we,"f"))}publicKey(){return Promise.resolve(String(f(this,we,"f").publicKey()))}publicKeyHash(){return Promise.resolve(f(this,we,"f").publicKey().hash())}secretKey(){return Promise.resolve(f(this,we,"f").secretKey())}}function _e(t){const[e,r]=(0,i.b58DecodeAndCheckPrefix)(t,[i.PrefixV2.Ed25519PublicKey,i.PrefixV2.Secp256k1PublicKey,i.PrefixV2.P256PublicKey,i.PrefixV2.BLS12_381PublicKey]);switch(r){case i.PrefixV2.Ed25519PublicKey:return new lt(e);case i.PrefixV2.Secp256k1PublicKey:return new vt(e,"secp256k1");case i.PrefixV2.P256PublicKey:return new vt(e,"p256");case i.PrefixV2.BLS12_381PublicKey:return new ve(e)}}we=new WeakMap;const Ae={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"}},2403(t,e,r){"use strict";r.r(e),r.d(e,{BLS12_381_DST:()=>We,DeprecationError:()=>O.DeprecationError,InvalidAddressError:()=>O.InvalidAddressError,InvalidBlockHashError:()=>O.InvalidBlockHashError,InvalidChainIdError:()=>O.InvalidChainIdError,InvalidContractAddressError:()=>O.InvalidContractAddressError,InvalidHexStringError:()=>O.InvalidHexStringError,InvalidKeyError:()=>O.InvalidKeyError,InvalidKeyHashError:()=>O.InvalidKeyHashError,InvalidMessageError:()=>O.InvalidMessageError,InvalidOperationHashError:()=>O.InvalidOperationHashError,InvalidOperationKindError:()=>O.InvalidOperationKindError,InvalidProtocolHashError:()=>Je,InvalidPublicKeyError:()=>O.InvalidPublicKeyError,InvalidSignatureError:()=>O.InvalidSignatureError,POP_DST:()=>Ze,PrefixV2:()=>_t,ProhibitedActionError:()=>O.ProhibitedActionError,VERSION:()=>qe,ValidationResult:()=>O.ValidationResult,ValueConversionError:()=>Qe,addressPrefixes:()=>ie,b58DecodeAddress:()=>fe,b58DecodeAndCheckPrefix:()=>ce,b58DecodeBlsAddress:()=>he,b58DecodePublicKey:()=>ue,b58DecodePublicKeyHash:()=>le,b58Encode:()=>pe,buf2hex:()=>Oe,bytesToString:()=>Te,compareArrays:()=>Le,encodeAddress:()=>ye,encodeBlsAddress:()=>be,encodeExpr:()=>ve,encodeKey:()=>ge,encodeKeyHash:()=>me,encodeOpHash:()=>we,format:()=>er,getPkhfromPk:()=>de,hex2Bytes:()=>Pe,hex2buf:()=>Ee,isValidPrefixedValue:()=>Ce,mergebuf:()=>_e,mic2arr:()=>Ae,num2PaddedHex:()=>Ie,numToHexBuffer:()=>xe,payloadLength:()=>It,publicKeyHashPrefixes:()=>oe,publicKeyPrefixes:()=>se,signaturePrefixes:()=>ae,splitAddress:()=>ke,stringToBytes:()=>Se,stripHexPrefix:()=>Ne,toHexBuf:()=>Re,validateAddress:()=>Be,validateBlock:()=>je,validateChain:()=>De,validateContractAddress:()=>Ue,validateKeyHash:()=>Ke,validateOperation:()=>Ge,validateProtocol:()=>Ve,validatePublicKey:()=>Fe,validateSignature:()=>He,validateSmartRollupAddress:()=>ze,validateSpendingKey:()=>$e,verifySignature:()=>Ye});var n=r(9848),i=r.n(n),s=function t(e){var r,n,i,s=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,a,c,l,f,d,p,g=this;if(!(g instanceof M))return new M(t,e);if(p=typeof t,null==e){if(D(t))return g.s=t.s,void(!t.c||t.e>x?g.c=g.e=null:t.e<R?g.c=[g.e=0]:(g.e=t.e,g.c=t.c.slice()));if("number"==p){if(0*t!=0)return g.s=isNaN(t)?null:t<0?-1:1,void(g.c=g.e=null);if(g.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?g.c=g.e=null:(g.e=c,g.c=[t]))}d=String(t)}else{if("string"==p){if(d=t,!o.test(d))return i(g,d)}else{if("bigint"!=p)throw Error(u+"Invalid argument: "+t);d=String(t)}g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(l=d.search(/e/i))>0?(c<0&&(c=l),c+=+d.slice(l+1),d=d.substring(0,l)):c<0&&(c=d.length)}else{if("string"!=p)throw Error(u+"String expected: "+t);for(v(e,2,C.length,"Base"),d=t,g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1,r=C.slice(0,e),c=l=0,f=d.length;l<f;l++)if(r.indexOf(s=d.charAt(l))<0){if("."==s){if(l>c){c=f;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,l=-1,c=0;continue}return i(g,t,e)}(c=(d=n(d,e,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(l=0;48===d.charCodeAt(l);l++);for(f=d.length;48===d.charCodeAt(--f););if(d=d.slice(l,++f))if(f-=l,(c=c-l-1)>x)g.c=g.e=null;else if(c<R)g.c=[g.e=0];else{if(g.e=c,g.c=[],l=(c+1)%h,c<0&&(l+=h),l<f){for(l&&g.c.push(+d.slice(0,l)),f-=h;l<f;)g.c.push(+d.slice(l,l+=h));l=h-(d=d.slice(l)).length}else l-=f;for(;l--;d+="0");g.c.push(+d)}else g.c=[g.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:v(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=y(t.c),c=1==n||2==n&&(o<=T||o>=P)?E(c,o):_(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=E(c,s)}else if(e-=o+(2===n&&s>o),c=_(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=b(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*h-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,s,o,u,f,p,g,m=t.c,y=d;if(m){t:{for(i=1,u=m[0];u>=10;u/=10,i++);if((s=e-i)<0)s+=h,o=e,f=m[p=0],g=c(f/y[i-o-1]%10);else if((p=a((s+1)/h))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));f=g=0,i=1,o=(s%=h)-h+1}else{for(f=u=m[p],i=1;u>=10;u/=10,i++);g=(o=(s%=h)-h+i)<0?0:c(f/y[i-o-1]%10)}if(n=n||e<0||null!=m[p+1]||(o<0?f:f%y[i-o-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(s>0?o>0?f/y[i-o]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(h-e%h)%h],t.e=-e||0):m[0]=t.e=0,t;if(0==s?(m.length=p,u=1,p--):(m.length=p+1,u=y[h-s],m[p]=o>0?c(f/y[i-o]%y[o])*u:0),n)for(;;){if(0==p){for(s=1,o=m[0];o>=10;o/=10,s++);for(o=m[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(t.e++,m[0]==l&&(m[0]=1));break}if(m[p]+=u,m[p]!=l)break;m[p--]=0,u=1}for(s=m.length;0===m[--s];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=y(t.c),e=r<=T||r>=P?E(e,r):_(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,g,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-g,0,e),v(r[1],0,g,e),T=r[0],P=r[1]):(v(r,-g,g,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-g,-1,e),v(r[1],1,g,e),R=r[0],x=r[1];else{if(v(r,-g,g,e),!r)throw Error(u+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(u+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,g,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-g||i>g||i!==c(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%h)<1&&(e+=h),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=l||r!==c(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return c(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,s,o,l=0,f=[],p=new M(A);if(null==t?t=O:v(t,0,g),s=a(t/h),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)(o=131072*r[l]+(r[l+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[l]=n[0],r[l+1]=n[1]):(f.push(o%1e14),l+=2);l=s/2}else{if(!crypto.randomBytes)throw I=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);l<s;)(o=281474976710656*(31&r[l])+1099511627776*r[l+1]+4294967296*r[l+2]+16777216*r[l+3]+(r[l+4]<<16)+(r[l+5]<<8)+r[l+6])>=9e15?crypto.randomBytes(7).copy(r,l):(f.push(o%1e14),l+=7);l=s/7}if(!I)for(;l<s;)(o=e())<9e15&&(f[l++]=o%1e14);for(s=f[--l],t%=h,s&&t&&(o=d[h-t],f[l]=c(s/o)*o);0===f[l];f.pop(),l--);if(l<0)f=[i=0];else{for(i=-1;0===f[0];f.splice(0,1),i-=h);for(l=1,o=f[0];o>=10;o/=10,l++);l<h&&(i-=h-l)}return p.e=i,p.c=f,p}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,g,m=n.indexOf("."),b=O,v=S;for(m>=0&&(h=k,k=0,n=n.replace(".",""),d=(g=new M(i)).pow(n.length-m),k=h,g.c=e(_(y(d.c),d.e,"0"),10,s,t),g.e=g.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,g,b,v,s)).c,f=d.r,l=d.e),m=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(d.s<0?3:2)):m>h||m==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?_(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(m=0,n="";m<=h;n+=c.charAt(p[m++]));n=_(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%p)+(n=l*s+(o=t[c]/p|0)*u)%p*p+a)/r|0)+(n/p|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,o,a){var u,f,d,p,g,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),x=x/h|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),p=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(g=c(a/(N[0]+1)))>1&&(N=t(N,g,a),I=t(I,g,a),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=a/2&&T++;do{if(g=0,(u=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*a+(E[1]||0)),(g=c(A/T))>1)for(g>=a&&(g=a-1),b=(y=t(N,g,a)).length,_=E.length;1==e(y,E,b,_);)g--,r(y,P<b?R:N,b,a),b=y.length,u=1;else 0==g&&(u=g=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,a),_=E.length,-1==u)for(;e(N,E,P,_)<1;)g++,r(E,P<_?R:N,_,a),_=E.length}else 0===u&&(g++,E=[0]);w[d++]=g,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);p=null!=E[0],w[0]||w.splice(0,1)}if(a==l){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*h-1)+1,o,p)}else v.e=f,v.r=+p;return v}}(),i=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,a){var c,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return c="x"==(r=r.toLowerCase())?16:"b"==r?2:8,a&&a!=c?t:e}),a&&(c=a,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,c);throw Error(u+"Not a"+(a?" base "+a:"")+" number: "+o)}}(),s.absoluteValue=s.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},s.comparedTo=function(t,e){return b(this,new M(t,e))},s.decimalPlaces=s.dp=function(t,e){var r,n,i,s=this;if(null!=t)return v(t,0,g),null==e?e=S:v(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},s.dividedBy=s.div=function(t,e){return r(this,new M(t,e),O,S)},s.dividedToIntegerBy=s.idiv=function(t,e){return r(this,new M(t,e),0,1)},s.exponentiatedBy=s.pow=function(t,e){var r,n,i,s,o,l,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),o=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),o?t.s*(2-w(t)):+F(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!l&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||o&&p.c[1]>=24e7:p.c[0]<8e13||o&&p.c[0]<=9999975e7)))return s=p.s<0&&w(t)?-0:0,p.e>-1&&(s=1/s),new M(l?1/s:s);k&&(s=a(k/h+2))}for(o?(r=new M(.5),l&&(t.s=1),f=w(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(i){if(0===(i=c(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=w(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?d:(l&&(d=A.div(d)),e?d.mod(e):s?H(d,k,S,void 0):d)},s.integerValue=function(t){var e=new M(this);return null==t?t=S:v(t,0,8),H(e,e.e+1,t)},s.isEqualTo=s.eq=function(t,e){return 0===b(this,new M(t,e))},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(t,e){return b(this,new M(t,e))>0},s.isGreaterThanOrEqualTo=s.gte=function(t,e){return 1===(e=b(this,new M(t,e)))||0===e},s.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},s.isLessThan=s.lt=function(t,e){return b(this,new M(t,e))<0},s.isLessThanOrEqualTo=s.lte=function(t,e){return-1===(e=b(this,new M(t,e)))||0===e},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&0==this.c[0]},s.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/h,u=t.e/h,f=o.c,d=t.c;if(!c||!u){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(c=m(c),u=m(u),f=f.slice(),a=c-u){for((s=a<0)?(a=-a,i=f):(u=c,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=l-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--u);return f[0]?K(t,f,u):(t.s=3==S?-1:1,t.c=[t.e=0],t)},s.modulo=s.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},s.multipliedBy=s.times=function(t,e){var r,n,i,s,o,a,c,u,f,d,g,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=m(E.e/h)+m(t.e/h),t.s*=E.s,(c=_.length)<(d=A.length)&&(b=_,_=A,A=b,i=c,c=d,d=i),i=c+d,b=[];i--;b.push(0));for(v=l,w=p,i=d;--i>=0;){for(r=0,g=A[i]%w,y=A[i]/w|0,s=i+(o=c);s>i;)r=((u=g*(u=_[--o]%w)+(a=y*u+(f=_[o]/w|0)*g)%w*w+b[s]+r)/v|0)+(a/w|0)+y*f,b[s--]=u%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},s.negated=function(){var t=new M(this);return t.s=-t.s||null,t},s.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/h,o=t.e/h,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?t:new M(a[0]?n:0*i)}if(s=m(s),o=m(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/l|0,a[e]=l===a[e]?0:a[e]%l;return i&&(a=[i].concat(a),++o),K(t,a,o)},s.precision=s.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return v(t,1,g),null==e?e=S:v(e,0,8),H(new M(s),t,e);if(!(r=s.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&&s.e+1>n&&(n=s.e+1),n},s.shiftedBy=function(t){return v(t,-9007199254740991,f),this.times("1e"+t)},s.squareRoot=s.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=y(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=m((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},s.toExponential=function(t,e){return null!=t&&(v(t,0,g),t++),B(this,t,e,1)},s.toFixed=function(t,e){return null!=t&&(v(t,0,g),t=t+this.e+1),B(this,t,e)},s.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),a=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(c&&(s=a,a=c,c=s,g-=s),a>0&&g>0){for(s=g%a||a,h=p.substr(0,s);s<g;s+=a)h+=l+p.substr(s,a);c>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},s.toFraction=function(t){var e,n,i,s,o,a,c,l,f,p,g,m,b=this,v=b.c;if(null!=t&&(!(c=new M(t)).isInteger()&&(c.c||1!==c.s)||c.lt(A)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+F(c));if(!v)return new M(b);for(e=new M(A),f=n=new M(A),i=l=new M(A),m=y(v),o=e.e=m.length-b.e-1,e.c[0]=d[(a=o%h)<0?h+a:a],t=!t||c.comparedTo(e)>0?o>0?e:f:c,a=x,x=1/0,c=new M(m),l.c[0]=0;p=r(c,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,f=l.plus(p.times(s=f)),l=s,e=c.minus(p.times(s=e)),c=s;return s=r(t.minus(n),i,0,1),l=l.plus(s.times(f)),n=n.plus(s.times(i)),l.s=f.s=b.s,g=r(f,i,o*=2,S).minus(b).abs().comparedTo(r(l,n,o,S).minus(b).abs())<1?[f,i]:[l,n],x=a,g},s.toNumber=function(){return+F(this)},s.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},s.toPrecision=function(t,e){return null!=t&&v(t,1,g),B(this,t,e,2)},s.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?E(y(r.c),s):_(y(r.c),s,"0"):(v(t,2,C.length,"Base"),e=n(_(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},s.valueOf=s.toJSON=function(){return F(this)},s._isBigNumber=!0,null!=e&&M.set(e);return M}(),o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=1e14,h=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function m(t){var e=0|t;return t>0||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=h-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function b(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function w(t){var e=t.c.length-1;return m(t.e/h)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function _(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const A=s;var O=r(6571),S=r(1032),T=r(3156),P=r(404),R=r(1188),x=void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},I=[],N=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,L=!1;function C(){L=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)I[e]=t[e],N[t.charCodeAt(e)]=e;N["-".charCodeAt(0)]=62,N["_".charCodeAt(0)]=63}function M(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[63&t]}function B(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(M(n));return i.join("")}function D(t){var e;L||C();for(var r=t.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(B(t,a,a+o>c?c:a+o));return 1===n?(e=t[r-1],i+=I[e>>2],i+=I[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=I[e>>10],i+=I[e>>4&63],i+=I[e<<2&63],i+="="),s.push(i),s.join("")}function U(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,h=r?i-1:0,f=r?-1:1,d=t[e+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[e+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+h],h+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)}function K(t,e,r,n,i,s){var o,a,c,u=8*s-i-1,l=(1<<u)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(o++,c/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}var H={}.toString,F=Array.isArray||function(t){return"[object Array]"==H.call(t)};function G(){return j.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function V(t,e){if(G()<e)throw new RangeError("Invalid typed array length");return j.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=j.prototype:(null===t&&(t=new j(e)),t.length=e),t}function j(t,e,r){if(!(j.TYPED_ARRAY_SUPPORT||this instanceof j))return new j(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return q(this,t)}return $(this,t,e,r)}function $(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);j.TYPED_ARRAY_SUPPORT?(t=e).__proto__=j.prototype:t=W(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!j.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|X(e,r);t=V(t,n);var i=t.write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(Y(e)){var r=0|Z(e.length);return 0===(t=V(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?V(t,0):W(t,e);if("Buffer"===e.type&&F(e.data))return W(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function z(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function q(t,e){if(z(e),t=V(t,e<0?0:0|Z(e)),!j.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function W(t,e){var r=e.length<0?0:0|Z(e.length);t=V(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function Z(t){if(t>=G())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+G().toString(16)+" bytes");return 0|t}function Y(t){return!(null==t||!t._isBuffer)}function X(t,e){if(Y(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return St(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Tt(t).length;default:if(n)return St(t).length;e=(""+e).toLowerCase(),n=!0}}function J(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return dt(this,e,r);case"utf8":case"utf-8":return ut(this,e,r);case"ascii":return ht(this,e,r);case"latin1":case"binary":return ft(this,e,r);case"base64":return ct(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Q(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function tt(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=j.from(e,n)),Y(e))return 0===e.length?-1:et(t,e,r,n,i);if("number"==typeof e)return e&=255,j.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):et(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function et(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var l=-1;for(s=r;s<a;s++)if(u(t,s)===u(e,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===c)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var h=!0,f=0;f<c;f++)if(u(t,s+f)!==u(e,f)){h=!1;break}if(h)return s}return-1}function rt(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function nt(t,e,r,n){return Pt(St(e,t.length-r),t,r,n)}function it(t,e,r,n){return Pt(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function st(t,e,r,n){return it(t,e,r,n)}function ot(t,e,r,n){return Pt(Tt(e),t,r,n)}function at(t,e,r,n){return Pt(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)n=(r=t.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function ct(t,e,r){return 0===e&&r===t.length?D(t):D(t.slice(e,r))}function ut(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,c,u=t[i],l=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(s=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(t){var e=t.length;if(e<=lt)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=lt));return r}(n)}j.TYPED_ARRAY_SUPPORT=void 0===x.TYPED_ARRAY_SUPPORT||x.TYPED_ARRAY_SUPPORT,G(),j.poolSize=8192,j._augment=function(t){return t.__proto__=j.prototype,t},j.from=function(t,e,r){return $(null,t,e,r)},j.TYPED_ARRAY_SUPPORT&&(j.prototype.__proto__=Uint8Array.prototype,j.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&j[Symbol.species]),j.alloc=function(t,e,r){return function(t,e,r,n){return z(e),e<=0?V(t,e):void 0!==r?"string"==typeof n?V(t,e).fill(r,n):V(t,e).fill(r):V(t,e)}(null,t,e,r)},j.allocUnsafe=function(t){return q(null,t)},j.allocUnsafeSlow=function(t){return q(null,t)},j.isBuffer=function(t){return null!=t&&(!!t._isBuffer||Rt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Rt(t.slice(0,0))}(t))},j.compare=function(t,e){if(!Y(t)||!Y(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},j.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},j.concat=function(t,e){if(!F(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return j.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=j.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var s=t[r];if(!Y(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},j.byteLength=X,j.prototype._isBuffer=!0,j.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Q(this,e,e+1);return this},j.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Q(this,e,e+3),Q(this,e+1,e+2);return this},j.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Q(this,e,e+7),Q(this,e+1,e+6),Q(this,e+2,e+5),Q(this,e+3,e+4);return this},j.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?ut(this,0,t):J.apply(this,arguments)},j.prototype.equals=function(t){if(!Y(t))throw new TypeError("Argument must be a Buffer");return this===t||0===j.compare(this,t)},j.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},j.prototype.compare=function(t,e,r,n,i){if(!Y(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),c=this.slice(n,i),u=t.slice(e,r),l=0;l<a;++l)if(c[l]!==u[l]){s=c[l],o=u[l];break}return s<o?-1:o<s?1:0},j.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},j.prototype.indexOf=function(t,e,r){return tt(this,t,e,r,!0)},j.prototype.lastIndexOf=function(t,e,r){return tt(this,t,e,r,!1)},j.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return rt(this,t,e,r);case"utf8":case"utf-8":return nt(this,t,e,r);case"ascii":return it(this,t,e,r);case"latin1":case"binary":return st(this,t,e,r);case"base64":return ot(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return at(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var lt=4096;function ht(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function ft(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function dt(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=Ot(t[s]);return i}function pt(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function gt(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function mt(t,e,r,n,i,s){if(!Y(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function yt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function bt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function vt(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function wt(t,e,r,n,i){return i||vt(t,0,r,4),K(t,e,r,n,23,4),r+4}function Et(t,e,r,n,i){return i||vt(t,0,r,8),K(t,e,r,n,52,8),r+8}j.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),j.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=j.prototype;else{var i=e-t;r=new j(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},j.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},j.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},j.prototype.readUInt8=function(t,e){return e||gt(t,1,this.length),this[t]},j.prototype.readUInt16LE=function(t,e){return e||gt(t,2,this.length),this[t]|this[t+1]<<8},j.prototype.readUInt16BE=function(t,e){return e||gt(t,2,this.length),this[t]<<8|this[t+1]},j.prototype.readUInt32LE=function(t,e){return e||gt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},j.prototype.readUInt32BE=function(t,e){return e||gt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},j.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},j.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||gt(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},j.prototype.readInt8=function(t,e){return e||gt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},j.prototype.readInt16LE=function(t,e){e||gt(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},j.prototype.readInt16BE=function(t,e){e||gt(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},j.prototype.readInt32LE=function(t,e){return e||gt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},j.prototype.readInt32BE=function(t,e){return e||gt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},j.prototype.readFloatLE=function(t,e){return e||gt(t,4,this.length),U(this,t,!0,23,4)},j.prototype.readFloatBE=function(t,e){return e||gt(t,4,this.length),U(this,t,!1,23,4)},j.prototype.readDoubleLE=function(t,e){return e||gt(t,8,this.length),U(this,t,!0,52,8)},j.prototype.readDoubleBE=function(t,e){return e||gt(t,8,this.length),U(this,t,!1,52,8)},j.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},j.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},j.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,1,255,0),j.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},j.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yt(this,t,e,!0),e+2},j.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yt(this,t,e,!1),e+2},j.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):bt(this,t,e,!0),e+4},j.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):bt(this,t,e,!1),e+4},j.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);mt(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o|0)-a&255;return e+r},j.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);mt(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o|0)-a&255;return e+r},j.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,1,127,-128),j.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},j.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yt(this,t,e,!0),e+2},j.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yt(this,t,e,!1),e+2},j.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,2147483647,-2147483648),j.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):bt(this,t,e,!0),e+4},j.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||mt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),j.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):bt(this,t,e,!1),e+4},j.prototype.writeFloatLE=function(t,e,r){return wt(this,t,e,!0,r)},j.prototype.writeFloatBE=function(t,e,r){return wt(this,t,e,!1,r)},j.prototype.writeDoubleLE=function(t,e,r){return Et(this,t,e,!0,r)},j.prototype.writeDoubleBE=function(t,e,r){return Et(this,t,e,!1,r)},j.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!j.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},j.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!j.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=Y(t)?t:St(new j(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var _t,At=/[^+\/0-9A-Za-z-_]/g;function Ot(t){return t<16?"0"+t.toString(16):t.toString(16)}function St(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function Tt(t){return function(t){var e,r,n,i,s,o;L||C();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===t[a-2]?2:"="===t[a-1]?1:0,o=new k(3*a/4-s),n=s>0?a-4:a;var c=0;for(e=0,r=0;e<n;e+=4,r+=3)i=N[t.charCodeAt(e)]<<18|N[t.charCodeAt(e+1)]<<12|N[t.charCodeAt(e+2)]<<6|N[t.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=255&i;return 2===s?(i=N[t.charCodeAt(e)]<<2|N[t.charCodeAt(e+1)]>>4,o[c++]=255&i):1===s&&(i=N[t.charCodeAt(e)]<<10|N[t.charCodeAt(e+1)]<<4|N[t.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=255&i),o}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(At,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Pt(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Rt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(t){t.BlockHash="B",t.OperationHash="o",t.OperationListHash="Lo",t.OperationListListHash="LLo",t.ProtocolHash="P",t.ContextHash="Co",t.BlockMetadataHash="bm",t.OperationMetadataHash="r",t.OperationMetadataListHash="Lr",t.OperationMetadataListListHash="LLr",t.Ed25519PublicKeyHash="tz1",t.Secp256k1PublicKeyHash="tz2",t.P256PublicKeyHash="tz3",t.ContractHash="KT1",t.BlindedPublicKeyHash="btz1",t.BLS12_381PublicKeyHash="tz4",t.TXRollupAddress="txr1",t.ZkRollupHash="epx1",t.ScRollupHash="scr1",t.SmartRollupHash="sr1",t.CryptoboxPublicKeyHash="id",t.Ed25519Seed="edsk",t.Ed25519PublicKey="edpk",t.Secp256k1SecretKey="spsk",t.P256SecretKey="p2sk",t.BLS12_381SecretKey="BLsk",t.ValueHash="vh",t.CycleNonce="nce",t.ScriptExpr="expr",t.InboxHash="txi",t.MessageHash="txm",t.CommitmentHash="txc",t.MessageResultHash="txmr",t.MessageResultListHash="txM",t.WithdrawListHash="txw",t.ScRollupStateHash="scs1",t.ScRollupCommitmentHash="scc1",t.SmartRollupStateHash="srs1",t.SmartRollupCommitmentHash="src1",t.Ed25519EncryptedSeed="edesk",t.Secp256k1EncryptedSecretKey="spesk",t.P256EncryptedSecretKey="p2esk",t.BLS12_381EncryptedSecretKey="BLesk",t.Secp256k1EncryptedScalar="seesk",t.Secp256k1PublicKey="sppk",t.P256PublicKey="p2pk",t.Secp256k1Scalar="SSp",t.Secp256k1Element="GSp",t.Ed25519SecretKey="_edsk",t.Ed25519Signature="edsig",t.Secp256k1Signature="spsig1",t.P256Signature="p2sig",t.GenericSignature="sig",t.ChainID="Net",t.SaplingSpendingKey="sask",t.EncryptedSaplingSpendingKey="_sask",t.SaplingAddress="zet1",t.GenericAggregateSignature="asig",t.BLS12_381Signature="BLsig",t.BLS12_381PublicKey="BLpk",t.SlotHeader="sh"}(_t||(_t={}));const xt={[_t.BlockHash]:new Uint8Array([1,52]),[_t.OperationHash]:new Uint8Array([5,116]),[_t.OperationListHash]:new Uint8Array([133,233]),[_t.OperationListListHash]:new Uint8Array([29,159,109]),[_t.ProtocolHash]:new Uint8Array([2,170]),[_t.ContextHash]:new Uint8Array([79,199]),[_t.BlockMetadataHash]:new Uint8Array([234,249]),[_t.OperationMetadataHash]:new Uint8Array([5,183]),[_t.OperationMetadataListHash]:new Uint8Array([134,39]),[_t.OperationMetadataListListHash]:new Uint8Array([29,159,182]),[_t.Ed25519PublicKeyHash]:new Uint8Array([6,161,159]),[_t.Secp256k1PublicKeyHash]:new Uint8Array([6,161,161]),[_t.P256PublicKeyHash]:new Uint8Array([6,161,164]),[_t.ContractHash]:new Uint8Array([2,90,121]),[_t.BlindedPublicKeyHash]:new Uint8Array([1,2,49,223]),[_t.BLS12_381PublicKeyHash]:new Uint8Array([6,161,166]),[_t.TXRollupAddress]:new Uint8Array([1,128,120,31]),[_t.ZkRollupHash]:new Uint8Array([1,23,224,125]),[_t.ScRollupHash]:new Uint8Array([1,118,132,217]),[_t.SmartRollupHash]:new Uint8Array([6,124,117]),[_t.CryptoboxPublicKeyHash]:new Uint8Array([153,103]),[_t.Ed25519Seed]:new Uint8Array([13,15,58,7]),[_t.Ed25519PublicKey]:new Uint8Array([13,15,37,217]),[_t.Secp256k1SecretKey]:new Uint8Array([17,162,224,201]),[_t.P256SecretKey]:new Uint8Array([16,81,238,189]),[_t.BLS12_381SecretKey]:new Uint8Array([3,150,192,40]),[_t.ValueHash]:new Uint8Array([1,106,242]),[_t.CycleNonce]:new Uint8Array([69,220,169]),[_t.ScriptExpr]:new Uint8Array([13,44,64,27]),[_t.InboxHash]:new Uint8Array([79,148,196]),[_t.MessageHash]:new Uint8Array([79,149,30]),[_t.CommitmentHash]:new Uint8Array([79,148,17]),[_t.MessageResultHash]:new Uint8Array([18,7,206,87]),[_t.MessageResultListHash]:new Uint8Array([79,146,82]),[_t.WithdrawListHash]:new Uint8Array([79,150,72]),[_t.ScRollupStateHash]:new Uint8Array([17,144,122,202]),[_t.ScRollupCommitmentHash]:new Uint8Array([17,144,21,100]),[_t.SmartRollupStateHash]:new Uint8Array([17,165,235,240]),[_t.SmartRollupCommitmentHash]:new Uint8Array([17,165,134,138]),[_t.Ed25519EncryptedSeed]:new Uint8Array([7,90,60,179,41]),[_t.Secp256k1EncryptedSecretKey]:new Uint8Array([9,237,241,174,150]),[_t.P256EncryptedSecretKey]:new Uint8Array([9,48,57,115,171]),[_t.BLS12_381EncryptedSecretKey]:new Uint8Array([2,5,30,53,25]),[_t.Secp256k1EncryptedScalar]:new Uint8Array([1,131,36,86,248]),[_t.Secp256k1PublicKey]:new Uint8Array([3,254,226,86]),[_t.P256PublicKey]:new Uint8Array([3,178,139,127]),[_t.Secp256k1Scalar]:new Uint8Array([38,248,136]),[_t.Secp256k1Element]:new Uint8Array([5,92,0]),[_t.Ed25519SecretKey]:new Uint8Array([43,246,78,7]),[_t.Ed25519Signature]:new Uint8Array([9,245,205,134,18]),[_t.Secp256k1Signature]:new Uint8Array([13,115,101,19,63]),[_t.P256Signature]:new Uint8Array([54,240,44,52]),[_t.GenericSignature]:new Uint8Array([4,130,43]),[_t.ChainID]:new Uint8Array([87,82,0]),[_t.SaplingSpendingKey]:new Uint8Array([11,237,20,92]),[_t.EncryptedSaplingSpendingKey]:new Uint8Array([11,237,20,92]),[_t.SaplingAddress]:new Uint8Array([18,71,40,223]),[_t.GenericAggregateSignature]:new Uint8Array([2,75,234,101]),[_t.BLS12_381Signature]:new Uint8Array([40,171,64,207]),[_t.BLS12_381PublicKey]:new Uint8Array([6,149,135,204]),[_t.SlotHeader]:new Uint8Array([2,116,180])},It={[_t.BlockHash]:32,[_t.OperationHash]:32,[_t.OperationListHash]:32,[_t.OperationListListHash]:32,[_t.ProtocolHash]:32,[_t.ContextHash]:32,[_t.BlockMetadataHash]:32,[_t.OperationMetadataHash]:32,[_t.OperationMetadataListHash]:32,[_t.OperationMetadataListListHash]:32,[_t.Ed25519PublicKeyHash]:20,[_t.Secp256k1PublicKeyHash]:20,[_t.P256PublicKeyHash]:20,[_t.ContractHash]:20,[_t.BlindedPublicKeyHash]:20,[_t.BLS12_381PublicKeyHash]:20,[_t.TXRollupAddress]:20,[_t.ZkRollupHash]:20,[_t.ScRollupHash]:20,[_t.SmartRollupHash]:20,[_t.CryptoboxPublicKeyHash]:16,[_t.Ed25519Seed]:32,[_t.Ed25519PublicKey]:32,[_t.Secp256k1SecretKey]:32,[_t.P256SecretKey]:32,[_t.BLS12_381SecretKey]:32,[_t.ValueHash]:32,[_t.CycleNonce]:32,[_t.ScriptExpr]:32,[_t.InboxHash]:32,[_t.MessageHash]:32,[_t.CommitmentHash]:32,[_t.MessageResultHash]:32,[_t.MessageResultListHash]:32,[_t.WithdrawListHash]:32,[_t.ScRollupStateHash]:32,[_t.ScRollupCommitmentHash]:32,[_t.SmartRollupStateHash]:32,[_t.SmartRollupCommitmentHash]:32,[_t.Ed25519EncryptedSeed]:56,[_t.Secp256k1EncryptedSecretKey]:56,[_t.P256EncryptedSecretKey]:56,[_t.BLS12_381EncryptedSecretKey]:56,[_t.Secp256k1EncryptedScalar]:60,[_t.Secp256k1PublicKey]:33,[_t.P256PublicKey]:33,[_t.Secp256k1Scalar]:33,[_t.Secp256k1Element]:33,[_t.Ed25519SecretKey]:64,[_t.Ed25519Signature]:64,[_t.Secp256k1Signature]:64,[_t.P256Signature]:64,[_t.GenericSignature]:64,[_t.ChainID]:4,[_t.SaplingSpendingKey]:169,[_t.EncryptedSaplingSpendingKey]:193,[_t.SaplingAddress]:43,[_t.GenericAggregateSignature]:96,[_t.BLS12_381Signature]:96,[_t.BLS12_381PublicKey]:48,[_t.SlotHeader]:48};function Nt(t,e=""){if("number"!=typeof t){throw new TypeError(`${e&&`"${e}" `}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){throw new RangeError(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}}function kt(t,e,r=""){const n=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&"BYTES_PER_ELEMENT"in i&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;if(!n||o&&s!==e){const i=(r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(n?`length=${s}`:"type="+typeof t);if(!n)throw new TypeError(i);throw new RangeError(i)}return t}function Lt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ct(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Bt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Dt(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const Ut=Bt?t=>t:t=>Dt(t)>>>0;const Kt=Bt?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=Dt(t[e]);return t};function Ht(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}const Ft=Uint8Array.from([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,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]),Gt=BigInt(2**32-1),Vt=BigInt(32);const jt=(t,e,r)=>t>>>r|e<<32-r,$t=(t,e,r)=>t<<32-r|e>>>r,zt=(t,e,r)=>t>>>r-32|e<<64-r;function qt(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const Wt=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Zt=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Yt=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xt=new Uint32Array(32);function Jt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Xt[2*t],u=Xt[2*t+1],l=Xt[2*e],h=Xt[2*e+1],f=Xt[2*r],d=Xt[2*r+1],p=Xt[2*n],g=Xt[2*n+1],m=Wt(c,l,o);var y,b;u=Zt(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:(b=p,b),Dl:(y=g,y)}),({h:d,l:f}=qt(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:jt(h,l,24),Bl:$t(h,l,24)}),Xt[2*t]=c,Xt[2*t+1]=u,Xt[2*e]=l,Xt[2*e+1]=h,Xt[2*r]=f,Xt[2*r+1]=d,Xt[2*n]=p,Xt[2*n+1]=g}function Qt(t,e,r,n,i,s){const o=i[s],a=i[s+1];let c=Xt[2*t],u=Xt[2*t+1],l=Xt[2*e],h=Xt[2*e+1],f=Xt[2*r],d=Xt[2*r+1],p=Xt[2*n],g=Xt[2*n+1],m=Wt(c,l,o);var y,b,v;u=Zt(m,u,h,a),c=0|m,({Dh:g,Dl:p}={Dh:g^u,Dl:p^c}),({Dh:g,Dl:p}={Dh:jt(g,p,16),Dl:$t(g,p,16)}),({h:d,l:f}=qt(d,f,g,p)),({Bh:h,Bl:l}={Bh:h^d,Bl:l^f}),({Bh:h,Bl:l}={Bh:(y=h,b=l,v=63,y<<64-v|b>>>v-32),Bl:zt(h,l,63)}),Xt[2*t]=c,Xt[2*t+1]=u,Xt[2*e]=l,Xt[2*e+1]=h,Xt[2*r]=f,Xt[2*r+1]=d,Xt[2*n]=p,Xt[2*n+1]=g}class te{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;canXOF=!1;constructor(t,e){Nt(t),Nt(e),this.blockLen=t,this.outputLen=e,this.buffer=new Uint8Array(t),this.buffer32=Ct(this.buffer)}update(t){Lt(this),kt(t);const{blockLen:e,buffer:r,buffer32:n}=this,i=t.length,s=t.byteOffset,o=t.buffer;for(let a=0;a<i;){this.pos===e&&(Kt(n),this.compress(n,0,!1),Kt(n),this.pos=0);const c=Math.min(e-this.pos,i-a),u=s+a;if(c===e&&!(u%4)&&a+c<i){const t=new Uint32Array(o,u,Math.floor((i-a)/4));Kt(t);for(let r=0;a+e<i;r+=n.length,a+=e)this.length+=e,this.compress(t,r,!1);Kt(t);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,this.length+=c,a+=c}return this}digestInto(t){Lt(this),function(t,e){kt(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}(t,this);const{pos:e,buffer32:r}=this;if(this.finished=!0,Mt(this.buffer.subarray(e)),Kt(r),this.compress(r,0,!0),Kt(r),3&t.byteOffset)throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got '+t.byteOffset);const n=this.get(),i=Ct(t),s=Math.floor(this.outputLen/4);for(let t=0;t<s;t++)i[t]=Ut(n[t]);const o=this.outputLen%4;if(!o)return;const a=4*s,c=n[s];for(let e=0;e<o;e++)t[a+e]=c>>>8*e}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){const{buffer:e,length:r,finished:n,destroyed:i,outputLen:s,pos:o}=this;return t||=new this.constructor({dkLen:s}),t.set(...this.get()),t.buffer.set(e),t.destroyed=i,t.finished=n,t.length=r,t.pos=o,t.outputLen=s,t}clone(){return this._cloneInto()}}class ee extends te{v0l=0|Yt[0];v0h=0|Yt[1];v1l=0|Yt[2];v1h=0|Yt[3];v2l=0|Yt[4];v2h=0|Yt[5];v3l=0|Yt[6];v3h=0|Yt[7];v4l=0|Yt[8];v4h=0|Yt[9];v5l=0|Yt[10];v5h=0|Yt[11];v6l=0|Yt[12];v6h=0|Yt[13];v7l=0|Yt[14];v7h=0|Yt[15];constructor(t={}){const e=void 0===t.dkLen?64:t.dkLen;super(128,e),function(t,e={},r,n,i){if(Nt(r),t<=0||t>r)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=e;if(void 0!==s&&(s.length<1||s.length>r))throw new Error('"key" expected to be undefined or of length=1..'+r);void 0!==o&&kt(o,n,"salt"),void 0!==a&&kt(a,i,"personalization")}(e,t,64,16,16);let{key:r,personalization:n,salt:i}=t,s=0;if(void 0!==r&&(kt(r,void 0,"key"),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,void 0!==i){kt(i,void 0,"salt");const t=Ct(i);this.v4l^=Ut(t[0]),this.v4h^=Ut(t[1]),this.v5l^=Ut(t[2]),this.v5h^=Ut(t[3])}if(void 0!==n){kt(n,void 0,"personalization");const t=Ct(n);this.v6l^=Ut(t[0]),this.v6h^=Ut(t[1]),this.v7l^=Ut(t[2]),this.v7h^=Ut(t[3])}if(void 0!==r){const t=new Uint8Array(this.blockLen);t.set(r),this.update(t)}}get(){let{v0l:t,v0h:e,v1l:r,v1h:n,v2l:i,v2h:s,v3l:o,v3h:a,v4l:c,v4h:u,v5l:l,v5h:h,v6l:f,v6h:d,v7l:p,v7h:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.v0l=0|t,this.v0h=0|e,this.v1l=0|r,this.v1h=0|n,this.v2l=0|i,this.v2h=0|s,this.v3l=0|o,this.v3h=0|a,this.v4l=0|c,this.v4h=0|u,this.v5l=0|l,this.v5h=0|h,this.v6l=0|f,this.v6h=0|d,this.v7l=0|p,this.v7h=0|g}compress(t,e,r){this.get().forEach((t,e)=>Xt[e]=t),Xt.set(Yt,16);let{h:n,l:i}=function(t,e=!1){return e?{h:Number(t&Gt),l:Number(t>>Vt&Gt)}:{h:0|Number(t>>Vt&Gt),l:0|Number(t&Gt)}}(BigInt(this.length));Xt[24]=Yt[8]^i,Xt[25]=Yt[9]^n,r&&(Xt[28]=~Xt[28],Xt[29]=~Xt[29]);let s=0;const o=Ft;for(let r=0;r<12;r++)Jt(0,4,8,12,t,e+2*o[s++]),Qt(0,4,8,12,t,e+2*o[s++]),Jt(1,5,9,13,t,e+2*o[s++]),Qt(1,5,9,13,t,e+2*o[s++]),Jt(2,6,10,14,t,e+2*o[s++]),Qt(2,6,10,14,t,e+2*o[s++]),Jt(3,7,11,15,t,e+2*o[s++]),Qt(3,7,11,15,t,e+2*o[s++]),Jt(0,5,10,15,t,e+2*o[s++]),Qt(0,5,10,15,t,e+2*o[s++]),Jt(1,6,11,12,t,e+2*o[s++]),Qt(1,6,11,12,t,e+2*o[s++]),Jt(2,7,8,13,t,e+2*o[s++]),Qt(2,7,8,13,t,e+2*o[s++]),Jt(3,4,9,14,t,e+2*o[s++]),Qt(3,4,9,14,t,e+2*o[s++]);this.v0l^=Xt[0]^Xt[16],this.v0h^=Xt[1]^Xt[17],this.v1l^=Xt[2]^Xt[18],this.v1h^=Xt[3]^Xt[19],this.v2l^=Xt[4]^Xt[20],this.v2h^=Xt[5]^Xt[21],this.v3l^=Xt[6]^Xt[22],this.v3h^=Xt[7]^Xt[23],this.v4l^=Xt[8]^Xt[24],this.v4h^=Xt[9]^Xt[25],this.v5l^=Xt[10]^Xt[26],this.v5h^=Xt[11]^Xt[27],this.v6l^=Xt[12]^Xt[28],this.v6h^=Xt[13]^Xt[29],this.v7l^=Xt[14]^Xt[30],this.v7h^=Xt[15]^Xt[31],Mt(Xt)}destroy(){this.destroyed=!0,Mt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const re=Ht(t=>new ee(t)),ne=A,ie=[_t.P256PublicKeyHash,_t.Secp256k1PublicKeyHash,_t.Ed25519PublicKeyHash,_t.BLS12_381PublicKeyHash,_t.ContractHash,_t.SmartRollupHash],se=[_t.P256PublicKey,_t.Secp256k1PublicKey,_t.Ed25519PublicKey,_t.BLS12_381PublicKey],oe=[_t.P256PublicKeyHash,_t.Secp256k1PublicKeyHash,_t.Ed25519PublicKeyHash,_t.BLS12_381PublicKeyHash],ae=[_t.P256Signature,_t.Secp256k1Signature,_t.Ed25519Signature,_t.BLS12_381Signature,_t.GenericSignature];function ce(t,e,r){const n=(()=>{try{return i().decode(t)}catch(t){throw t instanceof Error?t.message.includes("checksum")?new O.ParameterValidationError(O.ValidationResult.INVALID_CHECKSUM):new O.ParameterValidationError(O.ValidationResult.INVALID_ENCODING):t}})();let s;for(s in _t){const t=_t[s],i=xt[t];if(n.length===i.length+It[t]&&n.slice(0,i.length).every((t,e)=>t==i[e])){if(void 0!==e&&e.indexOf(t)<0)throw new O.ParameterValidationError(O.ValidationResult.PREFIX_NOT_ALLOWED);return r?n.slice(i.length):[n.slice(i.length),t]}}throw new O.ParameterValidationError(O.ValidationResult.NO_PREFIX_MATCHED)}function ue(t,e){const[r,n]=ce(t,se);let i;switch(n){case _t.Ed25519PublicKey:i=0;break;case _t.Secp256k1PublicKey:i=1;break;case _t.P256PublicKey:i=2;break;case _t.BLS12_381PublicKey:i=3;break;default:throw new O.InvalidKeyError(O.ValidationResult.NO_PREFIX_MATCHED)}const s=new Uint8Array(r.length+1);return s[0]=i,s.set(r,1),void 0!==e&&"array"===e?s:Oe(s)}function le(t,e){const[r,n]=ce(t,oe),i=new Uint8Array(21);let s;switch(n){case _t.Ed25519PublicKeyHash:s=0;break;case _t.Secp256k1PublicKeyHash:s=1;break;case _t.P256PublicKeyHash:s=2;break;case _t.BLS12_381PublicKeyHash:s=3;break;default:throw new O.InvalidAddressError(t,O.ValidationResult.NO_PREFIX_MATCHED)}return i[0]=s,i.set(r,1),void 0!==e&&"array"===e?i:Oe(i)}function he(t,e){const[r,n]=ce(t);if(n!==_t.BLS12_381PublicKeyHash)throw new O.InvalidKeyError(O.ValidationResult.NO_PREFIX_MATCHED);return void 0!==e&&"array"===e?r:Oe(r)}function fe(t,e){const r=t.indexOf("%");r>=0&&(t=t.slice(0,r));const[n,i]=ce(t,ie),s=new Uint8Array(22);if(i===_t.ContractHash||i===_t.SmartRollupHash||i===_t.ZkRollupHash){let t;switch(i){case _t.ContractHash:t=1;break;case _t.SmartRollupHash:t=3;break;case _t.ZkRollupHash:t=4}s[0]=t,s.set(n,1)}else{let e;switch(i){case _t.Ed25519PublicKeyHash:e=0;break;case _t.Secp256k1PublicKeyHash:e=1;break;case _t.P256PublicKeyHash:e=2;break;case _t.BLS12_381PublicKeyHash:e=3;break;default:throw new O.InvalidAddressError(t,O.ValidationResult.NO_PREFIX_MATCHED)}s[0]=0,s[1]=e,s.set(n,2)}return void 0!==e&&"array"===e?s:Oe(s)}function de(t){const[e,r]=ce(t);let n;switch(r){case _t.P256PublicKey:n=_t.P256PublicKeyHash;break;case _t.Secp256k1PublicKey:n=_t.Secp256k1PublicKeyHash;break;case _t.Ed25519PublicKey:n=_t.Ed25519PublicKeyHash;break;case _t.BLS12_381PublicKey:n=_t.BLS12_381PublicKeyHash;break;default:throw new O.InvalidPublicKeyError(t,O.ValidationResult.NO_PREFIX_MATCHED)}return pe(re(e,{dkLen:20}),n)}function pe(t,e){const r="string"==typeof t?Ee(t):t,n=xt[e],s=new Uint8Array(n.length+r.length);return s.set(n),s.set(r,n.length),i().encode(j.from(s.buffer,s.byteOffset,s.byteLength))}function ge(t){let e,r;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:r=_t.Ed25519PublicKey;break;case 1:r=_t.Secp256k1PublicKey;break;case 2:r=_t.P256PublicKey;break;case 3:r=_t.BLS12_381PublicKey;break;default:throw new Error("invalid address format")}return pe(e.slice(1),r)}function me(t){let e,r;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:r=_t.Ed25519PublicKeyHash;break;case 1:r=_t.Secp256k1PublicKeyHash;break;case 2:r=_t.P256PublicKeyHash;break;case 3:r=_t.BLS12_381PublicKeyHash;break;default:throw new Error("invalid address format")}return pe(e.slice(1,21),r)}function ye(t){let e;switch(e="string"==typeof t?Ee(t):t,e[0]){case 0:return me(e.slice(1));case 1:return pe(e.slice(1,21),_t.ContractHash);case 3:return pe(e.slice(1,21),_t.SmartRollupHash);case 4:return pe(e.slice(1,21),_t.ZkRollupHash);default:throw new Error("invalid address format")}}function be(t){return pe(t,_t.BLS12_381PublicKeyHash)}function ve(t){return pe(re(Ee(t),{dkLen:32}),_t.ScriptExpr)}function we(t){return pe(re(Ee(t),{dkLen:32}),_t.OperationHash)}function Ee(t){if((t=t.startsWith("0x")?t.slice(2):t).length%2!=0)throw new O.InvalidHexStringError(t,"Expecting even number of characters");if(!t.match(/^([\da-f]{2})*$/gi))throw new O.InvalidHexStringError(t,"Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'");const e=new Uint8Array(t.length/2);let r=0;for(let n=0;n<t.length;n+=2){const i=t.slice(n,n+2),s=parseInt(i,16);if(Number.isNaN(s))throw new O.InvalidHexStringError(t,"Only characters 0-9, a-f and A-F are expected. Optionally, it can be prefixed with '0x'");e[r++]=s}return e}function _e(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function Ae(t){let e=[];if(Object.prototype.hasOwnProperty.call(t,"prim"))"Pair"===t.prim?(e.push(Ae(t.args[0])),e=e.concat(Ae(t.args[1]))):"Elt"===t.prim?e={key:Ae(t.args[0]),val:Ae(t.args[1])}:"True"===t.prim?e=!0:"False"===t.prim&&(e=!1);else if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){const r=Ae(t[n]);void 0!==r.key?(Array.isArray(e)&&(e={keys:[],vals:[]}),e.keys.push(r.key),e.vals.push(r.val)):e.push(r)}}else e=Object.prototype.hasOwnProperty.call(t,"string")?t.string:Object.prototype.hasOwnProperty.call(t,"int")?parseInt(t.int,10):t;return e}function Oe(t){return Array.from(t).map(t=>(t>>4&15).toString(16)+(15&t).toString(16)).join("")}function Se(t){return j.from(t,"utf8").toString("hex")}function Te(t){return j.from(Ee(t)).toString("utf8")}function Pe(t){const e=Ne(t);if(!e.match(/^(0x)?([\da-f]{2})*$/gi))throw new O.InvalidHexStringError(t,"Expecting even number of characters: 0-9, a-z, A-Z, optionally prefixed with 0x");return j.from(e,"hex")}function Re(t,e=8){return j.from(Ie(t,e),"hex")}function xe(t,e=8){return j.from(Ie(t,e),"hex")}function Ie(t,e=8){if(new ne(t).isPositive()){const r=Math.ceil(e/4),n=t.toString(16);let i=n.length>=r?n.length:r;return i=i%2==0?i:i+1,function(t,e){const r="0";if(t.length>=e)return t;{const n=e-t.length;return r.repeat(n)+t}}(n,i)}return new ne(2).pow(e).minus(new ne(t).abs()).toString(16)}function Ne(t){return t.startsWith("0x")?t.slice(2):t}function ke(t){const e=t.indexOf("%");return e>=0?[t.slice(0,e),t.slice(e)]:[t,null]}function Le(t,e){let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];)r++;const n=r<t.length?t[r]:0,i=r<e.length?e[r]:0;return n<i?-1:n>i?1:0}function Ce(t,e){return Me(t,e)===O.ValidationResult.VALID}function Me(t,e){try{ce(t,e)}catch(t){return t instanceof O.ParameterValidationError&&void 0!==t.result?t.result:O.ValidationResult.OTHER}return O.ValidationResult.VALID}function Be(t){const[e]=ke(t??"");return Me(e,ie)}function De(t){return Me(t,[_t.ChainID])}function Ue(t){return Me(t,[_t.ContractHash])}function Ke(t){return Me(t,oe)}function He(t){return Me(t,ae)}function Fe(t){return Me(t,se)}function Ge(t){return Me(t,[_t.OperationHash])}function Ve(t){return Me(t,[_t.ProtocolHash])}function je(t){return Me(t,[_t.BlockHash])}function $e(t){return Me(t,[_t.SaplingSpendingKey])}function ze(t){return Me(t,[_t.SmartRollupHash])}const qe={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"},We="BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_",Ze="BLS_POP_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";function Ye(t,e,r,n,i){const[s,o]=(()=>{try{return ce(e,se)}catch(t){throw t instanceof O.ParameterValidationError?new O.InvalidPublicKeyError(e,t.result):t}})(),a=(()=>{try{const[t]=ce(r,ae);return t}catch(t){throw t instanceof O.ParameterValidationError?new O.InvalidSignatureError(r,t.result):t}})();let c;if(c="string"==typeof t?Ee(t):t,0===c.length)throw new O.InvalidMessageError(Oe(c),"can't be empty");if(void 0!==n&&(c=_e(n,c)),i)return function(t,e,r){try{const n=Xe.hash(e,Ze);return Xe.verify(t,n,r)}catch{return!1}}(a,c,s);switch(o){case _t.P256PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return P.s9.verify(t,n,r)}catch{return!1}}(a,c,s);case _t.Secp256k1PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return T.bI.verify(t,n,r)}catch{return!1}}(a,c,s);case _t.Ed25519PublicKey:return function(t,e,r){const n=re(e,{dkLen:32});try{return S.ev.verify(t,n,r)}catch{return!1}}(a,c,s);default:return function(t,e,r){try{const n=Xe.hash(e,We);return Xe.verify(t,n,r)}catch{return!1}}(a,c,s)}}const Xe=R.A.longSignatures;class Je extends O.ParameterValidationError{constructor(t,e){super(`The protocol hash '${t}' is invalid`,e),this.protocolHash=t,this.name="InvalidProtocolHashError",this.name=this.constructor.name}}class Qe extends O.UnsupportedActionError{constructor(t,e){super(`Unable to convert ${t} to a ${e}`),this.value=t,this.desiredType=e,this.name=this.constructor.name}}function tr(t){switch(t){case"tz":return 6;case"mtz":return 3;default:return 0}}function er(t="mutez",e="mutez",r){let n;try{n=new A(r)}catch{return r}return n.isNaN()?r:n.multipliedBy(Math.pow(10,tr(t))).dividedBy(Math.pow(10,tr(e)))}},268(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BATCH_KINDS=void 0;const n=r(3157);e.BATCH_KINDS=[n.OpKind.ACTIVATION,n.OpKind.ORIGINATION,n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET,n.OpKind.SMART_ROLLUP_ADD_MESSAGES,n.OpKind.SMART_ROLLUP_ORIGINATE,n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE]},5025(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCBatchProvider=e.OperationBatch=e.BATCH_KINDS=void 0;const n=r(2654),i=r(7669),s=r(3157),o=r(2403),a=r(6571),c=r(5605),u=r(3682);var l=r(268);Object.defineProperty(e,"BATCH_KINDS",{enumerable:!0,get:function(){return l.BATCH_KINDS}});class h extends c.Provider{constructor(t,e){super(t),this.estimator=e,this.operations=[],this.prepare=new u.PrepareProvider(this.context)}withTransfer(t){const e=(0,o.validateAddress)(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.to,e);return this.operations.push({kind:s.OpKind.TRANSACTION,...t}),this}withTransferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.destination,e);return this.operations.push({kind:s.OpKind.TRANSFER_TICKET,...t}),this}withContractCall(t,e={}){return this.withTransfer(t.toTransferParams(e))}withDelegation(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);const r=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.delegate,r);return this.operations.push({kind:s.OpKind.DELEGATION,...t}),this}withActivation({pkh:t,secret:e}){const r=(0,o.validateKeyHash)(t);if(r!==o.ValidationResult.VALID)throw new a.InvalidKeyHashError(t,r);return this.operations.push({kind:s.OpKind.ACTIVATION,pkh:t,secret:e}),this}withOrigination(t){return this.operations.push({kind:s.OpKind.ORIGINATION,...t}),this}withRegisterGlobalConstant(t){return this.operations.push({kind:s.OpKind.REGISTER_GLOBAL_CONSTANT,...t}),this}withIncreasePaidStorage(t){return this.operations.push({kind:s.OpKind.INCREASE_PAID_STORAGE,...t}),this}withUpdateConsensusKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");return this.operations.push({kind:s.OpKind.UPDATE_CONSENSUS_KEY,...t}),this}withUpdateCompanionKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e!==o.PrefixV2.BLS12_381PublicKey)throw new a.ProhibitedActionError("companion key must be a bls account");if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as companion key ");return this.operations.push({kind:s.OpKind.UPDATE_COMPANION_KEY,...t}),this}withSmartRollupAddMessages(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_ADD_MESSAGES,...t}),this}withSmartRollupOriginate(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_ORIGINATE,...t}),this}withSmartRollupExecuteOutboxMessage(t){return this.operations.push({kind:s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,...t}),this}async getRPCOp(t){switch(t.kind){case s.OpKind.TRANSACTION:return(0,n.createTransferOperation)({...t});case s.OpKind.ORIGINATION:return(0,n.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...t}));case s.OpKind.DELEGATION:return(0,n.createSetDelegateOperation)({...t});case s.OpKind.REGISTER_GLOBAL_CONSTANT:return(0,n.createRegisterGlobalConstantOperation)({...t});case s.OpKind.INCREASE_PAID_STORAGE:return(0,n.createIncreasePaidStorageOperation)({...t});case s.OpKind.UPDATE_CONSENSUS_KEY:return(0,n.createUpdateConsensusKeyOperation)({...t});case s.OpKind.UPDATE_COMPANION_KEY:return(0,n.createUpdateCompanionKeyOperation)({...t});case s.OpKind.TRANSFER_TICKET:return(0,n.createTransferTicketOperation)({...t});case s.OpKind.SMART_ROLLUP_ADD_MESSAGES:return(0,n.createSmartRollupAddMessagesOperation)({...t});case s.OpKind.SMART_ROLLUP_ORIGINATE:return(0,n.createSmartRollupOriginateOperation)({...t});case s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return(0,n.createSmartRollupExecuteOutboxMessageOperation)({...t});default:throw new a.InvalidOperationKindError(JSON.stringify(t.kind))}}with(t){for(const e of t)switch(e.kind){case s.OpKind.TRANSACTION:this.withTransfer(e);break;case s.OpKind.ORIGINATION:this.withOrigination(e);break;case s.OpKind.DELEGATION:this.withDelegation(e);break;case s.OpKind.ACTIVATION:this.withActivation(e);break;case s.OpKind.REGISTER_GLOBAL_CONSTANT:this.withRegisterGlobalConstant(e);break;case s.OpKind.INCREASE_PAID_STORAGE:this.withIncreasePaidStorage(e);break;case s.OpKind.TRANSFER_TICKET:this.withTransferTicket(e);break;case s.OpKind.SMART_ROLLUP_ADD_MESSAGES:this.withSmartRollupAddMessages(e);break;case s.OpKind.SMART_ROLLUP_ORIGINATE:this.withSmartRollupOriginate(e);break;case s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:this.withSmartRollupExecuteOutboxMessage(e);break;default:throw new a.InvalidOperationKindError(JSON.stringify(e.kind))}return this}async send(t){const e=await this.signer.publicKeyHash(),r=t&&t.source||e,n=await this.estimator.batch(this.operations);n.length!==this.operations.length&&n.shift();const s=await this.prepare.batch(this.operations,n),o=await this.forge(s),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new i.BatchOperation(a,s.opOb.contents,r,u,l,c)}}e.OperationBatch=h;e.RPCBatchProvider=class{constructor(t,e){this.context=t,this.estimator=e}batch(t){const e=new h(this.context,this.estimator);return Array.isArray(t)&&e.with(t),e}}},5283(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getRevealFeeInternal=e.getRevealFee=e.getRevealGasLimit=e.ChainIds=e.protocols=e.Protocols=e.COST_PER_BYTE=e.ORIGINATION_SIZE=e.REVEAL_STORAGE_LIMIT=void 0;const r=171,n=157,i=447,s=3252,o=278,a=277,c=306,u=736;var l,h;e.REVEAL_STORAGE_LIMIT=0,e.ORIGINATION_SIZE=257,e.COST_PER_BYTE=250,function(t){t.Pt24m4xi="Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd",t.PsBABY5H="PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU",t.PsBabyM1="PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS",t.PsCARTHA="PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb",t.PsDELPH1="PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo",t.PtEdo2Zk="PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA",t.PsFLorena="PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i",t.PtGRANADs="PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV",t.PtHangz2="PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",t.PsiThaCa="PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP",t.Psithaca2="Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A",t.PtJakart2="PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY",t.PtKathman="PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg",t.PtLimaPtL="PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW",t.PtMumbaii="PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc",t.PtMumbai2="PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1",t.PtNairobi="PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf",t.ProxfordY="ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH",t.PtParisBx="PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ",t.PsParisCZ="PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi",t.PsQuebecn="PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg",t.PsRiotuma="PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7",t.PtSeouLou="PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh",t.PtTALLiNt="PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu",t.PsUshuai9="PsUshuai9QapM5TGj1JpuVGkdxz5GykdnEvS6Rh8SUVrARvZLCY",t.ProtoALpha="ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"}(l||(e.Protocols=l={})),e.protocols={"004":[l.Pt24m4xi],"005":[l.PsBABY5H,l.PsBabyM1],"006":[l.PsCARTHA],"007":[l.PsDELPH1],"008":[l.PtEdo2Zk],"009":[l.PsFLorena],"010":[l.PtGRANADs],"011":[l.PtHangz2],"012":[l.PsiThaCa,l.Psithaca2],"013":[l.PtJakart2],"014":[l.PtKathman],"015":[l.PtLimaPtL],"016":[l.PtMumbai2],"017":[l.PtNairobi],"019":[l.ProxfordY],"020":[l.PtParisBx,l.PsParisCZ],"021":[l.PsQuebecn],"022":[l.PsRiotuma],"023":[l.PtSeouLou],"024":[l.PtTALLiNt],"025":[l.PsUshuai9],"026":[l.ProtoALpha]},function(t){t.MAINNET="NetXdQprcVkpaWU",t.GHOSTNET="NetXnHfVqm9iesp",t.SHADOWNET="NetXsqzbfFenSTS",t.CARTHAGENET="NetXjD3HPJJjmcd",t.DELPHINET="NetXm8tYqnMWky1",t.EDONET="NetXSgo1ZT2DRUG",t.FLORENCENET="NetXxkAx4woPLyu",t.GRANADANET="NetXz969SFaFn8k",t.HANGZHOUNET="NetXZSsxBpMQeAT",t.ITHACANET="NetXbhmtAbMukLc",t.JAKARTANET2="NetXLH1uAxK7CCh",t.KATHMANDUNET="NetXazhm4yetmff",t.LIMANET="NetXizpkH94bocH",t.MUMBAINET="NetXQw6nWSnrJ5t",t.MUMBAINET2="NetXgbcrNtXD2yA",t.NAIROBINET="NetXyuzvDo2Ugzb",t.OXFORDNET2="NetXxWsskGahzQB",t.PARISBNET="NetXo8SqH1c38SS",t.PARISCNET="NetXXWAHLEvre9b",t.QUEBECNET="NetXuTeGinLEqxp",t.RIONET="NetXPdgaoabtBth",t.SEOULNET="NetXd56aBs1aeW3",t.TALLINNNET="NetXe8DbhW9A1eS",t.USHUAIANET="NetXpX8WSZkAZZA"}(h||(e.ChainIds=h={}));e.getRevealGasLimit=t=>Math.round(37*f(t)/10);const f=t=>{switch(t.substring(0,3)){case"tz1":return r;case"tz2":return n;case"tz3":return i;case"tz4":return s;default:throw new Error(`Cannot estimate reveal gas limit for ${t}`)}};e.getRevealFee=t=>Math.round(12*(0,e.getRevealFeeInternal)(t)/10);e.getRevealFeeInternal=t=>{switch(t.substring(0,3)){case"tz1":return o;case"tz2":return a;case"tz3":return c;case"tz4":return 1.7*u;default:throw new Error(`Cannot estimate reveal fee for ${t}`)}}},7021(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Context=e.defaultConfigConfirmation=void 0;const n=r(3157),i=r(2245),s=r(6425),o=r(808),a=r(8907),c=r(4019),u=r(3995),l=r(5025),h=r(1170),f=r(8541),d=r(577),p=r(1948),g=r(8320),m=r(4631),y=r(8648),b=r(8724),v=r(7583);e.defaultConfigConfirmation={defaultConfirmationCount:1,confirmationPollingTimeoutSecond:180};class w{constructor(t,r=new s.NoopSigner,w,E=new p.BehaviorSubject({...e.defaultConfigConfirmation}),_,A,O,S,T,P,R,x){this._rpc=t,this._signer=r,this._proto=w,this._config=E,this.providerDecorator=[],this.tz=new a.RpcTzProvider(this),this.estimate=new c.RPCEstimateProvider(this),this.contract=new u.RpcContractProvider(this,this.estimate),this.prepare=new v.PrepareProvider(this),this.batch=new l.RPCBatchProvider(this,this.estimate),this.wallet=new h.Wallet(this),this.withExtensions=()=>{let t=this.clone();return this.providerDecorator.forEach(e=>{t=e(t)}),t},"string"==typeof this._rpc?this._rpcClient=new n.RpcClient(this._rpc):this._rpcClient=this._rpc,this._forger=_||new b.TaquitoLocalForger(this),this._injector=A||new i.RpcInjector(this),this.operationFactory=new o.OperationFactory(this),this._walletProvider=S||new h.LegacyWalletProvider(this),this._parser=T||new f.MichelCodecParser(this),this._packer=O||new d.RpcPacker(this),this._globalConstantsProvider=P||new g.NoopGlobalConstantsProvider,this._readProvider=R||new m.RpcReadAdapter(this._rpcClient),this._stream=x||new y.PollingSubscribeProvider(this)}get config(){return this._config.getValue()}set config(t){this._config.next({...t})}setPartialConfig(t){this._config.next({...this._config.getValue(),...t})}get rpc(){return this._rpcClient}set rpc(t){this._rpcClient=t}get injector(){return this._injector}set injector(t){this._injector=t}get forger(){return this._forger}set forger(t){this._forger=t}get signer(){return this._signer}set signer(t){this._signer=t}get walletProvider(){return this._walletProvider}set walletProvider(t){this._walletProvider=t}set proto(t){this._proto=t}get proto(){return this._proto}get parser(){return this._parser}set parser(t){this._parser=t}get packer(){return this._packer}set packer(t){this._packer=t}get globalConstantsProvider(){return this._globalConstantsProvider}set globalConstantsProvider(t){this._globalConstantsProvider=t}get readProvider(){return this._readProvider}set readProvider(t){this._readProvider=t}get stream(){return this._stream}set stream(t){this._stream=t}async isAnyProtocolActive(t=[]){if(this._proto)return t.includes(this._proto);{const e=await this.readProvider.getNextProtocol("head");return t.includes(e)}}isAnySignerConfigured(){return!(this.signer instanceof s.NoopSigner)}clone(){return new w(this.rpc,this.signer,this.proto,this._config,this.forger,this._injector,this.packer,this._walletProvider,this._parser,this._globalConstantsProvider,this._readProvider,this._stream)}registerProviderDecorator(t){this.providerDecorator.push(t)}}e.Context=w},9676(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BigMapAbstraction=void 0;r(7873).default;const n=r(2211);e.BigMapAbstraction=class{constructor(t,e,r,n){this.id=t,this.schema=e,this.provider=r,this.defaultBlock=n}async get(t,e){try{return await this.provider.getBigMapKeyByID(this.id.toString(),t,this.schema,e??this.defaultBlock)}catch(t){if(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND)return;throw t}}async getMultipleValues(t,e,r=5){return this.provider.getBigMapKeysByID(this.id.toString(),t,this.schema,e??this.defaultBlock,r)}toJSON(){return this.id.toString()}toString(){return this.id.toString()}}},3369(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.compose=function(t,e){return(r,n)=>e(t(r,n),n)}},9828(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_SMART_CONTRACT_METHOD_NAME=void 0,e.DEFAULT_SMART_CONTRACT_METHOD_NAME="default"},1844(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractMethodFactory=void 0;const n=r(2291),i=r(3085);e.ContractMethodFactory=class{constructor(t,e){this.provider=t,this.contractAddress=e}createContractMethodObjectParam(t,e,r,i=!0,s=!1){return new n.ContractMethodObject(this.provider,this.contractAddress,t,e,r,i,s)}createContractViewObjectParam(t,e,r,n,s){return new i.OnChainView(t,e,this.contractAddress,r,n,s)}}},4749(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2291(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractMethodObject=void 0;const n=r(9828);e.ContractMethodObject=class{constructor(t,e,r,n,i="unit",s=!0,o=!1){this.provider=t,this.address=e,this.parameterSchema=r,this.name=n,this.args=i,this.isMultipleEntrypoint=s,this.isAnonymous=o}getSignature(){const t=this.parameterSchema.generateSchema();if(this.isAnonymous){const e=t.schema;return e?.[this.name]}return t}send(t={}){return this.provider&&"pkh"in this.provider?this.provider.transfer(this.toTransferParams(t)).send():this.provider.transfer(this.toTransferParams(t))}toTransferParams({fee:t,gasLimit:e,storageLimit:r,source:i,amount:s=0,mutez:o=!1}={}){return{to:this.address,amount:s,fee:t,mutez:o,source:i,gasLimit:e,storageLimit:r,parameter:{entrypoint:this.isMultipleEntrypoint?this.name:n.DEFAULT_SMART_CONTRACT_METHOD_NAME,value:this.isAnonymous?this.parameterSchema.EncodeObject({[this.name]:this.args}):this.parameterSchema.EncodeObject(this.args)}}}}},3085(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OnChainView=void 0;const n=r(2403),i=r(6645),s=r(6571);e.OnChainView=class{constructor(t,e,r,n,i,s="Unit"){this._rpc=t,this._readProvider=e,this._contractAddress=r,this._smartContractViewSchema=n,this._contractStorageType=i,this._args=s}getSignature(){return{parameter:this._smartContractViewSchema.extractArgsSchema(),result:this._smartContractViewSchema.extractResultSchema()}}async executeView(t){this.verifyContextExecution(t);const e=await this._readProvider.getChainId(),r=this.transformArgsToMichelson(),n={contract:this._contractAddress,view:this._smartContractViewSchema.viewName,input:r,chain_id:e,source:t.viewCaller};return t.source&&(n.payer=t.source),this.executeViewAndDecodeResult(n)}verifyContextExecution(t){if(t.source&&(0,n.validateAddress)(t.source)!==n.ValidationResult.VALID)throw new i.InvalidViewSimulationContext(`The source account who initialized the view execution is invalid: ${t.source}.`);if(!t.viewCaller||(0,n.validateAddress)(t.viewCaller)!==n.ValidationResult.VALID)throw new i.InvalidViewSimulationContext(`The contract which is the caller of view is invalid: ${t.viewCaller}.`)}transformArgsToMichelson(){try{return this._smartContractViewSchema.encodeViewArgs(this._args)}catch(t){throw new s.InvalidViewParameterError(this._smartContractViewSchema.viewName,this.getSignature(),this._args,t)}}adaptViewCodeToContext(t,e,r){const n={BALANCE:[{prim:"PUSH",args:[{prim:"mutez"},{int:r}]}],SENDER:[{prim:"PUSH",args:[{prim:"address"},{string:e}]}],SELF_ADDRESS:[{prim:"PUSH",args:[{prim:"address"},{string:this._contractAddress}]}],AMOUNT:[{prim:"PUSH",args:[{prim:"mutez"},{int:"0"}]}]};return t.forEach((i,s)=>{i.prim in n&&(t[s]=Object(n)[i.prim]),i.args&&0!==i.args.length?this.adaptViewCodeToContext(i.args,e,r):Array.isArray(i)&&this.adaptViewCodeToContext(i,e,r)}),t}async executeViewAndDecodeResult(t){let e;try{e=(await this._rpc.runScriptView(t)).data}catch(t){const e=(0,i.validateAndExtractFailwith)(t);throw e?new i.ViewSimulationError(`The simulation of the on-chain view named ${this._smartContractViewSchema.viewName} failed with: ${JSON.stringify(e)}`,this._smartContractViewSchema.viewName,e,t):t}return this._smartContractViewSchema.decodeViewResult(e)}}},9339(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ContractAbstraction=e.ContractView=e.DEFAULT_SMART_CONTRACT_METHOD_NAME=void 0;const n=r(5602),i=r(2403),s=r(1844),o=r(6645),a=r(6571),c=r(9828);Object.defineProperty(e,"DEFAULT_SMART_CONTRACT_METHOD_NAME",{enumerable:!0,get:function(){return c.DEFAULT_SMART_CONTRACT_METHOD_NAME}});const u=r(9281);class l{constructor(t,e,r,n,i,s,o){this.currentContract=t,this.name=e,this.callbackParametersSchema=r,this.parameterSchema=n,this.args=i,this.rpc=s,this.readProvider=o}async read(t){const e=(0,i.validateChain)(t??"");if((0,i.validateContractAddress)(t??"")==i.ValidationResult.VALID)throw new a.DeprecationError("Since version 12, the lambda view no longer depends on a lambda contract. The read method no longer accepts a contract address as a parameter.");if(t&&e!==i.ValidationResult.VALID)throw new a.InvalidChainIdError(t,e);const r=this.parameterSchema.Encode(...this.args),n=await this.rpc.runView({contract:this.currentContract.address,entrypoint:this.name,input:r,chain_id:t||await this.readProvider.getChainId()});return this.callbackParametersSchema.Execute(n.data)}}e.ContractView=l;e.ContractAbstraction=class{constructor(t,e,r,i,o,a,c,u="head"){this.address=t,this.script=e,this.storageProvider=i,this.entrypoints=o,this.rpc=a,this.readProvider=c,this.readBlock=u,this.methodsObject={},this.views={},this.contractViews={},this.contractMethodFactory=new s.ContractMethodFactory(r,t),this.schema=n.Schema.fromRPCResponse({script:this.script}),this.parameterSchema=n.ParameterSchema.fromRPCResponse({script:this.script}),this.viewSchema=n.ViewSchema.fromRPCResponse({script:this.script}),0!==this.viewSchema.length&&this._initializeOnChainViews(this,a,this.readProvider,this.viewSchema),this.eventSchema=n.EventSchema.fromRPCResponse({script:this.script}),this._initializeMethods(this,this.entrypoints.entrypoints,this.rpc,this.readProvider)}_initializeMethods(t,e,r,i){const s=this.parameterSchema,a=Object.keys(e);if(s.isMultipleEntryPoint){a.forEach(s=>{const a=new n.ParameterSchema(e[s]);if(this.methodsObject[s]=function(e){return t.contractMethodFactory.createContractMethodObjectParam(a,s,e)},(t=>{let e=!1;if("prim"in t&&"pair"===t.prim&&t.args){const r=t.args[t.args.length-1];"prim"in r&&"contract"===r.prim&&(e=!0)}return e})(e[s])){const a=function(...a){const c=e[s].args[0],u=new n.ParameterSchema(c),h=e[s].args[1].args[0],f=new n.ParameterSchema(h);return((t,e,r)=>{const n=e.ExtractSignatures();if(!n.find(e=>e.length===t.length))throw new o.InvalidParameterError(r,n,t)})(a,u,s),new l(t,s,f,u,a,r,i)};this.views[s]=a}});const c=s.generateSchema();(c.schema&&"object"==typeof c.schema?Object.keys(c.schema):[]).filter(t=>-1===Object.keys(e).indexOf(t)).forEach(e=>{this.methodsObject[e]=function(r){return t.contractMethodFactory.createContractMethodObjectParam(s,e,r,!1,!0)}})}else{const e=this.parameterSchema;this.methodsObject[c.DEFAULT_SMART_CONTRACT_METHOD_NAME]=function(r){return t.contractMethodFactory.createContractMethodObjectParam(e,c.DEFAULT_SMART_CONTRACT_METHOD_NAME,r,!1)}}}_initializeOnChainViews(t,e,r,n){const i=this.schema.val;n.forEach(n=>{this.contractViews[n.viewName]=function(s){return t.contractMethodFactory.createContractViewObjectParam(e,r,n,i,s)}})}async storage(){return"head"!==this.readBlock?this.schema.Execute(this.script.storage,(0,u.smartContractAbstractionSemantic)(this.storageProvider,this.readBlock)):this.storageProvider.getStorage(this.address,this.schema,this.readBlock)}}},6645(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidBalanceError=e.OriginationParameterError=e.RevealOperationError=e.InvalidViewSimulationContext=e.validateAndExtractFailwith=e.ViewSimulationError=e.InvalidInitParameter=e.InvalidCodeParameter=e.InvalidDelegationSource=e.InvalidParameterError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t,e,r){super(),this.smartContractMethodName=t,this.sigs=e,this.invalidParams=r,this.name="InvalidParameterError",this.message=`${t} Received ${r.length} arguments while expecting one of the following signatures (${JSON.stringify(e)})`}}e.InvalidParameterError=i;class s extends n.ParameterValidationError{constructor(t){super(),this.source=t,this.name="InvalidDelegationSource",this.message=`Since Babylon delegation source can no longer be a contract address ${t}. Please use the smart contract abstraction to set your delegate.`}}e.InvalidDelegationSource=s;class o extends n.ParameterValidationError{constructor(t,e){super(),this.message=t,this.data=e,this.name="InvalidCodeParameter"}}e.InvalidCodeParameter=o;class a extends n.ParameterValidationError{constructor(t,e){super(),this.message=t,this.data=e,this.name="InvalidInitParameter"}}e.InvalidInitParameter=a;class c extends n.RpcError{constructor(t,e,r,n){super(),this.message=t,this.viewName=e,this.failWith=r,this.cause=n,this.name="ViewSimulationError"}}e.ViewSimulationError=c;e.validateAndExtractFailwith=t=>{if(u(t.body)){const e=JSON.parse(t.body);if(Array.isArray(e)&&"with"in e[e.length-1])return e[e.length-1].with}};const u=t=>{try{JSON.parse(t)}catch(t){return!1}return!0};class l extends n.ParameterValidationError{constructor(t){super(),this.info=t,this.name="InvalidViewSimulationContext",this.message=`${t} Please configure the context of the view execution in the executeView method.`}}e.InvalidViewSimulationContext=l;class h extends n.RpcError{constructor(t){super(),this.message=t,this.name="RevealOperationError"}}e.RevealOperationError=h;class f extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name}}e.OriginationParameterError=f;class d extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidBalanceError"}}e.InvalidBalanceError=d},2445(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.smartContractAbstractionSemantic=e.compose=void 0,i(r(9339),e),i(r(6645),e),i(r(1966),e),i(r(1752),e),i(r(2654),e),i(r(6200),e);var s=r(3369);Object.defineProperty(e,"compose",{enumerable:!0,get:function(){return s.compose}}),i(r(4749),e),i(r(2291),e),i(r(3e3),e);var o=r(9281);Object.defineProperty(e,"smartContractAbstractionSemantic",{enumerable:!0,get:function(){return o.smartContractAbstractionSemantic}})},1966(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1752(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MANAGER_LAMBDA=void 0;e.MANAGER_LAMBDA={setDelegate:t=>[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"PUSH",args:[{prim:"key_hash"},{string:t}]},{prim:"SOME"},{prim:"SET_DELEGATE"},{prim:"CONS"}],removeDelegate:()=>[{prim:"DROP"},{prim:"NIL",args:[{prim:"operation"}]},{prim:"NONE",args:[{prim:"key_hash"}]},{prim:"SET_DELEGATE"},{prim:"CONS"}],transferImplicit:(t,e)=>[{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:(t,e)=>[{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"}]}},1254(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.retryOnNotFound=e.isNotFoundError=void 0;const n=r(2211),i=[0,200,400,800],s=t=>new Promise(e=>{setTimeout(e,t)});e.isNotFoundError=t=>t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND;e.retryOnNotFound=async(t,r=i)=>{let n;for(const i of r){i>0&&await s(i);try{return await t()}catch(t){if(!(0,e.isNotFoundError)(t))throw t;n=t}}throw n}},2654(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createSmartRollupExecuteOutboxMessageOperation=e.createSmartRollupOriginateOperation=e.createSmartRollupAddMessagesOperation=e.createUpdateCompanionKeyOperation=e.createUpdateConsensusKeyOperation=e.createProposalsOperation=e.createBallotOperation=e.createDrainDelegateOperation=e.createIncreasePaidStorageOperation=e.createTransferTicketOperation=e.createRegisterGlobalConstantOperation=e.createRevealOperation=e.createRegisterDelegateOperation=e.createSetDelegateOperation=e.createTransferOperation=e.createOriginationOperation=e.createActivationOperation=void 0;const n=r(5602),i=r(3157),s=r(5283),o=r(2403),a=r(6645);e.createActivationOperation=async({pkh:t,secret:e})=>({kind:i.OpKind.ACTIVATION,pkh:t,secret:e});e.createOriginationOperation=async({code:t,init:e,balance:r="0",delegate:s,storage:c,fee:u,gasLimit:l,storageLimit:h,mutez:f=!1})=>{if(void 0!==c&&void 0!==e)throw new a.OriginationParameterError("Storage and Init cannot be set a the same time. Please either use storage or init but not both.");if(!Array.isArray(t))throw new a.InvalidCodeParameter("Wrong code parameter type, expected an array",t);let d;if(void 0!==c){const e=t.find(t=>"prim"in t&&"storage"===t.prim);if(void 0===e?.args)throw new a.InvalidCodeParameter("The storage section is missing from the script",t);d=new n.Schema(e.args[0]).Encode(c)}else{if(void 0===e||"object"!=typeof e)throw new a.InvalidInitParameter("Wrong init parameter type, expected JSON Michelson",e);d=e}const p={code:t,storage:d};if(isNaN(Number(r)))throw new a.InvalidBalanceError(`Invalid Balance "${r}", cannot be converted to a number`);const g={kind:i.OpKind.ORIGINATION,fee:u,gas_limit:l,storage_limit:h,balance:f?r.toString():(0,o.format)("tz","mutez",r).toString(),script:p};return s&&(g.delegate=s),g};e.createTransferOperation=async({to:t,amount:e,parameter:r,fee:n,gasLimit:s,storageLimit:a,mutez:c=!1})=>({kind:i.OpKind.TRANSACTION,fee:n,gas_limit:s,storage_limit:a,amount:c?e.toString():(0,o.format)("tz","mutez",e).toString(),destination:t,parameters:r});e.createSetDelegateOperation=async({delegate:t,source:e,fee:r,gasLimit:n,storageLimit:s})=>({kind:i.OpKind.DELEGATION,source:e,fee:r,gas_limit:n,storage_limit:s,delegate:t});e.createRegisterDelegateOperation=async({fee:t,gasLimit:e,storageLimit:r},n)=>({kind:i.OpKind.DELEGATION,fee:t,gas_limit:e,storage_limit:r,delegate:n});e.createRevealOperation=async({fee:t,gasLimit:e,storageLimit:r,proof:n},o,a)=>({kind:i.OpKind.REVEAL,fee:t,public_key:a,source:o,gas_limit:e??(0,s.getRevealGasLimit)(o),storage_limit:r,proof:n});e.createRegisterGlobalConstantOperation=async({value:t,source:e,fee:r,gasLimit:n,storageLimit:s})=>({kind:i.OpKind.REGISTER_GLOBAL_CONSTANT,value:t,fee:r,gas_limit:n,storage_limit:s,source:e});e.createTransferTicketOperation=async({ticketContents:t,ticketTy:e,ticketTicketer:r,ticketAmount:n,destination:s,entrypoint:o,source:a,fee:c,gasLimit:u,storageLimit:l})=>({kind:i.OpKind.TRANSFER_TICKET,fee:c,gas_limit:u,storage_limit:l,source:a,ticket_contents:t,ticket_ty:e,ticket_ticketer:r,ticket_amount:n,destination:s,entrypoint:o});e.createIncreasePaidStorageOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,amount:s,destination:o})=>({kind:i.OpKind.INCREASE_PAID_STORAGE,source:t,fee:e,gas_limit:r,storage_limit:n,amount:s,destination:o});e.createDrainDelegateOperation=async({consensus_key:t,delegate:e,destination:r})=>({kind:i.OpKind.DRAIN_DELEGATE,consensus_key:t,delegate:e,destination:r});e.createBallotOperation=async({source:t,proposal:e,ballot:r})=>({kind:i.OpKind.BALLOT,source:t,proposal:e,ballot:r});e.createProposalsOperation=async({source:t,proposals:e})=>({kind:i.OpKind.PROPOSALS,source:t,proposals:e});e.createUpdateConsensusKeyOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pk:s,proof:o})=>({kind:i.OpKind.UPDATE_CONSENSUS_KEY,source:t,fee:e,gas_limit:r,storage_limit:n,pk:s,proof:o});e.createUpdateCompanionKeyOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pk:s,proof:o})=>({kind:i.OpKind.UPDATE_COMPANION_KEY,source:t,fee:e,gas_limit:r,storage_limit:n,pk:s,proof:o});e.createSmartRollupAddMessagesOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,message:s})=>({kind:i.OpKind.SMART_ROLLUP_ADD_MESSAGES,source:t,fee:e,gas_limit:r,storage_limit:n,message:s});e.createSmartRollupOriginateOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,pvmKind:s,kernel:o,parametersType:a})=>({kind:i.OpKind.SMART_ROLLUP_ORIGINATE,source:t,fee:e,gas_limit:r,storage_limit:n,pvm_kind:s,kernel:o,parameters_ty:a});e.createSmartRollupExecuteOutboxMessageOperation=async({source:t,fee:e,gasLimit:r,storageLimit:n,rollup:s,cementedCommitment:o,outputProof:a})=>({kind:i.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,source:t,fee:e,gas_limit:r,storage_limit:n,rollup:s,cemented_commitment:o,output_proof:a})},3995(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcContractProvider=void 0;const n=r(2211),i=r(5602),s=r(3157),o=r(2403),a=r(6571),c=r(5025),u=r(4410),l=r(2526),h=r(6759),f=r(4368),d=r(2741),p=r(9339),g=r(6645),m=r(9281),y=r(4371),b=r(1660),v=r(659),w=r(8835),E=r(5574),_=r(2552),A=r(5649),O=r(3118),S=r(408),T=r(5185),P=r(5605),R=r(3682),x=r(1254);class I extends P.Provider{constructor(t,e){super(t),this.estimator=e,this.contractProviderTypeSymbol=Symbol.for("taquito-contract-provider-type-symbol"),this.prepare=new R.PrepareProvider(this.context)}async getStorage(t,e,r="head"){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const s="head"===r?await(0,x.retryOnNotFound)(()=>this.context.readProvider.getScript(t,"head")):await this.context.readProvider.getScript(t,r);let c;return e||(e=s),c=i.Schema.isSchema(e)?e:i.Schema.fromRPCResponse({script:e}),c.Execute(s.storage,(0,m.smartContractAbstractionSemantic)(this,r))}async getBigMapKeyByID(t,e,r,n){const{key:i,type:s}=r.EncodeBigMapKey(e),{packed:a}=await this.context.packer.packData({data:i,type:s}),c=(0,o.encodeExpr)(a),u=n??"head",l=await this.context.readProvider.getBigMapValue({id:t.toString(),expr:c},u);return r.ExecuteOnBigMapValue(l,(0,m.smartContractAbstractionSemantic)(this,u))}async getBigMapKeysByID(t,e,r,n,s=5){const o=await this.getBlockForRequest(e,n),a=new i.MichelsonMap;let c=0,u=[];for(;c<e.length;){const n=e.slice(c,c+s).map(e=>this.getBigMapValueOrUndefined(e,t,r,o));u=[...u,...await Promise.all(n)],c+=s}for(let t=0;t<u.length;t++)a.set(e[t],u[t]);return a}async getBlockForRequest(t,e){return 1===t.length||void 0!==e?e:await this.context.readProvider.getBlockLevel("head")}async getBigMapValueOrUndefined(t,e,r,i){try{return await this.getBigMapKeyByID(e,t,r,i)}catch(t){if(t instanceof n.HttpResponseError&&t.status===n.STATUS_CODE.NOT_FOUND)return;throw t}}async getSaplingDiffByID(t,e="head"){return this.context.readProvider.getSaplingDiffById({id:t.toString()},e)}async originate(t){const e=await this.estimate(t,this.estimator.originate.bind(this.estimator)),r=await this.prepare.originate({...t,...e}),n=r.opOb.contents.find(t=>t.kind===s.OpKind.ORIGINATION),i=await this.forge(r),{hash:o,context:a,forgedBytes:c,opResponse:u}=await this.signAndInject(i);return new l.OriginationOperation(o,n,c,u,a,this)}async setDelegate(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);const r=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.delegate,r);if(/^kt1/i.test(t.source??""))throw new g.InvalidDelegationSource(t.source??"");const n=await this.signer.publicKeyHash(),i=t.source||n,c=await this.estimate(t,this.estimator.setDelegate.bind(this.estimator)),l=await this.prepare.delegation({...t,...c}),h=l.opOb.contents.find(t=>t.kind===s.OpKind.DELEGATION),f=await this.forge(l),{hash:d,context:p,forgedBytes:m,opResponse:y}=await this.signAndInject(f);return new u.DelegateOperation(d,h,i,m,y,p)}async registerDelegate(t){const e=await this.estimate(t,this.estimator.registerDelegate.bind(this.estimator)),r=await this.signer.publicKeyHash(),n=await this.prepare.registerDelegate({...t,...e}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.DELEGATION),o=await this.forge(n),{hash:a,context:c,forgedBytes:l,opResponse:h}=await this.signAndInject(o);return new u.DelegateOperation(a,i,r,l,h,c)}async transfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.to,e);const r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const n=await this.signer.publicKeyHash(),i=await this.estimate(t,this.estimator.transfer.bind(this.estimator)),c=t.source||n,u=await this.prepare.transaction({...t,...i}),l=u.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),h=await this.forge(u),{hash:f,context:p,forgedBytes:g,opResponse:m}=await this.signAndInject(h);return new d.TransactionOperation(f,l,c,g,m,p)}async stake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.to&&t.to!==t.source)throw new a.InvalidStakingAddressError(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.stake.bind(this.estimator)),i=t.source||r,c=await this.prepare.stake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async unstake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.to&&t.to!==t.source)throw new a.InvalidStakingAddressError(t.to);if(t.amount<0)throw new a.InvalidAmountError(t.amount.toString());const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.unstake.bind(this.estimator)),i=t.source||r,c=await this.prepare.unstake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async finalizeUnstake(t){const e=(0,o.validateAddress)(t.source??"");if(t.source&&e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,e);if(t.to||(t.to=t.source),t.amount||(t.amount=0),void 0!==t.amount&&t.amount>0)throw new a.InvalidFinalizeUnstakeAmountError("Amount must be 0 to finalize unstake.");const r=await this.signer.publicKeyHash(),n=await this.estimate(t,this.estimator.finalizeUnstake.bind(this.estimator)),i=t.source||r,c=await this.prepare.finalizeUnstake({...t,...n}),u=c.opOb.contents.find(t=>t.kind===s.OpKind.TRANSACTION),l=await this.forge(c),{hash:h,context:f,forgedBytes:p,opResponse:g}=await this.signAndInject(l);return new d.TransactionOperation(h,u,i,p,g,f)}async transferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.destination,e);const r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=await this.signer.publicKeyHash(),i=t.source??n,c=await this.estimate(t,this.estimator.transferTicket.bind(this.estimator)),u=await this.prepare.transferTicket({...t,...c}),l=u.opOb.contents.find(t=>t.kind===s.OpKind.TRANSFER_TICKET),h=await this.forge(u),{hash:f,context:d,forgedBytes:p,opResponse:g}=await this.signAndInject(h);return new y.TransferTicketOperation(f,l,i,p,g,d)}async reveal(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(e,o.publicKeyHashPrefixes);if(r===o.PrefixV2.BLS12_381PublicKeyHash)if(t.proof)(0,o.b58DecodeAndCheckPrefix)(t.proof,[o.PrefixV2.BLS12_381Signature]);else{const{prefixSig:e}=await this.signer.provePossession();t.proof=e}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const n=await this.estimator.reveal(t);if(n){const r=await this.estimate(t,async()=>n),i=await this.prepare.reveal({...t,...r}),o=i.opOb.contents.find(t=>t.kind===s.OpKind.REVEAL),a=await this.forge(i),{hash:c,context:u,forgedBytes:l,opResponse:h}=await this.signAndInject(a);return new f.RevealOperation(c,o,e,l,h,u)}throw new g.RevealOperationError(`The publicKeyHash '${e}' has already been revealed.`)}async registerGlobalConstant(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.registerGlobalConstant.bind(this.estimator)),n=await this.prepare.registerGlobalConstant({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.REGISTER_GLOBAL_CONSTANT),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new h.RegisterGlobalConstantOperation(a,i,e,u,l,c)}async increasePaidStorage(t){if(t.amount<=0)throw new a.InvalidAmountError(t.amount.toString());const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.increasePaidStorage.bind(this.estimator)),n=await this.prepare.increasePaidStorage({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.INCREASE_PAID_STORAGE),o=await this.forge(n),{hash:c,context:u,forgedBytes:l,opResponse:h}=await this.signAndInject(o);return new b.IncreasePaidStorageOperation(c,i,e,l,h,u)}async drainDelegate(t){const e=await this.prepare.drainDelegate(t),r=e.opOb.contents.find(t=>t.kind===s.OpKind.DRAIN_DELEGATE),n=await this.forge(e),{hash:i,context:o,forgedBytes:a,opResponse:c}=await this.signAndInject(n);return new w.DrainDelegateOperation(i,r,a,c,o)}async ballot(t){const e=await this.signer.publicKeyHash(),r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=t.source??e,i=await this.prepare.ballot({...t,source:n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.BALLOT),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new v.BallotOperation(l,c,e,f,d,h)}async proposals(t){const e=await this.signer.publicKeyHash(),r=(0,o.validateAddress)(t.source??"");if(t.source&&r!==o.ValidationResult.VALID)throw new a.InvalidAddressError(t.source,r);const n=t.source??e,i=await this.prepare.proposals({...t,source:n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.PROPOSALS),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new E.ProposalsOperation(l,c,e,f,d,h)}async updateConsensusKey(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(r===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const n=await this.estimate(t,this.estimator.updateConsensusKey.bind(this.estimator)),i=await this.prepare.updateConsensusKey({...t,...n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.UPDATE_CONSENSUS_KEY),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new _.UpdateConsensusKeyOperation(l,c,e,f,d,h)}async updateCompanionKey(t){const e=await this.signer.publicKeyHash(),[,r]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(r!==o.PrefixV2.BLS12_381PublicKey)throw new a.ProhibitedActionError("Proof field is only allowed for a bls account as companion key");if(!t.proof)throw new a.InvalidProofError("Proof is required to set a bls account as companion key ");const n=await this.estimate(t,this.estimator.updateCompanionKey.bind(this.estimator)),i=await this.prepare.updateCompanionKey({...t,...n}),c=i.opOb.contents.find(t=>t.kind===s.OpKind.UPDATE_COMPANION_KEY),u=await this.forge(i),{hash:l,context:h,forgedBytes:f,opResponse:d}=await this.signAndInject(u);return new A.UpdateCompanionKeyOperation(l,c,e,f,d,h)}async smartRollupAddMessages(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupAddMessages.bind(this.estimator)),n=await this.prepare.smartRollupAddMessages({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_ADD_MESSAGES),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new O.SmartRollupAddMessagesOperation(a,i,e,u,l,c)}async smartRollupOriginate(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupOriginate.bind(this.estimator)),n=await this.prepare.smartRollupOriginate({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_ORIGINATE),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new S.SmartRollupOriginateOperation(a,i,e,u,l,c)}async smartRollupExecuteOutboxMessage(t){const e=await this.signer.publicKeyHash(),r=await this.estimate(t,this.estimator.smartRollupExecuteOutboxMessage.bind(this.estimator)),n=await this.prepare.smartRollupExecuteOutboxMessage({...t,...r}),i=n.opOb.contents.find(t=>t.kind===s.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE),o=await this.forge(n),{hash:a,context:c,forgedBytes:u,opResponse:l}=await this.signAndInject(o);return new T.SmartRollupExecuteOutboxMessageOperation(a,i,e,u,l,c)}async failingNoop(t){const e={kind:s.OpKind.FAILING_NOOP,arbitrary:t.arbitrary},r=await this.context.readProvider.getBlockHash(t.basedOnBlock),n=await this.context.forger.forge({branch:r,contents:[e]}),{prefixSig:i}=await this.signer.sign(n,new Uint8Array([3]));return{signature:i,bytes:n,signedContent:{branch:r,contents:[{kind:s.OpKind.FAILING_NOOP,arbitrary:t.arbitrary}]}}}async at(t,e=t=>t,r="head"){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const i=this.context.withExtensions().rpc,s=this.context.withExtensions().readProvider,c=async e=>({script:await s.getScript(t,e),entrypoints:"head"===e?await s.getEntrypoints(t):await i.getEntrypoints(t,{block:String(e)})});let u;try{u=await c(r)}catch(t){if("head"===r||!(0,x.isNotFoundError)(t))throw t;u=await(0,x.retryOnNotFound)(()=>c("head"))}return e(new p.ContractAbstraction(t,u.script,this,this,u.entrypoints,i,s,"head"),this.context)}async atExactBlock(t,e=t=>t,r){const n=(0,o.validateContractAddress)(t);if(n!==o.ValidationResult.VALID)throw new a.InvalidContractAddressError(t,n);const i=this.context.withExtensions().rpc,s=this.context.withExtensions().readProvider,c=await s.getScript(t,r),u=await i.getEntrypoints(t,{block:String(r)});return e(new p.ContractAbstraction(t,c,this,this,u,i,s,r),this.context)}batch(t){const e=new c.OperationBatch(this.context,this.estimator);return Array.isArray(t)&&e.with(t),e}}e.RpcContractProvider=I},3e3(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SaplingStateAbstraction=void 0;r(7873).default;e.SaplingStateAbstraction=class{constructor(t,e,r){this.id=t,this.provider=e,this.defaultBlock=r}async getSaplingDiff(t){return this.provider.getSaplingDiffByID(this.id.toString(),t??this.defaultBlock)}getId(){return this.id.toString()}}},9281(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.smartContractAbstractionSemantic=void 0;const n=r(5602),i=r(9676),s=r(7873),o=r(3e3);e.smartContractAbstractionSemantic=(t,e)=>({big_map:(r,o)=>{if(r&&"int"in r&&void 0!==r.int){const a=new n.Schema(o);return new i.BigMapAbstraction(new s.default(r.int),a,t,e)}return{}},sapling_state:r=>r&&"int"in r&&void 0!==r.int?new o.SaplingStateAbstraction(new s.default(r.int),t,e):{}})},6200(t,e){"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"}},4359(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCResponseError=e.ConfirmationTimeoutError=e.InvalidConfirmationCountError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t){super(),this.invalidConfirmations=t,this.name="InvalidConfirmationCountError",this.message=`Invalid confirmation count ${t} expecting at least 1`}}e.InvalidConfirmationCountError=i;class s extends n.NetworkError{constructor(t){super(),this.message=t,this.name="ConfirmationTimeoutError"}}e.ConfirmationTimeoutError=s;class o extends n.RpcError{constructor(t,e){super(),this.message=t,this.cause=e,this.name="RPCResponseError"}}e.RPCResponseError=o},8710(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchGasLimitExceededError=e.RevealEstimateError=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(){super(),this.name="RevealEstimateError",this.message="Public key is unknown, unable to estimate the reveal operation in Wallet API."}}e.RevealEstimateError=i;class s extends n.TaquitoError{constructor(t,e){super(),this.requiredGasLimit=t,this.hardGasLimitPerBlock=e,this.name="BatchGasLimitExceededError",this.message=`Batch gas estimation requires at least ${t} gas, which exceeds the per-block limit of ${e}. Split the batch into smaller operations.`}}e.BatchGasLimitExceededError=s},1263(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3771(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Estimate=e.feeParamsFromMempoolFilter=e.DEFAULT_FEE_PARAMS=void 0,e.DEFAULT_FEE_PARAMS={minimalFeeMutez:100,feePerGasMutez:.1,feePerByteMutez:1};const r=t=>{if(!Array.isArray(t)||t.length<2)return;const e=Number(t[0]),r=Number(t[1]);return Number.isFinite(e)&&Number.isFinite(r)&&0!==r?e/r:void 0};e.feeParamsFromMempoolFilter=t=>{const n=Number(t?.minimal_fees),i=r(t?.minimal_nanotez_per_gas_unit),s=r(t?.minimal_nanotez_per_byte);return{minimalFeeMutez:Number.isFinite(n)?n:e.DEFAULT_FEE_PARAMS.minimalFeeMutez,feePerGasMutez:"number"==typeof i?i/1e3:e.DEFAULT_FEE_PARAMS.feePerGasMutez,feePerByteMutez:"number"==typeof s?s/1e3:e.DEFAULT_FEE_PARAMS.feePerByteMutez}};class n{constructor(t,r,n,i,s=e.DEFAULT_FEE_PARAMS.minimalFeeMutez,o=e.DEFAULT_FEE_PARAMS){this._milligasLimit=t,this._storageLimit=r,this.opSize=n,this.minimalFeePerStorageByteMutez=i,this.baseFeeMutez=s,this.feeParams=o}get burnFeeMutez(){return this.roundUp(Number(this.storageLimit)*Number(this.minimalFeePerStorageByteMutez))}get storageLimit(){return Math.max(Number(this._storageLimit),0)}get gasLimit(){return this.roundUp(Number(this._milligasLimit)/1e3)}get operationFeeMutez(){return this.gasLimit*this.feeParams.feePerGasMutez+Number(this.opSize)*this.feeParams.feePerByteMutez}roundUp(t){return Math.ceil(Number(t))}get minimalFeeMutez(){return this.roundUp(this.operationFeeMutez+this.feeParams.minimalFeeMutez)}get suggestedFeeMutez(){return this.roundUp(this.operationFeeMutez+1.2*this.feeParams.minimalFeeMutez)}get usingBaseFeeMutez(){return Math.max(Number(this.baseFeeMutez),this.feeParams.minimalFeeMutez)+this.roundUp(this.operationFeeMutez)}get totalCost(){return this.minimalFeeMutez+this.burnFeeMutez}get consumedMilligas(){return Number(this._milligasLimit)}static createEstimateInstanceFromProperties(t){let e,r=0,i=0,s=0,o=0;const a=t[0]?.feeParams;return t.forEach(t=>{r+=t.milligasLimit,i+=t.storageLimit,s+=t.opSize,o=Math.max(t.minimalFeePerStorageByteMutez,o),t.baseFeeMutez&&(e=e?e+t.baseFeeMutez:t.baseFeeMutez)}),new n(r,i,s,o,e,a)}static createArrayEstimateInstancesFromProperties(t){return t.map(t=>new n(t.milligasLimit,t.storageLimit,t.opSize,t.minimalFeePerStorageByteMutez,t.baseFeeMutez,t.feeParams))}}e.Estimate=n},5681(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(3771),e),i(r(1263),e),i(r(4019),e),i(r(8710),e)},4019(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RPCEstimateProvider=void 0;r(7873).default;const n=r(286),i=r(6568),s=r(3771),o=r(2403),a=r(8710),c=r(5605),u=r(7583),l=r(6571);class h extends c.Provider{constructor(){super(...arguments),this.REVEAL_LENGTH=324,this.REVEAL_LENGTH_TZ4=622,this.MILLIGAS_BUFFER=1e5,this.STORAGE_BUFFER=20,this.UNKNOWN_GAS_LIMIT_PER_OPERATION=1e3,this.prepare=new u.PrepareProvider(this.context)}async getKeys(){const t=this.context.isAnySignerConfigured();return{publicKeyHash:t?await this.signer.publicKeyHash():await this.context.wallet.pkh(),publicKey:t?await this.signer.publicKey():await this.context.wallet.pk()}}getEstimationPropertiesFromOperationContent(t,e,r,s){const o=(0,n.flattenOperationResult)({contents:[t]});let a=0,c=0;return o.forEach(t=>{a+=Number(t.consumed_milligas)||0,c+="allocated_destination_contract"in t?s:0,c+="originated_contracts"in t&&Array.isArray(t.originated_contracts)?t.originated_contracts.length*s:0,c+="storage_size"in t&&"global_address"in t&&Number(t.storage_size)||0,c+="paid_storage_size_diff"in t&&Number(t.paid_storage_size_diff)||0,c+="genesis_commitment_hash"in t&&Number(t.size)||0}),(0,i.isOpWithFee)(t)?{milligasLimit:(0,i.isOpWithGasBuffer)(t)?a+Number(this.MILLIGAS_BUFFER):a,storageLimit:c>0?c+this.STORAGE_BUFFER:0,opSize:e,minimalFeePerStorageByteMutez:r.toNumber()}:{milligasLimit:0,storageLimit:0,opSize:e,minimalFeePerStorageByteMutez:r.toNumber(),baseFeeMutez:0}}hasOperationGasExhausted(t){return t.some(t=>t.id.endsWith("gas_exhausted.operation"))}getOperationResult(t){return t?.metadata?.operation_result}getInternalOperationResults(t){const e=t?.metadata?.internal_operation_results;return Array.isArray(e)?e:[]}operationResultHasGasExhausted(t){return!!Array.isArray(t?.errors)&&t.errors.some(t=>t.id?.endsWith("gas_exhausted.operation"))}findGasExhaustedContentIndex(t){const e=t.findIndex(t=>this.operationResultHasGasExhausted(this.getOperationResult(t)));if(-1!==e)return e;const r=t.findIndex(t=>this.getInternalOperationResults(t).some(t=>this.operationResultHasGasExhausted(t.result)));if(-1!==r)return r;const n=t.findIndex(t=>"skipped"===this.getOperationResult(t)?.status);return n>0?n-1:-1}getContentGasLimit(t){const e=Number(t?.gas_limit);return Number.isFinite(e)&&e>=0?e:0}getMeasuredGasLimit(t,e){const r=(0,n.flattenOperationResult)({contents:[t]}).reduce((t,e)=>t+(Number(e.consumed_milligas)||0),0);if(r<=0)return;const s=(0,i.isOpWithGasBuffer)(t)?this.MILLIGAS_BUFFER/1e3:0;return Math.min(Math.ceil(r/1e3)+s,e)}rebalanceGasLimits(t,e,r,n){const i=Number(n.hard_gas_limit_per_operation),s=Number(n.hard_gas_limit_per_block),o=r.simulation?.gasLimitPatchableIndexes?.filter(t=>t>=0&&t<e.contents.length);if(!(Array.isArray(t.operation.contents)&&o?.length&&Number.isFinite(i)&&Number.isFinite(s)))return;const c=e.contents,u=this.findGasExhaustedContentIndex(c);if(-1===u||!o.includes(u))return;const l=new Set(o),h=t.operation.contents.map(t=>({...t})),f=new Map;let d=0,p=0;const g=[];for(const[t,e]of c.entries()){if(!l.has(t)){d+=this.getContentGasLimit(h[t]);continue}if(t===u)continue;const r=this.getOperationResult(e)?.status,n="applied"===r||"backtracked"===r?this.getMeasuredGasLimit(e,i):void 0;"number"==typeof n?(f.set(t,n),p+=n):g.push(t)}const m=d+p;if(m>s)throw new a.BatchGasLimitExceededError(m,s);const y=s-m,b=g.length+1;if(y<b)throw new a.BatchGasLimitExceededError(m+b,s);const v=g.length>0?Math.min(this.UNKNOWN_GAS_LIMIT_PER_OPERATION,Math.floor((y-1)/g.length)):0,w=v*g.length,E=Math.min(i,y-w);if(E<=0)return;f.set(u,E);for(const t of g)f.set(t,v);let _=!1;for(const[t,e]of f.entries())this.getContentGasLimit(h[t])!==e&&(h[t].gas_limit=e.toString(),_=!0);return _?{...t,operation:{...t.operation,contents:h}}:void 0}async calculateEstimates(t,e){let r=s.DEFAULT_FEE_PARAMS;try{r=(0,s.feeParamsFromMempoolFilter)(await this.rpc.getMempoolFilter({include_default:!0}))}catch{}const i=await this.forge(t),{opbytes:a,opOb:{branch:c,contents:u}}=i,l={operation:{branch:c,contents:u,signature:"edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg"},chain_id:await this.context.readProvider.getChainId()};let h,f,d,p=l,g=a;const m=(t.simulation?.gasLimitPatchableIndexes?.length??0)+1;for(let r=0;r<=m;r++){const i=await this.simulate(p,0===r?t:void 0);h=i.opResponse,f=i.op,p=i.op;const s=[...(0,n.flattenErrors)(h,"backtracked"),...(0,n.flattenErrors)(h)];if(0===s.length)break;if(d=new n.TezosOperationError(s,"Error occurred during estimation",h.contents),!this.hasOperationGasExhausted(s))throw d;const o=this.rebalanceGasLimits(p,h,t,e);if(!o||r===m)throw d;p=o,h=void 0,f=void 0}if(!h||!f)throw d??new Error("Unable to simulate operation for estimation");if(f!==l){if(!f.operation.branch)throw new Error("Unable to reforge simulated operation without a branch");g=await this.context.forger.forge({branch:f.operation.branch,contents:f.operation.contents})}const{cost_per_byte:y,origination_size:b}=e;let v=1;return Array.isArray(f.operation.contents)&&f.operation.contents.length>1&&(v="reveal"===h.contents[0].kind?f.operation.contents.length-1:f.operation.contents.length),h.contents.map(t=>{const e=t;let n,i;return e.source=e.source||"",e.source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?(n=this.REVEAL_LENGTH_TZ4/2,i=(g.length/2+o.payloadLength[o.PrefixV2.BLS12_381Signature])/v):(n=this.REVEAL_LENGTH/2,i=(g.length/2+o.payloadLength[o.PrefixV2.Ed25519Signature])/v),{...this.getEstimationPropertiesFromOperationContent(t,"reveal"===t.kind?n:i,y,b??257),feeParams:r}})}async originate(t){const e=await this.prepare.originate(t),r=await this.context.readProvider.getProtocolConstants("head"),n=await this.calculateEstimates(e,r);if("reveal"===e.opOb.contents[0].kind){const t=e.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n.shift(),n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async transfer({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.to);if(i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.to,i);const a=(0,o.validateAddress)(n.source??"");if(n.source&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,a);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const c=await this.prepare.transaction({fee:t,storageLimit:e,gasLimit:r,...n}),u=await this.context.readProvider.getProtocolConstants("head"),h=await this.calculateEstimates(c,u);if("reveal"===c.opOb.contents[0].kind){const t=c.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h.shift(),h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async stake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.to&&n.to!==n.source)throw new l.InvalidStakingAddressError(n.to);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const a=await this.prepare.stake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async unstake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.to&&n.to!==n.source)throw new l.InvalidStakingAddressError(n.to);if(n.amount<0)throw new l.InvalidAmountError(n.amount.toString());const a=await this.prepare.unstake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);if(n.to||(n.to=n.source),n.amount||(n.amount=0),void 0!==n.amount&&0!==n.amount)throw new Error("Amount must be 0 for finalize_unstake operation");const a=await this.prepare.finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.calculateEstimates(a,c);if("reveal"===a.opOb.contents[0].kind){u.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;u[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(u)}async transferTicket({fee:t,storageLimit:e,gasLimit:r,...n}){const i=(0,o.validateAddress)(n.destination);if(i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.destination,i);const a=(0,o.validateAddress)(n.source??"");if(n.source&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,a);const c=await this.context.readProvider.getProtocolConstants("head"),u=await this.prepare.transferTicket({fee:t,storageLimit:e,gasLimit:r,...n}),h=await this.calculateEstimates(u,c);if("reveal"===u.opOb.contents[0].kind){h.shift();const t=u.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async setDelegate({fee:t,gasLimit:e,storageLimit:r,...n}){const i=(0,o.validateAddress)(n.source??"");if(n.source&&i!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.source,i);const a=(0,o.validateAddress)(n.delegate??"");if(n.delegate&&a!==o.ValidationResult.VALID)throw new l.InvalidAddressError(n.delegate,a);const c=await this.prepare.delegation({fee:t,storageLimit:r,gasLimit:e,...n}),u=await this.context.readProvider.getProtocolConstants("head"),h=await this.calculateEstimates(c,u);if("reveal"===c.opOb.contents[0].kind){h.shift();const t=c.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async batch(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.batch(t),n=await this.calculateEstimates(r,e);return s.Estimate.createArrayEstimateInstancesFromProperties(n)}async registerDelegate({fee:t,storageLimit:e,gasLimit:r,...n},i){const a=(await this.getKeys()).publicKeyHash,c=await this.context.readProvider.getProtocolConstants("head"),u=i||a,l=await this.prepare.registerDelegate({fee:t,storageLimit:e,gasLimit:r,...n},u),h=await this.calculateEstimates(l,c);if("reveal"===l.opOb.contents[0].kind){h.shift();const t=l.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;h[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(h)}async reveal(t){const{publicKeyHash:e,publicKey:r}=await this.getKeys();if(!r)throw new a.RevealEstimateError;if(await this.isAccountRevealRequired(e)){const[,r]=(0,o.b58DecodeAndCheckPrefix)(e,o.publicKeyHashPrefixes);if(r===o.PrefixV2.BLS12_381PublicKeyHash)if(t&&t.proof)(0,o.b58DecodeAndCheckPrefix)(t.proof,[o.PrefixV2.BLS12_381Signature]);else{const{prefixSig:e}=await this.signer.provePossession();t={...t,proof:e}}else if(t&&t.proof)throw new l.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const n=await this.context.readProvider.getProtocolConstants("head"),i=t?await this.prepare.reveal(t):await this.prepare.reveal({}),a=await this.calculateEstimates(i,n);return s.Estimate.createEstimateInstanceFromProperties(a)}}async registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...n}){const i=await this.prepare.registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...n}),a=await this.context.readProvider.getProtocolConstants("head"),c=await this.calculateEstimates(i,a);if("reveal"===i.opOb.contents[0].kind){c.shift();const t=i.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;c[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(c)}async increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...n}){if(n.amount<=0)throw new l.InvalidAmountError(n.amount.toString());const i=await this.context.readProvider.getProtocolConstants("head"),a=await this.prepare.increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...n}),c=await this.calculateEstimates(a,i);if("reveal"===a.opOb.contents[0].kind){c.shift();const t=a.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;c[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(c)}async updateConsensusKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e===o.PrefixV2.BLS12_381PublicKey){if(!t.proof)throw new l.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(t.proof)throw new l.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const r=await this.context.readProvider.getProtocolConstants("head"),n=await this.prepare.updateConsensusKey(t),i=await this.calculateEstimates(n,r);if("reveal"===n.opOb.contents[0].kind){i.shift();const t=n.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;i[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(i)}async updateCompanionKey(t){const[,e]=(0,o.b58DecodeAndCheckPrefix)(t.pk,o.publicKeyPrefixes);if(e!==o.PrefixV2.BLS12_381PublicKey)throw new l.ProhibitedActionError("companion key must be a bls account");if(!t.proof)throw new l.InvalidProofError("Proof is required to set a bls account as companion key ");const r=await this.context.readProvider.getProtocolConstants("head"),n=await this.prepare.updateCompanionKey(t),i=await this.calculateEstimates(n,r);if("reveal"===n.opOb.contents[0].kind){i.shift();const t=n.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;i[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(i)}async smartRollupAddMessages(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupAddMessages(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async smartRollupOriginate(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupOriginate(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}async smartRollupExecuteOutboxMessage(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.smartRollupExecuteOutboxMessage(t),n=await this.calculateEstimates(r,e);return"reveal"===r.opOb.contents[0].kind&&n.shift(),s.Estimate.createEstimateInstanceFromProperties(n)}async contractCall(t){const e=await this.context.readProvider.getProtocolConstants("head"),r=await this.prepare.contractCall(t),n=await this.calculateEstimates(r,e);if("reveal"===r.opOb.contents[0].kind){n.shift();const t=r.opOb.contents[0].source.startsWith(o.PrefixV2.BLS12_381PublicKeyHash)?this.REVEAL_LENGTH_TZ4/2:this.REVEAL_LENGTH/2;n[0].opSize-=t}return s.Estimate.createEstimateInstanceFromProperties(n)}}e.RPCEstimateProvider=h},3215(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CompositeForger=void 0;const n=r(8681);e.CompositeForger=class{constructor(t){if(this.forgers=t,0===t.length)throw new n.UnspecifiedForgerError}async forge({branch:t,contents:e}){const r=await Promise.all(this.forgers.map(r=>r.forge({branch:t,contents:e})));if(0===r.length)throw new n.UnspecifiedForgerError;let i=r.pop();for(;r.length;){const t=r.pop();if(t!==i)throw new n.ForgingMismatchError([i,t]);i=t}return i}}},8681(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnspecifiedForgerError=e.ForgingMismatchError=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(t){super(),this.results=t,this.name="ForgingMismatchError",this.message="Forging mismatch error"}}e.ForgingMismatchError=i;class s extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnspecifiedForgerError",this.message="No forger has been configured. Please configure new CompositeForger([rpcForger, localForger]) with your TezosToolkit instance."}}e.UnspecifiedForgerError=s},9719(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcForger=void 0;e.RpcForger=class{constructor(t){this.context=t}forge({branch:t,contents:e}){return this.context.rpc.forgeOperations({branch:t,contents:e})}}},8724(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TaquitoLocalForger=void 0;const n=r(8175);e.TaquitoLocalForger=class{constructor(t){this.context=t}async getNextProto(){if(!this.context.proto){const t=await this.context.readProvider.getNextProtocol("head");this.context.proto=t}return this.context.proto}async forge({branch:t,contents:e}){return new n.LocalForger(await this.getNextProto()).forge({branch:t,contents:e})}}},152(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultGlobalConstantsProvider=void 0;const n=r(1566);e.DefaultGlobalConstantsProvider=class{constructor(){this._globalConstantsLibrary={}}loadGlobalConstant(t){for(const e in t)Object.assign(this._globalConstantsLibrary,{[e]:t[e]})}async getGlobalConstantByHash(t){const e=this._globalConstantsLibrary[t];if(!e)throw new n.GlobalConstantNotFound(t);return e}}},1566(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnconfiguredGlobalConstantsProviderError=e.GlobalConstantNotFound=void 0;const n=r(6571);class i extends n.TaquitoError{constructor(t){super(),this.hash=t,this.name="GlobalConstantNotFound",this.message=`Please load the value associated with the constant ${t} using the loadGlobalConstant method of the DefaultGlobalConstantsProvider.`}}e.GlobalConstantNotFound=i;class s extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnconfiguredGlobalConstantsProviderError",this.message="No global constants provider has been configured. Please configure one by calling setGlobalConstantsProvider({globalConstantsProvider}) on your TezosToolkit instance."}}e.UnconfiguredGlobalConstantsProviderError=s},7157(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},8320(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopGlobalConstantsProvider=void 0;const n=r(1566);e.NoopGlobalConstantsProvider=class{async getGlobalConstantByHash(t){throw new n.UnconfiguredGlobalConstantsProviderError}}},8763(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.importKey=async function(t,e,r,i,s){if(e&&r&&i&&s){const o=n.InMemorySigner.fromFundraiser(e,r,i);t.setProvider({signer:o});const a=await o.publicKeyHash();let c;try{c=await t.tz.activate(a,s)}catch(t){if(!(t&&t.body&&/Invalid activation/.test(t.body)))throw t}c&&await c.confirmation()}else{const i=await n.InMemorySigner.fromSecretKey(e,r);t.setProvider({signer:i})}};const n=r(8691)},5299(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorMessage=function(t,e){const r=JSON.parse(t.body);if(r[0]&&r[0].kind&&r[0].msg){const i=JSON.stringify({kind:r[0].kind,id:r[0].id,msg:r[0].msg.replace(e,"")});return new n.HttpResponseError(`Http error response: (${t.status}) ${i}`,t.status,t.statusText,i,t.url)}return t};const n=r(2211)},9164(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2245(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcInjector=void 0;const n=r(5299),i=r(2211);e.RpcInjector=class{constructor(t){this.context=t}async inject(t){let e;try{e=await this.context.rpc.injectOperation(t)}catch(t){const e=". You may want to use --replace to provide adequate fee and replace it";throw t instanceof i.HttpResponseError&&t.message.includes(e)?(0,n.formatErrorMessage)(t,e):t}return e}}},659(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BallotOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"ballot"===t.kind);return t||void 0}get period(){return this.operationResults?.period}get proposal(){return this.params.proposal}get ballot(){return this.params.ballot}}e.BallotOperation=i},7669(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchOperation=void 0;const n=r(7873).default,i=r(268),s=r(286),o=r(1859),a=r(6568);class c extends o.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}getOriginatedContractAddresses(){const t=this.results.filter(t=>"origination"===t.kind);let e=[];for(const r of t)r.metadata.operation_result.originated_contracts&&(e=[...e,...r.metadata.operation_result.originated_contracts]);return e}get status(){return this.results.filter(t=>-1!==i.BATCH_KINDS.indexOf(t.kind)).map(t=>{if((0,a.hasMetadataWithResult)(t)){return t.metadata.operation_result.status}return"unknown"})[0]||"unknown"}get fee(){return this.sumProp(this.params,"fee")}get gasLimit(){return this.sumProp(this.params,"gas_limit")}get storageLimit(){return this.sumProp(this.params,"storage_limit")}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),new n(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.results}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.results}),"paid_storage_size_diff"))}get errors(){return(0,s.flattenErrors)({contents:this.results})}}e.BatchOperation=c},4410(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DelegateOperation=void 0;const n=r(7873).default,i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"delegation"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get delegate(){return this.params.delegate}get isRegisterOperation(){return this.delegate===this.source}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.DelegateOperation=s},8835(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DrainDelegateOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i){super(t,r,n,i),this.params=e}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"drain_delegate"===t.kind),e=t&&t.metadata&&t.metadata.balance_updates;return e||void 0}get consensusKey(){return this.params.consensus_key}get delegate(){return this.params.delegate}get destination(){return this.params.destination}}e.DrainDelegateOperation=i},286(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidEstimateValueError=e.OriginationOperationError=e.flattenErrors=e.flattenOperationResult=e.TezosPreapplyFailureError=e.TezosOperationError=void 0;const n=r(6571),i=r(6568);class s extends n.RpcError{constructor(t,e,r){super(),this.errors=t,this.errorDetails=e,this.operationsWithResults=r,this.name="TezosOperationError",this.lastError=t[t.length-1],this.message=`(${this.kind}) ${this.id}`,"with"in this.lastError&&(this.lastError.with.string?this.message=this.lastError.with.string:this.lastError.with.int?this.message=this.lastError.with.int:this.message=JSON.stringify(this.lastError.with))}get id(){return this.lastError.id}get kind(){return this.lastError.kind}}e.TezosOperationError=s;class o extends Error{constructor(t){super(),this.result=t,this.name="TezosPreapplyFailureError",this.message="Preapply returned an unexpected result"}}e.TezosPreapplyFailureError=o;e.flattenOperationResult=t=>{const e=Array.isArray(t)?t:[t],r=[];for(let t=0;t<e.length;t++)for(let n=0;n<e[t].contents.length;n++){const s=e[t].contents[n];(0,i.hasMetadataWithResult)(s)&&"fee"in s&&(r.push({fee:s.fee,...s.metadata.operation_result}),Array.isArray(s.metadata.internal_operation_results)&&s.metadata.internal_operation_results.forEach(t=>r.push(t.result)))}return r};e.flattenErrors=(t,e="failed")=>{const r=Array.isArray(t)?t:[t];let n=[];for(let t=0;t<r.length;t++)for(let s=0;s<r[t].contents.length;s++){const o=r[t].contents[s];if((0,i.hasMetadata)(o)&&((0,i.hasMetadataWithResult)(o)&&o.metadata.operation_result.status===e&&(n=n.concat(o.metadata.operation_result.errors||[])),(0,i.hasMetadataWithInternalOperationResult)(o)&&Array.isArray(o.metadata.internal_operation_results)))for(const t of o.metadata.internal_operation_results)"result"in t&&t.result.status===e&&(n=n.concat(t.result.errors||[]))}return n};class a extends n.TaquitoError{constructor(t){super(),this.message=t,this.name="OriginationOperationError"}}e.OriginationOperationError=a;class c extends n.ParameterValidationError{constructor(t){super(),this.message=t,this.name="InvalidEstimateValueError"}}e.InvalidEstimateValueError=c},1660(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IncreasePaidStorageOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"increase_paid_storage"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get errors(){return this.operationResults?.errors}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get amount(){return this.params.amount}get destination(){return this.params.destination}}e.IncreasePaidStorageOperation=i},105(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.Operation=e.RevealOperation=e.ProposalsOperation=e.DrainDelegateOperation=e.BallotOperation=e.SmartRollupOriginateOperation=e.SmartRollupAddMessagesOperation=e.UpdateCompanionKeyOperation=e.UpdateConsensusKeyOperation=e.TransferTicketOperation=e.IncreasePaidStorageOperation=e.RegisterGlobalConstantOperation=e.TransactionOperation=e.DelegateOperation=e.OriginationOperation=e.BatchOperation=e.InvalidEstimateValueError=e.TezosPreapplyFailureError=e.TezosOperationError=void 0,i(r(6568),e);var s=r(286);Object.defineProperty(e,"TezosOperationError",{enumerable:!0,get:function(){return s.TezosOperationError}}),Object.defineProperty(e,"TezosPreapplyFailureError",{enumerable:!0,get:function(){return s.TezosPreapplyFailureError}}),Object.defineProperty(e,"InvalidEstimateValueError",{enumerable:!0,get:function(){return s.InvalidEstimateValueError}});var o=r(7669);Object.defineProperty(e,"BatchOperation",{enumerable:!0,get:function(){return o.BatchOperation}});var a=r(2526);Object.defineProperty(e,"OriginationOperation",{enumerable:!0,get:function(){return a.OriginationOperation}});var c=r(4410);Object.defineProperty(e,"DelegateOperation",{enumerable:!0,get:function(){return c.DelegateOperation}});var u=r(2741);Object.defineProperty(e,"TransactionOperation",{enumerable:!0,get:function(){return u.TransactionOperation}});var l=r(6759);Object.defineProperty(e,"RegisterGlobalConstantOperation",{enumerable:!0,get:function(){return l.RegisterGlobalConstantOperation}});var h=r(1660);Object.defineProperty(e,"IncreasePaidStorageOperation",{enumerable:!0,get:function(){return h.IncreasePaidStorageOperation}});var f=r(4371);Object.defineProperty(e,"TransferTicketOperation",{enumerable:!0,get:function(){return f.TransferTicketOperation}});var d=r(2552);Object.defineProperty(e,"UpdateConsensusKeyOperation",{enumerable:!0,get:function(){return d.UpdateConsensusKeyOperation}});var p=r(5649);Object.defineProperty(e,"UpdateCompanionKeyOperation",{enumerable:!0,get:function(){return p.UpdateCompanionKeyOperation}});var g=r(3118);Object.defineProperty(e,"SmartRollupAddMessagesOperation",{enumerable:!0,get:function(){return g.SmartRollupAddMessagesOperation}});var m=r(408);Object.defineProperty(e,"SmartRollupOriginateOperation",{enumerable:!0,get:function(){return m.SmartRollupOriginateOperation}});var y=r(659);Object.defineProperty(e,"BallotOperation",{enumerable:!0,get:function(){return y.BallotOperation}});var b=r(8835);Object.defineProperty(e,"DrainDelegateOperation",{enumerable:!0,get:function(){return b.DrainDelegateOperation}});var v=r(5574);Object.defineProperty(e,"ProposalsOperation",{enumerable:!0,get:function(){return v.ProposalsOperation}});var w=r(4368);Object.defineProperty(e,"RevealOperation",{enumerable:!0,get:function(){return w.RevealOperation}});var E=r(1859);Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return E.Operation}})},1859(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Operation=void 0;const n=r(1948),i=r(1018),s=r(6568),o=r(2403),a=r(9940),c=r(4359),u=r(6571),l="undefined"!=typeof process?process.env:void 0,h=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE??""),f=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE_VERBOSE??""),d=Number(l?.TAQUITO_OP_TRACE_SLOW_MS??"60000"),p=Number.isFinite(d)&&d>=0?d:6e4,g=t=>"object"==typeof t&&null!==t?t:void 0,m=t=>Array.isArray(t)?t:[],y=t=>t.map(t=>{const e=g(t)??{},r=g(e.metadata),n=g(r?.operation_result),i=r?.internal_operation_results,s=Array.isArray(i)?i.reduce((t,e)=>{const r=g(e),n=g(r?.result),i=n?.status;return"string"!=typeof i||"applied"===i||t.push({kind:"string"==typeof r?.kind?r.kind:"unknown",status:i,errors:m(n?.errors)}),t},[]):[];return{kind:"string"==typeof e.kind?e.kind:"unknown",status:"string"==typeof n?.status?n.status:"unknown",errors:m(n?.errors),consumed_milligas:"string"==typeof n?.consumed_milligas?n.consumed_milligas:void 0,internalFailures:s}}),b=t=>{h&&console.log(`[taquito:op-trace] ${JSON.stringify(t)}`)};e.Operation=class{get includedInBlock(){return this._foundAt}async getInclusionBlock(){const t=await this._includedInBlock.pipe((0,i.first)()).toPromise();if(!t)throw new Error("Inclusion block is undefined");return t}constructor(t,e,r,s){if(this.hash=t,this.raw=e,this.results=r,this.context=s,this._pollingConfig$=new n.ReplaySubject(1),this._includedInBlock=new n.ReplaySubject(1),this.currentHead$=this._pollingConfig$.pipe((0,i.switchMap)(t=>new n.BehaviorSubject(t).pipe((0,i.timeout)({each:1e3*t.timeout,with:()=>(0,n.throwError)(()=>new c.ConfirmationTimeoutError("Confirmation polling timed out"))}))),(0,i.switchMap)(()=>(0,n.defer)(()=>(0,a.createObservableFromSubscription)(this.context.stream.subscribeBlock("head"))).pipe((0,i.switchMap)(t=>{const e=this.lastHead?.header.level??t.header.level-1;return(0,n.range)(e+1,t.header.level-e-1).pipe((0,i.concatMap)(t=>this.context.readProvider.getBlock(t)),(0,i.endWith)(t))}),(0,i.tap)(t=>this.lastHead=t))),(0,i.shareReplay)({refCount:!0})),this.confirmed$=this.currentHead$.pipe((0,i.map)(t=>{for(let e=3;e>=0;e--)for(const r of t.operations[e])if(r.hash===this.hash)return this._foundAt=t.header.level,this._includedInBlock.next(t),this._foundAt;if(t.header.level-this._foundAt>=0)return this._foundAt}),(0,i.filter)(t=>void 0!==t),(0,i.first)(),(0,i.shareReplay)()),this._foundAt=Number.POSITIVE_INFINITY,(0,o.validateOperation)(this.hash)!==o.ValidationResult.VALID)throw new u.InvalidOperationHashError(this.hash);this.confirmed$.pipe((0,i.first)(),(0,i.catchError)(()=>(0,n.of)(n.EMPTY))).subscribe()}get revealOperation(){return Array.isArray(this.results)&&this.results.find(t=>"reveal"===t.kind)}get revealStatus(){return this.revealOperation?this.revealOperation.metadata.operation_result.status:"unknown"}get status(){return this.results.map(t=>(0,s.hasMetadataWithResult)(t)?t.metadata.operation_result.status:"unknown")[0]||"unknown"}async confirmation(t,e){if(void 0!==t&&t<1)throw new c.InvalidConfirmationCountError(t);const{defaultConfirmationCount:r,confirmationPollingTimeoutSecond:n}=this.context.config,s=e||n,o=Date.now();this._pollingConfig$.next({timeout:s});const a=void 0!==t?t:r;return new Promise((t,e)=>{this.confirmed$.pipe((0,i.switchMap)(()=>this.currentHead$),(0,i.filter)(t=>t.header.level-this._foundAt>=a-1),(0,i.first)()).subscribe({error:t=>{var r;b({stage:"confirmation-error",hash:this.hash,elapsedMs:Date.now()-o,expectedConfirmations:a,timeoutSec:s,includedInBlock:Number.isFinite(this._foundAt)?this._foundAt:null,status:this.status,error:(r=t,r instanceof Error?`${r.name}: ${r.message}`:String(r)),results:y(this.results)}),e(t)},complete:()=>{const e=Date.now()-o;(f||e>=p||"applied"!==this.status)&&b({stage:"confirmation-complete",hash:this.hash,elapsedMs:e,expectedConfirmations:a,timeoutSec:s,includedInBlock:Number.isFinite(this._foundAt)?this._foundAt:null,status:this.status,results:y(this.results)}),t(this._foundAt+(a-1))}})})}}},2526(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationOperation=void 0;const n=r(7873).default,i=r(3484),s=r(286),o=r(1859),a=r(6568);class c extends o.Operation{constructor(t,e,r,n,i,s){super(t,r,n,i),this.params=e,this.contractProvider=s;const o=this.operationResults&&this.operationResults.originated_contracts;Array.isArray(o)&&(this.contractAddress=o[0])}get status(){return this.operationResults?.status??"unknown"}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"origination"===t.kind),e=t&&(0,a.hasMetadataWithResult)(t)&&t.metadata.operation_result;return e||void 0}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get storageDiff(){const t=this.operationResults&&this.operationResults.paid_storage_size_diff;return t||void 0}get storageSize(){const t=this.operationResults&&this.operationResults.storage_size;return t||void 0}get errors(){return this.operationResults?.errors}async contract(t,e){if(!this.contractAddress)throw new s.OriginationOperationError("No contract was originated in this operation");if(await this.confirmation(t,e),!Number.isFinite(this.includedInBlock))throw new s.OriginationOperationError("Confirmation completed but includedInBlock was not set");const r=await this.getInclusionBlock();if(!(0,i.isBlockHashIdentifier)(r.hash))throw new s.OriginationOperationError("Confirmation completed but includedInBlock was not set");return this.contractProvider.at(this.contractAddress,void 0,r.hash)}}e.OriginationOperation=c},5574(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ProposalsOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"proposals"===t.kind);return t||void 0}get proposals(){return this.params.proposals}get period(){return this.operationResults?.period}}e.ProposalsOperation=i},6759(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegisterGlobalConstantOperation=void 0;const n=r(7873).default,i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r,this.globalConstantHash=this.operationResults&&this.operationResults.global_address}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"register_global_constant"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get registeredExpression(){return this.params.value}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get errors(){return this.operationResults?.errors}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),this.consumedMilliGas?new n(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}}e.RegisterGlobalConstantOperation=s},4368(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RevealOperation=void 0;const n=r(6571),i=r(7873).default,s=r(286),o=r(1859);class a extends o.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"reveal"===t.kind);return t?[t]:[]}get status(){const t=this.operationResults[0];return t?t.metadata.operation_result.status:"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get publicKey(){return this.params.public_key}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only BLS key has proof")}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}get consumedGas(){return i.config({DECIMAL_PLACES:0,ROUNDING_MODE:i.ROUND_UP}),new i(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"paid_storage_size_diff"))}get storageSize(){return String(this.sumProp((0,s.flattenOperationResult)({contents:this.operationResults}),"storage_size"))}get errors(){return(0,s.flattenErrors)({contents:this.operationResults})}}e.RevealOperation=a},3118(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupAddMessagesOperation=void 0;const n=r(1859);class i extends n.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"smart_rollup_add_messages"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get message(){return this.params.message}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.SmartRollupAddMessagesOperation=i},5185(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupExecuteOutboxMessageOperation=void 0;const n=r(3157),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get rollup(){return this.params.rollup}get cementedCommitment(){return this.params.cemented_commitment}get outputProof(){return this.params.output_proof}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.SmartRollupExecuteOutboxMessageOperation=s},408(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartRollupOriginateOperation=void 0;const n=r(3157),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.SMART_ROLLUP_ORIGINATE),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get pvmKind(){return this.params.pvm_kind}get kernel(){return this.params.kernel}get errors(){return this.operationResults?.errors}}e.SmartRollupOriginateOperation=s},2741(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionOperation=void 0;const n=r(7873).default,i=r(286),s=r(1859);class o extends s.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"transaction"===t.kind);return t?[t]:[]}get status(){const t=this.operationResults[0];return t?t.metadata.operation_result.status:"unknown"}get amount(){return new n(this.params.amount)}get destination(){return this.params.destination}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}sumProp(t,e){return t.reduce((t,r)=>e in r?Number(r[e])+t:t,0)}get consumedGas(){return n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP}),new n(this.consumedMilliGas).dividedBy(1e3).toString()}get consumedMilliGas(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"consumed_milligas"))}get storageDiff(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"paid_storage_size_diff"))}get storageSize(){return String(this.sumProp((0,i.flattenOperationResult)({contents:this.operationResults}),"storage_size"))}get errors(){return(0,i.flattenErrors)({contents:this.operationResults})}}e.TransactionOperation=o},4371(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransferTicketOperation=void 0;const n=r(3157),i=r(7873).default,s=r(1859);class o extends s.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>t.kind===n.OpKind.TRANSFER_TICKET),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get consumedGas(){return i.config({DECIMAL_PLACES:0,ROUNDING_MODE:i.ROUND_UP}),this.consumedMilliGas?new i(this.consumedMilliGas).dividedBy(1e3).toString():void 0}get consumedMilliGas(){return this.operationResults?.consumed_milligas}}e.TransferTicketOperation=o},6568(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hasMetadataWithInternalOperationResult=e.hasMetadataWithResult=e.hasMetadata=e.isSourceOp=e.isOpRequireReveal=e.isOpWithFee=e.isOpWithGasBuffer=e.isKind=e.findWithKind=e.attachKind=e.OpKind=void 0;const n=r(3157);var i=r(3157);Object.defineProperty(e,"OpKind",{enumerable:!0,get:function(){return i.OpKind}});e.attachKind=(t,e)=>({...t,kind:e});e.findWithKind=(t,r)=>{if(Array.isArray(t)){const n=t.find(t=>t.kind===r);if(n&&(0,e.isKind)(n,r))return n}};e.isKind=(t,e)=>t.kind===e;const s=[n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.ORIGINATION,n.OpKind.REVEAL,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET,n.OpKind.UPDATE_CONSENSUS_KEY,n.OpKind.UPDATE_COMPANION_KEY,n.OpKind.SMART_ROLLUP_ADD_MESSAGES,n.OpKind.SMART_ROLLUP_ORIGINATE,n.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE];e.isOpWithGasBuffer=t=>!(t.kind!==n.OpKind.TRANSACTION||!t.destination?.startsWith("KT1"))||-1!==["origination","register_global_constant","transfer_ticket","update_consensus_key","update_companion_key","smart_rollup_add_messages","smart_rollup_originate"].indexOf(t.kind);e.isOpWithFee=t=>s.includes(t.kind);e.isOpRequireReveal=t=>-1!==["transaction","delegation","origination","register_global_constant","increase_paid_storage","transfer_ticket","update_consensus_key","update_companion_key","smart_rollup_add_messages","smart_rollup_originate","smart_rollup_execute_outbox_message"].indexOf(t.kind);e.isSourceOp=t=>-1!==["transaction","delegation","origination","reveal","ballot"].indexOf(t.kind);e.hasMetadata=t=>"metadata"in t;e.hasMetadataWithResult=t=>(0,e.hasMetadata)(t)&&"operation_result"in t.metadata;e.hasMetadataWithInternalOperationResult=t=>(0,e.hasMetadata)(t)&&"internal_operation_results"in t.metadata},5649(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateCompanionKeyOperation=void 0;const n=r(6571),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"update_companion_key"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get pk(){return this.params.pk}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only updating companion key to a BLS account has proof")}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.UpdateCompanionKeyOperation=s},2552(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateConsensusKeyOperation=void 0;const n=r(6571),i=r(1859);class s extends i.Operation{constructor(t,e,r,n,i,s){super(t,n,i,s),this.params=e,this.source=r}get operationResults(){const t=Array.isArray(this.results)&&this.results.find(t=>"update_consensus_key"===t.kind),e=t&&t.metadata&&t.metadata.operation_result;return e||void 0}get status(){return this.operationResults?.status??"unknown"}get fee(){return Number(this.params.fee)}get gasLimit(){return Number(this.params.gas_limit)}get storageLimit(){return Number(this.params.storage_limit)}get pk(){return this.params.pk}get proof(){if(this.params.proof)return this.params.proof;throw new n.ProhibitedActionError("Only updating consensus key to a BLS account has proof")}get consumedMilliGas(){return this.operationResults?.consumed_milligas}get errors(){return this.operationResults?.errors}}e.UpdateConsensusKeyOperation=s},458(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4377(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MichelCodecPacker=void 0;const n=r(5899);e.MichelCodecPacker=class{async packData(t){const{bytes:e}=(0,n.packDataBytes)(t.data,t.type);return{packed:e}}}},577(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcPacker=void 0;e.RpcPacker=class{constructor(t){this.context=t}async packData(t){return this.context.rpc.packData(t)}}},3971(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},8541(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MichelCodecParser=void 0;const n=r(5899),i=r(6645),s=r(5602);e.MichelCodecParser=class{constructor(t){this.context=t}async getNextProto(){if(!this.context.proto){const t=await this.context.readProvider.getNextProtocol("head");this.context.proto=t}return this.context.proto}async parseScript(t){return new n.Parser({protocol:await this.getNextProto()}).parseScript(t)}async parseMichelineExpression(t){return new n.Parser({protocol:await this.getNextProto()}).parseMichelineExpression(t)}async parseJSON(t){return new n.Parser({protocol:await this.getNextProto()}).parseJSON(t)}async prepareCodeOrigination(t){const e=t;if(e.code=await this.formatCodeParam(t.code),t.init)e.init=await this.formatInitParam(t.init);else if(t.storage){const r=e.code.find(t=>"prim"in t&&"storage"===t.prim);if(!r?.args)throw new i.InvalidCodeParameter("The storage section is missing from the script",t.code);const o=new s.Schema(r.args[0]),a=await this.findGlobalConstantsHashAndValue(o);if(0!==Object.keys(a).length){const i=new n.Parser({expandGlobalConstant:a}).parseJSON(r.args[0]),o=new s.Schema(i);e.init=o.Encode(t.storage)}else e.init=o.Encode(t.storage);delete e.storage}return e}async formatCodeParam(t){let e;if("string"==typeof t){const r=await this.parseScript(t);if(null===r)throw new i.InvalidCodeParameter("Unable to parse",t);e=r}else{const r=await this.parseJSON(t),n=["parameter","storage","code"];e=r.sort((t,e)=>n.indexOf(t.prim)-n.indexOf(e.prim))}return e}async formatInitParam(t){let e;if("string"==typeof t){const r=await this.parseMichelineExpression(t);if(null===r)throw new i.InvalidInitParameter("Invalid init parameter",t);e=r}else e=await this.parseJSON(t);return e}async findGlobalConstantsHashAndValue(t){const e=t.findToken("constant"),r={};if(0!==e.length)for(const t of e){const e=t.tokenVal.args;if(e){const t=e[0];if(t.string){const e=t.string,n=await this.context.globalConstantsProvider.getGlobalConstantByHash(e);Object.assign(r,{[e]:n})}}}return r}}},6424(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopParser=void 0;e.NoopParser=class{async prepareCodeOrigination(t){return t}}},3682(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(261),e),i(r(7583),e)},261(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},7583(t,e,r){"use strict";var n,i=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,"__esModule",{value:!0}),e.PrepareProvider=void 0;const o=r(3157),a=r(6568),c=r(5283),u=r(4359),l=r(6571),h=r(2445),f=r(5605),d=r(7873).default,p=r(2403),g=(t,e)=>({fee:t.fee??e.fee,gasLimit:t.gasLimit??e.gasLimit,storageLimit:t.storageLimit??e.storageLimit});class m extends f.Provider{constructor(t){super(t),this.context=t,n.set(this,void 0),i(this,n,{},"f")}async getBlockHash(t){return this.context.readProvider.getBlockHash(t??"head~2")}async getProtocolHash(){return this.context.readProvider.getNextProtocol("head")}async getHeadCounter(t){return this.context.readProvider.getCounter(t,"head")??"0"}adjustGasForManagerOperations(t,e,r,n=new d(0)){if(r<=0)return e;const i=t.minus(n);return i.lte(0)?new d(0):d.min(e,i.div(r).integerValue(d.ROUND_DOWN))}getOperationLimits(t,e={}){const{hard_gas_limit_per_operation:r,hard_gas_limit_per_block:n,hard_storage_limit_per_operation:i}=t;return{fee:0,gasLimit:this.adjustGasForManagerOperations(n,r,e.opsNeedingGasLimitPatch??0,e.explicitGasLimitTotal).toNumber(),storageLimit:i.toNumber()}}async getOperationLimitsForManagerOperation(t,e,r,n){const i=await this.isRevealOpNeeded([{kind:r}],e);return this.getOperationLimits(t,{opsNeedingGasLimitPatch:void 0===n?1:0,explicitGasLimitTotal:i?new d((0,c.getRevealGasLimit)(e)):void 0})}getFee(t,e,r){(!s(this,n,"f")[e]||s(this,n,"f")[e]<r)&&(s(this,n,"f")[e]=r);return{counter:`${++s(this,n,"f")[e]}`,fee:void 0===t.fee?"0":`${t.fee}`,gas_limit:void 0===t.gas_limit?"0":`${t.gas_limit}`,storage_limit:void 0===t.storage_limit?"0":`${t.storage_limit}`}}getSource(t,e,r){return{source:void 0===t.source?r||e:t.source}}async addRevealOperationIfNeeded(t,e){if((0,a.isOpRequireReveal)(t)){const r=[t],{publicKey:n,pkh:i}=await this.getKeys();if(await this.isAccountRevealRequired(e)){if(!n)throw new l.PublicKeyNotFoundError(i);const[,t]=(0,p.b58DecodeAndCheckPrefix)(i,p.publicKeyHashPrefixes);return r.unshift(await(0,h.createRevealOperation)({fee:(0,c.getRevealFee)(i),storageLimit:c.REVEAL_STORAGE_LIMIT,gasLimit:(0,c.getRevealGasLimit)(i),proof:t===p.PrefixV2.BLS12_381PublicKeyHash?(await this.signer.provePossession()).prefixSig:void 0},e,n)),r}}return t}async getKeys(){const t=this.context.isAnySignerConfigured();return{pkh:t?await this.signer.publicKeyHash():await this.context.wallet.pkh(),publicKey:t?await this.signer.publicKey():await this.context.wallet.pk()}}convertIntoArray(t){return Array.isArray(t)?[...t]:[t]}getSingleManagerOperationSimulation(t,e){if(void 0===e&&0!==t.length)return{gasLimitPatchableIndexes:[t.length-1]}}withSimulationMetadata(t,e){return e?(Object.defineProperty(t,"simulation",{value:e,configurable:!0,enumerable:!1,writable:!0}),t):t}constructOpContents(t,e,r,n,i){return t.map(t=>{switch(t.kind){case o.OpKind.ACTIVATION:case o.OpKind.DRAIN_DELEGATE:return{...t};case o.OpKind.ORIGINATION:return{...t,balance:void 0!==t.balance?`${t.balance}`:"0",...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.TRANSACTION:{const i={...t,amount:void 0!==t.amount?`${t.amount}`:"0",...this.getSource(t,r,n),...this.getFee(t,r,e)};if(i.source.toLowerCase().startsWith("kt1"))throw new l.DeprecationError(`KT1 addresses are not supported as source since ${c.Protocols.PsBabyM1}`);return i}case o.OpKind.REVEAL:case o.OpKind.DELEGATION:case o.OpKind.REGISTER_GLOBAL_CONSTANT:case o.OpKind.UPDATE_CONSENSUS_KEY:case o.OpKind.UPDATE_COMPANION_KEY:case o.OpKind.SMART_ROLLUP_ADD_MESSAGES:case o.OpKind.SMART_ROLLUP_ORIGINATE:case o.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return{...t,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.TRANSFER_TICKET:return{...t,ticket_amount:`${t.ticket_amount}`,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.INCREASE_PAID_STORAGE:return{...t,amount:`${t.amount}`,...this.getSource(t,r,n),...this.getFee(t,r,e)};case o.OpKind.BALLOT:case o.OpKind.PROPOSALS:if(void 0===i)throw new u.RPCResponseError("Failed to get the current voting period index");return{...t,period:i?.voting_period.index,...this.getSource(t,r,n)};default:throw new l.InvalidOperationKindError(t.kind)}})}async activate({pkh:t,secret:e}){const r=await(0,h.createActivationOperation)({pkh:t,secret:e}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(t),10);return{opOb:{branch:o,contents:this.constructOpContents(s,c,t),protocol:a},counter:c}}async reveal({fee:t,gasLimit:e,storageLimit:r,proof:s}){const{pkh:o,publicKey:a}=await this.getKeys();if(!a)throw new l.PublicKeyNotFoundError(o);const[,c]=(0,p.b58DecodeAndCheckPrefix)(o,p.publicKeyHashPrefixes);if(c===p.PrefixV2.BLS12_381PublicKeyHash)if(s)(0,p.b58DecodeAndCheckPrefix)(s,[p.PrefixV2.BLS12_381Signature]);else{const{prefixSig:t}=await this.signer.provePossession();s=t}else if(s)throw new l.ProhibitedActionError("Proof field is only allowed to reveal a bls account ");const u=await this.context.readProvider.getProtocolConstants("head"),f=await this.getOperationLimits(u),d=g({fee:t,storageLimit:r,gasLimit:e},f),m=await(0,h.createRevealOperation)({fee:d.fee,gasLimit:d.gasLimit,storageLimit:d.storageLimit,proof:s},o,a),y=this.convertIntoArray(m),b=await this.getBlockHash(),v=await this.getProtocolHash();i(this,n,{},"f");const w=parseInt(await this.getHeadCounter(o),10);return{opOb:{branch:b,contents:this.constructOpContents(y,w,o),protocol:v},counter:w}}async originate({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,c,o.OpKind.ORIGINATION,r),f=await(0,h.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...s,...g({fee:t,storageLimit:e,gasLimit:r},l)})),d=await this.addRevealOperationIfNeeded(f,c),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(c),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,c,a),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async transaction({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async stake({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,to:a,...g({fee:t,storageLimit:e,gasLimit:r},u),parameter:{entrypoint:"stake",value:{prim:"Unit"}}}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async unstake({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSACTION,r),l=await(0,h.createTransferOperation)({...s,to:a,...g({fee:t,storageLimit:e,gasLimit:r},u),parameter:{entrypoint:"unstake",value:{prim:"Unit"}}}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async finalizeUnstake({fee:t,storageLimit:e,gasLimit:r,to:s,...a}){const{pkh:c}=await this.getKeys(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,c,o.OpKind.TRANSACTION,r),f=await(0,h.createTransferOperation)({...a,to:s||c,amount:0,...g({fee:t,storageLimit:e,gasLimit:r},l),parameter:{entrypoint:"finalize_unstake",value:{prim:"Unit"}}}),d=await this.addRevealOperationIfNeeded(f,c),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(c),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,c,a.source),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async delegation({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.DELEGATION,r),l=await(0,h.createSetDelegateOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async registerDelegate({fee:t,storageLimit:e,gasLimit:r},s){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.DELEGATION,r),l=g({fee:t,storageLimit:e,gasLimit:r},u),f=await(0,h.createRegisterDelegateOperation)({fee:l.fee,storageLimit:l.storageLimit,gasLimit:l.gasLimit},a),d=await this.addRevealOperationIfNeeded(f,a),p=this.convertIntoArray(d),m=await this.getBlockHash(),y=await this.getProtocolHash();i(this,n,{},"f");const b=parseInt(await this.getHeadCounter(a),10),v={opOb:{branch:m,contents:this.constructOpContents(p,b,a,s),protocol:y},counter:b};return this.withSimulationMetadata(v,this.getSingleManagerOperationSimulation(p,r))}async registerGlobalConstant({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.REGISTER_GLOBAL_CONSTANT,r),l=await(0,h.createRegisterGlobalConstantOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async updateConsensusKey({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),[,u]=(0,p.b58DecodeAndCheckPrefix)(s.pk,p.publicKeyPrefixes);if(u===p.PrefixV2.BLS12_381PublicKey){if(!s.proof)throw new l.InvalidProofError("Proof is required to set a bls account as consensus key ")}else if(s.proof)throw new l.ProhibitedActionError("Proof field is only allowed for a bls account as consensus key");const f=await this.context.readProvider.getProtocolConstants("head"),d=await this.getOperationLimitsForManagerOperation(f,c,o.OpKind.UPDATE_CONSENSUS_KEY,r),m=await(0,h.createUpdateConsensusKeyOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},d)}),y=await this.addRevealOperationIfNeeded(m,c),b=this.convertIntoArray(y),v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(c),10),_={opOb:{branch:v,contents:this.constructOpContents(b,E,c,a),protocol:w},counter:E};return this.withSimulationMetadata(_,this.getSingleManagerOperationSimulation(b,r))}async updateCompanionKey({fee:t,storageLimit:e,gasLimit:r,...s},a){const{pkh:c}=await this.getKeys(),[,u]=(0,p.b58DecodeAndCheckPrefix)(s.pk,p.publicKeyPrefixes);if(u!==p.PrefixV2.BLS12_381PublicKey)throw new l.ProhibitedActionError("companion key must be a bls account");if(!s.proof)throw new l.InvalidProofError("Proof is required to set a bls account as companion key ");const f=await this.context.readProvider.getProtocolConstants("head"),d=await this.getOperationLimitsForManagerOperation(f,c,o.OpKind.UPDATE_COMPANION_KEY,r),m=await(0,h.createUpdateCompanionKeyOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},d)}),y=await this.addRevealOperationIfNeeded(m,c),b=this.convertIntoArray(y),v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(c),10),_={opOb:{branch:v,contents:this.constructOpContents(b,E,c,a),protocol:w},counter:E};return this.withSimulationMetadata(_,this.getSingleManagerOperationSimulation(b,r))}async increasePaidStorage({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.INCREASE_PAID_STORAGE,r),l=await(0,h.createIncreasePaidStorageOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async ballot(t){const{pkh:e}=await this.getKeys(),r=await(0,h.createBallotOperation)({...t}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(e),10);let l;try{l=await this.rpc.getCurrentPeriod()}catch(t){throw new u.RPCResponseError("Failed to get the current voting period index")}return{opOb:{branch:o,contents:this.constructOpContents(s,c,e,t.source,l),protocol:a},counter:c}}async proposals(t){const{pkh:e}=await this.getKeys(),r=await(0,h.createProposalsOperation)({...t}),s=this.convertIntoArray(r),o=await this.getBlockHash(),a=await this.getProtocolHash();i(this,n,{},"f");const c=parseInt(await this.getHeadCounter(e),10);let l;try{l=await this.rpc.getCurrentPeriod()}catch(t){throw new u.RPCResponseError("Failed to get the current voting period index")}return{opOb:{branch:o,contents:this.constructOpContents(s,c,e,t.source,l),protocol:a},counter:c}}async drainDelegate(t,e){const{pkh:r}=await this.getKeys(),s=await(0,h.createDrainDelegateOperation)({...t}),o=this.convertIntoArray(s),a=await this.getBlockHash(),c=await this.getProtocolHash();i(this,n,{},"f");const u=parseInt(await this.getHeadCounter(r),10);return{opOb:{branch:a,contents:this.constructOpContents(o,u,r,e),protocol:c},counter:u}}async transferTicket({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.TRANSFER_TICKET,r),l=await(0,h.createTransferTicketOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupAddMessages({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_ADD_MESSAGES,r),l=await(0,h.createSmartRollupAddMessagesOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupOriginate({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_ORIGINATE,r),l=await(0,h.createSmartRollupOriginateOperation)({...g({fee:t,storageLimit:e,gasLimit:r},u),...s}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async smartRollupExecuteOutboxMessage({fee:t,storageLimit:e,gasLimit:r,...s}){const{pkh:a}=await this.getKeys(),c=await this.context.readProvider.getProtocolConstants("head"),u=await this.getOperationLimitsForManagerOperation(c,a,o.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,r),l=await(0,h.createSmartRollupExecuteOutboxMessageOperation)({...s,...g({fee:t,storageLimit:e,gasLimit:r},u)}),f=await this.addRevealOperationIfNeeded(l,a),d=this.convertIntoArray(f),p=await this.getBlockHash(),m=await this.getProtocolHash();i(this,n,{},"f");const y=parseInt(await this.getHeadCounter(a),10),b={opOb:{branch:p,contents:this.constructOpContents(d,y,a,s.source),protocol:m},counter:y};return this.withSimulationMetadata(b,this.getSingleManagerOperationSimulation(d,r))}async batch(t,e){const{pkh:r,publicKey:s}=await this.getKeys(),o=await this.context.readProvider.getProtocolConstants("head"),u=await this.isRevealOpNeeded(t,r),f=t.reduce((t,e)=>(0,a.isOpWithFee)(e)&&void 0!==e.gasLimit?t.plus(e.gasLimit):t,new d(u?(0,c.getRevealGasLimit)(r):0)),m=this.getOperationLimits(o,{opsNeedingGasLimitPatch:t.filter(t=>(0,a.isOpWithFee)(t)&&void 0===t.gasLimit).length,explicitGasLimitTotal:f}),y=[],b=[];if(e)for(const r of t)if((0,a.isOpWithFee)(r)){const t=e.shift(),n=g(r,{fee:t.suggestedFeeMutez,storageLimit:t.storageLimit,gasLimit:t.gasLimit});y.push(await this.getRPCOp({...r,...n})),b.push(!1)}else y.push({...r}),b.push(!1);else for(const e of t)if((0,a.isOpWithFee)(e)){const t=g(e,m);y.push(await this.getRPCOp({...e,...t})),b.push(void 0===e.gasLimit)}else y.push({...e}),b.push(!1);if(u){if(!s)throw new l.PublicKeyNotFoundError(r);const[,t]=(0,p.b58DecodeAndCheckPrefix)(r,p.publicKeyHashPrefixes);y.unshift(await(0,h.createRevealOperation)({fee:(0,c.getRevealFee)(r),storageLimit:c.REVEAL_STORAGE_LIMIT,gasLimit:(0,c.getRevealGasLimit)(r),proof:t===p.PrefixV2.BLS12_381PublicKeyHash?(await this.signer.provePossession()).prefixSig:void 0},r,s)),b.unshift(!1)}const v=await this.getBlockHash(),w=await this.getProtocolHash();i(this,n,{},"f");const E=parseInt(await this.getHeadCounter(r),10),_=this.constructOpContents(y,E,r),A=b.flatMap((t,e)=>t?[e]:[]);return{opOb:{branch:v,contents:_,protocol:w},counter:E,simulation:A.length>0?{gasLimitPatchableIndexes:A}:void 0}}async contractCall(t){const e=await this.getBlockHash(),r=await this.getProtocolHash(),{pkh:s}=await this.getKeys();i(this,n,{},"f");const a=parseInt(await this.getHeadCounter(s),10),c=t.toTransferParams(),u=await this.context.readProvider.getProtocolConstants("head"),l=await this.getOperationLimitsForManagerOperation(u,s,o.OpKind.TRANSACTION,c.gasLimit),h=g({fee:c.fee,storageLimit:c.storageLimit,gasLimit:c.gasLimit},l),f={kind:o.OpKind.TRANSACTION,fee:c.fee??h.fee,gas_limit:c.gasLimit??h.gasLimit,storage_limit:c.storageLimit??h.storageLimit,amount:String(c.amount),destination:c.to,parameters:c.parameter},d=await this.addRevealOperationIfNeeded(f,s),p=this.convertIntoArray(d),m={opOb:{branch:e,contents:this.constructOpContents(p,a,s),protocol:r},counter:a};return this.withSimulationMetadata(m,this.getSingleManagerOperationSimulation(p,c.gasLimit))}async toPreapply(t){const{opOb:{contents:e,branch:r,protocol:n}}=t,i=this.toForge(t),s=await this.context.forger.forge(i);return[{contents:e,branch:r,protocol:n,signature:(await this.context.signer.sign(s,new Uint8Array([3]))).prefixSig}]}toForge({opOb:{contents:t,branch:e}}){return{branch:e,contents:t}}}e.PrepareProvider=m,n=new WeakMap},5605(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Provider=void 0;const n=r(2211),i=r(6568),s=r(286),o=r(2654),a=r(3157),c=r(2403);e.Provider=class{clearRpcCache(){const t=this.context.rpc;"function"==typeof t.deleteAllCachedData&&t.deleteAllCachedData()}parseRpcErrors(t){if(!(t instanceof n.HttpResponseError))return[];let e;try{e=JSON.parse(t.body)}catch{return[]}return Array.isArray(e)?e.filter(t=>"object"==typeof t&&null!==t):[]}toBigInt(t){if("bigint"==typeof t)return t;if("number"==typeof t&&Number.isFinite(t)&&Number.isInteger(t))return BigInt(t);if("string"==typeof t&&/^-?\d+$/.test(t))return BigInt(t);if("object"==typeof t&&null!==t&&"toString"in t){const e=t.toString();if(/^-?\d+$/.test(e))return BigInt(e)}}parseCounterAdjustments(t){return this.parseRpcErrors(t).filter(t=>{const e=t.id,r=t.contract,n=t.expected,i=t.found;return"string"==typeof e&&(e.endsWith("contract.counter_in_the_past")||e.endsWith("contract.counter_in_the_future"))&&"string"==typeof r&&"string"==typeof n&&"string"==typeof i}).map(t=>({contract:t.contract,expected:BigInt(t.expected),found:BigInt(t.found)})).filter(t=>t.expected!==t.found)}hasGasLimitTooHighAndBlockExhausted(t){const e=this.parseRpcErrors(t).map(t=>t.id).filter(t=>"string"==typeof t);return e.some(t=>t.endsWith("gas_limit_too_high"))&&e.some(t=>t.endsWith("gas_exhausted.block"))}async patchSimulationGasLimits(t,e,r){if(!this.hasGasLimitTooHighAndBlockExhausted(e))return;if(!Array.isArray(t.operation.contents))return;const n=await this.context.readProvider.getProtocolConstants("head"),i=this.toBigInt(n.hard_gas_limit_per_operation),s=this.toBigInt(n.hard_gas_limit_per_block),o=BigInt(0);if(void 0===i||void 0===s||i<=o||s<=o)return;const a=t.operation.contents.map(t=>({...t})),c=r&&r.length>0?r.filter(t=>t>=0&&t<a.length):[];let u=o;for(const[t,e]of a.entries()){const r=e.kind,n=this.toBigInt(e.gas_limit);if(void 0!==n){if(0===c.length){if("reveal"!==r&&n>=i){c.push(t);continue}}else if(c.includes(t))continue;u+=n}}if(0===c.length)return;const l=s-u,h=l>o?l/BigInt(c.length):o,f=h>i?i:h;let d=!1;for(const t of c){const e=a[t];this.toBigInt(e.gas_limit)!==f&&(a[t].gas_limit=f.toString(),d=!0)}return d?{...t,operation:{...t.operation,contents:a}}:void 0}patchSimulationCounters(t,e){if(0===e.length)return;if(!Array.isArray(t.operation.contents))return;const r=t.operation.contents.map(t=>({...t}));let n=!1;for(const t of e){const e=t.expected-t.found;for(const i of r){const r=i.source,s=i.counter;if(r!==t.contract||void 0===s)continue;const o=BigInt(String(s));o<t.found||(i.counter=(o+e).toString(),n=!0)}}return n?{...t,operation:{...t.operation,contents:r}}:void 0}get rpc(){return this.context.rpc}get signer(){return this.context.signer}constructor(t){this.context=t}async forge({opOb:{branch:t,contents:e,protocol:r},counter:n}){return{opbytes:await this.context.forger.forge({branch:t,contents:e}),opOb:{branch:t,contents:e,protocol:r},counter:n}}async estimate({fee:t,gasLimit:e,storageLimit:r,...n},i){let o=t,a=e,c=r;if(o&&o%1!=0)throw new s.InvalidEstimateValueError(`Fee value must not be a decimal: ${o}`);if(a&&a%1!=0)throw new s.InvalidEstimateValueError(`Gas Limit value must not be a decimal: ${a}`);if(c&&c%1!=0)throw new s.InvalidEstimateValueError(`Storage Limit value must not be a decimal: ${c}`);if(void 0===t||void 0===e||void 0===r){const s=await i({fee:t,gasLimit:e,storageLimit:r,...n});o??(o=s.suggestedFeeMutez),a??(a=s.gasLimit),c??(c=s.storageLimit)}return{fee:o,gasLimit:a,storageLimit:c}}async getRPCOp(t){switch(t.kind){case a.OpKind.TRANSACTION:return(0,o.createTransferOperation)({...t});case a.OpKind.ORIGINATION:return(0,o.createOriginationOperation)(await this.context.parser.prepareCodeOrigination({...t}));case a.OpKind.DELEGATION:return(0,o.createSetDelegateOperation)({...t});case a.OpKind.REGISTER_GLOBAL_CONSTANT:return(0,o.createRegisterGlobalConstantOperation)({...t});case a.OpKind.INCREASE_PAID_STORAGE:return(0,o.createIncreasePaidStorageOperation)({...t});case a.OpKind.UPDATE_CONSENSUS_KEY:return(0,o.createUpdateConsensusKeyOperation)({...t});case a.OpKind.UPDATE_COMPANION_KEY:return(0,o.createUpdateCompanionKeyOperation)({...t});case a.OpKind.TRANSFER_TICKET:return(0,o.createTransferTicketOperation)({...t});case a.OpKind.SMART_ROLLUP_ADD_MESSAGES:return(0,o.createSmartRollupAddMessagesOperation)({...t});case a.OpKind.SMART_ROLLUP_ORIGINATE:return(0,o.createSmartRollupOriginateOperation)({...t});case a.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE:return(0,o.createSmartRollupExecuteOutboxMessageOperation)({...t});default:throw new c.InvalidOperationKindError(t.kind)}}async simulate(t,e){const r=e?.simulation?.gasLimitPatchableIndexes;try{return{opResponse:await this.rpc.simulateOperation(t),op:t,context:this.context.clone()}}catch(e){const n=this.parseCounterAdjustments(e),i=this.patchSimulationCounters(t,n);if(i)try{return{opResponse:await this.rpc.simulateOperation(i),op:i,context:this.context.clone()}}catch(t){const e=await this.patchSimulationGasLimits(i,t,r);if(!e)throw t;return{opResponse:await this.rpc.simulateOperation(e),op:e,context:this.context.clone()}}const s=await this.patchSimulationGasLimits(t,e,r);if(!s)throw e;return{opResponse:await this.rpc.simulateOperation(s),op:s,context:this.context.clone()}}}async isRevealOpNeeded(t,e){return!(!await this.isAccountRevealRequired(e)||!this.isRevealRequiredForOpType(t))}async isAccountRevealRequired(t){return!await this.context.readProvider.isAccountRevealed(t,"head")}isRevealRequiredForOpType(t){let e=!1;for(const r of t)(0,i.isOpRequireReveal)(r)&&(e=!0);return e}async signAndInject(t){let e=await this.signForgedBytes(t);const r=[];let n;try{n=await this.rpc.preapplyOperations([e.opOb])}catch(t){const r=this.parseCounterAdjustments(t),i=await this.patchForgedBytesCounters(e,r);if(!i)throw t;e=await this.signForgedBytes(i),n=await this.rpc.preapplyOperations([e.opOb])}if(!Array.isArray(n))throw new s.TezosPreapplyFailureError(n);for(let t=0;t<n.length;t++)for(let e=0;e<n[t].contents.length;e++)r.push(n[t].contents[e]);const i=(0,s.flattenErrors)(n);if(i.length)throw new s.TezosOperationError(i,"Error occurred during validation simulation of operation",r);const o=await this.context.injector.inject(e.opbytes);return this.clearRpcCache(),{hash:o,forgedBytes:e,opResponse:r,context:this.context.clone()}}async signForgedBytes(t){const e=await this.signer.sign(t.opbytes,new Uint8Array([3]));return{...t,opbytes:e.sbytes,opOb:{...t.opOb,signature:e.prefixSig}}}async patchForgedBytesCounters(t,e){if(0===e.length||!Array.isArray(t.opOb.contents))return;const r=t.opOb.branch;if("string"!=typeof r)return;const n=t.opOb.contents.map(t=>({...t}));let i=!1;for(const t of e){const e=t.expected-t.found;for(const r of n){const n=r.source,s=r.counter;if(n!==t.contract||void 0===s)continue;const o=BigInt(String(s));o<t.found||(r.counter=(o+e).toString(),i=!0)}}if(!i)return;const s=await this.context.forger.forge({branch:r,contents:n});return{...t,opbytes:s,opOb:{...t.opOb,contents:n}}}}},3484(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isBlockHashIdentifier=void 0;const n=r(2403);r(7873).default;e.isBlockHashIdentifier=t=>(0,n.validateBlock)(t)===n.ValidationResult.VALID},4631(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcReadAdapter=void 0;r(7873).default;e.RpcReadAdapter=class{constructor(t){this.rpc=t}async getBalance(t,e){return this.rpc.getBalance(t,{block:String(e)})}async getSpendable(t,e){return this.rpc.getSpendable(t,{block:String(e)})}async getDelegate(t,e){return this.rpc.getDelegate(t,{block:String(e)})}async getNextProtocol(t){return(await this.rpc.getProtocols({block:String(t)})).next_protocol}async getProtocolConstants(t){const{time_between_blocks:e,minimal_block_delay:r,hard_gas_limit_per_operation:n,hard_gas_limit_per_block:i,hard_storage_limit_per_operation:s,cost_per_byte:o,smart_rollup_origination_size:a}=await this.rpc.getConstants({block:String(t)});return{time_between_blocks:e,minimal_block_delay:r,hard_gas_limit_per_operation:n,hard_gas_limit_per_block:i,hard_storage_limit_per_operation:s,cost_per_byte:o,smart_rollup_origination_size:a}}async getScript(t,e){const{script:r}=await this.rpc.getContract(t,{block:String(e)});return r}async getStorage(t,e){return this.rpc.getStorage(t,{block:String(e)})}async getBlockHash(t){const{hash:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getBlockLevel(t){const{level:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getCounter(t,e){const{counter:r}=await this.rpc.getContract(t,{block:String(e)});return r||"0"}async getBlockTimestamp(t){const{timestamp:e}=await this.rpc.getBlockHeader({block:String(t)});return e}async getBigMapValue(t,e){return this.rpc.getBigMapExpr(t.id,t.expr,{block:String(e)})}async getSaplingDiffById(t,e){return this.rpc.getSaplingDiffById(t.id,{block:String(e)})}async getSaplingDiffByContract(t,e){return this.rpc.getSaplingDiffByContract(t,{block:String(e)})}async getEntrypoints(t){return this.rpc.getEntrypoints(t)}async getChainId(){return this.rpc.getChainId()}async isAccountRevealed(t,e){const r=await this.rpc.getManagerKey(t,{block:String(e)});return r&&"object"==typeof r?!!r.key:!!r}async getBlock(t){return this.rpc.getBlock({block:String(t)})}getLiveBlocks(t){return this.rpc.getLiveBlocks({block:String(t)})}getAdaptiveIssuanceLaunchCycle(t){return this.rpc.getAdaptiveIssuanceLaunchCycle({block:String(t)})}}},1102(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnconfiguredSignerError=void 0;const n=r(6571);class i extends n.TezosToolkitConfigError{constructor(){super(),this.name="UnconfiguredSignerError",this.message="No signer has been configured. Please configure one by calling setProvider({signer}) on your TezosToolkit instance."}}e.UnconfiguredSignerError=i},6425(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NoopSigner=void 0;const n=r(1102);e.NoopSigner=class{async publicKey(){throw new n.UnconfiguredSignerError}async publicKeyHash(){throw new n.UnconfiguredSignerError}async secretKey(){throw new n.UnconfiguredSignerError}async sign(t,e){throw new n.UnconfiguredSignerError}}},9940(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createObservableFromSubscription=function(t){return new n.Observable(e=>(t.on("data",t=>{e.next(t)}),t.on("error",t=>{e.error(t)}),t.on("close",()=>{e.complete()}),()=>{t.close()}))};const n=r(1948)},4938(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidFilterExpressionError=e.UnsupportedEventError=void 0;const n=r(6571);class i extends n.ParameterValidationError{constructor(t){super(),this.type=t,this.name="UnsupportedEventError",this.message=`Unsupported event type "${t}" expecting one of the "data", "error", or "close".`}}e.UnsupportedEventError=i;class s extends n.ParameterValidationError{constructor(t){super(),this.invalidExpression=t,this.name="InvalidFilterExpressionError",this.message="Invalid filter expression expecting the object to contain either and/or property"}}e.InvalidFilterExpressionError=s},8706(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFilter=e.evaluateExpression=e.evaluateOpFilter=e.eventFilter=void 0;const n=r(4938);e.eventFilter=(t,e,r,n)=>"event"===t.kind&&((!r||t.tag===r)&&((!e||t.source===e)&&(!n||"applied"===t.result.status)));e.evaluateOpFilter=(t,e)=>"opHash"in e?((t,e)=>t.hash===e.opHash)(t,e):"source"in e?((t,e)=>{switch(t.kind){case"attestation":return"metadata"in t&&t.metadata.delegate===e.source;case"activate_account":return"metadata"in t&&t.pkh===e.source;default:return"source"in t&&t.source===e.source}})(t,e):"kind"in e?((t,e)=>"kind"in t&&t.kind===e.kind)(t,e):"destination"in e&&((t,e)=>{switch(t.kind){case"delegation":return t.delegate===e.destination;case"origination":if("metadata"in t&&"operation_result"in t.metadata&&"originated_contracts"in t.metadata.operation_result&&Array.isArray(t.metadata.operation_result.originated_contracts))return t.metadata.operation_result.originated_contracts.some(t=>t===e.destination);break;case"transaction":return t.destination===e.destination;default:return!1}})(t,e);e.evaluateExpression=(t,r)=>{if(Array.isArray(r.and))return r.and.every(r=>(0,e.evaluateFilter)(t,r));if(Array.isArray(r.or))return r.or.some(r=>(0,e.evaluateFilter)(t,r));throw new n.InvalidFilterExpressionError(r)};e.evaluateFilter=(t,r)=>{const n=[];return Array.isArray(r)?n.push(...r):n.push(r),n.every(r=>"and"in r||"or"in r?(0,e.evaluateExpression)(t,r):(0,e.evaluateOpFilter)(t,r))}},2422(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4040(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ObservableSubscription=e.UnsupportedEventError=void 0;const n=r(1948),i=r(1018),s=r(4938);var o=r(4938);Object.defineProperty(e,"UnsupportedEventError",{enumerable:!0,get:function(){return o.UnsupportedEventError}});e.ObservableSubscription=class{constructor(t,e=!1,r=(0,i.retry)()){this.shouldRetry=e,this.operatorFunction=r,this.errorListeners=[],this.messageListeners=[],this.closeListeners=[],this.completed$=new n.Subject,t.pipe((0,i.takeUntil)(this.completed$),(0,i.tap)(t=>{this.call(this.messageListeners,t)},t=>{this.call(this.errorListeners,t)},()=>{this.call(this.closeListeners)}),this.shouldRetry?r:(0,i.tap)(),(0,i.catchError)(()=>n.NEVER)).subscribe()}call(t,e){for(const r of t)try{r(e)}catch(t){console.error(t)}}remove(t,e){const r=t.indexOf(e);-1!==r&&t.splice(r,1)}on(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 s.UnsupportedEventError(t)}}off(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 s.UnsupportedEventError(t)}}close(){this.completed$.next()}}},8648(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PollingSubscribeProvider=e.defaultConfigStreamer=void 0;const n=r(1948),i=r(1018),s=r(8706),o=r(4040),a=r(7873);e.defaultConfigStreamer={shouldObservableSubscriptionRetry:!1,observableSubscriptionRetryFunction:(0,i.retry)()};e.PollingSubscribeProvider=class{constructor(t,r={}){this.context=t,this._config$=new n.BehaviorSubject({...e.defaultConfigStreamer,...r}),this.timer$=this._config$.pipe((0,i.map)(t=>t?.pollingIntervalMilliseconds),(0,i.switchMap)(t=>t?(0,n.timer)(0,t):(0,n.from)(this.getConfirmationPollingInterval()).pipe((0,i.switchMap)(t=>(0,n.timer)(0,t))))),this.newBlock$=this.timer$.pipe((0,i.exhaustMap)(()=>(t=>(0,n.from)(t.rpc.getBlock()).pipe((0,i.first)()))(this.context)),(0,i.distinctUntilKeyChanged)("hash"),(0,i.share)({resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0}))}get config(){return this._config$.getValue()}async getConfirmationPollingInterval(){if(!this.config.pollingIntervalMilliseconds){const t=5e3,e=700;try{const r=await this.context.readProvider.getProtocolConstants("head"),n=(r.minimal_block_delay?r.minimal_block_delay.multipliedBy(1e3):new a.default(t)).dividedBy(3);this.config.pollingIntervalMilliseconds=0===n.toNumber()?e:Math.max(n.toNumber(),e)}catch(e){return t}}return this.config.pollingIntervalMilliseconds}subscribeBlock(t){return new o.ObservableSubscription(this.newBlock$,this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribe(t){return new o.ObservableSubscription(this.newBlock$.pipe((0,i.map)(t=>t?.hash)),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribeOperation(t){return new o.ObservableSubscription(this.newBlock$.pipe((t=>(0,i.concatMap)(e=>new n.Observable(r=>{for(const n of e.operations)for(const e of n)for(const n of e.contents)(0,s.evaluateFilter)({hash:e.hash,...n},t)&&r.next({hash:e.hash,...n});r.complete()})))(t)),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction)}subscribeEvent(t){return new o.ObservableSubscription(this.newBlock$.pipe((e=t,(0,i.concatMap)(t=>new n.Observable(r=>{for(const n of t.operations)for(const i of n)for(const n of i.contents){const o=n.metadata.internal_operation_results;if(o)for(const n of o)(0,s.eventFilter)(n,e?.address,e?.tag,e?.excludeFailedOperations)&&r.next({opHash:i.hash,blockHash:t.hash,level:t.header.level,...n})}r.complete()})))),this.config.shouldObservableSubscriptionRetry,this.config.observableSubscriptionRetryFunction);var e}}},4779(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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}),e.TezosToolkit=e.importKey=e.TaquitoLocalForger=e.RpcReadAdapter=e.ObservableSubscription=e.PollingSubscribeProvider=e.OperationBatch=e.RpcForger=e.CompositeForger=e.UnitValue=e.MichelsonMap=e.Token=void 0;const s=r(3157),o=r(7021),a=r(2403),c=r(8320),u=r(577),l=r(4631),h=r(6425),f=r(8648),d=r(4982),p=r(1170),g=r(8724),m=r(8541),y=r(2245),b=r(5602);var v=r(5602);Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return v.Token}}),Object.defineProperty(e,"MichelsonMap",{enumerable:!0,get:function(){return v.MichelsonMap}}),Object.defineProperty(e,"UnitValue",{enumerable:!0,get:function(){return v.UnitValue}}),i(r(5283),e),i(r(7021),e),i(r(2445),e),i(r(9676),e);var w=r(3215);Object.defineProperty(e,"CompositeForger",{enumerable:!0,get:function(){return w.CompositeForger}});var E=r(9719);Object.defineProperty(e,"RpcForger",{enumerable:!0,get:function(){return E.RpcForger}}),i(r(105),e);var _=r(5025);Object.defineProperty(e,"OperationBatch",{enumerable:!0,get:function(){return _.OperationBatch}}),i(r(2422),e);var A=r(8648);Object.defineProperty(e,"PollingSubscribeProvider",{enumerable:!0,get:function(){return A.PollingSubscribeProvider}});var O=r(4040);Object.defineProperty(e,"ObservableSubscription",{enumerable:!0,get:function(){return O.ObservableSubscription}}),i(r(1174),e),i(r(1170),e),i(r(9164),e),i(r(2245),e),i(r(3971),e),i(r(8541),e),i(r(6424),e),i(r(458),e),i(r(4377),e),i(r(577),e),i(r(152),e),i(r(1566),e),i(r(7157),e);var S=r(4631);Object.defineProperty(e,"RpcReadAdapter",{enumerable:!0,get:function(){return S.RpcReadAdapter}}),i(r(5681),e);var T=r(8724);Object.defineProperty(e,"TaquitoLocalForger",{enumerable:!0,get:function(){return T.TaquitoLocalForger}}),i(r(3682),e);var P=r(8763);Object.defineProperty(e,"importKey",{enumerable:!0,get:function(){return P.importKey}});e.TezosToolkit=class{constructor(t){this._rpc=t,this._options={},this.format=a.format,"string"==typeof this._rpc?this._rpcClient=new s.RpcClient(this._rpc):this._rpcClient=this._rpc,this._context=new o.Context(t),this._wallet=new p.Wallet(this._context),this.setProvider({rpc:this._rpcClient})}setProvider({rpc:t,stream:e,signer:r,protocol:n,config:i,forger:s,wallet:o,packer:a,globalConstantsProvider:c,readProvider:u,parserProvider:l,injectorProvider:h}){this.setRpcProvider(t),this.setStreamProvider(e),this.setSignerProvider(r),this.setForgerProvider(s),this.setWalletProvider(o),this.setPackerProvider(a),this.setGlobalConstantsProvider(c),this.setReadProvider(u),this.setParserProvider(l),this.setInjectorProvider(h),this._context.proto=n,i&&this._context.setPartialConfig(i)}setSignerProvider(t){this._options.signer||void 0!==t?void 0!==t&&(this._context.signer=t,this._options.signer=t):(this._context.signer=new h.NoopSigner,this._options.signer=t)}setRpcProvider(t){"string"==typeof t?this._rpcClient=new s.RpcClient(t):void 0===t||(this._rpcClient=t),this._options.rpc=this._rpcClient,this._context.rpc=this._rpcClient}setForgerProvider(t){if(void 0!==t)this._options.forger=t,this._context.forger=t;else if(void 0===this._options.forger){const t=this.getFactory(g.TaquitoLocalForger)();this._options.forger=t,this._context.forger=t}}setStreamProvider(t){if("string"==typeof t){const e=new f.PollingSubscribeProvider(new o.Context(new s.RpcClient(t)));this._options.stream=e,this._context.stream=e}else if(void 0!==t)this._options.stream=t,this._context.stream=t;else if(void 0===this._options.stream){const t=this.getFactory(f.PollingSubscribeProvider)();this._options.stream=t,this._context.stream=t}}setWalletProvider(t){if(this._options.wallet||void 0!==t)void 0!==t&&(this._options.wallet=t,this._context.walletProvider=t);else{const t=this.getFactory(p.LegacyWalletProvider)();this._options.wallet=t,this._context.walletProvider=t}}setPackerProvider(t){if(this._options.packer||void 0!==t)void 0!==t&&(this._context.packer=t,this._options.packer=t);else{const t=this.getFactory(u.RpcPacker)();this._context.packer=t,this._options.packer=t}}setGlobalConstantsProvider(t){if(this._options.globalConstantsProvider||void 0!==t)void 0!==t&&(this._context.globalConstantsProvider=t,this._options.globalConstantsProvider=t);else{const t=new c.NoopGlobalConstantsProvider;this._context.globalConstantsProvider=t,this._options.globalConstantsProvider=t}}setReadProvider(t){const e=t||new l.RpcReadAdapter(this._context.rpc);this._options.readProvider=e,this._context.readProvider=e}setParserProvider(t){if(this._options.parserProvider||void 0!==t)void 0!==t&&(this._context.parser=t,this._options.parserProvider=t);else{const t=new m.MichelCodecParser(this._context);this._context.parser=t,this._options.parserProvider=t}}setInjectorProvider(t){if(this._options.injectorProvider||void 0!==t)void 0!==t&&(this._context.injector=t,this._options.injectorProvider=t);else{const t=new y.RpcInjector(this._context);this._context.injector=t,this._options.injectorProvider=t}}setFieldNumberingStrategy(t){b.Token.fieldNumberingStrategy=t}get tz(){return this._context.tz}get contract(){return this._context.contract}get prepare(){return this._context.prepare}get wallet(){return this._wallet}get operation(){return this._context.operationFactory}get estimate(){return this._context.estimate}get stream(){return this._context.stream}get rpc(){return this._context.rpc}get signer(){return this._context.signer}get globalConstants(){return this._context.globalConstantsProvider}addExtension(t){Array.isArray(t)?t.forEach(t=>t.configureContext(this._context)):t.configureContext(this._context)}getFactory(t){return(...e)=>new t(this._context,...e)}getVersionInfo(){return d.VERSION}}},1174(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});r(7873).default},8907(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RpcTzProvider=void 0;r(7873).default;const n=r(1859),i=r(2403),s=r(6571),o=r(5605),a=r(3682);class c extends o.Provider{constructor(t){super(t),this.prepare=new a.PrepareProvider(this.context)}async getBalance(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getBalance(t,"head")}async getSpendable(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getSpendable(t,"head")}async getDelegate(t){const e=(0,i.validateAddress)(t);if(e!==i.ValidationResult.VALID)throw new s.InvalidAddressError(t,e);return this.context.readProvider.getDelegate(t,"head")}async activate(t,e){const r=(0,i.validateKeyHash)(t);if(r!==i.ValidationResult.VALID)throw new i.InvalidKeyHashError(t,r);const s=await this.prepare.activate({pkh:t,secret:e}),o=await this.forge(s),a=`${o.opbytes}00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`;return new n.Operation(await this.rpc.injectOperation(a),{...o,opbytes:a},[],this.context.clone())}}e.RpcTzProvider=c},4982(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VERSION=void 0,e.VERSION={commitHash:"13f62cd47ea018312f100b660d0225604c757afa",version:"25.0.0"}},2538(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BatchWalletOperation=e.WALLET_BATCH_KINDS=void 0;const n=r(3157),i=r(6568),s=r(3871),o=r(2599);e.WALLET_BATCH_KINDS=[n.OpKind.REVEAL,n.OpKind.ORIGINATION,n.OpKind.TRANSACTION,n.OpKind.DELEGATION,n.OpKind.REGISTER_GLOBAL_CONSTANT,n.OpKind.INCREASE_PAID_STORAGE,n.OpKind.TRANSFER_TICKET];class a extends s.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e,this.getOriginatedContractAddresses=async()=>{const t=await this.operationResults();if(t){const e=t.filter(t=>"origination"===t.kind);let r=[];for(const t of e)t.metadata.operation_result.originated_contracts&&(r=[...r,...t.metadata.operation_result.originated_contracts]);return r}throw new o.ObservableError("Unable to fetch operation results")}}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.REVEAL);throw new o.ObservableError("Unable to fetch operation results")}async status(){if(!this._included)return"pending";const t=await this.operationResults();if(t)return t.filter(t=>-1!==e.WALLET_BATCH_KINDS.indexOf(t.kind)).map(t=>{if((0,i.hasMetadataWithResult)(t)){return t.metadata.operation_result.status}return"unknown"})[0]||"unknown";throw new o.ObservableError("Unable to fetch operation results")}}e.BatchWalletOperation=a},9734(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DelegationWalletOperation=void 0;const n=r(3157),i=r(3871),s=r(2599);class o extends i.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.REVEAL);throw new s.ObservableError("Unable to fetch operation result")}async delegationOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===n.OpKind.DELEGATION);throw new s.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.delegationOperation();return t?t.metadata.operation_result.status:"unknown"}}e.DelegationWalletOperation=o},2599(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationWalletOperationError=e.ObservableError=e.ConfirmationUndefinedError=void 0;const n=r(6571);class i extends n.TezosToolkitConfigError{constructor(){super(),this.name="ConfirmationUndefinedError",this.message="Default confirmation count can not be undefined"}}e.ConfirmationUndefinedError=i;class s extends n.NetworkError{constructor(t){super(),this.message=t,this.name="ObservableError"}}e.ObservableError=s;e.OriginationWalletOperationError=class extends s{constructor(t){super(t),this.message=t,this.name="OriginationWalletOperationError"}}},6583(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IncreasePaidStorageWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===i.OpKind.REVEAL);throw new s.ObservableError("Unable to fetch operation result")}async increasePaidStorageOperation(){const t=await this.operationResults();if(t)return t.find(t=>t.kind===i.OpKind.INCREASE_PAID_STORAGE);throw new s.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.increasePaidStorageOperation();return t?t.metadata.operation_result.status:"unknown"}}e.IncreasePaidStorageWalletOperation=o},1170(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}: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(1593),e),i(r(3871),e),i(r(122),e),i(r(77),e),i(r(9734),e),i(r(9432),e),i(r(3026),e),i(r(6117),e),i(r(4723),e)},6117(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},4723(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LegacyWalletProvider=void 0;const n=r(6568);e.LegacyWalletProvider=class{constructor(t){this.context=t}async getPKH(){return this.context.signer.publicKeyHash()}async getPK(){return this.context.signer.publicKey()}async mapTransferParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapStakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapUnstakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapFinalizeUnstakeParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSACTION)}async mapOriginateParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.ORIGINATION)}async mapDelegateParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.DELEGATION)}async mapIncreasePaidStorageWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.INCREASE_PAID_STORAGE)}async mapTransferTicketParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.TRANSFER_TICKET)}async mapRegisterGlobalConstantParamsToWalletParams(t){return(0,n.attachKind)(await t(),n.OpKind.REGISTER_GLOBAL_CONSTANT)}async sendOperations(t){return(await this.context.batch.batch(t).send()).hash}async sign(t,e){const{prefixSig:r}=await this.context.signer.sign(t,e);return r}}},808(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OperationFactory=e.createNewPollingBasedHeadObservable=void 0,e.timeoutAfter=g;const n=r(1948),i=r(1018),s=r(9940),o=r(2538),a=r(9734),c=r(6583),u=r(3871),l=r(77),h=r(122),f=r(9432),d=r(4359),p=r(3026);function g(t){return function(e){return new n.BehaviorSubject(null).pipe((0,i.timeout)({each:t,with:()=>(0,n.throwError)(()=>new d.ConfirmationTimeoutError("Confirmation polling timed out"))}),(0,i.mergeMap)(()=>e))}}e.createNewPollingBasedHeadObservable=(t,e,r)=>t.pipe(g(1e3*e.config.confirmationPollingTimeoutSecond),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0}));e.OperationFactory=class{constructor(t){this.context=t,this.sharedHeadObs=(0,n.defer)(()=>(0,s.createObservableFromSubscription)(this.context.stream.subscribeBlock("head")))}async createNewHeadObservable(){return(0,e.createNewPollingBasedHeadObservable)(this.sharedHeadObs,this.context)}createPastBlockWalker(t,e=1){return(0,n.from)(this.context.readProvider.getBlock(t)).pipe((0,i.switchMap)(t=>1===e?(0,n.of)(t):(0,n.range)(t.header.level,e-1).pipe((0,i.startWith)(t),(0,i.concatMap)(async t=>this.context.readProvider.getBlock("number"==typeof t?t:t.header.level)))))}async createHeadObservableFromConfig({blockIdentifier:t}){const e=[];return t&&e.push(this.createPastBlockWalker(t)),e.push(await this.createNewHeadObservable()),(0,n.concat)(...e)}async createOperation(t,e={}){return new u.WalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createBatchOperation(t,e={}){return new o.BatchWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createTransactionOperation(t,e={}){return new h.TransactionWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createTransferTicketOperation(t,e={}){return new f.TransferTicketWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createDelegationOperation(t,e={}){return new a.DelegationWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createOriginationOperation(t,e={}){return new l.OriginationWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createIncreasePaidStorageOperation(t,e={}){return new c.IncreasePaidStorageWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}async createRegisterGlobalConstantOperation(t,e={}){return new p.RegisterGlobalConstantWalletOperation(t,this.context.clone(),await this.createHeadObservableFromConfig(e))}}},3871(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WalletOperation=void 0;const n=r(1948),i=r(1018),s=r(6854),o=r(2403),a=r(4359),c=r(2599),u=r(6571),l="undefined"!=typeof process?process.env:void 0,h=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE??""),f=/^(1|true)$/i.test(l?.TAQUITO_OP_TRACE_VERBOSE??""),d=Number(l?.TAQUITO_OP_TRACE_SLOW_MS??"60000"),p=Number.isFinite(d)&&d>=0?d:6e4,g=t=>"object"==typeof t&&null!==t?t:void 0,m=t=>Array.isArray(t)?t.map(t=>{const e=g(t)??{},r=g(e.metadata),n=g(r?.operation_result);return{kind:"string"==typeof e.kind?e.kind:"unknown",status:"string"==typeof n?.status?n.status:"unknown",errors:(i=n?.errors,Array.isArray(i)?i:[]),consumed_milligas:"string"==typeof n?.consumed_milligas?n.consumed_milligas:void 0};var i}):[],y=t=>t instanceof Error?`${t.name}: ${t.message}`:String(t),b=t=>{h&&console.log(`[taquito:wallet-op-trace] ${JSON.stringify(t)}`)};e.WalletOperation=class{async operationResults(){return this._operationResult.pipe((0,i.first)()).toPromise()}async getInclusionBlock(){const t=await this._includedInBlock.pipe((0,i.first)()).toPromise();if(!t)throw new c.ObservableError("Inclusion block is undefined");return t}async getOperationResultsIfIncluded(){if(this._included)return this.operationResults().catch(()=>{})}async receipt(){const t=await this.operationResults();if(!t)throw new c.ObservableError("Unable to get operation results");return(0,s.receiptFromOperation)(t)}constructor(t,e,r){if(this.opHash=t,this.context=e,this._newHead$=r,this._operationResult=new n.ReplaySubject(1),this._includedInBlock=new n.ReplaySubject(1),this._included=!1,this.newHead$=this._newHead$.pipe((0,i.switchMap)(t=>{const e=this.lastHead?.header.level??t.header.level-1;return(0,n.range)(e+1,t.header.level-e-1).pipe((0,i.concatMap)(t=>this.context.readProvider.getBlock(t)),(0,i.endWith)(t))}),(0,i.tap)(t=>this.lastHead=t),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0})),this.confirmed$=this.newHead$.pipe((0,i.map)(t=>{for(const e of t.operations)for(const r of e)if(r.hash===this.opHash)return this._included=!0,this._includedInBlock.next(t),this._operationResult.next(r.contents),t}),(0,i.filter)(t=>void 0!==t),(0,i.first)(),(0,i.share)({connector:()=>new n.ReplaySubject(1),resetOnError:!1,resetOnComplete:!1,resetOnRefCountZero:!0})),(0,o.validateOperation)(this.opHash)!==o.ValidationResult.VALID)throw new u.InvalidOperationHashError(this.opHash);this.confirmed$.pipe((0,i.first)(),(0,i.catchError)(()=>(0,n.of)(void 0))).subscribe()}async getCurrentConfirmation(){return this._included?(0,n.combineLatest)([this._includedInBlock,(0,n.from)(this.context.readProvider.getBlock("head"))]).pipe((0,i.map)(([t,e])=>e.header.level-t.header.level+1),(0,i.first)()).toPromise():0}async isInCurrentBranch(t="head"){if(!this._included)return!0;const e=await this.context.readProvider.getBlockLevel(t),r=await this.getInclusionBlock(),n=e-r.header.level;if(n<=0)return!0;const i=Math.min(r.header.level+n,r.header.level+60);return new Set(await this.context.readProvider.getLiveBlocks(i)).has(r.hash)}confirmationObservable(t){if(void 0!==t&&t<1)throw new a.InvalidConfirmationCountError(t);const{defaultConfirmationCount:e}=this.context.config,r=void 0!==t?t:e;if(void 0===r)throw new c.ConfirmationUndefinedError;return(0,n.combineLatest)([this._includedInBlock,this.newHead$]).pipe((0,i.distinctUntilChanged)(([,t],[,e])=>t.hash===e.hash),(0,i.map)(([t,e])=>({block:e,expectedConfirmation:r,currentConfirmation:e.header.level-t.header.level+1,completed:e.header.level-t.header.level>=r-1,isInCurrentBranch:()=>this.isInCurrentBranch(e.hash)})),(0,i.takeWhile)(({completed:t})=>!t,!0))}async confirmation(t){const e=Date.now(),r=t??this.context.config.defaultConfirmationCount;try{const n=await this.confirmationObservable(t).toPromise(),i=await this.getOperationResultsIfIncluded(),s=m(i),o=s.filter(t=>"applied"!==t.status).map(t=>t.status),a=Date.now()-e;return(f||a>=p||o.length>0)&&b({stage:"confirmation-complete",opHash:this.opHash,elapsedMs:a,expectedConfirmation:r,currentConfirmation:n?.currentConfirmation,completed:n?.completed,statuses:s.map(t=>t.status),results:s}),n}catch(t){const n=await this.getOperationResultsIfIncluded();throw b({stage:"confirmation-error",opHash:this.opHash,elapsedMs:Date.now()-e,expectedConfirmation:r,error:y(t),results:m(n)}),t}}}},77(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OriginationWalletOperation=void 0;const n=r(3157),i=r(3484),s=r(6568),o=r(3871),a=r(2599);class c extends o.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async originationOperation(){const t=await this.operationResults();if(t)return(0,s.findWithKind)(t,n.OpKind.ORIGINATION);throw new a.ObservableError("Unable to fetch operation result")}async revealOperation(){const t=await this.operationResults();if(t)return(0,s.findWithKind)(t,n.OpKind.REVEAL);throw new a.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.originationOperation();return t?t.metadata.operation_result.status:"unknown"}async contract(){const t=await this.originationOperation(),e=(t?.metadata.operation_result.originated_contracts||[])[0];if(!e)throw new a.OriginationWalletOperationError("No contract was originated in this operation");await this.confirmation();const r=await this.getInclusionBlock();if(!(0,i.isBlockHashIdentifier)(r.hash))throw new a.OriginationWalletOperationError("Inclusion block hash is invalid");return this.context.wallet.at(e,void 0,r.hash)}}e.OriginationWalletOperation=c},6854(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.receiptFromOperation=void 0;const n=r(7873).default,i=r(5283),s=r(286);e.receiptFromOperation=(t,{ALLOCATION_BURN:e,ORIGINATION_BURN:r}={ALLOCATION_BURN:257,ORIGINATION_BURN:257})=>{n.config({DECIMAL_PLACES:0,ROUNDING_MODE:n.ROUND_UP});const o=(0,s.flattenOperationResult)({contents:t});let a=new n(0),c=new n(0),u=new n(0),l=new n(0),h=new n(0),f=new n(0);return o.forEach(t=>{u=u.plus(t.fee||0),l=l.plus(Array.isArray(t.originated_contracts)?t.originated_contracts.length*r:0),h=h.plus("allocated_destination_contract"in t?e:0),a=a.plus(t.consumed_milligas||0),f=f.plus("paid_storage_size_diff"in t&&Number(t.paid_storage_size_diff)||0)}),c=c.plus(h).plus(l).plus(f),{totalFee:u,totalMilliGas:a,totalGas:a.dividedBy(1e3),totalStorage:c,totalAllocationBurn:h,totalOriginationBurn:l,totalPaidStorageDiff:f,totalStorageBurn:new n(c.multipliedBy(i.COST_PER_BYTE))}}},3026(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegisterGlobalConstantWalletOperation=void 0;const n=r(3157),i=r(6568),s=r(3871),o=r(2599);class a extends s.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new o.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===n.OpKind.REVEAL)}async registerGlobalConstantOperation(){const t=await this.operationResults();if(t)return(0,i.findWithKind)(t,n.OpKind.REGISTER_GLOBAL_CONSTANT);throw new o.ObservableError("Unable to fetch operation result")}async status(){if(!this._included)return"pending";const t=await this.registerGlobalConstantOperation();return t?t.metadata.operation_result.status:"unknown"}async globalConstantHash(){const t=await this.registerGlobalConstantOperation();return t?.metadata.operation_result.global_address}}e.RegisterGlobalConstantWalletOperation=a},122(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.REVEAL)}async transactionOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.TRANSACTION)}async status(){if(!this._included)return"pending";const t=await this.transactionOperation();return t?t.metadata.operation_result.status:"unknown"}}e.TransactionWalletOperation=o},9432(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransferTicketWalletOperation=void 0;const n=r(3871),i=r(3157),s=r(2599);class o extends n.WalletOperation{constructor(t,e,r){super(t,e,r),this.opHash=t,this.context=e}async revealOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.REVEAL)}async transferTicketOperation(){const t=await this.operationResults();if(!t)throw new s.ObservableError("operationResult returned undefined");return t.find(t=>t.kind===i.OpKind.TRANSFER_TICKET)}async status(){if(!this._included)return"pending";const t=await this.transferTicketOperation();return t?t.metadata.operation_result.status:"unknown"}}e.TransferTicketWalletOperation=o},1593(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Wallet=e.WalletOperationBatch=void 0;const n=r(9339),i=r(6568),s=r(6571),o=r(2403),a=r(1254);class c{constructor(t,e){this.walletProvider=t,this.context=e,this.operations=[]}withTransfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.to,e);return this.operations.push({kind:i.OpKind.TRANSACTION,...t}),this}withContractCall(t,e={}){return this.withTransfer(t.toTransferParams(e))}withDelegation(t){const e=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.delegate,e);return this.operations.push({kind:i.OpKind.DELEGATION,...t}),this}withOrigination(t){return this.operations.push({kind:i.OpKind.ORIGINATION,...t}),this}withIncreasePaidStorage(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.operations.push({kind:i.OpKind.INCREASE_PAID_STORAGE,...t}),this}withTransferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.operations.push({kind:i.OpKind.TRANSFER_TICKET,...t}),this}withRegisterGlobalConstant(t){return this.operations.push({kind:i.OpKind.REGISTER_GLOBAL_CONSTANT,...t}),this}async mapOperation(t){switch(t.kind){case i.OpKind.TRANSACTION:return this.walletProvider.mapTransferParamsToWalletParams(async()=>t);case i.OpKind.ORIGINATION:return this.walletProvider.mapOriginateParamsToWalletParams(async()=>this.context.parser.prepareCodeOrigination({...t}));case i.OpKind.DELEGATION:return this.walletProvider.mapDelegateParamsToWalletParams(async()=>t);case i.OpKind.INCREASE_PAID_STORAGE:return this.walletProvider.mapIncreasePaidStorageWalletParams(async()=>t);case i.OpKind.REGISTER_GLOBAL_CONSTANT:return this.walletProvider.mapRegisterGlobalConstantParamsToWalletParams(async()=>t);case i.OpKind.TRANSFER_TICKET:return this.walletProvider.mapTransferTicketParamsToWalletParams(async()=>t);default:throw new s.InvalidOperationKindError(JSON.stringify(t.kind))}}with(t){for(const e of t)switch(e.kind){case i.OpKind.TRANSACTION:this.withTransfer(e);break;case i.OpKind.ORIGINATION:this.withOrigination(e);break;case i.OpKind.DELEGATION:this.withDelegation(e);break;case i.OpKind.INCREASE_PAID_STORAGE:this.withIncreasePaidStorage(e);break;case i.OpKind.REGISTER_GLOBAL_CONSTANT:this.withRegisterGlobalConstant(e);break;case i.OpKind.TRANSFER_TICKET:this.withTransferTicket(e);break;default:throw new s.InvalidOperationKindError(JSON.stringify(e.kind))}return this}async send(){const t=[];for(const e of this.operations)t.push(await this.mapOperation(e));const e=await this.walletProvider.sendOperations(t);return this.context.operationFactory.createBatchOperation(e)}}e.WalletOperationBatch=c;e.Wallet=class{constructor(t){this.context=t,this.walletCommand=t=>({send:t})}get walletProvider(){return this.context.walletProvider}async pkh({forceRefetch:t}={}){return this._pkh&&!t||(this._pkh=await this.walletProvider.getPKH()),this._pkh}async pk({forceRefetch:t}={}){return this._pk&&!t||(this._pk=await this.walletProvider.getPK()),this._pk}originate(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapOriginateParamsToWalletParams(()=>this.context.parser.prepareCodeOrigination({...t})),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createOriginationOperation(r)})}setDelegate(t){const e=(0,o.validateAddress)(t.delegate??"");if(t.delegate&&e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.delegate,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapDelegateParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createDelegationOperation(r)})}async signFailingNoop(t){const e={kind:i.OpKind.FAILING_NOOP,arbitrary:t.arbitrary},r=await this.context.readProvider.getBlockHash(t.basedOnBlock),n=await this.context.forger.forge({branch:r,contents:[e]});return{signature:await this.walletProvider.sign(n,Uint8Array.from([3])),bytes:n,signedContent:{branch:r,contents:[{kind:i.OpKind.FAILING_NOOP,arbitrary:t.arbitrary}]}}}registerDelegate(){return this.walletCommand(async()=>{const t=await this.walletProvider.mapDelegateParamsToWalletParams(async()=>({delegate:await this.pkh()})),e=await this.walletProvider.sendOperations([t]);return this.context.operationFactory.createDelegationOperation(e)})}transfer(t){const e=(0,o.validateAddress)(t.to);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.to,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapTransferParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransactionOperation(r)})}transferTicket(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapTransferTicketParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransferTicketOperation(r)})}stake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapStakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.to!==e)throw new s.InvalidStakingAddressError(t.to);return t.parameter={entrypoint:"stake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createTransactionOperation(r)})}unstake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapUnstakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.to!==e)throw new s.InvalidStakingAddressError(t.to);return t.parameter={entrypoint:"unstake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return await this.context.operationFactory.createTransactionOperation(r)})}finalizeUnstake(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapFinalizeUnstakeParamsToWalletParams(async()=>{const e=await this.pkh();if(t.to||(t.to=e),t.amount||(t.amount=0),0!==t.amount)throw new s.InvalidFinalizeUnstakeAmountError("Amount must be 0 to finalize unstake.");return t.parameter={entrypoint:"finalize_unstake",value:{prim:"Unit"}},t}),r=await this.walletProvider.sendOperations([e]);return await this.context.operationFactory.createTransactionOperation(r)})}increasePaidStorage(t){const e=(0,o.validateAddress)(t.destination);if(e!==o.ValidationResult.VALID)throw new s.InvalidAddressError(t.destination,e);return this.walletCommand(async()=>{const e=await this.walletProvider.mapIncreasePaidStorageWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createIncreasePaidStorageOperation(r)})}registerGlobalConstant(t){return this.walletCommand(async()=>{const e=await this.walletProvider.mapRegisterGlobalConstantParamsToWalletParams(async()=>t),r=await this.walletProvider.sendOperations([e]);return this.context.operationFactory.createRegisterGlobalConstantOperation(r)})}batch(t){const e=new c(this.walletProvider,this.context);return Array.isArray(t)&&e.with(t),e}async at(t,e=t=>t,r="head"){const i=(0,o.validateContractAddress)(t);if(i!==o.ValidationResult.VALID)throw new s.InvalidContractAddressError(t,i);const c=this.context.withExtensions().rpc,u=this.context.withExtensions().readProvider,l=async e=>({script:await u.getScript(t,e),entrypoints:"head"===e?await u.getEntrypoints(t):await c.getEntrypoints(t,{block:String(e)})});let h;try{h=await l(r)}catch(t){if("head"===r||!(0,a.isNotFoundError)(t))throw t;h=await(0,a.retryOnNotFound)(()=>l("head"))}return e(new n.ContractAbstraction(t,h.script,this,this.context.contract,h.entrypoints,c,u,"head"),this.context)}async atExactBlock(t,e=t=>t,r){const i=(0,o.validateContractAddress)(t);if(i!==o.ValidationResult.VALID)throw new s.InvalidContractAddressError(t,i);const a=this.context.withExtensions().rpc,c=this.context.withExtensions().readProvider,u=await c.getScript(t,r),l=await a.getEntrypoints(t,{block:String(r)});return e(new n.ContractAbstraction(t,u,this,this.context.contract,l,a,c,r),this.context)}}},5423(){},8379(){},8552(t,e,r){"use strict";r.d(e,{s:()=>i});var n=r(5603);function i(t,e){const r=e=>(0,n.x3)({...t,hash:e});return{...r(e),create:r}}},3556(t,e,r){"use strict";r.d(e,{Ak:()=>c,UT:()=>_,Xf:()=>w,fH:()=>v,hT:()=>b,u0:()=>a});var n=r(1633),i=r(6681);const s=BigInt(0),o=BigInt(1);function a(t,e){const r=e.negate();return t?r:e}function c(t,e){const r=(0,i.pS)(t.Fp,e.map(t=>t.Z));return e.map((e,n)=>t.fromAffine(e.toAffine(r[n])))}function u(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function l(t,e){u(t,e);const r=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:(0,n.OG)(t),maxNumber:r,shiftBy:BigInt(t)}}function h(t,e,r){const{windowSize:n,mask:i,maxNumber:s,shiftBy:a}=r;let c=Number(t&i),u=t>>a;c>n&&(c-=s,u+=o);const l=e*n;return{nextN:u,offset:l+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:e%2!=0,offsetF:l}}function f(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function d(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const p=new WeakMap,g=new WeakMap;function m(t){return g.get(t)||1}function y(t){if(t!==s)throw new Error("invalid wNAF")}class b{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let n=t;for(;e>s;)e&o&&(r=r.add(n)),n=n.double(),e>>=o;return r}precomputeWindow(t,e){const{windows:r,windowSize:n}=l(e,this.bits),i=[];let s=t,o=s;for(let t=0;t<r;t++){o=s,i.push(o);for(let t=1;t<n;t++)o=o.add(s),i.push(o);s=o.double()}return i}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let n=this.ZERO,i=this.BASE;const s=l(t,this.bits);for(let t=0;t<s.windows;t++){const{nextN:o,offset:c,isZero:u,isNeg:l,isNegF:f,offsetF:d}=h(r,t,s);r=o,u?i=i.add(a(f,e[d])):n=n.add(a(l,e[c]))}return y(r),{p:n,f:i}}wNAFUnsafe(t,e,r,n=this.ZERO){const i=l(t,this.bits);for(let t=0;t<i.windows&&r!==s;t++){const{nextN:s,offset:o,isZero:a,isNeg:c}=h(r,t,i);if(r=s,!a){const t=e[o];n=n.add(c?t.negate():t)}}return y(r),n}getPrecomputes(t,e,r){let n=p.get(e);return n||(n=this.precomputeWindow(e,t),1!==t&&("function"==typeof r&&(n=r(n)),p.set(e,n))),n}cached(t,e,r){const n=m(t);return this.wNAF(n,this.getPrecomputes(n,t,r),e)}unsafe(t,e,r,n){const i=m(t);return 1===i?this._unsafeLadder(t,e,n):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),e,n)}createCache(t,e){u(e,this.bits),g.set(t,e),p.delete(t)}hasCache(t){return 1!==m(t)}}function v(t,e,r,n){let i=e,a=t.ZERO,c=t.ZERO;for(;r>s||n>s;)r&o&&(a=a.add(i)),n&o&&(c=c.add(i)),i=i.double(),r>>=o,n>>=o;return{p1:a,p2:c}}function w(t,e,r,i){f(r,t),d(i,e);const s=r.length,o=i.length;if(s!==o)throw new Error("arrays of points and scalars must have equal length");const a=t.ZERO,c=(0,n.dJ)(BigInt(s));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const l=(0,n.OG)(u),h=new Array(Number(l)+1).fill(a);let p=a;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){h.fill(a);for(let e=0;e<o;e++){const n=i[e],s=Number(n>>BigInt(t)&l);h[s]=h[s].add(r[e])}let e=a;for(let t=h.length-1,r=a;t>0;t--)r=r.add(h[t]),e=e.add(r);if(p=p.add(e),0!==t)for(let t=0;t<u;t++)p=p.double()}return p}function E(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,i.jr)(e),e}return(0,i.D0)(t,{isLE:r})}function _(t,e,r={},n){if(void 0===n&&(n="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const r=e[t];if(!("bigint"==typeof r&&r>s))throw new Error(`CURVE.${t} must be positive bigint`)}const i=E(e.p,r.Fp,n),o=E(e.n,r.Fn,n),a=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of a)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:o}}},9991(t,e,r){"use strict";r.d(e,{FL:()=>d,Tq:()=>h,qX:()=>p,qj:()=>g});var n=r(1633),i=r(36),s=r(6681);const o=n.Ph;function a(t,e){if(u(t),u(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function c(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function u(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function l(t){if(!(0,i.aY)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,i.AI)(t):t}function h(t,e,r,n){(0,i.DO)(t),u(r),(e=l(e)).length>255&&(e=n((0,i.Id)((0,i.AI)("H2C-OVERSIZE-DST-"),e)));const{outputLen:s,blockLen:o}=n,h=Math.ceil(r/s);if(r>65535||h>255)throw new Error("expand_message_xmd: invalid lenInBytes");const f=(0,i.Id)(e,a(e.length,1)),d=a(0,o),p=a(r,2),g=new Array(h),m=n((0,i.Id)(d,t,p,a(0,1),f));g[0]=n((0,i.Id)(m,a(1,1),f));for(let t=1;t<=h;t++){const e=[c(m,g[t-1]),a(t+1,1),f];g[t]=n((0,i.Id)(...e))}return(0,i.Id)(...g).slice(0,r)}function f(t,e,r){(0,n.DS)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:c,k:f,m:d,hash:p,expand:g,DST:m}=r;if(!(0,n.jN)(r.hash))throw new Error("expected valid hash");(0,i.DO)(t),u(e);const y=c.toString(2).length,b=Math.ceil((y+f)/8),v=e*d*b;let w;if("xmd"===g)w=h(t,m,v,p);else if("xof"===g)w=function(t,e,r,n,s){if((0,i.DO)(t),u(r),(e=l(e)).length>255){const t=Math.ceil(2*n/8);e=s.create({dkLen:t}).update((0,i.AI)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}(t,m,v,f,p);else{if("_internal_pass"!==g)throw new Error('expand must be "xmd" or "xof"');w=t}const E=new Array(e);for(let t=0;t<e;t++){const e=new Array(d);for(let r=0;r<d;r++){const n=b*(r+t*d),i=w.subarray(n,n+b);e[r]=(0,s.zi)(o(i),c)}E[t]=e}return E}function d(t,e){const r=e.map(t=>Array.from(t).reverse());return(e,n)=>{const[i,o,a,c]=r.map(r=>r.reduce((r,n)=>t.add(t.mul(r,e),n))),[u,l]=(0,s.pS)(t,[o,c],!0);return e=t.mul(i,u),n=t.mul(n,t.mul(a,l)),{x:e,y:n}}}const p=(0,i.AI)("HashToScalar-");function g(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");function n(r){return t.fromAffine(e(r))}function i(e){const r=e.clearCofactor();return r.equals(t.ZERO)?t.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(t,e){const s=f(t,2,Object.assign({},r,e)),o=n(s[0]),a=n(s[1]);return i(o.add(a))},encodeToCurve(t,e){const s=r.encodeDST?{DST:r.encodeDST}:{};return i(n(f(t,1,Object.assign({},r,s,e))[0]))},mapToCurve(t){if(!Array.isArray(t))throw new Error("expected array of bigints");for(const e of t)if("bigint"!=typeof e)throw new Error("expected array of bigints");return i(n(t))},hashToScalar(e,n){const i=t.Fn.ORDER;return f(e,1,Object.assign({},r,{p:i,m:1,DST:p},n))[0][0]}}}},6681(t,e,r){"use strict";r.d(e,{D0:()=>I,LH:()=>x,Tp:()=>k,dQ:()=>A,f4:()=>T,jr:()=>S,pS:()=>P,qy:()=>L,tB:()=>R,zH:()=>m,zi:()=>g});var n=r(1633),i=r(36);const s=BigInt(0),o=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(4),l=BigInt(5),h=BigInt(7),f=BigInt(8),d=BigInt(9),p=BigInt(16);function g(t,e){const r=t%e;return r>=s?r:e+r}function m(t,e,r){let n=t;for(;e-- >s;)n*=n,n%=r;return n}function y(t,e){if(t===s)throw new Error("invert: expected non-zero number");if(e<=s)throw new Error("invert: expected positive modulus, got "+e);let r=g(t,e),n=e,i=s,a=o,c=o,u=s;for(;r!==s;){const t=n/r,e=n%r,s=i-c*t,o=a-u*t;n=r,r=e,i=c,a=u,c=s,u=o}if(n!==o)throw new Error("invert: does not exist");return g(i,e)}function b(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function v(t,e){const r=(t.ORDER+o)/u,n=t.pow(e,r);return b(t,n,e),n}function w(t,e){const r=(t.ORDER-l)/f,n=t.mul(e,a),i=t.pow(n,r),s=t.mul(e,i),o=t.mul(t.mul(s,a),i),c=t.mul(s,t.sub(o,t.ONE));return b(t,c,e),c}function E(t){if(t<c)throw new Error("sqrt is not defined for small field");let e=t-o,r=0;for(;e%a===s;)e/=a,r++;let n=a;const i=I(t);for(;1===R(i,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return v;let u=i.pow(n,e);const l=(e+o)/a;return function(t,n){if(t.is0(n))return n;if(1!==R(t,n))throw new Error("Cannot find square root");let i=r,s=t.mul(t.ONE,u),a=t.pow(n,e),c=t.pow(n,l);for(;!t.eql(a,t.ONE);){if(t.is0(a))return t.ZERO;let e=1,r=t.sqr(a);for(;!t.eql(r,t.ONE);)if(e++,r=t.sqr(r),e===i)throw new Error("Cannot find square root");const n=o<<BigInt(i-e-1),u=t.pow(s,n);i=e,s=t.sqr(u),a=t.mul(a,s),c=t.mul(c,u)}return c}}function _(t){return t%u===c?v:t%f===l?w:t%p===d?function(t){const e=I(t),r=E(t),n=r(e,e.neg(e.ONE)),i=r(e,n),s=r(e,e.neg(n)),o=(t+h)/p;return(t,e)=>{let r=t.pow(e,o),a=t.mul(r,n);const c=t.mul(r,i),u=t.mul(r,s),l=t.eql(t.sqr(a),e),h=t.eql(t.sqr(c),e);r=t.cmov(r,a,l),a=t.cmov(u,c,h);const f=t.eql(t.sqr(a),e),d=t.cmov(r,a,f);return b(t,d,e),d}}(t):E(t)}const A=(t,e)=>(g(t,e)&o)===o,O=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function S(t){const e=O.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,n.DS)(t,e),t}function T(t,e,r){if(r<s)throw new Error("invalid exponent, negatives unsupported");if(r===s)return t.ONE;if(r===o)return e;let n=t.ONE,i=e;for(;r>s;)r&o&&(n=t.mul(n,i)),i=t.sqr(i),r>>=o;return n}function P(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),s=t.inv(i);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),s),n}function R(t,e){const r=(t.ORDER-o)/a,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),c=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function x(t,e){void 0!==e&&(0,i.Fe)(e);const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function I(t,e,r=!1,i={}){if(t<=s)throw new Error("invalid field: expected ORDER > 0, got "+t);let a,c,u,l=!1;if("object"==typeof e&&null!=e){if(i.sqrt||r)throw new Error("cannot specify opts in two arguments");const t=e;t.BITS&&(a=t.BITS),t.sqrt&&(c=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE),"boolean"==typeof t.modFromBytes&&(l=t.modFromBytes),u=t.allowedLengths}else"number"==typeof e&&(a=e),i.sqrt&&(c=i.sqrt);const{nBitLength:h,nByteLength:f}=x(t,a);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const p=Object.freeze({ORDER:t,isLE:r,BITS:h,BYTES:f,MASK:(0,n.OG)(h),ZERO:s,ONE:o,allowedLengths:u,create:e=>g(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return s<=e&&e<t},is0:t=>t===s,isValidNot0:t=>!p.is0(t)&&p.isValid(t),isOdd:t=>(t&o)===o,neg:e=>g(-e,t),eql:(t,e)=>t===e,sqr:e=>g(e*e,t),add:(e,r)=>g(e+r,t),sub:(e,r)=>g(e-r,t),mul:(e,r)=>g(e*r,t),pow:(t,e)=>T(p,t,e),div:(e,r)=>g(e*y(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>y(e,t),sqrt:c||(e=>(d||(d=_(t)),d(p,e))),toBytes:t=>r?(0,n.z)(t,f):(0,n.lq)(t,f),fromBytes:(e,i=!0)=>{if(u){if(!u.includes(e.length)||e.length>f)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+e.length);const t=new Uint8Array(f);t.set(e,r?0:t.length-e.length),e=t}if(e.length!==f)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+e.length);let s=r?(0,n.lX)(e):(0,n.Ph)(e);if(l&&(s=g(s,t)),!i&&!p.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:t=>P(p,t),cmov:(t,e,r)=>r?e:t});return Object.freeze(p)}function N(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function k(t){const e=N(t);return e+Math.ceil(e/2)}function L(t,e,r=!1){const i=t.length,s=N(e),a=k(e);if(i<16||i<a||i>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+i);const c=g(r?(0,n.lX)(t):(0,n.Ph)(t),e-o)+o;return r?(0,n.z)(c,s):(0,n.lq)(c,s)}},5603(t,e,r){"use strict";r.d(e,{y6:()=>v,Is:()=>_,x3:()=>P,gx:()=>S});var n=r(36);class i extends n.Vw{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.sd)(t);const r=(0,n.ZJ)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),(0,n.uH)(s)}update(t){return(0,n.CC)(this),this.iHash.update(t),this}digestInto(t){(0,n.CC)(this),(0,n.DO)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:o}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const s=(t,e,r)=>new i(t,e).update(r).digest();s.create=(t,e)=>new i(t,e);var o=r(1633),a=r(3556),c=r(6681);const u=(t,e)=>(t+(t>=0?e:-e)/m)/e;function l(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function h(t,e){const r={};for(let n of Object.keys(e))r[n]=void 0===t[n]?e[n]:t[n];return(0,o.d6)(r.lowS,"lowS"),(0,o.d6)(r.prehash,"prehash"),void 0!==r.format&&l(r.format),r}class f extends Error{constructor(t=""){super(t)}}const d={Err:f,_tlv:{encode:(t,e)=>{const{Err:r}=d;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(1&e.length)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=(0,o.zW)(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?(0,o.zW)(i.length/2|128):"";return(0,o.zW)(t)+s+i+e},decode(t,e){const{Err:r}=d;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++];let s=0;if(!!(128&i)){const t=127&i;if(!t)throw new r("tlv.decode(long): indefinite length not supported");if(t>4)throw new r("tlv.decode(long): byte length is too big");const o=e.subarray(n,n+t);if(o.length!==t)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(const t of o)s=s<<8|t;if(n+=t,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=i;const o=e.subarray(n,n+s);if(o.length!==s)throw new r("tlv.decode: wrong value length");return{v:o,l:e.subarray(n+s)}}},_int:{encode(t){const{Err:e}=d;if(t<p)throw new e("integer: negative integers are not allowed");let r=(0,o.zW)(t);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=d;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return(0,o.Ph)(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=d,i=(0,o.qj)("signature",t),{v:s,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:u}=n.decode(2,s),{v:l,l:h}=n.decode(2,u);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(t){const{_tlv:e,_int:r}=d,n=e.encode(2,r.encode(t.r))+e.encode(2,r.encode(t.s));return e.encode(48,n)}},p=BigInt(0),g=BigInt(1),m=BigInt(2),y=BigInt(3),b=BigInt(4);function v(t,e){const{BYTES:r}=t;let n;if("bigint"==typeof e)n=e;else{let i=(0,o.qj)("private key",e);try{n=t.fromBytes(i)}catch(t){throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function w(t,e={}){const r=(0,a.UT)("weierstrass",t,e),{Fp:i,Fn:s}=r;let c=r.CURVE;const{h:l,n:h}=c;(0,o.DS)(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=e;if(f&&(!i.is0(c.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=A(i,s);function m(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const w=e.toBytes||function(t,e,r){const{x:s,y:a}=e.toAffine(),c=i.toBytes(s);if((0,o.d6)(r,"isCompressed"),r){m();const t=!i.isOdd(a);return(0,n.Id)(E(t),c)}return(0,n.Id)(Uint8Array.of(4),c,i.toBytes(a))},_=e.fromBytes||function(t){(0,o.eV)(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:r}=d,n=t.length,s=t[0],a=t.subarray(1);if(n!==e||2!==s&&3!==s){if(n===r&&4===s){const t=i.BYTES,e=i.fromBytes(a.subarray(0,t)),r=i.fromBytes(a.subarray(t,2*t));if(!S(e,r))throw new Error("bad point: is not on curve");return{x:e,y:r}}throw new Error(`bad point: got length ${n}, expected compressed=${e} or uncompressed=${r}`)}{const t=i.fromBytes(a);if(!i.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=O(t);let r;try{r=i.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}m();return!(1&~s)!==i.isOdd(r)&&(r=i.neg(r)),{x:t,y:r}}};function O(t){const e=i.sqr(t),r=i.mul(e,t);return i.add(i.add(r,i.mul(t,c.a)),c.b)}function S(t,e){const r=i.sqr(e),n=O(t);return i.eql(r,n)}if(!S(c.Gx,c.Gy))throw new Error("bad curve params: generator point");const T=i.mul(i.pow(c.a,y),b),P=i.mul(i.sqr(c.b),BigInt(27));if(i.is0(i.add(T,P)))throw new Error("bad curve params: a or b");function R(t,e,r=!1){if(!i.isValid(e)||r&&i.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function x(t){if(!(t instanceof C))throw new Error("ProjectivePoint expected")}function I(t){if(!f||!f.basises)throw new Error("no endo");return function(t,e,r){const[[n,i],[s,a]]=e,c=u(a*t,r),l=u(-i*t,r);let h=t-c*n-l*s,f=-c*i-l*a;const d=h<p,m=f<p;d&&(h=-h),m&&(f=-f);const y=(0,o.OG)(Math.ceil((0,o.dJ)(r)/2))+g;if(h<p||h>=y||f<p||f>=y)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:h,k2neg:m,k2:f}}(t,f.basises,s.ORDER)}const N=(0,o.x)((t,e)=>{const{X:r,Y:n,Z:s}=t;if(i.eql(s,i.ONE))return{x:r,y:n};const o=t.is0();null==e&&(e=o?i.ONE:i.inv(s));const a=i.mul(r,e),c=i.mul(n,e),u=i.mul(s,e);if(o)return{x:i.ZERO,y:i.ZERO};if(!i.eql(u,i.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),k=(0,o.x)(t=>{if(t.is0()){if(e.allowInfinityPoint&&!i.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:r,y:n}=t.toAffine();if(!i.isValid(r)||!i.isValid(n))throw new Error("bad point: x or y not field elements");if(!S(r,n))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(t,e,r,n,s){return r=new C(i.mul(r.X,t),r.Y,r.Z),e=(0,a.u0)(n,e),r=(0,a.u0)(s,r),e.add(r)}class C{constructor(t,e,r){this.X=R("x",t),this.Y=R("y",e,!0),this.Z=R("z",r),Object.freeze(this)}static CURVE(){return c}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!i.isValid(e)||!i.isValid(r))throw new Error("invalid affine point");if(t instanceof C)throw new Error("projective point not allowed");return i.is0(e)&&i.is0(r)?C.ZERO:new C(e,r,i.ONE)}static fromBytes(t){const e=C.fromAffine(_((0,o.eV)(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return C.fromBytes((0,o.qj)("pointHex",t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return B.createCache(this,t),e||this.multiply(y),this}assertValidity(){k(this)}hasEvenY(){const{y:t}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(t)}equals(t){x(t);const{X:e,Y:r,Z:n}=this,{X:s,Y:o,Z:a}=t,c=i.eql(i.mul(e,a),i.mul(s,n)),u=i.eql(i.mul(r,a),i.mul(o,n));return c&&u}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:t,b:e}=c,r=i.mul(e,y),{X:n,Y:s,Z:o}=this;let a=i.ZERO,u=i.ZERO,l=i.ZERO,h=i.mul(n,n),f=i.mul(s,s),d=i.mul(o,o),p=i.mul(n,s);return p=i.add(p,p),l=i.mul(n,o),l=i.add(l,l),a=i.mul(t,l),u=i.mul(r,d),u=i.add(a,u),a=i.sub(f,u),u=i.add(f,u),u=i.mul(a,u),a=i.mul(p,a),l=i.mul(r,l),d=i.mul(t,d),p=i.sub(h,d),p=i.mul(t,p),p=i.add(p,l),l=i.add(h,h),h=i.add(l,h),h=i.add(h,d),h=i.mul(h,p),u=i.add(u,h),d=i.mul(s,o),d=i.add(d,d),h=i.mul(d,p),a=i.sub(a,h),l=i.mul(d,f),l=i.add(l,l),l=i.add(l,l),new C(a,u,l)}add(t){x(t);const{X:e,Y:r,Z:n}=this,{X:s,Y:o,Z:a}=t;let u=i.ZERO,l=i.ZERO,h=i.ZERO;const f=c.a,d=i.mul(c.b,y);let p=i.mul(e,s),g=i.mul(r,o),m=i.mul(n,a),b=i.add(e,r),v=i.add(s,o);b=i.mul(b,v),v=i.add(p,g),b=i.sub(b,v),v=i.add(e,n);let w=i.add(s,a);return v=i.mul(v,w),w=i.add(p,m),v=i.sub(v,w),w=i.add(r,n),u=i.add(o,a),w=i.mul(w,u),u=i.add(g,m),w=i.sub(w,u),h=i.mul(f,v),u=i.mul(d,m),h=i.add(u,h),u=i.sub(g,h),h=i.add(g,h),l=i.mul(u,h),g=i.add(p,p),g=i.add(g,p),m=i.mul(f,m),v=i.mul(d,v),g=i.add(g,m),m=i.sub(p,m),m=i.mul(f,m),v=i.add(v,m),p=i.mul(g,v),l=i.add(l,p),p=i.mul(w,v),u=i.mul(b,u),u=i.sub(u,p),p=i.mul(b,g),h=i.mul(w,h),h=i.add(h,p),new C(u,l,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(C.ZERO)}multiply(t){const{endo:r}=e;if(!s.isValidNot0(t))throw new Error("invalid scalar: out of range");let n,i;const o=t=>B.cached(this,t,t=>(0,a.Ak)(C,t));if(r){const{k1neg:e,k1:s,k2neg:a,k2:c}=I(t),{p:u,f:l}=o(s),{p:h,f}=o(c);i=l.add(f),n=L(r.beta,u,h,e,a)}else{const{p:e,f:r}=o(t);n=e,i=r}return(0,a.Ak)(C,[n,i])[0]}multiplyUnsafe(t){const{endo:r}=e,n=this;if(!s.isValid(t))throw new Error("invalid scalar: out of range");if(t===p||n.is0())return C.ZERO;if(t===g)return n;if(B.hasCache(this))return this.multiply(t);if(r){const{k1neg:e,k1:i,k2neg:s,k2:o}=I(t),{p1:c,p2:u}=(0,a.fH)(C,n,i,o);return L(r.beta,c,u,e,s)}return B.unsafe(n,t)}multiplyAndAddUnsafe(t,e,r){const n=this.multiplyUnsafe(e).add(t.multiplyUnsafe(r));return n.is0()?void 0:n}toAffine(t){return N(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return l===g||(t?t(C,this):B.unsafe(this,h).is0())}clearCofactor(){const{clearCofactor:t}=e;return l===g?this:t?t(C,this):this.multiplyUnsafe(l)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}toBytes(t=!0){return(0,o.d6)(t,"isCompressed"),this.assertValidity(),w(C,this,t)}toHex(t=!0){return(0,n.My)(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(t=!0){return this.toBytes(t)}_setWindowSize(t){this.precompute(t)}static normalizeZ(t){return(0,a.Ak)(C,t)}static msm(t,e){return(0,a.Xf)(C,s,t,e)}static fromPrivateKey(t){return C.BASE.multiply(v(s,t))}}C.BASE=new C(c.Gx,c.Gy,i.ONE),C.ZERO=new C(i.ZERO,i.ONE,i.ZERO),C.Fp=i,C.Fn=s;const M=s.BITS,B=new a.hT(C,e.endo?Math.ceil(M/2):M);return C.BASE.precompute(8),C}function E(t){return Uint8Array.of(t?2:3)}function _(t,e){(0,c.jr)(t);const{A:r,B:n,Z:i}=e;if(!t.isValid(r)||!t.isValid(n)||!t.isValid(i))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=function(t,e){const r=t.ORDER;let n=p;for(let t=r-g;t%m===p;t/=m)n+=g;const i=n,s=m<<i-g-g,o=s*m,a=(r-g)/o,c=(a-g)/m,u=o-g,l=s,h=t.pow(e,a),f=t.pow(e,(a+g)/m);let d=(e,r)=>{let n=h,s=t.pow(r,u),o=t.sqr(s);o=t.mul(o,r);let a=t.mul(e,o);a=t.pow(a,c),a=t.mul(a,s),s=t.mul(a,r),o=t.mul(a,e);let d=t.mul(o,s);a=t.pow(d,l);let p=t.eql(a,t.ONE);s=t.mul(o,f),a=t.mul(d,n),o=t.cmov(s,o,p),d=t.cmov(a,d,p);for(let e=i;e>g;e--){let r=e-m;r=m<<r-g;let i=t.pow(d,r);const a=t.eql(i,t.ONE);s=t.mul(o,n),n=t.mul(n,n),i=t.mul(d,n),o=t.cmov(s,o,a),d=t.cmov(i,d,a)}return{isValid:p,value:o}};if(t.ORDER%b===y){const r=(t.ORDER-y)/b,n=t.sqrt(t.neg(e));d=(e,i)=>{let s=t.sqr(i);const o=t.mul(e,i);s=t.mul(s,o);let a=t.pow(s,r);a=t.mul(a,o);const c=t.mul(a,n),u=t.mul(t.sqr(a),i),l=t.eql(u,e);return{isValid:l,value:t.cmov(c,a,l)}}}return d}(t,i);if(!t.isOdd)throw new Error("Field does not have .isOdd()");return e=>{let o,a,u,l,h,f,d,p;o=t.sqr(e),o=t.mul(o,i),a=t.sqr(o),a=t.add(a,o),u=t.add(a,t.ONE),u=t.mul(u,n),l=t.cmov(i,t.neg(a),!t.eql(a,t.ZERO)),l=t.mul(l,r),a=t.sqr(u),f=t.sqr(l),h=t.mul(f,r),a=t.add(a,h),a=t.mul(a,u),f=t.mul(f,l),h=t.mul(f,n),a=t.add(a,h),d=t.mul(o,u);const{isValid:g,value:m}=s(a,f);p=t.mul(o,e),p=t.mul(p,m),d=t.cmov(d,u,g),p=t.cmov(p,m,g);const y=t.isOdd(e)===t.isOdd(p);p=t.cmov(t.neg(p),p,y);const b=(0,c.pS)(t,[l],!0)[0];return d=t.mul(d,b),{x:d,y:p}}}function A(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function O(t,e,r={}){(0,n.sd)(e),(0,o.DS)(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=r.randomBytes||n.po,a=r.hmac||((t,...r)=>s(e,t,(0,n.Id)(...r))),{Fp:u,Fn:f}=t,{ORDER:y,BITS:b}=f,{keygen:w,getPublicKey:_,getSharedSecret:O,utils:S,lengths:T}=function(t,e={}){const{Fn:r}=t,i=e.randomBytes||n.po,s=Object.assign(A(t.Fp,r),{seed:(0,c.Tp)(r.ORDER)});function a(t){try{return!!v(r,t)}catch(t){return!1}}function u(t=i(s.seed)){return(0,c.qy)((0,o.eV)(t,s.seed,"seed"),r.ORDER)}function l(e,n=!0){return t.BASE.multiply(v(r,e)).toBytes(n)}function h(e){if("bigint"==typeof e)return!1;if(e instanceof t)return!0;const{secretKey:n,publicKey:i,publicKeyUncompressed:a}=s;if(r.allowedLengths||n===i)return;const c=(0,o.qj)("key",e).length;return c===i||c===a}const f={isValidSecretKey:a,isValidPublicKey:function(e,r){const{publicKey:n,publicKeyUncompressed:i}=s;try{const s=e.length;return!(!0===r&&s!==n||!1===r&&s!==i||!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:u,isValidPrivateKey:a,randomPrivateKey:u,normPrivateKeyToScalar:t=>v(r,t),precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({getPublicKey:l,getSharedSecret:function(e,n,i=!0){if(!0===h(e))throw new Error("first arg must be private key");if(!1===h(n))throw new Error("second arg must be public key");const s=v(r,e);return t.fromHex(n).multiply(s).toBytes(i)},keygen:function(t){const e=u(t);return{secretKey:e,publicKey:l(e)}},Point:t,utils:f,lengths:s})}(t,r),P={prehash:!1,lowS:"boolean"==typeof r.lowS&&r.lowS,format:void 0,extraEntropy:!1},R="compact";function x(t){return t>y>>g}function I(t,e){if(!f.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}class N{constructor(t,e,r){this.r=I("r",t),this.s=I("s",e),null!=r&&(this.recovery=r),Object.freeze(this)}static fromBytes(t,e=R){let r;if(function(t,e){l(e);const r=T.signature,n="compact"===e?r:"recovered"===e?r+1:void 0;(0,o.eV)(t,n,`${e} signature`)}(t,e),"der"===e){const{r:e,s:r}=d.toSig((0,o.eV)(t));return new N(e,r)}"recovered"===e&&(r=t[0],e="compact",t=t.subarray(1));const n=f.BYTES,i=t.subarray(0,n),s=t.subarray(n,2*n);return new N(f.fromBytes(i),f.fromBytes(s),r)}static fromHex(t,e){return this.fromBytes((0,n.aT)(t),e)}addRecoveryBit(t){return new N(this.r,this.s,t)}recoverPublicKey(e){const r=u.ORDER,{r:i,s,recovery:a}=this;if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");if(y*m<r&&a>1)throw new Error("recovery id is ambiguous for h>1 curve");const c=2===a||3===a?i+y:i;if(!u.isValid(c))throw new Error("recovery id 2 or 3 invalid");const l=u.toBytes(c),h=t.fromBytes((0,n.Id)(E(!(1&a)),l)),d=f.inv(c),p=L((0,o.qj)("msgHash",e)),g=f.create(-p*d),b=f.create(s*d),v=t.BASE.multiplyUnsafe(g).add(h.multiplyUnsafe(b));if(v.is0())throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return x(this.s)}toBytes(t=R){if(l(t),"der"===t)return(0,n.aT)(d.hexFromSig(this));const e=f.toBytes(this.r),r=f.toBytes(this.s);if("recovered"===t){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,n.Id)(Uint8Array.of(this.recovery),e,r)}return(0,n.Id)(e,r)}toHex(t){return(0,n.My)(this.toBytes(t))}assertValidity(){}static fromCompact(t){return N.fromBytes((0,o.qj)("sig",t),"compact")}static fromDER(t){return N.fromBytes((0,o.qj)("sig",t),"der")}normalizeS(){return this.hasHighS()?new N(this.r,f.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,n.My)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,n.My)(this.toBytes("compact"))}}const k=r.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=(0,o.Ph)(t),r=8*t.length-b;return r>0?e>>BigInt(r):e},L=r.bits2int_modN||function(t){return f.create(k(t))},C=(0,o.OG)(b);function M(t){return(0,o.aK)("num < 2^"+b,t,p,C),f.toBytes(t)}function B(t,r){return(0,o.eV)(t,void 0,"message"),r?(0,o.eV)(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:w,getPublicKey:_,getSharedSecret:O,utils:S,lengths:T,Point:t,sign:function(r,s,c={}){r=(0,o.qj)("message",r);const{seed:u,k2sig:l}=function(e,r,s){if(["recovered","canonical"].some(t=>t in s))throw new Error("sign() legacy options not supported");const{lowS:a,prehash:c,extraEntropy:u}=h(s,P);e=B(e,c);const l=L(e),d=v(f,r),m=[M(d),M(l)];if(null!=u&&!1!==u){const t=!0===u?i(T.secretKey):u;m.push((0,o.qj)("extraEntropy",t))}const y=(0,n.Id)(...m),b=l;return{seed:y,k2sig:function(e){const r=k(e);if(!f.isValidNot0(r))return;const n=f.inv(r),i=t.BASE.multiply(r).toAffine(),s=f.create(i.x);if(s===p)return;const o=f.create(n*f.create(b+s*d));if(o===p)return;let c=(i.x===s?0:2)|Number(i.y&g),u=o;return a&&x(o)&&(u=f.neg(o),c^=1),new N(s,u,c)}}}(r,s,c);return(0,o.fg)(e.outputLen,f.BYTES,a)(u,l)},verify:function(e,r,i,s={}){const{lowS:a,prehash:c,format:u}=h(s,P);if(i=(0,o.qj)("publicKey",i),r=B((0,o.qj)("message",r),c),"strict"in s)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(t){let e;const r="string"==typeof t||(0,n.aY)(t),i=!r&&null!==t&&"object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s;if(!r&&!i)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(i)e=new N(t.r,t.s);else if(r){try{e=N.fromBytes((0,o.qj)("sig",t),"der")}catch(t){if(!(t instanceof d.Err))throw t}if(!e)try{e=N.fromBytes((0,o.qj)("sig",t),"compact")}catch(t){return!1}}return e||!1}(e):N.fromBytes((0,o.qj)("sig",e),u);if(!1===l)return!1;try{const e=t.fromBytes(i);if(a&&l.hasHighS())return!1;const{r:n,s}=l,o=L(r),c=f.inv(s),u=f.create(o*c),h=f.create(n*c),d=t.BASE.multiplyUnsafe(u).add(e.multiplyUnsafe(h));if(d.is0())return!1;return f.create(d.x)===n}catch(t){return!1}},recoverPublicKey:function(t,e,r={}){const{prehash:n}=h(r,P);return e=B(e,n),N.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:N,hash:e})}function S(t){const{CURVE:e,curveOpts:r}=T(t);return function(t,e){const{Fp:r,Fn:n}=e;function i(t){return(0,o.r4)(t,g,n.ORDER)}const s=function(t,e,r){function n(n){const i=t.sqr(n),s=t.mul(i,n);return t.add(t.add(s,t.mul(n,e)),r)}return n}(r,t.a,t.b);return Object.assign({},{CURVE:t,Point:e,ProjectivePoint:e,normPrivateKeyToScalar:t=>v(n,t),weierstrassEquation:s,isWithinCurveOrder:i})}(t,w(e,r))}function T(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(t=>Math.ceil(t/2)))):void 0;return{CURVE:e,curveOpts:{Fp:r,Fn:(0,c.D0)(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes}}}function P(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=function(t){const{CURVE:e,curveOpts:r}=T(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,(0,c.LH)(r.Fn.ORDER,r.Fn.BITS))})}(t,O(w(e,r),n,i))}},1188(t,e,r){"use strict";r.d(e,{A:()=>Y});var n=r(733),i=r(1633),s=r(36),o=r(3556),a=r(9991),c=r(6681),u=r(5603);const l=BigInt(0),h=BigInt(1),f=BigInt(2),d=BigInt(3);function p(t){if(!Array.isArray(t)||0===t.length)throw new Error("expected non-empty array")}function g(t,e,r,n){const{Fp2:s,Fp12:a}=t,{twistType:c,ateLoopSize:u,xNegative:p,postPrecompute:g}=n;let m;if("multiplicative"===c)m=(t,e,r,n,i,o)=>a.mul014(n,t,s.mul(e,i),s.mul(r,o));else{if("divisive"!==c)throw new Error("bls: unknown twist type");m=(t,e,r,n,i,o)=>a.mul034(n,s.mul(r,o),s.mul(e,i),t)}const y=s.div(s.ONE,s.mul(s.ONE,f));function b(t,e,r,n){const i=s.sqr(r),o=s.sqr(n),a=s.mulByB(s.mul(o,d)),c=s.mul(a,d),u=s.sub(s.sub(s.sqr(s.add(r,n)),o),i),l=s.sub(a,i),h=s.mul(s.sqr(e),d),f=s.neg(u);return t.push([l,h,f]),{Rx:e=s.mul(s.mul(s.mul(s.sub(i,c),e),r),y),Ry:r=s.sub(s.sqr(s.mul(s.add(i,c),y)),s.mul(s.sqr(a),d)),Rz:n=s.mul(i,u)}}function v(t,e,r,n,i,o){const a=s.sub(r,s.mul(o,n)),c=s.sub(e,s.mul(i,n)),u=s.sub(s.mul(a,i),s.mul(c,o)),l=s.neg(a),h=c;t.push([u,l,h]);const d=s.sqr(c),p=s.mul(d,c),g=s.mul(d,e),m=s.add(s.sub(p,s.mul(g,f)),s.mul(s.sqr(a),n));return{Rx:e=s.mul(c,m),Ry:r=s.sub(s.mul(s.sub(g,m),a),s.mul(p,r)),Rz:n=s.mul(n,p)}}const w=function(t){const e=[];for(;t>h;t>>=h)(t&h)===l?e.unshift(0):(t&d)===d?(e.unshift(-1),t+=h):e.unshift(1);return e}(u),E=(0,i.x)(t=>{const e=t,{x:r,y:n}=e.toAffine(),i=r,o=n,a=s.neg(n);let c=i,u=o,l=s.ONE;const h=[];for(const t of w){const e=[];({Rx:c,Ry:u,Rz:l}=b(e,c,u,l)),t&&({Rx:c,Ry:u,Rz:l}=v(e,c,u,l,i,-1===t?a:o)),h.push(e)}if(g){const t=h[h.length-1];g(c,u,l,i,o,v.bind(null,t))}return h});function _(t,e=!1){let r=a.ONE;if(t.length){const e=t[0][0].length;for(let n=0;n<e;n++){r=a.sqr(r);for(const[e,i,s]of t)for(const[t,o,a]of e[n])r=m(t,o,a,r,i,s)}}return p&&(r=a.conjugate(r)),e?a.finalExponentiate(r):r}function A(t,n=!0){const i=[];(0,o.Ak)(e,t.map(({g1:t})=>t)),(0,o.Ak)(r,t.map(({g2:t})=>t));for(const{g1:e,g2:r}of t){if(e.is0()||r.is0())throw new Error("pairing is not available for ZERO point");e.assertValidity(),r.assertValidity();const t=e.toAffine();i.push([E(r),t.x,t.y])}return _(i,n)}return{Fp12:a,millerLoopBatch:_,pairing:function(t,e,r=!0){return A([{g1:t,g2:e}],r)},pairingBatch:A,calcPairingPrecomputes:E}}function m(t,e,r,n,i){const{Fp12:o,pairingBatch:a}=t;function c(t){return t instanceof e.Point?t:e.Point.fromHex(t)}function l(t){return t instanceof r.Point?t:r.Point.fromHex(t)}function h(t){if(!(t instanceof r.Point))throw new Error(`expected valid message hashed to ${i?"G1":"G2"} curve`);return t}const f=i?(t,e)=>({g1:e,g2:t}):(t,e)=>({g1:t,g2:e});return{getPublicKey(t){const r=(0,u.y6)(e.Point.Fn,t);return e.Point.BASE.multiply(r)},sign(t,r,n){if(null!=n)throw new Error("sign() expects 2 arguments");const i=(0,u.y6)(e.Point.Fn,r);return h(t).assertValidity(),t.multiply(i)},verify(t,r,n,i){if(null!=i)throw new Error("verify() expects 3 arguments");t=l(t);const s=(n=c(n)).negate(),u=e.Point.BASE,d=h(r),p=t,g=a([f(s,d),f(u,p)]);return o.eql(g,o.ONE)},verifyBatch(t,r,n){if(p(r),n.length!==r.length)throw new Error("amount of public keys and messages should be equal");const i=l(t),s=r,u=n.map(c),h=new Map;for(let t=0;t<u.length;t++){const e=u[t],r=s[t];let n=h.get(r);void 0===n&&(n=[],h.set(r,n)),n.push(e)}const d=[],g=e.Point.BASE;try{for(const[t,e]of h){const r=e.reduce((t,e)=>t.add(e));d.push(f(r,t))}return d.push(f(g.negate(),i)),o.eql(a(d),o.ONE)}catch{return!1}},aggregatePublicKeys(t){p(t);const r=(t=t.map(t=>c(t))).reduce((t,e)=>t.add(e),e.Point.ZERO);return r.assertValidity(),r},aggregateSignatures(t){p(t);const e=(t=t.map(t=>l(t))).reduce((t,e)=>t.add(e),r.Point.ZERO);return e.assertValidity(),e},hash(t,e){(0,s.DO)(t);const n=e?{DST:e}:void 0;return r.hashToCurve(t,n)},Signature:n}}const y=BigInt(0),b=BigInt(1),v=BigInt(2),w=BigInt(3);function E(t,e,r,n,i=1,s){const o=BigInt(void 0===s?n:s),a=r**BigInt(n),c=[];for(let s=0;s<i;s++){const i=BigInt(s+1),u=[];for(let s=0,c=b;s<n;s++){const n=(i*c-i)/o%a;u.push(t.pow(e,n)),c*=r}c.push(u)}return c}const _=(t,e)=>{if(2!==e.length)throw new Error("invalid tuple");const r=e.map(e=>t.create(e));return{c0:r[0],c1:r[1]}};class A{constructor(t,e={}){this.MASK=b;const r=t.ORDER,n=r*r;this.Fp=t,this.ORDER=n,this.BITS=(0,i.dJ)(n),this.BYTES=Math.ceil((0,i.dJ)(n)/8),this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO},this.Fp_NONRESIDUE=t.create(e.NONRESIDUE||BigInt(-1)),this.Fp_div2=t.div(t.ONE,v),this.NONRESIDUE=_(t,e.FP2_NONRESIDUE),this.FROBENIUS_COEFFICIENTS=E(t,this.Fp_NONRESIDUE,t.ORDER,2)[0],this.mulByB=e.Fp2mulByB,Object.seal(this)}fromBigTuple(t){return _(this.Fp,t)}create(t){return t}isValid({c0:t,c1:e}){function r(t,e){return"bigint"==typeof t&&y<=t&&t<e}return r(t,this.ORDER)&&r(e,this.ORDER)}is0({c0:t,c1:e}){return this.Fp.is0(t)&&this.Fp.is0(e)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}eql({c0:t,c1:e},{c0:r,c1:n}){return this.Fp.eql(t,r)&&this.Fp.eql(e,n)}neg({c0:t,c1:e}){return{c0:this.Fp.neg(t),c1:this.Fp.neg(e)}}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}add(t,e){const{c0:r,c1:n}=t,{c0:i,c1:s}=e;return{c0:this.Fp.add(r,i),c1:this.Fp.add(n,s)}}sub({c0:t,c1:e},{c0:r,c1:n}){return{c0:this.Fp.sub(t,r),c1:this.Fp.sub(e,n)}}mul({c0:t,c1:e},r){const{Fp:n}=this;if("bigint"==typeof r)return{c0:n.mul(t,r),c1:n.mul(e,r)};const{c0:i,c1:s}=r;let o=n.mul(t,i),a=n.mul(e,s);return{c0:n.sub(o,a),c1:n.sub(n.mul(n.add(t,e),n.add(i,s)),n.add(o,a))}}sqr({c0:t,c1:e}){const{Fp:r}=this,n=r.add(t,e),i=r.sub(t,e),s=r.add(t,t);return{c0:r.mul(n,i),c1:r.mul(s,e)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}div(t,e){const{Fp:r}=this;return this.mul(t,"bigint"==typeof e?r.inv(r.create(e)):this.inv(e))}inv({c0:t,c1:e}){const{Fp:r}=this,n=r.inv(r.create(t*t+e*e));return{c0:r.mul(n,r.create(t)),c1:r.mul(n,r.create(-e))}}sqrt(t){const{Fp:e}=this,r=this,{c0:n,c1:i}=t;if(e.is0(i))return 1===c.tB(e,n)?r.create({c0:e.sqrt(n),c1:e.ZERO}):r.create({c0:e.ZERO,c1:e.sqrt(e.div(n,this.Fp_NONRESIDUE))});const s=e.sqrt(e.sub(e.sqr(n),e.mul(e.sqr(i),this.Fp_NONRESIDUE)));let o=e.mul(e.add(s,n),this.Fp_div2);-1===c.tB(e,o)&&(o=e.sub(o,s));const a=e.sqrt(o),u=r.create({c0:a,c1:e.div(e.mul(i,this.Fp_div2),a)});if(!r.eql(r.sqr(u),t))throw new Error("Cannot find square root");const l=u,h=r.neg(l),{re:f,im:d}=r.reim(l),{re:p,im:g}=r.reim(h);return d>g||d===g&&f>p?l:h}isOdd(t){const{re:e,im:r}=this.reim(t);return BigInt(e%v||e===y&&r%v)==b}fromBytes(t){const{Fp:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);return{c0:e.fromBytes(t.subarray(0,e.BYTES)),c1:e.fromBytes(t.subarray(e.BYTES))}}toBytes({c0:t,c1:e}){return(0,s.Id)(this.Fp.toBytes(t),this.Fp.toBytes(e))}cmov({c0:t,c1:e},{c0:r,c1:n},i){return{c0:this.Fp.cmov(t,r,i),c1:this.Fp.cmov(e,n,i)}}reim({c0:t,c1:e}){return{re:t,im:e}}Fp4Square(t,e){const r=this,n=r.sqr(t),i=r.sqr(e);return{first:r.add(r.mulByNonresidue(i),n),second:r.sub(r.sub(r.sqr(r.add(t,e)),n),i)}}mulByNonresidue({c0:t,c1:e}){return this.mul({c0:t,c1:e},this.NONRESIDUE)}frobeniusMap({c0:t,c1:e},r){return{c0:t,c1:this.Fp.mul(e,this.FROBENIUS_COEFFICIENTS[r%2])}}}class O{constructor(t){this.MASK=b,this.Fp2=t,this.ORDER=t.ORDER,this.BITS=3*t.BITS,this.BYTES=3*t.BYTES,this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO,c2:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO,c2:t.ZERO};const{Fp:e}=t,r=E(t,t.NONRESIDUE,e.ORDER,6,2,3);this.FROBENIUS_COEFFICIENTS_1=r[0],this.FROBENIUS_COEFFICIENTS_2=r[1],Object.seal(this)}add({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return{c0:o.add(t,n),c1:o.add(e,i),c2:o.add(r,s)}}sub({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return{c0:o.sub(t,n),c1:o.sub(e,i),c2:o.sub(r,s)}}mul({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;if("bigint"==typeof n)return{c0:i.mul(t,n),c1:i.mul(e,n),c2:i.mul(r,n)};const{c0:s,c1:o,c2:a}=n,c=i.mul(t,s),u=i.mul(e,o),l=i.mul(r,a);return{c0:i.add(c,i.mulByNonresidue(i.sub(i.mul(i.add(e,r),i.add(o,a)),i.add(u,l)))),c1:i.add(i.sub(i.mul(i.add(t,e),i.add(s,o)),i.add(c,u)),i.mulByNonresidue(l)),c2:i.sub(i.add(u,i.mul(i.add(t,r),i.add(s,a))),i.add(c,l))}}sqr({c0:t,c1:e,c2:r}){const{Fp2:n}=this;let i=n.sqr(t),s=n.mul(n.mul(t,e),v),o=n.mul(n.mul(e,r),v),a=n.sqr(r);return{c0:n.add(n.mulByNonresidue(o),i),c1:n.add(n.mulByNonresidue(a),s),c2:n.sub(n.sub(n.add(n.add(s,n.sqr(n.add(n.sub(t,e),r))),o),i),a)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}create(t){return t}isValid({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return n.isValid(t)&&n.isValid(e)&&n.isValid(r)}is0({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return n.is0(t)&&n.is0(e)&&n.is0(r)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}neg({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return{c0:n.neg(t),c1:n.neg(e),c2:n.neg(r)}}eql({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s}){const{Fp2:o}=this;return o.eql(t,n)&&o.eql(e,i)&&o.eql(r,s)}sqrt(t){return(0,i.SJ)()}div(t,e){const{Fp2:r}=this,{Fp:n}=r;return this.mul(t,"bigint"==typeof e?n.inv(n.create(e)):this.inv(e))}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}inv({c0:t,c1:e,c2:r}){const{Fp2:n}=this;let i=n.sub(n.sqr(t),n.mulByNonresidue(n.mul(r,e))),s=n.sub(n.mulByNonresidue(n.sqr(r)),n.mul(t,e)),o=n.sub(n.sqr(e),n.mul(t,r)),a=n.inv(n.add(n.mulByNonresidue(n.add(n.mul(r,s),n.mul(e,o))),n.mul(t,i)));return{c0:n.mul(a,i),c1:n.mul(a,s),c2:n.mul(a,o)}}fromBytes(t){const{Fp2:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);const r=e.BYTES;return{c0:e.fromBytes(t.subarray(0,r)),c1:e.fromBytes(t.subarray(r,2*r)),c2:e.fromBytes(t.subarray(2*r))}}toBytes({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return(0,s.Id)(n.toBytes(t),n.toBytes(e),n.toBytes(r))}cmov({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o){const{Fp2:a}=this;return{c0:a.cmov(t,n,o),c1:a.cmov(e,i,o),c2:a.cmov(r,s,o)}}fromBigSix(t){const{Fp2:e}=this;if(!Array.isArray(t)||6!==t.length)throw new Error("invalid Fp6 usage");return{c0:e.fromBigTuple(t.slice(0,2)),c1:e.fromBigTuple(t.slice(2,4)),c2:e.fromBigTuple(t.slice(4,6))}}frobeniusMap({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.frobeniusMap(t,n),c1:i.mul(i.frobeniusMap(e,n),this.FROBENIUS_COEFFICIENTS_1[n%6]),c2:i.mul(i.frobeniusMap(r,n),this.FROBENIUS_COEFFICIENTS_2[n%6])}}mulByFp2({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.mul(t,n),c1:i.mul(e,n),c2:i.mul(r,n)}}mulByNonresidue({c0:t,c1:e,c2:r}){const{Fp2:n}=this;return{c0:n.mulByNonresidue(r),c1:t,c2:e}}mul1({c0:t,c1:e,c2:r},n){const{Fp2:i}=this;return{c0:i.mulByNonresidue(i.mul(r,n)),c1:i.mul(t,n),c2:i.mul(e,n)}}mul01({c0:t,c1:e,c2:r},n,i){const{Fp2:s}=this;let o=s.mul(t,n),a=s.mul(e,i);return{c0:s.add(s.mulByNonresidue(s.sub(s.mul(s.add(e,r),i),a)),o),c1:s.sub(s.sub(s.mul(s.add(n,i),s.add(t,e)),o),a),c2:s.add(s.sub(s.mul(s.add(t,r),n),o),a)}}}class S{constructor(t,e){this.MASK=b;const{Fp2:r}=t,{Fp:n}=r;this.Fp6=t,this.ORDER=r.ORDER,this.BITS=2*t.BITS,this.BYTES=2*t.BYTES,this.isLE=t.isLE,this.ZERO={c0:t.ZERO,c1:t.ZERO},this.ONE={c0:t.ONE,c1:t.ZERO},this.FROBENIUS_COEFFICIENTS=E(r,r.NONRESIDUE,n.ORDER,12,1,6)[0],this.X_LEN=e.X_LEN,this.finalExponentiate=e.Fp12finalExponentiate}create(t){return t}isValid({c0:t,c1:e}){const{Fp6:r}=this;return r.isValid(t)&&r.isValid(e)}is0({c0:t,c1:e}){const{Fp6:r}=this;return r.is0(t)&&r.is0(e)}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}neg({c0:t,c1:e}){const{Fp6:r}=this;return{c0:r.neg(t),c1:r.neg(e)}}eql({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return i.eql(t,r)&&i.eql(e,n)}sqrt(t){(0,i.SJ)()}inv({c0:t,c1:e}){const{Fp6:r}=this;let n=r.inv(r.sub(r.sqr(t),r.mulByNonresidue(r.sqr(e))));return{c0:r.mul(t,n),c1:r.neg(r.mul(e,n))}}div(t,e){const{Fp6:r}=this,{Fp2:n}=r,{Fp:i}=n;return this.mul(t,"bigint"==typeof e?i.inv(i.create(e)):this.inv(e))}pow(t,e){return c.f4(this,t,e)}invertBatch(t){return c.pS(this,t)}add({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return{c0:i.add(t,r),c1:i.add(e,n)}}sub({c0:t,c1:e},{c0:r,c1:n}){const{Fp6:i}=this;return{c0:i.sub(t,r),c1:i.sub(e,n)}}mul({c0:t,c1:e},r){const{Fp6:n}=this;if("bigint"==typeof r)return{c0:n.mul(t,r),c1:n.mul(e,r)};let{c0:i,c1:s}=r,o=n.mul(t,i),a=n.mul(e,s);return{c0:n.add(o,n.mulByNonresidue(a)),c1:n.sub(n.mul(n.add(t,e),n.add(i,s)),n.add(o,a))}}sqr({c0:t,c1:e}){const{Fp6:r}=this;let n=r.mul(t,e);return{c0:r.sub(r.sub(r.mul(r.add(r.mulByNonresidue(e),t),r.add(t,e)),n),r.mulByNonresidue(n)),c1:r.add(n,n)}}addN(t,e){return this.add(t,e)}subN(t,e){return this.sub(t,e)}mulN(t,e){return this.mul(t,e)}sqrN(t){return this.sqr(t)}fromBytes(t){const{Fp6:e}=this;if(t.length!==this.BYTES)throw new Error("fromBytes invalid length="+t.length);return{c0:e.fromBytes(t.subarray(0,e.BYTES)),c1:e.fromBytes(t.subarray(e.BYTES))}}toBytes({c0:t,c1:e}){const{Fp6:r}=this;return(0,s.Id)(r.toBytes(t),r.toBytes(e))}cmov({c0:t,c1:e},{c0:r,c1:n},i){const{Fp6:s}=this;return{c0:s.cmov(t,r,i),c1:s.cmov(e,n,i)}}fromBigTwelve(t){const{Fp6:e}=this;return{c0:e.fromBigSix(t.slice(0,6)),c1:e.fromBigSix(t.slice(6,12))}}frobeniusMap(t,e){const{Fp6:r}=this,{Fp2:n}=r,{c0:i,c1:s,c2:o}=r.frobeniusMap(t.c1,e),a=this.FROBENIUS_COEFFICIENTS[e%12];return{c0:r.frobeniusMap(t.c0,e),c1:r.create({c0:n.mul(i,a),c1:n.mul(s,a),c2:n.mul(o,a)})}}mulByFp2({c0:t,c1:e},r){const{Fp6:n}=this;return{c0:n.mulByFp2(t,r),c1:n.mulByFp2(e,r)}}conjugate({c0:t,c1:e}){return{c0:t,c1:this.Fp6.neg(e)}}mul014({c0:t,c1:e},r,n,i){const{Fp6:s}=this,{Fp2:o}=s;let a=s.mul01(t,r,n),c=s.mul1(e,i);return{c0:s.add(s.mulByNonresidue(c),a),c1:s.sub(s.sub(s.mul01(s.add(e,t),r,o.add(n,i)),a),c)}}mul034({c0:t,c1:e},r,n,i){const{Fp6:s}=this,{Fp2:o}=s,a=s.create({c0:o.mul(t.c0,r),c1:o.mul(t.c1,r),c2:o.mul(t.c2,r)}),c=s.mul01(e,n,i),u=s.mul01(s.add(t,e),o.add(r,n),i);return{c0:s.add(s.mulByNonresidue(c),a),c1:s.sub(u,s.add(a,c))}}_cyclotomicSquare({c0:t,c1:e}){const{Fp6:r}=this,{Fp2:n}=r,{c0:i,c1:s,c2:o}=t,{c0:a,c1:c,c2:u}=e,{first:l,second:h}=n.Fp4Square(i,c),{first:f,second:d}=n.Fp4Square(a,o),{first:p,second:g}=n.Fp4Square(s,u),m=n.mulByNonresidue(g);return{c0:r.create({c0:n.add(n.mul(n.sub(l,i),v),l),c1:n.add(n.mul(n.sub(f,s),v),f),c2:n.add(n.mul(n.sub(p,o),v),p)}),c1:r.create({c0:n.add(n.mul(n.add(m,a),v),m),c1:n.add(n.mul(n.add(h,c),v),h),c2:n.add(n.mul(n.add(d,u),v),d)})}}_cyclotomicExp(t,e){let r=this.ONE;for(let n=this.X_LEN-1;n>=0;n--)r=this._cyclotomicSquare(r),(0,i.GU)(e,n)&&(r=this.mul(r,t));return r}}const T=BigInt(0),P=BigInt(1),R=BigInt(2),x=BigInt(3),I=BigInt(4),N=BigInt("0xd201000000010000"),k=(0,i.dJ)(N),L={p:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),n:BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"),h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),a:T,b:I,Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1")},C=(0,c.D0)(L.n,{modFromBytes:!0,isLE:!0}),{Fp:M,Fp2:B,Fp6:D,Fp12:U}=function(t){const e=c.D0(t.ORDER),r=new A(e,t),n=new O(r);return{Fp:e,Fp2:r,Fp6:n,Fp12:new S(n,t)}}({ORDER:L.p,X_LEN:k,FP2_NONRESIDUE:[P,P],Fp2mulByB:({c0:t,c1:e})=>{const r=M.mul(t,I),n=M.mul(e,I);return{c0:M.sub(r,n),c1:M.add(r,n)}},Fp12finalExponentiate:t=>{const e=N,r=U.div(U.frobeniusMap(t,6),t),n=U.mul(U.frobeniusMap(r,2),r),i=U.conjugate(U._cyclotomicExp(n,e)),s=U.mul(U.conjugate(U._cyclotomicSquare(n)),i),o=U.conjugate(U._cyclotomicExp(s,e)),a=U.conjugate(U._cyclotomicExp(o,e)),c=U.mul(U.conjugate(U._cyclotomicExp(a,e)),U._cyclotomicSquare(i)),u=U.conjugate(U._cyclotomicExp(c,e)),l=U.frobeniusMap(U.mul(i,a),2),h=U.frobeniusMap(U.mul(o,n),3),f=U.frobeniusMap(U.mul(c,U.conjugate(n)),1),d=U.mul(U.mul(u,U.conjugate(s)),n);return U.mul(U.mul(U.mul(l,h),f),d)}}),{G2psi:K,G2psi2:H}=function(t,e,r){const n=e.pow(r,(t.ORDER-b)/w),i=e.pow(r,(t.ORDER-b)/v);function s(t,r){return[e.mul(e.frobeniusMap(t,1),n),e.mul(e.frobeniusMap(r,1),i)]}const o=e.pow(r,(t.ORDER**v-b)/w),a=e.pow(r,(t.ORDER**v-b)/v);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(t,r){return[e.mul(t,o),e.neg(r)]}const u=t=>(e,r)=>{const n=r.toAffine(),i=t(n.x,n.y);return e.fromAffine({x:i[0],y:i[1]})};return{psi:s,psi2:c,G2psi:u(s),G2psi2:u(c),PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}(M,B,B.div(B.ONE,B.NONRESIDUE)),F=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:M.ORDER,m:2,k:128,expand:"xmd",hash:n.sc}),G={p:B.ORDER,n:L.n,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),a:B.ZERO,b:B.fromBigTuple([I,I]),Gx:B.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:B.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")])},V=$(M.toBytes(T),{infinity:!0,compressed:!0});function j(t){const e=224&(t=t.slice())[0],r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function $(t,e){if(224&t[0])throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function z(t){t.assertValidity();const{BYTES:e,ORDER:r}=M,{x:n,y:s}=t.toAffine();if(t.is0())return V.slice();const o=Boolean(s*R/r);return $((0,i.lq)(n,e),{compressed:!0,sort:o})}function q(t){const{infinity:e,sort:r,value:n}=j((0,i.qj)("signatureHex",t,48)),s=M.ORDER,o=Y.G1.Point,a=(0,i.Ph)(n);if(e)return o.ZERO;const c=M.create(a&(0,i.OG)(M.BITS)),u=M.add(M.pow(c,x),M.create(L.b));let l=M.sqrt(u);if(!l)throw new Error("invalid G1 point: compressed");const h=BigInt(r);l*R/s!==h&&(l=M.neg(l));const f=o.fromAffine({x:c,y:l});return f.assertValidity(),f}function W(t){t.assertValidity();const{BYTES:e}=M;if(t.is0())return(0,s.Id)(V,(0,i.lq)(T,e));const{x:r,y:n}=t.toAffine(),{re:o,im:a}=B.reim(r),{re:c,im:u}=B.reim(n),l=Boolean((u>T?u*R:c*R)/M.ORDER&P),h=o;return(0,s.Id)($((0,i.lq)(a,e),{sort:l,compressed:!0}),(0,i.lq)(h,e))}function Z(t){const{ORDER:e}=M,{infinity:r,sort:n,value:s}=j((0,i.qj)("signatureHex",t)),o=Y.G2.Point,a=s.length/2;if(48!==a&&96!==a)throw new Error("invalid compressed signature length, expected 96/192 bytes");const c=(0,i.Ph)(s.slice(0,a)),u=(0,i.Ph)(s.slice(a));if(r)return o.ZERO;const l=M.create(c&(0,i.OG)(M.BITS)),h=M.create(u),f=B.create({c0:h,c1:l}),d=B.add(B.pow(f,x),G.b);let p=B.sqrt(d);if(!p)throw new Error("Failed to find a square root");const{re:g,im:m}=B.reim(p),y=BigInt(n);(m>T&&m*R/e!==y||m===T&&g*R/e!==y)&&(p=B.neg(p));const b=o.fromAffine({x:f,y:p});return b.assertValidity(),b}const Y=function(t){const{Fp:e,Fr:r,Fp2:n,Fp6:o,Fp12:l}=t.fields,h=(0,u.gx)(t.G1),f=Object.assign(h,(0,a.qj)(h.Point,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,u.gx)(t.G2),p=Object.assign(d,(0,a.qj)(d.Point,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),y=g(t.fields,f.Point,p.Point,{...t.params,postPrecompute:t.postPrecompute}),{millerLoopBatch:b,pairing:v,pairingBatch:w,calcPairingPrecomputes:E}=y,_=m(y,f,p,t.G2.Signature,!1),A=m(y,p,f,t.G1.ShortSignature,!0),O=t.randomBytes||s.po,S=()=>{const t=(0,c.Tp)(r.ORDER);return(0,c.qy)(O(t),r.ORDER)},T={randomSecretKey:S,randomPrivateKey:S,calcPairingPrecomputes:E},{ShortSignature:P}=t.G1,{Signature:R}=t.G2;function x(t,e){return t instanceof f.Point?t:A.hash((0,i.qj)("point",t),e?.DST)}function I(t,e){return t instanceof p.Point?t:_.hash((0,i.qj)("point",t),e?.DST)}return f.Point.BASE.precompute(4),{longSignatures:_,shortSignatures:A,millerLoopBatch:b,pairing:v,pairingBatch:w,verifyBatch:function(t,e,r,n){const i=e.map(t=>I(t,n));return _.verifyBatch(t,i,r)},fields:{Fr:r,Fp:e,Fp2:n,Fp6:o,Fp12:l},params:{ateLoopSize:t.params.ateLoopSize,twistType:t.params.twistType,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:T,getPublicKey:function(t){return _.getPublicKey(t).toBytes(!0)},getPublicKeyForShortSignatures:function(t){return A.getPublicKey(t).toBytes(!0)},sign:function(t,e,r){const n=I(t,r),i=_.sign(n,e);return t instanceof p.Point?i:R.toBytes(i)},signShortSignature:function(t,e,r){const n=x(t,r),i=A.sign(n,e);return t instanceof f.Point?i:P.toBytes(i)},verify:function(t,e,r,n){const i=I(e,n);return _.verify(t,i,r)},verifyShortSignature:function(t,e,r,n){const i=x(e,n);return A.verify(t,i,r)},aggregatePublicKeys:function(t){const e=_.aggregatePublicKeys(t);return t[0]instanceof f.Point?e:e.toBytes(!0)},aggregateSignatures:function(t){const e=_.aggregateSignatures(t);return t[0]instanceof p.Point?e:R.toBytes(e)},aggregateShortSignatures:function(t){const e=A.aggregateSignatures(t);return t[0]instanceof f.Point?e:P.toBytes(e)},G1:f,G2:p,Signature:R,ShortSignature:P}}({fields:{Fp:M,Fp2:B,Fp6:D,Fp12:U,Fr:C},G1:{...L,Fp:M,htfDefaults:{...F,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(M.mul(e.X,r),e.Y,e.Z);return e.multiplyUnsafe(N).negate().multiplyUnsafe(N).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(N).add(e),mapToCurve:function(t){const{x:e,y:r}=Q(M.create(t[0]));return J(e,r)},fromBytes:function(t){const{compressed:e,infinity:r,sort:n,value:s}=j(t),{BYTES:o,ORDER:a}=M;if(48===s.length&&e){const t=(0,i.Ph)(s),e=M.create(t&(0,i.OG)(M.BITS));if(r){if(e!==T)throw new Error("invalid G1 point: non-empty, at infinity, with compression");return{x:T,y:T}}const o=M.add(M.pow(e,x),M.create(L.b));let c=M.sqrt(o);if(!c)throw new Error("invalid G1 point: compressed point");return c*R/a!==BigInt(n)&&(c=M.neg(c)),{x:M.create(e),y:M.create(c)}}if(96!==s.length||e)throw new Error("invalid G1 point: expected 48/96 bytes");{const t=(0,i.Ph)(s.subarray(0,o)),e=(0,i.Ph)(s.subarray(o));if(r){if(t!==T||e!==T)throw new Error("G1: non-empty point at infinity");return Y.G1.Point.ZERO.toAffine()}return{x:M.create(t),y:M.create(e)}}},toBytes:function(t,e,r){const{BYTES:n,ORDER:o}=M,a=e.is0(),{x:c,y:u}=e.toAffine();if(r){if(a)return V.slice();const t=Boolean(u*R/o);return $((0,i.lq)(c,n),{compressed:!0,sort:t})}return a?(0,s.Id)(Uint8Array.of(64),new Uint8Array(2*n-1)):(0,s.Id)((0,i.lq)(c,n),(0,i.lq)(u,n))},ShortSignature:{fromBytes:t=>((0,s.DO)(t),q(t)),fromHex:t=>q(t),toBytes:t=>z(t),toRawBytes:t=>z(t),toHex:t=>(0,s.My)(z(t))}},G2:{...G,Fp:B,hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...F},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:function(t){const{x:e,y:r}=tt(B.fromBigTuple(t));return X(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(N).negate().equals(K(t,e)),clearCofactor:(t,e)=>{const r=N;let n=e.multiplyUnsafe(r).negate(),i=K(t,e),s=e.double();s=H(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n);return s.subtract(e)},fromBytes:function(t){const{BYTES:e,ORDER:r}=M,{compressed:n,infinity:s,sort:o,value:a}=j(t);if(!n&&!s&&o||!n&&s&&o||o&&s&&n)throw new Error("invalid encoding flag: "+(224&t[0]));const c=(t,e,r)=>(0,i.Ph)(t.slice(e,r));if(96===a.length&&n){if(s){if(a.reduce((t,e)=>0!==t?e+1:e,0)>0)throw new Error("invalid G2 point: compressed");return{x:B.ZERO,y:B.ZERO}}const t=c(a,0,e),n=c(a,e,2*e),i=B.create({c0:M.create(n),c1:M.create(t)}),u=B.add(B.pow(i,x),G.b);let l=B.sqrt(u);const h=l.c1===T?l.c0*R/r:l.c1*R/r?P:T;return l=o&&h>0?l:B.neg(l),{x:i,y:l}}if(192!==a.length||n)throw new Error("invalid G2 point: expected 96/192 bytes");{if(s){if(a.reduce((t,e)=>0!==t?e+1:e,0)>0)throw new Error("invalid G2 point: uncompressed");return{x:B.ZERO,y:B.ZERO}}const t=c(a,0*e,1*e),r=c(a,1*e,2*e),n=c(a,2*e,3*e),i=c(a,3*e,4*e);return{x:B.fromBigTuple([r,t]),y:B.fromBigTuple([i,n])}}},toBytes:function(t,e,r){const{BYTES:n,ORDER:o}=M,a=e.is0(),{x:c,y:u}=e.toAffine();if(r){if(a)return(0,s.Id)(V,(0,i.lq)(T,n));const t=Boolean(u.c1===T?u.c0*R/o:u.c1*R/o);return(0,s.Id)($((0,i.lq)(c.c1,n),{compressed:!0,sort:t}),(0,i.lq)(c.c0,n))}{if(a)return(0,s.Id)(Uint8Array.of(64),new Uint8Array(4*n-1));const{re:t,im:e}=B.reim(c),{re:r,im:o}=B.reim(u);return(0,s.Id)((0,i.lq)(e,n),(0,i.lq)(t,n),(0,i.lq)(o,n),(0,i.lq)(r,n))}},Signature:{fromBytes:t=>((0,s.DO)(t),Z(t)),fromHex:t=>Z(t),toBytes:t=>W(t),toRawBytes:t=>W(t),toHex:t=>(0,s.My)(W(t))}},params:{ateLoopSize:N,r:L.n,xNegative:!0,twistType:"multiplicative"},htfDefaults:F,hash:n.sc}),X=(0,a.FL)(B,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(t=>B.fromBigTuple(t.map(BigInt))))),J=(0,a.FL)(M,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(t=>BigInt(t)))),Q=(0,u.Is)(M,{A:M.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:M.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:M.create(BigInt(11))}),tt=(0,u.Is)(B,{A:B.create({c0:M.create(T),c1:M.create(BigInt(240))}),B:B.create({c0:M.create(BigInt(1012)),c1:M.create(BigInt(1012))}),Z:B.create({c0:M.create(BigInt(-2)),c1:M.create(BigInt(-1))})})},1032(t,e,r){"use strict";r.d(e,{ev:()=>x});var n=r(733),i=r(36),s=r(3556),o=r(1633),a=r(6681);const c=BigInt(0),u=BigInt(1),l=BigInt(2),h=BigInt(8);class f{constructor(t){this.ep=t}static fromBytes(t){(0,o.SJ)()}static fromHex(t){(0,o.SJ)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return(0,i.My)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.init(this.ep.precompute(t,e))}toRawBytes(){return this.toBytes()}}function d(t,e,r={}){if("function"!=typeof e)throw new Error('"hash" function param is required');(0,o.DS)(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=r,{BASE:s,Fp:a,Fn:c}=t,l=r.randomBytes||i.po,h=r.adjustScalarBytes||(t=>t),f=r.domain||((t,e,r)=>{if((0,o.d6)(r,"phflag"),e.length||r)throw new Error("Contexts/pre-hash are not supported");return t});function d(t){return c.create((0,o.lX)(t))}function p(t){const{head:r,prefix:n,scalar:i}=function(t){const r=v.secretKey;t=(0,o.qj)("private key",t,r);const n=(0,o.qj)("hashed private key",e(t),2*r),i=h(n.slice(0,r));return{head:i,prefix:n.slice(r,2*r),scalar:d(i)}}(t),a=s.multiply(i),c=a.toBytes();return{head:r,prefix:n,scalar:i,point:a,pointBytes:c}}function g(t){return p(t).pointBytes}function m(t=Uint8Array.of(),...r){const s=(0,i.Id)(...r);return d(e(f(s,(0,o.qj)("context",t),!!n)))}const y={zip215:!0};const b=a.BYTES,v={secretKey:b,publicKey:b,signature:2*b,seed:b};function w(t=l(v.seed)){return(0,o.eV)(t,v.seed,"seed")}const E={getExtendedPublicKey:p,randomSecretKey:w,isValidSecretKey:function(t){return(0,i.aY)(t)&&t.length===c.BYTES},isValidPublicKey:function(e,r){try{return!!t.fromBytes(e,r)}catch(t){return!1}},toMontgomery(e){const{y:r}=t.fromBytes(e),n=v.publicKey,i=32===n;if(!i&&57!==n)throw new Error("only defined for 25519 and 448");const s=i?a.div(u+r,u-r):a.div(r-u,r+u);return a.toBytes(s)},toMontgomerySecret(t){const r=v.secretKey;(0,o.eV)(t,r);const n=e(t.subarray(0,r));return h(n).subarray(0,r)},randomPrivateKey:w,precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({keygen:function(t){const e=E.randomSecretKey(t);return{secretKey:e,publicKey:g(e)}},getPublicKey:g,sign:function(t,e,r={}){t=(0,o.qj)("message",t),n&&(t=n(t));const{prefix:a,scalar:u,pointBytes:l}=p(e),h=m(r.context,a,t),f=s.multiply(h).toBytes(),d=m(r.context,f,l,t),g=c.create(h+d*u);if(!c.isValid(g))throw new Error("sign failed: invalid s");const y=(0,i.Id)(f,c.toBytes(g));return(0,o.eV)(y,v.signature,"result")},verify:function(e,r,i,a=y){const{context:c,zip215:u}=a,l=v.signature;e=(0,o.qj)("signature",e,l),r=(0,o.qj)("message",r),i=(0,o.qj)("publicKey",i,v.publicKey),void 0!==u&&(0,o.d6)(u,"zip215"),n&&(r=n(r));const h=l/2,f=e.subarray(0,h),d=(0,o.lX)(e.subarray(h,l));let p,g,b;try{p=t.fromBytes(i,u),g=t.fromBytes(f,u),b=s.multiplyUnsafe(d)}catch(t){return!1}if(!u&&p.isSmallOrder())return!1;const w=m(c,g.toBytes(),p.toBytes(),r);return g.add(p.multiplyUnsafe(w)).subtract(b).clearCofactor().is0()},utils:E,Point:t,lengths:v})}function p(t){const{CURVE:e,curveOpts:r,hash:n,eddsaOpts:f}=function(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r={Fp:t.Fp,Fn:(0,a.D0)(e.n,t.nBitLength,!0),uvRatio:t.uvRatio},n={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:r,hash:t.hash,eddsaOpts:n}}(t),p=function(t,e={}){const r=(0,s.UT)("edwards",t,e,e.FpFnLE),{Fp:n,Fn:a}=r;let f=r.CURVE;const{h:d}=f;(0,o.DS)(e,{},{uvRatio:"function"});const p=l<<BigInt(8*a.BYTES)-u,g=t=>n.create(t),m=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:n.sqrt(n.div(t,e))}}catch(t){return{isValid:!1,value:c}}});if(!function(t,e,r,n){const i=t.sqr(r),s=t.sqr(n),o=t.add(t.mul(e.a,i),s),a=t.add(t.ONE,t.mul(e.d,t.mul(i,s)));return t.eql(o,a)}(n,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function y(t,e,r=!1){const n=r?u:c;return(0,o.aK)("coordinate "+t,e,n,p),e}function b(t){if(!(t instanceof E))throw new Error("ExtendedPoint expected")}const v=(0,o.x)((t,e)=>{const{X:r,Y:i,Z:s}=t,o=t.is0();null==e&&(e=o?h:n.inv(s));const a=g(r*e),l=g(i*e),f=n.mul(s,e);if(o)return{x:c,y:u};if(f!==u)throw new Error("invZ was invalid");return{x:a,y:l}}),w=(0,o.x)(t=>{const{a:e,d:r}=f;if(t.is0())throw new Error("bad point: ZERO");const{X:n,Y:i,Z:s,T:o}=t,a=g(n*n),c=g(i*i),u=g(s*s),l=g(u*u),h=g(a*e);if(g(u*g(h+c))!==g(l+g(r*g(a*c))))throw new Error("bad point: equation left != right (1)");if(g(n*i)!==g(s*o))throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(t,e,r,n){this.X=y("x",t),this.Y=y("y",e),this.Z=y("z",r,!0),this.T=y("t",n),Object.freeze(this)}static CURVE(){return f}static fromAffine(t){if(t instanceof E)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};return y("x",e),y("y",r),new E(e,r,u,g(e*r))}static fromBytes(t,e=!1){const r=n.BYTES,{a:i,d:s}=f;t=(0,o.nC)((0,o.eV)(t,r,"point")),(0,o.d6)(e,"zip215");const a=(0,o.nC)(t),l=t[r-1];a[r-1]=-129&l;const h=(0,o.lX)(a),d=e?p:n.ORDER;(0,o.aK)("point.y",h,c,d);const y=g(h*h),b=g(y-u),v=g(s*y-i);let{isValid:w,value:_}=m(b,v);if(!w)throw new Error("bad point: invalid y coordinate");const A=(_&u)===u,O=!!(128&l);if(!e&&_===c&&O)throw new Error("bad point: x=0 and x_0=1");return O!==A&&(_=g(-_)),E.fromAffine({x:_,y:h})}static fromHex(t,e=!1){return E.fromBytes((0,o.qj)("point",t),e)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return _.createCache(this,t),e||this.multiply(l),this}assertValidity(){w(this)}equals(t){b(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=t,a=g(e*o),c=g(i*n),u=g(r*o),l=g(s*n);return a===c&&u===l}is0(){return this.equals(E.ZERO)}negate(){return new E(g(-this.X),this.Y,this.Z,g(-this.T))}double(){const{a:t}=f,{X:e,Y:r,Z:n}=this,i=g(e*e),s=g(r*r),o=g(l*g(n*n)),a=g(t*i),c=e+r,u=g(g(c*c)-i-s),h=a+s,d=h-o,p=a-s,m=g(u*d),y=g(h*p),b=g(u*p),v=g(d*h);return new E(m,y,v,b)}add(t){b(t);const{a:e,d:r}=f,{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:c,Z:u,T:l}=t,h=g(n*a),d=g(i*c),p=g(o*r*l),m=g(s*u),y=g((n+i)*(a+c)-h-d),v=m-p,w=m+p,_=g(d-e*h),A=g(y*v),O=g(w*_),S=g(y*_),T=g(v*w);return new E(A,O,T,S)}subtract(t){return this.add(t.negate())}multiply(t){if(!a.isValidNot0(t))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:e,f:r}=_.cached(this,t,t=>(0,s.Ak)(E,t));return(0,s.Ak)(E,[e,r])[0]}multiplyUnsafe(t,e=E.ZERO){if(!a.isValid(t))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return t===c?E.ZERO:this.is0()||t===u?this:_.unsafe(this,t,t=>(0,s.Ak)(E,t),e)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return _.unsafe(this,f.n).is0()}toAffine(t){return v(this,t)}clearCofactor(){return d===u?this:this.multiplyUnsafe(d)}toBytes(){const{x:t,y:e}=this.toAffine(),r=n.toBytes(e);return r[r.length-1]|=t&u?128:0,r}toHex(){return(0,i.My)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(t){return(0,s.Ak)(E,t)}static msm(t,e){return(0,s.Xf)(E,a,t,e)}_setWindowSize(t){this.precompute(t)}toRawBytes(){return this.toBytes()}}E.BASE=new E(f.Gx,f.Gy,u,g(f.Gx*f.Gy)),E.ZERO=new E(c,u,u,c),E.Fp=n,E.Fn=a;const _=new s.hT(E,a.BITS);return E.BASE.precompute(8),E}(e,r);return function(t,e){const r=e.Point;return Object.assign({},e,{ExtendedPoint:r,CURVE:t,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}(t,d(p,n,f))}r(9991);const g=BigInt(0),m=BigInt(1),y=BigInt(2),b=(BigInt(3),BigInt(5)),v=BigInt(8),w=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),E=(()=>({p:w,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:v,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function _(t){const e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=w,o=t*t%s*t%s,c=(0,a.zH)(o,y,s)*o%s,u=(0,a.zH)(c,m,s)*t%s,l=(0,a.zH)(u,b,s)*u%s,h=(0,a.zH)(l,e,s)*l%s,f=(0,a.zH)(h,r,s)*h%s,d=(0,a.zH)(f,n,s)*f%s,p=(0,a.zH)(d,i,s)*d%s,g=(0,a.zH)(p,i,s)*d%s,v=(0,a.zH)(g,e,s)*l%s;return{pow_p_5_8:(0,a.zH)(v,y,s)*t%s,b2:o}}function A(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const O=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function S(t,e){const r=w,n=(0,a.zi)(e*e*e,r),i=_(t*(0,a.zi)(n*n*e,r)).pow_p_5_8;let s=(0,a.zi)(t*n*i,r);const o=(0,a.zi)(e*s*s,r),c=s,u=(0,a.zi)(s*O,r),l=o===t,h=o===(0,a.zi)(-t,r),f=o===(0,a.zi)(-t*O,r);return l&&(s=c),(h||f)&&(s=u),(0,a.dQ)(s,r)&&(s=(0,a.zi)(-s,r)),{isValid:l||h,value:s}}const T=(()=>(0,a.D0)(E.p,{isLE:!0}))(),P=(()=>(0,a.D0)(E.n,{isLE:!0}))(),R=(()=>({...E,Fp:T,hash:n.Zf,adjustScalarBytes:A,uvRatio:S}))(),x=(()=>p(R))();const I=O,N=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),k=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),L=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),C=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),M=t=>S(m,t),B=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),D=t=>x.Point.Fp.create((0,o.lX)(t)&B);function U(t){const{d:e}=E,r=w,n=t=>T.create(t),i=n(I*t*t),s=n((i+m)*L);let o=BigInt(-1);const c=n((o-e*i)*n(i+e));let{isValid:u,value:l}=S(s,c),h=n(l*t);(0,a.dQ)(h,r)||(h=n(-h)),u||(l=h),u||(o=i);const f=n(o*(i-m)*C-c),d=l*l,p=n((l+l)*c),g=n(f*N),y=n(m-d),b=n(m+d);return new x.Point(n(p*b),n(y*g),n(g*b),n(p*y))}function K(t){(0,i.DO)(t,64);const e=U(D(t.subarray(0,32))),r=U(D(t.subarray(32,64)));return new H(e.add(r))}class H extends f{constructor(t){super(t)}static fromAffine(t){return new H(x.Point.fromAffine(t))}assertSame(t){if(!(t instanceof H))throw new Error("RistrettoPoint expected")}init(t){return new H(t)}static hashToCurve(t){return K((0,o.qj)("ristrettoHash",t,64))}static fromBytes(t){(0,i.DO)(t,32);const{a:e,d:r}=E,n=w,s=t=>T.create(t),c=D(t);if(!(0,o.ex)(T.toBytes(c),t)||(0,a.dQ)(c,n))throw new Error("invalid ristretto255 encoding 1");const u=s(c*c),l=s(m+e*u),h=s(m-e*u),f=s(l*l),d=s(h*h),p=s(e*r*f-d),{isValid:y,value:b}=M(s(p*d)),v=s(b*h),_=s(b*v*p);let A=s((c+c)*v);(0,a.dQ)(A,n)&&(A=s(-A));const O=s(l*_),S=s(A*O);if(!y||(0,a.dQ)(S,n)||O===g)throw new Error("invalid ristretto255 encoding 2");return new H(new x.Point(A,O,m,S))}static fromHex(t){return H.fromBytes((0,o.qj)("ristrettoHex",t,32))}static msm(t,e){return(0,s.Xf)(H,x.Point.Fn,t,e)}toBytes(){let{X:t,Y:e,Z:r,T:n}=this.ep;const i=w,s=t=>T.create(t),o=s(s(r+e)*s(r-e)),c=s(t*e),u=s(c*c),{value:l}=M(s(o*u)),h=s(l*o),f=s(l*c),d=s(h*f*n);let p;if((0,a.dQ)(n*d,i)){let r=s(e*I),n=s(t*I);t=r,e=n,p=s(h*k)}else p=f;(0,a.dQ)(t*d,i)&&(e=s(-e));let g=s((r-e)*p);return(0,a.dQ)(g,i)&&(g=s(-g)),T.toBytes(g)}equals(t){this.assertSame(t);const{X:e,Y:r}=this.ep,{X:n,Y:i}=t.ep,s=t=>T.create(t),o=s(e*i)===s(r*n),a=s(r*i)===s(e*n);return o||a}is0(){return this.equals(H.ZERO)}}H.BASE=(()=>new H(x.Point.BASE))(),H.ZERO=(()=>new H(x.Point.ZERO))(),H.Fp=(()=>T)(),H.Fn=(()=>P)()},404(t,e,r){"use strict";r.d(e,{s9:()=>f});var n=r(733),i=r(8552),s=r(6681);const o={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},a={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},c={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},u=(0,s.D0)(o.p),l=(0,s.D0)(a.p),h=(0,s.D0)(c.p);const f=(0,i.s)({...o,Fp:u,lowS:!1},n.sc);(0,i.s)({...a,Fp:l,lowS:!1},n.qt),(0,i.s)({...c,Fp:h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},n.Zf)},3156(t,e,r){"use strict";r.d(e,{bI:()=>l});var n=r(733),i=r(8552),s=r(6681);const o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},a={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},c=BigInt(2);const u=(0,s.D0)(o.p,{sqrt:function(t){const e=o.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),a=BigInt(22),l=BigInt(23),h=BigInt(44),f=BigInt(88),d=t*t*t%e,p=d*d*t%e,g=(0,s.zH)(p,r,e)*p%e,m=(0,s.zH)(g,r,e)*p%e,y=(0,s.zH)(m,c,e)*d%e,b=(0,s.zH)(y,i,e)*y%e,v=(0,s.zH)(b,a,e)*b%e,w=(0,s.zH)(v,h,e)*v%e,E=(0,s.zH)(w,f,e)*w%e,_=(0,s.zH)(E,h,e)*v%e,A=(0,s.zH)(_,r,e)*p%e,O=(0,s.zH)(A,l,e)*b%e,S=(0,s.zH)(O,n,e)*d%e,T=(0,s.zH)(S,c,e);if(!u.eql(u.sqr(T),t))throw new Error("Cannot find square root");return T}}),l=(0,i.s)({...o,Fp:u,lowS:!0,endo:a},n.sc)},1633(t,e,r){"use strict";r.d(e,{DS:()=>S,GU:()=>E,OG:()=>_,Ph:()=>l,SJ:()=>T,aK:()=>v,d6:()=>o,dJ:()=>w,eV:()=>a,ex:()=>g,fg:()=>A,jN:()=>O,lX:()=>h,lq:()=>f,nC:()=>m,qj:()=>p,r4:()=>b,x:()=>P,z:()=>d,zW:()=>c});var n=r(36);const i=BigInt(0),s=BigInt(1);function o(t,e=""){if("boolean"!=typeof t){throw new Error((e&&`"${e}"`)+"expected boolean, got type="+typeof t)}return t}function a(t,e,r=""){const i=(0,n.aY)(t),s=t?.length,o=void 0!==e;if(!i||o&&s!==e){throw new Error((r&&`"${r}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(i?`length=${s}`:"type="+typeof t))}return t}function c(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function u(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?i:BigInt("0x"+t)}function l(t){return u((0,n.My)(t))}function h(t){return(0,n.DO)(t),u((0,n.My)(Uint8Array.from(t).reverse()))}function f(t,e){return(0,n.aT)(t.toString(16).padStart(2*e,"0"))}function d(t,e){return f(t,e).reverse()}function p(t,e,r){let i;if("string"==typeof e)try{i=(0,n.aT)(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!(0,n.aY)(e))throw new Error(t+" must be hex string or Uint8Array");i=Uint8Array.from(e)}const s=i.length;if("number"==typeof r&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}function g(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r}function m(t){return Uint8Array.from(t)}const y=t=>"bigint"==typeof t&&i<=t;function b(t,e,r){return y(t)&&y(e)&&y(r)&&e<=t&&t<r}function v(t,e,r,n){if(!b(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function w(t){let e;for(e=0;t>i;t>>=s,e+=1);return e}function E(t,e){return t>>BigInt(e)&s}const _=t=>(s<<BigInt(t))-s;function A(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");const i=t=>new Uint8Array(t),s=t=>Uint8Array.of(t);let o=i(t),a=i(t),c=0;const u=()=>{o.fill(1),a.fill(0),c=0},l=(...t)=>r(a,o,...t),h=(t=i(0))=>{a=l(s(0),t),o=l(),0!==t.length&&(a=l(s(1),t),o=l())},f=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){o=l();const e=o.slice();r.push(e),t+=o.length}return(0,n.Id)(...r)};return(t,e)=>{let r;for(u(),h(t);!(r=e(f()));)h();return u(),r}}function O(t){return"function"==typeof t&&Number.isSafeInteger(t.outputLen)}function S(t,e,r={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");function n(e,r,n){const i=t[e];if(n&&void 0===i)return;const s=typeof i;if(s!==r||null===i)throw new Error(`param "${e}" is invalid: expected ${r}, got ${s}`)}Object.entries(e).forEach(([t,e])=>n(t,e,!1)),Object.entries(r).forEach(([t,e])=>n(t,e,!0))}const T=()=>{throw new Error("not implemented")};function P(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const s=t(r,...n);return e.set(r,s),s}}},733(t,e,r){"use strict";r.d(e,{tn:()=>N,aD:()=>I,ZT:()=>H,sc:()=>K,qt:()=>G,Zf:()=>F});var n=r(36);function i(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}class o extends n.Vw{constructor(t,e,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=(0,n.O8)(this.buffer)}update(t){(0,n.CC)(this),t=(0,n.ZJ)(t),(0,n.DO)(t);const{view:e,buffer:r,blockLen:i}=this,s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const e=(0,n.O8)(t);for(;i<=s-o;o+=i)this.process(e,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.CC)(this),(0,n.Ht)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;e[o++]=128,(0,n.uH)(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(r,0),o=0);for(let t=o;t<i;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,u=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+u,a,n)}(r,i-8,BigInt(8*this.length),s),this.process(r,0);const a=(0,n.O8)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.setUint32(4*t,l[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return t.destroyed=s,t.finished=i,t.length=n,t.pos=o,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const a=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),u=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),l=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),h=BigInt(2**32-1),f=BigInt(32);function d(t,e=!1){return e?{h:Number(t&h),l:Number(t>>f&h)}:{h:0|Number(t>>f&h),l:0|Number(t&h)}}function p(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){const{h:r,l:o}=d(t[s],e);[n[s],i[s]]=[r,o]}return[n,i]}const g=(t,e,r)=>t>>>r,m=(t,e,r)=>t<<32-r|e>>>r,y=(t,e,r)=>t>>>r|e<<32-r,b=(t,e,r)=>t<<32-r|e>>>r,v=(t,e,r)=>t<<64-r|e>>>r-32,w=(t,e,r)=>t>>>r-32|e<<64-r;function E(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}const _=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),A=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,O=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,T=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),P=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;const R=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),x=new Uint32Array(64);class I extends o{constructor(t=32){super(64,t,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[t,e,r,n,i,s,o,a]}set(t,e,r,n,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)x[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=x[t-15],r=x[t-2],i=(0,n.Ow)(e,7)^(0,n.Ow)(e,18)^e>>>3,s=(0,n.Ow)(r,17)^(0,n.Ow)(r,19)^r>>>10;x[t]=s+x[t-7]+i+x[t-16]|0}let{A:r,B:o,C:a,D:c,E:u,F:l,G:h,H:f}=this;for(let t=0;t<64;t++){const e=f+((0,n.Ow)(u,6)^(0,n.Ow)(u,11)^(0,n.Ow)(u,25))+i(u,l,h)+R[t]+x[t]|0,d=((0,n.Ow)(r,2)^(0,n.Ow)(r,13)^(0,n.Ow)(r,22))+s(r,o,a)|0;f=h,h=l,l=u,u=c+e|0,c=a,a=o,o=r,r=e+d|0}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,l=l+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(r,o,a,c,u,l,h,f)}roundClean(){(0,n.uH)(x)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,n.uH)(this.buffer)}}class N extends I{constructor(){super(28),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4],this.F=0|c[5],this.G=0|c[6],this.H=0|c[7]}}const k=(()=>p(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),L=(()=>k[0])(),C=(()=>k[1])(),M=new Uint32Array(80),B=new Uint32Array(80);class D extends o{constructor(t=64){super(128,t,16,!1),this.Ah=0|l[0],this.Al=0|l[1],this.Bh=0|l[2],this.Bl=0|l[3],this.Ch=0|l[4],this.Cl=0|l[5],this.Dh=0|l[6],this.Dl=0|l[7],this.Eh=0|l[8],this.El=0|l[9],this.Fh=0|l[10],this.Fl=0|l[11],this.Gh=0|l[12],this.Gl=0|l[13],this.Hh=0|l[14],this.Hl=0|l[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g]}set(t,e,r,n,i,s,o,a,c,u,l,h,f,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)M[r]=t.getUint32(e),B[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|M[t-15],r=0|B[t-15],n=y(e,r,1)^y(e,r,8)^g(e,0,7),i=b(e,r,1)^b(e,r,8)^m(e,r,7),s=0|M[t-2],o=0|B[t-2],a=y(s,o,19)^v(s,o,61)^g(s,0,6),c=b(s,o,19)^w(s,o,61)^m(s,o,6),u=O(i,c,B[t-7],B[t-16]),l=S(u,n,a,M[t-7],M[t-16]);M[t]=0|l,B[t]=0|u}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:R,Hh:x,Hl:I}=this;for(let t=0;t<80;t++){const e=y(l,h,14)^y(l,h,18)^v(l,h,41),g=b(l,h,14)^b(l,h,18)^w(l,h,41),m=l&f^~l&p,O=T(I,g,h&d^~h&R,C[t],B[t]),S=P(O,x,e,m,L[t],M[t]),N=0|O,k=y(r,n,28)^v(r,n,34)^v(r,n,39),D=b(r,n,28)^w(r,n,34)^w(r,n,39),U=r&i^r&o^i&o,K=n&s^n&a^s&a;x=0|p,I=0|R,p=0|f,R=0|d,f=0|l,d=0|h,({h:l,l:h}=E(0|c,0|u,0|S,0|N)),c=0|o,u=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const H=_(N,D,K);r=A(H,S,k,U),n=0|H}({h:r,l:n}=E(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=E(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=E(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:u}=E(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=E(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=E(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:R}=E(0|this.Gh,0|this.Gl,0|p,0|R)),({h:x,l:I}=E(0|this.Hh,0|this.Hl,0|x,0|I)),this.set(r,n,i,s,o,a,c,u,l,h,f,d,p,R,x,I)}roundClean(){(0,n.uH)(M,B)}destroy(){(0,n.uH)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class U extends D{constructor(){super(48),this.Ah=0|u[0],this.Al=0|u[1],this.Bh=0|u[2],this.Bl=0|u[3],this.Ch=0|u[4],this.Cl=0|u[5],this.Dh=0|u[6],this.Dl=0|u[7],this.Eh=0|u[8],this.El=0|u[9],this.Fh=0|u[10],this.Fl=0|u[11],this.Gh=0|u[12],this.Gl=0|u[13],this.Hh=0|u[14],this.Hl=0|u[15]}}const K=(0,n.qj)(()=>new I),H=(0,n.qj)(()=>new N),F=(0,n.qj)(()=>new D),G=(0,n.qj)(()=>new U)},2001(t,e,r){"use strict";r.r(e),r.d(e,{SHA224:()=>o,SHA256:()=>i,sha224:()=>a,sha256:()=>s});var n=r(733);const i=n.aD,s=n.sc,o=n.tn,a=n.ZT},36(t,e,r){"use strict";r.d(e,{Vw:()=>P,DO:()=>o,CC:()=>c,sd:()=>a,Fe:()=>s,Ht:()=>u,My:()=>g,uH:()=>l,Id:()=>T,qj:()=>R,O8:()=>h,aT:()=>A,aY:()=>i,po:()=>x,Ow:()=>f,ZJ:()=>S,AI:()=>O});const n="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function a(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");s(t.outputLen),s(t.blockLen)}function c(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function l(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function h(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function f(t,e){return t<<32-e|t>>>e}const d=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function g(t){if(o(t),d)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=p[t[r]];return e}const m=48,y=57,b=65,v=70,w=97,E=102;function _(t){return t>=m&&t<=y?t-m:t>=b&&t<=v?t-(b-10):t>=w&&t<=E?t-(w-10):void 0}function A(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(d)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=_(t.charCodeAt(i)),s=_(t.charCodeAt(i+1));if(void 0===r||void 0===s){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+s}return n}function O(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function S(t){return"string"==typeof t&&(t=O(t)),o(t),t}function T(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];o(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}class P{}function R(t){const e=e=>t().update(S(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function x(t=32){if(n&&"function"==typeof n.getRandomValues)return n.getRandomValues(new Uint8Array(t));if(n&&"function"==typeof n.randomBytes)return Uint8Array.from(n.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}},5608(t,e,r){"use strict";r.d(e,{AQ:()=>h,C6:()=>i,Ju:()=>a,N3:()=>l,YH:()=>o,fX:()=>u,sH:()=>s,xN:()=>f,zs:()=>c});var 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])},n(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function s(t,e,r,n){return new(r||(r=Promise))(function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(o,a)}c((n=n.apply(t,e||[])).next())})}function o(t,e){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}Object.create;function a(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function u(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function l(t){return this instanceof l?(this.v=t,this):new l(t)}function h(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(t){return function(e){return Promise.resolve(e).then(t,u)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(t,e){i[t]&&(n[t]=function(e){return new Promise(function(r,n){s.push([t,e,r,n])>1||a(t,e)})},e&&(n[t]=e(n[t])))}function a(t,e){try{(r=i[t](e)).value instanceof l?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(t){h(s[0][3],t)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function f(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=a(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise(function(n,i){(function(t,e,r,n){Promise.resolve(n).then(function(e){t({value:e,done:r})},e)})(n,i,(e=t[r](e)).done,e.value)})}}}Object.create;"function"==typeof SuppressedError&&SuppressedError},7873(t,e,r){"use strict";r.r(e),r.d(e,{BigNumber:()=>n,default:()=>E});var n=function t(e){var r,n,E,_=M.prototype={constructor:M,toString:null,valueOf:null},A=new M(1),O=20,S=4,T=-7,P=21,R=-1e7,x=1e7,I=!1,N=1,k=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},C="0123456789abcdefghijklmnopqrstuvwxyz";function M(t,e){var r,s,o,c,l,h,f,d,p=this;if(!(p instanceof M))return new M(t,e);if(d=typeof t,null==e){if(D(t))return p.s=t.s,void(!t.c||t.e>x?p.c=p.e=null:t.e<R?p.c=[p.e=0]:(p.e=t.e,p.c=t.c.slice()));if("number"==d){if(0*t!=0)return p.s=isNaN(t)?null:t<0?-1:1,void(p.c=p.e=null);if(p.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,l=t;l>=10;l/=10,c++);return void(c>x?p.c=p.e=null:(p.e=c,p.c=[t]))}f=String(t)}else{if("string"==d){if(f=t,!i.test(f))return E(p,f)}else{if("bigint"!=d)throw Error(a+"Invalid argument: "+t);f=String(t)}p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(c=f.indexOf("."))>-1&&(f=f.replace(".","")),(l=f.search(/e/i))>0?(c<0&&(c=l),c+=+f.slice(l+1),f=f.substring(0,l)):c<0&&(c=f.length)}else{if("string"!=d)throw Error(a+"String expected: "+t);for(y(e,2,C.length,"Base"),f=t,p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1,r=C.slice(0,e),c=l=0,h=f.length;l<h;l++)if(r.indexOf(s=f.charAt(l))<0){if("."==s){if(l>c){c=h;continue}}else if(!o&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){o=!0,l=-1,c=0;continue}return E(p,t,e)}(c=(f=n(f,e,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):c=f.length}for(l=0;48===f.charCodeAt(l);l++);for(h=f.length;48===f.charCodeAt(--h););if(f=f.slice(l,++h))if(h-=l,(c=c-l-1)>x)p.c=p.e=null;else if(c<R)p.c=[p.e=0];else{if(p.e=c,p.c=[],l=(c+1)%u,c<0&&(l+=u),l<h){for(l&&p.c.push(+f.slice(0,l)),h-=u;l<h;)p.c.push(+f.slice(l,l+=u));l=u-(f=f.slice(l)).length}else l-=h;for(;l--;f+="0");p.c.push(+f)}else p.c=[p.e=0]}function B(t,e,r,n){var i,s,o,a,c;if(null==r?r=S:y(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=g(t.c),c=1==n||2==n&&(o<=T||o>=P)?v(c,o):w(c,o,"0");else if(s=(t=H(new M(t),e,r)).e,a=(c=g(t.c)).length,1==n||2==n&&(e<=s||s<=T)){for(;a<e;c+="0",a++);c=v(c,s)}else if(e-=o+(2===n&&s>o),c=w(c,s,"0"),s+1>a){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-a)>0)for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function D(t){return t instanceof M||!!t&&!0===t._isBigNumber}function U(t,e){for(var r,n,i=1,s=new M(t[0]);i<t.length;i++)(!(n=new M(t[i])).s||(r=m(s,n))===e||0===r&&s.s===e)&&(s=n);return s}function K(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*u-1)>x?t.c=t.e=null:r<R?t.c=[t.e=0]:(t.e=r,t.c=e),t}function H(t,e,r,n){var i,a,l,f,d,p,g,m=t.c,y=h;if(m){t:{for(i=1,f=m[0];f>=10;f/=10,i++);if((a=e-i)<0)a+=u,l=e,d=m[p=0],g=o(d/y[i-l-1]%10);else if((p=s((a+1)/u))>=m.length){if(!n)break t;for(;m.length<=p;m.push(0));d=g=0,i=1,l=(a%=u)-u+1}else{for(d=f=m[p],i=1;f>=10;f/=10,i++);g=(l=(a%=u)-u+i)<0?0:o(d/y[i-l-1]%10)}if(n=n||e<0||null!=m[p+1]||(l<0?d:d%y[i-l-1]),n=r<4?(g||n)&&(0==r||r==(t.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(a>0?l>0?d/y[i-l]:0:m[p-1])%10&1||r==(t.s<0?8:7)),e<1||!m[0])return m.length=0,n?(e-=t.e+1,m[0]=y[(u-e%u)%u],t.e=-e||0):m[0]=t.e=0,t;if(0==a?(m.length=p,f=1,p--):(m.length=p+1,f=y[u-a],m[p]=l>0?o(d/y[i-l]%y[l])*f:0),n)for(;;){if(0==p){for(a=1,l=m[0];l>=10;l/=10,a++);for(l=m[0]+=f,f=1;l>=10;l/=10,f++);a!=f&&(t.e++,m[0]==c&&(m[0]=1));break}if(m[p]+=f,m[p]!=c)break;m[p--]=0,f=1}for(a=m.length;0===m[--a];m.pop());}t.e>x?t.c=t.e=null:t.e<R&&(t.c=[t.e=0])}return t}function F(t){var e,r=t.e;return null===r?t.toString():(e=g(t.c),e=r<=T||r>=P?v(e,r):w(e,r,"0"),t.s<0?"-"+e:e)}M.clone=t,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(a+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(y(r=t[e],0,d,e),O=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(y(r=t[e],0,8,e),S=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(y(r[0],-d,0,e),y(r[1],0,d,e),T=r[0],P=r[1]):(y(r,-d,d,e),T=-(P=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)y(r[0],-d,-1,e),y(r[1],1,d,e),R=r[0],x=r[1];else{if(y(r,-d,d,e),!r)throw Error(a+e+" cannot be zero: "+r);R=-(x=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(a+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw I=!r,Error(a+"crypto unavailable");I=r}else I=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(y(r=t[e],0,9,e),N=r),t.hasOwnProperty(e="POW_PRECISION")&&(y(r=t[e],0,d,e),k=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(a+e+" not an object: "+r);L=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(a+e+" invalid: "+r);C=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:S,EXPONENTIAL_AT:[T,P],RANGE:[R,x],CRYPTO:I,MODULO_MODE:N,POW_PRECISION:k,FORMAT:L,ALPHABET:C}},M.isBigNumber=function(t){if(!D(t))return!1;var e,r,n=t.c,i=t.e,s=t.s;if("[object Array]"!={}.toString.call(n))return null===n&&null===i&&(null===s||1===s||-1===s);if(1!==s&&-1!==s||i<-d||i>d||i!==o(i))return!1;if(0===n[0])return 0===i&&1===n.length;if((e=(i+1)%u)<1&&(e+=u),String(n[0]).length!==e)return!1;for(e=0;e<n.length;e++)if((r=n[e])<0||r>=c||r!==o(r))return!1;return 0!==r},M.maximum=M.max=function(){return U(arguments,-1)},M.minimum=M.min=function(){return U(arguments,1)},M.random=function(){var t=9007199254740992,e=Math.random()*t&2097151?function(){return o(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var r,n,i,c,l,f=0,p=[],g=new M(A);if(null==t?t=O:y(t,0,d),c=s(t/u),I)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(c*=2));f<c;)(l=131072*r[f]+(r[f+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[f]=n[0],r[f+1]=n[1]):(p.push(l%1e14),f+=2);f=c/2}else{if(!crypto.randomBytes)throw I=!1,Error(a+"crypto unavailable");for(r=crypto.randomBytes(c*=7);f<c;)(l=281474976710656*(31&r[f])+1099511627776*r[f+1]+4294967296*r[f+2]+16777216*r[f+3]+(r[f+4]<<16)+(r[f+5]<<8)+r[f+6])>=9e15?crypto.randomBytes(7).copy(r,f):(p.push(l%1e14),f+=7);f=c/7}if(!I)for(;f<c;)(l=e())<9e15&&(p[f++]=l%1e14);for(c=p[--f],t%=u,c&&t&&(l=h[u-t],p[f]=o(c/l)*l);0===p[f];p.pop(),f--);if(f<0)p=[i=0];else{for(i=-1;0===p[0];p.splice(0,1),i-=u);for(f=1,l=p[0];l>=10;l/=10,f++);f<u&&(i-=u-f)}return g.e=i,g.c=p,g}}(),M.sum=function(){for(var t=1,e=arguments,r=new M(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(n,i,s,o,a){var c,u,l,h,f,d,p,m,y=n.indexOf("."),b=O,v=S;for(y>=0&&(h=k,k=0,n=n.replace(".",""),d=(m=new M(i)).pow(n.length-y),k=h,m.c=e(w(g(d.c),d.e,"0"),10,s,t),m.e=m.c.length),l=h=(p=e(n,i,s,a?(c=C,t):(c=t,C))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(y<0?--l:(d.c=p,d.e=l,d.s=o,p=(d=r(d,m,b,v,s)).c,f=d.r,l=d.e),y=p[u=l+b+1],h=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=y||f)&&(0==v||v==(d.s<0?3:2)):y>h||y==h&&(4==v||f||6==v&&1&p[u-1]||v==(d.s<0?8:7)),u<1||!p[0])n=f?w(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=c.charAt(p[y++]));n=w(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,s,o,a=0,c=t.length,u=e%f,l=e/f|0;for(t=t.slice();c--;)a=((i=u*(s=t[c]%f)+(n=l*s+(o=t[c]/f|0)*u)%f*f+a)/r|0)+(n/f|0)+l*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,s,a,l){var h,f,d,g,m,y,b,v,w,E,_,A,O,S,T,P,R,x=n.s==i.s?1:-1,I=n.c,N=i.c;if(!(I&&I[0]&&N&&N[0]))return new M(n.s&&i.s&&(I?!N||I[0]!=N[0]:N)?I&&0==I[0]||!N?0*x:x/0:NaN);for(w=(v=new M(x)).c=[],x=s+(f=n.e-i.e)+1,l||(l=c,f=p(n.e/u)-p(i.e/u),x=x/u|0),d=0;N[d]==(I[d]||0);d++);if(N[d]>(I[d]||0)&&f--,x<0)w.push(1),g=!0;else{for(S=I.length,P=N.length,d=0,x+=2,(m=o(l/(N[0]+1)))>1&&(N=t(N,m,l),I=t(I,m,l),P=N.length,S=I.length),O=P,_=(E=I.slice(0,P)).length;_<P;E[_++]=0);R=N.slice(),R=[0].concat(R),T=N[0],N[1]>=l/2&&T++;do{if(m=0,(h=e(N,E,P,_))<0){if(A=E[0],P!=_&&(A=A*l+(E[1]||0)),(m=o(A/T))>1)for(m>=l&&(m=l-1),b=(y=t(N,m,l)).length,_=E.length;1==e(y,E,b,_);)m--,r(y,P<b?R:N,b,l),b=y.length,h=1;else 0==m&&(h=m=1),b=(y=N.slice()).length;if(b<_&&(y=[0].concat(y)),r(E,y,_,l),_=E.length,-1==h)for(;e(N,E,P,_)<1;)m++,r(E,P<_?R:N,_,l),_=E.length}else 0===h&&(m++,E=[0]);w[d++]=m,E[0]?E[_++]=I[O]||0:(E=[I[O]],_=1)}while((O++<S||null!=E[0])&&x--);g=null!=E[0],w[0]||w.splice(0,1)}if(l==c){for(d=1,x=w[0];x>=10;x/=10,d++);H(v,s+(v.e=d+f*u-1)+1,a,g)}else v.e=f,v.r=+g;return v}}(),E=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,e=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,o,c){var u,l=o.replace(i,"");if(n.test(l))return s.s=isNaN(l)?null:l<0?-1:1,void(s.c=s.e=null);if(l=l.replace(t,function(t,e,r){return u="x"==(r=r.toLowerCase())?16:"b"==r?2:8,c&&c!=u?t:e}),c&&(u=c,l=l.replace(e,"$1").replace(r,"0.$1")),o!=l)return new M(l,u);throw Error(a+"Not a"+(c?" base "+c:"")+" number: "+o)}}(),_.absoluteValue=_.abs=function(){var t=new M(this);return t.s<0&&(t.s=1),t},_.comparedTo=function(t,e){return m(this,new M(t,e))},_.decimalPlaces=_.dp=function(t,e){var r,n,i,s=this;if(null!=t)return y(t,0,d),null==e?e=S:y(e,0,8),H(new M(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((i=r.length-1)-p(this.e/u))*u,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(t,e){return r(this,new M(t,e),O,S)},_.dividedToIntegerBy=_.idiv=function(t,e){return r(this,new M(t,e),0,1)},_.exponentiatedBy=_.pow=function(t,e){var r,n,i,c,l,h,f,d,p=this;if((t=new M(t)).c&&!t.isInteger())throw Error(a+"Exponent not an integer: "+F(t));if(null!=e&&(e=new M(e)),l=t.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return d=new M(Math.pow(+F(p),l?t.s*(2-b(t)):+F(t))),e?d.mod(e):d;if(h=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new M(NaN);(n=!h&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(t.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return c=p.s<0&&b(t)?-0:0,p.e>-1&&(c=1/c),new M(h?1/c:c);k&&(c=s(k/u+2))}for(l?(r=new M(.5),h&&(t.s=1),f=b(t)):f=(i=Math.abs(+F(t)))%2,d=new M(A);;){if(f){if(!(d=d.times(p)).c)break;c?d.c.length>c&&(d.c.length=c):n&&(d=d.mod(e))}if(i){if(0===(i=o(i/2)))break;f=i%2}else if(H(t=t.times(r),t.e+1,1),t.e>14)f=b(t);else{if(0===(i=+F(t)))break;f=i%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(e))}return n?d:(h&&(d=A.div(d)),e?d.mod(e):c?H(d,k,S,void 0):d)},_.integerValue=function(t){var e=new M(this);return null==t?t=S:y(t,0,8),H(e,e.e+1,t)},_.isEqualTo=_.eq=function(t,e){return 0===m(this,new M(t,e))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(t,e){return m(this,new M(t,e))>0},_.isGreaterThanOrEqualTo=_.gte=function(t,e){return 1===(e=m(this,new M(t,e)))||0===e},_.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},_.isLessThan=_.lt=function(t,e){return m(this,new M(t,e))<0},_.isLessThanOrEqualTo=_.lte=function(t,e){return-1===(e=m(this,new M(t,e)))||0===e},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new M(t,e)).s,!a||!e)return new M(NaN);if(a!=e)return t.s=-e,o.plus(t);var l=o.e/u,h=t.e/u,f=o.c,d=t.c;if(!l||!h){if(!f||!d)return f?(t.s=-e,t):new M(d?o:NaN);if(!f[0]||!d[0])return d[0]?(t.s=-e,t):new M(f[0]?o:3==S?-0:0)}if(l=p(l),h=p(h),f=f.slice(),a=l-h){for((s=a<0)?(a=-a,i=f):(h=l,i=d),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(e=d.length))?a:e,a=e=0;e<n;e++)if(f[e]!=d[e]){s=f[e]<d[e];break}if(s&&(i=f,f=d,d=i,t.s=-t.s),(e=(n=d.length)-(r=f.length))>0)for(;e--;f[r++]=0);for(e=c-1;n>a;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=e);--f[r],f[n]+=c}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--h);return f[0]?K(t,f,h):(t.s=3==S?-1:1,t.c=[t.e=0],t)},_.modulo=_.mod=function(t,e){var n,i,s=this;return t=new M(t,e),!s.c||!t.s||t.c&&!t.c[0]?new M(NaN):!t.c||s.c&&!s.c[0]?new M(s):(9==N?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,N),(t=s.minus(n.times(t))).c[0]||1!=N||(t.s=s.s),t)},_.multipliedBy=_.times=function(t,e){var r,n,i,s,o,a,l,h,d,g,m,y,b,v,w,E=this,_=E.c,A=(t=new M(t,e)).c;if(!(_&&A&&_[0]&&A[0]))return!E.s||!t.s||_&&!_[0]&&!A||A&&!A[0]&&!_?t.c=t.e=t.s=null:(t.s*=E.s,_&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=p(E.e/u)+p(t.e/u),t.s*=E.s,(l=_.length)<(g=A.length)&&(b=_,_=A,A=b,i=l,l=g,g=i),i=l+g,b=[];i--;b.push(0));for(v=c,w=f,i=g;--i>=0;){for(r=0,m=A[i]%w,y=A[i]/w|0,s=i+(o=l);s>i;)r=((h=m*(h=_[--o]%w)+(a=y*h+(d=_[o]/w|0)*m)%w*w+b[s]+r)/v|0)+(a/w|0)+y*d,b[s--]=h%v;b[s]=r}return r?++n:b.splice(0,1),K(t,b,n)},_.negated=function(){var t=new M(this);return t.s=-t.s||null,t},_.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new M(t,e)).s,!i||!e)return new M(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/u,o=t.e/u,a=n.c,l=t.c;if(!s||!o){if(!a||!l)return new M(i/0);if(!a[0]||!l[0])return l[0]?t:new M(a[0]?n:0*i)}if(s=p(s),o=p(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=l):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=l.length)<0&&(r=l,l=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+l[e]+i)/c|0,a[e]=c===a[e]?0:a[e]%c;return i&&(a=[i].concat(a),++o),K(t,a,o)},_.precision=_.sd=function(t,e){var r,n,i,s=this;if(null!=t&&t!==!!t)return y(t,1,d),null==e?e=S:y(e,0,8),H(new M(s),t,e);if(!(r=s.c))return null;if(n=(i=r.length-1)*u+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},_.shiftedBy=function(t){return y(t,-9007199254740991,l),this.times("1e"+t)},_.squareRoot=_.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,u=o.e,l=O+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+F(o)))||c==1/0?(((e=g(a)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=p((u+1)/2)-(u<0||u%2),n=new M(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,l,1))),g(s.c).slice(0,c)===(e=g(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(H(n,n.e+O+2,1),t=!n.times(n).eq(o));break}if(!i&&(H(s,s.e+O+2,0),s.times(s).eq(o))){n=s;break}l+=4,c+=4,i=1}return H(n,n.e+O+1,S,t)},_.toExponential=function(t,e){return null!=t&&(y(t,0,d),t++),B(this,t,e,1)},_.toFixed=function(t,e){return null!=t&&(y(t,0,d),t=t+this.e+1),B(this,t,e)},_.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=L;else if("object"!=typeof r)throw Error(a+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var s,o=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,l=r.groupSeparator||"",h=o[0],f=o[1],d=i.s<0,p=d?h.slice(1):h,g=p.length;if(u&&(s=c,c=u,u=s,g-=s),c>0&&g>0){for(s=g%c||c,h=p.substr(0,s);s<g;s+=c)h+=l+p.substr(s,c);u>0&&(h+=l+p.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(t){var e,n,i,s,o,c,l,f,d,p,m,y,b=this,v=b.c;if(null!=t&&(!(l=new M(t)).isInteger()&&(l.c||1!==l.s)||l.lt(A)))throw Error(a+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+F(l));if(!v)return new M(b);for(e=new M(A),d=n=new M(A),i=f=new M(A),y=g(v),o=e.e=y.length-b.e-1,e.c[0]=h[(c=o%u)<0?u+c:c],t=!t||l.comparedTo(e)>0?o>0?e:d:l,c=x,x=1/0,l=new M(y),f.c[0]=0;p=r(l,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,d=f.plus(p.times(s=d)),f=s,e=l.minus(p.times(s=e)),l=s;return s=r(t.minus(n),i,0,1),f=f.plus(s.times(d)),n=n.plus(s.times(i)),f.s=d.s=b.s,m=r(d,i,o*=2,S).minus(b).abs().comparedTo(r(f,n,o,S).minus(b).abs())<1?[d,i]:[f,n],x=c,m},_.toNumber=function(){return+F(this)},_.toObject=function(){var t=this;return{c:t.c?t.c.slice():null,e:t.e,s:t.s}},_.toPrecision=function(t,e){return null!=t&&y(t,1,d),B(this,t,e,2)},_.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=s<=T||s>=P?v(g(r.c),s):w(g(r.c),s,"0"):(y(t,2,C.length,"Base"),e=n(w(g(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},_.valueOf=_.toJSON=function(){return F(this)},_._isBigNumber=!0,null!=e&&M.set(e);return M}(),i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,o=Math.floor,a="[BigNumber Error] ",c=1e14,u=14,l=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,d=1e9;function p(t){var e=0|t;return t>0||t===e?e:e-1}function g(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=u-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function m(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,u=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==u,!i||!s)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function y(t,e,r,n){if(t<e||t>r||t!==o(t))throw Error(a+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function b(t){var e=t.c.length-1;return p(t.e/u)==e&&t.c[e]%2!=0}function v(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function w(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}const E=n}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r(4779)})());
|