polkadot-api 1.23.0 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { getCli, ink, update, remove, generate, add } from '@polkadot-api/cli';
3
3
 
4
- var version = "1.23.0";
4
+ var version = "1.23.2";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(de,tn){typeof exports=="object"&&typeof module<"u"?tn(exports):typeof define=="function"&&define.amd?define(["exports"],tn):(de=typeof globalThis<"u"?globalThis:de||self,tn(de.papi={}))})(this,(function(de){"use strict";var tn=Object.defineProperty,Ga=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gs=(e,t,n)=>(Ga(e,typeof t!="symbol"?t+"":t,n),n),fr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Qa(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|fr[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=fr[e[i]],l=fr[e[i+1]];s[t+o++]=a<<4|l}return s}var ws=class extends Uint8Array{constructor(e){super(e),gs(this,"i",0),gs(this,"v"),this.v=new DataView(e)}},Oe=e=>t=>e(t instanceof ws?t:new ws(t instanceof Uint8Array?t.buffer:typeof t=="string"?Qa(t).buffer:t)),We=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function kn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var et=Oe,K=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},An=(e,t)=>n=>e(t(n)),$n=(e,t)=>n=>t(e(n)),qe=([e,t],n,r)=>K(An(e,n),$n(t,r));function Za(e,t){return Oe(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ja(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function lt(e,t,n){return K(Ja(e,n),Za(e,t))}var z=lt(1,"getUint8","setUint8"),Ne=lt(2,"getUint16","setUint16"),He=lt(4,"getUint32","setUint32"),nn=lt(8,"getBigUint64","setBigUint64"),ec=lt(1,"getInt8","setInt8"),tc=lt(2,"getInt16","setInt16"),nc=lt(4,"getInt32","setInt32"),rc=lt(8,"getBigInt64","setBigInt64"),xs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Es=e=>Oe(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),ks=K(xs,Es("getBigUint64")),sc=K(xs,Es("getBigInt64")),As=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},$s=e=>Oe(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),oc=K(As,$s("getBigUint64")),ic=K(As,$s("getBigInt64")),ac=qe(z,e=>e?1:0,Boolean),cc=[z[1],Ne[1],He[1]],lc=Oe(e=>{const t=e[e.i],n=t&3;if(n<3)return cc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let l=0;l<o;l++)s=nn[1](e)<<i|s,i+=64n;let a=r%8;return a>3&&(s=BigInt(He[1](e))<<i|s,i+=32n,a-=4),a>1&&(s=BigInt(Ne[1](e))<<i|s,i+=16n,a-=2),a&&(s=BigInt(z[1](e))<<i|s),s}),uc=1n<<56n,fc=1<<24,hc=256,dc=4294967295n,pc=64,vc=16384,mc=1<<30,yc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<pc)return z[0](t);if(e<vc)return Ne[0](t|1);if(e<mc)return He[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=uc;)n.push(nn[0](r)),r>>=64n;r>=fc&&(n.push(He[0](Number(r&dc))),r>>=32n);let s=Number(r);s>=hc&&(n.push(Ne[0](s)),s>>=16),s&&n.push(z[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},pe=K(yc,lc),bc=new TextEncoder,gc=e=>{const t=bc.encode(e);return We([pe.enc(t.length),t])},wc=new TextDecoder,xc=Oe(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,wc.decode(n)}),q=K(gc,xc),Ec=()=>{},kc=new Uint8Array(0),P=K(()=>kc,Ec),Ss=e=>e===void 0?t=>We([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Is=e=>Oe(t=>{const n=e===void 0?pe.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),ee=e=>K(Ss(e),Is(e));ee.enc=Ss,ee.dec=Is;var Bs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>We([z.enc(s(o)),e[o](i)])},_s=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Oe(s=>{const o=z.dec(s),i=r.get(o),a=e[i];return{tag:i,value:a(s)}})},xe=(e,...t)=>K(Bs(kn(e,([n])=>n),...t),_s(kn(e,([,n])=>n),...t));xe.enc=Bs,xe.dec=_s;var Cs=e=>Oe(t=>z[1](t)>0?e(t):void 0),Os=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},Ee=e=>K(Os(e[0]),Cs(e[1]));Ee.enc=Os,Ee.dec=Cs;var Rs=(e,t)=>Oe(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Ts=(e,t)=>({success:n,value:r})=>We([z[0](n?0:1),(n?e:t)(r)]),rn=(e,t)=>K(Ts(e[0],t[0]),Rs(e[1],t[1]));rn.dec=Rs,rn.enc=Ts;var Ps=(...e)=>Oe(t=>e.map(n=>n(t))),Us=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),Re=(...e)=>K(Us(...e.map(([t])=>t)),Ps(...e.map(([,t])=>t)));Re.enc=Us,Re.dec=Ps;var Ms=e=>{const t=Object.keys(e);return An(Re.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ls=e=>{const t=Object.keys(e);return $n(Re.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},U=e=>K(Ms(kn(e,t=>t[0])),Ls(kn(e,t=>t[1])));U.enc=Ms,U.dec=Ls;var Vs=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([pe.enc(n.length),We(n.map(e))]),Ds=(e,t)=>Oe(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>K(Vs(e[0],t),Ds(e[1],t));V.enc=Vs,V.dec=Ds;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ac(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Hs(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function hr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Fs(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function dr(e){if(!Array.isArray(e))throw new Error("array expected")}function zs(e,t){if(!Hs(!0,t))throw new Error(`${e}: array of strings expected`)}function $c(e,t){if(!Hs(!1,t))throw new Error(`${e}: array of numbers expected`)}function Sc(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Ic(e){const t=typeof e=="string"?e.split(""):e,n=t.length;zs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(dr(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(dr(s),s.map(o=>{hr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function Bc(e=""){return hr("join",e),{encode:t=>(zs("join.decode",t),t.join(e)),decode:t=>(hr("join.decode",t),t.split(e))}}function js(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(dr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(Fs(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,l=!0;for(let c=r;c<i;c++){const u=o[c],v=t*a,h=v+u;if(!Number.isSafeInteger(h)||v/t!==a||h-u!==v)throw new Error("convertRadix: carry overflow");const f=h/n;a=h%n;const d=Math.floor(f);if(o[c]=d,!Number.isSafeInteger(d)||d*n+a!==h)throw new Error("convertRadix: carry overflow");if(l)d?l=!1:r=c;else continue}if(s.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function _c(e){Fs(e);const t=2**8;return{encode:n=>{if(!Ac(n))throw new Error("radix.encode input should be Uint8Array");return js(Array.from(n),t,e)},decode:n=>($c("radix.decode",n),Uint8Array.from(js(n,e,t)))}}const Ws=(e=>Sc(_c(58),Ic(e),Bc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Cc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Te(e,t,n=""){const r=Cc(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",l=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+l)}return e}function sn(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 pr(e,t){Te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function Oc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function $t(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sn(e,t){return e<<32-t|e>>>t}const qs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ns(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=qs?e=>e:e=>Ns(e);function Rc(e){for(let t=0;t<e.length;t++)e[t]=Ns(e[t]);return e}const ge=qs?e=>e:Rc;function vr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const Tc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ft(e,t,n,r,s){return e=e+t+s|0,r=Sn(r^e,16),n=n+r|0,t=Sn(t^n,12),{a:e,b:t,c:n,d:r}}function ht(e,t,n,r,s){return e=e+t+s|0,r=Sn(r^e,8),n=n+r|0,t=Sn(t^n,7),{a:e,b:t,c:n,d:r}}const Pc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),In=BigInt(2**32-1),Ks=BigInt(32);function Bn(e,t=!1){return t?{h:Number(e&In),l:Number(e>>Ks&In)}:{h:Number(e>>Ks&In)|0,l:Number(e&In)|0}}function Uc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:a}=Bn(e[o],t);[r[o],s[o]]=[i,a]}return[r,s]}const Xs=(e,t,n)=>e>>>n|t<<32-n,Ys=(e,t,n)=>e<<32-n|t>>>n,Mc=(e,t,n)=>e<<64-n|t>>>n-32,Lc=(e,t,n)=>e>>>n-32|t<<64-n,Vc=(e,t)=>t,Dc=(e,t)=>e,Hc=(e,t,n)=>e<<n|t>>>32-n,Fc=(e,t,n)=>t<<n|e>>>32-n,zc=(e,t,n)=>t<<n-32|e>>>64-n,jc=(e,t,n)=>e<<n-32|t>>>64-n;function Gs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Qs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Zs=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,oe=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function dt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let l=S[2*e],c=S[2*e+1],u=S[2*t],v=S[2*t+1],h=S[2*n],f=S[2*n+1],d=S[2*r],p=S[2*r+1],m=Qs(l,u,i);c=Zs(m,c,v,a),l=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^l},{Dh:p,Dl:d}={Dh:Vc(p,d),Dl:Dc(p)},{h:f,l:h}=Gs(f,h,p,d),{Bh:v,Bl:u}={Bh:v^f,Bl:u^h},{Bh:v,Bl:u}={Bh:Xs(v,u,24),Bl:Ys(v,u,24)},S[2*e]=l,S[2*e+1]=c,S[2*t]=u,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=f,S[2*r]=d,S[2*r+1]=p}function pt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let l=S[2*e],c=S[2*e+1],u=S[2*t],v=S[2*t+1],h=S[2*n],f=S[2*n+1],d=S[2*r],p=S[2*r+1],m=Qs(l,u,i);c=Zs(m,c,v,a),l=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^l},{Dh:p,Dl:d}={Dh:Xs(p,d,16),Dl:Ys(p,d,16)},{h:f,l:h}=Gs(f,h,p,d),{Bh:v,Bl:u}={Bh:v^f,Bl:u^h},{Bh:v,Bl:u}={Bh:Mc(v,u,63),Bl:Lc(v,u,63)},S[2*e]=l,S[2*e+1]=c,S[2*t]=u,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=f,S[2*r]=d,S[2*r+1]=p}function Wc(e,t={},n,r,s){if(Lt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:a}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);i!==void 0&&Te(i,r,"salt"),a!==void 0&&Te(a,s,"personalization")}class Js{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Lt(t),Lt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=$t(this.buffer)}update(t){sn(this),Te(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,a=t.buffer;for(let l=0;l<o;){this.pos===n&&(ge(s),this.compress(s,0,!1),ge(s),this.pos=0);const c=Math.min(n-this.pos,o-l),u=i+l;if(c===n&&!(u%4)&&l+c<o){const v=new Uint32Array(a,u,Math.floor((o-l)/4));ge(v);for(let h=0;l+n<o;h+=s.length,l+=n)this.length+=n,this.compress(v,h,!1);ge(v);continue}r.set(t.subarray(l,l+c),this.pos),this.pos+=c,this.length+=c,l+=c}return this}digestInto(t){sn(this),pr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),ge(r),this.compress(r,0,!0),ge(r);const s=$t(t);this.get().forEach((o,i)=>s[i]=tt(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:a}=this;return t||=new this.constructor({dkLen:i}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=a,t.outputLen=i,t}clone(){return this._cloneInto()}}class qc extends Js{v0l=oe[0]|0;v0h=oe[1]|0;v1l=oe[2]|0;v1h=oe[3]|0;v2l=oe[4]|0;v2h=oe[5]|0;v3l=oe[6]|0;v3h=oe[7]|0;v4l=oe[8]|0;v4h=oe[9]|0;v5l=oe[10]|0;v5h=oe[11]|0;v6l=oe[12]|0;v6h=oe[13]|0;v7l=oe[14]|0;v7h=oe[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Wc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Te(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Te(o,void 0,"salt");const a=$t(o);this.v4l^=tt(a[0]),this.v4h^=tt(a[1]),this.v5l^=tt(a[2]),this.v5h^=tt(a[3])}if(s!==void 0){Te(s,void 0,"personalization");const a=$t(s);this.v6l^=tt(a[0]),this.v6h^=tt(a[1]),this.v7l^=tt(a[2]),this.v7h^=tt(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:a,v3h:l,v4l:c,v4h:u,v5l:v,v5h:h,v6l:f,v6h:d,v7l:p,v7h:m}=this;return[t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m]}set(t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=a|0,this.v3h=l|0,this.v4l=c|0,this.v4h=u|0,this.v5l=v|0,this.v5h=h|0,this.v6l=f|0,this.v6h=d|0,this.v7l=p|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((l,c)=>S[c]=l),S.set(oe,16);let{h:s,l:o}=Bn(BigInt(this.length));S[24]=oe[8]^o,S[25]=oe[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const a=Tc;for(let l=0;l<12;l++)dt(0,4,8,12,t,n+2*a[i++]),pt(0,4,8,12,t,n+2*a[i++]),dt(1,5,9,13,t,n+2*a[i++]),pt(1,5,9,13,t,n+2*a[i++]),dt(2,6,10,14,t,n+2*a[i++]),pt(2,6,10,14,t,n+2*a[i++]),dt(3,7,11,15,t,n+2*a[i++]),pt(3,7,11,15,t,n+2*a[i++]),dt(0,5,10,15,t,n+2*a[i++]),pt(0,5,10,15,t,n+2*a[i++]),dt(1,6,11,12,t,n+2*a[i++]),pt(1,6,11,12,t,n+2*a[i++]),dt(2,7,8,13,t,n+2*a[i++]),pt(2,7,8,13,t,n+2*a[i++]),dt(3,4,9,14,t,n+2*a[i++]),pt(3,4,9,14,t,n+2*a[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],ut(S)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const _n=vr(e=>new qc(e));function eo(e,t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:s,b:l,c:h,d:m}=ft(s,l,h,m,n[t+e[w++]])),{a:s,b:l,c:h,d:m}=ht(s,l,h,m,n[t+e[w++]]),{a:o,b:c,c:f,d:b}=ft(o,c,f,b,n[t+e[w++]]),{a:o,b:c,c:f,d:b}=ht(o,c,f,b,n[t+e[w++]]),{a:i,b:u,c:d,d:y}=ft(i,u,d,y,n[t+e[w++]]),{a:i,b:u,c:d,d:y}=ht(i,u,d,y,n[t+e[w++]]),{a,b:v,c:p,d:g}=ft(a,v,p,g,n[t+e[w++]]),{a,b:v,c:p,d:g}=ht(a,v,p,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ft(s,c,d,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ht(s,c,d,g,n[t+e[w++]]),{a:o,b:u,c:p,d:m}=ft(o,u,p,m,n[t+e[w++]]),{a:o,b:u,c:p,d:m}=ht(o,u,p,m,n[t+e[w++]]),{a:i,b:v,c:h,d:b}=ft(i,v,h,b,n[t+e[w++]]),{a:i,b:v,c:h,d:b}=ht(i,v,h,b,n[t+e[w++]]),{a,b:l,c:f,d:y}=ft(a,l,f,y,n[t+e[w++]]),{a,b:l,c:f,d:y}=ht(a,l,f,y,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:a,v4:l,v5:c,v6:u,v7:v,v8:h,v9:f,v10:d,v11:p,v12:m,v13:b,v14:y,v15:g}}const to=new TextEncoder().encode("SS58PRE"),mr=2,yr=e=>{try{const t=Ws.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-mr),s=t.subarray(n.length+r.length),o=_n(Uint8Array.of(...to,...n,...r),{dkLen:64}).subarray(0,mr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Nc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Nc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Kc=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,a;++n===1&&s();let l=t;const c=o.length-1;for(let u=0;u<=c;u++)l=l[i=o[u]]||(l[i]={});return l[a=o[c]]||(l[a]=e(o))}},no=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Kc(n=>{const r=_n(Uint8Array.of(...to,...t,...n),{dkLen:64}).subarray(0,mr);return Ws.encode(Uint8Array.of(...t,...n,...r))})};function Xc(e,t){return n=>{const r=yr(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const St=(e=42,t=32)=>qe(ee(t),Xc(t),no(e)),ro="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=ro[r>>4]+ro[r&15]}return t.join("")}const br={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|br[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=br[e[i]],l=br[e[i+1]];s[t+o++]=a<<4|l}return s}function Vt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ie=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},It=Function.prototype;class so extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Yc=Object.defineProperty,oo=e=>{throw TypeError(e)},Gc=(e,t,n)=>t in e?Yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t,n)=>Gc(e,typeof t!="symbol"?t+"":t,n),io=(e,t,n)=>t.has(e)||oo("Cannot "+n),nt=(e,t,n)=>(io(e,t,"read from private field"),n?n.call(e):t.get(e)),an=(e,t,n)=>t.has(e)?oo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bt=(e,t,n,r)=>(io(e,t,"write to private field"),t.set(e,n),n),rt,cn,Cn,On,Rn;const Qc=new TextEncoder,Zc=new TextDecoder,Jc=Re(pe,ee(1/0))[1];class Ke{constructor(t,n=!1){if(an(this,rt),an(this,cn,null),an(this,Cn,null),an(this,On,null),an(this,Rn,null),on(this,"asText",()=>nt(this,Rn)??Bt(this,Rn,Zc.decode(nt(this,rt)))),on(this,"asHex",()=>nt(this,Cn)??Bt(this,Cn,Z(nt(this,rt)))),on(this,"asOpaqueHex",()=>nt(this,On)??Bt(this,On,Z(this.asBytes()))),on(this,"asBytes",()=>nt(this,rt)),on(this,"asOpaqueBytes",()=>nt(this,cn)??Bt(this,cn,ie([nt(this,rt),pe[0](nt(this,rt).length)]))),n){try{const[r,s]=Jc(t);if(r===s.length){Bt(this,rt,s),Bt(this,cn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Bt(this,rt,t)}static fromText(t){return new this(Qc.encode(t))}static fromHex(t){return new this(ve(t))}static fromOpaqueHex(t){return new this(ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,cn=new WeakMap,Cn=new WeakMap,On=new WeakMap,Rn=new WeakMap;const[el]=St();class Tn extends Ke{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(el(t))}}const ao=e=>{const t=ee.enc(e);return n=>t(n.asBytes())},co=e=>{const t=ee.dec(e),n=e==null?Ke:Tn;return r=>n.fromBytes(t(r))},ln=e=>K(ao(e),co(e));ln.enc=ao,ln.dec=co;const C=qe(pe,e=>e,Number),Pn=qe(pe,e=>e,BigInt),tl=et(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:ee(n).dec(e),bitsLen:t}}),nl=K(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},tl),rl=qe(z,e=>e.charCodeAt(0),String.fromCharCode),lo=e=>{const t=ee.enc(e);return n=>t(ve(n))},uo=e=>{const t=ee.dec(e);return n=>Z(t(n))},we=e=>K(lo(e),uo(e));we.enc=lo,we.dec=uo;const fo=new TextEncoder,sl=new TextDecoder,ol=e=>qe(ee(e),t=>fo.encode(t),t=>sl.decode(t)),ho=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},po=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},gr=e=>K(ho(()=>e().enc),po(()=>e().dec)),_t=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),vo=new Proxy({},{get(e,t){return n=>_t(t,n)}}),te=(e,t)=>{const n=e;return n.inner=t,n},mo=(...e)=>{const t=xe.enc(...e);return te(n=>t({tag:n.type,value:n.value}),e[0])},yo=(...e)=>{const t=xe.dec(...e);return te(n=>{const{tag:r,value:s}=t(n);return _t(r,s)},e[0])},ke=(e,...t)=>te(K(mo(Vt(e,([n])=>n),...t),yo(Vt(e,([,n])=>n),...t)),e);ke.enc=mo,ke.dec=yo;const wr=(e,...t)=>te(xe(e,...t),e);wr.enc=(e,...t)=>te(xe.enc(e,...t),e),wr.dec=(e,...t)=>te(xe.dec(e,...t),e);const Xe={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=Pc.slice(),bo=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class xr extends Js{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');Te(r,32,"key");const i=r.slice();this.IV=$t(i),ge(this.IV),this.flags=n|Xe.KEYED_HASH}else if(o){Te(s,void 0,"context");const i=s,a=new xr({dkLen:32},Xe.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=$t(a),ge(this.IV),this.flags=n|Xe.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Oc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:a,l}=Bn(BigInt(t),!0),{v0:c,v1:u,v2:v,v3:h,v4:f,v5:d,v6:p,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:E,v14:B,v15:O}=eo(bo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],a,l,i,n);o[0]=c^b,o[1]=u^y,o[2]=v^g,o[3]=h^w,o[4]=f^x,o[5]=d^E,o[6]=p^B,o[7]=m^O}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Xe.CHUNK_START),(this.chunkPos===15||r)&&(s|=Xe.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,a=this.chunksDone+1;(r||!(a&1))&&(i=this.stack.pop());a>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Xe.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:a,stack:l,chunksDone:c}=this;return t.state.set(s.slice()),t.stack=l.map(u=>Uint32Array.from(u)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=c,t.posOut=i,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:a}=Bn(BigInt(this.chunkOut++));ge(s);const{v0:l,v1:c,v2:u,v3:v,v4:h,v5:f,v6:d,v7:p,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:E,v15:B}=eo(bo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],a,i,n,r);o[0]=l^m,o[1]=c^b,o[2]=u^y,o[3]=v^g,o[4]=h^w,o[5]=f^x,o[6]=d^E,o[7]=p^B,o[8]=t[0]^m,o[9]=t[1]^b,o[10]=t[2]^y,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^x,o[14]=t[6]^E,o[15]=t[7]^B,ge(s),ge(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Xe.ROOT;this.stack.length?(t|=Xe.PARENT,ge(this.buffer32),this.compress(this.buffer32,0,!0),ge(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Xe.CHUNK_START)|Xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){sn(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pr(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const il=vr((e={})=>new xr(e)),al=BigInt(0),un=BigInt(1),cl=BigInt(2),ll=BigInt(7),ul=BigInt(256),fl=BigInt(113),go=[],wo=[],xo=[];for(let e=0,t=un,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],go.push(2*(5*r+n)),wo.push((e+1)*(e+2)/2%64);let s=al;for(let o=0;o<7;o++)t=(t<<un^(t>>ll)*fl)%ul,t&cl&&(s^=un<<(un<<BigInt(o))-un);xo.push(s)}const Eo=Uc(xo,!0),hl=Eo[0],dl=Eo[1],ko=(e,t,n)=>n>32?zc(e,t,n):Hc(e,t,n),Ao=(e,t,n)=>n>32?jc(e,t,n):Fc(e,t,n);function pl(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,l=(i+2)%10,c=n[l],u=n[l+1],v=ko(c,u,1)^n[a],h=Ao(c,u,1)^n[a+1];for(let f=0;f<50;f+=10)e[i+f]^=v,e[i+f+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const a=wo[i],l=ko(s,o,a),c=Ao(s,o,a),u=go[i];s=e[u],o=e[u+1],e[u]=l,e[u+1]=c}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=hl[r],e[1]^=dl[r]}ut(n)}class Er{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Lt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=$t(this.state)}clone(){return this._cloneInto()}keccak(){ge(this.state32),pl(this.state32,this.rounds),ge(this.state32),this.posOut=0,this.pos=0}update(t){sn(this),Te(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let a=0;a<i;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){sn(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new Er(n,r,s,i,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const kr=((e,t,n,r={})=>vr(()=>new Er(t,e,n),r))(1,136,32),$o=e=>{const t=e.slice(2),n=Z(kr(fo.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},vl=ee(20)[1],So=K(e=>{const t=ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if($o(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},et(e=>$o(Z(vl(e))))),ue=e=>te(U(e),e);ue.enc=e=>te(U.enc(e),e),ue.dec=e=>te(U.dec(e),e);const Fe=(...e)=>te(Re(...e),e);Fe.enc=(...e)=>te(Re.enc(...e),e),Fe.dec=(...e)=>te(Re.dec(...e),e);const Ie=(e,...t)=>te(V(e,...t),e);Ie.enc=(e,...t)=>te(V.enc(e,...t),e),Ie.dec=(e,...t)=>te(V.dec(e,...t),e);const Un=(e,t)=>te(rn(e,t),{ok:e,ko:t});Un.enc=(e,t)=>te(rn.enc(e,t),{ok:e,ko:t}),Un.dec=(e,t)=>te(rn.dec(e,t),{ok:e,ko:t});const vt=e=>te(Ee(e),e);vt.enc=e=>te(Ee.enc(e),e),vt.dec=e=>te(Ee.dec(e),e);const Io=(e=!0)=>et(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=ee(r).dec(t),o=new Array(n);let i=0;return s.forEach(a=>{for(let l=0;l<8&&i<n;l++){const c=e?l:7-l;o[i++]=a>>c&1}}),o}),Bo=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,a=0;for(let l=0;l<8&&i<t.length;l++,i++)a|=t[i]<<(e?l:7-l);s[o]=a}return ie([n,s])},Mn=e=>K(Bo(e),Io(e));Mn.enc=Bo,Mn.dec=Io;const _o=new TextEncoder,Co=new TextDecoder,ml=qe(ee(4),_o.encode.bind(_o),Co.decode.bind(Co)),Ar=ue({engine:ml,payload:we()}),yl=ke({other:ee(),consensus:Ar,seal:Ar,preRuntime:Ar,runtimeUpdated:P},[0,4,5,6,8]),$r=we(32),Ln=ue({parentHash:$r,number:C,stateRoot:$r,extrinsicRoot:$r,digests:Ie(yl)}),Be=V(q),Oo=Ee(q),bl=xe({bool:P,char:P,str:P,u8:P,u16:P,u32:P,u64:P,u128:P,u256:P,i8:P,i16:P,i32:P,i64:P,i128:P,i256:P}),Ro=V(U({name:Oo,type:C,typeName:Oo,docs:Be})),gl=U({len:He,type:C}),wl=U({bitStoreType:C,bitOrderType:C}),xl=V(U({name:q,fields:Ro,index:z,docs:Be})),El=xe({composite:Ro,variant:xl,sequence:C,array:gl,tuple:V(C),primitive:bl,compact:C,bitSequence:wl}),kl=U({name:q,type:Ee(C)}),Al=V(kl),$l=U({id:C,path:Be,params:Al,def:El,docs:Be}),Vn=V($l),Dt=xe({NotDeprecated:P,DeprecatedWithoutNote:P,Deprecated:U({note:q,since:Ee(q)})}),Sl=V(U({index:z,deprecation:xe({DeprecatedWithoutNote:P,Deprecated:U({note:q,since:Ee(q)})},[1,2])})),Sr={name:q,inputs:V(U({name:q,type:C})),output:C,docs:Be},Il=U({name:q,methods:V(U(Sr)),docs:Be}),Bl=U({name:q,methods:V(U({...Sr,deprecationInfo:Dt})),docs:Be,version:C,deprecationInfo:Dt}),_l=U({id:we(32),...Sr,deprecationInfo:Dt}),Cl=xe({Blake2128:P,Blake2256:P,Blake2128Concat:P,Twox128:P,Twox256:P,Twox64Concat:P,Identity:P}),Ol=V(Cl),Rl=U({hashers:Ol,key:C,value:C}),To={name:q,modifier:z,type:xe({plain:C,map:Rl}),fallback:we(),docs:Be},Ir=Ee(C),Po={name:q,storage:Ee(U({prefix:q,items:V(U(To))})),calls:Ir,events:Ir,constants:V(U({name:q,type:C,value:we(),docs:Be})),errors:Ir,index:z},Tl={...Po,docs:Be},Br=Ee(U({type:C,deprecationInfo:Sl})),Pl={name:q,storage:Ee(U({prefix:q,items:V(U({...To,deprecationInfo:Dt}))})),calls:Br,events:Br,constants:V(U({name:q,type:C,value:we(),docs:Be,deprecationInfo:Dt})),errors:Br,associatedTypes:V(U({name:q,type:C,docs:Be})),viewFns:V(_l),index:z,docs:Be,deprecationInfo:Dt},Ul=new Uint8Array,Uo=e=>K(()=>Ul,()=>e),Ml=U({type:C,version:z,signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Mo=U({lookup:Vn,pallets:V(U({...Po,docs:Uo([])})),extrinsic:Ml,type:C,apis:Uo([])}),Ll=U({version:z,address:C,call:C,signature:C,extra:C,signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Lo=U({lookup:Vn,pallets:V(U(Tl)),extrinsic:Ll,type:C,apis:V(Il),outerEnums:U({call:C,event:C,error:C}),custom:V(Re(q,U({type:C,value:we()})))}),Vl=U({version:V(z),address:C,call:C,signature:C,signedExtensionsByVersion:V(Re(z,V(C))),signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Vo=U({lookup:Vn,pallets:V(U(Pl)),extrinsic:Vl,apis:V(Bl),outerEnums:U({call:C,event:C,error:C}),custom:V(Re(q,U({type:C,value:we()})))}),Do=()=>{throw new Error("Unsupported metadata version!")},Ae=K(Do,Do),mt=U({magicNumber:He,metadata:xe({v0:Ae,v1:Ae,v2:Ae,v3:Ae,v4:Ae,v5:Ae,v6:Ae,v7:Ae,v8:Ae,v9:Ae,v10:Ae,v11:Ae,v12:Ae,v13:Ae,v14:Mo,v15:Lo,v16:Vo})}),_r=ee(),Dl=Ee(_r),Hl=Re(pe,_r),Cr=e=>{try{return mt.dec(e)}catch{}try{return mt.dec(Dl.dec(e))}catch{}try{return mt.dec(_r.dec(e))}catch{}try{return mt.dec(Hl.dec(e)[1])}catch{}throw null},Ht=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:a,pallets:l,outerEnums:c}=e;return{version:15,lookup:s,pallets:l.map(u=>({...u,calls:u.calls!=null?{type:u.calls}:void 0,events:u.events!=null?{type:u.events}:void 0,errors:u.errors!=null?{type:u.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:a,outerEnums:c,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Ct={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Or=qe(z,({version:e,type:t})=>e+(Ct[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Ct.bare||n===Ct.signed))return{version:t,type:Ct[n]};if(t===5&&(n===Ct.bare||n===Ct.general))return{version:t,type:Ct[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Fl={dkLen:32},Ft=e=>_n(e,Fl),zl={dkLen:16},Rr=e=>_n(e,zl),Ho=e=>ie([Rr(e),e]),jl={dkLen:32},Fo=e=>il(e,jl),Wl=e=>ie([Fo(e),e]),zo=e=>e,Ot=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Tr=2n**64n-1n,me=(e,t)=>e<<t&Tr|e>>64n-t,W=(e,t)=>e*t&Tr,ae=(e,t)=>e+t&Tr,ce=11400714785074694791n,_e=14029467366897019727n,jo=1609587929392839161n,fn=9650029242287828579n,Wo=2870177450012600261n;function yt(e,t=0n){let n=ae(ae(t,ce),_e),r=ae(t,_e),s=t,o=t-ce,i=e.length,a=0,l=null;(function(){let f=0,d=f+i;if(i){if(l=new Uint8Array(32),i<32){l.set(e.subarray(0,i),a),a+=i;return}if(f<=d-32){const p=d-32;do{let m;m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),n=W(me(ae(n,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),r=W(me(ae(r,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),s=W(me(ae(s,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),o=W(me(ae(o,W(m,_e)),31n),ce),f+=8}while(f<=p)}f<d&&(l.set(e.subarray(f,d),a),a=d-f)}})(),e=l||e;let c,u=0;for(i>=32?(c=me(n,1n),c=ae(c,me(r,7n)),c=ae(c,me(s,12n)),c=ae(c,me(o,18n)),n=W(me(W(n,_e),31n),ce),c=c^n,c=ae(W(c,ce),fn),r=W(me(W(r,_e),31n),ce),c=c^r,c=ae(W(c,ce),fn),s=W(me(W(s,_e),31n),ce),c=c^s,c=ae(W(c,ce),fn),o=W(me(W(o,_e),31n),ce),c=c^o,c=ae(W(c,ce),fn)):c=ae(t,Wo),c=ae(c,BigInt(i));u<=a-8;){let h=Ot(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]);h=W(me(W(h,_e),31n),ce),c=ae(W(me(c^h,27n),ce),fn),u+=8}if(u+4<=a){let h=W(Ot(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],0,0),ce);c=ae(W(me(c^h,23n),_e),jo),u+=4}for(;u<a;){const h=W(Ot(e[u++],0,0,0),Wo);c=W(me(c^h,11n),ce)}let v=c>>33n;return c=W(c^v,_e),v=c>>29n,c=W(c^v,jo),v=c>>32n,c^=v,c}const Dn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),t},qo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),n.setBigUint64(16,yt(e,2n),!0),n.setBigUint64(24,yt(e,3n),!0),t},No=e=>ie([nn.enc(yt(e)),e]),Ko=new TextEncoder,ql=new Map([[zo,0],[No,8],[Ho,16],[Rr,-16],[Ft,-32],[Dn,-16],[qo,-32]]),Xo=e=>{const t=Dn(Ko.encode(e));return(n,...r)=>{const s=ie([t,Dn(Ko.encode(n))]),o=Z(s),i=c=>{if(!c.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=ve(c.slice(o.length)),v=new Array(r.length);for(let h=0,f=0;h<r.length;h++){const[d,p]=r[h],m=ql.get(p);if(m==null)throw new Error("Unknown hasher");if(m<0){const b=m*-1;v[h]=Z(u.slice(f,f+b)),f+=b}else f+=m,v[h]=d.dec(u.slice(f)),f+=d.enc(v[h]).length}return v},a=r.map(([{enc:c},u])=>v=>u(c(v)));return{enc:(...c)=>Z(ie([s,...c.map((u,v)=>a[v](u))])),dec:i}}},Nl=Ke.fromText("modlpy/utilisuba").asBytes(),Kl=({threshold:e,signatories:t})=>{const n=Yo(t),r=ie([Nl,pe.enc(n.length),...n,Ne.enc(e)]);return Ft(r)},Yo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),bt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Go=we().dec,Xl=we(1/0).dec,Yl=we(32).dec,Qo=z.dec,Gl=e=>{const t=Qo(e);let n=6;const r=t>>n,s=r?r===1?bt.Leaf:r===2?bt.Branch:bt.BranchWithVal:t>>--n?bt.LeafWithHash:t>>--n?bt.BranchWithHash:t?bt.Reserved:bt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Qo(e);while(i===255)}return{type:s,partialKey:we(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Zo=et(e=>{const t=Gl(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Xl(e)};const r=Ne.dec(e),s=[];for(let a=0;a<16;a++)r>>a&1&&s.push(a.toString(16));let o=null;n==="BranchWithVal"&&(o=Go(e)),n==="BranchWithHash"&&(o=Yl(e));const i={...t,children:Object.fromEntries(s.map(a=>[a,Go(e)]))};return o!==null&&(i.value=o),i}),Jo=e=>et(t=>{const n=Z(e(new Uint8Array(t.buffer)));try{return{hash:n,...Zo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var ei=Object.freeze({__proto__:null,AccountId:St,Bin:ln,Binary:Ke,BitSeq:Mn,Blake2128:Rr,Blake2128Concat:Ho,Blake2256:Ft,Blake3256:Fo,Blake3256Concat:Wl,Bytes:ee,Enum:_t,FixedSizeBinary:Tn,Hex:we,Identity:zo,Keccak256:kr,Option:vt,Result:Un,ScaleEnum:wr,Self:gr,Storage:Xo,Struct:ue,TrieNodeHeaders:bt,TrieNodeWithHash:Jo,Tuple:Fe,Twox128:Dn,Twox256:qo,Twox64Concat:No,Variant:ke,Vector:Ie,_Enum:vo,_void:P,bitSequence:nl,blockHeader:Ln,bool:ac,char:rl,compact:pe,compactBn:Pn,compactNumber:C,createCodec:K,createDecoder:et,decAnyMetadata:Cr,enhanceCodec:qe,enhanceDecoder:$n,enhanceEncoder:An,ethAccount:So,extrinsicFormat:Or,fixedStr:ol,fromBufferToBase58:no,getMultisigAccountId:Kl,getSs58AddressInfo:yr,h64:yt,i128:sc,i16:tc,i256:ic,i32:nc,i64:rc,i8:ec,metadata:mt,selfDecoder:po,selfEncoder:ho,sortMultisigSignatories:Yo,str:q,trieNodeDec:Zo,u128:ks,u16:Ne,u256:oc,u32:He,u64:nn,u8:z,unifyMetadata:Ht,v14:Mo,v14Lookup:Vn,v15:Lo,v16:Vo,validateProofs:(e,t=Ft)=>{const n=e.map(Jo(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),s=n.map(a=>a.hash),o=new Set(s),i=a=>{if(a.value)return;const l=e[s.indexOf(a.hash)];a.value=typeof l=="string"?l:Z(l)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(l=>{const c=r[l];c&&(c.parent=a.hash,o.delete(l))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const l=a.value,c=r[l];if(!c)return;o.delete(l),c.type!=="Raw"&&(Object.keys(c).forEach(u=>delete c[u]),c.type="Raw",c.hash=l),c.parent=a.hash,i(c)}a.type==="Raw"&&i(a)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const ot=C,Ql=Ie(Fe(q,ot)),N={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Zl=ke(Object.fromEntries(Object.values(N).map(e=>[e,P]))),Jl=Ie(Fe(q,ke({inline:gr(()=>Pr),lookup:ot}))),eu=Ie(ot),tu=ue({typeRef:ot,length:vt(ot)}),nu=vt(ot),ru=ot,su=ue({ok:ot,ko:ot}),Pr=ke({struct:Ql,terminal:Zl,enum:Jl,tuple:eu,array:tu,binary:nu,option:ru,result:su}),ou={i256:N.big,i128:N.big,i64:N.big,i32:N.num,i16:N.num,i8:N.num,u256:N.big,u128:N.big,u64:N.big,u32:N.num,u16:N.num,u8:N.num,bool:N.bool,char:N.str,str:N.str},hn=e=>({type:"terminal",value:{type:e}});function Hn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return hn(N.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return hn(N.bits);case"compact":return hn(e.isBig?N.big:N.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Hn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return hn(ou[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return hn(N.void)}}function Fn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Fn(o,i,n),s=o=>{switch(o.value.type){case N.str:case N.big:case N.bool:case N.num:return typeof e===o.value.type;case N.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case N.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e!=null&&typeof e.asBytes=="function"&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,a=Object.fromEntries(t.value);if(!(i.type in a))return!1;const l=a[i.type];return l==null?!0:r(i.value,l.type==="inline"?l.value:n(l.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,u])=>r(e[c],n(u))):!1;case"tuple":return e?t.value.every((c,u)=>r(e[u],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}function iu(e,t,n,r){if(e.length>t)return!1;let s=[n];return t>1&&(n.type==="tuple"?s=n.value.map(r):n.type==="array"&&n.value.length&&(s=new Array(n.value.length).fill(r(n.value.typeRef)))),e.every((o,i)=>Fn(o,s[i],r))}var au=Object.defineProperty,cu=(e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lu=(e,t,n)=>cu(e,t+"",n);class ti{constructor(t=[]){lu(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Pe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Pe||{});function Ur(e,t,n,r,s,o=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const l=i.get(e);return l==null?{level:3,changes:[],assumptions:new ti([[e,n]])}:ze(l.level,l.changes)}i.set(e,null);const a=uu(e,n,(l,c)=>Ur(typeof l=="number"?t(l):l,t,typeof c=="number"?r(c):c,r,s),o);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?i.set(e,a):i.delete(e),a}function uu(e,t,n,r){const s=(o,i,a)=>{const l=n(o,i);return{...l,changes:l.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:l.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?zn(s(e,t.value,"some"),2):e.type==="option"?zn(s(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Lr(si(e.value,t.value));case"array":const i=e,a=Lr(si(i.value.length,t.value.length));return Mr([a,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const h=e,f=Object.fromEntries(t.value.map(([m,b])=>[m,b.value]));let d=ri(h.value.map(([m,b])=>()=>m in f?s(b.value,f[m],m):ze(0,[{id:[typeof b.value=="number"?b.value:null,null],level:0,path:m}])));if(h.value.length===t.value.length)return d;d=zn(d,2);const p=new Set(h.value.map(([m])=>m));return d.changes=[...d.changes,...t.value.filter(([m])=>!p.has(m)).map(([m,b])=>({id:[null,typeof b=="number"?b:null],level:0,path:m}))],d}case"option":return fu(s(e.value,t.value,"some"),1);case"struct":const l=e,c=Object.fromEntries(l.value),u=l.value.length===t.value.length?3:2;return zn(Mr(t.value.map(([h,f])=>()=>s(c[h],f,h)),r),u);case"tuple":{const h=e,f=Lr(hu(h.value,t.value));return Mr([f,...t.value.map((d,p)=>()=>s(h.value[p],d,String(p)))],r)}case"result":const v=e;return ri([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const zn=(e,t)=>({...e,level:Math.min(e.level,t)}),fu=(e,t)=>({...e,level:Math.max(e.level,t)}),ni=new ti,ze=(e,t)=>({level:e,changes:t,assumptions:ni}),Mr=(e,t)=>{let n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},ri=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:ze(0,n.changes)},Lr=e=>({assumptions:ni,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),hu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,si=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,oi=ke({lookup:C,typedef:Pr}),zt=e=>({type:"lookup",value:e}),Vr=e=>({type:"typedef",value:e}),jn=Vr({type:"terminal",value:{type:N.void}}),du=ue({args:oi,values:oi});function pu(e){if(e.type.tag==="plain")return{args:jn,values:zt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:zt(t),values:zt(n)}}function ii(e){return{args:Vr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:zt(e.output)}}function vu(e){return e.type==="lookupEntry"?zt(e.value.id):Vr(Hn(e))}function mu(e){return{args:jn,values:zt(e)}}function yu(e,t,n,r,s,o){const i=(a,l)=>a.type==="lookup"?l(a.value):a.value;return{args:Ur(i(e.args,t),t,i(n.args,r),r,s,o),values:Ur(i(n.values,r),r,i(e.values,t),t,s,o)}}function ai(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Fn(n,r,t)}var Dr=function(e,t){return Dr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Dr(e,t)};function Ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Dr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function bu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(v){i(v)}}function l(u){try{c(r.throw(u))}catch(v){i(v)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(e,t||[])).next())})}function ci(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,s=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(u){c=[6,u],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function jt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ue(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Me(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function Wt(e){return this instanceof Wt?(this.v=e,this):new Wt(e)}function gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(d){return Promise.resolve(d).then(f,v)}}function a(f,d){r[f]&&(s[f]=function(p){return new Promise(function(m,b){o.push([f,p,m,b])>1||l(f,p)})},d&&(s[f]=d(s[f])))}function l(f,d){try{c(r[f](d))}catch(p){h(o[0][3],p)}}function c(f){f.value instanceof Wt?Promise.resolve(f.value.v).then(u,v):h(o[0][2],f)}function u(f){l("next",f)}function v(f){l("throw",f)}function h(f,d){f(d),o.shift(),o.length&&l(o[0][0],o[0][1])}}function wu(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof jt=="function"?jt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(a,l){i=e[o](i),s(a,l,i.done,i.value)})}}function s(o,i,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},i)}}typeof SuppressedError=="function"&&SuppressedError;function Q(e){return typeof e=="function"}function Hr(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Fr=Hr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(de,tn){typeof exports=="object"&&typeof module<"u"?tn(exports):typeof define=="function"&&define.amd?define(["exports"],tn):(de=typeof globalThis<"u"?globalThis:de||self,tn(de.papi={}))})(this,(function(de){"use strict";var tn=Object.defineProperty,Ga=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gs=(e,t,n)=>(Ga(e,typeof t!="symbol"?t+"":t,n),n),fr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Qa(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|fr[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=fr[e[i]],l=fr[e[i+1]];s[t+o++]=a<<4|l}return s}var ws=class extends Uint8Array{constructor(e){super(e),gs(this,"i",0),gs(this,"v"),this.v=new DataView(e)}},Oe=e=>t=>e(t instanceof ws?t:new ws(t instanceof Uint8Array?t.buffer:typeof t=="string"?Qa(t).buffer:t)),We=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function kn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var et=Oe,K=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},An=(e,t)=>n=>e(t(n)),$n=(e,t)=>n=>t(e(n)),qe=([e,t],n,r)=>K(An(e,n),$n(t,r));function Za(e,t){return Oe(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ja(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function lt(e,t,n){return K(Ja(e,n),Za(e,t))}var z=lt(1,"getUint8","setUint8"),Ne=lt(2,"getUint16","setUint16"),He=lt(4,"getUint32","setUint32"),nn=lt(8,"getBigUint64","setBigUint64"),ec=lt(1,"getInt8","setInt8"),tc=lt(2,"getInt16","setInt16"),nc=lt(4,"getInt32","setInt32"),rc=lt(8,"getBigInt64","setBigInt64"),xs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Es=e=>Oe(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),ks=K(xs,Es("getBigUint64")),sc=K(xs,Es("getBigInt64")),As=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},$s=e=>Oe(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),oc=K(As,$s("getBigUint64")),ic=K(As,$s("getBigInt64")),ac=qe(z,e=>e?1:0,Boolean),cc=[z[1],Ne[1],He[1]],lc=Oe(e=>{const t=e[e.i],n=t&3;if(n<3)return cc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let l=0;l<o;l++)s=nn[1](e)<<i|s,i+=64n;let a=r%8;return a>3&&(s=BigInt(He[1](e))<<i|s,i+=32n,a-=4),a>1&&(s=BigInt(Ne[1](e))<<i|s,i+=16n,a-=2),a&&(s=BigInt(z[1](e))<<i|s),s}),uc=1n<<56n,fc=1<<24,hc=256,dc=4294967295n,pc=64,vc=16384,mc=1<<30,yc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<pc)return z[0](t);if(e<vc)return Ne[0](t|1);if(e<mc)return He[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=uc;)n.push(nn[0](r)),r>>=64n;r>=fc&&(n.push(He[0](Number(r&dc))),r>>=32n);let s=Number(r);s>=hc&&(n.push(Ne[0](s)),s>>=16),s&&n.push(z[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},pe=K(yc,lc),bc=new TextEncoder,gc=e=>{const t=bc.encode(e);return We([pe.enc(t.length),t])},wc=new TextDecoder,xc=Oe(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,wc.decode(n)}),q=K(gc,xc),Ec=()=>{},kc=new Uint8Array(0),P=K(()=>kc,Ec),Ss=e=>e===void 0?t=>We([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Is=e=>Oe(t=>{const n=e===void 0?pe.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),ee=e=>K(Ss(e),Is(e));ee.enc=Ss,ee.dec=Is;var Bs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>We([z.enc(s(o)),e[o](i)])},_s=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Oe(s=>{const o=z.dec(s),i=r.get(o),a=e[i];return{tag:i,value:a(s)}})},xe=(e,...t)=>K(Bs(kn(e,([n])=>n),...t),_s(kn(e,([,n])=>n),...t));xe.enc=Bs,xe.dec=_s;var Cs=e=>Oe(t=>z[1](t)>0?e(t):void 0),Os=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},Ee=e=>K(Os(e[0]),Cs(e[1]));Ee.enc=Os,Ee.dec=Cs;var Rs=(e,t)=>Oe(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Ts=(e,t)=>({success:n,value:r})=>We([z[0](n?0:1),(n?e:t)(r)]),rn=(e,t)=>K(Ts(e[0],t[0]),Rs(e[1],t[1]));rn.dec=Rs,rn.enc=Ts;var Ps=(...e)=>Oe(t=>e.map(n=>n(t))),Us=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),Re=(...e)=>K(Us(...e.map(([t])=>t)),Ps(...e.map(([,t])=>t)));Re.enc=Us,Re.dec=Ps;var Ms=e=>{const t=Object.keys(e);return An(Re.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ls=e=>{const t=Object.keys(e);return $n(Re.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},U=e=>K(Ms(kn(e,t=>t[0])),Ls(kn(e,t=>t[1])));U.enc=Ms,U.dec=Ls;var Vs=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([pe.enc(n.length),We(n.map(e))]),Ds=(e,t)=>Oe(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),V=(e,t)=>K(Vs(e[0],t),Ds(e[1],t));V.enc=Vs,V.dec=Ds;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ac(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Hs(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function hr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Fs(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function dr(e){if(!Array.isArray(e))throw new Error("array expected")}function zs(e,t){if(!Hs(!0,t))throw new Error(`${e}: array of strings expected`)}function $c(e,t){if(!Hs(!1,t))throw new Error(`${e}: array of numbers expected`)}function Sc(...e){const t=o=>o,n=(o,i)=>a=>o(i(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Ic(e){const t=typeof e=="string"?e.split(""):e,n=t.length;zs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(dr(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(dr(s),s.map(o=>{hr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function Bc(e=""){return hr("join",e),{encode:t=>(zs("join.decode",t),t.join(e)),decode:t=>(hr("join.decode",t),t.split(e))}}function js(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(dr(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,a=>{if(Fs(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),i=o.length;for(;;){let a=0,l=!0;for(let c=r;c<i;c++){const u=o[c],v=t*a,h=v+u;if(!Number.isSafeInteger(h)||v/t!==a||h-u!==v)throw new Error("convertRadix: carry overflow");const f=h/n;a=h%n;const d=Math.floor(f);if(o[c]=d,!Number.isSafeInteger(d)||d*n+a!==h)throw new Error("convertRadix: carry overflow");if(l)d?l=!1:r=c;else continue}if(s.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function _c(e){Fs(e);const t=2**8;return{encode:n=>{if(!Ac(n))throw new Error("radix.encode input should be Uint8Array");return js(Array.from(n),t,e)},decode:n=>($c("radix.decode",n),Uint8Array.from(js(n,e,t)))}}const Ws=(e=>Sc(_c(58),Ic(e),Bc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Cc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lt(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function Te(e,t,n=""){const r=Cc(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const i=n&&`"${n}" `,a=o?` of length ${t}`:"",l=r?`length=${s}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+l)}return e}function sn(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 pr(e,t){Te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function Oc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function $t(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ut(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sn(e,t){return e<<32-t|e>>>t}const qs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ns(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=qs?e=>e:e=>Ns(e);function Rc(e){for(let t=0;t<e.length;t++)e[t]=Ns(e[t]);return e}const ge=qs?e=>e:Rc;function vr(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const Tc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ft(e,t,n,r,s){return e=e+t+s|0,r=Sn(r^e,16),n=n+r|0,t=Sn(t^n,12),{a:e,b:t,c:n,d:r}}function ht(e,t,n,r,s){return e=e+t+s|0,r=Sn(r^e,8),n=n+r|0,t=Sn(t^n,7),{a:e,b:t,c:n,d:r}}const Pc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),In=BigInt(2**32-1),Ks=BigInt(32);function Bn(e,t=!1){return t?{h:Number(e&In),l:Number(e>>Ks&In)}:{h:Number(e>>Ks&In)|0,l:Number(e&In)|0}}function Uc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:a}=Bn(e[o],t);[r[o],s[o]]=[i,a]}return[r,s]}const Xs=(e,t,n)=>e>>>n|t<<32-n,Ys=(e,t,n)=>e<<32-n|t>>>n,Mc=(e,t,n)=>e<<64-n|t>>>n-32,Lc=(e,t,n)=>e>>>n-32|t<<64-n,Vc=(e,t)=>t,Dc=(e,t)=>e,Hc=(e,t,n)=>e<<n|t>>>32-n,Fc=(e,t,n)=>t<<n|e>>>32-n,zc=(e,t,n)=>t<<n-32|e>>>64-n,jc=(e,t,n)=>e<<n-32|t>>>64-n;function Gs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Qs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Zs=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,oe=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function dt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let l=S[2*e],c=S[2*e+1],u=S[2*t],v=S[2*t+1],h=S[2*n],f=S[2*n+1],d=S[2*r],p=S[2*r+1],m=Qs(l,u,i);c=Zs(m,c,v,a),l=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^l},{Dh:p,Dl:d}={Dh:Vc(p,d),Dl:Dc(p)},{h:f,l:h}=Gs(f,h,p,d),{Bh:v,Bl:u}={Bh:v^f,Bl:u^h},{Bh:v,Bl:u}={Bh:Xs(v,u,24),Bl:Ys(v,u,24)},S[2*e]=l,S[2*e+1]=c,S[2*t]=u,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=f,S[2*r]=d,S[2*r+1]=p}function pt(e,t,n,r,s,o){const i=s[o],a=s[o+1];let l=S[2*e],c=S[2*e+1],u=S[2*t],v=S[2*t+1],h=S[2*n],f=S[2*n+1],d=S[2*r],p=S[2*r+1],m=Qs(l,u,i);c=Zs(m,c,v,a),l=m|0,{Dh:p,Dl:d}={Dh:p^c,Dl:d^l},{Dh:p,Dl:d}={Dh:Xs(p,d,16),Dl:Ys(p,d,16)},{h:f,l:h}=Gs(f,h,p,d),{Bh:v,Bl:u}={Bh:v^f,Bl:u^h},{Bh:v,Bl:u}={Bh:Mc(v,u,63),Bl:Lc(v,u,63)},S[2*e]=l,S[2*e+1]=c,S[2*t]=u,S[2*t+1]=v,S[2*n]=h,S[2*n+1]=f,S[2*r]=d,S[2*r+1]=p}function Wc(e,t={},n,r,s){if(Lt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:a}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);i!==void 0&&Te(i,r,"salt"),a!==void 0&&Te(a,s,"personalization")}class Js{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Lt(t),Lt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=$t(this.buffer)}update(t){sn(this),Te(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,a=t.buffer;for(let l=0;l<o;){this.pos===n&&(ge(s),this.compress(s,0,!1),ge(s),this.pos=0);const c=Math.min(n-this.pos,o-l),u=i+l;if(c===n&&!(u%4)&&l+c<o){const v=new Uint32Array(a,u,Math.floor((o-l)/4));ge(v);for(let h=0;l+n<o;h+=s.length,l+=n)this.length+=n,this.compress(v,h,!1);ge(v);continue}r.set(t.subarray(l,l+c),this.pos),this.pos+=c,this.length+=c,l+=c}return this}digestInto(t){sn(this),pr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ut(this.buffer.subarray(n)),ge(r),this.compress(r,0,!0),ge(r);const s=$t(t);this.get().forEach((o,i)=>s[i]=tt(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:a}=this;return t||=new this.constructor({dkLen:i}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=a,t.outputLen=i,t}clone(){return this._cloneInto()}}class qc extends Js{v0l=oe[0]|0;v0h=oe[1]|0;v1l=oe[2]|0;v1h=oe[3]|0;v2l=oe[4]|0;v2h=oe[5]|0;v3l=oe[6]|0;v3h=oe[7]|0;v4l=oe[8]|0;v4h=oe[9]|0;v5l=oe[10]|0;v5h=oe[11]|0;v6l=oe[12]|0;v6h=oe[13]|0;v7l=oe[14]|0;v7h=oe[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Wc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(Te(r,void 0,"key"),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){Te(o,void 0,"salt");const a=$t(o);this.v4l^=tt(a[0]),this.v4h^=tt(a[1]),this.v5l^=tt(a[2]),this.v5h^=tt(a[3])}if(s!==void 0){Te(s,void 0,"personalization");const a=$t(s);this.v6l^=tt(a[0]),this.v6h^=tt(a[1]),this.v7l^=tt(a[2]),this.v7h^=tt(a[3])}if(r!==void 0){const a=new Uint8Array(this.blockLen);a.set(r),this.update(a)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:a,v3h:l,v4l:c,v4h:u,v5l:v,v5h:h,v6l:f,v6h:d,v7l:p,v7h:m}=this;return[t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m]}set(t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=a|0,this.v3h=l|0,this.v4l=c|0,this.v4h=u|0,this.v5l=v|0,this.v5h=h|0,this.v6l=f|0,this.v6h=d|0,this.v7l=p|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((l,c)=>S[c]=l),S.set(oe,16);let{h:s,l:o}=Bn(BigInt(this.length));S[24]=oe[8]^o,S[25]=oe[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const a=Tc;for(let l=0;l<12;l++)dt(0,4,8,12,t,n+2*a[i++]),pt(0,4,8,12,t,n+2*a[i++]),dt(1,5,9,13,t,n+2*a[i++]),pt(1,5,9,13,t,n+2*a[i++]),dt(2,6,10,14,t,n+2*a[i++]),pt(2,6,10,14,t,n+2*a[i++]),dt(3,7,11,15,t,n+2*a[i++]),pt(3,7,11,15,t,n+2*a[i++]),dt(0,5,10,15,t,n+2*a[i++]),pt(0,5,10,15,t,n+2*a[i++]),dt(1,6,11,12,t,n+2*a[i++]),pt(1,6,11,12,t,n+2*a[i++]),dt(2,7,8,13,t,n+2*a[i++]),pt(2,7,8,13,t,n+2*a[i++]),dt(3,4,9,14,t,n+2*a[i++]),pt(3,4,9,14,t,n+2*a[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],ut(S)}destroy(){this.destroyed=!0,ut(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const _n=vr(e=>new qc(e));function eo(e,t,n,r,s,o,i,a,l,c,u,v,h,f,d,p,m,b,y,g){let w=0;for(let x=0;x<r;x++)({a:s,b:l,c:h,d:m}=ft(s,l,h,m,n[t+e[w++]])),{a:s,b:l,c:h,d:m}=ht(s,l,h,m,n[t+e[w++]]),{a:o,b:c,c:f,d:b}=ft(o,c,f,b,n[t+e[w++]]),{a:o,b:c,c:f,d:b}=ht(o,c,f,b,n[t+e[w++]]),{a:i,b:u,c:d,d:y}=ft(i,u,d,y,n[t+e[w++]]),{a:i,b:u,c:d,d:y}=ht(i,u,d,y,n[t+e[w++]]),{a,b:v,c:p,d:g}=ft(a,v,p,g,n[t+e[w++]]),{a,b:v,c:p,d:g}=ht(a,v,p,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ft(s,c,d,g,n[t+e[w++]]),{a:s,b:c,c:d,d:g}=ht(s,c,d,g,n[t+e[w++]]),{a:o,b:u,c:p,d:m}=ft(o,u,p,m,n[t+e[w++]]),{a:o,b:u,c:p,d:m}=ht(o,u,p,m,n[t+e[w++]]),{a:i,b:v,c:h,d:b}=ft(i,v,h,b,n[t+e[w++]]),{a:i,b:v,c:h,d:b}=ht(i,v,h,b,n[t+e[w++]]),{a,b:l,c:f,d:y}=ft(a,l,f,y,n[t+e[w++]]),{a,b:l,c:f,d:y}=ht(a,l,f,y,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:a,v4:l,v5:c,v6:u,v7:v,v8:h,v9:f,v10:d,v11:p,v12:m,v13:b,v14:y,v15:g}}const to=new TextEncoder().encode("SS58PRE"),mr=2,yr=e=>{try{const t=Ws.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-mr),s=t.subarray(n.length+r.length),o=_n(Uint8Array.of(...to,...n,...r),{dkLen:64}).subarray(0,mr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Nc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Nc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Kc=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var i,a;++n===1&&s();let l=t;const c=o.length-1;for(let u=0;u<=c;u++)l=l[i=o[u]]||(l[i]={});return l[a=o[c]]||(l[a]=e(o))}},no=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Kc(n=>{const r=_n(Uint8Array.of(...to,...t,...n),{dkLen:64}).subarray(0,mr);return Ws.encode(Uint8Array.of(...t,...n,...r))})};function Xc(e,t){return n=>{const r=yr(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const St=(e=42,t=32)=>qe(ee(t),Xc(t),no(e)),ro="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=ro[r>>4]+ro[r&15]}return t.join("")}const br={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|br[e[2]]);for(let o=0;o<r;){const i=n+o*2,a=br[e[i]],l=br[e[i+1]];s[t+o++]=a<<4|l}return s}function Vt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ie=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},It=Function.prototype;class so extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Yc=Object.defineProperty,oo=e=>{throw TypeError(e)},Gc=(e,t,n)=>t in e?Yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t,n)=>Gc(e,typeof t!="symbol"?t+"":t,n),io=(e,t,n)=>t.has(e)||oo("Cannot "+n),nt=(e,t,n)=>(io(e,t,"read from private field"),n?n.call(e):t.get(e)),an=(e,t,n)=>t.has(e)?oo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bt=(e,t,n,r)=>(io(e,t,"write to private field"),t.set(e,n),n),rt,cn,Cn,On,Rn;const Qc=new TextEncoder,Zc=new TextDecoder,Jc=Re(pe,ee(1/0))[1];class Ke{constructor(t,n=!1){if(an(this,rt),an(this,cn,null),an(this,Cn,null),an(this,On,null),an(this,Rn,null),on(this,"asText",()=>nt(this,Rn)??Bt(this,Rn,Zc.decode(nt(this,rt)))),on(this,"asHex",()=>nt(this,Cn)??Bt(this,Cn,Z(nt(this,rt)))),on(this,"asOpaqueHex",()=>nt(this,On)??Bt(this,On,Z(this.asOpaqueBytes()))),on(this,"asBytes",()=>nt(this,rt)),on(this,"asOpaqueBytes",()=>nt(this,cn)??Bt(this,cn,ie([pe[0](nt(this,rt).length),nt(this,rt)]))),n){try{const[r,s]=Jc(t);if(r===s.length){Bt(this,rt,s),Bt(this,cn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Bt(this,rt,t)}static fromText(t){return new this(Qc.encode(t))}static fromHex(t){return new this(ve(t))}static fromOpaqueHex(t){return new this(ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,cn=new WeakMap,Cn=new WeakMap,On=new WeakMap,Rn=new WeakMap;const[el]=St();class Tn extends Ke{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(el(t))}}const ao=e=>{const t=ee.enc(e);return n=>t(n.asBytes())},co=e=>{const t=ee.dec(e),n=e==null?Ke:Tn;return r=>n.fromBytes(t(r))},ln=e=>K(ao(e),co(e));ln.enc=ao,ln.dec=co;const C=qe(pe,e=>e,Number),Pn=qe(pe,e=>e,BigInt),tl=et(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:ee(n).dec(e),bitsLen:t}}),nl=K(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},tl),rl=qe(z,e=>e.charCodeAt(0),String.fromCharCode),lo=e=>{const t=ee.enc(e);return n=>t(ve(n))},uo=e=>{const t=ee.dec(e);return n=>Z(t(n))},we=e=>K(lo(e),uo(e));we.enc=lo,we.dec=uo;const fo=new TextEncoder,sl=new TextDecoder,ol=e=>qe(ee(e),t=>fo.encode(t),t=>sl.decode(t)),ho=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},po=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},gr=e=>K(ho(()=>e().enc),po(()=>e().dec)),_t=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),vo=new Proxy({},{get(e,t){return n=>_t(t,n)}}),te=(e,t)=>{const n=e;return n.inner=t,n},mo=(...e)=>{const t=xe.enc(...e);return te(n=>t({tag:n.type,value:n.value}),e[0])},yo=(...e)=>{const t=xe.dec(...e);return te(n=>{const{tag:r,value:s}=t(n);return _t(r,s)},e[0])},ke=(e,...t)=>te(K(mo(Vt(e,([n])=>n),...t),yo(Vt(e,([,n])=>n),...t)),e);ke.enc=mo,ke.dec=yo;const wr=(e,...t)=>te(xe(e,...t),e);wr.enc=(e,...t)=>te(xe.enc(e,...t),e),wr.dec=(e,...t)=>te(xe.dec(e,...t),e);const Xe={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=Pc.slice(),bo=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class xr extends Js{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');Te(r,32,"key");const i=r.slice();this.IV=$t(i),ge(this.IV),this.flags=n|Xe.KEYED_HASH}else if(o){Te(s,void 0,"context");const i=s,a=new xr({dkLen:32},Xe.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=$t(a),ge(this.IV),this.flags=n|Xe.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Oc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:a,l}=Bn(BigInt(t),!0),{v0:c,v1:u,v2:v,v3:h,v4:f,v5:d,v6:p,v7:m,v8:b,v9:y,v10:g,v11:w,v12:x,v13:E,v14:B,v15:O}=eo(bo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],a,l,i,n);o[0]=c^b,o[1]=u^y,o[2]=v^g,o[3]=h^w,o[4]=f^x,o[5]=d^E,o[6]=p^B,o[7]=m^O}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Xe.CHUNK_START),(this.chunkPos===15||r)&&(s|=Xe.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,a=this.chunksDone+1;(r||!(a&1))&&(i=this.stack.pop());a>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Xe.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:a,stack:l,chunksDone:c}=this;return t.state.set(s.slice()),t.stack=l.map(u=>Uint32Array.from(u)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=c,t.posOut=i,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ut(this.state,this.buffer32,this.IV,this.bufferOut32),ut(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:a}=Bn(BigInt(this.chunkOut++));ge(s);const{v0:l,v1:c,v2:u,v3:v,v4:h,v5:f,v6:d,v7:p,v8:m,v9:b,v10:y,v11:g,v12:w,v13:x,v14:E,v15:B}=eo(bo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],a,i,n,r);o[0]=l^m,o[1]=c^b,o[2]=u^y,o[3]=v^g,o[4]=h^w,o[5]=f^x,o[6]=d^E,o[7]=p^B,o[8]=t[0]^m,o[9]=t[1]^b,o[10]=t[2]^y,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^x,o[14]=t[6]^E,o[15]=t[7]^B,ge(s),ge(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ut(this.buffer.subarray(this.pos));let t=this.flags|Xe.ROOT;this.stack.length?(t|=Xe.PARENT,ge(this.buffer32),this.compress(this.buffer32,0,!0),ge(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Xe.CHUNK_START)|Xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){sn(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pr(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const il=vr((e={})=>new xr(e)),al=BigInt(0),un=BigInt(1),cl=BigInt(2),ll=BigInt(7),ul=BigInt(256),fl=BigInt(113),go=[],wo=[],xo=[];for(let e=0,t=un,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],go.push(2*(5*r+n)),wo.push((e+1)*(e+2)/2%64);let s=al;for(let o=0;o<7;o++)t=(t<<un^(t>>ll)*fl)%ul,t&cl&&(s^=un<<(un<<BigInt(o))-un);xo.push(s)}const Eo=Uc(xo,!0),hl=Eo[0],dl=Eo[1],ko=(e,t,n)=>n>32?zc(e,t,n):Hc(e,t,n),Ao=(e,t,n)=>n>32?jc(e,t,n):Fc(e,t,n);function pl(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,l=(i+2)%10,c=n[l],u=n[l+1],v=ko(c,u,1)^n[a],h=Ao(c,u,1)^n[a+1];for(let f=0;f<50;f+=10)e[i+f]^=v,e[i+f+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const a=wo[i],l=ko(s,o,a),c=Ao(s,o,a),u=go[i];s=e[u],o=e[u+1],e[u]=l,e[u+1]=c}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)n[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=hl[r],e[1]^=dl[r]}ut(n)}class Er{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Lt(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=$t(this.state)}clone(){return this._cloneInto()}keccak(){ge(this.state32),pl(this.state32,this.rounds),ge(this.state32),this.posOut=0,this.pos=0}update(t){sn(this),Te(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let a=0;a<i;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){sn(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ut(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||=new Er(n,r,s,i,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const kr=((e,t,n,r={})=>vr(()=>new Er(t,e,n),r))(1,136,32),$o=e=>{const t=e.slice(2),n=Z(kr(fo.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},vl=ee(20)[1],So=K(e=>{const t=ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if($o(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},et(e=>$o(Z(vl(e))))),ue=e=>te(U(e),e);ue.enc=e=>te(U.enc(e),e),ue.dec=e=>te(U.dec(e),e);const Fe=(...e)=>te(Re(...e),e);Fe.enc=(...e)=>te(Re.enc(...e),e),Fe.dec=(...e)=>te(Re.dec(...e),e);const Ie=(e,...t)=>te(V(e,...t),e);Ie.enc=(e,...t)=>te(V.enc(e,...t),e),Ie.dec=(e,...t)=>te(V.dec(e,...t),e);const Un=(e,t)=>te(rn(e,t),{ok:e,ko:t});Un.enc=(e,t)=>te(rn.enc(e,t),{ok:e,ko:t}),Un.dec=(e,t)=>te(rn.dec(e,t),{ok:e,ko:t});const vt=e=>te(Ee(e),e);vt.enc=e=>te(Ee.enc(e),e),vt.dec=e=>te(Ee.dec(e),e);const Io=(e=!0)=>et(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=ee(r).dec(t),o=new Array(n);let i=0;return s.forEach(a=>{for(let l=0;l<8&&i<n;l++){const c=e?l:7-l;o[i++]=a>>c&1}}),o}),Bo=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,a=0;for(let l=0;l<8&&i<t.length;l++,i++)a|=t[i]<<(e?l:7-l);s[o]=a}return ie([n,s])},Mn=e=>K(Bo(e),Io(e));Mn.enc=Bo,Mn.dec=Io;const _o=new TextEncoder,Co=new TextDecoder,ml=qe(ee(4),_o.encode.bind(_o),Co.decode.bind(Co)),Ar=ue({engine:ml,payload:we()}),yl=ke({other:ee(),consensus:Ar,seal:Ar,preRuntime:Ar,runtimeUpdated:P},[0,4,5,6,8]),$r=we(32),Ln=ue({parentHash:$r,number:C,stateRoot:$r,extrinsicRoot:$r,digests:Ie(yl)}),Be=V(q),Oo=Ee(q),bl=xe({bool:P,char:P,str:P,u8:P,u16:P,u32:P,u64:P,u128:P,u256:P,i8:P,i16:P,i32:P,i64:P,i128:P,i256:P}),Ro=V(U({name:Oo,type:C,typeName:Oo,docs:Be})),gl=U({len:He,type:C}),wl=U({bitStoreType:C,bitOrderType:C}),xl=V(U({name:q,fields:Ro,index:z,docs:Be})),El=xe({composite:Ro,variant:xl,sequence:C,array:gl,tuple:V(C),primitive:bl,compact:C,bitSequence:wl}),kl=U({name:q,type:Ee(C)}),Al=V(kl),$l=U({id:C,path:Be,params:Al,def:El,docs:Be}),Vn=V($l),Dt=xe({NotDeprecated:P,DeprecatedWithoutNote:P,Deprecated:U({note:q,since:Ee(q)})}),Sl=V(U({index:z,deprecation:xe({DeprecatedWithoutNote:P,Deprecated:U({note:q,since:Ee(q)})},[1,2])})),Sr={name:q,inputs:V(U({name:q,type:C})),output:C,docs:Be},Il=U({name:q,methods:V(U(Sr)),docs:Be}),Bl=U({name:q,methods:V(U({...Sr,deprecationInfo:Dt})),docs:Be,version:C,deprecationInfo:Dt}),_l=U({id:we(32),...Sr,deprecationInfo:Dt}),Cl=xe({Blake2128:P,Blake2256:P,Blake2128Concat:P,Twox128:P,Twox256:P,Twox64Concat:P,Identity:P}),Ol=V(Cl),Rl=U({hashers:Ol,key:C,value:C}),To={name:q,modifier:z,type:xe({plain:C,map:Rl}),fallback:we(),docs:Be},Ir=Ee(C),Po={name:q,storage:Ee(U({prefix:q,items:V(U(To))})),calls:Ir,events:Ir,constants:V(U({name:q,type:C,value:we(),docs:Be})),errors:Ir,index:z},Tl={...Po,docs:Be},Br=Ee(U({type:C,deprecationInfo:Sl})),Pl={name:q,storage:Ee(U({prefix:q,items:V(U({...To,deprecationInfo:Dt}))})),calls:Br,events:Br,constants:V(U({name:q,type:C,value:we(),docs:Be,deprecationInfo:Dt})),errors:Br,associatedTypes:V(U({name:q,type:C,docs:Be})),viewFns:V(_l),index:z,docs:Be,deprecationInfo:Dt},Ul=new Uint8Array,Uo=e=>K(()=>Ul,()=>e),Ml=U({type:C,version:z,signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Mo=U({lookup:Vn,pallets:V(U({...Po,docs:Uo([])})),extrinsic:Ml,type:C,apis:Uo([])}),Ll=U({version:z,address:C,call:C,signature:C,extra:C,signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Lo=U({lookup:Vn,pallets:V(U(Tl)),extrinsic:Ll,type:C,apis:V(Il),outerEnums:U({call:C,event:C,error:C}),custom:V(Re(q,U({type:C,value:we()})))}),Vl=U({version:V(z),address:C,call:C,signature:C,signedExtensionsByVersion:V(Re(z,V(C))),signedExtensions:V(U({identifier:q,type:C,additionalSigned:C}))}),Vo=U({lookup:Vn,pallets:V(U(Pl)),extrinsic:Vl,apis:V(Bl),outerEnums:U({call:C,event:C,error:C}),custom:V(Re(q,U({type:C,value:we()})))}),Do=()=>{throw new Error("Unsupported metadata version!")},Ae=K(Do,Do),mt=U({magicNumber:He,metadata:xe({v0:Ae,v1:Ae,v2:Ae,v3:Ae,v4:Ae,v5:Ae,v6:Ae,v7:Ae,v8:Ae,v9:Ae,v10:Ae,v11:Ae,v12:Ae,v13:Ae,v14:Mo,v15:Lo,v16:Vo})}),_r=ee(),Dl=Ee(_r),Hl=Re(pe,_r),Cr=e=>{try{return mt.dec(e)}catch{}try{return mt.dec(Dl.dec(e))}catch{}try{return mt.dec(_r.dec(e))}catch{}try{return mt.dec(Hl.dec(e)[1])}catch{}throw null},Ht=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:a,pallets:l,outerEnums:c}=e;return{version:15,lookup:s,pallets:l.map(u=>({...u,calls:u.calls!=null?{type:u.calls}:void 0,events:u.events!=null?{type:u.events}:void 0,errors:u.errors!=null?{type:u.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:a,outerEnums:c,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},Ct={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Or=qe(z,({version:e,type:t})=>e+(Ct[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===Ct.bare||n===Ct.signed))return{version:t,type:Ct[n]};if(t===5&&(n===Ct.bare||n===Ct.general))return{version:t,type:Ct[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Fl={dkLen:32},Ft=e=>_n(e,Fl),zl={dkLen:16},Rr=e=>_n(e,zl),Ho=e=>ie([Rr(e),e]),jl={dkLen:32},Fo=e=>il(e,jl),Wl=e=>ie([Fo(e),e]),zo=e=>e,Ot=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Tr=2n**64n-1n,me=(e,t)=>e<<t&Tr|e>>64n-t,W=(e,t)=>e*t&Tr,ae=(e,t)=>e+t&Tr,ce=11400714785074694791n,_e=14029467366897019727n,jo=1609587929392839161n,fn=9650029242287828579n,Wo=2870177450012600261n;function yt(e,t=0n){let n=ae(ae(t,ce),_e),r=ae(t,_e),s=t,o=t-ce,i=e.length,a=0,l=null;(function(){let f=0,d=f+i;if(i){if(l=new Uint8Array(32),i<32){l.set(e.subarray(0,i),a),a+=i;return}if(f<=d-32){const p=d-32;do{let m;m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),n=W(me(ae(n,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),r=W(me(ae(r,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),s=W(me(ae(s,W(m,_e)),31n),ce),f+=8,m=Ot(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),o=W(me(ae(o,W(m,_e)),31n),ce),f+=8}while(f<=p)}f<d&&(l.set(e.subarray(f,d),a),a=d-f)}})(),e=l||e;let c,u=0;for(i>=32?(c=me(n,1n),c=ae(c,me(r,7n)),c=ae(c,me(s,12n)),c=ae(c,me(o,18n)),n=W(me(W(n,_e),31n),ce),c=c^n,c=ae(W(c,ce),fn),r=W(me(W(r,_e),31n),ce),c=c^r,c=ae(W(c,ce),fn),s=W(me(W(s,_e),31n),ce),c=c^s,c=ae(W(c,ce),fn),o=W(me(W(o,_e),31n),ce),c=c^o,c=ae(W(c,ce),fn)):c=ae(t,Wo),c=ae(c,BigInt(i));u<=a-8;){let h=Ot(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]);h=W(me(W(h,_e),31n),ce),c=ae(W(me(c^h,27n),ce),fn),u+=8}if(u+4<=a){let h=W(Ot(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],0,0),ce);c=ae(W(me(c^h,23n),_e),jo),u+=4}for(;u<a;){const h=W(Ot(e[u++],0,0,0),Wo);c=W(me(c^h,11n),ce)}let v=c>>33n;return c=W(c^v,_e),v=c>>29n,c=W(c^v,jo),v=c>>32n,c^=v,c}const Dn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),t},qo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,yt(e),!0),n.setBigUint64(8,yt(e,1n),!0),n.setBigUint64(16,yt(e,2n),!0),n.setBigUint64(24,yt(e,3n),!0),t},No=e=>ie([nn.enc(yt(e)),e]),Ko=new TextEncoder,ql=new Map([[zo,0],[No,8],[Ho,16],[Rr,-16],[Ft,-32],[Dn,-16],[qo,-32]]),Xo=e=>{const t=Dn(Ko.encode(e));return(n,...r)=>{const s=ie([t,Dn(Ko.encode(n))]),o=Z(s),i=c=>{if(!c.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const u=ve(c.slice(o.length)),v=new Array(r.length);for(let h=0,f=0;h<r.length;h++){const[d,p]=r[h],m=ql.get(p);if(m==null)throw new Error("Unknown hasher");if(m<0){const b=m*-1;v[h]=Z(u.slice(f,f+b)),f+=b}else f+=m,v[h]=d.dec(u.slice(f)),f+=d.enc(v[h]).length}return v},a=r.map(([{enc:c},u])=>v=>u(c(v)));return{enc:(...c)=>Z(ie([s,...c.map((u,v)=>a[v](u))])),dec:i}}},Nl=Ke.fromText("modlpy/utilisuba").asBytes(),Kl=({threshold:e,signatories:t})=>{const n=Yo(t),r=ie([Nl,pe.enc(n.length),...n,Ne.enc(e)]);return Ft(r)},Yo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),bt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Go=we().dec,Xl=we(1/0).dec,Yl=we(32).dec,Qo=z.dec,Gl=e=>{const t=Qo(e);let n=6;const r=t>>n,s=r?r===1?bt.Leaf:r===2?bt.Branch:bt.BranchWithVal:t>>--n?bt.LeafWithHash:t>>--n?bt.BranchWithHash:t?bt.Reserved:bt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Qo(e);while(i===255)}return{type:s,partialKey:we(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Zo=et(e=>{const t=Gl(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Xl(e)};const r=Ne.dec(e),s=[];for(let a=0;a<16;a++)r>>a&1&&s.push(a.toString(16));let o=null;n==="BranchWithVal"&&(o=Go(e)),n==="BranchWithHash"&&(o=Yl(e));const i={...t,children:Object.fromEntries(s.map(a=>[a,Go(e)]))};return o!==null&&(i.value=o),i}),Jo=e=>et(t=>{const n=Z(e(new Uint8Array(t.buffer)));try{return{hash:n,...Zo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var ei=Object.freeze({__proto__:null,AccountId:St,Bin:ln,Binary:Ke,BitSeq:Mn,Blake2128:Rr,Blake2128Concat:Ho,Blake2256:Ft,Blake3256:Fo,Blake3256Concat:Wl,Bytes:ee,Enum:_t,FixedSizeBinary:Tn,Hex:we,Identity:zo,Keccak256:kr,Option:vt,Result:Un,ScaleEnum:wr,Self:gr,Storage:Xo,Struct:ue,TrieNodeHeaders:bt,TrieNodeWithHash:Jo,Tuple:Fe,Twox128:Dn,Twox256:qo,Twox64Concat:No,Variant:ke,Vector:Ie,_Enum:vo,_void:P,bitSequence:nl,blockHeader:Ln,bool:ac,char:rl,compact:pe,compactBn:Pn,compactNumber:C,createCodec:K,createDecoder:et,decAnyMetadata:Cr,enhanceCodec:qe,enhanceDecoder:$n,enhanceEncoder:An,ethAccount:So,extrinsicFormat:Or,fixedStr:ol,fromBufferToBase58:no,getMultisigAccountId:Kl,getSs58AddressInfo:yr,h64:yt,i128:sc,i16:tc,i256:ic,i32:nc,i64:rc,i8:ec,metadata:mt,selfDecoder:po,selfEncoder:ho,sortMultisigSignatories:Yo,str:q,trieNodeDec:Zo,u128:ks,u16:Ne,u256:oc,u32:He,u64:nn,u8:z,unifyMetadata:Ht,v14:Mo,v14Lookup:Vn,v15:Lo,v16:Vo,validateProofs:(e,t=Ft)=>{const n=e.map(Jo(t)),r=Object.fromEntries(n.map(a=>[a.hash,a])),s=n.map(a=>a.hash),o=new Set(s),i=a=>{if(a.value)return;const l=e[s.indexOf(a.hash)];a.value=typeof l=="string"?l:Z(l)};return n.forEach(a=>{if("children"in a&&Object.values(a.children).forEach(l=>{const c=r[l];c&&(c.parent=a.hash,o.delete(l))}),a.type==="BranchWithHash"||a.type==="LeafWithHash"){const l=a.value,c=r[l];if(!c)return;o.delete(l),c.type!=="Raw"&&(Object.keys(c).forEach(u=>delete c[u]),c.type="Raw",c.hash=l),c.parent=a.hash,i(c)}a.type==="Raw"&&i(a)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const ot=C,Ql=Ie(Fe(q,ot)),N={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Zl=ke(Object.fromEntries(Object.values(N).map(e=>[e,P]))),Jl=Ie(Fe(q,ke({inline:gr(()=>Pr),lookup:ot}))),eu=Ie(ot),tu=ue({typeRef:ot,length:vt(ot)}),nu=vt(ot),ru=ot,su=ue({ok:ot,ko:ot}),Pr=ke({struct:Ql,terminal:Zl,enum:Jl,tuple:eu,array:tu,binary:nu,option:ru,result:su}),ou={i256:N.big,i128:N.big,i64:N.big,i32:N.num,i16:N.num,i8:N.num,u256:N.big,u128:N.big,u64:N.big,u32:N.num,u16:N.num,u8:N.num,bool:N.bool,char:N.str,str:N.str},hn=e=>({type:"terminal",value:{type:e}});function Hn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return hn(N.str);case"array":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:e.len}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id,length:e.len}});case"bitSequence":return hn(N.bits);case"compact":return hn(e.isBig?N.big:N.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Hn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return hn(ou[e.value]);case"result":return t(e.value.ok.id),t(e.value.ko.id),{type:"result",value:{ok:e.value.ok.id,ko:e.value.ko.id}};case"sequence":return e.value.type==="primitive"&&e.value.value==="u8"?{type:"binary",value:void 0}:(t(e.value.id),{type:"array",value:{typeRef:e.value.id}});case"void":return hn(N.void)}}function Fn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Fn(o,i,n),s=o=>{switch(o.value.type){case N.str:case N.big:case N.bool:case N.num:return typeof e===o.value.type;case N.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case N.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e!=null&&typeof e.asBytes=="function"&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(c=>r(c,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,a=Object.fromEntries(t.value);if(!(i.type in a))return!1;const l=a[i.type];return l==null?!0:r(i.value,l.type==="inline"?l.value:n(l.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([c,u])=>r(e[c],n(u))):!1;case"tuple":return e?t.value.every((c,u)=>r(e[u],n(c))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}function iu(e,t,n,r){if(e.length>t)return!1;let s=[n];return t>1&&(n.type==="tuple"?s=n.value.map(r):n.type==="array"&&n.value.length&&(s=new Array(n.value.length).fill(r(n.value.typeRef)))),e.every((o,i)=>Fn(o,s[i],r))}var au=Object.defineProperty,cu=(e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lu=(e,t,n)=>cu(e,t+"",n);class ti{constructor(t=[]){lu(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Pe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Pe||{});function Ur(e,t,n,r,s,o=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const l=i.get(e);return l==null?{level:3,changes:[],assumptions:new ti([[e,n]])}:ze(l.level,l.changes)}i.set(e,null);const a=uu(e,n,(l,c)=>Ur(typeof l=="number"?t(l):l,t,typeof c=="number"?r(c):c,r,s),o);return a.assumptions.delete(e,n),a.assumptions.isEmpty()||a.level===0?i.set(e,a):i.delete(e),a}function uu(e,t,n,r){const s=(o,i,a)=>{const l=n(o,i);return{...l,changes:l.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:l.level,path:a}]:[]}};if(e.type!==t.type)return t.type==="option"?zn(s(e,t.value,"some"),2):e.type==="option"?zn(s(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Lr(si(e.value,t.value));case"array":const i=e,a=Lr(si(i.value.length,t.value.length));return Mr([a,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const h=e,f=Object.fromEntries(t.value.map(([m,b])=>[m,b.value]));let d=ri(h.value.map(([m,b])=>()=>m in f?s(b.value,f[m],m):ze(0,[{id:[typeof b.value=="number"?b.value:null,null],level:0,path:m}])));if(h.value.length===t.value.length)return d;d=zn(d,2);const p=new Set(h.value.map(([m])=>m));return d.changes=[...d.changes,...t.value.filter(([m])=>!p.has(m)).map(([m,b])=>({id:[null,typeof b=="number"?b:null],level:0,path:m}))],d}case"option":return fu(s(e.value,t.value,"some"),1);case"struct":const l=e,c=Object.fromEntries(l.value),u=l.value.length===t.value.length?3:2;return zn(Mr(t.value.map(([h,f])=>()=>s(c[h],f,h)),r),u);case"tuple":{const h=e,f=Lr(hu(h.value,t.value));return Mr([f,...t.value.map((d,p)=>()=>s(h.value[p],d,String(p)))],r)}case"result":const v=e;return ri([s(v.value.ok,t.value.ok,"ok"),s(v.value.ko,t.value.ko,"ko")])}}const zn=(e,t)=>({...e,level:Math.min(e.level,t)}),fu=(e,t)=>({...e,level:Math.max(e.level,t)}),ni=new ti,ze=(e,t)=>({level:e,changes:t,assumptions:ni}),Mr=(e,t)=>{let n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},ri=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:ze(0,n.changes)},Lr=e=>({assumptions:ni,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),hu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,si=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,oi=ke({lookup:C,typedef:Pr}),zt=e=>({type:"lookup",value:e}),Vr=e=>({type:"typedef",value:e}),jn=Vr({type:"terminal",value:{type:N.void}}),du=ue({args:oi,values:oi});function pu(e){if(e.type.tag==="plain")return{args:jn,values:zt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:zt(t),values:zt(n)}}function ii(e){return{args:Vr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:zt(e.output)}}function vu(e){return e.type==="lookupEntry"?zt(e.value.id):Vr(Hn(e))}function mu(e){return{args:jn,values:zt(e)}}function yu(e,t,n,r,s,o){const i=(a,l)=>a.type==="lookup"?l(a.value):a.value;return{args:Ur(i(e.args,t),t,i(n.args,r),r,s,o),values:Ur(i(n.values,r),r,i(e.values,t),t,s,o)}}function ai(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Fn(n,r,t)}var Dr=function(e,t){return Dr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},Dr(e,t)};function Ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Dr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function bu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{c(r.next(u))}catch(v){i(v)}}function l(u){try{c(r.throw(u))}catch(v){i(v)}}function c(u){u.done?o(u.value):s(u.value).then(a,l)}c((r=r.apply(e,t||[])).next())})}function ci(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,s&&(o=c[0]&2?s.return:c[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,c[1])).done)return o;switch(s=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,s=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(u){c=[6,u],s=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function jt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ue(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Me(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function Wt(e){return this instanceof Wt?(this.v=e,this):new Wt(e)}function gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(d){return Promise.resolve(d).then(f,v)}}function a(f,d){r[f]&&(s[f]=function(p){return new Promise(function(m,b){o.push([f,p,m,b])>1||l(f,p)})},d&&(s[f]=d(s[f])))}function l(f,d){try{c(r[f](d))}catch(p){h(o[0][3],p)}}function c(f){f.value instanceof Wt?Promise.resolve(f.value.v).then(u,v):h(o[0][2],f)}function u(f){l("next",f)}function v(f){l("throw",f)}function h(f,d){f(d),o.shift(),o.length&&l(o[0][0],o[0][1])}}function wu(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof jt=="function"?jt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(a,l){i=e[o](i),s(a,l,i.done,i.value)})}}function s(o,i,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},i)}}typeof SuppressedError=="function"&&SuppressedError;function Q(e){return typeof e=="function"}function Hr(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Fr=Hr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
3
  `):"",this.name="UnsubscriptionError",this.errors=n}});function Wn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var qt=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=jt(i),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(p){t={error:p}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var u=this.initialTeardown;if(Q(u))try{u()}catch(p){o=p instanceof Fr?p.errors:[p]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=jt(v),f=h.next();!f.done;f=h.next()){var d=f.value;try{fi(d)}catch(p){o=o??[],p instanceof Fr?o=Me(Me([],Ue(o)),Ue(p.errors)):o.push(p)}}}catch(p){r={error:p}}finally{try{f&&!f.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new Fr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)fi(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&Wn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Wn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),li=qt.EMPTY;function ui(e){return e instanceof qt||e&&"closed"in e&&Q(e.remove)&&Q(e.add)&&Q(e.unsubscribe)}function fi(e){Q(e)?e():e.unsubscribe()}var xu={Promise:void 0},Eu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Me([e,t],Ue(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function hi(e){Eu.setTimeout(function(){throw e})}function $e(){}function qn(e){e()}var dn=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ui(n)&&n.add(r)):r.destination=$u,r}return t.create=function(n,r,s){return new Nt(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(qt),ku=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){Nn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Nn(r)}else Nn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Nn(n)}},e})(),Nt=(function(e){Ye(t,e);function t(n,r,s){var o=e.call(this)||this,i;return Q(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new ku(i),o}return t})(dn);function Nn(e){hi(e)}function Au(e){throw e}var $u={closed:!0,next:$e,error:Au,complete:$e},zr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ge(e){return e}function di(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pi(e)}function pi(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var M=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var s=this,o=Iu(t)?t:new Nt(t,n,r);return qn(function(){var i=s,a=i.operator,l=i.source;o.add(a?a.call(o,l):l?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=vi(n),new n(function(s,o){var i=new Nt({next:function(a){try{t(a)}catch(l){o(l),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[zr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return pi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=vi(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e})();function vi(e){var t;return(t=e??xu.Promise)!==null&&t!==void 0?t:Promise}function Su(e){return e&&Q(e.next)&&Q(e.error)&&Q(e.complete)}function Iu(e){return e&&e instanceof dn||Su(e)&&ui(e)}function Bu(e){return Q(e?.lift)}function J(e){return function(t){if(Bu(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Y(e,t,n,r,s){return new _u(e,t,n,r,s)}var _u=(function(e){Ye(t,e);function t(n,r,s,o,i,a){var l=e.call(this,n)||this;return l.onFinalize=i,l.shouldUnsubscribe=a,l._next=r?function(c){try{r(c)}catch(u){n.error(u)}}:e.prototype._next,l._error=o?function(c){try{o(c)}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=s?function(){try{s()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,l}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(dn),Cu=Hr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),je=(function(e){Ye(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new mi(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Cu},t.prototype.next=function(n){var r=this;qn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=jt(r.currentObservers),a=i.next();!a.done;a=i.next()){var l=a.value;l.next(n)}}catch(c){s={error:c}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;qn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;qn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?li:(this.currentObservers=null,a.push(n),new qt(function(){r.currentObservers=null,Wn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new M;return n.source=this,n},t.create=function(n,r){return new mi(n,r)},t})(M),mi=(function(e){Ye(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:li},t})(je),Ou=(function(e){Ye(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t})(je),jr={now:function(){return(jr.delegate||Date).now()},delegate:void 0},pn=(function(e){Ye(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=jr);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;s||(o.push(n),!i&&o.push(a.now()+l)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,a=i.slice(),l=0;l<a.length&&!n.closed;l+=o?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!i){for(var l=s.now(),c=0,u=1;u<o.length&&o[u]<=l;u+=2)c=u;c&&o.splice(0,c+1)}},t})(je),Ru=(function(e){Ye(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(qt),yi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Me([e,t],Ue(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Tu=(function(e){Ye(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),yi.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&yi.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Wn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Ru),bi=(function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=jr.now,e})(),Pu=(function(e){Ye(t,e);function t(n,r){r===void 0&&(r=bi.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t})(bi),gi=new Pu(Tu),Uu=gi,gt=new M(function(e){return e.complete()});function wi(e){return e&&Q(e.schedule)}function Wr(e){return e[e.length-1]}function qr(e){return Q(Wr(e))?e.pop():void 0}function vn(e){return wi(Wr(e))?e.pop():void 0}function Mu(e,t){return typeof Wr(e)=="number"?e.pop():t}var xi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Ei(e){return Q(e?.then)}function ki(e){return Q(e[zr])}function Ai(e){return Symbol.asyncIterator&&Q(e?.[Symbol.asyncIterator])}function $i(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Lu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Si=Lu();function Ii(e){return Q(e?.[Si])}function Bi(e){return gu(this,arguments,function(){var n,r,s,o;return ci(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Wt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Wt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Wt(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function _i(e){return Q(e?.getReader)}function le(e){if(e instanceof M)return e;if(e!=null){if(ki(e))return Vu(e);if(xi(e))return Du(e);if(Ei(e))return Hu(e);if(Ai(e))return Ci(e);if(Ii(e))return Fu(e);if(_i(e))return zu(e)}throw $i(e)}function Vu(e){return new M(function(t){var n=e[zr]();if(Q(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Du(e){return new M(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Hu(e){return new M(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,hi)})}function Fu(e){return new M(function(t){var n,r;try{for(var s=jt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function Ci(e){return new M(function(t){ju(e,t).catch(function(n){return t.error(n)})})}function zu(e){return Ci(Bi(e))}function ju(e,t){var n,r,s,o;return bu(this,void 0,void 0,function(){var i,a;return ci(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=wu(e),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),s={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function wt(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function Oi(e,t){return t===void 0&&(t=0),J(function(n,r){n.subscribe(Y(r,function(s){return wt(r,e,function(){return r.next(s)},t)},function(){return wt(r,e,function(){return r.complete()},t)},function(s){return wt(r,e,function(){return r.error(s)},t)}))})}function Ri(e,t){return t===void 0&&(t=0),J(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Wu(e,t){return le(e).pipe(Ri(t),Oi(t))}function qu(e,t){return le(e).pipe(Ri(t),Oi(t))}function Nu(e,t){return new M(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ku(e,t){return new M(function(n){var r;return wt(n,t,function(){r=e[Si](),wt(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(a){n.error(a);return}i?n.complete():n.next(o)},0,!0)}),function(){return Q(r?.return)&&r.return()}})}function Ti(e,t){if(!e)throw new Error("Iterable cannot be null");return new M(function(n){wt(n,t,function(){var r=e[Symbol.asyncIterator]();wt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Xu(e,t){return Ti(Bi(e),t)}function Yu(e,t){if(e!=null){if(ki(e))return Wu(e,t);if(xi(e))return Nu(e,t);if(Ei(e))return qu(e,t);if(Ai(e))return Ti(e,t);if(Ii(e))return Ku(e,t);if(_i(e))return Xu(e,t)}throw $i(e)}function xt(e,t){return t?Yu(e,t):le(e)}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e);return xt(e,n)}function Rt(e,t){var n=Q(e)?e:function(){return e},r=function(s){return s.error(n())};return new M(r)}var Pi=Hr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Gu(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new Pi)}})})}function Le(e,t){return new Promise(function(n,r){var s=new Nt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Pi)}});e.subscribe(s)})}function Qu(e){return e instanceof Date&&!isNaN(e)}function k(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){r.next(e.call(t,o,s++))}))})}var Zu=Array.isArray;function Ju(e,t){return Zu(t)?e.apply(void 0,Me([],Ue(t))):e(t)}function Ui(e){return k(function(t){return Ju(e,t)})}var ef=Array.isArray,tf=Object.getPrototypeOf,nf=Object.prototype,rf=Object.keys;function sf(e){if(e.length===1){var t=e[0];if(ef(t))return{args:t,keys:null};if(of(t)){var n=rf(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function of(e){return e&&typeof e=="object"&&tf(e)===nf}function af(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function it(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=qr(e),s=sf(e),o=s.args,i=s.keys;if(o.length===0)return xt([],n);var a=new M(Mi(o,n,i?function(l){return af(i,l)}:Ge));return r?a.pipe(Ui(r)):a}function Mi(e,t,n){return n===void 0&&(n=Ge),function(r){Li(t,function(){for(var s=e.length,o=new Array(s),i=s,a=s,l=function(u){Li(t,function(){var v=xt(e[u],t),h=!1;v.subscribe(Y(r,function(f){o[u]=f,h||(h=!0,a--),a||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},c=0;c<s;c++)l(c)},r)}}function Li(e,t,n){e?wt(n,e,t):t()}function cf(e,t,n,r,s,o,i,a){var l=[],c=0,u=0,v=!1,h=function(){v&&!l.length&&!c&&t.complete()},f=function(p){return c<r?d(p):l.push(p)},d=function(p){c++;var m=!1;le(n(p,u++)).subscribe(Y(t,function(b){t.next(b)},function(){m=!0},void 0,function(){if(m)try{c--;for(var b=function(){var y=l.shift();i||d(y)};l.length&&c<r;)b();h()}catch(y){t.error(y)}}))};return e.subscribe(Y(t,f,function(){v=!0,h()})),function(){}}function L(e,t,n){return n===void 0&&(n=1/0),Q(t)?L(function(r,s){return k(function(o,i){return t(r,o,s,i)})(le(e(r,s)))},n):(typeof t=="number"&&(n=t),J(function(r,s){return cf(r,s,e,n)}))}function Kn(e){return e===void 0&&(e=1/0),L(Ge,e)}function lf(){return Kn(1)}function Kt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return lf()(xt(e,vn(e)))}function Xn(e){return new M(function(t){le(e()).subscribe(t)})}function Yn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Uu);var r=-1;return t!=null&&(wi(t)?n=t:r=t),new M(function(s){var o=Qu(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function mn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=Mu(e,1/0),s=e;return s.length?s.length===1?le(s[0]):Kn(r)(xt(s,n)):gt}var uf=new M($e),ff=Array.isArray;function Vi(e){return e.length===1&&ff(e[0])?e[0]:e}function at(e,t){return J(function(n,r){var s=0;n.subscribe(Y(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function hf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=Vi(e),e.length===1?le(e[0]):new M(df(e))}function df(e){return function(t){for(var n=[],r=function(o){n.push(le(e[o]).subscribe(Y(t,function(i){if(n){for(var a=0;a<n.length;a++)a!==o&&n[a].unsubscribe();n=null}t.next(i)})))},s=0;n&&!t.closed&&s<e.length;s++)r(s)}}function Se(e){return J(function(t,n){var r=null,s=!1,o;r=t.subscribe(Y(n,void 0,void 0,function(i){o=le(e(i,Se(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function pf(e,t,n,r,s){return function(o,i){var a=n,l=t,c=0;o.subscribe(Y(i,function(u){var v=c++;l=a?e(l,u,v):(a=!0,u),i.next(l)},s))}}function Di(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=qr(e);return n?di(Di.apply(void 0,Me([],Ue(e))),Ui(n)):J(function(r,s){Mi(Me([r],Ue(Vi(e))))(s)})}function vf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Di.apply(void 0,Me([],Ue(e)))}function mf(e,t){return Q(t)?L(e,t,1):L(e,1)}function ye(e){return e<=0?function(){return gt}:J(function(t,n){var r=0;t.subscribe(Y(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Nr(){return J(function(e,t){e.subscribe(Y(t,$e))})}function yf(e){return k(function(){return e})}function bf(e,t){return L(function(n,r){return le(e(n,r)).pipe(ye(1),yf(n))})}function gf(e,t){t===void 0&&(t=gi);var n=Yn(e,t);return bf(function(){return n})}function wf(e,t){return J(function(n,r){var s=new Set;n.subscribe(Y(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&le(t).subscribe(Y(r,function(){return s.clear()},$e))})}function fe(e,t){return t===void 0&&(t=Ge),e=e??xf,J(function(n,r){var s,o=!0;n.subscribe(Y(r,function(i){var a=t(i);(o||!e(s,a))&&(o=!1,s=a,r.next(i))}))})}function xf(e,t){return e===t}function Hi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return Kt(n,ne.apply(void 0,Me([],Ue(e))))}}function Ef(e,t){return J(function(n,r){var s=0,o=null,i=!1;n.subscribe(Y(r,function(a){o||(o=Y(r,void 0,function(){o=null,i&&r.complete()}),le(e(a,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function kf(e){return J(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Af(){return J(function(e,t){var n,r=!1;e.subscribe(Y(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Gn(e,t){return J(pf(e,t,arguments.length>=2,!0))}function yn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new je}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,a=e.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var u,v,h,f=0,d=!1,p=!1,m=function(){v?.unsubscribe(),v=void 0},b=function(){m(),u=h=void 0,d=p=!1},y=function(){var g=u;b(),g?.unsubscribe()};return J(function(g,w){f++,!p&&!d&&m();var x=h=h??n();w.add(function(){f--,f===0&&!p&&!d&&(v=Kr(y,l))}),x.subscribe(w),!u&&f>0&&(u=new Nt({next:function(E){return x.next(E)},error:function(E){p=!0,m(),v=Kr(b,s,E),x.error(E)},complete:function(){d=!0,m(),v=Kr(b,i),x.complete()}}),le(g).subscribe(u))})(c)}}function Kr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var s=new Nt({next:function(){s.unsubscribe(),e()}});return le(t.apply(void 0,Me([],Ue(n)))).subscribe(s)}}function Qn(e,t,n){var r,s,o,i,a=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,a=o===void 0?!1:o,n=e.scheduler):i=e??1/0,yn({connector:function(){return new pn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Fi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e);return J(function(r,s){(n?Kt(e,r,n):Kt(e,r)).subscribe(s)})}function bn(e,t){return J(function(n,r){var s=null,o=0,i=!1,a=function(){return i&&!s&&r.complete()};n.subscribe(Y(r,function(l){s?.unsubscribe();var c=0,u=o++;le(e(l,u)).subscribe(s=Y(r,function(v){return r.next(t?t(l,v,u,c++):v)},function(){s=null,a()}))},function(){i=!0,a()}))})}function $f(){return bn(Ge)}function zi(e){return J(function(t,n){le(e).subscribe(Y(n,function(){return n.complete()},$e)),!n.closed&&t.subscribe(n)})}function Xt(e,t){return t===void 0&&(t=!1),J(function(n,r){var s=0;n.subscribe(Y(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function gn(e,t,n){var r=Q(e)||t||n?{next:e,error:t,complete:n}:e;return r?J(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var a=!0;s.subscribe(Y(o,function(l){var c;(c=r.next)===null||c===void 0||c.call(r,l),o.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),o.complete()},function(l){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),o.error(l)},function(){var l,c;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Ge}function Xr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=qr(e);return J(function(r,s){for(var o=e.length,i=new Array(o),a=e.map(function(){return!1}),l=!1,c=function(v){le(e[v]).subscribe(Y(s,function(h){i[v]=h,!l&&!a[v]&&(a[v]=!0,(l=a.every(Ge))&&(a=null))},$e))},u=0;u<o;u++)c(u);r.subscribe(Y(s,function(v){if(l){var h=Me([v],Ue(i));s.next(n?n.apply(void 0,Me([],Ue(h))):h)}}))})}var Sf=Object.defineProperty,If=(e,t,n)=>t in e?Sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ji=(e,t,n)=>If(e,typeof t!="symbol"?t+"":t,n);class Wi extends Error{constructor(t){super(t.message),ji(this,"code"),ji(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const qi=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};class Yr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let Bf=1;const _f=e=>{let t=Bf++;const n=new Map,r=qi();let s=null;const o=(u,v,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:u,method:v,params:h}))};function i(u){try{let v,h,f,d,p;if({id:v,result:h,error:f,params:d}=JSON.parse(u),v===null)throw new Error(d?.error?.message??"id null");if(v!=null){const y=n.get(v);return y?(n.delete(v),f?y.onError(new Wi(f)):y.onSuccess(h,(g,w)=>{const x=g;return r.subscribe(x,w),()=>{r.unsubscribe(x)}})):void 0}if({subscription:p,result:h,error:f}=d,!p||!f&&!Object.hasOwn(d,"result"))throw 0;const b=p;f?r.error(b,new Wi(f)):r.next(b,h)}catch(v){console.warn("Error parsing incomming message: "+u),console.error(v)}}s=e(i);const a=()=>{s?.disconnect(),s=null,r.errorAll(new Yr),n.forEach(u=>u.onError(new Yr)),n.clear()};let l=1;return{request:(u,v,h)=>{if(!s)throw new Error("Not connected");const f=`${t}-${l++}`;return h&&n.set(f,h),o(f,u,v),()=>{n.delete(f)}},disconnect:a}};var Cf=Object.defineProperty,Of=(e,t,n)=>t in e?Cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wn=(e,t,n)=>Of(e,t+"",n);const Ni=class za extends Error{constructor(){super("ChainHead stopped"),this.name=za.errorName}};wn(Ni,"errorName","StopError");let Ki=Ni;const Xi=class ja extends Error{constructor(){super("ChainHead disjointed"),this.name=ja.errorName}};wn(Xi,"errorName","DisjointError");let Zn=Xi;const Yi=class Wa extends Error{constructor(){super("ChainHead operations limit reached"),this.name=Wa.errorName}};wn(Yi,"errorName","OperationLimitError");let Jn=Yi;const Gi=class qa extends Error{constructor(t){super(t),this.name=qa.errorName}};wn(Gi,"errorName","OperationError");let Qi=Gi;const Zi=class Na extends Error{constructor(){super("ChainHead operation inaccessible"),this.name=Na.errorName}};wn(Zi,"errorName","OperationInaccessibleError");let er=Zi;const Ve={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},tr={chainName:"",genesisHash:"",properties:""},Gr={broadcast:"",stop:""};Object.entries({chainHead:Ve,chainSpec:tr,transaction:Gr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});var Rf=Object.defineProperty,Tf=(e,t,n)=>t in e?Rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qr=(e,t,n)=>Tf(e,t+"",n);const Ji=class Ka extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name=Ka.errorName}};Qr(Ji,"errorName","BlockHashNotFoundError");let ea=Ji;const ta=class Xa extends Error{constructor(t){super(`Storage Error: ${t}`),this.name=Xa.errorName}};Qr(ta,"errorName","StorageError");let Pf=ta;const na=class Ya extends Error{constructor(t){super(`Call Error: ${t}`),this.name=Ya.errorName}};Qr(na,"errorName","CallError");let Uf=na;const Yt=()=>{},Mf=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Gr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Gr.stop,[o]),s=Yt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function Lf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Gt=e=>(...t)=>new Promise((n,r)=>{let s=It;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],a=()=>{s(),r(new so)};i?.addEventListener("abort",a,{once:!0});const l=c=>u=>{s=It,i?.removeEventListener("abort",a),c(u)};s=e(l(n),l(r),...o)}),ra=(e,t)=>n=>Gt((r,s,...o)=>{let i=!0,a=()=>{i=!1};const[l,c]=t(...o);return n(e,l,{onSuccess:(u,v)=>{if(u.result==="limitReached")return s(new Jn);const{operationId:h}=u,f=()=>{n(Ve.stopOperation,[h])};if(!i)return f();let d=Yt;const p=b=>{i=!1,d(),r(b)},m=b=>{i=!1,d(),s(b)};d=v(h,{next:b=>{const y=b;y.event==="operationError"?s(new Qi(y.error)):y.event==="operationInaccessible"?s(new er):c(b,p,m)},error:m}),a=()=>{i&&(d(),f())}},onError:s}),()=>{a()}}),Vf=ra(Ve.body,e=>[[e],(t,n)=>{n(t.value)}]),Df=ra(Ve.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Hf=e=>t=>new Promise((n,r)=>{e(Ve.header,[t],{onSuccess:n,onError:r})}),sa=e=>(t,n,r,s,o,i,a)=>{if(n.length===0)return i(),It;let l=!0,c=()=>{l=!1};return e(Ve.storage,[t,n,r],{onSuccess:(u,v)=>{if(u.result==="limitReached"||u.discardedItems===n.length)return o(new Jn);const{operationId:h}=u,f=()=>{e(Ve.stopOperation,[h])};if(!l)return f();const d=v(u.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{s(b.items);break}case"operationStorageDone":{m();break}case"operationError":{p(new Qi(b.error));break}case"operationInaccessible":{p(new er);break}default:e(Ve.continue,[b.operationId])}},error:o});c=()=>{d(),e(Ve.stopOperation,[u.operationId])};const p=b=>{c=It,d(),o(b)},m=()=>{c=It,d(),i()};a(u.discardedItems)},onError:o}),()=>{c()}},Ff=e=>{const t=sa(e);return Gt((n,r,s,o,i,a)=>{const l=o.startsWith("descendants");let c=l?[]:null;const v=t(s,[{key:i,type:o}],a??null,l?h=>{c.push(h)}:h=>{c=h[0]?.[o]},r,()=>{try{n(l?c.flat():c)}catch(h){r(h)}},h=>{h>0&&(v(),r(new Jn))});return v})},zf=e=>t=>t.length>0?new Promise((n,r)=>{e(Ve.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function jf(e){return e.operationId!==void 0}function Wf(e){return(t,n,r)=>{const s=qi(),o=new Set,i=Lf();let a=i.promise,l=Yt;const c=d=>{e(Ve.unfollow,[d])},u=d=>{l(),a!==null&&(d&&(a instanceof Promise?a.then(p=>{typeof p=="string"&&c(p)}):c(a)),a=null,o.forEach(p=>{p()}),o.clear(),s.errorAll(new Zn))},v=d=>{if(jf(d))return s.next(d.operationId,d);switch(d.event){case"stop":return r(new Ki),u(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:p,...m}=d;return n({type:p,...m})}},h=d=>{r(d),u(!(d instanceof Yr))};e(Ve.follow,[t],{onSuccess:(d,p)=>{a instanceof Promise&&(a=d,l=p(d,{next:v,error:h})),i.res(d)},onError:d=>{a=null,i.res(d),r(d)}});const f=(d,p,m)=>{const b=()=>{m?.onError(new Zn)};if(a===null)return b(),Yt;const y=w=>{if(!m)return e(d,[w,...p]);o.add(b);const x=(B,O)=>a===null?(O.error(new Zn),Yt):(s.subscribe(B,O),()=>{s.unsubscribe(B)}),E=e(d,[w,...p],{onSuccess:B=>{o.delete(b),m.onSuccess(B,x)},onError:B=>{o.delete(b),m.onError(B)}});return()=>{o.delete(b),E()}};if(typeof a=="string")return y(a);let g=Yt;return a.then(w=>{if(w instanceof Error)return b();a&&(g=y(w))}),()=>{g()}};return{unfollow(){u(!0)},body:Vf(f),call:Df(f),header:Hf(f),storage:Ff(f),storageSubscription:sa(f),unpin:zf(f),_request:f}}}const qf=e=>{const t=Gt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(tr.chainName,[]),t(tr.genesisHash,[]),t(tr.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Nf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),It;let a=!0,l=()=>{a=!1};return e("storage",[t,n,r],{onSuccess:(c,u)=>{const v=()=>{e("stopStorage",[c])};if(!a)return v();const h=u(c,{next:m=>{const{event:b}=m;if(b==="storage"){const{event:y,...g}=m;s(g)}else b==="storageDone"?p():d(new Pf(m.error))},error:o}),f=()=>{l=It,h()};l=()=>{f(),v()};const d=m=>{f(),o(m)},p=()=>{f(),i()}},onError:o}),()=>{l()}},Kf=e=>Gt((t,n,r,s,o,i)=>{const a=s.startsWith("descendants");let l=a?[]:null;const c=a?l.push.bind(l):({[s]:u})=>{l=u};return e(r,[{key:o,type:s}],i,c,u=>{n(u),l=null},()=>{t(l),l=null})}),oa=()=>e=>e,ia=()=>(e,t)=>{if(e===null)throw new ea(t);return e},Xf=e=>{const t=(u,...v)=>e(`archive_v1_${u}`,...v),n=u=>v=>Gt((h,f,...d)=>t(u,d,{onSuccess:p=>{try{h(v(p,...d))}catch(m){f(m)}},onError:f})),r=n("header")(ia()),s=n("body")(ia()),o=Nf(t),i=Kf(o),a=n("call")((u,v)=>{if(!u)throw new ea(v);if(!u.success)throw new Uf(u.error);return u.value}),l=n("finalizedHeight")(oa()),c=n("hashByHeight")(oa());return{header:r,body:s,storageSubscription:o,storage:i,call:a,finalizedHeight:l,hashByHeight:c}},Yf=e=>{const{request:t,disconnect:n}=_f(e);return{archive:Xf(t),chainHead:Wf(t),transaction:Mf(t),getChainSpecData:qf(t),destroy:n,request:Gt((r,s,o,i)=>t(o,i,{onSuccess:r,onError:s})),_request:t}};var Gf=Object.defineProperty,Qf=(e,t,n)=>t in e?Gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,aa=(e,t,n)=>Qf(e,typeof t!="symbol"?t+"":t,n);class Zf{constructor(){aa(this,"first"),aa(this,"last")}getRemoveFn(t){return()=>{t.prev?t.prev.next=t.next:this.first=t.next,t.next?t.next.prev=t.prev:this.last=t.prev,delete t.prev,delete t.next}}push(t){const n={value:t};return this.last===void 0?this.last=this.first=n:(this.last.next=n,n.prev=this.last,this.last=n),this.getRemoveFn(n)}unshift(t){return this.first={value:t,next:this.first},this.first.next&&(this.first.next.prev=this.first),this.last||(this.last=this.first),this.getRemoveFn(this.first)}pop(){const t=this.first?.value;return this.first&&(this.first=this.first.next,this.first?(delete this.first.prev?.next,delete this.first.prev):this.last=void 0),t}isEmpty(){return!this.first}}const Jf=()=>{const e=new Map,t=(h,f)=>{e.set(h,()=>{e.delete(h),f()})},n=h=>{e.get(h)?.()},r=new Zf,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,f)=>{const d=f?s:o;t(h.source$,d(h))},a=()=>{const h=r.pop();h&&(e.delete(h.source$),l(h))},l=h=>{const{source$:f,observer:d}=h;let p=!1;const m=f.subscribe({next(b){d.next(b)},error(b){(p=b instanceof Error&&b.name===Jn.errorName)?i(h,!0):d.error(b)},complete(){d.complete()}});m.closed?p||a():t(f,()=>{m.unsubscribe(),a()})},c=(h=!1)=>f=>new M(d=>{const p={observer:d,source$:f};return r.isEmpty()?l(p):i(p,h),()=>{n(f)}}),u=c();return{withRecovery:c,withRecoveryFn:h=>(...f)=>u(h(...f))}};class Qe extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Zr=e=>{const t=e.pipe(Se(n=>n instanceof Error&&n.name===er.errorName?Yn(750).pipe(mf(()=>t)):Rt(()=>n)));return t},eh=new Set(["best","finalized",null]),th=(e,t,n)=>r=>(s,...o)=>{if(!eh.has(s))return Zr(r(s,...o)).pipe(n(s));const a=(s==="best"?t:e).pipe(ye(1),L(l=>r(l,...o).pipe(n(l))),Se(l=>l instanceof Qe?a:Rt(()=>l)));return Zr(a)},Tt=e=>(...t)=>new M(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),nh=e=>t=>(...n)=>e()[t](...n);var be=(e=>(e[e.Initializing=0]="Initializing",e[e.Ready=1]="Ready",e[e.RecoveringInit=2]="RecoveringInit",e[e.RecoveringFin=3]="RecoveringFin",e))(be||{});function nr(e,t,n){return(r,...s)=>{let o;const i=()=>new Qe(r,n),a=t(r,...s).pipe(k(c=>({type:"val",value:c})),Hi({type:"end"})),l=e.pipe(Xt(c=>!c.blocks.has(r)),k(c=>{if(c.blocks.get(c.finalized).number>=o.number)throw i()}),Nr());return e.pipe(k(c=>c.state.type===be.Ready),fe(),bn(c=>c?(o||(o=e.state.blocks.get(r)),o?Kt(l,a):Rt(i)):uf),Xt(c=>c.type==="val"),k(c=>c.value))}}const rh=(e,t)=>{const n=(r,s,o,i)=>new M(a=>e().storageSubscription(r,s,o??null,l=>{a.next(l)},l=>{a.error(l)},()=>{a.complete()},l=>{l>0&&a.next(n(r,s.slice(-l),o,!0))})).pipe(Kn(),t(i));return n},sh=[Ft,kr],oh=(e,t)=>sh.find(n=>Z(n(ve(e)))===t)||(()=>{throw new Error("Unsupported hasher")}),ih=e=>{const t=(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return ne([[o,r.id],[i,s.id]]);const a=r.idx+Math.floor((s.idx-r.idx)/2);return e(n[a]).pipe(L(l=>{const c={id:l,idx:a};return c.id===r.id?t(n,c,s):c.id===s.id?t(n,r,c):it([t(n,r,c),t(n,c,s)]).pipe(k(([u,[v,...h]])=>[...u,...h]))}))};return n=>{const[r]=n;if(n.length===1)return e(r).pipe(k(o=>[[r,o]]));const s=n.length-1;return it([r,n[s]].map(e)).pipe(L(([o,i])=>o===i?ne([[r,o]]):t(n,{idx:0,id:o},{idx:s,id:i})))}},ah=(e,t,n)=>{const r=ih(t),s=l=>Xn(()=>e().header(l)),o=new pn(1),i=l=>{if(l.type==="initialized"){const[c]=l.finalizedBlockHashes;return it([s(c),r(l.finalizedBlockHashes)]).pipe(k(([u,v])=>{o.closed||(o.next(oh(u,c)),o.complete());const{number:h,parentHash:f,digests:d}=Ln.dec(u);return{type:"initialized",finalizedBlockHashes:l.finalizedBlockHashes,runtimeChanges:new Map(v),number:h,parentHash:f,hasNewRuntime:d.some(p=>p.type==="runtimeUpdated")}}))}if(l.type==="newBlock"&&l.newRuntime)return t(l.blockHash).pipe(k(c=>({...l,codeHash:c})))},a=l=>new M(c=>{let u=null,v;const h=p=>u?.push(p)||f(p),f=p=>{const m=i(p);m?(u=[],v=m.subscribe({next:b=>{const y=[...u];u=null,c.next(b),y.forEach(h)},error:n})):c.next(p)},d=l.subscribe(p=>{p.type==="stop-error"?(v?.unsubscribe(),u=null,c.next(p)):h(p)});return()=>{v?.unsubscribe(),d.unsubscribe()}});return{getHeader:l=>s(l).pipe(k(Ln[1])),hasher$:o.asObservable(),enhancer:a}},ch=(e,t)=>{let n=null,r=!1,s=()=>{r=!0};const o=()=>{if(!n)throw new Error("Missing chainHead subscription");return n},i=t(Tt((h,f)=>o().storage(h,"hash","0x3a636f6465",null,f)));let a=$e;const{hasher$:l,enhancer:c,getHeader:u}=ah(o,i,()=>a()),v=new M(h=>{if(r)return h.complete();let f;const d=()=>{n=e(!0,p=>h.next(p),p=>{n=null,!r&&(p instanceof Error&&p.name===Ki.errorName?(d(),h.next({type:"stop-error"})):(console.warn("ChainHead follow request failed, retrying\u2026",p),f=setTimeout(d,250)))})};a=()=>{h.next({type:"stop-error"}),clearTimeout(f),n?.unfollow(),d()},d(),s=()=>{r=!0,clearTimeout(f),h.complete(),n?.unfollow()}}).pipe(c,yn());return{getHeader:u,hasher$:l,getFollower:o,follow$:v,unfollow:()=>{s()}}},lh=e=>Z(He.enc(e)),ca=ee(),uh=vt(ca),fh=Ie(He).dec,la=e=>{const t=e("Metadata_metadata_versions","").pipe(k(fh),Se(()=>ne([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(k(ca.dec)):e("Metadata_metadata_at_version",lh(s)).pipe(k(o=>uh.dec(o)))};return t.pipe(L(n))},ua=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Et={type:"void"},hh=(e,t=()=>null)=>{const n=new Map,r=new Set,s=u=>v=>{let h=n.get(v);if(h)return h;if(r.has(v)){const d={id:v};return n.set(v,d),d}r.add(v);const f=u(v);return h=n.get(v),h?Object.assign(h,f):(h={id:v,...f},n.set(v,h)),r.delete(v),h};let o=!0,i=!0;const a=s(u=>{const v=t(e[u]);if(v)return v;const{def:h,path:f,params:d}=e[u];if(h.tag==="composite"){if(h.value.length===0)return Et;if(h.value.length===1){const p=a(h.value[0].type);return o&&f.at(-1)==="AccountId32"&&ua(p,32)?(o=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&ua(p,20)?(i=!1,{type:"AccountId20"}):p}return l(h.value)}if(h.tag==="variant"){if(f.length===1&&f[0]==="Option"&&d.length===1&&d[0].name==="T"){const b=a(d[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}if(f.length===1&&f[0]==="Result"&&d.length===2&&d[0].name==="T"&&d[1].name==="E")return{type:"result",value:{ok:a(d[0].type),ko:a(d[1].type)}};if(h.value.length===0)return Et;const p={},m={};return h.value.forEach(b=>{const y=b.name;if(m[y]=b.docs,b.fields.length===0){p[y]={...Et,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){p[y]={type:"lookupEntry",value:a(b.fields[0].type),idx:b.index};return}p[y]={...l(b.fields),idx:b.index}}),{type:"enum",value:p,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:a(h.value)};if(h.tag==="array"){const{len:p}=h.value,m=a(h.value.type);return!p||m.type==="void"?Et:p>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?Et:h.value.length>1?c(h.value.map(p=>a(p)),h.value.map(p=>e[p].docs)):a(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=a(h.value);return p.type==="void"?Et:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),l=u=>{let v=!0;const h={},f={};return u.forEach((d,p)=>{v=v&&!!d.name;const m=d.name||p,b=a(d.type);b.type!=="void"&&(h[m]=b,f[m]=d.docs)}),v?{type:"struct",value:h,innerDocs:f}:c(Object.values(h),Object.values(f))},c=(u,v)=>{if(u.every(h=>h.id===u[0].id)&&v.every(h=>!h.length)){const[h]=u;return h.type==="void"?Et:{type:"array",value:u[0],len:u.length}}return{type:"tuple",value:u,innerDocs:v}};return a},rr=e=>{const t=hh(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...Et,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),a=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&a.type==="array"&&a.value.type==="primitive"&&a.value.value==="u8"?1+a.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},dh=(e,t,n)=>(r,s,o,...i)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(o.has(a)){const c=t(()=>s.get(a),r,...i);return s.set(a,c),c}o.add(a);let l=e(r,s,o,...i);return o.delete(a),s.has(a)&&(l=n(l,s.get(a),r,...i)),s.set(a,l),l},ph=ln(),fa=dh((e,t,n,r)=>{if(e.type==="primitive")return ei[e.value];if(e.type==="void")return P;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return So;if(e.type==="compact")return e.isBig?Pn:C;if(e.type==="bitSequence")return Mn(e.isLSB);const s=f=>fa(f,t,n,r),o=(f,d)=>{const p=s(f);return d?Ie(p,d):Ie(p)},i=f=>Fe(...f.map(s)),a=f=>{const d=Object.fromEntries(Object.entries(f).map(([p,m])=>[p,s(m)]));return ue(d)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return ph;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?ln(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return vt(s(e.value));if(e.type==="result")return Un(s(e.value.ok),s(e.value.ko));const l=Object.values(e.value).map(f=>{switch(f.type){case"void":return P;case"lookupEntry":return s(f.value);case"tuple":return i(f.value);case"struct":return a(f.value);case"array":return o(f.value,f.len)}}),c=Object.fromEntries(Object.keys(e.value).map((f,d)=>[f,l[d]])),u=Object.values(e.value).map(f=>f.idx),h=u.every((f,d)=>f===d)?ke(c):ke(c,u);return e.byteLength?vh(h,e.byteLength):h},gr,e=>e),ha=(e,t=St())=>{const n=new Map,r=s=>fa(e(s),n,new Set,t);return s=>r(s)},vh=(e,t)=>{const n=ee(t);return K(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},mh=qe(P,()=>{},()=>null),Jr=e=>{const{metadata:t}=e;let n=ha(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let s;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(s=h,n=ha(e,St(h)))}catch{}const o=new Map,i=(h,f)=>{let d=o.get(h);d||o.set(h,d=Xo(h));const p=t.pallets.find(O=>O.name===h).storage.items.find(O=>O.name===f),m=O=>O===P?mh:O,b=(O,A,...I)=>{const R=d(...I),[,...F]=I;return{args:Fe(...F.map(([D])=>D)),keys:R,value:A,len:O,fallback:p.modifier===1?A.dec(p.fallback):void 0}};if(p.type.tag==="plain")return b(0,m(n(p.type.value)),f);const{key:y,value:g,hashers:w}=p.type.value,x=m(n(g)),E=w.map(O=>ei[O.tag]),B=(()=>{if(E.length===1)return[[n(y),E[0]]];const O=e(y);switch(O.type){case"array":return E.map(A=>[n(O.value.id),A]);case"tuple":return O.value.map((A,I)=>[n(A.id),E[I]]);default:throw new Error("Invalid key type")}})();return b(E.length,x,f,...B)},a=h=>{switch(h.type){case"void":return P;case"lookupEntry":return n(h.value.id);case"tuple":return Fe(...Object.values(h.value).map(f=>n(f.id)));case"struct":return ue(Vt(h.value,f=>n(f.id)));case"array":return Ie(n(h.value.id),h.len)}},l=(h,f)=>{const d=t.pallets.find(p=>p.name===h).constants.find(p=>p.name===f);return n(d.type)},c=h=>(f,d)=>{const p=t.pallets.find(y=>y.name===f),m=e(p[h].type);if(m.type!=="enum")throw null;const b=m.value[d];return{location:[p.index,b.idx],codec:a(m.value[d])}},u=(h,f)=>{const d=t.pallets.find(p=>p.name===h)?.viewFns.find(p=>p.name===f);if(!d)throw null;return{args:Fe(...d.inputs.map(p=>n(p.type))),value:n(d.output)}},v=(h,f)=>{const d=t.apis.find(p=>p.name===h)?.methods.find(p=>p.name===f);if(!d)throw null;return{args:Fe(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:c("events"),buildError:c("errors"),buildViewFn:u,buildRuntimeCall:v,buildCall:c("calls"),buildConstant:l,ss58Prefix:s}},da="CheckMortality",pa=(e,t,n)=>{const r=rr(e),s=Jr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(u=>u.identifier==="ChargeAssetTxPayment");let a=null;if(i){const u=r(i.type);if(u.type==="struct"){const v=u.value.asset_id;v.type==="option"&&(a=v.value.id)}}const l=gh(r.metadata,s),c=u=>{const v=l(u);return"extra"in v&&v.extra[da]||{mortal:!1}};return{assetId:a,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:St(s.ss58Prefix),getMortalityFromTx:c,extVersions:e.extrinsic.version}},es=ee(1/0).dec,yh=$n(Ne[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),bh=et(e=>{const t=z.dec(e);if(t===0)return{mortal:!1};const n=z.dec(e);return yh(Uint8Array.from([t,n]))}),gh=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(a=>[a.identifier,a.identifier===da?bh:t.buildDefinition(a.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const a=e.lookup[o.type]?.params,l=a?.find(v=>v.name==="Call")?.type,c=a?.find(v=>v.name==="Address")?.type,u=a?.find(v=>v.name==="Signature")?.type;if(l==null||c==null||u==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(c)[1],s=t.buildDefinition(u)[1]}const i=ue.dec({address:r,signature:s,extra:ue.dec(n),callData:es});return et(a=>{const l=C.dec(a),{type:c,version:u}=Or[1](a);if(c==="bare")return{len:l,version:u,type:c,callData:es(a)};if(c==="signed")return{len:l,version:u,type:c,...i(a)};const v=z.dec(a);let h;if(e.version===16){const d=e.extrinsic.signedExtensionsByVersion.find(([p])=>p===v);if(!d)throw new Error("Unexpected extension version");h=ue.dec(Object.fromEntries(Object.entries(n).filter((p,m)=>d[1].includes(m))))}else h=ue.dec(n);const f=h(a);return{len:l,type:c,version:u,extensionVersion:v,extra:f,callData:es(a)}})},wh=e=>t=>{const n=(...r)=>{let s;try{s=e()}catch(o){return Rt(o)}return s?t(s,...r).pipe(Se(o=>{if(o instanceof Qe)return n(...r);if(o instanceof Error&&o.name===er.errorName)return Yn(750).pipe(L(()=>n(...r)));throw o})):gt};return n},xh=(e,t,n)=>{const r=(s,o)=>t(s).pipe(Se(()=>ne(null)),L(i=>i?ne(i):o.pipe(gn(a=>{n(s,a)}))),k(i=>({codeHash:s,metadataRaw:i,metadata:Ht(mt.dec(i))})));return(s,o)=>{const i=new Set([o]),a={},l=wh(()=>{if(!i.size)throw a;return i.has(o)?o:[...i].at(-1)}),c=r(s,la(l(e)).pipe(Se(v=>v===a?gt:Rt(()=>v)))).pipe(k(({metadata:v,metadataRaw:h,codeHash:f})=>pa(v,h,f)),Qn(1)),u={codeHash:s,runtime:c,addBlock:v=>{i.add(v)},deleteBlocks:v=>(v.forEach(h=>{i.delete(h)}),i.size),usages:i};return c.subscribe({error(){}}),u}},xn=yn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),sr=({hash:e,number:t,parent:n,hasNewRuntime:r})=>({hash:e,number:t,parent:n,hasNewRuntime:r}),Eh=(e,t,n,r,s,o,i,a)=>{const l=({blocks:y,runtimes:g},w)=>{w.forEach(x=>{y.get(y.get(x).parent)?.children.delete(x),y.delete(x),a(x)}),Object.entries(g).map(([x,E])=>({key:x,usages:E.deleteBlocks(w)})).filter(x=>x.usages===0).map(x=>x.key).forEach(x=>{delete g[x]})},c=y=>{o.next(sr(y))},u=y=>{l(y,[...y.blocks.values()].filter(w=>w.recovering).map(w=>w.hash));const g="pendingBlocks"in y.state?y.state.pendingBlocks:[];y.state={type:be.Ready},g.forEach(c)},v=new je,h=v.pipe(Ef(()=>Yn(0)),k(()=>({type:"cleanup"}))),f=va(),d=()=>(l(f,[...f.blocks.values()].map(y=>y.hash)),Object.assign(f,va())),p=mn(s,h,e).pipe(Gn((y,g)=>{const w=E=>{l(y,E),i(E)},x=(...E)=>{const B=y.blocks.get(y.finalized)?.number??-1,O=E.filter(({refCount:A,recovering:I,number:R,pruned:F})=>!A&&!I&&(F||R<B)).map(({hash:A})=>A);O.length&&w(O)};switch(g.type){case"initialized":if(y.state.type!==be.Initializing&&y.state.type!==be.RecoveringInit)throw new Error("Initialized event out of order");y.state.type===be.RecoveringInit&&!g.finalizedBlockHashes.some(I=>y.blocks.has(I))&&(d(),o.next(null));const E=y.blocks.get(y.finalized)?.number??-1,B=g.finalizedBlockHashes.length-1,O=[];E>g.number+B?y.state={type:be.RecoveringFin,target:E,pendingBlocks:O}:(y.state={type:be.Initializing,pendingBlocks:O},y.finalized=g.finalizedBlockHashes[B]);let A=y.finalizedRuntime.codeHash;return g.finalizedBlockHashes.forEach((I,R)=>{const F=y.blocks.get(I);if(F)F.recovering=!1;else{const D=g.number+R,X=D>E,H=g.runtimeChanges.get(I),re=H&&!y.runtimes[H]&&X;re&&(A=H);const G=R===0?g.parentHash:g.finalizedBlockHashes[R-1],se={hash:I,hasNewRuntime:R?g.runtimeChanges.has(I):g.hasNewRuntime,parent:G,children:new Set(R===B?[]:[g.finalizedBlockHashes[R+1]]),pruned:!1,runtime:A,refCount:0,number:D,recovering:!1};y.blocks.set(I,se),re&&(y.finalizedRuntime=y.runtimes[H]=b(H,I)),y.runtimes[A].usages.add(I),X&&O.push(se)}}),y;case"stop-error":if(y.state.type===be.Initializing)return d();for(const I of y.blocks.values())I.recovering=!0;return y.state={type:be.RecoveringInit},y;case"newBlock":{const{parentBlockHash:I,blockHash:R}=g;if(y.blocks.has(R))y.blocks.get(R).recovering=!1;else{const F=y.blocks.get(I);F.children.add(R);const D=F.number+1,X={hash:R,number:D,parent:I,children:new Set,runtime:F.runtime,pruned:!1,refCount:0,recovering:!1,hasNewRuntime:!!g.newRuntime};if(y.blocks.set(R,X),g.newRuntime){const{codeHash:H}=g;X.runtime=H,y.runtimes[H]=b(H,R)}y.runtimes[X.runtime].addBlock(R),"pendingBlocks"in y.state?y.state.pendingBlocks.push(X):c(X)}return y}case"bestBlockChanged":return y.state.type===be.RecoveringFin||(y.best=g.bestBlockHash,y.state.type===be.Initializing&&u(y)),y;case"finalized":{const I=g.finalizedBlockHashes.slice(-1)[0];let R=!1;if(y.state.type===be.RecoveringFin){if(y.blocks.get(I).number<y.state.target)return y;R=!0}y.finalized=I;const{blocks:F}=y;return F.get(y.best).number<F.get(y.finalized).number&&(y.best=y.finalized),y.finalizedRuntime=y.runtimes[F.get(y.finalized).runtime],g.prunedBlockHashes.forEach(D=>{const X=y.blocks.get(D);X&&(X.pruned=!0)}),R&&u(y),y.state.type===be.Ready&&v.next(),y}case"cleanup":return x(...y.blocks.values()),y;case"blockUsage":{const I=y.blocks.get(g.value.hash);return I&&(I.refCount+=g.value.type==="hold"?1:-1,x(I)),y}}},f),k(y=>({...y})),gn({error(y){o.error(y)}}),xn),m=Object.assign(p,{state:f}),b=xh(nr(m,t,"pinned-blocks"),n,r);return m},va=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},state:{type:be.Initializing,pendingBlocks:[]}}),ma=(e,t,n,r,s,o)=>{const i=new Map,a=f=>{i.get(f)?.(),i.delete(f)},l=new M(f=>{const d=t.subscribe({next:({hash:p})=>{i.set(p,o(p))},complete(){f.error(new Error("Tracking stopped"))}});return d.add(e.pipe(k(p=>p.finalized),fe()).subscribe(()=>{e.state.blocks.forEach(({pruned:p,hash:m})=>{p&&a(m)})})),d.add(()=>[...i.keys()].forEach(a)),d}),c=f=>zi(e.pipe(at(({blocks:d})=>d.get(f)?.pruned??!0))),u=(f,d,p)=>{if(p)return ne({hash:f,found:{type:!1,validity:null}});const m=c(f);return n(f).pipe(L(b=>{const y=b.indexOf(d);return y>-1?m(s(f)).pipe(k(g=>({hash:f,found:{type:!0,index:y,events:g}}))):r(f,d).pipe(k(g=>({hash:f,found:{type:!1,validity:g}})))}),m,kf(()=>a(f)))},v=f=>{[...e.state.blocks.get(f)?.children.keys()??[]].forEach(v),a(f)},h=(f,d,p)=>u(f,d,p.has(f)).pipe(L(m=>{const{found:b}=m,y=b.type||b.validity?.success===!1;return y&&v(f),y?ne(m):e.pipe(c(f),L(g=>g.blocks.get(f).children),wf(),L(g=>h(g,d,p)))}));return f=>mn(l,e.pipe(ye(1),L(d=>h(d.finalized,f,new Set(d.blocks.keys())))))},kh=new Uint8Array([2]),Ah=(e,t)=>Z(ie([kh,ve(e),ve(t)])),ya="TaggedTransactionQueue",ba="validate_transaction",[,$h]=ke({InvalidTransaction:ke({Call:P,Payment:P,Future:P,Stale:P,BadProof:P,AncientBirthBlock:P,ExhaustsResources:P,Custom:z,BadMandatory:P,MandatoryValidation:P,BadSigner:P}),UnknownTransaction:ke({CannotLookup:P,NoUnsignedValidator:P,Custom:z})}),Sh=et(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=$h(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Ih=(e,t)=>(n,r)=>{const s=t(n).pipe(k(o=>{try{return o.dynamicBuilder.buildRuntimeCall(ya,ba).value[1]}catch{return Sh}}));return e(n,`${ya}_${ba}`,Ah(r,n)).pipe(Xr(s),k(([o,i])=>i(o)))},Bh=e=>t=>new M(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),_h=e=>t=>new M(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),ga=(e,t=1/0)=>n=>new M(r=>{let s;const o=new Map,i=new Map,a=new Map;let l=0,c=0,u=0;const v=()=>{const h=o.get(c);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const f=c++;o.delete(f),u!==f&&a.set(f,[]);let d=!1,p=h.subscribe({next(m){u===f?r.next(m):a.get(f).push(m)},complete(){if(d=!0,i.delete(f),f===u)for(u++;a.has(u)&&(a.get(u).forEach(m=>r.next(m)),a.delete(u),!i.has(u));)u++;v()},error(m){r.error(m)}});d||i.set(f,p)};return s=new qt,s.add(n.subscribe({next(h){const f=l++;o.set(f,Xn(()=>e(h,f))),i.size<t&&v()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),a.clear()}}),Ch=(e,t,n)=>{const{withRecovery:r,withRecoveryFn:s}=Jf(),{getFollower:o,unfollow:i,follow$:a,getHeader:l,hasher$:c}=ch(e,s),u=nh(o),v=new je,h=$=>_=>new M(T=>{v.next({type:"blockUsage",value:{type:"hold",hash:$}});const j=_.subscribe(T);return j.add(()=>{setTimeout(()=>{v.next({type:"blockUsage",value:{type:"release",hash:$}})},0)}),j}),f=$=>(_,...T)=>$(_,...T).pipe(h(_)),d=($,_)=>(T,...j)=>new M(he=>g.state.blocks.has(T)?$(T,...j).subscribe(he):he.error(new Qe(T,_))),p=$=>o().unpin($).catch(_=>{if(!(_ instanceof Error&&_.name===Zn.errorName))throw _}),m=($,_)=>d(f(nr(g,s(Tt($)),`stop-${_}`)),_),b=new Map,y=new je,g=Eh(a,f(s(Tt(u("call")))),t,n,v,y,$=>{p($).catch(_=>{console.error("unpin",_)}),$.forEach(_=>{b.delete(_)})},$=>{b.delete($)}),w=d(f($=>g.state.runtimes[g.state.blocks.get($).runtime].runtime),"getRuntimeCtx"),x=$=>_=>_.pipe(ga(T=>w($(T)).pipe(k(j=>[T,j])))),E=($,_,T)=>{const j=b.get($)??new Map,he=j.get(_);if(he)return he;b.set($,j);let At;const ct=T.pipe(yn({connector:()=>At=new pn}),gn({complete(){j.set(_,At)}}),_h());return j.set(_,ct),ct},B=Object.assign(g.pipe(at($=>$.state.type===be.Ready)),{state:g.state}),O=B.pipe(fe(($,_)=>$.finalized===_.finalized),Gn(($,_)=>{let T=_.blocks.get(_.finalized);const j=[T],he=$.at(-1);if(!he)return j;for(;T.number>he.number+1&&(T=_.blocks.get(T.parent),!!T);)j.unshift(T);return j},[]),Kn(),k(sr),xn),A=B.pipe(fe(($,_)=>$.best===_.best),k($=>sr($.blocks.get($.best))),xn),I=B.pipe(fe(($,_)=>$.finalized===_.finalized&&$.best===_.best),Gn(($,_)=>{const T=De=>$.get(De)||sr(_.blocks.get(De)),j=T(_.best),he=T(_.finalized),At=j.number-he.number+1,ct=new Array(At);for(let De=0,Fa=j.hash;De<At;De++)ct[De]=T(Fa),Fa=ct[De].parent;return new Map(ct.map(De=>[De.hash,De]))},new Map),k($=>[...$.values()]),xn),R=B.pipe(fe(($,_)=>$.finalizedRuntime===_.finalizedRuntime),bn(({finalizedRuntime:{runtime:$}})=>$.pipe(Bh(null))),xn),F=R.pipe(k($=>$?.lookup.metadata??null)),D=th(O.pipe(k($=>$.hash)),A.pipe(k($=>$.hash)),h),X=m(u("body"),"body"),H=$=>Zr(E($,"body",X($))),re=m(u("storage"),"storage"),G=D(d(($,_,T,j=null,he)=>g.state.runtimes[g.state.blocks.get($).runtime].runtime.pipe(L(At=>{const ct=T(At);return E($,`storage-${_}-${ct}-${j??""}`,re($,_,ct,j)).pipe(he?k(De=>he(De,At)):Ge)})),"storage")),se=rh(o,r),Je=D(d(nr(g,($,_,T)=>se($,_,T??null,!1),"storageQueries"),"storageQueries")),lr=D(d(nr(g,l,"header"),"header")),en=$=>G($,"value",_=>_.events.key,null,(_,T)=>T.events.dec(_)),ms=m(u("call"),"call"),Ha=D(($,_,T)=>E($,`call-${_}-${T}`,ms($,_,T))),ys=Ih(Ha,w),Od=R.pipe(at(Boolean),ye(1),L($=>{const{enc:_}=$.dynamicBuilder.buildStorage("System","BlockHash").keys;let T;try{T=_(0)}catch{T=_(0n)}return G(null,"value",()=>T,null)}),Qn(1));mn(R,I).subscribe({error(){}});const Rd=$=>g.state.runtimes[$]?.runtime??ne(null),ur=($,_=!1)=>{let T=$||"finalized";if(T=g.state[T]||T,!g.state.blocks.has(T)){if(_)throw new Qe(T,"holdBlock");return $e}v.next({type:"blockUsage",value:{type:"hold",hash:T}});let j=()=>{v.next({type:"blockUsage",value:{type:"release",hash:T}}),j=$e};return()=>{j()}},Td=$=>_=>new M(T=>{const j=_.subscribe(T);return j.closed||j.add(ur($)),j}),bs=y.pipe(Xt(Boolean)),Pd=ma(B,bs,H,ys,en,ur),Ud=ma(g,bs,H,ys,()=>ne(),ur);return{follow$:a,unfollow:i,finalized$:O,best$:A,bestBlocks$:I,newBlocks$:Kt(B.pipe(ye(1),L(({blocks:$,finalized:_})=>{const T=j=>{const he=$.get(j);return he?[he,...Array.from(he.children).flatMap(T)]:[]};return T(_)})),bs),runtime$:R,metadata$:F,genesis$:Od,hasher$:c,getRuntime$:Rd,header$:lr,body$:H,call$:Ha,storage$:G,storageQueries$:Je,eventsAt$:en,withHodl:Td,holdBlock:ur,trackTx$:Pd,trackTxWithoutEvents$:Ud,validateTx$:ys,pinnedBlocks$:B,withRuntime:x,getRuntimeContext$:D(w)}};var Oh=e=>t=>new M(n=>e(t,r=>{n.error(r)}));const Rh=({storageSubscription:e,...t})=>n=>{const r={},s=Tt(t.storage),o=Tt(t.call),i=Tt(t.header),a=Tt(t.body),l=p=>i(p).pipe(k(Ln[1])),c=p=>s(p,"hash","0x3a636f6465",null).pipe(k(m=>m)),u=(p,m)=>n(p).pipe(Se(()=>ne(null)),L(b=>b?ne(b):la((...y)=>o(m,...y)).pipe(k(y=>pa(Ht(mt.dec(y)),y,p)))),gn(b=>{r[p]=b})),v=p=>c(p).pipe(L(m=>{const b=r[m];return b?ne(b):u(m,p)})),h=(p,m,b,y=null,g)=>v(p).pipe(L(w=>s(p,m,b(w),y).pipe(k(x=>g?g(x,w):x))));return{body$:a,header$:l,storage$:h,storageQueries$:(p,m,b)=>new M(y=>e(p,m,b||null,g=>y.next(g),g=>y.error(g),()=>{y.complete()})),call$:o,eventsAt$:p=>h(p,"value",m=>m.events.key,null,(m,b)=>b.events.dec(m)),getRuntimeContext$:v}},Th=()=>ne(null),Ph=(e,{getMetadata:t,setMetadata:n}={})=>({chainHead$:()=>Ch(e.chainHead,t||Th,n||$e),archive:Rh(e.archive),broadcastTx$:Oh(e.transaction),destroy:e.destroy}),Uh=(e,t)=>e.pipe(Xt(n=>n.blocks.has(t)),fe((n,r)=>n.finalized===r.finalized&&n.best===r.best),k(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),fe(),Xt(n=>n!=="finalized",!0)),Pt=(e,t)=>(n,...r)=>e(n,...r).pipe(Se(s=>{if(!(s instanceof Qe))throw s;return t(n,...r).pipe(Se(o=>{throw console.warn(o),s}))}));class Ut{constructor(){}_runtime(t){}}class ts{constructor(){}_compatibility(t){}}const or=new WeakMap,wa=new WeakMap,ir=e=>e instanceof Ut?wa.get(e):or.get(e);var kt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(kt||{});const Mh=Ie(du),Lh=Ie(Pr),Vh=Fe(Mh,Lh),Dh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(at(i=>i!=null));let o=await Le(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Vh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const a=new ts;return or.set(a,{runtime:i,getEntryPoint(l,c,u){const v=o[l]?.[c]?.[u];if(v==null)throw new Error(`Descriptor for ${l} ${c}.${u} does not exist`);return r[v]},typedefNodes:s}),a})},Hh=e=>new Promise(async t=>{const n=e.runtime$.pipe(at(s=>s!=null));let r=await Le(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Ut;return wa.set(n,{runtime:t}),n}),ns=new WeakMap,xa=e=>(ns.has(e.metadataRaw)||ns.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),ns.get(e.metadataRaw)),Mt=(e,t,n)=>{const r=(i,a)=>{var l;const c=xa(i);return(l=c.typeNodes)[a]||(l[a]=Hn(c.lookup(a)))};function s(i,a){if(i instanceof Ut)return{args:Pe.Identical,values:Pe.Identical};const l=or.get(i);a||(a=l.runtime());const c=n(a);if(c==null)return{args:Pe.Incompatible,values:Pe.Incompatible};const u=l.typedefNodes,v=xa(a),h=t(l),f=yu(h,d=>u[d],c,d=>r(a,d),v.compat);return{args:f.args.level,values:f.values.level}}const o=ka(e,i=>Ea(s(i)));return{isCompatible:ka(e,(i,a)=>o(a)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,a)=>l=>it([l.pipe(i.withRuntime(a)),e]).pipe(k(([[c,u],v])=>[c,v,u])),compatibleRuntime$:(i,a)=>it([e,i.getRuntimeContext$(a)]),argsAreCompatible:(i,a,l)=>{if(i instanceof Ut)return!0;const c=s(i,a);if(c.args===Pe.Incompatible)return!1;if(c.args>Pe.Partial)return!0;if(c.values===Pe.Incompatible)return!1;const u=n(a);return u==null?!1:ai(u.args,v=>r(a,v),l)},valuesAreCompatible:(i,a,l)=>{if(i instanceof Ut)return!0;const c=s(i,a).values;if(c===Pe.Incompatible)return!1;if(c>Pe.Partial)return!0;const u=or.get(i),v=t(u);return ai(v.values,h=>u.typedefNodes[h],l)},getRuntimeTypedef:r,storageKeysAreCompatible:(i,a,l)=>{const c=n(i);if(c==null)return!1;const u=h=>r(i,h),v=c.args.type==="lookup"?u(c.args.value):c.args.value;return iu(a,l,v,u)}}},Ea=e=>Math.min(e.args,e.values),ka=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof ts||r instanceof Ut?t(...n):e.then(s=>t(...n,s))},Fh=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,a=c=>{if(i.has(c))return i.get(c);const u=c.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(u==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const v=c.dynamicBuilder.buildConstant(e,t).dec(u.value);return i.set(c,v),v},l=c=>{if(c){const u=ir(c).runtime(),v=a(u);if(!n(c,u,v))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return v}return r.then(l)};return Object.assign(l,{isCompatible:s,getCompatibilityLevel:o})},zh=yn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Qt(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new so)}:$e;s=e.subscribe({next:a=>{n(a),s?.unsubscribe(),o=!0},error:a=>{t?.removeEventListener("abort",i),r(a),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const rs=Symbol("EMPTY_VALUE"),ss=e=>t=>new M(n=>{let r=0,s=null,o=rs,i=!1;const a=()=>{const c=e(o,r++);o=rs,s=c.subscribe({next(u){n.next(u)},error(u){n.error(u)},complete(){o!==rs?a():(s=null,i&&n.complete())}})},l=t.subscribe({next(c){o=c,s||a()},error(c){n.error(c)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),l.unsubscribe()}});let Aa={};const jh=e=>t=>new M(n=>{let r=Aa,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Aa?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Zt=e=>typeof e=="object"&&e!==null&&Object.entries(e).every(([t,n])=>t==="at"&&(n===void 0||typeof n=="string")||t==="signal"&&(n===void 0||n instanceof AbortSignal)),Wh=()=>{const e=new Ou(new je);return[e.pipe($f()),()=>gn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new je)},complete:()=>{e.value.complete(),e.next(new je)}})]},qh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const l=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),c=n.finalized$.pipe(o(n,u=>u.hash),k(([u,v,h])=>{const f=h.lookup.metadata.pallets.find(d=>d.name===e)?.events?.type;if(f==null||h.lookup.metadata.lookup[f].def.tag!=="variant"||h.lookup.metadata.lookup[f].def.value.find(d=>d.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(v,h,null))throw l();return[u,v,h]}),ga(([u,v,h])=>n.eventsAt$(u.hash).pipe(k(f=>f.filter(d=>d.event.type===e&&d.event.value.type===t).map(d=>{if(!a(v,h,d.event.value.value))throw l();return{meta:{phase:d.phase,block:u},payload:d.event.value.value}})))),zh);return{watch:u=>c.pipe(L(v=>u?v.filter(h=>u(h.payload)):v)),pull:()=>Le(c),filter:u=>u.filter(v=>v.type===e&&v.value.type===t).map(v=>v.value.value),getCompatibilityLevel:s,isCompatible:r}},Nh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const l=`${e}_${t}`,c=()=>new Error(`Incompatible runtime entry RuntimeCall(${l})`);return Object.assign((...u)=>{const v=u[u.length-1],h=Zt(v),{signal:f,at:d}=h?v:{},p=d??null,m=o(n,p).pipe(L(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${l}) not found`)}if(!i(b,y,u))throw c();return n.call$(p,l,Z(g.args.enc(u))).pipe(k(g.value.dec),k(w=>{if(!a(b,y,w))throw c();return w}))}),n.withHodl(p));return Qt(m,f)},{getCompatibilityLevel:s,isCompatible:r})},$a=k(e=>e.mapped),Kh=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:a,argsAreCompatible:l,storageKeysAreCompatible:c,valuesAreCompatible:u})=>{const v=e==="System"&&t==="Number",h=e==="System"&&t==="BlockHash",f=n.runtime$.pipe(at(Boolean),ye(1),k(({dynamicBuilder:A})=>typeof A.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Qn()),d=di(vf(f),k(([A,I])=>I(A))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=A=>new Error(`Invalid Arguments calling ${e}.${t}(${A})`),b=A=>{try{return A.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...A)=>{const I=A[A.length-1],R=I==="best",F=R||I==="finalized"?A.slice(0,-1):A;return n[R?"best$":"finalized$"].pipe(ss(()=>g(...F,R?{at:"best"}:{})),fe((D,X)=>D.raw===X.raw),$a)},g=(...A)=>{const I=A[A.length-1],R=Zt(I),{at:F}=R?I:{},D=F??null,X=xt(a).pipe(L(H=>n.storage$(D,"value",re=>{const G=b(re),se=A.length===G.len?A:A.slice(0,-1);if(A!==se&&!R)throw m(A);if(!c(re,se,G.len))throw p();return G.keys.enc(...se)},null,(re,G)=>{const se=b(G),Je=re===null?se.fallback:se.value.dec(re);if(re!==null&&!u(H,G,Je))throw p();return{raw:re,mapped:Je}})),n.withHodl(D));return v?n.pinnedBlocks$.pipe(k(H=>{const re=D==="finalized"||!D?H.finalized:D==="best"?H.best:D,G=H.blocks.get(re);if(!G)throw new Qe(re,"System.Number");return G.number}),fe(),d,k(H=>({raw:H.toString(),mapped:H})),Se(H=>{if(H instanceof Qe)return X;throw H})):h&&Number(A[0])===0?n.genesis$.pipe(k(H=>({raw:H,mapped:Tn.fromHex(H)}))):X},w=async(...A)=>{const I=A[A.length-1],R=Zt(I),{signal:F}=R?I:{};return Qt(g(...A).pipe($a),F)},x=async(...A)=>{const I=A[A.length-1],R=Zt(I),{signal:F,at:D}=R?I:{},X=D??null,H=xt(a).pipe(L(re=>n.storage$(X,"descendantsValues",G=>{const se=b(G);if(Ea(i(re,G))===Pe.Incompatible)throw p();if(A.length>se.len)throw m(A);const Je=A.length>0&&R?A.slice(0,-1):A;if(A.length===se.len&&Je===A)throw m(A);return se.keys.enc(...Je)},null,(G,se)=>{const Je=b(se),lr=G.map(({key:en,value:ms})=>({keyArgs:Je.keys.dec(en),value:Je.value.dec(ms)}));if(lr.some(({value:en})=>!u(re,se,en)))throw p();return lr})),n.withHodl(X));return Qt(H,F)},E=(A,I)=>Promise.all(A.map(R=>w(...I?[...R,I]:R))),B=(...A)=>{const I=A.at(-1),R=Zt(I);return r(e,t,R?A.slice(0,-1):A,R&&I.at==="best")},O=(...A)=>{const I=A.at(-1);if(I instanceof ts||I instanceof Ut){const R=A.slice(0,-1),F=ir(I).runtime();if(!l(I,F,R))throw p();return b(F).keys.enc(...R)}return a.then(R=>O(...A,R))};return{isCompatible:s,getCompatibilityLevel:o,getKey:O,getValue:w,getValues:E,getEntries:x,watchValue:y,watchEntries:B}},os=()=>new Error("Unkown signer"),Xh=e=>{const{extrinsic:t}=e,n=rr(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw os()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw os();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw os()},Yh={Ed25519:0,Sr25519:1,Ecdsa:2},Gh=(e,t,n,r,s,o)=>{const[i,a]=Xh(e),l=ie([Or.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...a,...t]),i===1||!o?n:new Uint8Array([Yh[o],...n]),...r,s]);return ie([pe.enc(l.length),l])},[ar,En]=["<Bytes>","</Bytes>"].map(e=>Ke.fromText(e).asBytes()),Qh=e=>async t=>{let n=!0,r;for(r=0;n&&r<ar.length;r++)n=ar[r]===t[r];n=n&&r===ar.length;const s=t.length-En.length;for(r=0;n&&r<En.length;r++)n=En[r]===t[s+r];return n=n&&r===En.length,e(n?t:ie([ar,t,En]))};function Zh(e,t,n){return{publicKey:e,signTx:async(s,o,i,a,l=Ft)=>{const c=Ht(Cr(i)),u=[],v=[];c.extrinsic.signedExtensions.map(({identifier:d})=>{const p=o[d];if(!p)throw new Error(`Missing ${d} signed extension`);u.push(p.value),v.push(p.additionalSigned)});const h=ie([s,...u,...v]),f=await n(h.length>256?l(h):h);return Gh(c,e,f,u,s,t)},signBytes:Qh(n)}}Uint8Array.from([1]);const Jh=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function ed(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const td=e=>1<<Math.ceil(Math.log2(e)),nd=An(ee(2)[0],e=>{const t=Math.min(Math.max(td(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(ed(t)-1,1),15),o=n/r<<4;return Ne[0](s|o)}),[rd]=ue({tip:pe,asset:vt(ee(1/0))}),Sa=new Uint8Array,is=Uint8Array.from([0]),as=e=>({value:e,additionalSigned:Sa}),cs=e=>({value:Sa,additionalSigned:e}),ls=(e,t)=>({value:e,additionalSigned:t}),Ia=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(a=>n.buildDefinition(a)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:a={},...l})=>{const c=[],u=Jh(t,n),v=f=>{const[d,p]=r[f],m=a[f];try{return Vt({value:d,additionalSigned:p},(b,y)=>{const g=m?.[y];return g instanceof Uint8Array?g:b(g)})}catch{if(m)throw new Error(`Wrong input received for ${f}`);return c.push(f),null}},h=Vt(r,([f,d],p)=>{if(a[p])return v(p);switch(p){case"CheckNonce":return as(f(i));case"CheckMortality":return s.mortal?ls(nd({period:s.period,startAtBlock:s.startAtBlock.height}),ve(s.startAtBlock.hash)):ls(is,e);case"ChargeTransactionPayment":return as(f(o));case"ChargeAssetTxPayment":return as(rd({tip:o,asset:l.asset}));case"CheckGenesis":return cs(e);case"CheckMetadataHash":return ls(is,is);case"CheckSpecVersion":return cs(d(u.spec_version));case"CheckTxVersion":return cs(d(u.transaction_version));default:return v(p)}});return c.forEach(f=>{delete h[f]}),Vt(h,(f,d)=>({...f,identifier:d}))}},Ba="AccountNonceApi_account_nonce",sd={1:z.dec,2:Ne.dec,4:He.dec,8:nn.dec},od=(e,t,n)=>e(n,Ba,t).pipe(k(r=>{const s=ve(r),o=sd[s.length];if(!o)throw new Error(`${Ba} retrieved wrong data`);return o(s)})),id=(e,t,n,r,s,o={})=>it([o.nonce?ne(o.nonce):ad(e,Z(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(ye(1),L(([i,a,l])=>{const c=Ia(ve(l),a.lookup,a.dynamicBuilder),u=o.mortality??{period:64,mortal:!0},v=c({nonce:i,tip:o.tip??0n,mortality:u.mortal?{mortal:!0,period:u.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,v,a.metadataRaw,r.number)})),ad=(e,t)=>{const n=o=>e.newBlocks$.pipe(Gn((i,a)=>a.parent===i?a.hash:i,o),Fi(o),fe()),r=o=>n(o).pipe(ye(2),bn(i=>od(e.call$,t,i))),s=o=>it(o.map(i=>r(i).pipe(k(a=>({success:!0,value:a})),Se(a=>ne({success:!1,value:a}))))).pipe(ye(1));return e.pinnedBlocks$.pipe(ye(1),k(({blocks:o,best:i})=>{const a=o.get(i);return[...o.values()].filter(l=>!l.pruned&&l.children.size===0&&l.number>=a.number).map(l=>l.hash)}),bn(s),k(o=>{const i=o.reduce((a,l)=>l.success&&l.value>=(a??0)?l.value:a,null);if(i==null)throw o[0].value;return i}))};var cd=Object.defineProperty,ld=(e,t,n)=>t in e?cd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ud=(e,t,n)=>ld(e,t+"",n);const fd=(e,t)=>new M(n=>{const r=new Map;let s,o;const i=()=>{let l=s.best,c=r.get(l),u=s.blocks.get(l).number;for(;!c;){const f=s.blocks.get(l);if(!f)break;c=r.get(l=f.parent),u--}if(!c)return;const v=u<=s.blocks.get(s.finalized).number,h=c.found.type;if(h&&o?.found&&o.hash===c.hash){v&&n.complete();return}n.next(o=c.found.type?{found:h,hash:c.hash,number:u,index:c.found.index,events:c.found.events}:{found:h,validity:c.found.validity}),v&&(h?n.complete():c.found.validity?.success===!1&&n.error(new us(c.found.validity.value)))},a=t.pipe(fe((l,c)=>l.finalized===c.finalized&&l.best===c.best)).subscribe({next:l=>{s=l,r.size!==0&&i()},error(l){n.error(l)}});return a.add(e.subscribe({next:l=>{r.set(l.hash,l),i()},error(l){n.error(l)}})),a}).pipe(fe((n,r)=>n===r)),hd=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class us extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Ke?r.asHex():r,2)),ud(this,"error"),this.name="InvalidTxError",this.error=t}}const fs=(e,t,n,r=!1)=>e.hasher$.pipe(L(s=>{const o=Z(s(ve(n))),i=(d,p)=>({type:d,txHash:o,...p}),a=e.pinnedBlocks$.state,l=d=>{if(!d.mortal)return 0;const{phase:p,period:m}=d,b=a.blocks.get(a.best).number;return Math.floor((Math.max(b,p)-p)/m)*m+p},c=d=>{let p=[...a.blocks.values()].filter(y=>!y.pruned&&!y.children.size);const m=Math.max(...p.map(({number:y})=>y));p=p.filter(({number:y})=>y>=m-1);const b=a.blocks.get(a.finalized);return p=b.children?[b,...p]:p,p.filter(y=>y.number>=d)},u=({hash:d})=>e.validateTx$(d,n),v=Xn(()=>a.finalizedRuntime.runtime.pipe(k(d=>d.getMortalityFromTx(n)),k(l),k(c),L(d=>{let p;return mn(...d.map(m=>hf(u(m),e.finalized$.pipe(Xt(b=>{if(b.number<m.number)return!0;let y=b;for(;y.number>m.number;){const g=a.blocks.get(y.parent);if(!g)return!1;y=g}return y.hash===b.hash}),Nr(),Hi({success:null}))))).pipe(at((m,b)=>{if(m.success===!1&&(p??(p=new us(m.value))),m.success)return!0;if(b===d.length-1&&p)throw p;return!1}),ye(1))}),Nr())),h=new M(d=>{const p=e.trackTx$(n).subscribe(d);return p.add(t(n).subscribe({error(m){d.error(m)}})),p}),f=fd(h,e.pinnedBlocks$).pipe(k(d=>d.found?i("txBestBlocksState",{found:!0,block:{index:d.index,number:d.number,hash:d.hash},...hd(d.events,d.index)}):i("txBestBlocksState",{found:!1,isValid:d.validity?.success!==!1})));return Kt(r?ne(i("signed",{})):gt,v,ne(i("broadcasted",{})),f.pipe(jh(({found:d,type:p,...m})=>d?ne(i("finalized",m)):gt)))})),_a=async(e,t,n,r)=>Gu(fs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),dd=St().enc,pd=new Uint8Array(64),vd=new Uint8Array(65),md=e=>()=>e?vd:pd,[,yd]=ue({weight:ue({ref_time:Pn,proof_size:Pn}),class:ke({Normal:P,Operational:P,Mandatory:P}),partial_fee:ks}),Ca=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:a,getRuntimeTypedef:l},c)=>Object.assign(u=>{const v=(x,E,B={})=>{const O=ir(x).runtime(),{dynamicBuilder:A,assetId:I,lookup:R,extVersions:F}=O;let D;try{D=A.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(c&&!a(x,O,E))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let X=B;if(B.asset){if(I==null||!Fn(B.asset,Hn(R(I)),se=>l(O,se)))throw new Error("Incompatible runtime asset");X={...B,asset:A.buildDefinition(I).enc(B.asset)}}const{location:H,codec:re}=D,G=ie([new Uint8Array(H),re.enc(E)]);return{callData:Ke.fromBytes(G),bare:Z(ie(pe.enc(G.length+1),new Uint8Array(F.slice(-1)),G)),options:X}},h=(x,E={})=>i(n,null).pipe(k(([B])=>v(B,x,E))),f=x=>x?v(x,u).callData:Le(h(u).pipe(k(E=>E.callData))),d=x=>x?v(x,u).bare:Le(h(u).pipe(k(E=>E.bare))),p=(x,{...E},B)=>h(u,E).pipe(L(({callData:O,options:A})=>id(n,x,O.asBytes(),B,E.customSignedExtensions||{},A))),m=(x,{at:E,...B}={})=>(!E||E==="finalized"?n.finalized$:E==="best"?n.best$:n.bestBlocks$.pipe(k(O=>O.find(A=>A.hash===E)))).pipe(ye(1),L(O=>O?p(x,B,O).pipe(k(A=>({tx:Z(A),block:O}))):Rt(()=>new Error(`Uknown block ${E}`)))),b=(x,E)=>Le(m(x,E)).then(B=>B.tx),y=(x,E)=>Le(m(x,E)).then(({tx:B,block:O})=>_a(n,r,B,O.hash)),g=(x,E)=>m(x,E).pipe(L(({tx:B})=>fs(n,r,B,!0))),w=async(x,E)=>{typeof x=="string"&&(x=x.startsWith("0x")?ve(x):dd(x));const B=x.length===20,O=Zh(x,B?"Ecdsa":"Sr25519",md(B)),A=ve(await b(O,E)),I=Z(ie([A,He.enc(A.length)])),R=n.getRuntimeContext$(null).pipe(k(D=>{try{return D.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return yd}})),F=n.call$(null,"TransactionPaymentApi_query_info",I);return Le(it([F,R]).pipe(k(([D,X])=>X(D))))};return{getPaymentInfo:w,getEstimatedFees:async(x,E)=>(await w(x,E)).partial_fee,decodedCall:{type:e,value:_t(t,u)},getEncodedData:f,getBareTx:d,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var bd=Object.defineProperty,gd=(e,t,n)=>t in e?bd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(gd(e,typeof t!="symbol"?t+"":t,n),n),hs=Symbol("SUSPENSE"),wd=class extends Promise{constructor(e){super(e)}},Oa=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ra=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ce={},cr=class extends M{constructor(e,t,n=$e){super(r=>{const s=new dn({next:r.next.bind(r),error:r.error.bind(r),complete:$e});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ce,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Oa),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ce&&r.next(this.currentValue)):(this.subject=new je,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new dn({next:i=>{this.promise&&i!==hs&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var a;this.subscription=null;const l=this.subject;this.subject=null,this.currentValue=Ce;const c=(a=this.promise)==null?void 0:a.rej;c&&i===hs&&(this.promise.rej=()=>{c(i)}),l.error(i),c&&this.promise&&(this.promise.rej=c)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ra),this.promise=null),this.currentValue!==Ce)return this.subject.complete();if(t===Ce){const i=this.subject;return this.subject=null,i.error(new Ra)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ce&&this.currentValue===Ce&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Ce),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof cr?s:new cr(s,Ce)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ce&&this.currentValue!==hs)return this.currentValue;if(this.defaultValue!==Ce)return this.defaultValue;if(this.refCount===0)throw new Oa;const r=new wd((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Ce&&delete this.getDefaultValue}};function Ta(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function xd(e,t){const n=new Ed,r=typeof t=="function"?t:()=>t,s=o=>{for(let v=o.length-1;o[v]===void 0&&v>-1;v--)o.splice(-1);const i=[o.length,...o],a=n.get(i);if(a!==void 0)return a;const l=new cr(e(...o),r(...o),()=>{n.delete(i)}),c=new M(v=>{const h=n.get(i);let f=l;return h?h!==c&&(f=h,Ta(f,c)):n.set(i,u),f.subscribe(v)});Ta(l,c);const u=c;return n.set(i,u),u};return(...o)=>s(o)}var Ed=class{constructor(){Ze(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function kd(e,t){return new cr(e,t)}var ds=(...e)=>(typeof e[0]=="function"?xd:kd)(e[0],e.length>1?e[1]:Ce);const Pa=(e,t,n)=>{const r=new Map(t.map(a=>[a.key,a])),s=new Map(e.map(a=>[a.key,a])),o=new Map,i=[];return t.forEach(a=>{const{key:l}=a,c=s.get(l);(!c||c.value!==a.value)&&o.set(l,n(a))}),e.forEach(a=>{r.has(a.key)||i.push(a)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:a})=>o.get(a)??s.get(a))}},Ua=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},Ma=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},Ad=(e,t,n)=>{const r=ds((a,l,c)=>{const u=Ma(a,l),v=(m,b)=>{const y=Uh(e,b.hash).pipe(at(g=>!g),ye(1));return t(b.hash,"closestDescendantMerkleValue",()=>c).pipe(L(g=>g===m?.rootHash?ne({...m,block:b,deltas:null,prev:m.block.hash}):t(b.hash,"descendantsValues",()=>c).pipe(n(()=>b.hash),k(([w,x])=>[w,u(x)]),k(([w,x])=>({prev:m&&m.block.hash,rootHash:g,block:b,...Pa(m?.entries??[],w,x)})))),zi(y),Se(g=>g instanceof Qe?gt:Rt(()=>g)))},h=e.pipe(fe((m,b)=>m.finalized===b.finalized),ss(({blocks:m,finalized:b})=>v(null,m.get(b))),ye(1),k(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[f,d]=Wh(),p=e.pipe(fe((m,b)=>m.best===b.best),Xr(f),ss(([m,b])=>{const{best:y}=m,{blocks:g}=b;let w=g[y]?null:y;if(!w)return gt;const x=Ua(w,g,m);return x?v(x,m.blocks.get(w)).pipe(k(E=>(g[w]=E,b))):(w=m.finalized,v(g[b.finalized],m.blocks.get(w)).pipe(k(E=>(E.prev=null,{blocks:{[w]:E},finalized:w}))))}));return mn(h,p).pipe(d())}),s=a=>(l,c,u)=>{const v=r(l,c,u),h=Ma(l,c),f=a?"finalized":"best";return it([v.pipe(gf(0)),e.pipe(fe((d,p)=>d[f]===p[f]))]).pipe(k(([d,p])=>Ua(p[f],d.blocks,p,!0)),at(Boolean),fe(),Fi(null),Af(),Xr(v),n(([[,d]])=>d.block.hash),k(([[[d,p],m],b])=>[d,p,m,h(b)]),L(([d,p,m,b])=>{if(!d)return[p];let y=p;const g=[];for(;y&&y.block.number>d.block.number;)g.unshift(y),y=y.prev?m.blocks[y.prev]:null;if(a&&(m.finalized=p.block.hash,g.length)){const{blocks:w}=m;Object.keys(w).forEach(x=>{w[x].block.number<g[0].block.number&&delete w[x]})}return d===y?g:[{...p,...d.rootHash===p.rootHash?{entries:d.entries,deltas:null}:Pa(d.entries,p.entries,b)}]}))},o=ds(s(!0)),i=ds(s(!1));return(a,l,c,u)=>{const v=u?i:o;return e.pipe(ye(1),L(h=>h.runtimes[h.blocks.get(h[u?"best":"finalized"]).runtime].runtime),k(h=>h.dynamicBuilder.buildStorage(a,l).keys.enc(...c))).pipe(ye(1),L(h=>v(a,l,h)),k(({block:{hash:h,number:f,parent:d},deltas:p,entries:m},b)=>{const y=b>0?p:{deleted:[],upserted:m};return{block:{hash:h,number:f,parent:d},entries:m.map(ps),deltas:y&&{deleted:y.deleted.map(ps),upserted:y.upserted.map(ps)}}}))}},ps=e=>e.dec,La="RuntimeViewFunction",Va="execute_view_function",vs=La+"_"+Va,$d=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:a})=>{const l=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...c)=>{const u=c[c.length-1],v=Zt(u),{signal:h,at:f}=v?u:{},d=f??null,p=o(n,d).pipe(L(([m,b])=>{let y;try{y=b.dynamicBuilder.buildRuntimeCall(La,Va)}catch{throw new Error(`Runtime entry RuntimeCall(${vs}) not found`)}let g;try{g=b.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,b,c))throw l();const w=g.args.enc(c),x=ie([ve(b.lookup.metadata.pallets.find(({name:E})=>E===e).viewFns.find(({name:E})=>E===t).id),C.enc(w.length),w]);return n.call$(d,vs,Z(x)).pipe(k(E=>{try{const B=y.value.dec(E);if(!("success"in B&&"value"in B)||!("type"in B.value)&&!("asBytes"in B.value))throw null;return B}catch{throw new Error(`Unexpected RuntimeCall(${vs}) type`)}}),k(({success:E,value:B})=>{if(!E)throw new Error(`ViewFn API Error: ${B.type}`);const O=g.value.dec(B.asBytes());if(!a(m,b,O))throw l();return O}))}),n.withHodl(d));return Qt(p,h)},{getCompatibilityLevel:s,isCompatible:r})},Sd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Da=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(b,y){return m(y)}}),o=m=>{const b={};return s(y=>(b[y]||(b[y]={}),s(g=>(b[y][g]||(b[y][g]=m(y,g)),b[y][g]))))},i=(m,b)=>m.lookup.metadata.pallets.find(y=>y.name===b),a=Ad(t.pinnedBlocks$,t.storage$,t.withRuntime),l=o((m,b)=>Kh(m,b,t,a,Mt(e,y=>y.getEntryPoint(kt.Storage,m,b),y=>{const g=i(y,m)?.storage?.items.find(w=>w.name===b);return g==null?null:pu(g)}))),c=(m,b,y,g)=>{if(y==null)return null;const w=m.lookup(y);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const x=vu(w.value[g]);return{args:b==="args"?x:jn,values:b==="args"?jn:x}},u=o((m,b)=>Ca(m,b,t,n,Mt(e,y=>y.getEntryPoint(kt.Tx,m,b),y=>c(y,"args",i(y,m)?.calls?.type,b)),!0)),v=o((m,b)=>qh(m,b,t,Mt(e,y=>y.getEntryPoint(kt.Event,m,b),y=>c(y,"values",i(y,m)?.events?.type,b)))),h=o((m,b)=>Fh(m,b,Mt(e,y=>y.getEntryPoint(kt.Const,m,b),y=>{const g=i(y,m)?.constants.find(w=>w.name===b)?.type;return g==null?null:mu(g)}))),f=o((m,b)=>Nh(m,b,t,Mt(e,y=>y.getEntryPoint(kt.Api,m,b),y=>{const g=y.lookup.metadata.apis.find(w=>w.name===m)?.methods.find(w=>w.name===b);return g==null?null:ii(g)}))),d=o((m,b)=>$d(m,b,t,Mt(e,y=>y.getEntryPoint(kt.ViewFns,m,b),y=>{const g=y.lookup.metadata.pallets.find(w=>w.name===m)?.viewFns.find(w=>w.name===b);return g==null?null:ii(g)}))),p=(m,b)=>{const{lookup:y,dynamicBuilder:g}=ir(b).runtime();try{const w=g.buildDefinition(y.call).dec(m.asBytes()),x=w.type,E=w.value.type,B=w.value.value;return Ca(x,E,t,n,Mt(e,O=>O.getEntryPoint(kt.Tx,x,E),O=>c(O,"args",i(O,x)?.calls?.type,E)),!1)(B)}catch{throw new Error("createTx: invalid call data")}};return{query:l,txFromCallData:(m,b)=>b?p(m,b):e.then(y=>p(m,y)),tx:u,event:v,apis:f,constants:h,view:d}};function Id(e,{getMetadata:t,setMetadata:n}={}){const r=Yf(e),s=Ph(r,{getMetadata:t?y=>xt(t(y)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...a}=s.chainHead$(),l=s.archive(a.getRuntime$),c={...a,genesis$:Xn(o).pipe(k(({genesisHash:y})=>y),Se(()=>i),Qn(1)),storage$:Pt(a.storage$,l.storage$),body$:Pt(a.body$,l.body$),call$:Pt(a.call$,l.call$),header$:Pt(a.header$,l.header$),eventsAt$:Pt(a.eventsAt$,l.eventsAt$),storageQueries$:Pt(a.storageQueries$,l.storageQueries$),getRuntimeContext$:Pt(a.getRuntimeContext$,l.getRuntimeContext$)},u=r.request;let v;const h=new WeakMap,f=y=>{const g=h.get(y)||Dh(y,c);return h.set(y,g),g},d=()=>v??(v=Hh(c)),{broadcastTx$:p}=s,m=y=>c.getRuntimeContext$(y).pipe(k(g=>g.metadataRaw)),b={getChainSpecData:o,getMetadata$:m,getMetadata:(y,g)=>Qt(m(y),g),blocks$:c.newBlocks$,hodlBlock:y=>c.holdBlock(y,!0),finalizedBlock$:c.finalized$,getFinalizedBlock:()=>Le(c.finalized$),bestBlocks$:c.bestBlocks$,getBestBlocks:()=>Le(c.bestBlocks$),watchBlockBody:c.body$,getBlockBody:y=>Le(c.body$(y)),getBlockHeader:y=>Le(c.header$(y??null)),submit:(...y)=>_a(c,p,...y),submitAndWatch:y=>fs(c,p,y),getTypedApi:y=>{const g=f(y);return Object.assign(Da(g,c,p),{compatibilityToken:g})},getUnsafeApi:()=>{const y=d();return Object.assign(Da(y,c,p),{runtimeToken:y})},rawQuery:(y,{at:g,signal:w}={})=>Qt(c.storage$(g??null,"value",()=>{const x=y.match(Sd)?.[1];return x?`0x${x}`:Ke.fromText(y).asHex()}),w),destroy:()=>{c.unfollow(),s.destroy()},_request:u};return b.___INTERNAL_DO_NOT_USE=c,b}const Bd=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:a}=o,l=new Uint8Array(i);return c=>{const u=Ke.fromBytes(ie([l,a.enc(c)]));return{encodedData:u,decodedCall:_t(e,_t(t,c)),sign:async(v,h)=>Z(await v.signTx(u.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},_d=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=ve(e),r=await t(),s=Ht(mt.dec(r)),o=rr(s),i=Jr(o),a=Ia(n,o,i),l=d=>s.pallets.find(p=>p.name===d),c={},u=d=>new Proxy(c,{get(p,m){return d(m)}}),v=d=>{const p={};return u(m=>(p[m]||(p[m]={}),u(b=>(p[m][b]||(p[m][b]=d(m,b)),p[m][b]))))},h=v((d,p)=>{const m=l(d)?.constants.find(b=>b.name===p);if(!m)throw new Error(`Runtime entry Constant(${d}.${p}) not found`);return i.buildConstant(d,p).dec(m.value)}),f=v((d,p)=>Bd(d,p,r,i,a));return{constants:h,tx:f}},Jt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},Cd=async e=>{const t=Ht(Cr(await e.getMetadata())),n={},r=h=>new Proxy(n,{get(f,d){return h(d)}}),s=h=>{const f={};return r(d=>(f[d]||(f[d]={}),r(p=>(f[d][p]||(f[d][p]=h(d,p)),f[d][p]))))},o=rr(t),{buildRuntimeCall:i,buildStorage:a,buildConstant:l,buildCall:c,buildEvent:u,buildViewFn:v}=Jr(o);return{query:s((...h)=>{const{value:f,args:d}=Jt(a,"Storage")(...h);return{value:f,args:d}}),tx:s((...h)=>Jt(c,"Call")(...h).codec),event:s((...h)=>Jt(u,"Event")(...h).codec),apis:s(Jt(i,"Runtime API")),constants:s(Jt(l,"Constant")),view:s(Jt(v,"ViewFn"))}};de.AccountId=St,de.Binary=Ke,de.BlockNotPinnedError=Qe,de.CompatibilityLevel=Pe,de.Enum=_t,de.FixedSizeBinary=Tn,de.InvalidTxError=us,de._Enum=vo,de.createClient=Id,de.getOfflineApi=_d,de.getSs58AddressInfo=yr,de.getTypedCodecs=Cd}));
@@ -1 +1 @@
1
- (function(_e,xe){typeof exports=="object"&&typeof module<"u"?xe(exports):typeof define=="function"&&define.amd?define(["exports"],xe):(_e=typeof globalThis<"u"?globalThis:_e||self,xe(_e.papiInk={}))})(this,(function(_e){"use strict";const xe=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",pe={type:"void"},yr=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>f=>{let h=n.get(f);if(h)return h;if(r.has(f)){const p={id:f};return n.set(f,p),p}r.add(f);const u=a(f);return h=n.get(f),h?Object.assign(h,u):(h={id:f,...u},n.set(f,h)),r.delete(f),h};let o=!0,c=!0;const i=s(a=>{const f=t(e[a]);if(f)return f;const{def:h,path:u,params:p}=e[a];if(h.tag==="composite"){if(h.value.length===0)return pe;if(h.value.length===1){const y=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&xe(y,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&xe(y,20)?(c=!1,{type:"AccountId20"}):y}return d(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=i(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(u.length===1&&u[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:i(p[0].type),ko:i(p[1].type)}};if(h.value.length===0)return pe;const y={},m={};return h.value.forEach(x=>{const L=x.name;if(m[L]=x.docs,x.fields.length===0){y[L]={...pe,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){y[L]={type:"lookupEntry",value:i(x.fields[0].type),idx:x.index};return}y[L]={...d(x.fields),idx:x.index}}),{type:"enum",value:y,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:y}=h.value,m=i(h.value.type);return!y||m.type==="void"?pe:y>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?pe:h.value.length>1?l(h.value.map(y=>i(y)),h.value.map(y=>e[y].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const y=i(h.value);return y.type==="void"?pe:{type:"compact",isBig:Number(y.value.slice(1))>32,size:y.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),d=a=>{let f=!0;const h={},u={};return a.forEach((p,y)=>{f=f&&!!p.name;const m=p.name||y,x=i(p.type);x.type!=="void"&&(h[m]=x,u[m]=p.docs)}),f?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,f)=>{if(a.every(h=>h.id===a[0].id)&&f.every(h=>!h.length)){const[h]=a;return h.type==="void"?pe:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:f}};return i},gr=e=>yr(e);var vr=Object.defineProperty,mr=(e,t,n)=>t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,At=(e,t,n)=>(mr(e,typeof t!="symbol"?t+"":t,n),n),st={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function br(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|st[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=st[e[c]],d=st[e[c+1]];s[t+o++]=i<<4|d}return s}var kt=class extends Uint8Array{constructor(e){super(e),At(this,"i",0),At(this,"v"),this.v=new DataView(e)}},W=e=>t=>e(t instanceof kt?t:new kt(t instanceof Uint8Array?t.buffer:typeof t=="string"?br(t).buffer:t)),G=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function je(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var Ie=W,A=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},ot=(e,t)=>n=>e(t(n)),ct=(e,t)=>n=>t(e(n)),M=([e,t],n,r)=>A(ot(e,n),ct(t,r));function wr(e,t){return W(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Er(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function re(e,t,n){return A(Er(e,n),wr(e,t))}var k=re(1,"getUint8","setUint8"),ye=re(2,"getUint16","setUint16"),se=re(4,"getUint32","setUint32"),Pe=re(8,"getBigUint64","setBigUint64"),xr=re(1,"getInt8","setInt8"),Ir=re(2,"getInt16","setInt16"),Br=re(4,"getInt32","setInt32"),Ar=re(8,"getBigInt64","setBigInt64"),_t=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Ot=e=>W(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),kr=A(_t,Ot("getBigUint64")),_r=A(_t,Ot("getBigInt64")),Ut=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},Lt=e=>W(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Or=A(Ut,Lt("getBigUint64")),Ur=A(Ut,Lt("getBigInt64")),Lr=M(k,e=>e?1:0,Boolean),Tr=[k[1],ye[1],se[1]],Sr=W(e=>{const t=e[e.i],n=t&3;if(n<3)return Tr[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let d=0;d<o;d++)s=Pe[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(se[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(ye[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(k[1](e))<<c|s),s}),$r=1n<<56n,Dr=1<<24,Cr=256,Hr=4294967295n,Vr=64,Mr=16384,Nr=1<<30,Rr=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Vr)return k[0](t);if(e<Mr)return ye[0](t|1);if(e<Nr)return se[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=$r;)n.push(Pe[0](r)),r>>=64n;r>=Dr&&(n.push(se[0](Number(r&Hr))),r>>=32n);let s=Number(r);s>=Cr&&(n.push(ye[0](s)),s>>=16),s&&n.push(k[0](s));const o=G(n);return o[0]=o.length-5<<2|3,o},q=A(Rr,Sr),jr=new TextEncoder,Pr=e=>{const t=jr.encode(e);return G([q.enc(t.length),t])},qr=new TextDecoder,Fr=W(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,qr.decode(n)}),I=A(Pr,Fr),Kr=()=>{},Wr=new Uint8Array(0),w=A(()=>Wr,Kr),Tt=e=>e===void 0?t=>G([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),St=e=>W(t=>{const n=e===void 0?q.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),T=e=>A(Tt(e),St(e));T.enc=Tt,T.dec=St;var $t=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>G([k.enc(s(o)),e[o](c)])},Dt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return W(s=>{const o=k.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},N=(e,...t)=>A($t(je(e,([n])=>n),...t),Dt(je(e,([,n])=>n),...t));N.enc=$t,N.dec=Dt;var Ct=e=>W(t=>k[1](t)>0?e(t):void 0),Ht=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,G([n,e(t)]))},R=e=>A(Ht(e[0]),Ct(e[1]));R.enc=Ht,R.dec=Ct;var Vt=(e,t)=>W(n=>{const r=k[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Mt=(e,t)=>({success:n,value:r})=>G([k[0](n?0:1),(n?e:t)(r)]),Oe=(e,t)=>A(Mt(e[0],t[0]),Vt(e[1],t[1]));Oe.dec=Vt,Oe.enc=Mt;var Nt=(...e)=>W(t=>e.map(n=>n(t))),Rt=(...e)=>t=>G(e.map((n,r)=>n(t[r]))),X=(...e)=>A(Rt(...e.map(([t])=>t)),Nt(...e.map(([,t])=>t)));X.enc=Rt,X.dec=Nt;var jt=e=>{const t=Object.keys(e);return ot(X.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Pt=e=>{const t=Object.keys(e);return ct(X.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},b=e=>A(jt(je(e,t=>t[0])),Pt(je(e,t=>t[1])));b.enc=jt,b.dec=Pt;var qt=(e,t)=>t>=0?n=>G(n.map(e)):n=>G([q.enc(n.length),G(n.map(e))]),Ft=(e,t)=>W(n=>{const r=t>=0?t:q.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),E=(e,t)=>A(qt(e[0],t),Ft(e[1],t));E.enc=qt,E.dec=Ft;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Xr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Kt(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function it(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Wt(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function at(e){if(!Array.isArray(e))throw new Error("array expected")}function Xt(e,t){if(!Kt(!0,t))throw new Error(`${e}: array of strings expected`)}function zr(e,t){if(!Kt(!1,t))throw new Error(`${e}: array of numbers expected`)}function Yr(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Gr(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Xt("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(at(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(at(s),s.map(o=>{it("alphabet.decode",o);const c=r.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return c}))}}function Jr(e=""){return it("join",e),{encode:t=>(Xt("join.decode",t),t.join(e)),decode:t=>(it("join.decode",t),t.split(e))}}function zt(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(at(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,i=>{if(Wt(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=o.length;for(;;){let i=0,d=!0;for(let l=r;l<c;l++){const a=o[l],f=t*i,h=f+a;if(!Number.isSafeInteger(h)||f/t!==i||h-a!==f)throw new Error("convertRadix: carry overflow");const u=h/n;i=h%n;const p=Math.floor(u);if(o[l]=p,!Number.isSafeInteger(p)||p*n+i!==h)throw new Error("convertRadix: carry overflow");if(d)p?d=!1:r=l;else continue}if(s.push(i),d)break}for(let i=0;i<e.length-1&&e[i]===0;i++)s.push(0);return s.reverse()}function Qr(e){Wt(e);const t=2**8;return{encode:n=>{if(!Xr(n))throw new Error("radix.encode input should be Uint8Array");return zt(Array.from(n),t,e)},decode:n=>(zr("radix.decode",n),Uint8Array.from(zt(n,e,t)))}}const Yt=(e=>Yr(Qr(58),Gr(e),Jr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Zr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Be(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function z(e,t,n=""){const r=Zr(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const c=n&&`"${n}" `,i=o?` of length ${t}`:"",d=r?`length=${s}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+i+", got "+d)}return e}function Ue(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 lt(e,t){z(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function es(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ge(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function qe(e,t){return e<<32-t|e>>>t}const Gt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Jt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Q=Gt?e=>e:e=>Jt(e);function ts(e){for(let t=0;t<e.length;t++)e[t]=Jt(e[t]);return e}const H=Gt?e=>e:ts;function ut(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const ns=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ce(e,t,n,r,s){return e=e+t+s|0,r=qe(r^e,16),n=n+r|0,t=qe(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=qe(r^e,8),n=n+r|0,t=qe(t^n,7),{a:e,b:t,c:n,d:r}}const rs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fe=BigInt(2**32-1),Qt=BigInt(32);function Ke(e,t=!1){return t?{h:Number(e&Fe),l:Number(e>>Qt&Fe)}:{h:Number(e>>Qt&Fe)|0,l:Number(e&Fe)|0}}function ss(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:c,l:i}=Ke(e[o],t);[r[o],s[o]]=[c,i]}return[r,s]}const Zt=(e,t,n)=>e>>>n|t<<32-n,en=(e,t,n)=>e<<32-n|t>>>n,os=(e,t,n)=>e<<64-n|t>>>n-32,cs=(e,t,n)=>e>>>n-32|t<<64-n,is=(e,t)=>t,as=(e,t)=>e,ls=(e,t,n)=>e<<n|t>>>32-n,us=(e,t,n)=>t<<n|e>>>32-n,ds=(e,t,n)=>t<<n-32|e>>>64-n,hs=(e,t,n)=>e<<n-32|t>>>64-n;function tn(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const nn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),rn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,U=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function ae(e,t,n,r,s,o){const c=s[o],i=s[o+1];let d=g[2*e],l=g[2*e+1],a=g[2*t],f=g[2*t+1],h=g[2*n],u=g[2*n+1],p=g[2*r],y=g[2*r+1],m=nn(d,a,c);l=rn(m,l,f,i),d=m|0,{Dh:y,Dl:p}={Dh:y^l,Dl:p^d},{Dh:y,Dl:p}={Dh:is(y,p),Dl:as(y)},{h:u,l:h}=tn(u,h,y,p),{Bh:f,Bl:a}={Bh:f^u,Bl:a^h},{Bh:f,Bl:a}={Bh:Zt(f,a,24),Bl:en(f,a,24)},g[2*e]=d,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=f,g[2*n]=h,g[2*n+1]=u,g[2*r]=p,g[2*r+1]=y}function le(e,t,n,r,s,o){const c=s[o],i=s[o+1];let d=g[2*e],l=g[2*e+1],a=g[2*t],f=g[2*t+1],h=g[2*n],u=g[2*n+1],p=g[2*r],y=g[2*r+1],m=nn(d,a,c);l=rn(m,l,f,i),d=m|0,{Dh:y,Dl:p}={Dh:y^l,Dl:p^d},{Dh:y,Dl:p}={Dh:Zt(y,p,16),Dl:en(y,p,16)},{h:u,l:h}=tn(u,h,y,p),{Bh:f,Bl:a}={Bh:f^u,Bl:a^h},{Bh:f,Bl:a}={Bh:os(f,a,63),Bl:cs(f,a,63)},g[2*e]=d,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=f,g[2*n]=h,g[2*n+1]=u,g[2*r]=p,g[2*r+1]=y}function fs(e,t={},n,r,s){if(Be(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:c,personalization:i}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);c!==void 0&&z(c,r,"salt"),i!==void 0&&z(i,s,"personalization")}class sn{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Be(t),Be(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=ge(this.buffer)}update(t){Ue(this),z(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,c=t.byteOffset,i=t.buffer;for(let d=0;d<o;){this.pos===n&&(H(s),this.compress(s,0,!1),H(s),this.pos=0);const l=Math.min(n-this.pos,o-d),a=c+d;if(l===n&&!(a%4)&&d+l<o){const f=new Uint32Array(i,a,Math.floor((o-d)/4));H(f);for(let h=0;d+n<o;h+=s.length,d+=n)this.length+=n,this.compress(f,h,!1);H(f);continue}r.set(t.subarray(d,d+l),this.pos),this.pos+=l,this.length+=l,d+=l}return this}digestInto(t){Ue(this),lt(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,oe(this.buffer.subarray(n)),H(r),this.compress(r,0,!0),H(r);const s=ge(t);this.get().forEach((o,c)=>s[c]=Q(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:i}=this;return t||=new this.constructor({dkLen:c}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=i,t.outputLen=c,t}clone(){return this._cloneInto()}}class ps extends sn{v0l=U[0]|0;v0h=U[1]|0;v1l=U[2]|0;v1h=U[3]|0;v2l=U[4]|0;v2h=U[5]|0;v3l=U[6]|0;v3h=U[7]|0;v4l=U[8]|0;v4h=U[9]|0;v5l=U[10]|0;v5h=U[11]|0;v6l=U[12]|0;v6h=U[13]|0;v7l=U[14]|0;v7h=U[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),fs(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,c=0;if(r!==void 0&&(z(r,void 0,"key"),c=r.length),this.v0l^=this.outputLen|c<<8|65536|1<<24,o!==void 0){z(o,void 0,"salt");const i=ge(o);this.v4l^=Q(i[0]),this.v4h^=Q(i[1]),this.v5l^=Q(i[2]),this.v5h^=Q(i[3])}if(s!==void 0){z(s,void 0,"personalization");const i=ge(s);this.v6l^=Q(i[0]),this.v6h^=Q(i[1]),this.v7l^=Q(i[2]),this.v7h^=Q(i[3])}if(r!==void 0){const i=new Uint8Array(this.blockLen);i.set(r),this.update(i)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:d,v4l:l,v4h:a,v5l:f,v5h:h,v6l:u,v6h:p,v7l:y,v7h:m}=this;return[t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m]}set(t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=d|0,this.v4l=l|0,this.v4h=a|0,this.v5l=f|0,this.v5h=h|0,this.v6l=u|0,this.v6h=p|0,this.v7l=y|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((d,l)=>g[l]=d),g.set(U,16);let{h:s,l:o}=Ke(BigInt(this.length));g[24]=U[8]^o,g[25]=U[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=ns;for(let d=0;d<12;d++)ae(0,4,8,12,t,n+2*i[c++]),le(0,4,8,12,t,n+2*i[c++]),ae(1,5,9,13,t,n+2*i[c++]),le(1,5,9,13,t,n+2*i[c++]),ae(2,6,10,14,t,n+2*i[c++]),le(2,6,10,14,t,n+2*i[c++]),ae(3,7,11,15,t,n+2*i[c++]),le(3,7,11,15,t,n+2*i[c++]),ae(0,5,10,15,t,n+2*i[c++]),le(0,5,10,15,t,n+2*i[c++]),ae(1,6,11,12,t,n+2*i[c++]),le(1,6,11,12,t,n+2*i[c++]),ae(2,7,8,13,t,n+2*i[c++]),le(2,7,8,13,t,n+2*i[c++]),ae(3,4,9,14,t,n+2*i[c++]),le(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],oe(g)}destroy(){this.destroyed=!0,oe(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const We=ut(e=>new ps(e));function on(e,t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m,x,L,P){let O=0;for(let Ee=0;Ee<r;Ee++)({a:s,b:d,c:h,d:m}=ce(s,d,h,m,n[t+e[O++]])),{a:s,b:d,c:h,d:m}=ie(s,d,h,m,n[t+e[O++]]),{a:o,b:l,c:u,d:x}=ce(o,l,u,x,n[t+e[O++]]),{a:o,b:l,c:u,d:x}=ie(o,l,u,x,n[t+e[O++]]),{a:c,b:a,c:p,d:L}=ce(c,a,p,L,n[t+e[O++]]),{a:c,b:a,c:p,d:L}=ie(c,a,p,L,n[t+e[O++]]),{a:i,b:f,c:y,d:P}=ce(i,f,y,P,n[t+e[O++]]),{a:i,b:f,c:y,d:P}=ie(i,f,y,P,n[t+e[O++]]),{a:s,b:l,c:p,d:P}=ce(s,l,p,P,n[t+e[O++]]),{a:s,b:l,c:p,d:P}=ie(s,l,p,P,n[t+e[O++]]),{a:o,b:a,c:y,d:m}=ce(o,a,y,m,n[t+e[O++]]),{a:o,b:a,c:y,d:m}=ie(o,a,y,m,n[t+e[O++]]),{a:c,b:f,c:h,d:x}=ce(c,f,h,x,n[t+e[O++]]),{a:c,b:f,c:h,d:x}=ie(c,f,h,x,n[t+e[O++]]),{a:i,b:d,c:u,d:L}=ce(i,d,u,L,n[t+e[O++]]),{a:i,b:d,c:u,d:L}=ie(i,d,u,L,n[t+e[O++]]);return{v0:s,v1:o,v2:c,v3:i,v4:d,v5:l,v6:a,v7:f,v8:h,v9:u,v10:p,v11:y,v12:m,v13:x,v14:L,v15:P}}const cn=new TextEncoder().encode("SS58PRE"),dt=2,an=e=>{try{const t=Yt.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-dt),s=t.subarray(n.length+r.length),o=We(Uint8Array.of(...cn,...n,...r),{dkLen:64}).subarray(0,dt);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:ys(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},ys=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},gs=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var c,i;++n===1&&s();let d=t;const l=o.length-1;for(let a=0;a<=l;a++)d=d[c=o[a]]||(d[c]={});return d[i=o[l]]||(d[i]=e(o))}},ln=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return gs(n=>{const r=We(Uint8Array.of(...cn,...t,...n),{dkLen:64}).subarray(0,dt);return Yt.encode(Uint8Array.of(...t,...n,...r))})};function vs(e,t){return n=>{const r=an(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const ht=(e=42,t=32)=>M(T(t),vs(t),ln(e)),un="0123456789abcdef";function Y(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=un[r>>4]+un[r&15]}return t.join("")}const ft={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Le(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|ft[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=ft[e[c]],d=ft[e[c+1]];s[t+o++]=i<<4|d}return s}function dn(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const c=t[s];r.set(c,o),o+=c.byteLength}return r};var ms=Object.defineProperty,hn=e=>{throw TypeError(e)},bs=(e,t,n)=>t in e?ms(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t,n)=>bs(e,typeof t!="symbol"?t+"":t,n),fn=(e,t,n)=>t.has(e)||hn("Cannot "+n),Z=(e,t,n)=>(fn(e,t,"read from private field"),n?n.call(e):t.get(e)),Se=(e,t,n)=>t.has(e)?hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ve=(e,t,n,r)=>(fn(e,t,"write to private field"),t.set(e,n),n),ee,$e,Xe,ze,Ye;const ws=new TextEncoder,Es=new TextDecoder,xs=X(q,T(1/0))[1];class te{constructor(t,n=!1){if(Se(this,ee),Se(this,$e,null),Se(this,Xe,null),Se(this,ze,null),Se(this,Ye,null),Te(this,"asText",()=>Z(this,Ye)??ve(this,Ye,Es.decode(Z(this,ee)))),Te(this,"asHex",()=>Z(this,Xe)??ve(this,Xe,Y(Z(this,ee)))),Te(this,"asOpaqueHex",()=>Z(this,ze)??ve(this,ze,Y(this.asBytes()))),Te(this,"asBytes",()=>Z(this,ee)),Te(this,"asOpaqueBytes",()=>Z(this,$e)??ve(this,$e,ue([Z(this,ee),q[0](Z(this,ee).length)]))),n){try{const[r,s]=xs(t);if(r===s.length){ve(this,ee,s),ve(this,$e,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ve(this,ee,t)}static fromText(t){return new this(ws.encode(t))}static fromHex(t){return new this(Le(t))}static fromOpaqueHex(t){return new this(Le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}ee=new WeakMap,$e=new WeakMap,Xe=new WeakMap,ze=new WeakMap,Ye=new WeakMap;const[Is]=ht();class pn extends te{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Is(t))}}const yn=e=>{const t=T.enc(e);return n=>t(n.asBytes())},gn=e=>{const t=T.dec(e),n=e==null?te:pn;return r=>n.fromBytes(t(r))},De=e=>A(yn(e),gn(e));De.enc=yn,De.dec=gn;const v=M(q,e=>e,Number),vn=M(q,e=>e,BigInt),Bs=Ie(e=>{const t=v.dec(e),n=Math.ceil(t/8);return{bytes:T(n).dec(e),bitsLen:t}}),As=A(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=v.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Bs),ks=M(k,e=>e.charCodeAt(0),String.fromCharCode),mn=e=>{const t=T.enc(e);return n=>t(Le(n))},bn=e=>{const t=T.dec(e);return n=>Y(t(n))},V=e=>A(mn(e),bn(e));V.enc=mn,V.dec=bn;const wn=new TextEncoder,_s=new TextDecoder,Os=e=>M(T(e),t=>wn.encode(t),t=>_s.decode(t)),En=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},xn=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},In=e=>A(En(()=>e().enc),xn(()=>e().dec)),pt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Us=new Proxy({},{get(e,t){return n=>pt(t,n)}}),_=(e,t)=>{const n=e;return n.inner=t,n},Bn=(...e)=>{const t=N.enc(...e);return _(n=>t({tag:n.type,value:n.value}),e[0])},An=(...e)=>{const t=N.dec(...e);return _(n=>{const{tag:r,value:s}=t(n);return pt(r,s)},e[0])},me=(e,...t)=>_(A(Bn(dn(e,([n])=>n),...t),An(dn(e,([,n])=>n),...t)),e);me.enc=Bn,me.dec=An;const Ge=(e,...t)=>_(N(e,...t),e);Ge.enc=(e,...t)=>_(N.enc(e,...t),e),Ge.dec=(e,...t)=>_(N.dec(e,...t),e);const J={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},ne=rs.slice(),kn=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class yt extends sn{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');z(r,32,"key");const c=r.slice();this.IV=ge(c),H(this.IV),this.flags=n|J.KEYED_HASH}else if(o){z(s,void 0,"context");const c=s,i=new yt({dkLen:32},J.DERIVE_KEY_CONTEXT).update(c).digest();this.IV=ge(i),H(this.IV),this.flags=n|J.DERIVE_KEY_MATERIAL}else this.IV=ne.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=es(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:d}=Ke(BigInt(t),!0),{v0:l,v1:a,v2:f,v3:h,v4:u,v5:p,v6:y,v7:m,v8:x,v9:L,v10:P,v11:O,v12:Ee,v13:nt,v14:rt,v15:Go}=on(kn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ne[0],ne[1],ne[2],ne[3],i,d,c,n);o[0]=l^x,o[1]=a^L,o[2]=f^P,o[3]=h^O,o[4]=u^Ee,o[5]=p^nt,o[6]=y^rt,o[7]=m^Go}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=J.CHUNK_START),(this.chunkPos===15||r)&&(s|=J.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|J.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:i,stack:d,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=d.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,oe(this.state,this.buffer32,this.IV,this.bufferOut32),oe(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:i}=Ke(BigInt(this.chunkOut++));H(s);const{v0:d,v1:l,v2:a,v3:f,v4:h,v5:u,v6:p,v7:y,v8:m,v9:x,v10:L,v11:P,v12:O,v13:Ee,v14:nt,v15:rt}=on(kn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ne[0],ne[1],ne[2],ne[3],i,c,n,r);o[0]=d^m,o[1]=l^x,o[2]=a^L,o[3]=f^P,o[4]=h^O,o[5]=u^Ee,o[6]=p^nt,o[7]=y^rt,o[8]=t[0]^m,o[9]=t[1]^x,o[10]=t[2]^L,o[11]=t[3]^P,o[12]=t[4]^O,o[13]=t[5]^Ee,o[14]=t[6]^nt,o[15]=t[7]^rt,H(s),H(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,oe(this.buffer.subarray(this.pos));let t=this.flags|J.ROOT;this.stack.length?(t|=J.PARENT,H(this.buffer32),this.compress(this.buffer32,0,!0),H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:J.CHUNK_START)|J.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ue(this,!1),z(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Be(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lt(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Ls=ut((e={})=>new yt(e)),Ts=BigInt(0),Ce=BigInt(1),Ss=BigInt(2),$s=BigInt(7),Ds=BigInt(256),Cs=BigInt(113),_n=[],On=[],Un=[];for(let e=0,t=Ce,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_n.push(2*(5*r+n)),On.push((e+1)*(e+2)/2%64);let s=Ts;for(let o=0;o<7;o++)t=(t<<Ce^(t>>$s)*Cs)%Ds,t&Ss&&(s^=Ce<<(Ce<<BigInt(o))-Ce);Un.push(s)}const Ln=ss(Un,!0),Hs=Ln[0],Vs=Ln[1],Tn=(e,t,n)=>n>32?ds(e,t,n):ls(e,t,n),Sn=(e,t,n)=>n>32?hs(e,t,n):us(e,t,n);function Ms(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,d=(c+2)%10,l=n[d],a=n[d+1],f=Tn(l,a,1)^n[i],h=Sn(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=f,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=On[c],d=Tn(s,o,i),l=Sn(s,o,i),a=_n[c];s=e[a],o=e[a+1],e[a]=d,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=Hs[r],e[1]^=Vs[r]}oe(n)}class gt{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Be(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ge(this.state)}clone(){return this._cloneInto()}keccak(){H(this.state32),Ms(this.state32,this.rounds),H(this.state32),this.posOut=0,this.pos=0}update(t){Ue(this),z(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Ue(this,!1),z(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Be(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,oe(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||=new gt(n,r,s,c,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const $n=((e,t,n,r={})=>ut(()=>new gt(t,e,n),r))(1,136,32),Dn=e=>{const t=e.slice(2),n=Y($n(wn.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},Ns=T(20)[1],Cn=A(e=>{const t=Le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Y(t);if(e===n||e===n.toUpperCase())return t;if(Dn(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ie(e=>Dn(Y(Ns(e))))),S=e=>_(b(e),e);S.enc=e=>_(b.enc(e),e),S.dec=e=>_(b.dec(e),e);const He=(...e)=>_(X(...e),e);He.enc=(...e)=>_(X.enc(...e),e),He.dec=(...e)=>_(X.dec(...e),e);const de=(e,...t)=>_(E(e,...t),e);de.enc=(e,...t)=>_(E.enc(e,...t),e),de.dec=(e,...t)=>_(E.dec(e,...t),e);const Je=(e,t)=>_(Oe(e,t),{ok:e,ko:t});Je.enc=(e,t)=>_(Oe.enc(e,t),{ok:e,ko:t}),Je.dec=(e,t)=>_(Oe.dec(e,t),{ok:e,ko:t});const Ae=e=>_(R(e),e);Ae.enc=e=>_(R.enc(e),e),Ae.dec=e=>_(R.dec(e),e);const Hn=(e=!0)=>Ie(t=>{const n=v.dec(t),r=Math.ceil(n/8),s=T(r).dec(t),o=new Array(n);let c=0;return s.forEach(i=>{for(let d=0;d<8&&c<n;d++){const l=e?d:7-d;o[c++]=i>>l&1}}),o}),Vn=(e=!0)=>t=>{const n=v.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let c=o*8,i=0;for(let d=0;d<8&&c<t.length;d++,c++)i|=t[c]<<(e?d:7-d);s[o]=i}return ue([n,s])},Qe=e=>A(Vn(e),Hn(e));Qe.enc=Vn,Qe.dec=Hn;const Mn=new TextEncoder,Nn=new TextDecoder,Rs=M(T(4),Mn.encode.bind(Mn),Nn.decode.bind(Nn)),vt=S({engine:Rs,payload:V()}),js=me({other:T(),consensus:vt,seal:vt,preRuntime:vt,runtimeUpdated:w},[0,4,5,6,8]),mt=V(32),Ps=S({parentHash:mt,number:v,stateRoot:mt,extrinsicRoot:mt,digests:de(js)}),F=E(I),Rn=R(I),qs=N({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),jn=E(b({name:Rn,type:v,typeName:Rn,docs:F})),Fs=b({len:se,type:v}),Ks=b({bitStoreType:v,bitOrderType:v}),Ws=E(b({name:I,fields:jn,index:k,docs:F})),Xs=N({composite:jn,variant:Ws,sequence:v,array:Fs,tuple:E(v),primitive:qs,compact:v,bitSequence:Ks}),zs=b({name:I,type:R(v)}),Ys=E(zs),Gs=b({id:v,path:F,params:Ys,def:Xs,docs:F}),Ve=E(Gs),ke=N({NotDeprecated:w,DeprecatedWithoutNote:w,Deprecated:b({note:I,since:R(I)})}),Js=E(b({index:k,deprecation:N({DeprecatedWithoutNote:w,Deprecated:b({note:I,since:R(I)})},[1,2])})),bt={name:I,inputs:E(b({name:I,type:v})),output:v,docs:F},Qs=b({name:I,methods:E(b(bt)),docs:F}),Zs=b({name:I,methods:E(b({...bt,deprecationInfo:ke})),docs:F,version:v,deprecationInfo:ke}),eo=b({id:V(32),...bt,deprecationInfo:ke}),to=N({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),no=E(to),ro=b({hashers:no,key:v,value:v}),Pn={name:I,modifier:k,type:N({plain:v,map:ro}),fallback:V(),docs:F},wt=R(v),qn={name:I,storage:R(b({prefix:I,items:E(b(Pn))})),calls:wt,events:wt,constants:E(b({name:I,type:v,value:V(),docs:F})),errors:wt,index:k},so={...qn,docs:F},Et=R(b({type:v,deprecationInfo:Js})),oo={name:I,storage:R(b({prefix:I,items:E(b({...Pn,deprecationInfo:ke}))})),calls:Et,events:Et,constants:E(b({name:I,type:v,value:V(),docs:F,deprecationInfo:ke})),errors:Et,associatedTypes:E(b({name:I,type:v,docs:F})),viewFns:E(eo),index:k,docs:F,deprecationInfo:ke},co=new Uint8Array,Fn=e=>A(()=>co,()=>e),io=b({type:v,version:k,signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Kn=b({lookup:Ve,pallets:E(b({...qn,docs:Fn([])})),extrinsic:io,type:v,apis:Fn([])}),ao=b({version:k,address:v,call:v,signature:v,extra:v,signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Wn=b({lookup:Ve,pallets:E(b(so)),extrinsic:ao,type:v,apis:E(Qs),outerEnums:b({call:v,event:v,error:v}),custom:E(X(I,b({type:v,value:V()})))}),lo=b({version:E(k),address:v,call:v,signature:v,signedExtensionsByVersion:E(X(k,E(v))),signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Xn=b({lookup:Ve,pallets:E(b(oo)),extrinsic:lo,apis:E(Zs),outerEnums:b({call:v,event:v,error:v}),custom:E(X(I,b({type:v,value:V()})))}),zn=()=>{throw new Error("Unsupported metadata version!")},j=A(zn,zn),Me=b({magicNumber:se,metadata:N({v0:j,v1:j,v2:j,v3:j,v4:j,v5:j,v6:j,v7:j,v8:j,v9:j,v10:j,v11:j,v12:j,v13:j,v14:Kn,v15:Wn,v16:Xn})}),xt=T(),uo=R(xt),ho=X(q,xt),fo=e=>{try{return Me.dec(e)}catch{}try{return Me.dec(uo.dec(e))}catch{}try{return Me.dec(xt.dec(e))}catch{}try{return Me.dec(ho.dec(e)[1])}catch{}throw null},po=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:c,apis:i,pallets:d,outerEnums:l}=e;return{version:15,lookup:s,pallets:d.map(a=>({...a,calls:a.calls!=null?{type:a.calls}:void 0,events:a.events!=null?{type:a.events}:void 0,errors:a.errors!=null?{type:a.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:i,outerEnums:l,custom:c}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},be={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},yo=M(k,({version:e,type:t})=>e+(be[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===be.bare||n===be.signed))return{version:t,type:be[n]};if(t===5&&(n===be.bare||n===be.general))return{version:t,type:be[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),go={dkLen:32},Ze=e=>We(e,go),vo={dkLen:16},It=e=>We(e,vo),Yn=e=>ue([It(e),e]),mo={dkLen:32},Gn=e=>Ls(e,mo),bo=e=>ue([Gn(e),e]),Jn=e=>e,we=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Bt=2n**64n-1n,C=(e,t)=>e<<t&Bt|e>>64n-t,B=(e,t)=>e*t&Bt,$=(e,t)=>e+t&Bt,D=11400714785074694791n,K=14029467366897019727n,Qn=1609587929392839161n,Ne=9650029242287828579n,Zn=2870177450012600261n;function he(e,t=0n){let n=$($(t,D),K),r=$(t,K),s=t,o=t-D,c=e.length,i=0,d=null;(function(){let u=0,p=u+c;if(c){if(d=new Uint8Array(32),c<32){d.set(e.subarray(0,c),i),i+=c;return}if(u<=p-32){const y=p-32;do{let m;m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=B(C($(n,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=B(C($(r,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=B(C($(s,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=B(C($(o,B(m,K)),31n),D),u+=8}while(u<=y)}u<p&&(d.set(e.subarray(u,p),i),i=p-u)}})(),e=d||e;let l,a=0;for(c>=32?(l=C(n,1n),l=$(l,C(r,7n)),l=$(l,C(s,12n)),l=$(l,C(o,18n)),n=B(C(B(n,K),31n),D),l=l^n,l=$(B(l,D),Ne),r=B(C(B(r,K),31n),D),l=l^r,l=$(B(l,D),Ne),s=B(C(B(s,K),31n),D),l=l^s,l=$(B(l,D),Ne),o=B(C(B(o,K),31n),D),l=l^o,l=$(B(l,D),Ne)):l=$(t,Zn),l=$(l,BigInt(c));a<=i-8;){let h=we(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=B(C(B(h,K),31n),D),l=$(B(C(l^h,27n),D),Ne),a+=8}if(a+4<=i){let h=B(we(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),D);l=$(B(C(l^h,23n),K),Qn),a+=4}for(;a<i;){const h=B(we(e[a++],0,0,0),Zn);l=B(C(l^h,11n),D)}let f=l>>33n;return l=B(l^f,K),f=l>>29n,l=B(l^f,Qn),f=l>>32n,l^=f,l}const et=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,he(e),!0),n.setBigUint64(8,he(e,1n),!0),t},er=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,he(e),!0),n.setBigUint64(8,he(e,1n),!0),n.setBigUint64(16,he(e,2n),!0),n.setBigUint64(24,he(e,3n),!0),t},tr=e=>ue([Pe.enc(he(e)),e]),nr=new TextEncoder,wo=new Map([[Jn,0],[tr,8],[Yn,16],[It,-16],[Ze,-32],[et,-16],[er,-32]]),Eo=e=>{const t=et(nr.encode(e));return(n,...r)=>{const s=ue([t,et(nr.encode(n))]),o=Y(s),c=l=>{if(!l.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const a=Le(l.slice(o.length)),f=new Array(r.length);for(let h=0,u=0;h<r.length;h++){const[p,y]=r[h],m=wo.get(y);if(m==null)throw new Error("Unknown hasher");if(m<0){const x=m*-1;f[h]=Y(a.slice(u,u+x)),u+=x}else u+=m,f[h]=p.dec(a.slice(u)),u+=p.enc(f[h]).length}return f},i=r.map(([{enc:l},a])=>f=>a(l(f)));return{enc:(...l)=>Y(ue([s,...l.map((a,f)=>i[f](a))])),dec:c}}},xo=te.fromText("modlpy/utilisuba").asBytes(),Io=({threshold:e,signatories:t})=>{const n=rr(t),r=ue([xo,q.enc(n.length),...n,ye.enc(e)]);return Ze(r)},rr=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),fe={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},sr=V().dec,Bo=V(1/0).dec,Ao=V(32).dec,or=k.dec,ko=e=>{const t=or(e);let n=6;const r=t>>n,s=r?r===1?fe.Leaf:r===2?fe.Branch:fe.BranchWithVal:t>>--n?fe.LeafWithHash:t>>--n?fe.BranchWithHash:t?fe.Reserved:fe.Empty;let o=t&255>>8-n;if(o===2**n-1){let c;do o+=c=or(e);while(c===255)}return{type:s,partialKey:V(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},cr=Ie(e=>{const t=ko(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Bo(e)};const r=ye.dec(e),s=[];for(let i=0;i<16;i++)r>>i&1&&s.push(i.toString(16));let o=null;n==="BranchWithVal"&&(o=sr(e)),n==="BranchWithHash"&&(o=Ao(e));const c={...t,children:Object.fromEntries(s.map(i=>[i,sr(e)]))};return o!==null&&(c.value=o),c}),ir=e=>Ie(t=>{const n=Y(e(new Uint8Array(t.buffer)));try{return{hash:n,...cr(t)}}catch{return{type:"Raw",hash:n,value:""}}});var _o=Object.freeze({__proto__:null,AccountId:ht,Bin:De,Binary:te,BitSeq:Qe,Blake2128:It,Blake2128Concat:Yn,Blake2256:Ze,Blake3256:Gn,Blake3256Concat:bo,Bytes:T,Enum:pt,FixedSizeBinary:pn,Hex:V,Identity:Jn,Keccak256:$n,Option:Ae,Result:Je,ScaleEnum:Ge,Self:In,Storage:Eo,Struct:S,TrieNodeHeaders:fe,TrieNodeWithHash:ir,Tuple:He,Twox128:et,Twox256:er,Twox64Concat:tr,Variant:me,Vector:de,_Enum:Us,_void:w,bitSequence:As,blockHeader:Ps,bool:Lr,char:ks,compact:q,compactBn:vn,compactNumber:v,createCodec:A,createDecoder:Ie,decAnyMetadata:fo,enhanceCodec:M,enhanceDecoder:ct,enhanceEncoder:ot,ethAccount:Cn,extrinsicFormat:yo,fixedStr:Os,fromBufferToBase58:ln,getMultisigAccountId:Io,getSs58AddressInfo:an,h64:he,i128:_r,i16:Ir,i256:Ur,i32:Br,i64:Ar,i8:xr,metadata:Me,selfDecoder:xn,selfEncoder:En,sortMultisigSignatories:rr,str:I,trieNodeDec:cr,u128:kr,u16:ye,u256:Or,u32:se,u64:Pe,u8:k,unifyMetadata:po,v14:Kn,v14Lookup:Ve,v15:Wn,v16:Xn,validateProofs:(e,t=Ze)=>{const n=e.map(ir(t)),r=Object.fromEntries(n.map(i=>[i.hash,i])),s=n.map(i=>i.hash),o=new Set(s),c=i=>{if(i.value)return;const d=e[s.indexOf(i.hash)];i.value=typeof d=="string"?d:Y(d)};return n.forEach(i=>{if("children"in i&&Object.values(i.children).forEach(d=>{const l=r[d];l&&(l.parent=i.hash,o.delete(d))}),i.type==="BranchWithHash"||i.type==="LeafWithHash"){const d=i.value,l=r[d];if(!l)return;o.delete(d),l.type!=="Raw"&&(Object.keys(l).forEach(a=>delete l[a]),l.type="Raw",l.hash=d),l.parent=i.hash,c(l)}i.type==="Raw"&&c(i)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const Oo=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let d=e(r,s,o,...c);return o.delete(i),s.has(i)&&(d=n(d,s.get(i),r,...c)),s.set(i,d),d},Uo=De(),ar=Oo((e,t,n,r)=>{if(e.type==="primitive")return _o[e.value];if(e.type==="void")return w;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Cn;if(e.type==="compact")return e.isBig?vn:v;if(e.type==="bitSequence")return Qe(e.isLSB);const s=u=>ar(u,t,n,r),o=(u,p)=>{const y=s(u);return p?de(y,p):de(y)},c=u=>He(...u.map(s)),i=u=>{const p=Object.fromEntries(Object.entries(u).map(([y,m])=>[y,s(m)]));return S(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Uo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?De(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return Ae(s(e.value));if(e.type==="result")return Je(s(e.value.ok),s(e.value.ko));const d=Object.values(e.value).map(u=>{switch(u.type){case"void":return w;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,p)=>[u,d[p]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,p)=>u===p)?me(l):me(l,a);return e.byteLength?To(h,e.byteLength):h},In,e=>e),Lo=(e,t=ht())=>{const n=new Map,r=s=>ar(e(s),n,new Set,t);return s=>r(s)},To=(e,t)=>{const n=T(t);return A(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},So=e=>{const{metadata:t}=e,n=Lo(e),r=(a="")=>{const f=e.storage[a];if(!f)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=f.key==null?w:n(f.key);return{key:lr(h,f.keyPrefix),value:n(f.typeId)}},s=a=>{const f=S(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:lr(f,a.selector),value:n(a.returnType.type)}},o=a=>{const f=t.spec.constructors.find(h=>h.label===a);if(!f)throw new Error(`Constructor ${a} not found`);return s(f)},c=a=>{const f=t.spec.messages.find(h=>h.label===a);if(!f)throw new Error(`Message ${a} not found`);return s(f)},i=a=>S(Object.fromEntries(a.args.map(f=>[f.label,n(f.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>me(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const f=t.spec.events,h=(p,y)=>M(p,m=>m.value,m=>({type:y,value:m}));if(a){const p=f.find(y=>y.signature_topic===a);return p?h(i(p),p.label):null}const u=f.filter(p=>p.signature_topic===a);return u.length?$o(u.map(p=>h(i(p),p.label))):null}}},lr=(e,t)=>{const n=te.fromHex(t).asBytes(),r=He(T(n.length),e);return M(r,s=>[n,s],([,s])=>s)},$o=e=>A(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),ur=e=>M(Ge(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Re=(e,t)=>M(de(e,t),n=>n??[],n=>n),dr=Ae(I),tt=Re(I),Do=ur({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),hr=Re(S({name:dr,type:v,typeName:dr,docs:tt})),Co=S({len:se,type:v}),Ho=S({bitStoreType:v,bitOrderType:v}),Vo=Re(S({name:I,fields:hr,index:k,docs:tt})),Mo=ur({composite:S({fields:hr}),variant:S({variants:Vo}),sequence:S({type:v}),array:Co,tuple:de(v),primitive:Do,compact:S({type:v}),bitSequence:Ho}),No=S({name:I,type:Ae(v)}),Ro=Re(No),jo=S({id:v,path:tt,params:Ro,def:Mo,docs:tt}),Po=M(jo,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),qo=Re(Po),Fo=e=>{const t=qo.enc(e.types),n=Ve.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=Ko(e,n),c=gr(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function Ko(e,t){const n={},r=(s,o=[])=>{function c(d){const l=t.length;return t[l]={id:l,docs:[],def:d,params:[],path:[]},l}if("root"in s){const d=Number(e.version)===4?te.fromBytes(te.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(f,h){const u=e.types[f].type,p="composite"in u.def?new Map((u.def.composite.fields??[]).map(m=>[m.name,m.type])):null,y=new Map((u.params??[]).map(m=>[m.name,m.type]));if(y.size===2&&y.has("V")&&p&&p.size===2&&p.has("len")&&p.has("elements")){a(p.get("len"),[...h,"len"]),a(p.get("elements"),h);return}else y.size===3&&y.has("K")&&y.has("V")?n[h.join(".")]={keyPrefix:d,key:y.get("K"),typeId:y.get("V")}:y.size===2&&y.has("V")&&(n[h.join(".")]={keyPrefix:d,key:null,typeId:y.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:d,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const d=r(s.array.layout,o);return d==null?null:c({tag:"array",value:{len:s.array.len,type:d}})}if("struct"in s){const d=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:d})}const i=Object.values(s.enum.variants).map((d,l)=>({name:d.name,fields:d.fields.map(a=>({name:a.name,type:r(a.layout,[...o,d.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const Wo=e=>{if(!e.metadata)throw new Error("Ink client needs the contract metadata");const t=Fo(e.metadata),n=So(t),r=pr(n.buildConstructor),s=pr(n.buildMessage),o=l=>{const a=t.metadata.spec.constructors.find(f=>f.label===l);if(!a)throw new Error(`Constructor ${l} not found`);return a},c=l=>{const a=t.metadata.spec.messages.find(f=>f.label===l);if(!a)throw new Error(`Message ${l} not found`);return a},i=t.metadata.spec.constructors.find(l=>l.default)?.label,d=t.metadata.spec.messages.find(l=>l.default)?.label;return{constructor:l=>({attributes:fr(o(l)),...r(l)}),defaultConstructor:i,message:l=>({attributes:fr(c(l)),...s(l)}),defaultMessage:d,storage:Xo(n.buildStorage),event:Number(t.metadata.version)===4?zo(n.buildEvents):Yo(t,n.buildEvent)}},fr=e=>({payable:e.payable,default:e.default,mutates:"mutates"in e?e.mutates:!0}),pr=e=>t=>{const n=e(t);return{encode:r=>te.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},Xo=e=>t=>{const n=e(t);return{encode:r=>te.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},zo=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},Yo=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>{const d=a=>(typeof a=="string"?a:a.asHex())===c;return i.map(a=>"event"in a?a:{event:a,topics:a.topics}).filter(a=>(a.event.type==="Contracts"||a.event.type==="Revive")&&a.event.value.type==="ContractEmitted"&&d(a.event.value.value.contract)).map(a=>{const h=[...a.topics,...a.event.value?.value?.topics??[]].map(u=>u.asHex()).find(u=>n.has(u));try{return s(a.event.value.value,h)}catch{return null}}).filter(a=>a!==null)}}};_e.getInkClient=Wo}));
1
+ (function(_e,xe){typeof exports=="object"&&typeof module<"u"?xe(exports):typeof define=="function"&&define.amd?define(["exports"],xe):(_e=typeof globalThis<"u"?globalThis:_e||self,xe(_e.papiInk={}))})(this,(function(_e){"use strict";const xe=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",pe={type:"void"},gr=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>f=>{let h=n.get(f);if(h)return h;if(r.has(f)){const p={id:f};return n.set(f,p),p}r.add(f);const u=a(f);return h=n.get(f),h?Object.assign(h,u):(h={id:f,...u},n.set(f,h)),r.delete(f),h};let o=!0,c=!0;const i=s(a=>{const f=t(e[a]);if(f)return f;const{def:h,path:u,params:p}=e[a];if(h.tag==="composite"){if(h.value.length===0)return pe;if(h.value.length===1){const y=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&xe(y,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&xe(y,20)?(c=!1,{type:"AccountId20"}):y}return d(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=i(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(u.length===1&&u[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:i(p[0].type),ko:i(p[1].type)}};if(h.value.length===0)return pe;const y={},m={};return h.value.forEach(x=>{const L=x.name;if(m[L]=x.docs,x.fields.length===0){y[L]={...pe,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){y[L]={type:"lookupEntry",value:i(x.fields[0].type),idx:x.index};return}y[L]={...d(x.fields),idx:x.index}}),{type:"enum",value:y,innerDocs:m}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:y}=h.value,m=i(h.value.type);return!y||m.type==="void"?pe:y>1?{type:"array",value:m,len:h.value.len}:m}if(h.tag==="tuple")return h.value.length===0?pe:h.value.length>1?l(h.value.map(y=>i(y)),h.value.map(y=>e[y].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const y=i(h.value);return y.type==="void"?pe:{type:"compact",isBig:Number(y.value.slice(1))>32,size:y.value}}return{type:h.tag,isLSB:(e[h.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),d=a=>{let f=!0;const h={},u={};return a.forEach((p,y)=>{f=f&&!!p.name;const m=p.name||y,x=i(p.type);x.type!=="void"&&(h[m]=x,u[m]=p.docs)}),f?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,f)=>{if(a.every(h=>h.id===a[0].id)&&f.every(h=>!h.length)){const[h]=a;return h.type==="void"?pe:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:f}};return i},vr=e=>gr(e);var mr=Object.defineProperty,br=(e,t,n)=>t in e?mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kt=(e,t,n)=>(br(e,typeof t!="symbol"?t+"":t,n),n),st={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function wr(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|st[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=st[e[c]],d=st[e[c+1]];s[t+o++]=i<<4|d}return s}var At=class extends Uint8Array{constructor(e){super(e),kt(this,"i",0),kt(this,"v"),this.v=new DataView(e)}},W=e=>t=>e(t instanceof At?t:new At(t instanceof Uint8Array?t.buffer:typeof t=="string"?wr(t).buffer:t)),G=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function je(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var Ie=W,k=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},ot=(e,t)=>n=>e(t(n)),ct=(e,t)=>n=>t(e(n)),M=([e,t],n,r)=>k(ot(e,n),ct(t,r));function Er(e,t){return W(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function xr(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function re(e,t,n){return k(xr(e,n),Er(e,t))}var A=re(1,"getUint8","setUint8"),ye=re(2,"getUint16","setUint16"),se=re(4,"getUint32","setUint32"),Pe=re(8,"getBigUint64","setBigUint64"),Ir=re(1,"getInt8","setInt8"),Br=re(2,"getInt16","setInt16"),kr=re(4,"getInt32","setInt32"),Ar=re(8,"getBigInt64","setBigInt64"),_t=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Ot=e=>W(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),_r=k(_t,Ot("getBigUint64")),Or=k(_t,Ot("getBigInt64")),Ut=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},Lt=e=>W(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Ur=k(Ut,Lt("getBigUint64")),Lr=k(Ut,Lt("getBigInt64")),Tr=M(A,e=>e?1:0,Boolean),Sr=[A[1],ye[1],se[1]],$r=W(e=>{const t=e[e.i],n=t&3;if(n<3)return Sr[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let d=0;d<o;d++)s=Pe[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(se[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(ye[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(A[1](e))<<c|s),s}),Dr=1n<<56n,Cr=1<<24,Hr=256,Vr=4294967295n,Mr=64,Nr=16384,Rr=1<<30,jr=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Mr)return A[0](t);if(e<Nr)return ye[0](t|1);if(e<Rr)return se[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Dr;)n.push(Pe[0](r)),r>>=64n;r>=Cr&&(n.push(se[0](Number(r&Vr))),r>>=32n);let s=Number(r);s>=Hr&&(n.push(ye[0](s)),s>>=16),s&&n.push(A[0](s));const o=G(n);return o[0]=o.length-5<<2|3,o},q=k(jr,$r),Pr=new TextEncoder,qr=e=>{const t=Pr.encode(e);return G([q.enc(t.length),t])},Fr=new TextDecoder,Kr=W(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Fr.decode(n)}),I=k(qr,Kr),Wr=()=>{},Xr=new Uint8Array(0),w=k(()=>Xr,Wr),Tt=e=>e===void 0?t=>G([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),St=e=>W(t=>{const n=e===void 0?q.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),T=e=>k(Tt(e),St(e));T.enc=Tt,T.dec=St;var $t=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>G([A.enc(s(o)),e[o](c)])},Dt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return W(s=>{const o=A.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},N=(e,...t)=>k($t(je(e,([n])=>n),...t),Dt(je(e,([,n])=>n),...t));N.enc=$t,N.dec=Dt;var Ct=e=>W(t=>A[1](t)>0?e(t):void 0),Ht=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,G([n,e(t)]))},R=e=>k(Ht(e[0]),Ct(e[1]));R.enc=Ht,R.dec=Ct;var Vt=(e,t)=>W(n=>{const r=A[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Mt=(e,t)=>({success:n,value:r})=>G([A[0](n?0:1),(n?e:t)(r)]),Oe=(e,t)=>k(Mt(e[0],t[0]),Vt(e[1],t[1]));Oe.dec=Vt,Oe.enc=Mt;var Nt=(...e)=>W(t=>e.map(n=>n(t))),Rt=(...e)=>t=>G(e.map((n,r)=>n(t[r]))),X=(...e)=>k(Rt(...e.map(([t])=>t)),Nt(...e.map(([,t])=>t)));X.enc=Rt,X.dec=Nt;var jt=e=>{const t=Object.keys(e);return ot(X.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Pt=e=>{const t=Object.keys(e);return ct(X.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},b=e=>k(jt(je(e,t=>t[0])),Pt(je(e,t=>t[1])));b.enc=jt,b.dec=Pt;var qt=(e,t)=>t>=0?n=>G(n.map(e)):n=>G([q.enc(n.length),G(n.map(e))]),Ft=(e,t)=>W(n=>{const r=t>=0?t:q.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),E=(e,t)=>k(qt(e[0],t),Ft(e[1],t));E.enc=qt,E.dec=Ft;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Kt(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function it(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Wt(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function at(e){if(!Array.isArray(e))throw new Error("array expected")}function Xt(e,t){if(!Kt(!0,t))throw new Error(`${e}: array of strings expected`)}function Yr(e,t){if(!Kt(!1,t))throw new Error(`${e}: array of numbers expected`)}function Gr(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Jr(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Xt("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(at(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(at(s),s.map(o=>{it("alphabet.decode",o);const c=r.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return c}))}}function Qr(e=""){return it("join",e),{encode:t=>(Xt("join.decode",t),t.join(e)),decode:t=>(it("join.decode",t),t.split(e))}}function zt(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(at(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,i=>{if(Wt(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=o.length;for(;;){let i=0,d=!0;for(let l=r;l<c;l++){const a=o[l],f=t*i,h=f+a;if(!Number.isSafeInteger(h)||f/t!==i||h-a!==f)throw new Error("convertRadix: carry overflow");const u=h/n;i=h%n;const p=Math.floor(u);if(o[l]=p,!Number.isSafeInteger(p)||p*n+i!==h)throw new Error("convertRadix: carry overflow");if(d)p?d=!1:r=l;else continue}if(s.push(i),d)break}for(let i=0;i<e.length-1&&e[i]===0;i++)s.push(0);return s.reverse()}function Zr(e){Wt(e);const t=2**8;return{encode:n=>{if(!zr(n))throw new Error("radix.encode input should be Uint8Array");return zt(Array.from(n),t,e)},decode:n=>(Yr("radix.decode",n),Uint8Array.from(zt(n,e,t)))}}const Yt=(e=>Gr(Zr(58),Jr(e),Qr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function es(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Be(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function z(e,t,n=""){const r=es(e),s=e?.length,o=t!==void 0;if(!r||o&&s!==t){const c=n&&`"${n}" `,i=o?` of length ${t}`:"",d=r?`length=${s}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+i+", got "+d)}return e}function Ue(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 lt(e,t){z(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function ts(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ge(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function qe(e,t){return e<<32-t|e>>>t}const Gt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Jt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Q=Gt?e=>e:e=>Jt(e);function ns(e){for(let t=0;t<e.length;t++)e[t]=Jt(e[t]);return e}const H=Gt?e=>e:ns;function ut(e,t={}){const n=(s,o)=>e(o).update(s).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=s=>e(s),Object.assign(n,t),Object.freeze(n)}const rs=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function ce(e,t,n,r,s){return e=e+t+s|0,r=qe(r^e,16),n=n+r|0,t=qe(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=qe(r^e,8),n=n+r|0,t=qe(t^n,7),{a:e,b:t,c:n,d:r}}const ss=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fe=BigInt(2**32-1),Qt=BigInt(32);function Ke(e,t=!1){return t?{h:Number(e&Fe),l:Number(e>>Qt&Fe)}:{h:Number(e>>Qt&Fe)|0,l:Number(e&Fe)|0}}function os(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:c,l:i}=Ke(e[o],t);[r[o],s[o]]=[c,i]}return[r,s]}const Zt=(e,t,n)=>e>>>n|t<<32-n,en=(e,t,n)=>e<<32-n|t>>>n,cs=(e,t,n)=>e<<64-n|t>>>n-32,is=(e,t,n)=>e>>>n-32|t<<64-n,as=(e,t)=>t,ls=(e,t)=>e,us=(e,t,n)=>e<<n|t>>>32-n,ds=(e,t,n)=>t<<n|e>>>32-n,hs=(e,t,n)=>t<<n-32|e>>>64-n,fs=(e,t,n)=>e<<n-32|t>>>64-n;function tn(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const nn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),rn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,U=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function ae(e,t,n,r,s,o){const c=s[o],i=s[o+1];let d=g[2*e],l=g[2*e+1],a=g[2*t],f=g[2*t+1],h=g[2*n],u=g[2*n+1],p=g[2*r],y=g[2*r+1],m=nn(d,a,c);l=rn(m,l,f,i),d=m|0,{Dh:y,Dl:p}={Dh:y^l,Dl:p^d},{Dh:y,Dl:p}={Dh:as(y,p),Dl:ls(y)},{h:u,l:h}=tn(u,h,y,p),{Bh:f,Bl:a}={Bh:f^u,Bl:a^h},{Bh:f,Bl:a}={Bh:Zt(f,a,24),Bl:en(f,a,24)},g[2*e]=d,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=f,g[2*n]=h,g[2*n+1]=u,g[2*r]=p,g[2*r+1]=y}function le(e,t,n,r,s,o){const c=s[o],i=s[o+1];let d=g[2*e],l=g[2*e+1],a=g[2*t],f=g[2*t+1],h=g[2*n],u=g[2*n+1],p=g[2*r],y=g[2*r+1],m=nn(d,a,c);l=rn(m,l,f,i),d=m|0,{Dh:y,Dl:p}={Dh:y^l,Dl:p^d},{Dh:y,Dl:p}={Dh:Zt(y,p,16),Dl:en(y,p,16)},{h:u,l:h}=tn(u,h,y,p),{Bh:f,Bl:a}={Bh:f^u,Bl:a^h},{Bh:f,Bl:a}={Bh:cs(f,a,63),Bl:is(f,a,63)},g[2*e]=d,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=f,g[2*n]=h,g[2*n+1]=u,g[2*r]=p,g[2*r+1]=y}function ps(e,t={},n,r,s){if(Be(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:c,personalization:i}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);c!==void 0&&z(c,r,"salt"),i!==void 0&&z(i,s,"personalization")}class sn{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Be(t),Be(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=ge(this.buffer)}update(t){Ue(this),z(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,c=t.byteOffset,i=t.buffer;for(let d=0;d<o;){this.pos===n&&(H(s),this.compress(s,0,!1),H(s),this.pos=0);const l=Math.min(n-this.pos,o-d),a=c+d;if(l===n&&!(a%4)&&d+l<o){const f=new Uint32Array(i,a,Math.floor((o-d)/4));H(f);for(let h=0;d+n<o;h+=s.length,d+=n)this.length+=n,this.compress(f,h,!1);H(f);continue}r.set(t.subarray(d,d+l),this.pos),this.pos+=l,this.length+=l,d+=l}return this}digestInto(t){Ue(this),lt(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,oe(this.buffer.subarray(n)),H(r),this.compress(r,0,!0),H(r);const s=ge(t);this.get().forEach((o,c)=>s[c]=Q(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:i}=this;return t||=new this.constructor({dkLen:c}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=i,t.outputLen=c,t}clone(){return this._cloneInto()}}class ys extends sn{v0l=U[0]|0;v0h=U[1]|0;v1l=U[2]|0;v1h=U[3]|0;v2l=U[4]|0;v2h=U[5]|0;v3l=U[6]|0;v3h=U[7]|0;v4l=U[8]|0;v4h=U[9]|0;v5l=U[10]|0;v5h=U[11]|0;v6l=U[12]|0;v6h=U[13]|0;v7l=U[14]|0;v7h=U[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),ps(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,c=0;if(r!==void 0&&(z(r,void 0,"key"),c=r.length),this.v0l^=this.outputLen|c<<8|65536|1<<24,o!==void 0){z(o,void 0,"salt");const i=ge(o);this.v4l^=Q(i[0]),this.v4h^=Q(i[1]),this.v5l^=Q(i[2]),this.v5h^=Q(i[3])}if(s!==void 0){z(s,void 0,"personalization");const i=ge(s);this.v6l^=Q(i[0]),this.v6h^=Q(i[1]),this.v7l^=Q(i[2]),this.v7h^=Q(i[3])}if(r!==void 0){const i=new Uint8Array(this.blockLen);i.set(r),this.update(i)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:d,v4l:l,v4h:a,v5l:f,v5h:h,v6l:u,v6h:p,v7l:y,v7h:m}=this;return[t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m]}set(t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=d|0,this.v4l=l|0,this.v4h=a|0,this.v5l=f|0,this.v5h=h|0,this.v6l=u|0,this.v6h=p|0,this.v7l=y|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((d,l)=>g[l]=d),g.set(U,16);let{h:s,l:o}=Ke(BigInt(this.length));g[24]=U[8]^o,g[25]=U[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=rs;for(let d=0;d<12;d++)ae(0,4,8,12,t,n+2*i[c++]),le(0,4,8,12,t,n+2*i[c++]),ae(1,5,9,13,t,n+2*i[c++]),le(1,5,9,13,t,n+2*i[c++]),ae(2,6,10,14,t,n+2*i[c++]),le(2,6,10,14,t,n+2*i[c++]),ae(3,7,11,15,t,n+2*i[c++]),le(3,7,11,15,t,n+2*i[c++]),ae(0,5,10,15,t,n+2*i[c++]),le(0,5,10,15,t,n+2*i[c++]),ae(1,6,11,12,t,n+2*i[c++]),le(1,6,11,12,t,n+2*i[c++]),ae(2,7,8,13,t,n+2*i[c++]),le(2,7,8,13,t,n+2*i[c++]),ae(3,4,9,14,t,n+2*i[c++]),le(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],oe(g)}destroy(){this.destroyed=!0,oe(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const We=ut(e=>new ys(e));function on(e,t,n,r,s,o,c,i,d,l,a,f,h,u,p,y,m,x,L,P){let O=0;for(let Ee=0;Ee<r;Ee++)({a:s,b:d,c:h,d:m}=ce(s,d,h,m,n[t+e[O++]])),{a:s,b:d,c:h,d:m}=ie(s,d,h,m,n[t+e[O++]]),{a:o,b:l,c:u,d:x}=ce(o,l,u,x,n[t+e[O++]]),{a:o,b:l,c:u,d:x}=ie(o,l,u,x,n[t+e[O++]]),{a:c,b:a,c:p,d:L}=ce(c,a,p,L,n[t+e[O++]]),{a:c,b:a,c:p,d:L}=ie(c,a,p,L,n[t+e[O++]]),{a:i,b:f,c:y,d:P}=ce(i,f,y,P,n[t+e[O++]]),{a:i,b:f,c:y,d:P}=ie(i,f,y,P,n[t+e[O++]]),{a:s,b:l,c:p,d:P}=ce(s,l,p,P,n[t+e[O++]]),{a:s,b:l,c:p,d:P}=ie(s,l,p,P,n[t+e[O++]]),{a:o,b:a,c:y,d:m}=ce(o,a,y,m,n[t+e[O++]]),{a:o,b:a,c:y,d:m}=ie(o,a,y,m,n[t+e[O++]]),{a:c,b:f,c:h,d:x}=ce(c,f,h,x,n[t+e[O++]]),{a:c,b:f,c:h,d:x}=ie(c,f,h,x,n[t+e[O++]]),{a:i,b:d,c:u,d:L}=ce(i,d,u,L,n[t+e[O++]]),{a:i,b:d,c:u,d:L}=ie(i,d,u,L,n[t+e[O++]]);return{v0:s,v1:o,v2:c,v3:i,v4:d,v5:l,v6:a,v7:f,v8:h,v9:u,v10:p,v11:y,v12:m,v13:x,v14:L,v15:P}}const cn=new TextEncoder().encode("SS58PRE"),dt=2,an=e=>{try{const t=Yt.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-dt),s=t.subarray(n.length+r.length),o=We(Uint8Array.of(...cn,...n,...r),{dkLen:64}).subarray(0,dt);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:gs(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},gs=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},vs=e=>{let t={},n=0,r=0;const s=()=>{n===r?(t={},n=r=0):(r=n,setTimeout(s,0))};return o=>{var c,i;++n===1&&s();let d=t;const l=o.length-1;for(let a=0;a<=l;a++)d=d[c=o[a]]||(d[c]={});return d[i=o[l]]||(d[i]=e(o))}},ln=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return vs(n=>{const r=We(Uint8Array.of(...cn,...t,...n),{dkLen:64}).subarray(0,dt);return Yt.encode(Uint8Array.of(...t,...n,...r))})};function ms(e,t){return n=>{const r=an(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const ht=(e=42,t=32)=>M(T(t),ms(t),ln(e)),un="0123456789abcdef";function Y(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=un[r>>4]+un[r&15]}return t.join("")}const ft={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Le(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|ft[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=ft[e[c]],d=ft[e[c+1]];s[t+o++]=i<<4|d}return s}function dn(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const c=t[s];r.set(c,o),o+=c.byteLength}return r};var bs=Object.defineProperty,hn=e=>{throw TypeError(e)},ws=(e,t,n)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Te=(e,t,n)=>ws(e,typeof t!="symbol"?t+"":t,n),fn=(e,t,n)=>t.has(e)||hn("Cannot "+n),Z=(e,t,n)=>(fn(e,t,"read from private field"),n?n.call(e):t.get(e)),Se=(e,t,n)=>t.has(e)?hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ve=(e,t,n,r)=>(fn(e,t,"write to private field"),t.set(e,n),n),ee,$e,Xe,ze,Ye;const Es=new TextEncoder,xs=new TextDecoder,Is=X(q,T(1/0))[1];class te{constructor(t,n=!1){if(Se(this,ee),Se(this,$e,null),Se(this,Xe,null),Se(this,ze,null),Se(this,Ye,null),Te(this,"asText",()=>Z(this,Ye)??ve(this,Ye,xs.decode(Z(this,ee)))),Te(this,"asHex",()=>Z(this,Xe)??ve(this,Xe,Y(Z(this,ee)))),Te(this,"asOpaqueHex",()=>Z(this,ze)??ve(this,ze,Y(this.asOpaqueBytes()))),Te(this,"asBytes",()=>Z(this,ee)),Te(this,"asOpaqueBytes",()=>Z(this,$e)??ve(this,$e,ue([q[0](Z(this,ee).length),Z(this,ee)]))),n){try{const[r,s]=Is(t);if(r===s.length){ve(this,ee,s),ve(this,$e,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ve(this,ee,t)}static fromText(t){return new this(Es.encode(t))}static fromHex(t){return new this(Le(t))}static fromOpaqueHex(t){return new this(Le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}ee=new WeakMap,$e=new WeakMap,Xe=new WeakMap,ze=new WeakMap,Ye=new WeakMap;const[Bs]=ht();class pn extends te{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Bs(t))}}const yn=e=>{const t=T.enc(e);return n=>t(n.asBytes())},gn=e=>{const t=T.dec(e),n=e==null?te:pn;return r=>n.fromBytes(t(r))},De=e=>k(yn(e),gn(e));De.enc=yn,De.dec=gn;const v=M(q,e=>e,Number),vn=M(q,e=>e,BigInt),ks=Ie(e=>{const t=v.dec(e),n=Math.ceil(t/8);return{bytes:T(n).dec(e),bitsLen:t}}),As=k(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=v.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ks),_s=M(A,e=>e.charCodeAt(0),String.fromCharCode),mn=e=>{const t=T.enc(e);return n=>t(Le(n))},bn=e=>{const t=T.dec(e);return n=>Y(t(n))},V=e=>k(mn(e),bn(e));V.enc=mn,V.dec=bn;const wn=new TextEncoder,Os=new TextDecoder,Us=e=>M(T(e),t=>wn.encode(t),t=>Os.decode(t)),En=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},xn=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},In=e=>k(En(()=>e().enc),xn(()=>e().dec)),pt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Ls=new Proxy({},{get(e,t){return n=>pt(t,n)}}),_=(e,t)=>{const n=e;return n.inner=t,n},Bn=(...e)=>{const t=N.enc(...e);return _(n=>t({tag:n.type,value:n.value}),e[0])},kn=(...e)=>{const t=N.dec(...e);return _(n=>{const{tag:r,value:s}=t(n);return pt(r,s)},e[0])},me=(e,...t)=>_(k(Bn(dn(e,([n])=>n),...t),kn(dn(e,([,n])=>n),...t)),e);me.enc=Bn,me.dec=kn;const Ge=(e,...t)=>_(N(e,...t),e);Ge.enc=(e,...t)=>_(N.enc(e,...t),e),Ge.dec=(e,...t)=>_(N.dec(e,...t),e);const J={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},ne=ss.slice(),An=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class yt extends sn{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');z(r,32,"key");const c=r.slice();this.IV=ge(c),H(this.IV),this.flags=n|J.KEYED_HASH}else if(o){z(s,void 0,"context");const c=s,i=new yt({dkLen:32},J.DERIVE_KEY_CONTEXT).update(c).digest();this.IV=ge(i),H(this.IV),this.flags=n|J.DERIVE_KEY_MATERIAL}else this.IV=ne.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=ts(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:d}=Ke(BigInt(t),!0),{v0:l,v1:a,v2:f,v3:h,v4:u,v5:p,v6:y,v7:m,v8:x,v9:L,v10:P,v11:O,v12:Ee,v13:nt,v14:rt,v15:Qo}=on(An,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ne[0],ne[1],ne[2],ne[3],i,d,c,n);o[0]=l^x,o[1]=a^L,o[2]=f^P,o[3]=h^O,o[4]=u^Ee,o[5]=p^nt,o[6]=y^rt,o[7]=m^Qo}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=J.CHUNK_START),(this.chunkPos===15||r)&&(s|=J.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|J.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:i,stack:d,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=d.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,oe(this.state,this.buffer32,this.IV,this.bufferOut32),oe(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:i}=Ke(BigInt(this.chunkOut++));H(s);const{v0:d,v1:l,v2:a,v3:f,v4:h,v5:u,v6:p,v7:y,v8:m,v9:x,v10:L,v11:P,v12:O,v13:Ee,v14:nt,v15:rt}=on(An,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ne[0],ne[1],ne[2],ne[3],i,c,n,r);o[0]=d^m,o[1]=l^x,o[2]=a^L,o[3]=f^P,o[4]=h^O,o[5]=u^Ee,o[6]=p^nt,o[7]=y^rt,o[8]=t[0]^m,o[9]=t[1]^x,o[10]=t[2]^L,o[11]=t[3]^P,o[12]=t[4]^O,o[13]=t[5]^Ee,o[14]=t[6]^nt,o[15]=t[7]^rt,H(s),H(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,oe(this.buffer.subarray(this.pos));let t=this.flags|J.ROOT;this.stack.length?(t|=J.PARENT,H(this.buffer32),this.compress(this.buffer32,0,!0),H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:J.CHUNK_START)|J.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ue(this,!1),z(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Be(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lt(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Ts=ut((e={})=>new yt(e)),Ss=BigInt(0),Ce=BigInt(1),$s=BigInt(2),Ds=BigInt(7),Cs=BigInt(256),Hs=BigInt(113),_n=[],On=[],Un=[];for(let e=0,t=Ce,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_n.push(2*(5*r+n)),On.push((e+1)*(e+2)/2%64);let s=Ss;for(let o=0;o<7;o++)t=(t<<Ce^(t>>Ds)*Hs)%Cs,t&$s&&(s^=Ce<<(Ce<<BigInt(o))-Ce);Un.push(s)}const Ln=os(Un,!0),Vs=Ln[0],Ms=Ln[1],Tn=(e,t,n)=>n>32?hs(e,t,n):us(e,t,n),Sn=(e,t,n)=>n>32?fs(e,t,n):ds(e,t,n);function Ns(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,d=(c+2)%10,l=n[d],a=n[d+1],f=Tn(l,a,1)^n[i],h=Sn(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=f,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=On[c],d=Tn(s,o,i),l=Sn(s,o,i),a=_n[c];s=e[a],o=e[a+1],e[a]=d,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=Vs[r],e[1]^=Ms[r]}oe(n)}class gt{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,r,s=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Be(r,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ge(this.state)}clone(){return this._cloneInto()}keccak(){H(this.state32),Ns(this.state32,this.rounds),H(this.state32),this.posOut=0,this.pos=0}update(t){Ue(this),z(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Ue(this,!1),z(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Be(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,oe(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||=new gt(n,r,s,c,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const $n=((e,t,n,r={})=>ut(()=>new gt(t,e,n),r))(1,136,32),Dn=e=>{const t=e.slice(2),n=Y($n(wn.encode(t))).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},Rs=T(20)[1],Cn=k(e=>{const t=Le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Y(t);if(e===n||e===n.toUpperCase())return t;if(Dn(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ie(e=>Dn(Y(Rs(e))))),S=e=>_(b(e),e);S.enc=e=>_(b.enc(e),e),S.dec=e=>_(b.dec(e),e);const He=(...e)=>_(X(...e),e);He.enc=(...e)=>_(X.enc(...e),e),He.dec=(...e)=>_(X.dec(...e),e);const de=(e,...t)=>_(E(e,...t),e);de.enc=(e,...t)=>_(E.enc(e,...t),e),de.dec=(e,...t)=>_(E.dec(e,...t),e);const Je=(e,t)=>_(Oe(e,t),{ok:e,ko:t});Je.enc=(e,t)=>_(Oe.enc(e,t),{ok:e,ko:t}),Je.dec=(e,t)=>_(Oe.dec(e,t),{ok:e,ko:t});const ke=e=>_(R(e),e);ke.enc=e=>_(R.enc(e),e),ke.dec=e=>_(R.dec(e),e);const Hn=(e=!0)=>Ie(t=>{const n=v.dec(t),r=Math.ceil(n/8),s=T(r).dec(t),o=new Array(n);let c=0;return s.forEach(i=>{for(let d=0;d<8&&c<n;d++){const l=e?d:7-d;o[c++]=i>>l&1}}),o}),Vn=(e=!0)=>t=>{const n=v.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let c=o*8,i=0;for(let d=0;d<8&&c<t.length;d++,c++)i|=t[c]<<(e?d:7-d);s[o]=i}return ue([n,s])},Qe=e=>k(Vn(e),Hn(e));Qe.enc=Vn,Qe.dec=Hn;const Mn=new TextEncoder,Nn=new TextDecoder,js=M(T(4),Mn.encode.bind(Mn),Nn.decode.bind(Nn)),vt=S({engine:js,payload:V()}),Ps=me({other:T(),consensus:vt,seal:vt,preRuntime:vt,runtimeUpdated:w},[0,4,5,6,8]),mt=V(32),qs=S({parentHash:mt,number:v,stateRoot:mt,extrinsicRoot:mt,digests:de(Ps)}),F=E(I),Rn=R(I),Fs=N({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),jn=E(b({name:Rn,type:v,typeName:Rn,docs:F})),Ks=b({len:se,type:v}),Ws=b({bitStoreType:v,bitOrderType:v}),Xs=E(b({name:I,fields:jn,index:A,docs:F})),zs=N({composite:jn,variant:Xs,sequence:v,array:Ks,tuple:E(v),primitive:Fs,compact:v,bitSequence:Ws}),Ys=b({name:I,type:R(v)}),Gs=E(Ys),Js=b({id:v,path:F,params:Gs,def:zs,docs:F}),Ve=E(Js),Ae=N({NotDeprecated:w,DeprecatedWithoutNote:w,Deprecated:b({note:I,since:R(I)})}),Qs=E(b({index:A,deprecation:N({DeprecatedWithoutNote:w,Deprecated:b({note:I,since:R(I)})},[1,2])})),bt={name:I,inputs:E(b({name:I,type:v})),output:v,docs:F},Zs=b({name:I,methods:E(b(bt)),docs:F}),eo=b({name:I,methods:E(b({...bt,deprecationInfo:Ae})),docs:F,version:v,deprecationInfo:Ae}),to=b({id:V(32),...bt,deprecationInfo:Ae}),no=N({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),ro=E(no),so=b({hashers:ro,key:v,value:v}),Pn={name:I,modifier:A,type:N({plain:v,map:so}),fallback:V(),docs:F},wt=R(v),qn={name:I,storage:R(b({prefix:I,items:E(b(Pn))})),calls:wt,events:wt,constants:E(b({name:I,type:v,value:V(),docs:F})),errors:wt,index:A},oo={...qn,docs:F},Et=R(b({type:v,deprecationInfo:Qs})),co={name:I,storage:R(b({prefix:I,items:E(b({...Pn,deprecationInfo:Ae}))})),calls:Et,events:Et,constants:E(b({name:I,type:v,value:V(),docs:F,deprecationInfo:Ae})),errors:Et,associatedTypes:E(b({name:I,type:v,docs:F})),viewFns:E(to),index:A,docs:F,deprecationInfo:Ae},io=new Uint8Array,Fn=e=>k(()=>io,()=>e),ao=b({type:v,version:A,signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Kn=b({lookup:Ve,pallets:E(b({...qn,docs:Fn([])})),extrinsic:ao,type:v,apis:Fn([])}),lo=b({version:A,address:v,call:v,signature:v,extra:v,signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Wn=b({lookup:Ve,pallets:E(b(oo)),extrinsic:lo,type:v,apis:E(Zs),outerEnums:b({call:v,event:v,error:v}),custom:E(X(I,b({type:v,value:V()})))}),uo=b({version:E(A),address:v,call:v,signature:v,signedExtensionsByVersion:E(X(A,E(v))),signedExtensions:E(b({identifier:I,type:v,additionalSigned:v}))}),Xn=b({lookup:Ve,pallets:E(b(co)),extrinsic:uo,apis:E(eo),outerEnums:b({call:v,event:v,error:v}),custom:E(X(I,b({type:v,value:V()})))}),zn=()=>{throw new Error("Unsupported metadata version!")},j=k(zn,zn),Me=b({magicNumber:se,metadata:N({v0:j,v1:j,v2:j,v3:j,v4:j,v5:j,v6:j,v7:j,v8:j,v9:j,v10:j,v11:j,v12:j,v13:j,v14:Kn,v15:Wn,v16:Xn})}),xt=T(),ho=R(xt),fo=X(q,xt),po=e=>{try{return Me.dec(e)}catch{}try{return Me.dec(ho.dec(e))}catch{}try{return Me.dec(xt.dec(e))}catch{}try{return Me.dec(fo.dec(e)[1])}catch{}throw null},yo=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:c,apis:i,pallets:d,outerEnums:l}=e;return{version:15,lookup:s,pallets:d.map(a=>({...a,calls:a.calls!=null?{type:a.calls}:void 0,events:a.events!=null?{type:a.events}:void 0,errors:a.errors!=null?{type:a.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:i,outerEnums:l,custom:c}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},be={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},go=M(A,({version:e,type:t})=>e+(be[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===be.bare||n===be.signed))return{version:t,type:be[n]};if(t===5&&(n===be.bare||n===be.general))return{version:t,type:be[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),vo={dkLen:32},Ze=e=>We(e,vo),mo={dkLen:16},It=e=>We(e,mo),Yn=e=>ue([It(e),e]),bo={dkLen:32},Gn=e=>Ts(e,bo),wo=e=>ue([Gn(e),e]),Jn=e=>e,we=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Bt=2n**64n-1n,C=(e,t)=>e<<t&Bt|e>>64n-t,B=(e,t)=>e*t&Bt,$=(e,t)=>e+t&Bt,D=11400714785074694791n,K=14029467366897019727n,Qn=1609587929392839161n,Ne=9650029242287828579n,Zn=2870177450012600261n;function he(e,t=0n){let n=$($(t,D),K),r=$(t,K),s=t,o=t-D,c=e.length,i=0,d=null;(function(){let u=0,p=u+c;if(c){if(d=new Uint8Array(32),c<32){d.set(e.subarray(0,c),i),i+=c;return}if(u<=p-32){const y=p-32;do{let m;m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=B(C($(n,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=B(C($(r,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=B(C($(s,B(m,K)),31n),D),u+=8,m=we(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=B(C($(o,B(m,K)),31n),D),u+=8}while(u<=y)}u<p&&(d.set(e.subarray(u,p),i),i=p-u)}})(),e=d||e;let l,a=0;for(c>=32?(l=C(n,1n),l=$(l,C(r,7n)),l=$(l,C(s,12n)),l=$(l,C(o,18n)),n=B(C(B(n,K),31n),D),l=l^n,l=$(B(l,D),Ne),r=B(C(B(r,K),31n),D),l=l^r,l=$(B(l,D),Ne),s=B(C(B(s,K),31n),D),l=l^s,l=$(B(l,D),Ne),o=B(C(B(o,K),31n),D),l=l^o,l=$(B(l,D),Ne)):l=$(t,Zn),l=$(l,BigInt(c));a<=i-8;){let h=we(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=B(C(B(h,K),31n),D),l=$(B(C(l^h,27n),D),Ne),a+=8}if(a+4<=i){let h=B(we(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),D);l=$(B(C(l^h,23n),K),Qn),a+=4}for(;a<i;){const h=B(we(e[a++],0,0,0),Zn);l=B(C(l^h,11n),D)}let f=l>>33n;return l=B(l^f,K),f=l>>29n,l=B(l^f,Qn),f=l>>32n,l^=f,l}const et=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,he(e),!0),n.setBigUint64(8,he(e,1n),!0),t},er=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,he(e),!0),n.setBigUint64(8,he(e,1n),!0),n.setBigUint64(16,he(e,2n),!0),n.setBigUint64(24,he(e,3n),!0),t},tr=e=>ue([Pe.enc(he(e)),e]),nr=new TextEncoder,Eo=new Map([[Jn,0],[tr,8],[Yn,16],[It,-16],[Ze,-32],[et,-16],[er,-32]]),xo=e=>{const t=et(nr.encode(e));return(n,...r)=>{const s=ue([t,et(nr.encode(n))]),o=Y(s),c=l=>{if(!l.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const a=Le(l.slice(o.length)),f=new Array(r.length);for(let h=0,u=0;h<r.length;h++){const[p,y]=r[h],m=Eo.get(y);if(m==null)throw new Error("Unknown hasher");if(m<0){const x=m*-1;f[h]=Y(a.slice(u,u+x)),u+=x}else u+=m,f[h]=p.dec(a.slice(u)),u+=p.enc(f[h]).length}return f},i=r.map(([{enc:l},a])=>f=>a(l(f)));return{enc:(...l)=>Y(ue([s,...l.map((a,f)=>i[f](a))])),dec:c}}},Io=te.fromText("modlpy/utilisuba").asBytes(),Bo=({threshold:e,signatories:t})=>{const n=rr(t),r=ue([Io,q.enc(n.length),...n,ye.enc(e)]);return Ze(r)},rr=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}}),fe={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},sr=V().dec,ko=V(1/0).dec,Ao=V(32).dec,or=A.dec,_o=e=>{const t=or(e);let n=6;const r=t>>n,s=r?r===1?fe.Leaf:r===2?fe.Branch:fe.BranchWithVal:t>>--n?fe.LeafWithHash:t>>--n?fe.BranchWithHash:t?fe.Reserved:fe.Empty;let o=t&255>>8-n;if(o===2**n-1){let c;do o+=c=or(e);while(c===255)}return{type:s,partialKey:V(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},cr=Ie(e=>{const t=_o(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:ko(e)};const r=ye.dec(e),s=[];for(let i=0;i<16;i++)r>>i&1&&s.push(i.toString(16));let o=null;n==="BranchWithVal"&&(o=sr(e)),n==="BranchWithHash"&&(o=Ao(e));const c={...t,children:Object.fromEntries(s.map(i=>[i,sr(e)]))};return o!==null&&(c.value=o),c}),ir=e=>Ie(t=>{const n=Y(e(new Uint8Array(t.buffer)));try{return{hash:n,...cr(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Oo=Object.freeze({__proto__:null,AccountId:ht,Bin:De,Binary:te,BitSeq:Qe,Blake2128:It,Blake2128Concat:Yn,Blake2256:Ze,Blake3256:Gn,Blake3256Concat:wo,Bytes:T,Enum:pt,FixedSizeBinary:pn,Hex:V,Identity:Jn,Keccak256:$n,Option:ke,Result:Je,ScaleEnum:Ge,Self:In,Storage:xo,Struct:S,TrieNodeHeaders:fe,TrieNodeWithHash:ir,Tuple:He,Twox128:et,Twox256:er,Twox64Concat:tr,Variant:me,Vector:de,_Enum:Ls,_void:w,bitSequence:As,blockHeader:qs,bool:Tr,char:_s,compact:q,compactBn:vn,compactNumber:v,createCodec:k,createDecoder:Ie,decAnyMetadata:po,enhanceCodec:M,enhanceDecoder:ct,enhanceEncoder:ot,ethAccount:Cn,extrinsicFormat:go,fixedStr:Us,fromBufferToBase58:ln,getMultisigAccountId:Bo,getSs58AddressInfo:an,h64:he,i128:Or,i16:Br,i256:Lr,i32:kr,i64:Ar,i8:Ir,metadata:Me,selfDecoder:xn,selfEncoder:En,sortMultisigSignatories:rr,str:I,trieNodeDec:cr,u128:_r,u16:ye,u256:Ur,u32:se,u64:Pe,u8:A,unifyMetadata:yo,v14:Kn,v14Lookup:Ve,v15:Wn,v16:Xn,validateProofs:(e,t=Ze)=>{const n=e.map(ir(t)),r=Object.fromEntries(n.map(i=>[i.hash,i])),s=n.map(i=>i.hash),o=new Set(s),c=i=>{if(i.value)return;const d=e[s.indexOf(i.hash)];i.value=typeof d=="string"?d:Y(d)};return n.forEach(i=>{if("children"in i&&Object.values(i.children).forEach(d=>{const l=r[d];l&&(l.parent=i.hash,o.delete(d))}),i.type==="BranchWithHash"||i.type==="LeafWithHash"){const d=i.value,l=r[d];if(!l)return;o.delete(d),l.type!=="Raw"&&(Object.keys(l).forEach(a=>delete l[a]),l.type="Raw",l.hash=d),l.parent=i.hash,c(l)}i.type==="Raw"&&c(i)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const Uo=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let d=e(r,s,o,...c);return o.delete(i),s.has(i)&&(d=n(d,s.get(i),r,...c)),s.set(i,d),d},Lo=De(),ar=Uo((e,t,n,r)=>{if(e.type==="primitive")return Oo[e.value];if(e.type==="void")return w;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Cn;if(e.type==="compact")return e.isBig?vn:v;if(e.type==="bitSequence")return Qe(e.isLSB);const s=u=>ar(u,t,n,r),o=(u,p)=>{const y=s(u);return p?de(y,p):de(y)},c=u=>He(...u.map(s)),i=u=>{const p=Object.fromEntries(Object.entries(u).map(([y,m])=>[y,s(m)]));return S(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Lo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?De(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return ke(s(e.value));if(e.type==="result")return Je(s(e.value.ok),s(e.value.ko));const d=Object.values(e.value).map(u=>{switch(u.type){case"void":return w;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,p)=>[u,d[p]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,p)=>u===p)?me(l):me(l,a);return e.byteLength?So(h,e.byteLength):h},In,e=>e),To=(e,t=ht())=>{const n=new Map,r=s=>ar(e(s),n,new Set,t);return s=>r(s)},So=(e,t)=>{const n=T(t);return k(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},$o=e=>{const{metadata:t}=e,n=To(e),r=(a="")=>{const f=e.storage[a];if(!f)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=f.key==null?w:n(f.key);return{key:lr(h,f.keyPrefix),value:n(f.typeId)}},s=a=>{const f=S(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:lr(f,a.selector),value:n(a.returnType.type)}},o=a=>{const f=t.spec.constructors.find(h=>h.label===a);if(!f)throw new Error(`Constructor ${a} not found`);return s(f)},c=a=>{const f=t.spec.messages.find(h=>h.label===a);if(!f)throw new Error(`Message ${a} not found`);return s(f)},i=a=>S(Object.fromEntries(a.args.map(f=>[f.label,n(f.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>me(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const f=t.spec.events,h=(p,y)=>M(p,m=>m.value,m=>({type:y,value:m}));if(a){const p=f.find(y=>y.signature_topic===a);return p?h(i(p),p.label):null}const u=f.filter(p=>p.signature_topic===a);return u.length?Do(u.map(p=>h(i(p),p.label))):null}}},lr=(e,t)=>{const n=te.fromHex(t).asBytes(),r=He(T(n.length),e);return M(r,s=>[n,s],([,s])=>s)},Do=e=>k(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),ur=e=>M(Ge(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Re=(e,t)=>M(de(e,t),n=>n??[],n=>n),dr=ke(I),tt=Re(I),Co=ur({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),hr=Re(S({name:dr,type:v,typeName:dr,docs:tt})),Ho=S({len:se,type:v}),Vo=S({bitStoreType:v,bitOrderType:v}),Mo=Re(S({name:I,fields:hr,index:A,docs:tt})),No=ur({composite:S({fields:hr}),variant:S({variants:Mo}),sequence:S({type:v}),array:Ho,tuple:de(v),primitive:Co,compact:S({type:v}),bitSequence:Vo}),Ro=S({name:I,type:ke(v)}),jo=Re(Ro),Po=S({id:v,path:tt,params:jo,def:No,docs:tt}),qo=M(Po,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),Fo=Re(qo),Ko=e=>{const t=Fo.enc(e.types),n=Ve.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=Wo(e,n),c=vr(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function Wo(e,t){const n={},r=(s,o=[])=>{function c(d){const l=t.length;return t[l]={id:l,docs:[],def:d,params:[],path:[]},l}if("root"in s){const d=Number(e.version)===4?te.fromBytes(te.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(f,h){const u=e.types[f].type,p="composite"in u.def?new Map((u.def.composite.fields??[]).map(m=>[m.name,m.type])):null,y=new Map((u.params??[]).map(m=>[m.name,m.type]));if(y.size===2&&y.has("V")&&p&&p.size===2&&p.has("len")&&p.has("elements")){a(p.get("len"),[...h,"len"]),a(p.get("elements"),h);return}else y.size===3&&y.has("K")&&y.has("V")?n[h.join(".")]={keyPrefix:d,key:y.get("K"),typeId:y.get("V")}:y.size===2&&y.has("V")&&(n[h.join(".")]={keyPrefix:d,key:null,typeId:y.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:d,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const d=r(s.array.layout,o);return d==null?null:c({tag:"array",value:{len:s.array.len,type:d}})}if("struct"in s){const d=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:d})}const i=Object.values(s.enum.variants).map((d,l)=>({name:d.name,fields:d.fields.map(a=>({name:a.name,type:r(a.layout,[...o,d.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const Xo=e=>{if(!e.metadata)throw new Error("Ink client needs the contract metadata");const t=Ko(e.metadata),n=$o(t),r=yr(n.buildConstructor),s=yr(n.buildMessage),o=l=>{const a=t.metadata.spec.constructors.find(f=>f.label===l);if(!a)throw new Error(`Constructor ${l} not found`);return a},c=l=>{const a=t.metadata.spec.messages.find(f=>f.label===l);if(!a)throw new Error(`Message ${l} not found`);return a},i=t.metadata.spec.constructors.find(l=>l.default)?.label,d=t.metadata.spec.messages.find(l=>l.default)?.label;return{constructor:l=>({attributes:pr(o(l)),...r(l)}),defaultConstructor:i,message:l=>({attributes:pr(c(l)),...s(l)}),defaultMessage:d,storage:Yo(n.buildStorage),event:Number(t.metadata.version)===4?Go(n.buildEvents):Jo(t,n.buildEvent)}},fr=new WeakMap,zo=e=>{const t=fr.get(e);if(t)return t;const n=Xo(e);return fr.set(e,n),n},pr=e=>({payable:e.payable,default:e.default,mutates:"mutates"in e?e.mutates:!0}),yr=e=>t=>{const n=e(t);return{encode:r=>te.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},Yo=e=>t=>{const n=e(t);return{encode:r=>te.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},Go=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},Jo=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>{const d=a=>(typeof a=="string"?a:a.asHex())===c;return i.map(a=>"event"in a?a:{event:a,topics:a.topics}).filter(a=>(a.event.type==="Contracts"||a.event.type==="Revive")&&a.event.value.type==="ContractEmitted"&&d(a.event.value.value.contract)).map(a=>{const h=[...a.topics,...a.event.value?.value?.topics??[]].map(u=>u.asHex()).find(u=>n.has(u));try{return s(a.event.value.value,h)}catch{return null}}).filter(a=>a!==null)}}};_e.getInkClient=zo}));
@@ -1 +1 @@
1
- (function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,(function(_){"use strict";const E=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.parse(d))});return d=>(c=d,{send(f){s(JSON.stringify(f))},disconnect(){c=null,n()}})},z=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.stringify(d))});return d=>(c=d,{send(f){s(JSON.parse(f))},disconnect(){c=null,n()}})},g=(...u)=>c=>z(u.reduce((s,n)=>n(s),E(c))),k={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},y={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:k,chainSpec:O,transaction:y}).forEach(([u,c])=>{Object.keys(c).forEach(s=>{c[s]=`${u}_v1_${s}`})});var L=Object.freeze({__proto__:null,chainHead:k,chainSpec:O,transaction:y});const Q=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{switch(f.method){case O.chainName:return s({...f,method:"system_chain"});case O.genesisHash:return s({...f,method:"chain_getBlockHash",params:[0]});case O.properties:return s({...f,method:"system_properties"})}s(f)},disconnect:n}},R=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="newBlock"){const{parentBlockHash:p}=t;if(!e.has(p)){const H=i.get(p)??[];H.push(a),i.set(p,H);return}const b=t.blockHash;e.add(t.blockHash),c(a);const w=i.get(b);w&&(i.delete(b),w.forEach(H=>{e.add(H.params.result.blockHash),c(H)}));return}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case k.follow:s.add(a.id);break;case k.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case k.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},M=u=>({jsonrpc:"2.0",...u}),N=(u,c,s,n={})=>M({method:"chainHead_v1_followEvent",params:{subscription:u,result:{event:c,operationId:s,...n}}}),Z="__INNER_RQ_DesV",X=u=>{let c=0;const s=new Map,n=({id:h,error:a,result:o})=>{const e=s.get(h);return e&&(s.delete(h),a?e(!1,a):e(!0,o)),!e};let d=()=>{};return[h=>{const{send:a,disconnect:o}=u(e=>{n(e)&&h(e)});return d=a,{send:d,disconnect:()=>{s.clear(),o()}}},(h,a,o,e)=>{const i=Z+c++;s.set(i,(t,l)=>{(t?o:e)(l)}),d(M({id:i,method:h,params:a}))}]},Y="__INNER_OP_DesV";let ee=0;const V=u=>c=>{const[s,n]=X(u),d=te(n),f=new Map,r=new Map,{send:h,disconnect:a}=s(i=>{if("id"in i){const t=f.get(i.id);t&&(f.delete(i.id),i.result.result==="started"&&t(i.result.operationId))}else if(i.params){const{subscription:t,result:l}=i.params,{operationId:p}=l||{},b=r.get(t);b&&l.event==="stop"&&(b.forEach(H=>{H.cancel()}),r.delete(t));const w=b?.get(p);if(w)switch(l.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)b.delete(p);else{w.isOutterDone=!0;return}}}c(i)}),o=(i,t,l)=>p=>{let b=()=>{};r.has(i)||r.set(i,new Map);const w=r.get(i),H={isOutterDone:!1,isInnerDone:!1,cancel:()=>{b()}};w.set(p,H);let I=0;const B=l.map(S=>d(S,t,v=>{c(N(i,"operationStorageItems",p,{items:v.map(([C,D])=>({key:C,value:D}))}))},v=>{b(),H.isOutterDone||h(M({method:"chainHead_v1_stopOperation",params:[p]})),c(N(i,"operationError",p,{error:typeof v=="string"?v:JSON.stringify(v)}))},()=>{++I===l.length&&(H.isOutterDone?(b(),c(N(i,"operationStorageDone",p))):H.isInnerDone=!0)}));b=()=>{w.delete(p),B.forEach(S=>S())}};return{send:i=>{switch(i.method){case k.storage:{const[t,l,p]=i.params,b=[],w=p.filter(I=>{const B=I.type==="descendantsValues";return B&&b.push(I.key),!B}),H=o(t,l,b);if(w.length)b.length&&f.set(i.id,H);else{const I=Y+ee++;c(M({id:i.id,result:{result:"started",operationId:I}})),H(I),r.get(t).get(I).isOutterDone=!0;return}i.params[2]=w;break}case k.stopOperation:{const[t,l]=i.params,p=r.get(t)?.get(l);if(p&&(p.cancel(),p.isOutterDone))return;break}case k.unfollow:{const[t]=i.params;r.get(t)?.forEach(l=>l.cancel()),r.delete(t);break}}h(i)},disconnect:a}},te=u=>(c,s,n,d,f)=>{let r=!0,h=!1,a=0;const o=t=>{r&&(r=!1,d(t))},e=1e3,i=t=>{u("state_getKeysPaged",[c,e,t||void 0,s],l=>{r&&(l.length>0&&(a++,u("state_queryStorageAt",[l,s],([{changes:p}])=>{r&&(a--,n(p),h&&!a&&f())},o)),l.length<e?(h=!0,a||f()):i(l.at(-1)))},o)};return i(),()=>{r=!1}},$=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="finalized"&&(t.prunedBlockHashes=t.prunedBlockHashes.filter(p=>e.has(p))),l==="newBlock"){e.add(t.blockHash);const p=t.blockHash,b=i.get(p);if(b){i.delete(p),c(a),Promise.resolve().then(()=>{c(b)});return}}if(l==="bestBlockChanged"){const p=t.bestBlockHash;if(!e.has(p)){d.get(o).set(p,a);return}}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case k.follow:s.add(a.id);break;case k.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case k.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},ne=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(u=>"operation"+u)),j=u=>ne.has(u.params?.result?.event),T=u=>c=>{const s=new Set,n=new Map,d=new Map,f=new Map,{send:r,disconnect:h}=u(o=>{if("id"in o){c(o);const{id:e,result:i}=o;if(s.has(e)){s.delete(e),d.set(i,new Set),f.set(i,new Map);return}const t=n.get(e);if(t!==void 0){n.delete(e);const l=o.result?.operationId;if(l!==void 0&&d.has(t)){const p=d.get(t);p.add(l);const b=f.get(t)?.get(l);b&&(b.forEach(c),f.get(t).delete(l),j(b.at(-1))&&p.delete(l))}}}else{const{subscription:e,result:i}=o.params,t=d.get(e);if(t){const{operationId:l}=o.params.result;if(l!==void 0)if(t.has(l))j(o)&&t.delete(l);else{const p=f.get(e),b=p.get(l)??[];b.push(o),p.set(l,b);return}else i?.event==="stop"&&(d.delete(e),f.delete(e))}c(o)}});return{send:o=>{const e=o.params[0];switch(o.method){case k.follow:s.add(o.id);break;case k.body:case k.call:case k.storage:n.set(o.id,e);break;case k.unfollow:d.delete(e),f.delete(e);break;case k.stopOperation:d.get(e)?.delete(o.params[1])}r(o)},disconnect:h}},A=u=>c=>{const s=new Set,n=new Map,{send:d,disconnect:f}=u(r=>{if("id"in r){const{id:h,result:a}=r;s.has(h)&&(s.delete(h),n.set(a,()=>{n.delete(a)}))}else{const{subscription:h}=r.params,a=n.get(h);if(a){const o=r.params.result,{event:e}=o;if(e==="initialized"){const i=setTimeout(()=>{n.delete(h),c({event:"bestBlockChanged",bestBlockHash:o.finalizedBlockHashes.at(-1)})},500);n.set(h,()=>{n.delete(h),clearTimeout(i)})}else a()}}c(r)});return{send(r){switch(r.method){case k.follow:s.add(r.id);break;case k.unfollow:n.get(r.params[0])?.()}d(r)},disconnect:f}},G=u=>c=>u(s=>{const n=s.params?.result;if(!("id"in s)&&n){const{prunedBlockHashes:d,finalizedBlockHash:f,event:r}=n;r==="finalized"&&Array.isArray(d)?n.prunedBlockHashes=[...new Set(n.prunedBlockHashes)]:r==="initialized"&&f&&(n.finalizedBlockHashes=[n.finalizedBlockHash],delete n.finalizedBlockHash)}c(s)}),m=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{const{method:r,params:h,id:a,...o}=f;r==k.unpin&&h&&Array.isArray(h[1])?h[1].forEach((e,i)=>{s({...o,id:i===0?a:`${a}-patched-${i}`,method:r,params:[h[0],e]})}):s(f)},disconnect:n}},q=u=>({jsonrpc:"2.0",...u}),[P]=y.stop.split("_"),x="unstable",J="rpc_methods",K="__INTERNAL_ID",U=u=>c=>{let s=!0,n=[],d=t=>{n.push(t)};const f=({id:t,result:l,error:p})=>{if(t!==K||!s)return;if(!l){if(console.error(p),e<4){setTimeout(i,200);return}l={methods:[]}}const b=new Set(l.methods),w={};[k,O,y].forEach(B=>{Object.values(B).forEach(S=>{if(b.has(S))w[S]=S;else{const[v,,C]=S.split("_"),D=`${v}_${x}_${C}`;if(b.has(D))w[S]=D,b.delete(D),b.add(S);else if(w[S]=null,v===P){let W;const oe=S==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ie=>["v1",x].find(ae=>b.has(W=`${ie}_${ae}_${oe}`)))&&(w[S]=W,b.add(S))}}})}),r=c;const H=({method:B,...S})=>{if(B===J){Promise.resolve().then(()=>{c(q({id:S.id,result:{methods:[...b]}}))});return}const v=w[B];v===null?B.split("_")[2]==="follow"?(o(),d({method:B,...S})):Promise.resolve().then(()=>{c({error:{code:-32603,message:`Method not found: ${B}`},id:S.id})}):h({method:v||B,...S})},I=[...n];n=[];for(let B=0;s&&B<I.length;B++)H(I[B]);s&&(d=H)};let r=f;const{send:h,disconnect:a}=u(t=>{r(t)}),o=()=>{s=!0,n=[],d=t=>{n.push(t)},r=f,i()};let e=0;const i=()=>{e++,h(q({id:K,method:J,params:[]}))};return i(),{send:t=>{d(t)},disconnect(){s=!1,d=r=()=>{},n=[],a()}}},F=u=>c=>{let s=0;const n=new Map,{send:d,disconnect:f}=u(r=>{const{id:h}=r;n.has(h)&&(r.id=n.get(h),n.delete(h)),c(r)});return{send:r=>{"id"in r&&(n.set(s,r.id),r.id=s++),d(r)},disconnect:f}},se=g(F,U,T,m,G,R,$,A,Q,V);_.fixDescendantValues=V,_.fixMissingInitialBest=A,_.fixPrematureBlocks=R,_.fixUnorderedBlocks=$,_.fixUnorderedEvents=T,_.fromParsed=z,_.methods=L,_.parsed=g,_.patchChainHeadEvents=G,_.toParsed=E,_.translate=U,_.unpinHash=m,_.withNumericIds=F,_.withPolkadotSdkCompat=se}));
1
+ (function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,(function(_){"use strict";const E=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.parse(d))});return d=>(c=d,{send(f){s(JSON.stringify(f))},disconnect(){c=null,n()}})},g=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.stringify(d))});return d=>(c=d,{send(f){s(JSON.parse(f))},disconnect(){c=null,n()}})},z=(...u)=>c=>g(u.reduce((s,n)=>n(s),E(c))),b={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},y={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:b,chainSpec:O,transaction:y}).forEach(([u,c])=>{Object.keys(c).forEach(s=>{c[s]=`${u}_v1_${s}`})});var L=Object.freeze({__proto__:null,chainHead:b,chainSpec:O,transaction:y});const Q=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{switch(f.method){case O.chainName:return s({...f,method:"system_chain"});case O.genesisHash:return s({...f,method:"chain_getBlockHash",params:[0]});case O.properties:return s({...f,method:"system_properties"})}s(f)},disconnect:n}},R=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="newBlock"){const{parentBlockHash:p}=t;if(!e.has(p)){const H=i.get(p)??[];H.push(a),i.set(p,H);return}const k=t.blockHash;e.add(t.blockHash),c(a);const w=i.get(k);w&&(i.delete(k),w.forEach(H=>{e.add(H.params.result.blockHash),c(H)}));return}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case b.follow:s.add(a.id);break;case b.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case b.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},M=u=>({jsonrpc:"2.0",...u}),N=(u,c,s,n={})=>M({method:"chainHead_v1_followEvent",params:{subscription:u,result:{event:c,operationId:s,...n}}}),Z="__INNER_RQ_DesV",X=u=>{let c=0;const s=new Map,n=({id:h,error:a,result:o})=>{const e=s.get(h);return e&&(s.delete(h),a?e(!1,a):e(!0,o)),!e};let d=()=>{};return[h=>{const{send:a,disconnect:o}=u(e=>{n(e)&&h(e)});return d=a,{send:d,disconnect:()=>{s.clear(),o()}}},(h,a,o,e)=>{const i=Z+c++;s.set(i,(t,l)=>{(t?o:e)(l)}),d(M({id:i,method:h,params:a}))}]},Y="__INNER_OP_DesV";let ee=0;const V=u=>c=>{const[s,n]=X(u),d=te(n),f=new Map,r=new Map,{send:h,disconnect:a}=s(i=>{if("id"in i){const t=f.get(i.id);t&&(f.delete(i.id),i.result.result==="started"&&t(i.result.operationId))}else if(i.params){const{subscription:t,result:l}=i.params,{operationId:p}=l||{},k=r.get(t);k&&l.event==="stop"&&(k.forEach(H=>{H.cancel()}),r.delete(t));const w=k?.get(p);if(w)switch(l.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)k.delete(p);else{w.isOutterDone=!0;return}}}c(i)}),o=(i,t,l)=>p=>{let k=()=>{};r.has(i)||r.set(i,new Map);const w=r.get(i),H={isOutterDone:!1,isInnerDone:!1,cancel:()=>{k()}};w.set(p,H);let v=0;const B=l.map(S=>d(S,t,I=>{c(N(i,"operationStorageItems",p,{items:I.map(([C,D])=>({key:C,value:D}))}))},I=>{k(),H.isOutterDone||h(M({method:"chainHead_v1_stopOperation",params:[p]})),c(N(i,"operationError",p,{error:typeof I=="string"?I:JSON.stringify(I)}))},()=>{++v===l.length&&(H.isOutterDone?(k(),c(N(i,"operationStorageDone",p))):H.isInnerDone=!0)}));k=()=>{w.delete(p),B.forEach(S=>S())}};return{send:i=>{switch(i.method){case b.storage:{const[t,l,p]=i.params,k=[],w=p.filter(v=>{const B=v.type==="descendantsValues";return B&&k.push(v.key),!B}),H=o(t,l,k);if(w.length)k.length&&f.set(i.id,H);else{const v=Y+ee++;c(M({id:i.id,result:{result:"started",operationId:v}})),H(v),r.get(t).get(v).isOutterDone=!0;return}i.params[2]=w;break}case b.stopOperation:{const[t,l]=i.params,p=r.get(t)?.get(l);if(p&&(p.cancel(),p.isOutterDone))return;break}case b.unfollow:{const[t]=i.params;r.get(t)?.forEach(l=>l.cancel()),r.delete(t);break}}h(i)},disconnect:a}},te=u=>(c,s,n,d,f)=>{let r=!0,h=!1,a=0;const o=t=>{r&&(r=!1,d(t))},e=1e3,i=t=>{u("state_getKeysPaged",[c,e,t||void 0,s],l=>{r&&(l.length>0&&(a++,u("state_queryStorageAt",[l,s],([{changes:p}])=>{r&&(a--,n(p),h&&!a&&f())},o)),l.length<e?(h=!0,a||f()):i(l.at(-1)))},o)};return i(),()=>{r=!1}},$=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="finalized"&&(t.prunedBlockHashes=t.prunedBlockHashes.filter(p=>e.has(p))),l==="newBlock"){e.add(t.blockHash);const p=t.blockHash,k=i.get(p);if(k){i.delete(p),c(a),Promise.resolve().then(()=>{c(k)});return}}if(l==="bestBlockChanged"){const p=t.bestBlockHash;if(!e.has(p)){d.get(o).set(p,a);return}}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case b.follow:s.add(a.id);break;case b.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case b.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},ne=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(u=>"operation"+u)),j=u=>ne.has(u.params?.result?.event),T=u=>c=>{const s=new Set,n=new Map,d=new Map,f=new Map,{send:r,disconnect:h}=u(o=>{if("id"in o){c(o);const{id:e,result:i}=o;if(s.has(e)){s.delete(e),d.set(i,new Set),f.set(i,new Map);return}const t=n.get(e);if(t!==void 0){n.delete(e);const l=o.result?.operationId;if(l!==void 0&&d.has(t)){const p=d.get(t);p.add(l);const k=f.get(t)?.get(l);k&&(k.forEach(c),f.get(t).delete(l),j(k.at(-1))&&p.delete(l))}}}else{const{subscription:e,result:i}=o.params,t=d.get(e);if(t){const{operationId:l}=o.params.result;if(l!==void 0)if(t.has(l))j(o)&&t.delete(l);else{const p=f.get(e),k=p.get(l)??[];k.push(o),p.set(l,k);return}else i?.event==="stop"&&(d.delete(e),f.delete(e))}c(o)}});return{send:o=>{const e=o.params[0];switch(o.method){case b.follow:s.add(o.id);break;case b.body:case b.call:case b.storage:n.set(o.id,e);break;case b.unfollow:d.delete(e),f.delete(e);break;case b.stopOperation:d.get(e)?.delete(o.params[1])}r(o)},disconnect:h}},se=new Set(["newBlock","bestBlockChanged","stop"]),A=u=>c=>{const s=new Set,n=new Map,{send:d,disconnect:f}=u(r=>{if("id"in r){const{id:h,result:a}=r;s.has(h)&&(s.delete(h),n.set(a,()=>{n.delete(a)}))}else{const{subscription:h}=r.params,a=n.get(h);if(a){const o=r.params.result,{event:e}=o;if(e==="initialized"){const i=setTimeout(()=>{n.delete(h),c(N(h,"bestBlockChanged",void 0,{bestBlockHash:o.finalizedBlockHashes.at(-1)}))},500);n.set(h,()=>{n.delete(h),clearTimeout(i)})}else se.has(e)&&a()}}c(r)});return{send(r){switch(r.method){case b.follow:s.add(r.id);break;case b.unfollow:n.get(r.params[0])?.()}d(r)},disconnect:f}},G=u=>c=>u(s=>{const n=s.params?.result;if(!("id"in s)&&n){const{prunedBlockHashes:d,finalizedBlockHash:f,event:r}=n;r==="finalized"&&Array.isArray(d)?n.prunedBlockHashes=[...new Set(n.prunedBlockHashes)]:r==="initialized"&&f&&(n.finalizedBlockHashes=[n.finalizedBlockHash],delete n.finalizedBlockHash)}c(s)}),m=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{const{method:r,params:h,id:a,...o}=f;r==b.unpin&&h&&Array.isArray(h[1])?h[1].forEach((e,i)=>{s({...o,id:i===0?a:`${a}-patched-${i}`,method:r,params:[h[0],e]})}):s(f)},disconnect:n}},q=u=>({jsonrpc:"2.0",...u}),[P]=y.stop.split("_"),x="unstable",J="rpc_methods",K="__INTERNAL_ID",U=u=>c=>{let s=!0,n=[],d=t=>{n.push(t)};const f=({id:t,result:l,error:p})=>{if(t!==K||!s)return;if(!l){if(console.error(p),e<4){setTimeout(i,200);return}l={methods:[]}}const k=new Set(l.methods),w={};[b,O,y].forEach(B=>{Object.values(B).forEach(S=>{if(k.has(S))w[S]=S;else{const[I,,C]=S.split("_"),D=`${I}_${x}_${C}`;if(k.has(D))w[S]=D,k.delete(D),k.add(S);else if(w[S]=null,I===P){let W;const ie=S==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ae=>["v1",x].find(ce=>k.has(W=`${ae}_${ce}_${ie}`)))&&(w[S]=W,k.add(S))}}})}),r=c;const H=({method:B,...S})=>{if(B===J){Promise.resolve().then(()=>{c(q({id:S.id,result:{methods:[...k]}}))});return}const I=w[B];I===null?B.split("_")[2]==="follow"?(o(),d({method:B,...S})):Promise.resolve().then(()=>{c({error:{code:-32603,message:`Method not found: ${B}`},id:S.id})}):h({method:I||B,...S})},v=[...n];n=[];for(let B=0;s&&B<v.length;B++)H(v[B]);s&&(d=H)};let r=f;const{send:h,disconnect:a}=u(t=>{r(t)}),o=()=>{s=!0,n=[],d=t=>{n.push(t)},r=f,i()};let e=0;const i=()=>{e++,h(q({id:K,method:J,params:[]}))};return i(),{send:t=>{d(t)},disconnect(){s=!1,d=r=()=>{},n=[],a()}}},F=u=>c=>{let s=0;const n=new Map,{send:d,disconnect:f}=u(r=>{const{id:h}=r;n.has(h)&&(r.id=n.get(h),n.delete(h)),c(r)});return{send:r=>{"id"in r&&(n.set(s,r.id),r.id=s++),d(r)},disconnect:f}},oe=z(F,U,T,m,G,R,$,A,Q,V);_.fixDescendantValues=V,_.fixMissingInitialBest=A,_.fixPrematureBlocks=R,_.fixUnorderedBlocks=$,_.fixUnorderedEvents=T,_.fromParsed=g,_.methods=L,_.parsed=z,_.patchChainHeadEvents=G,_.toParsed=E,_.translate=U,_.unpinHash=m,_.withNumericIds=F,_.withPolkadotSdkCompat=oe}));
@@ -1 +1 @@
1
- (function(Le,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports):typeof define=="function"&&define.amd?define(["exports"],Ce):(Le=typeof globalThis<"u"?globalThis:Le||self,Ce(Le.papiSigner={}))})(this,(function(Le){"use strict";const Ce="0123456789abcdef";function re(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const s=e[n++];t[n]=Ce[s>>4]+Ce[s&15]}return t.join("")}const yt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function He(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|yt[e[2]]);for(let o=0;o<s;){const c=n+o*2,i=yt[e[c]],l=yt[e[c+1]];r[t+o++]=i<<4|l}return r}function gt(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s,n)]))}const N=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((r,o)=>r+o.byteLength,0),s=new Uint8Array(n);for(let r=0,o=0;r<t.length;r++){const c=t[r];s.set(c,o),o+=c.byteLength}return s};var Gr=Object.defineProperty,Jr=(e,t,n)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kt=(e,t,n)=>(Jr(e,typeof t!="symbol"?t+"":t,n),n),vt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Qr(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|vt[e[2]]);for(let o=0;o<s;){const c=n+o*2,i=vt[e[c]],l=vt[e[c+1]];r[t+o++]=i<<4|l}return r}var Xt=class extends Uint8Array{constructor(e){super(e),Kt(this,"i",0),Kt(this,"v"),this.v=new DataView(e)}},Q=e=>t=>e(t instanceof Xt?t:new Xt(t instanceof Uint8Array?t.buffer:typeof t=="string"?Qr(t).buffer:t)),se=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].length;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const c=e[r];s.set(c,o),o+=c.byteLength}return s};function tt(e,t){const n=Object.keys(e),s=n.length,r={};for(let o=0;o<s;o++){const c=n[o];r[c]=t(e[c],c)}return r}var Be=Q,_=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),wt=(e,t)=>n=>t(e(n)),oe=([e,t],n,s)=>_(mt(e,n),wt(t,s));function Zr(e,t){return Q(n=>{const s=n.v[t](n.i,!0);return n.i+=e,s})}function es(e,t){return n=>{const s=new Uint8Array(e);return new DataView(s.buffer)[t](0,n,!0),s}}function ge(e,t,n){return _(es(e,n),Zr(e,t))}var A=ge(1,"getUint8","setUint8"),ie=ge(2,"getUint16","setUint16"),Z=ge(4,"getUint32","setUint32"),Re=ge(8,"getBigUint64","setBigUint64"),zt=ge(1,"getInt8","setInt8"),Yt=ge(2,"getInt16","setInt16"),Gt=ge(4,"getInt32","setInt32"),Jt=ge(8,"getBigInt64","setBigInt64"),Qt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Zt=e=>Q(t=>{const{v:n,i:s}=t,r=n.getBigUint64(s,!0),o=n[e](s+8,!0);return t.i+=16,o<<64n|r}),en=_(Qt,Zt("getBigUint64")),tn=_(Qt,Zt("getBigInt64")),nn=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},rn=e=>Q(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),sn=_(nn,rn("getBigUint64")),on=_(nn,rn("getBigInt64")),cn=oe(A,e=>e?1:0,Boolean),ts=[A[1],ie[1],Z[1]],ns=Q(e=>{const t=e[e.i],n=t&3;if(n<3)return ts[n](e)>>>2;const s=(t>>>2)+4;e.i++;let r=0n;const o=s/8|0;let c=0n;for(let l=0;l<o;l++)r=Re[1](e)<<c|r,c+=64n;let i=s%8;return i>3&&(r=BigInt(Z[1](e))<<c|r,c+=32n,i-=4),i>1&&(r=BigInt(ie[1](e))<<c|r,c+=16n,i-=2),i&&(r=BigInt(A[1](e))<<c|r),r}),rs=1n<<56n,ss=1<<24,os=256,cs=4294967295n,is=64,as=16384,ls=1<<30,us=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<is)return A[0](t);if(e<as)return ie[0](t|1);if(e<ls)return Z[0](t|2);let n=[new Uint8Array(1)],s=BigInt(e);for(;s>=rs;)n.push(Re[0](s)),s>>=64n;s>=ss&&(n.push(Z[0](Number(s&cs))),s>>=32n);let r=Number(s);r>=os&&(n.push(ie[0](r)),r>>=16),r&&n.push(A[0](r));const o=se(n);return o[0]=o.length-5<<2|3,o},D=_(us,ns),hs=new TextEncoder,ds=e=>{const t=hs.encode(e);return se([D.enc(t.length),t])},fs=new TextDecoder,ps=Q(e=>{let t=D.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,fs.decode(n)}),k=_(ds,ps),ys=()=>{},gs=new Uint8Array(0),v=_(()=>gs,ys),an=e=>e===void 0?t=>se([D.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ln=e=>Q(t=>{const n=e===void 0?D.dec(t):e!==1/0?e:t.byteLength-t.i,s=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,s}),C=e=>_(an(e),ln(e));C.enc=an,C.dec=ln;var un=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),r=o=>s.get(o);return({tag:o,value:c})=>se([A.enc(r(o)),e[o](c)])},hn=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((r,o)=>[r,n[o]])??n.map((r,o)=>[o,r]));return Q(r=>{const o=A.dec(r),c=s.get(o),i=e[c];return{tag:c,value:i(r)}})},K=(e,...t)=>_(un(tt(e,([n])=>n),...t),hn(tt(e,([,n])=>n),...t));K.enc=un,K.dec=hn;var dn=e=>Q(t=>A[1](t)>0?e(t):void 0),fn=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,se([n,e(t)]))},X=e=>_(fn(e[0]),dn(e[1]));X.enc=fn,X.dec=dn;var pn=(e,t)=>Q(n=>{const s=A[1](n)===0,o=(s?e:t)(n);return{success:s,value:o}}),yn=(e,t)=>({success:n,value:s})=>se([A[0](n?0:1),(n?e:t)(s)]),Fe=(e,t)=>_(yn(e[0],t[0]),pn(e[1],t[1]));Fe.dec=pn,Fe.enc=yn;var gn=(...e)=>Q(t=>e.map(n=>n(t))),vn=(...e)=>t=>se(e.map((n,s)=>n(t[s]))),ee=(...e)=>_(vn(...e.map(([t])=>t)),gn(...e.map(([,t])=>t)));ee.enc=vn,ee.dec=gn;var mn=e=>{const t=Object.keys(e);return mt(ee.enc(...Object.values(e)),n=>t.map(s=>n[s]))},wn=e=>{const t=Object.keys(e);return wt(ee.dec(...Object.values(e)),n=>Object.fromEntries(n.map((s,r)=>[t[r],s])))},b=e=>_(mn(tt(e,t=>t[0])),wn(tt(e,t=>t[1])));b.enc=mn,b.dec=wn;var bn=(e,t)=>t>=0?n=>se(n.map(e)):n=>se([D.enc(n.length),se(n.map(e))]),xn=(e,t)=>Q(n=>{const s=t>=0?t:D.dec(n),r=new Array(s);for(let o=0;o<s;o++)r[o]=e(n);return r}),I=(e,t)=>_(bn(e[0],t),xn(e[1],t));I.enc=bn,I.dec=xn;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function En(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function bt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function In(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function xt(e){if(!Array.isArray(e))throw new Error("array expected")}function kn(e,t){if(!En(!0,t))throw new Error(`${e}: array of strings expected`)}function ms(e,t){if(!En(!1,t))throw new Error(`${e}: array of numbers expected`)}function ws(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),s=e.map(o=>o.encode).reduceRight(n,t),r=e.map(o=>o.decode).reduce(n,t);return{encode:s,decode:r}}function bs(e){const t=typeof e=="string"?e.split(""):e,n=t.length;kn("alphabet",t);const s=new Map(t.map((r,o)=>[r,o]));return{encode:r=>(xt(r),r.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:r=>(xt(r),r.map(o=>{bt("alphabet.decode",o);const c=s.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return c}))}}function xs(e=""){return bt("join",e),{encode:t=>(kn("join.decode",t),t.join(e)),decode:t=>(bt("join.decode",t),t.split(e))}}function Bn(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(xt(e),!e.length)return[];let s=0;const r=[],o=Array.from(e,i=>{if(In(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=o.length;for(;;){let i=0,l=!0;for(let a=s;a<c;a++){const d=o[a],y=t*i,u=y+d;if(!Number.isSafeInteger(u)||y/t!==i||u-d!==y)throw new Error("convertRadix: carry overflow");const h=u/n;i=u%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+i!==u)throw new Error("convertRadix: carry overflow");if(l)p?l=!1:s=a;else continue}if(r.push(i),l)break}for(let i=0;i<e.length-1&&e[i]===0;i++)r.push(0);return r.reverse()}function Es(e){In(e);const t=2**8;return{encode:n=>{if(!vs(n))throw new Error("radix.encode input should be Uint8Array");return Bn(Array.from(n),t,e)},decode:n=>(ms("radix.decode",n),Uint8Array.from(Bn(n,e,t)))}}const An=(e=>ws(Es(58),bs(e),xs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Is(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Me(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function te(e,t,n=""){const s=Is(e),r=e?.length,o=t!==void 0;if(!s||o&&r!==t){const c=n&&`"${n}" `,i=o?` of length ${t}`:"",l=s?`length=${r}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+i+", got "+l)}return e}function qe(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 Et(e,t){te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function ks(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ae(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ve(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function nt(e,t){return e<<32-t|e>>>t}const Un=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function On(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ae=Un?e=>e:e=>On(e);function Bs(e){for(let t=0;t<e.length;t++)e[t]=On(e[t]);return e}const q=Un?e=>e:Bs;function It(e,t={}){const n=(r,o)=>e(o).update(r).digest(),s=e(void 0);return n.outputLen=s.outputLen,n.blockLen=s.blockLen,n.create=r=>e(r),Object.assign(n,t),Object.freeze(n)}const As=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function me(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,16),n=n+s|0,t=nt(t^n,12),{a:e,b:t,c:n,d:s}}function we(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,8),n=n+s|0,t=nt(t^n,7),{a:e,b:t,c:n,d:s}}const Us=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=BigInt(2**32-1),_n=BigInt(32);function st(e,t=!1){return t?{h:Number(e&rt),l:Number(e>>_n&rt)}:{h:Number(e>>_n&rt)|0,l:Number(e&rt)|0}}function Os(e,t=!1){const n=e.length;let s=new Uint32Array(n),r=new Uint32Array(n);for(let o=0;o<n;o++){const{h:c,l:i}=st(e[o],t);[s[o],r[o]]=[c,i]}return[s,r]}const Sn=(e,t,n)=>e>>>n|t<<32-n,Tn=(e,t,n)=>e<<32-n|t>>>n,_s=(e,t,n)=>e<<64-n|t>>>n-32,Ss=(e,t,n)=>e>>>n-32|t<<64-n,Ts=(e,t)=>t,Ds=(e,t)=>e,Ls=(e,t,n)=>e<<n|t>>>32-n,Cs=(e,t,n)=>t<<n|e>>>32-n,Hs=(e,t,n)=>t<<n-32|e>>>64-n,Ms=(e,t,n)=>e<<n-32|t>>>64-n;function Dn(e,t,n,s){const r=(t>>>0)+(s>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Ln=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Cn=(e,t,n,s)=>t+n+s+(e/2**32|0)|0,H=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function be(e,t,n,s,r,o){const c=r[o],i=r[o+1];let l=g[2*e],a=g[2*e+1],d=g[2*t],y=g[2*t+1],u=g[2*n],h=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Ln(l,d,c);a=Cn(m,a,y,i),l=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^l},{Dh:f,Dl:p}={Dh:Ts(f,p),Dl:Ds(f)},{h,l:u}=Dn(h,u,f,p),{Bh:y,Bl:d}={Bh:y^h,Bl:d^u},{Bh:y,Bl:d}={Bh:Sn(y,d,24),Bl:Tn(y,d,24)},g[2*e]=l,g[2*e+1]=a,g[2*t]=d,g[2*t+1]=y,g[2*n]=u,g[2*n+1]=h,g[2*s]=p,g[2*s+1]=f}function xe(e,t,n,s,r,o){const c=r[o],i=r[o+1];let l=g[2*e],a=g[2*e+1],d=g[2*t],y=g[2*t+1],u=g[2*n],h=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Ln(l,d,c);a=Cn(m,a,y,i),l=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^l},{Dh:f,Dl:p}={Dh:Sn(f,p,16),Dl:Tn(f,p,16)},{h,l:u}=Dn(h,u,f,p),{Bh:y,Bl:d}={Bh:y^h,Bl:d^u},{Bh:y,Bl:d}={Bh:_s(y,d,63),Bl:Ss(y,d,63)},g[2*e]=l,g[2*e+1]=a,g[2*t]=d,g[2*t+1]=y,g[2*n]=u,g[2*n+1]=h,g[2*s]=p,g[2*s+1]=f}function Vs(e,t={},n,s,r){if(Me(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:c,personalization:i}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);c!==void 0&&te(c,s,"salt"),i!==void 0&&te(i,r,"personalization")}class Hn{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Me(t),Me(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ae(this.buffer)}update(t){qe(this),te(t);const{blockLen:n,buffer:s,buffer32:r}=this,o=t.length,c=t.byteOffset,i=t.buffer;for(let l=0;l<o;){this.pos===n&&(q(r),this.compress(r,0,!1),q(r),this.pos=0);const a=Math.min(n-this.pos,o-l),d=c+l;if(a===n&&!(d%4)&&l+a<o){const y=new Uint32Array(i,d,Math.floor((o-l)/4));q(y);for(let u=0;l+n<o;u+=r.length,l+=n)this.length+=n,this.compress(y,u,!1);q(y);continue}s.set(t.subarray(l,l+a),this.pos),this.pos+=a,this.length+=a,l+=a}return this}digestInto(t){qe(this),Et(t,this);const{pos:n,buffer32:s}=this;this.finished=!0,ve(this.buffer.subarray(n)),q(s),this.compress(s,0,!0),q(s);const r=Ae(t);this.get().forEach((o,c)=>r[c]=ae(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const s=t.slice(0,n);return this.destroy(),s}_cloneInto(t){const{buffer:n,length:s,finished:r,destroyed:o,outputLen:c,pos:i}=this;return t||=new this.constructor({dkLen:c}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=r,t.length=s,t.pos=i,t.outputLen=c,t}clone(){return this._cloneInto()}}class $s extends Hn{v0l=H[0]|0;v0h=H[1]|0;v1l=H[2]|0;v1h=H[3]|0;v2l=H[4]|0;v2h=H[5]|0;v3l=H[6]|0;v3h=H[7]|0;v4l=H[8]|0;v4h=H[9]|0;v5l=H[10]|0;v5h=H[11]|0;v6l=H[12]|0;v6h=H[13]|0;v7l=H[14]|0;v7h=H[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Vs(n,t,64,16,16);let{key:s,personalization:r,salt:o}=t,c=0;if(s!==void 0&&(te(s,void 0,"key"),c=s.length),this.v0l^=this.outputLen|c<<8|65536|1<<24,o!==void 0){te(o,void 0,"salt");const i=Ae(o);this.v4l^=ae(i[0]),this.v4h^=ae(i[1]),this.v5l^=ae(i[2]),this.v5h^=ae(i[3])}if(r!==void 0){te(r,void 0,"personalization");const i=Ae(r);this.v6l^=ae(i[0]),this.v6h^=ae(i[1]),this.v7l^=ae(i[2]),this.v7h^=ae(i[3])}if(s!==void 0){const i=new Uint8Array(this.blockLen);i.set(s),this.update(i)}}get(){let{v0l:t,v0h:n,v1l:s,v1h:r,v2l:o,v2h:c,v3l:i,v3h:l,v4l:a,v4h:d,v5l:y,v5h:u,v6l:h,v6h:p,v7l:f,v7h:m}=this;return[t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m]}set(t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m){this.v0l=t|0,this.v0h=n|0,this.v1l=s|0,this.v1h=r|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=l|0,this.v4l=a|0,this.v4h=d|0,this.v5l=y|0,this.v5h=u|0,this.v6l=h|0,this.v6h=p|0,this.v7l=f|0,this.v7h=m|0}compress(t,n,s){this.get().forEach((l,a)=>g[a]=l),g.set(H,16);let{h:r,l:o}=st(BigInt(this.length));g[24]=H[8]^o,g[25]=H[9]^r,s&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=As;for(let l=0;l<12;l++)be(0,4,8,12,t,n+2*i[c++]),xe(0,4,8,12,t,n+2*i[c++]),be(1,5,9,13,t,n+2*i[c++]),xe(1,5,9,13,t,n+2*i[c++]),be(2,6,10,14,t,n+2*i[c++]),xe(2,6,10,14,t,n+2*i[c++]),be(3,7,11,15,t,n+2*i[c++]),xe(3,7,11,15,t,n+2*i[c++]),be(0,5,10,15,t,n+2*i[c++]),xe(0,5,10,15,t,n+2*i[c++]),be(1,6,11,12,t,n+2*i[c++]),xe(1,6,11,12,t,n+2*i[c++]),be(2,7,8,13,t,n+2*i[c++]),xe(2,7,8,13,t,n+2*i[c++]),be(3,4,9,14,t,n+2*i[c++]),xe(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],ve(g)}destroy(){this.destroyed=!0,ve(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ot=It(e=>new $s(e));function Mn(e,t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m,x,B,S){let T=0;for(let J=0;J<s;J++)({a:r,b:l,c:u,d:m}=me(r,l,u,m,n[t+e[T++]])),{a:r,b:l,c:u,d:m}=we(r,l,u,m,n[t+e[T++]]),{a:o,b:a,c:h,d:x}=me(o,a,h,x,n[t+e[T++]]),{a:o,b:a,c:h,d:x}=we(o,a,h,x,n[t+e[T++]]),{a:c,b:d,c:p,d:B}=me(c,d,p,B,n[t+e[T++]]),{a:c,b:d,c:p,d:B}=we(c,d,p,B,n[t+e[T++]]),{a:i,b:y,c:f,d:S}=me(i,y,f,S,n[t+e[T++]]),{a:i,b:y,c:f,d:S}=we(i,y,f,S,n[t+e[T++]]),{a:r,b:a,c:p,d:S}=me(r,a,p,S,n[t+e[T++]]),{a:r,b:a,c:p,d:S}=we(r,a,p,S,n[t+e[T++]]),{a:o,b:d,c:f,d:m}=me(o,d,f,m,n[t+e[T++]]),{a:o,b:d,c:f,d:m}=we(o,d,f,m,n[t+e[T++]]),{a:c,b:y,c:u,d:x}=me(c,y,u,x,n[t+e[T++]]),{a:c,b:y,c:u,d:x}=we(c,y,u,x,n[t+e[T++]]),{a:i,b:l,c:h,d:B}=me(i,l,h,B,n[t+e[T++]]),{a:i,b:l,c:h,d:B}=we(i,l,h,B,n[t+e[T++]]);return{v0:r,v1:o,v2:c,v3:i,v4:l,v5:a,v6:d,v7:y,v8:u,v9:h,v10:p,v11:f,v12:m,v13:x,v14:B,v15:S}}const Vn=new TextEncoder().encode("SS58PRE"),kt=2,$n=e=>{try{const t=An.decode(e),n=t.subarray(0,t[0]&64?2:1),s=t.subarray(n.length,t.length-kt),r=t.subarray(n.length+s.length),o=ot(Uint8Array.of(...Vn,...n,...s),{dkLen:64}).subarray(0,kt);return r[0]===o[0]&&r[1]===o[1]?{isValid:!0,ss58Format:Ps(n),publicKey:s.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ps=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ns=e=>{let t={},n=0,s=0;const r=()=>{n===s?(t={},n=s=0):(s=n,setTimeout(r,0))};return o=>{var c,i;++n===1&&r();let l=t;const a=o.length-1;for(let d=0;d<=a;d++)l=l[c=o[d]]||(l[c]={});return l[i=o[a]]||(l[i]=e(o))}},Pn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Ns(n=>{const s=ot(Uint8Array.of(...Vn,...t,...n),{dkLen:64}).subarray(0,kt);return An.encode(Uint8Array.of(...t,...n,...s))})};function Rs(e,t){return n=>{const s=$n(n);if(!s.isValid)throw new Error("Invalid checksum");const{publicKey:r}=s;if(r.length!==e)throw new Error("Invalid public key length");return r}}const ct=(e=42,t=32)=>oe(C(t),Rs(t),Pn(e));var Fs=Object.defineProperty,Nn=e=>{throw TypeError(e)},qs=(e,t,n)=>t in e?Fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,je=(e,t,n)=>qs(e,typeof t!="symbol"?t+"":t,n),Rn=(e,t,n)=>t.has(e)||Nn("Cannot "+n),le=(e,t,n)=>(Rn(e,t,"read from private field"),n?n.call(e):t.get(e)),We=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ue=(e,t,n,s)=>(Rn(e,t,"write to private field"),t.set(e,n),n),ue,Ke,it,at,lt;const js=new TextEncoder,Ws=new TextDecoder,Ks=ee(D,C(1/0))[1];class Xe{constructor(t,n=!1){if(We(this,ue),We(this,Ke,null),We(this,it,null),We(this,at,null),We(this,lt,null),je(this,"asText",()=>le(this,lt)??Ue(this,lt,Ws.decode(le(this,ue)))),je(this,"asHex",()=>le(this,it)??Ue(this,it,re(le(this,ue)))),je(this,"asOpaqueHex",()=>le(this,at)??Ue(this,at,re(this.asBytes()))),je(this,"asBytes",()=>le(this,ue)),je(this,"asOpaqueBytes",()=>le(this,Ke)??Ue(this,Ke,N([le(this,ue),D[0](le(this,ue).length)]))),n){try{const[s,r]=Ks(t);if(s===r.length){Ue(this,ue,r),Ue(this,Ke,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Ue(this,ue,t)}static fromText(t){return new this(js.encode(t))}static fromHex(t){return new this(He(t))}static fromOpaqueHex(t){return new this(He(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}ue=new WeakMap,Ke=new WeakMap,it=new WeakMap,at=new WeakMap,lt=new WeakMap;const[Xs]=ct();class Fn extends Xe{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Xs(t))}}const qn=e=>{const t=C.enc(e);return n=>t(n.asBytes())},jn=e=>{const t=C.dec(e),n=e==null?Xe:Fn;return s=>n.fromBytes(t(s))},ze=e=>_(qn(e),jn(e));ze.enc=qn,ze.dec=jn;const w=oe(D,e=>e,Number),Wn=oe(D,e=>e,BigInt),zs=Be(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:C(n).dec(e),bitsLen:t}}),Ys=_(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},zs),Gs=oe(A,e=>e.charCodeAt(0),String.fromCharCode),Kn=e=>{const t=C.enc(e);return n=>t(He(n))},Xn=e=>{const t=C.dec(e);return n=>re(t(n))},j=e=>_(Kn(e),Xn(e));j.enc=Kn,j.dec=Xn;const zn=new TextEncoder,Js=new TextDecoder,Qs=e=>oe(C(e),t=>zn.encode(t),t=>Js.decode(t)),Yn=e=>{let t=n=>{const s=e();return t=s,s(n)};return n=>t(n)},Gn=e=>{let t=n=>{const s=e(),r=s;return t=s,r(n)};return n=>t(n)},Jn=e=>_(Yn(()=>e().enc),Gn(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Zs=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),L=(e,t)=>{const n=e;return n.inner=t,n},Qn=(...e)=>{const t=K.enc(...e);return L(n=>t({tag:n.type,value:n.value}),e[0])},Zn=(...e)=>{const t=K.dec(...e);return L(n=>{const{tag:s,value:r}=t(n);return Bt(s,r)},e[0])},Ve=(e,...t)=>L(_(Qn(gt(e,([n])=>n),...t),Zn(gt(e,([,n])=>n),...t)),e);Ve.enc=Qn,Ve.dec=Zn;const Oe=(e,...t)=>L(K(e,...t),e);Oe.enc=(e,...t)=>L(K.enc(e,...t),e),Oe.dec=(e,...t)=>L(K.dec(e,...t),e);const ce={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},he=Us.slice(),er=(()=>{const e=Array.from({length:16},(s,r)=>r),t=s=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(r=>s[r]),n=[];for(let s=0,r=e;s<7;s++,r=t(r))n.push(...r);return Uint8Array.from(n)})();class At extends Hn{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:s,context:r}=t,o=r!==void 0;if(s!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');te(s,32,"key");const c=s.slice();this.IV=Ae(c),q(this.IV),this.flags=n|ce.KEYED_HASH}else if(o){te(r,void 0,"context");const c=r,i=new At({dkLen:32},ce.DERIVE_KEY_CONTEXT).update(c).digest();this.IV=Ae(i),q(this.IV),this.flags=n|ce.DERIVE_KEY_MATERIAL}else this.IV=he.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=ks(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,s,r=0){const{state:o,pos:c}=this,{h:i,l}=st(BigInt(t),!0),{v0:a,v1:d,v2:y,v3:u,v4:h,v5:p,v6:f,v7:m,v8:x,v9:B,v10:S,v11:T,v12:J,v13:ne,v14:pe,v15:M}=Mn(er,r,s,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],he[0],he[1],he[2],he[3],i,l,c,n);o[0]=a^x,o[1]=d^B,o[2]=y^S,o[3]=u^T,o[4]=h^J,o[5]=p^ne,o[6]=f^pe,o[7]=m^M}compress(t,n=0,s=!1){let r=this.flags;if(this.chunkPos||(r|=ce.CHUNK_START),(this.chunkPos===15||s)&&(r|=ce.CHUNK_END),s||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,r,t,n),this.chunkPos+=1,this.chunkPos===16||s){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(s||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ce.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:s,state:r,chunkPos:o,posOut:c,chunkOut:i,stack:l,chunksDone:a}=this;return t.state.set(r.slice()),t.stack=l.map(d=>Uint32Array.from(d)),t.IV.set(n),t.flags=s,t.chunkPos=o,t.chunksDone=a,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ve(this.state,this.buffer32,this.IV,this.bufferOut32),ve(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:s,buffer32:r,bufferOut32:o}=this,{h:c,l:i}=st(BigInt(this.chunkOut++));q(r);const{v0:l,v1:a,v2:d,v3:y,v4:u,v5:h,v6:p,v7:f,v8:m,v9:x,v10:B,v11:S,v12:T,v13:J,v14:ne,v15:pe}=Mn(er,0,r,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],he[0],he[1],he[2],he[3],i,c,n,s);o[0]=l^m,o[1]=a^x,o[2]=d^B,o[3]=y^S,o[4]=u^T,o[5]=h^J,o[6]=p^ne,o[7]=f^pe,o[8]=t[0]^m,o[9]=t[1]^x,o[10]=t[2]^B,o[11]=t[3]^S,o[12]=t[4]^T,o[13]=t[5]^J,o[14]=t[6]^ne,o[15]=t[7]^pe,q(r),q(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ve(this.buffer.subarray(this.pos));let t=this.flags|ce.ROOT;this.stack.length?(t|=ce.PARENT,q(this.buffer32),this.compress(this.buffer32,0,!0),q(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ce.CHUNK_START)|ce.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){qe(this,!1),te(t),this.finish();const{blockLen:n,bufferOut:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-r);t.set(s.subarray(this.posOut,this.posOut+c),r),this.posOut+=c,r+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Et(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const eo=It((e={})=>new At(e)),to=BigInt(0),Ye=BigInt(1),no=BigInt(2),ro=BigInt(7),so=BigInt(256),oo=BigInt(113),tr=[],nr=[],rr=[];for(let e=0,t=Ye,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],tr.push(2*(5*s+n)),nr.push((e+1)*(e+2)/2%64);let r=to;for(let o=0;o<7;o++)t=(t<<Ye^(t>>ro)*oo)%so,t&no&&(r^=Ye<<(Ye<<BigInt(o))-Ye);rr.push(r)}const sr=Os(rr,!0),co=sr[0],io=sr[1],or=(e,t,n)=>n>32?Hs(e,t,n):Ls(e,t,n),cr=(e,t,n)=>n>32?Ms(e,t,n):Cs(e,t,n);function ao(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,l=(c+2)%10,a=n[l],d=n[l+1],y=or(a,d,1)^n[i],u=cr(a,d,1)^n[i+1];for(let h=0;h<50;h+=10)e[c+h]^=y,e[c+h+1]^=u}let r=e[2],o=e[3];for(let c=0;c<24;c++){const i=nr[c],l=or(r,o,i),a=cr(r,o,i),d=tr[c];r=e[d],o=e[d+1],e[d]=l,e[d+1]=a}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=co[s],e[1]^=io[s]}ve(n)}class Ut{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,s,r=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=r,this.rounds=o,Me(s,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ae(this.state)}clone(){return this._cloneInto()}keccak(){q(this.state32),ao(this.state32,this.rounds),q(this.state32),this.posOut=0,this.pos=0}update(t){qe(this),te(t);const{blockLen:n,state:s}=this,r=t.length;for(let o=0;o<r;){const c=Math.min(n-this.pos,r-o);for(let i=0;i<c;i++)s[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:r}=this;t[s]^=n,(n&128)!==0&&s===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){qe(this,!1),te(t),this.finish();const n=this.state,{blockLen:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=s&&this.keccak();const c=Math.min(s-this.posOut,o-r);t.set(n.subarray(this.posOut,this.posOut+c),r),this.posOut+=c,r+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Et(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ve(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:r,rounds:o,enableXOF:c}=this;return t||=new Ut(n,s,r,c,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=s,t.outputLen=r,t.enableXOF=c,t.destroyed=this.destroyed,t}}const ir=((e,t,n,s={})=>It(()=>new Ut(t,e,n),s))(1,136,32),ar=e=>{const t=e.slice(2),n=re(ir(zn.encode(t))).slice(2),s=new Array(40);for(let r=0;r<40;r++){const o=parseInt(n[r],16),c=t[r];s[r]=o>7?c.toUpperCase():c}return`0x${s.join("")}`},lo=C(20)[1],lr=_(e=>{const t=He(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=re(t);if(e===n||e===n.toUpperCase())return t;if(ar(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Be(e=>ar(re(lo(e))))),R=e=>L(b(e),e);R.enc=e=>L(b.enc(e),e),R.dec=e=>L(b.dec(e),e);const de=(...e)=>L(ee(...e),e);de.enc=(...e)=>L(ee.enc(...e),e),de.dec=(...e)=>L(ee.dec(...e),e);const W=(e,...t)=>L(I(e,...t),e);W.enc=(e,...t)=>L(I.enc(e,...t),e),W.dec=(e,...t)=>L(I.dec(e,...t),e);const ut=(e,t)=>L(Fe(e,t),{ok:e,ko:t});ut.enc=(e,t)=>L(Fe.enc(e,t),{ok:e,ko:t}),ut.dec=(e,t)=>L(Fe.dec(e,t),{ok:e,ko:t});const $e=e=>L(X(e),e);$e.enc=e=>L(X.enc(e),e),$e.dec=e=>L(X.dec(e),e);const ur=(e=!0)=>Be(t=>{const n=w.dec(t),s=Math.ceil(n/8),r=C(s).dec(t),o=new Array(n);let c=0;return r.forEach(i=>{for(let l=0;l<8&&c<n;l++){const a=e?l:7-l;o[c++]=i>>a&1}}),o}),hr=(e=!0)=>t=>{const n=w.enc(t.length),s=Math.ceil(t.length/8),r=new Uint8Array(s);for(let o=0;o<s;o++){let c=o*8,i=0;for(let l=0;l<8&&c<t.length;l++,c++)i|=t[c]<<(e?l:7-l);r[o]=i}return N([n,r])},ht=e=>_(hr(e),ur(e));ht.enc=hr,ht.dec=ur;const dr=new TextEncoder,fr=new TextDecoder,uo=oe(C(4),dr.encode.bind(dr),fr.decode.bind(fr)),Ot=R({engine:uo,payload:j()}),ho=Ve({other:C(),consensus:Ot,seal:Ot,preRuntime:Ot,runtimeUpdated:v},[0,4,5,6,8]),_t=j(32),fo=R({parentHash:_t,number:w,stateRoot:_t,extrinsicRoot:_t,digests:W(ho)}),Y=I(k),pr=X(k),po=K({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v}),yr=I(b({name:pr,type:w,typeName:pr,docs:Y})),yo=b({len:Z,type:w}),go=b({bitStoreType:w,bitOrderType:w}),vo=I(b({name:k,fields:yr,index:A,docs:Y})),mo=K({composite:yr,variant:vo,sequence:w,array:yo,tuple:I(w),primitive:po,compact:w,bitSequence:go}),wo=b({name:k,type:X(w)}),bo=I(wo),xo=b({id:w,path:Y,params:bo,def:mo,docs:Y}),dt=I(xo),Pe=K({NotDeprecated:v,DeprecatedWithoutNote:v,Deprecated:b({note:k,since:X(k)})}),Eo=I(b({index:A,deprecation:K({DeprecatedWithoutNote:v,Deprecated:b({note:k,since:X(k)})},[1,2])})),St={name:k,inputs:I(b({name:k,type:w})),output:w,docs:Y},Io=b({name:k,methods:I(b(St)),docs:Y}),ko=b({name:k,methods:I(b({...St,deprecationInfo:Pe})),docs:Y,version:w,deprecationInfo:Pe}),Bo=b({id:j(32),...St,deprecationInfo:Pe}),Ao=K({Blake2128:v,Blake2256:v,Blake2128Concat:v,Twox128:v,Twox256:v,Twox64Concat:v,Identity:v}),Uo=I(Ao),Oo=b({hashers:Uo,key:w,value:w}),gr={name:k,modifier:A,type:K({plain:w,map:Oo}),fallback:j(),docs:Y},Tt=X(w),vr={name:k,storage:X(b({prefix:k,items:I(b(gr))})),calls:Tt,events:Tt,constants:I(b({name:k,type:w,value:j(),docs:Y})),errors:Tt,index:A},_o={...vr,docs:Y},Dt=X(b({type:w,deprecationInfo:Eo})),So={name:k,storage:X(b({prefix:k,items:I(b({...gr,deprecationInfo:Pe}))})),calls:Dt,events:Dt,constants:I(b({name:k,type:w,value:j(),docs:Y,deprecationInfo:Pe})),errors:Dt,associatedTypes:I(b({name:k,type:w,docs:Y})),viewFns:I(Bo),index:A,docs:Y,deprecationInfo:Pe},To=new Uint8Array,mr=e=>_(()=>To,()=>e),Do=b({type:w,version:A,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),wr=b({lookup:dt,pallets:I(b({...vr,docs:mr([])})),extrinsic:Do,type:w,apis:mr([])}),Lo=b({version:A,address:w,call:w,signature:w,extra:w,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),br=b({lookup:dt,pallets:I(b(_o)),extrinsic:Lo,type:w,apis:I(Io),outerEnums:b({call:w,event:w,error:w}),custom:I(ee(k,b({type:w,value:j()})))}),Co=b({version:I(A),address:w,call:w,signature:w,signedExtensionsByVersion:I(ee(A,I(w))),signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),xr=b({lookup:dt,pallets:I(b(So)),extrinsic:Co,apis:I(ko),outerEnums:b({call:w,event:w,error:w}),custom:I(ee(k,b({type:w,value:j()})))}),Er=()=>{throw new Error("Unsupported metadata version!")},z=_(Er,Er),Ge=b({magicNumber:Z,metadata:K({v0:z,v1:z,v2:z,v3:z,v4:z,v5:z,v6:z,v7:z,v8:z,v9:z,v10:z,v11:z,v12:z,v13:z,v14:wr,v15:br,v16:xr})}),Lt=C(),Ho=X(Lt),Mo=ee(D,Lt),Ct=e=>{try{return Ge.dec(e)}catch{}try{return Ge.dec(Ho.dec(e))}catch{}try{return Ge.dec(Lt.dec(e))}catch{}try{return Ge.dec(Mo.dec(e)[1])}catch{}throw null},Ht=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:r,extrinsic:o,custom:c,apis:i,pallets:l,outerEnums:a}=e;return{version:15,lookup:r,pallets:l.map(d=>({...d,calls:d.calls!=null?{type:d.calls}:void 0,events:d.events!=null?{type:d.events}:void 0,errors:d.errors!=null?{type:d.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:i,outerEnums:a,custom:c}}const{lookup:t,extrinsic:n,pallets:s}=e;return{version:14,lookup:t,pallets:s.map(r=>({...r,calls:r.calls!=null?{type:r.calls}:void 0,events:r.events!=null?{type:r.events}:void 0,errors:r.errors!=null?{type:r.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},_e={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Mt=oe(A,({version:e,type:t})=>e+(_e[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===_e.bare||n===_e.signed))return{version:t,type:_e[n]};if(t===5&&(n===_e.bare||n===_e.general))return{version:t,type:_e[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Vo={dkLen:32},Je=e=>ot(e,Vo),$o={dkLen:16},Vt=e=>ot(e,$o),Ir=e=>N([Vt(e),e]),Po={dkLen:32},Ne=e=>eo(e,Po),No=e=>N([Ne(e),e]),kr=e=>e,Se=(e,t,n,s)=>new DataView(new Uint16Array([e,t,n,s]).buffer).getBigUint64(0,!0),$t=2n**64n-1n,F=(e,t)=>e<<t&$t|e>>64n-t,U=(e,t)=>e*t&$t,$=(e,t)=>e+t&$t,P=11400714785074694791n,G=14029467366897019727n,Br=1609587929392839161n,Qe=9650029242287828579n,Ar=2870177450012600261n;function Ee(e,t=0n){let n=$($(t,P),G),s=$(t,G),r=t,o=t-P,c=e.length,i=0,l=null;(function(){let h=0,p=h+c;if(c){if(l=new Uint8Array(32),c<32){l.set(e.subarray(0,c),i),i+=c;return}if(h<=p-32){const f=p-32;do{let m;m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=U(F($(n,U(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=U(F($(s,U(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=U(F($(r,U(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),o=U(F($(o,U(m,G)),31n),P),h+=8}while(h<=f)}h<p&&(l.set(e.subarray(h,p),i),i=p-h)}})(),e=l||e;let a,d=0;for(c>=32?(a=F(n,1n),a=$(a,F(s,7n)),a=$(a,F(r,12n)),a=$(a,F(o,18n)),n=U(F(U(n,G),31n),P),a=a^n,a=$(U(a,P),Qe),s=U(F(U(s,G),31n),P),a=a^s,a=$(U(a,P),Qe),r=U(F(U(r,G),31n),P),a=a^r,a=$(U(a,P),Qe),o=U(F(U(o,G),31n),P),a=a^o,a=$(U(a,P),Qe)):a=$(t,Ar),a=$(a,BigInt(c));d<=i-8;){let u=Se(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]);u=U(F(U(u,G),31n),P),a=$(U(F(a^u,27n),P),Qe),d+=8}if(d+4<=i){let u=U(Se(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],0,0),P);a=$(U(F(a^u,23n),G),Br),d+=4}for(;d<i;){const u=U(Se(e[d++],0,0,0),Ar);a=U(F(a^u,11n),P)}let y=a>>33n;return a=U(a^y,G),y=a>>29n,a=U(a^y,Br),y=a>>32n,a^=y,a}const ft=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),t},Ur=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),n.setBigUint64(16,Ee(e,2n),!0),n.setBigUint64(24,Ee(e,3n),!0),t},Or=e=>N([Re.enc(Ee(e)),e]),_r=new TextEncoder,Ro=new Map([[kr,0],[Or,8],[Ir,16],[Vt,-16],[Je,-32],[ft,-16],[Ur,-32]]),Sr=e=>{const t=ft(_r.encode(e));return(n,...s)=>{const r=N([t,ft(_r.encode(n))]),o=re(r),c=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=He(a.slice(o.length)),y=new Array(s.length);for(let u=0,h=0;u<s.length;u++){const[p,f]=s[u],m=Ro.get(f);if(m==null)throw new Error("Unknown hasher");if(m<0){const x=m*-1;y[u]=re(d.slice(h,h+x)),h+=x}else h+=m,y[u]=p.dec(d.slice(h)),h+=p.enc(y[u]).length}return y},i=s.map(([{enc:a},d])=>y=>d(a(y)));return{enc:(...a)=>re(N([r,...a.map((d,y)=>i[y](d))])),dec:c}}},Fo=Xe.fromText("modlpy/utilisuba").asBytes(),qo=({threshold:e,signatories:t})=>{const n=Tr(t),s=N([Fo,D.enc(n.length),...n,ie.enc(e)]);return Je(s)},Tr=e=>e.slice().sort((t,n)=>{for(let s=0;;s++){const r=s>=t.length,o=s>=n.length;if(r&&o)return 0;if(r)return-1;if(o)return 1;if(t[s]!==n[s])return t[s]>n[s]?1:-1}}),Ie={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Dr=j().dec,jo=j(1/0).dec,Wo=j(32).dec,Lr=A.dec,Ko=e=>{const t=Lr(e);let n=6;const s=t>>n,r=s?s===1?Ie.Leaf:s===2?Ie.Branch:Ie.BranchWithVal:t>>--n?Ie.LeafWithHash:t>>--n?Ie.BranchWithHash:t?Ie.Reserved:Ie.Empty;let o=t&255>>8-n;if(o===2**n-1){let c;do o+=c=Lr(e);while(c===255)}return{type:r,partialKey:j(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Cr=Be(e=>{const t=Ko(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:jo(e)};const s=ie.dec(e),r=[];for(let i=0;i<16;i++)s>>i&1&&r.push(i.toString(16));let o=null;n==="BranchWithVal"&&(o=Dr(e)),n==="BranchWithHash"&&(o=Wo(e));const c={...t,children:Object.fromEntries(r.map(i=>[i,Dr(e)]))};return o!==null&&(c.value=o),c}),Hr=e=>Be(t=>{const n=re(e(new Uint8Array(t.buffer)));try{return{hash:n,...Cr(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Mr=Object.freeze({__proto__:null,AccountId:ct,Bin:ze,Binary:Xe,BitSeq:ht,Blake2128:Vt,Blake2128Concat:Ir,Blake2256:Je,Blake3256:Ne,Blake3256Concat:No,Bytes:C,Enum:Bt,FixedSizeBinary:Fn,Hex:j,Identity:kr,Keccak256:ir,Option:$e,Result:ut,ScaleEnum:Oe,Self:Jn,Storage:Sr,Struct:R,TrieNodeHeaders:Ie,TrieNodeWithHash:Hr,Tuple:de,Twox128:ft,Twox256:Ur,Twox64Concat:Or,Variant:Ve,Vector:W,_Enum:Zs,_void:v,bitSequence:Ys,blockHeader:fo,bool:cn,char:Gs,compact:D,compactBn:Wn,compactNumber:w,createCodec:_,createDecoder:Be,decAnyMetadata:Ct,enhanceCodec:oe,enhanceDecoder:wt,enhanceEncoder:mt,ethAccount:lr,extrinsicFormat:Mt,fixedStr:Qs,fromBufferToBase58:Pn,getMultisigAccountId:qo,getSs58AddressInfo:$n,h64:Ee,i128:tn,i16:Yt,i256:on,i32:Gt,i64:Jt,i8:zt,metadata:Ge,selfDecoder:Gn,selfEncoder:Yn,sortMultisigSignatories:Tr,str:k,trieNodeDec:Cr,u128:en,u16:ie,u256:sn,u32:Z,u64:Re,u8:A,unifyMetadata:Ht,v14:wr,v14Lookup:dt,v15:br,v16:xr,validateProofs:(e,t=Je)=>{const n=e.map(Hr(t)),s=Object.fromEntries(n.map(i=>[i.hash,i])),r=n.map(i=>i.hash),o=new Set(r),c=i=>{if(i.value)return;const l=e[r.indexOf(i.hash)];i.value=typeof l=="string"?l:re(l)};return n.forEach(i=>{if("children"in i&&Object.values(i.children).forEach(l=>{const a=s[l];a&&(a.parent=i.hash,o.delete(l))}),i.type==="BranchWithHash"||i.type==="LeafWithHash"){const l=i.value,a=s[l];if(!a)return;o.delete(l),a.type!=="Raw"&&(Object.keys(a).forEach(d=>delete a[d]),a.type="Raw",a.hash=l),a.parent=i.hash,c(a)}i.type==="Raw"&&c(i)}),o.size===1?{rootHash:o.values().next().value,proofs:s}:null}});const Vr=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ke={type:"void"},Xo=(e,t=()=>null)=>{const n=new Map,s=new Set,r=d=>y=>{let u=n.get(y);if(u)return u;if(s.has(y)){const p={id:y};return n.set(y,p),p}s.add(y);const h=d(y);return u=n.get(y),u?Object.assign(u,h):(u={id:y,...h},n.set(y,u)),s.delete(y),u};let o=!0,c=!0;const i=r(d=>{const y=t(e[d]);if(y)return y;const{def:u,path:h,params:p}=e[d];if(u.tag==="composite"){if(u.value.length===0)return ke;if(u.value.length===1){const f=i(u.value[0].type);return o&&h.at(-1)==="AccountId32"&&Vr(f,32)?(o=!1,{type:"AccountId32"}):c&&h.at(-1)==="AccountId20"&&Vr(f,20)?(c=!1,{type:"AccountId20"}):f}return l(u.value)}if(u.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=i(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(h.length===1&&h[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:i(p[0].type),ko:i(p[1].type)}};if(u.value.length===0)return ke;const f={},m={};return u.value.forEach(x=>{const B=x.name;if(m[B]=x.docs,x.fields.length===0){f[B]={...ke,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){f[B]={type:"lookupEntry",value:i(x.fields[0].type),idx:x.index};return}f[B]={...l(x.fields),idx:x.index}}),{type:"enum",value:f,innerDocs:m}}if(u.tag==="sequence")return{type:"sequence",value:i(u.value)};if(u.tag==="array"){const{len:f}=u.value,m=i(u.value.type);return!f||m.type==="void"?ke:f>1?{type:"array",value:m,len:u.value.len}:m}if(u.tag==="tuple")return u.value.length===0?ke:u.value.length>1?a(u.value.map(f=>i(f)),u.value.map(f=>e[f].docs)):i(u.value[0]);if(u.tag==="primitive")return{type:"primitive",value:u.value.tag};if(u.tag==="compact"){const f=i(u.value);return f.type==="void"?ke:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:u.tag,isLSB:(e[u.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),l=d=>{let y=!0;const u={},h={};return d.forEach((p,f)=>{y=y&&!!p.name;const m=p.name||f,x=i(p.type);x.type!=="void"&&(u[m]=x,h[m]=p.docs)}),y?{type:"struct",value:u,innerDocs:h}:a(Object.values(u),Object.values(h))},a=(d,y)=>{if(d.every(u=>u.id===d[0].id)&&y.every(u=>!u.length)){const[u]=d;return u.type==="void"?ke:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:y}};return i},$r=e=>{const t=Xo(e.lookup,({def:r})=>{if(r.tag==="composite"){const o=n(r);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(c=>[c.name,c.errors==null?{...ke,idx:c.index}:{type:"lookupEntry",value:t(c.errors.type),idx:c.index}])),byteLength:o}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const c=t(r.value[0].type),i=t(r.value[1].type);return c.type==="primitive"&&c.value==="u8"&&i.type==="array"&&i.value.type==="primitive"&&i.value.value==="u8"?1+i.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(c=>c.name==="Call")?.type??null})},zo=(e,t,n)=>(s,r,o,...c)=>{const{id:i}=s;if(r.has(i))return r.get(i);if(o.has(i)){const a=t(()=>r.get(i),s,...c);return r.set(i,a),a}o.add(i);let l=e(s,r,o,...c);return o.delete(i),r.has(i)&&(l=n(l,r.get(i),s,...c)),r.set(i,l),l},Yo=ze(),Pr=zo((e,t,n,s)=>{if(e.type==="primitive")return Mr[e.value];if(e.type==="void")return v;if(e.type==="AccountId32")return s;if(e.type==="AccountId20")return lr;if(e.type==="compact")return e.isBig?Wn:w;if(e.type==="bitSequence")return ht(e.isLSB);const r=h=>Pr(h,t,n,s),o=(h,p)=>{const f=r(h);return p?W(f,p):W(f)},c=h=>de(...h.map(r)),i=h=>{const p=Object.fromEntries(Object.entries(h).map(([f,m])=>[f,r(m)]));return R(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Yo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?ze(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return $e(r(e.value));if(e.type==="result")return ut(r(e.value.ok),r(e.value.ko));const l=Object.values(e.value).map(h=>{switch(h.type){case"void":return v;case"lookupEntry":return r(h.value);case"tuple":return c(h.value);case"struct":return i(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,l[p]])),d=Object.values(e.value).map(h=>h.idx),u=d.every((h,p)=>h===p)?Ve(a):Ve(a,d);return e.byteLength?Go(u,e.byteLength):u},Jn,e=>e),Nr=(e,t=ct())=>{const n=new Map,s=r=>Pr(e(r),n,new Set,t);return r=>s(r)},Go=(e,t)=>{const n=C(t);return _(s=>n.enc(e.enc(s)),s=>e.dec(n.dec(s)))},Jo=oe(v,()=>{},()=>null),Qo=e=>{const{metadata:t}=e;let n=Nr(e);const s=t.pallets.find(u=>u.name==="System")?.constants.find(u=>u.name==="SS58Prefix");let r;if(s)try{const u=n(s.type).dec(s.value);typeof u=="number"&&(r=u,n=Nr(e,ct(u)))}catch{}const o=new Map,c=(u,h)=>{let p=o.get(u);p||o.set(u,p=Sr(u));const f=t.pallets.find(M=>M.name===u).storage.items.find(M=>M.name===h),m=M=>M===v?Jo:M,x=(M,Te,...et)=>{const O=p(...et),[,...E]=et;return{args:de(...E.map(([V])=>V)),keys:O,value:Te,len:M,fallback:f.modifier===1?Te.dec(f.fallback):void 0}};if(f.type.tag==="plain")return x(0,m(n(f.type.value)),h);const{key:B,value:S,hashers:T}=f.type.value,J=m(n(S)),ne=T.map(M=>Mr[M.tag]),pe=(()=>{if(ne.length===1)return[[n(B),ne[0]]];const M=e(B);switch(M.type){case"array":return ne.map(Te=>[n(M.value.id),Te]);case"tuple":return M.value.map((Te,et)=>[n(Te.id),ne[et]]);default:throw new Error("Invalid key type")}})();return x(ne.length,J,h,...pe)},i=u=>{switch(u.type){case"void":return v;case"lookupEntry":return n(u.value.id);case"tuple":return de(...Object.values(u.value).map(h=>n(h.id)));case"struct":return R(gt(u.value,h=>n(h.id)));case"array":return W(n(u.value.id),u.len)}},l=(u,h)=>{const p=t.pallets.find(f=>f.name===u).constants.find(f=>f.name===h);return n(p.type)},a=u=>(h,p)=>{const f=t.pallets.find(B=>B.name===h),m=e(f[u].type);if(m.type!=="enum")throw null;const x=m.value[p];return{location:[f.index,x.idx],codec:i(m.value[p])}},d=(u,h)=>{const p=t.pallets.find(f=>f.name===u)?.viewFns.find(f=>f.name===h);if(!p)throw null;return{args:de(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},y=(u,h)=>{const p=t.apis.find(f=>f.name===u)?.methods.find(f=>f.name===h);if(!p)throw null;return{args:de(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:c,buildEvent:a("events"),buildError:a("errors"),buildViewFn:d,buildRuntimeCall:y,buildCall:a("calls"),buildConstant:l,ss58Prefix:r}},Pt=()=>new Error("Unkown signer"),Zo=e=>{const{extrinsic:t}=e,n=$r(e);let s,r;if("address"in t)s=n(t.address),r=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(c=>c.type!=null).map(c=>[c.name,n(c.type)]));if(s=o.Address,r=o.Signature,!s||!r)throw Pt()}if(s.type==="AccountId20"&&r.type==="array"&&r.len===65&&r.value.type==="primitive"&&r.value.value==="u8")return[1,[]];if(r.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in r.value)))throw Pt();if(s.type==="enum"){const o=s.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(s.type==="AccountId32")return[0,[]];throw Pt()},ec={Ed25519:0,Sr25519:1,Ecdsa:2},tc=(e,t,n,s,r,o)=>{const[c,i]=Zo(e),l=N([Mt.enc({version:4,type:"signed"}),c===1?t:new Uint8Array([...i,...t]),c===1||!o?n:new Uint8Array([ec[o],...n]),...s,r]);return N([D.enc(l.length),l])},[pt,Ze]=["<Bytes>","</Bytes>"].map(e=>Xe.fromText(e).asBytes()),nc=e=>async t=>{let n=!0,s;for(s=0;n&&s<pt.length;s++)n=pt[s]===t[s];n=n&&s===pt.length;const r=t.length-Ze.length;for(s=0;n&&s<Ze.length;s++)n=Ze[s]===t[r+s];return n=n&&s===Ze.length,e(n?t:N([pt,t,Ze]))},Rr={specVersion:Z,specName:k,base58Prefix:ie,decimals:A,tokenSymbol:k},Fr=R(Rr),Nt=C(32),rc=Oe({V0:v,V1:R({typeInformationTreeRoot:Nt,extrinsicMetadataHash:Nt,...Rr})});Oe({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v});const fe=Oe({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v,compactU8:v,compactU16:v,compactU32:v,compactU64:v,compactU128:v,compactU256:v,void:v,perId:w}),qr=R({name:$e(k),ty:fe,typeName:$e(k)}),sc=Oe({composite:W(qr),enumeration:R({name:k,fields:W(qr),index:w}),sequence:fe,array:R({len:Z,typeParam:fe}),tuple:W(fe),bitSequence:R({numBytes:A,leastSignificantBitFirst:cn})}),jr=R({path:W(k),typeDef:sc,typeId:w}),oc=W(jr),Rt=R({version:A,addressTy:fe,callTy:fe,signatureTy:fe,signedExtensions:W(R({identifier:k,includedInExtrinsic:fe,includedInSignedData:fe}))}),cc=de.dec(D[1],Mt[1],C(1/0)[1]);R({leaves:oc,leafIdxs:W(Z),proofs:W(Nt),extrinsic:Rt,info:Fr});const ic=(e,t)=>{const n=new Set,s=o=>{if(n.has(o))return;const{tag:c,value:i}=t.get(o).def;switch(c){case"composite":if(!i.length)break;n.add(o),i.forEach(({type:l})=>{s(l)});break;case"variant":if(!i.length)break;n.add(o),i.forEach(({fields:l})=>{l.forEach(({type:a})=>{s(a)})});break;case"tuple":if(!i.length)break;n.add(o),i.forEach(s);break;case"sequence":n.add(o),s(i);break;case"array":n.add(o),s(i.type);break;case"bitSequence":n.add(o)}};s(e.extrinsic.call),s(e.extrinsic.address),s(e.extrinsic.signature),e.extrinsic.signedExtensions.forEach(({type:o,additionalSigned:c})=>{s(o),s(c)});const r=[...n].sort((o,c)=>o-c);return new Map(r.map((o,c)=>[o,c]))},ac={u8:1,u16:2,u32:4,u64:8},lc=(e,t,n,s)=>{const{def:{tag:r,value:o}}=e.get(s);switch(r){case"composite":return[{tag:r,value:o.map(c=>({name:c.name,typeName:c.typeName,ty:t(c.type)}))}];case"variant":return o.map(c=>({tag:"enumeration",value:{name:c.name,index:c.index,fields:c.fields.map(i=>({name:i.name,typeName:i.typeName,ty:t(i.type)}))}}));case"sequence":return[{tag:r,value:t(o)}];case"array":return[{tag:r,value:{len:o.len,typeParam:t(o.type)}}];case"tuple":return[{tag:r,value:o.map(t)}];case"bitSequence":{const c=n(o.bitStoreType),i=ac[c];if(!i)throw new Error("Invalid primitive for BitSequence");const l=e.get(o.bitOrderType).path,a=l.includes("Lsb0");if(!a&&!l.includes("Msb0"))throw new Error("BitOrderType not recognized");return[{tag:"bitSequence",value:{numBytes:i,leastSignificantBitFirst:a}}]}}throw new Error(`FrameId(${s}) should have been filtered out`)},uc=(e,t,n,s)=>{const r=[];return[...t.entries()].forEach(([o,c])=>{const{path:i}=e.get(o);lc(e,n,s,o).forEach(l=>{r.push({path:i,typeId:c,typeDef:l})})}),r.sort((o,c)=>{if(o.typeId!==c.typeId)return o.typeId-c.typeId;if(o.typeDef.tag!=="enumeration"||c.typeDef.tag!=="enumeration")throw new Error("Found two types with same id");return o.typeDef.value.index-c.typeDef.value.index}),r},hc=e=>{try{const t=Ht(Ct(e));if(t.version<=14)throw new Error("Wrong metadata version");return t}catch(t){throw t||new Error("Unable to decode metadata")}},Wr=e=>typeof e=="string"?He(e):e,dc={null:"void",u8:"compactU8",u16:"compactU16",u32:"compactU32",u64:"compactU64",u128:"compactU128",u256:"compactU256"},fc={bool:A,char:A,str:k,u8:A,u16:ie,u32:Z,u64:Re,u128:en,u256:sn,i8:zt,i16:Yt,i32:Gt,i64:Jt,i128:tn,i256:on,void:v,compactU8:D,compactU16:D,compactU32:D,compactU64:D,compactU128:D,compactU256:D},Kr=(e,t,n,s,r)=>{if(t.tag!=="perId"){fc[t.tag][1](e);return}const o=a=>{Kr(e,a,n,s,r)},c=n.get(t.value),[i]=c,l=s[i];switch(c.length===1&&r.add(i),l.typeDef.tag){case"enumeration":{const a=A.dec(e),[d,y]=c.map(u=>[s[u].typeDef,u]).find(([u])=>u.value.index===a);r.add(y),d.value.fields.forEach(({ty:u})=>{o(u)});break}case"sequence":{const a=D.dec(e);for(let d=0;d<a;d++)o(l.typeDef.value);break}case"array":{for(let a=0;a<l.typeDef.value.len;a++)o(l.typeDef.value.typeParam);break}case"composite":{l.typeDef.value.forEach(a=>{o(a.ty)});break}case"tuple":{l.typeDef.value.forEach(o);break}case"bitSequence":throw new Error("bitSequence is not supported")}},Xr=(e,t,n)=>{let s=new Uint8Array;Be(c=>{s=c})(e);const r=new Map;n.forEach((c,i)=>{const l=r.get(c.typeId);l?l.push(i):r.set(c.typeId,[i])});const o=new Set;return t.forEach(c=>{Kr(s,c,r,n,o)}),[...o].sort((c,i)=>c-i)},Ft=e=>Math.log2(e+1)|0,pc=(e,t)=>(e+1>>t)-1;function yc(e,t){const n=t.map(l=>e[l]),s=e.length-1,r=t.map(l=>s+l),o=[];if(r.length){const l=Ft(r.at(-1)),a=Math.pow(2,l)-1,d=r.findIndex(y=>y>=a);d>0&&(r.unshift(...r.splice(d)),n.unshift(...n.splice(d)))}let c=0;const i=l=>{if(c===r.length){o.push(l);return}const a=r[c];if(a===l){++c;return}const d=Ft(l),y=Ft(a);if(l!==pc(a,y-d)){o.push(l);return}const u=2*l+1;i(u),i(u+1)};return i(0),{leaves:n,leafIdxs:r,proofIdxs:o}}const qt=(e,t,n)=>{if(n!=null&&n!==t)throw new Error(`${e} not expected. Received ${n} expected ${t}`)},gc=(e,{decimals:t,tokenSymbol:n,...s})=>{const r=hc(e),o=r.extrinsic.version.includes(4)?4:null;if(o==null)throw new Error("Only extrinsic v4 is supported");const{ss58Prefix:c,buildDefinition:i}=Qo($r(r));if(c==null)throw new Error("SS58 prefix not found in metadata");qt("SS58 prefix",c,s.base58Prefix);const l=r.pallets.find(O=>O.name==="System")?.constants.find(O=>O.name==="Version");if(l==null)throw new Error("System.Version constant not found");const{spec_name:a,spec_version:d}=i(l.type).dec(l.value);if(typeof a!="string"||typeof d!="number")throw new Error("Spec name or spec version not found");qt("Spec name",a,s.specName),qt("Spec version",d,s.specVersion);const y={decimals:t,tokenSymbol:n,specVersion:d,specName:a,base58Prefix:c},u=new Map(r.lookup.map(O=>[O.id,O])),h=ic(r,u),p=O=>{const{def:{tag:E,value:V}}=u.get(O);if(E==="primitive")return V.tag;if(E!=="composite"&&E!=="tuple"||V.length>1)throw new Error("The provided definition doesn't map to a primitive");return V.length===0?null:p(E==="tuple"?V[0]:V[0].type)},f=O=>{const{def:E}=u.get(O);if(E.tag==="primitive")return{tag:E.value.tag,value:void 0};if(E.tag==="compact"){const V=p(E.value),ye=dc[V];if(!ye)throw new Error("Invalid primitive for Compact");return{tag:ye,value:void 0}}return h.has(O)?{tag:"perId",value:h.get(O)}:{tag:"void",value:void 0}},m={version:o,addressTy:f(r.extrinsic.address),callTy:f(r.extrinsic.call),signatureTy:f(r.extrinsic.signature),signedExtensions:r.extrinsic.signedExtensions.map(O=>({identifier:O.identifier,includedInExtrinsic:f(O.type),includedInSignedData:f(O.additionalSigned)}))},x=uc(u,h,f,p),B=x.map(jr.enc);let S;const T=()=>{if(S)return S;if(!B.length)return S=[new Uint8Array(32).fill(0)];S=new Array(B.length*2-1);let O=B.length-1;for(let E=0;E<B.length;E++)S[O+E]=Ne(B[E]);for(let E=S.length-2;E>0;E-=2)S[(E-1)/2]=Ne(N([S[E],S[E+1]]));return S};let J;const ne=()=>{if(J)return J;const E={tag:"V1",value:{typeInformationTreeRoot:T()[0],extrinsicMetadataHash:Ne(Rt.enc(m)),...y}};return J=Ne(rc.enc(E))},pe=O=>{const E=yc(B,O),V=T(),ye=E.proofIdxs.map(De=>V[De]);return N([D.enc(E.leaves.length),...E.leaves,D.enc(E.leafIdxs.length),...E.leafIdxs.map(De=>Z.enc(De)),D.enc(ye.length),...ye,Rt.enc(m),Fr.enc(y)])},M=O=>{const E=[m.callTy,...m.signedExtensions.map(V=>V.includedInExtrinsic),...m.signedExtensions.map(V=>V.includedInSignedData)];return pe(Xr(O,E,x))};return{digest:ne,getProofForExtrinsic:(O,E)=>{let[,{version:V,type:ye},De]=cc(O);if(V!==m.version)throw new Error("Incorrect extrinsic version");const Yr=ye==="signed"?[m.addressTy,m.signatureTy,...m.signedExtensions.map(Wt=>Wt.includedInExtrinsic),m.callTy]:[m.callTy];return E&&(De=N([De,Wr(E)]),Yr.push(...m.signedExtensions.map(Wt=>Wt.includedInSignedData))),pe(Xr(De,Yr,x))},getProofForExtrinsicParts:(O,E,V)=>{const ye=N([O,E,V].map(Wr));return M(ye)},getProofForExtrinsicPayload:M}};function vc(e,t,n){return{publicKey:e,signTx:async(r,o,c,i,l=Je)=>{const a=Ht(Ct(c)),d=[],y=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);d.push(f.value),y.push(f.additionalSigned)});const u=N([r,...d,...y]),h=await n(u.length>256?l(u):u);return tc(a,e,h,d,r,t)},signBytes:nc(n)}}const jt="CheckMetadataHash",zr=Uint8Array.from([1]),mc=(e,t)=>({...t,signTx:async(n,s,r,...o)=>t.signTx(n,s[jt]?{...s,[jt]:{identifier:jt,value:zr,additionalSigned:N([zr,gc(r,e).digest()])}}:s,r,...o)});Le.getPolkadotSigner=vc,Le.withMetadataHash=mc}));
1
+ (function(Le,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports):typeof define=="function"&&define.amd?define(["exports"],Ce):(Le=typeof globalThis<"u"?globalThis:Le||self,Ce(Le.papiSigner={}))})(this,(function(Le){"use strict";const Ce="0123456789abcdef";function re(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const s=e[n++];t[n]=Ce[s>>4]+Ce[s&15]}return t.join("")}const yt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function He(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|yt[e[2]]);for(let o=0;o<s;){const c=n+o*2,i=yt[e[c]],l=yt[e[c+1]];r[t+o++]=i<<4|l}return r}function gt(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s,n)]))}const N=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((r,o)=>r+o.byteLength,0),s=new Uint8Array(n);for(let r=0,o=0;r<t.length;r++){const c=t[r];s.set(c,o),o+=c.byteLength}return s};var Gr=Object.defineProperty,Jr=(e,t,n)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kt=(e,t,n)=>(Jr(e,typeof t!="symbol"?t+"":t,n),n),vt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Qr(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,s=(e.length-n)/2+t,r=new Uint8Array(s);t&&(r[0]=0|vt[e[2]]);for(let o=0;o<s;){const c=n+o*2,i=vt[e[c]],l=vt[e[c+1]];r[t+o++]=i<<4|l}return r}var Xt=class extends Uint8Array{constructor(e){super(e),Kt(this,"i",0),Kt(this,"v"),this.v=new DataView(e)}},Q=e=>t=>e(t instanceof Xt?t:new Xt(t instanceof Uint8Array?t.buffer:typeof t=="string"?Qr(t).buffer:t)),se=e=>{const t=e.length;let n=0;for(let r=0;r<t;r++)n+=e[r].length;const s=new Uint8Array(n);for(let r=0,o=0;r<t;r++){const c=e[r];s.set(c,o),o+=c.byteLength}return s};function tt(e,t){const n=Object.keys(e),s=n.length,r={};for(let o=0;o<s;o++){const c=n[o];r[c]=t(e[c],c)}return r}var Be=Q,_=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),wt=(e,t)=>n=>t(e(n)),oe=([e,t],n,s)=>_(mt(e,n),wt(t,s));function Zr(e,t){return Q(n=>{const s=n.v[t](n.i,!0);return n.i+=e,s})}function es(e,t){return n=>{const s=new Uint8Array(e);return new DataView(s.buffer)[t](0,n,!0),s}}function ge(e,t,n){return _(es(e,n),Zr(e,t))}var A=ge(1,"getUint8","setUint8"),ie=ge(2,"getUint16","setUint16"),Z=ge(4,"getUint32","setUint32"),Re=ge(8,"getBigUint64","setBigUint64"),zt=ge(1,"getInt8","setInt8"),Yt=ge(2,"getInt16","setInt16"),Gt=ge(4,"getInt32","setInt32"),Jt=ge(8,"getBigInt64","setBigInt64"),Qt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Zt=e=>Q(t=>{const{v:n,i:s}=t,r=n.getBigUint64(s,!0),o=n[e](s+8,!0);return t.i+=16,o<<64n|r}),en=_(Qt,Zt("getBigUint64")),tn=_(Qt,Zt("getBigInt64")),nn=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},rn=e=>Q(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),sn=_(nn,rn("getBigUint64")),on=_(nn,rn("getBigInt64")),cn=oe(A,e=>e?1:0,Boolean),ts=[A[1],ie[1],Z[1]],ns=Q(e=>{const t=e[e.i],n=t&3;if(n<3)return ts[n](e)>>>2;const s=(t>>>2)+4;e.i++;let r=0n;const o=s/8|0;let c=0n;for(let l=0;l<o;l++)r=Re[1](e)<<c|r,c+=64n;let i=s%8;return i>3&&(r=BigInt(Z[1](e))<<c|r,c+=32n,i-=4),i>1&&(r=BigInt(ie[1](e))<<c|r,c+=16n,i-=2),i&&(r=BigInt(A[1](e))<<c|r),r}),rs=1n<<56n,ss=1<<24,os=256,cs=4294967295n,is=64,as=16384,ls=1<<30,us=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<is)return A[0](t);if(e<as)return ie[0](t|1);if(e<ls)return Z[0](t|2);let n=[new Uint8Array(1)],s=BigInt(e);for(;s>=rs;)n.push(Re[0](s)),s>>=64n;s>=ss&&(n.push(Z[0](Number(s&cs))),s>>=32n);let r=Number(s);r>=os&&(n.push(ie[0](r)),r>>=16),r&&n.push(A[0](r));const o=se(n);return o[0]=o.length-5<<2|3,o},D=_(us,ns),hs=new TextEncoder,ds=e=>{const t=hs.encode(e);return se([D.enc(t.length),t])},fs=new TextDecoder,ps=Q(e=>{let t=D.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,fs.decode(n)}),k=_(ds,ps),ys=()=>{},gs=new Uint8Array(0),v=_(()=>gs,ys),an=e=>e===void 0?t=>se([D.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ln=e=>Q(t=>{const n=e===void 0?D.dec(t):e!==1/0?e:t.byteLength-t.i,s=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,s}),C=e=>_(an(e),ln(e));C.enc=an,C.dec=ln;var un=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),r=o=>s.get(o);return({tag:o,value:c})=>se([A.enc(r(o)),e[o](c)])},hn=(e,t)=>{const n=Object.keys(e),s=new Map(t?.map((r,o)=>[r,n[o]])??n.map((r,o)=>[o,r]));return Q(r=>{const o=A.dec(r),c=s.get(o),i=e[c];return{tag:c,value:i(r)}})},K=(e,...t)=>_(un(tt(e,([n])=>n),...t),hn(tt(e,([,n])=>n),...t));K.enc=un,K.dec=hn;var dn=e=>Q(t=>A[1](t)>0?e(t):void 0),fn=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,se([n,e(t)]))},X=e=>_(fn(e[0]),dn(e[1]));X.enc=fn,X.dec=dn;var pn=(e,t)=>Q(n=>{const s=A[1](n)===0,o=(s?e:t)(n);return{success:s,value:o}}),yn=(e,t)=>({success:n,value:s})=>se([A[0](n?0:1),(n?e:t)(s)]),Fe=(e,t)=>_(yn(e[0],t[0]),pn(e[1],t[1]));Fe.dec=pn,Fe.enc=yn;var gn=(...e)=>Q(t=>e.map(n=>n(t))),vn=(...e)=>t=>se(e.map((n,s)=>n(t[s]))),ee=(...e)=>_(vn(...e.map(([t])=>t)),gn(...e.map(([,t])=>t)));ee.enc=vn,ee.dec=gn;var mn=e=>{const t=Object.keys(e);return mt(ee.enc(...Object.values(e)),n=>t.map(s=>n[s]))},wn=e=>{const t=Object.keys(e);return wt(ee.dec(...Object.values(e)),n=>Object.fromEntries(n.map((s,r)=>[t[r],s])))},b=e=>_(mn(tt(e,t=>t[0])),wn(tt(e,t=>t[1])));b.enc=mn,b.dec=wn;var bn=(e,t)=>t>=0?n=>se(n.map(e)):n=>se([D.enc(n.length),se(n.map(e))]),xn=(e,t)=>Q(n=>{const s=t>=0?t:D.dec(n),r=new Array(s);for(let o=0;o<s;o++)r[o]=e(n);return r}),I=(e,t)=>_(bn(e[0],t),xn(e[1],t));I.enc=bn,I.dec=xn;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function En(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function bt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function In(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function xt(e){if(!Array.isArray(e))throw new Error("array expected")}function kn(e,t){if(!En(!0,t))throw new Error(`${e}: array of strings expected`)}function ms(e,t){if(!En(!1,t))throw new Error(`${e}: array of numbers expected`)}function ws(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),s=e.map(o=>o.encode).reduceRight(n,t),r=e.map(o=>o.decode).reduce(n,t);return{encode:s,decode:r}}function bs(e){const t=typeof e=="string"?e.split(""):e,n=t.length;kn("alphabet",t);const s=new Map(t.map((r,o)=>[r,o]));return{encode:r=>(xt(r),r.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:r=>(xt(r),r.map(o=>{bt("alphabet.decode",o);const c=s.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return c}))}}function xs(e=""){return bt("join",e),{encode:t=>(kn("join.decode",t),t.join(e)),decode:t=>(bt("join.decode",t),t.split(e))}}function Bn(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(xt(e),!e.length)return[];let s=0;const r=[],o=Array.from(e,i=>{if(In(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=o.length;for(;;){let i=0,l=!0;for(let a=s;a<c;a++){const d=o[a],y=t*i,u=y+d;if(!Number.isSafeInteger(u)||y/t!==i||u-d!==y)throw new Error("convertRadix: carry overflow");const h=u/n;i=u%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+i!==u)throw new Error("convertRadix: carry overflow");if(l)p?l=!1:s=a;else continue}if(r.push(i),l)break}for(let i=0;i<e.length-1&&e[i]===0;i++)r.push(0);return r.reverse()}function Es(e){In(e);const t=2**8;return{encode:n=>{if(!vs(n))throw new Error("radix.encode input should be Uint8Array");return Bn(Array.from(n),t,e)},decode:n=>(ms("radix.decode",n),Uint8Array.from(Bn(n,e,t)))}}const An=(e=>ws(Es(58),bs(e),xs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Is(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Me(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function te(e,t,n=""){const s=Is(e),r=e?.length,o=t!==void 0;if(!s||o&&r!==t){const c=n&&`"${n}" `,i=o?` of length ${t}`:"",l=s?`length=${r}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+i+", got "+l)}return e}function qe(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 Et(e,t){te(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function ks(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ae(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ve(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function nt(e,t){return e<<32-t|e>>>t}const On=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Un(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ae=On?e=>e:e=>Un(e);function Bs(e){for(let t=0;t<e.length;t++)e[t]=Un(e[t]);return e}const q=On?e=>e:Bs;function It(e,t={}){const n=(r,o)=>e(o).update(r).digest(),s=e(void 0);return n.outputLen=s.outputLen,n.blockLen=s.blockLen,n.create=r=>e(r),Object.assign(n,t),Object.freeze(n)}const As=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function me(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,16),n=n+s|0,t=nt(t^n,12),{a:e,b:t,c:n,d:s}}function we(e,t,n,s,r){return e=e+t+r|0,s=nt(s^e,8),n=n+s|0,t=nt(t^n,7),{a:e,b:t,c:n,d:s}}const Os=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=BigInt(2**32-1),_n=BigInt(32);function st(e,t=!1){return t?{h:Number(e&rt),l:Number(e>>_n&rt)}:{h:Number(e>>_n&rt)|0,l:Number(e&rt)|0}}function Us(e,t=!1){const n=e.length;let s=new Uint32Array(n),r=new Uint32Array(n);for(let o=0;o<n;o++){const{h:c,l:i}=st(e[o],t);[s[o],r[o]]=[c,i]}return[s,r]}const Sn=(e,t,n)=>e>>>n|t<<32-n,Tn=(e,t,n)=>e<<32-n|t>>>n,_s=(e,t,n)=>e<<64-n|t>>>n-32,Ss=(e,t,n)=>e>>>n-32|t<<64-n,Ts=(e,t)=>t,Ds=(e,t)=>e,Ls=(e,t,n)=>e<<n|t>>>32-n,Cs=(e,t,n)=>t<<n|e>>>32-n,Hs=(e,t,n)=>t<<n-32|e>>>64-n,Ms=(e,t,n)=>e<<n-32|t>>>64-n;function Dn(e,t,n,s){const r=(t>>>0)+(s>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Ln=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Cn=(e,t,n,s)=>t+n+s+(e/2**32|0)|0,H=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function be(e,t,n,s,r,o){const c=r[o],i=r[o+1];let l=g[2*e],a=g[2*e+1],d=g[2*t],y=g[2*t+1],u=g[2*n],h=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Ln(l,d,c);a=Cn(m,a,y,i),l=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^l},{Dh:f,Dl:p}={Dh:Ts(f,p),Dl:Ds(f)},{h,l:u}=Dn(h,u,f,p),{Bh:y,Bl:d}={Bh:y^h,Bl:d^u},{Bh:y,Bl:d}={Bh:Sn(y,d,24),Bl:Tn(y,d,24)},g[2*e]=l,g[2*e+1]=a,g[2*t]=d,g[2*t+1]=y,g[2*n]=u,g[2*n+1]=h,g[2*s]=p,g[2*s+1]=f}function xe(e,t,n,s,r,o){const c=r[o],i=r[o+1];let l=g[2*e],a=g[2*e+1],d=g[2*t],y=g[2*t+1],u=g[2*n],h=g[2*n+1],p=g[2*s],f=g[2*s+1],m=Ln(l,d,c);a=Cn(m,a,y,i),l=m|0,{Dh:f,Dl:p}={Dh:f^a,Dl:p^l},{Dh:f,Dl:p}={Dh:Sn(f,p,16),Dl:Tn(f,p,16)},{h,l:u}=Dn(h,u,f,p),{Bh:y,Bl:d}={Bh:y^h,Bl:d^u},{Bh:y,Bl:d}={Bh:_s(y,d,63),Bl:Ss(y,d,63)},g[2*e]=l,g[2*e+1]=a,g[2*t]=d,g[2*t+1]=y,g[2*n]=u,g[2*n+1]=h,g[2*s]=p,g[2*s+1]=f}function Vs(e,t={},n,s,r){if(Me(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:c,personalization:i}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error('"key" expected to be undefined or of length=1..'+n);c!==void 0&&te(c,s,"salt"),i!==void 0&&te(i,r,"personalization")}class Hn{buffer;buffer32;finished=!1;destroyed=!1;length=0;pos=0;blockLen;outputLen;constructor(t,n){Me(t),Me(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Ae(this.buffer)}update(t){qe(this),te(t);const{blockLen:n,buffer:s,buffer32:r}=this,o=t.length,c=t.byteOffset,i=t.buffer;for(let l=0;l<o;){this.pos===n&&(q(r),this.compress(r,0,!1),q(r),this.pos=0);const a=Math.min(n-this.pos,o-l),d=c+l;if(a===n&&!(d%4)&&l+a<o){const y=new Uint32Array(i,d,Math.floor((o-l)/4));q(y);for(let u=0;l+n<o;u+=r.length,l+=n)this.length+=n,this.compress(y,u,!1);q(y);continue}s.set(t.subarray(l,l+a),this.pos),this.pos+=a,this.length+=a,l+=a}return this}digestInto(t){qe(this),Et(t,this);const{pos:n,buffer32:s}=this;this.finished=!0,ve(this.buffer.subarray(n)),q(s),this.compress(s,0,!0),q(s);const r=Ae(t);this.get().forEach((o,c)=>r[c]=ae(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const s=t.slice(0,n);return this.destroy(),s}_cloneInto(t){const{buffer:n,length:s,finished:r,destroyed:o,outputLen:c,pos:i}=this;return t||=new this.constructor({dkLen:c}),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=r,t.length=s,t.pos=i,t.outputLen=c,t}clone(){return this._cloneInto()}}class $s extends Hn{v0l=H[0]|0;v0h=H[1]|0;v1l=H[2]|0;v1h=H[3]|0;v2l=H[4]|0;v2h=H[5]|0;v3l=H[6]|0;v3h=H[7]|0;v4l=H[8]|0;v4h=H[9]|0;v5l=H[10]|0;v5h=H[11]|0;v6l=H[12]|0;v6h=H[13]|0;v7l=H[14]|0;v7h=H[15]|0;constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),Vs(n,t,64,16,16);let{key:s,personalization:r,salt:o}=t,c=0;if(s!==void 0&&(te(s,void 0,"key"),c=s.length),this.v0l^=this.outputLen|c<<8|65536|1<<24,o!==void 0){te(o,void 0,"salt");const i=Ae(o);this.v4l^=ae(i[0]),this.v4h^=ae(i[1]),this.v5l^=ae(i[2]),this.v5h^=ae(i[3])}if(r!==void 0){te(r,void 0,"personalization");const i=Ae(r);this.v6l^=ae(i[0]),this.v6h^=ae(i[1]),this.v7l^=ae(i[2]),this.v7h^=ae(i[3])}if(s!==void 0){const i=new Uint8Array(this.blockLen);i.set(s),this.update(i)}}get(){let{v0l:t,v0h:n,v1l:s,v1h:r,v2l:o,v2h:c,v3l:i,v3h:l,v4l:a,v4h:d,v5l:y,v5h:u,v6l:h,v6h:p,v7l:f,v7h:m}=this;return[t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m]}set(t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m){this.v0l=t|0,this.v0h=n|0,this.v1l=s|0,this.v1h=r|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=l|0,this.v4l=a|0,this.v4h=d|0,this.v5l=y|0,this.v5h=u|0,this.v6l=h|0,this.v6h=p|0,this.v7l=f|0,this.v7h=m|0}compress(t,n,s){this.get().forEach((l,a)=>g[a]=l),g.set(H,16);let{h:r,l:o}=st(BigInt(this.length));g[24]=H[8]^o,g[25]=H[9]^r,s&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=As;for(let l=0;l<12;l++)be(0,4,8,12,t,n+2*i[c++]),xe(0,4,8,12,t,n+2*i[c++]),be(1,5,9,13,t,n+2*i[c++]),xe(1,5,9,13,t,n+2*i[c++]),be(2,6,10,14,t,n+2*i[c++]),xe(2,6,10,14,t,n+2*i[c++]),be(3,7,11,15,t,n+2*i[c++]),xe(3,7,11,15,t,n+2*i[c++]),be(0,5,10,15,t,n+2*i[c++]),xe(0,5,10,15,t,n+2*i[c++]),be(1,6,11,12,t,n+2*i[c++]),xe(1,6,11,12,t,n+2*i[c++]),be(2,7,8,13,t,n+2*i[c++]),xe(2,7,8,13,t,n+2*i[c++]),be(3,4,9,14,t,n+2*i[c++]),xe(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],ve(g)}destroy(){this.destroyed=!0,ve(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ot=It(e=>new $s(e));function Mn(e,t,n,s,r,o,c,i,l,a,d,y,u,h,p,f,m,x,B,S){let T=0;for(let J=0;J<s;J++)({a:r,b:l,c:u,d:m}=me(r,l,u,m,n[t+e[T++]])),{a:r,b:l,c:u,d:m}=we(r,l,u,m,n[t+e[T++]]),{a:o,b:a,c:h,d:x}=me(o,a,h,x,n[t+e[T++]]),{a:o,b:a,c:h,d:x}=we(o,a,h,x,n[t+e[T++]]),{a:c,b:d,c:p,d:B}=me(c,d,p,B,n[t+e[T++]]),{a:c,b:d,c:p,d:B}=we(c,d,p,B,n[t+e[T++]]),{a:i,b:y,c:f,d:S}=me(i,y,f,S,n[t+e[T++]]),{a:i,b:y,c:f,d:S}=we(i,y,f,S,n[t+e[T++]]),{a:r,b:a,c:p,d:S}=me(r,a,p,S,n[t+e[T++]]),{a:r,b:a,c:p,d:S}=we(r,a,p,S,n[t+e[T++]]),{a:o,b:d,c:f,d:m}=me(o,d,f,m,n[t+e[T++]]),{a:o,b:d,c:f,d:m}=we(o,d,f,m,n[t+e[T++]]),{a:c,b:y,c:u,d:x}=me(c,y,u,x,n[t+e[T++]]),{a:c,b:y,c:u,d:x}=we(c,y,u,x,n[t+e[T++]]),{a:i,b:l,c:h,d:B}=me(i,l,h,B,n[t+e[T++]]),{a:i,b:l,c:h,d:B}=we(i,l,h,B,n[t+e[T++]]);return{v0:r,v1:o,v2:c,v3:i,v4:l,v5:a,v6:d,v7:y,v8:u,v9:h,v10:p,v11:f,v12:m,v13:x,v14:B,v15:S}}const Vn=new TextEncoder().encode("SS58PRE"),kt=2,$n=e=>{try{const t=An.decode(e),n=t.subarray(0,t[0]&64?2:1),s=t.subarray(n.length,t.length-kt),r=t.subarray(n.length+s.length),o=ot(Uint8Array.of(...Vn,...n,...s),{dkLen:64}).subarray(0,kt);return r[0]===o[0]&&r[1]===o[1]?{isValid:!0,ss58Format:Ps(n),publicKey:s.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ps=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ns=e=>{let t={},n=0,s=0;const r=()=>{n===s?(t={},n=s=0):(s=n,setTimeout(r,0))};return o=>{var c,i;++n===1&&r();let l=t;const a=o.length-1;for(let d=0;d<=a;d++)l=l[c=o[d]]||(l[c]={});return l[i=o[a]]||(l[i]=e(o))}},Pn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return Ns(n=>{const s=ot(Uint8Array.of(...Vn,...t,...n),{dkLen:64}).subarray(0,kt);return An.encode(Uint8Array.of(...t,...n,...s))})};function Rs(e,t){return n=>{const s=$n(n);if(!s.isValid)throw new Error("Invalid checksum");const{publicKey:r}=s;if(r.length!==e)throw new Error("Invalid public key length");return r}}const ct=(e=42,t=32)=>oe(C(t),Rs(t),Pn(e));var Fs=Object.defineProperty,Nn=e=>{throw TypeError(e)},qs=(e,t,n)=>t in e?Fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,je=(e,t,n)=>qs(e,typeof t!="symbol"?t+"":t,n),Rn=(e,t,n)=>t.has(e)||Nn("Cannot "+n),le=(e,t,n)=>(Rn(e,t,"read from private field"),n?n.call(e):t.get(e)),We=(e,t,n)=>t.has(e)?Nn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Oe=(e,t,n,s)=>(Rn(e,t,"write to private field"),t.set(e,n),n),ue,Ke,it,at,lt;const js=new TextEncoder,Ws=new TextDecoder,Ks=ee(D,C(1/0))[1];class Xe{constructor(t,n=!1){if(We(this,ue),We(this,Ke,null),We(this,it,null),We(this,at,null),We(this,lt,null),je(this,"asText",()=>le(this,lt)??Oe(this,lt,Ws.decode(le(this,ue)))),je(this,"asHex",()=>le(this,it)??Oe(this,it,re(le(this,ue)))),je(this,"asOpaqueHex",()=>le(this,at)??Oe(this,at,re(this.asOpaqueBytes()))),je(this,"asBytes",()=>le(this,ue)),je(this,"asOpaqueBytes",()=>le(this,Ke)??Oe(this,Ke,N([D[0](le(this,ue).length),le(this,ue)]))),n){try{const[s,r]=Ks(t);if(s===r.length){Oe(this,ue,r),Oe(this,Ke,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Oe(this,ue,t)}static fromText(t){return new this(js.encode(t))}static fromHex(t){return new this(He(t))}static fromOpaqueHex(t){return new this(He(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}ue=new WeakMap,Ke=new WeakMap,it=new WeakMap,at=new WeakMap,lt=new WeakMap;const[Xs]=ct();class Fn extends Xe{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Xs(t))}}const qn=e=>{const t=C.enc(e);return n=>t(n.asBytes())},jn=e=>{const t=C.dec(e),n=e==null?Xe:Fn;return s=>n.fromBytes(t(s))},ze=e=>_(qn(e),jn(e));ze.enc=qn,ze.dec=jn;const w=oe(D,e=>e,Number),Wn=oe(D,e=>e,BigInt),zs=Be(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:C(n).dec(e),bitsLen:t}}),Ys=_(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},zs),Gs=oe(A,e=>e.charCodeAt(0),String.fromCharCode),Kn=e=>{const t=C.enc(e);return n=>t(He(n))},Xn=e=>{const t=C.dec(e);return n=>re(t(n))},j=e=>_(Kn(e),Xn(e));j.enc=Kn,j.dec=Xn;const zn=new TextEncoder,Js=new TextDecoder,Qs=e=>oe(C(e),t=>zn.encode(t),t=>Js.decode(t)),Yn=e=>{let t=n=>{const s=e();return t=s,s(n)};return n=>t(n)},Gn=e=>{let t=n=>{const s=e(),r=s;return t=s,r(n)};return n=>t(n)},Jn=e=>_(Yn(()=>e().enc),Gn(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Zs=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),L=(e,t)=>{const n=e;return n.inner=t,n},Qn=(...e)=>{const t=K.enc(...e);return L(n=>t({tag:n.type,value:n.value}),e[0])},Zn=(...e)=>{const t=K.dec(...e);return L(n=>{const{tag:s,value:r}=t(n);return Bt(s,r)},e[0])},Ve=(e,...t)=>L(_(Qn(gt(e,([n])=>n),...t),Zn(gt(e,([,n])=>n),...t)),e);Ve.enc=Qn,Ve.dec=Zn;const Ue=(e,...t)=>L(K(e,...t),e);Ue.enc=(e,...t)=>L(K.enc(e,...t),e),Ue.dec=(e,...t)=>L(K.dec(e,...t),e);const ce={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},he=Os.slice(),er=(()=>{const e=Array.from({length:16},(s,r)=>r),t=s=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(r=>s[r]),n=[];for(let s=0,r=e;s<7;s++,r=t(r))n.push(...r);return Uint8Array.from(n)})();class At extends Hn{chunkPos=0;chunksDone=0;flags=0;IV;state;stack=[];posOut=0;bufferOut32=new Uint32Array(16);bufferOut;chunkOut=0;enableXOF=!0;constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen);const{key:s,context:r}=t,o=r!==void 0;if(s!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');te(s,32,"key");const c=s.slice();this.IV=Ae(c),q(this.IV),this.flags=n|ce.KEYED_HASH}else if(o){te(r,void 0,"context");const c=r,i=new At({dkLen:32},ce.DERIVE_KEY_CONTEXT).update(c).digest();this.IV=Ae(i),q(this.IV),this.flags=n|ce.DERIVE_KEY_MATERIAL}else this.IV=he.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=ks(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,s,r=0){const{state:o,pos:c}=this,{h:i,l}=st(BigInt(t),!0),{v0:a,v1:d,v2:y,v3:u,v4:h,v5:p,v6:f,v7:m,v8:x,v9:B,v10:S,v11:T,v12:J,v13:ne,v14:pe,v15:M}=Mn(er,r,s,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],he[0],he[1],he[2],he[3],i,l,c,n);o[0]=a^x,o[1]=d^B,o[2]=y^S,o[3]=u^T,o[4]=h^J,o[5]=p^ne,o[6]=f^pe,o[7]=m^M}compress(t,n=0,s=!1){let r=this.flags;if(this.chunkPos||(r|=ce.CHUNK_START),(this.chunkPos===15||s)&&(r|=ce.CHUNK_END),s||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,r,t,n),this.chunkPos+=1,this.chunkPos===16||s){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(s||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ce.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:s,state:r,chunkPos:o,posOut:c,chunkOut:i,stack:l,chunksDone:a}=this;return t.state.set(r.slice()),t.stack=l.map(d=>Uint32Array.from(d)),t.IV.set(n),t.flags=s,t.chunkPos=o,t.chunksDone=a,t.posOut=c,t.chunkOut=i,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,ve(this.state,this.buffer32,this.IV,this.bufferOut32),ve(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:s,buffer32:r,bufferOut32:o}=this,{h:c,l:i}=st(BigInt(this.chunkOut++));q(r);const{v0:l,v1:a,v2:d,v3:y,v4:u,v5:h,v6:p,v7:f,v8:m,v9:x,v10:B,v11:S,v12:T,v13:J,v14:ne,v15:pe}=Mn(er,0,r,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],he[0],he[1],he[2],he[3],i,c,n,s);o[0]=l^m,o[1]=a^x,o[2]=d^B,o[3]=y^S,o[4]=u^T,o[5]=h^J,o[6]=p^ne,o[7]=f^pe,o[8]=t[0]^m,o[9]=t[1]^x,o[10]=t[2]^B,o[11]=t[3]^S,o[12]=t[4]^T,o[13]=t[5]^J,o[14]=t[6]^ne,o[15]=t[7]^pe,q(r),q(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ve(this.buffer.subarray(this.pos));let t=this.flags|ce.ROOT;this.stack.length?(t|=ce.PARENT,q(this.buffer32),this.compress(this.buffer32,0,!0),q(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ce.CHUNK_START)|ce.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){qe(this,!1),te(t),this.finish();const{blockLen:n,bufferOut:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-r);t.set(s.subarray(this.posOut,this.posOut+c),r),this.posOut+=c,r+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Et(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const eo=It((e={})=>new At(e)),to=BigInt(0),Ye=BigInt(1),no=BigInt(2),ro=BigInt(7),so=BigInt(256),oo=BigInt(113),tr=[],nr=[],rr=[];for(let e=0,t=Ye,n=1,s=0;e<24;e++){[n,s]=[s,(2*n+3*s)%5],tr.push(2*(5*s+n)),nr.push((e+1)*(e+2)/2%64);let r=to;for(let o=0;o<7;o++)t=(t<<Ye^(t>>ro)*oo)%so,t&no&&(r^=Ye<<(Ye<<BigInt(o))-Ye);rr.push(r)}const sr=Us(rr,!0),co=sr[0],io=sr[1],or=(e,t,n)=>n>32?Hs(e,t,n):Ls(e,t,n),cr=(e,t,n)=>n>32?Ms(e,t,n):Cs(e,t,n);function ao(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,l=(c+2)%10,a=n[l],d=n[l+1],y=or(a,d,1)^n[i],u=cr(a,d,1)^n[i+1];for(let h=0;h<50;h+=10)e[c+h]^=y,e[c+h+1]^=u}let r=e[2],o=e[3];for(let c=0;c<24;c++){const i=nr[c],l=or(r,o,i),a=cr(r,o,i),d=tr[c];r=e[d],o=e[d+1],e[d]=l,e[d+1]=a}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=co[s],e[1]^=io[s]}ve(n)}class Ot{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,n,s,r=!1,o=24){if(this.blockLen=t,this.suffix=n,this.outputLen=s,this.enableXOF=r,this.rounds=o,Me(s,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ae(this.state)}clone(){return this._cloneInto()}keccak(){q(this.state32),ao(this.state32,this.rounds),q(this.state32),this.posOut=0,this.pos=0}update(t){qe(this),te(t);const{blockLen:n,state:s}=this,r=t.length;for(let o=0;o<r;){const c=Math.min(n-this.pos,r-o);for(let i=0;i<c;i++)s[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:s,blockLen:r}=this;t[s]^=n,(n&128)!==0&&s===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){qe(this,!1),te(t),this.finish();const n=this.state,{blockLen:s}=this;for(let r=0,o=t.length;r<o;){this.posOut>=s&&this.keccak();const c=Math.min(s-this.posOut,o-r);t.set(n.subarray(this.posOut,this.posOut+c),r),this.posOut+=c,r+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Me(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Et(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ve(this.state)}_cloneInto(t){const{blockLen:n,suffix:s,outputLen:r,rounds:o,enableXOF:c}=this;return t||=new Ot(n,s,r,c,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=s,t.outputLen=r,t.enableXOF=c,t.destroyed=this.destroyed,t}}const ir=((e,t,n,s={})=>It(()=>new Ot(t,e,n),s))(1,136,32),ar=e=>{const t=e.slice(2),n=re(ir(zn.encode(t))).slice(2),s=new Array(40);for(let r=0;r<40;r++){const o=parseInt(n[r],16),c=t[r];s[r]=o>7?c.toUpperCase():c}return`0x${s.join("")}`},lo=C(20)[1],lr=_(e=>{const t=He(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=re(t);if(e===n||e===n.toUpperCase())return t;if(ar(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Be(e=>ar(re(lo(e))))),R=e=>L(b(e),e);R.enc=e=>L(b.enc(e),e),R.dec=e=>L(b.dec(e),e);const de=(...e)=>L(ee(...e),e);de.enc=(...e)=>L(ee.enc(...e),e),de.dec=(...e)=>L(ee.dec(...e),e);const W=(e,...t)=>L(I(e,...t),e);W.enc=(e,...t)=>L(I.enc(e,...t),e),W.dec=(e,...t)=>L(I.dec(e,...t),e);const ut=(e,t)=>L(Fe(e,t),{ok:e,ko:t});ut.enc=(e,t)=>L(Fe.enc(e,t),{ok:e,ko:t}),ut.dec=(e,t)=>L(Fe.dec(e,t),{ok:e,ko:t});const $e=e=>L(X(e),e);$e.enc=e=>L(X.enc(e),e),$e.dec=e=>L(X.dec(e),e);const ur=(e=!0)=>Be(t=>{const n=w.dec(t),s=Math.ceil(n/8),r=C(s).dec(t),o=new Array(n);let c=0;return r.forEach(i=>{for(let l=0;l<8&&c<n;l++){const a=e?l:7-l;o[c++]=i>>a&1}}),o}),hr=(e=!0)=>t=>{const n=w.enc(t.length),s=Math.ceil(t.length/8),r=new Uint8Array(s);for(let o=0;o<s;o++){let c=o*8,i=0;for(let l=0;l<8&&c<t.length;l++,c++)i|=t[c]<<(e?l:7-l);r[o]=i}return N([n,r])},ht=e=>_(hr(e),ur(e));ht.enc=hr,ht.dec=ur;const dr=new TextEncoder,fr=new TextDecoder,uo=oe(C(4),dr.encode.bind(dr),fr.decode.bind(fr)),Ut=R({engine:uo,payload:j()}),ho=Ve({other:C(),consensus:Ut,seal:Ut,preRuntime:Ut,runtimeUpdated:v},[0,4,5,6,8]),_t=j(32),fo=R({parentHash:_t,number:w,stateRoot:_t,extrinsicRoot:_t,digests:W(ho)}),Y=I(k),pr=X(k),po=K({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v}),yr=I(b({name:pr,type:w,typeName:pr,docs:Y})),yo=b({len:Z,type:w}),go=b({bitStoreType:w,bitOrderType:w}),vo=I(b({name:k,fields:yr,index:A,docs:Y})),mo=K({composite:yr,variant:vo,sequence:w,array:yo,tuple:I(w),primitive:po,compact:w,bitSequence:go}),wo=b({name:k,type:X(w)}),bo=I(wo),xo=b({id:w,path:Y,params:bo,def:mo,docs:Y}),dt=I(xo),Pe=K({NotDeprecated:v,DeprecatedWithoutNote:v,Deprecated:b({note:k,since:X(k)})}),Eo=I(b({index:A,deprecation:K({DeprecatedWithoutNote:v,Deprecated:b({note:k,since:X(k)})},[1,2])})),St={name:k,inputs:I(b({name:k,type:w})),output:w,docs:Y},Io=b({name:k,methods:I(b(St)),docs:Y}),ko=b({name:k,methods:I(b({...St,deprecationInfo:Pe})),docs:Y,version:w,deprecationInfo:Pe}),Bo=b({id:j(32),...St,deprecationInfo:Pe}),Ao=K({Blake2128:v,Blake2256:v,Blake2128Concat:v,Twox128:v,Twox256:v,Twox64Concat:v,Identity:v}),Oo=I(Ao),Uo=b({hashers:Oo,key:w,value:w}),gr={name:k,modifier:A,type:K({plain:w,map:Uo}),fallback:j(),docs:Y},Tt=X(w),vr={name:k,storage:X(b({prefix:k,items:I(b(gr))})),calls:Tt,events:Tt,constants:I(b({name:k,type:w,value:j(),docs:Y})),errors:Tt,index:A},_o={...vr,docs:Y},Dt=X(b({type:w,deprecationInfo:Eo})),So={name:k,storage:X(b({prefix:k,items:I(b({...gr,deprecationInfo:Pe}))})),calls:Dt,events:Dt,constants:I(b({name:k,type:w,value:j(),docs:Y,deprecationInfo:Pe})),errors:Dt,associatedTypes:I(b({name:k,type:w,docs:Y})),viewFns:I(Bo),index:A,docs:Y,deprecationInfo:Pe},To=new Uint8Array,mr=e=>_(()=>To,()=>e),Do=b({type:w,version:A,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),wr=b({lookup:dt,pallets:I(b({...vr,docs:mr([])})),extrinsic:Do,type:w,apis:mr([])}),Lo=b({version:A,address:w,call:w,signature:w,extra:w,signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),br=b({lookup:dt,pallets:I(b(_o)),extrinsic:Lo,type:w,apis:I(Io),outerEnums:b({call:w,event:w,error:w}),custom:I(ee(k,b({type:w,value:j()})))}),Co=b({version:I(A),address:w,call:w,signature:w,signedExtensionsByVersion:I(ee(A,I(w))),signedExtensions:I(b({identifier:k,type:w,additionalSigned:w}))}),xr=b({lookup:dt,pallets:I(b(So)),extrinsic:Co,apis:I(ko),outerEnums:b({call:w,event:w,error:w}),custom:I(ee(k,b({type:w,value:j()})))}),Er=()=>{throw new Error("Unsupported metadata version!")},z=_(Er,Er),Ge=b({magicNumber:Z,metadata:K({v0:z,v1:z,v2:z,v3:z,v4:z,v5:z,v6:z,v7:z,v8:z,v9:z,v10:z,v11:z,v12:z,v13:z,v14:wr,v15:br,v16:xr})}),Lt=C(),Ho=X(Lt),Mo=ee(D,Lt),Ct=e=>{try{return Ge.dec(e)}catch{}try{return Ge.dec(Ho.dec(e))}catch{}try{return Ge.dec(Lt.dec(e))}catch{}try{return Ge.dec(Mo.dec(e)[1])}catch{}throw null},Ht=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:r,extrinsic:o,custom:c,apis:i,pallets:l,outerEnums:a}=e;return{version:15,lookup:r,pallets:l.map(d=>({...d,calls:d.calls!=null?{type:d.calls}:void 0,events:d.events!=null?{type:d.events}:void 0,errors:d.errors!=null?{type:d.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:i,outerEnums:a,custom:c}}const{lookup:t,extrinsic:n,pallets:s}=e;return{version:14,lookup:t,pallets:s.map(r=>({...r,calls:r.calls!=null?{type:r.calls}:void 0,events:r.events!=null?{type:r.events}:void 0,errors:r.errors!=null?{type:r.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},_e={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Mt=oe(A,({version:e,type:t})=>e+(_e[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===_e.bare||n===_e.signed))return{version:t,type:_e[n]};if(t===5&&(n===_e.bare||n===_e.general))return{version:t,type:_e[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Vo={dkLen:32},Je=e=>ot(e,Vo),$o={dkLen:16},Vt=e=>ot(e,$o),Ir=e=>N([Vt(e),e]),Po={dkLen:32},Ne=e=>eo(e,Po),No=e=>N([Ne(e),e]),kr=e=>e,Se=(e,t,n,s)=>new DataView(new Uint16Array([e,t,n,s]).buffer).getBigUint64(0,!0),$t=2n**64n-1n,F=(e,t)=>e<<t&$t|e>>64n-t,O=(e,t)=>e*t&$t,$=(e,t)=>e+t&$t,P=11400714785074694791n,G=14029467366897019727n,Br=1609587929392839161n,Qe=9650029242287828579n,Ar=2870177450012600261n;function Ee(e,t=0n){let n=$($(t,P),G),s=$(t,G),r=t,o=t-P,c=e.length,i=0,l=null;(function(){let h=0,p=h+c;if(c){if(l=new Uint8Array(32),c<32){l.set(e.subarray(0,c),i),i+=c;return}if(h<=p-32){const f=p-32;do{let m;m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=O(F($(n,O(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=O(F($(s,O(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=O(F($(r,O(m,G)),31n),P),h+=8,m=Se(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),o=O(F($(o,O(m,G)),31n),P),h+=8}while(h<=f)}h<p&&(l.set(e.subarray(h,p),i),i=p-h)}})(),e=l||e;let a,d=0;for(c>=32?(a=F(n,1n),a=$(a,F(s,7n)),a=$(a,F(r,12n)),a=$(a,F(o,18n)),n=O(F(O(n,G),31n),P),a=a^n,a=$(O(a,P),Qe),s=O(F(O(s,G),31n),P),a=a^s,a=$(O(a,P),Qe),r=O(F(O(r,G),31n),P),a=a^r,a=$(O(a,P),Qe),o=O(F(O(o,G),31n),P),a=a^o,a=$(O(a,P),Qe)):a=$(t,Ar),a=$(a,BigInt(c));d<=i-8;){let u=Se(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]);u=O(F(O(u,G),31n),P),a=$(O(F(a^u,27n),P),Qe),d+=8}if(d+4<=i){let u=O(Se(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],0,0),P);a=$(O(F(a^u,23n),G),Br),d+=4}for(;d<i;){const u=O(Se(e[d++],0,0,0),Ar);a=O(F(a^u,11n),P)}let y=a>>33n;return a=O(a^y,G),y=a>>29n,a=O(a^y,Br),y=a>>32n,a^=y,a}const ft=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),t},Or=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Ee(e),!0),n.setBigUint64(8,Ee(e,1n),!0),n.setBigUint64(16,Ee(e,2n),!0),n.setBigUint64(24,Ee(e,3n),!0),t},Ur=e=>N([Re.enc(Ee(e)),e]),_r=new TextEncoder,Ro=new Map([[kr,0],[Ur,8],[Ir,16],[Vt,-16],[Je,-32],[ft,-16],[Or,-32]]),Sr=e=>{const t=ft(_r.encode(e));return(n,...s)=>{const r=N([t,ft(_r.encode(n))]),o=re(r),c=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=He(a.slice(o.length)),y=new Array(s.length);for(let u=0,h=0;u<s.length;u++){const[p,f]=s[u],m=Ro.get(f);if(m==null)throw new Error("Unknown hasher");if(m<0){const x=m*-1;y[u]=re(d.slice(h,h+x)),h+=x}else h+=m,y[u]=p.dec(d.slice(h)),h+=p.enc(y[u]).length}return y},i=s.map(([{enc:a},d])=>y=>d(a(y)));return{enc:(...a)=>re(N([r,...a.map((d,y)=>i[y](d))])),dec:c}}},Fo=Xe.fromText("modlpy/utilisuba").asBytes(),qo=({threshold:e,signatories:t})=>{const n=Tr(t),s=N([Fo,D.enc(n.length),...n,ie.enc(e)]);return Je(s)},Tr=e=>e.slice().sort((t,n)=>{for(let s=0;;s++){const r=s>=t.length,o=s>=n.length;if(r&&o)return 0;if(r)return-1;if(o)return 1;if(t[s]!==n[s])return t[s]>n[s]?1:-1}}),Ie={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Dr=j().dec,jo=j(1/0).dec,Wo=j(32).dec,Lr=A.dec,Ko=e=>{const t=Lr(e);let n=6;const s=t>>n,r=s?s===1?Ie.Leaf:s===2?Ie.Branch:Ie.BranchWithVal:t>>--n?Ie.LeafWithHash:t>>--n?Ie.BranchWithHash:t?Ie.Reserved:Ie.Empty;let o=t&255>>8-n;if(o===2**n-1){let c;do o+=c=Lr(e);while(c===255)}return{type:r,partialKey:j(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Cr=Be(e=>{const t=Ko(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:jo(e)};const s=ie.dec(e),r=[];for(let i=0;i<16;i++)s>>i&1&&r.push(i.toString(16));let o=null;n==="BranchWithVal"&&(o=Dr(e)),n==="BranchWithHash"&&(o=Wo(e));const c={...t,children:Object.fromEntries(r.map(i=>[i,Dr(e)]))};return o!==null&&(c.value=o),c}),Hr=e=>Be(t=>{const n=re(e(new Uint8Array(t.buffer)));try{return{hash:n,...Cr(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Mr=Object.freeze({__proto__:null,AccountId:ct,Bin:ze,Binary:Xe,BitSeq:ht,Blake2128:Vt,Blake2128Concat:Ir,Blake2256:Je,Blake3256:Ne,Blake3256Concat:No,Bytes:C,Enum:Bt,FixedSizeBinary:Fn,Hex:j,Identity:kr,Keccak256:ir,Option:$e,Result:ut,ScaleEnum:Ue,Self:Jn,Storage:Sr,Struct:R,TrieNodeHeaders:Ie,TrieNodeWithHash:Hr,Tuple:de,Twox128:ft,Twox256:Or,Twox64Concat:Ur,Variant:Ve,Vector:W,_Enum:Zs,_void:v,bitSequence:Ys,blockHeader:fo,bool:cn,char:Gs,compact:D,compactBn:Wn,compactNumber:w,createCodec:_,createDecoder:Be,decAnyMetadata:Ct,enhanceCodec:oe,enhanceDecoder:wt,enhanceEncoder:mt,ethAccount:lr,extrinsicFormat:Mt,fixedStr:Qs,fromBufferToBase58:Pn,getMultisigAccountId:qo,getSs58AddressInfo:$n,h64:Ee,i128:tn,i16:Yt,i256:on,i32:Gt,i64:Jt,i8:zt,metadata:Ge,selfDecoder:Gn,selfEncoder:Yn,sortMultisigSignatories:Tr,str:k,trieNodeDec:Cr,u128:en,u16:ie,u256:sn,u32:Z,u64:Re,u8:A,unifyMetadata:Ht,v14:wr,v14Lookup:dt,v15:br,v16:xr,validateProofs:(e,t=Je)=>{const n=e.map(Hr(t)),s=Object.fromEntries(n.map(i=>[i.hash,i])),r=n.map(i=>i.hash),o=new Set(r),c=i=>{if(i.value)return;const l=e[r.indexOf(i.hash)];i.value=typeof l=="string"?l:re(l)};return n.forEach(i=>{if("children"in i&&Object.values(i.children).forEach(l=>{const a=s[l];a&&(a.parent=i.hash,o.delete(l))}),i.type==="BranchWithHash"||i.type==="LeafWithHash"){const l=i.value,a=s[l];if(!a)return;o.delete(l),a.type!=="Raw"&&(Object.keys(a).forEach(d=>delete a[d]),a.type="Raw",a.hash=l),a.parent=i.hash,c(a)}i.type==="Raw"&&c(i)}),o.size===1?{rootHash:o.values().next().value,proofs:s}:null}});const Vr=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ke={type:"void"},Xo=(e,t=()=>null)=>{const n=new Map,s=new Set,r=d=>y=>{let u=n.get(y);if(u)return u;if(s.has(y)){const p={id:y};return n.set(y,p),p}s.add(y);const h=d(y);return u=n.get(y),u?Object.assign(u,h):(u={id:y,...h},n.set(y,u)),s.delete(y),u};let o=!0,c=!0;const i=r(d=>{const y=t(e[d]);if(y)return y;const{def:u,path:h,params:p}=e[d];if(u.tag==="composite"){if(u.value.length===0)return ke;if(u.value.length===1){const f=i(u.value[0].type);return o&&h.at(-1)==="AccountId32"&&Vr(f,32)?(o=!1,{type:"AccountId32"}):c&&h.at(-1)==="AccountId20"&&Vr(f,20)?(c=!1,{type:"AccountId20"}):f}return l(u.value)}if(u.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const x=i(p[0].type);return x.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:x}}if(h.length===1&&h[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:i(p[0].type),ko:i(p[1].type)}};if(u.value.length===0)return ke;const f={},m={};return u.value.forEach(x=>{const B=x.name;if(m[B]=x.docs,x.fields.length===0){f[B]={...ke,idx:x.index};return}if(x.fields.length===1&&!x.fields[0].name){f[B]={type:"lookupEntry",value:i(x.fields[0].type),idx:x.index};return}f[B]={...l(x.fields),idx:x.index}}),{type:"enum",value:f,innerDocs:m}}if(u.tag==="sequence")return{type:"sequence",value:i(u.value)};if(u.tag==="array"){const{len:f}=u.value,m=i(u.value.type);return!f||m.type==="void"?ke:f>1?{type:"array",value:m,len:u.value.len}:m}if(u.tag==="tuple")return u.value.length===0?ke:u.value.length>1?a(u.value.map(f=>i(f)),u.value.map(f=>e[f].docs)):i(u.value[0]);if(u.tag==="primitive")return{type:"primitive",value:u.value.tag};if(u.tag==="compact"){const f=i(u.value);return f.type==="void"?ke:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:u.tag,isLSB:(e[u.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),l=d=>{let y=!0;const u={},h={};return d.forEach((p,f)=>{y=y&&!!p.name;const m=p.name||f,x=i(p.type);x.type!=="void"&&(u[m]=x,h[m]=p.docs)}),y?{type:"struct",value:u,innerDocs:h}:a(Object.values(u),Object.values(h))},a=(d,y)=>{if(d.every(u=>u.id===d[0].id)&&y.every(u=>!u.length)){const[u]=d;return u.type==="void"?ke:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:y}};return i},$r=e=>{const t=Xo(e.lookup,({def:r})=>{if(r.tag==="composite"){const o=n(r);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(c=>[c.name,c.errors==null?{...ke,idx:c.index}:{type:"lookupEntry",value:t(c.errors.type),idx:c.index}])),byteLength:o}}return null});function n(r){if(!(r.value.length===2&&r.value[0].name==="index"&&r.value[1].name==="error"))return null;const c=t(r.value[0].type),i=t(r.value[1].type);return c.type==="primitive"&&c.value==="u8"&&i.type==="array"&&i.value.type==="primitive"&&i.value.value==="u8"?1+i.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(c=>c.name==="Call")?.type??null})},zo=(e,t,n)=>(s,r,o,...c)=>{const{id:i}=s;if(r.has(i))return r.get(i);if(o.has(i)){const a=t(()=>r.get(i),s,...c);return r.set(i,a),a}o.add(i);let l=e(s,r,o,...c);return o.delete(i),r.has(i)&&(l=n(l,r.get(i),s,...c)),r.set(i,l),l},Yo=ze(),Pr=zo((e,t,n,s)=>{if(e.type==="primitive")return Mr[e.value];if(e.type==="void")return v;if(e.type==="AccountId32")return s;if(e.type==="AccountId20")return lr;if(e.type==="compact")return e.isBig?Wn:w;if(e.type==="bitSequence")return ht(e.isLSB);const r=h=>Pr(h,t,n,s),o=(h,p)=>{const f=r(h);return p?W(f,p):W(f)},c=h=>de(...h.map(r)),i=h=>{const p=Object.fromEntries(Object.entries(h).map(([f,m])=>[f,r(m)]));return R(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Yo;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?ze(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return $e(r(e.value));if(e.type==="result")return ut(r(e.value.ok),r(e.value.ko));const l=Object.values(e.value).map(h=>{switch(h.type){case"void":return v;case"lookupEntry":return r(h.value);case"tuple":return c(h.value);case"struct":return i(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,l[p]])),d=Object.values(e.value).map(h=>h.idx),u=d.every((h,p)=>h===p)?Ve(a):Ve(a,d);return e.byteLength?Go(u,e.byteLength):u},Jn,e=>e),Nr=(e,t=ct())=>{const n=new Map,s=r=>Pr(e(r),n,new Set,t);return r=>s(r)},Go=(e,t)=>{const n=C(t);return _(s=>n.enc(e.enc(s)),s=>e.dec(n.dec(s)))},Jo=oe(v,()=>{},()=>null),Qo=e=>{const{metadata:t}=e;let n=Nr(e);const s=t.pallets.find(u=>u.name==="System")?.constants.find(u=>u.name==="SS58Prefix");let r;if(s)try{const u=n(s.type).dec(s.value);typeof u=="number"&&(r=u,n=Nr(e,ct(u)))}catch{}const o=new Map,c=(u,h)=>{let p=o.get(u);p||o.set(u,p=Sr(u));const f=t.pallets.find(M=>M.name===u).storage.items.find(M=>M.name===h),m=M=>M===v?Jo:M,x=(M,Te,...et)=>{const U=p(...et),[,...E]=et;return{args:de(...E.map(([V])=>V)),keys:U,value:Te,len:M,fallback:f.modifier===1?Te.dec(f.fallback):void 0}};if(f.type.tag==="plain")return x(0,m(n(f.type.value)),h);const{key:B,value:S,hashers:T}=f.type.value,J=m(n(S)),ne=T.map(M=>Mr[M.tag]),pe=(()=>{if(ne.length===1)return[[n(B),ne[0]]];const M=e(B);switch(M.type){case"array":return ne.map(Te=>[n(M.value.id),Te]);case"tuple":return M.value.map((Te,et)=>[n(Te.id),ne[et]]);default:throw new Error("Invalid key type")}})();return x(ne.length,J,h,...pe)},i=u=>{switch(u.type){case"void":return v;case"lookupEntry":return n(u.value.id);case"tuple":return de(...Object.values(u.value).map(h=>n(h.id)));case"struct":return R(gt(u.value,h=>n(h.id)));case"array":return W(n(u.value.id),u.len)}},l=(u,h)=>{const p=t.pallets.find(f=>f.name===u).constants.find(f=>f.name===h);return n(p.type)},a=u=>(h,p)=>{const f=t.pallets.find(B=>B.name===h),m=e(f[u].type);if(m.type!=="enum")throw null;const x=m.value[p];return{location:[f.index,x.idx],codec:i(m.value[p])}},d=(u,h)=>{const p=t.pallets.find(f=>f.name===u)?.viewFns.find(f=>f.name===h);if(!p)throw null;return{args:de(...p.inputs.map(f=>n(f.type))),value:n(p.output)}},y=(u,h)=>{const p=t.apis.find(f=>f.name===u)?.methods.find(f=>f.name===h);if(!p)throw null;return{args:de(...p.inputs.map(f=>n(f.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:c,buildEvent:a("events"),buildError:a("errors"),buildViewFn:d,buildRuntimeCall:y,buildCall:a("calls"),buildConstant:l,ss58Prefix:r}},Pt=()=>new Error("Unkown signer"),Zo=e=>{const{extrinsic:t}=e,n=$r(e);let s,r;if("address"in t)s=n(t.address),r=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(c=>c.type!=null).map(c=>[c.name,n(c.type)]));if(s=o.Address,r=o.Signature,!s||!r)throw Pt()}if(s.type==="AccountId20"&&r.type==="array"&&r.len===65&&r.value.type==="primitive"&&r.value.value==="u8")return[1,[]];if(r.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in r.value)))throw Pt();if(s.type==="enum"){const o=s.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(s.type==="AccountId32")return[0,[]];throw Pt()},ec={Ed25519:0,Sr25519:1,Ecdsa:2},tc=(e,t,n,s,r,o)=>{const[c,i]=Zo(e),l=N([Mt.enc({version:4,type:"signed"}),c===1?t:new Uint8Array([...i,...t]),c===1||!o?n:new Uint8Array([ec[o],...n]),...s,r]);return N([D.enc(l.length),l])},[pt,Ze]=["<Bytes>","</Bytes>"].map(e=>Xe.fromText(e).asBytes()),nc=e=>async t=>{let n=!0,s;for(s=0;n&&s<pt.length;s++)n=pt[s]===t[s];n=n&&s===pt.length;const r=t.length-Ze.length;for(s=0;n&&s<Ze.length;s++)n=Ze[s]===t[r+s];return n=n&&s===Ze.length,e(n?t:N([pt,t,Ze]))},Rr={specVersion:Z,specName:k,base58Prefix:ie,decimals:A,tokenSymbol:k},Fr=R(Rr),Nt=C(32),rc=Ue({V0:v,V1:R({typeInformationTreeRoot:Nt,extrinsicMetadataHash:Nt,...Rr})});Ue({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v});const fe=Ue({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v,compactU8:v,compactU16:v,compactU32:v,compactU64:v,compactU128:v,compactU256:v,void:v,perId:w}),qr=R({name:$e(k),ty:fe,typeName:$e(k)}),sc=Ue({composite:W(qr),enumeration:R({name:k,fields:W(qr),index:w}),sequence:fe,array:R({len:Z,typeParam:fe}),tuple:W(fe),bitSequence:R({numBytes:A,leastSignificantBitFirst:cn})}),jr=R({path:W(k),typeDef:sc,typeId:w}),oc=W(jr),Rt=R({version:A,addressTy:fe,callTy:fe,signatureTy:fe,signedExtensions:W(R({identifier:k,includedInExtrinsic:fe,includedInSignedData:fe}))}),cc=de.dec(D[1],Mt[1],C(1/0)[1]);R({leaves:oc,leafIdxs:W(Z),proofs:W(Nt),extrinsic:Rt,info:Fr});const ic=(e,t)=>{const n=new Set,s=o=>{if(n.has(o))return;const{tag:c,value:i}=t.get(o).def;switch(c){case"composite":if(!i.length)break;n.add(o),i.forEach(({type:l})=>{s(l)});break;case"variant":if(!i.length)break;n.add(o),i.forEach(({fields:l})=>{l.forEach(({type:a})=>{s(a)})});break;case"tuple":if(!i.length)break;n.add(o),i.forEach(s);break;case"sequence":n.add(o),s(i);break;case"array":n.add(o),s(i.type);break;case"bitSequence":n.add(o)}};s(e.extrinsic.call),s(e.extrinsic.address),s(e.extrinsic.signature),e.extrinsic.signedExtensions.forEach(({type:o,additionalSigned:c})=>{s(o),s(c)});const r=[...n].sort((o,c)=>o-c);return new Map(r.map((o,c)=>[o,c]))},ac={u8:1,u16:2,u32:4,u64:8},lc=(e,t,n,s)=>{const{def:{tag:r,value:o}}=e.get(s);switch(r){case"composite":return[{tag:r,value:o.map(c=>({name:c.name,typeName:c.typeName,ty:t(c.type)}))}];case"variant":return o.map(c=>({tag:"enumeration",value:{name:c.name,index:c.index,fields:c.fields.map(i=>({name:i.name,typeName:i.typeName,ty:t(i.type)}))}}));case"sequence":return[{tag:r,value:t(o)}];case"array":return[{tag:r,value:{len:o.len,typeParam:t(o.type)}}];case"tuple":return[{tag:r,value:o.map(t)}];case"bitSequence":{const c=n(o.bitStoreType),i=ac[c];if(!i)throw new Error("Invalid primitive for BitSequence");const l=e.get(o.bitOrderType).path,a=l.includes("Lsb0");if(!a&&!l.includes("Msb0"))throw new Error("BitOrderType not recognized");return[{tag:"bitSequence",value:{numBytes:i,leastSignificantBitFirst:a}}]}}throw new Error(`FrameId(${s}) should have been filtered out`)},uc=(e,t,n,s)=>{const r=[];return[...t.entries()].forEach(([o,c])=>{const{path:i}=e.get(o);lc(e,n,s,o).forEach(l=>{r.push({path:i,typeId:c,typeDef:l})})}),r.sort((o,c)=>{if(o.typeId!==c.typeId)return o.typeId-c.typeId;if(o.typeDef.tag!=="enumeration"||c.typeDef.tag!=="enumeration")throw new Error("Found two types with same id");return o.typeDef.value.index-c.typeDef.value.index}),r},hc=e=>{try{const t=Ht(Ct(e));if(t.version<=14)throw new Error("Wrong metadata version");return t}catch(t){throw t||new Error("Unable to decode metadata")}},Wr=e=>typeof e=="string"?He(e):e,dc={null:"void",u8:"compactU8",u16:"compactU16",u32:"compactU32",u64:"compactU64",u128:"compactU128",u256:"compactU256"},fc={bool:A,char:A,str:k,u8:A,u16:ie,u32:Z,u64:Re,u128:en,u256:sn,i8:zt,i16:Yt,i32:Gt,i64:Jt,i128:tn,i256:on,void:v,compactU8:D,compactU16:D,compactU32:D,compactU64:D,compactU128:D,compactU256:D},Kr=(e,t,n,s,r)=>{if(t.tag!=="perId"){fc[t.tag][1](e);return}const o=a=>{Kr(e,a,n,s,r)},c=n.get(t.value),[i]=c,l=s[i];switch(c.length===1&&r.add(i),l.typeDef.tag){case"enumeration":{const a=A.dec(e),[d,y]=c.map(u=>[s[u].typeDef,u]).find(([u])=>u.value.index===a);r.add(y),d.value.fields.forEach(({ty:u})=>{o(u)});break}case"sequence":{const a=D.dec(e);for(let d=0;d<a;d++)o(l.typeDef.value);break}case"array":{for(let a=0;a<l.typeDef.value.len;a++)o(l.typeDef.value.typeParam);break}case"composite":{l.typeDef.value.forEach(a=>{o(a.ty)});break}case"tuple":{l.typeDef.value.forEach(o);break}case"bitSequence":throw new Error("bitSequence is not supported")}},Xr=(e,t,n)=>{let s=new Uint8Array;Be(c=>{s=c})(e);const r=new Map;n.forEach((c,i)=>{const l=r.get(c.typeId);l?l.push(i):r.set(c.typeId,[i])});const o=new Set;return t.forEach(c=>{Kr(s,c,r,n,o)}),[...o].sort((c,i)=>c-i)},Ft=e=>Math.log2(e+1)|0,pc=(e,t)=>(e+1>>t)-1;function yc(e,t){const n=t.map(l=>e[l]),s=e.length-1,r=t.map(l=>s+l),o=[];if(r.length){const l=Ft(r.at(-1)),a=Math.pow(2,l)-1,d=r.findIndex(y=>y>=a);d>0&&(r.unshift(...r.splice(d)),n.unshift(...n.splice(d)))}let c=0;const i=l=>{if(c===r.length){o.push(l);return}const a=r[c];if(a===l){++c;return}const d=Ft(l),y=Ft(a);if(l!==pc(a,y-d)){o.push(l);return}const u=2*l+1;i(u),i(u+1)};return i(0),{leaves:n,leafIdxs:r,proofIdxs:o}}const qt=(e,t,n)=>{if(n!=null&&n!==t)throw new Error(`${e} not expected. Received ${n} expected ${t}`)},gc=(e,{decimals:t,tokenSymbol:n,...s})=>{const r=hc(e),o=r.extrinsic.version.includes(4)?4:null;if(o==null)throw new Error("Only extrinsic v4 is supported");const{ss58Prefix:c,buildDefinition:i}=Qo($r(r));if(c==null)throw new Error("SS58 prefix not found in metadata");qt("SS58 prefix",c,s.base58Prefix);const l=r.pallets.find(U=>U.name==="System")?.constants.find(U=>U.name==="Version");if(l==null)throw new Error("System.Version constant not found");const{spec_name:a,spec_version:d}=i(l.type).dec(l.value);if(typeof a!="string"||typeof d!="number")throw new Error("Spec name or spec version not found");qt("Spec name",a,s.specName),qt("Spec version",d,s.specVersion);const y={decimals:t,tokenSymbol:n,specVersion:d,specName:a,base58Prefix:c},u=new Map(r.lookup.map(U=>[U.id,U])),h=ic(r,u),p=U=>{const{def:{tag:E,value:V}}=u.get(U);if(E==="primitive")return V.tag;if(E!=="composite"&&E!=="tuple"||V.length>1)throw new Error("The provided definition doesn't map to a primitive");return V.length===0?null:p(E==="tuple"?V[0]:V[0].type)},f=U=>{const{def:E}=u.get(U);if(E.tag==="primitive")return{tag:E.value.tag,value:void 0};if(E.tag==="compact"){const V=p(E.value),ye=dc[V];if(!ye)throw new Error("Invalid primitive for Compact");return{tag:ye,value:void 0}}return h.has(U)?{tag:"perId",value:h.get(U)}:{tag:"void",value:void 0}},m={version:o,addressTy:f(r.extrinsic.address),callTy:f(r.extrinsic.call),signatureTy:f(r.extrinsic.signature),signedExtensions:r.extrinsic.signedExtensions.map(U=>({identifier:U.identifier,includedInExtrinsic:f(U.type),includedInSignedData:f(U.additionalSigned)}))},x=uc(u,h,f,p),B=x.map(jr.enc);let S;const T=()=>{if(S)return S;if(!B.length)return S=[new Uint8Array(32).fill(0)];S=new Array(B.length*2-1);let U=B.length-1;for(let E=0;E<B.length;E++)S[U+E]=Ne(B[E]);for(let E=S.length-2;E>0;E-=2)S[(E-1)/2]=Ne(N([S[E],S[E+1]]));return S};let J;const ne=()=>{if(J)return J;const E={tag:"V1",value:{typeInformationTreeRoot:T()[0],extrinsicMetadataHash:Ne(Rt.enc(m)),...y}};return J=Ne(rc.enc(E))},pe=U=>{const E=yc(B,U),V=T(),ye=E.proofIdxs.map(De=>V[De]);return N([D.enc(E.leaves.length),...E.leaves,D.enc(E.leafIdxs.length),...E.leafIdxs.map(De=>Z.enc(De)),D.enc(ye.length),...ye,Rt.enc(m),Fr.enc(y)])},M=U=>{const E=[m.callTy,...m.signedExtensions.map(V=>V.includedInExtrinsic),...m.signedExtensions.map(V=>V.includedInSignedData)];return pe(Xr(U,E,x))};return{digest:ne,getProofForExtrinsic:(U,E)=>{let[,{version:V,type:ye},De]=cc(U);if(V!==m.version)throw new Error("Incorrect extrinsic version");const Yr=ye==="signed"?[m.addressTy,m.signatureTy,...m.signedExtensions.map(Wt=>Wt.includedInExtrinsic),m.callTy]:[m.callTy];return E&&(De=N([De,Wr(E)]),Yr.push(...m.signedExtensions.map(Wt=>Wt.includedInSignedData))),pe(Xr(De,Yr,x))},getProofForExtrinsicParts:(U,E,V)=>{const ye=N([U,E,V].map(Wr));return M(ye)},getProofForExtrinsicPayload:M}};function vc(e,t,n){return{publicKey:e,signTx:async(r,o,c,i,l=Je)=>{const a=Ht(Ct(c)),d=[],y=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const f=o[p];if(!f)throw new Error(`Missing ${p} signed extension`);d.push(f.value),y.push(f.additionalSigned)});const u=N([r,...d,...y]),h=await n(u.length>256?l(u):u);return tc(a,e,h,d,r,t)},signBytes:nc(n)}}const jt="CheckMetadataHash",zr=Uint8Array.from([1]),mc=(e,t)=>({...t,signTx:async(n,s,r,...o)=>t.signTx(n,s[jt]?{...s,[jt]:{identifier:jt,value:zr,additionalSigned:N([zr,gc(r,e).digest()])}}:s,r,...o)});Le.getPolkadotSigner=vc,Le.withMetadataHash=mc}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -204,28 +204,28 @@
204
204
  },
205
205
  "dependencies": {
206
206
  "@rx-state/core": "^0.1.4",
207
- "@polkadot-api/known-chains": "0.9.16",
208
- "@polkadot-api/ink-contracts": "0.4.4",
209
- "@polkadot-api/cli": "0.17.0",
207
+ "@polkadot-api/cli": "0.18.0",
210
208
  "@polkadot-api/json-rpc-provider": "0.0.4",
209
+ "@polkadot-api/ink-contracts": "0.4.5",
210
+ "@polkadot-api/known-chains": "0.9.17",
211
211
  "@polkadot-api/logs-provider": "0.0.6",
212
- "@polkadot-api/metadata-builders": "0.13.7",
213
- "@polkadot-api/pjs-signer": "0.6.17",
214
- "@polkadot-api/metadata-compatibility": "0.4.2",
215
- "@polkadot-api/observable-client": "0.17.1",
212
+ "@polkadot-api/metadata-builders": "0.13.8",
213
+ "@polkadot-api/metadata-compatibility": "0.4.3",
214
+ "@polkadot-api/observable-client": "0.17.2",
215
+ "@polkadot-api/pjs-signer": "0.6.18",
216
+ "@polkadot-api/polkadot-sdk-compat": "2.4.1",
216
217
  "@polkadot-api/polkadot-signer": "0.1.6",
217
- "@polkadot-api/polkadot-sdk-compat": "2.4.0",
218
- "@polkadot-api/signer": "0.2.11",
218
+ "@polkadot-api/signer": "0.2.12",
219
219
  "@polkadot-api/sm-provider": "0.1.15",
220
220
  "@polkadot-api/smoldot": "0.3.15",
221
- "@polkadot-api/substrate-bindings": "0.16.5",
222
- "@polkadot-api/substrate-client": "0.5.0",
221
+ "@polkadot-api/substrate-bindings": "0.16.6",
223
222
  "@polkadot-api/utils": "0.2.0",
223
+ "@polkadot-api/substrate-client": "0.5.0",
224
224
  "@polkadot-api/ws-provider": "0.7.4"
225
225
  },
226
226
  "devDependencies": {
227
227
  "rxjs": "^7.8.2",
228
- "@polkadot-api/codegen": "0.21.0"
228
+ "@polkadot-api/codegen": "0.21.1"
229
229
  },
230
230
  "scripts": {
231
231
  "build-core": "tsc --noEmit && rollup -c",