polkadot-api 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(ye,At){typeof exports=="object"&&typeof module<"u"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(ye=typeof globalThis<"u"?globalThis:ye||self,At(ye.papi={}))})(this,function(ye){"use strict";var At=Object.defineProperty,Hs=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pr=(e,t,n)=>(Hs(e,typeof t!="symbol"?t+"":t,n),n),$n={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 Fs(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|$n[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=$n[e[s]],u=$n[e[s+1]];o[t+i++]=c<<4|u}return o}var Ur=class extends Uint8Array{constructor(e){super(e),Pr(this,"i",0),Pr(this,"v"),this.v=new DataView(e)}},ke=e=>t=>e(t instanceof Ur?t:new Ur(t instanceof Uint8Array?t.buffer:typeof t=="string"?Fs(t).buffer:t)),_e=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,i=0;o<t;o++){const s=e[o];r.set(s,i),i+=s.byteLength}return r};function Yt(e,t){const n=Object.keys(e),r=n.length,o={};for(let i=0;i<r;i++){const s=n[i];o[s]=t(e[s],s)}return o}var Zt=ke,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},It=(e,t)=>n=>e(t(n)),Jt=(e,t)=>n=>t(e(n)),dt=([e,t],n,r)=>D(It(e,n),Jt(t,r));function qs(e,t){return ke(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ws(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function We(e,t,n){return D(Ws(e,n),qs(e,t))}var z=We(1,"getUint8","setUint8"),Xe=We(2,"getUint16","setUint16"),Se=We(4,"getUint32","setUint32"),Bt=We(8,"getBigUint64","setBigUint64"),Xs=We(1,"getInt8","setInt8"),Gs=We(2,"getInt16","setInt16"),Ks=We(4,"getInt32","setInt32"),Ys=We(8,"getBigInt64","setBigInt64"),Lr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Rr=e=>ke(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),i=n[e](r+8,!0);return t.i+=16,i<<64n|o}),Zs=D(Lr,Rr("getBigUint64")),Js=D(Lr,Rr("getBigInt64")),Mr=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},Dr=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}),Qs=D(Mr,Dr("getBigUint64")),Ns=D(Mr,Dr("getBigInt64")),ec=dt(z,e=>e?1:0,Boolean),tc=[z[1],Xe[1],Se[1]],nc=ke(e=>{const t=e[e.i],n=t&3;if(n<3)return tc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const i=r/8|0;let s=0n;for(let u=0;u<i;u++)o=Bt[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(Se[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(Xe[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(z[1](e))<<s|o),o}),rc=1n<<56n,oc=1<<24,ic=256,sc=4294967295n,cc=64,ac=16384,uc=1<<30,lc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<cc)return z[0](t);if(e<ac)return Xe[0](t|1);if(e<uc)return Se[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=rc;)n.push(Bt[0](r)),r>>=64n;r>=oc&&(n.push(Se[0](Number(r&sc))),r>>=32n);let o=Number(r);o>=ic&&(n.push(Xe[0](o)),o>>=16),o&&n.push(z[0](o));const i=_e(n);return i[0]=i.length-5<<2|3,i},H=D(lc,nc),fc=new TextEncoder,hc=e=>{const t=fc.encode(e);return _e([H.enc(t.length),t])},dc=new TextDecoder,pc=ke(e=>{let t=H.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,dc.decode(n)}),N=D(hc,pc),bc=()=>{},vc=new Uint8Array(0),_=D(()=>vc,bc),Vr=e=>e===void 0?t=>_e([H.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),jr=e=>ke(t=>{const n=e===void 0?H.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),G=e=>D(Vr(e),jr(e));G.enc=Vr,G.dec=jr;var zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[n[s],i])??n.map((i,s)=>[i,s])),o=i=>r.get(i);return({tag:i,value:s})=>_e([z.enc(o(i)),e[i](s)])},Hr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return ke(o=>{const i=z.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},Ce=(e,...t)=>D(zr(Yt(e,([n])=>n),...t),Hr(Yt(e,([,n])=>n),...t));Ce.enc=zr,Ce.dec=Hr;var Fr=e=>ke(t=>z[1](t)>0?e(t):void 0),qr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,_e([n,e(t)]))},te=e=>D(qr(e[0]),Fr(e[1]));te.enc=qr,te.dec=Fr;var Wr=(e,t)=>ke(n=>{const r=z[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Xr=(e,t)=>({success:n,value:r})=>_e([z[0](n?0:1),(n?e:t)(r)]),Qt=(e,t)=>D(Xr(e[0],t[0]),Wr(e[1],t[1]));Qt.dec=Wr,Qt.enc=Xr;var Gr=(...e)=>ke(t=>e.map(n=>n(t))),Kr=(...e)=>t=>_e(e.map((n,r)=>n(t[r]))),le=(...e)=>D(Kr(...e.map(([t])=>t)),Gr(...e.map(([,t])=>t)));le.enc=Kr,le.dec=Gr;var Yr=e=>{const t=Object.keys(e);return It(le.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Zr=e=>{const t=Object.keys(e);return Jt(le.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},T=e=>D(Yr(Yt(e,t=>t[0])),Zr(Yt(e,t=>t[1])));T.enc=Yr,T.dec=Zr;var Jr=(e,t)=>t>=0?n=>_e(n.map(e)):n=>_e([H.enc(n.length),_e(n.map(e))]),Qr=(e,t)=>ke(n=>{const r=t>=0?t:H.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),L=(e,t)=>D(Jr(e[0],t),Qr(e[1],t));L.enc=Jr,L.dec=Qr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function yc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Nr(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 Tn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function eo(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Pn(e){if(!Array.isArray(e))throw new Error("array expected")}function to(e,t){if(!Nr(!0,t))throw new Error(`${e}: array of strings expected`)}function mc(e,t){if(!Nr(!1,t))throw new Error(`${e}: array of numbers expected`)}function gc(...e){const t=i=>i,n=(i,s)=>c=>i(s(c)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function wc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;to("alphabet",t);const r=new Map(t.map((o,i)=>[o,i]));return{encode:o=>(Pn(o),o.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:o=>(Pn(o),o.map(i=>{Tn("alphabet.decode",i);const s=r.get(i);if(s===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function kc(e=""){return Tn("join",e),{encode:t=>(to("join.decode",t),t.join(e)),decode:t=>(Tn("join.decode",t),t.split(e))}}function no(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(Pn(e),!e.length)return[];let r=0;const o=[],i=Array.from(e,c=>{if(eo(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),s=i.length;for(;;){let c=0,u=!0;for(let a=r;a<s;a++){const f=i[a],l=t*c,h=l+f;if(!Number.isSafeInteger(h)||l/t!==c||h-f!==l)throw new Error("convertRadix: carry overflow");const d=h/n;c=h%n;const p=Math.floor(d);if(i[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 xc(e){eo(e);const t=2**8;return{encode:n=>{if(!yc(n))throw new Error("radix.encode input should be Uint8Array");return no(Array.from(n),t,e)},decode:n=>(mc("radix.decode",n),Uint8Array.from(no(n,e,t)))}}const ro=(e=>gc(xc(58),wc(e),kc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function rt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ec(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Nt(e,...t){if(!Ec(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 _t(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 Un(e,t){Nt(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) */const Sc=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),ot=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),en=(e,t)=>e<<32-t|e>>>t,oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,oo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Re=oe?e=>e:e=>oo(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=oo(e[t])}function Ac(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Me(e){return typeof e=="string"&&(e=Ac(e)),Nt(e),e}class io{clone(){return this._cloneInto()}}function Ic(e){const t=r=>e().update(Me(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Bc(e){const t=(r,o)=>e(o).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function _c(e){const t=(r,o)=>e(o).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Cc=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]);class so extends io{constructor(t,n,r={},o,i,s){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,rt(t),rt(n),rt(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!==i)throw new Error("salt must be undefined or "+i);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error("personalization must be undefined or "+s);this.buffer=new Uint8Array(t),this.buffer32=ot(this.buffer)}update(t){_t(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=Me(t);const i=t.length,s=t.byteOffset,c=t.buffer;for(let u=0;u<i;){this.pos===n&&(oe||ie(o),this.compress(o,0,!1),oe||ie(o),this.pos=0);const a=Math.min(n-this.pos,i-u),f=s+u;if(a===n&&!(f%4)&&u+a<i){const l=new Uint32Array(c,f,Math.floor((i-u)/4));oe||ie(l);for(let h=0;u+n<i;h+=o.length,u+=n)this.length+=n,this.compress(l,h,!1);oe||ie(l);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){_t(this),Un(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),oe||ie(r),this.compress(r,0,!0),oe||ie(r);const o=ot(t);this.get().forEach((i,s)=>o[s]=Re(i))}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:i,outputLen:s,pos:c}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=i,t.outputLen=s,t.buffer.set(n),t.pos=c,t}}const tn=BigInt(2**32-1),Ln=BigInt(32);function nn(e,t=!1){return t?{h:Number(e&tn),l:Number(e>>Ln&tn)}:{h:Number(e>>Ln&tn)|0,l:Number(e&tn)|0}}function co(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=nn(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Oc=(e,t)=>BigInt(e>>>0)<<Ln|BigInt(t>>>0),$c=(e,t,n)=>e>>>n,Tc=(e,t,n)=>e<<32-n|t>>>n,Pc=(e,t,n)=>e>>>n|t<<32-n,Uc=(e,t,n)=>e<<32-n|t>>>n,Lc=(e,t,n)=>e<<64-n|t>>>n-32,Rc=(e,t,n)=>e>>>n-32|t<<64-n,Mc=(e,t)=>t,Dc=(e,t)=>e,ao=(e,t,n)=>e<<n|t>>>32-n,uo=(e,t,n)=>t<<n|e>>>32-n,lo=(e,t,n)=>t<<n-32|e>>>64-n,fo=(e,t,n)=>e<<n-32|t>>>64-n;function Vc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const se={fromBig:nn,split:co,toBig:Oc,shrSH:$c,shrSL:Tc,rotrSH:Pc,rotrSL:Uc,rotrBH:Lc,rotrBL:Rc,rotr32H:Mc,rotr32L:Dc,rotlSH:ao,rotlSL:uo,rotlBH:lo,rotlBL:fo,add:Vc,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,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},q=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),x=new Uint32Array(32);function Ge(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],h=x[2*n],d=x[2*n+1],p=x[2*r],b=x[2*r+1],v=se.add3L(u,f,s);a=se.add3H(v,a,l,c),u=v|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:se.rotr32H(b,p),Dl:se.rotr32L(b,p)},{h:d,l:h}=se.add(d,h,b,p),{Bh:l,Bl:f}={Bh:l^d,Bl:f^h},{Bh:l,Bl:f}={Bh:se.rotrSH(l,f,24),Bl:se.rotrSL(l,f,24)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=h,x[2*n+1]=d,x[2*r]=p,x[2*r+1]=b}function Ke(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],h=x[2*n],d=x[2*n+1],p=x[2*r],b=x[2*r+1],v=se.add3L(u,f,s);a=se.add3H(v,a,l,c),u=v|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:se.rotrSH(b,p,16),Dl:se.rotrSL(b,p,16)},{h:d,l:h}=se.add(d,h,b,p),{Bh:l,Bl:f}={Bh:l^d,Bl:f^h},{Bh:l,Bl:f}={Bh:se.rotrBH(l,f,63),Bl:se.rotrBL(l,f,63)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=h,x[2*n+1]=d,x[2*r]=p,x[2*r+1]=b}class jc extends so{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=q[0]|0,this.v0h=q[1]|0,this.v1l=q[2]|0,this.v1h=q[3]|0,this.v2l=q[4]|0,this.v2h=q[5]|0,this.v3l=q[6]|0,this.v3h=q[7]|0,this.v4l=q[8]|0,this.v4h=q[9]|0,this.v5l=q[10]|0,this.v5h=q[11]|0,this.v6l=q[12]|0,this.v6h=q[13]|0,this.v7l=q[14]|0,this.v7h=q[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ot(Me(t.salt));this.v4l^=Re(r[0]),this.v4h^=Re(r[1]),this.v5l^=Re(r[2]),this.v5h^=Re(r[3])}if(t.personalization){const r=ot(Me(t.personalization));this.v6l^=Re(r[0]),this.v6h^=Re(r[1]),this.v7l^=Re(r[2]),this.v7h^=Re(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Me(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:c,v3h:u,v4l:a,v4h:f,v5l:l,v5h:h,v6l:d,v6h:p,v7l:b,v7h:v}=this;return[t,n,r,o,i,s,c,u,a,f,l,h,d,p,b,v]}set(t,n,r,o,i,s,c,u,a,f,l,h,d,p,b,v){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=f|0,this.v5l=l|0,this.v5h=h|0,this.v6l=d|0,this.v6h=p|0,this.v7l=b|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((u,a)=>x[a]=u),x.set(q,16);let{h:o,l:i}=se.fromBig(BigInt(this.length));x[24]=q[8]^i,x[25]=q[9]^o,r&&(x[28]=~x[28],x[29]=~x[29]);let s=0;const c=Cc;for(let u=0;u<12;u++)Ge(0,4,8,12,t,n+2*c[s++]),Ke(0,4,8,12,t,n+2*c[s++]),Ge(1,5,9,13,t,n+2*c[s++]),Ke(1,5,9,13,t,n+2*c[s++]),Ge(2,6,10,14,t,n+2*c[s++]),Ke(2,6,10,14,t,n+2*c[s++]),Ge(3,7,11,15,t,n+2*c[s++]),Ke(3,7,11,15,t,n+2*c[s++]),Ge(0,5,10,15,t,n+2*c[s++]),Ke(0,5,10,15,t,n+2*c[s++]),Ge(1,6,11,12,t,n+2*c[s++]),Ke(1,6,11,12,t,n+2*c[s++]),Ge(2,7,8,13,t,n+2*c[s++]),Ke(2,7,8,13,t,n+2*c[s++]),Ge(3,4,9,14,t,n+2*c[s++]),Ke(3,4,9,14,t,n+2*c[s++]);this.v0l^=x[0]^x[16],this.v0h^=x[1]^x[17],this.v1l^=x[2]^x[18],this.v1h^=x[3]^x[19],this.v2l^=x[4]^x[20],this.v2h^=x[5]^x[21],this.v3l^=x[6]^x[22],this.v3h^=x[7]^x[23],this.v4l^=x[8]^x[24],this.v4h^=x[9]^x[25],this.v5l^=x[10]^x[26],this.v5h^=x[11]^x[27],this.v6l^=x[12]^x[28],this.v6h^=x[13]^x[29],this.v7l^=x[14]^x[30],this.v7h^=x[15]^x[31],x.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 rn=Bc(e=>new jc(e)),ho=new TextEncoder().encode("SS58PRE"),Rn=2,Mn=e=>{try{const t=ro.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Rn),o=t.subarray(n.length+r.length),i=rn(Uint8Array.of(...ho,...n,...r),{dkLen:64}).subarray(0,Rn);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:zc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},zc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},po=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=rn(Uint8Array.of(...ho,...t,...n),{dkLen:64}).subarray(0,Rn);return ro.encode(Uint8Array.of(...t,...n,...r))}};function Hc(e,t){return n=>{const r=Mn(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 it=(e=42,t=32)=>dt(G(t),Hc(t),po(e)),bo="0123456789abcdef";function ne(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=bo[r>>4]+bo[r&15]}return t.join("")}const Dn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function me(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|Dn[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=Dn[e[s]],u=Dn[e[s+1]];o[t+i++]=c<<4|u}return o}function on(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const fe=(...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 i=e[r];n.set(i,o),o+=i.byteLength}return n},Ct=Function.prototype;class vo extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Fc=Object.defineProperty,yo=e=>{throw TypeError(e)},qc=(e,t,n)=>t in e?Fc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ot=(e,t,n)=>qc(e,typeof t!="symbol"?t+"":t,n),mo=(e,t,n)=>t.has(e)||yo("Cannot "+n),De=(e,t,n)=>(mo(e,t,"read from private field"),n?n.call(e):t.get(e)),$t=(e,t,n)=>t.has(e)?yo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(mo(e,t,"write to private field"),t.set(e,n),n),Ve,Tt,sn,cn,an;const Wc=new TextEncoder,Xc=new TextDecoder,Gc=le(H,G(1/0))[1];class je{constructor(t,n=!1){if($t(this,Ve),$t(this,Tt,null),$t(this,sn,null),$t(this,cn,null),$t(this,an,null),Ot(this,"asText",()=>De(this,an)??st(this,an,Xc.decode(De(this,Ve)))),Ot(this,"asHex",()=>De(this,sn)||st(this,sn,ne(De(this,Ve)))),Ot(this,"asOpaqueHex",()=>De(this,cn)||st(this,cn,ne(this.asBytes()))),Ot(this,"asBytes",()=>De(this,Ve)),Ot(this,"asOpaqueBytes",()=>De(this,Tt)||st(this,Tt,fe(H[0](De(this,Ve).length),De(this,Ve)))),n){try{const[r,o]=Gc(t);if(r===o.length){st(this,Ve,o),st(this,Tt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else st(this,Ve,t)}static fromText(t){return new this(Wc.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Ve=new WeakMap,Tt=new WeakMap,sn=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Kc]=it();class Vn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Kc(t))}}const go=e=>{const t=G.enc(e);return n=>t(n.asBytes())},wo=e=>{const t=G.dec(e),n=e==null?je:Vn;return r=>n.fromBytes(t(r))},Pt=e=>D(go(e),wo(e));Pt.enc=go,Pt.dec=wo;const O=H,ko=H,Yc=Zt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),xo=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Yc),Zc=dt(z,e=>e.charCodeAt(0),String.fromCharCode),Eo=e=>{const t=G.enc(e);return n=>t(me(n))},So=e=>{const t=G.dec(e);return n=>ne(t(n))},Ye=e=>D(Eo(e),So(e));Ye.enc=Eo,Ye.dec=So;const Jc=new TextEncoder,Qc=new TextDecoder,Nc=e=>dt(G(e),t=>Jc.encode(t),t=>Qc.decode(t)),Ao=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Io=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},jn=e=>D(Ao(()=>e().enc),Io(()=>e().dec)),Ut=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}}),Bo=new Proxy({},{get(e,t){return n=>Ut(t,n)}}),_o=(...e)=>{const t=Ce.enc(...e);return n=>t({tag:n.type,value:n.value})},Co=(...e)=>{const t=Ce.dec(...e);return n=>{const{tag:r,value:o}=t(n);return Ut(r,o)}},xe=(e,...t)=>D(_o(on(e,([n])=>n),...t),Co(on(e,([,n])=>n),...t));xe.enc=_o,xe.dec=Co;const Oo=[],$o=[],To=[],ea=BigInt(0),Lt=BigInt(1),ta=BigInt(2),na=BigInt(7),ra=BigInt(256),oa=BigInt(113);for(let e=0,t=Lt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Oo.push(2*(5*r+n)),$o.push((e+1)*(e+2)/2%64);let o=ea;for(let i=0;i<7;i++)t=(t<<Lt^(t>>na)*oa)%ra,t&ta&&(o^=Lt<<(Lt<<BigInt(i))-Lt);To.push(o)}const[ia,sa]=co(To,!0),Po=(e,t,n)=>n>32?lo(e,t,n):ao(e,t,n),Uo=(e,t,n)=>n>32?fo(e,t,n):uo(e,t,n);function ca(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,u=(s+2)%10,a=n[u],f=n[u+1],l=Po(a,f,1)^n[c],h=Uo(a,f,1)^n[c+1];for(let d=0;d<50;d+=10)e[s+d]^=l,e[s+d+1]^=h}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=$o[s],u=Po(o,i,c),a=Uo(o,i,c),f=Oo[s];o=e[f],i=e[f+1],e[f]=u,e[f+1]=a}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=ia[r],e[1]^=sa[r]}n.fill(0)}class zn extends io{constructor(t,n,r,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ot(this.state)}keccak(){oe||ie(this.state32),ca(this.state32,this.rounds),oe||ie(this.state32),this.posOut=0,this.pos=0}update(t){_t(this);const{blockLen:n,state:r}=this;t=Me(t);const o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let c=0;c<s;c++)r[this.pos++]^=t[i++];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&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){_t(this,!1),Nt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return rt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(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:i,enableXOF:s}=this;return t||(t=new zn(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const aa=((e,t,n)=>Ic(()=>new zn(t,e,n)))(1,136,256/8),Lo=e=>{const t=e.slice(2),n=ne(aa(t)).slice(2),r=new Array(40);for(let o=0;o<40;o++){const i=parseInt(n[o],16),s=t[o];r[o]=i>7?s.toUpperCase():s}return`0x${r.join("")}`},ua=G(20)[1],Ro=D(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=ne(t);if(e===n||e===n.toUpperCase())return t;if(Lo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Zt(e=>Lo(ne(ua(e))))),Mo=new TextEncoder,Do=new TextDecoder,la=dt(G(4),Mo.encode.bind(Mo),Do.decode.bind(Do)),Hn=T({engine:la,payload:Ye()}),fa=xe({consensus:Hn,seal:Hn,preRuntime:Hn,runtimeUpdated:_},[4,5,6,8]),Fn=Ye(32),Vo=T({parentHash:Fn,number:O,stateRoot:Fn,extrinsicRoot:Fn,digests:L(fa)}),ze=L(N),jo=te(N),ha=Ce({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),zo=L(T({name:jo,type:O,typeName:jo,docs:ze})),da=T({len:Se,type:O}),pa=T({bitStoreType:O,bitOrderType:O}),ba=L(T({name:N,fields:zo,index:z,docs:ze})),va=Ce({composite:zo,variant:ba,sequence:O,array:da,tuple:L(O),primitive:ha,compact:O,bitSequence:pa}),ya=T({name:N,type:te(O)}),ma=L(ya),ga=T({id:O,path:ze,params:ma,def:va,docs:ze}),qn=L(ga),wa=Ce({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),ka=L(wa),xa=T({hashers:ka,key:O,value:O}),Ea=T({name:N,modifier:z,type:Ce({plain:O,map:xa}),fallback:Ye(),docs:ze}),Sa=te(T({prefix:N,items:L(Ea)})),Ho={name:N,storage:Sa,calls:te(O),events:te(O),constants:L(T({name:N,type:O,value:Ye(),docs:ze})),errors:te(O),index:z},Aa={...Ho,docs:ze},Ia=new Uint8Array,Fo=e=>D(()=>Ia,()=>e),Ba=T({type:O,version:z,signedExtensions:L(T({identifier:N,type:O,additionalSigned:O}))}),qo=T({lookup:qn,pallets:L(T({...Ho,docs:Fo([])})),extrinsic:Ba,type:O,apis:Fo([])}),_a=T({name:N,methods:L(T({name:N,inputs:L(T({name:N,type:O})),output:O,docs:ze})),docs:ze}),Ca=T({version:z,address:O,call:O,signature:O,extra:O,signedExtensions:L(T({identifier:N,type:O,additionalSigned:O}))}),Wo=T({lookup:qn,pallets:L(T(Aa)),extrinsic:Ca,type:O,apis:L(_a),outerEnums:T({call:O,event:O,error:O}),custom:L(le(N,T({type:O,value:Ye()})))}),Xo=()=>{throw new Error("Unsupported metadata version!")},he=D(Xo,Xo),ct=T({magicNumber:Se,metadata:Ce({v0:he,v1:he,v2:he,v3:he,v4:he,v5:he,v6:he,v7:he,v8:he,v9:he,v10:he,v11:he,v12:he,v13:he,v14:qo,v15:Wo})}),Wn=G(),Oa=te(Wn),$a=le(H,Wn),Go=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(Oa.dec(e))}catch{}try{return ct.dec(Wn.dec(e))}catch{}try{return ct.dec($a.dec(e)[1])}catch{}throw null},Ta={dkLen:32},Rt=e=>rn(e,Ta),Pa={dkLen:16},Xn=e=>rn(e,Pa),Ko=e=>fe(Xn(e),e),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Ze(e,t,n,r,o){return e=e+t+o|0,r=en(r^e,16),n=n+r|0,t=en(t^n,12),{a:e,b:t,c:n,d:r}}function Je(e,t,n,r,o){return e=e+t+o|0,r=en(r^e,8),n=n+r|0,t=en(t^n,7),{a:e,b:t,c:n,d:r}}function Yo(e,t,n,r,o,i,s,c,u,a,f,l,h,d,p,b,v,y,w,g){let m=0;for(let k=0;k<r;k++)({a:o,b:u,c:h,d:v}=Ze(o,u,h,v,n[t+e[m++]])),{a:o,b:u,c:h,d:v}=Je(o,u,h,v,n[t+e[m++]]),{a:i,b:a,c:d,d:y}=Ze(i,a,d,y,n[t+e[m++]]),{a:i,b:a,c:d,d:y}=Je(i,a,d,y,n[t+e[m++]]),{a:s,b:f,c:p,d:w}=Ze(s,f,p,w,n[t+e[m++]]),{a:s,b:f,c:p,d:w}=Je(s,f,p,w,n[t+e[m++]]),{a:c,b:l,c:b,d:g}=Ze(c,l,b,g,n[t+e[m++]]),{a:c,b:l,c:b,d:g}=Je(c,l,b,g,n[t+e[m++]]),{a:o,b:a,c:p,d:g}=Ze(o,a,p,g,n[t+e[m++]]),{a:o,b:a,c:p,d:g}=Je(o,a,p,g,n[t+e[m++]]),{a:i,b:f,c:b,d:v}=Ze(i,f,b,v,n[t+e[m++]]),{a:i,b:f,c:b,d:v}=Je(i,f,b,v,n[t+e[m++]]),{a:s,b:l,c:h,d:y}=Ze(s,l,h,y,n[t+e[m++]]),{a:s,b:l,c:h,d:y}=Je(s,l,h,y,n[t+e[m++]]),{a:c,b:u,c:d,d:w}=Ze(c,u,d,w,n[t+e[m++]]),{a:c,b:u,c:d,d:w}=Je(c,u,d,w,n[t+e[m++]]);return{v0:o,v1:i,v2:s,v3:c,v4:u,v5:a,v6:f,v7:l,v8:h,v9:d,v10:p,v11:b,v12:v,v13:y,v14:w,v15:g}}const Zo=(()=>{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 so{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,rt(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=Me(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ot(r),oe||ie(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Gn({dkLen:32},32).update(t.context).digest();this.IV=ot(r),oe||ie(this.IV),this.flags=n|64}else this.IV=He.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Sc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:c,l:u}=nn(BigInt(t),!0),{v0:a,v1:f,v2:l,v3:h,v4:d,v5:p,v6:b,v7:v,v8:y,v9:w,v10:g,v11:m,v12:k,v13:S,v14:I,v15:C}=Yo(Zo,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],He[0],He[1],He[2],He[3],c,u,s,n);i[0]=a^y,i[1]=f^w,i[2]=l^g,i[3]=h^m,i[4]=d^k,i[5]=p^S,i[6]=b^I,i[7]=v^C}compress(t,n=0,r=!1){let o=this.flags;if(this.chunkPos||(o|=1),(this.chunkPos===15||r)&&(o|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,o,t,n),this.chunkPos+=1,this.chunkPos===16||r){let i=this.state;this.state=this.IV.slice();for(let s,c=this.chunksDone+1;(r||!(c&1))&&(s=this.stack.pop());c>>=1)this.buffer32.set(s,0),this.buffer32.set(i,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),i=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(i)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:o,chunkPos:i,posOut:s,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=i,t.chunksDone=a,t.posOut=s,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:i}=this,{h:s,l:c}=nn(BigInt(this.chunkOut++));oe||ie(o);const{v0:u,v1:a,v2:f,v3:l,v4:h,v5:d,v6:p,v7:b,v8:v,v9:y,v10:w,v11:g,v12:m,v13:k,v14:S,v15:I}=Yo(Zo,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],He[0],He[1],He[2],He[3],c,s,n,r);i[0]=u^v,i[1]=a^y,i[2]=f^w,i[3]=l^g,i[4]=h^m,i[5]=d^k,i[6]=p^S,i[7]=b^I,i[8]=t[0]^v,i[9]=t[1]^y,i[10]=t[2]^w,i[11]=t[3]^g,i[12]=t[4]^m,i[13]=t[5]^k,i[14]=t[6]^S,i[15]=t[7]^I,oe||(ie(o),ie(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,oe||ie(this.buffer32),this.compress(this.buffer32,0,!0),oe||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){_t(this,!1),Nt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=n&&this.b2CompressOut();const s=Math.min(n-this.posOut,i-o);t.set(r.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return rt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(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 Ua=_c(e=>new Gn(e)),La={dkLen:32},Jo=e=>Ua(e,La),Ra=e=>fe(Jo(e),e),Qo=e=>e,at=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Kn=2n**64n-1n,re=(e,t)=>e<<t&Kn|e>>64n-t,R=(e,t)=>e*t&Kn,K=(e,t)=>e+t&Kn,Y=11400714785074694791n,ge=14029467366897019727n,No=1609587929392839161n,Mt=9650029242287828579n,ei=2870177450012600261n;function Qe(e,t=0n){let n=K(K(t,Y),ge),r=K(t,ge),o=t,i=t-Y,s=e.length,c=0,u=null;(function(){let d=0,p=d+s;if(s){if(u=new Uint8Array(32),s<32){u.set(e.subarray(0,s),c),c+=s;return}if(d<=p-32){const b=p-32;do{let v;v=at(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=R(re(K(n,R(v,ge)),31n),Y),d+=8,v=at(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=R(re(K(r,R(v,ge)),31n),Y),d+=8,v=at(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=R(re(K(o,R(v,ge)),31n),Y),d+=8,v=at(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]),i=R(re(K(i,R(v,ge)),31n),Y),d+=8}while(d<=b)}d<p&&(u.set(e.subarray(d,p),c),c=p-d)}})(),e=u||e;let a,f=0;for(s>=32?(a=re(n,1n),a=K(a,re(r,7n)),a=K(a,re(o,12n)),a=K(a,re(i,18n)),n=R(re(R(n,ge),31n),Y),a=a^n,a=K(R(a,Y),Mt),r=R(re(R(r,ge),31n),Y),a=a^r,a=K(R(a,Y),Mt),o=R(re(R(o,ge),31n),Y),a=a^o,a=K(R(a,Y),Mt),i=R(re(R(i,ge),31n),Y),a=a^i,a=K(R(a,Y),Mt)):a=K(t,ei),a=K(a,BigInt(s));f<=c-8;){let h=at(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]);h=R(re(R(h,ge),31n),Y),a=K(R(re(a^h,27n),Y),Mt),f+=8}if(f+4<=c){let h=R(at(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),Y);a=K(R(re(a^h,23n),ge),No),f+=4}for(;f<c;){const h=R(at(e[f++],0,0,0),ei);a=R(re(a^h,11n),Y)}let l=a>>33n;return a=R(a^l,ge),l=a>>29n,a=R(a^l,No),l=a>>32n,a^=l,a}const un=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Qe(e),!0),n.setBigUint64(8,Qe(e,1n),!0),t},ti=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Qe(e),!0),n.setBigUint64(8,Qe(e,1n),!0),n.setBigUint64(16,Qe(e,2n),!0),n.setBigUint64(24,Qe(e,3n),!0),t},ni=e=>fe(Bt.enc(Qe(e)),e),ri=new TextEncoder,Ma=new Map([[Qo,0],[ni,8],[Ko,16],[Xn,-16],[Rt,-32],[un,-16],[ti,-32]]),oi=e=>{const t=un(ri.encode(e));return(n,...r)=>{const o=fe(t,un(ri.encode(n))),i=ne(o),s=a=>{if(!a.startsWith(i))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=me(a.slice(i.length)),l=new Array(r.length);for(let h=0,d=0;h<r.length;h++){const[p,b]=r[h],v=Ma.get(b);if(v==null)throw new Error("Unknown hasher");if(v<0){const y=v*-1;l[h]=ne(f.slice(d,d+y)),d+=y}else d+=v,l[h]=p.dec(f.slice(d)),d+=p.enc(l[h]).length}return l},c=r.map(([{enc:a},f])=>l=>f(a(l)));return{enc:(...a)=>ne(fe(o,...a.map((f,l)=>c[l](f)))),dec:s}}},Da=je.fromText("modlpy/utilisuba").asBytes(),Va=({threshold:e,signatories:t})=>{const n=ii(t),r=fe(Da,H.enc(n.length),...n,Xe.enc(e));return Rt(r)},ii=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const o=r>=t.length,i=r>=n.length;if(o&&i)return 0;if(o)return-1;if(i)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var si=Object.freeze({__proto__:null,AccountId:it,Bin:Pt,Binary:je,Blake2128:Xn,Blake2128Concat:Ko,Blake2256:Rt,Blake3256:Jo,Blake3256Concat:Ra,Bytes:G,Enum:Ut,FixedSizeBinary:Vn,Hex:Ye,Identity:Qo,Option:te,Result:Qt,ScaleEnum:Ce,Self:jn,Storage:oi,Struct:T,Tuple:le,Twox128:un,Twox256:ti,Twox64Concat:ni,Variant:xe,Vector:L,_Enum:Bo,_void:_,bitSequence:xo,blockHeader:Vo,bool:ec,char:Zc,compact:H,compactBn:ko,compactNumber:O,createCodec:D,createDecoder:Zt,decAnyMetadata:Go,enhanceCodec:dt,enhanceDecoder:Jt,enhanceEncoder:It,ethAccount:Ro,fixedStr:Nc,fromBufferToBase58:po,getMultisigAccountId:Va,getSs58AddressInfo:Mn,h64:Qe,i128:Js,i16:Gs,i256:Ns,i32:Ks,i64:Ys,i8:Xs,metadata:ct,selfDecoder:Io,selfEncoder:Ao,sortMultisigSignatories:ii,str:N,u128:Zs,u16:Xe,u256:Qs,u32:Se,u64:Bt,u8:z,v14:qo,v14Lookup:qn,v15:Wo});const ut=H,ja=L(le(N,ut)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},za=xe(Object.fromEntries(Object.values(M).map(e=>[e,_]))),Ha=L(le(N,te(jn(()=>Yn)))),Fa=L(ut),qa=T({typeRef:ut,length:te(ut)}),Wa=te(H),Xa=ut,Ga=T({ok:ut,ko:ut}),Yn=xe({struct:ja,terminal:za,enum:Ha,tuple:Fa,array:qa,binary:Wa,option:Xa,result:Ga}),Ka={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},Dt=e=>({type:"terminal",value:{type:e}});function Vt(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Dt(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 Dt(M.bits);case"compact":return Dt(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"?Vt(r.value,t):Vt(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 Dt(Ka[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 Dt(M.void)}}function Zn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>Zn(i,s,n),o=i=>{switch(i.value.type){case M.str:case M.big:case M.bool:case M.num:return typeof e===i.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 je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const i=e;return t.value.length!=null&&i.length<t.value.length?!1:i.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const s=e,c=Object.fromEntries(t.value);if(!(s.type in c))return!1;const u=c[s.type];return u==null?!0:r(s.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 Ya=Object.defineProperty,Za=(e,t,n)=>t in e?Ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ja=(e,t,n)=>Za(e,t+"",n);class ci{constructor(t=[]){Ja(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 Oe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Oe||{});function Jn(e,t,n,r,o){if(!n&&!e)return de(3);if(!n)return de(2);if(!e)return de(n.type==="option"?2:0);o.has(n)||o.set(n,new Map);const i=o.get(n);if(i.has(e)){const c=i.get(e);return c===null?{level:3,assumptions:new ci([[e,n]])}:de(c)}i.set(e,null);const s=Qa(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,o));return s.assumptions.delete(e,n),s.assumptions.isEmpty()||s.level===0?i.set(e,s.level):i.delete(e),s}function Qa(e,t,n){if(e.type!==t.type)return t.type==="option"?ln(n(e,t.value),2):e.type==="option"?ln(n(e.value,t),1):de(0);switch(t.type){case"terminal":return de(t.value.type===e.value.type?3:0);case"binary":return de(ui(e.value,t.value));case"array":const o=e,i=de(ui(o.value.length,t.value.length));return Qn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const f=e,l=Object.fromEntries(t.value),h=f.value.length===t.value.length?3:2;return ln(ai(f.value.map(([d,p])=>()=>d in l?n(p,l[d]):de(0))),h)}case"option":return n(e.value,t.value);case"struct":const s=e,c=Object.fromEntries(s.value),u=s.value.length===t.value.length?3:2;return ln(Qn(t.value.map(([f,l])=>()=>n(c[f],l))),u);case"tuple":{const f=e,l=de(eu(f.value,t.value));return Qn([l,...t.value.map((h,d)=>()=>n(f.value[d],h))])}case"result":const a=e;return ai([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const ln=(e,t)=>({...e,level:Math.min(e.level,t)}),Na=new ci,de=e=>({level:e,assumptions:Na}),Qn=e=>{let t=de(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},ai=e=>{if(!e.length)return de(3);let t=!1,n=de(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:de(0)},eu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,ui=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,li=xe({lookup:H,typedef:Yn}),pt=e=>({type:"lookup",value:e}),Nn=e=>({type:"typedef",value:e}),fn=Nn({type:"terminal",value:{type:M.void}}),tu=T({args:li,values:li});function nu(e){if(e.type.tag==="plain")return{args:fn,values:pt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:pt(t),values:pt(n)}}function ru(e){return{args:Nn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:pt(e.output)}}function ou(e){return e.type==="lookupEntry"?pt(e.value.id):Nn(Vt(e))}function iu(e){return{args:fn,values:pt(e)}}function su(e,t,n,r,o){const i=(s,c)=>s.type==="lookup"?c(s.value):s.value;return{args:Jn(i(e.args,t),t,i(n.args,r),r,o).level,values:Jn(i(n.values,r),r,i(e.values,t),t,o).level}}function fi(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const bt=()=>{},Ee={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},hn={chainName:"",genesisHash:"",properties:""},er={broadcast:"",stop:""};Object.entries({chainHead:Ee,chainSpec:hn,transaction:er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const cu=e=>(t,n)=>{let r=e(er.broadcast,[t],{onSuccess:o=>{r=o===null?bt:()=>{e(er.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class hi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class dn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class pn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class di extends Error{constructor(t){super(t),this.name="OperationError"}}class bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function au(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const pi=()=>{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)})}}},vn=e=>(...t)=>new Promise((n,r)=>{let o=Ct;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new vo)};s?.addEventListener("abort",c,{once:!0});const u=a=>f=>{o=Ct,s?.removeEventListener("abort",c),a(f)};o=e(u(n),u(r),...i)}),bi=(e,t)=>n=>vn((r,o,...i)=>{let s=!0,c=()=>{s=!1};const[u,a]=t(...i);return n(e,u,{onSuccess:(f,l)=>{if(f.result==="limitReached")return o(new pn);const{operationId:h}=f,d=()=>{n(Ee.stopOperation,[h])};if(!s)return d();let p=bt;const b=y=>{s=!1,p(),r(y)},v=y=>{s=!1,p(),o(y)};p=l(h,{next:y=>{const w=y;w.event==="operationError"?o(new di(w.error)):w.event==="operationInaccessible"?o(new bn):a(y,b,v)},error:v}),c=()=>{s&&(p(),d())}},onError:o}),()=>{c()}}),uu=bi(Ee.body,e=>[[e],(t,n)=>{n(t.value)}]),lu=bi(Ee.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),fu=e=>t=>new Promise((n,r)=>{e(Ee.header,[t],{onSuccess:n,onError:r})}),vi=e=>(t,n,r,o,i,s,c)=>{if(n.length===0)return s(),Ct;let u=!0,a=()=>{u=!1};return e(Ee.storage,[t,n,r],{onSuccess:(f,l)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return i(new pn);const{operationId:h}=f,d=()=>{e(Ee.stopOperation,[h])};if(!u)return d();const p=l(f.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{o(y.items);break}case"operationStorageDone":{v();break}case"operationError":{b(new di(y.error));break}case"operationInaccessible":{b(new bn);break}default:e(Ee.continue,[y.operationId])}},error:i});a=()=>{p(),e(Ee.stopOperation,[f.operationId])};const b=y=>{a=Ct,p(),i(y)},v=()=>{a=Ct,p(),s()};c(f.discardedItems)},onError:i}),()=>{a()}},hu=e=>{const t=vi(e);return vn((n,r,o,i,s,c)=>{const u=i.startsWith("descendants");let a=u?[]:null;const l=t(o,[{key:s,type:i}],c??null,u?h=>{a.push(h)}:h=>{a=h[0]?.[i]},r,()=>{try{n(u?a.flat():a)}catch(h){r(h)}},h=>{h>0&&(l(),r(new pn))});return l})},du=e=>t=>t.length>0?new Promise((n,r)=>{e(Ee.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class yn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function pu(e){return e.operationId!==void 0}function bu(e){return(t,n,r)=>{const o=pi(),i=new Set,s=au();let c=s.promise;const u=p=>{if(pu(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:b,...v}=p;return n({type:b,...v})}r(new hi),h(!1)},a=p=>{r(p),h(!(p instanceof yn))},f=(p,b)=>{const v=b(p,{next:u,error:a});h=(y=!0)=>{c=null,h=bt,v(),y&&e(Ee.unfollow,[p]),o.errorAll(new dn),i.forEach(w=>{w()}),i.clear()},c=p,s.res(p)},l=p=>{p instanceof yn?h(!1):r(p),c=null,s.res(p)};let h=e(Ee.follow,[t],{onSuccess:f,onError:l});const d=(p,b,v)=>{const y=()=>{v?.onError(new dn)};if(c===null)return y(),bt;const w=m=>{if(!v)return e(p,[m,...b]);i.add(y);const k=(I,C)=>c===null?(C.error(new dn),bt):(o.subscribe(I,C),()=>{o.unsubscribe(I)}),S=e(p,[m,...b],{onSuccess:I=>{i.delete(y),v.onSuccess(I,k)},onError:I=>{i.delete(y),v.onError(I)}});return()=>{i.delete(y),S()}};if(typeof c=="string")return w(c);let g=bt;return c.then(m=>{if(m instanceof Error)return y();c&&(g=w(m))}),()=>{g()}};return{unfollow(){h(),c=null},body:uu(d),call:lu(d),header:fu(d),storage:hu(d),storageSubscription:vi(d),unpin:du(d),_request:d}}}var vu=Object.defineProperty,yu=(e,t,n)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yi=(e,t,n)=>yu(e,typeof t!="symbol"?t+"":t,n);class mi extends Error{constructor(t){super(t.message),yi(this,"code"),yi(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let mu=1;const gu=e=>{let t=mu++;const n=new Map,r=pi();let o=null;const i=(f,l,h)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:l,params:h}))};function s(f){try{let l,h,d,p,b;if({id:l,result:h,error:d,params:p}=JSON.parse(f),l){const w=n.get(l);return w?(n.delete(l),d?w.onError(new mi(d)):w.onSuccess(h,(g,m)=>{const k=g;return r.subscribe(k,m),()=>{r.unsubscribe(k)}})):void 0}if({subscription:b,result:h,error:d}=p,!b||!d&&!Object.hasOwn(p,"result"))throw 0;const y=b;d?r.error(y,new mi(d)):r.next(y,h)}catch(l){console.warn("Error parsing incomming message: "+f),console.error(l)}}o=e(s);const c=()=>{o?.disconnect(),o=null,r.errorAll(new yn),n.forEach(f=>f.onError(new yn)),n.clear()};let u=1;return{request:(f,l,h)=>{if(!o)throw new Error("Not connected");const d=`${t}-${u++}`;return h&&n.set(d,h),i(d,f,l),()=>{n.delete(d)}},disconnect:c}},wu=e=>{const t=vn((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(hn.chainName,[]),t(hn.genesisHash,[]),t(hn.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},mn=new Map,ku=e=>{const t=mn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=gu(e),o=()=>{const s=mn.get(e);!s||s.refCount<=1?(mn.delete(e),r()):s.refCount--},i={chainHead:bu(n),transaction:cu(n),getChainSpecData:wu(n),destroy:o,request:vn((s,c,u,a)=>n(u,a,{onSuccess:s,onError:c})),_request:n};return mn.set(e,{client:i,refCount:1}),i};var tr=function(e,t){return tr=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])},tr(e,t)};function $e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");tr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function xu(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function c(f){try{a(r.next(f))}catch(l){s(l)}}function u(f){try{a(r.throw(f))}catch(l){s(l)}}function a(f){f.done?i(f.value):o(f.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function gi(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(f){return u([a,f])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(n=0)),n;)try{if(r=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=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(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(f){a=[6,f],o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function vt(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 Ne(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function et(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function yt(e){return this instanceof yt?(this.v=e,this):new yt(e)}function Eu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(d){return function(p){return Promise.resolve(p).then(d,l)}}function c(d,p){r[d]&&(o[d]=function(b){return new Promise(function(v,y){i.push([d,b,v,y])>1||u(d,b)})},p&&(o[d]=p(o[d])))}function u(d,p){try{a(r[d](p))}catch(b){h(i[0][3],b)}}function a(d){d.value instanceof yt?Promise.resolve(d.value.v).then(f,l):h(i[0][2],d)}function f(d){u("next",d)}function l(d){u("throw",d)}function h(d,p){d(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Su(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 vt=="function"?vt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(c,u){s=e[i](s),o(c,u,s.done,s.value)})}}function o(i,s,c,u){Promise.resolve(u).then(function(a){i({value:a,done:c})},s)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function nr(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 rr=nr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
- `+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function gn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var mt=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,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=vt(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(b){t={error:b}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else s.remove(this);var f=this.initialTeardown;if(V(f))try{f()}catch(b){i=b instanceof rr?b.errors:[b]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var h=vt(l),d=h.next();!d.done;d=h.next()){var p=d.value;try{xi(p)}catch(b){i=i??[],b instanceof rr?i=et(et([],Ne(i)),Ne(b.errors)):i.push(b)}}}catch(b){r={error:b}}finally{try{d&&!d.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}}if(i)throw new rr(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)xi(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)&&gn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&gn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),wi=mt.EMPTY;function ki(e){return e instanceof mt||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function xi(e){V(e)?e():e.unsubscribe()}var Ei={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Au={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,et([e,t],Ne(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Si(e){Au.setTimeout(function(){throw e})}function Ae(){}function wn(e){e()}var jt=function(e){$e(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ki(n)&&n.add(r)):r.destination=Cu,r}return t.create=function(n,r,o){return new gt(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}(mt),Iu=Function.prototype.bind;function or(e,t){return Iu.call(e,t)}var Bu=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){kn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){kn(r)}else kn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){kn(n)}},e}(),gt=function(e){$e(t,e);function t(n,r,o){var i=e.call(this)||this,s;if(V(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var c;i&&Ei.useDeprecatedNextContext?(c=Object.create(n),c.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&or(n.next,c),error:n.error&&or(n.error,c),complete:n.complete&&or(n.complete,c)}):s=n}return i.destination=new Bu(s),i}return t}(jt);function kn(e){Si(e)}function _u(e){throw e}var Cu={closed:!0,next:Ae,error:_u,complete:Ae},ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fe(e){return e}function Ai(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ii(e)}function Ii(e){return e.length===0?Fe:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var $=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=$u(t)?t:new gt(t,n,r);return wn(function(){var s=o,c=s.operator,u=s.source;i.add(c?c.call(i,u):u?o._subscribe(i):o._trySubscribe(i))}),i},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=Bi(n),new n(function(o,i){var s=new gt({next:function(c){try{t(c)}catch(u){i(u),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},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 Ii(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Bi(t),new t(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},e.create=function(t){return new e(t)},e}();function Bi(e){var t;return(t=e??Ei.Promise)!==null&&t!==void 0?t:Promise}function Ou(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function $u(e){return e&&e instanceof jt||Ou(e)&&ki(e)}function Tu(e){return V(e?.lift)}function Z(e){return function(t){if(Tu(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 F(e,t,n,r,o){return new Pu(e,t,n,r,o)}var Pu=function(e){$e(t,e);function t(n,r,o,i,s,c){var u=e.call(this,n)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(f){n.error(f)}}:e.prototype._next,u._error=i?function(a){try{i(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}(jt),Uu=nr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Te=function(e){$e(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 _i(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Uu},t.prototype.next=function(n){var r=this;wn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=vt(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(n)}}catch(a){o={error:a}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;wn(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;wn(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,i=o.hasError,s=o.isStopped,c=o.observers;return i||s?wi:(this.currentObservers=null,c.push(n),new mt(function(){r.currentObservers=null,gn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},t.prototype.asObservable=function(){var n=new $;return n.source=this,n},t.create=function(n,r){return new _i(n,r)},t}($),_i=function(e){$e(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:wi},t}(Te),Lu=function(e){$e(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,i=n._value;if(r)throw o;return this._throwIfClosed(),i},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Te),sr={now:function(){return(sr.delegate||Date).now()},delegate:void 0},xn=function(e){$e(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=sr);var i=e.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return t.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;o||(i.push(n),!s&&i.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,i=o._infiniteTimeWindow,s=o._buffer,c=s.slice(),u=0;u<c.length&&!n.closed;u+=i?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,c=(s?1:2)*r;if(r<1/0&&c<i.length&&i.splice(0,i.length-c),!s){for(var u=o.now(),a=0,f=1;f<i.length&&i[f]<=u;f+=2)a=f;a&&i.splice(0,a+1)}},t}(Te),Ru=function(e){$e(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(mt),Ci={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,et([e,t],Ne(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Mu=function(e){$e(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 i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),Ci.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&&Ci.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,i;try{this.work(n)}catch(s){o=!0,i=s||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,i=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,gn(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Ru),Oi=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=sr.now,e}(),Du=function(e){$e(t,e);function t(n,r){r===void 0&&(r=Oi.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}(Oi),$i=new Du(Mu),Vu=$i,lt=new $(function(e){return e.complete()});function Ti(e){return e&&V(e.schedule)}function cr(e){return e[e.length-1]}function Pi(e){return V(cr(e))?e.pop():void 0}function zt(e){return Ti(cr(e))?e.pop():void 0}function ju(e,t){return typeof cr(e)=="number"?e.pop():t}var Ui=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Li(e){return V(e?.then)}function Ri(e){return V(e[ir])}function Mi(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function Di(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 zu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Vi=zu();function ji(e){return V(e?.[Vi])}function zi(e){return Eu(this,arguments,function(){var n,r,o,i;return gi(this,function(s){switch(s.label){case 0:n=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,yt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,yt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,yt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Hi(e){return V(e?.getReader)}function ce(e){if(e instanceof $)return e;if(e!=null){if(Ri(e))return Hu(e);if(Ui(e))return Fu(e);if(Li(e))return qu(e);if(Mi(e))return Fi(e);if(ji(e))return Wu(e);if(Hi(e))return Xu(e)}throw Di(e)}function Hu(e){return new $(function(t){var n=e[ir]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Fu(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function qu(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Si)})}function Wu(e){return new $(function(t){var n,r;try{for(var o=vt(e),i=o.next();!i.done;i=o.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(c){n={error:c}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Fi(e){return new $(function(t){Gu(e,t).catch(function(n){return t.error(n)})})}function Xu(e){return Fi(zi(e))}function Gu(e,t){var n,r,o,i;return xu(this,void 0,void 0,function(){var s,c;return gi(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Su(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(s=r.value,t.next(s),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&&(i=n.return)?[4,i.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 tt(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(i),!o)return i}function qi(e,t){return t===void 0&&(t=0),Z(function(n,r){n.subscribe(F(r,function(o){return tt(r,e,function(){return r.next(o)},t)},function(){return tt(r,e,function(){return r.complete()},t)},function(o){return tt(r,e,function(){return r.error(o)},t)}))})}function Wi(e,t){return t===void 0&&(t=0),Z(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Ku(e,t){return ce(e).pipe(Wi(t),qi(t))}function Yu(e,t){return ce(e).pipe(Wi(t),qi(t))}function Zu(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ju(e,t){return new $(function(n){var r;return tt(n,t,function(){r=e[Vi](),tt(n,t,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(c){n.error(c);return}s?n.complete():n.next(i)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function Xi(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(function(n){tt(n,t,function(){var r=e[Symbol.asyncIterator]();tt(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Qu(e,t){return Xi(zi(e),t)}function Nu(e,t){if(e!=null){if(Ri(e))return Ku(e,t);if(Ui(e))return Zu(e,t);if(Li(e))return Yu(e,t);if(Mi(e))return Xi(e,t);if(ji(e))return Ju(e,t);if(Hi(e))return Qu(e,t)}throw Di(e)}function wt(e,t){return t?Nu(e,t):ce(e)}function ee(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e);return wt(e,n)}function Ht(e,t){var n=V(e)?e:function(){return e},r=function(o){return o.error(n())};return new $(r)}var Gi=nr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function el(e,t){return new Promise(function(n,r){var o=!1,i;e.subscribe({next:function(s){i=s,o=!0},error:r,complete:function(){o?n(i):r(new Gi)}})})}function Ie(e,t){return new Promise(function(n,r){var o=new gt({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new Gi)}});e.subscribe(o)})}function tl(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Z(function(n,r){var o=0;n.subscribe(F(r,function(i){r.next(e.call(t,i,o++))}))})}var nl=Array.isArray;function rl(e,t){return nl(t)?e.apply(void 0,et([],Ne(t))):e(t)}function ol(e){return A(function(t){return rl(e,t)})}var il=Array.isArray,sl=Object.getPrototypeOf,cl=Object.prototype,al=Object.keys;function ul(e){if(e.length===1){var t=e[0];if(il(t))return{args:t,keys:null};if(ll(t)){var n=al(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function ll(e){return e&&typeof e=="object"&&sl(e)===cl}function fl(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e),r=Pi(e),o=ul(e),i=o.args,s=o.keys;if(i.length===0)return wt([],n);var c=new $(hl(i,n,s?function(u){return fl(s,u)}:Fe));return r?c.pipe(ol(r)):c}function hl(e,t,n){return n===void 0&&(n=Fe),function(r){Ki(t,function(){for(var o=e.length,i=new Array(o),s=o,c=o,u=function(f){Ki(t,function(){var l=wt(e[f],t),h=!1;l.subscribe(F(r,function(d){i[f]=d,h||(h=!0,c--),c||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},a=0;a<o;a++)u(a)},r)}}function Ki(e,t,n){e?tt(n,e,t):t()}function dl(e,t,n,r,o,i,s,c){var u=[],a=0,f=0,l=!1,h=function(){l&&!u.length&&!a&&t.complete()},d=function(b){return a<r?p(b):u.push(b)},p=function(b){a++;var v=!1;ce(n(b,f++)).subscribe(F(t,function(y){t.next(y)},function(){v=!0},void 0,function(){if(v)try{a--;for(var y=function(){var w=u.shift();s||p(w)};u.length&&a<r;)y();h()}catch(w){t.error(w)}}))};return e.subscribe(F(t,d,function(){l=!0,h()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),V(t)?U(function(r,o){return A(function(i,s){return t(r,i,o,s)})(ce(e(r,o)))},n):(typeof t=="number"&&(n=t),Z(function(r,o){return dl(r,o,e,n)}))}function ar(e){return e===void 0&&(e=1/0),U(Fe,e)}function pl(){return ar(1)}function ur(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pl()(wt(e,zt(e)))}function lr(e){return new $(function(t){ce(e()).subscribe(t)})}var bl={connector:function(){return new Te},resetOnDisconnect:!0};function vl(e,t){t===void 0&&(t=bl);var n=null,r=t.connector,o=t.resetOnDisconnect,i=o===void 0?!0:o,s=r(),c=new $(function(u){return s.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=lr(function(){return e}).subscribe(s),i&&n.add(function(){return s=r()})),n},c}function fr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Vu);var r=-1;return t!=null&&(Ti(t)?n=t:r=t),new $(function(o){var i=tl(e)?+e-n.now():e;i<0&&(i=0);var s=0;return n.schedule(function(){o.closed||(o.next(s++),0<=r?this.schedule(void 0,r):o.complete())},i)})}function hr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e),r=ju(e,1/0),o=e;return o.length?o.length===1?ce(o[0]):ar(r)(wt(o,n)):lt}function Pe(e,t){return Z(function(n,r){var o=0;n.subscribe(F(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function kt(e){return Z(function(t,n){var r=null,o=!1,i;r=t.subscribe(F(n,void 0,void 0,function(s){i=ce(e(s,kt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function yl(e,t,n,r,o){return function(i,s){var c=n,u=t,a=0;i.subscribe(F(s,function(f){var l=a++;u=c?e(u,f,l):(c=!0,f),s.next(u)},o))}}function Yi(e,t){return V(t)?U(e,t,1):U(e,1)}function ae(e){return e<=0?function(){return lt}:Z(function(t,n){var r=0;t.subscribe(F(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function ml(e){return A(function(){return e})}function gl(e,t){return U(function(n,r){return ce(e(n,r)).pipe(ae(1),ml(n))})}function wl(e,t){t===void 0&&(t=$i);var n=fr(e,t);return gl(function(){return n})}function kl(e,t){return Z(function(n,r){var o=new Set;n.subscribe(F(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&ce(t).subscribe(F(r,function(){return o.clear()},Ae))})}function pe(e,t){return t===void 0&&(t=Fe),e=e??xl,Z(function(n,r){var o,i=!0;n.subscribe(F(r,function(s){var c=t(s);(i||!e(o,c))&&(i=!1,o=c,r.next(s))}))})}function xl(e,t){return e===t}function El(){return Z(function(e,t){var n,r=!1;e.subscribe(F(t,function(o){var i=n;n=o,r&&t.next([i,o]),r=!0}))})}function Zi(e,t){return Z(yl(e,t,arguments.length>=2,!0))}function En(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Te}:t,r=e.resetOnError,o=r===void 0?!0:r,i=e.resetOnComplete,s=i===void 0?!0:i,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var f,l,h,d=0,p=!1,b=!1,v=function(){l?.unsubscribe(),l=void 0},y=function(){v(),f=h=void 0,p=b=!1},w=function(){var g=f;y(),g?.unsubscribe()};return Z(function(g,m){d++,!b&&!p&&v();var k=h=h??n();m.add(function(){d--,d===0&&!b&&!p&&(l=dr(w,u))}),k.subscribe(m),!f&&d>0&&(f=new gt({next:function(S){return k.next(S)},error:function(S){b=!0,v(),l=dr(y,o,S),k.error(S)},complete:function(){p=!0,v(),l=dr(y,s),k.complete()}}),ce(g).subscribe(f))})(a)}}function dr(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 gt({next:function(){o.unsubscribe(),e()}});return ce(t.apply(void 0,et([],Ne(n)))).subscribe(o)}}function Ji(e,t,n){var r,o,i,s,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,s=r===void 0?1/0:r,o=e.windowTime,t=o===void 0?1/0:o,i=e.refCount,c=i===void 0?!1:i,n=e.scheduler):s=e??1/0,En({connector:function(){return new xn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Sl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zt(e);return Z(function(r,o){(n?ur(e,r,n):ur(e,r)).subscribe(o)})}function pr(e,t){return Z(function(n,r){var o=null,i=0,s=!1,c=function(){return s&&!o&&r.complete()};n.subscribe(F(r,function(u){o?.unsubscribe();var a=0,f=i++;ce(e(u,f)).subscribe(o=F(r,function(l){return r.next(t?t(u,l,f,a++):l)},function(){o=null,c()}))},function(){s=!0,c()}))})}function Al(){return pr(Fe)}function Qi(e){return Z(function(t,n){ce(e).subscribe(F(n,function(){return n.complete()},Ae)),!n.closed&&t.subscribe(n)})}function Ni(e,t){return t===void 0&&(t=!1),Z(function(n,r){var o=0;n.subscribe(F(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function es(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?Z(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;o.subscribe(F(i,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),i.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),i.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),i.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)}))}):Fe}function Sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Pi(e);return Z(function(r,o){for(var i=e.length,s=new Array(i),c=e.map(function(){return!1}),u=!1,a=function(l){ce(e[l]).subscribe(F(o,function(h){s[l]=h,!u&&!c[l]&&(c[l]=!0,(u=c.every(Fe))&&(c=null))},Ae))},f=0;f<i;f++)a(f);r.subscribe(F(o,function(l){if(u){var h=et([l],Ne(s));o.next(n?n.apply(void 0,et([],Ne(h))):h)}}))})}var Il=Object.defineProperty,Bl=(e,t,n)=>t in e?Il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t,n)=>Bl(e,typeof t!="symbol"?t+"":t,n);class _l{constructor(){ts(this,"first"),ts(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 Cl=()=>{const e=new Map,t=(h,d)=>{e.set(h,()=>{e.delete(h),d()})},n=h=>{e.get(h)?.()},r=new _l,o=r.unshift.bind(r),i=r.push.bind(r),s=(h,d)=>{const p=d?o:i;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 b=!1;const v=d.subscribe({next(y){p.next(y)},error(y){(b=y instanceof pn)?s(h,!0):p.error(y)},complete(){p.complete()}});v.closed?b||c():t(d,()=>{v.unsubscribe(),c()})},a=(h=!1)=>d=>new $(p=>{const b={observer:p,source$:d};return r.isEmpty()?u(b):s(b,h),()=>{n(d)}}),f=a();return{withRecovery:a,withRecoveryFn:h=>(...d)=>f(h(...d))}};class qt extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Ol extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class ns extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const $l=new Set(["best","finalized",null]),rs=e=>{const t=e.pipe(kt(n=>n instanceof bn?fr(750).pipe(Yi(()=>t)):Ht(()=>n)));return t},Tl=(e,t,n)=>r=>(o,...i)=>{if(!$l.has(o))return rs(r(o,...i)).pipe(n(o));const c=(o==="best"?t:e).pipe(ae(1),U(u=>r(u,...i).pipe(n(u))),kt(u=>u instanceof qt?c:Ht(()=>u)));return rs(c)},os=e=>(...t)=>new $(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}}),Pl=e=>t=>(...n)=>e()[t](...n),is=(e,t)=>e.pipe(Ni(n=>n.blocks.has(t)),pe((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(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),i=n.finalized===o.hash;for(;o.number>r;)o=n.blocks.get(o.parent),i=i||n.finalized===o.hash;return i?"finalized":o.hash===t?"best":null}),pe(),Ni(n=>n!=="finalized",!0));function Ul(e,t,n){return(r,o,...i)=>(o?Ai(Rl(r,t.pipe(Pe(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),Ll(r,e)):c=>c)(n(r,...i))}const Ll=(e,t)=>n=>is(t,e).pipe(ae(1),pr(r=>r?n:Ht(()=>new ns))),Rl=(e,t)=>n=>new $(r=>{const o=t.pipe(Pe(s=>s===e)).subscribe(()=>{r.error(new Ol)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function An(e,t){return(n,...r)=>{const o=t(n,...r);return new $(i=>{let s=null,c=!1;const u=()=>{c||(c=!0,s=o.subscribe({next:l=>i.next(l),error:l=>i.error(l),complete:()=>i.complete()}),s.add(()=>{c=!1,s=null}))};let a=!1;const f=e.subscribe({next:l=>{const h=l.blocks.get(n);h?h.recovering?s?.unsubscribe():u():a&&i.error(new qt),a=l.recovering},error:l=>i.error(l)});return()=>{f.unsubscribe(),s?.unsubscribe()}})}}const Ml=(e,t)=>{const n=(r,o,i,s)=>new $(c=>e().storageSubscription(r,o,i??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,o.slice(-u),i,!0))})).pipe(ar(),t(s));return n},Dl=e=>t=>t.pipe(Yi(n=>n.type!=="initialized"?ee(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Vl=e=>{let t=null,n=Ae;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(Vo.dec),i=vl(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Dl(o),jl()));return{getHeader:o,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},jl=()=>e=>new $(t=>{const n=new mt,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof hi?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n}),ss=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",nt={type:"void"},zl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=f=>l=>{let h=n.get(l);if(h)return h;if(r.has(l)){const p={id:l};return n.set(l,p),p}r.add(l);const d=f(l);return h=n.get(l),h?Object.assign(h,d):(h={id:l,...d},n.set(l,h)),r.delete(l),h};let i=!0,s=!0;const c=o(f=>{const l=t(e[f]);if(l)return l;const{def:h,path:d,params:p}=e[f];if(h.tag==="composite"){if(h.value.length===0)return nt;if(h.value.length===1){const b=c(h.value[0].type);return i&&d.at(-1)==="AccountId32"&&ss(b,32)?(i=!1,{type:"AccountId32"}):s&&d.at(-1)==="AccountId20"&&ss(b,20)?(s=!1,{type:"AccountId20"}):b}return u(h.value)}if(h.tag==="variant"){if(d.length===1&&d[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}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 nt;const b={},v={};return h.value.forEach(y=>{const w=y.name;if(v[w]=y.docs,y.fields.length===0){b[w]={...nt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){b[w]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}b[w]={...u(y.fields),idx:y.index}}),{type:"enum",value:b,innerDocs:v}}if(h.tag==="sequence")return{type:"sequence",value:c(h.value)};if(h.tag==="array"){const{len:b}=h.value,v=c(h.value.type);return!b||v.type==="void"?nt:b>1?{type:"array",value:v,len:h.value.len}:v}if(h.tag==="tuple")return h.value.length===0?nt:h.value.length>1?a(h.value.map(b=>c(b)),h.value.map(b=>e[b].docs)):c(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const b=c(h.value);return b.type==="void"?nt:{type:"compact",isBig:Number(b.value.slice(1))>32,size:b.value}}return{type:h.tag}}),u=f=>{let l=!0;const h={},d={};return f.forEach((p,b)=>{l=l&&!!p.name;const v=p.name||b,y=c(p.type);y.type!=="void"&&(h[v]=y,d[v]=p.docs)}),l?{type:"struct",value:h,innerDocs:d}:a(Object.values(h),Object.values(d))},a=(f,l)=>{if(f.every(h=>h.id===f[0].id)&&l.every(h=>!h.length)){const[h]=f;return h.type==="void"?nt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:l}};return c},cs=e=>{const t=zl(e.lookup,({def:o})=>{if(o.tag==="composite"){const i=n(o);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...nt,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const s=t(o.value[0].type),c=t(o.value[1].type);return s.type==="primitive"&&s.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(s=>s.name==="Call")?.type??null})},Hl=(e,t,n)=>(r,o,i,...s)=>{const{id:c}=r;if(o.has(c))return o.get(c);if(i.has(c)){const a=t(()=>o.get(c),r,...s);return o.set(c,a),a}i.add(c);let u=e(r,o,i,...s);return i.delete(c),o.has(c)&&(u=n(u,o.get(c),r,...s)),o.set(c,u),u},Fl=Pt(),ql=D(H[0],Jt(H[1],BigInt)),as=Hl((e,t,n,r)=>{if(e.type==="primitive")return si[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Ro;if(e.type==="compact")return e.isBig?ql:H;if(e.type==="bitSequence")return xo;const o=d=>as(d,t,n,r),i=(d,p)=>{const b=o(d);return p?L(b,p):L(b)},s=d=>le(...d.map(o)),c=d=>{const p=Object.fromEntries(Object.entries(d).map(([b,v])=>[b,o(v)]));return T(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Fl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Pt(e.len):i(e.value,e.len);if(e.type==="sequence")return i(e.value);if(e.type==="tuple")return s(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return te(o(e.value));if(e.type==="result")return Qt(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(d=>{switch(d.type){case"void":return _;case"lookupEntry":return o(d.value);case"tuple":return s(d.value);case"struct":return c(d.value);case"array":return i(d.value,d.len)}}),a=Object.fromEntries(Object.keys(e.value).map((d,p)=>[d,u[p]])),f=Object.values(e.value).map(d=>d.idx),h=f.every((d,p)=>d===p)?xe(a):xe(a,f);return e.byteLength?Wl(h,e.byteLength):h},jn,e=>e),us=(e,t=it())=>{const n=new Map,r=o=>as(e(o),n,new Set,t);return o=>r(o)},Wl=(e,t)=>{const n=G(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},ls=e=>{const{metadata:t}=e;let n=us(e);const r=t.pallets.find(l=>l.name==="System")?.constants.find(l=>l.name==="SS58Prefix");let o;if(r)try{const l=n(r.type).dec(r.value);typeof l=="number"&&(o=l,n=us(e,it(l)))}catch{}const i=new Map,s=(l,h)=>{let d=i.get(l);d||i.set(l,d=oi(l));const p=t.pallets.find(S=>S.name===l).storage.items.find(S=>S.name===h),b=(S,I,...C)=>({keys:d(...C),value:I,len:S,fallback:p.modifier===1?I.dec(p.fallback):void 0});if(p.type.tag==="plain")return b(0,n(p.type.value),h);const{key:v,value:y,hashers:w}=p.type.value,g=n(y),m=w.map(S=>si[S.tag]),k=(()=>{if(m.length===1)return[[n(v),m[0]]];const S=e(v);switch(S.type){case"array":return m.map(I=>[n(S.value.id),I]);case"tuple":return S.value.map((I,C)=>[n(I.id),m[C]]);default:throw new Error("Invalid key type")}})();return b(m.length,g,h,...k)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return le(...Object.values(l.value).map(h=>n(h.id)));case"struct":return T(on(l.value,h=>n(h.id)));case"array":return L(n(l.value.id),l.len)}},u=(l,h)=>{const d=t.pallets.find(p=>p.name===l).constants.find(p=>p.name===h);return n(d.type)},a=l=>(h,d)=>{const p=t.pallets.find(y=>y.name===h),b=e(p[l]);if(b.type!=="enum")throw null;const v=b.value[d];return{location:[p.index,v.idx],codec:c(b.value[d])}},f=(l,h)=>{const d=t.apis.find(p=>p.name===l)?.methods.find(p=>p.name===h);if(!d)throw null;return{args:le(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:s,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:f,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},Xl=ne(Se.enc(15)),fs=G(),Gl=te(fs),Kl=L(Se).dec,Yl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(kt(f=>{if(f instanceof qt)return r(c,u);if(f instanceof bn)return fr(750).pipe(U(()=>r(c,u)));throw f})):lt},o=r("Metadata_metadata_versions","").pipe(A(Kl)),i=r("Metadata_metadata","").pipe(A(c=>{const u=fs.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",Xl).pipe(A(c=>{const u=Gl.dec(c);return{metadata:ct.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(kt(()=>ee([14])),U(c=>c.includes(15)?s:i))};return n=>{const r=n(),o=new Set([r]),i=t(n).pipe(A(({metadata:c,metadataRaw:u})=>{const a=cs(c),f=ls(a),l=f.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 b=p.value.asset_id;b.type==="option"&&(d=b.value.id)}}return{assetId:d,metadataRaw:u,lookup:a,dynamicBuilder:f,events:{key:l.keys.enc(),dec:l.value.dec},accountId:it(f.ss58Prefix)}}),Ji(1)),s={at:r,runtime:i,addBlock:c=>(o.add(c),s),deleteBlocks:c=>(c.forEach(u=>{o.delete(u)}),o.size),usages:o};return i.subscribe({error(){}}),s}},Wt=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),hs=(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},ds=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Zl=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const o=[];for(;r;)o.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const i=[...t];for(let s=o.length-1;s>=0&&(r=e.blocks.get(o[s]),!!r.unpinned);s--)i.push(r.hash);return i.forEach(s=>{ds(e.blocks,s)}),Object.entries(e.runtimes).map(([s,c])=>({key:s,usages:c.deleteBlocks(i)})).filter(s=>s.usages===0).map(s=>s.key).forEach(s=>{delete e.runtimes[s]}),n},Jl=(e,t,n,r)=>{const o=hr(n,e).pipe(Zi((s,c)=>{switch(c.type){case"initialized":s.recovering&&(c.finalizedBlockHashes.some(h=>s.blocks.has(h))||(s=ps()));const[u]=c.finalizedBlockHashes.slice(-1);s.finalized=s.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((l,h)=>{s.blocks.has(l)?s.blocks.get(l).recovering=!1:s.blocks.set(l,{hash:l,parent:h===0?c.parentHash:c.finalizedBlockHashes[h-1],children:new Set(h===a?[]:[c.finalizedBlockHashes[h+1]]),runtime:l,refCount:0,number:c.number+h,recovering:!1})});const f=Object.values(s.runtimes).find(l=>l.usages.has(u));return s.finalizedRuntime=f??(s.runtimes[u]=i(hs(s,u))),s;case"stop-error":for(const l of s.blocks.values())l.recovering=!0;return s.recovering=!0,s;case"newBlock":{const{parentBlockHash:l,blockHash:h}=c;if(s.blocks.has(h))s.blocks.get(h).recovering=!1;else{const d=s.blocks.get(l);d.children.add(h),c.newRuntime&&(s.runtimes[h]=i(hs(s,h)));const p={hash:h,number:d.number+1,parent:l,children:new Set,runtime:c.newRuntime?h:d.runtime,refCount:0,recovering:!1};s.blocks.set(h,p),s.runtimes[p.runtime].addBlock(h)}return s}case"bestBlockChanged":{if(s.recovering){for(const[l,h]of s.blocks)h.recovering&&ds(s.blocks,l);s.recovering=!1}return s.best=c.bestBlockHash,s}case"finalized":{s.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:l}=s;return l.get(s.best).number<l.get(s.finalized).number&&(s.best=s.finalized),s.finalizedRuntime=s.runtimes[l.get(s.finalized).runtime],r(Zl(s,c.prunedBlockHashes)),s}case"blockUsage":{if(!s.blocks.has(c.value.hash))return s;const l=s.blocks.get(c.value.hash);return l.refCount+=c.value.type==="hold"?1:-1,l.refCount===0&&l.number<s.blocks.get(s.finalized).number&&!l.recovering&&(l.unpinned=!0,r([l.hash])),s}}},ps()),Pe(s=>!!s.finalizedRuntime.runtime),A(s=>({...s})),Wt),i=Yl(An(o,t));return o},ps=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),bs=(e,t,n,r)=>{const o=c=>Qi(e.pipe(Pe(({blocks:u})=>!u.has(c)))),i=(c,u,a)=>{if(a)return ee({hash:c,found:{type:!1,validity:null}});const f=o(c);return t(c).pipe(U(l=>{const h=l.indexOf(u);return h>-1?f(r(c)).pipe(A(d=>({hash:c,found:{type:!0,index:h,events:d}}))):n(c,u).pipe(A(d=>({hash:c,found:{type:!1,validity:d}})))}),f)},s=(c,u,a)=>i(c,u,a.has(c)).pipe(U(f=>{const{found:l}=f;return l.type||l.validity?.success===!1?ee(f):e.pipe(o(c),U(h=>h.blocks.get(c).children),kl(),U(h=>s(h,u,a)))}));return c=>e.pipe(ae(1),U(u=>s(u.finalized,c,new Set(u.blocks.keys()))))},Ql=new Uint8Array([2]),Nl=(e,t)=>ne(fe(Ql,me(e),me(t))),vs="TaggedTransactionQueue",ys="validate_transaction",[,ef]=xe({InvalidTransaction:xe({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:z,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:xe({CannotLookup:_,NoUnsignedValidator:_,Custom:z})}),tf=Zt(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=ef(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),nf=(e,t)=>(n,r)=>{const o=t(n).pipe(A(i=>{try{return i.dynamicBuilder.buildRuntimeCall(vs,ys).value[1]}catch{return tf}}));return e(n,`${vs}_${ys}`,Nl(r,n)).pipe(Sn(o),A(([i,s])=>s(i)))},rf=e=>t=>new $(n=>{let r=!1;const o=t.subscribe({next(i){r=!0,n.next(i)},error(i){n.error(i)},complete(){n.complete()}});return r||n.next(e),o}),ms=(e,t=1/0)=>n=>new $(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,f=0;const l=()=>{const h=i.get(a);if(!h){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=a++;i.delete(d),f!==d&&c.set(d,[]);let p=!1,b=h.subscribe({next(v){f===d?r.next(v):c.get(d).push(v)},complete(){if(p=!0,s.delete(d),d===f)for(f++;c.has(f)&&(c.get(f).forEach(v=>r.next(v)),c.delete(f),!s.has(f));)f++;l()},error(v){r.error(v)}});p||s.set(d,b)};return o=n.subscribe({next(h){const d=u++;i.set(d,lr(()=>e(h,d))),s.size<t&&l()},error(h){r.error(h)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(h=>h.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),of=e=>t=>new $(n=>{const r=t.subscribe({next(i){n.next(i)},error(i){n.error(i)},complete(){n.complete()}}),o=()=>r.unsubscribe();return()=>{Promise.resolve().then(o)}}),br=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),sf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=Vl(e),i=Pl(t),{withRecovery:s,withRecoveryFn:c}=Cl(),u=new Te,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),f=E=>B=>new $(P=>{const j=a(E),be=B.subscribe(P);return be.add(j),be}),l=E=>(B,...P)=>E(B,...P).pipe(f(B)),h=E=>(B,...P)=>new $(j=>{let be=!1;return y.pipe(ae(1)).subscribe(Le=>{const ue=Le.blocks.get(B);be=!!ue&&!ue.unpinned}),be?E(B,...P).subscribe(j):j.error(new qt)}),d=E=>t().unpin(E).catch(B=>{if(!(B instanceof dn))throw B}),p=E=>h(l((P=>Ul(y,r,P))(An(y,c(os(E)))))),b=(E,B=!0)=>(P,...j)=>E(P,B,...j),v=new Map,y=Jl(r,l(c(os(i("call")))),u,E=>{d(E),E.forEach(B=>{v.delete(B)})}),w=l(E=>y.pipe(ae(1),U(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(ms(P=>w(E(P)).pipe(A(j=>[P,j])))),m=(E,B,P)=>{const j=v.get(E)??new Map,be=j.get(B);if(be)return be;v.set(E,j);let Le;const ue=P.pipe(En({connector:()=>Le=new xn}),es({complete(){j.set(B,Le)}}),of());return j.set(B,ue),ue},k=y.pipe(pe((E,B)=>E.finalized===B.finalized),A(E=>br(E.blocks.get(E.finalized))),Wt),S=y.pipe(pe((E,B)=>E.best===B.best),A(E=>br(E.blocks.get(E.best))),Wt),I=y.pipe(pe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Zi((E,B)=>{const P=ve=>E.get(ve)||br(B.blocks.get(ve)),j=P(B.best),be=P(B.finalized),Le=j.number-be.number+1,ue=new Array(Le);for(let ve=0,Kt=j.hash;ve<Le;ve++)ue[ve]=P(Kt),Kt=ue[ve].parent;return new Map(ue.map(ve=>[ve.hash,ve]))},new Map),A(E=>[...E.values()]),Wt),C=y.pipe(pe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),pr(({finalizedRuntime:{runtime:E}})=>E.pipe(rf(null))),Wt),W=C.pipe(A(E=>E?.lookup.metadata??null)),J=Tl(k.pipe(A(E=>E.hash)),S.pipe(A(E=>E.hash)),f),X=J(p(i("body"))),Q=E=>m(E,"body",X(E,!0)),Be=p(i("storage")),ft=J((E,B,P,j,be=null,Le)=>y.pipe(ae(1),U(ue=>ue.runtimes[ue.blocks.get(E).runtime].runtime),U(ue=>{const ve=j(ue),Kt=m(E,`storage-${P}-${ve}-${be??""}`,Be(E,B,P,ve,be));return Le?m(E,`storage-${P}-${ve}-${be??""}-dec`,Kt.pipe(A(zs=>({raw:zs,mapped:Le(zs,ue)})))):Kt}))),ht=Ml(t,s),Cr=J(An(y,(E,B,P)=>ht(E,B,P??null,!1))),ih=J(An(y,E=>lr(()=>o(E)))),Ds=(E,B=!1)=>ft(E,B,"value",P=>P.events.key,null,(P,j)=>j.events.dec(P)).pipe(A(P=>P.mapped)),sh=p(i("call")),Vs=J((E,B,P,j)=>m(E,`call-${P}-${j}`,sh(E,B,P,j))),Or=nf(b(Vs,!1),w),js=E=>m(E,"body",X(E,!1)),ch=bs(y,js,Or,Ds),ah=bs(y,js,Or,()=>ee());hr(C,I).subscribe({error(){}});let $r=Ae,On=!1,Tr=0;const uh=E=>{Tr+=E,On=!0,$r=n()};return[{follow$:r,finalized$:k,best$:S,bestBlocks$:I,runtime$:C,metadata$:W,header$:ih,body$:Q,call$:b(Vs),storage$:b(ft),storageQueries$:Cr,eventsAt$:b(Ds),holdBlock:a,trackTx$:ch,trackTxWithoutEvents$:ah,validateTx$:Or,pinnedBlocks$:y,withRuntime:g,getRuntimeContext$:J(w),unfollow:()=>{On!=null&&(Tr--,On&&!Tr&&(On=null,$r(),$r=Ae))}},uh]};var cf=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const In=new Map,af=e=>{const t=In.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=In.get(e);!c||c.refCount<=1?(In.delete(e),e.destroy()):c.refCount--};let r=null,o=0,i=null;const s={chainHead$:c=>{o++,i||(i=c||1),r||(r=sf(e.chainHead));const[u,a]=r;if(i===o){const f=o;o=0,i=null,r=null,a(f)}return u},broadcastTx$:cf(e.transaction),destroy:n};return In.set(e,{client:s,refCount:1}),s};class xt{constructor(){}_runtime(t){}}class gs{constructor(){}_compatibility(t){}}const Bn=new WeakMap,ws=new WeakMap,vr=e=>e instanceof xt?ws.get(e):Bn.get(e);var Et=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(Et||{});const uf=L(tu),lf=L(Yn),ff=le(uf,lf),hf=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Pe(s=>s!=null));let i=await Ie(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(ff.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const c=new gs;return Bn.set(c,{runtime:s,getPalletEntryPoint(u,a,f){return r[i[u][a][f]]},getApiEntryPoint(u,a){return r[i.apis[u][a]]},typedefNodes:o}),c})},df=e=>new Promise(async t=>{const n=e.runtime$.pipe(Pe(o=>o!=null));let r=await Ie(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new xt;return ws.set(n,{runtime:t}),n}),yr=new WeakMap,ks=e=>(yr.has(e.metadataRaw)||yr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),yr.get(e.metadataRaw)),St=(e,t,n)=>{const r=(s,c)=>{var u;const a=ks(s);return(u=a.typeNodes)[c]||(u[c]=Vt(a.lookup(c)))};function o(s,c){if(s instanceof xt)return{args:Oe.Identical,values:Oe.Identical};const u=Bn.get(s);c||(c=u.runtime());const a=t(u),f=n(c),l=u.typedefNodes,h=ks(c);return su(a,d=>l[d],f,d=>r(c,d),h.compat)}const i=Es(e,s=>xs(o(s)));return{isCompatible:Es(e,(s,c)=>i(c)>=s),getCompatibilityLevel:i,getCompatibilityLevels:o,descriptors:e,withCompatibleRuntime:(s,c)=>u=>Ft([u.pipe(s.withRuntime(c)),e]).pipe(A(([[a,f],l])=>[a,l,f])),compatibleRuntime$:(s,c)=>Ft([e,s.getRuntimeContext$(c)]),argsAreCompatible:(s,c,u)=>{if(s instanceof xt)return!0;const a=o(s,c);if(a.args===Oe.Incompatible)return!1;if(a.args>Oe.Partial)return!0;if(a.values===Oe.Incompatible)return!1;const f=n(c);return fi(f.args,l=>r(c,l),u)},valuesAreCompatible:(s,c,u)=>{if(s instanceof xt)return!0;const a=o(s,c).values;if(a===Oe.Incompatible)return!1;if(a>Oe.Partial)return!0;const f=Bn.get(s),l=t(f);return fi(l.values,h=>f.typedefNodes[h],u)},getRuntimeTypedef:r}},xs=e=>Math.min(e.args,e.values),Es=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof gs||r instanceof xt?t(...n):e.then(o=>t(...n,o))},pf=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:o,getCompatibilityLevel:i})=>{const s=new WeakMap,c=a=>{if(s.has(a))return s.get(a);const f=a.lookup.metadata.pallets.find(h=>h.name===e)?.constants.find(h=>h.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const l=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return s.set(a,l),l},u=a=>{if(a){const f=vr(a).runtime(),l=c(f);if(!n(a,f,l))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return l}return r.then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},bf=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function mr(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new vo)}:Ae;o=e.subscribe({next:c=>{n(c),o?.unsubscribe(),i=!0},error:c=>{t?.removeEventListener("abort",s),r(c)},complete:()=>{t?.removeEventListener("abort",s),r(new Error("Observable completed without emitting"))}}),i||t?.addEventListener("abort",s)})}const gr=Symbol("EMPTY_VALUE"),wr=e=>t=>new $(n=>{let r=0,o=null,i=gr,s=!1;const c=()=>{const a=e(i,r++);i=gr,o=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){i!==gr?c():(o=null,s&&n.complete())}})},u=t.subscribe({next(a){i=a,o||c()},error(a){n.error(a)},complete(){o||n.complete(),s=!0}});return()=>{o?.unsubscribe(),u.unsubscribe()}});let Ss={};const vf=e=>t=>new $(n=>{let r=Ss,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===Ss?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)),yf=()=>{const e=new Lu(new Te);return[e.pipe(Al()),()=>es({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Te)},complete:()=>{e.value.complete(),e.next(new Te)}})]},mf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,withCompatibleRuntime:i,argsAreCompatible:s,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(i(n,f=>f.hash),A(([f,l,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(!s(l,h,null))throw u();return[f,l,h]}),ms(([f,l,h])=>n.eventsAt$(f.hash).pipe(A(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(l,h,p.event.value.value))throw u();return{meta:{phase:p.phase,block:f},payload:p.event.value.value}})))),bf);return{watch:f=>a.pipe(U(l=>f?l.filter(h=>f(h.payload)):l)),pull:()=>Ie(a),filter:f=>f.filter(l=>l.type===e&&l.value.type===t).map(l=>l.value.value),getCompatibilityLevel:o,isCompatible:r}},gf=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:s,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...f)=>{const l=f[f.length-1],h=Xt(l),{signal:d,at:p}=h?l:{},b=p??null,v=i(n,b).pipe(U(([y,w])=>{let g;try{g=w.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!s(y,w,f))throw a();return n.call$(b,u,ne(g.args.enc(f))).pipe(A(g.value.dec),A(m=>{if(!c(y,w,m))throw a();return m}))}));return mr(v,d)},{getCompatibilityLevel:o,isCompatible:r})},kr=A(e=>e.mapped),wf=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,getCompatibilityLevels:s,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",l=n.runtime$.pipe(Pe(Boolean),ae(1),A(({dynamicBuilder:g})=>typeof g.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Fe),Ji()),h=Ai(Sn(l),A(([g,m])=>m(g))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=g=>new Error(`Invalid Arguments calling ${e}.${t}(${g})`),b=g=>{try{return g.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},v=(...g)=>{const m=g[g.length-1],k=m==="best",S=k||m==="finalized"?g.slice(0,-1):g;return n[k?"best$":"finalized$"].pipe(wr(()=>y(...S,k?{at:"best"}:{})),pe((I,C)=>I.raw===C.raw),kr)},y=(...g)=>{const m=g[g.length-1],k=Xt(m),{at:S}=k?m:{},I=S??null;return f?n.bestBlocks$.pipe(A(C=>I==="finalized"||!I?C.at(-1):I==="best"?C.at(0):C.find(W=>W.hash===I)),A(C=>{if(!C)throw new ns;return C.number}),pe(),h,A(C=>({raw:"",mapped:C}))):wt(c).pipe(U(C=>n.storage$(I,"value",W=>{const J=b(W),X=g.length===J.len?g:g.slice(0,-1);if(g!==X&&!k)throw p(g);if(!u(C,W,X))throw d();return J.keys.enc(...X)},null,(W,J)=>{const X=b(J),Q=W===null?X.fallback:X.value.dec(W);if(!a(C,J,Q))throw d();return Q})))},w=async(...g)=>{const m=g[g.length-1],k=Xt(m),{signal:S}=k?m:{};return mr(y(...g).pipe(kr),S)};return{isCompatible:o,getCompatibilityLevel:i,getValue:w,getValues:(g,m)=>Promise.all(g.map(k=>w(...m?[...k,m]:k))),getEntries:async(...g)=>{const m=g[g.length-1],k=Xt(m),{signal:S,at:I}=k?m:{},C=I??null,W=await c,J=n.storage$(C,"descendantsValues",X=>{const Q=b(X);if(xs(s(W,X))===Oe.Incompatible)throw d();if(g.length>Q.len)throw p(g);const Be=g.length>0&&k?g.slice(0,-1):g;if(g.length===Q.len&&Be===g)throw p(g);return Q.keys.enc(...Be)},null,(X,Q)=>{const Be=b(Q),ft=X.map(({key:ht,value:Cr})=>({keyArgs:Be.keys.dec(ht),value:Be.value.dec(Cr)}));if(ft.some(({value:ht})=>!a(W,Q,ht)))throw d();return ft}).pipe(kr);return mr(J,S)},watchValue:v,watchEntries:(...g)=>{const m=g.at(-1),k=Xt(m);return r(e,t,k?g.slice(0,-1):g,k&&m.at==="best")}}},kf=It(z.enc,e=>+!!e.signed<<7|e.version),xr=()=>new Error("Unkown signer"),xf=e=>{const{extrinsic:t}=e,n=cs(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const i=Object.fromEntries(e.lookup[t.type].params.filter(s=>s.type!=null).map(s=>[s.name,n(s.type)]));if(r=i.Address,o=i.Signature,!r||!o)throw xr()}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(i=>!(i in o.value)))throw xr();if(r.type==="enum"){const i=r.value.Id;if(i.type==="lookupEntry"&&i.value.type==="AccountId32")return[0,[i.idx]]}else if(r.type==="AccountId32")return[0,[]];throw xr()},Ef={Ed25519:0,Sr25519:1,Ecdsa:2},Sf=(e,t,n,r,o,i)=>{const[s,c]=xf(e),u=fe(kf({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([Ef[i],...n]),...r,o);return fe(H.enc(u.length),u)},[_n,Gt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Af=e=>async t=>{let n=!0,r;for(r=0;n&&r<_n.length;r++)n=_n[r]===t[r];n=n&&r===_n.length;const o=t.length-Gt.length;for(r=0;n&&r<Gt.length;r++)n=Gt[r]===t[o+r];return n=n&&r===Gt.length,e(n?t:fe(_n,t,Gt))};function If(e,t,n){return{publicKey:e,signTx:async(o,i,s,c,u=Rt)=>{let a;try{const p=Go(s);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const f=[],l=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const b=i[p];if(!b)throw new Error(`Missing ${p} signed extension`);f.push(b.value),l.push(b.additionalSigned)});const h=fe(o,...f,...l),d=await n(h.length>256?u(h):h);return Sf(a,e,d,f,o,t)},signBytes:Af(n)}}const qe=new Uint8Array,As=e=>{const{keys:{enc:t}}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(A(r=>me(r)))},Is=(e,t)=>{const n=ls(t),r=t.metadata.pallets.find(c=>c.name==="System").constants.find(c=>c.name==="Version"),o=t(r.type),i=n.buildDefinition(r.type).dec;if(o.type!=="struct")throw new Error("not a struct");const s=n.buildDefinition(o.value[e].id).enc;return ee(s(i(r.value)[e]))},Bf=e=>ee({value:ko.enc(e),additionalSigned:qe});function _f(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Cf=It(G(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(_f(e.period)-1,1),15),r=e.phase/t<<4;return Xe.enc(n|r)}),Of=new Uint8Array([0]),$f=(e,t)=>{if(!e)return As(t).pipe(A(o=>({additionalSigned:o,value:Of})));const{period:n,blockNumber:r}=e;return ee({additionalSigned:me(t.at),value:Cf({period:n,phase:r%n})})},Tf=T({tip:H,asset:te(G(1/0))}).enc,Pf=(e,t)=>ee({value:Tf({tip:e,asset:t}),additionalSigned:qe}),Uf=e=>As(e).pipe(A(t=>({value:qe,additionalSigned:t}))),Lf=()=>ee({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),Bs="AccountNonceApi_account_nonce",Rf={1:z.dec,2:Xe.dec,4:Se.dec,8:Bt.dec},Er=e=>ee({value:H.enc(e),additionalSigned:qe});var Mf=Object.freeze({__proto__:null,CheckGenesis:Uf,CheckMetadataHash:Lf,CheckNonce:e=>e.chainHead.call$(e.at,Bs,ne(e.from)).pipe(U(t=>{const n=me(t),r=Rf[n.length];if(!r)throw new Error(`${Bs} retrieved wrong data`);return Er(r(n))})),CheckSpecVersion:({lookupFn:e})=>Is("spec_version",e).pipe(A(t=>({additionalSigned:t,value:qe}))),CheckTxVersion:({lookupFn:e})=>Is("transaction_version",e).pipe(A(t=>({additionalSigned:t,value:qe}))),getNonce:Er});const Df=ee({value:qe,additionalSigned:qe}),_s=(e,t,n)=>{if(!(t in e))return qe;const r=e[t];return r instanceof Uint8Array?r:n(r)},Vf=(e,t,n)=>ee({value:_s(e,"value",t),additionalSigned:_s(e,"additionalSigned",n)}),jf=(e,t,n,r,o,i={})=>e.getRuntimeContext$(r.hash).pipe(ae(1),U(s=>{const c={lookupFn:s.lookup,dynamicBuilder:s.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=i.mortality?i.mortality.mortal?{period:i.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return Ft(Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:f,additionalSigned:l})=>[a,(()=>{if(a==="CheckMortality")return $f(u,c);if(a==="ChargeTransactionPayment")return Bf(i.tip??0n);if(a==="ChargeAssetTxPayment")return Pf(i.tip??0n,i.asset);if(a==="CheckNonce"&&"nonce"in i)return Er(i.nonce);const h=Mf[a],[d]=s.dynamicBuilder.buildDefinition(f),[p]=s.dynamicBuilder.buildDefinition(l);return h?h(c):d===_[0]&&p===_[0]?Df:a in o?Vf(o[a],d,p):null})()]).filter(a=>a[1]))).pipe(U(a=>t.signTx(n,on(a,(f,l)=>({identifier:l,...f})),s.metadataRaw,r.number)))}));var zf=Object.defineProperty,Hf=(e,t,n)=>t in e?zf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ff=(e,t,n)=>Hf(e,t+"",n);const qf=e=>ne(Rt(me(e))),Wf=(e,t)=>new $(n=>{const r=new Map;let o,i;const s=()=>{let u=o.best,a=r.get(u),f=o.blocks.get(u).number;for(;!a;){const d=o.blocks.get(u);if(!d)break;a=r.get(u=d.parent),f--}if(!a)return;const l=f<=o.blocks.get(o.finalized).number,h=a.found.type;if(h&&i?.found&&i.hash===a.hash){l&&n.complete();return}n.next(i=a.found.type?{found:h,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:h,validity:a.found.validity}),l&&(h?n.complete():a.found.validity?.success===!1&&n.error(new Sr(a.found.validity.value)))},c=t.pipe(pe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{o=u,r.size!==0&&s()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),s()},error(u){n.error(u)}})),c}).pipe(pe((n,r)=>n===r)),Xf=(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 Sr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),Ff(this,"error"),this.name="InvalidTxError",this.error=t}}const Ar=(e,t,n,r,o=!1)=>{const i=qf(n),s=(f,l)=>({type:f,txHash:i,...l}),c=e.pinnedBlocks$.pipe(ae(1),A(f=>{const l=f.blocks.get(r);return l&&!l.unpinned?l.hash:f.finalized})).pipe(U(f=>e.validateTx$(f,n).pipe(Pe(l=>!l.success),A(l=>{throw new Sr(l.value)})))),u=new $(f=>{const l=e.trackTx$(n).subscribe(f);return l.add(t(n).subscribe({error(h){f.error(h)}})),l}),a=Wf(u,e.pinnedBlocks$).pipe(A(f=>f.found?s("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...Xf(f.events,f.index)}):s("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return ur(o?ee(s("signed",{})):lt,c,ee(s("broadcasted",{})),a.pipe(vf(({found:f,type:l,...h})=>f?ee(s("finalized",h)):lt)))},Cs=async(e,t,n,r)=>el(Ar(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),Gf=it().enc,Kf=new Uint8Array(64),Yf=new Uint8Array(65),Zf=e=>()=>e?Yf:Kf,Os=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const l=(m,k,S={})=>{const I=vr(m).runtime(),{dynamicBuilder:C,assetId:W,lookup:J}=I;let X;try{X=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(m,I,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let Q=S;if(S.asset){if(W==null||!Zn(S.asset,Vt(J(W)),ht=>u(I,ht)))throw new Error("Incompatible runtime asset");Q={...S,asset:C.buildDefinition(W).enc(S.asset)}}const{location:Be,codec:ft}=X;return{callData:je.fromBytes(fe(new Uint8Array(Be),ft.enc(k))),options:Q}},h=(m,k={})=>s(n,null).pipe(A(([S])=>l(S,m,k))),d=m=>m?l(m,f).callData:Ie(h(f).pipe(A(k=>k.callData))),p=(m,{...k},S)=>h(f,k).pipe(U(({callData:I,options:C})=>jf(n,m,I.asBytes(),S,k.customSignedExtensions||{},C))),b=(m,{at:k,...S}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(A(I=>I.find(C=>C.hash===k)))).pipe(ae(1),U(I=>I?p(m,S,I).pipe(A(C=>({tx:ne(C),block:I}))):Ht(()=>new Error(`Uknown block ${k}`)))),v=(m,k)=>Ie(b(m,k)).then(S=>S.tx),y=(m,k)=>Ie(b(m,k)).then(({tx:S,block:I})=>Cs(n,r,S,I.hash)),w=(m,k)=>b(m,k).pipe(U(({tx:S,block:I})=>Ar(n,r,S,I.hash,!0))),g=async(m,k)=>{typeof m=="string"&&(m=m.startsWith("0x")?me(m):Gf(m));const S=m.length===20,I=If(m,S?"Ecdsa":"Sr25519",Zf(S)),C=me(await v(I,k)),W=ne(fe(C,Se.enc(C.length))),J=n.getRuntimeContext$(null).pipe(A(Q=>Q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),X=n.call$(null,"TransactionPaymentApi_query_info",W);return Ie(Ft([X,J]).pipe(A(([Q,Be])=>Be(Q))))};return{getPaymentInfo:g,getEstimatedFees:async(m,k)=>(await g(m,k)).partial_fee,decodedCall:{type:e,value:Ut(t,f)},getEncodedData:d,sign:v,signSubmitAndWatch:w,signAndSubmit:y}},{getCompatibilityLevel:i,isCompatible:o});var Jf=Object.defineProperty,Qf=(e,t,n)=>t in e?Jf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ue=(e,t,n)=>(Qf(e,typeof t!="symbol"?t+"":t,n),n),Ir=Symbol("SUSPENSE"),Nf=class extends Promise{constructor(e){super(e)}},$s=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ts=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},we={},Cn=class extends ${constructor(e,t,n=Ae){super(r=>{const o=new jt({next:r.next.bind(r),error:r.error.bind(r),complete:Ae});this.refCount++;let i;r.add(()=>{var s;this.refCount--,i.unsubscribe(),this.refCount===0&&(this.currentValue=we,this.subscription&&this.subscription.unsubscribe(),n(),(s=this.subject)==null||s.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new $s),this.promise=null))}),this.subject?(i=this.subject.subscribe(o),this.currentValue!==we&&r.next(this.currentValue)):(this.subject=new Te,i=this.subject.subscribe(o),this.subscription=null,this.subscription=new jt({next:s=>{this.promise&&s!==Ir&&(this.promise.res(s),this.promise=null),this.subject.next(this.currentValue=s)},error:s=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=we;const a=(c=this.promise)==null?void 0:c.rej;a&&s===Ir&&(this.promise.rej=()=>{a(s)}),u.error(s),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ts),this.promise=null),this.currentValue!==we)return this.subject.complete();if(t===we){const s=this.subject;return this.subject=null,s.error(new Ts)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==we&&this.currentValue===we&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ue(this,"subject",null),Ue(this,"subscription",null),Ue(this,"refCount",0),Ue(this,"currentValue",we),Ue(this,"promise",null),Ue(this,"pipeState",(...r)=>{const o=super.pipe(...r);return o instanceof Cn?o:new Cn(o,we)}),Ue(this,"getRefCount",()=>this.refCount),Ue(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==we&&this.currentValue!==Ir)return this.currentValue;if(this.defaultValue!==we)return this.defaultValue;if(this.refCount===0)throw new $s;const r=new Nf((o,i)=>{this.promise={res:o,rej:i,p:null}});return this.promise.p=r,r}),Ue(this,"getDefaultValue",()=>this.defaultValue),t===we&&delete this.getDefaultValue}};function Ps(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function eh(e,t){const n=new th,r=typeof t=="function"?t:()=>t,o=i=>{for(let l=i.length-1;i[l]===void 0&&l>-1;l--)i.splice(-1);const s=[i.length,...i],c=n.get(s);if(c!==void 0)return c;const u=new Cn(e(...i),r(...i),()=>{n.delete(s)}),a=new $(l=>{const h=n.get(s);let d=u;return h?h!==a&&(d=h,Ps(d,a)):n.set(s,f),d.subscribe(l)});Ps(u,a);const f=a;return n.set(s,f),f};return(...i)=>o(i)}var th=class{constructor(){Ue(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 nh(e,t){return new Cn(e,t)}var Br=(...e)=>(typeof e[0]=="function"?eh:nh)(e[0],e.length>1?e[1]:we);const Us=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),o=new Map(e.map(c=>[c.key,c])),i=new Map,s=[];return t.forEach(c=>{const{key:u}=c,a=o.get(u);(!a||a.value!==c.value)&&i.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||s.push(c)}),{deltas:{deleted:s,upserted:[...i.values()]},entries:t.map(({key:c})=>i.get(c)??o.get(c))}},Ls=(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}},Rs=(e,t)=>n=>{const{keys:r,value:o}=n.dynamicBuilder.buildStorage(e,t);return i=>(i.dec={value:o.dec(i.value),args:r.dec(i.key)},i)},rh=(e,t,n)=>{const r=Br((c,u,a)=>{const f=Rs(c,u),l=(v,y)=>{const w=is(e,y.hash).pipe(Pe(g=>!g),ae(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(U(g=>g===v?.rootHash?ee({...v,block:y,deltas:null,prev:v.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),A(([m,k])=>[m,f(k)]),A(([m,k])=>({prev:v&&v.block.hash,rootHash:g,block:y,...Us(v?.entries??[],m,k)})))),Qi(w),kt(g=>g instanceof qt?lt:Ht(()=>g)))},h=e.pipe(pe((v,y)=>v.finalized===y.finalized),wr(({blocks:v,finalized:y})=>l(null,v.get(y))),ae(1),A(v=>({blocks:{[v.block.hash]:v},finalized:v.block.hash}))),[d,p]=yf(),b=e.pipe(pe((v,y)=>v.best===y.best),Sn(d),wr(([v,y])=>{const{best:w}=v,{blocks:g}=y;let m=g[w]?null:w;if(!m)return lt;const k=Ls(m,g,v);return k?l(k,v.blocks.get(m)).pipe(A(S=>(g[m]=S,y))):(m=v.finalized,l(g[y.finalized],v.blocks.get(m)).pipe(A(S=>(S.prev=null,{blocks:{[m]:S},finalized:m}))))}));return hr(h,b).pipe(p())}),o=c=>(u,a,f)=>{const l=r(u,a,f),h=Rs(u,a),d=c?"finalized":"best";return Ft([l.pipe(wl(0)),e.pipe(pe((p,b)=>p[d]===b[d]))]).pipe(A(([p,b])=>Ls(b[d],p.blocks,b,!0)),Pe(Boolean),pe(),Sl(null),El(),Sn(l),n(([[,p]])=>p.block.hash),A(([[[p,b],v],y])=>[p,b,v,h(y)]),U(([p,b,v,y])=>{if(!p)return[b];let w=b;const g=[];for(;w&&w.block.number>p.block.number;)g.unshift(w),w=w.prev?v.blocks[w.prev]:null;if(c&&(v.finalized=b.block.hash,g.length)){const{blocks:m}=v;Object.keys(m).forEach(k=>{m[k].block.number<g[0].block.number&&delete m[k]})}return p===w?g:[{...b,...p.rootHash===b.rootHash?{entries:p.entries,deltas:null}:Us(p.entries,b.entries,y)}]}))},i=Br(o(!0)),s=Br(o(!1));return(c,u,a,f)=>{const l=f?s:i;return e.pipe(ae(1),U(h=>h.runtimes[h.blocks.get(h[f?"best":"finalized"]).runtime].runtime),A(h=>h.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ae(1),U(h=>l(c,u,h)),A(({block:{hash:h,number:d,parent:p},deltas:b,entries:v},y)=>{const w=y>0?b:{deleted:[],upserted:v};return{block:{hash:h,number:d,parent:p},entries:v.map(_r),deltas:w&&{deleted:w.deleted.map(_r),upserted:w.upserted.map(_r)}}}))}},_r=e=>e.dec,Ms=(e,t,n)=>{const r={},o=b=>new Proxy(r,{get(v,y){return b(y)}}),i=b=>{const v={};return o(y=>(v[y]||(v[y]={}),o(w=>(v[y][w]||(v[y][w]=b(y,w)),v[y][w]))))},s=(b,v)=>b.lookup.metadata.pallets.find(y=>y.name===v),c=rh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=i((b,v)=>wf(b,v,t,c,St(e,y=>y.getPalletEntryPoint(Et.Storage,b,v),y=>nu(s(y,b).storage.items.find(w=>w.name===v))))),a=(b,v,y,w)=>{const g=b.lookup(y);if(g.type!=="enum")throw new Error("Expected enum");const m=ou(g.value[w]);return{args:v==="args"?m:fn,values:v==="args"?fn:m}},f=i((b,v)=>Os(b,v,t,n,St(e,y=>y.getPalletEntryPoint(Et.Tx,b,v),y=>a(y,"args",s(y,b).calls,v)),!0)),l=i((b,v)=>mf(b,v,t,St(e,y=>y.getPalletEntryPoint(Et.Event,b,v),y=>a(y,"values",s(y,b).events,v)))),h=i((b,v)=>pf(b,v,St(e,y=>y.getPalletEntryPoint(Et.Const,b,v),y=>iu(s(y,b).constants.find(w=>w.name===v).type)))),d=i((b,v)=>gf(b,v,t,St(e,y=>y.getApiEntryPoint(b,v),y=>ru(y.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===v))))),p=(b,v)=>{const{lookup:y,dynamicBuilder:w}=vr(v).runtime();try{const g=w.buildDefinition(y.call).dec(b.asBytes()),m=g.type,k=g.value.type,S=g.value.value;return Os(m,k,t,n,St(e,I=>I.getPalletEntryPoint(Et.Tx,m,k),I=>a(I,"args",s(I,m).calls,k)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,v)=>v?p(b,v):e.then(y=>p(b,y)),tx:f,event:l,apis:d,constants:h}};function oh(e){const t=ku(e),n=af(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const c=new WeakMap,u=l=>{const h=c.get(l)||hf(l,r);return c.set(l,h),h},a=()=>s??(s=df(r)),{broadcastTx$:f}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Ie(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Ie(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:l=>Ie(r.body$(l)),getBlockHeader:l=>Ie(r.header$(l??null)),submit:(...l)=>Cs(r,f,...l),submitAndWatch:(...l)=>Ar(r,f,...l),getTypedApi:l=>{const h=u(l);return Object.assign(Ms(h,r,f),{compatibilityToken:h})},getUnsafeApi:()=>{const l=a();return Object.assign(Ms(l,r,f),{runtimeToken:l})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}ye.AccountId=it,ye.Binary=je,ye.CompatibilityLevel=Oe,ye.Enum=Ut,ye.FixedSizeBinary=Vn,ye.InvalidTxError=Sr,ye._Enum=Bo,ye.createClient=oh,ye.getSs58AddressInfo=Mn});
1
+ (function(me,At){typeof exports=="object"&&typeof module<"u"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(me=typeof globalThis<"u"?globalThis:me||self,At(me.papi={}))})(this,function(me){"use strict";var At=Object.defineProperty,Vo=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pr=(e,t,n)=>(Vo(e,typeof t!="symbol"?t+"":t,n),n),$n={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 jo(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|$n[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=$n[e[o]],u=$n[e[o+1]];i[t+s++]=c<<4|u}return i}var Tr=class extends Uint8Array{constructor(e){super(e),Pr(this,"i",0),Pr(this,"v"),this.v=new DataView(e)}},ke=e=>t=>e(t instanceof Tr?t:new Tr(t instanceof Uint8Array?t.buffer:typeof t=="string"?jo(t).buffer:t)),Ce=e=>{const t=e.length;let n=0;for(let i=0;i<t;i++)n+=e[i].length;const r=new Uint8Array(n);for(let i=0,s=0;i<t;i++){const o=e[i];r.set(o,s),s+=o.byteLength}return r};function Zt(e,t){const n=Object.keys(e),r=n.length,i={};for(let s=0;s<r;s++){const o=n[s];i[o]=t(e[o],o)}return i}var Jt=ke,D=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},It=(e,t)=>n=>e(t(n)),Qt=(e,t)=>n=>t(e(n)),dt=([e,t],n,r)=>D(It(e,n),Qt(t,r));function zo(e,t){return ke(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Ho(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function qe(e,t,n){return D(Ho(e,n),zo(e,t))}var z=qe(1,"getUint8","setUint8"),We=qe(2,"getUint16","setUint16"),Ae=qe(4,"getUint32","setUint32"),Bt=qe(8,"getBigUint64","setBigUint64"),Fo=qe(1,"getInt8","setInt8"),qo=qe(2,"getInt16","setInt16"),Wo=qe(4,"getInt32","setInt32"),Xo=qe(8,"getBigInt64","setBigInt64"),Ur=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},Lr=e=>ke(t=>{const{v:n,i:r}=t,i=n.getBigUint64(r,!0),s=n[e](r+8,!0);return t.i+=16,s<<64n|i}),Go=D(Ur,Lr("getBigUint64")),Ko=D(Ur,Lr("getBigInt64")),Rr=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},Mr=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}),Yo=D(Rr,Mr("getBigUint64")),Zo=D(Rr,Mr("getBigInt64")),Jo=dt(z,e=>e?1:0,Boolean),Qo=[z[1],We[1],Ae[1]],No=ke(e=>{const t=e[e.i],n=t&3;if(n<3)return Qo[n](e)>>>2;const r=(t>>>2)+4;e.i++;let i=0n;const s=r/8|0;let o=0n;for(let u=0;u<s;u++)i=Bt[1](e)<<o|i,o+=64n;let c=r%8;return c>3&&(i=BigInt(Ae[1](e))<<o|i,o+=32n,c-=4),c>1&&(i=BigInt(We[1](e))<<o|i,o+=16n,c-=2),c&&(i=BigInt(z[1](e))<<o|i),i}),ec=1n<<56n,tc=1<<24,nc=256,rc=4294967295n,ic=64,sc=16384,oc=1<<30,cc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ic)return z[0](t);if(e<sc)return We[0](t|1);if(e<oc)return Ae[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ec;)n.push(Bt[0](r)),r>>=64n;r>=tc&&(n.push(Ae[0](Number(r&rc))),r>>=32n);let i=Number(r);i>=nc&&(n.push(We[0](i)),i>>=16),i&&n.push(z[0](i));const s=Ce(n);return s[0]=s.length-5<<2|3,s},H=D(cc,No),ac=new TextEncoder,uc=e=>{const t=ac.encode(e);return Ce([H.enc(t.length),t])},lc=new TextDecoder,fc=ke(e=>{let t=H.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,lc.decode(n)}),N=D(uc,fc),dc=()=>{},hc=new Uint8Array(0),_=D(()=>hc,dc),Dr=e=>e===void 0?t=>Ce([H.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Vr=e=>ke(t=>{const n=e===void 0?H.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),G=e=>D(Dr(e),Vr(e));G.enc=Dr,G.dec=Vr;var jr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[n[o],s])??n.map((s,o)=>[s,o])),i=s=>r.get(s);return({tag:s,value:o})=>Ce([z.enc(i(s)),e[s](o)])},zr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[i,n[s]])??n.map((i,s)=>[s,i]));return ke(i=>{const s=z.dec(i),o=r.get(s),c=e[o];return{tag:o,value:c(i)}})},Oe=(e,...t)=>D(jr(Zt(e,([n])=>n),...t),zr(Zt(e,([,n])=>n),...t));Oe.enc=jr,Oe.dec=zr;var Hr=e=>ke(t=>z[1](t)>0?e(t):void 0),Fr=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ce([n,e(t)]))},ee=e=>D(Fr(e[0]),Hr(e[1]));ee.enc=Fr,ee.dec=Hr;var qr=(e,t)=>ke(n=>{const r=z[1](n)===0,s=(r?e:t)(n);return{success:r,value:s}}),Wr=(e,t)=>({success:n,value:r})=>Ce([z[0](n?0:1),(n?e:t)(r)]),Nt=(e,t)=>D(Wr(e[0],t[0]),qr(e[1],t[1]));Nt.dec=qr,Nt.enc=Wr;var Xr=(...e)=>ke(t=>e.map(n=>n(t))),Gr=(...e)=>t=>Ce(e.map((n,r)=>n(t[r]))),le=(...e)=>D(Gr(...e.map(([t])=>t)),Xr(...e.map(([,t])=>t)));le.enc=Gr,le.dec=Xr;var Kr=e=>{const t=Object.keys(e);return It(le.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Yr=e=>{const t=Object.keys(e);return Qt(le.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,i)=>[t[i],r])))},P=e=>D(Kr(Zt(e,t=>t[0])),Yr(Zt(e,t=>t[1])));P.enc=Kr,P.dec=Yr;var Zr=(e,t)=>t>=0?n=>Ce(n.map(e)):n=>Ce([H.enc(n.length),Ce(n.map(e))]),Jr=(e,t)=>ke(n=>{const r=t>=0?t:H.dec(n),i=new Array(r);for(let s=0;s<r;s++)i[s]=e(n);return i}),L=(e,t)=>D(Zr(e[0],t),Jr(e[1],t));L.enc=Zr,L.dec=Jr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qr(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 Pn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Nr(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Tn(e){if(!Array.isArray(e))throw new Error("array expected")}function ei(e,t){if(!Qr(!0,t))throw new Error(`${e}: array of strings expected`)}function bc(e,t){if(!Qr(!1,t))throw new Error(`${e}: array of numbers expected`)}function yc(...e){const t=s=>s,n=(s,o)=>c=>s(o(c)),r=e.map(s=>s.encode).reduceRight(n,t),i=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:i}}function mc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;ei("alphabet",t);const r=new Map(t.map((i,s)=>[i,s]));return{encode:i=>(Tn(i),i.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:i=>(Tn(i),i.map(s=>{Pn("alphabet.decode",s);const o=r.get(s);if(o===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return o}))}}function vc(e=""){return Pn("join",e),{encode:t=>(ei("join.decode",t),t.join(e)),decode:t=>(Pn("join.decode",t),t.split(e))}}function ti(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(Tn(e),!e.length)return[];let r=0;const i=[],s=Array.from(e,c=>{if(Nr(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),o=s.length;for(;;){let c=0,u=!0;for(let a=r;a<o;a++){const f=s[a],l=t*c,d=l+f;if(!Number.isSafeInteger(d)||l/t!==c||d-f!==l)throw new Error("convertRadix: carry overflow");const h=d/n;c=d%n;const p=Math.floor(h);if(s[a]=p,!Number.isSafeInteger(p)||p*n+c!==d)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(i.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)i.push(0);return i.reverse()}function gc(e){Nr(e);const t=2**8;return{encode:n=>{if(!pc(n))throw new Error("radix.encode input should be Uint8Array");return ti(Array.from(n),t,e)},decode:n=>(bc("radix.decode",n),Uint8Array.from(ti(n,e,t)))}}const ni=(e=>yc(gc(58),mc(e),vc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function nt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function en(e,...t){if(!wc(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 _t(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 Un(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) */const kc=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),rt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),tn=(e,t)=>e<<32-t|e>>>t,ie=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ri=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Re=ie?e=>e:e=>ri(e);function se(e){for(let t=0;t<e.length;t++)e[t]=ri(e[t])}function xc(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Me(e){return typeof e=="string"&&(e=xc(e)),en(e),e}class ii{clone(){return this._cloneInto()}}function Ec(e){const t=r=>e().update(Me(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Sc(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ac(e){const t=(r,i)=>e(i).update(Me(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ic=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]);class si extends ii{constructor(t,n,r={},i,s,o){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,nt(t),nt(n),nt(i),n<0||n>i)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>i))throw new Error("key length must be undefined or 1.."+i);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!==o)throw new Error("personalization must be undefined or "+o);this.buffer=new Uint8Array(t),this.buffer32=rt(this.buffer)}update(t){_t(this);const{blockLen:n,buffer:r,buffer32:i}=this;t=Me(t);const s=t.length,o=t.byteOffset,c=t.buffer;for(let u=0;u<s;){this.pos===n&&(ie||se(i),this.compress(i,0,!1),ie||se(i),this.pos=0);const a=Math.min(n-this.pos,s-u),f=o+u;if(a===n&&!(f%4)&&u+a<s){const l=new Uint32Array(c,f,Math.floor((s-u)/4));ie||se(l);for(let d=0;u+n<s;d+=i.length,u+=n)this.length+=n,this.compress(l,d,!1);ie||se(l);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){_t(this),Un(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),ie||se(r),this.compress(r,0,!0),ie||se(r);const i=rt(t);this.get().forEach((s,o)=>i[o]=Re(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:i,destroyed:s,outputLen:o,pos:c}=this;return t||(t=new this.constructor({dkLen:o})),t.set(...this.get()),t.length=r,t.finished=i,t.destroyed=s,t.outputLen=o,t.buffer.set(n),t.pos=c,t}}const nn=BigInt(2**32-1),Ln=BigInt(32);function rn(e,t=!1){return t?{h:Number(e&nn),l:Number(e>>Ln&nn)}:{h:Number(e>>Ln&nn)|0,l:Number(e&nn)|0}}function oi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=rn(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const Bc=(e,t)=>BigInt(e>>>0)<<Ln|BigInt(t>>>0),_c=(e,t,n)=>e>>>n,Cc=(e,t,n)=>e<<32-n|t>>>n,Oc=(e,t,n)=>e>>>n|t<<32-n,$c=(e,t,n)=>e<<32-n|t>>>n,Pc=(e,t,n)=>e<<64-n|t>>>n-32,Tc=(e,t,n)=>e>>>n-32|t<<64-n,Uc=(e,t)=>t,Lc=(e,t)=>e,ci=(e,t,n)=>e<<n|t>>>32-n,ai=(e,t,n)=>t<<n|e>>>32-n,ui=(e,t,n)=>t<<n-32|e>>>64-n,li=(e,t,n)=>e<<n-32|t>>>64-n;function Rc(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const oe={fromBig:rn,split:oi,toBig:Bc,shrSH:_c,shrSL:Cc,rotrSH:Oc,rotrSL:$c,rotrBH:Pc,rotrBL:Tc,rotr32H:Uc,rotr32L:Lc,rotlSH:ci,rotlSL:ai,rotlBH:ui,rotlBL:li,add:Rc,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,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},q=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),x=new Uint32Array(32);function Xe(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],d=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=oe.add3L(u,f,o);a=oe.add3H(y,a,l,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:oe.rotr32H(b,p),Dl:oe.rotr32L(b,p)},{h,l:d}=oe.add(h,d,b,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:oe.rotrSH(l,f,24),Bl:oe.rotrSL(l,f,24)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=d,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}function Ge(e,t,n,r,i,s){const o=i[s],c=i[s+1];let u=x[2*e],a=x[2*e+1],f=x[2*t],l=x[2*t+1],d=x[2*n],h=x[2*n+1],p=x[2*r],b=x[2*r+1],y=oe.add3L(u,f,o);a=oe.add3H(y,a,l,c),u=y|0,{Dh:b,Dl:p}={Dh:b^a,Dl:p^u},{Dh:b,Dl:p}={Dh:oe.rotrSH(b,p,16),Dl:oe.rotrSL(b,p,16)},{h,l:d}=oe.add(h,d,b,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:oe.rotrBH(l,f,63),Bl:oe.rotrBL(l,f,63)},x[2*e]=u,x[2*e+1]=a,x[2*t]=f,x[2*t+1]=l,x[2*n]=d,x[2*n+1]=h,x[2*r]=p,x[2*r+1]=b}class Mc extends si{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=q[0]|0,this.v0h=q[1]|0,this.v1l=q[2]|0,this.v1h=q[3]|0,this.v2l=q[4]|0,this.v2h=q[5]|0,this.v3l=q[6]|0,this.v3h=q[7]|0,this.v4l=q[8]|0,this.v4h=q[9]|0,this.v5l=q[10]|0,this.v5h=q[11]|0,this.v6l=q[12]|0,this.v6h=q[13]|0,this.v7l=q[14]|0,this.v7h=q[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=rt(Me(t.salt));this.v4l^=Re(r[0]),this.v4h^=Re(r[1]),this.v5l^=Re(r[2]),this.v5h^=Re(r[3])}if(t.personalization){const r=rt(Me(t.personalization));this.v6l^=Re(r[0]),this.v6h^=Re(r[1]),this.v7l^=Re(r[2]),this.v7h^=Re(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Me(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:i,v2l:s,v2h:o,v3l:c,v3h:u,v4l:a,v4h:f,v5l:l,v5h:d,v6l:h,v6h:p,v7l:b,v7h:y}=this;return[t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y]}set(t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=i|0,this.v2l=s|0,this.v2h=o|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=f|0,this.v5l=l|0,this.v5h=d|0,this.v6l=h|0,this.v6h=p|0,this.v7l=b|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,a)=>x[a]=u),x.set(q,16);let{h:i,l:s}=oe.fromBig(BigInt(this.length));x[24]=q[8]^s,x[25]=q[9]^i,r&&(x[28]=~x[28],x[29]=~x[29]);let o=0;const c=Ic;for(let u=0;u<12;u++)Xe(0,4,8,12,t,n+2*c[o++]),Ge(0,4,8,12,t,n+2*c[o++]),Xe(1,5,9,13,t,n+2*c[o++]),Ge(1,5,9,13,t,n+2*c[o++]),Xe(2,6,10,14,t,n+2*c[o++]),Ge(2,6,10,14,t,n+2*c[o++]),Xe(3,7,11,15,t,n+2*c[o++]),Ge(3,7,11,15,t,n+2*c[o++]),Xe(0,5,10,15,t,n+2*c[o++]),Ge(0,5,10,15,t,n+2*c[o++]),Xe(1,6,11,12,t,n+2*c[o++]),Ge(1,6,11,12,t,n+2*c[o++]),Xe(2,7,8,13,t,n+2*c[o++]),Ge(2,7,8,13,t,n+2*c[o++]),Xe(3,4,9,14,t,n+2*c[o++]),Ge(3,4,9,14,t,n+2*c[o++]);this.v0l^=x[0]^x[16],this.v0h^=x[1]^x[17],this.v1l^=x[2]^x[18],this.v1h^=x[3]^x[19],this.v2l^=x[4]^x[20],this.v2h^=x[5]^x[21],this.v3l^=x[6]^x[22],this.v3h^=x[7]^x[23],this.v4l^=x[8]^x[24],this.v4h^=x[9]^x[25],this.v5l^=x[10]^x[26],this.v5h^=x[11]^x[27],this.v6l^=x[12]^x[28],this.v6h^=x[13]^x[29],this.v7l^=x[14]^x[30],this.v7h^=x[15]^x[31],x.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 sn=Sc(e=>new Mc(e)),fi=new TextEncoder().encode("SS58PRE"),Rn=2,Mn=e=>{try{const t=ni.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Rn),i=t.subarray(n.length+r.length),s=sn(Uint8Array.of(...fi,...n,...r),{dkLen:64}).subarray(0,Rn);return i[0]===s[0]&&i[1]===s[1]?{isValid:!0,ss58Format:Dc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Dc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},di=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=sn(Uint8Array.of(...fi,...t,...n),{dkLen:64}).subarray(0,Rn);return ni.encode(Uint8Array.of(...t,...n,...r))}};function Vc(e,t){return n=>{const r=Mn(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:i}=r;if(i.length!==e)throw new Error("Invalid public key length");return i}}const it=(e=42,t=32)=>dt(G(t),Vc(t),di(e)),hi="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=hi[r>>4]+hi[r&15]}return t.join("")}const Dn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,i=new Uint8Array(r);t&&(i[0]=0|Dn[e[2]]);for(let s=0;s<r;){const o=n+s*2,c=Dn[e[o]],u=Dn[e[o+1]];i[t+s++]=c<<4|u}return i}function Ct(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const fe=(...e)=>{const t=e.reduce((r,i)=>r+i.byteLength,0),n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.byteLength}return n},Ot=Function.prototype;class pi extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var jc=Object.defineProperty,bi=e=>{throw TypeError(e)},zc=(e,t,n)=>t in e?jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$t=(e,t,n)=>zc(e,typeof t!="symbol"?t+"":t,n),yi=(e,t,n)=>t.has(e)||bi("Cannot "+n),De=(e,t,n)=>(yi(e,t,"read from private field"),n?n.call(e):t.get(e)),Pt=(e,t,n)=>t.has(e)?bi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(yi(e,t,"write to private field"),t.set(e,n),n),Ve,Tt,on,cn,an;const Hc=new TextEncoder,Fc=new TextDecoder,qc=le(H,G(1/0))[1];class je{constructor(t,n=!1){if(Pt(this,Ve),Pt(this,Tt,null),Pt(this,on,null),Pt(this,cn,null),Pt(this,an,null),$t(this,"asText",()=>De(this,an)??st(this,an,Fc.decode(De(this,Ve)))),$t(this,"asHex",()=>De(this,on)||st(this,on,te(De(this,Ve)))),$t(this,"asOpaqueHex",()=>De(this,cn)||st(this,cn,te(this.asBytes()))),$t(this,"asBytes",()=>De(this,Ve)),$t(this,"asOpaqueBytes",()=>De(this,Tt)||st(this,Tt,fe(H[0](De(this,Ve).length),De(this,Ve)))),n){try{const[r,i]=qc(t);if(r===i.length){st(this,Ve,i),st(this,Tt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else st(this,Ve,t)}static fromText(t){return new this(Hc.encode(t))}static fromHex(t){return new this(ve(t))}static fromOpaqueHex(t){return new this(ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Ve=new WeakMap,Tt=new WeakMap,on=new WeakMap,cn=new WeakMap,an=new WeakMap;const[Wc]=it();class Vn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Wc(t))}}const mi=e=>{const t=G.enc(e);return n=>t(n.asBytes())},vi=e=>{const t=G.dec(e),n=e==null?je:Vn;return r=>n.fromBytes(t(r))},Ut=e=>D(mi(e),vi(e));Ut.enc=mi,Ut.dec=vi;const O=H,gi=H,Xc=Jt(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:G(n).dec(e),bitsLen:t}}),wi=D(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=O.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Xc),Gc=dt(z,e=>e.charCodeAt(0),String.fromCharCode),ki=e=>{const t=G.enc(e);return n=>t(ve(n))},xi=e=>{const t=G.dec(e);return n=>te(t(n))},Ke=e=>D(ki(e),xi(e));Ke.enc=ki,Ke.dec=xi;const Kc=new TextEncoder,Yc=new TextDecoder,Zc=e=>dt(G(e),t=>Kc.encode(t),t=>Yc.decode(t)),Ei=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Si=e=>{let t=n=>{const r=e(),i=r;return t=r,i(n)};return n=>t(n)},jn=e=>D(Ei(()=>e().enc),Si(()=>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}}),Ai=new Proxy({},{get(e,t){return n=>Lt(t,n)}}),Ii=(...e)=>{const t=Oe.enc(...e);return n=>t({tag:n.type,value:n.value})},Bi=(...e)=>{const t=Oe.dec(...e);return n=>{const{tag:r,value:i}=t(n);return Lt(r,i)}},xe=(e,...t)=>D(Ii(Ct(e,([n])=>n),...t),Bi(Ct(e,([,n])=>n),...t));xe.enc=Ii,xe.dec=Bi;const _i=[],Ci=[],Oi=[],Jc=BigInt(0),Rt=BigInt(1),Qc=BigInt(2),Nc=BigInt(7),ea=BigInt(256),ta=BigInt(113);for(let e=0,t=Rt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_i.push(2*(5*r+n)),Ci.push((e+1)*(e+2)/2%64);let i=Jc;for(let s=0;s<7;s++)t=(t<<Rt^(t>>Nc)*ta)%ea,t&Qc&&(i^=Rt<<(Rt<<BigInt(s))-Rt);Oi.push(i)}const[na,ra]=oi(Oi,!0),$i=(e,t,n)=>n>32?ui(e,t,n):ci(e,t,n),Pi=(e,t,n)=>n>32?li(e,t,n):ai(e,t,n);function ia(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const c=(o+8)%10,u=(o+2)%10,a=n[u],f=n[u+1],l=$i(a,f,1)^n[c],d=Pi(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[o+h]^=l,e[o+h+1]^=d}let i=e[2],s=e[3];for(let o=0;o<24;o++){const c=Ci[o],u=$i(i,s,c),a=Pi(i,s,c),f=_i[o];i=e[f],s=e[f+1],e[f]=u,e[f+1]=a}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=e[o+c];for(let c=0;c<10;c++)e[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=na[r],e[1]^=ra[r]}n.fill(0)}class zn extends ii{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,nt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=rt(this.state)}keccak(){ie||se(this.state32),ia(this.state32,this.rounds),ie||se(this.state32),this.posOut=0,this.pos=0}update(t){_t(this);const{blockLen:n,state:r}=this;t=Me(t);const i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let c=0;c<o;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:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){_t(this,!1),en(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(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:i,rounds:s,enableXOF:o}=this;return t||(t=new zn(n,r,i,o,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=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const sa=((e,t,n)=>Ec(()=>new zn(t,e,n)))(1,136,256/8),Ti=e=>{const t=e.slice(2),n=te(sa(t)).slice(2),r=new Array(40);for(let i=0;i<40;i++){const s=parseInt(n[i],16),o=t[i];r[i]=s>7?o.toUpperCase():o}return`0x${r.join("")}`},oa=G(20)[1],Ui=D(e=>{const t=ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(Ti(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Jt(e=>Ti(te(oa(e))))),Li=new TextEncoder,Ri=new TextDecoder,ca=dt(G(4),Li.encode.bind(Li),Ri.decode.bind(Ri)),Hn=P({engine:ca,payload:Ke()}),aa=xe({consensus:Hn,seal:Hn,preRuntime:Hn,runtimeUpdated:_},[4,5,6,8]),Fn=Ke(32),Mi=P({parentHash:Fn,number:O,stateRoot:Fn,extrinsicRoot:Fn,digests:L(aa)}),ze=L(N),Di=ee(N),ua=Oe({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),Vi=L(P({name:Di,type:O,typeName:Di,docs:ze})),la=P({len:Ae,type:O}),fa=P({bitStoreType:O,bitOrderType:O}),da=L(P({name:N,fields:Vi,index:z,docs:ze})),ha=Oe({composite:Vi,variant:da,sequence:O,array:la,tuple:L(O),primitive:ua,compact:O,bitSequence:fa}),pa=P({name:N,type:ee(O)}),ba=L(pa),ya=P({id:O,path:ze,params:ba,def:ha,docs:ze}),qn=L(ya),ma=Oe({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),va=L(ma),ga=P({hashers:va,key:O,value:O}),wa=P({name:N,modifier:z,type:Oe({plain:O,map:ga}),fallback:Ke(),docs:ze}),ka=ee(P({prefix:N,items:L(wa)})),ji={name:N,storage:ka,calls:ee(O),events:ee(O),constants:L(P({name:N,type:O,value:Ke(),docs:ze})),errors:ee(O),index:z},xa={...ji,docs:ze},Ea=new Uint8Array,zi=e=>D(()=>Ea,()=>e),Sa=P({type:O,version:z,signedExtensions:L(P({identifier:N,type:O,additionalSigned:O}))}),Hi=P({lookup:qn,pallets:L(P({...ji,docs:zi([])})),extrinsic:Sa,type:O,apis:zi([])}),Aa=P({name:N,methods:L(P({name:N,inputs:L(P({name:N,type:O})),output:O,docs:ze})),docs:ze}),Ia=P({version:z,address:O,call:O,signature:O,extra:O,signedExtensions:L(P({identifier:N,type:O,additionalSigned:O}))}),Fi=P({lookup:qn,pallets:L(P(xa)),extrinsic:Ia,type:O,apis:L(Aa),outerEnums:P({call:O,event:O,error:O}),custom:L(le(N,P({type:O,value:Ke()})))}),qi=()=>{throw new Error("Unsupported metadata version!")},de=D(qi,qi),ot=P({magicNumber:Ae,metadata:Oe({v0:de,v1:de,v2:de,v3:de,v4:de,v5:de,v6:de,v7:de,v8:de,v9:de,v10:de,v11:de,v12:de,v13:de,v14:Hi,v15:Fi})}),Wn=G(),Ba=ee(Wn),_a=le(H,Wn),Wi=e=>{try{return ot.dec(e)}catch{}try{return ot.dec(Ba.dec(e))}catch{}try{return ot.dec(Wn.dec(e))}catch{}try{return ot.dec(_a.dec(e)[1])}catch{}throw null},Ca={dkLen:32},Mt=e=>sn(e,Ca),Oa={dkLen:16},Xn=e=>sn(e,Oa),Xi=e=>fe(Xn(e),e),He=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function Ye(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,16),n=n+r|0,t=tn(t^n,12),{a:e,b:t,c:n,d:r}}function Ze(e,t,n,r,i){return e=e+t+i|0,r=tn(r^e,8),n=n+r|0,t=tn(t^n,7),{a:e,b:t,c:n,d:r}}function Gi(e,t,n,r,i,s,o,c,u,a,f,l,d,h,p,b,y,m,w,g){let v=0;for(let k=0;k<r;k++)({a:i,b:u,c:d,d:y}=Ye(i,u,d,y,n[t+e[v++]])),{a:i,b:u,c:d,d:y}=Ze(i,u,d,y,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Ye(s,a,h,m,n[t+e[v++]]),{a:s,b:a,c:h,d:m}=Ze(s,a,h,m,n[t+e[v++]]),{a:o,b:f,c:p,d:w}=Ye(o,f,p,w,n[t+e[v++]]),{a:o,b:f,c:p,d:w}=Ze(o,f,p,w,n[t+e[v++]]),{a:c,b:l,c:b,d:g}=Ye(c,l,b,g,n[t+e[v++]]),{a:c,b:l,c:b,d:g}=Ze(c,l,b,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Ye(i,a,p,g,n[t+e[v++]]),{a:i,b:a,c:p,d:g}=Ze(i,a,p,g,n[t+e[v++]]),{a:s,b:f,c:b,d:y}=Ye(s,f,b,y,n[t+e[v++]]),{a:s,b:f,c:b,d:y}=Ze(s,f,b,y,n[t+e[v++]]),{a:o,b:l,c:d,d:m}=Ye(o,l,d,m,n[t+e[v++]]),{a:o,b:l,c:d,d:m}=Ze(o,l,d,m,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Ye(c,u,h,w,n[t+e[v++]]),{a:c,b:u,c:h,d:w}=Ze(c,u,h,w,n[t+e[v++]]);return{v0:i,v1:s,v2:o,v3:c,v4:u,v5:a,v6:f,v7:l,v8:d,v9:h,v10:p,v11:b,v12:y,v13:m,v14:w,v15:g}}const Ki=(()=>{const e=Array.from({length:16},(r,i)=>i),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(i=>r[i]),n=[];for(let r=0,i=e;r<7;r++,i=t(i))n.push(...i);return Uint8Array.from(n)})();class Gn extends si{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,nt(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=Me(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=rt(r),ie||se(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Gn({dkLen:32},32).update(t.context).digest();this.IV=rt(r),ie||se(this.IV),this.flags=n|64}else this.IV=He.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=kc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,i=0){const{state:s,pos:o}=this,{h:c,l:u}=rn(BigInt(t),!0),{v0:a,v1:f,v2:l,v3:d,v4:h,v5:p,v6:b,v7:y,v8:m,v9:w,v10:g,v11:v,v12:k,v13:S,v14:I,v15:C}=Gi(Ki,i,r,7,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],He[0],He[1],He[2],He[3],c,u,o,n);s[0]=a^m,s[1]=f^w,s[2]=l^g,s[3]=d^v,s[4]=h^k,s[5]=p^S,s[6]=b^I,s[7]=y^C}compress(t,n=0,r=!1){let i=this.flags;if(this.chunkPos||(i|=1),(this.chunkPos===15||r)&&(i|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,i,t,n),this.chunkPos+=1,this.chunkPos===16||r){let s=this.state;this.state=this.IV.slice();for(let o,c=this.chunksDone+1;(r||!(c&1))&&(o=this.stack.pop());c>>=1)this.buffer32.set(o,0),this.buffer32.set(s,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,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:i,chunkPos:s,posOut:o,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(i.slice()),t.stack=u.map(f=>Uint32Array.from(f)),t.IV.set(n),t.flags=r,t.chunkPos=s,t.chunksDone=a,t.posOut=o,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:i,bufferOut32:s}=this,{h:o,l:c}=rn(BigInt(this.chunkOut++));ie||se(i);const{v0:u,v1:a,v2:f,v3:l,v4:d,v5:h,v6:p,v7:b,v8:y,v9:m,v10:w,v11:g,v12:v,v13:k,v14:S,v15:I}=Gi(Ki,0,i,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],He[0],He[1],He[2],He[3],c,o,n,r);s[0]=u^y,s[1]=a^m,s[2]=f^w,s[3]=l^g,s[4]=d^v,s[5]=h^k,s[6]=p^S,s[7]=b^I,s[8]=t[0]^y,s[9]=t[1]^m,s[10]=t[2]^w,s[11]=t[3]^g,s[12]=t[4]^v,s[13]=t[5]^k,s[14]=t[6]^S,s[15]=t[7]^I,ie||(se(i),se(s)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,ie||se(this.buffer32),this.compress(this.buffer32,0,!0),ie||se(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){_t(this,!1),en(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=n&&this.b2CompressOut();const o=Math.min(n-this.posOut,s-i);t.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return nt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Un(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 $a=Ac(e=>new Gn(e)),Pa={dkLen:32},Yi=e=>$a(e,Pa),Ta=e=>fe(Yi(e),e),Zi=e=>e,ct=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Kn=2n**64n-1n,ne=(e,t)=>e<<t&Kn|e>>64n-t,R=(e,t)=>e*t&Kn,K=(e,t)=>e+t&Kn,Y=11400714785074694791n,ge=14029467366897019727n,Ji=1609587929392839161n,Dt=9650029242287828579n,Qi=2870177450012600261n;function Je(e,t=0n){let n=K(K(t,Y),ge),r=K(t,ge),i=t,s=t-Y,o=e.length,c=0,u=null;(function(){let h=0,p=h+o;if(o){if(u=new Uint8Array(32),o<32){u.set(e.subarray(0,o),c),c+=o;return}if(h<=p-32){const b=p-32;do{let y;y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=R(ne(K(n,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=R(ne(K(r,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),i=R(ne(K(i,R(y,ge)),31n),Y),h+=8,y=ct(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=R(ne(K(s,R(y,ge)),31n),Y),h+=8}while(h<=b)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,f=0;for(o>=32?(a=ne(n,1n),a=K(a,ne(r,7n)),a=K(a,ne(i,12n)),a=K(a,ne(s,18n)),n=R(ne(R(n,ge),31n),Y),a=a^n,a=K(R(a,Y),Dt),r=R(ne(R(r,ge),31n),Y),a=a^r,a=K(R(a,Y),Dt),i=R(ne(R(i,ge),31n),Y),a=a^i,a=K(R(a,Y),Dt),s=R(ne(R(s,ge),31n),Y),a=a^s,a=K(R(a,Y),Dt)):a=K(t,Qi),a=K(a,BigInt(o));f<=c-8;){let d=ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]);d=R(ne(R(d,ge),31n),Y),a=K(R(ne(a^d,27n),Y),Dt),f+=8}if(f+4<=c){let d=R(ct(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),Y);a=K(R(ne(a^d,23n),ge),Ji),f+=4}for(;f<c;){const d=R(ct(e[f++],0,0,0),Qi);a=R(ne(a^d,11n),Y)}let l=a>>33n;return a=R(a^l,ge),l=a>>29n,a=R(a^l,Ji),l=a>>32n,a^=l,a}const un=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Je(e),!0),n.setBigUint64(8,Je(e,1n),!0),t},Ni=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Je(e),!0),n.setBigUint64(8,Je(e,1n),!0),n.setBigUint64(16,Je(e,2n),!0),n.setBigUint64(24,Je(e,3n),!0),t},es=e=>fe(Bt.enc(Je(e)),e),ts=new TextEncoder,Ua=new Map([[Zi,0],[es,8],[Xi,16],[Xn,-16],[Mt,-32],[un,-16],[Ni,-32]]),ns=e=>{const t=un(ts.encode(e));return(n,...r)=>{const i=fe(t,un(ts.encode(n))),s=te(i),o=a=>{if(!a.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=ve(a.slice(s.length)),l=new Array(r.length);for(let d=0,h=0;d<r.length;d++){const[p,b]=r[d],y=Ua.get(b);if(y==null)throw new Error("Unknown hasher");if(y<0){const m=y*-1;l[d]=te(f.slice(h,h+m)),h+=m}else h+=y,l[d]=p.dec(f.slice(h)),h+=p.enc(l[d]).length}return l},c=r.map(([{enc:a},f])=>l=>f(a(l)));return{enc:(...a)=>te(fe(i,...a.map((f,l)=>c[l](f)))),dec:o}}},La=je.fromText("modlpy/utilisuba").asBytes(),Ra=({threshold:e,signatories:t})=>{const n=rs(t),r=fe(La,H.enc(n.length),...n,We.enc(e));return Mt(r)},rs=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const i=r>=t.length,s=r>=n.length;if(i&&s)return 0;if(i)return-1;if(s)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var is=Object.freeze({__proto__:null,AccountId:it,Bin:Ut,Binary:je,Blake2128:Xn,Blake2128Concat:Xi,Blake2256:Mt,Blake3256:Yi,Blake3256Concat:Ta,Bytes:G,Enum:Lt,FixedSizeBinary:Vn,Hex:Ke,Identity:Zi,Option:ee,Result:Nt,ScaleEnum:Oe,Self:jn,Storage:ns,Struct:P,Tuple:le,Twox128:un,Twox256:Ni,Twox64Concat:es,Variant:xe,Vector:L,_Enum:Ai,_void:_,bitSequence:wi,blockHeader:Mi,bool:Jo,char:Gc,compact:H,compactBn:gi,compactNumber:O,createCodec:D,createDecoder:Jt,decAnyMetadata:Wi,enhanceCodec:dt,enhanceDecoder:Qt,enhanceEncoder:It,ethAccount:Ui,fixedStr:Zc,fromBufferToBase58:di,getMultisigAccountId:Ra,getSs58AddressInfo:Mn,h64:Je,i128:Ko,i16:qo,i256:Zo,i32:Wo,i64:Xo,i8:Fo,metadata:ot,selfDecoder:Si,selfEncoder:Ei,sortMultisigSignatories:rs,str:N,u128:Go,u16:We,u256:Yo,u32:Ae,u64:Bt,u8:z,v14:Hi,v14Lookup:qn,v15:Fi});const at=H,Ma=L(le(N,at)),M={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Da=xe(Object.fromEntries(Object.values(M).map(e=>[e,_]))),Va=L(le(N,ee(jn(()=>Yn)))),ja=L(at),za=P({typeRef:at,length:ee(at)}),Ha=ee(H),Fa=at,qa=P({ok:at,ko:at}),Yn=xe({struct:Ma,terminal:Da,enum:Va,tuple:ja,array:za,binary:Ha,option:Fa,result:qa}),Wa={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 jt(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"?jt(r.value,t):jt(r,t)]))};case"struct":{const n=Object.entries(e.value).map(([r,i])=>[r,i.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(Wa[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,o)=>Zn(s,o,n),i=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 i(t);case"binary":return e instanceof je&&(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 o=e,c=Object.fromEntries(t.value);if(!(o.type in c))return!1;const u=c[o.type];return u==null?!0:r(o.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 Xa=Object.defineProperty,Ga=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ka=(e,t,n)=>Ga(e,t+"",n);class ss{constructor(t=[]){Ka(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 Ee=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ee||{});function Jn(e,t,n,r,i){if(!n&&!e)return he(3);if(!n)return he(2);if(!e)return he(n.type==="option"?2:0);i.has(n)||i.set(n,new Map);const s=i.get(n);if(s.has(e)){const c=s.get(e);return c===null?{level:3,assumptions:new ss([[e,n]])}:he(c)}s.set(e,null);const o=Ya(e,n,(c,u)=>Jn(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,i));return o.assumptions.delete(e,n),o.assumptions.isEmpty()||o.level===0?s.set(e,o.level):s.delete(e),o}function Ya(e,t,n){if(e.type!==t.type)return t.type==="option"?ln(n(e,t.value),2):e.type==="option"?ln(n(e.value,t),1):he(0);switch(t.type){case"terminal":return he(t.value.type===e.value.type?3:0);case"binary":return he(cs(e.value,t.value));case"array":const i=e,s=he(cs(i.value.length,t.value.length));return Qn([s,()=>n(i.value.typeRef,t.value.typeRef)]);case"enum":{const f=e,l=Object.fromEntries(t.value),d=f.value.length===t.value.length?3:2;return ln(os(f.value.map(([h,p])=>()=>h in l?n(p,l[h]):he(0))),d)}case"option":return n(e.value,t.value);case"struct":const o=e,c=Object.fromEntries(o.value),u=o.value.length===t.value.length?3:2;return ln(Qn(t.value.map(([f,l])=>()=>n(c[f],l))),u);case"tuple":{const f=e,l=he(Ja(f.value,t.value));return Qn([l,...t.value.map((d,h)=>()=>n(f.value[h],d))])}case"result":const a=e;return os([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const ln=(e,t)=>({...e,level:Math.min(e.level,t)}),Za=new ss,he=e=>({level:e,assumptions:Za}),Qn=e=>{let t=he(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},os=e=>{if(!e.length)return he(3);let t=!1,n=he(3);for(const r of e){const i=typeof r=="function"?r():r;if(i.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(i.assumptions.values),n.level=Math.min(n.level,i.level)}return t?n:he(0)},Ja=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,cs=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,as=xe({lookup:H,typedef:Yn}),ht=e=>({type:"lookup",value:e}),Nn=e=>({type:"typedef",value:e}),fn=Nn({type:"terminal",value:{type:M.void}}),Qa=P({args:as,values:as});function Na(e){if(e.type.tag==="plain")return{args:fn,values:ht(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ht(t),values:ht(n)}}function eu(e){return{args:Nn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ht(e.output)}}function tu(e){return e.type==="lookupEntry"?ht(e.value.id):Nn(jt(e))}function nu(e){return{args:fn,values:ht(e)}}function ru(e,t,n,r,i){const s=(o,c)=>o.type==="lookup"?c(o.value):o.value;return{args:Jn(s(e.args,t),t,s(n.args,r),r,i).level,values:Jn(s(n.values,r),r,s(e.values,t),t,i).level}}function us(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Zn(n,r,t)}const pt=()=>{},Se={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},dn={chainName:"",genesisHash:"",properties:""},er={broadcast:"",stop:""};Object.entries({chainHead:Se,chainSpec:dn,transaction:er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const iu=e=>(t,n)=>{let r=e(er.broadcast,[t],{onSuccess:i=>{r=i===null?pt:()=>{e(er.stop,[i])},i===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class ls extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class hn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class pn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class fs extends Error{constructor(t){super(t),this.name="OperationError"}}class bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function su(){let e=()=>{},t=()=>{};return{promise:new Promise((r,i)=>{e=r,t=i}),res:e,rej:t}}const ds=()=>{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 i=Ot;const[s,o]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{i(),r(new pi)};o?.addEventListener("abort",c,{once:!0});const u=a=>f=>{i=Ot,o?.removeEventListener("abort",c),a(f)};i=e(u(n),u(r),...s)}),hs=(e,t)=>n=>yn((r,i,...s)=>{let o=!0,c=()=>{o=!1};const[u,a]=t(...s);return n(e,u,{onSuccess:(f,l)=>{if(f.result==="limitReached")return i(new pn);const{operationId:d}=f,h=()=>{n(Se.stopOperation,[d])};if(!o)return h();let p=pt;const b=m=>{o=!1,p(),r(m)},y=m=>{o=!1,p(),i(m)};p=l(d,{next:m=>{const w=m;w.event==="operationError"?i(new fs(w.error)):w.event==="operationInaccessible"?i(new bn):a(m,b,y)},error:y}),c=()=>{o&&(p(),h())}},onError:i}),()=>{c()}}),ou=hs(Se.body,e=>[[e],(t,n)=>{n(t.value)}]),cu=hs(Se.call,(e,t,n)=>[[e,t,n],(r,i)=>{i(r.output)}]),au=e=>t=>new Promise((n,r)=>{e(Se.header,[t],{onSuccess:n,onError:r})}),ps=e=>(t,n,r,i,s,o,c)=>{if(n.length===0)return o(),Ot;let u=!0,a=()=>{u=!1};return e(Se.storage,[t,n,r],{onSuccess:(f,l)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return s(new pn);const{operationId:d}=f,h=()=>{e(Se.stopOperation,[d])};if(!u)return h();const p=l(f.operationId,{next:m=>{switch(m.event){case"operationStorageItems":{i(m.items);break}case"operationStorageDone":{y();break}case"operationError":{b(new fs(m.error));break}case"operationInaccessible":{b(new bn);break}default:e(Se.continue,[m.operationId])}},error:s});a=()=>{p(),e(Se.stopOperation,[f.operationId])};const b=m=>{a=Ot,p(),s(m)},y=()=>{a=Ot,p(),o()};c(f.discardedItems)},onError:s}),()=>{a()}},uu=e=>{const t=ps(e);return yn((n,r,i,s,o,c)=>{const u=s.startsWith("descendants");let a=u?[]:null;const l=t(i,[{key:o,type:s}],c??null,u?d=>{a.push(d)}:d=>{a=d[0]?.[s]},r,()=>{try{n(u?a.flat():a)}catch(d){r(d)}},d=>{d>0&&(l(),r(new pn))});return l})},lu=e=>t=>t.length>0?new Promise((n,r)=>{e(Se.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class mn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function fu(e){return e.operationId!==void 0}function du(e){return(t,n,r)=>{const i=ds(),s=new Set,o=su();let c=o.promise;const u=p=>{if(fu(p))return i.has(p.operationId)||console.warn("Uknown operationId on",p),i.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:b,...y}=p;return n({type:b,...y})}r(new ls),d(!1)},a=p=>{r(p),d(!(p instanceof mn))},f=(p,b)=>{const y=b(p,{next:u,error:a});d=(m=!0)=>{c=null,d=pt,y(),m&&e(Se.unfollow,[p]),i.errorAll(new hn),s.forEach(w=>{w()}),s.clear()},c=p,o.res(p)},l=p=>{p instanceof mn?d(!1):r(p),c=null,o.res(p)};let d=e(Se.follow,[t],{onSuccess:f,onError:l});const h=(p,b,y)=>{const m=()=>{y?.onError(new hn)};if(c===null)return m(),pt;const w=v=>{if(!y)return e(p,[v,...b]);s.add(m);const k=(I,C)=>c===null?(C.error(new hn),pt):(i.subscribe(I,C),()=>{i.unsubscribe(I)}),S=e(p,[v,...b],{onSuccess:I=>{s.delete(m),y.onSuccess(I,k)},onError:I=>{s.delete(m),y.onError(I)}});return()=>{s.delete(m),S()}};if(typeof c=="string")return w(c);let g=pt;return c.then(v=>{if(v instanceof Error)return m();c&&(g=w(v))}),()=>{g()}};return{unfollow(){d(),c=null},body:ou(h),call:cu(h),header:au(h),storage:uu(h),storageSubscription:ps(h),unpin:lu(h),_request:h}}}var hu=Object.defineProperty,pu=(e,t,n)=>t in e?hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bs=(e,t,n)=>pu(e,typeof t!="symbol"?t+"":t,n);class ys extends Error{constructor(t){super(t.message),bs(this,"code"),bs(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let bu=1;const yu=e=>{let t=bu++;const n=new Map,r=ds();let i=null;const s=(f,l,d)=>{i.send(JSON.stringify({jsonrpc:"2.0",id:f,method:l,params:d}))};function o(f){try{let l,d,h,p,b;if({id:l,result:d,error:h,params:p}=JSON.parse(f),l){const w=n.get(l);return w?(n.delete(l),h?w.onError(new ys(h)):w.onSuccess(d,(g,v)=>{const k=g;return r.subscribe(k,v),()=>{r.unsubscribe(k)}})):void 0}if({subscription:b,result:d,error:h}=p,!b||!h&&!Object.hasOwn(p,"result"))throw 0;const m=b;h?r.error(m,new ys(h)):r.next(m,d)}catch(l){console.warn("Error parsing incomming message: "+f),console.error(l)}}i=e(o);const c=()=>{i?.disconnect(),i=null,r.errorAll(new mn),n.forEach(f=>f.onError(new mn)),n.clear()};let u=1;return{request:(f,l,d)=>{if(!i)throw new Error("Not connected");const h=`${t}-${u++}`;return d&&n.set(h,d),s(h,f,l),()=>{n.delete(h)}},disconnect:c}},mu=e=>{const t=yn((r,i,s,o)=>e(s,o,{onSuccess:r,onError:i}));let n=null;return async()=>n||(n=Promise.all([t(dn.chainName,[]),t(dn.genesisHash,[]),t(dn.properties,[])]).then(([r,i,s])=>({name:r,genesisHash:i,properties:s})))},vn=new Map,vu=e=>{const t=vn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=yu(e),i=()=>{const o=vn.get(e);!o||o.refCount<=1?(vn.delete(e),r()):o.refCount--},s={chainHead:du(n),transaction:iu(n),getChainSpecData:mu(n),destroy:i,request:yn((o,c,u,a)=>n(u,a,{onSuccess:o,onError:c})),_request:n};return vn.set(e,{client:s,refCount:1}),s};var tr=function(e,t){return tr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},tr(e,t)};function $e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");tr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function gu(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(f){try{a(r.next(f))}catch(l){o(l)}}function u(f){try{a(r.throw(f))}catch(l){o(l)}}function a(f){f.done?s(f.value):i(f.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function ms(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(a){return function(f){return u([a,f])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=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++,i=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],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function bt(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 Qe(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Ne(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;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 wu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(h){return function(p){return Promise.resolve(p).then(h,l)}}function c(h,p){r[h]&&(i[h]=function(b){return new Promise(function(y,m){s.push([h,b,y,m])>1||u(h,b)})},p&&(i[h]=p(i[h])))}function u(h,p){try{a(r[h](p))}catch(b){d(s[0][3],b)}}function a(h){h.value instanceof yt?Promise.resolve(h.value.v).then(f,l):d(s[0][2],h)}function f(h){u("next",h)}function l(h){u("throw",h)}function d(h,p){h(p),s.shift(),s.length&&u(s[0][0],s[0][1])}}function ku(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 bt=="function"?bt(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(o){return new Promise(function(c,u){o=e[s](o),i(c,u,o.done,o.value)})}}function i(s,o,c,u){Promise.resolve(u).then(function(a){s({value:a,done:c})},o)}}typeof SuppressedError=="function"&&SuppressedError;function V(e){return typeof e=="function"}function nr(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 rr=nr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
+ `+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function gn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var mt=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,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=bt(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(b){t={error:b}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else o.remove(this);var f=this.initialTeardown;if(V(f))try{f()}catch(b){s=b instanceof rr?b.errors:[b]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=bt(l),h=d.next();!h.done;h=d.next()){var p=h.value;try{ws(p)}catch(b){s=s??[],b instanceof rr?s=Ne(Ne([],Qe(s)),Qe(b.errors)):s.push(b)}}}catch(b){r={error:b}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}}if(s)throw new rr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ws(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)&&gn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&gn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),vs=mt.EMPTY;function gs(e){return e instanceof mt||e&&"closed"in e&&V(e.remove)&&V(e.add)&&V(e.unsubscribe)}function ws(e){V(e)?e():e.unsubscribe()}var xu={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Eu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ne([e,t],Qe(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ks(e){Eu.setTimeout(function(){throw e})}function Ie(){}function wn(e){e()}var zt=function(e){$e(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,gs(n)&&n.add(r)):r.destination=Iu,r}return t.create=function(n,r,i){return new vt(n,r,i)},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}(mt),Su=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){kn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){kn(r)}else kn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){kn(n)}},e}(),vt=function(e){$e(t,e);function t(n,r,i){var s=e.call(this)||this,o;return V(n)||!n?o={next:n??void 0,error:r??void 0,complete:i??void 0}:o=n,s.destination=new Su(o),s}return t}(zt);function kn(e){ks(e)}function Au(e){throw e}var Iu={closed:!0,next:Ie,error:Au,complete:Ie},ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Fe(e){return e}function xs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Es(e)}function Es(e){return e.length===0?Fe:e.length===1?e[0]:function(n){return e.reduce(function(r,i){return i(r)},n)}}var $=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var i=this,s=_u(t)?t:new vt(t,n,r);return wn(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._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=Ss(n),new n(function(i,s){var o=new vt({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},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 Es(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Ss(t),new t(function(r,i){var s;n.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},e.create=function(t){return new e(t)},e}();function Ss(e){var t;return(t=e??xu.Promise)!==null&&t!==void 0?t:Promise}function Bu(e){return e&&V(e.next)&&V(e.error)&&V(e.complete)}function _u(e){return e&&e instanceof zt||Bu(e)&&gs(e)}function Cu(e){return V(e?.lift)}function Z(e){return function(t){if(Cu(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 F(e,t,n,r,i){return new Ou(e,t,n,r,i)}var Ou=function(e){$e(t,e);function t(n,r,i,s,o,c){var u=e.call(this,n)||this;return u.onFinalize=o,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=i?function(){try{i()}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),$u=nr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pe=function(e){$e(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 As(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new $u},t.prototype.next=function(n){var r=this;wn(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=bt(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(n)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var r=this;wn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;wn(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,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?vs:(this.currentObservers=null,c.push(n),new mt(function(){r.currentObservers=null,gn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},t.prototype.asObservable=function(){var n=new $;return n.source=this,n},t.create=function(n,r){return new As(n,r)},t}($),As=function(e){$e(t,e);function t(n,r){var i=e.call(this)||this;return i.destination=n,i.source=r,i}return t.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},t.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.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,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:vs},t}(Pe),Pu=function(e){$e(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,i=n.thrownError,s=n._value;if(r)throw i;return this._throwIfClosed(),s},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Pe),sr={now:function(){return(sr.delegate||Date).now()},delegate:void 0},xn=function(e){$e(t,e);function t(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=sr);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=i,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,i=r.isStopped,s=r._buffer,o=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;i||(s.push(n),!o&&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),i=this,s=i._infiniteTimeWindow,o=i._buffer,c=o.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,i=n._timestampProvider,s=n._buffer,o=n._infiniteTimeWindow,c=(o?1:2)*r;if(r<1/0&&c<s.length&&s.splice(0,s.length-c),!o){for(var u=i.now(),a=0,f=1;f<s.length&&s[f]<=u;f+=2)a=f;a&&s.splice(0,a+1)}},t}(Pe),Tu=function(e){$e(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(mt),Is={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ne([e,t],Qe(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},Uu=function(e){$e(t,e);function t(n,r){var i=e.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Is.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Is.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var i=!1,s;try{this.work(n)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,gn(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Tu),Bs=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=sr.now,e}(),Lu=function(e){$e(t,e);function t(n,r){r===void 0&&(r=Bs.now);var i=e.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},t}(Bs),_s=new Lu(Uu),Ru=_s,ut=new $(function(e){return e.complete()});function Cs(e){return e&&V(e.schedule)}function or(e){return e[e.length-1]}function Os(e){return V(or(e))?e.pop():void 0}function Ht(e){return Cs(or(e))?e.pop():void 0}function Mu(e,t){return typeof or(e)=="number"?e.pop():t}var $s=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Ps(e){return V(e?.then)}function Ts(e){return V(e[ir])}function Us(e){return Symbol.asyncIterator&&V(e?.[Symbol.asyncIterator])}function Ls(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 Du(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Rs=Du();function Ms(e){return V(e?.[Rs])}function Ds(e){return wu(this,arguments,function(){var n,r,i,s;return ms(this,function(o){switch(o.label){case 0:n=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,yt(n.read())];case 3:return r=o.sent(),i=r.value,s=r.done,s?[4,yt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,yt(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Vs(e){return V(e?.getReader)}function ce(e){if(e instanceof $)return e;if(e!=null){if(Ts(e))return Vu(e);if($s(e))return ju(e);if(Ps(e))return zu(e);if(Us(e))return js(e);if(Ms(e))return Hu(e);if(Vs(e))return Fu(e)}throw Ls(e)}function Vu(e){return new $(function(t){var n=e[ir]();if(V(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ju(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function zu(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ks)})}function Hu(e){return new $(function(t){var n,r;try{for(var i=bt(e),s=i.next();!s.done;s=i.next()){var o=s.value;if(t.next(o),t.closed)return}}catch(c){n={error:c}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function js(e){return new $(function(t){qu(e,t).catch(function(n){return t.error(n)})})}function Fu(e){return js(Ds(e))}function qu(e,t){var n,r,i,s;return gu(this,void 0,void 0,function(){var o,c;return ms(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=ku(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),i={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(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function et(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var s=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!i)return s}function zs(e,t){return t===void 0&&(t=0),Z(function(n,r){n.subscribe(F(r,function(i){return et(r,e,function(){return r.next(i)},t)},function(){return et(r,e,function(){return r.complete()},t)},function(i){return et(r,e,function(){return r.error(i)},t)}))})}function Hs(e,t){return t===void 0&&(t=0),Z(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Wu(e,t){return ce(e).pipe(Hs(t),zs(t))}function Xu(e,t){return ce(e).pipe(Hs(t),zs(t))}function Gu(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Ku(e,t){return new $(function(n){var r;return et(n,t,function(){r=e[Rs](),et(n,t,function(){var i,s,o;try{i=r.next(),s=i.value,o=i.done}catch(c){n.error(c);return}o?n.complete():n.next(s)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function Fs(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(function(n){et(n,t,function(){var r=e[Symbol.asyncIterator]();et(n,t,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function Yu(e,t){return Fs(Ds(e),t)}function Zu(e,t){if(e!=null){if(Ts(e))return Wu(e,t);if($s(e))return Gu(e,t);if(Ps(e))return Xu(e,t);if(Us(e))return Fs(e,t);if(Ms(e))return Ku(e,t);if(Vs(e))return Yu(e,t)}throw Ls(e)}function gt(e,t){return t?Zu(e,t):ce(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return gt(e,n)}function Ft(e,t){var n=V(e)?e:function(){return e},r=function(i){return i.error(n())};return new $(r)}var qs=nr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Ju(e,t){return new Promise(function(n,r){var i=!1,s;e.subscribe({next:function(o){s=o,i=!0},error:r,complete:function(){i?n(s):r(new qs)}})})}function Be(e,t){return new Promise(function(n,r){var i=new vt({next:function(s){n(s),i.unsubscribe()},error:r,complete:function(){r(new qs)}});e.subscribe(i)})}function Qu(e){return e instanceof Date&&!isNaN(e)}function A(e,t){return Z(function(n,r){var i=0;n.subscribe(F(r,function(s){r.next(e.call(t,s,i++))}))})}var Nu=Array.isArray;function el(e,t){return Nu(t)?e.apply(void 0,Ne([],Qe(t))):e(t)}function tl(e){return A(function(t){return el(e,t)})}var nl=Array.isArray,rl=Object.getPrototypeOf,il=Object.prototype,sl=Object.keys;function ol(e){if(e.length===1){var t=e[0];if(nl(t))return{args:t,keys:null};if(cl(t)){var n=sl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function cl(e){return e&&typeof e=="object"&&rl(e)===il}function al(e,t){return e.reduce(function(n,r,i){return n[r]=t[i],n},{})}function qt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=Os(e),i=ol(e),s=i.args,o=i.keys;if(s.length===0)return gt([],n);var c=new $(ul(s,n,o?function(u){return al(o,u)}:Fe));return r?c.pipe(tl(r)):c}function ul(e,t,n){return n===void 0&&(n=Fe),function(r){Ws(t,function(){for(var i=e.length,s=new Array(i),o=i,c=i,u=function(f){Ws(t,function(){var l=gt(e[f],t),d=!1;l.subscribe(F(r,function(h){s[f]=h,d||(d=!0,c--),c||r.next(n(s.slice()))},function(){--o||r.complete()}))},r)},a=0;a<i;a++)u(a)},r)}}function Ws(e,t,n){e?et(n,e,t):t()}function ll(e,t,n,r,i,s,o,c){var u=[],a=0,f=0,l=!1,d=function(){l&&!u.length&&!a&&t.complete()},h=function(b){return a<r?p(b):u.push(b)},p=function(b){a++;var y=!1;ce(n(b,f++)).subscribe(F(t,function(m){t.next(m)},function(){y=!0},void 0,function(){if(y)try{a--;for(var m=function(){var w=u.shift();o||p(w)};u.length&&a<r;)m();d()}catch(w){t.error(w)}}))};return e.subscribe(F(t,h,function(){l=!0,d()})),function(){}}function U(e,t,n){return n===void 0&&(n=1/0),V(t)?U(function(r,i){return A(function(s,o){return t(r,s,i,o)})(ce(e(r,i)))},n):(typeof t=="number"&&(n=t),Z(function(r,i){return ll(r,i,e,n)}))}function cr(e){return e===void 0&&(e=1/0),U(Fe,e)}function fl(){return cr(1)}function ar(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fl()(gt(e,Ht(e)))}function ur(e){return new $(function(t){ce(e()).subscribe(t)})}var dl={connector:function(){return new Pe},resetOnDisconnect:!0};function hl(e,t){t===void 0&&(t=dl);var n=null,r=t.connector,i=t.resetOnDisconnect,s=i===void 0?!0:i,o=r(),c=new $(function(u){return o.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=ur(function(){return e}).subscribe(o),s&&n.add(function(){return o=r()})),n},c}function lr(e,t,n){e===void 0&&(e=0),n===void 0&&(n=Ru);var r=-1;return t!=null&&(Cs(t)?n=t:r=t),new $(function(i){var s=Qu(e)?+e-n.now():e;s<0&&(s=0);var o=0;return n.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function fr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e),r=Mu(e,1/0),i=e;return i.length?i.length===1?ce(i[0]):cr(r)(gt(i,n)):ut}function Te(e,t){return Z(function(n,r){var i=0;n.subscribe(F(r,function(s){return e.call(t,s,i++)&&r.next(s)}))})}function wt(e){return Z(function(t,n){var r=null,i=!1,s;r=t.subscribe(F(n,void 0,void 0,function(o){s=ce(e(o,wt(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,s.subscribe(n))})}function pl(e,t,n,r,i){return function(s,o){var c=n,u=t,a=0;s.subscribe(F(o,function(f){var l=a++;u=c?e(u,f,l):(c=!0,f),o.next(u)},i))}}function Xs(e,t){return V(t)?U(e,t,1):U(e,1)}function ae(e){return e<=0?function(){return ut}:Z(function(t,n){var r=0;t.subscribe(F(n,function(i){++r<=e&&(n.next(i),e<=r&&n.complete())}))})}function bl(e){return A(function(){return e})}function yl(e,t){return U(function(n,r){return ce(e(n,r)).pipe(ae(1),bl(n))})}function ml(e,t){t===void 0&&(t=_s);var n=lr(e,t);return yl(function(){return n})}function vl(e,t){return Z(function(n,r){var i=new Set;n.subscribe(F(r,function(s){var o=e?e(s):s;i.has(o)||(i.add(o),r.next(s))})),t&&ce(t).subscribe(F(r,function(){return i.clear()},Ie))})}function pe(e,t){return t===void 0&&(t=Fe),e=e??gl,Z(function(n,r){var i,s=!0;n.subscribe(F(r,function(o){var c=t(o);(s||!e(i,c))&&(s=!1,i=c,r.next(o))}))})}function gl(e,t){return e===t}function wl(){return Z(function(e,t){var n,r=!1;e.subscribe(F(t,function(i){var s=n;n=i,r&&t.next([s,i]),r=!0}))})}function Gs(e,t){return Z(pl(e,t,arguments.length>=2,!0))}function En(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Pe}:t,r=e.resetOnError,i=r===void 0?!0:r,s=e.resetOnComplete,o=s===void 0?!0:s,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var f,l,d,h=0,p=!1,b=!1,y=function(){l?.unsubscribe(),l=void 0},m=function(){y(),f=d=void 0,p=b=!1},w=function(){var g=f;m(),g?.unsubscribe()};return Z(function(g,v){h++,!b&&!p&&y();var k=d=d??n();v.add(function(){h--,h===0&&!b&&!p&&(l=dr(w,u))}),k.subscribe(v),!f&&h>0&&(f=new vt({next:function(S){return k.next(S)},error:function(S){b=!0,y(),l=dr(m,i,S),k.error(S)},complete:function(){p=!0,y(),l=dr(m,o),k.complete()}}),ce(g).subscribe(f))})(a)}}function dr(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 i=new vt({next:function(){i.unsubscribe(),e()}});return ce(t.apply(void 0,Ne([],Qe(n)))).subscribe(i)}}function Ks(e,t,n){var r,i,s,o,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,o=r===void 0?1/0:r,i=e.windowTime,t=i===void 0?1/0:i,s=e.refCount,c=s===void 0?!1:s,n=e.scheduler):o=e??1/0,En({connector:function(){return new xn(o,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function kl(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ht(e);return Z(function(r,i){(n?ar(e,r,n):ar(e,r)).subscribe(i)})}function hr(e,t){return Z(function(n,r){var i=null,s=0,o=!1,c=function(){return o&&!i&&r.complete()};n.subscribe(F(r,function(u){i?.unsubscribe();var a=0,f=s++;ce(e(u,f)).subscribe(i=F(r,function(l){return r.next(t?t(u,l,f,a++):l)},function(){i=null,c()}))},function(){o=!0,c()}))})}function xl(){return hr(Fe)}function Ys(e){return Z(function(t,n){ce(e).subscribe(F(n,function(){return n.complete()},Ie)),!n.closed&&t.subscribe(n)})}function Zs(e,t){return t===void 0&&(t=!1),Z(function(n,r){var i=0;n.subscribe(F(r,function(s){var o=e(s,i++);(o||t)&&r.next(s),!o&&r.complete()}))})}function Js(e,t,n){var r=V(e)||t||n?{next:e,error:t,complete:n}:e;return r?Z(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(F(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)}))}):Fe}function Sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Os(e);return Z(function(r,i){for(var s=e.length,o=new Array(s),c=e.map(function(){return!1}),u=!1,a=function(l){ce(e[l]).subscribe(F(i,function(d){o[l]=d,!u&&!c[l]&&(c[l]=!0,(u=c.every(Fe))&&(c=null))},Ie))},f=0;f<s;f++)a(f);r.subscribe(F(i,function(l){if(u){var d=Ne([l],Qe(o));i.next(n?n.apply(void 0,Ne([],Qe(d))):d)}}))})}var El=Object.defineProperty,Sl=(e,t,n)=>t in e?El(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qs=(e,t,n)=>Sl(e,typeof t!="symbol"?t+"":t,n);class Al{constructor(){Qs(this,"first"),Qs(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 Il=()=>{const e=new Map,t=(d,h)=>{e.set(d,()=>{e.delete(d),h()})},n=d=>{e.get(d)?.()},r=new Al,i=r.unshift.bind(r),s=r.push.bind(r),o=(d,h)=>{const p=h?i:s;t(d.source$,p(d))},c=()=>{const d=r.pop();d&&(e.delete(d.source$),u(d))},u=d=>{const{source$:h,observer:p}=d;let b=!1;const y=h.subscribe({next(m){p.next(m)},error(m){(b=m instanceof pn)?o(d,!0):p.error(m)},complete(){p.complete()}});y.closed?b||c():t(h,()=>{y.unsubscribe(),c()})},a=(d=!1)=>h=>new $(p=>{const b={observer:p,source$:h};return r.isEmpty()?u(b):o(b,d),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:d=>(...h)=>f(d(...h))}};class Wt extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Bl extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Ns extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const _l=new Set(["best","finalized",null]),eo=e=>{const t=e.pipe(wt(n=>n instanceof bn?lr(750).pipe(Xs(()=>t)):Ft(()=>n)));return t},Cl=(e,t,n)=>r=>(i,...s)=>{if(!_l.has(i))return eo(r(i,...s)).pipe(n(i));const c=(i==="best"?t:e).pipe(ae(1),U(u=>r(u,...s).pipe(n(u))),wt(u=>u instanceof Wt?c:Ft(()=>u)));return eo(c)},to=e=>(...t)=>new $(n=>{let r=new AbortController;return e(...t,r.signal).then(i=>{n.next(i),n.complete()},i=>{n.error(i)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Ol=e=>t=>(...n)=>e()[t](...n),no=(e,t)=>e.pipe(Zs(n=>n.blocks.has(t)),pe((n,r)=>n.finalized===r.finalized&&n.best===r.best),A(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let i=n.blocks.get(n.best),s=n.finalized===i.hash;for(;i.number>r;)i=n.blocks.get(i.parent),s=s||n.finalized===i.hash;return s?"finalized":i.hash===t?"best":null}),pe(),Zs(n=>n!=="finalized",!0));function $l(e,t,n){return(r,i,...s)=>(i?xs(Tl(r,t.pipe(Te(c=>c.type==="finalized"),U(c=>c.prunedBlockHashes))),Pl(r,e)):c=>c)(n(r,...s))}const Pl=(e,t)=>n=>no(t,e).pipe(ae(1),hr(r=>r?n:Ft(()=>new Ns))),Tl=(e,t)=>n=>new $(r=>{const i=t.pipe(Te(o=>o===e)).subscribe(()=>{r.error(new Bl)}),s=n.subscribe(r);return()=>{i.unsubscribe(),s.unsubscribe()}});function An(e,t){return(n,...r)=>{const i=t(n,...r);return new $(s=>{let o=null,c=!1;const u=()=>{c||(c=!0,o=i.subscribe({next:l=>s.next(l),error:l=>s.error(l),complete:()=>s.complete()}),o.add(()=>{c=!1,o=null}))};let a=!1;const f=e.subscribe({next:l=>{const d=l.blocks.get(n);d?d.recovering?o?.unsubscribe():u():a&&s.error(new Wt),a=l.recovering},error:l=>s.error(l)});return()=>{f.unsubscribe(),o?.unsubscribe()}})}}const Ul=(e,t)=>{const n=(r,i,s,o)=>new $(c=>e().storageSubscription(r,i,s??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,i.slice(-u),s,!0))})).pipe(cr(),t(o));return n},Ll=e=>t=>t.pipe(Xs(n=>n.type!=="initialized"?re(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Rl=e=>{let t=null,n=Ie;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},i=c=>r().header(c).then(Mi.dec),s=hl(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(Ll(i),Ml()));return{getHeader:i,getFollower:r,startFollow:()=>(s.connect(),()=>{n()}),follow$:s}},Ml=()=>e=>new $(t=>{const n=new mt,r=()=>e.subscribe({next:i=>t.next(i),error:i=>{i instanceof ls?(t.next({type:"stop-error"}),n.add(r())):t.error(i)},complete:()=>t.complete()});return n.add(r()),n}),ro=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",tt={type:"void"},Dl=(e,t=()=>null)=>{const n=new Map,r=new Set,i=f=>l=>{let d=n.get(l);if(d)return d;if(r.has(l)){const p={id:l};return n.set(l,p),p}r.add(l);const h=f(l);return d=n.get(l),d?Object.assign(d,h):(d={id:l,...h},n.set(l,d)),r.delete(l),d};let s=!0,o=!0;const c=i(f=>{const l=t(e[f]);if(l)return l;const{def:d,path:h,params:p}=e[f];if(d.tag==="composite"){if(d.value.length===0)return tt;if(d.value.length===1){const b=c(d.value[0].type);return s&&h.at(-1)==="AccountId32"&&ro(b,32)?(s=!1,{type:"AccountId32"}):o&&h.at(-1)==="AccountId20"&&ro(b,20)?(o=!1,{type:"AccountId20"}):b}return u(d.value)}if(d.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(d.value.length===0)return tt;const b={},y={};return d.value.forEach(m=>{const w=m.name;if(y[w]=m.docs,m.fields.length===0){b[w]={...tt,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){b[w]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}b[w]={...u(m.fields),idx:m.index}}),{type:"enum",value:b,innerDocs:y}}if(d.tag==="sequence")return{type:"sequence",value:c(d.value)};if(d.tag==="array"){const{len:b}=d.value,y=c(d.value.type);return!b||y.type==="void"?tt:b>1?{type:"array",value:y,len:d.value.len}:y}if(d.tag==="tuple")return d.value.length===0?tt:d.value.length>1?a(d.value.map(b=>c(b)),d.value.map(b=>e[b].docs)):c(d.value[0]);if(d.tag==="primitive")return{type:"primitive",value:d.value.tag};if(d.tag==="compact"){const b=c(d.value);return b.type==="void"?tt:{type:"compact",isBig:Number(b.value.slice(1))>32,size:b.value}}return{type:d.tag}}),u=f=>{let l=!0;const d={},h={};return f.forEach((p,b)=>{l=l&&!!p.name;const y=p.name||b,m=c(p.type);m.type!=="void"&&(d[y]=m,h[y]=p.docs)}),l?{type:"struct",value:d,innerDocs:h}:a(Object.values(d),Object.values(h))},a=(f,l)=>{if(f.every(d=>d.id===f[0].id)&&l.every(d=>!d.length)){const[d]=f;return d.type==="void"?tt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:l}};return c},io=e=>{const t=Dl(e.lookup,({def:i})=>{if(i.tag==="composite"){const s=n(i);if(s)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(o=>[o.name,o.errors==null?{...tt,idx:o.index}:{type:"lookupEntry",value:t(o.errors),idx:o.index}])),byteLength:s}}return null});function n(i){if(!(i.value.length===2&&i.value[0].name==="index"&&i.value[1].name==="error"))return null;const o=t(i.value[0].type),c=t(i.value[1].type);return o.type==="primitive"&&o.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(o=>o.name==="Call")?.type??null})},Vl=(e,t,n)=>(r,i,s,...o)=>{const{id:c}=r;if(i.has(c))return i.get(c);if(s.has(c)){const a=t(()=>i.get(c),r,...o);return i.set(c,a),a}s.add(c);let u=e(r,i,s,...o);return s.delete(c),i.has(c)&&(u=n(u,i.get(c),r,...o)),i.set(c,u),u},jl=Ut(),zl=D(H[0],Qt(H[1],BigInt)),so=Vl((e,t,n,r)=>{if(e.type==="primitive")return is[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return Ui;if(e.type==="compact")return e.isBig?zl:H;if(e.type==="bitSequence")return wi;const i=h=>so(h,t,n,r),s=(h,p)=>{const b=i(h);return p?L(b,p):L(b)},o=h=>le(...h.map(i)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([b,y])=>[b,i(y)]));return P(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return jl;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 o(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return ee(i(e.value));if(e.type==="result")return Nt(i(e.value.ok),i(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return i(h.value);case"tuple":return o(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),d=f.every((h,p)=>h===p)?xe(a):xe(a,f);return e.byteLength?Hl(d,e.byteLength):d},jn,e=>e),oo=(e,t=it())=>{const n=new Map,r=i=>so(e(i),n,new Set,t);return i=>r(i)},Hl=(e,t)=>{const n=G(t);return D(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},co=e=>{const{metadata:t}=e;let n=oo(e);const r=t.pallets.find(l=>l.name==="System")?.constants.find(l=>l.name==="SS58Prefix");let i;if(r)try{const l=n(r.type).dec(r.value);typeof l=="number"&&(i=l,n=oo(e,it(l)))}catch{}const s=new Map,o=(l,d)=>{let h=s.get(l);h||s.set(l,h=ns(l));const p=t.pallets.find(S=>S.name===l).storage.items.find(S=>S.name===d),b=(S,I,...C)=>({keys:h(...C),value:I,len:S,fallback:p.modifier===1?I.dec(p.fallback):void 0});if(p.type.tag==="plain")return b(0,n(p.type.value),d);const{key:y,value:m,hashers:w}=p.type.value,g=n(m),v=w.map(S=>is[S.tag]),k=(()=>{if(v.length===1)return[[n(y),v[0]]];const S=e(y);switch(S.type){case"array":return v.map(I=>[n(S.value.id),I]);case"tuple":return S.value.map((I,C)=>[n(I.id),v[C]]);default:throw new Error("Invalid key type")}})();return b(v.length,g,d,...k)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return le(...Object.values(l.value).map(d=>n(d.id)));case"struct":return P(Ct(l.value,d=>n(d.id)));case"array":return L(n(l.value.id),l.len)}},u=(l,d)=>{const h=t.pallets.find(p=>p.name===l).constants.find(p=>p.name===d);return n(h.type)},a=l=>(d,h)=>{const p=t.pallets.find(m=>m.name===d),b=e(p[l]);if(b.type!=="enum")throw null;const y=b.value[h];return{location:[p.index,y.idx],codec:c(b.value[h])}},f=(l,d)=>{const h=t.apis.find(p=>p.name===l)?.methods.find(p=>p.name===d);if(!h)throw null;return{args:le(...h.inputs.map(p=>n(p.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:o,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:f,buildCall:a("calls"),buildConstant:u,ss58Prefix:i}},Fl=te(Ae.enc(15)),ao=G(),ql=ee(ao),Wl=L(Ae).dec,Xl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(wt(f=>{if(f instanceof Wt)return r(c,u);if(f instanceof bn)return lr(750).pipe(U(()=>r(c,u)));throw f})):ut},i=r("Metadata_metadata_versions","").pipe(A(Wl)),s=r("Metadata_metadata","").pipe(A(c=>{const u=ao.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}})),o=r("Metadata_metadata_at_version",Fl).pipe(A(c=>{const u=ql.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}}));return i.pipe(wt(()=>re([14])),U(c=>c.includes(15)?o:s))};return n=>{const r=n(),i=new Set([r]),s=t(n).pipe(A(({metadata:c,metadataRaw:u})=>{const a=io(c),f=co(a),l=f.buildStorage("System","Events"),d=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(d){const p=a(d.type);if(p.type==="struct"){const b=p.value.asset_id;b.type==="option"&&(h=b.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:f,events:{key:l.keys.enc(),dec:l.value.dec},accountId:it(f.ss58Prefix)}}),Ks(1)),o={at:r,runtime:s,addBlock:c=>(i.add(c),o),deleteBlocks:c=>(c.forEach(u=>{i.delete(u)}),i.size),usages:i};return s.subscribe({error(){}}),o}},Xt=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),uo=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(i=>!e.blocks.get(i).unpinned)??null:e.blocks.has(t)?t:null},lo=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},Gl=(e,t)=>{const n=[...t];let r=e.blocks.get(e.blocks.get(e.finalized).parent);const i=[];for(;r;)i.push(r.hash),r.refCount===0&&!r.unpinned&&(n.push(r.hash),r.unpinned=!0),r=e.blocks.get(r.parent);const s=[...t];for(let o=i.length-1;o>=0&&(r=e.blocks.get(i[o]),!!r.unpinned);o--)s.push(r.hash);return s.forEach(o=>{lo(e.blocks,o)}),Object.entries(e.runtimes).map(([o,c])=>({key:o,usages:c.deleteBlocks(s)})).filter(o=>o.usages===0).map(o=>o.key).forEach(o=>{delete e.runtimes[o]}),n},Kl=(e,t,n,r)=>{const i=fr(n,e).pipe(Gs((o,c)=>{switch(c.type){case"initialized":o.recovering&&(c.finalizedBlockHashes.some(d=>o.blocks.has(d))||(o=fo()));const[u]=c.finalizedBlockHashes.slice(-1);o.finalized=o.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((l,d)=>{o.blocks.has(l)?o.blocks.get(l).recovering=!1:o.blocks.set(l,{hash:l,parent:d===0?c.parentHash:c.finalizedBlockHashes[d-1],children:new Set(d===a?[]:[c.finalizedBlockHashes[d+1]]),runtime:l,refCount:0,number:c.number+d,recovering:!1})});const f=Object.values(o.runtimes).find(l=>l.usages.has(u));return o.finalizedRuntime=f??(o.runtimes[u]=s(uo(o,u))),o;case"stop-error":for(const l of o.blocks.values())l.recovering=!0;return o.recovering=!0,o;case"newBlock":{const{parentBlockHash:l,blockHash:d}=c;if(o.blocks.has(d))o.blocks.get(d).recovering=!1;else{const h=o.blocks.get(l);h.children.add(d),c.newRuntime&&(o.runtimes[d]=s(uo(o,d)));const p={hash:d,number:h.number+1,parent:l,children:new Set,runtime:c.newRuntime?d:h.runtime,refCount:0,recovering:!1};o.blocks.set(d,p),o.runtimes[p.runtime].addBlock(d)}return o}case"bestBlockChanged":{if(o.recovering){for(const[l,d]of o.blocks)d.recovering&&lo(o.blocks,l);o.recovering=!1}return o.best=c.bestBlockHash,o}case"finalized":{o.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:l}=o;return l.get(o.best).number<l.get(o.finalized).number&&(o.best=o.finalized),o.finalizedRuntime=o.runtimes[l.get(o.finalized).runtime],r(Gl(o,c.prunedBlockHashes)),o}case"blockUsage":{if(!o.blocks.has(c.value.hash))return o;const l=o.blocks.get(c.value.hash);return l.refCount+=c.value.type==="hold"?1:-1,l.refCount===0&&l.number<o.blocks.get(o.finalized).number&&!l.recovering&&(l.unpinned=!0,r([l.hash])),o}}},fo()),Te(o=>!!o.finalizedRuntime.runtime),A(o=>({...o})),Xt),s=Xl(An(i,t));return i},fo=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),ho=(e,t,n,r)=>{const i=c=>Ys(e.pipe(Te(({blocks:u})=>!u.has(c)))),s=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const f=i(c);return t(c).pipe(U(l=>{const d=l.indexOf(u);return d>-1?f(r(c)).pipe(A(h=>({hash:c,found:{type:!0,index:d,events:h}}))):n(c,u).pipe(A(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},o=(c,u,a)=>s(c,u,a.has(c)).pipe(U(f=>{const{found:l}=f;return l.type||l.validity?.success===!1?re(f):e.pipe(i(c),U(d=>d.blocks.get(c).children),vl(),U(d=>o(d,u,a)))}));return c=>e.pipe(ae(1),U(u=>o(u.finalized,c,new Set(u.blocks.keys()))))},Yl=new Uint8Array([2]),Zl=(e,t)=>te(fe(Yl,ve(e),ve(t))),po="TaggedTransactionQueue",bo="validate_transaction",[,Jl]=xe({InvalidTransaction:xe({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:z,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:xe({CannotLookup:_,NoUnsignedValidator:_,Custom:z})}),Ql=Jt(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Jl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Nl=(e,t)=>(n,r)=>{const i=t(n).pipe(A(s=>{try{return s.dynamicBuilder.buildRuntimeCall(po,bo).value[1]}catch{return Ql}}));return e(n,`${po}_${bo}`,Zl(r,n)).pipe(Sn(i),A(([s,o])=>o(s)))},ef=e=>t=>new $(n=>{let r=!1;const i=t.subscribe({next(s){r=!0,n.next(s)},error(s){n.error(s)},complete(){n.complete()}});return r||n.next(e),i}),yo=(e,t=1/0)=>n=>new $(r=>{let i;const s=new Map,o=new Map,c=new Map;let u=0,a=0,f=0;const l=()=>{const d=s.get(a);if(!d){o.size===0&&(typeof i>"u"||i.closed)&&r.complete();return}const h=a++;s.delete(h),f!==h&&c.set(h,[]);let p=!1,b=d.subscribe({next(y){f===h?r.next(y):c.get(h).push(y)},complete(){if(p=!0,o.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(y=>r.next(y)),c.delete(f),!o.has(f));)f++;l()},error(y){r.error(y)}});p||o.set(h,b)};return i=n.subscribe({next(d){const h=u++;s.set(h,ur(()=>e(d,h))),o.size<t&&l()},error(d){r.error(d)},complete(){o.size===0&&r.complete()}}),()=>{o.forEach(d=>d.unsubscribe()),i.unsubscribe(),s.clear(),c.clear()}}),tf=e=>t=>new $(n=>{const r=t.subscribe({next(s){n.next(s)},error(s){n.error(s)},complete(){n.complete()}}),i=()=>r.unsubscribe();return()=>{Promise.resolve().then(i)}}),pr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),nf=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:i}=Rl(e),s=Ol(t),{withRecovery:o,withRecoveryFn:c}=Il(),u=new Pe,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),f=E=>B=>new $(T=>{const j=a(E),be=B.subscribe(T);return be.add(j),be}),l=E=>(B,...T)=>E(B,...T).pipe(f(B)),d=E=>(B,...T)=>new $(j=>{let be=!1;return m.pipe(ae(1)).subscribe(Le=>{const ue=Le.blocks.get(B);be=!!ue&&!ue.unpinned}),be?E(B,...T).subscribe(j):j.error(new Wt)}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof hn))throw B}),p=E=>d(l((T=>$l(m,r,T))(An(m,c(to(E)))))),b=(E,B=!0)=>(T,...j)=>E(T,B,...j),y=new Map,m=Kl(r,l(c(to(s("call")))),u,E=>{h(E),E.forEach(B=>{y.delete(B)})}),w=l(E=>m.pipe(ae(1),U(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(yo(T=>w(E(T)).pipe(A(j=>[T,j])))),v=(E,B,T)=>{const j=y.get(E)??new Map,be=j.get(B);if(be)return be;y.set(E,j);let Le;const ue=T.pipe(En({connector:()=>Le=new xn}),Js({complete(){j.set(B,Le)}}),tf());return j.set(B,ue),ue},k=m.pipe(pe((E,B)=>E.finalized===B.finalized),A(E=>pr(E.blocks.get(E.finalized))),Xt),S=m.pipe(pe((E,B)=>E.best===B.best),A(E=>pr(E.blocks.get(E.best))),Xt),I=m.pipe(pe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Gs((E,B)=>{const T=ye=>E.get(ye)||pr(B.blocks.get(ye)),j=T(B.best),be=T(B.finalized),Le=j.number-be.number+1,ue=new Array(Le);for(let ye=0,Yt=j.hash;ye<Le;ye++)ue[ye]=T(Yt),Yt=ue[ye].parent;return new Map(ue.map(ye=>[ye.hash,ye]))},new Map),A(E=>[...E.values()]),Xt),C=m.pipe(pe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),hr(({finalizedRuntime:{runtime:E}})=>E.pipe(ef(null))),Xt),W=C.pipe(A(E=>E?.lookup.metadata??null)),J=Cl(k.pipe(A(E=>E.hash)),S.pipe(A(E=>E.hash)),f),X=J(p(s("body"))),Q=E=>v(E,"body",X(E,!0)),_e=p(s("storage")),lt=J((E,B,T,j,be=null,Le)=>m.pipe(ae(1),U(ue=>ue.runtimes[ue.blocks.get(E).runtime].runtime),U(ue=>{const ye=j(ue),Yt=v(E,`storage-${T}-${ye}-${be??""}`,_e(E,B,T,ye,be));return Le?v(E,`storage-${T}-${ye}-${be??""}-dec`,Yt.pipe(A(Do=>({raw:Do,mapped:Le(Do,ue)})))):Yt}))),ft=Ul(t,o),_r=J(An(m,(E,B,T)=>ft(E,B,T??null,!1))),ed=J(An(m,E=>ur(()=>i(E)))),Lo=(E,B=!1)=>lt(E,B,"value",T=>T.events.key,null,(T,j)=>j.events.dec(T)).pipe(A(T=>T.mapped)),td=p(s("call")),Ro=J((E,B,T,j)=>v(E,`call-${T}-${j}`,td(E,B,T,j))),Cr=Nl(b(Ro,!1),w),Mo=E=>v(E,"body",X(E,!1)),nd=ho(m,Mo,Cr,Lo),rd=ho(m,Mo,Cr,()=>re());fr(C,I).subscribe({error(){}});let Or=Ie,On=!1,$r=0;const id=E=>{$r+=E,On=!0,Or=n()};return[{follow$:r,finalized$:k,best$:S,bestBlocks$:I,runtime$:C,metadata$:W,header$:ed,body$:Q,call$:b(Ro),storage$:b(lt),storageQueries$:_r,eventsAt$:b(Lo),holdBlock:a,trackTx$:nd,trackTxWithoutEvents$:rd,validateTx$:Cr,pinnedBlocks$:m,withRuntime:g,getRuntimeContext$:J(w),unfollow:()=>{On!=null&&($r--,On&&!$r&&(On=null,Or(),Or=Ie))}},id]};var rf=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const In=new Map,sf=e=>{const t=In.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=In.get(e);!c||c.refCount<=1?(In.delete(e),e.destroy()):c.refCount--};let r=null,i=0,s=null;const o={chainHead$:c=>{i++,s||(s=c||1),r||(r=nf(e.chainHead));const[u,a]=r;if(s===i){const f=i;i=0,s=null,r=null,a(f)}return u},broadcastTx$:rf(e.transaction),destroy:n};return In.set(e,{client:o,refCount:1}),o};class kt{constructor(){}_runtime(t){}}class mo{constructor(){}_compatibility(t){}}const Bn=new WeakMap,vo=new WeakMap,br=e=>e instanceof kt?vo.get(e):Bn.get(e);var xt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(xt||{});const of=L(Qa),cf=L(Yn),af=le(of,cf),uf=(e,t)=>{const n=new Promise(async r=>{const i=t.runtime$.pipe(Te(o=>o!=null));let s=await Be(i);i.subscribe(o=>s=o),r(()=>s)});return Promise.all([e.metadataTypes.then(af.dec),e.descriptors,n]).then(([[r,i],s,o])=>{const c=new mo;return Bn.set(c,{runtime:o,getPalletEntryPoint(u,a,f){const l=s[u]?.[a]?.[f];if(l==null)throw new Error(`Descriptor for ${u} ${a}.${f} does not exist`);return r[l]},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:i}),c})},lf=e=>new Promise(async t=>{const n=e.runtime$.pipe(Te(i=>i!=null));let r=await Be(n);n.subscribe(i=>r=i),t(()=>r)}).then(t=>{const n=new kt;return vo.set(n,{runtime:t}),n}),yr=new WeakMap,go=e=>(yr.has(e.metadataRaw)||yr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),yr.get(e.metadataRaw)),Et=(e,t,n)=>{const r=(o,c)=>{var u;const a=go(o);return(u=a.typeNodes)[c]||(u[c]=jt(a.lookup(c)))};function i(o,c){if(o instanceof kt)return{args:Ee.Identical,values:Ee.Identical};const u=Bn.get(o);c||(c=u.runtime());const a=t(u),f=n(c);if(f==null)return{args:Ee.Incompatible,values:Ee.Incompatible};const l=u.typedefNodes,d=go(c);return ru(a,h=>l[h],f,h=>r(c,h),d.compat)}const s=ko(e,o=>wo(i(o)));return{isCompatible:ko(e,(o,c)=>s(c)>=o),getCompatibilityLevel:s,getCompatibilityLevels:i,descriptors:e,withCompatibleRuntime:(o,c)=>u=>qt([u.pipe(o.withRuntime(c)),e]).pipe(A(([[a,f],l])=>[a,l,f])),compatibleRuntime$:(o,c)=>qt([e,o.getRuntimeContext$(c)]),argsAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c);if(a.args===Ee.Incompatible)return!1;if(a.args>Ee.Partial)return!0;if(a.values===Ee.Incompatible)return!1;const f=n(c);return f==null?!1:us(f.args,l=>r(c,l),u)},valuesAreCompatible:(o,c,u)=>{if(o instanceof kt)return!0;const a=i(o,c).values;if(a===Ee.Incompatible)return!1;if(a>Ee.Partial)return!0;const f=Bn.get(o),l=t(f);return us(l.values,d=>f.typedefNodes[d],u)},getRuntimeTypedef:r}},wo=e=>Math.min(e.args,e.values),ko=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof mo||r instanceof kt?t(...n):e.then(i=>t(...n,i))},ff=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:i,getCompatibilityLevel:s})=>{const o=new WeakMap,c=a=>{if(o.has(a))return o.get(a);const f=a.lookup.metadata.pallets.find(d=>d.name===e)?.constants.find(d=>d.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const l=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return o.set(a,l),l},u=a=>{if(a){const f=br(a).runtime(),l=c(f);if(!n(a,f,l))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return l}return r.then(u)};return Object.assign(u,{isCompatible:i,getCompatibilityLevel:s})},df=En({connector:()=>new xn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function mr(e,t){return new Promise((n,r)=>{let i=null,s=!1;const o=t?()=>{i?.unsubscribe(),r(new pi)}:Ie;i=e.subscribe({next:c=>{n(c),i?.unsubscribe(),s=!0},error:c=>{t?.removeEventListener("abort",o),r(c)},complete:()=>{t?.removeEventListener("abort",o),r(new Error("Observable completed without emitting"))}}),s||t?.addEventListener("abort",o)})}const vr=Symbol("EMPTY_VALUE"),gr=e=>t=>new $(n=>{let r=0,i=null,s=vr,o=!1;const c=()=>{const a=e(s,r++);s=vr,i=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){s!==vr?c():(i=null,o&&n.complete())}})},u=t.subscribe({next(a){s=a,i||c()},error(a){n.error(a)},complete(){i||n.complete(),o=!0}});return()=>{i?.unsubscribe(),u.unsubscribe()}});let xo={};const hf=e=>t=>new $(n=>{let r=xo,i=t.subscribe({next(s){n.next(r=s)},error(s){n.error(s)},complete(){r===xo?n.complete():i=e(r).subscribe(n)}});return()=>{i.unsubscribe()}}),Gt=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)),pf=()=>{const e=new Pu(new Pe);return[e.pipe(xl()),()=>Js({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Pe)},complete:()=>{e.value.complete(),e.next(new Pe)}})]},bf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,withCompatibleRuntime:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(s(n,f=>f.hash),A(([f,l,d])=>{const h=d.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(h==null||d.lookup.metadata.lookup[h].def.tag!=="variant"||d.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!o(l,d,null))throw u();return[f,l,d]}),yo(([f,l,d])=>n.eventsAt$(f.hash).pipe(A(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(l,d,p.event.value.value))throw u();return{meta:{phase:p.phase,block:f},payload:p.event.value.value}})))),df);return{watch:f=>a.pipe(U(l=>f?l.filter(d=>f(d.payload)):l)),pull:()=>Be(a),filter:f=>f.filter(l=>l.type===e&&l.value.type===t).map(l=>l.value.value),getCompatibilityLevel:i,isCompatible:r}},yf=(e,t,n,{isCompatible:r,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:o,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...f)=>{const l=f[f.length-1],d=Gt(l),{signal:h,at:p}=d?l:{},b=p??null,y=s(n,b).pipe(U(([m,w])=>{let g;try{g=w.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!o(m,w,f))throw a();return n.call$(b,u,te(g.args.enc(f))).pipe(A(g.value.dec),A(v=>{if(!c(m,w,v))throw a();return v}))}));return mr(y,h)},{getCompatibilityLevel:i,isCompatible:r})},wr=A(e=>e.mapped),mf=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,getCompatibilityLevels:o,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",l=n.runtime$.pipe(Te(Boolean),ae(1),A(({dynamicBuilder:g})=>typeof g.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Fe),Ks()),d=xs(Sn(l),A(([g,v])=>v(g))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=g=>new Error(`Invalid Arguments calling ${e}.${t}(${g})`),b=g=>{try{return g.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...g)=>{const v=g[g.length-1],k=v==="best",S=k||v==="finalized"?g.slice(0,-1):g;return n[k?"best$":"finalized$"].pipe(gr(()=>m(...S,k?{at:"best"}:{})),pe((I,C)=>I.raw===C.raw),wr)},m=(...g)=>{const v=g[g.length-1],k=Gt(v),{at:S}=k?v:{},I=S??null;return f?n.bestBlocks$.pipe(A(C=>I==="finalized"||!I?C.at(-1):I==="best"?C.at(0):C.find(W=>W.hash===I)),A(C=>{if(!C)throw new Ns;return C.number}),pe(),d,A(C=>({raw:"",mapped:C}))):gt(c).pipe(U(C=>n.storage$(I,"value",W=>{const J=b(W),X=g.length===J.len?g:g.slice(0,-1);if(g!==X&&!k)throw p(g);if(!u(C,W,X))throw h();return J.keys.enc(...X)},null,(W,J)=>{const X=b(J),Q=W===null?X.fallback:X.value.dec(W);if(!a(C,J,Q))throw h();return Q})))},w=async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S}=k?v:{};return mr(m(...g).pipe(wr),S)};return{isCompatible:i,getCompatibilityLevel:s,getValue:w,getValues:(g,v)=>Promise.all(g.map(k=>w(...v?[...k,v]:k))),getEntries:async(...g)=>{const v=g[g.length-1],k=Gt(v),{signal:S,at:I}=k?v:{},C=I??null,W=await c,J=n.storage$(C,"descendantsValues",X=>{const Q=b(X);if(wo(o(W,X))===Ee.Incompatible)throw h();if(g.length>Q.len)throw p(g);const _e=g.length>0&&k?g.slice(0,-1):g;if(g.length===Q.len&&_e===g)throw p(g);return Q.keys.enc(..._e)},null,(X,Q)=>{const _e=b(Q),lt=X.map(({key:ft,value:_r})=>({keyArgs:_e.keys.dec(ft),value:_e.value.dec(_r)}));if(lt.some(({value:ft})=>!a(W,Q,ft)))throw h();return lt}).pipe(wr);return mr(J,S)},watchValue:y,watchEntries:(...g)=>{const v=g.at(-1),k=Gt(v);return r(e,t,k?g.slice(0,-1):g,k&&v.at==="best")}}},vf=It(z.enc,e=>+!!e.signed<<7|e.version),kr=()=>new Error("Unkown signer"),gf=e=>{const{extrinsic:t}=e,n=io(e);let r,i;if("address"in t)r=n(t.address),i=n(t.signature);else{const s=Object.fromEntries(e.lookup[t.type].params.filter(o=>o.type!=null).map(o=>[o.name,n(o.type)]));if(r=s.Address,i=s.Signature,!r||!i)throw kr()}if(r.type==="AccountId20"&&i.type==="array"&&i.len===65&&i.value.type==="primitive"&&i.value.value==="u8")return[1,[]];if(i.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(s=>!(s in i.value)))throw kr();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 kr()},wf={Ed25519:0,Sr25519:1,Ecdsa:2},kf=(e,t,n,r,i,s)=>{const[o,c]=gf(e),u=fe(vf({signed:!0,version:4}),o===1?t:new Uint8Array([...c,...t]),o===1||!s?n:new Uint8Array([wf[s],...n]),...r,i);return fe(H.enc(u.length),u)},[_n,Kt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),xf=e=>async t=>{let n=!0,r;for(r=0;n&&r<_n.length;r++)n=_n[r]===t[r];n=n&&r===_n.length;const i=t.length-Kt.length;for(r=0;n&&r<Kt.length;r++)n=Kt[r]===t[i+r];return n=n&&r===Kt.length,e(n?t:fe(_n,t,Kt))};function Ef(e,t,n){return{publicKey:e,signTx:async(i,s,o,c,u=Mt)=>{let a;try{const p=Wi(o);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const f=[],l=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const b=s[p];if(!b)throw new Error(`Missing ${p} signed extension`);f.push(b.value),l.push(b.additionalSigned)});const d=fe(i,...f,...l),h=await n(d.length>256?u(d):d);return kf(a,e,h,f,i,t)},signBytes:xf(n)}}const St=new Uint8Array,Eo=e=>{const{keys:{enc:t}}=e.dynamicBuilder.buildStorage("System","BlockHash");let n;try{n=t(0)}catch{n=t(0n)}return e.chainHead.storage$(e.at,"value",()=>n,null).pipe(A(r=>ve(r)))},So=(e,t)=>{const n=co(t),r=t.metadata.pallets.find(c=>c.name==="System").constants.find(c=>c.name==="Version"),i=t(r.type),s=n.buildDefinition(r.type).dec;if(i.type!=="struct")throw new Error("not a struct");const o=n.buildDefinition(i.value[e].id).enc;return re(o(s(r.value)[e]))},Sf=e=>re({value:gi.enc(e),additionalSigned:St});function Af(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const If=It(G(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Af(e.period)-1,1),15),r=e.phase/t<<4;return We.enc(n|r)}),Bf=new Uint8Array([0]),_f=(e,t)=>{if(!e)return Eo(t).pipe(A(i=>({additionalSigned:i,value:Bf})));const{period:n,blockNumber:r}=e;return re({additionalSigned:ve(t.at),value:If({period:n,phase:r%n})})},Cf=P({tip:H,asset:ee(G(1/0))}).enc,Of=(e,t)=>re({value:Cf({tip:e,asset:t}),additionalSigned:St}),$f=e=>Eo(e).pipe(A(t=>({value:St,additionalSigned:t}))),Pf=()=>re({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),Ao="AccountNonceApi_account_nonce",Tf={1:z.dec,2:We.dec,4:Ae.dec,8:Bt.dec},xr=e=>re({value:H.enc(e),additionalSigned:St});var Uf=Object.freeze({__proto__:null,CheckGenesis:$f,CheckMetadataHash:Pf,CheckNonce:e=>e.chainHead.call$(e.at,Ao,te(e.from)).pipe(U(t=>{const n=ve(t),r=Tf[n.length];if(!r)throw new Error(`${Ao} retrieved wrong data`);return xr(r(n))})),CheckSpecVersion:({lookupFn:e})=>So("spec_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),CheckTxVersion:({lookupFn:e})=>So("transaction_version",e).pipe(A(t=>({additionalSigned:t,value:St}))),getNonce:xr});const Lf=(e,t,n,r,i,s={})=>e.getRuntimeContext$(r.hash).pipe(ae(1),U(o=>{const c={lookupFn:o.lookup,dynamicBuilder:o.dynamicBuilder,chainHead:e,callData:n,at:r.hash,from:t.publicKey},u=s.mortality?s.mortality.mortal?{period:s.mortality.period,blockNumber:r.number}:void 0:{period:64,blockNumber:r.number};return qt(Object.fromEntries(o.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:f,additionalSigned:l})=>[a,(()=>{if(a==="CheckMortality")return _f(u,c);if(a==="ChargeTransactionPayment")return Sf(s.tip??0n);if(a==="ChargeAssetTxPayment")return Of(s.tip??0n,s.asset);if(a==="CheckNonce"&&"nonce"in s)return xr(s.nonce);const d=Uf[a];if(d)return d(c);const h=i[a],[[p],[b]]=[f,l].map(o.dynamicBuilder.buildDefinition);try{return re(Ct({value:p,additionalSigned:b},(y,m)=>{const w=h?.[m];return w instanceof Uint8Array?w:y(w)}))}catch{return null}})()]).filter(a=>a[1]))).pipe(U(a=>t.signTx(n,Ct(a,(f,l)=>({identifier:l,...f})),o.metadataRaw,r.number)))}));var Rf=Object.defineProperty,Mf=(e,t,n)=>t in e?Rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Df=(e,t,n)=>Mf(e,t+"",n);const Vf=e=>te(Mt(ve(e))),jf=(e,t)=>new $(n=>{const r=new Map;let i,s;const o=()=>{let u=i.best,a=r.get(u),f=i.blocks.get(u).number;for(;!a;){const h=i.blocks.get(u);if(!h)break;a=r.get(u=h.parent),f--}if(!a)return;const l=f<=i.blocks.get(i.finalized).number,d=a.found.type;if(d&&s?.found&&s.hash===a.hash){l&&n.complete();return}n.next(s=a.found.type?{found:d,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:d,validity:a.found.validity}),l&&(d?n.complete():a.found.validity?.success===!1&&n.error(new Er(a.found.validity.value)))},c=t.pipe(pe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{i=u,r.size!==0&&o()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),o()},error(u){n.error(u)}})),c}).pipe(pe((n,r)=>n===r)),zf=(e,t)=>{const n=e.filter(i=>i.phase.type==="ApplyExtrinsic"&&i.phase.value===t).map(i=>({...i.event,topics:i.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 Er extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),Df(this,"error"),this.name="InvalidTxError",this.error=t}}const Sr=(e,t,n,r,i=!1)=>{const s=Vf(n),o=(f,l)=>({type:f,txHash:s,...l}),c=e.pinnedBlocks$.pipe(ae(1),A(f=>{const l=f.blocks.get(r);return l&&!l.unpinned?l.hash:f.finalized})).pipe(U(f=>e.validateTx$(f,n).pipe(Te(l=>!l.success),A(l=>{throw new Er(l.value)})))),u=new $(f=>{const l=e.trackTx$(n).subscribe(f);return l.add(t(n).subscribe({error(d){f.error(d)}})),l}),a=jf(u,e.pinnedBlocks$).pipe(A(f=>f.found?o("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...zf(f.events,f.index)}):o("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return ar(i?re(o("signed",{})):ut,c,re(o("broadcasted",{})),a.pipe(hf(({found:f,type:l,...d})=>f?re(o("finalized",d)):ut)))},Io=async(e,t,n,r)=>Ju(Sr(e,t,n,r)).then(i=>{if(i.type!=="finalized")throw null;const s={...i};return delete s.type,s}),Hf=it().enc,Ff=new Uint8Array(64),qf=new Uint8Array(65),Wf=e=>()=>e?qf:Ff,Bo=(e,t,n,r,{isCompatible:i,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const l=(v,k,S={})=>{const I=br(v).runtime(),{dynamicBuilder:C,assetId:W,lookup:J}=I;let X;try{X=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(v,I,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let Q=S;if(S.asset){if(W==null||!Zn(S.asset,jt(J(W)),ft=>u(I,ft)))throw new Error("Incompatible runtime asset");Q={...S,asset:C.buildDefinition(W).enc(S.asset)}}const{location:_e,codec:lt}=X;return{callData:je.fromBytes(fe(new Uint8Array(_e),lt.enc(k))),options:Q}},d=(v,k={})=>o(n,null).pipe(A(([S])=>l(S,v,k))),h=v=>v?l(v,f).callData:Be(d(f).pipe(A(k=>k.callData))),p=(v,{...k},S)=>d(f,k).pipe(U(({callData:I,options:C})=>Lf(n,v,I.asBytes(),S,k.customSignedExtensions||{},C))),b=(v,{at:k,...S}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(A(I=>I.find(C=>C.hash===k)))).pipe(ae(1),U(I=>I?p(v,S,I).pipe(A(C=>({tx:te(C),block:I}))):Ft(()=>new Error(`Uknown block ${k}`)))),y=(v,k)=>Be(b(v,k)).then(S=>S.tx),m=(v,k)=>Be(b(v,k)).then(({tx:S,block:I})=>Io(n,r,S,I.hash)),w=(v,k)=>b(v,k).pipe(U(({tx:S,block:I})=>Sr(n,r,S,I.hash,!0))),g=async(v,k)=>{typeof v=="string"&&(v=v.startsWith("0x")?ve(v):Hf(v));const S=v.length===20,I=Ef(v,S?"Ecdsa":"Sr25519",Wf(S)),C=ve(await y(I,k)),W=te(fe(C,Ae.enc(C.length))),J=n.getRuntimeContext$(null).pipe(A(Q=>Q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),X=n.call$(null,"TransactionPaymentApi_query_info",W);return Be(qt([X,J]).pipe(A(([Q,_e])=>_e(Q))))};return{getPaymentInfo:g,getEstimatedFees:async(v,k)=>(await g(v,k)).partial_fee,decodedCall:{type:e,value:Lt(t,f)},getEncodedData:h,sign:y,signSubmitAndWatch:w,signAndSubmit:m}},{getCompatibilityLevel:s,isCompatible:i});var Xf=Object.defineProperty,Gf=(e,t,n)=>t in e?Xf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ue=(e,t,n)=>(Gf(e,typeof t!="symbol"?t+"":t,n),n),Ar=Symbol("SUSPENSE"),Kf=class extends Promise{constructor(e){super(e)}},_o=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Co=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},we={},Cn=class extends ${constructor(e,t,n=Ie){super(r=>{const i=new zt({next:r.next.bind(r),error:r.error.bind(r),complete:Ie});this.refCount++;let s;r.add(()=>{var o;this.refCount--,s.unsubscribe(),this.refCount===0&&(this.currentValue=we,this.subscription&&this.subscription.unsubscribe(),n(),(o=this.subject)==null||o.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new _o),this.promise=null))}),this.subject?(s=this.subject.subscribe(i),this.currentValue!==we&&r.next(this.currentValue)):(this.subject=new Pe,s=this.subject.subscribe(i),this.subscription=null,this.subscription=new zt({next:o=>{this.promise&&o!==Ar&&(this.promise.res(o),this.promise=null),this.subject.next(this.currentValue=o)},error:o=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=we;const a=(c=this.promise)==null?void 0:c.rej;a&&o===Ar&&(this.promise.rej=()=>{a(o)}),u.error(o),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Co),this.promise=null),this.currentValue!==we)return this.subject.complete();if(t===we){const o=this.subject;return this.subject=null,o.error(new Co)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==we&&this.currentValue===we&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ue(this,"subject",null),Ue(this,"subscription",null),Ue(this,"refCount",0),Ue(this,"currentValue",we),Ue(this,"promise",null),Ue(this,"pipeState",(...r)=>{const i=super.pipe(...r);return i instanceof Cn?i:new Cn(i,we)}),Ue(this,"getRefCount",()=>this.refCount),Ue(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==we&&this.currentValue!==Ar)return this.currentValue;if(this.defaultValue!==we)return this.defaultValue;if(this.refCount===0)throw new _o;const r=new Kf((i,s)=>{this.promise={res:i,rej:s,p:null}});return this.promise.p=r,r}),Ue(this,"getDefaultValue",()=>this.defaultValue),t===we&&delete this.getDefaultValue}};function Oo(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function Yf(e,t){const n=new Zf,r=typeof t=="function"?t:()=>t,i=s=>{for(let l=s.length-1;s[l]===void 0&&l>-1;l--)s.splice(-1);const o=[s.length,...s],c=n.get(o);if(c!==void 0)return c;const u=new Cn(e(...s),r(...s),()=>{n.delete(o)}),a=new $(l=>{const d=n.get(o);let h=u;return d?d!==a&&(h=d,Oo(h,a)):n.set(o,f),h.subscribe(l)});Oo(u,a);const f=a;return n.set(o,f),f};return(...s)=>i(s)}var Zf=class{constructor(){Ue(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 i=n.get(e[r]);i||(i=new Map,n.set(e[r],i)),n=i}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let i=0;i<e.length-1;i++)t.push(n=n.get(e[i]));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 Jf(e,t){return new Cn(e,t)}var Ir=(...e)=>(typeof e[0]=="function"?Yf:Jf)(e[0],e.length>1?e[1]:we);const $o=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),i=new Map(e.map(c=>[c.key,c])),s=new Map,o=[];return t.forEach(c=>{const{key:u}=c,a=i.get(u);(!a||a.value!==c.value)&&s.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||o.push(c)}),{deltas:{deleted:o,upserted:[...s.values()]},entries:t.map(({key:c})=>s.get(c)??i.get(c))}},Po=(e,t,n,r=!1)=>{try{let i=r?e:n.blocks.get(e).parent;for(;i&&!t[i];)i=n.blocks.get(i).parent;return i?t[i]:null}catch{return null}},To=(e,t)=>n=>{const{keys:r,value:i}=n.dynamicBuilder.buildStorage(e,t);return s=>(s.dec={value:i.dec(s.value),args:r.dec(s.key)},s)},Qf=(e,t,n)=>{const r=Ir((c,u,a)=>{const f=To(c,u),l=(y,m)=>{const w=no(e,m.hash).pipe(Te(g=>!g),ae(1));return t(m.hash,"closestDescendantMerkleValue",()=>a).pipe(U(g=>g===y?.rootHash?re({...y,block:m,deltas:null,prev:y.block.hash}):t(m.hash,"descendantsValues",()=>a).pipe(n(()=>m.hash),A(([v,k])=>[v,f(k)]),A(([v,k])=>({prev:y&&y.block.hash,rootHash:g,block:m,...$o(y?.entries??[],v,k)})))),Ys(w),wt(g=>g instanceof Wt?ut:Ft(()=>g)))},d=e.pipe(pe((y,m)=>y.finalized===m.finalized),gr(({blocks:y,finalized:m})=>l(null,y.get(m))),ae(1),A(y=>({blocks:{[y.block.hash]:y},finalized:y.block.hash}))),[h,p]=pf(),b=e.pipe(pe((y,m)=>y.best===m.best),Sn(h),gr(([y,m])=>{const{best:w}=y,{blocks:g}=m;let v=g[w]?null:w;if(!v)return ut;const k=Po(v,g,y);return k?l(k,y.blocks.get(v)).pipe(A(S=>(g[v]=S,m))):(v=y.finalized,l(g[m.finalized],y.blocks.get(v)).pipe(A(S=>(S.prev=null,{blocks:{[v]:S},finalized:v}))))}));return fr(d,b).pipe(p())}),i=c=>(u,a,f)=>{const l=r(u,a,f),d=To(u,a),h=c?"finalized":"best";return qt([l.pipe(ml(0)),e.pipe(pe((p,b)=>p[h]===b[h]))]).pipe(A(([p,b])=>Po(b[h],p.blocks,b,!0)),Te(Boolean),pe(),kl(null),wl(),Sn(l),n(([[,p]])=>p.block.hash),A(([[[p,b],y],m])=>[p,b,y,d(m)]),U(([p,b,y,m])=>{if(!p)return[b];let w=b;const g=[];for(;w&&w.block.number>p.block.number;)g.unshift(w),w=w.prev?y.blocks[w.prev]:null;if(c&&(y.finalized=b.block.hash,g.length)){const{blocks:v}=y;Object.keys(v).forEach(k=>{v[k].block.number<g[0].block.number&&delete v[k]})}return p===w?g:[{...b,...p.rootHash===b.rootHash?{entries:p.entries,deltas:null}:$o(p.entries,b.entries,m)}]}))},s=Ir(i(!0)),o=Ir(i(!1));return(c,u,a,f)=>{const l=f?o:s;return e.pipe(ae(1),U(d=>d.runtimes[d.blocks.get(d[f?"best":"finalized"]).runtime].runtime),A(d=>d.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(ae(1),U(d=>l(c,u,d)),A(({block:{hash:d,number:h,parent:p},deltas:b,entries:y},m)=>{const w=m>0?b:{deleted:[],upserted:y};return{block:{hash:d,number:h,parent:p},entries:y.map(Br),deltas:w&&{deleted:w.deleted.map(Br),upserted:w.upserted.map(Br)}}}))}},Br=e=>e.dec,Uo=(e,t,n)=>{const r={},i=b=>new Proxy(r,{get(y,m){return b(m)}}),s=b=>{const y={};return i(m=>(y[m]||(y[m]={}),i(w=>(y[m][w]||(y[m][w]=b(m,w)),y[m][w]))))},o=(b,y)=>b.lookup.metadata.pallets.find(m=>m.name===y),c=Qf(t.pinnedBlocks$,t.storage$,t.withRuntime),u=s((b,y)=>mf(b,y,t,c,Et(e,m=>m.getPalletEntryPoint(xt.Storage,b,y),m=>{const w=o(m,b)?.storage?.items.find(g=>g.name===y);return w==null?null:Na(w)}))),a=(b,y,m,w)=>{if(m==null)return null;const g=b.lookup(m);if(g.type!=="enum")throw new Error("Expected enum");if(g.value[w]==null)return null;const v=tu(g.value[w]);return{args:y==="args"?v:fn,values:y==="args"?fn:v}},f=s((b,y)=>Bo(b,y,t,n,Et(e,m=>m.getPalletEntryPoint(xt.Tx,b,y),m=>a(m,"args",o(m,b)?.calls,y)),!0)),l=s((b,y)=>bf(b,y,t,Et(e,m=>m.getPalletEntryPoint(xt.Event,b,y),m=>a(m,"values",o(m,b)?.events,y)))),d=s((b,y)=>ff(b,y,Et(e,m=>m.getPalletEntryPoint(xt.Const,b,y),m=>{const w=o(m,b)?.constants.find(g=>g.name===y)?.type;return w==null?null:nu(w)}))),h=s((b,y)=>yf(b,y,t,Et(e,m=>m.getApiEntryPoint(b,y),m=>eu(m.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=(b,y)=>{const{lookup:m,dynamicBuilder:w}=br(y).runtime();try{const g=w.buildDefinition(m.call).dec(b.asBytes()),v=g.type,k=g.value.type,S=g.value.value;return Bo(v,k,t,n,Et(e,I=>I.getPalletEntryPoint(xt.Tx,v,k),I=>a(I,"args",o(I,v)?.calls,k)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?p(b,y):e.then(m=>p(b,m)),tx:f,event:l,apis:h,constants:d}};function Nf(e){const t=vu(e),n=sf(t),r=n.chainHead$(),{getChainSpecData:i}=t,s=t.request;let o;const c=new WeakMap,u=l=>{const d=c.get(l)||uf(l,r);return c.set(l,d),d},a=()=>o??(o=lf(r)),{broadcastTx$:f}=n;return{getChainSpecData:i,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Be(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Be(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:l=>Be(r.body$(l)),getBlockHeader:l=>Be(r.header$(l??null)),submit:(...l)=>Io(r,f,...l),submitAndWatch:(...l)=>Sr(r,f,...l),getTypedApi:l=>{const d=u(l);return Object.assign(Uo(d,r,f),{compatibilityToken:d})},getUnsafeApi:()=>{const l=a();return Object.assign(Uo(l,r,f),{runtimeToken:l})},destroy:()=>{r.unfollow(),n.destroy()},_request:s}}me.AccountId=it,me.Binary=je,me.CompatibilityLevel=Ee,me.Enum=Lt,me.FixedSizeBinary=Vn,me.InvalidTxError=Er,me._Enum=Ai,me.createClient=Nf,me.getSs58AddressInfo=Mn});