polkadot-api 1.7.7 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(he,mt){typeof exports=="object"&&typeof module<"u"?mt(exports):typeof define=="function"&&define.amd?define(["exports"],mt):(he=typeof globalThis<"u"?globalThis:he||self,mt(he.papi={}))})(this,function(he){"use strict";var mt=Object.defineProperty,hs=(e,t,n)=>t in e?mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yr=(e,t,n)=>(hs(e,typeof t!="symbol"?t+"":t,n),n),In={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 ps(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|In[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=In[e[s]],u=In[e[s+1]];o[t+i++]=c<<4|u}return o}var br=class extends Uint8Array{constructor(e){super(e),yr(this,"i",0),yr(this,"v"),this.v=new DataView(e)}},me=e=>t=>e(t instanceof br?t:new br(t instanceof Uint8Array?t.buffer:typeof t=="string"?ps(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 Ht(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 Ft=me,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gt=(e,t)=>n=>e(t(n)),Vt=(e,t)=>n=>t(e(n)),ut=([e,t],n,r)=>M(gt(e,n),Vt(t,r));function vs(e,t){return me(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 He(e,t,n){return M(ys(e,n),vs(e,t))}var V=He(1,"getUint8","setUint8"),Ne=He(2,"getUint16","setUint16"),ke=He(4,"getUint32","setUint32"),wt=He(8,"getBigUint64","setBigUint64"),bs=He(1,"getInt8","setInt8"),ms=He(2,"getInt16","setInt16"),gs=He(4,"getInt32","setInt32"),ws=He(8,"getBigInt64","setBigInt64"),mr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},gr=e=>me(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}),ks=M(mr,gr("getBigUint64")),xs=M(mr,gr("getBigInt64")),wr=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},kr=e=>me(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}),Es=M(wr,kr("getBigUint64")),Ss=M(wr,kr("getBigInt64")),As=ut(V,e=>e?1:0,Boolean),Is=[V[1],Ne[1],ke[1]],Bs=me(e=>{const t=e[e.i],n=t&3;if(n<3)return Is[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=wt[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(ke[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}),_s=1n<<56n,Cs=1<<24,Os=256,$s=4294967295n,Ts=64,Ps=16384,Us=1<<30,Ls=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Ts)return V[0](t);if(e<Ps)return Ne[0](t|1);if(e<Us)return ke[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=_s;)n.push(wt[0](r)),r>>=64n;r>=Cs&&(n.push(ke[0](Number(r&$s))),r>>=32n);let o=Number(r);o>=Os&&(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(Ls,Bs),Rs=new TextEncoder,Ms=e=>{const t=Rs.encode(e);return Ae([q.enc(t.length),t])},Ds=new TextDecoder,zs=me(e=>{let t=q.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Ds.decode(n)}),Q=M(Ms,zs),Hs=()=>{},Fs=new Uint8Array(0),_=M(()=>Fs,Hs),xr=e=>e===void 0?t=>Ae([q.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Er=e=>me(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}),K=e=>M(xr(e),Er(e));K.enc=xr,K.dec=Er;var Sr=(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)])},Ar=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return me(o=>{const i=V.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},Ie=(e,...t)=>M(Sr(Ht(e,([n])=>n),...t),Ar(Ht(e,([,n])=>n),...t));Ie.enc=Sr,Ie.dec=Ar;var Ir=e=>me(t=>V[1](t)>0?e(t):void 0),Br=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ae([n,e(t)]))},ee=e=>M(Br(e[0]),Ir(e[1]));ee.enc=Br,ee.dec=Ir;var _r=(e,t)=>me(n=>{const r=V[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Cr=(e,t)=>({success:n,value:r})=>Ae([V[0](n?0:1),(n?e:t)(r)]),jt=(e,t)=>M(Cr(e[0],t[0]),_r(e[1],t[1]));jt.dec=_r,jt.enc=Cr;var Or=(...e)=>me(t=>e.map(n=>n(t))),$r=(...e)=>t=>Ae(e.map((n,r)=>n(t[r]))),ae=(...e)=>M($r(...e.map(([t])=>t)),Or(...e.map(([,t])=>t)));ae.enc=$r,ae.dec=Or;var Tr=e=>{const t=Object.keys(e);return gt(ae.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Pr=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(Tr(Ht(e,t=>t[0])),Pr(Ht(e,t=>t[1])));$.enc=Tr,$.dec=Pr;var Ur=(e,t)=>t>=0?n=>Ae(n.map(e)):n=>Ae([q.enc(n.length),Ae(n.map(e))]),Lr=(e,t)=>me(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(Ur(e[0],t),Lr(e[1],t));P.enc=Ur,P.dec=Lr;/*! 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 js(...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 qs(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 Ws(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 Rr(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 f=Math.floor(l/n);if(i[u]=f,!Number.isSafeInteger(f)||f*n+s!==l)throw new Error("convertRadix: carry overflow");if(c)f?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 Xs(e){return{encode:t=>{if(!Vs(t))throw new Error("radix.encode input should be Uint8Array");return Rr(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(Rr(t,e,2**8))}}}const Mr=(e=>js(Xs(58),qs(e),Ws("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function et(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Gs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function qt(e,...t){if(!Gs(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 kt(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 Bn(e,t){qt(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 Ks=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),tt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Wt=(e,t)=>e<<32-t|e>>>t,oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Dr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=oe?e=>e:e=>Dr(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=Dr(e[t])}function Ys(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=Ys(e)),qt(e),e}class zr{clone(){return this._cloneInto()}}function Zs(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 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}function Qs(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 Ns=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 Hr extends zr{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){kt(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&&(oe||ie(o),this.compress(o,0,!1),oe||ie(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 f=new Uint32Array(c,l,Math.floor((i-u)/4));oe||ie(f);for(let d=0;u+n<i;d+=o.length,u+=n)this.length+=n,this.compress(f,d,!1);oe||ie(f);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){kt(this),Bn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),oe||ie(r),this.compress(r,0,!0),oe||ie(r);const o=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 Xt=BigInt(2**32-1),_n=BigInt(32);function Gt(e,t=!1){return t?{h:Number(e&Xt),l:Number(e>>_n&Xt)}:{h:Number(e>>_n&Xt)|0,l:Number(e&Xt)|0}}function Fr(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}=Gt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const ec=(e,t)=>BigInt(e>>>0)<<_n|BigInt(t>>>0),tc=(e,t,n)=>e>>>n,nc=(e,t,n)=>e<<32-n|t>>>n,rc=(e,t,n)=>e>>>n|t<<32-n,oc=(e,t,n)=>e<<32-n|t>>>n,ic=(e,t,n)=>e<<64-n|t>>>n-32,sc=(e,t,n)=>e>>>n-32|t<<64-n,cc=(e,t)=>t,ac=(e,t)=>e,Vr=(e,t,n)=>e<<n|t>>>32-n,jr=(e,t,n)=>t<<n|e>>>32-n,qr=(e,t,n)=>t<<n-32|e>>>64-n,Wr=(e,t,n)=>e<<n-32|t>>>64-n;function uc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const se={fromBig:Gt,split:Fr,toBig:ec,shrSH:tc,shrSL:nc,rotrSH:rc,rotrSL:oc,rotrBH:ic,rotrBL:sc,rotr32H:cc,rotr32L:ac,rotlSH:Vr,rotlSL:jr,rotlBH:qr,rotlBL:Wr,add:uc,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],l=w[2*t],f=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=se.add3L(u,l,s);a=se.add3H(y,a,f,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:se.rotr32H(v,p),Dl:se.rotr32L(v,p)},{h,l:d}=se.add(h,d,v,p),{Bh:f,Bl:l}={Bh:f^h,Bl:l^d},{Bh:f,Bl:l}={Bh:se.rotrSH(f,l,24),Bl:se.rotrSL(f,l,24)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=f,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],l=w[2*t],f=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=se.add3L(u,l,s);a=se.add3H(y,a,f,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:se.rotrSH(v,p,16),Dl:se.rotrSL(v,p,16)},{h,l:d}=se.add(h,d,v,p),{Bh:f,Bl:l}={Bh:f^h,Bl:l^d},{Bh:f,Bl:l}={Bh:se.rotrBH(f,l,63),Bl:se.rotrBL(f,l,63)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=f,w[2*n]=d,w[2*n+1]=h,w[2*r]=p,w[2*r+1]=v}class lc extends Hr{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:l,v5l:f,v5h:d,v6l:h,v6h:p,v7l:v,v7h:y}=this;return[t,n,r,o,i,s,c,u,a,l,f,d,h,p,v,y]}set(t,n,r,o,i,s,c,u,a,l,f,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=l|0,this.v5l=f|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}=se.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=Ns;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 Kt=Js(e=>new lc(e)),Xr=new TextEncoder().encode("SS58PRE"),Cn=2,On=e=>{try{const t=Mr.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Cn),o=t.subarray(n.length+r.length),i=Kt(Uint8Array.of(...Xr,...n,...r),{dkLen:64}).subarray(0,Cn);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:fc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},fc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Gr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Kt(Uint8Array.of(...Xr,...t,...n),{dkLen:64}).subarray(0,Cn);return Mr.encode(Uint8Array.of(...t,...n,...r))}};function dc(e,t){return n=>{const r=On(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)=>ut(K(t),dc(t),Gr(e)),Kr="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Kr[r>>4]+Kr[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 pe(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|$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 Yt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ve=(...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},xt=Function.prototype;class Yr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var hc=Object.defineProperty,Zr=e=>{throw TypeError(e)},pc=(e,t,n)=>t in e?hc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Et=(e,t,n)=>pc(e,typeof t!="symbol"?t+"":t,n),Jr=(e,t,n)=>t.has(e)||Zr("Cannot "+n),Te=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),St=(e,t,n)=>t.has(e)?Zr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Jr(e,t,"write to private field"),t.set(e,n),n),Pe,At,Zt,Jt,Qt;const vc=new TextEncoder,yc=new TextDecoder,bc=ae(q,K(1/0))[1];class je{constructor(t,n=!1){if(St(this,Pe),St(this,At,null),St(this,Zt,null),St(this,Jt,null),St(this,Qt,null),Et(this,"asText",()=>Te(this,Qt)??rt(this,Qt,yc.decode(Te(this,Pe)))),Et(this,"asHex",()=>Te(this,Zt)||rt(this,Zt,te(Te(this,Pe)))),Et(this,"asOpaqueHex",()=>Te(this,Jt)||rt(this,Jt,te(this.asBytes()))),Et(this,"asBytes",()=>Te(this,Pe)),Et(this,"asOpaqueBytes",()=>Te(this,At)||rt(this,At,ve(q[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=bc(t);if(r===o.length){rt(this,Pe,o),rt(this,At,t);return}}catch{}throw new Error("Invalid opaque bytes")}else rt(this,Pe,t)}static fromText(t){return new this(vc.encode(t))}static fromHex(t){return new this(pe(t))}static fromOpaqueHex(t){return new this(pe(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Pe=new WeakMap,At=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap;const[mc]=nt();class Tn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(mc(t))}}const Qr=e=>{const t=K.enc(e);return n=>t(n.asBytes())},Nr=e=>{const t=K.dec(e),n=e==null?je:Tn;return r=>n.fromBytes(t(r))},It=e=>M(Qr(e),Nr(e));It.enc=Qr,It.dec=Nr;const O=q,eo=q,gc=Ft(e=>{const t=O.dec(e),n=Math.ceil(t/8);return{bytes:K(n).dec(e),bitsLen:t}}),to=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},gc),wc=ut(V,e=>e.charCodeAt(0),String.fromCharCode),no=e=>{const t=K.enc(e);return n=>t(pe(n))},ro=e=>{const t=K.dec(e);return n=>te(t(n))},qe=e=>M(no(e),ro(e));qe.enc=no,qe.dec=ro;const kc=new TextEncoder,xc=new TextDecoder,Ec=e=>ut(K(e),t=>kc.encode(t),t=>xc.decode(t)),oo=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},io=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},Pn=e=>M(oo(()=>e().enc),io(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),so=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),co=(...e)=>{const t=Ie.enc(...e);return n=>t({tag:n.type,value:n.value})},ao=(...e)=>{const t=Ie.dec(...e);return n=>{const{tag:r,value:o}=t(n);return Bt(r,o)}},ge=(e,...t)=>M(co(Yt(e,([n])=>n),...t),ao(Yt(e,([,n])=>n),...t));ge.enc=co,ge.dec=ao;const uo=[],lo=[],fo=[],Sc=BigInt(0),_t=BigInt(1),Ac=BigInt(2),Ic=BigInt(7),Bc=BigInt(256),_c=BigInt(113);for(let e=0,t=_t,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],uo.push(2*(5*r+n)),lo.push((e+1)*(e+2)/2%64);let o=Sc;for(let i=0;i<7;i++)t=(t<<_t^(t>>Ic)*_c)%Bc,t&Ac&&(o^=_t<<(_t<<BigInt(i))-_t);fo.push(o)}const[Cc,Oc]=Fr(fo,!0),ho=(e,t,n)=>n>32?qr(e,t,n):Vr(e,t,n),po=(e,t,n)=>n>32?Wr(e,t,n):jr(e,t,n);function $c(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],f=ho(a,l,1)^n[c],d=po(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=lo[s],u=ho(o,i,c),a=po(o,i,c),l=uo[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]^=Cc[r],e[1]^=Oc[r]}n.fill(0)}class Un extends zr{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(){oe||ie(this.state32),$c(this.state32,this.rounds),oe||ie(this.state32),this.posOut=0,this.pos=0}update(t){kt(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){kt(this,!1),qt(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(Bn(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 Un(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 Tc=((e,t,n)=>Zs(()=>new Un(t,e,n)))(1,136,256/8),vo=e=>{const t=e.slice(2),n=te(Tc(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("")}`},Pc=K(20)[1],yo=M(e=>{const t=pe(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(vo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ft(e=>vo(te(Pc(e))))),bo=new TextEncoder,mo=new TextDecoder,Uc=ut(K(4),bo.encode.bind(bo),mo.decode.bind(mo)),Ln=$({engine:Uc,payload:qe()}),Lc=ge({consensus:Ln,seal:Ln,preRuntime:Ln,runtimeUpdated:_},[4,5,6,8]),Rn=qe(32),go=$({parentHash:Rn,number:O,stateRoot:Rn,extrinsicRoot:Rn,digests:P(Lc)}),Ue=P(Q),wo=ee(Q),Rc=Ie({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),ko=P($({name:wo,type:O,typeName:wo,docs:Ue})),Mc=$({len:ke,type:O}),Dc=$({bitStoreType:O,bitOrderType:O}),zc=P($({name:Q,fields:ko,index:V,docs:Ue})),Hc=Ie({composite:ko,variant:zc,sequence:O,array:Mc,tuple:P(O),primitive:Rc,compact:O,bitSequence:Dc}),Fc=$({name:Q,type:ee(O)}),Vc=P(Fc),jc=$({id:O,path:Ue,params:Vc,def:Hc,docs:Ue}),Mn=P(jc),qc=Ie({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),Wc=P(qc),Xc=$({hashers:Wc,key:O,value:O}),Gc=$({name:Q,modifier:V,type:Ie({plain:O,map:Xc}),fallback:qe(),docs:Ue}),Kc=ee($({prefix:Q,items:P(Gc)})),xo={name:Q,storage:Kc,calls:ee(O),events:ee(O),constants:P($({name:Q,type:O,value:qe(),docs:Ue})),errors:ee(O),index:V},Yc={...xo,docs:Ue},Zc=new Uint8Array,Eo=e=>M(()=>Zc,()=>e),Jc=$({type:O,version:V,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),So=$({lookup:Mn,pallets:P($({...xo,docs:Eo([])})),extrinsic:Jc,type:O,apis:Eo([])}),Qc=$({name:Q,methods:P($({name:Q,inputs:P($({name:Q,type:O})),output:O,docs:Ue})),docs:Ue}),Nc=$({version:V,address:O,call:O,signature:O,extra:O,signedExtensions:P($({identifier:Q,type:O,additionalSigned:O}))}),Ao=$({lookup:Mn,pallets:P($(Yc)),extrinsic:Nc,type:O,apis:P(Qc),outerEnums:$({call:O,event:O,error:O}),custom:P(ae(Q,$({type:O,value:qe()})))}),Io=()=>{throw new Error("Unsupported metadata version!")},ue=M(Io,Io),ot=$({magicNumber:ke,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:So,v15:Ao})}),Dn=K(),ea=ee(Dn),ta=ae(q,Dn),Bo=e=>{try{return ot.dec(e)}catch{}try{return ot.dec(ea.dec(e))}catch{}try{return ot.dec(Dn.dec(e))}catch{}try{return ot.dec(ta.dec(e)[1])}catch{}throw null},na={dkLen:32},Nt=e=>Kt(e,na),ra={dkLen:16},zn=e=>Kt(e,ra),_o=e=>ve(zn(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=Wt(r^e,16),n=n+r|0,t=Wt(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=Wt(r^e,8),n=n+r|0,t=Wt(t^n,7),{a:e,b:t,c:n,d:r}}function Co(e,t,n,r,o,i,s,c,u,a,l,f,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:l,c:p,d:m}=We(s,l,p,m,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=Xe(s,l,p,m,n[t+e[g++]]),{a:c,b:f,c:v,d:S}=We(c,f,v,S,n[t+e[g++]]),{a:c,b:f,c:v,d:S}=Xe(c,f,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:l,c:v,d:y}=We(i,l,v,y,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=Xe(i,l,v,y,n[t+e[g++]]),{a:s,b:f,c:d,d:b}=We(s,f,d,b,n[t+e[g++]]),{a:s,b:f,c:d,d:b}=Xe(s,f,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:l,v7:f,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 Hn extends Hr{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),oe||ie(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Hn({dkLen:32},32).update(t.context).digest();this.IV=tt(r),oe||ie(this.IV),this.flags=n|64}else this.IV=Le.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Ks(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:c,l:u}=Gt(BigInt(t),!0),{v0:a,v1:l,v2:f,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]=l^m,i[2]=f^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(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}=Gt(BigInt(this.chunkOut++));oe||ie(o);const{v0:u,v1:a,v2:l,v3:f,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]=l^m,i[3]=f^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,oe||(ie(o),ie(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,oe||ie(this.buffer32),this.compress(this.buffer32,0,!0),oe||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){kt(this,!1),qt(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(Bn(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 oa=Qs(e=>new Hn(e)),ia={dkLen:32},$o=e=>oa(e,ia),sa=e=>ve($o(e),e),To=e=>e,it=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Fn=2n**64n-1n,ne=(e,t)=>e<<t&Fn|e>>64n-t,U=(e,t)=>e*t&Fn,Y=(e,t)=>e+t&Fn,Z=11400714785074694791n,ye=14029467366897019727n,Po=1609587929392839161n,Ct=9650029242287828579n,Uo=2870177450012600261n;function Ge(e,t=0n){let n=Y(Y(t,Z),ye),r=Y(t,ye),o=t,i=t-Z,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(ne(Y(n,U(y,ye)),31n),Z),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(ne(Y(r,U(y,ye)),31n),Z),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(ne(Y(o,U(y,ye)),31n),Z),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(ne(Y(i,U(y,ye)),31n),Z),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,l=0;for(s>=32?(a=ne(n,1n),a=Y(a,ne(r,7n)),a=Y(a,ne(o,12n)),a=Y(a,ne(i,18n)),n=U(ne(U(n,ye),31n),Z),a=a^n,a=Y(U(a,Z),Ct),r=U(ne(U(r,ye),31n),Z),a=a^r,a=Y(U(a,Z),Ct),o=U(ne(U(o,ye),31n),Z),a=a^o,a=Y(U(a,Z),Ct),i=U(ne(U(i,ye),31n),Z),a=a^i,a=Y(U(a,Z),Ct)):a=Y(t,Uo),a=Y(a,BigInt(s));l<=c-8;){let d=it(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]);d=U(ne(U(d,ye),31n),Z),a=Y(U(ne(a^d,27n),Z),Ct),l+=8}if(l+4<=c){let d=U(it(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),Z);a=Y(U(ne(a^d,23n),ye),Po),l+=4}for(;l<c;){const d=U(it(e[l++],0,0,0),Uo);a=U(ne(a^d,11n),Z)}let f=a>>33n;return a=U(a^f,ye),f=a>>29n,a=U(a^f,Po),f=a>>32n,a^=f,a}const en=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},Lo=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},Ro=e=>ve(wt.enc(Ge(e)),e),Mo=new TextEncoder,ca=new Map([[To,0],[Ro,8],[_o,16],[zn,-16],[Nt,-32],[en,-16],[Lo,-32]]),Do=e=>{const t=en(Mo.encode(e));return(n,r,...o)=>{const i=ve(t,en(Mo.encode(n))),s=te(i),c=l=>{if(!l.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(o.length===0)return[];const f=pe(l.slice(s.length)),d=new Array(o.length);for(let h=0,p=0;h<o.length;h++){const[v,y]=o[h],b=ca.get(y);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[h]=te(f.slice(p,p+m)),p+=m}else p+=b,d[h]=v.dec(f.slice(p)),p+=v.enc(d[h]).length}return d},u=o.map(([{enc:l},f])=>d=>f(l(d)));return{enc:(...l)=>te(ve(i,...l.map((f,d)=>u[d](f)))),dec:r,keyDecoder:c}}};var zo=Object.freeze({__proto__:null,AccountId:nt,Bin:It,Binary:je,Blake2128:zn,Blake2128Concat:_o,Blake2256:Nt,Blake3256:$o,Blake3256Concat:sa,Bytes:K,Enum:Bt,FixedSizeBinary:Tn,Hex:qe,Identity:To,Option:ee,Result:jt,ScaleEnum:Ie,Self:Pn,Storage:Do,Struct:$,Tuple:ae,Twox128:en,Twox256:Lo,Twox64Concat:Ro,Variant:ge,Vector:P,_Enum:so,_void:_,bitSequence:to,blockHeader:go,bool:As,char:wc,compact:q,compactBn:eo,compactNumber:O,createCodec:M,createDecoder:Ft,decAnyMetadata:Bo,enhanceCodec:ut,enhanceDecoder:Vt,enhanceEncoder:gt,ethAccount:yo,fixedStr:Ec,fromBufferToBase58:Gr,getSs58AddressInfo:On,h64:Ge,i128:xs,i16:ms,i256:Ss,i32:gs,i64:ws,i8:bs,metadata:ot,selfDecoder:io,selfEncoder:oo,str:Q,u128:ks,u16:Ne,u256:Es,u32:ke,u64:wt,u8:V,v14:So,v14Lookup:Mn,v15:Ao});const st=q,aa=P(ae(Q,st)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},ua=ge(Object.fromEntries(Object.values(R).map(e=>[e,_]))),la=P(ae(Q,ee(Pn(()=>Vn)))),fa=P(st),da=$({typeRef:st,length:ee(st)}),ha=ee(q),pa=st,va=$({ok:st,ko:st}),Vn=ge({struct:aa,terminal:ua,enum:la,tuple:fa,array:da,binary:ha,option:pa,result:va}),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},Ot=e=>({type:"terminal",value:{type:e}});function $t(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Ot(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 Ot(R.bits);case"compact":return Ot(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"?$t(r.value,t):$t(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 Ot(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 Ot(R.void)}}function jn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>jn(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,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 ba=Object.defineProperty,ma=(e,t,n)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ga=(e,t,n)=>ma(e,t+"",n);class Ho{constructor(t=[]){ga(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 qn(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 Ho([[e,n]])}:le(c)}i.set(e,null);const s=wa(e,n,(c,u)=>qn(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 wa(e,t,n){if(e.type!==t.type)return t.type==="option"?tn(n(e,t.value),2):e.type==="option"?tn(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(Vo(e.value,t.value));case"array":const o=e,i=le(Vo(o.value.length,t.value.length));return Wn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,f=Object.fromEntries(t.value),d=l.value.length===t.value.length?3:2;return tn(Fo(l.value.map(([h,p])=>()=>h in f?n(p,f[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 tn(Wn(t.value.map(([l,f])=>()=>n(c[l],f))),u);case"tuple":{const l=e,f=le(xa(l.value,t.value));return Wn([f,...t.value.map((d,h)=>()=>n(l.value[h],d))])}case"result":const a=e;return Fo([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const tn=(e,t)=>({...e,level:Math.min(e.level,t)}),ka=new Ho,le=e=>({level:e,assumptions:ka}),Wn=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},Fo=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)},xa=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Vo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,jo=ge({lookup:q,typedef:Vn}),lt=e=>({type:"lookup",value:e}),Xn=e=>({type:"typedef",value:e}),nn=Xn({type:"terminal",value:{type:R.void}}),Ea=$({args:jo,values:jo});function Sa(e){if(e.type.tag==="plain")return{args:nn,values:lt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:lt(t),values:lt(n)}}function Aa(e){return{args:Xn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:lt(e.output)}}function Ia(e){return e.type==="lookupEntry"?lt(e.value.id):Xn($t(e))}function Ba(e){return{args:nn,values:lt(e)}}function _a(e,t,n,r,o){const i=(s,c)=>s.type==="lookup"?c(s.value):s.value;return{args:qn(i(e.args,t),t,i(n.args,r),r,o).level,values:qn(i(n.values,r),r,i(e.values,t),t,o).level}}function qo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return jn(n,r,t)}const ft=()=>{},we={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},rn={chainName:"",genesisHash:"",properties:""},Gn={broadcast:"",stop:""};Object.entries({chainHead:we,chainSpec:rn,transaction:Gn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ca=e=>(t,n)=>{let r=e(Gn.broadcast,[t],{onSuccess:o=>{r=o===null?ft:()=>{e(Gn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Wo extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class on extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class sn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Xo extends Error{constructor(t){super(t),this.name="OperationError"}}class cn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Oa(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Go=()=>{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)})}}},an=e=>(...t)=>new Promise((n,r)=>{let o=xt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Yr)};s?.addEventListener("abort",c,{once:!0});const u=a=>l=>{o=xt,s?.removeEventListener("abort",c),a(l)};o=e(u(n),u(r),...i)}),Ko=(e,t)=>n=>an((r,o,...i)=>{let s=!0,c=()=>{s=!1};const[u,a]=t(...i);return n(e,u,{onSuccess:(l,f)=>{if(l.result==="limitReached")return o(new sn);const{operationId:d}=l,h=()=>{n(we.stopOperation,[d])};if(!s)return h();let p=ft;const v=b=>{s=!1,p(),r(b)},y=b=>{s=!1,p(),o(b)};p=f(d,{next:b=>{const m=b;m.event==="operationError"?o(new Xo(m.error)):m.event==="operationInaccessible"?o(new cn):a(b,v,y)},error:y}),c=()=>{s&&(p(),h())}},onError:o}),()=>{c()}}),$a=Ko(we.body,e=>[[e],(t,n)=>{n(t.value)}]),Ta=Ko(we.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),Pa=e=>t=>new Promise((n,r)=>{e(we.header,[t],{onSuccess:n,onError:r})}),Yo=e=>(t,n,r,o,i,s,c)=>{if(n.length===0)return s(),xt;let u=!0,a=()=>{u=!1};return e(we.storage,[t,n,r],{onSuccess:(l,f)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return i(new sn);const{operationId:d}=l,h=()=>{e(we.stopOperation,[d])};if(!u)return h();const p=f(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{y();break}case"operationError":{v(new Xo(b.error));break}case"operationInaccessible":{v(new cn);break}default:e(we.continue,[b.operationId])}},error:i});a=()=>{p(),e(we.stopOperation,[l.operationId])};const v=b=>{a=xt,p(),i(b)},y=()=>{a=xt,p(),s()};c(l.discardedItems)},onError:i}),()=>{a()}},Ua=e=>{const t=Yo(e);return an((n,r,o,i,s,c)=>{const u=i.startsWith("descendants");let a=u?[]:null;const f=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&&(f(),r(new sn))});return f})},La=e=>t=>t.length>0?new Promise((n,r)=>{e(we.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class un extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function Ra(e){return e.operationId!==void 0}function Ma(e){return(t,n,r)=>{const o=Go(),i=new Set,s=Oa();let c=s.promise;const u=p=>{if(Ra(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 Wo),d(!1)},a=p=>{r(p),d(!(p instanceof un))},l=(p,v)=>{const y=v(p,{next:u,error:a});d=(b=!0)=>{c=null,d=ft,y(),b&&e(we.unfollow,[p]),o.errorAll(new on),i.forEach(m=>{m()}),i.clear()},c=p,s.res(p)},f=p=>{p instanceof un?d(!1):r(p),c=null,s.res(p)};let d=e(we.follow,[t],{onSuccess:l,onError:f});const h=(p,v,y)=>{const b=()=>{y?.onError(new on)};if(c===null)return b(),ft;const m=g=>{if(!y)return e(p,[g,...v]);i.add(b);const x=(A,C)=>c===null?(C.error(new on),ft):(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=ft;return c.then(g=>{if(g instanceof Error)return b();c&&(S=m(g))}),()=>{S()}};return{unfollow(){d(),c=null},body:$a(h),call:Ta(h),header:Pa(h),storage:Ua(h),storageSubscription:Yo(h),unpin:La(h),_request:h}}}var Da=Object.defineProperty,za=(e,t,n)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zo=(e,t,n)=>za(e,typeof t!="symbol"?t+"":t,n);class Jo extends Error{constructor(t){super(t.message),Zo(this,"code"),Zo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let Ha=1;const Fa=e=>{let t=Ha++;const n=new Map,r=Go();let o=null;const i=(l,f,d)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:f,params:d}))};function s(l){try{let f,d,h,p,v;if({id:f,result:d,error:h,params:p}=JSON.parse(l),f){const m=n.get(f);return m?(n.delete(f),h?m.onError(new Jo(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 Jo(h)):r.next(b,d)}catch(f){console.warn("Error parsing incomming message: "+l),console.error(f)}}o=e(s);const c=()=>{o?.disconnect(),o=null,r.errorAll(new un),n.forEach(l=>l.onError(new un)),n.clear()};let u=1;return{request:(l,f,d)=>{if(!o)throw new Error("Not connected");const h=`${t}-${u++}`;return d&&n.set(h,d),i(h,l,f),()=>{n.delete(h)}},disconnect:c}},Va=e=>{const t=an((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(rn.chainName,[]),t(rn.genesisHash,[]),t(rn.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},ln=new Map,ja=e=>{const t=ln.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Fa(e),o=()=>{const s=ln.get(e);!s||s.refCount<=1?(ln.delete(e),r()):s.refCount--},i={chainHead:Ma(n),transaction:Ca(n),getChainSpecData:Va(n),destroy:o,request:an((s,c,u,a)=>n(u,a,{onSuccess:s,onError:c})),_request:n};return ln.set(e,{client:i,refCount:1}),i};var Kn=function(e,t){return Kn=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])},Kn(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");Kn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function qa(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(f){s(f)}}function u(l){try{a(r.throw(l))}catch(f){s(f)}}function a(l){l.done?i(l.value):o(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Qo(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 dt(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 ht(e){return this instanceof ht?(this.v=e,this):new ht(e)}function Wa(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,f)}}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 ht?Promise.resolve(h.value.v).then(l,f):d(i[0][2],h)}function l(h){u("next",h)}function f(h){u("throw",h)}function d(h,p){h(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Xa(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 dt=="function"?dt(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 Yn(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 Zn=Yn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(ve,mt){typeof exports=="object"&&typeof module<"u"?mt(exports):typeof define=="function"&&define.amd?define(["exports"],mt):(ve=typeof globalThis<"u"?globalThis:ve||self,mt(ve.papi={}))})(this,function(ve){"use strict";var mt=Object.defineProperty,ps=(e,t,n)=>t in e?mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yr=(e,t,n)=>(ps(e,typeof t!="symbol"?t+"":t,n),n),In={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 vs(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|In[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=In[e[s]],u=In[e[s+1]];o[t+i++]=c<<4|u}return o}var br=class extends Uint8Array{constructor(e){super(e),yr(this,"i",0),yr(this,"v"),this.v=new DataView(e)}},me=e=>t=>e(t instanceof br?t:new br(t instanceof Uint8Array?t.buffer:typeof t=="string"?vs(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 Ft(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 Vt=me,M=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gt=(e,t)=>n=>e(t(n)),jt=(e,t)=>n=>t(e(n)),ut=([e,t],n,r)=>M(gt(e,n),jt(t,r));function ys(e,t){return me(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function bs(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(bs(e,n),ys(e,t))}var V=He(1,"getUint8","setUint8"),Fe=He(2,"getUint16","setUint16"),ke=He(4,"getUint32","setUint32"),wt=He(8,"getBigUint64","setBigUint64"),ms=He(1,"getInt8","setInt8"),gs=He(2,"getInt16","setInt16"),ws=He(4,"getInt32","setInt32"),ks=He(8,"getBigInt64","setBigInt64"),mr=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},gr=e=>me(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}),xs=M(mr,gr("getBigUint64")),Es=M(mr,gr("getBigInt64")),wr=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},kr=e=>me(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}),Ss=M(wr,kr("getBigUint64")),As=M(wr,kr("getBigInt64")),Is=ut(V,e=>e?1:0,Boolean),Bs=[V[1],Fe[1],ke[1]],_s=me(e=>{const t=e[e.i],n=t&3;if(n<3)return Bs[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=wt[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(ke[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(Fe[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(V[1](e))<<s|o),o}),Cs=1n<<56n,Os=1<<24,$s=256,Ts=4294967295n,Ps=64,Us=16384,Ls=1<<30,Rs=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Ps)return V[0](t);if(e<Us)return Fe[0](t|1);if(e<Ls)return ke[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Cs;)n.push(wt[0](r)),r>>=64n;r>=Os&&(n.push(ke[0](Number(r&Ts))),r>>=32n);let o=Number(r);o>=$s&&(n.push(Fe[0](o)),o>>=16),o&&n.push(V[0](o));const i=Ae(n);return i[0]=i.length-5<<2|3,i},j=M(Rs,_s),Ms=new TextEncoder,Ds=e=>{const t=Ms.encode(e);return Ae([j.enc(t.length),t])},zs=new TextDecoder,Hs=me(e=>{let t=j.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,zs.decode(n)}),Q=M(Ds,Hs),Fs=()=>{},Vs=new Uint8Array(0),_=M(()=>Vs,Fs),xr=e=>e===void 0?t=>Ae([j.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Er=e=>me(t=>{const n=e===void 0?j.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(xr(e),Er(e));Y.enc=xr,Y.dec=Er;var Sr=(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)])},Ar=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return me(o=>{const i=V.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},Ie=(e,...t)=>M(Sr(Ft(e,([n])=>n),...t),Ar(Ft(e,([,n])=>n),...t));Ie.enc=Sr,Ie.dec=Ar;var Ir=e=>me(t=>V[1](t)>0?e(t):void 0),Br=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ae([n,e(t)]))},ee=e=>M(Br(e[0]),Ir(e[1]));ee.enc=Br,ee.dec=Ir;var _r=(e,t)=>me(n=>{const r=V[1](n)===0,i=(r?e:t)(n);return{success:r,value:i}}),Cr=(e,t)=>({success:n,value:r})=>Ae([V[0](n?0:1),(n?e:t)(r)]),qt=(e,t)=>M(Cr(e[0],t[0]),_r(e[1],t[1]));qt.dec=_r,qt.enc=Cr;var Or=(...e)=>me(t=>e.map(n=>n(t))),$r=(...e)=>t=>Ae(e.map((n,r)=>n(t[r]))),ae=(...e)=>M($r(...e.map(([t])=>t)),Or(...e.map(([,t])=>t)));ae.enc=$r,ae.dec=Or;var Tr=e=>{const t=Object.keys(e);return gt(ae.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Pr=e=>{const t=Object.keys(e);return jt(ae.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},O=e=>M(Tr(Ft(e,t=>t[0])),Pr(Ft(e,t=>t[1])));O.enc=Tr,O.dec=Pr;var Ur=(e,t)=>t>=0?n=>Ae(n.map(e)):n=>Ae([j.enc(n.length),Ae(n.map(e))]),Lr=(e,t)=>me(n=>{const r=t>=0?t:j.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),U=(e,t)=>M(Ur(e[0],t),Lr(e[1],t));U.enc=Ur,U.dec=Lr;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function js(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function qs(...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 Ws(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 Xs(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 Rr(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 f=Math.floor(l/n);if(i[u]=f,!Number.isSafeInteger(f)||f*n+s!==l)throw new Error("convertRadix: carry overflow");if(c)f?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 Gs(e){return{encode:t=>{if(!js(t))throw new Error("radix.encode input should be Uint8Array");return Rr(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(Rr(t,e,2**8))}}}const Mr=(e=>qs(Gs(58),Ws(e),Xs("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function tt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ks(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Wt(e,...t){if(!Ks(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 kt(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 Bn(e,t){Wt(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 Ys=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),nt=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Xt=(e,t)=>e<<32-t|e>>>t,oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Dr=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,Oe=oe?e=>e:e=>Dr(e);function ie(e){for(let t=0;t<e.length;t++)e[t]=Dr(e[t])}function Zs(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=Zs(e)),Wt(e),e}class zr{clone(){return this._cloneInto()}}function Js(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 Qs(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 Ns(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 ec=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 Hr extends zr{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,tt(t),tt(n),tt(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=nt(this.buffer=new Uint8Array(t))}update(t){kt(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&&(oe||ie(o),this.compress(o,0,!1),oe||ie(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 f=new Uint32Array(c,l,Math.floor((i-u)/4));oe||ie(f);for(let d=0;u+n<i;d+=o.length,u+=n)this.length+=n,this.compress(f,d,!1);oe||ie(f);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){kt(this),Bn(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),oe||ie(r),this.compress(r,0,!0),oe||ie(r);const o=nt(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 Gt=BigInt(2**32-1),_n=BigInt(32);function Kt(e,t=!1){return t?{h:Number(e&Gt),l:Number(e>>_n&Gt)}:{h:Number(e>>_n&Gt)|0,l:Number(e&Gt)|0}}function Fr(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}=Kt(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const tc=(e,t)=>BigInt(e>>>0)<<_n|BigInt(t>>>0),nc=(e,t,n)=>e>>>n,rc=(e,t,n)=>e<<32-n|t>>>n,oc=(e,t,n)=>e>>>n|t<<32-n,ic=(e,t,n)=>e<<32-n|t>>>n,sc=(e,t,n)=>e<<64-n|t>>>n-32,cc=(e,t,n)=>e>>>n-32|t<<64-n,ac=(e,t)=>t,uc=(e,t)=>e,Vr=(e,t,n)=>e<<n|t>>>32-n,jr=(e,t,n)=>t<<n|e>>>32-n,qr=(e,t,n)=>t<<n-32|e>>>64-n,Wr=(e,t,n)=>e<<n-32|t>>>64-n;function lc(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const se={fromBig:Kt,split:Fr,toBig:tc,shrSH:nc,shrSL:rc,rotrSH:oc,rotrSL:ic,rotrBH:sc,rotrBL:cc,rotr32H:ac,rotr32L:uc,rotlSH:Vr,rotlSL:jr,rotlBH:qr,rotlBL:Wr,add:lc,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)},K=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w=new Uint32Array(32);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],f=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=se.add3L(u,l,s);a=se.add3H(y,a,f,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:se.rotr32H(v,p),Dl:se.rotr32L(v,p)},{h,l:d}=se.add(h,d,v,p),{Bh:f,Bl:l}={Bh:f^h,Bl:l^d},{Bh:f,Bl:l}={Bh:se.rotrSH(f,l,24),Bl:se.rotrSL(f,l,24)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=f,w[2*n]=d,w[2*n+1]=h,w[2*r]=p,w[2*r+1]=v}function je(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],f=w[2*t+1],d=w[2*n],h=w[2*n+1],p=w[2*r],v=w[2*r+1],y=se.add3L(u,l,s);a=se.add3H(y,a,f,c),u=y|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:se.rotrSH(v,p,16),Dl:se.rotrSL(v,p,16)},{h,l:d}=se.add(h,d,v,p),{Bh:f,Bl:l}={Bh:f^h,Bl:l^d},{Bh:f,Bl:l}={Bh:se.rotrBH(f,l,63),Bl:se.rotrBL(f,l,63)},w[2*e]=u,w[2*e+1]=a,w[2*t]=l,w[2*t+1]=f,w[2*n]=d,w[2*n+1]=h,w[2*r]=p,w[2*r+1]=v}class fc extends Hr{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=K[0]|0,this.v0h=K[1]|0,this.v1l=K[2]|0,this.v1h=K[3]|0,this.v2l=K[4]|0,this.v2h=K[5]|0,this.v3l=K[6]|0,this.v3h=K[7]|0,this.v4l=K[8]|0,this.v4h=K[9]|0,this.v5l=K[10]|0,this.v5h=K[11]|0,this.v6l=K[12]|0,this.v6h=K[13]|0,this.v7l=K[14]|0,this.v7h=K[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=nt($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=nt($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:f,v5h:d,v6l:h,v6h:p,v7l:v,v7h:y}=this;return[t,n,r,o,i,s,c,u,a,l,f,d,h,p,v,y]}set(t,n,r,o,i,s,c,u,a,l,f,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=l|0,this.v5l=f|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(K,16);let{h:o,l:i}=se.fromBig(BigInt(this.length));w[24]=K[8]^i,w[25]=K[9]^o,r&&(w[28]=~w[28],w[29]=~w[29]);let s=0;const c=ec;for(let u=0;u<12;u++)Ve(0,4,8,12,t,n+2*c[s++]),je(0,4,8,12,t,n+2*c[s++]),Ve(1,5,9,13,t,n+2*c[s++]),je(1,5,9,13,t,n+2*c[s++]),Ve(2,6,10,14,t,n+2*c[s++]),je(2,6,10,14,t,n+2*c[s++]),Ve(3,7,11,15,t,n+2*c[s++]),je(3,7,11,15,t,n+2*c[s++]),Ve(0,5,10,15,t,n+2*c[s++]),je(0,5,10,15,t,n+2*c[s++]),Ve(1,6,11,12,t,n+2*c[s++]),je(1,6,11,12,t,n+2*c[s++]),Ve(2,7,8,13,t,n+2*c[s++]),je(2,7,8,13,t,n+2*c[s++]),Ve(3,4,9,14,t,n+2*c[s++]),je(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 Yt=Qs(e=>new fc(e)),Xr=new TextEncoder().encode("SS58PRE"),Cn=2,On=e=>{try{const t=Mr.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Cn),o=t.subarray(n.length+r.length),i=Yt(Uint8Array.of(...Xr,...n,...r),{dkLen:64}).subarray(0,Cn);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:dc(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},dc=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Gr=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Yt(Uint8Array.of(...Xr,...t,...n),{dkLen:64}).subarray(0,Cn);return Mr.encode(Uint8Array.of(...t,...n,...r))}};function hc(e,t){return n=>{const r=On(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 rt=(e=42,t=32)=>ut(Y(t),hc(t),Gr(e)),Kr="0123456789abcdef";function te(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Kr[r>>4]+Kr[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 ye(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 Zt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const ue=(...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},xt=Function.prototype;class Yr extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var pc=Object.defineProperty,Zr=e=>{throw TypeError(e)},vc=(e,t,n)=>t in e?pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Et=(e,t,n)=>vc(e,typeof t!="symbol"?t+"":t,n),Jr=(e,t,n)=>t.has(e)||Zr("Cannot "+n),Te=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),St=(e,t,n)=>t.has(e)?Zr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ot=(e,t,n,r)=>(Jr(e,t,"write to private field"),t.set(e,n),n),Pe,At,Jt,Qt,Nt;const yc=new TextEncoder,bc=new TextDecoder,mc=ae(j,Y(1/0))[1];class Ue{constructor(t,n=!1){if(St(this,Pe),St(this,At,null),St(this,Jt,null),St(this,Qt,null),St(this,Nt,null),Et(this,"asText",()=>Te(this,Nt)??ot(this,Nt,bc.decode(Te(this,Pe)))),Et(this,"asHex",()=>Te(this,Jt)||ot(this,Jt,te(Te(this,Pe)))),Et(this,"asOpaqueHex",()=>Te(this,Qt)||ot(this,Qt,te(this.asBytes()))),Et(this,"asBytes",()=>Te(this,Pe)),Et(this,"asOpaqueBytes",()=>Te(this,At)||ot(this,At,ue(j[0](Te(this,Pe).length),Te(this,Pe)))),n){try{const[r,o]=mc(t);if(r===o.length){ot(this,Pe,o),ot(this,At,t);return}}catch{}throw new Error("Invalid opaque bytes")}else ot(this,Pe,t)}static fromText(t){return new this(yc.encode(t))}static fromHex(t){return new this(ye(t))}static fromOpaqueHex(t){return new this(ye(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Pe=new WeakMap,At=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Nt=new WeakMap;const[gc]=rt();class Tn extends Ue{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(gc(t))}}const Qr=e=>{const t=Y.enc(e);return n=>t(n.asBytes())},Nr=e=>{const t=Y.dec(e),n=e==null?Ue:Tn;return r=>n.fromBytes(t(r))},It=e=>M(Qr(e),Nr(e));It.enc=Qr,It.dec=Nr;const C=j,eo=j,wc=Vt(e=>{const t=C.dec(e),n=Math.ceil(t/8);return{bytes:Y(n).dec(e),bitsLen:t}}),to=M(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=C.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},wc),kc=ut(V,e=>e.charCodeAt(0),String.fromCharCode),no=e=>{const t=Y.enc(e);return n=>t(ye(n))},ro=e=>{const t=Y.dec(e);return n=>te(t(n))},qe=e=>M(no(e),ro(e));qe.enc=no,qe.dec=ro;const xc=new TextEncoder,Ec=new TextDecoder,Sc=e=>ut(Y(e),t=>xc.encode(t),t=>Ec.decode(t)),oo=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},io=e=>{let t=n=>{const r=e(),o=r;return t=r,o(n)};return n=>t(n)},Pn=e=>M(oo(()=>e().enc),io(()=>e().dec)),Bt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),so=new Proxy({},{get(e,t){return n=>Bt(t,n)}}),co=(...e)=>{const t=Ie.enc(...e);return n=>t({tag:n.type,value:n.value})},ao=(...e)=>{const t=Ie.dec(...e);return n=>{const{tag:r,value:o}=t(n);return Bt(r,o)}},ge=(e,...t)=>M(co(Zt(e,([n])=>n),...t),ao(Zt(e,([,n])=>n),...t));ge.enc=co,ge.dec=ao;const uo=[],lo=[],fo=[],Ac=BigInt(0),_t=BigInt(1),Ic=BigInt(2),Bc=BigInt(7),_c=BigInt(256),Cc=BigInt(113);for(let e=0,t=_t,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],uo.push(2*(5*r+n)),lo.push((e+1)*(e+2)/2%64);let o=Ac;for(let i=0;i<7;i++)t=(t<<_t^(t>>Bc)*Cc)%_c,t&Ic&&(o^=_t<<(_t<<BigInt(i))-_t);fo.push(o)}const[Oc,$c]=Fr(fo,!0),ho=(e,t,n)=>n>32?qr(e,t,n):Vr(e,t,n),po=(e,t,n)=>n>32?Wr(e,t,n):jr(e,t,n);function Tc(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],f=ho(a,l,1)^n[c],d=po(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=lo[s],u=ho(o,i,c),a=po(o,i,c),l=uo[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]^=Oc[r],e[1]^=$c[r]}n.fill(0)}class Un extends zr{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,tt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=nt(this.state)}keccak(){oe||ie(this.state32),Tc(this.state32,this.rounds),oe||ie(this.state32),this.posOut=0,this.pos=0}update(t){kt(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){kt(this,!1),Wt(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 tt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Bn(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 Un(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 Pc=((e,t,n)=>Js(()=>new Un(t,e,n)))(1,136,256/8),vo=e=>{const t=e.slice(2),n=te(Pc(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("")}`},Uc=Y(20)[1],yo=M(e=>{const t=ye(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=te(t);if(e===n||e===n.toUpperCase())return t;if(vo(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Vt(e=>vo(te(Uc(e))))),bo=new TextEncoder,mo=new TextDecoder,Lc=ut(Y(4),bo.encode.bind(bo),mo.decode.bind(mo)),Ln=O({engine:Lc,payload:qe()}),Rc=ge({consensus:Ln,seal:Ln,preRuntime:Ln,runtimeUpdated:_},[4,5,6,8]),Rn=qe(32),go=O({parentHash:Rn,number:C,stateRoot:Rn,extrinsicRoot:Rn,digests:U(Rc)}),Le=U(Q),wo=ee(Q),Mc=Ie({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),ko=U(O({name:wo,type:C,typeName:wo,docs:Le})),Dc=O({len:ke,type:C}),zc=O({bitStoreType:C,bitOrderType:C}),Hc=U(O({name:Q,fields:ko,index:V,docs:Le})),Fc=Ie({composite:ko,variant:Hc,sequence:C,array:Dc,tuple:U(C),primitive:Mc,compact:C,bitSequence:zc}),Vc=O({name:Q,type:ee(C)}),jc=U(Vc),qc=O({id:C,path:Le,params:jc,def:Fc,docs:Le}),Mn=U(qc),Wc=Ie({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),Xc=U(Wc),Gc=O({hashers:Xc,key:C,value:C}),Kc=O({name:Q,modifier:V,type:Ie({plain:C,map:Gc}),fallback:qe(),docs:Le}),Yc=ee(O({prefix:Q,items:U(Kc)})),xo={name:Q,storage:Yc,calls:ee(C),events:ee(C),constants:U(O({name:Q,type:C,value:qe(),docs:Le})),errors:ee(C),index:V},Zc={...xo,docs:Le},Jc=new Uint8Array,Eo=e=>M(()=>Jc,()=>e),Qc=O({type:C,version:V,signedExtensions:U(O({identifier:Q,type:C,additionalSigned:C}))}),So=O({lookup:Mn,pallets:U(O({...xo,docs:Eo([])})),extrinsic:Qc,type:C,apis:Eo([])}),Nc=O({name:Q,methods:U(O({name:Q,inputs:U(O({name:Q,type:C})),output:C,docs:Le})),docs:Le}),ea=O({version:V,address:C,call:C,signature:C,extra:C,signedExtensions:U(O({identifier:Q,type:C,additionalSigned:C}))}),Ao=O({lookup:Mn,pallets:U(O(Zc)),extrinsic:ea,type:C,apis:U(Nc),outerEnums:O({call:C,event:C,error:C}),custom:U(ae(Q,O({type:C,value:qe()})))}),Io=()=>{throw new Error("Unsupported metadata version!")},le=M(Io,Io),it=O({magicNumber:ke,metadata:Ie({v0:le,v1:le,v2:le,v3:le,v4:le,v5:le,v6:le,v7:le,v8:le,v9:le,v10:le,v11:le,v12:le,v13:le,v14:So,v15:Ao})}),Dn=Y(),ta=ee(Dn),na=ae(j,Dn),Bo=e=>{try{return it.dec(e)}catch{}try{return it.dec(ta.dec(e))}catch{}try{return it.dec(Dn.dec(e))}catch{}try{return it.dec(na.dec(e)[1])}catch{}throw null},ra={dkLen:32},Ct=e=>Yt(e,ra),oa={dkLen:16},zn=e=>Yt(e,oa),_o=e=>ue(zn(e),e),Re=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function We(e,t,n,r,o){return e=e+t+o|0,r=Xt(r^e,16),n=n+r|0,t=Xt(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=Xt(r^e,8),n=n+r|0,t=Xt(t^n,7),{a:e,b:t,c:n,d:r}}function Co(e,t,n,r,o,i,s,c,u,a,l,f,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:l,c:p,d:m}=We(s,l,p,m,n[t+e[g++]]),{a:s,b:l,c:p,d:m}=Xe(s,l,p,m,n[t+e[g++]]),{a:c,b:f,c:v,d:S}=We(c,f,v,S,n[t+e[g++]]),{a:c,b:f,c:v,d:S}=Xe(c,f,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:l,c:v,d:y}=We(i,l,v,y,n[t+e[g++]]),{a:i,b:l,c:v,d:y}=Xe(i,l,v,y,n[t+e[g++]]),{a:s,b:f,c:d,d:b}=We(s,f,d,b,n[t+e[g++]]),{a:s,b:f,c:d,d:b}=Xe(s,f,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:l,v7:f,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 Hn extends Hr{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,tt(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=nt(r),oe||ie(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new Hn({dkLen:32},32).update(t.context).digest();this.IV=nt(r),oe||ie(this.IV),this.flags=n|64}else this.IV=Re.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Ys(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,o=0){const{state:i,pos:s}=this,{h:c,l:u}=Kt(BigInt(t),!0),{v0:a,v1:l,v2:f,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:T}=Co(Oo,o,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],Re[0],Re[1],Re[2],Re[3],c,u,s,n);i[0]=a^b,i[1]=l^m,i[2]=f^S,i[3]=d^g,i[4]=h^x,i[5]=p^E,i[6]=v^A,i[7]=y^T}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}=Kt(BigInt(this.chunkOut++));oe||ie(o);const{v0:u,v1:a,v2:l,v3:f,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],Re[0],Re[1],Re[2],Re[3],c,s,n,r);i[0]=u^y,i[1]=a^b,i[2]=l^m,i[3]=f^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,oe||(ie(o),ie(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,oe||ie(this.buffer32),this.compress(this.buffer32,0,!0),oe||ie(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){kt(this,!1),Wt(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 tt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Bn(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 ia=Ns(e=>new Hn(e)),sa={dkLen:32},$o=e=>ia(e,sa),ca=e=>ue($o(e),e),To=e=>e,st=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Fn=2n**64n-1n,ne=(e,t)=>e<<t&Fn|e>>64n-t,L=(e,t)=>e*t&Fn,Z=(e,t)=>e+t&Fn,J=11400714785074694791n,be=14029467366897019727n,Po=1609587929392839161n,Ot=9650029242287828579n,Uo=2870177450012600261n;function Ge(e,t=0n){let n=Z(Z(t,J),be),r=Z(t,be),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=st(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),n=L(ne(Z(n,L(y,be)),31n),J),h+=8,y=st(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),r=L(ne(Z(r,L(y,be)),31n),J),h+=8,y=st(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),o=L(ne(Z(o,L(y,be)),31n),J),h+=8,y=st(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=L(ne(Z(i,L(y,be)),31n),J),h+=8}while(h<=v)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,l=0;for(s>=32?(a=ne(n,1n),a=Z(a,ne(r,7n)),a=Z(a,ne(o,12n)),a=Z(a,ne(i,18n)),n=L(ne(L(n,be),31n),J),a=a^n,a=Z(L(a,J),Ot),r=L(ne(L(r,be),31n),J),a=a^r,a=Z(L(a,J),Ot),o=L(ne(L(o,be),31n),J),a=a^o,a=Z(L(a,J),Ot),i=L(ne(L(i,be),31n),J),a=a^i,a=Z(L(a,J),Ot)):a=Z(t,Uo),a=Z(a,BigInt(s));l<=c-8;){let d=st(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]);d=L(ne(L(d,be),31n),J),a=Z(L(ne(a^d,27n),J),Ot),l+=8}if(l+4<=c){let d=L(st(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),J);a=Z(L(ne(a^d,23n),be),Po),l+=4}for(;l<c;){const d=L(st(e[l++],0,0,0),Uo);a=L(ne(a^d,11n),J)}let f=a>>33n;return a=L(a^f,be),f=a>>29n,a=L(a^f,Po),f=a>>32n,a^=f,a}const en=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},Lo=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},Ro=e=>ue(wt.enc(Ge(e)),e),Mo=new TextEncoder,aa=new Map([[To,0],[Ro,8],[_o,16],[zn,-16],[Ct,-32],[en,-16],[Lo,-32]]),Do=e=>{const t=en(Mo.encode(e));return(n,r,...o)=>{const i=ue(t,en(Mo.encode(n))),s=te(i),c=l=>{if(!l.startsWith(s))throw new Error(`key does not match this storage (${e}.${n})`);if(o.length===0)return[];const f=ye(l.slice(s.length)),d=new Array(o.length);for(let h=0,p=0;h<o.length;h++){const[v,y]=o[h],b=aa.get(y);if(b==null)throw new Error("Unknown hasher");if(b<0){const m=b*-1;d[h]=te(f.slice(p,p+m)),p+=m}else p+=b,d[h]=v.dec(f.slice(p)),p+=v.enc(d[h]).length}return d},u=o.map(([{enc:l},f])=>d=>f(l(d)));return{enc:(...l)=>te(ue(i,...l.map((f,d)=>u[d](f)))),dec:r,keyDecoder:c}}},ua=Ue.fromText("modlpy/utilisuba").asBytes(),la=({threshold:e,signatories:t})=>{const n=zo(t),r=ue(ua,j.enc(n.length),...n,Fe.enc(e));return Ct(r)},zo=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const o=r>=t.length,i=r>=n.length;if(o&&i)return 0;if(o)return-1;if(i)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var Ho=Object.freeze({__proto__:null,AccountId:rt,Bin:It,Binary:Ue,Blake2128:zn,Blake2128Concat:_o,Blake2256:Ct,Blake3256:$o,Blake3256Concat:ca,Bytes:Y,Enum:Bt,FixedSizeBinary:Tn,Hex:qe,Identity:To,Option:ee,Result:qt,ScaleEnum:Ie,Self:Pn,Storage:Do,Struct:O,Tuple:ae,Twox128:en,Twox256:Lo,Twox64Concat:Ro,Variant:ge,Vector:U,_Enum:so,_void:_,bitSequence:to,blockHeader:go,bool:Is,char:kc,compact:j,compactBn:eo,compactNumber:C,createCodec:M,createDecoder:Vt,decAnyMetadata:Bo,enhanceCodec:ut,enhanceDecoder:jt,enhanceEncoder:gt,ethAccount:yo,fixedStr:Sc,fromBufferToBase58:Gr,getMultisigAccountId:la,getSs58AddressInfo:On,h64:Ge,i128:Es,i16:gs,i256:As,i32:ws,i64:ks,i8:ms,metadata:it,selfDecoder:io,selfEncoder:oo,sortMultisigSignatories:zo,str:Q,u128:xs,u16:Fe,u256:Ss,u32:ke,u64:wt,u8:V,v14:So,v14Lookup:Mn,v15:Ao});const ct=j,fa=U(ae(Q,ct)),R={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},da=ge(Object.fromEntries(Object.values(R).map(e=>[e,_]))),ha=U(ae(Q,ee(Pn(()=>Vn)))),pa=U(ct),va=O({typeRef:ct,length:ee(ct)}),ya=ee(j),ba=ct,ma=O({ok:ct,ko:ct}),Vn=ge({struct:fa,terminal:da,enum:ha,tuple:pa,array:va,binary:ya,option:ba,result:ma}),ga={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},$t=e=>({type:"terminal",value:{type:e}});function Tt(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return $t(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 $t(R.bits);case"compact":return $t(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"?Tt(r.value,t):Tt(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 $t(ga[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 $t(R.void)}}function jn(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(i,s)=>jn(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 Ue&&(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 wa=Object.defineProperty,ka=(e,t,n)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xa=(e,t,n)=>ka(e,t+"",n);class Fo{constructor(t=[]){xa(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 qn(e,t,n,r,o){if(!n&&!e)return fe(3);if(!n)return fe(2);if(!e)return fe(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 Fo([[e,n]])}:fe(c)}i.set(e,null);const s=Ea(e,n,(c,u)=>qn(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 Ea(e,t,n){if(e.type!==t.type)return t.type==="option"?tn(n(e,t.value),2):e.type==="option"?tn(n(e.value,t),1):fe(0);switch(t.type){case"terminal":return fe(t.value.type===e.value.type?3:0);case"binary":return fe(jo(e.value,t.value));case"array":const o=e,i=fe(jo(o.value.length,t.value.length));return Wn([i,()=>n(o.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,f=Object.fromEntries(t.value),d=l.value.length===t.value.length?3:2;return tn(Vo(l.value.map(([h,p])=>()=>h in f?n(p,f[h]):fe(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 tn(Wn(t.value.map(([l,f])=>()=>n(c[l],f))),u);case"tuple":{const l=e,f=fe(Aa(l.value,t.value));return Wn([f,...t.value.map((d,h)=>()=>n(l.value[h],d))])}case"result":const a=e;return Vo([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const tn=(e,t)=>({...e,level:Math.min(e.level,t)}),Sa=new Fo,fe=e=>({level:e,assumptions:Sa}),Wn=e=>{let t=fe(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},Vo=e=>{if(!e.length)return fe(3);let t=!1,n=fe(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:fe(0)},Aa=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,jo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,qo=ge({lookup:j,typedef:Vn}),lt=e=>({type:"lookup",value:e}),Xn=e=>({type:"typedef",value:e}),nn=Xn({type:"terminal",value:{type:R.void}}),Ia=O({args:qo,values:qo});function Ba(e){if(e.type.tag==="plain")return{args:nn,values:lt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:lt(t),values:lt(n)}}function _a(e){return{args:Xn({type:"tuple",value:e.inputs.map(t=>t.type)}),values:lt(e.output)}}function Ca(e){return e.type==="lookupEntry"?lt(e.value.id):Xn(Tt(e))}function Oa(e){return{args:nn,values:lt(e)}}function $a(e,t,n,r,o){const i=(s,c)=>s.type==="lookup"?c(s.value):s.value;return{args:qn(i(e.args,t),t,i(n.args,r),r,o).level,values:qn(i(n.values,r),r,i(e.values,t),t,o).level}}function Wo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return jn(n,r,t)}const ft=()=>{},we={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},rn={chainName:"",genesisHash:"",properties:""},Gn={broadcast:"",stop:""};Object.entries({chainHead:we,chainSpec:rn,transaction:Gn}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ta=e=>(t,n)=>{let r=e(Gn.broadcast,[t],{onSuccess:o=>{r=o===null?ft:()=>{e(Gn.stop,[o])},o===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Xo extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class on extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class sn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Go extends Error{constructor(t){super(t),this.name="OperationError"}}class cn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Pa(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),res:e,rej:t}}const Ko=()=>{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)})}}},an=e=>(...t)=>new Promise((n,r)=>{let o=xt;const[i,s]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{o(),r(new Yr)};s?.addEventListener("abort",c,{once:!0});const u=a=>l=>{o=xt,s?.removeEventListener("abort",c),a(l)};o=e(u(n),u(r),...i)}),Yo=(e,t)=>n=>an((r,o,...i)=>{let s=!0,c=()=>{s=!1};const[u,a]=t(...i);return n(e,u,{onSuccess:(l,f)=>{if(l.result==="limitReached")return o(new sn);const{operationId:d}=l,h=()=>{n(we.stopOperation,[d])};if(!s)return h();let p=ft;const v=b=>{s=!1,p(),r(b)},y=b=>{s=!1,p(),o(b)};p=f(d,{next:b=>{const m=b;m.event==="operationError"?o(new Go(m.error)):m.event==="operationInaccessible"?o(new cn):a(b,v,y)},error:y}),c=()=>{s&&(p(),h())}},onError:o}),()=>{c()}}),Ua=Yo(we.body,e=>[[e],(t,n)=>{n(t.value)}]),La=Yo(we.call,(e,t,n)=>[[e,t,n],(r,o)=>{o(r.output)}]),Ra=e=>t=>new Promise((n,r)=>{e(we.header,[t],{onSuccess:n,onError:r})}),Zo=e=>(t,n,r,o,i,s,c)=>{if(n.length===0)return s(),xt;let u=!0,a=()=>{u=!1};return e(we.storage,[t,n,r],{onSuccess:(l,f)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return i(new sn);const{operationId:d}=l,h=()=>{e(we.stopOperation,[d])};if(!u)return h();const p=f(l.operationId,{next:b=>{switch(b.event){case"operationStorageItems":{o(b.items);break}case"operationStorageDone":{y();break}case"operationError":{v(new Go(b.error));break}case"operationInaccessible":{v(new cn);break}default:e(we.continue,[b.operationId])}},error:i});a=()=>{p(),e(we.stopOperation,[l.operationId])};const v=b=>{a=xt,p(),i(b)},y=()=>{a=xt,p(),s()};c(l.discardedItems)},onError:i}),()=>{a()}},Ma=e=>{const t=Zo(e);return an((n,r,o,i,s,c)=>{const u=i.startsWith("descendants");let a=u?[]:null;const f=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&&(f(),r(new sn))});return f})},Da=e=>t=>t.length>0?new Promise((n,r)=>{e(we.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class un extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function za(e){return e.operationId!==void 0}function Ha(e){return(t,n,r)=>{const o=Ko(),i=new Set,s=Pa();let c=s.promise;const u=p=>{if(za(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 Xo),d(!1)},a=p=>{r(p),d(!(p instanceof un))},l=(p,v)=>{const y=v(p,{next:u,error:a});d=(b=!0)=>{c=null,d=ft,y(),b&&e(we.unfollow,[p]),o.errorAll(new on),i.forEach(m=>{m()}),i.clear()},c=p,s.res(p)},f=p=>{p instanceof un?d(!1):r(p),c=null,s.res(p)};let d=e(we.follow,[t],{onSuccess:l,onError:f});const h=(p,v,y)=>{const b=()=>{y?.onError(new on)};if(c===null)return b(),ft;const m=g=>{if(!y)return e(p,[g,...v]);i.add(b);const x=(A,T)=>c===null?(T.error(new on),ft):(o.subscribe(A,T),()=>{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=ft;return c.then(g=>{if(g instanceof Error)return b();c&&(S=m(g))}),()=>{S()}};return{unfollow(){d(),c=null},body:Ua(h),call:La(h),header:Ra(h),storage:Ma(h),storageSubscription:Zo(h),unpin:Da(h),_request:h}}}var Fa=Object.defineProperty,Va=(e,t,n)=>t in e?Fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jo=(e,t,n)=>Va(e,typeof t!="symbol"?t+"":t,n);class Qo extends Error{constructor(t){super(t.message),Jo(this,"code"),Jo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let ja=1;const qa=e=>{let t=ja++;const n=new Map,r=Ko();let o=null;const i=(l,f,d)=>{o.send(JSON.stringify({jsonrpc:"2.0",id:l,method:f,params:d}))};function s(l){try{let f,d,h,p,v;if({id:f,result:d,error:h,params:p}=JSON.parse(l),f){const m=n.get(f);return m?(n.delete(f),h?m.onError(new Qo(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 Qo(h)):r.next(b,d)}catch(f){console.warn("Error parsing incomming message: "+l),console.error(f)}}o=e(s);const c=()=>{o?.disconnect(),o=null,r.errorAll(new un),n.forEach(l=>l.onError(new un)),n.clear()};let u=1;return{request:(l,f,d)=>{if(!o)throw new Error("Not connected");const h=`${t}-${u++}`;return d&&n.set(h,d),i(h,l,f),()=>{n.delete(h)}},disconnect:c}},Wa=e=>{const t=an((r,o,i,s)=>e(i,s,{onSuccess:r,onError:o}));let n=null;return async()=>n||(n=Promise.all([t(rn.chainName,[]),t(rn.genesisHash,[]),t(rn.properties,[])]).then(([r,o,i])=>({name:r,genesisHash:o,properties:i})))},ln=new Map,Xa=e=>{const t=ln.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=qa(e),o=()=>{const s=ln.get(e);!s||s.refCount<=1?(ln.delete(e),r()):s.refCount--},i={chainHead:Ha(n),transaction:Ta(n),getChainSpecData:Wa(n),destroy:o,request:an((s,c,u,a)=>n(u,a,{onSuccess:s,onError:c})),_request:n};return ln.set(e,{client:i,refCount:1}),i};var Kn=function(e,t){return Kn=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])},Kn(e,t)};function Me(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Kn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ga(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(f){s(f)}}function u(l){try{a(r.throw(l))}catch(f){s(f)}}function a(l){l.done?i(l.value):o(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function No(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 dt(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 ht(e){return this instanceof ht?(this.v=e,this):new ht(e)}function Ka(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,f)}}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 ht?Promise.resolve(h.value.v).then(l,f):d(i[0][2],h)}function l(h){u("next",h)}function f(h){u("throw",h)}function d(h,p){h(p),i.shift(),i.length&&u(i[0][0],i[0][1])}}function Ya(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 dt=="function"?dt(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 Yn(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 Zn=Yn(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 fn(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=dt(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 l=this.initialTeardown;if(z(l))try{l()}catch(v){i=v instanceof Zn?v.errors:[v]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var d=dt(f),h=d.next();!h.done;h=d.next()){var p=h.value;try{ti(p)}catch(v){i=i??[],v instanceof Zn?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 Zn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ti(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)&&fn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&fn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),No=ct.EMPTY;function ei(e){return e instanceof ct||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function ti(e){z(e)?e():e.unsubscribe()}var ni={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ga={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 ri(e){Ga.setTimeout(function(){throw e})}function Me(){}function dn(e){e()}var Jn=function(e){Re(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ei(n)&&n.add(r)):r.destination=Ja,r}return t.create=function(n,r,o){return new pt(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),Ka=Function.prototype.bind;function Qn(e,t){return Ka.call(e,t)}var Ya=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){hn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){hn(r)}else hn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){hn(n)}},e}(),pt=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&&ni.useDeprecatedNextContext?(c=Object.create(n),c.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Qn(n.next,c),error:n.error&&Qn(n.error,c),complete:n.complete&&Qn(n.complete,c)}):s=n}return i.destination=new Ya(s),i}return t}(Jn);function hn(e){ri(e)}function Za(e){throw e}var Ja={closed:!0,next:Me,error:Za,complete:Me},Nn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ze(e){return e}function oi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ii(e)}function ii(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=Na(t)?t:new pt(t,n,r);return dn(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=si(n),new n(function(o,i){var s=new pt({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[Nn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ii(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=si(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 si(e){var t;return(t=e??ni.Promise)!==null&&t!==void 0?t:Promise}function Qa(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function Na(e){return e&&e instanceof Jn||Qa(e)&&ei(e)}function eu(e){return z(e?.lift)}function N(e){return function(t){if(eu(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 tu(e,t,n,r,o)}var tu=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}(Jn),nu=Yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Tt=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 ci(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new nu},t.prototype.next=function(n){var r=this;dn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=dt(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;dn(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;dn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,c=o.observers;return i||s?No:(this.currentObservers=null,c.push(n),new ct(function(){r.currentObservers=null,fn(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 ci(n,r)},t}(T),ci=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:No},t}(Tt),er={now:function(){return(er.delegate||Date).now()},delegate:void 0},pn=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=er);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}(Tt),ru=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),ai={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},ou=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),ai.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&&ai.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,fn(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(ru),ui=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=er.now,e}(),iu=function(e){Re(t,e);function t(n,r){r===void 0&&(r=ui.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}(ui),li=new iu(ou),su=li,Pt=new T(function(e){return e.complete()});function cu(e){return e&&z(e.schedule)}function tr(e){return e[e.length-1]}function fi(e){return z(tr(e))?e.pop():void 0}function vn(e){return cu(tr(e))?e.pop():void 0}function au(e,t){return typeof tr(e)=="number"?e.pop():t}var di=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function hi(e){return z(e?.then)}function pi(e){return z(e[Nn])}function vi(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function yi(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 uu(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var bi=uu();function mi(e){return z(e?.[bi])}function gi(e){return Wa(this,arguments,function(){var n,r,o,i;return Qo(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,ht(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,ht(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,ht(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 wi(e){return z(e?.getReader)}function fe(e){if(e instanceof T)return e;if(e!=null){if(pi(e))return lu(e);if(di(e))return fu(e);if(hi(e))return du(e);if(vi(e))return ki(e);if(mi(e))return hu(e);if(wi(e))return pu(e)}throw yi(e)}function lu(e){return new T(function(t){var n=e[Nn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function fu(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function du(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,ri)})}function hu(e){return new T(function(t){var n,r;try{for(var o=dt(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 ki(e){return new T(function(t){vu(e,t).catch(function(n){return t.error(n)})})}function pu(e){return ki(gi(e))}function vu(e,t){var n,r,o,i;return qa(this,void 0,void 0,function(){var s,c;return Qo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Xa(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 xi(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 Ei(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(Ei(t),xi(t))}function bu(e,t){return fe(e).pipe(Ei(t),xi(t))}function mu(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 gu(e,t){return new T(function(n){var r;return Je(n,t,function(){r=e[bi](),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 Si(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 wu(e,t){return Si(gi(e),t)}function ku(e,t){if(e!=null){if(pi(e))return yu(e,t);if(di(e))return mu(e,t);if(hi(e))return bu(e,t);if(vi(e))return Si(e,t);if(mi(e))return gu(e,t);if(wi(e))return wu(e,t)}throw yi(e)}function Ut(e,t){return t?ku(e,t):fe(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e);return Ut(e,n)}function yn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new T(r)}var Ai=Yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function xu(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 Ai)}})})}function xe(e,t){return new Promise(function(n,r){var o=new pt({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new Ai)}});e.subscribe(o)})}function Eu(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 Su=Array.isArray;function Au(e,t){return Su(t)?e.apply(void 0,Ye([],Ke(t))):e(t)}function Iu(e){return I(function(t){return Au(e,t)})}var Bu=Array.isArray,_u=Object.getPrototypeOf,Cu=Object.prototype,Ou=Object.keys;function $u(e){if(e.length===1){var t=e[0];if(Bu(t))return{args:t,keys:null};if(Tu(t)){var n=Ou(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Tu(e){return e&&typeof e=="object"&&_u(e)===Cu}function Pu(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function bn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=fi(e),o=$u(e),i=o.args,s=o.keys;if(i.length===0)return Ut([],n);var c=new T(Uu(i,n,s?function(u){return Pu(s,u)}:Ze));return r?c.pipe(Iu(r)):c}function Uu(e,t,n){return n===void 0&&(n=Ze),function(r){Ii(t,function(){for(var o=e.length,i=new Array(o),s=o,c=o,u=function(l){Ii(t,function(){var f=Ut(e[l],t),d=!1;f.subscribe(W(r,function(h){i[l]=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 Ii(e,t,n){e?Je(n,e,t):t()}function Lu(e,t,n,r,o,i,s,c){var u=[],a=0,l=0,f=!1,d=function(){f&&!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,l++)).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(){f=!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 Lu(r,o,e,n)}))}function nr(e){return e===void 0&&(e=1/0),D(Ze,e)}function Ru(){return nr(1)}function Mu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ru()(Ut(e,vn(e)))}function mn(e){return new T(function(t){fe(e()).subscribe(t)})}var Du={connector:function(){return new Tt},resetOnDisconnect:!0};function zu(e,t){t===void 0&&(t=Du);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=mn(function(){return e}).subscribe(s),i&&n.add(function(){return s=r()})),n},c}function Bi(e,t,n){return n===void 0&&(n=su),new T(function(r){var o=Eu(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 _i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=au(e,1/0),o=e;return o.length?o.length===1?fe(o[0]):nr(r)(Ut(o,n)):Pt}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 Lt(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,Lt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function Hu(e,t,n,r,o){return function(i,s){var c=n,u=t,a=0;i.subscribe(W(s,function(l){var f=a++;u=c?e(u,l,f):(c=!0,l),s.next(u)},o))}}function Ci(e,t){return z(t)?D(e,t,1):D(e,1)}function Fu(e,t){return t===void 0&&(t=li),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 Pt}:N(function(t,n){var r=0;t.subscribe(W(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Vu(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 Ee(e,t){return t===void 0&&(t=Ze),e=e??ju,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 ju(e,t){return e===t}function Oi(e,t){return N(Hu(e,t,arguments.length>=2,!0))}function gn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Tt}: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,f,d,h=0,p=!1,v=!1,y=function(){f?.unsubscribe(),f=void 0},b=function(){y(),l=d=void 0,p=v=!1},m=function(){var S=l;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&&(f=rr(m,u))}),x.subscribe(g),!l&&h>0&&(l=new pt({next:function(E){return x.next(E)},error:function(E){v=!0,y(),f=rr(b,o,E),x.error(E)},complete:function(){p=!0,y(),f=rr(b,s),x.complete()}}),fe(S).subscribe(l))})(a)}}function rr(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 pt({next:function(){o.unsubscribe(),e()}});return fe(t.apply(void 0,Ye([],Ke(n)))).subscribe(o)}}function $i(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,gn({connector:function(){return new pn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Ti(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(f){return r.next(t?t(u,f,l,a++):f)},function(){o=null,c()}))},function(){s=!0,c()}))})}function qu(e){return N(function(t,n){fe(e).subscribe(W(n,function(){return n.complete()},Me)),!n.closed&&t.subscribe(n)})}function Pi(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 Wu(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 Ui(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=fi(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(f){fe(e[f]).subscribe(W(o,function(d){s[f]=d,!u&&!c[f]&&(c[f]=!0,(u=c.every(Ze))&&(c=null))},Me))},l=0;l<i;l++)a(l);r.subscribe(W(o,function(f){if(u){var d=Ye([f],Ke(s));o.next(n?n.apply(void 0,Ye([],Ke(d))):d)}}))})}var Xu=Object.defineProperty,Gu=(e,t,n)=>t in e?Xu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Li=(e,t,n)=>Gu(e,typeof t!="symbol"?t+"":t,n);class Ku{constructor(){Li(this,"first"),Li(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 Yu=()=>{const e=new Map,t=(d,h)=>{e.set(d,()=>{e.delete(d),h()})},n=d=>{e.get(d)?.()},r=new Ku,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 sn)?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)}}),l=a();return{withRecovery:a,withRecoveryFn:d=>(...h)=>l(d(...h))}};class wn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Zu extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Ri extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const Ju=new Set(["best","finalized",null]),Mi=e=>{const t=e.pipe(Lt(n=>n instanceof cn?Bi(750).pipe(Ci(()=>t)):yn(()=>n)));return t},Qu=(e,t)=>n=>(r,...o)=>{if(!Ju.has(r))return Mi(n(r,...o));const s=(r==="best"?t:e).pipe(_e(1),D(c=>n(c,...o)),Lt(c=>c instanceof wn?s:yn(()=>c)));return Mi(s)},Di=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}}),Nu=e=>t=>(...n)=>e()[t](...n),el=(e,t)=>e.pipe(Pi(n=>n.blocks.has(t)),Ee((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}),Ee(),Pi(n=>n!=="finalized",!0));function tl(e,t,n){return(r,o,...i)=>(o?oi(rl(r,t.pipe(De(c=>c.type==="finalized"),D(c=>c.prunedBlockHashes))),nl(r,e)):c=>c)(n(r,...i))}const nl=(e,t)=>n=>el(t,e).pipe(_e(1),Ti(r=>r?n:yn(()=>new Ri))),rl=(e,t)=>n=>new T(r=>{const o=t.pipe(De(s=>s===e)).subscribe(()=>{r.error(new Zu)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function kn(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:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),s.add(()=>{c=!1,s=null}))};let a=!1;const l=e.subscribe({next:f=>{const d=f.blocks.get(n);d?d.recovering?s?.unsubscribe():u():a&&i.error(new wn),a=f.recovering},error:f=>i.error(f)});return()=>{l.unsubscribe(),s?.unsubscribe()}})}}const ol=(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(nr(),t(s));return n},il=e=>t=>t.pipe(Ci(n=>n.type!=="initialized"?re(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),sl=e=>{let t=null,n=Me;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(go.dec),i=zu(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(il(o),cl()));return{getHeader:o,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},cl=()=>e=>new T(t=>{const n=new ct,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof Wo?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n}),zi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Qe={type:"void"},al=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>f=>{let d=n.get(f);if(d)return d;if(r.has(f)){const p={id:f};return n.set(f,p),p}r.add(f);const h=l(f);return d=n.get(f),d?Object.assign(d,h):(d={id:f,...h},n.set(f,d)),r.delete(f),d};let i=!0,s=!0;const c=o(l=>{const f=t(e[l]);if(f)return f;const{def:d,path:h,params:p}=e[l];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"&&zi(v,32)?(i=!1,{type:"AccountId32"}):s&&h.at(-1)==="AccountId20"&&zi(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=l=>{let f=!0;const d={},h={};return l.forEach((p,v)=>{f=f&&!!p.name;const y=p.name||v,b=c(p.type);b.type!=="void"&&(d[y]=b,h[y]=p.docs)}),f?{type:"struct",value:d,innerDocs:h}:a(Object.values(d),Object.values(h))},a=(l,f)=>{if(l.every(d=>d.id===l[0].id)&&f.every(d=>!d.length)){const[d]=l;return d.type==="void"?Qe:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:f}};return c},Hi=e=>{const t=al(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})},ul=(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},ll=It(),fl=M(q[0],Vt(q[1],BigInt)),Fi=ul((e,t,n,r)=>{if(e.type==="primitive")return zo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return yo;if(e.type==="compact")return e.isBig?fl:q;if(e.type==="bitSequence")return to;const o=h=>Fi(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 ll;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?It(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 jt(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]])),l=Object.values(e.value).map(h=>h.idx),d=l.every((h,p)=>h===p)?ge(a):ge(a,l);return e.byteLength?dl(d,e.byteLength):d},Pn,e=>e),Vi=(e,t=nt())=>{const n=new Map,r=o=>Fi(e(o),n,new Set,t);return o=>r(o)},dl=(e,t)=>{const n=K(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},ji=e=>{const{metadata:t}=e;let n=Vi(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let o;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(o=f,n=Vi(e,nt(f)))}catch{}const i=new Map,s=(f,d)=>{let h=i.get(f);h||i.set(f,h=Do(f));const p=t.pallets.find(E=>E.name===f).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=>zo[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=f=>{switch(f.type){case"void":return _;case"lookupEntry":return n(f.value.id);case"tuple":return ae(...Object.values(f.value).map(d=>n(d.id)));case"struct":return $(Yt(f.value,d=>n(d.id)));case"array":return P(n(f.value.id),f.len)}},u=(f,d)=>{const h=t.pallets.find(p=>p.name===f).constants.find(p=>p.name===d);return n(h.type)},a=f=>(d,h)=>{const p=t.pallets.find(b=>b.name===d),v=e(p[f]);if(v.type!=="enum")throw null;const y=v.value[h];return{location:[p.index,y.idx],codec:c(v.value[h])}},l=(f,d)=>{const h=t.apis.find(p=>p.name===f)?.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:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},hl=te(ke.enc(15)),qi=K(),pl=ee(qi),vl=P(ke).dec,yl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(Lt(l=>{if(l instanceof wn)return r(c,u);if(l instanceof cn)return Bi(750).pipe(D(()=>r(c,u)));throw l})):Pt},o=r("Metadata_metadata_versions","").pipe(I(vl)),i=r("Metadata_metadata","").pipe(I(c=>{const u=qi.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",hl).pipe(I(c=>{const u=pl.dec(c);return{metadata:ot.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Lt(()=>re([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=Hi(c),l=ji(a),f=l.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:l,events:{key:f.enc(),dec:f.dec},accountId:nt(l.ss58Prefix)}}),$i(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}},Rt=gn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Wi=(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},Xi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},bl=(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=>{Xi(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},ml=(e,t,n,r)=>{const o=_i(n,e).pipe(Oi((s,c)=>{switch(c.type){case"initialized":s.recovering&&(c.finalizedBlockHashes.some(d=>s.blocks.has(d))||(s=Gi()));const[u]=c.finalizedBlockHashes.slice(-1);s.finalized=s.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((f,d)=>{s.blocks.has(f)?s.blocks.get(f).recovering=!1:s.blocks.set(f,{hash:f,parent:d===0?c.parentHash:c.finalizedBlockHashes[d-1],children:new Set(d===a?[]:[c.finalizedBlockHashes[d+1]]),runtime:f,refCount:0,number:c.number+d,recovering:!1})});const l=Object.values(s.runtimes).find(f=>f.usages.has(u));return s.finalizedRuntime=l??(s.runtimes[u]=i(Wi(s,u))),s;case"stop-error":for(const f of s.blocks.values())f.recovering=!0;return s.recovering=!0,s;case"newBlock":{const{parentBlockHash:f,blockHash:d}=c;if(s.blocks.has(d))s.blocks.get(d).recovering=!1;else{const h=s.blocks.get(f);h.children.add(d),c.newRuntime&&(s.runtimes[d]=i(Wi(s,d)));const p={hash:d,number:h.number+1,parent:f,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[f,d]of s.blocks)d.recovering&&Xi(s.blocks,f);s.recovering=!1}return s.best=c.bestBlockHash,s}case"finalized":{s.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=s;return f.get(s.best).number<f.get(s.finalized).number&&(s.best=s.finalized),s.finalizedRuntime=s.runtimes[f.get(s.finalized).runtime],r(bl(s,c.prunedBlockHashes)),s}case"blockUsage":{if(!s.blocks.has(c.value.hash))return s;const f=s.blocks.get(c.value.hash);return f.refCount+=c.value.type==="hold"?1:-1,f.refCount===0&&f.number<s.blocks.get(s.finalized).number&&!f.recovering&&(f.unpinned=!0,r([f.hash])),s}}},Gi()),De(s=>!!s.finalizedRuntime.runtime),I(s=>({...s})),Rt),i=yl(kn(o,t));return o},Gi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Ki=(e,t,n,r)=>{const o=c=>qu(e.pipe(De(({blocks:u})=>!u.has(c)))),i=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const l=o(c);return t(c).pipe(D(f=>{const d=f.indexOf(u);return d>-1?l(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}})))}),l)},s=(c,u,a)=>i(c,u,a.has(c)).pipe(D(l=>{const{found:f}=l;return f.type||f.validity?.success===!1?re(l):e.pipe(o(c),D(d=>d.blocks.get(c).children),Vu(),D(d=>s(d,u,a)))}));return c=>e.pipe(_e(1),D(u=>s(u.finalized,c,new Set(u.blocks.keys()))))},gl=new Uint8Array([2]),wl=(e,t)=>te(ve(gl,pe(e),pe(t))),Yi="TaggedTransactionQueue",Zi="validate_transaction",[,kl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),xl=Ft(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=kl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),El=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(Yi,Zi).value[1]}catch{return xl}}));return e(n,`${Yi}_${Zi}`,wl(r,n)).pipe(Ui(o),I(([i,s])=>s(i)))},Sl=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}),Al=(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 f=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),l!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){l===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;f()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,mn(()=>e(d,h))),s.size<t&&f()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Il=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)}}),or=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),Bl=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=sl(e),i=Nu(t),{withRecovery:s,withRecoveryFn:c}=Yu(),u=new Tt,a=k=>(B,...L)=>new T(F=>{u.next({type:"blockUsage",value:{type:"hold",hash:B}});const be=k(B,...L).subscribe(F);return()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:B}})},0),be.unsubscribe()}}),l=k=>(B,...L)=>new T(F=>{let be=!1;return v.pipe(_e(1)).subscribe(Ce=>{const ce=Ce.blocks.get(B);be=!!ce&&!ce.unpinned}),be?k(B,...L).subscribe(F):F.error(new wn)}),f=k=>t().unpin(k).catch(B=>{if(!(B instanceof on))throw B}),d=k=>l(a((L=>tl(v,r,L))(kn(v,c(Di(k)))))),h=(k,B=!0)=>(L,...F)=>k(L,B,...F),p=new Map,v=ml(r,a(c(Di(i("call")))),u,k=>{f(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(Al(L=>y(k(L)).pipe(I(F=>[L,F])))),m=(k,B,L)=>{const F=p.get(k)??new Map,be=F.get(B);if(be)return be;p.set(k,F);const Ce=new pn,ce=L.pipe(gn({connector:()=>Ce}),Wu({complete(){F.set(B,Ce)}}),Il());return F.set(B,ce),ce},S=v.pipe(Ee((k,B)=>k.finalized===B.finalized),I(k=>or(k.blocks.get(k.finalized))),Rt),g=v.pipe(Ee((k,B)=>k.best===B.best),I(k=>or(k.blocks.get(k.best))),Rt),x=v.pipe(Ee((k,B)=>k.finalized===B.finalized&&k.best===B.best),Oi((k,B)=>{const L=de=>k.get(de)||or(B.blocks.get(de)),F=L(B.best),be=L(B.finalized),Ce=F.number-be.number+1,ce=new Array(Ce);for(let de=0,zt=F.hash;de<Ce;de++)ce[de]=L(zt),zt=ce[de].parent;return new Map(ce.map(de=>[de.hash,de]))},new Map),I(k=>[...k.values()]),Rt),E=v.pipe(Ee((k,B)=>k.finalizedRuntime===B.finalizedRuntime),Ti(({finalizedRuntime:{runtime:k}})=>k.pipe(Sl(null))),Rt),A=E.pipe(I(k=>k?.lookup.metadata??null)),C=Qu(S.pipe(I(k=>k.hash)),g.pipe(I(k=>k.hash))),H=C(d(i("body"))),J=k=>m(k,"body",H(k,!0)),G=d(i("storage")),j=C((k,B,L,F,be=null,Ce)=>v.pipe(_e(1),D(ce=>ce.runtimes[ce.blocks.get(k).runtime].runtime),D(ce=>{const de=F(ce),zt=m(k,`storage-${L}-${de}-${be??""}`,G(k,B,L,de,be));return Ce?m(k,`storage-${L}-${de}-${be??""}-dec`,zt.pipe(I(Af=>Ce(Af,ce)))):zt}))),Se=ol(t,s),at=C(a(kn(v,(k,B,L)=>Se(k,B,L??null,!1)))),Dt=C(a(kn(v,k=>mn(()=>o(k))))),ls=(k,B=!1)=>j(k,B,"value",L=>L.events.key,null,(L,F)=>F.events.dec(L)),kf=d(i("call")),fs=C((k,B,L,F)=>m(k,`call-${L}-${F}`,kf(k,B,L,F))),hr=El(h(fs,!1),y),ds=k=>m(k,"body",H(k,!1)),xf=Ki(v,ds,hr,ls),Ef=Ki(v,ds,hr,()=>re());_i(E,x).subscribe({error(){}});let pr=Me,An=!1,vr=0;const Sf=k=>{vr+=k,An=!0,pr=n()};return[{follow$:r,finalized$:S,best$:g,bestBlocks$:x,runtime$:E,metadata$:A,header$:Dt,body$:J,call$:h(fs),storage$:h(j),storageQueries$:at,eventsAt$:h(ls),trackTx$:xf,trackTxWithoutEvents$:Ef,validateTx$:hr,pinnedBlocks$:v,withRuntime:b,getRuntimeContext$:C(y),unfollow:()=>{An!=null&&(vr--,An&&!vr&&(An=null,pr(),pr=Me))}},Sf]};var _l=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const xn=new Map,Cl=e=>{const t=xn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=xn.get(e);!c||c.refCount<=1?(xn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,i=null;const s={chainHead$:c=>{o++,i||(i=c||1),r||(r=Bl(e.chainHead));const[u,a]=r;if(i===o){const l=o;o=0,i=null,r=null,a(l)}return u},broadcastTx$:_l(e.transaction),destroy:n};return xn.set(e,{client:s,refCount:1}),s};class vt{constructor(){}_runtime(t){}}class Ji{constructor(){}_compatibility(t){}}const En=new WeakMap,Qi=new WeakMap,ir=e=>e instanceof vt?Qi.get(e):En.get(e);var yt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(yt||{});const Ol=P(Ea),$l=P(Vn),Tl=ae(Ol,$l),Pl=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(De(s=>s!=null));let i=await xe(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(Tl.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const c=new Ji;return En.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})},Ul=e=>new Promise(async t=>{const n=e.runtime$.pipe(De(o=>o!=null));let r=await xe(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new vt;return Qi.set(n,{runtime:t}),n}),sr=new WeakMap,Ni=e=>(sr.has(e.metadataRaw)||sr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),sr.get(e.metadataRaw)),bt=(e,t,n)=>{const r=(u,a)=>{var l;const f=Ni(u);return(l=f.typeNodes)[a]||(l[a]=$t(f.lookup(a)))};function o(u,a){if(u instanceof vt)return{args:Be.Identical,values:Be.Identical};const l=En.get(u);a||(a=l.runtime());const f=t(l),d=n(a),h=l.typedefNodes,p=Ni(a);return _a(f,v=>h[v],d,v=>r(a,v),p.compat)}const i=ts(e,u=>es(o(u))),s=ts(e,(u,a)=>i(a)>=u),c=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:c,withCompatibleRuntime:(u,a)=>l=>bn([l.pipe(u.withRuntime(a)),c()]).pipe(I(([[f,d],h])=>[f,h,d])),compatibleRuntime$:(u,a)=>bn([c(),u.getRuntimeContext$(a)]),argsAreCompatible:(u,a,l)=>{if(u instanceof vt)return!0;const f=o(u,a);if(f.args===Be.Incompatible)return!1;if(f.args>Be.Partial)return!0;if(f.values===Be.Incompatible)return!1;const d=n(a);return qo(d.args,h=>r(a,h),l)},valuesAreCompatible:(u,a,l)=>{if(u instanceof vt)return!0;const f=o(u,a).values;if(f===Be.Incompatible)return!1;if(f>Be.Partial)return!0;const d=En.get(u),h=t(d);return qo(h.values,p=>d.typedefNodes[p],l)},getRuntimeTypedef:r}},es=e=>Math.min(e.args,e.values),ts=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Ji||r instanceof vt?t(...n):e.then(o=>t(...n,o))},Ll=(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(d=>d.name===e)?.constants.find(d=>d.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const f=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return s.set(a,f),f},u=a=>{if(a){const l=ir(a).runtime(),f=c(l);if(!n(a,l,f))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return f}return r().then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},Rl=gn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function cr(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new Yr)}: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 Ml=(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 f=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),l!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){l===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;f()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,mn(()=>e(d,h))),s.size<t&&f()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Dl=(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 l=e(u).subscribe({next(f){const d=o.indexOf(a);o.slice(0,d).forEach(h=>h.unsubscribe()),o=o.slice(d),r.next(f)},error(f){r.error(f)},complete(){const f=o.indexOf(a);o.splice(f,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 ns={};const zl=e=>t=>new T(n=>{let r=ns,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===ns?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),ar=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)),Hl=(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,f,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(f,d,null))throw u();return[l,f,d]}),Ml(([l,f,d])=>n.eventsAt$(l.hash).pipe(I(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(f,d,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),Rl);return{watch:l=>a.pipe(D(f=>l?f.filter(d=>l(d.payload)):f)),pull:()=>xe(a),filter:l=>l.filter(f=>f.type===e&&f.value.type===t).map(f=>f.value.value),getCompatibilityLevel:o,isCompatible:r}},Fl=(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 f=l[l.length-1],d=ar(f),{signal:h,at:p}=d?f:{},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,l))throw a();return n.call$(v,u,te(S.args.enc(l))).pipe(I(S.value.dec),I(g=>{if(!c(b,m,g))throw a();return g}))}));return cr(y,h)},{getCompatibilityLevel:o,isCompatible:r})},Vl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",f=n.runtime$.pipe(De(Boolean),_e(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ze),$i()),d=oi(Ui(f),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 l?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Ee(),d):n[S==="best"?"best$":"finalized$"].pipe(Fu(0),c(n,x=>x.hash),Dl(([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),Ee((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=ar(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(J=>J.hash===A)),I(H=>{if(!H)throw new Ri;return H.number}),Ee(),d);else{const H=await s();C=n.storage$(A,"value",J=>{const G=v(J),j=m.length===G.len?m:m.slice(0,-1);if(m!==j&&!g)throw p(m);if(!u(H,J,j))throw h();return G.enc(...j)},null,(J,G)=>{const j=v(G),Se=J===null?j.fallback:j.dec(J);if(!a(H,G,Se))throw h();return Se})}return cr(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=ar(S),{signal:x,at:E}=g?S:{},A=E??null,C=await s(),H=n.storage$(A,"descendantsValues",J=>{const G=v(J);if(es(i(C,J))===Be.Incompatible)throw h();if(m.length>G.len)throw p(m);const j=m.length>0&&g?m.slice(0,-1):m;if(m.length===G.len&&j===m)throw p(m);return G.enc(...j)},null,(J,G)=>{const j=v(G),Se=J.map(({key:at,value:Dt})=>({keyArgs:j.keyDecoder(at),value:j.dec(Dt)}));if(Se.some(({value:at})=>!a(C,G,at)))throw h();return Se});return cr(H,x)},watchValue:y}},jl=gt(V.enc,e=>+!!e.signed<<7|e.version),ur=()=>new Error("Unkown signer"),ql=e=>{const{extrinsic:t}=e,n=Hi(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 ur()}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 ur();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 ur()},Wl={Ed25519:0,Sr25519:1,Ecdsa:2},Xl=(e,t,n,r,o,i)=>{const[s,c]=ql(e),u=ve(jl({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([Wl[i],...n]),...r,o);return ve(q.enc(u.length),u)},[Sn,Mt]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Gl=e=>async t=>{let n=!0,r;for(r=0;n&&r<Sn.length;r++)n=Sn[r]===t[r];n=n&&r===Sn.length;const o=t.length-Mt.length;for(r=0;n&&r<Mt.length;r++)n=Mt[r]===t[o+r];return n=n&&r===Mt.length,e(n?t:ve(Sn,t,Mt))};function Kl(e,t,n){return{publicKey:e,signTx:async(o,i,s,c,u=Nt)=>{let a;try{const p=Bo(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=[],f=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=i[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),f.push(v.additionalSigned)});const d=ve(o,...l,...f),h=await n(d.length>256?u(d):d);return Xl(a,e,h,l,o,t)},signBytes:Gl(n)}}const ze=new Uint8Array,rs=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=>pe(r)))},os=(e,t)=>{const n=ji(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 re(s(i(r.value)[e]))},Yl=e=>re({value:eo.enc(e),additionalSigned:ze});function Zl(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Jl=gt(K(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Zl(e.period)-1,1),15),r=e.phase/t<<4;return Ne.enc(n|r)}),Ql=new Uint8Array([0]),Nl=(e,t)=>{if(!e)return rs(t).pipe(I(o=>({additionalSigned:o,value:Ql})));const{period:n,blockNumber:r}=e;return re({additionalSigned:pe(t.at),value:Jl({period:n,phase:r%n})})},ef=$({tip:q,asset:ee(K(1/0))}).enc,tf=(e,t)=>re({value:ef({tip:e,asset:t}),additionalSigned:ze}),nf=e=>rs(e).pipe(I(t=>({value:ze,additionalSigned:t}))),rf=()=>re({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),is="AccountNonceApi_account_nonce",of={1:V.dec,2:Ne.dec,4:ke.dec,8:wt.dec},lr=e=>re({value:q.enc(e),additionalSigned:ze});var sf=Object.freeze({__proto__:null,CheckGenesis:nf,CheckMetadataHash:rf,CheckNonce:e=>e.chainHead.call$(e.at,is,te(e.from)).pipe(D(t=>{const n=pe(t),r=of[n.length];if(!r)throw new Error(`${is} retrieved wrong data`);return lr(r(n))})),CheckSpecVersion:({lookupFn:e})=>os("spec_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),CheckTxVersion:({lookupFn:e})=>os("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),getNonce:lr});const cf=re({value:ze,additionalSigned:ze}),ss=(e,t,n)=>{if(!(t in e))return ze;const r=e[t];return r instanceof Uint8Array?r:n(r)},af=(e,t,n)=>re({value:ss(e,"value",t),additionalSigned:ss(e,"additionalSigned",n)}),uf=(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 bn(Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:l,additionalSigned:f})=>[a,(()=>{if(a==="CheckMortality")return Nl(u,c);if(a==="ChargeTransactionPayment")return Yl(i.tip??0n);if(a==="ChargeAssetTxPayment")return tf(i.tip??0n,i.asset);if(a==="CheckNonce"&&"nonce"in i)return lr(i.nonce);const d=sf[a],[h]=s.dynamicBuilder.buildDefinition(l),[p]=s.dynamicBuilder.buildDefinition(f);return d?d(c):h===_[0]&&p===_[0]?cf:a in o?af(o[a],h,p):null})()]).filter(a=>a[1]))).pipe(D(a=>t.signTx(n,Yt(a,(l,f)=>({identifier:f,...l})),s.metadataRaw,r.number)))}));var lf=Object.defineProperty,ff=(e,t,n)=>t in e?lf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,df=(e,t,n)=>ff(e,t+"",n);const hf=e=>te(Nt(pe(e))),pf=(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 h=o.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const f=l<=o.blocks.get(o.finalized).number,d=a.found.type;if(d&&i?.found&&i.hash===a.hash){f&&n.complete();return}n.next(i=a.found.type?{found:d,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:d,validity:a.found.validity}),f&&(d?n.complete():a.found.validity?.success===!1&&n.error(new fr(a.found.validity.value)))},c=t.pipe(Ee((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(Ee((n,r)=>n===r)),vf=(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 fr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),df(this,"error"),this.name="InvalidTxError",this.error=t}}const dr=(e,t,n,r,o=!1)=>{const i=hf(n),s=(l,f)=>({type:l,txHash:i,...f}),c=e.pinnedBlocks$.pipe(_e(1),I(l=>{const f=l.blocks.get(r);return f&&!f.unpinned?f.hash:l.finalized})).pipe(D(l=>e.validateTx$(l,n).pipe(De(f=>!f.success),I(f=>{throw new fr(f.value)})))),u=new T(l=>{const f=e.trackTx$(n).subscribe(l);return f.add(t(n).subscribe({error(d){l.error(d)}})),f}),a=pf(u,e.pinnedBlocks$).pipe(I(l=>l.found?s("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...vf(l.events,l.index)}):s("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Mu(o?re(s("signed",{})):Pt,c,re(s("broadcasted",{})),a.pipe(zl(({found:l,type:f,...d})=>l?re(s("finalized",d)):Pt)))},cs=async(e,t,n,r)=>xu(dr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),yf=nt().enc,bf=new Uint8Array(64),mf=new Uint8Array(65),gf=e=>()=>e?mf:bf,as=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const f=(g,x,E={})=>{const A=ir(g).runtime(),{dynamicBuilder:C,assetId:H,lookup:J}=A;let G;try{G=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||!jn(E.asset,$t(J(H)),Dt=>u(A,Dt)))throw new Error("Incompatible runtime asset");j={...E,asset:C.buildDefinition(H).enc(E.asset)}}const{location:Se,codec:at}=G;return{callData:je.fromBytes(ve(new Uint8Array(Se),at.enc(x))),options:j}},d=(g,x={})=>s(n,null).pipe(I(([E])=>f(E,g,x))),h=g=>g?f(g,l).callData:xe(d(l).pipe(I(x=>x.callData))),p=(g,{...x},E)=>d(l,x).pipe(D(({callData:A,options:C})=>uf(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:te(C),block:A}))):yn(()=>new Error(`Uknown block ${x}`)))),y=(g,x)=>xe(v(g,x)).then(E=>E.tx),b=(g,x)=>xe(v(g,x)).then(({tx:E,block:A})=>cs(n,r,E,A.hash)),m=(g,x)=>v(g,x).pipe(D(({tx:E,block:A})=>dr(n,r,E,A.hash,!0))),S=async(g,x)=>{typeof g=="string"&&(g=g.startsWith("0x")?pe(g):yf(g));const E=g.length===20,A=Kl(g,E?"Ecdsa":"Sr25519",gf(E)),C=pe(await y(A,x)),H=te(ve(C,ke.enc(C.length))),J=n.getRuntimeContext$(null).pipe(I(j=>j.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),G=n.call$(null,"TransactionPaymentApi_query_info",H);return xe(bn([G,J]).pipe(I(([j,Se])=>Se(j))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:Bt(t,l)},getEncodedData:h,sign:y,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),us=(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)=>Vl(p,v,t,bt(e,y=>y.getPalletEntryPoint(yt.Storage,p,v),y=>Sa(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=Ia(m.value[b]);return{args:v==="args"?S:nn,values:v==="args"?nn:S}},a=i((p,v)=>as(p,v,t,n,bt(e,y=>y.getPalletEntryPoint(yt.Tx,p,v),y=>u(y,"args",s(y,p).calls,v)),!0)),l=i((p,v)=>Hl(p,v,t,bt(e,y=>y.getPalletEntryPoint(yt.Event,p,v),y=>u(y,"values",s(y,p).events,v)))),f=i((p,v)=>Ll(p,v,bt(e,y=>y.getPalletEntryPoint(yt.Const,p,v),y=>Ba(s(y,p).constants.find(b=>b.name===v).type)))),d=i((p,v)=>Fl(p,v,t,bt(e,y=>y.getApiEntryPoint(p,v),y=>Aa(y.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===v))))),h=(p,v)=>{const{lookup:y,dynamicBuilder:b}=ir(v).runtime();try{const m=b.buildDefinition(y.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return as(S,g,t,n,bt(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,v)=>v?h(p,v):e.then(y=>h(p,y)),tx:a,event:l,apis:d,constants:f}};function wf(e){const t=ja(e),n=Cl(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const c=new WeakMap,u=f=>{const d=c.get(f)||Pl(f,r);return c.set(f,d),d},a=()=>s??(s=Ul(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>xe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>xe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:f=>xe(r.body$(f)),getBlockHeader:f=>xe(r.header$(f??null)),submit:(...f)=>cs(r,l,...f),submitAndWatch:(...f)=>dr(r,l,...f),getTypedApi:f=>{const d=u(f);return Object.assign(us(d,r,l),{compatibilityToken:d})},getUnsafeApi:()=>{const f=a();return Object.assign(us(f,r,l),{runtimeToken:f})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}he.AccountId=nt,he.Binary=je,he.CompatibilityLevel=Be,he.Enum=Bt,he.FixedSizeBinary=Tn,he.InvalidTxError=fr,he._Enum=so,he.createClient=wf,he.getSs58AddressInfo=On});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function fn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var at=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=dt(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 l=this.initialTeardown;if(z(l))try{l()}catch(v){i=v instanceof Zn?v.errors:[v]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var d=dt(f),h=d.next();!h.done;h=d.next()){var p=h.value;try{ni(p)}catch(v){i=i??[],v instanceof Zn?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 Zn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ni(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)&&fn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&fn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),ei=at.EMPTY;function ti(e){return e instanceof at||e&&"closed"in e&&z(e.remove)&&z(e.add)&&z(e.unsubscribe)}function ni(e){z(e)?e():e.unsubscribe()}var ri={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Za={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 oi(e){Za.setTimeout(function(){throw e})}function De(){}function dn(e){e()}var Jn=function(e){Me(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ti(n)&&n.add(r)):r.destination=eu,r}return t.create=function(n,r,o){return new pt(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}(at),Ja=Function.prototype.bind;function Qn(e,t){return Ja.call(e,t)}var Qa=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){hn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){hn(r)}else hn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){hn(n)}},e}(),pt=function(e){Me(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&&ri.useDeprecatedNextContext?(c=Object.create(n),c.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Qn(n.next,c),error:n.error&&Qn(n.error,c),complete:n.complete&&Qn(n.complete,c)}):s=n}return i.destination=new Qa(s),i}return t}(Jn);function hn(e){oi(e)}function Na(e){throw e}var eu={closed:!0,next:De,error:Na,complete:De},Nn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ze(e){return e}function ii(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return si(e)}function si(e){return e.length===0?Ze:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var $=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,i=nu(t)?t:new pt(t,n,r);return dn(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=ci(n),new n(function(o,i){var s=new pt({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[Nn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return si(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ci(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 ci(e){var t;return(t=e??ri.Promise)!==null&&t!==void 0?t:Promise}function tu(e){return e&&z(e.next)&&z(e.error)&&z(e.complete)}function nu(e){return e&&e instanceof Jn||tu(e)&&ti(e)}function ru(e){return z(e?.lift)}function N(e){return function(t){if(ru(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function X(e,t,n,r,o){return new ou(e,t,n,r,o)}var ou=function(e){Me(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}(Jn),iu=Yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Pt=function(e){Me(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new ai(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new iu},t.prototype.next=function(n){var r=this;dn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=dt(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;dn(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;dn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,c=o.observers;return i||s?ei:(this.currentObservers=null,c.push(n),new at(function(){r.currentObservers=null,fn(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},t.prototype.asObservable=function(){var n=new $;return n.source=this,n},t.create=function(n,r){return new ai(n,r)},t}($),ai=function(e){Me(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:ei},t}(Pt),er={now:function(){return(er.delegate||Date).now()},delegate:void 0},pn=function(e){Me(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=er);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}(Pt),su=function(e){Me(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(at),ui={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},cu=function(e){Me(t,e);function t(n,r){var o=e.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return t.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var 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),ui.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&&ui.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,fn(i,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(su),li=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=er.now,e}(),au=function(e){Me(t,e);function t(n,r){r===void 0&&(r=li.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}(li),fi=new au(cu),uu=fi,Ut=new $(function(e){return e.complete()});function lu(e){return e&&z(e.schedule)}function tr(e){return e[e.length-1]}function di(e){return z(tr(e))?e.pop():void 0}function vn(e){return lu(tr(e))?e.pop():void 0}function fu(e,t){return typeof tr(e)=="number"?e.pop():t}var hi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function pi(e){return z(e?.then)}function vi(e){return z(e[Nn])}function yi(e){return Symbol.asyncIterator&&z(e?.[Symbol.asyncIterator])}function bi(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function du(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var mi=du();function gi(e){return z(e?.[mi])}function wi(e){return Ka(this,arguments,function(){var n,r,o,i;return No(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,ht(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,ht(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,ht(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 ki(e){return z(e?.getReader)}function de(e){if(e instanceof $)return e;if(e!=null){if(vi(e))return hu(e);if(hi(e))return pu(e);if(pi(e))return vu(e);if(yi(e))return xi(e);if(gi(e))return yu(e);if(ki(e))return bu(e)}throw bi(e)}function hu(e){return new $(function(t){var n=e[Nn]();if(z(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function pu(e){return new $(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function vu(e){return new $(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,oi)})}function yu(e){return new $(function(t){var n,r;try{for(var o=dt(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 xi(e){return new $(function(t){mu(e,t).catch(function(n){return t.error(n)})})}function bu(e){return xi(wi(e))}function mu(e,t){var n,r,o,i;return Ga(this,void 0,void 0,function(){var s,c;return No(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Ya(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 Ei(e,t){return t===void 0&&(t=0),N(function(n,r){n.subscribe(X(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 Si(e,t){return t===void 0&&(t=0),N(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function gu(e,t){return de(e).pipe(Si(t),Ei(t))}function wu(e,t){return de(e).pipe(Si(t),Ei(t))}function ku(e,t){return new $(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function xu(e,t){return new $(function(n){var r;return Je(n,t,function(){r=e[mi](),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 Ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new $(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 Eu(e,t){return Ai(wi(e),t)}function Su(e,t){if(e!=null){if(vi(e))return gu(e,t);if(hi(e))return ku(e,t);if(pi(e))return wu(e,t);if(yi(e))return Ai(e,t);if(gi(e))return xu(e,t);if(ki(e))return Eu(e,t)}throw bi(e)}function Lt(e,t){return t?Su(e,t):de(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e);return Lt(e,n)}function yn(e,t){var n=z(e)?e:function(){return e},r=function(o){return o.error(n())};return new $(r)}var Ii=Yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Au(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 Ii)}})})}function xe(e,t){return new Promise(function(n,r){var o=new pt({next:function(i){n(i),o.unsubscribe()},error:r,complete:function(){r(new Ii)}});e.subscribe(o)})}function Iu(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return N(function(n,r){var o=0;n.subscribe(X(r,function(i){r.next(e.call(t,i,o++))}))})}var Bu=Array.isArray;function _u(e,t){return Bu(t)?e.apply(void 0,Ye([],Ke(t))):e(t)}function Cu(e){return I(function(t){return _u(e,t)})}var Ou=Array.isArray,$u=Object.getPrototypeOf,Tu=Object.prototype,Pu=Object.keys;function Uu(e){if(e.length===1){var t=e[0];if(Ou(t))return{args:t,keys:null};if(Lu(t)){var n=Pu(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Lu(e){return e&&typeof e=="object"&&$u(e)===Tu}function Ru(e,t){return e.reduce(function(n,r,o){return n[r]=t[o],n},{})}function bn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=di(e),o=Uu(e),i=o.args,s=o.keys;if(i.length===0)return Lt([],n);var c=new $(Mu(i,n,s?function(u){return Ru(s,u)}:Ze));return r?c.pipe(Cu(r)):c}function Mu(e,t,n){return n===void 0&&(n=Ze),function(r){Bi(t,function(){for(var o=e.length,i=new Array(o),s=o,c=o,u=function(l){Bi(t,function(){var f=Lt(e[l],t),d=!1;f.subscribe(X(r,function(h){i[l]=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 Bi(e,t,n){e?Je(n,e,t):t()}function Du(e,t,n,r,o,i,s,c){var u=[],a=0,l=0,f=!1,d=function(){f&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var y=!1;de(n(v,l++)).subscribe(X(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(X(t,h,function(){f=!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)})(de(e(r,o)))},n):(typeof t=="number"&&(n=t),N(function(r,o){return Du(r,o,e,n)}))}function nr(e){return e===void 0&&(e=1/0),D(Ze,e)}function zu(){return nr(1)}function Hu(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return zu()(Lt(e,vn(e)))}function mn(e){return new $(function(t){de(e()).subscribe(t)})}var Fu={connector:function(){return new Pt},resetOnDisconnect:!0};function Vu(e,t){t===void 0&&(t=Fu);var n=null,r=t.connector,o=t.resetOnDisconnect,i=o===void 0?!0:o,s=r(),c=new $(function(u){return s.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=mn(function(){return e}).subscribe(s),i&&n.add(function(){return s=r()})),n},c}function _i(e,t,n){return n===void 0&&(n=uu),new $(function(r){var o=Iu(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 Ci(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=vn(e),r=fu(e,1/0),o=e;return o.length?o.length===1?de(o[0]):nr(r)(Lt(o,n)):Ut}function Qe(e,t){return N(function(n,r){var o=0;n.subscribe(X(r,function(i){return e.call(t,i,o++)&&r.next(i)}))})}function Rt(e){return N(function(t,n){var r=null,o=!1,i;r=t.subscribe(X(n,void 0,void 0,function(s){i=de(e(s,Rt(e)(t))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function ju(e,t,n,r,o){return function(i,s){var c=n,u=t,a=0;i.subscribe(X(s,function(l){var f=a++;u=c?e(u,l,f):(c=!0,l),s.next(u)},o))}}function Oi(e,t){return z(t)?D(e,t,1):D(e,1)}function qu(e,t){return t===void 0&&(t=fi),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(X(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 Ut}:N(function(t,n){var r=0;t.subscribe(X(n,function(o){++r<=e&&(n.next(o),e<=r&&n.complete())}))})}function Wu(e,t){return N(function(n,r){var o=new Set;n.subscribe(X(r,function(i){var s=e?e(i):i;o.has(s)||(o.add(s),r.next(i))})),t&&de(t).subscribe(X(r,function(){return o.clear()},De))})}function Ee(e,t){return t===void 0&&(t=Ze),e=e??Xu,N(function(n,r){var o,i=!0;n.subscribe(X(r,function(s){var c=t(s);(i||!e(o,c))&&(i=!1,o=c,r.next(s))}))})}function Xu(e,t){return e===t}function $i(e,t){return N(ju(e,t,arguments.length>=2,!0))}function gn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Pt}: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,f,d,h=0,p=!1,v=!1,y=function(){f?.unsubscribe(),f=void 0},b=function(){y(),l=d=void 0,p=v=!1},m=function(){var S=l;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&&(f=rr(m,u))}),x.subscribe(g),!l&&h>0&&(l=new pt({next:function(E){return x.next(E)},error:function(E){v=!0,y(),f=rr(b,o,E),x.error(E)},complete:function(){p=!0,y(),f=rr(b,s),x.complete()}}),de(S).subscribe(l))})(a)}}function rr(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 pt({next:function(){o.unsubscribe(),e()}});return de(t.apply(void 0,Ye([],Ke(n)))).subscribe(o)}}function Ti(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,gn({connector:function(){return new pn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Pi(e,t){return N(function(n,r){var o=null,i=0,s=!1,c=function(){return s&&!o&&r.complete()};n.subscribe(X(r,function(u){o?.unsubscribe();var a=0,l=i++;de(e(u,l)).subscribe(o=X(r,function(f){return r.next(t?t(u,f,l,a++):f)},function(){o=null,c()}))},function(){s=!0,c()}))})}function Gu(e){return N(function(t,n){de(e).subscribe(X(n,function(){return n.complete()},De)),!n.closed&&t.subscribe(n)})}function Ui(e,t){return t===void 0&&(t=!1),N(function(n,r){var o=0;n.subscribe(X(r,function(i){var s=e(i,o++);(s||t)&&r.next(i),!s&&r.complete()}))})}function Ku(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(X(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 Li(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=di(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(f){de(e[f]).subscribe(X(o,function(d){s[f]=d,!u&&!c[f]&&(c[f]=!0,(u=c.every(Ze))&&(c=null))},De))},l=0;l<i;l++)a(l);r.subscribe(X(o,function(f){if(u){var d=Ye([f],Ke(s));o.next(n?n.apply(void 0,Ye([],Ke(d))):d)}}))})}var Yu=Object.defineProperty,Zu=(e,t,n)=>t in e?Yu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ri=(e,t,n)=>Zu(e,typeof t!="symbol"?t+"":t,n);class Ju{constructor(){Ri(this,"first"),Ri(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 Qu=()=>{const e=new Map,t=(d,h)=>{e.set(d,()=>{e.delete(d),h()})},n=d=>{e.get(d)?.()},r=new Ju,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 sn)?s(d,!0):p.error(b)},complete(){p.complete()}});y.closed?v||c():t(h,()=>{y.unsubscribe(),c()})},a=(d=!1)=>h=>new $(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):s(v,d),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:d=>(...h)=>l(d(...h))}};class wn extends Error{constructor(){super("Block is not pinned"),this.name="BlockNotPinnedError"}}class Nu extends Error{constructor(){super("Block pruned"),this.name="BlockPrunedError"}}class Mi extends Error{constructor(){super("Block is not best block or finalized"),this.name="NotBestBlockError"}}const el=new Set(["best","finalized",null]),Di=e=>{const t=e.pipe(Rt(n=>n instanceof cn?_i(750).pipe(Oi(()=>t)):yn(()=>n)));return t},tl=(e,t,n)=>r=>(o,...i)=>{if(!el.has(o))return Di(r(o,...i)).pipe(n(o));const c=(o==="best"?t:e).pipe(_e(1),D(u=>r(u,...i).pipe(n(u))),Rt(u=>u instanceof wn?c:yn(()=>u)));return Di(c)},zi=e=>(...t)=>new $(n=>{let r=new AbortController;return e(...t,r.signal).then(o=>{n.next(o),n.complete()},o=>{n.error(o)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),nl=e=>t=>(...n)=>e()[t](...n),rl=(e,t)=>e.pipe(Ui(n=>n.blocks.has(t)),Ee((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let 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}),Ee(),Ui(n=>n!=="finalized",!0));function ol(e,t,n){return(r,o,...i)=>(o?ii(sl(r,t.pipe(Qe(c=>c.type==="finalized"),D(c=>c.prunedBlockHashes))),il(r,e)):c=>c)(n(r,...i))}const il=(e,t)=>n=>rl(t,e).pipe(_e(1),Pi(r=>r?n:yn(()=>new Mi))),sl=(e,t)=>n=>new $(r=>{const o=t.pipe(Qe(s=>s===e)).subscribe(()=>{r.error(new Nu)}),i=n.subscribe(r);return()=>{o.unsubscribe(),i.unsubscribe()}});function kn(e,t){return(n,...r)=>{const o=t(n,...r);return new $(i=>{let s=null,c=!1;const u=()=>{c||(c=!0,s=o.subscribe({next:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),s.add(()=>{c=!1,s=null}))};let a=!1;const l=e.subscribe({next:f=>{const d=f.blocks.get(n);d?d.recovering?s?.unsubscribe():u():a&&i.error(new wn),a=f.recovering},error:f=>i.error(f)});return()=>{l.unsubscribe(),s?.unsubscribe()}})}}const cl=(e,t)=>{const n=(r,o,i,s)=>new $(c=>e().storageSubscription(r,o,i??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,o.slice(-u),i,!0))})).pipe(nr(),t(s));return n},al=e=>t=>t.pipe(Oi(n=>n.type!=="initialized"?re(n):e(n.finalizedBlockHashes[0]).then(r=>({...n,number:r.number,parentHash:r.parentHash})))),ul=e=>{let t=null,n=De;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},o=c=>r().header(c).then(go.dec),i=Vu(new $(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(al(o),ll()));return{getHeader:o,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},ll=()=>e=>new $(t=>{const n=new at,r=()=>e.subscribe({next:o=>t.next(o),error:o=>{o instanceof Xo?(t.next({type:"stop-error"}),n.add(r())):t.error(o)},complete:()=>t.complete()});return n.add(r()),n}),Hi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",Ne={type:"void"},fl=(e,t=()=>null)=>{const n=new Map,r=new Set,o=l=>f=>{let d=n.get(f);if(d)return d;if(r.has(f)){const p={id:f};return n.set(f,p),p}r.add(f);const h=l(f);return d=n.get(f),d?Object.assign(d,h):(d={id:f,...h},n.set(f,d)),r.delete(f),d};let i=!0,s=!0;const c=o(l=>{const f=t(e[l]);if(f)return f;const{def:d,path:h,params:p}=e[l];if(d.tag==="composite"){if(d.value.length===0)return Ne;if(d.value.length===1){const v=c(d.value[0].type);return i&&h.at(-1)==="AccountId32"&&Hi(v,32)?(i=!1,{type:"AccountId32"}):s&&h.at(-1)==="AccountId20"&&Hi(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 Ne;const v={},y={};return d.value.forEach(b=>{const m=b.name;if(y[m]=b.docs,b.fields.length===0){v[m]={...Ne,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"?Ne:v>1?{type:"array",value:y,len:d.value.len}:y}if(d.tag==="tuple")return d.value.length===0?Ne: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"?Ne:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:d.tag}}),u=l=>{let f=!0;const d={},h={};return l.forEach((p,v)=>{f=f&&!!p.name;const y=p.name||v,b=c(p.type);b.type!=="void"&&(d[y]=b,h[y]=p.docs)}),f?{type:"struct",value:d,innerDocs:h}:a(Object.values(d),Object.values(h))},a=(l,f)=>{if(l.every(d=>d.id===l[0].id)&&f.every(d=>!d.length)){const[d]=l;return d.type==="void"?Ne:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:f}};return c},Fi=e=>{const t=fl(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?{...Ne,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})},dl=(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},hl=It(),pl=M(j[0],jt(j[1],BigInt)),Vi=dl((e,t,n,r)=>{if(e.type==="primitive")return Ho[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return yo;if(e.type==="compact")return e.isBig?pl:j;if(e.type==="bitSequence")return to;const o=h=>Vi(h,t,n,r),i=(h,p)=>{const v=o(h);return p?U(v,p):U(v)},s=h=>ae(...h.map(o)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,y])=>[v,o(y)]));return O(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return hl;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?It(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 qt(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]])),l=Object.values(e.value).map(h=>h.idx),d=l.every((h,p)=>h===p)?ge(a):ge(a,l);return e.byteLength?vl(d,e.byteLength):d},Pn,e=>e),ji=(e,t=rt())=>{const n=new Map,r=o=>Vi(e(o),n,new Set,t);return o=>r(o)},vl=(e,t)=>{const n=Y(t);return M(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},qi=e=>{const{metadata:t}=e;let n=ji(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let o;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(o=f,n=ji(e,rt(f)))}catch{}const i=new Map,s=(f,d)=>{let h=i.get(f);h||i.set(f,h=Do(f));const p=t.pallets.find(E=>E.name===f).storage.items.find(E=>E.name===d),v=(E,...A)=>{const T=h(...A);return{...T,len:E,fallback:p.modifier===1?T.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=>Ho[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,T)=>[n(A.id),g[T]]);default:throw new Error("Invalid key type")}})();return v(g.length,d,S.dec,...x)},c=f=>{switch(f.type){case"void":return _;case"lookupEntry":return n(f.value.id);case"tuple":return ae(...Object.values(f.value).map(d=>n(d.id)));case"struct":return O(Zt(f.value,d=>n(d.id)));case"array":return U(n(f.value.id),f.len)}},u=(f,d)=>{const h=t.pallets.find(p=>p.name===f).constants.find(p=>p.name===d);return n(h.type)},a=f=>(d,h)=>{const p=t.pallets.find(b=>b.name===d),v=e(p[f]);if(v.type!=="enum")throw null;const y=v.value[h];return{location:[p.index,y.idx],codec:c(v.value[h])}},l=(f,d)=>{const h=t.apis.find(p=>p.name===f)?.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:l,buildCall:a("calls"),buildConstant:u,ss58Prefix:o}},yl=te(ke.enc(15)),Wi=Y(),bl=ee(Wi),ml=U(ke).dec,gl=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(Rt(l=>{if(l instanceof wn)return r(c,u);if(l instanceof cn)return _i(750).pipe(D(()=>r(c,u)));throw l})):Ut},o=r("Metadata_metadata_versions","").pipe(I(ml)),i=r("Metadata_metadata","").pipe(I(c=>{const u=Wi.dec(c);return{metadata:it.dec(u).metadata.value,metadataRaw:u}})),s=r("Metadata_metadata_at_version",yl).pipe(I(c=>{const u=bl.dec(c);return{metadata:it.dec(u).metadata.value,metadataRaw:u}}));return o.pipe(Rt(()=>re([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=Fi(c),l=qi(a),f=l.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:l,events:{key:f.enc(),dec:f.dec},accountId:rt(l.ss58Prefix)}}),Ti(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}},Mt=gn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Xi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].reverse().find(o=>!e.blocks.get(o).unpinned)??null:e.blocks.has(t)?t:null},Gi=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},wl=(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=>{Gi(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},kl=(e,t,n,r)=>{const o=Ci(n,e).pipe($i((s,c)=>{switch(c.type){case"initialized":s.recovering&&(c.finalizedBlockHashes.some(d=>s.blocks.has(d))||(s=Ki()));const[u]=c.finalizedBlockHashes.slice(-1);s.finalized=s.best=u;const a=c.finalizedBlockHashes.length-1;c.finalizedBlockHashes.forEach((f,d)=>{s.blocks.has(f)?s.blocks.get(f).recovering=!1:s.blocks.set(f,{hash:f,parent:d===0?c.parentHash:c.finalizedBlockHashes[d-1],children:new Set(d===a?[]:[c.finalizedBlockHashes[d+1]]),runtime:f,refCount:0,number:c.number+d,recovering:!1})});const l=Object.values(s.runtimes).find(f=>f.usages.has(u));return s.finalizedRuntime=l??(s.runtimes[u]=i(Xi(s,u))),s;case"stop-error":for(const f of s.blocks.values())f.recovering=!0;return s.recovering=!0,s;case"newBlock":{const{parentBlockHash:f,blockHash:d}=c;if(s.blocks.has(d))s.blocks.get(d).recovering=!1;else{const h=s.blocks.get(f);h.children.add(d),c.newRuntime&&(s.runtimes[d]=i(Xi(s,d)));const p={hash:d,number:h.number+1,parent:f,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[f,d]of s.blocks)d.recovering&&Gi(s.blocks,f);s.recovering=!1}return s.best=c.bestBlockHash,s}case"finalized":{s.finalized=c.finalizedBlockHashes.slice(-1)[0];const{blocks:f}=s;return f.get(s.best).number<f.get(s.finalized).number&&(s.best=s.finalized),s.finalizedRuntime=s.runtimes[f.get(s.finalized).runtime],r(wl(s,c.prunedBlockHashes)),s}case"blockUsage":{if(!s.blocks.has(c.value.hash))return s;const f=s.blocks.get(c.value.hash);return f.refCount+=c.value.type==="hold"?1:-1,f.refCount===0&&f.number<s.blocks.get(s.finalized).number&&!f.recovering&&(f.unpinned=!0,r([f.hash])),s}}},Ki()),Qe(s=>!!s.finalizedRuntime.runtime),I(s=>({...s})),Mt),i=gl(kn(o,t));return o},Ki=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Yi=(e,t,n,r)=>{const o=c=>Gu(e.pipe(Qe(({blocks:u})=>!u.has(c)))),i=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const l=o(c);return t(c).pipe(D(f=>{const d=f.indexOf(u);return d>-1?l(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}})))}),l)},s=(c,u,a)=>i(c,u,a.has(c)).pipe(D(l=>{const{found:f}=l;return f.type||f.validity?.success===!1?re(l):e.pipe(o(c),D(d=>d.blocks.get(c).children),Wu(),D(d=>s(d,u,a)))}));return c=>e.pipe(_e(1),D(u=>s(u.finalized,c,new Set(u.blocks.keys()))))},xl=new Uint8Array([2]),El=(e,t)=>te(ue(xl,ye(e),ye(t))),Zi="TaggedTransactionQueue",Ji="validate_transaction",[,Sl]=ge({InvalidTransaction:ge({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:ge({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),Al=Vt(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=Sl(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Il=(e,t)=>(n,r)=>{const o=t(n).pipe(I(i=>{try{return i.dynamicBuilder.buildRuntimeCall(Zi,Ji).value[1]}catch{return Al}}));return e(n,`${Zi}_${Ji}`,El(r,n)).pipe(Li(o),I(([i,s])=>s(i)))},Bl=e=>t=>new $(n=>{let r=!1;const o=t.subscribe({next(i){r=!0,n.next(i)},error(i){n.error(i)},complete(){n.complete()}});return r||n.next(e),o}),_l=(e,t=1/0)=>n=>new $(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,l=0;const f=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),l!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){l===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;f()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,mn(()=>e(d,h))),s.size<t&&f()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Cl=e=>t=>new $(n=>{const r=t.subscribe({next(i){n.next(i)},error(i){n.error(i)},complete(){n.complete()}}),o=()=>r.unsubscribe();return()=>{Promise.resolve().then(o)}}),or=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),Ol=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:o}=ul(e),i=nl(t),{withRecovery:s,withRecoveryFn:c}=Qu(),u=new Pt,a=k=>(u.next({type:"blockUsage",value:{type:"hold",hash:k}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:k}})},0)}),l=k=>B=>new $(P=>{const F=a(k),he=B.subscribe(P);return he.add(F),he}),f=k=>(B,...P)=>k(B,...P).pipe(l(B)),d=k=>(B,...P)=>new $(F=>{let he=!1;return b.pipe(_e(1)).subscribe(Ce=>{const ce=Ce.blocks.get(B);he=!!ce&&!ce.unpinned}),he?k(B,...P).subscribe(F):F.error(new wn)}),h=k=>t().unpin(k).catch(B=>{if(!(B instanceof on))throw B}),p=k=>d(f((P=>ol(b,r,P))(kn(b,c(zi(k)))))),v=(k,B=!0)=>(P,...F)=>k(P,B,...F),y=new Map,b=kl(r,f(c(zi(i("call")))),u,k=>{h(k),k.forEach(B=>{y.delete(B)})}),m=f(k=>b.pipe(_e(1),D(B=>B.runtimes[B.blocks.get(k).runtime].runtime))),S=k=>B=>B.pipe(_l(P=>m(k(P)).pipe(I(F=>[P,F])))),g=(k,B,P)=>{const F=y.get(k)??new Map,he=F.get(B);if(he)return he;y.set(k,F);let Ce;const ce=P.pipe(gn({connector:()=>Ce=new pn}),Ku({complete(){F.set(B,Ce)}}),Cl());return F.set(B,ce),ce},x=b.pipe(Ee((k,B)=>k.finalized===B.finalized),I(k=>or(k.blocks.get(k.finalized))),Mt),E=b.pipe(Ee((k,B)=>k.best===B.best),I(k=>or(k.blocks.get(k.best))),Mt),A=b.pipe(Ee((k,B)=>k.finalized===B.finalized&&k.best===B.best),$i((k,B)=>{const P=pe=>k.get(pe)||or(B.blocks.get(pe)),F=P(B.best),he=P(B.finalized),Ce=F.number-he.number+1,ce=new Array(Ce);for(let pe=0,Ht=F.hash;pe<Ce;pe++)ce[pe]=P(Ht),Ht=ce[pe].parent;return new Map(ce.map(pe=>[pe.hash,pe]))},new Map),I(k=>[...k.values()]),Mt),T=b.pipe(Ee((k,B)=>k.finalizedRuntime===B.finalizedRuntime),Pi(({finalizedRuntime:{runtime:k}})=>k.pipe(Bl(null))),Mt),q=T.pipe(I(k=>k?.lookup.metadata??null)),H=tl(x.pipe(I(k=>k.hash)),E.pipe(I(k=>k.hash)),l),G=H(p(i("body"))),W=k=>g(k,"body",G(k,!0)),Se=p(i("storage")),et=H((k,B,P,F,he=null,Ce)=>b.pipe(_e(1),D(ce=>ce.runtimes[ce.blocks.get(k).runtime].runtime),D(ce=>{const pe=F(ce),Ht=g(k,`storage-${P}-${pe}-${he??""}`,Se(k,B,P,pe,he));return Ce?g(k,`storage-${P}-${pe}-${he??""}-dec`,Ht.pipe(I(Of=>Ce(Of,ce)))):Ht}))),zt=cl(t,s),Sf=H(kn(b,(k,B,P)=>zt(k,B,P??null,!1))),Af=H(kn(b,k=>mn(()=>o(k)))),fs=(k,B=!1)=>et(k,B,"value",P=>P.events.key,null,(P,F)=>F.events.dec(P)),If=p(i("call")),ds=H((k,B,P,F)=>g(k,`call-${P}-${F}`,If(k,B,P,F))),hr=Il(v(ds,!1),m),hs=k=>g(k,"body",G(k,!1)),Bf=Yi(b,hs,hr,fs),_f=Yi(b,hs,hr,()=>re());Ci(T,A).subscribe({error(){}});let pr=De,An=!1,vr=0;const Cf=k=>{vr+=k,An=!0,pr=n()};return[{follow$:r,finalized$:x,best$:E,bestBlocks$:A,runtime$:T,metadata$:q,header$:Af,body$:W,call$:v(ds),storage$:v(et),storageQueries$:Sf,eventsAt$:v(fs),holdBlock:a,trackTx$:Bf,trackTxWithoutEvents$:_f,validateTx$:hr,pinnedBlocks$:b,withRuntime:S,getRuntimeContext$:H(m),unfollow:()=>{An!=null&&(vr--,An&&!vr&&(An=null,pr(),pr=De))}},Cf]};var $l=e=>t=>new $(n=>e(t,r=>{n.error(r)}));const xn=new Map,Tl=e=>{const t=xn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=xn.get(e);!c||c.refCount<=1?(xn.delete(e),e.destroy()):c.refCount--};let r=null,o=0,i=null;const s={chainHead$:c=>{o++,i||(i=c||1),r||(r=Ol(e.chainHead));const[u,a]=r;if(i===o){const l=o;o=0,i=null,r=null,a(l)}return u},broadcastTx$:$l(e.transaction),destroy:n};return xn.set(e,{client:s,refCount:1}),s};class vt{constructor(){}_runtime(t){}}class Qi{constructor(){}_compatibility(t){}}const En=new WeakMap,Ni=new WeakMap,ir=e=>e instanceof vt?Ni.get(e):En.get(e);var yt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e))(yt||{});const Pl=U(Ia),Ul=U(Vn),Ll=ae(Pl,Ul),Rl=(e,t)=>{const n=new Promise(async r=>{const o=t.runtime$.pipe(Qe(s=>s!=null));let i=await xe(o);o.subscribe(s=>i=s),r(()=>i)});return Promise.all([e.metadataTypes.then(Ll.dec),e.descriptors,n]).then(([[r,o],i,s])=>{const c=new Qi;return En.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})},Ml=e=>new Promise(async t=>{const n=e.runtime$.pipe(Qe(o=>o!=null));let r=await xe(n);n.subscribe(o=>r=o),t(()=>r)}).then(t=>{const n=new vt;return Ni.set(n,{runtime:t}),n}),sr=new WeakMap,es=e=>(sr.has(e.metadataRaw)||sr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),sr.get(e.metadataRaw)),bt=(e,t,n)=>{const r=(u,a)=>{var l;const f=es(u);return(l=f.typeNodes)[a]||(l[a]=Tt(f.lookup(a)))};function o(u,a){if(u instanceof vt)return{args:Be.Identical,values:Be.Identical};const l=En.get(u);a||(a=l.runtime());const f=t(l),d=n(a),h=l.typedefNodes,p=es(a);return $a(f,v=>h[v],d,v=>r(a,v),p.compat)}const i=ns(e,u=>ts(o(u))),s=ns(e,(u,a)=>i(a)>=u),c=()=>e;return{isCompatible:s,getCompatibilityLevel:i,getCompatibilityLevels:o,waitDescriptors:c,withCompatibleRuntime:(u,a)=>l=>bn([l.pipe(u.withRuntime(a)),c()]).pipe(I(([[f,d],h])=>[f,h,d])),compatibleRuntime$:(u,a)=>bn([c(),u.getRuntimeContext$(a)]),argsAreCompatible:(u,a,l)=>{if(u instanceof vt)return!0;const f=o(u,a);if(f.args===Be.Incompatible)return!1;if(f.args>Be.Partial)return!0;if(f.values===Be.Incompatible)return!1;const d=n(a);return Wo(d.args,h=>r(a,h),l)},valuesAreCompatible:(u,a,l)=>{if(u instanceof vt)return!0;const f=o(u,a).values;if(f===Be.Incompatible)return!1;if(f>Be.Partial)return!0;const d=En.get(u),h=t(d);return Wo(h.values,p=>d.typedefNodes[p],l)},getRuntimeTypedef:r}},ts=e=>Math.min(e.args,e.values),ns=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Qi||r instanceof vt?t(...n):e.then(o=>t(...n,o))},Dl=(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(d=>d.name===e)?.constants.find(d=>d.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const f=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return s.set(a,f),f},u=a=>{if(a){const l=ir(a).runtime(),f=c(l);if(!n(a,l,f))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return f}return r().then(u)};return Object.assign(u,{isCompatible:o,getCompatibilityLevel:i})},zl=gn({connector:()=>new pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function cr(e,t){return new Promise((n,r)=>{let o=null,i=!1;const s=t?()=>{o?.unsubscribe(),r(new Yr)}:De;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 Hl=(e,t=1/0)=>n=>new $(r=>{let o;const i=new Map,s=new Map,c=new Map;let u=0,a=0,l=0;const f=()=>{const d=i.get(a);if(!d){s.size===0&&(typeof o>"u"||o.closed)&&r.complete();return}const h=a++;i.delete(h),l!==h&&c.set(h,[]),s.set(h,d.subscribe({next(p){l===h?r.next(p):c.get(h).push(p)},complete(){if(s.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(p=>r.next(p)),c.delete(l),!s.has(l));)l++;f()},error(p){r.error(p)}}))};return o=n.subscribe({next(d){const h=u++;i.set(h,mn(()=>e(d,h))),s.size<t&&f()},error(d){r.error(d)},complete(){s.size===0&&r.complete()}}),()=>{s.forEach(d=>d.unsubscribe()),o.unsubscribe(),i.clear(),c.clear()}}),Fl=(e,t)=>n=>new $(r=>{let o=new Array,i=!1;const s=u=>{const a=new at;o.push(a),o.length>t&&(o[0].unsubscribe(),o=o.slice(1));const l=e(u).subscribe({next(f){const d=o.indexOf(a);o.slice(0,d).forEach(h=>h.unsubscribe()),o=o.slice(d),r.next(f)},error(f){r.error(f)},complete(){const f=o.indexOf(a);o.splice(f,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 rs={};const Vl=e=>t=>new $(n=>{let r=rs,o=t.subscribe({next(i){n.next(r=i)},error(i){n.error(i)},complete(){r===rs?n.complete():o=e(r).subscribe(n)}});return()=>{o.unsubscribe()}}),ar=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)),jl=(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,f,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(f,d,null))throw u();return[l,f,d]}),Hl(([l,f,d])=>n.eventsAt$(l.hash).pipe(I(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(f,d,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),zl);return{watch:l=>a.pipe(D(f=>l?f.filter(d=>l(d.payload)):f)),pull:()=>xe(a),filter:l=>l.filter(f=>f.type===e&&f.value.type===t).map(f=>f.value.value),getCompatibilityLevel:o,isCompatible:r}},ql=(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 f=l[l.length-1],d=ar(f),{signal:h,at:p}=d?f:{},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,l))throw a();return n.call$(v,u,te(S.args.enc(l))).pipe(I(S.value.dec),I(g=>{if(!c(b,m,g))throw a();return g}))}));return cr(y,h)},{getCompatibilityLevel:o,isCompatible:r})},Wl=(e,t,n,{isCompatible:r,getCompatibilityLevel:o,getCompatibilityLevels:i,waitDescriptors:s,withCompatibleRuntime:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",f=n.runtime$.pipe(Qe(Boolean),_e(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").dec(new Uint8Array(32))=="bigint"?BigInt:Ze),Ti()),d=ii(Li(f),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 l?n.bestBlocks$.pipe(I(x=>x.at(S==="best"?0:-1).number),Ee(),d):n[S==="best"?"best$":"finalized$"].pipe(qu(0),c(n,x=>x.hash),Fl(([x,E,A])=>{const T=v(A);if(!u(E,A,g))throw h();return n.storage$(x.hash,"value",()=>T.enc(...g)).pipe(I(q=>{if(!a(E,A,q))throw h();return{val:q,codecs:T}}))},4),Ee((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=ar(S),{signal:x,at:E}=g?S:{},A=E??null;let T;if(l)T=n.bestBlocks$.pipe(I(q=>A==="finalized"||!A?q.at(-1):A==="best"?q.at(0):q.find(H=>H.hash===A)),I(q=>{if(!q)throw new Mi;return q.number}),Ee(),d);else{const q=await s();T=n.storage$(A,"value",H=>{const G=v(H),W=m.length===G.len?m:m.slice(0,-1);if(m!==W&&!g)throw p(m);if(!u(q,H,W))throw h();return G.enc(...W)},null,(H,G)=>{const W=v(G),Se=H===null?W.fallback:W.dec(H);if(!a(q,G,Se))throw h();return Se})}return cr(T,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=ar(S),{signal:x,at:E}=g?S:{},A=E??null,T=await s(),q=n.storage$(A,"descendantsValues",H=>{const G=v(H);if(ts(i(T,H))===Be.Incompatible)throw h();if(m.length>G.len)throw p(m);const W=m.length>0&&g?m.slice(0,-1):m;if(m.length===G.len&&W===m)throw p(m);return G.enc(...W)},null,(H,G)=>{const W=v(G),Se=H.map(({key:et,value:zt})=>({keyArgs:W.keyDecoder(et),value:W.dec(zt)}));if(Se.some(({value:et})=>!a(T,G,et)))throw h();return Se});return cr(q,x)},watchValue:y}},Xl=gt(V.enc,e=>+!!e.signed<<7|e.version),ur=()=>new Error("Unkown signer"),Gl=e=>{const{extrinsic:t}=e,n=Fi(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 ur()}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 ur();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 ur()},Kl={Ed25519:0,Sr25519:1,Ecdsa:2},Yl=(e,t,n,r,o,i)=>{const[s,c]=Gl(e),u=ue(Xl({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([Kl[i],...n]),...r,o);return ue(j.enc(u.length),u)},[Sn,Dt]=["<Bytes>","</Bytes>"].map(e=>Ue.fromText(e).asBytes()),Zl=e=>async t=>{let n=!0,r;for(r=0;n&&r<Sn.length;r++)n=Sn[r]===t[r];n=n&&r===Sn.length;const o=t.length-Dt.length;for(r=0;n&&r<Dt.length;r++)n=Dt[r]===t[o+r];return n=n&&r===Dt.length,e(n?t:ue(Sn,t,Dt))};function Jl(e,t,n){return{publicKey:e,signTx:async(o,i,s,c,u=Ct)=>{let a;try{const p=Bo(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=[],f=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=i[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),f.push(v.additionalSigned)});const d=ue(o,...l,...f),h=await n(d.length>256?u(d):d);return Yl(a,e,h,l,o,t)},signBytes:Zl(n)}}const ze=new Uint8Array,os=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=>ye(r)))},is=(e,t)=>{const n=qi(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 re(s(i(r.value)[e]))},Ql=e=>re({value:eo.enc(e),additionalSigned:ze});function Nl(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const ef=gt(Y(2).enc,e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Nl(e.period)-1,1),15),r=e.phase/t<<4;return Fe.enc(n|r)}),tf=new Uint8Array([0]),nf=(e,t)=>{if(!e)return os(t).pipe(I(o=>({additionalSigned:o,value:tf})));const{period:n,blockNumber:r}=e;return re({additionalSigned:ye(t.at),value:ef({period:n,phase:r%n})})},rf=O({tip:j,asset:ee(Y(1/0))}).enc,of=(e,t)=>re({value:rf({tip:e,asset:t}),additionalSigned:ze}),sf=e=>os(e).pipe(I(t=>({value:ze,additionalSigned:t}))),cf=()=>re({value:Uint8Array.from([0]),additionalSigned:Uint8Array.from([0])}),ss="AccountNonceApi_account_nonce",af={1:V.dec,2:Fe.dec,4:ke.dec,8:wt.dec},lr=e=>re({value:j.enc(e),additionalSigned:ze});var uf=Object.freeze({__proto__:null,CheckGenesis:sf,CheckMetadataHash:cf,CheckNonce:e=>e.chainHead.call$(e.at,ss,te(e.from)).pipe(D(t=>{const n=ye(t),r=af[n.length];if(!r)throw new Error(`${ss} retrieved wrong data`);return lr(r(n))})),CheckSpecVersion:({lookupFn:e})=>is("spec_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),CheckTxVersion:({lookupFn:e})=>is("transaction_version",e).pipe(I(t=>({additionalSigned:t,value:ze}))),getNonce:lr});const lf=re({value:ze,additionalSigned:ze}),cs=(e,t,n)=>{if(!(t in e))return ze;const r=e[t];return r instanceof Uint8Array?r:n(r)},ff=(e,t,n)=>re({value:cs(e,"value",t),additionalSigned:cs(e,"additionalSigned",n)}),df=(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 bn(Object.fromEntries(s.lookup.metadata.extrinsic.signedExtensions.map(({identifier:a,type:l,additionalSigned:f})=>[a,(()=>{if(a==="CheckMortality")return nf(u,c);if(a==="ChargeTransactionPayment")return Ql(i.tip??0n);if(a==="ChargeAssetTxPayment")return of(i.tip??0n,i.asset);if(a==="CheckNonce"&&"nonce"in i)return lr(i.nonce);const d=uf[a],[h]=s.dynamicBuilder.buildDefinition(l),[p]=s.dynamicBuilder.buildDefinition(f);return d?d(c):h===_[0]&&p===_[0]?lf:a in o?ff(o[a],h,p):null})()]).filter(a=>a[1]))).pipe(D(a=>t.signTx(n,Zt(a,(l,f)=>({identifier:f,...l})),s.metadataRaw,r.number)))}));var hf=Object.defineProperty,pf=(e,t,n)=>t in e?hf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vf=(e,t,n)=>pf(e,t+"",n);const yf=e=>te(Ct(ye(e))),bf=(e,t)=>new $(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 h=o.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const f=l<=o.blocks.get(o.finalized).number,d=a.found.type;if(d&&i?.found&&i.hash===a.hash){f&&n.complete();return}n.next(i=a.found.type?{found:d,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:d,validity:a.found.validity}),f&&(d?n.complete():a.found.validity?.success===!1&&n.error(new fr(a.found.validity.value)))},c=t.pipe(Ee((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(Ee((n,r)=>n===r)),mf=(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 fr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Ue?r.asHex():r,2)),vf(this,"error"),this.name="InvalidTxError",this.error=t}}const dr=(e,t,n,r,o=!1)=>{const i=yf(n),s=(l,f)=>({type:l,txHash:i,...f}),c=e.pinnedBlocks$.pipe(_e(1),I(l=>{const f=l.blocks.get(r);return f&&!f.unpinned?f.hash:l.finalized})).pipe(D(l=>e.validateTx$(l,n).pipe(Qe(f=>!f.success),I(f=>{throw new fr(f.value)})))),u=new $(l=>{const f=e.trackTx$(n).subscribe(l);return f.add(t(n).subscribe({error(d){l.error(d)}})),f}),a=bf(u,e.pinnedBlocks$).pipe(I(l=>l.found?s("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...mf(l.events,l.index)}):s("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return Hu(o?re(s("signed",{})):Ut,c,re(s("broadcasted",{})),a.pipe(Vl(({found:l,type:f,...d})=>l?re(s("finalized",d)):Ut)))},as=async(e,t,n,r)=>Au(dr(e,t,n,r)).then(o=>{if(o.type!=="finalized")throw null;const i={...o};return delete i.type,i}),gf=rt().enc,wf=new Uint8Array(64),kf=new Uint8Array(65),xf=e=>()=>e?kf:wf,us=(e,t,n,r,{isCompatible:o,getCompatibilityLevel:i,compatibleRuntime$:s,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const f=(g,x,E={})=>{const A=ir(g).runtime(),{dynamicBuilder:T,assetId:q,lookup:H}=A;let G;try{G=T.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 W=E;if(E.asset){if(q==null||!jn(E.asset,Tt(H(q)),zt=>u(A,zt)))throw new Error("Incompatible runtime asset");W={...E,asset:T.buildDefinition(q).enc(E.asset)}}const{location:Se,codec:et}=G;return{callData:Ue.fromBytes(ue(new Uint8Array(Se),et.enc(x))),options:W}},d=(g,x={})=>s(n,null).pipe(I(([E])=>f(E,g,x))),h=g=>g?f(g,l).callData:xe(d(l).pipe(I(x=>x.callData))),p=(g,{...x},E)=>d(l,x).pipe(D(({callData:A,options:T})=>df(n,g,A.asBytes(),E,x.customSignedExtensions||{},T))),v=(g,{at:x,...E}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(A=>A.find(T=>T.hash===x)))).pipe(_e(1),D(A=>A?p(g,E,A).pipe(I(T=>({tx:te(T),block:A}))):yn(()=>new Error(`Uknown block ${x}`)))),y=(g,x)=>xe(v(g,x)).then(E=>E.tx),b=(g,x)=>xe(v(g,x)).then(({tx:E,block:A})=>as(n,r,E,A.hash)),m=(g,x)=>v(g,x).pipe(D(({tx:E,block:A})=>dr(n,r,E,A.hash,!0))),S=async(g,x)=>{typeof g=="string"&&(g=g.startsWith("0x")?ye(g):gf(g));const E=g.length===20,A=Jl(g,E?"Ecdsa":"Sr25519",xf(E)),T=ye(await y(A,x)),q=te(ue(T,ke.enc(T.length))),H=n.getRuntimeContext$(null).pipe(I(W=>W.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1])),G=n.call$(null,"TransactionPaymentApi_query_info",q);return xe(bn([G,H]).pipe(I(([W,Se])=>Se(W))))};return{getPaymentInfo:S,getEstimatedFees:async(g,x)=>(await S(g,x)).partial_fee,decodedCall:{type:e,value:Bt(t,l)},getEncodedData:h,sign:y,signSubmitAndWatch:m,signAndSubmit:b}},{getCompatibilityLevel:i,isCompatible:o}),ls=(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)=>Wl(p,v,t,bt(e,y=>y.getPalletEntryPoint(yt.Storage,p,v),y=>Ba(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=Ca(m.value[b]);return{args:v==="args"?S:nn,values:v==="args"?nn:S}},a=i((p,v)=>us(p,v,t,n,bt(e,y=>y.getPalletEntryPoint(yt.Tx,p,v),y=>u(y,"args",s(y,p).calls,v)),!0)),l=i((p,v)=>jl(p,v,t,bt(e,y=>y.getPalletEntryPoint(yt.Event,p,v),y=>u(y,"values",s(y,p).events,v)))),f=i((p,v)=>Dl(p,v,bt(e,y=>y.getPalletEntryPoint(yt.Const,p,v),y=>Oa(s(y,p).constants.find(b=>b.name===v).type)))),d=i((p,v)=>ql(p,v,t,bt(e,y=>y.getApiEntryPoint(p,v),y=>_a(y.lookup.metadata.apis.find(b=>b.name===p).methods.find(b=>b.name===v))))),h=(p,v)=>{const{lookup:y,dynamicBuilder:b}=ir(v).runtime();try{const m=b.buildDefinition(y.call).dec(p.asBytes()),S=m.type,g=m.value.type,x=m.value.value;return us(S,g,t,n,bt(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,v)=>v?h(p,v):e.then(y=>h(p,y)),tx:a,event:l,apis:d,constants:f}};function Ef(e){const t=Xa(e),n=Tl(t),r=n.chainHead$(),{getChainSpecData:o}=t,i=t.request;let s;const c=new WeakMap,u=f=>{const d=c.get(f)||Rl(f,r);return c.set(f,d),d},a=()=>s??(s=Ml(r)),{broadcastTx$:l}=n;return{getChainSpecData:o,finalizedBlock$:r.finalized$,getFinalizedBlock:()=>xe(r.finalized$),bestBlocks$:r.bestBlocks$,getBestBlocks:()=>xe(r.bestBlocks$),watchBlockBody:r.body$,getBlockBody:f=>xe(r.body$(f)),getBlockHeader:f=>xe(r.header$(f??null)),submit:(...f)=>as(r,l,...f),submitAndWatch:(...f)=>dr(r,l,...f),getTypedApi:f=>{const d=u(f);return Object.assign(ls(d,r,l),{compatibilityToken:d})},getUnsafeApi:()=>{const f=a();return Object.assign(ls(f,r,l),{runtimeToken:f})},destroy:()=>{r.unfollow(),n.destroy()},_request:i}}ve.AccountId=rt,ve.Binary=Ue,ve.CompatibilityLevel=Be,ve.Enum=Bt,ve.FixedSizeBinary=Tn,ve.InvalidTxError=fr,ve._Enum=so,ve.createClient=Ef,ve.getSs58AddressInfo=On});
@@ -1 +1 @@
1
- (function(we,ge){typeof exports=="object"&&typeof module<"u"?ge(exports):typeof define=="function"&&define.amd?define(["exports"],ge):(we=typeof globalThis<"u"?globalThis:we||self,ge(we.papiInk={}))})(this,function(we){"use strict";const ge=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Vn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=a(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(a=>{const d=t(e[a]);if(d)return d;const{def:h,path:u,params:y}=e[a];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&ge(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&ge(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const I=E.name;if(b[I]=E.docs,E.fields.length===0){p[I]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[I]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[I]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?l(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=a=>{let d=!0;const h={},u={};return a.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,d)=>{if(a.every(h=>h.id===a[0].id)&&d.every(h=>!h.length)){const[h]=a;return h.type==="void"?le:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:d}};return i},Mn=e=>Vn(e);var jn=Object.defineProperty,Pn=(e,t,n)=>t in e?jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(Pn(e,typeof t!="symbol"?t+"":t,n),n),Ke={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 Nn(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=i<<4|f}return s}var ut=class extends Uint8Array{constructor(e){super(e),lt(this,"i",0),lt(this,"v"),this.v=new DataView(e)}},q=e=>t=>e(t instanceof ut?t:new ut(t instanceof Uint8Array?t.buffer:typeof t=="string"?Nn(t).buffer:t)),X=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var We=q,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ge=(e,t)=>n=>e(t(n)),Se=(e,t)=>n=>t(e(n)),R=([e,t],n,r)=>x(Ge(e,n),Se(t,r));function qn(e,t){return q(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Rn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function ee(e,t,n){return x(Rn(e,n),qn(e,t))}var U=ee(1,"getUint8","setUint8"),me=ee(2,"getUint16","setUint16"),te=ee(4,"getUint32","setUint32"),$e=ee(8,"getBigUint64","setBigUint64"),Fn=ee(1,"getInt8","setInt8"),Xn=ee(2,"getInt16","setInt16"),zn=ee(4,"getInt32","setInt32"),Kn=ee(8,"getBigInt64","setBigInt64"),ht=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},dt=e=>q(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),Wn=x(ht,dt("getBigUint64")),Gn=x(ht,dt("getBigInt64")),ft=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},yt=e=>q(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}),Yn=x(ft,yt("getBigUint64")),Jn=x(ft,yt("getBigInt64")),Qn=R(U,e=>e?1:0,Boolean),Zn=[U[1],me[1],te[1]],er=q(e=>{const t=e[e.i],n=t&3;if(n<3)return Zn[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let f=0;f<o;f++)s=$e[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(te[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(U[1](e))<<c|s),s}),tr=1n<<56n,nr=1<<24,rr=256,sr=4294967295n,or=64,cr=16384,ir=1<<30,ar=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<or)return U[0](t);if(e<cr)return me[0](t|1);if(e<ir)return te[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=tr;)n.push($e[0](r)),r>>=64n;r>=nr&&(n.push(te[0](Number(r&sr))),r>>=32n);let s=Number(r);s>=rr&&(n.push(me[0](s)),s>>=16),s&&n.push(U[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},T=x(ar,er),lr=new TextEncoder,ur=e=>{const t=lr.encode(e);return X([T.enc(t.length),t])},hr=new TextDecoder,dr=q(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,hr.decode(n)}),O=x(ur,dr),fr=()=>{},yr=new Uint8Array(0),m=x(()=>yr,fr),pt=e=>e===void 0?t=>X([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),gt=e=>q(t=>{const n=e===void 0?T.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}),$=e=>x(pt(e),gt(e));$.enc=pt,$.dec=gt;var bt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>X([U.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return q(s=>{const o=U.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(bt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));F.enc=bt,F.dec=wt;var mt=e=>q(t=>U[1](t)>0?e(t):void 0),vt=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(vt(e[0]),mt(e[1]));P.enc=vt,P.dec=mt;var Et=(e,t)=>q(n=>{const r=U[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),kt=(e,t)=>({success:n,value:r})=>X([U[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(kt(e[0],t[0]),Et(e[1],t[1]));De.dec=Et,De.enc=kt;var xt=(...e)=>q(t=>e.map(n=>n(t))),Bt=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(Bt(...e.map(([t])=>t)),xt(...e.map(([,t])=>t)));z.enc=Bt,z.dec=xt;var It=e=>{const t=Object.keys(e);return Ge(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},At=e=>{const t=Object.keys(e);return Se(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(It(Le(e,t=>t[0])),At(Le(e,t=>t[1])));v.enc=It,v.dec=At;var Ot=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([T.enc(n.length),X(n.map(e))]),_t=(e,t)=>q(n=>{const r=t>=0?t:T.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>x(Ot(e[0],t),_t(e[1],t));B.enc=Ot,B.dec=_t;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function gr(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function br(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 wr(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 Ut(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 s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,i=!0;for(let f=r;f<o.length;f++){const l=o[f],a=t*c+l;if(!Number.isSafeInteger(a)||t*c/t!==c||a-l!==t*c)throw new Error("convertRadix: carry overflow");c=a%n;const d=Math.floor(a/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==a)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function mr(e){return{encode:t=>{if(!pr(t))throw new Error("radix.encode input should be Uint8Array");return Ut(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(Ut(t,e,2**8))}}}const Lt=(e=>gr(mr(58),br(e),wr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function vr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Te(e,...t){if(!vr(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 ve(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 Ye(e,t){Te(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 Er=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Ce=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,St=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,K=C?e=>e:e=>St(e);function H(e){for(let t=0;t<e.length;t++)e[t]=St(e[t])}function kr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=kr(e)),Te(e),e}class $t{clone(){return this._cloneInto()}}function xr(e){const t=r=>e().update(W(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Br(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ir(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ar=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 Dt extends $t{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ue(t),ue(n),ue(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=he(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=W(t);const o=t.length,c=t.byteOffset,i=t.buffer;for(let f=0;f<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const l=Math.min(n-this.pos,o-f),a=c+f;if(l===n&&!(a%4)&&f+l<o){const d=new Uint32Array(i,a,Math.floor((o-f)/4));C||H(d);for(let h=0;f+n<o;h+=s.length,f+=n)this.length+=n,this.compress(d,h,!1);C||H(d);continue}r.set(t.subarray(f,f+l),this.pos),this.pos+=l,this.length+=l,f+=l}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=he(t);this.get().forEach((o,c)=>s[c]=K(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:i}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=i,t}}const He=BigInt(2**32-1),Je=BigInt(32);function Ve(e,t=!1){return t?{h:Number(e&He),l:Number(e>>Je&He)}:{h:Number(e>>Je&He)|0,l:Number(e&He)|0}}function Tt(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=Ve(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const Or=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),_r=(e,t,n)=>e>>>n,Ur=(e,t,n)=>e<<32-n|t>>>n,Lr=(e,t,n)=>e>>>n|t<<32-n,Sr=(e,t,n)=>e<<32-n|t>>>n,$r=(e,t,n)=>e<<64-n|t>>>n-32,Dr=(e,t,n)=>e>>>n-32|t<<64-n,Tr=(e,t)=>t,Cr=(e,t)=>e,Ct=(e,t,n)=>e<<n|t>>>32-n,Ht=(e,t,n)=>t<<n|e>>>32-n,Vt=(e,t,n)=>t<<n-32|e>>>64-n,Mt=(e,t,n)=>e<<n-32|t>>>64-n;function Hr(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const V={fromBig:Ve,split:Tt,toBig:Or,shrSH:_r,shrSL:Ur,rotrSH:Lr,rotrSL:Sr,rotrBH:$r,rotrBL:Dr,rotr32H:Tr,rotr32L:Cr,rotlSH:Ct,rotlSL:Ht,rotlBH:Vt,rotlBL:Mt,add:Hr,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,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},_=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function ne(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotr32H(p,y),Dl:V.rotr32L(p,y)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrSH(d,a,24),Bl:V.rotrSL(d,a,24)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function re(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotrSH(p,y,16),Dl:V.rotrSL(p,y,16)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrBH(d,a,63),Bl:V.rotrBL(d,a,63)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}class Vr extends Dt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=_[0]|0,this.v0h=_[1]|0,this.v1l=_[2]|0,this.v1h=_[3]|0,this.v2l=_[4]|0,this.v2h=_[5]|0,this.v3l=_[6]|0,this.v3h=_[7]|0,this.v4l=_[8]|0,this.v4h=_[9]|0,this.v5l=_[10]|0,this.v5h=_[11]|0,this.v6l=_[12]|0,this.v6h=_[13]|0,this.v7l=_[14]|0,this.v7h=_[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=he(W(t.salt));this.v4l^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(W(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:f,v4l:l,v4h:a,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=f|0,this.v4l=l|0,this.v4h=a|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,l)=>g[l]=f),g.set(_,16);let{h:s,l:o}=V.fromBig(BigInt(this.length));g[24]=_[8]^o,g[25]=_[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=Ar;for(let f=0;f<12;f++)ne(0,4,8,12,t,n+2*i[c++]),re(0,4,8,12,t,n+2*i[c++]),ne(1,5,9,13,t,n+2*i[c++]),re(1,5,9,13,t,n+2*i[c++]),ne(2,6,10,14,t,n+2*i[c++]),re(2,6,10,14,t,n+2*i[c++]),ne(3,7,11,15,t,n+2*i[c++]),re(3,7,11,15,t,n+2*i[c++]),ne(0,5,10,15,t,n+2*i[c++]),re(0,5,10,15,t,n+2*i[c++]),ne(1,6,11,12,t,n+2*i[c++]),re(1,6,11,12,t,n+2*i[c++]),ne(2,7,8,13,t,n+2*i[c++]),re(2,7,8,13,t,n+2*i[c++]),ne(3,4,9,14,t,n+2*i[c++]),re(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],g.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 Me=Br(e=>new Vr(e)),jt=new TextEncoder().encode("SS58PRE"),Qe=2,Pt=e=>{try{const t=Lt.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Me(Uint8Array.of(...jt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Mr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Mr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Nt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Me(Uint8Array.of(...jt,...t,...n),{dkLen:64}).subarray(0,Qe);return Lt.encode(Uint8Array.of(...t,...n,...r))}};function jr(e,t){return n=>{const r=Pt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const Ze=(e=42,t=32)=>R($(t),jr(t),Nt(e)),qt="0123456789abcdef";function G(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=qt[r>>4]+qt[r&15]}return t.join("")}const et={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 Ee(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=et[e[c]],f=et[e[c+1]];s[t+o++]=i<<4|f}return s}function Rt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const be=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n};var Pr=Object.defineProperty,Ft=e=>{throw TypeError(e)},Nr=(e,t,n)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>Nr(e,typeof t!="symbol"?t+"":t,n),Xt=(e,t,n)=>t.has(e)||Ft("Cannot "+n),Y=(e,t,n)=>(Xt(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),de=(e,t,n,r)=>(Xt(e,t,"write to private field"),t.set(e,n),n),J,Be,je,Pe,Ne;const qr=new TextEncoder,Rr=new TextDecoder,Fr=z(T,$(1/0))[1];class se{constructor(t,n=!1){if(xe(this,J),xe(this,Be,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>Y(this,Ne)??de(this,Ne,Rr.decode(Y(this,J)))),ke(this,"asHex",()=>Y(this,je)||de(this,je,G(Y(this,J)))),ke(this,"asOpaqueHex",()=>Y(this,Pe)||de(this,Pe,G(this.asBytes()))),ke(this,"asBytes",()=>Y(this,J)),ke(this,"asOpaqueBytes",()=>Y(this,Be)||de(this,Be,be(T[0](Y(this,J).length),Y(this,J)))),n){try{const[r,s]=Fr(t);if(r===s.length){de(this,J,s),de(this,Be,t);return}}catch{}throw new Error("Invalid opaque bytes")}else de(this,J,t)}static fromText(t){return new this(qr.encode(t))}static fromHex(t){return new this(Ee(t))}static fromOpaqueHex(t){return new this(Ee(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}J=new WeakMap,Be=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[Xr]=Ze();class zt extends se{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Xr(t))}}const Kt=e=>{const t=$.enc(e);return n=>t(n.asBytes())},Wt=e=>{const t=$.dec(e),n=e==null?se:zt;return r=>n.fromBytes(t(r))},Ie=e=>x(Kt(e),Wt(e));Ie.enc=Kt,Ie.dec=Wt;const w=T,zr=T,Kr=We(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:$(n).dec(e),bitsLen:t}}),Gt=x(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Kr),Wr=R(U,e=>e.charCodeAt(0),String.fromCharCode),Yt=e=>{const t=$.enc(e);return n=>t(Ee(n))},Jt=e=>{const t=$.dec(e);return n=>G(t(n))},oe=e=>x(Yt(e),Jt(e));oe.enc=Yt,oe.dec=Jt;const Gr=new TextEncoder,Yr=new TextDecoder,Jr=e=>R($(e),t=>Gr.encode(t),t=>Yr.decode(t)),Qt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Zt=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},en=e=>x(Qt(()=>e().enc),Zt(()=>e().dec)),tt=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}}),Qr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),tn=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},nn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},fe=(e,...t)=>x(tn(Rt(e,([n])=>n),...t),nn(Rt(e,([,n])=>n),...t));fe.enc=tn,fe.dec=nn;const rn=[],sn=[],on=[],Zr=BigInt(0),Ae=BigInt(1),es=BigInt(2),ts=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let e=0,t=Ae,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],rn.push(2*(5*r+n)),sn.push((e+1)*(e+2)/2%64);let s=Zr;for(let o=0;o<7;o++)t=(t<<Ae^(t>>ts)*rs)%ns,t&es&&(s^=Ae<<(Ae<<BigInt(o))-Ae);on.push(s)}const[ss,os]=Tt(on,!0),cn=(e,t,n)=>n>32?Vt(e,t,n):Ct(e,t,n),an=(e,t,n)=>n>32?Mt(e,t,n):Ht(e,t,n);function cs(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,f=(c+2)%10,l=n[f],a=n[f+1],d=cn(l,a,1)^n[i],h=an(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=sn[c],f=cn(s,o,i),l=an(s,o,i),a=rn[c];s=e[a],o=e[a+1],e[a]=f,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=ss[r],e[1]^=os[r]}n.fill(0)}class nt extends $t{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ue(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=he(this.state)}keccak(){C||H(this.state32),cs(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=W(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const is=((e,t,n)=>xr(()=>new nt(t,e,n)))(1,136,256/8),ln=e=>{const t=e.slice(2),n=G(is(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},as=$(20)[1],un=x(e=>{const t=Ee(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=G(t);if(e===n||e===n.toUpperCase())return t;if(ln(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},We(e=>ln(G(as(e))))),hn=new TextEncoder,dn=new TextDecoder,ls=R($(4),hn.encode.bind(hn),dn.decode.bind(dn)),rt=v({engine:ls,payload:oe()}),us=fe({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:m},[4,5,6,8]),st=oe(32),hs=v({parentHash:st,number:w,stateRoot:st,extrinsicRoot:st,digests:B(us)}),Q=B(O),fn=P(O),ds=F({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m}),yn=B(v({name:fn,type:w,typeName:fn,docs:Q})),fs=v({len:te,type:w}),ys=v({bitStoreType:w,bitOrderType:w}),ps=B(v({name:O,fields:yn,index:U,docs:Q})),gs=F({composite:yn,variant:ps,sequence:w,array:fs,tuple:B(w),primitive:ds,compact:w,bitSequence:ys}),bs=v({name:O,type:P(w)}),ws=B(bs),ms=v({id:w,path:Q,params:ws,def:gs,docs:Q}),qe=B(ms),vs=F({Blake2128:m,Blake2256:m,Blake2128Concat:m,Twox128:m,Twox256:m,Twox64Concat:m,Identity:m}),Es=B(vs),ks=v({hashers:Es,key:w,value:w}),xs=v({name:O,modifier:U,type:F({plain:w,map:ks}),fallback:oe(),docs:Q}),Bs=P(v({prefix:O,items:B(xs)})),pn={name:O,storage:Bs,calls:P(w),events:P(w),constants:B(v({name:O,type:w,value:oe(),docs:Q})),errors:P(w),index:U},Is={...pn,docs:Q},As=new Uint8Array,gn=e=>x(()=>As,()=>e),Os=v({type:w,version:U,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),bn=v({lookup:qe,pallets:B(v({...pn,docs:gn([])})),extrinsic:Os,type:w,apis:gn([])}),_s=v({name:O,methods:B(v({name:O,inputs:B(v({name:O,type:w})),output:w,docs:Q})),docs:Q}),Us=v({version:U,address:w,call:w,signature:w,extra:w,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),wn=v({lookup:qe,pallets:B(v(Is)),extrinsic:Us,type:w,apis:B(_s),outerEnums:v({call:w,event:w,error:w}),custom:B(z(O,v({type:w,value:oe()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},M=x(mn,mn),Oe=v({magicNumber:te,metadata:F({v0:M,v1:M,v2:M,v3:M,v4:M,v5:M,v6:M,v7:M,v8:M,v9:M,v10:M,v11:M,v12:M,v13:M,v14:bn,v15:wn})}),ot=$(),Ls=P(ot),Ss=z(T,ot),$s=e=>{try{return Oe.dec(e)}catch{}try{return Oe.dec(Ls.dec(e))}catch{}try{return Oe.dec(ot.dec(e))}catch{}try{return Oe.dec(Ss.dec(e)[1])}catch{}throw null},Ds={dkLen:32},vn=e=>Me(e,Ds),Ts={dkLen:16},ct=e=>Me(e,Ts),En=e=>be(ct(e),e),Z=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,16),n=n+r|0,t=Ce(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,8),n=n+r|0,t=Ce(t^n,7),{a:e,b:t,c:n,d:r}}function kn(e,t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b,E,I,j){let A=0;for(let pe=0;pe<r;pe++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[A++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ce(o,l,u,E,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ie(o,l,u,E,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ce(c,a,y,I,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ie(c,a,y,I,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ce(s,l,y,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ie(s,l,y,j,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ce(o,a,p,b,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ie(o,a,p,b,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ce(i,f,u,I,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ie(i,f,u,I,n[t+e[A++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:l,v6:a,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:I,v15:j}}const xn=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class it extends Dt{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,ue(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=W(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=he(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new it({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=Z.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Er(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=Ve(BigInt(t),!0),{v0:l,v1:a,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:I,v10:j,v11:A,v12:pe,v13:Xe,v14:ze,v15:lo}=kn(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Z[0],Z[1],Z[2],Z[3],i,f,c,n);o[0]=l^E,o[1]=a^I,o[2]=d^j,o[3]=h^A,o[4]=u^pe,o[5]=y^Xe,o[6]=p^ze,o[7]=b^lo}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:i,stack:f,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=f.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,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:s,bufferOut32:o}=this,{h:c,l:i}=Ve(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:l,v2:a,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:I,v11:j,v12:A,v13:pe,v14:Xe,v15:ze}=kn(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Z[0],Z[1],Z[2],Z[3],i,c,n,r);o[0]=f^b,o[1]=l^E,o[2]=a^I,o[3]=d^j,o[4]=h^A,o[5]=u^pe,o[6]=y^Xe,o[7]=p^ze,o[8]=t[0]^b,o[9]=t[1]^E,o[10]=t[2]^I,o[11]=t[3]^j,o[12]=t[4]^A,o[13]=t[5]^pe,o[14]=t[6]^Xe,o[15]=t[7]^ze,C||(H(s),H(o)),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,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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 Cs=Ir(e=>new it(e)),Hs={dkLen:32},Bn=e=>Cs(e,Hs),Vs=e=>be(Bn(e),e),In=e=>e,ye=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),at=2n**64n-1n,D=(e,t)=>e<<t&at|e>>64n-t,k=(e,t)=>e*t&at,L=(e,t)=>e+t&at,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,_e=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=L(L(t,S),N),r=L(t,N),s=t,o=t-S,c=e.length,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=k(D(L(n,k(b,N)),31n),S),u+=8,b=ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=k(D(L(r,k(b,N)),31n),S),u+=8,b=ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=k(D(L(s,k(b,N)),31n),S),u+=8,b=ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=k(D(L(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let l,a=0;for(c>=32?(l=D(n,1n),l=L(l,D(r,7n)),l=L(l,D(s,12n)),l=L(l,D(o,18n)),n=k(D(k(n,N),31n),S),l=l^n,l=L(k(l,S),_e),r=k(D(k(r,N),31n),S),l=l^r,l=L(k(l,S),_e),s=k(D(k(s,N),31n),S),l=l^s,l=L(k(l,S),_e),o=k(D(k(o,N),31n),S),l=l^o,l=L(k(l,S),_e)):l=L(t,On),l=L(l,BigInt(c));a<=i-8;){let h=ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=k(D(k(h,N),31n),S),l=L(k(D(l^h,27n),S),_e),a+=8}if(a+4<=i){let h=k(ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),S);l=L(k(D(l^h,23n),N),An),a+=4}for(;a<i;){const h=k(ye(e[a++],0,0,0),On);l=k(D(l^h,11n),S)}let d=l>>33n;return l=k(l^d,N),d=l>>29n,l=k(l^d,An),d=l>>32n,l^=d,l}const Re=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),t},_n=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),n.setBigUint64(16,ae(e,2n),!0),n.setBigUint64(24,ae(e,3n),!0),t},Un=e=>be($e.enc(ae(e)),e),Ln=new TextEncoder,Ms=new Map([[In,0],[Un,8],[En,16],[ct,-16],[vn,-32],[Re,-16],[_n,-32]]);var js=Object.freeze({__proto__:null,AccountId:Ze,Bin:Ie,Binary:se,Blake2128:ct,Blake2128Concat:En,Blake2256:vn,Blake3256:Bn,Blake3256Concat:Vs,Bytes:$,Enum:tt,FixedSizeBinary:zt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:F,Self:en,Storage:e=>{const t=Re(Ln.encode(e));return(n,r,...s)=>{const o=be(t,Re(Ln.encode(n))),c=G(o),i=a=>{if(!a.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Ee(a.slice(c.length)),h=new Array(s.length);for(let u=0,y=0;u<s.length;u++){const[p,b]=s[u],E=Ms.get(b);if(E==null)throw new Error("Unknown hasher");if(E<0){const I=E*-1;h[u]=G(d.slice(y,y+I)),y+=I}else y+=E,h[u]=p.dec(d.slice(y)),y+=p.enc(h[u]).length}return h},f=s.map(([{enc:a},d])=>h=>d(a(h)));return{enc:(...a)=>G(be(o,...a.map((d,h)=>f[h](d)))),dec:r,keyDecoder:i}}},Struct:v,Tuple:z,Twox128:Re,Twox256:_n,Twox64Concat:Un,Variant:fe,Vector:B,_Enum:Qr,_void:m,bitSequence:Gt,blockHeader:hs,bool:Qn,char:Wr,compact:T,compactBn:zr,compactNumber:w,createCodec:x,createDecoder:We,decAnyMetadata:$s,enhanceCodec:R,enhanceDecoder:Se,enhanceEncoder:Ge,ethAccount:un,fixedStr:Jr,fromBufferToBase58:Nt,getSs58AddressInfo:Pt,h64:ae,i128:Gn,i16:Xn,i256:Jn,i32:zn,i64:Kn,i8:Fn,metadata:Oe,selfDecoder:Zt,selfEncoder:Qt,str:O,u128:Wn,u16:me,u256:Yn,u32:te,u64:$e,u8:U,v14:bn,v14Lookup:qe,v15:wn});const Ps=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Ns=Ie(),qs=x(T[0],Se(T[1],BigInt)),Sn=Ps((e,t,n,r)=>{if(e.type==="primitive")return js[e.value];if(e.type==="void")return m;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return un;if(e.type==="compact")return e.isBig?qs:T;if(e.type==="bitSequence")return Gt;const s=u=>Sn(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Ns;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ie(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(u=>{switch(u.type){case"void":return m;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,y)=>u===y)?fe(l):fe(l,a);return e.byteLength?Fs(h,e.byteLength):h},en,e=>e),Rs=(e,t=Ze())=>{const n=new Map,r=s=>Sn(e(s),n,new Set,t);return s=>r(s)},Fs=(e,t)=>{const n=$(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Xs=e=>{const{metadata:t}=e,n=Rs(e),r=(a="")=>{const d=e.storage[a];if(!d)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=d.key==null?m:n(d.key);return{key:$n(h,d.keyPrefix),value:n(d.typeId)}},s=a=>{const d=v(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:$n(d,a.selector),value:n(a.returnType.type)}},o=a=>{const d=t.spec.constructors.find(h=>h.label===a);if(!d)throw new Error(`Constructor ${a} not found`);return s(d)},c=a=>{const d=t.spec.messages.find(h=>h.label===a);if(!d)throw new Error(`Message ${a} not found`);return s(d)},i=a=>v(Object.fromEntries(a.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>fe(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(a){const y=d.find(p=>p.signature_topic===a);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===a);return u.length?zs(u.map(y=>h(i(y),y.label))):null}}},$n=(e,t)=>{const n=se.fromHex(t).asBytes(),r=z($(n.length),e);return R(r,s=>[n,s],([,s])=>s)},zs=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Dn=e=>R(F(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Ue=(e,t)=>R(B(e,t),n=>n??[],n=>n),Tn=P(O),Fe=Ue(O),Ks=Dn({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m}),Cn=Ue(v({name:Tn,type:w,typeName:Tn,docs:Fe})),Ws=v({len:te,type:w}),Gs=v({bitStoreType:w,bitOrderType:w}),Ys=Ue(v({name:O,fields:Cn,index:U,docs:Fe})),Js=Dn({composite:v({fields:Cn}),variant:v({variants:Ys}),sequence:v({type:w}),array:Ws,tuple:B(w),primitive:Ks,compact:w,bitSequence:Gs}),Qs=v({name:O,type:P(w)}),Zs=Ue(Qs),eo=v({id:w,path:Fe,params:Zs,def:Js,docs:Fe}),to=R(eo,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),no=Ue(to),ro=e=>{const t=no.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=so(e,n),c=Mn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function so(e,t){const n={},r=(s,o=[])=>{function c(f){const l=t.length;return t[l]={id:l,docs:[],def:f,params:[],path:[]},l}if("root"in s){const f=Number(e.version)===4?se.fromBytes(se.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){a(y.get("len"),[...h,"len"]),a(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,l)=>({name:f.name,fields:f.fields.map(a=>({name:a.name,type:r(a.layout,[...o,f.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const oo=e=>{const t=ro(e.metadata),n=Xs(t);return{constructor:Hn(n.buildConstructor),message:Hn(n.buildMessage),storage:co(n.buildStorage),event:Number(t.metadata.version)===4?io(n.buildEvents):ao(t,n.buildEvent)}},Hn=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},co=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},io=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},ao=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(l=>"event"in l?l:{event:l,topics:l.topics}).filter(l=>l.event.type==="Contracts"&&l.event.value.type==="ContractEmitted"&&l.event.value.value.contract===c).map(l=>{const a=l.topics.map(h=>h.asHex()),d=a.find(h=>n.has(h));try{return s(l.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:l.event.value.value.data.asHex(),eventTopics:a,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(l=>l!==null)}};we.getInkClient=oo});
1
+ (function(we,be){typeof exports=="object"&&typeof module<"u"?be(exports):typeof define=="function"&&define.amd?define(["exports"],be):(we=typeof globalThis<"u"?globalThis:we||self,be(we.papiInk={}))})(this,function(we){"use strict";const be=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Vn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=a(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(a=>{const d=t(e[a]);if(d)return d;const{def:h,path:u,params:y}=e[a];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&be(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&be(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const I=E.name;if(b[I]=E.docs,E.fields.length===0){p[I]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[I]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[I]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?l(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=a=>{let d=!0;const h={},u={};return a.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,d)=>{if(a.every(h=>h.id===a[0].id)&&d.every(h=>!h.length)){const[h]=a;return h.type==="void"?le:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:d}};return i},jn=e=>Vn(e);var Pn=Object.defineProperty,Nn=(e,t,n)=>t in e?Pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ut=(e,t,n)=>(Nn(e,typeof t!="symbol"?t+"":t,n),n),Ke={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 qn(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=i<<4|f}return s}var ht=class extends Uint8Array{constructor(e){super(e),ut(this,"i",0),ut(this,"v"),this.v=new DataView(e)}},q=e=>t=>e(t instanceof ht?t:new ht(t instanceof Uint8Array?t.buffer:typeof t=="string"?qn(t).buffer:t)),X=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var We=q,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ge=(e,t)=>n=>e(t(n)),Se=(e,t)=>n=>t(e(n)),R=([e,t],n,r)=>x(Ge(e,n),Se(t,r));function Rn(e,t){return q(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Fn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function te(e,t,n){return x(Fn(e,n),Rn(e,t))}var U=te(1,"getUint8","setUint8"),me=te(2,"getUint16","setUint16"),ne=te(4,"getUint32","setUint32"),$e=te(8,"getBigUint64","setBigUint64"),Xn=te(1,"getInt8","setInt8"),zn=te(2,"getInt16","setInt16"),Kn=te(4,"getInt32","setInt32"),Wn=te(8,"getBigInt64","setBigInt64"),dt=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ft=e=>q(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),Gn=x(dt,ft("getBigUint64")),Yn=x(dt,ft("getBigInt64")),yt=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},pt=e=>q(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}),Jn=x(yt,pt("getBigUint64")),Qn=x(yt,pt("getBigInt64")),Zn=R(U,e=>e?1:0,Boolean),er=[U[1],me[1],ne[1]],tr=q(e=>{const t=e[e.i],n=t&3;if(n<3)return er[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let f=0;f<o;f++)s=$e[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(ne[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(U[1](e))<<c|s),s}),nr=1n<<56n,rr=1<<24,sr=256,or=4294967295n,cr=64,ir=16384,ar=1<<30,lr=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<cr)return U[0](t);if(e<ir)return me[0](t|1);if(e<ar)return ne[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=nr;)n.push($e[0](r)),r>>=64n;r>=rr&&(n.push(ne[0](Number(r&or))),r>>=32n);let s=Number(r);s>=sr&&(n.push(me[0](s)),s>>=16),s&&n.push(U[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},$=x(lr,tr),ur=new TextEncoder,hr=e=>{const t=ur.encode(e);return X([$.enc(t.length),t])},dr=new TextDecoder,fr=q(e=>{let t=$.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,dr.decode(n)}),O=x(hr,fr),yr=()=>{},pr=new Uint8Array(0),w=x(()=>pr,yr),gt=e=>e===void 0?t=>X([$.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),bt=e=>q(t=>{const n=e===void 0?$.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}),D=e=>x(gt(e),bt(e));D.enc=gt,D.dec=bt;var mt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>X([U.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return q(s=>{const o=U.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(mt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));F.enc=mt,F.dec=wt;var vt=e=>q(t=>U[1](t)>0?e(t):void 0),Et=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(Et(e[0]),vt(e[1]));P.enc=Et,P.dec=vt;var kt=(e,t)=>q(n=>{const r=U[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),xt=(e,t)=>({success:n,value:r})=>X([U[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(xt(e[0],t[0]),kt(e[1],t[1]));De.dec=kt,De.enc=xt;var Bt=(...e)=>q(t=>e.map(n=>n(t))),It=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(It(...e.map(([t])=>t)),Bt(...e.map(([,t])=>t)));z.enc=It,z.dec=Bt;var At=e=>{const t=Object.keys(e);return Ge(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ot=e=>{const t=Object.keys(e);return Se(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(At(Le(e,t=>t[0])),Ot(Le(e,t=>t[1])));v.enc=At,v.dec=Ot;var _t=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([$.enc(n.length),X(n.map(e))]),Ut=(e,t)=>q(n=>{const r=t>=0?t:$.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>x(_t(e[0],t),Ut(e[1],t));B.enc=_t,B.dec=Ut;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function br(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function mr(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 wr(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 Lt(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 s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,i=!0;for(let f=r;f<o.length;f++){const l=o[f],a=t*c+l;if(!Number.isSafeInteger(a)||t*c/t!==c||a-l!==t*c)throw new Error("convertRadix: carry overflow");c=a%n;const d=Math.floor(a/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==a)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function vr(e){return{encode:t=>{if(!gr(t))throw new Error("radix.encode input should be Uint8Array");return Lt(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(Lt(t,e,2**8))}}}const St=(e=>br(vr(58),mr(e),wr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Er(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Te(e,...t){if(!Er(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 ve(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 Ye(e,t){Te(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 kr=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Ce=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,$t=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,K=C?e=>e:e=>$t(e);function H(e){for(let t=0;t<e.length;t++)e[t]=$t(e[t])}function xr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=xr(e)),Te(e),e}class Dt{clone(){return this._cloneInto()}}function Br(e){const t=r=>e().update(W(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ir(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Ar(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Or=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 Tt extends Dt{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ue(t),ue(n),ue(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=he(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=W(t);const o=t.length,c=t.byteOffset,i=t.buffer;for(let f=0;f<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const l=Math.min(n-this.pos,o-f),a=c+f;if(l===n&&!(a%4)&&f+l<o){const d=new Uint32Array(i,a,Math.floor((o-f)/4));C||H(d);for(let h=0;f+n<o;h+=s.length,f+=n)this.length+=n,this.compress(d,h,!1);C||H(d);continue}r.set(t.subarray(f,f+l),this.pos),this.pos+=l,this.length+=l,f+=l}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=he(t);this.get().forEach((o,c)=>s[c]=K(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:i}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=i,t}}const He=BigInt(2**32-1),Je=BigInt(32);function Me(e,t=!1){return t?{h:Number(e&He),l:Number(e>>Je&He)}:{h:Number(e>>Je&He)|0,l:Number(e&He)|0}}function Ct(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=Me(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const _r=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),Ur=(e,t,n)=>e>>>n,Lr=(e,t,n)=>e<<32-n|t>>>n,Sr=(e,t,n)=>e>>>n|t<<32-n,$r=(e,t,n)=>e<<32-n|t>>>n,Dr=(e,t,n)=>e<<64-n|t>>>n-32,Tr=(e,t,n)=>e>>>n-32|t<<64-n,Cr=(e,t)=>t,Hr=(e,t)=>e,Ht=(e,t,n)=>e<<n|t>>>32-n,Mt=(e,t,n)=>t<<n|e>>>32-n,Vt=(e,t,n)=>t<<n-32|e>>>64-n,jt=(e,t,n)=>e<<n-32|t>>>64-n;function Mr(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const M={fromBig:Me,split:Ct,toBig:_r,shrSH:Ur,shrSL:Lr,rotrSH:Sr,rotrSL:$r,rotrBH:Dr,rotrBL:Tr,rotr32H:Cr,rotr32L:Hr,rotlSH:Ht,rotlSL:Mt,rotlBH:Vt,rotlBL:jt,add:Mr,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,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},_=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function re(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=M.add3L(f,a,c);l=M.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:M.rotr32H(p,y),Dl:M.rotr32L(p,y)},{h:u,l:h}=M.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:M.rotrSH(d,a,24),Bl:M.rotrSL(d,a,24)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function se(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=M.add3L(f,a,c);l=M.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:M.rotrSH(p,y,16),Dl:M.rotrSL(p,y,16)},{h:u,l:h}=M.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:M.rotrBH(d,a,63),Bl:M.rotrBL(d,a,63)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}class Vr extends Tt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=_[0]|0,this.v0h=_[1]|0,this.v1l=_[2]|0,this.v1h=_[3]|0,this.v2l=_[4]|0,this.v2h=_[5]|0,this.v3l=_[6]|0,this.v3h=_[7]|0,this.v4l=_[8]|0,this.v4h=_[9]|0,this.v5l=_[10]|0,this.v5h=_[11]|0,this.v6l=_[12]|0,this.v6h=_[13]|0,this.v7l=_[14]|0,this.v7h=_[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=he(W(t.salt));this.v4l^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(W(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:i,v3h:f,v4l:l,v4h:a,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=i|0,this.v3h=f|0,this.v4l=l|0,this.v4h=a|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,l)=>g[l]=f),g.set(_,16);let{h:s,l:o}=M.fromBig(BigInt(this.length));g[24]=_[8]^o,g[25]=_[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=Or;for(let f=0;f<12;f++)re(0,4,8,12,t,n+2*i[c++]),se(0,4,8,12,t,n+2*i[c++]),re(1,5,9,13,t,n+2*i[c++]),se(1,5,9,13,t,n+2*i[c++]),re(2,6,10,14,t,n+2*i[c++]),se(2,6,10,14,t,n+2*i[c++]),re(3,7,11,15,t,n+2*i[c++]),se(3,7,11,15,t,n+2*i[c++]),re(0,5,10,15,t,n+2*i[c++]),se(0,5,10,15,t,n+2*i[c++]),re(1,6,11,12,t,n+2*i[c++]),se(1,6,11,12,t,n+2*i[c++]),re(2,7,8,13,t,n+2*i[c++]),se(2,7,8,13,t,n+2*i[c++]),re(3,4,9,14,t,n+2*i[c++]),se(3,4,9,14,t,n+2*i[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],g.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 Ve=Ir(e=>new Vr(e)),Pt=new TextEncoder().encode("SS58PRE"),Qe=2,Nt=e=>{try{const t=St.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Ve(Uint8Array.of(...Pt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:jr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},jr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},qt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Ve(Uint8Array.of(...Pt,...t,...n),{dkLen:64}).subarray(0,Qe);return St.encode(Uint8Array.of(...t,...n,...r))}};function Pr(e,t){return n=>{const r=Nt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const Ze=(e=42,t=32)=>R(D(t),Pr(t),qt(e)),Rt="0123456789abcdef";function G(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rt[r>>4]+Rt[r&15]}return t.join("")}const et={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 Ee(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=et[e[c]],f=et[e[c+1]];s[t+o++]=i<<4|f}return s}function Ft(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const de=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n};var Nr=Object.defineProperty,Xt=e=>{throw TypeError(e)},qr=(e,t,n)=>t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>qr(e,typeof t!="symbol"?t+"":t,n),zt=(e,t,n)=>t.has(e)||Xt("Cannot "+n),Y=(e,t,n)=>(zt(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Xt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),fe=(e,t,n,r)=>(zt(e,t,"write to private field"),t.set(e,n),n),J,Be,je,Pe,Ne;const Rr=new TextEncoder,Fr=new TextDecoder,Xr=z($,D(1/0))[1];class Q{constructor(t,n=!1){if(xe(this,J),xe(this,Be,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>Y(this,Ne)??fe(this,Ne,Fr.decode(Y(this,J)))),ke(this,"asHex",()=>Y(this,je)||fe(this,je,G(Y(this,J)))),ke(this,"asOpaqueHex",()=>Y(this,Pe)||fe(this,Pe,G(this.asBytes()))),ke(this,"asBytes",()=>Y(this,J)),ke(this,"asOpaqueBytes",()=>Y(this,Be)||fe(this,Be,de($[0](Y(this,J).length),Y(this,J)))),n){try{const[r,s]=Xr(t);if(r===s.length){fe(this,J,s),fe(this,Be,t);return}}catch{}throw new Error("Invalid opaque bytes")}else fe(this,J,t)}static fromText(t){return new this(Rr.encode(t))}static fromHex(t){return new this(Ee(t))}static fromOpaqueHex(t){return new this(Ee(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}J=new WeakMap,Be=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[zr]=Ze();class Kt extends Q{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(zr(t))}}const Wt=e=>{const t=D.enc(e);return n=>t(n.asBytes())},Gt=e=>{const t=D.dec(e),n=e==null?Q:Kt;return r=>n.fromBytes(t(r))},Ie=e=>x(Wt(e),Gt(e));Ie.enc=Wt,Ie.dec=Gt;const m=$,Kr=$,Wr=We(e=>{const t=m.dec(e),n=Math.ceil(t/8);return{bytes:D(n).dec(e),bitsLen:t}}),Yt=x(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=m.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Wr),Gr=R(U,e=>e.charCodeAt(0),String.fromCharCode),Jt=e=>{const t=D.enc(e);return n=>t(Ee(n))},Qt=e=>{const t=D.dec(e);return n=>G(t(n))},oe=e=>x(Jt(e),Qt(e));oe.enc=Jt,oe.dec=Qt;const Yr=new TextEncoder,Jr=new TextDecoder,Qr=e=>R(D(e),t=>Yr.encode(t),t=>Jr.decode(t)),Zt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},en=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},tn=e=>x(Zt(()=>e().enc),en(()=>e().dec)),tt=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}}),Zr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),nn=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},rn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},ye=(e,...t)=>x(nn(Ft(e,([n])=>n),...t),rn(Ft(e,([,n])=>n),...t));ye.enc=nn,ye.dec=rn;const sn=[],on=[],cn=[],es=BigInt(0),Ae=BigInt(1),ts=BigInt(2),ns=BigInt(7),rs=BigInt(256),ss=BigInt(113);for(let e=0,t=Ae,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],sn.push(2*(5*r+n)),on.push((e+1)*(e+2)/2%64);let s=es;for(let o=0;o<7;o++)t=(t<<Ae^(t>>ns)*ss)%rs,t&ts&&(s^=Ae<<(Ae<<BigInt(o))-Ae);cn.push(s)}const[os,cs]=Ct(cn,!0),an=(e,t,n)=>n>32?Vt(e,t,n):Ht(e,t,n),ln=(e,t,n)=>n>32?jt(e,t,n):Mt(e,t,n);function is(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const i=(c+8)%10,f=(c+2)%10,l=n[f],a=n[f+1],d=an(l,a,1)^n[i],h=ln(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=on[c],f=an(s,o,i),l=ln(s,o,i),a=sn[c];s=e[a],o=e[a+1],e[a]=f,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=os[r],e[1]^=cs[r]}n.fill(0)}class nt extends Dt{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ue(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=he(this.state)}keccak(){C||H(this.state32),is(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=W(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let i=0;i<c;i++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const as=((e,t,n)=>Br(()=>new nt(t,e,n)))(1,136,256/8),un=e=>{const t=e.slice(2),n=G(as(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},ls=D(20)[1],hn=x(e=>{const t=Ee(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=G(t);if(e===n||e===n.toUpperCase())return t;if(un(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},We(e=>un(G(ls(e))))),dn=new TextEncoder,fn=new TextDecoder,us=R(D(4),dn.encode.bind(dn),fn.decode.bind(fn)),rt=v({engine:us,payload:oe()}),hs=ye({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:w},[4,5,6,8]),st=oe(32),ds=v({parentHash:st,number:m,stateRoot:st,extrinsicRoot:st,digests:B(hs)}),Z=B(O),yn=P(O),fs=F({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),pn=B(v({name:yn,type:m,typeName:yn,docs:Z})),ys=v({len:ne,type:m}),ps=v({bitStoreType:m,bitOrderType:m}),gs=B(v({name:O,fields:pn,index:U,docs:Z})),bs=F({composite:pn,variant:gs,sequence:m,array:ys,tuple:B(m),primitive:fs,compact:m,bitSequence:ps}),ms=v({name:O,type:P(m)}),ws=B(ms),vs=v({id:m,path:Z,params:ws,def:bs,docs:Z}),qe=B(vs),Es=F({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),ks=B(Es),xs=v({hashers:ks,key:m,value:m}),Bs=v({name:O,modifier:U,type:F({plain:m,map:xs}),fallback:oe(),docs:Z}),Is=P(v({prefix:O,items:B(Bs)})),gn={name:O,storage:Is,calls:P(m),events:P(m),constants:B(v({name:O,type:m,value:oe(),docs:Z})),errors:P(m),index:U},As={...gn,docs:Z},Os=new Uint8Array,bn=e=>x(()=>Os,()=>e),_s=v({type:m,version:U,signedExtensions:B(v({identifier:O,type:m,additionalSigned:m}))}),mn=v({lookup:qe,pallets:B(v({...gn,docs:bn([])})),extrinsic:_s,type:m,apis:bn([])}),Us=v({name:O,methods:B(v({name:O,inputs:B(v({name:O,type:m})),output:m,docs:Z})),docs:Z}),Ls=v({version:U,address:m,call:m,signature:m,extra:m,signedExtensions:B(v({identifier:O,type:m,additionalSigned:m}))}),wn=v({lookup:qe,pallets:B(v(As)),extrinsic:Ls,type:m,apis:B(Us),outerEnums:v({call:m,event:m,error:m}),custom:B(z(O,v({type:m,value:oe()})))}),vn=()=>{throw new Error("Unsupported metadata version!")},V=x(vn,vn),Oe=v({magicNumber:ne,metadata:F({v0:V,v1:V,v2:V,v3:V,v4:V,v5:V,v6:V,v7:V,v8:V,v9:V,v10:V,v11:V,v12:V,v13:V,v14:mn,v15:wn})}),ot=D(),Ss=P(ot),$s=z($,ot),Ds=e=>{try{return Oe.dec(e)}catch{}try{return Oe.dec(Ss.dec(e))}catch{}try{return Oe.dec(ot.dec(e))}catch{}try{return Oe.dec($s.dec(e)[1])}catch{}throw null},Ts={dkLen:32},ct=e=>Ve(e,Ts),Cs={dkLen:16},it=e=>Ve(e,Cs),En=e=>de(it(e),e),ee=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,16),n=n+r|0,t=Ce(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,8),n=n+r|0,t=Ce(t^n,7),{a:e,b:t,c:n,d:r}}function kn(e,t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b,E,I,j){let A=0;for(let ge=0;ge<r;ge++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[A++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ce(o,l,u,E,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ie(o,l,u,E,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ce(c,a,y,I,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ie(c,a,y,I,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ce(s,l,y,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ie(s,l,y,j,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ce(o,a,p,b,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ie(o,a,p,b,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ce(i,f,u,I,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ie(i,f,u,I,n[t+e[A++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:l,v6:a,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:I,v15:j}}const xn=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class at extends Tt{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,ue(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=W(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=he(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new at({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=ee.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=kr(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=Me(BigInt(t),!0),{v0:l,v1:a,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:I,v10:j,v11:A,v12:ge,v13:Xe,v14:ze,v15:yo}=kn(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],ee[0],ee[1],ee[2],ee[3],i,f,c,n);o[0]=l^E,o[1]=a^I,o[2]=d^j,o[3]=h^A,o[4]=u^ge,o[5]=y^Xe,o[6]=p^ze,o[7]=b^yo}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:i,stack:f,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=f.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,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:s,bufferOut32:o}=this,{h:c,l:i}=Me(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:l,v2:a,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:I,v11:j,v12:A,v13:ge,v14:Xe,v15:ze}=kn(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],ee[0],ee[1],ee[2],ee[3],i,c,n,r);o[0]=f^b,o[1]=l^E,o[2]=a^I,o[3]=d^j,o[4]=h^A,o[5]=u^ge,o[6]=y^Xe,o[7]=p^ze,o[8]=t[0]^b,o[9]=t[1]^E,o[10]=t[2]^I,o[11]=t[3]^j,o[12]=t[4]^A,o[13]=t[5]^ge,o[14]=t[6]^Xe,o[15]=t[7]^ze,C||(H(s),H(o)),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,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),Te(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(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 Hs=Ar(e=>new at(e)),Ms={dkLen:32},Bn=e=>Hs(e,Ms),Vs=e=>de(Bn(e),e),In=e=>e,pe=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),lt=2n**64n-1n,T=(e,t)=>e<<t&lt|e>>64n-t,k=(e,t)=>e*t&lt,L=(e,t)=>e+t&lt,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,_e=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=L(L(t,S),N),r=L(t,N),s=t,o=t-S,c=e.length,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=pe(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),n=k(T(L(n,k(b,N)),31n),S),u+=8,b=pe(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),r=k(T(L(r,k(b,N)),31n),S),u+=8,b=pe(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),s=k(T(L(s,k(b,N)),31n),S),u+=8,b=pe(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]),o=k(T(L(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let l,a=0;for(c>=32?(l=T(n,1n),l=L(l,T(r,7n)),l=L(l,T(s,12n)),l=L(l,T(o,18n)),n=k(T(k(n,N),31n),S),l=l^n,l=L(k(l,S),_e),r=k(T(k(r,N),31n),S),l=l^r,l=L(k(l,S),_e),s=k(T(k(s,N),31n),S),l=l^s,l=L(k(l,S),_e),o=k(T(k(o,N),31n),S),l=l^o,l=L(k(l,S),_e)):l=L(t,On),l=L(l,BigInt(c));a<=i-8;){let h=pe(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=k(T(k(h,N),31n),S),l=L(k(T(l^h,27n),S),_e),a+=8}if(a+4<=i){let h=k(pe(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),S);l=L(k(T(l^h,23n),N),An),a+=4}for(;a<i;){const h=k(pe(e[a++],0,0,0),On);l=k(T(l^h,11n),S)}let d=l>>33n;return l=k(l^d,N),d=l>>29n,l=k(l^d,An),d=l>>32n,l^=d,l}const Re=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),t},_n=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),n.setBigUint64(16,ae(e,2n),!0),n.setBigUint64(24,ae(e,3n),!0),t},Un=e=>de($e.enc(ae(e)),e),Ln=new TextEncoder,js=new Map([[In,0],[Un,8],[En,16],[it,-16],[ct,-32],[Re,-16],[_n,-32]]),Ps=e=>{const t=Re(Ln.encode(e));return(n,r,...s)=>{const o=de(t,Re(Ln.encode(n))),c=G(o),i=a=>{if(!a.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Ee(a.slice(c.length)),h=new Array(s.length);for(let u=0,y=0;u<s.length;u++){const[p,b]=s[u],E=js.get(b);if(E==null)throw new Error("Unknown hasher");if(E<0){const I=E*-1;h[u]=G(d.slice(y,y+I)),y+=I}else y+=E,h[u]=p.dec(d.slice(y)),y+=p.enc(h[u]).length}return h},f=s.map(([{enc:a},d])=>h=>d(a(h)));return{enc:(...a)=>G(de(o,...a.map((d,h)=>f[h](d)))),dec:r,keyDecoder:i}}},Ns=Q.fromText("modlpy/utilisuba").asBytes(),qs=({threshold:e,signatories:t})=>{const n=Sn(t),r=de(Ns,$.enc(n.length),...n,me.enc(e));return ct(r)},Sn=e=>e.slice().sort((t,n)=>{for(let r=0;;r++){const s=r>=t.length,o=r>=n.length;if(s&&o)return 0;if(s)return-1;if(o)return 1;if(t[r]!==n[r])return t[r]>n[r]?1:-1}});var Rs=Object.freeze({__proto__:null,AccountId:Ze,Bin:Ie,Binary:Q,Blake2128:it,Blake2128Concat:En,Blake2256:ct,Blake3256:Bn,Blake3256Concat:Vs,Bytes:D,Enum:tt,FixedSizeBinary:Kt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:F,Self:tn,Storage:Ps,Struct:v,Tuple:z,Twox128:Re,Twox256:_n,Twox64Concat:Un,Variant:ye,Vector:B,_Enum:Zr,_void:w,bitSequence:Yt,blockHeader:ds,bool:Zn,char:Gr,compact:$,compactBn:Kr,compactNumber:m,createCodec:x,createDecoder:We,decAnyMetadata:Ds,enhanceCodec:R,enhanceDecoder:Se,enhanceEncoder:Ge,ethAccount:hn,fixedStr:Qr,fromBufferToBase58:qt,getMultisigAccountId:qs,getSs58AddressInfo:Nt,h64:ae,i128:Yn,i16:zn,i256:Qn,i32:Kn,i64:Wn,i8:Xn,metadata:Oe,selfDecoder:en,selfEncoder:Zt,sortMultisigSignatories:Sn,str:O,u128:Gn,u16:me,u256:Jn,u32:ne,u64:$e,u8:U,v14:mn,v14Lookup:qe,v15:wn});const Fs=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Xs=Ie(),zs=x($[0],Se($[1],BigInt)),$n=Fs((e,t,n,r)=>{if(e.type==="primitive")return Rs[e.value];if(e.type==="void")return w;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return hn;if(e.type==="compact")return e.isBig?zs:$;if(e.type==="bitSequence")return Yt;const s=u=>$n(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Xs;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ie(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return i(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(u=>{switch(u.type){case"void":return w;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,y)=>u===y)?ye(l):ye(l,a);return e.byteLength?Ws(h,e.byteLength):h},tn,e=>e),Ks=(e,t=Ze())=>{const n=new Map,r=s=>$n(e(s),n,new Set,t);return s=>r(s)},Ws=(e,t)=>{const n=D(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Gs=e=>{const{metadata:t}=e,n=Ks(e),r=(a="")=>{const d=e.storage[a];if(!d)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=d.key==null?w:n(d.key);return{key:Dn(h,d.keyPrefix),value:n(d.typeId)}},s=a=>{const d=v(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:Dn(d,a.selector),value:n(a.returnType.type)}},o=a=>{const d=t.spec.constructors.find(h=>h.label===a);if(!d)throw new Error(`Constructor ${a} not found`);return s(d)},c=a=>{const d=t.spec.messages.find(h=>h.label===a);if(!d)throw new Error(`Message ${a} not found`);return s(d)},i=a=>v(Object.fromEntries(a.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>ye(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(a){const y=d.find(p=>p.signature_topic===a);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===a);return u.length?Ys(u.map(y=>h(i(y),y.label))):null}}},Dn=(e,t)=>{const n=Q.fromHex(t).asBytes(),r=z(D(n.length),e);return R(r,s=>[n,s],([,s])=>s)},Ys=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Tn=e=>R(F(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),Ue=(e,t)=>R(B(e,t),n=>n??[],n=>n),Cn=P(O),Fe=Ue(O),Js=Tn({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),Hn=Ue(v({name:Cn,type:m,typeName:Cn,docs:Fe})),Qs=v({len:ne,type:m}),Zs=v({bitStoreType:m,bitOrderType:m}),eo=Ue(v({name:O,fields:Hn,index:U,docs:Fe})),to=Tn({composite:v({fields:Hn}),variant:v({variants:eo}),sequence:v({type:m}),array:Qs,tuple:B(m),primitive:Js,compact:m,bitSequence:Zs}),no=v({name:O,type:P(m)}),ro=Ue(no),so=v({id:m,path:Fe,params:ro,def:to,docs:Fe}),oo=R(so,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),co=Ue(oo),io=e=>{const t=co.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=ao(e,n),c=jn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function ao(e,t){const n={},r=(s,o=[])=>{function c(f){const l=t.length;return t[l]={id:l,docs:[],def:f,params:[],path:[]},l}if("root"in s){const f=Number(e.version)===4?Q.fromBytes(Q.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){a(y.get("len"),[...h,"len"]),a(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,l)=>({name:f.name,fields:f.fields.map(a=>({name:a.name,type:r(a.layout,[...o,f.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const lo=e=>{const t=io(e.metadata),n=Gs(t);return{constructor:Mn(n.buildConstructor),message:Mn(n.buildMessage),storage:uo(n.buildStorage),event:Number(t.metadata.version)===4?ho(n.buildEvents):fo(t,n.buildEvent)}},Mn=e=>t=>{const n=e(t);return{encode:r=>Q.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},uo=e=>t=>{const n=e(t);return{encode:r=>Q.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},ho=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},fo=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(l=>"event"in l?l:{event:l,topics:l.topics}).filter(l=>l.event.type==="Contracts"&&l.event.value.type==="ContractEmitted"&&l.event.value.value.contract===c).map(l=>{const a=l.topics.map(h=>h.asHex()),d=a.find(h=>n.has(h));try{return s(l.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:l.event.value.value.data.asHex(),eventTopics:a,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(l=>l!==null)}};we.getInkClient=lo});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -191,28 +191,28 @@
191
191
  "rxjs": ">=7.8.0"
192
192
  },
193
193
  "dependencies": {
194
+ "@polkadot-api/cli": "0.9.22",
195
+ "@polkadot-api/ink-contracts": "0.2.3",
194
196
  "@polkadot-api/json-rpc-provider": "0.0.4",
195
- "@polkadot-api/cli": "0.9.21",
196
197
  "@polkadot-api/logs-provider": "0.0.6",
197
198
  "@polkadot-api/polkadot-sdk-compat": "2.3.1",
198
- "@polkadot-api/metadata-builders": "0.9.2",
199
- "@polkadot-api/metadata-compatibility": "0.1.12",
200
- "@polkadot-api/pjs-signer": "0.6.1",
201
- "@polkadot-api/observable-client": "0.6.3",
199
+ "@polkadot-api/observable-client": "0.6.4",
200
+ "@polkadot-api/metadata-builders": "0.9.3",
201
+ "@polkadot-api/metadata-compatibility": "0.1.13",
202
+ "@polkadot-api/pjs-signer": "0.6.2",
202
203
  "@polkadot-api/polkadot-signer": "0.1.6",
203
- "@polkadot-api/signer": "0.1.11",
204
+ "@polkadot-api/signer": "0.1.12",
205
+ "@polkadot-api/substrate-bindings": "0.10.0",
204
206
  "@polkadot-api/sm-provider": "0.1.7",
205
- "@polkadot-api/substrate-bindings": "0.9.4",
206
207
  "@polkadot-api/substrate-client": "0.3.0",
207
- "@polkadot-api/utils": "0.1.2",
208
- "@polkadot-api/ink-contracts": "0.2.2",
209
208
  "@polkadot-api/ws-provider": "0.3.6",
210
209
  "@polkadot-api/known-chains": "0.5.8",
211
- "@polkadot-api/smoldot": "0.3.7"
210
+ "@polkadot-api/utils": "0.1.2",
211
+ "@polkadot-api/smoldot": "0.3.8"
212
212
  },
213
213
  "devDependencies": {
214
214
  "rxjs": "^7.8.1",
215
- "@polkadot-api/codegen": "0.12.9"
215
+ "@polkadot-api/codegen": "0.12.11"
216
216
  },
217
217
  "scripts": {
218
218
  "build-core": "tsc --noEmit && rollup -c",