@dfinity/sns 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/candid/sns_governance.certified.idl.js +14 -6
  2. package/dist/candid/sns_governance.d.ts +8 -4
  3. package/dist/candid/sns_governance.did +5 -7
  4. package/dist/candid/sns_governance.idl.js +14 -6
  5. package/dist/candid/sns_root.certified.idl.js +85 -3
  6. package/dist/candid/sns_root.d.ts +62 -3
  7. package/dist/candid/sns_root.did +52 -6
  8. package/dist/candid/sns_root.idl.js +85 -3
  9. package/dist/candid/sns_swap.certified.idl.js +24 -1
  10. package/dist/candid/sns_swap.d.ts +24 -1
  11. package/dist/candid/sns_swap.did +21 -2
  12. package/dist/candid/sns_swap.idl.js +24 -1
  13. package/dist/cjs/index.cjs.js +31 -31
  14. package/dist/cjs/index.cjs.js.map +3 -3
  15. package/dist/esm/chunk-5EFW5NLJ.js +2 -0
  16. package/dist/esm/chunk-5EFW5NLJ.js.map +7 -0
  17. package/dist/esm/chunk-NJ4DNYU7.js +2 -0
  18. package/dist/esm/chunk-NJ4DNYU7.js.map +7 -0
  19. package/dist/esm/chunk-QOHSQFP6.js +2 -0
  20. package/dist/esm/chunk-QOHSQFP6.js.map +7 -0
  21. package/dist/esm/chunk-S7OOQWQZ.js +2 -0
  22. package/dist/esm/chunk-S7OOQWQZ.js.map +7 -0
  23. package/dist/esm/chunk-TGR2FDNH.js +2 -0
  24. package/dist/esm/chunk-TGR2FDNH.js.map +7 -0
  25. package/dist/esm/chunk-Y5V5O772.js +2 -0
  26. package/dist/esm/chunk-Y5V5O772.js.map +7 -0
  27. package/dist/esm/governance.canister.js +1 -1
  28. package/dist/esm/index.js +1 -1
  29. package/dist/esm/index.js.map +3 -3
  30. package/dist/esm/ledger.canister.js +1 -1
  31. package/dist/esm/root.canister.js +1 -1
  32. package/dist/esm/sns.js +1 -1
  33. package/dist/esm/sns.wrapper.js +1 -1
  34. package/dist/esm/swap.canister.js +2 -0
  35. package/dist/esm/swap.canister.js.map +7 -0
  36. package/dist/types/enums/swap.enums.d.ts +7 -0
  37. package/dist/types/index.d.ts +5 -2
  38. package/dist/types/root.canister.d.ts +5 -8
  39. package/dist/types/sns.d.ts +2 -2
  40. package/dist/types/sns.wrapper.d.ts +8 -1
  41. package/dist/types/swap.canister.d.ts +11 -0
  42. package/dist/types/utils/did.utils.d.ts +1 -0
  43. package/package.json +1 -1
  44. package/dist/esm/chunk-7F6PCBCJ.js +0 -2
  45. package/dist/esm/chunk-7F6PCBCJ.js.map +0 -7
  46. package/dist/esm/chunk-LXL5LYD3.js +0 -2
  47. package/dist/esm/chunk-LXL5LYD3.js.map +0 -7
  48. package/dist/esm/chunk-RB6XGLR7.js +0 -2
  49. package/dist/esm/chunk-RB6XGLR7.js.map +0 -7
  50. package/dist/esm/chunk-WPRZTZWQ.js +0 -2
  51. package/dist/esm/chunk-WPRZTZWQ.js.map +0 -7
  52. package/dist/esm/chunk-YKP66JDM.js +0 -2
  53. package/dist/esm/chunk-YKP66JDM.js.map +0 -7
  54. package/dist/esm/chunk-YL4WAPXH.js +0 -2
  55. package/dist/esm/chunk-YL4WAPXH.js.map +0 -7
@@ -1,17 +1,17 @@
1
- "use strict";var Do=Object.create;var Vt=Object.defineProperty;var $o=Object.getOwnPropertyDescriptor;var Lo=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,ea=Object.prototype.hasOwnProperty;var T=(e,A)=>()=>(A||e((A={exports:{}}).exports,A),A.exports),ta=(e,A)=>{for(var t in A)Vt(e,t,{get:A[t],enumerable:!0})},fi=(e,A,t,r)=>{if(A&&typeof A=="object"||typeof A=="function")for(let n of Lo(A))!ea.call(e,n)&&n!==t&&Vt(e,n,{get:()=>A[n],enumerable:!(r=$o(A,n))||r.enumerable});return e};var Ii=(e,A,t)=>(t=e!=null?Do(Aa(e)):{},fi(A||!e||!e.__esModule?Vt(t,"default",{value:e,enumerable:!0}):t,e)),ra=e=>fi(Vt({},"__esModule",{value:!0}),e);var yi=T(jt=>{"use strict";jt.byteLength=ia;jt.toByteArray=oa;jt.fromByteArray=Ba;var Be=[],XA=[],na=typeof Uint8Array<"u"?Uint8Array:Array,Pr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ye=0,pi=Pr.length;Ye<pi;++Ye)Be[Ye]=Pr[Ye],XA[Pr.charCodeAt(Ye)]=Ye;var Ye,pi;XA["-".charCodeAt(0)]=62;XA["_".charCodeAt(0)]=63;function wi(e){var A=e.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=A);var r=t===A?0:4-t%4;return[t,r]}function ia(e){var A=wi(e),t=A[0],r=A[1];return(t+r)*3/4-r}function sa(e,A,t){return(A+t)*3/4-t}function oa(e){var A,t=wi(e),r=t[0],n=t[1],i=new na(sa(e,r,n)),s=0,c=n>0?r-4:r,a;for(a=0;a<c;a+=4)A=XA[e.charCodeAt(a)]<<18|XA[e.charCodeAt(a+1)]<<12|XA[e.charCodeAt(a+2)]<<6|XA[e.charCodeAt(a+3)],i[s++]=A>>16&255,i[s++]=A>>8&255,i[s++]=A&255;return n===2&&(A=XA[e.charCodeAt(a)]<<2|XA[e.charCodeAt(a+1)]>>4,i[s++]=A&255),n===1&&(A=XA[e.charCodeAt(a)]<<10|XA[e.charCodeAt(a+1)]<<4|XA[e.charCodeAt(a+2)]>>2,i[s++]=A>>8&255,i[s++]=A&255),i}function aa(e){return Be[e>>18&63]+Be[e>>12&63]+Be[e>>6&63]+Be[e&63]}function ca(e,A,t){for(var r,n=[],i=A;i<t;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),n.push(aa(r));return n.join("")}function Ba(e){for(var A,t=e.length,r=t%3,n=[],i=16383,s=0,c=t-r;s<c;s+=i)n.push(ca(e,s,s+i>c?c:s+i));return r===1?(A=e[t-1],n.push(Be[A>>2]+Be[A<<4&63]+"==")):r===2&&(A=(e[t-2]<<8)+e[t-1],n.push(Be[A>>10]+Be[A>>4&63]+Be[A<<2&63]+"=")),n.join("")}});var Vr=T(Zr=>{Zr.read=function(e,A,t,r,n){var i,s,c=n*8-r-1,a=(1<<c)-1,w=a>>1,N=-7,S=t?n-1:0,k=t?-1:1,m=e[A+S];for(S+=k,i=m&(1<<-N)-1,m>>=-N,N+=c;N>0;i=i*256+e[A+S],S+=k,N-=8);for(s=i&(1<<-N)-1,i>>=-N,N+=r;N>0;s=s*256+e[A+S],S+=k,N-=8);if(i===0)i=1-w;else{if(i===a)return s?NaN:(m?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-w}return(m?-1:1)*s*Math.pow(2,i-r)};Zr.write=function(e,A,t,r,n,i){var s,c,a,w=i*8-n-1,N=(1<<w)-1,S=N>>1,k=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=r?0:i-1,R=r?1:-1,J=A<0||A===0&&1/A<0?1:0;for(A=Math.abs(A),isNaN(A)||A===1/0?(c=isNaN(A)?1:0,s=N):(s=Math.floor(Math.log(A)/Math.LN2),A*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+S>=1?A+=k/a:A+=k*Math.pow(2,1-S),A*a>=2&&(s++,a/=2),s+S>=N?(c=0,s=N):s+S>=1?(c=(A*a-1)*Math.pow(2,n),s=s+S):(c=A*Math.pow(2,S-1)*Math.pow(2,n),s=0));n>=8;e[t+m]=c&255,m+=R,c/=256,n-=8);for(s=s<<n|c,w+=n;w>0;e[t+m]=s&255,m+=R,s/=256,w-=8);e[t+m-R]|=J*128}});var Hi=T(De=>{"use strict";var jr=yi(),ze=Vr(),_i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;De.Buffer=_;De.SlowBuffer=la;De.INSPECT_MAX_BYTES=50;var Kt=2147483647;De.kMaxLength=Kt;_.TYPED_ARRAY_SUPPORT=ga();!_.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ga(){try{var e=new Uint8Array(1),A={foo:function(){return 42}};return Object.setPrototypeOf(A,Uint8Array.prototype),Object.setPrototypeOf(e,A),e.foo()===42}catch{return!1}}Object.defineProperty(_.prototype,"parent",{enumerable:!0,get:function(){if(!!_.isBuffer(this))return this.buffer}});Object.defineProperty(_.prototype,"offset",{enumerable:!0,get:function(){if(!!_.isBuffer(this))return this.byteOffset}});function Ge(e){if(e>Kt)throw new RangeError('The value "'+e+'" is invalid for option "size"');var A=new Uint8Array(e);return Object.setPrototypeOf(A,_.prototype),A}function _(e,A,t){if(typeof e=="number"){if(typeof A=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return zr(e)}return Ni(e,A,t)}_.poolSize=8192;function Ni(e,A,t){if(typeof e=="string")return Ea(e,A);if(ArrayBuffer.isView(e))return Qa(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(ge(e,ArrayBuffer)||e&&ge(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ge(e,SharedArrayBuffer)||e&&ge(e.buffer,SharedArrayBuffer)))return Wr(e,A,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return _.from(r,A,t);var n=ha(e);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return _.from(e[Symbol.toPrimitive]("string"),A,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}_.from=function(e,A,t){return Ni(e,A,t)};Object.setPrototypeOf(_.prototype,Uint8Array.prototype);Object.setPrototypeOf(_,Uint8Array);function Fi(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function ua(e,A,t){return Fi(e),e<=0?Ge(e):A!==void 0?typeof t=="string"?Ge(e).fill(A,t):Ge(e).fill(A):Ge(e)}_.alloc=function(e,A,t){return ua(e,A,t)};function zr(e){return Fi(e),Ge(e<0?0:Dr(e)|0)}_.allocUnsafe=function(e){return zr(e)};_.allocUnsafeSlow=function(e){return zr(e)};function Ea(e,A){if((typeof A!="string"||A==="")&&(A="utf8"),!_.isEncoding(A))throw new TypeError("Unknown encoding: "+A);var t=Si(e,A)|0,r=Ge(t),n=r.write(e,A);return n!==t&&(r=r.slice(0,n)),r}function Kr(e){for(var A=e.length<0?0:Dr(e.length)|0,t=Ge(A),r=0;r<A;r+=1)t[r]=e[r]&255;return t}function Qa(e){if(ge(e,Uint8Array)){var A=new Uint8Array(e);return Wr(A.buffer,A.byteOffset,A.byteLength)}return Kr(e)}function Wr(e,A,t){if(A<0||e.byteLength<A)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<A+(t||0))throw new RangeError('"length" is outside of buffer bounds');var r;return A===void 0&&t===void 0?r=new Uint8Array(e):t===void 0?r=new Uint8Array(e,A):r=new Uint8Array(e,A,t),Object.setPrototypeOf(r,_.prototype),r}function ha(e){if(_.isBuffer(e)){var A=Dr(e.length)|0,t=Ge(A);return t.length===0||e.copy(t,0,0,A),t}if(e.length!==void 0)return typeof e.length!="number"||$r(e.length)?Ge(0):Kr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Kr(e.data)}function Dr(e){if(e>=Kt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Kt.toString(16)+" bytes");return e|0}function la(e){return+e!=e&&(e=0),_.alloc(+e)}_.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==_.prototype};_.compare=function(A,t){if(ge(A,Uint8Array)&&(A=_.from(A,A.offset,A.byteLength)),ge(t,Uint8Array)&&(t=_.from(t,t.offset,t.byteLength)),!_.isBuffer(A)||!_.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===t)return 0;for(var r=A.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(A[i]!==t[i]){r=A[i],n=t[i];break}return r<n?-1:n<r?1:0};_.isEncoding=function(A){switch(String(A).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}};_.concat=function(A,t){if(!Array.isArray(A))throw new TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return _.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<A.length;++r)t+=A[r].length;var n=_.allocUnsafe(t),i=0;for(r=0;r<A.length;++r){var s=A[r];if(ge(s,Uint8Array))i+s.length>n.length?_.from(s).copy(n,i):Uint8Array.prototype.set.call(n,s,i);else if(_.isBuffer(s))s.copy(n,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return n};function Si(e,A){if(_.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||ge(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var t=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&t===0)return 0;for(var n=!1;;)switch(A){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Xr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Mi(e).length;default:if(n)return r?-1:Xr(e).length;A=(""+A).toLowerCase(),n=!0}}_.byteLength=Si;function fa(e,A,t){var r=!1;if((A===void 0||A<0)&&(A=0),A>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,A>>>=0,t<=A))return"";for(e||(e="utf8");;)switch(e){case"hex":return Na(this,A,t);case"utf8":case"utf-8":return qi(this,A,t);case"ascii":return Ga(this,A,t);case"latin1":case"binary":return ma(this,A,t);case"base64":return ya(this,A,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fa(this,A,t);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}_.prototype._isBuffer=!0;function Oe(e,A,t){var r=e[A];e[A]=e[t],e[t]=r}_.prototype.swap16=function(){var A=this.length;if(A%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<A;t+=2)Oe(this,t,t+1);return this};_.prototype.swap32=function(){var A=this.length;if(A%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<A;t+=4)Oe(this,t,t+3),Oe(this,t+1,t+2);return this};_.prototype.swap64=function(){var A=this.length;if(A%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<A;t+=8)Oe(this,t,t+7),Oe(this,t+1,t+6),Oe(this,t+2,t+5),Oe(this,t+3,t+4);return this};_.prototype.toString=function(){var A=this.length;return A===0?"":arguments.length===0?qi(this,0,A):fa.apply(this,arguments)};_.prototype.toLocaleString=_.prototype.toString;_.prototype.equals=function(A){if(!_.isBuffer(A))throw new TypeError("Argument must be a Buffer");return this===A?!0:_.compare(this,A)===0};_.prototype.inspect=function(){var A="",t=De.INSPECT_MAX_BYTES;return A=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(A+=" ... "),"<Buffer "+A+">"};_i&&(_.prototype[_i]=_.prototype.inspect);_.prototype.compare=function(A,t,r,n,i){if(ge(A,Uint8Array)&&(A=_.from(A,A.offset,A.byteLength)),!_.isBuffer(A))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(t===void 0&&(t=0),r===void 0&&(r=A?A.length:0),n===void 0&&(n=0),i===void 0&&(i=this.length),t<0||r>A.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===A)return 0;for(var s=i-n,c=r-t,a=Math.min(s,c),w=this.slice(n,i),N=A.slice(t,r),S=0;S<a;++S)if(w[S]!==N[S]){s=w[S],c=N[S];break}return s<c?-1:c<s?1:0};function bi(e,A,t,r,n){if(e.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,$r(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof A=="string"&&(A=_.from(A,r)),_.isBuffer(A))return A.length===0?-1:Gi(e,A,t,r,n);if(typeof A=="number")return A=A&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,A,t):Uint8Array.prototype.lastIndexOf.call(e,A,t):Gi(e,[A],t,r,n);throw new TypeError("val must be string, number or Buffer")}function Gi(e,A,t,r,n){var i=1,s=e.length,c=A.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(e.length<2||A.length<2)return-1;i=2,s/=2,c/=2,t/=2}function a(m,R){return i===1?m[R]:m.readUInt16BE(R*i)}var w;if(n){var N=-1;for(w=t;w<s;w++)if(a(e,w)===a(A,N===-1?0:w-N)){if(N===-1&&(N=w),w-N+1===c)return N*i}else N!==-1&&(w-=w-N),N=-1}else for(t+c>s&&(t=s-c),w=t;w>=0;w--){for(var S=!0,k=0;k<c;k++)if(a(e,w+k)!==a(A,k)){S=!1;break}if(S)return w}return-1}_.prototype.includes=function(A,t,r){return this.indexOf(A,t,r)!==-1};_.prototype.indexOf=function(A,t,r){return bi(this,A,t,r,!0)};_.prototype.lastIndexOf=function(A,t,r){return bi(this,A,t,r,!1)};function Ia(e,A,t,r){t=Number(t)||0;var n=e.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;var i=A.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var c=parseInt(A.substr(s*2,2),16);if($r(c))return s;e[t+s]=c}return s}function Ca(e,A,t,r){return Wt(Xr(A,e.length-t),e,t,r)}function da(e,A,t,r){return Wt(qa(A),e,t,r)}function pa(e,A,t,r){return Wt(Mi(A),e,t,r)}function wa(e,A,t,r){return Wt(xa(A,e.length-t),e,t,r)}_.prototype.write=function(A,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(r)?(r=r>>>0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-t;if((r===void 0||r>i)&&(r=i),A.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return Ia(this,A,t,r);case"utf8":case"utf-8":return Ca(this,A,t,r);case"ascii":case"latin1":case"binary":return da(this,A,t,r);case"base64":return pa(this,A,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wa(this,A,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ya(e,A,t){return A===0&&t===e.length?jr.fromByteArray(e):jr.fromByteArray(e.slice(A,t))}function qi(e,A,t){t=Math.min(e.length,t);for(var r=[],n=A;n<t;){var i=e[n],s=null,c=i>239?4:i>223?3:i>191?2:1;if(n+c<=t){var a,w,N,S;switch(c){case 1:i<128&&(s=i);break;case 2:a=e[n+1],(a&192)===128&&(S=(i&31)<<6|a&63,S>127&&(s=S));break;case 3:a=e[n+1],w=e[n+2],(a&192)===128&&(w&192)===128&&(S=(i&15)<<12|(a&63)<<6|w&63,S>2047&&(S<55296||S>57343)&&(s=S));break;case 4:a=e[n+1],w=e[n+2],N=e[n+3],(a&192)===128&&(w&192)===128&&(N&192)===128&&(S=(i&15)<<18|(a&63)<<12|(w&63)<<6|N&63,S>65535&&S<1114112&&(s=S))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),n+=c}return _a(r)}var mi=4096;function _a(e){var A=e.length;if(A<=mi)return String.fromCharCode.apply(String,e);for(var t="",r=0;r<A;)t+=String.fromCharCode.apply(String,e.slice(r,r+=mi));return t}function Ga(e,A,t){var r="";t=Math.min(e.length,t);for(var n=A;n<t;++n)r+=String.fromCharCode(e[n]&127);return r}function ma(e,A,t){var r="";t=Math.min(e.length,t);for(var n=A;n<t;++n)r+=String.fromCharCode(e[n]);return r}function Na(e,A,t){var r=e.length;(!A||A<0)&&(A=0),(!t||t<0||t>r)&&(t=r);for(var n="",i=A;i<t;++i)n+=ka[e[i]];return n}function Fa(e,A,t){for(var r=e.slice(A,t),n="",i=0;i<r.length-1;i+=2)n+=String.fromCharCode(r[i]+r[i+1]*256);return n}_.prototype.slice=function(A,t){var r=this.length;A=~~A,t=t===void 0?r:~~t,A<0?(A+=r,A<0&&(A=0)):A>r&&(A=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<A&&(t=A);var n=this.subarray(A,t);return Object.setPrototypeOf(n,_.prototype),n};function NA(e,A,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+A>t)throw new RangeError("Trying to access beyond buffer length")}_.prototype.readUintLE=_.prototype.readUIntLE=function(A,t,r){A=A>>>0,t=t>>>0,r||NA(A,t,this.length);for(var n=this[A],i=1,s=0;++s<t&&(i*=256);)n+=this[A+s]*i;return n};_.prototype.readUintBE=_.prototype.readUIntBE=function(A,t,r){A=A>>>0,t=t>>>0,r||NA(A,t,this.length);for(var n=this[A+--t],i=1;t>0&&(i*=256);)n+=this[A+--t]*i;return n};_.prototype.readUint8=_.prototype.readUInt8=function(A,t){return A=A>>>0,t||NA(A,1,this.length),this[A]};_.prototype.readUint16LE=_.prototype.readUInt16LE=function(A,t){return A=A>>>0,t||NA(A,2,this.length),this[A]|this[A+1]<<8};_.prototype.readUint16BE=_.prototype.readUInt16BE=function(A,t){return A=A>>>0,t||NA(A,2,this.length),this[A]<<8|this[A+1]};_.prototype.readUint32LE=_.prototype.readUInt32LE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};_.prototype.readUint32BE=_.prototype.readUInt32BE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};_.prototype.readIntLE=function(A,t,r){A=A>>>0,t=t>>>0,r||NA(A,t,this.length);for(var n=this[A],i=1,s=0;++s<t&&(i*=256);)n+=this[A+s]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n};_.prototype.readIntBE=function(A,t,r){A=A>>>0,t=t>>>0,r||NA(A,t,this.length);for(var n=t,i=1,s=this[A+--n];n>0&&(i*=256);)s+=this[A+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s};_.prototype.readInt8=function(A,t){return A=A>>>0,t||NA(A,1,this.length),this[A]&128?(255-this[A]+1)*-1:this[A]};_.prototype.readInt16LE=function(A,t){A=A>>>0,t||NA(A,2,this.length);var r=this[A]|this[A+1]<<8;return r&32768?r|4294901760:r};_.prototype.readInt16BE=function(A,t){A=A>>>0,t||NA(A,2,this.length);var r=this[A+1]|this[A]<<8;return r&32768?r|4294901760:r};_.prototype.readInt32LE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};_.prototype.readInt32BE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};_.prototype.readFloatLE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),ze.read(this,A,!0,23,4)};_.prototype.readFloatBE=function(A,t){return A=A>>>0,t||NA(A,4,this.length),ze.read(this,A,!1,23,4)};_.prototype.readDoubleLE=function(A,t){return A=A>>>0,t||NA(A,8,this.length),ze.read(this,A,!0,52,8)};_.prototype.readDoubleBE=function(A,t){return A=A>>>0,t||NA(A,8,this.length),ze.read(this,A,!1,52,8)};function OA(e,A,t,r,n,i){if(!_.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(A>n||A<i)throw new RangeError('"value" argument is out of bounds');if(t+r>e.length)throw new RangeError("Index out of range")}_.prototype.writeUintLE=_.prototype.writeUIntLE=function(A,t,r,n){if(A=+A,t=t>>>0,r=r>>>0,!n){var i=Math.pow(2,8*r)-1;OA(this,A,t,r,i,0)}var s=1,c=0;for(this[t]=A&255;++c<r&&(s*=256);)this[t+c]=A/s&255;return t+r};_.prototype.writeUintBE=_.prototype.writeUIntBE=function(A,t,r,n){if(A=+A,t=t>>>0,r=r>>>0,!n){var i=Math.pow(2,8*r)-1;OA(this,A,t,r,i,0)}var s=r-1,c=1;for(this[t+s]=A&255;--s>=0&&(c*=256);)this[t+s]=A/c&255;return t+r};_.prototype.writeUint8=_.prototype.writeUInt8=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,1,255,0),this[t]=A&255,t+1};_.prototype.writeUint16LE=_.prototype.writeUInt16LE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,2,65535,0),this[t]=A&255,this[t+1]=A>>>8,t+2};_.prototype.writeUint16BE=_.prototype.writeUInt16BE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,2,65535,0),this[t]=A>>>8,this[t+1]=A&255,t+2};_.prototype.writeUint32LE=_.prototype.writeUInt32LE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,4,4294967295,0),this[t+3]=A>>>24,this[t+2]=A>>>16,this[t+1]=A>>>8,this[t]=A&255,t+4};_.prototype.writeUint32BE=_.prototype.writeUInt32BE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,4,4294967295,0),this[t]=A>>>24,this[t+1]=A>>>16,this[t+2]=A>>>8,this[t+3]=A&255,t+4};_.prototype.writeIntLE=function(A,t,r,n){if(A=+A,t=t>>>0,!n){var i=Math.pow(2,8*r-1);OA(this,A,t,r,i-1,-i)}var s=0,c=1,a=0;for(this[t]=A&255;++s<r&&(c*=256);)A<0&&a===0&&this[t+s-1]!==0&&(a=1),this[t+s]=(A/c>>0)-a&255;return t+r};_.prototype.writeIntBE=function(A,t,r,n){if(A=+A,t=t>>>0,!n){var i=Math.pow(2,8*r-1);OA(this,A,t,r,i-1,-i)}var s=r-1,c=1,a=0;for(this[t+s]=A&255;--s>=0&&(c*=256);)A<0&&a===0&&this[t+s+1]!==0&&(a=1),this[t+s]=(A/c>>0)-a&255;return t+r};_.prototype.writeInt8=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,1,127,-128),A<0&&(A=255+A+1),this[t]=A&255,t+1};_.prototype.writeInt16LE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,2,32767,-32768),this[t]=A&255,this[t+1]=A>>>8,t+2};_.prototype.writeInt16BE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,2,32767,-32768),this[t]=A>>>8,this[t+1]=A&255,t+2};_.prototype.writeInt32LE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,4,2147483647,-2147483648),this[t]=A&255,this[t+1]=A>>>8,this[t+2]=A>>>16,this[t+3]=A>>>24,t+4};_.prototype.writeInt32BE=function(A,t,r){return A=+A,t=t>>>0,r||OA(this,A,t,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),this[t]=A>>>24,this[t+1]=A>>>16,this[t+2]=A>>>8,this[t+3]=A&255,t+4};function xi(e,A,t,r,n,i){if(t+r>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ki(e,A,t,r,n){return A=+A,t=t>>>0,n||xi(e,A,t,4,34028234663852886e22,-34028234663852886e22),ze.write(e,A,t,r,23,4),t+4}_.prototype.writeFloatLE=function(A,t,r){return ki(this,A,t,!0,r)};_.prototype.writeFloatBE=function(A,t,r){return ki(this,A,t,!1,r)};function Ri(e,A,t,r,n){return A=+A,t=t>>>0,n||xi(e,A,t,8,17976931348623157e292,-17976931348623157e292),ze.write(e,A,t,r,52,8),t+8}_.prototype.writeDoubleLE=function(A,t,r){return Ri(this,A,t,!0,r)};_.prototype.writeDoubleBE=function(A,t,r){return Ri(this,A,t,!1,r)};_.prototype.copy=function(A,t,r,n){if(!_.isBuffer(A))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&n!==0&&(n=this.length),t>=A.length&&(t=A.length),t||(t=0),n>0&&n<r&&(n=r),n===r||A.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),A.length-t<n-r&&(n=A.length-t+r);var i=n-r;return this===A&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(A,this.subarray(r,n),t),i};_.prototype.fill=function(A,t,r,n){if(typeof A=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!_.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(A.length===1){var i=A.charCodeAt(0);(n==="utf8"&&i<128||n==="latin1")&&(A=i)}}else typeof A=="number"?A=A&255:typeof A=="boolean"&&(A=Number(A));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,A||(A=0);var s;if(typeof A=="number")for(s=t;s<r;++s)this[s]=A;else{var c=_.isBuffer(A)?A:_.from(A,n),a=c.length;if(a===0)throw new TypeError('The value "'+A+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=c[s%a]}return this};var Sa=/[^+/0-9A-Za-z-_]/g;function ba(e){if(e=e.split("=")[0],e=e.trim().replace(Sa,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Xr(e,A){A=A||1/0;for(var t,r=e.length,n=null,i=[],s=0;s<r;++s){if(t=e.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(A-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(A-=3)>-1&&i.push(239,191,189);continue}n=t;continue}if(t<56320){(A-=3)>-1&&i.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(A-=3)>-1&&i.push(239,191,189);if(n=null,t<128){if((A-=1)<0)break;i.push(t)}else if(t<2048){if((A-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((A-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((A-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function qa(e){for(var A=[],t=0;t<e.length;++t)A.push(e.charCodeAt(t)&255);return A}function xa(e,A){for(var t,r,n,i=[],s=0;s<e.length&&!((A-=2)<0);++s)t=e.charCodeAt(s),r=t>>8,n=t%256,i.push(n),i.push(r);return i}function Mi(e){return jr.toByteArray(ba(e))}function Wt(e,A,t,r){for(var n=0;n<r&&!(n+t>=A.length||n>=e.length);++n)A[n+t]=e[n];return n}function ge(e,A){return e instanceof A||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===A.name}function $r(e){return e!==e}var ka=function(){for(var e="0123456789abcdef",A=new Array(256),t=0;t<16;++t)for(var r=t*16,n=0;n<16;++n)A[r+n]=e[t]+e[n];return A}()});var vi=T(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.ReplicaRejectCode=void 0;var Ra;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(Ra=wt.ReplicaRejectCode||(wt.ReplicaRejectCode={}))});var Ui=T(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.decode=Le.encode=void 0;var Xt="abcdefghijklmnopqrstuvwxyz234567",$e=Object.create(null);for(let e=0;e<Xt.length;e++)$e[Xt[e]]=e;$e[0]=$e.o;$e[1]=$e.i;function Ma(e){let A=0,t=0,r="";function n(i){return A<0?t|=i>>-A:t=i<<A&248,A>3?(A-=8,1):(A<4&&(r+=Xt[t>>3],A+=5),0)}for(let i=0;i<e.length;)i+=n(e[i]);return r+(A<0?Xt[t>>3]:"")}Le.encode=Ma;function Ha(e){let A=0,t=0,r=new Uint8Array(e.length*4/3|0),n=0;function i(s){let c=$e[s.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(s)}`);c<<=3,t|=c>>>A,A+=5,A>=8&&(r[n++]=t,A-=8,A>0?t=c<<5-A&255:t=0)}for(let s of e)i(s);return r.slice(0,n)}Le.decode=Ha});var Ti=T(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.getCrc32=void 0;var va=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function Ua(e){let A=new Uint8Array(e),t=-1;for(let r=0;r<A.length;r++){let i=(A[r]^t)&255;t=va[i]^t>>>8}return(t^-1)>>>0}zt.getCrc32=Ua});var Lr=T((exports,module)=>{(function(){"use strict";var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;NODE_JS?root=global:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,AMD=typeof define=="function"&&define.amd,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[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],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e,A){return function(t){return new Sha256(A,!0).update(t)[e]()}},createMethod=function(e){var A=createOutputMethod("hex",e);NODE_JS&&(A=nodeWrap(A,e)),A.create=function(){return new Sha256(e)},A.update=function(n){return A.create().update(n)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];A[r]=createOutputMethod(r,e)}return A},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(e){if(typeof e=="string")return crypto.createHash(algorithm).update(e,"utf8").digest("hex");if(e==null)throw new Error(ERROR);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(e)).digest("hex"):method(e)};return nodeMethod},createHmacOutputMethod=function(e,A){return function(t,r){return new HmacSha256(t,A,!0).update(r)[e]()}},createHmacMethod=function(e){var A=createHmacOutputMethod("hex",e);A.create=function(n){return new HmacSha256(n,e)},A.update=function(n,i){return A.create(n).update(i)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];A[r]=createHmacOutputMethod(r,e)}return A};function Sha256(e,A){A?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}Sha256.prototype.update=function(e){if(!this.finalized){var A,t=typeof e;if(t!=="string"){if(t==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);A=!0}for(var r,n=0,i,s=e.length,c=this.blocks;n<s;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),A)for(i=this.start;n<s&&i<64;++n)c[i>>2]|=e[n]<<SHIFT[i++&3];else for(i=this.start;n<s&&i<64;++n)r=e.charCodeAt(n),r<128?c[i>>2]|=r<<SHIFT[i++&3]:r<2048?(c[i>>2]|=(192|r>>6)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]):r<55296||r>=57344?(c[i>>2]|=(224|r>>12)<<SHIFT[i++&3],c[i>>2]|=(128|r>>6&63)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++n)&1023),c[i>>2]|=(240|r>>18)<<SHIFT[i++&3],c[i>>2]|=(128|r>>12&63)<<SHIFT[i++&3],c[i>>2]|=(128|r>>6&63)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=c[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,A=this.lastByteIndex;e[16]=this.block,e[A>>2]|=EXTRA[A&3],this.block=e[16],A>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var e=this.h0,A=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=this.blocks,w,N,S,k,m,R,J,$,O,eA,L;for(w=16;w<64;++w)m=a[w-15],N=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=a[w-2],S=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,a[w]=a[w-16]+N+a[w-7]+S<<0;for(L=A&t,w=0;w<64;w+=4)this.first?(this.is224?($=300032,m=a[0]-1413257819,c=m-150054599<<0,r=m+24177077<<0):($=704751109,m=a[0]-210244248,c=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(N=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),S=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),$=e&A,k=$^e&t^L,J=n&i^~n&s,m=c+S+J+K[w]+a[w],R=N+k,c=r+m<<0,r=m+R<<0),N=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),S=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),O=r&e,k=O^r&A^$,J=c&n^~c&i,m=s+S+J+K[w+1]+a[w+1],R=N+k,s=t+m<<0,t=m+R<<0,N=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),S=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),eA=t&r,k=eA^t&e^O,J=s&c^~s&n,m=i+S+J+K[w+2]+a[w+2],R=N+k,i=A+m<<0,A=m+R<<0,N=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),S=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),L=A&t,k=L^A&r^eA,J=i&s^~i&c,m=n+S+J+K[w+3]+a[w+3],R=N+k,n=e+m<<0,e=m+R<<0;this.h0=this.h0+e<<0,this.h1=this.h1+A<<0,this.h2=this.h2+t<<0,this.h3=this.h3+r<<0,this.h4=this.h4+n<<0,this.h5=this.h5+i<<0,this.h6=this.h6+s<<0,this.h7=this.h7+c<<0},Sha256.prototype.hex=function(){this.finalize();var e=this.h0,A=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[A>>28&15]+HEX_CHARS[A>>24&15]+HEX_CHARS[A>>20&15]+HEX_CHARS[A>>16&15]+HEX_CHARS[A>>12&15]+HEX_CHARS[A>>8&15]+HEX_CHARS[A>>4&15]+HEX_CHARS[A&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15];return this.is224||(a+=HEX_CHARS[c>>28&15]+HEX_CHARS[c>>24&15]+HEX_CHARS[c>>20&15]+HEX_CHARS[c>>16&15]+HEX_CHARS[c>>12&15]+HEX_CHARS[c>>8&15]+HEX_CHARS[c>>4&15]+HEX_CHARS[c&15]),a},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var e=this.h0,A=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=[e>>24&255,e>>16&255,e>>8&255,e&255,A>>24&255,A>>16&255,A>>8&255,A&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,n>>24&255,n>>16&255,n>>8&255,n&255,i>>24&255,i>>16&255,i>>8&255,i&255,s>>24&255,s>>16&255,s>>8&255,s&255];return this.is224||a.push(c>>24&255,c>>16&255,c>>8&255,c&255),a},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),A=new DataView(e);return A.setUint32(0,this.h0),A.setUint32(4,this.h1),A.setUint32(8,this.h2),A.setUint32(12,this.h3),A.setUint32(16,this.h4),A.setUint32(20,this.h5),A.setUint32(24,this.h6),this.is224||A.setUint32(28,this.h7),e};function HmacSha256(e,A,t){var r,n=typeof e;if(n==="string"){var i=[],s=e.length,c=0,a;for(r=0;r<s;++r)a=e.charCodeAt(r),a<128?i[c++]=a:a<2048?(i[c++]=192|a>>6,i[c++]=128|a&63):a<55296||a>=57344?(i[c++]=224|a>>12,i[c++]=128|a>>6&63,i[c++]=128|a&63):(a=65536+((a&1023)<<10|e.charCodeAt(++r)&1023),i[c++]=240|a>>18,i[c++]=128|a>>12&63,i[c++]=128|a>>6&63,i[c++]=128|a&63);e=i}else if(n==="object"){if(e===null)throw new Error(ERROR);if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw new Error(ERROR)}else throw new Error(ERROR);e.length>64&&(e=new Sha256(A,!0).update(e).array());var w=[],N=[];for(r=0;r<64;++r){var S=e[r]||0;w[r]=92^S,N[r]=54^S}Sha256.call(this,A,t),this.update(N),this.oKeyPad=w,this.inner=!0,this.sharedMemory=t}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224,AMD&&define(function(){return exports}))})()});var Yi=T(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.sha224=void 0;var Ta=Lr();function Ya(e){let A=Ta.sha224.create();return A.update(e),new Uint8Array(A.array())}Dt.sha224=Ya});var ue=T($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.Principal=void 0;var Oi=Ui(),Oa=Ti(),Ja=Yi(),Pa=2,Ji=4,Za="aaaaa-aa",Va=e=>{var A;return new Uint8Array(((A=e.match(/.{1,2}/g))!==null&&A!==void 0?A:[]).map(t=>parseInt(t,16)))},ja=e=>e.reduce((A,t)=>A+t.toString(16).padStart(2,"0"),""),At=class{constructor(A){this._arr=A,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Ji]))}static managementCanister(){return this.fromHex(Za)}static selfAuthenticating(A){let t=(0,Ja.sha224)(A);return new this(new Uint8Array([...t,Pa]))}static from(A){if(typeof A=="string")return At.fromText(A);if(typeof A=="object"&&A!==null&&A._isPrincipal===!0)return new At(A._arr);throw new Error(`Impossible to convert ${JSON.stringify(A)} to Principal.`)}static fromHex(A){return new this(Va(A))}static fromText(A){let t=A.toLowerCase().replace(/-/g,""),r=(0,Oi.decode)(t);r=r.slice(4,r.length);let n=new this(r);if(n.toText()!==A)throw new Error(`Principal "${n.toText()}" does not have a valid checksum (original value "${A}" may not be a valid Principal ID).`);return n}static fromUint8Array(A){return new this(A)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Ji}toUint8Array(){return this._arr}toHex(){return ja(this._arr).toUpperCase()}toText(){let A=new ArrayBuffer(4);new DataView(A).setUint32(0,(0,Oa.getCrc32)(this._arr));let r=new Uint8Array(A),n=Uint8Array.from(this._arr),i=new Uint8Array([...r,...n]),c=(0,Oi.encode)(i).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}compareTo(A){for(let t=0;t<Math.min(this._arr.length,A._arr.length);t++){if(this._arr[t]<A._arr[t])return"lt";if(this._arr[t]>A._arr[t])return"gt"}return this._arr.length<A._arr.length?"lt":this._arr.length>A._arr.length?"gt":"eq"}ltEq(A){let t=this.compareTo(A);return t=="lt"||t=="eq"}gtEq(A){let t=this.compareTo(A);return t=="gt"||t=="eq"}};$t.Principal=At});var Ar=T(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.AgentError=void 0;var yt=class extends Error{constructor(A){super(A),this.message=A,Object.setPrototypeOf(this,yt.prototype)}};Lt.AgentError=yt});var er=T(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.PipeArrayBuffer=Ee.fromHexString=Ee.toHexString=Ee.concat=void 0;function Ka(...e){let A=new Uint8Array(e.reduce((r,n)=>r+n.byteLength,0)),t=0;for(let r of e)A.set(new Uint8Array(r),t),t+=r.byteLength;return A}Ee.concat=Ka;function Wa(e){return new Uint8Array(e).reduce((A,t)=>A+t.toString(16).padStart(2,"0"),"")}Ee.toHexString=Wa;function Xa(e){var A;return new Uint8Array(((A=e.match(/.{1,2}/g))!==null&&A!==void 0?A:[]).map(t=>parseInt(t,16)))}Ee.fromHexString=Xa;var An=class{constructor(A,t=(A==null?void 0:A.byteLength)||0){this._buffer=A||new ArrayBuffer(0),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return this._view.slice()}get byteLength(){return this._view.byteLength}read(A){let t=this._view.subarray(0,A);return this._view=this._view.subarray(A),t.slice().buffer}readUint8(){let A=this._view[0];return this._view=this._view.subarray(1),A}write(A){let t=new Uint8Array(A),r=this._view.byteLength;this._view.byteOffset+this._view.byteLength+t.byteLength>=this._buffer.byteLength?this.alloc(t.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+t.byteLength),this._view.set(t,r)}get end(){return this._view.byteLength===0}alloc(A){let t=new ArrayBuffer((this._buffer.byteLength+A)*1.2|0),r=new Uint8Array(t,0,this._view.byteLength+A);r.set(this._view),this._buffer=t,this._view=r}};Ee.PipeArrayBuffer=An});var en=T(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.idlLabelToId=void 0;function za(e){let t=new TextEncoder().encode(e),r=0;for(let n of t)r=(r*223+n)%2**32;return r}function Da(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let A=+e.slice(1,-1);if(Number.isSafeInteger(A)&&A>=0&&A<2**32)return A}return za(e)}tr.idlLabelToId=Da});var rn=T(CA=>{"use strict";Object.defineProperty(CA,"__esModule",{value:!0});CA.readIntLE=CA.readUIntLE=CA.writeIntLE=CA.writeUIntLE=CA.slebDecode=CA.slebEncode=CA.lebDecode=CA.lebEncode=CA.safeReadUint8=CA.safeRead=void 0;var tn=er();function Pi(){throw new Error("unexpected end of buffer")}function Zi(e,A){return e.byteLength<A&&Pi(),e.read(A)}CA.safeRead=Zi;function rr(e){let A=e.readUint8();return A===void 0&&Pi(),A}CA.safeReadUint8=rr;function $a(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let A=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,t=new tn.PipeArrayBuffer(new ArrayBuffer(A),0);for(;;){let r=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){t.write(new Uint8Array([r]));break}else t.write(new Uint8Array([r|128]))}return t.buffer}CA.lebEncode=$a;function Vi(e){let A=BigInt(1),t=BigInt(0),r;do r=rr(e),t+=BigInt(r&127).valueOf()*A,A*=BigInt(128);while(r>=128);return t}CA.lebDecode=Vi;function La(e){typeof e=="number"&&(e=BigInt(e));let A=e<BigInt(0);A&&(e=-e-BigInt(1));let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new tn.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let i=n(e);if(e/=BigInt(128),A&&e===BigInt(0)&&(i&64)!==0||!A&&e===BigInt(0)&&(i&64)===0){r.write(new Uint8Array([i]));break}else r.write(new Uint8Array([i|128]))}function n(i){let s=i%BigInt(128);return Number(A?BigInt(128)-s-BigInt(1):s)}return r.buffer}CA.slebEncode=La;function Ac(e){let A=new Uint8Array(e.buffer),t=0;for(;t<A.byteLength;t++)if(A[t]<128){if((A[t]&64)===0)return Vi(e);break}let r=new Uint8Array(Zi(e,t+1)),n=BigInt(0);for(let i=r.byteLength-1;i>=0;i--)n=n*BigInt(128)+BigInt(128-(r[i]&127)-1);return-n-BigInt(1)}CA.slebDecode=Ac;function ec(e,A){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return ji(e,A)}CA.writeUIntLE=ec;function ji(e,A){e=BigInt(e);let t=new tn.PipeArrayBuffer(new ArrayBuffer(Math.min(1,A)),0),r=0,n=BigInt(256),i=BigInt(0),s=Number(e%n);for(t.write(new Uint8Array([s]));++r<A;)e<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((e/n-i)%BigInt(256)),t.write(new Uint8Array([s])),n*=BigInt(256);return t.buffer}CA.writeIntLE=ji;function Ki(e,A){let t=BigInt(rr(e)),r=BigInt(1),n=0;for(;++n<A;){r*=BigInt(256);let i=BigInt(rr(e));t=t+r*i}return t}CA.readUIntLE=Ki;function tc(e,A){let t=Ki(e,A),r=BigInt(2)**(BigInt(8)*BigInt(A-1)+BigInt(7));return t>=r&&(t-=r*BigInt(2)),t}CA.readIntLE=tc});var an=T(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.Variant=y.Record=y.Opt=y.Vec=y.Tuple=y.Principal=y.Nat64=y.Nat32=y.Nat16=y.Nat8=y.Int64=y.Int32=y.Int16=y.Int8=y.Float64=y.Float32=y.Nat=y.Int=y.Text=y.Null=y.Bool=y.Unknown=y.Reserved=y.Empty=y.decode=y.encode=y.ServiceClass=y.FuncClass=y.PrincipalClass=y.RecClass=y.VariantClass=y.TupleClass=y.RecordClass=y.OptClass=y.VecClass=y.FixedNatClass=y.FixedIntClass=y.FloatClass=y.NatClass=y.IntClass=y.TextClass=y.ReservedClass=y.NullClass=y.BoolClass=y.UnknownClass=y.EmptyClass=y.ConstructType=y.PrimitiveType=y.Type=y.Visitor=void 0;y.Service=y.Func=y.Rec=void 0;var rc=ue(),AA=er(),zA=en(),x=rn(),nr="DIDL";function _t(e,A,t){return e.map((r,n)=>t(r,A[n]))}var nn=class{constructor(){this._typs=[],this._idx=new Map}has(A){return this._idx.has(A.name)}add(A,t){let r=this._typs.length;this._idx.set(A.name,r),this._typs.push(t)}merge(A,t){let r=this._idx.get(A.name),n=this._idx.get(t);if(r===void 0)throw new Error("Missing type index for "+A);if(n===void 0)throw new Error("Missing type index for "+t);this._typs[r]=this._typs[n],this._typs.splice(n,1),this._idx.delete(t)}encode(){let A=(0,x.lebEncode)(this._typs.length),t=(0,AA.concat)(...this._typs);return(0,AA.concat)(A,t)}indexOf(A){if(!this._idx.has(A))throw new Error("Missing type index for "+A);return(0,x.slebEncode)(this._idx.get(A)||0)}},sn=class{visitType(A,t){throw new Error("Not implemented")}visitPrimitive(A,t){return this.visitType(A,t)}visitEmpty(A,t){return this.visitPrimitive(A,t)}visitBool(A,t){return this.visitPrimitive(A,t)}visitNull(A,t){return this.visitPrimitive(A,t)}visitReserved(A,t){return this.visitPrimitive(A,t)}visitText(A,t){return this.visitPrimitive(A,t)}visitNumber(A,t){return this.visitPrimitive(A,t)}visitInt(A,t){return this.visitNumber(A,t)}visitNat(A,t){return this.visitNumber(A,t)}visitFloat(A,t){return this.visitPrimitive(A,t)}visitFixedInt(A,t){return this.visitNumber(A,t)}visitFixedNat(A,t){return this.visitNumber(A,t)}visitPrincipal(A,t){return this.visitPrimitive(A,t)}visitConstruct(A,t){return this.visitType(A,t)}visitVec(A,t,r){return this.visitConstruct(A,r)}visitOpt(A,t,r){return this.visitConstruct(A,r)}visitRecord(A,t,r){return this.visitConstruct(A,r)}visitTuple(A,t,r){let n=t.map((i,s)=>[`_${s}_`,i]);return this.visitRecord(A,n,r)}visitVariant(A,t,r){return this.visitConstruct(A,r)}visitRec(A,t,r){return this.visitConstruct(t,r)}visitFunc(A,t){return this.visitConstruct(A,t)}visitService(A,t){return this.visitConstruct(A,t)}};y.Visitor=sn;var et=class{display(){return this.name}valueToString(A){return Wi(A)}buildTypeTable(A){A.has(this)||this._buildTypeTableImpl(A)}};y.Type=et;var JA=class extends et{checkType(A){if(this.name!==A.name)throw new Error(`type mismatch: type on the wire ${A.name}, expect type ${this.name}`);return A}_buildTypeTableImpl(A){}};y.PrimitiveType=JA;var he=class extends et{checkType(A){if(A instanceof le){let t=A.getType();if(typeof t>"u")throw new Error("type mismatch with uninitialized type");return t}throw new Error(`type mismatch: type on the wire ${A.name}, expect type ${this.name}`)}encodeType(A){return A.indexOf(this.name)}};y.ConstructType=he;var ir=class extends JA{accept(A,t){return A.visitEmpty(this,t)}covariant(A){return!1}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,x.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};y.EmptyClass=ir;var sr=class extends et{checkType(A){throw new Error("Method not implemented for unknown.")}accept(A,t){throw A.visitType(this,t)}covariant(A){return!1}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(A,t){let r=t.decodeValue(A,t);Object(r)!==r&&(r=Object(r));let n;return t instanceof le?n=()=>t.getType():n=()=>t,Object.defineProperty(r,"type",{value:n,writable:!0,enumerable:!1,configurable:!0}),r}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};y.UnknownClass=sr;var or=class extends JA{accept(A,t){return A.visitBool(this,t)}covariant(A){return typeof A=="boolean"}encodeValue(A){return new Uint8Array([A?1:0])}encodeType(){return(0,x.slebEncode)(-2)}decodeValue(A,t){switch(this.checkType(t),(0,x.safeReadUint8)(A)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};y.BoolClass=or;var ar=class extends JA{accept(A,t){return A.visitNull(this,t)}covariant(A){return A===null}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,x.slebEncode)(-1)}decodeValue(A,t){return this.checkType(t),null}get name(){return"null"}};y.NullClass=ar;var tt=class extends JA{accept(A,t){return A.visitReserved(this,t)}covariant(A){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,x.slebEncode)(-16)}decodeValue(A,t){return t.name!==this.name&&t.decodeValue(A,t),null}get name(){return"reserved"}};y.ReservedClass=tt;var cr=class extends JA{accept(A,t){return A.visitText(this,t)}covariant(A){return typeof A=="string"}encodeValue(A){let t=new TextEncoder().encode(A),r=(0,x.lebEncode)(t.byteLength);return(0,AA.concat)(r,t)}encodeType(){return(0,x.slebEncode)(-15)}decodeValue(A,t){this.checkType(t);let r=(0,x.lebDecode)(A),n=(0,x.safeRead)(A,Number(r));return new TextDecoder("utf8",{fatal:!0}).decode(n)}get name(){return"text"}valueToString(A){return'"'+A+'"'}};y.TextClass=cr;var Br=class extends JA{accept(A,t){return A.visitInt(this,t)}covariant(A){return typeof A=="bigint"||Number.isInteger(A)}encodeValue(A){return(0,x.slebEncode)(A)}encodeType(){return(0,x.slebEncode)(-4)}decodeValue(A,t){return this.checkType(t),(0,x.slebDecode)(A)}get name(){return"int"}valueToString(A){return A.toString()}};y.IntClass=Br;var gr=class extends JA{accept(A,t){return A.visitNat(this,t)}covariant(A){return typeof A=="bigint"&&A>=BigInt(0)||Number.isInteger(A)&&A>=0}encodeValue(A){return(0,x.lebEncode)(A)}encodeType(){return(0,x.slebEncode)(-3)}decodeValue(A,t){return this.checkType(t),(0,x.lebDecode)(A)}get name(){return"nat"}valueToString(A){return A.toString()}};y.NatClass=gr;var Gt=class extends JA{constructor(A){if(super(),this._bits=A,A!==32&&A!==64)throw new Error("not a valid float type")}accept(A,t){return A.visitFloat(this,t)}covariant(A){return typeof A=="number"||A instanceof Number}encodeValue(A){let t=new ArrayBuffer(this._bits/8),r=new DataView(t);return this._bits===32?r.setFloat32(0,A,!0):r.setFloat64(0,A,!0),t}encodeType(){let A=this._bits===32?-13:-14;return(0,x.slebEncode)(A)}decodeValue(A,t){this.checkType(t);let r=(0,x.safeRead)(A,this._bits/8),n=new DataView(r);return this._bits===32?n.getFloat32(0,!0):n.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(A){return A.toString()}};y.FloatClass=Gt;var me=class extends JA{constructor(A){super(),this._bits=A}accept(A,t){return A.visitFixedInt(this,t)}covariant(A){let t=BigInt(2)**BigInt(this._bits-1)*BigInt(-1),r=BigInt(2)**BigInt(this._bits-1)-BigInt(1);if(typeof A=="bigint")return A>=t&&A<=r;if(Number.isInteger(A)){let n=BigInt(A);return n>=t&&n<=r}else return!1}encodeValue(A){return(0,x.writeIntLE)(A,this._bits/8)}encodeType(){let A=Math.log2(this._bits)-3;return(0,x.slebEncode)(-9-A)}decodeValue(A,t){this.checkType(t);let r=(0,x.readIntLE)(A,this._bits/8);return this._bits<=32?Number(r):r}get name(){return`int${this._bits}`}valueToString(A){return A.toString()}};y.FixedIntClass=me;var Qe=class extends JA{constructor(A){super(),this._bits=A}accept(A,t){return A.visitFixedNat(this,t)}covariant(A){let t=BigInt(2)**BigInt(this._bits);return typeof A=="bigint"&&A>=BigInt(0)?A<t:Number.isInteger(A)&&A>=0?BigInt(A)<t:!1}encodeValue(A){return(0,x.writeUIntLE)(A,this._bits/8)}encodeType(){let A=Math.log2(this._bits)-3;return(0,x.slebEncode)(-5-A)}decodeValue(A,t){this.checkType(t);let r=(0,x.readUIntLE)(A,this._bits/8);return this._bits<=32?Number(r):r}get name(){return`nat${this._bits}`}valueToString(A){return A.toString()}};y.FixedNatClass=Qe;var rt=class extends he{constructor(A){super(),this._type=A,this._blobOptimization=!1,A instanceof Qe&&A._bits===8&&(this._blobOptimization=!0)}accept(A,t){return A.visitVec(this,this._type,t)}covariant(A){let t=this._type instanceof Qe?this._type._bits:this._type instanceof me?this._type._bits:0;return ArrayBuffer.isView(A)&&t==A.BYTES_PER_ELEMENT*8||Array.isArray(A)&&A.every(r=>this._type.covariant(r))}encodeValue(A){let t=(0,x.lebEncode)(A.length);if(this._blobOptimization)return(0,AA.concat)(t,new Uint8Array(A));if(ArrayBuffer.isView(A))return(0,AA.concat)(t,new Uint8Array(A.buffer));let r=new AA.PipeArrayBuffer(new ArrayBuffer(t.byteLength+A.length),0);r.write(t);for(let n of A){let i=this._type.encodeValue(n);r.write(new Uint8Array(i))}return r.buffer}_buildTypeTableImpl(A){this._type.buildTypeTable(A);let t=(0,x.slebEncode)(-19),r=this._type.encodeType(A);A.add(this,(0,AA.concat)(t,r))}decodeValue(A,t){let r=this.checkType(t);if(!(r instanceof rt))throw new Error("Not a vector type");let n=Number((0,x.lebDecode)(A));if(this._type instanceof Qe){if(this._type._bits==8)return new Uint8Array(A.read(n));if(this._type._bits==16)return new Uint16Array(A.read(n*2));if(this._type._bits==32)return new Uint32Array(A.read(n*4));if(this._type._bits==64)return new BigUint64Array(A.read(n*8))}if(this._type instanceof me){if(this._type._bits==8)return new Int8Array(A.read(n));if(this._type._bits==16)return new Int16Array(A.read(n*2));if(this._type._bits==32)return new Int32Array(A.read(n*4));if(this._type._bits==64)return new BigInt64Array(A.read(n*8))}let i=[];for(let s=0;s<n;s++)i.push(this._type.decodeValue(A,r._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(A){let t=A.map(r=>this._type.valueToString(r));return"vec {"+t.join("; ")+"}"}};y.VecClass=rt;var qe=class extends he{constructor(A){super(),this._type=A}accept(A,t){return A.visitOpt(this,this._type,t)}covariant(A){return Array.isArray(A)&&(A.length===0||A.length===1&&this._type.covariant(A[0]))}encodeValue(A){return A.length===0?new Uint8Array([0]):(0,AA.concat)(new Uint8Array([1]),this._type.encodeValue(A[0]))}_buildTypeTableImpl(A){this._type.buildTypeTable(A);let t=(0,x.slebEncode)(-18),r=this._type.encodeType(A);A.add(this,(0,AA.concat)(t,r))}decodeValue(A,t){let r=this.checkType(t);if(!(r instanceof qe))throw new Error("Not an option type");switch((0,x.safeReadUint8)(A)){case 0:return[];case 1:return[this._type.decodeValue(A,r._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(A){return A.length===0?"null":`opt ${this._type.valueToString(A[0])}`}};y.OptClass=qe;var Je=class extends he{constructor(A={}){super(),this._fields=Object.entries(A).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(A,t){return A.visitRecord(this,this._fields,t)}tryAsTuple(){let A=[];for(let t=0;t<this._fields.length;t++){let[r,n]=this._fields[t];if(r!==`_${t}_`)return null;A.push(n)}return A}covariant(A){return typeof A=="object"&&this._fields.every(([t,r])=>{if(!A.hasOwnProperty(t))throw new Error(`Record is missing key "${t}".`);return r.covariant(A[t])})}encodeValue(A){let t=this._fields.map(([n])=>A[n]),r=_t(this._fields,t,([,n],i)=>n.encodeValue(i));return(0,AA.concat)(...r)}_buildTypeTableImpl(A){this._fields.forEach(([i,s])=>s.buildTypeTable(A));let t=(0,x.slebEncode)(-20),r=(0,x.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>(0,AA.concat)((0,x.lebEncode)((0,zA.idlLabelToId)(i)),s.encodeType(A)));A.add(this,(0,AA.concat)(t,r,(0,AA.concat)(...n)))}decodeValue(A,t){let r=this.checkType(t);if(!(r instanceof Je))throw new Error("Not a record type");let n={},i=0,s=0;for(;s<r._fields.length;){let[c,a]=r._fields[s];if(i>=this._fields.length){a.decodeValue(A,a),s++;continue}let[w,N]=this._fields[i];if((0,zA.idlLabelToId)(this._fields[i][0])!==(0,zA.idlLabelToId)(c)){if(N instanceof qe||N instanceof tt){n[w]=[],i++;continue}a.decodeValue(A,a),s++;continue}n[w]=N.decodeValue(A,a),i++,s++}for(let[c,a]of this._fields.slice(i))if(a instanceof qe||a instanceof tt)n[c]=[];else throw new Error("Cannot find required field "+c);return n}get name(){return`record {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}display(){return`record {${this._fields.map(([t,r])=>t+":"+r.display()).join("; ")}}`}valueToString(A){let t=this._fields.map(([n])=>A[n]);return`record {${_t(this._fields,t,([n,i],s)=>n+"="+i.valueToString(s)).join("; ")}}`}};y.RecordClass=Je;var nt=class extends Je{constructor(A){let t={};A.forEach((r,n)=>t["_"+n+"_"]=r),super(t),this._components=A}accept(A,t){return A.visitTuple(this,this._components,t)}covariant(A){return Array.isArray(A)&&A.length>=this._fields.length&&this._components.every((t,r)=>t.covariant(A[r]))}encodeValue(A){let t=_t(this._components,A,(r,n)=>r.encodeValue(n));return(0,AA.concat)(...t)}decodeValue(A,t){let r=this.checkType(t);if(!(r instanceof nt))throw new Error("not a tuple type");if(r._components.length<this._components.length)throw new Error("tuple mismatch");let n=[];for(let[i,s]of r._components.entries())i>=this._components.length?s.decodeValue(A,s):n.push(this._components[i].decodeValue(A,s));return n}display(){return`record {${this._components.map(t=>t.display()).join("; ")}}`}valueToString(A){return`record {${_t(this._components,A,(r,n)=>r.valueToString(n)).join("; ")}}`}};y.TupleClass=nt;var it=class extends he{constructor(A={}){super(),this._fields=Object.entries(A).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(A,t){return A.visitVariant(this,this._fields,t)}covariant(A){return typeof A=="object"&&Object.entries(A).length===1&&this._fields.every(([t,r])=>!A.hasOwnProperty(t)||r.covariant(A[t]))}encodeValue(A){for(let t=0;t<this._fields.length;t++){let[r,n]=this._fields[t];if(A.hasOwnProperty(r)){let i=(0,x.lebEncode)(t),s=n.encodeValue(A[r]);return(0,AA.concat)(i,s)}}throw Error("Variant has no data: "+A)}_buildTypeTableImpl(A){this._fields.forEach(([,i])=>{i.buildTypeTable(A)});let t=(0,x.slebEncode)(-21),r=(0,x.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>(0,AA.concat)((0,x.lebEncode)((0,zA.idlLabelToId)(i)),s.encodeType(A)));A.add(this,(0,AA.concat)(t,r,...n))}decodeValue(A,t){let r=this.checkType(t);if(!(r instanceof it))throw new Error("Not a variant type");let n=Number((0,x.lebDecode)(A));if(n>=r._fields.length)throw Error("Invalid variant index: "+n);let[i,s]=r._fields[n];for(let[c,a]of this._fields)if((0,zA.idlLabelToId)(i)===(0,zA.idlLabelToId)(c)){let w=a.decodeValue(A,s);return{[c]:w}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}display(){return`variant {${this._fields.map(([t,r])=>t+(r.name==="null"?"":`:${r.display()}`)).join("; ")}}`}valueToString(A){for(let[t,r]of this._fields)if(A.hasOwnProperty(t)){let n=r.valueToString(A[t]);return n==="null"?`variant {${t}}`:`variant {${t}=${n}}`}throw new Error("Variant has no data: "+A)}};y.VariantClass=it;var le=class extends he{constructor(){super(...arguments),this._id=le._counter++,this._type=void 0}accept(A,t){if(!this._type)throw Error("Recursive type uninitialized.");return A.visitRec(this,this._type,t)}fill(A){this._type=A}getType(){return this._type}covariant(A){return this._type?this._type.covariant(A):!1}encodeValue(A){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(A)}_buildTypeTableImpl(A){if(!this._type)throw Error("Recursive type uninitialized.");A.add(this,new Uint8Array([])),this._type.buildTypeTable(A),A.merge(this,this._type.name)}decodeValue(A,t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(A,t)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(A){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(A)}};y.RecClass=le;le._counter=0;function on(e){if((0,x.safeReadUint8)(e)!==1)throw new Error("Cannot decode principal");let t=Number((0,x.lebDecode)(e));return rc.Principal.fromUint8Array(new Uint8Array((0,x.safeRead)(e,t)))}var ur=class extends JA{accept(A,t){return A.visitPrincipal(this,t)}covariant(A){return A&&A._isPrincipal}encodeValue(A){let t=A.toUint8Array(),r=(0,x.lebEncode)(t.byteLength);return(0,AA.concat)(new Uint8Array([1]),r,t)}encodeType(){return(0,x.slebEncode)(-24)}decodeValue(A,t){return this.checkType(t),on(A)}get name(){return"principal"}valueToString(A){return`${this.name} "${A.toText()}"`}};y.PrincipalClass=ur;var mt=class extends he{constructor(A,t,r=[]){super(),this.argTypes=A,this.retTypes=t,this.annotations=r}static argsToString(A,t){if(A.length!==t.length)throw new Error("arity mismatch");return"("+A.map((r,n)=>r.valueToString(t[n])).join(", ")+")"}accept(A,t){return A.visitFunc(this,t)}covariant(A){return Array.isArray(A)&&A.length===2&&A[0]&&A[0]._isPrincipal&&typeof A[1]=="string"}encodeValue([A,t]){let r=A.toUint8Array(),n=(0,x.lebEncode)(r.byteLength),i=(0,AA.concat)(new Uint8Array([1]),n,r),s=new TextEncoder().encode(t),c=(0,x.lebEncode)(s.byteLength);return(0,AA.concat)(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(A){this.argTypes.forEach(w=>w.buildTypeTable(A)),this.retTypes.forEach(w=>w.buildTypeTable(A));let t=(0,x.slebEncode)(-22),r=(0,x.lebEncode)(this.argTypes.length),n=(0,AA.concat)(...this.argTypes.map(w=>w.encodeType(A))),i=(0,x.lebEncode)(this.retTypes.length),s=(0,AA.concat)(...this.retTypes.map(w=>w.encodeType(A))),c=(0,x.lebEncode)(this.annotations.length),a=(0,AA.concat)(...this.annotations.map(w=>this.encodeAnnotation(w)));A.add(this,(0,AA.concat)(t,r,n,i,s,c,a))}decodeValue(A){if((0,x.safeReadUint8)(A)!==1)throw new Error("Cannot decode function reference");let r=on(A),n=Number((0,x.lebDecode)(A)),i=(0,x.safeRead)(A,n),c=new TextDecoder("utf8",{fatal:!0}).decode(i);return[r,c]}get name(){let A=this.argTypes.map(n=>n.name).join(", "),t=this.retTypes.map(n=>n.name).join(", "),r=" "+this.annotations.join(" ");return`(${A}) -> (${t})${r}`}valueToString([A,t]){return`func "${A.toText()}".${t}`}display(){let A=this.argTypes.map(n=>n.display()).join(", "),t=this.retTypes.map(n=>n.display()).join(", "),r=" "+this.annotations.join(" ");return`(${A}) \u2192 (${t})${r}`}encodeAnnotation(A){if(A==="query")return new Uint8Array([1]);if(A==="oneway")return new Uint8Array([2]);throw new Error("Illegal function annotation")}};y.FuncClass=mt;var Er=class extends he{constructor(A){super(),this._fields=Object.entries(A).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(A,t){return A.visitService(this,t)}covariant(A){return A&&A._isPrincipal}encodeValue(A){let t=A.toUint8Array(),r=(0,x.lebEncode)(t.length);return(0,AA.concat)(new Uint8Array([1]),r,t)}_buildTypeTableImpl(A){this._fields.forEach(([i,s])=>s.buildTypeTable(A));let t=(0,x.slebEncode)(-23),r=(0,x.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),a=(0,x.lebEncode)(c.length);return(0,AA.concat)(a,c,s.encodeType(A))});A.add(this,(0,AA.concat)(t,r,...n))}decodeValue(A){return on(A)}get name(){return`service {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}valueToString(A){return`service "${A.toText()}"`}};y.ServiceClass=Er;function Wi(e){return JSON.stringify(e,(A,t)=>typeof t=="bigint"?`BigInt(${t})`:t)}function nc(e,A){if(A.length<e.length)throw Error("Wrong number of message arguments");let t=new nn;e.forEach(a=>a.buildTypeTable(t));let r=new TextEncoder().encode(nr),n=t.encode(),i=(0,x.lebEncode)(A.length),s=(0,AA.concat)(...e.map(a=>a.encodeType(t))),c=(0,AA.concat)(..._t(e,A,(a,w)=>{if(!a.covariant(w))throw new Error(`Invalid ${a.display()} argument: ${Wi(w)}`);return a.encodeValue(w)}));return(0,AA.concat)(r,n,i,s,c)}y.encode=nc;function ic(e,A){let t=new AA.PipeArrayBuffer(A);if(A.byteLength<nr.length)throw new Error("Message length smaller than magic number");let r=(0,x.safeRead)(t,nr.length),n=new TextDecoder().decode(r);if(n!==nr)throw new Error("Wrong magic number: "+JSON.stringify(n));function i(m){let R=[],J=Number((0,x.lebDecode)(m));for(let eA=0;eA<J;eA++){let L=Number((0,x.slebDecode)(m));switch(L){case-18:case-19:{let BA=Number((0,x.slebDecode)(m));R.push([L,BA]);break}case-20:case-21:{let BA=[],v=Number((0,x.lebDecode)(m)),M;for(;v--;){let P=Number((0,x.lebDecode)(m));if(P>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof M=="number"&&M>=P)throw new Error("field id collision or not sorted");M=P;let W=Number((0,x.slebDecode)(m));BA.push([P,W])}R.push([L,BA]);break}case-22:{let BA=[],v=Number((0,x.lebDecode)(m));for(;v--;)BA.push(Number((0,x.slebDecode)(m)));let M=[],P=Number((0,x.lebDecode)(m));for(;P--;)M.push(Number((0,x.slebDecode)(m)));let W=[],q=Number((0,x.lebDecode)(m));for(;q--;)switch(Number((0,x.lebDecode)(m))){case 1:{W.push("query");break}case 2:{W.push("oneway");break}default:throw new Error("unknown annotation")}R.push([L,[BA,M,W]]);break}case-23:{let BA=Number((0,x.lebDecode)(m)),v=[];for(;BA--;){let M=Number((0,x.lebDecode)(m)),P=new TextDecoder().decode((0,x.safeRead)(m,M)),W=(0,x.slebDecode)(m);v.push([P,W])}R.push([L,v]);break}default:throw new Error("Illegal op_code: "+L)}}let $=[],O=Number((0,x.lebDecode)(m));for(let eA=0;eA<O;eA++)$.push(Number((0,x.slebDecode)(m)));return[R,$]}let[s,c]=i(t);if(c.length<e.length)throw new Error("Wrong number of return values");let a=s.map(m=>As());function w(m){if(m<-24)throw new Error("future value not supported");if(m<0)switch(m){case-1:return y.Null;case-2:return y.Bool;case-3:return y.Nat;case-4:return y.Int;case-5:return y.Nat8;case-6:return y.Nat16;case-7:return y.Nat32;case-8:return y.Nat64;case-9:return y.Int8;case-10:return y.Int16;case-11:return y.Int32;case-12:return y.Int64;case-13:return y.Float32;case-14:return y.Float64;case-15:return y.Text;case-16:return y.Reserved;case-17:return y.Empty;case-24:return y.Principal;default:throw new Error("Illegal op_code: "+m)}if(m>=s.length)throw new Error("type index out of range");return a[m]}function N(m){switch(m[0]){case-19:{let R=w(m[1]);return zi(R)}case-18:{let R=w(m[1]);return Di(R)}case-20:{let R={};for(let[O,eA]of m[1]){let L=`_${O}_`;R[L]=w(eA)}let J=$i(R),$=J.tryAsTuple();return Array.isArray($)?Xi(...$):J}case-21:{let R={};for(let[J,$]of m[1]){let O=`_${J}_`;R[O]=w($)}return Li(R)}case-22:{let[R,J,$]=m[1];return es(R.map(O=>w(O)),J.map(O=>w(O)),$)}case-23:{let R={},J=m[1];for(let[$,O]of J){let eA=w(O);if(eA instanceof le&&(eA=eA.getType()),!(eA instanceof mt))throw new Error("Illegal service definition: services can only contain functions");R[$]=eA}return ts(R)}default:throw new Error("Illegal op_code: "+m[0])}}s.forEach((m,R)=>{let J=N(m);a[R].fill(J)});let S=c.map(m=>w(m)),k=e.map((m,R)=>m.decodeValue(t,S[R]));for(let m=e.length;m<S.length;m++)S[m].decodeValue(t,S[m]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return k}y.decode=ic;y.Empty=new ir;y.Reserved=new tt;y.Unknown=new sr;y.Bool=new or;y.Null=new ar;y.Text=new cr;y.Int=new Br;y.Nat=new gr;y.Float32=new Gt(32);y.Float64=new Gt(64);y.Int8=new me(8);y.Int16=new me(16);y.Int32=new me(32);y.Int64=new me(64);y.Nat8=new Qe(8);y.Nat16=new Qe(16);y.Nat32=new Qe(32);y.Nat64=new Qe(64);y.Principal=new ur;function Xi(...e){return new nt(e)}y.Tuple=Xi;function zi(e){return new rt(e)}y.Vec=zi;function Di(e){return new qe(e)}y.Opt=Di;function $i(e){return new Je(e)}y.Record=$i;function Li(e){return new it(e)}y.Variant=Li;function As(){return new le}y.Rec=As;function es(e,A,t=[]){return new mt(e,A,t)}y.Func=es;function ts(e){return new Er(e)}y.Service=ts});var hn=T(UA=>{"use strict";Object.defineProperty(UA,"__esModule",{value:!0});UA.VecForm=UA.OptionForm=UA.VariantForm=UA.TupleForm=UA.RecordForm=UA.InputForm=UA.InputBox=void 0;var cn=class{constructor(A,t){this.idl=A,this.ui=t,this.label=null,this.value=void 0;let r=document.createElement("span");r.className="status",this.status=r,t.input&&(t.input.addEventListener("blur",()=>{t.input.value!==""&&this.parse()}),t.input.addEventListener("input",()=>{r.style.display="none",t.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(A={}){if(this.ui.form){let t=this.ui.form.parse(A);return this.value=t,t}if(this.ui.input){let t=this.ui.input;try{let r=this.ui.parse(this.idl,A,t.value);if(!this.idl.covariant(r))throw new Error(`${t.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=r,r}catch(r){t.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+r.message,this.value=void 0;return}}return null}render(A){let t=document.createElement("span");if(this.label){let r=document.createElement("label");r.innerText=this.label,t.appendChild(r)}this.ui.input&&(t.appendChild(this.ui.input),t.appendChild(this.status)),this.ui.form&&this.ui.form.render(t),A.appendChild(t)}};UA.InputBox=cn;var xe=class{constructor(A){this.ui=A,this.form=[]}renderForm(A){this.ui.container?(this.form.forEach(t=>t.render(this.ui.container)),A.appendChild(this.ui.container)):this.form.forEach(t=>t.render(A))}render(A){if(this.ui.open&&this.ui.event){A.appendChild(this.ui.open);let t=this;t.ui.open.addEventListener(t.ui.event,()=>{if(t.ui.container)t.ui.container.innerHTML="";else{let r=t.ui.open.nextElementSibling;r&&r.parentNode.removeChild(r)}t.generateForm(),t.renderForm(A)})}else this.generateForm(),this.renderForm(A)}};UA.InputForm=xe;var Bn=class extends xe{constructor(A,t){super(t),this.fields=A,this.ui=t}generateForm(){this.form=this.fields.map(([A,t])=>{let r=this.ui.render(t);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(A)?r.label=this.ui.labelMap[A]+" ":r.label=A+" ",r})}parse(A){let t={};if(this.fields.forEach(([r,n],i)=>{let s=this.form[i].parse(A);t[r]=s}),!this.form.some(r=>r.isRejected()))return t}};UA.RecordForm=Bn;var gn=class extends xe{constructor(A,t){super(t),this.components=A,this.ui=t}generateForm(){this.form=this.components.map(A=>this.ui.render(A))}parse(A){let t=[];if(this.components.forEach((r,n)=>{let i=this.form[n].parse(A);t.push(i)}),!this.form.some(r=>r.isRejected()))return t}};UA.TupleForm=gn;var un=class extends xe{constructor(A,t){super(t),this.fields=A,this.ui=t}generateForm(){let A=this.ui.open.selectedIndex,[t,r]=this.fields[A],n=this.ui.render(r);this.form=[n]}parse(A){let t=this.ui.open,r=t.options[t.selectedIndex].value,n=this.form[0].parse(A);if(n===void 0)return;let i={};return i[r]=n,i}};UA.VariantForm=un;var En=class extends xe{constructor(A,t){super(t),this.ty=A,this.ui=t}generateForm(){if(this.ui.open.checked){let A=this.ui.render(this.ty);this.form=[A]}else this.form=[]}parse(A){if(this.form.length===0)return[];{let t=this.form[0].parse(A);return t===void 0?void 0:[t]}}};UA.OptionForm=En;var Qn=class extends xe{constructor(A,t){super(t),this.ty=A,this.ui=t}generateForm(){let A=+this.ui.open.value;this.form=[];for(let t=0;t<A;t++){let r=this.ui.render(this.ty);this.form.push(r)}}parse(A){let t=this.form.map(r=>r.parse(A));if(!this.form.some(r=>r.isRejected()))return t}};UA.VecForm=Qn});var ns=T(j=>{"use strict";var sc=j&&j.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),oc=j&&j.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),rs=j&&j.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&sc(A,e,t);return oc(A,e),A};Object.defineProperty(j,"__esModule",{value:!0});j.renderValue=j.renderInput=j.Render=j.vecForm=j.optForm=j.variantForm=j.tupleForm=j.recordForm=j.inputBox=void 0;var hr=rs(an()),ln=ue(),st=rs(hn()),ac={parse:hc},Nt={render:dn},cc=(e,A)=>new st.InputBox(e,Object.assign(Object.assign({},ac),A));j.inputBox=cc;var Bc=(e,A)=>new st.RecordForm(e,Object.assign(Object.assign({},Nt),A));j.recordForm=Bc;var gc=(e,A)=>new st.TupleForm(e,Object.assign(Object.assign({},Nt),A));j.tupleForm=gc;var uc=(e,A)=>new st.VariantForm(e,Object.assign(Object.assign({},Nt),A));j.variantForm=uc;var Ec=(e,A)=>new st.OptionForm(e,Object.assign(Object.assign({},Nt),A));j.optForm=Ec;var Qc=(e,A)=>new st.VecForm(e,Object.assign(Object.assign({},Nt),A));j.vecForm=Qc;var Qr=class extends hr.Visitor{visitType(A,t){let r=document.createElement("input");return r.classList.add("argument"),r.placeholder=A.display(),(0,j.inputBox)(A,{input:r})}visitNull(A,t){return(0,j.inputBox)(A,{})}visitRecord(A,t,r){let n={};if(t.length>1){let s=document.createElement("div");s.classList.add("popup-form"),n={container:s}}let i=(0,j.recordForm)(t,n);return(0,j.inputBox)(A,{form:i})}visitTuple(A,t,r){let n={};if(t.length>1){let s=document.createElement("div");s.classList.add("popup-form"),n={container:s}}let i=(0,j.tupleForm)(t,n);return(0,j.inputBox)(A,{form:i})}visitVariant(A,t,r){let n=document.createElement("select");for(let[c,a]of t){let w=new Option(c);n.add(w)}n.selectedIndex=-1,n.classList.add("open");let i={open:n,event:"change"},s=(0,j.variantForm)(t,i);return(0,j.inputBox)(A,{form:s})}visitOpt(A,t,r){let n=document.createElement("input");n.type="checkbox",n.classList.add("open");let i=(0,j.optForm)(t,{open:n,event:"change"});return(0,j.inputBox)(A,{form:i})}visitVec(A,t,r){let n=document.createElement("input");n.type="number",n.min="0",n.max="100",n.style.width="8rem",n.placeholder="len",n.classList.add("open");let i=document.createElement("div");i.classList.add("popup-form");let s=(0,j.vecForm)(t,{open:n,event:"change",container:i});return(0,j.inputBox)(A,{form:s})}visitRec(A,t,r){return dn(t)}};j.Render=Qr;var fn=class extends hr.Visitor{visitNull(A,t){return null}visitBool(A,t){if(t==="true")return!0;if(t==="false")return!1;throw new Error(`Cannot parse ${t} as boolean`)}visitText(A,t){return t}visitFloat(A,t){return parseFloat(t)}visitFixedInt(A,t){return A._bits<=32?parseInt(t,10):BigInt(t)}visitFixedNat(A,t){return A._bits<=32?parseInt(t,10):BigInt(t)}visitNumber(A,t){return BigInt(t)}visitPrincipal(A,t){return ln.Principal.fromText(t)}visitService(A,t){return ln.Principal.fromText(t)}visitFunc(A,t){let r=t.split(".",2);return[ln.Principal.fromText(r[0]),r[1]]}},In=class extends hr.Visitor{visitNull(A,t){return null}visitBool(A,t){return Math.random()<.5}visitText(A,t){return Math.random().toString(36).substring(6)}visitFloat(A,t){return Math.random()}visitInt(A,t){return BigInt(this.generateNumber(!0))}visitNat(A,t){return BigInt(this.generateNumber(!1))}visitFixedInt(A,t){let r=this.generateNumber(!0);return A._bits<=32?r:BigInt(t)}visitFixedNat(A,t){let r=this.generateNumber(!1);return A._bits<=32?r:BigInt(t)}generateNumber(A){let t=Math.floor(Math.random()*100);return A&&Math.random()<.5?-t:t}};function hc(e,A,t){return A.random&&t===""?e.accept(new In,t):e.accept(new fn,t)}function dn(e){return e.accept(new Qr,null)}j.renderInput=dn;function Pe(e,A,t){return e.accept(new Cn,{input:A,value:t})}j.renderValue=Pe;var Cn=class extends hr.Visitor{visitType(A,t){t.input.ui.input.value=A.valueToString(t.value)}visitNull(A,t){}visitText(A,t){t.input.ui.input.value=t.value}visitRec(A,t,r){Pe(t,r.input,r.value)}visitOpt(A,t,r){if(r.value.length!==0){let n=r.input.ui.form,i=n.ui.open;i.checked=!0,i.dispatchEvent(new Event(n.ui.event)),Pe(t,n.form[0],r.value[0])}}visitRecord(A,t,r){let n=r.input.ui.form;t.forEach(([i,s],c)=>{Pe(s,n.form[c],r.value[i])})}visitTuple(A,t,r){let n=r.input.ui.form;t.forEach((i,s)=>{Pe(i,n.form[s],r.value[s])})}visitVariant(A,t,r){let n=r.input.ui.form,i=Object.entries(r.value)[0];t.forEach(([s,c],a)=>{if(s===i[0]){let w=n.ui.open;w.selectedIndex=a,w.dispatchEvent(new Event(n.ui.event)),Pe(c,n.form[0],i[1])}})}visitVec(A,t,r){let n=r.input.ui.form,i=r.value.length,s=n.ui.open;s.value=i,s.dispatchEvent(new Event(n.ui.event)),r.value.forEach((c,a)=>{Pe(t,n.form[a],c)})}}});var ss=T(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0})});var Ft=T(FA=>{"use strict";var os=FA&&FA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),lc=FA&&FA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),ot=FA&&FA.__exportStar||function(e,A){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(A,t)&&os(A,e,t)},fc=FA&&FA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&os(A,e,t);return lc(A,e),A};Object.defineProperty(FA,"__esModule",{value:!0});FA.IDL=void 0;ot(ns(),FA);ot(hn(),FA);FA.IDL=fc(an());ot(en(),FA);ot(rn(),FA);ot(er(),FA);ot(ss(),FA)});var St=T((as,lr)=>{(function(e){"use strict";var A,t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,n=Math.floor,i="[BigNumber Error] ",s=i+"Number primitive has more than 15 significant digits: ",c=1e14,a=14,w=9007199254740991,N=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],S=1e7,k=1e9;function m(v){var M,P,W,q=F.prototype={constructor:F,toString:null,valueOf:null},nA=new F(1),tA=20,iA=4,gA=-7,pA=21,RA=-1e7,qA=1e7,MA=!1,lA=1,HA=0,Ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},WA="0123456789abcdefghijklmnopqrstuvwxyz",ee=!0;function F(o,B){var g,C,h,f,p,u,l,d,I=this;if(!(I instanceof F))return new F(o,B);if(B==null){if(o&&o._isBigNumber===!0){I.s=o.s,!o.c||o.e>qA?I.c=I.e=null:o.e<RA?I.c=[I.e=0]:(I.e=o.e,I.c=o.c.slice());return}if((u=typeof o=="number")&&o*0==0){if(I.s=1/o<0?(o=-o,-1):1,o===~~o){for(f=0,p=o;p>=10;p/=10,f++);f>qA?I.c=I.e=null:(I.e=f,I.c=[o]);return}d=String(o)}else{if(!t.test(d=String(o)))return W(I,d,u);I.s=d.charCodeAt(0)==45?(d=d.slice(1),-1):1}(f=d.indexOf("."))>-1&&(d=d.replace(".","")),(p=d.search(/e/i))>0?(f<0&&(f=p),f+=+d.slice(p+1),d=d.substring(0,p)):f<0&&(f=d.length)}else{if(O(B,2,WA.length,"Base"),B==10&&ee)return I=new F(o),fA(I,tA+I.e+1,iA);if(d=String(o),u=typeof o=="number"){if(o*0!=0)return W(I,d,u,B);if(I.s=1/o<0?(d=d.slice(1),-1):1,F.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(s+o)}else I.s=d.charCodeAt(0)===45?(d=d.slice(1),-1):1;for(g=WA.slice(0,B),f=p=0,l=d.length;p<l;p++)if(g.indexOf(C=d.charAt(p))<0){if(C=="."){if(p>f){f=l;continue}}else if(!h&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){h=!0,p=-1,f=0;continue}return W(I,String(o),u,B)}u=!1,d=P(d,B,10,I.s),(f=d.indexOf("."))>-1?d=d.replace(".",""):f=d.length}for(p=0;d.charCodeAt(p)===48;p++);for(l=d.length;d.charCodeAt(--l)===48;);if(d=d.slice(p,++l)){if(l-=p,u&&F.DEBUG&&l>15&&(o>w||o!==n(o)))throw Error(s+I.s*o);if((f=f-p-1)>qA)I.c=I.e=null;else if(f<RA)I.c=[I.e=0];else{if(I.e=f,I.c=[],p=(f+1)%a,f<0&&(p+=a),p<l){for(p&&I.c.push(+d.slice(0,p)),l-=a;p<l;)I.c.push(+d.slice(p,p+=a));p=a-(d=d.slice(p)).length}else p-=l;for(;p--;d+="0");I.c.push(+d)}}else I.c=[I.e=0]}F.clone=m,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(o){var B,g;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(B="DECIMAL_PLACES")&&(g=o[B],O(g,0,k,B),tA=g),o.hasOwnProperty(B="ROUNDING_MODE")&&(g=o[B],O(g,0,8,B),iA=g),o.hasOwnProperty(B="EXPONENTIAL_AT")&&(g=o[B],g&&g.pop?(O(g[0],-k,0,B),O(g[1],0,k,B),gA=g[0],pA=g[1]):(O(g,-k,k,B),gA=-(pA=g<0?-g:g))),o.hasOwnProperty(B="RANGE"))if(g=o[B],g&&g.pop)O(g[0],-k,-1,B),O(g[1],1,k,B),RA=g[0],qA=g[1];else if(O(g,-k,k,B),g)RA=-(qA=g<0?-g:g);else throw Error(i+B+" cannot be zero: "+g);if(o.hasOwnProperty(B="CRYPTO"))if(g=o[B],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))MA=g;else throw MA=!g,Error(i+"crypto unavailable");else MA=g;else throw Error(i+B+" not true or false: "+g);if(o.hasOwnProperty(B="MODULO_MODE")&&(g=o[B],O(g,0,9,B),lA=g),o.hasOwnProperty(B="POW_PRECISION")&&(g=o[B],O(g,0,k,B),HA=g),o.hasOwnProperty(B="FORMAT"))if(g=o[B],typeof g=="object")Ae=g;else throw Error(i+B+" not an object: "+g);if(o.hasOwnProperty(B="ALPHABET"))if(g=o[B],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))ee=g.slice(0,10)=="0123456789",WA=g;else throw Error(i+B+" invalid: "+g)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:tA,ROUNDING_MODE:iA,EXPONENTIAL_AT:[gA,pA],RANGE:[RA,qA],CRYPTO:MA,MODULO_MODE:lA,POW_PRECISION:HA,FORMAT:Ae,ALPHABET:WA}},F.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var B,g,C=o.c,h=o.e,f=o.s;A:if({}.toString.call(C)=="[object Array]"){if((f===1||f===-1)&&h>=-k&&h<=k&&h===n(h)){if(C[0]===0){if(h===0&&C.length===1)return!0;break A}if(B=(h+1)%a,B<1&&(B+=a),String(C[0]).length==B){for(B=0;B<C.length;B++)if(g=C[B],g<0||g>=c||g!==n(g))break A;if(g!==0)return!0}}}else if(C===null&&h===null&&(f===null||f===1||f===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},F.maximum=F.max=function(){return ae(arguments,q.lt)},F.minimum=F.min=function(){return ae(arguments,q.gt)},F.random=function(){var o=9007199254740992,B=Math.random()*o&2097151?function(){return n(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var C,h,f,p,u,l=0,d=[],I=new F(nA);if(g==null?g=tA:O(g,0,k),p=r(g/a),MA)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(p*=2));l<p;)u=C[l]*131072+(C[l+1]>>>11),u>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),C[l]=h[0],C[l+1]=h[1]):(d.push(u%1e14),l+=2);l=p/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(p*=7);l<p;)u=(C[l]&31)*281474976710656+C[l+1]*1099511627776+C[l+2]*4294967296+C[l+3]*16777216+(C[l+4]<<16)+(C[l+5]<<8)+C[l+6],u>=9e15?crypto.randomBytes(7).copy(C,l):(d.push(u%1e14),l+=7);l=p/7}else throw MA=!1,Error(i+"crypto unavailable");if(!MA)for(;l<p;)u=B(),u<9e15&&(d[l++]=u%1e14);for(p=d[--l],g%=a,p&&g&&(u=N[a-g],d[l]=n(p/u)*u);d[l]===0;d.pop(),l--);if(l<0)d=[f=0];else{for(f=-1;d[0]===0;d.splice(0,1),f-=a);for(l=1,u=d[0];u>=10;u/=10,l++);l<a&&(f-=a-l)}return I.e=f,I.c=d,I}}(),F.sum=function(){for(var o=1,B=arguments,g=new F(B[0]);o<B.length;)g=g.plus(B[o++]);return g},P=function(){var o="0123456789";function B(g,C,h,f){for(var p,u=[0],l,d=0,I=g.length;d<I;){for(l=u.length;l--;u[l]*=C);for(u[0]+=f.indexOf(g.charAt(d++)),p=0;p<u.length;p++)u[p]>h-1&&(u[p+1]==null&&(u[p+1]=0),u[p+1]+=u[p]/h|0,u[p]%=h)}return u.reverse()}return function(g,C,h,f,p){var u,l,d,I,G,b,H,V,sA=g.indexOf("."),uA=tA,Z=iA;for(sA>=0&&(I=HA,HA=0,g=g.replace(".",""),V=new F(C),b=V.pow(g.length-sA),HA=I,V.c=B(BA(J(b.c),b.e,"0"),10,h,o),V.e=V.c.length),H=B(g,C,h,p?(u=WA,o):(u=o,WA)),d=I=H.length;H[--I]==0;H.pop());if(!H[0])return u.charAt(0);if(sA<0?--d:(b.c=H,b.e=d,b.s=f,b=M(b,V,uA,Z,h),H=b.c,G=b.r,d=b.e),l=d+uA+1,sA=H[l],I=h/2,G=G||l<0||H[l+1]!=null,G=Z<4?(sA!=null||G)&&(Z==0||Z==(b.s<0?3:2)):sA>I||sA==I&&(Z==4||G||Z==6&&H[l-1]&1||Z==(b.s<0?8:7)),l<1||!H[0])g=G?BA(u.charAt(1),-uA,u.charAt(0)):u.charAt(0);else{if(H.length=l,G)for(--h;++H[--l]>h;)H[l]=0,l||(++d,H=[1].concat(H));for(I=H.length;!H[--I];);for(sA=0,g="";sA<=I;g+=u.charAt(H[sA++]));g=BA(g,d,u.charAt(0))}return g}}(),M=function(){function o(C,h,f){var p,u,l,d,I=0,G=C.length,b=h%S,H=h/S|0;for(C=C.slice();G--;)l=C[G]%S,d=C[G]/S|0,p=H*l+d*b,u=b*l+p%S*S+I,I=(u/f|0)+(p/S|0)+H*d,C[G]=u%f;return I&&(C=[I].concat(C)),C}function B(C,h,f,p){var u,l;if(f!=p)l=f>p?1:-1;else for(u=l=0;u<f;u++)if(C[u]!=h[u]){l=C[u]>h[u]?1:-1;break}return l}function g(C,h,f,p){for(var u=0;f--;)C[f]-=u,u=C[f]<h[f]?1:0,C[f]=u*p+C[f]-h[f];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,h,f,p,u){var l,d,I,G,b,H,V,sA,uA,Z,U,IA,ce,ye,_e,vA,rA,YA=C.s==h.s?1:-1,xA=C.c,EA=h.c;if(!xA||!xA[0]||!EA||!EA[0])return new F(!C.s||!h.s||(xA?EA&&xA[0]==EA[0]:!EA)?NaN:xA&&xA[0]==0||!EA?YA*0:YA/0);for(sA=new F(YA),uA=sA.c=[],d=C.e-h.e,YA=f+d+1,u||(u=c,d=R(C.e/a)-R(h.e/a),YA=YA/a|0),I=0;EA[I]==(xA[I]||0);I++);if(EA[I]>(xA[I]||0)&&d--,YA<0)uA.push(1),G=!0;else{for(ye=xA.length,vA=EA.length,I=0,YA+=2,b=n(u/(EA[0]+1)),b>1&&(EA=o(EA,b,u),xA=o(xA,b,u),vA=EA.length,ye=xA.length),ce=vA,Z=xA.slice(0,vA),U=Z.length;U<vA;Z[U++]=0);rA=EA.slice(),rA=[0].concat(rA),_e=EA[0],EA[1]>=u/2&&_e++;do{if(b=0,l=B(EA,Z,vA,U),l<0){if(IA=Z[0],vA!=U&&(IA=IA*u+(Z[1]||0)),b=n(IA/_e),b>1)for(b>=u&&(b=u-1),H=o(EA,b,u),V=H.length,U=Z.length;B(H,Z,V,U)==1;)b--,g(H,vA<V?rA:EA,V,u),V=H.length,l=1;else b==0&&(l=b=1),H=EA.slice(),V=H.length;if(V<U&&(H=[0].concat(H)),g(Z,H,U,u),U=Z.length,l==-1)for(;B(EA,Z,vA,U)<1;)b++,g(Z,vA<U?rA:EA,U,u),U=Z.length}else l===0&&(b++,Z=[0]);uA[I++]=b,Z[0]?Z[U++]=xA[ce]||0:(Z=[xA[ce]],U=1)}while((ce++<ye||Z[0]!=null)&&YA--);G=Z[0]!=null,uA[0]||uA.splice(0,1)}if(u==c){for(I=1,YA=uA[0];YA>=10;YA/=10,I++);fA(sA,f+(sA.e=I+d*a-1)+1,p,G)}else sA.e=d,sA.r=+G;return sA}}();function Q(o,B,g,C){var h,f,p,u,l;if(g==null?g=iA:O(g,0,8),!o.c)return o.toString();if(h=o.c[0],p=o.e,B==null)l=J(o.c),l=C==1||C==2&&(p<=gA||p>=pA)?L(l,p):BA(l,p,"0");else if(o=fA(new F(o),B,g),f=o.e,l=J(o.c),u=l.length,C==1||C==2&&(B<=f||f<=gA)){for(;u<B;l+="0",u++);l=L(l,f)}else if(B-=p,l=BA(l,f,"0"),f+1>u){if(--B>0)for(l+=".";B--;l+="0");}else if(B+=f-u,B>0)for(f+1==u&&(l+=".");B--;l+="0");return o.s<0&&h?"-"+l:l}function ae(o,B){for(var g,C=1,h=new F(o[0]);C<o.length;C++)if(g=new F(o[C]),g.s)B.call(h,g)&&(h=g);else{h=g;break}return h}function te(o,B,g){for(var C=1,h=B.length;!B[--h];B.pop());for(h=B[0];h>=10;h/=10,C++);return(g=C+g*a-1)>qA?o.c=o.e=null:g<RA?o.c=[o.e=0]:(o.e=g,o.c=B),o}W=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,B=/^([^.]+)\.$/,g=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(f,p,u,l){var d,I=u?p:p.replace(h,"");if(C.test(I))f.s=isNaN(I)?null:I<0?-1:1;else{if(!u&&(I=I.replace(o,function(G,b,H){return d=(H=H.toLowerCase())=="x"?16:H=="b"?2:8,!l||l==d?b:G}),l&&(d=l,I=I.replace(B,"$1").replace(g,"0.$1")),p!=I))return new F(I,d);if(F.DEBUG)throw Error(i+"Not a"+(l?" base "+l:"")+" number: "+p);f.s=null}f.c=f.e=null}}();function fA(o,B,g,C){var h,f,p,u,l,d,I,G=o.c,b=N;if(G){A:{for(h=1,u=G[0];u>=10;u/=10,h++);if(f=B-h,f<0)f+=a,p=B,l=G[d=0],I=l/b[h-p-1]%10|0;else if(d=r((f+1)/a),d>=G.length)if(C){for(;G.length<=d;G.push(0));l=I=0,h=1,f%=a,p=f-a+1}else break A;else{for(l=u=G[d],h=1;u>=10;u/=10,h++);f%=a,p=f-a+h,I=p<0?0:l/b[h-p-1]%10|0}if(C=C||B<0||G[d+1]!=null||(p<0?l:l%b[h-p-1]),C=g<4?(I||C)&&(g==0||g==(o.s<0?3:2)):I>5||I==5&&(g==4||C||g==6&&(f>0?p>0?l/b[h-p]:0:G[d-1])%10&1||g==(o.s<0?8:7)),B<1||!G[0])return G.length=0,C?(B-=o.e+1,G[0]=b[(a-B%a)%a],o.e=-B||0):G[0]=o.e=0,o;if(f==0?(G.length=d,u=1,d--):(G.length=d+1,u=b[a-f],G[d]=p>0?n(l/b[h-p]%b[p])*u:0),C)for(;;)if(d==0){for(f=1,p=G[0];p>=10;p/=10,f++);for(p=G[0]+=u,u=1;p>=10;p/=10,u++);f!=u&&(o.e++,G[0]==c&&(G[0]=1));break}else{if(G[d]+=u,G[d]!=c)break;G[d--]=0,u=1}for(f=G.length;G[--f]===0;G.pop());}o.e>qA?o.c=o.e=null:o.e<RA&&(o.c=[o.e=0])}return o}function Y(o){var B,g=o.e;return g===null?o.toString():(B=J(o.c),B=g<=gA||g>=pA?L(B,g):BA(B,g,"0"),o.s<0?"-"+B:B)}return q.absoluteValue=q.abs=function(){var o=new F(this);return o.s<0&&(o.s=1),o},q.comparedTo=function(o,B){return $(this,new F(o,B))},q.decimalPlaces=q.dp=function(o,B){var g,C,h,f=this;if(o!=null)return O(o,0,k),B==null?B=iA:O(B,0,8),fA(new F(f),o+f.e+1,B);if(!(g=f.c))return null;if(C=((h=g.length-1)-R(this.e/a))*a,h=g[h])for(;h%10==0;h/=10,C--);return C<0&&(C=0),C},q.dividedBy=q.div=function(o,B){return M(this,new F(o,B),tA,iA)},q.dividedToIntegerBy=q.idiv=function(o,B){return M(this,new F(o,B),0,1)},q.exponentiatedBy=q.pow=function(o,B){var g,C,h,f,p,u,l,d,I,G=this;if(o=new F(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+Y(o));if(B!=null&&(B=new F(B)),u=o.e>14,!G.c||!G.c[0]||G.c[0]==1&&!G.e&&G.c.length==1||!o.c||!o.c[0])return I=new F(Math.pow(+Y(G),u?2-eA(o):+Y(o))),B?I.mod(B):I;if(l=o.s<0,B){if(B.c?!B.c[0]:!B.s)return new F(NaN);C=!l&&G.isInteger()&&B.isInteger(),C&&(G=G.mod(B))}else{if(o.e>9&&(G.e>0||G.e<-1||(G.e==0?G.c[0]>1||u&&G.c[1]>=24e7:G.c[0]<8e13||u&&G.c[0]<=9999975e7)))return f=G.s<0&&eA(o)?-0:0,G.e>-1&&(f=1/f),new F(l?1/f:f);HA&&(f=r(HA/a+2))}for(u?(g=new F(.5),l&&(o.s=1),d=eA(o)):(h=Math.abs(+Y(o)),d=h%2),I=new F(nA);;){if(d){if(I=I.times(G),!I.c)break;f?I.c.length>f&&(I.c.length=f):C&&(I=I.mod(B))}if(h){if(h=n(h/2),h===0)break;d=h%2}else if(o=o.times(g),fA(o,o.e+1,1),o.e>14)d=eA(o);else{if(h=+Y(o),h===0)break;d=h%2}G=G.times(G),f?G.c&&G.c.length>f&&(G.c.length=f):C&&(G=G.mod(B))}return C?I:(l&&(I=nA.div(I)),B?I.mod(B):f?fA(I,HA,iA,p):I)},q.integerValue=function(o){var B=new F(this);return o==null?o=iA:O(o,0,8),fA(B,B.e+1,o)},q.isEqualTo=q.eq=function(o,B){return $(this,new F(o,B))===0},q.isFinite=function(){return!!this.c},q.isGreaterThan=q.gt=function(o,B){return $(this,new F(o,B))>0},q.isGreaterThanOrEqualTo=q.gte=function(o,B){return(B=$(this,new F(o,B)))===1||B===0},q.isInteger=function(){return!!this.c&&R(this.e/a)>this.c.length-2},q.isLessThan=q.lt=function(o,B){return $(this,new F(o,B))<0},q.isLessThanOrEqualTo=q.lte=function(o,B){return(B=$(this,new F(o,B)))===-1||B===0},q.isNaN=function(){return!this.s},q.isNegative=function(){return this.s<0},q.isPositive=function(){return this.s>0},q.isZero=function(){return!!this.c&&this.c[0]==0},q.minus=function(o,B){var g,C,h,f,p=this,u=p.s;if(o=new F(o,B),B=o.s,!u||!B)return new F(NaN);if(u!=B)return o.s=-B,p.plus(o);var l=p.e/a,d=o.e/a,I=p.c,G=o.c;if(!l||!d){if(!I||!G)return I?(o.s=-B,o):new F(G?p:NaN);if(!I[0]||!G[0])return G[0]?(o.s=-B,o):new F(I[0]?p:iA==3?-0:0)}if(l=R(l),d=R(d),I=I.slice(),u=l-d){for((f=u<0)?(u=-u,h=I):(d=l,h=G),h.reverse(),B=u;B--;h.push(0));h.reverse()}else for(C=(f=(u=I.length)<(B=G.length))?u:B,u=B=0;B<C;B++)if(I[B]!=G[B]){f=I[B]<G[B];break}if(f&&(h=I,I=G,G=h,o.s=-o.s),B=(C=G.length)-(g=I.length),B>0)for(;B--;I[g++]=0);for(B=c-1;C>u;){if(I[--C]<G[C]){for(g=C;g&&!I[--g];I[g]=B);--I[g],I[C]+=c}I[C]-=G[C]}for(;I[0]==0;I.splice(0,1),--d);return I[0]?te(o,I,d):(o.s=iA==3?-1:1,o.c=[o.e=0],o)},q.modulo=q.mod=function(o,B){var g,C,h=this;return o=new F(o,B),!h.c||!o.s||o.c&&!o.c[0]?new F(NaN):!o.c||h.c&&!h.c[0]?new F(h):(lA==9?(C=o.s,o.s=1,g=M(h,o,0,3),o.s=C,g.s*=C):g=M(h,o,0,lA),o=h.minus(g.times(o)),!o.c[0]&&lA==1&&(o.s=h.s),o)},q.multipliedBy=q.times=function(o,B){var g,C,h,f,p,u,l,d,I,G,b,H,V,sA,uA,Z=this,U=Z.c,IA=(o=new F(o,B)).c;if(!U||!IA||!U[0]||!IA[0])return!Z.s||!o.s||U&&!U[0]&&!IA||IA&&!IA[0]&&!U?o.c=o.e=o.s=null:(o.s*=Z.s,!U||!IA?o.c=o.e=null:(o.c=[0],o.e=0)),o;for(C=R(Z.e/a)+R(o.e/a),o.s*=Z.s,l=U.length,G=IA.length,l<G&&(V=U,U=IA,IA=V,h=l,l=G,G=h),h=l+G,V=[];h--;V.push(0));for(sA=c,uA=S,h=G;--h>=0;){for(g=0,b=IA[h]%uA,H=IA[h]/uA|0,p=l,f=h+p;f>h;)d=U[--p]%uA,I=U[p]/uA|0,u=H*d+I*b,d=b*d+u%uA*uA+V[f]+g,g=(d/sA|0)+(u/uA|0)+H*I,V[f--]=d%sA;V[f]=g}return g?++C:V.splice(0,1),te(o,V,C)},q.negated=function(){var o=new F(this);return o.s=-o.s||null,o},q.plus=function(o,B){var g,C=this,h=C.s;if(o=new F(o,B),B=o.s,!h||!B)return new F(NaN);if(h!=B)return o.s=-B,C.minus(o);var f=C.e/a,p=o.e/a,u=C.c,l=o.c;if(!f||!p){if(!u||!l)return new F(h/0);if(!u[0]||!l[0])return l[0]?o:new F(u[0]?C:h*0)}if(f=R(f),p=R(p),u=u.slice(),h=f-p){for(h>0?(p=f,g=l):(h=-h,g=u),g.reverse();h--;g.push(0));g.reverse()}for(h=u.length,B=l.length,h-B<0&&(g=l,l=u,u=g,B=h),h=0;B;)h=(u[--B]=u[B]+l[B]+h)/c|0,u[B]=c===u[B]?0:u[B]%c;return h&&(u=[h].concat(u),++p),te(o,u,p)},q.precision=q.sd=function(o,B){var g,C,h,f=this;if(o!=null&&o!==!!o)return O(o,1,k),B==null?B=iA:O(B,0,8),fA(new F(f),o,B);if(!(g=f.c))return null;if(h=g.length-1,C=h*a+1,h=g[h]){for(;h%10==0;h/=10,C--);for(h=g[0];h>=10;h/=10,C++);}return o&&f.e+1>C&&(C=f.e+1),C},q.shiftedBy=function(o){return O(o,-w,w),this.times("1e"+o)},q.squareRoot=q.sqrt=function(){var o,B,g,C,h,f=this,p=f.c,u=f.s,l=f.e,d=tA+4,I=new F("0.5");if(u!==1||!p||!p[0])return new F(!u||u<0&&(!p||p[0])?NaN:p?f:1/0);if(u=Math.sqrt(+Y(f)),u==0||u==1/0?(B=J(p),(B.length+l)%2==0&&(B+="0"),u=Math.sqrt(+B),l=R((l+1)/2)-(l<0||l%2),u==1/0?B="5e"+l:(B=u.toExponential(),B=B.slice(0,B.indexOf("e")+1)+l),g=new F(B)):g=new F(u+""),g.c[0]){for(l=g.e,u=l+d,u<3&&(u=0);;)if(h=g,g=I.times(h.plus(M(f,h,d,1))),J(h.c).slice(0,u)===(B=J(g.c)).slice(0,u))if(g.e<l&&--u,B=B.slice(u-3,u+1),B=="9999"||!C&&B=="4999"){if(!C&&(fA(h,h.e+tA+2,0),h.times(h).eq(f))){g=h;break}d+=4,u+=4,C=1}else{(!+B||!+B.slice(1)&&B.charAt(0)=="5")&&(fA(g,g.e+tA+2,1),o=!g.times(g).eq(f));break}}return fA(g,g.e+tA+1,iA,o)},q.toExponential=function(o,B){return o!=null&&(O(o,0,k),o++),Q(this,o,B,1)},q.toFixed=function(o,B){return o!=null&&(O(o,0,k),o=o+this.e+1),Q(this,o,B)},q.toFormat=function(o,B,g){var C,h=this;if(g==null)o!=null&&B&&typeof B=="object"?(g=B,B=null):o&&typeof o=="object"?(g=o,o=B=null):g=Ae;else if(typeof g!="object")throw Error(i+"Argument not an object: "+g);if(C=h.toFixed(o,B),h.c){var f,p=C.split("."),u=+g.groupSize,l=+g.secondaryGroupSize,d=g.groupSeparator||"",I=p[0],G=p[1],b=h.s<0,H=b?I.slice(1):I,V=H.length;if(l&&(f=u,u=l,l=f,V-=f),u>0&&V>0){for(f=V%u||u,I=H.substr(0,f);f<V;f+=u)I+=d+H.substr(f,u);l>0&&(I+=d+H.slice(f)),b&&(I="-"+I)}C=G?I+(g.decimalSeparator||"")+((l=+g.fractionGroupSize)?G.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):G):I}return(g.prefix||"")+C+(g.suffix||"")},q.toFraction=function(o){var B,g,C,h,f,p,u,l,d,I,G,b,H=this,V=H.c;if(o!=null&&(u=new F(o),!u.isInteger()&&(u.c||u.s!==1)||u.lt(nA)))throw Error(i+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+Y(u));if(!V)return new F(H);for(B=new F(nA),d=g=new F(nA),C=l=new F(nA),b=J(V),f=B.e=b.length-H.e-1,B.c[0]=N[(p=f%a)<0?a+p:p],o=!o||u.comparedTo(B)>0?f>0?B:d:u,p=qA,qA=1/0,u=new F(b),l.c[0]=0;I=M(u,B,0,1),h=g.plus(I.times(C)),h.comparedTo(o)!=1;)g=C,C=h,d=l.plus(I.times(h=d)),l=h,B=u.minus(I.times(h=B)),u=h;return h=M(o.minus(g),C,0,1),l=l.plus(h.times(d)),g=g.plus(h.times(C)),l.s=d.s=H.s,f=f*2,G=M(d,C,f,iA).minus(H).abs().comparedTo(M(l,g,f,iA).minus(H).abs())<1?[d,C]:[l,g],qA=p,G},q.toNumber=function(){return+Y(this)},q.toPrecision=function(o,B){return o!=null&&O(o,1,k),Q(this,o,B,2)},q.toString=function(o){var B,g=this,C=g.s,h=g.e;return h===null?C?(B="Infinity",C<0&&(B="-"+B)):B="NaN":(o==null?B=h<=gA||h>=pA?L(J(g.c),h):BA(J(g.c),h,"0"):o===10&&ee?(g=fA(new F(g),tA+h+1,iA),B=BA(J(g.c),g.e,"0")):(O(o,2,WA.length,"Base"),B=P(BA(J(g.c),h,"0"),10,o,C,!0)),C<0&&g.c[0]&&(B="-"+B)),B},q.valueOf=q.toJSON=function(){return Y(this)},q._isBigNumber=!0,v!=null&&F.set(v),F}function R(v){var M=v|0;return v>0||v===M?M:M-1}function J(v){for(var M,P,W=1,q=v.length,nA=v[0]+"";W<q;){for(M=v[W++]+"",P=a-M.length;P--;M="0"+M);nA+=M}for(q=nA.length;nA.charCodeAt(--q)===48;);return nA.slice(0,q+1||1)}function $(v,M){var P,W,q=v.c,nA=M.c,tA=v.s,iA=M.s,gA=v.e,pA=M.e;if(!tA||!iA)return null;if(P=q&&!q[0],W=nA&&!nA[0],P||W)return P?W?0:-iA:tA;if(tA!=iA)return tA;if(P=tA<0,W=gA==pA,!q||!nA)return W?0:!q^P?1:-1;if(!W)return gA>pA^P?1:-1;for(iA=(gA=q.length)<(pA=nA.length)?gA:pA,tA=0;tA<iA;tA++)if(q[tA]!=nA[tA])return q[tA]>nA[tA]^P?1:-1;return gA==pA?0:gA>pA^P?1:-1}function O(v,M,P,W){if(v<M||v>P||v!==n(v))throw Error(i+(W||"Argument")+(typeof v=="number"?v<M||v>P?" out of range: ":" not an integer: ":" not a primitive number: ")+String(v))}function eA(v){var M=v.c.length-1;return R(v.e/a)==M&&v.c[M]%2!=0}function L(v,M){return(v.length>1?v.charAt(0)+"."+v.slice(1):v)+(M<0?"e":"e+")+M}function BA(v,M,P){var W,q;if(M<0){for(q=P+".";++M;q+=P);v=q+v}else if(W=v.length,++M>W){for(q=P,M-=W;--M;q+=P);v+=q}else M<W&&(v=v.slice(0,M)+"."+v.slice(M));return v}A=m(),A.default=A.BigNumber=A,typeof define=="function"&&define.amd?define(function(){return A}):typeof lr<"u"&&lr.exports?lr.exports=A:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=A)})(as)});var Bs=T((Ru,cs)=>{cs.exports=function(A,t,r){var n=new A.Uint8Array(r),i=t.pushInt,s=t.pushInt32,c=t.pushInt32Neg,a=t.pushInt64,w=t.pushInt64Neg,N=t.pushFloat,S=t.pushFloatSingle,k=t.pushFloatDouble,m=t.pushTrue,R=t.pushFalse,J=t.pushUndefined,$=t.pushNull,O=t.pushInfinity,eA=t.pushInfinityNeg,L=t.pushNaN,BA=t.pushNaNNeg,v=t.pushArrayStart,M=t.pushArrayStartFixed,P=t.pushArrayStartFixed32,W=t.pushArrayStartFixed64,q=t.pushObjectStart,nA=t.pushObjectStartFixed,tA=t.pushObjectStartFixed32,iA=t.pushObjectStartFixed64,gA=t.pushByteString,pA=t.pushByteStringStart,RA=t.pushUtf8String,qA=t.pushUtf8StringStart,MA=t.pushSimpleUnassigned,lA=t.pushTagStart,HA=t.pushTagStart4,Ae=t.pushTagStart8,WA=t.pushTagUnassigned,ee=t.pushBreak,F=A.Math.pow,Q=0,ae=0,te=0;function fA(E){for(E=E|0,Q=0,ae=E;(Q|0)<(ae|0)&&(te=zo[n[Q]&255](n[Q]|0)|0,!((te|0)>0)););return te|0}function Y(E){return E=E|0,((Q|0)+(E|0)|0)<(ae|0)?0:1}function o(E){return E=E|0,n[E|0]<<8|n[E+1|0]|0}function B(E){return E=E|0,n[E|0]<<24|n[E+1|0]<<16|n[E+2|0]<<8|n[E+3|0]|0}function g(E){return E=E|0,i(E|0),Q=Q+1|0,0}function C(E){return E=E|0,Y(1)|0?1:(i(n[Q+1|0]|0),Q=Q+2|0,0)}function h(E){return E=E|0,Y(2)|0?1:(i(o(Q+1|0)|0),Q=Q+3|0,0)}function f(E){return E=E|0,Y(4)|0?1:(s(o(Q+1|0)|0,o(Q+3|0)|0),Q=Q+5|0,0)}function p(E){return E=E|0,Y(8)|0?1:(a(o(Q+1|0)|0,o(Q+3|0)|0,o(Q+5|0)|0,o(Q+7|0)|0),Q=Q+9|0,0)}function u(E){return E=E|0,i(-1-(E-32|0)|0),Q=Q+1|0,0}function l(E){return E=E|0,Y(1)|0?1:(i(-1-(n[Q+1|0]|0)|0),Q=Q+2|0,0)}function d(E){E=E|0;var z=0;return Y(2)|0?1:(z=o(Q+1|0)|0,i(-1-(z|0)|0),Q=Q+3|0,0)}function I(E){return E=E|0,Y(4)|0?1:(c(o(Q+1|0)|0,o(Q+3|0)|0),Q=Q+5|0,0)}function G(E){return E=E|0,Y(8)|0?1:(w(o(Q+1|0)|0,o(Q+3|0)|0,o(Q+5|0)|0,o(Q+7|0)|0),Q=Q+9|0,0)}function b(E){E=E|0;var z=0,D=0,X=0;return X=E-64|0,Y(X|0)|0?1:(z=Q+1|0,D=(Q+1|0)+(X|0)|0,gA(z|0,D|0),Q=D|0,0)}function H(E){E=E|0;var z=0,D=0,X=0;return Y(1)|0||(X=n[Q+1|0]|0,z=Q+2|0,D=(Q+2|0)+(X|0)|0,Y(X+1|0)|0)?1:(gA(z|0,D|0),Q=D|0,0)}function V(E){E=E|0;var z=0,D=0,X=0;return Y(2)|0||(X=o(Q+1|0)|0,z=Q+3|0,D=(Q+3|0)+(X|0)|0,Y(X+2|0)|0)?1:(gA(z|0,D|0),Q=D|0,0)}function sA(E){E=E|0;var z=0,D=0,X=0;return Y(4)|0||(X=B(Q+1|0)|0,z=Q+5|0,D=(Q+5|0)+(X|0)|0,Y(X+4|0)|0)?1:(gA(z|0,D|0),Q=D|0,0)}function uA(E){return E=E|0,1}function Z(E){return E=E|0,pA(),Q=Q+1|0,0}function U(E){E=E|0;var z=0,D=0,X=0;return X=E-96|0,Y(X|0)|0?1:(z=Q+1|0,D=(Q+1|0)+(X|0)|0,RA(z|0,D|0),Q=D|0,0)}function IA(E){E=E|0;var z=0,D=0,X=0;return Y(1)|0||(X=n[Q+1|0]|0,z=Q+2|0,D=(Q+2|0)+(X|0)|0,Y(X+1|0)|0)?1:(RA(z|0,D|0),Q=D|0,0)}function ce(E){E=E|0;var z=0,D=0,X=0;return Y(2)|0||(X=o(Q+1|0)|0,z=Q+3|0,D=(Q+3|0)+(X|0)|0,Y(X+2|0)|0)?1:(RA(z|0,D|0),Q=D|0,0)}function ye(E){E=E|0;var z=0,D=0,X=0;return Y(4)|0||(X=B(Q+1|0)|0,z=Q+5|0,D=(Q+5|0)+(X|0)|0,Y(X+4|0)|0)?1:(RA(z|0,D|0),Q=D|0,0)}function _e(E){return E=E|0,1}function vA(E){return E=E|0,qA(),Q=Q+1|0,0}function rA(E){return E=E|0,M(E-128|0),Q=Q+1|0,0}function YA(E){return E=E|0,Y(1)|0?1:(M(n[Q+1|0]|0),Q=Q+2|0,0)}function xA(E){return E=E|0,Y(2)|0?1:(M(o(Q+1|0)|0),Q=Q+3|0,0)}function EA(E){return E=E|0,Y(4)|0?1:(P(o(Q+1|0)|0,o(Q+3|0)|0),Q=Q+5|0,0)}function bo(E){return E=E|0,Y(8)|0?1:(W(o(Q+1|0)|0,o(Q+3|0)|0,o(Q+5|0)|0,o(Q+7|0)|0),Q=Q+9|0,0)}function qo(E){return E=E|0,v(),Q=Q+1|0,0}function QA(E){E=E|0;var z=0;return z=E-160|0,Y(z|0)|0?1:(nA(z|0),Q=Q+1|0,0)}function xo(E){return E=E|0,Y(1)|0?1:(nA(n[Q+1|0]|0),Q=Q+2|0,0)}function ko(E){return E=E|0,Y(2)|0?1:(nA(o(Q+1|0)|0),Q=Q+3|0,0)}function Ro(E){return E=E|0,Y(4)|0?1:(tA(o(Q+1|0)|0,o(Q+3|0)|0),Q=Q+5|0,0)}function Mo(E){return E=E|0,Y(8)|0?1:(iA(o(Q+1|0)|0,o(Q+3|0)|0,o(Q+5|0)|0,o(Q+7|0)|0),Q=Q+9|0,0)}function Ho(E){return E=E|0,q(),Q=Q+1|0,0}function Xe(E){return E=E|0,lA(E-192|0|0),Q=Q+1|0,0}function nu(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function iu(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function su(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function ou(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function mA(E){return E=E|0,lA(E-192|0|0),Q=Q+1|0,0}function au(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function cu(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function Bu(E){return E=E|0,lA(E|0),Q=Q+1|0,0}function vo(E){return E=E|0,Y(1)|0?1:(lA(n[Q+1|0]|0),Q=Q+2|0,0)}function Uo(E){return E=E|0,Y(2)|0?1:(lA(o(Q+1|0)|0),Q=Q+3|0,0)}function To(E){return E=E|0,Y(4)|0?1:(HA(o(Q+1|0)|0,o(Q+3|0)|0),Q=Q+5|0,0)}function Yo(E){return E=E|0,Y(8)|0?1:(Ae(o(Q+1|0)|0,o(Q+3|0)|0,o(Q+5|0)|0,o(Q+7|0)|0),Q=Q+9|0,0)}function wA(E){return E=E|0,MA((E|0)-224|0),Q=Q+1|0,0}function Oo(E){return E=E|0,R(),Q=Q+1|0,0}function Jo(E){return E=E|0,m(),Q=Q+1|0,0}function Po(E){return E=E|0,$(),Q=Q+1|0,0}function Zo(E){return E=E|0,J(),Q=Q+1|0,0}function Vo(E){return E=E|0,Y(1)|0?1:(MA(n[Q+1|0]|0),Q=Q+2|0,0)}function jo(E){E=E|0;var z=0,D=0,X=1,Zt=0,pt=0,gu=0;return Y(2)|0?1:(z=n[Q+1|0]|0,D=n[Q+2|0]|0,(z|0)&128&&(X=-1),Zt=+(((z|0)&124)>>2),pt=+(((z|0)&3)<<8|D),+Zt==0?N(+(+X*5960464477539063e-23*+pt)):+Zt==31?+X==1?+pt>0?L():O():+pt>0?BA():eA():N(+(+X*F(2,+(+Zt-25))*+(1024+pt))),Q=Q+3|0,0)}function Ko(E){return E=E|0,Y(4)|0?1:(S(n[Q+1|0]|0,n[Q+2|0]|0,n[Q+3|0]|0,n[Q+4|0]|0),Q=Q+5|0,0)}function Wo(E){return E=E|0,Y(8)|0?1:(k(n[Q+1|0]|0,n[Q+2|0]|0,n[Q+3|0]|0,n[Q+4|0]|0,n[Q+5|0]|0,n[Q+6|0]|0,n[Q+7|0]|0,n[Q+8|0]|0),Q=Q+9|0,0)}function aA(E){return E=E|0,1}function Xo(E){return E=E|0,ee(),Q=Q+1|0,0}var zo=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,C,h,f,p,aA,aA,aA,aA,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,l,d,I,G,aA,aA,aA,aA,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,H,V,sA,uA,aA,aA,aA,Z,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,IA,ce,ye,_e,aA,aA,aA,vA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,rA,YA,xA,EA,bo,aA,aA,aA,qo,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,QA,xo,ko,Ro,Mo,aA,aA,aA,Ho,Xe,Xe,Xe,Xe,Xe,Xe,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,mA,vo,Uo,To,Yo,aA,aA,aA,aA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,wA,Oo,Jo,Po,Zo,Vo,jo,Ko,Wo,aA,aA,aA,Xo];return{parse:fA}}});var bt=T(VA=>{"use strict";var pn=St().BigNumber;VA.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};VA.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};VA.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};VA.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};VA.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};VA.SHIFT32=Math.pow(2,32);VA.SHIFT16=Math.pow(2,16);VA.MAX_SAFE_HIGH=2097151;VA.NEG_ONE=new pn(-1);VA.TEN=new pn(10);VA.TWO=new pn(2);VA.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var fr=T(DA=>{"use strict";var{Buffer:Ic}=require("buffer"),us=St().BigNumber,Es=bt(),gs=Es.SHIFT32,Cc=Es.SHIFT16,dc=2097151;DA.parseHalf=function(A){var t,r,n;return n=A[0]&128?-1:1,t=(A[0]&124)>>2,r=(A[0]&3)<<8|A[1],t?t===31?n*(r?0/0:1/0):n*Math.pow(2,t-25)*(1024+r):n*5960464477539063e-23*r};function pc(e){return e<16?"0"+e.toString(16):e.toString(16)}DA.arrayBufferToBignumber=function(e){let A=e.byteLength,t="";for(let r=0;r<A;r++)t+=pc(e[r]);return new us(t,16)};DA.buildMap=e=>{let A=new Map,t=Object.keys(e),r=t.length;for(let n=0;n<r;n++)A.set(t[n],e[t[n]]);return A};DA.buildInt32=(e,A)=>e*Cc+A;DA.buildInt64=(e,A,t,r)=>{let n=DA.buildInt32(e,A),i=DA.buildInt32(t,r);return n>dc?new us(n).times(gs).plus(i):n*gs+i};DA.writeHalf=function(A,t){let r=Ic.allocUnsafe(4);r.writeFloatBE(t,0);let n=r.readUInt32BE(0);if((n&8191)!==0)return!1;var i=n>>16&32768;let s=n>>23&255,c=n&8388607;if(s>=113&&s<=142)i+=(s-112<<10)+(c>>13);else if(s>=103&&s<113){if(c&(1<<126-s)-1)return!1;i+=c+8388608>>126-s}else return!1;return A.writeUInt16BE(i,0),!0};DA.keySorter=function(e,A){var t=e[0].byteLength,r=A[0].byteLength;return t>r?1:r>t?-1:e[0].compare(A[0])};DA.isNegativeZero=e=>e===0&&1/e<0;DA.nextPowerOf2=e=>{let A=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,A+=1;return 1<<A}});var _n=T((vu,Qs)=>{"use strict";var yn=bt(),wc=yn.MT,Ir=yn.SIMPLE,wn=yn.SYMS,at=class{constructor(A){if(typeof A!="number")throw new Error("Invalid Simple type: "+typeof A);if(A<0||A>255||(A|0)!==A)throw new Error("value must be a small positive integer: "+A);this.value=A}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(A){return A._pushInt(this.value,wc.SIMPLE_FLOAT)}static isSimple(A){return A instanceof at}static decode(A,t){switch(t==null&&(t=!0),A){case Ir.FALSE:return!1;case Ir.TRUE:return!0;case Ir.NULL:return t?null:wn.NULL;case Ir.UNDEFINED:return t?void 0:wn.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return wn.BREAK;default:return new at(A)}}};Qs.exports=at});var Gn=T((Uu,hs)=>{"use strict";var ct=class{constructor(A,t,r){if(this.tag=A,this.value=t,this.err=r,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(A){return A._pushTag(this.tag),A.pushAny(this.value)}convert(A){var t,r;if(r=A!=null?A[this.tag]:void 0,typeof r!="function"&&(r=ct["_tag"+this.tag],typeof r!="function"))return this;try{return r.call(ct,this.value)}catch(n){return t=n,this.err=t,this}}};hs.exports=ct});var Nn=T((Tu,fs)=>{"use strict";var{URL:yc,URLSearchParams:_c,format:Gc}=require("url"),ls="http://localhost",mn=class extends yc{constructor(A="",t=ls){super(A,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};fs.exports={URLWithLegacySupport:mn,URLSearchParams:_c,format:Gc,defaultBase:ls}});var ds=T((Yu,Cs)=>{"use strict";var{URLWithLegacySupport:Is,format:mc}=Nn();Cs.exports=(e,A={},t={},r)=>{let n=A.protocol?A.protocol.replace(":",""):"http";n=(t[n]||r||n)+":";let i;try{i=new Is(e)}catch{i={}}let s=Object.assign({},A,{protocol:n||i.protocol,host:A.host||i.host});return new Is(e,mc(s)).toString()}});var Fn=T((Ou,ps)=>{"use strict";var{URLWithLegacySupport:Nc,format:Fc,URLSearchParams:Sc,defaultBase:bc}=Nn(),qc=ds();ps.exports={URL:Nc,URLSearchParams:Sc,format:Fc,relative:qc,defaultBase:bc}});var Sn=T((Ju,ys)=>{"use strict";var{Buffer:Bt}=require("buffer"),ws=Vr(),xc=St().BigNumber,kc=Bs(),TA=fr(),oA=bt(),Rc=_n(),Mc=Gn(),{URL:Hc}=Fn(),ke=class{constructor(A){A=A||{},!A.size||A.size<65536?A.size=65536:A.size=TA.nextPowerOf2(A.size),this._heap=new ArrayBuffer(A.size),this._heap8=new Uint8Array(this._heap),this._buffer=Bt.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>TA.arrayBufferToBignumber(t),3:t=>oA.NEG_ONE.minus(TA.arrayBufferToBignumber(t)),4:t=>oA.TEN.pow(t[0]).times(t[1]),5:t=>oA.TWO.pow(t[0]).times(t[1]),32:t=>new Hc(t),35:t=>new RegExp(t)},A.tags),this.parser=kc(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var A=this._parents.pop();if(A.length>0)throw new Error(`Missing ${A.length} elements`);switch(A.type){case oA.PARENT.TAG:this._push(this.createTag(A.ref[0],A.ref[1]));break;case oA.PARENT.BYTE_STRING:this._push(this.createByteString(A.ref,A.length));break;case oA.PARENT.UTF8_STRING:this._push(this.createUtf8String(A.ref,A.length));break;case oA.PARENT.MAP:if(A.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(A.ref,A.length));break;case oA.PARENT.OBJECT:if(A.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(A.ref,A.length));break;case oA.PARENT.ARRAY:this._push(this.createArray(A.ref,A.length));break;default:break}this._currentParent&&this._currentParent.type===oA.PARENT.TAG&&this._dec()}_dec(){let A=this._currentParent;A.length<0||(A.length--,A.length===0&&this._closeParent())}_push(A,t){let r=this._currentParent;switch(r.values++,r.type){case oA.PARENT.ARRAY:case oA.PARENT.BYTE_STRING:case oA.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=A:this._ref.push(A),this._dec();break;case oA.PARENT.OBJECT:r.tmpKey!=null?(this._ref[r.tmpKey]=A,r.tmpKey=null,this._dec()):(r.tmpKey=A,typeof r.tmpKey!="string"&&(r.type=oA.PARENT.MAP,r.ref=TA.buildMap(r.ref)));break;case oA.PARENT.MAP:r.tmpKey!=null?(this._ref.set(r.tmpKey,A),r.tmpKey=null,this._dec()):r.tmpKey=A;break;case oA.PARENT.TAG:this._ref.push(A),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(A,t,r){this._parents[this._depth]={type:t,length:r,ref:A,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:oA.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(A,t){let r=this._knownTags[A];return r?r(t):new Mc(A,t)}createMap(A,t){return A}createObject(A,t){return A}createArray(A,t){return A}createByteString(A,t){return Bt.concat(A)}createByteStringFromHeap(A,t){return A===t?Bt.alloc(0):Bt.from(this._heap.slice(A,t))}createInt(A){return A}createInt32(A,t){return TA.buildInt32(A,t)}createInt64(A,t,r,n){return TA.buildInt64(A,t,r,n)}createFloat(A){return A}createFloatSingle(A,t,r,n){return ws.read([A,t,r,n],0,!1,23,4)}createFloatDouble(A,t,r,n,i,s,c,a){return ws.read([A,t,r,n,i,s,c,a],0,!1,52,8)}createInt32Neg(A,t){return-1-TA.buildInt32(A,t)}createInt64Neg(A,t,r,n){let i=TA.buildInt32(A,t),s=TA.buildInt32(r,n);return i>oA.MAX_SAFE_HIGH?oA.NEG_ONE.minus(new xc(i).times(oA.SHIFT32).plus(s)):-1-(i*oA.SHIFT32+s)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(A,t){return A.join("")}createUtf8StringFromHeap(A,t){return A===t?"":this._buffer.toString("utf8",A,t)}createSimpleUnassigned(A){return new Rc(A)}pushInt(A){this._push(this.createInt(A))}pushInt32(A,t){this._push(this.createInt32(A,t))}pushInt64(A,t,r,n){this._push(this.createInt64(A,t,r,n))}pushFloat(A){this._push(this.createFloat(A))}pushFloatSingle(A,t,r,n){this._push(this.createFloatSingle(A,t,r,n))}pushFloatDouble(A,t,r,n,i,s,c,a){this._push(this.createFloatDouble(A,t,r,n,i,s,c,a))}pushInt32Neg(A,t){this._push(this.createInt32Neg(A,t))}pushInt64Neg(A,t,r,n){this._push(this.createInt64Neg(A,t,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],oA.PARENT.ARRAY,-1)}pushArrayStartFixed(A){this._createArrayStartFixed(A)}pushArrayStartFixed32(A,t){let r=TA.buildInt32(A,t);this._createArrayStartFixed(r)}pushArrayStartFixed64(A,t,r,n){let i=TA.buildInt64(A,t,r,n);this._createArrayStartFixed(i)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(A){this._createObjectStartFixed(A)}pushObjectStartFixed32(A,t){let r=TA.buildInt32(A,t);this._createObjectStartFixed(r)}pushObjectStartFixed64(A,t,r,n){let i=TA.buildInt64(A,t,r,n);this._createObjectStartFixed(i)}pushByteStringStart(){this._parents[this._depth]={type:oA.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(A,t){this._push(this.createByteStringFromHeap(A,t))}pushUtf8StringStart(){this._parents[this._depth]={type:oA.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(A,t){this._push(this.createUtf8StringFromHeap(A,t))}pushSimpleUnassigned(A){this._push(this.createSimpleUnassigned(A))}pushTagStart(A){this._parents[this._depth]={type:oA.PARENT.TAG,length:1,ref:[A]}}pushTagStart4(A,t){this.pushTagStart(TA.buildInt32(A,t))}pushTagStart8(A,t,r,n){this.pushTagStart(TA.buildInt64(A,t,r,n))}pushTagUnassigned(A){this._push(this.createTag(A))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(A){if(A===0){this._push(this.createObject({}));return}this._createParent({},oA.PARENT.OBJECT,A)}_createArrayStartFixed(A){if(A===0){this._push(this.createArray([]));return}this._createParent(new Array(A),oA.PARENT.ARRAY,A)}_decode(A){if(A.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(A);let t=this.parser.parse(A.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(t>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(A){return this._decode(A),this._res[0]}decodeAll(A){return this._decode(A),this._res}static decode(A,t){return typeof A=="string"&&(A=Bt.from(A,t||"hex")),new ke({size:A.length}).decodeFirst(A)}static decodeAll(A,t){return typeof A=="string"&&(A=Bt.from(A,t||"hex")),new ke({size:A.length}).decodeAll(A)}};ke.decodeFirst=ke.decode;ys.exports=ke});var ms=T((Pu,Gs)=>{"use strict";var{Buffer:bn}=require("buffer"),vc=Sn(),Uc=fr(),qt=class extends vc{createTag(A,t){return`${A}(${t})`}createInt(A){return super.createInt(A).toString()}createInt32(A,t){return super.createInt32(A,t).toString()}createInt64(A,t,r,n){return super.createInt64(A,t,r,n).toString()}createInt32Neg(A,t){return super.createInt32Neg(A,t).toString()}createInt64Neg(A,t,r,n){return super.createInt64Neg(A,t,r,n).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(A){let t=super.createFloat(A);return Uc.isNegativeZero(A)?"-0_1":`${t}_1`}createFloatSingle(A,t,r,n){return`${super.createFloatSingle(A,t,r,n)}_2`}createFloatDouble(A,t,r,n,i,s,c,a){return`${super.createFloatDouble(A,t,r,n,i,s,c,a)}_3`}createByteString(A,t){let r=A.join(", ");return t===-1?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(A,t){return`h'${bn.from(super.createByteStringFromHeap(A,t)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(A){return`simple(${A})`}createArray(A,t){let r=super.createArray(A,t);return t===-1?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(A,t){let r=super.createMap(A),n=Array.from(r.keys()).reduce(_s(r),"");return t===-1?`{_ ${n}}`:`{${n}}`}createObject(A,t){let r=super.createObject(A),n=Object.keys(r).reduce(_s(r),"");return t===-1?`{_ ${n}}`:`{${n}}`}createUtf8String(A,t){let r=A.join(", ");return t===-1?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(A,t){return`"${bn.from(super.createUtf8StringFromHeap(A,t)).toString("utf8")}"`}static diagnose(A,t){return typeof A=="string"&&(A=bn.from(A,t||"hex")),new qt().decodeFirst(A)}};Gs.exports=qt;function _s(e){return(A,t)=>A?`${A}, ${t}: ${e[t]}`:`${t}: ${e[t]}`}});var qs=T((Zu,bs)=>{"use strict";var{Buffer:fe}=require("buffer"),{URL:Tc}=Fn(),xn=St().BigNumber,qn=fr(),yA=bt(),re=yA.MT,Cr=yA.NUMBYTES,Ns=yA.SHIFT32,Fs=yA.SYMS,gt=yA.TAG,Yc=yA.MT.SIMPLE_FLOAT<<5|yA.NUMBYTES.TWO,Oc=yA.MT.SIMPLE_FLOAT<<5|yA.NUMBYTES.FOUR,Jc=yA.MT.SIMPLE_FLOAT<<5|yA.NUMBYTES.EIGHT,Pc=yA.MT.SIMPLE_FLOAT<<5|yA.SIMPLE.TRUE,Zc=yA.MT.SIMPLE_FLOAT<<5|yA.SIMPLE.FALSE,Vc=yA.MT.SIMPLE_FLOAT<<5|yA.SIMPLE.UNDEFINED,Ss=yA.MT.SIMPLE_FLOAT<<5|yA.SIMPLE.NULL,jc=new xn("0x20000000000000"),Kc=fe.from("f97e00","hex"),Wc=fe.from("f9fc00","hex"),Xc=fe.from("f97c00","hex");function zc(e){return{}.toString.call(e).slice(8,-1)}var ut=class{constructor(A){A=A||{},this.streaming=typeof A.stream=="function",this.onData=A.stream,this.semanticTypes=[[Tc,this._pushUrl],[xn,this._pushBigNumber]];let t=A.genTypes||[],r=t.length;for(let n=0;n<r;n++)this.addSemanticType(t[n][0],t[n][1]);this._reset()}addSemanticType(A,t){let r=this.semanticTypes.length;for(let n=0;n<r;n++)if(this.semanticTypes[n][0]===A){let s=this.semanticTypes[n][1];return this.semanticTypes[n][1]=t,s}return this.semanticTypes.push([A,t]),null}push(A){return A&&(this.result[this.offset]=A,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=A.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(A,t,r){return this.result[this.offset]=A,this.resultMethod[this.offset]=t,this.resultLength[this.offset]=r,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(A){return this.pushWrite(A,1,1)}_pushUInt16BE(A){return this.pushWrite(A,2,2)}_pushUInt32BE(A){return this.pushWrite(A,3,4)}_pushDoubleBE(A){return this.pushWrite(A,4,8)}_pushNaN(){return this.push(Kc)}_pushInfinity(A){let t=A<0?Wc:Xc;return this.push(t)}_pushFloat(A){let t=fe.allocUnsafe(2);if(qn.writeHalf(t,A)&&qn.parseHalf(t)===A)return this._pushUInt8(Yc)&&this.push(t);let r=fe.allocUnsafe(4);return r.writeFloatBE(A,0),r.readFloatBE(0)===A?this._pushUInt8(Oc)&&this.push(r):this._pushUInt8(Jc)&&this._pushDoubleBE(A)}_pushInt(A,t,r){let n=t<<5;return A<24?this._pushUInt8(n|A):A<=255?this._pushUInt8(n|Cr.ONE)&&this._pushUInt8(A):A<=65535?this._pushUInt8(n|Cr.TWO)&&this._pushUInt16BE(A):A<=4294967295?this._pushUInt8(n|Cr.FOUR)&&this._pushUInt32BE(A):A<=Number.MAX_SAFE_INTEGER?this._pushUInt8(n|Cr.EIGHT)&&this._pushUInt32BE(Math.floor(A/Ns))&&this._pushUInt32BE(A%Ns):t===re.NEG_INT?this._pushFloat(r):this._pushFloat(A)}_pushIntNum(A){return A<0?this._pushInt(-A-1,re.NEG_INT,A):this._pushInt(A,re.POS_INT)}_pushNumber(A){switch(!1){case A===A:return this._pushNaN(A);case isFinite(A):return this._pushInfinity(A);case A%1!==0:return this._pushIntNum(A);default:return this._pushFloat(A)}}_pushString(A){let t=fe.byteLength(A,"utf8");return this._pushInt(t,re.UTF8_STRING)&&this.pushWrite(A,5,t)}_pushBoolean(A){return this._pushUInt8(A?Pc:Zc)}_pushUndefined(A){return this._pushUInt8(Vc)}_pushArray(A,t){let r=t.length;if(!A._pushInt(r,re.ARRAY))return!1;for(let n=0;n<r;n++)if(!A.pushAny(t[n]))return!1;return!0}_pushTag(A){return this._pushInt(A,re.TAG)}_pushDate(A,t){return A._pushTag(gt.DATE_EPOCH)&&A.pushAny(Math.round(t/1e3))}_pushBuffer(A,t){return A._pushInt(t.length,re.BYTE_STRING)&&A.push(t)}_pushNoFilter(A,t){return A._pushBuffer(A,t.slice())}_pushRegexp(A,t){return A._pushTag(gt.REGEXP)&&A.pushAny(t.source)}_pushSet(A,t){if(!A._pushInt(t.size,re.ARRAY))return!1;for(let r of t)if(!A.pushAny(r))return!1;return!0}_pushUrl(A,t){return A._pushTag(gt.URI)&&A.pushAny(t.format())}_pushBigint(A){let t=gt.POS_BIGINT;A.isNegative()&&(A=A.negated().minus(1),t=gt.NEG_BIGINT);let r=A.toString(16);r.length%2&&(r="0"+r);let n=fe.from(r,"hex");return this._pushTag(t)&&this._pushBuffer(this,n)}_pushBigNumber(A,t){if(t.isNaN())return A._pushNaN();if(!t.isFinite())return A._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return A._pushBigint(t);if(!(A._pushTag(gt.DECIMAL_FRAC)&&A._pushInt(2,re.ARRAY)))return!1;let r=t.decimalPlaces(),n=t.multipliedBy(new xn(10).pow(r));return A._pushIntNum(-r)?n.abs().isLessThan(jc)?A._pushIntNum(n.toNumber()):A._pushBigint(n):!1}_pushMap(A,t){return A._pushInt(t.size,re.MAP)?this._pushRawMap(t.size,Array.from(t)):!1}_pushObject(A){if(!A)return this._pushUInt8(Ss);for(var t=this.semanticTypes.length,r=0;r<t;r++)if(A instanceof this.semanticTypes[r][0])return this.semanticTypes[r][1].call(A,this,A);var n=A.encodeCBOR;if(typeof n=="function")return n.call(A,this);var i=Object.keys(A),s=i.length;return this._pushInt(s,re.MAP)?this._pushRawMap(s,i.map(c=>[c,A[c]])):!1}_pushRawMap(A,t){t=t.map(function(n){return n[0]=ut.encode(n[0]),n}).sort(qn.keySorter);for(var r=0;r<A;r++)if(!this.push(t[r][0])||!this.pushAny(t[r][1]))return!1;return!0}write(A){return this.pushAny(A)}pushAny(A){var t=zc(A);switch(t){case"Number":return this._pushNumber(A);case"String":return this._pushString(A);case"Boolean":return this._pushBoolean(A);case"Object":return this._pushObject(A);case"Array":return this._pushArray(this,A);case"Uint8Array":return this._pushBuffer(this,fe.isBuffer(A)?A:fe.from(A));case"Null":return this._pushUInt8(Ss);case"Undefined":return this._pushUndefined(A);case"Map":return this._pushMap(this,A);case"Set":return this._pushSet(this,A);case"URL":return this._pushUrl(this,A);case"BigNumber":return this._pushBigNumber(this,A);case"Date":return this._pushDate(this,A);case"RegExp":return this._pushRegexp(this,A);case"Symbol":switch(A){case Fs.NULL:return this._pushObject(null);case Fs.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+A.toString())}default:throw new Error("Unknown type: "+typeof A+", "+(A?A.toString():""))}}finalize(){if(this.offset===0)return null;for(var A=this.result,t=this.resultLength,r=this.resultMethod,n=this.offset,i=0,s=0;s<n;s++)i+=t[s];var c=fe.allocUnsafe(i),a=0,w=0;for(s=0;s<n;s++){switch(w=t[s],r[s]){case 0:A[s].copy(c,a);break;case 1:c.writeUInt8(A[s],a,!0);break;case 2:c.writeUInt16BE(A[s],a,!0);break;case 3:c.writeUInt32BE(A[s],a,!0);break;case 4:c.writeDoubleBE(A[s],a,!0);break;case 5:c.write(A[s],a,w,"utf8");break;default:throw new Error("unkown method")}a+=w}var N=c;return this._reset(),N}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(A){let t=new ut;if(!t.pushAny(A))throw new Error("Failed to encode input");return t.finalize()}};bs.exports=ut});var kn=T(_A=>{"use strict";_A.Diagnose=ms();_A.Decoder=Sn();_A.Encoder=qs();_A.Simple=_n();_A.Tagged=Gn();_A.decodeAll=_A.Decoder.decodeAll;_A.decodeFirst=_A.Decoder.decodeFirst;_A.diagnose=_A.Diagnose.diagnose;_A.encode=_A.Encoder.encode;_A.decode=_A.Decoder.decode;_A.leveldb={decode:_A.Decoder.decodeAll,encode:_A.Encoder.encode,buffer:!0,name:"cbor"}});var Ce=T(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.compare=Ie.fromHex=Ie.toHex=Ie.concat=void 0;function Dc(...e){let A=new Uint8Array(e.reduce((r,n)=>r+n.byteLength,0)),t=0;for(let r of e)A.set(new Uint8Array(r),t),t+=r.byteLength;return A.buffer}Ie.concat=Dc;function $c(e){return[...new Uint8Array(e)].map(A=>A.toString(16).padStart(2,"0")).join("")}Ie.toHex=$c;var Lc=new RegExp(/^([0-9A-F]{2})*$/i);function AB(e){if(!Lc.test(e))throw new Error("Invalid hexadecimal string.");let A=[...e].reduce((t,r,n)=>(t[n/2|0]=(t[n/2|0]||"")+r,t),[]).map(t=>Number.parseInt(t,16));return new Uint8Array(A).buffer}Ie.fromHex=AB;function eB(e,A){if(e.byteLength!==A.byteLength)return e.byteLength-A.byteLength;let t=new Uint8Array(e),r=new Uint8Array(A);for(let n=0;n<t.length;n++)if(t[n]!==r[n])return t[n]-r[n];return 0}Ie.compare=eB});var kt=T(de=>{"use strict";var tB=de&&de.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(de,"__esModule",{value:!0});de.requestIdOf=de.hashValue=de.hash=void 0;var xs=Ft(),rB=tB(kn()),nB=Lr(),dr=Ce();function Re(e){return nB.sha256.create().update(new Uint8Array(e)).arrayBuffer()}de.hash=Re;function xt(e){if(e instanceof rB.default.Tagged)return xt(e.value);if(typeof e=="string")return ks(e);if(typeof e=="number")return Re(xs.lebEncode(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return Re(e);if(Array.isArray(e)){let A=e.map(xt);return Re(dr.concat(...A))}else{if(e&&typeof e=="object"&&e._isPrincipal)return Re(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return xt(e.toHash());if(typeof e=="bigint")return Re(xs.lebEncode(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}de.hashValue=xt;var ks=e=>{let A=new TextEncoder().encode(e);return Re(A)};function iB(e){let r=Object.entries(e).filter(([,s])=>s!==void 0).map(([s,c])=>{let a=ks(s),w=xt(c);return[a,w]}).sort(([s],[c])=>dr.compare(s,c)),n=dr.concat(...r.map(s=>dr.concat(...s)));return Re(n)}de.requestIdOf=iB});var Hn=T(pe=>{"use strict";var sB=pe&&pe.__rest||function(e,A){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&A.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)A.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(t[r[n]]=e[r[n]]);return t};Object.defineProperty(pe,"__esModule",{value:!0});pe.createIdentityDescriptor=pe.AnonymousIdentity=pe.SignIdentity=void 0;var Rs=ue(),oB=kt(),Ms=Ce(),aB=new TextEncoder().encode(`
2
- ic-request`),Rn=class{getPrincipal(){return this._principal||(this._principal=Rs.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(A){let{body:t}=A,r=sB(A,["body"]),n=await oB.requestIdOf(t);return Object.assign(Object.assign({},r),{body:{content:t,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(Ms.concat(aB,n))}})}};pe.SignIdentity=Rn;var Mn=class{getPrincipal(){return Rs.Principal.anonymous()}async transformRequest(A){return Object.assign(Object.assign({},A),{body:{content:A.body}})}};pe.AnonymousIdentity=Mn;function cB(e){return"getPublicKey"in e?{type:"PublicKeyIdentity",publicKey:Ms.toHex(e.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}pe.createIdentityDescriptor=cB});var Tn=T(cA=>{"use strict";Object.defineProperty(cA,"__esModule",{value:!0});var BB=9007199254740992;function Ne(e,...A){let t=new Uint8Array(e.byteLength+A.reduce((n,i)=>n+i.byteLength,0));t.set(new Uint8Array(e),0);let r=e.byteLength;for(let n of A)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}function ne(e,A,t){t=t.replace(/[^0-9a-fA-F]/g,"");let r=2**(A-24);t=t.slice(-r*2).padStart(r*2,"0");let n=[(e<<5)+A].concat(t.match(/../g).map(i=>parseInt(i,16)));return new Uint8Array(n).buffer}function pr(e,A){if(A<24)return new Uint8Array([(e<<5)+A]).buffer;{let t=A<=255?24:A<=65535?25:A<=4294967295?26:27;return ne(e,t,A.toString(16))}}function Hs(e){let A=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);r<128?A.push(r):r<2048?A.push(192|r>>6,128|r&63):r<55296||r>=57344?A.push(224|r>>12,128|r>>6&63,128|r&63):(t++,r=(r&1023)<<10|e.charCodeAt(t)&1023,A.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63))}return Ne(new Uint8Array(pr(3,e.length)),new Uint8Array(A))}function gB(e,A){if(e==14277111)return Ne(new Uint8Array([217,217,247]),A);if(e<24)return Ne(new Uint8Array([(6<<5)+e]),A);{let t=e<=255?24:e<=65535?25:e<=4294967295?26:27,r=2**(t-24),n=e.toString(16).slice(-r*2).padStart(r*2,"0"),i=[(6<<5)+t].concat(n.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}}cA.tagged=gB;function Rt(e){return new Uint8Array(e).buffer}cA.raw=Rt;function vn(e){if(isNaN(e))throw new RangeError("Invalid number.");e=Math.min(Math.max(0,e),23);let A=[(0<<5)+e];return new Uint8Array(A).buffer}cA.uSmall=vn;function vs(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),255),e=e.toString(16),ne(0,24,e)}cA.u8=vs;function Us(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),65535),e=e.toString(16),ne(0,25,e)}cA.u16=Us;function Ts(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),4294967295),e=e.toString(16),ne(0,26,e)}cA.u32=Ts;function Un(e,A){if(typeof e=="string"&&A==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return ne(0,27,e)}if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),BB),e=e.toString(16),ne(0,27,e)}cA.u64=Un;function Ys(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return vn(0);e=Math.min(Math.max(0,-e),24)-1;let A=[(1<<5)+e];return new Uint8Array(A).buffer}cA.iSmall=Ys;function Os(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),255),e=e.toString(16),ne(1,24,e)}cA.i8=Os;function Js(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),65535),e=e.toString(16),ne(1,25,e)}cA.i16=Js;function Ps(e,A){if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),4294967295),e=e.toString(16),ne(1,26,e)}cA.i32=Ps;function Zs(e,A){if(typeof e=="string"&&A==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let t=!1,r=e.split("").reduceRight((n,i)=>{if(t)return i+n;let s=parseInt(i,16)-1;return s>=0?(t=!0,s.toString(16)+n):"f"+n},"");return t?ne(1,27,r):Un(0)}if(e=parseInt(""+e,A),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),9007199254740992),e=e.toString(16),ne(1,27,e)}cA.i64=Zs;function uB(e){return e>=0?e<24?vn(e):e<=255?vs(e):e<=65535?Us(e):e<=4294967295?Ts(e):Un(e):e>=-24?Ys(e):e>=-255?Os(e):e>=-65535?Js(e):e>=-4294967295?Ps(e):Zs(e)}cA.number=uB;function EB(e){return Ne(pr(2,e.byteLength),e)}cA.bytes=EB;function QB(e){return Hs(e)}cA.string=QB;function hB(e){return Ne(pr(4,e.length),...e)}cA.array=hB;function lB(e,A=!1){e instanceof Map||(e=new Map(Object.entries(e)));let t=Array.from(e.entries());return A&&(t=t.sort(([r],[n])=>r.localeCompare(n))),Ne(pr(5,e.size),...t.map(([r,n])=>Ne(Hs(r),n)))}cA.map=lB;function fB(e){let A=new Float32Array([e]);return Ne(new Uint8Array([(7<<5)+26]),new Uint8Array(A.buffer))}cA.singleFloat=fB;function IB(e){let A=new Float64Array([e]);return Ne(new Uint8Array([(7<<5)+27]),new Uint8Array(A.buffer))}cA.doubleFloat=IB;function CB(e){return e?Vs():js()}cA.bool=CB;function Vs(){return Rt(new Uint8Array([(7<<5)+21]))}cA.true_=Vs;function js(){return Rt(new Uint8Array([(7<<5)+20]))}cA.false_=js;function dB(){return Rt(new Uint8Array([(7<<5)+22]))}cA.null_=dB;function pB(){return Rt(new Uint8Array([(7<<5)+23]))}cA.undefined_=pB});var Ks=T(Me=>{"use strict";var wB=Me&&Me.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)Object.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A};Object.defineProperty(Me,"__esModule",{value:!0});var ie=wB(Tn()),yB=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],wr=class{constructor(A,t=!1){this._serializer=A,this._stable=t,this.name="jsonDefault",this.priority=-100}match(A){return["undefined","boolean","number","string","object"].indexOf(typeof A)!=-1}encode(A){switch(typeof A){case"undefined":return ie.undefined_();case"boolean":return ie.bool(A);case"number":return Math.floor(A)===A?ie.number(A):ie.doubleFloat(A);case"string":return ie.string(A);case"object":if(A===null)return ie.null_();if(Array.isArray(A))return ie.array(A.map(t=>this._serializer.serializeValue(t)));if(yB.find(t=>A instanceof t))return ie.bytes(A.buffer);if(Object.getOwnPropertyNames(A).indexOf("toJSON")!==-1)return this.encode(A.toJSON());if(A instanceof Map){let t=new Map;for(let[r,n]of A.entries())t.set(r,this._serializer.serializeValue(n));return ie.map(t,this._stable)}else{let t=new Map;for(let[r,n]of Object.entries(A))t.set(r,this._serializer.serializeValue(n));return ie.map(t,this._stable)}default:throw new Error("Invalid value.")}}};Me.JsonDefaultCborEncoder=wr;var yr=class{constructor(){this.name="cborEncoder",this.priority=-90}match(A){return typeof A=="object"&&typeof A.toCBOR=="function"}encode(A){return A.toCBOR()}};Me.ToCborEncoder=yr;var _r=class{constructor(){this._encoders=new Set}static withDefaultEncoders(A=!1){let t=new this;return t.addEncoder(new wr(t,A)),t.addEncoder(new yr),t}removeEncoder(A){for(let t of this._encoders.values())t.name==A&&this._encoders.delete(t)}addEncoder(A){this._encoders.add(A)}getEncoderFor(A){let t=null;for(let r of this._encoders)(!t||r.priority>t.priority)&&r.match(A)&&(t=r);if(t===null)throw new Error("Could not find an encoder for value.");return t}serializeValue(A){return this.getEncoderFor(A).encode(A)}serialize(A){return this.serializeValue(A)}};Me.CborSerializer=_r;var Yn=class extends _r{serialize(A){return ie.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(A))]))}};Me.SelfDescribeCborSerializer=Yn});var Gr=T(Ze=>{"use strict";function _B(e){for(var A in e)Ze.hasOwnProperty(A)||(Ze[A]=e[A])}var GB=Ze&&Ze.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)Object.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A};Object.defineProperty(Ze,"__esModule",{value:!0});_B(Ks());var mB=GB(Tn());Ze.value=mB});var Nr=T(kA=>{"use strict";var NB=kA&&kA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),FB=kA&&kA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),SB=kA&&kA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&NB(A,e,t);return FB(A,e),A},bB=kA&&kA.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(kA,"__esModule",{value:!0});kA.decode=kA.encode=kA.CborTag=void 0;var qB=bB(kn()),Et=SB(Gr()),xB=Gr(),On=Ce(),Jn=class{get name(){return"Principal"}get priority(){return 0}match(A){return A&&A._isPrincipal===!0}encode(A){return Et.value.bytes(A.toUint8Array())}},Pn=class{get name(){return"Buffer"}get priority(){return 1}match(A){return A instanceof ArrayBuffer||ArrayBuffer.isView(A)}encode(A){return Et.value.bytes(new Uint8Array(A))}},Zn=class{get name(){return"BigInt"}get priority(){return 1}match(A){return typeof A=="bigint"}encode(A){return A>BigInt(0)?Et.value.tagged(2,Et.value.bytes(On.fromHex(A.toString(16)))):Et.value.tagged(3,Et.value.bytes(On.fromHex((BigInt("-1")*A).toString(16))))}},mr=xB.SelfDescribeCborSerializer.withDefaultEncoders(!0);mr.addEncoder(new Jn);mr.addEncoder(new Pn);mr.addEncoder(new Zn);var Xs;(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(Xs=kA.CborTag||(kA.CborTag={}));function kB(e){return mr.serialize(e)}kA.encode=kB;function Ws(e){let A=e.byteLength,t=BigInt(0);for(let r=0;r<A;r++)t=t*BigInt(256)+BigInt(e[r]);return t}var Vn=class extends qB.default.Decoder{createByteString(A){return On.concat(...A)}createByteStringFromHeap(A,t){return A===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(A,t))}};function RB(e){let A=new Uint8Array(e);return new Vn({size:A.byteLength,tags:{2:r=>Ws(r),3:r=>-Ws(r),[Xs.Semantic]:r=>r}}).decodeFirst(A)}kA.decode=RB});var Mt=T(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.makeNonce=Ve.SubmitRequestType=void 0;var MB;(function(e){e.Call="call"})(MB=Ve.SubmitRequestType||(Ve.SubmitRequestType={}));function HB(){let e=new ArrayBuffer(16),A=new DataView(e),t=BigInt(+Date.now()),r=Math.floor(Math.random()*4294967295),n=Math.floor(Math.random()*4294967295);if(typeof A.setBigUint64=="function")A.setBigUint64(0,t);else{let i=BigInt(1)<<BigInt(32);A.setUint32(0,Number(t>>BigInt(32))),A.setUint32(4,Number(t%i))}return A.setUint32(8,r),A.setUint32(12,n),e}Ve.makeNonce=HB});var Sr=T(PA=>{"use strict";var vB=PA&&PA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),UB=PA&&PA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),TB=PA&&PA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&vB(A,e,t);return UB(A,e),A};Object.defineProperty(PA,"__esModule",{value:!0});PA.makeExpiryTransform=PA.makeNonceTransform=PA.Expiry=void 0;var YB=Ft(),OB=TB(Gr()),JB=Mt(),PB=BigInt(1e6),ZB=BigInt(60*1e3),Fr=class{constructor(A){this._value=(BigInt(Date.now())+BigInt(A)-ZB)*PB}toCBOR(){return OB.value.u64(this._value.toString(16),16)}toHash(){return YB.lebEncode(this._value)}};PA.Expiry=Fr;function VB(e=JB.makeNonce){return async A=>{A.endpoint==="call"&&(A.body.nonce=e())}}PA.makeNonceTransform=VB;function jB(e){return async A=>{A.body.ingress_expiry=new Fr(e)}}PA.makeExpiryTransform=jB});var Ls=T(GA=>{"use strict";var Ds=GA&&GA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),KB=GA&&GA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),WB=GA&&GA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&Ds(A,e,t);return KB(A,e),A},XB=GA&&GA.__exportStar||function(e,A){for(var t in e)t!=="default"&&!A.hasOwnProperty(t)&&Ds(A,e,t)};Object.defineProperty(GA,"__esModule",{value:!0});GA.HttpAgent=GA.IdentityInvalidError=GA.RequestStatusResponseStatus=void 0;var je=ue(),$s=Ar(),zB=Hn(),Qt=WB(Nr()),DB=kt(),$B=Ce(),br=Sr(),zs=Mt();XB(Sr(),GA);var LB=Mt();Object.defineProperty(GA,"makeNonce",{enumerable:!0,get:function(){return LB.makeNonce}});var Ag;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(Ag=GA.RequestStatusResponseStatus||(GA.RequestStatusResponseStatus={}));var jn=5*60*1e3,eg="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",tg="ic0.app",rg=".ic0.app",Ht=class extends $s.AgentError{constructor(A){super(A),this.message=A}},Ke=class extends $s.AgentError{constructor(A){super(A),this.message=A}};GA.IdentityInvalidError=Ke;function ng(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new Ht("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)e=global.fetch.bind(global);else throw new Ht("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(e=self.fetch.bind(self));if(e)return e;throw new Ht("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var vt=class{constructor(A={}){if(this.rootKey=$B.fromHex(eg),this._pipeline=[],this._rootKeyFetched=!1,A.source){if(!(A.source instanceof vt))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...A.source._pipeline],this._identity=A.source._identity,this._fetch=A.source._fetch,this._host=A.source._host,this._credentials=A.source._credentials}else this._fetch=A.fetch||ng()||fetch.bind(global);if(A.host!==void 0)!A.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+A.host):this._host=new URL(A.host);else if(A.source!==void 0)this._host=A.source._host;else{let t=typeof window<"u"?window.location:void 0;if(!t)throw new Error("Must specify a host to connect to.");this._host=new URL(t+"")}if(this._host.hostname.endsWith(rg)&&(this._host.hostname=tg),A.credentials){let{name:t,password:r}=A.credentials;this._credentials=`${t}${r?":"+r:""}`}this._identity=Promise.resolve(A.identity||new zB.AnonymousIdentity),A.disableNonce||this.addTransform(br.makeNonceTransform(zs.makeNonce))}addTransform(A,t=A.priority||0){let r=this._pipeline.findIndex(n=>(n.priority||0)<t);this._pipeline.splice(r>=0?r:this._pipeline.length,0,Object.assign(A,{priority:t}))}async getPrincipal(){if(!this._identity)throw new Ke("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(A,t,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Ke("This identity has expired due this application's security policy. Please refresh your authentication.");let i=je.Principal.from(A),s=t.effectiveCanisterId?je.Principal.from(t.effectiveCanisterId):i,c=n.getPrincipal()||je.Principal.anonymous(),a={request_type:zs.SubmitRequestType.Call,canister_id:i,method_name:t.methodName,arg:t.arg,sender:c,ingress_expiry:new br.Expiry(jn)},w=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:a});w=await n.transformRequest(w);let N=Qt.encode(w.body),[S,k]=await Promise.all([this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign({},w.request),{body:N})),DB.requestIdOf(a)]);if(!S.ok)throw new Error(`Server returned an error:
3
- Code: ${S.status} (${S.statusText})
4
- Body: ${await S.text()}
5
- `);return{requestId:k,response:{ok:S.ok,status:S.status,statusText:S.statusText}}}async query(A,t,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Ke("This identity has expired due this application's security policy. Please refresh your authentication.");let i=typeof A=="string"?je.Principal.fromText(A):A,s=(n==null?void 0:n.getPrincipal())||je.Principal.anonymous(),c={request_type:"query",canister_id:i,method_name:t.methodName,arg:t.arg,sender:s,ingress_expiry:new br.Expiry(jn)},a=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:c});a=await(n==null?void 0:n.transformRequest(a));let w=Qt.encode(a.body),N=await this._fetch(""+new URL(`/api/v2/canister/${i.toText()}/query`,this._host),Object.assign(Object.assign({},a.request),{body:w}));if(!N.ok)throw new Error(`Server returned an error:
6
- Code: ${N.status} (${N.statusText})
7
- Body: ${await N.text()}
8
- `);return Qt.decode(await N.arrayBuffer())}async readState(A,t,r){let n=typeof A=="string"?je.Principal.fromText(A):A,i=await(r!==void 0?await r:await this._identity);if(!i)throw new Ke("This identity has expired due this application's security policy. Please refresh your authentication.");let s=(i==null?void 0:i.getPrincipal())||je.Principal.anonymous(),c=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:s,ingress_expiry:new br.Expiry(jn)}});c=await(i==null?void 0:i.transformRequest(c));let a=Qt.encode(c.body),w=await this._fetch(""+new URL(`/api/v2/canister/${n}/read_state`,this._host),Object.assign(Object.assign({},c.request),{body:a}));if(!w.ok)throw new Error(`Server returned an error:
9
- Code: ${w.status} (${w.statusText})
10
- Body: ${await w.text()}
11
- `);return Qt.decode(await w.arrayBuffer())}async status(){let A=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},t=await this._fetch(""+new URL("/api/v2/status",this._host),{headers:A});if(!t.ok)throw new Error(`Server returned an error:
1
+ "use strict";var na=Object.create;var jt=Object.defineProperty;var ia=Object.getOwnPropertyDescriptor;var sa=Object.getOwnPropertyNames;var oa=Object.getPrototypeOf,aa=Object.prototype.hasOwnProperty;var J=(A,e)=>()=>(e||A((e={exports:{}}).exports,e),e.exports),ca=(A,e)=>{for(var t in e)jt(A,t,{get:e[t],enumerable:!0})},fi=(A,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sa(e))!aa.call(A,n)&&n!==t&&jt(A,n,{get:()=>e[n],enumerable:!(r=ia(e,n))||r.enumerable});return A};var di=(A,e,t)=>(t=A!=null?na(oa(A)):{},fi(e||!A||!A.__esModule?jt(t,"default",{value:A,enumerable:!0}):t,A)),Ba=A=>fi(jt({},"__esModule",{value:!0}),A);var yi=J(Kt=>{"use strict";Kt.byteLength=ua;Kt.toByteArray=la;Kt.fromByteArray=fa;var Be=[],XA=[],ga=typeof Uint8Array<"u"?Uint8Array:Array,Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Je=0,wi=Vr.length;Je<wi;++Je)Be[Je]=Vr[Je],XA[Vr.charCodeAt(Je)]=Je;var Je,wi;XA["-".charCodeAt(0)]=62;XA["_".charCodeAt(0)]=63;function _i(A){var e=A.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=A.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function ua(A){var e=_i(A),t=e[0],r=e[1];return(t+r)*3/4-r}function Ea(A,e,t){return(e+t)*3/4-t}function la(A){var e,t=_i(A),r=t[0],n=t[1],i=new ga(Ea(A,r,n)),s=0,c=n>0?r-4:r,a;for(a=0;a<c;a+=4)e=XA[A.charCodeAt(a)]<<18|XA[A.charCodeAt(a+1)]<<12|XA[A.charCodeAt(a+2)]<<6|XA[A.charCodeAt(a+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return n===2&&(e=XA[A.charCodeAt(a)]<<2|XA[A.charCodeAt(a+1)]>>4,i[s++]=e&255),n===1&&(e=XA[A.charCodeAt(a)]<<10|XA[A.charCodeAt(a+1)]<<4|XA[A.charCodeAt(a+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function ha(A){return Be[A>>18&63]+Be[A>>12&63]+Be[A>>6&63]+Be[A&63]}function Qa(A,e,t){for(var r,n=[],i=e;i<t;i+=3)r=(A[i]<<16&16711680)+(A[i+1]<<8&65280)+(A[i+2]&255),n.push(ha(r));return n.join("")}function fa(A){for(var e,t=A.length,r=t%3,n=[],i=16383,s=0,c=t-r;s<c;s+=i)n.push(Qa(A,s,s+i>c?c:s+i));return r===1?(e=A[t-1],n.push(Be[e>>2]+Be[e<<4&63]+"==")):r===2&&(e=(A[t-2]<<8)+A[t-1],n.push(Be[e>>10]+Be[e>>4&63]+Be[e<<2&63]+"=")),n.join("")}});var jr=J(Zr=>{Zr.read=function(A,e,t,r,n){var i,s,c=n*8-r-1,a=(1<<c)-1,p=a>>1,m=-7,F=t?n-1:0,R=t?-1:1,y=A[e+F];for(F+=R,i=y&(1<<-m)-1,y>>=-m,m+=c;m>0;i=i*256+A[e+F],F+=R,m-=8);for(s=i&(1<<-m)-1,i>>=-m,m+=r;m>0;s=s*256+A[e+F],F+=R,m-=8);if(i===0)i=1-p;else{if(i===a)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-p}return(y?-1:1)*s*Math.pow(2,i-r)};Zr.write=function(A,e,t,r,n,i){var s,c,a,p=i*8-n-1,m=(1<<p)-1,F=m>>1,R=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=r?0:i-1,q=r?1:-1,O=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,s=m):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+F>=1?e+=R/a:e+=R*Math.pow(2,1-F),e*a>=2&&(s++,a/=2),s+F>=m?(c=0,s=m):s+F>=1?(c=(e*a-1)*Math.pow(2,n),s=s+F):(c=e*Math.pow(2,F-1)*Math.pow(2,n),s=0));n>=8;A[t+y]=c&255,y+=q,c/=256,n-=8);for(s=s<<n|c,p+=n;p>0;A[t+y]=s&255,y+=q,s/=256,p-=8);A[t+y-q]|=O*128}});var Hi=J(Le=>{"use strict";var Kr=yi(),De=jr(),Gi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Le.Buffer=G;Le.SlowBuffer=_a;Le.INSPECT_MAX_BYTES=50;var Wt=2147483647;Le.kMaxLength=Wt;G.TYPED_ARRAY_SUPPORT=da();!G.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function da(){try{var A=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(A,e),A.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.byteOffset}});function me(A){if(A>Wt)throw new RangeError('The value "'+A+'" is invalid for option "size"');var e=new Uint8Array(A);return Object.setPrototypeOf(e,G.prototype),e}function G(A,e,t){if(typeof A=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $r(A)}return Fi(A,e,t)}G.poolSize=8192;function Fi(A,e,t){if(typeof A=="string")return Ca(A,e);if(ArrayBuffer.isView(A))return Ia(A);if(A==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof A);if(ge(A,ArrayBuffer)||A&&ge(A.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ge(A,SharedArrayBuffer)||A&&ge(A.buffer,SharedArrayBuffer)))return Xr(A,e,t);if(typeof A=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var r=A.valueOf&&A.valueOf();if(r!=null&&r!==A)return G.from(r,e,t);var n=wa(A);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof A[Symbol.toPrimitive]=="function")return G.from(A[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof A)}G.from=function(A,e,t){return Fi(A,e,t)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function Si(A){if(typeof A!="number")throw new TypeError('"size" argument must be of type number');if(A<0)throw new RangeError('The value "'+A+'" is invalid for option "size"')}function pa(A,e,t){return Si(A),A<=0?me(A):e!==void 0?typeof t=="string"?me(A).fill(e,t):me(A).fill(e):me(A)}G.alloc=function(A,e,t){return pa(A,e,t)};function $r(A){return Si(A),me(A<0?0:Dr(A)|0)}G.allocUnsafe=function(A){return $r(A)};G.allocUnsafeSlow=function(A){return $r(A)};function Ca(A,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var t=Ri(A,e)|0,r=me(t),n=r.write(A,e);return n!==t&&(r=r.slice(0,n)),r}function Wr(A){for(var e=A.length<0?0:Dr(A.length)|0,t=me(e),r=0;r<e;r+=1)t[r]=A[r]&255;return t}function Ia(A){if(ge(A,Uint8Array)){var e=new Uint8Array(A);return Xr(e.buffer,e.byteOffset,e.byteLength)}return Wr(A)}function Xr(A,e,t){if(e<0||A.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(A.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');var r;return e===void 0&&t===void 0?r=new Uint8Array(A):t===void 0?r=new Uint8Array(A,e):r=new Uint8Array(A,e,t),Object.setPrototypeOf(r,G.prototype),r}function wa(A){if(G.isBuffer(A)){var e=Dr(A.length)|0,t=me(e);return t.length===0||A.copy(t,0,0,e),t}if(A.length!==void 0)return typeof A.length!="number"||Lr(A.length)?me(0):Wr(A);if(A.type==="Buffer"&&Array.isArray(A.data))return Wr(A.data)}function Dr(A){if(A>=Wt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Wt.toString(16)+" bytes");return A|0}function _a(A){return+A!=A&&(A=0),G.alloc(+A)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,t){if(ge(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),ge(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),!G.isBuffer(e)||!G.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0};G.isEncoding=function(e){switch(String(e).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}};G.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=G.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(ge(s,Uint8Array))i+s.length>n.length?G.from(s).copy(n,i):Uint8Array.prototype.set.call(n,s,i);else if(G.isBuffer(s))s.copy(n,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return n};function Ri(A,e){if(G.isBuffer(A))return A.length;if(ArrayBuffer.isView(A)||ge(A,ArrayBuffer))return A.byteLength;if(typeof A!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof A);var t=A.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&t===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return zr(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return vi(A).length;default:if(n)return r?-1:zr(A).length;e=(""+e).toLowerCase(),n=!0}}G.byteLength=Ri;function ya(A,e,t){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(A||(A="utf8");;)switch(A){case"hex":return qa(this,e,t);case"utf8":case"utf-8":return xi(this,e,t);case"ascii":return xa(this,e,t);case"latin1":case"binary":return ka(this,e,t);case"base64":return Ra(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ma(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),r=!0}}G.prototype._isBuffer=!0;function Pe(A,e,t){var r=A[e];A[e]=A[t],A[t]=r}G.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Pe(this,t,t+1);return this};G.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Pe(this,t,t+3),Pe(this,t+1,t+2);return this};G.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Pe(this,t,t+7),Pe(this,t+1,t+6),Pe(this,t+2,t+5),Pe(this,t+3,t+4);return this};G.prototype.toString=function(){var e=this.length;return e===0?"":arguments.length===0?xi(this,0,e):ya.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){var e="",t=Le.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Gi&&(G.prototype[Gi]=G.prototype.inspect);G.prototype.compare=function(e,t,r,n,i){if(ge(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),i===void 0&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var s=i-n,c=r-t,a=Math.min(s,c),p=this.slice(n,i),m=e.slice(t,r),F=0;F<a;++F)if(p[F]!==m[F]){s=p[F],c=m[F];break}return s<c?-1:c<s?1:0};function bi(A,e,t,r,n){if(A.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Lr(t)&&(t=n?0:A.length-1),t<0&&(t=A.length+t),t>=A.length){if(n)return-1;t=A.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=G.from(e,r)),G.isBuffer(e))return e.length===0?-1:mi(A,e,t,r,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(A,e,t):Uint8Array.prototype.lastIndexOf.call(A,e,t):mi(A,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function mi(A,e,t,r,n){var i=1,s=A.length,c=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(A.length<2||e.length<2)return-1;i=2,s/=2,c/=2,t/=2}function a(y,q){return i===1?y[q]:y.readUInt16BE(q*i)}var p;if(n){var m=-1;for(p=t;p<s;p++)if(a(A,p)===a(e,m===-1?0:p-m)){if(m===-1&&(m=p),p-m+1===c)return m*i}else m!==-1&&(p-=p-m),m=-1}else for(t+c>s&&(t=s-c),p=t;p>=0;p--){for(var F=!0,R=0;R<c;R++)if(a(A,p+R)!==a(e,R)){F=!1;break}if(F)return p}return-1}G.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};G.prototype.indexOf=function(e,t,r){return bi(this,e,t,r,!0)};G.prototype.lastIndexOf=function(e,t,r){return bi(this,e,t,r,!1)};function Ga(A,e,t,r){t=Number(t)||0;var n=A.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;var i=e.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var c=parseInt(e.substr(s*2,2),16);if(Lr(c))return s;A[t+s]=c}return s}function ma(A,e,t,r){return Xt(zr(e,A.length-t),A,t,r)}function Na(A,e,t,r){return Xt(Ta(e),A,t,r)}function Fa(A,e,t,r){return Xt(vi(e),A,t,r)}function Sa(A,e,t,r){return Xt(Ua(e,A.length-t),A,t,r)}G.prototype.write=function(e,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(r)?(r=r>>>0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-t;if((r===void 0||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return Ga(this,e,t,r);case"utf8":case"utf-8":return ma(this,e,t,r);case"ascii":case"latin1":case"binary":return Na(this,e,t,r);case"base64":return Fa(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sa(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ra(A,e,t){return e===0&&t===A.length?Kr.fromByteArray(A):Kr.fromByteArray(A.slice(e,t))}function xi(A,e,t){t=Math.min(A.length,t);for(var r=[],n=e;n<t;){var i=A[n],s=null,c=i>239?4:i>223?3:i>191?2:1;if(n+c<=t){var a,p,m,F;switch(c){case 1:i<128&&(s=i);break;case 2:a=A[n+1],(a&192)===128&&(F=(i&31)<<6|a&63,F>127&&(s=F));break;case 3:a=A[n+1],p=A[n+2],(a&192)===128&&(p&192)===128&&(F=(i&15)<<12|(a&63)<<6|p&63,F>2047&&(F<55296||F>57343)&&(s=F));break;case 4:a=A[n+1],p=A[n+2],m=A[n+3],(a&192)===128&&(p&192)===128&&(m&192)===128&&(F=(i&15)<<18|(a&63)<<12|(p&63)<<6|m&63,F>65535&&F<1114112&&(s=F))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),n+=c}return ba(r)}var Ni=4096;function ba(A){var e=A.length;if(e<=Ni)return String.fromCharCode.apply(String,A);for(var t="",r=0;r<e;)t+=String.fromCharCode.apply(String,A.slice(r,r+=Ni));return t}function xa(A,e,t){var r="";t=Math.min(A.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(A[n]&127);return r}function ka(A,e,t){var r="";t=Math.min(A.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(A[n]);return r}function qa(A,e,t){var r=A.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);for(var n="",i=e;i<t;++i)n+=Oa[A[i]];return n}function Ma(A,e,t){for(var r=A.slice(e,t),n="",i=0;i<r.length-1;i+=2)n+=String.fromCharCode(r[i]+r[i+1]*256);return n}G.prototype.slice=function(e,t){var r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,G.prototype),n};function FA(A,e,t){if(A%1!==0||A<0)throw new RangeError("offset is not uint");if(A+e>t)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||FA(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||FA(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n};G.prototype.readUint8=G.prototype.readUInt8=function(e,t){return e=e>>>0,t||FA(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||FA(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||FA(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||FA(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n};G.prototype.readIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||FA(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s};G.prototype.readInt8=function(e,t){return e=e>>>0,t||FA(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,t){e=e>>>0,t||FA(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};G.prototype.readInt16BE=function(e,t){e=e>>>0,t||FA(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};G.prototype.readInt32LE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readFloatLE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),De.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,t){return e=e>>>0,t||FA(e,4,this.length),De.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||FA(e,8,this.length),De.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||FA(e,8,this.length),De.read(this,e,!1,52,8)};function JA(A,e,t,r,n,i){if(!G.isBuffer(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<i)throw new RangeError('"value" argument is out of bounds');if(t+r>A.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t>>>0,r=r>>>0,!n){var i=Math.pow(2,8*r)-1;JA(this,e,t,r,i,0)}var s=1,c=0;for(this[t]=e&255;++c<r&&(s*=256);)this[t+c]=e/s&255;return t+r};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t=t>>>0,r=r>>>0,!n){var i=Math.pow(2,8*r)-1;JA(this,e,t,r,i,0)}var s=r-1,c=1;for(this[t+s]=e&255;--s>=0&&(c*=256);)this[t+s]=e/c&255;return t+r};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,1,255,0),this[t]=e&255,t+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};G.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t>>>0,!n){var i=Math.pow(2,8*r-1);JA(this,e,t,r,i-1,-i)}var s=0,c=1,a=0;for(this[t]=e&255;++s<r&&(c*=256);)e<0&&a===0&&this[t+s-1]!==0&&(a=1),this[t+s]=(e/c>>0)-a&255;return t+r};G.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t>>>0,!n){var i=Math.pow(2,8*r-1);JA(this,e,t,r,i-1,-i)}var s=r-1,c=1,a=0;for(this[t+s]=e&255;--s>=0&&(c*=256);)e<0&&a===0&&this[t+s+1]!==0&&(a=1),this[t+s]=(e/c>>0)-a&255;return t+r};G.prototype.writeInt8=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};G.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};G.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};G.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};G.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||JA(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ki(A,e,t,r,n,i){if(t+r>A.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function qi(A,e,t,r,n){return e=+e,t=t>>>0,n||ki(A,e,t,4,34028234663852886e22,-34028234663852886e22),De.write(A,e,t,r,23,4),t+4}G.prototype.writeFloatLE=function(e,t,r){return qi(this,e,t,!0,r)};G.prototype.writeFloatBE=function(e,t,r){return qi(this,e,t,!1,r)};function Mi(A,e,t,r,n){return e=+e,t=t>>>0,n||ki(A,e,t,8,17976931348623157e292,-17976931348623157e292),De.write(A,e,t,r,52,8),t+8}G.prototype.writeDoubleLE=function(e,t,r){return Mi(this,e,t,!0,r)};G.prototype.writeDoubleBE=function(e,t,r){return Mi(this,e,t,!1,r)};G.prototype.copy=function(e,t,r,n){if(!G.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i};G.prototype.fill=function(e,t,r,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!G.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){var i=e.charCodeAt(0);(n==="utf8"&&i<128||n==="latin1")&&(e=i)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);var s;if(typeof e=="number")for(s=t;s<r;++s)this[s]=e;else{var c=G.isBuffer(e)?e:G.from(e,n),a=c.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=c[s%a]}return this};var va=/[^+/0-9A-Za-z-_]/g;function Ha(A){if(A=A.split("=")[0],A=A.trim().replace(va,""),A.length<2)return"";for(;A.length%4!==0;)A=A+"=";return A}function zr(A,e){e=e||1/0;for(var t,r=A.length,n=null,i=[],s=0;s<r;++s){if(t=A.charCodeAt(s),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&i.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&i.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;i.push(t)}else if(t<2048){if((e-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function Ta(A){for(var e=[],t=0;t<A.length;++t)e.push(A.charCodeAt(t)&255);return e}function Ua(A,e){for(var t,r,n,i=[],s=0;s<A.length&&!((e-=2)<0);++s)t=A.charCodeAt(s),r=t>>8,n=t%256,i.push(n),i.push(r);return i}function vi(A){return Kr.toByteArray(Ha(A))}function Xt(A,e,t,r){for(var n=0;n<r&&!(n+t>=e.length||n>=A.length);++n)e[n+t]=A[n];return n}function ge(A,e){return A instanceof e||A!=null&&A.constructor!=null&&A.constructor.name!=null&&A.constructor.name===e.name}function Lr(A){return A!==A}var Oa=function(){for(var A="0123456789abcdef",e=new Array(256),t=0;t<16;++t)for(var r=t*16,n=0;n<16;++n)e[r+n]=A[t]+A[n];return e}()});var Ti=J(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.ReplicaRejectCode=void 0;var Ya;(function(A){A[A.SysFatal=1]="SysFatal",A[A.SysTransient=2]="SysTransient",A[A.DestinationInvalid=3]="DestinationInvalid",A[A.CanisterReject=4]="CanisterReject",A[A.CanisterError=5]="CanisterError"})(Ya=_t.ReplicaRejectCode||(_t.ReplicaRejectCode={}))});var Ui=J(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.decode=et.encode=void 0;var zt="abcdefghijklmnopqrstuvwxyz234567",At=Object.create(null);for(let A=0;A<zt.length;A++)At[zt[A]]=A;At[0]=At.o;At[1]=At.i;function Ja(A){let e=0,t=0,r="";function n(i){return e<0?t|=i>>-e:t=i<<e&248,e>3?(e-=8,1):(e<4&&(r+=zt[t>>3],e+=5),0)}for(let i=0;i<A.length;)i+=n(A[i]);return r+(e<0?zt[t>>3]:"")}et.encode=Ja;function Pa(A){let e=0,t=0,r=new Uint8Array(A.length*4/3|0),n=0;function i(s){let c=At[s.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(s)}`);c<<=3,t|=c>>>e,e+=5,e>=8&&(r[n++]=t,e-=8,e>0?t=c<<5-e&255:t=0)}for(let s of A)i(s);return r.slice(0,n)}et.decode=Pa});var Oi=J($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.getCrc32=void 0;var Va=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function Za(A){let e=new Uint8Array(A),t=-1;for(let r=0;r<e.length;r++){let i=(e[r]^t)&255;t=Va[i]^t>>>8}return(t^-1)>>>0}$t.getCrc32=Za});var An=J((exports,module)=>{(function(){"use strict";var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;NODE_JS?root=global:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,AMD=typeof define=="function"&&define.amd,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[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],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(A){return Object.prototype.toString.call(A)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(A){return typeof A=="object"&&A.buffer&&A.buffer.constructor===ArrayBuffer});var createOutputMethod=function(A,e){return function(t){return new Sha256(e,!0).update(t)[A]()}},createMethod=function(A){var e=createOutputMethod("hex",A);NODE_JS&&(e=nodeWrap(e,A)),e.create=function(){return new Sha256(A)},e.update=function(n){return e.create().update(n)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];e[r]=createOutputMethod(r,A)}return e},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(A){if(typeof A=="string")return crypto.createHash(algorithm).update(A,"utf8").digest("hex");if(A==null)throw new Error(ERROR);return A.constructor===ArrayBuffer&&(A=new Uint8Array(A)),Array.isArray(A)||ArrayBuffer.isView(A)||A.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(A)).digest("hex"):method(A)};return nodeMethod},createHmacOutputMethod=function(A,e){return function(t,r){return new HmacSha256(t,e,!0).update(r)[A]()}},createHmacMethod=function(A){var e=createHmacOutputMethod("hex",A);e.create=function(n){return new HmacSha256(n,A)},e.update=function(n,i){return e.create(n).update(i)};for(var t=0;t<OUTPUT_TYPES.length;++t){var r=OUTPUT_TYPES[t];e[r]=createHmacOutputMethod(r,A)}return e};function Sha256(A,e){e?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=A}Sha256.prototype.update=function(A){if(!this.finalized){var e,t=typeof A;if(t!=="string"){if(t==="object"){if(A===null)throw new Error(ERROR);if(ARRAY_BUFFER&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(A)))throw new Error(ERROR)}else throw new Error(ERROR);e=!0}for(var r,n=0,i,s=A.length,c=this.blocks;n<s;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),e)for(i=this.start;n<s&&i<64;++n)c[i>>2]|=A[n]<<SHIFT[i++&3];else for(i=this.start;n<s&&i<64;++n)r=A.charCodeAt(n),r<128?c[i>>2]|=r<<SHIFT[i++&3]:r<2048?(c[i>>2]|=(192|r>>6)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]):r<55296||r>=57344?(c[i>>2]|=(224|r>>12)<<SHIFT[i++&3],c[i>>2]|=(128|r>>6&63)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]):(r=65536+((r&1023)<<10|A.charCodeAt(++n)&1023),c[i>>2]|=(240|r>>18)<<SHIFT[i++&3],c[i>>2]|=(128|r>>12&63)<<SHIFT[i++&3],c[i>>2]|=(128|r>>6&63)<<SHIFT[i++&3],c[i>>2]|=(128|r&63)<<SHIFT[i++&3]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=c[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[16]=this.block,A[e>>2]|=EXTRA[e&3],this.block=A[16],e>=56&&(this.hashed||this.hash(),A[0]=this.block,A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.hBytes<<3|this.bytes>>>29,A[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var A=this.h0,e=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=this.blocks,p,m,F,R,y,q,O,V,Y,W,Z;for(p=16;p<64;++p)y=a[p-15],m=(y>>>7|y<<25)^(y>>>18|y<<14)^y>>>3,y=a[p-2],F=(y>>>17|y<<15)^(y>>>19|y<<13)^y>>>10,a[p]=a[p-16]+m+a[p-7]+F<<0;for(Z=e&t,p=0;p<64;p+=4)this.first?(this.is224?(V=300032,y=a[0]-1413257819,c=y-150054599<<0,r=y+24177077<<0):(V=704751109,y=a[0]-210244248,c=y-1521486534<<0,r=y+143694565<<0),this.first=!1):(m=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),F=(n>>>6|n<<26)^(n>>>11|n<<21)^(n>>>25|n<<7),V=A&e,R=V^A&t^Z,O=n&i^~n&s,y=c+F+O+K[p]+a[p],q=m+R,c=r+y<<0,r=y+q<<0),m=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),F=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),Y=r&A,R=Y^r&e^V,O=c&n^~c&i,y=s+F+O+K[p+1]+a[p+1],q=m+R,s=t+y<<0,t=y+q<<0,m=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),F=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),W=t&r,R=W^t&A^Y,O=s&c^~s&n,y=i+F+O+K[p+2]+a[p+2],q=m+R,i=e+y<<0,e=y+q<<0,m=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),F=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),Z=e&t,R=Z^e&r^W,O=i&s^~i&c,y=n+F+O+K[p+3]+a[p+3],q=m+R,n=A+y<<0,A=y+q<<0;this.h0=this.h0+A<<0,this.h1=this.h1+e<<0,this.h2=this.h2+t<<0,this.h3=this.h3+r<<0,this.h4=this.h4+n<<0,this.h5=this.h5+i<<0,this.h6=this.h6+s<<0,this.h7=this.h7+c<<0},Sha256.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=HEX_CHARS[A>>28&15]+HEX_CHARS[A>>24&15]+HEX_CHARS[A>>20&15]+HEX_CHARS[A>>16&15]+HEX_CHARS[A>>12&15]+HEX_CHARS[A>>8&15]+HEX_CHARS[A>>4&15]+HEX_CHARS[A&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15];return this.is224||(a+=HEX_CHARS[c>>28&15]+HEX_CHARS[c>>24&15]+HEX_CHARS[c>>20&15]+HEX_CHARS[c>>16&15]+HEX_CHARS[c>>12&15]+HEX_CHARS[c>>8&15]+HEX_CHARS[c>>4&15]+HEX_CHARS[c&15]),a},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,r=this.h3,n=this.h4,i=this.h5,s=this.h6,c=this.h7,a=[A>>24&255,A>>16&255,A>>8&255,A&255,e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,r>>24&255,r>>16&255,r>>8&255,r&255,n>>24&255,n>>16&255,n>>8&255,n&255,i>>24&255,i>>16&255,i>>8&255,i&255,s>>24&255,s>>16&255,s>>8&255,s&255];return this.is224||a.push(c>>24&255,c>>16&255,c>>8&255,c&255),a},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(this.is224?28:32),e=new DataView(A);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),A};function HmacSha256(A,e,t){var r,n=typeof A;if(n==="string"){var i=[],s=A.length,c=0,a;for(r=0;r<s;++r)a=A.charCodeAt(r),a<128?i[c++]=a:a<2048?(i[c++]=192|a>>6,i[c++]=128|a&63):a<55296||a>=57344?(i[c++]=224|a>>12,i[c++]=128|a>>6&63,i[c++]=128|a&63):(a=65536+((a&1023)<<10|A.charCodeAt(++r)&1023),i[c++]=240|a>>18,i[c++]=128|a>>12&63,i[c++]=128|a>>6&63,i[c++]=128|a&63);A=i}else if(n==="object"){if(A===null)throw new Error(ERROR);if(ARRAY_BUFFER&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(A)))throw new Error(ERROR)}else throw new Error(ERROR);A.length>64&&(A=new Sha256(e,!0).update(A).array());var p=[],m=[];for(r=0;r<64;++r){var F=A[r]||0;p[r]=92^F,m[r]=54^F}Sha256.call(this,e,t),this.update(m),this.oKeyPad=p,this.inner=!0,this.sharedMemory=t}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(A),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224,AMD&&define(function(){return exports}))})()});var Yi=J(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.sha224=void 0;var ja=An();function Ka(A){let e=ja.sha224.create();return e.update(A),new Uint8Array(e.array())}Dt.sha224=Ka});var ue=J(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.Principal=void 0;var Ji=Ui(),Wa=Oi(),Xa=Yi(),za=2,Pi=4,$a="aaaaa-aa",Da=A=>{var e;return new Uint8Array(((e=A.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))},La=A=>A.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),tt=class{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Pi]))}static managementCanister(){return this.fromHex($a)}static selfAuthenticating(e){let t=(0,Xa.sha224)(e);return new this(new Uint8Array([...t,za]))}static from(e){if(typeof e=="string")return tt.fromText(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new tt(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(Da(e))}static fromText(e){let t=e.toLowerCase().replace(/-/g,""),r=(0,Ji.decode)(t);r=r.slice(4,r.length);let n=new this(r);if(n.toText()!==e)throw new Error(`Principal "${n.toText()}" does not have a valid checksum (original value "${e}" may not be a valid Principal ID).`);return n}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Pi}toUint8Array(){return this._arr}toHex(){return La(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,Wa.getCrc32)(this._arr));let r=new Uint8Array(e),n=Uint8Array.from(this._arr),i=new Uint8Array([...r,...n]),c=(0,Ji.encode)(i).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}compareTo(e){for(let t=0;t<Math.min(this._arr.length,e._arr.length);t++){if(this._arr[t]<e._arr[t])return"lt";if(this._arr[t]>e._arr[t])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let t=this.compareTo(e);return t=="lt"||t=="eq"}gtEq(e){let t=this.compareTo(e);return t=="gt"||t=="eq"}};Lt.Principal=tt});var er=J(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.AgentError=void 0;var yt=class extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,yt.prototype)}};Ar.AgentError=yt});var tr=J(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.PipeArrayBuffer=Ee.fromHexString=Ee.toHexString=Ee.concat=void 0;function Ac(...A){let e=new Uint8Array(A.reduce((r,n)=>r+n.byteLength,0)),t=0;for(let r of A)e.set(new Uint8Array(r),t),t+=r.byteLength;return e}Ee.concat=Ac;function ec(A){return new Uint8Array(A).reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}Ee.toHexString=ec;function tc(A){var e;return new Uint8Array(((e=A.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(t=>parseInt(t,16)))}Ee.fromHexString=tc;var en=class{constructor(e,t=(e==null?void 0:e.byteLength)||0){this._buffer=e||new ArrayBuffer(0),this._view=new Uint8Array(this._buffer,0,t)}get buffer(){return this._view.slice()}get byteLength(){return this._view.byteLength}read(e){let t=this._view.subarray(0,e);return this._view=this._view.subarray(e),t.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let t=new Uint8Array(e),r=this._view.byteLength;this._view.byteOffset+this._view.byteLength+t.byteLength>=this._buffer.byteLength?this.alloc(t.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+t.byteLength),this._view.set(t,r)}get end(){return this._view.byteLength===0}alloc(e){let t=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),r=new Uint8Array(t,0,this._view.byteLength+e);r.set(this._view),this._buffer=t,this._view=r}};Ee.PipeArrayBuffer=en});var tn=J(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.idlLabelToId=void 0;function rc(A){let t=new TextEncoder().encode(A),r=0;for(let n of t)r=(r*223+n)%2**32;return r}function nc(A){if(/^_\d+_$/.test(A)||/^_0x[0-9a-fA-F]+_$/.test(A)){let e=+A.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return rc(A)}rr.idlLabelToId=nc});var nn=J(dA=>{"use strict";Object.defineProperty(dA,"__esModule",{value:!0});dA.readIntLE=dA.readUIntLE=dA.writeIntLE=dA.writeUIntLE=dA.slebDecode=dA.slebEncode=dA.lebDecode=dA.lebEncode=dA.safeReadUint8=dA.safeRead=void 0;var rn=tr();function Vi(){throw new Error("unexpected end of buffer")}function Zi(A,e){return A.byteLength<e&&Vi(),A.read(e)}dA.safeRead=Zi;function nr(A){let e=A.readUint8();return e===void 0&&Vi(),e}dA.safeReadUint8=nr;function ic(A){if(typeof A=="number"&&(A=BigInt(A)),A<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(A===BigInt(0)?0:Math.ceil(Math.log2(Number(A))))+1,t=new rn.PipeArrayBuffer(new ArrayBuffer(e),0);for(;;){let r=Number(A&BigInt(127));if(A/=BigInt(128),A===BigInt(0)){t.write(new Uint8Array([r]));break}else t.write(new Uint8Array([r|128]))}return t.buffer}dA.lebEncode=ic;function ji(A){let e=BigInt(1),t=BigInt(0),r;do r=nr(A),t+=BigInt(r&127).valueOf()*e,e*=BigInt(128);while(r>=128);return t}dA.lebDecode=ji;function sc(A){typeof A=="number"&&(A=BigInt(A));let e=A<BigInt(0);e&&(A=-A-BigInt(1));let t=(A===BigInt(0)?0:Math.ceil(Math.log2(Number(A))))+1,r=new rn.PipeArrayBuffer(new ArrayBuffer(t),0);for(;;){let i=n(A);if(A/=BigInt(128),e&&A===BigInt(0)&&(i&64)!==0||!e&&A===BigInt(0)&&(i&64)===0){r.write(new Uint8Array([i]));break}else r.write(new Uint8Array([i|128]))}function n(i){let s=i%BigInt(128);return Number(e?BigInt(128)-s-BigInt(1):s)}return r.buffer}dA.slebEncode=sc;function oc(A){let e=new Uint8Array(A.buffer),t=0;for(;t<e.byteLength;t++)if(e[t]<128){if((e[t]&64)===0)return ji(A);break}let r=new Uint8Array(Zi(A,t+1)),n=BigInt(0);for(let i=r.byteLength-1;i>=0;i--)n=n*BigInt(128)+BigInt(128-(r[i]&127)-1);return-n-BigInt(1)}dA.slebDecode=oc;function ac(A,e){if(BigInt(A)<BigInt(0))throw new Error("Cannot write negative values.");return Ki(A,e)}dA.writeUIntLE=ac;function Ki(A,e){A=BigInt(A);let t=new rn.PipeArrayBuffer(new ArrayBuffer(Math.min(1,e)),0),r=0,n=BigInt(256),i=BigInt(0),s=Number(A%n);for(t.write(new Uint8Array([s]));++r<e;)A<0&&i===BigInt(0)&&s!==0&&(i=BigInt(1)),s=Number((A/n-i)%BigInt(256)),t.write(new Uint8Array([s])),n*=BigInt(256);return t.buffer}dA.writeIntLE=Ki;function Wi(A,e){let t=BigInt(nr(A)),r=BigInt(1),n=0;for(;++n<e;){r*=BigInt(256);let i=BigInt(nr(A));t=t+r*i}return t}dA.readUIntLE=Wi;function cc(A,e){let t=Wi(A,e),r=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return t>=r&&(t-=r*BigInt(2)),t}dA.readIntLE=cc});var cn=J(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.Variant=_.Record=_.Opt=_.Vec=_.Tuple=_.Principal=_.Nat64=_.Nat32=_.Nat16=_.Nat8=_.Int64=_.Int32=_.Int16=_.Int8=_.Float64=_.Float32=_.Nat=_.Int=_.Text=_.Null=_.Bool=_.Unknown=_.Reserved=_.Empty=_.decode=_.encode=_.ServiceClass=_.FuncClass=_.PrincipalClass=_.RecClass=_.VariantClass=_.TupleClass=_.RecordClass=_.OptClass=_.VecClass=_.FixedNatClass=_.FixedIntClass=_.FloatClass=_.NatClass=_.IntClass=_.TextClass=_.ReservedClass=_.NullClass=_.BoolClass=_.UnknownClass=_.EmptyClass=_.ConstructType=_.PrimitiveType=_.Type=_.Visitor=void 0;_.Service=_.Func=_.Rec=void 0;var Bc=ue(),tA=tr(),zA=tn(),k=nn(),ir="DIDL";function Gt(A,e,t){return A.map((r,n)=>t(r,e[n]))}var sn=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,t){let r=this._typs.length;this._idx.set(e.name,r),this._typs.push(t)}merge(e,t){let r=this._idx.get(e.name),n=this._idx.get(t);if(r===void 0)throw new Error("Missing type index for "+e);if(n===void 0)throw new Error("Missing type index for "+t);this._typs[r]=this._typs[n],this._typs.splice(n,1),this._idx.delete(t)}encode(){let e=(0,k.lebEncode)(this._typs.length),t=(0,tA.concat)(...this._typs);return(0,tA.concat)(e,t)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,k.slebEncode)(this._idx.get(e)||0)}},on=class{visitType(e,t){throw new Error("Not implemented")}visitPrimitive(e,t){return this.visitType(e,t)}visitEmpty(e,t){return this.visitPrimitive(e,t)}visitBool(e,t){return this.visitPrimitive(e,t)}visitNull(e,t){return this.visitPrimitive(e,t)}visitReserved(e,t){return this.visitPrimitive(e,t)}visitText(e,t){return this.visitPrimitive(e,t)}visitNumber(e,t){return this.visitPrimitive(e,t)}visitInt(e,t){return this.visitNumber(e,t)}visitNat(e,t){return this.visitNumber(e,t)}visitFloat(e,t){return this.visitPrimitive(e,t)}visitFixedInt(e,t){return this.visitNumber(e,t)}visitFixedNat(e,t){return this.visitNumber(e,t)}visitPrincipal(e,t){return this.visitPrimitive(e,t)}visitConstruct(e,t){return this.visitType(e,t)}visitVec(e,t,r){return this.visitConstruct(e,r)}visitOpt(e,t,r){return this.visitConstruct(e,r)}visitRecord(e,t,r){return this.visitConstruct(e,r)}visitTuple(e,t,r){let n=t.map((i,s)=>[`_${s}_`,i]);return this.visitRecord(e,n,r)}visitVariant(e,t,r){return this.visitConstruct(e,r)}visitRec(e,t,r){return this.visitConstruct(t,r)}visitFunc(e,t){return this.visitConstruct(e,t)}visitService(e,t){return this.visitConstruct(e,t)}};_.Visitor=on;var rt=class{display(){return this.name}valueToString(e){return Xi(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};_.Type=rt;var PA=class extends rt{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}};_.PrimitiveType=PA;var he=class extends rt{checkType(e){if(e instanceof Qe){let t=e.getType();if(typeof t>"u")throw new Error("type mismatch with uninitialized type");return t}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}};_.ConstructType=he;var sr=class extends PA{accept(e,t){return e.visitEmpty(this,t)}covariant(e){return!1}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,k.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};_.EmptyClass=sr;var or=class extends rt{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,t){throw e.visitType(this,t)}covariant(e){return!1}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,t){let r=t.decodeValue(e,t);Object(r)!==r&&(r=Object(r));let n;return t instanceof Qe?n=()=>t.getType():n=()=>t,Object.defineProperty(r,"type",{value:n,writable:!0,enumerable:!1,configurable:!0}),r}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}};_.UnknownClass=or;var ar=class extends PA{accept(e,t){return e.visitBool(this,t)}covariant(e){return typeof e=="boolean"}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,k.slebEncode)(-2)}decodeValue(e,t){switch(this.checkType(t),(0,k.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};_.BoolClass=ar;var cr=class extends PA{accept(e,t){return e.visitNull(this,t)}covariant(e){return e===null}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,k.slebEncode)(-1)}decodeValue(e,t){return this.checkType(t),null}get name(){return"null"}};_.NullClass=cr;var nt=class extends PA{accept(e,t){return e.visitReserved(this,t)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,k.slebEncode)(-16)}decodeValue(e,t){return t.name!==this.name&&t.decodeValue(e,t),null}get name(){return"reserved"}};_.ReservedClass=nt;var Br=class extends PA{accept(e,t){return e.visitText(this,t)}covariant(e){return typeof e=="string"}encodeValue(e){let t=new TextEncoder().encode(e),r=(0,k.lebEncode)(t.byteLength);return(0,tA.concat)(r,t)}encodeType(){return(0,k.slebEncode)(-15)}decodeValue(e,t){this.checkType(t);let r=(0,k.lebDecode)(e),n=(0,k.safeRead)(e,Number(r));return new TextDecoder("utf8",{fatal:!0}).decode(n)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};_.TextClass=Br;var gr=class extends PA{accept(e,t){return e.visitInt(this,t)}covariant(e){return typeof e=="bigint"||Number.isInteger(e)}encodeValue(e){return(0,k.slebEncode)(e)}encodeType(){return(0,k.slebEncode)(-4)}decodeValue(e,t){return this.checkType(t),(0,k.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};_.IntClass=gr;var ur=class extends PA{accept(e,t){return e.visitNat(this,t)}covariant(e){return typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0}encodeValue(e){return(0,k.lebEncode)(e)}encodeType(){return(0,k.slebEncode)(-3)}decodeValue(e,t){return this.checkType(t),(0,k.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};_.NatClass=ur;var mt=class extends PA{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,t){return e.visitFloat(this,t)}covariant(e){return typeof e=="number"||e instanceof Number}encodeValue(e){let t=new ArrayBuffer(this._bits/8),r=new DataView(t);return this._bits===32?r.setFloat32(0,e,!0):r.setFloat64(0,e,!0),t}encodeType(){let e=this._bits===32?-13:-14;return(0,k.slebEncode)(e)}decodeValue(e,t){this.checkType(t);let r=(0,k.safeRead)(e,this._bits/8),n=new DataView(r);return this._bits===32?n.getFloat32(0,!0):n.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}};_.FloatClass=mt;var Ne=class extends PA{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedInt(this,t)}covariant(e){let t=BigInt(2)**BigInt(this._bits-1)*BigInt(-1),r=BigInt(2)**BigInt(this._bits-1)-BigInt(1);if(typeof e=="bigint")return e>=t&&e<=r;if(Number.isInteger(e)){let n=BigInt(e);return n>=t&&n<=r}else return!1}encodeValue(e){return(0,k.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,k.slebEncode)(-9-e)}decodeValue(e,t){this.checkType(t);let r=(0,k.readIntLE)(e,this._bits/8);return this._bits<=32?Number(r):r}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};_.FixedIntClass=Ne;var le=class extends PA{constructor(e){super(),this._bits=e}accept(e,t){return e.visitFixedNat(this,t)}covariant(e){let t=BigInt(2)**BigInt(this._bits);return typeof e=="bigint"&&e>=BigInt(0)?e<t:Number.isInteger(e)&&e>=0?BigInt(e)<t:!1}encodeValue(e){return(0,k.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,k.slebEncode)(-5-e)}decodeValue(e,t){this.checkType(t);let r=(0,k.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(r):r}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};_.FixedNatClass=le;var it=class extends he{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof le&&e._bits===8&&(this._blobOptimization=!0)}accept(e,t){return e.visitVec(this,this._type,t)}covariant(e){let t=this._type instanceof le?this._type._bits:this._type instanceof Ne?this._type._bits:0;return ArrayBuffer.isView(e)&&t==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every(r=>this._type.covariant(r))}encodeValue(e){let t=(0,k.lebEncode)(e.length);if(this._blobOptimization)return(0,tA.concat)(t,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,tA.concat)(t,new Uint8Array(e.buffer));let r=new tA.PipeArrayBuffer(new ArrayBuffer(t.byteLength+e.length),0);r.write(t);for(let n of e){let i=this._type.encodeValue(n);r.write(new Uint8Array(i))}return r.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=(0,k.slebEncode)(-19),r=this._type.encodeType(e);e.add(this,(0,tA.concat)(t,r))}decodeValue(e,t){let r=this.checkType(t);if(!(r instanceof it))throw new Error("Not a vector type");let n=Number((0,k.lebDecode)(e));if(this._type instanceof le){if(this._type._bits==8)return new Uint8Array(e.read(n));if(this._type._bits==16)return new Uint16Array(e.read(n*2));if(this._type._bits==32)return new Uint32Array(e.read(n*4));if(this._type._bits==64)return new BigUint64Array(e.read(n*8))}if(this._type instanceof Ne){if(this._type._bits==8)return new Int8Array(e.read(n));if(this._type._bits==16)return new Int16Array(e.read(n*2));if(this._type._bits==32)return new Int32Array(e.read(n*4));if(this._type._bits==64)return new BigInt64Array(e.read(n*8))}let i=[];for(let s=0;s<n;s++)i.push(this._type.decodeValue(e,r._type));return i}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){let t=e.map(r=>this._type.valueToString(r));return"vec {"+t.join("; ")+"}"}};_.VecClass=it;var be=class extends he{constructor(e){super(),this._type=e}accept(e,t){return e.visitOpt(this,this._type,t)}covariant(e){return Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0]))}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,tA.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let t=(0,k.slebEncode)(-18),r=this._type.encodeType(e);e.add(this,(0,tA.concat)(t,r))}decodeValue(e,t){let r=this.checkType(t);if(!(r instanceof be))throw new Error("Not an option type");switch((0,k.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,r._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};_.OptClass=be;var Ve=class extends he{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(e,t){return e.visitRecord(this,this._fields,t)}tryAsTuple(){let e=[];for(let t=0;t<this._fields.length;t++){let[r,n]=this._fields[t];if(r!==`_${t}_`)return null;e.push(n)}return e}covariant(e){return typeof e=="object"&&this._fields.every(([t,r])=>{if(!e.hasOwnProperty(t))throw new Error(`Record is missing key "${t}".`);return r.covariant(e[t])})}encodeValue(e){let t=this._fields.map(([n])=>e[n]),r=Gt(this._fields,t,([,n],i)=>n.encodeValue(i));return(0,tA.concat)(...r)}_buildTypeTableImpl(e){this._fields.forEach(([i,s])=>s.buildTypeTable(e));let t=(0,k.slebEncode)(-20),r=(0,k.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>(0,tA.concat)((0,k.lebEncode)((0,zA.idlLabelToId)(i)),s.encodeType(e)));e.add(this,(0,tA.concat)(t,r,(0,tA.concat)(...n)))}decodeValue(e,t){let r=this.checkType(t);if(!(r instanceof Ve))throw new Error("Not a record type");let n={},i=0,s=0;for(;s<r._fields.length;){let[c,a]=r._fields[s];if(i>=this._fields.length){a.decodeValue(e,a),s++;continue}let[p,m]=this._fields[i];if((0,zA.idlLabelToId)(this._fields[i][0])!==(0,zA.idlLabelToId)(c)){if(m instanceof be||m instanceof nt){n[p]=[],i++;continue}a.decodeValue(e,a),s++;continue}n[p]=m.decodeValue(e,a),i++,s++}for(let[c,a]of this._fields.slice(i))if(a instanceof be||a instanceof nt)n[c]=[];else throw new Error("Cannot find required field "+c);return n}get name(){return`record {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}display(){return`record {${this._fields.map(([t,r])=>t+":"+r.display()).join("; ")}}`}valueToString(e){let t=this._fields.map(([n])=>e[n]);return`record {${Gt(this._fields,t,([n,i],s)=>n+"="+i.valueToString(s)).join("; ")}}`}};_.RecordClass=Ve;var st=class extends Ve{constructor(e){let t={};e.forEach((r,n)=>t["_"+n+"_"]=r),super(t),this._components=e}accept(e,t){return e.visitTuple(this,this._components,t)}covariant(e){return Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((t,r)=>t.covariant(e[r]))}encodeValue(e){let t=Gt(this._components,e,(r,n)=>r.encodeValue(n));return(0,tA.concat)(...t)}decodeValue(e,t){let r=this.checkType(t);if(!(r instanceof st))throw new Error("not a tuple type");if(r._components.length<this._components.length)throw new Error("tuple mismatch");let n=[];for(let[i,s]of r._components.entries())i>=this._components.length?s.decodeValue(e,s):n.push(this._components[i].decodeValue(e,s));return n}display(){return`record {${this._components.map(t=>t.display()).join("; ")}}`}valueToString(e){return`record {${Gt(this._components,e,(r,n)=>r.valueToString(n)).join("; ")}}`}};_.TupleClass=st;var ot=class extends he{constructor(e={}){super(),this._fields=Object.entries(e).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(e,t){return e.visitVariant(this,this._fields,t)}covariant(e){return typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([t,r])=>!e.hasOwnProperty(t)||r.covariant(e[t]))}encodeValue(e){for(let t=0;t<this._fields.length;t++){let[r,n]=this._fields[t];if(e.hasOwnProperty(r)){let i=(0,k.lebEncode)(t),s=n.encodeValue(e[r]);return(0,tA.concat)(i,s)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,i])=>{i.buildTypeTable(e)});let t=(0,k.slebEncode)(-21),r=(0,k.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>(0,tA.concat)((0,k.lebEncode)((0,zA.idlLabelToId)(i)),s.encodeType(e)));e.add(this,(0,tA.concat)(t,r,...n))}decodeValue(e,t){let r=this.checkType(t);if(!(r instanceof ot))throw new Error("Not a variant type");let n=Number((0,k.lebDecode)(e));if(n>=r._fields.length)throw Error("Invalid variant index: "+n);let[i,s]=r._fields[n];for(let[c,a]of this._fields)if((0,zA.idlLabelToId)(i)===(0,zA.idlLabelToId)(c)){let p=a.decodeValue(e,s);return{[c]:p}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}display(){return`variant {${this._fields.map(([t,r])=>t+(r.name==="null"?"":`:${r.display()}`)).join("; ")}}`}valueToString(e){for(let[t,r]of this._fields)if(e.hasOwnProperty(t)){let n=r.valueToString(e[t]);return n==="null"?`variant {${t}}`:`variant {${t}=${n}}`}throw new Error("Variant has no data: "+e)}};_.VariantClass=ot;var Qe=class extends he{constructor(){super(...arguments),this._id=Qe._counter++,this._type=void 0}accept(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,t)}fill(e){this._type=e}getType(){return this._type}covariant(e){return this._type?this._type.covariant(e):!1}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,t)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};_.RecClass=Qe;Qe._counter=0;function an(A){if((0,k.safeReadUint8)(A)!==1)throw new Error("Cannot decode principal");let t=Number((0,k.lebDecode)(A));return Bc.Principal.fromUint8Array(new Uint8Array((0,k.safeRead)(A,t)))}var Er=class extends PA{accept(e,t){return e.visitPrincipal(this,t)}covariant(e){return e&&e._isPrincipal}encodeValue(e){let t=e.toUint8Array(),r=(0,k.lebEncode)(t.byteLength);return(0,tA.concat)(new Uint8Array([1]),r,t)}encodeType(){return(0,k.slebEncode)(-24)}decodeValue(e,t){return this.checkType(t),an(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};_.PrincipalClass=Er;var Nt=class extends he{constructor(e,t,r=[]){super(),this.argTypes=e,this.retTypes=t,this.annotations=r}static argsToString(e,t){if(e.length!==t.length)throw new Error("arity mismatch");return"("+e.map((r,n)=>r.valueToString(t[n])).join(", ")+")"}accept(e,t){return e.visitFunc(this,t)}covariant(e){return Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string"}encodeValue([e,t]){let r=e.toUint8Array(),n=(0,k.lebEncode)(r.byteLength),i=(0,tA.concat)(new Uint8Array([1]),n,r),s=new TextEncoder().encode(t),c=(0,k.lebEncode)(s.byteLength);return(0,tA.concat)(new Uint8Array([1]),i,c,s)}_buildTypeTableImpl(e){this.argTypes.forEach(p=>p.buildTypeTable(e)),this.retTypes.forEach(p=>p.buildTypeTable(e));let t=(0,k.slebEncode)(-22),r=(0,k.lebEncode)(this.argTypes.length),n=(0,tA.concat)(...this.argTypes.map(p=>p.encodeType(e))),i=(0,k.lebEncode)(this.retTypes.length),s=(0,tA.concat)(...this.retTypes.map(p=>p.encodeType(e))),c=(0,k.lebEncode)(this.annotations.length),a=(0,tA.concat)(...this.annotations.map(p=>this.encodeAnnotation(p)));e.add(this,(0,tA.concat)(t,r,n,i,s,c,a))}decodeValue(e){if((0,k.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let r=an(e),n=Number((0,k.lebDecode)(e)),i=(0,k.safeRead)(e,n),c=new TextDecoder("utf8",{fatal:!0}).decode(i);return[r,c]}get name(){let e=this.argTypes.map(n=>n.name).join(", "),t=this.retTypes.map(n=>n.name).join(", "),r=" "+this.annotations.join(" ");return`(${e}) -> (${t})${r}`}valueToString([e,t]){return`func "${e.toText()}".${t}`}display(){let e=this.argTypes.map(n=>n.display()).join(", "),t=this.retTypes.map(n=>n.display()).join(", "),r=" "+this.annotations.join(" ");return`(${e}) \u2192 (${t})${r}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);throw new Error("Illegal function annotation")}};_.FuncClass=Nt;var lr=class extends he{constructor(e){super(),this._fields=Object.entries(e).sort((t,r)=>(0,zA.idlLabelToId)(t[0])-(0,zA.idlLabelToId)(r[0]))}accept(e,t){return e.visitService(this,t)}covariant(e){return e&&e._isPrincipal}encodeValue(e){let t=e.toUint8Array(),r=(0,k.lebEncode)(t.length);return(0,tA.concat)(new Uint8Array([1]),r,t)}_buildTypeTableImpl(e){this._fields.forEach(([i,s])=>s.buildTypeTable(e));let t=(0,k.slebEncode)(-23),r=(0,k.lebEncode)(this._fields.length),n=this._fields.map(([i,s])=>{let c=new TextEncoder().encode(i),a=(0,k.lebEncode)(c.length);return(0,tA.concat)(a,c,s.encodeType(e))});e.add(this,(0,tA.concat)(t,r,...n))}decodeValue(e){return an(e)}get name(){return`service {${this._fields.map(([t,r])=>t+":"+r.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};_.ServiceClass=lr;function Xi(A){return JSON.stringify(A,(e,t)=>typeof t=="bigint"?`BigInt(${t})`:t)}function gc(A,e){if(e.length<A.length)throw Error("Wrong number of message arguments");let t=new sn;A.forEach(a=>a.buildTypeTable(t));let r=new TextEncoder().encode(ir),n=t.encode(),i=(0,k.lebEncode)(e.length),s=(0,tA.concat)(...A.map(a=>a.encodeType(t))),c=(0,tA.concat)(...Gt(A,e,(a,p)=>{if(!a.covariant(p))throw new Error(`Invalid ${a.display()} argument: ${Xi(p)}`);return a.encodeValue(p)}));return(0,tA.concat)(r,n,i,s,c)}_.encode=gc;function uc(A,e){let t=new tA.PipeArrayBuffer(e);if(e.byteLength<ir.length)throw new Error("Message length smaller than magic number");let r=(0,k.safeRead)(t,ir.length),n=new TextDecoder().decode(r);if(n!==ir)throw new Error("Wrong magic number: "+JSON.stringify(n));function i(y){let q=[],O=Number((0,k.lebDecode)(y));for(let W=0;W<O;W++){let Z=Number((0,k.slebDecode)(y));switch(Z){case-18:case-19:{let iA=Number((0,k.slebDecode)(y));q.push([Z,iA]);break}case-20:case-21:{let iA=[],v=Number((0,k.lebDecode)(y)),M;for(;v--;){let P=Number((0,k.lebDecode)(y));if(P>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof M=="number"&&M>=P)throw new Error("field id collision or not sorted");M=P;let D=Number((0,k.slebDecode)(y));iA.push([P,D])}q.push([Z,iA]);break}case-22:{let iA=[],v=Number((0,k.lebDecode)(y));for(;v--;)iA.push(Number((0,k.slebDecode)(y)));let M=[],P=Number((0,k.lebDecode)(y));for(;P--;)M.push(Number((0,k.slebDecode)(y)));let D=[],x=Number((0,k.lebDecode)(y));for(;x--;)switch(Number((0,k.lebDecode)(y))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}default:throw new Error("unknown annotation")}q.push([Z,[iA,M,D]]);break}case-23:{let iA=Number((0,k.lebDecode)(y)),v=[];for(;iA--;){let M=Number((0,k.lebDecode)(y)),P=new TextDecoder().decode((0,k.safeRead)(y,M)),D=(0,k.slebDecode)(y);v.push([P,D])}q.push([Z,v]);break}default:throw new Error("Illegal op_code: "+Z)}}let V=[],Y=Number((0,k.lebDecode)(y));for(let W=0;W<Y;W++)V.push(Number((0,k.slebDecode)(y)));return[q,V]}let[s,c]=i(t);if(c.length<A.length)throw new Error("Wrong number of return values");let a=s.map(y=>es());function p(y){if(y<-24)throw new Error("future value not supported");if(y<0)switch(y){case-1:return _.Null;case-2:return _.Bool;case-3:return _.Nat;case-4:return _.Int;case-5:return _.Nat8;case-6:return _.Nat16;case-7:return _.Nat32;case-8:return _.Nat64;case-9:return _.Int8;case-10:return _.Int16;case-11:return _.Int32;case-12:return _.Int64;case-13:return _.Float32;case-14:return _.Float64;case-15:return _.Text;case-16:return _.Reserved;case-17:return _.Empty;case-24:return _.Principal;default:throw new Error("Illegal op_code: "+y)}if(y>=s.length)throw new Error("type index out of range");return a[y]}function m(y){switch(y[0]){case-19:{let q=p(y[1]);return $i(q)}case-18:{let q=p(y[1]);return Di(q)}case-20:{let q={};for(let[Y,W]of y[1]){let Z=`_${Y}_`;q[Z]=p(W)}let O=Li(q),V=O.tryAsTuple();return Array.isArray(V)?zi(...V):O}case-21:{let q={};for(let[O,V]of y[1]){let Y=`_${O}_`;q[Y]=p(V)}return As(q)}case-22:{let[q,O,V]=y[1];return ts(q.map(Y=>p(Y)),O.map(Y=>p(Y)),V)}case-23:{let q={},O=y[1];for(let[V,Y]of O){let W=p(Y);if(W instanceof Qe&&(W=W.getType()),!(W instanceof Nt))throw new Error("Illegal service definition: services can only contain functions");q[V]=W}return rs(q)}default:throw new Error("Illegal op_code: "+y[0])}}s.forEach((y,q)=>{let O=m(y);a[q].fill(O)});let F=c.map(y=>p(y)),R=A.map((y,q)=>y.decodeValue(t,F[q]));for(let y=A.length;y<F.length;y++)F[y].decodeValue(t,F[y]);if(t.byteLength>0)throw new Error("decode: Left-over bytes");return R}_.decode=uc;_.Empty=new sr;_.Reserved=new nt;_.Unknown=new or;_.Bool=new ar;_.Null=new cr;_.Text=new Br;_.Int=new gr;_.Nat=new ur;_.Float32=new mt(32);_.Float64=new mt(64);_.Int8=new Ne(8);_.Int16=new Ne(16);_.Int32=new Ne(32);_.Int64=new Ne(64);_.Nat8=new le(8);_.Nat16=new le(16);_.Nat32=new le(32);_.Nat64=new le(64);_.Principal=new Er;function zi(...A){return new st(A)}_.Tuple=zi;function $i(A){return new it(A)}_.Vec=$i;function Di(A){return new be(A)}_.Opt=Di;function Li(A){return new Ve(A)}_.Record=Li;function As(A){return new ot(A)}_.Variant=As;function es(){return new Qe}_.Rec=es;function ts(A,e,t=[]){return new Nt(A,e,t)}_.Func=ts;function rs(A){return new lr(A)}_.Service=rs});var Qn=J(HA=>{"use strict";Object.defineProperty(HA,"__esModule",{value:!0});HA.VecForm=HA.OptionForm=HA.VariantForm=HA.TupleForm=HA.RecordForm=HA.InputForm=HA.InputBox=void 0;var Bn=class{constructor(e,t){this.idl=e,this.ui=t,this.label=null,this.value=void 0;let r=document.createElement("span");r.className="status",this.status=r,t.input&&(t.input.addEventListener("blur",()=>{t.input.value!==""&&this.parse()}),t.input.addEventListener("input",()=>{r.style.display="none",t.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let t=this.ui.form.parse(e);return this.value=t,t}if(this.ui.input){let t=this.ui.input;try{let r=this.ui.parse(this.idl,e,t.value);if(!this.idl.covariant(r))throw new Error(`${t.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=r,r}catch(r){t.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+r.message,this.value=void 0;return}}return null}render(e){let t=document.createElement("span");if(this.label){let r=document.createElement("label");r.innerText=this.label,t.appendChild(r)}this.ui.input&&(t.appendChild(this.ui.input),t.appendChild(this.status)),this.ui.form&&this.ui.form.render(t),e.appendChild(t)}};HA.InputBox=Bn;var xe=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(t=>t.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(t=>t.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let t=this;t.ui.open.addEventListener(t.ui.event,()=>{if(t.ui.container)t.ui.container.innerHTML="";else{let r=t.ui.open.nextElementSibling;r&&r.parentNode.removeChild(r)}t.generateForm(),t.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};HA.InputForm=xe;var gn=class extends xe{constructor(e,t){super(t),this.fields=e,this.ui=t}generateForm(){this.form=this.fields.map(([e,t])=>{let r=this.ui.render(t);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?r.label=this.ui.labelMap[e]+" ":r.label=e+" ",r})}parse(e){let t={};if(this.fields.forEach(([r,n],i)=>{let s=this.form[i].parse(e);t[r]=s}),!this.form.some(r=>r.isRejected()))return t}};HA.RecordForm=gn;var un=class extends xe{constructor(e,t){super(t),this.components=e,this.ui=t}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let t=[];if(this.components.forEach((r,n)=>{let i=this.form[n].parse(e);t.push(i)}),!this.form.some(r=>r.isRejected()))return t}};HA.TupleForm=un;var En=class extends xe{constructor(e,t){super(t),this.fields=e,this.ui=t}generateForm(){let e=this.ui.open.selectedIndex,[t,r]=this.fields[e],n=this.ui.render(r);this.form=[n]}parse(e){let t=this.ui.open,r=t.options[t.selectedIndex].value,n=this.form[0].parse(e);if(n===void 0)return;let i={};return i[r]=n,i}};HA.VariantForm=En;var ln=class extends xe{constructor(e,t){super(t),this.ty=e,this.ui=t}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let t=this.form[0].parse(e);return t===void 0?void 0:[t]}}};HA.OptionForm=ln;var hn=class extends xe{constructor(e,t){super(t),this.ty=e,this.ui=t}generateForm(){let e=+this.ui.open.value;this.form=[];for(let t=0;t<e;t++){let r=this.ui.render(this.ty);this.form.push(r)}}parse(e){let t=this.form.map(r=>r.parse(e));if(!this.form.some(r=>r.isRejected()))return t}};HA.VecForm=hn});var is=J(z=>{"use strict";var Ec=z&&z.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),lc=z&&z.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),ns=z&&z.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.prototype.hasOwnProperty.call(A,t)&&Ec(e,A,t);return lc(e,A),e};Object.defineProperty(z,"__esModule",{value:!0});z.renderValue=z.renderInput=z.Render=z.vecForm=z.optForm=z.variantForm=z.tupleForm=z.recordForm=z.inputBox=void 0;var Qr=ns(cn()),fn=ue(),at=ns(Qn()),hc={parse:wc},Ft={render:In},Qc=(A,e)=>new at.InputBox(A,Object.assign(Object.assign({},hc),e));z.inputBox=Qc;var fc=(A,e)=>new at.RecordForm(A,Object.assign(Object.assign({},Ft),e));z.recordForm=fc;var dc=(A,e)=>new at.TupleForm(A,Object.assign(Object.assign({},Ft),e));z.tupleForm=dc;var pc=(A,e)=>new at.VariantForm(A,Object.assign(Object.assign({},Ft),e));z.variantForm=pc;var Cc=(A,e)=>new at.OptionForm(A,Object.assign(Object.assign({},Ft),e));z.optForm=Cc;var Ic=(A,e)=>new at.VecForm(A,Object.assign(Object.assign({},Ft),e));z.vecForm=Ic;var hr=class extends Qr.Visitor{visitType(e,t){let r=document.createElement("input");return r.classList.add("argument"),r.placeholder=e.display(),(0,z.inputBox)(e,{input:r})}visitNull(e,t){return(0,z.inputBox)(e,{})}visitRecord(e,t,r){let n={};if(t.length>1){let s=document.createElement("div");s.classList.add("popup-form"),n={container:s}}let i=(0,z.recordForm)(t,n);return(0,z.inputBox)(e,{form:i})}visitTuple(e,t,r){let n={};if(t.length>1){let s=document.createElement("div");s.classList.add("popup-form"),n={container:s}}let i=(0,z.tupleForm)(t,n);return(0,z.inputBox)(e,{form:i})}visitVariant(e,t,r){let n=document.createElement("select");for(let[c,a]of t){let p=new Option(c);n.add(p)}n.selectedIndex=-1,n.classList.add("open");let i={open:n,event:"change"},s=(0,z.variantForm)(t,i);return(0,z.inputBox)(e,{form:s})}visitOpt(e,t,r){let n=document.createElement("input");n.type="checkbox",n.classList.add("open");let i=(0,z.optForm)(t,{open:n,event:"change"});return(0,z.inputBox)(e,{form:i})}visitVec(e,t,r){let n=document.createElement("input");n.type="number",n.min="0",n.max="100",n.style.width="8rem",n.placeholder="len",n.classList.add("open");let i=document.createElement("div");i.classList.add("popup-form");let s=(0,z.vecForm)(t,{open:n,event:"change",container:i});return(0,z.inputBox)(e,{form:s})}visitRec(e,t,r){return In(t)}};z.Render=hr;var dn=class extends Qr.Visitor{visitNull(e,t){return null}visitBool(e,t){if(t==="true")return!0;if(t==="false")return!1;throw new Error(`Cannot parse ${t} as boolean`)}visitText(e,t){return t}visitFloat(e,t){return parseFloat(t)}visitFixedInt(e,t){return e._bits<=32?parseInt(t,10):BigInt(t)}visitFixedNat(e,t){return e._bits<=32?parseInt(t,10):BigInt(t)}visitNumber(e,t){return BigInt(t)}visitPrincipal(e,t){return fn.Principal.fromText(t)}visitService(e,t){return fn.Principal.fromText(t)}visitFunc(e,t){let r=t.split(".",2);return[fn.Principal.fromText(r[0]),r[1]]}},pn=class extends Qr.Visitor{visitNull(e,t){return null}visitBool(e,t){return Math.random()<.5}visitText(e,t){return Math.random().toString(36).substring(6)}visitFloat(e,t){return Math.random()}visitInt(e,t){return BigInt(this.generateNumber(!0))}visitNat(e,t){return BigInt(this.generateNumber(!1))}visitFixedInt(e,t){let r=this.generateNumber(!0);return e._bits<=32?r:BigInt(t)}visitFixedNat(e,t){let r=this.generateNumber(!1);return e._bits<=32?r:BigInt(t)}generateNumber(e){let t=Math.floor(Math.random()*100);return e&&Math.random()<.5?-t:t}};function wc(A,e,t){return e.random&&t===""?A.accept(new pn,t):A.accept(new dn,t)}function In(A){return A.accept(new hr,null)}z.renderInput=In;function Ze(A,e,t){return A.accept(new Cn,{input:e,value:t})}z.renderValue=Ze;var Cn=class extends Qr.Visitor{visitType(e,t){t.input.ui.input.value=e.valueToString(t.value)}visitNull(e,t){}visitText(e,t){t.input.ui.input.value=t.value}visitRec(e,t,r){Ze(t,r.input,r.value)}visitOpt(e,t,r){if(r.value.length!==0){let n=r.input.ui.form,i=n.ui.open;i.checked=!0,i.dispatchEvent(new Event(n.ui.event)),Ze(t,n.form[0],r.value[0])}}visitRecord(e,t,r){let n=r.input.ui.form;t.forEach(([i,s],c)=>{Ze(s,n.form[c],r.value[i])})}visitTuple(e,t,r){let n=r.input.ui.form;t.forEach((i,s)=>{Ze(i,n.form[s],r.value[s])})}visitVariant(e,t,r){let n=r.input.ui.form,i=Object.entries(r.value)[0];t.forEach(([s,c],a)=>{if(s===i[0]){let p=n.ui.open;p.selectedIndex=a,p.dispatchEvent(new Event(n.ui.event)),Ze(c,n.form[0],i[1])}})}visitVec(e,t,r){let n=r.input.ui.form,i=r.value.length,s=n.ui.open;s.value=i,s.dispatchEvent(new Event(n.ui.event)),r.value.forEach((c,a)=>{Ze(t,n.form[a],c)})}}});var os=J(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0})});var St=J(SA=>{"use strict";var as=SA&&SA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),_c=SA&&SA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),ct=SA&&SA.__exportStar||function(A,e){for(var t in A)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&as(e,A,t)},yc=SA&&SA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.prototype.hasOwnProperty.call(A,t)&&as(e,A,t);return _c(e,A),e};Object.defineProperty(SA,"__esModule",{value:!0});SA.IDL=void 0;ct(is(),SA);ct(Qn(),SA);SA.IDL=yc(cn());ct(tn(),SA);ct(nn(),SA);ct(tr(),SA);ct(os(),SA)});var Rt=J((cs,fr)=>{(function(A){"use strict";var e,t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,n=Math.floor,i="[BigNumber Error] ",s=i+"Number primitive has more than 15 significant digits: ",c=1e14,a=14,p=9007199254740991,m=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],F=1e7,R=1e9;function y(v){var M,P,D,x=S.prototype={constructor:S,toString:null,valueOf:null},rA=new S(1),nA=20,sA=4,hA=-7,CA=21,GA=-1e7,xA=1e7,UA=!1,QA=1,MA=0,Ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},OA="0123456789abcdefghijklmnopqrstuvwxyz",_e=!0;function S(o,B){var g,C,h,f,w,u,Q,I,d=this;if(!(d instanceof S))return new S(o,B);if(B==null){if(o&&o._isBigNumber===!0){d.s=o.s,!o.c||o.e>xA?d.c=d.e=null:o.e<GA?d.c=[d.e=0]:(d.e=o.e,d.c=o.c.slice());return}if((u=typeof o=="number")&&o*0==0){if(d.s=1/o<0?(o=-o,-1):1,o===~~o){for(f=0,w=o;w>=10;w/=10,f++);f>xA?d.c=d.e=null:(d.e=f,d.c=[o]);return}I=String(o)}else{if(!t.test(I=String(o)))return D(d,I,u);d.s=I.charCodeAt(0)==45?(I=I.slice(1),-1):1}(f=I.indexOf("."))>-1&&(I=I.replace(".","")),(w=I.search(/e/i))>0?(f<0&&(f=w),f+=+I.slice(w+1),I=I.substring(0,w)):f<0&&(f=I.length)}else{if(Y(B,2,OA.length,"Base"),B==10&&_e)return d=new S(o),mA(d,nA+d.e+1,sA);if(I=String(o),u=typeof o=="number"){if(o*0!=0)return D(d,I,u,B);if(d.s=1/o<0?(I=I.slice(1),-1):1,S.DEBUG&&I.replace(/^0\.0*|\./,"").length>15)throw Error(s+o)}else d.s=I.charCodeAt(0)===45?(I=I.slice(1),-1):1;for(g=OA.slice(0,B),f=w=0,Q=I.length;w<Q;w++)if(g.indexOf(C=I.charAt(w))<0){if(C=="."){if(w>f){f=Q;continue}}else if(!h&&(I==I.toUpperCase()&&(I=I.toLowerCase())||I==I.toLowerCase()&&(I=I.toUpperCase()))){h=!0,w=-1,f=0;continue}return D(d,String(o),u,B)}u=!1,I=P(I,B,10,d.s),(f=I.indexOf("."))>-1?I=I.replace(".",""):f=I.length}for(w=0;I.charCodeAt(w)===48;w++);for(Q=I.length;I.charCodeAt(--Q)===48;);if(I=I.slice(w,++Q)){if(Q-=w,u&&S.DEBUG&&Q>15&&(o>p||o!==n(o)))throw Error(s+d.s*o);if((f=f-w-1)>xA)d.c=d.e=null;else if(f<GA)d.c=[d.e=0];else{if(d.e=f,d.c=[],w=(f+1)%a,f<0&&(w+=a),w<Q){for(w&&d.c.push(+I.slice(0,w)),Q-=a;w<Q;)d.c.push(+I.slice(w,w+=a));w=a-(I=I.slice(w)).length}else w-=Q;for(;w--;I+="0");d.c.push(+I)}}else d.c=[d.e=0]}S.clone=y,S.ROUND_UP=0,S.ROUND_DOWN=1,S.ROUND_CEIL=2,S.ROUND_FLOOR=3,S.ROUND_HALF_UP=4,S.ROUND_HALF_DOWN=5,S.ROUND_HALF_EVEN=6,S.ROUND_HALF_CEIL=7,S.ROUND_HALF_FLOOR=8,S.EUCLID=9,S.config=S.set=function(o){var B,g;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(B="DECIMAL_PLACES")&&(g=o[B],Y(g,0,R,B),nA=g),o.hasOwnProperty(B="ROUNDING_MODE")&&(g=o[B],Y(g,0,8,B),sA=g),o.hasOwnProperty(B="EXPONENTIAL_AT")&&(g=o[B],g&&g.pop?(Y(g[0],-R,0,B),Y(g[1],0,R,B),hA=g[0],CA=g[1]):(Y(g,-R,R,B),hA=-(CA=g<0?-g:g))),o.hasOwnProperty(B="RANGE"))if(g=o[B],g&&g.pop)Y(g[0],-R,-1,B),Y(g[1],1,R,B),GA=g[0],xA=g[1];else if(Y(g,-R,R,B),g)GA=-(xA=g<0?-g:g);else throw Error(i+B+" cannot be zero: "+g);if(o.hasOwnProperty(B="CRYPTO"))if(g=o[B],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))UA=g;else throw UA=!g,Error(i+"crypto unavailable");else UA=g;else throw Error(i+B+" not true or false: "+g);if(o.hasOwnProperty(B="MODULO_MODE")&&(g=o[B],Y(g,0,9,B),QA=g),o.hasOwnProperty(B="POW_PRECISION")&&(g=o[B],Y(g,0,R,B),MA=g),o.hasOwnProperty(B="FORMAT"))if(g=o[B],typeof g=="object")Ae=g;else throw Error(i+B+" not an object: "+g);if(o.hasOwnProperty(B="ALPHABET"))if(g=o[B],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))_e=g.slice(0,10)=="0123456789",OA=g;else throw Error(i+B+" invalid: "+g)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:nA,ROUNDING_MODE:sA,EXPONENTIAL_AT:[hA,CA],RANGE:[GA,xA],CRYPTO:UA,MODULO_MODE:QA,POW_PRECISION:MA,FORMAT:Ae,ALPHABET:OA}},S.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!S.DEBUG)return!0;var B,g,C=o.c,h=o.e,f=o.s;A:if({}.toString.call(C)=="[object Array]"){if((f===1||f===-1)&&h>=-R&&h<=R&&h===n(h)){if(C[0]===0){if(h===0&&C.length===1)return!0;break A}if(B=(h+1)%a,B<1&&(B+=a),String(C[0]).length==B){for(B=0;B<C.length;B++)if(g=C[B],g<0||g>=c||g!==n(g))break A;if(g!==0)return!0}}}else if(C===null&&h===null&&(f===null||f===1||f===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},S.maximum=S.max=function(){return oe(arguments,x.lt)},S.minimum=S.min=function(){return oe(arguments,x.gt)},S.random=function(){var o=9007199254740992,B=Math.random()*o&2097151?function(){return n(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var C,h,f,w,u,Q=0,I=[],d=new S(rA);if(g==null?g=nA:Y(g,0,R),w=r(g/a),UA)if(crypto.getRandomValues){for(C=crypto.getRandomValues(new Uint32Array(w*=2));Q<w;)u=C[Q]*131072+(C[Q+1]>>>11),u>=9e15?(h=crypto.getRandomValues(new Uint32Array(2)),C[Q]=h[0],C[Q+1]=h[1]):(I.push(u%1e14),Q+=2);Q=w/2}else if(crypto.randomBytes){for(C=crypto.randomBytes(w*=7);Q<w;)u=(C[Q]&31)*281474976710656+C[Q+1]*1099511627776+C[Q+2]*4294967296+C[Q+3]*16777216+(C[Q+4]<<16)+(C[Q+5]<<8)+C[Q+6],u>=9e15?crypto.randomBytes(7).copy(C,Q):(I.push(u%1e14),Q+=7);Q=w/7}else throw UA=!1,Error(i+"crypto unavailable");if(!UA)for(;Q<w;)u=B(),u<9e15&&(I[Q++]=u%1e14);for(w=I[--Q],g%=a,w&&g&&(u=m[a-g],I[Q]=n(w/u)*u);I[Q]===0;I.pop(),Q--);if(Q<0)I=[f=0];else{for(f=-1;I[0]===0;I.splice(0,1),f-=a);for(Q=1,u=I[0];u>=10;u/=10,Q++);Q<a&&(f-=a-Q)}return d.e=f,d.c=I,d}}(),S.sum=function(){for(var o=1,B=arguments,g=new S(B[0]);o<B.length;)g=g.plus(B[o++]);return g},P=function(){var o="0123456789";function B(g,C,h,f){for(var w,u=[0],Q,I=0,d=g.length;I<d;){for(Q=u.length;Q--;u[Q]*=C);for(u[0]+=f.indexOf(g.charAt(I++)),w=0;w<u.length;w++)u[w]>h-1&&(u[w+1]==null&&(u[w+1]=0),u[w+1]+=u[w]/h|0,u[w]%=h)}return u.reverse()}return function(g,C,h,f,w){var u,Q,I,d,N,b,H,X,oA=g.indexOf("."),gA=nA,j=sA;for(oA>=0&&(d=MA,MA=0,g=g.replace(".",""),X=new S(C),b=X.pow(g.length-oA),MA=d,X.c=B(iA(O(b.c),b.e,"0"),10,h,o),X.e=X.c.length),H=B(g,C,h,w?(u=OA,o):(u=o,OA)),I=d=H.length;H[--d]==0;H.pop());if(!H[0])return u.charAt(0);if(oA<0?--I:(b.c=H,b.e=I,b.s=f,b=M(b,X,gA,j,h),H=b.c,N=b.r,I=b.e),Q=I+gA+1,oA=H[Q],d=h/2,N=N||Q<0||H[Q+1]!=null,N=j<4?(oA!=null||N)&&(j==0||j==(b.s<0?3:2)):oA>d||oA==d&&(j==4||N||j==6&&H[Q-1]&1||j==(b.s<0?8:7)),Q<1||!H[0])g=N?iA(u.charAt(1),-gA,u.charAt(0)):u.charAt(0);else{if(H.length=Q,N)for(--h;++H[--Q]>h;)H[Q]=0,Q||(++I,H=[1].concat(H));for(d=H.length;!H[--d];);for(oA=0,g="";oA<=d;g+=u.charAt(H[oA++]));g=iA(g,I,u.charAt(0))}return g}}(),M=function(){function o(C,h,f){var w,u,Q,I,d=0,N=C.length,b=h%F,H=h/F|0;for(C=C.slice();N--;)Q=C[N]%F,I=C[N]/F|0,w=H*Q+I*b,u=b*Q+w%F*F+d,d=(u/f|0)+(w/F|0)+H*I,C[N]=u%f;return d&&(C=[d].concat(C)),C}function B(C,h,f,w){var u,Q;if(f!=w)Q=f>w?1:-1;else for(u=Q=0;u<f;u++)if(C[u]!=h[u]){Q=C[u]>h[u]?1:-1;break}return Q}function g(C,h,f,w){for(var u=0;f--;)C[f]-=u,u=C[f]<h[f]?1:0,C[f]=u*w+C[f]-h[f];for(;!C[0]&&C.length>1;C.splice(0,1));}return function(C,h,f,w,u){var Q,I,d,N,b,H,X,oA,gA,j,U,fA,ae,ye,Ge,vA,AA,YA=C.s==h.s?1:-1,kA=C.c,uA=h.c;if(!kA||!kA[0]||!uA||!uA[0])return new S(!C.s||!h.s||(kA?uA&&kA[0]==uA[0]:!uA)?NaN:kA&&kA[0]==0||!uA?YA*0:YA/0);for(oA=new S(YA),gA=oA.c=[],I=C.e-h.e,YA=f+I+1,u||(u=c,I=q(C.e/a)-q(h.e/a),YA=YA/a|0),d=0;uA[d]==(kA[d]||0);d++);if(uA[d]>(kA[d]||0)&&I--,YA<0)gA.push(1),N=!0;else{for(ye=kA.length,vA=uA.length,d=0,YA+=2,b=n(u/(uA[0]+1)),b>1&&(uA=o(uA,b,u),kA=o(kA,b,u),vA=uA.length,ye=kA.length),ae=vA,j=kA.slice(0,vA),U=j.length;U<vA;j[U++]=0);AA=uA.slice(),AA=[0].concat(AA),Ge=uA[0],uA[1]>=u/2&&Ge++;do{if(b=0,Q=B(uA,j,vA,U),Q<0){if(fA=j[0],vA!=U&&(fA=fA*u+(j[1]||0)),b=n(fA/Ge),b>1)for(b>=u&&(b=u-1),H=o(uA,b,u),X=H.length,U=j.length;B(H,j,X,U)==1;)b--,g(H,vA<X?AA:uA,X,u),X=H.length,Q=1;else b==0&&(Q=b=1),H=uA.slice(),X=H.length;if(X<U&&(H=[0].concat(H)),g(j,H,U,u),U=j.length,Q==-1)for(;B(uA,j,vA,U)<1;)b++,g(j,vA<U?AA:uA,U,u),U=j.length}else Q===0&&(b++,j=[0]);gA[d++]=b,j[0]?j[U++]=kA[ae]||0:(j=[kA[ae]],U=1)}while((ae++<ye||j[0]!=null)&&YA--);N=j[0]!=null,gA[0]||gA.splice(0,1)}if(u==c){for(d=1,YA=gA[0];YA>=10;YA/=10,d++);mA(oA,f+(oA.e=d+I*a-1)+1,w,N)}else oA.e=I,oA.r=+N;return oA}}();function l(o,B,g,C){var h,f,w,u,Q;if(g==null?g=sA:Y(g,0,8),!o.c)return o.toString();if(h=o.c[0],w=o.e,B==null)Q=O(o.c),Q=C==1||C==2&&(w<=hA||w>=CA)?Z(Q,w):iA(Q,w,"0");else if(o=mA(new S(o),B,g),f=o.e,Q=O(o.c),u=Q.length,C==1||C==2&&(B<=f||f<=hA)){for(;u<B;Q+="0",u++);Q=Z(Q,f)}else if(B-=w,Q=iA(Q,f,"0"),f+1>u){if(--B>0)for(Q+=".";B--;Q+="0");}else if(B+=f-u,B>0)for(f+1==u&&(Q+=".");B--;Q+="0");return o.s<0&&h?"-"+Q:Q}function oe(o,B){for(var g,C=1,h=new S(o[0]);C<o.length;C++)if(g=new S(o[C]),g.s)B.call(h,g)&&(h=g);else{h=g;break}return h}function ee(o,B,g){for(var C=1,h=B.length;!B[--h];B.pop());for(h=B[0];h>=10;h/=10,C++);return(g=C+g*a-1)>xA?o.c=o.e=null:g<GA?o.c=[o.e=0]:(o.e=g,o.c=B),o}D=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,B=/^([^.]+)\.$/,g=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,h=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(f,w,u,Q){var I,d=u?w:w.replace(h,"");if(C.test(d))f.s=isNaN(d)?null:d<0?-1:1;else{if(!u&&(d=d.replace(o,function(N,b,H){return I=(H=H.toLowerCase())=="x"?16:H=="b"?2:8,!Q||Q==I?b:N}),Q&&(I=Q,d=d.replace(B,"$1").replace(g,"0.$1")),w!=d))return new S(d,I);if(S.DEBUG)throw Error(i+"Not a"+(Q?" base "+Q:"")+" number: "+w);f.s=null}f.c=f.e=null}}();function mA(o,B,g,C){var h,f,w,u,Q,I,d,N=o.c,b=m;if(N){A:{for(h=1,u=N[0];u>=10;u/=10,h++);if(f=B-h,f<0)f+=a,w=B,Q=N[I=0],d=Q/b[h-w-1]%10|0;else if(I=r((f+1)/a),I>=N.length)if(C){for(;N.length<=I;N.push(0));Q=d=0,h=1,f%=a,w=f-a+1}else break A;else{for(Q=u=N[I],h=1;u>=10;u/=10,h++);f%=a,w=f-a+h,d=w<0?0:Q/b[h-w-1]%10|0}if(C=C||B<0||N[I+1]!=null||(w<0?Q:Q%b[h-w-1]),C=g<4?(d||C)&&(g==0||g==(o.s<0?3:2)):d>5||d==5&&(g==4||C||g==6&&(f>0?w>0?Q/b[h-w]:0:N[I-1])%10&1||g==(o.s<0?8:7)),B<1||!N[0])return N.length=0,C?(B-=o.e+1,N[0]=b[(a-B%a)%a],o.e=-B||0):N[0]=o.e=0,o;if(f==0?(N.length=I,u=1,I--):(N.length=I+1,u=b[a-f],N[I]=w>0?n(Q/b[h-w]%b[w])*u:0),C)for(;;)if(I==0){for(f=1,w=N[0];w>=10;w/=10,f++);for(w=N[0]+=u,u=1;w>=10;w/=10,u++);f!=u&&(o.e++,N[0]==c&&(N[0]=1));break}else{if(N[I]+=u,N[I]!=c)break;N[I--]=0,u=1}for(f=N.length;N[--f]===0;N.pop());}o.e>xA?o.c=o.e=null:o.e<GA&&(o.c=[o.e=0])}return o}function T(o){var B,g=o.e;return g===null?o.toString():(B=O(o.c),B=g<=hA||g>=CA?Z(B,g):iA(B,g,"0"),o.s<0?"-"+B:B)}return x.absoluteValue=x.abs=function(){var o=new S(this);return o.s<0&&(o.s=1),o},x.comparedTo=function(o,B){return V(this,new S(o,B))},x.decimalPlaces=x.dp=function(o,B){var g,C,h,f=this;if(o!=null)return Y(o,0,R),B==null?B=sA:Y(B,0,8),mA(new S(f),o+f.e+1,B);if(!(g=f.c))return null;if(C=((h=g.length-1)-q(this.e/a))*a,h=g[h])for(;h%10==0;h/=10,C--);return C<0&&(C=0),C},x.dividedBy=x.div=function(o,B){return M(this,new S(o,B),nA,sA)},x.dividedToIntegerBy=x.idiv=function(o,B){return M(this,new S(o,B),0,1)},x.exponentiatedBy=x.pow=function(o,B){var g,C,h,f,w,u,Q,I,d,N=this;if(o=new S(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+T(o));if(B!=null&&(B=new S(B)),u=o.e>14,!N.c||!N.c[0]||N.c[0]==1&&!N.e&&N.c.length==1||!o.c||!o.c[0])return d=new S(Math.pow(+T(N),u?2-W(o):+T(o))),B?d.mod(B):d;if(Q=o.s<0,B){if(B.c?!B.c[0]:!B.s)return new S(NaN);C=!Q&&N.isInteger()&&B.isInteger(),C&&(N=N.mod(B))}else{if(o.e>9&&(N.e>0||N.e<-1||(N.e==0?N.c[0]>1||u&&N.c[1]>=24e7:N.c[0]<8e13||u&&N.c[0]<=9999975e7)))return f=N.s<0&&W(o)?-0:0,N.e>-1&&(f=1/f),new S(Q?1/f:f);MA&&(f=r(MA/a+2))}for(u?(g=new S(.5),Q&&(o.s=1),I=W(o)):(h=Math.abs(+T(o)),I=h%2),d=new S(rA);;){if(I){if(d=d.times(N),!d.c)break;f?d.c.length>f&&(d.c.length=f):C&&(d=d.mod(B))}if(h){if(h=n(h/2),h===0)break;I=h%2}else if(o=o.times(g),mA(o,o.e+1,1),o.e>14)I=W(o);else{if(h=+T(o),h===0)break;I=h%2}N=N.times(N),f?N.c&&N.c.length>f&&(N.c.length=f):C&&(N=N.mod(B))}return C?d:(Q&&(d=rA.div(d)),B?d.mod(B):f?mA(d,MA,sA,w):d)},x.integerValue=function(o){var B=new S(this);return o==null?o=sA:Y(o,0,8),mA(B,B.e+1,o)},x.isEqualTo=x.eq=function(o,B){return V(this,new S(o,B))===0},x.isFinite=function(){return!!this.c},x.isGreaterThan=x.gt=function(o,B){return V(this,new S(o,B))>0},x.isGreaterThanOrEqualTo=x.gte=function(o,B){return(B=V(this,new S(o,B)))===1||B===0},x.isInteger=function(){return!!this.c&&q(this.e/a)>this.c.length-2},x.isLessThan=x.lt=function(o,B){return V(this,new S(o,B))<0},x.isLessThanOrEqualTo=x.lte=function(o,B){return(B=V(this,new S(o,B)))===-1||B===0},x.isNaN=function(){return!this.s},x.isNegative=function(){return this.s<0},x.isPositive=function(){return this.s>0},x.isZero=function(){return!!this.c&&this.c[0]==0},x.minus=function(o,B){var g,C,h,f,w=this,u=w.s;if(o=new S(o,B),B=o.s,!u||!B)return new S(NaN);if(u!=B)return o.s=-B,w.plus(o);var Q=w.e/a,I=o.e/a,d=w.c,N=o.c;if(!Q||!I){if(!d||!N)return d?(o.s=-B,o):new S(N?w:NaN);if(!d[0]||!N[0])return N[0]?(o.s=-B,o):new S(d[0]?w:sA==3?-0:0)}if(Q=q(Q),I=q(I),d=d.slice(),u=Q-I){for((f=u<0)?(u=-u,h=d):(I=Q,h=N),h.reverse(),B=u;B--;h.push(0));h.reverse()}else for(C=(f=(u=d.length)<(B=N.length))?u:B,u=B=0;B<C;B++)if(d[B]!=N[B]){f=d[B]<N[B];break}if(f&&(h=d,d=N,N=h,o.s=-o.s),B=(C=N.length)-(g=d.length),B>0)for(;B--;d[g++]=0);for(B=c-1;C>u;){if(d[--C]<N[C]){for(g=C;g&&!d[--g];d[g]=B);--d[g],d[C]+=c}d[C]-=N[C]}for(;d[0]==0;d.splice(0,1),--I);return d[0]?ee(o,d,I):(o.s=sA==3?-1:1,o.c=[o.e=0],o)},x.modulo=x.mod=function(o,B){var g,C,h=this;return o=new S(o,B),!h.c||!o.s||o.c&&!o.c[0]?new S(NaN):!o.c||h.c&&!h.c[0]?new S(h):(QA==9?(C=o.s,o.s=1,g=M(h,o,0,3),o.s=C,g.s*=C):g=M(h,o,0,QA),o=h.minus(g.times(o)),!o.c[0]&&QA==1&&(o.s=h.s),o)},x.multipliedBy=x.times=function(o,B){var g,C,h,f,w,u,Q,I,d,N,b,H,X,oA,gA,j=this,U=j.c,fA=(o=new S(o,B)).c;if(!U||!fA||!U[0]||!fA[0])return!j.s||!o.s||U&&!U[0]&&!fA||fA&&!fA[0]&&!U?o.c=o.e=o.s=null:(o.s*=j.s,!U||!fA?o.c=o.e=null:(o.c=[0],o.e=0)),o;for(C=q(j.e/a)+q(o.e/a),o.s*=j.s,Q=U.length,N=fA.length,Q<N&&(X=U,U=fA,fA=X,h=Q,Q=N,N=h),h=Q+N,X=[];h--;X.push(0));for(oA=c,gA=F,h=N;--h>=0;){for(g=0,b=fA[h]%gA,H=fA[h]/gA|0,w=Q,f=h+w;f>h;)I=U[--w]%gA,d=U[w]/gA|0,u=H*I+d*b,I=b*I+u%gA*gA+X[f]+g,g=(I/oA|0)+(u/gA|0)+H*d,X[f--]=I%oA;X[f]=g}return g?++C:X.splice(0,1),ee(o,X,C)},x.negated=function(){var o=new S(this);return o.s=-o.s||null,o},x.plus=function(o,B){var g,C=this,h=C.s;if(o=new S(o,B),B=o.s,!h||!B)return new S(NaN);if(h!=B)return o.s=-B,C.minus(o);var f=C.e/a,w=o.e/a,u=C.c,Q=o.c;if(!f||!w){if(!u||!Q)return new S(h/0);if(!u[0]||!Q[0])return Q[0]?o:new S(u[0]?C:h*0)}if(f=q(f),w=q(w),u=u.slice(),h=f-w){for(h>0?(w=f,g=Q):(h=-h,g=u),g.reverse();h--;g.push(0));g.reverse()}for(h=u.length,B=Q.length,h-B<0&&(g=Q,Q=u,u=g,B=h),h=0;B;)h=(u[--B]=u[B]+Q[B]+h)/c|0,u[B]=c===u[B]?0:u[B]%c;return h&&(u=[h].concat(u),++w),ee(o,u,w)},x.precision=x.sd=function(o,B){var g,C,h,f=this;if(o!=null&&o!==!!o)return Y(o,1,R),B==null?B=sA:Y(B,0,8),mA(new S(f),o,B);if(!(g=f.c))return null;if(h=g.length-1,C=h*a+1,h=g[h]){for(;h%10==0;h/=10,C--);for(h=g[0];h>=10;h/=10,C++);}return o&&f.e+1>C&&(C=f.e+1),C},x.shiftedBy=function(o){return Y(o,-p,p),this.times("1e"+o)},x.squareRoot=x.sqrt=function(){var o,B,g,C,h,f=this,w=f.c,u=f.s,Q=f.e,I=nA+4,d=new S("0.5");if(u!==1||!w||!w[0])return new S(!u||u<0&&(!w||w[0])?NaN:w?f:1/0);if(u=Math.sqrt(+T(f)),u==0||u==1/0?(B=O(w),(B.length+Q)%2==0&&(B+="0"),u=Math.sqrt(+B),Q=q((Q+1)/2)-(Q<0||Q%2),u==1/0?B="5e"+Q:(B=u.toExponential(),B=B.slice(0,B.indexOf("e")+1)+Q),g=new S(B)):g=new S(u+""),g.c[0]){for(Q=g.e,u=Q+I,u<3&&(u=0);;)if(h=g,g=d.times(h.plus(M(f,h,I,1))),O(h.c).slice(0,u)===(B=O(g.c)).slice(0,u))if(g.e<Q&&--u,B=B.slice(u-3,u+1),B=="9999"||!C&&B=="4999"){if(!C&&(mA(h,h.e+nA+2,0),h.times(h).eq(f))){g=h;break}I+=4,u+=4,C=1}else{(!+B||!+B.slice(1)&&B.charAt(0)=="5")&&(mA(g,g.e+nA+2,1),o=!g.times(g).eq(f));break}}return mA(g,g.e+nA+1,sA,o)},x.toExponential=function(o,B){return o!=null&&(Y(o,0,R),o++),l(this,o,B,1)},x.toFixed=function(o,B){return o!=null&&(Y(o,0,R),o=o+this.e+1),l(this,o,B)},x.toFormat=function(o,B,g){var C,h=this;if(g==null)o!=null&&B&&typeof B=="object"?(g=B,B=null):o&&typeof o=="object"?(g=o,o=B=null):g=Ae;else if(typeof g!="object")throw Error(i+"Argument not an object: "+g);if(C=h.toFixed(o,B),h.c){var f,w=C.split("."),u=+g.groupSize,Q=+g.secondaryGroupSize,I=g.groupSeparator||"",d=w[0],N=w[1],b=h.s<0,H=b?d.slice(1):d,X=H.length;if(Q&&(f=u,u=Q,Q=f,X-=f),u>0&&X>0){for(f=X%u||u,d=H.substr(0,f);f<X;f+=u)d+=I+H.substr(f,u);Q>0&&(d+=I+H.slice(f)),b&&(d="-"+d)}C=N?d+(g.decimalSeparator||"")+((Q=+g.fractionGroupSize)?N.replace(new RegExp("\\d{"+Q+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):N):d}return(g.prefix||"")+C+(g.suffix||"")},x.toFraction=function(o){var B,g,C,h,f,w,u,Q,I,d,N,b,H=this,X=H.c;if(o!=null&&(u=new S(o),!u.isInteger()&&(u.c||u.s!==1)||u.lt(rA)))throw Error(i+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+T(u));if(!X)return new S(H);for(B=new S(rA),I=g=new S(rA),C=Q=new S(rA),b=O(X),f=B.e=b.length-H.e-1,B.c[0]=m[(w=f%a)<0?a+w:w],o=!o||u.comparedTo(B)>0?f>0?B:I:u,w=xA,xA=1/0,u=new S(b),Q.c[0]=0;d=M(u,B,0,1),h=g.plus(d.times(C)),h.comparedTo(o)!=1;)g=C,C=h,I=Q.plus(d.times(h=I)),Q=h,B=u.minus(d.times(h=B)),u=h;return h=M(o.minus(g),C,0,1),Q=Q.plus(h.times(I)),g=g.plus(h.times(C)),Q.s=I.s=H.s,f=f*2,N=M(I,C,f,sA).minus(H).abs().comparedTo(M(Q,g,f,sA).minus(H).abs())<1?[I,C]:[Q,g],xA=w,N},x.toNumber=function(){return+T(this)},x.toPrecision=function(o,B){return o!=null&&Y(o,1,R),l(this,o,B,2)},x.toString=function(o){var B,g=this,C=g.s,h=g.e;return h===null?C?(B="Infinity",C<0&&(B="-"+B)):B="NaN":(o==null?B=h<=hA||h>=CA?Z(O(g.c),h):iA(O(g.c),h,"0"):o===10&&_e?(g=mA(new S(g),nA+h+1,sA),B=iA(O(g.c),g.e,"0")):(Y(o,2,OA.length,"Base"),B=P(iA(O(g.c),h,"0"),10,o,C,!0)),C<0&&g.c[0]&&(B="-"+B)),B},x.valueOf=x.toJSON=function(){return T(this)},x._isBigNumber=!0,v!=null&&S.set(v),S}function q(v){var M=v|0;return v>0||v===M?M:M-1}function O(v){for(var M,P,D=1,x=v.length,rA=v[0]+"";D<x;){for(M=v[D++]+"",P=a-M.length;P--;M="0"+M);rA+=M}for(x=rA.length;rA.charCodeAt(--x)===48;);return rA.slice(0,x+1||1)}function V(v,M){var P,D,x=v.c,rA=M.c,nA=v.s,sA=M.s,hA=v.e,CA=M.e;if(!nA||!sA)return null;if(P=x&&!x[0],D=rA&&!rA[0],P||D)return P?D?0:-sA:nA;if(nA!=sA)return nA;if(P=nA<0,D=hA==CA,!x||!rA)return D?0:!x^P?1:-1;if(!D)return hA>CA^P?1:-1;for(sA=(hA=x.length)<(CA=rA.length)?hA:CA,nA=0;nA<sA;nA++)if(x[nA]!=rA[nA])return x[nA]>rA[nA]^P?1:-1;return hA==CA?0:hA>CA^P?1:-1}function Y(v,M,P,D){if(v<M||v>P||v!==n(v))throw Error(i+(D||"Argument")+(typeof v=="number"?v<M||v>P?" out of range: ":" not an integer: ":" not a primitive number: ")+String(v))}function W(v){var M=v.c.length-1;return q(v.e/a)==M&&v.c[M]%2!=0}function Z(v,M){return(v.length>1?v.charAt(0)+"."+v.slice(1):v)+(M<0?"e":"e+")+M}function iA(v,M,P){var D,x;if(M<0){for(x=P+".";++M;x+=P);v=x+v}else if(D=v.length,++M>D){for(x=P,M-=D;--M;x+=P);v+=x}else M<D&&(v=v.slice(0,M)+"."+v.slice(M));return v}e=y(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof fr<"u"&&fr.exports?fr.exports=e:(A||(A=typeof self<"u"&&self?self:window),A.BigNumber=e)})(cs)});var gs=J((Ju,Bs)=>{Bs.exports=function(e,t,r){var n=new e.Uint8Array(r),i=t.pushInt,s=t.pushInt32,c=t.pushInt32Neg,a=t.pushInt64,p=t.pushInt64Neg,m=t.pushFloat,F=t.pushFloatSingle,R=t.pushFloatDouble,y=t.pushTrue,q=t.pushFalse,O=t.pushUndefined,V=t.pushNull,Y=t.pushInfinity,W=t.pushInfinityNeg,Z=t.pushNaN,iA=t.pushNaNNeg,v=t.pushArrayStart,M=t.pushArrayStartFixed,P=t.pushArrayStartFixed32,D=t.pushArrayStartFixed64,x=t.pushObjectStart,rA=t.pushObjectStartFixed,nA=t.pushObjectStartFixed32,sA=t.pushObjectStartFixed64,hA=t.pushByteString,CA=t.pushByteStringStart,GA=t.pushUtf8String,xA=t.pushUtf8StringStart,UA=t.pushSimpleUnassigned,QA=t.pushTagStart,MA=t.pushTagStart4,Ae=t.pushTagStart8,OA=t.pushTagUnassigned,_e=t.pushBreak,S=e.Math.pow,l=0,oe=0,ee=0;function mA(E){for(E=E|0,l=0,oe=E;(l|0)<(oe|0)&&(ee=ra[n[l]&255](n[l]|0)|0,!((ee|0)>0)););return ee|0}function T(E){return E=E|0,((l|0)+(E|0)|0)<(oe|0)?0:1}function o(E){return E=E|0,n[E|0]<<8|n[E+1|0]|0}function B(E){return E=E|0,n[E|0]<<24|n[E+1|0]<<16|n[E+2|0]<<8|n[E+3|0]|0}function g(E){return E=E|0,i(E|0),l=l+1|0,0}function C(E){return E=E|0,T(1)|0?1:(i(n[l+1|0]|0),l=l+2|0,0)}function h(E){return E=E|0,T(2)|0?1:(i(o(l+1|0)|0),l=l+3|0,0)}function f(E){return E=E|0,T(4)|0?1:(s(o(l+1|0)|0,o(l+3|0)|0),l=l+5|0,0)}function w(E){return E=E|0,T(8)|0?1:(a(o(l+1|0)|0,o(l+3|0)|0,o(l+5|0)|0,o(l+7|0)|0),l=l+9|0,0)}function u(E){return E=E|0,i(-1-(E-32|0)|0),l=l+1|0,0}function Q(E){return E=E|0,T(1)|0?1:(i(-1-(n[l+1|0]|0)|0),l=l+2|0,0)}function I(E){E=E|0;var L=0;return T(2)|0?1:(L=o(l+1|0)|0,i(-1-(L|0)|0),l=l+3|0,0)}function d(E){return E=E|0,T(4)|0?1:(c(o(l+1|0)|0,o(l+3|0)|0),l=l+5|0,0)}function N(E){return E=E|0,T(8)|0?1:(p(o(l+1|0)|0,o(l+3|0)|0,o(l+5|0)|0,o(l+7|0)|0),l=l+9|0,0)}function b(E){E=E|0;var L=0,eA=0,$=0;return $=E-64|0,T($|0)|0?1:(L=l+1|0,eA=(l+1|0)+($|0)|0,hA(L|0,eA|0),l=eA|0,0)}function H(E){E=E|0;var L=0,eA=0,$=0;return T(1)|0||($=n[l+1|0]|0,L=l+2|0,eA=(l+2|0)+($|0)|0,T($+1|0)|0)?1:(hA(L|0,eA|0),l=eA|0,0)}function X(E){E=E|0;var L=0,eA=0,$=0;return T(2)|0||($=o(l+1|0)|0,L=l+3|0,eA=(l+3|0)+($|0)|0,T($+2|0)|0)?1:(hA(L|0,eA|0),l=eA|0,0)}function oA(E){E=E|0;var L=0,eA=0,$=0;return T(4)|0||($=B(l+1|0)|0,L=l+5|0,eA=(l+5|0)+($|0)|0,T($+4|0)|0)?1:(hA(L|0,eA|0),l=eA|0,0)}function gA(E){return E=E|0,1}function j(E){return E=E|0,CA(),l=l+1|0,0}function U(E){E=E|0;var L=0,eA=0,$=0;return $=E-96|0,T($|0)|0?1:(L=l+1|0,eA=(l+1|0)+($|0)|0,GA(L|0,eA|0),l=eA|0,0)}function fA(E){E=E|0;var L=0,eA=0,$=0;return T(1)|0||($=n[l+1|0]|0,L=l+2|0,eA=(l+2|0)+($|0)|0,T($+1|0)|0)?1:(GA(L|0,eA|0),l=eA|0,0)}function ae(E){E=E|0;var L=0,eA=0,$=0;return T(2)|0||($=o(l+1|0)|0,L=l+3|0,eA=(l+3|0)+($|0)|0,T($+2|0)|0)?1:(GA(L|0,eA|0),l=eA|0,0)}function ye(E){E=E|0;var L=0,eA=0,$=0;return T(4)|0||($=B(l+1|0)|0,L=l+5|0,eA=(l+5|0)+($|0)|0,T($+4|0)|0)?1:(GA(L|0,eA|0),l=eA|0,0)}function Ge(E){return E=E|0,1}function vA(E){return E=E|0,xA(),l=l+1|0,0}function AA(E){return E=E|0,M(E-128|0),l=l+1|0,0}function YA(E){return E=E|0,T(1)|0?1:(M(n[l+1|0]|0),l=l+2|0,0)}function kA(E){return E=E|0,T(2)|0?1:(M(o(l+1|0)|0),l=l+3|0,0)}function uA(E){return E=E|0,T(4)|0?1:(P(o(l+1|0)|0,o(l+3|0)|0),l=l+5|0,0)}function Ho(E){return E=E|0,T(8)|0?1:(D(o(l+1|0)|0,o(l+3|0)|0,o(l+5|0)|0,o(l+7|0)|0),l=l+9|0,0)}function To(E){return E=E|0,v(),l=l+1|0,0}function EA(E){E=E|0;var L=0;return L=E-160|0,T(L|0)|0?1:(rA(L|0),l=l+1|0,0)}function Uo(E){return E=E|0,T(1)|0?1:(rA(n[l+1|0]|0),l=l+2|0,0)}function Oo(E){return E=E|0,T(2)|0?1:(rA(o(l+1|0)|0),l=l+3|0,0)}function Yo(E){return E=E|0,T(4)|0?1:(nA(o(l+1|0)|0,o(l+3|0)|0),l=l+5|0,0)}function Jo(E){return E=E|0,T(8)|0?1:(sA(o(l+1|0)|0,o(l+3|0)|0,o(l+5|0)|0,o(l+7|0)|0),l=l+9|0,0)}function Po(E){return E=E|0,x(),l=l+1|0,0}function $e(E){return E=E|0,QA(E-192|0|0),l=l+1|0,0}function gu(E){return E=E|0,QA(E|0),l=l+1|0,0}function uu(E){return E=E|0,QA(E|0),l=l+1|0,0}function Eu(E){return E=E|0,QA(E|0),l=l+1|0,0}function lu(E){return E=E|0,QA(E|0),l=l+1|0,0}function NA(E){return E=E|0,QA(E-192|0|0),l=l+1|0,0}function hu(E){return E=E|0,QA(E|0),l=l+1|0,0}function Qu(E){return E=E|0,QA(E|0),l=l+1|0,0}function fu(E){return E=E|0,QA(E|0),l=l+1|0,0}function Vo(E){return E=E|0,T(1)|0?1:(QA(n[l+1|0]|0),l=l+2|0,0)}function Zo(E){return E=E|0,T(2)|0?1:(QA(o(l+1|0)|0),l=l+3|0,0)}function jo(E){return E=E|0,T(4)|0?1:(MA(o(l+1|0)|0,o(l+3|0)|0),l=l+5|0,0)}function Ko(E){return E=E|0,T(8)|0?1:(Ae(o(l+1|0)|0,o(l+3|0)|0,o(l+5|0)|0,o(l+7|0)|0),l=l+9|0,0)}function IA(E){return E=E|0,UA((E|0)-224|0),l=l+1|0,0}function Wo(E){return E=E|0,q(),l=l+1|0,0}function Xo(E){return E=E|0,y(),l=l+1|0,0}function zo(E){return E=E|0,V(),l=l+1|0,0}function $o(E){return E=E|0,O(),l=l+1|0,0}function Do(E){return E=E|0,T(1)|0?1:(UA(n[l+1|0]|0),l=l+2|0,0)}function Lo(E){E=E|0;var L=0,eA=0,$=1,Zt=0,wt=0,du=0;return T(2)|0?1:(L=n[l+1|0]|0,eA=n[l+2|0]|0,(L|0)&128&&($=-1),Zt=+(((L|0)&124)>>2),wt=+(((L|0)&3)<<8|eA),+Zt==0?m(+(+$*5960464477539063e-23*+wt)):+Zt==31?+$==1?+wt>0?Z():Y():+wt>0?iA():W():m(+(+$*S(2,+(+Zt-25))*+(1024+wt))),l=l+3|0,0)}function Aa(E){return E=E|0,T(4)|0?1:(F(n[l+1|0]|0,n[l+2|0]|0,n[l+3|0]|0,n[l+4|0]|0),l=l+5|0,0)}function ea(E){return E=E|0,T(8)|0?1:(R(n[l+1|0]|0,n[l+2|0]|0,n[l+3|0]|0,n[l+4|0]|0,n[l+5|0]|0,n[l+6|0]|0,n[l+7|0]|0,n[l+8|0]|0),l=l+9|0,0)}function cA(E){return E=E|0,1}function ta(E){return E=E|0,_e(),l=l+1|0,0}var ra=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,C,h,f,w,cA,cA,cA,cA,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u,Q,I,d,N,cA,cA,cA,cA,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,H,X,oA,gA,cA,cA,cA,j,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,fA,ae,ye,Ge,cA,cA,cA,vA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,AA,YA,kA,uA,Ho,cA,cA,cA,To,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,EA,Uo,Oo,Yo,Jo,cA,cA,cA,Po,$e,$e,$e,$e,$e,$e,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,Vo,Zo,jo,Ko,cA,cA,cA,cA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,IA,Wo,Xo,zo,$o,Do,Lo,Aa,ea,cA,cA,cA,ta];return{parse:mA}}});var bt=J(jA=>{"use strict";var wn=Rt().BigNumber;jA.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};jA.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};jA.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};jA.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};jA.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};jA.SHIFT32=Math.pow(2,32);jA.SHIFT16=Math.pow(2,16);jA.MAX_SAFE_HIGH=2097151;jA.NEG_ONE=new wn(-1);jA.TEN=new wn(10);jA.TWO=new wn(2);jA.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var dr=J($A=>{"use strict";var{Buffer:Gc}=require("buffer"),Es=Rt().BigNumber,ls=bt(),us=ls.SHIFT32,mc=ls.SHIFT16,Nc=2097151;$A.parseHalf=function(e){var t,r,n;return n=e[0]&128?-1:1,t=(e[0]&124)>>2,r=(e[0]&3)<<8|e[1],t?t===31?n*(r?0/0:1/0):n*Math.pow(2,t-25)*(1024+r):n*5960464477539063e-23*r};function Fc(A){return A<16?"0"+A.toString(16):A.toString(16)}$A.arrayBufferToBignumber=function(A){let e=A.byteLength,t="";for(let r=0;r<e;r++)t+=Fc(A[r]);return new Es(t,16)};$A.buildMap=A=>{let e=new Map,t=Object.keys(A),r=t.length;for(let n=0;n<r;n++)e.set(t[n],A[t[n]]);return e};$A.buildInt32=(A,e)=>A*mc+e;$A.buildInt64=(A,e,t,r)=>{let n=$A.buildInt32(A,e),i=$A.buildInt32(t,r);return n>Nc?new Es(n).times(us).plus(i):n*us+i};$A.writeHalf=function(e,t){let r=Gc.allocUnsafe(4);r.writeFloatBE(t,0);let n=r.readUInt32BE(0);if((n&8191)!==0)return!1;var i=n>>16&32768;let s=n>>23&255,c=n&8388607;if(s>=113&&s<=142)i+=(s-112<<10)+(c>>13);else if(s>=103&&s<113){if(c&(1<<126-s)-1)return!1;i+=c+8388608>>126-s}else return!1;return e.writeUInt16BE(i,0),!0};$A.keySorter=function(A,e){var t=A[0].byteLength,r=e[0].byteLength;return t>r?1:r>t?-1:A[0].compare(e[0])};$A.isNegativeZero=A=>A===0&&1/A<0;$A.nextPowerOf2=A=>{let e=0;if(A&&!(A&A-1))return A;for(;A!==0;)A>>=1,e+=1;return 1<<e}});var Gn=J((Zu,hs)=>{"use strict";var yn=bt(),Sc=yn.MT,pr=yn.SIMPLE,_n=yn.SYMS,Bt=class{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Sc.SIMPLE_FLOAT)}static isSimple(e){return e instanceof Bt}static decode(e,t){switch(t==null&&(t=!0),e){case pr.FALSE:return!1;case pr.TRUE:return!0;case pr.NULL:return t?null:_n.NULL;case pr.UNDEFINED:return t?void 0:_n.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return _n.BREAK;default:return new Bt(e)}}};hs.exports=Bt});var mn=J((ju,Qs)=>{"use strict";var gt=class{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var t,r;if(r=e!=null?e[this.tag]:void 0,typeof r!="function"&&(r=gt["_tag"+this.tag],typeof r!="function"))return this;try{return r.call(gt,this.value)}catch(n){return t=n,this.err=t,this}}};Qs.exports=gt});var Fn=J((Ku,ds)=>{"use strict";var{URL:Rc,URLSearchParams:bc,format:xc}=require("url"),fs="http://localhost",Nn=class extends Rc{constructor(e="",t=fs){super(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}format(){return this.toString()}};ds.exports={URLWithLegacySupport:Nn,URLSearchParams:bc,format:xc,defaultBase:fs}});var Is=J((Wu,Cs)=>{"use strict";var{URLWithLegacySupport:ps,format:kc}=Fn();Cs.exports=(A,e={},t={},r)=>{let n=e.protocol?e.protocol.replace(":",""):"http";n=(t[n]||r||n)+":";let i;try{i=new ps(A)}catch{i={}}let s=Object.assign({},e,{protocol:n||i.protocol,host:e.host||i.host});return new ps(A,kc(s)).toString()}});var Sn=J((Xu,ws)=>{"use strict";var{URLWithLegacySupport:qc,format:Mc,URLSearchParams:vc,defaultBase:Hc}=Fn(),Tc=Is();ws.exports={URL:qc,URLSearchParams:vc,format:Mc,relative:Tc,defaultBase:Hc}});var Rn=J((zu,ys)=>{"use strict";var{Buffer:ut}=require("buffer"),_s=jr(),Uc=Rt().BigNumber,Oc=gs(),TA=dr(),aA=bt(),Yc=Gn(),Jc=mn(),{URL:Pc}=Sn(),ke=class{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=TA.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=ut.from(this._heap),this._reset(),this._knownTags=Object.assign({0:t=>new Date(t),1:t=>new Date(t*1e3),2:t=>TA.arrayBufferToBignumber(t),3:t=>aA.NEG_ONE.minus(TA.arrayBufferToBignumber(t)),4:t=>aA.TEN.pow(t[0]).times(t[1]),5:t=>aA.TWO.pow(t[0]).times(t[1]),32:t=>new Pc(t),35:t=>new RegExp(t)},e.tags),this.parser=Oc(global,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case aA.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case aA.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case aA.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case aA.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case aA.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case aA.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===aA.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,t){let r=this._currentParent;switch(r.values++,r.type){case aA.PARENT.ARRAY:case aA.PARENT.BYTE_STRING:case aA.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=e:this._ref.push(e),this._dec();break;case aA.PARENT.OBJECT:r.tmpKey!=null?(this._ref[r.tmpKey]=e,r.tmpKey=null,this._dec()):(r.tmpKey=e,typeof r.tmpKey!="string"&&(r.type=aA.PARENT.MAP,r.ref=TA.buildMap(r.ref)));break;case aA.PARENT.MAP:r.tmpKey!=null?(this._ref.set(r.tmpKey,e),r.tmpKey=null,this._dec()):r.tmpKey=e;break;case aA.PARENT.TAG:this._ref.push(e),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,t,r){this._parents[this._depth]={type:t,length:r,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:aA.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){let r=this._knownTags[e];return r?r(t):new Jc(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return ut.concat(e)}createByteStringFromHeap(e,t){return e===t?ut.alloc(0):ut.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return TA.buildInt32(e,t)}createInt64(e,t,r,n){return TA.buildInt64(e,t,r,n)}createFloat(e){return e}createFloatSingle(e,t,r,n){return _s.read([e,t,r,n],0,!1,23,4)}createFloatDouble(e,t,r,n,i,s,c,a){return _s.read([e,t,r,n,i,s,c,a],0,!1,52,8)}createInt32Neg(e,t){return-1-TA.buildInt32(e,t)}createInt64Neg(e,t,r,n){let i=TA.buildInt32(e,t),s=TA.buildInt32(r,n);return i>aA.MAX_SAFE_HIGH?aA.NEG_ONE.minus(new Uc(i).times(aA.SHIFT32).plus(s)):-1-(i*aA.SHIFT32+s)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,t){return e.join("")}createUtf8StringFromHeap(e,t){return e===t?"":this._buffer.toString("utf8",e,t)}createSimpleUnassigned(e){return new Yc(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,t){this._push(this.createInt32(e,t))}pushInt64(e,t,r,n){this._push(this.createInt64(e,t,r,n))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,t,r,n){this._push(this.createFloatSingle(e,t,r,n))}pushFloatDouble(e,t,r,n,i,s,c,a){this._push(this.createFloatDouble(e,t,r,n,i,s,c,a))}pushInt32Neg(e,t){this._push(this.createInt32Neg(e,t))}pushInt64Neg(e,t,r,n){this._push(this.createInt64Neg(e,t,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],aA.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){let r=TA.buildInt32(e,t);this._createArrayStartFixed(r)}pushArrayStartFixed64(e,t,r,n){let i=TA.buildInt64(e,t,r,n);this._createArrayStartFixed(i)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){let r=TA.buildInt32(e,t);this._createObjectStartFixed(r)}pushObjectStartFixed64(e,t,r,n){let i=TA.buildInt64(e,t,r,n);this._createObjectStartFixed(i)}pushByteStringStart(){this._parents[this._depth]={type:aA.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,t){this._push(this.createByteStringFromHeap(e,t))}pushUtf8StringStart(){this._parents[this._depth]={type:aA.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,t){this._push(this.createUtf8StringFromHeap(e,t))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:aA.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(TA.buildInt32(e,t))}pushTagStart8(e,t,r,n){this.pushTagStart(TA.buildInt64(e,t,r,n))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},aA.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),aA.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let t=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(t>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,t){return typeof e=="string"&&(e=ut.from(e,t||"hex")),new ke({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return typeof e=="string"&&(e=ut.from(e,t||"hex")),new ke({size:e.length}).decodeAll(e)}};ke.decodeFirst=ke.decode;ys.exports=ke});var Ns=J(($u,ms)=>{"use strict";var{Buffer:bn}=require("buffer"),Vc=Rn(),Zc=dr(),xt=class extends Vc{createTag(e,t){return`${e}(${t})`}createInt(e){return super.createInt(e).toString()}createInt32(e,t){return super.createInt32(e,t).toString()}createInt64(e,t,r,n){return super.createInt64(e,t,r,n).toString()}createInt32Neg(e,t){return super.createInt32Neg(e,t).toString()}createInt64Neg(e,t,r,n){return super.createInt64Neg(e,t,r,n).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let t=super.createFloat(e);return Zc.isNegativeZero(e)?"-0_1":`${t}_1`}createFloatSingle(e,t,r,n){return`${super.createFloatSingle(e,t,r,n)}_2`}createFloatDouble(e,t,r,n,i,s,c,a){return`${super.createFloatDouble(e,t,r,n,i,s,c,a)}_3`}createByteString(e,t){let r=e.join(", ");return t===-1?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(e,t){return`h'${bn.from(super.createByteStringFromHeap(e,t)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,t){let r=super.createArray(e,t);return t===-1?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(e,t){let r=super.createMap(e),n=Array.from(r.keys()).reduce(Gs(r),"");return t===-1?`{_ ${n}}`:`{${n}}`}createObject(e,t){let r=super.createObject(e),n=Object.keys(r).reduce(Gs(r),"");return t===-1?`{_ ${n}}`:`{${n}}`}createUtf8String(e,t){let r=e.join(", ");return t===-1?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(e,t){return`"${bn.from(super.createUtf8StringFromHeap(e,t)).toString("utf8")}"`}static diagnose(e,t){return typeof e=="string"&&(e=bn.from(e,t||"hex")),new xt().decodeFirst(e)}};ms.exports=xt;function Gs(A){return(e,t)=>e?`${e}, ${t}: ${A[t]}`:`${t}: ${A[t]}`}});var xs=J((Du,bs)=>{"use strict";var{Buffer:fe}=require("buffer"),{URL:jc}=Sn(),kn=Rt().BigNumber,xn=dr(),wA=bt(),te=wA.MT,Cr=wA.NUMBYTES,Fs=wA.SHIFT32,Ss=wA.SYMS,Et=wA.TAG,Kc=wA.MT.SIMPLE_FLOAT<<5|wA.NUMBYTES.TWO,Wc=wA.MT.SIMPLE_FLOAT<<5|wA.NUMBYTES.FOUR,Xc=wA.MT.SIMPLE_FLOAT<<5|wA.NUMBYTES.EIGHT,zc=wA.MT.SIMPLE_FLOAT<<5|wA.SIMPLE.TRUE,$c=wA.MT.SIMPLE_FLOAT<<5|wA.SIMPLE.FALSE,Dc=wA.MT.SIMPLE_FLOAT<<5|wA.SIMPLE.UNDEFINED,Rs=wA.MT.SIMPLE_FLOAT<<5|wA.SIMPLE.NULL,Lc=new kn("0x20000000000000"),AB=fe.from("f97e00","hex"),eB=fe.from("f9fc00","hex"),tB=fe.from("f97c00","hex");function rB(A){return{}.toString.call(A).slice(8,-1)}var lt=class{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[jc,this._pushUrl],[kn,this._pushBigNumber]];let t=e.genTypes||[],r=t.length;for(let n=0;n<r;n++)this.addSemanticType(t[n][0],t[n][1]);this._reset()}addSemanticType(e,t){let r=this.semanticTypes.length;for(let n=0;n<r;n++)if(this.semanticTypes[n][0]===e){let s=this.semanticTypes[n][1];return this.semanticTypes[n][1]=t,s}return this.semanticTypes.push([e,t]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,t,r){return this.result[this.offset]=e,this.resultMethod[this.offset]=t,this.resultLength[this.offset]=r,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(AB)}_pushInfinity(e){let t=e<0?eB:tB;return this.push(t)}_pushFloat(e){let t=fe.allocUnsafe(2);if(xn.writeHalf(t,e)&&xn.parseHalf(t)===e)return this._pushUInt8(Kc)&&this.push(t);let r=fe.allocUnsafe(4);return r.writeFloatBE(e,0),r.readFloatBE(0)===e?this._pushUInt8(Wc)&&this.push(r):this._pushUInt8(Xc)&&this._pushDoubleBE(e)}_pushInt(e,t,r){let n=t<<5;return e<24?this._pushUInt8(n|e):e<=255?this._pushUInt8(n|Cr.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(n|Cr.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(n|Cr.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(n|Cr.EIGHT)&&this._pushUInt32BE(Math.floor(e/Fs))&&this._pushUInt32BE(e%Fs):t===te.NEG_INT?this._pushFloat(r):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,te.NEG_INT,e):this._pushInt(e,te.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let t=fe.byteLength(e,"utf8");return this._pushInt(t,te.UTF8_STRING)&&this.pushWrite(e,5,t)}_pushBoolean(e){return this._pushUInt8(e?zc:$c)}_pushUndefined(e){return this._pushUInt8(Dc)}_pushArray(e,t){let r=t.length;if(!e._pushInt(r,te.ARRAY))return!1;for(let n=0;n<r;n++)if(!e.pushAny(t[n]))return!1;return!0}_pushTag(e){return this._pushInt(e,te.TAG)}_pushDate(e,t){return e._pushTag(Et.DATE_EPOCH)&&e.pushAny(Math.round(t/1e3))}_pushBuffer(e,t){return e._pushInt(t.length,te.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(Et.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,te.ARRAY))return!1;for(let r of t)if(!e.pushAny(r))return!1;return!0}_pushUrl(e,t){return e._pushTag(Et.URI)&&e.pushAny(t.format())}_pushBigint(e){let t=Et.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),t=Et.NEG_BIGINT);let r=e.toString(16);r.length%2&&(r="0"+r);let n=fe.from(r,"hex");return this._pushTag(t)&&this._pushBuffer(this,n)}_pushBigNumber(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushBigint(t);if(!(e._pushTag(Et.DECIMAL_FRAC)&&e._pushInt(2,te.ARRAY)))return!1;let r=t.decimalPlaces(),n=t.multipliedBy(new kn(10).pow(r));return e._pushIntNum(-r)?n.abs().isLessThan(Lc)?e._pushIntNum(n.toNumber()):e._pushBigint(n):!1}_pushMap(e,t){return e._pushInt(t.size,te.MAP)?this._pushRawMap(t.size,Array.from(t)):!1}_pushObject(e){if(!e)return this._pushUInt8(Rs);for(var t=this.semanticTypes.length,r=0;r<t;r++)if(e instanceof this.semanticTypes[r][0])return this.semanticTypes[r][1].call(e,this,e);var n=e.encodeCBOR;if(typeof n=="function")return n.call(e,this);var i=Object.keys(e),s=i.length;return this._pushInt(s,te.MAP)?this._pushRawMap(s,i.map(c=>[c,e[c]])):!1}_pushRawMap(e,t){t=t.map(function(n){return n[0]=lt.encode(n[0]),n}).sort(xn.keySorter);for(var r=0;r<e;r++)if(!this.push(t[r][0])||!this.pushAny(t[r][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var t=rB(e);switch(t){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,fe.isBuffer(e)?e:fe.from(e));case"Null":return this._pushUInt8(Rs);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Ss.NULL:return this._pushObject(null);case Ss.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,t=this.resultLength,r=this.resultMethod,n=this.offset,i=0,s=0;s<n;s++)i+=t[s];var c=fe.allocUnsafe(i),a=0,p=0;for(s=0;s<n;s++){switch(p=t[s],r[s]){case 0:e[s].copy(c,a);break;case 1:c.writeUInt8(e[s],a,!0);break;case 2:c.writeUInt16BE(e[s],a,!0);break;case 3:c.writeUInt32BE(e[s],a,!0);break;case 4:c.writeDoubleBE(e[s],a,!0);break;case 5:c.write(e[s],a,p,"utf8");break;default:throw new Error("unkown method")}a+=p}var m=c;return this._reset(),m}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let t=new lt;if(!t.pushAny(e))throw new Error("Failed to encode input");return t.finalize()}};bs.exports=lt});var qn=J(_A=>{"use strict";_A.Diagnose=Ns();_A.Decoder=Rn();_A.Encoder=xs();_A.Simple=Gn();_A.Tagged=mn();_A.decodeAll=_A.Decoder.decodeAll;_A.decodeFirst=_A.Decoder.decodeFirst;_A.diagnose=_A.Diagnose.diagnose;_A.encode=_A.Encoder.encode;_A.decode=_A.Decoder.decode;_A.leveldb={decode:_A.Decoder.decodeAll,encode:_A.Encoder.encode,buffer:!0,name:"cbor"}});var pe=J(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.compare=de.fromHex=de.toHex=de.concat=void 0;function nB(...A){let e=new Uint8Array(A.reduce((r,n)=>r+n.byteLength,0)),t=0;for(let r of A)e.set(new Uint8Array(r),t),t+=r.byteLength;return e.buffer}de.concat=nB;function iB(A){return[...new Uint8Array(A)].map(e=>e.toString(16).padStart(2,"0")).join("")}de.toHex=iB;var sB=new RegExp(/^([0-9A-F]{2})*$/i);function oB(A){if(!sB.test(A))throw new Error("Invalid hexadecimal string.");let e=[...A].reduce((t,r,n)=>(t[n/2|0]=(t[n/2|0]||"")+r,t),[]).map(t=>Number.parseInt(t,16));return new Uint8Array(e).buffer}de.fromHex=oB;function aB(A,e){if(A.byteLength!==e.byteLength)return A.byteLength-e.byteLength;let t=new Uint8Array(A),r=new Uint8Array(e);for(let n=0;n<t.length;n++)if(t[n]!==r[n])return t[n]-r[n];return 0}de.compare=aB});var qt=J(Ce=>{"use strict";var cB=Ce&&Ce.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(Ce,"__esModule",{value:!0});Ce.requestIdOf=Ce.hashValue=Ce.hash=void 0;var ks=St(),BB=cB(qn()),gB=An(),Ir=pe();function qe(A){return gB.sha256.create().update(new Uint8Array(A)).arrayBuffer()}Ce.hash=qe;function kt(A){if(A instanceof BB.default.Tagged)return kt(A.value);if(typeof A=="string")return qs(A);if(typeof A=="number")return qe(ks.lebEncode(A));if(A instanceof ArrayBuffer||ArrayBuffer.isView(A))return qe(A);if(Array.isArray(A)){let e=A.map(kt);return qe(Ir.concat(...e))}else{if(A&&typeof A=="object"&&A._isPrincipal)return qe(A.toUint8Array());if(typeof A=="object"&&A!==null&&typeof A.toHash=="function")return kt(A.toHash());if(typeof A=="bigint")return qe(ks.lebEncode(A))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${A}`),{value:A})}Ce.hashValue=kt;var qs=A=>{let e=new TextEncoder().encode(A);return qe(e)};function uB(A){let r=Object.entries(A).filter(([,s])=>s!==void 0).map(([s,c])=>{let a=qs(s),p=kt(c);return[a,p]}).sort(([s],[c])=>Ir.compare(s,c)),n=Ir.concat(...r.map(s=>Ir.concat(...s)));return qe(n)}Ce.requestIdOf=uB});var Hn=J(Ie=>{"use strict";var EB=Ie&&Ie.__rest||function(A,e){var t={};for(var r in A)Object.prototype.hasOwnProperty.call(A,r)&&e.indexOf(r)<0&&(t[r]=A[r]);if(A!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(A);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(A,r[n])&&(t[r[n]]=A[r[n]]);return t};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.createIdentityDescriptor=Ie.AnonymousIdentity=Ie.SignIdentity=void 0;var Ms=ue(),lB=qt(),vs=pe(),hB=new TextEncoder().encode(`
2
+ ic-request`),Mn=class{getPrincipal(){return this._principal||(this._principal=Ms.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:t}=e,r=EB(e,["body"]),n=await lB.requestIdOf(t);return Object.assign(Object.assign({},r),{body:{content:t,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign(vs.concat(hB,n))}})}};Ie.SignIdentity=Mn;var vn=class{getPrincipal(){return Ms.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Ie.AnonymousIdentity=vn;function QB(A){return"getPublicKey"in A?{type:"PublicKeyIdentity",publicKey:vs.toHex(A.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Ie.createIdentityDescriptor=QB});var On=J(BA=>{"use strict";Object.defineProperty(BA,"__esModule",{value:!0});var fB=9007199254740992;function Fe(A,...e){let t=new Uint8Array(A.byteLength+e.reduce((n,i)=>n+i.byteLength,0));t.set(new Uint8Array(A),0);let r=A.byteLength;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}function re(A,e,t){t=t.replace(/[^0-9a-fA-F]/g,"");let r=2**(e-24);t=t.slice(-r*2).padStart(r*2,"0");let n=[(A<<5)+e].concat(t.match(/../g).map(i=>parseInt(i,16)));return new Uint8Array(n).buffer}function wr(A,e){if(e<24)return new Uint8Array([(A<<5)+e]).buffer;{let t=e<=255?24:e<=65535?25:e<=4294967295?26:27;return re(A,t,e.toString(16))}}function Hs(A){let e=[];for(let t=0;t<A.length;t++){let r=A.charCodeAt(t);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):r<55296||r>=57344?e.push(224|r>>12,128|r>>6&63,128|r&63):(t++,r=(r&1023)<<10|A.charCodeAt(t)&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63))}return Fe(new Uint8Array(wr(3,A.length)),new Uint8Array(e))}function dB(A,e){if(A==14277111)return Fe(new Uint8Array([217,217,247]),e);if(A<24)return Fe(new Uint8Array([(6<<5)+A]),e);{let t=A<=255?24:A<=65535?25:A<=4294967295?26:27,r=2**(t-24),n=A.toString(16).slice(-r*2).padStart(r*2,"0"),i=[(6<<5)+t].concat(n.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}}BA.tagged=dB;function Mt(A){return new Uint8Array(A).buffer}BA.raw=Mt;function Tn(A){if(isNaN(A))throw new RangeError("Invalid number.");A=Math.min(Math.max(0,A),23);let e=[(0<<5)+A];return new Uint8Array(e).buffer}BA.uSmall=Tn;function Ts(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,A),255),A=A.toString(16),re(0,24,A)}BA.u8=Ts;function Us(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,A),65535),A=A.toString(16),re(0,25,A)}BA.u16=Us;function Os(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,A),4294967295),A=A.toString(16),re(0,26,A)}BA.u32=Os;function Un(A,e){if(typeof A=="string"&&e==16){if(A.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return re(0,27,A)}if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,A),fB),A=A.toString(16),re(0,27,A)}BA.u64=Un;function Ys(A){if(isNaN(A))throw new RangeError("Invalid number.");if(A===0)return Tn(0);A=Math.min(Math.max(0,-A),24)-1;let e=[(1<<5)+A];return new Uint8Array(e).buffer}BA.iSmall=Ys;function Js(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,-A-1),255),A=A.toString(16),re(1,24,A)}BA.i8=Js;function Ps(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,-A-1),65535),A=A.toString(16),re(1,25,A)}BA.i16=Ps;function Vs(A,e){if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,-A-1),4294967295),A=A.toString(16),re(1,26,A)}BA.i32=Vs;function Zs(A,e){if(typeof A=="string"&&e==16){if(A.startsWith("-")?A=A.slice(1):A="0",A.match(/[^0-9a-fA-F]/)||A.length>16)throw new RangeError("Invalid number.");let t=!1,r=A.split("").reduceRight((n,i)=>{if(t)return i+n;let s=parseInt(i,16)-1;return s>=0?(t=!0,s.toString(16)+n):"f"+n},"");return t?re(1,27,r):Un(0)}if(A=parseInt(""+A,e),isNaN(A))throw new RangeError("Invalid number.");return A=Math.min(Math.max(0,-A-1),9007199254740992),A=A.toString(16),re(1,27,A)}BA.i64=Zs;function pB(A){return A>=0?A<24?Tn(A):A<=255?Ts(A):A<=65535?Us(A):A<=4294967295?Os(A):Un(A):A>=-24?Ys(A):A>=-255?Js(A):A>=-65535?Ps(A):A>=-4294967295?Vs(A):Zs(A)}BA.number=pB;function CB(A){return Fe(wr(2,A.byteLength),A)}BA.bytes=CB;function IB(A){return Hs(A)}BA.string=IB;function wB(A){return Fe(wr(4,A.length),...A)}BA.array=wB;function _B(A,e=!1){A instanceof Map||(A=new Map(Object.entries(A)));let t=Array.from(A.entries());return e&&(t=t.sort(([r],[n])=>r.localeCompare(n))),Fe(wr(5,A.size),...t.map(([r,n])=>Fe(Hs(r),n)))}BA.map=_B;function yB(A){let e=new Float32Array([A]);return Fe(new Uint8Array([(7<<5)+26]),new Uint8Array(e.buffer))}BA.singleFloat=yB;function GB(A){let e=new Float64Array([A]);return Fe(new Uint8Array([(7<<5)+27]),new Uint8Array(e.buffer))}BA.doubleFloat=GB;function mB(A){return A?js():Ks()}BA.bool=mB;function js(){return Mt(new Uint8Array([(7<<5)+21]))}BA.true_=js;function Ks(){return Mt(new Uint8Array([(7<<5)+20]))}BA.false_=Ks;function NB(){return Mt(new Uint8Array([(7<<5)+22]))}BA.null_=NB;function FB(){return Mt(new Uint8Array([(7<<5)+23]))}BA.undefined_=FB});var Ws=J(Me=>{"use strict";var SB=Me&&Me.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)Object.hasOwnProperty.call(A,t)&&(e[t]=A[t]);return e.default=A,e};Object.defineProperty(Me,"__esModule",{value:!0});var ne=SB(On()),RB=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],_r=class{constructor(e,t=!1){this._serializer=e,this._stable=t,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return ne.undefined_();case"boolean":return ne.bool(e);case"number":return Math.floor(e)===e?ne.number(e):ne.doubleFloat(e);case"string":return ne.string(e);case"object":if(e===null)return ne.null_();if(Array.isArray(e))return ne.array(e.map(t=>this._serializer.serializeValue(t)));if(RB.find(t=>e instanceof t))return ne.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let t=new Map;for(let[r,n]of e.entries())t.set(r,this._serializer.serializeValue(n));return ne.map(t,this._stable)}else{let t=new Map;for(let[r,n]of Object.entries(e))t.set(r,this._serializer.serializeValue(n));return ne.map(t,this._stable)}default:throw new Error("Invalid value.")}}};Me.JsonDefaultCborEncoder=_r;var yr=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};Me.ToCborEncoder=yr;var Gr=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new _r(t,e)),t.addEncoder(new yr),t}removeEncoder(e){for(let t of this._encoders.values())t.name==e&&this._encoders.delete(t)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let t=null;for(let r of this._encoders)(!t||r.priority>t.priority)&&r.match(e)&&(t=r);if(t===null)throw new Error("Could not find an encoder for value.");return t}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};Me.CborSerializer=Gr;var Yn=class extends Gr{serialize(e){return ne.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};Me.SelfDescribeCborSerializer=Yn});var mr=J(je=>{"use strict";function bB(A){for(var e in A)je.hasOwnProperty(e)||(je[e]=A[e])}var xB=je&&je.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)Object.hasOwnProperty.call(A,t)&&(e[t]=A[t]);return e.default=A,e};Object.defineProperty(je,"__esModule",{value:!0});bB(Ws());var kB=xB(On());je.value=kB});var Fr=J(qA=>{"use strict";var qB=qA&&qA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),MB=qA&&qA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),vB=qA&&qA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&qB(e,A,t);return MB(e,A),e},HB=qA&&qA.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(qA,"__esModule",{value:!0});qA.decode=qA.encode=qA.CborTag=void 0;var TB=HB(qn()),ht=vB(mr()),UB=mr(),Jn=pe(),Pn=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return ht.value.bytes(e.toUint8Array())}},Vn=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return ht.value.bytes(new Uint8Array(e))}},Zn=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?ht.value.tagged(2,ht.value.bytes(Jn.fromHex(e.toString(16)))):ht.value.tagged(3,ht.value.bytes(Jn.fromHex((BigInt("-1")*e).toString(16))))}},Nr=UB.SelfDescribeCborSerializer.withDefaultEncoders(!0);Nr.addEncoder(new Pn);Nr.addEncoder(new Vn);Nr.addEncoder(new Zn);var zs;(function(A){A[A.Uint64LittleEndian=71]="Uint64LittleEndian",A[A.Semantic=55799]="Semantic"})(zs=qA.CborTag||(qA.CborTag={}));function OB(A){return Nr.serialize(A)}qA.encode=OB;function Xs(A){let e=A.byteLength,t=BigInt(0);for(let r=0;r<e;r++)t=t*BigInt(256)+BigInt(A[r]);return t}var jn=class extends TB.default.Decoder{createByteString(e){return Jn.concat(...e)}createByteStringFromHeap(e,t){return e===t?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,t))}};function YB(A){let e=new Uint8Array(A);return new jn({size:e.byteLength,tags:{2:r=>Xs(r),3:r=>-Xs(r),[zs.Semantic]:r=>r}}).decodeFirst(e)}qA.decode=YB});var vt=J(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.makeNonce=Ke.SubmitRequestType=void 0;var JB;(function(A){A.Call="call"})(JB=Ke.SubmitRequestType||(Ke.SubmitRequestType={}));function PB(){let A=new ArrayBuffer(16),e=new DataView(A),t=BigInt(+Date.now()),r=Math.floor(Math.random()*4294967295),n=Math.floor(Math.random()*4294967295);if(typeof e.setBigUint64=="function")e.setBigUint64(0,t);else{let i=BigInt(1)<<BigInt(32);e.setUint32(0,Number(t>>BigInt(32))),e.setUint32(4,Number(t%i))}return e.setUint32(8,r),e.setUint32(12,n),A}Ke.makeNonce=PB});var Rr=J(VA=>{"use strict";var VB=VA&&VA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),ZB=VA&&VA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),jB=VA&&VA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&VB(e,A,t);return ZB(e,A),e};Object.defineProperty(VA,"__esModule",{value:!0});VA.makeExpiryTransform=VA.makeNonceTransform=VA.Expiry=void 0;var KB=St(),WB=jB(mr()),XB=vt(),zB=BigInt(1e6),$B=BigInt(60*1e3),Sr=class{constructor(e){this._value=(BigInt(Date.now())+BigInt(e)-$B)*zB}toCBOR(){return WB.value.u64(this._value.toString(16),16)}toHash(){return KB.lebEncode(this._value)}};VA.Expiry=Sr;function DB(A=XB.makeNonce){return async e=>{e.endpoint==="call"&&(e.body.nonce=A())}}VA.makeNonceTransform=DB;function LB(A){return async e=>{e.body.ingress_expiry=new Sr(A)}}VA.makeExpiryTransform=LB});var Ao=J(yA=>{"use strict";var Ds=yA&&yA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),Ag=yA&&yA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),eg=yA&&yA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&Ds(e,A,t);return Ag(e,A),e},tg=yA&&yA.__exportStar||function(A,e){for(var t in A)t!=="default"&&!e.hasOwnProperty(t)&&Ds(e,A,t)};Object.defineProperty(yA,"__esModule",{value:!0});yA.HttpAgent=yA.IdentityInvalidError=yA.RequestStatusResponseStatus=void 0;var We=ue(),Ls=er(),rg=Hn(),Qt=eg(Fr()),ng=qt(),ig=pe(),br=Rr(),$s=vt();tg(Rr(),yA);var sg=vt();Object.defineProperty(yA,"makeNonce",{enumerable:!0,get:function(){return sg.makeNonce}});var og;(function(A){A.Received="received",A.Processing="processing",A.Replied="replied",A.Rejected="rejected",A.Unknown="unknown",A.Done="done"})(og=yA.RequestStatusResponseStatus||(yA.RequestStatusResponseStatus={}));var Kn=5*60*1e3,ag="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae",cg="ic0.app",Bg=".ic0.app",Ht=class extends Ls.AgentError{constructor(e){super(e),this.message=e}},Xe=class extends Ls.AgentError{constructor(e){super(e),this.message=e}};yA.IdentityInvalidError=Xe;function gg(){let A;if(typeof window<"u")if(window.fetch)A=window.fetch.bind(window);else throw new Ht("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)A=global.fetch.bind(global);else throw new Ht("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(A=self.fetch.bind(self));if(A)return A;throw new Ht("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Tt=class{constructor(e={}){if(this.rootKey=ig.fromHex(ag),this._pipeline=[],this._rootKeyFetched=!1,e.source){if(!(e.source instanceof Tt))throw new Error("An Agent's source can only be another HttpAgent");this._pipeline=[...e.source._pipeline],this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||gg()||fetch.bind(global);if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let t=typeof window<"u"?window.location:void 0;if(!t)throw new Error("Must specify a host to connect to.");this._host=new URL(t+"")}if(this._host.hostname.endsWith(Bg)&&(this._host.hostname=cg),e.credentials){let{name:t,password:r}=e.credentials;this._credentials=`${t}${r?":"+r:""}`}this._identity=Promise.resolve(e.identity||new rg.AnonymousIdentity),e.disableNonce||this.addTransform(br.makeNonceTransform($s.makeNonce))}addTransform(e,t=e.priority||0){let r=this._pipeline.findIndex(n=>(n.priority||0)<t);this._pipeline.splice(r>=0?r:this._pipeline.length,0,Object.assign(e,{priority:t}))}async getPrincipal(){if(!this._identity)throw new Xe("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,t,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Xe("This identity has expired due this application's security policy. Please refresh your authentication.");let i=We.Principal.from(e),s=t.effectiveCanisterId?We.Principal.from(t.effectiveCanisterId):i,c=n.getPrincipal()||We.Principal.anonymous(),a={request_type:$s.SubmitRequestType.Call,canister_id:i,method_name:t.methodName,arg:t.arg,sender:c,ingress_expiry:new br.Expiry(Kn)},p=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:a});p=await n.transformRequest(p);let m=Qt.encode(p.body),[F,R]=await Promise.all([this._fetch(""+new URL(`/api/v2/canister/${s.toText()}/call`,this._host),Object.assign(Object.assign({},p.request),{body:m})),ng.requestIdOf(a)]);if(!F.ok)throw new Error(`Server returned an error:
3
+ Code: ${F.status} (${F.statusText})
4
+ Body: ${await F.text()}
5
+ `);return{requestId:R,response:{ok:F.ok,status:F.status,statusText:F.statusText}}}async query(e,t,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new Xe("This identity has expired due this application's security policy. Please refresh your authentication.");let i=typeof e=="string"?We.Principal.fromText(e):e,s=(n==null?void 0:n.getPrincipal())||We.Principal.anonymous(),c={request_type:"query",canister_id:i,method_name:t.methodName,arg:t.arg,sender:s,ingress_expiry:new br.Expiry(Kn)},a=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:c});a=await(n==null?void 0:n.transformRequest(a));let p=Qt.encode(a.body),m=await this._fetch(""+new URL(`/api/v2/canister/${i.toText()}/query`,this._host),Object.assign(Object.assign({},a.request),{body:p}));if(!m.ok)throw new Error(`Server returned an error:
6
+ Code: ${m.status} (${m.statusText})
7
+ Body: ${await m.text()}
8
+ `);return Qt.decode(await m.arrayBuffer())}async readState(e,t,r){let n=typeof e=="string"?We.Principal.fromText(e):e,i=await(r!==void 0?await r:await this._identity);if(!i)throw new Xe("This identity has expired due this application's security policy. Please refresh your authentication.");let s=(i==null?void 0:i.getPrincipal())||We.Principal.anonymous(),c=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:s,ingress_expiry:new br.Expiry(Kn)}});c=await(i==null?void 0:i.transformRequest(c));let a=Qt.encode(c.body),p=await this._fetch(""+new URL(`/api/v2/canister/${n}/read_state`,this._host),Object.assign(Object.assign({},c.request),{body:a}));if(!p.ok)throw new Error(`Server returned an error:
9
+ Code: ${p.status} (${p.statusText})
10
+ Body: ${await p.text()}
11
+ `);return Qt.decode(await p.arrayBuffer())}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{},t=await this._fetch(""+new URL("/api/v2/status",this._host),{headers:e});if(!t.ok)throw new Error(`Server returned an error:
12
12
  Code: ${t.status} (${t.statusText})
13
13
  Body: ${await t.text()}
14
- `);return Qt.decode(await t.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(A){this._identity=Promise.resolve(A)}_transform(A){let t=Promise.resolve(A);for(let r of this._pipeline)t=t.then(n=>r(n).then(i=>i||n));return t}};GA.HttpAgent=vt});var Ao=T(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ProxyAgent=Fe.ProxyStubAgent=Fe.ProxyMessageKind=void 0;var ig=ue(),dA;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(dA=Fe.ProxyMessageKind||(Fe.ProxyMessageKind={}));var Kn=class{constructor(A,t){this._frontend=A,this._agent=t}onmessage(A){switch(A.type){case dA.GetPrincipal:this._agent.getPrincipal().then(t=>{this._frontend({id:A.id,type:dA.GetPrincipalResponse,response:t.toText()})});break;case dA.Query:this._agent.query(...A.args).then(t=>{this._frontend({id:A.id,type:dA.QueryResponse,response:t})});break;case dA.Call:this._agent.call(...A.args).then(t=>{this._frontend({id:A.id,type:dA.CallResponse,response:t})});break;case dA.ReadState:this._agent.readState(...A.args).then(t=>{this._frontend({id:A.id,type:dA.ReadStateResponse,response:t})});break;case dA.Status:this._agent.status().then(t=>{this._frontend({id:A.id,type:dA.StatusResponse,response:t})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(A)}`)}}};Fe.ProxyStubAgent=Kn;var Wn=class{constructor(A){this._backend=A,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(A){let t=A.id,r=this._pendingCalls.get(t);if(!r)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(t);let[n,i]=r;switch(A.type){case dA.Error:return i(A.error);case dA.GetPrincipalResponse:case dA.CallResponse:case dA.QueryResponse:case dA.ReadStateResponse:case dA.StatusResponse:return n(A.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(A)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:dA.GetPrincipal}).then(A=>{if(typeof A!="string")throw new Error("Invalid principal received.");return ig.Principal.fromText(A)})}readState(A,t){return this._sendAndWait({id:this._nextId++,type:dA.ReadState,args:[A.toString(),t]})}call(A,t){return this._sendAndWait({id:this._nextId++,type:dA.Call,args:[A.toString(),t]})}status(){return this._sendAndWait({id:this._nextId++,type:dA.Status})}query(A,t){return this._sendAndWait({id:this._nextId++,type:dA.Query,args:[A.toString(),t]})}async _sendAndWait(A){return new Promise((t,r)=>{this._pendingCalls.set(A.id,[t,r]),this._backend(A)})}async fetchRootKey(){let A=(await this.status()).root_key;return this.rootKey=A,A}};Fe.ProxyAgent=Wn});var qr=T(se=>{"use strict";var sg=se&&se.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),Xn=se&&se.__exportStar||function(e,A){for(var t in e)t!=="default"&&!A.hasOwnProperty(t)&&sg(A,e,t)};Object.defineProperty(se,"__esModule",{value:!0});se.getDefaultAgent=void 0;Xn(vi(),se);Xn(Ls(),se);Xn(Ao(),se);function og(){let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}se.getDefaultAgent=og});var eo=T(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.default=({IDL:e})=>{let A=e.Principal,t=e.Record({controllers:e.Vec(e.Principal),freezing_threshold:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),r=e.Record({controllers:e.Opt(e.Vec(e.Principal)),freezing_threshold:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),n=e.Vec(e.Nat8);return e.Service({canister_status:e.Func([e.Record({canister_id:A})],[e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:t,module_hash:e.Opt(e.Vec(e.Nat8))})],[]),create_canister:e.Func([e.Record({settings:e.Opt(r)})],[e.Record({canister_id:A})],[]),delete_canister:e.Func([e.Record({canister_id:A})],[],[]),deposit_cycles:e.Func([e.Record({canister_id:A})],[],[]),install_code:e.Func([e.Record({arg:e.Vec(e.Nat8),wasm_module:n,mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),canister_id:A})],[],[]),provisional_create_canister_with_cycles:e.Func([e.Record({settings:e.Opt(r),amount:e.Opt(e.Nat)})],[e.Record({canister_id:A})],[]),provisional_top_up_canister:e.Func([e.Record({canister_id:A,amount:e.Nat})],[],[]),raw_rand:e.Func([],[e.Vec(e.Nat8)],[]),start_canister:e.Func([e.Record({canister_id:A})],[],[]),stop_canister:e.Func([e.Record({canister_id:A})],[],[]),uninstall_code:e.Func([e.Record({canister_id:A})],[],[]),update_settings:e.Func([e.Record({canister_id:e.Principal,settings:r})],[],[])})}});var $n=T(ht=>{"use strict";var ag=ht&&ht.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ht,"__esModule",{value:!0});ht.getManagementCanister=void 0;var cg=xr(),Dn=ue(),Bg=ag(eo());function gg(e){function A(t,r,n){let i=r[0],s=Dn.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=Dn.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return cg.Actor.createActor(Bg.default,Object.assign(Object.assign(Object.assign({},e),{canisterId:Dn.Principal.fromHex("")}),{callTransform:A,queryTransform:A}))}ht.getManagementCanister=gg});var to=T(Ln=>{(function(){"use strict";for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=new Uint8Array(256),t=0;t<e.length;t++)A[e.charCodeAt(t)]=t;Ln.encode=function(r){var n=new Uint8Array(r),i,s=n.length,c="";for(i=0;i<s;i+=3)c+=e[n[i]>>2],c+=e[(n[i]&3)<<4|n[i+1]>>4],c+=e[(n[i+1]&15)<<2|n[i+2]>>6],c+=e[n[i+2]&63];return s%3===2?c=c.substring(0,c.length-1)+"=":s%3===1&&(c=c.substring(0,c.length-2)+"=="),c},Ln.decode=function(r){var n=r.length*.75,i=r.length,s,c=0,a,w,N,S;r[r.length-1]==="="&&(n--,r[r.length-2]==="="&&n--);var k=new ArrayBuffer(n),m=new Uint8Array(k);for(s=0;s<i;s+=4)a=A[r.charCodeAt(s)],w=A[r.charCodeAt(s+1)],N=A[r.charCodeAt(s+2)],S=A[r.charCodeAt(s+3)],m[c++]=a<<2|w>>4,m[c++]=(w&15)<<4|N>>2,m[c++]=(N&3)<<6|S&63;return k}})()});var no=T(jA=>{"use strict";var ug=jA&&jA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),Eg=jA&&jA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),Qg=jA&&jA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&ug(A,e,t);return Eg(A,e),A};Object.defineProperty(jA,"__esModule",{value:!0});jA.bls_verify=jA.bls_init=void 0;var hg=Qg(to()),Se,lg=`
14
+ `);return Qt.decode(await t.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}_transform(e){let t=Promise.resolve(e);for(let r of this._pipeline)t=t.then(n=>r(n).then(i=>i||n));return t}};yA.HttpAgent=Tt});var eo=J(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.ProxyAgent=Se.ProxyStubAgent=Se.ProxyMessageKind=void 0;var ug=ue(),pA;(function(A){A.Error="err",A.GetPrincipal="gp",A.GetPrincipalResponse="gpr",A.Query="q",A.QueryResponse="qr",A.Call="c",A.CallResponse="cr",A.ReadState="rs",A.ReadStateResponse="rsr",A.Status="s",A.StatusResponse="sr"})(pA=Se.ProxyMessageKind||(Se.ProxyMessageKind={}));var Wn=class{constructor(e,t){this._frontend=e,this._agent=t}onmessage(e){switch(e.type){case pA.GetPrincipal:this._agent.getPrincipal().then(t=>{this._frontend({id:e.id,type:pA.GetPrincipalResponse,response:t.toText()})});break;case pA.Query:this._agent.query(...e.args).then(t=>{this._frontend({id:e.id,type:pA.QueryResponse,response:t})});break;case pA.Call:this._agent.call(...e.args).then(t=>{this._frontend({id:e.id,type:pA.CallResponse,response:t})});break;case pA.ReadState:this._agent.readState(...e.args).then(t=>{this._frontend({id:e.id,type:pA.ReadStateResponse,response:t})});break;case pA.Status:this._agent.status().then(t=>{this._frontend({id:e.id,type:pA.StatusResponse,response:t})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};Se.ProxyStubAgent=Wn;var Xn=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let t=e.id,r=this._pendingCalls.get(t);if(!r)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(t);let[n,i]=r;switch(e.type){case pA.Error:return i(e.error);case pA.GetPrincipalResponse:case pA.CallResponse:case pA.QueryResponse:case pA.ReadStateResponse:case pA.StatusResponse:return n(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:pA.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return ug.Principal.fromText(e)})}readState(e,t){return this._sendAndWait({id:this._nextId++,type:pA.ReadState,args:[e.toString(),t]})}call(e,t){return this._sendAndWait({id:this._nextId++,type:pA.Call,args:[e.toString(),t]})}status(){return this._sendAndWait({id:this._nextId++,type:pA.Status})}query(e,t){return this._sendAndWait({id:this._nextId++,type:pA.Query,args:[e.toString(),t]})}async _sendAndWait(e){return new Promise((t,r)=>{this._pendingCalls.set(e.id,[t,r]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};Se.ProxyAgent=Xn});var xr=J(ie=>{"use strict";var Eg=ie&&ie.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),zn=ie&&ie.__exportStar||function(A,e){for(var t in A)t!=="default"&&!e.hasOwnProperty(t)&&Eg(e,A,t)};Object.defineProperty(ie,"__esModule",{value:!0});ie.getDefaultAgent=void 0;zn(Ti(),ie);zn(Ao(),ie);zn(eo(),ie);function lg(){let A=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!A)throw new Error("No Agent could be found.");return A}ie.getDefaultAgent=lg});var to=J($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.default=({IDL:A})=>{let e=A.Principal,t=A.Record({controllers:A.Vec(A.Principal),freezing_threshold:A.Nat,memory_allocation:A.Nat,compute_allocation:A.Nat}),r=A.Record({controllers:A.Opt(A.Vec(A.Principal)),freezing_threshold:A.Opt(A.Nat),memory_allocation:A.Opt(A.Nat),compute_allocation:A.Opt(A.Nat)}),n=A.Vec(A.Nat8);return A.Service({canister_status:A.Func([A.Record({canister_id:e})],[A.Record({status:A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),memory_size:A.Nat,cycles:A.Nat,settings:t,module_hash:A.Opt(A.Vec(A.Nat8))})],[]),create_canister:A.Func([A.Record({settings:A.Opt(r)})],[A.Record({canister_id:e})],[]),delete_canister:A.Func([A.Record({canister_id:e})],[],[]),deposit_cycles:A.Func([A.Record({canister_id:e})],[],[]),install_code:A.Func([A.Record({arg:A.Vec(A.Nat8),wasm_module:n,mode:A.Variant({reinstall:A.Null,upgrade:A.Null,install:A.Null}),canister_id:e})],[],[]),provisional_create_canister_with_cycles:A.Func([A.Record({settings:A.Opt(r),amount:A.Opt(A.Nat)})],[A.Record({canister_id:e})],[]),provisional_top_up_canister:A.Func([A.Record({canister_id:e,amount:A.Nat})],[],[]),raw_rand:A.Func([],[A.Vec(A.Nat8)],[]),start_canister:A.Func([A.Record({canister_id:e})],[],[]),stop_canister:A.Func([A.Record({canister_id:e})],[],[]),uninstall_code:A.Func([A.Record({canister_id:e})],[],[]),update_settings:A.Func([A.Record({canister_id:A.Principal,settings:r})],[],[])})}});var Ln=J(ft=>{"use strict";var hg=ft&&ft.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(ft,"__esModule",{value:!0});ft.getManagementCanister=void 0;var Qg=kr(),Dn=ue(),fg=hg(to());function dg(A){function e(t,r,n){let i=r[0],s=Dn.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=Dn.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Qg.Actor.createActor(fg.default,Object.assign(Object.assign(Object.assign({},A),{canisterId:Dn.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}ft.getManagementCanister=dg});var ro=J(Ai=>{(function(){"use strict";for(var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=new Uint8Array(256),t=0;t<A.length;t++)e[A.charCodeAt(t)]=t;Ai.encode=function(r){var n=new Uint8Array(r),i,s=n.length,c="";for(i=0;i<s;i+=3)c+=A[n[i]>>2],c+=A[(n[i]&3)<<4|n[i+1]>>4],c+=A[(n[i+1]&15)<<2|n[i+2]>>6],c+=A[n[i+2]&63];return s%3===2?c=c.substring(0,c.length-1)+"=":s%3===1&&(c=c.substring(0,c.length-2)+"=="),c},Ai.decode=function(r){var n=r.length*.75,i=r.length,s,c=0,a,p,m,F;r[r.length-1]==="="&&(n--,r[r.length-2]==="="&&n--);var R=new ArrayBuffer(n),y=new Uint8Array(R);for(s=0;s<i;s+=4)a=e[r.charCodeAt(s)],p=e[r.charCodeAt(s+1)],m=e[r.charCodeAt(s+2)],F=e[r.charCodeAt(s+3)],y[c++]=a<<2|p>>4,y[c++]=(p&15)<<4|m>>2,y[c++]=(m&3)<<6|F&63;return R}})()});var io=J(KA=>{"use strict";var pg=KA&&KA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),Cg=KA&&KA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),Ig=KA&&KA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&pg(e,A,t);return Cg(e,A),e};Object.defineProperty(KA,"__esModule",{value:!0});KA.bls_verify=KA.bls_init=void 0;var wg=Ig(ro()),Re,_g=`
15
15
  AGFzbQEAAAABXg9gAn9/AGABfwBgA39/fwBgAn9/AX9gAX8Bf2ADf39/AX9gBH9/f38AYAV/f39/fwBgBn9/f39/fwF/
16
16
  YAAAYAZ/f39/f38AYAV/fn5+fgBgAAF/YAF/AX5gAn9/AX4DvAG6AQgEAAEAAAABAgEDAAAMAAACAQEKAQAHBgEAAQEA
17
17
  AgcCAgABAgAGAAgOBAEBBAAAAQALAQkAAwMAAQQBAAICAAIBAQEBAQEGAQACAQEEAAECAQEABQMBAQMEAwQCAwAAAAEA
@@ -808,33 +808,33 @@ ic-request`),Rn=class{getPrincipal(){return this._principal||(this._principal=Rs
808
808
  EACwEBAEHItMEACwEBAEGItcEACwEBAEHItcEACwEBAHsJcHJvZHVjZXJzAghsYW5ndWFnZQEEUnVzdAAMcHJvY2Vzc2V
809
809
  kLWJ5AwVydXN0Yx0xLjQ5LjAgKGUxODg0YThlMyAyMDIwLTEyLTI5KQZ3YWxydXMGMC4xOC4wDHdhc20tYmluZGdlbhIw
810
810
  LjIuNzAgKGI2MzU1YzI3MCk=
811
- `.replace(/[^0-9a-zA-Z/+]/g,""),fg=hg.decode(lg);function Ig(){return Se.bls_init()}jA.bls_init=Ig;var kr=null;function Cg(){return(kr===null||kr.buffer!==Se.memory.buffer)&&(kr=new Uint8Array(Se.memory.buffer)),kr}function Ai(e,A){let t=A(e.length*1);return Cg().set(e,t/1),[t,e.length]}function dg(e,A,t){let[r,n]=Ai(e,Se.__wbindgen_malloc),[i,s]=Ai(A,Se.__wbindgen_malloc),[c,a]=Ai(t,Se.__wbindgen_malloc);return Se.bls_verify(r,n,i,s,c,a)}jA.bls_verify=dg;async function pg(e,A){if(typeof Response=="function"&&e instanceof Response){let t=await e.arrayBuffer();return await WebAssembly.instantiate(t,A)}else{let t=await WebAssembly.instantiate(e,A);return t instanceof WebAssembly.Instance?{instance:t,module:e}:t}}async function ro(){let e={},{instance:A,module:t}=await pg(fg,e);return Se=A.exports,ro.__wbindgen_wasm_module=t,Se}jA.default=ro});var ti=T(ZA=>{"use strict";var wg=ZA&&ZA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),yg=ZA&&ZA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),_g=ZA&&ZA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&wg(A,e,t);return yg(A,e),A};Object.defineProperty(ZA,"__esModule",{value:!0});ZA.blsVerify=ZA.verify=void 0;var ei=_g(no());async function Gg(e,A,t){if(!ZA.verify){if(await ei.default(),ei.bls_init()!==0)throw new Error("Cannot initialize BLS");ZA.verify=(r,n,i)=>ei.bls_verify(n,i,r)===0}return ZA.verify(e,A,t)}ZA.blsVerify=Gg});var si=T(SA=>{"use strict";var mg=SA&&SA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),Ng=SA&&SA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),Fg=SA&&SA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&mg(A,e,t);return Ng(A,e),A};Object.defineProperty(SA,"__esModule",{value:!0});SA.lookup_path=SA.reconstruct=SA.Certificate=SA.hashTreeToString=SA.CertificateVerificationError=void 0;var io=Fg(Nr()),Sg=Ar(),Rr=kt(),bg=ti(),we=Ce(),ri=ue(),lt=class extends Sg.AgentError{constructor(A){super(`Invalid certificate: ${A}`)}};SA.CertificateVerificationError=lt;function Mr(e){let A=r=>r.split(`
811
+ `.replace(/[^0-9a-zA-Z/+]/g,""),yg=wg.decode(_g);function Gg(){return Re.bls_init()}KA.bls_init=Gg;var qr=null;function mg(){return(qr===null||qr.buffer!==Re.memory.buffer)&&(qr=new Uint8Array(Re.memory.buffer)),qr}function ei(A,e){let t=e(A.length*1);return mg().set(A,t/1),[t,A.length]}function Ng(A,e,t){let[r,n]=ei(A,Re.__wbindgen_malloc),[i,s]=ei(e,Re.__wbindgen_malloc),[c,a]=ei(t,Re.__wbindgen_malloc);return Re.bls_verify(r,n,i,s,c,a)}KA.bls_verify=Ng;async function Fg(A,e){if(typeof Response=="function"&&A instanceof Response){let t=await A.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(A,e);return t instanceof WebAssembly.Instance?{instance:t,module:A}:t}}async function no(){let A={},{instance:e,module:t}=await Fg(yg,A);return Re=e.exports,no.__wbindgen_wasm_module=t,Re}KA.default=no});var ri=J(ZA=>{"use strict";var Sg=ZA&&ZA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),Rg=ZA&&ZA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),bg=ZA&&ZA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&Sg(e,A,t);return Rg(e,A),e};Object.defineProperty(ZA,"__esModule",{value:!0});ZA.blsVerify=ZA.verify=void 0;var ti=bg(io());async function xg(A,e,t){if(!ZA.verify){if(await ti.default(),ti.bls_init()!==0)throw new Error("Cannot initialize BLS");ZA.verify=(r,n,i)=>ti.bls_verify(n,i,r)===0}return ZA.verify(A,e,t)}ZA.blsVerify=xg});var oi=J(RA=>{"use strict";var kg=RA&&RA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),qg=RA&&RA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),Mg=RA&&RA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&kg(e,A,t);return qg(e,A),e};Object.defineProperty(RA,"__esModule",{value:!0});RA.lookup_path=RA.reconstruct=RA.Certificate=RA.hashTreeToString=RA.CertificateVerificationError=void 0;var so=Mg(Fr()),vg=er(),Mr=qt(),Hg=ri(),we=pe(),ni=ue(),dt=class extends vg.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};RA.CertificateVerificationError=dt;function vr(A){let e=r=>r.split(`
812
812
  `).map(n=>" "+n).join(`
813
- `);function t(r){let n=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(n.decode(r))}catch{return`data(...${r.byteLength} bytes)`}}switch(e[0]){case 0:return"()";case 1:{let r=Mr(e[1]),n=Mr(e[2]);return`sub(
813
+ `);function t(r){let n=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(n.decode(r))}catch{return`data(...${r.byteLength} bytes)`}}switch(A[0]){case 0:return"()";case 1:{let r=vr(A[1]),n=vr(A[2]);return`sub(
814
814
  left:
815
- ${A(r)}
815
+ ${e(r)}
816
816
  ---
817
817
  right:
818
- ${A(n)}
819
- )`}case 2:{let r=t(e[1]),n=Mr(e[2]);return`label(
818
+ ${e(n)}
819
+ )`}case 2:{let r=t(A[1]),n=vr(A[2]);return`label(
820
820
  label:
821
- ${A(r)}
821
+ ${e(r)}
822
822
  sub:
823
- ${A(n)}
824
- )`}case 3:return`leaf(...${e[1].byteLength} bytes)`;case 4:return`pruned(${we.toHex(new Uint8Array(e[1]))}`;default:return`unknown(${JSON.stringify(e[0])})`}}SA.hashTreeToString=Mr;function so(e,A){if(e.byteLength!==A.byteLength)return!1;let t=new Uint8Array(e),r=new Uint8Array(A);for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}var ft=class{constructor(A,t,r){this._rootKey=t,this._canisterId=r,this.cert=io.decode(new Uint8Array(A))}static async create(A){let t=new ft(A.certificate,A.rootKey,A.canisterId);return await t.verify(),t}lookup(A){return ii(A,this.cert.tree)}async verify(){let A=await Yt(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),r=this.cert.signature,n=xg(t),i=we.concat(Tt("ic-state-root"),A),s=!1;try{s=await bg.blsVerify(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}catch{s=!1}if(!s)throw new lt("Signature verification failed")}async _checkDelegationAndGetKey(A){if(!A)return this._rootKey;let t=await ft.create({certificate:A.certificate,rootKey:this._rootKey,canisterId:this._canisterId});if(this._canisterId.compareTo(ri.Principal.managementCanister())!=="eq"){let n=t.lookup(["subnet",A.subnet_id,"canister_ranges"]);if(!n)throw new lt(`Could not find canister ranges for subnet 0x${we.toHex(A.subnet_id)}`);if(!io.decode(n).map(a=>[ri.Principal.fromUint8Array(a[0]),ri.Principal.fromUint8Array(a[1])]).some(a=>a[0].ltEq(this._canisterId)&&a[1].gtEq(this._canisterId)))throw new lt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${we.toHex(A.subnet_id)}`)}let r=t.lookup(["subnet",A.subnet_id,"public_key"]);if(!r)throw new Error(`Could not find subnet key for subnet 0x${we.toHex(A.subnet_id)}`);return r}};SA.Certificate=ft;var Ut=we.fromHex("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),qg=96;function xg(e){let A=Ut.byteLength+qg;if(e.byteLength!==A)throw new TypeError(`BLS DER-encoded public key must be ${A} bytes long`);let t=e.slice(0,Ut.byteLength);if(!so(t,Ut))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ut}, but get ${t}`);return e.slice(Ut.byteLength)}async function Yt(e){switch(e[0]){case 0:return Rr.hash(Tt("ic-hashtree-empty"));case 4:return e[1];case 3:return Rr.hash(we.concat(Tt("ic-hashtree-leaf"),e[1]));case 2:return Rr.hash(we.concat(Tt("ic-hashtree-labeled"),e[1],await Yt(e[2])));case 1:return Rr.hash(we.concat(Tt("ic-hashtree-fork"),await Yt(e[1]),await Yt(e[2])));default:throw new Error("unreachable")}}SA.reconstruct=Yt;function Tt(e){let A=new Uint8Array([e.length]),t=new TextEncoder().encode(e);return we.concat(A,t)}function ii(e,A){if(e.length===0)switch(A[0]){case 3:return new Uint8Array(A[1]).buffer;default:return}let t=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],r=kg(t,ni(A));if(r)return ii(e.slice(1),r)}SA.lookup_path=ii;function ni(e){switch(e[0]){case 0:return[];case 1:return ni(e[1]).concat(ni(e[2]));default:return[e]}}function kg(e,A){if(A.length!==0){for(let t of A)if(t[0]===2){let r=t[1];if(so(e,r))return t[2]}}}});var oi=T(bA=>{"use strict";Object.defineProperty(bA,"__esModule",{value:!0});bA.chain=bA.backoff=bA.timeout=bA.throttle=bA.maxAttempts=bA.conditionalDelay=bA.once=bA.defaultStrategy=void 0;var oo=Ce(),Rg=5*60*1e3;function Mg(){return uo(co(ao(),1e3),go(1e3,1.2),Bo(Rg))}bA.defaultStrategy=Mg;function ao(){let e=!0;return async()=>e?(e=!1,!0):!1}bA.once=ao;function co(e,A){return async(t,r,n)=>{if(await e(t,r,n))return new Promise(i=>setTimeout(i,A))}}bA.conditionalDelay=co;function Hg(e){let A=e;return async(t,r,n)=>{if(--A<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
825
- Request ID: ${oo.toHex(r)}
823
+ ${e(n)}
824
+ )`}case 3:return`leaf(...${A[1].byteLength} bytes)`;case 4:return`pruned(${we.toHex(new Uint8Array(A[1]))}`;default:return`unknown(${JSON.stringify(A[0])})`}}RA.hashTreeToString=vr;function oo(A,e){if(A.byteLength!==e.byteLength)return!1;let t=new Uint8Array(A),r=new Uint8Array(e);for(let n=0;n<t.length;n++)if(t[n]!==r[n])return!1;return!0}var pt=class{constructor(e,t,r){this._rootKey=t,this._canisterId=r,this.cert=so.decode(new Uint8Array(e))}static async create(e){let t=new pt(e.certificate,e.rootKey,e.canisterId);return await t.verify(),t}lookup(e){return si(e,this.cert.tree)}async verify(){let e=await Yt(this.cert.tree),t=await this._checkDelegationAndGetKey(this.cert.delegation),r=this.cert.signature,n=Ug(t),i=we.concat(Ot("ic-state-root"),e),s=!1;try{s=await Hg.blsVerify(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}catch{s=!1}if(!s)throw new dt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let t=await pt.create({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId});if(this._canisterId.compareTo(ni.Principal.managementCanister())!=="eq"){let n=t.lookup(["subnet",e.subnet_id,"canister_ranges"]);if(!n)throw new dt(`Could not find canister ranges for subnet 0x${we.toHex(e.subnet_id)}`);if(!so.decode(n).map(a=>[ni.Principal.fromUint8Array(a[0]),ni.Principal.fromUint8Array(a[1])]).some(a=>a[0].ltEq(this._canisterId)&&a[1].gtEq(this._canisterId)))throw new dt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${we.toHex(e.subnet_id)}`)}let r=t.lookup(["subnet",e.subnet_id,"public_key"]);if(!r)throw new Error(`Could not find subnet key for subnet 0x${we.toHex(e.subnet_id)}`);return r}};RA.Certificate=pt;var Ut=we.fromHex("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Tg=96;function Ug(A){let e=Ut.byteLength+Tg;if(A.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let t=A.slice(0,Ut.byteLength);if(!oo(t,Ut))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Ut}, but get ${t}`);return A.slice(Ut.byteLength)}async function Yt(A){switch(A[0]){case 0:return Mr.hash(Ot("ic-hashtree-empty"));case 4:return A[1];case 3:return Mr.hash(we.concat(Ot("ic-hashtree-leaf"),A[1]));case 2:return Mr.hash(we.concat(Ot("ic-hashtree-labeled"),A[1],await Yt(A[2])));case 1:return Mr.hash(we.concat(Ot("ic-hashtree-fork"),await Yt(A[1]),await Yt(A[2])));default:throw new Error("unreachable")}}RA.reconstruct=Yt;function Ot(A){let e=new Uint8Array([A.length]),t=new TextEncoder().encode(A);return we.concat(e,t)}function si(A,e){if(A.length===0)switch(e[0]){case 3:return new Uint8Array(e[1]).buffer;default:return}let t=typeof A[0]=="string"?new TextEncoder().encode(A[0]):A[0],r=Og(t,ii(e));if(r)return si(A.slice(1),r)}RA.lookup_path=si;function ii(A){switch(A[0]){case 0:return[];case 1:return ii(A[1]).concat(ii(A[2]));default:return[A]}}function Og(A,e){if(e.length!==0){for(let t of e)if(t[0]===2){let r=t[1];if(oo(A,r))return t[2]}}}});var ai=J(bA=>{"use strict";Object.defineProperty(bA,"__esModule",{value:!0});bA.chain=bA.backoff=bA.timeout=bA.throttle=bA.maxAttempts=bA.conditionalDelay=bA.once=bA.defaultStrategy=void 0;var ao=pe(),Yg=5*60*1e3;function Jg(){return Eo(Bo(co(),1e3),uo(1e3,1.2),go(Yg))}bA.defaultStrategy=Jg;function co(){let A=!0;return async()=>A?(A=!1,!0):!1}bA.once=co;function Bo(A,e){return async(t,r,n)=>{if(await A(t,r,n))return new Promise(i=>setTimeout(i,e))}}bA.conditionalDelay=Bo;function Pg(A){let e=A;return async(t,r,n)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${A} attempts:
825
+ Request ID: ${ao.toHex(r)}
826
826
  Request status: ${n}
827
- `)}}bA.maxAttempts=Hg;function vg(e){return()=>new Promise(A=>setTimeout(A,e))}bA.throttle=vg;function Bo(e){let A=Date.now()+e;return async(t,r,n)=>{if(Date.now()>A)throw new Error(`Request timed out after ${e} msec:
828
- Request ID: ${oo.toHex(r)}
827
+ `)}}bA.maxAttempts=Pg;function Vg(A){return()=>new Promise(e=>setTimeout(e,A))}bA.throttle=Vg;function go(A){let e=Date.now()+A;return async(t,r,n)=>{if(Date.now()>e)throw new Error(`Request timed out after ${A} msec:
828
+ Request ID: ${ao.toHex(r)}
829
829
  Request status: ${n}
830
- `)}}bA.timeout=Bo;function go(e,A){let t=e;return()=>new Promise(r=>setTimeout(()=>{t*=A,r()},t))}bA.backoff=go;function uo(...e){return async(A,t,r)=>{for(let n of e)await n(A,t,r)}}bA.chain=uo});var ai=T($A=>{"use strict";var Ug=$A&&$A.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),Tg=$A&&$A.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),Yg=$A&&$A.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&Ug(A,e,t);return Tg(A,e),A};Object.defineProperty($A,"__esModule",{value:!0});$A.pollForResponse=void 0;var We=qr(),Og=si(),Eo=Ce();$A.strategy=Yg(oi());var Jg=oi();Object.defineProperty($A,"defaultStrategy",{enumerable:!0,get:function(){return Jg.defaultStrategy}});async function Qo(e,A,t,r){let n=[new TextEncoder().encode("request_status"),t],i=await e.readState(A,{paths:[n]});if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let s=await Og.Certificate.create({certificate:i.certificate,rootKey:e.rootKey,canisterId:A}),c=s.lookup([...n,new TextEncoder().encode("status")]),a;switch(typeof c>"u"?a=We.RequestStatusResponseStatus.Unknown:a=new TextDecoder().decode(c),a){case We.RequestStatusResponseStatus.Replied:return s.lookup([...n,"reply"]);case We.RequestStatusResponseStatus.Received:case We.RequestStatusResponseStatus.Unknown:case We.RequestStatusResponseStatus.Processing:return await r(A,t,a),Qo(e,A,t,r);case We.RequestStatusResponseStatus.Rejected:{let w=new Uint8Array(s.lookup([...n,"reject_code"]))[0],N=new TextDecoder().decode(s.lookup([...n,"reject_message"]));throw new Error(`Call was rejected:
831
- Request ID: ${Eo.toHex(t)}
832
- Reject code: ${w}
833
- Reject text: ${N}
834
- `)}case We.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
835
- Request ID: ${Eo.toHex(t)}
836
- `)}throw new Error("unreachable")}$A.pollForResponse=Qo});var xr=T(KA=>{"use strict";Object.defineProperty(KA,"__esModule",{value:!0});KA.Actor=KA.CanisterInstallMode=KA.UpdateCallRejectedError=KA.QueryCallRejectedError=KA.ActorCallError=void 0;var Pg=Hi(),ci=qr(),ho=$n(),Zg=Ar(),Hr=Ft(),fo=ai(),It=ue(),Vg=Ce(),Ot=class extends Zg.AgentError{constructor(A,t,r,n){super(["Call failed:",` Canister: ${A.toText()}`,` Method: ${t} (${r})`,...Object.getOwnPropertyNames(n).map(i=>` "${i}": ${JSON.stringify(n[i])}`)].join(`
837
- `)),this.canisterId=A,this.methodName=t,this.type=r,this.props=n}};KA.ActorCallError=Ot;var vr=class extends Ot{constructor(A,t,r){var n;super(A,t,"query",{Status:r.status,Code:(n=ci.ReplicaRejectCode[r.reject_code])!==null&&n!==void 0?n:`Unknown Code "${r.reject_code}"`,Message:r.reject_message}),this.result=r}};KA.QueryCallRejectedError=vr;var Ur=class extends Ot{constructor(A,t,r,n){super(A,t,"update",{"Request ID":Vg.toHex(r),"HTTP status code":n.status.toString(),"HTTP status text":n.statusText}),this.requestId=r,this.response=n}};KA.UpdateCallRejectedError=Ur;var Io;(function(e){e.Install="install",e.Reinstall="reinstall",e.Upgrade="upgrade"})(Io=KA.CanisterInstallMode||(KA.CanisterInstallMode={}));var LA=Symbol.for("ic-agent-metadata"),Jt=class{constructor(A){this[LA]=Object.freeze(A)}static agentOf(A){return A[LA].config.agent}static interfaceOf(A){return A[LA].service}static canisterIdOf(A){return It.Principal.from(A[LA].config.canisterId)}static async install(A,t){let r=A.mode===void 0?Io.Install:A.mode,n=A.arg?[...new Uint8Array(A.arg)]:[],i=[...new Uint8Array(A.module)],s=typeof t.canisterId=="string"?It.Principal.fromText(t.canisterId):t.canisterId;await ho.getManagementCanister(t).install_code({mode:{[r]:null},arg:n,wasm_module:i,canister_id:s})}static async createCanister(A){let{canister_id:t}=await ho.getManagementCanister(A||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return t}static async createAndInstallCanister(A,t,r){let n=await this.createCanister(r);return await this.install(Object.assign({},t),Object.assign(Object.assign({},r),{canisterId:n})),this.createActor(A,Object.assign(Object.assign({},r),{canisterId:n}))}static createActorClass(A){let t=A({IDL:Hr.IDL});class r extends Jt{constructor(i){let s=typeof i.canisterId=="string"?It.Principal.fromText(i.canisterId):i.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Co),i),{canisterId:s}),service:t});for(let[c,a]of t._fields)this[c]=jg(this,c,a)}}return r}static createActor(A,t){return new(this.createActorClass(A))(t)}};KA.Actor=Jt;function lo(e,A){let t=Hr.IDL.decode(e,Pg.Buffer.from(A));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var Co={pollingStrategyFactory:fo.strategy.defaultStrategy};function jg(e,A,t){let r;t.annotations.includes("query")?r=async(i,...s)=>{var c,a;i=Object.assign(Object.assign({},i),(a=(c=e[LA].config).queryTransform)===null||a===void 0?void 0:a.call(c,A,s,Object.assign(Object.assign({},e[LA].config),i)));let w=i.agent||e[LA].config.agent||ci.getDefaultAgent(),N=It.Principal.from(i.canisterId||e[LA].config.canisterId),S=Hr.IDL.encode(t.argTypes,s),k=await w.query(N,{methodName:A,arg:S});switch(k.status){case"rejected":throw new vr(N,A,k);case"replied":return lo(t.retTypes,k.reply.arg)}}:r=async(i,...s)=>{var c,a;i=Object.assign(Object.assign({},i),(a=(c=e[LA].config).callTransform)===null||a===void 0?void 0:a.call(c,A,s,Object.assign(Object.assign({},e[LA].config),i)));let w=i.agent||e[LA].config.agent||ci.getDefaultAgent(),{canisterId:N,effectiveCanisterId:S,pollingStrategyFactory:k}=Object.assign(Object.assign(Object.assign({},Co),e[LA].config),i),m=It.Principal.from(N),R=S!==void 0?It.Principal.from(S):m,J=Hr.IDL.encode(t.argTypes,s),{requestId:$,response:O}=await w.call(m,{methodName:A,arg:J,effectiveCanisterId:R});if(!O.ok)throw new Ur(m,A,$,O);let eA=k(),L=await fo.pollForResponse(w,R,$,eA);if(L!==void 0)return lo(t.retTypes,L);if(t.retTypes.length===0)return;throw new Error(`Call was returned undefined, but type [${t.retTypes.join(",")}].`)};let n=(...i)=>r({},...i);return n.withOptions=i=>(...s)=>r(i,...s),n}});var po=T(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.default=({IDL:e})=>e.Service({retrieve:e.Func([e.Text],[e.Vec(e.Nat8)],["query"]),store:e.Func([e.Text,e.Vec(e.Nat8)],[],[])})});var wo=T(Ct=>{"use strict";var Kg=Ct&&Ct.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.createAssetCanisterActor=void 0;var Wg=xr(),Xg=Kg(po());function zg(e){return Wg.Actor.createActor(Xg.default,e)}Ct.createAssetCanisterActor=zg});var No=T(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.encodePath=He.request=void 0;var yo=Ft(),Dg=ue(),gi=Tr();He.request=async e=>{let{canisterId:A,agent:t,paths:r}=e,n=[...new Set(r)],i=n.map(a=>He.encodePath(a,A)),s=new Map,c=n.map((a,w)=>(async()=>{try{let N=await t.readState(A,{paths:[i[w]]}),k=(await gi.Certificate.create({certificate:N.certificate,rootKey:t.rootKey,canisterId:A})).lookup(He.encodePath(n[w],A));if(!k)console.warn(`Expected to find result for path ${a}, but instead found nothing.`),typeof a=="string"?s.set(a,null):s.set(a.key,null);else switch(a){case"time":{s.set(a,$g(k));break}case"controllers":{s.set(a,Lg(k));break}case"module_hash":{s.set(a,_o(k));break}case"candid":{s.set(a,new TextDecoder().decode(k));break}default:if(typeof a!="string"&&"key"in a&&"path"in a)switch(a.decodeStrategy){case"raw":s.set(a.key,k);break;case"leb128":{s.set(a.key,Go(k));break}case"cbor":{s.set(a.key,mo(k));break}case"hex":{s.set(a.key,_o(k));break}}}}catch(N){typeof a!="string"&&"key"in a&&"path"in a?s.set(a.key,null):s.set(a,null),console.warn(`Expected to find result for path ${a}, but instead found nothing.`)}})());return await Promise.all(c),s};He.encodePath=(e,A)=>{let t=new TextEncoder,r=i=>new DataView(t.encode(i).buffer).buffer,n=new DataView(A.toUint8Array().buffer).buffer;switch(e){case"time":return[r("time")];case"controllers":return[r("canister"),n,r("controllers")];case"module_hash":return[r("canister"),n,r("module_hash")];case"subnet":return[r("subnet")];case"candid":return[r("canister"),n,r("metadata"),r("candid:service")];default:if("key"in e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let i=e.path,s=typeof i=="string"?r(i):i;return[r("canister"),n,r("metadata"),s]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)};var _o=e=>gi.toHex(e),Go=e=>yo.lebDecode(new yo.PipeArrayBuffer(e)),mo=e=>gi.Cbor.decode(e),$g=e=>{let A=Go(e);return new Date(Number(A/BigInt(1e6)))},Lg=e=>{let[A,...t]=mo(e);return t.map(r=>Dg.Principal.fromUint8Array(new Uint8Array(r)))}});var Tr=T(hA=>{"use strict";var Fo=hA&&hA.__createBinding||(Object.create?function(e,A,t,r){r===void 0&&(r=t),Object.defineProperty(e,r,{enumerable:!0,get:function(){return A[t]}})}:function(e,A,t,r){r===void 0&&(r=t),e[r]=A[t]}),Au=hA&&hA.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),oe=hA&&hA.__exportStar||function(e,A){for(var t in e)t!=="default"&&!A.hasOwnProperty(t)&&Fo(A,e,t)},ui=hA&&hA.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(e!=null)for(var t in e)t!=="default"&&Object.hasOwnProperty.call(e,t)&&Fo(A,e,t);return Au(A,e),A};Object.defineProperty(hA,"__esModule",{value:!0});oe(xr(),hA);oe(qr(),hA);oe(Hn(),hA);oe(si(),hA);oe(Sr(),hA);oe(Mt(),hA);oe(wo(),hA);oe($n(),hA);oe(kt(),hA);oe(ti(),hA);oe(Ce(),hA);hA.polling=ui(ai());hA.CanisterStatus=ui(No());hA.Cbor=ui(Nr())});var ru={};ta(ru,{GovernanceCanister:()=>ve,LedgerCanister:()=>Ue,RootCanister:()=>Te,SnsWrapper:()=>Pt,initSns:()=>tu});module.exports=ra(ru);var Ci=({IDL:e})=>{let A=e.Record({validator_canister_id:e.Opt(e.Principal),target_canister_id:e.Opt(e.Principal),validator_method_name:e.Opt(e.Text),target_method_name:e.Opt(e.Text)}),t=e.Variant({NativeNervousSystemFunction:e.Record({}),GenericNervousSystemFunction:A}),r=e.Record({id:e.Nat64,name:e.Text,description:e.Opt(e.Text),function_type:e.Opt(t)}),n=e.Record({not_dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),garbage_collectable_neurons_count:e.Nat64,neurons_with_invalid_stake_count:e.Nat64,not_dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,total_staked_e8s:e.Nat64,total_supply_governance_tokens:e.Nat64,not_dissolving_neurons_count:e.Nat64,dissolved_neurons_e8s:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:e.Nat64,dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),dissolving_neurons_count:e.Nat64,dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),timestamp_seconds:e.Nat64}),i=e.Record({id:e.Vec(e.Nat8)}),s=e.Record({followees:e.Vec(i)}),c=e.Record({followees:e.Vec(e.Tuple(e.Nat64,s))}),a=e.Record({permissions:e.Vec(e.Int32)}),w=e.Record({default_followees:e.Opt(c),max_dissolve_delay_seconds:e.Opt(e.Nat64),max_followees_per_function:e.Opt(e.Nat64),neuron_claimer_permissions:e.Opt(a),neuron_minimum_stake_e8s:e.Opt(e.Nat64),initial_voting_period:e.Opt(e.Nat64),max_neuron_age_for_age_bonus:e.Opt(e.Nat64),neuron_minimum_dissolve_delay_to_vote_seconds:e.Opt(e.Nat64),reject_cost_e8s:e.Opt(e.Nat64),max_proposals_to_keep_per_action:e.Opt(e.Nat32),max_number_of_neurons:e.Opt(e.Nat64),transaction_fee_e8s:e.Opt(e.Nat64),max_number_of_proposals_with_ballots:e.Opt(e.Nat64),reward_distribution_period_seconds:e.Opt(e.Nat64),neuron_grantable_permissions:e.Opt(a),max_number_of_principals_per_neuron:e.Opt(e.Nat64)}),N=e.Record({id:e.Nat64}),S=e.Record({actual_timestamp_seconds:e.Nat64,periods_since_genesis:e.Nat64,distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(N)}),k=e.Record({error_message:e.Text,error_type:e.Int32}),m=e.Record({vote:e.Int32,cast_timestamp_seconds:e.Nat64,voting_power:e.Nat64}),R=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),J=e.Record({new_canister_wasm:e.Vec(e.Nat8),canister_id:e.Opt(e.Principal)}),$=e.Record({function_id:e.Nat64,payload:e.Vec(e.Nat8)}),O=e.Record({motion_text:e.Text}),eA=e.Variant({ManageNervousSystemParameters:w,AddGenericNervousSystemFunction:r,RemoveGenericNervousSystemFunction:e.Nat64,UpgradeSnsControlledCanister:J,Unspecified:e.Record({}),ExecuteGenericNervousSystemFunction:$,Motion:O}),L=e.Record({url:e.Text,title:e.Text,action:e.Opt(eA),summary:e.Text}),BA=e.Record({current_deadline_timestamp_seconds:e.Nat64}),v=e.Record({id:e.Opt(N),payload_text_rendering:e.Opt(e.Text),action:e.Nat64,failure_reason:e.Opt(k),ballots:e.Vec(e.Tuple(e.Text,m)),reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,proposal_creation_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,latest_tally:e.Opt(R),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(L),proposer:e.Opt(i),wait_for_quiet_state:e.Opt(BA),executed_timestamp_seconds:e.Nat64}),M=e.Record({memo:e.Nat64,amount_e8s:e.Nat64}),P=e.Record({function_id:e.Nat64,followees:e.Vec(i)}),W=e.Record({hash:e.Vec(e.Nat8)}),q=e.Record({to_account:e.Opt(W),percentage_to_disburse:e.Nat32}),nA=e.Record({additional_dissolve_delay_seconds:e.Nat32}),tA=e.Record({dissolve_timestamp_seconds:e.Nat64}),iA=e.Variant({StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:nA,SetDissolveTimestamp:tA}),gA=e.Record({operation:e.Opt(iA)}),pA=e.Record({vote:e.Int32,proposal:e.Opt(N)}),RA=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),qA=e.Variant({MemoAndController:RA,NeuronId:e.Record({})}),MA=e.Record({by:e.Opt(qA)}),lA=e.Record({permissions_to_remove:e.Opt(a),principal_id:e.Opt(e.Principal)}),HA=e.Record({permissions_to_add:e.Opt(a),principal_id:e.Opt(e.Principal)}),Ae=e.Record({percentage_to_merge:e.Nat32}),WA=e.Record({e8s:e.Nat64}),ee=e.Record({to_account:e.Opt(W),amount:e.Opt(WA)}),F=e.Variant({Split:M,Follow:P,DisburseMaturity:q,Configure:gA,RegisterVote:pA,MakeProposal:L,ClaimOrRefreshNeuron:MA,RemoveNeuronPermissions:lA,AddNeuronPermissions:HA,MergeMaturity:Ae,Disburse:ee}),Q=e.Record({command:e.Opt(F),timestamp:e.Nat64}),ae=e.Record({principal:e.Opt(e.Principal),permission_type:e.Vec(e.Int32)}),te=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),fA=e.Record({id:e.Opt(i),permissions:e.Vec(ae),maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,aging_since_timestamp_seconds:e.Nat64,dissolve_state:e.Opt(te),followees:e.Vec(e.Tuple(e.Nat64,s)),neuron_fees_e8s:e.Nat64}),Y=e.Record({root_canister_id:e.Opt(e.Principal),id_to_nervous_system_functions:e.Vec(e.Tuple(e.Nat64,r)),metrics:e.Opt(n),mode:e.Int32,parameters:e.Opt(w),latest_reward_event:e.Opt(S),ledger_canister_id:e.Opt(e.Principal),proposals:e.Vec(e.Tuple(e.Nat64,v)),in_flight_commands:e.Vec(e.Tuple(e.Text,Q)),neurons:e.Vec(e.Tuple(e.Text,fA)),genesis_timestamp_seconds:e.Nat64}),o=e.Record({neuron_id:e.Opt(i)}),B=e.Variant({Error:k,Neuron:fA}),g=e.Record({result:e.Opt(B)}),C=e.Record({proposal_id:e.Opt(N)}),h=e.Variant({Error:k,Proposal:v}),f=e.Record({result:e.Opt(h)}),p=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),u=e.Record({controller:e.Principal,freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),l=e.Record({controller:e.Principal,status:p,freezing_threshold:e.Nat,balance:e.Vec(e.Tuple(e.Vec(e.Nat8),e.Nat)),memory_size:e.Nat,cycles:e.Nat,settings:u,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),d=e.Record({reserved_ids:e.Vec(e.Nat64),functions:e.Vec(r)}),I=e.Record({of_principal:e.Opt(e.Principal),limit:e.Nat32,start_page_at:e.Opt(i)}),G=e.Record({neurons:e.Vec(fA)}),b=e.Record({include_reward_status:e.Vec(e.Int32),before_proposal:e.Opt(N),limit:e.Nat32,exclude_type:e.Vec(e.Nat64),include_status:e.Vec(e.Int32)}),H=e.Record({proposals:e.Vec(v)}),V=e.Variant({Split:M,Follow:P,DisburseMaturity:q,ClaimOrRefresh:MA,Configure:gA,RegisterVote:pA,MakeProposal:L,RemoveNeuronPermissions:lA,AddNeuronPermissions:HA,MergeMaturity:Ae,Disburse:ee}),sA=e.Record({subaccount:e.Vec(e.Nat8),command:e.Opt(V)}),uA=e.Record({created_neuron_id:e.Opt(i)}),Z=e.Record({transfer_block_height:e.Nat64,amount_disbursed_e8s:e.Nat64}),U=e.Record({refreshed_neuron_id:e.Opt(i)}),IA=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),ce=e.Record({transfer_block_height:e.Nat64}),ye=e.Variant({Error:k,Split:uA,Follow:e.Record({}),DisburseMaturity:Z,ClaimOrRefresh:U,Configure:e.Record({}),RegisterVote:e.Record({}),MakeProposal:C,RemoveNeuronPermission:e.Record({}),MergeMaturity:IA,Disburse:ce,AddNeuronPermission:e.Record({})}),_e=e.Record({command:e.Opt(ye)}),vA=e.Record({mode:e.Int32});return e.Service({get_build_metadata:e.Func([],[e.Text],[]),get_nervous_system_parameters:e.Func([e.Null],[w],[]),get_neuron:e.Func([o],[g],[]),get_proposal:e.Func([C],[f],[]),get_root_canister_status:e.Func([e.Null],[l],[]),list_nervous_system_functions:e.Func([],[d],[]),list_neurons:e.Func([I],[G],[]),list_proposals:e.Func([b],[H],[]),manage_neuron:e.Func([sA],[_e],[]),set_mode:e.Func([vA],[e.Record({})],[])})};var di=({IDL:e})=>{let A=e.Record({validator_canister_id:e.Opt(e.Principal),target_canister_id:e.Opt(e.Principal),validator_method_name:e.Opt(e.Text),target_method_name:e.Opt(e.Text)}),t=e.Variant({NativeNervousSystemFunction:e.Record({}),GenericNervousSystemFunction:A}),r=e.Record({id:e.Nat64,name:e.Text,description:e.Opt(e.Text),function_type:e.Opt(t)}),n=e.Record({not_dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),garbage_collectable_neurons_count:e.Nat64,neurons_with_invalid_stake_count:e.Nat64,not_dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,total_staked_e8s:e.Nat64,total_supply_governance_tokens:e.Nat64,not_dissolving_neurons_count:e.Nat64,dissolved_neurons_e8s:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:e.Nat64,dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),dissolving_neurons_count:e.Nat64,dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),timestamp_seconds:e.Nat64}),i=e.Record({id:e.Vec(e.Nat8)}),s=e.Record({followees:e.Vec(i)}),c=e.Record({followees:e.Vec(e.Tuple(e.Nat64,s))}),a=e.Record({permissions:e.Vec(e.Int32)}),w=e.Record({default_followees:e.Opt(c),max_dissolve_delay_seconds:e.Opt(e.Nat64),max_followees_per_function:e.Opt(e.Nat64),neuron_claimer_permissions:e.Opt(a),neuron_minimum_stake_e8s:e.Opt(e.Nat64),initial_voting_period:e.Opt(e.Nat64),max_neuron_age_for_age_bonus:e.Opt(e.Nat64),neuron_minimum_dissolve_delay_to_vote_seconds:e.Opt(e.Nat64),reject_cost_e8s:e.Opt(e.Nat64),max_proposals_to_keep_per_action:e.Opt(e.Nat32),max_number_of_neurons:e.Opt(e.Nat64),transaction_fee_e8s:e.Opt(e.Nat64),max_number_of_proposals_with_ballots:e.Opt(e.Nat64),reward_distribution_period_seconds:e.Opt(e.Nat64),neuron_grantable_permissions:e.Opt(a),max_number_of_principals_per_neuron:e.Opt(e.Nat64)}),N=e.Record({id:e.Nat64}),S=e.Record({actual_timestamp_seconds:e.Nat64,periods_since_genesis:e.Nat64,distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(N)}),k=e.Record({error_message:e.Text,error_type:e.Int32}),m=e.Record({vote:e.Int32,cast_timestamp_seconds:e.Nat64,voting_power:e.Nat64}),R=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),J=e.Record({new_canister_wasm:e.Vec(e.Nat8),canister_id:e.Opt(e.Principal)}),$=e.Record({function_id:e.Nat64,payload:e.Vec(e.Nat8)}),O=e.Record({motion_text:e.Text}),eA=e.Variant({ManageNervousSystemParameters:w,AddGenericNervousSystemFunction:r,RemoveGenericNervousSystemFunction:e.Nat64,UpgradeSnsControlledCanister:J,Unspecified:e.Record({}),ExecuteGenericNervousSystemFunction:$,Motion:O}),L=e.Record({url:e.Text,title:e.Text,action:e.Opt(eA),summary:e.Text}),BA=e.Record({current_deadline_timestamp_seconds:e.Nat64}),v=e.Record({id:e.Opt(N),payload_text_rendering:e.Opt(e.Text),action:e.Nat64,failure_reason:e.Opt(k),ballots:e.Vec(e.Tuple(e.Text,m)),reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,proposal_creation_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,latest_tally:e.Opt(R),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(L),proposer:e.Opt(i),wait_for_quiet_state:e.Opt(BA),executed_timestamp_seconds:e.Nat64}),M=e.Record({memo:e.Nat64,amount_e8s:e.Nat64}),P=e.Record({function_id:e.Nat64,followees:e.Vec(i)}),W=e.Record({hash:e.Vec(e.Nat8)}),q=e.Record({to_account:e.Opt(W),percentage_to_disburse:e.Nat32}),nA=e.Record({additional_dissolve_delay_seconds:e.Nat32}),tA=e.Record({dissolve_timestamp_seconds:e.Nat64}),iA=e.Variant({StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:nA,SetDissolveTimestamp:tA}),gA=e.Record({operation:e.Opt(iA)}),pA=e.Record({vote:e.Int32,proposal:e.Opt(N)}),RA=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),qA=e.Variant({MemoAndController:RA,NeuronId:e.Record({})}),MA=e.Record({by:e.Opt(qA)}),lA=e.Record({permissions_to_remove:e.Opt(a),principal_id:e.Opt(e.Principal)}),HA=e.Record({permissions_to_add:e.Opt(a),principal_id:e.Opt(e.Principal)}),Ae=e.Record({percentage_to_merge:e.Nat32}),WA=e.Record({e8s:e.Nat64}),ee=e.Record({to_account:e.Opt(W),amount:e.Opt(WA)}),F=e.Variant({Split:M,Follow:P,DisburseMaturity:q,Configure:gA,RegisterVote:pA,MakeProposal:L,ClaimOrRefreshNeuron:MA,RemoveNeuronPermissions:lA,AddNeuronPermissions:HA,MergeMaturity:Ae,Disburse:ee}),Q=e.Record({command:e.Opt(F),timestamp:e.Nat64}),ae=e.Record({principal:e.Opt(e.Principal),permission_type:e.Vec(e.Int32)}),te=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),fA=e.Record({id:e.Opt(i),permissions:e.Vec(ae),maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,aging_since_timestamp_seconds:e.Nat64,dissolve_state:e.Opt(te),followees:e.Vec(e.Tuple(e.Nat64,s)),neuron_fees_e8s:e.Nat64}),Y=e.Record({root_canister_id:e.Opt(e.Principal),id_to_nervous_system_functions:e.Vec(e.Tuple(e.Nat64,r)),metrics:e.Opt(n),mode:e.Int32,parameters:e.Opt(w),latest_reward_event:e.Opt(S),ledger_canister_id:e.Opt(e.Principal),proposals:e.Vec(e.Tuple(e.Nat64,v)),in_flight_commands:e.Vec(e.Tuple(e.Text,Q)),neurons:e.Vec(e.Tuple(e.Text,fA)),genesis_timestamp_seconds:e.Nat64}),o=e.Record({neuron_id:e.Opt(i)}),B=e.Variant({Error:k,Neuron:fA}),g=e.Record({result:e.Opt(B)}),C=e.Record({proposal_id:e.Opt(N)}),h=e.Variant({Error:k,Proposal:v}),f=e.Record({result:e.Opt(h)}),p=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),u=e.Record({controller:e.Principal,freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),l=e.Record({controller:e.Principal,status:p,freezing_threshold:e.Nat,balance:e.Vec(e.Tuple(e.Vec(e.Nat8),e.Nat)),memory_size:e.Nat,cycles:e.Nat,settings:u,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),d=e.Record({reserved_ids:e.Vec(e.Nat64),functions:e.Vec(r)}),I=e.Record({of_principal:e.Opt(e.Principal),limit:e.Nat32,start_page_at:e.Opt(i)}),G=e.Record({neurons:e.Vec(fA)}),b=e.Record({include_reward_status:e.Vec(e.Int32),before_proposal:e.Opt(N),limit:e.Nat32,exclude_type:e.Vec(e.Nat64),include_status:e.Vec(e.Int32)}),H=e.Record({proposals:e.Vec(v)}),V=e.Variant({Split:M,Follow:P,DisburseMaturity:q,ClaimOrRefresh:MA,Configure:gA,RegisterVote:pA,MakeProposal:L,RemoveNeuronPermissions:lA,AddNeuronPermissions:HA,MergeMaturity:Ae,Disburse:ee}),sA=e.Record({subaccount:e.Vec(e.Nat8),command:e.Opt(V)}),uA=e.Record({created_neuron_id:e.Opt(i)}),Z=e.Record({transfer_block_height:e.Nat64,amount_disbursed_e8s:e.Nat64}),U=e.Record({refreshed_neuron_id:e.Opt(i)}),IA=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),ce=e.Record({transfer_block_height:e.Nat64}),ye=e.Variant({Error:k,Split:uA,Follow:e.Record({}),DisburseMaturity:Z,ClaimOrRefresh:U,Configure:e.Record({}),RegisterVote:e.Record({}),MakeProposal:C,RemoveNeuronPermission:e.Record({}),MergeMaturity:IA,Disburse:ce,AddNeuronPermission:e.Record({})}),_e=e.Record({command:e.Opt(ye)}),vA=e.Record({mode:e.Int32});return e.Service({get_build_metadata:e.Func([],[e.Text],["query"]),get_nervous_system_parameters:e.Func([e.Null],[w],["query"]),get_neuron:e.Func([o],[g],["query"]),get_proposal:e.Func([C],[f],["query"]),get_root_canister_status:e.Func([e.Null],[l],[]),list_nervous_system_functions:e.Func([],[d],["query"]),list_neurons:e.Func([I],[G],["query"]),list_proposals:e.Func([b],[H],["query"]),manage_neuron:e.Func([sA],[_e],[]),set_mode:e.Func([vA],[e.Record({})],[])})};var be=class{constructor(A,t,r){this.id=A;this.service=t;this.certifiedService=r;this.caller=({certified:A=!0})=>A?this.certifiedService:this.service}get canisterId(){return this.id}};var Ei=Ii(Tr());var Yr=Ii(Tr()),So=()=>new Yr.HttpAgent({host:"https://ic0.app",identity:new Yr.AnonymousIdentity});var dt=({options:{canisterId:e,serviceOverride:A,certifiedServiceOverride:t,agent:r},idlFactory:n,certifiedIdlFactory:i})=>{let s=r??So(),c=A??Ei.Actor.createActor(n,{agent:s,canisterId:e}),a=t??Ei.Actor.createActor(i,{agent:s,canisterId:e});return{service:c,certifiedService:a,agent:s,canisterId:e}};var Qi=e=>e?[e]:[];var ve=class extends be{constructor(){super(...arguments);this.listNeurons=async t=>{let{principal:r,limit:n,beforeNeuronId:i}=t,{neurons:s}=await this.caller(t).list_neurons({of_principal:Qi(r),limit:n??100,start_page_at:Qi(i)});return s};this.metadata=async t=>this.caller(t).get_build_metadata()}static create(t){let{service:r,certifiedService:n,canisterId:i}=dt({options:t,idlFactory:di,certifiedIdlFactory:Ci});return new ve(i,r,n)}};var Or=({IDL:e})=>{let A=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),t=e.Record({controller:e.Principal,freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),r=e.Record({controller:e.Principal,status:A,freezing_threshold:e.Nat,balance:e.Vec(e.Tuple(e.Vec(e.Nat8),e.Nat)),memory_size:e.Nat,cycles:e.Nat,settings:t,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))});return e.Service({get_sns_canisters_summary:e.Func([e.Vec(e.Principal)],[e.Vec(e.Tuple(e.Text,e.Principal,r))],[])})};var Jr=({IDL:e})=>{let A=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),t=e.Record({controller:e.Principal,freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),r=e.Record({controller:e.Principal,status:A,freezing_threshold:e.Nat,balance:e.Vec(e.Tuple(e.Vec(e.Nat8),e.Nat)),memory_size:e.Nat,cycles:e.Nat,settings:t,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))});return e.Service({get_sns_canisters_summary:e.Func([e.Vec(e.Principal)],[e.Vec(e.Tuple(e.Text,e.Principal,r))],[])})};var Ue=class extends be{static create(A){let{service:t,certifiedService:r,canisterId:n}=dt({options:A,idlFactory:Jr,certifiedIdlFactory:Or});return new Ue(n,t,r)}};var Te=class extends be{constructor(){super(...arguments);this.canistersSummary=async({certified:t=!0,additionalCanisterIds:r})=>this.caller({certified:t}).get_sns_canisters_summary(r??[])}static create(t){let{service:r,certifiedService:n,canisterId:i}=dt({options:t,idlFactory:Jr,certifiedIdlFactory:Or});return new Te(i,r,n)}};var Pt=class{constructor({root:A,governance:t,ledger:r,certified:n}){this.listNeurons=A=>this.governance.listNeurons({...A,certified:this.certified});this.metadata=A=>this.governance.metadata({...A,certified:this.certified});this.root=A,this.governance=t,this.ledger=r,this.certified=n}get canisterIds(){return{rootCanisterId:this.root.canisterId,ledgerCanisterId:this.ledger.canisterId,governanceCanisterId:this.governance.canisterId}}};var hi=class extends Error{},li=(e,A)=>{if(e==null)throw new hi(A)};var tu=async({agent:e,rootOptions:A,certified:t=!0})=>{let r=Te.create({...A,agent:e}),n=await r.canistersSummary({certified:t}),i=a=>{var w;return(w=n.find(([N,S,k])=>N===a))==null?void 0:w[1]},s=i("governance"),c=i("ledger");return li(s),li(c),new Pt({root:r,governance:ve.create({canisterId:s,agent:e}),ledger:Ue.create({canisterId:c,agent:e}),certified:t})};0&&(module.exports={GovernanceCanister,LedgerCanister,RootCanister,SnsWrapper,initSns});
830
+ `)}}bA.timeout=go;function uo(A,e){let t=A;return()=>new Promise(r=>setTimeout(()=>{t*=e,r()},t))}bA.backoff=uo;function Eo(...A){return async(e,t,r)=>{for(let n of A)await n(e,t,r)}}bA.chain=Eo});var ci=J(DA=>{"use strict";var Zg=DA&&DA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),jg=DA&&DA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),Kg=DA&&DA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&Zg(e,A,t);return jg(e,A),e};Object.defineProperty(DA,"__esModule",{value:!0});DA.pollForResponse=void 0;var ze=xr(),Wg=oi(),lo=pe();DA.strategy=Kg(ai());var Xg=ai();Object.defineProperty(DA,"defaultStrategy",{enumerable:!0,get:function(){return Xg.defaultStrategy}});async function ho(A,e,t,r){let n=[new TextEncoder().encode("request_status"),t],i=await A.readState(e,{paths:[n]});if(A.rootKey==null)throw new Error("Agent root key not initialized before polling");let s=await Wg.Certificate.create({certificate:i.certificate,rootKey:A.rootKey,canisterId:e}),c=s.lookup([...n,new TextEncoder().encode("status")]),a;switch(typeof c>"u"?a=ze.RequestStatusResponseStatus.Unknown:a=new TextDecoder().decode(c),a){case ze.RequestStatusResponseStatus.Replied:return s.lookup([...n,"reply"]);case ze.RequestStatusResponseStatus.Received:case ze.RequestStatusResponseStatus.Unknown:case ze.RequestStatusResponseStatus.Processing:return await r(e,t,a),ho(A,e,t,r);case ze.RequestStatusResponseStatus.Rejected:{let p=new Uint8Array(s.lookup([...n,"reject_code"]))[0],m=new TextDecoder().decode(s.lookup([...n,"reject_message"]));throw new Error(`Call was rejected:
831
+ Request ID: ${lo.toHex(t)}
832
+ Reject code: ${p}
833
+ Reject text: ${m}
834
+ `)}case ze.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
835
+ Request ID: ${lo.toHex(t)}
836
+ `)}throw new Error("unreachable")}DA.pollForResponse=ho});var kr=J(WA=>{"use strict";Object.defineProperty(WA,"__esModule",{value:!0});WA.Actor=WA.CanisterInstallMode=WA.UpdateCallRejectedError=WA.QueryCallRejectedError=WA.ActorCallError=void 0;var zg=Hi(),Bi=xr(),Qo=Ln(),$g=er(),Hr=St(),po=ci(),Ct=ue(),Dg=pe(),Jt=class extends $g.AgentError{constructor(e,t,r,n){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${t} (${r})`,...Object.getOwnPropertyNames(n).map(i=>` "${i}": ${JSON.stringify(n[i])}`)].join(`
837
+ `)),this.canisterId=e,this.methodName=t,this.type=r,this.props=n}};WA.ActorCallError=Jt;var Tr=class extends Jt{constructor(e,t,r){var n;super(e,t,"query",{Status:r.status,Code:(n=Bi.ReplicaRejectCode[r.reject_code])!==null&&n!==void 0?n:`Unknown Code "${r.reject_code}"`,Message:r.reject_message}),this.result=r}};WA.QueryCallRejectedError=Tr;var Ur=class extends Jt{constructor(e,t,r,n){super(e,t,"update",{"Request ID":Dg.toHex(r),"HTTP status code":n.status.toString(),"HTTP status text":n.statusText}),this.requestId=r,this.response=n}};WA.UpdateCallRejectedError=Ur;var Co;(function(A){A.Install="install",A.Reinstall="reinstall",A.Upgrade="upgrade"})(Co=WA.CanisterInstallMode||(WA.CanisterInstallMode={}));var LA=Symbol.for("ic-agent-metadata"),Pt=class{constructor(e){this[LA]=Object.freeze(e)}static agentOf(e){return e[LA].config.agent}static interfaceOf(e){return e[LA].service}static canisterIdOf(e){return Ct.Principal.from(e[LA].config.canisterId)}static async install(e,t){let r=e.mode===void 0?Co.Install:e.mode,n=e.arg?[...new Uint8Array(e.arg)]:[],i=[...new Uint8Array(e.module)],s=typeof t.canisterId=="string"?Ct.Principal.fromText(t.canisterId):t.canisterId;await Qo.getManagementCanister(t).install_code({mode:{[r]:null},arg:n,wasm_module:i,canister_id:s})}static async createCanister(e){let{canister_id:t}=await Qo.getManagementCanister(e||{}).provisional_create_canister_with_cycles({amount:[],settings:[]});return t}static async createAndInstallCanister(e,t,r){let n=await this.createCanister(r);return await this.install(Object.assign({},t),Object.assign(Object.assign({},r),{canisterId:n})),this.createActor(e,Object.assign(Object.assign({},r),{canisterId:n}))}static createActorClass(e){let t=e({IDL:Hr.IDL});class r extends Pt{constructor(i){let s=typeof i.canisterId=="string"?Ct.Principal.fromText(i.canisterId):i.canisterId;super({config:Object.assign(Object.assign(Object.assign({},Io),i),{canisterId:s}),service:t});for(let[c,a]of t._fields)this[c]=Lg(this,c,a)}}return r}static createActor(e,t){return new(this.createActorClass(e))(t)}};WA.Actor=Pt;function fo(A,e){let t=Hr.IDL.decode(A,zg.Buffer.from(e));switch(t.length){case 0:return;case 1:return t[0];default:return t}}var Io={pollingStrategyFactory:po.strategy.defaultStrategy};function Lg(A,e,t){let r;t.annotations.includes("query")?r=async(i,...s)=>{var c,a;i=Object.assign(Object.assign({},i),(a=(c=A[LA].config).queryTransform)===null||a===void 0?void 0:a.call(c,e,s,Object.assign(Object.assign({},A[LA].config),i)));let p=i.agent||A[LA].config.agent||Bi.getDefaultAgent(),m=Ct.Principal.from(i.canisterId||A[LA].config.canisterId),F=Hr.IDL.encode(t.argTypes,s),R=await p.query(m,{methodName:e,arg:F});switch(R.status){case"rejected":throw new Tr(m,e,R);case"replied":return fo(t.retTypes,R.reply.arg)}}:r=async(i,...s)=>{var c,a;i=Object.assign(Object.assign({},i),(a=(c=A[LA].config).callTransform)===null||a===void 0?void 0:a.call(c,e,s,Object.assign(Object.assign({},A[LA].config),i)));let p=i.agent||A[LA].config.agent||Bi.getDefaultAgent(),{canisterId:m,effectiveCanisterId:F,pollingStrategyFactory:R}=Object.assign(Object.assign(Object.assign({},Io),A[LA].config),i),y=Ct.Principal.from(m),q=F!==void 0?Ct.Principal.from(F):y,O=Hr.IDL.encode(t.argTypes,s),{requestId:V,response:Y}=await p.call(y,{methodName:e,arg:O,effectiveCanisterId:q});if(!Y.ok)throw new Ur(y,e,V,Y);let W=R(),Z=await po.pollForResponse(p,q,V,W);if(Z!==void 0)return fo(t.retTypes,Z);if(t.retTypes.length===0)return;throw new Error(`Call was returned undefined, but type [${t.retTypes.join(",")}].`)};let n=(...i)=>r({},...i);return n.withOptions=i=>(...s)=>r(i,...s),n}});var wo=J(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.default=({IDL:A})=>A.Service({retrieve:A.Func([A.Text],[A.Vec(A.Nat8)],["query"]),store:A.Func([A.Text,A.Vec(A.Nat8)],[],[])})});var _o=J(It=>{"use strict";var Au=It&&It.__importDefault||function(A){return A&&A.__esModule?A:{default:A}};Object.defineProperty(It,"__esModule",{value:!0});It.createAssetCanisterActor=void 0;var eu=kr(),tu=Au(wo());function ru(A){return eu.Actor.createActor(tu.default,A)}It.createAssetCanisterActor=ru});var Fo=J(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.encodePath=ve.request=void 0;var yo=St(),nu=ue(),ui=Or();ve.request=async A=>{let{canisterId:e,agent:t,paths:r}=A,n=[...new Set(r)],i=n.map(a=>ve.encodePath(a,e)),s=new Map,c=n.map((a,p)=>(async()=>{try{let m=await t.readState(e,{paths:[i[p]]}),R=(await ui.Certificate.create({certificate:m.certificate,rootKey:t.rootKey,canisterId:e})).lookup(ve.encodePath(n[p],e));if(!R)console.warn(`Expected to find result for path ${a}, but instead found nothing.`),typeof a=="string"?s.set(a,null):s.set(a.key,null);else switch(a){case"time":{s.set(a,iu(R));break}case"controllers":{s.set(a,su(R));break}case"module_hash":{s.set(a,Go(R));break}case"candid":{s.set(a,new TextDecoder().decode(R));break}default:if(typeof a!="string"&&"key"in a&&"path"in a)switch(a.decodeStrategy){case"raw":s.set(a.key,R);break;case"leb128":{s.set(a.key,mo(R));break}case"cbor":{s.set(a.key,No(R));break}case"hex":{s.set(a.key,Go(R));break}}}}catch(m){typeof a!="string"&&"key"in a&&"path"in a?s.set(a.key,null):s.set(a,null),console.warn(`Expected to find result for path ${a}, but instead found nothing.`)}})());return await Promise.all(c),s};ve.encodePath=(A,e)=>{let t=new TextEncoder,r=i=>new DataView(t.encode(i).buffer).buffer,n=new DataView(e.toUint8Array().buffer).buffer;switch(A){case"time":return[r("time")];case"controllers":return[r("canister"),n,r("controllers")];case"module_hash":return[r("canister"),n,r("module_hash")];case"subnet":return[r("subnet")];case"candid":return[r("canister"),n,r("metadata"),r("candid:service")];default:if("key"in A&&"path"in A)if(typeof A.path=="string"||A.path instanceof ArrayBuffer){let i=A.path,s=typeof i=="string"?r(i):i;return[r("canister"),n,r("metadata"),s]}else return A.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${A} was formatted correctly.`)};var Go=A=>ui.toHex(A),mo=A=>yo.lebDecode(new yo.PipeArrayBuffer(A)),No=A=>ui.Cbor.decode(A),iu=A=>{let e=mo(A);return new Date(Number(e/BigInt(1e6)))},su=A=>{let[e,...t]=No(A);return t.map(r=>nu.Principal.fromUint8Array(new Uint8Array(r)))}});var Or=J(lA=>{"use strict";var So=lA&&lA.__createBinding||(Object.create?function(A,e,t,r){r===void 0&&(r=t),Object.defineProperty(A,r,{enumerable:!0,get:function(){return e[t]}})}:function(A,e,t,r){r===void 0&&(r=t),A[r]=e[t]}),ou=lA&&lA.__setModuleDefault||(Object.create?function(A,e){Object.defineProperty(A,"default",{enumerable:!0,value:e})}:function(A,e){A.default=e}),se=lA&&lA.__exportStar||function(A,e){for(var t in A)t!=="default"&&!e.hasOwnProperty(t)&&So(e,A,t)},Ei=lA&&lA.__importStar||function(A){if(A&&A.__esModule)return A;var e={};if(A!=null)for(var t in A)t!=="default"&&Object.hasOwnProperty.call(A,t)&&So(e,A,t);return ou(e,A),e};Object.defineProperty(lA,"__esModule",{value:!0});se(kr(),lA);se(xr(),lA);se(Hn(),lA);se(oi(),lA);se(Rr(),lA);se(vt(),lA);se(_o(),lA);se(Ln(),lA);se(qt(),lA);se(ri(),lA);se(pe(),lA);lA.polling=Ei(ci());lA.CanisterStatus=Ei(Fo());lA.Cbor=Ei(Fr())});var Bu={};ca(Bu,{GovernanceCanister:()=>Te,LedgerCanister:()=>Ue,RootCanister:()=>Oe,SnsSwapLifecycle:()=>pi,SnsWrapper:()=>Vt,SwapCanister:()=>Ye,initSnsWrapper:()=>cu});module.exports=Ba(Bu);var pi=(i=>(i[i.Unspecified=0]="Unspecified",i[i.Pending=1]="Pending",i[i.Open=2]="Open",i[i.Committed=3]="Committed",i[i.Aborted=4]="Aborted",i))(pi||{});var Ci=({IDL:A})=>{let e=A.Record({validator_canister_id:A.Opt(A.Principal),target_canister_id:A.Opt(A.Principal),validator_method_name:A.Opt(A.Text),target_method_name:A.Opt(A.Text)}),t=A.Variant({NativeNervousSystemFunction:A.Record({}),GenericNervousSystemFunction:e}),r=A.Record({id:A.Nat64,name:A.Text,description:A.Opt(A.Text),function_type:A.Opt(t)}),n=A.Record({not_dissolving_neurons_e8s_buckets:A.Vec(A.Tuple(A.Nat64,A.Float64)),garbage_collectable_neurons_count:A.Nat64,neurons_with_invalid_stake_count:A.Nat64,not_dissolving_neurons_count_buckets:A.Vec(A.Tuple(A.Nat64,A.Nat64)),neurons_with_less_than_6_months_dissolve_delay_count:A.Nat64,dissolved_neurons_count:A.Nat64,total_staked_e8s:A.Nat64,total_supply_governance_tokens:A.Nat64,not_dissolving_neurons_count:A.Nat64,dissolved_neurons_e8s:A.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:A.Nat64,dissolving_neurons_count_buckets:A.Vec(A.Tuple(A.Nat64,A.Nat64)),dissolving_neurons_count:A.Nat64,dissolving_neurons_e8s_buckets:A.Vec(A.Tuple(A.Nat64,A.Float64)),timestamp_seconds:A.Nat64}),i=A.Record({id:A.Vec(A.Nat8)}),s=A.Record({followees:A.Vec(i)}),c=A.Record({followees:A.Vec(A.Tuple(A.Nat64,s))}),a=A.Record({permissions:A.Vec(A.Int32)}),p=A.Record({default_followees:A.Opt(c),max_dissolve_delay_seconds:A.Opt(A.Nat64),max_followees_per_function:A.Opt(A.Nat64),neuron_claimer_permissions:A.Opt(a),neuron_minimum_stake_e8s:A.Opt(A.Nat64),initial_voting_period:A.Opt(A.Nat64),max_neuron_age_for_age_bonus:A.Opt(A.Nat64),neuron_minimum_dissolve_delay_to_vote_seconds:A.Opt(A.Nat64),reject_cost_e8s:A.Opt(A.Nat64),max_proposals_to_keep_per_action:A.Opt(A.Nat32),max_number_of_neurons:A.Opt(A.Nat64),transaction_fee_e8s:A.Opt(A.Nat64),max_number_of_proposals_with_ballots:A.Opt(A.Nat64),reward_distribution_period_seconds:A.Opt(A.Nat64),neuron_grantable_permissions:A.Opt(a),max_number_of_principals_per_neuron:A.Opt(A.Nat64)}),m=A.Record({id:A.Nat64}),F=A.Record({actual_timestamp_seconds:A.Nat64,periods_since_genesis:A.Nat64,distributed_e8s_equivalent:A.Nat64,settled_proposals:A.Vec(m)}),R=A.Record({error_message:A.Text,error_type:A.Int32}),y=A.Record({vote:A.Int32,cast_timestamp_seconds:A.Nat64,voting_power:A.Nat64}),q=A.Record({no:A.Nat64,yes:A.Nat64,total:A.Nat64,timestamp_seconds:A.Nat64}),O=A.Record({new_canister_wasm:A.Vec(A.Nat8),canister_id:A.Opt(A.Principal)}),V=A.Record({function_id:A.Nat64,payload:A.Vec(A.Nat8)}),Y=A.Record({motion_text:A.Text}),W=A.Variant({ManageNervousSystemParameters:p,AddGenericNervousSystemFunction:r,RemoveGenericNervousSystemFunction:A.Nat64,UpgradeSnsControlledCanister:O,Unspecified:A.Record({}),ExecuteGenericNervousSystemFunction:V,Motion:Y}),Z=A.Record({url:A.Text,title:A.Text,action:A.Opt(W),summary:A.Text}),iA=A.Record({current_deadline_timestamp_seconds:A.Nat64}),v=A.Record({id:A.Opt(m),payload_text_rendering:A.Opt(A.Text),action:A.Nat64,failure_reason:A.Opt(R),ballots:A.Vec(A.Tuple(A.Text,y)),reward_event_round:A.Nat64,failed_timestamp_seconds:A.Nat64,proposal_creation_timestamp_seconds:A.Nat64,reject_cost_e8s:A.Nat64,latest_tally:A.Opt(q),decided_timestamp_seconds:A.Nat64,proposal:A.Opt(Z),proposer:A.Opt(i),wait_for_quiet_state:A.Opt(iA),executed_timestamp_seconds:A.Nat64}),M=A.Record({memo:A.Nat64,amount_e8s:A.Nat64}),P=A.Record({function_id:A.Nat64,followees:A.Vec(i)}),D=A.Record({subaccount:A.Vec(A.Nat8)}),x=A.Record({of:A.Opt(A.Principal),subaccount:A.Opt(D)}),rA=A.Record({to_account:A.Opt(x),percentage_to_disburse:A.Nat32}),nA=A.Record({additional_dissolve_delay_seconds:A.Nat32}),sA=A.Record({dissolve_timestamp_seconds:A.Nat64}),hA=A.Variant({StopDissolving:A.Record({}),StartDissolving:A.Record({}),IncreaseDissolveDelay:nA,SetDissolveTimestamp:sA}),CA=A.Record({operation:A.Opt(hA)}),GA=A.Record({vote:A.Int32,proposal:A.Opt(m)}),xA=A.Record({controller:A.Opt(A.Principal),memo:A.Nat64}),UA=A.Variant({MemoAndController:xA,NeuronId:A.Record({})}),QA=A.Record({by:A.Opt(UA)}),MA=A.Record({permissions_to_remove:A.Opt(a),principal_id:A.Opt(A.Principal)}),Ae=A.Record({permissions_to_add:A.Opt(a),principal_id:A.Opt(A.Principal)}),OA=A.Record({percentage_to_merge:A.Nat32}),_e=A.Record({e8s:A.Nat64}),S=A.Record({to_account:A.Opt(x),amount:A.Opt(_e)}),l=A.Variant({Split:M,Follow:P,DisburseMaturity:rA,Configure:CA,RegisterVote:GA,MakeProposal:Z,ClaimOrRefreshNeuron:QA,RemoveNeuronPermissions:MA,AddNeuronPermissions:Ae,MergeMaturity:OA,Disburse:S}),oe=A.Record({command:A.Opt(l),timestamp:A.Nat64}),ee=A.Record({principal:A.Opt(A.Principal),permission_type:A.Vec(A.Int32)}),mA=A.Variant({DissolveDelaySeconds:A.Nat64,WhenDissolvedTimestampSeconds:A.Nat64}),T=A.Record({id:A.Opt(i),permissions:A.Vec(ee),maturity_e8s_equivalent:A.Nat64,cached_neuron_stake_e8s:A.Nat64,created_timestamp_seconds:A.Nat64,aging_since_timestamp_seconds:A.Nat64,dissolve_state:A.Opt(mA),followees:A.Vec(A.Tuple(A.Nat64,s)),neuron_fees_e8s:A.Nat64}),o=A.Record({root_canister_id:A.Opt(A.Principal),id_to_nervous_system_functions:A.Vec(A.Tuple(A.Nat64,r)),metrics:A.Opt(n),mode:A.Int32,parameters:A.Opt(p),latest_reward_event:A.Opt(F),ledger_canister_id:A.Opt(A.Principal),proposals:A.Vec(A.Tuple(A.Nat64,v)),in_flight_commands:A.Vec(A.Tuple(A.Text,oe)),neurons:A.Vec(A.Tuple(A.Text,T)),genesis_timestamp_seconds:A.Nat64}),B=A.Record({neuron_id:A.Opt(i)}),g=A.Variant({Error:R,Neuron:T}),C=A.Record({result:A.Opt(g)}),h=A.Record({proposal_id:A.Opt(m)}),f=A.Variant({Error:R,Proposal:v}),w=A.Record({result:A.Opt(f)}),u=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),Q=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),I=A.Record({controller:A.Principal,status:u,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:Q,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),d=A.Record({reserved_ids:A.Vec(A.Nat64),functions:A.Vec(r)}),N=A.Record({of_principal:A.Opt(A.Principal),limit:A.Nat32,start_page_at:A.Opt(i)}),b=A.Record({neurons:A.Vec(T)}),H=A.Record({include_reward_status:A.Vec(A.Int32),before_proposal:A.Opt(m),limit:A.Nat32,exclude_type:A.Vec(A.Nat64),include_status:A.Vec(A.Int32)}),X=A.Record({proposals:A.Vec(v)}),oA=A.Variant({Split:M,Follow:P,DisburseMaturity:rA,ClaimOrRefresh:QA,Configure:CA,RegisterVote:GA,MakeProposal:Z,RemoveNeuronPermissions:MA,AddNeuronPermissions:Ae,MergeMaturity:OA,Disburse:S}),gA=A.Record({subaccount:A.Vec(A.Nat8),command:A.Opt(oA)}),j=A.Record({created_neuron_id:A.Opt(i)}),U=A.Record({transfer_block_height:A.Nat64,amount_disbursed_e8s:A.Nat64}),fA=A.Record({refreshed_neuron_id:A.Opt(i)}),ae=A.Record({merged_maturity_e8s:A.Nat64,new_stake_e8s:A.Nat64}),ye=A.Record({transfer_block_height:A.Nat64}),Ge=A.Variant({Error:R,Split:j,Follow:A.Record({}),DisburseMaturity:U,ClaimOrRefresh:fA,Configure:A.Record({}),RegisterVote:A.Record({}),MakeProposal:h,RemoveNeuronPermission:A.Record({}),MergeMaturity:ae,Disburse:ye,AddNeuronPermission:A.Record({})}),vA=A.Record({command:A.Opt(Ge)}),AA=A.Record({mode:A.Int32});return A.Service({get_build_metadata:A.Func([],[A.Text],[]),get_nervous_system_parameters:A.Func([A.Null],[p],[]),get_neuron:A.Func([B],[C],[]),get_proposal:A.Func([h],[w],[]),get_root_canister_status:A.Func([A.Null],[I],[]),list_nervous_system_functions:A.Func([],[d],[]),list_neurons:A.Func([N],[b],[]),list_proposals:A.Func([H],[X],[]),manage_neuron:A.Func([gA],[vA],[]),set_mode:A.Func([AA],[A.Record({})],[])})};var Ii=({IDL:A})=>{let e=A.Record({validator_canister_id:A.Opt(A.Principal),target_canister_id:A.Opt(A.Principal),validator_method_name:A.Opt(A.Text),target_method_name:A.Opt(A.Text)}),t=A.Variant({NativeNervousSystemFunction:A.Record({}),GenericNervousSystemFunction:e}),r=A.Record({id:A.Nat64,name:A.Text,description:A.Opt(A.Text),function_type:A.Opt(t)}),n=A.Record({not_dissolving_neurons_e8s_buckets:A.Vec(A.Tuple(A.Nat64,A.Float64)),garbage_collectable_neurons_count:A.Nat64,neurons_with_invalid_stake_count:A.Nat64,not_dissolving_neurons_count_buckets:A.Vec(A.Tuple(A.Nat64,A.Nat64)),neurons_with_less_than_6_months_dissolve_delay_count:A.Nat64,dissolved_neurons_count:A.Nat64,total_staked_e8s:A.Nat64,total_supply_governance_tokens:A.Nat64,not_dissolving_neurons_count:A.Nat64,dissolved_neurons_e8s:A.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:A.Nat64,dissolving_neurons_count_buckets:A.Vec(A.Tuple(A.Nat64,A.Nat64)),dissolving_neurons_count:A.Nat64,dissolving_neurons_e8s_buckets:A.Vec(A.Tuple(A.Nat64,A.Float64)),timestamp_seconds:A.Nat64}),i=A.Record({id:A.Vec(A.Nat8)}),s=A.Record({followees:A.Vec(i)}),c=A.Record({followees:A.Vec(A.Tuple(A.Nat64,s))}),a=A.Record({permissions:A.Vec(A.Int32)}),p=A.Record({default_followees:A.Opt(c),max_dissolve_delay_seconds:A.Opt(A.Nat64),max_followees_per_function:A.Opt(A.Nat64),neuron_claimer_permissions:A.Opt(a),neuron_minimum_stake_e8s:A.Opt(A.Nat64),initial_voting_period:A.Opt(A.Nat64),max_neuron_age_for_age_bonus:A.Opt(A.Nat64),neuron_minimum_dissolve_delay_to_vote_seconds:A.Opt(A.Nat64),reject_cost_e8s:A.Opt(A.Nat64),max_proposals_to_keep_per_action:A.Opt(A.Nat32),max_number_of_neurons:A.Opt(A.Nat64),transaction_fee_e8s:A.Opt(A.Nat64),max_number_of_proposals_with_ballots:A.Opt(A.Nat64),reward_distribution_period_seconds:A.Opt(A.Nat64),neuron_grantable_permissions:A.Opt(a),max_number_of_principals_per_neuron:A.Opt(A.Nat64)}),m=A.Record({id:A.Nat64}),F=A.Record({actual_timestamp_seconds:A.Nat64,periods_since_genesis:A.Nat64,distributed_e8s_equivalent:A.Nat64,settled_proposals:A.Vec(m)}),R=A.Record({error_message:A.Text,error_type:A.Int32}),y=A.Record({vote:A.Int32,cast_timestamp_seconds:A.Nat64,voting_power:A.Nat64}),q=A.Record({no:A.Nat64,yes:A.Nat64,total:A.Nat64,timestamp_seconds:A.Nat64}),O=A.Record({new_canister_wasm:A.Vec(A.Nat8),canister_id:A.Opt(A.Principal)}),V=A.Record({function_id:A.Nat64,payload:A.Vec(A.Nat8)}),Y=A.Record({motion_text:A.Text}),W=A.Variant({ManageNervousSystemParameters:p,AddGenericNervousSystemFunction:r,RemoveGenericNervousSystemFunction:A.Nat64,UpgradeSnsControlledCanister:O,Unspecified:A.Record({}),ExecuteGenericNervousSystemFunction:V,Motion:Y}),Z=A.Record({url:A.Text,title:A.Text,action:A.Opt(W),summary:A.Text}),iA=A.Record({current_deadline_timestamp_seconds:A.Nat64}),v=A.Record({id:A.Opt(m),payload_text_rendering:A.Opt(A.Text),action:A.Nat64,failure_reason:A.Opt(R),ballots:A.Vec(A.Tuple(A.Text,y)),reward_event_round:A.Nat64,failed_timestamp_seconds:A.Nat64,proposal_creation_timestamp_seconds:A.Nat64,reject_cost_e8s:A.Nat64,latest_tally:A.Opt(q),decided_timestamp_seconds:A.Nat64,proposal:A.Opt(Z),proposer:A.Opt(i),wait_for_quiet_state:A.Opt(iA),executed_timestamp_seconds:A.Nat64}),M=A.Record({memo:A.Nat64,amount_e8s:A.Nat64}),P=A.Record({function_id:A.Nat64,followees:A.Vec(i)}),D=A.Record({subaccount:A.Vec(A.Nat8)}),x=A.Record({of:A.Opt(A.Principal),subaccount:A.Opt(D)}),rA=A.Record({to_account:A.Opt(x),percentage_to_disburse:A.Nat32}),nA=A.Record({additional_dissolve_delay_seconds:A.Nat32}),sA=A.Record({dissolve_timestamp_seconds:A.Nat64}),hA=A.Variant({StopDissolving:A.Record({}),StartDissolving:A.Record({}),IncreaseDissolveDelay:nA,SetDissolveTimestamp:sA}),CA=A.Record({operation:A.Opt(hA)}),GA=A.Record({vote:A.Int32,proposal:A.Opt(m)}),xA=A.Record({controller:A.Opt(A.Principal),memo:A.Nat64}),UA=A.Variant({MemoAndController:xA,NeuronId:A.Record({})}),QA=A.Record({by:A.Opt(UA)}),MA=A.Record({permissions_to_remove:A.Opt(a),principal_id:A.Opt(A.Principal)}),Ae=A.Record({permissions_to_add:A.Opt(a),principal_id:A.Opt(A.Principal)}),OA=A.Record({percentage_to_merge:A.Nat32}),_e=A.Record({e8s:A.Nat64}),S=A.Record({to_account:A.Opt(x),amount:A.Opt(_e)}),l=A.Variant({Split:M,Follow:P,DisburseMaturity:rA,Configure:CA,RegisterVote:GA,MakeProposal:Z,ClaimOrRefreshNeuron:QA,RemoveNeuronPermissions:MA,AddNeuronPermissions:Ae,MergeMaturity:OA,Disburse:S}),oe=A.Record({command:A.Opt(l),timestamp:A.Nat64}),ee=A.Record({principal:A.Opt(A.Principal),permission_type:A.Vec(A.Int32)}),mA=A.Variant({DissolveDelaySeconds:A.Nat64,WhenDissolvedTimestampSeconds:A.Nat64}),T=A.Record({id:A.Opt(i),permissions:A.Vec(ee),maturity_e8s_equivalent:A.Nat64,cached_neuron_stake_e8s:A.Nat64,created_timestamp_seconds:A.Nat64,aging_since_timestamp_seconds:A.Nat64,dissolve_state:A.Opt(mA),followees:A.Vec(A.Tuple(A.Nat64,s)),neuron_fees_e8s:A.Nat64}),o=A.Record({root_canister_id:A.Opt(A.Principal),id_to_nervous_system_functions:A.Vec(A.Tuple(A.Nat64,r)),metrics:A.Opt(n),mode:A.Int32,parameters:A.Opt(p),latest_reward_event:A.Opt(F),ledger_canister_id:A.Opt(A.Principal),proposals:A.Vec(A.Tuple(A.Nat64,v)),in_flight_commands:A.Vec(A.Tuple(A.Text,oe)),neurons:A.Vec(A.Tuple(A.Text,T)),genesis_timestamp_seconds:A.Nat64}),B=A.Record({neuron_id:A.Opt(i)}),g=A.Variant({Error:R,Neuron:T}),C=A.Record({result:A.Opt(g)}),h=A.Record({proposal_id:A.Opt(m)}),f=A.Variant({Error:R,Proposal:v}),w=A.Record({result:A.Opt(f)}),u=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),Q=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),I=A.Record({controller:A.Principal,status:u,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:Q,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),d=A.Record({reserved_ids:A.Vec(A.Nat64),functions:A.Vec(r)}),N=A.Record({of_principal:A.Opt(A.Principal),limit:A.Nat32,start_page_at:A.Opt(i)}),b=A.Record({neurons:A.Vec(T)}),H=A.Record({include_reward_status:A.Vec(A.Int32),before_proposal:A.Opt(m),limit:A.Nat32,exclude_type:A.Vec(A.Nat64),include_status:A.Vec(A.Int32)}),X=A.Record({proposals:A.Vec(v)}),oA=A.Variant({Split:M,Follow:P,DisburseMaturity:rA,ClaimOrRefresh:QA,Configure:CA,RegisterVote:GA,MakeProposal:Z,RemoveNeuronPermissions:MA,AddNeuronPermissions:Ae,MergeMaturity:OA,Disburse:S}),gA=A.Record({subaccount:A.Vec(A.Nat8),command:A.Opt(oA)}),j=A.Record({created_neuron_id:A.Opt(i)}),U=A.Record({transfer_block_height:A.Nat64,amount_disbursed_e8s:A.Nat64}),fA=A.Record({refreshed_neuron_id:A.Opt(i)}),ae=A.Record({merged_maturity_e8s:A.Nat64,new_stake_e8s:A.Nat64}),ye=A.Record({transfer_block_height:A.Nat64}),Ge=A.Variant({Error:R,Split:j,Follow:A.Record({}),DisburseMaturity:U,ClaimOrRefresh:fA,Configure:A.Record({}),RegisterVote:A.Record({}),MakeProposal:h,RemoveNeuronPermission:A.Record({}),MergeMaturity:ae,Disburse:ye,AddNeuronPermission:A.Record({})}),vA=A.Record({command:A.Opt(Ge)}),AA=A.Record({mode:A.Int32});return A.Service({get_build_metadata:A.Func([],[A.Text],["query"]),get_nervous_system_parameters:A.Func([A.Null],[p],["query"]),get_neuron:A.Func([B],[C],["query"]),get_proposal:A.Func([h],[w],["query"]),get_root_canister_status:A.Func([A.Null],[I],[]),list_nervous_system_functions:A.Func([],[d],["query"]),list_neurons:A.Func([N],[b],["query"]),list_proposals:A.Func([H],[X],["query"]),manage_neuron:A.Func([gA],[vA],[]),set_mode:A.Func([AA],[A.Record({})],[])})};var ce=class{constructor(e,t,r){this.id=e;this.service=t;this.certifiedService=r;this.caller=({certified:e=!0})=>e?this.certifiedService:this.service}get canisterId(){return this.id}};var li=di(Or());var Yr=di(Or()),Ro=()=>new Yr.HttpAgent({host:"https://ic0.app",identity:new Yr.AnonymousIdentity});var He=({options:{canisterId:A,serviceOverride:e,certifiedServiceOverride:t,agent:r},idlFactory:n,certifiedIdlFactory:i})=>{let s=r??Ro(),c=e??li.Actor.createActor(n,{agent:s,canisterId:A}),a=t??li.Actor.createActor(i,{agent:s,canisterId:A});return{service:c,certifiedService:a,agent:s,canisterId:A}};var hi=A=>A?[A]:[],Jr=A=>A==null?void 0:A[0];var Te=class extends ce{constructor(){super(...arguments);this.listNeurons=async t=>{let{principal:r,limit:n,beforeNeuronId:i}=t,{neurons:s}=await this.caller(t).list_neurons({of_principal:hi(r),limit:n??100,start_page_at:hi(i)});return s};this.metadata=async t=>this.caller(t).get_build_metadata()}static create(t){let{service:r,certifiedService:n,canisterId:i}=He({options:t,idlFactory:Ii,certifiedIdlFactory:Ci});return new Te(i,r,n)}};var bo=({IDL:A})=>{let e=A.Nat64,t=A.Record({start:e,length:A.Nat64}),r=A.Nat64,n=A.Vec(A.Nat8),i=A.Record({e8s:A.Nat64}),s=A.Variant({Burn:A.Record({from:n,amount:i}),Mint:A.Record({to:n,amount:i}),Transfer:A.Record({to:n,fee:i,from:n,amount:i})}),c=A.Record({timestamp_nanos:A.Nat64}),a=A.Record({memo:r,operation:A.Opt(s),created_at_time:c}),p=A.Record({transaction:a,timestamp:c,parent_hash:A.Opt(A.Vec(A.Nat8))}),m=A.Record({blocks:A.Vec(p)}),F=A.Variant({BadFirstBlockIndex:A.Record({requested_index:e,first_valid_index:e}),Other:A.Record({error_message:A.Text,error_code:A.Nat64})}),R=A.Variant({Ok:m,Err:F}),y=A.Func([t],[R],[]),q=A.Record({certificate:A.Opt(A.Vec(A.Nat8)),blocks:A.Vec(p),chain_length:A.Nat64,first_block_index:e,archived_blocks:A.Vec(A.Record({callback:y,start:e,length:A.Nat64}))}),O=A.Record({account:n}),V=A.Record({canister_id:A.Principal}),Y=A.Record({archives:A.Vec(V)}),W=A.Vec(A.Nat8),Z=A.Record({to:n,fee:i,memo:r,from_subaccount:A.Opt(W),created_at_time:A.Opt(c),amount:i}),iA=A.Variant({TxTooOld:A.Record({allowed_window_nanos:A.Nat64}),BadFee:A.Record({expected_fee:i}),TxDuplicate:A.Record({duplicate_of:e}),TxCreatedInFuture:A.Null,InsufficientFunds:A.Record({balance:i})}),v=A.Variant({Ok:e,Err:iA}),M=A.Record({}),P=A.Record({transfer_fee:i});return A.Service({_blocks:A.Func([t],[q],[]),account_balance:A.Func([O],[i],[]),archives:A.Func([],[Y],[]),decimals:A.Func([],[A.Record({decimals:A.Nat32})],[]),name:A.Func([],[A.Record({name:A.Text})],[]),symbol:A.Func([],[A.Record({symbol:A.Text})],[]),transfer:A.Func([Z],[v],[]),transfer_fee:A.Func([M],[P],[])})};var xo=({IDL:A})=>{let e=A.Vec(A.Nat8),t=A.Record({account:e}),r=A.Record({e8s:A.Nat64}),n=A.Record({canister_id:A.Principal}),i=A.Record({archives:A.Vec(n)}),s=A.Nat64,c=A.Record({start:s,length:A.Nat64}),a=A.Nat64,p=A.Variant({Burn:A.Record({from:e,amount:r}),Mint:A.Record({to:e,amount:r}),Transfer:A.Record({to:e,fee:r,from:e,amount:r})}),m=A.Record({timestamp_nanos:A.Nat64}),F=A.Record({memo:a,operation:A.Opt(p),created_at_time:m}),R=A.Record({transaction:F,timestamp:m,parent_hash:A.Opt(A.Vec(A.Nat8))}),y=A.Record({blocks:A.Vec(R)}),q=A.Variant({BadFirstBlockIndex:A.Record({requested_index:s,first_valid_index:s}),Other:A.Record({error_message:A.Text,error_code:A.Nat64})}),O=A.Variant({Ok:y,Err:q}),V=A.Func([c],[O],["query"]),Y=A.Record({certificate:A.Opt(A.Vec(A.Nat8)),blocks:A.Vec(R),chain_length:A.Nat64,first_block_index:s,archived_blocks:A.Vec(A.Record({callback:V,start:s,length:A.Nat64}))}),W=A.Vec(A.Nat8),Z=A.Record({to:e,fee:r,memo:a,from_subaccount:A.Opt(W),created_at_time:A.Opt(m),amount:r}),iA=A.Variant({TxTooOld:A.Record({allowed_window_nanos:A.Nat64}),BadFee:A.Record({expected_fee:r}),TxDuplicate:A.Record({duplicate_of:s}),TxCreatedInFuture:A.Null,InsufficientFunds:A.Record({balance:r})}),v=A.Variant({Ok:s,Err:iA}),M=A.Record({}),P=A.Record({transfer_fee:r});return A.Service({account_balance:A.Func([t],[r],["query"]),archives:A.Func([],[i],["query"]),decimals:A.Func([],[A.Record({decimals:A.Nat32})],["query"]),name:A.Func([],[A.Record({name:A.Text})],["query"]),query_blocks:A.Func([c],[Y],["query"]),symbol:A.Func([],[A.Record({symbol:A.Text})],["query"]),transfer:A.Func([Z],[v],[]),transfer_fee:A.Func([M],[P],["query"])})};var Ue=class extends ce{static create(e){let{service:t,certifiedService:r,canisterId:n}=He({options:e,idlFactory:xo,certifiedIdlFactory:bo});return new Ue(n,t,r)}};var ko=({IDL:A})=>{let e=A.Record({dapp_canister_ids:A.Vec(A.Principal),governance_canister_id:A.Opt(A.Principal),swap_canister_id:A.Opt(A.Principal),ledger_canister_id:A.Opt(A.Principal)}),t=A.Record({canister_id:A.Principal}),r=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),n=A.Record({controller:A.Principal,status:r,memory_size:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),i=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),s=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),c=A.Record({controller:A.Principal,status:i,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:s,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),a=A.Record({status:A.Opt(c),canister_id:A.Opt(A.Principal)}),p=A.Record({ledger_canister_summary:A.Opt(a),governance_canister_summary:A.Opt(a),root_canister_summary:A.Opt(a),dapp_canister_summaries:A.Vec(a)}),m=A.Record({root:A.Opt(A.Principal),swap:A.Opt(A.Principal),ledger:A.Opt(A.Principal),governance:A.Opt(A.Principal),dapps:A.Vec(A.Principal),archives:A.Vec(A.Principal)}),F=A.Record({canister_id:A.Opt(A.Principal)}),R=A.Record({controller_principal_ids:A.Vec(A.Principal)}),y=A.Record({code:A.Opt(A.Int32),description:A.Text}),q=A.Record({err:A.Opt(y),dapp_canister_id:A.Opt(A.Principal)}),O=A.Record({failed_updates:A.Vec(q)});return A.Service({canister_status:A.Func([t],[n],[]),get_build_metadata:A.Func([],[A.Text],[]),get_sns_canisters_summary:A.Func([A.Record({})],[p],[]),list_sns_canisters:A.Func([A.Record({})],[m],[]),register_dapp_canister:A.Func([F],[A.Record({})],[]),set_dapp_controllers:A.Func([R],[O],[])})};var qo=({IDL:A})=>{let e=A.Record({dapp_canister_ids:A.Vec(A.Principal),governance_canister_id:A.Opt(A.Principal),swap_canister_id:A.Opt(A.Principal),ledger_canister_id:A.Opt(A.Principal)}),t=A.Record({canister_id:A.Principal}),r=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),n=A.Record({controller:A.Principal,status:r,memory_size:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),i=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),s=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),c=A.Record({controller:A.Principal,status:i,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:s,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),a=A.Record({status:A.Opt(c),canister_id:A.Opt(A.Principal)}),p=A.Record({ledger_canister_summary:A.Opt(a),governance_canister_summary:A.Opt(a),root_canister_summary:A.Opt(a),dapp_canister_summaries:A.Vec(a)}),m=A.Record({root:A.Opt(A.Principal),swap:A.Opt(A.Principal),ledger:A.Opt(A.Principal),governance:A.Opt(A.Principal),dapps:A.Vec(A.Principal),archives:A.Vec(A.Principal)}),F=A.Record({canister_id:A.Opt(A.Principal)}),R=A.Record({controller_principal_ids:A.Vec(A.Principal)}),y=A.Record({code:A.Opt(A.Int32),description:A.Text}),q=A.Record({err:A.Opt(y),dapp_canister_id:A.Opt(A.Principal)}),O=A.Record({failed_updates:A.Vec(q)});return A.Service({canister_status:A.Func([t],[n],[]),get_build_metadata:A.Func([],[A.Text],["query"]),get_sns_canisters_summary:A.Func([A.Record({})],[p],[]),list_sns_canisters:A.Func([A.Record({})],[m],["query"]),register_dapp_canister:A.Func([F],[A.Record({})],[]),set_dapp_controllers:A.Func([R],[O],[])})};var Oe=class extends ce{constructor(){super(...arguments);this.listSnsCanisters=async({certified:t=!0})=>this.caller({certified:t}).list_sns_canisters({})}static create(t){let{service:r,certifiedService:n,canisterId:i}=He({options:t,idlFactory:qo,certifiedIdlFactory:ko});return new Oe(i,r,n)}};var Vt=class{constructor({root:e,governance:t,ledger:r,swap:n,certified:i}){this.listNeurons=e=>this.governance.listNeurons(this.mergeParams(e));this.metadata=e=>this.governance.metadata(this.mergeParams(e));this.swapState=e=>this.swap.state(this.mergeParams(e));this.root=e,this.governance=t,this.ledger=r,this.swap=n,this.certified=i}get canisterIds(){return{rootCanisterId:this.root.canisterId,ledgerCanisterId:this.ledger.canisterId,governanceCanisterId:this.governance.canisterId}}mergeParams(e){return{...e,certified:this.certified}}};var Mo=({IDL:A})=>{let e=A.Record({min_participant_icp_e8s:A.Nat64,fallback_controller_principal_ids:A.Vec(A.Text),max_icp_e8s:A.Nat64,min_participants:A.Nat32,nns_governance_canister_id:A.Text,icp_ledger_canister_id:A.Text,sns_ledger_canister_id:A.Text,max_participant_icp_e8s:A.Nat64,sns_governance_canister_id:A.Text,min_icp_e8s:A.Nat64}),t=A.Record({icp_e8s:A.Nat64,fee_override_e8s:A.Nat64}),r=A.Record({code:A.Opt(A.Int32),description:A.Text}),n=A.Variant({Err:r}),i=A.Record({possibility:A.Opt(n)}),s=A.Record({failure:A.Nat32,skipped:A.Nat32,success:A.Nat32}),c=A.Record({sns_governance_normal_mode_enabled:A.Opt(i),sweep_icp:A.Opt(s),sweep_sns:A.Opt(s),create_neuron:A.Opt(s)}),a=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),p=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),m=A.Record({controller:A.Principal,status:a,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:p,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),F=A.Record({status:m}),R=A.Record({start_timestamp_seconds:A.Nat64,end_timestamp_seconds:A.Nat64}),y=A.Record({icp_disbursing:A.Bool,amount_sns_e8s:A.Nat64,amount_icp_e8s:A.Nat64,sns_disbursing:A.Bool}),q=A.Record({open_time_window:A.Opt(R),sns_token_e8s:A.Nat64,lifecycle:A.Int32,buyers:A.Vec(A.Tuple(A.Text,y))}),O=A.Record({init:A.Opt(e),state:A.Opt(q)}),V=A.Record({sns_tokens_per_icp:A.Float32,buyer_total_icp_e8s:A.Nat64}),Y=A.Record({swap:A.Opt(O),derived:A.Opt(V)}),W=A.Record({buyer:A.Text}),Z=A.Record({open_time_window:A.Opt(R)});return A.Service({error_refund_icp:A.Func([t],[A.Record({})],[]),finalize_swap:A.Func([A.Record({})],[c],[]),get_canister_status:A.Func([A.Record({})],[F],[]),get_state:A.Func([A.Record({})],[Y],[]),refresh_buyer_tokens:A.Func([W],[A.Record({})],[]),refresh_sns_tokens:A.Func([A.Record({})],[A.Record({})],[]),set_open_time_window:A.Func([Z],[A.Record({})],[])})};var vo=({IDL:A})=>{let e=A.Record({min_participant_icp_e8s:A.Nat64,fallback_controller_principal_ids:A.Vec(A.Text),max_icp_e8s:A.Nat64,min_participants:A.Nat32,nns_governance_canister_id:A.Text,icp_ledger_canister_id:A.Text,sns_ledger_canister_id:A.Text,max_participant_icp_e8s:A.Nat64,sns_governance_canister_id:A.Text,min_icp_e8s:A.Nat64}),t=A.Record({icp_e8s:A.Nat64,fee_override_e8s:A.Nat64}),r=A.Record({code:A.Opt(A.Int32),description:A.Text}),n=A.Variant({Err:r}),i=A.Record({possibility:A.Opt(n)}),s=A.Record({failure:A.Nat32,skipped:A.Nat32,success:A.Nat32}),c=A.Record({sns_governance_normal_mode_enabled:A.Opt(i),sweep_icp:A.Opt(s),sweep_sns:A.Opt(s),create_neuron:A.Opt(s)}),a=A.Variant({stopped:A.Null,stopping:A.Null,running:A.Null}),p=A.Record({controller:A.Principal,freezing_threshold:A.Nat,controllers:A.Vec(A.Principal),memory_allocation:A.Nat,compute_allocation:A.Nat}),m=A.Record({controller:A.Principal,status:a,freezing_threshold:A.Nat,balance:A.Vec(A.Tuple(A.Vec(A.Nat8),A.Nat)),memory_size:A.Nat,cycles:A.Nat,settings:p,idle_cycles_burned_per_day:A.Nat,module_hash:A.Opt(A.Vec(A.Nat8))}),F=A.Record({status:m}),R=A.Record({start_timestamp_seconds:A.Nat64,end_timestamp_seconds:A.Nat64}),y=A.Record({icp_disbursing:A.Bool,amount_sns_e8s:A.Nat64,amount_icp_e8s:A.Nat64,sns_disbursing:A.Bool}),q=A.Record({open_time_window:A.Opt(R),sns_token_e8s:A.Nat64,lifecycle:A.Int32,buyers:A.Vec(A.Tuple(A.Text,y))}),O=A.Record({init:A.Opt(e),state:A.Opt(q)}),V=A.Record({sns_tokens_per_icp:A.Float32,buyer_total_icp_e8s:A.Nat64}),Y=A.Record({swap:A.Opt(O),derived:A.Opt(V)}),W=A.Record({buyer:A.Text}),Z=A.Record({open_time_window:A.Opt(R)});return A.Service({error_refund_icp:A.Func([t],[A.Record({})],[]),finalize_swap:A.Func([A.Record({})],[c],[]),get_canister_status:A.Func([A.Record({})],[F],[]),get_state:A.Func([A.Record({})],[Y],["query"]),refresh_buyer_tokens:A.Func([W],[A.Record({})],[]),refresh_sns_tokens:A.Func([A.Record({})],[A.Record({})],[]),set_open_time_window:A.Func([Z],[A.Record({})],[])})};var Ye=class extends ce{constructor(){super(...arguments);this.state=t=>this.caller(t).get_state({})}static create(t){let{service:r,certifiedService:n,canisterId:i}=He({options:t,idlFactory:vo,certifiedIdlFactory:Mo});return new Ye(i,r,n)}};var Qi=class extends Error{},Pr=(A,e)=>{if(A==null)throw new Qi(e)};var cu=async({agent:A,rootOptions:e,certified:t=!0})=>{let r=Oe.create({...e,agent:A}),{ledger:n,swap:i,governance:s}=await r.listSnsCanisters({certified:t}),c=Jr(s),a=Jr(n),p=Jr(i);return Pr(c),Pr(a),Pr(p),new Vt({root:r,governance:Te.create({canisterId:c,agent:A}),ledger:Ue.create({canisterId:a,agent:A}),swap:Ye.create({canisterId:p,agent:A}),certified:t})};0&&(module.exports={GovernanceCanister,LedgerCanister,RootCanister,SnsSwapLifecycle,SnsWrapper,SwapCanister,initSnsWrapper});
838
838
  /*!
839
839
  * The buffer module from node.js, for the browser.
840
840
  *