@dfinity/ledger-icp
Version:
A library for interfacing with the ICP ledger on the Internet Computer.
20 lines (16 loc) • 30.2 kB
JavaScript
import{a as dr}from"./chunk-OHHNCOLH.js";import{A as _t,B as kt,C as bt,D as mr,a as ot,b as ut,c as ct,d as ft,e as ht,f as pt,g as st,h as lt,i as at,j as N,k as yt,l as xt,m as wt,n as Bt,o as dt,p as mt,q as Et,r as gt,s as It,t as At,u as Ft,v as Ut,w as Tt,x as Rt,y as Ct,z as St}from"./chunk-W2HWVSWO.js";import"./chunk-CQ4GZJ2C.js";import{a as L,b as xr,c as V,d as wr,e as Br}from"./chunk-D2JQPN4X.js";var J=L(S=>{"use strict";S.byteLength=gr;S.toByteArray=Ar;S.fromByteArray=Tr;var B=[],x=[],Er=typeof Uint8Array<"u"?Uint8Array:Array,M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(g=0,X=M.length;g<X;++g)B[g]=M[g],x[M.charCodeAt(g)]=g;var g,X;x[45]=62;x[95]=63;function z(i){var r=i.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=r);var e=t===r?0:4-t%4;return[t,e]}function gr(i){var r=z(i),t=r[0],e=r[1];return(t+e)*3/4-e}function Ir(i,r,t){return(r+t)*3/4-t}function Ar(i){var r,t=z(i),e=t[0],n=t[1],o=new Er(Ir(i,e,n)),u=0,f=n>0?e-4:e,h;for(h=0;h<f;h+=4)r=x[i.charCodeAt(h)]<<18|x[i.charCodeAt(h+1)]<<12|x[i.charCodeAt(h+2)]<<6|x[i.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return n===2&&(r=x[i.charCodeAt(h)]<<2|x[i.charCodeAt(h+1)]>>4,o[u++]=r&255),n===1&&(r=x[i.charCodeAt(h)]<<10|x[i.charCodeAt(h+1)]<<4|x[i.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Fr(i){return B[i>>18&63]+B[i>>12&63]+B[i>>6&63]+B[i&63]}function Ur(i,r,t){for(var e,n=[],o=r;o<t;o+=3)e=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(i[o+2]&255),n.push(Fr(e));return n.join("")}function Tr(i){for(var r,t=i.length,e=t%3,n=[],o=16383,u=0,f=t-e;u<f;u+=o)n.push(Ur(i,u,u+o>f?f:u+o));return e===1?(r=i[t-1],n.push(B[r>>2]+B[r<<4&63]+"==")):e===2&&(r=(i[t-2]<<8)+i[t-1],n.push(B[r>>10]+B[r>>4&63]+B[r<<2&63]+"=")),n.join("")}});var K=L($=>{$.read=function(i,r,t,e,n){var o,u,f=n*8-e-1,h=(1<<f)-1,l=h>>1,s=-7,p=t?n-1:0,A=t?-1:1,w=i[r+p];for(p+=A,o=w&(1<<-s)-1,w>>=-s,s+=f;s>0;o=o*256+i[r+p],p+=A,s-=8);for(u=o&(1<<-s)-1,o>>=-s,s+=e;s>0;u=u*256+i[r+p],p+=A,s-=8);if(o===0)o=1-l;else{if(o===h)return u?NaN:(w?-1:1)*(1/0);u=u+Math.pow(2,e),o=o-l}return(w?-1:1)*u*Math.pow(2,o-e)};$.write=function(i,r,t,e,n,o){var u,f,h,l=o*8-n-1,s=(1<<l)-1,p=s>>1,A=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=e?0:o-1,b=e?1:-1,yr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,u=s):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+p>=1?r+=A/h:r+=A*Math.pow(2,1-p),r*h>=2&&(u++,h/=2),u+p>=s?(f=0,u=s):u+p>=1?(f=(r*h-1)*Math.pow(2,n),u=u+p):(f=r*Math.pow(2,p-1)*Math.pow(2,n),u=0));n>=8;i[t+w]=f&255,w+=b,f/=256,n-=8);for(u=u<<n|f,l+=n;l>0;i[t+w]=u&255,w+=b,u/=256,l-=8);i[t+w-b]|=yr*128}});var ar=L(R=>{"use strict";var D=J(),U=K(),Z=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=c;R.SlowBuffer=br;R.INSPECT_MAX_BYTES=50;var _=2147483647;R.kMaxLength=_;c.TYPED_ARRAY_SUPPORT=Rr();!c.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 Rr(){try{let i=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(i,r),i.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function m(i){if(i>_)throw new RangeError('The value "'+i+'" is invalid for option "size"');let r=new Uint8Array(i);return Object.setPrototypeOf(r,c.prototype),r}function c(i,r,t){if(typeof i=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return G(i)}return tr(i,r,t)}c.poolSize=8192;function tr(i,r,t){if(typeof i=="string")return Sr(i,r);if(ArrayBuffer.isView(i))return _r(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(d(i,ArrayBuffer)||i&&d(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(d(i,SharedArrayBuffer)||i&&d(i.buffer,SharedArrayBuffer)))return O(i,r,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let e=i.valueOf&&i.valueOf();if(e!=null&&e!==i)return c.from(e,r,t);let n=kr(i);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return c.from(i[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}c.from=function(i,r,t){return tr(i,r,t)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function ir(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function Cr(i,r,t){return ir(i),i<=0?m(i):r!==void 0?typeof t=="string"?m(i).fill(r,t):m(i).fill(r):m(i)}c.alloc=function(i,r,t){return Cr(i,r,t)};function G(i){return ir(i),m(i<0?0:H(i)|0)}c.allocUnsafe=function(i){return G(i)};c.allocUnsafeSlow=function(i){return G(i)};function Sr(i,r){if((typeof r!="string"||r==="")&&(r="utf8"),!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=er(i,r)|0,e=m(t),n=e.write(i,r);return n!==t&&(e=e.slice(0,n)),e}function P(i){let r=i.length<0?0:H(i.length)|0,t=m(r);for(let e=0;e<r;e+=1)t[e]=i[e]&255;return t}function _r(i){if(d(i,Uint8Array)){let r=new Uint8Array(i);return O(r.buffer,r.byteOffset,r.byteLength)}return P(i)}function O(i,r,t){if(r<0||i.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let e;return r===void 0&&t===void 0?e=new Uint8Array(i):t===void 0?e=new Uint8Array(i,r):e=new Uint8Array(i,r,t),Object.setPrototypeOf(e,c.prototype),e}function kr(i){if(c.isBuffer(i)){let r=H(i.length)|0,t=m(r);return t.length===0||i.copy(t,0,0,r),t}if(i.length!==void 0)return typeof i.length!="number"||W(i.length)?m(0):P(i);if(i.type==="Buffer"&&Array.isArray(i.data))return P(i.data)}function H(i){if(i>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return i|0}function br(i){return+i!=i&&(i=0),c.alloc(+i)}c.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==c.prototype};c.compare=function(r,t){if(d(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),d(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(r)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let e=r.length,n=t.length;for(let o=0,u=Math.min(e,n);o<u;++o)if(r[o]!==t[o]){e=r[o],n=t[o];break}return e<n?-1:n<e?1:0};c.isEncoding=function(r){switch(String(r).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}};c.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return c.alloc(0);let e;if(t===void 0)for(t=0,e=0;e<r.length;++e)t+=r[e].length;let n=c.allocUnsafe(t),o=0;for(e=0;e<r.length;++e){let u=r[e];if(d(u,Uint8Array))o+u.length>n.length?(c.isBuffer(u)||(u=c.from(u)),u.copy(n,o)):Uint8Array.prototype.set.call(n,u,o);else if(c.isBuffer(u))u.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return n};function er(i,r){if(c.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||d(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);let t=i.length,e=arguments.length>2&&arguments[2]===!0;if(!e&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return q(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return lr(i).length;default:if(n)return e?-1:q(i).length;r=(""+r).toLowerCase(),n=!0}}c.byteLength=er;function Lr(i,r,t){let e=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(i||(i="utf8");;)switch(i){case"hex":return Yr(this,r,t);case"utf8":case"utf-8":return or(this,r,t);case"ascii":return Gr(this,r,t);case"latin1":case"binary":return Hr(this,r,t);case"base64":return Or(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,r,t);default:if(e)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),e=!0}}c.prototype._isBuffer=!0;function I(i,r,t){let e=i[r];i[r]=i[t],i[t]=e}c.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)I(this,t,t+1);return this};c.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)I(this,t,t+3),I(this,t+1,t+2);return this};c.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)I(this,t,t+7),I(this,t+1,t+6),I(this,t+2,t+5),I(this,t+3,t+4);return this};c.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?or(this,0,r):Lr.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(r){if(!c.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:c.compare(this,r)===0};c.prototype.inspect=function(){let r="",t=R.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Z&&(c.prototype[Z]=c.prototype.inspect);c.prototype.compare=function(r,t,e,n,o){if(d(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),e===void 0&&(e=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||e>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=e)return 0;if(n>=o)return-1;if(t>=e)return 1;if(t>>>=0,e>>>=0,n>>>=0,o>>>=0,this===r)return 0;let u=o-n,f=e-t,h=Math.min(u,f),l=this.slice(n,o),s=r.slice(t,e);for(let p=0;p<h;++p)if(l[p]!==s[p]){u=l[p],f=s[p];break}return u<f?-1:f<u?1:0};function nr(i,r,t,e,n){if(i.length===0)return-1;if(typeof t=="string"?(e=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,W(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=c.from(r,e)),c.isBuffer(r))return r.length===0?-1:Q(i,r,t,e,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,r,t):Uint8Array.prototype.lastIndexOf.call(i,r,t):Q(i,[r],t,e,n);throw new TypeError("val must be string, number or Buffer")}function Q(i,r,t,e,n){let o=1,u=i.length,f=r.length;if(e!==void 0&&(e=String(e).toLowerCase(),e==="ucs2"||e==="ucs-2"||e==="utf16le"||e==="utf-16le")){if(i.length<2||r.length<2)return-1;o=2,u/=2,f/=2,t/=2}function h(s,p){return o===1?s[p]:s.readUInt16BE(p*o)}let l;if(n){let s=-1;for(l=t;l<u;l++)if(h(i,l)===h(r,s===-1?0:l-s)){if(s===-1&&(s=l),l-s+1===f)return s*o}else s!==-1&&(l-=l-s),s=-1}else for(t+f>u&&(t=u-f),l=t;l>=0;l--){let s=!0;for(let p=0;p<f;p++)if(h(i,l+p)!==h(r,p)){s=!1;break}if(s)return l}return-1}c.prototype.includes=function(r,t,e){return this.indexOf(r,t,e)!==-1};c.prototype.indexOf=function(r,t,e){return nr(this,r,t,e,!0)};c.prototype.lastIndexOf=function(r,t,e){return nr(this,r,t,e,!1)};function Nr(i,r,t,e){t=Number(t)||0;let n=i.length-t;e?(e=Number(e),e>n&&(e=n)):e=n;let o=r.length;e>o/2&&(e=o/2);let u;for(u=0;u<e;++u){let f=parseInt(r.substr(u*2,2),16);if(W(f))return u;i[t+u]=f}return u}function Mr(i,r,t,e){return k(q(r,i.length-t),i,t,e)}function $r(i,r,t,e){return k(zr(r),i,t,e)}function Dr(i,r,t,e){return k(lr(r),i,t,e)}function Pr(i,r,t,e){return k(Jr(r,i.length-t),i,t,e)}c.prototype.write=function(r,t,e,n){if(t===void 0)n="utf8",e=this.length,t=0;else if(e===void 0&&typeof t=="string")n=t,e=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(e)?(e=e>>>0,n===void 0&&(n="utf8")):(n=e,e=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((e===void 0||e>o)&&(e=o),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let u=!1;for(;;)switch(n){case"hex":return Nr(this,r,t,e);case"utf8":case"utf-8":return Mr(this,r,t,e);case"ascii":case"latin1":case"binary":return $r(this,r,t,e);case"base64":return Dr(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pr(this,r,t,e);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Or(i,r,t){return r===0&&t===i.length?D.fromByteArray(i):D.fromByteArray(i.slice(r,t))}function or(i,r,t){t=Math.min(i.length,t);let e=[],n=r;for(;n<t;){let o=i[n],u=null,f=o>239?4:o>223?3:o>191?2:1;if(n+f<=t){let h,l,s,p;switch(f){case 1:o<128&&(u=o);break;case 2:h=i[n+1],(h&192)===128&&(p=(o&31)<<6|h&63,p>127&&(u=p));break;case 3:h=i[n+1],l=i[n+2],(h&192)===128&&(l&192)===128&&(p=(o&15)<<12|(h&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(u=p));break;case 4:h=i[n+1],l=i[n+2],s=i[n+3],(h&192)===128&&(l&192)===128&&(s&192)===128&&(p=(o&15)<<18|(h&63)<<12|(l&63)<<6|s&63,p>65535&&p<1114112&&(u=p))}}u===null?(u=65533,f=1):u>65535&&(u-=65536,e.push(u>>>10&1023|55296),u=56320|u&1023),e.push(u),n+=f}return qr(e)}var v=4096;function qr(i){let r=i.length;if(r<=v)return String.fromCharCode.apply(String,i);let t="",e=0;for(;e<r;)t+=String.fromCharCode.apply(String,i.slice(e,e+=v));return t}function Gr(i,r,t){let e="";t=Math.min(i.length,t);for(let n=r;n<t;++n)e+=String.fromCharCode(i[n]&127);return e}function Hr(i,r,t){let e="";t=Math.min(i.length,t);for(let n=r;n<t;++n)e+=String.fromCharCode(i[n]);return e}function Yr(i,r,t){let e=i.length;(!r||r<0)&&(r=0),(!t||t<0||t>e)&&(t=e);let n="";for(let o=r;o<t;++o)n+=Kr[i[o]];return n}function Wr(i,r,t){let e=i.slice(r,t),n="";for(let o=0;o<e.length-1;o+=2)n+=String.fromCharCode(e[o]+e[o+1]*256);return n}c.prototype.slice=function(r,t){let e=this.length;r=~~r,t=t===void 0?e:~~t,r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),t<0?(t+=e,t<0&&(t=0)):t>e&&(t=e),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,c.prototype),n};function a(i,r,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+r>t)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(r,t,e){r=r>>>0,t=t>>>0,e||a(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return n};c.prototype.readUintBE=c.prototype.readUIntBE=function(r,t,e){r=r>>>0,t=t>>>0,e||a(r,t,this.length);let n=this[r+--t],o=1;for(;t>0&&(o*=256);)n+=this[r+--t]*o;return n};c.prototype.readUint8=c.prototype.readUInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]|this[r+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]<<8|this[r+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};c.prototype.readBigUInt64LE=E(function(r){r=r>>>0,T(r,"offset");let t=this[r],e=this[r+7];(t===void 0||e===void 0)&&C(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+e*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=E(function(r){r=r>>>0,T(r,"offset");let t=this[r],e=this[r+7];(t===void 0||e===void 0)&&C(r,this.length-8);let n=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+e;return(BigInt(n)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(r,t,e){r=r>>>0,t=t>>>0,e||a(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};c.prototype.readIntBE=function(r,t,e){r=r>>>0,t=t>>>0,e||a(r,t,this.length);let n=t,o=1,u=this[r+--n];for(;n>0&&(o*=256);)u+=this[r+--n]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};c.prototype.readInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};c.prototype.readInt16LE=function(r,t){r=r>>>0,t||a(r,2,this.length);let e=this[r]|this[r+1]<<8;return e&32768?e|4294901760:e};c.prototype.readInt16BE=function(r,t){r=r>>>0,t||a(r,2,this.length);let e=this[r+1]|this[r]<<8;return e&32768?e|4294901760:e};c.prototype.readInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};c.prototype.readInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};c.prototype.readBigInt64LE=E(function(r){r=r>>>0,T(r,"offset");let t=this[r],e=this[r+7];(t===void 0||e===void 0)&&C(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(e<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});c.prototype.readBigInt64BE=E(function(r){r=r>>>0,T(r,"offset");let t=this[r],e=this[r+7];(t===void 0||e===void 0)&&C(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+e)});c.prototype.readFloatLE=function(r,t){return r=r>>>0,t||a(r,4,this.length),U.read(this,r,!0,23,4)};c.prototype.readFloatBE=function(r,t){return r=r>>>0,t||a(r,4,this.length),U.read(this,r,!1,23,4)};c.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!0,52,8)};c.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!1,52,8)};function y(i,r,t,e,n,o){if(!c.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(t+e>i.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(r,t,e,n){if(r=+r,t=t>>>0,e=e>>>0,!n){let f=Math.pow(2,8*e)-1;y(this,r,t,e,f,0)}let o=1,u=0;for(this[t]=r&255;++u<e&&(o*=256);)this[t+u]=r/o&255;return t+e};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(r,t,e,n){if(r=+r,t=t>>>0,e=e>>>0,!n){let f=Math.pow(2,8*e)-1;y(this,r,t,e,f,0)}let o=e-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+e};c.prototype.writeUint8=c.prototype.writeUInt8=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,1,255,0),this[t]=r&255,t+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function ur(i,r,t,e,n){sr(r,e,n,i,t,7);let o=Number(r&BigInt(4294967295));i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,t}function cr(i,r,t,e,n){sr(r,e,n,i,t,7);let o=Number(r&BigInt(4294967295));i[t+7]=o,o=o>>8,i[t+6]=o,o=o>>8,i[t+5]=o,o=o>>8,i[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t+3]=u,u=u>>8,i[t+2]=u,u=u>>8,i[t+1]=u,u=u>>8,i[t]=u,t+8}c.prototype.writeBigUInt64LE=E(function(r,t=0){return ur(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=E(function(r,t=0){return cr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*e-1);y(this,r,t,e,h-1,-h)}let o=0,u=1,f=0;for(this[t]=r&255;++o<e&&(u*=256);)r<0&&f===0&&this[t+o-1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+e};c.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*e-1);y(this,r,t,e,h-1,-h)}let o=e-1,u=1,f=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&f===0&&this[t+o+1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+e};c.prototype.writeInt8=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};c.prototype.writeInt16LE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};c.prototype.writeInt16BE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};c.prototype.writeInt32LE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};c.prototype.writeInt32BE=function(r,t,e){return r=+r,t=t>>>0,e||y(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};c.prototype.writeBigInt64LE=E(function(r,t=0){return ur(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=E(function(r,t=0){return cr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fr(i,r,t,e,n,o){if(t+e>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function hr(i,r,t,e,n){return r=+r,t=t>>>0,n||fr(i,r,t,4,34028234663852886e22,-34028234663852886e22),U.write(i,r,t,e,23,4),t+4}c.prototype.writeFloatLE=function(r,t,e){return hr(this,r,t,!0,e)};c.prototype.writeFloatBE=function(r,t,e){return hr(this,r,t,!1,e)};function pr(i,r,t,e,n){return r=+r,t=t>>>0,n||fr(i,r,t,8,17976931348623157e292,-17976931348623157e292),U.write(i,r,t,e,52,8),t+8}c.prototype.writeDoubleLE=function(r,t,e){return pr(this,r,t,!0,e)};c.prototype.writeDoubleBE=function(r,t,e){return pr(this,r,t,!1,e)};c.prototype.copy=function(r,t,e,n){if(!c.isBuffer(r))throw new TypeError("argument should be a Buffer");if(e||(e=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<e&&(n=e),n===e||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=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),r.length-t<n-e&&(n=r.length-t+e);let o=n-e;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,e,n):Uint8Array.prototype.set.call(r,this.subarray(e,n),t),o};c.prototype.fill=function(r,t,e,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,e=this.length):typeof e=="string"&&(n=e,e=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let u=r.charCodeAt(0);(n==="utf8"&&u<128||n==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<e)throw new RangeError("Out of range index");if(e<=t)return this;t=t>>>0,e=e===void 0?this.length:e>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<e;++o)this[o]=r;else{let u=c.isBuffer(r)?r:c.from(r,n),f=u.length;if(f===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<e-t;++o)this[o+t]=u[o%f]}return this};var F={};function Y(i,r,t){F[i]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${i}]`,this.stack,delete this.name}get code(){return i}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${i}]: ${this.message}`}}}Y("ERR_BUFFER_OUT_OF_BOUNDS",function(i){return i?`${i} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Y("ERR_INVALID_ARG_TYPE",function(i,r){return`The "${i}" argument must be of type number. Received type ${typeof r}`},TypeError);Y("ERR_OUT_OF_RANGE",function(i,r,t){let e=`The value of "${i}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=rr(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=rr(n)),n+="n"),e+=` It must be ${r}. Received ${n}`,e},RangeError);function rr(i){let r="",t=i.length,e=i[0]==="-"?1:0;for(;t>=e+4;t-=3)r=`_${i.slice(t-3,t)}${r}`;return`${i.slice(0,t)}${r}`}function jr(i,r,t){T(r,"offset"),(i[r]===void 0||i[r+t]===void 0)&&C(r,i.length-(t+1))}function sr(i,r,t,e,n,o){if(i>t||i<r){let u=typeof r=="bigint"?"n":"",f;throw o>3?r===0||r===BigInt(0)?f=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:f=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:f=`>= ${r}${u} and <= ${t}${u}`,new F.ERR_OUT_OF_RANGE("value",f,i)}jr(e,n,o)}function T(i,r){if(typeof i!="number")throw new F.ERR_INVALID_ARG_TYPE(r,"number",i)}function C(i,r,t){throw Math.floor(i)!==i?(T(i,t),new F.ERR_OUT_OF_RANGE(t||"offset","an integer",i)):r<0?new F.ERR_BUFFER_OUT_OF_BOUNDS:new F.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,i)}var Vr=/[^+/0-9A-Za-z-_]/g;function Xr(i){if(i=i.split("=")[0],i=i.trim().replace(Vr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function q(i,r){r=r||1/0;let t,e=i.length,n=null,o=[];for(let u=0;u<e;++u){if(t=i.charCodeAt(u),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===e){(r-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function zr(i){let r=[];for(let t=0;t<i.length;++t)r.push(i.charCodeAt(t)&255);return r}function Jr(i,r){let t,e,n,o=[];for(let u=0;u<i.length&&!((r-=2)<0);++u)t=i.charCodeAt(u),e=t>>8,n=t%256,o.push(n),o.push(e);return o}function lr(i){return D.toByteArray(Xr(i))}function k(i,r,t,e){let n;for(n=0;n<e&&!(n+t>=r.length||n>=i.length);++n)r[n+t]=i[n];return n}function d(i,r){return i instanceof r||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===r.name}function W(i){return i!==i}var Kr=function(){let i="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let e=t*16;for(let n=0;n<16;++n)r[e+n]=i[t]+i[n]}return r}();function E(i){return typeof BigInt>"u"?Zr:i}function Zr(){throw new Error("BigInt not supported")}});import{arrayOfNumberToUint8Array as Qr,asciiStringToByteArray as vr,bigEndianCrc32 as rt,uint8ArrayToHexString as tt}from"@dfinity/utils";var j=xr(ar()),Ot=i=>Uint8Array.from(j.Buffer.from(i,"hex")).subarray(4),qt=i=>j.Buffer.from(i).toString("hex"),Gt=(i,r)=>{let t=vr(`
account-id`),e=V.create();e.update(Qr([...t,...i.toUint8Array(),...r??Array(32).fill(0)]));let n=e.digest(),o=rt(n),u=new Uint8Array([...o,...n]);return tt(u)};import{bigEndianCrc32 as it,isNullish as et}from"@dfinity/utils";var nt=i=>{if(i.length!=64)throw new N(`Invalid account identifier ${i}. The account identifier must be 64 chars in length.`);let r=Buffer.from(i,"hex"),t=r.slice(0,4),e=Buffer.from(it(r.slice(4)));if(!e.equals(t))throw new N(`Account identifier ${i} has an invalid checksum. Are you sure the account identifier is correct?
Expected checksum: ${e.toString("hex")}
Found checksum: ${t.toString("hex")}`)},jt=i=>{if(et(i))return!1;try{return nt(i),!0}catch{}return!1};export{wr as AccountIdentifier,It as AllowanceChangedError,st as ApproveError,dt as BadFeeError,lt as ConsentMessageError,Ct as ConsentMessageUnavailableError,At as CreatedInFutureError,gt as DuplicateError,Ut as ExpiredError,mt as GenericError,ht as IcrcError,dr as IndexCanister,yt as InsufficientFundsError,Tt as InsufficientPaymentError,N as InvalidAccountIDError,at as InvalidSenderError,mr as LedgerCanister,Br as SubAccount,Et as TemporarilyUnavailableError,Ft as TooOldError,pt as TransferError,wt as TxCreatedInFutureError,Bt as TxDuplicateError,xt as TxTooOldError,Rt as UnsupportedCanisterCallError,qt as accountIdentifierFromBytes,Ot as accountIdentifierToBytes,nt as checkAccountId,jt as isIcpAccountIdentifier,_t as mapIcrc1TransferError,bt as mapIcrc21ConsentMessageError,kt as mapIcrc2ApproveError,St as mapTransferError,Gt as principalToAccountIdentifier,ut as toIcrc1TransferRawRequest,ft as toIcrc21ConsentMessageRawRequest,ct as toIcrc2ApproveRawRequest,ot as toTransferRawRequest};
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
*/
//# sourceMappingURL=index.js.map