polkadot-api 1.10.1 → 1.10.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.10.1";
4
+ var version = "1.10.2";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(ie,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports):typeof define=="function"&&define.amd?define(["exports"],Rt):(ie=typeof globalThis<"u"?globalThis:ie||self,Rt(ie.papi={}))})(this,function(ie){"use strict";var Rt=Object.defineProperty,Ji=(e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gr=(e,t,n)=>(Ji(e,typeof t!="symbol"?t+"":t,n),n),Kn={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 ec(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|Kn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Kn[e[i]],u=Kn[e[i+1]];s[t+o++]=c<<4|u}return s}var Nr=class extends Uint8Array{constructor(e){super(e),Gr(this,"i",0),Gr(this,"v"),this.v=new DataView(e)}},Ee=e=>t=>e(t instanceof Nr?t:new Nr(t instanceof Uint8Array?t.buffer:typeof t=="string"?ec(t).buffer:t)),Ue=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 sn(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 on=Ee,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ut=(e,t)=>n=>e(t(n)),Xn=(e,t)=>n=>t(e(n)),Qe=([e,t],n,r)=>D(Ut(e,n),Xn(t,r));function tc(e,t){return Ee(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function nc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ze(e,t,n){return D(nc(e,n),tc(e,t))}var j=Ze(1,"getUint8","setUint8"),Je=Ze(2,"getUint16","setUint16"),Be=Ze(4,"getUint32","setUint32"),Mt=Ze(8,"getBigUint64","setBigUint64"),rc=Ze(1,"getInt8","setInt8"),sc=Ze(2,"getInt16","setInt16"),oc=Ze(4,"getInt32","setInt32"),ic=Ze(8,"getBigInt64","setBigInt64"),Qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Zr=e=>Ee(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}),Jr=D(Qr,Zr("getBigUint64")),cc=D(Qr,Zr("getBigInt64")),es=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},ts=e=>Ee(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}),ac=D(es,ts("getBigUint64")),uc=D(es,ts("getBigInt64")),lc=Qe(j,e=>e?1:0,Boolean),fc=[j[1],Je[1],Be[1]],hc=Ee(e=>{const t=e[e.i],n=t&3;if(n<3)return fc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=Mt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(Be[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Je[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(j[1](e))<<i|s),s}),dc=1n<<56n,pc=1<<24,vc=256,bc=4294967295n,mc=64,yc=16384,gc=1<<30,wc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<mc)return j[0](t);if(e<yc)return Je[0](t|1);if(e<gc)return Be[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=dc;)n.push(Mt[0](r)),r>>=64n;r>=pc&&(n.push(Be[0](Number(r&bc))),r>>=32n);let s=Number(r);s>=vc&&(n.push(Je[0](s)),s>>=16),s&&n.push(j[0](s));const o=Ue(n);return o[0]=o.length-5<<2|3,o},ce=D(wc,hc),Ec=new TextEncoder,xc=e=>{const t=Ec.encode(e);return Ue([ce.enc(t.length),t])},kc=new TextDecoder,Ac=Ee(e=>{let t=ce.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,kc.decode(n)}),ee=D(xc,Ac),Sc=()=>{},Ic=new Uint8Array(0),B=D(()=>Ic,Sc),ns=e=>e===void 0?t=>Ue([ce.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),rs=e=>Ee(t=>{const n=e===void 0?ce.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}),N=e=>D(ns(e),rs(e));N.enc=ns,N.dec=rs;var ss=(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})=>Ue([j.enc(s(o)),e[o](i)])},os=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ee(s=>{const o=j.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},xe=(e,...t)=>D(ss(sn(e,([n])=>n),...t),os(sn(e,([,n])=>n),...t));xe.enc=ss,xe.dec=os;var is=e=>Ee(t=>j[1](t)>0?e(t):void 0),cs=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ue([n,e(t)]))},ke=e=>D(cs(e[0]),is(e[1]));ke.enc=cs,ke.dec=is;var as=(e,t)=>Ee(n=>{const r=j[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),us=(e,t)=>({success:n,value:r})=>Ue([j[0](n?0:1),(n?e:t)(r)]),Lt=(e,t)=>D(us(e[0],t[0]),as(e[1],t[1]));Lt.dec=as,Lt.enc=us;var ls=(...e)=>Ee(t=>e.map(n=>n(t))),fs=(...e)=>t=>Ue(e.map((n,r)=>n(t[r]))),Me=(...e)=>D(fs(...e.map(([t])=>t)),ls(...e.map(([,t])=>t)));Me.enc=fs,Me.dec=ls;var hs=e=>{const t=Object.keys(e);return Ut(Me.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ds=e=>{const t=Object.keys(e);return Xn(Me.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},U=e=>D(hs(sn(e,t=>t[0])),ds(sn(e,t=>t[1])));U.enc=hs,U.dec=ds;var ps=(e,t)=>t>=0?n=>Ue(n.map(e)):n=>Ue([ce.enc(n.length),Ue(n.map(e))]),vs=(e,t)=>Ee(n=>{const r=t>=0?t:ce.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),z=(e,t)=>D(ps(e[0],t),vs(e[1],t));z.enc=ps,z.dec=vs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _c(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bs(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 Yn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ms(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gn(e){if(!Array.isArray(e))throw new Error("array expected")}function ys(e,t){if(!bs(!0,t))throw new Error(`${e}: array of strings expected`)}function Bc(e,t){if(!bs(!1,t))throw new Error(`${e}: array of numbers expected`)}function Oc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Cc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ys("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Gn(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=>(Gn(s),s.map(o=>{Yn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function $c(e=""){return Yn("join",e),{encode:t=>(ys("join.decode",t),t.join(e)),decode:t=>(Yn("join.decode",t),t.split(e))}}function gs(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(Gn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ms(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,h=d+l;if(!Number.isSafeInteger(h)||d/t!==c||h-l!==d)throw new Error("convertRadix: carry overflow");const f=h/n;c=h%n;const p=Math.floor(f);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==h)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Tc(e){ms(e);const t=2**8;return{encode:n=>{if(!_c(n))throw new Error("radix.encode input should be Uint8Array");return gs(Array.from(n),t,e)},decode:n=>(Bc("radix.decode",n),Uint8Array.from(gs(n,e,t)))}}const ws=(e=>Oc(Tc(58),Cc(e),$c("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!Pc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Dt(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 Nn(e,t){ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Rc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function dt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cn(e,t){return e<<32-t|e>>>t}const Es=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Fe=Es?e=>e:e=>xs(e);function Uc(e){for(let t=0;t<e.length;t++)e[t]=xs(e[t]);return e}const ae=Es?e=>e:Uc;function Mc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Le(e){return typeof e=="string"&&(e=Mc(e)),ht(e),e}class ks{}function Lc(e){const t=r=>e().update(Le(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Dc(e){const t=(r,s)=>e(s).update(Le(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Vc(e){const t=(r,s)=>e(s).update(Le(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const jc=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 tt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,16),n=n+r|0,t=cn(t^n,12),{a:e,b:t,c:n,d:r}}function nt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,8),n=n+r|0,t=cn(t^n,7),{a:e,b:t,c:n,d:r}}const zc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=BigInt(2**32-1),As=BigInt(32);function un(e,t=!1){return t?{h:Number(e&an),l:Number(e>>As&an)}:{h:Number(e>>As&an)|0,l:Number(e&an)|0}}function Hc(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:c}=un(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Ss=(e,t,n)=>e>>>n|t<<32-n,Is=(e,t,n)=>e<<32-n|t>>>n,Fc=(e,t,n)=>e<<64-n|t>>>n-32,qc=(e,t,n)=>e>>>n-32|t<<64-n,Wc=(e,t)=>t,Kc=(e,t)=>e,Xc=(e,t,n)=>e<<n|t>>>32-n,Yc=(e,t,n)=>t<<n|e>>>32-n,Gc=(e,t,n)=>t<<n-32|e>>>64-n,Nc=(e,t,n)=>e<<n-32|t>>>64-n;function _s(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Bs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Os=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Y=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function rt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Wc(v,p),Dl:Kc(v)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Ss(d,l,24),Bl:Is(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Ss(v,p,16),Dl:Is(v,p,16)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Fc(d,l,63),Bl:qc(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function Qc(e,t={},n,r,s){if(gt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Cs extends ks{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,gt(t),gt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=dt(this.buffer)}update(t){Dt(this),t=Le(t),ht(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ae(s),this.compress(s,0,!1),ae(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ae(d);for(let h=0;u+n<o;h+=s.length,u+=n)this.length+=n,this.compress(d,h,!1);ae(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Dt(this),Nn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,et(this.buffer.subarray(n)),ae(r),this.compress(r,0,!0),ae(r);const s=dt(t);this.get().forEach((o,i)=>s[i]=Fe(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:c}=this;return t||(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=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class Zc extends Cs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=Y[0]|0,this.v0h=Y[1]|0,this.v1l=Y[2]|0,this.v1h=Y[3]|0,this.v2l=Y[4]|0,this.v2h=Y[5]|0,this.v3l=Y[6]|0,this.v3h=Y[7]|0,this.v4l=Y[8]|0,this.v4h=Y[9]|0,this.v5l=Y[10]|0,this.v5h=Y[11]|0,this.v6l=Y[12]|0,this.v6h=Y[13]|0,this.v7l=Y[14]|0,this.v7h=Y[15]|0,Qc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Le(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Le(o);const c=dt(o);this.v4l^=Fe(c[0]),this.v4h^=Fe(c[1]),this.v5l^=Fe(c[2]),this.v5h^=Fe(c[3])}if(s!==void 0){s=Le(s);const c=dt(s);this.v6l^=Fe(c[0]),this.v6h^=Fe(c[1]),this.v7l^=Fe(c[2]),this.v7h^=Fe(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:h,v6l:f,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b){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=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=h|0,this.v6l=f|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(Y,16);let{h:s,l:o}=un(BigInt(this.length));k[24]=Y[8]^o,k[25]=Y[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=jc;for(let u=0;u<12;u++)rt(0,4,8,12,t,n+2*c[i++]),st(0,4,8,12,t,n+2*c[i++]),rt(1,5,9,13,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),rt(2,6,10,14,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),rt(3,7,11,15,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),rt(0,5,10,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),rt(1,6,11,12,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),rt(2,7,8,13,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),rt(3,4,9,14,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],et(k)}destroy(){this.destroyed=!0,et(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jc=Dc(e=>new Zc(e));function $s(e,t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b,m,g,x){let y=0;for(let w=0;w<r;w++)({a:s,b:u,c:h,d:b}=tt(s,u,h,b,n[t+e[y++]])),{a:s,b:u,c:h,d:b}=nt(s,u,h,b,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=tt(o,a,f,m,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=nt(o,a,f,m,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=tt(i,l,p,g,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=tt(c,d,v,x,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=nt(c,d,v,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=tt(s,a,p,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=nt(s,a,p,x,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=tt(o,l,v,b,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=tt(i,d,h,m,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=nt(i,d,h,m,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=tt(c,u,f,g,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=nt(c,u,f,g,n[t+e[y++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:h,v9:f,v10:p,v11:v,v12:b,v13:m,v14:g,v15:x}}const ln=Jc,Ts=new TextEncoder().encode("SS58PRE"),Qn=2,Zn=e=>{try{const t=ws.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qn),s=t.subarray(n.length+r.length),o=ln(Uint8Array.of(...Ts,...n,...r),{dkLen:64}).subarray(0,Qn);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:ea(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},ea=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ps=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ln(Uint8Array.of(...Ts,...t,...n),{dkLen:64}).subarray(0,Qn);return ws.encode(Uint8Array.of(...t,...n,...r))}};function ta(e,t){return n=>{const r=Zn(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 pt=(e=42,t=32)=>Qe(N(t),ta(t),Ps(e)),Rs="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rs[r>>4]+Rs[r&15]}return t.join("")}const Jn={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 fe(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|Jn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Jn[e[i]],u=Jn[e[i+1]];s[t+o++]=c<<4|u}return s}function wt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n},Vt=Function.prototype;class Us extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var na=Object.defineProperty,Ms=e=>{throw TypeError(e)},ra=(e,t,n)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n)=>ra(e,typeof t!="symbol"?t+"":t,n),Ls=(e,t,n)=>t.has(e)||Ms("Cannot "+n),qe=(e,t,n)=>(Ls(e,t,"read from private field"),n?n.call(e):t.get(e)),zt=(e,t,n)=>t.has(e)?Ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),vt=(e,t,n,r)=>(Ls(e,t,"write to private field"),t.set(e,n),n),We,Ht,fn,hn,dn;const sa=new TextEncoder,oa=new TextDecoder,ia=Me(ce,N(1/0))[1];class De{constructor(t,n=!1){if(zt(this,We),zt(this,Ht,null),zt(this,fn,null),zt(this,hn,null),zt(this,dn,null),jt(this,"asText",()=>qe(this,dn)??vt(this,dn,oa.decode(qe(this,We)))),jt(this,"asHex",()=>qe(this,fn)||vt(this,fn,te(qe(this,We)))),jt(this,"asOpaqueHex",()=>qe(this,hn)||vt(this,hn,te(this.asBytes()))),jt(this,"asBytes",()=>qe(this,We)),jt(this,"asOpaqueBytes",()=>qe(this,Ht)||vt(this,Ht,ue(ce[0](qe(this,We).length),qe(this,We)))),n){try{const[r,s]=ia(t);if(r===s.length){vt(this,We,s),vt(this,Ht,t);return}}catch{}throw new Error("Invalid opaque bytes")}else vt(this,We,t)}static fromText(t){return new this(sa.encode(t))}static fromHex(t){return new this(fe(t))}static fromOpaqueHex(t){return new this(fe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}We=new WeakMap,Ht=new WeakMap,fn=new WeakMap,hn=new WeakMap,dn=new WeakMap;const[ca]=pt();class pn extends De{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ca(t))}}const Ds=e=>{const t=N.enc(e);return n=>t(n.asBytes())},Vs=e=>{const t=N.dec(e),n=e==null?De:pn;return r=>n.fromBytes(t(r))},Ft=e=>D(Ds(e),Vs(e));Ft.enc=Ds,Ft.dec=Vs;const O=Qe(ce,e=>e,Number),vn=Qe(ce,e=>e,BigInt),aa=on(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:N(n).dec(e),bitsLen:t}}),js=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},aa),ua=Qe(j,e=>e.charCodeAt(0),String.fromCharCode),zs=e=>{const t=N.enc(e);return n=>t(fe(n))},Hs=e=>{const t=N.dec(e);return n=>te(t(n))},ot=e=>D(zs(e),Hs(e));ot.enc=zs,ot.dec=Hs;const la=new TextEncoder,fa=new TextDecoder,ha=e=>Qe(N(e),t=>la.encode(t),t=>fa.decode(t)),Fs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},qs=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},er=e=>D(Fs(()=>e().enc),qs(()=>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}}),Ws=new Proxy({},{get(e,t){return n=>bt(t,n)}}),F=(e,t)=>{const n=e;return n.inner=t,n},Ks=(...e)=>{const t=xe.enc(...e);return F(n=>t({tag:n.type,value:n.value}),e[0])},Xs=(...e)=>{const t=xe.dec(...e);return F(n=>{const{tag:r,value:s}=t(n);return bt(r,s)},e[0])},he=(e,...t)=>F(D(Ks(wt(e,([n])=>n),...t),Xs(wt(e,([,n])=>n),...t)),e);he.enc=Ks,he.dec=Xs;const tr=(e,...t)=>F(xe(e,...t),e);tr.enc=(e,...t)=>F(xe.enc(e,...t),e),tr.dec=(e,...t)=>F(xe.dec(e,...t),e);const da=BigInt(0),qt=BigInt(1),pa=BigInt(2),va=BigInt(7),ba=BigInt(256),ma=BigInt(113),Ys=[],Gs=[],Ns=[];for(let e=0,t=qt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Ys.push(2*(5*r+n)),Gs.push((e+1)*(e+2)/2%64);let s=da;for(let o=0;o<7;o++)t=(t<<qt^(t>>va)*ma)%ba,t&pa&&(s^=qt<<(qt<<BigInt(o))-qt);Ns.push(s)}const Qs=Hc(Ns,!0),ya=Qs[0],ga=Qs[1],Zs=(e,t,n)=>n>32?Gc(e,t,n):Xc(e,t,n),Js=(e,t,n)=>n>32?Nc(e,t,n):Yc(e,t,n);function wa(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 c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=Zs(a,l,1)^n[c],h=Js(a,l,1)^n[c+1];for(let f=0;f<50;f+=10)e[i+f]^=d,e[i+f+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=Gs[i],u=Zs(s,o,c),a=Js(s,o,c),l=Ys[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=ya[r],e[1]^=ga[r]}et(n)}class nr extends ks{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,gt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=dt(this.state)}clone(){return this._cloneInto()}keccak(){ae(this.state32),wa(this.state32,this.rounds),ae(this.state32),this.posOut=0,this.pos=0}update(t){Dt(this),t=Le(t),ht(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 c=0;c<i;c++)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){Dt(this,!1),ht(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 gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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,et(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(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 Ea=(e,t,n)=>Lc(()=>new nr(t,e,n)),xa=Ea(1,136,256/8),eo=e=>{const t=e.slice(2),n=te(xa(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("")}`},ka=N(20)[1],to=D(e=>{const t=fe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(eo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},on(e=>eo(te(ka(e))))),be=e=>F(U(e),e);be.enc=e=>F(U.enc(e),e),be.dec=e=>F(U.dec(e),e);const Ve=(...e)=>F(Me(...e),e);Ve.enc=(...e)=>F(Me.enc(...e),e),Ve.dec=(...e)=>F(Me.dec(...e),e);const me=(e,...t)=>F(z(e,...t),e);me.enc=(e,...t)=>F(z.enc(e,...t),e),me.dec=(e,...t)=>F(z.dec(e,...t),e);const bn=(e,t)=>F(Lt(e,t),{ok:e,ko:t});bn.enc=(e,t)=>F(Lt.enc(e,t),{ok:e,ko:t}),bn.dec=(e,t)=>F(Lt.dec(e,t),{ok:e,ko:t});const it=e=>F(ke(e),e);it.enc=e=>F(ke.enc(e),e),it.dec=e=>F(ke.dec(e),e);const no=new TextEncoder,ro=new TextDecoder,Aa=Qe(N(4),no.encode.bind(no),ro.decode.bind(ro)),rr=be({engine:Aa,payload:ot()}),Sa=he({consensus:rr,seal:rr,preRuntime:rr,runtimeUpdated:B},[4,5,6,8]),sr=ot(32),so=be({parentHash:sr,number:O,stateRoot:sr,extrinsicRoot:sr,digests:me(Sa)}),Ke=z(ee),oo=ke(ee),Ia=xe({bool:B,char:B,str:B,u8:B,u16:B,u32:B,u64:B,u128:B,u256:B,i8:B,i16:B,i32:B,i64:B,i128:B,i256:B}),io=z(U({name:oo,type:O,typeName:oo,docs:Ke})),_a=U({len:Be,type:O}),Ba=U({bitStoreType:O,bitOrderType:O}),Oa=z(U({name:ee,fields:io,index:j,docs:Ke})),Ca=xe({composite:io,variant:Oa,sequence:O,array:_a,tuple:z(O),primitive:Ia,compact:O,bitSequence:Ba}),$a=U({name:ee,type:ke(O)}),Ta=z($a),Pa=U({id:O,path:Ke,params:Ta,def:Ca,docs:Ke}),or=z(Pa),Ra=xe({Blake2128:B,Blake2256:B,Blake2128Concat:B,Twox128:B,Twox256:B,Twox64Concat:B,Identity:B}),Ua=z(Ra),Ma=U({hashers:Ua,key:O,value:O}),La=U({name:ee,modifier:j,type:xe({plain:O,map:Ma}),fallback:ot(),docs:Ke}),Da=ke(U({prefix:ee,items:z(La)})),co={name:ee,storage:Da,calls:ke(O),events:ke(O),constants:z(U({name:ee,type:O,value:ot(),docs:Ke})),errors:ke(O),index:j},Va={...co,docs:Ke},ja=new Uint8Array,ao=e=>D(()=>ja,()=>e),za=U({type:O,version:j,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),uo=U({lookup:or,pallets:z(U({...co,docs:ao([])})),extrinsic:za,type:O,apis:ao([])}),Ha=U({name:ee,methods:z(U({name:ee,inputs:z(U({name:ee,type:O})),output:O,docs:Ke})),docs:Ke}),Fa=U({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),lo=U({lookup:or,pallets:z(U(Va)),extrinsic:Fa,type:O,apis:z(Ha),outerEnums:U({call:O,event:O,error:O}),custom:z(Me(ee,U({type:O,value:ot()})))}),fo=()=>{throw new Error("Unsupported metadata version!")},de=D(fo,fo),ct=U({magicNumber:Be,metadata:xe({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:uo,v15:lo})}),ir=N(),qa=ke(ir),Wa=Me(ce,ir),cr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(qa.dec(e))}catch{}try{return ct.dec(ir.dec(e))}catch{}try{return ct.dec(Wa.dec(e)[1])}catch{}throw null},Ka={dkLen:32},Wt=e=>ln(e,Ka),Xa={dkLen:16},ar=e=>ln(e,Xa),ho=e=>ue(ar(e),e),je={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Xe=zc.slice(),po=(()=>{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 ur extends Cs{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;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');const i=Le(r).slice();ht(i,32),this.IV=dt(i),ae(this.IV),this.flags=n|je.KEYED_HASH}else if(o){const i=Le(s),c=new ur({dkLen:32},je.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=dt(c),ae(this.IV),this.flags=n|je.DERIVE_KEY_MATERIAL}else this.IV=Xe.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Rc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=un(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:h,v4:f,v5:p,v6:v,v7:b,v8:m,v9:g,v10:x,v11:y,v12:w,v13:A,v14:_,v15:T}=$s(po,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Xe[0],Xe[1],Xe[2],Xe[3],c,u,i,n);o[0]=a^m,o[1]=l^g,o[2]=d^x,o[3]=h^y,o[4]=f^w,o[5]=p^A,o[6]=v^_,o[7]=b^T}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=je.CHUNK_START),(this.chunkPos===15||r)&&(s|=je.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,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|je.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:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,et(this.state,this.buffer32,this.IV,this.bufferOut32),et(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=un(BigInt(this.chunkOut++));ae(s);const{v0:u,v1:a,v2:l,v3:d,v4:h,v5:f,v6:p,v7:v,v8:b,v9:m,v10:g,v11:x,v12:y,v13:w,v14:A,v15:_}=$s(po,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Xe[0],Xe[1],Xe[2],Xe[3],c,i,n,r);o[0]=u^b,o[1]=a^m,o[2]=l^g,o[3]=d^x,o[4]=h^y,o[5]=f^w,o[6]=p^A,o[7]=v^_,o[8]=t[0]^b,o[9]=t[1]^m,o[10]=t[2]^g,o[11]=t[3]^x,o[12]=t[4]^y,o[13]=t[5]^w,o[14]=t[6]^A,o[15]=t[7]^_,ae(s),ae(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,et(this.buffer.subarray(this.pos));let t=this.flags|je.ROOT;this.stack.length?(t|=je.PARENT,ae(this.buffer32),this.compress(this.buffer32,0,!0),ae(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:je.CHUNK_START)|je.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Dt(this,!1),ht(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 gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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 Ya=Vc(e=>new ur(e)),Ga={dkLen:32},vo=e=>Ya(e,Ga),Na=e=>ue(vo(e),e),bo=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),lr=2n**64n-1n,re=(e,t)=>e<<t&lr|e>>64n-t,M=(e,t)=>e*t&lr,Q=(e,t)=>e+t&lr,Z=11400714785074694791n,ye=14029467366897019727n,mo=1609587929392839161n,Kt=9650029242287828579n,yo=2870177450012600261n;function at(e,t=0n){let n=Q(Q(t,Z),ye),r=Q(t,ye),s=t,o=t-Z,i=e.length,c=0,u=null;(function(){let f=0,p=f+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(f<=p-32){const v=p-32;do{let b;b=mt(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=M(re(Q(n,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(r,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(s,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(o,M(b,ye)),31n),Z),f+=8}while(f<=v)}f<p&&(u.set(e.subarray(f,p),c),c=p-f)}})(),e=u||e;let a,l=0;for(i>=32?(a=re(n,1n),a=Q(a,re(r,7n)),a=Q(a,re(s,12n)),a=Q(a,re(o,18n)),n=M(re(M(n,ye),31n),Z),a=a^n,a=Q(M(a,Z),Kt),r=M(re(M(r,ye),31n),Z),a=a^r,a=Q(M(a,Z),Kt),s=M(re(M(s,ye),31n),Z),a=a^s,a=Q(M(a,Z),Kt),o=M(re(M(o,ye),31n),Z),a=a^o,a=Q(M(a,Z),Kt)):a=Q(t,yo),a=Q(a,BigInt(i));l<=c-8;){let h=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=M(re(M(h,ye),31n),Z),a=Q(M(re(a^h,27n),Z),Kt),l+=8}if(l+4<=c){let h=M(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),Z);a=Q(M(re(a^h,23n),ye),mo),l+=4}for(;l<c;){const h=M(mt(e[l++],0,0,0),yo);a=M(re(a^h,11n),Z)}let d=a>>33n;return a=M(a^d,ye),d=a>>29n,a=M(a^d,mo),d=a>>32n,a^=d,a}const mn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},go=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},wo=e=>ue(Mt.enc(at(e)),e),Eo=new TextEncoder,Qa=new Map([[bo,0],[wo,8],[ho,16],[ar,-16],[Wt,-32],[mn,-16],[go,-32]]),xo=e=>{const t=mn(Eo.encode(e));return(n,...r)=>{const s=ue(t,mn(Eo.encode(n))),o=te(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=fe(a.slice(o.length)),d=new Array(r.length);for(let h=0,f=0;h<r.length;h++){const[p,v]=r[h],b=Qa.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[h]=te(l.slice(f,f+m)),f+=m}else f+=b,d[h]=p.dec(l.slice(f)),f+=p.enc(d[h]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>te(ue(s,...a.map((l,d)=>c[d](l)))),dec:i}}},Za=De.fromText("modlpy/utilisuba").asBytes(),Ja=({threshold:e,signatories:t})=>{const n=ko(t),r=ue(Za,ce.enc(n.length),...n,Je.enc(e));return Wt(r)},ko=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}});var Ao=Object.freeze({__proto__:null,AccountId:pt,Bin:Ft,Binary:De,Blake2128:ar,Blake2128Concat:ho,Blake2256:Wt,Blake3256:vo,Blake3256Concat:Na,Bytes:N,Enum:bt,FixedSizeBinary:pn,Hex:ot,Identity:bo,Option:it,Result:bn,ScaleEnum:tr,Self:er,Storage:xo,Struct:be,Tuple:Ve,Twox128:mn,Twox256:go,Twox64Concat:wo,Variant:he,Vector:me,_Enum:Ws,_void:B,bitSequence:js,blockHeader:so,bool:lc,char:ua,compact:ce,compactBn:vn,compactNumber:O,createCodec:D,createDecoder:on,decAnyMetadata:cr,enhanceCodec:Qe,enhanceDecoder:Xn,enhanceEncoder:Ut,ethAccount:to,fixedStr:ha,fromBufferToBase58:Ps,getMultisigAccountId:Ja,getSs58AddressInfo:Zn,h64:at,i128:cc,i16:sc,i256:uc,i32:oc,i64:ic,i8:rc,metadata:ct,selfDecoder:qs,selfEncoder:Fs,sortMultisigSignatories:ko,str:ee,u128:Jr,u16:Je,u256:ac,u32:Be,u64:Mt,u8:j,v14:uo,v14Lookup:or,v15:lo});const Ye=O,eu=me(Ve(ee,Ye)),L={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},tu=he(Object.fromEntries(Object.values(L).map(e=>[e,B]))),nu=me(Ve(ee,he({inline:er(()=>fr),lookup:Ye}))),ru=me(Ye),su=be({typeRef:Ye,length:it(Ye)}),ou=it(Ye),iu=Ye,cu=be({ok:Ye,ko:Ye}),fr=he({struct:eu,terminal:tu,enum:nu,tuple:ru,array:su,binary:ou,option:iu,result:cu}),au={i256:L.big,i128:L.big,i64:L.big,i32:L.num,i16:L.num,i8:L.num,u256:L.big,u128:L.big,u64:L.big,u32:L.num,u16:L.num,u8:L.num,bool:L.bool,char:L.str,str:L.str},Xt=e=>({type:"terminal",value:{type:e}});function yn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Xt(L.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 Xt(L.bits);case"compact":return Xt(e.isBig?L.big:L.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:yn(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 Xt(au[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 Xt(L.void)}}function hr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>hr(o,i,n),s=o=>{switch(o.value.type){case L.str:case L.big:case L.bool:case L.num:return typeof e===o.value.type;case L.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case L.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof De&&(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(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var uu=Object.defineProperty,lu=(e,t,n)=>t in e?uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fu=(e,t,n)=>lu(e,t+"",n);class So{constructor(t=[]){fu(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 Ae=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ae||{});function dr(e,t,n,r,s){if(!n&&!e)return pe(3);if(!n)return pe(2);if(!e)return pe(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new So([[e,n]])}:pe(c)}o.set(e,null);const i=hu(e,n,(c,u)=>dr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function hu(e,t,n){if(e.type!==t.type)return t.type==="option"?gn(n(e,t.value),2):e.type==="option"?gn(n(e.value,t),1):pe(0);switch(t.type){case"terminal":return pe(t.value.type===e.value.type?3:0);case"binary":return pe(_o(e.value,t.value));case"array":const s=e,o=pe(_o(s.value.length,t.value.length));return pr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([f,p])=>[f,p.value])),h=l.value.length===t.value.length?3:2;return gn(Io(l.value.map(([f,p])=>()=>f in d?n(p.value,d[f]):pe(0))),h)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return gn(pr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=pe(pu(l.value,t.value));return pr([d,...t.value.map((h,f)=>()=>n(l.value[f],h))])}case"result":const a=e;return Io([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const gn=(e,t)=>({...e,level:Math.min(e.level,t)}),du=new So,pe=e=>({level:e,assumptions:du}),pr=e=>{let t=pe(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Io=e=>{if(!e.length)return pe(3);let t=!1,n=pe(3);for(const r of e){const s=typeof r=="function"?r():r;if(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:pe(0)},pu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,_o=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Bo=he({lookup:O,typedef:fr}),Et=e=>({type:"lookup",value:e}),vr=e=>({type:"typedef",value:e}),wn=vr({type:"terminal",value:{type:L.void}}),vu=be({args:Bo,values:Bo});function bu(e){if(e.type.tag==="plain")return{args:wn,values:Et(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Et(t),values:Et(n)}}function mu(e){return{args:vr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Et(e.output)}}function yu(e){return e.type==="lookupEntry"?Et(e.value.id):vr(yn(e))}function gu(e){return{args:wn,values:Et(e)}}function wu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:dr(o(e.args,t),t,o(n.args,r),r,s).level,values:dr(o(n.values,r),r,o(e.values,t),t,s).level}}function Oo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return hr(n,r,t)}const xt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},En={chainName:"",genesisHash:"",properties:""},br={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:En,transaction:br}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Eu=e=>(t,n)=>{let r=e(br.broadcast,[t],{onSuccess:s=>{r=s===null?xt:()=>{e(br.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Co extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class xn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class kn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class $o extends Error{constructor(t){super(t),this.name="OperationError"}}class An extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function xu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const To=()=>{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)})}}},Sn=e=>(...t)=>new Promise((n,r)=>{let s=Vt;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new Us)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Vt,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Po=(e,t)=>n=>Sn((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new kn);const{operationId:h}=l,f=()=>{n(Se.stopOperation,[h])};if(!i)return f();let p=xt;const v=m=>{i=!1,p(),r(m)},b=m=>{i=!1,p(),s(m)};p=d(h,{next:m=>{const g=m;g.event==="operationError"?s(new $o(g.error)):g.event==="operationInaccessible"?s(new An):a(m,v,b)},error:b}),c=()=>{i&&(p(),f())}},onError:s}),()=>{c()}}),ku=Po(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),Au=Po(Se.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Su=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),Ro=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Vt;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new kn);const{operationId:h}=l,f=()=>{e(Se.stopOperation,[h])};if(!u)return f();const p=d(l.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{s(m.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new $o(m.error));break}case"operationInaccessible":{v(new An);break}default:e(Se.continue,[m.operationId])}},error:o});a=()=>{p(),e(Se.stopOperation,[l.operationId])};const v=m=>{a=Vt,p(),o(m)},b=()=>{a=Vt,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Iu=e=>{const t=Ro(e);return Sn((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?h=>{a.push(h)}:h=>{a=h[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(h){r(h)}},h=>{h>0&&(d(),r(new kn))});return d})},_u=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class In extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function Bu(e){return e.operationId!==void 0}function Ou(e){return(t,n,r)=>{const s=To(),o=new Set,i=xu();let c=i.promise;const u=p=>{if(Bu(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Co),h(!1)},a=p=>{r(p),h(!(p instanceof In))},l=(p,v)=>{const b=v(p,{next:u,error:a});h=(m=!0)=>{c=null,h=xt,b(),m&&e(Se.unfollow,[p]),s.errorAll(new xn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof In?h(!1):r(p),c=null,i.res(p)};let h=e(Se.follow,[t],{onSuccess:l,onError:d});const f=(p,v,b)=>{const m=()=>{b?.onError(new xn)};if(c===null)return m(),xt;const g=y=>{if(!b)return e(p,[y,...v]);o.add(m);const w=(_,T)=>c===null?(T.error(new xn),xt):(s.subscribe(_,T),()=>{s.unsubscribe(_)}),A=e(p,[y,...v],{onSuccess:_=>{o.delete(m),b.onSuccess(_,w)},onError:_=>{o.delete(m),b.onError(_)}});return()=>{o.delete(m),A()}};if(typeof c=="string")return g(c);let x=xt;return c.then(y=>{if(y instanceof Error)return m();c&&(x=g(y))}),()=>{x()}};return{unfollow(){h(),c=null},body:ku(f),call:Au(f),header:Su(f),storage:Iu(f),storageSubscription:Ro(f),unpin:_u(f),_request:f}}}var Cu=Object.defineProperty,$u=(e,t,n)=>t in e?Cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uo=(e,t,n)=>$u(e,typeof t!="symbol"?t+"":t,n);class Mo extends Error{constructor(t){super(t.message),Uo(this,"code"),Uo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let Tu=1;const Pu=e=>{let t=Tu++;const n=new Map,r=To();let s=null;const o=(l,d,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:h}))};function i(l){try{let d,h,f,p,v;if({id:d,result:h,error:f,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),f?g.onError(new Mo(f)):g.onSuccess(h,(x,y)=>{const w=x;return r.subscribe(w,y),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:h,error:f}=p,!v||!f&&!Object.hasOwn(p,"result"))throw 0;const m=v;f?r.error(m,new Mo(f)):r.next(m,h)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new In),n.forEach(l=>l.onError(new In)),n.clear()};let u=1;return{request:(l,d,h)=>{if(!s)throw new Error("Not connected");const f=`${t}-${u++}`;return h&&n.set(f,h),o(f,l,d),()=>{n.delete(f)}},disconnect:c}},Ru=e=>{const t=Sn((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(En.chainName,[]),t(En.genesisHash,[]),t(En.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},_n=new Map,Uu=e=>{const t=_n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Pu(e),s=()=>{const i=_n.get(e);!i||i.refCount<=1?(_n.delete(e),r()):i.refCount--},o={chainHead:Ou(n),transaction:Eu(n),getChainSpecData:Ru(n),destroy:s,request:Sn((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return _n.set(e,{client:o,refCount:1}),o};var mr=function(e,t){return mr=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])},mr(e,t)};function ze(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Mu(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 c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Lo(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=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function kt(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 Oe(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(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Ce(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 At(e){return this instanceof At?(this.v=e,this):new At(e)}function Lu(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),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(p){return Promise.resolve(p).then(f,d)}}function c(f,p){r[f]&&(s[f]=function(v){return new Promise(function(b,m){o.push([f,v,b,m])>1||u(f,v)})},p&&(s[f]=p(s[f])))}function u(f,p){try{a(r[f](p))}catch(v){h(o[0][3],v)}}function a(f){f.value instanceof At?Promise.resolve(f.value.v).then(l,d):h(o[0][2],f)}function l(f){u("next",f)}function d(f){u("throw",f)}function h(f,p){f(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Du(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 kt=="function"?kt(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(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function yr(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 gr=yr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(ie,Rt){typeof exports=="object"&&typeof module<"u"?Rt(exports):typeof define=="function"&&define.amd?define(["exports"],Rt):(ie=typeof globalThis<"u"?globalThis:ie||self,Rt(ie.papi={}))})(this,function(ie){"use strict";var Rt=Object.defineProperty,Zi=(e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gr=(e,t,n)=>(Zi(e,typeof t!="symbol"?t+"":t,n),n),Kn={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 Ji(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|Kn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Kn[e[i]],u=Kn[e[i+1]];s[t+o++]=c<<4|u}return s}var Nr=class extends Uint8Array{constructor(e){super(e),Gr(this,"i",0),Gr(this,"v"),this.v=new DataView(e)}},Ee=e=>t=>e(t instanceof Nr?t:new Nr(t instanceof Uint8Array?t.buffer:typeof t=="string"?Ji(t).buffer:t)),Re=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 sn(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 on=Ee,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ut=(e,t)=>n=>e(t(n)),Xn=(e,t)=>n=>t(e(n)),Qe=([e,t],n,r)=>D(Ut(e,n),Xn(t,r));function ec(e,t){return Ee(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function tc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ze(e,t,n){return D(tc(e,n),ec(e,t))}var j=Ze(1,"getUint8","setUint8"),Je=Ze(2,"getUint16","setUint16"),Be=Ze(4,"getUint32","setUint32"),Mt=Ze(8,"getBigUint64","setBigUint64"),nc=Ze(1,"getInt8","setInt8"),rc=Ze(2,"getInt16","setInt16"),sc=Ze(4,"getInt32","setInt32"),oc=Ze(8,"getBigInt64","setBigInt64"),Qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Zr=e=>Ee(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}),Jr=D(Qr,Zr("getBigUint64")),ic=D(Qr,Zr("getBigInt64")),es=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},ts=e=>Ee(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}),cc=D(es,ts("getBigUint64")),ac=D(es,ts("getBigInt64")),uc=Qe(j,e=>e?1:0,Boolean),lc=[j[1],Je[1],Be[1]],fc=Ee(e=>{const t=e[e.i],n=t&3;if(n<3)return lc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=Mt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(Be[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Je[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(j[1](e))<<i|s),s}),hc=1n<<56n,dc=1<<24,pc=256,vc=4294967295n,bc=64,mc=16384,yc=1<<30,gc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<bc)return j[0](t);if(e<mc)return Je[0](t|1);if(e<yc)return Be[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=hc;)n.push(Mt[0](r)),r>>=64n;r>=dc&&(n.push(Be[0](Number(r&vc))),r>>=32n);let s=Number(r);s>=pc&&(n.push(Je[0](s)),s>>=16),s&&n.push(j[0](s));const o=Re(n);return o[0]=o.length-5<<2|3,o},ce=D(gc,fc),wc=new TextEncoder,Ec=e=>{const t=wc.encode(e);return Re([ce.enc(t.length),t])},xc=new TextDecoder,kc=Ee(e=>{let t=ce.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,xc.decode(n)}),ee=D(Ec,kc),Ac=()=>{},Sc=new Uint8Array(0),B=D(()=>Sc,Ac),ns=e=>e===void 0?t=>Re([ce.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),rs=e=>Ee(t=>{const n=e===void 0?ce.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}),N=e=>D(ns(e),rs(e));N.enc=ns,N.dec=rs;var ss=(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})=>Re([j.enc(s(o)),e[o](i)])},os=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ee(s=>{const o=j.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},xe=(e,...t)=>D(ss(sn(e,([n])=>n),...t),os(sn(e,([,n])=>n),...t));xe.enc=ss,xe.dec=os;var is=e=>Ee(t=>j[1](t)>0?e(t):void 0),cs=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Re([n,e(t)]))},ke=e=>D(cs(e[0]),is(e[1]));ke.enc=cs,ke.dec=is;var as=(e,t)=>Ee(n=>{const r=j[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),us=(e,t)=>({success:n,value:r})=>Re([j[0](n?0:1),(n?e:t)(r)]),Lt=(e,t)=>D(us(e[0],t[0]),as(e[1],t[1]));Lt.dec=as,Lt.enc=us;var ls=(...e)=>Ee(t=>e.map(n=>n(t))),fs=(...e)=>t=>Re(e.map((n,r)=>n(t[r]))),Ue=(...e)=>D(fs(...e.map(([t])=>t)),ls(...e.map(([,t])=>t)));Ue.enc=fs,Ue.dec=ls;var hs=e=>{const t=Object.keys(e);return Ut(Ue.enc(...Object.values(e)),n=>t.map(r=>n[r]))},ds=e=>{const t=Object.keys(e);return Xn(Ue.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},U=e=>D(hs(sn(e,t=>t[0])),ds(sn(e,t=>t[1])));U.enc=hs,U.dec=ds;var ps=(e,t)=>t>=0?n=>Re(n.map(e)):n=>Re([ce.enc(n.length),Re(n.map(e))]),vs=(e,t)=>Ee(n=>{const r=t>=0?t:ce.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),z=(e,t)=>D(ps(e[0],t),vs(e[1],t));z.enc=ps,z.dec=vs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bs(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 Yn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ms(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gn(e){if(!Array.isArray(e))throw new Error("array expected")}function ys(e,t){if(!bs(!0,t))throw new Error(`${e}: array of strings expected`)}function _c(e,t){if(!bs(!1,t))throw new Error(`${e}: array of numbers expected`)}function Bc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function Oc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ys("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Gn(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=>(Gn(s),s.map(o=>{Yn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function Cc(e=""){return Yn("join",e),{encode:t=>(ys("join.decode",t),t.join(e)),decode:t=>(Yn("join.decode",t),t.split(e))}}function gs(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(Gn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ms(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,h=d+l;if(!Number.isSafeInteger(h)||d/t!==c||h-l!==d)throw new Error("convertRadix: carry overflow");const f=h/n;c=h%n;const p=Math.floor(f);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==h)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function $c(e){ms(e);const t=2**8;return{encode:n=>{if(!Ic(n))throw new Error("radix.encode input should be Uint8Array");return gs(Array.from(n),t,e)},decode:n=>(_c("radix.decode",n),Uint8Array.from(gs(n,e,t)))}}const ws=(e=>Bc($c(58),Oc(e),Cc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Tc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!Tc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Dt(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 Nn(e,t){ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Pc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function dt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cn(e,t){return e<<32-t|e>>>t}const Es=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Fe=Es?e=>e:e=>xs(e);function Rc(e){for(let t=0;t<e.length;t++)e[t]=xs(e[t]);return e}const ae=Es?e=>e:Rc;function Uc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Me(e){return typeof e=="string"&&(e=Uc(e)),ht(e),e}class ks{}function Mc(e){const t=r=>e().update(Me(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Lc(e){const t=(r,s)=>e(s).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Dc(e){const t=(r,s)=>e(s).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Vc=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 tt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,16),n=n+r|0,t=cn(t^n,12),{a:e,b:t,c:n,d:r}}function nt(e,t,n,r,s){return e=e+t+s|0,r=cn(r^e,8),n=n+r|0,t=cn(t^n,7),{a:e,b:t,c:n,d:r}}const jc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=BigInt(2**32-1),As=BigInt(32);function un(e,t=!1){return t?{h:Number(e&an),l:Number(e>>As&an)}:{h:Number(e>>As&an)|0,l:Number(e&an)|0}}function zc(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:c}=un(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Ss=(e,t,n)=>e>>>n|t<<32-n,Is=(e,t,n)=>e<<32-n|t>>>n,Hc=(e,t,n)=>e<<64-n|t>>>n-32,Fc=(e,t,n)=>e>>>n-32|t<<64-n,qc=(e,t)=>t,Wc=(e,t)=>e,Kc=(e,t,n)=>e<<n|t>>>32-n,Xc=(e,t,n)=>t<<n|e>>>32-n,Yc=(e,t,n)=>t<<n-32|e>>>64-n,Gc=(e,t,n)=>e<<n-32|t>>>64-n;function _s(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Bs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Os=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Y=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function rt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:qc(v,p),Dl:Wc(v)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Ss(d,l,24),Bl:Is(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],h=k[2*n],f=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Bs(u,l,i);a=Os(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Ss(v,p,16),Dl:Is(v,p,16)},{h:f,l:h}=_s(f,h,v,p),{Bh:d,Bl:l}={Bh:d^f,Bl:l^h},{Bh:d,Bl:l}={Bh:Hc(d,l,63),Bl:Fc(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=h,k[2*n+1]=f,k[2*r]=p,k[2*r+1]=v}function Nc(e,t={},n,r,s){if(gt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Cs extends ks{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,gt(t),gt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=dt(this.buffer)}update(t){Dt(this),t=Me(t),ht(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ae(s),this.compress(s,0,!1),ae(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ae(d);for(let h=0;u+n<o;h+=s.length,u+=n)this.length+=n,this.compress(d,h,!1);ae(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Dt(this),Nn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,et(this.buffer.subarray(n)),ae(r),this.compress(r,0,!0),ae(r);const s=dt(t);this.get().forEach((o,i)=>s[i]=Fe(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:c}=this;return t||(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=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class Qc extends Cs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=Y[0]|0,this.v0h=Y[1]|0,this.v1l=Y[2]|0,this.v1h=Y[3]|0,this.v2l=Y[4]|0,this.v2h=Y[5]|0,this.v3l=Y[6]|0,this.v3h=Y[7]|0,this.v4l=Y[8]|0,this.v4h=Y[9]|0,this.v5l=Y[10]|0,this.v5h=Y[11]|0,this.v6l=Y[12]|0,this.v6h=Y[13]|0,this.v7l=Y[14]|0,this.v7h=Y[15]|0,Nc(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Me(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Me(o);const c=dt(o);this.v4l^=Fe(c[0]),this.v4h^=Fe(c[1]),this.v5l^=Fe(c[2]),this.v5h^=Fe(c[3])}if(s!==void 0){s=Me(s);const c=dt(s);this.v6l^=Fe(c[0]),this.v6h^=Fe(c[1]),this.v7l^=Fe(c[2]),this.v7h^=Fe(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:h,v6l:f,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b){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=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=h|0,this.v6l=f|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(Y,16);let{h:s,l:o}=un(BigInt(this.length));k[24]=Y[8]^o,k[25]=Y[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Vc;for(let u=0;u<12;u++)rt(0,4,8,12,t,n+2*c[i++]),st(0,4,8,12,t,n+2*c[i++]),rt(1,5,9,13,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),rt(2,6,10,14,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),rt(3,7,11,15,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),rt(0,5,10,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),rt(1,6,11,12,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),rt(2,7,8,13,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),rt(3,4,9,14,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],et(k)}destroy(){this.destroyed=!0,et(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Zc=Lc(e=>new Qc(e));function $s(e,t,n,r,s,o,i,c,u,a,l,d,h,f,p,v,b,m,g,x){let y=0;for(let w=0;w<r;w++)({a:s,b:u,c:h,d:b}=tt(s,u,h,b,n[t+e[y++]])),{a:s,b:u,c:h,d:b}=nt(s,u,h,b,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=tt(o,a,f,m,n[t+e[y++]]),{a:o,b:a,c:f,d:m}=nt(o,a,f,m,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=tt(i,l,p,g,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=tt(c,d,v,x,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=nt(c,d,v,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=tt(s,a,p,x,n[t+e[y++]]),{a:s,b:a,c:p,d:x}=nt(s,a,p,x,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=tt(o,l,v,b,n[t+e[y++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=tt(i,d,h,m,n[t+e[y++]]),{a:i,b:d,c:h,d:m}=nt(i,d,h,m,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=tt(c,u,f,g,n[t+e[y++]]),{a:c,b:u,c:f,d:g}=nt(c,u,f,g,n[t+e[y++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:h,v9:f,v10:p,v11:v,v12:b,v13:m,v14:g,v15:x}}const ln=Zc,Ts=new TextEncoder().encode("SS58PRE"),Qn=2,Zn=e=>{try{const t=ws.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qn),s=t.subarray(n.length+r.length),o=ln(Uint8Array.of(...Ts,...n,...r),{dkLen:64}).subarray(0,Qn);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Jc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Jc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ps=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ln(Uint8Array.of(...Ts,...t,...n),{dkLen:64}).subarray(0,Qn);return ws.encode(Uint8Array.of(...t,...n,...r))}};function ea(e,t){return n=>{const r=Zn(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 pt=(e=42,t=32)=>Qe(N(t),ea(t),Ps(e)),Rs="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rs[r>>4]+Rs[r&15]}return t.join("")}const Jn={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 fe(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|Jn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Jn[e[i]],u=Jn[e[i+1]];s[t+o++]=c<<4|u}return s}function wt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n},Vt=Function.prototype;class Us extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ta=Object.defineProperty,Ms=e=>{throw TypeError(e)},na=(e,t,n)=>t in e?ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n)=>na(e,typeof t!="symbol"?t+"":t,n),Ls=(e,t,n)=>t.has(e)||Ms("Cannot "+n),qe=(e,t,n)=>(Ls(e,t,"read from private field"),n?n.call(e):t.get(e)),zt=(e,t,n)=>t.has(e)?Ms("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),vt=(e,t,n,r)=>(Ls(e,t,"write to private field"),t.set(e,n),n),We,Ht,fn,hn,dn;const ra=new TextEncoder,sa=new TextDecoder,oa=Ue(ce,N(1/0))[1];class Le{constructor(t,n=!1){if(zt(this,We),zt(this,Ht,null),zt(this,fn,null),zt(this,hn,null),zt(this,dn,null),jt(this,"asText",()=>qe(this,dn)??vt(this,dn,sa.decode(qe(this,We)))),jt(this,"asHex",()=>qe(this,fn)||vt(this,fn,te(qe(this,We)))),jt(this,"asOpaqueHex",()=>qe(this,hn)||vt(this,hn,te(this.asBytes()))),jt(this,"asBytes",()=>qe(this,We)),jt(this,"asOpaqueBytes",()=>qe(this,Ht)||vt(this,Ht,ue(ce[0](qe(this,We).length),qe(this,We)))),n){try{const[r,s]=oa(t);if(r===s.length){vt(this,We,s),vt(this,Ht,t);return}}catch{}throw new Error("Invalid opaque bytes")}else vt(this,We,t)}static fromText(t){return new this(ra.encode(t))}static fromHex(t){return new this(fe(t))}static fromOpaqueHex(t){return new this(fe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}We=new WeakMap,Ht=new WeakMap,fn=new WeakMap,hn=new WeakMap,dn=new WeakMap;const[ia]=pt();class pn extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ia(t))}}const Ds=e=>{const t=N.enc(e);return n=>t(n.asBytes())},Vs=e=>{const t=N.dec(e),n=e==null?Le:pn;return r=>n.fromBytes(t(r))},Ft=e=>D(Ds(e),Vs(e));Ft.enc=Ds,Ft.dec=Vs;const O=Qe(ce,e=>e,Number),vn=Qe(ce,e=>e,BigInt),ca=on(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:N(n).dec(e),bitsLen:t}}),js=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ca),aa=Qe(j,e=>e.charCodeAt(0),String.fromCharCode),zs=e=>{const t=N.enc(e);return n=>t(fe(n))},Hs=e=>{const t=N.dec(e);return n=>te(t(n))},ot=e=>D(zs(e),Hs(e));ot.enc=zs,ot.dec=Hs;const ua=new TextEncoder,la=new TextDecoder,fa=e=>Qe(N(e),t=>ua.encode(t),t=>la.decode(t)),Fs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},qs=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},er=e=>D(Fs(()=>e().enc),qs(()=>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}}),Ws=new Proxy({},{get(e,t){return n=>bt(t,n)}}),F=(e,t)=>{const n=e;return n.inner=t,n},Ks=(...e)=>{const t=xe.enc(...e);return F(n=>t({tag:n.type,value:n.value}),e[0])},Xs=(...e)=>{const t=xe.dec(...e);return F(n=>{const{tag:r,value:s}=t(n);return bt(r,s)},e[0])},he=(e,...t)=>F(D(Ks(wt(e,([n])=>n),...t),Xs(wt(e,([,n])=>n),...t)),e);he.enc=Ks,he.dec=Xs;const tr=(e,...t)=>F(xe(e,...t),e);tr.enc=(e,...t)=>F(xe.enc(e,...t),e),tr.dec=(e,...t)=>F(xe.dec(e,...t),e);const ha=BigInt(0),qt=BigInt(1),da=BigInt(2),pa=BigInt(7),va=BigInt(256),ba=BigInt(113),Ys=[],Gs=[],Ns=[];for(let e=0,t=qt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Ys.push(2*(5*r+n)),Gs.push((e+1)*(e+2)/2%64);let s=ha;for(let o=0;o<7;o++)t=(t<<qt^(t>>pa)*ba)%va,t&da&&(s^=qt<<(qt<<BigInt(o))-qt);Ns.push(s)}const Qs=zc(Ns,!0),ma=Qs[0],ya=Qs[1],Zs=(e,t,n)=>n>32?Yc(e,t,n):Kc(e,t,n),Js=(e,t,n)=>n>32?Gc(e,t,n):Xc(e,t,n);function ga(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 c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=Zs(a,l,1)^n[c],h=Js(a,l,1)^n[c+1];for(let f=0;f<50;f+=10)e[i+f]^=d,e[i+f+1]^=h}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=Gs[i],u=Zs(s,o,c),a=Js(s,o,c),l=Ys[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=ma[r],e[1]^=ya[r]}et(n)}class nr extends ks{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,gt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=dt(this.state)}clone(){return this._cloneInto()}keccak(){ae(this.state32),ga(this.state32,this.rounds),ae(this.state32),this.posOut=0,this.pos=0}update(t){Dt(this),t=Me(t),ht(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 c=0;c<i;c++)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){Dt(this,!1),ht(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 gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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,et(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(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 wa=(e,t,n)=>Mc(()=>new nr(t,e,n)),Ea=wa(1,136,256/8),eo=e=>{const t=e.slice(2),n=te(Ea(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("")}`},xa=N(20)[1],to=D(e=>{const t=fe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(eo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},on(e=>eo(te(xa(e))))),be=e=>F(U(e),e);be.enc=e=>F(U.enc(e),e),be.dec=e=>F(U.dec(e),e);const De=(...e)=>F(Ue(...e),e);De.enc=(...e)=>F(Ue.enc(...e),e),De.dec=(...e)=>F(Ue.dec(...e),e);const me=(e,...t)=>F(z(e,...t),e);me.enc=(e,...t)=>F(z.enc(e,...t),e),me.dec=(e,...t)=>F(z.dec(e,...t),e);const bn=(e,t)=>F(Lt(e,t),{ok:e,ko:t});bn.enc=(e,t)=>F(Lt.enc(e,t),{ok:e,ko:t}),bn.dec=(e,t)=>F(Lt.dec(e,t),{ok:e,ko:t});const it=e=>F(ke(e),e);it.enc=e=>F(ke.enc(e),e),it.dec=e=>F(ke.dec(e),e);const no=new TextEncoder,ro=new TextDecoder,ka=Qe(N(4),no.encode.bind(no),ro.decode.bind(ro)),rr=be({engine:ka,payload:ot()}),Aa=he({consensus:rr,seal:rr,preRuntime:rr,runtimeUpdated:B},[4,5,6,8]),sr=ot(32),so=be({parentHash:sr,number:O,stateRoot:sr,extrinsicRoot:sr,digests:me(Aa)}),Ke=z(ee),oo=ke(ee),Sa=xe({bool:B,char:B,str:B,u8:B,u16:B,u32:B,u64:B,u128:B,u256:B,i8:B,i16:B,i32:B,i64:B,i128:B,i256:B}),io=z(U({name:oo,type:O,typeName:oo,docs:Ke})),Ia=U({len:Be,type:O}),_a=U({bitStoreType:O,bitOrderType:O}),Ba=z(U({name:ee,fields:io,index:j,docs:Ke})),Oa=xe({composite:io,variant:Ba,sequence:O,array:Ia,tuple:z(O),primitive:Sa,compact:O,bitSequence:_a}),Ca=U({name:ee,type:ke(O)}),$a=z(Ca),Ta=U({id:O,path:Ke,params:$a,def:Oa,docs:Ke}),or=z(Ta),Pa=xe({Blake2128:B,Blake2256:B,Blake2128Concat:B,Twox128:B,Twox256:B,Twox64Concat:B,Identity:B}),Ra=z(Pa),Ua=U({hashers:Ra,key:O,value:O}),Ma=U({name:ee,modifier:j,type:xe({plain:O,map:Ua}),fallback:ot(),docs:Ke}),La=ke(U({prefix:ee,items:z(Ma)})),co={name:ee,storage:La,calls:ke(O),events:ke(O),constants:z(U({name:ee,type:O,value:ot(),docs:Ke})),errors:ke(O),index:j},Da={...co,docs:Ke},Va=new Uint8Array,ao=e=>D(()=>Va,()=>e),ja=U({type:O,version:j,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),uo=U({lookup:or,pallets:z(U({...co,docs:ao([])})),extrinsic:ja,type:O,apis:ao([])}),za=U({name:ee,methods:z(U({name:ee,inputs:z(U({name:ee,type:O})),output:O,docs:Ke})),docs:Ke}),Ha=U({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:z(U({identifier:ee,type:O,additionalSigned:O}))}),lo=U({lookup:or,pallets:z(U(Da)),extrinsic:Ha,type:O,apis:z(za),outerEnums:U({call:O,event:O,error:O}),custom:z(Ue(ee,U({type:O,value:ot()})))}),fo=()=>{throw new Error("Unsupported metadata version!")},de=D(fo,fo),ct=U({magicNumber:Be,metadata:xe({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:uo,v15:lo})}),ir=N(),Fa=ke(ir),qa=Ue(ce,ir),cr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(Fa.dec(e))}catch{}try{return ct.dec(ir.dec(e))}catch{}try{return ct.dec(qa.dec(e)[1])}catch{}throw null},Wa={dkLen:32},Wt=e=>ln(e,Wa),Ka={dkLen:16},ar=e=>ln(e,Ka),ho=e=>ue(ar(e),e),Ve={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Xe=jc.slice(),po=(()=>{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 ur extends Cs{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;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');const i=Me(r).slice();ht(i,32),this.IV=dt(i),ae(this.IV),this.flags=n|Ve.KEYED_HASH}else if(o){const i=Me(s),c=new ur({dkLen:32},Ve.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=dt(c),ae(this.IV),this.flags=n|Ve.DERIVE_KEY_MATERIAL}else this.IV=Xe.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Pc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=un(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:h,v4:f,v5:p,v6:v,v7:b,v8:m,v9:g,v10:x,v11:y,v12:w,v13:A,v14:_,v15:T}=$s(po,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Xe[0],Xe[1],Xe[2],Xe[3],c,u,i,n);o[0]=a^m,o[1]=l^g,o[2]=d^x,o[3]=h^y,o[4]=f^w,o[5]=p^A,o[6]=v^_,o[7]=b^T}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ve.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ve.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,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ve.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:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,et(this.state,this.buffer32,this.IV,this.bufferOut32),et(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=un(BigInt(this.chunkOut++));ae(s);const{v0:u,v1:a,v2:l,v3:d,v4:h,v5:f,v6:p,v7:v,v8:b,v9:m,v10:g,v11:x,v12:y,v13:w,v14:A,v15:_}=$s(po,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Xe[0],Xe[1],Xe[2],Xe[3],c,i,n,r);o[0]=u^b,o[1]=a^m,o[2]=l^g,o[3]=d^x,o[4]=h^y,o[5]=f^w,o[6]=p^A,o[7]=v^_,o[8]=t[0]^b,o[9]=t[1]^m,o[10]=t[2]^g,o[11]=t[3]^x,o[12]=t[4]^y,o[13]=t[5]^w,o[14]=t[6]^A,o[15]=t[7]^_,ae(s),ae(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,et(this.buffer.subarray(this.pos));let t=this.flags|Ve.ROOT;this.stack.length?(t|=Ve.PARENT,ae(this.buffer32),this.compress(this.buffer32,0,!0),ae(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ve.CHUNK_START)|Ve.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Dt(this,!1),ht(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 gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Nn(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 Xa=Dc(e=>new ur(e)),Ya={dkLen:32},vo=e=>Xa(e,Ya),Ga=e=>ue(vo(e),e),bo=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),lr=2n**64n-1n,re=(e,t)=>e<<t&lr|e>>64n-t,M=(e,t)=>e*t&lr,Q=(e,t)=>e+t&lr,Z=11400714785074694791n,ye=14029467366897019727n,mo=1609587929392839161n,Kt=9650029242287828579n,yo=2870177450012600261n;function at(e,t=0n){let n=Q(Q(t,Z),ye),r=Q(t,ye),s=t,o=t-Z,i=e.length,c=0,u=null;(function(){let f=0,p=f+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(f<=p-32){const v=p-32;do{let b;b=mt(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=M(re(Q(n,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(r,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(s,M(b,ye)),31n),Z),f+=8,b=mt(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=M(re(Q(o,M(b,ye)),31n),Z),f+=8}while(f<=v)}f<p&&(u.set(e.subarray(f,p),c),c=p-f)}})(),e=u||e;let a,l=0;for(i>=32?(a=re(n,1n),a=Q(a,re(r,7n)),a=Q(a,re(s,12n)),a=Q(a,re(o,18n)),n=M(re(M(n,ye),31n),Z),a=a^n,a=Q(M(a,Z),Kt),r=M(re(M(r,ye),31n),Z),a=a^r,a=Q(M(a,Z),Kt),s=M(re(M(s,ye),31n),Z),a=a^s,a=Q(M(a,Z),Kt),o=M(re(M(o,ye),31n),Z),a=a^o,a=Q(M(a,Z),Kt)):a=Q(t,yo),a=Q(a,BigInt(i));l<=c-8;){let h=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=M(re(M(h,ye),31n),Z),a=Q(M(re(a^h,27n),Z),Kt),l+=8}if(l+4<=c){let h=M(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),Z);a=Q(M(re(a^h,23n),ye),mo),l+=4}for(;l<c;){const h=M(mt(e[l++],0,0,0),yo);a=M(re(a^h,11n),Z)}let d=a>>33n;return a=M(a^d,ye),d=a>>29n,a=M(a^d,mo),d=a>>32n,a^=d,a}const mn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},go=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},wo=e=>ue(Mt.enc(at(e)),e),Eo=new TextEncoder,Na=new Map([[bo,0],[wo,8],[ho,16],[ar,-16],[Wt,-32],[mn,-16],[go,-32]]),xo=e=>{const t=mn(Eo.encode(e));return(n,...r)=>{const s=ue(t,mn(Eo.encode(n))),o=te(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=fe(a.slice(o.length)),d=new Array(r.length);for(let h=0,f=0;h<r.length;h++){const[p,v]=r[h],b=Na.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[h]=te(l.slice(f,f+m)),f+=m}else f+=b,d[h]=p.dec(l.slice(f)),f+=p.enc(d[h]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>te(ue(s,...a.map((l,d)=>c[d](l)))),dec:i}}},Qa=Le.fromText("modlpy/utilisuba").asBytes(),Za=({threshold:e,signatories:t})=>{const n=ko(t),r=ue(Qa,ce.enc(n.length),...n,Je.enc(e));return Wt(r)},ko=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}});var Ao=Object.freeze({__proto__:null,AccountId:pt,Bin:Ft,Binary:Le,Blake2128:ar,Blake2128Concat:ho,Blake2256:Wt,Blake3256:vo,Blake3256Concat:Ga,Bytes:N,Enum:bt,FixedSizeBinary:pn,Hex:ot,Identity:bo,Option:it,Result:bn,ScaleEnum:tr,Self:er,Storage:xo,Struct:be,Tuple:De,Twox128:mn,Twox256:go,Twox64Concat:wo,Variant:he,Vector:me,_Enum:Ws,_void:B,bitSequence:js,blockHeader:so,bool:uc,char:aa,compact:ce,compactBn:vn,compactNumber:O,createCodec:D,createDecoder:on,decAnyMetadata:cr,enhanceCodec:Qe,enhanceDecoder:Xn,enhanceEncoder:Ut,ethAccount:to,fixedStr:fa,fromBufferToBase58:Ps,getMultisigAccountId:Za,getSs58AddressInfo:Zn,h64:at,i128:ic,i16:rc,i256:ac,i32:sc,i64:oc,i8:nc,metadata:ct,selfDecoder:qs,selfEncoder:Fs,sortMultisigSignatories:ko,str:ee,u128:Jr,u16:Je,u256:cc,u32:Be,u64:Mt,u8:j,v14:uo,v14Lookup:or,v15:lo});const Ye=O,Ja=me(De(ee,Ye)),L={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},eu=he(Object.fromEntries(Object.values(L).map(e=>[e,B]))),tu=me(De(ee,he({inline:er(()=>fr),lookup:Ye}))),nu=me(Ye),ru=be({typeRef:Ye,length:it(Ye)}),su=it(Ye),ou=Ye,iu=be({ok:Ye,ko:Ye}),fr=he({struct:Ja,terminal:eu,enum:tu,tuple:nu,array:ru,binary:su,option:ou,result:iu}),cu={i256:L.big,i128:L.big,i64:L.big,i32:L.num,i16:L.num,i8:L.num,u256:L.big,u128:L.big,u64:L.big,u32:L.num,u16:L.num,u8:L.num,bool:L.bool,char:L.str,str:L.str},Xt=e=>({type:"terminal",value:{type:e}});function yn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Xt(L.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 Xt(L.bits);case"compact":return Xt(e.isBig?L.big:L.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:yn(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 Xt(cu[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 Xt(L.void)}}function hr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>hr(o,i,n),s=o=>{switch(o.value.type){case L.str:case L.big:case L.bool:case L.num:return typeof e===o.value.type;case L.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case L.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof Le&&(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(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var au=Object.defineProperty,uu=(e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lu=(e,t,n)=>uu(e,t+"",n);class So{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 Ae=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ae||{});function dr(e,t,n,r,s){if(!n&&!e)return pe(3);if(!n)return pe(2);if(!e)return pe(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new So([[e,n]])}:pe(c)}o.set(e,null);const i=fu(e,n,(c,u)=>dr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function fu(e,t,n){if(e.type!==t.type)return t.type==="option"?gn(n(e,t.value),2):e.type==="option"?gn(n(e.value,t),1):pe(0);switch(t.type){case"terminal":return pe(t.value.type===e.value.type?3:0);case"binary":return pe(_o(e.value,t.value));case"array":const s=e,o=pe(_o(s.value.length,t.value.length));return pr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([f,p])=>[f,p.value])),h=l.value.length===t.value.length?3:2;return gn(Io(l.value.map(([f,p])=>()=>f in d?n(p.value,d[f]):pe(0))),h)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return gn(pr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=pe(du(l.value,t.value));return pr([d,...t.value.map((h,f)=>()=>n(l.value[f],h))])}case"result":const a=e;return Io([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const gn=(e,t)=>({...e,level:Math.min(e.level,t)}),hu=new So,pe=e=>({level:e,assumptions:hu}),pr=e=>{let t=pe(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Io=e=>{if(!e.length)return pe(3);let t=!1,n=pe(3);for(const r of e){const s=typeof r=="function"?r():r;if(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:pe(0)},du=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,_o=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Bo=he({lookup:O,typedef:fr}),Et=e=>({type:"lookup",value:e}),vr=e=>({type:"typedef",value:e}),wn=vr({type:"terminal",value:{type:L.void}}),pu=be({args:Bo,values:Bo});function vu(e){if(e.type.tag==="plain")return{args:wn,values:Et(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Et(t),values:Et(n)}}function bu(e){return{args:vr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Et(e.output)}}function mu(e){return e.type==="lookupEntry"?Et(e.value.id):vr(yn(e))}function yu(e){return{args:wn,values:Et(e)}}function gu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:dr(o(e.args,t),t,o(n.args,r),r,s).level,values:dr(o(n.values,r),r,o(e.values,t),t,s).level}}function Oo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return hr(n,r,t)}const xt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},En={chainName:"",genesisHash:"",properties:""},br={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:En,transaction:br}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const wu=e=>(t,n)=>{let r=e(br.broadcast,[t],{onSuccess:s=>{r=s===null?xt:()=>{e(br.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Co extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class xn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class kn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class $o extends Error{constructor(t){super(t),this.name="OperationError"}}class An extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Eu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const To=()=>{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)})}}},Sn=e=>(...t)=>new Promise((n,r)=>{let s=Vt;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new Us)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Vt,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Po=(e,t)=>n=>Sn((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new kn);const{operationId:h}=l,f=()=>{n(Se.stopOperation,[h])};if(!i)return f();let p=xt;const v=m=>{i=!1,p(),r(m)},b=m=>{i=!1,p(),s(m)};p=d(h,{next:m=>{const g=m;g.event==="operationError"?s(new $o(g.error)):g.event==="operationInaccessible"?s(new An):a(m,v,b)},error:b}),c=()=>{i&&(p(),f())}},onError:s}),()=>{c()}}),xu=Po(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),ku=Po(Se.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Au=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),Ro=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Vt;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new kn);const{operationId:h}=l,f=()=>{e(Se.stopOperation,[h])};if(!u)return f();const p=d(l.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{s(m.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new $o(m.error));break}case"operationInaccessible":{v(new An);break}default:e(Se.continue,[m.operationId])}},error:o});a=()=>{p(),e(Se.stopOperation,[l.operationId])};const v=m=>{a=Vt,p(),o(m)},b=()=>{a=Vt,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Su=e=>{const t=Ro(e);return Sn((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?h=>{a.push(h)}:h=>{a=h[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(h){r(h)}},h=>{h>0&&(d(),r(new kn))});return d})},Iu=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class In extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function _u(e){return e.operationId!==void 0}function Bu(e){return(t,n,r)=>{const s=To(),o=new Set,i=Eu();let c=i.promise;const u=p=>{if(_u(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Co),h(!1)},a=p=>{r(p),h(!(p instanceof In))},l=(p,v)=>{const b=v(p,{next:u,error:a});h=(m=!0)=>{c=null,h=xt,b(),m&&e(Se.unfollow,[p]),s.errorAll(new xn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof In?h(!1):r(p),c=null,i.res(p)};let h=e(Se.follow,[t],{onSuccess:l,onError:d});const f=(p,v,b)=>{const m=()=>{b?.onError(new xn)};if(c===null)return m(),xt;const g=y=>{if(!b)return e(p,[y,...v]);o.add(m);const w=(_,T)=>c===null?(T.error(new xn),xt):(s.subscribe(_,T),()=>{s.unsubscribe(_)}),A=e(p,[y,...v],{onSuccess:_=>{o.delete(m),b.onSuccess(_,w)},onError:_=>{o.delete(m),b.onError(_)}});return()=>{o.delete(m),A()}};if(typeof c=="string")return g(c);let x=xt;return c.then(y=>{if(y instanceof Error)return m();c&&(x=g(y))}),()=>{x()}};return{unfollow(){h(),c=null},body:xu(f),call:ku(f),header:Au(f),storage:Su(f),storageSubscription:Ro(f),unpin:Iu(f),_request:f}}}var Ou=Object.defineProperty,Cu=(e,t,n)=>t in e?Ou(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uo=(e,t,n)=>Cu(e,typeof t!="symbol"?t+"":t,n);class Mo extends Error{constructor(t){super(t.message),Uo(this,"code"),Uo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let $u=1;const Tu=e=>{let t=$u++;const n=new Map,r=To();let s=null;const o=(l,d,h)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:h}))};function i(l){try{let d,h,f,p,v;if({id:d,result:h,error:f,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),f?g.onError(new Mo(f)):g.onSuccess(h,(x,y)=>{const w=x;return r.subscribe(w,y),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:h,error:f}=p,!v||!f&&!Object.hasOwn(p,"result"))throw 0;const m=v;f?r.error(m,new Mo(f)):r.next(m,h)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new In),n.forEach(l=>l.onError(new In)),n.clear()};let u=1;return{request:(l,d,h)=>{if(!s)throw new Error("Not connected");const f=`${t}-${u++}`;return h&&n.set(f,h),o(f,l,d),()=>{n.delete(f)}},disconnect:c}},Pu=e=>{const t=Sn((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(En.chainName,[]),t(En.genesisHash,[]),t(En.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},_n=new Map,Ru=e=>{const t=_n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Tu(e),s=()=>{const i=_n.get(e);!i||i.refCount<=1?(_n.delete(e),r()):i.refCount--},o={chainHead:Bu(n),transaction:wu(n),getChainSpecData:Pu(n),destroy:s,request:Sn((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return _n.set(e,{client:o,refCount:1}),o};var mr=function(e,t){return mr=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])},mr(e,t)};function je(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Uu(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 c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Lo(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=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function kt(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 Oe(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(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Ce(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 At(e){return this instanceof At?(this.v=e,this):new At(e)}function Mu(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),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(p){return Promise.resolve(p).then(f,d)}}function c(f,p){r[f]&&(s[f]=function(v){return new Promise(function(b,m){o.push([f,v,b,m])>1||u(f,v)})},p&&(s[f]=p(s[f])))}function u(f,p){try{a(r[f](p))}catch(v){h(o[0][3],v)}}function a(f){f.value instanceof At?Promise.resolve(f.value.v).then(l,d):h(o[0][2],f)}function l(f){u("next",f)}function d(f){u("throw",f)}function h(f,p){f(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Lu(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 kt=="function"?kt(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(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function yr(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 gr=yr(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
- `):"",this.name="UnsubscriptionError",this.errors=n}});function Bn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var St=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 c=kt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(V(l))try{l()}catch(v){o=v instanceof gr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=kt(d),f=h.next();!f.done;f=h.next()){var p=f.value;try{jo(p)}catch(v){o=o??[],v instanceof gr?o=Ce(Ce([],Oe(o)),Oe(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{f&&!f.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new gr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)jo(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)&&Bn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Bn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Do=St.EMPTY;function Vo(e){return e instanceof St||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function jo(e){V(e)?e():e.unsubscribe()}var Vu={Promise:void 0},ju={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ce([e,t],Oe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function zo(e){ju.setTimeout(function(){throw e})}function $e(){}function On(e){e()}var Yt=function(e){ze(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Vo(n)&&n.add(r)):r.destination=Fu,r}return t.create=function(n,r,s){return new It(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}(St),zu=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){Cn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Cn(r)}else Cn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Cn(n)}},e}(),It=function(e){ze(t,e);function t(n,r,s){var o=e.call(this)||this,i;return V(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new zu(i),o}return t}(Yt);function Cn(e){zo(e)}function Hu(e){throw e}var Fu={closed:!0,next:$e,error:Hu,complete:$e},wr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ge(e){return e}function Ho(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fo(e)}function Fo(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var $=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=Wu(t)?t:new It(t,n,r);return On(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?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=qo(n),new n(function(s,o){var i=new It({next:function(c){try{t(c)}catch(u){o(u),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[wr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Fo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=qo(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 qo(e){var t;return(t=e??Vu.Promise)!==null&&t!==void 0?t:Promise}function qu(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function Wu(e){return e&&e instanceof Yt||qu(e)&&Vo(e)}function Ku(e){return V(e?.lift)}function W(e){return function(t){if(Ku(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 H(e,t,n,r,s){return new Xu(e,t,n,r,s)}var Xu=function(e){ze(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}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}(Yt),Yu=yr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=function(e){ze(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 Wo(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Yu},t.prototype.next=function(n){var r=this;On(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=kt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;On(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;On(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,c=s.observers;return o||i?Do:(this.currentObservers=null,c.push(n),new St(function(){r.currentObservers=null,Bn(c,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 $;return n.source=this,n},t.create=function(n,r){return new Wo(n,r)},t}($),Wo=function(e){ze(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:Do},t}(Te),Gu=function(e){ze(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}(Te),Er={now:function(){return(Er.delegate||Date).now()},delegate:void 0},$n=function(e){ze(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Er);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,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+u)),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,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Te),Nu=function(e){ze(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(St),Ko={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ce([e,t],Oe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Qu=function(e){ze(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),Ko.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&&Ko.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,Bn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Nu),Xo=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=Er.now,e}(),Zu=function(e){ze(t,e);function t(n,r){r===void 0&&(r=Xo.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}(Xo),Yo=new Zu(Qu),Ju=Yo,yt=new $(function(e){return e.complete()});function Go(e){return e&&V(e.schedule)}function xr(e){return e[e.length-1]}function kr(e){return V(xr(e))?e.pop():void 0}function Gt(e){return Go(xr(e))?e.pop():void 0}function el(e,t){return typeof xr(e)=="number"?e.pop():t}var No=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Qo(e){return V(e?.then)}function Zo(e){return V(e[wr])}function Jo(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function ei(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 tl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ti=tl();function ni(e){return V(e?.[ti])}function ri(e){return Lu(this,arguments,function(){var n,r,s,o;return Lo(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,At(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,At(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,At(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 si(e){return V(e?.getReader)}function se(e){if(e instanceof $)return e;if(e!=null){if(Zo(e))return nl(e);if(No(e))return rl(e);if(Qo(e))return sl(e);if(Jo(e))return oi(e);if(ni(e))return ol(e);if(si(e))return il(e)}throw ei(e)}function nl(e){return new $(function(t){var n=e[wr]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function rl(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function sl(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,zo)})}function ol(e){return new $(function(t){var n,r;try{for(var s=kt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function oi(e){return new $(function(t){cl(e,t).catch(function(n){return t.error(n)})})}function il(e){return oi(ri(e))}function cl(e,t){var n,r,s,o;return Mu(this,void 0,void 0,function(){var i,c;return Lo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Du(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.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 ut(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 ii(e,t){return t===void 0&&(t=0),W(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function ci(e,t){return t===void 0&&(t=0),W(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function al(e,t){return se(e).pipe(ci(t),ii(t))}function ul(e,t){return se(e).pipe(ci(t),ii(t))}function ll(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function fl(e,t){return new $(function(n){var r;return ut(n,t,function(){r=e[ti](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function hl(e,t){return ai(ri(e),t)}function dl(e,t){if(e!=null){if(Zo(e))return al(e,t);if(No(e))return ll(e,t);if(Qo(e))return ul(e,t);if(Jo(e))return ai(e,t);if(ni(e))return fl(e,t);if(si(e))return hl(e,t)}throw ei(e)}function _t(e,t){return t?dl(e,t):se(e)}function Pe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return _t(e,n)}function Tn(e,t){var n=V(e)?e:function(){return e},r=function(s){return s.error(n())};return new $(r)}var ui=yr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function pl(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 ui)}})})}function Re(e,t){return new Promise(function(n,r){var s=new It({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new ui)}});e.subscribe(s)})}function vl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var bl=Array.isArray;function ml(e,t){return bl(t)?e.apply(void 0,Ce([],Oe(t))):e(t)}function li(e){return I(function(t){return ml(e,t)})}var yl=Array.isArray,gl=Object.getPrototypeOf,wl=Object.prototype,El=Object.keys;function xl(e){if(e.length===1){var t=e[0];if(yl(t))return{args:t,keys:null};if(kl(t)){var n=El(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function kl(e){return e&&typeof e=="object"&&gl(e)===wl}function Al(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Bt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=kr(e),s=xl(e),o=s.args,i=s.keys;if(o.length===0)return _t([],n);var c=new $(fi(o,n,i?function(u){return Al(i,u)}:Ge));return r?c.pipe(li(r)):c}function fi(e,t,n){return n===void 0&&(n=Ge),function(r){hi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){hi(t,function(){var d=_t(e[l],t),h=!1;d.subscribe(H(r,function(f){o[l]=f,h||(h=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function hi(e,t,n){e?ut(n,e,t):t()}function Sl(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,h=function(){d&&!u.length&&!a&&t.complete()},f=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;se(n(v,l++)).subscribe(H(t,function(m){t.next(m)},function(){b=!0},void 0,function(){if(b)try{a--;for(var m=function(){var g=u.shift();i||p(g)};u.length&&a<r;)m();h()}catch(g){t.error(g)}}))};return e.subscribe(H(t,f,function(){d=!0,h()})),function(){}}function R(e,t,n){return n===void 0&&(n=1/0),V(t)?R(function(r,s){return I(function(o,i){return t(r,o,s,i)})(se(e(r,s)))},n):(typeof t=="number"&&(n=t),W(function(r,s){return Sl(r,s,e,n)}))}function Pn(e){return e===void 0&&(e=1/0),R(Ge,e)}function Il(){return Pn(1)}function Ar(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Il()(_t(e,Gt(e)))}function Rn(e){return new $(function(t){se(e()).subscribe(t)})}var _l={connector:function(){return new Te},resetOnDisconnect:!0};function Bl(e,t){t===void 0&&(t=_l);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new $(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Rn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Un(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Ju);var r=-1;return t!=null&&(Go(t)?n=t:r=t),new $(function(s){var o=vl(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 Sr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=el(e,1/0),s=e;return s.length?s.length===1?se(s[0]):Pn(r)(_t(s,n)):yt}var Ol=Array.isArray;function Cl(e){return e.length===1&&Ol(e[0])?e[0]:e}function Ie(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return W(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=se(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function $l(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function di(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return n?Ho(di.apply(void 0,Ce([],Oe(e))),li(n)):W(function(r,s){fi(Ce([r],Oe(Cl(e))))(s)})}function Tl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return di.apply(void 0,Ce([],Oe(e)))}function pi(e,t){return V(t)?R(e,t,1):R(e,1)}function J(e){return e<=0?function(){return yt}:W(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Pl(e){return I(function(){return e})}function Rl(e,t){return R(function(n,r){return se(e(n,r)).pipe(J(1),Pl(n))})}function Ul(e,t){t===void 0&&(t=Yo);var n=Un(e,t);return Rl(function(){return n})}function Ml(e,t){return W(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&se(t).subscribe(H(r,function(){return s.clear()},$e))})}function le(e,t){return t===void 0&&(t=Ge),e=e??Ll,W(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Ll(e,t){return e===t}function Dl(e,t){return W(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),se(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Vl(){return W(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Nt(e,t){return W($l(e,t,arguments.length>=2,!0))}function Qt(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,h,f=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},m=function(){b(),l=h=void 0,p=v=!1},g=function(){var x=l;m(),x?.unsubscribe()};return W(function(x,y){f++,!v&&!p&&b();var w=h=h??n();y.add(function(){f--,f===0&&!v&&!p&&(d=Ir(g,u))}),w.subscribe(y),!l&&f>0&&(l=new It({next:function(A){return w.next(A)},error:function(A){v=!0,b(),d=Ir(m,s,A),w.error(A)},complete:function(){p=!0,b(),d=Ir(m,i),w.complete()}}),se(x).subscribe(l))})(a)}}function Ir(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 It({next:function(){s.unsubscribe(),e()}});return se(t.apply(void 0,Ce([],Oe(n)))).subscribe(s)}}function Mn(e,t,n){var r,s,o,i,c=!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,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,Qt({connector:function(){return new $n(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function vi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return W(function(r,s){(n?Ar(e,r,n):Ar(e,r)).subscribe(s)})}function Ln(e,t){return W(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;se(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function jl(){return Ln(Ge)}function bi(e){return W(function(t,n){se(e).subscribe(H(n,function(){return n.complete()},$e)),!n.closed&&t.subscribe(n)})}function mi(e,t){return t===void 0&&(t=!1),W(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function yi(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?W(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Ge}function _r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return W(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){se(e[d]).subscribe(H(s,function(h){i[d]=h,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ge))&&(c=null))},$e))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var h=Ce([d],Oe(i));s.next(n?n.apply(void 0,Ce([],Oe(h))):h)}}))})}var zl=Object.defineProperty,Hl=(e,t,n)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gi=(e,t,n)=>Hl(e,typeof t!="symbol"?t+"":t,n);class Fl{constructor(){gi(this,"first"),gi(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 ql=()=>{const e=new Map,t=(h,f)=>{e.set(h,()=>{e.delete(h),f()})},n=h=>{e.get(h)?.()},r=new Fl,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,f)=>{const p=f?s:o;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:f,observer:p}=h;let v=!1;const b=f.subscribe({next(m){p.next(m)},error(m){(v=m instanceof kn)?i(h,!0):p.error(m)},complete(){p.complete()}});b.closed?v||c():t(f,()=>{b.unsubscribe(),c()})},a=(h=!1)=>f=>new $(p=>{const v={observer:p,source$:f};return r.isEmpty()?u(v):i(v,h),()=>{n(f)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...f)=>l(h(...f))}};class Ot extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Wl=new Set(["best","finalized",null]),wi=e=>{const t=e.pipe(lt(n=>n instanceof An?Un(750).pipe(pi(()=>t)):Tn(()=>n)));return t},Kl=(e,t,n)=>r=>(s,...o)=>{if(!Wl.has(s))return wi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(J(1),R(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Ot?c:Tn(()=>u)));return wi(c)},Ei=e=>(...t)=>new $(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}}),Xl=e=>t=>(...n)=>e()[t](...n);function Dn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new $(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:h=>{const f=h.blocks.get(r);f?f.recovering?c?.unsubscribe():a():l&&i.error(new Ot(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Yl=e=>e.pipe(Nt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),R(({newBlocks:t})=>t),Qt()),Gl=(e,t)=>{const n=(r,s,o,i)=>new $(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Pn(),t(i));return n},Nl=e=>t=>t.pipe(pi(n=>n.type!=="initialized"?Pe(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Ql=e=>{let t=null,n=$e;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(so.dec),o=Bl(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Nl(s),Zl()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},Zl=()=>e=>new $(t=>{const n=new St,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Co?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),xi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},Jl=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const f=l(d);return h=n.get(d),h?Object.assign(h,f):(h={id:d,...f},n.set(d,h)),r.delete(d),h};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:h,path:f,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return ft;if(h.value.length===1){const v=c(h.value[0].type);return o&&f.at(-1)==="AccountId32"&&xi(v,32)?(o=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&xi(v,20)?(i=!1,{type:"AccountId20"}):v}return u(h.value)}if(h.tag==="variant"){if(f.length===1&&f[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(f.length===1&&f[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(h.value.length===0)return ft;const v={},b={};return h.value.forEach(m=>{const g=m.name;if(b[g]=m.docs,m.fields.length===0){v[g]={...ft,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[g]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[g]={...u(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:v}=h.value,b=c(h.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?ft:h.value.length>1?a(h.value.map(v=>c(v)),h.value.map(v=>e[v].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const v=c(h.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:h.tag}}),u=l=>{let d=!0;const h={},f={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,m=c(p.type);m.type!=="void"&&(h[b]=m,f[b]=p.docs)}),d?{type:"struct",value:h,innerDocs:f}:a(Object.values(h),Object.values(f))},a=(l,d)=>{if(l.every(h=>h.id===l[0].id)&&d.every(h=>!h.length)){const[h]=l;return h.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Vn=e=>{const t=Jl(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?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors),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),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},ef=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},tf=Ft(),ki=ef((e,t,n,r)=>{if(e.type==="primitive")return Ao[e.value];if(e.type==="void")return B;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return to;if(e.type==="compact")return e.isBig?vn:O;if(e.type==="bitSequence")return js;const s=f=>ki(f,t,n,r),o=(f,p)=>{const v=s(f);return p?me(v,p):me(v)},i=f=>Ve(...f.map(s)),c=f=>{const p=Object.fromEntries(Object.entries(f).map(([v,b])=>[v,s(b)]));return be(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return tf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ft(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 c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return bn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(f=>{switch(f.type){case"void":return B;case"lookupEntry":return s(f.value);case"tuple":return i(f.value);case"struct":return c(f.value);case"array":return o(f.value,f.len)}}),a=Object.fromEntries(Object.keys(e.value).map((f,p)=>[f,u[p]])),l=Object.values(e.value).map(f=>f.idx),h=l.every((f,p)=>f===p)?he(a):he(a,l);return e.byteLength?nf(h,e.byteLength):h},er,e=>e),Ai=(e,t=pt())=>{const n=new Map,r=s=>ki(e(s),n,new Set,t);return s=>r(s)},nf=(e,t)=>{const n=N(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Br=e=>{const{metadata:t}=e;let n=Ai(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let s;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(s=d,n=Ai(e,pt(d)))}catch{}const o=new Map,i=(d,h)=>{let f=o.get(d);f||o.set(d,f=xo(d));const p=t.pallets.find(A=>A.name===d).storage.items.find(A=>A.name===h),v=(A,_,...T)=>{const P=f(...T),[,...K]=T;return{args:Ve(...K.map(([G])=>G)),keys:P,value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,n(p.type.value),h);const{key:b,value:m,hashers:g}=p.type.value,x=n(m),y=g.map(A=>Ao[A.tag]),w=(()=>{if(y.length===1)return[[n(b),y[0]]];const A=e(b);switch(A.type){case"array":return y.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,T)=>[n(_.id),y[T]]);default:throw new Error("Invalid key type")}})();return v(y.length,x,h,...w)},c=d=>{switch(d.type){case"void":return B;case"lookupEntry":return n(d.value.id);case"tuple":return Ve(...Object.values(d.value).map(h=>n(h.id)));case"struct":return be(wt(d.value,h=>n(h.id)));case"array":return me(n(d.value.id),d.len)}},u=(d,h)=>{const f=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===h);return n(f.type)},a=d=>(h,f)=>{const p=t.pallets.find(m=>m.name===h),v=e(p[d]);if(v.type!=="enum")throw null;const b=v.value[f];return{location:[p.index,b.idx],codec:c(v.value[f])}},l=(d,h)=>{const f=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===h);if(!f)throw null;return{args:Ve(...f.inputs.map(p=>n(p.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},rf=te(Be.enc(15)),Si=N(),sf=it(Si),of=me(Be).dec,cf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Ot)return r(c,u);if(l instanceof An)return Un(750).pipe(R(()=>r(c,u)));throw l})):yt},s=r("Metadata_metadata_versions","").pipe(I(of)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Si.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}})),i=r("Metadata_metadata_at_version",rf).pipe(I(c=>{const u=sf.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}}));return s.pipe(lt(()=>Pe([14])),R(c=>c.includes(15)?i:o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Vn(c),l=Br(a),d=l.buildStorage("System","Events"),h=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let f=null;if(h){const p=a(h.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(f=v.value.id)}}return{assetId:f,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:pt(l.ss58Prefix)}}),Mn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},Zt=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Ii=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},_i=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},af=(e,t)=>{t.forEach(n=>{_i(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},uf=(e,t,n,r,s)=>{const o=new Te,i=o.pipe(Dl(()=>Un(0)),I(()=>({type:"cleanup"}))),c=Sr(n,i,e).pipe(Nt((a,l)=>{const d=h=>{af(a,h),r(h)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Bi()));const[h]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=h;const f=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const m=a.blocks.get(v);m?(m.recovering=!1,m.unpinnable=b!==f):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===f?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==f,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(h));return a.finalizedRuntime=p??(a.runtimes[h]=u(Ii(a,h))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const m=a.blocks.get(v);m.children.add(b);const g={hash:b,number:m.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:m.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Ii(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(_i(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(m=>{const g=a.blocks.get(m);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:m})=>b&&!m).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Bi()),Ie(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),Zt),u=cf(Dn(c,t,"pinned-blocks"));return c},Bi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Oi=(e,t,n,r)=>{const s=c=>bi(e.pipe(Ie(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return Pe({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(R(d=>{const h=d.indexOf(u);return h>-1?l(r(c)).pipe(I(f=>({hash:c,found:{type:!0,index:h,events:f}}))):n(c,u).pipe(I(f=>({hash:c,found:{type:!1,validity:f}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(R(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?Pe(l):e.pipe(s(c),R(h=>h.blocks.get(c).children),Ml(),R(h=>i(h,u,a)))}));return c=>e.pipe(J(1),R(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},lf=new Uint8Array([2]),ff=(e,t)=>te(ue(lf,fe(e),fe(t))),Ci="TaggedTransactionQueue",$i="validate_transaction",[,hf]=he({InvalidTransaction:he({Call:B,Payment:B,Future:B,Stale:B,BadProof:B,AncientBirthBlock:B,ExhaustsResources:B,Custom:j,BadMandatory:B,MandatoryValidation:B,BadSigner:B}),UnknownTransaction:he({CannotLookup:B,NoUnsignedValidator:B,Custom:j})}),df=on(e=>{const t=j.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=hf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),pf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Ci,$i).value[1]}catch{return df}}));return e(n,`${Ci}_${$i}`,ff(r,n)).pipe(_r(s),I(([o,i])=>i(o)))},vf=e=>t=>new $(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}),bf=e=>t=>new $(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)}}),Ti=(e,t=1/0)=>n=>new $(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const h=o.get(a);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const f=a++;o.delete(f),l!==f&&c.set(f,[]);let p=!1,v=h.subscribe({next(b){l===f?r.next(b):c.get(f).push(b)},complete(){if(p=!0,i.delete(f),f===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(f,v)};return s=n.subscribe({next(h){const f=u++;o.set(f,Rn(()=>e(h,f))),i.size<t&&d()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Or=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),mf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=Ql(e),o=Xl(t),{withRecovery:i,withRecoveryFn:c}=ql(),u=new Te,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>S=>new $(C=>{const q=a(E),oe=S.subscribe(C);return oe.add(q),oe}),d=E=>(S,...C)=>E(S,...C).pipe(l(S)),h=(E,S)=>(C,...q)=>new $(oe=>{let ve=!1;return b.pipe(J(1)).subscribe(_e=>{ve=_e.blocks.has(C)}),ve?E(C,...q).subscribe(oe):oe.error(new Ot(C,S))}),f=E=>t().unpin(E).catch(S=>{if(!(S instanceof xn))throw S}),p=(E,S)=>h(d(Dn(b,c(Ei(E)),`stop-${S}`)),S),v=new Map,b=uf(r,d(c(Ei(o("call")))),u,E=>{f(E),E.forEach(S=>{v.delete(S)})},E=>{v.delete(E)}),m=d(E=>b.pipe(J(1),R(S=>S.runtimes[S.blocks.get(E).runtime].runtime))),g=E=>S=>S.pipe(Ti(C=>m(E(C)).pipe(I(q=>[C,q])))),x=(E,S,C)=>{const q=v.get(E)??new Map,oe=q.get(S);if(oe)return oe;v.set(E,q);let ve;const _e=C.pipe(Qt({connector:()=>ve=new $n}),yi({complete(){q.set(S,ve)}}),bf());return q.set(S,_e),_e},y=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized),Nt((E,S)=>{let C=S.blocks.get(S.finalized);const q=[C],oe=E.at(-1);if(!oe)return q;for(;C.number>oe.number+1&&(C=S.blocks.get(C.parent),!!C);)q.unshift(C);return q},[]),Pn(),I(Or),Zt),w=b.pipe(le((E,S)=>E.best===S.best),I(E=>Or(E.blocks.get(E.best))),Zt),A=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized&&E.best===S.best),Nt((E,S)=>{const C=we=>E.get(we)||Or(S.blocks.get(we)),q=C(S.best),oe=C(S.finalized),ve=q.number-oe.number+1,_e=new Array(ve);for(let we=0,rn=q.hash;we<ve;we++)_e[we]=C(rn),rn=_e[we].parent;return new Map(_e.map(we=>[we.hash,we]))},new Map),I(E=>[...E.values()]),Zt),_=b.pipe(le((E,S)=>E.finalizedRuntime===S.finalizedRuntime),Ln(({finalizedRuntime:{runtime:E}})=>E.pipe(vf(null))),Zt),T=_.pipe(I(E=>E?.lookup.metadata??null)),P=Kl(y.pipe(I(E=>E.hash)),w.pipe(I(E=>E.hash)),l),K=P(p(o("body"),"body")),G=E=>x(E,"body",K(E)),X=p(o("storage"),"storage"),ne=P((E,S,C,q=null,oe)=>b.pipe(J(1),R(ve=>ve.runtimes[ve.blocks.get(E).runtime].runtime),R(ve=>{const _e=C(ve),we=x(E,`storage-${S}-${_e}-${q??""}`,X(E,S,_e,q));return oe?x(E,`storage-${S}-${_e}-${q??""}-dec`,we.pipe(I(rn=>({raw:rn,mapped:oe(rn,ve)})))):we}))),Ne=Gl(t,i),Pt=P(Dn(b,(E,S,C)=>Ne(E,S,C??null,!1),"storageQueries")),nn=P(Dn(b,E=>Rn(()=>s(E)),"header")),qn=E=>ne(E,"value",S=>S.events.key,null,(S,C)=>C.events.dec(S)).pipe(I(S=>S.mapped)),vh=p(o("call"),"call"),Qi=P((E,S,C)=>x(E,`call-${S}-${C}`,vh(E,S,C))),Kr=pf(Qi,m),Zi=E=>x(E,"body",K(E)),bh=Oi(b,Zi,Kr,qn),mh=Oi(b,Zi,Kr,()=>Pe()),yh=_.pipe(Ie(Boolean),J(1),R(E=>{const{enc:S}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=S(0)}catch{C=S(0n)}return ne(null,"value",()=>C,null)}),Mn(1));Sr(_,A).subscribe({error(){}});let Xr=$e,Wn=!1,Yr=0;const gh=E=>{Yr+=E,Wn=!0,Xr=n()};return[{follow$:r,finalized$:y,best$:w,bestBlocks$:A,newBlocks$:Yl(b),runtime$:_,metadata$:T,genesis$:yh,header$:nn,body$:G,call$:Qi,storage$:ne,storageQueries$:Pt,eventsAt$:qn,holdBlock:a,trackTx$:bh,trackTxWithoutEvents$:mh,validateTx$:Kr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:P(m),unfollow:()=>{Wn!=null&&(Yr--,Wn&&!Yr&&(Wn=null,Xr(),Xr=$e))}},gh]};var yf=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const jn=new Map,gf=e=>{const t=jn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=jn.get(e);!c||c.refCount<=1?(jn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=mf(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:yf(e.transaction),destroy:n};return jn.set(e,{client:i,refCount:1}),i},wf=(e,t)=>e.pipe(mi(n=>n.blocks.has(t)),le((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(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}),le(),mi(n=>n!=="finalized",!0));class Ct{constructor(){}_runtime(t){}}class Pi{constructor(){}_compatibility(t){}}const zn=new WeakMap,Ri=new WeakMap,Cr=e=>e instanceof Ct?Ri.get(e):zn.get(e);var $t=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))($t||{});const Ef=me(vu),xf=me(fr),kf=Ve(Ef,xf),Af=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Ie(i=>i!=null));let o=await Re(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(kf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Pi;return zn.set(c,{runtime:i,getPalletEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},getApiEntryPoint(u,a){const l=o.apis?.[u]?.[a];if(l==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[l]},typedefNodes:s}),c})},Sf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ie(s=>s!=null));let r=await Re(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Ct;return Ri.set(n,{runtime:t}),n}),$r=new WeakMap,Ui=e=>($r.has(e.metadataRaw)||$r.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),$r.get(e.metadataRaw)),Tt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Ui(i);return(u=a.typeNodes)[c]||(u[c]=yn(a.lookup(c)))};function s(i,c){if(i instanceof Ct)return{args:Ae.Identical,values:Ae.Identical};const u=zn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ae.Incompatible,values:Ae.Incompatible};const d=u.typedefNodes,h=Ui(c);return wu(a,f=>d[f],l,f=>r(c,f),h.compat)}const o=Li(e,i=>Mi(s(i)));return{isCompatible:Li(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Bt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Bt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c);if(a.args===Ae.Incompatible)return!1;if(a.args>Ae.Partial)return!0;if(a.values===Ae.Incompatible)return!1;const l=n(c);return l==null?!1:Oo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c).values;if(a===Ae.Incompatible)return!1;if(a>Ae.Partial)return!0;const l=zn.get(i),d=t(l);return Oo(d.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r}},Mi=e=>Math.min(e.args,e.values),Li=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Pi||r instanceof Ct?t(...n):e.then(s=>t(...n,s))},If=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Cr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},_f=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Tr(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new Us)}:$e;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Pr=Symbol("EMPTY_VALUE"),Rr=e=>t=>new $(n=>{let r=0,s=null,o=Pr,i=!1;const c=()=>{const a=e(o,r++);o=Pr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Pr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Di={};const Bf=e=>t=>new $(n=>{let r=Di,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Di?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Jt=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)),Of=()=>{const e=new Gu(new Te);return[e.pipe(jl()),()=>yi({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},Cf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,h])=>{const f=h.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(f==null||h.lookup.metadata.lookup[f].def.tag!=="variant"||h.lookup.metadata.lookup[f].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,h,null))throw u();return[l,d,h]}),Ti(([l,d,h])=>n.eventsAt$(l.hash).pipe(I(f=>f.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),_f);return{watch:l=>a.pipe(R(d=>l?d.filter(h=>l(h.payload)):d)),pull:()=>Re(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},$f=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],h=Jt(d),{signal:f,at:p}=h?d:{},v=p??null,b=o(n,v).pipe(R(([m,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(m,g,l))throw a();return n.call$(v,u,te(x.args.enc(l))).pipe(I(x.value.dec),I(y=>{if(!c(m,g,y))throw a();return y}))}));return Tr(b,f)},{getCompatibilityLevel:s,isCompatible:r})},Ur=I(e=>e.mapped),Tf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",h=n.runtime$.pipe(Ie(Boolean),J(1),I(({dynamicBuilder:y})=>typeof y.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Mn()),f=Ho(Tl(h),I(([y,w])=>w(y))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=y=>new Error(`Invalid Arguments calling ${e}.${t}(${y})`),b=y=>{try{return y.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},m=(...y)=>{const w=y[y.length-1],A=w==="best",_=A||w==="finalized"?y.slice(0,-1):y;return n[A?"best$":"finalized$"].pipe(Rr(()=>g(..._,A?{at:"best"}:{})),le((T,P)=>T.raw===P.raw),Ur)},g=(...y)=>{const w=y[y.length-1],A=Jt(w),{at:_}=A?w:{},T=_??null;return l?n.pinnedBlocks$.pipe(I(P=>{const K=T==="finalized"||!T?P.finalized:T==="best"?P.best:T,G=P.blocks.get(K);if(!G)throw new Ot(K,"System.Number");return G.number}),le(),f,I(P=>({raw:P,mapped:P}))):d&&Number(y[0])===0?n.genesis$.pipe(I(P=>({raw:P,mapped:pn.fromHex(P)}))):_t(c).pipe(R(P=>n.storage$(T,"value",K=>{const G=b(K),X=y.length===G.len?y:y.slice(0,-1);if(y!==X&&!A)throw v(y);if(!u(P,K,X))throw p();return G.keys.enc(...X)},null,(K,G)=>{const X=b(G),ne=K===null?X.fallback:X.value.dec(K);if(!a(P,G,ne))throw p();return ne})))},x=async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_}=A?w:{};return Tr(g(...y).pipe(Ur),_)};return{isCompatible:s,getCompatibilityLevel:o,getValue:x,getValues:(y,w)=>Promise.all(y.map(A=>x(...w?[...A,w]:A))),getEntries:async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_,at:T}=A?w:{},P=T??null,K=await c,G=n.storage$(P,"descendantsValues",X=>{const ne=b(X);if(Mi(i(K,X))===Ae.Incompatible)throw p();if(y.length>ne.len)throw v(y);const Ne=y.length>0&&A?y.slice(0,-1):y;if(y.length===ne.len&&Ne===y)throw v(y);return ne.keys.enc(...Ne)},null,(X,ne)=>{const Ne=b(ne),Pt=X.map(({key:nn,value:qn})=>({keyArgs:Ne.keys.dec(nn),value:Ne.value.dec(qn)}));if(Pt.some(({value:nn})=>!a(K,ne,nn)))throw p();return Pt}).pipe(Ur);return Tr(G,_)},watchValue:m,watchEntries:(...y)=>{const w=y.at(-1),A=Jt(w);return r(e,t,A?y.slice(0,-1):y,A&&w.at==="best")}}},Pf=Ut(j.enc,e=>+!!e.signed<<7|e.version),Mr=()=>new Error("Unkown signer"),Rf=e=>{const{extrinsic:t}=e,n=Vn(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 Mr()}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 Mr();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 Mr()},Uf={Ed25519:0,Sr25519:1,Ecdsa:2},Mf=(e,t,n,r,s,o)=>{const[i,c]=Rf(e),u=ue(Pf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Uf[o],...n]),...r,s);return ue(ce.enc(u.length),u)},[Hn,en]=["<Bytes>","</Bytes>"].map(e=>De.fromText(e).asBytes()),Lf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Hn.length;r++)n=Hn[r]===t[r];n=n&&r===Hn.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:ue(Hn,t,en))};function Df(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Wt)=>{let a;try{const p=cr(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const h=ue(s,...l,...d),f=await n(h.length>256?u(h):h);return Mf(a,e,f,l,s,t)},signBytes:Lf(n)}}const Vf=(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 jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const zf=Ut(N(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(jf(e.period)-1,1),15),r=e.phase/t<<4;return Je[0](n|r)}),[Hf]=be({tip:ce,asset:it(N(1/0))}),Vi=new Uint8Array,Lr=Uint8Array.from([0]),Dr=e=>({value:e,additionalSigned:Vi}),Vr=e=>({value:Vi,additionalSigned:e}),jr=(e,t)=>({value:e,additionalSigned:t}),ji=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Vf(t,n),d=f=>{const[p,v]=r[f],b=c[f];try{return wt({value:p,additionalSigned:v},(m,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:m(x)})}catch{return a.push(f),null}},h=wt(r,([f,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Dr(f(i));case"CheckMortality":return s.mortal?jr(zf({period:s.period,phase:s.startAtBlock.height%s.period}),fe(s.startAtBlock.hash)):jr(Lr,e);case"ChargeTransactionPayment":return Dr(f(o));case"ChargeAssetTxPayment":return Dr(Hf({tip:o,asset:u.asset}));case"CheckGenesis":return Vr(e);case"CheckMetadataHash":return jr(Lr,Lr);case"CheckSpecVersion":return Vr(p(l.spec_version));case"CheckTxVersion":return Vr(p(l.transaction_version));default:return d(v)}});return a.forEach(f=>{delete h[f]}),wt(h,(f,p)=>({...f,identifier:p}))}},zi="AccountNonceApi_account_nonce",Ff={1:j.dec,2:Je.dec,4:Be.dec,8:Mt.dec},qf=(e,t,n)=>e(n,zi,t).pipe(I(r=>{const s=fe(r),o=Ff[s.length];if(!o)throw new Error(`${zi} retrieved wrong data`);return o(s)})),Wf=(e,t,n,r,s,o={})=>Bt([o.nonce?Pe(o.nonce):Kf(e,te(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(J(1),R(([i,c,u])=>{const a=ji(fe(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),Kf=(e,t)=>{const n=o=>e.newBlocks$.pipe(Nt((i,c)=>c.parent===i?c.hash:i,o),vi(o),le()),r=o=>n(o).pipe(J(2),Ln(i=>qf(e.call$,t,i))),s=o=>Bt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>Pe({success:!1,value:c}))))).pipe(J(1));return e.pinnedBlocks$.pipe(Ie(o=>!o.recovering&&o.blocks.size>0),J(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),Ln(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var Xf=Object.defineProperty,Yf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gf=(e,t,n)=>Yf(e,t+"",n);const Nf=e=>te(Wt(fe(e))),Qf=(e,t)=>new $(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const f=s.blocks.get(u);if(!f)break;a=r.get(u=f.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,h=a.found.type;if(h&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:h,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:h,validity:a.found.validity}),d&&(h?n.complete():a.found.validity?.success===!1&&n.error(new zr(a.found.validity.value)))},c=t.pipe(le((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(le((n,r)=>n===r)),Zf=(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 zr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof De?r.asHex():r,2)),Gf(this,"error"),this.name="InvalidTxError",this.error=t}}const Hr=(e,t,n,r,s=!1)=>{const o=Nf(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(J(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(R(l=>e.validateTx$(l,n).pipe(Ie(d=>!d.success),I(d=>{throw new zr(d.value)})))),u=new $(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(h){l.error(h)}})),d}),a=Qf(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...Zf(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Ar(s?Pe(i("signed",{})):yt,c,Pe(i("broadcasted",{})),a.pipe(Bf(({found:l,type:d,...h})=>l?Pe(i("finalized",h)):yt)))},Hi=async(e,t,n,r)=>pl(Hr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Jf=pt().enc,eh=new Uint8Array(64),th=new Uint8Array(65),nh=e=>()=>e?th:eh,[,rh]=be({weight:be({ref_time:vn,proof_size:vn}),class:he({Normal:B,Operational:B,Mandatory:B}),partial_fee:Jr}),Fi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(y,w,A={})=>{const _=Cr(y).runtime(),{dynamicBuilder:T,assetId:P,lookup:K}=_;let G;try{G=T.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(y,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let X=A;if(A.asset){if(P==null||!hr(A.asset,yn(K(P)),Pt=>u(_,Pt)))throw new Error("Incompatible runtime asset");X={...A,asset:T.buildDefinition(P).enc(A.asset)}}const{location:ne,codec:Ne}=G;return{callData:De.fromBytes(ue(new Uint8Array(ne),Ne.enc(w))),options:X}},h=(y,w={})=>i(n,null).pipe(I(([A])=>d(A,y,w))),f=y=>y?d(y,l).callData:Re(h(l).pipe(I(w=>w.callData))),p=(y,{...w},A)=>h(l,w).pipe(R(({callData:_,options:T})=>Wf(n,y,_.asBytes(),A,w.customSignedExtensions||{},T))),v=(y,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(I(_=>_.find(T=>T.hash===w)))).pipe(J(1),R(_=>_?p(y,A,_).pipe(I(T=>({tx:te(T),block:_}))):Tn(()=>new Error(`Uknown block ${w}`)))),b=(y,w)=>Re(v(y,w)).then(A=>A.tx),m=(y,w)=>Re(v(y,w)).then(({tx:A,block:_})=>Hi(n,r,A,_.hash)),g=(y,w)=>v(y,w).pipe(R(({tx:A,block:_})=>Hr(n,r,A,_.hash,!0))),x=async(y,w)=>{typeof y=="string"&&(y=y.startsWith("0x")?fe(y):Jf(y));const A=y.length===20,_=Df(y,A?"Ecdsa":"Sr25519",nh(A)),T=fe(await b(_,w)),P=te(ue(T,Be.enc(T.length))),K=n.getRuntimeContext$(null).pipe(I(X=>{try{return X.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return rh}})),G=n.call$(null,"TransactionPaymentApi_query_info",P);return Re(Bt([G,K]).pipe(I(([X,ne])=>ne(X))))};return{getPaymentInfo:x,getEstimatedFees:async(y,w)=>(await x(y,w)).partial_fee,decodedCall:{type:e,value:bt(t,l)},getEncodedData:f,sign:b,signSubmitAndWatch:g,signAndSubmit:m}},{getCompatibilityLevel:o,isCompatible:s});var sh=Object.defineProperty,oh=(e,t,n)=>t in e?sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(oh(e,typeof t!="symbol"?t+"":t,n),n),Fr=Symbol("SUSPENSE"),ih=class extends Promise{constructor(e){super(e)}},qi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Wi=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ge={},Fn=class extends ${constructor(e,t,n=$e){super(r=>{const s=new Yt({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=ge,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new qi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==ge&&r.next(this.currentValue)):(this.subject=new Te,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Yt({next:i=>{this.promise&&i!==Fr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=ge;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Fr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Wi),this.promise=null),this.currentValue!==ge)return this.subject.complete();if(t===ge){const i=this.subject;return this.subject=null,i.error(new Wi)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ge&&this.currentValue===ge&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",ge),He(this,"promise",null),He(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Fn?s:new Fn(s,ge)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ge&&this.currentValue!==Fr)return this.currentValue;if(this.defaultValue!==ge)return this.defaultValue;if(this.refCount===0)throw new qi;const r=new ih((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===ge&&delete this.getDefaultValue}};function Ki(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function ch(e,t){const n=new ah,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Fn(e(...o),r(...o),()=>{n.delete(i)}),a=new $(d=>{const h=n.get(i);let f=u;return h?h!==a&&(f=h,Ki(f,a)):n.set(i,l),f.subscribe(d)});Ki(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var ah=class{constructor(){He(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 uh(e,t){return new Fn(e,t)}var qr=(...e)=>(typeof e[0]=="function"?ch:uh)(e[0],e.length>1?e[1]:ge);const Xi=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},Yi=(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}},Gi=(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)},lh=(e,t,n)=>{const r=qr((c,u,a)=>{const l=Gi(c,u),d=(b,m)=>{const g=wf(e,m.hash).pipe(Ie(x=>!x),J(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(R(x=>x===b?.rootHash?Pe({...b,block:m,deltas:null,prev:b.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),I(([y,w])=>[y,l(w)]),I(([y,w])=>({prev:b&&b.block.hash,rootHash:x,block:m,...Xi(b?.entries??[],y,w)})))),bi(g),lt(x=>x instanceof Ot?yt:Tn(()=>x)))},h=e.pipe(le((b,m)=>b.finalized===m.finalized),Rr(({blocks:b,finalized:m})=>d(null,b.get(m))),J(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[f,p]=Of(),v=e.pipe(le((b,m)=>b.best===m.best),_r(f),Rr(([b,m])=>{const{best:g}=b,{blocks:x}=m;let y=x[g]?null:g;if(!y)return yt;const w=Yi(y,x,b);return w?d(w,b.blocks.get(y)).pipe(I(A=>(x[y]=A,m))):(y=b.finalized,d(x[m.finalized],b.blocks.get(y)).pipe(I(A=>(A.prev=null,{blocks:{[y]:A},finalized:y}))))}));return Sr(h,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),h=Gi(u,a),f=c?"finalized":"best";return Bt([d.pipe(Ul(0)),e.pipe(le((p,v)=>p[f]===v[f]))]).pipe(I(([p,v])=>Yi(v[f],p.blocks,v,!0)),Ie(Boolean),le(),vi(null),Vl(),_r(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],m])=>[p,v,b,h(m)]),R(([p,v,b,m])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:y}=b;Object.keys(y).forEach(w=>{y[w].block.number<x[0].block.number&&delete y[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Xi(p.entries,v.entries,m)}]}))},o=qr(s(!0)),i=qr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(J(1),R(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),I(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(J(1),R(h=>d(c,u,h)),I(({block:{hash:h,number:f,parent:p},deltas:v,entries:b},m)=>{const g=m>0?v:{deleted:[],upserted:b};return{block:{hash:h,number:f,parent:p},entries:b.map(Wr),deltas:g&&{deleted:g.deleted.map(Wr),upserted:g.upserted.map(Wr)}}}))}},Wr=e=>e.dec,Ni=(e,t,n)=>{const r={},s=v=>new Proxy(r,{get(b,m){return v(m)}}),o=v=>{const b={};return s(m=>(b[m]||(b[m]={}),s(g=>(b[m][g]||(b[m][g]=v(m,g)),b[m][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(m=>m.name===b),c=lh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((v,b)=>Tf(v,b,t,c,Tt(e,m=>m.getPalletEntryPoint($t.Storage,v,b),m=>{const g=i(m,v)?.storage?.items.find(x=>x.name===b);return g==null?null:bu(g)}))),a=(v,b,m,g)=>{if(m==null)return null;const x=v.lookup(m);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const y=yu(x.value[g]);return{args:b==="args"?y:wn,values:b==="args"?wn:y}},l=o((v,b)=>Fi(v,b,t,n,Tt(e,m=>m.getPalletEntryPoint($t.Tx,v,b),m=>a(m,"args",i(m,v)?.calls,b)),!0)),d=o((v,b)=>Cf(v,b,t,Tt(e,m=>m.getPalletEntryPoint($t.Event,v,b),m=>a(m,"values",i(m,v)?.events,b)))),h=o((v,b)=>If(v,b,Tt(e,m=>m.getPalletEntryPoint($t.Const,v,b),m=>{const g=i(m,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:gu(g)}))),f=o((v,b)=>$f(v,b,t,Tt(e,m=>m.getApiEntryPoint(v,b),m=>mu(m.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:m,dynamicBuilder:g}=Cr(b).runtime();try{const x=g.buildDefinition(m.call).dec(v.asBytes()),y=x.type,w=x.value.type,A=x.value.value;return Fi(y,w,t,n,Tt(e,_=>_.getPalletEntryPoint($t.Tx,y,w),_=>a(_,"args",i(_,y)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,b)=>b?p(v,b):e.then(m=>p(v,m)),tx:l,event:d,apis:f,constants:h}};function fh(e){const t=Uu(e),n=gf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Rn(r).pipe(I(({genesisHash:f})=>f),lt(()=>s),Mn(1))},c=t.request;let u;const a=new WeakMap,l=f=>{const p=a.get(f)||Af(f,i);return a.set(f,p),p},d=()=>u??(u=Sf(i)),{broadcastTx$:h}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Re(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Re(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:f=>Re(i.body$(f)),getBlockHeader:f=>Re(i.header$(f??null)),submit:(...f)=>Hi(i,h,...f),submitAndWatch:(...f)=>Hr(i,h,...f),getTypedApi:f=>{const p=l(f);return Object.assign(Ni(p,i,h),{compatibilityToken:p})},getUnsafeApi:()=>{const f=d();return Object.assign(Ni(f,i,h),{runtimeToken:f})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const hh=(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:c}=o,u=new Uint8Array(i);return a=>{const l=De.fromBytes(ue(u,c.enc(a)));return{encodedData:l,decodedCall:bt(e,bt(t,a)),sign:async(d,h)=>te(await d.signTx(l.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},dh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=fe(e),r=await t(),s=ct.dec(r).metadata.value,o=Vn(s),i=Br(o),c=ji(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(m=>(v[b][m]||(v[b][m]=p(b,m)),v[b][m]))))},h=d((p,v)=>{const b=u(p)?.constants.find(m=>m.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),f=d((p,v)=>hh(p,v,r,i,c));return{constants:h,tx:f}},tn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ph=async e=>{const t=cr(await e.getMetadata()).metadata.value,n={},r=d=>new Proxy(n,{get(h,f){return d(f)}}),s=d=>{const h={};return r(f=>(h[f]||(h[f]={}),r(p=>(h[f][p]||(h[f][p]=d(f,p)),h[f][p]))))},o=Vn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Br(o);return{query:s((...d)=>{const{value:h,args:f}=tn(c,"Storage")(...d);return{value:h,args:f}}),tx:s((...d)=>tn(a,"Call")(...d).codec),event:s((...d)=>tn(l,"Event")(...d).codec),apis:s(tn(i,"Runtime API")),constants:s(tn(u,"Constant"))}};ie.AccountId=pt,ie.Binary=De,ie.CompatibilityLevel=Ae,ie.Enum=bt,ie.FixedSizeBinary=pn,ie.InvalidTxError=zr,ie._Enum=Ws,ie.createClient=fh,ie.getOfflineApi=dh,ie.getSs58AddressInfo=Zn,ie.getTypedCodecs=ph});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function Bn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var St=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 c=kt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(V(l))try{l()}catch(v){o=v instanceof gr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=kt(d),f=h.next();!f.done;f=h.next()){var p=f.value;try{jo(p)}catch(v){o=o??[],v instanceof gr?o=Ce(Ce([],Oe(o)),Oe(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{f&&!f.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(o)throw new gr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)jo(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)&&Bn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Bn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Do=St.EMPTY;function Vo(e){return e instanceof St||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function jo(e){V(e)?e():e.unsubscribe()}var Du={Promise:void 0},Vu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ce([e,t],Oe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function zo(e){Vu.setTimeout(function(){throw e})}function $e(){}function On(e){e()}var Yt=function(e){je(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Vo(n)&&n.add(r)):r.destination=Hu,r}return t.create=function(n,r,s){return new It(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}(St),ju=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){Cn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Cn(r)}else Cn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Cn(n)}},e}(),It=function(e){je(t,e);function t(n,r,s){var o=e.call(this)||this,i;return V(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new ju(i),o}return t}(Yt);function Cn(e){zo(e)}function zu(e){throw e}var Hu={closed:!0,next:$e,error:zu,complete:$e},wr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ge(e){return e}function Ho(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fo(e)}function Fo(e){return e.length===0?Ge:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var C=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=qu(t)?t:new It(t,n,r);return On(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?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=qo(n),new n(function(s,o){var i=new It({next:function(c){try{t(c)}catch(u){o(u),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[wr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Fo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=qo(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 qo(e){var t;return(t=e??Du.Promise)!==null&&t!==void 0?t:Promise}function Fu(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function qu(e){return e&&e instanceof Yt||Fu(e)&&Vo(e)}function Wu(e){return V(e?.lift)}function W(e){return function(t){if(Wu(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 H(e,t,n,r,s){return new Ku(e,t,n,r,s)}var Ku=function(e){je(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}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}(Yt),Xu=yr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=function(e){je(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 Wo(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Xu},t.prototype.next=function(n){var r=this;On(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=kt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;On(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;On(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,c=s.observers;return o||i?Do:(this.currentObservers=null,c.push(n),new St(function(){r.currentObservers=null,Bn(c,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 C;return n.source=this,n},t.create=function(n,r){return new Wo(n,r)},t}(C),Wo=function(e){je(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:Do},t}(Te),Yu=function(e){je(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}(Te),Er={now:function(){return(Er.delegate||Date).now()},delegate:void 0},$n=function(e){je(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Er);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,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+u)),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,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Te),Gu=function(e){je(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(St),Ko={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ce([e,t],Oe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Nu=function(e){je(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),Ko.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&&Ko.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,Bn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Gu),Xo=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=Er.now,e}(),Qu=function(e){je(t,e);function t(n,r){r===void 0&&(r=Xo.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}(Xo),Yo=new Qu(Nu),Zu=Yo,yt=new C(function(e){return e.complete()});function Go(e){return e&&V(e.schedule)}function xr(e){return e[e.length-1]}function kr(e){return V(xr(e))?e.pop():void 0}function Gt(e){return Go(xr(e))?e.pop():void 0}function Ju(e,t){return typeof xr(e)=="number"?e.pop():t}var No=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Qo(e){return V(e?.then)}function Zo(e){return V(e[wr])}function Jo(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function ei(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 el(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ti=el();function ni(e){return V(e?.[ti])}function ri(e){return Mu(this,arguments,function(){var n,r,s,o;return Lo(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,At(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,At(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,At(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 si(e){return V(e?.getReader)}function se(e){if(e instanceof C)return e;if(e!=null){if(Zo(e))return tl(e);if(No(e))return nl(e);if(Qo(e))return rl(e);if(Jo(e))return oi(e);if(ni(e))return sl(e);if(si(e))return ol(e)}throw ei(e)}function tl(e){return new C(function(t){var n=e[wr]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function nl(e){return new C(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function rl(e){return new C(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,zo)})}function sl(e){return new C(function(t){var n,r;try{for(var s=kt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function oi(e){return new C(function(t){il(e,t).catch(function(n){return t.error(n)})})}function ol(e){return oi(ri(e))}function il(e,t){var n,r,s,o;return Uu(this,void 0,void 0,function(){var i,c;return Lo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Lu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.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 ut(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 ii(e,t){return t===void 0&&(t=0),W(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function ci(e,t){return t===void 0&&(t=0),W(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function cl(e,t){return se(e).pipe(ci(t),ii(t))}function al(e,t){return se(e).pipe(ci(t),ii(t))}function ul(e,t){return new C(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function ll(e,t){return new C(function(n){var r;return ut(n,t,function(){r=e[ti](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new C(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function fl(e,t){return ai(ri(e),t)}function hl(e,t){if(e!=null){if(Zo(e))return cl(e,t);if(No(e))return ul(e,t);if(Qo(e))return al(e,t);if(Jo(e))return ai(e,t);if(ni(e))return ll(e,t);if(si(e))return fl(e,t)}throw ei(e)}function _t(e,t){return t?hl(e,t):se(e)}function ze(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return _t(e,n)}function Tn(e,t){var n=V(e)?e:function(){return e},r=function(s){return s.error(n())};return new C(r)}var ui=yr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function dl(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 ui)}})})}function Pe(e,t){return new Promise(function(n,r){var s=new It({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new ui)}});e.subscribe(s)})}function pl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var vl=Array.isArray;function bl(e,t){return vl(t)?e.apply(void 0,Ce([],Oe(t))):e(t)}function li(e){return I(function(t){return bl(e,t)})}var ml=Array.isArray,yl=Object.getPrototypeOf,gl=Object.prototype,wl=Object.keys;function El(e){if(e.length===1){var t=e[0];if(ml(t))return{args:t,keys:null};if(xl(t)){var n=wl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function xl(e){return e&&typeof e=="object"&&yl(e)===gl}function kl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Bt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=kr(e),s=El(e),o=s.args,i=s.keys;if(o.length===0)return _t([],n);var c=new C(fi(o,n,i?function(u){return kl(i,u)}:Ge));return r?c.pipe(li(r)):c}function fi(e,t,n){return n===void 0&&(n=Ge),function(r){hi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){hi(t,function(){var d=_t(e[l],t),h=!1;d.subscribe(H(r,function(f){o[l]=f,h||(h=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function hi(e,t,n){e?ut(n,e,t):t()}function Al(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,h=function(){d&&!u.length&&!a&&t.complete()},f=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;se(n(v,l++)).subscribe(H(t,function(m){t.next(m)},function(){b=!0},void 0,function(){if(b)try{a--;for(var m=function(){var g=u.shift();i||p(g)};u.length&&a<r;)m();h()}catch(g){t.error(g)}}))};return e.subscribe(H(t,f,function(){d=!0,h()})),function(){}}function R(e,t,n){return n===void 0&&(n=1/0),V(t)?R(function(r,s){return I(function(o,i){return t(r,o,s,i)})(se(e(r,s)))},n):(typeof t=="number"&&(n=t),W(function(r,s){return Al(r,s,e,n)}))}function Pn(e){return e===void 0&&(e=1/0),R(Ge,e)}function Sl(){return Pn(1)}function Ar(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Sl()(_t(e,Gt(e)))}function Rn(e){return new C(function(t){se(e()).subscribe(t)})}var Il={connector:function(){return new Te},resetOnDisconnect:!0};function _l(e,t){t===void 0&&(t=Il);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new C(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Rn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Un(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Zu);var r=-1;return t!=null&&(Go(t)?n=t:r=t),new C(function(s){var o=pl(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 Sr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e),r=Ju(e,1/0),s=e;return s.length?s.length===1?se(s[0]):Pn(r)(_t(s,n)):yt}var Bl=Array.isArray;function Ol(e){return e.length===1&&Bl(e[0])?e[0]:e}function Ie(e,t){return W(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return W(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=se(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Cl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function di(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return n?Ho(di.apply(void 0,Ce([],Oe(e))),li(n)):W(function(r,s){fi(Ce([r],Oe(Ol(e))))(s)})}function $l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return di.apply(void 0,Ce([],Oe(e)))}function Tl(e,t){return V(t)?R(e,t,1):R(e,1)}function J(e){return e<=0?function(){return yt}:W(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Pl(e){return I(function(){return e})}function Rl(e,t){return R(function(n,r){return se(e(n,r)).pipe(J(1),Pl(n))})}function Ul(e,t){t===void 0&&(t=Yo);var n=Un(e,t);return Rl(function(){return n})}function Ml(e,t){return W(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&se(t).subscribe(H(r,function(){return s.clear()},$e))})}function le(e,t){return t===void 0&&(t=Ge),e=e??Ll,W(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Ll(e,t){return e===t}function Dl(e,t){return W(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),se(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Vl(){return W(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Nt(e,t){return W(Cl(e,t,arguments.length>=2,!0))}function Qt(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,h,f=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},m=function(){b(),l=h=void 0,p=v=!1},g=function(){var x=l;m(),x?.unsubscribe()};return W(function(x,y){f++,!v&&!p&&b();var w=h=h??n();y.add(function(){f--,f===0&&!v&&!p&&(d=Ir(g,u))}),w.subscribe(y),!l&&f>0&&(l=new It({next:function(A){return w.next(A)},error:function(A){v=!0,b(),d=Ir(m,s,A),w.error(A)},complete:function(){p=!0,b(),d=Ir(m,i),w.complete()}}),se(x).subscribe(l))})(a)}}function Ir(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 It({next:function(){s.unsubscribe(),e()}});return se(t.apply(void 0,Ce([],Oe(n)))).subscribe(s)}}function Mn(e,t,n){var r,s,o,i,c=!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,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,Qt({connector:function(){return new $n(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function pi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Gt(e);return W(function(r,s){(n?Ar(e,r,n):Ar(e,r)).subscribe(s)})}function Ln(e,t){return W(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;se(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function jl(){return Ln(Ge)}function vi(e){return W(function(t,n){se(e).subscribe(H(n,function(){return n.complete()},$e)),!n.closed&&t.subscribe(n)})}function bi(e,t){return t===void 0&&(t=!1),W(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function mi(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?W(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Ge}function _r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=kr(e);return W(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){se(e[d]).subscribe(H(s,function(h){i[d]=h,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ge))&&(c=null))},$e))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var h=Ce([d],Oe(i));s.next(n?n.apply(void 0,Ce([],Oe(h))):h)}}))})}var zl=Object.defineProperty,Hl=(e,t,n)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yi=(e,t,n)=>Hl(e,typeof t!="symbol"?t+"":t,n);class Fl{constructor(){yi(this,"first"),yi(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 ql=()=>{const e=new Map,t=(h,f)=>{e.set(h,()=>{e.delete(h),f()})},n=h=>{e.get(h)?.()},r=new Fl,s=r.unshift.bind(r),o=r.push.bind(r),i=(h,f)=>{const p=f?s:o;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:f,observer:p}=h;let v=!1;const b=f.subscribe({next(m){p.next(m)},error(m){(v=m instanceof kn)?i(h,!0):p.error(m)},complete(){p.complete()}});b.closed?v||c():t(f,()=>{b.unsubscribe(),c()})},a=(h=!1)=>f=>new C(p=>{const v={observer:p,source$:f};return r.isEmpty()?u(v):i(v,h),()=>{n(f)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...f)=>l(h(...f))}};class Ot extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Wl=new Set(["best","finalized",null]),gi=e=>{const t=e.pipe(lt(n=>n instanceof An?Un(750).pipe(Tl(()=>t)):Tn(()=>n)));return t},Kl=(e,t,n)=>r=>(s,...o)=>{if(!Wl.has(s))return gi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(J(1),R(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Ot?c:Tn(()=>u)));return gi(c)},wi=e=>(...t)=>new C(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}}),Xl=e=>t=>(...n)=>e()[t](...n);function Dn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new C(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:h=>{const f=h.blocks.get(r);f?f.recovering?c?.unsubscribe():a():l&&i.error(new Ot(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Yl=e=>e.pipe(Nt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),R(({newBlocks:t})=>t),Qt()),Gl=(e,t)=>{const n=(r,s,o,i)=>new C(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Pn(),t(i));return n},Nl=e=>t=>new C(n=>{let r=null;return t.subscribe({next(s){s.type==="initialized"?(r=[],e(s.finalizedBlockHashes[0]).then(o=>{n.closed||(n.next({...s,number:o.number,parentHash:o.parentHash}),r.forEach(i=>{n.next(i)}),r=null)}).catch(o=>{n.closed||n.error(o)})):r?r.push(s):n.next(s)},error(s){n.error(s)},complete(){n.complete()}})}),Ql=e=>{let t=null,n=$e;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(so.dec),o=_l(new C(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Nl(s),Zl()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},Zl=()=>e=>new C(t=>{const n=new St,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Co?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),Ei=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},Jl=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const f=l(d);return h=n.get(d),h?Object.assign(h,f):(h={id:d,...f},n.set(d,h)),r.delete(d),h};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:h,path:f,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return ft;if(h.value.length===1){const v=c(h.value[0].type);return o&&f.at(-1)==="AccountId32"&&Ei(v,32)?(o=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&Ei(v,20)?(i=!1,{type:"AccountId20"}):v}return u(h.value)}if(h.tag==="variant"){if(f.length===1&&f[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(f.length===1&&f[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(h.value.length===0)return ft;const v={},b={};return h.value.forEach(m=>{const g=m.name;if(b[g]=m.docs,m.fields.length===0){v[g]={...ft,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[g]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[g]={...u(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:v}=h.value,b=c(h.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?ft:h.value.length>1?a(h.value.map(v=>c(v)),h.value.map(v=>e[v].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const v=c(h.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:h.tag}}),u=l=>{let d=!0;const h={},f={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,m=c(p.type);m.type!=="void"&&(h[b]=m,f[b]=p.docs)}),d?{type:"struct",value:h,innerDocs:f}:a(Object.values(h),Object.values(f))},a=(l,d)=>{if(l.every(h=>h.id===l[0].id)&&d.every(h=>!h.length)){const[h]=l;return h.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Vn=e=>{const t=Jl(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?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors),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),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},ef=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},tf=Ft(),xi=ef((e,t,n,r)=>{if(e.type==="primitive")return Ao[e.value];if(e.type==="void")return B;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return to;if(e.type==="compact")return e.isBig?vn:O;if(e.type==="bitSequence")return js;const s=f=>xi(f,t,n,r),o=(f,p)=>{const v=s(f);return p?me(v,p):me(v)},i=f=>De(...f.map(s)),c=f=>{const p=Object.fromEntries(Object.entries(f).map(([v,b])=>[v,s(b)]));return be(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return tf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ft(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 c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return bn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(f=>{switch(f.type){case"void":return B;case"lookupEntry":return s(f.value);case"tuple":return i(f.value);case"struct":return c(f.value);case"array":return o(f.value,f.len)}}),a=Object.fromEntries(Object.keys(e.value).map((f,p)=>[f,u[p]])),l=Object.values(e.value).map(f=>f.idx),h=l.every((f,p)=>f===p)?he(a):he(a,l);return e.byteLength?nf(h,e.byteLength):h},er,e=>e),ki=(e,t=pt())=>{const n=new Map,r=s=>xi(e(s),n,new Set,t);return s=>r(s)},nf=(e,t)=>{const n=N(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Br=e=>{const{metadata:t}=e;let n=ki(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let s;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(s=d,n=ki(e,pt(d)))}catch{}const o=new Map,i=(d,h)=>{let f=o.get(d);f||o.set(d,f=xo(d));const p=t.pallets.find(A=>A.name===d).storage.items.find(A=>A.name===h),v=(A,_,...T)=>{const P=f(...T),[,...K]=T;return{args:De(...K.map(([G])=>G)),keys:P,value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,n(p.type.value),h);const{key:b,value:m,hashers:g}=p.type.value,x=n(m),y=g.map(A=>Ao[A.tag]),w=(()=>{if(y.length===1)return[[n(b),y[0]]];const A=e(b);switch(A.type){case"array":return y.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,T)=>[n(_.id),y[T]]);default:throw new Error("Invalid key type")}})();return v(y.length,x,h,...w)},c=d=>{switch(d.type){case"void":return B;case"lookupEntry":return n(d.value.id);case"tuple":return De(...Object.values(d.value).map(h=>n(h.id)));case"struct":return be(wt(d.value,h=>n(h.id)));case"array":return me(n(d.value.id),d.len)}},u=(d,h)=>{const f=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===h);return n(f.type)},a=d=>(h,f)=>{const p=t.pallets.find(m=>m.name===h),v=e(p[d]);if(v.type!=="enum")throw null;const b=v.value[f];return{location:[p.index,b.idx],codec:c(v.value[f])}},l=(d,h)=>{const f=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===h);if(!f)throw null;return{args:De(...f.inputs.map(p=>n(p.type))),value:n(f.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},rf=te(Be.enc(15)),Ai=N(),sf=it(Ai),of=me(Be).dec,cf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Ot)return r(c,u);if(l instanceof An)return Un(750).pipe(R(()=>r(c,u)));throw l})):yt},s=r("Metadata_metadata_versions","").pipe(I(of)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Ai.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}})),i=r("Metadata_metadata_at_version",rf).pipe(I(c=>{const u=sf.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}}));return s.pipe(lt(()=>ze([14])),R(c=>c.includes(15)?i:o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Vn(c),l=Br(a),d=l.buildStorage("System","Events"),h=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let f=null;if(h){const p=a(h.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(f=v.value.id)}}return{assetId:f,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:d.keys.enc(),dec:d.value.dec},accountId:pt(l.ss58Prefix)}}),Mn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},Zt=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Si=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ii=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},af=(e,t)=>{t.forEach(n=>{Ii(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},uf=(e,t,n,r,s)=>{const o=new Te,i=o.pipe(Dl(()=>Un(0)),I(()=>({type:"cleanup"}))),c=Sr(n,i,e).pipe(Nt((a,l)=>{const d=h=>{af(a,h),r(h)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=_i()));const[h]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=h;const f=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const m=a.blocks.get(v);m?(m.recovering=!1,m.unpinnable=b!==f):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===f?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==f,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(h));return a.finalizedRuntime=p??(a.runtimes[h]=u(Si(a,h))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const m=a.blocks.get(v);m.children.add(b);const g={hash:b,number:m.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:m.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Si(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(Ii(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(m=>{const g=a.blocks.get(m);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:m})=>b&&!m).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},_i()),Ie(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),Zt),u=cf(Dn(c,t,"pinned-blocks"));return c},_i=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Bi=(e,t,n,r)=>{const s=c=>vi(e.pipe(Ie(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return ze({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(R(d=>{const h=d.indexOf(u);return h>-1?l(r(c)).pipe(I(f=>({hash:c,found:{type:!0,index:h,events:f}}))):n(c,u).pipe(I(f=>({hash:c,found:{type:!1,validity:f}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(R(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?ze(l):e.pipe(s(c),R(h=>h.blocks.get(c).children),Ml(),R(h=>i(h,u,a)))}));return c=>e.pipe(J(1),R(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},lf=new Uint8Array([2]),ff=(e,t)=>te(ue(lf,fe(e),fe(t))),Oi="TaggedTransactionQueue",Ci="validate_transaction",[,hf]=he({InvalidTransaction:he({Call:B,Payment:B,Future:B,Stale:B,BadProof:B,AncientBirthBlock:B,ExhaustsResources:B,Custom:j,BadMandatory:B,MandatoryValidation:B,BadSigner:B}),UnknownTransaction:he({CannotLookup:B,NoUnsignedValidator:B,Custom:j})}),df=on(e=>{const t=j.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=hf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),pf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Oi,Ci).value[1]}catch{return df}}));return e(n,`${Oi}_${Ci}`,ff(r,n)).pipe(_r(s),I(([o,i])=>i(o)))},vf=e=>t=>new C(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}),bf=e=>t=>new C(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)}}),$i=(e,t=1/0)=>n=>new C(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const h=o.get(a);if(!h){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const f=a++;o.delete(f),l!==f&&c.set(f,[]);let p=!1,v=h.subscribe({next(b){l===f?r.next(b):c.get(f).push(b)},complete(){if(p=!0,i.delete(f),f===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(f,v)};return s=n.subscribe({next(h){const f=u++;o.set(f,Rn(()=>e(h,f))),i.size<t&&d()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(h=>h.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Or=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),mf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=Ql(e),o=Xl(t),{withRecovery:i,withRecoveryFn:c}=ql(),u=new Te,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>S=>new C($=>{const q=a(E),oe=S.subscribe($);return oe.add(q),oe}),d=E=>(S,...$)=>E(S,...$).pipe(l(S)),h=(E,S)=>($,...q)=>new C(oe=>{let ve=!1;return b.pipe(J(1)).subscribe(_e=>{ve=_e.blocks.has($)}),ve?E($,...q).subscribe(oe):oe.error(new Ot($,S))}),f=E=>t().unpin(E).catch(S=>{if(!(S instanceof xn))throw S}),p=(E,S)=>h(d(Dn(b,c(wi(E)),`stop-${S}`)),S),v=new Map,b=uf(r,d(c(wi(o("call")))),u,E=>{f(E),E.forEach(S=>{v.delete(S)})},E=>{v.delete(E)}),m=d(E=>b.pipe(J(1),R(S=>S.runtimes[S.blocks.get(E).runtime].runtime))),g=E=>S=>S.pipe($i($=>m(E($)).pipe(I(q=>[$,q])))),x=(E,S,$)=>{const q=v.get(E)??new Map,oe=q.get(S);if(oe)return oe;v.set(E,q);let ve;const _e=$.pipe(Qt({connector:()=>ve=new $n}),mi({complete(){q.set(S,ve)}}),bf());return q.set(S,_e),_e},y=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized),Nt((E,S)=>{let $=S.blocks.get(S.finalized);const q=[$],oe=E.at(-1);if(!oe)return q;for(;$.number>oe.number+1&&($=S.blocks.get($.parent),!!$);)q.unshift($);return q},[]),Pn(),I(Or),Zt),w=b.pipe(le((E,S)=>E.best===S.best),I(E=>Or(E.blocks.get(E.best))),Zt),A=b.pipe(Ie(E=>!E.recovering),le((E,S)=>E.finalized===S.finalized&&E.best===S.best),Nt((E,S)=>{const $=we=>E.get(we)||Or(S.blocks.get(we)),q=$(S.best),oe=$(S.finalized),ve=q.number-oe.number+1,_e=new Array(ve);for(let we=0,rn=q.hash;we<ve;we++)_e[we]=$(rn),rn=_e[we].parent;return new Map(_e.map(we=>[we.hash,we]))},new Map),I(E=>[...E.values()]),Zt),_=b.pipe(le((E,S)=>E.finalizedRuntime===S.finalizedRuntime),Ln(({finalizedRuntime:{runtime:E}})=>E.pipe(vf(null))),Zt),T=_.pipe(I(E=>E?.lookup.metadata??null)),P=Kl(y.pipe(I(E=>E.hash)),w.pipe(I(E=>E.hash)),l),K=P(p(o("body"),"body")),G=E=>x(E,"body",K(E)),X=p(o("storage"),"storage"),ne=P((E,S,$,q=null,oe)=>b.pipe(J(1),R(ve=>ve.runtimes[ve.blocks.get(E).runtime].runtime),R(ve=>{const _e=$(ve),we=x(E,`storage-${S}-${_e}-${q??""}`,X(E,S,_e,q));return oe?x(E,`storage-${S}-${_e}-${q??""}-dec`,we.pipe(I(rn=>({raw:rn,mapped:oe(rn,ve)})))):we}))),Ne=Gl(t,i),Pt=P(Dn(b,(E,S,$)=>Ne(E,S,$??null,!1),"storageQueries")),nn=P(Dn(b,E=>Rn(()=>s(E)),"header")),qn=E=>ne(E,"value",S=>S.events.key,null,(S,$)=>$.events.dec(S)).pipe(I(S=>S.mapped)),vh=p(o("call"),"call"),Ni=P((E,S,$)=>x(E,`call-${S}-${$}`,vh(E,S,$))),Kr=pf(Ni,m),Qi=E=>x(E,"body",K(E)),bh=Bi(b,Qi,Kr,qn),mh=Bi(b,Qi,Kr,()=>ze()),yh=_.pipe(Ie(Boolean),J(1),R(E=>{const{enc:S}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let $;try{$=S(0)}catch{$=S(0n)}return ne(null,"value",()=>$,null)}),Mn(1));Sr(_,A).subscribe({error(){}});let Xr=$e,Wn=!1,Yr=0;const gh=E=>{Yr+=E,Wn=!0,Xr=n()};return[{follow$:r,finalized$:y,best$:w,bestBlocks$:A,newBlocks$:Yl(b),runtime$:_,metadata$:T,genesis$:yh,header$:nn,body$:G,call$:Ni,storage$:ne,storageQueries$:Pt,eventsAt$:qn,holdBlock:a,trackTx$:bh,trackTxWithoutEvents$:mh,validateTx$:Kr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:P(m),unfollow:()=>{Wn!=null&&(Yr--,Wn&&!Yr&&(Wn=null,Xr(),Xr=$e))}},gh]};var yf=e=>t=>new C(n=>e(t,r=>{n.error(r)}));const jn=new Map,gf=e=>{const t=jn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=jn.get(e);!c||c.refCount<=1?(jn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=mf(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:yf(e.transaction),destroy:n};return jn.set(e,{client:i,refCount:1}),i},wf=(e,t)=>e.pipe(bi(n=>n.blocks.has(t)),le((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(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}),le(),bi(n=>n!=="finalized",!0));class Ct{constructor(){}_runtime(t){}}class Ti{constructor(){}_compatibility(t){}}const zn=new WeakMap,Pi=new WeakMap,Cr=e=>e instanceof Ct?Pi.get(e):zn.get(e);var $t=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))($t||{});const Ef=me(pu),xf=me(fr),kf=De(Ef,xf),Af=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Ie(i=>i!=null));let o=await Pe(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(kf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Ti;return zn.set(c,{runtime:i,getPalletEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},getApiEntryPoint(u,a){const l=o.apis?.[u]?.[a];if(l==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[l]},typedefNodes:s}),c})},Sf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ie(s=>s!=null));let r=await Pe(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Ct;return Pi.set(n,{runtime:t}),n}),$r=new WeakMap,Ri=e=>($r.has(e.metadataRaw)||$r.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),$r.get(e.metadataRaw)),Tt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Ri(i);return(u=a.typeNodes)[c]||(u[c]=yn(a.lookup(c)))};function s(i,c){if(i instanceof Ct)return{args:Ae.Identical,values:Ae.Identical};const u=zn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ae.Incompatible,values:Ae.Incompatible};const d=u.typedefNodes,h=Ri(c);return gu(a,f=>d[f],l,f=>r(c,f),h.compat)}const o=Mi(e,i=>Ui(s(i)));return{isCompatible:Mi(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Bt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Bt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c);if(a.args===Ae.Incompatible)return!1;if(a.args>Ae.Partial)return!0;if(a.values===Ae.Incompatible)return!1;const l=n(c);return l==null?!1:Oo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Ct)return!0;const a=s(i,c).values;if(a===Ae.Incompatible)return!1;if(a>Ae.Partial)return!0;const l=zn.get(i),d=t(l);return Oo(d.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r}},Ui=e=>Math.min(e.args,e.values),Mi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Ti||r instanceof Ct?t(...n):e.then(s=>t(...n,s))},If=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Cr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},_f=Qt({connector:()=>new $n(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Tr(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new Us)}:$e;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Pr=Symbol("EMPTY_VALUE"),Rr=e=>t=>new C(n=>{let r=0,s=null,o=Pr,i=!1;const c=()=>{const a=e(o,r++);o=Pr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Pr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Li={};const Bf=e=>t=>new C(n=>{let r=Li,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Li?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Jt=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)),Of=()=>{const e=new Yu(new Te);return[e.pipe(jl()),()=>mi({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},Cf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,h])=>{const f=h.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(f==null||h.lookup.metadata.lookup[f].def.tag!=="variant"||h.lookup.metadata.lookup[f].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,h,null))throw u();return[l,d,h]}),$i(([l,d,h])=>n.eventsAt$(l.hash).pipe(I(f=>f.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),_f);return{watch:l=>a.pipe(R(d=>l?d.filter(h=>l(h.payload)):d)),pull:()=>Pe(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},$f=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],h=Jt(d),{signal:f,at:p}=h?d:{},v=p??null,b=o(n,v).pipe(R(([m,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(m,g,l))throw a();return n.call$(v,u,te(x.args.enc(l))).pipe(I(x.value.dec),I(y=>{if(!c(m,g,y))throw a();return y}))}));return Tr(b,f)},{getCompatibilityLevel:s,isCompatible:r})},Ur=I(e=>e.mapped),Tf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",h=n.runtime$.pipe(Ie(Boolean),J(1),I(({dynamicBuilder:y})=>typeof y.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ge),Mn()),f=Ho($l(h),I(([y,w])=>w(y))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=y=>new Error(`Invalid Arguments calling ${e}.${t}(${y})`),b=y=>{try{return y.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},m=(...y)=>{const w=y[y.length-1],A=w==="best",_=A||w==="finalized"?y.slice(0,-1):y;return n[A?"best$":"finalized$"].pipe(Rr(()=>g(..._,A?{at:"best"}:{})),le((T,P)=>T.raw===P.raw),Ur)},g=(...y)=>{const w=y[y.length-1],A=Jt(w),{at:_}=A?w:{},T=_??null;return l?n.pinnedBlocks$.pipe(I(P=>{const K=T==="finalized"||!T?P.finalized:T==="best"?P.best:T,G=P.blocks.get(K);if(!G)throw new Ot(K,"System.Number");return G.number}),le(),f,I(P=>({raw:P,mapped:P}))):d&&Number(y[0])===0?n.genesis$.pipe(I(P=>({raw:P,mapped:pn.fromHex(P)}))):_t(c).pipe(R(P=>n.storage$(T,"value",K=>{const G=b(K),X=y.length===G.len?y:y.slice(0,-1);if(y!==X&&!A)throw v(y);if(!u(P,K,X))throw p();return G.keys.enc(...X)},null,(K,G)=>{const X=b(G),ne=K===null?X.fallback:X.value.dec(K);if(!a(P,G,ne))throw p();return ne})))},x=async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_}=A?w:{};return Tr(g(...y).pipe(Ur),_)};return{isCompatible:s,getCompatibilityLevel:o,getValue:x,getValues:(y,w)=>Promise.all(y.map(A=>x(...w?[...A,w]:A))),getEntries:async(...y)=>{const w=y[y.length-1],A=Jt(w),{signal:_,at:T}=A?w:{},P=T??null,K=await c,G=n.storage$(P,"descendantsValues",X=>{const ne=b(X);if(Ui(i(K,X))===Ae.Incompatible)throw p();if(y.length>ne.len)throw v(y);const Ne=y.length>0&&A?y.slice(0,-1):y;if(y.length===ne.len&&Ne===y)throw v(y);return ne.keys.enc(...Ne)},null,(X,ne)=>{const Ne=b(ne),Pt=X.map(({key:nn,value:qn})=>({keyArgs:Ne.keys.dec(nn),value:Ne.value.dec(qn)}));if(Pt.some(({value:nn})=>!a(K,ne,nn)))throw p();return Pt}).pipe(Ur);return Tr(G,_)},watchValue:m,watchEntries:(...y)=>{const w=y.at(-1),A=Jt(w);return r(e,t,A?y.slice(0,-1):y,A&&w.at==="best")}}},Pf=Ut(j.enc,e=>+!!e.signed<<7|e.version),Mr=()=>new Error("Unkown signer"),Rf=e=>{const{extrinsic:t}=e,n=Vn(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 Mr()}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 Mr();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 Mr()},Uf={Ed25519:0,Sr25519:1,Ecdsa:2},Mf=(e,t,n,r,s,o)=>{const[i,c]=Rf(e),u=ue(Pf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Uf[o],...n]),...r,s);return ue(ce.enc(u.length),u)},[Hn,en]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),Lf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Hn.length;r++)n=Hn[r]===t[r];n=n&&r===Hn.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:ue(Hn,t,en))};function Df(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Wt)=>{let a;try{const p=cr(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const h=ue(s,...l,...d),f=await n(h.length>256?u(h):h);return Mf(a,e,f,l,s,t)},signBytes:Lf(n)}}const Vf=(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 jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const zf=Ut(N(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(jf(e.period)-1,1),15),r=e.phase/t<<4;return Je[0](n|r)}),[Hf]=be({tip:ce,asset:it(N(1/0))}),Di=new Uint8Array,Lr=Uint8Array.from([0]),Dr=e=>({value:e,additionalSigned:Di}),Vr=e=>({value:Di,additionalSigned:e}),jr=(e,t)=>({value:e,additionalSigned:t}),Vi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Vf(t,n),d=f=>{const[p,v]=r[f],b=c[f];try{return wt({value:p,additionalSigned:v},(m,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:m(x)})}catch{return a.push(f),null}},h=wt(r,([f,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Dr(f(i));case"CheckMortality":return s.mortal?jr(zf({period:s.period,phase:s.startAtBlock.height%s.period}),fe(s.startAtBlock.hash)):jr(Lr,e);case"ChargeTransactionPayment":return Dr(f(o));case"ChargeAssetTxPayment":return Dr(Hf({tip:o,asset:u.asset}));case"CheckGenesis":return Vr(e);case"CheckMetadataHash":return jr(Lr,Lr);case"CheckSpecVersion":return Vr(p(l.spec_version));case"CheckTxVersion":return Vr(p(l.transaction_version));default:return d(v)}});return a.forEach(f=>{delete h[f]}),wt(h,(f,p)=>({...f,identifier:p}))}},ji="AccountNonceApi_account_nonce",Ff={1:j.dec,2:Je.dec,4:Be.dec,8:Mt.dec},qf=(e,t,n)=>e(n,ji,t).pipe(I(r=>{const s=fe(r),o=Ff[s.length];if(!o)throw new Error(`${ji} retrieved wrong data`);return o(s)})),Wf=(e,t,n,r,s,o={})=>Bt([o.nonce?ze(o.nonce):Kf(e,te(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(J(1),R(([i,c,u])=>{const a=Vi(fe(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),Kf=(e,t)=>{const n=o=>e.newBlocks$.pipe(Nt((i,c)=>c.parent===i?c.hash:i,o),pi(o),le()),r=o=>n(o).pipe(J(2),Ln(i=>qf(e.call$,t,i))),s=o=>Bt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>ze({success:!1,value:c}))))).pipe(J(1));return e.pinnedBlocks$.pipe(Ie(o=>!o.recovering&&o.blocks.size>0),J(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),Ln(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var Xf=Object.defineProperty,Yf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gf=(e,t,n)=>Yf(e,t+"",n);const Nf=e=>te(Wt(fe(e))),Qf=(e,t)=>new C(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const f=s.blocks.get(u);if(!f)break;a=r.get(u=f.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,h=a.found.type;if(h&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:h,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:h,validity:a.found.validity}),d&&(h?n.complete():a.found.validity?.success===!1&&n.error(new zr(a.found.validity.value)))},c=t.pipe(le((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(le((n,r)=>n===r)),Zf=(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 zr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),Gf(this,"error"),this.name="InvalidTxError",this.error=t}}const Hr=(e,t,n,r,s=!1)=>{const o=Nf(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(J(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(R(l=>e.validateTx$(l,n).pipe(Ie(d=>!d.success),I(d=>{throw new zr(d.value)})))),u=new C(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(h){l.error(h)}})),d}),a=Qf(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...Zf(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Ar(s?ze(i("signed",{})):yt,c,ze(i("broadcasted",{})),a.pipe(Bf(({found:l,type:d,...h})=>l?ze(i("finalized",h)):yt)))},zi=async(e,t,n,r)=>dl(Hr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Jf=pt().enc,eh=new Uint8Array(64),th=new Uint8Array(65),nh=e=>()=>e?th:eh,[,rh]=be({weight:be({ref_time:vn,proof_size:vn}),class:he({Normal:B,Operational:B,Mandatory:B}),partial_fee:Jr}),Hi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(y,w,A={})=>{const _=Cr(y).runtime(),{dynamicBuilder:T,assetId:P,lookup:K}=_;let G;try{G=T.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(y,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let X=A;if(A.asset){if(P==null||!hr(A.asset,yn(K(P)),Pt=>u(_,Pt)))throw new Error("Incompatible runtime asset");X={...A,asset:T.buildDefinition(P).enc(A.asset)}}const{location:ne,codec:Ne}=G;return{callData:Le.fromBytes(ue(new Uint8Array(ne),Ne.enc(w))),options:X}},h=(y,w={})=>i(n,null).pipe(I(([A])=>d(A,y,w))),f=y=>y?d(y,l).callData:Pe(h(l).pipe(I(w=>w.callData))),p=(y,{...w},A)=>h(l,w).pipe(R(({callData:_,options:T})=>Wf(n,y,_.asBytes(),A,w.customSignedExtensions||{},T))),v=(y,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(I(_=>_.find(T=>T.hash===w)))).pipe(J(1),R(_=>_?p(y,A,_).pipe(I(T=>({tx:te(T),block:_}))):Tn(()=>new Error(`Uknown block ${w}`)))),b=(y,w)=>Pe(v(y,w)).then(A=>A.tx),m=(y,w)=>Pe(v(y,w)).then(({tx:A,block:_})=>zi(n,r,A,_.hash)),g=(y,w)=>v(y,w).pipe(R(({tx:A,block:_})=>Hr(n,r,A,_.hash,!0))),x=async(y,w)=>{typeof y=="string"&&(y=y.startsWith("0x")?fe(y):Jf(y));const A=y.length===20,_=Df(y,A?"Ecdsa":"Sr25519",nh(A)),T=fe(await b(_,w)),P=te(ue(T,Be.enc(T.length))),K=n.getRuntimeContext$(null).pipe(I(X=>{try{return X.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return rh}})),G=n.call$(null,"TransactionPaymentApi_query_info",P);return Pe(Bt([G,K]).pipe(I(([X,ne])=>ne(X))))};return{getPaymentInfo:x,getEstimatedFees:async(y,w)=>(await x(y,w)).partial_fee,decodedCall:{type:e,value:bt(t,l)},getEncodedData:f,sign:b,signSubmitAndWatch:g,signAndSubmit:m}},{getCompatibilityLevel:o,isCompatible:s});var sh=Object.defineProperty,oh=(e,t,n)=>t in e?sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(oh(e,typeof t!="symbol"?t+"":t,n),n),Fr=Symbol("SUSPENSE"),ih=class extends Promise{constructor(e){super(e)}},Fi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},qi=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ge={},Fn=class extends C{constructor(e,t,n=$e){super(r=>{const s=new Yt({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=ge,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Fi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==ge&&r.next(this.currentValue)):(this.subject=new Te,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Yt({next:i=>{this.promise&&i!==Fr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=ge;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Fr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new qi),this.promise=null),this.currentValue!==ge)return this.subject.complete();if(t===ge){const i=this.subject;return this.subject=null,i.error(new qi)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ge&&this.currentValue===ge&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",ge),He(this,"promise",null),He(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Fn?s:new Fn(s,ge)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ge&&this.currentValue!==Fr)return this.currentValue;if(this.defaultValue!==ge)return this.defaultValue;if(this.refCount===0)throw new Fi;const r=new ih((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===ge&&delete this.getDefaultValue}};function Wi(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function ch(e,t){const n=new ah,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Fn(e(...o),r(...o),()=>{n.delete(i)}),a=new C(d=>{const h=n.get(i);let f=u;return h?h!==a&&(f=h,Wi(f,a)):n.set(i,l),f.subscribe(d)});Wi(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var ah=class{constructor(){He(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 uh(e,t){return new Fn(e,t)}var qr=(...e)=>(typeof e[0]=="function"?ch:uh)(e[0],e.length>1?e[1]:ge);const Ki=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},Xi=(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}},Yi=(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)},lh=(e,t,n)=>{const r=qr((c,u,a)=>{const l=Yi(c,u),d=(b,m)=>{const g=wf(e,m.hash).pipe(Ie(x=>!x),J(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(R(x=>x===b?.rootHash?ze({...b,block:m,deltas:null,prev:b.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),I(([y,w])=>[y,l(w)]),I(([y,w])=>({prev:b&&b.block.hash,rootHash:x,block:m,...Ki(b?.entries??[],y,w)})))),vi(g),lt(x=>x instanceof Ot?yt:Tn(()=>x)))},h=e.pipe(le((b,m)=>b.finalized===m.finalized),Rr(({blocks:b,finalized:m})=>d(null,b.get(m))),J(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[f,p]=Of(),v=e.pipe(le((b,m)=>b.best===m.best),_r(f),Rr(([b,m])=>{const{best:g}=b,{blocks:x}=m;let y=x[g]?null:g;if(!y)return yt;const w=Xi(y,x,b);return w?d(w,b.blocks.get(y)).pipe(I(A=>(x[y]=A,m))):(y=b.finalized,d(x[m.finalized],b.blocks.get(y)).pipe(I(A=>(A.prev=null,{blocks:{[y]:A},finalized:y}))))}));return Sr(h,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),h=Yi(u,a),f=c?"finalized":"best";return Bt([d.pipe(Ul(0)),e.pipe(le((p,v)=>p[f]===v[f]))]).pipe(I(([p,v])=>Xi(v[f],p.blocks,v,!0)),Ie(Boolean),le(),pi(null),Vl(),_r(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],m])=>[p,v,b,h(m)]),R(([p,v,b,m])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:y}=b;Object.keys(y).forEach(w=>{y[w].block.number<x[0].block.number&&delete y[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Ki(p.entries,v.entries,m)}]}))},o=qr(s(!0)),i=qr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(J(1),R(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),I(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(J(1),R(h=>d(c,u,h)),I(({block:{hash:h,number:f,parent:p},deltas:v,entries:b},m)=>{const g=m>0?v:{deleted:[],upserted:b};return{block:{hash:h,number:f,parent:p},entries:b.map(Wr),deltas:g&&{deleted:g.deleted.map(Wr),upserted:g.upserted.map(Wr)}}}))}},Wr=e=>e.dec,Gi=(e,t,n)=>{const r={},s=v=>new Proxy(r,{get(b,m){return v(m)}}),o=v=>{const b={};return s(m=>(b[m]||(b[m]={}),s(g=>(b[m][g]||(b[m][g]=v(m,g)),b[m][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(m=>m.name===b),c=lh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((v,b)=>Tf(v,b,t,c,Tt(e,m=>m.getPalletEntryPoint($t.Storage,v,b),m=>{const g=i(m,v)?.storage?.items.find(x=>x.name===b);return g==null?null:vu(g)}))),a=(v,b,m,g)=>{if(m==null)return null;const x=v.lookup(m);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const y=mu(x.value[g]);return{args:b==="args"?y:wn,values:b==="args"?wn:y}},l=o((v,b)=>Hi(v,b,t,n,Tt(e,m=>m.getPalletEntryPoint($t.Tx,v,b),m=>a(m,"args",i(m,v)?.calls,b)),!0)),d=o((v,b)=>Cf(v,b,t,Tt(e,m=>m.getPalletEntryPoint($t.Event,v,b),m=>a(m,"values",i(m,v)?.events,b)))),h=o((v,b)=>If(v,b,Tt(e,m=>m.getPalletEntryPoint($t.Const,v,b),m=>{const g=i(m,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:yu(g)}))),f=o((v,b)=>$f(v,b,t,Tt(e,m=>m.getApiEntryPoint(v,b),m=>bu(m.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:m,dynamicBuilder:g}=Cr(b).runtime();try{const x=g.buildDefinition(m.call).dec(v.asBytes()),y=x.type,w=x.value.type,A=x.value.value;return Hi(y,w,t,n,Tt(e,_=>_.getPalletEntryPoint($t.Tx,y,w),_=>a(_,"args",i(_,y)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,b)=>b?p(v,b):e.then(m=>p(v,m)),tx:l,event:d,apis:f,constants:h}};function fh(e){const t=Ru(e),n=gf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Rn(r).pipe(I(({genesisHash:f})=>f),lt(()=>s),Mn(1))},c=t.request;let u;const a=new WeakMap,l=f=>{const p=a.get(f)||Af(f,i);return a.set(f,p),p},d=()=>u??(u=Sf(i)),{broadcastTx$:h}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Pe(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Pe(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:f=>Pe(i.body$(f)),getBlockHeader:f=>Pe(i.header$(f??null)),submit:(...f)=>zi(i,h,...f),submitAndWatch:(...f)=>Hr(i,h,...f),getTypedApi:f=>{const p=l(f);return Object.assign(Gi(p,i,h),{compatibilityToken:p})},getUnsafeApi:()=>{const f=d();return Object.assign(Gi(f,i,h),{runtimeToken:f})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const hh=(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:c}=o,u=new Uint8Array(i);return a=>{const l=Le.fromBytes(ue(u,c.enc(a)));return{encodedData:l,decodedCall:bt(e,bt(t,a)),sign:async(d,h)=>te(await d.signTx(l.asBytes(),s(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},dh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=fe(e),r=await t(),s=ct.dec(r).metadata.value,o=Vn(s),i=Br(o),c=Vi(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(m=>(v[b][m]||(v[b][m]=p(b,m)),v[b][m]))))},h=d((p,v)=>{const b=u(p)?.constants.find(m=>m.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),f=d((p,v)=>hh(p,v,r,i,c));return{constants:h,tx:f}},tn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ph=async e=>{const t=cr(await e.getMetadata()).metadata.value,n={},r=d=>new Proxy(n,{get(h,f){return d(f)}}),s=d=>{const h={};return r(f=>(h[f]||(h[f]={}),r(p=>(h[f][p]||(h[f][p]=d(f,p)),h[f][p]))))},o=Vn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Br(o);return{query:s((...d)=>{const{value:h,args:f}=tn(c,"Storage")(...d);return{value:h,args:f}}),tx:s((...d)=>tn(a,"Call")(...d).codec),event:s((...d)=>tn(l,"Event")(...d).codec),apis:s(tn(i,"Runtime API")),constants:s(tn(u,"Constant"))}};ie.AccountId=pt,ie.Binary=Le,ie.CompatibilityLevel=Ae,ie.Enum=bt,ie.FixedSizeBinary=pn,ie.InvalidTxError=zr,ie._Enum=Ws,ie.createClient=fh,ie.getOfflineApi=dh,ie.getSs58AddressInfo=Zn,ie.getTypedCodecs=ph});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -192,24 +192,24 @@
192
192
  },
193
193
  "dependencies": {
194
194
  "@rx-state/core": "^0.1.4",
195
- "@polkadot-api/cli": "0.11.12",
195
+ "@polkadot-api/cli": "0.11.13",
196
196
  "@polkadot-api/ink-contracts": "0.3.0",
197
197
  "@polkadot-api/json-rpc-provider": "0.0.4",
198
+ "@polkadot-api/known-chains": "0.7.4",
198
199
  "@polkadot-api/logs-provider": "0.0.6",
199
200
  "@polkadot-api/metadata-builders": "0.11.0",
200
- "@polkadot-api/known-chains": "0.7.4",
201
+ "@polkadot-api/observable-client": "0.9.1",
201
202
  "@polkadot-api/metadata-compatibility": "0.2.1",
202
- "@polkadot-api/observable-client": "0.9.0",
203
- "@polkadot-api/polkadot-sdk-compat": "2.3.2",
204
203
  "@polkadot-api/pjs-signer": "0.6.6",
204
+ "@polkadot-api/polkadot-sdk-compat": "2.3.2",
205
205
  "@polkadot-api/polkadot-signer": "0.1.6",
206
- "@polkadot-api/smoldot": "0.3.8",
207
- "@polkadot-api/sm-provider": "0.1.7",
208
206
  "@polkadot-api/signer": "0.1.16",
209
- "@polkadot-api/substrate-client": "0.3.0",
207
+ "@polkadot-api/sm-provider": "0.1.7",
210
208
  "@polkadot-api/substrate-bindings": "0.12.0",
211
- "@polkadot-api/ws-provider": "0.4.0",
212
- "@polkadot-api/utils": "0.1.2"
209
+ "@polkadot-api/substrate-client": "0.3.0",
210
+ "@polkadot-api/smoldot": "0.3.8",
211
+ "@polkadot-api/utils": "0.1.2",
212
+ "@polkadot-api/ws-provider": "0.4.0"
213
213
  },
214
214
  "devDependencies": {
215
215
  "rxjs": "^7.8.2",