polkadot-api 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/index.min.js +2 -2
- package/package.json +9 -9
package/dist/umd/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(he,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(he=typeof globalThis<"u"?globalThis:he||self,bt(he.papi={}))})(this,function(he){"use strict";var bt=Object.defineProperty,ds=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pr=(e,t,n)=>(ds(e,typeof t!="symbol"?t+"":t,n),n),xn={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 hs(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|xn[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=xn[e[s]],u=xn[e[s+1]];o[t+i++]=c<<4|u}return o}var yr=class extends Uint8Array{constructor(e){super(e),pr(this,"i",0),pr(this,"v"),this.v=new DataView(e)}},be=e=>t=>e(t instanceof yr?t:new yr(t instanceof Uint8Array?t.buffer:typeof t=="string"?hs(t).buffer:t)),Ae=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 zt(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 Ht=be,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),Vt=(e,t)=>n=>t(e(n)),at=([e,t],n,r)=>M(mt(e,n),Vt(t,r));function ps(e,t){return be(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function ys(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ze(e,t,n){return M(ys(e,n),ps(e,t))}var F=ze(1,"getUint8","setUint8"),Qe=ze(2,"getUint16","setUint16"),xe=ze(4,"getUint32","setUint32"),gt=ze(8,"getBigUint64","setBigUint64"),vs=ze(1,"getInt8","setInt8"),bs=ze(2,"getInt16","setInt16"),ms=ze(4,"getInt32","setInt32"),gs=ze(8,"getBigInt64","setBigInt64"),vr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},br=e=>be(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}),ws=M(vr,br("getBigUint64")),ks=M(vr,br("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},gr=e=>be(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}),xs=M(mr,gr("getBigUint64")),Es=M(mr,gr("getBigInt64")),Ss=at(F,e=>e?1:0,Boolean),As=[F[1],Qe[1],xe[1]],Is=be(e=>{const t=e[e.i],n=t&3;if(n<3)return As[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=gt[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(xe[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(Qe[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(F[1](e))<<s|o),o}),Bs=1n<<56n,_s=1<<24,Cs=256,Os=4294967295n,$s=64,Ts=16384,Ps=1<<30,Us=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<$s)return F[0](t);if(e<Ts)return Qe[0](t|1);if(e<Ps)return xe[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Bs;)n.push(gt[0](r)),r>>=64n;r>=_s&&(n.push(xe[0](Number(r&Os))),r>>=32n);let o=Number(r);o>=Cs&&(n.push(Qe[0](o)),o>>=16),o&&n.push(F[0](o));const i=Ae(n);return i[0]=i.length-5<<2|3,i},q=M(Us,Is),Ls=new TextEncoder,Rs=e=>{const t=Ls.encode(e);return Ae([q.enc(t.length),t])},Ms=new TextDecoder,Ds=be(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Ms.decode(n)}),Q=M(Rs,Ds),zs=()=>{},Hs=new Uint8Array(0),_=M(()=>Hs,zs),wr=e=>e===void 0?t=>Ae([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),kr=e=>be(t=>{const n=e===void 0?q.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Y=e=>M(wr(e),kr(e));Y.enc=wr,Y.dec=kr;var xr=(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})=>Ae([F.enc(o(i)),e[i](s)])},Er=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return be(o=>{const i=F.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},Ie=(e,...t)=>M(xr(zt(e,([n])=>n),...t),Er(zt(e,([,n])=>n),...t));Ie.enc=xr,Ie.dec=Er;var Sr=e=>be(t=>F[1](t)>0?e(t):void 0),Ar=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ae([n,e(t)]))},ee=e=>M(Ar(e[0]),Sr(e[1]));ee.enc=Ar,ee.dec=Sr;var Ir=(e,t)=>be(n=>{const r=F[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Br=(e,t)=>({success:n,value:r})=>Ae([F[0](n?0:1),(n?e:t)(r)]),Ft=(e,t)=>M(Br(e[0],t[0]),Ir(e[1],t[1]));Ft.dec=Ir,Ft.enc=Br;var _r=(...e)=>be(t=>e.map(n=>n(t))),Cr=(...e)=>t=>Ae(e.map((n,r)=>n(t[r]))),ae=(...e)=>M(Cr(...e.map(([t])=>t)),_r(...e.map(([,t])=>t)));ae.enc=Cr,ae.dec=_r;var Or=e=>{const t=Object.keys(e);return mt(ae.enc(...Object.values(e)),n=>t.map(r=>n[r]))},$r=e=>{const t=Object.keys(e);return Vt(ae.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>M(Or(zt(e,t=>t[0])),$r(zt(e,t=>t[1])));$.enc=Or,$.dec=$r;var Tr=(e,t)=>t>=0?n=>Ae(n.map(e)):n=>Ae([q.enc(n.length),Ae(n.map(e))]),Pr=(e,t)=>be(n=>{const r=t>=0?t:q.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),P=(e,t)=>M(Tr(e[0],t),Pr(e[1],t));P.enc=Tr,P.dec=Pr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Fs(...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 js(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function qs(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Ur(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let u=r;u<i.length;u++){const a=i[u],l=t*s+a;if(!Number.isSafeInteger(l)||t*s/t!==s||l-a!==t*s)throw new Error("convertRadix: carry overflow");s=l%n;const h=Math.floor(l/n);if(i[u]=h,!Number.isSafeInteger(h)||h*n+s!==l)throw new Error("convertRadix: carry overflow");if(c)h?c=!1:r=u;else continue}if(o.push(s),c)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function Ws(e){return{encode:t=>{if(!Vs(t))throw new Error("radix.encode input should be Uint8Array");return Ur(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Ur(t,e,2**8))}}}const Lr=(e=>Fs(Ws(58),js(e),qs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function Ne(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Xs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function jt(e,...t){if(!Xs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function wt(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 En(e,t){jt(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 Gs=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),et=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),qt=(e,t)=>e<<32-t|e>>>t,re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Rr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=re?e=>e:e=>Rr(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=Rr(e[t])}function Ks(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function $e(e){return typeof e=="string"&&(e=Ks(e)),jt(e),e}class Mr{clone(){return this._cloneInto()}}function Ys(e){const t=r=>e().update($e(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Zs(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Js(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Qs=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 Dr extends Mr{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,Ne(t),Ne(n),Ne(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 must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=et(this.buffer=new Uint8Array(t))}update(t){wt(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=$e(t);const i=t.length,s=t.byteOffset,c=t.buffer;for(let u=0;u<i;){this.pos===n&&(re||oe(o),this.compress(o,0,!1),re||oe(o),this.pos=0);const a=Math.min(n-this.pos,i-u),l=s+u;if(a===n&&!(l%4)&&u+a<i){const h=new Uint32Array(c,l,Math.floor((i-u)/4));re||oe(h);for(let f=0;u+n<i;f+=o.length,u+=n)this.length+=n,this.compress(h,f,!1);re||oe(h);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){wt(this),En(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),re||oe(r),this.compress(r,0,!0),re||oe(r);const o=et(t);this.get().forEach((i,s)=>o[s]=Oe(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 Wt=BigInt(2**32-1),Sn=BigInt(32);function Xt(e,t=!1){return t?{h:Number(e&Wt),l:Number(e>>Sn&Wt)}:{h:Number(e>>Sn&Wt)|0,l:Number(e&Wt)|0}}function zr(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}=Xt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Ns=(e,t)=>BigInt(e>>>0)<<Sn|BigInt(t>>>0),ec=(e,t,n)=>e>>>n,tc=(e,t,n)=>e<<32-n|t>>>n,nc=(e,t,n)=>e>>>n|t<<32-n,rc=(e,t,n)=>e<<32-n|t>>>n,oc=(e,t,n)=>e<<64-n|t>>>n-32,ic=(e,t,n)=>e>>>n-32|t<<64-n,sc=(e,t)=>t,cc=(e,t)=>e,Hr=(e,t,n)=>e<<n|t>>>32-n,Vr=(e,t,n)=>t<<n|e>>>32-n,Fr=(e,t,n)=>t<<n-32|e>>>64-n,jr=(e,t,n)=>e<<n-32|t>>>64-n;function ac(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ie={fromBig:Xt,split:zr,toBig:Ns,shrSH:ec,shrSL:tc,rotrSH:nc,rotrSL:rc,rotrBH:oc,rotrBL:ic,rotr32H:sc,rotr32L:cc,rotlSH:Hr,rotlSL:Vr,rotlBH:Fr,rotlBL:jr,add:ac,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)},X=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w=new Uint32Array(32);function He(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=w[2*e],a=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],y=w[2*r+1],v=ie.add3L(u,l,s);a=ie.add3H(v,a,h,c),u=v|0,{Dh:y,Dl:p}={Dh:y^a,Dl:p^u},{Dh:y,Dl:p}={Dh:ie.rotr32H(y,p),Dl:ie.rotr32L(y,p)},{h:d,l:f}=ie.add(d,f,y,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrSH(h,l,24),Bl:ie.rotrSL(h,l,24)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=y}function Ve(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=w[2*e],a=w[2*e+1],l=w[2*t],h=w[2*t+1],f=w[2*n],d=w[2*n+1],p=w[2*r],y=w[2*r+1],v=ie.add3L(u,l,s);a=ie.add3H(v,a,h,c),u=v|0,{Dh:y,Dl:p}={Dh:y^a,Dl:p^u},{Dh:y,Dl:p}={Dh:ie.rotrSH(y,p,16),Dl:ie.rotrSL(y,p,16)},{h:d,l:f}=ie.add(d,f,y,p),{Bh:h,Bl:l}={Bh:h^d,Bl:l^f},{Bh:h,Bl:l}={Bh:ie.rotrBH(h,l,63),Bl:ie.rotrBL(h,l,63)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=h,w[2*n]=f,w[2*n+1]=d,w[2*r]=p,w[2*r+1]=y}class uc extends Dr{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=X[0]|0,this.v0h=X[1]|0,this.v1l=X[2]|0,this.v1h=X[3]|0,this.v2l=X[4]|0,this.v2h=X[5]|0,this.v3l=X[6]|0,this.v3h=X[7]|0,this.v4l=X[8]|0,this.v4h=X[9]|0,this.v5l=X[10]|0,this.v5h=X[11]|0,this.v6l=X[12]|0,this.v6h=X[13]|0,this.v7l=X[14]|0,this.v7h=X[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=et($e(t.salt));this.v4l^=Oe(r[0]),this.v4h^=Oe(r[1]),this.v5l^=Oe(r[2]),this.v5h^=Oe(r[3])}if(t.personalization){const r=et($e(t.personalization));this.v6l^=Oe(r[0]),this.v6h^=Oe(r[1]),this.v7l^=Oe(r[2]),this.v7h^=Oe(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set($e(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:l,v5l:h,v5h:f,v6l:d,v6h:p,v7l:y,v7h:v}=this;return[t,n,r,o,i,s,c,u,a,l,h,f,d,p,y,v]}set(t,n,r,o,i,s,c,u,a,l,h,f,d,p,y,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=l|0,this.v5l=h|0,this.v5h=f|0,this.v6l=d|0,this.v6h=p|0,this.v7l=y|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((u,a)=>w[a]=u),w.set(X,16);let{h:o,l:i}=ie.fromBig(BigInt(this.length));w[24]=X[8]^i,w[25]=X[9]^o,r&&(w[28]=~w[28],w[29]=~w[29]);let s=0;const c=Qs;for(let u=0;u<12;u++)He(0,4,8,12,t,n+2*c[s++]),Ve(0,4,8,12,t,n+2*c[s++]),He(1,5,9,13,t,n+2*c[s++]),Ve(1,5,9,13,t,n+2*c[s++]),He(2,6,10,14,t,n+2*c[s++]),Ve(2,6,10,14,t,n+2*c[s++]),He(3,7,11,15,t,n+2*c[s++]),Ve(3,7,11,15,t,n+2*c[s++]),He(0,5,10,15,t,n+2*c[s++]),Ve(0,5,10,15,t,n+2*c[s++]),He(1,6,11,12,t,n+2*c[s++]),Ve(1,6,11,12,t,n+2*c[s++]),He(2,7,8,13,t,n+2*c[s++]),Ve(2,7,8,13,t,n+2*c[s++]),He(3,4,9,14,t,n+2*c[s++]),Ve(3,4,9,14,t,n+2*c[s++]);this.v0l^=w[0]^w[16],this.v0h^=w[1]^w[17],this.v1l^=w[2]^w[18],this.v1h^=w[3]^w[19],this.v2l^=w[4]^w[20],this.v2h^=w[5]^w[21],this.v3l^=w[6]^w[22],this.v3h^=w[7]^w[23],this.v4l^=w[8]^w[24],this.v4h^=w[9]^w[25],this.v5l^=w[10]^w[26],this.v5h^=w[11]^w[27],this.v6l^=w[12]^w[28],this.v6h^=w[13]^w[29],this.v7l^=w[14]^w[30],this.v7h^=w[15]^w[31],w.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 Gt=Zs(e=>new uc(e)),qr=new TextEncoder().encode("SS58PRE"),An=2,In=e=>{try{const t=Lr.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-An),o=t.subarray(n.length+r.length),i=Gt(Uint8Array.of(...qr,...n,...r),{dkLen:64}).subarray(0,An);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:lc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},lc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Wr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Gt(Uint8Array.of(...qr,...t,...n),{dkLen:64}).subarray(0,An);return Lr.encode(Uint8Array.of(...t,...n,...r))}};function fc(e,t){return n=>{const r=In(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 tt=(e=42,t=32)=>at(Y(t),fc(t),Wr(e)),Xr="0123456789abcdef";function se(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Xr[r>>4]+Xr[r&15]}return t.join("")}const Bn={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|Bn[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=Bn[e[s]],u=Bn[e[s+1]];o[t+i++]=c<<4|u}return o}function Kt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const pe=(...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},kt=Function.prototype;class Gr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var dc=Object.defineProperty,Kr=e=>{throw TypeError(e)},hc=(e,t,n)=>t in e?dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xt=(e,t,n)=>hc(e,typeof t!="symbol"?t+"":t,n),Yr=(e,t,n)=>t.has(e)||Kr("Cannot "+n),Te=(e,t,n)=>(Yr(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(e,t,n)=>t.has(e)?Kr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),nt=(e,t,n,r)=>(Yr(e,t,"write to private field"),t.set(e,n),n),Pe,St,Yt,Zt,Jt;const pc=new TextEncoder,yc=new TextDecoder,vc=ae(q,Y(1/0))[1];class Fe{constructor(t,n=!1){if(Et(this,Pe),Et(this,St,null),Et(this,Yt,null),Et(this,Zt,null),Et(this,Jt,null),xt(this,"asText",()=>Te(this,Jt)??nt(this,Jt,yc.decode(Te(this,Pe)))),xt(this,"asHex",()=>Te(this,Yt)||nt(this,Yt,se(Te(this,Pe)))),xt(this,"asOpaqueHex",()=>Te(this,Zt)||nt(this,Zt,se(this.asBytes()))),xt(this,"asBytes",()=>Te(this,Pe)),xt(this,"asOpaqueBytes",()=>Te(this,St)||nt(this,St,pe(q[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=vc(t);if(r===o.length){nt(this,Pe,o),nt(this,St,t);return}}catch{}throw new Error("Invalid opaque bytes")}else nt(this,Pe,t)}static fromText(t){return new this(pc.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)}}Pe=new WeakMap,St=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Jt=new WeakMap;const[bc]=tt();class _n extends Fe{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(bc(t))}}const Zr=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Jr=e=>{const t=Y.dec(e),n=e==null?Fe:_n;return r=>n.fromBytes(t(r))},At=e=>M(Zr(e),Jr(e));At.enc=Zr,At.dec=Jr;const O=q,Qr=q,mc=Ht(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),Nr=M(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},mc),gc=at(F,e=>e.charCodeAt(0),String.fromCharCode),eo=e=>{const t=Y.enc(e);return n=>t(me(n))},to=e=>{const t=Y.dec(e);return n=>se(t(n))},je=e=>M(eo(e),to(e));je.enc=eo,je.dec=to;const wc=new TextEncoder,kc=new TextDecoder,xc=e=>at(Y(e),t=>wc.encode(t),t=>kc.decode(t)),no=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},ro=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},Cn=e=>M(no(()=>e().enc),ro(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),oo=new Proxy({},{get(e,t){return n=>It(t,n)}}),io=(...e)=>{const t=Ie.enc(...e);return n=>t({tag:n.type,value:n.value})},so=(...e)=>{const t=Ie.dec(...e);return n=>{const{tag:r,value:o}=t(n);return It(r,o)}},ge=(e,...t)=>M(io(Kt(e,([n])=>n),...t),so(Kt(e,([,n])=>n),...t));ge.enc=io,ge.dec=so;const co=[],ao=[],uo=[],Ec=BigInt(0),Bt=BigInt(1),Sc=BigInt(2),Ac=BigInt(7),Ic=BigInt(256),Bc=BigInt(113);for(let e=0,t=Bt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],co.push(2*(5*r+n)),ao.push((e+1)*(e+2)/2%64);let o=Ec;for(let i=0;i<7;i++)t=(t<<Bt^(t>>Ac)*Bc)%Ic,t&Sc&&(o^=Bt<<(Bt<<BigInt(i))-Bt);uo.push(o)}const[_c,Cc]=zr(uo,!0),lo=(e,t,n)=>n>32?Fr(e,t,n):Hr(e,t,n),fo=(e,t,n)=>n>32?jr(e,t,n):Vr(e,t,n);function Oc(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],l=n[u+1],h=lo(a,l,1)^n[c],f=fo(a,l,1)^n[c+1];for(let d=0;d<50;d+=10)e[s+d]^=h,e[s+d+1]^=f}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=ao[s],u=lo(o,i,c),a=fo(o,i,c),l=co[s];o=e[l],i=e[l+1],e[l]=u,e[l+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]^=_c[r],e[1]^=Cc[r]}n.fill(0)}class On extends Mr{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,Ne(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=et(this.state)}keccak(){re||oe(this.state32),Oc(this.state32,this.rounds),re||oe(this.state32),this.posOut=0,this.pos=0}update(t){wt(this);const{blockLen:n,state:r}=this;t=$e(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){wt(this,!1),jt(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 Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(En(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 On(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 $c=((e,t,n)=>Ys(()=>new On(t,e,n)))(1,136,256/8),ho=e=>{const t=e.slice(2),n=se($c(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("")}`},Tc=Y(20)[1],po=M(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=se(t);if(e===n||e===n.toUpperCase())return t;if(ho(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ht(e=>ho(se(Tc(e))))),yo=new TextEncoder,vo=new TextDecoder,Pc=at(Y(4),yo.encode.bind(yo),vo.decode.bind(vo)),$n=$({engine:Pc,payload:je()}),Uc=ge({consensus:$n,seal:$n,preRuntime:$n,runtimeUpdated:_},[4,5,6,8]),Tn=je(32),bo=$({parentHash:Tn,number:O,stateRoot:Tn,extrinsicRoot:Tn,digests:P(Uc)}),Ue=P(Q),mo=ee(Q),Lc=Ie({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),go=P($({name:mo,type:O,typeName:mo,docs:Ue})),Rc=$({len:xe,type:O}),Mc=$({bitStoreType:O,bitOrderType:O}),Dc=P($({name:Q,fields:go,index:F,docs:Ue})),zc=Ie({composite:go,variant:Dc,sequence:O,array:Rc,tuple:P(O),primitive:Lc,compact:O,bitSequence:Mc}),Hc=$({name:Q,type:ee(O)}),Vc=P(Hc),Fc=$({id:O,path:Ue,params:Vc,def:zc,docs:Ue}),Pn=P(Fc),jc=Ie({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),qc=P(jc),Wc=$({hashers:qc,key:O,value:O}),Xc=$({name:Q,modifier:F,type:Ie({plain:O,map:Wc}),fallback:je(),docs:Ue}),Gc=ee($({prefix:Q,items:P(Xc)})),wo={name:Q,storage:Gc,calls:ee(O),events:ee(O),constants:P($({name:Q,type:O,value:je(),docs:Ue})),errors:ee(O),index:F},Kc={...wo,docs:Ue},Yc=new Uint8Array,ko=e=>M(()=>Yc,()=>e),Zc=$({type:O,version:F,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),xo=$({lookup:Pn,pallets:P($({...wo,docs:ko([])})),extrinsic:Zc,type:O,apis:ko([])}),Jc=$({name:Q,methods:P($({name:Q,inputs:P($({name:Q,type:O})),output:O,docs:Ue})),docs:Ue}),Qc=$({version:F,address:O,call:O,signature:O,extra:O,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),Eo=$({lookup:Pn,pallets:P($(Kc)),extrinsic:Qc,type:O,apis:P(Jc),outerEnums:$({call:O,event:O,error:O}),custom:P(ae(Q,$({type:O,value:je()})))}),So=()=>{throw new Error("Unsupported metadata version!")},ue=M(So,So),rt=$({magicNumber:xe,metadata:Ie({v0:ue,v1:ue,v2:ue,v3:ue,v4:ue,v5:ue,v6:ue,v7:ue,v8:ue,v9:ue,v10:ue,v11:ue,v12:ue,v13:ue,v14:xo,v15:Eo})}),Un=Y(),Nc=ee(Un),ea=ae(q,Un),Ao=e=>{try{return rt.dec(e)}catch{}try{return rt.dec(Nc.dec(e))}catch{}try{return rt.dec(Un.dec(e))}catch{}try{return rt.dec(ea.dec(e)[1])}catch{}throw null},ta={dkLen:32},Ln=e=>Gt(e,ta),na={dkLen:16},Io=e=>Gt(e,na),Bo=e=>pe(Io(e),e),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function qe(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,16),n=n+r|0,t=qt(t^n,12),{a:e,b:t,c:n,d:r}}function We(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,8),n=n+r|0,t=qt(t^n,7),{a:e,b:t,c:n,d:r}}function _o(e,t,n,r,o,i,s,c,u,a,l,h,f,d,p,y,v,b,m,S){let g=0;for(let x=0;x<r;x++)({a:o,b:u,c:f,d:v}=qe(o,u,f,v,n[t+e[g++]])),{a:o,b:u,c:f,d:v}=We(o,u,f,v,n[t+e[g++]]),{a:i,b:a,c:d,d:b}=qe(i,a,d,b,n[t+e[g++]]),{a:i,b:a,c:d,d:b}=We(i,a,d,b,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=qe(s,l,p,m,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=We(s,l,p,m,n[t+e[g++]]),{a:c,b:h,c:y,d:S}=qe(c,h,y,S,n[t+e[g++]]),{a:c,b:h,c:y,d:S}=We(c,h,y,S,n[t+e[g++]]),{a:o,b:a,c:p,d:S}=qe(o,a,p,S,n[t+e[g++]]),{a:o,b:a,c:p,d:S}=We(o,a,p,S,n[t+e[g++]]),{a:i,b:l,c:y,d:v}=qe(i,l,y,v,n[t+e[g++]]),{a:i,b:l,c:y,d:v}=We(i,l,y,v,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=qe(s,h,f,b,n[t+e[g++]]),{a:s,b:h,c:f,d:b}=We(s,h,f,b,n[t+e[g++]]),{a:c,b:u,c:d,d:m}=qe(c,u,d,m,n[t+e[g++]]),{a:c,b:u,c:d,d:m}=We(c,u,d,m,n[t+e[g++]]);return{v0:o,v1:i,v2:s,v3:c,v4:u,v5:a,v6:l,v7:h,v8:f,v9:d,v10:p,v11:y,v12:v,v13:b,v14:m,v15:S}}const Co=(()=>{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 Rn extends Dr{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,Ne(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=$e(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=et(r),re||oe(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Rn({dkLen:32},32).update(t.context).digest();this.IV=et(r),re||oe(this.IV),this.flags=n|64}else this.IV=Le.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Gs(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:c,l:u}=Xt(BigInt(t),!0),{v0:a,v1:l,v2:h,v3:f,v4:d,v5:p,v6:y,v7:v,v8:b,v9:m,v10:S,v11:g,v12:x,v13:E,v14:A,v15:C}=_o(Co,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],Le[0],Le[1],Le[2],Le[3],c,u,s,n);i[0]=a^b,i[1]=l^m,i[2]=h^S,i[3]=f^g,i[4]=d^x,i[5]=p^E,i[6]=y^A,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(l=>Uint32Array.from(l)),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}=Xt(BigInt(this.chunkOut++));re||oe(o);const{v0:u,v1:a,v2:l,v3:h,v4:f,v5:d,v6:p,v7:y,v8:v,v9:b,v10:m,v11:S,v12:g,v13:x,v14:E,v15:A}=_o(Co,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Le[0],Le[1],Le[2],Le[3],c,s,n,r);i[0]=u^v,i[1]=a^b,i[2]=l^m,i[3]=h^S,i[4]=f^g,i[5]=d^x,i[6]=p^E,i[7]=y^A,i[8]=t[0]^v,i[9]=t[1]^b,i[10]=t[2]^m,i[11]=t[3]^S,i[12]=t[4]^g,i[13]=t[5]^x,i[14]=t[6]^E,i[15]=t[7]^A,re||(oe(o),oe(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,re||oe(this.buffer32),this.compress(this.buffer32,0,!0),re||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){wt(this,!1),jt(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 Ne(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(En(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 ra=Js(e=>new Rn(e)),oa={dkLen:32},Oo=e=>ra(e,oa),ia=e=>pe(Oo(e),e),$o=e=>e,ot=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Mn=2n**64n-1n,te=(e,t)=>e<<t&Mn|e>>64n-t,U=(e,t)=>e*t&Mn,Z=(e,t)=>e+t&Mn,J=11400714785074694791n,ye=14029467366897019727n,To=1609587929392839161n,_t=9650029242287828579n,Po=2870177450012600261n;function Xe(e,t=0n){let n=Z(Z(t,J),ye),r=Z(t,ye),o=t,i=t-J,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 y=p-32;do{let v;v=ot(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=U(te(Z(n,U(v,ye)),31n),J),d+=8,v=ot(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=U(te(Z(r,U(v,ye)),31n),J),d+=8,v=ot(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=U(te(Z(o,U(v,ye)),31n),J),d+=8,v=ot(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=U(te(Z(i,U(v,ye)),31n),J),d+=8}while(d<=y)}d<p&&(u.set(e.subarray(d,p),c),c=p-d)}})(),e=u||e;let a,l=0;for(s>=32?(a=te(n,1n),a=Z(a,te(r,7n)),a=Z(a,te(o,12n)),a=Z(a,te(i,18n)),n=U(te(U(n,ye),31n),J),a=a^n,a=Z(U(a,J),_t),r=U(te(U(r,ye),31n),J),a=a^r,a=Z(U(a,J),_t),o=U(te(U(o,ye),31n),J),a=a^o,a=Z(U(a,J),_t),i=U(te(U(i,ye),31n),J),a=a^i,a=Z(U(a,J),_t)):a=Z(t,Po),a=Z(a,BigInt(s));l<=c-8;){let f=ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=U(te(U(f,ye),31n),J),a=Z(U(te(a^f,27n),J),_t),l+=8}if(l+4<=c){let f=U(ot(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),J);a=Z(U(te(a^f,23n),ye),To),l+=4}for(;l<c;){const f=U(ot(e[l++],0,0,0),Po);a=U(te(a^f,11n),J)}let h=a>>33n;return a=U(a^h,ye),h=a>>29n,a=U(a^h,To),h=a>>32n,a^=h,a}const Dn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),t},sa=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Xe(e),!0),n.setBigUint64(8,Xe(e,1n),!0),n.setBigUint64(16,Xe(e,2n),!0),n.setBigUint64(24,Xe(e,3n),!0),t},Uo=e=>pe(gt.enc(Xe(e)),e),Lo=new TextEncoder,Ro=e=>{const t=Dn(Lo.encode(e));return(n,r,...o)=>{const i=pe(t,Dn(Lo.encode(n))),s=se(i),c=o.map(h=>h[1]).map(h=>{switch(h){case $o:return 0;case Uo:return 8;case Bo:return 16;default:return null}}).filter(h=>h!==null),u=h=>{if(!h.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(c.length!==o.length)throw new Error("Impossible to decode this key");if(o.length===0)return[];const f=h.slice(s.length),d=new Array(o.length);for(let p=0,y=0;p<c.length;p++){const v=o[p][0];y+=c[p],d[p]=v.dec(f.slice(y*2)),y+=v.enc(d[p]).length}return d},a=o.map(([{enc:h},f])=>d=>f(h(d)));return{enc:(...h)=>se(pe(i,...h.map((f,d)=>a[d](f)))),dec:r,keyDecoder:u}}};var Mo=Object.freeze({__proto__:null,AccountId:tt,Bin:At,Binary:Fe,Blake2128:Io,Blake2128Concat:Bo,Blake2256:Ln,Blake3256:Oo,Blake3256Concat:ia,Bytes:Y,Enum:It,FixedSizeBinary:_n,Hex:je,Identity:$o,Option:ee,Result:Ft,ScaleEnum:Ie,Self:Cn,Storage:Ro,Struct:$,Tuple:ae,Twox128:Dn,Twox256:sa,Twox64Concat:Uo,Variant:ge,Vector:P,_Enum:oo,_void:_,bitSequence:Nr,blockHeader:bo,bool:Ss,char:gc,compact:q,compactBn:Qr,compactNumber:O,createCodec:M,createDecoder:Ht,decAnyMetadata:Ao,enhanceCodec:at,enhanceDecoder:Vt,enhanceEncoder:mt,ethAccount:po,fixedStr:xc,fromBufferToBase58:Wr,getSs58AddressInfo:In,h64:Xe,i128:ks,i16:bs,i256:Es,i32:ms,i64:gs,i8:vs,metadata:rt,selfDecoder:ro,selfEncoder:no,str:Q,u128:ws,u16:Qe,u256:xs,u32:xe,u64:gt,u8:F,v14:xo,v14Lookup:Pn,v15:Eo});const it=q,ca=P(ae(Q,it)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},aa=ge(Object.fromEntries(Object.values(R).map(e=>[e,_]))),ua=P(ae(Q,ee(Cn(()=>zn)))),la=P(it),fa=$({typeRef:it,length:ee(it)}),da=ee(q),ha=it,pa=$({ok:it,ko:it}),zn=ge({struct:ca,terminal:aa,enum:ua,tuple:la,array:fa,binary:da,option:ha,result:pa}),ya={i256:R.big,i128:R.big,i64:R.big,i32:R.num,i16:R.num,i8:R.num,u256:R.big,u128:R.big,u64:R.big,u32:R.num,u16:R.num,u8:R.num,bool:R.bool,char:R.str,str:R.str},Ct=e=>({type:"terminal",value:{type:e}});function Ot(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Ct(R.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 Ct(R.bits);case"compact":return Ct(e.isBig?R.big:R.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"?Ot(r.value,t):Ot(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 Ct(ya[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 Ct(R.void)}}function Hn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>Hn(i,s,n),o=i=>{switch(i.value.type){case R.str:case R.big:case R.bool:case R.num:return typeof e===i.value.type;case R.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case R.void:return!0}};switch(t.type){case"terminal":return o(t);case"binary":return e instanceof Fe&&(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,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var va=Object.defineProperty,ba=(e,t,n)=>t in e?va(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ma=(e,t,n)=>ba(e,t+"",n);class Do{constructor(t=[]){ma(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 Be=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Be||{});function Vn(e,t,n,r,o){if(!n&&!e)return le(3);if(!n)return le(2);if(!e)return le(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 Do([[e,n]])}:le(c)}i.set(e,null);const s=ga(e,n,(c,u)=>Vn(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 ga(e,t,n){if(e.type!==t.type)return t.type==="option"?Qt(n(e,t.value),2):e.type==="option"?Qt(n(e.value,t),1):le(0);switch(t.type){case"terminal":return le(t.value.type===e.value.type?3:0);case"binary":return le(Ho(e.value,t.value));case"array":const o=e,i=le(Ho(o.value.length,t.value.length));return Fn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,h=Object.fromEntries(t.value),f=l.value.length===t.value.length?3:2;return Qt(zo(l.value.map(([d,p])=>()=>d in h?n(p,h[d]):le(0))),f)}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 Qt(Fn(t.value.map(([l,h])=>()=>n(c[l],h))),u);case"tuple":{const l=e,h=le(ka(l.value,t.value));return Fn([h,...t.value.map((f,d)=>()=>n(l.value[d],f))])}case"result":const a=e;return zo([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const Qt=(e,t)=>({...e,level:Math.min(e.level,t)}),wa=new Do,le=e=>({level:e,assumptions:wa}),Fn=e=>{let t=le(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},zo=e=>{if(!e.length)return le(3);let t=!1,n=le(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:le(0)},ka=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Ho=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Vo=ge({lookup:q,typedef:zn}),ut=e=>({type:"lookup",value:e}),jn=e=>({type:"typedef",value:e}),Nt=jn({type:"terminal",value:{type:R.void}}),xa=$({args:Vo,values:Vo});function Ea(e){if(e.type.tag==="plain")return{args:Nt,values:ut(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ut(t),values:ut(n)}}function Sa(e){return{args:jn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ut(e.output)}}function Aa(e){return e.type==="lookupEntry"?ut(e.value.id):jn(Ot(e))}function Ia(e){return{args:Nt,values:ut(e)}}function Ba(e,t,n,r,o){const i=(s,c)=>s.type==="lookup"?c(s.value):s.value;return{args:Vn(i(e.args,t),t,i(n.args,r),r,o).level,values:Vn(i(n.values,r),r,i(e.values,t),t,o).level}}function Fo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Hn(n,r,t)}const lt=()=>{},we={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},en={chainName:"",genesisHash:"",properties:""},qn={broadcast:"",stop:""};Object.entries({chainHead:we,chainSpec:en,transaction:qn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const _a=e=>(t,n)=>{let r=e(qn.broadcast,[t],{onSuccess:o=>{r=o===null?lt:()=>{e(qn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class jo extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class tn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class nn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class qo extends Error{constructor(t){super(t),this.name="OperationError"}}class rn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Ca(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Wo=()=>{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)})}}},on=e=>(...t)=>new Promise((n,r)=>{let o=kt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Gr)};s?.addEventListener("abort",c,{once:!0});const u=a=>l=>{o=kt,s?.removeEventListener("abort",c),a(l)};o=e(u(n),u(r),...i)}),Xo=(e,t)=>n=>on((r,o,...i)=>{let s=!0,c=()=>{s=!1};const[u,a]=t(...i);return n(e,u,{onSuccess:(l,h)=>{if(l.result==="limitReached")return o(new nn);const{operationId:f}=l,d=()=>{n(we.stopOperation,[f])};if(!s)return d();let p=lt;const y=b=>{s=!1,p(),r(b)},v=b=>{s=!1,p(),o(b)};p=h(f,{next:b=>{const m=b;m.event==="operationError"?o(new qo(m.error)):m.event==="operationInaccessible"?o(new rn):a(b,y,v)},error:v}),c=()=>{s&&(p(),d())}},onError:o}),()=>{c()}}),Oa=Xo(we.body,e=>[[e],(t,n)=>{n(t.value)}]),$a=Xo(we.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),Ta=e=>t=>new Promise((n,r)=>{e(we.header,[t],{onSuccess:n,onError:r})}),Go=e=>(t,n,r,o,i,s,c)=>{if(n.length===0)return s(),kt;let u=!0,a=()=>{u=!1};return e(we.storage,[t,n,r],{onSuccess:(l,h)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return i(new nn);const{operationId:f}=l,d=()=>{e(we.stopOperation,[f])};if(!u)return d();const p=h(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{v();break}case"operationError":{y(new qo(b.error));break}case"operationInaccessible":{y(new rn);break}default:e(we.continue,[b.operationId])}},error:i});a=()=>{p(),e(we.stopOperation,[l.operationId])};const y=b=>{a=kt,p(),i(b)},v=()=>{a=kt,p(),s()};c(l.discardedItems)},onError:i}),()=>{a()}},Pa=e=>{const t=Go(e);return on((n,r,o,i,s,c)=>{const u=i.startsWith("descendants");let a=u?[]:null;const h=t(o,[{key:s,type:i}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[i]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(h(),r(new nn))});return h})},Ua=e=>t=>t.length>0?new Promise((n,r)=>{e(we.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class sn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function La(e){return e.operationId!==void 0}function Ra(e){return(t,n,r)=>{const o=Wo(),i=new Set,s=Ca();let c=s.promise;const u=p=>{if(La(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:y,...v}=p;return n({type:y,...v})}r(new jo),f(!1)},a=p=>{r(p),f(!(p instanceof sn))},l=(p,y)=>{const v=y(p,{next:u,error:a});f=(b=!0)=>{c=null,f=lt,v(),b&&e(we.unfollow,[p]),o.errorAll(new tn),i.forEach(m=>{m()}),i.clear()},c=p,s.res(p)},h=p=>{p instanceof sn?f(!1):r(p),c=null,s.res(p)};let f=e(we.follow,[t],{onSuccess:l,onError:h});const d=(p,y,v)=>{const b=()=>{v?.onError(new tn)};if(c===null)return b(),lt;const m=g=>{if(!v)return e(p,[g,...y]);i.add(b);const x=(A,C)=>c===null?(C.error(new tn),lt):(o.subscribe(A,C),()=>{o.unsubscribe(A)}),E=e(p,[g,...y],{onSuccess:A=>{i.delete(b),v.onSuccess(A,x)},onError:A=>{i.delete(b),v.onError(A)}});return()=>{i.delete(b),E()}};if(typeof c=="string")return m(c);let S=lt;return c.then(g=>{if(g instanceof Error)return b();c&&(S=m(g))}),()=>{S()}};return{unfollow(){f(),c=null},body:Oa(d),call:$a(d),header:Ta(d),storage:Pa(d),storageSubscription:Go(d),unpin:Ua(d),_request:d}}}var Ma=Object.defineProperty,Da=(e,t,n)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ko=(e,t,n)=>Da(e,typeof t!="symbol"?t+"":t,n);class Yo extends Error{constructor(t){super(t.message),Ko(this,"code"),Ko(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let za=1;const Ha=e=>{let t=za++;const n=new Map,r=Wo();let o=null;const i=(l,h,f)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:h,params:f}))};function s(l){try{let h,f,d,p,y;if({id:h,result:f,error:d,params:p}=JSON.parse(l),h){const m=n.get(h);return m?(n.delete(h),d?m.onError(new Yo(d)):m.onSuccess(f,(S,g)=>{const x=S;return r.subscribe(x,g),()=>{r.unsubscribe(x)}})):void 0}if({subscription:y,result:f,error:d}=p,!y||!d&&!Object.hasOwn(p,"result"))throw 0;const b=y;d?r.error(b,new Yo(d)):r.next(b,f)}catch(h){console.warn("Error parsing incomming message: "+l),console.error(h)}}o=e(s);const c=()=>{o?.disconnect(),o=null,r.errorAll(new sn),n.forEach(l=>l.onError(new sn)),n.clear()};let u=1;return{request:(l,h,f)=>{if(!o)throw new Error("Not connected");const d=`${t}-${u++}`;return f&&n.set(d,f),i(d,l,h),()=>{n.delete(d)}},disconnect:c}},Va=e=>{const t=on((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(en.chainName,[]),t(en.genesisHash,[]),t(en.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},cn=new Map,Fa=e=>{const t=cn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Ha(e),o=()=>{const s=cn.get(e);!s||s.refCount<=1?(cn.delete(e),r()):s.refCount--},i={chainHead:Ra(n),transaction:_a(n),getChainSpecData:Va(n),destroy:o,request:on((s,c,u,a)=>n(u,a,{onSuccess:s,onError:c})),_request:n};return cn.set(e,{client:i,refCount:1}),i};var Wn=function(e,t){return Wn=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])},Wn(e,t)};function Re(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Wn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function ja(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(l){try{a(r.next(l))}catch(h){s(h)}}function u(l){try{a(r.throw(l))}catch(h){s(h)}}function a(l){l.done?i(l.value):o(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Zo(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(l){return u([a,l])}}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(l){a=[6,l],o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ge(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 Ke(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 dt(e){return this instanceof dt?(this.v=e,this):new dt(e)}function qa(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,h)}}function c(d,p){r[d]&&(o[d]=function(y){return new Promise(function(v,b){i.push([d,y,v,b])>1||u(d,y)})},p&&(o[d]=p(o[d])))}function u(d,p){try{a(r[d](p))}catch(y){f(i[0][3],y)}}function a(d){d.value instanceof dt?Promise.resolve(d.value.v).then(l,h):f(i[0][2],d)}function l(d){u("next",d)}function h(d){u("throw",d)}function f(d,p){d(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Wa(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ft=="function"?ft(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(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 z(e){return typeof e=="function"}function Xn(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 Gn=Xn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(he,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(he=typeof globalThis<"u"?globalThis:he||self,bt(he.papi={}))})(this,function(he){"use strict";var bt=Object.defineProperty,ds=(e,t,n)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vr=(e,t,n)=>(ds(e,typeof t!="symbol"?t+"":t,n),n),En={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 hs(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|En[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=En[e[s]],u=En[e[s+1]];o[t+i++]=c<<4|u}return o}var yr=class extends Uint8Array{constructor(e){super(e),vr(this,"i",0),vr(this,"v"),this.v=new DataView(e)}},be=e=>t=>e(t instanceof yr?t:new yr(t instanceof Uint8Array?t.buffer:typeof t=="string"?hs(t).buffer:t)),Ae=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 zt(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 Ht=be,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},mt=(e,t)=>n=>e(t(n)),Ft=(e,t)=>n=>t(e(n)),at=([e,t],n,r)=>M(mt(e,n),Ft(t,r));function ps(e,t){return be(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function vs(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function He(e,t,n){return M(vs(e,n),ps(e,t))}var V=He(1,"getUint8","setUint8"),Ne=He(2,"getUint16","setUint16"),xe=He(4,"getUint32","setUint32"),gt=He(8,"getBigUint64","setBigUint64"),ys=He(1,"getInt8","setInt8"),bs=He(2,"getInt16","setInt16"),ms=He(4,"getInt32","setInt32"),gs=He(8,"getBigInt64","setBigInt64"),br=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},mr=e=>be(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}),ws=M(br,mr("getBigUint64")),ks=M(br,mr("getBigInt64")),gr=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},wr=e=>be(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}),xs=M(gr,wr("getBigUint64")),Es=M(gr,wr("getBigInt64")),Ss=at(V,e=>e?1:0,Boolean),As=[V[1],Ne[1],xe[1]],Is=be(e=>{const t=e[e.i],n=t&3;if(n<3)return As[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=gt[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(xe[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(Ne[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(V[1](e))<<s|o),o}),Bs=1n<<56n,_s=1<<24,Cs=256,Os=4294967295n,$s=64,Ts=16384,Ps=1<<30,Us=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<$s)return V[0](t);if(e<Ts)return Ne[0](t|1);if(e<Ps)return xe[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Bs;)n.push(gt[0](r)),r>>=64n;r>=_s&&(n.push(xe[0](Number(r&Os))),r>>=32n);let o=Number(r);o>=Cs&&(n.push(Ne[0](o)),o>>=16),o&&n.push(V[0](o));const i=Ae(n);return i[0]=i.length-5<<2|3,i},q=M(Us,Is),Ls=new TextEncoder,Rs=e=>{const t=Ls.encode(e);return Ae([q.enc(t.length),t])},Ms=new TextDecoder,Ds=be(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Ms.decode(n)}),Q=M(Rs,Ds),zs=()=>{},Hs=new Uint8Array(0),_=M(()=>Hs,zs),kr=e=>e===void 0?t=>Ae([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),xr=e=>be(t=>{const n=e===void 0?q.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),Y=e=>M(kr(e),xr(e));Y.enc=kr,Y.dec=xr;var Er=(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})=>Ae([V.enc(o(i)),e[i](s)])},Sr=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return be(o=>{const i=V.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},Ie=(e,...t)=>M(Er(zt(e,([n])=>n),...t),Sr(zt(e,([,n])=>n),...t));Ie.enc=Er,Ie.dec=Sr;var Ar=e=>be(t=>V[1](t)>0?e(t):void 0),Ir=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ae([n,e(t)]))},ee=e=>M(Ir(e[0]),Ar(e[1]));ee.enc=Ir,ee.dec=Ar;var Br=(e,t)=>be(n=>{const r=V[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),_r=(e,t)=>({success:n,value:r})=>Ae([V[0](n?0:1),(n?e:t)(r)]),Vt=(e,t)=>M(_r(e[0],t[0]),Br(e[1],t[1]));Vt.dec=Br,Vt.enc=_r;var Cr=(...e)=>be(t=>e.map(n=>n(t))),Or=(...e)=>t=>Ae(e.map((n,r)=>n(t[r]))),ae=(...e)=>M(Or(...e.map(([t])=>t)),Cr(...e.map(([,t])=>t)));ae.enc=Or,ae.dec=Cr;var $r=e=>{const t=Object.keys(e);return mt(ae.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Tr=e=>{const t=Object.keys(e);return Ft(ae.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},$=e=>M($r(zt(e,t=>t[0])),Tr(zt(e,t=>t[1])));$.enc=$r,$.dec=Tr;var Pr=(e,t)=>t>=0?n=>Ae(n.map(e)):n=>Ae([q.enc(n.length),Ae(n.map(e))]),Ur=(e,t)=>be(n=>{const r=t>=0?t:q.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),P=(e,t)=>M(Pr(e[0],t),Ur(e[1],t));P.enc=Pr,P.dec=Ur;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Vs(...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 js(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function qs(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Lr(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let u=r;u<i.length;u++){const a=i[u],f=t*s+a;if(!Number.isSafeInteger(f)||t*s/t!==s||f-a!==t*s)throw new Error("convertRadix: carry overflow");s=f%n;const l=Math.floor(f/n);if(i[u]=l,!Number.isSafeInteger(l)||l*n+s!==f)throw new Error("convertRadix: carry overflow");if(c)l?c=!1:r=u;else continue}if(o.push(s),c)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function Ws(e){return{encode:t=>{if(!Fs(t))throw new Error("radix.encode input should be Uint8Array");return Lr(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Lr(t,e,2**8))}}}const Rr=(e=>Vs(Ws(58),js(e),qs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function et(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Xs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function jt(e,...t){if(!Xs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function wt(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 Sn(e,t){jt(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 Gs=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),tt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),qt=(e,t)=>e<<32-t|e>>>t,re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Mr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=re?e=>e:e=>Mr(e);function oe(e){for(let t=0;t<e.length;t++)e[t]=Mr(e[t])}function Ks(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function $e(e){return typeof e=="string"&&(e=Ks(e)),jt(e),e}class Dr{clone(){return this._cloneInto()}}function Ys(e){const t=r=>e().update($e(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Zs(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Js(e){const t=(r,o)=>e(o).update($e(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Qs=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 zr extends Dr{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,et(t),et(n),et(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 must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=tt(this.buffer=new Uint8Array(t))}update(t){wt(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=$e(t);const i=t.length,s=t.byteOffset,c=t.buffer;for(let u=0;u<i;){this.pos===n&&(re||oe(o),this.compress(o,0,!1),re||oe(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));re||oe(l);for(let d=0;u+n<i;d+=o.length,u+=n)this.length+=n,this.compress(l,d,!1);re||oe(l);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){wt(this),Sn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),re||oe(r),this.compress(r,0,!0),re||oe(r);const o=tt(t);this.get().forEach((i,s)=>o[s]=Oe(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 Wt=BigInt(2**32-1),An=BigInt(32);function Xt(e,t=!1){return t?{h:Number(e&Wt),l:Number(e>>An&Wt)}:{h:Number(e>>An&Wt)|0,l:Number(e&Wt)|0}}function Hr(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}=Xt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Ns=(e,t)=>BigInt(e>>>0)<<An|BigInt(t>>>0),ec=(e,t,n)=>e>>>n,tc=(e,t,n)=>e<<32-n|t>>>n,nc=(e,t,n)=>e>>>n|t<<32-n,rc=(e,t,n)=>e<<32-n|t>>>n,oc=(e,t,n)=>e<<64-n|t>>>n-32,ic=(e,t,n)=>e>>>n-32|t<<64-n,sc=(e,t)=>t,cc=(e,t)=>e,Fr=(e,t,n)=>e<<n|t>>>32-n,Vr=(e,t,n)=>t<<n|e>>>32-n,jr=(e,t,n)=>t<<n-32|e>>>64-n,qr=(e,t,n)=>e<<n-32|t>>>64-n;function ac(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const ie={fromBig:Xt,split:Hr,toBig:Ns,shrSH:ec,shrSL:tc,rotrSH:nc,rotrSL:rc,rotrBH:oc,rotrBL:ic,rotr32H:sc,rotr32L:cc,rotlSH:Fr,rotlSL:Vr,rotlBH:jr,rotlBL:qr,add:ac,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)},X=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w=new Uint32Array(32);function Fe(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=w[2*e],a=w[2*e+1],f=w[2*t],l=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,f,s);a=ie.add3H(y,a,l,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotr32H(v,p),Dl:ie.rotr32L(v,p)},{h,l:d}=ie.add(h,d,v,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:ie.rotrSH(l,f,24),Bl:ie.rotrSL(l,f,24)},w[2*e]=u,w[2*e+1]=a,w[2*t]=f,w[2*t+1]=l,w[2*n]=d,w[2*n+1]=h,w[2*r]=p,w[2*r+1]=v}function Ve(e,t,n,r,o,i){const s=o[i],c=o[i+1];let u=w[2*e],a=w[2*e+1],f=w[2*t],l=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=ie.add3L(u,f,s);a=ie.add3H(y,a,l,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ie.rotrSH(v,p,16),Dl:ie.rotrSL(v,p,16)},{h,l:d}=ie.add(h,d,v,p),{Bh:l,Bl:f}={Bh:l^h,Bl:f^d},{Bh:l,Bl:f}={Bh:ie.rotrBH(l,f,63),Bl:ie.rotrBL(l,f,63)},w[2*e]=u,w[2*e+1]=a,w[2*t]=f,w[2*t+1]=l,w[2*n]=d,w[2*n+1]=h,w[2*r]=p,w[2*r+1]=v}class uc extends zr{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=X[0]|0,this.v0h=X[1]|0,this.v1l=X[2]|0,this.v1h=X[3]|0,this.v2l=X[4]|0,this.v2h=X[5]|0,this.v3l=X[6]|0,this.v3h=X[7]|0,this.v4l=X[8]|0,this.v4h=X[9]|0,this.v5l=X[10]|0,this.v5h=X[11]|0,this.v6l=X[12]|0,this.v6h=X[13]|0,this.v7l=X[14]|0,this.v7h=X[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=tt($e(t.salt));this.v4l^=Oe(r[0]),this.v4h^=Oe(r[1]),this.v5l^=Oe(r[2]),this.v5h^=Oe(r[3])}if(t.personalization){const r=tt($e(t.personalization));this.v6l^=Oe(r[0]),this.v6h^=Oe(r[1]),this.v7l^=Oe(r[2]),this.v7h^=Oe(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set($e(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:d,v6l:h,v6h:p,v7l:v,v7h:y}=this;return[t,n,r,o,i,s,c,u,a,f,l,d,h,p,v,y]}set(t,n,r,o,i,s,c,u,a,f,l,d,h,p,v,y){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=d|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=y|0}compress(t,n,r){this.get().forEach((u,a)=>w[a]=u),w.set(X,16);let{h:o,l:i}=ie.fromBig(BigInt(this.length));w[24]=X[8]^i,w[25]=X[9]^o,r&&(w[28]=~w[28],w[29]=~w[29]);let s=0;const c=Qs;for(let u=0;u<12;u++)Fe(0,4,8,12,t,n+2*c[s++]),Ve(0,4,8,12,t,n+2*c[s++]),Fe(1,5,9,13,t,n+2*c[s++]),Ve(1,5,9,13,t,n+2*c[s++]),Fe(2,6,10,14,t,n+2*c[s++]),Ve(2,6,10,14,t,n+2*c[s++]),Fe(3,7,11,15,t,n+2*c[s++]),Ve(3,7,11,15,t,n+2*c[s++]),Fe(0,5,10,15,t,n+2*c[s++]),Ve(0,5,10,15,t,n+2*c[s++]),Fe(1,6,11,12,t,n+2*c[s++]),Ve(1,6,11,12,t,n+2*c[s++]),Fe(2,7,8,13,t,n+2*c[s++]),Ve(2,7,8,13,t,n+2*c[s++]),Fe(3,4,9,14,t,n+2*c[s++]),Ve(3,4,9,14,t,n+2*c[s++]);this.v0l^=w[0]^w[16],this.v0h^=w[1]^w[17],this.v1l^=w[2]^w[18],this.v1h^=w[3]^w[19],this.v2l^=w[4]^w[20],this.v2h^=w[5]^w[21],this.v3l^=w[6]^w[22],this.v3h^=w[7]^w[23],this.v4l^=w[8]^w[24],this.v4h^=w[9]^w[25],this.v5l^=w[10]^w[26],this.v5h^=w[11]^w[27],this.v6l^=w[12]^w[28],this.v6h^=w[13]^w[29],this.v7l^=w[14]^w[30],this.v7h^=w[15]^w[31],w.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 Gt=Zs(e=>new uc(e)),Wr=new TextEncoder().encode("SS58PRE"),In=2,Bn=e=>{try{const t=Rr.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-In),o=t.subarray(n.length+r.length),i=Gt(Uint8Array.of(...Wr,...n,...r),{dkLen:64}).subarray(0,In);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:lc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},lc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Xr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Gt(Uint8Array.of(...Wr,...t,...n),{dkLen:64}).subarray(0,In);return Rr.encode(Uint8Array.of(...t,...n,...r))}};function fc(e,t){return n=>{const r=Bn(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 nt=(e=42,t=32)=>at(Y(t),fc(t),Xr(e)),Gr="0123456789abcdef";function se(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Gr[r>>4]+Gr[r&15]}return t.join("")}const _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 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|_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}function Kt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const pe=(...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},kt=Function.prototype;class Kr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var dc=Object.defineProperty,Yr=e=>{throw TypeError(e)},hc=(e,t,n)=>t in e?dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xt=(e,t,n)=>hc(e,typeof t!="symbol"?t+"":t,n),Zr=(e,t,n)=>t.has(e)||Yr("Cannot "+n),Te=(e,t,n)=>(Zr(e,t,"read from private field"),n?n.call(e):t.get(e)),Et=(e,t,n)=>t.has(e)?Yr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Zr(e,t,"write to private field"),t.set(e,n),n),Pe,St,Yt,Zt,Jt;const pc=new TextEncoder,vc=new TextDecoder,yc=ae(q,Y(1/0))[1];class je{constructor(t,n=!1){if(Et(this,Pe),Et(this,St,null),Et(this,Yt,null),Et(this,Zt,null),Et(this,Jt,null),xt(this,"asText",()=>Te(this,Jt)??rt(this,Jt,vc.decode(Te(this,Pe)))),xt(this,"asHex",()=>Te(this,Yt)||rt(this,Yt,se(Te(this,Pe)))),xt(this,"asOpaqueHex",()=>Te(this,Zt)||rt(this,Zt,se(this.asBytes()))),xt(this,"asBytes",()=>Te(this,Pe)),xt(this,"asOpaqueBytes",()=>Te(this,St)||rt(this,St,pe(q[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=yc(t);if(r===o.length){rt(this,Pe,o),rt(this,St,t);return}}catch{}throw new Error("Invalid opaque bytes")}else rt(this,Pe,t)}static fromText(t){return new this(pc.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)}}Pe=new WeakMap,St=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Jt=new WeakMap;const[bc]=nt();class Cn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(bc(t))}}const Jr=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Qr=e=>{const t=Y.dec(e),n=e==null?je:Cn;return r=>n.fromBytes(t(r))},At=e=>M(Jr(e),Qr(e));At.enc=Jr,At.dec=Qr;const O=q,Nr=q,mc=Ht(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),eo=M(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},mc),gc=at(V,e=>e.charCodeAt(0),String.fromCharCode),to=e=>{const t=Y.enc(e);return n=>t(me(n))},no=e=>{const t=Y.dec(e);return n=>se(t(n))},qe=e=>M(to(e),no(e));qe.enc=to,qe.dec=no;const wc=new TextEncoder,kc=new TextDecoder,xc=e=>at(Y(e),t=>wc.encode(t),t=>kc.decode(t)),ro=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},oo=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},On=e=>M(ro(()=>e().enc),oo(()=>e().dec)),It=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),io=new Proxy({},{get(e,t){return n=>It(t,n)}}),so=(...e)=>{const t=Ie.enc(...e);return n=>t({tag:n.type,value:n.value})},co=(...e)=>{const t=Ie.dec(...e);return n=>{const{tag:r,value:o}=t(n);return It(r,o)}},ge=(e,...t)=>M(so(Kt(e,([n])=>n),...t),co(Kt(e,([,n])=>n),...t));ge.enc=so,ge.dec=co;const ao=[],uo=[],lo=[],Ec=BigInt(0),Bt=BigInt(1),Sc=BigInt(2),Ac=BigInt(7),Ic=BigInt(256),Bc=BigInt(113);for(let e=0,t=Bt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ao.push(2*(5*r+n)),uo.push((e+1)*(e+2)/2%64);let o=Ec;for(let i=0;i<7;i++)t=(t<<Bt^(t>>Ac)*Bc)%Ic,t&Sc&&(o^=Bt<<(Bt<<BigInt(i))-Bt);lo.push(o)}const[_c,Cc]=Hr(lo,!0),fo=(e,t,n)=>n>32?jr(e,t,n):Fr(e,t,n),ho=(e,t,n)=>n>32?qr(e,t,n):Vr(e,t,n);function Oc(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=fo(a,f,1)^n[c],d=ho(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[s+h]^=l,e[s+h+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=uo[s],u=fo(o,i,c),a=ho(o,i,c),f=ao[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]^=_c[r],e[1]^=Cc[r]}n.fill(0)}class $n extends Dr{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,et(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=tt(this.state)}keccak(){re||oe(this.state32),Oc(this.state32,this.rounds),re||oe(this.state32),this.posOut=0,this.pos=0}update(t){wt(this);const{blockLen:n,state:r}=this;t=$e(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){wt(this,!1),jt(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 et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Sn(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 $n(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 $c=((e,t,n)=>Ys(()=>new $n(t,e,n)))(1,136,256/8),po=e=>{const t=e.slice(2),n=se($c(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("")}`},Tc=Y(20)[1],vo=M(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=se(t);if(e===n||e===n.toUpperCase())return t;if(po(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ht(e=>po(se(Tc(e))))),yo=new TextEncoder,bo=new TextDecoder,Pc=at(Y(4),yo.encode.bind(yo),bo.decode.bind(bo)),Tn=$({engine:Pc,payload:qe()}),Uc=ge({consensus:Tn,seal:Tn,preRuntime:Tn,runtimeUpdated:_},[4,5,6,8]),Pn=qe(32),mo=$({parentHash:Pn,number:O,stateRoot:Pn,extrinsicRoot:Pn,digests:P(Uc)}),Ue=P(Q),go=ee(Q),Lc=Ie({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),wo=P($({name:go,type:O,typeName:go,docs:Ue})),Rc=$({len:xe,type:O}),Mc=$({bitStoreType:O,bitOrderType:O}),Dc=P($({name:Q,fields:wo,index:V,docs:Ue})),zc=Ie({composite:wo,variant:Dc,sequence:O,array:Rc,tuple:P(O),primitive:Lc,compact:O,bitSequence:Mc}),Hc=$({name:Q,type:ee(O)}),Fc=P(Hc),Vc=$({id:O,path:Ue,params:Fc,def:zc,docs:Ue}),Un=P(Vc),jc=Ie({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),qc=P(jc),Wc=$({hashers:qc,key:O,value:O}),Xc=$({name:Q,modifier:V,type:Ie({plain:O,map:Wc}),fallback:qe(),docs:Ue}),Gc=ee($({prefix:Q,items:P(Xc)})),ko={name:Q,storage:Gc,calls:ee(O),events:ee(O),constants:P($({name:Q,type:O,value:qe(),docs:Ue})),errors:ee(O),index:V},Kc={...ko,docs:Ue},Yc=new Uint8Array,xo=e=>M(()=>Yc,()=>e),Zc=$({type:O,version:V,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),Eo=$({lookup:Un,pallets:P($({...ko,docs:xo([])})),extrinsic:Zc,type:O,apis:xo([])}),Jc=$({name:Q,methods:P($({name:Q,inputs:P($({name:Q,type:O})),output:O,docs:Ue})),docs:Ue}),Qc=$({version:V,address:O,call:O,signature:O,extra:O,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),So=$({lookup:Un,pallets:P($(Kc)),extrinsic:Qc,type:O,apis:P(Jc),outerEnums:$({call:O,event:O,error:O}),custom:P(ae(Q,$({type:O,value:qe()})))}),Ao=()=>{throw new Error("Unsupported metadata version!")},ue=M(Ao,Ao),ot=$({magicNumber:xe,metadata:Ie({v0:ue,v1:ue,v2:ue,v3:ue,v4:ue,v5:ue,v6:ue,v7:ue,v8:ue,v9:ue,v10:ue,v11:ue,v12:ue,v13:ue,v14:Eo,v15:So})}),Ln=Y(),Nc=ee(Ln),ea=ae(q,Ln),Io=e=>{try{return ot.dec(e)}catch{}try{return ot.dec(Nc.dec(e))}catch{}try{return ot.dec(Ln.dec(e))}catch{}try{return ot.dec(ea.dec(e)[1])}catch{}throw null},ta={dkLen:32},Rn=e=>Gt(e,ta),na={dkLen:16},Bo=e=>Gt(e,na),_o=e=>pe(Bo(e),e),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function We(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,16),n=n+r|0,t=qt(t^n,12),{a:e,b:t,c:n,d:r}}function Xe(e,t,n,r,o){return e=e+t+o|0,r=qt(r^e,8),n=n+r|0,t=qt(t^n,7),{a:e,b:t,c:n,d:r}}function Co(e,t,n,r,o,i,s,c,u,a,f,l,d,h,p,v,y,b,m,S){let g=0;for(let x=0;x<r;x++)({a:o,b:u,c:d,d:y}=We(o,u,d,y,n[t+e[g++]])),{a:o,b:u,c:d,d:y}=Xe(o,u,d,y,n[t+e[g++]]),{a:i,b:a,c:h,d:b}=We(i,a,h,b,n[t+e[g++]]),{a:i,b:a,c:h,d:b}=Xe(i,a,h,b,n[t+e[g++]]),{a:s,b:f,c:p,d:m}=We(s,f,p,m,n[t+e[g++]]),{a:s,b:f,c:p,d:m}=Xe(s,f,p,m,n[t+e[g++]]),{a:c,b:l,c:v,d:S}=We(c,l,v,S,n[t+e[g++]]),{a:c,b:l,c:v,d:S}=Xe(c,l,v,S,n[t+e[g++]]),{a:o,b:a,c:p,d:S}=We(o,a,p,S,n[t+e[g++]]),{a:o,b:a,c:p,d:S}=Xe(o,a,p,S,n[t+e[g++]]),{a:i,b:f,c:v,d:y}=We(i,f,v,y,n[t+e[g++]]),{a:i,b:f,c:v,d:y}=Xe(i,f,v,y,n[t+e[g++]]),{a:s,b:l,c:d,d:b}=We(s,l,d,b,n[t+e[g++]]),{a:s,b:l,c:d,d:b}=Xe(s,l,d,b,n[t+e[g++]]),{a:c,b:u,c:h,d:m}=We(c,u,h,m,n[t+e[g++]]),{a:c,b:u,c:h,d:m}=Xe(c,u,h,m,n[t+e[g++]]);return{v0:o,v1:i,v2:s,v3:c,v4:u,v5:a,v6:f,v7:l,v8:d,v9:h,v10:p,v11:v,v12:y,v13:b,v14:m,v15:S}}const Oo=(()=>{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 Mn extends zr{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,et(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=$e(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=tt(r),re||oe(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Mn({dkLen:32},32).update(t.context).digest();this.IV=tt(r),re||oe(this.IV),this.flags=n|64}else this.IV=Le.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Gs(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:c,l:u}=Xt(BigInt(t),!0),{v0:a,v1:f,v2:l,v3:d,v4:h,v5:p,v6:v,v7:y,v8:b,v9:m,v10:S,v11:g,v12:x,v13:E,v14:A,v15:C}=Co(Oo,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],Le[0],Le[1],Le[2],Le[3],c,u,s,n);i[0]=a^b,i[1]=f^m,i[2]=l^S,i[3]=d^g,i[4]=h^x,i[5]=p^E,i[6]=v^A,i[7]=y^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}=Xt(BigInt(this.chunkOut++));re||oe(o);const{v0:u,v1:a,v2:f,v3:l,v4:d,v5:h,v6:p,v7:v,v8:y,v9:b,v10:m,v11:S,v12:g,v13:x,v14:E,v15:A}=Co(Oo,0,o,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Le[0],Le[1],Le[2],Le[3],c,s,n,r);i[0]=u^y,i[1]=a^b,i[2]=f^m,i[3]=l^S,i[4]=d^g,i[5]=h^x,i[6]=p^E,i[7]=v^A,i[8]=t[0]^y,i[9]=t[1]^b,i[10]=t[2]^m,i[11]=t[3]^S,i[12]=t[4]^g,i[13]=t[5]^x,i[14]=t[6]^E,i[15]=t[7]^A,re||(oe(o),oe(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,re||oe(this.buffer32),this.compress(this.buffer32,0,!0),re||oe(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){wt(this,!1),jt(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 et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Sn(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 ra=Js(e=>new Mn(e)),oa={dkLen:32},$o=e=>ra(e,oa),ia=e=>pe($o(e),e),To=e=>e,it=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Dn=2n**64n-1n,te=(e,t)=>e<<t&Dn|e>>64n-t,U=(e,t)=>e*t&Dn,Z=(e,t)=>e+t&Dn,J=11400714785074694791n,ve=14029467366897019727n,Po=1609587929392839161n,_t=9650029242287828579n,Uo=2870177450012600261n;function Ge(e,t=0n){let n=Z(Z(t,J),ve),r=Z(t,ve),o=t,i=t-J,s=e.length,c=0,u=null;(function(){let h=0,p=h+s;if(s){if(u=new Uint8Array(32),s<32){u.set(e.subarray(0,s),c),c+=s;return}if(h<=p-32){const v=p-32;do{let y;y=it(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=U(te(Z(n,U(y,ve)),31n),J),h+=8,y=it(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=U(te(Z(r,U(y,ve)),31n),J),h+=8,y=it(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),o=U(te(Z(o,U(y,ve)),31n),J),h+=8,y=it(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=U(te(Z(i,U(y,ve)),31n),J),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,f=0;for(s>=32?(a=te(n,1n),a=Z(a,te(r,7n)),a=Z(a,te(o,12n)),a=Z(a,te(i,18n)),n=U(te(U(n,ve),31n),J),a=a^n,a=Z(U(a,J),_t),r=U(te(U(r,ve),31n),J),a=a^r,a=Z(U(a,J),_t),o=U(te(U(o,ve),31n),J),a=a^o,a=Z(U(a,J),_t),i=U(te(U(i,ve),31n),J),a=a^i,a=Z(U(a,J),_t)):a=Z(t,Uo),a=Z(a,BigInt(s));f<=c-8;){let d=it(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=U(te(U(d,ve),31n),J),a=Z(U(te(a^d,27n),J),_t),f+=8}if(f+4<=c){let d=U(it(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),J);a=Z(U(te(a^d,23n),ve),Po),f+=4}for(;f<c;){const d=U(it(e[f++],0,0,0),Uo);a=U(te(a^d,11n),J)}let l=a>>33n;return a=U(a^l,ve),l=a>>29n,a=U(a^l,Po),l=a>>32n,a^=l,a}const zn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,Ge(e),!0),n.setBigUint64(8,Ge(e,1n),!0),t},sa=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,Ge(e),!0),n.setBigUint64(8,Ge(e,1n),!0),n.setBigUint64(16,Ge(e,2n),!0),n.setBigUint64(24,Ge(e,3n),!0),t},Lo=e=>pe(gt.enc(Ge(e)),e),Ro=new TextEncoder,Mo=e=>{const t=zn(Ro.encode(e));return(n,r,...o)=>{const i=pe(t,zn(Ro.encode(n))),s=se(i),c=o.map(l=>l[1]).map(l=>{switch(l){case To:return 0;case Lo:return 8;case _o:return 16;default:return null}}).filter(l=>l!==null),u=l=>{if(!l.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(c.length!==o.length)throw new Error("Impossible to decode this key");if(o.length===0)return[];const d=l.slice(s.length),h=new Array(o.length);for(let p=0,v=0;p<c.length;p++){const y=o[p][0];v+=c[p],h[p]=y.dec(d.slice(v*2)),v+=y.enc(h[p]).length}return h},a=o.map(([{enc:l},d])=>h=>d(l(h)));return{enc:(...l)=>se(pe(i,...l.map((d,h)=>a[h](d)))),dec:r,keyDecoder:u}}};var Do=Object.freeze({__proto__:null,AccountId:nt,Bin:At,Binary:je,Blake2128:Bo,Blake2128Concat:_o,Blake2256:Rn,Blake3256:$o,Blake3256Concat:ia,Bytes:Y,Enum:It,FixedSizeBinary:Cn,Hex:qe,Identity:To,Option:ee,Result:Vt,ScaleEnum:Ie,Self:On,Storage:Mo,Struct:$,Tuple:ae,Twox128:zn,Twox256:sa,Twox64Concat:Lo,Variant:ge,Vector:P,_Enum:io,_void:_,bitSequence:eo,blockHeader:mo,bool:Ss,char:gc,compact:q,compactBn:Nr,compactNumber:O,createCodec:M,createDecoder:Ht,decAnyMetadata:Io,enhanceCodec:at,enhanceDecoder:Ft,enhanceEncoder:mt,ethAccount:vo,fixedStr:xc,fromBufferToBase58:Xr,getSs58AddressInfo:Bn,h64:Ge,i128:ks,i16:bs,i256:Es,i32:ms,i64:gs,i8:ys,metadata:ot,selfDecoder:oo,selfEncoder:ro,str:Q,u128:ws,u16:Ne,u256:xs,u32:xe,u64:gt,u8:V,v14:Eo,v14Lookup:Un,v15:So});const st=q,ca=P(ae(Q,st)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},aa=ge(Object.fromEntries(Object.values(R).map(e=>[e,_]))),ua=P(ae(Q,ee(On(()=>Hn)))),la=P(st),fa=$({typeRef:st,length:ee(st)}),da=ee(q),ha=st,pa=$({ok:st,ko:st}),Hn=ge({struct:ca,terminal:aa,enum:ua,tuple:la,array:fa,binary:da,option:ha,result:pa}),va={i256:R.big,i128:R.big,i64:R.big,i32:R.num,i16:R.num,i8:R.num,u256:R.big,u128:R.big,u64:R.big,u32:R.num,u16:R.num,u8:R.num,bool:R.bool,char:R.str,str:R.str},Ct=e=>({type:"terminal",value:{type:e}});function Ot(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Ct(R.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 Ct(R.bits);case"compact":return Ct(e.isBig?R.big:R.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"?Ot(r.value,t):Ot(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 Ct(va[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 Ct(R.void)}}function Fn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>Fn(i,s,n),o=i=>{switch(i.value.type){case R.str:case R.big:case R.bool:case R.num:return typeof e===i.value.type;case R.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case R.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,ba=(e,t,n)=>t in e?ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ma=(e,t,n)=>ba(e,t+"",n);class zo{constructor(t=[]){ma(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 Be=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Be||{});function Vn(e,t,n,r,o){if(!n&&!e)return le(3);if(!n)return le(2);if(!e)return le(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 zo([[e,n]])}:le(c)}i.set(e,null);const s=ga(e,n,(c,u)=>Vn(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 ga(e,t,n){if(e.type!==t.type)return t.type==="option"?Qt(n(e,t.value),2):e.type==="option"?Qt(n(e.value,t),1):le(0);switch(t.type){case"terminal":return le(t.value.type===e.value.type?3:0);case"binary":return le(Fo(e.value,t.value));case"array":const o=e,i=le(Fo(o.value.length,t.value.length));return jn([i,()=>n(o.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 Qt(Ho(f.value.map(([h,p])=>()=>h in l?n(p,l[h]):le(0))),d)}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 Qt(jn(t.value.map(([f,l])=>()=>n(c[f],l))),u);case"tuple":{const f=e,l=le(ka(f.value,t.value));return jn([l,...t.value.map((d,h)=>()=>n(f.value[h],d))])}case"result":const a=e;return Ho([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const Qt=(e,t)=>({...e,level:Math.min(e.level,t)}),wa=new zo,le=e=>({level:e,assumptions:wa}),jn=e=>{let t=le(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},Ho=e=>{if(!e.length)return le(3);let t=!1,n=le(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:le(0)},ka=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Fo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Vo=ge({lookup:q,typedef:Hn}),ut=e=>({type:"lookup",value:e}),qn=e=>({type:"typedef",value:e}),Nt=qn({type:"terminal",value:{type:R.void}}),xa=$({args:Vo,values:Vo});function Ea(e){if(e.type.tag==="plain")return{args:Nt,values:ut(e.type.value)};const{key:t,value:n}=e.type.value;return{args:ut(t),values:ut(n)}}function Sa(e){return{args:qn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:ut(e.output)}}function Aa(e){return e.type==="lookupEntry"?ut(e.value.id):qn(Ot(e))}function Ia(e){return{args:Nt,values:ut(e)}}function Ba(e,t,n,r,o){const i=(s,c)=>s.type==="lookup"?c(s.value):s.value;return{args:Vn(i(e.args,t),t,i(n.args,r),r,o).level,values:Vn(i(n.values,r),r,i(e.values,t),t,o).level}}function jo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Fn(n,r,t)}const lt=()=>{},we={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},en={chainName:"",genesisHash:"",properties:""},Wn={broadcast:"",stop:""};Object.entries({chainHead:we,chainSpec:en,transaction:Wn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const _a=e=>(t,n)=>{let r=e(Wn.broadcast,[t],{onSuccess:o=>{r=o===null?lt:()=>{e(Wn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class qo extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class tn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class nn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Wo extends Error{constructor(t){super(t),this.name="OperationError"}}class rn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Ca(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Xo=()=>{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)})}}},on=e=>(...t)=>new Promise((n,r)=>{let o=kt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Kr)};s?.addEventListener("abort",c,{once:!0});const u=a=>f=>{o=kt,s?.removeEventListener("abort",c),a(f)};o=e(u(n),u(r),...i)}),Go=(e,t)=>n=>on((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 nn);const{operationId:d}=f,h=()=>{n(we.stopOperation,[d])};if(!s)return h();let p=lt;const v=b=>{s=!1,p(),r(b)},y=b=>{s=!1,p(),o(b)};p=l(d,{next:b=>{const m=b;m.event==="operationError"?o(new Wo(m.error)):m.event==="operationInaccessible"?o(new rn):a(b,v,y)},error:y}),c=()=>{s&&(p(),h())}},onError:o}),()=>{c()}}),Oa=Go(we.body,e=>[[e],(t,n)=>{n(t.value)}]),$a=Go(we.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),Ta=e=>t=>new Promise((n,r)=>{e(we.header,[t],{onSuccess:n,onError:r})}),Ko=e=>(t,n,r,o,i,s,c)=>{if(n.length===0)return s(),kt;let u=!0,a=()=>{u=!1};return e(we.storage,[t,n,r],{onSuccess:(f,l)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return i(new nn);const{operationId:d}=f,h=()=>{e(we.stopOperation,[d])};if(!u)return h();const p=l(f.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{y();break}case"operationError":{v(new Wo(b.error));break}case"operationInaccessible":{v(new rn);break}default:e(we.continue,[b.operationId])}},error:i});a=()=>{p(),e(we.stopOperation,[f.operationId])};const v=b=>{a=kt,p(),i(b)},y=()=>{a=kt,p(),s()};c(f.discardedItems)},onError:i}),()=>{a()}},Pa=e=>{const t=Ko(e);return on((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?d=>{a.push(d)}:d=>{a=d[0]?.[i]},r,()=>{try{n(u?a.flat():a)}catch(d){r(d)}},d=>{d>0&&(l(),r(new nn))});return l})},Ua=e=>t=>t.length>0?new Promise((n,r)=>{e(we.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class sn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function La(e){return e.operationId!==void 0}function Ra(e){return(t,n,r)=>{const o=Xo(),i=new Set,s=Ca();let c=s.promise;const u=p=>{if(La(p))return o.has(p.operationId)||console.warn("Uknown operationId on",p),o.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...y}=p;return n({type:v,...y})}r(new qo),d(!1)},a=p=>{r(p),d(!(p instanceof sn))},f=(p,v)=>{const y=v(p,{next:u,error:a});d=(b=!0)=>{c=null,d=lt,y(),b&&e(we.unfollow,[p]),o.errorAll(new tn),i.forEach(m=>{m()}),i.clear()},c=p,s.res(p)},l=p=>{p instanceof sn?d(!1):r(p),c=null,s.res(p)};let d=e(we.follow,[t],{onSuccess:f,onError:l});const h=(p,v,y)=>{const b=()=>{y?.onError(new tn)};if(c===null)return b(),lt;const m=g=>{if(!y)return e(p,[g,...v]);i.add(b);const x=(A,C)=>c===null?(C.error(new tn),lt):(o.subscribe(A,C),()=>{o.unsubscribe(A)}),E=e(p,[g,...v],{onSuccess:A=>{i.delete(b),y.onSuccess(A,x)},onError:A=>{i.delete(b),y.onError(A)}});return()=>{i.delete(b),E()}};if(typeof c=="string")return m(c);let S=lt;return c.then(g=>{if(g instanceof Error)return b();c&&(S=m(g))}),()=>{S()}};return{unfollow(){d(),c=null},body:Oa(h),call:$a(h),header:Ta(h),storage:Pa(h),storageSubscription:Ko(h),unpin:Ua(h),_request:h}}}var Ma=Object.defineProperty,Da=(e,t,n)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yo=(e,t,n)=>Da(e,typeof t!="symbol"?t+"":t,n);class Zo extends Error{constructor(t){super(t.message),Yo(this,"code"),Yo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let za=1;const Ha=e=>{let t=za++;const n=new Map,r=Xo();let o=null;const i=(f,l,d)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:l,params:d}))};function s(f){try{let l,d,h,p,v;if({id:l,result:d,error:h,params:p}=JSON.parse(f),l){const m=n.get(l);return m?(n.delete(l),h?m.onError(new Zo(h)):m.onSuccess(d,(S,g)=>{const x=S;return r.subscribe(x,g),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:d,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const b=v;h?r.error(b,new Zo(h)):r.next(b,d)}catch(l){console.warn("Error parsing incomming message: "+f),console.error(l)}}o=e(s);const c=()=>{o?.disconnect(),o=null,r.errorAll(new sn),n.forEach(f=>f.onError(new sn)),n.clear()};let u=1;return{request:(f,l,d)=>{if(!o)throw new Error("Not connected");const h=`${t}-${u++}`;return d&&n.set(h,d),i(h,f,l),()=>{n.delete(h)}},disconnect:c}},Fa=e=>{const t=on((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(en.chainName,[]),t(en.genesisHash,[]),t(en.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},cn=new Map,Va=e=>{const t=cn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Ha(e),o=()=>{const s=cn.get(e);!s||s.refCount<=1?(cn.delete(e),r()):s.refCount--},i={chainHead:Ra(n),transaction:_a(n),getChainSpecData:Fa(n),destroy:o,request:on((s,c,u,a)=>n(u,a,{onSuccess:s,onError:c})),_request:n};return cn.set(e,{client:i,refCount:1}),i};var Xn=function(e,t){return Xn=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])},Xn(e,t)};function Re(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Xn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function ja(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 Jo(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 ft(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ke(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 Ye(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 dt(e){return this instanceof dt?(this.v=e,this):new dt(e)}function qa(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(h){return function(p){return Promise.resolve(p).then(h,l)}}function c(h,p){r[h]&&(o[h]=function(v){return new Promise(function(y,b){i.push([h,v,y,b])>1||u(h,v)})},p&&(o[h]=p(o[h])))}function u(h,p){try{a(r[h](p))}catch(v){d(i[0][3],v)}}function a(h){h.value instanceof dt?Promise.resolve(h.value.v).then(f,l):d(i[0][2],h)}function f(h){u("next",h)}function l(h){u("throw",h)}function d(h,p){h(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Wa(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ft=="function"?ft(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(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 z(e){return typeof e=="function"}function Gn(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 Kn=Gn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function an(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var st=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,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=ft(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(y){t={error:y}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else s.remove(this);var l=this.initialTeardown;if(z(l))try{l()}catch(y){i=y instanceof Gn?y.errors:[y]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var f=ft(h),d=f.next();!d.done;d=f.next()){var p=d.value;try{No(p)}catch(y){i=i??[],y instanceof Gn?i=Ke(Ke([],Ge(i)),Ge(y.errors)):i.push(y)}}}catch(y){r={error:y}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}if(i)throw new Gn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)No(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)&&an(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&an(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Jo=st.EMPTY;function Qo(e){return e instanceof st||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function No(e){z(e)?e():e.unsubscribe()}var ei={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Xa={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ke([e,t],Ge(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ti(e){Xa.setTimeout(function(){throw e})}function ct(){}function un(e){e()}var Kn=function(e){Re(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Qo(n)&&n.add(r)):r.destination=Za,r}return t.create=function(n,r,o){return new ht(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}(st),Ga=Function.prototype.bind;function Yn(e,t){return Ga.call(e,t)}var Ka=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){ln(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){ln(r)}else ln(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){ln(n)}},e}(),ht=function(e){Re(t,e);function t(n,r,o){var i=e.call(this)||this,s;if(z(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&&Yn(n.next,c),error:n.error&&Yn(n.error,c),complete:n.complete&&Yn(n.complete,c)}):s=n}return i.destination=new Ka(s),i}return t}(Kn);function ln(e){ti(e)}function Ya(e){throw e}var Za={closed:!0,next:ct,error:Ya,complete:ct},Zn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ye(e){return e}function ni(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ri(e)}function ri(e){return e.length===0?Ye:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=Qa(t)?t:new ht(t,n,r);return un(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=oi(n),new n(function(o,i){var s=new ht({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[Zn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ri(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=oi(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 oi(e){var t;return(t=e??ei.Promise)!==null&&t!==void 0?t:Promise}function Ja(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Qa(e){return e&&e instanceof Kn||Ja(e)&&Qo(e)}function Na(e){return z(e?.lift)}function N(e){return function(t){if(Na(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 W(e,t,n,r,o){return new eu(e,t,n,r,o)}var eu=function(e){Re(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(l){n.error(l)}}:e.prototype._next,u._error=i?function(a){try{i(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(a){n.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Kn),tu=Xn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),fn=function(e){Re(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 ii(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new tu},t.prototype.next=function(n){var r=this;un(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ft(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;un(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;un(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?Jo:(this.currentObservers=null,c.push(n),new st(function(){r.currentObservers=null,an(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 T;return n.source=this,n},t.create=function(n,r){return new ii(n,r)},t}(T),ii=function(e){Re(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:Jo},t}(fn),Jn={now:function(){return(Jn.delegate||Date).now()},delegate:void 0},dn=function(e){Re(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Jn);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,l=1;l<i.length&&i[l]<=u;l+=2)a=l;a&&i.splice(0,a+1)}},t}(fn),nu=function(e){Re(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(st),si={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ke([e,t],Ge(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ru=function(e){Re(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),si.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&&si.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,an(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(nu),ci=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=Jn.now,e}(),ou=function(e){Re(t,e);function t(n,r){r===void 0&&(r=ci.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}(ci),ai=new ou(ru),iu=ai,$t=new T(function(e){return e.complete()});function su(e){return e&&z(e.schedule)}function Qn(e){return e[e.length-1]}function ui(e){return z(Qn(e))?e.pop():void 0}function hn(e){return su(Qn(e))?e.pop():void 0}function cu(e,t){return typeof Qn(e)=="number"?e.pop():t}var li=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function fi(e){return z(e?.then)}function di(e){return z(e[Zn])}function hi(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function pi(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 au(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var yi=au();function vi(e){return z(e?.[yi])}function bi(e){return qa(this,arguments,function(){var n,r,o,i;return Zo(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,dt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,dt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,dt(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 mi(e){return z(e?.getReader)}function fe(e){if(e instanceof T)return e;if(e!=null){if(di(e))return uu(e);if(li(e))return lu(e);if(fi(e))return fu(e);if(hi(e))return gi(e);if(vi(e))return du(e);if(mi(e))return hu(e)}throw pi(e)}function uu(e){return new T(function(t){var n=e[Zn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function lu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function fu(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ti)})}function du(e){return new T(function(t){var n,r;try{for(var o=ft(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 gi(e){return new T(function(t){pu(e,t).catch(function(n){return t.error(n)})})}function hu(e){return gi(bi(e))}function pu(e,t){var n,r,o,i;return ja(this,void 0,void 0,function(){var s,c;return Zo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Wa(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 Ze(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 wi(e,t){return t===void 0&&(t=0),N(function(n,r){n.subscribe(W(r,function(o){return Ze(r,e,function(){return r.next(o)},t)},function(){return Ze(r,e,function(){return r.complete()},t)},function(o){return Ze(r,e,function(){return r.error(o)},t)}))})}function ki(e,t){return t===void 0&&(t=0),N(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function yu(e,t){return fe(e).pipe(ki(t),wi(t))}function vu(e,t){return fe(e).pipe(ki(t),wi(t))}function bu(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function mu(e,t){return new T(function(n){var r;return Ze(n,t,function(){r=e[yi](),Ze(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 z(r?.return)&&r.return()}})}function xi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){Ze(n,t,function(){var r=e[Symbol.asyncIterator]();Ze(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function gu(e,t){return xi(bi(e),t)}function wu(e,t){if(e!=null){if(di(e))return yu(e,t);if(li(e))return bu(e,t);if(fi(e))return vu(e,t);if(hi(e))return xi(e,t);if(vi(e))return mu(e,t);if(mi(e))return gu(e,t)}throw pi(e)}function Tt(e,t){return t?wu(e,t):fe(e)}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=hn(e);return Tt(e,n)}function pn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Ei=Xn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function ku(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 Ei)}})})}function Ee(e,t){return new Promise(function(n,r){var o=new ht({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new Ei)}});e.subscribe(o)})}function xu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){r.next(e.call(t,i,o++))}))})}var Eu=Array.isArray;function Su(e,t){return Eu(t)?e.apply(void 0,Ke([],Ge(t))):e(t)}function Au(e){return I(function(t){return Su(e,t)})}var Iu=Array.isArray,Bu=Object.getPrototypeOf,_u=Object.prototype,Cu=Object.keys;function Ou(e){if(e.length===1){var t=e[0];if(Iu(t))return{args:t,keys:null};if($u(t)){var n=Cu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function $u(e){return e&&typeof e=="object"&&Bu(e)===_u}function Tu(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function yn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=hn(e),r=ui(e),o=Ou(e),i=o.args,s=o.keys;if(i.length===0)return Tt([],n);var c=new T(Pu(i,n,s?function(u){return Tu(s,u)}:Ye));return r?c.pipe(Au(r)):c}function Pu(e,t,n){return n===void 0&&(n=Ye),function(r){Si(t,function(){for(var o=e.length,i=new Array(o),s=o,c=o,u=function(l){Si(t,function(){var h=Tt(e[l],t),f=!1;h.subscribe(W(r,function(d){i[l]=d,f||(f=!0,c--),c||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},a=0;a<o;a++)u(a)},r)}}function Si(e,t,n){e?Ze(n,e,t):t()}function Uu(e,t,n,r,o,i,s,c){var u=[],a=0,l=0,h=!1,f=function(){h&&!u.length&&!a&&t.complete()},d=function(y){return a<r?p(y):u.push(y)},p=function(y){a++;var v=!1;fe(n(y,l++)).subscribe(W(t,function(b){t.next(b)},function(){v=!0},void 0,function(){if(v)try{a--;for(var b=function(){var m=u.shift();s||p(m)};u.length&&a<r;)b();f()}catch(m){t.error(m)}}))};return e.subscribe(W(t,d,function(){h=!0,f()})),function(){}}function D(e,t,n){return n===void 0&&(n=1/0),z(t)?D(function(r,o){return I(function(i,s){return t(r,i,o,s)})(fe(e(r,o)))},n):(typeof t=="number"&&(n=t),N(function(r,o){return Uu(r,o,e,n)}))}function Nn(e){return e===void 0&&(e=1/0),D(Ye,e)}function Lu(){return Nn(1)}function Ru(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Lu()(Tt(e,hn(e)))}function er(e){return new T(function(t){fe(e()).subscribe(t)})}function Ai(e,t,n){return n===void 0&&(n=iu),new T(function(r){var o=xu(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){r.closed||(r.next(i++),r.complete())},o)})}function Ii(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=hn(e),r=cu(e,1/0),o=e;return o.length?o.length===1?fe(o[0]):Nn(r)(Tt(o,n)):$t}function Me(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function Pt(e){return N(function(t,n){var r=null,o=!1,i;r=t.subscribe(W(n,void 0,void 0,function(s){i=fe(e(s,Pt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function Mu(e,t,n,r,o){return function(i,s){var c=n,u=t,a=0;i.subscribe(W(s,function(l){var h=a++;u=c?e(u,l,h):(c=!0,l),s.next(u)},o))}}function Bi(e,t){return z(t)?D(e,t,1):D(e,1)}function Du(e,t){return t===void 0&&(t=ai),N(function(n,r){var o=null,i=null,s=null,c=function(){if(o){o.unsubscribe(),o=null;var a=i;i=null,r.next(a)}};function u(){var a=s+e,l=t.now();if(l<a){o=this.schedule(void 0,a-l),r.add(o);return}c()}n.subscribe(W(r,function(a){i=a,s=t.now(),o||(o=t.schedule(u,e),r.add(o))},function(){c(),r.complete()},void 0,function(){i=o=null}))})}function _e(e){return e<=0?function(){return $t}:N(function(t,n){var r=0;t.subscribe(W(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function zu(e,t){return N(function(n,r){var o=new Set;n.subscribe(W(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&fe(t).subscribe(W(r,function(){return o.clear()},ct))})}function Se(e,t){return t===void 0&&(t=Ye),e=e??Hu,N(function(n,r){var o,i=!0;n.subscribe(W(r,function(s){var c=t(s);(i||!e(o,c))&&(i=!1,o=c,r.next(s))}))})}function Hu(e,t){return e===t}function _i(e,t){return N(Mu(e,t,arguments.length>=2,!0))}function Ut(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new fn}: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 l,h,f,d=0,p=!1,y=!1,v=function(){h?.unsubscribe(),h=void 0},b=function(){v(),l=f=void 0,p=y=!1},m=function(){var S=l;b(),S?.unsubscribe()};return N(function(S,g){d++,!y&&!p&&v();var x=f=f??n();g.add(function(){d--,d===0&&!y&&!p&&(h=tr(m,u))}),x.subscribe(g),!l&&d>0&&(l=new ht({next:function(E){return x.next(E)},error:function(E){y=!0,v(),h=tr(b,o,E),x.error(E)},complete:function(){p=!0,v(),h=tr(b,s),x.complete()}}),fe(S).subscribe(l))})(a)}}function tr(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 ht({next:function(){o.unsubscribe(),e()}});return fe(t.apply(void 0,Ke([],Ge(n)))).subscribe(o)}}function Ci(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,Ut({connector:function(){return new dn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Oi(e,t){return N(function(n,r){var o=null,i=0,s=!1,c=function(){return s&&!o&&r.complete()};n.subscribe(W(r,function(u){o?.unsubscribe();var a=0,l=i++;fe(e(u,l)).subscribe(o=W(r,function(h){return r.next(t?t(u,h,l,a++):h)},function(){o=null,c()}))},function(){s=!0,c()}))})}function Vu(e){return N(function(t,n){fe(e).subscribe(W(n,function(){return n.complete()},ct)),!n.closed&&t.subscribe(n)})}function $i(e,t){return t===void 0&&(t=!1),N(function(n,r){var o=0;n.subscribe(W(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function Fu(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?N(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;o.subscribe(W(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)}))}):Ye}function Ti(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=ui(e);return N(function(r,o){for(var i=e.length,s=new Array(i),c=e.map(function(){return!1}),u=!1,a=function(h){fe(e[h]).subscribe(W(o,function(f){s[h]=f,!u&&!c[h]&&(c[h]=!0,(u=c.every(Ye))&&(c=null))},ct))},l=0;l<i;l++)a(l);r.subscribe(W(o,function(h){if(u){var f=Ke([h],Ge(s));o.next(n?n.apply(void 0,Ke([],Ge(f))):f)}}))})}var ju=Object.defineProperty,qu=(e,t,n)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pi=(e,t,n)=>qu(e,typeof t!="symbol"?t+"":t,n);class Wu{constructor(){Pi(this,"first"),Pi(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 Xu=()=>{const e=new Map,t=(f,d)=>{e.set(f,()=>{e.delete(f),d()})},n=f=>{e.get(f)?.()},r=new Wu,o=r.unshift.bind(r),i=r.push.bind(r),s=(f,d)=>{const p=d?o:i;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:d,observer:p}=f;let y=!1;const v=d.subscribe({next(b){p.next(b)},error(b){(y=b instanceof nn)?s(f,!0):p.error(b)},complete(){p.complete()}});v.closed?y||c():t(d,()=>{v.unsubscribe(),c()})},a=(f=!1)=>d=>new T(p=>{const y={observer:p,source$:d};return r.isEmpty()?u(y):s(y,f),()=>{n(d)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...d)=>l(f(...d))}};class vn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Gu extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Ui extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Ku=new Set(["best","finalized",null]),Li=e=>{const t=e.pipe(Pt(n=>n instanceof rn?Ai(750).pipe(Bi(()=>t)):pn(()=>n)));return t},Yu=(e,t)=>n=>(r,...o)=>{if(!Ku.has(r))return Li(n(r,...o));const s=(r==="best"?t:e).pipe(_e(1),D(c=>n(c,...o)),Pt(c=>c instanceof vn?s:pn(()=>c)));return Li(s)},Ri=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Zu=e=>t=>(...n)=>e()[t](...n),Ju=(e,t)=>e.pipe($i(n=>n.blocks.has(t)),Se((n,r)=>n.finalized===r.finalized&&n.best===r.best),Me(n=>n.blocks.get(n.best).number>=n.blocks.get(t).number),I(n=>{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}),Se(),$i(n=>n!=="finalized",!0)),Qu=e=>{let t=null,n=ct;const r=new T(o=>{t=e(!0,i=>{o.next(i)},i=>{t=null,o.error(i)}),n=()=>{o.complete(),t?.unfollow()}}).pipe(Ut());return{getFollower:()=>{if(!t)throw new Error("Missing chainHead subscription");return t},unfollow:()=>{n()},follow$:r}},Mi=()=>e=>new T(t=>{const n=new st,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof jo?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n});function Nu(e,t,n){return(r,o,...i)=>(o?ni(tl(r,t.pipe(Mi(),Me(c=>c.type==="finalized"),D(c=>c.prunedBlockHashes))),el(r,e)):c=>c)(n(r,...i))}const el=(e,t)=>n=>Ju(t,e).pipe(_e(1),Oi(r=>r?n:pn(()=>new Ui))),tl=(e,t)=>n=>new T(r=>{const o=t.pipe(Me(s=>s===e)).subscribe(()=>{r.error(new Gu)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function bn(e,t){return(n,...r)=>{const o=t(n,...r);return new T(i=>{let s=null,c=!1;const u=()=>{c||(c=!0,s=o.subscribe({next:h=>i.next(h),error:h=>i.error(h),complete:()=>i.complete()}),s.add(()=>{c=!1,s=null}))};let a=!1;const l=e.subscribe({next:h=>{const f=h.blocks.get(n);f?f.recovering?s?.unsubscribe():u():a&&i.error(new vn),a=h.recovering},error:h=>i.error(h)});return()=>{l.unsubscribe(),s?.unsubscribe()}})}}const nl=(e,t)=>{const n=(r,o,i,s)=>new T(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(Nn(),t(s));return n},Di=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Je={type:"void"},rl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>h=>{let f=n.get(h);if(f)return f;if(r.has(h)){const p={id:h};return n.set(h,p),p}r.add(h);const d=l(h);return f=n.get(h),f?Object.assign(f,d):(f={id:h,...d},n.set(h,f)),r.delete(h),f};let i=!0,s=!0;const c=o(l=>{const h=t(e[l]);if(h)return h;const{def:f,path:d,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return Je;if(f.value.length===1){const y=c(f.value[0].type);return i&&d.at(-1)==="AccountId32"&&Di(y,32)?(i=!1,{type:"AccountId32"}):s&&d.at(-1)==="AccountId20"&&Di(y,20)?(s=!1,{type:"AccountId20"}):y}return u(f.value)}if(f.tag==="variant"){if(d.length===1&&d[0]==="Option"&&p.length===1&&p[0].name==="T"){const b=c(p[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}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(f.value.length===0)return Je;const y={},v={};return f.value.forEach(b=>{const m=b.name;if(v[m]=b.docs,b.fields.length===0){y[m]={...Je,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){y[m]={type:"lookupEntry",value:c(b.fields[0].type),idx:b.index};return}y[m]={...u(b.fields),idx:b.index}}),{type:"enum",value:y,innerDocs:v}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:y}=f.value,v=c(f.value.type);return!y||v.type==="void"?Je:y>1?{type:"array",value:v,len:f.value.len}:v}if(f.tag==="tuple")return f.value.length===0?Je:f.value.length>1?a(f.value.map(y=>c(y)),f.value.map(y=>e[y].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const y=c(f.value);return y.type==="void"?Je:{type:"compact",isBig:Number(y.value.slice(1))>32,size:y.value}}return{type:f.tag}}),u=l=>{let h=!0;const f={},d={};return l.forEach((p,y)=>{h=h&&!!p.name;const v=p.name||y,b=c(p.type);b.type!=="void"&&(f[v]=b,d[v]=p.docs)}),h?{type:"struct",value:f,innerDocs:d}:a(Object.values(f),Object.values(d))},a=(l,h)=>{if(l.every(f=>f.id===l[0].id)&&h.every(f=>!f.length)){const[f]=l;return f.type==="void"?Je:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:h}};return c},zi=e=>{const t=rl(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?{...Je,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})},ol=(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},il=At(),sl=M(q[0],Vt(q[1],BigInt)),Hi=ol((e,t,n,r)=>{if(e.type==="primitive")return Mo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return po;if(e.type==="compact")return e.isBig?sl:q;if(e.type==="bitSequence")return Nr;const o=d=>Hi(d,t,n,r),i=(d,p)=>{const y=o(d);return p?P(y,p):P(y)},s=d=>ae(...d.map(o)),c=d=>{const p=Object.fromEntries(Object.entries(d).map(([y,v])=>[y,o(v)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return il;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?At(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 ee(o(e.value));if(e.type==="result")return Ft(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]])),l=Object.values(e.value).map(d=>d.idx),f=l.every((d,p)=>d===p)?ge(a):ge(a,l);return e.byteLength?cl(f,e.byteLength):f},Cn,e=>e),Vi=(e,t=tt())=>{const n=new Map,r=o=>Hi(e(o),n,new Set,t);return o=>r(o)},cl=(e,t)=>{const n=Y(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Fi=e=>{const{metadata:t}=e;let n=Vi(e);const r=t.pallets.find(h=>h.name==="System")?.constants.find(h=>h.name==="SS58Prefix");let o;if(r)try{const h=n(r.type).dec(r.value);typeof h=="number"&&(o=h,n=Vi(e,tt(h)))}catch{}const i=new Map,s=(h,f)=>{let d=i.get(h);d||i.set(h,d=Ro(h));const p=t.pallets.find(E=>E.name===h).storage.items.find(E=>E.name===f),y=(E,...A)=>{const C=d(...A);return{...C,len:E,fallback:p.modifier===1?C.dec(p.fallback):void 0}};if(p.type.tag==="plain")return y(0,f,n(p.type.value).dec);const{key:v,value:b,hashers:m}=p.type.value,S=n(b),g=m.map(E=>Mo[E.tag]),x=(()=>{if(g.length===1)return[[n(v),g[0]]];const E=e(v);switch(E.type){case"array":return g.map(A=>[n(E.value.id),A]);case"tuple":return E.value.map((A,C)=>[n(A.id),g[C]]);default:throw new Error("Invalid key type")}})();return y(g.length,f,S.dec,...x)},c=h=>{switch(h.type){case"void":return _;case"lookupEntry":return n(h.value.id);case"tuple":return ae(...Object.values(h.value).map(f=>n(f.id)));case"struct":return $(Kt(h.value,f=>n(f.id)));case"array":return P(n(h.value.id),h.len)}},u=(h,f)=>{const d=t.pallets.find(p=>p.name===h).constants.find(p=>p.name===f);return n(d.type)},a=h=>(f,d)=>{const p=t.pallets.find(b=>b.name===f),y=e(p[h]);if(y.type!=="enum")throw null;const v=y.value[d];return{location:[p.index,v.idx],codec:c(y.value[d])}},l=(h,f)=>{const d=t.apis.find(p=>p.name===h)?.methods.find(p=>p.name===f);if(!d)throw null;return{args:ae(...d.inputs.map(p=>n(p.type))),value:n(d.output)}};return{buildDefinition:n,buildStorage:s,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},al=se(xe.enc(15)),ji=Y(),ul=ee(ji),ll=P(xe).dec,fl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(Pt(l=>{if(l instanceof vn)return r(c,u);if(l instanceof rn)return Ai(750).pipe(D(()=>r(c,u)));throw l})):$t},o=r("Metadata_metadata_versions","").pipe(I(ll)),i=r("Metadata_metadata","").pipe(I(c=>{const u=ji.dec(c);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",al).pipe(I(c=>{const u=ul.dec(c);return{metadata:rt.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Pt(()=>ne([14])),D(c=>c.includes(15)?s:i))};return n=>{const r=n(),o=new Set([r]),i=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=zi(c),l=Fi(a),h=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let d=null;if(f){const p=a(f.type);if(p.type==="struct"){const y=p.value.asset_id;y.type==="option"&&(d=y.value.id)}}return{assetId:d,metadataRaw:u,lookup:a,dynamicBuilder:l,events:{key:h.enc(),dec:h.dec},accountId:tt(l.ss58Prefix)}}),Ci(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}},Lt=Ut({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),qi=(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},Wi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},dl=(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=>{Wi(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},hl=(e,t,n,r,o)=>{const i=Ii(r,e.pipe(pl(t),Mi())).pipe(_i((c,u)=>{switch(u.type){case"initialized":c.recovering&&(u.finalizedBlockHashes.some(d=>c.blocks.has(d))||(c=Xi()));const[a]=u.finalizedBlockHashes.slice(-1);c.finalized=c.best=a;const l=u.finalizedBlockHashes.length-1;u.finalizedBlockHashes.forEach((f,d)=>{c.blocks.has(f)?c.blocks.get(f).recovering=!1:c.blocks.set(f,{hash:f,parent:d===0?u.parentHash:u.finalizedBlockHashes[d-1],children:new Set(d===l?[]:[u.finalizedBlockHashes[d+1]]),runtime:f,refCount:0,number:u.number+d,recovering:!1})});const h=Object.values(c.runtimes).find(f=>f.usages.has(a));return c.finalizedRuntime=h??(c.runtimes[a]=s(qi(c,a))),c;case"stop-error":for(const f of c.blocks.values())f.recovering=!0;return c.recovering=!0,c;case"newBlock":{const{parentBlockHash:f,blockHash:d}=u;if(c.blocks.has(d))c.blocks.get(d).recovering=!1;else{const p=c.blocks.get(f);p.children.add(d),u.newRuntime&&(c.runtimes[d]=s(qi(c,d)));const y={hash:d,number:p.number+1,parent:f,children:new Set,runtime:u.newRuntime?d:p.runtime,refCount:0,recovering:!1};c.blocks.set(d,y),c.runtimes[y.runtime].addBlock(d)}return c}case"bestBlockChanged":{if(c.recovering){for(const[f,d]of c.blocks)d.recovering&&Wi(c.blocks,f);c.recovering=!1}return c.best=u.bestBlockHash,c}case"finalized":{c.finalized=u.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=c;return f.get(c.best).number<f.get(c.finalized).number&&(c.best=c.finalized),c.finalizedRuntime=c.runtimes[f.get(c.finalized).runtime],o(dl(c,u.prunedBlockHashes)),c}case"blockUsage":{if(!c.blocks.has(u.value.hash))return c;const f=c.blocks.get(u.value.hash);return f.refCount+=u.value.type==="hold"?1:-1,f.refCount===0&&f.number<c.blocks.get(c.finalized).number&&!f.recovering&&(f.unpinned=!0,o([f.hash])),c}}},Xi()),Me(c=>!!c.finalizedRuntime.runtime),I(c=>({...c})),Lt),s=fl(bn(i,n));return i},Xi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),pl=e=>t=>t.pipe(Bi(n=>n.type!=="initialized"?ne(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),Gi=(e,t,n,r)=>{const o=c=>Vu(e.pipe(Me(({blocks:u})=>!u.has(c)))),i=(c,u,a)=>{if(a)return ne({hash:c,found:{type:!1,validity:null}});const l=o(c);return t(c).pipe(D(h=>{const f=h.indexOf(u);return f>-1?l(r(c)).pipe(I(d=>({hash:c,found:{type:!0,index:f,events:d}}))):n(c,u).pipe(I(d=>({hash:c,found:{type:!1,validity:d}})))}),l)},s=(c,u,a)=>i(c,u,a.has(c)).pipe(D(l=>{const{found:h}=l;return h.type||h.validity?.success===!1?ne(l):e.pipe(o(c),D(f=>f.blocks.get(c).children),zu(),D(f=>s(f,u,a)))}));return c=>e.pipe(_e(1),D(u=>s(u.finalized,c,new Set(u.blocks.keys()))))},yl=new Uint8Array([2]),vl=(e,t)=>se(pe(yl,me(e),me(t))),Ki="TaggedTransactionQueue",Yi="validate_transaction",[,bl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:F,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:F})}),ml=Ht(e=>{const t=F.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=bl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),gl=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(Ki,Yi).value[1]}catch{return ml}}));return e(n,`${Ki}_${Yi}`,vl(r,n)).pipe(Ti(o),I(([i,s])=>s(i)))},wl=e=>t=>new T(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}),kl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,l=0;const h=()=>{const f=i.get(a);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=a++;i.delete(d),l!==d&&c.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):c.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,er(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),xl=e=>t=>new T(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)}}),nr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),El=e=>{const{getFollower:t,unfollow:n,follow$:r}=Qu(e),o=Zu(t),{withRecovery:i,withRecoveryFn:s}=Xu(),c=new fn,u=k=>(B,...L)=>new T(V=>{c.next({type:"blockUsage",value:{type:"hold",hash:B}});const ve=k(B,...L).subscribe(V);return()=>{setTimeout(()=>{c.next({type:"blockUsage",value:{type:"release",hash:B}})},0),ve.unsubscribe()}}),a=k=>(B,...L)=>new T(V=>{let ve=!1;return y.pipe(_e(1)).subscribe(Ce=>{const ce=Ce.blocks.get(B);ve=!!ce&&!ce.unpinned}),ve?k(B,...L).subscribe(V):V.error(new vn)}),l=k=>t().header(k).then(bo.dec),h=k=>t().unpin(k).catch(B=>{if(!(B instanceof tn))throw B}),f=k=>a(u((L=>Nu(y,r,L))(bn(y,s(Ri(k)))))),d=(k,B=!0)=>(L,...V)=>k(L,B,...V),p=new Map,y=hl(r,l,u(s(Ri(o("call")))),c,k=>{h(k),k.forEach(B=>{p.delete(B)})}),v=u(k=>y.pipe(_e(1),D(B=>B.runtimes[B.blocks.get(k).runtime].runtime))),b=k=>B=>B.pipe(kl(L=>v(k(L)).pipe(I(V=>[L,V])))),m=(k,B,L)=>{const V=p.get(k)??new Map,ve=V.get(B);if(ve)return ve;p.set(k,V);const Ce=new dn,ce=L.pipe(Ut({connector:()=>Ce}),Fu({complete(){V.set(B,Ce)}}),xl());return V.set(B,ce),ce},S=y.pipe(Se((k,B)=>k.finalized===B.finalized),I(k=>nr(k.blocks.get(k.finalized))),Lt),g=y.pipe(Se((k,B)=>k.best===B.best),I(k=>nr(k.blocks.get(k.best))),Lt),x=y.pipe(Se((k,B)=>k.finalized===B.finalized&&k.best===B.best),_i((k,B)=>{const L=de=>k.get(de)||nr(B.blocks.get(de)),V=L(B.best),ve=L(B.finalized),Ce=V.number-ve.number+1,ce=new Array(Ce);for(let de=0,Dt=V.hash;de<Ce;de++)ce[de]=L(Dt),Dt=ce[de].parent;return new Map(ce.map(de=>[de.hash,de]))},new Map),I(k=>[...k.values()]),Lt),E=y.pipe(Se((k,B)=>k.finalizedRuntime===B.finalizedRuntime),Oi(({finalizedRuntime:{runtime:k}})=>k.pipe(wl(null))),Lt),A=E.pipe(I(k=>k?.lookup.metadata??null)),C=Yu(S.pipe(I(k=>k.hash)),g.pipe(I(k=>k.hash))),H=C(f(o("body"))),G=k=>m(k,"body",H(k,!0)),K=f(o("storage")),j=C((k,B,L,V,ve=null,Ce)=>y.pipe(_e(1),D(ce=>ce.runtimes[ce.blocks.get(k).runtime].runtime),D(ce=>{const de=V(ce),Dt=m(k,`storage-${L}-${de}-${ve??""}`,K(k,B,L,de,ve));return Ce?m(k,`storage-${L}-${de}-${ve??""}-dec`,Dt.pipe(I(kf=>Ce(kf,ce)))):Dt}))),ke=nl(t,i),Mt=C(u(bn(y,(k,B,L)=>ke(k,B,L??null,!1)))),fr=C(u(bn(y,k=>er(()=>l(k))))),us=(k,B=!1)=>j(k,B,"value",L=>L.events.key,null,(L,V)=>V.events.dec(L)),bf=f(o("call")),ls=C((k,B,L,V)=>m(k,`call-${L}-${V}`,bf(k,B,L,V))),dr=gl(d(ls,!1),v),fs=k=>m(k,"body",H(k,!1)),mf=Gi(y,fs,dr,us),gf=Gi(y,fs,dr,()=>ne());let kn=!1,hr=0;const wf=k=>{hr+=k,kn=!0,Ii(E,x).subscribe({error(){}})};return[{follow$:r,finalized$:S,best$:g,bestBlocks$:x,runtime$:E,metadata$:A,header$:fr,body$:G,call$:d(ls),storage$:d(j),storageQueries$:Mt,eventsAt$:d(us),trackTx$:mf,trackTxWithoutEvents$:gf,validateTx$:dr,pinnedBlocks$:y,withRuntime:b,getRuntimeContext$:C(v),unfollow:()=>{kn!=null&&(hr--,kn&&!hr&&(kn=null,n()))}},wf]};var Sl=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const mn=new Map,Al=e=>{const t=mn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=mn.get(e);!c||c.refCount<=1?(mn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,i=null;const s={chainHead$:c=>{o++,i||(i=c||1),r||(r=El(e.chainHead));const[u,a]=r;if(i===o){const l=o;o=0,i=null,r=null,a(l)}return u},broadcastTx$:Sl(e.transaction),destroy:n};return mn.set(e,{client:s,refCount:1}),s};class pt{constructor(){}_runtime(t){}}class Zi{constructor(){}_compatibility(t){}}const gn=new WeakMap,Ji=new WeakMap,rr=e=>e instanceof pt?Ji.get(e):gn.get(e);var yt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(yt||{});const Il=P(xa),Bl=P(zn),_l=ae(Il,Bl),Cl=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Me(s=>s!=null));let i=await Ee(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(_l.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const c=new Zi;return gn.set(c,{runtime:s,getPalletEntryPoint(u,a,l){return r[i[u][a][l]]},getApiEntryPoint(u,a){return r[i.apis[u][a]]},typedefNodes:o}),c})},Ol=e=>new Promise(async t=>{const n=e.runtime$.pipe(Me(o=>o!=null));let r=await Ee(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new pt;return Ji.set(n,{runtime:t}),n}),or=new WeakMap,Qi=e=>(or.has(e.metadataRaw)||or.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),or.get(e.metadataRaw)),vt=(e,t,n)=>{const r=(u,a)=>{var l;const h=Qi(u);return(l=h.typeNodes)[a]||(l[a]=Ot(h.lookup(a)))};function o(u,a){if(u instanceof pt)return{args:Be.Identical,values:Be.Identical};const l=gn.get(u);a||(a=l.runtime());const h=t(l),f=n(a),d=l.typedefNodes,p=Qi(a);return Ba(h,y=>d[y],f,y=>r(a,y),p.compat)}const i=es(e,u=>Ni(o(u))),s=es(e,(u,a)=>i(a)>=u),c=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:c,withCompatibleRuntime:(u,a)=>l=>yn([l.pipe(u.withRuntime(a)),c()]).pipe(I(([[h,f],d])=>[h,d,f])),compatibleRuntime$:(u,a)=>yn([c(),u.getRuntimeContext$(a)]),argsAreCompatible:(u,a,l)=>{if(u instanceof pt)return!0;const h=o(u,a);if(h.args===Be.Incompatible)return!1;if(h.args>Be.Partial)return!0;if(h.values===Be.Incompatible)return!1;const f=n(a);return Fo(f.args,d=>r(a,d),l)},valuesAreCompatible:(u,a,l)=>{if(u instanceof pt)return!0;const h=o(u,a).values;if(h===Be.Incompatible)return!1;if(h>Be.Partial)return!0;const f=gn.get(u),d=t(f);return Fo(d.values,p=>f.typedefNodes[p],l)},getRuntimeTypedef:r}},Ni=e=>Math.min(e.args,e.values),es=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Zi||r instanceof pt?t(...n):e.then(o=>t(...n,o))},$l=(e,t,{valuesAreCompatible:n,waitDescriptors:r,isCompatible:o,getCompatibilityLevel:i})=>{const s=new WeakMap,c=a=>{if(s.has(a))return s.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const h=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return s.set(a,h),h},u=a=>{if(a){const l=rr(a).runtime(),h=c(l);if(!n(a,l,h))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return h}return r().then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},Tl=Ut({connector:()=>new dn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function ir(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new Gr)}:ct;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 Pl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,l=0;const h=()=>{const f=i.get(a);if(!f){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const d=a++;i.delete(d),l!==d&&c.set(d,[]),s.set(d,f.subscribe({next(p){l===d?r.next(p):c.get(d).push(p)},complete(){if(s.delete(d),d===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;h()},error(p){r.error(p)}}))};return o=n.subscribe({next(f){const d=u++;i.set(d,er(()=>e(f,d))),s.size<t&&h()},error(f){r.error(f)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(f=>f.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Ul=(e,t)=>n=>new T(r=>{let o=new Array,i=!1;const s=u=>{const a=new st;o.push(a),o.length>t&&(o[0].unsubscribe(),o=o.slice(1));const l=e(u).subscribe({next(h){const f=o.indexOf(a);o.slice(0,f).forEach(d=>d.unsubscribe()),o=o.slice(f),r.next(h)},error(h){r.error(h)},complete(){const h=o.indexOf(a);o.splice(h,1),o.length===0&&i&&r.complete()}});a.add(l)},c=n.subscribe({next(u){s(u)},error(u){r.error(u)},complete(){o.length===0&&r.complete(),i=!0}});return()=>{c.unsubscribe(),o.forEach(u=>u.unsubscribe())}});let ts={};const Ll=e=>t=>new T(n=>{let r=ts,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===ts?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),sr=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)),Rl=(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,l=>l.hash),I(([l,h,f])=>{const d=f.lookup.metadata.pallets.find(p=>p.name===e)?.events;if(d==null||f.lookup.metadata.lookup[d].def.tag!=="variant"||f.lookup.metadata.lookup[d].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!s(h,f,null))throw u();return[l,h,f]}),Pl(([l,h,f])=>n.eventsAt$(l.hash).pipe(I(d=>d.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(h,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),Tl);return{watch:l=>a.pipe(D(h=>l?h.filter(f=>l(f.payload)):h)),pull:()=>Ee(a),filter:l=>l.filter(h=>h.type===e&&h.value.type===t).map(h=>h.value.value),getCompatibilityLevel:o,isCompatible:r}},Ml=(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((...l)=>{const h=l[l.length-1],f=sr(h),{signal:d,at:p}=f?h:{},y=p??null,v=i(n,y).pipe(D(([b,m])=>{let S;try{S=m.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!s(b,m,l))throw a();return n.call$(y,u,se(S.args.enc(l))).pipe(I(S.value.dec),I(g=>{if(!c(b,m,g))throw a();return g}))}));return ir(v,d)},{getCompatibilityLevel:o,isCompatible:r})},Dl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",h=n.runtime$.pipe(Me(Boolean),_e(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ye),Ci()),f=ni(Ti(h),I(([m,S])=>S(m))),d=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),y=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},v=(...m)=>{const S=m[m.length-1],g=S==="best"||S==="finalized"?m.slice(0,-1):m;return l?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Se(),f):n[S==="best"?"best$":"finalized$"].pipe(Du(0),c(n,x=>x.hash),Ul(([x,E,A])=>{const C=y(A);if(!u(E,A,g))throw d();return n.storage$(x.hash,"value",()=>C.enc(...g)).pipe(I(H=>{if(!a(E,A,H))throw d();return{val:H,codecs:C}}))},4),Se((x,E)=>x.val===E.val),I(({val:x,codecs:E})=>x===null?E.fallback:E.dec(x)))},b=async(...m)=>{const S=m[m.length-1],g=sr(S),{signal:x,at:E}=g?S:{},A=E??null;let C;if(l)C=n.bestBlocks$.pipe(I(H=>A==="finalized"||!A?H.at(-1):A==="best"?H.at(0):H.find(G=>G.hash===A)),I(H=>{if(!H)throw new Ui;return H.number}),Se(),f);else{const H=await s();C=n.storage$(A,"value",G=>{const K=y(G),j=m.length===K.len?m:m.slice(0,-1);if(m!==j&&!g)throw p(m);if(!u(H,G,j))throw d();return K.enc(...j)},null,(G,K)=>{const j=y(K),ke=G===null?j.fallback:j.dec(G);if(!a(H,K,ke))throw d();return ke})}return ir(C,x)};return{isCompatible:r,getCompatibilityLevel:o,getValue:b,getValues:(m,S)=>Promise.all(m.map(g=>b(...S?[...g,S]:g))),getEntries:async(...m)=>{const S=m[m.length-1],g=sr(S),{signal:x,at:E}=g?S:{},A=E??null,C=await s(),H=n.storage$(A,"descendantsValues",G=>{const K=y(G);if(Ni(i(C,G))===Be.Incompatible)throw d();if(m.length>K.len)throw p(m);const j=m.length>0&&g?m.slice(0,-1):m;if(m.length===K.len&&j===m)throw p(m);return K.enc(...j)},null,(G,K)=>{const j=y(K);if(G.some(({value:ke})=>!a(C,K,ke)))throw d();return G.map(({key:ke,value:Mt})=>({keyArgs:j.keyDecoder(ke),value:j.dec(Mt)}))});return ir(H,x)},watchValue:v}},zl=mt(F.enc,e=>+!!e.signed<<7|e.version),cr=()=>new Error("Unkown signer"),Hl=e=>{const{extrinsic:t}=e,n=zi(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 cr()}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 cr();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 cr()},Vl={Ed25519:0,Sr25519:1,Ecdsa:2},Fl=(e,t,n,r,o,i)=>{const[s,c]=Hl(e),u=pe(zl({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([Vl[i],...n]),...r,o);return pe(q.enc(u.length),u)},[wn,Rt]=["<Bytes>","</Bytes>"].map(e=>Fe.fromText(e).asBytes()),jl=e=>async t=>{let n=!0,r;for(r=0;n&&r<wn.length;r++)n=wn[r]===t[r];n=n&&r===wn.length;const o=t.length-Rt.length;for(r=0;n&&r<Rt.length;r++)n=Rt[r]===t[o+r];return n=n&&r===Rt.length,e(n?t:pe(wn,t,Rt))};function ql(e,t,n){return{publicKey:e,signTx:async(o,i,s,c,u=Ln)=>{let a;try{const p=Ao(s);if(p.metadata.tag!=="v14"&&p.metadata.tag!=="v15")throw null;a=p.metadata.value}catch{throw new Error("Unsupported metadata version")}const l=[],h=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const y=i[p];if(!y)throw new Error(`Missing ${p} signed extension`);l.push(y.value),h.push(y.additionalSigned)});const f=pe(o,...l,...h),d=await n(f.length>256?u(f):f);return Fl(a,e,d,l,o,t)},signBytes:jl(n)}}const De=new Uint8Array,ns=e=>{const{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(I(r=>me(r)))},rs=(e,t)=>{const n=Fi(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 ne(s(i(r.value)[e]))},Wl=e=>ne({value:Qr.enc(e),additionalSigned:De});function Xl(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Gl=mt(Y(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Xl(e.period)-1,1),15),r=e.phase/t<<4;return Qe.enc(n|r)}),Kl=new Uint8Array([0]),Yl=(e,t)=>{if(!e)return ns(t).pipe(I(o=>({additionalSigned:o,value:Kl})));const{period:n,blockNumber:r}=e;return ne({additionalSigned:me(t.at),value:Gl({period:n,phase:r%n})})},Zl=$({tip:q,asset:ee(Y(1/0))}).enc,Jl=(e,t)=>ne({value:Zl({tip:e,asset:t}),additionalSigned:De}),Ql=e=>ns(e).pipe(I(t=>({value:De,additionalSigned:t}))),Nl=()=>ne({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),os="AccountNonceApi_account_nonce",ef={1:F.dec,2:Qe.dec,4:xe.dec,8:gt.dec},ar=e=>ne({value:q.enc(e),additionalSigned:De});var tf=Object.freeze({__proto__:null,CheckGenesis:Ql,CheckMetadataHash:Nl,CheckNonce:e=>e.chainHead.call$(e.at,os,se(e.from)).pipe(D(t=>{const n=me(t),r=ef[n.length];if(!r)throw new Error(`${os} retrieved wrong data`);return ar(r(n))})),CheckSpecVersion:({lookupFn:e})=>rs("spec_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),CheckTxVersion:({lookupFn:e})=>rs("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:De}))),getNonce:ar});const nf=ne({value:De,additionalSigned:De}),is=(e,t,n)=>{if(!(t in e))return De;const r=e[t];return r instanceof Uint8Array?r:n(r)},rf=(e,t,n)=>ne({value:is(e,"value",t),additionalSigned:is(e,"additionalSigned",n)}),of=(e,t,n,r,o,i={})=>e.getRuntimeContext$(r.hash).pipe(_e(1),D(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 yn(Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:l,additionalSigned:h})=>[a,(()=>{if(a==="CheckMortality")return Yl(u,c);if(a==="ChargeTransactionPayment")return Wl(i.tip??0n);if(a==="ChargeAssetTxPayment")return Jl(i.tip??0n,i.asset);if(a==="CheckNonce"&&"nonce"in i)return ar(i.nonce);const f=tf[a],[d]=s.dynamicBuilder.buildDefinition(l),[p]=s.dynamicBuilder.buildDefinition(h);return f?f(c):d===_[0]&&p===_[0]?nf:a in o?rf(o[a],d,p):null})()]).filter(a=>a[1]))).pipe(D(a=>t.signTx(n,Kt(a,(l,h)=>({identifier:h,...l})),s.metadataRaw,r.number)))}));var sf=Object.defineProperty,cf=(e,t,n)=>t in e?sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,af=(e,t,n)=>cf(e,t+"",n);const uf=e=>se(Ln(me(e))),lf=(e,t)=>new T(n=>{const r=new Map;let o,i;const s=()=>{let u=o.best,a=r.get(u),l=o.blocks.get(u).number;for(;!a;){const d=o.blocks.get(u);if(!d)break;a=r.get(u=d.parent),l--}if(!a)return;const h=l<=o.blocks.get(o.finalized).number,f=a.found.type;if(f&&i?.found&&i.hash===a.hash){h&&n.complete();return}n.next(i=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),h&&(f?n.complete():a.found.validity?.success===!1&&n.error(new ur(a.found.validity.value)))},c=t.pipe(Se((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(Se((n,r)=>n===r)),ff=(e,t)=>{const n=e.filter(o=>o.phase.type==="ApplyExtrinsic"&&o.phase.value===t).map(o=>({...o.event,topics:o.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class ur extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Fe?r.asHex():r,2)),af(this,"error"),this.name="InvalidTxError",this.error=t}}const lr=(e,t,n,r,o=!1)=>{const i=uf(n),s=(l,h)=>({type:l,txHash:i,...h}),c=e.pinnedBlocks$.pipe(_e(1),I(l=>{const h=l.blocks.get(r);return h&&!h.unpinned?h.hash:l.finalized})).pipe(D(l=>e.validateTx$(l,n).pipe(Me(h=>!h.success),I(h=>{throw new ur(h.value)})))),u=new T(l=>{const h=e.trackTx$(n).subscribe(l);return h.add(t(n).subscribe({error(f){l.error(f)}})),h}),a=lf(u,e.pinnedBlocks$).pipe(I(l=>l.found?s("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...ff(l.events,l.index)}):s("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Ru(o?ne(s("signed",{})):$t,c,ne(s("broadcasted",{})),a.pipe(Ll(({found:l,type:h,...f})=>l?ne(s("finalized",f)):$t)))},ss=async(e,t,n,r)=>ku(lr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),df=tt().enc,hf=new Uint8Array(64),pf=new Uint8Array(65),yf=e=>()=>e?pf:hf,cs=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const h=(g,x,E={})=>{const A=rr(g).runtime(),{dynamicBuilder:C,assetId:H,lookup:G}=A;let K;try{K=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(g,A,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let j=E;if(E.asset){if(H==null||!Hn(E.asset,Ot(G(H)),fr=>u(A,fr)))throw new Error("Incompatible runtime asset");j={...E,asset:C.buildDefinition(H).enc(E.asset)}}const{location:ke,codec:Mt}=K;return{callData:Fe.fromBytes(pe(new Uint8Array(ke),Mt.enc(x))),options:j}},f=(g,x={})=>s(n,null).pipe(I(([E])=>h(E,g,x))),d=g=>g?h(g,l).callData:Ee(f(l).pipe(I(x=>x.callData))),p=(g,{...x},E)=>f(l,x).pipe(D(({callData:A,options:C})=>of(n,g,A.asBytes(),E,x.customSignedExtensions||{},C))),y=(g,{at:x,...E}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(A=>A.find(C=>C.hash===x)))).pipe(_e(1),D(A=>A?p(g,E,A).pipe(I(C=>({tx:se(C),block:A}))):pn(()=>new Error(`Uknown block ${x}`)))),v=(g,x)=>Ee(y(g,x)).then(E=>E.tx),b=(g,x)=>Ee(y(g,x)).then(({tx:E,block:A})=>ss(n,r,E,A.hash)),m=(g,x)=>y(g,x).pipe(D(({tx:E,block:A})=>lr(n,r,E,A.hash,!0))),S=async(g,x)=>{typeof g=="string"&&(g=g.startsWith("0x")?me(g):df(g));const E=g.length===20,A=ql(g,E?"Ecdsa":"Sr25519",yf(E)),C=me(await v(A,x)),H=se(pe(C,xe.enc(C.length))),G=n.getRuntimeContext$(null).pipe(I(j=>j.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),K=n.call$(null,"TransactionPaymentApi_query_info",H);return Ee(yn([K,G]).pipe(I(([j,ke])=>ke(j))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:It(t,l)},getEncodedData:d,sign:v,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),as=(e,t,n)=>{const r={},o=p=>new Proxy(r,{get(y,v){return p(v)}}),i=p=>{const y={};return o(v=>(y[v]||(y[v]={}),o(b=>(y[v][b]||(y[v][b]=p(v,b)),y[v][b]))))},s=(p,y)=>p.lookup.metadata.pallets.find(v=>v.name===y),c=i((p,y)=>Dl(p,y,t,vt(e,v=>v.getPalletEntryPoint(yt.Storage,p,y),v=>Ea(s(v,p).storage.items.find(b=>b.name===y))))),u=(p,y,v,b)=>{const m=p.lookup(v);if(m.type!=="enum")throw new Error("Expected enum");const S=Aa(m.value[b]);return{args:y==="args"?S:Nt,values:y==="args"?Nt:S}},a=i((p,y)=>cs(p,y,t,n,vt(e,v=>v.getPalletEntryPoint(yt.Tx,p,y),v=>u(v,"args",s(v,p).calls,y)),!0)),l=i((p,y)=>Rl(p,y,t,vt(e,v=>v.getPalletEntryPoint(yt.Event,p,y),v=>u(v,"values",s(v,p).events,y)))),h=i((p,y)=>$l(p,y,vt(e,v=>v.getPalletEntryPoint(yt.Const,p,y),v=>Ia(s(v,p).constants.find(b=>b.name===y).type)))),f=i((p,y)=>Ml(p,y,t,vt(e,v=>v.getApiEntryPoint(p,y),v=>Sa(v.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===y))))),d=(p,y)=>{const{lookup:v,dynamicBuilder:b}=rr(y).runtime();try{const m=b.buildDefinition(v.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return cs(S,g,t,n,vt(e,E=>E.getPalletEntryPoint(yt.Tx,S,g),E=>u(E,"args",s(E,S).calls,g)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:c,txFromCallData:(p,y)=>y?d(p,y):e.then(v=>d(p,v)),tx:a,event:l,apis:f,constants:h}};function vf(e){const t=Fa(e),n=Al(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const c=new WeakMap,u=h=>{const f=c.get(h)||Cl(h,r);return c.set(h,f),f},a=()=>s??(s=Ol(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Ee(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Ee(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:h=>Ee(r.body$(h)),getBlockHeader:h=>Ee(r.header$(h??null)),submit:(...h)=>ss(r,l,...h),submitAndWatch:(...h)=>lr(r,l,...h),getTypedApi:h=>{const f=u(h);return Object.assign(as(f,r,l),{compatibilityToken:f})},getUnsafeApi:()=>{const h=a();return Object.assign(as(h,r,l),{runtimeToken:h})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}he.AccountId=tt,he.Binary=Fe,he.CompatibilityLevel=Be,he.Enum=It,he.FixedSizeBinary=_n,he.InvalidTxError=ur,he._Enum=oo,he.createClient=vf,he.getSs58AddressInfo=In});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function an(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var ct=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=ft(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else s.remove(this);var f=this.initialTeardown;if(z(f))try{f()}catch(v){i=v instanceof Kn?v.errors:[v]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=ft(l),h=d.next();!h.done;h=d.next()){var p=h.value;try{ei(p)}catch(v){i=i??[],v instanceof Kn?i=Ye(Ye([],Ke(i)),Ke(v.errors)):i.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(o=d.return)&&o.call(d)}finally{if(r)throw r.error}}}if(i)throw new Kn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ei(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)&&an(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&an(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Qo=ct.EMPTY;function No(e){return e instanceof ct||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function ei(e){z(e)?e():e.unsubscribe()}var ti={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Xa={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Ye([e,t],Ke(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ni(e){Xa.setTimeout(function(){throw e})}function Me(){}function un(e){e()}var Yn=function(e){Re(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,No(n)&&n.add(r)):r.destination=Za,r}return t.create=function(n,r,o){return new ht(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}(ct),Ga=Function.prototype.bind;function Zn(e,t){return Ga.call(e,t)}var Ka=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){ln(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){ln(r)}else ln(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){ln(n)}},e}(),ht=function(e){Re(t,e);function t(n,r,o){var i=e.call(this)||this,s;if(z(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var c;i&&ti.useDeprecatedNextContext?(c=Object.create(n),c.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Zn(n.next,c),error:n.error&&Zn(n.error,c),complete:n.complete&&Zn(n.complete,c)}):s=n}return i.destination=new Ka(s),i}return t}(Yn);function ln(e){ni(e)}function Ya(e){throw e}var Za={closed:!0,next:Me,error:Ya,complete:Me},Jn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ze(e){return e}function ri(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return oi(e)}function oi(e){return e.length===0?Ze:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var T=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=Qa(t)?t:new ht(t,n,r);return un(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=ii(n),new n(function(o,i){var s=new ht({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[Jn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return oi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ii(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 ii(e){var t;return(t=e??ti.Promise)!==null&&t!==void 0?t:Promise}function Ja(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Qa(e){return e&&e instanceof Yn||Ja(e)&&No(e)}function Na(e){return z(e?.lift)}function N(e){return function(t){if(Na(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 W(e,t,n,r,o){return new eu(e,t,n,r,o)}var eu=function(e){Re(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}(Yn),tu=Gn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),$t=function(e){Re(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 si(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new tu},t.prototype.next=function(n){var r=this;un(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ft(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;un(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;un(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?Qo:(this.currentObservers=null,c.push(n),new ct(function(){r.currentObservers=null,an(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 T;return n.source=this,n},t.create=function(n,r){return new si(n,r)},t}(T),si=function(e){Re(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:Qo},t}($t),Qn={now:function(){return(Qn.delegate||Date).now()},delegate:void 0},fn=function(e){Re(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Qn);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}($t),nu=function(e){Re(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(ct),ci={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Ye([e,t],Ke(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ru=function(e){Re(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,an(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(nu),ai=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=Qn.now,e}(),ou=function(e){Re(t,e);function t(n,r){r===void 0&&(r=ai.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}(ai),ui=new ou(ru),iu=ui,Tt=new T(function(e){return e.complete()});function su(e){return e&&z(e.schedule)}function Nn(e){return e[e.length-1]}function li(e){return z(Nn(e))?e.pop():void 0}function dn(e){return su(Nn(e))?e.pop():void 0}function cu(e,t){return typeof Nn(e)=="number"?e.pop():t}var fi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function di(e){return z(e?.then)}function hi(e){return z(e[Jn])}function pi(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function vi(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 au(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var yi=au();function bi(e){return z(e?.[yi])}function mi(e){return qa(this,arguments,function(){var n,r,o,i;return Jo(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,dt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,dt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,dt(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 gi(e){return z(e?.getReader)}function fe(e){if(e instanceof T)return e;if(e!=null){if(hi(e))return uu(e);if(fi(e))return lu(e);if(di(e))return fu(e);if(pi(e))return wi(e);if(bi(e))return du(e);if(gi(e))return hu(e)}throw vi(e)}function uu(e){return new T(function(t){var n=e[Jn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function lu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function fu(e){return new T(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ni)})}function du(e){return new T(function(t){var n,r;try{for(var o=ft(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 wi(e){return new T(function(t){pu(e,t).catch(function(n){return t.error(n)})})}function hu(e){return wi(mi(e))}function pu(e,t){var n,r,o,i;return ja(this,void 0,void 0,function(){var s,c;return Jo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Wa(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 Je(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 ki(e,t){return t===void 0&&(t=0),N(function(n,r){n.subscribe(W(r,function(o){return Je(r,e,function(){return r.next(o)},t)},function(){return Je(r,e,function(){return r.complete()},t)},function(o){return Je(r,e,function(){return r.error(o)},t)}))})}function xi(e,t){return t===void 0&&(t=0),N(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function vu(e,t){return fe(e).pipe(xi(t),ki(t))}function yu(e,t){return fe(e).pipe(xi(t),ki(t))}function bu(e,t){return new T(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function mu(e,t){return new T(function(n){var r;return Je(n,t,function(){r=e[yi](),Je(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 z(r?.return)&&r.return()}})}function Ei(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){Je(n,t,function(){var r=e[Symbol.asyncIterator]();Je(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function gu(e,t){return Ei(mi(e),t)}function wu(e,t){if(e!=null){if(hi(e))return vu(e,t);if(fi(e))return bu(e,t);if(di(e))return yu(e,t);if(pi(e))return Ei(e,t);if(bi(e))return mu(e,t);if(gi(e))return gu(e,t)}throw vi(e)}function Pt(e,t){return t?wu(e,t):fe(e)}function ne(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=dn(e);return Pt(e,n)}function hn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Si=Gn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function ku(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 Si)}})})}function Ee(e,t){return new Promise(function(n,r){var o=new ht({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new Si)}});e.subscribe(o)})}function xu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){r.next(e.call(t,i,o++))}))})}var Eu=Array.isArray;function Su(e,t){return Eu(t)?e.apply(void 0,Ye([],Ke(t))):e(t)}function Au(e){return I(function(t){return Su(e,t)})}var Iu=Array.isArray,Bu=Object.getPrototypeOf,_u=Object.prototype,Cu=Object.keys;function Ou(e){if(e.length===1){var t=e[0];if(Iu(t))return{args:t,keys:null};if($u(t)){var n=Cu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function $u(e){return e&&typeof e=="object"&&Bu(e)===_u}function Tu(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function pn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=dn(e),r=li(e),o=Ou(e),i=o.args,s=o.keys;if(i.length===0)return Pt([],n);var c=new T(Pu(i,n,s?function(u){return Tu(s,u)}:Ze));return r?c.pipe(Au(r)):c}function Pu(e,t,n){return n===void 0&&(n=Ze),function(r){Ai(t,function(){for(var o=e.length,i=new Array(o),s=o,c=o,u=function(f){Ai(t,function(){var l=Pt(e[f],t),d=!1;l.subscribe(W(r,function(h){i[f]=h,d||(d=!0,c--),c||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},a=0;a<o;a++)u(a)},r)}}function Ai(e,t,n){e?Je(n,e,t):t()}function Uu(e,t,n,r,o,i,s,c){var u=[],a=0,f=0,l=!1,d=function(){l&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var y=!1;fe(n(v,f++)).subscribe(W(t,function(b){t.next(b)},function(){y=!0},void 0,function(){if(y)try{a--;for(var b=function(){var m=u.shift();s||p(m)};u.length&&a<r;)b();d()}catch(m){t.error(m)}}))};return e.subscribe(W(t,h,function(){l=!0,d()})),function(){}}function D(e,t,n){return n===void 0&&(n=1/0),z(t)?D(function(r,o){return I(function(i,s){return t(r,i,o,s)})(fe(e(r,o)))},n):(typeof t=="number"&&(n=t),N(function(r,o){return Uu(r,o,e,n)}))}function er(e){return e===void 0&&(e=1/0),D(Ze,e)}function Lu(){return er(1)}function Ru(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Lu()(Pt(e,dn(e)))}function vn(e){return new T(function(t){fe(e()).subscribe(t)})}var Mu={connector:function(){return new $t},resetOnDisconnect:!0};function Du(e,t){t===void 0&&(t=Mu);var n=null,r=t.connector,o=t.resetOnDisconnect,i=o===void 0?!0:o,s=r(),c=new T(function(u){return s.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=vn(function(){return e}).subscribe(s),i&&n.add(function(){return s=r()})),n},c}function Ii(e,t,n){return n===void 0&&(n=iu),new T(function(r){var o=xu(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){r.closed||(r.next(i++),r.complete())},o)})}function Bi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=dn(e),r=cu(e,1/0),o=e;return o.length?o.length===1?fe(o[0]):er(r)(Pt(o,n)):Tt}function De(e,t){return N(function(n,r){var o=0;n.subscribe(W(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function Ut(e){return N(function(t,n){var r=null,o=!1,i;r=t.subscribe(W(n,void 0,void 0,function(s){i=fe(e(s,Ut(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function zu(e,t,n,r,o){return function(i,s){var c=n,u=t,a=0;i.subscribe(W(s,function(f){var l=a++;u=c?e(u,f,l):(c=!0,f),s.next(u)},o))}}function _i(e,t){return z(t)?D(e,t,1):D(e,1)}function Hu(e,t){return t===void 0&&(t=ui),N(function(n,r){var o=null,i=null,s=null,c=function(){if(o){o.unsubscribe(),o=null;var a=i;i=null,r.next(a)}};function u(){var a=s+e,f=t.now();if(f<a){o=this.schedule(void 0,a-f),r.add(o);return}c()}n.subscribe(W(r,function(a){i=a,s=t.now(),o||(o=t.schedule(u,e),r.add(o))},function(){c(),r.complete()},void 0,function(){i=o=null}))})}function _e(e){return e<=0?function(){return Tt}:N(function(t,n){var r=0;t.subscribe(W(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Fu(e,t){return N(function(n,r){var o=new Set;n.subscribe(W(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&fe(t).subscribe(W(r,function(){return o.clear()},Me))})}function Se(e,t){return t===void 0&&(t=Ze),e=e??Vu,N(function(n,r){var o,i=!0;n.subscribe(W(r,function(s){var c=t(s);(i||!e(o,c))&&(i=!1,o=c,r.next(s))}))})}function Vu(e,t){return e===t}function Ci(e,t){return N(zu(e,t,arguments.length>=2,!0))}function yn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new $t}: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,d,h=0,p=!1,v=!1,y=function(){l?.unsubscribe(),l=void 0},b=function(){y(),f=d=void 0,p=v=!1},m=function(){var S=f;b(),S?.unsubscribe()};return N(function(S,g){h++,!v&&!p&&y();var x=d=d??n();g.add(function(){h--,h===0&&!v&&!p&&(l=tr(m,u))}),x.subscribe(g),!f&&h>0&&(f=new ht({next:function(E){return x.next(E)},error:function(E){v=!0,y(),l=tr(b,o,E),x.error(E)},complete:function(){p=!0,y(),l=tr(b,s),x.complete()}}),fe(S).subscribe(f))})(a)}}function tr(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 ht({next:function(){o.unsubscribe(),e()}});return fe(t.apply(void 0,Ye([],Ke(n)))).subscribe(o)}}function Oi(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,yn({connector:function(){return new fn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function $i(e,t){return N(function(n,r){var o=null,i=0,s=!1,c=function(){return s&&!o&&r.complete()};n.subscribe(W(r,function(u){o?.unsubscribe();var a=0,f=i++;fe(e(u,f)).subscribe(o=W(r,function(l){return r.next(t?t(u,l,f,a++):l)},function(){o=null,c()}))},function(){s=!0,c()}))})}function ju(e){return N(function(t,n){fe(e).subscribe(W(n,function(){return n.complete()},Me)),!n.closed&&t.subscribe(n)})}function Ti(e,t){return t===void 0&&(t=!1),N(function(n,r){var o=0;n.subscribe(W(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function qu(e,t,n){var r=z(e)||t||n?{next:e,error:t,complete:n}:e;return r?N(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;o.subscribe(W(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)}))}):Ze}function Pi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=li(e);return N(function(r,o){for(var i=e.length,s=new Array(i),c=e.map(function(){return!1}),u=!1,a=function(l){fe(e[l]).subscribe(W(o,function(d){s[l]=d,!u&&!c[l]&&(c[l]=!0,(u=c.every(Ze))&&(c=null))},Me))},f=0;f<i;f++)a(f);r.subscribe(W(o,function(l){if(u){var d=Ye([l],Ke(s));o.next(n?n.apply(void 0,Ye([],Ke(d))):d)}}))})}var Wu=Object.defineProperty,Xu=(e,t,n)=>t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ui=(e,t,n)=>Xu(e,typeof t!="symbol"?t+"":t,n);class Gu{constructor(){Ui(this,"first"),Ui(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 Ku=()=>{const e=new Map,t=(d,h)=>{e.set(d,()=>{e.delete(d),h()})},n=d=>{e.get(d)?.()},r=new Gu,o=r.unshift.bind(r),i=r.push.bind(r),s=(d,h)=>{const p=h?o:i;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 v=!1;const y=h.subscribe({next(b){p.next(b)},error(b){(v=b instanceof nn)?s(d,!0):p.error(b)},complete(){p.complete()}});y.closed?v||c():t(h,()=>{y.unsubscribe(),c()})},a=(d=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):s(v,d),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:d=>(...h)=>f(d(...h))}};class bn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Yu extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Li extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Zu=new Set(["best","finalized",null]),Ri=e=>{const t=e.pipe(Ut(n=>n instanceof rn?Ii(750).pipe(_i(()=>t)):hn(()=>n)));return t},Ju=(e,t)=>n=>(r,...o)=>{if(!Zu.has(r))return Ri(n(r,...o));const s=(r==="best"?t:e).pipe(_e(1),D(c=>n(c,...o)),Ut(c=>c instanceof bn?s:hn(()=>c)));return Ri(s)},Mi=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),Qu=e=>t=>(...n)=>e()[t](...n),Nu=(e,t)=>e.pipe(Ti(n=>n.blocks.has(t)),Se((n,r)=>n.finalized===r.finalized&&n.best===r.best),De(n=>n.blocks.get(n.best).number>=n.blocks.get(t).number),I(n=>{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}),Se(),Ti(n=>n!=="finalized",!0));function el(e,t,n){return(r,o,...i)=>(o?ri(nl(r,t.pipe(De(c=>c.type==="finalized"),D(c=>c.prunedBlockHashes))),tl(r,e)):c=>c)(n(r,...i))}const tl=(e,t)=>n=>Nu(t,e).pipe(_e(1),$i(r=>r?n:hn(()=>new Li))),nl=(e,t)=>n=>new T(r=>{const o=t.pipe(De(s=>s===e)).subscribe(()=>{r.error(new Yu)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function mn(e,t){return(n,...r)=>{const o=t(n,...r);return new T(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 d=l.blocks.get(n);d?d.recovering?s?.unsubscribe():u():a&&i.error(new bn),a=l.recovering},error:l=>i.error(l)});return()=>{f.unsubscribe(),s?.unsubscribe()}})}}const rl=(e,t)=>{const n=(r,o,i,s)=>new T(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(er(),t(s));return n},ol=e=>t=>t.pipe(_i(n=>n.type!=="initialized"?ne(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),il=e=>{let t=null,n=Me;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(mo.dec),i=Du(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(ol(o),sl()));return{getHeader:o,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},sl=()=>e=>new T(t=>{const n=new ct,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof qo?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n}),Di=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Qe={type:"void"},cl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=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 i=!0,s=!0;const c=o(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 Qe;if(d.value.length===1){const v=c(d.value[0].type);return i&&h.at(-1)==="AccountId32"&&Di(v,32)?(i=!1,{type:"AccountId32"}):s&&h.at(-1)==="AccountId20"&&Di(v,20)?(s=!1,{type:"AccountId20"}):v}return u(d.value)}if(d.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const b=c(p[0].type);return b.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:b}}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 Qe;const v={},y={};return d.value.forEach(b=>{const m=b.name;if(y[m]=b.docs,b.fields.length===0){v[m]={...Qe,idx:b.index};return}if(b.fields.length===1&&!b.fields[0].name){v[m]={type:"lookupEntry",value:c(b.fields[0].type),idx:b.index};return}v[m]={...u(b.fields),idx:b.index}}),{type:"enum",value:v,innerDocs:y}}if(d.tag==="sequence")return{type:"sequence",value:c(d.value)};if(d.tag==="array"){const{len:v}=d.value,y=c(d.value.type);return!v||y.type==="void"?Qe:v>1?{type:"array",value:y,len:d.value.len}:y}if(d.tag==="tuple")return d.value.length===0?Qe:d.value.length>1?a(d.value.map(v=>c(v)),d.value.map(v=>e[v].docs)):c(d.value[0]);if(d.tag==="primitive")return{type:"primitive",value:d.value.tag};if(d.tag==="compact"){const v=c(d.value);return v.type==="void"?Qe:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:d.tag}}),u=f=>{let l=!0;const d={},h={};return f.forEach((p,v)=>{l=l&&!!p.name;const y=p.name||v,b=c(p.type);b.type!=="void"&&(d[y]=b,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"?Qe:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:l}};return c},zi=e=>{const t=cl(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?{...Qe,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})},al=(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},ul=At(),ll=M(q[0],Ft(q[1],BigInt)),Hi=al((e,t,n,r)=>{if(e.type==="primitive")return Do[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return vo;if(e.type==="compact")return e.isBig?ll:q;if(e.type==="bitSequence")return eo;const o=h=>Hi(h,t,n,r),i=(h,p)=>{const v=o(h);return p?P(v,p):P(v)},s=h=>ae(...h.map(o)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,y])=>[v,o(y)]));return $(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return ul;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?At(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 ee(o(e.value));if(e.type==="result")return Vt(o(e.value.ok),o(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;case"lookupEntry":return o(h.value);case"tuple":return s(h.value);case"struct":return c(h.value);case"array":return i(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)?ge(a):ge(a,f);return e.byteLength?fl(d,e.byteLength):d},On,e=>e),Fi=(e,t=nt())=>{const n=new Map,r=o=>Hi(e(o),n,new Set,t);return o=>r(o)},fl=(e,t)=>{const n=Y(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Vi=e=>{const{metadata:t}=e;let n=Fi(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=Fi(e,nt(l)))}catch{}const i=new Map,s=(l,d)=>{let h=i.get(l);h||i.set(l,h=Mo(l));const p=t.pallets.find(E=>E.name===l).storage.items.find(E=>E.name===d),v=(E,...A)=>{const C=h(...A);return{...C,len:E,fallback:p.modifier===1?C.dec(p.fallback):void 0}};if(p.type.tag==="plain")return v(0,d,n(p.type.value).dec);const{key:y,value:b,hashers:m}=p.type.value,S=n(b),g=m.map(E=>Do[E.tag]),x=(()=>{if(g.length===1)return[[n(y),g[0]]];const E=e(y);switch(E.type){case"array":return g.map(A=>[n(E.value.id),A]);case"tuple":return E.value.map((A,C)=>[n(A.id),g[C]]);default:throw new Error("Invalid key type")}})();return v(g.length,d,S.dec,...x)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return ae(...Object.values(l.value).map(d=>n(d.id)));case"struct":return $(Kt(l.value,d=>n(d.id)));case"array":return P(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(b=>b.name===d),v=e(p[l]);if(v.type!=="enum")throw null;const y=v.value[h];return{location:[p.index,y.idx],codec:c(v.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:ae(...h.inputs.map(p=>n(p.type))),value:n(h.output)}};return{buildDefinition:n,buildStorage:s,buildEvent:a("events"),buildError:a("errors"),buildRuntimeCall:f,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},dl=se(xe.enc(15)),ji=Y(),hl=ee(ji),pl=P(xe).dec,vl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(Ut(f=>{if(f instanceof bn)return r(c,u);if(f instanceof rn)return Ii(750).pipe(D(()=>r(c,u)));throw f})):Tt},o=r("Metadata_metadata_versions","").pipe(I(pl)),i=r("Metadata_metadata","").pipe(I(c=>{const u=ji.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",dl).pipe(I(c=>{const u=hl.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Ut(()=>ne([14])),D(c=>c.includes(15)?s:i))};return n=>{const r=n(),o=new Set([r]),i=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=zi(c),f=Vi(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 v=p.value.asset_id;v.type==="option"&&(h=v.value.id)}}return{assetId:h,metadataRaw:u,lookup:a,dynamicBuilder:f,events:{key:l.enc(),dec:l.dec},accountId:nt(f.ss58Prefix)}}),Oi(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}},Lt=yn({connector:()=>new fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),qi=(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},Wi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},yl=(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=>{Wi(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},bl=(e,t,n,r)=>{const o=Bi(n,e).pipe(Ci((s,c)=>{switch(c.type){case"initialized":s.recovering&&(c.finalizedBlockHashes.some(d=>s.blocks.has(d))||(s=Xi()));const[u]=c.finalizedBlockHashes.slice(-1);s.finalized=s.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((l,d)=>{s.blocks.has(l)?s.blocks.get(l).recovering=!1:s.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(s.runtimes).find(l=>l.usages.has(u));return s.finalizedRuntime=f??(s.runtimes[u]=i(qi(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:d}=c;if(s.blocks.has(d))s.blocks.get(d).recovering=!1;else{const h=s.blocks.get(l);h.children.add(d),c.newRuntime&&(s.runtimes[d]=i(qi(s,d)));const p={hash:d,number:h.number+1,parent:l,children:new Set,runtime:c.newRuntime?d:h.runtime,refCount:0,recovering:!1};s.blocks.set(d,p),s.runtimes[p.runtime].addBlock(d)}return s}case"bestBlockChanged":{if(s.recovering){for(const[l,d]of s.blocks)d.recovering&&Wi(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(yl(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}}},Xi()),De(s=>!!s.finalizedRuntime.runtime),I(s=>({...s})),Lt),i=vl(mn(o,t));return o},Xi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Gi=(e,t,n,r)=>{const o=c=>ju(e.pipe(De(({blocks:u})=>!u.has(c)))),i=(c,u,a)=>{if(a)return ne({hash:c,found:{type:!1,validity:null}});const f=o(c);return t(c).pipe(D(l=>{const d=l.indexOf(u);return d>-1?f(r(c)).pipe(I(h=>({hash:c,found:{type:!0,index:d,events:h}}))):n(c,u).pipe(I(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},s=(c,u,a)=>i(c,u,a.has(c)).pipe(D(f=>{const{found:l}=f;return l.type||l.validity?.success===!1?ne(f):e.pipe(o(c),D(d=>d.blocks.get(c).children),Fu(),D(d=>s(d,u,a)))}));return c=>e.pipe(_e(1),D(u=>s(u.finalized,c,new Set(u.blocks.keys()))))},ml=new Uint8Array([2]),gl=(e,t)=>se(pe(ml,me(e),me(t))),Ki="TaggedTransactionQueue",Yi="validate_transaction",[,wl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),kl=Ht(e=>{const t=V.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=wl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),xl=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(Ki,Yi).value[1]}catch{return kl}}));return e(n,`${Ki}_${Yi}`,gl(r,n)).pipe(Pi(o),I(([i,s])=>s(i)))},El=e=>t=>new T(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}),Sl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,f=0;const l=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),f!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){f===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(p=>r.next(p)),c.delete(f),!s.has(f));)f++;l()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,vn(()=>e(d,h))),s.size<t&&l()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Al=e=>t=>new T(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)}}),nr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),Il=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=il(e),i=Qu(t),{withRecovery:s,withRecoveryFn:c}=Ku(),u=new $t,a=k=>(B,...L)=>new T(F=>{u.next({type:"blockUsage",value:{type:"hold",hash:B}});const ye=k(B,...L).subscribe(F);return()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:B}})},0),ye.unsubscribe()}}),f=k=>(B,...L)=>new T(F=>{let ye=!1;return v.pipe(_e(1)).subscribe(Ce=>{const ce=Ce.blocks.get(B);ye=!!ce&&!ce.unpinned}),ye?k(B,...L).subscribe(F):F.error(new bn)}),l=k=>t().unpin(k).catch(B=>{if(!(B instanceof tn))throw B}),d=k=>f(a((L=>el(v,r,L))(mn(v,c(Mi(k)))))),h=(k,B=!0)=>(L,...F)=>k(L,B,...F),p=new Map,v=bl(r,a(c(Mi(i("call")))),u,k=>{l(k),k.forEach(B=>{p.delete(B)})}),y=a(k=>v.pipe(_e(1),D(B=>B.runtimes[B.blocks.get(k).runtime].runtime))),b=k=>B=>B.pipe(Sl(L=>y(k(L)).pipe(I(F=>[L,F])))),m=(k,B,L)=>{const F=p.get(k)??new Map,ye=F.get(B);if(ye)return ye;p.set(k,F);const Ce=new fn,ce=L.pipe(yn({connector:()=>Ce}),qu({complete(){F.set(B,Ce)}}),Al());return F.set(B,ce),ce},S=v.pipe(Se((k,B)=>k.finalized===B.finalized),I(k=>nr(k.blocks.get(k.finalized))),Lt),g=v.pipe(Se((k,B)=>k.best===B.best),I(k=>nr(k.blocks.get(k.best))),Lt),x=v.pipe(Se((k,B)=>k.finalized===B.finalized&&k.best===B.best),Ci((k,B)=>{const L=de=>k.get(de)||nr(B.blocks.get(de)),F=L(B.best),ye=L(B.finalized),Ce=F.number-ye.number+1,ce=new Array(Ce);for(let de=0,Dt=F.hash;de<Ce;de++)ce[de]=L(Dt),Dt=ce[de].parent;return new Map(ce.map(de=>[de.hash,de]))},new Map),I(k=>[...k.values()]),Lt),E=v.pipe(Se((k,B)=>k.finalizedRuntime===B.finalizedRuntime),$i(({finalizedRuntime:{runtime:k}})=>k.pipe(El(null))),Lt),A=E.pipe(I(k=>k?.lookup.metadata??null)),C=Ju(S.pipe(I(k=>k.hash)),g.pipe(I(k=>k.hash))),H=C(d(i("body"))),G=k=>m(k,"body",H(k,!0)),K=d(i("storage")),j=C((k,B,L,F,ye=null,Ce)=>v.pipe(_e(1),D(ce=>ce.runtimes[ce.blocks.get(k).runtime].runtime),D(ce=>{const de=F(ce),Dt=m(k,`storage-${L}-${de}-${ye??""}`,K(k,B,L,de,ye));return Ce?m(k,`storage-${L}-${de}-${ye??""}-dec`,Dt.pipe(I(Sf=>Ce(Sf,ce)))):Dt}))),ke=rl(t,s),Mt=C(a(mn(v,(k,B,L)=>ke(k,B,L??null,!1)))),fr=C(a(mn(v,k=>vn(()=>o(k))))),us=(k,B=!1)=>j(k,B,"value",L=>L.events.key,null,(L,F)=>F.events.dec(L)),wf=d(i("call")),ls=C((k,B,L,F)=>m(k,`call-${L}-${F}`,wf(k,B,L,F))),dr=xl(h(ls,!1),y),fs=k=>m(k,"body",H(k,!1)),kf=Gi(v,fs,dr,us),xf=Gi(v,fs,dr,()=>ne());Bi(E,x).subscribe({error(){}});let hr=Me,xn=!1,pr=0;const Ef=k=>{pr+=k,xn=!0,hr=n()};return[{follow$:r,finalized$:S,best$:g,bestBlocks$:x,runtime$:E,metadata$:A,header$:fr,body$:G,call$:h(ls),storage$:h(j),storageQueries$:Mt,eventsAt$:h(us),trackTx$:kf,trackTxWithoutEvents$:xf,validateTx$:dr,pinnedBlocks$:v,withRuntime:b,getRuntimeContext$:C(y),unfollow:()=>{xn!=null&&(pr--,xn&&!pr&&(xn=null,hr(),hr=Me))}},Ef]};var Bl=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const gn=new Map,_l=e=>{const t=gn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=gn.get(e);!c||c.refCount<=1?(gn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,i=null;const s={chainHead$:c=>{o++,i||(i=c||1),r||(r=Il(e.chainHead));const[u,a]=r;if(i===o){const f=o;o=0,i=null,r=null,a(f)}return u},broadcastTx$:Bl(e.transaction),destroy:n};return gn.set(e,{client:s,refCount:1}),s};class pt{constructor(){}_runtime(t){}}class Zi{constructor(){}_compatibility(t){}}const wn=new WeakMap,Ji=new WeakMap,rr=e=>e instanceof pt?Ji.get(e):wn.get(e);var vt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(vt||{});const Cl=P(xa),Ol=P(Hn),$l=ae(Cl,Ol),Tl=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(De(s=>s!=null));let i=await Ee(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then($l.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const c=new Zi;return wn.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})},Pl=e=>new Promise(async t=>{const n=e.runtime$.pipe(De(o=>o!=null));let r=await Ee(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new pt;return Ji.set(n,{runtime:t}),n}),or=new WeakMap,Qi=e=>(or.has(e.metadataRaw)||or.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),or.get(e.metadataRaw)),yt=(e,t,n)=>{const r=(u,a)=>{var f;const l=Qi(u);return(f=l.typeNodes)[a]||(f[a]=Ot(l.lookup(a)))};function o(u,a){if(u instanceof pt)return{args:Be.Identical,values:Be.Identical};const f=wn.get(u);a||(a=f.runtime());const l=t(f),d=n(a),h=f.typedefNodes,p=Qi(a);return Ba(l,v=>h[v],d,v=>r(a,v),p.compat)}const i=es(e,u=>Ni(o(u))),s=es(e,(u,a)=>i(a)>=u),c=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:c,withCompatibleRuntime:(u,a)=>f=>pn([f.pipe(u.withRuntime(a)),c()]).pipe(I(([[l,d],h])=>[l,h,d])),compatibleRuntime$:(u,a)=>pn([c(),u.getRuntimeContext$(a)]),argsAreCompatible:(u,a,f)=>{if(u instanceof pt)return!0;const l=o(u,a);if(l.args===Be.Incompatible)return!1;if(l.args>Be.Partial)return!0;if(l.values===Be.Incompatible)return!1;const d=n(a);return jo(d.args,h=>r(a,h),f)},valuesAreCompatible:(u,a,f)=>{if(u instanceof pt)return!0;const l=o(u,a).values;if(l===Be.Incompatible)return!1;if(l>Be.Partial)return!0;const d=wn.get(u),h=t(d);return jo(h.values,p=>d.typedefNodes[p],f)},getRuntimeTypedef:r}},Ni=e=>Math.min(e.args,e.values),es=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Zi||r instanceof pt?t(...n):e.then(o=>t(...n,o))},Ul=(e,t,{valuesAreCompatible:n,waitDescriptors: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(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 s.set(a,l),l},u=a=>{if(a){const f=rr(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})},Ll=yn({connector:()=>new fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function ir(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new Kr)}:Me;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 Rl=(e,t=1/0)=>n=>new T(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,f=0;const l=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),f!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){f===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(p=>r.next(p)),c.delete(f),!s.has(f));)f++;l()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,vn(()=>e(d,h))),s.size<t&&l()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Ml=(e,t)=>n=>new T(r=>{let o=new Array,i=!1;const s=u=>{const a=new ct;o.push(a),o.length>t&&(o[0].unsubscribe(),o=o.slice(1));const f=e(u).subscribe({next(l){const d=o.indexOf(a);o.slice(0,d).forEach(h=>h.unsubscribe()),o=o.slice(d),r.next(l)},error(l){r.error(l)},complete(){const l=o.indexOf(a);o.splice(l,1),o.length===0&&i&&r.complete()}});a.add(f)},c=n.subscribe({next(u){s(u)},error(u){r.error(u)},complete(){o.length===0&&r.complete(),i=!0}});return()=>{c.unsubscribe(),o.forEach(u=>u.unsubscribe())}});let ts={};const Dl=e=>t=>new T(n=>{let r=ts,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===ts?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),sr=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)),zl=(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),I(([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(!s(l,d,null))throw u();return[f,l,d]}),Rl(([f,l,d])=>n.eventsAt$(f.hash).pipe(I(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}})))),Ll);return{watch:f=>a.pipe(D(l=>f?l.filter(d=>f(d.payload)):l)),pull:()=>Ee(a),filter:f=>f.filter(l=>l.type===e&&l.value.type===t).map(l=>l.value.value),getCompatibilityLevel:o,isCompatible:r}},Hl=(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],d=sr(l),{signal:h,at:p}=d?l:{},v=p??null,y=i(n,v).pipe(D(([b,m])=>{let S;try{S=m.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!s(b,m,f))throw a();return n.call$(v,u,se(S.args.enc(f))).pipe(I(S.value.dec),I(g=>{if(!c(b,m,g))throw a();return g}))}));return ir(y,h)},{getCompatibilityLevel:o,isCompatible:r})},Fl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",l=n.runtime$.pipe(De(Boolean),_e(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ze),Oi()),d=ri(Pi(l),I(([m,S])=>S(m))),h=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),p=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),v=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const S=m[m.length-1],g=S==="best"||S==="finalized"?m.slice(0,-1):m;return f?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Se(),d):n[S==="best"?"best$":"finalized$"].pipe(Hu(0),c(n,x=>x.hash),Ml(([x,E,A])=>{const C=v(A);if(!u(E,A,g))throw h();return n.storage$(x.hash,"value",()=>C.enc(...g)).pipe(I(H=>{if(!a(E,A,H))throw h();return{val:H,codecs:C}}))},4),Se((x,E)=>x.val===E.val),I(({val:x,codecs:E})=>x===null?E.fallback:E.dec(x)))},b=async(...m)=>{const S=m[m.length-1],g=sr(S),{signal:x,at:E}=g?S:{},A=E??null;let C;if(f)C=n.bestBlocks$.pipe(I(H=>A==="finalized"||!A?H.at(-1):A==="best"?H.at(0):H.find(G=>G.hash===A)),I(H=>{if(!H)throw new Li;return H.number}),Se(),d);else{const H=await s();C=n.storage$(A,"value",G=>{const K=v(G),j=m.length===K.len?m:m.slice(0,-1);if(m!==j&&!g)throw p(m);if(!u(H,G,j))throw h();return K.enc(...j)},null,(G,K)=>{const j=v(K),ke=G===null?j.fallback:j.dec(G);if(!a(H,K,ke))throw h();return ke})}return ir(C,x)};return{isCompatible:r,getCompatibilityLevel:o,getValue:b,getValues:(m,S)=>Promise.all(m.map(g=>b(...S?[...g,S]:g))),getEntries:async(...m)=>{const S=m[m.length-1],g=sr(S),{signal:x,at:E}=g?S:{},A=E??null,C=await s(),H=n.storage$(A,"descendantsValues",G=>{const K=v(G);if(Ni(i(C,G))===Be.Incompatible)throw h();if(m.length>K.len)throw p(m);const j=m.length>0&&g?m.slice(0,-1):m;if(m.length===K.len&&j===m)throw p(m);return K.enc(...j)},null,(G,K)=>{const j=v(K);if(G.some(({value:ke})=>!a(C,K,ke)))throw h();return G.map(({key:ke,value:Mt})=>({keyArgs:j.keyDecoder(ke),value:j.dec(Mt)}))});return ir(H,x)},watchValue:y}},Vl=mt(V.enc,e=>+!!e.signed<<7|e.version),cr=()=>new Error("Unkown signer"),jl=e=>{const{extrinsic:t}=e,n=zi(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 cr()}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 cr();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 cr()},ql={Ed25519:0,Sr25519:1,Ecdsa:2},Wl=(e,t,n,r,o,i)=>{const[s,c]=jl(e),u=pe(Vl({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([ql[i],...n]),...r,o);return pe(q.enc(u.length),u)},[kn,Rt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Xl=e=>async t=>{let n=!0,r;for(r=0;n&&r<kn.length;r++)n=kn[r]===t[r];n=n&&r===kn.length;const o=t.length-Rt.length;for(r=0;n&&r<Rt.length;r++)n=Rt[r]===t[o+r];return n=n&&r===Rt.length,e(n?t:pe(kn,t,Rt))};function Gl(e,t,n){return{publicKey:e,signTx:async(o,i,s,c,u=Rn)=>{let a;try{const p=Io(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 v=i[p];if(!v)throw new Error(`Missing ${p} signed extension`);f.push(v.value),l.push(v.additionalSigned)});const d=pe(o,...f,...l),h=await n(d.length>256?u(d):d);return Wl(a,e,h,f,o,t)},signBytes:Xl(n)}}const ze=new Uint8Array,ns=e=>{const{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(I(r=>me(r)))},rs=(e,t)=>{const n=Vi(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 ne(s(i(r.value)[e]))},Kl=e=>ne({value:Nr.enc(e),additionalSigned:ze});function Yl(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Zl=mt(Y(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Yl(e.period)-1,1),15),r=e.phase/t<<4;return Ne.enc(n|r)}),Jl=new Uint8Array([0]),Ql=(e,t)=>{if(!e)return ns(t).pipe(I(o=>({additionalSigned:o,value:Jl})));const{period:n,blockNumber:r}=e;return ne({additionalSigned:me(t.at),value:Zl({period:n,phase:r%n})})},Nl=$({tip:q,asset:ee(Y(1/0))}).enc,ef=(e,t)=>ne({value:Nl({tip:e,asset:t}),additionalSigned:ze}),tf=e=>ns(e).pipe(I(t=>({value:ze,additionalSigned:t}))),nf=()=>ne({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),os="AccountNonceApi_account_nonce",rf={1:V.dec,2:Ne.dec,4:xe.dec,8:gt.dec},ar=e=>ne({value:q.enc(e),additionalSigned:ze});var of=Object.freeze({__proto__:null,CheckGenesis:tf,CheckMetadataHash:nf,CheckNonce:e=>e.chainHead.call$(e.at,os,se(e.from)).pipe(D(t=>{const n=me(t),r=rf[n.length];if(!r)throw new Error(`${os} retrieved wrong data`);return ar(r(n))})),CheckSpecVersion:({lookupFn:e})=>rs("spec_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),CheckTxVersion:({lookupFn:e})=>rs("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),getNonce:ar});const sf=ne({value:ze,additionalSigned:ze}),is=(e,t,n)=>{if(!(t in e))return ze;const r=e[t];return r instanceof Uint8Array?r:n(r)},cf=(e,t,n)=>ne({value:is(e,"value",t),additionalSigned:is(e,"additionalSigned",n)}),af=(e,t,n,r,o,i={})=>e.getRuntimeContext$(r.hash).pipe(_e(1),D(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 pn(Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:f,additionalSigned:l})=>[a,(()=>{if(a==="CheckMortality")return Ql(u,c);if(a==="ChargeTransactionPayment")return Kl(i.tip??0n);if(a==="ChargeAssetTxPayment")return ef(i.tip??0n,i.asset);if(a==="CheckNonce"&&"nonce"in i)return ar(i.nonce);const d=of[a],[h]=s.dynamicBuilder.buildDefinition(f),[p]=s.dynamicBuilder.buildDefinition(l);return d?d(c):h===_[0]&&p===_[0]?sf:a in o?cf(o[a],h,p):null})()]).filter(a=>a[1]))).pipe(D(a=>t.signTx(n,Kt(a,(f,l)=>({identifier:l,...f})),s.metadataRaw,r.number)))}));var uf=Object.defineProperty,lf=(e,t,n)=>t in e?uf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ff=(e,t,n)=>lf(e,t+"",n);const df=e=>se(Rn(me(e))),hf=(e,t)=>new T(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 h=o.blocks.get(u);if(!h)break;a=r.get(u=h.parent),f--}if(!a)return;const l=f<=o.blocks.get(o.finalized).number,d=a.found.type;if(d&&i?.found&&i.hash===a.hash){l&&n.complete();return}n.next(i=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 ur(a.found.validity.value)))},c=t.pipe(Se((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(Se((n,r)=>n===r)),pf=(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 ur 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 lr=(e,t,n,r,o=!1)=>{const i=df(n),s=(f,l)=>({type:f,txHash:i,...l}),c=e.pinnedBlocks$.pipe(_e(1),I(f=>{const l=f.blocks.get(r);return l&&!l.unpinned?l.hash:f.finalized})).pipe(D(f=>e.validateTx$(f,n).pipe(De(l=>!l.success),I(l=>{throw new ur(l.value)})))),u=new T(f=>{const l=e.trackTx$(n).subscribe(f);return l.add(t(n).subscribe({error(d){f.error(d)}})),l}),a=hf(u,e.pinnedBlocks$).pipe(I(f=>f.found?s("txBestBlocksState",{found:!0,block:{index:f.index,number:f.number,hash:f.hash},...pf(f.events,f.index)}):s("txBestBlocksState",{found:!1,isValid:f.validity?.success!==!1})));return Ru(o?ne(s("signed",{})):Tt,c,ne(s("broadcasted",{})),a.pipe(Dl(({found:f,type:l,...d})=>f?ne(s("finalized",d)):Tt)))},ss=async(e,t,n,r)=>ku(lr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),vf=nt().enc,yf=new Uint8Array(64),bf=new Uint8Array(65),mf=e=>()=>e?bf:yf,cs=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const l=(g,x,E={})=>{const A=rr(g).runtime(),{dynamicBuilder:C,assetId:H,lookup:G}=A;let K;try{K=C.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(g,A,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let j=E;if(E.asset){if(H==null||!Fn(E.asset,Ot(G(H)),fr=>u(A,fr)))throw new Error("Incompatible runtime asset");j={...E,asset:C.buildDefinition(H).enc(E.asset)}}const{location:ke,codec:Mt}=K;return{callData:je.fromBytes(pe(new Uint8Array(ke),Mt.enc(x))),options:j}},d=(g,x={})=>s(n,null).pipe(I(([E])=>l(E,g,x))),h=g=>g?l(g,f).callData:Ee(d(f).pipe(I(x=>x.callData))),p=(g,{...x},E)=>d(f,x).pipe(D(({callData:A,options:C})=>af(n,g,A.asBytes(),E,x.customSignedExtensions||{},C))),v=(g,{at:x,...E}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(A=>A.find(C=>C.hash===x)))).pipe(_e(1),D(A=>A?p(g,E,A).pipe(I(C=>({tx:se(C),block:A}))):hn(()=>new Error(`Uknown block ${x}`)))),y=(g,x)=>Ee(v(g,x)).then(E=>E.tx),b=(g,x)=>Ee(v(g,x)).then(({tx:E,block:A})=>ss(n,r,E,A.hash)),m=(g,x)=>v(g,x).pipe(D(({tx:E,block:A})=>lr(n,r,E,A.hash,!0))),S=async(g,x)=>{typeof g=="string"&&(g=g.startsWith("0x")?me(g):vf(g));const E=g.length===20,A=Gl(g,E?"Ecdsa":"Sr25519",mf(E)),C=me(await y(A,x)),H=se(pe(C,xe.enc(C.length))),G=n.getRuntimeContext$(null).pipe(I(j=>j.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),K=n.call$(null,"TransactionPaymentApi_query_info",H);return Ee(pn([K,G]).pipe(I(([j,ke])=>ke(j))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:It(t,f)},getEncodedData:h,sign:y,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),as=(e,t,n)=>{const r={},o=p=>new Proxy(r,{get(v,y){return p(y)}}),i=p=>{const v={};return o(y=>(v[y]||(v[y]={}),o(b=>(v[y][b]||(v[y][b]=p(y,b)),v[y][b]))))},s=(p,v)=>p.lookup.metadata.pallets.find(y=>y.name===v),c=i((p,v)=>Fl(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Storage,p,v),y=>Ea(s(y,p).storage.items.find(b=>b.name===v))))),u=(p,v,y,b)=>{const m=p.lookup(y);if(m.type!=="enum")throw new Error("Expected enum");const S=Aa(m.value[b]);return{args:v==="args"?S:Nt,values:v==="args"?Nt:S}},a=i((p,v)=>cs(p,v,t,n,yt(e,y=>y.getPalletEntryPoint(vt.Tx,p,v),y=>u(y,"args",s(y,p).calls,v)),!0)),f=i((p,v)=>zl(p,v,t,yt(e,y=>y.getPalletEntryPoint(vt.Event,p,v),y=>u(y,"values",s(y,p).events,v)))),l=i((p,v)=>Ul(p,v,yt(e,y=>y.getPalletEntryPoint(vt.Const,p,v),y=>Ia(s(y,p).constants.find(b=>b.name===v).type)))),d=i((p,v)=>Hl(p,v,t,yt(e,y=>y.getApiEntryPoint(p,v),y=>Sa(y.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===v))))),h=(p,v)=>{const{lookup:y,dynamicBuilder:b}=rr(v).runtime();try{const m=b.buildDefinition(y.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return cs(S,g,t,n,yt(e,E=>E.getPalletEntryPoint(vt.Tx,S,g),E=>u(E,"args",s(E,S).calls,g)),!1)(x)}catch{throw new Error("createTx: invalid call data")}};return{query:c,txFromCallData:(p,v)=>v?h(p,v):e.then(y=>h(p,y)),tx:a,event:f,apis:d,constants:l}};function gf(e){const t=Va(e),n=_l(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const c=new WeakMap,u=l=>{const d=c.get(l)||Tl(l,r);return c.set(l,d),d},a=()=>s??(s=Pl(r)),{broadcastTx$:f}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>Ee(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>Ee(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:l=>Ee(r.body$(l)),getBlockHeader:l=>Ee(r.header$(l??null)),submit:(...l)=>ss(r,f,...l),submitAndWatch:(...l)=>lr(r,f,...l),getTypedApi:l=>{const d=u(l);return Object.assign(as(d,r,f),{compatibilityToken:d})},getUnsafeApi:()=>{const l=a();return Object.assign(as(l,r,f),{runtimeToken:l})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}he.AccountId=nt,he.Binary=je,he.CompatibilityLevel=Be,he.Enum=It,he.FixedSizeBinary=Cn,he.InvalidTxError=ur,he._Enum=io,he.createClient=gf,he.getSs58AddressInfo=Bn});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -191,24 +191,24 @@
|
|
|
191
191
|
"rxjs": ">=7.8.0"
|
|
192
192
|
},
|
|
193
193
|
"dependencies": {
|
|
194
|
-
"@polkadot-api/cli": "0.9.
|
|
194
|
+
"@polkadot-api/cli": "0.9.16",
|
|
195
195
|
"@polkadot-api/ink-contracts": "0.2.0",
|
|
196
|
-
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
197
196
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
198
197
|
"@polkadot-api/polkadot-sdk-compat": "2.3.1",
|
|
198
|
+
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
199
199
|
"@polkadot-api/metadata-builders": "0.9.1",
|
|
200
200
|
"@polkadot-api/metadata-compatibility": "0.1.11",
|
|
201
|
-
"@polkadot-api/observable-client": "0.6.
|
|
202
|
-
"@polkadot-api/pjs-signer": "0.6.0",
|
|
201
|
+
"@polkadot-api/observable-client": "0.6.2",
|
|
203
202
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
203
|
+
"@polkadot-api/sm-provider": "0.1.4",
|
|
204
204
|
"@polkadot-api/signer": "0.1.10",
|
|
205
|
-
"@polkadot-api/
|
|
205
|
+
"@polkadot-api/pjs-signer": "0.6.0",
|
|
206
206
|
"@polkadot-api/substrate-bindings": "0.9.3",
|
|
207
|
-
"@polkadot-api/substrate-client": "0.3.0",
|
|
208
207
|
"@polkadot-api/ws-provider": "0.3.4",
|
|
209
|
-
"@polkadot-api/
|
|
208
|
+
"@polkadot-api/substrate-client": "0.3.0",
|
|
210
209
|
"@polkadot-api/known-chains": "0.5.6",
|
|
211
|
-
"@polkadot-api/smoldot": "0.3.
|
|
210
|
+
"@polkadot-api/smoldot": "0.3.4",
|
|
211
|
+
"@polkadot-api/utils": "0.1.2"
|
|
212
212
|
},
|
|
213
213
|
"devDependencies": {
|
|
214
214
|
"rxjs": "^7.8.1",
|