polkadot-api 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { getCli, ink, update, remove, generate, add } from '@polkadot-api/cli';
3
3
 
4
- var version = "1.11.0";
4
+ var version = "1.11.1";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(ce,Lt){typeof exports=="object"&&typeof module<"u"?Lt(exports):typeof define=="function"&&define.amd?define(["exports"],Lt):(ce=typeof globalThis<"u"?globalThis:ce||self,Lt(ce.papi={}))})(this,function(ce){"use strict";var Lt=Object.defineProperty,uc=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t,n)=>(uc(e,typeof t!="symbol"?t+"":t,n),n),Nn={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 lc(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|Nn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Nn[e[i]],u=Nn[e[i+1]];s[t+o++]=c<<4|u}return s}var ns=class extends Uint8Array{constructor(e){super(e),ts(this,"i",0),ts(this,"v"),this.v=new DataView(e)}},Ae=e=>t=>e(t instanceof ns?t:new ns(t instanceof Uint8Array?t.buffer:typeof t=="string"?lc(t).buffer:t)),Ve=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function cn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var an=Ae,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Vt=(e,t)=>n=>e(t(n)),Qn=(e,t)=>n=>t(e(n)),Ze=([e,t],n,r)=>j(Vt(e,n),Qn(t,r));function fc(e,t){return Ae(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function hc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Je(e,t,n){return j(hc(e,n),fc(e,t))}var z=Je(1,"getUint8","setUint8"),et=Je(2,"getUint16","setUint16"),$e=Je(4,"getUint32","setUint32"),Dt=Je(8,"getBigUint64","setBigUint64"),dc=Je(1,"getInt8","setInt8"),pc=Je(2,"getInt16","setInt16"),vc=Je(4,"getInt32","setInt32"),bc=Je(8,"getBigInt64","setBigInt64"),rs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ss=e=>Ae(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}),os=j(rs,ss("getBigUint64")),yc=j(rs,ss("getBigInt64")),is=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},cs=e=>Ae(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}),mc=j(is,cs("getBigUint64")),gc=j(is,cs("getBigInt64")),wc=Ze(z,e=>e?1:0,Boolean),xc=[z[1],et[1],$e[1]],Ec=Ae(e=>{const t=e[e.i],n=t&3;if(n<3)return xc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=Dt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt($e[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(z[1](e))<<i|s),s}),kc=1n<<56n,Ac=1<<24,Sc=256,Ic=4294967295n,Bc=64,_c=16384,Cc=1<<30,$c=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Bc)return z[0](t);if(e<_c)return et[0](t|1);if(e<Cc)return $e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=kc;)n.push(Dt[0](r)),r>>=64n;r>=Ac&&(n.push($e[0](Number(r&Ic))),r>>=32n);let s=Number(r);s>=Sc&&(n.push(et[0](s)),s>>=16),s&&n.push(z[0](s));const o=Ve(n);return o[0]=o.length-5<<2|3,o},ae=j($c,Ec),Oc=new TextEncoder,Tc=e=>{const t=Oc.encode(e);return Ve([ae.enc(t.length),t])},Rc=new TextDecoder,Pc=Ae(e=>{let t=ae.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Rc.decode(n)}),V=j(Tc,Pc),Uc=()=>{},Mc=new Uint8Array(0),C=j(()=>Mc,Uc),as=e=>e===void 0?t=>Ve([ae.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),us=e=>Ae(t=>{const n=e===void 0?ae.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}),Q=e=>j(as(e),us(e));Q.enc=as,Q.dec=us;var ls=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>Ve([z.enc(s(o)),e[o](i)])},fs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ae(s=>{const o=z.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},he=(e,...t)=>j(ls(cn(e,([n])=>n),...t),fs(cn(e,([,n])=>n),...t));he.enc=ls,he.dec=fs;var hs=e=>Ae(t=>z[1](t)>0?e(t):void 0),ds=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ve([n,e(t)]))},de=e=>j(ds(e[0]),hs(e[1]));de.enc=ds,de.dec=hs;var ps=(e,t)=>Ae(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),vs=(e,t)=>({success:n,value:r})=>Ve([z[0](n?0:1),(n?e:t)(r)]),jt=(e,t)=>j(vs(e[0],t[0]),ps(e[1],t[1]));jt.dec=ps,jt.enc=vs;var bs=(...e)=>Ae(t=>e.map(n=>n(t))),ys=(...e)=>t=>Ve(e.map((n,r)=>n(t[r]))),Se=(...e)=>j(ys(...e.map(([t])=>t)),bs(...e.map(([,t])=>t)));Se.enc=ys,Se.dec=bs;var ms=e=>{const t=Object.keys(e);return Vt(Se.enc(...Object.values(e)),n=>t.map(r=>n[r]))},gs=e=>{const t=Object.keys(e);return Qn(Se.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},$=e=>j(ms(cn(e,t=>t[0])),gs(cn(e,t=>t[1])));$.enc=ms,$.dec=gs;var ws=(e,t)=>t>=0?n=>Ve(n.map(e)):n=>Ve([ae.enc(n.length),Ve(n.map(e))]),xs=(e,t)=>Ae(n=>{const r=t>=0?t:ae.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),P=(e,t)=>j(ws(e[0],t),xs(e[1],t));P.enc=ws,P.dec=xs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Es(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Zn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ks(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Jn(e){if(!Array.isArray(e))throw new Error("array expected")}function As(e,t){if(!Es(!0,t))throw new Error(`${e}: array of strings expected`)}function Vc(e,t){if(!Es(!1,t))throw new Error(`${e}: array of numbers expected`)}function Dc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function jc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;As("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Jn(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Jn(s),s.map(o=>{Zn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function zc(e=""){return Zn("join",e),{encode:t=>(As("join.decode",t),t.join(e)),decode:t=>(Zn("join.decode",t),t.split(e))}}function Ss(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Jn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ks(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,f=d+l;if(!Number.isSafeInteger(f)||d/t!==c||f-l!==d)throw new Error("convertRadix: carry overflow");const h=f/n;c=f%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==f)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Fc(e){ks(e);const t=2**8;return{encode:n=>{if(!Lc(n))throw new Error("radix.encode input should be Uint8Array");return Ss(Array.from(n),t,e)},decode:n=>(Vc("radix.decode",n),Uint8Array.from(Ss(n,e,t)))}}const Is=(e=>Dc(Fc(58),jc(e),zc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Hc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function dt(e,...t){if(!Hc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function er(e,t){dt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function qc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e,t){return e<<32-t|e>>>t}const Bs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const We=Bs?e=>e:e=>_s(e);function Wc(e){for(let t=0;t<e.length;t++)e[t]=_s(e[t]);return e}const ue=Bs?e=>e:Wc;function Kc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function De(e){return typeof e=="string"&&(e=Kc(e)),dt(e),e}class Cs{}function Xc(e){const t=r=>e().update(De(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Gc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Nc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function nt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,16),n=n+r|0,t=un(t^n,12),{a:e,b:t,c:n,d:r}}function rt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,8),n=n+r|0,t=un(t^n,7),{a:e,b:t,c:n,d:r}}const Qc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=BigInt(2**32-1),$s=BigInt(32);function fn(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>$s&ln)}:{h:Number(e>>$s&ln)|0,l:Number(e&ln)|0}}function Zc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=fn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Os=(e,t,n)=>e>>>n|t<<32-n,Ts=(e,t,n)=>e<<32-n|t>>>n,Jc=(e,t,n)=>e<<64-n|t>>>n-32,ea=(e,t,n)=>e>>>n-32|t<<64-n,ta=(e,t)=>t,na=(e,t)=>e,ra=(e,t,n)=>e<<n|t>>>32-n,sa=(e,t,n)=>t<<n|e>>>32-n,oa=(e,t,n)=>t<<n-32|e>>>64-n,ia=(e,t,n)=>e<<n-32|t>>>64-n;function Rs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Us=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,G=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ta(v,p),Dl:na(v)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Os(d,l,24),Bl:Ts(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ot(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Os(v,p,16),Dl:Ts(v,p,16)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Jc(d,l,63),Bl:ea(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ca(e,t={},n,r,s){if(xt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Ms extends Cs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,xt(t),xt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=pt(this.buffer)}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ue(s),this.compress(s,0,!1),ue(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ue(d);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(d,f,!1);ue(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){zt(this),er(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,tt(this.buffer.subarray(n)),ue(r),this.compress(r,0,!0),ue(r);const s=pt(t);this.get().forEach((o,i)=>s[i]=We(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class aa extends Ms{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=G[0]|0,this.v0h=G[1]|0,this.v1l=G[2]|0,this.v1h=G[3]|0,this.v2l=G[4]|0,this.v2h=G[5]|0,this.v3l=G[6]|0,this.v3h=G[7]|0,this.v4l=G[8]|0,this.v4h=G[9]|0,this.v5l=G[10]|0,this.v5h=G[11]|0,this.v6l=G[12]|0,this.v6h=G[13]|0,this.v7l=G[14]|0,this.v7h=G[15]|0,ca(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=De(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=De(o);const c=pt(o);this.v4l^=We(c[0]),this.v4h^=We(c[1]),this.v5l^=We(c[2]),this.v5h^=We(c[3])}if(s!==void 0){s=De(s);const c=pt(s);this.v6l^=We(c[0]),this.v6h^=We(c[1]),this.v7l^=We(c[2]),this.v7h^=We(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:f,v6l:h,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=f|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(G,16);let{h:s,l:o}=fn(BigInt(this.length));k[24]=G[8]^o,k[25]=G[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Nc;for(let u=0;u<12;u++)st(0,4,8,12,t,n+2*c[i++]),ot(0,4,8,12,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),ot(1,5,9,13,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),ot(2,6,10,14,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),ot(3,7,11,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),ot(0,5,10,15,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),ot(1,6,11,12,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),ot(2,7,8,13,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]),ot(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],tt(k)}destroy(){this.destroyed=!0,tt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ua=Yc(e=>new aa(e));function Ls(e,t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b,y,g,w){let m=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:b}=nt(s,u,f,b,n[t+e[m++]])),{a:s,b:u,c:f,d:b}=rt(s,u,f,b,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=nt(o,a,h,y,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=rt(o,a,h,y,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=rt(i,l,p,g,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=nt(c,d,v,w,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=rt(c,d,v,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=nt(s,a,p,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=rt(s,a,p,w,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=rt(o,l,v,b,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=nt(i,d,f,y,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=rt(i,d,f,y,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=nt(c,u,h,g,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=rt(c,u,h,g,n[t+e[m++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:f,v9:h,v10:p,v11:v,v12:b,v13:y,v14:g,v15:w}}const hn=ua,Vs=new TextEncoder().encode("SS58PRE"),tr=2,nr=e=>{try{const t=Is.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-tr),s=t.subarray(n.length+r.length),o=hn(Uint8Array.of(...Vs,...n,...r),{dkLen:64}).subarray(0,tr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:la(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},la=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ds=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=hn(Uint8Array.of(...Vs,...t,...n),{dkLen:64}).subarray(0,tr);return Is.encode(Uint8Array.of(...t,...n,...r))}};function fa(e,t){return n=>{const r=nr(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 vt=(e=42,t=32)=>Ze(Q(t),fa(t),Ds(e)),js="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=js[r>>4]+js[r&15]}return t.join("")}const rr={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 le(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|rr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=rr[e[i]],u=rr[e[i+1]];s[t+o++]=c<<4|u}return s}function Et(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const re=(...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},Ft=Function.prototype;class zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ha=Object.defineProperty,Fs=e=>{throw TypeError(e)},da=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>da(e,typeof t!="symbol"?t+"":t,n),Hs=(e,t,n)=>t.has(e)||Fs("Cannot "+n),Ke=(e,t,n)=>(Hs(e,t,"read from private field"),n?n.call(e):t.get(e)),qt=(e,t,n)=>t.has(e)?Fs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(Hs(e,t,"write to private field"),t.set(e,n),n),Xe,Wt,dn,pn,vn;const pa=new TextEncoder,va=new TextDecoder,ba=Se(ae,Q(1/0))[1];class je{constructor(t,n=!1){if(qt(this,Xe),qt(this,Wt,null),qt(this,dn,null),qt(this,pn,null),qt(this,vn,null),Ht(this,"asText",()=>Ke(this,vn)??bt(this,vn,va.decode(Ke(this,Xe)))),Ht(this,"asHex",()=>Ke(this,dn)||bt(this,dn,Z(Ke(this,Xe)))),Ht(this,"asOpaqueHex",()=>Ke(this,pn)||bt(this,pn,Z(this.asBytes()))),Ht(this,"asBytes",()=>Ke(this,Xe)),Ht(this,"asOpaqueBytes",()=>Ke(this,Wt)||bt(this,Wt,re(ae[0](Ke(this,Xe).length),Ke(this,Xe)))),n){try{const[r,s]=ba(t);if(r===s.length){bt(this,Xe,s),bt(this,Wt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else bt(this,Xe,t)}static fromText(t){return new this(pa.encode(t))}static fromHex(t){return new this(le(t))}static fromOpaqueHex(t){return new this(le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Xe=new WeakMap,Wt=new WeakMap,dn=new WeakMap,pn=new WeakMap,vn=new WeakMap;const[ya]=vt();class bn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ya(t))}}const qs=e=>{const t=Q.enc(e);return n=>t(n.asBytes())},Ws=e=>{const t=Q.dec(e),n=e==null?je:bn;return r=>n.fromBytes(t(r))},Kt=e=>j(qs(e),Ws(e));Kt.enc=qs,Kt.dec=Ws;const _=Ze(ae,e=>e,Number),yn=Ze(ae,e=>e,BigInt),ma=an(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:Q(n).dec(e),bitsLen:t}}),Ks=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ma),ga=Ze(z,e=>e.charCodeAt(0),String.fromCharCode),Xs=e=>{const t=Q.enc(e);return n=>t(le(n))},Ys=e=>{const t=Q.dec(e);return n=>Z(t(n))},Oe=e=>j(Xs(e),Ys(e));Oe.enc=Xs,Oe.dec=Ys;const wa=new TextEncoder,xa=new TextDecoder,Ea=e=>Ze(Q(e),t=>wa.encode(t),t=>xa.decode(t)),Gs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ns=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},sr=e=>j(Gs(()=>e().enc),Ns(()=>e().dec)),yt=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}}),Qs=new Proxy({},{get(e,t){return n=>yt(t,n)}}),W=(e,t)=>{const n=e;return n.inner=t,n},Zs=(...e)=>{const t=he.enc(...e);return W(n=>t({tag:n.type,value:n.value}),e[0])},Js=(...e)=>{const t=he.dec(...e);return W(n=>{const{tag:r,value:s}=t(n);return yt(r,s)},e[0])},pe=(e,...t)=>W(j(Zs(Et(e,([n])=>n),...t),Js(Et(e,([,n])=>n),...t)),e);pe.enc=Zs,pe.dec=Js;const or=(e,...t)=>W(he(e,...t),e);or.enc=(e,...t)=>W(he.enc(e,...t),e),or.dec=(e,...t)=>W(he.dec(e,...t),e);const ka=BigInt(0),Xt=BigInt(1),Aa=BigInt(2),Sa=BigInt(7),Ia=BigInt(256),Ba=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=Xt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let s=ka;for(let o=0;o<7;o++)t=(t<<Xt^(t>>Sa)*Ba)%Ia,t&Aa&&(s^=Xt<<(Xt<<BigInt(o))-Xt);no.push(s)}const ro=Zc(no,!0),_a=ro[0],Ca=ro[1],so=(e,t,n)=>n>32?oa(e,t,n):ra(e,t,n),oo=(e,t,n)=>n>32?ia(e,t,n):sa(e,t,n);function $a(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=so(a,l,1)^n[c],f=oo(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=to[i],u=so(s,o,c),a=oo(s,o,c),l=eo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=_a[r],e[1]^=Ca[r]}tt(n)}class ir extends Cs{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,xt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){ue(this.state32),$a(this.state32,this.rounds),ue(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){zt(this,!1),dt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return xt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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,tt(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new ir(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Oa=(e,t,n)=>Xc(()=>new ir(t,e,n)),Ta=Oa(1,136,256/8),io=e=>{const t=e.slice(2),n=Z(Ta(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},Ra=Q(20)[1],co=j(e=>{const t=le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(io(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},an(e=>io(Z(Ra(e))))),me=e=>W($(e),e);me.enc=e=>W($.enc(e),e),me.dec=e=>W($.dec(e),e);const Te=(...e)=>W(Se(...e),e);Te.enc=(...e)=>W(Se.enc(...e),e),Te.dec=(...e)=>W(Se.dec(...e),e);const ge=(e,...t)=>W(P(e,...t),e);ge.enc=(e,...t)=>W(P.enc(e,...t),e),ge.dec=(e,...t)=>W(P.dec(e,...t),e);const mn=(e,t)=>W(jt(e,t),{ok:e,ko:t});mn.enc=(e,t)=>W(jt.enc(e,t),{ok:e,ko:t}),mn.dec=(e,t)=>W(jt.dec(e,t),{ok:e,ko:t});const it=e=>W(de(e),e);it.enc=e=>W(de.enc(e),e),it.dec=e=>W(de.dec(e),e);const ao=new TextEncoder,uo=new TextDecoder,Pa=Ze(Q(4),ao.encode.bind(ao),uo.decode.bind(uo)),cr=me({engine:Pa,payload:Oe()}),Ua=pe({consensus:cr,seal:cr,preRuntime:cr,runtimeUpdated:C},[4,5,6,8]),ar=Oe(32),lo=me({parentHash:ar,number:_,stateRoot:ar,extrinsicRoot:ar,digests:ge(Ua)}),we=P(V),fo=de(V),Ma=he({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),ho=P($({name:fo,type:_,typeName:fo,docs:we})),La=$({len:$e,type:_}),Va=$({bitStoreType:_,bitOrderType:_}),Da=P($({name:V,fields:ho,index:z,docs:we})),ja=he({composite:ho,variant:Da,sequence:_,array:La,tuple:P(_),primitive:Ma,compact:_,bitSequence:Va}),za=$({name:V,type:de(_)}),Fa=P(za),Ha=$({id:_,path:we,params:Fa,def:ja,docs:we}),gn=P(Ha),kt=he({NotDeprecated:C,DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})}),qa=P($({index:z,deprecation:he({DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})},[1,2])})),ur={name:V,inputs:P($({name:V,type:_})),output:_,docs:we},Wa=$({name:V,methods:P($(ur)),docs:we}),Ka=$({name:V,methods:P($({...ur,deprecationInfo:kt})),docs:we,version:_,deprecationInfo:kt}),Xa=$({id:Oe(32),...ur,deprecationInfo:kt}),Ya=he({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ga=P(Ya),Na=$({hashers:Ga,key:_,value:_}),po={name:V,modifier:z,type:he({plain:_,map:Na}),fallback:Oe(),docs:we},lr=de(_),vo={name:V,storage:de($({prefix:V,items:P($(po))})),calls:lr,events:lr,constants:P($({name:V,type:_,value:Oe(),docs:we})),errors:lr,index:z},Qa={...vo,docs:we},fr=de($({type:_,deprecationInfo:qa})),Za={name:V,storage:de($({prefix:V,items:P($({...po,deprecationInfo:kt}))})),calls:fr,events:fr,constants:P($({name:V,type:_,value:Oe(),docs:we,deprecationInfo:kt})),errors:fr,associatedTypes:P($({name:V,type:_,docs:we})),viewFns:P(Xa),index:z,docs:we,deprecationInfo:kt},Ja=new Uint8Array,bo=e=>j(()=>Ja,()=>e),eu=$({type:_,version:z,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),yo=$({lookup:gn,pallets:P($({...vo,docs:bo([])})),extrinsic:eu,type:_,apis:bo([])}),tu=$({version:z,address:_,call:_,signature:_,extra:_,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),mo=$({lookup:gn,pallets:P($(Qa)),extrinsic:tu,type:_,apis:P(Wa),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),nu=$({version:P(z),address:_,call:_,signature:_,signedExtensionsByVersion:P(Se(z,P(_))),signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),go=$({lookup:gn,pallets:P($(Za)),extrinsic:nu,apis:P(Ka),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),wo=()=>{throw new Error("Unsupported metadata version!")},ve=j(wo,wo),ct=$({magicNumber:$e,metadata:he({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:yo,v15:mo,v16:go})}),hr=Q(),ru=de(hr),su=Se(ae,hr),dr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(ru.dec(e))}catch{}try{return ct.dec(hr.dec(e))}catch{}try{return ct.dec(su.dec(e)[1])}catch{}throw null},At=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},ou={dkLen:32},Yt=e=>hn(e,ou),iu={dkLen:16},pr=e=>hn(e,iu),xo=e=>re(pr(e),e),ze={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Ye=Qc.slice(),Eo=(()=>{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 vr extends Ms{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=De(r).slice();dt(i,32),this.IV=pt(i),ue(this.IV),this.flags=n|ze.KEYED_HASH}else if(o){const i=De(s),c=new vr({dkLen:32},ze.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=pt(c),ue(this.IV),this.flags=n|ze.DERIVE_KEY_MATERIAL}else this.IV=Ye.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=qc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=fn(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:f,v4:h,v5:p,v6:v,v7:b,v8:y,v9:g,v10:w,v11:m,v12:x,v13:A,v14:S,v15:O}=Ls(Eo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Ye[0],Ye[1],Ye[2],Ye[3],c,u,i,n);o[0]=a^y,o[1]=l^g,o[2]=d^w,o[3]=f^m,o[4]=h^x,o[5]=p^A,o[6]=v^S,o[7]=b^O}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=ze.CHUNK_START),(this.chunkPos===15||r)&&(s|=ze.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ze.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,tt(this.state,this.buffer32,this.IV,this.bufferOut32),tt(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=fn(BigInt(this.chunkOut++));ue(s);const{v0:u,v1:a,v2:l,v3:d,v4:f,v5:h,v6:p,v7:v,v8:b,v9:y,v10:g,v11:w,v12:m,v13:x,v14:A,v15:S}=Ls(Eo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ye[0],Ye[1],Ye[2],Ye[3],c,i,n,r);o[0]=u^b,o[1]=a^y,o[2]=l^g,o[3]=d^w,o[4]=f^m,o[5]=h^x,o[6]=p^A,o[7]=v^S,o[8]=t[0]^b,o[9]=t[1]^y,o[10]=t[2]^g,o[11]=t[3]^w,o[12]=t[4]^m,o[13]=t[5]^x,o[14]=t[6]^A,o[15]=t[7]^S,ue(s),ue(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,tt(this.buffer.subarray(this.pos));let t=this.flags|ze.ROOT;this.stack.length?(t|=ze.PARENT,ue(this.buffer32),this.compress(this.buffer32,0,!0),ue(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ze.CHUNK_START)|ze.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){zt(this,!1),dt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return xt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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 cu=Gc(e=>new vr(e)),au={dkLen:32},ko=e=>cu(e,au),uu=e=>re(ko(e),e),Ao=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),br=2n**64n-1n,se=(e,t)=>e<<t&br|e>>64n-t,L=(e,t)=>e*t&br,J=(e,t)=>e+t&br,ee=11400714785074694791n,xe=14029467366897019727n,So=1609587929392839161n,Gt=9650029242287828579n,Io=2870177450012600261n;function at(e,t=0n){let n=J(J(t,ee),xe),r=J(t,xe),s=t,o=t-ee,i=e.length,c=0,u=null;(function(){let h=0,p=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(h<=p-32){const v=p-32;do{let b;b=mt(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(se(J(n,L(b,xe)),31n),ee),h+=8,b=mt(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(se(J(r,L(b,xe)),31n),ee),h+=8,b=mt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=L(se(J(s,L(b,xe)),31n),ee),h+=8,b=mt(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(se(J(o,L(b,xe)),31n),ee),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(i>=32?(a=se(n,1n),a=J(a,se(r,7n)),a=J(a,se(s,12n)),a=J(a,se(o,18n)),n=L(se(L(n,xe),31n),ee),a=a^n,a=J(L(a,ee),Gt),r=L(se(L(r,xe),31n),ee),a=a^r,a=J(L(a,ee),Gt),s=L(se(L(s,xe),31n),ee),a=a^s,a=J(L(a,ee),Gt),o=L(se(L(o,xe),31n),ee),a=a^o,a=J(L(a,ee),Gt)):a=J(t,Io),a=J(a,BigInt(i));l<=c-8;){let f=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=L(se(L(f,xe),31n),ee),a=J(L(se(a^f,27n),ee),Gt),l+=8}if(l+4<=c){let f=L(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),ee);a=J(L(se(a^f,23n),xe),So),l+=4}for(;l<c;){const f=L(mt(e[l++],0,0,0),Io);a=L(se(a^f,11n),ee)}let d=a>>33n;return a=L(a^d,xe),d=a>>29n,a=L(a^d,So),d=a>>32n,a^=d,a}const wn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},Bo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},_o=e=>re(Dt.enc(at(e)),e),Co=new TextEncoder,lu=new Map([[Ao,0],[_o,8],[xo,16],[pr,-16],[Yt,-32],[wn,-16],[Bo,-32]]),$o=e=>{const t=wn(Co.encode(e));return(n,...r)=>{const s=re(t,wn(Co.encode(n))),o=Z(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=le(a.slice(o.length)),d=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[p,v]=r[f],b=lu.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const y=b*-1;d[f]=Z(l.slice(h,h+y)),h+=y}else h+=b,d[f]=p.dec(l.slice(h)),h+=p.enc(d[f]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>Z(re(s,...a.map((l,d)=>c[d](l)))),dec:i}}},fu=je.fromText("modlpy/utilisuba").asBytes(),hu=({threshold:e,signatories:t})=>{const n=Oo(t),r=re(fu,ae.enc(n.length),...n,et.enc(e));return Yt(r)},Oo=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 To=Object.freeze({__proto__:null,AccountId:vt,Bin:Kt,Binary:je,Blake2128:pr,Blake2128Concat:xo,Blake2256:Yt,Blake3256:ko,Blake3256Concat:uu,Bytes:Q,Enum:yt,FixedSizeBinary:bn,Hex:Oe,Identity:Ao,Option:it,Result:mn,ScaleEnum:or,Self:sr,Storage:$o,Struct:me,Tuple:Te,Twox128:wn,Twox256:Bo,Twox64Concat:_o,Variant:pe,Vector:ge,_Enum:Qs,_void:C,bitSequence:Ks,blockHeader:lo,bool:wc,char:ga,compact:ae,compactBn:yn,compactNumber:_,createCodec:j,createDecoder:an,decAnyMetadata:dr,enhanceCodec:Ze,enhanceDecoder:Qn,enhanceEncoder:Vt,ethAccount:co,fixedStr:Ea,fromBufferToBase58:Ds,getMultisigAccountId:hu,getSs58AddressInfo:nr,h64:at,i128:yc,i16:pc,i256:gc,i32:vc,i64:bc,i8:dc,metadata:ct,selfDecoder:Ns,selfEncoder:Gs,sortMultisigSignatories:Oo,str:V,u128:os,u16:et,u256:mc,u32:$e,u64:Dt,u8:z,unifyMetadata:At,v14:yo,v14Lookup:gn,v15:mo,v16:go});const Ge=_,du=ge(Te(V,Ge)),D={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},pu=pe(Object.fromEntries(Object.values(D).map(e=>[e,C]))),vu=ge(Te(V,pe({inline:sr(()=>yr),lookup:Ge}))),bu=ge(Ge),yu=me({typeRef:Ge,length:it(Ge)}),mu=it(Ge),gu=Ge,wu=me({ok:Ge,ko:Ge}),yr=pe({struct:du,terminal:pu,enum:vu,tuple:bu,array:yu,binary:mu,option:gu,result:wu}),xu={i256:D.big,i128:D.big,i64:D.big,i32:D.num,i16:D.num,i8:D.num,u256:D.big,u128:D.big,u64:D.big,u32:D.num,u16:D.num,u8:D.num,bool:D.bool,char:D.str,str:D.str},Nt=e=>({type:"terminal",value:{type:e}});function xn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Nt(D.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 Nt(D.bits);case"compact":return Nt(e.isBig?D.big:D.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:xn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Nt(xu[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 Nt(D.void)}}function mr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>mr(o,i,n),s=o=>{switch(o.value.type){case D.str:case D.big:case D.bool:case D.num:return typeof e===o.value.type;case D.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case D.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Au=(e,t,n)=>ku(e,t+"",n);class Ro{constructor(t=[]){Au(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 Ie=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ie||{});function gr(e,t,n,r,s){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new Ro([[e,n]])}:be(c)}o.set(e,null);const i=Su(e,n,(c,u)=>gr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function Su(e,t,n){if(e.type!==t.type)return t.type==="option"?En(n(e,t.value),2):e.type==="option"?En(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(Uo(e.value,t.value));case"array":const s=e,o=be(Uo(s.value.length,t.value.length));return wr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([h,p])=>[h,p.value])),f=l.value.length===t.value.length?3:2;return En(Po(l.value.map(([h,p])=>()=>h in d?n(p.value,d[h]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return En(wr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=be(Bu(l.value,t.value));return wr([d,...t.value.map((f,h)=>()=>n(l.value[h],f))])}case"result":const a=e;return Po([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const En=(e,t)=>({...e,level:Math.min(e.level,t)}),Iu=new Ro,be=e=>({level:e,assumptions:Iu}),wr=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Po=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const s=typeof r=="function"?r():r;if(s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:be(0)},Bu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Uo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Mo=pe({lookup:_,typedef:yr}),St=e=>({type:"lookup",value:e}),xr=e=>({type:"typedef",value:e}),kn=xr({type:"terminal",value:{type:D.void}}),_u=me({args:Mo,values:Mo});function Cu(e){if(e.type.tag==="plain")return{args:kn,values:St(e.type.value)};const{key:t,value:n}=e.type.value;return{args:St(t),values:St(n)}}function Lo(e){return{args:xr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:St(e.output)}}function $u(e){return e.type==="lookupEntry"?St(e.value.id):xr(xn(e))}function Ou(e){return{args:kn,values:St(e)}}function Tu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:gr(o(e.args,t),t,o(n.args,r),r,s).level,values:gr(o(n.values,r),r,o(e.values,t),t,s).level}}function Vo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return mr(n,r,t)}const It=()=>{},Be={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},An={chainName:"",genesisHash:"",properties:""},Er={broadcast:"",stop:""};Object.entries({chainHead:Be,chainSpec:An,transaction:Er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ru=e=>(t,n)=>{let r=e(Er.broadcast,[t],{onSuccess:s=>{r=s===null?It:()=>{e(Er.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Do extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Sn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class In extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class jo extends Error{constructor(t){super(t),this.name="OperationError"}}class Bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Pu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const zo=()=>{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)})}}},_n=e=>(...t)=>new Promise((n,r)=>{let s=Ft;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Ft,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Fo=(e,t)=>n=>_n((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new In);const{operationId:f}=l,h=()=>{n(Be.stopOperation,[f])};if(!i)return h();let p=It;const v=y=>{i=!1,p(),r(y)},b=y=>{i=!1,p(),s(y)};p=d(f,{next:y=>{const g=y;g.event==="operationError"?s(new jo(g.error)):g.event==="operationInaccessible"?s(new Bn):a(y,v,b)},error:b}),c=()=>{i&&(p(),h())}},onError:s}),()=>{c()}}),Uu=Fo(Be.body,e=>[[e],(t,n)=>{n(t.value)}]),Mu=Fo(Be.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Lu=e=>t=>new Promise((n,r)=>{e(Be.header,[t],{onSuccess:n,onError:r})}),Ho=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Ft;let u=!0,a=()=>{u=!1};return e(Be.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new In);const{operationId:f}=l,h=()=>{e(Be.stopOperation,[f])};if(!u)return h();const p=d(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new jo(y.error));break}case"operationInaccessible":{v(new Bn);break}default:e(Be.continue,[y.operationId])}},error:o});a=()=>{p(),e(Be.stopOperation,[l.operationId])};const v=y=>{a=Ft,p(),o(y)},b=()=>{a=Ft,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Vu=e=>{const t=Ho(e);return _n((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(d(),r(new In))});return d})},Du=e=>t=>t.length>0?new Promise((n,r)=>{e(Be.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class Cn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function ju(e){return e.operationId!==void 0}function zu(e){return(t,n,r)=>{const s=zo(),o=new Set,i=Pu();let c=i.promise;const u=p=>{if(ju(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Do),f(!1)},a=p=>{r(p),f(!(p instanceof Cn))},l=(p,v)=>{const b=v(p,{next:u,error:a});f=(y=!0)=>{c=null,f=It,b(),y&&e(Be.unfollow,[p]),s.errorAll(new Sn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof Cn?f(!1):r(p),c=null,i.res(p)};let f=e(Be.follow,[t],{onSuccess:l,onError:d});const h=(p,v,b)=>{const y=()=>{b?.onError(new Sn)};if(c===null)return y(),It;const g=m=>{if(!b)return e(p,[m,...v]);o.add(y);const x=(S,O)=>c===null?(O.error(new Sn),It):(s.subscribe(S,O),()=>{s.unsubscribe(S)}),A=e(p,[m,...v],{onSuccess:S=>{o.delete(y),b.onSuccess(S,x)},onError:S=>{o.delete(y),b.onError(S)}});return()=>{o.delete(y),A()}};if(typeof c=="string")return g(c);let w=It;return c.then(m=>{if(m instanceof Error)return y();c&&(w=g(m))}),()=>{w()}};return{unfollow(){f(),c=null},body:Uu(h),call:Mu(h),header:Lu(h),storage:Vu(h),storageSubscription:Ho(h),unpin:Du(h),_request:h}}}var Fu=Object.defineProperty,Hu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qo=(e,t,n)=>Hu(e,typeof t!="symbol"?t+"":t,n);class Wo extends Error{constructor(t){super(t.message),qo(this,"code"),qo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let qu=1;const Wu=e=>{let t=qu++;const n=new Map,r=zo();let s=null;const o=(l,d,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:f}))};function i(l){try{let d,f,h,p,v;if({id:d,result:f,error:h,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),h?g.onError(new Wo(h)):g.onSuccess(f,(w,m)=>{const x=w;return r.subscribe(x,m),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const y=v;h?r.error(y,new Wo(h)):r.next(y,f)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Cn),n.forEach(l=>l.onError(new Cn)),n.clear()};let u=1;return{request:(l,d,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,d),()=>{n.delete(h)}},disconnect:c}},Ku=e=>{const t=_n((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(An.chainName,[]),t(An.genesisHash,[]),t(An.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},$n=new Map,Xu=e=>{const t=$n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Wu(e),s=()=>{const i=$n.get(e);!i||i.refCount<=1?($n.delete(e),r()):i.refCount--},o={chainHead:zu(n),transaction:Ru(n),getChainSpecData:Ku(n),destroy:s,request:_n((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return $n.set(e,{client:o,refCount:1}),o};var kr=function(e,t){return kr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},kr(e,t)};function Fe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Yu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Ko(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Bt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Re(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Pe(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function _t(e){return this instanceof _t?(this.v=e,this):new _t(e)}function Gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(s[h]=function(v){return new Promise(function(b,y){o.push([h,v,b,y])>1||u(h,v)})},p&&(s[h]=p(s[h])))}function u(h,p){try{a(r[h](p))}catch(v){f(o[0][3],v)}}function a(h){h.value instanceof _t?Promise.resolve(h.value.v).then(l,d):f(o[0][2],h)}function l(h){u("next",h)}function d(h){u("throw",h)}function f(h,p){h(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Nu(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Bt=="function"?Bt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function F(e){return typeof e=="function"}function Ar(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Sr=Ar(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(ce,Lt){typeof exports=="object"&&typeof module<"u"?Lt(exports):typeof define=="function"&&define.amd?define(["exports"],Lt):(ce=typeof globalThis<"u"?globalThis:ce||self,Lt(ce.papi={}))})(this,function(ce){"use strict";var Lt=Object.defineProperty,uc=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ts=(e,t,n)=>(uc(e,typeof t!="symbol"?t+"":t,n),n),Nn={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 lc(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|Nn[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=Nn[e[i]],u=Nn[e[i+1]];s[t+o++]=c<<4|u}return s}var ns=class extends Uint8Array{constructor(e){super(e),ts(this,"i",0),ts(this,"v"),this.v=new DataView(e)}},Ae=e=>t=>e(t instanceof ns?t:new ns(t instanceof Uint8Array?t.buffer:typeof t=="string"?lc(t).buffer:t)),Ve=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function cn(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const i=n[o];s[i]=t(e[i],i)}return s}var an=Ae,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Vt=(e,t)=>n=>e(t(n)),Qn=(e,t)=>n=>t(e(n)),Ze=([e,t],n,r)=>j(Vt(e,n),Qn(t,r));function fc(e,t){return Ae(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function hc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Je(e,t,n){return j(hc(e,n),fc(e,t))}var z=Je(1,"getUint8","setUint8"),et=Je(2,"getUint16","setUint16"),$e=Je(4,"getUint32","setUint32"),Dt=Je(8,"getBigUint64","setBigUint64"),dc=Je(1,"getInt8","setInt8"),pc=Je(2,"getInt16","setInt16"),vc=Je(4,"getInt32","setInt32"),bc=Je(8,"getBigInt64","setBigInt64"),rs=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ss=e=>Ae(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}),os=j(rs,ss("getBigUint64")),yc=j(rs,ss("getBigInt64")),is=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},cs=e=>Ae(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}),mc=j(is,cs("getBigUint64")),gc=j(is,cs("getBigInt64")),wc=Ze(z,e=>e?1:0,Boolean),xc=[z[1],et[1],$e[1]],Ec=Ae(e=>{const t=e[e.i],n=t&3;if(n<3)return xc[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let i=0n;for(let u=0;u<o;u++)s=Dt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt($e[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(z[1](e))<<i|s),s}),kc=1n<<56n,Ac=1<<24,Sc=256,Ic=4294967295n,Bc=64,_c=16384,Cc=1<<30,$c=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Bc)return z[0](t);if(e<_c)return et[0](t|1);if(e<Cc)return $e[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=kc;)n.push(Dt[0](r)),r>>=64n;r>=Ac&&(n.push($e[0](Number(r&Ic))),r>>=32n);let s=Number(r);s>=Sc&&(n.push(et[0](s)),s>>=16),s&&n.push(z[0](s));const o=Ve(n);return o[0]=o.length-5<<2|3,o},ae=j($c,Ec),Oc=new TextEncoder,Tc=e=>{const t=Oc.encode(e);return Ve([ae.enc(t.length),t])},Rc=new TextDecoder,Pc=Ae(e=>{let t=ae.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Rc.decode(n)}),V=j(Tc,Pc),Uc=()=>{},Mc=new Uint8Array(0),C=j(()=>Mc,Uc),as=e=>e===void 0?t=>Ve([ae.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),us=e=>Ae(t=>{const n=e===void 0?ae.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}),Q=e=>j(as(e),us(e));Q.enc=as,Q.dec=us;var ls=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[n[i],o])??n.map((o,i)=>[o,i])),s=o=>r.get(o);return({tag:o,value:i})=>Ve([z.enc(s(o)),e[o](i)])},fs=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ae(s=>{const o=z.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},he=(e,...t)=>j(ls(cn(e,([n])=>n),...t),fs(cn(e,([,n])=>n),...t));he.enc=ls,he.dec=fs;var hs=e=>Ae(t=>z[1](t)>0?e(t):void 0),ds=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,Ve([n,e(t)]))},de=e=>j(ds(e[0]),hs(e[1]));de.enc=ds,de.dec=hs;var ps=(e,t)=>Ae(n=>{const r=z[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),vs=(e,t)=>({success:n,value:r})=>Ve([z[0](n?0:1),(n?e:t)(r)]),jt=(e,t)=>j(vs(e[0],t[0]),ps(e[1],t[1]));jt.dec=ps,jt.enc=vs;var bs=(...e)=>Ae(t=>e.map(n=>n(t))),ys=(...e)=>t=>Ve(e.map((n,r)=>n(t[r]))),Se=(...e)=>j(ys(...e.map(([t])=>t)),bs(...e.map(([,t])=>t)));Se.enc=ys,Se.dec=bs;var ms=e=>{const t=Object.keys(e);return Vt(Se.enc(...Object.values(e)),n=>t.map(r=>n[r]))},gs=e=>{const t=Object.keys(e);return Qn(Se.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},$=e=>j(ms(cn(e,t=>t[0])),gs(cn(e,t=>t[1])));$.enc=ms,$.dec=gs;var ws=(e,t)=>t>=0?n=>Ve(n.map(e)):n=>Ve([ae.enc(n.length),Ve(n.map(e))]),xs=(e,t)=>Ae(n=>{const r=t>=0?t:ae.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),P=(e,t)=>j(ws(e[0],t),xs(e[1],t));P.enc=ws,P.dec=xs;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Es(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Zn(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function ks(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Jn(e){if(!Array.isArray(e))throw new Error("array expected")}function As(e,t){if(!Es(!0,t))throw new Error(`${e}: array of strings expected`)}function Vc(e,t){if(!Es(!1,t))throw new Error(`${e}: array of numbers expected`)}function Dc(...e){const t=o=>o,n=(o,i)=>c=>o(i(c)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function jc(e){const t=typeof e=="string"?e.split(""):e,n=t.length;As("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(Jn(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(Jn(s),s.map(o=>{Zn("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function zc(e=""){return Zn("join",e),{encode:t=>(As("join.decode",t),t.join(e)),decode:t=>(Zn("join.decode",t),t.split(e))}}function Ss(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Jn(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(ks(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,u=!0;for(let a=r;a<i;a++){const l=o[a],d=t*c,f=d+l;if(!Number.isSafeInteger(f)||d/t!==c||f-l!==d)throw new Error("convertRadix: carry overflow");const h=f/n;c=f%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==f)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function Fc(e){ks(e);const t=2**8;return{encode:n=>{if(!Lc(n))throw new Error("radix.encode input should be Uint8Array");return Ss(Array.from(n),t,e)},decode:n=>(Vc("radix.decode",n),Uint8Array.from(Ss(n,e,t)))}}const Is=(e=>Dc(Fc(58),jc(e),zc("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Hc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Et(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function dt(e,...t){if(!Hc(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function er(e,t){dt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function qc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e,t){return e<<32-t|e>>>t}const Bs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _s(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const We=Bs?e=>e:e=>_s(e);function Wc(e){for(let t=0;t<e.length;t++)e[t]=_s(e[t]);return e}const ue=Bs?e=>e:Wc;function Kc(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function De(e){return typeof e=="string"&&(e=Kc(e)),dt(e),e}class Cs{}function Xc(e){const t=r=>e().update(De(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Gc(e){const t=(r,s)=>e(s).update(De(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Nc=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);function nt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,16),n=n+r|0,t=un(t^n,12),{a:e,b:t,c:n,d:r}}function rt(e,t,n,r,s){return e=e+t+s|0,r=un(r^e,8),n=n+r|0,t=un(t^n,7),{a:e,b:t,c:n,d:r}}const Qc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ln=BigInt(2**32-1),$s=BigInt(32);function fn(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>$s&ln)}:{h:Number(e>>$s&ln)|0,l:Number(e&ln)|0}}function Zc(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let o=0;o<n;o++){const{h:i,l:c}=fn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const Os=(e,t,n)=>e>>>n|t<<32-n,Ts=(e,t,n)=>e<<32-n|t>>>n,Jc=(e,t,n)=>e<<64-n|t>>>n-32,ea=(e,t,n)=>e>>>n-32|t<<64-n,ta=(e,t)=>t,na=(e,t)=>e,ra=(e,t,n)=>e<<n|t>>>32-n,sa=(e,t,n)=>t<<n|e>>>32-n,oa=(e,t,n)=>t<<n-32|e>>>64-n,ia=(e,t,n)=>e<<n-32|t>>>64-n;function Rs(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Ps=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Us=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,G=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),k=new Uint32Array(32);function st(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:ta(v,p),Dl:na(v)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Os(d,l,24),Bl:Ts(d,l,24)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ot(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=k[2*e],a=k[2*e+1],l=k[2*t],d=k[2*t+1],f=k[2*n],h=k[2*n+1],p=k[2*r],v=k[2*r+1],b=Ps(u,l,i);a=Us(b,a,d,c),u=b|0,{Dh:v,Dl:p}={Dh:v^a,Dl:p^u},{Dh:v,Dl:p}={Dh:Os(v,p,16),Dl:Ts(v,p,16)},{h,l:f}=Rs(h,f,v,p),{Bh:d,Bl:l}={Bh:d^h,Bl:l^f},{Bh:d,Bl:l}={Bh:Jc(d,l,63),Bl:ea(d,l,63)},k[2*e]=u,k[2*e+1]=a,k[2*t]=l,k[2*t+1]=d,k[2*n]=f,k[2*n+1]=h,k[2*r]=p,k[2*r+1]=v}function ca(e,t={},n,r,s){if(Et(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:o,salt:i,personalization:c}=t;if(o!==void 0&&(o.length<1||o.length>n))throw new Error("key length must be undefined or 1.."+n);if(i!==void 0&&i.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==s)throw new Error("personalization must be undefined or "+s)}class Ms extends Cs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Et(t),Et(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=pt(this.buffer)}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,buffer:r,buffer32:s}=this,o=t.length,i=t.byteOffset,c=t.buffer;for(let u=0;u<o;){this.pos===n&&(ue(s),this.compress(s,0,!1),ue(s),this.pos=0);const a=Math.min(n-this.pos,o-u),l=i+u;if(a===n&&!(l%4)&&u+a<o){const d=new Uint32Array(c,l,Math.floor((o-u)/4));ue(d);for(let f=0;u+n<o;f+=s.length,u+=n)this.length+=n,this.compress(d,f,!1);ue(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){zt(this),er(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,tt(this.buffer.subarray(n)),ue(r),this.compress(r,0,!0),ue(r);const s=pt(t);this.get().forEach((o,i)=>s[i]=We(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:i,pos:c}=this;return t||(t=new this.constructor({dkLen:i})),t.set(...this.get()),t.buffer.set(n),t.destroyed=o,t.finished=s,t.length=r,t.pos=c,t.outputLen=i,t}clone(){return this._cloneInto()}}class aa extends Ms{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=G[0]|0,this.v0h=G[1]|0,this.v1l=G[2]|0,this.v1h=G[3]|0,this.v2l=G[4]|0,this.v2h=G[5]|0,this.v3l=G[6]|0,this.v3h=G[7]|0,this.v4l=G[8]|0,this.v4h=G[9]|0,this.v5l=G[10]|0,this.v5h=G[11]|0,this.v6l=G[12]|0,this.v6h=G[13]|0,this.v7l=G[14]|0,this.v7h=G[15]|0,ca(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=De(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=De(o);const c=pt(o);this.v4l^=We(c[0]),this.v4h^=We(c[1]),this.v5l^=We(c[2]),this.v5h^=We(c[3])}if(s!==void 0){s=De(s);const c=pt(s);this.v6l^=We(c[0]),this.v6h^=We(c[1]),this.v7l^=We(c[2]),this.v7h^=We(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:u,v4l:a,v4h:l,v5l:d,v5h:f,v6l:h,v6h:p,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b]}set(t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=i|0,this.v3l=c|0,this.v3h=u|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=f|0,this.v6l=h|0,this.v6h=p|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,a)=>k[a]=u),k.set(G,16);let{h:s,l:o}=fn(BigInt(this.length));k[24]=G[8]^o,k[25]=G[9]^s,r&&(k[28]=~k[28],k[29]=~k[29]);let i=0;const c=Nc;for(let u=0;u<12;u++)st(0,4,8,12,t,n+2*c[i++]),ot(0,4,8,12,t,n+2*c[i++]),st(1,5,9,13,t,n+2*c[i++]),ot(1,5,9,13,t,n+2*c[i++]),st(2,6,10,14,t,n+2*c[i++]),ot(2,6,10,14,t,n+2*c[i++]),st(3,7,11,15,t,n+2*c[i++]),ot(3,7,11,15,t,n+2*c[i++]),st(0,5,10,15,t,n+2*c[i++]),ot(0,5,10,15,t,n+2*c[i++]),st(1,6,11,12,t,n+2*c[i++]),ot(1,6,11,12,t,n+2*c[i++]),st(2,7,8,13,t,n+2*c[i++]),ot(2,7,8,13,t,n+2*c[i++]),st(3,4,9,14,t,n+2*c[i++]),ot(3,4,9,14,t,n+2*c[i++]);this.v0l^=k[0]^k[16],this.v0h^=k[1]^k[17],this.v1l^=k[2]^k[18],this.v1h^=k[3]^k[19],this.v2l^=k[4]^k[20],this.v2h^=k[5]^k[21],this.v3l^=k[6]^k[22],this.v3h^=k[7]^k[23],this.v4l^=k[8]^k[24],this.v4h^=k[9]^k[25],this.v5l^=k[10]^k[26],this.v5h^=k[11]^k[27],this.v6l^=k[12]^k[28],this.v6h^=k[13]^k[29],this.v7l^=k[14]^k[30],this.v7h^=k[15]^k[31],tt(k)}destroy(){this.destroyed=!0,tt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ua=Yc(e=>new aa(e));function Ls(e,t,n,r,s,o,i,c,u,a,l,d,f,h,p,v,b,y,g,w){let m=0;for(let x=0;x<r;x++)({a:s,b:u,c:f,d:b}=nt(s,u,f,b,n[t+e[m++]])),{a:s,b:u,c:f,d:b}=rt(s,u,f,b,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=nt(o,a,h,y,n[t+e[m++]]),{a:o,b:a,c:h,d:y}=rt(o,a,h,y,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=nt(i,l,p,g,n[t+e[m++]]),{a:i,b:l,c:p,d:g}=rt(i,l,p,g,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=nt(c,d,v,w,n[t+e[m++]]),{a:c,b:d,c:v,d:w}=rt(c,d,v,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=nt(s,a,p,w,n[t+e[m++]]),{a:s,b:a,c:p,d:w}=rt(s,a,p,w,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=nt(o,l,v,b,n[t+e[m++]]),{a:o,b:l,c:v,d:b}=rt(o,l,v,b,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=nt(i,d,f,y,n[t+e[m++]]),{a:i,b:d,c:f,d:y}=rt(i,d,f,y,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=nt(c,u,h,g,n[t+e[m++]]),{a:c,b:u,c:h,d:g}=rt(c,u,h,g,n[t+e[m++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:l,v7:d,v8:f,v9:h,v10:p,v11:v,v12:b,v13:y,v14:g,v15:w}}const hn=ua,Vs=new TextEncoder().encode("SS58PRE"),tr=2,nr=e=>{try{const t=Is.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-tr),s=t.subarray(n.length+r.length),o=hn(Uint8Array.of(...Vs,...n,...r),{dkLen:64}).subarray(0,tr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:la(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},la=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Ds=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=hn(Uint8Array.of(...Vs,...t,...n),{dkLen:64}).subarray(0,tr);return Is.encode(Uint8Array.of(...t,...n,...r))}};function fa(e,t){return n=>{const r=nr(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 vt=(e=42,t=32)=>Ze(Q(t),fa(t),Ds(e)),js="0123456789abcdef";function Z(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=js[r>>4]+js[r&15]}return t.join("")}const rr={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 le(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|rr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=rr[e[i]],u=rr[e[i+1]];s[t+o++]=c<<4|u}return s}function kt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const re=(...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},Ft=Function.prototype;class zs extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var ha=Object.defineProperty,Fs=e=>{throw TypeError(e)},da=(e,t,n)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ht=(e,t,n)=>da(e,typeof t!="symbol"?t+"":t,n),Hs=(e,t,n)=>t.has(e)||Fs("Cannot "+n),Ke=(e,t,n)=>(Hs(e,t,"read from private field"),n?n.call(e):t.get(e)),qt=(e,t,n)=>t.has(e)?Fs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),bt=(e,t,n,r)=>(Hs(e,t,"write to private field"),t.set(e,n),n),Xe,Wt,dn,pn,vn;const pa=new TextEncoder,va=new TextDecoder,ba=Se(ae,Q(1/0))[1];class je{constructor(t,n=!1){if(qt(this,Xe),qt(this,Wt,null),qt(this,dn,null),qt(this,pn,null),qt(this,vn,null),Ht(this,"asText",()=>Ke(this,vn)??bt(this,vn,va.decode(Ke(this,Xe)))),Ht(this,"asHex",()=>Ke(this,dn)||bt(this,dn,Z(Ke(this,Xe)))),Ht(this,"asOpaqueHex",()=>Ke(this,pn)||bt(this,pn,Z(this.asBytes()))),Ht(this,"asBytes",()=>Ke(this,Xe)),Ht(this,"asOpaqueBytes",()=>Ke(this,Wt)||bt(this,Wt,re(ae[0](Ke(this,Xe).length),Ke(this,Xe)))),n){try{const[r,s]=ba(t);if(r===s.length){bt(this,Xe,s),bt(this,Wt,t);return}}catch{}throw new Error("Invalid opaque bytes")}else bt(this,Xe,t)}static fromText(t){return new this(pa.encode(t))}static fromHex(t){return new this(le(t))}static fromOpaqueHex(t){return new this(le(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Xe=new WeakMap,Wt=new WeakMap,dn=new WeakMap,pn=new WeakMap,vn=new WeakMap;const[ya]=vt();class bn extends je{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(ya(t))}}const qs=e=>{const t=Q.enc(e);return n=>t(n.asBytes())},Ws=e=>{const t=Q.dec(e),n=e==null?je:bn;return r=>n.fromBytes(t(r))},Kt=e=>j(qs(e),Ws(e));Kt.enc=qs,Kt.dec=Ws;const _=Ze(ae,e=>e,Number),yn=Ze(ae,e=>e,BigInt),ma=an(e=>{const t=_.dec(e),n=Math.ceil(t/8);return{bytes:Q(n).dec(e),bitsLen:t}}),Ks=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=_.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},ma),ga=Ze(z,e=>e.charCodeAt(0),String.fromCharCode),Xs=e=>{const t=Q.enc(e);return n=>t(le(n))},Ys=e=>{const t=Q.dec(e);return n=>Z(t(n))},Oe=e=>j(Xs(e),Ys(e));Oe.enc=Xs,Oe.dec=Ys;const wa=new TextEncoder,xa=new TextDecoder,Ea=e=>Ze(Q(e),t=>wa.encode(t),t=>xa.decode(t)),Gs=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Ns=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},sr=e=>j(Gs(()=>e().enc),Ns(()=>e().dec)),yt=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}}),Qs=new Proxy({},{get(e,t){return n=>yt(t,n)}}),W=(e,t)=>{const n=e;return n.inner=t,n},Zs=(...e)=>{const t=he.enc(...e);return W(n=>t({tag:n.type,value:n.value}),e[0])},Js=(...e)=>{const t=he.dec(...e);return W(n=>{const{tag:r,value:s}=t(n);return yt(r,s)},e[0])},pe=(e,...t)=>W(j(Zs(kt(e,([n])=>n),...t),Js(kt(e,([,n])=>n),...t)),e);pe.enc=Zs,pe.dec=Js;const or=(e,...t)=>W(he(e,...t),e);or.enc=(e,...t)=>W(he.enc(e,...t),e),or.dec=(e,...t)=>W(he.dec(e,...t),e);const ka=BigInt(0),Xt=BigInt(1),Aa=BigInt(2),Sa=BigInt(7),Ia=BigInt(256),Ba=BigInt(113),eo=[],to=[],no=[];for(let e=0,t=Xt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],eo.push(2*(5*r+n)),to.push((e+1)*(e+2)/2%64);let s=ka;for(let o=0;o<7;o++)t=(t<<Xt^(t>>Sa)*Ba)%Ia,t&Aa&&(s^=Xt<<(Xt<<BigInt(o))-Xt);no.push(s)}const ro=Zc(no,!0),_a=ro[0],Ca=ro[1],so=(e,t,n)=>n>32?oa(e,t,n):ra(e,t,n),oo=(e,t,n)=>n>32?ia(e,t,n):sa(e,t,n);function $a(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],l=n[u+1],d=so(a,l,1)^n[c],f=oo(a,l,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=f}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=to[i],u=so(s,o,c),a=oo(s,o,c),l=eo[i];s=e[l],o=e[l+1],e[l]=u,e[l+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=_a[r],e[1]^=Ca[r]}tt(n)}class ir extends Cs{constructor(t,n,r,s=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,Et(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){ue(this.state32),$a(this.state32,this.rounds),ue(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=De(t),dt(t);const{blockLen:n,state:r}=this,s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){zt(this,!1),dt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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,tt(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new ir(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Oa=(e,t,n)=>Xc(()=>new ir(t,e,n)),Ta=Oa(1,136,256/8),io=e=>{const t=e.slice(2),n=Z(Ta(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),i=t[s];r[s]=o>7?i.toUpperCase():i}return`0x${r.join("")}`},Ra=Q(20)[1],co=j(e=>{const t=le(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=Z(t);if(e===n||e===n.toUpperCase())return t;if(io(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},an(e=>io(Z(Ra(e))))),me=e=>W($(e),e);me.enc=e=>W($.enc(e),e),me.dec=e=>W($.dec(e),e);const Te=(...e)=>W(Se(...e),e);Te.enc=(...e)=>W(Se.enc(...e),e),Te.dec=(...e)=>W(Se.dec(...e),e);const ge=(e,...t)=>W(P(e,...t),e);ge.enc=(e,...t)=>W(P.enc(e,...t),e),ge.dec=(e,...t)=>W(P.dec(e,...t),e);const mn=(e,t)=>W(jt(e,t),{ok:e,ko:t});mn.enc=(e,t)=>W(jt.enc(e,t),{ok:e,ko:t}),mn.dec=(e,t)=>W(jt.dec(e,t),{ok:e,ko:t});const it=e=>W(de(e),e);it.enc=e=>W(de.enc(e),e),it.dec=e=>W(de.dec(e),e);const ao=new TextEncoder,uo=new TextDecoder,Pa=Ze(Q(4),ao.encode.bind(ao),uo.decode.bind(uo)),cr=me({engine:Pa,payload:Oe()}),Ua=pe({consensus:cr,seal:cr,preRuntime:cr,runtimeUpdated:C},[4,5,6,8]),ar=Oe(32),lo=me({parentHash:ar,number:_,stateRoot:ar,extrinsicRoot:ar,digests:ge(Ua)}),we=P(V),fo=de(V),Ma=he({bool:C,char:C,str:C,u8:C,u16:C,u32:C,u64:C,u128:C,u256:C,i8:C,i16:C,i32:C,i64:C,i128:C,i256:C}),ho=P($({name:fo,type:_,typeName:fo,docs:we})),La=$({len:$e,type:_}),Va=$({bitStoreType:_,bitOrderType:_}),Da=P($({name:V,fields:ho,index:z,docs:we})),ja=he({composite:ho,variant:Da,sequence:_,array:La,tuple:P(_),primitive:Ma,compact:_,bitSequence:Va}),za=$({name:V,type:de(_)}),Fa=P(za),Ha=$({id:_,path:we,params:Fa,def:ja,docs:we}),gn=P(Ha),At=he({NotDeprecated:C,DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})}),qa=P($({index:z,deprecation:he({DeprecatedWithoutNote:C,Deprecated:$({note:V,since:de(V)})},[1,2])})),ur={name:V,inputs:P($({name:V,type:_})),output:_,docs:we},Wa=$({name:V,methods:P($(ur)),docs:we}),Ka=$({name:V,methods:P($({...ur,deprecationInfo:At})),docs:we,version:_,deprecationInfo:At}),Xa=$({id:Oe(32),...ur,deprecationInfo:At}),Ya=he({Blake2128:C,Blake2256:C,Blake2128Concat:C,Twox128:C,Twox256:C,Twox64Concat:C,Identity:C}),Ga=P(Ya),Na=$({hashers:Ga,key:_,value:_}),po={name:V,modifier:z,type:he({plain:_,map:Na}),fallback:Oe(),docs:we},lr=de(_),vo={name:V,storage:de($({prefix:V,items:P($(po))})),calls:lr,events:lr,constants:P($({name:V,type:_,value:Oe(),docs:we})),errors:lr,index:z},Qa={...vo,docs:we},fr=de($({type:_,deprecationInfo:qa})),Za={name:V,storage:de($({prefix:V,items:P($({...po,deprecationInfo:At}))})),calls:fr,events:fr,constants:P($({name:V,type:_,value:Oe(),docs:we,deprecationInfo:At})),errors:fr,associatedTypes:P($({name:V,type:_,docs:we})),viewFns:P(Xa),index:z,docs:we,deprecationInfo:At},Ja=new Uint8Array,bo=e=>j(()=>Ja,()=>e),eu=$({type:_,version:z,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),yo=$({lookup:gn,pallets:P($({...vo,docs:bo([])})),extrinsic:eu,type:_,apis:bo([])}),tu=$({version:z,address:_,call:_,signature:_,extra:_,signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),mo=$({lookup:gn,pallets:P($(Qa)),extrinsic:tu,type:_,apis:P(Wa),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),nu=$({version:P(z),address:_,call:_,signature:_,signedExtensionsByVersion:P(Se(z,P(_))),signedExtensions:P($({identifier:V,type:_,additionalSigned:_}))}),go=$({lookup:gn,pallets:P($(Za)),extrinsic:nu,apis:P(Ka),outerEnums:$({call:_,event:_,error:_}),custom:P(Se(V,$({type:_,value:Oe()})))}),wo=()=>{throw new Error("Unsupported metadata version!")},ve=j(wo,wo),ct=$({magicNumber:$e,metadata:he({v0:ve,v1:ve,v2:ve,v3:ve,v4:ve,v5:ve,v6:ve,v7:ve,v8:ve,v9:ve,v10:ve,v11:ve,v12:ve,v13:ve,v14:yo,v15:mo,v16:go})}),hr=Q(),ru=de(hr),su=Se(ae,hr),dr=e=>{try{return ct.dec(e)}catch{}try{return ct.dec(ru.dec(e))}catch{}try{return ct.dec(hr.dec(e))}catch{}try{return ct.dec(su.dec(e)[1])}catch{}throw null},St=e=>{if("magicNumber"in e&&(e=e.metadata),"tag"in e){if(e.tag!=="v14"&&e.tag!=="v15"&&e.tag!=="v16")throw new Error("Only metadata 14, 15, and 16 are supported");e=e.value}if("signedExtensionsByVersion"in e.extrinsic)return{version:16,...e};if("custom"in e){const{lookup:s,extrinsic:o,custom:i,apis:c,pallets:u,outerEnums:a}=e;return{version:15,lookup:s,pallets:u.map(l=>({...l,calls:l.calls!=null?{type:l.calls}:void 0,events:l.events!=null?{type:l.events}:void 0,errors:l.errors!=null?{type:l.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...o,version:[o.version]},apis:c,outerEnums:a,custom:i}}const{lookup:t,extrinsic:n,pallets:r}=e;return{version:14,lookup:t,pallets:r.map(s=>({...s,calls:s.calls!=null?{type:s.calls}:void 0,events:s.events!=null?{type:s.events}:void 0,errors:s.errors!=null?{type:s.errors}:void 0,viewFns:[],associatedTypes:[]})),extrinsic:{...n,version:[n.version]},apis:[]}},ou={dkLen:32},Yt=e=>hn(e,ou),iu={dkLen:16},pr=e=>hn(e,iu),xo=e=>re(pr(e),e),ze={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},Ye=Qc.slice(),Eo=(()=>{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 vr extends Ms{constructor(t={},n=0){super(64,t.dkLen===void 0?32:t.dkLen),this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;const{key:r,context:s}=t,o=s!==void 0;if(r!==void 0){if(o)throw new Error('Only "key" or "context" can be specified at same time');const i=De(r).slice();dt(i,32),this.IV=pt(i),ue(this.IV),this.flags=n|ze.KEYED_HASH}else if(o){const i=De(s),c=new vr({dkLen:32},ze.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=pt(c),ue(this.IV),this.flags=n|ze.DERIVE_KEY_MATERIAL}else this.IV=Ye.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=qc(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=fn(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:f,v4:h,v5:p,v6:v,v7:b,v8:y,v9:g,v10:w,v11:m,v12:x,v13:A,v14:S,v15:O}=Ls(Eo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Ye[0],Ye[1],Ye[2],Ye[3],c,u,i,n);o[0]=a^y,o[1]=l^g,o[2]=d^w,o[3]=f^m,o[4]=h^x,o[5]=p^A,o[6]=v^S,o[7]=b^O}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=ze.CHUNK_START),(this.chunkPos===15||r)&&(s|=ze.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let i,c=this.chunksDone+1;(r||!(c&1))&&(i=this.stack.pop());c>>=1)this.buffer32.set(i,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|ze.PARENT,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:i,chunkOut:c,stack:u,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=u.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=i,t.chunkOut=c,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,tt(this.state,this.buffer32,this.IV,this.bufferOut32),tt(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=fn(BigInt(this.chunkOut++));ue(s);const{v0:u,v1:a,v2:l,v3:d,v4:f,v5:h,v6:p,v7:v,v8:b,v9:y,v10:g,v11:w,v12:m,v13:x,v14:A,v15:S}=Ls(Eo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Ye[0],Ye[1],Ye[2],Ye[3],c,i,n,r);o[0]=u^b,o[1]=a^y,o[2]=l^g,o[3]=d^w,o[4]=f^m,o[5]=h^x,o[6]=p^A,o[7]=v^S,o[8]=t[0]^b,o[9]=t[1]^y,o[10]=t[2]^g,o[11]=t[3]^w,o[12]=t[4]^m,o[13]=t[5]^x,o[14]=t[6]^A,o[15]=t[7]^S,ue(s),ue(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,tt(this.buffer.subarray(this.pos));let t=this.flags|ze.ROOT;this.stack.length?(t|=ze.PARENT,ue(this.buffer32),this.compress(this.buffer32,0,!0),ue(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:ze.CHUNK_START)|ze.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){zt(this,!1),dt(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const i=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return Et(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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 cu=Gc(e=>new vr(e)),au={dkLen:32},ko=e=>cu(e,au),uu=e=>re(ko(e),e),Ao=e=>e,mt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),br=2n**64n-1n,se=(e,t)=>e<<t&br|e>>64n-t,L=(e,t)=>e*t&br,J=(e,t)=>e+t&br,ee=11400714785074694791n,xe=14029467366897019727n,So=1609587929392839161n,Gt=9650029242287828579n,Io=2870177450012600261n;function at(e,t=0n){let n=J(J(t,ee),xe),r=J(t,xe),s=t,o=t-ee,i=e.length,c=0,u=null;(function(){let h=0,p=h+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(h<=p-32){const v=p-32;do{let b;b=mt(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(se(J(n,L(b,xe)),31n),ee),h+=8,b=mt(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(se(J(r,L(b,xe)),31n),ee),h+=8,b=mt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]),s=L(se(J(s,L(b,xe)),31n),ee),h+=8,b=mt(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(se(J(o,L(b,xe)),31n),ee),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(i>=32?(a=se(n,1n),a=J(a,se(r,7n)),a=J(a,se(s,12n)),a=J(a,se(o,18n)),n=L(se(L(n,xe),31n),ee),a=a^n,a=J(L(a,ee),Gt),r=L(se(L(r,xe),31n),ee),a=a^r,a=J(L(a,ee),Gt),s=L(se(L(s,xe),31n),ee),a=a^s,a=J(L(a,ee),Gt),o=L(se(L(o,xe),31n),ee),a=a^o,a=J(L(a,ee),Gt)):a=J(t,Io),a=J(a,BigInt(i));l<=c-8;){let f=mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]);f=L(se(L(f,xe),31n),ee),a=J(L(se(a^f,27n),ee),Gt),l+=8}if(l+4<=c){let f=L(mt(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),ee);a=J(L(se(a^f,23n),xe),So),l+=4}for(;l<c;){const f=L(mt(e[l++],0,0,0),Io);a=L(se(a^f,11n),ee)}let d=a>>33n;return a=L(a^d,xe),d=a>>29n,a=L(a^d,So),d=a>>32n,a^=d,a}const wn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),t},Bo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,at(e),!0),n.setBigUint64(8,at(e,1n),!0),n.setBigUint64(16,at(e,2n),!0),n.setBigUint64(24,at(e,3n),!0),t},_o=e=>re(Dt.enc(at(e)),e),Co=new TextEncoder,lu=new Map([[Ao,0],[_o,8],[xo,16],[pr,-16],[Yt,-32],[wn,-16],[Bo,-32]]),$o=e=>{const t=wn(Co.encode(e));return(n,...r)=>{const s=re(t,wn(Co.encode(n))),o=Z(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const l=le(a.slice(o.length)),d=new Array(r.length);for(let f=0,h=0;f<r.length;f++){const[p,v]=r[f],b=lu.get(v);if(b==null)throw new Error("Unknown hasher");if(b<0){const y=b*-1;d[f]=Z(l.slice(h,h+y)),h+=y}else h+=b,d[f]=p.dec(l.slice(h)),h+=p.enc(d[f]).length}return d},c=r.map(([{enc:a},l])=>d=>l(a(d)));return{enc:(...a)=>Z(re(s,...a.map((l,d)=>c[d](l)))),dec:i}}},fu=je.fromText("modlpy/utilisuba").asBytes(),hu=({threshold:e,signatories:t})=>{const n=Oo(t),r=re(fu,ae.enc(n.length),...n,et.enc(e));return Yt(r)},Oo=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 To=Object.freeze({__proto__:null,AccountId:vt,Bin:Kt,Binary:je,Blake2128:pr,Blake2128Concat:xo,Blake2256:Yt,Blake3256:ko,Blake3256Concat:uu,Bytes:Q,Enum:yt,FixedSizeBinary:bn,Hex:Oe,Identity:Ao,Option:it,Result:mn,ScaleEnum:or,Self:sr,Storage:$o,Struct:me,Tuple:Te,Twox128:wn,Twox256:Bo,Twox64Concat:_o,Variant:pe,Vector:ge,_Enum:Qs,_void:C,bitSequence:Ks,blockHeader:lo,bool:wc,char:ga,compact:ae,compactBn:yn,compactNumber:_,createCodec:j,createDecoder:an,decAnyMetadata:dr,enhanceCodec:Ze,enhanceDecoder:Qn,enhanceEncoder:Vt,ethAccount:co,fixedStr:Ea,fromBufferToBase58:Ds,getMultisigAccountId:hu,getSs58AddressInfo:nr,h64:at,i128:yc,i16:pc,i256:gc,i32:vc,i64:bc,i8:dc,metadata:ct,selfDecoder:Ns,selfEncoder:Gs,sortMultisigSignatories:Oo,str:V,u128:os,u16:et,u256:mc,u32:$e,u64:Dt,u8:z,unifyMetadata:St,v14:yo,v14Lookup:gn,v15:mo,v16:go});const Ge=_,du=ge(Te(V,Ge)),D={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},pu=pe(Object.fromEntries(Object.values(D).map(e=>[e,C]))),vu=ge(Te(V,pe({inline:sr(()=>yr),lookup:Ge}))),bu=ge(Ge),yu=me({typeRef:Ge,length:it(Ge)}),mu=it(Ge),gu=Ge,wu=me({ok:Ge,ko:Ge}),yr=pe({struct:du,terminal:pu,enum:vu,tuple:bu,array:yu,binary:mu,option:gu,result:wu}),xu={i256:D.big,i128:D.big,i64:D.big,i32:D.num,i16:D.num,i8:D.num,u256:D.big,u128:D.big,u64:D.big,u32:D.num,u16:D.num,u8:D.num,bool:D.bool,char:D.str,str:D.str},Nt=e=>({type:"terminal",value:{type:e}});function xn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return Nt(D.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 Nt(D.bits);case"compact":return Nt(e.isBig?D.big:D.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:xn(r,t)}]:(t(r.value.id),[n,{type:"lookup",value:r.value.id}]))};case"struct":{const n=Object.entries(e.value).map(([r,s])=>[r,s.id]);return n.forEach(([,r])=>t(r)),{type:"struct",value:n}}case"tuple":{const n=e.value.map(r=>r.id);return n.forEach(t),{type:"tuple",value:n}}case"option":return t(e.value.id),{type:"option",value:e.value.id};case"primitive":return Nt(xu[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 Nt(D.void)}}function mr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>mr(o,i,n),s=o=>{switch(o.value.type){case D.str:case D.big:case D.bool:case D.num:return typeof e===o.value.type;case D.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case D.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof je&&(t.value==null||e.asBytes().length>=t.value);case"array":if(!Array.isArray(e))return!1;const o=e;return t.value.length!=null&&o.length<t.value.length?!1:o.slice(0,t.value.length).every(a=>r(a,n(t.value.typeRef)));case"enum":if(!e)return!1;const i=e,c=Object.fromEntries(t.value);if(!(i.type in c))return!1;const u=c[i.type];return u==null?!0:r(i.value,u.type==="inline"?u.value:n(u.value));case"option":return e==null?!0:r(e,n(t.value));case"struct":return e?t.value.every(([a,l])=>r(e[a],n(l))):!1;case"tuple":return e?t.value.every((a,l)=>r(e[l],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var Eu=Object.defineProperty,ku=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Au=(e,t,n)=>ku(e,t+"",n);class Ro{constructor(t=[]){Au(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 Ie=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Ie||{});function gr(e,t,n,r,s){if(!n&&!e)return be(3);if(!n)return be(2);if(!e)return be(n.type==="option"?2:0);s.has(n)||s.set(n,new Map);const o=s.get(n);if(o.has(e)){const c=o.get(e);return c===null?{level:3,assumptions:new Ro([[e,n]])}:be(c)}o.set(e,null);const i=Su(e,n,(c,u)=>gr(typeof c=="number"?t(c):c,t,typeof u=="number"?r(u):u,r,s));return i.assumptions.delete(e,n),i.assumptions.isEmpty()||i.level===0?o.set(e,i.level):o.delete(e),i}function Su(e,t,n){if(e.type!==t.type)return t.type==="option"?En(n(e,t.value),2):e.type==="option"?En(n(e.value,t),1):be(0);switch(t.type){case"terminal":return be(t.value.type===e.value.type?3:0);case"binary":return be(Uo(e.value,t.value));case"array":const s=e,o=be(Uo(s.value.length,t.value.length));return wr([o,()=>n(s.value.typeRef,t.value.typeRef)]);case"enum":{const l=e,d=Object.fromEntries(t.value.map(([h,p])=>[h,p.value])),f=l.value.length===t.value.length?3:2;return En(Po(l.value.map(([h,p])=>()=>h in d?n(p.value,d[h]):be(0))),f)}case"option":return n(e.value,t.value);case"struct":const i=e,c=Object.fromEntries(i.value),u=i.value.length===t.value.length?3:2;return En(wr(t.value.map(([l,d])=>()=>n(c[l],d))),u);case"tuple":{const l=e,d=be(Bu(l.value,t.value));return wr([d,...t.value.map((f,h)=>()=>n(l.value[h],f))])}case"result":const a=e;return Po([n(a.value.ok,t.value.ok),n(a.value.ko,t.value.ko)])}}const En=(e,t)=>({...e,level:Math.min(e.level,t)}),Iu=new Ro,be=e=>({level:e,assumptions:Iu}),wr=e=>{let t=be(3);for(const n of e){const r=typeof n=="function"?n():n;if(r.level===0)return r;t.assumptions.addAll(r.assumptions.values),t.level=Math.min(t.level,r.level)}return t},Po=e=>{if(!e.length)return be(3);let t=!1,n=be(3);for(const r of e){const s=typeof r=="function"?r():r;if(s.level===0){n.level=Math.min(n.level,1);continue}t=!0,n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return t?n:be(0)},Bu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Uo=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Mo=pe({lookup:_,typedef:yr}),It=e=>({type:"lookup",value:e}),xr=e=>({type:"typedef",value:e}),kn=xr({type:"terminal",value:{type:D.void}}),_u=me({args:Mo,values:Mo});function Cu(e){if(e.type.tag==="plain")return{args:kn,values:It(e.type.value)};const{key:t,value:n}=e.type.value;return{args:It(t),values:It(n)}}function Lo(e){return{args:xr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:It(e.output)}}function $u(e){return e.type==="lookupEntry"?It(e.value.id):xr(xn(e))}function Ou(e){return{args:kn,values:It(e)}}function Tu(e,t,n,r,s){const o=(i,c)=>i.type==="lookup"?c(i.value):i.value;return{args:gr(o(e.args,t),t,o(n.args,r),r,s).level,values:gr(o(n.values,r),r,o(e.values,t),t,s).level}}function Vo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return mr(n,r,t)}const Bt=()=>{},Be={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},An={chainName:"",genesisHash:"",properties:""},Er={broadcast:"",stop:""};Object.entries({chainHead:Be,chainSpec:An,transaction:Er}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});const Ru=e=>(t,n)=>{let r=e(Er.broadcast,[t],{onSuccess:s=>{r=s===null?Bt:()=>{e(Er.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};class Do extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Sn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class In extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class jo extends Error{constructor(t){super(t),this.name="OperationError"}}class Bn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}function Pu(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const zo=()=>{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)})}}},_n=e=>(...t)=>new Promise((n,r)=>{let s=Ft;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new zs)};i?.addEventListener("abort",c,{once:!0});const u=a=>l=>{s=Ft,i?.removeEventListener("abort",c),a(l)};s=e(u(n),u(r),...o)}),Fo=(e,t)=>n=>_n((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(l,d)=>{if(l.result==="limitReached")return s(new In);const{operationId:f}=l,h=()=>{n(Be.stopOperation,[f])};if(!i)return h();let p=Bt;const v=y=>{i=!1,p(),r(y)},b=y=>{i=!1,p(),s(y)};p=d(f,{next:y=>{const g=y;g.event==="operationError"?s(new jo(g.error)):g.event==="operationInaccessible"?s(new Bn):a(y,v,b)},error:b}),c=()=>{i&&(p(),h())}},onError:s}),()=>{c()}}),Uu=Fo(Be.body,e=>[[e],(t,n)=>{n(t.value)}]),Mu=Fo(Be.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),Lu=e=>t=>new Promise((n,r)=>{e(Be.header,[t],{onSuccess:n,onError:r})}),Ho=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),Ft;let u=!0,a=()=>{u=!1};return e(Be.storage,[t,n,r],{onSuccess:(l,d)=>{if(l.result==="limitReached"||l.discardedItems===n.length)return o(new In);const{operationId:f}=l,h=()=>{e(Be.stopOperation,[f])};if(!u)return h();const p=d(l.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{b();break}case"operationError":{v(new jo(y.error));break}case"operationInaccessible":{v(new Bn);break}default:e(Be.continue,[y.operationId])}},error:o});a=()=>{p(),e(Be.stopOperation,[l.operationId])};const v=y=>{a=Ft,p(),o(y)},b=()=>{a=Ft,p(),i()};c(l.discardedItems)},onError:o}),()=>{a()}},Vu=e=>{const t=Ho(e);return _n((n,r,s,o,i,c)=>{const u=o.startsWith("descendants");let a=u?[]:null;const d=t(s,[{key:i,type:o}],c??null,u?f=>{a.push(f)}:f=>{a=f[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(f){r(f)}},f=>{f>0&&(d(),r(new In))});return d})},Du=e=>t=>t.length>0?new Promise((n,r)=>{e(Be.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();class Cn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}function ju(e){return e.operationId!==void 0}function zu(e){return(t,n,r)=>{const s=zo(),o=new Set,i=Pu();let c=i.promise;const u=p=>{if(ju(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);if(p.event!=="stop"){if(p.event==="initialized")return n({type:p.event,finalizedBlockHashes:p.finalizedBlockHashes,finalizedBlockRuntime:p.finalizedBlockRuntime});const{event:v,...b}=p;return n({type:v,...b})}r(new Do),f(!1)},a=p=>{r(p),f(!(p instanceof Cn))},l=(p,v)=>{const b=v(p,{next:u,error:a});f=(y=!0)=>{c=null,f=Bt,b(),y&&e(Be.unfollow,[p]),s.errorAll(new Sn),o.forEach(g=>{g()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof Cn?f(!1):r(p),c=null,i.res(p)};let f=e(Be.follow,[t],{onSuccess:l,onError:d});const h=(p,v,b)=>{const y=()=>{b?.onError(new Sn)};if(c===null)return y(),Bt;const g=m=>{if(!b)return e(p,[m,...v]);o.add(y);const x=(S,O)=>c===null?(O.error(new Sn),Bt):(s.subscribe(S,O),()=>{s.unsubscribe(S)}),A=e(p,[m,...v],{onSuccess:S=>{o.delete(y),b.onSuccess(S,x)},onError:S=>{o.delete(y),b.onError(S)}});return()=>{o.delete(y),A()}};if(typeof c=="string")return g(c);let w=Bt;return c.then(m=>{if(m instanceof Error)return y();c&&(w=g(m))}),()=>{w()}};return{unfollow(){f(),c=null},body:Uu(h),call:Mu(h),header:Lu(h),storage:Vu(h),storageSubscription:Ho(h),unpin:Du(h),_request:h}}}var Fu=Object.defineProperty,Hu=(e,t,n)=>t in e?Fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qo=(e,t,n)=>Hu(e,typeof t!="symbol"?t+"":t,n);class Wo extends Error{constructor(t){super(t.message),qo(this,"code"),qo(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}let qu=1;const Wu=e=>{let t=qu++;const n=new Map,r=zo();let s=null;const o=(l,d,f)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:l,method:d,params:f}))};function i(l){try{let d,f,h,p,v;if({id:d,result:f,error:h,params:p}=JSON.parse(l),d){const g=n.get(d);return g?(n.delete(d),h?g.onError(new Wo(h)):g.onSuccess(f,(w,m)=>{const x=w;return r.subscribe(x,m),()=>{r.unsubscribe(x)}})):void 0}if({subscription:v,result:f,error:h}=p,!v||!h&&!Object.hasOwn(p,"result"))throw 0;const y=v;h?r.error(y,new Wo(h)):r.next(y,f)}catch(d){console.warn("Error parsing incomming message: "+l),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Cn),n.forEach(l=>l.onError(new Cn)),n.clear()};let u=1;return{request:(l,d,f)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return f&&n.set(h,f),o(h,l,d),()=>{n.delete(h)}},disconnect:c}},Ku=e=>{const t=_n((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(An.chainName,[]),t(An.genesisHash,[]),t(An.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},$n=new Map,Xu=e=>{const t=$n.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Wu(e),s=()=>{const i=$n.get(e);!i||i.refCount<=1?($n.delete(e),r()):i.refCount--},o={chainHead:zu(n),transaction:Ru(n),getChainSpecData:Ku(n),destroy:s,request:_n((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return $n.set(e,{client:o,refCount:1}),o};var kr=function(e,t){return kr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},kr(e,t)};function Fe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Yu(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function c(l){try{a(r.next(l))}catch(d){i(d)}}function u(l){try{a(r.throw(l))}catch(d){i(d)}}function a(l){l.done?o(l.value):s(l.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Ko(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(a){return function(l){return u([a,l])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(o=a[0]&2?s.return:a[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;switch(s=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1],o=a;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(a);break}o[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function _t(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Re(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,o=[],i;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return o}function Pe(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,o;r<s;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function Ct(e){return this instanceof Ct?(this.v=e,this):new Ct(e)}function Gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(h){return function(p){return Promise.resolve(p).then(h,d)}}function c(h,p){r[h]&&(s[h]=function(v){return new Promise(function(b,y){o.push([h,v,b,y])>1||u(h,v)})},p&&(s[h]=p(s[h])))}function u(h,p){try{a(r[h](p))}catch(v){f(o[0][3],v)}}function a(h){h.value instanceof Ct?Promise.resolve(h.value.v).then(l,d):f(o[0][2],h)}function l(h){u("next",h)}function d(h){u("throw",h)}function f(h,p){h(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Nu(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 _t=="function"?_t(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(i){return new Promise(function(c,u){i=e[o](i),s(c,u,i.done,i.value)})}}function s(o,i,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},i)}}typeof SuppressedError=="function"&&SuppressedError;function F(e){return typeof e=="function"}function Ar(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Sr=Ar(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
2
2
  `+n.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=n}});function On(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,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=Bt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(F(l))try{l()}catch(v){o=v instanceof Sr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=Bt(d),h=f.next();!h.done;h=f.next()){var p=h.value;try{Go(p)}catch(v){o=o??[],v instanceof Sr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Sr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Go(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)&&On(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&On(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Xo=Ct.EMPTY;function Yo(e){return e instanceof Ct||e&&"closed"in e&&F(e.remove)&&F(e.add)&&F(e.unsubscribe)}function Go(e){F(e)?e():e.unsubscribe()}var Qu={Promise:void 0},Zu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function No(e){Zu.setTimeout(function(){throw e})}function Ue(){}function Tn(e){e()}var Qt=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Yo(n)&&n.add(r)):r.destination=tl,r}return t.create=function(n,r,s){return new $t(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Ct),Ju=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){Rn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Rn(r)}else Rn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Rn(n)}},e}(),$t=function(e){Fe(t,e);function t(n,r,s){var o=e.call(this)||this,i;return F(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new Ju(i),o}return t}(Qt);function Rn(e){No(e)}function el(e){throw e}var tl={closed:!0,next:Ue,error:el,complete:Ue},Ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ne(e){return e}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zo(e)}function Zo(e){return e.length===0?Ne:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(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 s=this,o=rl(t)?t:new $t(t,n,r);return Tn(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Jo(n),new n(function(s,o){var i=new $t({next:function(c){try{t(c)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Zo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Jo(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e}();function Jo(e){var t;return(t=e??Qu.Promise)!==null&&t!==void 0?t:Promise}function nl(e){return e&&F(e.next)&&F(e.error)&&F(e.complete)}function rl(e){return e&&e instanceof Qt||nl(e)&&Yo(e)}function sl(e){return F(e?.lift)}function X(e){return function(t){if(sl(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 H(e,t,n,r,s){return new ol(e,t,n,r,s)}var ol=function(e){Fe(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}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}(Qt),il=Ar(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Me=function(e){Fe(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 ei(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new il},t.prototype.next=function(n){var r=this;Tn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Bt(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;Tn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;Tn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,c=s.observers;return o||i?Xo:(this.currentObservers=null,c.push(n),new Ct(function(){r.currentObservers=null,On(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ei(n,r)},t}(T),ei=function(e){Fe(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:Xo},t}(Me),cl=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Me),Br={now:function(){return(Br.delegate||Date).now()},delegate:void 0},Pn=function(e){Fe(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Br);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.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),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Me),al=function(e){Fe(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(Ct),ti={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ul=function(e){Fe(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),ti.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&ti.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,On(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(al),ni=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=Br.now,e}(),ll=function(e){Fe(t,e);function t(n,r){r===void 0&&(r=ni.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t}(ni),ri=new ll(ul),fl=ri,gt=new T(function(e){return e.complete()});function si(e){return e&&F(e.schedule)}function _r(e){return e[e.length-1]}function Cr(e){return F(_r(e))?e.pop():void 0}function Zt(e){return si(_r(e))?e.pop():void 0}function hl(e,t){return typeof _r(e)=="number"?e.pop():t}var oi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ii(e){return F(e?.then)}function ci(e){return F(e[Ir])}function ai(e){return Symbol.asyncIterator&&F(e?.[Symbol.asyncIterator])}function ui(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 dl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var li=dl();function fi(e){return F(e?.[li])}function hi(e){return Gu(this,arguments,function(){var n,r,s,o;return Ko(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,_t(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,_t(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,_t(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function di(e){return F(e?.getReader)}function oe(e){if(e instanceof T)return e;if(e!=null){if(ci(e))return pl(e);if(oi(e))return vl(e);if(ii(e))return bl(e);if(ai(e))return pi(e);if(fi(e))return yl(e);if(di(e))return ml(e)}throw ui(e)}function pl(e){return new T(function(t){var n=e[Ir]();if(F(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function vl(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function bl(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,No)})}function yl(e){return new T(function(t){var n,r;try{for(var s=Bt(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function pi(e){return new T(function(t){gl(e,t).catch(function(n){return t.error(n)})})}function ml(e){return pi(hi(e))}function gl(e,t){var n,r,s,o;return Yu(this,void 0,void 0,function(){var i,c;return Ko(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Nu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ut(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function vi(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function bi(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function wl(e,t){return oe(e).pipe(bi(t),vi(t))}function xl(e,t){return oe(e).pipe(bi(t),vi(t))}function El(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 kl(e,t){return new T(function(n){var r;return ut(n,t,function(){r=e[li](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return F(r?.return)&&r.return()}})}function yi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Al(e,t){return yi(hi(e),t)}function Sl(e,t){if(e!=null){if(ci(e))return wl(e,t);if(oi(e))return El(e,t);if(ii(e))return xl(e,t);if(ai(e))return yi(e,t);if(fi(e))return kl(e,t);if(di(e))return Al(e,t)}throw ui(e)}function Ot(e,t){return t?Sl(e,t):oe(e)}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return Ot(e,n)}function Un(e,t){var n=F(e)?e:function(){return e},r=function(s){return s.error(n())};return new T(r)}var mi=Ar(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Il(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new mi)}})})}function Le(e,t){return new Promise(function(n,r){var s=new $t({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new mi)}});e.subscribe(s)})}function Bl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var _l=Array.isArray;function Cl(e,t){return _l(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function gi(e){return I(function(t){return Cl(e,t)})}var $l=Array.isArray,Ol=Object.getPrototypeOf,Tl=Object.prototype,Rl=Object.keys;function Pl(e){if(e.length===1){var t=e[0];if($l(t))return{args:t,keys:null};if(Ul(t)){var n=Rl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Ul(e){return e&&typeof e=="object"&&Ol(e)===Tl}function Ml(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Tt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=Cr(e),s=Pl(e),o=s.args,i=s.keys;if(o.length===0)return Ot([],n);var c=new T(wi(o,n,i?function(u){return Ml(i,u)}:Ne));return r?c.pipe(gi(r)):c}function wi(e,t,n){return n===void 0&&(n=Ne),function(r){xi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){xi(t,function(){var d=Ot(e[l],t),f=!1;d.subscribe(H(r,function(h){o[l]=h,f||(f=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function xi(e,t,n){e?ut(n,e,t):t()}function Ll(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,f=function(){d&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;oe(n(v,l++)).subscribe(H(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{a--;for(var y=function(){var g=u.shift();i||p(g)};u.length&&a<r;)y();f()}catch(g){t.error(g)}}))};return e.subscribe(H(t,h,function(){d=!0,f()})),function(){}}function M(e,t,n){return n===void 0&&(n=1/0),F(t)?M(function(r,s){return I(function(o,i){return t(r,o,s,i)})(oe(e(r,s)))},n):(typeof t=="number"&&(n=t),X(function(r,s){return Ll(r,s,e,n)}))}function Mn(e){return e===void 0&&(e=1/0),M(Ne,e)}function Vl(){return Mn(1)}function $r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vl()(Ot(e,Zt(e)))}function Ln(e){return new T(function(t){oe(e()).subscribe(t)})}var Dl={connector:function(){return new Me},resetOnDisconnect:!0};function jl(e,t){t===void 0&&(t=Dl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Ln(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Vn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=fl);var r=-1;return t!=null&&(si(t)?n=t:r=t),new T(function(s){var o=Bl(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=hl(e,1/0),s=e;return s.length?s.length===1?oe(s[0]):Mn(r)(Ot(s,n)):gt}var zl=Array.isArray;function Fl(e){return e.length===1&&zl(e[0])?e[0]:e}function _e(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return X(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=oe(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Hl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function Ei(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return n?Qo(Ei.apply(void 0,Pe([],Re(e))),gi(n)):X(function(r,s){wi(Pe([r],Re(Fl(e))))(s)})}function ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ei.apply(void 0,Pe([],Re(e)))}function Wl(e,t){return F(t)?M(e,t,1):M(e,1)}function te(e){return e<=0?function(){return gt}:X(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Kl(e){return I(function(){return e})}function Xl(e,t){return M(function(n,r){return oe(e(n,r)).pipe(te(1),Kl(n))})}function Yl(e,t){t===void 0&&(t=ri);var n=Vn(e,t);return Xl(function(){return n})}function Gl(e,t){return X(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&oe(t).subscribe(H(r,function(){return s.clear()},Ue))})}function fe(e,t){return t===void 0&&(t=Ne),e=e??Nl,X(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Nl(e,t){return e===t}function Ql(e,t){return X(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),oe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Zl(){return X(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Jt(e,t){return X(Hl(e,t,arguments.length>=2,!0))}function en(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Me}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,f,h=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},y=function(){b(),l=f=void 0,p=v=!1},g=function(){var w=l;y(),w?.unsubscribe()};return X(function(w,m){h++,!v&&!p&&b();var x=f=f??n();m.add(function(){h--,h===0&&!v&&!p&&(d=Tr(g,u))}),x.subscribe(m),!l&&h>0&&(l=new $t({next:function(A){return x.next(A)},error:function(A){v=!0,b(),d=Tr(y,s,A),x.error(A)},complete:function(){p=!0,b(),d=Tr(y,i),x.complete()}}),oe(w).subscribe(l))})(a)}}function Tr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var s=new $t({next:function(){s.unsubscribe(),e()}});return oe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function Dn(e,t,n){var r,s,o,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,en({connector:function(){return new Pn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function ki(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return X(function(r,s){(n?$r(e,r,n):$r(e,r)).subscribe(s)})}function jn(e,t){return X(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;oe(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function Jl(){return jn(Ne)}function Ai(e){return X(function(t,n){oe(e).subscribe(H(n,function(){return n.complete()},Ue)),!n.closed&&t.subscribe(n)})}function Si(e,t){return t===void 0&&(t=!1),X(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Ii(e,t,n){var r=F(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Ne}function Rr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return X(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){oe(e[d]).subscribe(H(s,function(f){i[d]=f,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ne))&&(c=null))},Ue))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var f=Pe([d],Re(i));s.next(n?n.apply(void 0,Pe([],Re(f))):f)}}))})}var ef=Object.defineProperty,tf=(e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bi=(e,t,n)=>tf(e,typeof t!="symbol"?t+"":t,n);class nf{constructor(){Bi(this,"first"),Bi(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 rf=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new nf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const p=h?s:o;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:p}=f;let v=!1;const b=h.subscribe({next(y){p.next(y)},error(y){(v=y instanceof In)?i(f,!0):p.error(y)},complete(){p.complete()}});b.closed?v||c():t(h,()=>{b.unsubscribe(),c()})},a=(f=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):i(v,f),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Rt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const sf=new Set(["best","finalized",null]),_i=e=>{const t=e.pipe(lt(n=>n instanceof Bn?Vn(750).pipe(Wl(()=>t)):Un(()=>n)));return t},of=(e,t,n)=>r=>(s,...o)=>{if(!sf.has(s))return _i(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(te(1),M(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Rt?c:Un(()=>u)));return _i(c)},Ci=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),cf=e=>t=>(...n)=>e()[t](...n);function zn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:f=>{const h=f.blocks.get(r);h?h.recovering?c?.unsubscribe():a():l&&i.error(new Rt(r,n)),l=f.recovering},error:f=>i.error(f)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const af=e=>e.pipe(Jt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),M(({newBlocks:t})=>t),en()),uf=(e,t)=>{const n=(r,s,o,i)=>new T(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Mn(),t(i));return n},lf=e=>t=>new T(n=>{let r=null;return t.subscribe({next(s){s.type==="initialized"?(r=[],e(s.finalizedBlockHashes[0]).then(o=>{n.closed||(n.next({...s,number:o.number,parentHash:o.parentHash}),r.forEach(i=>{n.next(i)}),r=null)}).catch(o=>{n.closed||n.error(o)})):r?r.push(s):n.next(s)},error(s){n.error(s)},complete(){n.complete()}})}),ff=e=>{let t=null,n=Ue;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(lo.dec),o=jl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(lf(s),hf()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},hf=()=>e=>new T(t=>{const n=new Ct,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Do?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),$i=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},df=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let f=n.get(d);if(f)return f;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=l(d);return f=n.get(d),f?Object.assign(f,h):(f={id:d,...h},n.set(d,f)),r.delete(d),f};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:f,path:h,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return ft;if(f.value.length===1){const v=c(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&$i(v,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&$i(v,20)?(i=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(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(f.value.length===0)return ft;const v={},b={};return f.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){v[g]={...ft,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[g]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[g]={...u(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:b}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:v}=f.value,b=c(f.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:f.value.len}:b}if(f.tag==="tuple")return f.value.length===0?ft:f.value.length>1?a(f.value.map(v=>c(v)),f.value.map(v=>e[v].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=c(f.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:f.tag}}),u=l=>{let d=!0;const f={},h={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,y=c(p.type);y.type!=="void"&&(f[b]=y,h[b]=p.docs)}),d?{type:"struct",value:f,innerDocs:h}:a(Object.values(f),Object.values(h))},a=(l,d)=>{if(l.every(f=>f.id===l[0].id)&&d.every(f=>!f.length)){const[f]=l;return f.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Fn=e=>{const t=df(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},pf=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},vf=Kt(),Oi=pf((e,t,n,r)=>{if(e.type==="primitive")return To[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return co;if(e.type==="compact")return e.isBig?yn:_;if(e.type==="bitSequence")return Ks;const s=h=>Oi(h,t,n,r),o=(h,p)=>{const v=s(h);return p?ge(v,p):ge(v)},i=h=>Te(...h.map(s)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,b])=>[v,s(b)]));return me(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return vf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Kt(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return mn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return C;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,p)=>h===p)?pe(a):pe(a,l);return e.byteLength?bf(f,e.byteLength):f},sr,e=>e),Ti=(e,t=vt())=>{const n=new Map,r=s=>Oi(e(s),n,new Set,t);return s=>r(s)},bf=(e,t)=>{const n=Q(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Pr=e=>{const{metadata:t}=e;let n=Ti(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let s;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(s=f,n=Ti(e,vt(f)))}catch{}const o=new Map,i=(f,h)=>{let p=o.get(f);p||o.set(f,p=$o(f));const v=t.pallets.find(S=>S.name===f).storage.items.find(S=>S.name===h),b=(S,O,...U)=>{const Y=p(...U),[,...N]=U;return{args:Te(...N.map(([q])=>q)),keys:Y,value:O,len:S,fallback:v.modifier===1?O.dec(v.fallback):void 0}};if(v.type.tag==="plain")return b(0,n(v.type.value),h);const{key:y,value:g,hashers:w}=v.type.value,m=n(g),x=w.map(S=>To[S.tag]),A=(()=>{if(x.length===1)return[[n(y),x[0]]];const S=e(y);switch(S.type){case"array":return x.map(O=>[n(S.value.id),O]);case"tuple":return S.value.map((O,U)=>[n(O.id),x[U]]);default:throw new Error("Invalid key type")}})();return b(x.length,m,h,...A)},c=f=>{switch(f.type){case"void":return C;case"lookupEntry":return n(f.value.id);case"tuple":return Te(...Object.values(f.value).map(h=>n(h.id)));case"struct":return me(Et(f.value,h=>n(h.id)));case"array":return ge(n(f.value.id),f.len)}},u=(f,h)=>{const p=t.pallets.find(v=>v.name===f).constants.find(v=>v.name===h);return n(p.type)},a=f=>(h,p)=>{const v=t.pallets.find(g=>g.name===h),b=e(v[f].type);if(b.type!=="enum")throw null;const y=b.value[p];return{location:[v.index,y.idx],codec:c(b.value[p])}},l=(f,h)=>{const p=t.pallets.find(v=>v.name===f)?.viewFns.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}},d=(f,h)=>{const p=t.apis.find(v=>v.name===f)?.methods.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},yf=e=>Z($e.enc(e)),Ri=Q(),mf=it(Ri),gf=ge($e).dec,wf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Rt)return r(c,u);if(l instanceof Bn)return Vn(750).pipe(M(()=>r(c,u)));throw l})):gt},s=r("Metadata_metadata_versions","").pipe(I(gf)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Ri.dec(c),a=ct.dec(u);return{metadata:At(a),metadataRaw:u}})),i=c=>r("Metadata_metadata_at_version",yf(c)).pipe(I(u=>{const a=mf.dec(u),l=ct.dec(a);return{metadata:At(l),metadataRaw:a}}));return s.pipe(lt(()=>He([14])),M(c=>c.includes(16)?i(16):c.includes(15)?i(15):o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Fn(c),l=Pr(a),d=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(f){const p=a(f.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:d.keys.enc(),dec:d.value.dec},accountId:vt(l.ss58Prefix)}}),Dn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},tn=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Pi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ui=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},xf=(e,t)=>{t.forEach(n=>{Ui(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},Ef=(e,t,n,r,s)=>{const o=new Me,i=o.pipe(Ql(()=>Vn(0)),I(()=>({type:"cleanup"}))),c=Or(n,i,e).pipe(Jt((a,l)=>{const d=f=>{xf(a,f),r(f)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Mi()));const[f]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=f;const h=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const y=a.blocks.get(v);y?(y.recovering=!1,y.unpinnable=b!==h):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===h?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==h,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(f));return a.finalizedRuntime=p??(a.runtimes[f]=u(Pi(a,f))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const y=a.blocks.get(v);y.children.add(b);const g={hash:b,number:y.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:y.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Pi(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(Ui(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(y=>{const g=a.blocks.get(y);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:y})=>b&&!y).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Mi()),_e(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),tn),u=wf(zn(c,t,"pinned-blocks"));return c},Mi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Li=(e,t,n,r)=>{const s=c=>Ai(e.pipe(_e(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return He({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(M(d=>{const f=d.indexOf(u);return f>-1?l(r(c)).pipe(I(h=>({hash:c,found:{type:!0,index:f,events:h}}))):n(c,u).pipe(I(h=>({hash:c,found:{type:!1,validity:h}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(M(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?He(l):e.pipe(s(c),M(f=>f.blocks.get(c).children),Gl(),M(f=>i(f,u,a)))}));return c=>e.pipe(te(1),M(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},kf=new Uint8Array([2]),Af=(e,t)=>Z(re(kf,le(e),le(t))),Vi="TaggedTransactionQueue",Di="validate_transaction",[,Sf]=pe({InvalidTransaction:pe({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:z,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:pe({CannotLookup:C,NoUnsignedValidator:C,Custom:z})}),If=an(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Sf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Bf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Vi,Di).value[1]}catch{return If}}));return e(n,`${Vi}_${Di}`,Af(r,n)).pipe(Rr(s),I(([o,i])=>i(o)))},_f=e=>t=>new T(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),Cf=e=>t=>new T(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),ji=(e,t=1/0)=>n=>new T(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const f=o.get(a);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),l!==h&&c.set(h,[]);let p=!1,v=f.subscribe({next(b){l===h?r.next(b):c.get(h).push(b)},complete(){if(p=!0,i.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(h,v)};return s=n.subscribe({next(f){const h=u++;o.set(h,Ln(()=>e(f,h))),i.size<t&&d()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}}),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Ur=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),$f=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=ff(e),o=cf(t),{withRecovery:i,withRecoveryFn:c}=rf(),u=new Me,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>B=>new T(R=>{const K=a(E),ie=B.subscribe(R);return ie.add(K),ie}),d=E=>(B,...R)=>E(B,...R).pipe(l(B)),f=(E,B)=>(R,...K)=>new T(ie=>{let ye=!1;return b.pipe(te(1)).subscribe(Ce=>{ye=Ce.blocks.has(R)}),ye?E(R,...K).subscribe(ie):ie.error(new Rt(R,B))}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof Sn))throw B}),p=(E,B)=>f(d(zn(b,c(Ci(E)),`stop-${B}`)),B),v=new Map,b=Ef(r,d(c(Ci(o("call")))),u,E=>{h(E),E.forEach(B=>{v.delete(B)})},E=>{v.delete(E)}),y=d(E=>b.pipe(te(1),M(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(ji(R=>y(E(R)).pipe(I(K=>[R,K])))),w=(E,B,R)=>{const K=v.get(E)??new Map,ie=K.get(B);if(ie)return ie;v.set(E,K);let ye;const Ce=R.pipe(en({connector:()=>ye=new Pn}),Ii({complete(){K.set(B,ye)}}),Cf());return K.set(B,Ce),Ce},m=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized),Jt((E,B)=>{let R=B.blocks.get(B.finalized);const K=[R],ie=E.at(-1);if(!ie)return K;for(;R.number>ie.number+1&&(R=B.blocks.get(R.parent),!!R);)K.unshift(R);return K},[]),Mn(),I(Ur),tn),x=b.pipe(fe((E,B)=>E.best===B.best),I(E=>Ur(E.blocks.get(E.best))),tn),A=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Jt((E,B)=>{const R=ke=>E.get(ke)||Ur(B.blocks.get(ke)),K=R(B.best),ie=R(B.finalized),ye=K.number-ie.number+1,Ce=new Array(ye);for(let ke=0,on=K.hash;ke<ye;ke++)Ce[ke]=R(on),on=Ce[ke].parent;return new Map(Ce.map(ke=>[ke.hash,ke]))},new Map),I(E=>[...E.values()]),tn),S=b.pipe(fe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),jn(({finalizedRuntime:{runtime:E}})=>E.pipe(_f(null))),tn),O=S.pipe(I(E=>E?.lookup.metadata??null)),U=of(m.pipe(I(E=>E.hash)),x.pipe(I(E=>E.hash)),l),Y=U(p(o("body"),"body")),N=E=>w(E,"body",Y(E)),q=p(o("storage"),"storage"),ne=U((E,B,R,K=null,ie)=>b.pipe(te(1),M(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),M(ye=>{const Ce=R(ye),ke=w(E,`storage-${B}-${Ce}-${K??""}`,q(E,B,Ce,K));return ie?w(E,`storage-${B}-${Ce}-${K??""}-dec`,ke.pipe(I(on=>({raw:on,mapped:ie(on,ye)})))):ke}))),Qe=uf(t,i),Mt=U(zn(b,(E,B,R)=>Qe(E,B,R??null,!1),"storageQueries")),sn=U(zn(b,E=>Ln(()=>s(E)),"header")),Yn=E=>ne(E,"value",B=>B.events.key,null,(B,R)=>R.events.dec(B)).pipe(I(B=>B.mapped)),Ch=p(o("call"),"call"),cc=U((E,B,R)=>w(E,`call-${B}-${R}`,Ch(E,B,R))),Zr=Bf(cc,y),ac=E=>w(E,"body",Y(E)),$h=Li(b,ac,Zr,Yn),Oh=Li(b,ac,Zr,()=>He()),Th=S.pipe(_e(Boolean),te(1),M(E=>{const{enc:B}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let R;try{R=B(0)}catch{R=B(0n)}return ne(null,"value",()=>R,null)}),Dn(1));Or(S,A).subscribe({error(){}});let Jr=Ue,Gn=!1,es=0;const Rh=E=>{es+=E,Gn=!0,Jr=n()};return[{follow$:r,finalized$:m,best$:x,bestBlocks$:A,newBlocks$:af(b),runtime$:S,metadata$:O,genesis$:Th,header$:sn,body$:N,call$:cc,storage$:ne,storageQueries$:Mt,eventsAt$:Yn,holdBlock:a,trackTx$:$h,trackTxWithoutEvents$:Oh,validateTx$:Zr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:U(y),unfollow:()=>{Gn!=null&&(es--,Gn&&!es&&(Gn=null,Jr(),Jr=Ue))}},Rh]};var Of=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Hn=new Map,Tf=e=>{const t=Hn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Hn.get(e);!c||c.refCount<=1?(Hn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=$f(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:Of(e.transaction),destroy:n};return Hn.set(e,{client:i,refCount:1}),i},Rf=(e,t)=>e.pipe(Si(n=>n.blocks.has(t)),fe((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),fe(),Si(n=>n!=="finalized",!0));class Pt{constructor(){}_runtime(t){}}class zi{constructor(){}_compatibility(t){}}const qn=new WeakMap,Fi=new WeakMap,Mr=e=>e instanceof Pt?Fi.get(e):qn.get(e);var ht=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(ht||{});const Pf=ge(_u),Uf=ge(yr),Mf=Te(Pf,Uf),Lf=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(_e(i=>i!=null));let o=await Le(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Mf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new zi;return qn.set(c,{runtime:i,getEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},typedefNodes:s}),c})},Vf=e=>new Promise(async t=>{const n=e.runtime$.pipe(_e(s=>s!=null));let r=await Le(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return Fi.set(n,{runtime:t}),n}),Lr=new WeakMap,Hi=e=>(Lr.has(e.metadataRaw)||Lr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Lr.get(e.metadataRaw)),wt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Hi(i);return(u=a.typeNodes)[c]||(u[c]=xn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Ie.Identical,values:Ie.Identical};const u=qn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ie.Incompatible,values:Ie.Incompatible};const d=u.typedefNodes,f=Hi(c);return Tu(a,h=>d[h],l,h=>r(c,h),f.compat)}const o=Wi(e,i=>qi(s(i)));return{isCompatible:Wi(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Tt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Tt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Ie.Incompatible)return!1;if(a.args>Ie.Partial)return!0;if(a.values===Ie.Incompatible)return!1;const l=n(c);return l==null?!1:Vo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Ie.Incompatible)return!1;if(a>Ie.Partial)return!0;const l=qn.get(i),d=t(l);return Vo(d.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r}},qi=e=>Math.min(e.args,e.values),Wi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof zi||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},Df=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Mr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},jf=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Wn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new zs)}:Ue;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Vr=Symbol("EMPTY_VALUE"),Dr=e=>t=>new T(n=>{let r=0,s=null,o=Vr,i=!1;const c=()=>{const a=e(o,r++);o=Vr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Vr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Ki={};const zf=e=>t=>new T(n=>{let r=Ki,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Ki?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Ut=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)),Ff=()=>{const e=new cl(new Me);return[e.pipe(Jl()),()=>Ii({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Me)},complete:()=>{e.value.complete(),e.next(new Me)}})]},Hf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,f])=>{const h=f.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,f,null))throw u();return[l,d,f]}),ji(([l,d,f])=>n.eventsAt$(l.hash).pipe(I(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),jf);return{watch:l=>a.pipe(M(d=>l?d.filter(f=>l(f.payload)):d)),pull:()=>Le(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},qf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],f=Ut(d),{signal:h,at:p}=f?d:{},v=p??null,b=o(n,v).pipe(M(([y,g])=>{let w;try{w=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,g,l))throw a();return n.call$(v,u,Z(w.args.enc(l))).pipe(I(w.value.dec),I(m=>{if(!c(y,g,m))throw a();return m}))}));return Wn(b,h)},{getCompatibilityLevel:s,isCompatible:r})},jr=I(e=>e.mapped),Wf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",f=n.runtime$.pipe(_e(Boolean),te(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ne),Dn()),h=Qo(ql(f),I(([m,x])=>x(m))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),b=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const x=m[m.length-1],A=x==="best",S=A||x==="finalized"?m.slice(0,-1):m;return n[A?"best$":"finalized$"].pipe(Dr(()=>g(...S,A?{at:"best"}:{})),fe((O,U)=>O.raw===U.raw),jr)},g=(...m)=>{const x=m[m.length-1],A=Ut(x),{at:S}=A?x:{},O=S??null;return l?n.pinnedBlocks$.pipe(I(U=>{const Y=O==="finalized"||!O?U.finalized:O==="best"?U.best:O,N=U.blocks.get(Y);if(!N)throw new Rt(Y,"System.Number");return N.number}),fe(),h,I(U=>({raw:U,mapped:U}))):d&&Number(m[0])===0?n.genesis$.pipe(I(U=>({raw:U,mapped:bn.fromHex(U)}))):Ot(c).pipe(M(U=>n.storage$(O,"value",Y=>{const N=b(Y),q=m.length===N.len?m:m.slice(0,-1);if(m!==q&&!A)throw v(m);if(!u(U,Y,q))throw p();return N.keys.enc(...q)},null,(Y,N)=>{const q=b(N),ne=Y===null?q.fallback:q.value.dec(Y);if(!a(U,N,ne))throw p();return ne})))},w=async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S}=A?x:{};return Wn(g(...m).pipe(jr),S)};return{isCompatible:s,getCompatibilityLevel:o,getValue:w,getValues:(m,x)=>Promise.all(m.map(A=>w(...x?[...A,x]:A))),getEntries:async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S,at:O}=A?x:{},U=O??null,Y=await c,N=n.storage$(U,"descendantsValues",q=>{const ne=b(q);if(qi(i(Y,q))===Ie.Incompatible)throw p();if(m.length>ne.len)throw v(m);const Qe=m.length>0&&A?m.slice(0,-1):m;if(m.length===ne.len&&Qe===m)throw v(m);return ne.keys.enc(...Qe)},null,(q,ne)=>{const Qe=b(ne),Mt=q.map(({key:sn,value:Yn})=>({keyArgs:Qe.keys.dec(sn),value:Qe.value.dec(Yn)}));if(Mt.some(({value:sn})=>!a(Y,ne,sn)))throw p();return Mt}).pipe(jr);return Wn(N,S)},watchValue:y,watchEntries:(...m)=>{const x=m.at(-1),A=Ut(x);return r(e,t,A?m.slice(0,-1):m,A&&x.at==="best")}}},Kf=Vt(z.enc,e=>+!!e.signed<<7|e.version),zr=()=>new Error("Unkown signer"),Xf=e=>{const{extrinsic:t}=e,n=Fn(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw zr()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw zr();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw zr()},Yf={Ed25519:0,Sr25519:1,Ecdsa:2},Gf=(e,t,n,r,s,o)=>{const[i,c]=Xf(e),u=re(Kf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Yf[o],...n]),...r,s);return re(ae.enc(u.length),u)},[Kn,nn]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Nf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Kn.length;r++)n=Kn[r]===t[r];n=n&&r===Kn.length;const s=t.length-nn.length;for(r=0;n&&r<nn.length;r++)n=nn[r]===t[s+r];return n=n&&r===nn.length,e(n?t:re(Kn,t,nn))};function Qf(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Yt)=>{const a=At(dr(i)),l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const f=re(s,...l,...d),h=await n(f.length>256?u(f):f);return Gf(a,e,h,l,s,t)},signBytes:Nf(n)}}Uint8Array.from([1]);const Zf=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function Jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const eh=Vt(Q(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Jf(e.period)-1,1),15),r=e.phase/t<<4;return et[0](n|r)}),[th]=me({tip:ae,asset:it(Q(1/0))}),Xi=new Uint8Array,Fr=Uint8Array.from([0]),Hr=e=>({value:e,additionalSigned:Xi}),qr=e=>({value:Xi,additionalSigned:e}),Wr=(e,t)=>({value:e,additionalSigned:t}),Yi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Zf(t,n),d=h=>{const[p,v]=r[h],b=c[h];try{return Et({value:p,additionalSigned:v},(y,g)=>{const w=b?.[g];return w instanceof Uint8Array?w:y(w)})}catch{return a.push(h),null}},f=Et(r,([h,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Hr(h(i));case"CheckMortality":return s.mortal?Wr(eh({period:s.period,phase:s.startAtBlock.height%s.period}),le(s.startAtBlock.hash)):Wr(Fr,e);case"ChargeTransactionPayment":return Hr(h(o));case"ChargeAssetTxPayment":return Hr(th({tip:o,asset:u.asset}));case"CheckGenesis":return qr(e);case"CheckMetadataHash":return Wr(Fr,Fr);case"CheckSpecVersion":return qr(p(l.spec_version));case"CheckTxVersion":return qr(p(l.transaction_version));default:return d(v)}});return a.forEach(h=>{delete f[h]}),Et(f,(h,p)=>({...h,identifier:p}))}},Gi="AccountNonceApi_account_nonce",nh={1:z.dec,2:et.dec,4:$e.dec,8:Dt.dec},rh=(e,t,n)=>e(n,Gi,t).pipe(I(r=>{const s=le(r),o=nh[s.length];if(!o)throw new Error(`${Gi} retrieved wrong data`);return o(s)})),sh=(e,t,n,r,s,o={})=>Tt([o.nonce?He(o.nonce):oh(e,Z(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(te(1),M(([i,c,u])=>{const a=Yi(le(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),oh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Jt((i,c)=>c.parent===i?c.hash:i,o),ki(o),fe()),r=o=>n(o).pipe(te(2),jn(i=>rh(e.call$,t,i))),s=o=>Tt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>He({success:!1,value:c}))))).pipe(te(1));return e.pinnedBlocks$.pipe(_e(o=>!o.recovering&&o.blocks.size>0),te(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),jn(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var ih=Object.defineProperty,ch=(e,t,n)=>t in e?ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ah=(e,t,n)=>ch(e,t+"",n);const uh=e=>Z(Yt(le(e))),lh=(e,t)=>new T(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const h=s.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,f=a.found.type;if(f&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),d&&(f?n.complete():a.found.validity?.success===!1&&n.error(new Kr(a.found.validity.value)))},c=t.pipe(fe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(fe((n,r)=>n===r)),fh=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Kr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),ah(this,"error"),this.name="InvalidTxError",this.error=t}}const Xr=(e,t,n,r,s=!1)=>{const o=uh(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(te(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(M(l=>e.validateTx$(l,n).pipe(_e(d=>!d.success),I(d=>{throw new Kr(d.value)})))),u=new T(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(f){l.error(f)}})),d}),a=lh(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...fh(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return $r(s?He(i("signed",{})):gt,c,He(i("broadcasted",{})),a.pipe(zf(({found:l,type:d,...f})=>l?He(i("finalized",f)):gt)))},Ni=async(e,t,n,r)=>Il(Xr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),hh=vt().enc,dh=new Uint8Array(64),ph=new Uint8Array(65),vh=e=>()=>e?ph:dh,[,bh]=me({weight:me({ref_time:yn,proof_size:yn}),class:pe({Normal:C,Operational:C,Mandatory:C}),partial_fee:os}),Qi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(m,x,A={})=>{const S=Mr(m).runtime(),{dynamicBuilder:O,assetId:U,lookup:Y}=S;let N;try{N=O.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(m,S,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=A;if(A.asset){if(U==null||!mr(A.asset,xn(Y(U)),Mt=>u(S,Mt)))throw new Error("Incompatible runtime asset");q={...A,asset:O.buildDefinition(U).enc(A.asset)}}const{location:ne,codec:Qe}=N;return{callData:je.fromBytes(re(new Uint8Array(ne),Qe.enc(x))),options:q}},f=(m,x={})=>i(n,null).pipe(I(([A])=>d(A,m,x))),h=m=>m?d(m,l).callData:Le(f(l).pipe(I(x=>x.callData))),p=(m,{...x},A)=>f(l,x).pipe(M(({callData:S,options:O})=>sh(n,m,S.asBytes(),A,x.customSignedExtensions||{},O))),v=(m,{at:x,...A}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(S=>S.find(O=>O.hash===x)))).pipe(te(1),M(S=>S?p(m,A,S).pipe(I(O=>({tx:Z(O),block:S}))):Un(()=>new Error(`Uknown block ${x}`)))),b=(m,x)=>Le(v(m,x)).then(A=>A.tx),y=(m,x)=>Le(v(m,x)).then(({tx:A,block:S})=>Ni(n,r,A,S.hash)),g=(m,x)=>v(m,x).pipe(M(({tx:A,block:S})=>Xr(n,r,A,S.hash,!0))),w=async(m,x)=>{typeof m=="string"&&(m=m.startsWith("0x")?le(m):hh(m));const A=m.length===20,S=Qf(m,A?"Ecdsa":"Sr25519",vh(A)),O=le(await b(S,x)),U=Z(re(O,$e.enc(O.length))),Y=n.getRuntimeContext$(null).pipe(I(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return bh}})),N=n.call$(null,"TransactionPaymentApi_query_info",U);return Le(Tt([N,Y]).pipe(I(([q,ne])=>ne(q))))};return{getPaymentInfo:w,getEstimatedFees:async(m,x)=>(await w(m,x)).partial_fee,decodedCall:{type:e,value:yt(t,l)},getEncodedData:h,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var yh=Object.defineProperty,mh=(e,t,n)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t,n)=>(mh(e,typeof t!="symbol"?t+"":t,n),n),Yr=Symbol("SUSPENSE"),gh=class extends Promise{constructor(e){super(e)}},Zi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ji=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ee={},Xn=class extends T{constructor(e,t,n=Ue){super(r=>{const s=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:Ue});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ee,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Zi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ee&&r.next(this.currentValue)):(this.subject=new Me,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Qt({next:i=>{this.promise&&i!==Yr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Ee;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Yr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ji),this.promise=null),this.currentValue!==Ee)return this.subject.complete();if(t===Ee){const i=this.subject;return this.subject=null,i.error(new Ji)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ee&&this.currentValue===Ee&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,qe(this,"subject",null),qe(this,"subscription",null),qe(this,"refCount",0),qe(this,"currentValue",Ee),qe(this,"promise",null),qe(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Xn?s:new Xn(s,Ee)}),qe(this,"getRefCount",()=>this.refCount),qe(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ee&&this.currentValue!==Yr)return this.currentValue;if(this.defaultValue!==Ee)return this.defaultValue;if(this.refCount===0)throw new Zi;const r=new gh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),qe(this,"getDefaultValue",()=>this.defaultValue),t===Ee&&delete this.getDefaultValue}};function ec(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function wh(e,t){const n=new xh,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Xn(e(...o),r(...o),()=>{n.delete(i)}),a=new T(d=>{const f=n.get(i);let h=u;return f?f!==a&&(h=f,ec(h,a)):n.set(i,l),h.subscribe(d)});ec(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var xh=class{constructor(){qe(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function Eh(e,t){return new Xn(e,t)}var Gr=(...e)=>(typeof e[0]=="function"?wh:Eh)(e[0],e.length>1?e[1]:Ee);const tc=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},nc=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},rc=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},kh=(e,t,n)=>{const r=Gr((c,u,a)=>{const l=rc(c,u),d=(b,y)=>{const g=Rf(e,y.hash).pipe(_e(w=>!w),te(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(M(w=>w===b?.rootHash?He({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),I(([m,x])=>[m,l(x)]),I(([m,x])=>({prev:b&&b.block.hash,rootHash:w,block:y,...tc(b?.entries??[],m,x)})))),Ai(g),lt(w=>w instanceof Rt?gt:Un(()=>w)))},f=e.pipe(fe((b,y)=>b.finalized===y.finalized),Dr(({blocks:b,finalized:y})=>d(null,b.get(y))),te(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[h,p]=Ff(),v=e.pipe(fe((b,y)=>b.best===y.best),Rr(h),Dr(([b,y])=>{const{best:g}=b,{blocks:w}=y;let m=w[g]?null:g;if(!m)return gt;const x=nc(m,w,b);return x?d(x,b.blocks.get(m)).pipe(I(A=>(w[m]=A,y))):(m=b.finalized,d(w[y.finalized],b.blocks.get(m)).pipe(I(A=>(A.prev=null,{blocks:{[m]:A},finalized:m}))))}));return Or(f,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),f=rc(u,a),h=c?"finalized":"best";return Tt([d.pipe(Yl(0)),e.pipe(fe((p,v)=>p[h]===v[h]))]).pipe(I(([p,v])=>nc(v[h],p.blocks,v,!0)),_e(Boolean),fe(),ki(null),Zl(),Rr(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],y])=>[p,v,b,f(y)]),M(([p,v,b,y])=>{if(!p)return[v];let g=v;const w=[];for(;g&&g.block.number>p.block.number;)w.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,w.length)){const{blocks:m}=b;Object.keys(m).forEach(x=>{m[x].block.number<w[0].block.number&&delete m[x]})}return p===g?w:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:tc(p.entries,v.entries,y)}]}))},o=Gr(s(!0)),i=Gr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(te(1),M(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),I(f=>f.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(te(1),M(f=>d(c,u,f)),I(({block:{hash:f,number:h,parent:p},deltas:v,entries:b},y)=>{const g=y>0?v:{deleted:[],upserted:b};return{block:{hash:f,number:h,parent:p},entries:b.map(Nr),deltas:g&&{deleted:g.deleted.map(Nr),upserted:g.upserted.map(Nr)}}}))}},Nr=e=>e.dec,sc="RuntimeViewFunction",oc="execute_view_function",Qr=sc+"_"+oc,Ah=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],d=Ut(l),{signal:f,at:h}=d?l:{},p=h??null,v=o(n,p).pipe(M(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(sc,oc)}catch{throw new Error(`Runtime entry RuntimeCall(${Qr}) not found`)}let w;try{w=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(b,y,a))throw u();const m=w.args.enc(a),x=re(le(y.lookup.metadata.pallets.find(({name:A})=>A===e).viewFns.find(({name:A})=>A===t).id),_.enc(m.length),m);return n.call$(p,Qr,Z(x)).pipe(I(A=>{try{const S=g.value.dec(A);if(!("success"in S&&"value"in S)||!("type"in S.value)&&!("asBytes"in S.value))throw null;return S}catch{throw new Error(`Unexpected RuntimeCall(${Qr}) type`)}}),I(({success:A,value:S})=>{if(!A)throw new Error(`ViewFn API Error: ${S.type}`);const O=w.value.dec(S.asBytes());if(!c(b,y,O))throw u();return O}))}));return Wn(v,f)},{getCompatibilityLevel:s,isCompatible:r})},ic=(e,t,n)=>{const r={},s=b=>new Proxy(r,{get(y,g){return b(g)}}),o=b=>{const y={};return s(g=>(y[g]||(y[g]={}),s(w=>(y[g][w]||(y[g][w]=b(g,w)),y[g][w]))))},i=(b,y)=>b.lookup.metadata.pallets.find(g=>g.name===y),c=kh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((b,y)=>Wf(b,y,t,c,wt(e,g=>g.getEntryPoint(ht.Storage,b,y),g=>{const w=i(g,b)?.storage?.items.find(m=>m.name===y);return w==null?null:Cu(w)}))),a=(b,y,g,w)=>{if(g==null)return null;const m=b.lookup(g);if(m.type!=="enum")throw new Error("Expected enum");if(m.value[w]==null)return null;const x=$u(m.value[w]);return{args:y==="args"?x:kn,values:y==="args"?kn:x}},l=o((b,y)=>Qi(b,y,t,n,wt(e,g=>g.getEntryPoint(ht.Tx,b,y),g=>a(g,"args",i(g,b)?.calls?.type,y)),!0)),d=o((b,y)=>Hf(b,y,t,wt(e,g=>g.getEntryPoint(ht.Event,b,y),g=>a(g,"values",i(g,b)?.events?.type,y)))),f=o((b,y)=>Df(b,y,wt(e,g=>g.getEntryPoint(ht.Const,b,y),g=>{const w=i(g,b)?.constants.find(m=>m.name===y)?.type;return w==null?null:Ou(w)}))),h=o((b,y)=>qf(b,y,t,wt(e,g=>g.getEntryPoint(ht.Api,b,y),g=>Lo(g.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=o((b,y)=>Ah(b,y,t,wt(e,g=>g.getEntryPoint(ht.ViewFns,b,y),g=>Lo(g.lookup.metadata.pallets.find(w=>w.name===b).viewFns.find(w=>w.name===y))))),v=(b,y)=>{const{lookup:g,dynamicBuilder:w}=Mr(y).runtime();try{const m=w.buildDefinition(g.call).dec(b.asBytes()),x=m.type,A=m.value.type,S=m.value.value;return Qi(x,A,t,n,wt(e,O=>O.getEntryPoint(ht.Tx,x,A),O=>a(O,"args",i(O,x)?.calls?.type,A)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?v(b,y):e.then(g=>v(b,g)),tx:l,event:d,apis:h,constants:f,view:p}};function Sh(e){const t=Xu(e),n=Tf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Ln(r).pipe(I(({genesisHash:h})=>h),lt(()=>s),Dn(1))},c=t.request;let u;const a=new WeakMap,l=h=>{const p=a.get(h)||Lf(h,i);return a.set(h,p),p},d=()=>u??(u=Vf(i)),{broadcastTx$:f}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Le(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Le(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:h=>Le(i.body$(h)),getBlockHeader:h=>Le(i.header$(h??null)),submit:(...h)=>Ni(i,f,...h),submitAndWatch:(...h)=>Xr(i,f,...h),getTypedApi:h=>{const p=l(h);return Object.assign(ic(p,i,f),{compatibilityToken:p})},getUnsafeApi:()=>{const h=d();return Object.assign(ic(h,i,f),{runtimeToken:h})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const Ih=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=o,u=new Uint8Array(i);return a=>{const l=je.fromBytes(re(u,c.enc(a)));return{encodedData:l,decodedCall:yt(e,yt(t,a)),sign:async(d,f)=>Z(await d.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},Bh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=le(e),r=await t(),s=At(ct.dec(r)),o=Fn(s),i=Pr(o),c=Yi(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(y=>(v[b][y]||(v[b][y]=p(b,y)),v[b][y]))))},f=d((p,v)=>{const b=u(p)?.constants.find(y=>y.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),h=d((p,v)=>Ih(p,v,r,i,c));return{constants:f,tx:h}},rn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},_h=async e=>{const t=At(dr(await e.getMetadata())),n={},r=d=>new Proxy(n,{get(f,h){return d(h)}}),s=d=>{const f={};return r(h=>(f[h]||(f[h]={}),r(p=>(f[h][p]||(f[h][p]=d(h,p)),f[h][p]))))},o=Fn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Pr(o);return{query:s((...d)=>{const{value:f,args:h}=rn(c,"Storage")(...d);return{value:f,args:h}}),tx:s((...d)=>rn(a,"Call")(...d).codec),event:s((...d)=>rn(l,"Event")(...d).codec),apis:s(rn(i,"Runtime API")),constants:s(rn(u,"Constant"))}};ce.AccountId=vt,ce.Binary=je,ce.CompatibilityLevel=Ie,ce.Enum=yt,ce.FixedSizeBinary=bn,ce.InvalidTxError=Kr,ce._Enum=Qs,ce.createClient=Sh,ce.getOfflineApi=Bh,ce.getSs58AddressInfo=nr,ce.getTypedCodecs=_h});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function On(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var gt=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var c=_t(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var l=this.initialTeardown;if(F(l))try{l()}catch(v){o=v instanceof Sr?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=_t(d),h=f.next();!h.done;h=f.next()){var p=h.value;try{Go(p)}catch(v){o=o??[],v instanceof Sr?o=Pe(Pe([],Re(o)),Re(v.errors)):o.push(v)}}}catch(v){r={error:v}}finally{try{h&&!h.done&&(s=f.return)&&s.call(f)}finally{if(r)throw r.error}}}if(o)throw new Sr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Go(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)&&On(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&On(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Xo=gt.EMPTY;function Yo(e){return e instanceof gt||e&&"closed"in e&&F(e.remove)&&F(e.add)&&F(e.unsubscribe)}function Go(e){F(e)?e():e.unsubscribe()}var Qu={Promise:void 0},Zu={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Pe([e,t],Re(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function No(e){Zu.setTimeout(function(){throw e})}function Ue(){}function Tn(e){e()}var Qt=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Yo(n)&&n.add(r)):r.destination=tl,r}return t.create=function(n,r,s){return new $t(n,r,s)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(gt),Ju=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){Rn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Rn(r)}else Rn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Rn(n)}},e}(),$t=function(e){Fe(t,e);function t(n,r,s){var o=e.call(this)||this,i;return F(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new Ju(i),o}return t}(Qt);function Rn(e){No(e)}function el(e){throw e}var tl={closed:!0,next:Ue,error:el,complete:Ue},Ir=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ne(e){return e}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Zo(e)}function Zo(e){return e.length===0?Ne:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(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 s=this,o=rl(t)?t:new $t(t,n,r);return Tn(function(){var i=s,c=i.operator,u=i.source;o.add(c?c.call(o,u):u?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Jo(n),new n(function(s,o){var i=new $t({next:function(c){try{t(c)}catch(u){o(u),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Ir]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Zo(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Jo(t),new t(function(r,s){var o;n.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},e.create=function(t){return new e(t)},e}();function Jo(e){var t;return(t=e??Qu.Promise)!==null&&t!==void 0?t:Promise}function nl(e){return e&&F(e.next)&&F(e.error)&&F(e.complete)}function rl(e){return e&&e instanceof Qt||nl(e)&&Yo(e)}function sl(e){return F(e?.lift)}function X(e){return function(t){if(sl(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 H(e,t,n,r,s){return new ol(e,t,n,r,s)}var ol=function(e){Fe(t,e);function t(n,r,s,o,i,c){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(l){n.error(l)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(l){n.error(l)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=s?function(){try{s()}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}(Qt),il=Ar(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Me=function(e){Fe(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 ei(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new il},t.prototype.next=function(n){var r=this;Tn(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=_t(r.currentObservers),c=i.next();!c.done;c=i.next()){var u=c.value;u.next(n)}}catch(a){s={error:a}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},t.prototype.error=function(n){var r=this;Tn(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},t.prototype.complete=function(){var n=this;Tn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,s=this,o=s.hasError,i=s.isStopped,c=s.observers;return o||i?Xo:(this.currentObservers=null,c.push(n),new gt(function(){r.currentObservers=null,On(c,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?n.error(o):i&&n.complete()},t.prototype.asObservable=function(){var n=new T;return n.source=this,n},t.create=function(n,r){return new ei(n,r)},t}(T),ei=function(e){Fe(t,e);function t(n,r){var s=e.call(this)||this;return s.destination=n,s.source=r,s}return t.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},t.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:Xo},t}(Me),cl=function(e){Fe(t,e);function t(n){var r=e.call(this)||this;return r._value=n,r}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(n){var r=e.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},t.prototype.getValue=function(){var n=this,r=n.hasError,s=n.thrownError,o=n._value;if(r)throw s;return this._throwIfClosed(),o},t.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},t}(Me),Br={now:function(){return(Br.delegate||Date).now()},delegate:void 0},Pn=function(e){Fe(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Br);var o=e.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return t.prototype.next=function(n){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,c=r._timestampProvider,u=r._windowTime;s||(o.push(n),!i&&o.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),s=this,o=s._infiniteTimeWindow,i=s._buffer,c=i.slice(),u=0;u<c.length&&!n.closed;u+=o?1:2)n.next(c[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,s=n._timestampProvider,o=n._buffer,i=n._infiniteTimeWindow,c=(i?1:2)*r;if(r<1/0&&c<o.length&&o.splice(0,o.length-c),!i){for(var u=s.now(),a=0,l=1;l<o.length&&o[l]<=u;l+=2)a=l;a&&o.splice(0,a+1)}},t}(Me),al=function(e){Fe(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(gt),ti={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Pe([e,t],Re(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},ul=function(e){Fe(t,e);function t(n,r){var s=e.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,i=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(i,o,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},t.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),ti.setInterval(n.flush.bind(n,this),s)},t.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&ti.clearInterval(r)},t.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,r){var s=!1,o;try{this.work(n)}catch(i){s=!0,o=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,o=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,On(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(al),ni=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=Br.now,e}(),ll=function(e){Fe(t,e);function t(n,r){r===void 0&&(r=ni.now);var s=e.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},t}(ni),ri=new ll(ul),fl=ri,wt=new T(function(e){return e.complete()});function si(e){return e&&F(e.schedule)}function _r(e){return e[e.length-1]}function Cr(e){return F(_r(e))?e.pop():void 0}function Zt(e){return si(_r(e))?e.pop():void 0}function hl(e,t){return typeof _r(e)=="number"?e.pop():t}var oi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ii(e){return F(e?.then)}function ci(e){return F(e[Ir])}function ai(e){return Symbol.asyncIterator&&F(e?.[Symbol.asyncIterator])}function ui(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 dl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var li=dl();function fi(e){return F(e?.[li])}function hi(e){return Gu(this,arguments,function(){var n,r,s,o;return Ko(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Ct(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Ct(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ct(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function di(e){return F(e?.getReader)}function oe(e){if(e instanceof T)return e;if(e!=null){if(ci(e))return pl(e);if(oi(e))return vl(e);if(ii(e))return bl(e);if(ai(e))return pi(e);if(fi(e))return yl(e);if(di(e))return ml(e)}throw ui(e)}function pl(e){return new T(function(t){var n=e[Ir]();if(F(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function vl(e){return new T(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function bl(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,No)})}function yl(e){return new T(function(t){var n,r;try{for(var s=_t(e),o=s.next();!o.done;o=s.next()){var i=o.value;if(t.next(i),t.closed)return}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}t.complete()})}function pi(e){return new T(function(t){gl(e,t).catch(function(n){return t.error(n)})})}function ml(e){return pi(hi(e))}function gl(e,t){var n,r,s,o;return Yu(this,void 0,void 0,function(){var i,c;return Ko(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Nu(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),s={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ut(e,t,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var o=t.schedule(function(){n(),s?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(o),!s)return o}function vi(e,t){return t===void 0&&(t=0),X(function(n,r){n.subscribe(H(r,function(s){return ut(r,e,function(){return r.next(s)},t)},function(){return ut(r,e,function(){return r.complete()},t)},function(s){return ut(r,e,function(){return r.error(s)},t)}))})}function bi(e,t){return t===void 0&&(t=0),X(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function wl(e,t){return oe(e).pipe(bi(t),vi(t))}function xl(e,t){return oe(e).pipe(bi(t),vi(t))}function El(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 kl(e,t){return new T(function(n){var r;return ut(n,t,function(){r=e[li](),ut(n,t,function(){var s,o,i;try{s=r.next(),o=s.value,i=s.done}catch(c){n.error(c);return}i?n.complete():n.next(o)},0,!0)}),function(){return F(r?.return)&&r.return()}})}function yi(e,t){if(!e)throw new Error("Iterable cannot be null");return new T(function(n){ut(n,t,function(){var r=e[Symbol.asyncIterator]();ut(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function Al(e,t){return yi(hi(e),t)}function Sl(e,t){if(e!=null){if(ci(e))return wl(e,t);if(oi(e))return El(e,t);if(ii(e))return xl(e,t);if(ai(e))return yi(e,t);if(fi(e))return kl(e,t);if(di(e))return Al(e,t)}throw ui(e)}function Ot(e,t){return t?Sl(e,t):oe(e)}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return Ot(e,n)}function Un(e,t){var n=F(e)?e:function(){return e},r=function(s){return s.error(n())};return new T(r)}var mi=Ar(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Il(e,t){return new Promise(function(n,r){var s=!1,o;e.subscribe({next:function(i){o=i,s=!0},error:r,complete:function(){s?n(o):r(new mi)}})})}function Le(e,t){return new Promise(function(n,r){var s=new $t({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new mi)}});e.subscribe(s)})}function Bl(e){return e instanceof Date&&!isNaN(e)}function I(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){r.next(e.call(t,o,s++))}))})}var _l=Array.isArray;function Cl(e,t){return _l(t)?e.apply(void 0,Pe([],Re(t))):e(t)}function gi(e){return I(function(t){return Cl(e,t)})}var $l=Array.isArray,Ol=Object.getPrototypeOf,Tl=Object.prototype,Rl=Object.keys;function Pl(e){if(e.length===1){var t=e[0];if($l(t))return{args:t,keys:null};if(Ul(t)){var n=Rl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Ul(e){return e&&typeof e=="object"&&Ol(e)===Tl}function Ml(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Tt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=Cr(e),s=Pl(e),o=s.args,i=s.keys;if(o.length===0)return Ot([],n);var c=new T(wi(o,n,i?function(u){return Ml(i,u)}:Ne));return r?c.pipe(gi(r)):c}function wi(e,t,n){return n===void 0&&(n=Ne),function(r){xi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(l){xi(t,function(){var d=Ot(e[l],t),f=!1;d.subscribe(H(r,function(h){o[l]=h,f||(f=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function xi(e,t,n){e?ut(n,e,t):t()}function Ll(e,t,n,r,s,o,i,c){var u=[],a=0,l=0,d=!1,f=function(){d&&!u.length&&!a&&t.complete()},h=function(v){return a<r?p(v):u.push(v)},p=function(v){a++;var b=!1;oe(n(v,l++)).subscribe(H(t,function(y){t.next(y)},function(){b=!0},void 0,function(){if(b)try{a--;for(var y=function(){var g=u.shift();i||p(g)};u.length&&a<r;)y();f()}catch(g){t.error(g)}}))};return e.subscribe(H(t,h,function(){d=!0,f()})),function(){}}function M(e,t,n){return n===void 0&&(n=1/0),F(t)?M(function(r,s){return I(function(o,i){return t(r,o,s,i)})(oe(e(r,s)))},n):(typeof t=="number"&&(n=t),X(function(r,s){return Ll(r,s,e,n)}))}function Mn(e){return e===void 0&&(e=1/0),M(Ne,e)}function Vl(){return Mn(1)}function $r(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Vl()(Ot(e,Zt(e)))}function Ln(e){return new T(function(t){oe(e()).subscribe(t)})}var Dl={connector:function(){return new Me},resetOnDisconnect:!0};function jl(e,t){t===void 0&&(t=Dl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new T(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=Ln(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Vn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=fl);var r=-1;return t!=null&&(si(t)?n=t:r=t),new T(function(s){var o=Bl(e)?+e-n.now():e;o<0&&(o=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},o)})}function Or(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e),r=hl(e,1/0),s=e;return s.length?s.length===1?oe(s[0]):Mn(r)(Ot(s,n)):wt}var zl=Array.isArray;function Fl(e){return e.length===1&&zl(e[0])?e[0]:e}function _e(e,t){return X(function(n,r){var s=0;n.subscribe(H(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function lt(e){return X(function(t,n){var r=null,s=!1,o;r=t.subscribe(H(n,void 0,void 0,function(i){o=oe(e(i,lt(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Hl(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(H(i,function(l){var d=a++;u=c?e(u,l,d):(c=!0,l),i.next(u)},s))}}function Ei(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return n?Qo(Ei.apply(void 0,Pe([],Re(e))),gi(n)):X(function(r,s){wi(Pe([r],Re(Fl(e))))(s)})}function ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ei.apply(void 0,Pe([],Re(e)))}function Wl(e,t){return F(t)?M(e,t,1):M(e,1)}function te(e){return e<=0?function(){return wt}:X(function(t,n){var r=0;t.subscribe(H(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Kl(e){return I(function(){return e})}function Xl(e,t){return M(function(n,r){return oe(e(n,r)).pipe(te(1),Kl(n))})}function Yl(e,t){t===void 0&&(t=ri);var n=Vn(e,t);return Xl(function(){return n})}function Gl(e,t){return X(function(n,r){var s=new Set;n.subscribe(H(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&oe(t).subscribe(H(r,function(){return s.clear()},Ue))})}function fe(e,t){return t===void 0&&(t=Ne),e=e??Nl,X(function(n,r){var s,o=!0;n.subscribe(H(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function Nl(e,t){return e===t}function Ql(e,t){return X(function(n,r){var s=0,o=null,i=!1;n.subscribe(H(r,function(c){o||(o=H(r,void 0,function(){o=null,i&&r.complete()}),oe(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Zl(){return X(function(e,t){var n,r=!1;e.subscribe(H(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function Jt(e,t){return X(Hl(e,t,arguments.length>=2,!0))}function en(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new Me}:t,r=e.resetOnError,s=r===void 0?!0:r,o=e.resetOnComplete,i=o===void 0?!0:o,c=e.resetOnRefCountZero,u=c===void 0?!0:c;return function(a){var l,d,f,h=0,p=!1,v=!1,b=function(){d?.unsubscribe(),d=void 0},y=function(){b(),l=f=void 0,p=v=!1},g=function(){var w=l;y(),w?.unsubscribe()};return X(function(w,m){h++,!v&&!p&&b();var x=f=f??n();m.add(function(){h--,h===0&&!v&&!p&&(d=Tr(g,u))}),x.subscribe(m),!l&&h>0&&(l=new $t({next:function(A){return x.next(A)},error:function(A){v=!0,b(),d=Tr(y,s,A),x.error(A)},complete:function(){p=!0,b(),d=Tr(y,i),x.complete()}}),oe(w).subscribe(l))})(a)}}function Tr(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(t===!0){e();return}if(t!==!1){var s=new $t({next:function(){s.unsubscribe(),e()}});return oe(t.apply(void 0,Pe([],Re(n)))).subscribe(s)}}function Dn(e,t,n){var r,s,o,i,c=!1;return e&&typeof e=="object"?(r=e.bufferSize,i=r===void 0?1/0:r,s=e.windowTime,t=s===void 0?1/0:s,o=e.refCount,c=o===void 0?!1:o,n=e.scheduler):i=e??1/0,en({connector:function(){return new Pn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function ki(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Zt(e);return X(function(r,s){(n?$r(e,r,n):$r(e,r)).subscribe(s)})}function jn(e,t){return X(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(H(r,function(u){s?.unsubscribe();var a=0,l=o++;oe(e(u,l)).subscribe(s=H(r,function(d){return r.next(t?t(u,d,l,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function Jl(){return jn(Ne)}function Ai(e){return X(function(t,n){oe(e).subscribe(H(n,function(){return n.complete()},Ue)),!n.closed&&t.subscribe(n)})}function Si(e,t){return t===void 0&&(t=!1),X(function(n,r){var s=0;n.subscribe(H(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Ii(e,t,n){var r=F(e)||t||n?{next:e,error:t,complete:n}:e;return r?X(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(H(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Ne}function Rr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Cr(e);return X(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){oe(e[d]).subscribe(H(s,function(f){i[d]=f,!u&&!c[d]&&(c[d]=!0,(u=c.every(Ne))&&(c=null))},Ue))},l=0;l<o;l++)a(l);r.subscribe(H(s,function(d){if(u){var f=Pe([d],Re(i));s.next(n?n.apply(void 0,Pe([],Re(f))):f)}}))})}var ef=Object.defineProperty,tf=(e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bi=(e,t,n)=>tf(e,typeof t!="symbol"?t+"":t,n);class nf{constructor(){Bi(this,"first"),Bi(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 rf=()=>{const e=new Map,t=(f,h)=>{e.set(f,()=>{e.delete(f),h()})},n=f=>{e.get(f)?.()},r=new nf,s=r.unshift.bind(r),o=r.push.bind(r),i=(f,h)=>{const p=h?s:o;t(f.source$,p(f))},c=()=>{const f=r.pop();f&&(e.delete(f.source$),u(f))},u=f=>{const{source$:h,observer:p}=f;let v=!1;const b=h.subscribe({next(y){p.next(y)},error(y){(v=y instanceof In)?i(f,!0):p.error(y)},complete(){p.complete()}});b.closed?v||c():t(h,()=>{b.unsubscribe(),c()})},a=(f=!1)=>h=>new T(p=>{const v={observer:p,source$:h};return r.isEmpty()?u(v):i(v,f),()=>{n(h)}}),l=a();return{withRecovery:a,withRecoveryFn:f=>(...h)=>l(f(...h))}};class Rt extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const sf=new Set(["best","finalized",null]),_i=e=>{const t=e.pipe(lt(n=>n instanceof Bn?Vn(750).pipe(Wl(()=>t)):Un(()=>n)));return t},of=(e,t,n)=>r=>(s,...o)=>{if(!sf.has(s))return _i(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(te(1),M(u=>r(u,...o).pipe(n(u))),lt(u=>u instanceof Rt?c:Un(()=>u)));return _i(c)},Ci=e=>(...t)=>new T(n=>{let r=new AbortController;return e(...t,r.signal).then(s=>{n.next(s),n.complete()},s=>{n.error(s)}),()=>{n.unsubscribe(),r.abort(),r=void 0}}),cf=e=>t=>(...n)=>e()[t](...n);function zn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new T(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:f=>i.next(f),error:f=>i.error(f),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let l=!1;const d=e.subscribe({next:f=>{const h=f.blocks.get(r);h?h.recovering?c?.unsubscribe():a():l&&i.error(new Rt(r,n)),l=f.recovering},error:f=>i.error(f)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const af=e=>e.pipe(Jt(({reportedBlocks:t},{blocks:n})=>{const r=new Set(n.keys()),s=[];return r.size>t.size&&n.forEach(({hash:o,number:i,parent:c})=>{t.has(o)||s.push({hash:o,number:i,parent:c})}),{reportedBlocks:r,newBlocks:s}},{reportedBlocks:new Set,newBlocks:new Array(0)}),M(({newBlocks:t})=>t),en()),uf=(e,t)=>{const n=(r,s,o,i)=>new T(c=>e().storageSubscription(r,s,o??null,u=>{c.next(u)},u=>{c.error(u)},()=>{c.complete()},u=>{u>0&&c.next(n(r,s.slice(-u),o,!0))})).pipe(Mn(),t(i));return n},lf=e=>t=>new T(n=>{let r=null;return t.subscribe({next(s){s.type==="initialized"?(r=[],e(s.finalizedBlockHashes[0]).then(o=>{n.closed||(n.next({...s,number:o.number,parentHash:o.parentHash}),r.forEach(i=>{n.next(i)}),r=null)}).catch(o=>{n.closed||n.error(o)})):r?r.push(s):n.next(s)},error(s){n.error(s)},complete(){n.complete()}})}),ff=e=>{let t=null,n=Ue;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=c=>r().header(c).then(lo.dec),o=jl(new T(c=>{t=e(!0,u=>{c.next(u)},u=>{t=null,c.error(u)}),n=()=>{c.complete(),t?.unfollow()}}).pipe(lf(s),hf()));return{getHeader:s,getFollower:r,startFollow:()=>(o.connect(),()=>{n()}),follow$:o}},hf=()=>e=>new T(t=>{const n=new gt,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Do?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),$i=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ft={type:"void"},df=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let f=n.get(d);if(f)return f;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=l(d);return f=n.get(d),f?Object.assign(f,h):(f={id:d,...h},n.set(d,f)),r.delete(d),f};let o=!0,i=!0;const c=s(l=>{const d=t(e[l]);if(d)return d;const{def:f,path:h,params:p}=e[l];if(f.tag==="composite"){if(f.value.length===0)return ft;if(f.value.length===1){const v=c(f.value[0].type);return o&&h.at(-1)==="AccountId32"&&$i(v,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&$i(v,20)?(i=!1,{type:"AccountId20"}):v}return u(f.value)}if(f.tag==="variant"){if(h.length===1&&h[0]==="Option"&&p.length===1&&p[0].name==="T"){const y=c(p[0].type);return y.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:y}}if(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(f.value.length===0)return ft;const v={},b={};return f.value.forEach(y=>{const g=y.name;if(b[g]=y.docs,y.fields.length===0){v[g]={...ft,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){v[g]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}v[g]={...u(y.fields),idx:y.index}}),{type:"enum",value:v,innerDocs:b}}if(f.tag==="sequence")return{type:"sequence",value:c(f.value)};if(f.tag==="array"){const{len:v}=f.value,b=c(f.value.type);return!v||b.type==="void"?ft:v>1?{type:"array",value:b,len:f.value.len}:b}if(f.tag==="tuple")return f.value.length===0?ft:f.value.length>1?a(f.value.map(v=>c(v)),f.value.map(v=>e[v].docs)):c(f.value[0]);if(f.tag==="primitive")return{type:"primitive",value:f.value.tag};if(f.tag==="compact"){const v=c(f.value);return v.type==="void"?ft:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:f.tag}}),u=l=>{let d=!0;const f={},h={};return l.forEach((p,v)=>{d=d&&!!p.name;const b=p.name||v,y=c(p.type);y.type!=="void"&&(f[b]=y,h[b]=p.docs)}),d?{type:"struct",value:f,innerDocs:h}:a(Object.values(f),Object.values(h))},a=(l,d)=>{if(l.every(f=>f.id===l[0].id)&&d.every(f=>!f.length)){const[f]=l;return f.type==="void"?ft:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return c},Fn=e=>{const t=df(e.lookup,({def:s})=>{if(s.tag==="composite"){const o=n(s);if(o)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(i=>[i.name,i.errors==null?{...ft,idx:i.index}:{type:"lookupEntry",value:t(i.errors.type),idx:i.index}])),byteLength:o}}return null});function n(s){if(!(s.value.length===2&&s.value[0].name==="index"&&s.value[1].name==="error"))return null;const i=t(s.value[0].type),c=t(s.value[1].type);return i.type==="primitive"&&i.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"call"in e.extrinsic?e.extrinsic.call:e.lookup[e.extrinsic.type]?.params.find(i=>i.name==="Call")?.type??null})},pf=(e,t,n)=>(r,s,o,...i)=>{const{id:c}=r;if(s.has(c))return s.get(c);if(o.has(c)){const a=t(()=>s.get(c),r,...i);return s.set(c,a),a}o.add(c);let u=e(r,s,o,...i);return o.delete(c),s.has(c)&&(u=n(u,s.get(c),r,...i)),s.set(c,u),u},vf=Kt(),Oi=pf((e,t,n,r)=>{if(e.type==="primitive")return To[e.value];if(e.type==="void")return C;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return co;if(e.type==="compact")return e.isBig?yn:_;if(e.type==="bitSequence")return Ks;const s=h=>Oi(h,t,n,r),o=(h,p)=>{const v=s(h);return p?ge(v,p):ge(v)},i=h=>Te(...h.map(s)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([v,b])=>[v,s(b)]));return me(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return vf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Kt(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return i(e.value);if(e.type==="struct")return c(e.value);if(e.type==="option")return it(s(e.value));if(e.type==="result")return mn(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return C;case"lookupEntry":return s(h.value);case"tuple":return i(h.value);case"struct":return c(h.value);case"array":return o(h.value,h.len)}}),a=Object.fromEntries(Object.keys(e.value).map((h,p)=>[h,u[p]])),l=Object.values(e.value).map(h=>h.idx),f=l.every((h,p)=>h===p)?pe(a):pe(a,l);return e.byteLength?bf(f,e.byteLength):f},sr,e=>e),Ti=(e,t=vt())=>{const n=new Map,r=s=>Oi(e(s),n,new Set,t);return s=>r(s)},bf=(e,t)=>{const n=Q(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Pr=e=>{const{metadata:t}=e;let n=Ti(e);const r=t.pallets.find(f=>f.name==="System")?.constants.find(f=>f.name==="SS58Prefix");let s;if(r)try{const f=n(r.type).dec(r.value);typeof f=="number"&&(s=f,n=Ti(e,vt(f)))}catch{}const o=new Map,i=(f,h)=>{let p=o.get(f);p||o.set(f,p=$o(f));const v=t.pallets.find(S=>S.name===f).storage.items.find(S=>S.name===h),b=(S,O,...U)=>{const Y=p(...U),[,...N]=U;return{args:Te(...N.map(([q])=>q)),keys:Y,value:O,len:S,fallback:v.modifier===1?O.dec(v.fallback):void 0}};if(v.type.tag==="plain")return b(0,n(v.type.value),h);const{key:y,value:g,hashers:w}=v.type.value,m=n(g),x=w.map(S=>To[S.tag]),A=(()=>{if(x.length===1)return[[n(y),x[0]]];const S=e(y);switch(S.type){case"array":return x.map(O=>[n(S.value.id),O]);case"tuple":return S.value.map((O,U)=>[n(O.id),x[U]]);default:throw new Error("Invalid key type")}})();return b(x.length,m,h,...A)},c=f=>{switch(f.type){case"void":return C;case"lookupEntry":return n(f.value.id);case"tuple":return Te(...Object.values(f.value).map(h=>n(h.id)));case"struct":return me(kt(f.value,h=>n(h.id)));case"array":return ge(n(f.value.id),f.len)}},u=(f,h)=>{const p=t.pallets.find(v=>v.name===f).constants.find(v=>v.name===h);return n(p.type)},a=f=>(h,p)=>{const v=t.pallets.find(g=>g.name===h),b=e(v[f].type);if(b.type!=="enum")throw null;const y=b.value[p];return{location:[v.index,y.idx],codec:c(b.value[p])}},l=(f,h)=>{const p=t.pallets.find(v=>v.name===f)?.viewFns.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}},d=(f,h)=>{const p=t.apis.find(v=>v.name===f)?.methods.find(v=>v.name===h);if(!p)throw null;return{args:Te(...p.inputs.map(v=>n(v.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:l,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},yf=e=>Z($e.enc(e)),Ri=Q(),mf=it(Ri),gf=ge($e).dec,wf=e=>{const t=n=>{const r=(c,u)=>{const a=n();return a?e(a,c,u).pipe(lt(l=>{if(l instanceof Rt)return r(c,u);if(l instanceof Bn)return Vn(750).pipe(M(()=>r(c,u)));throw l})):wt},s=r("Metadata_metadata_versions","").pipe(I(gf)),o=r("Metadata_metadata","").pipe(I(c=>{const u=Ri.dec(c),a=ct.dec(u);return{metadata:St(a),metadataRaw:u}})),i=c=>r("Metadata_metadata_at_version",yf(c)).pipe(I(u=>{const a=mf.dec(u),l=ct.dec(a);return{metadata:St(l),metadataRaw:a}}));return s.pipe(lt(()=>He([14])),M(c=>c.includes(16)?i(16):c.includes(15)?i(15):o))};return n=>{const r=n(),s=new Set([r]),o=t(n).pipe(I(({metadata:c,metadataRaw:u})=>{const a=Fn(c),l=Pr(a),d=l.buildStorage("System","Events"),f=c.extrinsic.signedExtensions.find(p=>p.identifier==="ChargeAssetTxPayment");let h=null;if(f){const p=a(f.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:d.keys.enc(),dec:d.value.dec},accountId:vt(l.ss58Prefix)}}),Dn(1)),i={at:r,runtime:o,addBlock:c=>(s.add(c),i),deleteBlocks:c=>(c.forEach(u=>{s.delete(u)}),s.size),usages:s};return o.subscribe({error(){}}),i}},tn=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Pi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ui=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},xf=(e,t)=>{t.forEach(n=>{Ui(e.blocks,n)}),Object.entries(e.runtimes).map(([n,r])=>({key:n,usages:r.deleteBlocks(t)})).filter(n=>n.usages===0).map(n=>n.key).forEach(n=>{delete e.runtimes[n]})},Ef=(e,t,n,r,s)=>{const o=new Me,i=o.pipe(Ql(()=>Vn(0)),I(()=>({type:"cleanup"}))),c=Or(n,i,e).pipe(Jt((a,l)=>{const d=f=>{xf(a,f),r(f)};switch(l.type){case"initialized":a.recovering&&(l.finalizedBlockHashes.some(b=>a.blocks.has(b))||(a=Mi()));const[f]=l.finalizedBlockHashes.slice(-1);a.finalized=a.best=f;const h=l.finalizedBlockHashes.length-1;l.finalizedBlockHashes.forEach((v,b)=>{const y=a.blocks.get(v);y?(y.recovering=!1,y.unpinnable=b!==h):a.blocks.set(v,{hash:v,parent:b===0?l.parentHash:l.finalizedBlockHashes[b-1],children:new Set(b===h?[]:[l.finalizedBlockHashes[b+1]]),unpinnable:b!==h,runtime:v,refCount:0,number:l.number+b,recovering:!1})});const p=Object.values(a.runtimes).find(v=>v.usages.has(f));return a.finalizedRuntime=p??(a.runtimes[f]=u(Pi(a,f))),a;case"stop-error":for(const v of a.blocks.values())v.recovering=!0;return a.recovering=!0,a;case"newBlock":{const{parentBlockHash:v,blockHash:b}=l;if(a.blocks.has(b))a.blocks.get(b).recovering=!1;else{const y=a.blocks.get(v);y.children.add(b);const g={hash:b,number:y.number+1,parent:v,children:new Set,runtime:l.newRuntime?b:y.runtime,unpinnable:!1,refCount:0,recovering:!1};a.blocks.set(b,g),l.newRuntime&&(a.runtimes[b]=u(Pi(a,b))),a.runtimes[g.runtime].addBlock(b)}return a}case"bestBlockChanged":{if(a.recovering){for(const[v,b]of a.blocks)b.recovering&&(Ui(a.blocks,v),s(v));a.recovering=!1}return a.best=l.bestBlockHash,a}case"finalized":{a.finalized=l.finalizedBlockHashes.slice(-1)[0];const{blocks:v}=a;v.get(a.best).number<v.get(a.finalized).number&&(a.best=a.finalized),a.finalizedRuntime=a.runtimes[v.get(a.finalized).runtime],l.prunedBlockHashes.forEach(y=>{const g=a.blocks.get(y);g&&(g.unpinnable=!0)});let b=v.get(v.get(a.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=v.get(b.parent);return o.next(),a}case"cleanup":{const v=[...a.blocks.values()].filter(({unpinnable:b,refCount:y})=>b&&!y).map(({hash:b})=>b);return d(v),a}case"blockUsage":{if(!a.blocks.has(l.value.hash))return a;const v=a.blocks.get(l.value.hash);if(v.refCount+=l.value.type==="hold"?1:-1,v.refCount===0&&!v.recovering&&v.unpinnable){const b=[v.hash];d(b)}return a}}},Mi()),_e(a=>!!a.finalizedRuntime.runtime),I(a=>({...a})),tn),u=wf(zn(c,t,"pinned-blocks"));return c},Mi=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),Li=(e,t,n,r)=>{const s=c=>Ai(e.pipe(_e(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return He({hash:c,found:{type:!1,validity:null}});const l=s(c);return t(c).pipe(M(d=>{const f=d.indexOf(u);return f>-1?l(r(c)).pipe(I(h=>({hash:c,found:{type:!0,index:f,events:h}}))):n(c,u).pipe(I(h=>({hash:c,found:{type:!1,validity:h}})))}),l)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(M(l=>{const{found:d}=l;return d.type||d.validity?.success===!1?He(l):e.pipe(s(c),M(f=>f.blocks.get(c).children),Gl(),M(f=>i(f,u,a)))}));return c=>e.pipe(te(1),M(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},kf=new Uint8Array([2]),Af=(e,t)=>Z(re(kf,le(e),le(t))),Vi="TaggedTransactionQueue",Di="validate_transaction",[,Sf]=pe({InvalidTransaction:pe({Call:C,Payment:C,Future:C,Stale:C,BadProof:C,AncientBirthBlock:C,ExhaustsResources:C,Custom:z,BadMandatory:C,MandatoryValidation:C,BadSigner:C}),UnknownTransaction:pe({CannotLookup:C,NoUnsignedValidator:C,Custom:z})}),If=an(e=>{const t=z.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=Sf(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),Bf=(e,t)=>(n,r)=>{const s=t(n).pipe(I(o=>{try{return o.dynamicBuilder.buildRuntimeCall(Vi,Di).value[1]}catch{return If}}));return e(n,`${Vi}_${Di}`,Af(r,n)).pipe(Rr(s),I(([o,i])=>i(o)))},_f=e=>t=>new T(n=>{let r=!1;const s=t.subscribe({next(o){r=!0,n.next(o)},error(o){n.error(o)},complete(){n.complete()}});return r||n.next(e),s}),Cf=e=>t=>new T(n=>{const r=t.subscribe({next(o){n.next(o)},error(o){n.error(o)},complete(){n.complete()}}),s=()=>r.unsubscribe();return()=>{Promise.resolve().then(s)}}),ji=(e,t=1/0)=>n=>new T(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,l=0;const d=()=>{const f=o.get(a);if(!f){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),l!==h&&c.set(h,[]);let p=!1,v=f.subscribe({next(b){l===h?r.next(b):c.get(h).push(b)},complete(){if(p=!0,i.delete(h),h===l)for(l++;c.has(l)&&(c.get(l).forEach(b=>r.next(b)),c.delete(l),!i.has(l));)l++;d()},error(b){r.error(b)}});p||i.set(h,v)};return s=new gt,s.add(n.subscribe({next(f){const h=u++;o.set(h,Ln(()=>e(f,h))),i.size<t&&d()},error(f){r.error(f)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(f=>f.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Ur=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),$f=e=>{const{getFollower:t,startFollow:n,follow$:r,getHeader:s}=ff(e),o=cf(t),{withRecovery:i,withRecoveryFn:c}=rf(),u=new Me,a=E=>(u.next({type:"blockUsage",value:{type:"hold",hash:E}}),()=>{setTimeout(()=>{u.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),l=E=>B=>new T(R=>{const K=a(E),ie=B.subscribe(R);return ie.add(K),ie}),d=E=>(B,...R)=>E(B,...R).pipe(l(B)),f=(E,B)=>(R,...K)=>new T(ie=>{let ye=!1;return b.pipe(te(1)).subscribe(Ce=>{ye=Ce.blocks.has(R)}),ye?E(R,...K).subscribe(ie):ie.error(new Rt(R,B))}),h=E=>t().unpin(E).catch(B=>{if(!(B instanceof Sn))throw B}),p=(E,B)=>f(d(zn(b,c(Ci(E)),`stop-${B}`)),B),v=new Map,b=Ef(r,d(c(Ci(o("call")))),u,E=>{h(E),E.forEach(B=>{v.delete(B)})},E=>{v.delete(E)}),y=d(E=>b.pipe(te(1),M(B=>B.runtimes[B.blocks.get(E).runtime].runtime))),g=E=>B=>B.pipe(ji(R=>y(E(R)).pipe(I(K=>[R,K])))),w=(E,B,R)=>{const K=v.get(E)??new Map,ie=K.get(B);if(ie)return ie;v.set(E,K);let ye;const Ce=R.pipe(en({connector:()=>ye=new Pn}),Ii({complete(){K.set(B,ye)}}),Cf());return K.set(B,Ce),Ce},m=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized),Jt((E,B)=>{let R=B.blocks.get(B.finalized);const K=[R],ie=E.at(-1);if(!ie)return K;for(;R.number>ie.number+1&&(R=B.blocks.get(R.parent),!!R);)K.unshift(R);return K},[]),Mn(),I(Ur),tn),x=b.pipe(fe((E,B)=>E.best===B.best),I(E=>Ur(E.blocks.get(E.best))),tn),A=b.pipe(_e(E=>!E.recovering),fe((E,B)=>E.finalized===B.finalized&&E.best===B.best),Jt((E,B)=>{const R=ke=>E.get(ke)||Ur(B.blocks.get(ke)),K=R(B.best),ie=R(B.finalized),ye=K.number-ie.number+1,Ce=new Array(ye);for(let ke=0,on=K.hash;ke<ye;ke++)Ce[ke]=R(on),on=Ce[ke].parent;return new Map(Ce.map(ke=>[ke.hash,ke]))},new Map),I(E=>[...E.values()]),tn),S=b.pipe(fe((E,B)=>E.finalizedRuntime===B.finalizedRuntime),jn(({finalizedRuntime:{runtime:E}})=>E.pipe(_f(null))),tn),O=S.pipe(I(E=>E?.lookup.metadata??null)),U=of(m.pipe(I(E=>E.hash)),x.pipe(I(E=>E.hash)),l),Y=U(p(o("body"),"body")),N=E=>w(E,"body",Y(E)),q=p(o("storage"),"storage"),ne=U((E,B,R,K=null,ie)=>b.pipe(te(1),M(ye=>ye.runtimes[ye.blocks.get(E).runtime].runtime),M(ye=>{const Ce=R(ye),ke=w(E,`storage-${B}-${Ce}-${K??""}`,q(E,B,Ce,K));return ie?w(E,`storage-${B}-${Ce}-${K??""}-dec`,ke.pipe(I(on=>({raw:on,mapped:ie(on,ye)})))):ke}))),Qe=uf(t,i),Mt=U(zn(b,(E,B,R)=>Qe(E,B,R??null,!1),"storageQueries")),sn=U(zn(b,E=>Ln(()=>s(E)),"header")),Yn=E=>ne(E,"value",B=>B.events.key,null,(B,R)=>R.events.dec(B)).pipe(I(B=>B.mapped)),Ch=p(o("call"),"call"),cc=U((E,B,R)=>w(E,`call-${B}-${R}`,Ch(E,B,R))),Zr=Bf(cc,y),ac=E=>w(E,"body",Y(E)),$h=Li(b,ac,Zr,Yn),Oh=Li(b,ac,Zr,()=>He()),Th=S.pipe(_e(Boolean),te(1),M(E=>{const{enc:B}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let R;try{R=B(0)}catch{R=B(0n)}return ne(null,"value",()=>R,null)}),Dn(1));Or(S,A).subscribe({error(){}});let Jr=Ue,Gn=!1,es=0;const Rh=E=>{es+=E,Gn=!0,Jr=n()};return[{follow$:r,finalized$:m,best$:x,bestBlocks$:A,newBlocks$:af(b),runtime$:S,metadata$:O,genesis$:Th,header$:sn,body$:N,call$:cc,storage$:ne,storageQueries$:Mt,eventsAt$:Yn,holdBlock:a,trackTx$:$h,trackTxWithoutEvents$:Oh,validateTx$:Zr,pinnedBlocks$:b,withRuntime:g,getRuntimeContext$:U(y),unfollow:()=>{Gn!=null&&(es--,Gn&&!es&&(Gn=null,Jr(),Jr=Ue))}},Rh]};var Of=e=>t=>new T(n=>e(t,r=>{n.error(r)}));const Hn=new Map,Tf=e=>{const t=Hn.get(e);if(t)return t.refCount++,t.client;const n=()=>{const c=Hn.get(e);!c||c.refCount<=1?(Hn.delete(e),e.destroy()):c.refCount--};let r=null,s=0,o=null;const i={chainHead$:c=>{s++,o||(o=c||1),r||(r=$f(e.chainHead));const[u,a]=r;if(o===s){const l=s;s=0,o=null,r=null,a(l)}return u},broadcastTx$:Of(e.transaction),destroy:n};return Hn.set(e,{client:i,refCount:1}),i},Rf=(e,t)=>e.pipe(Si(n=>n.blocks.has(t)),fe((n,r)=>n.finalized===r.finalized&&n.best===r.best),I(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let s=n.blocks.get(n.best),o=n.finalized===s.hash;for(;s.number>r;)s=n.blocks.get(s.parent),o=o||n.finalized===s.hash;return o?"finalized":s.hash===t?"best":null}),fe(),Si(n=>n!=="finalized",!0));class Pt{constructor(){}_runtime(t){}}class zi{constructor(){}_compatibility(t){}}const qn=new WeakMap,Fi=new WeakMap,Mr=e=>e instanceof Pt?Fi.get(e):qn.get(e);var ht=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(ht||{});const Pf=ge(_u),Uf=ge(yr),Mf=Te(Pf,Uf),Lf=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(_e(i=>i!=null));let o=await Le(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(Mf.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new zi;return qn.set(c,{runtime:i,getEntryPoint(u,a,l){const d=o[u]?.[a]?.[l];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${l} does not exist`);return r[d]},typedefNodes:s}),c})},Vf=e=>new Promise(async t=>{const n=e.runtime$.pipe(_e(s=>s!=null));let r=await Le(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Pt;return Fi.set(n,{runtime:t}),n}),Lr=new WeakMap,Hi=e=>(Lr.has(e.metadataRaw)||Lr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Lr.get(e.metadataRaw)),xt=(e,t,n)=>{const r=(i,c)=>{var u;const a=Hi(i);return(u=a.typeNodes)[c]||(u[c]=xn(a.lookup(c)))};function s(i,c){if(i instanceof Pt)return{args:Ie.Identical,values:Ie.Identical};const u=qn.get(i);c||(c=u.runtime());const a=t(u),l=n(c);if(l==null)return{args:Ie.Incompatible,values:Ie.Incompatible};const d=u.typedefNodes,f=Hi(c);return Tu(a,h=>d[h],l,h=>r(c,h),f.compat)}const o=Wi(e,i=>qi(s(i)));return{isCompatible:Wi(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Tt([u.pipe(i.withRuntime(c)),e]).pipe(I(([[a,l],d])=>[a,d,l])),compatibleRuntime$:(i,c)=>Tt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c);if(a.args===Ie.Incompatible)return!1;if(a.args>Ie.Partial)return!0;if(a.values===Ie.Incompatible)return!1;const l=n(c);return l==null?!1:Vo(l.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Pt)return!0;const a=s(i,c).values;if(a===Ie.Incompatible)return!1;if(a>Ie.Partial)return!0;const l=qn.get(i),d=t(l);return Vo(d.values,f=>l.typedefNodes[f],u)},getRuntimeTypedef:r}},qi=e=>Math.min(e.args,e.values),Wi=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof zi||r instanceof Pt?t(...n):e.then(s=>t(...n,s))},Df=(e,t,{valuesAreCompatible:n,descriptors:r,isCompatible:s,getCompatibilityLevel:o})=>{const i=new WeakMap,c=a=>{if(i.has(a))return i.get(a);const l=a.lookup.metadata.pallets.find(f=>f.name===e)?.constants.find(f=>f.name===t);if(l==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(l.value);return i.set(a,d),d},u=a=>{if(a){const l=Mr(a).runtime(),d=c(l);if(!n(a,l,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},jf=en({connector:()=>new Pn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function Wn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new zs)}:Ue;s=e.subscribe({next:c=>{n(c),s?.unsubscribe(),o=!0},error:c=>{t?.removeEventListener("abort",i),r(c),o=!0},complete:()=>{t?.removeEventListener("abort",i),r(new Error("Observable completed without emitting")),o=!0}}),o||t?.addEventListener("abort",i)})}const Vr=Symbol("EMPTY_VALUE"),Dr=e=>t=>new T(n=>{let r=0,s=null,o=Vr,i=!1;const c=()=>{const a=e(o,r++);o=Vr,s=a.subscribe({next(l){n.next(l)},error(l){n.error(l)},complete(){o!==Vr?c():(s=null,i&&n.complete())}})},u=t.subscribe({next(a){o=a,s||c()},error(a){n.error(a)},complete(){s||n.complete(),i=!0}});return()=>{s?.unsubscribe(),u.unsubscribe()}});let Ki={};const zf=e=>t=>new T(n=>{let r=Ki,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===Ki?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Ut=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)),Ff=()=>{const e=new cl(new Me);return[e.pipe(Jl()),()=>Ii({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new Me)},complete:()=>{e.value.complete(),e.next(new Me)}})]},Hf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,withCompatibleRuntime:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry Event(${e}.${t})`),a=n.finalized$.pipe(o(n,l=>l.hash),I(([l,d,f])=>{const h=f.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(h==null||f.lookup.metadata.lookup[h].def.tag!=="variant"||f.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,f,null))throw u();return[l,d,f]}),ji(([l,d,f])=>n.eventsAt$(l.hash).pipe(I(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,f,p.event.value.value))throw u();return{meta:{phase:p.phase,block:l},payload:p.event.value.value}})))),jf);return{watch:l=>a.pipe(M(d=>l?d.filter(f=>l(f.payload)):d)),pull:()=>Le(a),filter:l=>l.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},qf=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=`${e}_${t}`,a=()=>new Error(`Incompatible runtime entry RuntimeCall(${u})`);return Object.assign((...l)=>{const d=l[l.length-1],f=Ut(d),{signal:h,at:p}=f?d:{},v=p??null,b=o(n,v).pipe(M(([y,g])=>{let w;try{w=g.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,g,l))throw a();return n.call$(v,u,Z(w.args.enc(l))).pipe(I(w.value.dec),I(m=>{if(!c(y,g,m))throw a();return m}))}));return Wn(b,h)},{getCompatibilityLevel:s,isCompatible:r})},jr=I(e=>e.mapped),Wf=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const l=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",f=n.runtime$.pipe(_e(Boolean),te(1),I(({dynamicBuilder:m})=>typeof m.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Ne),Dn()),h=Qo(ql(f),I(([m,x])=>x(m))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),v=m=>new Error(`Invalid Arguments calling ${e}.${t}(${m})`),b=m=>{try{return m.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...m)=>{const x=m[m.length-1],A=x==="best",S=A||x==="finalized"?m.slice(0,-1):m;return n[A?"best$":"finalized$"].pipe(Dr(()=>g(...S,A?{at:"best"}:{})),fe((O,U)=>O.raw===U.raw),jr)},g=(...m)=>{const x=m[m.length-1],A=Ut(x),{at:S}=A?x:{},O=S??null;return l?n.pinnedBlocks$.pipe(I(U=>{const Y=O==="finalized"||!O?U.finalized:O==="best"?U.best:O,N=U.blocks.get(Y);if(!N)throw new Rt(Y,"System.Number");return N.number}),fe(),h,I(U=>({raw:U,mapped:U}))):d&&Number(m[0])===0?n.genesis$.pipe(I(U=>({raw:U,mapped:bn.fromHex(U)}))):Ot(c).pipe(M(U=>n.storage$(O,"value",Y=>{const N=b(Y),q=m.length===N.len?m:m.slice(0,-1);if(m!==q&&!A)throw v(m);if(!u(U,Y,q))throw p();return N.keys.enc(...q)},null,(Y,N)=>{const q=b(N),ne=Y===null?q.fallback:q.value.dec(Y);if(!a(U,N,ne))throw p();return ne})))},w=async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S}=A?x:{};return Wn(g(...m).pipe(jr),S)};return{isCompatible:s,getCompatibilityLevel:o,getValue:w,getValues:(m,x)=>Promise.all(m.map(A=>w(...x?[...A,x]:A))),getEntries:async(...m)=>{const x=m[m.length-1],A=Ut(x),{signal:S,at:O}=A?x:{},U=O??null,Y=await c,N=n.storage$(U,"descendantsValues",q=>{const ne=b(q);if(qi(i(Y,q))===Ie.Incompatible)throw p();if(m.length>ne.len)throw v(m);const Qe=m.length>0&&A?m.slice(0,-1):m;if(m.length===ne.len&&Qe===m)throw v(m);return ne.keys.enc(...Qe)},null,(q,ne)=>{const Qe=b(ne),Mt=q.map(({key:sn,value:Yn})=>({keyArgs:Qe.keys.dec(sn),value:Qe.value.dec(Yn)}));if(Mt.some(({value:sn})=>!a(Y,ne,sn)))throw p();return Mt}).pipe(jr);return Wn(N,S)},watchValue:y,watchEntries:(...m)=>{const x=m.at(-1),A=Ut(x);return r(e,t,A?m.slice(0,-1):m,A&&x.at==="best")}}},Kf=Vt(z.enc,e=>+!!e.signed<<7|e.version),zr=()=>new Error("Unkown signer"),Xf=e=>{const{extrinsic:t}=e,n=Fn(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw zr()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw zr();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw zr()},Yf={Ed25519:0,Sr25519:1,Ecdsa:2},Gf=(e,t,n,r,s,o)=>{const[i,c]=Xf(e),u=re(Kf({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Yf[o],...n]),...r,s);return re(ae.enc(u.length),u)},[Kn,nn]=["<Bytes>","</Bytes>"].map(e=>je.fromText(e).asBytes()),Nf=e=>async t=>{let n=!0,r;for(r=0;n&&r<Kn.length;r++)n=Kn[r]===t[r];n=n&&r===Kn.length;const s=t.length-nn.length;for(r=0;n&&r<nn.length;r++)n=nn[r]===t[s+r];return n=n&&r===nn.length,e(n?t:re(Kn,t,nn))};function Qf(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=Yt)=>{const a=St(dr(i)),l=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const v=o[p];if(!v)throw new Error(`Missing ${p} signed extension`);l.push(v.value),d.push(v.additionalSigned)});const f=re(s,...l,...d),h=await n(f.length>256?u(f):f);return Gf(a,e,h,l,s,t)},signBytes:Nf(n)}}Uint8Array.from([1]);const Zf=(e,t)=>{const n=e.metadata.pallets.find(o=>o.name==="System").constants.find(o=>o.name==="Version"),r=e(n.type),s=t.buildDefinition(n.type).dec;if(r.type!=="struct")throw new Error("not a struct");return s(n.value)};function Jf(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const eh=Vt(Q(2)[0],e=>{const t=Math.max(e.period>>12,1),n=Math.min(Math.max(Jf(e.period)-1,1),15),r=e.phase/t<<4;return et[0](n|r)}),[th]=me({tip:ae,asset:it(Q(1/0))}),Xi=new Uint8Array,Fr=Uint8Array.from([0]),Hr=e=>({value:e,additionalSigned:Xi}),qr=e=>({value:Xi,additionalSigned:e}),Wr=(e,t)=>({value:e,additionalSigned:t}),Yi=(e,t,n)=>{const r={};return t.metadata.extrinsic.signedExtensions.forEach(({identifier:s,type:o,additionalSigned:i})=>{r[s]=[o,i].map(c=>n.buildDefinition(c)[0])}),({mortality:s,tip:o=0n,nonce:i,customSignedExtensions:c={},...u})=>{const a=[],l=Zf(t,n),d=h=>{const[p,v]=r[h],b=c[h];try{return kt({value:p,additionalSigned:v},(y,g)=>{const w=b?.[g];return w instanceof Uint8Array?w:y(w)})}catch{return a.push(h),null}},f=kt(r,([h,p],v)=>{if(c[v])return d(v);switch(v){case"CheckNonce":return Hr(h(i));case"CheckMortality":return s.mortal?Wr(eh({period:s.period,phase:s.startAtBlock.height%s.period}),le(s.startAtBlock.hash)):Wr(Fr,e);case"ChargeTransactionPayment":return Hr(h(o));case"ChargeAssetTxPayment":return Hr(th({tip:o,asset:u.asset}));case"CheckGenesis":return qr(e);case"CheckMetadataHash":return Wr(Fr,Fr);case"CheckSpecVersion":return qr(p(l.spec_version));case"CheckTxVersion":return qr(p(l.transaction_version));default:return d(v)}});return a.forEach(h=>{delete f[h]}),kt(f,(h,p)=>({...h,identifier:p}))}},Gi="AccountNonceApi_account_nonce",nh={1:z.dec,2:et.dec,4:$e.dec,8:Dt.dec},rh=(e,t,n)=>e(n,Gi,t).pipe(I(r=>{const s=le(r),o=nh[s.length];if(!o)throw new Error(`${Gi} retrieved wrong data`);return o(s)})),sh=(e,t,n,r,s,o={})=>Tt([o.nonce?He(o.nonce):oh(e,Z(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(te(1),M(([i,c,u])=>{const a=Yi(le(u),c.lookup,c.dynamicBuilder),l=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:l.mortal?{mortal:!0,period:l.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),oh=(e,t)=>{const n=o=>e.newBlocks$.pipe(Jt((i,c)=>c.parent===i?c.hash:i,o),ki(o),fe()),r=o=>n(o).pipe(te(2),jn(i=>rh(e.call$,t,i))),s=o=>Tt(o.map(i=>r(i).pipe(I(c=>({success:!0,value:c})),lt(c=>He({success:!1,value:c}))))).pipe(te(1));return e.pinnedBlocks$.pipe(_e(o=>!o.recovering&&o.blocks.size>0),te(1),I(({blocks:o,best:i})=>{const c=o.get(i);return[...o.values()].filter(u=>!u.unpinnable&&u.children.size===0&&u.number>=c.number).map(u=>u.hash)}),jn(s),I(o=>{const i=o.reduce((c,u)=>u.success&&u.value>=(c??0)?u.value:c,null);if(i==null)throw o[0].value;return i}))};var ih=Object.defineProperty,ch=(e,t,n)=>t in e?ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ah=(e,t,n)=>ch(e,t+"",n);const uh=e=>Z(Yt(le(e))),lh=(e,t)=>new T(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),l=s.blocks.get(u).number;for(;!a;){const h=s.blocks.get(u);if(!h)break;a=r.get(u=h.parent),l--}if(!a)return;const d=l<=s.blocks.get(s.finalized).number,f=a.found.type;if(f&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:f,hash:a.hash,number:l,index:a.found.index,events:a.found.events}:{found:f,validity:a.found.validity}),d&&(f?n.complete():a.found.validity?.success===!1&&n.error(new Kr(a.found.validity.value)))},c=t.pipe(fe((u,a)=>u.finalized===a.finalized&&u.best===a.best)).subscribe({next:u=>{s=u,r.size!==0&&i()},error(u){n.error(u)}});return c.add(e.subscribe({next:u=>{r.set(u.hash,u),i()},error(u){n.error(u)}})),c}).pipe(fe((n,r)=>n===r)),fh=(e,t)=>{const n=e.filter(s=>s.phase.type==="ApplyExtrinsic"&&s.phase.value===t).map(s=>({...s.event,topics:s.topics})),r=n[n.length-1];return r.type==="System"&&r.value.type==="ExtrinsicFailed"?{ok:!1,events:n,dispatchError:r.value.value.dispatch_error}:{ok:!0,events:n}};class Kr extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof je?r.asHex():r,2)),ah(this,"error"),this.name="InvalidTxError",this.error=t}}const Xr=(e,t,n,r,s=!1)=>{const o=uh(n),i=(l,d)=>({type:l,txHash:o,...d}),c=e.pinnedBlocks$.pipe(te(1),I(l=>{const d=l.blocks.get(r);return d?d.hash:l.finalized})).pipe(M(l=>e.validateTx$(l,n).pipe(_e(d=>!d.success),I(d=>{throw new Kr(d.value)})))),u=new T(l=>{const d=e.trackTx$(n).subscribe(l);return d.add(t(n).subscribe({error(f){l.error(f)}})),d}),a=lh(u,e.pinnedBlocks$).pipe(I(l=>l.found?i("txBestBlocksState",{found:!0,block:{index:l.index,number:l.number,hash:l.hash},...fh(l.events,l.index)}):i("txBestBlocksState",{found:!1,isValid:l.validity?.success!==!1})));return $r(s?He(i("signed",{})):wt,c,He(i("broadcasted",{})),a.pipe(zf(({found:l,type:d,...f})=>l?He(i("finalized",f)):wt)))},Ni=async(e,t,n,r)=>Il(Xr(e,t,n,r)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),hh=vt().enc,dh=new Uint8Array(64),ph=new Uint8Array(65),vh=e=>()=>e?ph:dh,[,bh]=me({weight:me({ref_time:yn,proof_size:yn}),class:pe({Normal:C,Operational:C,Mandatory:C}),partial_fee:os}),Qi=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(l=>{const d=(m,x,A={})=>{const S=Mr(m).runtime(),{dynamicBuilder:O,assetId:U,lookup:Y}=S;let N;try{N=O.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(m,S,x))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=A;if(A.asset){if(U==null||!mr(A.asset,xn(Y(U)),Mt=>u(S,Mt)))throw new Error("Incompatible runtime asset");q={...A,asset:O.buildDefinition(U).enc(A.asset)}}const{location:ne,codec:Qe}=N;return{callData:je.fromBytes(re(new Uint8Array(ne),Qe.enc(x))),options:q}},f=(m,x={})=>i(n,null).pipe(I(([A])=>d(A,m,x))),h=m=>m?d(m,l).callData:Le(f(l).pipe(I(x=>x.callData))),p=(m,{...x},A)=>f(l,x).pipe(M(({callData:S,options:O})=>sh(n,m,S.asBytes(),A,x.customSignedExtensions||{},O))),v=(m,{at:x,...A}={})=>(!x||x==="finalized"?n.finalized$:x==="best"?n.best$:n.bestBlocks$.pipe(I(S=>S.find(O=>O.hash===x)))).pipe(te(1),M(S=>S?p(m,A,S).pipe(I(O=>({tx:Z(O),block:S}))):Un(()=>new Error(`Uknown block ${x}`)))),b=(m,x)=>Le(v(m,x)).then(A=>A.tx),y=(m,x)=>Le(v(m,x)).then(({tx:A,block:S})=>Ni(n,r,A,S.hash)),g=(m,x)=>v(m,x).pipe(M(({tx:A,block:S})=>Xr(n,r,A,S.hash,!0))),w=async(m,x)=>{typeof m=="string"&&(m=m.startsWith("0x")?le(m):hh(m));const A=m.length===20,S=Qf(m,A?"Ecdsa":"Sr25519",vh(A)),O=le(await b(S,x)),U=Z(re(O,$e.enc(O.length))),Y=n.getRuntimeContext$(null).pipe(I(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return bh}})),N=n.call$(null,"TransactionPaymentApi_query_info",U);return Le(Tt([N,Y]).pipe(I(([q,ne])=>ne(q))))};return{getPaymentInfo:w,getEstimatedFees:async(m,x)=>(await w(m,x)).partial_fee,decodedCall:{type:e,value:yt(t,l)},getEncodedData:h,sign:b,signSubmitAndWatch:g,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var yh=Object.defineProperty,mh=(e,t,n)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t,n)=>(mh(e,typeof t!="symbol"?t+"":t,n),n),Yr=Symbol("SUSPENSE"),gh=class extends Promise{constructor(e){super(e)}},Zi=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},Ji=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Ee={},Xn=class extends T{constructor(e,t,n=Ue){super(r=>{const s=new Qt({next:r.next.bind(r),error:r.error.bind(r),complete:Ue});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Ee,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new Zi),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Ee&&r.next(this.currentValue)):(this.subject=new Me,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new Qt({next:i=>{this.promise&&i!==Yr&&(this.promise.res(i),this.promise=null),this.subject.next(this.currentValue=i)},error:i=>{var c;this.subscription=null;const u=this.subject;this.subject=null,this.currentValue=Ee;const a=(c=this.promise)==null?void 0:c.rej;a&&i===Yr&&(this.promise.rej=()=>{a(i)}),u.error(i),a&&this.promise&&(this.promise.rej=a)},complete:()=>{if(this.subscription=null,this.promise&&(this.promise.rej(new Ji),this.promise=null),this.currentValue!==Ee)return this.subject.complete();if(t===Ee){const i=this.subject;return this.subject=null,i.error(new Ji)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Ee&&this.currentValue===Ee&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,qe(this,"subject",null),qe(this,"subscription",null),qe(this,"refCount",0),qe(this,"currentValue",Ee),qe(this,"promise",null),qe(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof Xn?s:new Xn(s,Ee)}),qe(this,"getRefCount",()=>this.refCount),qe(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Ee&&this.currentValue!==Yr)return this.currentValue;if(this.defaultValue!==Ee)return this.defaultValue;if(this.refCount===0)throw new Zi;const r=new gh((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),qe(this,"getDefaultValue",()=>this.defaultValue),t===Ee&&delete this.getDefaultValue}};function ec(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function wh(e,t){const n=new xh,r=typeof t=="function"?t:()=>t,s=o=>{for(let d=o.length-1;o[d]===void 0&&d>-1;d--)o.splice(-1);const i=[o.length,...o],c=n.get(i);if(c!==void 0)return c;const u=new Xn(e(...o),r(...o),()=>{n.delete(i)}),a=new T(d=>{const f=n.get(i);let h=u;return f?f!==a&&(h=f,ec(h,a)):n.set(i,l),h.subscribe(d)});ec(u,a);const l=a;return n.set(i,l),l};return(...o)=>s(o)}var xh=class{constructor(){qe(this,"root"),this.root=new Map}get(e){let t=this.root;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),!t)return;return t}set(e,t){let n=this.root,r;for(r=0;r<e.length-1;r++){let s=n.get(e[r]);s||(s=new Map,n.set(e[r],s)),n=s}n.set(e[r],t)}delete(e){const t=[this.root];let n=this.root;for(let s=0;s<e.length-1;s++)t.push(n=n.get(e[s]));let r=t.length-1;for(t[r].delete(e[r]);--r>-1&&t[r].get(e[r]).size===0;)t[r].delete(e[r])}};function Eh(e,t){return new Xn(e,t)}var Gr=(...e)=>(typeof e[0]=="function"?wh:Eh)(e[0],e.length>1?e[1]:Ee);const tc=(e,t,n)=>{const r=new Map(t.map(c=>[c.key,c])),s=new Map(e.map(c=>[c.key,c])),o=new Map,i=[];return t.forEach(c=>{const{key:u}=c,a=s.get(u);(!a||a.value!==c.value)&&o.set(u,n(c))}),e.forEach(c=>{r.has(c.key)||i.push(c)}),{deltas:{deleted:i,upserted:[...o.values()]},entries:t.map(({key:c})=>o.get(c)??s.get(c))}},nc=(e,t,n,r=!1)=>{try{let s=r?e:n.blocks.get(e).parent;for(;s&&!t[s];)s=n.blocks.get(s).parent;return s?t[s]:null}catch{return null}},rc=(e,t)=>n=>{const{keys:r,value:s}=n.dynamicBuilder.buildStorage(e,t);return o=>(o.dec={value:s.dec(o.value),args:r.dec(o.key)},o)},kh=(e,t,n)=>{const r=Gr((c,u,a)=>{const l=rc(c,u),d=(b,y)=>{const g=Rf(e,y.hash).pipe(_e(w=>!w),te(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(M(w=>w===b?.rootHash?He({...b,block:y,deltas:null,prev:b.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),I(([m,x])=>[m,l(x)]),I(([m,x])=>({prev:b&&b.block.hash,rootHash:w,block:y,...tc(b?.entries??[],m,x)})))),Ai(g),lt(w=>w instanceof Rt?wt:Un(()=>w)))},f=e.pipe(fe((b,y)=>b.finalized===y.finalized),Dr(({blocks:b,finalized:y})=>d(null,b.get(y))),te(1),I(b=>({blocks:{[b.block.hash]:b},finalized:b.block.hash}))),[h,p]=Ff(),v=e.pipe(fe((b,y)=>b.best===y.best),Rr(h),Dr(([b,y])=>{const{best:g}=b,{blocks:w}=y;let m=w[g]?null:g;if(!m)return wt;const x=nc(m,w,b);return x?d(x,b.blocks.get(m)).pipe(I(A=>(w[m]=A,y))):(m=b.finalized,d(w[y.finalized],b.blocks.get(m)).pipe(I(A=>(A.prev=null,{blocks:{[m]:A},finalized:m}))))}));return Or(f,v).pipe(p())}),s=c=>(u,a,l)=>{const d=r(u,a,l),f=rc(u,a),h=c?"finalized":"best";return Tt([d.pipe(Yl(0)),e.pipe(fe((p,v)=>p[h]===v[h]))]).pipe(I(([p,v])=>nc(v[h],p.blocks,v,!0)),_e(Boolean),fe(),ki(null),Zl(),Rr(d),n(([[,p]])=>p.block.hash),I(([[[p,v],b],y])=>[p,v,b,f(y)]),M(([p,v,b,y])=>{if(!p)return[v];let g=v;const w=[];for(;g&&g.block.number>p.block.number;)w.unshift(g),g=g.prev?b.blocks[g.prev]:null;if(c&&(b.finalized=v.block.hash,w.length)){const{blocks:m}=b;Object.keys(m).forEach(x=>{m[x].block.number<w[0].block.number&&delete m[x]})}return p===g?w:[{...v,...p.rootHash===v.rootHash?{entries:p.entries,deltas:null}:tc(p.entries,v.entries,y)}]}))},o=Gr(s(!0)),i=Gr(s(!1));return(c,u,a,l)=>{const d=l?i:o;return e.pipe(te(1),M(f=>f.runtimes[f.blocks.get(f[l?"best":"finalized"]).runtime].runtime),I(f=>f.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(te(1),M(f=>d(c,u,f)),I(({block:{hash:f,number:h,parent:p},deltas:v,entries:b},y)=>{const g=y>0?v:{deleted:[],upserted:b};return{block:{hash:f,number:h,parent:p},entries:b.map(Nr),deltas:g&&{deleted:g.deleted.map(Nr),upserted:g.upserted.map(Nr)}}}))}},Nr=e=>e.dec,sc="RuntimeViewFunction",oc="execute_view_function",Qr=sc+"_"+oc,Ah=(e,t,n,{isCompatible:r,getCompatibilityLevel:s,compatibleRuntime$:o,argsAreCompatible:i,valuesAreCompatible:c})=>{const u=()=>new Error(`Incompatible runtime entry ViewFn(${e}.${t})`);return Object.assign((...a)=>{const l=a[a.length-1],d=Ut(l),{signal:f,at:h}=d?l:{},p=h??null,v=o(n,p).pipe(M(([b,y])=>{let g;try{g=y.dynamicBuilder.buildRuntimeCall(sc,oc)}catch{throw new Error(`Runtime entry RuntimeCall(${Qr}) not found`)}let w;try{w=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(b,y,a))throw u();const m=w.args.enc(a),x=re(le(y.lookup.metadata.pallets.find(({name:A})=>A===e).viewFns.find(({name:A})=>A===t).id),_.enc(m.length),m);return n.call$(p,Qr,Z(x)).pipe(I(A=>{try{const S=g.value.dec(A);if(!("success"in S&&"value"in S)||!("type"in S.value)&&!("asBytes"in S.value))throw null;return S}catch{throw new Error(`Unexpected RuntimeCall(${Qr}) type`)}}),I(({success:A,value:S})=>{if(!A)throw new Error(`ViewFn API Error: ${S.type}`);const O=w.value.dec(S.asBytes());if(!c(b,y,O))throw u();return O}))}));return Wn(v,f)},{getCompatibilityLevel:s,isCompatible:r})},ic=(e,t,n)=>{const r={},s=b=>new Proxy(r,{get(y,g){return b(g)}}),o=b=>{const y={};return s(g=>(y[g]||(y[g]={}),s(w=>(y[g][w]||(y[g][w]=b(g,w)),y[g][w]))))},i=(b,y)=>b.lookup.metadata.pallets.find(g=>g.name===y),c=kh(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((b,y)=>Wf(b,y,t,c,xt(e,g=>g.getEntryPoint(ht.Storage,b,y),g=>{const w=i(g,b)?.storage?.items.find(m=>m.name===y);return w==null?null:Cu(w)}))),a=(b,y,g,w)=>{if(g==null)return null;const m=b.lookup(g);if(m.type!=="enum")throw new Error("Expected enum");if(m.value[w]==null)return null;const x=$u(m.value[w]);return{args:y==="args"?x:kn,values:y==="args"?kn:x}},l=o((b,y)=>Qi(b,y,t,n,xt(e,g=>g.getEntryPoint(ht.Tx,b,y),g=>a(g,"args",i(g,b)?.calls?.type,y)),!0)),d=o((b,y)=>Hf(b,y,t,xt(e,g=>g.getEntryPoint(ht.Event,b,y),g=>a(g,"values",i(g,b)?.events?.type,y)))),f=o((b,y)=>Df(b,y,xt(e,g=>g.getEntryPoint(ht.Const,b,y),g=>{const w=i(g,b)?.constants.find(m=>m.name===y)?.type;return w==null?null:Ou(w)}))),h=o((b,y)=>qf(b,y,t,xt(e,g=>g.getEntryPoint(ht.Api,b,y),g=>Lo(g.lookup.metadata.apis.find(w=>w.name===b).methods.find(w=>w.name===y))))),p=o((b,y)=>Ah(b,y,t,xt(e,g=>g.getEntryPoint(ht.ViewFns,b,y),g=>Lo(g.lookup.metadata.pallets.find(w=>w.name===b).viewFns.find(w=>w.name===y))))),v=(b,y)=>{const{lookup:g,dynamicBuilder:w}=Mr(y).runtime();try{const m=w.buildDefinition(g.call).dec(b.asBytes()),x=m.type,A=m.value.type,S=m.value.value;return Qi(x,A,t,n,xt(e,O=>O.getEntryPoint(ht.Tx,x,A),O=>a(O,"args",i(O,x)?.calls?.type,A)),!1)(S)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(b,y)=>y?v(b,y):e.then(g=>v(b,g)),tx:l,event:d,apis:h,constants:f,view:p}};function Sh(e){const t=Xu(e),n=Tf(t),{getChainSpecData:r}=t,{genesis$:s,...o}=n.chainHead$(),i={...o,genesis$:Ln(r).pipe(I(({genesisHash:h})=>h),lt(()=>s),Dn(1))},c=t.request;let u;const a=new WeakMap,l=h=>{const p=a.get(h)||Lf(h,i);return a.set(h,p),p},d=()=>u??(u=Vf(i)),{broadcastTx$:f}=n;return{getChainSpecData:r,blocks$:i.newBlocks$,finalizedBlock$:i.finalized$,getFinalizedBlock:()=>Le(i.finalized$),bestBlocks$:i.bestBlocks$,getBestBlocks:()=>Le(i.bestBlocks$),watchBlockBody:i.body$,getBlockBody:h=>Le(i.body$(h)),getBlockHeader:h=>Le(i.header$(h??null)),submit:(...h)=>Ni(i,f,...h),submitAndWatch:(...h)=>Xr(i,f,...h),getTypedApi:h=>{const p=l(h);return Object.assign(ic(p,i,f),{compatibilityToken:p})},getUnsafeApi:()=>{const h=d();return Object.assign(ic(h,i,f),{runtimeToken:h})},destroy:()=>{i.unfollow(),n.destroy()},_request:c}}const Ih=(e,t,n,r,s)=>{let o;try{o=r.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}const{location:i,codec:c}=o,u=new Uint8Array(i);return a=>{const l=je.fromBytes(re(u,c.enc(a)));return{encodedData:l,decodedCall:yt(e,yt(t,a)),sign:async(d,f)=>Z(await d.signTx(l.asBytes(),s(f),n,f.mortality.mortal?f.mortality.startAtBlock.height:0))}}},Bh=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=le(e),r=await t(),s=St(ct.dec(r)),o=Fn(s),i=Pr(o),c=Yi(n,o,i),u=p=>s.pallets.find(v=>v.name===p),a={},l=p=>new Proxy(a,{get(v,b){return p(b)}}),d=p=>{const v={};return l(b=>(v[b]||(v[b]={}),l(y=>(v[b][y]||(v[b][y]=p(b,y)),v[b][y]))))},f=d((p,v)=>{const b=u(p)?.constants.find(y=>y.name===v);if(!b)throw new Error(`Runtime entry Constant(${p}.${v}) not found`);return i.buildConstant(p,v).dec(b.value)}),h=d((p,v)=>Ih(p,v,r,i,c));return{constants:f,tx:h}},rn=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},_h=async e=>{const t=St(dr(await e.getMetadata())),n={},r=d=>new Proxy(n,{get(f,h){return d(h)}}),s=d=>{const f={};return r(h=>(f[h]||(f[h]={}),r(p=>(f[h][p]||(f[h][p]=d(h,p)),f[h][p]))))},o=Fn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:l}=Pr(o);return{query:s((...d)=>{const{value:f,args:h}=rn(c,"Storage")(...d);return{value:f,args:h}}),tx:s((...d)=>rn(a,"Call")(...d).codec),event:s((...d)=>rn(l,"Event")(...d).codec),apis:s(rn(i,"Runtime API")),constants:s(rn(u,"Constant"))}};ce.AccountId=vt,ce.Binary=je,ce.CompatibilityLevel=Ie,ce.Enum=yt,ce.FixedSizeBinary=bn,ce.InvalidTxError=Kr,ce._Enum=Qs,ce.createClient=Sh,ce.getOfflineApi=Bh,ce.getSs58AddressInfo=nr,ce.getTypedCodecs=_h});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -192,23 +192,23 @@
192
192
  },
193
193
  "dependencies": {
194
194
  "@rx-state/core": "^0.1.4",
195
- "@polkadot-api/cli": "0.12.0",
195
+ "@polkadot-api/cli": "0.12.1",
196
196
  "@polkadot-api/ink-contracts": "0.3.1",
197
197
  "@polkadot-api/json-rpc-provider": "0.0.4",
198
198
  "@polkadot-api/known-chains": "0.7.5",
199
199
  "@polkadot-api/logs-provider": "0.0.6",
200
- "@polkadot-api/metadata-builders": "0.12.0",
201
200
  "@polkadot-api/metadata-compatibility": "0.2.2",
202
- "@polkadot-api/observable-client": "0.10.0",
201
+ "@polkadot-api/observable-client": "0.10.1",
202
+ "@polkadot-api/metadata-builders": "0.12.0",
203
203
  "@polkadot-api/pjs-signer": "0.6.7",
204
204
  "@polkadot-api/polkadot-sdk-compat": "2.3.2",
205
205
  "@polkadot-api/signer": "0.2.0",
206
+ "@polkadot-api/sm-provider": "0.1.7",
206
207
  "@polkadot-api/smoldot": "0.3.8",
207
208
  "@polkadot-api/polkadot-signer": "0.1.6",
208
209
  "@polkadot-api/substrate-bindings": "0.13.0",
209
- "@polkadot-api/sm-provider": "0.1.7",
210
- "@polkadot-api/utils": "0.1.2",
211
210
  "@polkadot-api/substrate-client": "0.3.0",
211
+ "@polkadot-api/utils": "0.1.2",
212
212
  "@polkadot-api/ws-provider": "0.4.0"
213
213
  },
214
214
  "devDependencies": {