polkadot-api 1.16.2 → 1.16.3
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 +1 -1
- package/dist/umd/index.min.js +2 -2
- package/package.json +6 -6
package/bin/cli.mjs
CHANGED
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(le,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(le=typeof globalThis<"u"?globalThis:le||self,Gt(le.papi={}))})(this,(function(le){"use strict";var Gt=Object.defineProperty,Pc=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vs=(e,t,n)=>(Pc(e,typeof t!="symbol"?t+"":t,n),n),ar={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 Uc(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|ar[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=ar[e[i]],l=ar[e[i+1]];s[t+o++]=c<<4|l}return s}var ms=class extends Uint8Array{constructor(e){super(e),vs(this,"i",0),vs(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ms?t:new ms(t instanceof Uint8Array?t.buffer:typeof t=="string"?Uc(t).buffer:t)),qe=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 bn(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 tt=_e,z=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gn=(e,t)=>n=>e(t(n)),wn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>z(gn(e,n),wn(t,r));function Mc(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Lc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ct(e,t,n){return z(Lc(e,n),Mc(e,t))}var D=ct(1,"getUint8","setUint8"),Xe=ct(2,"getUint16","setUint16"),Ve=ct(4,"getUint32","setUint32"),Nt=ct(8,"getBigUint64","setBigUint64"),Dc=ct(1,"getInt8","setInt8"),Vc=ct(2,"getInt16","setInt16"),Hc=ct(4,"getInt32","setInt32"),Fc=ct(8,"getBigInt64","setBigInt64"),ys=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},bs=e=>_e(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}),gs=z(ys,bs("getBigUint64")),jc=z(ys,bs("getBigInt64")),ws=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},xs=e=>_e(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}),zc=z(ws,xs("getBigUint64")),Wc=z(ws,xs("getBigInt64")),qc=Ke(D,e=>e?1:0,Boolean),Kc=[D[1],Xe[1],Ve[1]],Xc=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return Kc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let l=0;l<o;l++)s=Nt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(Ve[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Xe[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(D[1](e))<<i|s),s}),Yc=1n<<56n,Gc=1<<24,Nc=256,Qc=4294967295n,Zc=64,Jc=16384,ea=1<<30,ta=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Zc)return D[0](t);if(e<Jc)return Xe[0](t|1);if(e<ea)return Ve[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Yc;)n.push(Nt[0](r)),r>>=64n;r>=Gc&&(n.push(Ve[0](Number(r&Qc))),r>>=32n);let s=Number(r);s>=Nc&&(n.push(Xe[0](s)),s>>=16),s&&n.push(D[0](s));const o=qe(n);return o[0]=o.length-5<<2|3,o},pe=z(ta,Xc),na=new TextEncoder,ra=e=>{const t=na.encode(e);return qe([pe.enc(t.length),t])},sa=new TextDecoder,oa=_e(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,sa.decode(n)}),F=z(ra,oa),ia=()=>{},ca=new Uint8Array(0),O=z(()=>ca,ia),Es=e=>e===void 0?t=>qe([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ks=e=>_e(t=>{const n=e===void 0?pe.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),G=e=>z(Es(e),ks(e));G.enc=Es,G.dec=ks;var As=(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})=>qe([D.enc(s(o)),e[o](i)])},Ss=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=D.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},we=(e,...t)=>z(As(bn(e,([n])=>n),...t),Ss(bn(e,([,n])=>n),...t));we.enc=As,we.dec=Ss;var Bs=e=>_e(t=>D[1](t)>0?e(t):void 0),Is=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,qe([n,e(t)]))},xe=e=>z(Is(e[0]),Bs(e[1]));xe.enc=Is,xe.dec=Bs;var $s=(e,t)=>_e(n=>{const r=D[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Cs=(e,t)=>({success:n,value:r})=>qe([D[0](n?0:1),(n?e:t)(r)]),Qt=(e,t)=>z(Cs(e[0],t[0]),$s(e[1],t[1]));Qt.dec=$s,Qt.enc=Cs;var _s=(...e)=>_e(t=>e.map(n=>n(t))),Os=(...e)=>t=>qe(e.map((n,r)=>n(t[r]))),Oe=(...e)=>z(Os(...e.map(([t])=>t)),_s(...e.map(([,t])=>t)));Oe.enc=Os,Oe.dec=_s;var Ts=e=>{const t=Object.keys(e);return gn(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Rs=e=>{const t=Object.keys(e);return wn(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},R=e=>z(Ts(bn(e,t=>t[0])),Rs(bn(e,t=>t[1])));R.enc=Ts,R.dec=Rs;var Ps=(e,t)=>t>=0?n=>qe(n.map(e)):n=>qe([pe.enc(n.length),qe(n.map(e))]),Us=(e,t)=>_e(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),L=(e,t)=>z(Ps(e[0],t),Us(e[1],t));L.enc=Ps,L.dec=Us;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function aa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ms(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 lr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ls(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ur(e){if(!Array.isArray(e))throw new Error("array expected")}function Ds(e,t){if(!Ms(!0,t))throw new Error(`${e}: array of strings expected`)}function la(e,t){if(!Ms(!1,t))throw new Error(`${e}: array of numbers expected`)}function ua(...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 fa(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ds("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ur(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=>(ur(s),s.map(o=>{lr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ha(e=""){return lr("join",e),{encode:t=>(Ds("join.decode",t),t.join(e)),decode:t=>(lr("join.decode",t),t.split(e))}}function Vs(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(ur(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Ls(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,l=!0;for(let a=r;a<i;a++){const f=o[a],p=t*c,u=p+f;if(!Number.isSafeInteger(u)||p/t!==c||u-f!==p)throw new Error("convertRadix: carry overflow");const h=u/n;c=u%n;const d=Math.floor(h);if(o[a]=d,!Number.isSafeInteger(d)||d*n+c!==u)throw new Error("convertRadix: carry overflow");if(l)d?l=!1:r=a;else continue}if(s.push(c),l)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function da(e){Ls(e);const t=2**8;return{encode:n=>{if(!aa(n))throw new Error("radix.encode input should be Uint8Array");return Vs(Array.from(n),t,e)},decode:n=>(la("radix.decode",n),Uint8Array.from(Vs(n,e,t)))}}const Hs=(e=>ua(da(58),fa(e),ha("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ut(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Et(e,...t){if(!pa(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 Zt(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 fr(e,t){Et(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function va(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function kt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function at(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e,t){return e<<32-t|e>>>t}const Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function js(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const nt=Fs?e=>e:e=>js(e);function ma(e){for(let t=0;t<e.length;t++)e[t]=js(e[t]);return e}const ve=Fs?e=>e:ma;function ya(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ye(e){return typeof e=="string"&&(e=ya(e)),Et(e),e}class zs{}function ba(e){const t=r=>e().update(Ye(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ga(e){const t=(r,s)=>e(s).update(Ye(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function wa(e){const t=(r,s)=>e(s).update(Ye(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const xa=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 lt(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,16),n=n+r|0,t=xn(t^n,12),{a:e,b:t,c:n,d:r}}function ut(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,8),n=n+r|0,t=xn(t^n,7),{a:e,b:t,c:n,d:r}}const Ea=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),En=BigInt(2**32-1),Ws=BigInt(32);function kn(e,t=!1){return t?{h:Number(e&En),l:Number(e>>Ws&En)}:{h:Number(e>>Ws&En)|0,l:Number(e&En)|0}}function ka(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}=kn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const qs=(e,t,n)=>e>>>n|t<<32-n,Ks=(e,t,n)=>e<<32-n|t>>>n,Aa=(e,t,n)=>e<<64-n|t>>>n-32,Sa=(e,t,n)=>e>>>n-32|t<<64-n,Ba=(e,t)=>t,Ia=(e,t)=>e,$a=(e,t,n)=>e<<n|t>>>32-n,Ca=(e,t,n)=>t<<n|e>>>32-n,_a=(e,t,n)=>t<<n-32|e>>>64-n,Oa=(e,t,n)=>e<<n-32|t>>>64-n;function Xs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ys=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Gs=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,ee=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function ft(e,t,n,r,s,o){const i=s[o],c=s[o+1];let l=S[2*e],a=S[2*e+1],f=S[2*t],p=S[2*t+1],u=S[2*n],h=S[2*n+1],d=S[2*r],v=S[2*r+1],m=Ys(l,f,i);a=Gs(m,a,p,c),l=m|0,{Dh:v,Dl:d}={Dh:v^a,Dl:d^l},{Dh:v,Dl:d}={Dh:Ba(v,d),Dl:Ia(v)},{h,l:u}=Xs(h,u,v,d),{Bh:p,Bl:f}={Bh:p^h,Bl:f^u},{Bh:p,Bl:f}={Bh:qs(p,f,24),Bl:Ks(p,f,24)},S[2*e]=l,S[2*e+1]=a,S[2*t]=f,S[2*t+1]=p,S[2*n]=u,S[2*n+1]=h,S[2*r]=d,S[2*r+1]=v}function ht(e,t,n,r,s,o){const i=s[o],c=s[o+1];let l=S[2*e],a=S[2*e+1],f=S[2*t],p=S[2*t+1],u=S[2*n],h=S[2*n+1],d=S[2*r],v=S[2*r+1],m=Ys(l,f,i);a=Gs(m,a,p,c),l=m|0,{Dh:v,Dl:d}={Dh:v^a,Dl:d^l},{Dh:v,Dl:d}={Dh:qs(v,d,16),Dl:Ks(v,d,16)},{h,l:u}=Xs(h,u,v,d),{Bh:p,Bl:f}={Bh:p^h,Bl:f^u},{Bh:p,Bl:f}={Bh:Aa(p,f,63),Bl:Sa(p,f,63)},S[2*e]=l,S[2*e+1]=a,S[2*t]=f,S[2*t+1]=p,S[2*n]=u,S[2*n+1]=h,S[2*r]=d,S[2*r+1]=v}function Ta(e,t={},n,r,s){if(Ut(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 Ns extends zs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Ut(t),Ut(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=kt(this.buffer)}update(t){Zt(this),t=Ye(t),Et(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let l=0;l<o;){this.pos===n&&(ve(s),this.compress(s,0,!1),ve(s),this.pos=0);const a=Math.min(n-this.pos,o-l),f=i+l;if(a===n&&!(f%4)&&l+a<o){const p=new Uint32Array(c,f,Math.floor((o-l)/4));ve(p);for(let u=0;l+n<o;u+=s.length,l+=n)this.length+=n,this.compress(p,u,!1);ve(p);continue}r.set(t.subarray(l,l+a),this.pos),this.pos+=a,this.length+=a,l+=a}return this}digestInto(t){Zt(this),fr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,at(this.buffer.subarray(n)),ve(r),this.compress(r,0,!0),ve(r);const s=kt(t);this.get().forEach((o,i)=>s[i]=nt(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 Ra extends Ns{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=ee[0]|0,this.v0h=ee[1]|0,this.v1l=ee[2]|0,this.v1h=ee[3]|0,this.v2l=ee[4]|0,this.v2h=ee[5]|0,this.v3l=ee[6]|0,this.v3h=ee[7]|0,this.v4l=ee[8]|0,this.v4h=ee[9]|0,this.v5l=ee[10]|0,this.v5h=ee[11]|0,this.v6l=ee[12]|0,this.v6h=ee[13]|0,this.v7l=ee[14]|0,this.v7h=ee[15]|0,Ta(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Ye(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Ye(o);const c=kt(o);this.v4l^=nt(c[0]),this.v4h^=nt(c[1]),this.v5l^=nt(c[2]),this.v5h^=nt(c[3])}if(s!==void 0){s=Ye(s);const c=kt(s);this.v6l^=nt(c[0]),this.v6h^=nt(c[1]),this.v7l^=nt(c[2]),this.v7h^=nt(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:l,v4l:a,v4h:f,v5l:p,v5h:u,v6l:h,v6h:d,v7l:v,v7h:m}=this;return[t,n,r,s,o,i,c,l,a,f,p,u,h,d,v,m]}set(t,n,r,s,o,i,c,l,a,f,p,u,h,d,v,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=l|0,this.v4l=a|0,this.v4h=f|0,this.v5l=p|0,this.v5h=u|0,this.v6l=h|0,this.v6h=d|0,this.v7l=v|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((l,a)=>S[a]=l),S.set(ee,16);let{h:s,l:o}=kn(BigInt(this.length));S[24]=ee[8]^o,S[25]=ee[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const c=xa;for(let l=0;l<12;l++)ft(0,4,8,12,t,n+2*c[i++]),ht(0,4,8,12,t,n+2*c[i++]),ft(1,5,9,13,t,n+2*c[i++]),ht(1,5,9,13,t,n+2*c[i++]),ft(2,6,10,14,t,n+2*c[i++]),ht(2,6,10,14,t,n+2*c[i++]),ft(3,7,11,15,t,n+2*c[i++]),ht(3,7,11,15,t,n+2*c[i++]),ft(0,5,10,15,t,n+2*c[i++]),ht(0,5,10,15,t,n+2*c[i++]),ft(1,6,11,12,t,n+2*c[i++]),ht(1,6,11,12,t,n+2*c[i++]),ft(2,7,8,13,t,n+2*c[i++]),ht(2,7,8,13,t,n+2*c[i++]),ft(3,4,9,14,t,n+2*c[i++]),ht(3,4,9,14,t,n+2*c[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],at(S)}destroy(){this.destroyed=!0,at(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Pa=ga(e=>new Ra(e));function Qs(e,t,n,r,s,o,i,c,l,a,f,p,u,h,d,v,m,y,b,x){let g=0;for(let w=0;w<r;w++)({a:s,b:l,c:u,d:m}=lt(s,l,u,m,n[t+e[g++]])),{a:s,b:l,c:u,d:m}=ut(s,l,u,m,n[t+e[g++]]),{a:o,b:a,c:h,d:y}=lt(o,a,h,y,n[t+e[g++]]),{a:o,b:a,c:h,d:y}=ut(o,a,h,y,n[t+e[g++]]),{a:i,b:f,c:d,d:b}=lt(i,f,d,b,n[t+e[g++]]),{a:i,b:f,c:d,d:b}=ut(i,f,d,b,n[t+e[g++]]),{a:c,b:p,c:v,d:x}=lt(c,p,v,x,n[t+e[g++]]),{a:c,b:p,c:v,d:x}=ut(c,p,v,x,n[t+e[g++]]),{a:s,b:a,c:d,d:x}=lt(s,a,d,x,n[t+e[g++]]),{a:s,b:a,c:d,d:x}=ut(s,a,d,x,n[t+e[g++]]),{a:o,b:f,c:v,d:m}=lt(o,f,v,m,n[t+e[g++]]),{a:o,b:f,c:v,d:m}=ut(o,f,v,m,n[t+e[g++]]),{a:i,b:p,c:u,d:y}=lt(i,p,u,y,n[t+e[g++]]),{a:i,b:p,c:u,d:y}=ut(i,p,u,y,n[t+e[g++]]),{a:c,b:l,c:h,d:b}=lt(c,l,h,b,n[t+e[g++]]),{a:c,b:l,c:h,d:b}=ut(c,l,h,b,n[t+e[g++]]);return{v0:s,v1:o,v2:i,v3:c,v4:l,v5:a,v6:f,v7:p,v8:u,v9:h,v10:d,v11:v,v12:m,v13:y,v14:b,v15:x}}const An=Pa,Zs=new TextEncoder().encode("SS58PRE"),hr=2,dr=e=>{try{const t=Hs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-hr),s=t.subarray(n.length+r.length),o=An(Uint8Array.of(...Zs,...n,...r),{dkLen:64}).subarray(0,hr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Ua(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ua=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Js=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=An(Uint8Array.of(...Zs,...t,...n),{dkLen:64}).subarray(0,hr);return Hs.encode(Uint8Array.of(...t,...n,...r))}};function Ma(e,t){return n=>{const r=dr(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 At=(e=42,t=32)=>Ke(G(t),Ma(t),Js(e)),eo="0123456789abcdef";function J(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=eo[r>>4]+eo[r&15]}return t.join("")}const pr={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 me(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|pr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=pr[e[i]],l=pr[e[i+1]];s[t+o++]=c<<4|l}return s}function Mt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const oe=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},St=Function.prototype;class to extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var La=Object.defineProperty,no=e=>{throw TypeError(e)},Da=(e,t,n)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jt=(e,t,n)=>Da(e,typeof t!="symbol"?t+"":t,n),ro=(e,t,n)=>t.has(e)||no("Cannot "+n),rt=(e,t,n)=>(ro(e,t,"read from private field"),n?n.call(e):t.get(e)),en=(e,t,n)=>t.has(e)?no("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bt=(e,t,n,r)=>(ro(e,t,"write to private field"),t.set(e,n),n),st,tn,Sn,Bn,In;const Va=new TextEncoder,Ha=new TextDecoder,Fa=Oe(pe,G(1/0))[1];class He{constructor(t,n=!1){if(en(this,st),en(this,tn,null),en(this,Sn,null),en(this,Bn,null),en(this,In,null),Jt(this,"asText",()=>rt(this,In)??Bt(this,In,Ha.decode(rt(this,st)))),Jt(this,"asHex",()=>rt(this,Sn)||Bt(this,Sn,J(rt(this,st)))),Jt(this,"asOpaqueHex",()=>rt(this,Bn)||Bt(this,Bn,J(this.asBytes()))),Jt(this,"asBytes",()=>rt(this,st)),Jt(this,"asOpaqueBytes",()=>rt(this,tn)||Bt(this,tn,oe([rt(this,st),pe[0](rt(this,st).length)]))),n){try{const[r,s]=Fa(t);if(r===s.length){Bt(this,st,s),Bt(this,tn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else Bt(this,st,t)}static fromText(t){return new this(Va.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}st=new WeakMap,tn=new WeakMap,Sn=new WeakMap,Bn=new WeakMap,In=new WeakMap;const[ja]=At();class $n extends He{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ja(t))}}const so=e=>{const t=G.enc(e);return n=>t(n.asBytes())},oo=e=>{const t=G.dec(e),n=e==null?He:$n;return r=>n.fromBytes(t(r))},nn=e=>z(so(e),oo(e));nn.enc=so,nn.dec=oo;const C=Ke(pe,e=>e,Number),Cn=Ke(pe,e=>e,BigInt),za=tt(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Wa=z(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},za),qa=Ke(D,e=>e.charCodeAt(0),String.fromCharCode),io=e=>{const t=G.enc(e);return n=>t(me(n))},co=e=>{const t=G.dec(e);return n=>J(t(n))},ye=e=>z(io(e),co(e));ye.enc=io,ye.dec=co;const Ka=new TextEncoder,Xa=new TextDecoder,Ya=e=>Ke(G(e),t=>Ka.encode(t),t=>Xa.decode(t)),ao=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},lo=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},vr=e=>z(ao(()=>e().enc),lo(()=>e().dec)),It=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}}),uo=new Proxy({},{get(e,t){return n=>It(t,n)}}),N=(e,t)=>{const n=e;return n.inner=t,n},fo=(...e)=>{const t=we.enc(...e);return N(n=>t({tag:n.type,value:n.value}),e[0])},ho=(...e)=>{const t=we.dec(...e);return N(n=>{const{tag:r,value:s}=t(n);return It(r,s)},e[0])},Ee=(e,...t)=>N(z(fo(Mt(e,([n])=>n),...t),ho(Mt(e,([,n])=>n),...t)),e);Ee.enc=fo,Ee.dec=ho;const mr=(e,...t)=>N(we(e,...t),e);mr.enc=(e,...t)=>N(we.enc(e,...t),e),mr.dec=(e,...t)=>N(we.dec(e,...t),e);const Ga=BigInt(0),rn=BigInt(1),Na=BigInt(2),Qa=BigInt(7),Za=BigInt(256),Ja=BigInt(113),po=[],vo=[],mo=[];for(let e=0,t=rn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],po.push(2*(5*r+n)),vo.push((e+1)*(e+2)/2%64);let s=Ga;for(let o=0;o<7;o++)t=(t<<rn^(t>>Qa)*Ja)%Za,t&Na&&(s^=rn<<(rn<<BigInt(o))-rn);mo.push(s)}const yo=ka(mo,!0),el=yo[0],tl=yo[1],bo=(e,t,n)=>n>32?_a(e,t,n):$a(e,t,n),go=(e,t,n)=>n>32?Oa(e,t,n):Ca(e,t,n);function nl(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,l=(i+2)%10,a=n[l],f=n[l+1],p=bo(a,f,1)^n[c],u=go(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=u}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=vo[i],l=bo(s,o,c),a=go(s,o,c),f=po[i];s=e[f],o=e[f+1],e[f]=l,e[f+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]^=el[r],e[1]^=tl[r]}at(n)}class yr extends zs{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,Ut(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=kt(this.state)}clone(){return this._cloneInto()}keccak(){ve(this.state32),nl(this.state32,this.rounds),ve(this.state32),this.posOut=0,this.pos=0}update(t){Zt(this),t=Ye(t),Et(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){Zt(this,!1),Et(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 Ut(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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,at(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new yr(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 rl=(e,t,n)=>ba(()=>new yr(t,e,n)),sl=rl(1,136,256/8),wo=e=>{const t=e.slice(2),n=J(sl(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("")}`},ol=G(20)[1],xo=z(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=J(t);if(e===n||e===n.toUpperCase())return t;if(wo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},tt(e=>wo(J(ol(e))))),ie=e=>N(R(e),e);ie.enc=e=>N(R.enc(e),e),ie.dec=e=>N(R.dec(e),e);const Fe=(...e)=>N(Oe(...e),e);Fe.enc=(...e)=>N(Oe.enc(...e),e),Fe.dec=(...e)=>N(Oe.dec(...e),e);const Be=(e,...t)=>N(L(e,...t),e);Be.enc=(e,...t)=>N(L.enc(e,...t),e),Be.dec=(e,...t)=>N(L.dec(e,...t),e);const _n=(e,t)=>N(Qt(e,t),{ok:e,ko:t});_n.enc=(e,t)=>N(Qt.enc(e,t),{ok:e,ko:t}),_n.dec=(e,t)=>N(Qt.dec(e,t),{ok:e,ko:t});const dt=e=>N(xe(e),e);dt.enc=e=>N(xe.enc(e),e),dt.dec=e=>N(xe.dec(e),e);const Eo=(e=!0)=>tt(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let l=0;l<8&&i<n;l++){const a=e?l:7-l;o[i++]=c>>a&1}}),o}),ko=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let l=0;l<8&&i<t.length;l++,i++)c|=t[i]<<(e?l:7-l);s[o]=c}return oe([n,s])},On=e=>z(ko(e),Eo(e));On.enc=ko,On.dec=Eo;const Ao=new TextEncoder,So=new TextDecoder,il=Ke(G(4),Ao.encode.bind(Ao),So.decode.bind(So)),br=ie({engine:il,payload:ye()}),cl=Ee({other:G(),consensus:br,seal:br,preRuntime:br,runtimeUpdated:O},[0,4,5,6,8]),gr=ye(32),wr=ie({parentHash:gr,number:C,stateRoot:gr,extrinsicRoot:gr,digests:Be(cl)}),Ie=L(F),Bo=xe(F),al=we({bool:O,char:O,str:O,u8:O,u16:O,u32:O,u64:O,u128:O,u256:O,i8:O,i16:O,i32:O,i64:O,i128:O,i256:O}),Io=L(R({name:Bo,type:C,typeName:Bo,docs:Ie})),ll=R({len:Ve,type:C}),ul=R({bitStoreType:C,bitOrderType:C}),fl=L(R({name:F,fields:Io,index:D,docs:Ie})),hl=we({composite:Io,variant:fl,sequence:C,array:ll,tuple:L(C),primitive:al,compact:C,bitSequence:ul}),dl=R({name:F,type:xe(C)}),pl=L(dl),vl=R({id:C,path:Ie,params:pl,def:hl,docs:Ie}),Tn=L(vl),Lt=we({NotDeprecated:O,DeprecatedWithoutNote:O,Deprecated:R({note:F,since:xe(F)})}),ml=L(R({index:D,deprecation:we({DeprecatedWithoutNote:O,Deprecated:R({note:F,since:xe(F)})},[1,2])})),xr={name:F,inputs:L(R({name:F,type:C})),output:C,docs:Ie},yl=R({name:F,methods:L(R(xr)),docs:Ie}),bl=R({name:F,methods:L(R({...xr,deprecationInfo:Lt})),docs:Ie,version:C,deprecationInfo:Lt}),gl=R({id:ye(32),...xr,deprecationInfo:Lt}),wl=we({Blake2128:O,Blake2256:O,Blake2128Concat:O,Twox128:O,Twox256:O,Twox64Concat:O,Identity:O}),xl=L(wl),El=R({hashers:xl,key:C,value:C}),$o={name:F,modifier:D,type:we({plain:C,map:El}),fallback:ye(),docs:Ie},Er=xe(C),Co={name:F,storage:xe(R({prefix:F,items:L(R($o))})),calls:Er,events:Er,constants:L(R({name:F,type:C,value:ye(),docs:Ie})),errors:Er,index:D},kl={...Co,docs:Ie},kr=xe(R({type:C,deprecationInfo:ml})),Al={name:F,storage:xe(R({prefix:F,items:L(R({...$o,deprecationInfo:Lt}))})),calls:kr,events:kr,constants:L(R({name:F,type:C,value:ye(),docs:Ie,deprecationInfo:Lt})),errors:kr,associatedTypes:L(R({name:F,type:C,docs:Ie})),viewFns:L(gl),index:D,docs:Ie,deprecationInfo:Lt},Sl=new Uint8Array,_o=e=>z(()=>Sl,()=>e),Bl=R({type:C,version:D,signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),Oo=R({lookup:Tn,pallets:L(R({...Co,docs:_o([])})),extrinsic:Bl,type:C,apis:_o([])}),Il=R({version:D,address:C,call:C,signature:C,extra:C,signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),To=R({lookup:Tn,pallets:L(R(kl)),extrinsic:Il,type:C,apis:L(yl),outerEnums:R({call:C,event:C,error:C}),custom:L(Oe(F,R({type:C,value:ye()})))}),$l=R({version:L(D),address:C,call:C,signature:C,signedExtensionsByVersion:L(Oe(D,L(C))),signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),Ro=R({lookup:Tn,pallets:L(R(Al)),extrinsic:$l,apis:L(bl),outerEnums:R({call:C,event:C,error:C}),custom:L(Oe(F,R({type:C,value:ye()})))}),Po=()=>{throw new Error("Unsupported metadata version!")},ke=z(Po,Po),pt=R({magicNumber:Ve,metadata:we({v0:ke,v1:ke,v2:ke,v3:ke,v4:ke,v5:ke,v6:ke,v7:ke,v8:ke,v9:ke,v10:ke,v11:ke,v12:ke,v13:ke,v14:Oo,v15:To,v16:Ro})}),Ar=G(),Cl=xe(Ar),_l=Oe(pe,Ar),Sr=e=>{try{return pt.dec(e)}catch{}try{return pt.dec(Cl.dec(e))}catch{}try{return pt.dec(Ar.dec(e))}catch{}try{return pt.dec(_l.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:l,outerEnums:a}=e;return{version:15,lookup:s,pallets:l.map(f=>({...f,calls:f.calls!=null?{type:f.calls}:void 0,events:f.events!=null?{type:f.events}:void 0,errors:f.errors!=null?{type:f.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},$t={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Br=Ke(D,({version:e,type:t})=>e+($t[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===$t.bare||n===$t.signed))return{version:t,type:$t[n]};if(t===5&&(n===$t.bare||n===$t.general))return{version:t,type:$t[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Ol={dkLen:32},Vt=e=>An(e,Ol),Tl={dkLen:16},Ir=e=>An(e,Tl),Uo=e=>oe([Ir(e),e]),Ge={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},ot=Ea.slice(),Mo=(()=>{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 $r extends Ns{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=Ye(r).slice();Et(i,32),this.IV=kt(i),ve(this.IV),this.flags=n|Ge.KEYED_HASH}else if(o){const i=Ye(s),c=new $r({dkLen:32},Ge.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=kt(c),ve(this.IV),this.flags=n|Ge.DERIVE_KEY_MATERIAL}else this.IV=ot.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=va(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l}=kn(BigInt(t),!0),{v0:a,v1:f,v2:p,v3:u,v4:h,v5:d,v6:v,v7:m,v8:y,v9:b,v10:x,v11:g,v12:w,v13:k,v14:$,v15:E}=Qs(Mo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ot[0],ot[1],ot[2],ot[3],c,l,i,n);o[0]=a^y,o[1]=f^b,o[2]=p^x,o[3]=u^g,o[4]=h^w,o[5]=d^k,o[6]=v^$,o[7]=m^E}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ge.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ge.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|Ge.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:l,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=l.map(f=>Uint32Array.from(f)),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,at(this.state,this.buffer32,this.IV,this.bufferOut32),at(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=kn(BigInt(this.chunkOut++));ve(s);const{v0:l,v1:a,v2:f,v3:p,v4:u,v5:h,v6:d,v7:v,v8:m,v9:y,v10:b,v11:x,v12:g,v13:w,v14:k,v15:$}=Qs(Mo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ot[0],ot[1],ot[2],ot[3],c,i,n,r);o[0]=l^m,o[1]=a^y,o[2]=f^b,o[3]=p^x,o[4]=u^g,o[5]=h^w,o[6]=d^k,o[7]=v^$,o[8]=t[0]^m,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^x,o[12]=t[4]^g,o[13]=t[5]^w,o[14]=t[6]^k,o[15]=t[7]^$,ve(s),ve(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,at(this.buffer.subarray(this.pos));let t=this.flags|Ge.ROOT;this.stack.length?(t|=Ge.PARENT,ve(this.buffer32),this.compress(this.buffer32,0,!0),ve(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ge.CHUNK_START)|Ge.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Zt(this,!1),Et(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 Ut(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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 Rl=wa(e=>new $r(e)),Pl={dkLen:32},Lo=e=>Rl(e,Pl),Ul=e=>oe([Lo(e),e]),Do=e=>e,Ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Cr=2n**64n-1n,ue=(e,t)=>e<<t&Cr|e>>64n-t,H=(e,t)=>e*t&Cr,ne=(e,t)=>e+t&Cr,re=11400714785074694791n,$e=14029467366897019727n,Vo=1609587929392839161n,sn=9650029242287828579n,Ho=2870177450012600261n;function vt(e,t=0n){let n=ne(ne(t,re),$e),r=ne(t,$e),s=t,o=t-re,i=e.length,c=0,l=null;(function(){let h=0,d=h+i;if(i){if(l=new Uint8Array(32),i<32){l.set(e.subarray(0,i),c),c+=i;return}if(h<=d-32){const v=d-32;do{let m;m=Ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=H(ue(ne(n,H(m,$e)),31n),re),h+=8,m=Ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=H(ue(ne(r,H(m,$e)),31n),re),h+=8,m=Ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=H(ue(ne(s,H(m,$e)),31n),re),h+=8,m=Ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),o=H(ue(ne(o,H(m,$e)),31n),re),h+=8}while(h<=v)}h<d&&(l.set(e.subarray(h,d),c),c=d-h)}})(),e=l||e;let a,f=0;for(i>=32?(a=ue(n,1n),a=ne(a,ue(r,7n)),a=ne(a,ue(s,12n)),a=ne(a,ue(o,18n)),n=H(ue(H(n,$e),31n),re),a=a^n,a=ne(H(a,re),sn),r=H(ue(H(r,$e),31n),re),a=a^r,a=ne(H(a,re),sn),s=H(ue(H(s,$e),31n),re),a=a^s,a=ne(H(a,re),sn),o=H(ue(H(o,$e),31n),re),a=a^o,a=ne(H(a,re),sn)):a=ne(t,Ho),a=ne(a,BigInt(i));f<=c-8;){let u=Ct(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]);u=H(ue(H(u,$e),31n),re),a=ne(H(ue(a^u,27n),re),sn),f+=8}if(f+4<=c){let u=H(Ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),re);a=ne(H(ue(a^u,23n),$e),Vo),f+=4}for(;f<c;){const u=H(Ct(e[f++],0,0,0),Ho);a=H(ue(a^u,11n),re)}let p=a>>33n;return a=H(a^p,$e),p=a>>29n,a=H(a^p,Vo),p=a>>32n,a^=p,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,vt(e),!0),n.setBigUint64(8,vt(e,1n),!0),t},Fo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,vt(e),!0),n.setBigUint64(8,vt(e,1n),!0),n.setBigUint64(16,vt(e,2n),!0),n.setBigUint64(24,vt(e,3n),!0),t},jo=e=>oe([Nt.enc(vt(e)),e]),zo=new TextEncoder,Ml=new Map([[Do,0],[jo,8],[Uo,16],[Ir,-16],[Vt,-32],[Rn,-16],[Fo,-32]]),Wo=e=>{const t=Rn(zo.encode(e));return(n,...r)=>{const s=oe([t,Rn(zo.encode(n))]),o=J(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=me(a.slice(o.length)),p=new Array(r.length);for(let u=0,h=0;u<r.length;u++){const[d,v]=r[u],m=Ml.get(v);if(m==null)throw new Error("Unknown hasher");if(m<0){const y=m*-1;p[u]=J(f.slice(h,h+y)),h+=y}else h+=m,p[u]=d.dec(f.slice(h)),h+=d.enc(p[u]).length}return p},c=r.map(([{enc:a},f])=>p=>f(a(p)));return{enc:(...a)=>J(oe([s,...a.map((f,p)=>c[p](f))])),dec:i}}},Ll=He.fromText("modlpy/utilisuba").asBytes(),Dl=({threshold:e,signatories:t})=>{const n=qo(t),r=oe([Ll,pe.enc(n.length),...n,Xe.enc(e)]);return Vt(r)},qo=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}}),mt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Ko=ye().dec,Vl=ye(1/0).dec,Hl=ye(32).dec,Xo=D.dec,Fl=e=>{const t=Xo(e);let n=6;const r=t>>n,s=r?r===1?mt.Leaf:r===2?mt.Branch:mt.BranchWithVal:t>>--n?mt.LeafWithHash:t>>--n?mt.BranchWithHash:t?mt.Reserved:mt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Xo(e);while(i===255)}return{type:s,partialKey:ye(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Yo=tt(e=>{const t=Fl(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Vl(e)};const r=Xe.dec(e),s=[];for(let c=0;c<16;c++)r>>c&1&&s.push(c.toString(16));let o=null;n==="BranchWithVal"&&(o=Ko(e)),n==="BranchWithHash"&&(o=Hl(e));const i={...t,children:Object.fromEntries(s.map(c=>[c,Ko(e)]))};return o!==null&&(i.value=o),i}),Go=e=>tt(t=>{const n=J(e(new Uint8Array(t.buffer)));try{return{hash:n,...Yo(t)}}catch{return{type:"Raw",hash:n,value:""}}});var No=Object.freeze({__proto__:null,AccountId:At,Bin:nn,Binary:He,BitSeq:On,Blake2128:Ir,Blake2128Concat:Uo,Blake2256:Vt,Blake3256:Lo,Blake3256Concat:Ul,Bytes:G,Enum:It,FixedSizeBinary:$n,Hex:ye,Identity:Do,Option:dt,Result:_n,ScaleEnum:mr,Self:vr,Storage:Wo,Struct:ie,TrieNodeHeaders:mt,TrieNodeWithHash:Go,Tuple:Fe,Twox128:Rn,Twox256:Fo,Twox64Concat:jo,Variant:Ee,Vector:Be,_Enum:uo,_void:O,bitSequence:Wa,blockHeader:wr,bool:qc,char:qa,compact:pe,compactBn:Cn,compactNumber:C,createCodec:z,createDecoder:tt,decAnyMetadata:Sr,enhanceCodec:Ke,enhanceDecoder:wn,enhanceEncoder:gn,ethAccount:xo,extrinsicFormat:Br,fixedStr:Ya,fromBufferToBase58:Js,getMultisigAccountId:Dl,getSs58AddressInfo:dr,h64:vt,i128:jc,i16:Vc,i256:Wc,i32:Hc,i64:Fc,i8:Dc,metadata:pt,selfDecoder:lo,selfEncoder:ao,sortMultisigSignatories:qo,str:F,trieNodeDec:Yo,u128:gs,u16:Xe,u256:zc,u32:Ve,u64:Nt,u8:D,unifyMetadata:Dt,v14:Oo,v14Lookup:Tn,v15:To,v16:Ro,validateProofs:(e,t=Vt)=>{const n=e.map(Go(t)),r=Object.fromEntries(n.map(c=>[c.hash,c])),s=n.map(c=>c.hash),o=new Set(s),i=c=>{if(c.value)return;const l=e[s.indexOf(c.hash)];c.value=typeof l=="string"?l:J(l)};return n.forEach(c=>{if("children"in c&&Object.values(c.children).forEach(l=>{const a=r[l];a&&(a.parent=c.hash,o.delete(l))}),c.type==="BranchWithHash"||c.type==="LeafWithHash"){const l=c.value,a=r[l];if(!a)return;o.delete(l),a.type!=="Raw"&&(Object.keys(a).forEach(f=>delete a[f]),a.type="Raw",a.hash=l),a.parent=c.hash,i(a)}c.type==="Raw"&&i(c)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const it=C,jl=Be(Fe(F,it)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},zl=Ee(Object.fromEntries(Object.values(j).map(e=>[e,O]))),Wl=Be(Fe(F,Ee({inline:vr(()=>_r),lookup:it}))),ql=Be(it),Kl=ie({typeRef:it,length:dt(it)}),Xl=dt(it),Yl=it,Gl=ie({ok:it,ko:it}),_r=Ee({struct:jl,terminal:zl,enum:Wl,tuple:ql,array:Kl,binary:Xl,option:Yl,result:Gl}),Nl={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},on=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return on(j.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 on(j.bits);case"compact":return on(e.isBig?j.big:j.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 on(Nl[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 on(j.void)}}function Or(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Or(o,i,n),s=o=>{switch(o.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===o.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof He&&(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 l=c[i.type];return l==null?!0:r(i.value,l.type==="inline"?l.value:n(l.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,f])=>r(e[a],n(f))):!1;case"tuple":return e?t.value.every((a,f)=>r(e[f],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 Ql=Object.defineProperty,Zl=(e,t,n)=>t in e?Ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jl=(e,t,n)=>Zl(e,t+"",n);class Qo{constructor(t=[]){Jl(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 Te=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Te||{});function Tr(e,t,n,r,s,o=!1){if(!n&&!e)return je(3,[]);if(!n)return je(2,[]);if(!e)return je(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const l=i.get(e);return l==null?{level:3,changes:[],assumptions:new Qo([[e,n]])}:je(l.level,l.changes)}i.set(e,null);const c=eu(e,n,(l,a)=>Tr(typeof l=="number"?t(l):l,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function eu(e,t,n,r){const s=(o,i,c)=>{const l=n(o,i);return{...l,changes:l.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:l.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Un(s(e,t.value,"some"),2):e.type==="option"?Un(s(e.value,t,"some"),1):je(0,[]);switch(t.type){case"terminal":return je(t.value.type===e.value.type?3:0,[]);case"binary":return Pr(ei(e.value,t.value));case"array":const i=e,c=Pr(ei(i.value.length,t.value.length));return Rr([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const u=e,h=Object.fromEntries(t.value.map(([m,y])=>[m,y.value]));let d=Jo(u.value.map(([m,y])=>()=>m in h?s(y.value,h[m],m):je(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:m}])));if(u.value.length===t.value.length)return d;d=Un(d,2);const v=new Set(u.value.map(([m])=>m));return d.changes=[...d.changes,...t.value.filter(([m])=>!v.has(m)).map(([m,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:m}))],d}case"option":return tu(s(e.value,t.value,"some"),1);case"struct":const l=e,a=Object.fromEntries(l.value),f=l.value.length===t.value.length?3:2;return Un(Rr(t.value.map(([u,h])=>()=>s(a[u],h,u)),r),f);case"tuple":{const u=e,h=Pr(nu(u.value,t.value));return Rr([h,...t.value.map((d,v)=>()=>s(u.value[v],d,String(v)))],r)}case"result":const p=e;return Jo([s(p.value.ok,t.value.ok,"ok"),s(p.value.ko,t.value.ko,"ko")])}}const Un=(e,t)=>({...e,level:Math.min(e.level,t)}),tu=(e,t)=>({...e,level:Math.max(e.level,t)}),Zo=new Qo,je=(e,t)=>({level:e,changes:t,assumptions:Zo}),Rr=(e,t)=>{let n=je(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Jo=e=>{if(!e.length)return je(3,[]);let t=!1,n=je(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:je(0,n.changes)},Pr=e=>({assumptions:Zo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),nu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ei=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,ti=Ee({lookup:C,typedef:_r}),Ht=e=>({type:"lookup",value:e}),Ur=e=>({type:"typedef",value:e}),Mn=Ur({type:"terminal",value:{type:j.void}}),ru=ie({args:ti,values:ti});function su(e){if(e.type.tag==="plain")return{args:Mn,values:Ht(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ht(t),values:Ht(n)}}function ni(e){return{args:Ur({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ht(e.output)}}function ou(e){return e.type==="lookupEntry"?Ht(e.value.id):Ur(Pn(e))}function iu(e){return{args:Mn,values:Ht(e)}}function cu(e,t,n,r,s,o){const i=(c,l)=>c.type==="lookup"?l(c.value):c.value;return{args:Tr(i(e.args,t),t,i(n.args,r),r,s,o),values:Tr(i(n.values,r),r,i(e.values,t),t,s,o)}}function ri(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Or(n,r,t)}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 Ne(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 au(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(f){try{a(r.next(f))}catch(p){i(p)}}function l(f){try{a(r.throw(f))}catch(p){i(p)}}function a(f){f.done?o(f.value):s(f.value).then(c,l)}a((r=r.apply(e,t||[])).next())})}function si(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(f){return l([a,f])}}function l(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(f){a=[6,f],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Ft(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 Re(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 Pe(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 jt(e){return this instanceof jt?(this.v=e,this):new jt(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(h){return function(d){return Promise.resolve(d).then(h,p)}}function c(h,d){r[h]&&(s[h]=function(v){return new Promise(function(m,y){o.push([h,v,m,y])>1||l(h,v)})},d&&(s[h]=d(s[h])))}function l(h,d){try{a(r[h](d))}catch(v){u(o[0][3],v)}}function a(h){h.value instanceof jt?Promise.resolve(h.value.v).then(f,p):u(o[0][2],h)}function f(h){l("next",h)}function p(h){l("throw",h)}function u(h,d){h(d),o.shift(),o.length&&l(o[0][0],o[0][1])}}function uu(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 Ft=="function"?Ft(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,l){i=e[o](i),s(c,l,i.done,i.value)})}}function s(o,i,c,l){Promise.resolve(l).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function K(e){return typeof e=="function"}function Lr(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 Dr=Lr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(le,Gt){typeof exports=="object"&&typeof module<"u"?Gt(exports):typeof define=="function"&&define.amd?define(["exports"],Gt):(le=typeof globalThis<"u"?globalThis:le||self,Gt(le.papi={}))})(this,(function(le){"use strict";var Gt=Object.defineProperty,Pc=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ms=(e,t,n)=>(Pc(e,typeof t!="symbol"?t+"":t,n),n),ar={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 Uc(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|ar[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=ar[e[i]],l=ar[e[i+1]];s[t+o++]=c<<4|l}return s}var ys=class extends Uint8Array{constructor(e){super(e),ms(this,"i",0),ms(this,"v"),this.v=new DataView(e)}},_e=e=>t=>e(t instanceof ys?t:new ys(t instanceof Uint8Array?t.buffer:typeof t=="string"?Uc(t).buffer:t)),qe=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 bn(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 tt=_e,z=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gn=(e,t)=>n=>e(t(n)),wn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>z(gn(e,n),wn(t,r));function Mc(e,t){return _e(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Lc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ct(e,t,n){return z(Lc(e,n),Mc(e,t))}var D=ct(1,"getUint8","setUint8"),Xe=ct(2,"getUint16","setUint16"),Ve=ct(4,"getUint32","setUint32"),Nt=ct(8,"getBigUint64","setBigUint64"),Dc=ct(1,"getInt8","setInt8"),Vc=ct(2,"getInt16","setInt16"),Hc=ct(4,"getInt32","setInt32"),Fc=ct(8,"getBigInt64","setBigInt64"),bs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},gs=e=>_e(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}),ws=z(bs,gs("getBigUint64")),jc=z(bs,gs("getBigInt64")),xs=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},Es=e=>_e(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}),zc=z(xs,Es("getBigUint64")),Wc=z(xs,Es("getBigInt64")),qc=Ke(D,e=>e?1:0,Boolean),Kc=[D[1],Xe[1],Ve[1]],Xc=_e(e=>{const t=e[e.i],n=t&3;if(n<3)return Kc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let l=0;l<o;l++)s=Nt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(Ve[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(Xe[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(D[1](e))<<i|s),s}),Yc=1n<<56n,Gc=1<<24,Nc=256,Qc=4294967295n,Zc=64,Jc=16384,ea=1<<30,ta=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Zc)return D[0](t);if(e<Jc)return Xe[0](t|1);if(e<ea)return Ve[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Yc;)n.push(Nt[0](r)),r>>=64n;r>=Gc&&(n.push(Ve[0](Number(r&Qc))),r>>=32n);let s=Number(r);s>=Nc&&(n.push(Xe[0](s)),s>>=16),s&&n.push(D[0](s));const o=qe(n);return o[0]=o.length-5<<2|3,o},pe=z(ta,Xc),na=new TextEncoder,ra=e=>{const t=na.encode(e);return qe([pe.enc(t.length),t])},sa=new TextDecoder,oa=_e(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,sa.decode(n)}),F=z(ra,oa),ia=()=>{},ca=new Uint8Array(0),O=z(()=>ca,ia),ks=e=>e===void 0?t=>qe([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),As=e=>_e(t=>{const n=e===void 0?pe.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),G=e=>z(ks(e),As(e));G.enc=ks,G.dec=As;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})=>qe([D.enc(s(o)),e[o](i)])},Is=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _e(s=>{const o=D.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},we=(e,...t)=>z(Ss(bn(e,([n])=>n),...t),Is(bn(e,([,n])=>n),...t));we.enc=Ss,we.dec=Is;var Bs=e=>_e(t=>D[1](t)>0?e(t):void 0),$s=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,qe([n,e(t)]))},xe=e=>z($s(e[0]),Bs(e[1]));xe.enc=$s,xe.dec=Bs;var Cs=(e,t)=>_e(n=>{const r=D[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),_s=(e,t)=>({success:n,value:r})=>qe([D[0](n?0:1),(n?e:t)(r)]),Qt=(e,t)=>z(_s(e[0],t[0]),Cs(e[1],t[1]));Qt.dec=Cs,Qt.enc=_s;var Os=(...e)=>_e(t=>e.map(n=>n(t))),Ts=(...e)=>t=>qe(e.map((n,r)=>n(t[r]))),Oe=(...e)=>z(Ts(...e.map(([t])=>t)),Os(...e.map(([,t])=>t)));Oe.enc=Ts,Oe.dec=Os;var Rs=e=>{const t=Object.keys(e);return gn(Oe.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ps=e=>{const t=Object.keys(e);return wn(Oe.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},R=e=>z(Rs(bn(e,t=>t[0])),Ps(bn(e,t=>t[1])));R.enc=Rs,R.dec=Ps;var Us=(e,t)=>t>=0?n=>qe(n.map(e)):n=>qe([pe.enc(n.length),qe(n.map(e))]),Ms=(e,t)=>_e(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),L=(e,t)=>z(Us(e[0],t),Ms(e[1],t));L.enc=Us,L.dec=Ms;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function aa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ls(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 lr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ds(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ur(e){if(!Array.isArray(e))throw new Error("array expected")}function Vs(e,t){if(!Ls(!0,t))throw new Error(`${e}: array of strings expected`)}function la(e,t){if(!Ls(!1,t))throw new Error(`${e}: array of numbers expected`)}function ua(...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 fa(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Vs("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ur(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=>(ur(s),s.map(o=>{lr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ha(e=""){return lr("join",e),{encode:t=>(Vs("join.decode",t),t.join(e)),decode:t=>(lr("join.decode",t),t.split(e))}}function Hs(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(ur(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Ds(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,l=!0;for(let a=r;a<i;a++){const f=o[a],p=t*c,u=p+f;if(!Number.isSafeInteger(u)||p/t!==c||u-f!==p)throw new Error("convertRadix: carry overflow");const d=u/n;c=u%n;const h=Math.floor(d);if(o[a]=h,!Number.isSafeInteger(h)||h*n+c!==u)throw new Error("convertRadix: carry overflow");if(l)h?l=!1:r=a;else continue}if(s.push(c),l)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function da(e){Ds(e);const t=2**8;return{encode:n=>{if(!aa(n))throw new Error("radix.encode input should be Uint8Array");return Hs(Array.from(n),t,e)},decode:n=>(la("radix.decode",n),Uint8Array.from(Hs(n,e,t)))}}const Fs=(e=>ua(da(58),fa(e),ha("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ut(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Et(e,...t){if(!pa(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 Zt(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 fr(e,t){Et(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function va(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function kt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function at(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e,t){return e<<32-t|e>>>t}const js=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const nt=js?e=>e:e=>zs(e);function ma(e){for(let t=0;t<e.length;t++)e[t]=zs(e[t]);return e}const ve=js?e=>e:ma;function ya(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ye(e){return typeof e=="string"&&(e=ya(e)),Et(e),e}class Ws{}function ba(e){const t=r=>e().update(Ye(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ga(e){const t=(r,s)=>e(s).update(Ye(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function wa(e){const t=(r,s)=>e(s).update(Ye(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const xa=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 lt(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,16),n=n+r|0,t=xn(t^n,12),{a:e,b:t,c:n,d:r}}function ut(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,8),n=n+r|0,t=xn(t^n,7),{a:e,b:t,c:n,d:r}}const Ea=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),En=BigInt(2**32-1),qs=BigInt(32);function kn(e,t=!1){return t?{h:Number(e&En),l:Number(e>>qs&En)}:{h:Number(e>>qs&En)|0,l:Number(e&En)|0}}function ka(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}=kn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Ks=(e,t,n)=>e>>>n|t<<32-n,Xs=(e,t,n)=>e<<32-n|t>>>n,Aa=(e,t,n)=>e<<64-n|t>>>n-32,Sa=(e,t,n)=>e>>>n-32|t<<64-n,Ia=(e,t)=>t,Ba=(e,t)=>e,$a=(e,t,n)=>e<<n|t>>>32-n,Ca=(e,t,n)=>t<<n|e>>>32-n,_a=(e,t,n)=>t<<n-32|e>>>64-n,Oa=(e,t,n)=>e<<n-32|t>>>64-n;function Ys(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Gs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ns=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,ee=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),S=new Uint32Array(32);function ft(e,t,n,r,s,o){const i=s[o],c=s[o+1];let l=S[2*e],a=S[2*e+1],f=S[2*t],p=S[2*t+1],u=S[2*n],d=S[2*n+1],h=S[2*r],v=S[2*r+1],m=Gs(l,f,i);a=Ns(m,a,p,c),l=m|0,{Dh:v,Dl:h}={Dh:v^a,Dl:h^l},{Dh:v,Dl:h}={Dh:Ia(v,h),Dl:Ba(v)},{h:d,l:u}=Ys(d,u,v,h),{Bh:p,Bl:f}={Bh:p^d,Bl:f^u},{Bh:p,Bl:f}={Bh:Ks(p,f,24),Bl:Xs(p,f,24)},S[2*e]=l,S[2*e+1]=a,S[2*t]=f,S[2*t+1]=p,S[2*n]=u,S[2*n+1]=d,S[2*r]=h,S[2*r+1]=v}function ht(e,t,n,r,s,o){const i=s[o],c=s[o+1];let l=S[2*e],a=S[2*e+1],f=S[2*t],p=S[2*t+1],u=S[2*n],d=S[2*n+1],h=S[2*r],v=S[2*r+1],m=Gs(l,f,i);a=Ns(m,a,p,c),l=m|0,{Dh:v,Dl:h}={Dh:v^a,Dl:h^l},{Dh:v,Dl:h}={Dh:Ks(v,h,16),Dl:Xs(v,h,16)},{h:d,l:u}=Ys(d,u,v,h),{Bh:p,Bl:f}={Bh:p^d,Bl:f^u},{Bh:p,Bl:f}={Bh:Aa(p,f,63),Bl:Sa(p,f,63)},S[2*e]=l,S[2*e+1]=a,S[2*t]=f,S[2*t+1]=p,S[2*n]=u,S[2*n+1]=d,S[2*r]=h,S[2*r+1]=v}function Ta(e,t={},n,r,s){if(Ut(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 Qs extends Ws{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Ut(t),Ut(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=kt(this.buffer)}update(t){Zt(this),t=Ye(t),Et(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let l=0;l<o;){this.pos===n&&(ve(s),this.compress(s,0,!1),ve(s),this.pos=0);const a=Math.min(n-this.pos,o-l),f=i+l;if(a===n&&!(f%4)&&l+a<o){const p=new Uint32Array(c,f,Math.floor((o-l)/4));ve(p);for(let u=0;l+n<o;u+=s.length,l+=n)this.length+=n,this.compress(p,u,!1);ve(p);continue}r.set(t.subarray(l,l+a),this.pos),this.pos+=a,this.length+=a,l+=a}return this}digestInto(t){Zt(this),fr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,at(this.buffer.subarray(n)),ve(r),this.compress(r,0,!0),ve(r);const s=kt(t);this.get().forEach((o,i)=>s[i]=nt(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 Ra extends Qs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=ee[0]|0,this.v0h=ee[1]|0,this.v1l=ee[2]|0,this.v1h=ee[3]|0,this.v2l=ee[4]|0,this.v2h=ee[5]|0,this.v3l=ee[6]|0,this.v3h=ee[7]|0,this.v4l=ee[8]|0,this.v4h=ee[9]|0,this.v5l=ee[10]|0,this.v5h=ee[11]|0,this.v6l=ee[12]|0,this.v6h=ee[13]|0,this.v7l=ee[14]|0,this.v7h=ee[15]|0,Ta(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Ye(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Ye(o);const c=kt(o);this.v4l^=nt(c[0]),this.v4h^=nt(c[1]),this.v5l^=nt(c[2]),this.v5h^=nt(c[3])}if(s!==void 0){s=Ye(s);const c=kt(s);this.v6l^=nt(c[0]),this.v6h^=nt(c[1]),this.v7l^=nt(c[2]),this.v7h^=nt(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:l,v4l:a,v4h:f,v5l:p,v5h:u,v6l:d,v6h:h,v7l:v,v7h:m}=this;return[t,n,r,s,o,i,c,l,a,f,p,u,d,h,v,m]}set(t,n,r,s,o,i,c,l,a,f,p,u,d,h,v,m){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=l|0,this.v4l=a|0,this.v4h=f|0,this.v5l=p|0,this.v5h=u|0,this.v6l=d|0,this.v6h=h|0,this.v7l=v|0,this.v7h=m|0}compress(t,n,r){this.get().forEach((l,a)=>S[a]=l),S.set(ee,16);let{h:s,l:o}=kn(BigInt(this.length));S[24]=ee[8]^o,S[25]=ee[9]^s,r&&(S[28]=~S[28],S[29]=~S[29]);let i=0;const c=xa;for(let l=0;l<12;l++)ft(0,4,8,12,t,n+2*c[i++]),ht(0,4,8,12,t,n+2*c[i++]),ft(1,5,9,13,t,n+2*c[i++]),ht(1,5,9,13,t,n+2*c[i++]),ft(2,6,10,14,t,n+2*c[i++]),ht(2,6,10,14,t,n+2*c[i++]),ft(3,7,11,15,t,n+2*c[i++]),ht(3,7,11,15,t,n+2*c[i++]),ft(0,5,10,15,t,n+2*c[i++]),ht(0,5,10,15,t,n+2*c[i++]),ft(1,6,11,12,t,n+2*c[i++]),ht(1,6,11,12,t,n+2*c[i++]),ft(2,7,8,13,t,n+2*c[i++]),ht(2,7,8,13,t,n+2*c[i++]),ft(3,4,9,14,t,n+2*c[i++]),ht(3,4,9,14,t,n+2*c[i++]);this.v0l^=S[0]^S[16],this.v0h^=S[1]^S[17],this.v1l^=S[2]^S[18],this.v1h^=S[3]^S[19],this.v2l^=S[4]^S[20],this.v2h^=S[5]^S[21],this.v3l^=S[6]^S[22],this.v3h^=S[7]^S[23],this.v4l^=S[8]^S[24],this.v4h^=S[9]^S[25],this.v5l^=S[10]^S[26],this.v5h^=S[11]^S[27],this.v6l^=S[12]^S[28],this.v6h^=S[13]^S[29],this.v7l^=S[14]^S[30],this.v7h^=S[15]^S[31],at(S)}destroy(){this.destroyed=!0,at(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Pa=ga(e=>new Ra(e));function Zs(e,t,n,r,s,o,i,c,l,a,f,p,u,d,h,v,m,y,b,x){let g=0;for(let w=0;w<r;w++)({a:s,b:l,c:u,d:m}=lt(s,l,u,m,n[t+e[g++]])),{a:s,b:l,c:u,d:m}=ut(s,l,u,m,n[t+e[g++]]),{a:o,b:a,c:d,d:y}=lt(o,a,d,y,n[t+e[g++]]),{a:o,b:a,c:d,d:y}=ut(o,a,d,y,n[t+e[g++]]),{a:i,b:f,c:h,d:b}=lt(i,f,h,b,n[t+e[g++]]),{a:i,b:f,c:h,d:b}=ut(i,f,h,b,n[t+e[g++]]),{a:c,b:p,c:v,d:x}=lt(c,p,v,x,n[t+e[g++]]),{a:c,b:p,c:v,d:x}=ut(c,p,v,x,n[t+e[g++]]),{a:s,b:a,c:h,d:x}=lt(s,a,h,x,n[t+e[g++]]),{a:s,b:a,c:h,d:x}=ut(s,a,h,x,n[t+e[g++]]),{a:o,b:f,c:v,d:m}=lt(o,f,v,m,n[t+e[g++]]),{a:o,b:f,c:v,d:m}=ut(o,f,v,m,n[t+e[g++]]),{a:i,b:p,c:u,d:y}=lt(i,p,u,y,n[t+e[g++]]),{a:i,b:p,c:u,d:y}=ut(i,p,u,y,n[t+e[g++]]),{a:c,b:l,c:d,d:b}=lt(c,l,d,b,n[t+e[g++]]),{a:c,b:l,c:d,d:b}=ut(c,l,d,b,n[t+e[g++]]);return{v0:s,v1:o,v2:i,v3:c,v4:l,v5:a,v6:f,v7:p,v8:u,v9:d,v10:h,v11:v,v12:m,v13:y,v14:b,v15:x}}const An=Pa,Js=new TextEncoder().encode("SS58PRE"),hr=2,dr=e=>{try{const t=Fs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-hr),s=t.subarray(n.length+r.length),o=An(Uint8Array.of(...Js,...n,...r),{dkLen:64}).subarray(0,hr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Ua(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Ua=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},eo=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=An(Uint8Array.of(...Js,...t,...n),{dkLen:64}).subarray(0,hr);return Fs.encode(Uint8Array.of(...t,...n,...r))}};function Ma(e,t){return n=>{const r=dr(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 At=(e=42,t=32)=>Ke(G(t),Ma(t),eo(e)),to="0123456789abcdef";function J(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=to[r>>4]+to[r&15]}return t.join("")}const pr={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 me(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|pr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=pr[e[i]],l=pr[e[i+1]];s[t+o++]=c<<4|l}return s}function Mt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const oe=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},St=Function.prototype;class no extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var La=Object.defineProperty,ro=e=>{throw TypeError(e)},Da=(e,t,n)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jt=(e,t,n)=>Da(e,typeof t!="symbol"?t+"":t,n),so=(e,t,n)=>t.has(e)||ro("Cannot "+n),rt=(e,t,n)=>(so(e,t,"read from private field"),n?n.call(e):t.get(e)),en=(e,t,n)=>t.has(e)?ro("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),It=(e,t,n,r)=>(so(e,t,"write to private field"),t.set(e,n),n),st,tn,Sn,In,Bn;const Va=new TextEncoder,Ha=new TextDecoder,Fa=Oe(pe,G(1/0))[1];class He{constructor(t,n=!1){if(en(this,st),en(this,tn,null),en(this,Sn,null),en(this,In,null),en(this,Bn,null),Jt(this,"asText",()=>rt(this,Bn)??It(this,Bn,Ha.decode(rt(this,st)))),Jt(this,"asHex",()=>rt(this,Sn)||It(this,Sn,J(rt(this,st)))),Jt(this,"asOpaqueHex",()=>rt(this,In)||It(this,In,J(this.asBytes()))),Jt(this,"asBytes",()=>rt(this,st)),Jt(this,"asOpaqueBytes",()=>rt(this,tn)||It(this,tn,oe([rt(this,st),pe[0](rt(this,st).length)]))),n){try{const[r,s]=Fa(t);if(r===s.length){It(this,st,s),It(this,tn,t);return}}catch{}throw new Error("Invalid opaque bytes")}else It(this,st,t)}static fromText(t){return new this(Va.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}st=new WeakMap,tn=new WeakMap,Sn=new WeakMap,In=new WeakMap,Bn=new WeakMap;const[ja]=At();class $n extends He{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ja(t))}}const oo=e=>{const t=G.enc(e);return n=>t(n.asBytes())},io=e=>{const t=G.dec(e),n=e==null?He:$n;return r=>n.fromBytes(t(r))},nn=e=>z(oo(e),io(e));nn.enc=oo,nn.dec=io;const C=Ke(pe,e=>e,Number),Cn=Ke(pe,e=>e,BigInt),za=tt(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),Wa=z(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},za),qa=Ke(D,e=>e.charCodeAt(0),String.fromCharCode),co=e=>{const t=G.enc(e);return n=>t(me(n))},ao=e=>{const t=G.dec(e);return n=>J(t(n))},ye=e=>z(co(e),ao(e));ye.enc=co,ye.dec=ao;const Ka=new TextEncoder,Xa=new TextDecoder,Ya=e=>Ke(G(e),t=>Ka.encode(t),t=>Xa.decode(t)),lo=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},uo=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},vr=e=>z(lo(()=>e().enc),uo(()=>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}}),fo=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),N=(e,t)=>{const n=e;return n.inner=t,n},ho=(...e)=>{const t=we.enc(...e);return N(n=>t({tag:n.type,value:n.value}),e[0])},po=(...e)=>{const t=we.dec(...e);return N(n=>{const{tag:r,value:s}=t(n);return Bt(r,s)},e[0])},Ee=(e,...t)=>N(z(ho(Mt(e,([n])=>n),...t),po(Mt(e,([,n])=>n),...t)),e);Ee.enc=ho,Ee.dec=po;const mr=(e,...t)=>N(we(e,...t),e);mr.enc=(e,...t)=>N(we.enc(e,...t),e),mr.dec=(e,...t)=>N(we.dec(e,...t),e);const Ga=BigInt(0),rn=BigInt(1),Na=BigInt(2),Qa=BigInt(7),Za=BigInt(256),Ja=BigInt(113),vo=[],mo=[],yo=[];for(let e=0,t=rn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],vo.push(2*(5*r+n)),mo.push((e+1)*(e+2)/2%64);let s=Ga;for(let o=0;o<7;o++)t=(t<<rn^(t>>Qa)*Ja)%Za,t&Na&&(s^=rn<<(rn<<BigInt(o))-rn);yo.push(s)}const bo=ka(yo,!0),el=bo[0],tl=bo[1],go=(e,t,n)=>n>32?_a(e,t,n):$a(e,t,n),wo=(e,t,n)=>n>32?Oa(e,t,n):Ca(e,t,n);function nl(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,l=(i+2)%10,a=n[l],f=n[l+1],p=go(a,f,1)^n[c],u=wo(a,f,1)^n[c+1];for(let d=0;d<50;d+=10)e[i+d]^=p,e[i+d+1]^=u}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=mo[i],l=go(s,o,c),a=wo(s,o,c),f=vo[i];s=e[f],o=e[f+1],e[f]=l,e[f+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]^=el[r],e[1]^=tl[r]}at(n)}class yr extends Ws{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,Ut(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=kt(this.state)}clone(){return this._cloneInto()}keccak(){ve(this.state32),nl(this.state32,this.rounds),ve(this.state32),this.posOut=0,this.pos=0}update(t){Zt(this),t=Ye(t),Et(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){Zt(this,!1),Et(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 Ut(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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,at(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new yr(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 rl=(e,t,n)=>ba(()=>new yr(t,e,n)),sl=rl(1,136,256/8),xo=e=>{const t=e.slice(2),n=J(sl(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("")}`},ol=G(20)[1],Eo=z(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=J(t);if(e===n||e===n.toUpperCase())return t;if(xo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},tt(e=>xo(J(ol(e))))),ie=e=>N(R(e),e);ie.enc=e=>N(R.enc(e),e),ie.dec=e=>N(R.dec(e),e);const Fe=(...e)=>N(Oe(...e),e);Fe.enc=(...e)=>N(Oe.enc(...e),e),Fe.dec=(...e)=>N(Oe.dec(...e),e);const Ie=(e,...t)=>N(L(e,...t),e);Ie.enc=(e,...t)=>N(L.enc(e,...t),e),Ie.dec=(e,...t)=>N(L.dec(e,...t),e);const _n=(e,t)=>N(Qt(e,t),{ok:e,ko:t});_n.enc=(e,t)=>N(Qt.enc(e,t),{ok:e,ko:t}),_n.dec=(e,t)=>N(Qt.dec(e,t),{ok:e,ko:t});const dt=e=>N(xe(e),e);dt.enc=e=>N(xe.enc(e),e),dt.dec=e=>N(xe.dec(e),e);const ko=(e=!0)=>tt(t=>{const n=C.dec(t),r=Math.ceil(n/8),s=G(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let l=0;l<8&&i<n;l++){const a=e?l:7-l;o[i++]=c>>a&1}}),o}),Ao=(e=!0)=>t=>{const n=C.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let l=0;l<8&&i<t.length;l++,i++)c|=t[i]<<(e?l:7-l);s[o]=c}return oe([n,s])},On=e=>z(Ao(e),ko(e));On.enc=Ao,On.dec=ko;const So=new TextEncoder,Io=new TextDecoder,il=Ke(G(4),So.encode.bind(So),Io.decode.bind(Io)),br=ie({engine:il,payload:ye()}),cl=Ee({other:G(),consensus:br,seal:br,preRuntime:br,runtimeUpdated:O},[0,4,5,6,8]),gr=ye(32),wr=ie({parentHash:gr,number:C,stateRoot:gr,extrinsicRoot:gr,digests:Ie(cl)}),Be=L(F),Bo=xe(F),al=we({bool:O,char:O,str:O,u8:O,u16:O,u32:O,u64:O,u128:O,u256:O,i8:O,i16:O,i32:O,i64:O,i128:O,i256:O}),$o=L(R({name:Bo,type:C,typeName:Bo,docs:Be})),ll=R({len:Ve,type:C}),ul=R({bitStoreType:C,bitOrderType:C}),fl=L(R({name:F,fields:$o,index:D,docs:Be})),hl=we({composite:$o,variant:fl,sequence:C,array:ll,tuple:L(C),primitive:al,compact:C,bitSequence:ul}),dl=R({name:F,type:xe(C)}),pl=L(dl),vl=R({id:C,path:Be,params:pl,def:hl,docs:Be}),Tn=L(vl),Lt=we({NotDeprecated:O,DeprecatedWithoutNote:O,Deprecated:R({note:F,since:xe(F)})}),ml=L(R({index:D,deprecation:we({DeprecatedWithoutNote:O,Deprecated:R({note:F,since:xe(F)})},[1,2])})),xr={name:F,inputs:L(R({name:F,type:C})),output:C,docs:Be},yl=R({name:F,methods:L(R(xr)),docs:Be}),bl=R({name:F,methods:L(R({...xr,deprecationInfo:Lt})),docs:Be,version:C,deprecationInfo:Lt}),gl=R({id:ye(32),...xr,deprecationInfo:Lt}),wl=we({Blake2128:O,Blake2256:O,Blake2128Concat:O,Twox128:O,Twox256:O,Twox64Concat:O,Identity:O}),xl=L(wl),El=R({hashers:xl,key:C,value:C}),Co={name:F,modifier:D,type:we({plain:C,map:El}),fallback:ye(),docs:Be},Er=xe(C),_o={name:F,storage:xe(R({prefix:F,items:L(R(Co))})),calls:Er,events:Er,constants:L(R({name:F,type:C,value:ye(),docs:Be})),errors:Er,index:D},kl={..._o,docs:Be},kr=xe(R({type:C,deprecationInfo:ml})),Al={name:F,storage:xe(R({prefix:F,items:L(R({...Co,deprecationInfo:Lt}))})),calls:kr,events:kr,constants:L(R({name:F,type:C,value:ye(),docs:Be,deprecationInfo:Lt})),errors:kr,associatedTypes:L(R({name:F,type:C,docs:Be})),viewFns:L(gl),index:D,docs:Be,deprecationInfo:Lt},Sl=new Uint8Array,Oo=e=>z(()=>Sl,()=>e),Il=R({type:C,version:D,signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),To=R({lookup:Tn,pallets:L(R({..._o,docs:Oo([])})),extrinsic:Il,type:C,apis:Oo([])}),Bl=R({version:D,address:C,call:C,signature:C,extra:C,signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),Ro=R({lookup:Tn,pallets:L(R(kl)),extrinsic:Bl,type:C,apis:L(yl),outerEnums:R({call:C,event:C,error:C}),custom:L(Oe(F,R({type:C,value:ye()})))}),$l=R({version:L(D),address:C,call:C,signature:C,signedExtensionsByVersion:L(Oe(D,L(C))),signedExtensions:L(R({identifier:F,type:C,additionalSigned:C}))}),Po=R({lookup:Tn,pallets:L(R(Al)),extrinsic:$l,apis:L(bl),outerEnums:R({call:C,event:C,error:C}),custom:L(Oe(F,R({type:C,value:ye()})))}),Uo=()=>{throw new Error("Unsupported metadata version!")},ke=z(Uo,Uo),pt=R({magicNumber:Ve,metadata:we({v0:ke,v1:ke,v2:ke,v3:ke,v4:ke,v5:ke,v6:ke,v7:ke,v8:ke,v9:ke,v10:ke,v11:ke,v12:ke,v13:ke,v14:To,v15:Ro,v16:Po})}),Ar=G(),Cl=xe(Ar),_l=Oe(pe,Ar),Sr=e=>{try{return pt.dec(e)}catch{}try{return pt.dec(Cl.dec(e))}catch{}try{return pt.dec(Ar.dec(e))}catch{}try{return pt.dec(_l.dec(e)[1])}catch{}throw null},Dt=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:l,outerEnums:a}=e;return{version:15,lookup:s,pallets:l.map(f=>({...f,calls:f.calls!=null?{type:f.calls}:void 0,events:f.events!=null?{type:f.events}:void 0,errors:f.errors!=null?{type:f.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},$t={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Ir=Ke(D,({version:e,type:t})=>e+($t[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===$t.bare||n===$t.signed))return{version:t,type:$t[n]};if(t===5&&(n===$t.bare||n===$t.general))return{version:t,type:$t[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),Ol={dkLen:32},Vt=e=>An(e,Ol),Tl={dkLen:16},Br=e=>An(e,Tl),Mo=e=>oe([Br(e),e]),Ge={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},ot=Ea.slice(),Lo=(()=>{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 $r extends Qs{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=Ye(r).slice();Et(i,32),this.IV=kt(i),ve(this.IV),this.flags=n|Ge.KEYED_HASH}else if(o){const i=Ye(s),c=new $r({dkLen:32},Ge.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=kt(c),ve(this.IV),this.flags=n|Ge.DERIVE_KEY_MATERIAL}else this.IV=ot.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=va(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l}=kn(BigInt(t),!0),{v0:a,v1:f,v2:p,v3:u,v4:d,v5:h,v6:v,v7:m,v8:y,v9:b,v10:x,v11:g,v12:w,v13:k,v14:$,v15:E}=Zs(Lo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ot[0],ot[1],ot[2],ot[3],c,l,i,n);o[0]=a^y,o[1]=f^b,o[2]=p^x,o[3]=u^g,o[4]=d^w,o[5]=h^k,o[6]=v^$,o[7]=m^E}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ge.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ge.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|Ge.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:l,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=l.map(f=>Uint32Array.from(f)),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,at(this.state,this.buffer32,this.IV,this.bufferOut32),at(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=kn(BigInt(this.chunkOut++));ve(s);const{v0:l,v1:a,v2:f,v3:p,v4:u,v5:d,v6:h,v7:v,v8:m,v9:y,v10:b,v11:x,v12:g,v13:w,v14:k,v15:$}=Zs(Lo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ot[0],ot[1],ot[2],ot[3],c,i,n,r);o[0]=l^m,o[1]=a^y,o[2]=f^b,o[3]=p^x,o[4]=u^g,o[5]=d^w,o[6]=h^k,o[7]=v^$,o[8]=t[0]^m,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^x,o[12]=t[4]^g,o[13]=t[5]^w,o[14]=t[6]^k,o[15]=t[7]^$,ve(s),ve(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,at(this.buffer.subarray(this.pos));let t=this.flags|Ge.ROOT;this.stack.length?(t|=Ge.PARENT,ve(this.buffer32),this.compress(this.buffer32,0,!0),ve(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ge.CHUNK_START)|Ge.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Zt(this,!1),Et(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 Ut(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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 Rl=wa(e=>new $r(e)),Pl={dkLen:32},Do=e=>Rl(e,Pl),Ul=e=>oe([Do(e),e]),Vo=e=>e,Ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Cr=2n**64n-1n,ue=(e,t)=>e<<t&Cr|e>>64n-t,H=(e,t)=>e*t&Cr,ne=(e,t)=>e+t&Cr,re=11400714785074694791n,$e=14029467366897019727n,Ho=1609587929392839161n,sn=9650029242287828579n,Fo=2870177450012600261n;function vt(e,t=0n){let n=ne(ne(t,re),$e),r=ne(t,$e),s=t,o=t-re,i=e.length,c=0,l=null;(function(){let d=0,h=d+i;if(i){if(l=new Uint8Array(32),i<32){l.set(e.subarray(0,i),c),c+=i;return}if(d<=h-32){const v=h-32;do{let m;m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),n=H(ue(ne(n,H(m,$e)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),r=H(ue(ne(r,H(m,$e)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),s=H(ue(ne(s,H(m,$e)),31n),re),d+=8,m=Ct(e[d+1]<<8|e[d],e[d+3]<<8|e[d+2],e[d+5]<<8|e[d+4],e[d+7]<<8|e[d+6]),o=H(ue(ne(o,H(m,$e)),31n),re),d+=8}while(d<=v)}d<h&&(l.set(e.subarray(d,h),c),c=h-d)}})(),e=l||e;let a,f=0;for(i>=32?(a=ue(n,1n),a=ne(a,ue(r,7n)),a=ne(a,ue(s,12n)),a=ne(a,ue(o,18n)),n=H(ue(H(n,$e),31n),re),a=a^n,a=ne(H(a,re),sn),r=H(ue(H(r,$e),31n),re),a=a^r,a=ne(H(a,re),sn),s=H(ue(H(s,$e),31n),re),a=a^s,a=ne(H(a,re),sn),o=H(ue(H(o,$e),31n),re),a=a^o,a=ne(H(a,re),sn)):a=ne(t,Fo),a=ne(a,BigInt(i));f<=c-8;){let u=Ct(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]);u=H(ue(H(u,$e),31n),re),a=ne(H(ue(a^u,27n),re),sn),f+=8}if(f+4<=c){let u=H(Ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),re);a=ne(H(ue(a^u,23n),$e),Ho),f+=4}for(;f<c;){const u=H(Ct(e[f++],0,0,0),Fo);a=H(ue(a^u,11n),re)}let p=a>>33n;return a=H(a^p,$e),p=a>>29n,a=H(a^p,Ho),p=a>>32n,a^=p,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,vt(e),!0),n.setBigUint64(8,vt(e,1n),!0),t},jo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,vt(e),!0),n.setBigUint64(8,vt(e,1n),!0),n.setBigUint64(16,vt(e,2n),!0),n.setBigUint64(24,vt(e,3n),!0),t},zo=e=>oe([Nt.enc(vt(e)),e]),Wo=new TextEncoder,Ml=new Map([[Vo,0],[zo,8],[Mo,16],[Br,-16],[Vt,-32],[Rn,-16],[jo,-32]]),qo=e=>{const t=Rn(Wo.encode(e));return(n,...r)=>{const s=oe([t,Rn(Wo.encode(n))]),o=J(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=me(a.slice(o.length)),p=new Array(r.length);for(let u=0,d=0;u<r.length;u++){const[h,v]=r[u],m=Ml.get(v);if(m==null)throw new Error("Unknown hasher");if(m<0){const y=m*-1;p[u]=J(f.slice(d,d+y)),d+=y}else d+=m,p[u]=h.dec(f.slice(d)),d+=h.enc(p[u]).length}return p},c=r.map(([{enc:a},f])=>p=>f(a(p)));return{enc:(...a)=>J(oe([s,...a.map((f,p)=>c[p](f))])),dec:i}}},Ll=He.fromText("modlpy/utilisuba").asBytes(),Dl=({threshold:e,signatories:t})=>{const n=Ko(t),r=oe([Ll,pe.enc(n.length),...n,Xe.enc(e)]);return Vt(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}}),mt={Leaf:"Leaf",Branch:"Branch",BranchWithVal:"BranchWithVal",LeafWithHash:"LeafWithHash",BranchWithHash:"BranchWithHash",Empty:"Empty",Reserved:"Reserved"},Xo=ye().dec,Vl=ye(1/0).dec,Hl=ye(32).dec,Yo=D.dec,Fl=e=>{const t=Yo(e);let n=6;const r=t>>n,s=r?r===1?mt.Leaf:r===2?mt.Branch:mt.BranchWithVal:t>>--n?mt.LeafWithHash:t>>--n?mt.BranchWithHash:t?mt.Reserved:mt.Empty;let o=t&255>>8-n;if(o===2**n-1){let i;do o+=i=Yo(e);while(i===255)}return{type:s,partialKey:ye(Math.ceil(o/2)).dec(e).slice(o%2?3:2)}},Go=tt(e=>{const t=Fl(e),{type:n}=t;if(n==="Empty"||n==="Reserved")return t;if(n==="Leaf"||n==="LeafWithHash")return{...t,value:Vl(e)};const r=Xe.dec(e),s=[];for(let c=0;c<16;c++)r>>c&1&&s.push(c.toString(16));let o=null;n==="BranchWithVal"&&(o=Xo(e)),n==="BranchWithHash"&&(o=Hl(e));const i={...t,children:Object.fromEntries(s.map(c=>[c,Xo(e)]))};return o!==null&&(i.value=o),i}),No=e=>tt(t=>{const n=J(e(new Uint8Array(t.buffer)));try{return{hash:n,...Go(t)}}catch{return{type:"Raw",hash:n,value:""}}});var Qo=Object.freeze({__proto__:null,AccountId:At,Bin:nn,Binary:He,BitSeq:On,Blake2128:Br,Blake2128Concat:Mo,Blake2256:Vt,Blake3256:Do,Blake3256Concat:Ul,Bytes:G,Enum:Bt,FixedSizeBinary:$n,Hex:ye,Identity:Vo,Option:dt,Result:_n,ScaleEnum:mr,Self:vr,Storage:qo,Struct:ie,TrieNodeHeaders:mt,TrieNodeWithHash:No,Tuple:Fe,Twox128:Rn,Twox256:jo,Twox64Concat:zo,Variant:Ee,Vector:Ie,_Enum:fo,_void:O,bitSequence:Wa,blockHeader:wr,bool:qc,char:qa,compact:pe,compactBn:Cn,compactNumber:C,createCodec:z,createDecoder:tt,decAnyMetadata:Sr,enhanceCodec:Ke,enhanceDecoder:wn,enhanceEncoder:gn,ethAccount:Eo,extrinsicFormat:Ir,fixedStr:Ya,fromBufferToBase58:eo,getMultisigAccountId:Dl,getSs58AddressInfo:dr,h64:vt,i128:jc,i16:Vc,i256:Wc,i32:Hc,i64:Fc,i8:Dc,metadata:pt,selfDecoder:uo,selfEncoder:lo,sortMultisigSignatories:Ko,str:F,trieNodeDec:Go,u128:ws,u16:Xe,u256:zc,u32:Ve,u64:Nt,u8:D,unifyMetadata:Dt,v14:To,v14Lookup:Tn,v15:Ro,v16:Po,validateProofs:(e,t=Vt)=>{const n=e.map(No(t)),r=Object.fromEntries(n.map(c=>[c.hash,c])),s=n.map(c=>c.hash),o=new Set(s),i=c=>{if(c.value)return;const l=e[s.indexOf(c.hash)];c.value=typeof l=="string"?l:J(l)};return n.forEach(c=>{if("children"in c&&Object.values(c.children).forEach(l=>{const a=r[l];a&&(a.parent=c.hash,o.delete(l))}),c.type==="BranchWithHash"||c.type==="LeafWithHash"){const l=c.value,a=r[l];if(!a)return;o.delete(l),a.type!=="Raw"&&(Object.keys(a).forEach(f=>delete a[f]),a.type="Raw",a.hash=l),a.parent=c.hash,i(a)}c.type==="Raw"&&i(c)}),o.size===1?{rootHash:o.values().next().value,proofs:r}:null}});const it=C,jl=Ie(Fe(F,it)),j={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},zl=Ee(Object.fromEntries(Object.values(j).map(e=>[e,O]))),Wl=Ie(Fe(F,Ee({inline:vr(()=>_r),lookup:it}))),ql=Ie(it),Kl=ie({typeRef:it,length:dt(it)}),Xl=dt(it),Yl=it,Gl=ie({ok:it,ko:it}),_r=Ee({struct:jl,terminal:zl,enum:Wl,tuple:ql,array:Kl,binary:Xl,option:Yl,result:Gl}),Nl={i256:j.big,i128:j.big,i64:j.big,i32:j.num,i16:j.num,i8:j.num,u256:j.big,u128:j.big,u64:j.big,u32:j.num,u16:j.num,u8:j.num,bool:j.bool,char:j.str,str:j.str},on=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return on(j.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 on(j.bits);case"compact":return on(e.isBig?j.big:j.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 on(Nl[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 on(j.void)}}function Or(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Or(o,i,n),s=o=>{switch(o.value.type){case j.str:case j.big:case j.bool:case j.num:return typeof e===o.value.type;case j.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case j.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof He&&(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 l=c[i.type];return l==null?!0:r(i.value,l.type==="inline"?l.value:n(l.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,f])=>r(e[a],n(f))):!1;case"tuple":return e?t.value.every((a,f)=>r(e[f],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 Ql=Object.defineProperty,Zl=(e,t,n)=>t in e?Ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jl=(e,t,n)=>Zl(e,t+"",n);class Zo{constructor(t=[]){Jl(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 Te=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Te||{});function Tr(e,t,n,r,s,o=!1){if(!n&&!e)return je(3,[]);if(!n)return je(2,[]);if(!e)return je(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const l=i.get(e);return l==null?{level:3,changes:[],assumptions:new Zo([[e,n]])}:je(l.level,l.changes)}i.set(e,null);const c=eu(e,n,(l,a)=>Tr(typeof l=="number"?t(l):l,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function eu(e,t,n,r){const s=(o,i,c)=>{const l=n(o,i);return{...l,changes:l.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:l.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Un(s(e,t.value,"some"),2):e.type==="option"?Un(s(e.value,t,"some"),1):je(0,[]);switch(t.type){case"terminal":return je(t.value.type===e.value.type?3:0,[]);case"binary":return Pr(ti(e.value,t.value));case"array":const i=e,c=Pr(ti(i.value.length,t.value.length));return Rr([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const u=e,d=Object.fromEntries(t.value.map(([m,y])=>[m,y.value]));let h=ei(u.value.map(([m,y])=>()=>m in d?s(y.value,d[m],m):je(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:m}])));if(u.value.length===t.value.length)return h;h=Un(h,2);const v=new Set(u.value.map(([m])=>m));return h.changes=[...h.changes,...t.value.filter(([m])=>!v.has(m)).map(([m,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:m}))],h}case"option":return tu(s(e.value,t.value,"some"),1);case"struct":const l=e,a=Object.fromEntries(l.value),f=l.value.length===t.value.length?3:2;return Un(Rr(t.value.map(([u,d])=>()=>s(a[u],d,u)),r),f);case"tuple":{const u=e,d=Pr(nu(u.value,t.value));return Rr([d,...t.value.map((h,v)=>()=>s(u.value[v],h,String(v)))],r)}case"result":const p=e;return ei([s(p.value.ok,t.value.ok,"ok"),s(p.value.ko,t.value.ko,"ko")])}}const Un=(e,t)=>({...e,level:Math.min(e.level,t)}),tu=(e,t)=>({...e,level:Math.max(e.level,t)}),Jo=new Zo,je=(e,t)=>({level:e,changes:t,assumptions:Jo}),Rr=(e,t)=>{let n=je(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},ei=e=>{if(!e.length)return je(3,[]);let t=!1,n=je(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:je(0,n.changes)},Pr=e=>({assumptions:Jo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),nu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ti=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,ni=Ee({lookup:C,typedef:_r}),Ht=e=>({type:"lookup",value:e}),Ur=e=>({type:"typedef",value:e}),Mn=Ur({type:"terminal",value:{type:j.void}}),ru=ie({args:ni,values:ni});function su(e){if(e.type.tag==="plain")return{args:Mn,values:Ht(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Ht(t),values:Ht(n)}}function ri(e){return{args:Ur({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Ht(e.output)}}function ou(e){return e.type==="lookupEntry"?Ht(e.value.id):Ur(Pn(e))}function iu(e){return{args:Mn,values:Ht(e)}}function cu(e,t,n,r,s,o){const i=(c,l)=>c.type==="lookup"?l(c.value):c.value;return{args:Tr(i(e.args,t),t,i(n.args,r),r,s,o),values:Tr(i(n.values,r),r,i(e.values,t),t,s,o)}}function si(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Or(n,r,t)}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 Ne(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 au(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(f){try{a(r.next(f))}catch(p){i(p)}}function l(f){try{a(r.throw(f))}catch(p){i(p)}}function a(f){f.done?o(f.value):s(f.value).then(c,l)}a((r=r.apply(e,t||[])).next())})}function oi(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(f){return l([a,f])}}function l(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(f){a=[6,f],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Ft(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 Re(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 Pe(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 jt(e){return this instanceof jt?(this.v=e,this):new jt(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(d){return function(h){return Promise.resolve(h).then(d,p)}}function c(d,h){r[d]&&(s[d]=function(v){return new Promise(function(m,y){o.push([d,v,m,y])>1||l(d,v)})},h&&(s[d]=h(s[d])))}function l(d,h){try{a(r[d](h))}catch(v){u(o[0][3],v)}}function a(d){d.value instanceof jt?Promise.resolve(d.value.v).then(f,p):u(o[0][2],d)}function f(d){l("next",d)}function p(d){l("throw",d)}function u(d,h){d(h),o.shift(),o.length&&l(o[0][0],o[0][1])}}function uu(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 Ft=="function"?Ft(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,l){i=e[o](i),s(c,l,i.done,i.value)})}}function s(o,i,c,l){Promise.resolve(l).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function K(e){return typeof e=="function"}function Lr(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 Dr=Lr(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 Ln(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var _t=(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=Ft(i),l=c.next();!l.done;l=c.next()){var a=l.value;a.remove(this)}}catch(v){t={error:v}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var f=this.initialTeardown;if(K(f))try{f()}catch(v){o=v instanceof Dr?v.errors:[v]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var u=Ft(p),h=u.next();!h.done;h=u.next()){var d=h.value;try{ci(d)}catch(v){o=o??[],v instanceof Dr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ci(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)&&Ln(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Ln(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),oi=_t.EMPTY;function ii(e){return e instanceof _t||e&&"closed"in e&&K(e.remove)&&K(e.add)&&K(e.unsubscribe)}function ci(e){K(e)?e():e.unsubscribe()}var fu={Promise:void 0},hu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ai(e){hu.setTimeout(function(){throw e})}function Ae(){}function Dn(e){e()}var cn=(function(e){Ne(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ii(n)&&n.add(r)):r.destination=vu,r}return t.create=function(n,r,s){return new zt(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})(_t),du=(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){Vn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Vn(r)}else Vn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Vn(n)}},e})(),zt=(function(e){Ne(t,e);function t(n,r,s){var o=e.call(this)||this,i;return K(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new du(i),o}return t})(cn);function Vn(e){ai(e)}function pu(e){throw e}var vu={closed:!0,next:Ae,error:pu,complete:Ae},Vr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Qe(e){return e}function li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ui(e)}function ui(e){return e.length===0?Qe:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=(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=yu(t)?t:new zt(t,n,r);return Dn(function(){var i=s,c=i.operator,l=i.source;o.add(c?c.call(o,l):l?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=fi(n),new n(function(s,o){var i=new zt({next:function(c){try{t(c)}catch(l){o(l),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Vr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ui(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=fi(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 fi(e){var t;return(t=e??fu.Promise)!==null&&t!==void 0?t:Promise}function mu(e){return e&&K(e.next)&&K(e.error)&&K(e.complete)}function yu(e){return e&&e instanceof cn||mu(e)&&ii(e)}function bu(e){return K(e?.lift)}function Q(e){return function(t){if(bu(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function X(e,t,n,r,s){return new gu(e,t,n,r,s)}var gu=(function(e){Ne(t,e);function t(n,r,s,o,i,c){var l=e.call(this,n)||this;return l.onFinalize=i,l.shouldUnsubscribe=c,l._next=r?function(a){try{r(a)}catch(f){n.error(f)}}:e.prototype._next,l._error=o?function(a){try{o(a)}catch(f){n.error(f)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,l}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(cn),wu=Lr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ue=(function(e){Ne(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 hi(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new wu},t.prototype.next=function(n){var r=this;Dn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Ft(r.currentObservers),c=i.next();!c.done;c=i.next()){var l=c.value;l.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;Dn(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;Dn(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?oi:(this.currentObservers=null,c.push(n),new _t(function(){r.currentObservers=null,Ln(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 U;return n.source=this,n},t.create=function(n,r){return new hi(n,r)},t})(U),hi=(function(e){Ne(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:oi},t})(Ue),xu=(function(e){Ne(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})(Ue),Hr={now:function(){return(Hr.delegate||Date).now()},delegate:void 0},Hn=(function(e){Ne(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Hr);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,l=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+l)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),l=0;l<c.length&&!n.closed;l+=o?1:2)n.next(c[l]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var l=s.now(),a=0,f=1;f<o.length&&o[f]<=l;f+=2)a=f;a&&o.splice(0,a+1)}},t})(Ue),Eu=(function(e){Ne(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(_t),di={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ku=(function(e){Ne(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),di.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&&di.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,Ln(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Eu),pi=(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=Hr.now,e})(),Au=(function(e){Ne(t,e);function t(n,r){r===void 0&&(r=pi.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})(pi),vi=new Au(ku),Su=vi,yt=new U(function(e){return e.complete()});function mi(e){return e&&K(e.schedule)}function Fr(e){return e[e.length-1]}function jr(e){return K(Fr(e))?e.pop():void 0}function an(e){return mi(Fr(e))?e.pop():void 0}function Bu(e,t){return typeof Fr(e)=="number"?e.pop():t}var yi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function bi(e){return K(e?.then)}function gi(e){return K(e[Vr])}function wi(e){return Symbol.asyncIterator&&K(e?.[Symbol.asyncIterator])}function xi(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 Iu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ei=Iu();function ki(e){return K(e?.[Ei])}function Ai(e){return lu(this,arguments,function(){var n,r,s,o;return si(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,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(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 K(e?.getReader)}function fe(e){if(e instanceof U)return e;if(e!=null){if(gi(e))return $u(e);if(yi(e))return Cu(e);if(bi(e))return _u(e);if(wi(e))return Bi(e);if(ki(e))return Ou(e);if(Si(e))return Tu(e)}throw xi(e)}function $u(e){return new U(function(t){var n=e[Vr]();if(K(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Cu(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function _u(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ai)})}function Ou(e){return new U(function(t){var n,r;try{for(var s=Ft(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 Bi(e){return new U(function(t){Ru(e,t).catch(function(n){return t.error(n)})})}function Tu(e){return Bi(Ai(e))}function Ru(e,t){var n,r,s,o;return au(this,void 0,void 0,function(){var i,c;return si(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=uu(e),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=l.sent(),s={error:c},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function bt(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),Q(function(n,r){n.subscribe(X(r,function(s){return bt(r,e,function(){return r.next(s)},t)},function(){return bt(r,e,function(){return r.complete()},t)},function(s){return bt(r,e,function(){return r.error(s)},t)}))})}function $i(e,t){return t===void 0&&(t=0),Q(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Pu(e,t){return fe(e).pipe($i(t),Ii(t))}function Uu(e,t){return fe(e).pipe($i(t),Ii(t))}function Mu(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Lu(e,t){return new U(function(n){var r;return bt(n,t,function(){r=e[Ei](),bt(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 K(r?.return)&&r.return()}})}function Ci(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){bt(n,t,function(){var r=e[Symbol.asyncIterator]();bt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Du(e,t){return Ci(Ai(e),t)}function Vu(e,t){if(e!=null){if(gi(e))return Pu(e,t);if(yi(e))return Mu(e,t);if(bi(e))return Uu(e,t);if(wi(e))return Ci(e,t);if(ki(e))return Lu(e,t);if(Si(e))return Du(e,t)}throw xi(e)}function gt(e,t){return t?Vu(e,t):fe(e)}function se(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return gt(e,n)}function Fn(e,t){var n=K(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var _i=Lr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Hu(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 _i)}})})}function ze(e,t){return new Promise(function(n,r){var s=new zt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new _i)}});e.subscribe(s)})}function Fu(e){return e instanceof Date&&!isNaN(e)}function B(e,t){return Q(function(n,r){var s=0;n.subscribe(X(r,function(o){r.next(e.call(t,o,s++))}))})}var ju=Array.isArray;function zu(e,t){return ju(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function Oi(e){return B(function(t){return zu(e,t)})}var Wu=Array.isArray,qu=Object.getPrototypeOf,Ku=Object.prototype,Xu=Object.keys;function Yu(e){if(e.length===1){var t=e[0];if(Wu(t))return{args:t,keys:null};if(Gu(t)){var n=Xu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Gu(e){return e&&typeof e=="object"&&qu(e)===Ku}function Nu(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Wt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=jr(e),s=Yu(e),o=s.args,i=s.keys;if(o.length===0)return gt([],n);var c=new U(Ti(o,n,i?function(l){return Nu(i,l)}:Qe));return r?c.pipe(Oi(r)):c}function Ti(e,t,n){return n===void 0&&(n=Qe),function(r){Ri(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,l=function(f){Ri(t,function(){var p=gt(e[f],t),u=!1;p.subscribe(X(r,function(h){o[f]=h,u||(u=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)l(a)},r)}}function Ri(e,t,n){e?bt(n,e,t):t()}function Qu(e,t,n,r,s,o,i,c){var l=[],a=0,f=0,p=!1,u=function(){p&&!l.length&&!a&&t.complete()},h=function(v){return a<r?d(v):l.push(v)},d=function(v){a++;var m=!1;fe(n(v,f++)).subscribe(X(t,function(y){t.next(y)},function(){m=!0},void 0,function(){if(m)try{a--;for(var y=function(){var b=l.shift();i||d(b)};l.length&&a<r;)y();u()}catch(b){t.error(b)}}))};return e.subscribe(X(t,h,function(){p=!0,u()})),function(){}}function P(e,t,n){return n===void 0&&(n=1/0),K(t)?P(function(r,s){return B(function(o,i){return t(r,o,s,i)})(fe(e(r,s)))},n):(typeof t=="number"&&(n=t),Q(function(r,s){return Qu(r,s,e,n)}))}function jn(e){return e===void 0&&(e=1/0),P(Qe,e)}function Zu(){return jn(1)}function zn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zu()(gt(e,an(e)))}function Wn(e){return new U(function(t){fe(e()).subscribe(t)})}var Ju={connector:function(){return new Ue},resetOnDisconnect:!0};function ef(e,t){t===void 0&&(t=Ju);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new U(function(l){return i.subscribe(l)});return c.connect=function(){return(!n||n.closed)&&(n=Wn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function qn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Su);var r=-1;return t!=null&&(mi(t)?n=t:r=t),new U(function(s){var o=Fu(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 ln(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=Bu(e,1/0),s=e;return s.length?s.length===1?fe(s[0]):jn(r)(gt(s,n)):yt}var tf=Array.isArray;function nf(e){return e.length===1&&tf(e[0])?e[0]:e}function Me(e,t){return Q(function(n,r){var s=0;n.subscribe(X(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Se(e){return Q(function(t,n){var r=null,s=!1,o;r=t.subscribe(X(n,void 0,void 0,function(i){o=fe(e(i,Se(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Pi(e,t,n,r,s){return function(o,i){var c=n,l=t,a=0;o.subscribe(X(i,function(f){var p=a++;l=c?e(l,f,p):(c=!0,f),r&&i.next(l)},s&&(function(){c&&i.next(l),i.complete()})))}}function rf(e,t){return Q(Pi(e,t,arguments.length>=2,!1,!0))}function Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return n?li(Ui.apply(void 0,Pe([],Re(e))),Oi(n)):Q(function(r,s){Ti(Pe([r],Re(nf(e))))(s)})}function sf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ui.apply(void 0,Pe([],Re(e)))}function of(e,t){return K(t)?P(e,t,1):P(e,1)}function Z(e){return e<=0?function(){return yt}:Q(function(t,n){var r=0;t.subscribe(X(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function cf(e){return B(function(){return e})}function af(e,t){return P(function(n,r){return fe(e(n,r)).pipe(Z(1),cf(n))})}function lf(e,t){t===void 0&&(t=vi);var n=qn(e,t);return af(function(){return n})}function uf(e,t){return Q(function(n,r){var s=new Set;n.subscribe(X(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&fe(t).subscribe(X(r,function(){return s.clear()},Ae))})}function be(e,t){return t===void 0&&(t=Qe),e=e??ff,Q(function(n,r){var s,o=!0;n.subscribe(X(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function ff(e,t){return e===t}function hf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return zn(n,se.apply(void 0,Pe([],Re(e))))}}function df(e,t){return Q(function(n,r){var s=0,o=null,i=!1;n.subscribe(X(r,function(c){o||(o=X(r,void 0,function(){o=null,i&&r.complete()}),fe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function pf(){return Q(function(e,t){var n,r=!1;e.subscribe(X(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Kn(e,t){return Q(Pi(e,t,arguments.length>=2,!0))}function Xn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Ue}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,l=c===void 0?!0:c;return function(a){var f,p,u,h=0,d=!1,v=!1,m=function(){p?.unsubscribe(),p=void 0},y=function(){m(),f=u=void 0,d=v=!1},b=function(){var x=f;y(),x?.unsubscribe()};return Q(function(x,g){h++,!v&&!d&&m();var w=u=u??n();g.add(function(){h--,h===0&&!v&&!d&&(p=zr(b,l))}),w.subscribe(g),!f&&h>0&&(f=new zt({next:function(k){return w.next(k)},error:function(k){v=!0,m(),p=zr(y,s,k),w.error(k)},complete:function(){d=!0,m(),p=zr(y,i),w.complete()}}),fe(x).subscribe(f))})(a)}}function zr(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 zt({next:function(){s.unsubscribe(),e()}});return fe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function un(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,Xn({connector:function(){return new Hn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Mi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return Q(function(r,s){(n?zn(e,r,n):zn(e,r)).subscribe(s)})}function Yn(e,t){return Q(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(X(r,function(l){s?.unsubscribe();var a=0,f=o++;fe(e(l,f)).subscribe(s=X(r,function(p){return r.next(t?t(l,p,f,a++):p)},function(){s=null,c()}))},function(){i=!0,c()}))})}function vf(){return Yn(Qe)}function Li(e){return Q(function(t,n){fe(e).subscribe(X(n,function(){return n.complete()},Ae)),!n.closed&&t.subscribe(n)})}function Wr(e,t){return t===void 0&&(t=!1),Q(function(n,r){var s=0;n.subscribe(X(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function fn(e,t,n){var r=K(e)||t||n?{next:e,error:t,complete:n}:e;return r?Q(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(X(o,function(l){var a;(a=r.next)===null||a===void 0||a.call(r,l),o.next(l)},function(){var l;c=!1,(l=r.complete)===null||l===void 0||l.call(r),o.complete()},function(l){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,l),o.error(l)},function(){var l,a;c&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Qe}function qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return Q(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),l=!1,a=function(p){fe(e[p]).subscribe(X(s,function(u){i[p]=u,!l&&!c[p]&&(c[p]=!0,(l=c.every(Qe))&&(c=null))},Ae))},f=0;f<o;f++)a(f);r.subscribe(X(s,function(p){if(l){var u=Pe([p],Re(i));s.next(n?n.apply(void 0,Pe([],Re(u))):u)}}))})}var mf=Object.defineProperty,yf=(e,t,n)=>t in e?mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Di=(e,t,n)=>yf(e,typeof t!="symbol"?t+"":t,n);class Vi extends Error{constructor(t){super(t.message),Di(this,"code"),Di(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Hi=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};class Kr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let bf=1;const gf=e=>{let t=bf++;const n=new Map,r=Hi();let s=null;const o=(f,p,u)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:f,method:p,params:u}))};function i(f){try{let p,u,h,d,v;if({id:p,result:u,error:h,params:d}=JSON.parse(f),p===null)throw new Error(d?.error?.message??"id null");if(p!=null){const b=n.get(p);return b?(n.delete(p),h?b.onError(new Vi(h)):b.onSuccess(u,(x,g)=>{const w=x;return r.subscribe(w,g),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:u,error:h}=d,!v||!h&&!Object.hasOwn(d,"result"))throw 0;const y=v;h?r.error(y,new Vi(h)):r.next(y,u)}catch(p){console.warn("Error parsing incomming message: "+f),console.error(p)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Kr),n.forEach(f=>f.onError(new Kr)),n.clear()};let l=1;return{request:(f,p,u)=>{if(!s)throw new Error("Not connected");const h=`${t}-${l++}`;return u&&n.set(h,u),o(h,f,p),()=>{n.delete(h)}},disconnect:c}};class Fi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Gn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Nn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ji extends Error{constructor(t){super(t),this.name="OperationError"}}class Qn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Le={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Zn={chainName:"",genesisHash:"",properties:""},Xr={broadcast:"",stop:""};Object.entries({chainHead:Le,chainSpec:Zn,transaction:Xr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class zi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class wf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class xf extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const qt=()=>{},Ef=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Xr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Xr.stop,[o]),s=qt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function kf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Kt=e=>(...t)=>new Promise((n,r)=>{let s=St;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new to)};i?.addEventListener("abort",c,{once:!0});const l=a=>f=>{s=St,i?.removeEventListener("abort",c),a(f)};s=e(l(n),l(r),...o)}),Wi=(e,t)=>n=>Kt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[l,a]=t(...o);return n(e,l,{onSuccess:(f,p)=>{if(f.result==="limitReached")return s(new Nn);const{operationId:u}=f,h=()=>{n(Le.stopOperation,[u])};if(!i)return h();let d=qt;const v=y=>{i=!1,d(),r(y)},m=y=>{i=!1,d(),s(y)};d=p(u,{next:y=>{const b=y;b.event==="operationError"?s(new ji(b.error)):b.event==="operationInaccessible"?s(new Qn):a(y,v,m)},error:m}),c=()=>{i&&(d(),h())}},onError:s}),()=>{c()}}),Af=Wi(Le.body,e=>[[e],(t,n)=>{n(t.value)}]),Sf=Wi(Le.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Bf=e=>t=>new Promise((n,r)=>{e(Le.header,[t],{onSuccess:n,onError:r})}),qi=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),St;let l=!0,a=()=>{l=!1};return e(Le.storage,[t,n,r],{onSuccess:(f,p)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return o(new Nn);const{operationId:u}=f,h=()=>{e(Le.stopOperation,[u])};if(!l)return h();const d=p(f.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{m();break}case"operationError":{v(new ji(y.error));break}case"operationInaccessible":{v(new Qn);break}default:e(Le.continue,[y.operationId])}},error:o});a=()=>{d(),e(Le.stopOperation,[f.operationId])};const v=y=>{a=St,d(),o(y)},m=()=>{a=St,d(),i()};c(f.discardedItems)},onError:o}),()=>{a()}},If=e=>{const t=qi(e);return Kt((n,r,s,o,i,c)=>{const l=o.startsWith("descendants");let a=l?[]:null;const p=t(s,[{key:i,type:o}],c??null,l?u=>{a.push(u)}:u=>{a=u[0]?.[o]},r,()=>{try{n(l?a.flat():a)}catch(u){r(u)}},u=>{u>0&&(p(),r(new Nn))});return p})},$f=e=>t=>t.length>0?new Promise((n,r)=>{e(Le.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function Cf(e){return e.operationId!==void 0}function _f(e){return(t,n,r)=>{const s=Hi(),o=new Set,i=kf();let c=i.promise,l=qt;const a=d=>{e(Le.unfollow,[d])},f=d=>{l(),c!==null&&(d&&(c instanceof Promise?c.then(v=>{typeof v=="string"&&a(v)}):a(c)),c=null,o.forEach(v=>{v()}),o.clear(),s.errorAll(new Gn))},p=d=>{if(Cf(d))return s.has(d.operationId)||console.warn("Uknown operationId on",d),s.next(d.operationId,d);switch(d.event){case"stop":return r(new Fi),f(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:v,...m}=d;return n({type:v,...m})}console.warn("Invalid event",d)},u=d=>{r(d),f(!(d instanceof Kr))};e(Le.follow,[t],{onSuccess:(d,v)=>{c instanceof Promise&&(c=d,l=v(d,{next:p,error:u})),i.res(d)},onError:d=>{c=null,i.res(d),r(d)}});const h=(d,v,m)=>{const y=()=>{m?.onError(new Gn)};if(c===null)return y(),qt;const b=g=>{if(!m)return e(d,[g,...v]);o.add(y);const w=($,E)=>c===null?(E.error(new Gn),qt):(s.subscribe($,E),()=>{s.unsubscribe($)}),k=e(d,[g,...v],{onSuccess:$=>{o.delete(y),m.onSuccess($,w)},onError:$=>{o.delete(y),m.onError($)}});return()=>{o.delete(y),k()}};if(typeof c=="string")return b(c);let x=qt;return c.then(g=>{if(g instanceof Error)return y();c&&(x=b(g))}),()=>{x()}};return{unfollow(){f(!0)},body:Af(h),call:Sf(h),header:Bf(h),storage:If(h),storageSubscription:qi(h),unpin:$f(h),_request:h}}}const Of=e=>{const t=Kt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(Zn.chainName,[]),t(Zn.genesisHash,[]),t(Zn.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Tf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),St;let c=!0,l=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,f)=>{const p=()=>{e("stopStorage",[a])};if(!c)return p();const u=f(a,{next:m=>{const{event:y}=m;if(y==="storage"){const{event:b,...x}=m;s(x)}else y==="storageDone"?v():d(new wf(m.error))},error:o}),h=()=>{l=St,u()};l=()=>{h(),p()};const d=m=>{h(),o(m)},v=()=>{h(),i()}},onError:o}),()=>{l()}},Rf=e=>Kt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let l=c?[]:null;const a=c?l.push.bind(l):({[s]:f})=>{l=f};return e(r,[{key:o,type:s}],i,a,f=>{n(f),l=null},()=>{t(l),l=null})}),Ki=()=>e=>e,Xi=()=>(e,t)=>{if(e===null)throw new zi(t);return e},Pf=e=>{const t=(f,...p)=>e(`archive_v1_${f}`,...p),n=f=>p=>Kt((u,h,...d)=>t(f,d,{onSuccess:v=>{try{u(p(v,...d))}catch(m){h(m)}},onError:h})),r=n("header")(Xi()),s=n("body")(Xi()),o=Tf(t),i=Rf(o),c=n("call")((f,p)=>{if(!f)throw new zi(p);if(!f.success)throw new xf(f.error);return f.value}),l=n("finalizedHeight")(Ki()),a=n("hashByHeight")(Ki());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:l,hashByHeight:a}},Jn=new Map,Uf=e=>{const t=Jn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=gf(e),s=()=>{const i=Jn.get(e);!i||i.refCount<=1?(Jn.delete(e),r()):i.refCount--},o={archive:Pf(n),chainHead:_f(n),transaction:Ef(n),getChainSpecData:Of(n),destroy:s,request:Kt((i,c,l,a)=>n(l,a,{onSuccess:i,onError:c})),_request:n};return Jn.set(e,{client:o,refCount:1}),o};var Mf=Object.defineProperty,Lf=(e,t,n)=>t in e?Mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yi=(e,t,n)=>Lf(e,typeof t!="symbol"?t+"":t,n);class Df{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 Vf=()=>{const e=new Map,t=(u,h)=>{e.set(u,()=>{e.delete(u),h()})},n=u=>{e.get(u)?.()},r=new Df,s=r.unshift.bind(r),o=r.push.bind(r),i=(u,h)=>{const d=h?s:o;t(u.source$,d(u))},c=()=>{const u=r.pop();u&&(e.delete(u.source$),l(u))},l=u=>{const{source$:h,observer:d}=u;let v=!1;const m=h.subscribe({next(y){d.next(y)},error(y){(v=y instanceof Nn)?i(u,!0):d.error(y)},complete(){d.complete()}});m.closed?v||c():t(h,()=>{m.unsubscribe(),c()})},a=(u=!1)=>h=>new U(d=>{const v={observer:d,source$:h};return r.isEmpty()?l(v):i(v,u),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:u=>(...h)=>f(u(...h))}};class Ze extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Hf=new Set(["best","finalized",null]),Gi=e=>{const t=e.pipe(Se(n=>n instanceof Qn?qn(750).pipe(of(()=>t)):Fn(()=>n)));return t},Ff=(e,t,n)=>r=>(s,...o)=>{if(!Hf.has(s))return Gi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(Z(1),P(l=>r(l,...o).pipe(n(l))),Se(l=>l instanceof Ze?c:Fn(()=>l)));return Gi(c)},Ot=e=>(...t)=>new U(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}}),jf=e=>t=>(...n)=>e()[t](...n);function hn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,l=!1;const a=()=>{l||(l=!0,c=o.subscribe({next:u=>i.next(u),error:u=>i.error(u),complete:()=>i.complete()}),c.add(()=>{l=!1,c=null}))};let f=!1;const p=e.subscribe({next:u=>{const h=u.blocks.get(r);h?h.recovering?c?.unsubscribe():a():f&&i.error(new Ze(r,n)),f=u.recovering},error:u=>i.error(u)});return()=>{p.unsubscribe(),c?.unsubscribe()}})}}const zf=(e,t)=>{const n=(r,s,o,i)=>new U(c=>e().storageSubscription(r,s,o??null,l=>{c.next(l)},l=>{c.error(l)},()=>{c.complete()},l=>{l>0&&c.next(n(r,s.slice(-l),o,!0))})).pipe(jn(),t(i));return n},Wf=e=>{const t=async(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return[o,i];const c=r.idx+Math.floor((s.idx-r.idx)/2),l={idx:c,id:await e(n[c])};if(l.id===r.id)return t(n,l,s);if(l.id===s.id)return t(n,r,l);const[a,[f,...p]]=await Promise.all([t(n,r,l),t(n,l,s)]);return[...a,...p]};return async n=>{if(n.length<2)return n;const r=n.length-1,[s]=n,o=n[r],[i,c]=await Promise.all([s,o].map(e));return i===c?[n[0]]:t(n,{idx:0,id:i},{idx:r,id:c})}},qf=(e,t)=>{const n=Wf(t);return r=>new U(s=>{let o=null;return r.subscribe({next(i){i.type==="initialized"?(o=[],Promise.all([e(i.finalizedBlockHashes[0]),n(i.finalizedBlockHashes)]).then(([c,l])=>{s.closed||(s.next({type:"initialized",finalizedBlockHashes:i.finalizedBlockHashes,runtimeChanges:new Set(l),number:c.number,parentHash:c.parentHash}),o.forEach(a=>{s.next(a)}),o=null)}).catch(c=>{s.closed||s.error(c)})):o?o.push(i):s.next(i)},error(i){s.error(i)},complete(){s.complete()}})})},Kf=e=>{let t=null,n=Ae;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=l=>r().header(l).then(wr.dec),o=async l=>r().storage(l,"hash","0x3a636f6465",null),i=ef(new U(l=>{t=e(!0,a=>{l.next(a)},a=>{t=null,l.error(a)}),n=()=>{l.complete(),t?.unfollow()}}).pipe(qf(s,o),Xf()));return{getHeader:s,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},Xf=()=>e=>new U(t=>{const n=new _t,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Fi?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),Yf=e=>J(Ve.enc(e)),Ni=G(),Gf=dt(Ni),Nf=Be(Ve).dec,Qi=e=>{const t=e("Metadata_metadata_versions","").pipe(B(Nf),Se(()=>se([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(B(Ni.dec)):e("Metadata_metadata_at_version",Yf(s)).pipe(B(o=>Gf.dec(o)))};return t.pipe(P(n))},Zi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},Qf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=f=>p=>{let u=n.get(p);if(u)return u;if(r.has(p)){const d={id:p};return n.set(p,d),d}r.add(p);const h=f(p);return u=n.get(p),u?Object.assign(u,h):(u={id:p,...h},n.set(p,u)),r.delete(p),u};let o=!0,i=!0;const c=s(f=>{const p=t(e[f]);if(p)return p;const{def:u,path:h,params:d}=e[f];if(u.tag==="composite"){if(u.value.length===0)return wt;if(u.value.length===1){const v=c(u.value[0].type);return o&&h.at(-1)==="AccountId32"&&Zi(v,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&Zi(v,20)?(i=!1,{type:"AccountId20"}):v}return l(u.value)}if(u.tag==="variant"){if(h.length===1&&h[0]==="Option"&&d.length===1&&d[0].name==="T"){const y=c(d[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(h.length===1&&h[0]==="Result"&&d.length===2&&d[0].name==="T"&&d[1].name==="E")return{type:"result",value:{ok:c(d[0].type),ko:c(d[1].type)}};if(u.value.length===0)return wt;const v={},m={};return u.value.forEach(y=>{const b=y.name;if(m[b]=y.docs,y.fields.length===0){v[b]={...wt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[b]={...l(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:m}}if(u.tag==="sequence")return{type:"sequence",value:c(u.value)};if(u.tag==="array"){const{len:v}=u.value,m=c(u.value.type);return!v||m.type==="void"?wt:v>1?{type:"array",value:m,len:u.value.len}:m}if(u.tag==="tuple")return u.value.length===0?wt:u.value.length>1?a(u.value.map(v=>c(v)),u.value.map(v=>e[v].docs)):c(u.value[0]);if(u.tag==="primitive")return{type:"primitive",value:u.value.tag};if(u.tag==="compact"){const v=c(u.value);return v.type==="void"?wt:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:u.tag,isLSB:(e[u.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),l=f=>{let p=!0;const u={},h={};return f.forEach((d,v)=>{p=p&&!!d.name;const m=d.name||v,y=c(d.type);y.type!=="void"&&(u[m]=y,h[m]=d.docs)}),p?{type:"struct",value:u,innerDocs:h}:a(Object.values(u),Object.values(h))},a=(f,p)=>{if(f.every(u=>u.id===f[0].id)&&p.every(u=>!u.length)){const[u]=f;return u.type==="void"?wt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:p}};return c},er=e=>{const t=Qf(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?{...wt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),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:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Zf=(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 l=e(r,s,o,...i);return o.delete(c),s.has(c)&&(l=n(l,s.get(c),r,...i)),s.set(c,l),l},Jf=nn(),Ji=Zf((e,t,n,r)=>{if(e.type==="primitive")return No[e.value];if(e.type==="void")return O;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return xo;if(e.type==="compact")return e.isBig?Cn:C;if(e.type==="bitSequence")return On(e.isLSB);const s=h=>Ji(h,t,n,r),o=(h,d)=>{const v=s(h);return d?Be(v,d):Be(v)},i=h=>Fe(...h.map(s)),c=h=>{const d=Object.fromEntries(Object.entries(h).map(([v,m])=>[v,s(m)]));return ie(d)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Jf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?nn(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 dt(s(e.value));if(e.type==="result")return _n(s(e.value.ok),s(e.value.ko));const l=Object.values(e.value).map(h=>{switch(h.type){case"void":return O;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,d)=>[h,l[d]])),f=Object.values(e.value).map(h=>h.idx),u=f.every((h,d)=>h===d)?Ee(a):Ee(a,f);return e.byteLength?eh(u,e.byteLength):u},vr,e=>e),ec=(e,t=At())=>{const n=new Map,r=s=>Ji(e(s),n,new Set,t);return s=>r(s)},eh=(e,t)=>{const n=G(t);return z(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},th=Ke(O,()=>{},()=>null),Yr=e=>{const{metadata:t}=e;let n=ec(e);const r=t.pallets.find(u=>u.name==="System")?.constants.find(u=>u.name==="SS58Prefix");let s;if(r)try{const u=n(r.type).dec(r.value);typeof u=="number"&&(s=u,n=ec(e,At(u)))}catch{}const o=new Map,i=(u,h)=>{let d=o.get(u);d||o.set(u,d=Wo(u));const v=t.pallets.find(E=>E.name===u).storage.items.find(E=>E.name===h),m=E=>E===O?th:E,y=(E,T,...M)=>{const W=d(...M),[,...q]=M;return{args:Fe(...q.map(([te])=>te)),keys:W,value:T,len:E,fallback:v.modifier===1?T.dec(v.fallback):void 0}};if(v.type.tag==="plain")return y(0,m(n(v.type.value)),h);const{key:b,value:x,hashers:g}=v.type.value,w=m(n(x)),k=g.map(E=>No[E.tag]),$=(()=>{if(k.length===1)return[[n(b),k[0]]];const E=e(b);switch(E.type){case"array":return k.map(T=>[n(E.value.id),T]);case"tuple":return E.value.map((T,M)=>[n(T.id),k[M]]);default:throw new Error("Invalid key type")}})();return y(k.length,w,h,...$)},c=u=>{switch(u.type){case"void":return O;case"lookupEntry":return n(u.value.id);case"tuple":return Fe(...Object.values(u.value).map(h=>n(h.id)));case"struct":return ie(Mt(u.value,h=>n(h.id)));case"array":return Be(n(u.value.id),u.len)}},l=(u,h)=>{const d=t.pallets.find(v=>v.name===u).constants.find(v=>v.name===h);return n(d.type)},a=u=>(h,d)=>{const v=t.pallets.find(b=>b.name===h),m=e(v[u].type);if(m.type!=="enum")throw null;const y=m.value[d];return{location:[v.index,y.idx],codec:c(m.value[d])}},f=(u,h)=>{const d=t.pallets.find(v=>v.name===u)?.viewFns.find(v=>v.name===h);if(!d)throw null;return{args:Fe(...d.inputs.map(v=>n(v.type))),value:n(d.output)}},p=(u,h)=>{const d=t.apis.find(v=>v.name===u)?.methods.find(v=>v.name===h);if(!d)throw null;return{args:Fe(...d.inputs.map(v=>n(v.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:f,buildRuntimeCall:p,buildCall:a("calls"),buildConstant:l,ss58Prefix:s}},tc="CheckMortality",nc=(e,t,n)=>{const r=er(e),s=Yr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(f=>f.identifier==="ChargeAssetTxPayment");let c=null;if(i){const f=r(i.type);if(f.type==="struct"){const p=f.value.asset_id;p.type==="option"&&(c=p.value.id)}}const l=sh(r.metadata,s),a=f=>{const p=l(f);return"extra"in p&&p.extra[tc]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:At(s.ss58Prefix),getMortalityFromTx:a}},Gr=G(1/0).dec,nh=wn(Xe[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),rh=tt(e=>{const t=D.dec(e);if(t===0)return{mortal:!1};const n=D.dec(e);return nh(Uint8Array.from([t,n]))}),sh=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===tc?rh:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,l=c?.find(p=>p.name==="Call")?.type,a=c?.find(p=>p.name==="Address")?.type,f=c?.find(p=>p.name==="Signature")?.type;if(l==null||a==null||f==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(f)[1]}const i=ie.dec({address:r,signature:s,extra:ie.dec(n),callData:Gr});return tt(c=>{const l=C.dec(c),{type:a,version:f}=Br[1](c);if(a==="bare")return{len:l,version:f,type:a,callData:Gr(c)};if(a==="signed")return{len:l,version:f,type:a,...i(c)};const p=D.dec(c);let u;if(e.version===16){const d=e.extrinsic.signedExtensionsByVersion.find(([v])=>v===p);if(!d)throw new Error("Unexpected extension version");u=ie.dec(Object.fromEntries(Object.entries(n).filter((v,m)=>d[1].includes(m))))}else u=ie.dec(n);const h=u(c);return{len:l,type:a,version:f,extensionVersion:p,extra:h,callData:Gr(c)}})},oh=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe(Se(o=>{if(o instanceof Ze)return n(...r);if(o instanceof Qn)return qn(750).pipe(P(()=>n(...r)));throw o})):yt};return n},ih=(e,t,n,r)=>{const s=(o,i)=>o.pipe(P(c=>n(c).pipe(Se(()=>se(null)),P(l=>l?se(l):i.pipe(fn(a=>{r(c,a)}))),B(l=>({codeHash:c,metadataRaw:l,metadata:Dt(pt.dec(l))})))));return o=>{const i=oh(o),c=o(),l=new Set([c]),a=i(t)().pipe(un(1)),f=s(a,Qi(i(e))).pipe(B(({metadata:u,metadataRaw:h,codeHash:d})=>nc(u,h,d)),un(1)),p={at:c,runtime:f,codeHash$:a,addBlock:u=>(l.add(u),p),deleteBlocks:u=>(u.forEach(h=>{l.delete(h)}),l.size),usages:l};return f.subscribe({error(){}}),p}},dn=Xn({connector:()=>new Hn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),rc=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},sc=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},ch=(e,t)=>{t.forEach(n=>{sc(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]})},ah=(e,t,n,r,s,o,i,c,l)=>{const a=d=>{i.next(d)},f=new Ue,p=f.pipe(df(()=>qn(0)),B(()=>({type:"cleanup"}))),u=ln(o,p,e).pipe(Kn((d,v)=>{const m=y=>{ch(d,y),c(y)};switch(v.type){case"initialized":d.recovering&&!v.finalizedBlockHashes.some(w=>d.blocks.has(w))&&(d=oc());const y=d.blocks.get(d.finalized)?.number??-1,b=v.finalizedBlockHashes.length-1;d.finalized=d.best=v.finalizedBlockHashes[b];let x=d.finalizedRuntime.at;const g=[];return v.finalizedBlockHashes.forEach((w,k)=>{const $=k!==b,E=d.blocks.get(w);if(E)E.recovering=!1,E.unpinnable=$;else{const T=v.number+k,M=T>y,W=v.runtimeChanges.has(w)&&!d.runtimes[w]&&M;W&&(x=w);const q=k===0?v.parentHash:v.finalizedBlockHashes[k-1];d.blocks.set(w,{hash:w,parent:q,children:new Set(k===b?[]:[v.finalizedBlockHashes[k+1]]),unpinnable:$,runtime:x,refCount:0,number:T,recovering:!1}),W&&(d.finalizedRuntime=d.runtimes[w]=h(rc(d,w))),d.runtimes[x].usages.add(w),M&&g.push({hash:w,number:T,parent:q})}}),g.forEach(a),d;case"stop-error":for(const w of d.blocks.values())w.recovering=!0;return d.recovering=!0,d;case"newBlock":{const{parentBlockHash:w,blockHash:k}=v;if(d.blocks.has(k))d.blocks.get(k).recovering=!1;else{const $=d.blocks.get(w);$.children.add(k);const E=$.number+1,T={hash:k,number:E,parent:w,children:new Set,runtime:v.newRuntime?k:$.runtime,unpinnable:!1,refCount:0,recovering:!1};d.blocks.set(k,T),v.newRuntime&&(d.runtimes[k]=h(rc(d,k))),d.runtimes[T.runtime].addBlock(k),a({hash:k,number:E,parent:w})}return d}case"bestBlockChanged":{if(d.recovering){for(const[w,k]of d.blocks)k.recovering&&(sc(d.blocks,w),l(w));d.recovering=!1}return d.best=v.bestBlockHash,d}case"finalized":{d.finalized=v.finalizedBlockHashes.slice(-1)[0];const{blocks:w}=d;w.get(d.best).number<w.get(d.finalized).number&&(d.best=d.finalized),d.finalizedRuntime=d.runtimes[w.get(d.finalized).runtime],v.prunedBlockHashes.forEach($=>{const E=d.blocks.get($);E&&(E.unpinnable=!0)});let k=w.get(w.get(d.finalized).parent);for(;k&&!k.unpinnable;)k.unpinnable=!0,k=w.get(k.parent);return f.next(),d}case"cleanup":{const w=[...d.blocks.values()].filter(({unpinnable:k,refCount:$})=>k&&!$).map(({hash:k})=>k);return m(w),d}case"blockUsage":{if(!d.blocks.has(v.value.hash))return d;const w=d.blocks.get(v.value.hash);if(w.refCount+=v.value.type==="hold"?1:-1,w.refCount===0&&!w.recovering&&w.unpinnable){const k=[w.hash];m(k)}return d}}},oc()),Me(d=>!!d.finalizedRuntime.runtime),B(d=>({...d})),fn({error(d){i.error(d)}}),dn),h=ih(hn(u,t,"pinned-blocks"),hn(u,n,"pinned-blocks"),r,s);return u},oc=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ic=(e,t,n,r)=>{const s=c=>Li(e.pipe(Me(({blocks:l})=>!l.has(c)))),o=(c,l,a)=>{if(a)return se({hash:c,found:{type:!1,validity:null}});const f=s(c);return t(c).pipe(P(p=>{const u=p.indexOf(l);return u>-1?f(r(c)).pipe(B(h=>({hash:c,found:{type:!0,index:u,events:h}}))):n(c,l).pipe(B(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},i=(c,l,a)=>o(c,l,a.has(c)).pipe(P(f=>{const{found:p}=f;return p.type||p.validity?.success===!1?se(f):e.pipe(s(c),P(u=>u.blocks.get(c).children),uf(),P(u=>i(u,l,a)))}));return c=>e.pipe(Z(1),P(l=>i(l.finalized,c,new Set(l.blocks.keys()))))},lh=new Uint8Array([2]),uh=(e,t)=>J(oe([lh,me(e),me(t)])),cc="TaggedTransactionQueue",ac="validate_transaction",[,fh]=Ee({InvalidTransaction:Ee({Call:O,Payment:O,Future:O,Stale:O,BadProof:O,AncientBirthBlock:O,ExhaustsResources:O,Custom:D,BadMandatory:O,MandatoryValidation:O,BadSigner:O}),UnknownTransaction:Ee({CannotLookup:O,NoUnsignedValidator:O,Custom:D})}),hh=tt(e=>{const t=D.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=fh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),dh=(e,t)=>(n,r)=>{const s=t(n).pipe(B(o=>{try{return o.dynamicBuilder.buildRuntimeCall(cc,ac).value[1]}catch{return hh}}));return e(n,`${cc}_${ac}`,uh(r,n)).pipe(qr(s),B(([o,i])=>i(o)))},ph=e=>t=>new U(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}),vh=e=>t=>new U(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)}}),lc=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let l=0,a=0,f=0;const p=()=>{const u=o.get(a);if(!u){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),f!==h&&c.set(h,[]);let d=!1,v=u.subscribe({next(m){f===h?r.next(m):c.get(h).push(m)},complete(){if(d=!0,i.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(m=>r.next(m)),c.delete(f),!i.has(f));)f++;p()},error(m){r.error(m)}});d||i.set(h,v)};return s=new _t,s.add(n.subscribe({next(u){const h=l++;o.set(h,Wn(()=>e(u,h))),i.size<t&&p()},error(u){r.error(u)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(u=>u.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Nr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),mh=(e,t,n)=>{const{getFollower:r,startFollow:s,follow$:o,getHeader:i}=Kf(e),c=jf(r),{withRecovery:l,withRecoveryFn:a}=Vf(),f=new Ue,p=A=>I=>new U(_=>{f.next({type:"blockUsage",value:{type:"hold",hash:A}});const V=I.subscribe(_);return V.add(()=>{setTimeout(()=>{f.next({type:"blockUsage",value:{type:"release",hash:A}})},0)}),V}),u=A=>(I,..._)=>A(I,..._).pipe(p(I)),h=(A,I)=>(_,...V)=>new U(de=>{let ae=!1;return g.pipe(Z(1)).subscribe(We=>{ae=We.blocks.has(_)}),ae?A(_,...V).subscribe(de):de.error(new Ze(_,I))}),d=A=>r().unpin(A).catch(I=>{if(!(I instanceof Gn))throw I}),v=(A,I)=>h(u(hn(g,a(Ot(A)),`stop-${I}`)),I),m=new Map,y=u(a(Ot(c("storage")))),b=A=>y(A,"hash","0x3a636f6465",null).pipe(B(I=>I)),x=new Ue,g=ah(o,u(a(Ot(c("call")))),b,t,n,f,x,A=>{d(A).catch(I=>{console.error("unpin",I)}),A.forEach(I=>{m.delete(I)})},A=>{m.delete(A)}),w=h(u(A=>g.pipe(Z(1),P(I=>I.runtimes[I.blocks.get(A).runtime].runtime))),"getRuntimeCtx"),k=A=>I=>I.pipe(lc(_=>w(A(_)).pipe(B(V=>[_,V])))),$=(A,I,_)=>{const V=m.get(A)??new Map,de=V.get(I);if(de)return de;m.set(A,V);let ae;const We=_.pipe(Xn({connector:()=>ae=new Hn}),fn({complete(){V.set(I,ae)}}),vh());return V.set(I,We),We},E=g.pipe(Me(A=>!A.recovering),be((A,I)=>A.finalized===I.finalized),Kn((A,I)=>{let _=I.blocks.get(I.finalized);const V=[_],de=A.at(-1);if(!de)return V;for(;_.number>de.number+1&&(_=I.blocks.get(_.parent),!!_);)V.unshift(_);return V},[]),jn(),B(Nr),dn),T=g.pipe(be((A,I)=>A.best===I.best),B(A=>Nr(A.blocks.get(A.best))),dn),M=g.pipe(Me(A=>!A.recovering),be((A,I)=>A.finalized===I.finalized&&A.best===I.best),Kn((A,I)=>{const _=De=>A.get(De)||Nr(I.blocks.get(De)),V=_(I.best),de=_(I.finalized),ae=V.number-de.number+1,We=new Array(ae);for(let De=0,Rc=V.hash;De<ae;De++)We[De]=_(Rc),Rc=We[De].parent;return new Map(We.map(De=>[De.hash,De]))},new Map),B(A=>[...A.values()]),dn),W=g.pipe(be((A,I)=>A.finalizedRuntime===I.finalizedRuntime),Yn(({finalizedRuntime:{runtime:A}})=>A.pipe(ph(null))),dn),q=W.pipe(B(A=>A?.lookup.metadata??null)),te=Ff(E.pipe(B(A=>A.hash)),T.pipe(B(A=>A.hash)),p),Y=v(c("body"),"body"),he=A=>$(A,"body",Y(A)),ge=v(c("storage"),"storage"),ce=te(h((A,I,_,V=null,de)=>g.pipe(Z(1),P(ae=>ae.runtimes[ae.blocks.get(A).runtime].runtime),P(ae=>{const We=_(ae);return $(A,`storage-${I}-${We}-${V??""}`,ge(A,I,We,V)).pipe(de?B(De=>de(De,ae)):Qe)})),"storage")),et=zf(r,l),ir=te(h(hn(g,(A,I,_)=>et(A,I,_??null,!1),"storageQueries"),"storageQueries")),mn=te(h(hn(g,A=>Wn(()=>i(A)),"header"),"header")),cr=A=>ce(A,"value",I=>I.events.key,null,(I,_)=>_.events.dec(I)),bd=v(c("call"),"call"),_c=te((A,I,_)=>$(A,`call-${I}-${_}`,bd(A,I,_))),hs=dh(_c,w),Oc=A=>$(A,"body",Y(A)),gd=ic(g,Oc,hs,cr),wd=ic(g,Oc,hs,()=>se()),xd=W.pipe(Me(Boolean),Z(1),P(A=>{const{enc:I}=A.dynamicBuilder.buildStorage("System","BlockHash").keys;let _;try{_=I(0)}catch{_=I(0n)}return ce(null,"value",()=>_,null)}),un(1));ln(W,M).subscribe({error(){}});let ds=Ae,yn=!1,ps=0;const Ed=A=>{ps+=A,yn=!0,ds=s()},kd=A=>g.pipe(Z(1),P(({runtimes:I})=>ln(...Object.values(I).map(_=>_.codeHash$.pipe(P(V=>A===V?_.runtime:yt)))).pipe(hf(null),Z(1)))),Tc=(A,I=!1)=>{let _=A||"finalized",V=!1;if(yn&&g.pipe(Z(1)).subscribe(ae=>{_=ae[_]||_,V=ae.blocks.has(_)}),!V){if(I)throw new Ze(_,"holdBlock");return Ae}f.next({type:"blockUsage",value:{type:"hold",hash:_}});let de=()=>{f.next({type:"blockUsage",value:{type:"release",hash:_}}),de=Ae};return()=>{de()}};return[{follow$:o,finalized$:E,best$:T,bestBlocks$:M,newBlocks$:x,runtime$:W,metadata$:q,genesis$:xd,getRuntime$:kd,header$:mn,body$:he,call$:_c,storage$:ce,storageQueries$:ir,eventsAt$:cr,withHodl:A=>I=>new U(_=>{const V=I.subscribe(_);return V.closed||V.add(Tc(A)),V}),holdBlock:Tc,trackTx$:gd,trackTxWithoutEvents$:wd,validateTx$:hs,pinnedBlocks$:g,withRuntime:k,getRuntimeContext$:te(w),unfollow:()=>{yn!=null&&(ps--,yn&&!ps&&(yn=null,ds(),ds=Ae))}},Ed]};var yh=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const bh=({storageSubscription:e,...t})=>n=>{const r={},s=Ot(t.storage),o=Ot(t.call),i=Ot(t.header),c=Ot(t.body),l=v=>i(v).pipe(B(wr[1])),a=v=>s(v,"hash","0x3a636f6465",null).pipe(B(m=>m)),f=(v,m)=>n(v).pipe(Se(()=>se(null)),P(y=>y?se(y):Qi((...b)=>o(m,...b)).pipe(B(b=>nc(Dt(pt.dec(b)),b,v)))),fn(y=>{r[v]=y})),p=v=>a(v).pipe(P(m=>{const y=r[m];return y?se(y):f(m,v)})),u=(v,m,y,b=null,x)=>p(v).pipe(P(g=>s(v,m,y(g),b).pipe(B(w=>x?x(w,g):w))));return{body$:c,header$:l,storage$:u,storageQueries$:(v,m,y)=>new U(b=>e(v,m,y||null,x=>b.next(x),x=>b.error(x),()=>{b.complete()})),call$:o,eventsAt$:v=>u(v,"value",m=>m.events.key,null,(m,y)=>y.events.dec(m)),getRuntimeContext$:p}},gh=()=>se(null),tr=new Map,wh=(e,t={})=>{const{getMetadata:n,setMetadata:r}=t,s=tr.get(e);if(s)return s.refCount++,s.client;const o=()=>{const f=tr.get(e);!f||f.refCount<=1?(tr.delete(e),e.destroy()):f.refCount--};let i=null,c=0,l=null;const a={chainHead$:f=>{c++,l||(l=f||1),i||(i=mh(e.chainHead,n||gh,r||Ae));const[p,u]=i;if(l===c){const h=c;c=0,l=null,i=null,u(h)}return p},archive:bh(e.archive),broadcastTx$:yh(e.transaction),destroy:o};return tr.set(e,{client:a,refCount:1}),a},xh=(e,t)=>e.pipe(Wr(n=>n.blocks.has(t)),be((n,r)=>n.finalized===r.finalized&&n.best===r.best),B(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}),be(),Wr(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(Se(s=>{if(!(s instanceof Ze))throw s;return t(n,...r).pipe(Se(o=>{throw console.warn(o),s}))}));class Rt{constructor(){}_runtime(t){}}class Qr{constructor(){}_compatibility(t){}}const nr=new WeakMap,uc=new WeakMap,rr=e=>e instanceof Rt?uc.get(e):nr.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(xt||{});const Eh=Be(ru),kh=Be(_r),Ah=Fe(Eh,kh),Sh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Me(i=>i!=null));let o=await ze(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Ah.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Qr;return nr.set(c,{runtime:i,getEntryPoint(l,a,f){const p=o[l]?.[a]?.[f];if(p==null)throw new Error(`Descriptor for ${l} ${a}.${f} does not exist`);return r[p]},typedefNodes:s}),c})},Bh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(s=>s!=null));let r=await ze(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Rt;return uc.set(n,{runtime:t}),n}),Zr=new WeakMap,fc=e=>(Zr.has(e.metadataRaw)||Zr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Zr.get(e.metadataRaw)),Pt=(e,t,n)=>{const r=(i,c)=>{var l;const a=fc(i);return(l=a.typeNodes)[c]||(l[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Rt)return{args:Te.Identical,values:Te.Identical};const l=nr.get(i);c||(c=l.runtime());const a=n(c);if(a==null)return{args:Te.Incompatible,values:Te.Incompatible};const f=l.typedefNodes,p=fc(c),u=t(l),h=cu(u,d=>f[d],a,d=>r(c,d),p.compat);return{args:h.args.level,values:h.values.level}}const o=dc(e,i=>hc(s(i)));return{isCompatible:dc(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>l=>Wt([l.pipe(i.withRuntime(c)),e]).pipe(B(([[a,f],p])=>[a,p,f])),compatibleRuntime$:(i,c)=>Wt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,l)=>{if(i instanceof Rt)return!0;const a=s(i,c);if(a.args===Te.Incompatible)return!1;if(a.args>Te.Partial)return!0;if(a.values===Te.Incompatible)return!1;const f=n(c);return f==null?!1:ri(f.args,p=>r(c,p),l)},valuesAreCompatible:(i,c,l)=>{if(i instanceof Rt)return!0;const a=s(i,c).values;if(a===Te.Incompatible)return!1;if(a>Te.Partial)return!0;const f=nr.get(i),p=t(f);return ri(p.values,u=>f.typedefNodes[u],l)},getRuntimeTypedef:r}},hc=e=>Math.min(e.args,e.values),dc=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Qr||r instanceof Rt?t(...n):e.then(s=>t(...n,s))},Ih=(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 f=a.lookup.metadata.pallets.find(u=>u.name===e)?.constants.find(u=>u.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const p=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return i.set(a,p),p},l=a=>{if(a){const f=rr(a).runtime(),p=c(f);if(!n(a,f,p))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return p}return r.then(l)};return Object.assign(l,{isCompatible:s,getCompatibilityLevel:o})},$h=Xn({connector:()=>new Hn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function pn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new to)}:Ae;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 Jr=Symbol("EMPTY_VALUE"),es=e=>t=>new U(n=>{let r=0,s=null,o=Jr,i=!1;const c=()=>{const a=e(o,r++);o=Jr,s=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){o!==Jr?c():(s=null,i&&n.complete())}})},l=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),l.unsubscribe()}});let pc={};const Ch=e=>t=>new U(n=>{let r=pc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===pc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Xt=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)),_h=()=>{const e=new xu(new Ue);return[e.pipe(vf()),()=>fn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Ue)},complete:()=>{e.value.complete(),e.next(new Ue)}})]},Oh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,f=>f.hash),B(([f,p,u])=>{const h=u.lookup.metadata.pallets.find(d=>d.name===e)?.events?.type;if(h==null||u.lookup.metadata.lookup[h].def.tag!=="variant"||u.lookup.metadata.lookup[h].def.value.find(d=>d.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(p,u,null))throw l();return[f,p,u]}),lc(([f,p,u])=>n.eventsAt$(f.hash).pipe(B(h=>h.filter(d=>d.event.type===e&&d.event.value.type===t).map(d=>{if(!c(p,u,d.event.value.value))throw l();return{meta:{phase:d.phase,block:f},payload:d.event.value.value}})))),$h);return{watch:f=>a.pipe(P(p=>f?p.filter(u=>f(u.payload)):p)),pull:()=>ze(a),filter:f=>f.filter(p=>p.type===e&&p.value.type===t).map(p=>p.value.value),getCompatibilityLevel:s,isCompatible:r}},Th=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${l})`);return Object.assign((...f)=>{const p=f[f.length-1],u=Xt(p),{signal:h,at:d}=u?p:{},v=d??null,m=o(n,v).pipe(P(([y,b])=>{let x;try{x=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${l}) not found`)}if(!i(y,b,f))throw a();return n.call$(v,l,J(x.args.enc(f))).pipe(B(x.value.dec),B(g=>{if(!c(y,b,g))throw a();return g}))}),n.withHodl(v));return pn(m,h)},{getCompatibilityLevel:s,isCompatible:r})},vc=B(e=>e.mapped),Rh=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:l,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",p=e==="System"&&t==="BlockHash",u=n.runtime$.pipe(Me(Boolean),Z(1),B(({dynamicBuilder:E})=>typeof E.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Qe),un()),h=li(sf(u),B(([E,T])=>T(E))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=E=>new Error(`Invalid Arguments calling ${e}.${t}(${E})`),m=E=>{try{return E.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...E)=>{const T=E[E.length-1],M=T==="best",W=M||T==="finalized"?E.slice(0,-1):E;return n[M?"best$":"finalized$"].pipe(es(()=>b(...W,M?{at:"best"}:{})),be((q,te)=>q.raw===te.raw),vc)},b=(...E)=>{const T=E[E.length-1],M=Xt(T),{at:W}=M?T:{},q=W??null,te=gt(c).pipe(P(Y=>n.storage$(q,"value",he=>{const ge=m(he),ce=E.length===ge.len?E:E.slice(0,-1);if(E!==ce&&!M)throw v(E);if(!l(Y,he,ce))throw d();return ge.keys.enc(...ce)},null,(he,ge)=>{const ce=m(ge),et=he===null?ce.fallback:ce.value.dec(he);if(!a(Y,ge,et))throw d();return{raw:he,mapped:et}})),n.withHodl(q));return f?n.pinnedBlocks$.pipe(B(Y=>{const he=q==="finalized"||!q?Y.finalized:q==="best"?Y.best:q,ge=Y.blocks.get(he);if(!ge)throw new Ze(he,"System.Number");return ge.number}),be(),h,B(Y=>({raw:Y.toString(),mapped:Y})),Se(Y=>{if(Y instanceof Ze)return te;throw Y})):p&&Number(E[0])===0?n.genesis$.pipe(B(Y=>({raw:Y,mapped:$n.fromHex(Y)}))):te},x=async(...E)=>{const T=E[E.length-1],M=Xt(T),{signal:W}=M?T:{};return pn(b(...E).pipe(vc),W)},g=async(...E)=>{const T=E[E.length-1],M=Xt(T),{signal:W,at:q}=M?T:{},te=q??null,Y=gt(c).pipe(P(he=>n.storage$(te,"descendantsValues",ge=>{const ce=m(ge);if(hc(i(he,ge))===Te.Incompatible)throw d();if(E.length>ce.len)throw v(E);const et=E.length>0&&M?E.slice(0,-1):E;if(E.length===ce.len&&et===E)throw v(E);return ce.keys.enc(...et)},null,(ge,ce)=>{const et=m(ce),ir=ge.map(({key:mn,value:cr})=>({keyArgs:et.keys.dec(mn),value:et.value.dec(cr)}));if(ir.some(({value:mn})=>!a(he,ce,mn)))throw d();return ir})),n.withHodl(te));return pn(Y,W)},w=(E,T)=>Promise.all(E.map(M=>x(...T?[...M,T]:M))),k=(...E)=>{const T=E.at(-1),M=Xt(T);return r(e,t,M?E.slice(0,-1):E,M&&T.at==="best")},$=(...E)=>{const T=E.at(-1);if(T instanceof Qr||T instanceof Rt){const M=E.slice(0,-1),W=rr(T).runtime();if(!l(T,W,M))throw d();return m(W).keys.enc(...M)}return c.then(M=>$(...E,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:$,getValue:x,getValues:w,getEntries:g,watchValue:y,watchEntries:k}},ts=()=>new Error("Unkown signer"),Ph=e=>{const{extrinsic:t}=e,n=er(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 ts()}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 ts();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 ts()},Uh={Ed25519:0,Sr25519:1,Ecdsa:2},Mh=(e,t,n,r,s,o)=>{const[i,c]=Ph(e),l=oe([Br.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Uh[o],...n]),...r,s]);return oe([pe.enc(l.length),l])},[sr,vn]=["<Bytes>","</Bytes>"].map(e=>He.fromText(e).asBytes()),Lh=e=>async t=>{let n=!0,r;for(r=0;n&&r<sr.length;r++)n=sr[r]===t[r];n=n&&r===sr.length;const s=t.length-vn.length;for(r=0;n&&r<vn.length;r++)n=vn[r]===t[s+r];return n=n&&r===vn.length,e(n?t:oe([sr,t,vn]))};function Dh(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,l=Vt)=>{const a=Dt(Sr(i)),f=[],p=[];a.extrinsic.signedExtensions.map(({identifier:d})=>{const v=o[d];if(!v)throw new Error(`Missing ${d} signed extension`);f.push(v.value),p.push(v.additionalSigned)});const u=oe([s,...f,...p]),h=await n(u.length>256?l(u):u);return Mh(a,e,h,f,s,t)},signBytes:Lh(n)}}Uint8Array.from([1]);const Vh=(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 Hh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Fh=e=>1<<Math.ceil(Math.log2(e)),jh=gn(G(2)[0],e=>{const t=Math.min(Math.max(Fh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Hh(t)-1,1),15),o=n/r<<4;return Xe[0](s|o)}),[zh]=ie({tip:pe,asset:dt(G(1/0))}),mc=new Uint8Array,ns=Uint8Array.from([0]),rs=e=>({value:e,additionalSigned:mc}),ss=e=>({value:mc,additionalSigned:e}),os=(e,t)=>({value:e,additionalSigned:t}),yc=(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={},...l})=>{const a=[],f=Vh(t,n),p=h=>{const[d,v]=r[h],m=c[h];try{return Mt({value:d,additionalSigned:v},(y,b)=>{const x=m?.[b];return x instanceof Uint8Array?x:y(x)})}catch{return a.push(h),null}},u=Mt(r,([h,d],v)=>{if(c[v])return p(v);switch(v){case"CheckNonce":return rs(h(i));case"CheckMortality":return s.mortal?os(jh({period:s.period,startAtBlock:s.startAtBlock.height}),me(s.startAtBlock.hash)):os(ns,e);case"ChargeTransactionPayment":return rs(h(o));case"ChargeAssetTxPayment":return rs(zh({tip:o,asset:l.asset}));case"CheckGenesis":return ss(e);case"CheckMetadataHash":return os(ns,ns);case"CheckSpecVersion":return ss(d(f.spec_version));case"CheckTxVersion":return ss(d(f.transaction_version));default:return p(v)}});return a.forEach(h=>{delete u[h]}),Mt(u,(h,d)=>({...h,identifier:d}))}},bc="AccountNonceApi_account_nonce",Wh={1:D.dec,2:Xe.dec,4:Ve.dec,8:Nt.dec},qh=(e,t,n)=>e(n,bc,t).pipe(B(r=>{const s=me(r),o=Wh[s.length];if(!o)throw new Error(`${bc} retrieved wrong data`);return o(s)})),Kh=(e,t,n,r,s,o={})=>Wt([o.nonce?se(o.nonce):Xh(e,J(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(Z(1),P(([i,c,l])=>{const a=yc(me(l),c.lookup,c.dynamicBuilder),f=o.mortality??{period:64,mortal:!0},p=a({nonce:i,tip:o.tip??0n,mortality:f.mortal?{mortal:!0,period:f.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,p,c.metadataRaw,r.number)})),Xh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Kn((i,c)=>c.parent===i?c.hash:i,o),Mi(o),be()),r=o=>n(o).pipe(Z(2),Yn(i=>qh(e.call$,t,i))),s=o=>Wt(o.map(i=>r(i).pipe(B(c=>({success:!0,value:c})),Se(c=>se({success:!1,value:c}))))).pipe(Z(1));return e.pinnedBlocks$.pipe(Me(o=>!o.recovering&&o.blocks.size>0),Z(1),B(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(l=>!l.unpinnable&&l.children.size===0&&l.number>=c.number).map(l=>l.hash)}),Yn(s),B(o=>{const i=o.reduce((c,l)=>l.success&&l.value>=(c??0)?l.value:c,null);if(i==null)throw o[0].value;return i}))};var Yh=Object.defineProperty,Gh=(e,t,n)=>t in e?Yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nh=(e,t,n)=>Gh(e,t+"",n);const Qh=e=>J(Vt(me(e))),Zh=(e,t)=>new U(n=>{const r=new Map;let s,o;const i=()=>{let l=s.best,a=r.get(l),f=s.blocks.get(l).number;for(;!a;){const h=s.blocks.get(l);if(!h)break;a=r.get(l=h.parent),f--}if(!a)return;const p=f<=s.blocks.get(s.finalized).number,u=a.found.type;if(u&&o?.found&&o.hash===a.hash){p&&n.complete();return}n.next(o=a.found.type?{found:u,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:u,validity:a.found.validity}),p&&(u?n.complete():a.found.validity?.success===!1&&n.error(new is(a.found.validity.value)))},c=t.pipe(be((l,a)=>l.finalized===a.finalized&&l.best===a.best)).subscribe({next:l=>{s=l,r.size!==0&&i()},error(l){n.error(l)}});return c.add(e.subscribe({next:l=>{r.set(l.hash,l),i()},error(l){n.error(l)}})),c}).pipe(be((n,r)=>n===r)),Jh=(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 is extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof He?r.asHex():r,2)),Nh(this,"error"),this.name="InvalidTxError",this.error=t}}const cs=(e,t,n,r=!1)=>{const s=Qh(n),o=(a,f)=>({type:a,txHash:s,...f}),i=e.pinnedBlocks$.pipe(Z(1),P(a=>{let f=[];return a.finalizedRuntime.runtime.pipe(B(p=>p.getMortalityFromTx(n)),Se(()=>se({mortal:!1})),B(p=>{const{best:u,finalized:h}=a;let d=u;for(;d!==h;)f.push(d),d=a.blocks.get(d).parent;if(f.push(h),!p.mortal)return[h,u];const{phase:v,period:m}=p,y=a.blocks.get(u),b=y.number,x=Math.floor((b-v)/m)*m+v;let g=[a.blocks.get(a.finalized)];for(;g.length&&g[0].number<x;)g=g.flatMap(w=>[...w.children]).map(w=>a.blocks.get(w)).filter(Boolean);return(g.length?g:[y]).map(w=>w.hash)}),P(p=>ln(...[...new Set(p)].map(u=>e.validateTx$(u,n).pipe(B(h=>({at:u,result:h})))))),Wr(({result:p})=>!p.success,!0),rf((p,u)=>[...p,u],[]),B(p=>{const u=new Map(p.filter(({result:h})=>!h.success).map(h=>[h.at,h.result]));if(u.size<p.length)return null;throw new is(u.get(f.find(h=>u.has(h))??[...u.keys()][0]).value)}),Me(Boolean))})),c=new U(a=>{const f=e.trackTx$(n).subscribe(a);return f.add(t(n).subscribe({error(p){a.error(p)}})),f}),l=Zh(c,e.pinnedBlocks$).pipe(B(a=>a.found?o("txBestBlocksState",{found:!0,block:{index:a.index,number:a.number,hash:a.hash},...Jh(a.events,a.index)}):o("txBestBlocksState",{found:!1,isValid:a.validity?.success!==!1})));return zn(r?se(o("signed",{})):yt,i,se(o("broadcasted",{})),l.pipe(Ch(({found:a,type:f,...p})=>a?se(o("finalized",p)):yt)))},gc=async(e,t,n,r)=>Hu(cs(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),ed=At().enc,td=new Uint8Array(64),nd=new Uint8Array(65),rd=e=>()=>e?nd:td,[,sd]=ie({weight:ie({ref_time:Cn,proof_size:Cn}),class:Ee({Normal:O,Operational:O,Mandatory:O}),partial_fee:gs}),wc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:l},a)=>Object.assign(f=>{const p=(g,w,k={})=>{const $=rr(g).runtime(),{dynamicBuilder:E,assetId:T,lookup:M}=$;let W;try{W=E.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(g,$,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=k;if(k.asset){if(T==null||!Or(k.asset,Pn(M(T)),he=>l($,he)))throw new Error("Incompatible runtime asset");q={...k,asset:E.buildDefinition(T).enc(k.asset)}}const{location:te,codec:Y}=W;return{callData:He.fromBytes(oe([new Uint8Array(te),Y.enc(w)])),options:q}},u=(g,w={})=>i(n,null).pipe(B(([k])=>p(k,g,w))),h=g=>g?p(g,f).callData:ze(u(f).pipe(B(w=>w.callData))),d=(g,{...w},k)=>u(f,w).pipe(P(({callData:$,options:E})=>Kh(n,g,$.asBytes(),k,w.customSignedExtensions||{},E))),v=(g,{at:w,...k}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(B($=>$.find(E=>E.hash===w)))).pipe(Z(1),P($=>$?d(g,k,$).pipe(B(E=>({tx:J(E),block:$}))):Fn(()=>new Error(`Uknown block ${w}`)))),m=(g,w)=>ze(v(g,w)).then(k=>k.tx),y=(g,w)=>ze(v(g,w)).then(({tx:k,block:$})=>gc(n,r,k,$.hash)),b=(g,w)=>v(g,w).pipe(P(({tx:k})=>cs(n,r,k,!0))),x=async(g,w)=>{typeof g=="string"&&(g=g.startsWith("0x")?me(g):ed(g));const k=g.length===20,$=Dh(g,k?"Ecdsa":"Sr25519",rd(k)),E=me(await m($,w)),T=J(oe([E,Ve.enc(E.length)])),M=n.getRuntimeContext$(null).pipe(B(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return sd}})),W=n.call$(null,"TransactionPaymentApi_query_info",T);return ze(Wt([W,M]).pipe(B(([q,te])=>te(q))))};return{getPaymentInfo:x,getEstimatedFees:async(g,w)=>(await x(g,w)).partial_fee,decodedCall:{type:e,value:It(t,f)},getEncodedData:h,sign:m,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var od=Object.defineProperty,id=(e,t,n)=>t in e?od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Je=(e,t,n)=>(id(e,typeof t!="symbol"?t+"":t,n),n),as=Symbol("SUSPENSE"),cd=class extends Promise{constructor(e){super(e)}},xc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ec=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ce={},or=class extends U{constructor(e,t,n=Ae){super(r=>{const s=new cn({next:r.next.bind(r),error:r.error.bind(r),complete:Ae});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ce,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new xc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ce&&r.next(this.currentValue)):(this.subject=new Ue,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new cn({next:i=>{this.promise&&i!==as&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const l=this.subject;this.subject=null,this.currentValue=Ce;const a=(c=this.promise)==null?void 0:c.rej;a&&i===as&&(this.promise.rej=()=>{a(i)}),l.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ec),this.promise=null),this.currentValue!==Ce)return this.subject.complete();if(t===Ce){const i=this.subject;return this.subject=null,i.error(new Ec)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ce&&this.currentValue===Ce&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Je(this,"subject",null),Je(this,"subscription",null),Je(this,"refCount",0),Je(this,"currentValue",Ce),Je(this,"promise",null),Je(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof or?s:new or(s,Ce)}),Je(this,"getRefCount",()=>this.refCount),Je(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ce&&this.currentValue!==as)return this.currentValue;if(this.defaultValue!==Ce)return this.defaultValue;if(this.refCount===0)throw new xc;const r=new cd((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Je(this,"getDefaultValue",()=>this.defaultValue),t===Ce&&delete this.getDefaultValue}};function kc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function ad(e,t){const n=new ld,r=typeof t=="function"?t:()=>t,s=o=>{for(let p=o.length-1;o[p]===void 0&&p>-1;p--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const l=new or(e(...o),r(...o),()=>{n.delete(i)}),a=new U(p=>{const u=n.get(i);let h=l;return u?u!==a&&(h=u,kc(h,a)):n.set(i,f),h.subscribe(p)});kc(l,a);const f=a;return n.set(i,f),f};return(...o)=>s(o)}var ld=class{constructor(){Je(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 ud(e,t){return new or(e,t)}var ls=(...e)=>(typeof e[0]=="function"?ad:ud)(e[0],e.length>1?e[1]:Ce);const Ac=(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:l}=c,a=s.get(l);(!a||a.value!==c.value)&&o.set(l,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))}},Sc=(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}},Bc=(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)},fd=(e,t,n)=>{const r=ls((c,l,a)=>{const f=Bc(c,l),p=(m,y)=>{const b=xh(e,y.hash).pipe(Me(x=>!x),Z(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(P(x=>x===m?.rootHash?se({...m,block:y,deltas:null,prev:m.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),B(([g,w])=>[g,f(w)]),B(([g,w])=>({prev:m&&m.block.hash,rootHash:x,block:y,...Ac(m?.entries??[],g,w)})))),Li(b),Se(x=>x instanceof Ze?yt:Fn(()=>x)))},u=e.pipe(be((m,y)=>m.finalized===y.finalized),es(({blocks:m,finalized:y})=>p(null,m.get(y))),Z(1),B(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[h,d]=_h(),v=e.pipe(be((m,y)=>m.best===y.best),qr(h),es(([m,y])=>{const{best:b}=m,{blocks:x}=y;let g=x[b]?null:b;if(!g)return yt;const w=Sc(g,x,m);return w?p(w,m.blocks.get(g)).pipe(B(k=>(x[g]=k,y))):(g=m.finalized,p(x[y.finalized],m.blocks.get(g)).pipe(B(k=>(k.prev=null,{blocks:{[g]:k},finalized:g}))))}));return ln(u,v).pipe(d())}),s=c=>(l,a,f)=>{const p=r(l,a,f),u=Bc(l,a),h=c?"finalized":"best";return Wt([p.pipe(lf(0)),e.pipe(be((d,v)=>d[h]===v[h]))]).pipe(B(([d,v])=>Sc(v[h],d.blocks,v,!0)),Me(Boolean),be(),Mi(null),pf(),qr(p),n(([[,d]])=>d.block.hash),B(([[[d,v],m],y])=>[d,v,m,u(y)]),P(([d,v,m,y])=>{if(!d)return[v];let b=v;const x=[];for(;b&&b.block.number>d.block.number;)x.unshift(b),b=b.prev?m.blocks[b.prev]:null;if(c&&(m.finalized=v.block.hash,x.length)){const{blocks:g}=m;Object.keys(g).forEach(w=>{g[w].block.number<x[0].block.number&&delete g[w]})}return d===b?x:[{...v,...d.rootHash===v.rootHash?{entries:d.entries,deltas:null}:Ac(d.entries,v.entries,y)}]}))},o=ls(s(!0)),i=ls(s(!1));return(c,l,a,f)=>{const p=f?i:o;return e.pipe(Z(1),P(u=>u.runtimes[u.blocks.get(u[f?"best":"finalized"]).runtime].runtime),B(u=>u.dynamicBuilder.buildStorage(c,l).keys.enc(...a))).pipe(Z(1),P(u=>p(c,l,u)),B(({block:{hash:u,number:h,parent:d},deltas:v,entries:m},y)=>{const b=y>0?v:{deleted:[],upserted:m};return{block:{hash:u,number:h,parent:d},entries:m.map(us),deltas:b&&{deleted:b.deleted.map(us),upserted:b.upserted.map(us)}}}))}},us=e=>e.dec,Ic="RuntimeViewFunction",$c="execute_view_function",fs=Ic+"_"+$c,hd=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const f=a[a.length-1],p=Xt(f),{signal:u,at:h}=p?f:{},d=h??null,v=o(n,d).pipe(P(([m,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Ic,$c)}catch{throw new Error(`Runtime entry RuntimeCall(${fs}) not found`)}let x;try{x=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,y,a))throw l();const g=x.args.enc(a),w=oe([me(y.lookup.metadata.pallets.find(({name:k})=>k===e).viewFns.find(({name:k})=>k===t).id),C.enc(g.length),g]);return n.call$(d,fs,J(w)).pipe(B(k=>{try{const $=b.value.dec(k);if(!("success"in $&&"value"in $)||!("type"in $.value)&&!("asBytes"in $.value))throw null;return $}catch{throw new Error(`Unexpected RuntimeCall(${fs}) type`)}}),B(({success:k,value:$})=>{if(!k)throw new Error(`ViewFn API Error: ${$.type}`);const E=x.value.dec($.asBytes());if(!c(m,y,E))throw l();return E}))}),n.withHodl(d));return pn(v,u)},{getCompatibilityLevel:s,isCompatible:r})},dd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Cc=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(y,b){return m(b)}}),o=m=>{const y={};return s(b=>(y[b]||(y[b]={}),s(x=>(y[b][x]||(y[b][x]=m(b,x)),y[b][x]))))},i=(m,y)=>m.lookup.metadata.pallets.find(b=>b.name===y),c=fd(t.pinnedBlocks$,t.storage$,t.withRuntime),l=o((m,y)=>Rh(m,y,t,c,Pt(e,b=>b.getEntryPoint(xt.Storage,m,y),b=>{const x=i(b,m)?.storage?.items.find(g=>g.name===y);return x==null?null:su(x)}))),a=(m,y,b,x)=>{if(b==null)return null;const g=m.lookup(b);if(g.type!=="enum")throw new Error("Expected enum");if(g.value[x]==null)return null;const w=ou(g.value[x]);return{args:y==="args"?w:Mn,values:y==="args"?Mn:w}},f=o((m,y)=>wc(m,y,t,n,Pt(e,b=>b.getEntryPoint(xt.Tx,m,y),b=>a(b,"args",i(b,m)?.calls?.type,y)),!0)),p=o((m,y)=>Oh(m,y,t,Pt(e,b=>b.getEntryPoint(xt.Event,m,y),b=>a(b,"values",i(b,m)?.events?.type,y)))),u=o((m,y)=>Ih(m,y,Pt(e,b=>b.getEntryPoint(xt.Const,m,y),b=>{const x=i(b,m)?.constants.find(g=>g.name===y)?.type;return x==null?null:iu(x)}))),h=o((m,y)=>Th(m,y,t,Pt(e,b=>b.getEntryPoint(xt.Api,m,y),b=>ni(b.lookup.metadata.apis.find(x=>x.name===m).methods.find(x=>x.name===y))))),d=o((m,y)=>hd(m,y,t,Pt(e,b=>b.getEntryPoint(xt.ViewFns,m,y),b=>ni(b.lookup.metadata.pallets.find(x=>x.name===m).viewFns.find(x=>x.name===y))))),v=(m,y)=>{const{lookup:b,dynamicBuilder:x}=rr(y).runtime();try{const g=x.buildDefinition(b.call).dec(m.asBytes()),w=g.type,k=g.value.type,$=g.value.value;return wc(w,k,t,n,Pt(e,E=>E.getEntryPoint(xt.Tx,w,k),E=>a(E,"args",i(E,w)?.calls?.type,k)),!1)($)}catch{throw new Error("createTx: invalid call data")}};return{query:l,txFromCallData:(m,y)=>y?v(m,y):e.then(b=>v(m,b)),tx:f,event:p,apis:h,constants:u,view:d}};function pd(e,{getMetadata:t,setMetadata:n}={}){const r=Uf(e),s=wh(r,{getMetadata:t?m=>gt(t(m)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),l=s.archive(c.getRuntime$),a={...c,genesis$:Wn(o).pipe(B(({genesisHash:m})=>m),Se(()=>i),un(1)),storage$:Tt(c.storage$,l.storage$),body$:Tt(c.body$,l.body$),call$:Tt(c.call$,l.call$),header$:Tt(c.header$,l.header$),eventsAt$:Tt(c.eventsAt$,l.eventsAt$),storageQueries$:Tt(c.storageQueries$,l.storageQueries$),getRuntimeContext$:Tt(c.getRuntimeContext$,l.getRuntimeContext$)},f=r.request;let p;const u=new WeakMap,h=m=>{const y=u.get(m)||Sh(m,a);return u.set(m,y),y},d=()=>p??(p=Bh(a)),{broadcastTx$:v}=s;return{getChainSpecData:o,blocks$:a.newBlocks$,hodlBlock:m=>a.holdBlock(m,!0),finalizedBlock$:a.finalized$,getFinalizedBlock:()=>ze(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>ze(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:m=>ze(a.body$(m)),getBlockHeader:m=>ze(a.header$(m??null)),submit:(...m)=>gc(a,v,...m),submitAndWatch:m=>cs(a,v,m),getTypedApi:m=>{const y=h(m);return Object.assign(Cc(y,a,v),{compatibilityToken:y})},getUnsafeApi:()=>{const m=d();return Object.assign(Cc(m,a,v),{runtimeToken:m})},rawQuery:(m,{at:y,signal:b}={})=>pn(a.storage$(y??null,"value",()=>{const x=m.match(dd)?.[1];return x?`0x${x}`:He.fromText(m).asHex()}),b),destroy:()=>{a.unfollow(),s.destroy()},_request:f}}const vd=(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,l=new Uint8Array(i);return a=>{const f=He.fromBytes(oe([l,c.enc(a)]));return{encodedData:f,decodedCall:It(e,It(t,a)),sign:async(p,u)=>J(await p.signTx(f.asBytes(),s(u),n,u.mortality.mortal?u.mortality.startAtBlock.height:0))}}},md=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=me(e),r=await t(),s=Dt(pt.dec(r)),o=er(s),i=Yr(o),c=yc(n,o,i),l=d=>s.pallets.find(v=>v.name===d),a={},f=d=>new Proxy(a,{get(v,m){return d(m)}}),p=d=>{const v={};return f(m=>(v[m]||(v[m]={}),f(y=>(v[m][y]||(v[m][y]=d(m,y)),v[m][y]))))},u=p((d,v)=>{const m=l(d)?.constants.find(y=>y.name===v);if(!m)throw new Error(`Runtime entry Constant(${d}.${v}) not found`);return i.buildConstant(d,v).dec(m.value)}),h=p((d,v)=>vd(d,v,r,i,c));return{constants:u,tx:h}},Yt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},yd=async e=>{const t=Dt(Sr(await e.getMetadata())),n={},r=u=>new Proxy(n,{get(h,d){return u(d)}}),s=u=>{const h={};return r(d=>(h[d]||(h[d]={}),r(v=>(h[d][v]||(h[d][v]=u(d,v)),h[d][v]))))},o=er(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:l,buildCall:a,buildEvent:f,buildViewFn:p}=Yr(o);return{query:s((...u)=>{const{value:h,args:d}=Yt(c,"Storage")(...u);return{value:h,args:d}}),tx:s((...u)=>Yt(a,"Call")(...u).codec),event:s((...u)=>Yt(f,"Event")(...u).codec),apis:s(Yt(i,"Runtime API")),constants:s(Yt(l,"Constant")),view:s(Yt(p,"ViewFn"))}};le.AccountId=At,le.Binary=He,le.BlockNotPinnedError=Ze,le.CompatibilityLevel=Te,le.Enum=It,le.FixedSizeBinary=$n,le.InvalidTxError=is,le._Enum=uo,le.createClient=pd,le.getOfflineApi=md,le.getSs58AddressInfo=dr,le.getTypedCodecs=yd}));
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function Ln(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var _t=(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=Ft(i),l=c.next();!l.done;l=c.next()){var a=l.value;a.remove(this)}}catch(v){t={error:v}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var f=this.initialTeardown;if(K(f))try{f()}catch(v){o=v instanceof Dr?v.errors:[v]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var u=Ft(p),d=u.next();!d.done;d=u.next()){var h=d.value;try{ai(h)}catch(v){o=o??[],v instanceof Dr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{d&&!d.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ai(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)&&Ln(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Ln(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ii=_t.EMPTY;function ci(e){return e instanceof _t||e&&"closed"in e&&K(e.remove)&&K(e.add)&&K(e.unsubscribe)}function ai(e){K(e)?e():e.unsubscribe()}var fu={Promise:void 0},hu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function li(e){hu.setTimeout(function(){throw e})}function Ae(){}function Dn(e){e()}var cn=(function(e){Ne(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ci(n)&&n.add(r)):r.destination=vu,r}return t.create=function(n,r,s){return new zt(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})(_t),du=(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){Vn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Vn(r)}else Vn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Vn(n)}},e})(),zt=(function(e){Ne(t,e);function t(n,r,s){var o=e.call(this)||this,i;return K(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new du(i),o}return t})(cn);function Vn(e){li(e)}function pu(e){throw e}var vu={closed:!0,next:Ae,error:pu,complete:Ae},Vr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Qe(e){return e}function ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fi(e)}function fi(e){return e.length===0?Qe:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=(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=yu(t)?t:new zt(t,n,r);return Dn(function(){var i=s,c=i.operator,l=i.source;o.add(c?c.call(o,l):l?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=hi(n),new n(function(s,o){var i=new zt({next:function(c){try{t(c)}catch(l){o(l),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Vr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return fi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=hi(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 hi(e){var t;return(t=e??fu.Promise)!==null&&t!==void 0?t:Promise}function mu(e){return e&&K(e.next)&&K(e.error)&&K(e.complete)}function yu(e){return e&&e instanceof cn||mu(e)&&ci(e)}function bu(e){return K(e?.lift)}function Q(e){return function(t){if(bu(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function X(e,t,n,r,s){return new gu(e,t,n,r,s)}var gu=(function(e){Ne(t,e);function t(n,r,s,o,i,c){var l=e.call(this,n)||this;return l.onFinalize=i,l.shouldUnsubscribe=c,l._next=r?function(a){try{r(a)}catch(f){n.error(f)}}:e.prototype._next,l._error=o?function(a){try{o(a)}catch(f){n.error(f)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=s?function(){try{s()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,l}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(cn),wu=Lr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ue=(function(e){Ne(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 di(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new wu},t.prototype.next=function(n){var r=this;Dn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Ft(r.currentObservers),c=i.next();!c.done;c=i.next()){var l=c.value;l.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;Dn(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;Dn(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?ii:(this.currentObservers=null,c.push(n),new _t(function(){r.currentObservers=null,Ln(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 U;return n.source=this,n},t.create=function(n,r){return new di(n,r)},t})(U),di=(function(e){Ne(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:ii},t})(Ue),xu=(function(e){Ne(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})(Ue),Hr={now:function(){return(Hr.delegate||Date).now()},delegate:void 0},Hn=(function(e){Ne(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Hr);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,l=r._windowTime;s||(o.push(n),!i&&o.push(c.now()+l)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),l=0;l<c.length&&!n.closed;l+=o?1:2)n.next(c[l]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var l=s.now(),a=0,f=1;f<o.length&&o[f]<=l;f+=2)a=f;a&&o.splice(0,a+1)}},t})(Ue),Eu=(function(e){Ne(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t})(_t),pi={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ku=(function(e){Ne(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),pi.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&&pi.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,Ln(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Eu),vi=(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=Hr.now,e})(),Au=(function(e){Ne(t,e);function t(n,r){r===void 0&&(r=vi.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})(vi),mi=new Au(ku),Su=mi,yt=new U(function(e){return e.complete()});function yi(e){return e&&K(e.schedule)}function Fr(e){return e[e.length-1]}function jr(e){return K(Fr(e))?e.pop():void 0}function an(e){return yi(Fr(e))?e.pop():void 0}function Iu(e,t){return typeof Fr(e)=="number"?e.pop():t}var bi=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function gi(e){return K(e?.then)}function wi(e){return K(e[Vr])}function xi(e){return Symbol.asyncIterator&&K(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 Bu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ki=Bu();function Ai(e){return K(e?.[ki])}function Si(e){return lu(this,arguments,function(){var n,r,s,o;return oi(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,jt(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,jt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,jt(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 Ii(e){return K(e?.getReader)}function fe(e){if(e instanceof U)return e;if(e!=null){if(wi(e))return $u(e);if(bi(e))return Cu(e);if(gi(e))return _u(e);if(xi(e))return Bi(e);if(Ai(e))return Ou(e);if(Ii(e))return Tu(e)}throw Ei(e)}function $u(e){return new U(function(t){var n=e[Vr]();if(K(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Cu(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function _u(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,li)})}function Ou(e){return new U(function(t){var n,r;try{for(var s=Ft(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 Bi(e){return new U(function(t){Ru(e,t).catch(function(n){return t.error(n)})})}function Tu(e){return Bi(Si(e))}function Ru(e,t){var n,r,s,o;return au(this,void 0,void 0,function(){var i,c;return oi(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=uu(e),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=l.sent(),s={error:c},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function bt(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 $i(e,t){return t===void 0&&(t=0),Q(function(n,r){n.subscribe(X(r,function(s){return bt(r,e,function(){return r.next(s)},t)},function(){return bt(r,e,function(){return r.complete()},t)},function(s){return bt(r,e,function(){return r.error(s)},t)}))})}function Ci(e,t){return t===void 0&&(t=0),Q(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Pu(e,t){return fe(e).pipe(Ci(t),$i(t))}function Uu(e,t){return fe(e).pipe(Ci(t),$i(t))}function Mu(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Lu(e,t){return new U(function(n){var r;return bt(n,t,function(){r=e[ki](),bt(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 K(r?.return)&&r.return()}})}function _i(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){bt(n,t,function(){var r=e[Symbol.asyncIterator]();bt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Du(e,t){return _i(Si(e),t)}function Vu(e,t){if(e!=null){if(wi(e))return Pu(e,t);if(bi(e))return Mu(e,t);if(gi(e))return Uu(e,t);if(xi(e))return _i(e,t);if(Ai(e))return Lu(e,t);if(Ii(e))return Du(e,t)}throw Ei(e)}function gt(e,t){return t?Vu(e,t):fe(e)}function se(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return gt(e,n)}function Fn(e,t){var n=K(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var Oi=Lr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Hu(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 Oi)}})})}function ze(e,t){return new Promise(function(n,r){var s=new zt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Oi)}});e.subscribe(s)})}function Fu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return Q(function(n,r){var s=0;n.subscribe(X(r,function(o){r.next(e.call(t,o,s++))}))})}var ju=Array.isArray;function zu(e,t){return ju(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function Ti(e){return I(function(t){return zu(e,t)})}var Wu=Array.isArray,qu=Object.getPrototypeOf,Ku=Object.prototype,Xu=Object.keys;function Yu(e){if(e.length===1){var t=e[0];if(Wu(t))return{args:t,keys:null};if(Gu(t)){var n=Xu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Gu(e){return e&&typeof e=="object"&&qu(e)===Ku}function Nu(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Wt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=jr(e),s=Yu(e),o=s.args,i=s.keys;if(o.length===0)return gt([],n);var c=new U(Ri(o,n,i?function(l){return Nu(i,l)}:Qe));return r?c.pipe(Ti(r)):c}function Ri(e,t,n){return n===void 0&&(n=Qe),function(r){Pi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,l=function(f){Pi(t,function(){var p=gt(e[f],t),u=!1;p.subscribe(X(r,function(d){o[f]=d,u||(u=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)l(a)},r)}}function Pi(e,t,n){e?bt(n,e,t):t()}function Qu(e,t,n,r,s,o,i,c){var l=[],a=0,f=0,p=!1,u=function(){p&&!l.length&&!a&&t.complete()},d=function(v){return a<r?h(v):l.push(v)},h=function(v){a++;var m=!1;fe(n(v,f++)).subscribe(X(t,function(y){t.next(y)},function(){m=!0},void 0,function(){if(m)try{a--;for(var y=function(){var b=l.shift();i||h(b)};l.length&&a<r;)y();u()}catch(b){t.error(b)}}))};return e.subscribe(X(t,d,function(){p=!0,u()})),function(){}}function P(e,t,n){return n===void 0&&(n=1/0),K(t)?P(function(r,s){return I(function(o,i){return t(r,o,s,i)})(fe(e(r,s)))},n):(typeof t=="number"&&(n=t),Q(function(r,s){return Qu(r,s,e,n)}))}function jn(e){return e===void 0&&(e=1/0),P(Qe,e)}function Zu(){return jn(1)}function zn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zu()(gt(e,an(e)))}function Wn(e){return new U(function(t){fe(e()).subscribe(t)})}var Ju={connector:function(){return new Ue},resetOnDisconnect:!0};function ef(e,t){t===void 0&&(t=Ju);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new U(function(l){return i.subscribe(l)});return c.connect=function(){return(!n||n.closed)&&(n=Wn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function qn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Su);var r=-1;return t!=null&&(yi(t)?n=t:r=t),new U(function(s){var o=Fu(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 ln(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=Iu(e,1/0),s=e;return s.length?s.length===1?fe(s[0]):jn(r)(gt(s,n)):yt}var tf=Array.isArray;function nf(e){return e.length===1&&tf(e[0])?e[0]:e}function Me(e,t){return Q(function(n,r){var s=0;n.subscribe(X(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Se(e){return Q(function(t,n){var r=null,s=!1,o;r=t.subscribe(X(n,void 0,void 0,function(i){o=fe(e(i,Se(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Ui(e,t,n,r,s){return function(o,i){var c=n,l=t,a=0;o.subscribe(X(i,function(f){var p=a++;l=c?e(l,f,p):(c=!0,f),r&&i.next(l)},s&&(function(){c&&i.next(l),i.complete()})))}}function rf(e,t){return Q(Ui(e,t,arguments.length>=2,!1,!0))}function Mi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return n?ui(Mi.apply(void 0,Pe([],Re(e))),Ti(n)):Q(function(r,s){Ri(Pe([r],Re(nf(e))))(s)})}function sf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Mi.apply(void 0,Pe([],Re(e)))}function of(e,t){return K(t)?P(e,t,1):P(e,1)}function Z(e){return e<=0?function(){return yt}:Q(function(t,n){var r=0;t.subscribe(X(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function cf(e){return I(function(){return e})}function af(e,t){return P(function(n,r){return fe(e(n,r)).pipe(Z(1),cf(n))})}function lf(e,t){t===void 0&&(t=mi);var n=qn(e,t);return af(function(){return n})}function uf(e,t){return Q(function(n,r){var s=new Set;n.subscribe(X(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&fe(t).subscribe(X(r,function(){return s.clear()},Ae))})}function be(e,t){return t===void 0&&(t=Qe),e=e??ff,Q(function(n,r){var s,o=!0;n.subscribe(X(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function ff(e,t){return e===t}function hf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return zn(n,se.apply(void 0,Pe([],Re(e))))}}function df(e,t){return Q(function(n,r){var s=0,o=null,i=!1;n.subscribe(X(r,function(c){o||(o=X(r,void 0,function(){o=null,i&&r.complete()}),fe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function pf(){return Q(function(e,t){var n,r=!1;e.subscribe(X(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Kn(e,t){return Q(Ui(e,t,arguments.length>=2,!0))}function Xn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Ue}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,l=c===void 0?!0:c;return function(a){var f,p,u,d=0,h=!1,v=!1,m=function(){p?.unsubscribe(),p=void 0},y=function(){m(),f=u=void 0,h=v=!1},b=function(){var x=f;y(),x?.unsubscribe()};return Q(function(x,g){d++,!v&&!h&&m();var w=u=u??n();g.add(function(){d--,d===0&&!v&&!h&&(p=zr(b,l))}),w.subscribe(g),!f&&d>0&&(f=new zt({next:function(k){return w.next(k)},error:function(k){v=!0,m(),p=zr(y,s,k),w.error(k)},complete:function(){h=!0,m(),p=zr(y,i),w.complete()}}),fe(x).subscribe(f))})(a)}}function zr(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 zt({next:function(){s.unsubscribe(),e()}});return fe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function un(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,Xn({connector:function(){return new Hn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return Q(function(r,s){(n?zn(e,r,n):zn(e,r)).subscribe(s)})}function Yn(e,t){return Q(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(X(r,function(l){s?.unsubscribe();var a=0,f=o++;fe(e(l,f)).subscribe(s=X(r,function(p){return r.next(t?t(l,p,f,a++):p)},function(){s=null,c()}))},function(){i=!0,c()}))})}function vf(){return Yn(Qe)}function Di(e){return Q(function(t,n){fe(e).subscribe(X(n,function(){return n.complete()},Ae)),!n.closed&&t.subscribe(n)})}function Wr(e,t){return t===void 0&&(t=!1),Q(function(n,r){var s=0;n.subscribe(X(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function fn(e,t,n){var r=K(e)||t||n?{next:e,error:t,complete:n}:e;return r?Q(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(X(o,function(l){var a;(a=r.next)===null||a===void 0||a.call(r,l),o.next(l)},function(){var l;c=!1,(l=r.complete)===null||l===void 0||l.call(r),o.complete()},function(l){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,l),o.error(l)},function(){var l,a;c&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Qe}function qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jr(e);return Q(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),l=!1,a=function(p){fe(e[p]).subscribe(X(s,function(u){i[p]=u,!l&&!c[p]&&(c[p]=!0,(l=c.every(Qe))&&(c=null))},Ae))},f=0;f<o;f++)a(f);r.subscribe(X(s,function(p){if(l){var u=Pe([p],Re(i));s.next(n?n.apply(void 0,Pe([],Re(u))):u)}}))})}var mf=Object.defineProperty,yf=(e,t,n)=>t in e?mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vi=(e,t,n)=>yf(e,typeof t!="symbol"?t+"":t,n);class Hi extends Error{constructor(t){super(t.message),Vi(this,"code"),Vi(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Fi=()=>{const e=new Map;return{has:e.has.bind(e),subscribe(t,n){e.set(t,n)},unsubscribe(t){e.delete(t)},next(t,n){e.get(t)?.next(n)},error(t,n){const r=e.get(t);r&&(e.delete(t),r.error(n))},errorAll(t){const n=[...e.values()];e.clear(),n.forEach(r=>{r.error(t)})}}};class Kr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let bf=1;const gf=e=>{let t=bf++;const n=new Map,r=Fi();let s=null;const o=(f,p,u)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:f,method:p,params:u}))};function i(f){try{let p,u,d,h,v;if({id:p,result:u,error:d,params:h}=JSON.parse(f),p===null)throw new Error(h?.error?.message??"id null");if(p!=null){const b=n.get(p);return b?(n.delete(p),d?b.onError(new Hi(d)):b.onSuccess(u,(x,g)=>{const w=x;return r.subscribe(w,g),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:u,error:d}=h,!v||!d&&!Object.hasOwn(h,"result"))throw 0;const y=v;d?r.error(y,new Hi(d)):r.next(y,u)}catch(p){console.warn("Error parsing incomming message: "+f),console.error(p)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Kr),n.forEach(f=>f.onError(new Kr)),n.clear()};let l=1;return{request:(f,p,u)=>{if(!s)throw new Error("Not connected");const d=`${t}-${l++}`;return u&&n.set(d,u),o(d,f,p),()=>{n.delete(d)}},disconnect:c}};class ji extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Gn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Nn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class zi extends Error{constructor(t){super(t),this.name="OperationError"}}class Qn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Le={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Zn={chainName:"",genesisHash:"",properties:""},Xr={broadcast:"",stop:""};Object.entries({chainHead:Le,chainSpec:Zn,transaction:Xr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class Wi extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class wf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class xf extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const qt=()=>{},Ef=e=>(t,n)=>{let r=!1,s=()=>{r=!0};return e(Xr.broadcast,[t],{onSuccess:o=>{o!==null?(s=()=>{e(Xr.stop,[o]),s=qt},r&&s()):r||n(new Error("Max # of broadcasted transactions has been reached"))},onError:n}),()=>{s()}};function kf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Kt=e=>(...t)=>new Promise((n,r)=>{let s=St;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new no)};i?.addEventListener("abort",c,{once:!0});const l=a=>f=>{s=St,i?.removeEventListener("abort",c),a(f)};s=e(l(n),l(r),...o)}),qi=(e,t)=>n=>Kt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[l,a]=t(...o);return n(e,l,{onSuccess:(f,p)=>{if(f.result==="limitReached")return s(new Nn);const{operationId:u}=f,d=()=>{n(Le.stopOperation,[u])};if(!i)return d();let h=qt;const v=y=>{i=!1,h(),r(y)},m=y=>{i=!1,h(),s(y)};h=p(u,{next:y=>{const b=y;b.event==="operationError"?s(new zi(b.error)):b.event==="operationInaccessible"?s(new Qn):a(y,v,m)},error:m}),c=()=>{i&&(h(),d())}},onError:s}),()=>{c()}}),Af=qi(Le.body,e=>[[e],(t,n)=>{n(t.value)}]),Sf=qi(Le.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),If=e=>t=>new Promise((n,r)=>{e(Le.header,[t],{onSuccess:n,onError:r})}),Ki=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),St;let l=!0,a=()=>{l=!1};return e(Le.storage,[t,n,r],{onSuccess:(f,p)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return o(new Nn);const{operationId:u}=f,d=()=>{e(Le.stopOperation,[u])};if(!l)return d();const h=p(f.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{m();break}case"operationError":{v(new zi(y.error));break}case"operationInaccessible":{v(new Qn);break}default:e(Le.continue,[y.operationId])}},error:o});a=()=>{h(),e(Le.stopOperation,[f.operationId])};const v=y=>{a=St,h(),o(y)},m=()=>{a=St,h(),i()};c(f.discardedItems)},onError:o}),()=>{a()}},Bf=e=>{const t=Ki(e);return Kt((n,r,s,o,i,c)=>{const l=o.startsWith("descendants");let a=l?[]:null;const p=t(s,[{key:i,type:o}],c??null,l?u=>{a.push(u)}:u=>{a=u[0]?.[o]},r,()=>{try{n(l?a.flat():a)}catch(u){r(u)}},u=>{u>0&&(p(),r(new Nn))});return p})},$f=e=>t=>t.length>0?new Promise((n,r)=>{e(Le.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function Cf(e){return e.operationId!==void 0}function _f(e){return(t,n,r)=>{const s=Fi(),o=new Set,i=kf();let c=i.promise,l=qt;const a=h=>{e(Le.unfollow,[h])},f=h=>{l(),c!==null&&(h&&(c instanceof Promise?c.then(v=>{typeof v=="string"&&a(v)}):a(c)),c=null,o.forEach(v=>{v()}),o.clear(),s.errorAll(new Gn))},p=h=>{if(Cf(h))return s.has(h.operationId)||console.warn("Uknown operationId on",h),s.next(h.operationId,h);switch(h.event){case"stop":return r(new ji),f(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:v,...m}=h;return n({type:v,...m})}console.warn("Invalid event",h)},u=h=>{r(h),f(!(h instanceof Kr))};e(Le.follow,[t],{onSuccess:(h,v)=>{c instanceof Promise&&(c=h,l=v(h,{next:p,error:u})),i.res(h)},onError:h=>{c=null,i.res(h),r(h)}});const d=(h,v,m)=>{const y=()=>{m?.onError(new Gn)};if(c===null)return y(),qt;const b=g=>{if(!m)return e(h,[g,...v]);o.add(y);const w=($,E)=>c===null?(E.error(new Gn),qt):(s.subscribe($,E),()=>{s.unsubscribe($)}),k=e(h,[g,...v],{onSuccess:$=>{o.delete(y),m.onSuccess($,w)},onError:$=>{o.delete(y),m.onError($)}});return()=>{o.delete(y),k()}};if(typeof c=="string")return b(c);let x=qt;return c.then(g=>{if(g instanceof Error)return y();c&&(x=b(g))}),()=>{x()}};return{unfollow(){f(!0)},body:Af(d),call:Sf(d),header:If(d),storage:Bf(d),storageSubscription:Ki(d),unpin:$f(d),_request:d}}}const Of=e=>{const t=Kt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(Zn.chainName,[]),t(Zn.genesisHash,[]),t(Zn.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Tf=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),St;let c=!0,l=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,f)=>{const p=()=>{e("stopStorage",[a])};if(!c)return p();const u=f(a,{next:m=>{const{event:y}=m;if(y==="storage"){const{event:b,...x}=m;s(x)}else y==="storageDone"?v():h(new wf(m.error))},error:o}),d=()=>{l=St,u()};l=()=>{d(),p()};const h=m=>{d(),o(m)},v=()=>{d(),i()}},onError:o}),()=>{l()}},Rf=e=>Kt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let l=c?[]:null;const a=c?l.push.bind(l):({[s]:f})=>{l=f};return e(r,[{key:o,type:s}],i,a,f=>{n(f),l=null},()=>{t(l),l=null})}),Xi=()=>e=>e,Yi=()=>(e,t)=>{if(e===null)throw new Wi(t);return e},Pf=e=>{const t=(f,...p)=>e(`archive_v1_${f}`,...p),n=f=>p=>Kt((u,d,...h)=>t(f,h,{onSuccess:v=>{try{u(p(v,...h))}catch(m){d(m)}},onError:d})),r=n("header")(Yi()),s=n("body")(Yi()),o=Tf(t),i=Rf(o),c=n("call")((f,p)=>{if(!f)throw new Wi(p);if(!f.success)throw new xf(f.error);return f.value}),l=n("finalizedHeight")(Xi()),a=n("hashByHeight")(Xi());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:l,hashByHeight:a}},Jn=new Map,Uf=e=>{const t=Jn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=gf(e),s=()=>{const i=Jn.get(e);!i||i.refCount<=1?(Jn.delete(e),r()):i.refCount--},o={archive:Pf(n),chainHead:_f(n),transaction:Ef(n),getChainSpecData:Of(n),destroy:s,request:Kt((i,c,l,a)=>n(l,a,{onSuccess:i,onError:c})),_request:n};return Jn.set(e,{client:o,refCount:1}),o};var Mf=Object.defineProperty,Lf=(e,t,n)=>t in e?Mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gi=(e,t,n)=>Lf(e,typeof t!="symbol"?t+"":t,n);class Df{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 Vf=()=>{const e=new Map,t=(u,d)=>{e.set(u,()=>{e.delete(u),d()})},n=u=>{e.get(u)?.()},r=new Df,s=r.unshift.bind(r),o=r.push.bind(r),i=(u,d)=>{const h=d?s:o;t(u.source$,h(u))},c=()=>{const u=r.pop();u&&(e.delete(u.source$),l(u))},l=u=>{const{source$:d,observer:h}=u;let v=!1;const m=d.subscribe({next(y){h.next(y)},error(y){(v=y instanceof Nn)?i(u,!0):h.error(y)},complete(){h.complete()}});m.closed?v||c():t(d,()=>{m.unsubscribe(),c()})},a=(u=!1)=>d=>new U(h=>{const v={observer:h,source$:d};return r.isEmpty()?l(v):i(v,u),()=>{n(d)}}),f=a();return{withRecovery:a,withRecoveryFn:u=>(...d)=>f(u(...d))}};class Ze extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Yr=e=>{const t=e.pipe(Se(n=>n instanceof Qn?qn(750).pipe(of(()=>t)):Fn(()=>n)));return t},Hf=new Set(["best","finalized",null]),Ff=(e,t,n)=>r=>(s,...o)=>{if(!Hf.has(s))return Yr(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(Z(1),P(l=>r(l,...o).pipe(n(l))),Se(l=>l instanceof Ze?c:Fn(()=>l)));return Yr(c)},Ot=e=>(...t)=>new U(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}}),jf=e=>t=>(...n)=>e()[t](...n);function hn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,l=!1;const a=()=>{l||(l=!0,c=o.subscribe({next:u=>i.next(u),error:u=>i.error(u),complete:()=>i.complete()}),c.add(()=>{l=!1,c=null}))};let f=!1;const p=e.subscribe({next:u=>{const d=u.blocks.get(r);d?d.recovering?c?.unsubscribe():a():f&&i.error(new Ze(r,n)),f=u.recovering},error:u=>i.error(u)});return()=>{p.unsubscribe(),c?.unsubscribe()}})}}const zf=(e,t)=>{const n=(r,s,o,i)=>new U(c=>e().storageSubscription(r,s,o??null,l=>{c.next(l)},l=>{c.error(l)},()=>{c.complete()},l=>{l>0&&c.next(n(r,s.slice(-l),o,!0))})).pipe(jn(),t(i));return n},Wf=e=>{const t=async(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return[o,i];const c=r.idx+Math.floor((s.idx-r.idx)/2),l={idx:c,id:await e(n[c])};if(l.id===r.id)return t(n,l,s);if(l.id===s.id)return t(n,r,l);const[a,[f,...p]]=await Promise.all([t(n,r,l),t(n,l,s)]);return[...a,...p]};return async n=>{if(n.length<2)return n;const r=n.length-1,[s]=n,o=n[r],[i,c]=await Promise.all([s,o].map(e));return i===c?[n[0]]:t(n,{idx:0,id:i},{idx:r,id:c})}},qf=(e,t)=>{const n=Wf(t);return r=>new U(s=>{let o=null;return r.subscribe({next(i){i.type==="initialized"?(o=[],Promise.all([e(i.finalizedBlockHashes[0]),n(i.finalizedBlockHashes)]).then(([c,l])=>{s.closed||(s.next({type:"initialized",finalizedBlockHashes:i.finalizedBlockHashes,runtimeChanges:new Set(l),number:c.number,parentHash:c.parentHash}),o.forEach(a=>{s.next(a)}),o=null)}).catch(c=>{s.closed||s.error(c)})):o?o.push(i):s.next(i)},error(i){s.error(i)},complete(){s.complete()}})})},Kf=e=>{let t=null,n=Ae;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=l=>r().header(l).then(wr.dec),o=async l=>r().storage(l,"hash","0x3a636f6465",null),i=ef(new U(l=>{t=e(!0,a=>{l.next(a)},a=>{t=null,l.error(a)}),n=()=>{l.complete(),t?.unfollow()}}).pipe(qf(s,o),Xf()));return{getHeader:s,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},Xf=()=>e=>new U(t=>{const n=new _t,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof ji?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),Yf=e=>J(Ve.enc(e)),Ni=G(),Gf=dt(Ni),Nf=Ie(Ve).dec,Qi=e=>{const t=e("Metadata_metadata_versions","").pipe(I(Nf),Se(()=>se([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(I(Ni.dec)):e("Metadata_metadata_at_version",Yf(s)).pipe(I(o=>Gf.dec(o)))};return t.pipe(P(n))},Zi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",wt={type:"void"},Qf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=f=>p=>{let u=n.get(p);if(u)return u;if(r.has(p)){const h={id:p};return n.set(p,h),h}r.add(p);const d=f(p);return u=n.get(p),u?Object.assign(u,d):(u={id:p,...d},n.set(p,u)),r.delete(p),u};let o=!0,i=!0;const c=s(f=>{const p=t(e[f]);if(p)return p;const{def:u,path:d,params:h}=e[f];if(u.tag==="composite"){if(u.value.length===0)return wt;if(u.value.length===1){const v=c(u.value[0].type);return o&&d.at(-1)==="AccountId32"&&Zi(v,32)?(o=!1,{type:"AccountId32"}):i&&d.at(-1)==="AccountId20"&&Zi(v,20)?(i=!1,{type:"AccountId20"}):v}return l(u.value)}if(u.tag==="variant"){if(d.length===1&&d[0]==="Option"&&h.length===1&&h[0].name==="T"){const y=c(h[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(d.length===1&&d[0]==="Result"&&h.length===2&&h[0].name==="T"&&h[1].name==="E")return{type:"result",value:{ok:c(h[0].type),ko:c(h[1].type)}};if(u.value.length===0)return wt;const v={},m={};return u.value.forEach(y=>{const b=y.name;if(m[b]=y.docs,y.fields.length===0){v[b]={...wt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[b]={...l(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:m}}if(u.tag==="sequence")return{type:"sequence",value:c(u.value)};if(u.tag==="array"){const{len:v}=u.value,m=c(u.value.type);return!v||m.type==="void"?wt:v>1?{type:"array",value:m,len:u.value.len}:m}if(u.tag==="tuple")return u.value.length===0?wt:u.value.length>1?a(u.value.map(v=>c(v)),u.value.map(v=>e[v].docs)):c(u.value[0]);if(u.tag==="primitive")return{type:"primitive",value:u.value.tag};if(u.tag==="compact"){const v=c(u.value);return v.type==="void"?wt:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:u.tag,isLSB:(e[u.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),l=f=>{let p=!0;const u={},d={};return f.forEach((h,v)=>{p=p&&!!h.name;const m=h.name||v,y=c(h.type);y.type!=="void"&&(u[m]=y,d[m]=h.docs)}),p?{type:"struct",value:u,innerDocs:d}:a(Object.values(u),Object.values(d))},a=(f,p)=>{if(f.every(u=>u.id===f[0].id)&&p.every(u=>!u.length)){const[u]=f;return u.type==="void"?wt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:p}};return c},er=e=>{const t=Qf(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?{...wt,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),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:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},Zf=(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 l=e(r,s,o,...i);return o.delete(c),s.has(c)&&(l=n(l,s.get(c),r,...i)),s.set(c,l),l},Jf=nn(),Ji=Zf((e,t,n,r)=>{if(e.type==="primitive")return Qo[e.value];if(e.type==="void")return O;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Eo;if(e.type==="compact")return e.isBig?Cn:C;if(e.type==="bitSequence")return On(e.isLSB);const s=d=>Ji(d,t,n,r),o=(d,h)=>{const v=s(d);return h?Ie(v,h):Ie(v)},i=d=>Fe(...d.map(s)),c=d=>{const h=Object.fromEntries(Object.entries(d).map(([v,m])=>[v,s(m)]));return ie(h)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Jf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?nn(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 dt(s(e.value));if(e.type==="result")return _n(s(e.value.ok),s(e.value.ko));const l=Object.values(e.value).map(d=>{switch(d.type){case"void":return O;case"lookupEntry":return s(d.value);case"tuple":return i(d.value);case"struct":return c(d.value);case"array":return o(d.value,d.len)}}),a=Object.fromEntries(Object.keys(e.value).map((d,h)=>[d,l[h]])),f=Object.values(e.value).map(d=>d.idx),u=f.every((d,h)=>d===h)?Ee(a):Ee(a,f);return e.byteLength?eh(u,e.byteLength):u},vr,e=>e),ec=(e,t=At())=>{const n=new Map,r=s=>Ji(e(s),n,new Set,t);return s=>r(s)},eh=(e,t)=>{const n=G(t);return z(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},th=Ke(O,()=>{},()=>null),Gr=e=>{const{metadata:t}=e;let n=ec(e);const r=t.pallets.find(u=>u.name==="System")?.constants.find(u=>u.name==="SS58Prefix");let s;if(r)try{const u=n(r.type).dec(r.value);typeof u=="number"&&(s=u,n=ec(e,At(u)))}catch{}const o=new Map,i=(u,d)=>{let h=o.get(u);h||o.set(u,h=qo(u));const v=t.pallets.find(E=>E.name===u).storage.items.find(E=>E.name===d),m=E=>E===O?th:E,y=(E,T,...M)=>{const W=h(...M),[,...q]=M;return{args:Fe(...q.map(([te])=>te)),keys:W,value:T,len:E,fallback:v.modifier===1?T.dec(v.fallback):void 0}};if(v.type.tag==="plain")return y(0,m(n(v.type.value)),d);const{key:b,value:x,hashers:g}=v.type.value,w=m(n(x)),k=g.map(E=>Qo[E.tag]),$=(()=>{if(k.length===1)return[[n(b),k[0]]];const E=e(b);switch(E.type){case"array":return k.map(T=>[n(E.value.id),T]);case"tuple":return E.value.map((T,M)=>[n(T.id),k[M]]);default:throw new Error("Invalid key type")}})();return y(k.length,w,d,...$)},c=u=>{switch(u.type){case"void":return O;case"lookupEntry":return n(u.value.id);case"tuple":return Fe(...Object.values(u.value).map(d=>n(d.id)));case"struct":return ie(Mt(u.value,d=>n(d.id)));case"array":return Ie(n(u.value.id),u.len)}},l=(u,d)=>{const h=t.pallets.find(v=>v.name===u).constants.find(v=>v.name===d);return n(h.type)},a=u=>(d,h)=>{const v=t.pallets.find(b=>b.name===d),m=e(v[u].type);if(m.type!=="enum")throw null;const y=m.value[h];return{location:[v.index,y.idx],codec:c(m.value[h])}},f=(u,d)=>{const h=t.pallets.find(v=>v.name===u)?.viewFns.find(v=>v.name===d);if(!h)throw null;return{args:Fe(...h.inputs.map(v=>n(v.type))),value:n(h.output)}},p=(u,d)=>{const h=t.apis.find(v=>v.name===u)?.methods.find(v=>v.name===d);if(!h)throw null;return{args:Fe(...h.inputs.map(v=>n(v.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:f,buildRuntimeCall:p,buildCall:a("calls"),buildConstant:l,ss58Prefix:s}},tc="CheckMortality",nc=(e,t,n)=>{const r=er(e),s=Gr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(f=>f.identifier==="ChargeAssetTxPayment");let c=null;if(i){const f=r(i.type);if(f.type==="struct"){const p=f.value.asset_id;p.type==="option"&&(c=p.value.id)}}const l=sh(r.metadata,s),a=f=>{const p=l(f);return"extra"in p&&p.extra[tc]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:At(s.ss58Prefix),getMortalityFromTx:a}},Nr=G(1/0).dec,nh=wn(Xe[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),rh=tt(e=>{const t=D.dec(e);if(t===0)return{mortal:!1};const n=D.dec(e);return nh(Uint8Array.from([t,n]))}),sh=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===tc?rh:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,l=c?.find(p=>p.name==="Call")?.type,a=c?.find(p=>p.name==="Address")?.type,f=c?.find(p=>p.name==="Signature")?.type;if(l==null||a==null||f==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(f)[1]}const i=ie.dec({address:r,signature:s,extra:ie.dec(n),callData:Nr});return tt(c=>{const l=C.dec(c),{type:a,version:f}=Ir[1](c);if(a==="bare")return{len:l,version:f,type:a,callData:Nr(c)};if(a==="signed")return{len:l,version:f,type:a,...i(c)};const p=D.dec(c);let u;if(e.version===16){const h=e.extrinsic.signedExtensionsByVersion.find(([v])=>v===p);if(!h)throw new Error("Unexpected extension version");u=ie.dec(Object.fromEntries(Object.entries(n).filter((v,m)=>h[1].includes(m))))}else u=ie.dec(n);const d=u(c);return{len:l,type:a,version:f,extensionVersion:p,extra:d,callData:Nr(c)}})},oh=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe(Se(o=>{if(o instanceof Ze)return n(...r);if(o instanceof Qn)return qn(750).pipe(P(()=>n(...r)));throw o})):yt};return n},ih=(e,t,n,r)=>{const s=(o,i)=>o.pipe(P(c=>n(c).pipe(Se(()=>se(null)),P(l=>l?se(l):i.pipe(fn(a=>{r(c,a)}))),I(l=>({codeHash:c,metadataRaw:l,metadata:Dt(pt.dec(l))})))));return o=>{const i=oh(o),c=o(),l=new Set([c]),a=i(t)().pipe(un(1)),f=s(a,Qi(i(e))).pipe(I(({metadata:u,metadataRaw:d,codeHash:h})=>nc(u,d,h)),un(1)),p={at:c,runtime:f,codeHash$:a,addBlock:u=>(l.add(u),p),deleteBlocks:u=>(u.forEach(d=>{l.delete(d)}),l.size),usages:l};return f.subscribe({error(){}}),p}},dn=Xn({connector:()=>new Hn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),rc=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},sc=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},ch=(e,t)=>{t.forEach(n=>{sc(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]})},ah=(e,t,n,r,s,o,i,c,l)=>{const a=h=>{i.next(h)},f=new Ue,p=f.pipe(df(()=>qn(0)),I(()=>({type:"cleanup"}))),u=ln(o,p,e).pipe(Kn((h,v)=>{const m=y=>{ch(h,y),c(y)};switch(v.type){case"initialized":h.recovering&&!v.finalizedBlockHashes.some(w=>h.blocks.has(w))&&(h=Object.assign(h,oc()));const y=h.blocks.get(h.finalized)?.number??-1,b=v.finalizedBlockHashes.length-1;h.finalized=h.best=v.finalizedBlockHashes[b];let x=h.finalizedRuntime.at;const g=[];return v.finalizedBlockHashes.forEach((w,k)=>{const $=k!==b,E=h.blocks.get(w);if(E)E.recovering=!1,E.unpinnable=$;else{const T=v.number+k,M=T>y,W=v.runtimeChanges.has(w)&&!h.runtimes[w]&&M;W&&(x=w);const q=k===0?v.parentHash:v.finalizedBlockHashes[k-1];h.blocks.set(w,{hash:w,parent:q,children:new Set(k===b?[]:[v.finalizedBlockHashes[k+1]]),unpinnable:$,runtime:x,refCount:0,number:T,recovering:!1}),W&&(h.finalizedRuntime=h.runtimes[w]=d(rc(h,w))),h.runtimes[x].usages.add(w),M&&g.push({hash:w,number:T,parent:q})}}),g.forEach(a),h;case"stop-error":for(const w of h.blocks.values())w.recovering=!0;return h.recovering=!0,h;case"newBlock":{const{parentBlockHash:w,blockHash:k}=v;if(h.blocks.has(k))h.blocks.get(k).recovering=!1;else{const $=h.blocks.get(w);$.children.add(k);const E=$.number+1,T={hash:k,number:E,parent:w,children:new Set,runtime:v.newRuntime?k:$.runtime,unpinnable:!1,refCount:0,recovering:!1};h.blocks.set(k,T),v.newRuntime&&(h.runtimes[k]=d(rc(h,k))),h.runtimes[T.runtime].addBlock(k),a({hash:k,number:E,parent:w})}return h}case"bestBlockChanged":{if(h.recovering){for(const[w,k]of h.blocks)k.recovering&&(sc(h.blocks,w),l(w));h.recovering=!1}return h.best=v.bestBlockHash,h}case"finalized":{h.finalized=v.finalizedBlockHashes.slice(-1)[0];const{blocks:w}=h;w.get(h.best).number<w.get(h.finalized).number&&(h.best=h.finalized),h.finalizedRuntime=h.runtimes[w.get(h.finalized).runtime],v.prunedBlockHashes.forEach($=>{const E=h.blocks.get($);E&&(E.unpinnable=!0)});let k=w.get(w.get(h.finalized).parent);for(;k&&!k.unpinnable;)k.unpinnable=!0,k=w.get(k.parent);return f.next(),h}case"cleanup":{const w=[...h.blocks.values()].filter(({unpinnable:k,refCount:$})=>k&&!$).map(({hash:k})=>k);return m(w),h}case"blockUsage":{if(!h.blocks.has(v.value.hash))return h;const w=h.blocks.get(v.value.hash);if(w.refCount+=v.value.type==="hold"?1:-1,w.refCount===0&&!w.recovering&&w.unpinnable){const k=[w.hash];m(k)}return h}}},oc()),Me(h=>!!h.finalizedRuntime.runtime),I(h=>({...h})),fn({error(h){i.error(h)}}),dn),d=ih(hn(u,t,"pinned-blocks"),hn(u,n,"pinned-blocks"),r,s);return u},oc=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ic=(e,t,n,r)=>{const s=c=>Di(e.pipe(Me(({blocks:l})=>!l.has(c)))),o=(c,l,a)=>{if(a)return se({hash:c,found:{type:!1,validity:null}});const f=s(c);return t(c).pipe(P(p=>{const u=p.indexOf(l);return u>-1?f(r(c)).pipe(I(d=>({hash:c,found:{type:!0,index:u,events:d}}))):n(c,l).pipe(I(d=>({hash:c,found:{type:!1,validity:d}})))}),f)},i=(c,l,a)=>o(c,l,a.has(c)).pipe(P(f=>{const{found:p}=f;return p.type||p.validity?.success===!1?se(f):e.pipe(s(c),P(u=>u.blocks.get(c).children),uf(),P(u=>i(u,l,a)))}));return c=>e.pipe(Z(1),P(l=>i(l.finalized,c,new Set(l.blocks.keys()))))},lh=new Uint8Array([2]),uh=(e,t)=>J(oe([lh,me(e),me(t)])),cc="TaggedTransactionQueue",ac="validate_transaction",[,fh]=Ee({InvalidTransaction:Ee({Call:O,Payment:O,Future:O,Stale:O,BadProof:O,AncientBirthBlock:O,ExhaustsResources:O,Custom:D,BadMandatory:O,MandatoryValidation:O,BadSigner:O}),UnknownTransaction:Ee({CannotLookup:O,NoUnsignedValidator:O,Custom:D})}),hh=tt(e=>{const t=D.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=fh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),dh=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(cc,ac).value[1]}catch{return hh}}));return e(n,`${cc}_${ac}`,uh(r,n)).pipe(qr(s),I(([o,i])=>i(o)))},ph=e=>t=>new U(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}),vh=e=>t=>new U(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)}}),lc=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let l=0,a=0,f=0;const p=()=>{const u=o.get(a);if(!u){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const d=a++;o.delete(d),f!==d&&c.set(d,[]);let h=!1,v=u.subscribe({next(m){f===d?r.next(m):c.get(d).push(m)},complete(){if(h=!0,i.delete(d),d===f)for(f++;c.has(f)&&(c.get(f).forEach(m=>r.next(m)),c.delete(f),!i.has(f));)f++;p()},error(m){r.error(m)}});h||i.set(d,v)};return s=new _t,s.add(n.subscribe({next(u){const d=l++;o.set(d,Wn(()=>e(u,d))),i.size<t&&p()},error(u){r.error(u)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(u=>u.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Qr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),mh=(e,t,n)=>{const{getFollower:r,startFollow:s,follow$:o,getHeader:i}=Kf(e),c=jf(r),{withRecovery:l,withRecoveryFn:a}=Vf(),f=new Ue,p=A=>B=>new U(_=>{f.next({type:"blockUsage",value:{type:"hold",hash:A}});const V=B.subscribe(_);return V.add(()=>{setTimeout(()=>{f.next({type:"blockUsage",value:{type:"release",hash:A}})},0)}),V}),u=A=>(B,..._)=>A(B,..._).pipe(p(B)),d=(A,B)=>(_,...V)=>new U(de=>{let ae=!1;return g.pipe(Z(1)).subscribe(We=>{ae=We.blocks.has(_)}),ae?A(_,...V).subscribe(de):de.error(new Ze(_,B))}),h=A=>r().unpin(A).catch(B=>{if(!(B instanceof Gn))throw B}),v=(A,B)=>d(u(hn(g,a(Ot(A)),`stop-${B}`)),B),m=new Map,y=u(a(Ot(c("storage")))),b=A=>y(A,"hash","0x3a636f6465",null).pipe(I(B=>B)),x=new Ue,g=ah(o,u(a(Ot(c("call")))),b,t,n,f,x,A=>{h(A).catch(B=>{console.error("unpin",B)}),A.forEach(B=>{m.delete(B)})},A=>{m.delete(A)}),w=d(u(A=>g.pipe(Z(1),P(B=>B.runtimes[B.blocks.get(A).runtime].runtime))),"getRuntimeCtx"),k=A=>B=>B.pipe(lc(_=>w(A(_)).pipe(I(V=>[_,V])))),$=(A,B,_)=>{const V=m.get(A)??new Map,de=V.get(B);if(de)return de;m.set(A,V);let ae;const We=_.pipe(Xn({connector:()=>ae=new Hn}),fn({complete(){V.set(B,ae)}}),vh());return V.set(B,We),We},E=g.pipe(Me(A=>!A.recovering),be((A,B)=>A.finalized===B.finalized),Kn((A,B)=>{let _=B.blocks.get(B.finalized);const V=[_],de=A.at(-1);if(!de)return V;for(;_.number>de.number+1&&(_=B.blocks.get(_.parent),!!_);)V.unshift(_);return V},[]),jn(),I(Qr),dn),T=g.pipe(be((A,B)=>A.best===B.best),I(A=>Qr(A.blocks.get(A.best))),dn),M=g.pipe(Me(A=>!A.recovering),be((A,B)=>A.finalized===B.finalized&&A.best===B.best),Kn((A,B)=>{const _=De=>A.get(De)||Qr(B.blocks.get(De)),V=_(B.best),de=_(B.finalized),ae=V.number-de.number+1,We=new Array(ae);for(let De=0,Rc=V.hash;De<ae;De++)We[De]=_(Rc),Rc=We[De].parent;return new Map(We.map(De=>[De.hash,De]))},new Map),I(A=>[...A.values()]),dn),W=g.pipe(be((A,B)=>A.finalizedRuntime===B.finalizedRuntime),Yn(({finalizedRuntime:{runtime:A}})=>A.pipe(ph(null))),dn),q=W.pipe(I(A=>A?.lookup.metadata??null)),te=Ff(E.pipe(I(A=>A.hash)),T.pipe(I(A=>A.hash)),p),Y=v(c("body"),"body"),he=A=>Yr($(A,"body",Y(A))),ge=v(c("storage"),"storage"),ce=te(d((A,B,_,V=null,de)=>g.pipe(Z(1),P(ae=>ae.runtimes[ae.blocks.get(A).runtime].runtime),P(ae=>{const We=_(ae);return $(A,`storage-${B}-${We}-${V??""}`,ge(A,B,We,V)).pipe(de?I(De=>de(De,ae)):Qe)})),"storage")),et=zf(r,l),ir=te(d(hn(g,(A,B,_)=>et(A,B,_??null,!1),"storageQueries"),"storageQueries")),mn=te(d(hn(g,A=>Wn(()=>i(A)),"header"),"header")),cr=A=>ce(A,"value",B=>B.events.key,null,(B,_)=>_.events.dec(B)),bd=v(c("call"),"call"),_c=te((A,B,_)=>$(A,`call-${B}-${_}`,bd(A,B,_))),ds=dh(_c,w),Oc=A=>$(A,"body",Y(A)),gd=ic(g,Oc,ds,cr),wd=ic(g,Oc,ds,()=>se()),xd=W.pipe(Me(Boolean),Z(1),P(A=>{const{enc:B}=A.dynamicBuilder.buildStorage("System","BlockHash").keys;let _;try{_=B(0)}catch{_=B(0n)}return ce(null,"value",()=>_,null)}),un(1));ln(W,M).subscribe({error(){}});let ps=Ae,yn=!1,vs=0;const Ed=A=>{vs+=A,yn=!0,ps=s()},kd=A=>g.pipe(Z(1),P(({runtimes:B})=>ln(...Object.values(B).map(_=>_.codeHash$.pipe(P(V=>A===V?_.runtime:yt)))).pipe(hf(null),Z(1)))),Tc=(A,B=!1)=>{let _=A||"finalized",V=!1;if(yn&&g.pipe(Z(1)).subscribe(ae=>{_=ae[_]||_,V=ae.blocks.has(_)}),!V){if(B)throw new Ze(_,"holdBlock");return Ae}f.next({type:"blockUsage",value:{type:"hold",hash:_}});let de=()=>{f.next({type:"blockUsage",value:{type:"release",hash:_}}),de=Ae};return()=>{de()}};return[{follow$:o,finalized$:E,best$:T,bestBlocks$:M,newBlocks$:x,runtime$:W,metadata$:q,genesis$:xd,getRuntime$:kd,header$:mn,body$:he,call$:_c,storage$:ce,storageQueries$:ir,eventsAt$:cr,withHodl:A=>B=>new U(_=>{const V=B.subscribe(_);return V.closed||V.add(Tc(A)),V}),holdBlock:Tc,trackTx$:gd,trackTxWithoutEvents$:wd,validateTx$:ds,pinnedBlocks$:g,withRuntime:k,getRuntimeContext$:te(w),unfollow:()=>{yn!=null&&(vs--,yn&&!vs&&(yn=null,ps(),ps=Ae))}},Ed]};var yh=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const bh=({storageSubscription:e,...t})=>n=>{const r={},s=Ot(t.storage),o=Ot(t.call),i=Ot(t.header),c=Ot(t.body),l=v=>i(v).pipe(I(wr[1])),a=v=>s(v,"hash","0x3a636f6465",null).pipe(I(m=>m)),f=(v,m)=>n(v).pipe(Se(()=>se(null)),P(y=>y?se(y):Qi((...b)=>o(m,...b)).pipe(I(b=>nc(Dt(pt.dec(b)),b,v)))),fn(y=>{r[v]=y})),p=v=>a(v).pipe(P(m=>{const y=r[m];return y?se(y):f(m,v)})),u=(v,m,y,b=null,x)=>p(v).pipe(P(g=>s(v,m,y(g),b).pipe(I(w=>x?x(w,g):w))));return{body$:c,header$:l,storage$:u,storageQueries$:(v,m,y)=>new U(b=>e(v,m,y||null,x=>b.next(x),x=>b.error(x),()=>{b.complete()})),call$:o,eventsAt$:v=>u(v,"value",m=>m.events.key,null,(m,y)=>y.events.dec(m)),getRuntimeContext$:p}},gh=()=>se(null),tr=new Map,wh=(e,t={})=>{const{getMetadata:n,setMetadata:r}=t,s=tr.get(e);if(s)return s.refCount++,s.client;const o=()=>{const f=tr.get(e);!f||f.refCount<=1?(tr.delete(e),e.destroy()):f.refCount--};let i=null,c=0,l=null;const a={chainHead$:f=>{c++,l||(l=f||1),i||(i=mh(e.chainHead,n||gh,r||Ae));const[p,u]=i;if(l===c){const d=c;c=0,l=null,i=null,u(d)}return p},archive:bh(e.archive),broadcastTx$:yh(e.transaction),destroy:o};return tr.set(e,{client:a,refCount:1}),a},xh=(e,t)=>e.pipe(Wr(n=>n.blocks.has(t)),be((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}),be(),Wr(n=>n!=="finalized",!0)),Tt=(e,t)=>(n,...r)=>e(n,...r).pipe(Se(s=>{if(!(s instanceof Ze))throw s;return t(n,...r).pipe(Se(o=>{throw console.warn(o),s}))}));class Rt{constructor(){}_runtime(t){}}class Zr{constructor(){}_compatibility(t){}}const nr=new WeakMap,uc=new WeakMap,rr=e=>e instanceof Rt?uc.get(e):nr.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(xt||{});const Eh=Ie(ru),kh=Ie(_r),Ah=Fe(Eh,kh),Sh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Me(i=>i!=null));let o=await ze(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Ah.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Zr;return nr.set(c,{runtime:i,getEntryPoint(l,a,f){const p=o[l]?.[a]?.[f];if(p==null)throw new Error(`Descriptor for ${l} ${a}.${f} does not exist`);return r[p]},typedefNodes:s}),c})},Ih=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(s=>s!=null));let r=await ze(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Rt;return uc.set(n,{runtime:t}),n}),Jr=new WeakMap,fc=e=>(Jr.has(e.metadataRaw)||Jr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Jr.get(e.metadataRaw)),Pt=(e,t,n)=>{const r=(i,c)=>{var l;const a=fc(i);return(l=a.typeNodes)[c]||(l[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Rt)return{args:Te.Identical,values:Te.Identical};const l=nr.get(i);c||(c=l.runtime());const a=n(c);if(a==null)return{args:Te.Incompatible,values:Te.Incompatible};const f=l.typedefNodes,p=fc(c),u=t(l),d=cu(u,h=>f[h],a,h=>r(c,h),p.compat);return{args:d.args.level,values:d.values.level}}const o=dc(e,i=>hc(s(i)));return{isCompatible:dc(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>l=>Wt([l.pipe(i.withRuntime(c)),e]).pipe(I(([[a,f],p])=>[a,p,f])),compatibleRuntime$:(i,c)=>Wt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,l)=>{if(i instanceof Rt)return!0;const a=s(i,c);if(a.args===Te.Incompatible)return!1;if(a.args>Te.Partial)return!0;if(a.values===Te.Incompatible)return!1;const f=n(c);return f==null?!1:si(f.args,p=>r(c,p),l)},valuesAreCompatible:(i,c,l)=>{if(i instanceof Rt)return!0;const a=s(i,c).values;if(a===Te.Incompatible)return!1;if(a>Te.Partial)return!0;const f=nr.get(i),p=t(f);return si(p.values,u=>f.typedefNodes[u],l)},getRuntimeTypedef:r}},hc=e=>Math.min(e.args,e.values),dc=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Zr||r instanceof Rt?t(...n):e.then(s=>t(...n,s))},Bh=(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 f=a.lookup.metadata.pallets.find(u=>u.name===e)?.constants.find(u=>u.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const p=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return i.set(a,p),p},l=a=>{if(a){const f=rr(a).runtime(),p=c(f);if(!n(a,f,p))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return p}return r.then(l)};return Object.assign(l,{isCompatible:s,getCompatibilityLevel:o})},$h=Xn({connector:()=>new Hn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function pn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new no)}:Ae;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 es=Symbol("EMPTY_VALUE"),ts=e=>t=>new U(n=>{let r=0,s=null,o=es,i=!1;const c=()=>{const a=e(o,r++);o=es,s=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){o!==es?c():(s=null,i&&n.complete())}})},l=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),l.unsubscribe()}});let pc={};const Ch=e=>t=>new U(n=>{let r=pc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===pc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Xt=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)),_h=()=>{const e=new xu(new Ue);return[e.pipe(vf()),()=>fn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Ue)},complete:()=>{e.value.complete(),e.next(new Ue)}})]},Oh=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,f=>f.hash),I(([f,p,u])=>{const d=u.lookup.metadata.pallets.find(h=>h.name===e)?.events?.type;if(d==null||u.lookup.metadata.lookup[d].def.tag!=="variant"||u.lookup.metadata.lookup[d].def.value.find(h=>h.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(p,u,null))throw l();return[f,p,u]}),lc(([f,p,u])=>n.eventsAt$(f.hash).pipe(I(d=>d.filter(h=>h.event.type===e&&h.event.value.type===t).map(h=>{if(!c(p,u,h.event.value.value))throw l();return{meta:{phase:h.phase,block:f},payload:h.event.value.value}})))),$h);return{watch:f=>a.pipe(P(p=>f?p.filter(u=>f(u.payload)):p)),pull:()=>ze(a),filter:f=>f.filter(p=>p.type===e&&p.value.type===t).map(p=>p.value.value),getCompatibilityLevel:s,isCompatible:r}},Th=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${l})`);return Object.assign((...f)=>{const p=f[f.length-1],u=Xt(p),{signal:d,at:h}=u?p:{},v=h??null,m=o(n,v).pipe(P(([y,b])=>{let x;try{x=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${l}) not found`)}if(!i(y,b,f))throw a();return n.call$(v,l,J(x.args.enc(f))).pipe(I(x.value.dec),I(g=>{if(!c(y,b,g))throw a();return g}))}),n.withHodl(v));return pn(m,d)},{getCompatibilityLevel:s,isCompatible:r})},vc=I(e=>e.mapped),Rh=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:l,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",p=e==="System"&&t==="BlockHash",u=n.runtime$.pipe(Me(Boolean),Z(1),I(({dynamicBuilder:E})=>typeof E.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Qe),un()),d=ui(sf(u),I(([E,T])=>T(E))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=E=>new Error(`Invalid Arguments calling ${e}.${t}(${E})`),m=E=>{try{return E.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...E)=>{const T=E[E.length-1],M=T==="best",W=M||T==="finalized"?E.slice(0,-1):E;return n[M?"best$":"finalized$"].pipe(ts(()=>b(...W,M?{at:"best"}:{})),be((q,te)=>q.raw===te.raw),vc)},b=(...E)=>{const T=E[E.length-1],M=Xt(T),{at:W}=M?T:{},q=W??null,te=gt(c).pipe(P(Y=>n.storage$(q,"value",he=>{const ge=m(he),ce=E.length===ge.len?E:E.slice(0,-1);if(E!==ce&&!M)throw v(E);if(!l(Y,he,ce))throw h();return ge.keys.enc(...ce)},null,(he,ge)=>{const ce=m(ge),et=he===null?ce.fallback:ce.value.dec(he);if(!a(Y,ge,et))throw h();return{raw:he,mapped:et}})),n.withHodl(q));return f?n.pinnedBlocks$.pipe(I(Y=>{const he=q==="finalized"||!q?Y.finalized:q==="best"?Y.best:q,ge=Y.blocks.get(he);if(!ge)throw new Ze(he,"System.Number");return ge.number}),be(),d,I(Y=>({raw:Y.toString(),mapped:Y})),Se(Y=>{if(Y instanceof Ze)return te;throw Y})):p&&Number(E[0])===0?n.genesis$.pipe(I(Y=>({raw:Y,mapped:$n.fromHex(Y)}))):te},x=async(...E)=>{const T=E[E.length-1],M=Xt(T),{signal:W}=M?T:{};return pn(b(...E).pipe(vc),W)},g=async(...E)=>{const T=E[E.length-1],M=Xt(T),{signal:W,at:q}=M?T:{},te=q??null,Y=gt(c).pipe(P(he=>n.storage$(te,"descendantsValues",ge=>{const ce=m(ge);if(hc(i(he,ge))===Te.Incompatible)throw h();if(E.length>ce.len)throw v(E);const et=E.length>0&&M?E.slice(0,-1):E;if(E.length===ce.len&&et===E)throw v(E);return ce.keys.enc(...et)},null,(ge,ce)=>{const et=m(ce),ir=ge.map(({key:mn,value:cr})=>({keyArgs:et.keys.dec(mn),value:et.value.dec(cr)}));if(ir.some(({value:mn})=>!a(he,ce,mn)))throw h();return ir})),n.withHodl(te));return pn(Y,W)},w=(E,T)=>Promise.all(E.map(M=>x(...T?[...M,T]:M))),k=(...E)=>{const T=E.at(-1),M=Xt(T);return r(e,t,M?E.slice(0,-1):E,M&&T.at==="best")},$=(...E)=>{const T=E.at(-1);if(T instanceof Zr||T instanceof Rt){const M=E.slice(0,-1),W=rr(T).runtime();if(!l(T,W,M))throw h();return m(W).keys.enc(...M)}return c.then(M=>$(...E,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:$,getValue:x,getValues:w,getEntries:g,watchValue:y,watchEntries:k}},ns=()=>new Error("Unkown signer"),Ph=e=>{const{extrinsic:t}=e,n=er(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 ns()}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 ns();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 ns()},Uh={Ed25519:0,Sr25519:1,Ecdsa:2},Mh=(e,t,n,r,s,o)=>{const[i,c]=Ph(e),l=oe([Ir.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Uh[o],...n]),...r,s]);return oe([pe.enc(l.length),l])},[sr,vn]=["<Bytes>","</Bytes>"].map(e=>He.fromText(e).asBytes()),Lh=e=>async t=>{let n=!0,r;for(r=0;n&&r<sr.length;r++)n=sr[r]===t[r];n=n&&r===sr.length;const s=t.length-vn.length;for(r=0;n&&r<vn.length;r++)n=vn[r]===t[s+r];return n=n&&r===vn.length,e(n?t:oe([sr,t,vn]))};function Dh(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,l=Vt)=>{const a=Dt(Sr(i)),f=[],p=[];a.extrinsic.signedExtensions.map(({identifier:h})=>{const v=o[h];if(!v)throw new Error(`Missing ${h} signed extension`);f.push(v.value),p.push(v.additionalSigned)});const u=oe([s,...f,...p]),d=await n(u.length>256?l(u):u);return Mh(a,e,d,f,s,t)},signBytes:Lh(n)}}Uint8Array.from([1]);const Vh=(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 Hh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Fh=e=>1<<Math.ceil(Math.log2(e)),jh=gn(G(2)[0],e=>{const t=Math.min(Math.max(Fh(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Hh(t)-1,1),15),o=n/r<<4;return Xe[0](s|o)}),[zh]=ie({tip:pe,asset:dt(G(1/0))}),mc=new Uint8Array,rs=Uint8Array.from([0]),ss=e=>({value:e,additionalSigned:mc}),os=e=>({value:mc,additionalSigned:e}),is=(e,t)=>({value:e,additionalSigned:t}),yc=(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={},...l})=>{const a=[],f=Vh(t,n),p=d=>{const[h,v]=r[d],m=c[d];try{return Mt({value:h,additionalSigned:v},(y,b)=>{const x=m?.[b];return x instanceof Uint8Array?x:y(x)})}catch{return a.push(d),null}},u=Mt(r,([d,h],v)=>{if(c[v])return p(v);switch(v){case"CheckNonce":return ss(d(i));case"CheckMortality":return s.mortal?is(jh({period:s.period,startAtBlock:s.startAtBlock.height}),me(s.startAtBlock.hash)):is(rs,e);case"ChargeTransactionPayment":return ss(d(o));case"ChargeAssetTxPayment":return ss(zh({tip:o,asset:l.asset}));case"CheckGenesis":return os(e);case"CheckMetadataHash":return is(rs,rs);case"CheckSpecVersion":return os(h(f.spec_version));case"CheckTxVersion":return os(h(f.transaction_version));default:return p(v)}});return a.forEach(d=>{delete u[d]}),Mt(u,(d,h)=>({...d,identifier:h}))}},bc="AccountNonceApi_account_nonce",Wh={1:D.dec,2:Xe.dec,4:Ve.dec,8:Nt.dec},qh=(e,t,n)=>e(n,bc,t).pipe(I(r=>{const s=me(r),o=Wh[s.length];if(!o)throw new Error(`${bc} retrieved wrong data`);return o(s)})),Kh=(e,t,n,r,s,o={})=>Wt([o.nonce?se(o.nonce):Xh(e,J(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(Z(1),P(([i,c,l])=>{const a=yc(me(l),c.lookup,c.dynamicBuilder),f=o.mortality??{period:64,mortal:!0},p=a({nonce:i,tip:o.tip??0n,mortality:f.mortal?{mortal:!0,period:f.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,p,c.metadataRaw,r.number)})),Xh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Kn((i,c)=>c.parent===i?c.hash:i,o),Li(o),be()),r=o=>n(o).pipe(Z(2),Yn(i=>qh(e.call$,t,i))),s=o=>Wt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),Se(c=>se({success:!1,value:c}))))).pipe(Z(1));return e.pinnedBlocks$.pipe(Me(o=>!o.recovering&&o.blocks.size>0),Z(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(l=>!l.unpinnable&&l.children.size===0&&l.number>=c.number).map(l=>l.hash)}),Yn(s),I(o=>{const i=o.reduce((c,l)=>l.success&&l.value>=(c??0)?l.value:c,null);if(i==null)throw o[0].value;return i}))};var Yh=Object.defineProperty,Gh=(e,t,n)=>t in e?Yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nh=(e,t,n)=>Gh(e,t+"",n);const Qh=e=>J(Vt(me(e))),Zh=(e,t)=>new U(n=>{const r=new Map;let s,o;const i=()=>{let l=s.best,a=r.get(l),f=s.blocks.get(l).number;for(;!a;){const d=s.blocks.get(l);if(!d)break;a=r.get(l=d.parent),f--}if(!a)return;const p=f<=s.blocks.get(s.finalized).number,u=a.found.type;if(u&&o?.found&&o.hash===a.hash){p&&n.complete();return}n.next(o=a.found.type?{found:u,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:u,validity:a.found.validity}),p&&(u?n.complete():a.found.validity?.success===!1&&n.error(new cs(a.found.validity.value)))},c=t.pipe(be((l,a)=>l.finalized===a.finalized&&l.best===a.best)).subscribe({next:l=>{s=l,r.size!==0&&i()},error(l){n.error(l)}});return c.add(e.subscribe({next:l=>{r.set(l.hash,l),i()},error(l){n.error(l)}})),c}).pipe(be((n,r)=>n===r)),Jh=(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 cs extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof He?r.asHex():r,2)),Nh(this,"error"),this.name="InvalidTxError",this.error=t}}const as=(e,t,n,r=!1)=>{const s=Qh(n),o=(a,f)=>({type:a,txHash:s,...f}),i=e.pinnedBlocks$.pipe(Z(1),P(a=>{let f=[];return a.finalizedRuntime.runtime.pipe(I(p=>p.getMortalityFromTx(n)),Se(()=>se({mortal:!1})),I(p=>{const{best:u,finalized:d}=a;let h=u;for(;h!==d;)f.push(h),h=a.blocks.get(h).parent;if(f.push(d),!p.mortal)return[d,u];const{phase:v,period:m}=p,y=a.blocks.get(u),b=y.number,x=Math.floor((b-v)/m)*m+v;let g=[a.blocks.get(a.finalized)];for(;g.length&&g[0].number<x;)g=g.flatMap(w=>[...w.children]).map(w=>a.blocks.get(w)).filter(Boolean);return(g.length?g:[y]).map(w=>w.hash)}),P(p=>ln(...[...new Set(p)].map(u=>e.validateTx$(u,n).pipe(I(d=>({at:u,result:d})))))),Wr(({result:p})=>!p.success,!0),rf((p,u)=>[...p,u],[]),I(p=>{const u=new Map(p.filter(({result:d})=>!d.success).map(d=>[d.at,d.result]));if(u.size<p.length)return null;throw new cs(u.get(f.find(d=>u.has(d))??[...u.keys()][0]).value)}),Me(Boolean))})),c=new U(a=>{const f=e.trackTx$(n).subscribe(a);return f.add(t(n).subscribe({error(p){a.error(p)}})),f}),l=Zh(c,e.pinnedBlocks$).pipe(I(a=>a.found?o("txBestBlocksState",{found:!0,block:{index:a.index,number:a.number,hash:a.hash},...Jh(a.events,a.index)}):o("txBestBlocksState",{found:!1,isValid:a.validity?.success!==!1})));return zn(r?se(o("signed",{})):yt,i,se(o("broadcasted",{})),l.pipe(Ch(({found:a,type:f,...p})=>a?se(o("finalized",p)):yt)))},gc=async(e,t,n,r)=>Hu(as(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),ed=At().enc,td=new Uint8Array(64),nd=new Uint8Array(65),rd=e=>()=>e?nd:td,[,sd]=ie({weight:ie({ref_time:Cn,proof_size:Cn}),class:Ee({Normal:O,Operational:O,Mandatory:O}),partial_fee:ws}),wc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:l},a)=>Object.assign(f=>{const p=(g,w,k={})=>{const $=rr(g).runtime(),{dynamicBuilder:E,assetId:T,lookup:M}=$;let W;try{W=E.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(g,$,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=k;if(k.asset){if(T==null||!Or(k.asset,Pn(M(T)),he=>l($,he)))throw new Error("Incompatible runtime asset");q={...k,asset:E.buildDefinition(T).enc(k.asset)}}const{location:te,codec:Y}=W;return{callData:He.fromBytes(oe([new Uint8Array(te),Y.enc(w)])),options:q}},u=(g,w={})=>i(n,null).pipe(I(([k])=>p(k,g,w))),d=g=>g?p(g,f).callData:ze(u(f).pipe(I(w=>w.callData))),h=(g,{...w},k)=>u(f,w).pipe(P(({callData:$,options:E})=>Kh(n,g,$.asBytes(),k,w.customSignedExtensions||{},E))),v=(g,{at:w,...k}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(I($=>$.find(E=>E.hash===w)))).pipe(Z(1),P($=>$?h(g,k,$).pipe(I(E=>({tx:J(E),block:$}))):Fn(()=>new Error(`Uknown block ${w}`)))),m=(g,w)=>ze(v(g,w)).then(k=>k.tx),y=(g,w)=>ze(v(g,w)).then(({tx:k,block:$})=>gc(n,r,k,$.hash)),b=(g,w)=>v(g,w).pipe(P(({tx:k})=>as(n,r,k,!0))),x=async(g,w)=>{typeof g=="string"&&(g=g.startsWith("0x")?me(g):ed(g));const k=g.length===20,$=Dh(g,k?"Ecdsa":"Sr25519",rd(k)),E=me(await m($,w)),T=J(oe([E,Ve.enc(E.length)])),M=n.getRuntimeContext$(null).pipe(I(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return sd}})),W=n.call$(null,"TransactionPaymentApi_query_info",T);return ze(Wt([W,M]).pipe(I(([q,te])=>te(q))))};return{getPaymentInfo:x,getEstimatedFees:async(g,w)=>(await x(g,w)).partial_fee,decodedCall:{type:e,value:Bt(t,f)},getEncodedData:d,sign:m,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var od=Object.defineProperty,id=(e,t,n)=>t in e?od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Je=(e,t,n)=>(id(e,typeof t!="symbol"?t+"":t,n),n),ls=Symbol("SUSPENSE"),cd=class extends Promise{constructor(e){super(e)}},xc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ec=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ce={},or=class extends U{constructor(e,t,n=Ae){super(r=>{const s=new cn({next:r.next.bind(r),error:r.error.bind(r),complete:Ae});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ce,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new xc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ce&&r.next(this.currentValue)):(this.subject=new Ue,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new cn({next:i=>{this.promise&&i!==ls&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const l=this.subject;this.subject=null,this.currentValue=Ce;const a=(c=this.promise)==null?void 0:c.rej;a&&i===ls&&(this.promise.rej=()=>{a(i)}),l.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ec),this.promise=null),this.currentValue!==Ce)return this.subject.complete();if(t===Ce){const i=this.subject;return this.subject=null,i.error(new Ec)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ce&&this.currentValue===Ce&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Je(this,"subject",null),Je(this,"subscription",null),Je(this,"refCount",0),Je(this,"currentValue",Ce),Je(this,"promise",null),Je(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof or?s:new or(s,Ce)}),Je(this,"getRefCount",()=>this.refCount),Je(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ce&&this.currentValue!==ls)return this.currentValue;if(this.defaultValue!==Ce)return this.defaultValue;if(this.refCount===0)throw new xc;const r=new cd((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Je(this,"getDefaultValue",()=>this.defaultValue),t===Ce&&delete this.getDefaultValue}};function kc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function ad(e,t){const n=new ld,r=typeof t=="function"?t:()=>t,s=o=>{for(let p=o.length-1;o[p]===void 0&&p>-1;p--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const l=new or(e(...o),r(...o),()=>{n.delete(i)}),a=new U(p=>{const u=n.get(i);let d=l;return u?u!==a&&(d=u,kc(d,a)):n.set(i,f),d.subscribe(p)});kc(l,a);const f=a;return n.set(i,f),f};return(...o)=>s(o)}var ld=class{constructor(){Je(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 ud(e,t){return new or(e,t)}var us=(...e)=>(typeof e[0]=="function"?ad:ud)(e[0],e.length>1?e[1]:Ce);const Ac=(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:l}=c,a=s.get(l);(!a||a.value!==c.value)&&o.set(l,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))}},Sc=(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}},Ic=(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)},fd=(e,t,n)=>{const r=us((c,l,a)=>{const f=Ic(c,l),p=(m,y)=>{const b=xh(e,y.hash).pipe(Me(x=>!x),Z(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(P(x=>x===m?.rootHash?se({...m,block:y,deltas:null,prev:m.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),I(([g,w])=>[g,f(w)]),I(([g,w])=>({prev:m&&m.block.hash,rootHash:x,block:y,...Ac(m?.entries??[],g,w)})))),Di(b),Se(x=>x instanceof Ze?yt:Fn(()=>x)))},u=e.pipe(be((m,y)=>m.finalized===y.finalized),ts(({blocks:m,finalized:y})=>p(null,m.get(y))),Z(1),I(m=>({blocks:{[m.block.hash]:m},finalized:m.block.hash}))),[d,h]=_h(),v=e.pipe(be((m,y)=>m.best===y.best),qr(d),ts(([m,y])=>{const{best:b}=m,{blocks:x}=y;let g=x[b]?null:b;if(!g)return yt;const w=Sc(g,x,m);return w?p(w,m.blocks.get(g)).pipe(I(k=>(x[g]=k,y))):(g=m.finalized,p(x[y.finalized],m.blocks.get(g)).pipe(I(k=>(k.prev=null,{blocks:{[g]:k},finalized:g}))))}));return ln(u,v).pipe(h())}),s=c=>(l,a,f)=>{const p=r(l,a,f),u=Ic(l,a),d=c?"finalized":"best";return Wt([p.pipe(lf(0)),e.pipe(be((h,v)=>h[d]===v[d]))]).pipe(I(([h,v])=>Sc(v[d],h.blocks,v,!0)),Me(Boolean),be(),Li(null),pf(),qr(p),n(([[,h]])=>h.block.hash),I(([[[h,v],m],y])=>[h,v,m,u(y)]),P(([h,v,m,y])=>{if(!h)return[v];let b=v;const x=[];for(;b&&b.block.number>h.block.number;)x.unshift(b),b=b.prev?m.blocks[b.prev]:null;if(c&&(m.finalized=v.block.hash,x.length)){const{blocks:g}=m;Object.keys(g).forEach(w=>{g[w].block.number<x[0].block.number&&delete g[w]})}return h===b?x:[{...v,...h.rootHash===v.rootHash?{entries:h.entries,deltas:null}:Ac(h.entries,v.entries,y)}]}))},o=us(s(!0)),i=us(s(!1));return(c,l,a,f)=>{const p=f?i:o;return e.pipe(Z(1),P(u=>u.runtimes[u.blocks.get(u[f?"best":"finalized"]).runtime].runtime),I(u=>u.dynamicBuilder.buildStorage(c,l).keys.enc(...a))).pipe(Z(1),P(u=>p(c,l,u)),I(({block:{hash:u,number:d,parent:h},deltas:v,entries:m},y)=>{const b=y>0?v:{deleted:[],upserted:m};return{block:{hash:u,number:d,parent:h},entries:m.map(fs),deltas:b&&{deleted:b.deleted.map(fs),upserted:b.upserted.map(fs)}}}))}},fs=e=>e.dec,Bc="RuntimeViewFunction",$c="execute_view_function",hs=Bc+"_"+$c,hd=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const l=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const f=a[a.length-1],p=Xt(f),{signal:u,at:d}=p?f:{},h=d??null,v=o(n,h).pipe(P(([m,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Bc,$c)}catch{throw new Error(`Runtime entry RuntimeCall(${hs}) not found`)}let x;try{x=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(m,y,a))throw l();const g=x.args.enc(a),w=oe([me(y.lookup.metadata.pallets.find(({name:k})=>k===e).viewFns.find(({name:k})=>k===t).id),C.enc(g.length),g]);return n.call$(h,hs,J(w)).pipe(I(k=>{try{const $=b.value.dec(k);if(!("success"in $&&"value"in $)||!("type"in $.value)&&!("asBytes"in $.value))throw null;return $}catch{throw new Error(`Unexpected RuntimeCall(${hs}) type`)}}),I(({success:k,value:$})=>{if(!k)throw new Error(`ViewFn API Error: ${$.type}`);const E=x.value.dec($.asBytes());if(!c(m,y,E))throw l();return E}))}),n.withHodl(h));return pn(v,u)},{getCompatibilityLevel:s,isCompatible:r})},dd=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Cc=(e,t,n)=>{const r={},s=m=>new Proxy(r,{get(y,b){return m(b)}}),o=m=>{const y={};return s(b=>(y[b]||(y[b]={}),s(x=>(y[b][x]||(y[b][x]=m(b,x)),y[b][x]))))},i=(m,y)=>m.lookup.metadata.pallets.find(b=>b.name===y),c=fd(t.pinnedBlocks$,t.storage$,t.withRuntime),l=o((m,y)=>Rh(m,y,t,c,Pt(e,b=>b.getEntryPoint(xt.Storage,m,y),b=>{const x=i(b,m)?.storage?.items.find(g=>g.name===y);return x==null?null:su(x)}))),a=(m,y,b,x)=>{if(b==null)return null;const g=m.lookup(b);if(g.type!=="enum")throw new Error("Expected enum");if(g.value[x]==null)return null;const w=ou(g.value[x]);return{args:y==="args"?w:Mn,values:y==="args"?Mn:w}},f=o((m,y)=>wc(m,y,t,n,Pt(e,b=>b.getEntryPoint(xt.Tx,m,y),b=>a(b,"args",i(b,m)?.calls?.type,y)),!0)),p=o((m,y)=>Oh(m,y,t,Pt(e,b=>b.getEntryPoint(xt.Event,m,y),b=>a(b,"values",i(b,m)?.events?.type,y)))),u=o((m,y)=>Bh(m,y,Pt(e,b=>b.getEntryPoint(xt.Const,m,y),b=>{const x=i(b,m)?.constants.find(g=>g.name===y)?.type;return x==null?null:iu(x)}))),d=o((m,y)=>Th(m,y,t,Pt(e,b=>b.getEntryPoint(xt.Api,m,y),b=>ri(b.lookup.metadata.apis.find(x=>x.name===m).methods.find(x=>x.name===y))))),h=o((m,y)=>hd(m,y,t,Pt(e,b=>b.getEntryPoint(xt.ViewFns,m,y),b=>ri(b.lookup.metadata.pallets.find(x=>x.name===m).viewFns.find(x=>x.name===y))))),v=(m,y)=>{const{lookup:b,dynamicBuilder:x}=rr(y).runtime();try{const g=x.buildDefinition(b.call).dec(m.asBytes()),w=g.type,k=g.value.type,$=g.value.value;return wc(w,k,t,n,Pt(e,E=>E.getEntryPoint(xt.Tx,w,k),E=>a(E,"args",i(E,w)?.calls?.type,k)),!1)($)}catch{throw new Error("createTx: invalid call data")}};return{query:l,txFromCallData:(m,y)=>y?v(m,y):e.then(b=>v(m,b)),tx:f,event:p,apis:d,constants:u,view:h}};function pd(e,{getMetadata:t,setMetadata:n}={}){const r=Uf(e),s=wh(r,{getMetadata:t?m=>gt(t(m)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),l=s.archive(c.getRuntime$),a={...c,genesis$:Wn(o).pipe(I(({genesisHash:m})=>m),Se(()=>i),un(1)),storage$:Tt(c.storage$,l.storage$),body$:Tt(c.body$,l.body$),call$:Tt(c.call$,l.call$),header$:Tt(c.header$,l.header$),eventsAt$:Tt(c.eventsAt$,l.eventsAt$),storageQueries$:Tt(c.storageQueries$,l.storageQueries$),getRuntimeContext$:Tt(c.getRuntimeContext$,l.getRuntimeContext$)},f=r.request;let p;const u=new WeakMap,d=m=>{const y=u.get(m)||Sh(m,a);return u.set(m,y),y},h=()=>p??(p=Ih(a)),{broadcastTx$:v}=s;return{getChainSpecData:o,blocks$:a.newBlocks$,hodlBlock:m=>a.holdBlock(m,!0),finalizedBlock$:a.finalized$,getFinalizedBlock:()=>ze(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>ze(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:m=>ze(a.body$(m)),getBlockHeader:m=>ze(a.header$(m??null)),submit:(...m)=>gc(a,v,...m),submitAndWatch:m=>as(a,v,m),getTypedApi:m=>{const y=d(m);return Object.assign(Cc(y,a,v),{compatibilityToken:y})},getUnsafeApi:()=>{const m=h();return Object.assign(Cc(m,a,v),{runtimeToken:m})},rawQuery:(m,{at:y,signal:b}={})=>pn(a.storage$(y??null,"value",()=>{const x=m.match(dd)?.[1];return x?`0x${x}`:He.fromText(m).asHex()}),b),destroy:()=>{a.unfollow(),s.destroy()},_request:f}}const vd=(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,l=new Uint8Array(i);return a=>{const f=He.fromBytes(oe([l,c.enc(a)]));return{encodedData:f,decodedCall:Bt(e,Bt(t,a)),sign:async(p,u)=>J(await p.signTx(f.asBytes(),s(u),n,u.mortality.mortal?u.mortality.startAtBlock.height:0))}}},md=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=me(e),r=await t(),s=Dt(pt.dec(r)),o=er(s),i=Gr(o),c=yc(n,o,i),l=h=>s.pallets.find(v=>v.name===h),a={},f=h=>new Proxy(a,{get(v,m){return h(m)}}),p=h=>{const v={};return f(m=>(v[m]||(v[m]={}),f(y=>(v[m][y]||(v[m][y]=h(m,y)),v[m][y]))))},u=p((h,v)=>{const m=l(h)?.constants.find(y=>y.name===v);if(!m)throw new Error(`Runtime entry Constant(${h}.${v}) not found`);return i.buildConstant(h,v).dec(m.value)}),d=p((h,v)=>vd(h,v,r,i,c));return{constants:u,tx:d}},Yt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},yd=async e=>{const t=Dt(Sr(await e.getMetadata())),n={},r=u=>new Proxy(n,{get(d,h){return u(h)}}),s=u=>{const d={};return r(h=>(d[h]||(d[h]={}),r(v=>(d[h][v]||(d[h][v]=u(h,v)),d[h][v]))))},o=er(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:l,buildCall:a,buildEvent:f,buildViewFn:p}=Gr(o);return{query:s((...u)=>{const{value:d,args:h}=Yt(c,"Storage")(...u);return{value:d,args:h}}),tx:s((...u)=>Yt(a,"Call")(...u).codec),event:s((...u)=>Yt(f,"Event")(...u).codec),apis:s(Yt(i,"Runtime API")),constants:s(Yt(l,"Constant")),view:s(Yt(p,"ViewFn"))}};le.AccountId=At,le.Binary=He,le.BlockNotPinnedError=Ze,le.CompatibilityLevel=Te,le.Enum=Bt,le.FixedSizeBinary=$n,le.InvalidTxError=cs,le._Enum=fo,le.createClient=pd,le.getOfflineApi=md,le.getSs58AddressInfo=dr,le.getTypedCodecs=yd}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -192,14 +192,14 @@
|
|
|
192
192
|
},
|
|
193
193
|
"dependencies": {
|
|
194
194
|
"@rx-state/core": "^0.1.4",
|
|
195
|
-
"@polkadot-api/cli": "0.14.
|
|
196
|
-
"@polkadot-api/ink-contracts": "0.3.8",
|
|
195
|
+
"@polkadot-api/cli": "0.14.10",
|
|
197
196
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
198
|
-
"@polkadot-api/
|
|
197
|
+
"@polkadot-api/ink-contracts": "0.3.8",
|
|
198
|
+
"@polkadot-api/known-chains": "0.9.6",
|
|
199
199
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
200
200
|
"@polkadot-api/metadata-builders": "0.13.2",
|
|
201
201
|
"@polkadot-api/metadata-compatibility": "0.3.3",
|
|
202
|
-
"@polkadot-api/observable-client": "0.13.
|
|
202
|
+
"@polkadot-api/observable-client": "0.13.7",
|
|
203
203
|
"@polkadot-api/pjs-signer": "0.6.12",
|
|
204
204
|
"@polkadot-api/polkadot-sdk-compat": "2.3.3",
|
|
205
205
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
@@ -207,8 +207,8 @@
|
|
|
207
207
|
"@polkadot-api/sm-provider": "0.1.7",
|
|
208
208
|
"@polkadot-api/substrate-bindings": "0.16.0",
|
|
209
209
|
"@polkadot-api/smoldot": "0.3.10",
|
|
210
|
-
"@polkadot-api/utils": "0.2.0",
|
|
211
210
|
"@polkadot-api/substrate-client": "0.4.4",
|
|
211
|
+
"@polkadot-api/utils": "0.2.0",
|
|
212
212
|
"@polkadot-api/ws-provider": "0.5.0"
|
|
213
213
|
},
|
|
214
214
|
"devDependencies": {
|