@dfinity/nns 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +32 -261
  2. package/dist/cjs/index.cjs.js +2 -8
  3. package/dist/cjs/index.cjs.js.map +4 -4
  4. package/dist/esm/{chunk-OFXRZRFU.js → chunk-IJWQXUQ5.js} +2 -2
  5. package/dist/esm/chunk-KCY3PAEP.js +2 -0
  6. package/dist/esm/chunk-KCY3PAEP.js.map +7 -0
  7. package/dist/esm/chunk-LARRGLCK.js +20 -0
  8. package/dist/esm/chunk-LARRGLCK.js.map +7 -0
  9. package/dist/esm/{chunk-QJA26RTP.js → chunk-YKKQOXDQ.js} +2 -2
  10. package/dist/esm/genesis_token.canister.js +1 -1
  11. package/dist/esm/governance.canister.js +1 -1
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/sns_wasm.canister.js +1 -1
  15. package/dist/types/canisters/governance/request.converters.d.ts +1 -1
  16. package/dist/types/constants/canister_ids.d.ts +0 -1
  17. package/dist/types/constants/constants.d.ts +0 -4
  18. package/dist/types/errors/governance.errors.d.ts +0 -2
  19. package/dist/types/governance.canister.d.ts +1 -1
  20. package/dist/types/index.d.ts +0 -7
  21. package/dist/types/types/common.d.ts +0 -1
  22. package/package.json +2 -1
  23. package/dist/candid/ledger.certified.idl.d.ts +0 -2
  24. package/dist/candid/ledger.certified.idl.js +0 -245
  25. package/dist/candid/ledger.d.ts +0 -215
  26. package/dist/candid/ledger.did +0 -380
  27. package/dist/candid/ledger.idl.d.ts +0 -2
  28. package/dist/candid/ledger.idl.js +0 -265
  29. package/dist/esm/account_identifier.js +0 -2
  30. package/dist/esm/account_identifier.js.map +0 -7
  31. package/dist/esm/chunk-2MZ7K2GY.js +0 -4
  32. package/dist/esm/chunk-2MZ7K2GY.js.map +0 -7
  33. package/dist/esm/chunk-DGJWOAUC.js +0 -2
  34. package/dist/esm/chunk-DGJWOAUC.js.map +0 -7
  35. package/dist/esm/chunk-H5FXE6EH.js +0 -8
  36. package/dist/esm/chunk-H5FXE6EH.js.map +0 -7
  37. package/dist/esm/chunk-IS3C7V4B.js +0 -2
  38. package/dist/esm/chunk-IS3C7V4B.js.map +0 -7
  39. package/dist/esm/chunk-JCUF5KWH.js +0 -2
  40. package/dist/esm/chunk-JCUF5KWH.js.map +0 -7
  41. package/dist/esm/chunk-TETJJ4EX.js +0 -20
  42. package/dist/esm/chunk-TETJJ4EX.js.map +0 -7
  43. package/dist/esm/chunk-WDXBCCBB.js +0 -2
  44. package/dist/esm/chunk-WDXBCCBB.js.map +0 -7
  45. package/dist/esm/chunk-ZMUQLPST.js +0 -2
  46. package/dist/esm/chunk-ZMUQLPST.js.map +0 -7
  47. package/dist/esm/icp.js +0 -2
  48. package/dist/esm/icp.js.map +0 -7
  49. package/dist/esm/ledger.canister.js +0 -2
  50. package/dist/esm/ledger.canister.js.map +0 -7
  51. package/dist/types/account_identifier.d.ts +0 -29
  52. package/dist/types/canisters/ledger/ledger.request.converts.d.ts +0 -7
  53. package/dist/types/errors/ledger.errors.d.ts +0 -27
  54. package/dist/types/icp.d.ts +0 -22
  55. package/dist/types/ledger.canister.d.ts +0 -48
  56. package/dist/types/types/ledger.options.d.ts +0 -15
  57. package/dist/types/types/ledger_converters.d.ts +0 -19
  58. package/dist/types/utils/account_identifier.utils.d.ts +0 -5
  59. package/dist/types/utils/accounts.utils.d.ts +0 -6
  60. /package/dist/esm/{chunk-OFXRZRFU.js.map → chunk-IJWQXUQ5.js.map} +0 -0
  61. /package/dist/esm/{chunk-QJA26RTP.js.map → chunk-YKKQOXDQ.js.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants/constants.ts"],
4
- "sourcesContent": ["export const SUB_ACCOUNT_BYTE_LENGTH = 32;\nexport const CREATE_CANISTER_MEMO = BigInt(0x41455243); // CREA,\nexport const TOP_UP_CANISTER_MEMO = BigInt(0x50555054); // TPUP\n\nexport const TRANSACTION_FEE = BigInt(10_000);\n\n// Note: Canister IDs are not constant, so are not provided here.\n// The same applies to HOST.\nexport const E8S_PER_TOKEN = BigInt(100000000);\n"],
5
- "mappings": "AACO,IAAMA,EAAuB,OAAO,UAAU,EACxCC,EAAuB,OAAO,UAAU,EAExCC,EAAkB,OAAO,GAAM,EAI/BC,EAAgB,OAAO,GAAS",
6
- "names": ["CREATE_CANISTER_MEMO", "TOP_UP_CANISTER_MEMO", "TRANSACTION_FEE", "E8S_PER_TOKEN"]
7
- }
@@ -1,8 +0,0 @@
1
- import{a as H}from"./chunk-2MZ7K2GY.js";import{arrayOfNumberToUint8Array as v,asciiStringToByteArray as G,bigEndianCrc32 as W,uint8ArrayToHexString as R}from"@dfinity/utils";function D(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function U(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function k(e,t){D(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var N=e=>e instanceof Uint8Array;var w=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),h=(e,t)=>e<<32-t|e>>>t,T=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!T)throw new Error("Non little-endian hardware is not supported");function P(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function E(e){if(typeof e=="string"&&(e=P(e)),!N(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var y=class{clone(){return this._cloneInto()}},M={}.toString;function L(e){let t=n=>e().update(E(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function V(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),s=Number(r&c),u=n?4:0,a=n?0:4;e.setUint32(t+u,i,n),e.setUint32(t+a,s,n)}var g=class extends y{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=w(this.buffer)}update(t){U(this);let{view:r,buffer:n,blockLen:o}=this;t=E(t);let c=t.length;for(let i=0;i<c;){let s=Math.min(o-this.pos,c-i);if(s===o){let u=w(t);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){U(this),k(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;V(n,o-8,BigInt(this.length*8),c),this.process(n,0);let s=w(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,p=this.get();if(a>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)s.setUint32(4*f,p[f],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:s}=this;return t.length=o,t.pos=s,t.finished=c,t.destroyed=i,o%r&&t.buffer.set(n),t}};var j=(e,t,r)=>e&t^~e&r,F=(e,t,r)=>e&t^e&r^t&r,$=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),x=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=new Uint32Array(64),m=class extends g{constructor(){super(64,32,8,!1),this.A=x[0]|0,this.B=x[1]|0,this.C=x[2]|0,this.D=x[3]|0,this.E=x[4]|0,this.F=x[5]|0,this.G=x[6]|0,this.H=x[7]|0}get(){let{A:t,B:r,C:n,D:o,E:c,F:i,G:s,H:u}=this;return[t,r,n,o,c,i,s,u]}set(t,r,n,o,c,i,s,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=s|0,this.H=u|0}process(t,r){for(let f=0;f<16;f++,r+=4)b[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let d=b[f-15],l=b[f-2],C=h(d,7)^h(d,18)^d>>>3,A=h(l,17)^h(l,19)^l>>>10;b[f]=A+b[f-7]+C+b[f-16]|0}let{A:n,B:o,C:c,D:i,E:s,F:u,G:a,H:p}=this;for(let f=0;f<64;f++){let d=h(s,6)^h(s,11)^h(s,25),l=p+d+j(s,u,a)+$[f]+b[f]|0,A=(h(n,2)^h(n,13)^h(n,22))+F(n,o,c)|0;p=a,a=u,u=s,s=i+l|0,i=c,c=o,o=n,n=l+A|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,s=s+this.E|0,u=u+this.F|0,a=a+this.G|0,p=p+this.H|0,this.set(n,o,c,i,s,u,a,p)}roundClean(){b.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},I=class extends m{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},Q=L(()=>new m),O=L(()=>new I);var S=class e{constructor(t){this.bytes=t}static fromHex(t){return new e(Uint8Array.from(Buffer.from(t,"hex")))}static fromPrincipal({principal:t,subAccount:r=B.ZERO}){let n=G(`
2
- account-id`),o=O.create();o.update(v([...n,...t.toUint8Array(),...r.toUint8Array()]));let c=o.digest(),i=W(c),s=new Uint8Array([...i,...c]);return new e(s)}async toProto(){let{AccountIdentifier:t}=await H(),r=new t;return r.setHash(this.bytes),r}toHex(){return R(this.bytes)}toUint8Array(){return this.bytes}toNumbers(){return Array.from(this.bytes)}toAccountIdentifierHash(){return{hash:this.toUint8Array()}}},B=class e{constructor(t){this.bytes=t}static fromBytes(t){return t.length!=32?Error("Subaccount length must be 32-bytes"):new e(t)}static fromPrincipal(t){let r=new Uint8Array(32).fill(0),n=t.toUint8Array();r[0]=n.length;for(let o=0;o<n.length;o++)r[1+o]=n[o];return new e(r)}static fromID(t){if(t<0||t>255)throw"Subaccount ID must be >= 0 and <= 255";let r=new Uint8Array(32).fill(0);return r[31]=t,new e(r)}static{this.ZERO=this.fromID(0)}toUint8Array(){return this.bytes}};export{Q as a,O as b,S as c,B as d};
3
- /*! Bundled license information:
4
-
5
- @noble/hashes/esm/utils.js:
6
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
7
- */
8
- //# sourceMappingURL=chunk-H5FXE6EH.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/account_identifier.ts", "../../../../node_modules/@noble/hashes/src/_assert.ts", "../../../../node_modules/@noble/hashes/src/utils.ts", "../../../../node_modules/@noble/hashes/src/_sha2.ts", "../../../../node_modules/@noble/hashes/src/sha256.ts"],
4
- "sourcesContent": ["import type { AccountIdentifier as AccountIdentifierPb } from \"@dfinity/nns-proto\";\nimport type { Principal } from \"@dfinity/principal\";\nimport {\n arrayOfNumberToUint8Array,\n asciiStringToByteArray,\n bigEndianCrc32,\n uint8ArrayToHexString,\n} from \"@dfinity/utils\";\nimport { sha224 } from \"@noble/hashes/sha256\";\nimport type { AccountIdentifier as AccountIdentifierCandid } from \"../candid/governance\";\nimport { importNnsProto } from \"./utils/proto.utils\";\n\nexport class AccountIdentifier {\n private constructor(private readonly bytes: Uint8Array) {}\n\n public static fromHex(hex: string): AccountIdentifier {\n return new AccountIdentifier(Uint8Array.from(Buffer.from(hex, \"hex\")));\n }\n\n public static fromPrincipal({\n principal,\n subAccount = SubAccount.ZERO,\n }: {\n principal: Principal;\n subAccount?: SubAccount;\n }): AccountIdentifier {\n // Hash (sha224) the principal, the subAccount and some padding\n const padding = asciiStringToByteArray(\"\\x0Aaccount-id\");\n\n const shaObj = sha224.create();\n shaObj.update(\n arrayOfNumberToUint8Array([\n ...padding,\n ...principal.toUint8Array(),\n ...subAccount.toUint8Array(),\n ]),\n );\n const hash = shaObj.digest();\n\n // Prepend the checksum of the hash and convert to a hex string\n const checksum = bigEndianCrc32(hash);\n const bytes = new Uint8Array([...checksum, ...hash]);\n return new AccountIdentifier(bytes);\n }\n\n /**\n * @returns An AccountIdentifier protobuf object.\n */\n public async toProto(): Promise<AccountIdentifierPb> {\n const { AccountIdentifier: AccountIdentifierConstructor } =\n await importNnsProto();\n const accountIdentifier = new AccountIdentifierConstructor();\n accountIdentifier.setHash(this.bytes);\n return accountIdentifier;\n }\n\n public toHex(): string {\n return uint8ArrayToHexString(this.bytes);\n }\n\n public toUint8Array(): Uint8Array {\n return this.bytes;\n }\n\n public toNumbers(): number[] {\n return Array.from(this.bytes);\n }\n\n public toAccountIdentifierHash(): AccountIdentifierCandid {\n return {\n hash: this.toUint8Array(),\n };\n }\n}\n\nexport class SubAccount {\n private constructor(private readonly bytes: Uint8Array) {}\n\n public static fromBytes(bytes: Uint8Array): SubAccount | Error {\n if (bytes.length != 32) {\n return Error(\"Subaccount length must be 32-bytes\");\n }\n\n return new SubAccount(bytes);\n }\n\n public static fromPrincipal(principal: Principal): SubAccount {\n const bytes = new Uint8Array(32).fill(0);\n\n const principalBytes = principal.toUint8Array();\n bytes[0] = principalBytes.length;\n\n for (let i = 0; i < principalBytes.length; i++) {\n bytes[1 + i] = principalBytes[i];\n }\n\n return new SubAccount(bytes);\n }\n\n public static fromID(id: number): SubAccount {\n if (id < 0 || id > 255) {\n throw \"Subaccount ID must be >= 0 and <= 255\";\n }\n\n const bytes: Uint8Array = new Uint8Array(32).fill(0);\n bytes[31] = id;\n return new SubAccount(bytes);\n }\n\n public static ZERO: SubAccount = this.fromID(0);\n\n public toUint8Array(): Uint8Array {\n return this.bytes;\n }\n}\n", "function number(n: number) {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error(`Wrong positive integer: ${n}`);\n}\n\nfunction bool(b: boolean) {\n if (typeof b !== 'boolean') throw new Error(`Expected boolean, not ${b}`);\n}\n\nfunction bytes(b: Uint8Array | undefined, ...lengths: number[]) {\n if (!(b instanceof Uint8Array)) throw new Error('Expected Uint8Array');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);\n}\n\ntype Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\nfunction hash(hash: Hash) {\n if (typeof hash !== 'function' || typeof hash.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(hash.outputLen);\n number(hash.blockLen);\n}\n\nfunction exists(instance: any, checkFinished = true) {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\nfunction output(out: any, instance: any) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nexport { number, bool, bytes, hash, exists, output };\n\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n", "/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated, we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\nconst u8a = (a: any): a is Uint8Array => a instanceof Uint8Array;\n// Cast array to different type\nexport const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr: TypedArray) =>\n new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n\n// Cast array to view\nexport const createView = (arr: TypedArray) =>\n new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word: number, shift: number) => (word << (32 - shift)) | (word >>> shift);\n\n// big-endian hardware is rare. Just in case someone still decides to run hashes:\n// early-throw an error because we don't support BE yet.\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\nif (!isLE) throw new Error('Non little-endian hardware is not supported');\n\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n if (!u8a(bytes)) throw new Error('Uint8Array expected');\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const len = hex.length;\n if (len % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + len);\n const array = new Uint8Array(len / 2);\n for (let i = 0; i < array.length; i++) {\n const j = i * 2;\n const hexByte = hex.slice(j, j + 2);\n const byte = Number.parseInt(hexByte, 16);\n if (Number.isNaN(byte) || byte < 0) throw new Error('Invalid byte sequence');\n array[i] = byte;\n }\n return array;\n}\n\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => {};\n\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters: number, tick: number, cb: (i: number) => void) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n if (!u8a(data)) throw new Error(`expected Uint8Array, got ${typeof data}`);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));\n let pad = 0; // walk through each item, ensure they have proper type\n arrays.forEach((a) => {\n if (!u8a(a)) throw new Error('Uint8Array expected');\n r.set(a, pad);\n pad += a.length;\n });\n return r;\n}\n\n// For runtime check if class implements interface\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\nconst toStr = {}.toString;\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\nexport type CHash = ReturnType<typeof wrapConstructor>;\n\nexport function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>) {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "import { exists, output } from './_assert.js';\nimport { Hash, createView, Input, toBytes } from './utils.js';\n\n// Polyfill for Safari 14\nfunction setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n// Base SHA2 class (RFC 6234)\nexport abstract class SHA2<T extends SHA2<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(\n readonly blockLen: number,\n public outputLen: number,\n readonly padOffset: number,\n readonly isLE: boolean\n ) {\n super();\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\n", "import { SHA2 } from './_sha2.js';\nimport { rotr, wrapConstructor } from './utils.js';\n\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n\n// Choice: a ? b : c\nconst Chi = (a: number, b: number, c: number) => (a & b) ^ (~a & c);\n// Majority function, true if any two inpust is true\nconst Maj = (a: number, b: number, c: number) => (a & b) ^ (a & c) ^ (b & c);\n\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n// prettier-ignore\nconst IV = /* @__PURE__ */new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends SHA2<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = IV[0] | 0;\n B = IV[1] | 0;\n C = IV[2] | 0;\n D = IV[3] | 0;\n E = IV[4] | 0;\n F = IV[5] | 0;\n G = IV[6] | 0;\n H = IV[7] | 0;\n\n constructor() {\n super(64, 32, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n A = 0xc1059ed8 | 0;\n B = 0x367cd507 | 0;\n C = 0x3070dd17 | 0;\n D = 0xf70e5939 | 0;\n E = 0xffc00b31 | 0;\n F = 0x68581511 | 0;\n G = 0x64f98fa7 | 0;\n H = 0xbefa4fa4 | 0;\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n"],
5
- "mappings": "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",
6
- "names": ["arrayOfNumberToUint8Array", "asciiStringToByteArray", "bigEndianCrc32", "uint8ArrayToHexString", "bytes", "b", "lengths", "exists", "instance", "checkFinished", "output", "out", "bytes", "min", "u8a", "a", "createView", "arr", "rotr", "word", "shift", "isLE", "utf8ToBytes", "str", "toBytes", "data", "u8a", "Hash", "toStr", "wrapConstructor", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "h", "l", "SHA2", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "exists", "buffer", "toBytes", "len", "pos", "take", "dataView", "out", "output", "i", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "Chi", "a", "b", "c", "Maj", "SHA256_K", "IV", "SHA256_W", "SHA256", "SHA2", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "i", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "T2", "SHA224", "sha256", "wrapConstructor", "sha224", "AccountIdentifier", "_AccountIdentifier", "bytes", "hex", "principal", "subAccount", "SubAccount", "padding", "asciiStringToByteArray", "shaObj", "sha224", "arrayOfNumberToUint8Array", "hash", "checksum", "bigEndianCrc32", "AccountIdentifierConstructor", "importNnsProto", "accountIdentifier", "uint8ArrayToHexString", "_SubAccount", "principalBytes", "i", "id"]
7
- }
@@ -1,2 +0,0 @@
1
- var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
2
- //# sourceMappingURL=chunk-IS3C7V4B.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import{a as n}from"./chunk-2MZ7K2GY.js";import{ICPToken as i,convertStringToE8s as e}from"@dfinity/utils";var s=class o{constructor(r,t){this.e8s=r;this.token=t}static fromE8s(r){return new o(r,i)}static fromString(r){let t=e(r);return typeof t=="bigint"?new o(t,i):t}toE8s(){return this.e8s}async toProto(){let{ICPTs:r}=await n(),t=new r;return t.setE8s(this.e8s.toString()),t}};export{s as a};
2
- //# sourceMappingURL=chunk-JCUF5KWH.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/icp.ts"],
4
- "sourcesContent": ["import type { ICPTs } from \"@dfinity/nns-proto\";\nimport {\n ICPToken,\n convertStringToE8s,\n type FromStringToTokenError,\n type Token,\n} from \"@dfinity/utils\";\nimport { importNnsProto } from \"./utils/proto.utils\";\n\n/**\n * We don't extend to keep `fromE8s` and `fromString` as backwards compatible.\n * @deprecated\n */\nexport class ICP {\n private constructor(\n private e8s: bigint,\n public token: Token,\n ) {}\n\n public static fromE8s(amount: bigint): ICP {\n return new ICP(amount, ICPToken);\n }\n\n /**\n * Initialize from a string. Accepted formats:\n *\n * 1234567.8901\n * 1'234'567.8901\n * 1,234,567.8901\n */\n public static fromString(amount: string): ICP | FromStringToTokenError {\n const e8s = convertStringToE8s(amount);\n if (typeof e8s === \"bigint\") {\n return new ICP(e8s, ICPToken);\n }\n return e8s;\n }\n\n public toE8s(): bigint {\n return this.e8s;\n }\n\n public async toProto(): Promise<ICPTs> {\n const { ICPTs: ICPTsConstructor } = await importNnsProto();\n\n const proto = new ICPTsConstructor();\n proto.setE8s(this.e8s.toString());\n return proto;\n }\n}\n"],
5
- "mappings": "wCACA,OACE,YAAAA,EACA,sBAAAC,MAGK,iBAOA,IAAMC,EAAN,MAAMC,CAAI,CACP,YACEC,EACDC,EACP,CAFQ,SAAAD,EACD,WAAAC,CACN,CAEH,OAAc,QAAQC,EAAqB,CACzC,OAAO,IAAIH,EAAIG,EAAQC,CAAQ,CACjC,CASA,OAAc,WAAWD,EAA8C,CACrE,IAAMF,EAAMI,EAAmBF,CAAM,EACrC,OAAI,OAAOF,GAAQ,SACV,IAAID,EAAIC,EAAKG,CAAQ,EAEvBH,CACT,CAEO,OAAgB,CACrB,OAAO,KAAK,GACd,CAEA,MAAa,SAA0B,CACrC,GAAM,CAAE,MAAOK,CAAiB,EAAI,MAAMC,EAAe,EAEnDC,EAAQ,IAAIF,EAClB,OAAAE,EAAM,OAAO,KAAK,IAAI,SAAS,CAAC,EACzBA,CACT,CACF",
6
- "names": ["ICPToken", "convertStringToE8s", "ICP", "_ICP", "e8s", "token", "amount", "ICPToken", "convertStringToE8s", "ICPTsConstructor", "importNnsProto", "proto"]
7
- }
@@ -1,20 +0,0 @@
1
- import{a as Mn,b as An,c as te,d as Pe}from"./chunk-H5FXE6EH.js";import{b as on}from"./chunk-DGJWOAUC.js";import{a as S,b as Ce}from"./chunk-2MZ7K2GY.js";import{a as Vn}from"./chunk-ZMUQLPST.js";import{a as Se,b as Pn}from"./chunk-IS3C7V4B.js";var Bn=Se(Me=>{"use strict";Me.byteLength=ir;Me.toByteArray=cr;Me.fromByteArray=pr;var A=[],T=[],ar=typeof Uint8Array<"u"?Uint8Array:Array,rn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(L=0,En=rn.length;L<En;++L)A[L]=rn[L],T[rn.charCodeAt(L)]=L;var L,En;T["-".charCodeAt(0)]=62;T["_".charCodeAt(0)]=63;function Fn(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var o=n===t?0:4-n%4;return[n,o]}function ir(e){var t=Fn(e),n=t[0],o=t[1];return(n+o)*3/4-o}function sr(e,t,n){return(t+n)*3/4-n}function cr(e){var t,n=Fn(e),o=n[0],r=n[1],a=new ar(sr(e,o,r)),i=0,c=r>0?o-4:o,d;for(d=0;d<c;d+=4)t=T[e.charCodeAt(d)]<<18|T[e.charCodeAt(d+1)]<<12|T[e.charCodeAt(d+2)]<<6|T[e.charCodeAt(d+3)],a[i++]=t>>16&255,a[i++]=t>>8&255,a[i++]=t&255;return r===2&&(t=T[e.charCodeAt(d)]<<2|T[e.charCodeAt(d+1)]>>4,a[i++]=t&255),r===1&&(t=T[e.charCodeAt(d)]<<10|T[e.charCodeAt(d+1)]<<4|T[e.charCodeAt(d+2)]>>2,a[i++]=t>>8&255,a[i++]=t&255),a}function ur(e){return A[e>>18&63]+A[e>>12&63]+A[e>>6&63]+A[e&63]}function dr(e,t,n){for(var o,r=[],a=t;a<n;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),r.push(ur(o));return r.join("")}function pr(e){for(var t,n=e.length,o=n%3,r=[],a=16383,i=0,c=n-o;i<c;i+=a)r.push(dr(e,i,i+a>c?c:i+a));return o===1?(t=e[n-1],r.push(A[t>>2]+A[t<<4&63]+"==")):o===2&&(t=(e[n-2]<<8)+e[n-1],r.push(A[t>>10]+A[t>>4&63]+A[t<<2&63]+"=")),r.join("")}});var qn=Se(an=>{an.read=function(e,t,n,o,r){var a,i,c=r*8-o-1,d=(1<<c)-1,m=d>>1,f=-7,_=n?r-1:0,y=n?-1:1,g=e[t+_];for(_+=y,a=g&(1<<-f)-1,g>>=-f,f+=c;f>0;a=a*256+e[t+_],_+=y,f-=8);for(i=a&(1<<-f)-1,a>>=-f,f+=o;f>0;i=i*256+e[t+_],_+=y,f-=8);if(a===0)a=1-m;else{if(a===d)return i?NaN:(g?-1:1)*(1/0);i=i+Math.pow(2,o),a=a-m}return(g?-1:1)*i*Math.pow(2,a-o)};an.write=function(e,t,n,o,r,a){var i,c,d,m=a*8-r-1,f=(1<<m)-1,_=f>>1,y=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=o?0:a-1,k=o?1:-1,l=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,i=f):(i=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-i))<1&&(i--,d*=2),i+_>=1?t+=y/d:t+=y*Math.pow(2,1-_),t*d>=2&&(i++,d/=2),i+_>=f?(c=0,i=f):i+_>=1?(c=(t*d-1)*Math.pow(2,r),i=i+_):(c=t*Math.pow(2,_-1)*Math.pow(2,r),i=0));r>=8;e[n+g]=c&255,g+=k,c/=256,r-=8);for(i=i<<r|c,m+=r;m>0;e[n+g]=i&255,g+=k,i/=256,m-=8);e[n+g-k]|=l*128}});var mn=Se(oe=>{"use strict";var sn=Bn(),ne=qn(),Un=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;oe.Buffer=s;oe.SlowBuffer=Nr;oe.INSPECT_MAX_BYTES=50;var Ae=2147483647;oe.kMaxLength=Ae;s.TYPED_ARRAY_SUPPORT=lr();!s.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 lr(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function G(e){if(e>Ae)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return pn(e)}return Wn(e,t,n)}s.poolSize=8192;function Wn(e,t,n){if(typeof e=="string")return mr(e,t);if(ArrayBuffer.isView(e))return fr(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(V(e,ArrayBuffer)||e&&V(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(V(e,SharedArrayBuffer)||e&&V(e.buffer,SharedArrayBuffer)))return un(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return s.from(o,t,n);var r=wr(e);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,t,n){return Wn(e,t,n)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function Gn(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 _r(e,t,n){return Gn(e),e<=0?G(e):t!==void 0?typeof n=="string"?G(e).fill(t,n):G(e).fill(t):G(e)}s.alloc=function(e,t,n){return _r(e,t,n)};function pn(e){return Gn(e),G(e<0?0:ln(e)|0)}s.allocUnsafe=function(e){return pn(e)};s.allocUnsafeSlow=function(e){return pn(e)};function mr(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=jn(e,t)|0,o=G(n),r=o.write(e,t);return r!==n&&(o=o.slice(0,r)),o}function cn(e){for(var t=e.length<0?0:ln(e.length)|0,n=G(t),o=0;o<t;o+=1)n[o]=e[o]&255;return n}function fr(e){if(V(e,Uint8Array)){var t=new Uint8Array(e);return un(t.buffer,t.byteOffset,t.byteLength)}return cn(e)}function un(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,s.prototype),o}function wr(e){if(s.isBuffer(e)){var t=ln(e.length)|0,n=G(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||_n(e.length)?G(0):cn(e);if(e.type==="Buffer"&&Array.isArray(e.data))return cn(e.data)}function ln(e){if(e>=Ae)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ae.toString(16)+" bytes");return e|0}function Nr(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype};s.compare=function(t,n){if(V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),V(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(t)||!s.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;for(var o=t.length,r=n.length,a=0,i=Math.min(o,r);a<i;++a)if(t[a]!==n[a]){o=t[a],r=n[a];break}return o<r?-1:r<o?1:0};s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);var o;if(n===void 0)for(n=0,o=0;o<t.length;++o)n+=t[o].length;var r=s.allocUnsafe(n),a=0;for(o=0;o<t.length;++o){var i=t[o];if(V(i,Uint8Array))a+i.length>r.length?s.from(i).copy(r,a):Uint8Array.prototype.set.call(r,i,a);else if(s.isBuffer(i))i.copy(r,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=i.length}return r};function jn(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||V(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 n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return dn(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Qn(e).length;default:if(r)return o?-1:dn(e).length;t=(""+t).toLowerCase(),r=!0}}s.byteLength=jn;function yr(e,t,n){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Tr(this,t,n);case"utf8":case"utf-8":return Jn(this,t,n);case"ascii":return xr(this,t,n);case"latin1":case"binary":return kr(this,t,n);case"base64":return Sr(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Cr(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}s.prototype._isBuffer=!0;function ee(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}s.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)ee(this,n,n+1);return this};s.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)ee(this,n,n+3),ee(this,n+1,n+2);return this};s.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)ee(this,n,n+7),ee(this,n+1,n+6),ee(this,n+2,n+5),ee(this,n+3,n+4);return this};s.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?Jn(this,0,t):yr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0};s.prototype.inspect=function(){var t="",n=oe.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"};Un&&(s.prototype[Un]=s.prototype.inspect);s.prototype.compare=function(t,n,o,r,a){if(V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),o===void 0&&(o=t?t.length:0),r===void 0&&(r=0),a===void 0&&(a=this.length),n<0||o>t.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&n>=o)return 0;if(r>=a)return-1;if(n>=o)return 1;if(n>>>=0,o>>>=0,r>>>=0,a>>>=0,this===t)return 0;for(var i=a-r,c=o-n,d=Math.min(i,c),m=this.slice(r,a),f=t.slice(n,o),_=0;_<d;++_)if(m[_]!==f[_]){i=m[_],c=f[_];break}return i<c?-1:c<i?1:0};function zn(e,t,n,o,r){if(e.length===0)return-1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,_n(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0)if(r)n=0;else return-1;if(typeof t=="string"&&(t=s.from(t,o)),s.isBuffer(t))return t.length===0?-1:Kn(e,t,n,o,r);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Kn(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function Kn(e,t,n,o,r){var a=1,i=e.length,c=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,i/=2,c/=2,n/=2}function d(g,k){return a===1?g[k]:g.readUInt16BE(k*a)}var m;if(r){var f=-1;for(m=n;m<i;m++)if(d(e,m)===d(t,f===-1?0:m-f)){if(f===-1&&(f=m),m-f+1===c)return f*a}else f!==-1&&(m-=m-f),f=-1}else for(n+c>i&&(n=i-c),m=n;m>=0;m--){for(var _=!0,y=0;y<c;y++)if(d(e,m+y)!==d(t,y)){_=!1;break}if(_)return m}return-1}s.prototype.includes=function(t,n,o){return this.indexOf(t,n,o)!==-1};s.prototype.indexOf=function(t,n,o){return zn(this,t,n,o,!0)};s.prototype.lastIndexOf=function(t,n,o){return zn(this,t,n,o,!1)};function gr(e,t,n,o){n=Number(n)||0;var r=e.length-n;o?(o=Number(o),o>r&&(o=r)):o=r;var a=t.length;o>a/2&&(o=a/2);for(var i=0;i<o;++i){var c=parseInt(t.substr(i*2,2),16);if(_n(c))return i;e[n+i]=c}return i}function Rr(e,t,n,o){return Ve(dn(t,e.length-n),e,n,o)}function vr(e,t,n,o){return Ve(Ar(t),e,n,o)}function hr(e,t,n,o){return Ve(Qn(t),e,n,o)}function Or(e,t,n,o){return Ve(Vr(t,e.length-n),e,n,o)}s.prototype.write=function(t,n,o,r){if(n===void 0)r="utf8",o=this.length,n=0;else if(o===void 0&&typeof n=="string")r=n,o=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(o)?(o=o>>>0,r===void 0&&(r="utf8")):(r=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-n;if((o===void 0||o>a)&&(o=a),t.length>0&&(o<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return gr(this,t,n,o);case"utf8":case"utf-8":return Rr(this,t,n,o);case"ascii":case"latin1":case"binary":return vr(this,t,n,o);case"base64":return hr(this,t,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Or(this,t,n,o);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Sr(e,t,n){return t===0&&n===e.length?sn.fromByteArray(e):sn.fromByteArray(e.slice(t,n))}function Jn(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r<n;){var a=e[r],i=null,c=a>239?4:a>223?3:a>191?2:1;if(r+c<=n){var d,m,f,_;switch(c){case 1:a<128&&(i=a);break;case 2:d=e[r+1],(d&192)===128&&(_=(a&31)<<6|d&63,_>127&&(i=_));break;case 3:d=e[r+1],m=e[r+2],(d&192)===128&&(m&192)===128&&(_=(a&15)<<12|(d&63)<<6|m&63,_>2047&&(_<55296||_>57343)&&(i=_));break;case 4:d=e[r+1],m=e[r+2],f=e[r+3],(d&192)===128&&(m&192)===128&&(f&192)===128&&(_=(a&15)<<18|(d&63)<<12|(m&63)<<6|f&63,_>65535&&_<1114112&&(i=_))}}i===null?(i=65533,c=1):i>65535&&(i-=65536,o.push(i>>>10&1023|55296),i=56320|i&1023),o.push(i),r+=c}return br(o)}var Hn=4096;function br(e){var t=e.length;if(t<=Hn)return String.fromCharCode.apply(String,e);for(var n="",o=0;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=Hn));return n}function xr(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(e[r]&127);return o}function kr(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(e[r]);return o}function Tr(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var r="",a=t;a<n;++a)r+=Er[e[a]];return r}function Cr(e,t,n){for(var o=e.slice(t,n),r="",a=0;a<o.length-1;a+=2)r+=String.fromCharCode(o[a]+o[a+1]*256);return r}s.prototype.slice=function(t,n){var o=this.length;t=~~t,n=n===void 0?o:~~n,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),n<0?(n+=o,n<0&&(n=0)):n>o&&(n=o),n<t&&(n=t);var r=this.subarray(t,n);return Object.setPrototypeOf(r,s.prototype),r};function R(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,n,o){t=t>>>0,n=n>>>0,o||R(t,n,this.length);for(var r=this[t],a=1,i=0;++i<n&&(a*=256);)r+=this[t+i]*a;return r};s.prototype.readUintBE=s.prototype.readUIntBE=function(t,n,o){t=t>>>0,n=n>>>0,o||R(t,n,this.length);for(var r=this[t+--n],a=1;n>0&&(a*=256);)r+=this[t+--n]*a;return r};s.prototype.readUint8=s.prototype.readUInt8=function(t,n){return t=t>>>0,n||R(t,1,this.length),this[t]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||R(t,2,this.length),this[t]|this[t+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||R(t,2,this.length),this[t]<<8|this[t+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};s.prototype.readIntLE=function(t,n,o){t=t>>>0,n=n>>>0,o||R(t,n,this.length);for(var r=this[t],a=1,i=0;++i<n&&(a*=256);)r+=this[t+i]*a;return a*=128,r>=a&&(r-=Math.pow(2,8*n)),r};s.prototype.readIntBE=function(t,n,o){t=t>>>0,n=n>>>0,o||R(t,n,this.length);for(var r=n,a=1,i=this[t+--r];r>0&&(a*=256);)i+=this[t+--r]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*n)),i};s.prototype.readInt8=function(t,n){return t=t>>>0,n||R(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};s.prototype.readInt16LE=function(t,n){t=t>>>0,n||R(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o};s.prototype.readInt16BE=function(t,n){t=t>>>0,n||R(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o};s.prototype.readInt32LE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};s.prototype.readInt32BE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};s.prototype.readFloatLE=function(t,n){return t=t>>>0,n||R(t,4,this.length),ne.read(this,t,!0,23,4)};s.prototype.readFloatBE=function(t,n){return t=t>>>0,n||R(t,4,this.length),ne.read(this,t,!1,23,4)};s.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||R(t,8,this.length),ne.read(this,t,!0,52,8)};s.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||R(t,8,this.length),ne.read(this,t,!1,52,8)};function b(e,t,n,o,r,a){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<a)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,n,o,r){if(t=+t,n=n>>>0,o=o>>>0,!r){var a=Math.pow(2,8*o)-1;b(this,t,n,o,a,0)}var i=1,c=0;for(this[n]=t&255;++c<o&&(i*=256);)this[n+c]=t/i&255;return n+o};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,n,o,r){if(t=+t,n=n>>>0,o=o>>>0,!r){var a=Math.pow(2,8*o)-1;b(this,t,n,o,a,0)}var i=o-1,c=1;for(this[n+i]=t&255;--i>=0&&(c*=256);)this[n+i]=t/c&255;return n+o};s.prototype.writeUint8=s.prototype.writeUInt8=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,1,255,0),this[n]=t&255,n+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};s.prototype.writeIntLE=function(t,n,o,r){if(t=+t,n=n>>>0,!r){var a=Math.pow(2,8*o-1);b(this,t,n,o,a-1,-a)}var i=0,c=1,d=0;for(this[n]=t&255;++i<o&&(c*=256);)t<0&&d===0&&this[n+i-1]!==0&&(d=1),this[n+i]=(t/c>>0)-d&255;return n+o};s.prototype.writeIntBE=function(t,n,o,r){if(t=+t,n=n>>>0,!r){var a=Math.pow(2,8*o-1);b(this,t,n,o,a-1,-a)}var i=o-1,c=1,d=0;for(this[n+i]=t&255;--i>=0&&(c*=256);)t<0&&d===0&&this[n+i+1]!==0&&(d=1),this[n+i]=(t/c>>0)-d&255;return n+o};s.prototype.writeInt8=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1};s.prototype.writeInt16LE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2};s.prototype.writeInt16BE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2};s.prototype.writeInt32LE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4};s.prototype.writeInt32BE=function(t,n,o){return t=+t,n=n>>>0,o||b(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function $n(e,t,n,o,r,a){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Xn(e,t,n,o,r){return t=+t,n=n>>>0,r||$n(e,t,n,4,34028234663852886e22,-34028234663852886e22),ne.write(e,t,n,o,23,4),n+4}s.prototype.writeFloatLE=function(t,n,o){return Xn(this,t,n,!0,o)};s.prototype.writeFloatBE=function(t,n,o){return Xn(this,t,n,!1,o)};function Yn(e,t,n,o,r){return t=+t,n=n>>>0,r||$n(e,t,n,8,17976931348623157e292,-17976931348623157e292),ne.write(e,t,n,o,52,8),n+8}s.prototype.writeDoubleLE=function(t,n,o){return Yn(this,t,n,!0,o)};s.prototype.writeDoubleBE=function(t,n,o){return Yn(this,t,n,!1,o)};s.prototype.copy=function(t,n,o,r){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!r&&r!==0&&(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r<o&&(r=o),r===o||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-o&&(r=t.length-n+o);var a=r-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,o,r):Uint8Array.prototype.set.call(t,this.subarray(o,r),n),a};s.prototype.fill=function(t,n,o,r){if(typeof t=="string"){if(typeof n=="string"?(r=n,n=0,o=this.length):typeof o=="string"&&(r=o,o=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(t.length===1){var a=t.charCodeAt(0);(r==="utf8"&&a<128||r==="latin1")&&(t=a)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(n<0||this.length<n||this.length<o)throw new RangeError("Out of range index");if(o<=n)return this;n=n>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var i;if(typeof t=="number")for(i=n;i<o;++i)this[i]=t;else{var c=s.isBuffer(t)?t:s.from(t,r),d=c.length;if(d===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<o-n;++i)this[i+n]=c[i%d]}return this};var Pr=/[^+/0-9A-Za-z-_]/g;function Mr(e){if(e=e.split("=")[0],e=e.trim().replace(Pr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function dn(e,t){t=t||1/0;for(var n,o=e.length,r=null,a=[],i=0;i<o;++i){if(n=e.charCodeAt(i),n>55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(i+1===o){(t-=3)>-1&&a.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(t-=3)>-1&&a.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return a}function Ar(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Vr(e,t){for(var n,o,r,a=[],i=0;i<e.length&&!((t-=2)<0);++i)n=e.charCodeAt(i),o=n>>8,r=n%256,a.push(r),a.push(o);return a}function Qn(e){return sn.toByteArray(Mr(e))}function Ve(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function V(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function _n(e){return e!==e}var Er=function(){for(var e="0123456789abcdef",t=new Array(256),n=0;n<16;++n)for(var o=n*16,r=0;r<16;++r)t[o+r]=e[n]+e[r];return t}()});var Dn=Se((fn,In)=>{var Ee=mn(),j=Ee.Buffer;function Zn(e,t){for(var n in e)t[n]=e[n]}j.from&&j.alloc&&j.allocUnsafe&&j.allocUnsafeSlow?In.exports=Ee:(Zn(Ee,fn),fn.Buffer=re);function re(e,t,n){return j(e,t,n)}Zn(j,re);re.from=function(e,t,n){if(typeof e=="number")throw new TypeError("Argument must not be a number");return j(e,t,n)};re.alloc=function(e,t,n){if(typeof e!="number")throw new TypeError("Argument must be a number");var o=j(e);return t!==void 0?typeof n=="string"?o.fill(t,n):o.fill(t):o.fill(0),o};re.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return j(e)};re.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ee.SlowBuffer(e)}});var Ln=Se((Za,Nn)=>{"use strict";var wn=65536,Fr=4294967295;function Br(){throw new Error(`Secure random number generation is not supported by this browser.
2
- Use Chrome, Firefox or Internet Explorer 11`)}var qr=Dn().Buffer,Fe=window.crypto||window.msCrypto;Fe&&Fe.getRandomValues?Nn.exports=Ur:Nn.exports=Br;function Ur(e,t){if(e>Fr)throw new RangeError("requested too many random bytes");var n=qr.allocUnsafe(e);if(e>0)if(e>wn)for(var o=0;o<e;o+=wn)Fe.getRandomValues(n.slice(o,o+wn));else Fe.getRandomValues(n);return typeof t=="function"?process.nextTick(function(){t(null,n)}):n}});import{arrayOfNumberToUint8Array as za,asciiStringToByteArray as Ja,assertPercentageNumber as kn,createServices as $a,fromNullable as x,isNullish as Tn,nonNullish as M,uint8ArrayToBigInt as nr}from"@dfinity/utils";var Cn=Pn(Ln());var eo=({IDL:e})=>{let t=e.Rec(),n=e.Record({id:e.Nat64}),o=e.Record({followees:e.Vec(n)}),r=e.Record({hash:e.Vec(e.Nat8)}),a=e.Record({id:e.Opt(e.Principal),reward_account:e.Opt(r)}),i=e.Record({dissolve_delay_seconds:e.Nat64}),c=e.Record({to_account:e.Opt(r)}),d=e.Variant({RewardToNeuron:i,RewardToAccount:c}),m=e.Record({node_provider:e.Opt(a),reward_mode:e.Opt(d),amount_e8s:e.Nat64}),f=e.Record({timestamp:e.Nat64,rewards:e.Vec(m)}),_=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)),total_supply_icp:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,community_fund_total_maturity_e8s_equivalent:e.Nat64,total_staked_e8s:e.Nat64,not_dissolving_neurons_count:e.Nat64,total_locked_e8s: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)),community_fund_total_staked_e8s:e.Nat64,timestamp_seconds:e.Nat64}),y=e.Record({neuron_minimum_stake_e8s:e.Nat64,max_proposals_to_keep_per_topic:e.Nat32,neuron_management_fee_per_proposal_e8s:e.Nat64,reject_cost_e8s:e.Nat64,transaction_fee_e8s:e.Nat64,neuron_spawn_dissolve_delay_seconds:e.Nat64,minimum_icp_xdr_rate:e.Nat64,maximum_node_provider_rewards_e8s:e.Nat64}),g=e.Record({rounds_since_last_distribution:e.Opt(e.Nat64),day_after_genesis:e.Nat64,actual_timestamp_seconds:e.Nat64,total_available_e8s_equivalent:e.Nat64,latest_round_available_e8s_equivalent:e.Opt(e.Nat64),distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(n)}),k=e.Record({to_subaccount:e.Vec(e.Nat8),neuron_stake_e8s:e.Nat64,from:e.Opt(e.Principal),memo:e.Nat64,from_subaccount:e.Vec(e.Nat8),transfer_timestamp:e.Nat64,block_height:e.Nat64}),l=e.Record({error_message:e.Text,error_type:e.Int32}),Ge=e.Record({nns_neuron_id:e.Nat64,amount_icp_e8s:e.Nat64}),je=e.Record({hotkey_principal:e.Text,cf_neurons:e.Vec(Ge)}),ie=e.Record({vote:e.Int32,voting_power:e.Nat64}),ze=e.Record({status:e.Opt(e.Int32),freezing_threshold:e.Opt(e.Nat64),controllers:e.Vec(e.Principal),memory_size:e.Opt(e.Nat64),cycles:e.Opt(e.Nat64),idle_cycles_burned_per_day:e.Opt(e.Nat64),module_hash:e.Vec(e.Nat8)}),O=e.Record({status:e.Opt(ze),canister_id:e.Opt(e.Principal)}),Je=e.Record({ledger_index_canister_summary:e.Opt(O),fallback_controller_principal_ids:e.Vec(e.Principal),ledger_archive_canister_summaries:e.Vec(O),ledger_canister_summary:e.Opt(O),swap_canister_summary:e.Opt(O),governance_canister_summary:e.Opt(O),root_canister_summary:e.Opt(O),dapp_canister_summaries:e.Vec(O)}),se=e.Record({swap_background_information:e.Opt(Je)}),ce=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),Y=e.Record({name:e.Text,description:e.Opt(e.Text)}),ue=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(Y)}),$e=e.Record({percentage_to_spawn:e.Opt(e.Nat32),new_controller:e.Opt(e.Principal),nonce:e.Opt(e.Nat64)}),de=e.Record({amount_e8s:e.Nat64}),Xe=e.Record({topic:e.Int32,followees:e.Vec(n)}),pe=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),Ye=e.Variant({NeuronIdOrSubaccount:e.Record({}),MemoAndController:pe,Memo:e.Nat64}),le=e.Record({by:e.Opt(Ye)}),Qe=e.Record({hot_key_to_remove:e.Opt(e.Principal)}),Ze=e.Record({new_hot_key:e.Opt(e.Principal)}),Ie=e.Record({requested_setting_for_auto_stake_maturity:e.Bool}),De=e.Record({additional_dissolve_delay_seconds:e.Nat32}),Le=e.Record({dissolve_timestamp_seconds:e.Nat64}),et=e.Variant({RemoveHotKey:Qe,AddHotKey:Ze,ChangeAutoStakeMaturity:Ie,StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:De,JoinCommunityFund:e.Record({}),LeaveCommunityFund:e.Record({}),SetDissolveTimestamp:Le}),_e=e.Record({operation:e.Opt(et)}),tt=e.Record({vote:e.Int32,proposal:e.Opt(n)}),u=e.Record({source_neuron_id:e.Opt(n)}),me=e.Record({dissolve_delay_seconds:e.Nat64,kyc_verified:e.Bool,amount_e8s:e.Nat64,new_controller:e.Opt(e.Principal),nonce:e.Nat64}),nt=e.Record({percentage_to_stake:e.Opt(e.Nat32)}),fe=e.Record({percentage_to_merge:e.Nat32}),ot=e.Record({e8s:e.Nat64}),we=e.Record({to_account:e.Opt(r),amount:e.Opt(ot)}),rt=e.Variant({Spawn:$e,Split:de,Follow:Xe,ClaimOrRefresh:le,Configure:_e,RegisterVote:tt,Merge:u,DisburseToNeuron:me,MakeProposal:t,StakeMaturity:nt,MergeMaturity:fe,Disburse:we}),Q=e.Variant({Subaccount:e.Vec(e.Nat8),NeuronId:n}),Z=e.Record({id:e.Opt(n),command:e.Opt(rt),neuron_id_or_subaccount:e.Opt(Q)}),K=e.Record({basis_points:e.Opt(e.Nat64)}),w=e.Record({seconds:e.Opt(e.Nat64)}),N=e.Record({e8s:e.Opt(e.Nat64)}),at=e.Record({reward_rate_transition_duration:e.Opt(w),initial_reward_rate:e.Opt(K),final_reward_rate:e.Opt(K)}),it=e.Record({neuron_maximum_dissolve_delay_bonus:e.Opt(K),neuron_maximum_age_for_age_bonus:e.Opt(w),neuron_maximum_dissolve_delay:e.Opt(w),neuron_minimum_dissolve_delay_to_vote:e.Opt(w),neuron_maximum_age_bonus:e.Opt(K),neuron_minimum_stake:e.Opt(N),proposal_wait_for_quiet_deadline_increase:e.Opt(w),proposal_initial_voting_period:e.Opt(w),proposal_rejection_fee:e.Opt(N),voting_reward_parameters:e.Opt(at)}),Ne=e.Record({base64_encoding:e.Opt(e.Text)}),st=e.Record({transaction_fee:e.Opt(N),token_symbol:e.Opt(e.Text),token_logo:e.Opt(Ne),token_name:e.Opt(e.Text)}),ct=e.Record({id:e.Opt(e.Principal)}),ut=e.Record({dissolve_delay_interval:e.Opt(w),count:e.Opt(e.Nat64)}),dt=e.Record({seconds_after_utc_midnight:e.Opt(e.Nat64)}),pt=e.Record({iso_codes:e.Vec(e.Text)}),lt=e.Record({minimum_participants:e.Opt(e.Nat64),duration:e.Opt(w),neuron_basket_construction_parameters:e.Opt(ut),confirmation_text:e.Opt(e.Text),maximum_participant_icp:e.Opt(N),minimum_icp:e.Opt(N),minimum_participant_icp:e.Opt(N),start_time:e.Opt(dt),maximum_icp:e.Opt(N),neurons_fund_investment_icp:e.Opt(N),restricted_countries:e.Opt(pt)}),ye=e.Record({total:e.Opt(N)}),_t=e.Record({controller:e.Opt(e.Principal),dissolve_delay:e.Opt(w),memo:e.Opt(e.Nat64),vesting_period:e.Opt(w),stake:e.Opt(N)}),mt=e.Record({developer_neurons:e.Vec(_t)}),ft=e.Record({treasury_distribution:e.Opt(ye),developer_distribution:e.Opt(mt),swap_distribution:e.Opt(ye)}),wt=e.Record({url:e.Opt(e.Text),governance_parameters:e.Opt(it),fallback_controller_principal_ids:e.Vec(e.Principal),logo:e.Opt(Ne),name:e.Opt(e.Text),ledger_parameters:e.Opt(st),description:e.Opt(e.Text),dapp_canisters:e.Vec(ct),swap_parameters:e.Opt(lt),initial_token_distribution:e.Opt(ft)}),Nt=e.Record({nns_function:e.Int32,payload:e.Vec(e.Nat8)}),yt=e.Record({dissolve_delay_interval_seconds:e.Nat64,count:e.Nat64}),gt=e.Record({min_participant_icp_e8s:e.Nat64,neuron_basket_construction_parameters:e.Opt(yt),max_icp_e8s:e.Nat64,swap_due_timestamp_seconds:e.Nat64,min_participants:e.Nat32,sns_token_e8s:e.Nat64,sale_delay_seconds:e.Opt(e.Nat64),max_participant_icp_e8s:e.Nat64,min_icp_e8s:e.Nat64}),Rt=e.Record({community_fund_investment_e8s:e.Opt(e.Nat64),target_swap_canister_id:e.Opt(e.Principal),params:e.Opt(gt)}),vt=e.Record({start_timestamp_seconds:e.Nat64,end_timestamp_seconds:e.Nat64}),ht=e.Record({open_time_window:e.Opt(vt)}),Ot=e.Record({request:e.Opt(ht),swap_canister_id:e.Opt(e.Principal)}),St=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o))}),ge=e.Record({use_registry_derived_rewards:e.Opt(e.Bool),rewards:e.Vec(m)}),bt=e.Record({principals:e.Vec(e.Principal)}),xt=e.Variant({ToRemove:a,ToAdd:a}),kt=e.Record({change:e.Opt(xt)}),Tt=e.Record({motion_text:e.Text}),Ct=e.Variant({RegisterKnownNeuron:ue,ManageNeuron:Z,CreateServiceNervousSystem:wt,ExecuteNnsFunction:Nt,RewardNodeProvider:m,OpenSnsTokenSwap:Rt,SetSnsTokenSwapOpenTimeWindow:Ot,SetDefaultFollowees:St,RewardNodeProviders:ge,ManageNetworkEconomics:y,ApproveGenesisKyc:bt,AddOrRemoveNodeProvider:kt,Motion:Tt});t.fill(e.Record({url:e.Text,title:e.Opt(e.Text),action:e.Opt(Ct),summary:e.Text}));let Pt=e.Record({current_deadline_timestamp_seconds:e.Nat64}),Mt=e.Record({id:e.Opt(n),failure_reason:e.Opt(l),cf_participants:e.Vec(je),ballots:e.Vec(e.Tuple(e.Nat64,ie)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(se),latest_tally:e.Opt(ce),sns_token_swap_lifecycle:e.Opt(e.Int32),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),wait_for_quiet_state:e.Opt(Pt),executed_timestamp_seconds:e.Nat64,original_total_community_fund_maturity_e8s_equivalent:e.Opt(e.Nat64)}),At=e.Variant({Spawn:n,Split:de,Configure:_e,Merge:u,DisburseToNeuron:me,SyncCommand:e.Record({}),ClaimOrRefreshNeuron:le,MergeMaturity:fe,Disburse:we}),Vt=e.Record({command:e.Opt(At),timestamp:e.Nat64}),Re=e.Record({vote:e.Int32,proposal_id:e.Opt(n)}),Et=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),C=e.Record({id:e.Opt(n),staked_maturity_e8s_equivalent:e.Opt(e.Nat64),controller:e.Opt(e.Principal),recent_ballots:e.Vec(Re),kyc_verified:e.Bool,not_for_profit:e.Bool,maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,auto_stake_maturity:e.Opt(e.Bool),aging_since_timestamp_seconds:e.Nat64,hot_keys:e.Vec(e.Principal),account:e.Vec(e.Nat8),joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),dissolve_state:e.Opt(Et),followees:e.Vec(e.Tuple(e.Int32,o)),neuron_fees_e8s:e.Nat64,transfer:e.Opt(k),known_neuron_data:e.Opt(Y),spawn_at_timestamp_seconds:e.Opt(e.Nat64)}),rr=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o)),most_recent_monthly_node_provider_rewards:e.Opt(f),maturity_modulation_last_updated_at_timestamp_seconds:e.Opt(e.Nat64),wait_for_quiet_threshold_seconds:e.Nat64,metrics:e.Opt(_),node_providers:e.Vec(a),cached_daily_maturity_modulation_basis_points:e.Opt(e.Int32),economics:e.Opt(y),spawning_neurons:e.Opt(e.Bool),latest_reward_event:e.Opt(g),to_claim_transfers:e.Vec(k),short_voting_period_seconds:e.Nat64,proposals:e.Vec(e.Tuple(e.Nat64,Mt)),in_flight_commands:e.Vec(e.Tuple(e.Nat64,Vt)),neurons:e.Vec(e.Tuple(e.Nat64,C)),genesis_timestamp_seconds:e.Nat64}),H=e.Variant({Ok:e.Null,Err:l}),Ft=e.Variant({Error:l,NeuronId:n}),Bt=e.Record({result:e.Opt(Ft)}),ve=e.Variant({Ok:C,Err:l}),qt=e.Variant({Ok:_,Err:l}),Ut=e.Variant({Ok:ge,Err:l}),W=e.Record({dissolve_delay_seconds:e.Nat64,recent_ballots:e.Vec(Re),created_timestamp_seconds:e.Nat64,state:e.Int32,stake_e8s:e.Nat64,joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),retrieved_at_timestamp_seconds:e.Nat64,known_neuron_data:e.Opt(Y),voting_power:e.Nat64,age_seconds:e.Nat64}),he=e.Variant({Ok:W,Err:l}),Kt=e.Variant({Ok:a,Err:l}),I=e.Record({id:e.Opt(n),status:e.Int32,topic:e.Int32,failure_reason:e.Opt(l),ballots:e.Vec(e.Tuple(e.Nat64,ie)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,deadline_timestamp_seconds:e.Opt(e.Nat64),failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(se),latest_tally:e.Opt(ce),reward_status:e.Int32,decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),executed_timestamp_seconds:e.Nat64}),Ht=e.Record({known_neurons:e.Vec(ue)}),Wt=e.Record({neuron_ids:e.Vec(e.Nat64),include_neurons_readable_by_caller:e.Bool}),Gt=e.Record({neuron_infos:e.Vec(e.Tuple(e.Nat64,W)),full_neurons:e.Vec(C)}),jt=e.Record({node_providers:e.Vec(a)}),zt=e.Record({include_reward_status:e.Vec(e.Int32),before_proposal:e.Opt(n),limit:e.Nat32,exclude_topic:e.Vec(e.Int32),include_all_manage_neuron_proposals:e.Opt(e.Bool),include_status:e.Vec(e.Int32)}),Jt=e.Record({proposal_info:e.Vec(I)}),D=e.Record({created_neuron_id:e.Opt(n)}),$t=e.Record({refreshed_neuron_id:e.Opt(n)}),Xt=e.Record({target_neuron:e.Opt(C),source_neuron:e.Opt(C),target_neuron_info:e.Opt(W),source_neuron_info:e.Opt(W)}),Yt=e.Record({proposal_id:e.Opt(n)}),Qt=e.Record({maturity_e8s:e.Nat64,staked_maturity_e8s:e.Nat64}),Zt=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),It=e.Record({transfer_block_height:e.Nat64}),Dt=e.Variant({Error:l,Spawn:D,Split:D,Follow:e.Record({}),ClaimOrRefresh:$t,Configure:e.Record({}),RegisterVote:e.Record({}),Merge:Xt,DisburseToNeuron:D,MakeProposal:Yt,StakeMaturity:Qt,MergeMaturity:Zt,Disburse:It}),Oe=e.Record({command:e.Opt(Dt)}),Lt=e.Record({sns_governance_canister_id:e.Opt(e.Principal)}),en=e.Variant({Committed:Lt,Aborted:e.Record({})}),tn=e.Record({result:e.Opt(en),open_sns_token_swap_proposal_id:e.Opt(e.Nat64)}),nn=e.Record({reward_account:e.Opt(r)});return e.Service({claim_gtc_neurons:e.Func([e.Principal,e.Vec(n)],[H],[]),claim_or_refresh_neuron_from_account:e.Func([pe],[Bt],[]),get_build_metadata:e.Func([],[e.Text],[]),get_full_neuron:e.Func([e.Nat64],[ve],[]),get_full_neuron_by_id_or_subaccount:e.Func([Q],[ve],[]),get_latest_reward_event:e.Func([],[g],[]),get_metrics:e.Func([],[qt],[]),get_monthly_node_provider_rewards:e.Func([],[Ut],[]),get_most_recent_monthly_node_provider_rewards:e.Func([],[e.Opt(f)],[]),get_network_economics_parameters:e.Func([],[y],[]),get_neuron_ids:e.Func([],[e.Vec(e.Nat64)],[]),get_neuron_info:e.Func([e.Nat64],[he],[]),get_neuron_info_by_id_or_subaccount:e.Func([Q],[he],[]),get_node_provider_by_caller:e.Func([e.Null],[Kt],[]),get_pending_proposals:e.Func([],[e.Vec(I)],[]),get_proposal_info:e.Func([e.Nat64],[e.Opt(I)],[]),list_known_neurons:e.Func([],[Ht],[]),list_neurons:e.Func([Wt],[Gt],[]),list_node_providers:e.Func([],[jt],[]),list_proposals:e.Func([zt],[Jt],[]),manage_neuron:e.Func([Z],[Oe],[]),settle_community_fund_participation:e.Func([tn],[H],[]),simulate_manage_neuron:e.Func([Z],[Oe],[]),transfer_gtc_neuron:e.Func([n,n],[H],[]),update_node_provider:e.Func([nn],[H],[])})};var to=({IDL:e})=>{let t=e.Rec(),n=e.Record({id:e.Nat64}),o=e.Record({followees:e.Vec(n)}),r=e.Record({hash:e.Vec(e.Nat8)}),a=e.Record({id:e.Opt(e.Principal),reward_account:e.Opt(r)}),i=e.Record({dissolve_delay_seconds:e.Nat64}),c=e.Record({to_account:e.Opt(r)}),d=e.Variant({RewardToNeuron:i,RewardToAccount:c}),m=e.Record({node_provider:e.Opt(a),reward_mode:e.Opt(d),amount_e8s:e.Nat64}),f=e.Record({timestamp:e.Nat64,rewards:e.Vec(m)}),_=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)),total_supply_icp:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,community_fund_total_maturity_e8s_equivalent:e.Nat64,total_staked_e8s:e.Nat64,not_dissolving_neurons_count:e.Nat64,total_locked_e8s: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)),community_fund_total_staked_e8s:e.Nat64,timestamp_seconds:e.Nat64}),y=e.Record({neuron_minimum_stake_e8s:e.Nat64,max_proposals_to_keep_per_topic:e.Nat32,neuron_management_fee_per_proposal_e8s:e.Nat64,reject_cost_e8s:e.Nat64,transaction_fee_e8s:e.Nat64,neuron_spawn_dissolve_delay_seconds:e.Nat64,minimum_icp_xdr_rate:e.Nat64,maximum_node_provider_rewards_e8s:e.Nat64}),g=e.Record({rounds_since_last_distribution:e.Opt(e.Nat64),day_after_genesis:e.Nat64,actual_timestamp_seconds:e.Nat64,total_available_e8s_equivalent:e.Nat64,latest_round_available_e8s_equivalent:e.Opt(e.Nat64),distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(n)}),k=e.Record({to_subaccount:e.Vec(e.Nat8),neuron_stake_e8s:e.Nat64,from:e.Opt(e.Principal),memo:e.Nat64,from_subaccount:e.Vec(e.Nat8),transfer_timestamp:e.Nat64,block_height:e.Nat64}),l=e.Record({error_message:e.Text,error_type:e.Int32}),Ge=e.Record({nns_neuron_id:e.Nat64,amount_icp_e8s:e.Nat64}),je=e.Record({hotkey_principal:e.Text,cf_neurons:e.Vec(Ge)}),ie=e.Record({vote:e.Int32,voting_power:e.Nat64}),ze=e.Record({status:e.Opt(e.Int32),freezing_threshold:e.Opt(e.Nat64),controllers:e.Vec(e.Principal),memory_size:e.Opt(e.Nat64),cycles:e.Opt(e.Nat64),idle_cycles_burned_per_day:e.Opt(e.Nat64),module_hash:e.Vec(e.Nat8)}),O=e.Record({status:e.Opt(ze),canister_id:e.Opt(e.Principal)}),Je=e.Record({ledger_index_canister_summary:e.Opt(O),fallback_controller_principal_ids:e.Vec(e.Principal),ledger_archive_canister_summaries:e.Vec(O),ledger_canister_summary:e.Opt(O),swap_canister_summary:e.Opt(O),governance_canister_summary:e.Opt(O),root_canister_summary:e.Opt(O),dapp_canister_summaries:e.Vec(O)}),se=e.Record({swap_background_information:e.Opt(Je)}),ce=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),Y=e.Record({name:e.Text,description:e.Opt(e.Text)}),ue=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(Y)}),$e=e.Record({percentage_to_spawn:e.Opt(e.Nat32),new_controller:e.Opt(e.Principal),nonce:e.Opt(e.Nat64)}),de=e.Record({amount_e8s:e.Nat64}),Xe=e.Record({topic:e.Int32,followees:e.Vec(n)}),pe=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),Ye=e.Variant({NeuronIdOrSubaccount:e.Record({}),MemoAndController:pe,Memo:e.Nat64}),le=e.Record({by:e.Opt(Ye)}),Qe=e.Record({hot_key_to_remove:e.Opt(e.Principal)}),Ze=e.Record({new_hot_key:e.Opt(e.Principal)}),Ie=e.Record({requested_setting_for_auto_stake_maturity:e.Bool}),De=e.Record({additional_dissolve_delay_seconds:e.Nat32}),Le=e.Record({dissolve_timestamp_seconds:e.Nat64}),et=e.Variant({RemoveHotKey:Qe,AddHotKey:Ze,ChangeAutoStakeMaturity:Ie,StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:De,JoinCommunityFund:e.Record({}),LeaveCommunityFund:e.Record({}),SetDissolveTimestamp:Le}),_e=e.Record({operation:e.Opt(et)}),tt=e.Record({vote:e.Int32,proposal:e.Opt(n)}),u=e.Record({source_neuron_id:e.Opt(n)}),me=e.Record({dissolve_delay_seconds:e.Nat64,kyc_verified:e.Bool,amount_e8s:e.Nat64,new_controller:e.Opt(e.Principal),nonce:e.Nat64}),nt=e.Record({percentage_to_stake:e.Opt(e.Nat32)}),fe=e.Record({percentage_to_merge:e.Nat32}),ot=e.Record({e8s:e.Nat64}),we=e.Record({to_account:e.Opt(r),amount:e.Opt(ot)}),rt=e.Variant({Spawn:$e,Split:de,Follow:Xe,ClaimOrRefresh:le,Configure:_e,RegisterVote:tt,Merge:u,DisburseToNeuron:me,MakeProposal:t,StakeMaturity:nt,MergeMaturity:fe,Disburse:we}),Q=e.Variant({Subaccount:e.Vec(e.Nat8),NeuronId:n}),Z=e.Record({id:e.Opt(n),command:e.Opt(rt),neuron_id_or_subaccount:e.Opt(Q)}),K=e.Record({basis_points:e.Opt(e.Nat64)}),w=e.Record({seconds:e.Opt(e.Nat64)}),N=e.Record({e8s:e.Opt(e.Nat64)}),at=e.Record({reward_rate_transition_duration:e.Opt(w),initial_reward_rate:e.Opt(K),final_reward_rate:e.Opt(K)}),it=e.Record({neuron_maximum_dissolve_delay_bonus:e.Opt(K),neuron_maximum_age_for_age_bonus:e.Opt(w),neuron_maximum_dissolve_delay:e.Opt(w),neuron_minimum_dissolve_delay_to_vote:e.Opt(w),neuron_maximum_age_bonus:e.Opt(K),neuron_minimum_stake:e.Opt(N),proposal_wait_for_quiet_deadline_increase:e.Opt(w),proposal_initial_voting_period:e.Opt(w),proposal_rejection_fee:e.Opt(N),voting_reward_parameters:e.Opt(at)}),Ne=e.Record({base64_encoding:e.Opt(e.Text)}),st=e.Record({transaction_fee:e.Opt(N),token_symbol:e.Opt(e.Text),token_logo:e.Opt(Ne),token_name:e.Opt(e.Text)}),ct=e.Record({id:e.Opt(e.Principal)}),ut=e.Record({dissolve_delay_interval:e.Opt(w),count:e.Opt(e.Nat64)}),dt=e.Record({seconds_after_utc_midnight:e.Opt(e.Nat64)}),pt=e.Record({iso_codes:e.Vec(e.Text)}),lt=e.Record({minimum_participants:e.Opt(e.Nat64),duration:e.Opt(w),neuron_basket_construction_parameters:e.Opt(ut),confirmation_text:e.Opt(e.Text),maximum_participant_icp:e.Opt(N),minimum_icp:e.Opt(N),minimum_participant_icp:e.Opt(N),start_time:e.Opt(dt),maximum_icp:e.Opt(N),neurons_fund_investment_icp:e.Opt(N),restricted_countries:e.Opt(pt)}),ye=e.Record({total:e.Opt(N)}),_t=e.Record({controller:e.Opt(e.Principal),dissolve_delay:e.Opt(w),memo:e.Opt(e.Nat64),vesting_period:e.Opt(w),stake:e.Opt(N)}),mt=e.Record({developer_neurons:e.Vec(_t)}),ft=e.Record({treasury_distribution:e.Opt(ye),developer_distribution:e.Opt(mt),swap_distribution:e.Opt(ye)}),wt=e.Record({url:e.Opt(e.Text),governance_parameters:e.Opt(it),fallback_controller_principal_ids:e.Vec(e.Principal),logo:e.Opt(Ne),name:e.Opt(e.Text),ledger_parameters:e.Opt(st),description:e.Opt(e.Text),dapp_canisters:e.Vec(ct),swap_parameters:e.Opt(lt),initial_token_distribution:e.Opt(ft)}),Nt=e.Record({nns_function:e.Int32,payload:e.Vec(e.Nat8)}),yt=e.Record({dissolve_delay_interval_seconds:e.Nat64,count:e.Nat64}),gt=e.Record({min_participant_icp_e8s:e.Nat64,neuron_basket_construction_parameters:e.Opt(yt),max_icp_e8s:e.Nat64,swap_due_timestamp_seconds:e.Nat64,min_participants:e.Nat32,sns_token_e8s:e.Nat64,sale_delay_seconds:e.Opt(e.Nat64),max_participant_icp_e8s:e.Nat64,min_icp_e8s:e.Nat64}),Rt=e.Record({community_fund_investment_e8s:e.Opt(e.Nat64),target_swap_canister_id:e.Opt(e.Principal),params:e.Opt(gt)}),vt=e.Record({start_timestamp_seconds:e.Nat64,end_timestamp_seconds:e.Nat64}),ht=e.Record({open_time_window:e.Opt(vt)}),Ot=e.Record({request:e.Opt(ht),swap_canister_id:e.Opt(e.Principal)}),St=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o))}),ge=e.Record({use_registry_derived_rewards:e.Opt(e.Bool),rewards:e.Vec(m)}),bt=e.Record({principals:e.Vec(e.Principal)}),xt=e.Variant({ToRemove:a,ToAdd:a}),kt=e.Record({change:e.Opt(xt)}),Tt=e.Record({motion_text:e.Text}),Ct=e.Variant({RegisterKnownNeuron:ue,ManageNeuron:Z,CreateServiceNervousSystem:wt,ExecuteNnsFunction:Nt,RewardNodeProvider:m,OpenSnsTokenSwap:Rt,SetSnsTokenSwapOpenTimeWindow:Ot,SetDefaultFollowees:St,RewardNodeProviders:ge,ManageNetworkEconomics:y,ApproveGenesisKyc:bt,AddOrRemoveNodeProvider:kt,Motion:Tt});t.fill(e.Record({url:e.Text,title:e.Opt(e.Text),action:e.Opt(Ct),summary:e.Text}));let Pt=e.Record({current_deadline_timestamp_seconds:e.Nat64}),Mt=e.Record({id:e.Opt(n),failure_reason:e.Opt(l),cf_participants:e.Vec(je),ballots:e.Vec(e.Tuple(e.Nat64,ie)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(se),latest_tally:e.Opt(ce),sns_token_swap_lifecycle:e.Opt(e.Int32),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),wait_for_quiet_state:e.Opt(Pt),executed_timestamp_seconds:e.Nat64,original_total_community_fund_maturity_e8s_equivalent:e.Opt(e.Nat64)}),At=e.Variant({Spawn:n,Split:de,Configure:_e,Merge:u,DisburseToNeuron:me,SyncCommand:e.Record({}),ClaimOrRefreshNeuron:le,MergeMaturity:fe,Disburse:we}),Vt=e.Record({command:e.Opt(At),timestamp:e.Nat64}),Re=e.Record({vote:e.Int32,proposal_id:e.Opt(n)}),Et=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),C=e.Record({id:e.Opt(n),staked_maturity_e8s_equivalent:e.Opt(e.Nat64),controller:e.Opt(e.Principal),recent_ballots:e.Vec(Re),kyc_verified:e.Bool,not_for_profit:e.Bool,maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,auto_stake_maturity:e.Opt(e.Bool),aging_since_timestamp_seconds:e.Nat64,hot_keys:e.Vec(e.Principal),account:e.Vec(e.Nat8),joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),dissolve_state:e.Opt(Et),followees:e.Vec(e.Tuple(e.Int32,o)),neuron_fees_e8s:e.Nat64,transfer:e.Opt(k),known_neuron_data:e.Opt(Y),spawn_at_timestamp_seconds:e.Opt(e.Nat64)}),rr=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o)),most_recent_monthly_node_provider_rewards:e.Opt(f),maturity_modulation_last_updated_at_timestamp_seconds:e.Opt(e.Nat64),wait_for_quiet_threshold_seconds:e.Nat64,metrics:e.Opt(_),node_providers:e.Vec(a),cached_daily_maturity_modulation_basis_points:e.Opt(e.Int32),economics:e.Opt(y),spawning_neurons:e.Opt(e.Bool),latest_reward_event:e.Opt(g),to_claim_transfers:e.Vec(k),short_voting_period_seconds:e.Nat64,proposals:e.Vec(e.Tuple(e.Nat64,Mt)),in_flight_commands:e.Vec(e.Tuple(e.Nat64,Vt)),neurons:e.Vec(e.Tuple(e.Nat64,C)),genesis_timestamp_seconds:e.Nat64}),H=e.Variant({Ok:e.Null,Err:l}),Ft=e.Variant({Error:l,NeuronId:n}),Bt=e.Record({result:e.Opt(Ft)}),ve=e.Variant({Ok:C,Err:l}),qt=e.Variant({Ok:_,Err:l}),Ut=e.Variant({Ok:ge,Err:l}),W=e.Record({dissolve_delay_seconds:e.Nat64,recent_ballots:e.Vec(Re),created_timestamp_seconds:e.Nat64,state:e.Int32,stake_e8s:e.Nat64,joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),retrieved_at_timestamp_seconds:e.Nat64,known_neuron_data:e.Opt(Y),voting_power:e.Nat64,age_seconds:e.Nat64}),he=e.Variant({Ok:W,Err:l}),Kt=e.Variant({Ok:a,Err:l}),I=e.Record({id:e.Opt(n),status:e.Int32,topic:e.Int32,failure_reason:e.Opt(l),ballots:e.Vec(e.Tuple(e.Nat64,ie)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,deadline_timestamp_seconds:e.Opt(e.Nat64),failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(se),latest_tally:e.Opt(ce),reward_status:e.Int32,decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),executed_timestamp_seconds:e.Nat64}),Ht=e.Record({known_neurons:e.Vec(ue)}),Wt=e.Record({neuron_ids:e.Vec(e.Nat64),include_neurons_readable_by_caller:e.Bool}),Gt=e.Record({neuron_infos:e.Vec(e.Tuple(e.Nat64,W)),full_neurons:e.Vec(C)}),jt=e.Record({node_providers:e.Vec(a)}),zt=e.Record({include_reward_status:e.Vec(e.Int32),before_proposal:e.Opt(n),limit:e.Nat32,exclude_topic:e.Vec(e.Int32),include_all_manage_neuron_proposals:e.Opt(e.Bool),include_status:e.Vec(e.Int32)}),Jt=e.Record({proposal_info:e.Vec(I)}),D=e.Record({created_neuron_id:e.Opt(n)}),$t=e.Record({refreshed_neuron_id:e.Opt(n)}),Xt=e.Record({target_neuron:e.Opt(C),source_neuron:e.Opt(C),target_neuron_info:e.Opt(W),source_neuron_info:e.Opt(W)}),Yt=e.Record({proposal_id:e.Opt(n)}),Qt=e.Record({maturity_e8s:e.Nat64,staked_maturity_e8s:e.Nat64}),Zt=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),It=e.Record({transfer_block_height:e.Nat64}),Dt=e.Variant({Error:l,Spawn:D,Split:D,Follow:e.Record({}),ClaimOrRefresh:$t,Configure:e.Record({}),RegisterVote:e.Record({}),Merge:Xt,DisburseToNeuron:D,MakeProposal:Yt,StakeMaturity:Qt,MergeMaturity:Zt,Disburse:It}),Oe=e.Record({command:e.Opt(Dt)}),Lt=e.Record({sns_governance_canister_id:e.Opt(e.Principal)}),en=e.Variant({Committed:Lt,Aborted:e.Record({})}),tn=e.Record({result:e.Opt(en),open_sns_token_swap_proposal_id:e.Opt(e.Nat64)}),nn=e.Record({reward_account:e.Opt(r)});return e.Service({claim_gtc_neurons:e.Func([e.Principal,e.Vec(n)],[H],[]),claim_or_refresh_neuron_from_account:e.Func([pe],[Bt],[]),get_build_metadata:e.Func([],[e.Text],["query"]),get_full_neuron:e.Func([e.Nat64],[ve],["query"]),get_full_neuron_by_id_or_subaccount:e.Func([Q],[ve],["query"]),get_latest_reward_event:e.Func([],[g],["query"]),get_metrics:e.Func([],[qt],["query"]),get_monthly_node_provider_rewards:e.Func([],[Ut],[]),get_most_recent_monthly_node_provider_rewards:e.Func([],[e.Opt(f)],["query"]),get_network_economics_parameters:e.Func([],[y],["query"]),get_neuron_ids:e.Func([],[e.Vec(e.Nat64)],["query"]),get_neuron_info:e.Func([e.Nat64],[he],["query"]),get_neuron_info_by_id_or_subaccount:e.Func([Q],[he],["query"]),get_node_provider_by_caller:e.Func([e.Null],[Kt],["query"]),get_pending_proposals:e.Func([],[e.Vec(I)],["query"]),get_proposal_info:e.Func([e.Nat64],[e.Opt(I)],["query"]),list_known_neurons:e.Func([],[Ht],["query"]),list_neurons:e.Func([Wt],[Gt],["query"]),list_node_providers:e.Func([],[jt],["query"]),list_proposals:e.Func([zt],[Jt],["query"]),manage_neuron:e.Func([Z],[Oe],[]),settle_community_fund_participation:e.Func([tn],[H],[]),simulate_manage_neuron:e.Func([Z],[Oe],[]),transfer_gtc_neuron:e.Func([n,n],[H],[]),update_node_provider:e.Func([nn],[H],[])})};import{Principal as B}from"@dfinity/principal";import{arrayBufferToUint8Array as jr,toNullable as ae}from"@dfinity/utils";var Be=class extends Error{},be=class extends Be{},xe=class extends Be{constructor(n){super();this.minimumAmount=n}},z=class extends Error{},P=class extends Error{constructor(n){super();this.detail=n}},ke=class extends Error{},v=class extends Error{constructor(t){super("Unsupported value: "+t)}},qe=class extends Error{};import{arrayOfNumberToUint8Array as Kr,asciiStringToByteArray as Hr,bigEndianCrc32 as Wr,uint8ArrayToHexString as Gr}from"@dfinity/utils";var yn=Pn(mn()),no=e=>Uint8Array.from(yn.Buffer.from(e,"hex")).subarray(4),oo=e=>yn.Buffer.from(e).toString("hex"),ro=(e,t)=>{let n=Hr(`
3
- account-id`),o=An.create();o.update(Kr([...n,...e.toUint8Array(),...t??Array(32).fill(0)]));let r=o.digest(),a=Wr(r),i=new Uint8Array([...a,...r]);return Gr(i)};var so=e=>({id:e}),gn=e=>({id:e}),zr=e=>({followees:e.map(gn)}),Jr=e=>{if("NeuronId"in e)return{NeuronId:{id:e.NeuronId}};if("Subaccount"in e)return{Subaccount:Uint8Array.from(e.Subaccount)};throw new v(e)},Ue=e=>e.basisPoints!==void 0?{basis_points:[e.basisPoints]}:{basis_points:[]},E=e=>e.seconds!==void 0?{seconds:[e.seconds]}:{seconds:[]},$r=e=>e.secondsAfterUtcMidnight!==void 0?{seconds_after_utc_midnight:[e.secondsAfterUtcMidnight]}:{seconds_after_utc_midnight:[]},Xr=e=>({iso_codes:e.isoCodes}),F=e=>e.e8s!==void 0?{e8s:[e.e8s]}:{e8s:[]},co=e=>e.base64Encoding!==void 0?{base64_encoding:[e.base64Encoding]}:{base64_encoding:[]},Yr=e=>({reward_rate_transition_duration:e.rewardRateTransitionDuration!==void 0?[E(e.rewardRateTransitionDuration)]:[],initial_reward_rate:e.initialRewardRate!==void 0?[Ue(e.initialRewardRate)]:[],final_reward_rate:e.finalRewardRate!==void 0?[Ue(e.finalRewardRate)]:[]}),Qr=e=>({transaction_fee:e.transactionFee!==void 0?[F(e.transactionFee)]:[],token_symbol:e.tokenSymbol!==void 0?[e.tokenSymbol]:[],token_logo:e.tokenLogo!==void 0?[co(e.tokenLogo)]:[],token_name:e.tokenName!==void 0?[e.tokenName]:[]}),Zr=e=>({minimum_participants:e.minimumParticipants!==void 0?[e.minimumParticipants]:[],duration:e.duration!==void 0?[E(e.duration)]:[],neuron_basket_construction_parameters:e.neuronBasketConstructionParameters!==void 0?[Ir(e.neuronBasketConstructionParameters)]:[],confirmation_text:e.confirmationText!==void 0?[e.confirmationText]:[],maximum_participant_icp:e.maximumParticipantIcp!==void 0?[F(e.maximumParticipantIcp)]:[],neurons_fund_investment_icp:e.neuronsFundInvestmentIcp!==void 0?[F(e.neuronsFundInvestmentIcp)]:[],minimum_icp:e.minimumIcp!==void 0?[F(e.minimumIcp)]:[],minimum_participant_icp:e.minimumParticipantIcp!==void 0?[F(e.minimumParticipantIcp)]:[],start_time:e.startTime!==void 0?[$r(e.startTime)]:[],maximum_icp:e.maximumIcp!==void 0?[F(e.maximumIcp)]:[],restricted_countries:e.restrictedCountries!==void 0?[Xr(e.restrictedCountries)]:[]}),Ir=e=>({dissolve_delay_interval:e.dissolveDelayInterval!==void 0?[E(e.dissolveDelayInterval)]:[],count:e.count!==void 0?[e.count]:[]}),Dr=e=>({neuron_maximum_dissolve_delay_bonus:e.neuronMaximumDissolveDelayBonus!==void 0?[Ue(e.neuronMaximumDissolveDelayBonus)]:[],neuron_maximum_age_for_age_bonus:e.neuronMaximumAgeForAgeBonus!==void 0?[E(e.neuronMaximumAgeForAgeBonus)]:[],neuron_maximum_dissolve_delay:e.neuronMaximumDissolveDelay!==void 0?[E(e.neuronMaximumDissolveDelay)]:[],neuron_minimum_dissolve_delay_to_vote:e.neuronMinimumDissolveDelayToVote!==void 0?[E(e.neuronMinimumDissolveDelayToVote)]:[],neuron_maximum_age_bonus:e.neuronMaximumAgeBonus!==void 0?[Ue(e.neuronMaximumAgeBonus)]:[],neuron_minimum_stake:e.neuronMinimumStake!==void 0?[F(e.neuronMinimumStake)]:[],proposal_wait_for_quiet_deadline_increase:e.proposalWaitForQuietDeadlineIncrease!==void 0?[E(e.proposalWaitForQuietDeadlineIncrease)]:[],proposal_initial_voting_period:e.proposalInitialVotingPeriod!==void 0?[E(e.proposalInitialVotingPeriod)]:[],proposal_rejection_fee:e.proposalRejectionFee!==void 0?[F(e.proposalRejectionFee)]:[],voting_reward_parameters:e.votingRewardParameters!==void 0?[Yr(e.votingRewardParameters)]:[]}),ao=e=>({total:e.total!==void 0?[F(e.total)]:[]}),Lr=e=>({treasury_distribution:e.treasuryDistribution!==void 0?[ao(e.treasuryDistribution)]:[],developer_distribution:e.developerDistribution!==void 0?[ta(e.developerDistribution)]:[],swap_distribution:e.swapDistribution!==void 0?[ao(e.swapDistribution)]:[]}),ea=e=>({controller:e.controller!==void 0?[B.fromText(e.controller)]:[],dissolve_delay:e.dissolveDelay!==void 0?[E(e.dissolveDelay)]:[],memo:e.memo!==void 0?[e.memo]:[],vesting_period:e.vestingPeriod!==void 0?[E(e.vestingPeriod)]:[],stake:e.stake!==void 0?[F(e.stake)]:[]}),ta=e=>({developer_neurons:e.developerNeurons.map(ea)}),na=e=>({url:e.url!==void 0?[e.url]:[],governance_parameters:e.governanceParameters!==void 0?[Dr(e.governanceParameters)]:[],fallback_controller_principal_ids:e.fallbackControllerPrincipalIds.map(B.fromText),logo:e.logo!==void 0?[co(e.logo)]:[],name:e.name!==void 0?[e.name]:[],ledger_parameters:e.ledgerParameters!==void 0?[Qr(e.ledgerParameters)]:[],description:e.description!==void 0?[e.description]:[],dapp_canisters:e.dappCanisters.map(t=>({id:[B.fromText(t)]})),swap_parameters:e.swapParameters!==void 0?[Zr(e.swapParameters)]:[],initial_token_distribution:e.initialTokenDistribution!==void 0?[Lr(e.initialTokenDistribution)]:[]}),uo=e=>{if("ExecuteNnsFunction"in e){let t=e.ExecuteNnsFunction;if(t.payloadBytes===void 0)throw new Error("payloadBytes not found");return{ExecuteNnsFunction:{nns_function:t.nnsFunctionId,payload:jr(t.payloadBytes)}}}if("ManageNeuron"in e){let t=e.ManageNeuron;return{ManageNeuron:sa(t)}}if("ApproveGenesisKyc"in e)return{ApproveGenesisKyc:{principals:e.ApproveGenesisKyc.principals.map(B.fromText)}};if("ManageNetworkEconomics"in e){let t=e.ManageNetworkEconomics;return{ManageNetworkEconomics:{neuron_minimum_stake_e8s:t.neuronMinimumStake,max_proposals_to_keep_per_topic:t.maxProposalsToKeepPerTopic,neuron_management_fee_per_proposal_e8s:t.neuronManagementFeePerProposal,reject_cost_e8s:t.rejectCost,transaction_fee_e8s:t.transactionFee,neuron_spawn_dissolve_delay_seconds:t.neuronSpawnDissolveDelaySeconds,minimum_icp_xdr_rate:t.minimumIcpXdrRate,maximum_node_provider_rewards_e8s:t.maximumNodeProviderRewards}}}if("RewardNodeProvider"in e){let t=e.RewardNodeProvider;return{RewardNodeProvider:{node_provider:t.nodeProvider?[Ke(t.nodeProvider)]:[],amount_e8s:t.amountE8s,reward_mode:t.rewardMode!=null?[io(t.rewardMode)]:[]}}}if("RewardNodeProviders"in e){let t=e.RewardNodeProviders;return{RewardNodeProviders:{use_registry_derived_rewards:t.useRegistryDerivedRewards===void 0?[]:[t.useRegistryDerivedRewards],rewards:t.rewards.map(n=>({node_provider:n.nodeProvider?[Ke(n.nodeProvider)]:[],amount_e8s:n.amountE8s,reward_mode:n.rewardMode!=null?[io(n.rewardMode)]:[]}))}}}if("AddOrRemoveNodeProvider"in e){let t=e.AddOrRemoveNodeProvider;return{AddOrRemoveNodeProvider:{change:t.change?[aa(t.change)]:[]}}}if("Motion"in e)return{Motion:{motion_text:e.Motion.motionText}};if("SetDefaultFollowees"in e)return{SetDefaultFollowees:{default_followees:e.SetDefaultFollowees.defaultFollowees.map(n=>[n.topic,zr(n.followees)])}};if("RegisterKnownNeuron"in e){let t=e.RegisterKnownNeuron;return{RegisterKnownNeuron:{id:[{id:t.id}],known_neuron_data:[{name:t.name,description:t.description!==void 0?[t.description]:[]}]}}}if("SetSnsTokenSwapOpenTimeWindow"in e){let{request:t,swapCanisterId:n}=e.SetSnsTokenSwapOpenTimeWindow;return{SetSnsTokenSwapOpenTimeWindow:{request:t===void 0?[]:[{open_time_window:t.openTimeWindow===void 0?[]:[{start_timestamp_seconds:t.openTimeWindow.startTimestampSeconds,end_timestamp_seconds:t.openTimeWindow.endTimestampSeconds}]}],swap_canister_id:n===void 0?[]:[B.fromText(n)]}}}if("OpenSnsTokenSwap"in e){let{communityFundInvestmentE8s:t,targetSwapCanisterId:n,params:o}=e.OpenSnsTokenSwap;return{OpenSnsTokenSwap:{community_fund_investment_e8s:ae(t),target_swap_canister_id:ae(n),params:o===void 0?[]:[{min_participant_icp_e8s:o.minParticipantIcpE8s,max_icp_e8s:o.maxIcpE8s,swap_due_timestamp_seconds:o.swapDueTimestampSeconds,min_participants:o.minParticipants,sns_token_e8s:o.snsTokenE8s,max_participant_icp_e8s:o.maxParticipantIcpE8s,min_icp_e8s:o.minIcpE8s,sale_delay_seconds:ae(o.saleDelaySeconds),neuron_basket_construction_parameters:ae(o.neuronBasketConstructionParameters)}]}}}if("CreateServiceNervousSystem"in e)return{CreateServiceNervousSystem:na(e.CreateServiceNervousSystem)};throw new v(e)},oa=e=>{if("Split"in e)return{Split:{amount_e8s:e.Split.amount}};if("Follow"in e){let t=e.Follow;return{Follow:{topic:t.topic,followees:t.followees.map(gn)}}}if("ClaimOrRefresh"in e){let t=e.ClaimOrRefresh;return{ClaimOrRefresh:{by:t.by?[ia(t.by)]:[]}}}if("Configure"in e){let t=e.Configure;return{Configure:{operation:t.operation?[ra(t.operation)]:[]}}}if("RegisterVote"in e){let t=e.RegisterVote;return{RegisterVote:{vote:t.vote,proposal:t.proposal?[so(t.proposal)]:[]}}}if("DisburseToNeuron"in e){let t=e.DisburseToNeuron;return{DisburseToNeuron:{dissolve_delay_seconds:t.dissolveDelaySeconds,kyc_verified:t.kycVerified,amount_e8s:t.amount,new_controller:t.newController?[B.fromText(t.newController)]:[],nonce:t.nonce}}}if("MergeMaturity"in e)return{MergeMaturity:{percentage_to_merge:e.MergeMaturity.percentageToMerge}};if("StakeMaturity"in e){let{percentageToStake:t}=e.StakeMaturity;return{StakeMaturity:{percentage_to_stake:ae(t)}}}if("MakeProposal"in e){let t=e.MakeProposal;return{MakeProposal:{url:t.url,title:[],action:t.action?[uo(t.action)]:[],summary:t.summary}}}if("Disburse"in e){let t=e.Disburse;return{Disburse:{to_account:t.toAccountId?[Rn(t.toAccountId)]:[],amount:t.amount?[po(t.amount)]:[]}}}if("Spawn"in e){let t=e.Spawn;return{Spawn:{percentage_to_spawn:t.percentageToSpawn===void 0?[]:[t.percentageToSpawn],new_controller:t.newController?[B.fromText(t.newController)]:[],nonce:[]}}}if("Merge"in e){let t=e.Merge;return{Merge:{source_neuron_id:t.sourceNeuronId?[{id:t.sourceNeuronId}]:[]}}}throw new v(e)},ra=e=>{if("RemoveHotKey"in e){let t=e.RemoveHotKey;return{RemoveHotKey:{hot_key_to_remove:t.hotKeyToRemove!=null?[B.fromText(t.hotKeyToRemove)]:[]}}}if("AddHotKey"in e){let t=e.AddHotKey;return{AddHotKey:{new_hot_key:t.newHotKey?[B.fromText(t.newHotKey)]:[]}}}if("StopDissolving"in e)return{StopDissolving:{}};if("StartDissolving"in e)return{StartDissolving:{}};if("IncreaseDissolveDelay"in e)return{IncreaseDissolveDelay:{additional_dissolve_delay_seconds:e.IncreaseDissolveDelay.additionalDissolveDelaySeconds}};if("JoinCommunityFund"in e||"LeaveCommunityFund"in e)return e;if("SetDissolveTimestamp"in e)return{SetDissolveTimestamp:{dissolve_timestamp_seconds:e.SetDissolveTimestamp.dissolveTimestampSeconds}};if("ChangeAutoStakeMaturity"in e){let{requestedSettingForAutoStakeMaturity:t}=e.ChangeAutoStakeMaturity;return{ChangeAutoStakeMaturity:{requested_setting_for_auto_stake_maturity:t}}}throw new v(e)},aa=e=>{if("ToRemove"in e)return{ToRemove:Ke(e.ToRemove)};if("ToAdd"in e)return{ToAdd:Ke(e.ToAdd)};throw new v(e)},Ke=e=>({id:e.id!=null?[B.fromText(e.id)]:[],reward_account:e.rewardAccount!=null?[Rn(e.rewardAccount)]:[]}),po=e=>({e8s:e}),Rn=e=>({hash:no(e)}),io=e=>{if("RewardToNeuron"in e)return{RewardToNeuron:{dissolve_delay_seconds:e.RewardToNeuron.dissolveDelaySeconds}};if("RewardToAccount"in e)return{RewardToAccount:{to_account:e.RewardToAccount.toAccount!=null?[Rn(e.RewardToAccount.toAccount)]:[]}};throw new v(e)},ia=e=>{if("NeuronIdOrSubaccount"in e)return{NeuronIdOrSubaccount:{}};if("Memo"in e)return{Memo:e.Memo};if("MemoAndController"in e)return{MemoAndController:{memo:e.MemoAndController.memo,controller:e.MemoAndController.controller?[e.MemoAndController.controller]:[]}};throw new v(e)},lo=e=>({neuron_ids:BigUint64Array.from(e??[]),include_neurons_readable_by_caller:!e}),sa=({id:e,command:t,neuronIdOrSubaccount:n})=>({id:e?[gn(e)]:[],command:t?[oa(t)]:[],neuron_id_or_subaccount:n?[Jr(n)]:[]}),_o=({includeRewardStatus:e,beforeProposal:t,excludeTopic:n,includeStatus:o,limit:r,includeAllManageNeuronProposals:a})=>({include_reward_status:Int32Array.from(e),before_proposal:t?[so(t)]:[],limit:r,exclude_topic:Int32Array.from(n),include_all_manage_neuron_proposals:a!==void 0?[a]:[],include_status:Int32Array.from(o)}),mo=e=>({id:[],command:[{ClaimOrRefresh:{by:[{NeuronIdOrSubaccount:{}}]}}],neuron_id_or_subaccount:[{NeuronId:{id:e.neuronId}}]}),fo=({memo:e,controller:t})=>{let n={ClaimOrRefresh:{by:[{MemoAndController:{controller:t==null?[]:[t],memo:e}}]}};return{id:[],command:[n],neuron_id_or_subaccount:[]}},wo=({neuronId:e,amount:t})=>({id:[],command:[{Split:{amount_e8s:t}}],neuron_id_or_subaccount:[{NeuronId:{id:e}}]});var No=({neuronId:e,vote:t,proposalId:n})=>$({neuronId:e,command:{RegisterVote:{vote:t,proposal:[{id:n}]}}}),yo=e=>{let t={MakeProposal:{url:e.url,title:e.title!=null?[e.title]:[],summary:e.summary,action:[uo(e.action)]}};return{id:[],command:[t],neuron_id_or_subaccount:[{NeuronId:{id:e.neuronId}}]}},go=({neuronId:e,topic:t,followees:n})=>$({neuronId:e,command:{Follow:{topic:t,followees:n.map(o=>({id:o}))}}}),Ro=({neuronId:e,toAccountIdentifier:t,amount:n})=>$({neuronId:e,command:{Disburse:{to_account:t!==void 0?[t.toAccountIdentifierHash()]:[],amount:n!==void 0?[po(n)]:[]}}}),vo=({neuronId:e,percentageToMerge:t})=>$({neuronId:e,command:{MergeMaturity:{percentage_to_merge:t}}}),ho=({neuronId:e,percentageToStake:t})=>$({neuronId:e,command:{StakeMaturity:{percentage_to_stake:ae(t)}}}),Oo=({neuronId:e,percentageToSpawn:t,newController:n,nonce:o})=>$({neuronId:e,command:{Spawn:{percentage_to_spawn:t===void 0?[]:[t],new_controller:n===void 0?[]:[n],nonce:o===void 0?[]:[o]}}}),So=({neuronId:e,principal:t})=>J({neuronId:e,operation:{AddHotKey:{new_hot_key:[t]}}}),bo=({neuronId:e,principal:t})=>J({neuronId:e,operation:{RemoveHotKey:{hot_key_to_remove:[t]}}}),xo=({neuronId:e,additionalDissolveDelaySeconds:t})=>J({neuronId:e,operation:{IncreaseDissolveDelay:{additional_dissolve_delay_seconds:t}}}),ko=({neuronId:e,dissolveDelaySeconds:t})=>J({neuronId:e,operation:{SetDissolveTimestamp:{dissolve_timestamp_seconds:BigInt(t)}}}),To=e=>J({neuronId:e,operation:{JoinCommunityFund:{}}}),Co=({neuronId:e,autoStake:t})=>J({neuronId:e,operation:{ChangeAutoStakeMaturity:{requested_setting_for_auto_stake_maturity:t}}}),Po=e=>J({neuronId:e,operation:{LeaveCommunityFund:{}}}),vn=({sourceNeuronId:e,targetNeuronId:t})=>$({neuronId:t,command:{Merge:{source_neuron_id:[{id:e}]}}}),Mo=e=>J({neuronId:e,operation:{StartDissolving:{}}}),Ao=e=>J({neuronId:e,operation:{StopDissolving:{}}}),$=({neuronId:e,command:t})=>({id:[{id:e}],command:[t],neuron_id_or_subaccount:[]}),J=({neuronId:e,operation:t})=>$({neuronId:e,command:{Configure:{operation:[t]}}});import{Principal as hn}from"@dfinity/principal";var Vo=async e=>{let{PrincipalId:t,ManageNeuron:n,NeuronId:o}=await S(),r=new t;r.setSerializedId(hn.fromText(e.principal).toUint8Array());let a=new n.AddHotKey;a.setNewHotKey(r);let i=new n.Configure;i.setAddHotKey(a);let c=new n;c.setConfigure(i);let d=new o;return d.setId(e.neuronId.toString()),c.setNeuronId(d),c},Eo=async e=>{let{PrincipalId:t,ManageNeuron:n,NeuronId:o}=await S(),r=new t;r.setSerializedId(hn.fromText(e.principal).toUint8Array());let a=new n.RemoveHotKey;a.setHotKeyToRemove(r);let i=new n.Configure;i.setRemoveHotKey(a);let c=new n;c.setConfigure(i);let d=new o;return d.setId(e.neuronId.toString()),c.setNeuronId(d),c},Fo=async({neuronId:e,additionalDissolveDelaySeconds:t})=>{let{ManageNeuron:n,NeuronId:o}=await S(),r=new n.IncreaseDissolveDelay;r.setAdditionalDissolveDelaySeconds(t);let a=new n.Configure;a.setIncreaseDissolveDelay(r);let i=new n;i.setConfigure(a);let c=new o;return c.setId(e.toString()),i.setNeuronId(c),i},Bo=async e=>{let{ManageNeuron:t,NeuronId:n}=await S(),o=new t.Configure;o.setStartDissolving(new t.StartDissolving);let r=new t;r.setConfigure(o);let a=new n;return a.setId(e.toString()),r.setNeuronId(a),r},qo=async e=>{let{ManageNeuron:t,NeuronId:n}=await S(),o=new t.Configure;o.setStopDissolving(new t.StopDissolving);let r=new t;r.setConfigure(o);let a=new n;return a.setId(e.toString()),r.setNeuronId(a),r},Uo=async e=>{let{ManageNeuron:t,NeuronId:n}=await S(),o=new t.Configure;o.setJoinCommunityFund(new t.JoinCommunityFund);let r=new t;r.setConfigure(o);let a=new n;return a.setId(e.toString()),r.setNeuronId(a),r},Ko=async e=>{let{ManageNeuron:t,NeuronId:n,AccountIdentifier:o}=await S(),r=new t.Disburse;if(e.toAccountId){let c=new o;c.setHash(Uint8Array.from(Buffer.from(e.toAccountId,"hex"))),r.setToAccount(c)}if(e.amount!=null){let c=new t.Disburse.Amount;c.setE8s(e.amount.toString()),r.setAmount(c)}let a=new t;a.setDisburse(r);let i=new n;return i.setId(e.neuronId.toString()),a.setNeuronId(i),a},Ho=async e=>{let{ManageNeuron:t,NeuronId:n}=await S(),o=new t.MergeMaturity;o.setPercentageToMerge(e.percentageToMerge);let r=new t,a=new n;return a.setId(e.neuronId.toString()),r.setNeuronId(a),r.setMergeMaturity(o),r},Wo=async e=>{let{ManageNeuron:t,NeuronId:n,PrincipalId:o}=await S(),r=new t.Spawn;if(e.newController){let c=new o;c.setSerializedId(hn.fromText(e.newController).toUint8Array().slice(4)),r.setNewController(c)}e.percentageToSpawn!==void 0&&r.setPercentageToSpawn(e.percentageToSpawn);let a=new t;a.setSpawn(r);let i=new n;return i.setId(e.neuronId.toString()),a.setNeuronId(i),a};import{Principal as _a}from"@dfinity/principal";import{fromDefinedNullable as ma,fromNullable as p,uint8ArrayToArrayOfNumber as fa}from"@dfinity/utils";var Go=(a=>(a[a.Unspecified=0]="Unspecified",a[a.Locked=1]="Locked",a[a.Dissolving=2]="Dissolving",a[a.Dissolved=3]="Dissolved",a[a.Spawning=4]="Spawning",a))(Go||{}),ca=(l=>(l[l.Unspecified=0]="Unspecified",l[l.ManageNeuron=1]="ManageNeuron",l[l.ExchangeRate=2]="ExchangeRate",l[l.NetworkEconomics=3]="NetworkEconomics",l[l.Governance=4]="Governance",l[l.NodeAdmin=5]="NodeAdmin",l[l.ParticipantManagement=6]="ParticipantManagement",l[l.SubnetManagement=7]="SubnetManagement",l[l.NetworkCanisterManagement=8]="NetworkCanisterManagement",l[l.Kyc=9]="Kyc",l[l.NodeProviderRewards=10]="NodeProviderRewards",l[l.SnsDecentralizationSale=11]="SnsDecentralizationSale",l[l.SubnetReplicaVersionManagement=12]="SubnetReplicaVersionManagement",l[l.ReplicaVersionManagement=13]="ReplicaVersionManagement",l[l.SnsAndCommunityFund=14]="SnsAndCommunityFund",l))(ca||{}),ua=(a=>(a[a.Unknown=0]="Unknown",a[a.AcceptVotes=1]="AcceptVotes",a[a.ReadyToSettle=2]="ReadyToSettle",a[a.Settled=3]="Settled",a[a.Ineligible=4]="Ineligible",a))(ua||{}),da=(i=>(i[i.Unknown=0]="Unknown",i[i.Open=1]="Open",i[i.Rejected=2]="Rejected",i[i.Accepted=3]="Accepted",i[i.Executed=4]="Executed",i[i.Failed=5]="Failed",i))(da||{}),pa=(o=>(o[o.Unspecified=0]="Unspecified",o[o.Yes=1]="Yes",o[o.No=2]="No",o))(pa||{}),la=(u=>(u[u.Unspecified=0]="Unspecified",u[u.CreateSubnet=1]="CreateSubnet",u[u.AddNodeToSubnet=2]="AddNodeToSubnet",u[u.NnsCanisterInstall=3]="NnsCanisterInstall",u[u.NnsCanisterUpgrade=4]="NnsCanisterUpgrade",u[u.BlessReplicaVersion=5]="BlessReplicaVersion",u[u.RecoverSubnet=6]="RecoverSubnet",u[u.UpdateConfigOfSubnet=7]="UpdateConfigOfSubnet",u[u.AssignNoid=8]="AssignNoid",u[u.NnsRootUpgrade=9]="NnsRootUpgrade",u[u.IcpXdrConversionRate=10]="IcpXdrConversionRate",u[u.UpdateSubnetReplicaVersion=11]="UpdateSubnetReplicaVersion",u[u.ClearProvisionalWhitelist=12]="ClearProvisionalWhitelist",u[u.RemoveNodesFromSubnet=13]="RemoveNodesFromSubnet",u[u.SetAuthorizedSubnetworks=14]="SetAuthorizedSubnetworks",u[u.SetFirewallConfig=15]="SetFirewallConfig",u[u.UpdateNodeOperatorConfig=16]="UpdateNodeOperatorConfig",u[u.StopOrStartNnsCanister=17]="StopOrStartNnsCanister",u[u.RemoveNodes=18]="RemoveNodes",u[u.UninstallCode=19]="UninstallCode",u[u.UpdateNodeRewardsTable=20]="UpdateNodeRewardsTable",u[u.AddOrRemoveDataCenters=21]="AddOrRemoveDataCenters",u[u.UpdateUnassignedNodesConfig=22]="UpdateUnassignedNodesConfig",u[u.RemoveNodeOperators=23]="RemoveNodeOperators",u[u.RerouteCanisterRanges=24]="RerouteCanisterRanges",u[u.AddFirewallRules=25]="AddFirewallRules",u[u.RemoveFirewallRules=26]="RemoveFirewallRules",u[u.UpdateFirewallRules=27]="UpdateFirewallRules",u[u.PrepareCanisterMigration=28]="PrepareCanisterMigration",u[u.CompleteCanisterMigration=29]="CompleteCanisterMigration",u[u.AddSnsWasm=30]="AddSnsWasm",u[u.ChangeSubnetMembership=31]="ChangeSubnetMembership",u[u.UpdateSubnetType=32]="UpdateSubnetType",u[u.ChangeSubnetTypeAssignment=33]="ChangeSubnetTypeAssignment",u[u.UpdateSnsWasmSnsSubnetIds=34]="UpdateSnsWasmSnsSubnetIds",u[u.UpdateAllowedPrincipals=35]="UpdateAllowedPrincipals",u[u.RetireReplicaVersion=36]="RetireReplicaVersion",u[u.InsertSnsWasmUpgradePathEntries=37]="InsertSnsWasmUpgradePathEntries",u[u.UpdateElectedReplicaVersions=38]="UpdateElectedReplicaVersions",u[u.BitcoinSetConfig=39]="BitcoinSetConfig",u))(la||{});var On=({neuronId:e,neuronInfo:t,rawNeuron:n,canisterId:o})=>{let r=n?wa({neuron:n,canisterId:o}):void 0;return{neuronId:e,dissolveDelaySeconds:t.dissolve_delay_seconds,recentBallots:t.recent_ballots.map($o),createdTimestampSeconds:t.created_timestamp_seconds,state:t.state,joinedCommunityFundTimestampSeconds:t.joined_community_fund_timestamp_seconds.length?t.joined_community_fund_timestamp_seconds[0]:void 0,retrievedAtTimestampSeconds:t.retrieved_at_timestamp_seconds,votingPower:t.voting_power,ageSeconds:t.age_seconds,fullNeuron:r}},wa=({neuron:e,canisterId:t})=>({id:e.id.length?X(e.id[0]):void 0,stakedMaturityE8sEquivalent:p(e.staked_maturity_e8s_equivalent),controller:e.controller.length?e.controller[0].toString():void 0,recentBallots:e.recent_ballots.map($o),kycVerified:e.kyc_verified,notForProfit:e.not_for_profit,cachedNeuronStake:e.cached_neuron_stake_e8s,createdTimestampSeconds:e.created_timestamp_seconds,autoStakeMaturity:p(e.auto_stake_maturity),maturityE8sEquivalent:e.maturity_e8s_equivalent,agingSinceTimestampSeconds:e.aging_since_timestamp_seconds,neuronFees:e.neuron_fees_e8s,hotKeys:e.hot_keys.map(n=>n.toString()),accountIdentifier:ro(t,e.account),joinedCommunityFundTimestampSeconds:e.joined_community_fund_timestamp_seconds.length?e.joined_community_fund_timestamp_seconds[0]:void 0,dissolveState:e.dissolve_state.length?Na(e.dissolve_state[0]):void 0,spawnAtTimesSeconds:e.spawn_at_timestamp_seconds[0],followees:e.followees.map(([n,o])=>Xo({topic:n,followees:o}))}),$o=({vote:e,proposal_id:t})=>({vote:e,proposalId:t.length?X(t[0]):void 0}),Na=e=>"DissolveDelaySeconds"in e?{DissolveDelaySeconds:e.DissolveDelaySeconds}:{WhenDissolvedTimestampSeconds:e.WhenDissolvedTimestampSeconds},Xo=({topic:e,followees:t})=>({topic:e,followees:t.followees.map(X)}),X=({id:e})=>e,ya=e=>{if("NeuronId"in e)return{NeuronId:e.NeuronId.id};if("Subaccount"in e)return{Subaccount:fa(e.Subaccount)};throw new v(e)},ga=({neuronId:e,ballot:t})=>{let{vote:n,voting_power:o}=t;return{neuronId:e,vote:n,votingPower:o}},Ra=({title:e,url:t,action:n,summary:o})=>({title:e.length?e[0]:void 0,url:t,action:n.length?Yo(n[0]):void 0,summary:o}),Yo=e=>{if("ExecuteNnsFunction"in e)return{ExecuteNnsFunction:{nnsFunctionId:e.ExecuteNnsFunction.nns_function}};if("ManageNeuron"in e){let t=e.ManageNeuron;return{ManageNeuron:{id:t.id.length?X(t.id[0]):void 0,command:t.command.length?ha(t.command[0]):void 0,neuronIdOrSubaccount:t.neuron_id_or_subaccount.length?ya(t.neuron_id_or_subaccount[0]):void 0}}}if("ApproveGenesisKyc"in e)return{ApproveGenesisKyc:{principals:e.ApproveGenesisKyc.principals.map(n=>n.toString())}};if("ManageNetworkEconomics"in e){let t=e.ManageNetworkEconomics;return{ManageNetworkEconomics:{neuronMinimumStake:t.neuron_minimum_stake_e8s,maxProposalsToKeepPerTopic:t.max_proposals_to_keep_per_topic,neuronManagementFeePerProposal:t.neuron_management_fee_per_proposal_e8s,rejectCost:t.reject_cost_e8s,transactionFee:t.transaction_fee_e8s,neuronSpawnDissolveDelaySeconds:t.neuron_spawn_dissolve_delay_seconds,minimumIcpXdrRate:t.minimum_icp_xdr_rate,maximumNodeProviderRewards:t.maximum_node_provider_rewards_e8s}}}if("RewardNodeProvider"in e){let t=e.RewardNodeProvider;return{RewardNodeProvider:{nodeProvider:t.node_provider.length?He(t.node_provider[0]):void 0,amountE8s:t.amount_e8s,rewardMode:t.reward_mode.length?jo(t.reward_mode[0]):void 0}}}if("RewardNodeProviders"in e){let t=e.RewardNodeProviders;return{RewardNodeProviders:{useRegistryDerivedRewards:t.use_registry_derived_rewards.length?t.use_registry_derived_rewards[0]:void 0,rewards:t.rewards.map(n=>({nodeProvider:n.node_provider.length?He(n.node_provider[0]):void 0,amountE8s:n.amount_e8s,rewardMode:n.reward_mode.length?jo(n.reward_mode[0]):void 0}))}}}if("AddOrRemoveNodeProvider"in e){let t=e.AddOrRemoveNodeProvider;return{AddOrRemoveNodeProvider:{change:t.change.length?Sa(t.change[0]):void 0}}}if("Motion"in e)return{Motion:{motionText:e.Motion.motion_text}};if("SetDefaultFollowees"in e)return{SetDefaultFollowees:{defaultFollowees:e.SetDefaultFollowees.default_followees.map(([n,o])=>Xo({topic:n,followees:o}))}};if("RegisterKnownNeuron"in e){let t=e.RegisterKnownNeuron;return{RegisterKnownNeuron:ka(t)}}if("SetSnsTokenSwapOpenTimeWindow"in e){let t=e.SetSnsTokenSwapOpenTimeWindow,n=t.request?.length?{openTimeWindow:t.request[0].open_time_window.length?{startTimestampSeconds:t.request[0].open_time_window[0].start_timestamp_seconds,endTimestampSeconds:t.request[0].open_time_window[0].end_timestamp_seconds}:void 0}:void 0,o=t?.swap_canister_id.length?t.swap_canister_id[0].toString():void 0;return{SetSnsTokenSwapOpenTimeWindow:{request:n,swapCanisterId:o}}}if("OpenSnsTokenSwap"in e){let t=e.OpenSnsTokenSwap,n=p(t.params);return{OpenSnsTokenSwap:{communityFundInvestmentE8s:p(t.community_fund_investment_e8s),targetSwapCanisterId:p(t.target_swap_canister_id),...n!==void 0&&{params:{minParticipantIcpE8s:n.min_participant_icp_e8s,maxIcpE8s:n.max_icp_e8s,swapDueTimestampSeconds:n.swap_due_timestamp_seconds,minParticipants:n.min_participants,snsTokenE8s:n.sns_token_e8s,maxParticipantIcpE8s:n.max_participant_icp_e8s,minIcpE8s:n.min_icp_e8s,saleDelaySeconds:p(n.sale_delay_seconds),neuronBasketConstructionParameters:p(n.neuron_basket_construction_parameters)}}}}}if("CreateServiceNervousSystem"in e){let t=e.CreateServiceNervousSystem;return{CreateServiceNervousSystem:{url:p(t.url),governanceParameters:qa(p(t.governance_parameters)),fallbackControllerPrincipalIds:t.fallback_controller_principal_ids.map(n=>n.toString()),logo:Lo(p(t.logo)),name:p(t.name),ledgerParameters:Fa(p(t.ledger_parameters)),description:p(t.description),dappCanisters:t.dapp_canisters.map(Ea)??[],swapParameters:Ka(p(t.swap_parameters)),initialTokenDistribution:Ga(p(t.initial_token_distribution))}}}throw new v(e)},va=e=>({no:e.no,yes:e.yes,total:e.total,timestampSeconds:e.timestamp_seconds}),ha=e=>{if("Spawn"in e){let t=e.Spawn;return{Spawn:{newController:t.new_controller.length?t.new_controller[0].toString():void 0,percentageToSpawn:t.percentage_to_spawn.length?t.percentage_to_spawn[0]:0}}}if("Split"in e)return{Split:{amount:e.Split.amount_e8s}};if("Follow"in e){let t=e.Follow;return{Follow:{topic:t.topic,followees:t.followees.map(X)}}}if("ClaimOrRefresh"in e){let t=e.ClaimOrRefresh;return{ClaimOrRefresh:{by:t.by.length?xa(t.by[0]):void 0}}}if("Configure"in e){let t=e.Configure;return{Configure:{operation:t.operation.length?Oa(t.operation[0]):void 0}}}if("RegisterVote"in e){let t=e.RegisterVote;return{RegisterVote:{vote:t.vote,proposal:t.proposal.length?X(t.proposal[0]):void 0}}}if("DisburseToNeuron"in e){let t=e.DisburseToNeuron;return{DisburseToNeuron:{dissolveDelaySeconds:t.dissolve_delay_seconds,kycVerified:t.kyc_verified,amount:t.amount_e8s,newController:t.new_controller.length?t.new_controller[0].toString():void 0,nonce:t.nonce}}}if("MergeMaturity"in e)return{MergeMaturity:{percentageToMerge:e.MergeMaturity.percentage_to_merge}};if("StakeMaturity"in e){let{percentage_to_stake:t}=e.StakeMaturity;return{StakeMaturity:{percentageToStake:p(t)}}}if("MakeProposal"in e){let t=e.MakeProposal;return{MakeProposal:{title:t.title.length?t.title[0]:void 0,url:t.url,action:t.action.length?Yo(t.action[0]):void 0,summary:t.summary}}}if("Disburse"in e){let t=e.Disburse;return{Disburse:{toAccountId:t.to_account.length?Sn(t.to_account[0]):void 0,amount:t.amount.length?ba(t.amount[0]):void 0}}}if("Merge"in e){let t=e.Merge;return{Merge:{sourceNeuronId:t.source_neuron_id.length?t.source_neuron_id[0].id:void 0}}}throw new v(e)},Oa=e=>{if("RemoveHotKey"in e){let t=e.RemoveHotKey;return{RemoveHotKey:{hotKeyToRemove:t.hot_key_to_remove.length?t.hot_key_to_remove[0].toString():void 0}}}if("AddHotKey"in e){let t=e.AddHotKey;return{AddHotKey:{newHotKey:t.new_hot_key.length?t.new_hot_key[0].toString():void 0}}}if("StopDissolving"in e)return{StopDissolving:{}};if("StartDissolving"in e)return{StartDissolving:{}};if("IncreaseDissolveDelay"in e)return{IncreaseDissolveDelay:{additionalDissolveDelaySeconds:e.IncreaseDissolveDelay.additional_dissolve_delay_seconds}};if("JoinCommunityFund"in e||"LeaveCommunityFund"in e)return e;if("SetDissolveTimestamp"in e)return{SetDissolveTimestamp:{dissolveTimestampSeconds:e.SetDissolveTimestamp.dissolve_timestamp_seconds}};if("ChangeAutoStakeMaturity"in e){let{requested_setting_for_auto_stake_maturity:t}=e.ChangeAutoStakeMaturity;return{ChangeAutoStakeMaturity:{requestedSettingForAutoStakeMaturity:t}}}throw new v(e)},Sa=e=>{if("ToRemove"in e)return{ToRemove:He(e.ToRemove)};if("ToAdd"in e)return{ToAdd:He(e.ToAdd)};throw new v(e)},He=e=>({id:e.id.length?e.id[0].toString():void 0,rewardAccount:e.reward_account.length?Sn(e.reward_account[0]):void 0}),ba=e=>e.e8s,Sn=e=>oo(new Uint8Array(e.hash)),jo=e=>{if("RewardToNeuron"in e)return{RewardToNeuron:{dissolveDelaySeconds:e.RewardToNeuron.dissolve_delay_seconds}};if("RewardToAccount"in e)return{RewardToAccount:{toAccount:e.RewardToAccount.to_account!=null&&e.RewardToAccount.to_account.length?Sn(e.RewardToAccount.to_account[0]):void 0}};throw new v(e)},xa=e=>{if("NeuronIdOrSubaccount"in e)return{NeuronIdOrSubaccount:{}};if("Memo"in e)return{Memo:e.Memo};if("MemoAndController"in e)return{MemoAndController:{memo:e.MemoAndController.memo,controller:e.MemoAndController.controller.length?e.MemoAndController.controller[0]:void 0}};throw new v(e)},bn=e=>({id:e.id.length?X(e.id[0]):void 0,ballots:e.ballots.map(t=>ga({neuronId:t[0],ballot:t[1]})),rejectCost:e.reject_cost_e8s,proposalTimestampSeconds:e.proposal_timestamp_seconds,rewardEventRound:e.reward_event_round,failedTimestampSeconds:e.failed_timestamp_seconds,deadlineTimestampSeconds:p(e.deadline_timestamp_seconds),decidedTimestampSeconds:e.decided_timestamp_seconds,proposal:e.proposal.length?Ra(e.proposal[0]):void 0,proposer:e.proposer.length?X(e.proposer[0]):void 0,latestTally:e.latest_tally.length?va(e.latest_tally[0]):void 0,executedTimestampSeconds:e.executed_timestamp_seconds,topic:e.topic,status:e.status,rewardStatus:e.reward_status}),Qo=({response:{neuron_infos:e,full_neurons:t},canisterId:n})=>e.map(([o,r])=>On({neuronId:o,neuronInfo:r,rawNeuron:t.find(a=>a.id.length&&a.id[0].id===o),canisterId:n})),Zo=({proposal_info:e})=>({proposals:e.map(bn)}),ka=({id:e,known_neuron_data:t})=>({id:e[0]?.id??BigInt(0),name:t[0]?.name??"",description:t[0]?.description[0]??""}),Io=e=>{let t=e.getProposalId();return{vote:e.getVote(),proposalId:t!==void 0?BigInt(t.getId()):void 0}},Ta=e=>e?.hasWhenDissolvedTimestampSeconds()?2:e?.hasDissolveDelaySeconds()?e.getDissolveDelaySeconds()==="0"?3:1:0,Ca=e=>e.toArray().map(([t,n])=>({topic:Number(t),followees:n.getFolloweesList?.().map(o=>BigInt(o.getId()))??[]})),zo=e=>_a.fromUint8Array(e.getSerializedId_asU8()).toText(),Pa=({neuron:e,canisterId:t})=>{let n=Pe.fromBytes(e.getAccount_asU8());return te.fromPrincipal({principal:t,subAccount:n})},Ma=({pbNeuron:e,pbNeuronInfo:t,canisterId:n})=>{let o=e.getId(),r=e.getController(),a=r===void 0?r:zo(r),i;return e.hasWhenDissolvedTimestampSeconds()?i={WhenDissolvedTimestampSeconds:BigInt(e.getWhenDissolvedTimestampSeconds())}:e.hasDissolveDelaySeconds()&&(i={DissolveDelaySeconds:BigInt(e.getDissolveDelaySeconds())}),{id:o===void 0?void 0:BigInt(o.getId()),stakedMaturityE8sEquivalent:void 0,controller:a,recentBallots:t.getRecentBallotsList().map(Io),kycVerified:e.getKycVerified(),notForProfit:e.getNotForProfit(),cachedNeuronStake:BigInt(e.getCachedNeuronStakeE8s()),createdTimestampSeconds:BigInt(e.getCreatedTimestampSeconds()),autoStakeMaturity:void 0,maturityE8sEquivalent:BigInt(e.getMaturityE8sEquivalent()),agingSinceTimestampSeconds:BigInt(e.getAgingSinceTimestampSeconds()),spawnAtTimesSeconds:e.hasSpawnAtTimestampSeconds()?BigInt(e.getSpawnAtTimestampSeconds()):void 0,neuronFees:BigInt(e.getNeuronFeesE8s()),hotKeys:e.getHotKeysList().map(zo),accountIdentifier:Pa({neuron:e,canisterId:n}).toHex(),joinedCommunityFundTimestampSeconds:void 0,dissolveState:i,followees:Ca(e.getFolloweesMap())}},Do=({pbNeurons:e,canisterId:t})=>n=>{let o=e.find(a=>a.getId()?.getId()===n.getKey()),r=n.getValue();if(r===void 0)throw new Error(`NeuronInfo not present for neuron ${n.getKey()}`);return{neuronId:BigInt(n.getKey()),dissolveDelaySeconds:BigInt(r.getDissolveDelaySeconds()),recentBallots:r.getRecentBallotsList().map(Io),createdTimestampSeconds:BigInt(r.getCreatedTimestampSeconds()),state:Ta(o),joinedCommunityFundTimestampSeconds:void 0,retrievedAtTimestampSeconds:BigInt(r.getRetrievedAtTimestampSeconds()),votingPower:BigInt(r.getVotingPower()),ageSeconds:BigInt(r.getAgeSeconds()),fullNeuron:o===void 0?void 0:Ma({pbNeuron:o,pbNeuronInfo:r,canisterId:t})}},We=e=>e===void 0?void 0:{basisPoints:p(e.basis_points)},q=e=>e===void 0?void 0:{seconds:p(e.seconds)},Aa=e=>e===void 0?void 0:{secondsAfterUtcMidnight:p(e.seconds_after_utc_midnight)},Va=e=>e===void 0?void 0:{isoCodes:e.iso_codes},U=e=>e===void 0?void 0:{e8s:p(e.e8s)},Ea=e=>e===void 0||e.id.length===0?void 0:ma(e.id).toString(),Lo=e=>e===void 0?void 0:{base64Encoding:p(e.base64_encoding)},Fa=e=>e===void 0?void 0:{transactionFee:U(p(e.transaction_fee)),tokenSymbol:p(e.token_symbol),tokenLogo:Lo(p(e.token_logo)),tokenName:p(e.token_name)},Ba=e=>e===void 0?void 0:{rewardRateTransitionDuration:q(p(e.reward_rate_transition_duration)),initialRewardRate:We(p(e.initial_reward_rate)),finalRewardRate:We(p(e.final_reward_rate))},qa=e=>e===void 0?void 0:{neuronMaximumDissolveDelayBonus:We(p(e.neuron_maximum_dissolve_delay_bonus)),neuronMaximumAgeForAgeBonus:q(p(e.neuron_maximum_age_for_age_bonus)),neuronMaximumDissolveDelay:q(p(e.neuron_maximum_dissolve_delay)),neuronMinimumDissolveDelayToVote:q(p(e.neuron_minimum_dissolve_delay_to_vote)),neuronMaximumAgeBonus:We(p(e.neuron_maximum_age_bonus)),neuronMinimumStake:U(p(e.neuron_minimum_stake)),proposalWaitForQuietDeadlineIncrease:q(p(e.proposal_wait_for_quiet_deadline_increase)),proposalInitialVotingPeriod:q(p(e.proposal_initial_voting_period)),proposalRejectionFee:U(p(e.proposal_rejection_fee)),votingRewardParameters:Ba(p(e.voting_reward_parameters))},Ua=e=>e===void 0?void 0:{dissolveDelayInterval:q(p(e.dissolve_delay_interval)),count:p(e.count)},Ka=e=>e===void 0?void 0:{minimumParticipants:p(e.minimum_participants),duration:q(p(e.duration)),neuronBasketConstructionParameters:Ua(p(e.neuron_basket_construction_parameters)),confirmationText:p(e.confirmation_text),maximumParticipantIcp:U(p(e.maximum_participant_icp)),neuronsFundInvestmentIcp:U(p(e.neurons_fund_investment_icp)),minimumIcp:U(p(e.minimum_icp)),minimumParticipantIcp:U(p(e.minimum_participant_icp)),startTime:Aa(p(e.start_time)),maximumIcp:U(p(e.maximum_icp)),restrictedCountries:Va(p(e.restricted_countries))},Jo=e=>e===void 0?void 0:{total:U(p(e.total))},Ha=e=>e===void 0?void 0:{controller:e.controller.length===0?void 0:e.controller[0].toString(),dissolveDelay:q(p(e.dissolve_delay)),memo:p(e.memo),vestingPeriod:q(p(e.vesting_period)),stake:U(p(e.stake))},Wa=e=>e===void 0?void 0:{developerNeurons:e.developer_neurons.map(Ha)},Ga=e=>e===void 0?void 0:{treasuryDistribution:Jo(p(e.treasury_distribution)),developerDistribution:Wa(p(e.developer_distribution)),swapDistribution:Jo(p(e.swap_distribution))};var er=async e=>{let{ManageNeuronResponse:t}=await S(),o=t.deserializeBinary(e).getError();if(o)throw new P({error_message:o.getErrorMessage(),error_type:o.getErrorType()})};var Te=e=>{let{command:t}=e,n=t[0];if(!n)throw new P({error_message:"Error updating neuron",error_type:0});if("Error"in n)throw new P(n.Error);return n},h=async({request:e,service:t})=>{let n=await t.manage_neuron(e);Te(n)},tr=async({request:e,service:t})=>{let n=await t.simulate_manage_neuron(e);return Te(n)};import{bigEndianCrc32 as ja}from"@dfinity/utils";var xn=e=>{if(e.length!=64)throw new ke(`Invalid account identifier ${e}. The account identifier must be 64 chars in length.`);let t=Buffer.from(e,"hex"),n=t.slice(0,4),o=Buffer.from(ja(t.slice(4)));if(!o.equals(n))throw new ke(`Account identifier ${e} has an invalid checksum. Are you sure the account identifier is correct?
4
-
5
- Expected checksum: ${o.toString("hex")}
6
- Found checksum: ${n.toString("hex")}`)};var or=class e{constructor(t,n,o,r,a=!1){this.canisterId=t;this.service=n;this.certifiedService=o;this.agent=r;this.hardwareWallet=a;this.listNeurons=async({certified:t=!0,neuronIds:n})=>{if(this.hardwareWallet&&!t)throw new qe;if(this.hardwareWallet)return this.listNeuronsHardwareWallet();let o=lo(n),r=await this.getGovernanceService(t).list_neurons(o);return Qo({response:r,canisterId:this.canisterId})};this.listKnownNeurons=async(t=!0)=>(await this.getGovernanceService(t).list_known_neurons()).known_neurons.map(o=>({id:x(o.id)?.id??BigInt(0),name:x(o.known_neuron_data)?.name??"",description:x(x(o.known_neuron_data)?.description??[])}));this.getLastestRewardEvent=async(t=!0)=>this.getGovernanceService(t).get_latest_reward_event();this.listProposals=async({request:t,certified:n=!0})=>{let o=_o(t),r=await this.getGovernanceService(n).list_proposals(o);return Zo(r)};this.stakeNeuron=async({stake:t,principal:n,fromSubAccount:o,ledgerCanister:r,createdAt:a,fee:i})=>{if(t<on)throw new xe(t);let c=new Uint8Array((0,Cn.default)(8)),d=nr(c),m=this.buildNeuronStakeSubAccount(c,n),f=te.fromPrincipal({principal:this.canisterId,subAccount:m});await r.transfer({memo:d,amount:t,fromSubAccount:o,to:f,createdAt:a,fee:i});let _=await this.claimOrRefreshNeuronFromAccount({controller:n,memo:d});if(Tn(_))throw new be;return _};this.stakeNeuronIcrc1=async({stake:t,principal:n,fromSubAccount:o,ledgerCanister:r,createdAt:a,fee:i})=>{if(t<on)throw new xe(t);let c=new Uint8Array((0,Cn.default)(8)),d=nr(c),m=this.getNeuronStakeSubAccountBytes(c,n);await r.icrc1Transfer({icrc1Memo:c,amount:t,fromSubAccount:o,to:{owner:this.canisterId,subaccount:[m]},createdAt:a,fee:i});let f=await this.claimOrRefreshNeuronFromAccount({controller:n,memo:d});if(Tn(f))throw new be;return f};this.increaseDissolveDelay=async({neuronId:t,additionalDissolveDelaySeconds:n})=>{if(this.hardwareWallet)return this.increaseDissolveDelayHardwareWallet({neuronId:t,additionalDissolveDelaySeconds:n});let o=xo({neuronId:t,additionalDissolveDelaySeconds:n});return h({request:o,service:this.certifiedService})};this.setDissolveDelay=async({neuronId:t,dissolveDelaySeconds:n})=>{let o=ko({neuronId:t,dissolveDelaySeconds:n});return h({request:o,service:this.certifiedService})};this.startDissolving=async t=>{if(this.hardwareWallet)return this.startDissolvingHardwareWallet(t);let n=Mo(t);return h({request:n,service:this.certifiedService})};this.stopDissolving=async t=>{if(this.hardwareWallet)return this.stopDissolvingHardwareWallet(t);let n=Ao(t);return h({request:n,service:this.certifiedService})};this.joinCommunityFund=async t=>{if(this.hardwareWallet)return this.joinCommunityFundHardwareWallet(t);let n=To(t);return h({request:n,service:this.certifiedService})};this.autoStakeMaturity=t=>h({request:Co(t),service:this.certifiedService});this.leaveCommunityFund=async t=>{let n=Po(t);return h({request:n,service:this.certifiedService})};this.setNodeProviderAccount=async t=>{xn(t);let n=te.fromHex(t),o=await this.certifiedService.update_node_provider({reward_account:[n.toAccountIdentifierHash()]});if("Err"in o)throw new P(o.Err)};this.mergeNeurons=async t=>{let n=vn(t);return h({request:n,service:this.certifiedService})};this.simulateMergeNeurons=async t=>{let n=vn(t),o=await tr({request:n,service:this.certifiedService}),r,a,i,c;if("Merge"in o&&M(r=o.Merge)&&M(a=x(r.target_neuron_info))&&M(i=x(r.target_neuron))&&M(c=x(i.id)?.id))return On({neuronId:c,neuronInfo:a,rawNeuron:i,canisterId:this.canisterId});throw new z(`simulateMergeNeurons: Unrecognized Merge error in ${JSON.stringify(o)}`)};this.splitNeuron=async({neuronId:t,amount:n})=>{let o=wo({neuronId:t,amount:n}),r=await this.certifiedService.manage_neuron(o),a=Te(r);if("Split"in a){let i=x(a.Split.created_neuron_id);if(Tn(i))throw new P({error_message:"Unexpected error splitting neuron. No neuronId in Split response.",error_type:0});return i.id}throw new z(`Unrecognized Split error in ${JSON.stringify(r)}`)};this.getProposal=async({proposalId:t,certified:n=!0})=>{let[o]=await this.getGovernanceService(n).get_proposal_info(t);return o?bn(o):void 0};this.makeProposal=async t=>{let n=yo(t);return h({request:n,service:this.certifiedService})};this.registerVote=async({neuronId:t,vote:n,proposalId:o})=>{let r=No({neuronId:t,vote:n,proposalId:o});return h({request:r,service:this.certifiedService})};this.setFollowees=async t=>{let n=go(t);return h({request:n,service:this.certifiedService})};this.disburse=async({neuronId:t,toAccountId:n,amount:o})=>{if(M(n)&&xn(n),this.hardwareWallet)return this.disburseHardwareWallet({neuronId:t,toAccountId:n,amount:o});let r=M(n)?te.fromHex(n):void 0,a=Ro({neuronId:t,toAccountIdentifier:r,amount:o});return h({request:a,service:this.certifiedService})};this.mergeMaturity=async({neuronId:t,percentageToMerge:n})=>{if(kn(n),this.hardwareWallet)return this.mergeMaturityHardwareWallet({neuronId:t,percentageToMerge:n});let o=vo({neuronId:t,percentageToMerge:n});return h({request:o,service:this.certifiedService})};this.stakeMaturity=async({neuronId:t,percentageToStake:n})=>{kn(n??100),await h({request:ho({neuronId:t,percentageToStake:n}),service:this.certifiedService})};this.spawnNeuron=async({neuronId:t,percentageToSpawn:n,newController:o,nonce:r})=>{if(M(n)&&kn(n),this.hardwareWallet)return this.spawnHardwareWallet({neuronId:t,percentageToSpawn:n,newController:o?.toText()});let a=Oo({neuronId:t,percentageToSpawn:n,newController:o,nonce:r}),i=await this.certifiedService.manage_neuron(a),c=Te(i),d;if("Spawn"in c&&M(d=x(c.Spawn.created_neuron_id)?.id))return d;throw new z(`Unrecognized Spawn error in ${JSON.stringify(i)}`)};this.addHotkey=async({neuronId:t,principal:n})=>{if(this.hardwareWallet)return this.addHotkeyHardwareWallet({neuronId:t,principal:n});let o=So({neuronId:t,principal:n});return h({request:o,service:this.certifiedService})};this.removeHotkey=async({neuronId:t,principal:n})=>{if(this.hardwareWallet)return this.removeHotkeyHardwareWallet({neuronId:t,principal:n});let o=bo({neuronId:t,principal:n});return h({request:o,service:this.certifiedService})};this.claimOrRefreshNeuronFromAccount=async({memo:t,controller:n})=>{let o=fo({memo:t,controller:n}),r=await this.certifiedService.manage_neuron(o),a;if(M(a=x(r.command))&&"ClaimOrRefresh"in a)return x(a.ClaimOrRefresh.refreshed_neuron_id)?.id;throw new z(`Unrecognized ClaimOrRefresh error in ${JSON.stringify(r)}`)};this.claimOrRefreshNeuron=async t=>{let n=mo(t),o=await this.service.manage_neuron(n),r;if(M(r=x(o.command))&&"ClaimOrRefresh"in r)return x(r.ClaimOrRefresh.refreshed_neuron_id)?.id;throw new z(`Unrecognized ClaimOrRefresh error in ${JSON.stringify(o)}`)};this.buildNeuronStakeSubAccount=(t,n)=>Pe.fromBytes(this.getNeuronStakeSubAccountBytes(t,n));this.getNeuronStakeSubAccountBytes=(t,n)=>{let o=Ja("neuron-stake"),r=Mn.create();return r.update(za([12,...o,...n.toUint8Array(),...t])),r.digest()};this.getNeuron=async({certified:t=!0,neuronId:n})=>{let[o]=await this.listNeurons({certified:t,neuronIds:[n]});return o};this.listNeuronsHardwareWallet=async()=>{let{ListNeurons:t,ListNeuronsResponse:n}=await S(),o=new t;o.setIncludeNeuronsReadableByCaller(!0);let r=await Ce({agent:this.agent,canisterId:this.canisterId,methodName:"list_neurons_pb",arg:o.serializeBinary()}),a=n.deserializeBinary(r),i=a.getFullNeuronsList();return a.getNeuronIdsList().map(Do({pbNeurons:i,canisterId:this.canisterId}))};this.manageNeuronUpdateCall=async t=>{let n=await Ce({agent:this.agent,canisterId:this.canisterId,methodName:"manage_neuron_pb",arg:t.serializeBinary()});await er(n)};this.addHotkeyHardwareWallet=async({neuronId:t,principal:n})=>{let o=await Vo({neuronId:t,principal:n.toText()});await this.manageNeuronUpdateCall(o)};this.removeHotkeyHardwareWallet=async({neuronId:t,principal:n})=>{let o=await Eo({neuronId:t,principal:n.toText()});await this.manageNeuronUpdateCall(o)};this.increaseDissolveDelayHardwareWallet=async({neuronId:t,additionalDissolveDelaySeconds:n})=>{let o=await Fo({neuronId:t,additionalDissolveDelaySeconds:n});await this.manageNeuronUpdateCall(o)};this.startDissolvingHardwareWallet=async t=>{let n=await Bo(t);await this.manageNeuronUpdateCall(n)};this.stopDissolvingHardwareWallet=async t=>{let n=await qo(t);await this.manageNeuronUpdateCall(n)};this.joinCommunityFundHardwareWallet=async t=>{let n=await Uo(t);await this.manageNeuronUpdateCall(n)};this.disburseHardwareWallet=async t=>{let n=await Ko(t);await this.manageNeuronUpdateCall(n)};this.mergeMaturityHardwareWallet=async t=>{let n=await Ho(t);await this.manageNeuronUpdateCall(n)};this.spawnHardwareWallet=async t=>{let n=await Wo(t),o=await Ce({agent:this.agent,canisterId:this.canisterId,methodName:"manage_neuron_pb",arg:n.serializeBinary()}),{ManageNeuronResponse:r}=await S(),a=r.deserializeBinary(o),i=a.getError();if(i)throw new P({error_message:i.getErrorMessage(),error_type:i.getErrorType()});let c=a.getSpawn()?.getCreatedNeuronId();if(M(c))return BigInt(c.getId());throw new z(`Unrecognized Spawn error in ${JSON.stringify(a)}`)};this.canisterId=t,this.service=n,this.certifiedService=o,this.agent=r,this.hardwareWallet=a}static create(t={}){let n=t.canisterId??Vn,{service:o,certifiedService:r,agent:a}=$a({options:{...t,canisterId:n},idlFactory:to,certifiedIdlFactory:eo});return new e(n,o,r,a,t.hardwareWallet)}getGovernanceService(t){return t?this.certifiedService:this.service}};export{Be as a,be as b,xe as c,z as d,P as e,ke as f,v as g,qe as h,no as i,oo as j,ro as k,Go as l,ca as m,ua as n,da as o,pa as p,la as q,xn as r,or as s};
7
- /*! Bundled license information:
8
-
9
- ieee754/index.js:
10
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
11
-
12
- buffer/index.js:
13
- (*!
14
- * The buffer module from node.js, for the browser.
15
- *
16
- * @author Feross Aboukhadijeh <https://feross.org>
17
- * @license MIT
18
- *)
19
- */
20
- //# sourceMappingURL=chunk-TETJJ4EX.js.map