polkadot-api 1.9.5 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { getCli, ink, update, remove, generate, add } from '@polkadot-api/cli';
3
3
 
4
- var version = "1.9.5";
4
+ var version = "1.9.6";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(he,_t){typeof exports=="object"&&typeof module<"u"?_t(exports):typeof define=="function"&&define.amd?define(["exports"],_t):(he=typeof globalThis<"u"?globalThis:he||self,_t(he.papi={}))})(this,function(he){"use strict";var _t=Object.defineProperty,Yi=(e,t,n)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t,n)=>(Yi(e,typeof t!="symbol"?t+"":t,n),n),Pn={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 Gi(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Pn[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=Pn[e[i]],u=Pn[e[i+1]];o[t+s++]=c<<4|u}return o}var Fr=class extends Uint8Array{constructor(e){super(e),jr(this,"i",0),jr(this,"v"),this.v=new DataView(e)}},ke=e=>t=>e(t instanceof Fr?t:new Fr(t instanceof Uint8Array?t.buffer:typeof t=="string"?Gi(t).buffer:t)),Re=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].length;const r=new Uint8Array(n);for(let o=0,s=0;o<t;o++){const i=e[o];r.set(i,s),s+=i.byteLength}return r};function Qt(e,t){const n=Object.keys(e),r=n.length,o={};for(let s=0;s<r;s++){const i=n[s];o[i]=t(e[i],i)}return o}var Zt=ke,H=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Bt=(e,t)=>n=>e(t(n)),Rn=(e,t)=>n=>t(e(n)),Ye=([e,t],n,r)=>H(Bt(e,n),Rn(t,r));function Ni(e,t){return ke(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Qi(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ge(e,t,n){return H(Qi(e,n),Ni(e,t))}var j=Ge(1,"getUint8","setUint8"),Ne=Ge(2,"getUint16","setUint16"),Ie=Ge(4,"getUint32","setUint32"),Ct=Ge(8,"getBigUint64","setBigUint64"),Zi=Ge(1,"getInt8","setInt8"),Ji=Ge(2,"getInt16","setInt16"),ec=Ge(4,"getInt32","setInt32"),tc=Ge(8,"getBigInt64","setBigInt64"),qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Wr=e=>ke(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|o}),Kr=H(qr,Wr("getBigUint64")),nc=H(qr,Wr("getBigInt64")),Xr=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},Yr=e=>ke(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}),rc=H(Xr,Yr("getBigUint64")),oc=H(Xr,Yr("getBigInt64")),sc=Ye(j,e=>e?1:0,Boolean),ic=[j[1],Ne[1],Ie[1]],cc=ke(e=>{const t=e[e.i],n=t&3;if(n<3)return ic[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const s=r/8|0;let i=0n;for(let u=0;u<s;u++)o=Ct[1](e)<<i|o,i+=64n;let c=r%8;return c>3&&(o=BigInt(Ie[1](e))<<i|o,i+=32n,c-=4),c>1&&(o=BigInt(Ne[1](e))<<i|o,i+=16n,c-=2),c&&(o=BigInt(j[1](e))<<i|o),o}),ac=1n<<56n,uc=1<<24,lc=256,fc=4294967295n,hc=64,dc=16384,pc=1<<30,vc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<hc)return j[0](t);if(e<dc)return Ne[0](t|1);if(e<pc)return Ie[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ac;)n.push(Ct[0](r)),r>>=64n;r>=uc&&(n.push(Ie[0](Number(r&fc))),r>>=32n);let o=Number(r);o>=lc&&(n.push(Ne[0](o)),o>>=16),o&&n.push(j[0](o));const s=Re(n);return s[0]=s.length-5<<2|3,s},oe=H(vc,cc),bc=new TextEncoder,mc=e=>{const t=bc.encode(e);return Re([oe.enc(t.length),t])},yc=new TextDecoder,gc=ke(e=>{let t=oe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,yc.decode(n)}),Q=H(mc,gc),wc=()=>{},Ec=new Uint8Array(0),C=H(()=>Ec,wc),Gr=e=>e===void 0?t=>Re([oe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Nr=e=>ke(t=>{const n=e===void 0?oe.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}),Y=e=>H(Gr(e),Nr(e));Y.enc=Gr,Y.dec=Nr;var Qr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,i)=>[n[i],s])??n.map((s,i)=>[s,i])),o=s=>r.get(s);return({tag:s,value:i})=>Re([j.enc(o(s)),e[s](i)])},Zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,s)=>[o,n[s]])??n.map((o,s)=>[s,o]));return ke(o=>{const s=j.dec(o),i=r.get(s),c=e[i];return{tag:i,value:c(o)}})},Ue=(e,...t)=>H(Qr(Qt(e,([n])=>n),...t),Zr(Qt(e,([,n])=>n),...t));Ue.enc=Qr,Ue.dec=Zr;var Jr=e=>ke(t=>j[1](t)>0?e(t):void 0),eo=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Re([n,e(t)]))},te=e=>H(eo(e[0]),Jr(e[1]));te.enc=eo,te.dec=Jr;var to=(e,t)=>ke(n=>{const r=j[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),no=(e,t)=>({success:n,value:r})=>Re([j[0](n?0:1),(n?e:t)(r)]),Jt=(e,t)=>H(no(e[0],t[0]),to(e[1],t[1]));Jt.dec=to,Jt.enc=no;var ro=(...e)=>ke(t=>e.map(n=>n(t))),oo=(...e)=>t=>Re(e.map((n,r)=>n(t[r]))),de=(...e)=>H(oo(...e.map(([t])=>t)),ro(...e.map(([,t])=>t)));de.enc=oo,de.dec=ro;var so=e=>{const t=Object.keys(e);return Bt(de.enc(...Object.values(e)),n=>t.map(r=>n[r]))},io=e=>{const t=Object.keys(e);return Rn(de.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>H(so(Qt(e,t=>t[0])),io(Qt(e,t=>t[1])));$.enc=so,$.dec=io;var co=(e,t)=>t>=0?n=>Re(n.map(e)):n=>Re([oe.enc(n.length),Re(n.map(e))]),ao=(e,t)=>ke(n=>{const r=t>=0?t:oe.dec(n),o=new Array(r);for(let s=0;s<r;s++)o[s]=e(n);return o}),R=(e,t)=>H(co(e[0],t),ao(e[1],t));R.enc=co,R.dec=ao;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function uo(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 Un(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function lo(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Ln(e){if(!Array.isArray(e))throw new Error("array expected")}function fo(e,t){if(!uo(!0,t))throw new Error(`${e}: array of strings expected`)}function xc(e,t){if(!uo(!1,t))throw new Error(`${e}: array of numbers expected`)}function Ac(...e){const t=s=>s,n=(s,i)=>c=>s(i(c)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function Sc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;fo("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Ln(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:o=>(Ln(o),o.map(s=>{Un("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function Ic(e=""){return Un("join",e),{encode:t=>(fo("join.decode",t),t.join(e)),decode:t=>(Un("join.decode",t),t.split(e))}}function ho(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(Ln(e),!e.length)return[];let r=0;const o=[],s=Array.from(e,c=>{if(lo(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=s.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=s[a],f=t*c,h=f+l;if(!Number.isSafeInteger(h)||f/t!==c||h-l!==f)throw new Error("convertRadix: carry overflow");const d=h/n;c=h%n;const p=Math.floor(d);if(s[a]=p,!Number.isSafeInteger(p)||p*n+c!==h)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(o.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)o.push(0);return o.reverse()}function _c(e){lo(e);const t=2**8;return{encode:n=>{if(!kc(n))throw new Error("radix.encode input should be Uint8Array");return ho(Array.from(n),t,e)},decode:n=>(xc("radix.decode",n),Uint8Array.from(ho(n,e,t)))}}const po=(e=>Ac(_c(58),Sc(e),Ic("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function it(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Bc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function en(e,...t){if(!Bc(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 Ot(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 Mn(e,t){en(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Cc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ct(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tn(e,t){return e<<32-t|e>>>t}const se=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ze=se?e=>e:e=>vo(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=vo(e[t])}function Oc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function je(e){return typeof e=="string"&&(e=Oc(e)),en(e),e}class bo{clone(){return this._cloneInto()}}function $c(e){const t=r=>e().update(je(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Tc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Pc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Rc=new Uint8Array([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]);class mo extends bo{constructor(t,n,r={},o,s,i){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,it(t),it(n),it(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error("key length must be undefined or 1.."+o);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==i)throw new Error("personalization must be undefined or "+i);this.buffer=new Uint8Array(t),this.buffer32=ct(this.buffer)}update(t){Ot(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=je(t);const s=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<s;){this.pos===n&&(se||ie(o),this.compress(o,0,!1),se||ie(o),this.pos=0);const a=Math.min(n-this.pos,s-u),l=i+u;if(a===n&&!(l%4)&&u+a<s){const f=new Uint32Array(c,l,Math.floor((s-u)/4));se||ie(f);for(let h=0;u+n<s;h+=o.length,u+=n)this.length+=n,this.compress(f,h,!1);se||ie(f);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Ot(this),Mn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),se||ie(r),this.compress(r,0,!0),se||ie(r);const o=ct(t);this.get().forEach((s,i)=>o[i]=ze(s))}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:o,destroyed:s,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=s,t.outputLen=i,t.buffer.set(n),t.pos=c,t}}const nn=BigInt(2**32-1),Dn=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&nn),l:Number(e>>Dn&nn)}:{h:Number(e>>Dn&nn)|0,l:Number(e&nn)|0}}function yo(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:s,l:i}=rn(e[o],t);[n[o],r[o]]=[s,i]}return[n,r]}const Uc=(e,t)=>BigInt(e>>>0)<<Dn|BigInt(t>>>0),Lc=(e,t,n)=>e>>>n,Mc=(e,t,n)=>e<<32-n|t>>>n,Dc=(e,t,n)=>e>>>n|t<<32-n,Vc=(e,t,n)=>e<<32-n|t>>>n,Hc=(e,t,n)=>e<<64-n|t>>>n-32,zc=(e,t,n)=>e>>>n-32|t<<64-n,jc=(e,t)=>t,Fc=(e,t)=>e,go=(e,t,n)=>e<<n|t>>>32-n,wo=(e,t,n)=>t<<n|e>>>32-n,Eo=(e,t,n)=>t<<n-32|e>>>64-n,ko=(e,t,n)=>e<<n-32|t>>>64-n;function qc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ce={fromBig:rn,split:yo,toBig:Uc,shrSH:Lc,shrSL:Mc,rotrSH:Dc,rotrSL:Vc,rotrBH:Hc,rotrBL:zc,rotr32H:jc,rotr32L:Fc,rotlSH:go,rotlSL:wo,rotlBH:Eo,rotlBL:ko,add:qc,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function Qe(e,t,n,r,o,s){const i=o[s],c=o[s+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],f=k[2*t+1],h=k[2*n],d=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(u,l,i);a=ce.add3H(b,a,f,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ce.rotr32H(v,p),Dl:ce.rotr32L(v,p)},{h:d,l:h}=ce.add(d,h,v,p),{Bh:f,Bl:l}={Bh:f^d,Bl:l^h},{Bh:f,Bl:l}={Bh:ce.rotrSH(f,l,24),Bl:ce.rotrSL(f,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=f,k[2*n]=h,k[2*n+1]=d,k[2*r]=p,k[2*r+1]=v}function Ze(e,t,n,r,o,s){const i=o[s],c=o[s+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],f=k[2*t+1],h=k[2*n],d=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(u,l,i);a=ce.add3H(b,a,f,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ce.rotrSH(v,p,16),Dl:ce.rotrSL(v,p,16)},{h:d,l:h}=ce.add(d,h,v,p),{Bh:f,Bl:l}={Bh:f^d,Bl:l^h},{Bh:f,Bl:l}={Bh:ce.rotrBH(f,l,63),Bl:ce.rotrBL(f,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=f,k[2*n]=h,k[2*n+1]=d,k[2*r]=p,k[2*r+1]=v}class Wc extends mo{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=K[0]|0,this.v0h=K[1]|0,this.v1l=K[2]|0,this.v1h=K[3]|0,this.v2l=K[4]|0,this.v2h=K[5]|0,this.v3l=K[6]|0,this.v3h=K[7]|0,this.v4l=K[8]|0,this.v4h=K[9]|0,this.v5l=K[10]|0,this.v5h=K[11]|0,this.v6l=K[12]|0,this.v6h=K[13]|0,this.v7l=K[14]|0,this.v7h=K[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ct(je(t.salt));this.v4l^=ze(r[0]),this.v4h^=ze(r[1]),this.v5l^=ze(r[2]),this.v5h^=ze(r[3])}if(t.personalization){const r=ct(je(t.personalization));this.v6l^=ze(r[0]),this.v6h^=ze(r[1]),this.v7l^=ze(r[2]),this.v7h^=ze(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(je(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:s,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:f,v5h:h,v6l:d,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,o,s,i,c,u,a,l,f,h,d,p,v,b]}set(t,n,r,o,s,i,c,u,a,l,f,h,d,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=s|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=f|0,this.v5h=h|0,this.v6l=d|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(K,16);let{h:o,l:s}=ce.fromBig(BigInt(this.length));k[24]=K[8]^s,k[25]=K[9]^o,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Rc;for(let u=0;u<12;u++)Qe(0,4,8,12,t,n+2*c[i++]),Ze(0,4,8,12,t,n+2*c[i++]),Qe(1,5,9,13,t,n+2*c[i++]),Ze(1,5,9,13,t,n+2*c[i++]),Qe(2,6,10,14,t,n+2*c[i++]),Ze(2,6,10,14,t,n+2*c[i++]),Qe(3,7,11,15,t,n+2*c[i++]),Ze(3,7,11,15,t,n+2*c[i++]),Qe(0,5,10,15,t,n+2*c[i++]),Ze(0,5,10,15,t,n+2*c[i++]),Qe(1,6,11,12,t,n+2*c[i++]),Ze(1,6,11,12,t,n+2*c[i++]),Qe(2,7,8,13,t,n+2*c[i++]),Ze(2,7,8,13,t,n+2*c[i++]),Qe(3,4,9,14,t,n+2*c[i++]),Ze(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],k.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const on=Tc(e=>new Wc(e)),xo=new TextEncoder().encode("SS58PRE"),Vn=2,Hn=e=>{try{const t=po.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Vn),o=t.subarray(n.length+r.length),s=on(Uint8Array.of(...xo,...n,...r),{dkLen:64}).subarray(0,Vn);return o[0]===s[0]&&o[1]===s[1]?{isValid:!0,ss58Format:Kc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Kc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ao=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=on(Uint8Array.of(...xo,...t,...n),{dkLen:64}).subarray(0,Vn);return po.encode(Uint8Array.of(...t,...n,...r))}};function Xc(e,t){return n=>{const r=Hn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const at=(e=42,t=32)=>Ye(Y(t),Xc(t),Ao(e)),So="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=So[r>>4]+So[r&15]}return t.join("")}const zn={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 pe(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|zn[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=zn[e[i]],u=zn[e[i+1]];o[t+s++]=c<<4|u}return o}function pt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ae=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const s=e[r];n.set(s,o),o+=s.byteLength}return n},$t=Function.prototype;class Io extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Yc=Object.defineProperty,_o=e=>{throw TypeError(e)},Gc=(e,t,n)=>t in e?Yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t,n)=>Gc(e,typeof t!="symbol"?t+"":t,n),Bo=(e,t,n)=>t.has(e)||_o("Cannot "+n),Fe=(e,t,n)=>(Bo(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?_o("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Bo(e,t,"write to private field"),t.set(e,n),n),qe,Rt,sn,cn,an;const Nc=new TextEncoder,Qc=new TextDecoder,Zc=de(oe,Y(1/0))[1];class Le{constructor(t,n=!1){if(Pt(this,qe),Pt(this,Rt,null),Pt(this,sn,null),Pt(this,cn,null),Pt(this,an,null),Tt(this,"asText",()=>Fe(this,an)??ut(this,an,Qc.decode(Fe(this,qe)))),Tt(this,"asHex",()=>Fe(this,sn)||ut(this,sn,Z(Fe(this,qe)))),Tt(this,"asOpaqueHex",()=>Fe(this,cn)||ut(this,cn,Z(this.asBytes()))),Tt(this,"asBytes",()=>Fe(this,qe)),Tt(this,"asOpaqueBytes",()=>Fe(this,Rt)||ut(this,Rt,ae(oe[0](Fe(this,qe).length),Fe(this,qe)))),n){try{const[r,o]=Zc(t);if(r===o.length){ut(this,qe,o),ut(this,Rt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ut(this,qe,t)}static fromText(t){return new this(Nc.encode(t))}static fromHex(t){return new this(pe(t))}static fromOpaqueHex(t){return new this(pe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}qe=new WeakMap,Rt=new WeakMap,sn=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Jc]=at();class un extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Jc(t))}}const Co=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Oo=e=>{const t=Y.dec(e),n=e==null?Le:un;return r=>n.fromBytes(t(r))},Ut=e=>H(Co(e),Oo(e));Ut.enc=Co,Ut.dec=Oo;const O=Ye(oe,e=>e,Number),ln=Ye(oe,e=>e,BigInt),ea=Zt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),$o=H(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ea),ta=Ye(j,e=>e.charCodeAt(0),String.fromCharCode),To=e=>{const t=Y.enc(e);return n=>t(pe(n))},Po=e=>{const t=Y.dec(e);return n=>Z(t(n))},Je=e=>H(To(e),Po(e));Je.enc=To,Je.dec=Po;const na=new TextEncoder,ra=new TextDecoder,oa=e=>Ye(Y(e),t=>na.encode(t),t=>ra.decode(t)),Ro=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Uo=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},jn=e=>H(Ro(()=>e().enc),Uo(()=>e().dec)),lt=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}}),Lo=new Proxy({},{get(e,t){return n=>lt(t,n)}}),Mo=(...e)=>{const t=Ue.enc(...e);return n=>t({tag:n.type,value:n.value})},Do=(...e)=>{const t=Ue.dec(...e);return n=>{const{tag:r,value:o}=t(n);return lt(r,o)}},ge=(e,...t)=>H(Mo(pt(e,([n])=>n),...t),Do(pt(e,([,n])=>n),...t));ge.enc=Mo,ge.dec=Do;const Vo=[],Ho=[],zo=[],sa=BigInt(0),Lt=BigInt(1),ia=BigInt(2),ca=BigInt(7),aa=BigInt(256),ua=BigInt(113);for(let e=0,t=Lt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Vo.push(2*(5*r+n)),Ho.push((e+1)*(e+2)/2%64);let o=sa;for(let s=0;s<7;s++)t=(t<<Lt^(t>>ca)*ua)%aa,t&ia&&(o^=Lt<<(Lt<<BigInt(s))-Lt);zo.push(o)}const[la,fa]=yo(zo,!0),jo=(e,t,n)=>n>32?Eo(e,t,n):go(e,t,n),Fo=(e,t,n)=>n>32?ko(e,t,n):wo(e,t,n);function ha(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],f=jo(a,l,1)^n[c],h=Fo(a,l,1)^n[c+1];for(let d=0;d<50;d+=10)e[i+d]^=f,e[i+d+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){const c=Ho[i],u=jo(o,s,c),a=Fo(o,s,c),l=Vo[i];o=e[l],s=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=la[r],e[1]^=fa[r]}n.fill(0)}class Fn extends bo{constructor(t,n,r,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,it(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ct(this.state)}keccak(){se||ie(this.state32),ha(this.state32,this.rounds),se||ie(this.state32),this.posOut=0,this.pos=0}update(t){Ot(this);const{blockLen:n,state:r}=this;t=je(t);const o=t.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ot(this,!1),en(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 it(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mn(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,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new Fn(n,r,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const da=((e,t,n)=>$c(()=>new Fn(t,e,n)))(1,136,256/8),qo=e=>{const t=e.slice(2),n=Z(da(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const s=parseInt(n[o],16),i=t[o];r[o]=s>7?i.toUpperCase():i}return`0x${r.join("")}`},pa=Y(20)[1],Wo=H(e=>{const t=pe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(qo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Zt(e=>qo(Z(pa(e))))),Ko=new TextEncoder,Xo=new TextDecoder,va=Ye(Y(4),Ko.encode.bind(Ko),Xo.decode.bind(Xo)),qn=$({engine:va,payload:Je()}),ba=ge({consensus:qn,seal:qn,preRuntime:qn,runtimeUpdated:C},[4,5,6,8]),Wn=Je(32),Yo=$({parentHash:Wn,number:O,stateRoot:Wn,extrinsicRoot:Wn,digests:R(ba)}),We=R(Q),Go=te(Q),ma=Ue({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),No=R($({name:Go,type:O,typeName:Go,docs:We})),ya=$({len:Ie,type:O}),ga=$({bitStoreType:O,bitOrderType:O}),wa=R($({name:Q,fields:No,index:j,docs:We})),Ea=Ue({composite:No,variant:wa,sequence:O,array:ya,tuple:R(O),primitive:ma,compact:O,bitSequence:ga}),ka=$({name:Q,type:te(O)}),xa=R(ka),Aa=$({id:O,path:We,params:xa,def:Ea,docs:We}),Kn=R(Aa),Sa=Ue({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ia=R(Sa),_a=$({hashers:Ia,key:O,value:O}),Ba=$({name:Q,modifier:j,type:Ue({plain:O,map:_a}),fallback:Je(),docs:We}),Ca=te($({prefix:Q,items:R(Ba)})),Qo={name:Q,storage:Ca,calls:te(O),events:te(O),constants:R($({name:Q,type:O,value:Je(),docs:We})),errors:te(O),index:j},Oa={...Qo,docs:We},$a=new Uint8Array,Zo=e=>H(()=>$a,()=>e),Ta=$({type:O,version:j,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),Jo=$({lookup:Kn,pallets:R($({...Qo,docs:Zo([])})),extrinsic:Ta,type:O,apis:Zo([])}),Pa=$({name:Q,methods:R($({name:Q,inputs:R($({name:Q,type:O})),output:O,docs:We})),docs:We}),Ra=$({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),es=$({lookup:Kn,pallets:R($(Oa)),extrinsic:Ra,type:O,apis:R(Pa),outerEnums:$({call:O,event:O,error:O}),custom:R(de(Q,$({type:O,value:Je()})))}),ts=()=>{throw new Error("Unsupported metadata version!")},ve=H(ts,ts),et=$({magicNumber:Ie,metadata:Ue({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:Jo,v15:es})}),Xn=Y(),Ua=te(Xn),La=de(oe,Xn),ns=e=>{try{return et.dec(e)}catch{}try{return et.dec(Ua.dec(e))}catch{}try{return et.dec(Xn.dec(e))}catch{}try{return et.dec(La.dec(e)[1])}catch{}throw null},Ma={dkLen:32},Mt=e=>on(e,Ma),Da={dkLen:16},Yn=e=>on(e,Da),rs=e=>ae(Yn(e),e),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function tt(e,t,n,r,o){return e=e+t+o|0,r=tn(r^e,16),n=n+r|0,t=tn(t^n,12),{a:e,b:t,c:n,d:r}}function nt(e,t,n,r,o){return e=e+t+o|0,r=tn(r^e,8),n=n+r|0,t=tn(t^n,7),{a:e,b:t,c:n,d:r}}function os(e,t,n,r,o,s,i,c,u,a,l,f,h,d,p,v,b,m,g,x){let y=0;for(let w=0;w<r;w++)({a:o,b:u,c:h,d:b}=tt(o,u,h,b,n[t+e[y++]])),{a:o,b:u,c:h,d:b}=nt(o,u,h,b,n[t+e[y++]]),{a:s,b:a,c:d,d:m}=tt(s,a,d,m,n[t+e[y++]]),{a:s,b:a,c:d,d:m}=nt(s,a,d,m,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=tt(i,l,p,g,n[t+e[y++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[y++]]),{a:c,b:f,c:v,d:x}=tt(c,f,v,x,n[t+e[y++]]),{a:c,b:f,c:v,d:x}=nt(c,f,v,x,n[t+e[y++]]),{a:o,b:a,c:p,d:x}=tt(o,a,p,x,n[t+e[y++]]),{a:o,b:a,c:p,d:x}=nt(o,a,p,x,n[t+e[y++]]),{a:s,b:l,c:v,d:b}=tt(s,l,v,b,n[t+e[y++]]),{a:s,b:l,c:v,d:b}=nt(s,l,v,b,n[t+e[y++]]),{a:i,b:f,c:h,d:m}=tt(i,f,h,m,n[t+e[y++]]),{a:i,b:f,c:h,d:m}=nt(i,f,h,m,n[t+e[y++]]),{a:c,b:u,c:d,d:g}=tt(c,u,d,g,n[t+e[y++]]),{a:c,b:u,c:d,d:g}=nt(c,u,d,g,n[t+e[y++]]);return{v0:o,v1:s,v2:i,v3:c,v4:u,v5:a,v6:l,v7:f,v8:h,v9:d,v10:p,v11:v,v12:b,v13:m,v14:g,v15:x}}var xe;(function(e){e[e.CHUNK_START=1]="CHUNK_START",e[e.CHUNK_END=2]="CHUNK_END",e[e.PARENT=4]="PARENT",e[e.ROOT=8]="ROOT",e[e.KEYED_HASH=16]="KEYED_HASH",e[e.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",e[e.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(xe||(xe={}));const ss=(()=>{const e=Array.from({length:16},(r,o)=>o),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(o=>r[o]),n=[];for(let r=0,o=e;r<7;r++,o=t(o))n.push(...o);return Uint8Array.from(n)})();class Gn extends mo{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,it(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=je(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ct(r),se||ie(this.IV),this.flags=n|xe.KEYED_HASH}else if(t.context!==void 0){const r=new Gn({dkLen:32},xe.DERIVE_KEY_CONTEXT).update(t.context).digest();this.IV=ct(r),se||ie(this.IV),this.flags=n|xe.DERIVE_KEY_MATERIAL}else this.IV=Ke.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Cc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:s,pos:i}=this,{h:c,l:u}=rn(BigInt(t),!0),{v0:a,v1:l,v2:f,v3:h,v4:d,v5:p,v6:v,v7:b,v8:m,v9:g,v10:x,v11:y,v12:w,v13:A,v14:_,v15:P}=os(ss,o,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],Ke[0],Ke[1],Ke[2],Ke[3],c,u,i,n);s[0]=a^m,s[1]=l^g,s[2]=f^x,s[3]=h^y,s[4]=d^w,s[5]=p^A,s[6]=v^_,s[7]=b^P}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=xe.CHUNK_START),(this.chunkPos===15||r)&&(o|=xe.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=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(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|xe.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:o,chunkPos:s,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(o.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:o,bufferOut32:s}=this,{h:i,l:c}=rn(BigInt(this.chunkOut++));se||ie(o);const{v0:u,v1:a,v2:l,v3:f,v4:h,v5:d,v6:p,v7:v,v8:b,v9:m,v10:g,v11:x,v12:y,v13:w,v14:A,v15:_}=os(ss,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ke[0],Ke[1],Ke[2],Ke[3],c,i,n,r);s[0]=u^b,s[1]=a^m,s[2]=l^g,s[3]=f^x,s[4]=h^y,s[5]=d^w,s[6]=p^A,s[7]=v^_,s[8]=t[0]^b,s[9]=t[1]^m,s[10]=t[2]^g,s[11]=t[3]^x,s[12]=t[4]^y,s[13]=t[5]^w,s[14]=t[6]^A,s[15]=t[7]^_,se||(ie(o),ie(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|xe.ROOT;this.stack.length?(t|=xe.PARENT,se||ie(this.buffer32),this.compress(this.buffer32,0,!0),se||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:xe.CHUNK_START)|xe.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ot(this,!1),en(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 it(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mn(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 Va=Pc(e=>new Gn(e)),Ha={dkLen:32},is=e=>Va(e,Ha),za=e=>ae(is(e),e),cs=e=>e,ft=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Nn=2n**64n-1n,ne=(e,t)=>e<<t&Nn|e>>64n-t,L=(e,t)=>e*t&Nn,G=(e,t)=>e+t&Nn,N=11400714785074694791n,we=14029467366897019727n,as=1609587929392839161n,Dt=9650029242287828579n,us=2870177450012600261n;function rt(e,t=0n){let n=G(G(t,N),we),r=G(t,we),o=t,s=t-N,i=e.length,c=0,u=null;(function(){let d=0,p=d+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(d<=p-32){const v=p-32;do{let b;b=ft(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=L(ne(G(n,L(b,we)),31n),N),d+=8,b=ft(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=L(ne(G(r,L(b,we)),31n),N),d+=8,b=ft(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=L(ne(G(o,L(b,we)),31n),N),d+=8,b=ft(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=L(ne(G(s,L(b,we)),31n),N),d+=8}while(d<=v)}d<p&&(u.set(e.subarray(d,p),c),c=p-d)}})(),e=u||e;let a,l=0;for(i>=32?(a=ne(n,1n),a=G(a,ne(r,7n)),a=G(a,ne(o,12n)),a=G(a,ne(s,18n)),n=L(ne(L(n,we),31n),N),a=a^n,a=G(L(a,N),Dt),r=L(ne(L(r,we),31n),N),a=a^r,a=G(L(a,N),Dt),o=L(ne(L(o,we),31n),N),a=a^o,a=G(L(a,N),Dt),s=L(ne(L(s,we),31n),N),a=a^s,a=G(L(a,N),Dt)):a=G(t,us),a=G(a,BigInt(i));l<=c-8;){let h=ft(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);h=L(ne(L(h,we),31n),N),a=G(L(ne(a^h,27n),N),Dt),l+=8}if(l+4<=c){let h=L(ft(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),N);a=G(L(ne(a^h,23n),we),as),l+=4}for(;l<c;){const h=L(ft(e[l++],0,0,0),us);a=L(ne(a^h,11n),N)}let f=a>>33n;return a=L(a^f,we),f=a>>29n,a=L(a^f,as),f=a>>32n,a^=f,a}const fn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,rt(e),!0),n.setBigUint64(8,rt(e,1n),!0),t},ls=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,rt(e),!0),n.setBigUint64(8,rt(e,1n),!0),n.setBigUint64(16,rt(e,2n),!0),n.setBigUint64(24,rt(e,3n),!0),t},fs=e=>ae(Ct.enc(rt(e)),e),hs=new TextEncoder,ja=new Map([[cs,0],[fs,8],[rs,16],[Yn,-16],[Mt,-32],[fn,-16],[ls,-32]]),ds=e=>{const t=fn(hs.encode(e));return(n,...r)=>{const o=ae(t,fn(hs.encode(n))),s=Z(o),i=a=>{if(!a.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=pe(a.slice(s.length)),f=new Array(r.length);for(let h=0,d=0;h<r.length;h++){const[p,v]=r[h],b=ja.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;f[h]=Z(l.slice(d,d+m)),d+=m}else d+=b,f[h]=p.dec(l.slice(d)),d+=p.enc(f[h]).length}return f},c=r.map(([{enc:a},l])=>f=>l(a(f)));return{enc:(...a)=>Z(ae(o,...a.map((l,f)=>c[f](l)))),dec:i}}},Fa=Le.fromText("modlpy/utilisuba").asBytes(),qa=({threshold:e,signatories:t})=>{const n=ps(t),r=ae(Fa,oe.enc(n.length),...n,Ne.enc(e));return Mt(r)},ps=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const o=r>=t.length,s=r>=n.length;if(o&&s)return 0;if(o)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var vs=Object.freeze({__proto__:null,AccountId:at,Bin:Ut,Binary:Le,Blake2128:Yn,Blake2128Concat:rs,Blake2256:Mt,Blake3256:is,Blake3256Concat:za,Bytes:Y,Enum:lt,FixedSizeBinary:un,Hex:Je,Identity:cs,Option:te,Result:Jt,ScaleEnum:Ue,Self:jn,Storage:ds,Struct:$,Tuple:de,Twox128:fn,Twox256:ls,Twox64Concat:fs,Variant:ge,Vector:R,_Enum:Lo,_void:C,bitSequence:$o,blockHeader:Yo,bool:sc,char:ta,compact:oe,compactBn:ln,compactNumber:O,createCodec:H,createDecoder:Zt,decAnyMetadata:ns,enhanceCodec:Ye,enhanceDecoder:Rn,enhanceEncoder:Bt,ethAccount:Wo,fixedStr:oa,fromBufferToBase58:Ao,getMultisigAccountId:qa,getSs58AddressInfo:Hn,h64:rt,i128:nc,i16:Ji,i256:oc,i32:ec,i64:tc,i8:Zi,metadata:et,selfDecoder:Uo,selfEncoder:Ro,sortMultisigSignatories:ps,str:Q,u128:Kr,u16:Ne,u256:rc,u32:Ie,u64:Ct,u8:j,v14:Jo,v14Lookup:Kn,v15:es});const ht=O,Wa=R(de(Q,ht)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Ka=ge(Object.fromEntries(Object.values(M).map(e=>[e,C]))),Xa=R(de(Q,te(jn(()=>Qn)))),Ya=R(ht),Ga=$({typeRef:ht,length:te(ht)}),Na=te(O),Qa=ht,Za=$({ok:ht,ko:ht}),Qn=ge({struct:Wa,terminal:Ka,enum:Xa,tuple:Ya,array:Ga,binary:Na,option:Qa,result:Za}),Ja={i256:M.big,i128:M.big,i64:M.big,i32:M.num,i16:M.num,i8:M.num,u256:M.big,u128:M.big,u64:M.big,u32:M.num,u16:M.num,u8:M.num,bool:M.bool,char:M.str,str:M.str},Vt=e=>({type:"terminal",value:{type:e}});function Ht(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Vt(M.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 Vt(M.bits);case"compact":return Vt(e.isBig?M.big:M.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?Ht(r.value,t):Ht(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,o])=>[r,o.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 Vt(Ja[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 Vt(M.void)}}function Zn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,i)=>Zn(s,i,n),o=s=>{switch(s.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===s.value.type;case M.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case M.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Le&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u);case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var eu=Object.defineProperty,tu=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nu=(e,t,n)=>tu(e,t+"",n);class bs{constructor(t=[]){nu(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Ae=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ae||{});function Jn(e,t,n,r,o){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const s=o.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new bs([[e,n]])}:be(c)}s.set(e,null);const i=ru(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,o));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?s.set(e,i.level):s.delete(e),i}function ru(e,t,n){if(e.type!==t.type)return t.type==="option"?hn(n(e,t.value),2):e.type==="option"?hn(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(ys(e.value,t.value));case"array":const o=e,s=be(ys(o.value.length,t.value.length));return er([s,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,f=Object.fromEntries(t.value),h=l.value.length===t.value.length?3:2;return hn(ms(l.value.map(([d,p])=>()=>d in f?n(p,f[d]):be(0))),h)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return hn(er(t.value.map(([l,f])=>()=>n(c[l],f))),u);case"tuple":{const l=e,f=be(su(l.value,t.value));return er([f,...t.value.map((h,d)=>()=>n(l.value[d],h))])}case"result":const a=e;return ms([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const hn=(e,t)=>({...e,level:Math.min(e.level,t)}),ou=new bs,be=e=>({level:e,assumptions:ou}),er=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},ms=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const o=typeof r=="function"?r():r;if(o.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(o.assumptions.values),n.level=Math.min(n.level,o.level)}return t?n:be(0)},su=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ys=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,gs=ge({lookup:O,typedef:Qn}),vt=e=>({type:"lookup",value:e}),tr=e=>({type:"typedef",value:e}),dn=tr({type:"terminal",value:{type:M.void}}),iu=$({args:gs,values:gs});function cu(e){if(e.type.tag==="plain")return{args:dn,values:vt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:vt(t),values:vt(n)}}function au(e){return{args:tr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:vt(e.output)}}function uu(e){return e.type==="lookupEntry"?vt(e.value.id):tr(Ht(e))}function lu(e){return{args:dn,values:vt(e)}}function fu(e,t,n,r,o){const s=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:Jn(s(e.args,t),t,s(n.args,r),r,o).level,values:Jn(s(n.values,r),r,s(e.values,t),t,o).level}}function ws(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const bt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},pn={chainName:"",genesisHash:"",properties:""},nr={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:pn,transaction:nr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const hu=e=>(t,n)=>{let r=e(nr.broadcast,[t],{onSuccess:o=>{r=o===null?bt:()=>{e(nr.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Es extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class vn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class bn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ks extends Error{constructor(t){super(t),this.name="OperationError"}}class mn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function du(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const xs=()=>{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)})}}},yn=e=>(...t)=>new Promise((n,r)=>{let o=$t;const[s,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Io)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{o=$t,i?.removeEventListener("abort",c),a(l)};o=e(u(n),u(r),...s)}),As=(e,t)=>n=>yn((r,o,...s)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...s);return n(e,u,{onSuccess:(l,f)=>{if(l.result==="limitReached")return o(new bn);const{operationId:h}=l,d=()=>{n(Se.stopOperation,[h])};if(!i)return d();let p=bt;const v=m=>{i=!1,p(),r(m)},b=m=>{i=!1,p(),o(m)};p=f(h,{next:m=>{const g=m;g.event==="operationError"?o(new ks(g.error)):g.event==="operationInaccessible"?o(new mn):a(m,v,b)},error:b}),c=()=>{i&&(p(),d())}},onError:o}),()=>{c()}}),pu=As(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),vu=As(Se.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),bu=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),Ss=e=>(t,n,r,o,s,i,c)=>{if(n.length===0)return i(),$t;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(l,f)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return s(new bn);const{operationId:h}=l,d=()=>{e(Se.stopOperation,[h])};if(!u)return d();const p=f(l.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{o(m.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new ks(m.error));break}case"operationInaccessible":{v(new mn);break}default:e(Se.continue,[m.operationId])}},error:s});a=()=>{p(),e(Se.stopOperation,[l.operationId])};const v=m=>{a=$t,p(),s(m)},b=()=>{a=$t,p(),i()};c(l.discardedItems)},onError:s}),()=>{a()}},mu=e=>{const t=Ss(e);return yn((n,r,o,s,i,c)=>{const u=s.startsWith("descendants");let a=u?[]:null;const f=t(o,[{key:i,type:s}],c??null,u?h=>{a.push(h)}:h=>{a=h[0]?.[s]},r,()=>{try{n(u?a.flat():a)}catch(h){r(h)}},h=>{h>0&&(f(),r(new bn))});return f})},yu=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class gn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function gu(e){return e.operationId!==void 0}function wu(e){return(t,n,r)=>{const o=xs(),s=new Set,i=du();let c=i.promise;const u=p=>{if(gu(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Es),h(!1)},a=p=>{r(p),h(!(p instanceof gn))},l=(p,v)=>{const b=v(p,{next:u,error:a});h=(m=!0)=>{c=null,h=bt,b(),m&&e(Se.unfollow,[p]),o.errorAll(new vn),s.forEach(g=>{g()}),s.clear()},c=p,i.res(p)},f=p=>{p instanceof gn?h(!1):r(p),c=null,i.res(p)};let h=e(Se.follow,[t],{onSuccess:l,onError:f});const d=(p,v,b)=>{const m=()=>{b?.onError(new vn)};if(c===null)return m(),bt;const g=y=>{if(!b)return e(p,[y,...v]);s.add(m);const w=(_,P)=>c===null?(P.error(new vn),bt):(o.subscribe(_,P),()=>{o.unsubscribe(_)}),A=e(p,[y,...v],{onSuccess:_=>{s.delete(m),b.onSuccess(_,w)},onError:_=>{s.delete(m),b.onError(_)}});return()=>{s.delete(m),A()}};if(typeof c=="string")return g(c);let x=bt;return c.then(y=>{if(y instanceof Error)return m();c&&(x=g(y))}),()=>{x()}};return{unfollow(){h(),c=null},body:pu(d),call:vu(d),header:bu(d),storage:mu(d),storageSubscription:Ss(d),unpin:yu(d),_request:d}}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Is=(e,t,n)=>ku(e,typeof t!="symbol"?t+"":t,n);class _s extends Error{constructor(t){super(t.message),Is(this,"code"),Is(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let xu=1;const Au=e=>{let t=xu++;const n=new Map,r=xs();let o=null;const s=(l,f,h)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:f,params:h}))};function i(l){try{let f,h,d,p,v;if({id:f,result:h,error:d,params:p}=JSON.parse(l),f){const g=n.get(f);return g?(n.delete(f),d?g.onError(new _s(d)):g.onSuccess(h,(x,y)=>{const w=x;return r.subscribe(w,y),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:h,error:d}=p,!v||!d&&!Object.hasOwn(p,"result"))throw 0;const m=v;d?r.error(m,new _s(d)):r.next(m,h)}catch(f){console.warn("Error parsing incomming message: "+l),console.error(f)}}o=e(i);const c=()=>{o?.disconnect(),o=null,r.errorAll(new gn),n.forEach(l=>l.onError(new gn)),n.clear()};let u=1;return{request:(l,f,h)=>{if(!o)throw new Error("Not connected");const d=`${t}-${u++}`;return h&&n.set(d,h),s(d,l,f),()=>{n.delete(d)}},disconnect:c}},Su=e=>{const t=yn((r,o,s,i)=>e(s,i,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(pn.chainName,[]),t(pn.genesisHash,[]),t(pn.properties,[])]).then(([r,o,s])=>({name:r,genesisHash:o,properties:s})))},wn=new Map,Iu=e=>{const t=wn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Au(e),o=()=>{const i=wn.get(e);!i||i.refCount<=1?(wn.delete(e),r()):i.refCount--},s={chainHead:wu(n),transaction:hu(n),getChainSpecData:Su(n),destroy:o,request:yn((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return wn.set(e,{client:s,refCount:1}),s};var rr=function(e,t){return rr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},rr(e,t)};function Me(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");rr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function _u(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function c(l){try{a(r.next(l))}catch(f){i(f)}}function u(l){try{a(r.throw(l))}catch(f){i(f)}}function a(l){l.done?s(l.value):o(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Bs(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,o&&(s=a[0]&2?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1],s=a;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(a);break}s[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],o=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function mt(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 _e(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(c){i={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Be(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function yt(e){return this instanceof yt?(this.v=e,this):new yt(e)}function Bu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(d){return function(p){return Promise.resolve(p).then(d,f)}}function c(d,p){r[d]&&(o[d]=function(v){return new Promise(function(b,m){s.push([d,v,b,m])>1||u(d,v)})},p&&(o[d]=p(o[d])))}function u(d,p){try{a(r[d](p))}catch(v){h(s[0][3],v)}}function a(d){d.value instanceof yt?Promise.resolve(d.value.v).then(l,f):h(s[0][2],d)}function l(d){u("next",d)}function f(d){u("throw",d)}function h(d,p){d(p),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Cu(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 mt=="function"?mt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(c,u){i=e[s](i),o(c,u,i.done,i.value)})}}function o(s,i,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function z(e){return typeof e=="function"}function or(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 sr=or(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(he,_t){typeof exports=="object"&&typeof module<"u"?_t(exports):typeof define=="function"&&define.amd?define(["exports"],_t):(he=typeof globalThis<"u"?globalThis:he||self,_t(he.papi={}))})(this,function(he){"use strict";var _t=Object.defineProperty,Yi=(e,t,n)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t,n)=>(Yi(e,typeof t!="symbol"?t+"":t,n),n),Pn={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 Gi(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Pn[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=Pn[e[i]],u=Pn[e[i+1]];o[t+s++]=c<<4|u}return o}var Fr=class extends Uint8Array{constructor(e){super(e),jr(this,"i",0),jr(this,"v"),this.v=new DataView(e)}},xe=e=>t=>e(t instanceof Fr?t:new Fr(t instanceof Uint8Array?t.buffer:typeof t=="string"?Gi(t).buffer:t)),Re=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].length;const r=new Uint8Array(n);for(let o=0,s=0;o<t;o++){const i=e[o];r.set(i,s),s+=i.byteLength}return r};function Qt(e,t){const n=Object.keys(e),r=n.length,o={};for(let s=0;s<r;s++){const i=n[s];o[i]=t(e[i],i)}return o}var Zt=xe,H=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Bt=(e,t)=>n=>e(t(n)),Rn=(e,t)=>n=>t(e(n)),Ye=([e,t],n,r)=>H(Bt(e,n),Rn(t,r));function Ni(e,t){return xe(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Qi(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Ge(e,t,n){return H(Qi(e,n),Ni(e,t))}var j=Ge(1,"getUint8","setUint8"),Ne=Ge(2,"getUint16","setUint16"),_e=Ge(4,"getUint32","setUint32"),Ct=Ge(8,"getBigUint64","setBigUint64"),Zi=Ge(1,"getInt8","setInt8"),Ji=Ge(2,"getInt16","setInt16"),ec=Ge(4,"getInt32","setInt32"),tc=Ge(8,"getBigInt64","setBigInt64"),qr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Wr=e=>xe(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|o}),Kr=H(qr,Wr("getBigUint64")),nc=H(qr,Wr("getBigInt64")),Xr=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},Yr=e=>xe(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}),rc=H(Xr,Yr("getBigUint64")),oc=H(Xr,Yr("getBigInt64")),sc=Ye(j,e=>e?1:0,Boolean),ic=[j[1],Ne[1],_e[1]],cc=xe(e=>{const t=e[e.i],n=t&3;if(n<3)return ic[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const s=r/8|0;let i=0n;for(let u=0;u<s;u++)o=Ct[1](e)<<i|o,i+=64n;let c=r%8;return c>3&&(o=BigInt(_e[1](e))<<i|o,i+=32n,c-=4),c>1&&(o=BigInt(Ne[1](e))<<i|o,i+=16n,c-=2),c&&(o=BigInt(j[1](e))<<i|o),o}),ac=1n<<56n,uc=1<<24,lc=256,fc=4294967295n,hc=64,dc=16384,pc=1<<30,vc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<hc)return j[0](t);if(e<dc)return Ne[0](t|1);if(e<pc)return _e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ac;)n.push(Ct[0](r)),r>>=64n;r>=uc&&(n.push(_e[0](Number(r&fc))),r>>=32n);let o=Number(r);o>=lc&&(n.push(Ne[0](o)),o>>=16),o&&n.push(j[0](o));const s=Re(n);return s[0]=s.length-5<<2|3,s},oe=H(vc,cc),bc=new TextEncoder,mc=e=>{const t=bc.encode(e);return Re([oe.enc(t.length),t])},yc=new TextDecoder,gc=xe(e=>{let t=oe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,yc.decode(n)}),Q=H(mc,gc),wc=()=>{},Ec=new Uint8Array(0),C=H(()=>Ec,wc),Gr=e=>e===void 0?t=>Re([oe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Nr=e=>xe(t=>{const n=e===void 0?oe.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}),Y=e=>H(Gr(e),Nr(e));Y.enc=Gr,Y.dec=Nr;var Qr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,i)=>[n[i],s])??n.map((s,i)=>[s,i])),o=s=>r.get(s);return({tag:s,value:i})=>Re([j.enc(o(s)),e[s](i)])},Zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,s)=>[o,n[s]])??n.map((o,s)=>[s,o]));return xe(o=>{const s=j.dec(o),i=r.get(s),c=e[i];return{tag:i,value:c(o)}})},Ue=(e,...t)=>H(Qr(Qt(e,([n])=>n),...t),Zr(Qt(e,([,n])=>n),...t));Ue.enc=Qr,Ue.dec=Zr;var Jr=e=>xe(t=>j[1](t)>0?e(t):void 0),eo=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Re([n,e(t)]))},te=e=>H(eo(e[0]),Jr(e[1]));te.enc=eo,te.dec=Jr;var to=(e,t)=>xe(n=>{const r=j[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),no=(e,t)=>({success:n,value:r})=>Re([j[0](n?0:1),(n?e:t)(r)]),Jt=(e,t)=>H(no(e[0],t[0]),to(e[1],t[1]));Jt.dec=to,Jt.enc=no;var ro=(...e)=>xe(t=>e.map(n=>n(t))),oo=(...e)=>t=>Re(e.map((n,r)=>n(t[r]))),de=(...e)=>H(oo(...e.map(([t])=>t)),ro(...e.map(([,t])=>t)));de.enc=oo,de.dec=ro;var so=e=>{const t=Object.keys(e);return Bt(de.enc(...Object.values(e)),n=>t.map(r=>n[r]))},io=e=>{const t=Object.keys(e);return Rn(de.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>H(so(Qt(e,t=>t[0])),io(Qt(e,t=>t[1])));$.enc=so,$.dec=io;var co=(e,t)=>t>=0?n=>Re(n.map(e)):n=>Re([oe.enc(n.length),Re(n.map(e))]),ao=(e,t)=>xe(n=>{const r=t>=0?t:oe.dec(n),o=new Array(r);for(let s=0;s<r;s++)o[s]=e(n);return o}),R=(e,t)=>H(co(e[0],t),ao(e[1],t));R.enc=co,R.dec=ao;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function uo(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 Un(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function lo(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Ln(e){if(!Array.isArray(e))throw new Error("array expected")}function fo(e,t){if(!uo(!0,t))throw new Error(`${e}: array of strings expected`)}function xc(e,t){if(!uo(!1,t))throw new Error(`${e}: array of numbers expected`)}function Ac(...e){const t=s=>s,n=(s,i)=>c=>s(i(c)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function Sc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;fo("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Ln(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:o=>(Ln(o),o.map(s=>{Un("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function Ic(e=""){return Un("join",e),{encode:t=>(fo("join.decode",t),t.join(e)),decode:t=>(Un("join.decode",t),t.split(e))}}function ho(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(Ln(e),!e.length)return[];let r=0;const o=[],s=Array.from(e,c=>{if(lo(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=s.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const f=s[a],d=t*c,l=d+f;if(!Number.isSafeInteger(l)||d/t!==c||l-f!==d)throw new Error("convertRadix: carry overflow");const h=l/n;c=l%n;const p=Math.floor(h);if(s[a]=p,!Number.isSafeInteger(p)||p*n+c!==l)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(o.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)o.push(0);return o.reverse()}function _c(e){lo(e);const t=2**8;return{encode:n=>{if(!kc(n))throw new Error("radix.encode input should be Uint8Array");return ho(Array.from(n),t,e)},decode:n=>(xc("radix.decode",n),Uint8Array.from(ho(n,e,t)))}}const po=(e=>Ac(_c(58),Sc(e),Ic("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function it(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Bc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function en(e,...t){if(!Bc(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 Ot(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 Mn(e,t){en(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Cc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ct(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tn(e,t){return e<<32-t|e>>>t}const se=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const ze=se?e=>e:e=>vo(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=vo(e[t])}function Oc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function je(e){return typeof e=="string"&&(e=Oc(e)),en(e),e}class bo{clone(){return this._cloneInto()}}function $c(e){const t=r=>e().update(je(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Tc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Pc(e){const t=(r,o)=>e(o).update(je(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Rc=new Uint8Array([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]);class mo extends bo{constructor(t,n,r={},o,s,i){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,it(t),it(n),it(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error("key length must be undefined or 1.."+o);if(r.salt!==void 0&&r.salt.length!==s)throw new Error("salt must be undefined or "+s);if(r.personalization!==void 0&&r.personalization.length!==i)throw new Error("personalization must be undefined or "+i);this.buffer=new Uint8Array(t),this.buffer32=ct(this.buffer)}update(t){Ot(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=je(t);const s=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<s;){this.pos===n&&(se||ie(o),this.compress(o,0,!1),se||ie(o),this.pos=0);const a=Math.min(n-this.pos,s-u),f=i+u;if(a===n&&!(f%4)&&u+a<s){const d=new Uint32Array(c,f,Math.floor((s-u)/4));se||ie(d);for(let l=0;u+n<s;l+=o.length,u+=n)this.length+=n,this.compress(d,l,!1);se||ie(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Ot(this),Mn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),se||ie(r),this.compress(r,0,!0),se||ie(r);const o=ct(t);this.get().forEach((s,i)=>o[i]=ze(s))}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:o,destroyed:s,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=s,t.outputLen=i,t.buffer.set(n),t.pos=c,t}}const nn=BigInt(2**32-1),Dn=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&nn),l:Number(e>>Dn&nn)}:{h:Number(e>>Dn&nn)|0,l:Number(e&nn)|0}}function yo(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:s,l:i}=rn(e[o],t);[n[o],r[o]]=[s,i]}return[n,r]}const Uc=(e,t)=>BigInt(e>>>0)<<Dn|BigInt(t>>>0),Lc=(e,t,n)=>e>>>n,Mc=(e,t,n)=>e<<32-n|t>>>n,Dc=(e,t,n)=>e>>>n|t<<32-n,Vc=(e,t,n)=>e<<32-n|t>>>n,Hc=(e,t,n)=>e<<64-n|t>>>n-32,zc=(e,t,n)=>e>>>n-32|t<<64-n,jc=(e,t)=>t,Fc=(e,t)=>e,go=(e,t,n)=>e<<n|t>>>32-n,wo=(e,t,n)=>t<<n|e>>>32-n,Eo=(e,t,n)=>t<<n-32|e>>>64-n,ko=(e,t,n)=>e<<n-32|t>>>64-n;function qc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ce={fromBig:rn,split:yo,toBig:Uc,shrSH:Lc,shrSL:Mc,rotrSH:Dc,rotrSL:Vc,rotrBH:Hc,rotrBL:zc,rotr32H:jc,rotr32L:Fc,rotlSH:go,rotlSL:wo,rotlBH:Eo,rotlBL:ko,add:qc,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function Qe(e,t,n,r,o,s){const i=o[s],c=o[s+1];let u=k[2*e],a=k[2*e+1],f=k[2*t],d=k[2*t+1],l=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(u,f,i);a=ce.add3H(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ce.rotr32H(v,p),Dl:ce.rotr32L(v,p)},{h,l}=ce.add(h,l,v,p),{Bh:d,Bl:f}={Bh:d^h,Bl:f^l},{Bh:d,Bl:f}={Bh:ce.rotrSH(d,f,24),Bl:ce.rotrSL(d,f,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=f,k[2*t+1]=d,k[2*n]=l,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function Ze(e,t,n,r,o,s){const i=o[s],c=o[s+1];let u=k[2*e],a=k[2*e+1],f=k[2*t],d=k[2*t+1],l=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=ce.add3L(u,f,i);a=ce.add3H(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ce.rotrSH(v,p,16),Dl:ce.rotrSL(v,p,16)},{h,l}=ce.add(h,l,v,p),{Bh:d,Bl:f}={Bh:d^h,Bl:f^l},{Bh:d,Bl:f}={Bh:ce.rotrBH(d,f,63),Bl:ce.rotrBL(d,f,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=f,k[2*t+1]=d,k[2*n]=l,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}class Wc extends mo{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=K[0]|0,this.v0h=K[1]|0,this.v1l=K[2]|0,this.v1h=K[3]|0,this.v2l=K[4]|0,this.v2h=K[5]|0,this.v3l=K[6]|0,this.v3h=K[7]|0,this.v4l=K[8]|0,this.v4h=K[9]|0,this.v5l=K[10]|0,this.v5h=K[11]|0,this.v6l=K[12]|0,this.v6h=K[13]|0,this.v7l=K[14]|0,this.v7h=K[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ct(je(t.salt));this.v4l^=ze(r[0]),this.v4h^=ze(r[1]),this.v5l^=ze(r[2]),this.v5h^=ze(r[3])}if(t.personalization){const r=ct(je(t.personalization));this.v6l^=ze(r[0]),this.v6h^=ze(r[1]),this.v7l^=ze(r[2]),this.v7h^=ze(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(je(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:s,v2h:i,v3l:c,v3h:u,v4l:a,v4h:f,v5l:d,v5h:l,v6l:h,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,o,s,i,c,u,a,f,d,l,h,p,v,b]}set(t,n,r,o,s,i,c,u,a,f,d,l,h,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=s|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=f|0,this.v5l=d|0,this.v5h=l|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(K,16);let{h:o,l:s}=ce.fromBig(BigInt(this.length));k[24]=K[8]^s,k[25]=K[9]^o,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Rc;for(let u=0;u<12;u++)Qe(0,4,8,12,t,n+2*c[i++]),Ze(0,4,8,12,t,n+2*c[i++]),Qe(1,5,9,13,t,n+2*c[i++]),Ze(1,5,9,13,t,n+2*c[i++]),Qe(2,6,10,14,t,n+2*c[i++]),Ze(2,6,10,14,t,n+2*c[i++]),Qe(3,7,11,15,t,n+2*c[i++]),Ze(3,7,11,15,t,n+2*c[i++]),Qe(0,5,10,15,t,n+2*c[i++]),Ze(0,5,10,15,t,n+2*c[i++]),Qe(1,6,11,12,t,n+2*c[i++]),Ze(1,6,11,12,t,n+2*c[i++]),Qe(2,7,8,13,t,n+2*c[i++]),Ze(2,7,8,13,t,n+2*c[i++]),Qe(3,4,9,14,t,n+2*c[i++]),Ze(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],k.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const on=Tc(e=>new Wc(e)),xo=new TextEncoder().encode("SS58PRE"),Vn=2,Hn=e=>{try{const t=po.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Vn),o=t.subarray(n.length+r.length),s=on(Uint8Array.of(...xo,...n,...r),{dkLen:64}).subarray(0,Vn);return o[0]===s[0]&&o[1]===s[1]?{isValid:!0,ss58Format:Kc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Kc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ao=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=on(Uint8Array.of(...xo,...t,...n),{dkLen:64}).subarray(0,Vn);return po.encode(Uint8Array.of(...t,...n,...r))}};function Xc(e,t){return n=>{const r=Hn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const at=(e=42,t=32)=>Ye(Y(t),Xc(t),Ao(e)),So="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=So[r>>4]+So[r&15]}return t.join("")}const zn={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 pe(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|zn[e[2]]);for(let s=0;s<r;){const i=n+s*2,c=zn[e[i]],u=zn[e[i+1]];o[t+s++]=c<<4|u}return o}function pt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ae=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const s=e[r];n.set(s,o),o+=s.byteLength}return n},$t=Function.prototype;class Io extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Yc=Object.defineProperty,_o=e=>{throw TypeError(e)},Gc=(e,t,n)=>t in e?Yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t,n)=>Gc(e,typeof t!="symbol"?t+"":t,n),Bo=(e,t,n)=>t.has(e)||_o("Cannot "+n),Fe=(e,t,n)=>(Bo(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?_o("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Bo(e,t,"write to private field"),t.set(e,n),n),qe,Rt,sn,cn,an;const Nc=new TextEncoder,Qc=new TextDecoder,Zc=de(oe,Y(1/0))[1];class Le{constructor(t,n=!1){if(Pt(this,qe),Pt(this,Rt,null),Pt(this,sn,null),Pt(this,cn,null),Pt(this,an,null),Tt(this,"asText",()=>Fe(this,an)??ut(this,an,Qc.decode(Fe(this,qe)))),Tt(this,"asHex",()=>Fe(this,sn)||ut(this,sn,Z(Fe(this,qe)))),Tt(this,"asOpaqueHex",()=>Fe(this,cn)||ut(this,cn,Z(this.asBytes()))),Tt(this,"asBytes",()=>Fe(this,qe)),Tt(this,"asOpaqueBytes",()=>Fe(this,Rt)||ut(this,Rt,ae(oe[0](Fe(this,qe).length),Fe(this,qe)))),n){try{const[r,o]=Zc(t);if(r===o.length){ut(this,qe,o),ut(this,Rt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ut(this,qe,t)}static fromText(t){return new this(Nc.encode(t))}static fromHex(t){return new this(pe(t))}static fromOpaqueHex(t){return new this(pe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}qe=new WeakMap,Rt=new WeakMap,sn=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Jc]=at();class un extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Jc(t))}}const Co=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Oo=e=>{const t=Y.dec(e),n=e==null?Le:un;return r=>n.fromBytes(t(r))},Ut=e=>H(Co(e),Oo(e));Ut.enc=Co,Ut.dec=Oo;const O=Ye(oe,e=>e,Number),ln=Ye(oe,e=>e,BigInt),ea=Zt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),$o=H(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ea),ta=Ye(j,e=>e.charCodeAt(0),String.fromCharCode),To=e=>{const t=Y.enc(e);return n=>t(pe(n))},Po=e=>{const t=Y.dec(e);return n=>Z(t(n))},Je=e=>H(To(e),Po(e));Je.enc=To,Je.dec=Po;const na=new TextEncoder,ra=new TextDecoder,oa=e=>Ye(Y(e),t=>na.encode(t),t=>ra.decode(t)),Ro=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Uo=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},jn=e=>H(Ro(()=>e().enc),Uo(()=>e().dec)),lt=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}}),Lo=new Proxy({},{get(e,t){return n=>lt(t,n)}}),Mo=(...e)=>{const t=Ue.enc(...e);return n=>t({tag:n.type,value:n.value})},Do=(...e)=>{const t=Ue.dec(...e);return n=>{const{tag:r,value:o}=t(n);return lt(r,o)}},ge=(e,...t)=>H(Mo(pt(e,([n])=>n),...t),Do(pt(e,([,n])=>n),...t));ge.enc=Mo,ge.dec=Do;const Vo=[],Ho=[],zo=[],sa=BigInt(0),Lt=BigInt(1),ia=BigInt(2),ca=BigInt(7),aa=BigInt(256),ua=BigInt(113);for(let e=0,t=Lt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Vo.push(2*(5*r+n)),Ho.push((e+1)*(e+2)/2%64);let o=sa;for(let s=0;s<7;s++)t=(t<<Lt^(t>>ca)*ua)%aa,t&ia&&(o^=Lt<<(Lt<<BigInt(s))-Lt);zo.push(o)}const[la,fa]=yo(zo,!0),jo=(e,t,n)=>n>32?Eo(e,t,n):go(e,t,n),Fo=(e,t,n)=>n>32?ko(e,t,n):wo(e,t,n);function ha(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],f=n[u+1],d=jo(a,f,1)^n[c],l=Fo(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=l}let o=e[2],s=e[3];for(let i=0;i<24;i++){const c=Ho[i],u=jo(o,s,c),a=Fo(o,s,c),f=Vo[i];o=e[f],s=e[f+1],e[f]=u,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]^=la[r],e[1]^=fa[r]}n.fill(0)}class Fn extends bo{constructor(t,n,r,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,it(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ct(this.state)}keccak(){se||ie(this.state32),ha(this.state32,this.rounds),se||ie(this.state32),this.posOut=0,this.pos=0}update(t){Ot(this);const{blockLen:n,state:r}=this;t=je(t);const o=t.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ot(this,!1),en(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 it(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mn(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,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new Fn(n,r,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const da=((e,t,n)=>$c(()=>new Fn(t,e,n)))(1,136,256/8),qo=e=>{const t=e.slice(2),n=Z(da(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const s=parseInt(n[o],16),i=t[o];r[o]=s>7?i.toUpperCase():i}return`0x${r.join("")}`},pa=Y(20)[1],Wo=H(e=>{const t=pe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(qo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Zt(e=>qo(Z(pa(e))))),Ko=new TextEncoder,Xo=new TextDecoder,va=Ye(Y(4),Ko.encode.bind(Ko),Xo.decode.bind(Xo)),qn=$({engine:va,payload:Je()}),ba=ge({consensus:qn,seal:qn,preRuntime:qn,runtimeUpdated:C},[4,5,6,8]),Wn=Je(32),Yo=$({parentHash:Wn,number:O,stateRoot:Wn,extrinsicRoot:Wn,digests:R(ba)}),We=R(Q),Go=te(Q),ma=Ue({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),No=R($({name:Go,type:O,typeName:Go,docs:We})),ya=$({len:_e,type:O}),ga=$({bitStoreType:O,bitOrderType:O}),wa=R($({name:Q,fields:No,index:j,docs:We})),Ea=Ue({composite:No,variant:wa,sequence:O,array:ya,tuple:R(O),primitive:ma,compact:O,bitSequence:ga}),ka=$({name:Q,type:te(O)}),xa=R(ka),Aa=$({id:O,path:We,params:xa,def:Ea,docs:We}),Kn=R(Aa),Sa=Ue({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ia=R(Sa),_a=$({hashers:Ia,key:O,value:O}),Ba=$({name:Q,modifier:j,type:Ue({plain:O,map:_a}),fallback:Je(),docs:We}),Ca=te($({prefix:Q,items:R(Ba)})),Qo={name:Q,storage:Ca,calls:te(O),events:te(O),constants:R($({name:Q,type:O,value:Je(),docs:We})),errors:te(O),index:j},Oa={...Qo,docs:We},$a=new Uint8Array,Zo=e=>H(()=>$a,()=>e),Ta=$({type:O,version:j,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),Jo=$({lookup:Kn,pallets:R($({...Qo,docs:Zo([])})),extrinsic:Ta,type:O,apis:Zo([])}),Pa=$({name:Q,methods:R($({name:Q,inputs:R($({name:Q,type:O})),output:O,docs:We})),docs:We}),Ra=$({version:j,address:O,call:O,signature:O,extra:O,signedExtensions:R($({identifier:Q,type:O,additionalSigned:O}))}),es=$({lookup:Kn,pallets:R($(Oa)),extrinsic:Ra,type:O,apis:R(Pa),outerEnums:$({call:O,event:O,error:O}),custom:R(de(Q,$({type:O,value:Je()})))}),ts=()=>{throw new Error("Unsupported metadata version!")},ve=H(ts,ts),et=$({magicNumber:_e,metadata:Ue({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:Jo,v15:es})}),Xn=Y(),Ua=te(Xn),La=de(oe,Xn),ns=e=>{try{return et.dec(e)}catch{}try{return et.dec(Ua.dec(e))}catch{}try{return et.dec(Xn.dec(e))}catch{}try{return et.dec(La.dec(e)[1])}catch{}throw null},Ma={dkLen:32},Mt=e=>on(e,Ma),Da={dkLen:16},Yn=e=>on(e,Da),rs=e=>ae(Yn(e),e),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function tt(e,t,n,r,o){return e=e+t+o|0,r=tn(r^e,16),n=n+r|0,t=tn(t^n,12),{a:e,b:t,c:n,d:r}}function nt(e,t,n,r,o){return e=e+t+o|0,r=tn(r^e,8),n=n+r|0,t=tn(t^n,7),{a:e,b:t,c:n,d:r}}function os(e,t,n,r,o,s,i,c,u,a,f,d,l,h,p,v,b,m,g,x){let y=0;for(let w=0;w<r;w++)({a:o,b:u,c:l,d:b}=tt(o,u,l,b,n[t+e[y++]])),{a:o,b:u,c:l,d:b}=nt(o,u,l,b,n[t+e[y++]]),{a:s,b:a,c:h,d:m}=tt(s,a,h,m,n[t+e[y++]]),{a:s,b:a,c:h,d:m}=nt(s,a,h,m,n[t+e[y++]]),{a:i,b:f,c:p,d:g}=tt(i,f,p,g,n[t+e[y++]]),{a:i,b:f,c:p,d:g}=nt(i,f,p,g,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=tt(c,d,v,x,n[t+e[y++]]),{a:c,b:d,c:v,d:x}=nt(c,d,v,x,n[t+e[y++]]),{a:o,b:a,c:p,d:x}=tt(o,a,p,x,n[t+e[y++]]),{a:o,b:a,c:p,d:x}=nt(o,a,p,x,n[t+e[y++]]),{a:s,b:f,c:v,d:b}=tt(s,f,v,b,n[t+e[y++]]),{a:s,b:f,c:v,d:b}=nt(s,f,v,b,n[t+e[y++]]),{a:i,b:d,c:l,d:m}=tt(i,d,l,m,n[t+e[y++]]),{a:i,b:d,c:l,d:m}=nt(i,d,l,m,n[t+e[y++]]),{a:c,b:u,c:h,d:g}=tt(c,u,h,g,n[t+e[y++]]),{a:c,b:u,c:h,d:g}=nt(c,u,h,g,n[t+e[y++]]);return{v0:o,v1:s,v2:i,v3:c,v4:u,v5:a,v6:f,v7:d,v8:l,v9:h,v10:p,v11:v,v12:b,v13:m,v14:g,v15:x}}var Ae;(function(e){e[e.CHUNK_START=1]="CHUNK_START",e[e.CHUNK_END=2]="CHUNK_END",e[e.PARENT=4]="PARENT",e[e.ROOT=8]="ROOT",e[e.KEYED_HASH=16]="KEYED_HASH",e[e.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",e[e.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(Ae||(Ae={}));const ss=(()=>{const e=Array.from({length:16},(r,o)=>o),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(o=>r[o]),n=[];for(let r=0,o=e;r<7;r++,o=t(o))n.push(...o);return Uint8Array.from(n)})();class Gn extends mo{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,it(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=je(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ct(r),se||ie(this.IV),this.flags=n|Ae.KEYED_HASH}else if(t.context!==void 0){const r=new Gn({dkLen:32},Ae.DERIVE_KEY_CONTEXT).update(t.context).digest();this.IV=ct(r),se||ie(this.IV),this.flags=n|Ae.DERIVE_KEY_MATERIAL}else this.IV=Ke.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Cc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:s,pos:i}=this,{h:c,l:u}=rn(BigInt(t),!0),{v0:a,v1:f,v2:d,v3:l,v4:h,v5:p,v6:v,v7:b,v8:m,v9:g,v10:x,v11:y,v12:w,v13:A,v14:_,v15:P}=os(ss,o,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],Ke[0],Ke[1],Ke[2],Ke[3],c,u,i,n);s[0]=a^m,s[1]=f^g,s[2]=d^x,s[3]=l^y,s[4]=h^w,s[5]=p^A,s[6]=v^_,s[7]=b^P}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=Ae.CHUNK_START),(this.chunkPos===15||r)&&(o|=Ae.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=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(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Ae.PARENT,this.buffer32,0),s=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(s)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:o,chunkPos:s,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(o.slice()),t.stack=u.map(f=>Uint32Array.from(f)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:o,bufferOut32:s}=this,{h:i,l:c}=rn(BigInt(this.chunkOut++));se||ie(o);const{v0:u,v1:a,v2:f,v3:d,v4:l,v5:h,v6:p,v7:v,v8:b,v9:m,v10:g,v11:x,v12:y,v13:w,v14:A,v15:_}=os(ss,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ke[0],Ke[1],Ke[2],Ke[3],c,i,n,r);s[0]=u^b,s[1]=a^m,s[2]=f^g,s[3]=d^x,s[4]=l^y,s[5]=h^w,s[6]=p^A,s[7]=v^_,s[8]=t[0]^b,s[9]=t[1]^m,s[10]=t[2]^g,s[11]=t[3]^x,s[12]=t[4]^y,s[13]=t[5]^w,s[14]=t[6]^A,s[15]=t[7]^_,se||(ie(o),ie(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|Ae.ROOT;this.stack.length?(t|=Ae.PARENT,se||ie(this.buffer32),this.compress(this.buffer32,0,!0),se||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ae.CHUNK_START)|Ae.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Ot(this,!1),en(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 it(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Mn(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 Va=Pc(e=>new Gn(e)),Ha={dkLen:32},is=e=>Va(e,Ha),za=e=>ae(is(e),e),cs=e=>e,ft=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Nn=2n**64n-1n,ne=(e,t)=>e<<t&Nn|e>>64n-t,L=(e,t)=>e*t&Nn,G=(e,t)=>e+t&Nn,N=11400714785074694791n,we=14029467366897019727n,as=1609587929392839161n,Dt=9650029242287828579n,us=2870177450012600261n;function rt(e,t=0n){let n=G(G(t,N),we),r=G(t,we),o=t,s=t-N,i=e.length,c=0,u=null;(function(){let h=0,p=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(h<=p-32){const v=p-32;do{let b;b=ft(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=L(ne(G(n,L(b,we)),31n),N),h+=8,b=ft(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=L(ne(G(r,L(b,we)),31n),N),h+=8,b=ft(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=L(ne(G(o,L(b,we)),31n),N),h+=8,b=ft(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=L(ne(G(s,L(b,we)),31n),N),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,f=0;for(i>=32?(a=ne(n,1n),a=G(a,ne(r,7n)),a=G(a,ne(o,12n)),a=G(a,ne(s,18n)),n=L(ne(L(n,we),31n),N),a=a^n,a=G(L(a,N),Dt),r=L(ne(L(r,we),31n),N),a=a^r,a=G(L(a,N),Dt),o=L(ne(L(o,we),31n),N),a=a^o,a=G(L(a,N),Dt),s=L(ne(L(s,we),31n),N),a=a^s,a=G(L(a,N),Dt)):a=G(t,us),a=G(a,BigInt(i));f<=c-8;){let l=ft(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]);l=L(ne(L(l,we),31n),N),a=G(L(ne(a^l,27n),N),Dt),f+=8}if(f+4<=c){let l=L(ft(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),N);a=G(L(ne(a^l,23n),we),as),f+=4}for(;f<c;){const l=L(ft(e[f++],0,0,0),us);a=L(ne(a^l,11n),N)}let d=a>>33n;return a=L(a^d,we),d=a>>29n,a=L(a^d,as),d=a>>32n,a^=d,a}const fn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,rt(e),!0),n.setBigUint64(8,rt(e,1n),!0),t},ls=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,rt(e),!0),n.setBigUint64(8,rt(e,1n),!0),n.setBigUint64(16,rt(e,2n),!0),n.setBigUint64(24,rt(e,3n),!0),t},fs=e=>ae(Ct.enc(rt(e)),e),hs=new TextEncoder,ja=new Map([[cs,0],[fs,8],[rs,16],[Yn,-16],[Mt,-32],[fn,-16],[ls,-32]]),ds=e=>{const t=fn(hs.encode(e));return(n,...r)=>{const o=ae(t,fn(hs.encode(n))),s=Z(o),i=a=>{if(!a.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=pe(a.slice(s.length)),d=new Array(r.length);for(let l=0,h=0;l<r.length;l++){const[p,v]=r[l],b=ja.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[l]=Z(f.slice(h,h+m)),h+=m}else h+=b,d[l]=p.dec(f.slice(h)),h+=p.enc(d[l]).length}return d},c=r.map(([{enc:a},f])=>d=>f(a(d)));return{enc:(...a)=>Z(ae(o,...a.map((f,d)=>c[d](f)))),dec:i}}},Fa=Le.fromText("modlpy/utilisuba").asBytes(),qa=({threshold:e,signatories:t})=>{const n=ps(t),r=ae(Fa,oe.enc(n.length),...n,Ne.enc(e));return Mt(r)},ps=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const o=r>=t.length,s=r>=n.length;if(o&&s)return 0;if(o)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var vs=Object.freeze({__proto__:null,AccountId:at,Bin:Ut,Binary:Le,Blake2128:Yn,Blake2128Concat:rs,Blake2256:Mt,Blake3256:is,Blake3256Concat:za,Bytes:Y,Enum:lt,FixedSizeBinary:un,Hex:Je,Identity:cs,Option:te,Result:Jt,ScaleEnum:Ue,Self:jn,Storage:ds,Struct:$,Tuple:de,Twox128:fn,Twox256:ls,Twox64Concat:fs,Variant:ge,Vector:R,_Enum:Lo,_void:C,bitSequence:$o,blockHeader:Yo,bool:sc,char:ta,compact:oe,compactBn:ln,compactNumber:O,createCodec:H,createDecoder:Zt,decAnyMetadata:ns,enhanceCodec:Ye,enhanceDecoder:Rn,enhanceEncoder:Bt,ethAccount:Wo,fixedStr:oa,fromBufferToBase58:Ao,getMultisigAccountId:qa,getSs58AddressInfo:Hn,h64:rt,i128:nc,i16:Ji,i256:oc,i32:ec,i64:tc,i8:Zi,metadata:et,selfDecoder:Uo,selfEncoder:Ro,sortMultisigSignatories:ps,str:Q,u128:Kr,u16:Ne,u256:rc,u32:_e,u64:Ct,u8:j,v14:Jo,v14Lookup:Kn,v15:es});const ht=O,Wa=R(de(Q,ht)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Ka=ge(Object.fromEntries(Object.values(M).map(e=>[e,C]))),Xa=R(de(Q,te(jn(()=>Qn)))),Ya=R(ht),Ga=$({typeRef:ht,length:te(ht)}),Na=te(O),Qa=ht,Za=$({ok:ht,ko:ht}),Qn=ge({struct:Wa,terminal:Ka,enum:Xa,tuple:Ya,array:Ga,binary:Na,option:Qa,result:Za}),Ja={i256:M.big,i128:M.big,i64:M.big,i32:M.num,i16:M.num,i8:M.num,u256:M.big,u128:M.big,u64:M.big,u32:M.num,u16:M.num,u8:M.num,bool:M.bool,char:M.str,str:M.str},Vt=e=>({type:"terminal",value:{type:e}});function Ht(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Vt(M.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 Vt(M.bits);case"compact":return Vt(e.isBig?M.big:M.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>(r.type==="lookupEntry"&&t(r.value.id),[n,r.type==="lookupEntry"?Ht(r.value,t):Ht(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,o])=>[r,o.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 Vt(Ja[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 Vt(M.void)}}function Zn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(s,i)=>Zn(s,i,n),o=s=>{switch(s.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===s.value.type;case M.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case M.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Le&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const s=e;return t.value.length!=null&&s.length<t.value.length?!1:s.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u);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 eu=Object.defineProperty,tu=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nu=(e,t,n)=>tu(e,t+"",n);class bs{constructor(t=[]){nu(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 Se=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Se||{});function Jn(e,t,n,r,o){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const s=o.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new bs([[e,n]])}:be(c)}s.set(e,null);const i=ru(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,o));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?s.set(e,i.level):s.delete(e),i}function ru(e,t,n){if(e.type!==t.type)return t.type==="option"?hn(n(e,t.value),2):e.type==="option"?hn(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(ys(e.value,t.value));case"array":const o=e,s=be(ys(o.value.length,t.value.length));return er([s,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const f=e,d=Object.fromEntries(t.value),l=f.value.length===t.value.length?3:2;return hn(ms(f.value.map(([h,p])=>()=>h in d?n(p,d[h]):be(0))),l)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return hn(er(t.value.map(([f,d])=>()=>n(c[f],d))),u);case"tuple":{const f=e,d=be(su(f.value,t.value));return er([d,...t.value.map((l,h)=>()=>n(f.value[h],l))])}case"result":const a=e;return ms([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const hn=(e,t)=>({...e,level:Math.min(e.level,t)}),ou=new bs,be=e=>({level:e,assumptions:ou}),er=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},ms=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const o=typeof r=="function"?r():r;if(o.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(o.assumptions.values),n.level=Math.min(n.level,o.level)}return t?n:be(0)},su=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ys=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,gs=ge({lookup:O,typedef:Qn}),vt=e=>({type:"lookup",value:e}),tr=e=>({type:"typedef",value:e}),dn=tr({type:"terminal",value:{type:M.void}}),iu=$({args:gs,values:gs});function cu(e){if(e.type.tag==="plain")return{args:dn,values:vt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:vt(t),values:vt(n)}}function au(e){return{args:tr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:vt(e.output)}}function uu(e){return e.type==="lookupEntry"?vt(e.value.id):tr(Ht(e))}function lu(e){return{args:dn,values:vt(e)}}function fu(e,t,n,r,o){const s=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:Jn(s(e.args,t),t,s(n.args,r),r,o).level,values:Jn(s(n.values,r),r,s(e.values,t),t,o).level}}function ws(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const bt=()=>{},Ie={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},pn={chainName:"",genesisHash:"",properties:""},nr={broadcast:"",stop:""};Object.entries({chainHead:Ie,chainSpec:pn,transaction:nr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const hu=e=>(t,n)=>{let r=e(nr.broadcast,[t],{onSuccess:o=>{r=o===null?bt:()=>{e(nr.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Es extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class vn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class bn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class ks extends Error{constructor(t){super(t),this.name="OperationError"}}class mn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function du(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const xs=()=>{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)})}}},yn=e=>(...t)=>new Promise((n,r)=>{let o=$t;const[s,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Io)};i?.addEventListener("abort",c,{once:!0});const u=a=>f=>{o=$t,i?.removeEventListener("abort",c),a(f)};o=e(u(n),u(r),...s)}),As=(e,t)=>n=>yn((r,o,...s)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...s);return n(e,u,{onSuccess:(f,d)=>{if(f.result==="limitReached")return o(new bn);const{operationId:l}=f,h=()=>{n(Ie.stopOperation,[l])};if(!i)return h();let p=bt;const v=m=>{i=!1,p(),r(m)},b=m=>{i=!1,p(),o(m)};p=d(l,{next:m=>{const g=m;g.event==="operationError"?o(new ks(g.error)):g.event==="operationInaccessible"?o(new mn):a(m,v,b)},error:b}),c=()=>{i&&(p(),h())}},onError:o}),()=>{c()}}),pu=As(Ie.body,e=>[[e],(t,n)=>{n(t.value)}]),vu=As(Ie.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),bu=e=>t=>new Promise((n,r)=>{e(Ie.header,[t],{onSuccess:n,onError:r})}),Ss=e=>(t,n,r,o,s,i,c)=>{if(n.length===0)return i(),$t;let u=!0,a=()=>{u=!1};return e(Ie.storage,[t,n,r],{onSuccess:(f,d)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return s(new bn);const{operationId:l}=f,h=()=>{e(Ie.stopOperation,[l])};if(!u)return h();const p=d(f.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{o(m.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new ks(m.error));break}case"operationInaccessible":{v(new mn);break}default:e(Ie.continue,[m.operationId])}},error:s});a=()=>{p(),e(Ie.stopOperation,[f.operationId])};const v=m=>{a=$t,p(),s(m)},b=()=>{a=$t,p(),i()};c(f.discardedItems)},onError:s}),()=>{a()}},mu=e=>{const t=Ss(e);return yn((n,r,o,s,i,c)=>{const u=s.startsWith("descendants");let a=u?[]:null;const d=t(o,[{key:i,type:s}],c??null,u?l=>{a.push(l)}:l=>{a=l[0]?.[s]},r,()=>{try{n(u?a.flat():a)}catch(l){r(l)}},l=>{l>0&&(d(),r(new bn))});return d})},yu=e=>t=>t.length>0?new Promise((n,r)=>{e(Ie.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class gn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function gu(e){return e.operationId!==void 0}function wu(e){return(t,n,r)=>{const o=xs(),s=new Set,i=du();let c=i.promise;const u=p=>{if(gu(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Es),l(!1)},a=p=>{r(p),l(!(p instanceof gn))},f=(p,v)=>{const b=v(p,{next:u,error:a});l=(m=!0)=>{c=null,l=bt,b(),m&&e(Ie.unfollow,[p]),o.errorAll(new vn),s.forEach(g=>{g()}),s.clear()},c=p,i.res(p)},d=p=>{p instanceof gn?l(!1):r(p),c=null,i.res(p)};let l=e(Ie.follow,[t],{onSuccess:f,onError:d});const h=(p,v,b)=>{const m=()=>{b?.onError(new vn)};if(c===null)return m(),bt;const g=y=>{if(!b)return e(p,[y,...v]);s.add(m);const w=(_,P)=>c===null?(P.error(new vn),bt):(o.subscribe(_,P),()=>{o.unsubscribe(_)}),A=e(p,[y,...v],{onSuccess:_=>{s.delete(m),b.onSuccess(_,w)},onError:_=>{s.delete(m),b.onError(_)}});return()=>{s.delete(m),A()}};if(typeof c=="string")return g(c);let x=bt;return c.then(y=>{if(y instanceof Error)return m();c&&(x=g(y))}),()=>{x()}};return{unfollow(){l(),c=null},body:pu(h),call:vu(h),header:bu(h),storage:mu(h),storageSubscription:Ss(h),unpin:yu(h),_request:h}}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Is=(e,t,n)=>ku(e,typeof t!="symbol"?t+"":t,n);class _s extends Error{constructor(t){super(t.message),Is(this,"code"),Is(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let xu=1;const Au=e=>{let t=xu++;const n=new Map,r=xs();let o=null;const s=(f,d,l)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:d,params:l}))};function i(f){try{let d,l,h,p,v;if({id:d,result:l,error:h,params:p}=JSON.parse(f),d){const g=n.get(d);return g?(n.delete(d),h?g.onError(new _s(h)):g.onSuccess(l,(x,y)=>{const w=x;return r.subscribe(w,y),()=>{r.unsubscribe(w)}})):void 0}if({subscription:v,result:l,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const m=v;h?r.error(m,new _s(h)):r.next(m,l)}catch(d){console.warn("Error parsing incomming message: "+f),console.error(d)}}o=e(i);const c=()=>{o?.disconnect(),o=null,r.errorAll(new gn),n.forEach(f=>f.onError(new gn)),n.clear()};let u=1;return{request:(f,d,l)=>{if(!o)throw new Error("Not connected");const h=`${t}-${u++}`;return l&&n.set(h,l),s(h,f,d),()=>{n.delete(h)}},disconnect:c}},Su=e=>{const t=yn((r,o,s,i)=>e(s,i,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(pn.chainName,[]),t(pn.genesisHash,[]),t(pn.properties,[])]).then(([r,o,s])=>({name:r,genesisHash:o,properties:s})))},wn=new Map,Iu=e=>{const t=wn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Au(e),o=()=>{const i=wn.get(e);!i||i.refCount<=1?(wn.delete(e),r()):i.refCount--},s={chainHead:wu(n),transaction:hu(n),getChainSpecData:Su(n),destroy:o,request:yn((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return wn.set(e,{client:s,refCount:1}),s};var rr=function(e,t){return rr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},rr(e,t)};function Me(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");rr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function _u(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function c(f){try{a(r.next(f))}catch(d){i(d)}}function u(f){try{a(r.throw(f))}catch(d){i(d)}}function a(f){f.done?s(f.value):o(f.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Bs(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,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 u([a,f])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,o&&(s=a[0]&2?o.return:a[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;switch(o=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1],s=a;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(a);break}s[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(f){a=[6,f],o=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function mt(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 Be(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(c){i={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function Ce(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function yt(e){return this instanceof yt?(this.v=e,this):new yt(e)}function Bu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(o[h]=function(v){return new Promise(function(b,m){s.push([h,v,b,m])>1||u(h,v)})},p&&(o[h]=p(o[h])))}function u(h,p){try{a(r[h](p))}catch(v){l(s[0][3],v)}}function a(h){h.value instanceof yt?Promise.resolve(h.value.v).then(f,d):l(s[0][2],h)}function f(h){u("next",h)}function d(h){u("throw",h)}function l(h,p){h(p),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Cu(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 mt=="function"?mt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(c,u){i=e[s](i),o(c,u,i.done,i.value)})}}function o(s,i,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function z(e){return typeof e=="function"}function or(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 sr=or(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function En(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=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,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=mt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(z(l))try{l()}catch(v){s=v instanceof sr?v.errors:[v]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var h=mt(f),d=h.next();!d.done;d=h.next()){var p=d.value;try{$s(p)}catch(v){s=s??[],v instanceof sr?s=Be(Be([],_e(s)),_e(v.errors)):s.push(v)}}}catch(v){r={error:v}}finally{try{d&&!d.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}}if(s)throw new sr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)$s(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)&&En(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&En(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Cs=gt.EMPTY;function Os(e){return e instanceof gt||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function $s(e){z(e)?e():e.unsubscribe()}var Ou={Promise:void 0},$u={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Be([e,t],_e(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Ts(e){$u.setTimeout(function(){throw e})}function Ce(){}function kn(e){e()}var zt=function(e){Me(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Os(n)&&n.add(r)):r.destination=Ru,r}return t.create=function(n,r,o){return new wt(n,r,o)},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}(gt),Tu=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){xn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){xn(r)}else xn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){xn(n)}},e}(),wt=function(e){Me(t,e);function t(n,r,o){var s=e.call(this)||this,i;return z(n)||!n?i={next:n??void 0,error:r??void 0,complete:o??void 0}:i=n,s.destination=new Tu(i),s}return t}(zt);function xn(e){Ts(e)}function Pu(e){throw e}var Ru={closed:!0,next:Ce,error:Pu,complete:Ce},ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xe(e){return e}function cr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ps(e)}function Ps(e){return e.length===0?Xe:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=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 o=this,s=Lu(t)?t:new wt(t,n,r);return kn(function(){var i=o,c=i.operator,u=i.source;s.add(c?c.call(s,u):u?o._subscribe(s):o._trySubscribe(s))}),s},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=Rs(n),new n(function(o,s){var i=new wt({next:function(c){try{t(c)}catch(u){s(u),i.unsubscribe()}},error:s,complete:o});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[ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Ps(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Rs(t),new t(function(r,o){var s;n.subscribe(function(i){return s=i},function(i){return o(i)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Rs(e){var t;return(t=e??Ou.Promise)!==null&&t!==void 0?t:Promise}function Uu(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Lu(e){return e&&e instanceof zt||Uu(e)&&Os(e)}function Mu(e){return z(e?.lift)}function X(e){return function(t){if(Mu(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 q(e,t,n,r,o){return new Du(e,t,n,r,o)}var Du=function(e){Me(t,e);function t(n,r,o,s,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=s?function(a){try{s(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(zt),Vu=or(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),De=function(e){Me(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 Us(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Vu},t.prototype.next=function(n){var r=this;kn(function(){var o,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=mt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){o={error:a}}finally{try{c&&!c.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;kn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;kn(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,o=this,s=o.hasError,i=o.isStopped,c=o.observers;return s||i?Cs:(this.currentObservers=null,c.push(n),new gt(function(){r.currentObservers=null,En(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,s=r.thrownError,i=r.isStopped;o?n.error(s):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new Us(n,r)},t}(T),Us=function(e){Me(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.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,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:Cs},t}(De),Hu=function(e){Me(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,o=n.thrownError,s=n._value;if(r)throw o;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(De),ar={now:function(){return(ar.delegate||Date).now()},delegate:void 0},An=function(e){Me(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=ar);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,o=r.isStopped,s=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;o||(s.push(n),!i&&s.push(c.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,s=o._infiniteTimeWindow,i=o._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=s?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,s=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!i){for(var u=o.now(),a=0,l=1;l<s.length&&s[l]<=u;l+=2)a=l;a&&s.splice(0,a+1)}},t}(De),zu=function(e){Me(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),Ls={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Be([e,t],_e(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ju=function(e){Me(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,i=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(i,s,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),Ls.setInterval(n.flush.bind(n,this),o)},t.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&Ls.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var o=!1,s;try{this.work(n)}catch(i){o=!0,s=i||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,s=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,En(s,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(zu),Ms=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=ar.now,e}(),Fu=function(e){Me(t,e);function t(n,r){r===void 0&&(r=Ms.now);var o=e.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},t}(Ms),Ds=new Fu(ju),qu=Ds,dt=new T(function(e){return e.complete()});function Vs(e){return e&&z(e.schedule)}function ur(e){return e[e.length-1]}function lr(e){return z(ur(e))?e.pop():void 0}function jt(e){return Vs(ur(e))?e.pop():void 0}function Wu(e,t){return typeof ur(e)=="number"?e.pop():t}var Hs=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function zs(e){return z(e?.then)}function js(e){return z(e[ir])}function Fs(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function qs(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 Ku(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ws=Ku();function Ks(e){return z(e?.[Ws])}function Xs(e){return Bu(this,arguments,function(){var n,r,o,s;return Bs(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,yt(n.read())];case 3:return r=i.sent(),o=r.value,s=r.done,s?[4,yt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,yt(o)];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 Ys(e){return z(e?.getReader)}function ue(e){if(e instanceof T)return e;if(e!=null){if(js(e))return Xu(e);if(Hs(e))return Yu(e);if(zs(e))return Gu(e);if(Fs(e))return Gs(e);if(Ks(e))return Nu(e);if(Ys(e))return Qu(e)}throw qs(e)}function Xu(e){return new T(function(t){var n=e[ir]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Yu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Gu(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Ts)})}function Nu(e){return new T(function(t){var n,r;try{for(var o=mt(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Gs(e){return new T(function(t){Zu(e,t).catch(function(n){return t.error(n)})})}function Qu(e){return Gs(Xs(e))}function Zu(e,t){var n,r,o,s;return _u(this,void 0,void 0,function(){var i,c;return Bs(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Cu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),o={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ot(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var s=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!o)return s}function Ns(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(q(r,function(o){return ot(r,e,function(){return r.next(o)},t)},function(){return ot(r,e,function(){return r.complete()},t)},function(o){return ot(r,e,function(){return r.error(o)},t)}))})}function Qs(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Ju(e,t){return ue(e).pipe(Qs(t),Ns(t))}function el(e,t){return ue(e).pipe(Qs(t),Ns(t))}function tl(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function nl(e,t){return new T(function(n){var r;return ot(n,t,function(){r=e[Ws](),ot(n,t,function(){var o,s,i;try{o=r.next(),s=o.value,i=o.done}catch(c){n.error(c);return}i?n.complete():n.next(s)},0,!0)}),function(){return z(r?.return)&&r.return()}})}function Zs(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ot(n,t,function(){var r=e[Symbol.asyncIterator]();ot(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function rl(e,t){return Zs(Xs(e),t)}function ol(e,t){if(e!=null){if(js(e))return Ju(e,t);if(Hs(e))return tl(e,t);if(zs(e))return el(e,t);if(Fs(e))return Zs(e,t);if(Ks(e))return nl(e,t);if(Ys(e))return rl(e,t)}throw qs(e)}function Et(e,t){return t?ol(e,t):ue(e)}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e);return Et(e,n)}function Ft(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Js=or(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function sl(e,t){return new Promise(function(n,r){var o=!1,s;e.subscribe({next:function(i){s=i,o=!0},error:r,complete:function(){o?n(s):r(new Js)}})})}function Oe(e,t){return new Promise(function(n,r){var o=new wt({next:function(s){n(s),o.unsubscribe()},error:r,complete:function(){r(new Js)}});e.subscribe(o)})}function il(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){r.next(e.call(t,s,o++))}))})}var cl=Array.isArray;function al(e,t){return cl(t)?e.apply(void 0,Be([],_e(t))):e(t)}function ei(e){return S(function(t){return al(e,t)})}var ul=Array.isArray,ll=Object.getPrototypeOf,fl=Object.prototype,hl=Object.keys;function dl(e){if(e.length===1){var t=e[0];if(ul(t))return{args:t,keys:null};if(pl(t)){var n=hl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function pl(e){return e&&typeof e=="object"&&ll(e)===fl}function vl(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function qt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e),r=lr(e),o=dl(e),s=o.args,i=o.keys;if(s.length===0)return Et([],n);var c=new T(ti(s,n,i?function(u){return vl(i,u)}:Xe));return r?c.pipe(ei(r)):c}function ti(e,t,n){return n===void 0&&(n=Xe),function(r){ni(t,function(){for(var o=e.length,s=new Array(o),i=o,c=o,u=function(l){ni(t,function(){var f=Et(e[l],t),h=!1;f.subscribe(q(r,function(d){s[l]=d,h||(h=!0,c--),c||r.next(n(s.slice()))},function(){--i||r.complete()}))},r)},a=0;a<o;a++)u(a)},r)}}function ni(e,t,n){e?ot(n,e,t):t()}function bl(e,t,n,r,o,s,i,c){var u=[],a=0,l=0,f=!1,h=function(){f&&!u.length&&!a&&t.complete()},d=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;ue(n(v,l++)).subscribe(q(t,function(m){t.next(m)},function(){b=!0},void 0,function(){if(b)try{a--;for(var m=function(){var g=u.shift();i||p(g)};u.length&&a<r;)m();h()}catch(g){t.error(g)}}))};return e.subscribe(q(t,d,function(){f=!0,h()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),z(t)?U(function(r,o){return S(function(s,i){return t(r,s,o,i)})(ue(e(r,o)))},n):(typeof t=="number"&&(n=t),X(function(r,o){return bl(r,o,e,n)}))}function Sn(e){return e===void 0&&(e=1/0),U(Xe,e)}function ml(){return Sn(1)}function fr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ml()(Et(e,jt(e)))}function hr(e){return new T(function(t){ue(e()).subscribe(t)})}var yl={connector:function(){return new De},resetOnDisconnect:!0};function gl(e,t){t===void 0&&(t=yl);var n=null,r=t.connector,o=t.resetOnDisconnect,s=o===void 0?!0:o,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=hr(function(){return e}).subscribe(i),s&&n.add(function(){return i=r()})),n},c}function dr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=qu);var r=-1;return t!=null&&(Vs(t)?n=t:r=t),new T(function(o){var s=il(e)?+e-n.now():e;s<0&&(s=0);var i=0;return n.schedule(function(){o.closed||(o.next(i++),0<=r?this.schedule(void 0,r):o.complete())},s)})}function pr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e),r=Wu(e,1/0),o=e;return o.length?o.length===1?ue(o[0]):Sn(r)(Et(o,n)):dt}var wl=Array.isArray;function El(e){return e.length===1&&wl(e[0])?e[0]:e}function $e(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){return e.call(t,s,o++)&&r.next(s)}))})}function kt(e){return X(function(t,n){var r=null,o=!1,s;r=t.subscribe(q(n,void 0,void 0,function(i){s=ue(e(i,kt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,s.subscribe(n))})}function kl(e,t,n,r,o){return function(s,i){var c=n,u=t,a=0;s.subscribe(q(i,function(l){var f=a++;u=c?e(u,l,f):(c=!0,l),i.next(u)},o))}}function ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=lr(e);return n?cr(ri.apply(void 0,Be([],_e(e))),ei(n)):X(function(r,o){ti(Be([r],_e(El(e))))(o)})}function xl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ri.apply(void 0,Be([],_e(e)))}function oi(e,t){return z(t)?U(e,t,1):U(e,1)}function re(e){return e<=0?function(){return dt}:X(function(t,n){var r=0;t.subscribe(q(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Al(e){return S(function(){return e})}function Sl(e,t){return U(function(n,r){return ue(e(n,r)).pipe(re(1),Al(n))})}function Il(e,t){t===void 0&&(t=Ds);var n=dr(e,t);return Sl(function(){return n})}function _l(e,t){return X(function(n,r){var o=new Set;n.subscribe(q(r,function(s){var i=e?e(s):s;o.has(i)||(o.add(i),r.next(s))})),t&&ue(t).subscribe(q(r,function(){return o.clear()},Ce))})}function me(e,t){return t===void 0&&(t=Xe),e=e??Bl,X(function(n,r){var o,s=!0;n.subscribe(q(r,function(i){var c=t(i);(s||!e(o,c))&&(s=!1,o=c,r.next(i))}))})}function Bl(e,t){return e===t}function Cl(){return X(function(e,t){var n,r=!1;e.subscribe(q(t,function(o){var s=n;n=o,r&&t.next([s,o]),r=!0}))})}function vr(e,t){return X(kl(e,t,arguments.length>=2,!0))}function In(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new De}:t,r=e.resetOnError,o=r===void 0?!0:r,s=e.resetOnComplete,i=s===void 0?!0:s,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,f,h,d=0,p=!1,v=!1,b=function(){f?.unsubscribe(),f=void 0},m=function(){b(),l=h=void 0,p=v=!1},g=function(){var x=l;m(),x?.unsubscribe()};return X(function(x,y){d++,!v&&!p&&b();var w=h=h??n();y.add(function(){d--,d===0&&!v&&!p&&(f=br(g,u))}),w.subscribe(y),!l&&d>0&&(l=new wt({next:function(A){return w.next(A)},error:function(A){v=!0,b(),f=br(m,o,A),w.error(A)},complete:function(){p=!0,b(),f=br(m,i),w.complete()}}),ue(x).subscribe(l))})(a)}}function br(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 o=new wt({next:function(){o.unsubscribe(),e()}});return ue(t.apply(void 0,Be([],_e(n)))).subscribe(o)}}function mr(e,t,n){var r,o,s,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):i=e??1/0,In({connector:function(){return new An(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ol(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e);return X(function(r,o){(n?fr(e,r,n):fr(e,r)).subscribe(o)})}function yr(e,t){return X(function(n,r){var o=null,s=0,i=!1,c=function(){return i&&!o&&r.complete()};n.subscribe(q(r,function(u){o?.unsubscribe();var a=0,l=s++;ue(e(u,l)).subscribe(o=q(r,function(f){return r.next(t?t(u,f,l,a++):f)},function(){o=null,c()}))},function(){i=!0,c()}))})}function $l(){return yr(Xe)}function si(e){return X(function(t,n){ue(e).subscribe(q(n,function(){return n.complete()},Ce)),!n.closed&&t.subscribe(n)})}function ii(e,t){return t===void 0&&(t=!1),X(function(n,r){var o=0;n.subscribe(q(r,function(s){var i=e(s,o++);(i||t)&&r.next(s),!i&&r.complete()}))})}function ci(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(o,s){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;o.subscribe(q(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Xe}function gr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=lr(e);return X(function(r,o){for(var s=e.length,i=new Array(s),c=e.map(function(){return!1}),u=!1,a=function(f){ue(e[f]).subscribe(q(o,function(h){i[f]=h,!u&&!c[f]&&(c[f]=!0,(u=c.every(Xe))&&(c=null))},Ce))},l=0;l<s;l++)a(l);r.subscribe(q(o,function(f){if(u){var h=Be([f],_e(i));o.next(n?n.apply(void 0,Be([],_e(h))):h)}}))})}var Tl=Object.defineProperty,Pl=(e,t,n)=>t in e?Tl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ai=(e,t,n)=>Pl(e,typeof t!="symbol"?t+"":t,n);class Rl{constructor(){ai(this,"first"),ai(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 Ul=()=>{const e=new Map,t=(h,d)=>{e.set(h,()=>{e.delete(h),d()})},n=h=>{e.get(h)?.()},r=new Rl,o=r.unshift.bind(r),s=r.push.bind(r),i=(h,d)=>{const p=d?o:s;t(h.source$,p(h))},c=()=>{const h=r.pop();h&&(e.delete(h.source$),u(h))},u=h=>{const{source$:d,observer:p}=h;let v=!1;const b=d.subscribe({next(m){p.next(m)},error(m){(v=m instanceof bn)?i(h,!0):p.error(m)},complete(){p.complete()}});b.closed?v||c():t(d,()=>{b.unsubscribe(),c()})},a=(h=!1)=>d=>new T(p=>{const v={observer:p,source$:d};return r.isEmpty()?u(v):i(v,h),()=>{n(d)}}),l=a();return{withRecovery:a,withRecoveryFn:h=>(...d)=>l(h(...d))}};class Wt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}class Ll extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class ui extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Ml=new Set(["best","finalized",null]),li=e=>{const t=e.pipe(kt(n=>n instanceof mn?dr(750).pipe(oi(()=>t)):Ft(()=>n)));return t},Dl=(e,t,n)=>r=>(o,...s)=>{if(!Ml.has(o))return li(r(o,...s)).pipe(n(o));const c=(o==="best"?t:e).pipe(re(1),U(u=>r(u,...s).pipe(n(u))),kt(u=>u instanceof Wt?c:Ft(()=>u)));return li(c)},fi=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Vl=e=>t=>(...n)=>e()[t](...n),hi=(e,t)=>e.pipe(ii(n=>n.blocks.has(t)),me((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let o=n.blocks.get(n.best),s=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),s=s||n.finalized===o.hash;return s?"finalized":o.hash===t?"best":null}),me(),ii(n=>n!=="finalized",!0));function Hl(e,t,n){return(r,o,...s)=>(o?cr(jl(r,t.pipe($e(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),zl(r,e)):c=>c)(n(r,...s))}const zl=(e,t)=>n=>hi(t,e).pipe(re(1),yr(r=>r?n:Ft(()=>new ui))),jl=(e,t)=>n=>new T(r=>{const o=t.pipe($e(i=>i===e)).subscribe(()=>{r.error(new Ll)}),s=n.subscribe(r);return()=>{o.unsubscribe(),s.unsubscribe()}});function _n(e,t,n){return(r,...o)=>{const s=t(r,...o);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=s.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const f=e.subscribe({next:h=>{const d=h.blocks.get(r);d?d.recovering?c?.unsubscribe():a():l&&i.error(new Wt(r,n)),l=h.recovering},error:h=>i.error(h)});return()=>{f.unsubscribe(),c?.unsubscribe()}})}}const Fl=(e,t)=>{const n=(r,o,s,i)=>new T(c=>e().storageSubscription(r,o,s??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,o.slice(-u),s,!0))})).pipe(Sn(),t(i));return n},ql=e=>t=>t.pipe(oi(n=>n.type!=="initialized"?Ve(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Wl=e=>{let t=null,n=Ce;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(Yo.dec),s=gl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(ql(o),Kl()));return{getHeader:o,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Kl=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof Es?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n}),di=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",st={type:"void"},Xl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>f=>{let h=n.get(f);if(h)return h;if(r.has(f)){const p={id:f};return n.set(f,p),p}r.add(f);const d=l(f);return h=n.get(f),h?Object.assign(h,d):(h={id:f,...d},n.set(f,h)),r.delete(f),h};let s=!0,i=!0;const c=o(l=>{const f=t(e[l]);if(f)return f;const{def:h,path:d,params:p}=e[l];if(h.tag==="composite"){if(h.value.length===0)return st;if(h.value.length===1){const v=c(h.value[0].type);return s&&d.at(-1)==="AccountId32"&&di(v,32)?(s=!1,{type:"AccountId32"}):i&&d.at(-1)==="AccountId20"&&di(v,20)?(i=!1,{type:"AccountId20"}):v}return u(h.value)}if(h.tag==="variant"){if(d.length===1&&d[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(d.length===1&&d[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(h.value.length===0)return st;const v={},b={};return h.value.forEach(m=>{const g=m.name;if(b[g]=m.docs,m.fields.length===0){v[g]={...st,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[g]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[g]={...u(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:v}=h.value,b=c(h.value.type);return!v||b.type==="void"?st:v>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?st:h.value.length>1?a(h.value.map(v=>c(v)),h.value.map(v=>e[v].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const v=c(h.value);return v.type==="void"?st:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:h.tag}}),u=l=>{let f=!0;const h={},d={};return l.forEach((p,v)=>{f=f&&!!p.name;const b=p.name||v,m=c(p.type);m.type!=="void"&&(h[b]=m,d[b]=p.docs)}),f?{type:"struct",value:h,innerDocs:d}:a(Object.values(h),Object.values(d))},a=(l,f)=>{if(l.every(h=>h.id===l[0].id)&&f.every(h=>!h.length)){const[h]=l;return h.type==="void"?st:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:f}};return c},wr=e=>{const t=Xl(e.lookup,({def:o})=>{if(o.tag==="composite"){const s=n(o);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...st,idx:i.index}:{type:"lookupEntry",value:t(i.errors),idx:i.index}])),byteLength:s}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const i=t(o.value[0].type),c=t(o.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},Yl=(e,t,n)=>(r,o,s,...i)=>{const{id:c}=r;if(o.has(c))return o.get(c);if(s.has(c)){const a=t(()=>o.get(c),r,...i);return o.set(c,a),a}s.add(c);let u=e(r,o,s,...i);return s.delete(c),o.has(c)&&(u=n(u,o.get(c),r,...i)),o.set(c,u),u},Gl=Ut(),pi=Yl((e,t,n,r)=>{if(e.type==="primitive")return vs[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Wo;if(e.type==="compact")return e.isBig?ln:O;if(e.type==="bitSequence")return $o;const o=d=>pi(d,t,n,r),s=(d,p)=>{const v=o(d);return p?R(v,p):R(v)},i=d=>de(...d.map(o)),c=d=>{const p=Object.fromEntries(Object.entries(d).map(([v,b])=>[v,o(b)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Gl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ut(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return te(o(e.value));if(e.type==="result")return Jt(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return C;case"lookupEntry":return o(d.value);case"tuple":return i(d.value);case"struct":return c(d.value);case"array":return s(d.value,d.len)}}),a=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),l=Object.values(e.value).map(d=>d.idx),h=l.every((d,p)=>d===p)?ge(a):ge(a,l);return e.byteLength?Nl(h,e.byteLength):h},jn,e=>e),vi=(e,t=at())=>{const n=new Map,r=o=>pi(e(o),n,new Set,t);return o=>r(o)},Nl=(e,t)=>{const n=Y(t);return H(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},bi=e=>{const{metadata:t}=e;let n=vi(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let o;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(o=f,n=vi(e,at(f)))}catch{}const s=new Map,i=(f,h)=>{let d=s.get(f);d||s.set(f,d=ds(f));const p=t.pallets.find(A=>A.name===f).storage.items.find(A=>A.name===h),v=(A,_,...P)=>({keys:d(...P),value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0});if(p.type.tag==="plain")return v(0,n(p.type.value),h);const{key:b,value:m,hashers:g}=p.type.value,x=n(m),y=g.map(A=>vs[A.tag]),w=(()=>{if(y.length===1)return[[n(b),y[0]]];const A=e(b);switch(A.type){case"array":return y.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,P)=>[n(_.id),y[P]]);default:throw new Error("Invalid key type")}})();return v(y.length,x,h,...w)},c=f=>{switch(f.type){case"void":return C;case"lookupEntry":return n(f.value.id);case"tuple":return de(...Object.values(f.value).map(h=>n(h.id)));case"struct":return $(pt(f.value,h=>n(h.id)));case"array":return R(n(f.value.id),f.len)}},u=(f,h)=>{const d=t.pallets.find(p=>p.name===f).constants.find(p=>p.name===h);return n(d.type)},a=f=>(h,d)=>{const p=t.pallets.find(m=>m.name===h),v=e(p[f]);if(v.type!=="enum")throw null;const b=v.value[d];return{location:[p.index,b.idx],codec:c(v.value[d])}},l=(f,h)=>{const d=t.apis.find(p=>p.name===f)?.methods.find(p=>p.name===h);if(!d)throw null;return{args:de(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},Ql=Z(Ie.enc(15)),mi=Y(),Zl=te(mi),Jl=R(Ie).dec,ef=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(kt(l=>{if(l instanceof Wt)return r(c,u);if(l instanceof mn)return dr(750).pipe(U(()=>r(c,u)));throw l})):dt},o=r("Metadata_metadata_versions","").pipe(S(Jl)),s=r("Metadata_metadata","").pipe(S(c=>{const u=mi.dec(c);return{metadata:et.dec(u).metadata.value,metadataRaw:u}})),i=r("Metadata_metadata_at_version",Ql).pipe(S(c=>{const u=Zl.dec(c);return{metadata:et.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(kt(()=>Ve([14])),U(c=>c.includes(15)?i:s))};return n=>{const r=n(),o=new Set([r]),s=t(n).pipe(S(({metadata:c,metadataRaw:u})=>{const a=wr(c),l=bi(a),f=l.buildStorage("System","Events"),h=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let d=null;if(h){const p=a(h.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(d=v.value.id)}}return{assetId:d,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:f.keys.enc(),dec:f.value.dec},accountId:at(l.ss58Prefix)}}),mr(1)),i={at:r,runtime:s,addBlock:c=>(o.add(c),i),deleteBlocks:c=>(c.forEach(u=>{o.delete(u)}),o.size),usages:o};return s.subscribe({error(){}}),i}},Kt=In({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),yi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},gi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},wi=(e,t)=>{t.forEach(n=>{gi(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]})},tf=(e,t,n,r)=>{const o=pr(n,e).pipe(vr((i,c)=>{switch(c.type){case"initialized":i.recovering&&(c.finalizedBlockHashes.some(h=>i.blocks.has(h))||(i=Ei()));const[u]=c.finalizedBlockHashes.slice(-1);i.finalized=i.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((f,h)=>{i.blocks.has(f)?i.blocks.get(f).recovering=!1:i.blocks.set(f,{hash:f,parent:h===0?c.parentHash:c.finalizedBlockHashes[h-1],children:new Set(h===a?[]:[c.finalizedBlockHashes[h+1]]),runtime:f,refCount:0,number:c.number+h,recovering:!1})});const l=Object.values(i.runtimes).find(f=>f.usages.has(u));return i.finalizedRuntime=l??(i.runtimes[u]=s(yi(i,u))),i;case"stop-error":for(const f of i.blocks.values())f.recovering=!0;return i.recovering=!0,i;case"newBlock":{const{parentBlockHash:f,blockHash:h}=c;if(i.blocks.has(h))i.blocks.get(h).recovering=!1;else{const d=i.blocks.get(f);d.children.add(h),c.newRuntime&&(i.runtimes[h]=s(yi(i,h)));const p={hash:h,number:d.number+1,parent:f,children:new Set,runtime:c.newRuntime?h:d.runtime,refCount:0,recovering:!1};i.blocks.set(h,p),i.runtimes[p.runtime].addBlock(h)}return i}case"bestBlockChanged":{if(i.recovering){for(const[f,h]of i.blocks)h.recovering&&gi(i.blocks,f);i.recovering=!1}return i.best=c.bestBlockHash,i}case"finalized":{i.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=i;f.get(i.best).number<f.get(i.finalized).number&&(i.best=i.finalized),i.finalizedRuntime=i.runtimes[f.get(i.finalized).runtime];const{prunedBlockHashes:h}=c;return wi(i,h),r(h),setTimeout(()=>{const d=[],p=[];let v=f.get(f.get(i.finalized).parent);for(;v;)d.push(v.hash),v.refCount===0&&!v.unpinned&&(p.push(v.hash),v.unpinned=!0),v=f.get(v.parent);const b=[];for(let m=d.length-1;m>=0&&(v=f.get(d[m]),!!v.unpinned);m--)b.push(v.hash);wi(i,b),r(p)},0),i}case"blockUsage":{if(!i.blocks.has(c.value.hash))return i;const f=i.blocks.get(c.value.hash);return f.refCount+=c.value.type==="hold"?1:-1,f.refCount===0&&f.number<i.blocks.get(i.finalized).number&&!f.recovering&&(f.unpinned=!0,r([f.hash])),i}}},Ei()),$e(i=>!!i.finalizedRuntime.runtime),S(i=>({...i})),Kt),s=ef(_n(o,t,"pinned-blocks"));return o},Ei=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ki=(e,t,n,r)=>{const o=c=>si(e.pipe($e(({blocks:u})=>!u.has(c)))),s=(c,u,a)=>{if(a)return Ve({hash:c,found:{type:!1,validity:null}});const l=o(c);return t(c).pipe(U(f=>{const h=f.indexOf(u);return h>-1?l(r(c)).pipe(S(d=>({hash:c,found:{type:!0,index:h,events:d}}))):n(c,u).pipe(S(d=>({hash:c,found:{type:!1,validity:d}})))}),l)},i=(c,u,a)=>s(c,u,a.has(c)).pipe(U(l=>{const{found:f}=l;return f.type||f.validity?.success===!1?Ve(l):e.pipe(o(c),U(h=>h.blocks.get(c).children),_l(),U(h=>i(h,u,a)))}));return c=>e.pipe(re(1),U(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},nf=new Uint8Array([2]),rf=(e,t)=>Z(ae(nf,pe(e),pe(t))),xi="TaggedTransactionQueue",Ai="validate_transaction",[,of]=ge({InvalidTransaction:ge({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:j,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:ge({CannotLookup:C,NoUnsignedValidator:C,Custom:j})}),sf=Zt(e=>{const t=j.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=of(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),cf=(e,t)=>(n,r)=>{const o=t(n).pipe(S(s=>{try{return s.dynamicBuilder.buildRuntimeCall(xi,Ai).value[1]}catch{return sf}}));return e(n,`${xi}_${Ai}`,rf(r,n)).pipe(gr(o),S(([s,i])=>i(s)))},af=e=>t=>new T(n=>{let r=!1;const o=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),o}),Si=(e,t=1/0)=>n=>new T(r=>{let o;const s=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const f=()=>{const h=s.get(a);if(!h){i.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=a++;s.delete(d),l!==d&&c.set(d,[]);let p=!1,v=h.subscribe({next(b){l===d?r.next(b):c.get(d).push(b)},complete(){if(p=!0,i.delete(d),d===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;f()},error(b){r.error(b)}});p||i.set(d,v)};return o=n.subscribe({next(h){const d=u++;s.set(d,hr(()=>e(h,d))),i.size<t&&f()},error(h){r.error(h)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(h=>h.unsubscribe()),o.unsubscribe(),s.clear(),c.clear()}}),uf=e=>t=>new T(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),o=()=>r.unsubscribe();return()=>{Promise.resolve().then(o)}}),Er=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),lf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=Wl(e),s=Vl(t),{withRecovery:i,withRecoveryFn:c}=Ul(),u=new De,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>I=>new T(B=>{const V=a(E),J=I.subscribe(B);return J.add(V),J}),f=E=>(I,...B)=>E(I,...B).pipe(l(I)),h=(E,I)=>(B,...V)=>new T(J=>{let Pe=!1;return m.pipe(re(1)).subscribe(ye=>{const ee=ye.blocks.get(B);Pe=!!ee&&!ee.unpinned}),Pe?E(B,...V).subscribe(J):J.error(new Wt(B,I))}),d=E=>t().unpin(E).catch(I=>{if(!(I instanceof vn))throw I}),p=(E,I)=>h(f((V=>Hl(m,r,V))(_n(m,c(fi(E)),`stop-${I}`))),I),v=(E,I=!0)=>(B,...V)=>E(B,I,...V),b=new Map,m=tf(r,f(c(fi(s("call")))),u,E=>{d(E),E.forEach(I=>{b.delete(I)})}),g=f(E=>m.pipe(re(1),U(I=>I.runtimes[I.blocks.get(E).runtime].runtime))),x=E=>I=>I.pipe(Si(B=>g(E(B)).pipe(S(V=>[B,V])))),y=(E,I,B)=>{const V=b.get(E)??new Map,J=V.get(I);if(J)return J;b.set(E,V);let Pe;const ye=B.pipe(In({connector:()=>Pe=new An}),ci({complete(){V.set(I,Pe)}}),uf());return V.set(I,ye),ye},w=m.pipe(me((E,I)=>E.finalized===I.finalized),vr((E,I)=>{let B=I.blocks.get(I.finalized);const V=[B],J=E.at(-1);if(!J)return V;for(;B.number>J.number+1&&(B=I.blocks.get(B.parent),!!B);)V.unshift(B);return V},[]),Sn(),S(Er),Kt),A=m.pipe(me((E,I)=>E.best===I.best),S(E=>Er(E.blocks.get(E.best))),Kt),_=m.pipe(me((E,I)=>E.finalized===I.finalized&&E.best===I.best),vr((E,I)=>{const B=ee=>E.get(ee)||Er(I.blocks.get(ee)),V=B(I.best),J=B(I.finalized),Pe=V.number-J.number+1,ye=new Array(Pe);for(let ee=0,Nt=V.hash;ee<Pe;ee++)ye[ee]=B(Nt),Nt=ye[ee].parent;return new Map(ye.map(ee=>[ee.hash,ee]))},new Map),S(E=>[...E.values()]),Kt),P=m.pipe(me((E,I)=>E.finalizedRuntime===I.finalizedRuntime),yr(({finalizedRuntime:{runtime:E}})=>E.pipe(af(null))),Kt),D=P.pipe(S(E=>E?.lookup.metadata??null)),F=Dl(w.pipe(S(E=>E.hash)),A.pipe(S(E=>E.hash)),l),le=F(p(s("body"),"body")),W=E=>y(E,"body",le(E,!0)),fe=p(s("storage"),"storage"),Te=F((E,I,B,V,J=null,Pe)=>m.pipe(re(1),U(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),U(ye=>{const ee=V(ye),Nt=y(E,`storage-${B}-${ee}-${J??""}`,fe(E,I,B,ee,J));return Pe?y(E,`storage-${B}-${ee}-${J??""}-dec`,Nt.pipe(S(Xi=>({raw:Xi,mapped:Pe(Xi,ye)})))):Nt}))),It=Fl(t,i),Gt=F(_n(m,(E,I,B)=>It(E,I,B??null,!1),"storageQueries")),Dr=F(_n(m,E=>hr(()=>o(E)),"header")),qi=(E,I=!1)=>Te(E,I,"value",B=>B.events.key,null,(B,V)=>V.events.dec(B)).pipe(S(B=>B.mapped)),sh=p(s("call"),"call"),Wi=F((E,I,B,V)=>y(E,`call-${B}-${V}`,sh(E,I,B,V))),Vr=cf(v(Wi,!1),g),Ki=E=>y(E,"body",le(E,!1)),ih=ki(m,Ki,Vr,qi),ch=ki(m,Ki,Vr,()=>Ve()),ah=P.pipe($e(Boolean),re(1),U(E=>{const{enc:I}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let B;try{B=I(0)}catch{B=I(0n)}return Te(null,!1,"value",()=>B,null)}),mr(1));pr(P,_).subscribe({error(){}});let Hr=Ce,Tn=!1,zr=0;const uh=E=>{zr+=E,Tn=!0,Hr=n()};return[{follow$:r,finalized$:w,best$:A,bestBlocks$:_,runtime$:P,metadata$:D,genesis$:ah,header$:Dr,body$:W,call$:v(Wi),storage$:v(Te),storageQueries$:Gt,eventsAt$:v(qi),holdBlock:a,trackTx$:ih,trackTxWithoutEvents$:ch,validateTx$:Vr,pinnedBlocks$:m,withRuntime:x,getRuntimeContext$:F(g),unfollow:()=>{Tn!=null&&(zr--,Tn&&!zr&&(Tn=null,Hr(),Hr=Ce))}},uh]};var ff=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Bn=new Map,hf=e=>{const t=Bn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Bn.get(e);!c||c.refCount<=1?(Bn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,s=null;const i={chainHead$:c=>{o++,s||(s=c||1),r||(r=lf(e.chainHead));const[u,a]=r;if(s===o){const l=o;o=0,s=null,r=null,a(l)}return u},broadcastTx$:ff(e.transaction),destroy:n};return Bn.set(e,{client:i,refCount:1}),i};class xt{constructor(){}_runtime(t){}}class Ii{constructor(){}_compatibility(t){}}const Cn=new WeakMap,_i=new WeakMap,kr=e=>e instanceof xt?_i.get(e):Cn.get(e);var At=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(At||{});const df=R(iu),pf=R(Qn),vf=de(df,pf),bf=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe($e(i=>i!=null));let s=await Oe(o);o.subscribe(i=>s=i),r(()=>s)});return Promise.all([e.metadataTypes.then(vf.dec),e.descriptors,n]).then(([[r,o],s,i])=>{const c=new Ii;return Cn.set(c,{runtime:i,getPalletEntryPoint(u,a,l){const f=s[u]?.[a]?.[l];if(f==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[f]},getApiEntryPoint(u,a){const l=s.apis?.[u]?.[a];if(l==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[l]},typedefNodes:o}),c})},mf=e=>new Promise(async t=>{const n=e.runtime$.pipe($e(o=>o!=null));let r=await Oe(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new xt;return _i.set(n,{runtime:t}),n}),xr=new WeakMap,Bi=e=>(xr.has(e.metadataRaw)||xr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),xr.get(e.metadataRaw)),St=(e,t,n)=>{const r=(i,c)=>{var u;const a=Bi(i);return(u=a.typeNodes)[c]||(u[c]=Ht(a.lookup(c)))};function o(i,c){if(i instanceof xt)return{args:Ae.Identical,values:Ae.Identical};const u=Cn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ae.Incompatible,values:Ae.Incompatible};const f=u.typedefNodes,h=Bi(c);return fu(a,d=>f[d],l,d=>r(c,d),h.compat)}const s=Oi(e,i=>Ci(o(i)));return{isCompatible:Oi(e,(i,c)=>s(c)>=i),getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:e,withCompatibleRuntime:(i,c)=>u=>qt([u.pipe(i.withRuntime(c)),e]).pipe(S(([[a,l],f])=>[a,f,l])),compatibleRuntime$:(i,c)=>qt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof xt)return!0;const a=o(i,c);if(a.args===Ae.Incompatible)return!1;if(a.args>Ae.Partial)return!0;if(a.values===Ae.Incompatible)return!1;const l=n(c);return l==null?!1:ws(l.args,f=>r(c,f),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof xt)return!0;const a=o(i,c).values;if(a===Ae.Incompatible)return!1;if(a>Ae.Partial)return!0;const l=Cn.get(i),f=t(l);return ws(f.values,h=>l.typedefNodes[h],u)},getRuntimeTypedef:r}},Ci=e=>Math.min(e.args,e.values),Oi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Ii||r instanceof xt?t(...n):e.then(o=>t(...n,o))},yf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:o,getCompatibilityLevel:s})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const f=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,f),f},u=a=>{if(a){const l=kr(a).runtime(),f=c(l);if(!n(a,l,f))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return f}return r.then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:s})},gf=In({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Ar(e,t){return new Promise((n,r)=>{let o=null,s=!1;const i=t?()=>{o?.unsubscribe(),r(new Io)}:Ce;o=e.subscribe({next:c=>{n(c),o?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",i),r(c),s=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",i)})}const Sr=Symbol("EMPTY_VALUE"),Ir=e=>t=>new T(n=>{let r=0,o=null,s=Sr,i=!1;const c=()=>{const a=e(s,r++);s=Sr,o=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){s!==Sr?c():(o=null,i&&n.complete())}})},u=t.subscribe({next(a){s=a,o||c()},error(a){n.error(a)},complete(){o||n.complete(),i=!0}});return()=>{o?.unsubscribe(),u.unsubscribe()}});let $i={};const wf=e=>t=>new T(n=>{let r=$i,o=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===$i?n.complete():o=e(r).subscribe(n)}});return()=>{o.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)),Ef=()=>{const e=new Hu(new De);return[e.pipe($l()),()=>ci({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new De)},complete:()=>{e.value.complete(),e.next(new De)}})]},kf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(s(n,l=>l.hash),S(([l,f,h])=>{const d=h.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(d==null||h.lookup.metadata.lookup[d].def.tag!=="variant"||h.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(f,h,null))throw u();return[l,f,h]}),Si(([l,f,h])=>n.eventsAt$(l.hash).pipe(S(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(f,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),gf);return{watch:l=>a.pipe(U(f=>l?f.filter(h=>l(h.payload)):f)),pull:()=>Oe(a),filter:l=>l.filter(f=>f.type===e&&f.value.type===t).map(f=>f.value.value),getCompatibilityLevel:o,isCompatible:r}},xf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const f=l[l.length-1],h=Xt(f),{signal:d,at:p}=h?f:{},v=p??null,b=s(n,v).pipe(U(([m,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(m,g,l))throw a();return n.call$(v,u,Z(x.args.enc(l))).pipe(S(x.value.dec),S(y=>{if(!c(m,g,y))throw a();return y}))}));return Ar(b,d)},{getCompatibilityLevel:o,isCompatible:r})},_r=S(e=>e.mapped),Af=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",f=e==="System"&&t==="BlockHash",h=n.runtime$.pipe($e(Boolean),re(1),S(({dynamicBuilder:y})=>typeof y.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Xe),mr()),d=cr(xl(h),S(([y,w])=>w(y))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=y=>new Error(`Invalid Arguments calling ${e}.${t}(${y})`),b=y=>{try{return y.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},m=(...y)=>{const w=y[y.length-1],A=w==="best",_=A||w==="finalized"?y.slice(0,-1):y;return n[A?"best$":"finalized$"].pipe(Ir(()=>g(..._,A?{at:"best"}:{})),me((P,D)=>P.raw===D.raw),_r)},g=(...y)=>{const w=y[y.length-1],A=Xt(w),{at:_}=A?w:{},P=_??null;return l?n.bestBlocks$.pipe(S(D=>P==="finalized"||!P?D.at(-1):P==="best"?D.at(0):D.find(F=>F.hash===P)),S(D=>{if(!D)throw new ui;return D.number}),me(),d,S(D=>({raw:D,mapped:D}))):f&&Number(y[0])===0?n.genesis$.pipe(S(D=>({raw:D,mapped:un.fromHex(D)}))):Et(c).pipe(U(D=>n.storage$(P,"value",F=>{const le=b(F),W=y.length===le.len?y:y.slice(0,-1);if(y!==W&&!A)throw v(y);if(!u(D,F,W))throw p();return le.keys.enc(...W)},null,(F,le)=>{const W=b(le),fe=F===null?W.fallback:W.value.dec(F);if(!a(D,le,fe))throw p();return fe})))},x=async(...y)=>{const w=y[y.length-1],A=Xt(w),{signal:_}=A?w:{};return Ar(g(...y).pipe(_r),_)};return{isCompatible:o,getCompatibilityLevel:s,getValue:x,getValues:(y,w)=>Promise.all(y.map(A=>x(...w?[...A,w]:A))),getEntries:async(...y)=>{const w=y[y.length-1],A=Xt(w),{signal:_,at:P}=A?w:{},D=P??null,F=await c,le=n.storage$(D,"descendantsValues",W=>{const fe=b(W);if(Ci(i(F,W))===Ae.Incompatible)throw p();if(y.length>fe.len)throw v(y);const Te=y.length>0&&A?y.slice(0,-1):y;if(y.length===fe.len&&Te===y)throw v(y);return fe.keys.enc(...Te)},null,(W,fe)=>{const Te=b(fe),It=W.map(({key:Gt,value:Dr})=>({keyArgs:Te.keys.dec(Gt),value:Te.value.dec(Dr)}));if(It.some(({value:Gt})=>!a(F,fe,Gt)))throw p();return It}).pipe(_r);return Ar(le,_)},watchValue:m,watchEntries:(...y)=>{const w=y.at(-1),A=Xt(w);return r(e,t,A?y.slice(0,-1):y,A&&w.at==="best")}}},Sf=Bt(j.enc,e=>+!!e.signed<<7|e.version),Br=()=>new Error("Unkown signer"),If=e=>{const{extrinsic:t}=e,n=wr(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=s.Address,o=s.Signature,!r||!o)throw Br()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in o.value)))throw Br();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Br()},_f={Ed25519:0,Sr25519:1,Ecdsa:2},Bf=(e,t,n,r,o,s)=>{const[i,c]=If(e),u=ae(Sf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!s?n:new Uint8Array([_f[s],...n]),...r,o);return ae(oe.enc(u.length),u)},[On,Yt]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),Cf=e=>async t=>{let n=!0,r;for(r=0;n&&r<On.length;r++)n=On[r]===t[r];n=n&&r===On.length;const o=t.length-Yt.length;for(r=0;n&&r<Yt.length;r++)n=Yt[r]===t[o+r];return n=n&&r===Yt.length,e(n?t:ae(On,t,Yt))};function Of(e,t,n){return{publicKey:e,signTx:async(o,s,i,c,u=Mt)=>{let a;try{const p=ns(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],f=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=s[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),f.push(v.additionalSigned)});const h=ae(o,...l,...f),d=await n(h.length>256?u(h):h);return Bf(a,e,d,l,o,t)},signBytes:Cf(n)}}const $f=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),o=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return o(n.value)};function Tf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Pf=Bt(Y(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Tf(e.period)-1,1),15),r=e.phase/t<<4;return Ne[0](n|r)}),[Rf]=$({tip:oe,asset:te(Y(1/0))}),Ti=new Uint8Array,Cr=Uint8Array.from([0]),Or=e=>({value:e,additionalSigned:Ti}),$r=e=>({value:Ti,additionalSigned:e}),Tr=(e,t)=>({value:e,additionalSigned:t}),Pi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:o,type:s,additionalSigned:i})=>{r[o]=[s,i].map(c=>n.buildDefinition(c)[0])}),({mortality:o,tip:s=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=$f(t,n),f=d=>{const[p,v]=r[d],b=c[d];try{return pt({value:p,additionalSigned:v},(m,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:m(x)})}catch{return a.push(d),null}},h=pt(r,([d,p],v)=>{if(c[v])return f(v);switch(v){case"CheckNonce":return Or(d(i));case"CheckMortality":return o.mortal?Tr(Pf({period:o.period,phase:o.startAtBlock.height%o.period}),pe(o.startAtBlock.hash)):Tr(Cr,e);case"ChargeTransactionPayment":return Or(d(s));case"ChargeAssetTxPayment":return Or(Rf({tip:s,asset:u.asset}));case"CheckGenesis":return $r(e);case"CheckMetadataHash":return Tr(Cr,Cr);case"CheckSpecVersion":return $r(p(l.spec_version));case"CheckTxVersion":return $r(p(l.transaction_version));default:return f(v)}});return a.forEach(d=>{delete h[d]}),pt(h,(d,p)=>({...d,identifier:p}))}},Ri="AccountNonceApi_account_nonce",Uf={1:j.dec,2:Ne.dec,4:Ie.dec,8:Ct.dec},Lf=(e,t,n)=>e(n,Ri,t).pipe(S(r=>{const o=pe(r),s=Uf[o.length];if(!s)throw new Error(`${Ri} retrieved wrong data`);return s(o)})),Mf=(e,t,n,r,o,s={})=>qt([s.nonce?Ve(s.nonce):Lf(e.call$,Z(t.publicKey),r.hash),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(re(1),U(([i,c,u])=>{const a=Pi(pe(u),c.lookup,c.dynamicBuilder),l=s.mortality??{period:64,mortal:!0},f=a({nonce:i,tip:s.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:o});return t.signTx(n,f,c.metadataRaw,r.number)}));var Df=Object.defineProperty,Vf=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hf=(e,t,n)=>Vf(e,t+"",n);const zf=e=>Z(Mt(pe(e))),jf=(e,t)=>new T(n=>{const r=new Map;let o,s;const i=()=>{let u=o.best,a=r.get(u),l=o.blocks.get(u).number;for(;!a;){const d=o.blocks.get(u);if(!d)break;a=r.get(u=d.parent),l--}if(!a)return;const f=l<=o.blocks.get(o.finalized).number,h=a.found.type;if(h&&s?.found&&s.hash===a.hash){f&&n.complete();return}n.next(s=a.found.type?{found:h,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:h,validity:a.found.validity}),f&&(h?n.complete():a.found.validity?.success===!1&&n.error(new Pr(a.found.validity.value)))},c=t.pipe(me((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{o=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(me((n,r)=>n===r)),Ff=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>({...o.event,topics:o.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 Pr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),Hf(this,"error"),this.name="InvalidTxError",this.error=t}}const Rr=(e,t,n,r,o=!1)=>{const s=zf(n),i=(l,f)=>({type:l,txHash:s,...f}),c=e.pinnedBlocks$.pipe(re(1),S(l=>{const f=l.blocks.get(r);return f&&!f.unpinned?f.hash:l.finalized})).pipe(U(l=>e.validateTx$(l,n).pipe($e(f=>!f.success),S(f=>{throw new Pr(f.value)})))),u=new T(l=>{const f=e.trackTx$(n).subscribe(l);return f.add(t(n).subscribe({error(h){l.error(h)}})),f}),a=jf(u,e.pinnedBlocks$).pipe(S(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...Ff(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return fr(o?Ve(i("signed",{})):dt,c,Ve(i("broadcasted",{})),a.pipe(wf(({found:l,type:f,...h})=>l?Ve(i("finalized",h)):dt)))},Ui=async(e,t,n,r)=>sl(Rr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const s={...o};return delete s.type,s}),qf=at().enc,Wf=new Uint8Array(64),Kf=new Uint8Array(65),Xf=e=>()=>e?Kf:Wf,[,Yf]=$({weight:$({ref_time:ln,proof_size:ln}),class:ge({Normal:C,Operational:C,Mandatory:C}),partial_fee:Kr}),Li=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const f=(y,w,A={})=>{const _=kr(y).runtime(),{dynamicBuilder:P,assetId:D,lookup:F}=_;let le;try{le=P.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(y,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let W=A;if(A.asset){if(D==null||!Zn(A.asset,Ht(F(D)),It=>u(_,It)))throw new Error("Incompatible runtime asset");W={...A,asset:P.buildDefinition(D).enc(A.asset)}}const{location:fe,codec:Te}=le;return{callData:Le.fromBytes(ae(new Uint8Array(fe),Te.enc(w))),options:W}},h=(y,w={})=>i(n,null).pipe(S(([A])=>f(A,y,w))),d=y=>y?f(y,l).callData:Oe(h(l).pipe(S(w=>w.callData))),p=(y,{...w},A)=>h(l,w).pipe(U(({callData:_,options:P})=>Mf(n,y,_.asBytes(),A,w.customSignedExtensions||{},P))),v=(y,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(S(_=>_.find(P=>P.hash===w)))).pipe(re(1),U(_=>_?p(y,A,_).pipe(S(P=>({tx:Z(P),block:_}))):Ft(()=>new Error(`Uknown block ${w}`)))),b=(y,w)=>Oe(v(y,w)).then(A=>A.tx),m=(y,w)=>Oe(v(y,w)).then(({tx:A,block:_})=>Ui(n,r,A,_.hash)),g=(y,w)=>v(y,w).pipe(U(({tx:A,block:_})=>Rr(n,r,A,_.hash,!0))),x=async(y,w)=>{typeof y=="string"&&(y=y.startsWith("0x")?pe(y):qf(y));const A=y.length===20,_=Of(y,A?"Ecdsa":"Sr25519",Xf(A)),P=pe(await b(_,w)),D=Z(ae(P,Ie.enc(P.length))),F=n.getRuntimeContext$(null).pipe(S(W=>{try{return W.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yf}})),le=n.call$(null,"TransactionPaymentApi_query_info",D);return Oe(qt([le,F]).pipe(S(([W,fe])=>fe(W))))};return{getPaymentInfo:x,getEstimatedFees:async(y,w)=>(await x(y,w)).partial_fee,decodedCall:{type:e,value:lt(t,l)},getEncodedData:d,sign:b,signSubmitAndWatch:g,signAndSubmit:m}},{getCompatibilityLevel:s,isCompatible:o});var Gf=Object.defineProperty,Nf=(e,t,n)=>t in e?Gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(Nf(e,typeof t!="symbol"?t+"":t,n),n),Ur=Symbol("SUSPENSE"),Qf=class extends Promise{constructor(e){super(e)}},Mi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Di=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ee={},$n=class extends T{constructor(e,t,n=Ce){super(r=>{const o=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Ce});this.refCount++;let s;r.add(()=>{var i;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=Ee,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Mi),this.promise=null))}),this.subject?(s=this.subject.subscribe(o),this.currentValue!==Ee&&r.next(this.currentValue)):(this.subject=new De,s=this.subject.subscribe(o),this.subscription=null,this.subscription=new zt({next:i=>{this.promise&&i!==Ur&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Ee;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Ur&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Di),this.promise=null),this.currentValue!==Ee)return this.subject.complete();if(t===Ee){const i=this.subject;return this.subject=null,i.error(new Di)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ee&&this.currentValue===Ee&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",Ee),He(this,"promise",null),He(this,"pipeState",(...r)=>{const o=super.pipe(...r);return o instanceof $n?o:new $n(o,Ee)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ee&&this.currentValue!==Ur)return this.currentValue;if(this.defaultValue!==Ee)return this.defaultValue;if(this.refCount===0)throw new Mi;const r=new Qf((o,s)=>{this.promise={res:o,rej:s,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===Ee&&delete this.getDefaultValue}};function Vi(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zf(e,t){const n=new Jf,r=typeof t=="function"?t:()=>t,o=s=>{for(let f=s.length-1;s[f]===void 0&&f>-1;f--)s.splice(-1);const i=[s.length,...s],c=n.get(i);if(c!==void 0)return c;const u=new $n(e(...s),r(...s),()=>{n.delete(i)}),a=new T(f=>{const h=n.get(i);let d=u;return h?h!==a&&(d=h,Vi(d,a)):n.set(i,l),d.subscribe(f)});Vi(u,a);const l=a;return n.set(i,l),l};return(...s)=>o(s)}var Jf=class{constructor(){He(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let o=n.get(e[r]);o||(o=new Map,n.set(e[r],o)),n=o}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let o=0;o<e.length-1;o++)t.push(n=n.get(e[o]));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 eh(e,t){return new $n(e,t)}var Lr=(...e)=>(typeof e[0]=="function"?Zf:eh)(e[0],e.length>1?e[1]:Ee);const Hi=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),o=new Map(e.map(c=>[c.key,c])),s=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=o.get(u);(!a||a.value!==c.value)&&s.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??o.get(c))}},zi=(e,t,n,r=!1)=>{try{let o=r?e:n.blocks.get(e).parent;for(;o&&!t[o];)o=n.blocks.get(o).parent;return o?t[o]:null}catch{return null}},ji=(e,t)=>n=>{const{keys:r,value:o}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:o.dec(s.value),args:r.dec(s.key)},s)},th=(e,t,n)=>{const r=Lr((c,u,a)=>{const l=ji(c,u),f=(b,m)=>{const g=hi(e,m.hash).pipe($e(x=>!x),re(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(U(x=>x===b?.rootHash?Ve({...b,block:m,deltas:null,prev:b.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),S(([y,w])=>[y,l(w)]),S(([y,w])=>({prev:b&&b.block.hash,rootHash:x,block:m,...Hi(b?.entries??[],y,w)})))),si(g),kt(x=>x instanceof Wt?dt:Ft(()=>x)))},h=e.pipe(me((b,m)=>b.finalized===m.finalized),Ir(({blocks:b,finalized:m})=>f(null,b.get(m))),re(1),S(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[d,p]=Ef(),v=e.pipe(me((b,m)=>b.best===m.best),gr(d),Ir(([b,m])=>{const{best:g}=b,{blocks:x}=m;let y=x[g]?null:g;if(!y)return dt;const w=zi(y,x,b);return w?f(w,b.blocks.get(y)).pipe(S(A=>(x[y]=A,m))):(y=b.finalized,f(x[m.finalized],b.blocks.get(y)).pipe(S(A=>(A.prev=null,{blocks:{[y]:A},finalized:y}))))}));return pr(h,v).pipe(p())}),o=c=>(u,a,l)=>{const f=r(u,a,l),h=ji(u,a),d=c?"finalized":"best";return qt([f.pipe(Il(0)),e.pipe(me((p,v)=>p[d]===v[d]))]).pipe(S(([p,v])=>zi(v[d],p.blocks,v,!0)),$e(Boolean),me(),Ol(null),Cl(),gr(f),n(([[,p]])=>p.block.hash),S(([[[p,v],b],m])=>[p,v,b,h(m)]),U(([p,v,b,m])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:y}=b;Object.keys(y).forEach(w=>{y[w].block.number<x[0].block.number&&delete y[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Hi(p.entries,v.entries,m)}]}))},s=Lr(o(!0)),i=Lr(o(!1));return(c,u,a,l)=>{const f=l?i:s;return e.pipe(re(1),U(h=>h.runtimes[h.blocks.get(h[l?"best":"finalized"]).runtime].runtime),S(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(re(1),U(h=>f(c,u,h)),S(({block:{hash:h,number:d,parent:p},deltas:v,entries:b},m)=>{const g=m>0?v:{deleted:[],upserted:b};return{block:{hash:h,number:d,parent:p},entries:b.map(Mr),deltas:g&&{deleted:g.deleted.map(Mr),upserted:g.upserted.map(Mr)}}}))}},Mr=e=>e.dec,Fi=(e,t,n)=>{const r={},o=v=>new Proxy(r,{get(b,m){return v(m)}}),s=v=>{const b={};return o(m=>(b[m]||(b[m]={}),o(g=>(b[m][g]||(b[m][g]=v(m,g)),b[m][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(m=>m.name===b),c=th(t.pinnedBlocks$,t.storage$,t.withRuntime),u=s((v,b)=>Af(v,b,t,c,St(e,m=>m.getPalletEntryPoint(At.Storage,v,b),m=>{const g=i(m,v)?.storage?.items.find(x=>x.name===b);return g==null?null:cu(g)}))),a=(v,b,m,g)=>{if(m==null)return null;const x=v.lookup(m);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const y=uu(x.value[g]);return{args:b==="args"?y:dn,values:b==="args"?dn:y}},l=s((v,b)=>Li(v,b,t,n,St(e,m=>m.getPalletEntryPoint(At.Tx,v,b),m=>a(m,"args",i(m,v)?.calls,b)),!0)),f=s((v,b)=>kf(v,b,t,St(e,m=>m.getPalletEntryPoint(At.Event,v,b),m=>a(m,"values",i(m,v)?.events,b)))),h=s((v,b)=>yf(v,b,St(e,m=>m.getPalletEntryPoint(At.Const,v,b),m=>{const g=i(m,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:lu(g)}))),d=s((v,b)=>xf(v,b,t,St(e,m=>m.getApiEntryPoint(v,b),m=>au(m.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:m,dynamicBuilder:g}=kr(b).runtime();try{const x=g.buildDefinition(m.call).dec(v.asBytes()),y=x.type,w=x.value.type,A=x.value.value;return Li(y,w,t,n,St(e,_=>_.getPalletEntryPoint(At.Tx,y,w),_=>a(_,"args",i(_,y)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,b)=>b?p(v,b):e.then(m=>p(v,m)),tx:l,event:f,apis:d,constants:h}};function nh(e){const t=Iu(e),n=hf(t),r=n.chainHead$(),{getChainSpecData:o}=t,s=t.request;let i;const c=new WeakMap,u=f=>{const h=c.get(f)||bf(f,r);return c.set(f,h),h},a=()=>i??(i=mf(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Oe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Oe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:f=>Oe(r.body$(f)),getBlockHeader:f=>Oe(r.header$(f??null)),submit:(...f)=>Ui(r,l,...f),submitAndWatch:(...f)=>Rr(r,l,...f),getTypedApi:f=>{const h=u(f);return Object.assign(Fi(h,r,l),{compatibilityToken:h})},getUnsafeApi:()=>{const f=a();return Object.assign(Fi(f,r,l),{runtimeToken:f})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}const rh=(e,t,n,r,o)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=s,u=new Uint8Array(i);return a=>{const l=Le.fromBytes(ae(u,c.enc(a)));return{encodedData:l,decodedCall:lt(e,lt(t,a)),sign:async(f,h)=>Z(await f.signTx(l.asBytes(),o(h),n,h.mortality.mortal?h.mortality.startAtBlock.height:0))}}},oh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=pe(e),r=await t(),o=et.dec(r).metadata.value,s=wr(o),i=bi(s),c=Pi(n,s,i),u=p=>o.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),f=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(m=>(v[b][m]||(v[b][m]=p(b,m)),v[b][m]))))},h=f((p,v)=>{const b=u(p)?.constants.find(m=>m.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),d=f((p,v)=>rh(p,v,r,i,c));return{constants:h,tx:d}};he.AccountId=at,he.Binary=Le,he.CompatibilityLevel=Ae,he.Enum=lt,he.FixedSizeBinary=un,he.InvalidTxError=Pr,he._Enum=Lo,he.createClient=nh,he.getOfflineApi=oh,he.getSs58AddressInfo=Hn});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function En(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=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,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=mt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var f=this.initialTeardown;if(z(f))try{f()}catch(v){s=v instanceof sr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var l=mt(d),h=l.next();!h.done;h=l.next()){var p=h.value;try{$s(p)}catch(v){s=s??[],v instanceof sr?s=Ce(Ce([],Be(s)),Be(v.errors)):s.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}if(s)throw new sr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)$s(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)&&En(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&En(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Cs=gt.EMPTY;function Os(e){return e instanceof gt||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function $s(e){z(e)?e():e.unsubscribe()}var Ou={Promise:void 0},$u={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ce([e,t],Be(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Ts(e){$u.setTimeout(function(){throw e})}function Oe(){}function kn(e){e()}var zt=function(e){Me(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Os(n)&&n.add(r)):r.destination=Ru,r}return t.create=function(n,r,o){return new wt(n,r,o)},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}(gt),Tu=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){xn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){xn(r)}else xn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){xn(n)}},e}(),wt=function(e){Me(t,e);function t(n,r,o){var s=e.call(this)||this,i;return z(n)||!n?i={next:n??void 0,error:r??void 0,complete:o??void 0}:i=n,s.destination=new Tu(i),s}return t}(zt);function xn(e){Ts(e)}function Pu(e){throw e}var Ru={closed:!0,next:Oe,error:Pu,complete:Oe},ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Xe(e){return e}function cr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ps(e)}function Ps(e){return e.length===0?Xe:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=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 o=this,s=Lu(t)?t:new wt(t,n,r);return kn(function(){var i=o,c=i.operator,u=i.source;s.add(c?c.call(s,u):u?o._subscribe(s):o._trySubscribe(s))}),s},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=Rs(n),new n(function(o,s){var i=new wt({next:function(c){try{t(c)}catch(u){s(u),i.unsubscribe()}},error:s,complete:o});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[ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Ps(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Rs(t),new t(function(r,o){var s;n.subscribe(function(i){return s=i},function(i){return o(i)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Rs(e){var t;return(t=e??Ou.Promise)!==null&&t!==void 0?t:Promise}function Uu(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Lu(e){return e&&e instanceof zt||Uu(e)&&Os(e)}function Mu(e){return z(e?.lift)}function X(e){return function(t){if(Mu(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 q(e,t,n,r,o){return new Du(e,t,n,r,o)}var Du=function(e){Me(t,e);function t(n,r,o,s,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(f){n.error(f)}}:e.prototype._next,u._error=s?function(a){try{s(a)}catch(f){n.error(f)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(zt),Vu=or(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),De=function(e){Me(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 Us(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Vu},t.prototype.next=function(n){var r=this;kn(function(){var o,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=mt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){o={error:a}}finally{try{c&&!c.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;kn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;kn(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,o=this,s=o.hasError,i=o.isStopped,c=o.observers;return s||i?Cs:(this.currentObservers=null,c.push(n),new gt(function(){r.currentObservers=null,En(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,s=r.thrownError,i=r.isStopped;o?n.error(s):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new Us(n,r)},t}(T),Us=function(e){Me(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.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,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:Cs},t}(De),Hu=function(e){Me(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,o=n.thrownError,s=n._value;if(r)throw o;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(De),ar={now:function(){return(ar.delegate||Date).now()},delegate:void 0},An=function(e){Me(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=ar);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,o=r.isStopped,s=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;o||(s.push(n),!i&&s.push(c.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,s=o._infiniteTimeWindow,i=o._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=s?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,s=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!i){for(var u=o.now(),a=0,f=1;f<s.length&&s[f]<=u;f+=2)a=f;a&&s.splice(0,a+1)}},t}(De),zu=function(e){Me(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),Ls={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ce([e,t],Be(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ju=function(e){Me(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,i=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(i,s,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),Ls.setInterval(n.flush.bind(n,this),o)},t.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&Ls.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var o=!1,s;try{this.work(n)}catch(i){o=!0,s=i||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,s=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,En(s,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(zu),Ms=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=ar.now,e}(),Fu=function(e){Me(t,e);function t(n,r){r===void 0&&(r=Ms.now);var o=e.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},t}(Ms),Ds=new Fu(ju),qu=Ds,dt=new T(function(e){return e.complete()});function Vs(e){return e&&z(e.schedule)}function ur(e){return e[e.length-1]}function lr(e){return z(ur(e))?e.pop():void 0}function jt(e){return Vs(ur(e))?e.pop():void 0}function Wu(e,t){return typeof ur(e)=="number"?e.pop():t}var Hs=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function zs(e){return z(e?.then)}function js(e){return z(e[ir])}function Fs(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function qs(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 Ku(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ws=Ku();function Ks(e){return z(e?.[Ws])}function Xs(e){return Bu(this,arguments,function(){var n,r,o,s;return Bs(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,yt(n.read())];case 3:return r=i.sent(),o=r.value,s=r.done,s?[4,yt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,yt(o)];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 Ys(e){return z(e?.getReader)}function ue(e){if(e instanceof T)return e;if(e!=null){if(js(e))return Xu(e);if(Hs(e))return Yu(e);if(zs(e))return Gu(e);if(Fs(e))return Gs(e);if(Ks(e))return Nu(e);if(Ys(e))return Qu(e)}throw qs(e)}function Xu(e){return new T(function(t){var n=e[ir]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Yu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Gu(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Ts)})}function Nu(e){return new T(function(t){var n,r;try{for(var o=mt(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Gs(e){return new T(function(t){Zu(e,t).catch(function(n){return t.error(n)})})}function Qu(e){return Gs(Xs(e))}function Zu(e,t){var n,r,o,s;return _u(this,void 0,void 0,function(){var i,c;return Bs(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Cu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),o={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ot(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var s=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!o)return s}function Ns(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(q(r,function(o){return ot(r,e,function(){return r.next(o)},t)},function(){return ot(r,e,function(){return r.complete()},t)},function(o){return ot(r,e,function(){return r.error(o)},t)}))})}function Qs(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Ju(e,t){return ue(e).pipe(Qs(t),Ns(t))}function el(e,t){return ue(e).pipe(Qs(t),Ns(t))}function tl(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function nl(e,t){return new T(function(n){var r;return ot(n,t,function(){r=e[Ws](),ot(n,t,function(){var o,s,i;try{o=r.next(),s=o.value,i=o.done}catch(c){n.error(c);return}i?n.complete():n.next(s)},0,!0)}),function(){return z(r?.return)&&r.return()}})}function Zs(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ot(n,t,function(){var r=e[Symbol.asyncIterator]();ot(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function rl(e,t){return Zs(Xs(e),t)}function ol(e,t){if(e!=null){if(js(e))return Ju(e,t);if(Hs(e))return tl(e,t);if(zs(e))return el(e,t);if(Fs(e))return Zs(e,t);if(Ks(e))return nl(e,t);if(Ys(e))return rl(e,t)}throw qs(e)}function Et(e,t){return t?ol(e,t):ue(e)}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e);return Et(e,n)}function Ft(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Js=or(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function sl(e,t){return new Promise(function(n,r){var o=!1,s;e.subscribe({next:function(i){s=i,o=!0},error:r,complete:function(){o?n(s):r(new Js)}})})}function $e(e,t){return new Promise(function(n,r){var o=new wt({next:function(s){n(s),o.unsubscribe()},error:r,complete:function(){r(new Js)}});e.subscribe(o)})}function il(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){r.next(e.call(t,s,o++))}))})}var cl=Array.isArray;function al(e,t){return cl(t)?e.apply(void 0,Ce([],Be(t))):e(t)}function ei(e){return S(function(t){return al(e,t)})}var ul=Array.isArray,ll=Object.getPrototypeOf,fl=Object.prototype,hl=Object.keys;function dl(e){if(e.length===1){var t=e[0];if(ul(t))return{args:t,keys:null};if(pl(t)){var n=hl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function pl(e){return e&&typeof e=="object"&&ll(e)===fl}function vl(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function qt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e),r=lr(e),o=dl(e),s=o.args,i=o.keys;if(s.length===0)return Et([],n);var c=new T(ti(s,n,i?function(u){return vl(i,u)}:Xe));return r?c.pipe(ei(r)):c}function ti(e,t,n){return n===void 0&&(n=Xe),function(r){ni(t,function(){for(var o=e.length,s=new Array(o),i=o,c=o,u=function(f){ni(t,function(){var d=Et(e[f],t),l=!1;d.subscribe(q(r,function(h){s[f]=h,l||(l=!0,c--),c||r.next(n(s.slice()))},function(){--i||r.complete()}))},r)},a=0;a<o;a++)u(a)},r)}}function ni(e,t,n){e?ot(n,e,t):t()}function bl(e,t,n,r,o,s,i,c){var u=[],a=0,f=0,d=!1,l=function(){d&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;ue(n(v,f++)).subscribe(q(t,function(m){t.next(m)},function(){b=!0},void 0,function(){if(b)try{a--;for(var m=function(){var g=u.shift();i||p(g)};u.length&&a<r;)m();l()}catch(g){t.error(g)}}))};return e.subscribe(q(t,h,function(){d=!0,l()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),z(t)?U(function(r,o){return S(function(s,i){return t(r,s,o,i)})(ue(e(r,o)))},n):(typeof t=="number"&&(n=t),X(function(r,o){return bl(r,o,e,n)}))}function Sn(e){return e===void 0&&(e=1/0),U(Xe,e)}function ml(){return Sn(1)}function fr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ml()(Et(e,jt(e)))}function hr(e){return new T(function(t){ue(e()).subscribe(t)})}var yl={connector:function(){return new De},resetOnDisconnect:!0};function gl(e,t){t===void 0&&(t=yl);var n=null,r=t.connector,o=t.resetOnDisconnect,s=o===void 0?!0:o,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=hr(function(){return e}).subscribe(i),s&&n.add(function(){return i=r()})),n},c}function dr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=qu);var r=-1;return t!=null&&(Vs(t)?n=t:r=t),new T(function(o){var s=il(e)?+e-n.now():e;s<0&&(s=0);var i=0;return n.schedule(function(){o.closed||(o.next(i++),0<=r?this.schedule(void 0,r):o.complete())},s)})}function pr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e),r=Wu(e,1/0),o=e;return o.length?o.length===1?ue(o[0]):Sn(r)(Et(o,n)):dt}var wl=Array.isArray;function El(e){return e.length===1&&wl(e[0])?e[0]:e}function Ee(e,t){return X(function(n,r){var o=0;n.subscribe(q(r,function(s){return e.call(t,s,o++)&&r.next(s)}))})}function kt(e){return X(function(t,n){var r=null,o=!1,s;r=t.subscribe(q(n,void 0,void 0,function(i){s=ue(e(i,kt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,s.subscribe(n))})}function kl(e,t,n,r,o){return function(s,i){var c=n,u=t,a=0;s.subscribe(q(i,function(f){var d=a++;u=c?e(u,f,d):(c=!0,f),i.next(u)},o))}}function ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=lr(e);return n?cr(ri.apply(void 0,Ce([],Be(e))),ei(n)):X(function(r,o){ti(Ce([r],Be(El(e))))(o)})}function xl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ri.apply(void 0,Ce([],Be(e)))}function oi(e,t){return z(t)?U(e,t,1):U(e,1)}function re(e){return e<=0?function(){return dt}:X(function(t,n){var r=0;t.subscribe(q(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Al(e){return S(function(){return e})}function Sl(e,t){return U(function(n,r){return ue(e(n,r)).pipe(re(1),Al(n))})}function Il(e,t){t===void 0&&(t=Ds);var n=dr(e,t);return Sl(function(){return n})}function _l(e,t){return X(function(n,r){var o=new Set;n.subscribe(q(r,function(s){var i=e?e(s):s;o.has(i)||(o.add(i),r.next(s))})),t&&ue(t).subscribe(q(r,function(){return o.clear()},Oe))})}function me(e,t){return t===void 0&&(t=Xe),e=e??Bl,X(function(n,r){var o,s=!0;n.subscribe(q(r,function(i){var c=t(i);(s||!e(o,c))&&(s=!1,o=c,r.next(i))}))})}function Bl(e,t){return e===t}function Cl(){return X(function(e,t){var n,r=!1;e.subscribe(q(t,function(o){var s=n;n=o,r&&t.next([s,o]),r=!0}))})}function vr(e,t){return X(kl(e,t,arguments.length>=2,!0))}function In(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new De}:t,r=e.resetOnError,o=r===void 0?!0:r,s=e.resetOnComplete,i=s===void 0?!0:s,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var f,d,l,h=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},m=function(){b(),f=l=void 0,p=v=!1},g=function(){var x=f;m(),x?.unsubscribe()};return X(function(x,y){h++,!v&&!p&&b();var w=l=l??n();y.add(function(){h--,h===0&&!v&&!p&&(d=br(g,u))}),w.subscribe(y),!f&&h>0&&(f=new wt({next:function(A){return w.next(A)},error:function(A){v=!0,b(),d=br(m,o,A),w.error(A)},complete:function(){p=!0,b(),d=br(m,i),w.complete()}}),ue(x).subscribe(f))})(a)}}function br(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 o=new wt({next:function(){o.unsubscribe(),e()}});return ue(t.apply(void 0,Ce([],Be(n)))).subscribe(o)}}function mr(e,t,n){var r,o,s,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):i=e??1/0,In({connector:function(){return new An(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ol(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=jt(e);return X(function(r,o){(n?fr(e,r,n):fr(e,r)).subscribe(o)})}function yr(e,t){return X(function(n,r){var o=null,s=0,i=!1,c=function(){return i&&!o&&r.complete()};n.subscribe(q(r,function(u){o?.unsubscribe();var a=0,f=s++;ue(e(u,f)).subscribe(o=q(r,function(d){return r.next(t?t(u,d,f,a++):d)},function(){o=null,c()}))},function(){i=!0,c()}))})}function $l(){return yr(Xe)}function si(e){return X(function(t,n){ue(e).subscribe(q(n,function(){return n.complete()},Oe)),!n.closed&&t.subscribe(n)})}function ii(e,t){return t===void 0&&(t=!1),X(function(n,r){var o=0;n.subscribe(q(r,function(s){var i=e(s,o++);(i||t)&&r.next(s),!i&&r.complete()}))})}function ci(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(o,s){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;o.subscribe(q(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Xe}function gr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=lr(e);return X(function(r,o){for(var s=e.length,i=new Array(s),c=e.map(function(){return!1}),u=!1,a=function(d){ue(e[d]).subscribe(q(o,function(l){i[d]=l,!u&&!c[d]&&(c[d]=!0,(u=c.every(Xe))&&(c=null))},Oe))},f=0;f<s;f++)a(f);r.subscribe(q(o,function(d){if(u){var l=Ce([d],Be(i));o.next(n?n.apply(void 0,Ce([],Be(l))):l)}}))})}var Tl=Object.defineProperty,Pl=(e,t,n)=>t in e?Tl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ai=(e,t,n)=>Pl(e,typeof t!="symbol"?t+"":t,n);class Rl{constructor(){ai(this,"first"),ai(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 Ul=()=>{const e=new Map,t=(l,h)=>{e.set(l,()=>{e.delete(l),h()})},n=l=>{e.get(l)?.()},r=new Rl,o=r.unshift.bind(r),s=r.push.bind(r),i=(l,h)=>{const p=h?o:s;t(l.source$,p(l))},c=()=>{const l=r.pop();l&&(e.delete(l.source$),u(l))},u=l=>{const{source$:h,observer:p}=l;let v=!1;const b=h.subscribe({next(m){p.next(m)},error(m){(v=m instanceof bn)?i(l,!0):p.error(m)},complete(){p.complete()}});b.closed?v||c():t(h,()=>{b.unsubscribe(),c()})},a=(l=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):i(v,l),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:l=>(...h)=>f(l(...h))}};class Wt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}class Ll extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class ui extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Ml=new Set(["best","finalized",null]),li=e=>{const t=e.pipe(kt(n=>n instanceof mn?dr(750).pipe(oi(()=>t)):Ft(()=>n)));return t},Dl=(e,t,n)=>r=>(o,...s)=>{if(!Ml.has(o))return li(r(o,...s)).pipe(n(o));const c=(o==="best"?t:e).pipe(re(1),U(u=>r(u,...s).pipe(n(u))),kt(u=>u instanceof Wt?c:Ft(()=>u)));return li(c)},fi=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Vl=e=>t=>(...n)=>e()[t](...n),hi=(e,t)=>e.pipe(ii(n=>n.blocks.has(t)),me((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let o=n.blocks.get(n.best),s=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),s=s||n.finalized===o.hash;return s?"finalized":o.hash===t?"best":null}),me(),ii(n=>n!=="finalized",!0));function Hl(e,t,n){return(r,o,...s)=>(o?cr(jl(r,t.pipe(Ee(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),zl(r,e)):c=>c)(n(r,...s))}const zl=(e,t)=>n=>hi(t,e).pipe(re(1),yr(r=>r?n:Ft(()=>new ui))),jl=(e,t)=>n=>new T(r=>{const o=t.pipe(Ee(i=>i===e)).subscribe(()=>{r.error(new Ll)}),s=n.subscribe(r);return()=>{o.unsubscribe(),s.unsubscribe()}});function _n(e,t,n){return(r,...o)=>{const s=t(r,...o);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=s.subscribe({next:l=>i.next(l),error:l=>i.error(l),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let f=!1;const d=e.subscribe({next:l=>{const h=l.blocks.get(r);h?h.recovering?c?.unsubscribe():a():f&&i.error(new Wt(r,n)),f=l.recovering},error:l=>i.error(l)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Fl=(e,t)=>{const n=(r,o,s,i)=>new T(c=>e().storageSubscription(r,o,s??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,o.slice(-u),s,!0))})).pipe(Sn(),t(i));return n},ql=e=>t=>t.pipe(oi(n=>n.type!=="initialized"?Ve(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Wl=e=>{let t=null,n=Oe;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(Yo.dec),s=gl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(ql(o),Kl()));return{getHeader:o,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Kl=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof Es?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",o),n.add(r())},complete:()=>t.complete()});return n.add(r()),n}),di=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",st={type:"void"},Xl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=f=>d=>{let l=n.get(d);if(l)return l;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=f(d);return l=n.get(d),l?Object.assign(l,h):(l={id:d,...h},n.set(d,l)),r.delete(d),l};let s=!0,i=!0;const c=o(f=>{const d=t(e[f]);if(d)return d;const{def:l,path:h,params:p}=e[f];if(l.tag==="composite"){if(l.value.length===0)return st;if(l.value.length===1){const v=c(l.value[0].type);return s&&h.at(-1)==="AccountId32"&&di(v,32)?(s=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&di(v,20)?(i=!1,{type:"AccountId20"}):v}return u(l.value)}if(l.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const m=c(p[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(h.length===1&&h[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(l.value.length===0)return st;const v={},b={};return l.value.forEach(m=>{const g=m.name;if(b[g]=m.docs,m.fields.length===0){v[g]={...st,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[g]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[g]={...u(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:v}=l.value,b=c(l.value.type);return!v||b.type==="void"?st:v>1?{type:"array",value:b,len:l.value.len}:b}if(l.tag==="tuple")return l.value.length===0?st:l.value.length>1?a(l.value.map(v=>c(v)),l.value.map(v=>e[v].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const v=c(l.value);return v.type==="void"?st:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:l.tag}}),u=f=>{let d=!0;const l={},h={};return f.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,m=c(p.type);m.type!=="void"&&(l[b]=m,h[b]=p.docs)}),d?{type:"struct",value:l,innerDocs:h}:a(Object.values(l),Object.values(h))},a=(f,d)=>{if(f.every(l=>l.id===f[0].id)&&d.every(l=>!l.length)){const[l]=f;return l.type==="void"?st:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:d}};return c},wr=e=>{const t=Xl(e.lookup,({def:o})=>{if(o.tag==="composite"){const s=n(o);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...st,idx:i.index}:{type:"lookupEntry",value:t(i.errors),idx:i.index}])),byteLength:s}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const i=t(o.value[0].type),c=t(o.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(i=>i.name==="Call")?.type??null})},Yl=(e,t,n)=>(r,o,s,...i)=>{const{id:c}=r;if(o.has(c))return o.get(c);if(s.has(c)){const a=t(()=>o.get(c),r,...i);return o.set(c,a),a}s.add(c);let u=e(r,o,s,...i);return s.delete(c),o.has(c)&&(u=n(u,o.get(c),r,...i)),o.set(c,u),u},Gl=Ut(),pi=Yl((e,t,n,r)=>{if(e.type==="primitive")return vs[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Wo;if(e.type==="compact")return e.isBig?ln:O;if(e.type==="bitSequence")return $o;const o=h=>pi(h,t,n,r),s=(h,p)=>{const v=o(h);return p?R(v,p):R(v)},i=h=>de(...h.map(o)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,b])=>[v,o(b)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Gl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ut(e.len):s(e.value,e.len);if(e.type==="sequence")return s(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return te(o(e.value));if(e.type==="result")return Jt(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return C;case"lookupEntry":return o(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return s(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),f=Object.values(e.value).map(h=>h.idx),l=f.every((h,p)=>h===p)?ge(a):ge(a,f);return e.byteLength?Nl(l,e.byteLength):l},jn,e=>e),vi=(e,t=at())=>{const n=new Map,r=o=>pi(e(o),n,new Set,t);return o=>r(o)},Nl=(e,t)=>{const n=Y(t);return H(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},bi=e=>{const{metadata:t}=e;let n=vi(e);const r=t.pallets.find(d=>d.name==="System")?.constants.find(d=>d.name==="SS58Prefix");let o;if(r)try{const d=n(r.type).dec(r.value);typeof d=="number"&&(o=d,n=vi(e,at(d)))}catch{}const s=new Map,i=(d,l)=>{let h=s.get(d);h||s.set(d,h=ds(d));const p=t.pallets.find(A=>A.name===d).storage.items.find(A=>A.name===l),v=(A,_,...P)=>({keys:h(...P),value:_,len:A,fallback:p.modifier===1?_.dec(p.fallback):void 0});if(p.type.tag==="plain")return v(0,n(p.type.value),l);const{key:b,value:m,hashers:g}=p.type.value,x=n(m),y=g.map(A=>vs[A.tag]),w=(()=>{if(y.length===1)return[[n(b),y[0]]];const A=e(b);switch(A.type){case"array":return y.map(_=>[n(A.value.id),_]);case"tuple":return A.value.map((_,P)=>[n(_.id),y[P]]);default:throw new Error("Invalid key type")}})();return v(y.length,x,l,...w)},c=d=>{switch(d.type){case"void":return C;case"lookupEntry":return n(d.value.id);case"tuple":return de(...Object.values(d.value).map(l=>n(l.id)));case"struct":return $(pt(d.value,l=>n(l.id)));case"array":return R(n(d.value.id),d.len)}},u=(d,l)=>{const h=t.pallets.find(p=>p.name===d).constants.find(p=>p.name===l);return n(h.type)},a=d=>(l,h)=>{const p=t.pallets.find(m=>m.name===l),v=e(p[d]);if(v.type!=="enum")throw null;const b=v.value[h];return{location:[p.index,b.idx],codec:c(v.value[h])}},f=(d,l)=>{const h=t.apis.find(p=>p.name===d)?.methods.find(p=>p.name===l);if(!h)throw null;return{args:de(...h.inputs.map(p=>n(p.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:f,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},Ql=Z(_e.enc(15)),mi=Y(),Zl=te(mi),Jl=R(_e).dec,ef=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(kt(f=>{if(f instanceof Wt)return r(c,u);if(f instanceof mn)return dr(750).pipe(U(()=>r(c,u)));throw f})):dt},o=r("Metadata_metadata_versions","").pipe(S(Jl)),s=r("Metadata_metadata","").pipe(S(c=>{const u=mi.dec(c);return{metadata:et.dec(u).metadata.value,metadataRaw:u}})),i=r("Metadata_metadata_at_version",Ql).pipe(S(c=>{const u=Zl.dec(c);return{metadata:et.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(kt(()=>Ve([14])),U(c=>c.includes(15)?i:s))};return n=>{const r=n(),o=new Set([r]),s=t(n).pipe(S(({metadata:c,metadataRaw:u})=>{const a=wr(c),f=bi(a),d=f.buildStorage("System","Events"),l=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(l){const p=a(l.type);if(p.type==="struct"){const v=p.value.asset_id;v.type==="option"&&(h=v.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:f,events:{key:d.keys.enc(),dec:d.value.dec},accountId:at(f.ss58Prefix)}}),mr(1)),i={at:r,runtime:s,addBlock:c=>(o.add(c),i),deleteBlocks:c=>(c.forEach(u=>{o.delete(u)}),o.size),usages:o};return s.subscribe({error(){}}),i}},Kt=In({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),yi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},gi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},wi=(e,t)=>{t.forEach(n=>{gi(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]})},tf=(e,t,n,r,o)=>{const s=pr(n,e).pipe(vr((c,u)=>{switch(u.type){case"initialized":c.recovering&&(u.finalizedBlockHashes.some(h=>c.blocks.has(h))||(c=Ei()));const[a]=u.finalizedBlockHashes.slice(-1);c.finalized=c.best=a;const f=u.finalizedBlockHashes.length-1;u.finalizedBlockHashes.forEach((l,h)=>{c.blocks.has(l)?c.blocks.get(l).recovering=!1:c.blocks.set(l,{hash:l,parent:h===0?u.parentHash:u.finalizedBlockHashes[h-1],children:new Set(h===f?[]:[u.finalizedBlockHashes[h+1]]),runtime:l,refCount:0,number:u.number+h,recovering:!1})});const d=Object.values(c.runtimes).find(l=>l.usages.has(a));return c.finalizedRuntime=d??(c.runtimes[a]=i(yi(c,a))),c;case"stop-error":for(const l of c.blocks.values())l.recovering=!0;return c.recovering=!0,c;case"newBlock":{const{parentBlockHash:l,blockHash:h}=u;if(c.blocks.has(h))c.blocks.get(h).recovering=!1;else{const p=c.blocks.get(l);p.children.add(h),u.newRuntime&&(c.runtimes[h]=i(yi(c,h)));const v={hash:h,number:p.number+1,parent:l,children:new Set,runtime:u.newRuntime?h:p.runtime,refCount:0,recovering:!1};c.blocks.set(h,v),c.runtimes[v.runtime].addBlock(h)}return c}case"bestBlockChanged":{if(c.recovering){for(const[l,h]of c.blocks)h.recovering&&(gi(c.blocks,l),o(l));c.recovering=!1}return c.best=u.bestBlockHash,c}case"finalized":{c.finalized=u.finalizedBlockHashes.slice(-1)[0];const{blocks:l}=c;l.get(c.best).number<l.get(c.finalized).number&&(c.best=c.finalized),c.finalizedRuntime=c.runtimes[l.get(c.finalized).runtime];const{prunedBlockHashes:h}=u;return wi(c,h),r(h),setTimeout(()=>{const p=[],v=[];let b=l.get(l.get(c.finalized).parent);for(;b;)p.push(b.hash),b.refCount===0&&!b.unpinned&&(v.push(b.hash),b.unpinned=!0),b=l.get(b.parent);const m=[];for(let g=p.length-1;g>=0&&(b=l.get(p[g]),!!b.unpinned);g--)m.push(b.hash);wi(c,m),r(v)},0),c}case"blockUsage":{if(!c.blocks.has(u.value.hash))return c;const l=c.blocks.get(u.value.hash);return l.refCount+=u.value.type==="hold"?1:-1,l.refCount===0&&l.number<c.blocks.get(c.finalized).number&&!l.recovering&&(l.unpinned=!0,r([l.hash])),c}}},Ei()),Ee(c=>!!c.finalizedRuntime.runtime),S(c=>({...c})),Kt),i=ef(_n(s,t,"pinned-blocks"));return s},Ei=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ki=(e,t,n,r)=>{const o=c=>si(e.pipe(Ee(({blocks:u})=>!u.has(c)))),s=(c,u,a)=>{if(a)return Ve({hash:c,found:{type:!1,validity:null}});const f=o(c);return t(c).pipe(U(d=>{const l=d.indexOf(u);return l>-1?f(r(c)).pipe(S(h=>({hash:c,found:{type:!0,index:l,events:h}}))):n(c,u).pipe(S(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},i=(c,u,a)=>s(c,u,a.has(c)).pipe(U(f=>{const{found:d}=f;return d.type||d.validity?.success===!1?Ve(f):e.pipe(o(c),U(l=>l.blocks.get(c).children),_l(),U(l=>i(l,u,a)))}));return c=>e.pipe(re(1),U(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},nf=new Uint8Array([2]),rf=(e,t)=>Z(ae(nf,pe(e),pe(t))),xi="TaggedTransactionQueue",Ai="validate_transaction",[,of]=ge({InvalidTransaction:ge({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:j,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:ge({CannotLookup:C,NoUnsignedValidator:C,Custom:j})}),sf=Zt(e=>{const t=j.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=of(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),cf=(e,t)=>(n,r)=>{const o=t(n).pipe(S(s=>{try{return s.dynamicBuilder.buildRuntimeCall(xi,Ai).value[1]}catch{return sf}}));return e(n,`${xi}_${Ai}`,rf(r,n)).pipe(gr(o),S(([s,i])=>i(s)))},af=e=>t=>new T(n=>{let r=!1;const o=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),o}),Si=(e,t=1/0)=>n=>new T(r=>{let o;const s=new Map,i=new Map,c=new Map;let u=0,a=0,f=0;const d=()=>{const l=s.get(a);if(!l){i.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;s.delete(h),f!==h&&c.set(h,[]);let p=!1,v=l.subscribe({next(b){f===h?r.next(b):c.get(h).push(b)},complete(){if(p=!0,i.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(b=>r.next(b)),c.delete(f),!i.has(f));)f++;d()},error(b){r.error(b)}});p||i.set(h,v)};return o=n.subscribe({next(l){const h=u++;s.set(h,hr(()=>e(l,h))),i.size<t&&d()},error(l){r.error(l)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(l=>l.unsubscribe()),o.unsubscribe(),s.clear(),c.clear()}}),uf=e=>t=>new T(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),o=()=>r.unsubscribe();return()=>{Promise.resolve().then(o)}}),Er=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),lf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=Wl(e),s=Vl(t),{withRecovery:i,withRecoveryFn:c}=Ul(),u=new De,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),f=E=>I=>new T(B=>{const V=a(E),J=I.subscribe(B);return J.add(V),J}),d=E=>(I,...B)=>E(I,...B).pipe(f(I)),l=(E,I)=>(B,...V)=>new T(J=>{let Pe=!1;return m.pipe(re(1)).subscribe(ye=>{const ee=ye.blocks.get(B);Pe=!!ee&&!ee.unpinned}),Pe?E(B,...V).subscribe(J):J.error(new Wt(B,I))}),h=E=>t().unpin(E).catch(I=>{if(!(I instanceof vn))throw I}),p=(E,I)=>l(d((V=>Hl(m,r,V))(_n(m,c(fi(E)),`stop-${I}`))),I),v=(E,I=!0)=>(B,...V)=>E(B,I,...V),b=new Map,m=tf(r,d(c(fi(s("call")))),u,E=>{h(E),E.forEach(I=>{b.delete(I)})},E=>{b.delete(E)}),g=d(E=>m.pipe(re(1),U(I=>I.runtimes[I.blocks.get(E).runtime].runtime))),x=E=>I=>I.pipe(Si(B=>g(E(B)).pipe(S(V=>[B,V])))),y=(E,I,B)=>{const V=b.get(E)??new Map,J=V.get(I);if(J)return J;b.set(E,V);let Pe;const ye=B.pipe(In({connector:()=>Pe=new An}),ci({complete(){V.set(I,Pe)}}),uf());return V.set(I,ye),ye},w=m.pipe(Ee(E=>!E.recovering),me((E,I)=>E.finalized===I.finalized),vr((E,I)=>{let B=I.blocks.get(I.finalized);const V=[B],J=E.at(-1);if(!J)return V;for(;B.number>J.number+1&&(B=I.blocks.get(B.parent),!!B);)V.unshift(B);return V},[]),Sn(),S(Er),Kt),A=m.pipe(me((E,I)=>E.best===I.best),S(E=>Er(E.blocks.get(E.best))),Kt),_=m.pipe(Ee(E=>!E.recovering),me((E,I)=>E.finalized===I.finalized&&E.best===I.best),vr((E,I)=>{const B=ee=>E.get(ee)||Er(I.blocks.get(ee)),V=B(I.best),J=B(I.finalized),Pe=V.number-J.number+1,ye=new Array(Pe);for(let ee=0,Nt=V.hash;ee<Pe;ee++)ye[ee]=B(Nt),Nt=ye[ee].parent;return new Map(ye.map(ee=>[ee.hash,ee]))},new Map),S(E=>[...E.values()]),Kt),P=m.pipe(me((E,I)=>E.finalizedRuntime===I.finalizedRuntime),yr(({finalizedRuntime:{runtime:E}})=>E.pipe(af(null))),Kt),D=P.pipe(S(E=>E?.lookup.metadata??null)),F=Dl(w.pipe(S(E=>E.hash)),A.pipe(S(E=>E.hash)),f),le=F(p(s("body"),"body")),W=E=>y(E,"body",le(E,!0)),fe=p(s("storage"),"storage"),Te=F((E,I,B,V,J=null,Pe)=>m.pipe(re(1),U(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),U(ye=>{const ee=V(ye),Nt=y(E,`storage-${B}-${ee}-${J??""}`,fe(E,I,B,ee,J));return Pe?y(E,`storage-${B}-${ee}-${J??""}-dec`,Nt.pipe(S(Xi=>({raw:Xi,mapped:Pe(Xi,ye)})))):Nt}))),It=Fl(t,i),Gt=F(_n(m,(E,I,B)=>It(E,I,B??null,!1),"storageQueries")),Dr=F(_n(m,E=>hr(()=>o(E)),"header")),qi=(E,I=!1)=>Te(E,I,"value",B=>B.events.key,null,(B,V)=>V.events.dec(B)).pipe(S(B=>B.mapped)),sh=p(s("call"),"call"),Wi=F((E,I,B,V)=>y(E,`call-${B}-${V}`,sh(E,I,B,V))),Vr=cf(v(Wi,!1),g),Ki=E=>y(E,"body",le(E,!1)),ih=ki(m,Ki,Vr,qi),ch=ki(m,Ki,Vr,()=>Ve()),ah=P.pipe(Ee(Boolean),re(1),U(E=>{const{enc:I}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let B;try{B=I(0)}catch{B=I(0n)}return Te(null,!1,"value",()=>B,null)}),mr(1));pr(P,_).subscribe({error(){}});let Hr=Oe,Tn=!1,zr=0;const uh=E=>{zr+=E,Tn=!0,Hr=n()};return[{follow$:r,finalized$:w,best$:A,bestBlocks$:_,runtime$:P,metadata$:D,genesis$:ah,header$:Dr,body$:W,call$:v(Wi),storage$:v(Te),storageQueries$:Gt,eventsAt$:v(qi),holdBlock:a,trackTx$:ih,trackTxWithoutEvents$:ch,validateTx$:Vr,pinnedBlocks$:m,withRuntime:x,getRuntimeContext$:F(g),unfollow:()=>{Tn!=null&&(zr--,Tn&&!zr&&(Tn=null,Hr(),Hr=Oe))}},uh]};var ff=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Bn=new Map,hf=e=>{const t=Bn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Bn.get(e);!c||c.refCount<=1?(Bn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,s=null;const i={chainHead$:c=>{o++,s||(s=c||1),r||(r=lf(e.chainHead));const[u,a]=r;if(s===o){const f=o;o=0,s=null,r=null,a(f)}return u},broadcastTx$:ff(e.transaction),destroy:n};return Bn.set(e,{client:i,refCount:1}),i};class xt{constructor(){}_runtime(t){}}class Ii{constructor(){}_compatibility(t){}}const Cn=new WeakMap,_i=new WeakMap,kr=e=>e instanceof xt?_i.get(e):Cn.get(e);var At=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(At||{});const df=R(iu),pf=R(Qn),vf=de(df,pf),bf=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Ee(i=>i!=null));let s=await $e(o);o.subscribe(i=>s=i),r(()=>s)});return Promise.all([e.metadataTypes.then(vf.dec),e.descriptors,n]).then(([[r,o],s,i])=>{const c=new Ii;return Cn.set(c,{runtime:i,getPalletEntryPoint(u,a,f){const d=s[u]?.[a]?.[f];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${f} does not exist`);return r[d]},getApiEntryPoint(u,a){const f=s.apis?.[u]?.[a];if(f==null)throw new Error(`Descriptor for API ${u}.${a} does not exist`);return r[f]},typedefNodes:o}),c})},mf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Ee(o=>o!=null));let r=await $e(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new xt;return _i.set(n,{runtime:t}),n}),xr=new WeakMap,Bi=e=>(xr.has(e.metadataRaw)||xr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),xr.get(e.metadataRaw)),St=(e,t,n)=>{const r=(i,c)=>{var u;const a=Bi(i);return(u=a.typeNodes)[c]||(u[c]=Ht(a.lookup(c)))};function o(i,c){if(i instanceof xt)return{args:Se.Identical,values:Se.Identical};const u=Cn.get(i);c||(c=u.runtime());const a=t(u),f=n(c);if(f==null)return{args:Se.Incompatible,values:Se.Incompatible};const d=u.typedefNodes,l=Bi(c);return fu(a,h=>d[h],f,h=>r(c,h),l.compat)}const s=Oi(e,i=>Ci(o(i)));return{isCompatible:Oi(e,(i,c)=>s(c)>=i),getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:e,withCompatibleRuntime:(i,c)=>u=>qt([u.pipe(i.withRuntime(c)),e]).pipe(S(([[a,f],d])=>[a,d,f])),compatibleRuntime$:(i,c)=>qt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof xt)return!0;const a=o(i,c);if(a.args===Se.Incompatible)return!1;if(a.args>Se.Partial)return!0;if(a.values===Se.Incompatible)return!1;const f=n(c);return f==null?!1:ws(f.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof xt)return!0;const a=o(i,c).values;if(a===Se.Incompatible)return!1;if(a>Se.Partial)return!0;const f=Cn.get(i),d=t(f);return ws(d.values,l=>f.typedefNodes[l],u)},getRuntimeTypedef:r}},Ci=e=>Math.min(e.args,e.values),Oi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Ii||r instanceof xt?t(...n):e.then(o=>t(...n,o))},yf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:o,getCompatibilityLevel:s})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const f=a.lookup.metadata.pallets.find(l=>l.name===e)?.constants.find(l=>l.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return i.set(a,d),d},u=a=>{if(a){const f=kr(a).runtime(),d=c(f);if(!n(a,f,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:s})},gf=In({connector:()=>new An(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Ar(e,t){return new Promise((n,r)=>{let o=null,s=!1;const i=t?()=>{o?.unsubscribe(),r(new Io)}:Oe;o=e.subscribe({next:c=>{n(c),o?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",i),r(c),s=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),s=!0}}),s||t?.addEventListener("abort",i)})}const Sr=Symbol("EMPTY_VALUE"),Ir=e=>t=>new T(n=>{let r=0,o=null,s=Sr,i=!1;const c=()=>{const a=e(s,r++);s=Sr,o=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){s!==Sr?c():(o=null,i&&n.complete())}})},u=t.subscribe({next(a){s=a,o||c()},error(a){n.error(a)},complete(){o||n.complete(),i=!0}});return()=>{o?.unsubscribe(),u.unsubscribe()}});let $i={};const wf=e=>t=>new T(n=>{let r=$i,o=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===$i?n.complete():o=e(r).subscribe(n)}});return()=>{o.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)),Ef=()=>{const e=new Hu(new De);return[e.pipe($l()),()=>ci({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new De)},complete:()=>{e.value.complete(),e.next(new De)}})]},kf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(s(n,f=>f.hash),S(([f,d,l])=>{const h=l.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(h==null||l.lookup.metadata.lookup[h].def.tag!=="variant"||l.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,l,null))throw u();return[f,d,l]}),Si(([f,d,l])=>n.eventsAt$(f.hash).pipe(S(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,l,p.event.value.value))throw u();return{meta:{phase:p.phase,block:f},payload:p.event.value.value}})))),gf);return{watch:f=>a.pipe(U(d=>f?d.filter(l=>f(l.payload)):d)),pull:()=>$e(a),filter:f=>f.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:o,isCompatible:r}},xf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:s,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...f)=>{const d=f[f.length-1],l=Xt(d),{signal:h,at:p}=l?d:{},v=p??null,b=s(n,v).pipe(U(([m,g])=>{let x;try{x=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(m,g,f))throw a();return n.call$(v,u,Z(x.args.enc(f))).pipe(S(x.value.dec),S(y=>{if(!c(m,g,y))throw a();return y}))}));return Ar(b,h)},{getCompatibilityLevel:o,isCompatible:r})},_r=S(e=>e.mapped),Af=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",l=n.runtime$.pipe(Ee(Boolean),re(1),S(({dynamicBuilder:y})=>typeof y.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Xe),mr()),h=cr(xl(l),S(([y,w])=>w(y))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=y=>new Error(`Invalid Arguments calling ${e}.${t}(${y})`),b=y=>{try{return y.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},m=(...y)=>{const w=y[y.length-1],A=w==="best",_=A||w==="finalized"?y.slice(0,-1):y;return n[A?"best$":"finalized$"].pipe(Ir(()=>g(..._,A?{at:"best"}:{})),me((P,D)=>P.raw===D.raw),_r)},g=(...y)=>{const w=y[y.length-1],A=Xt(w),{at:_}=A?w:{},P=_??null;return f?n.bestBlocks$.pipe(S(D=>P==="finalized"||!P?D.at(-1):P==="best"?D.at(0):D.find(F=>F.hash===P)),S(D=>{if(!D)throw new ui;return D.number}),me(),h,S(D=>({raw:D,mapped:D}))):d&&Number(y[0])===0?n.genesis$.pipe(S(D=>({raw:D,mapped:un.fromHex(D)}))):Et(c).pipe(U(D=>n.storage$(P,"value",F=>{const le=b(F),W=y.length===le.len?y:y.slice(0,-1);if(y!==W&&!A)throw v(y);if(!u(D,F,W))throw p();return le.keys.enc(...W)},null,(F,le)=>{const W=b(le),fe=F===null?W.fallback:W.value.dec(F);if(!a(D,le,fe))throw p();return fe})))},x=async(...y)=>{const w=y[y.length-1],A=Xt(w),{signal:_}=A?w:{};return Ar(g(...y).pipe(_r),_)};return{isCompatible:o,getCompatibilityLevel:s,getValue:x,getValues:(y,w)=>Promise.all(y.map(A=>x(...w?[...A,w]:A))),getEntries:async(...y)=>{const w=y[y.length-1],A=Xt(w),{signal:_,at:P}=A?w:{},D=P??null,F=await c,le=n.storage$(D,"descendantsValues",W=>{const fe=b(W);if(Ci(i(F,W))===Se.Incompatible)throw p();if(y.length>fe.len)throw v(y);const Te=y.length>0&&A?y.slice(0,-1):y;if(y.length===fe.len&&Te===y)throw v(y);return fe.keys.enc(...Te)},null,(W,fe)=>{const Te=b(fe),It=W.map(({key:Gt,value:Dr})=>({keyArgs:Te.keys.dec(Gt),value:Te.value.dec(Dr)}));if(It.some(({value:Gt})=>!a(F,fe,Gt)))throw p();return It}).pipe(_r);return Ar(le,_)},watchValue:m,watchEntries:(...y)=>{const w=y.at(-1),A=Xt(w);return r(e,t,A?y.slice(0,-1):y,A&&w.at==="best")}}},Sf=Bt(j.enc,e=>+!!e.signed<<7|e.version),Br=()=>new Error("Unkown signer"),If=e=>{const{extrinsic:t}=e,n=wr(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=s.Address,o=s.Signature,!r||!o)throw Br()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in o.value)))throw Br();if(r.type==="enum"){const s=r.value.Id;if(s.type==="lookupEntry"&&s.value.type==="AccountId32")return[0,[s.idx]]}else if(r.type==="AccountId32")return[0,[]];throw Br()},_f={Ed25519:0,Sr25519:1,Ecdsa:2},Bf=(e,t,n,r,o,s)=>{const[i,c]=If(e),u=ae(Sf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!s?n:new Uint8Array([_f[s],...n]),...r,o);return ae(oe.enc(u.length),u)},[On,Yt]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),Cf=e=>async t=>{let n=!0,r;for(r=0;n&&r<On.length;r++)n=On[r]===t[r];n=n&&r===On.length;const o=t.length-Yt.length;for(r=0;n&&r<Yt.length;r++)n=Yt[r]===t[o+r];return n=n&&r===Yt.length,e(n?t:ae(On,t,Yt))};function Of(e,t,n){return{publicKey:e,signTx:async(o,s,i,c,u=Mt)=>{let a;try{const p=ns(i);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const f=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=s[p];if(!v)throw new Error(`Missing ${p} signed extension`);f.push(v.value),d.push(v.additionalSigned)});const l=ae(o,...f,...d),h=await n(l.length>256?u(l):l);return Bf(a,e,h,f,o,t)},signBytes:Cf(n)}}const $f=(e,t)=>{const n=e.metadata.pallets.find(s=>s.name==="System").constants.find(s=>s.name==="Version"),r=e(n.type),o=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return o(n.value)};function Tf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Pf=Bt(Y(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Tf(e.period)-1,1),15),r=e.phase/t<<4;return Ne[0](n|r)}),[Rf]=$({tip:oe,asset:te(Y(1/0))}),Ti=new Uint8Array,Cr=Uint8Array.from([0]),Or=e=>({value:e,additionalSigned:Ti}),$r=e=>({value:Ti,additionalSigned:e}),Tr=(e,t)=>({value:e,additionalSigned:t}),Pi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:o,type:s,additionalSigned:i})=>{r[o]=[s,i].map(c=>n.buildDefinition(c)[0])}),({mortality:o,tip:s=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],f=$f(t,n),d=h=>{const[p,v]=r[h],b=c[h];try{return pt({value:p,additionalSigned:v},(m,g)=>{const x=b?.[g];return x instanceof Uint8Array?x:m(x)})}catch{return a.push(h),null}},l=pt(r,([h,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Or(h(i));case"CheckMortality":return o.mortal?Tr(Pf({period:o.period,phase:o.startAtBlock.height%o.period}),pe(o.startAtBlock.hash)):Tr(Cr,e);case"ChargeTransactionPayment":return Or(h(s));case"ChargeAssetTxPayment":return Or(Rf({tip:s,asset:u.asset}));case"CheckGenesis":return $r(e);case"CheckMetadataHash":return Tr(Cr,Cr);case"CheckSpecVersion":return $r(p(f.spec_version));case"CheckTxVersion":return $r(p(f.transaction_version));default:return d(v)}});return a.forEach(h=>{delete l[h]}),pt(l,(h,p)=>({...h,identifier:p}))}},Ri="AccountNonceApi_account_nonce",Uf={1:j.dec,2:Ne.dec,4:_e.dec,8:Ct.dec},Lf=(e,t,n)=>e(n,Ri,t).pipe(S(r=>{const o=pe(r),s=Uf[o.length];if(!s)throw new Error(`${Ri} retrieved wrong data`);return s(o)})),Mf=(e,t,n,r,o,s={})=>qt([s.nonce?Ve(s.nonce):Lf(e.call$,Z(t.publicKey),r.hash),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(re(1),U(([i,c,u])=>{const a=Pi(pe(u),c.lookup,c.dynamicBuilder),f=s.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:s.tip??0n,mortality:f.mortal?{mortal:!0,period:f.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:o});return t.signTx(n,d,c.metadataRaw,r.number)}));var Df=Object.defineProperty,Vf=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hf=(e,t,n)=>Vf(e,t+"",n);const zf=e=>Z(Mt(pe(e))),jf=(e,t)=>new T(n=>{const r=new Map;let o,s;const i=()=>{let u=o.best,a=r.get(u),f=o.blocks.get(u).number;for(;!a;){const h=o.blocks.get(u);if(!h)break;a=r.get(u=h.parent),f--}if(!a)return;const d=f<=o.blocks.get(o.finalized).number,l=a.found.type;if(l&&s?.found&&s.hash===a.hash){d&&n.complete();return}n.next(s=a.found.type?{found:l,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:l,validity:a.found.validity}),d&&(l?n.complete():a.found.validity?.success===!1&&n.error(new Pr(a.found.validity.value)))},c=t.pipe(me((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{o=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(me((n,r)=>n===r)),Ff=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>({...o.event,topics:o.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 Pr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),Hf(this,"error"),this.name="InvalidTxError",this.error=t}}const Rr=(e,t,n,r,o=!1)=>{const s=zf(n),i=(f,d)=>({type:f,txHash:s,...d}),c=e.pinnedBlocks$.pipe(re(1),S(f=>{const d=f.blocks.get(r);return d&&!d.unpinned?d.hash:f.finalized})).pipe(U(f=>e.validateTx$(f,n).pipe(Ee(d=>!d.success),S(d=>{throw new Pr(d.value)})))),u=new T(f=>{const d=e.trackTx$(n).subscribe(f);return d.add(t(n).subscribe({error(l){f.error(l)}})),d}),a=jf(u,e.pinnedBlocks$).pipe(S(f=>f.found?i("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...Ff(f.events,f.index)}):i("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return fr(o?Ve(i("signed",{})):dt,c,Ve(i("broadcasted",{})),a.pipe(wf(({found:f,type:d,...l})=>f?Ve(i("finalized",l)):dt)))},Ui=async(e,t,n,r)=>sl(Rr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const s={...o};return delete s.type,s}),qf=at().enc,Wf=new Uint8Array(64),Kf=new Uint8Array(65),Xf=e=>()=>e?Kf:Wf,[,Yf]=$({weight:$({ref_time:ln,proof_size:ln}),class:ge({Normal:C,Operational:C,Mandatory:C}),partial_fee:Kr}),Li=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:s,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const d=(y,w,A={})=>{const _=kr(y).runtime(),{dynamicBuilder:P,assetId:D,lookup:F}=_;let le;try{le=P.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(y,_,w))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let W=A;if(A.asset){if(D==null||!Zn(A.asset,Ht(F(D)),It=>u(_,It)))throw new Error("Incompatible runtime asset");W={...A,asset:P.buildDefinition(D).enc(A.asset)}}const{location:fe,codec:Te}=le;return{callData:Le.fromBytes(ae(new Uint8Array(fe),Te.enc(w))),options:W}},l=(y,w={})=>i(n,null).pipe(S(([A])=>d(A,y,w))),h=y=>y?d(y,f).callData:$e(l(f).pipe(S(w=>w.callData))),p=(y,{...w},A)=>l(f,w).pipe(U(({callData:_,options:P})=>Mf(n,y,_.asBytes(),A,w.customSignedExtensions||{},P))),v=(y,{at:w,...A}={})=>(!w||w==="finalized"?n.finalized$:w==="best"?n.best$:n.bestBlocks$.pipe(S(_=>_.find(P=>P.hash===w)))).pipe(re(1),U(_=>_?p(y,A,_).pipe(S(P=>({tx:Z(P),block:_}))):Ft(()=>new Error(`Uknown block ${w}`)))),b=(y,w)=>$e(v(y,w)).then(A=>A.tx),m=(y,w)=>$e(v(y,w)).then(({tx:A,block:_})=>Ui(n,r,A,_.hash)),g=(y,w)=>v(y,w).pipe(U(({tx:A,block:_})=>Rr(n,r,A,_.hash,!0))),x=async(y,w)=>{typeof y=="string"&&(y=y.startsWith("0x")?pe(y):qf(y));const A=y.length===20,_=Of(y,A?"Ecdsa":"Sr25519",Xf(A)),P=pe(await b(_,w)),D=Z(ae(P,_e.enc(P.length))),F=n.getRuntimeContext$(null).pipe(S(W=>{try{return W.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Yf}})),le=n.call$(null,"TransactionPaymentApi_query_info",D);return $e(qt([le,F]).pipe(S(([W,fe])=>fe(W))))};return{getPaymentInfo:x,getEstimatedFees:async(y,w)=>(await x(y,w)).partial_fee,decodedCall:{type:e,value:lt(t,f)},getEncodedData:h,sign:b,signSubmitAndWatch:g,signAndSubmit:m}},{getCompatibilityLevel:s,isCompatible:o});var Gf=Object.defineProperty,Nf=(e,t,n)=>t in e?Gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(Nf(e,typeof t!="symbol"?t+"":t,n),n),Ur=Symbol("SUSPENSE"),Qf=class extends Promise{constructor(e){super(e)}},Mi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Di=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},ke={},$n=class extends T{constructor(e,t,n=Oe){super(r=>{const o=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Oe});this.refCount++;let s;r.add(()=>{var i;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=ke,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Mi),this.promise=null))}),this.subject?(s=this.subject.subscribe(o),this.currentValue!==ke&&r.next(this.currentValue)):(this.subject=new De,s=this.subject.subscribe(o),this.subscription=null,this.subscription=new zt({next:i=>{this.promise&&i!==Ur&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=ke;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Ur&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Di),this.promise=null),this.currentValue!==ke)return this.subject.complete();if(t===ke){const i=this.subject;return this.subject=null,i.error(new Di)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==ke&&this.currentValue===ke&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,He(this,"subject",null),He(this,"subscription",null),He(this,"refCount",0),He(this,"currentValue",ke),He(this,"promise",null),He(this,"pipeState",(...r)=>{const o=super.pipe(...r);return o instanceof $n?o:new $n(o,ke)}),He(this,"getRefCount",()=>this.refCount),He(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==ke&&this.currentValue!==Ur)return this.currentValue;if(this.defaultValue!==ke)return this.defaultValue;if(this.refCount===0)throw new Mi;const r=new Qf((o,s)=>{this.promise={res:o,rej:s,p:null}});return this.promise.p=r,r}),He(this,"getDefaultValue",()=>this.defaultValue),t===ke&&delete this.getDefaultValue}};function Vi(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Zf(e,t){const n=new Jf,r=typeof t=="function"?t:()=>t,o=s=>{for(let d=s.length-1;s[d]===void 0&&d>-1;d--)s.splice(-1);const i=[s.length,...s],c=n.get(i);if(c!==void 0)return c;const u=new $n(e(...s),r(...s),()=>{n.delete(i)}),a=new T(d=>{const l=n.get(i);let h=u;return l?l!==a&&(h=l,Vi(h,a)):n.set(i,f),h.subscribe(d)});Vi(u,a);const f=a;return n.set(i,f),f};return(...s)=>o(s)}var Jf=class{constructor(){He(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let o=n.get(e[r]);o||(o=new Map,n.set(e[r],o)),n=o}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let o=0;o<e.length-1;o++)t.push(n=n.get(e[o]));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 eh(e,t){return new $n(e,t)}var Lr=(...e)=>(typeof e[0]=="function"?Zf:eh)(e[0],e.length>1?e[1]:ke);const Hi=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),o=new Map(e.map(c=>[c.key,c])),s=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=o.get(u);(!a||a.value!==c.value)&&s.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??o.get(c))}},zi=(e,t,n,r=!1)=>{try{let o=r?e:n.blocks.get(e).parent;for(;o&&!t[o];)o=n.blocks.get(o).parent;return o?t[o]:null}catch{return null}},ji=(e,t)=>n=>{const{keys:r,value:o}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:o.dec(s.value),args:r.dec(s.key)},s)},th=(e,t,n)=>{const r=Lr((c,u,a)=>{const f=ji(c,u),d=(b,m)=>{const g=hi(e,m.hash).pipe(Ee(x=>!x),re(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(U(x=>x===b?.rootHash?Ve({...b,block:m,deltas:null,prev:b.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),S(([y,w])=>[y,f(w)]),S(([y,w])=>({prev:b&&b.block.hash,rootHash:x,block:m,...Hi(b?.entries??[],y,w)})))),si(g),kt(x=>x instanceof Wt?dt:Ft(()=>x)))},l=e.pipe(me((b,m)=>b.finalized===m.finalized),Ir(({blocks:b,finalized:m})=>d(null,b.get(m))),re(1),S(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[h,p]=Ef(),v=e.pipe(me((b,m)=>b.best===m.best),gr(h),Ir(([b,m])=>{const{best:g}=b,{blocks:x}=m;let y=x[g]?null:g;if(!y)return dt;const w=zi(y,x,b);return w?d(w,b.blocks.get(y)).pipe(S(A=>(x[y]=A,m))):(y=b.finalized,d(x[m.finalized],b.blocks.get(y)).pipe(S(A=>(A.prev=null,{blocks:{[y]:A},finalized:y}))))}));return pr(l,v).pipe(p())}),o=c=>(u,a,f)=>{const d=r(u,a,f),l=ji(u,a),h=c?"finalized":"best";return qt([d.pipe(Il(0)),e.pipe(me((p,v)=>p[h]===v[h]))]).pipe(S(([p,v])=>zi(v[h],p.blocks,v,!0)),Ee(Boolean),me(),Ol(null),Cl(),gr(d),n(([[,p]])=>p.block.hash),S(([[[p,v],b],m])=>[p,v,b,l(m)]),U(([p,v,b,m])=>{if(!p)return[v];let g=v;const x=[];for(;g&&g.block.number>p.block.number;)x.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,x.length)){const{blocks:y}=b;Object.keys(y).forEach(w=>{y[w].block.number<x[0].block.number&&delete y[w]})}return p===g?x:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:Hi(p.entries,v.entries,m)}]}))},s=Lr(o(!0)),i=Lr(o(!1));return(c,u,a,f)=>{const d=f?i:s;return e.pipe(re(1),U(l=>l.runtimes[l.blocks.get(l[f?"best":"finalized"]).runtime].runtime),S(l=>l.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(re(1),U(l=>d(c,u,l)),S(({block:{hash:l,number:h,parent:p},deltas:v,entries:b},m)=>{const g=m>0?v:{deleted:[],upserted:b};return{block:{hash:l,number:h,parent:p},entries:b.map(Mr),deltas:g&&{deleted:g.deleted.map(Mr),upserted:g.upserted.map(Mr)}}}))}},Mr=e=>e.dec,Fi=(e,t,n)=>{const r={},o=v=>new Proxy(r,{get(b,m){return v(m)}}),s=v=>{const b={};return o(m=>(b[m]||(b[m]={}),o(g=>(b[m][g]||(b[m][g]=v(m,g)),b[m][g]))))},i=(v,b)=>v.lookup.metadata.pallets.find(m=>m.name===b),c=th(t.pinnedBlocks$,t.storage$,t.withRuntime),u=s((v,b)=>Af(v,b,t,c,St(e,m=>m.getPalletEntryPoint(At.Storage,v,b),m=>{const g=i(m,v)?.storage?.items.find(x=>x.name===b);return g==null?null:cu(g)}))),a=(v,b,m,g)=>{if(m==null)return null;const x=v.lookup(m);if(x.type!=="enum")throw new Error("Expected enum");if(x.value[g]==null)return null;const y=uu(x.value[g]);return{args:b==="args"?y:dn,values:b==="args"?dn:y}},f=s((v,b)=>Li(v,b,t,n,St(e,m=>m.getPalletEntryPoint(At.Tx,v,b),m=>a(m,"args",i(m,v)?.calls,b)),!0)),d=s((v,b)=>kf(v,b,t,St(e,m=>m.getPalletEntryPoint(At.Event,v,b),m=>a(m,"values",i(m,v)?.events,b)))),l=s((v,b)=>yf(v,b,St(e,m=>m.getPalletEntryPoint(At.Const,v,b),m=>{const g=i(m,v)?.constants.find(x=>x.name===b)?.type;return g==null?null:lu(g)}))),h=s((v,b)=>xf(v,b,t,St(e,m=>m.getApiEntryPoint(v,b),m=>au(m.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===b))))),p=(v,b)=>{const{lookup:m,dynamicBuilder:g}=kr(b).runtime();try{const x=g.buildDefinition(m.call).dec(v.asBytes()),y=x.type,w=x.value.type,A=x.value.value;return Li(y,w,t,n,St(e,_=>_.getPalletEntryPoint(At.Tx,y,w),_=>a(_,"args",i(_,y)?.calls,w)),!1)(A)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,b)=>b?p(v,b):e.then(m=>p(v,m)),tx:f,event:d,apis:h,constants:l}};function nh(e){const t=Iu(e),n=hf(t),r=n.chainHead$(),{getChainSpecData:o}=t,s=t.request;let i;const c=new WeakMap,u=d=>{const l=c.get(d)||bf(d,r);return c.set(d,l),l},a=()=>i??(i=mf(r)),{broadcastTx$:f}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>$e(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>$e(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:d=>$e(r.body$(d)),getBlockHeader:d=>$e(r.header$(d??null)),submit:(...d)=>Ui(r,f,...d),submitAndWatch:(...d)=>Rr(r,f,...d),getTypedApi:d=>{const l=u(d);return Object.assign(Fi(l,r,f),{compatibilityToken:l})},getUnsafeApi:()=>{const d=a();return Object.assign(Fi(d,r,f),{runtimeToken:d})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}const rh=(e,t,n,r,o)=>{let s;try{s=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=s,u=new Uint8Array(i);return a=>{const f=Le.fromBytes(ae(u,c.enc(a)));return{encodedData:f,decodedCall:lt(e,lt(t,a)),sign:async(d,l)=>Z(await d.signTx(f.asBytes(),o(l),n,l.mortality.mortal?l.mortality.startAtBlock.height:0))}}},oh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=pe(e),r=await t(),o=et.dec(r).metadata.value,s=wr(o),i=bi(s),c=Pi(n,s,i),u=p=>o.pallets.find(v=>v.name===p),a={},f=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return f(b=>(v[b]||(v[b]={}),f(m=>(v[b][m]||(v[b][m]=p(b,m)),v[b][m]))))},l=d((p,v)=>{const b=u(p)?.constants.find(m=>m.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),h=d((p,v)=>rh(p,v,r,i,c));return{constants:l,tx:h}};he.AccountId=at,he.Binary=Le,he.CompatibilityLevel=Se,he.Enum=lt,he.FixedSizeBinary=un,he.InvalidTxError=Pr,he._Enum=Lo,he.createClient=nh,he.getOfflineApi=oh,he.getSs58AddressInfo=Hn});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -192,23 +192,23 @@
192
192
  },
193
193
  "dependencies": {
194
194
  "@rx-state/core": "^0.1.4",
195
+ "@polkadot-api/cli": "0.11.3",
196
+ "@polkadot-api/known-chains": "0.7.2",
195
197
  "@polkadot-api/ink-contracts": "0.2.6",
196
- "@polkadot-api/cli": "0.11.2",
197
198
  "@polkadot-api/json-rpc-provider": "0.0.4",
198
- "@polkadot-api/known-chains": "0.7.1",
199
199
  "@polkadot-api/logs-provider": "0.0.6",
200
200
  "@polkadot-api/metadata-builders": "0.10.2",
201
201
  "@polkadot-api/metadata-compatibility": "0.1.16",
202
- "@polkadot-api/observable-client": "0.8.2",
202
+ "@polkadot-api/observable-client": "0.8.3",
203
203
  "@polkadot-api/pjs-signer": "0.6.5",
204
204
  "@polkadot-api/polkadot-sdk-compat": "2.3.2",
205
- "@polkadot-api/polkadot-signer": "0.1.6",
206
205
  "@polkadot-api/signer": "0.1.15",
206
+ "@polkadot-api/polkadot-signer": "0.1.6",
207
207
  "@polkadot-api/sm-provider": "0.1.7",
208
208
  "@polkadot-api/smoldot": "0.3.8",
209
- "@polkadot-api/substrate-client": "0.3.0",
210
209
  "@polkadot-api/substrate-bindings": "0.11.1",
211
210
  "@polkadot-api/utils": "0.1.2",
211
+ "@polkadot-api/substrate-client": "0.3.0",
212
212
  "@polkadot-api/ws-provider": "0.4.0"
213
213
  },
214
214
  "devDependencies": {