blockcore-notes/472.97f3e27d27990537.js

1 line
122 KiB
JavaScript
Raw Normal View History

(()=>{var a,se,er={5521:(se,a)=>{"use strict";function H(l){if(!Number.isSafeInteger(l))throw new Error(`Wrong integer: ${l}`)}function D(...l){const u=(j,k)=>V=>j(k(V));return{encode:Array.from(l).reverse().reduce((j,k)=>j?u(j,k.encode):k.encode,void 0),decode:l.reduce((j,k)=>j?u(j,k.decode):k.decode,void 0)}}function d(l){return{encode:u=>{if(!Array.isArray(u)||u.length&&"number"!=typeof u[0])throw new Error("alphabet.encode input should be an array of numbers");return u.map(y=>{if(H(y),y<0||y>=l.length)throw new Error(`Digit index outside alphabet: ${y} (alphabet: ${l.length})`);return l[y]})},decode:u=>{if(!Array.isArray(u)||u.length&&"string"!=typeof u[0])throw new Error("alphabet.decode input should be array of strings");return u.map(y=>{if("string"!=typeof y)throw new Error(`alphabet.decode: not string element=${y}`);const U=l.indexOf(y);if(-1===U)throw new Error(`Unknown letter: "${y}". Allowed: ${l}`);return U})}}}function C(l=""){if("string"!=typeof l)throw new Error("join separator should be string");return{encode:u=>{if(!Array.isArray(u)||u.length&&"string"!=typeof u[0])throw new Error("join.encode input should be array of strings");for(let y of u)if("string"!=typeof y)throw new Error(`join.encode: non-string input=${y}`);return u.join(l)},decode:u=>{if("string"!=typeof u)throw new Error("join.decode input should be string");return u.split(l)}}}function Z(l,u="="){if(H(l),"string"!=typeof u)throw new Error("padding chr should be string");return{encode(y){if(!Array.isArray(y)||y.length&&"string"!=typeof y[0])throw new Error("padding.encode input should be array of strings");for(let U of y)if("string"!=typeof U)throw new Error(`padding.encode: non-string input=${U}`);for(;y.length*l%8;)y.push(u);return y},decode(y){if(!Array.isArray(y)||y.length&&"string"!=typeof y[0])throw new Error("padding.encode input should be array of strings");for(let j of y)if("string"!=typeof j)throw new Error(`padding.decode: non-string input=${j}`);let U=y.length;if(U*l%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;U>0&&y[U-1]===u;U--)if(!((U-1)*l%8))throw new Error("Invalid padding: string has too much padding");return y.slice(0,U)}}}function Q(l){if("function"!=typeof l)throw new Error("normalize fn should be function");return{encode:u=>u,decode:u=>l(u)}}function m(l,u,y){if(u<2)throw new Error(`convertRadix: wrong from=${u}, base cannot be less than 2`);if(y<2)throw new Error(`convertRadix: wrong to=${y}, base cannot be less than 2`);if(!Array.isArray(l))throw new Error("convertRadix: data should be array");if(!l.length)return[];let U=0;const j=[],k=Array.from(l);for(k.forEach(V=>{if(H(V),V<0||V>=u)throw new Error(`Wrong integer: ${V}`)});;){let V=0,ce=!0;for(let le=U;le<k.length;le++){const fe=k[le],M=u*V+fe;if(!Number.isSafeInteger(M)||u*V/u!==V||M-fe!=u*V)throw new Error("convertRadix: carry overflow");if(V=M%y,k[le]=Math.floor(M/y),!Number.isSafeInteger(k[le])||k[le]*y+V!==M)throw new Error("convertRadix: carry overflow");ce&&(k[le]?ce=!1:U=le)}if(j.push(V),ce)break}for(let V=0;V<l.length-1&&0===l[V];V++)j.push(0);return j.reverse()}Object.defineProperty(a,"__esModule",{value:!0}),a.bytes=a.stringToBytes=a.str=a.bytesToString=a.hex=a.utf8=a.bech32m=a.bech32=a.base58check=a.base58xmr=a.base58xrp=a.base58flickr=a.base58=a.base64url=a.base64=a.base32crockford=a.base32hex=a.base32=a.base16=a.utils=a.assertNumber=void 0,a.assertNumber=H;const w=(l,u)=>u?w(u,l%u):l,$=(l,u)=>l+(u-w(l,u));function q(l,u,y,U){if(!Array.isArray(l))throw new Error("convertRadix2: data should be array");if(u<=0||u>32)throw new Error(`convertRadix2: wrong from=${u}`);if(y<=0||y>32)throw new Error(`convertRadix2: wrong to=${y}`);if($(u,y)>32)throw new Error(`convertRadix2: carry overflow from=${u} to=${y} carryBits=${$(u,y)}`);let j=0,k=0;const V=2**y-1,ce=[];for(const le of l){if(H(le),le>=2**u)throw new Error(`convertRadix2: invalid data word=${le} from=${u}`);if(j=j<<u|le,k+u>32)throw new Error(`convertRadix2: carry overflow pos=${k} from=${u}`);for(k+=u;k>=y;k-=y)ce.push((j>>k-y&V)>>>0);j&=2**k-1}if(j=j<<y-k&V,!U&&