polkadot-api 1.15.2 → 1.15.4

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.15.2";
4
+ var version = "1.15.4";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1,3 +1,3 @@
1
- (function(ae,Yt){typeof exports=="object"&&typeof module<"u"?Yt(exports):typeof define=="function"&&define.amd?define(["exports"],Yt):(ae=typeof globalThis<"u"?globalThis:ae||self,Yt(ae.papi={}))})(this,function(ae){"use strict";var Yt=Object.defineProperty,Cc=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ps=(e,t,n)=>(Cc(e,typeof t!="symbol"?t+"":t,n),n),cr={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 _c(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|cr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=cr[e[i]],u=cr[e[i+1]];s[t+o++]=c<<4|u}return s}var vs=class extends Uint8Array{constructor(e){super(e),ps(this,"i",0),ps(this,"v"),this.v=new DataView(e)}},Ce=e=>t=>e(t instanceof vs?t:new vs(t instanceof Uint8Array?t.buffer:typeof t=="string"?_c(t).buffer:t)),We=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 bn(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 wt=Ce,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gn=(e,t)=>n=>e(t(n)),wn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>j(gn(e,n),wn(t,r));function Oc(e,t){return Ce(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Tc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function it(e,t,n){return j(Tc(e,n),Oc(e,t))}var V=it(1,"getUint8","setUint8"),et=it(2,"getUint16","setUint16"),De=it(4,"getUint32","setUint32"),Gt=it(8,"getBigUint64","setBigUint64"),Rc=it(1,"getInt8","setInt8"),Pc=it(2,"getInt16","setInt16"),Uc=it(4,"getInt32","setInt32"),Mc=it(8,"getBigInt64","setBigInt64"),ms=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ys=e=>Ce(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}),bs=j(ms,ys("getBigUint64")),Dc=j(ms,ys("getBigInt64")),gs=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},ws=e=>Ce(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}),Lc=j(gs,ws("getBigUint64")),Vc=j(gs,ws("getBigInt64")),Fc=Ke(V,e=>e?1:0,Boolean),zc=[V[1],et[1],De[1]],Hc=Ce(e=>{const t=e[e.i],n=t&3;if(n<3)return zc[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=Gt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(De[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(V[1](e))<<i|s),s}),jc=1n<<56n,qc=1<<24,Wc=256,Kc=4294967295n,Xc=64,Yc=16384,Gc=1<<30,Qc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Xc)return V[0](t);if(e<Yc)return et[0](t|1);if(e<Gc)return De[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=jc;)n.push(Gt[0](r)),r>>=64n;r>=qc&&(n.push(De[0](Number(r&Kc))),r>>=32n);let s=Number(r);s>=Wc&&(n.push(et[0](s)),s>>=16),s&&n.push(V[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},pe=j(Qc,Hc),Nc=new TextEncoder,Zc=e=>{const t=Nc.encode(e);return We([pe.enc(t.length),t])},Jc=new TextDecoder,ea=Ce(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Jc.decode(n)}),z=j(Zc,ea),ta=()=>{},na=new Uint8Array(0),_=j(()=>na,ta),xs=e=>e===void 0?t=>We([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Es=e=>Ce(t=>{const n=e===void 0?pe.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}),X=e=>j(xs(e),Es(e));X.enc=xs,X.dec=Es;var ks=(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})=>We([V.enc(s(o)),e[o](i)])},As=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ce(s=>{const o=V.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},ge=(e,...t)=>j(ks(bn(e,([n])=>n),...t),As(bn(e,([,n])=>n),...t));ge.enc=ks,ge.dec=As;var Ss=e=>Ce(t=>V[1](t)>0?e(t):void 0),$s=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},we=e=>j($s(e[0]),Ss(e[1]));we.enc=$s,we.dec=Ss;var Is=(e,t)=>Ce(n=>{const r=V[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Bs=(e,t)=>({success:n,value:r})=>We([V[0](n?0:1),(n?e:t)(r)]),Qt=(e,t)=>j(Bs(e[0],t[0]),Is(e[1],t[1]));Qt.dec=Is,Qt.enc=Bs;var Cs=(...e)=>Ce(t=>e.map(n=>n(t))),_s=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),_e=(...e)=>j(_s(...e.map(([t])=>t)),Cs(...e.map(([,t])=>t)));_e.enc=_s,_e.dec=Cs;var Os=e=>{const t=Object.keys(e);return gn(_e.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ts=e=>{const t=Object.keys(e);return wn(_e.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},O=e=>j(Os(bn(e,t=>t[0])),Ts(bn(e,t=>t[1])));O.enc=Os,O.dec=Ts;var Rs=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([pe.enc(n.length),We(n.map(e))]),Ps=(e,t)=>Ce(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),D=(e,t)=>j(Rs(e[0],t),Ps(e[1],t));D.enc=Rs,D.dec=Ps;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ra(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Us(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 ar(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ms(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ur(e){if(!Array.isArray(e))throw new Error("array expected")}function Ds(e,t){if(!Us(!0,t))throw new Error(`${e}: array of strings expected`)}function sa(e,t){if(!Us(!1,t))throw new Error(`${e}: array of numbers expected`)}function oa(...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 ia(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ds("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ur(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=>(ur(s),s.map(o=>{ar("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ca(e=""){return ar("join",e),{encode:t=>(Ds("join.decode",t),t.join(e)),decode:t=>(ar("join.decode",t),t.split(e))}}function Ls(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(ur(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Ms(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 h=o[a],d=t*c,l=d+h;if(!Number.isSafeInteger(l)||d/t!==c||l-h!==d)throw new Error("convertRadix: carry overflow");const f=l/n;c=l%n;const p=Math.floor(f);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==l)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function aa(e){Ms(e);const t=2**8;return{encode:n=>{if(!ra(n))throw new Error("radix.encode input should be Uint8Array");return Ls(Array.from(n),t,e)},decode:n=>(sa("radix.decode",n),Uint8Array.from(Ls(n,e,t)))}}const Vs=(e=>oa(aa(58),ia(e),ca("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ua(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Pt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xt(e,...t){if(!ua(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 Nt(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 lr(e,t){xt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function la(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ct(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e,t){return e<<32-t|e>>>t}const Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=Fs?e=>e:e=>zs(e);function fa(e){for(let t=0;t<e.length;t++)e[t]=zs(e[t]);return e}const ve=Fs?e=>e:fa;function ha(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Xe(e){return typeof e=="string"&&(e=ha(e)),xt(e),e}class Hs{}function da(e){const t=r=>e().update(Xe(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function pa(e){const t=(r,s)=>e(s).update(Xe(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function va(e){const t=(r,s)=>e(s).update(Xe(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const ma=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 at(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,16),n=n+r|0,t=xn(t^n,12),{a:e,b:t,c:n,d:r}}function ut(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,8),n=n+r|0,t=xn(t^n,7),{a:e,b:t,c:n,d:r}}const ya=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),En=BigInt(2**32-1),js=BigInt(32);function kn(e,t=!1){return t?{h:Number(e&En),l:Number(e>>js&En)}:{h:Number(e>>js&En)|0,l:Number(e&En)|0}}function ba(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}=kn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const qs=(e,t,n)=>e>>>n|t<<32-n,Ws=(e,t,n)=>e<<32-n|t>>>n,ga=(e,t,n)=>e<<64-n|t>>>n-32,wa=(e,t,n)=>e>>>n-32|t<<64-n,xa=(e,t)=>t,Ea=(e,t)=>e,ka=(e,t,n)=>e<<n|t>>>32-n,Aa=(e,t,n)=>t<<n|e>>>32-n,Sa=(e,t,n)=>t<<n-32|e>>>64-n,$a=(e,t,n)=>e<<n-32|t>>>64-n;function Ks(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Xs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ys=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Z=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),A=new Uint32Array(32);function lt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],h=A[2*t],d=A[2*t+1],l=A[2*n],f=A[2*n+1],p=A[2*r],m=A[2*r+1],v=Xs(u,h,i);a=Ys(v,a,d,c),u=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^u},{Dh:m,Dl:p}={Dh:xa(m,p),Dl:Ea(m)},{h:f,l}=Ks(f,l,m,p),{Bh:d,Bl:h}={Bh:d^f,Bl:h^l},{Bh:d,Bl:h}={Bh:qs(d,h,24),Bl:Ws(d,h,24)},A[2*e]=u,A[2*e+1]=a,A[2*t]=h,A[2*t+1]=d,A[2*n]=l,A[2*n+1]=f,A[2*r]=p,A[2*r+1]=m}function ft(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],h=A[2*t],d=A[2*t+1],l=A[2*n],f=A[2*n+1],p=A[2*r],m=A[2*r+1],v=Xs(u,h,i);a=Ys(v,a,d,c),u=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^u},{Dh:m,Dl:p}={Dh:qs(m,p,16),Dl:Ws(m,p,16)},{h:f,l}=Ks(f,l,m,p),{Bh:d,Bl:h}={Bh:d^f,Bl:h^l},{Bh:d,Bl:h}={Bh:ga(d,h,63),Bl:wa(d,h,63)},A[2*e]=u,A[2*e+1]=a,A[2*t]=h,A[2*t+1]=d,A[2*n]=l,A[2*n+1]=f,A[2*r]=p,A[2*r+1]=m}function Ia(e,t={},n,r,s){if(Pt(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 Gs extends Hs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Pt(t),Pt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Et(this.buffer)}update(t){Nt(this),t=Xe(t),xt(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&&(ve(s),this.compress(s,0,!1),ve(s),this.pos=0);const a=Math.min(n-this.pos,o-u),h=i+u;if(a===n&&!(h%4)&&u+a<o){const d=new Uint32Array(c,h,Math.floor((o-u)/4));ve(d);for(let l=0;u+n<o;l+=s.length,u+=n)this.length+=n,this.compress(d,l,!1);ve(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Nt(this),lr(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ct(this.buffer.subarray(n)),ve(r),this.compress(r,0,!0),ve(r);const s=Et(t);this.get().forEach((o,i)=>s[i]=tt(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 Ba extends Gs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=Z[0]|0,this.v0h=Z[1]|0,this.v1l=Z[2]|0,this.v1h=Z[3]|0,this.v2l=Z[4]|0,this.v2h=Z[5]|0,this.v3l=Z[6]|0,this.v3h=Z[7]|0,this.v4l=Z[8]|0,this.v4h=Z[9]|0,this.v5l=Z[10]|0,this.v5h=Z[11]|0,this.v6l=Z[12]|0,this.v6h=Z[13]|0,this.v7l=Z[14]|0,this.v7h=Z[15]|0,Ia(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Xe(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Xe(o);const c=Et(o);this.v4l^=tt(c[0]),this.v4h^=tt(c[1]),this.v5l^=tt(c[2]),this.v5h^=tt(c[3])}if(s!==void 0){s=Xe(s);const c=Et(s);this.v6l^=tt(c[0]),this.v6h^=tt(c[1]),this.v7l^=tt(c[2]),this.v7h^=tt(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:h,v5l:d,v5h:l,v6l:f,v6h:p,v7l:m,v7h:v}=this;return[t,n,r,s,o,i,c,u,a,h,d,l,f,p,m,v]}set(t,n,r,s,o,i,c,u,a,h,d,l,f,p,m,v){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=h|0,this.v5l=d|0,this.v5h=l|0,this.v6l=f|0,this.v6h=p|0,this.v7l=m|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((u,a)=>A[a]=u),A.set(Z,16);let{h:s,l:o}=kn(BigInt(this.length));A[24]=Z[8]^o,A[25]=Z[9]^s,r&&(A[28]=~A[28],A[29]=~A[29]);let i=0;const c=ma;for(let u=0;u<12;u++)lt(0,4,8,12,t,n+2*c[i++]),ft(0,4,8,12,t,n+2*c[i++]),lt(1,5,9,13,t,n+2*c[i++]),ft(1,5,9,13,t,n+2*c[i++]),lt(2,6,10,14,t,n+2*c[i++]),ft(2,6,10,14,t,n+2*c[i++]),lt(3,7,11,15,t,n+2*c[i++]),ft(3,7,11,15,t,n+2*c[i++]),lt(0,5,10,15,t,n+2*c[i++]),ft(0,5,10,15,t,n+2*c[i++]),lt(1,6,11,12,t,n+2*c[i++]),ft(1,6,11,12,t,n+2*c[i++]),lt(2,7,8,13,t,n+2*c[i++]),ft(2,7,8,13,t,n+2*c[i++]),lt(3,4,9,14,t,n+2*c[i++]),ft(3,4,9,14,t,n+2*c[i++]);this.v0l^=A[0]^A[16],this.v0h^=A[1]^A[17],this.v1l^=A[2]^A[18],this.v1h^=A[3]^A[19],this.v2l^=A[4]^A[20],this.v2h^=A[5]^A[21],this.v3l^=A[6]^A[22],this.v3h^=A[7]^A[23],this.v4l^=A[8]^A[24],this.v4h^=A[9]^A[25],this.v5l^=A[10]^A[26],this.v5h^=A[11]^A[27],this.v6l^=A[12]^A[28],this.v6h^=A[13]^A[29],this.v7l^=A[14]^A[30],this.v7h^=A[15]^A[31],ct(A)}destroy(){this.destroyed=!0,ct(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ca=pa(e=>new Ba(e));function Qs(e,t,n,r,s,o,i,c,u,a,h,d,l,f,p,m,v,y,b,g){let w=0;for(let k=0;k<r;k++)({a:s,b:u,c:l,d:v}=at(s,u,l,v,n[t+e[w++]])),{a:s,b:u,c:l,d:v}=ut(s,u,l,v,n[t+e[w++]]),{a:o,b:a,c:f,d:y}=at(o,a,f,y,n[t+e[w++]]),{a:o,b:a,c:f,d:y}=ut(o,a,f,y,n[t+e[w++]]),{a:i,b:h,c:p,d:b}=at(i,h,p,b,n[t+e[w++]]),{a:i,b:h,c:p,d:b}=ut(i,h,p,b,n[t+e[w++]]),{a:c,b:d,c:m,d:g}=at(c,d,m,g,n[t+e[w++]]),{a:c,b:d,c:m,d:g}=ut(c,d,m,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=at(s,a,p,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=ut(s,a,p,g,n[t+e[w++]]),{a:o,b:h,c:m,d:v}=at(o,h,m,v,n[t+e[w++]]),{a:o,b:h,c:m,d:v}=ut(o,h,m,v,n[t+e[w++]]),{a:i,b:d,c:l,d:y}=at(i,d,l,y,n[t+e[w++]]),{a:i,b:d,c:l,d:y}=ut(i,d,l,y,n[t+e[w++]]),{a:c,b:u,c:f,d:b}=at(c,u,f,b,n[t+e[w++]]),{a:c,b:u,c:f,d:b}=ut(c,u,f,b,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:h,v7:d,v8:l,v9:f,v10:p,v11:m,v12:v,v13:y,v14:b,v15:g}}const An=Ca,Ns=new TextEncoder().encode("SS58PRE"),fr=2,hr=e=>{try{const t=Vs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-fr),s=t.subarray(n.length+r.length),o=An(Uint8Array.of(...Ns,...n,...r),{dkLen:64}).subarray(0,fr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:_a(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},_a=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Zs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=An(Uint8Array.of(...Ns,...t,...n),{dkLen:64}).subarray(0,fr);return Vs.encode(Uint8Array.of(...t,...n,...r))}};function Oa(e,t){return n=>{const r=hr(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 kt=(e=42,t=32)=>Ke(X(t),Oa(t),Zs(e)),Js="0123456789abcdef";function ee(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 dr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function me(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|dr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=dr[e[i]],u=dr[e[i+1]];s[t+o++]=c<<4|u}return s}function Ut(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const se=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},At=Function.prototype;class eo extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Ta=Object.defineProperty,to=e=>{throw TypeError(e)},Ra=(e,t,n)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zt=(e,t,n)=>Ra(e,typeof t!="symbol"?t+"":t,n),no=(e,t,n)=>t.has(e)||to("Cannot "+n),nt=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),Jt=(e,t,n)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),St=(e,t,n,r)=>(no(e,t,"write to private field"),t.set(e,n),n),rt,en,Sn,$n,In;const Pa=new TextEncoder,Ua=new TextDecoder,Ma=_e(pe,X(1/0))[1];class Le{constructor(t,n=!1){if(Jt(this,rt),Jt(this,en,null),Jt(this,Sn,null),Jt(this,$n,null),Jt(this,In,null),Zt(this,"asText",()=>nt(this,In)??St(this,In,Ua.decode(nt(this,rt)))),Zt(this,"asHex",()=>nt(this,Sn)||St(this,Sn,ee(nt(this,rt)))),Zt(this,"asOpaqueHex",()=>nt(this,$n)||St(this,$n,ee(this.asBytes()))),Zt(this,"asBytes",()=>nt(this,rt)),Zt(this,"asOpaqueBytes",()=>nt(this,en)||St(this,en,se([nt(this,rt),pe[0](nt(this,rt).length)]))),n){try{const[r,s]=Ma(t);if(r===s.length){St(this,rt,s),St(this,en,t);return}}catch{}throw new Error("Invalid opaque bytes")}else St(this,rt,t)}static fromText(t){return new this(Pa.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,en=new WeakMap,Sn=new WeakMap,$n=new WeakMap,In=new WeakMap;const[Da]=kt();class Bn extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Da(t))}}const ro=e=>{const t=X.enc(e);return n=>t(n.asBytes())},so=e=>{const t=X.dec(e),n=e==null?Le:Bn;return r=>n.fromBytes(t(r))},tn=e=>j(ro(e),so(e));tn.enc=ro,tn.dec=so;const B=Ke(pe,e=>e,Number),Cn=Ke(pe,e=>e,BigInt),La=wt(e=>{const t=B.dec(e),n=Math.ceil(t/8);return{bytes:X(n).dec(e),bitsLen:t}}),Va=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=B.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},La),Fa=Ke(V,e=>e.charCodeAt(0),String.fromCharCode),oo=e=>{const t=X.enc(e);return n=>t(me(n))},io=e=>{const t=X.dec(e);return n=>ee(t(n))},Ve=e=>j(oo(e),io(e));Ve.enc=oo,Ve.dec=io;const za=new TextEncoder,Ha=new TextDecoder,ja=e=>Ke(X(e),t=>za.encode(t),t=>Ha.decode(t)),co=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},ao=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},pr=e=>j(co(()=>e().enc),ao(()=>e().dec)),$t=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}}),uo=new Proxy({},{get(e,t){return n=>$t(t,n)}}),Y=(e,t)=>{const n=e;return n.inner=t,n},lo=(...e)=>{const t=ge.enc(...e);return Y(n=>t({tag:n.type,value:n.value}),e[0])},fo=(...e)=>{const t=ge.dec(...e);return Y(n=>{const{tag:r,value:s}=t(n);return $t(r,s)},e[0])},xe=(e,...t)=>Y(j(lo(Ut(e,([n])=>n),...t),fo(Ut(e,([,n])=>n),...t)),e);xe.enc=lo,xe.dec=fo;const vr=(e,...t)=>Y(ge(e,...t),e);vr.enc=(e,...t)=>Y(ge.enc(e,...t),e),vr.dec=(e,...t)=>Y(ge.dec(e,...t),e);const qa=BigInt(0),nn=BigInt(1),Wa=BigInt(2),Ka=BigInt(7),Xa=BigInt(256),Ya=BigInt(113),ho=[],po=[],vo=[];for(let e=0,t=nn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ho.push(2*(5*r+n)),po.push((e+1)*(e+2)/2%64);let s=qa;for(let o=0;o<7;o++)t=(t<<nn^(t>>Ka)*Ya)%Xa,t&Wa&&(s^=nn<<(nn<<BigInt(o))-nn);vo.push(s)}const mo=ba(vo,!0),Ga=mo[0],Qa=mo[1],yo=(e,t,n)=>n>32?Sa(e,t,n):ka(e,t,n),bo=(e,t,n)=>n>32?$a(e,t,n):Aa(e,t,n);function Na(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],h=n[u+1],d=yo(a,h,1)^n[c],l=bo(a,h,1)^n[c+1];for(let f=0;f<50;f+=10)e[i+f]^=d,e[i+f+1]^=l}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=po[i],u=yo(s,o,c),a=bo(s,o,c),h=ho[i];s=e[h],o=e[h+1],e[h]=u,e[h+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]^=Ga[r],e[1]^=Qa[r]}ct(n)}class mr extends Hs{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,Pt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Et(this.state)}clone(){return this._cloneInto()}keccak(){ve(this.state32),Na(this.state32,this.rounds),ve(this.state32),this.posOut=0,this.pos=0}update(t){Nt(this),t=Xe(t),xt(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){Nt(this,!1),xt(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 Pt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lr(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,ct(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new mr(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 Za=(e,t,n)=>da(()=>new mr(t,e,n)),Ja=Za(1,136,256/8),go=e=>{const t=e.slice(2),n=ee(Ja(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("")}`},eu=X(20)[1],wo=j(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=ee(t);if(e===n||e===n.toUpperCase())return t;if(go(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},wt(e=>go(ee(eu(e))))),oe=e=>Y(O(e),e);oe.enc=e=>Y(O.enc(e),e),oe.dec=e=>Y(O.dec(e),e);const Fe=(...e)=>Y(_e(...e),e);Fe.enc=(...e)=>Y(_e.enc(...e),e),Fe.dec=(...e)=>Y(_e.dec(...e),e);const Se=(e,...t)=>Y(D(e,...t),e);Se.enc=(e,...t)=>Y(D.enc(e,...t),e),Se.dec=(e,...t)=>Y(D.dec(e,...t),e);const _n=(e,t)=>Y(Qt(e,t),{ok:e,ko:t});_n.enc=(e,t)=>Y(Qt.enc(e,t),{ok:e,ko:t}),_n.dec=(e,t)=>Y(Qt.dec(e,t),{ok:e,ko:t});const ht=e=>Y(we(e),e);ht.enc=e=>Y(we.enc(e),e),ht.dec=e=>Y(we.dec(e),e);const xo=(e=!0)=>wt(t=>{const n=B.dec(t),r=Math.ceil(n/8),s=X(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let u=0;u<8&&i<n;u++){const a=e?u:7-u;o[i++]=c>>a&1}}),o}),Eo=(e=!0)=>t=>{const n=B.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let u=0;u<8&&i<t.length;u++,i++)c|=t[i]<<(e?u:7-u);s[o]=c}return se([n,s])},On=e=>j(Eo(e),xo(e));On.enc=Eo,On.dec=xo;const ko=new TextEncoder,Ao=new TextDecoder,tu=Ke(X(4),ko.encode.bind(ko),Ao.decode.bind(Ao)),yr=oe({engine:tu,payload:Ve()}),nu=xe({other:X(),consensus:yr,seal:yr,preRuntime:yr,runtimeUpdated:_},[0,4,5,6,8]),br=Ve(32),gr=oe({parentHash:br,number:B,stateRoot:br,extrinsicRoot:br,digests:Se(nu)}),$e=D(z),So=we(z),ru=ge({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),$o=D(O({name:So,type:B,typeName:So,docs:$e})),su=O({len:De,type:B}),ou=O({bitStoreType:B,bitOrderType:B}),iu=D(O({name:z,fields:$o,index:V,docs:$e})),cu=ge({composite:$o,variant:iu,sequence:B,array:su,tuple:D(B),primitive:ru,compact:B,bitSequence:ou}),au=O({name:z,type:we(B)}),uu=D(au),lu=O({id:B,path:$e,params:uu,def:cu,docs:$e}),Tn=D(lu),Mt=ge({NotDeprecated:_,DeprecatedWithoutNote:_,Deprecated:O({note:z,since:we(z)})}),fu=D(O({index:V,deprecation:ge({DeprecatedWithoutNote:_,Deprecated:O({note:z,since:we(z)})},[1,2])})),wr={name:z,inputs:D(O({name:z,type:B})),output:B,docs:$e},hu=O({name:z,methods:D(O(wr)),docs:$e}),du=O({name:z,methods:D(O({...wr,deprecationInfo:Mt})),docs:$e,version:B,deprecationInfo:Mt}),pu=O({id:Ve(32),...wr,deprecationInfo:Mt}),vu=ge({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),mu=D(vu),yu=O({hashers:mu,key:B,value:B}),Io={name:z,modifier:V,type:ge({plain:B,map:yu}),fallback:Ve(),docs:$e},xr=we(B),Bo={name:z,storage:we(O({prefix:z,items:D(O(Io))})),calls:xr,events:xr,constants:D(O({name:z,type:B,value:Ve(),docs:$e})),errors:xr,index:V},bu={...Bo,docs:$e},Er=we(O({type:B,deprecationInfo:fu})),gu={name:z,storage:we(O({prefix:z,items:D(O({...Io,deprecationInfo:Mt}))})),calls:Er,events:Er,constants:D(O({name:z,type:B,value:Ve(),docs:$e,deprecationInfo:Mt})),errors:Er,associatedTypes:D(O({name:z,type:B,docs:$e})),viewFns:D(pu),index:V,docs:$e,deprecationInfo:Mt},wu=new Uint8Array,Co=e=>j(()=>wu,()=>e),xu=O({type:B,version:V,signedExtensions:D(O({identifier:z,type:B,additionalSigned:B}))}),_o=O({lookup:Tn,pallets:D(O({...Bo,docs:Co([])})),extrinsic:xu,type:B,apis:Co([])}),Eu=O({version:V,address:B,call:B,signature:B,extra:B,signedExtensions:D(O({identifier:z,type:B,additionalSigned:B}))}),Oo=O({lookup:Tn,pallets:D(O(bu)),extrinsic:Eu,type:B,apis:D(hu),outerEnums:O({call:B,event:B,error:B}),custom:D(_e(z,O({type:B,value:Ve()})))}),ku=O({version:D(V),address:B,call:B,signature:B,signedExtensionsByVersion:D(_e(V,D(B))),signedExtensions:D(O({identifier:z,type:B,additionalSigned:B}))}),To=O({lookup:Tn,pallets:D(O(gu)),extrinsic:ku,apis:D(du),outerEnums:O({call:B,event:B,error:B}),custom:D(_e(z,O({type:B,value:Ve()})))}),Ro=()=>{throw new Error("Unsupported metadata version!")},Ee=j(Ro,Ro),dt=O({magicNumber:De,metadata:ge({v0:Ee,v1:Ee,v2:Ee,v3:Ee,v4:Ee,v5:Ee,v6:Ee,v7:Ee,v8:Ee,v9:Ee,v10:Ee,v11:Ee,v12:Ee,v13:Ee,v14:_o,v15:Oo,v16:To})}),kr=X(),Au=we(kr),Su=_e(pe,kr),Ar=e=>{try{return dt.dec(e)}catch{}try{return dt.dec(Au.dec(e))}catch{}try{return dt.dec(kr.dec(e))}catch{}try{return dt.dec(Su.dec(e)[1])}catch{}throw null},Dt=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(h=>({...h,calls:h.calls!=null?{type:h.calls}:void 0,events:h.events!=null?{type:h.events}:void 0,errors:h.errors!=null?{type:h.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:[]}},It={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Sr=Ke(V,({version:e,type:t})=>e+(It[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===It.bare||n===It.signed))return{version:t,type:It[n]};if(t===5&&(n===It.bare||n===It.general))return{version:t,type:It[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),$u={dkLen:32},rn=e=>An(e,$u),Iu={dkLen:16},$r=e=>An(e,Iu),Po=e=>se([$r(e),e]),Ye={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=ya.slice(),Uo=(()=>{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 Ir extends Gs{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=Xe(r).slice();xt(i,32),this.IV=Et(i),ve(this.IV),this.flags=n|Ye.KEYED_HASH}else if(o){const i=Xe(s),c=new Ir({dkLen:32},Ye.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=Et(c),ve(this.IV),this.flags=n|Ye.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=la(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=kn(BigInt(t),!0),{v0:a,v1:h,v2:d,v3:l,v4:f,v5:p,v6:m,v7:v,v8:y,v9:b,v10:g,v11:w,v12:k,v13:I,v14:T,v15:x}=Qs(Uo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],c,u,i,n);o[0]=a^y,o[1]=h^b,o[2]=d^g,o[3]=l^w,o[4]=f^k,o[5]=p^I,o[6]=m^T,o[7]=v^x}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ye.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ye.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|Ye.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(h=>Uint32Array.from(h)),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,ct(this.state,this.buffer32,this.IV,this.bufferOut32),ct(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=kn(BigInt(this.chunkOut++));ve(s);const{v0:u,v1:a,v2:h,v3:d,v4:l,v5:f,v6:p,v7:m,v8:v,v9:y,v10:b,v11:g,v12:w,v13:k,v14:I,v15:T}=Qs(Uo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],c,i,n,r);o[0]=u^v,o[1]=a^y,o[2]=h^b,o[3]=d^g,o[4]=l^w,o[5]=f^k,o[6]=p^I,o[7]=m^T,o[8]=t[0]^v,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^k,o[14]=t[6]^I,o[15]=t[7]^T,ve(s),ve(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ct(this.buffer.subarray(this.pos));let t=this.flags|Ye.ROOT;this.stack.length?(t|=Ye.PARENT,ve(this.buffer32),this.compress(this.buffer32,0,!0),ve(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ye.CHUNK_START)|Ye.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Nt(this,!1),xt(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 Pt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(lr(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 Bu=va(e=>new Ir(e)),Cu={dkLen:32},Mo=e=>Bu(e,Cu),_u=e=>se([Mo(e),e]),Do=e=>e,Bt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Br=2n**64n-1n,ue=(e,t)=>e<<t&Br|e>>64n-t,F=(e,t)=>e*t&Br,te=(e,t)=>e+t&Br,ne=11400714785074694791n,Ie=14029467366897019727n,Lo=1609587929392839161n,sn=9650029242287828579n,Vo=2870177450012600261n;function pt(e,t=0n){let n=te(te(t,ne),Ie),r=te(t,Ie),s=t,o=t-ne,i=e.length,c=0,u=null;(function(){let f=0,p=f+i;if(i){if(u=new Uint8Array(32),i<32){u.set(e.subarray(0,i),c),c+=i;return}if(f<=p-32){const m=p-32;do{let v;v=Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),n=F(ue(te(n,F(v,Ie)),31n),ne),f+=8,v=Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),r=F(ue(te(r,F(v,Ie)),31n),ne),f+=8,v=Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),s=F(ue(te(s,F(v,Ie)),31n),ne),f+=8,v=Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]),o=F(ue(te(o,F(v,Ie)),31n),ne),f+=8}while(f<=m)}f<p&&(u.set(e.subarray(f,p),c),c=p-f)}})(),e=u||e;let a,h=0;for(i>=32?(a=ue(n,1n),a=te(a,ue(r,7n)),a=te(a,ue(s,12n)),a=te(a,ue(o,18n)),n=F(ue(F(n,Ie),31n),ne),a=a^n,a=te(F(a,ne),sn),r=F(ue(F(r,Ie),31n),ne),a=a^r,a=te(F(a,ne),sn),s=F(ue(F(s,Ie),31n),ne),a=a^s,a=te(F(a,ne),sn),o=F(ue(F(o,Ie),31n),ne),a=a^o,a=te(F(a,ne),sn)):a=te(t,Vo),a=te(a,BigInt(i));h<=c-8;){let l=Bt(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]);l=F(ue(F(l,Ie),31n),ne),a=te(F(ue(a^l,27n),ne),sn),h+=8}if(h+4<=c){let l=F(Bt(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],0,0),ne);a=te(F(ue(a^l,23n),Ie),Lo),h+=4}for(;h<c;){const l=F(Bt(e[h++],0,0,0),Vo);a=F(ue(a^l,11n),ne)}let d=a>>33n;return a=F(a^d,Ie),d=a>>29n,a=F(a^d,Lo),d=a>>32n,a^=d,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,pt(e),!0),n.setBigUint64(8,pt(e,1n),!0),t},Fo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,pt(e),!0),n.setBigUint64(8,pt(e,1n),!0),n.setBigUint64(16,pt(e,2n),!0),n.setBigUint64(24,pt(e,3n),!0),t},zo=e=>se([Gt.enc(pt(e)),e]),Ho=new TextEncoder,Ou=new Map([[Do,0],[zo,8],[Po,16],[$r,-16],[rn,-32],[Rn,-16],[Fo,-32]]),jo=e=>{const t=Rn(Ho.encode(e));return(n,...r)=>{const s=se([t,Rn(Ho.encode(n))]),o=ee(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const h=me(a.slice(o.length)),d=new Array(r.length);for(let l=0,f=0;l<r.length;l++){const[p,m]=r[l],v=Ou.get(m);if(v==null)throw new Error("Unknown hasher");if(v<0){const y=v*-1;d[l]=ee(h.slice(f,f+y)),f+=y}else f+=v,d[l]=p.dec(h.slice(f)),f+=p.enc(d[l]).length}return d},c=r.map(([{enc:a},h])=>d=>h(a(d)));return{enc:(...a)=>ee(se([s,...a.map((h,d)=>c[d](h))])),dec:i}}},Tu=Le.fromText("modlpy/utilisuba").asBytes(),Ru=({threshold:e,signatories:t})=>{const n=qo(t),r=se([Tu,pe.enc(n.length),...n,et.enc(e)]);return rn(r)},qo=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 Wo=Object.freeze({__proto__:null,AccountId:kt,Bin:tn,Binary:Le,BitSeq:On,Blake2128:$r,Blake2128Concat:Po,Blake2256:rn,Blake3256:Mo,Blake3256Concat:_u,Bytes:X,Enum:$t,FixedSizeBinary:Bn,Hex:Ve,Identity:Do,Option:ht,Result:_n,ScaleEnum:vr,Self:pr,Storage:jo,Struct:oe,Tuple:Fe,Twox128:Rn,Twox256:Fo,Twox64Concat:zo,Variant:xe,Vector:Se,_Enum:uo,_void:_,bitSequence:Va,blockHeader:gr,bool:Fc,char:Fa,compact:pe,compactBn:Cn,compactNumber:B,createCodec:j,createDecoder:wt,decAnyMetadata:Ar,enhanceCodec:Ke,enhanceDecoder:wn,enhanceEncoder:gn,ethAccount:wo,extrinsicFormat:Sr,fixedStr:ja,fromBufferToBase58:Zs,getMultisigAccountId:Ru,getSs58AddressInfo:hr,h64:pt,i128:Dc,i16:Pc,i256:Vc,i32:Uc,i64:Mc,i8:Rc,metadata:dt,selfDecoder:ao,selfEncoder:co,sortMultisigSignatories:qo,str:z,u128:bs,u16:et,u256:Lc,u32:De,u64:Gt,u8:V,unifyMetadata:Dt,v14:_o,v14Lookup:Tn,v15:Oo,v16:To});const ot=B,Pu=Se(Fe(z,ot)),H={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Uu=xe(Object.fromEntries(Object.values(H).map(e=>[e,_]))),Mu=Se(Fe(z,xe({inline:pr(()=>Cr),lookup:ot}))),Du=Se(ot),Lu=oe({typeRef:ot,length:ht(ot)}),Vu=ht(ot),Fu=ot,zu=oe({ok:ot,ko:ot}),Cr=xe({struct:Pu,terminal:Uu,enum:Mu,tuple:Du,array:Lu,binary:Vu,option:Fu,result:zu}),Hu={i256:H.big,i128:H.big,i64:H.big,i32:H.num,i16:H.num,i8:H.num,u256:H.big,u128:H.big,u64:H.big,u32:H.num,u16:H.num,u8:H.num,bool:H.bool,char:H.str,str:H.str},on=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return on(H.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 on(H.bits);case"compact":return on(e.isBig?H.big:H.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 on(Hu[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 on(H.void)}}function _r(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>_r(o,i,n),s=o=>{switch(o.value.type){case H.str:case H.big:case H.bool:case H.num:return typeof e===o.value.type;case H.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case H.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof Le&&(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,h])=>r(e[a],n(h))):!1;case"tuple":return e?t.value.every((a,h)=>r(e[h],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 ju=Object.defineProperty,qu=(e,t,n)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wu=(e,t,n)=>qu(e,t+"",n);class Ko{constructor(t=[]){Wu(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Oe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Oe||{});function Or(e,t,n,r,s,o=!1){if(!n&&!e)return ze(3,[]);if(!n)return ze(2,[]);if(!e)return ze(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new Ko([[e,n]])}:ze(u.level,u.changes)}i.set(e,null);const c=Ku(e,n,(u,a)=>Or(typeof u=="number"?t(u):u,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function Ku(e,t,n,r){const s=(o,i,c)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Un(s(e,t.value,"some"),2):e.type==="option"?Un(s(e.value,t,"some"),1):ze(0,[]);switch(t.type){case"terminal":return ze(t.value.type===e.value.type?3:0,[]);case"binary":return Rr(Go(e.value,t.value));case"array":const i=e,c=Rr(Go(i.value.length,t.value.length));return Tr([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const l=e,f=Object.fromEntries(t.value.map(([v,y])=>[v,y.value]));let p=Yo(l.value.map(([v,y])=>()=>v in f?s(y.value,f[v],v):ze(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:v}])));if(l.value.length===t.value.length)return p;p=Un(p,2);const m=new Set(l.value.map(([v])=>v));return p.changes=[...p.changes,...t.value.filter(([v])=>!m.has(v)).map(([v,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:v}))],p}case"option":return Xu(s(e.value,t.value,"some"),1);case"struct":const u=e,a=Object.fromEntries(u.value),h=u.value.length===t.value.length?3:2;return Un(Tr(t.value.map(([l,f])=>()=>s(a[l],f,l)),r),h);case"tuple":{const l=e,f=Rr(Yu(l.value,t.value));return Tr([f,...t.value.map((p,m)=>()=>s(l.value[m],p,String(m)))],r)}case"result":const d=e;return Yo([s(d.value.ok,t.value.ok,"ok"),s(d.value.ko,t.value.ko,"ko")])}}const Un=(e,t)=>({...e,level:Math.min(e.level,t)}),Xu=(e,t)=>({...e,level:Math.max(e.level,t)}),Xo=new Ko,ze=(e,t)=>({level:e,changes:t,assumptions:Xo}),Tr=(e,t)=>{let n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Yo=e=>{if(!e.length)return ze(3,[]);let t=!1,n=ze(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),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:ze(0,n.changes)},Rr=e=>({assumptions:Xo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Yu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Go=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Qo=xe({lookup:B,typedef:Cr}),Lt=e=>({type:"lookup",value:e}),Pr=e=>({type:"typedef",value:e}),Mn=Pr({type:"terminal",value:{type:H.void}}),Gu=oe({args:Qo,values:Qo});function Qu(e){if(e.type.tag==="plain")return{args:Mn,values:Lt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Lt(t),values:Lt(n)}}function No(e){return{args:Pr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Lt(e.output)}}function Nu(e){return e.type==="lookupEntry"?Lt(e.value.id):Pr(Pn(e))}function Zu(e){return{args:Mn,values:Lt(e)}}function Ju(e,t,n,r,s,o){const i=(c,u)=>c.type==="lookup"?u(c.value):c.value;return{args:Or(i(e.args,t),t,i(n.args,r),r,s,o),values:Or(i(n.values,r),r,i(e.values,t),t,s,o)}}function Zo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return _r(n,r,t)}var Ur=function(e,t){return Ur=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])},Ur(e,t)};function Ge(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ur(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function el(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(h){try{a(r.next(h))}catch(d){i(d)}}function u(h){try{a(r.throw(h))}catch(d){i(d)}}function a(h){h.done?o(h.value):s(h.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Jo(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(h){return u([a,h])}}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(h){a=[6,h],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Vt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(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 Re(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 Ft(e){return this instanceof Ft?(this.v=e,this):new Ft(e)}function tl(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(f){return function(p){return Promise.resolve(p).then(f,d)}}function c(f,p){r[f]&&(s[f]=function(m){return new Promise(function(v,y){o.push([f,m,v,y])>1||u(f,m)})},p&&(s[f]=p(s[f])))}function u(f,p){try{a(r[f](p))}catch(m){l(o[0][3],m)}}function a(f){f.value instanceof Ft?Promise.resolve(f.value.v).then(h,d):l(o[0][2],f)}function h(f){u("next",f)}function d(f){u("throw",f)}function l(f,p){f(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function nl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Vt=="function"?Vt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(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 W(e){return typeof e=="function"}function Mr(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 Dr=Mr(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
1
+ (function(ae,Yt){typeof exports=="object"&&typeof module<"u"?Yt(exports):typeof define=="function"&&define.amd?define(["exports"],Yt):(ae=typeof globalThis<"u"?globalThis:ae||self,Yt(ae.papi={}))})(this,function(ae){"use strict";var Yt=Object.defineProperty,Cc=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ps=(e,t,n)=>(Cc(e,typeof t!="symbol"?t+"":t,n),n),ir={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 _c(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|ir[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=ir[e[i]],u=ir[e[i+1]];s[t+o++]=c<<4|u}return s}var vs=class extends Uint8Array{constructor(e){super(e),ps(this,"i",0),ps(this,"v"),this.v=new DataView(e)}},Ce=e=>t=>e(t instanceof vs?t:new vs(t instanceof Uint8Array?t.buffer:typeof t=="string"?_c(t).buffer:t)),We=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 bn(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 wt=Ce,j=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},gn=(e,t)=>n=>e(t(n)),wn=(e,t)=>n=>t(e(n)),Ke=([e,t],n,r)=>j(gn(e,n),wn(t,r));function Oc(e,t){return Ce(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Tc(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function it(e,t,n){return j(Tc(e,n),Oc(e,t))}var V=it(1,"getUint8","setUint8"),et=it(2,"getUint16","setUint16"),De=it(4,"getUint32","setUint32"),Gt=it(8,"getBigUint64","setBigUint64"),Rc=it(1,"getInt8","setInt8"),Pc=it(2,"getInt16","setInt16"),Uc=it(4,"getInt32","setInt32"),Mc=it(8,"getBigInt64","setBigInt64"),ms=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ys=e=>Ce(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}),bs=j(ms,ys("getBigUint64")),Dc=j(ms,ys("getBigInt64")),gs=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},ws=e=>Ce(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}),Lc=j(gs,ws("getBigUint64")),Vc=j(gs,ws("getBigInt64")),Fc=Ke(V,e=>e?1:0,Boolean),Hc=[V[1],et[1],De[1]],zc=Ce(e=>{const t=e[e.i],n=t&3;if(n<3)return Hc[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=Gt[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(De[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(et[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(V[1](e))<<i|s),s}),jc=1n<<56n,qc=1<<24,Wc=256,Kc=4294967295n,Xc=64,Yc=16384,Gc=1<<30,Qc=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<Xc)return V[0](t);if(e<Yc)return et[0](t|1);if(e<Gc)return De[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=jc;)n.push(Gt[0](r)),r>>=64n;r>=qc&&(n.push(De[0](Number(r&Kc))),r>>=32n);let s=Number(r);s>=Wc&&(n.push(et[0](s)),s>>=16),s&&n.push(V[0](s));const o=We(n);return o[0]=o.length-5<<2|3,o},pe=j(Qc,zc),Nc=new TextEncoder,Zc=e=>{const t=Nc.encode(e);return We([pe.enc(t.length),t])},Jc=new TextDecoder,ea=Ce(e=>{let t=pe.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,Jc.decode(n)}),H=j(Zc,ea),ta=()=>{},na=new Uint8Array(0),_=j(()=>na,ta),xs=e=>e===void 0?t=>We([pe.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Es=e=>Ce(t=>{const n=e===void 0?pe.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}),X=e=>j(xs(e),Es(e));X.enc=xs,X.dec=Es;var ks=(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})=>We([V.enc(s(o)),e[o](i)])},As=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return Ce(s=>{const o=V.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},ge=(e,...t)=>j(ks(bn(e,([n])=>n),...t),As(bn(e,([,n])=>n),...t));ge.enc=ks,ge.dec=As;var Ss=e=>Ce(t=>V[1](t)>0?e(t):void 0),$s=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,We([n,e(t)]))},we=e=>j($s(e[0]),Ss(e[1]));we.enc=$s,we.dec=Ss;var Is=(e,t)=>Ce(n=>{const r=V[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Bs=(e,t)=>({success:n,value:r})=>We([V[0](n?0:1),(n?e:t)(r)]),Qt=(e,t)=>j(Bs(e[0],t[0]),Is(e[1],t[1]));Qt.dec=Is,Qt.enc=Bs;var Cs=(...e)=>Ce(t=>e.map(n=>n(t))),_s=(...e)=>t=>We(e.map((n,r)=>n(t[r]))),_e=(...e)=>j(_s(...e.map(([t])=>t)),Cs(...e.map(([,t])=>t)));_e.enc=_s,_e.dec=Cs;var Os=e=>{const t=Object.keys(e);return gn(_e.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ts=e=>{const t=Object.keys(e);return wn(_e.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},O=e=>j(Os(bn(e,t=>t[0])),Ts(bn(e,t=>t[1])));O.enc=Os,O.dec=Ts;var Rs=(e,t)=>t>=0?n=>We(n.map(e)):n=>We([pe.enc(n.length),We(n.map(e))]),Ps=(e,t)=>Ce(n=>{const r=t>=0?t:pe.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),D=(e,t)=>j(Rs(e[0],t),Ps(e[1],t));D.enc=Rs,D.dec=Ps;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ra(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Us(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 cr(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Ms(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ar(e){if(!Array.isArray(e))throw new Error("array expected")}function Ds(e,t){if(!Us(!0,t))throw new Error(`${e}: array of strings expected`)}function sa(e,t){if(!Us(!1,t))throw new Error(`${e}: array of numbers expected`)}function oa(...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 ia(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Ds("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ar(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=>(ar(s),s.map(o=>{cr("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function ca(e=""){return cr("join",e),{encode:t=>(Ds("join.decode",t),t.join(e)),decode:t=>(cr("join.decode",t),t.split(e))}}function Ls(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(ar(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Ms(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 f=o[a],d=t*c,l=d+f;if(!Number.isSafeInteger(l)||d/t!==c||l-f!==d)throw new Error("convertRadix: carry overflow");const h=l/n;c=l%n;const p=Math.floor(h);if(o[a]=p,!Number.isSafeInteger(p)||p*n+c!==l)throw new Error("convertRadix: carry overflow");if(u)p?u=!1:r=a;else continue}if(s.push(c),u)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function aa(e){Ms(e);const t=2**8;return{encode:n=>{if(!ra(n))throw new Error("radix.encode input should be Uint8Array");return Ls(Array.from(n),t,e)},decode:n=>(sa("radix.decode",n),Uint8Array.from(Ls(n,e,t)))}}const Vs=(e=>oa(aa(58),ia(e),ca("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ua(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Pt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xt(e,...t){if(!ua(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 Nt(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 ur(e,t){xt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function la(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ct(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e,t){return e<<32-t|e>>>t}const Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tt=Fs?e=>e:e=>Hs(e);function fa(e){for(let t=0;t<e.length;t++)e[t]=Hs(e[t]);return e}const ve=Fs?e=>e:fa;function ha(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Xe(e){return typeof e=="string"&&(e=ha(e)),xt(e),e}class zs{}function da(e){const t=r=>e().update(Xe(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function pa(e){const t=(r,s)=>e(s).update(Xe(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function va(e){const t=(r,s)=>e(s).update(Xe(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const ma=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 at(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,16),n=n+r|0,t=xn(t^n,12),{a:e,b:t,c:n,d:r}}function ut(e,t,n,r,s){return e=e+t+s|0,r=xn(r^e,8),n=n+r|0,t=xn(t^n,7),{a:e,b:t,c:n,d:r}}const ya=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),En=BigInt(2**32-1),js=BigInt(32);function kn(e,t=!1){return t?{h:Number(e&En),l:Number(e>>js&En)}:{h:Number(e>>js&En)|0,l:Number(e&En)|0}}function ba(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}=kn(e[o],t);[r[o],s[o]]=[i,c]}return[r,s]}const qs=(e,t,n)=>e>>>n|t<<32-n,Ws=(e,t,n)=>e<<32-n|t>>>n,ga=(e,t,n)=>e<<64-n|t>>>n-32,wa=(e,t,n)=>e>>>n-32|t<<64-n,xa=(e,t)=>t,Ea=(e,t)=>e,ka=(e,t,n)=>e<<n|t>>>32-n,Aa=(e,t,n)=>t<<n|e>>>32-n,Sa=(e,t,n)=>t<<n-32|e>>>64-n,$a=(e,t,n)=>e<<n-32|t>>>64-n;function Ks(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const Xs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ys=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Z=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),A=new Uint32Array(32);function lt(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],f=A[2*t],d=A[2*t+1],l=A[2*n],h=A[2*n+1],p=A[2*r],m=A[2*r+1],v=Xs(u,f,i);a=Ys(v,a,d,c),u=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^u},{Dh:m,Dl:p}={Dh:xa(m,p),Dl:Ea(m)},{h,l}=Ks(h,l,m,p),{Bh:d,Bl:f}={Bh:d^h,Bl:f^l},{Bh:d,Bl:f}={Bh:qs(d,f,24),Bl:Ws(d,f,24)},A[2*e]=u,A[2*e+1]=a,A[2*t]=f,A[2*t+1]=d,A[2*n]=l,A[2*n+1]=h,A[2*r]=p,A[2*r+1]=m}function ft(e,t,n,r,s,o){const i=s[o],c=s[o+1];let u=A[2*e],a=A[2*e+1],f=A[2*t],d=A[2*t+1],l=A[2*n],h=A[2*n+1],p=A[2*r],m=A[2*r+1],v=Xs(u,f,i);a=Ys(v,a,d,c),u=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^u},{Dh:m,Dl:p}={Dh:qs(m,p,16),Dl:Ws(m,p,16)},{h,l}=Ks(h,l,m,p),{Bh:d,Bl:f}={Bh:d^h,Bl:f^l},{Bh:d,Bl:f}={Bh:ga(d,f,63),Bl:wa(d,f,63)},A[2*e]=u,A[2*e+1]=a,A[2*t]=f,A[2*t+1]=d,A[2*n]=l,A[2*n+1]=h,A[2*r]=p,A[2*r+1]=m}function Ia(e,t={},n,r,s){if(Pt(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 Gs extends zs{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Pt(t),Pt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=Et(this.buffer)}update(t){Nt(this),t=Xe(t),xt(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&&(ve(s),this.compress(s,0,!1),ve(s),this.pos=0);const a=Math.min(n-this.pos,o-u),f=i+u;if(a===n&&!(f%4)&&u+a<o){const d=new Uint32Array(c,f,Math.floor((o-u)/4));ve(d);for(let l=0;u+n<o;l+=s.length,u+=n)this.length+=n,this.compress(d,l,!1);ve(d);continue}r.set(t.subarray(u,u+a),this.pos),this.pos+=a,this.length+=a,u+=a}return this}digestInto(t){Nt(this),ur(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,ct(this.buffer.subarray(n)),ve(r),this.compress(r,0,!0),ve(r);const s=Et(t);this.get().forEach((o,i)=>s[i]=tt(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 Ba extends Gs{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=Z[0]|0,this.v0h=Z[1]|0,this.v1l=Z[2]|0,this.v1h=Z[3]|0,this.v2l=Z[4]|0,this.v2h=Z[5]|0,this.v3l=Z[6]|0,this.v3h=Z[7]|0,this.v4l=Z[8]|0,this.v4h=Z[9]|0,this.v5l=Z[10]|0,this.v5h=Z[11]|0,this.v6l=Z[12]|0,this.v6h=Z[13]|0,this.v7l=Z[14]|0,this.v7h=Z[15]|0,Ia(n,t,64,16,16);let{key:r,personalization:s,salt:o}=t,i=0;if(r!==void 0&&(r=Xe(r),i=r.length),this.v0l^=this.outputLen|i<<8|65536|1<<24,o!==void 0){o=Xe(o);const c=Et(o);this.v4l^=tt(c[0]),this.v4h^=tt(c[1]),this.v5l^=tt(c[2]),this.v5h^=tt(c[3])}if(s!==void 0){s=Xe(s);const c=Et(s);this.v6l^=tt(c[0]),this.v6h^=tt(c[1]),this.v7l^=tt(c[2]),this.v7h^=tt(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:f,v5l:d,v5h:l,v6l:h,v6h:p,v7l:m,v7h:v}=this;return[t,n,r,s,o,i,c,u,a,f,d,l,h,p,m,v]}set(t,n,r,s,o,i,c,u,a,f,d,l,h,p,m,v){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=f|0,this.v5l=d|0,this.v5h=l|0,this.v6l=h|0,this.v6h=p|0,this.v7l=m|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((u,a)=>A[a]=u),A.set(Z,16);let{h:s,l:o}=kn(BigInt(this.length));A[24]=Z[8]^o,A[25]=Z[9]^s,r&&(A[28]=~A[28],A[29]=~A[29]);let i=0;const c=ma;for(let u=0;u<12;u++)lt(0,4,8,12,t,n+2*c[i++]),ft(0,4,8,12,t,n+2*c[i++]),lt(1,5,9,13,t,n+2*c[i++]),ft(1,5,9,13,t,n+2*c[i++]),lt(2,6,10,14,t,n+2*c[i++]),ft(2,6,10,14,t,n+2*c[i++]),lt(3,7,11,15,t,n+2*c[i++]),ft(3,7,11,15,t,n+2*c[i++]),lt(0,5,10,15,t,n+2*c[i++]),ft(0,5,10,15,t,n+2*c[i++]),lt(1,6,11,12,t,n+2*c[i++]),ft(1,6,11,12,t,n+2*c[i++]),lt(2,7,8,13,t,n+2*c[i++]),ft(2,7,8,13,t,n+2*c[i++]),lt(3,4,9,14,t,n+2*c[i++]),ft(3,4,9,14,t,n+2*c[i++]);this.v0l^=A[0]^A[16],this.v0h^=A[1]^A[17],this.v1l^=A[2]^A[18],this.v1h^=A[3]^A[19],this.v2l^=A[4]^A[20],this.v2h^=A[5]^A[21],this.v3l^=A[6]^A[22],this.v3h^=A[7]^A[23],this.v4l^=A[8]^A[24],this.v4h^=A[9]^A[25],this.v5l^=A[10]^A[26],this.v5h^=A[11]^A[27],this.v6l^=A[12]^A[28],this.v6h^=A[13]^A[29],this.v7l^=A[14]^A[30],this.v7h^=A[15]^A[31],ct(A)}destroy(){this.destroyed=!0,ct(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ca=pa(e=>new Ba(e));function Qs(e,t,n,r,s,o,i,c,u,a,f,d,l,h,p,m,v,y,b,g){let w=0;for(let k=0;k<r;k++)({a:s,b:u,c:l,d:v}=at(s,u,l,v,n[t+e[w++]])),{a:s,b:u,c:l,d:v}=ut(s,u,l,v,n[t+e[w++]]),{a:o,b:a,c:h,d:y}=at(o,a,h,y,n[t+e[w++]]),{a:o,b:a,c:h,d:y}=ut(o,a,h,y,n[t+e[w++]]),{a:i,b:f,c:p,d:b}=at(i,f,p,b,n[t+e[w++]]),{a:i,b:f,c:p,d:b}=ut(i,f,p,b,n[t+e[w++]]),{a:c,b:d,c:m,d:g}=at(c,d,m,g,n[t+e[w++]]),{a:c,b:d,c:m,d:g}=ut(c,d,m,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=at(s,a,p,g,n[t+e[w++]]),{a:s,b:a,c:p,d:g}=ut(s,a,p,g,n[t+e[w++]]),{a:o,b:f,c:m,d:v}=at(o,f,m,v,n[t+e[w++]]),{a:o,b:f,c:m,d:v}=ut(o,f,m,v,n[t+e[w++]]),{a:i,b:d,c:l,d:y}=at(i,d,l,y,n[t+e[w++]]),{a:i,b:d,c:l,d:y}=ut(i,d,l,y,n[t+e[w++]]),{a:c,b:u,c:h,d:b}=at(c,u,h,b,n[t+e[w++]]),{a:c,b:u,c:h,d:b}=ut(c,u,h,b,n[t+e[w++]]);return{v0:s,v1:o,v2:i,v3:c,v4:u,v5:a,v6:f,v7:d,v8:l,v9:h,v10:p,v11:m,v12:v,v13:y,v14:b,v15:g}}const An=Ca,Ns=new TextEncoder().encode("SS58PRE"),lr=2,fr=e=>{try{const t=Vs.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-lr),s=t.subarray(n.length+r.length),o=An(Uint8Array.of(...Ns,...n,...r),{dkLen:64}).subarray(0,lr);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:_a(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},_a=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Zs=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=An(Uint8Array.of(...Ns,...t,...n),{dkLen:64}).subarray(0,lr);return Vs.encode(Uint8Array.of(...t,...n,...r))}};function Oa(e,t){return n=>{const r=fr(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 kt=(e=42,t=32)=>Ke(X(t),Oa(t),Zs(e)),Js="0123456789abcdef";function ee(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 hr={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function me(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|hr[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=hr[e[i]],u=hr[e[i+1]];s[t+o++]=c<<4|u}return s}function Ut(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const se=(...e)=>{const t=Array.isArray(e[0])?e[0]:e,n=t.reduce((s,o)=>s+o.byteLength,0),r=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const i=t[s];r.set(i,o),o+=i.byteLength}return r},At=Function.prototype;class eo extends Error{constructor(){super("Abort Error"),this.name="AbortError"}}var Ta=Object.defineProperty,to=e=>{throw TypeError(e)},Ra=(e,t,n)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zt=(e,t,n)=>Ra(e,typeof t!="symbol"?t+"":t,n),no=(e,t,n)=>t.has(e)||to("Cannot "+n),nt=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),Jt=(e,t,n)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),St=(e,t,n,r)=>(no(e,t,"write to private field"),t.set(e,n),n),rt,en,Sn,$n,In;const Pa=new TextEncoder,Ua=new TextDecoder,Ma=_e(pe,X(1/0))[1];class Le{constructor(t,n=!1){if(Jt(this,rt),Jt(this,en,null),Jt(this,Sn,null),Jt(this,$n,null),Jt(this,In,null),Zt(this,"asText",()=>nt(this,In)??St(this,In,Ua.decode(nt(this,rt)))),Zt(this,"asHex",()=>nt(this,Sn)||St(this,Sn,ee(nt(this,rt)))),Zt(this,"asOpaqueHex",()=>nt(this,$n)||St(this,$n,ee(this.asBytes()))),Zt(this,"asBytes",()=>nt(this,rt)),Zt(this,"asOpaqueBytes",()=>nt(this,en)||St(this,en,se([nt(this,rt),pe[0](nt(this,rt).length)]))),n){try{const[r,s]=Ma(t);if(r===s.length){St(this,rt,s),St(this,en,t);return}}catch{}throw new Error("Invalid opaque bytes")}else St(this,rt,t)}static fromText(t){return new this(Pa.encode(t))}static fromHex(t){return new this(me(t))}static fromOpaqueHex(t){return new this(me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}rt=new WeakMap,en=new WeakMap,Sn=new WeakMap,$n=new WeakMap,In=new WeakMap;const[Da]=kt();class Bn extends Le{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Da(t))}}const ro=e=>{const t=X.enc(e);return n=>t(n.asBytes())},so=e=>{const t=X.dec(e),n=e==null?Le:Bn;return r=>n.fromBytes(t(r))},tn=e=>j(ro(e),so(e));tn.enc=ro,tn.dec=so;const B=Ke(pe,e=>e,Number),Cn=Ke(pe,e=>e,BigInt),La=wt(e=>{const t=B.dec(e),n=Math.ceil(t/8);return{bytes:X(n).dec(e),bitsLen:t}}),Va=j(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=B.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},La),Fa=Ke(V,e=>e.charCodeAt(0),String.fromCharCode),oo=e=>{const t=X.enc(e);return n=>t(me(n))},io=e=>{const t=X.dec(e);return n=>ee(t(n))},Ve=e=>j(oo(e),io(e));Ve.enc=oo,Ve.dec=io;const Ha=new TextEncoder,za=new TextDecoder,ja=e=>Ke(X(e),t=>Ha.encode(t),t=>za.decode(t)),co=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},ao=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},dr=e=>j(co(()=>e().enc),ao(()=>e().dec)),$t=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}}),uo=new Proxy({},{get(e,t){return n=>$t(t,n)}}),Y=(e,t)=>{const n=e;return n.inner=t,n},lo=(...e)=>{const t=ge.enc(...e);return Y(n=>t({tag:n.type,value:n.value}),e[0])},fo=(...e)=>{const t=ge.dec(...e);return Y(n=>{const{tag:r,value:s}=t(n);return $t(r,s)},e[0])},xe=(e,...t)=>Y(j(lo(Ut(e,([n])=>n),...t),fo(Ut(e,([,n])=>n),...t)),e);xe.enc=lo,xe.dec=fo;const pr=(e,...t)=>Y(ge(e,...t),e);pr.enc=(e,...t)=>Y(ge.enc(e,...t),e),pr.dec=(e,...t)=>Y(ge.dec(e,...t),e);const qa=BigInt(0),nn=BigInt(1),Wa=BigInt(2),Ka=BigInt(7),Xa=BigInt(256),Ya=BigInt(113),ho=[],po=[],vo=[];for(let e=0,t=nn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ho.push(2*(5*r+n)),po.push((e+1)*(e+2)/2%64);let s=qa;for(let o=0;o<7;o++)t=(t<<nn^(t>>Ka)*Ya)%Xa,t&Wa&&(s^=nn<<(nn<<BigInt(o))-nn);vo.push(s)}const mo=ba(vo,!0),Ga=mo[0],Qa=mo[1],yo=(e,t,n)=>n>32?Sa(e,t,n):ka(e,t,n),bo=(e,t,n)=>n>32?$a(e,t,n):Aa(e,t,n);function Na(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,u=(i+2)%10,a=n[u],f=n[u+1],d=yo(a,f,1)^n[c],l=bo(a,f,1)^n[c+1];for(let h=0;h<50;h+=10)e[i+h]^=d,e[i+h+1]^=l}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=po[i],u=yo(s,o,c),a=bo(s,o,c),f=ho[i];s=e[f],o=e[f+1],e[f]=u,e[f+1]=a}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ga[r],e[1]^=Qa[r]}ct(n)}class vr extends zs{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,Pt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Et(this.state)}clone(){return this._cloneInto()}keccak(){ve(this.state32),Na(this.state32,this.rounds),ve(this.state32),this.posOut=0,this.pos=0}update(t){Nt(this),t=Xe(t),xt(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){Nt(this,!1),xt(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 Pt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ur(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,ct(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new vr(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 Za=(e,t,n)=>da(()=>new vr(t,e,n)),Ja=Za(1,136,256/8),go=e=>{const t=e.slice(2),n=ee(Ja(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("")}`},eu=X(20)[1],wo=j(e=>{const t=me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=ee(t);if(e===n||e===n.toUpperCase())return t;if(go(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},wt(e=>go(ee(eu(e))))),oe=e=>Y(O(e),e);oe.enc=e=>Y(O.enc(e),e),oe.dec=e=>Y(O.dec(e),e);const Fe=(...e)=>Y(_e(...e),e);Fe.enc=(...e)=>Y(_e.enc(...e),e),Fe.dec=(...e)=>Y(_e.dec(...e),e);const Se=(e,...t)=>Y(D(e,...t),e);Se.enc=(e,...t)=>Y(D.enc(e,...t),e),Se.dec=(e,...t)=>Y(D.dec(e,...t),e);const _n=(e,t)=>Y(Qt(e,t),{ok:e,ko:t});_n.enc=(e,t)=>Y(Qt.enc(e,t),{ok:e,ko:t}),_n.dec=(e,t)=>Y(Qt.dec(e,t),{ok:e,ko:t});const ht=e=>Y(we(e),e);ht.enc=e=>Y(we.enc(e),e),ht.dec=e=>Y(we.dec(e),e);const xo=(e=!0)=>wt(t=>{const n=B.dec(t),r=Math.ceil(n/8),s=X(r).dec(t),o=new Array(n);let i=0;return s.forEach(c=>{for(let u=0;u<8&&i<n;u++){const a=e?u:7-u;o[i++]=c>>a&1}}),o}),Eo=(e=!0)=>t=>{const n=B.enc(t.length),r=Math.ceil(t.length/8),s=new Uint8Array(r);for(let o=0;o<r;o++){let i=o*8,c=0;for(let u=0;u<8&&i<t.length;u++,i++)c|=t[i]<<(e?u:7-u);s[o]=c}return se([n,s])},On=e=>j(Eo(e),xo(e));On.enc=Eo,On.dec=xo;const ko=new TextEncoder,Ao=new TextDecoder,tu=Ke(X(4),ko.encode.bind(ko),Ao.decode.bind(Ao)),mr=oe({engine:tu,payload:Ve()}),nu=xe({other:X(),consensus:mr,seal:mr,preRuntime:mr,runtimeUpdated:_},[0,4,5,6,8]),yr=Ve(32),br=oe({parentHash:yr,number:B,stateRoot:yr,extrinsicRoot:yr,digests:Se(nu)}),$e=D(H),So=we(H),ru=ge({bool:_,char:_,str:_,u8:_,u16:_,u32:_,u64:_,u128:_,u256:_,i8:_,i16:_,i32:_,i64:_,i128:_,i256:_}),$o=D(O({name:So,type:B,typeName:So,docs:$e})),su=O({len:De,type:B}),ou=O({bitStoreType:B,bitOrderType:B}),iu=D(O({name:H,fields:$o,index:V,docs:$e})),cu=ge({composite:$o,variant:iu,sequence:B,array:su,tuple:D(B),primitive:ru,compact:B,bitSequence:ou}),au=O({name:H,type:we(B)}),uu=D(au),lu=O({id:B,path:$e,params:uu,def:cu,docs:$e}),Tn=D(lu),Mt=ge({NotDeprecated:_,DeprecatedWithoutNote:_,Deprecated:O({note:H,since:we(H)})}),fu=D(O({index:V,deprecation:ge({DeprecatedWithoutNote:_,Deprecated:O({note:H,since:we(H)})},[1,2])})),gr={name:H,inputs:D(O({name:H,type:B})),output:B,docs:$e},hu=O({name:H,methods:D(O(gr)),docs:$e}),du=O({name:H,methods:D(O({...gr,deprecationInfo:Mt})),docs:$e,version:B,deprecationInfo:Mt}),pu=O({id:Ve(32),...gr,deprecationInfo:Mt}),vu=ge({Blake2128:_,Blake2256:_,Blake2128Concat:_,Twox128:_,Twox256:_,Twox64Concat:_,Identity:_}),mu=D(vu),yu=O({hashers:mu,key:B,value:B}),Io={name:H,modifier:V,type:ge({plain:B,map:yu}),fallback:Ve(),docs:$e},wr=we(B),Bo={name:H,storage:we(O({prefix:H,items:D(O(Io))})),calls:wr,events:wr,constants:D(O({name:H,type:B,value:Ve(),docs:$e})),errors:wr,index:V},bu={...Bo,docs:$e},xr=we(O({type:B,deprecationInfo:fu})),gu={name:H,storage:we(O({prefix:H,items:D(O({...Io,deprecationInfo:Mt}))})),calls:xr,events:xr,constants:D(O({name:H,type:B,value:Ve(),docs:$e,deprecationInfo:Mt})),errors:xr,associatedTypes:D(O({name:H,type:B,docs:$e})),viewFns:D(pu),index:V,docs:$e,deprecationInfo:Mt},wu=new Uint8Array,Co=e=>j(()=>wu,()=>e),xu=O({type:B,version:V,signedExtensions:D(O({identifier:H,type:B,additionalSigned:B}))}),_o=O({lookup:Tn,pallets:D(O({...Bo,docs:Co([])})),extrinsic:xu,type:B,apis:Co([])}),Eu=O({version:V,address:B,call:B,signature:B,extra:B,signedExtensions:D(O({identifier:H,type:B,additionalSigned:B}))}),Oo=O({lookup:Tn,pallets:D(O(bu)),extrinsic:Eu,type:B,apis:D(hu),outerEnums:O({call:B,event:B,error:B}),custom:D(_e(H,O({type:B,value:Ve()})))}),ku=O({version:D(V),address:B,call:B,signature:B,signedExtensionsByVersion:D(_e(V,D(B))),signedExtensions:D(O({identifier:H,type:B,additionalSigned:B}))}),To=O({lookup:Tn,pallets:D(O(gu)),extrinsic:ku,apis:D(du),outerEnums:O({call:B,event:B,error:B}),custom:D(_e(H,O({type:B,value:Ve()})))}),Ro=()=>{throw new Error("Unsupported metadata version!")},Ee=j(Ro,Ro),dt=O({magicNumber:De,metadata:ge({v0:Ee,v1:Ee,v2:Ee,v3:Ee,v4:Ee,v5:Ee,v6:Ee,v7:Ee,v8:Ee,v9:Ee,v10:Ee,v11:Ee,v12:Ee,v13:Ee,v14:_o,v15:Oo,v16:To})}),Er=X(),Au=we(Er),Su=_e(pe,Er),kr=e=>{try{return dt.dec(e)}catch{}try{return dt.dec(Au.dec(e))}catch{}try{return dt.dec(Er.dec(e))}catch{}try{return dt.dec(Su.dec(e)[1])}catch{}throw null},Dt=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(f=>({...f,calls:f.calls!=null?{type:f.calls}:void 0,events:f.events!=null?{type:f.events}:void 0,errors:f.errors!=null?{type:f.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:[]}},It={bare:0,0:"bare",general:1,1:"general",signed:2,2:"signed"},Ar=Ke(V,({version:e,type:t})=>e+(It[t]<<6),e=>{const t=e&63,n=e>>6;if(t===4&&(n===It.bare||n===It.signed))return{version:t,type:It[n]};if(t===5&&(n===It.bare||n===It.general))return{version:t,type:It[n]};throw new Error(`ExtrinsicFormat ${e} not valid`)}),$u={dkLen:32},rn=e=>An(e,$u),Iu={dkLen:16},Sr=e=>An(e,Iu),Po=e=>se([Sr(e),e]),Ye={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},st=ya.slice(),Uo=(()=>{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 $r extends Gs{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=Xe(r).slice();xt(i,32),this.IV=Et(i),ve(this.IV),this.flags=n|Ye.KEYED_HASH}else if(o){const i=Xe(s),c=new $r({dkLen:32},Ye.DERIVE_KEY_CONTEXT).update(i).digest();this.IV=Et(c),ve(this.IV),this.flags=n|Ye.DERIVE_KEY_MATERIAL}else this.IV=st.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=la(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:i}=this,{h:c,l:u}=kn(BigInt(t),!0),{v0:a,v1:f,v2:d,v3:l,v4:h,v5:p,v6:m,v7:v,v8:y,v9:b,v10:g,v11:w,v12:k,v13:I,v14:T,v15:x}=Qs(Uo,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],st[0],st[1],st[2],st[3],c,u,i,n);o[0]=a^y,o[1]=f^b,o[2]=d^g,o[3]=l^w,o[4]=h^k,o[5]=p^I,o[6]=m^T,o[7]=v^x}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=Ye.CHUNK_START),(this.chunkPos===15||r)&&(s|=Ye.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|Ye.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(f=>Uint32Array.from(f)),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,ct(this.state,this.buffer32,this.IV,this.bufferOut32),ct(...this.stack)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:i,l:c}=kn(BigInt(this.chunkOut++));ve(s);const{v0:u,v1:a,v2:f,v3:d,v4:l,v5:h,v6:p,v7:m,v8:v,v9:y,v10:b,v11:g,v12:w,v13:k,v14:I,v15:T}=Qs(Uo,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],st[0],st[1],st[2],st[3],c,i,n,r);o[0]=u^v,o[1]=a^y,o[2]=f^b,o[3]=d^g,o[4]=l^w,o[5]=h^k,o[6]=p^I,o[7]=m^T,o[8]=t[0]^v,o[9]=t[1]^y,o[10]=t[2]^b,o[11]=t[3]^g,o[12]=t[4]^w,o[13]=t[5]^k,o[14]=t[6]^I,o[15]=t[7]^T,ve(s),ve(o),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,ct(this.buffer.subarray(this.pos));let t=this.flags|Ye.ROOT;this.stack.length?(t|=Ye.PARENT,ve(this.buffer32),this.compress(this.buffer32,0,!0),ve(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:Ye.CHUNK_START)|Ye.CHUNK_END,this.flags=t,this.b2CompressOut()}writeInto(t){Nt(this,!1),xt(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 Pt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ur(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 Bu=va(e=>new $r(e)),Cu={dkLen:32},Mo=e=>Bu(e,Cu),_u=e=>se([Mo(e),e]),Do=e=>e,Bt=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),Ir=2n**64n-1n,ue=(e,t)=>e<<t&Ir|e>>64n-t,F=(e,t)=>e*t&Ir,te=(e,t)=>e+t&Ir,ne=11400714785074694791n,Ie=14029467366897019727n,Lo=1609587929392839161n,sn=9650029242287828579n,Vo=2870177450012600261n;function pt(e,t=0n){let n=te(te(t,ne),Ie),r=te(t,Ie),s=t,o=t-ne,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 m=p-32;do{let v;v=Bt(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=F(ue(te(n,F(v,Ie)),31n),ne),h+=8,v=Bt(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=F(ue(te(r,F(v,Ie)),31n),ne),h+=8,v=Bt(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=F(ue(te(s,F(v,Ie)),31n),ne),h+=8,v=Bt(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=F(ue(te(o,F(v,Ie)),31n),ne),h+=8}while(h<=m)}h<p&&(u.set(e.subarray(h,p),c),c=p-h)}})(),e=u||e;let a,f=0;for(i>=32?(a=ue(n,1n),a=te(a,ue(r,7n)),a=te(a,ue(s,12n)),a=te(a,ue(o,18n)),n=F(ue(F(n,Ie),31n),ne),a=a^n,a=te(F(a,ne),sn),r=F(ue(F(r,Ie),31n),ne),a=a^r,a=te(F(a,ne),sn),s=F(ue(F(s,Ie),31n),ne),a=a^s,a=te(F(a,ne),sn),o=F(ue(F(o,Ie),31n),ne),a=a^o,a=te(F(a,ne),sn)):a=te(t,Vo),a=te(a,BigInt(i));f<=c-8;){let l=Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],e[f+5]<<8|e[f+4],e[f+7]<<8|e[f+6]);l=F(ue(F(l,Ie),31n),ne),a=te(F(ue(a^l,27n),ne),sn),f+=8}if(f+4<=c){let l=F(Bt(e[f+1]<<8|e[f],e[f+3]<<8|e[f+2],0,0),ne);a=te(F(ue(a^l,23n),Ie),Lo),f+=4}for(;f<c;){const l=F(Bt(e[f++],0,0,0),Vo);a=F(ue(a^l,11n),ne)}let d=a>>33n;return a=F(a^d,Ie),d=a>>29n,a=F(a^d,Lo),d=a>>32n,a^=d,a}const Rn=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,pt(e),!0),n.setBigUint64(8,pt(e,1n),!0),t},Fo=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,pt(e),!0),n.setBigUint64(8,pt(e,1n),!0),n.setBigUint64(16,pt(e,2n),!0),n.setBigUint64(24,pt(e,3n),!0),t},Ho=e=>se([Gt.enc(pt(e)),e]),zo=new TextEncoder,Ou=new Map([[Do,0],[Ho,8],[Po,16],[Sr,-16],[rn,-32],[Rn,-16],[Fo,-32]]),jo=e=>{const t=Rn(zo.encode(e));return(n,...r)=>{const s=se([t,Rn(zo.encode(n))]),o=ee(s),i=a=>{if(!a.startsWith(o))throw new Error(`key does not match this storage (${e}.${n})`);if(r.length===0)return[];const f=me(a.slice(o.length)),d=new Array(r.length);for(let l=0,h=0;l<r.length;l++){const[p,m]=r[l],v=Ou.get(m);if(v==null)throw new Error("Unknown hasher");if(v<0){const y=v*-1;d[l]=ee(f.slice(h,h+y)),h+=y}else h+=v,d[l]=p.dec(f.slice(h)),h+=p.enc(d[l]).length}return d},c=r.map(([{enc:a},f])=>d=>f(a(d)));return{enc:(...a)=>ee(se([s,...a.map((f,d)=>c[d](f))])),dec:i}}},Tu=Le.fromText("modlpy/utilisuba").asBytes(),Ru=({threshold:e,signatories:t})=>{const n=qo(t),r=se([Tu,pe.enc(n.length),...n,et.enc(e)]);return rn(r)},qo=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 Wo=Object.freeze({__proto__:null,AccountId:kt,Bin:tn,Binary:Le,BitSeq:On,Blake2128:Sr,Blake2128Concat:Po,Blake2256:rn,Blake3256:Mo,Blake3256Concat:_u,Bytes:X,Enum:$t,FixedSizeBinary:Bn,Hex:Ve,Identity:Do,Option:ht,Result:_n,ScaleEnum:pr,Self:dr,Storage:jo,Struct:oe,Tuple:Fe,Twox128:Rn,Twox256:Fo,Twox64Concat:Ho,Variant:xe,Vector:Se,_Enum:uo,_void:_,bitSequence:Va,blockHeader:br,bool:Fc,char:Fa,compact:pe,compactBn:Cn,compactNumber:B,createCodec:j,createDecoder:wt,decAnyMetadata:kr,enhanceCodec:Ke,enhanceDecoder:wn,enhanceEncoder:gn,ethAccount:wo,extrinsicFormat:Ar,fixedStr:ja,fromBufferToBase58:Zs,getMultisigAccountId:Ru,getSs58AddressInfo:fr,h64:pt,i128:Dc,i16:Pc,i256:Vc,i32:Uc,i64:Mc,i8:Rc,metadata:dt,selfDecoder:ao,selfEncoder:co,sortMultisigSignatories:qo,str:H,u128:bs,u16:et,u256:Lc,u32:De,u64:Gt,u8:V,unifyMetadata:Dt,v14:_o,v14Lookup:Tn,v15:Oo,v16:To});const ot=B,Pu=Se(Fe(H,ot)),z={bool:"boolean",str:"string",num:"number",big:"bigint",bits:"bitseq",void:"void"},Uu=xe(Object.fromEntries(Object.values(z).map(e=>[e,_]))),Mu=Se(Fe(H,xe({inline:dr(()=>Br),lookup:ot}))),Du=Se(ot),Lu=oe({typeRef:ot,length:ht(ot)}),Vu=ht(ot),Fu=ot,Hu=oe({ok:ot,ko:ot}),Br=xe({struct:Pu,terminal:Uu,enum:Mu,tuple:Du,array:Lu,binary:Vu,option:Fu,result:Hu}),zu={i256:z.big,i128:z.big,i64:z.big,i32:z.num,i16:z.num,i8:z.num,u256:z.big,u128:z.big,u64:z.big,u32:z.num,u16:z.num,u8:z.num,bool:z.bool,char:z.str,str:z.str},on=e=>({type:"terminal",value:{type:e}});function Pn(e,t=()=>{}){switch(e.type){case"AccountId20":case"AccountId32":return on(z.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 on(z.bits);case"compact":return on(e.isBig?z.big:z.num);case"enum":return{type:"enum",value:Object.entries(e.value).map(([n,r])=>r.type!=="lookupEntry"?[n,{type:"inline",value:Pn(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 on(zu[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 on(z.void)}}function Cr(e,t,n){if(t.type==="option"&&e==null)return!0;const r=(o,i)=>Cr(o,i,n),s=o=>{switch(o.value.type){case z.str:case z.big:case z.bool:case z.num:return typeof e===o.value.type;case z.bits:return typeof e=="object"&&e!=null&&typeof e.bitsLen=="number"&&e.bytes instanceof Uint8Array;case z.void:return!0}};switch(t.type){case"terminal":return s(t);case"binary":return e instanceof Le&&(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,f])=>r(e[a],n(f))):!1;case"tuple":return e?t.value.every((a,f)=>r(e[f],n(a))):!1;case"result":return"success"in e&&"value"in e?r(e.value,n(e.success?t.value.ok:t.value.ko)):!1}}var ju=Object.defineProperty,qu=(e,t,n)=>t in e?ju(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wu=(e,t,n)=>qu(e,t+"",n);class Ko{constructor(t=[]){Wu(this,"value",new Map),t.forEach(([n,r])=>this.add(n,r))}has(t,n){return this.value.get(t)?.has(n)??!1}add(t,n){this.value.has(t)||this.value.set(t,new Set),this.value.get(t).add(n)}addAll(t){t.forEach(([n,r])=>this.add(n,r))}delete(t,n){if(!this.value.has(t))return;const r=this.value.get(t);r.delete(n),r.size||this.value.delete(t)}isEmpty(){return!this.value.size}get values(){return Array.from(this.value).flatMap(([t,n])=>Array.from(n).map(r=>[t,r]))}}var Oe=(e=>(e[e.Incompatible=0]="Incompatible",e[e.Partial=1]="Partial",e[e.BackwardsCompatible=2]="BackwardsCompatible",e[e.Identical=3]="Identical",e))(Oe||{});function _r(e,t,n,r,s,o=!1){if(!n&&!e)return He(3,[]);if(!n)return He(2,[]);if(!e)return He(n.type==="option"?2:0,[]);s.has(n)||s.set(n,new Map);const i=s.get(n);if(i.has(e)){const u=i.get(e);return u==null?{level:3,changes:[],assumptions:new Ko([[e,n]])}:He(u.level,u.changes)}i.set(e,null);const c=Ku(e,n,(u,a)=>_r(typeof u=="number"?t(u):u,t,typeof a=="number"?r(a):a,r,s),o);return c.assumptions.delete(e,n),c.assumptions.isEmpty()||c.level===0?i.set(e,c):i.delete(e),c}function Ku(e,t,n,r){const s=(o,i,c)=>{const u=n(o,i);return{...u,changes:u.level<3?[{id:[typeof o=="number"?o:null,typeof i=="number"?i:null],level:u.level,path:c}]:[]}};if(e.type!==t.type)return t.type==="option"?Un(s(e,t.value,"some"),2):e.type==="option"?Un(s(e.value,t,"some"),1):He(0,[]);switch(t.type){case"terminal":return He(t.value.type===e.value.type?3:0,[]);case"binary":return Tr(Go(e.value,t.value));case"array":const i=e,c=Tr(Go(i.value.length,t.value.length));return Or([c,()=>s(i.value.typeRef,t.value.typeRef,"value")],r);case"enum":{const l=e,h=Object.fromEntries(t.value.map(([v,y])=>[v,y.value]));let p=Yo(l.value.map(([v,y])=>()=>v in h?s(y.value,h[v],v):He(0,[{id:[typeof y.value=="number"?y.value:null,null],level:0,path:v}])));if(l.value.length===t.value.length)return p;p=Un(p,2);const m=new Set(l.value.map(([v])=>v));return p.changes=[...p.changes,...t.value.filter(([v])=>!m.has(v)).map(([v,y])=>({id:[null,typeof y=="number"?y:null],level:0,path:v}))],p}case"option":return Xu(s(e.value,t.value,"some"),1);case"struct":const u=e,a=Object.fromEntries(u.value),f=u.value.length===t.value.length?3:2;return Un(Or(t.value.map(([l,h])=>()=>s(a[l],h,l)),r),f);case"tuple":{const l=e,h=Tr(Yu(l.value,t.value));return Or([h,...t.value.map((p,m)=>()=>s(l.value[m],p,String(m)))],r)}case"result":const d=e;return Yo([s(d.value.ok,t.value.ok,"ok"),s(d.value.ko,t.value.ko,"ko")])}}const Un=(e,t)=>({...e,level:Math.min(e.level,t)}),Xu=(e,t)=>({...e,level:Math.max(e.level,t)}),Xo=new Ko,He=(e,t)=>({level:e,changes:t,assumptions:Xo}),Or=(e,t)=>{let n=He(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(!t&&s.level===0)return s;s.level!==3&&(n.changes=[...n.changes,...s.changes]),n.assumptions.addAll(s.assumptions.values),n.level=Math.min(n.level,s.level)}return n},Yo=e=>{if(!e.length)return He(3,[]);let t=!1,n=He(3,[]);for(const r of e){const s=typeof r=="function"?r():r;if(s.level!==3&&(n.changes=[...n.changes,...s.changes]),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:He(0,n.changes)},Tr=e=>({assumptions:Xo,changes:e===3?[]:[{id:[null,null],level:e,path:"length"}],level:e}),Yu=(e,t)=>t.length===e.length?3:e.length>=t.length?2:0,Go=(e,t)=>t===e?3:t==null||e>=t?2:e==null?1:0,Qo=xe({lookup:B,typedef:Br}),Lt=e=>({type:"lookup",value:e}),Rr=e=>({type:"typedef",value:e}),Mn=Rr({type:"terminal",value:{type:z.void}}),Gu=oe({args:Qo,values:Qo});function Qu(e){if(e.type.tag==="plain")return{args:Mn,values:Lt(e.type.value)};const{key:t,value:n}=e.type.value;return{args:Lt(t),values:Lt(n)}}function No(e){return{args:Rr({type:"tuple",value:e.inputs.map(t=>t.type)}),values:Lt(e.output)}}function Nu(e){return e.type==="lookupEntry"?Lt(e.value.id):Rr(Pn(e))}function Zu(e){return{args:Mn,values:Lt(e)}}function Ju(e,t,n,r,s,o){const i=(c,u)=>c.type==="lookup"?u(c.value):c.value;return{args:_r(i(e.args,t),t,i(n.args,r),r,s,o),values:_r(i(n.values,r),r,i(e.values,t),t,s,o)}}function Zo(e,t,n){const r=e.type==="lookup"?t(e.value):e.value;return Cr(n,r,t)}var Pr=function(e,t){return Pr=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])},Pr(e,t)};function Ge(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function el(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(f){try{a(r.next(f))}catch(d){i(d)}}function u(f){try{a(r.throw(f))}catch(d){i(d)}}function a(f){f.done?o(f.value):s(f.value).then(c,u)}a((r=r.apply(e,t||[])).next())})}function Jo(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(f){return u([a,f])}}function u(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(n=0)),n;)try{if(r=1,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(f){a=[6,f],s=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function Vt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(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 Re(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 Ft(e){return this instanceof Ft?(this.v=e,this):new Ft(e)}function tl(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(m){return new Promise(function(v,y){o.push([h,m,v,y])>1||u(h,m)})},p&&(s[h]=p(s[h])))}function u(h,p){try{a(r[h](p))}catch(m){l(o[0][3],m)}}function a(h){h.value instanceof Ft?Promise.resolve(h.value.v).then(f,d):l(o[0][2],h)}function f(h){u("next",h)}function d(h){u("throw",h)}function l(h,p){h(p),o.shift(),o.length&&u(o[0][0],o[0][1])}}function nl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Vt=="function"?Vt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(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 W(e){return typeof e=="function"}function Ur(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 Mr=Ur(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 Dn(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=Vt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(m){t={error:m}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var h=this.initialTeardown;if(W(h))try{h()}catch(m){o=m instanceof Dr?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var l=Vt(d),f=l.next();!f.done;f=l.next()){var p=f.value;try{ni(p)}catch(m){o=o??[],m instanceof Dr?o=Re(Re([],Te(o)),Te(m.errors)):o.push(m)}}}catch(m){r={error:m}}finally{try{f&&!f.done&&(s=l.return)&&s.call(l)}finally{if(r)throw r.error}}}if(o)throw new Dr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ni(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&Dn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Dn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),ei=Ct.EMPTY;function ti(e){return e instanceof Ct||e&&"closed"in e&&W(e.remove)&&W(e.add)&&W(e.unsubscribe)}function ni(e){W(e)?e():e.unsubscribe()}var rl={Promise:void 0},sl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Re([e,t],Te(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ri(e){sl.setTimeout(function(){throw e})}function ke(){}function Ln(e){e()}var cn=function(e){Ge(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ti(n)&&n.add(r)):r.destination=cl,r}return t.create=function(n,r,s){return new zt(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),ol=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){Vn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Vn(r)}else Vn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Vn(n)}},e}(),zt=function(e){Ge(t,e);function t(n,r,s){var o=e.call(this)||this,i;return W(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new ol(i),o}return t}(cn);function Vn(e){ri(e)}function il(e){throw e}var cl={closed:!0,next:ke,error:il,complete:ke},Lr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Qe(e){return e}function si(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return oi(e)}function oi(e){return e.length===0?Qe:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=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=ul(t)?t:new zt(t,n,r);return Ln(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=ii(n),new n(function(s,o){var i=new zt({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[Lr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return oi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ii(t),new t(function(r,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 ii(e){var t;return(t=e??rl.Promise)!==null&&t!==void 0?t:Promise}function al(e){return e&&W(e.next)&&W(e.error)&&W(e.complete)}function ul(e){return e&&e instanceof cn||al(e)&&ti(e)}function ll(e){return W(e?.lift)}function G(e){return function(t){if(ll(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 K(e,t,n,r,s){return new fl(e,t,n,r,s)}var fl=function(e){Ge(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(h){n.error(h)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(h){n.error(h)}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}(cn),hl=Mr(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),He=function(e){Ge(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new ci(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new hl},t.prototype.next=function(n){var r=this;Ln(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Vt(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;Ln(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;Ln(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?ei:(this.currentObservers=null,c.push(n),new Ct(function(){r.currentObservers=null,Dn(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 U;return n.source=this,n},t.create=function(n,r){return new ci(n,r)},t}(U),ci=function(e){Ge(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:ei},t}(He),dl=function(e){Ge(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}(He),Vr={now:function(){return(Vr.delegate||Date).now()},delegate:void 0},Fn=function(e){Ge(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Vr);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,h=1;h<o.length&&o[h]<=u;h+=2)a=h;a&&o.splice(0,a+1)}},t}(He),pl=function(e){Ge(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(Ct),ai={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Re([e,t],Te(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},vl=function(e){Ge(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),ai.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&&ai.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,Dn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(pl),ui=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Vr.now,e}(),ml=function(e){Ge(t,e);function t(n,r){r===void 0&&(r=ui.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}(ui),li=new ml(vl),yl=li,vt=new U(function(e){return e.complete()});function fi(e){return e&&W(e.schedule)}function Fr(e){return e[e.length-1]}function zr(e){return W(Fr(e))?e.pop():void 0}function an(e){return fi(Fr(e))?e.pop():void 0}function bl(e,t){return typeof Fr(e)=="number"?e.pop():t}var hi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function di(e){return W(e?.then)}function pi(e){return W(e[Lr])}function vi(e){return Symbol.asyncIterator&&W(e?.[Symbol.asyncIterator])}function mi(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 gl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var yi=gl();function bi(e){return W(e?.[yi])}function gi(e){return tl(this,arguments,function(){var n,r,s,o;return Jo(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,Ft(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Ft(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ft(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 wi(e){return W(e?.getReader)}function le(e){if(e instanceof U)return e;if(e!=null){if(pi(e))return wl(e);if(hi(e))return xl(e);if(di(e))return El(e);if(vi(e))return xi(e);if(bi(e))return kl(e);if(wi(e))return Al(e)}throw mi(e)}function wl(e){return new U(function(t){var n=e[Lr]();if(W(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function xl(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function El(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ri)})}function kl(e){return new U(function(t){var n,r;try{for(var s=Vt(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 xi(e){return new U(function(t){Sl(e,t).catch(function(n){return t.error(n)})})}function Al(e){return xi(gi(e))}function Sl(e,t){var n,r,s,o;return el(this,void 0,void 0,function(){var i,c;return Jo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=nl(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 mt(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 Ei(e,t){return t===void 0&&(t=0),G(function(n,r){n.subscribe(K(r,function(s){return mt(r,e,function(){return r.next(s)},t)},function(){return mt(r,e,function(){return r.complete()},t)},function(s){return mt(r,e,function(){return r.error(s)},t)}))})}function ki(e,t){return t===void 0&&(t=0),G(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function $l(e,t){return le(e).pipe(ki(t),Ei(t))}function Il(e,t){return le(e).pipe(ki(t),Ei(t))}function Bl(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Cl(e,t){return new U(function(n){var r;return mt(n,t,function(){r=e[yi](),mt(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 W(r?.return)&&r.return()}})}function Ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){mt(n,t,function(){var r=e[Symbol.asyncIterator]();mt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function _l(e,t){return Ai(gi(e),t)}function Ol(e,t){if(e!=null){if(pi(e))return $l(e,t);if(hi(e))return Bl(e,t);if(di(e))return Il(e,t);if(vi(e))return Ai(e,t);if(bi(e))return Cl(e,t);if(wi(e))return _l(e,t)}throw mi(e)}function yt(e,t){return t?Ol(e,t):le(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return yt(e,n)}function zn(e,t){var n=W(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var Si=Mr(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Tl(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 Si)}})})}function je(e,t){return new Promise(function(n,r){var s=new zt({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Si)}});e.subscribe(s)})}function Rl(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return G(function(n,r){var s=0;n.subscribe(K(r,function(o){r.next(e.call(t,o,s++))}))})}var Pl=Array.isArray;function Ul(e,t){return Pl(t)?e.apply(void 0,Re([],Te(t))):e(t)}function $i(e){return S(function(t){return Ul(e,t)})}var Ml=Array.isArray,Dl=Object.getPrototypeOf,Ll=Object.prototype,Vl=Object.keys;function Fl(e){if(e.length===1){var t=e[0];if(Ml(t))return{args:t,keys:null};if(zl(t)){var n=Vl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function zl(e){return e&&typeof e=="object"&&Dl(e)===Ll}function Hl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function Ht(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=zr(e),s=Fl(e),o=s.args,i=s.keys;if(o.length===0)return yt([],n);var c=new U(Ii(o,n,i?function(u){return Hl(i,u)}:Qe));return r?c.pipe($i(r)):c}function Ii(e,t,n){return n===void 0&&(n=Qe),function(r){Bi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(h){Bi(t,function(){var d=yt(e[h],t),l=!1;d.subscribe(K(r,function(f){o[h]=f,l||(l=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function Bi(e,t,n){e?mt(n,e,t):t()}function jl(e,t,n,r,s,o,i,c){var u=[],a=0,h=0,d=!1,l=function(){d&&!u.length&&!a&&t.complete()},f=function(m){return a<r?p(m):u.push(m)},p=function(m){a++;var v=!1;le(n(m,h++)).subscribe(K(t,function(y){t.next(y)},function(){v=!0},void 0,function(){if(v)try{a--;for(var y=function(){var b=u.shift();i||p(b)};u.length&&a<r;)y();l()}catch(b){t.error(b)}}))};return e.subscribe(K(t,f,function(){d=!0,l()})),function(){}}function R(e,t,n){return n===void 0&&(n=1/0),W(t)?R(function(r,s){return S(function(o,i){return t(r,o,s,i)})(le(e(r,s)))},n):(typeof t=="number"&&(n=t),G(function(r,s){return jl(r,s,e,n)}))}function Hn(e){return e===void 0&&(e=1/0),R(Qe,e)}function ql(){return Hn(1)}function jn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ql()(yt(e,an(e)))}function qn(e){return new U(function(t){le(e()).subscribe(t)})}var Wl={connector:function(){return new He},resetOnDisconnect:!0};function Kl(e,t){t===void 0&&(t=Wl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new U(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=qn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Wn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=yl);var r=-1;return t!=null&&(fi(t)?n=t:r=t),new U(function(s){var o=Rl(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 un(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=bl(e,1/0),s=e;return s.length?s.length===1?le(s[0]):Hn(r)(yt(s,n)):vt}var Xl=Array.isArray;function Yl(e){return e.length===1&&Xl(e[0])?e[0]:e}function Pe(e,t){return G(function(n,r){var s=0;n.subscribe(K(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Ae(e){return G(function(t,n){var r=null,s=!1,o;r=t.subscribe(K(n,void 0,void 0,function(i){o=le(e(i,Ae(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Ci(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(K(i,function(h){var d=a++;u=c?e(u,h,d):(c=!0,h),r&&i.next(u)},s&&function(){c&&i.next(u),i.complete()}))}}function Gl(e,t){return G(Ci(e,t,arguments.length>=2,!1,!0))}function _i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zr(e);return n?si(_i.apply(void 0,Re([],Te(e))),$i(n)):G(function(r,s){Ii(Re([r],Te(Yl(e))))(s)})}function Ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _i.apply(void 0,Re([],Te(e)))}function Nl(e,t){return W(t)?R(e,t,1):R(e,1)}function Q(e){return e<=0?function(){return vt}:G(function(t,n){var r=0;t.subscribe(K(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Zl(e){return S(function(){return e})}function Jl(e,t){return R(function(n,r){return le(e(n,r)).pipe(Q(1),Zl(n))})}function ef(e,t){t===void 0&&(t=li);var n=Wn(e,t);return Jl(function(){return n})}function tf(e,t){return G(function(n,r){var s=new Set;n.subscribe(K(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&le(t).subscribe(K(r,function(){return s.clear()},ke))})}function ye(e,t){return t===void 0&&(t=Qe),e=e??nf,G(function(n,r){var s,o=!0;n.subscribe(K(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function nf(e,t){return e===t}function rf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return jn(n,re.apply(void 0,Re([],Te(e))))}}function sf(e,t){return G(function(n,r){var s=0,o=null,i=!1;n.subscribe(K(r,function(c){o||(o=K(r,void 0,function(){o=null,i&&r.complete()}),le(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function of(){return G(function(e,t){var n,r=!1;e.subscribe(K(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function ln(e,t){return G(Ci(e,t,arguments.length>=2,!0))}function fn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new He}: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 h,d,l,f=0,p=!1,m=!1,v=function(){d?.unsubscribe(),d=void 0},y=function(){v(),h=l=void 0,p=m=!1},b=function(){var g=h;y(),g?.unsubscribe()};return G(function(g,w){f++,!m&&!p&&v();var k=l=l??n();w.add(function(){f--,f===0&&!m&&!p&&(d=Hr(b,u))}),k.subscribe(w),!h&&f>0&&(h=new zt({next:function(I){return k.next(I)},error:function(I){m=!0,v(),d=Hr(y,s,I),k.error(I)},complete:function(){p=!0,v(),d=Hr(y,i),k.complete()}}),le(g).subscribe(h))})(a)}}function Hr(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 zt({next:function(){s.unsubscribe(),e()}});return le(t.apply(void 0,Re([],Te(n)))).subscribe(s)}}function hn(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,fn({connector:function(){return new Fn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Oi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return G(function(r,s){(n?jn(e,r,n):jn(e,r)).subscribe(s)})}function Kn(e,t){return G(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(K(r,function(u){s?.unsubscribe();var a=0,h=o++;le(e(u,h)).subscribe(s=K(r,function(d){return r.next(t?t(u,d,h,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function cf(){return Kn(Qe)}function Ti(e){return G(function(t,n){le(e).subscribe(K(n,function(){return n.complete()},ke)),!n.closed&&t.subscribe(n)})}function jr(e,t){return t===void 0&&(t=!1),G(function(n,r){var s=0;n.subscribe(K(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Xn(e,t,n){var r=W(e)||t||n?{next:e,error:t,complete:n}:e;return r?G(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(K(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)}))}):Qe}function qr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=zr(e);return G(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){le(e[d]).subscribe(K(s,function(l){i[d]=l,!u&&!c[d]&&(c[d]=!0,(u=c.every(Qe))&&(c=null))},ke))},h=0;h<o;h++)a(h);r.subscribe(K(s,function(d){if(u){var l=Re([d],Te(i));s.next(n?n.apply(void 0,Re([],Te(l))):l)}}))})}var af=Object.defineProperty,uf=(e,t,n)=>t in e?af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ri=(e,t,n)=>uf(e,typeof t!="symbol"?t+"":t,n);class Pi extends Error{constructor(t){super(t.message),Ri(this,"code"),Ri(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}class Yn extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}class Ui extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Gn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Qn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Mi extends Error{constructor(t){super(t),this.name="OperationError"}}class Nn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Ue={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Zn={chainName:"",genesisHash:"",properties:""},Wr={broadcast:"",stop:""};Object.entries({chainHead:Ue,chainSpec:Zn,transaction:Wr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class Di extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class lf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class ff extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const jt=()=>{},hf=e=>(t,n)=>{let r=e(Wr.broadcast,[t],{onSuccess:s=>{r=s===null?jt:()=>{e(Wr.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};function df(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const Li=()=>{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)})}}},qt=e=>(...t)=>new Promise((n,r)=>{let s=At;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new eo)};i?.addEventListener("abort",c,{once:!0});const u=a=>h=>{s=At,i?.removeEventListener("abort",c),a(h)};s=e(u(n),u(r),...o)}),Vi=(e,t)=>n=>qt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(h,d)=>{if(h.result==="limitReached")return s(new Qn);const{operationId:l}=h,f=()=>{n(Ue.stopOperation,[l])};if(!i)return f();let p=jt;const m=y=>{i=!1,p(),r(y)},v=y=>{i=!1,p(),s(y)};p=d(l,{next:y=>{const b=y;b.event==="operationError"?s(new Mi(b.error)):b.event==="operationInaccessible"?s(new Nn):a(y,m,v)},error:v}),c=()=>{i&&(p(),f())}},onError:s}),()=>{c()}}),pf=Vi(Ue.body,e=>[[e],(t,n)=>{n(t.value)}]),vf=Vi(Ue.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),mf=e=>t=>new Promise((n,r)=>{e(Ue.header,[t],{onSuccess:n,onError:r})}),Fi=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),At;let u=!0,a=()=>{u=!1};return e(Ue.storage,[t,n,r],{onSuccess:(h,d)=>{if(h.result==="limitReached"||h.discardedItems===n.length)return o(new Qn);const{operationId:l}=h,f=()=>{e(Ue.stopOperation,[l])};if(!u)return f();const p=d(h.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{v();break}case"operationError":{m(new Mi(y.error));break}case"operationInaccessible":{m(new Nn);break}default:e(Ue.continue,[y.operationId])}},error:o});a=()=>{p(),e(Ue.stopOperation,[h.operationId])};const m=y=>{a=At,p(),o(y)},v=()=>{a=At,p(),i()};c(h.discardedItems)},onError:o}),()=>{a()}},yf=e=>{const t=Fi(e);return qt((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?l=>{a.push(l)}:l=>{a=l[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(l){r(l)}},l=>{l>0&&(d(),r(new Qn))});return d})},bf=e=>t=>t.length>0?new Promise((n,r)=>{e(Ue.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function gf(e){return e.operationId!==void 0}function wf(e){return(t,n,r)=>{const s=Li(),o=new Set,i=df();let c=i.promise;const u=p=>{if(gf(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:m,...v}=p;return n({type:m,...v})}r(new Ui),l(!1)},a=p=>{r(p),l(!(p instanceof Yn))},h=(p,m)=>{const v=m(p,{next:u,error:a});l=(y=!0)=>{c=null,l=jt,v(),y&&e(Ue.unfollow,[p]),s.errorAll(new Gn),o.forEach(b=>{b()}),o.clear()},c=p,i.res(p)},d=p=>{p instanceof Yn?l(!1):r(p),c=null,i.res(p)};let l=e(Ue.follow,[t],{onSuccess:h,onError:d});const f=(p,m,v)=>{const y=()=>{v?.onError(new Gn)};if(c===null)return y(),jt;const b=w=>{if(!v)return e(p,[w,...m]);o.add(y);const k=(T,x)=>c===null?(x.error(new Gn),jt):(s.subscribe(T,x),()=>{s.unsubscribe(T)}),I=e(p,[w,...m],{onSuccess:T=>{o.delete(y),v.onSuccess(T,k)},onError:T=>{o.delete(y),v.onError(T)}});return()=>{o.delete(y),I()}};if(typeof c=="string")return b(c);let g=jt;return c.then(w=>{if(w instanceof Error)return y();c&&(g=b(w))}),()=>{g()}};return{unfollow(){l(),c=null},body:pf(f),call:vf(f),header:mf(f),storage:yf(f),storageSubscription:Fi(f),unpin:bf(f),_request:f}}}let xf=1;const Ef=e=>{let t=xf++;const n=new Map,r=Li();let s=null;const o=(h,d,l)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:h,method:d,params:l}))};function i(h){try{let d,l,f,p,m;if({id:d,result:l,error:f,params:p}=JSON.parse(h),d===null)throw new Error(p?.error?.message??"id null");if(d!=null){const b=n.get(d);return b?(n.delete(d),f?b.onError(new Pi(f)):b.onSuccess(l,(g,w)=>{const k=g;return r.subscribe(k,w),()=>{r.unsubscribe(k)}})):void 0}if({subscription:m,result:l,error:f}=p,!m||!f&&!Object.hasOwn(p,"result"))throw 0;const y=m;f?r.error(y,new Pi(f)):r.next(y,l)}catch(d){console.warn("Error parsing incomming message: "+h),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new Yn),n.forEach(h=>h.onError(new Yn)),n.clear()};let u=1;return{request:(h,d,l)=>{if(!s)throw new Error("Not connected");const f=`${t}-${u++}`;return l&&n.set(f,l),o(f,h,d),()=>{n.delete(f)}},disconnect:c}},kf=e=>{const t=qt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(Zn.chainName,[]),t(Zn.genesisHash,[]),t(Zn.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Af=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),At;let c=!0,u=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,h)=>{const d=()=>{e("stopStorage",[a])};if(!c)return d();const l=h(a,{next:v=>{const{event:y}=v;if(y==="storage"){const{event:b,...g}=v;s(g)}else y==="storageDone"?m():p(new lf(v.error))},error:o}),f=()=>{u=At,l()};u=()=>{f(),d()};const p=v=>{f(),o(v)},m=()=>{f(),i()}},onError:o}),()=>{u()}},Sf=e=>qt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let u=c?[]:null;const a=c?u.push.bind(u):({[s]:h})=>{u=h};return e(r,[{key:o,type:s}],i,a,h=>{n(h),u=null},()=>{t(u),u=null})}),zi=()=>e=>e,Hi=()=>(e,t)=>{if(e===null)throw new Di(t);return e},$f=e=>{const t=(h,...d)=>e(`archive_v1_${h}`,...d),n=h=>d=>qt((l,f,...p)=>t(h,p,{onSuccess:m=>{try{l(d(m,...p))}catch(v){f(v)}},onError:f})),r=n("header")(Hi()),s=n("body")(Hi()),o=Af(t),i=Sf(o),c=n("call")((h,d)=>{if(!h)throw new Di(d);if(!h.success)throw new ff(h.error);return h.value}),u=n("finalizedHeight")(zi()),a=n("hashByHeight")(zi());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:u,hashByHeight:a}},Jn=new Map,If=e=>{const t=Jn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=Ef(e),s=()=>{const i=Jn.get(e);!i||i.refCount<=1?(Jn.delete(e),r()):i.refCount--},o={archive:$f(n),chainHead:wf(n),transaction:hf(n),getChainSpecData:kf(n),destroy:s,request:qt((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return Jn.set(e,{client:o,refCount:1}),o};var Bf=Object.defineProperty,Cf=(e,t,n)=>t in e?Bf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ji=(e,t,n)=>Cf(e,typeof t!="symbol"?t+"":t,n);class _f{constructor(){ji(this,"first"),ji(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 Of=()=>{const e=new Map,t=(l,f)=>{e.set(l,()=>{e.delete(l),f()})},n=l=>{e.get(l)?.()},r=new _f,s=r.unshift.bind(r),o=r.push.bind(r),i=(l,f)=>{const p=f?s:o;t(l.source$,p(l))},c=()=>{const l=r.pop();l&&(e.delete(l.source$),u(l))},u=l=>{const{source$:f,observer:p}=l;let m=!1;const v=f.subscribe({next(y){p.next(y)},error(y){(m=y instanceof Qn)?i(l,!0):p.error(y)},complete(){p.complete()}});v.closed?m||c():t(f,()=>{v.unsubscribe(),c()})},a=(l=!1)=>f=>new U(p=>{const m={observer:p,source$:f};return r.isEmpty()?u(m):i(m,l),()=>{n(f)}}),h=a();return{withRecovery:a,withRecoveryFn:l=>(...f)=>h(l(...f))}};class Ne extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Tf=new Set(["best","finalized",null]),qi=e=>{const t=e.pipe(Ae(n=>n instanceof Nn?Wn(750).pipe(Nl(()=>t)):zn(()=>n)));return t},Rf=(e,t,n)=>r=>(s,...o)=>{if(!Tf.has(s))return qi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(Q(1),R(u=>r(u,...o).pipe(n(u))),Ae(u=>u instanceof Ne?c:zn(()=>u)));return qi(c)},_t=e=>(...t)=>new U(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}}),Pf=e=>t=>(...n)=>e()[t](...n);function dn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:l=>i.next(l),error:l=>i.error(l),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let h=!1;const d=e.subscribe({next:l=>{const f=l.blocks.get(r);f?f.recovering?c?.unsubscribe():a():h&&i.error(new Ne(r,n)),h=l.recovering},error:l=>i.error(l)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Uf=e=>e.pipe(ln(({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)}),R(({newBlocks:t})=>t),fn()),Mf=(e,t)=>{const n=(r,s,o,i)=>new U(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(Hn(),t(i));return n},Df=e=>{const t=async(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return[o,i];const c=r.idx+Math.floor((s.idx-r.idx)/2),u={idx:c,id:await e(n[c])};if(u.id===r.id)return t(n,u,s);if(u.id===s.id)return t(n,r,u);const[a,[h,...d]]=await Promise.all([t(n,r,u),t(n,u,s)]);return[...a,...d]};return async n=>{if(n.length<2)return n;const r=n.length-1,[s]=n,o=n[r],[i,c]=await Promise.all([s,o].map(e));return i===c?[n[0]]:t(n,{idx:0,id:i},{idx:r,id:c})}},Lf=(e,t)=>{const n=Df(t);return r=>new U(s=>{let o=null;return r.subscribe({next(i){i.type==="initialized"?(o=[],Promise.all([e(i.finalizedBlockHashes[0]),n(i.finalizedBlockHashes)]).then(([c,u])=>{s.closed||(s.next({type:"initialized",finalizedBlockHashes:i.finalizedBlockHashes,runtimeChanges:new Set(u),number:c.number,parentHash:c.parentHash}),o.forEach(a=>{s.next(a)}),o=null)}).catch(c=>{s.closed||s.error(c)})):o?o.push(i):s.next(i)},error(i){s.error(i)},complete(){s.complete()}})})},Vf=e=>{let t=null,n=ke;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=u=>r().header(u).then(gr.dec),o=async u=>r().storage(u,"hash","0x3a636f6465",null),i=Kl(new U(u=>{t=e(!0,a=>{u.next(a)},a=>{t=null,u.error(a)}),n=()=>{u.complete(),t?.unfollow()}}).pipe(Lf(s,o),Ff()));return{getHeader:s,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},Ff=()=>e=>new U(t=>{const n=new Ct,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Ui?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),zf=e=>ee(De.enc(e)),Wi=X(),Hf=ht(Wi),jf=Se(De).dec,Ki=e=>{const t=e("Metadata_metadata_versions","").pipe(S(jf),Ae(()=>re([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(S(Wi.dec)):e("Metadata_metadata_at_version",zf(s)).pipe(S(o=>Hf.dec(o)))};return t.pipe(R(n))},Xi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",bt={type:"void"},qf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=h=>d=>{let l=n.get(d);if(l)return l;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const f=h(d);return l=n.get(d),l?Object.assign(l,f):(l={id:d,...f},n.set(d,l)),r.delete(d),l};let o=!0,i=!0;const c=s(h=>{const d=t(e[h]);if(d)return d;const{def:l,path:f,params:p}=e[h];if(l.tag==="composite"){if(l.value.length===0)return bt;if(l.value.length===1){const m=c(l.value[0].type);return o&&f.at(-1)==="AccountId32"&&Xi(m,32)?(o=!1,{type:"AccountId32"}):i&&f.at(-1)==="AccountId20"&&Xi(m,20)?(i=!1,{type:"AccountId20"}):m}return u(l.value)}if(l.tag==="variant"){if(f.length===1&&f[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(f.length===1&&f[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(l.value.length===0)return bt;const m={},v={};return l.value.forEach(y=>{const b=y.name;if(v[b]=y.docs,y.fields.length===0){m[b]={...bt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){m[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}m[b]={...u(y.fields),idx:y.index}}),{type:"enum",value:m,innerDocs:v}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:m}=l.value,v=c(l.value.type);return!m||v.type==="void"?bt:m>1?{type:"array",value:v,len:l.value.len}:v}if(l.tag==="tuple")return l.value.length===0?bt:l.value.length>1?a(l.value.map(m=>c(m)),l.value.map(m=>e[m].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const m=c(l.value);return m.type==="void"?bt:{type:"compact",isBig:Number(m.value.slice(1))>32,size:m.value}}return{type:l.tag,isLSB:(e[l.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=h=>{let d=!0;const l={},f={};return h.forEach((p,m)=>{d=d&&!!p.name;const v=p.name||m,y=c(p.type);y.type!=="void"&&(l[v]=y,f[v]=p.docs)}),d?{type:"struct",value:l,innerDocs:f}:a(Object.values(l),Object.values(f))},a=(h,d)=>{if(h.every(l=>l.id===h[0].id)&&d.every(l=>!l.length)){const[l]=h;return l.type==="void"?bt:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:d}};return c},er=e=>{const t=qf(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?{...bt,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})},Wf=(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},Kf=tn(),Yi=Wf((e,t,n,r)=>{if(e.type==="primitive")return Wo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return wo;if(e.type==="compact")return e.isBig?Cn:B;if(e.type==="bitSequence")return On(e.isLSB);const s=f=>Yi(f,t,n,r),o=(f,p)=>{const m=s(f);return p?Se(m,p):Se(m)},i=f=>Fe(...f.map(s)),c=f=>{const p=Object.fromEntries(Object.entries(f).map(([m,v])=>[m,s(v)]));return oe(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Kf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?tn(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 ht(s(e.value));if(e.type==="result")return _n(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(f=>{switch(f.type){case"void":return _;case"lookupEntry":return s(f.value);case"tuple":return i(f.value);case"struct":return c(f.value);case"array":return o(f.value,f.len)}}),a=Object.fromEntries(Object.keys(e.value).map((f,p)=>[f,u[p]])),h=Object.values(e.value).map(f=>f.idx),l=h.every((f,p)=>f===p)?xe(a):xe(a,h);return e.byteLength?Xf(l,e.byteLength):l},pr,e=>e),Gi=(e,t=kt())=>{const n=new Map,r=s=>Yi(e(s),n,new Set,t);return s=>r(s)},Xf=(e,t)=>{const n=X(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Yf=Ke(_,()=>{},()=>null),Kr=e=>{const{metadata:t}=e;let n=Gi(e);const r=t.pallets.find(l=>l.name==="System")?.constants.find(l=>l.name==="SS58Prefix");let s;if(r)try{const l=n(r.type).dec(r.value);typeof l=="number"&&(s=l,n=Gi(e,kt(l)))}catch{}const o=new Map,i=(l,f)=>{let p=o.get(l);p||o.set(l,p=jo(l));const m=t.pallets.find(x=>x.name===l).storage.items.find(x=>x.name===f),v=x=>x===_?Yf:x,y=(x,P,...M)=>{const J=p(...M),[,...q]=M;return{args:Fe(...q.map(([fe])=>fe)),keys:J,value:P,len:x,fallback:m.modifier===1?P.dec(m.fallback):void 0}};if(m.type.tag==="plain")return y(0,v(n(m.type.value)),f);const{key:b,value:g,hashers:w}=m.type.value,k=v(n(g)),I=w.map(x=>Wo[x.tag]),T=(()=>{if(I.length===1)return[[n(b),I[0]]];const x=e(b);switch(x.type){case"array":return I.map(P=>[n(x.value.id),P]);case"tuple":return x.value.map((P,M)=>[n(P.id),I[M]]);default:throw new Error("Invalid key type")}})();return y(I.length,k,f,...T)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return Fe(...Object.values(l.value).map(f=>n(f.id)));case"struct":return oe(Ut(l.value,f=>n(f.id)));case"array":return Se(n(l.value.id),l.len)}},u=(l,f)=>{const p=t.pallets.find(m=>m.name===l).constants.find(m=>m.name===f);return n(p.type)},a=l=>(f,p)=>{const m=t.pallets.find(b=>b.name===f),v=e(m[l].type);if(v.type!=="enum")throw null;const y=v.value[p];return{location:[m.index,y.idx],codec:c(v.value[p])}},h=(l,f)=>{const p=t.pallets.find(m=>m.name===l)?.viewFns.find(m=>m.name===f);if(!p)throw null;return{args:Fe(...p.inputs.map(m=>n(m.type))),value:n(p.output)}},d=(l,f)=>{const p=t.apis.find(m=>m.name===l)?.methods.find(m=>m.name===f);if(!p)throw null;return{args:Fe(...p.inputs.map(m=>n(m.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:h,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},Qi="CheckMortality",Ni=(e,t,n)=>{const r=er(e),s=Kr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(h=>h.identifier==="ChargeAssetTxPayment");let c=null;if(i){const h=r(i.type);if(h.type==="struct"){const d=h.value.asset_id;d.type==="option"&&(c=d.value.id)}}const u=Nf(r.metadata,s),a=h=>{const d=u(h);return"extra"in d&&d.extra[Qi]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:kt(s.ss58Prefix),getMortalityFromTx:a}},Xr=X(1/0).dec,Gf=wn(et[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),Qf=wt(e=>{const t=V.dec(e);if(t===0)return{mortal:!1};const n=V.dec(e);return Gf(Uint8Array.from([t,n]))}),Nf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===Qi?Qf:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,u=c?.find(d=>d.name==="Call")?.type,a=c?.find(d=>d.name==="Address")?.type,h=c?.find(d=>d.name==="Signature")?.type;if(u==null||a==null||h==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(h)[1]}const i=oe.dec({address:r,signature:s,extra:oe.dec(n),callData:Xr});return wt(c=>{const u=B.dec(c),{type:a,version:h}=Sr[1](c);if(a==="bare")return{len:u,version:h,type:a,callData:Xr(c)};if(a==="signed")return{len:u,version:h,type:a,...i(c)};const d=V.dec(c);let l;if(e.version===16){const p=e.extrinsic.signedExtensionsByVersion.find(([m])=>m===d);if(!p)throw new Error("Unexpected extension version");l=oe.dec(Object.fromEntries(Object.entries(n).filter((m,v)=>p[1].includes(v))))}else l=oe.dec(n);const f=l(c);return{len:u,type:a,version:h,extensionVersion:d,extra:f,callData:Xr(c)}})},Zf=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe(Ae(o=>{if(o instanceof Ne)return n(...r);if(o instanceof Nn)return Wn(750).pipe(R(()=>n(...r)));throw o})):vt};return n},Jf=(e,t,n,r)=>{const s=(o,i)=>o.pipe(R(c=>n(c).pipe(Ae(()=>re(null)),R(u=>u?re(u):i.pipe(Xn(a=>{r(c,a)}))),S(u=>({codeHash:c,metadataRaw:u,metadata:Dt(dt.dec(u))})))));return o=>{const i=Zf(o),c=o(),u=new Set([c]),a=i(t)().pipe(hn(1)),h=s(a,Ki(i(e))).pipe(S(({metadata:l,metadataRaw:f,codeHash:p})=>Ni(l,f,p)),hn(1)),d={at:c,runtime:h,codeHash$:a,addBlock:l=>(u.add(l),d),deleteBlocks:l=>(l.forEach(f=>{u.delete(f)}),u.size),usages:u};return h.subscribe({error(){}}),d}},pn=fn({connector:()=>new Fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Zi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ji=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},eh=(e,t)=>{t.forEach(n=>{Ji(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]})},th=(e,t,n,r,s,o,i,c)=>{const u=new He,a=u.pipe(sf(()=>Wn(0)),S(()=>({type:"cleanup"}))),h=un(o,a,e).pipe(ln((l,f)=>{const p=m=>{eh(l,m),i(m)};switch(f.type){case"initialized":l.recovering&&!f.finalizedBlockHashes.some(y=>l.blocks.has(y))&&(l=ec());const m=f.finalizedBlockHashes.length-1;l.finalized=l.best=f.finalizedBlockHashes[m];let v=l.finalizedRuntime.at;return f.finalizedBlockHashes.forEach((y,b)=>{const g=b!==m,w=l.blocks.get(y);if(w)w.recovering=!1,w.unpinnable=g;else{const k=f.runtimeChanges.has(y);k&&(v=y),l.blocks.set(y,{hash:y,parent:b===0?f.parentHash:f.finalizedBlockHashes[b-1],children:new Set(b===m?[]:[f.finalizedBlockHashes[b+1]]),unpinnable:g,runtime:v,refCount:0,number:f.number+b,recovering:!1}),k&&(l.finalizedRuntime=l.runtimes[y]=d(Zi(l,y))),l.runtimes[v].usages.add(y)}}),l;case"stop-error":for(const y of l.blocks.values())y.recovering=!0;return l.recovering=!0,l;case"newBlock":{const{parentBlockHash:y,blockHash:b}=f;if(l.blocks.has(b))l.blocks.get(b).recovering=!1;else{const g=l.blocks.get(y);g.children.add(b);const w={hash:b,number:g.number+1,parent:y,children:new Set,runtime:f.newRuntime?b:g.runtime,unpinnable:!1,refCount:0,recovering:!1};l.blocks.set(b,w),f.newRuntime&&(l.runtimes[b]=d(Zi(l,b))),l.runtimes[w.runtime].addBlock(b)}return l}case"bestBlockChanged":{if(l.recovering){for(const[y,b]of l.blocks)b.recovering&&(Ji(l.blocks,y),c(y));l.recovering=!1}return l.best=f.bestBlockHash,l}case"finalized":{l.finalized=f.finalizedBlockHashes.slice(-1)[0];const{blocks:y}=l;y.get(l.best).number<y.get(l.finalized).number&&(l.best=l.finalized),l.finalizedRuntime=l.runtimes[y.get(l.finalized).runtime],f.prunedBlockHashes.forEach(g=>{const w=l.blocks.get(g);w&&(w.unpinnable=!0)});let b=y.get(y.get(l.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=y.get(b.parent);return u.next(),l}case"cleanup":{const y=[...l.blocks.values()].filter(({unpinnable:b,refCount:g})=>b&&!g).map(({hash:b})=>b);return p(y),l}case"blockUsage":{if(!l.blocks.has(f.value.hash))return l;const y=l.blocks.get(f.value.hash);if(y.refCount+=f.value.type==="hold"?1:-1,y.refCount===0&&!y.recovering&&y.unpinnable){const b=[y.hash];p(b)}return l}}},ec()),Pe(l=>!!l.finalizedRuntime.runtime),S(l=>({...l})),pn),d=Jf(dn(h,t,"pinned-blocks"),dn(h,n,"pinned-blocks"),r,s);return h},ec=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),tc=(e,t,n,r)=>{const s=c=>Ti(e.pipe(Pe(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const h=s(c);return t(c).pipe(R(d=>{const l=d.indexOf(u);return l>-1?h(r(c)).pipe(S(f=>({hash:c,found:{type:!0,index:l,events:f}}))):n(c,u).pipe(S(f=>({hash:c,found:{type:!1,validity:f}})))}),h)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(R(h=>{const{found:d}=h;return d.type||d.validity?.success===!1?re(h):e.pipe(s(c),R(l=>l.blocks.get(c).children),tf(),R(l=>i(l,u,a)))}));return c=>e.pipe(Q(1),R(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},nh=new Uint8Array([2]),rh=(e,t)=>ee(se([nh,me(e),me(t)])),nc="TaggedTransactionQueue",rc="validate_transaction",[,sh]=xe({InvalidTransaction:xe({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:xe({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),oh=wt(e=>{const t=V.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=sh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),ih=(e,t)=>(n,r)=>{const s=t(n).pipe(S(o=>{try{return o.dynamicBuilder.buildRuntimeCall(nc,rc).value[1]}catch{return oh}}));return e(n,`${nc}_${rc}`,rh(r,n)).pipe(qr(s),S(([o,i])=>i(o)))},ch=e=>t=>new U(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}),ah=e=>t=>new U(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)}}),sc=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,h=0;const d=()=>{const l=o.get(a);if(!l){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const f=a++;o.delete(f),h!==f&&c.set(f,[]);let p=!1,m=l.subscribe({next(v){h===f?r.next(v):c.get(f).push(v)},complete(){if(p=!0,i.delete(f),f===h)for(h++;c.has(h)&&(c.get(h).forEach(v=>r.next(v)),c.delete(h),!i.has(h));)h++;d()},error(v){r.error(v)}});p||i.set(f,m)};return s=new Ct,s.add(n.subscribe({next(l){const f=u++;o.set(f,qn(()=>e(l,f))),i.size<t&&d()},error(l){r.error(l)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(l=>l.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Yr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),uh=(e,t,n)=>{const{getFollower:r,startFollow:s,follow$:o,getHeader:i}=Vf(e),c=Pf(r),{withRecovery:u,withRecoveryFn:a}=Of(),h=new He,d=E=>$=>new U(C=>{h.next({type:"blockUsage",value:{type:"hold",hash:E}});const L=$.subscribe(C);return L.add(()=>{setTimeout(()=>{h.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),L}),l=E=>($,...C)=>E($,...C).pipe(d($)),f=(E,$)=>(C,...L)=>new U(de=>{let ce=!1;return g.pipe(Q(1)).subscribe(qe=>{ce=qe.blocks.has(C)}),ce?E(C,...L).subscribe(de):de.error(new Ne(C,$))}),p=E=>r().unpin(E).catch($=>{if(!($ instanceof Gn))throw $}),m=(E,$)=>f(l(dn(g,a(_t(E)),`stop-${$}`)),$),v=new Map,y=l(a(_t(c("storage")))),b=E=>y(E,"hash","0x3a636f6465",null).pipe(S($=>$)),g=th(o,l(a(_t(c("call")))),b,t,n,h,E=>{p(E),E.forEach($=>{v.delete($)})},E=>{v.delete(E)}),w=f(l(E=>g.pipe(Q(1),R($=>$.runtimes[$.blocks.get(E).runtime].runtime))),"getRuntimeCtx"),k=E=>$=>$.pipe(sc(C=>w(E(C)).pipe(S(L=>[C,L])))),I=(E,$,C)=>{const L=v.get(E)??new Map,de=L.get($);if(de)return de;v.set(E,L);let ce;const qe=C.pipe(fn({connector:()=>ce=new Fn}),Xn({complete(){L.set($,ce)}}),ah());return L.set($,qe),qe},T=g.pipe(Pe(E=>!E.recovering),ye((E,$)=>E.finalized===$.finalized),ln((E,$)=>{let C=$.blocks.get($.finalized);const L=[C],de=E.at(-1);if(!de)return L;for(;C.number>de.number+1&&(C=$.blocks.get(C.parent),!!C);)L.unshift(C);return L},[]),Hn(),S(Yr),pn),x=g.pipe(ye((E,$)=>E.best===$.best),S(E=>Yr(E.blocks.get(E.best))),pn),P=g.pipe(Pe(E=>!E.recovering),ye((E,$)=>E.finalized===$.finalized&&E.best===$.best),ln((E,$)=>{const C=Me=>E.get(Me)||Yr($.blocks.get(Me)),L=C($.best),de=C($.finalized),ce=L.number-de.number+1,qe=new Array(ce);for(let Me=0,Bc=L.hash;Me<ce;Me++)qe[Me]=C(Bc),Bc=qe[Me].parent;return new Map(qe.map(Me=>[Me.hash,Me]))},new Map),S(E=>[...E.values()]),pn),M=g.pipe(ye((E,$)=>E.finalizedRuntime===$.finalizedRuntime),Kn(({finalizedRuntime:{runtime:E}})=>E.pipe(ch(null))),pn),J=M.pipe(S(E=>E?.lookup.metadata??null)),q=Rf(T.pipe(S(E=>E.hash)),x.pipe(S(E=>E.hash)),d),fe=m(c("body"),"body"),N=E=>I(E,"body",fe(E)),he=m(c("storage"),"storage"),ie=q(f((E,$,C,L=null,de)=>g.pipe(Q(1),R(ce=>ce.runtimes[ce.blocks.get(E).runtime].runtime),R(ce=>{const qe=C(ce);return I(E,`storage-${$}-${qe}-${L??""}`,he(E,$,qe,L)).pipe(de?S(Me=>de(Me,ce)):Qe)})),"storage")),be=Mf(r,u),Je=q(f(dn(g,(E,$,C)=>be(E,$,C??null,!1),"storageQueries"),"storageQueries")),ir=q(f(dn(g,E=>qn(()=>i(E)),"header"),"header")),Xt=E=>ie(E,"value",$=>$.events.key,null,($,C)=>C.events.dec($)),ls=m(c("call"),"call"),Sc=q((E,$,C)=>I(E,`call-${$}-${C}`,ls(E,$,C))),fs=ih(Sc,w),$c=E=>I(E,"body",fe(E)),fd=tc(g,$c,fs,Xt),hd=tc(g,$c,fs,()=>re()),dd=M.pipe(Pe(Boolean),Q(1),R(E=>{const{enc:$}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=$(0)}catch{C=$(0n)}return ie(null,"value",()=>C,null)}),hn(1));un(M,P).subscribe({error(){}});let hs=ke,yn=!1,ds=0;const pd=E=>{ds+=E,yn=!0,hs=s()},vd=E=>g.pipe(Q(1),R(({runtimes:$})=>un(...Object.values($).map(C=>C.codeHash$.pipe(R(L=>E===L?C.runtime:vt)))).pipe(rf(null),Q(1)))),Ic=(E,$=!1)=>{let C=E||"finalized",L=!1;if(yn&&g.pipe(Q(1)).subscribe(ce=>{C=ce[C]||C,L=ce.blocks.has(C)}),!L){if($)throw new Ne(C,"holdBlock");return ke}h.next({type:"blockUsage",value:{type:"hold",hash:C}});let de=()=>{h.next({type:"blockUsage",value:{type:"release",hash:C}}),de=ke};return()=>{de()}},md=E=>$=>new U(C=>{const L=$.subscribe(C);return L.closed||L.add(Ic(E)),L});return[{follow$:o,finalized$:T,best$:x,bestBlocks$:P,newBlocks$:Uf(g),runtime$:M,metadata$:J,genesis$:dd,getRuntime$:vd,header$:ir,body$:N,call$:Sc,storage$:ie,storageQueries$:Je,eventsAt$:Xt,withHodl:md,holdBlock:Ic,trackTx$:fd,trackTxWithoutEvents$:hd,validateTx$:fs,pinnedBlocks$:g,withRuntime:k,getRuntimeContext$:q(w),unfollow:()=>{yn!=null&&(ds--,yn&&!ds&&(yn=null,hs(),hs=ke))}},pd]};var lh=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const fh=({storageSubscription:e,...t})=>n=>{const r={},s=_t(t.storage),o=_t(t.call),i=_t(t.header),c=_t(t.body),u=m=>i(m).pipe(S(gr[1])),a=m=>s(m,"hash","0x3a636f6465",null).pipe(S(v=>v)),h=(m,v)=>n(m).pipe(Ae(()=>re(null)),R(y=>y?re(y):Ki((...b)=>o(v,...b)).pipe(S(b=>Ni(Dt(dt.dec(b)),b,m)))),Xn(y=>{r[m]=y})),d=m=>a(m).pipe(R(v=>{const y=r[v];return y?re(y):h(v,m)})),l=(m,v,y,b=null,g)=>d(m).pipe(R(w=>s(m,v,y(w),b).pipe(S(k=>g?g(k,w):k))));return{body$:c,header$:u,storage$:l,storageQueries$:(m,v,y)=>new U(b=>e(m,v,y||null,g=>b.next(g),g=>b.error(g),()=>{b.complete()})),call$:o,eventsAt$:m=>l(m,"value",v=>v.events.key,null,(v,y)=>y.events.dec(v)),getRuntimeContext$:d}},hh=()=>re(null),tr=new Map,dh=(e,t={})=>{const{getMetadata:n,setMetadata:r}=t,s=tr.get(e);if(s)return s.refCount++,s.client;const o=()=>{const h=tr.get(e);!h||h.refCount<=1?(tr.delete(e),e.destroy()):h.refCount--};let i=null,c=0,u=null;const a={chainHead$:h=>{c++,u||(u=h||1),i||(i=uh(e.chainHead,n||hh,r||ke));const[d,l]=i;if(u===c){const f=c;c=0,u=null,i=null,l(f)}return d},archive:fh(e.archive),broadcastTx$:lh(e.transaction),destroy:o};return tr.set(e,{client:a,refCount:1}),a},ph=(e,t)=>e.pipe(jr(n=>n.blocks.has(t)),ye((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let 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}),ye(),jr(n=>n!=="finalized",!0)),Ot=(e,t)=>(n,...r)=>e(n,...r).pipe(Ae(s=>{if(!(s instanceof Ne))throw s;return t(n,...r).pipe(Ae(o=>{throw console.warn(o),s}))}));class Tt{constructor(){}_runtime(t){}}class Gr{constructor(){}_compatibility(t){}}const nr=new WeakMap,oc=new WeakMap,rr=e=>e instanceof Tt?oc.get(e):nr.get(e);var gt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(gt||{});const vh=Se(Gu),mh=Se(Cr),yh=Fe(vh,mh),bh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Pe(i=>i!=null));let o=await je(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(yh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Gr;return nr.set(c,{runtime:i,getEntryPoint(u,a,h){const d=o[u]?.[a]?.[h];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${h} does not exist`);return r[d]},typedefNodes:s}),c})},gh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Pe(s=>s!=null));let r=await je(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Tt;return oc.set(n,{runtime:t}),n}),Qr=new WeakMap,ic=e=>(Qr.has(e.metadataRaw)||Qr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Qr.get(e.metadataRaw)),Rt=(e,t,n)=>{const r=(i,c)=>{var u;const a=ic(i);return(u=a.typeNodes)[c]||(u[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Tt)return{args:Oe.Identical,values:Oe.Identical};const u=nr.get(i);c||(c=u.runtime());const a=n(c);if(a==null)return{args:Oe.Incompatible,values:Oe.Incompatible};const h=u.typedefNodes,d=ic(c),l=t(u),f=Ju(l,p=>h[p],a,p=>r(c,p),d.compat);return{args:f.args.level,values:f.values.level}}const o=ac(e,i=>cc(s(i)));return{isCompatible:ac(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>Ht([u.pipe(i.withRuntime(c)),e]).pipe(S(([[a,h],d])=>[a,d,h])),compatibleRuntime$:(i,c)=>Ht([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Tt)return!0;const a=s(i,c);if(a.args===Oe.Incompatible)return!1;if(a.args>Oe.Partial)return!0;if(a.values===Oe.Incompatible)return!1;const h=n(c);return h==null?!1:Zo(h.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Tt)return!0;const a=s(i,c).values;if(a===Oe.Incompatible)return!1;if(a>Oe.Partial)return!0;const h=nr.get(i),d=t(h);return Zo(d.values,l=>h.typedefNodes[l],u)},getRuntimeTypedef:r}},cc=e=>Math.min(e.args,e.values),ac=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Gr||r instanceof Tt?t(...n):e.then(s=>t(...n,s))},wh=(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 h=a.lookup.metadata.pallets.find(l=>l.name===e)?.constants.find(l=>l.name===t);if(h==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(h.value);return i.set(a,d),d},u=a=>{if(a){const h=rr(a).runtime(),d=c(h);if(!n(a,h,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},xh=fn({connector:()=>new Fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function vn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new eo)}:ke;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 Nr=Symbol("EMPTY_VALUE"),Zr=e=>t=>new U(n=>{let r=0,s=null,o=Nr,i=!1;const c=()=>{const a=e(o,r++);o=Nr,s=a.subscribe({next(h){n.next(h)},error(h){n.error(h)},complete(){o!==Nr?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 uc={};const Eh=e=>t=>new U(n=>{let r=uc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===uc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Wt=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)),kh=()=>{const e=new dl(new He);return[e.pipe(cf()),()=>Xn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new He)},complete:()=>{e.value.complete(),e.next(new He)}})]},Ah=(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,h=>h.hash),S(([h,d,l])=>{const f=l.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(f==null||l.lookup.metadata.lookup[f].def.tag!=="variant"||l.lookup.metadata.lookup[f].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,l,null))throw u();return[h,d,l]}),sc(([h,d,l])=>n.eventsAt$(h.hash).pipe(S(f=>f.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,l,p.event.value.value))throw u();return{meta:{phase:p.phase,block:h},payload:p.event.value.value}})))),xh);return{watch:h=>a.pipe(R(d=>h?d.filter(l=>h(l.payload)):d)),pull:()=>je(a),filter:h=>h.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},Sh=(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((...h)=>{const d=h[h.length-1],l=Wt(d),{signal:f,at:p}=l?d:{},m=p??null,v=o(n,m).pipe(R(([y,b])=>{let g;try{g=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,b,h))throw a();return n.call$(m,u,ee(g.args.enc(h))).pipe(S(g.value.dec),S(w=>{if(!c(y,b,w))throw a();return w}))}),n.withHodl(m));return vn(v,f)},{getCompatibilityLevel:s,isCompatible:r})},lc=S(e=>e.mapped),$h=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const h=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",l=n.runtime$.pipe(Pe(Boolean),Q(1),S(({dynamicBuilder:x})=>typeof x.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Qe),hn()),f=si(Ql(l),S(([x,P])=>P(x))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=x=>new Error(`Invalid Arguments calling ${e}.${t}(${x})`),v=x=>{try{return x.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...x)=>{const P=x[x.length-1],M=P==="best",J=M||P==="finalized"?x.slice(0,-1):x;return n[M?"best$":"finalized$"].pipe(Zr(()=>b(...J,M?{at:"best"}:{})),ye((q,fe)=>q.raw===fe.raw),lc)},b=(...x)=>{const P=x[x.length-1],M=Wt(P),{at:J}=M?P:{},q=J??null,fe=yt(c).pipe(R(N=>n.storage$(q,"value",he=>{const ie=v(he),be=x.length===ie.len?x:x.slice(0,-1);if(x!==be&&!M)throw m(x);if(!u(N,he,be))throw p();return ie.keys.enc(...be)},null,(he,ie)=>{const be=v(ie),Je=he===null?be.fallback:be.value.dec(he);if(!a(N,ie,Je))throw p();return{raw:he,mapped:Je}})),n.withHodl(q));return h?n.pinnedBlocks$.pipe(S(N=>{const he=q==="finalized"||!q?N.finalized:q==="best"?N.best:q,ie=N.blocks.get(he);if(!ie)throw new Ne(he,"System.Number");return ie.number}),ye(),f,S(N=>({raw:N.toString(),mapped:N})),Ae(N=>{if(N instanceof Ne)return fe;throw N})):d&&Number(x[0])===0?n.genesis$.pipe(S(N=>({raw:N,mapped:Bn.fromHex(N)}))):fe},g=async(...x)=>{const P=x[x.length-1],M=Wt(P),{signal:J}=M?P:{};return vn(b(...x).pipe(lc),J)},w=async(...x)=>{const P=x[x.length-1],M=Wt(P),{signal:J,at:q}=M?P:{},fe=q??null,N=yt(c).pipe(R(he=>n.storage$(fe,"descendantsValues",ie=>{const be=v(ie);if(cc(i(he,ie))===Oe.Incompatible)throw p();if(x.length>be.len)throw m(x);const Je=x.length>0&&M?x.slice(0,-1):x;if(x.length===be.len&&Je===x)throw m(x);return be.keys.enc(...Je)},null,(ie,be)=>{const Je=v(be),ir=ie.map(({key:Xt,value:ls})=>({keyArgs:Je.keys.dec(Xt),value:Je.value.dec(ls)}));if(ir.some(({value:Xt})=>!a(he,be,Xt)))throw p();return ir})),n.withHodl(fe));return vn(N,J)},k=(x,P)=>Promise.all(x.map(M=>g(...P?[...M,P]:M))),I=(...x)=>{const P=x.at(-1),M=Wt(P);return r(e,t,M?x.slice(0,-1):x,M&&P.at==="best")},T=(...x)=>{const P=x.at(-1);if(P instanceof Gr||P instanceof Tt){const M=x.slice(0,-1),J=rr(P).runtime();if(!u(P,J,M))throw p();return v(J).keys.enc(...M)}return c.then(M=>T(...x,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:T,getValue:g,getValues:k,getEntries:w,watchValue:y,watchEntries:I}},Jr=()=>new Error("Unkown signer"),Ih=e=>{const{extrinsic:t}=e,n=er(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 Jr()}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 Jr();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 Jr()},Bh={Ed25519:0,Sr25519:1,Ecdsa:2},Ch=(e,t,n,r,s,o)=>{const[i,c]=Ih(e),u=se([Sr.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Bh[o],...n]),...r,s]);return se([pe.enc(u.length),u])},[sr,mn]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),_h=e=>async t=>{let n=!0,r;for(r=0;n&&r<sr.length;r++)n=sr[r]===t[r];n=n&&r===sr.length;const s=t.length-mn.length;for(r=0;n&&r<mn.length;r++)n=mn[r]===t[s+r];return n=n&&r===mn.length,e(n?t:se([sr,t,mn]))};function Oh(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=rn)=>{const a=Dt(Ar(i)),h=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const m=o[p];if(!m)throw new Error(`Missing ${p} signed extension`);h.push(m.value),d.push(m.additionalSigned)});const l=se([s,...h,...d]),f=await n(l.length>256?u(l):l);return Ch(a,e,f,h,s,t)},signBytes:_h(n)}}Uint8Array.from([1]);const Th=(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 Rh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Ph=e=>1<<Math.ceil(Math.log2(e)),Uh=gn(X(2)[0],e=>{const t=Math.min(Math.max(Ph(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Rh(t)-1,1),15),o=n/r<<4;return et[0](s|o)}),[Mh]=oe({tip:pe,asset:ht(X(1/0))}),fc=new Uint8Array,es=Uint8Array.from([0]),ts=e=>({value:e,additionalSigned:fc}),ns=e=>({value:fc,additionalSigned:e}),rs=(e,t)=>({value:e,additionalSigned:t}),hc=(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=[],h=Th(t,n),d=f=>{const[p,m]=r[f],v=c[f];try{return Ut({value:p,additionalSigned:m},(y,b)=>{const g=v?.[b];return g instanceof Uint8Array?g:y(g)})}catch{return a.push(f),null}},l=Ut(r,([f,p],m)=>{if(c[m])return d(m);switch(m){case"CheckNonce":return ts(f(i));case"CheckMortality":return s.mortal?rs(Uh({period:s.period,startAtBlock:s.startAtBlock.height}),me(s.startAtBlock.hash)):rs(es,e);case"ChargeTransactionPayment":return ts(f(o));case"ChargeAssetTxPayment":return ts(Mh({tip:o,asset:u.asset}));case"CheckGenesis":return ns(e);case"CheckMetadataHash":return rs(es,es);case"CheckSpecVersion":return ns(p(h.spec_version));case"CheckTxVersion":return ns(p(h.transaction_version));default:return d(m)}});return a.forEach(f=>{delete l[f]}),Ut(l,(f,p)=>({...f,identifier:p}))}},dc="AccountNonceApi_account_nonce",Dh={1:V.dec,2:et.dec,4:De.dec,8:Gt.dec},Lh=(e,t,n)=>e(n,dc,t).pipe(S(r=>{const s=me(r),o=Dh[s.length];if(!o)throw new Error(`${dc} retrieved wrong data`);return o(s)})),Vh=(e,t,n,r,s,o={})=>Ht([o.nonce?re(o.nonce):Fh(e,ee(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(Q(1),R(([i,c,u])=>{const a=hc(me(u),c.lookup,c.dynamicBuilder),h=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:h.mortal?{mortal:!0,period:h.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),Fh=(e,t)=>{const n=o=>e.newBlocks$.pipe(ln((i,c)=>c.parent===i?c.hash:i,o),Oi(o),ye()),r=o=>n(o).pipe(Q(2),Kn(i=>Lh(e.call$,t,i))),s=o=>Ht(o.map(i=>r(i).pipe(S(c=>({success:!0,value:c})),Ae(c=>re({success:!1,value:c}))))).pipe(Q(1));return e.pinnedBlocks$.pipe(Pe(o=>!o.recovering&&o.blocks.size>0),Q(1),S(({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)}),Kn(s),S(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 zh=Object.defineProperty,Hh=(e,t,n)=>t in e?zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jh=(e,t,n)=>Hh(e,t+"",n);const qh=e=>ee(rn(me(e))),Wh=(e,t)=>new U(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),h=s.blocks.get(u).number;for(;!a;){const f=s.blocks.get(u);if(!f)break;a=r.get(u=f.parent),h--}if(!a)return;const d=h<=s.blocks.get(s.finalized).number,l=a.found.type;if(l&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:l,hash:a.hash,number:h,index:a.found.index,events:a.found.events}:{found:l,validity:a.found.validity}),d&&(l?n.complete():a.found.validity?.success===!1&&n.error(new ss(a.found.validity.value)))},c=t.pipe(ye((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(ye((n,r)=>n===r)),Kh=(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 ss extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),jh(this,"error"),this.name="InvalidTxError",this.error=t}}const os=(e,t,n,r=!1)=>{const s=qh(n),o=(a,h)=>({type:a,txHash:s,...h}),i=e.pinnedBlocks$.pipe(Q(1),R(a=>{let h=[];return a.finalizedRuntime.runtime.pipe(S(d=>d.getMortalityFromTx(n)),Ae(()=>re({mortal:!1})),S(d=>{const{best:l,finalized:f}=a;let p=l;for(;p!==f;)h.push(p),p=a.blocks.get(p).parent;if(h.push(f),!d.mortal)return[f,l];const{phase:m,period:v}=d,y=a.blocks.get(l),b=y.number,g=Math.floor((b-m)/v)*v+m;let w=[a.blocks.get(a.finalized)];for(;w.length&&w[0].number<g;)w=w.flatMap(k=>[...k.children]).map(k=>a.blocks.get(k)).filter(Boolean);return(w.length?w:[y]).map(k=>k.hash)}),R(d=>un(...[...new Set(d)].map(l=>e.validateTx$(l,n).pipe(S(f=>({at:l,result:f})))))),jr(({result:d})=>!d.success,!0),Gl((d,l)=>[...d,l],[]),S(d=>{const l=new Map(d.filter(({result:f})=>!f.success).map(f=>[f.at,f.result]));if(l.size<d.length)return null;throw new ss(l.get(h.find(f=>l.has(f))??[...l.keys()][0]).value)}),Pe(Boolean))})),c=new U(a=>{const h=e.trackTx$(n).subscribe(a);return h.add(t(n).subscribe({error(d){a.error(d)}})),h}),u=Wh(c,e.pinnedBlocks$).pipe(S(a=>a.found?o("txBestBlocksState",{found:!0,block:{index:a.index,number:a.number,hash:a.hash},...Kh(a.events,a.index)}):o("txBestBlocksState",{found:!1,isValid:a.validity?.success!==!1})));return jn(r?re(o("signed",{})):vt,i,re(o("broadcasted",{})),u.pipe(Eh(({found:a,type:h,...d})=>a?re(o("finalized",d)):vt)))},pc=async(e,t,n,r)=>Tl(os(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Xh=kt().enc,Yh=new Uint8Array(64),Gh=new Uint8Array(65),Qh=e=>()=>e?Gh:Yh,[,Nh]=oe({weight:oe({ref_time:Cn,proof_size:Cn}),class:xe({Normal:_,Operational:_,Mandatory:_}),partial_fee:bs}),vc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(h=>{const d=(w,k,I={})=>{const T=rr(w).runtime(),{dynamicBuilder:x,assetId:P,lookup:M}=T;let J;try{J=x.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(w,T,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=I;if(I.asset){if(P==null||!_r(I.asset,Pn(M(P)),he=>u(T,he)))throw new Error("Incompatible runtime asset");q={...I,asset:x.buildDefinition(P).enc(I.asset)}}const{location:fe,codec:N}=J;return{callData:Le.fromBytes(se([new Uint8Array(fe),N.enc(k)])),options:q}},l=(w,k={})=>i(n,null).pipe(S(([I])=>d(I,w,k))),f=w=>w?d(w,h).callData:je(l(h).pipe(S(k=>k.callData))),p=(w,{...k},I)=>l(h,k).pipe(R(({callData:T,options:x})=>Vh(n,w,T.asBytes(),I,k.customSignedExtensions||{},x))),m=(w,{at:k,...I}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(S(T=>T.find(x=>x.hash===k)))).pipe(Q(1),R(T=>T?p(w,I,T).pipe(S(x=>({tx:ee(x),block:T}))):zn(()=>new Error(`Uknown block ${k}`)))),v=(w,k)=>je(m(w,k)).then(I=>I.tx),y=(w,k)=>je(m(w,k)).then(({tx:I,block:T})=>pc(n,r,I,T.hash)),b=(w,k)=>m(w,k).pipe(R(({tx:I})=>os(n,r,I,!0))),g=async(w,k)=>{typeof w=="string"&&(w=w.startsWith("0x")?me(w):Xh(w));const I=w.length===20,T=Oh(w,I?"Ecdsa":"Sr25519",Qh(I)),x=me(await v(T,k)),P=ee(se([x,De.enc(x.length)])),M=n.getRuntimeContext$(null).pipe(S(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Nh}})),J=n.call$(null,"TransactionPaymentApi_query_info",P);return je(Ht([J,M]).pipe(S(([q,fe])=>fe(q))))};return{getPaymentInfo:g,getEstimatedFees:async(w,k)=>(await g(w,k)).partial_fee,decodedCall:{type:e,value:$t(t,h)},getEncodedData:f,sign:v,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var Zh=Object.defineProperty,Jh=(e,t,n)=>t in e?Zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(Jh(e,typeof t!="symbol"?t+"":t,n),n),is=Symbol("SUSPENSE"),ed=class extends Promise{constructor(e){super(e)}},mc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},yc=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Be={},or=class extends U{constructor(e,t,n=ke){super(r=>{const s=new cn({next:r.next.bind(r),error:r.error.bind(r),complete:ke});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Be,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new mc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Be&&r.next(this.currentValue)):(this.subject=new He,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new cn({next:i=>{this.promise&&i!==is&&(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=Be;const a=(c=this.promise)==null?void 0:c.rej;a&&i===is&&(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 yc),this.promise=null),this.currentValue!==Be)return this.subject.complete();if(t===Be){const i=this.subject;return this.subject=null,i.error(new yc)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Be&&this.currentValue===Be&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Be),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof or?s:new or(s,Be)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Be&&this.currentValue!==is)return this.currentValue;if(this.defaultValue!==Be)return this.defaultValue;if(this.refCount===0)throw new mc;const r=new ed((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Be&&delete this.getDefaultValue}};function bc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function td(e,t){const n=new nd,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 or(e(...o),r(...o),()=>{n.delete(i)}),a=new U(d=>{const l=n.get(i);let f=u;return l?l!==a&&(f=l,bc(f,a)):n.set(i,h),f.subscribe(d)});bc(u,a);const h=a;return n.set(i,h),h};return(...o)=>s(o)}var nd=class{constructor(){Ze(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 rd(e,t){return new or(e,t)}var cs=(...e)=>(typeof e[0]=="function"?td:rd)(e[0],e.length>1?e[1]:Be);const gc=(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))}},wc=(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}},xc=(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)},sd=(e,t,n)=>{const r=cs((c,u,a)=>{const h=xc(c,u),d=(v,y)=>{const b=ph(e,y.hash).pipe(Pe(g=>!g),Q(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(R(g=>g===v?.rootHash?re({...v,block:y,deltas:null,prev:v.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),S(([w,k])=>[w,h(k)]),S(([w,k])=>({prev:v&&v.block.hash,rootHash:g,block:y,...gc(v?.entries??[],w,k)})))),Ti(b),Ae(g=>g instanceof Ne?vt:zn(()=>g)))},l=e.pipe(ye((v,y)=>v.finalized===y.finalized),Zr(({blocks:v,finalized:y})=>d(null,v.get(y))),Q(1),S(v=>({blocks:{[v.block.hash]:v},finalized:v.block.hash}))),[f,p]=kh(),m=e.pipe(ye((v,y)=>v.best===y.best),qr(f),Zr(([v,y])=>{const{best:b}=v,{blocks:g}=y;let w=g[b]?null:b;if(!w)return vt;const k=wc(w,g,v);return k?d(k,v.blocks.get(w)).pipe(S(I=>(g[w]=I,y))):(w=v.finalized,d(g[y.finalized],v.blocks.get(w)).pipe(S(I=>(I.prev=null,{blocks:{[w]:I},finalized:w}))))}));return un(l,m).pipe(p())}),s=c=>(u,a,h)=>{const d=r(u,a,h),l=xc(u,a),f=c?"finalized":"best";return Ht([d.pipe(ef(0)),e.pipe(ye((p,m)=>p[f]===m[f]))]).pipe(S(([p,m])=>wc(m[f],p.blocks,m,!0)),Pe(Boolean),ye(),Oi(null),of(),qr(d),n(([[,p]])=>p.block.hash),S(([[[p,m],v],y])=>[p,m,v,l(y)]),R(([p,m,v,y])=>{if(!p)return[m];let b=m;const g=[];for(;b&&b.block.number>p.block.number;)g.unshift(b),b=b.prev?v.blocks[b.prev]:null;if(c&&(v.finalized=m.block.hash,g.length)){const{blocks:w}=v;Object.keys(w).forEach(k=>{w[k].block.number<g[0].block.number&&delete w[k]})}return p===b?g:[{...m,...p.rootHash===m.rootHash?{entries:p.entries,deltas:null}:gc(p.entries,m.entries,y)}]}))},o=cs(s(!0)),i=cs(s(!1));return(c,u,a,h)=>{const d=h?i:o;return e.pipe(Q(1),R(l=>l.runtimes[l.blocks.get(l[h?"best":"finalized"]).runtime].runtime),S(l=>l.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(Q(1),R(l=>d(c,u,l)),S(({block:{hash:l,number:f,parent:p},deltas:m,entries:v},y)=>{const b=y>0?m:{deleted:[],upserted:v};return{block:{hash:l,number:f,parent:p},entries:v.map(as),deltas:b&&{deleted:b.deleted.map(as),upserted:b.upserted.map(as)}}}))}},as=e=>e.dec,Ec="RuntimeViewFunction",kc="execute_view_function",us=Ec+"_"+kc,od=(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 h=a[a.length-1],d=Wt(h),{signal:l,at:f}=d?h:{},p=f??null,m=o(n,p).pipe(R(([v,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Ec,kc)}catch{throw new Error(`Runtime entry RuntimeCall(${us}) not found`)}let g;try{g=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(v,y,a))throw u();const w=g.args.enc(a),k=se([me(y.lookup.metadata.pallets.find(({name:I})=>I===e).viewFns.find(({name:I})=>I===t).id),B.enc(w.length),w]);return n.call$(p,us,ee(k)).pipe(S(I=>{try{const T=b.value.dec(I);if(!("success"in T&&"value"in T)||!("type"in T.value)&&!("asBytes"in T.value))throw null;return T}catch{throw new Error(`Unexpected RuntimeCall(${us}) type`)}}),S(({success:I,value:T})=>{if(!I)throw new Error(`ViewFn API Error: ${T.type}`);const x=g.value.dec(T.asBytes());if(!c(v,y,x))throw u();return x}))}),n.withHodl(p));return vn(m,l)},{getCompatibilityLevel:s,isCompatible:r})},id=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Ac=(e,t,n)=>{const r={},s=v=>new Proxy(r,{get(y,b){return v(b)}}),o=v=>{const y={};return s(b=>(y[b]||(y[b]={}),s(g=>(y[b][g]||(y[b][g]=v(b,g)),y[b][g]))))},i=(v,y)=>v.lookup.metadata.pallets.find(b=>b.name===y),c=sd(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((v,y)=>$h(v,y,t,c,Rt(e,b=>b.getEntryPoint(gt.Storage,v,y),b=>{const g=i(b,v)?.storage?.items.find(w=>w.name===y);return g==null?null:Qu(g)}))),a=(v,y,b,g)=>{if(b==null)return null;const w=v.lookup(b);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const k=Nu(w.value[g]);return{args:y==="args"?k:Mn,values:y==="args"?Mn:k}},h=o((v,y)=>vc(v,y,t,n,Rt(e,b=>b.getEntryPoint(gt.Tx,v,y),b=>a(b,"args",i(b,v)?.calls?.type,y)),!0)),d=o((v,y)=>Ah(v,y,t,Rt(e,b=>b.getEntryPoint(gt.Event,v,y),b=>a(b,"values",i(b,v)?.events?.type,y)))),l=o((v,y)=>wh(v,y,Rt(e,b=>b.getEntryPoint(gt.Const,v,y),b=>{const g=i(b,v)?.constants.find(w=>w.name===y)?.type;return g==null?null:Zu(g)}))),f=o((v,y)=>Sh(v,y,t,Rt(e,b=>b.getEntryPoint(gt.Api,v,y),b=>No(b.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===y))))),p=o((v,y)=>od(v,y,t,Rt(e,b=>b.getEntryPoint(gt.ViewFns,v,y),b=>No(b.lookup.metadata.pallets.find(g=>g.name===v).viewFns.find(g=>g.name===y))))),m=(v,y)=>{const{lookup:b,dynamicBuilder:g}=rr(y).runtime();try{const w=g.buildDefinition(b.call).dec(v.asBytes()),k=w.type,I=w.value.type,T=w.value.value;return vc(k,I,t,n,Rt(e,x=>x.getEntryPoint(gt.Tx,k,I),x=>a(x,"args",i(x,k)?.calls?.type,I)),!1)(T)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,y)=>y?m(v,y):e.then(b=>m(v,b)),tx:h,event:d,apis:f,constants:l,view:p}};function cd(e,{getMetadata:t,setMetadata:n}={}){const r=If(e),s=dh(r,{getMetadata:t?v=>yt(t(v)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),u=s.archive(c.getRuntime$),a={...c,genesis$:qn(o).pipe(S(({genesisHash:v})=>v),Ae(()=>i),hn(1)),storage$:Ot(c.storage$,u.storage$),body$:Ot(c.body$,u.body$),call$:Ot(c.call$,u.call$),header$:Ot(c.header$,u.header$),eventsAt$:Ot(c.eventsAt$,u.eventsAt$),storageQueries$:Ot(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Ot(c.getRuntimeContext$,u.getRuntimeContext$)},h=r.request;let d;const l=new WeakMap,f=v=>{const y=l.get(v)||bh(v,a);return l.set(v,y),y},p=()=>d??(d=gh(a)),{broadcastTx$:m}=s;return{getChainSpecData:o,blocks$:a.newBlocks$,finalizedBlock$:a.finalized$,getFinalizedBlock:()=>je(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>je(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:v=>je(a.body$(v)),getBlockHeader:v=>je(a.header$(v??null)),submit:(...v)=>pc(a,m,...v),submitAndWatch:v=>os(a,m,v),getTypedApi:v=>{const y=f(v);return Object.assign(Ac(y,a,m),{compatibilityToken:y})},getUnsafeApi:()=>{const v=p();return Object.assign(Ac(v,a,m),{runtimeToken:v})},rawQuery:(v,{at:y,signal:b}={})=>vn(a.storage$(y??null,"value",()=>{const g=v.match(id)?.[1];return g?`0x${g}`:Le.fromText(v).asHex()}),b),destroy:()=>{a.unfollow(),s.destroy()},_request:h}}const ad=(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 h=Le.fromBytes(se([u,c.enc(a)]));return{encodedData:h,decodedCall:$t(e,$t(t,a)),sign:async(d,l)=>ee(await d.signTx(h.asBytes(),s(l),n,l.mortality.mortal?l.mortality.startAtBlock.height:0))}}},ud=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=me(e),r=await t(),s=Dt(dt.dec(r)),o=er(s),i=Kr(o),c=hc(n,o,i),u=p=>s.pallets.find(m=>m.name===p),a={},h=p=>new Proxy(a,{get(m,v){return p(v)}}),d=p=>{const m={};return h(v=>(m[v]||(m[v]={}),h(y=>(m[v][y]||(m[v][y]=p(v,y)),m[v][y]))))},l=d((p,m)=>{const v=u(p)?.constants.find(y=>y.name===m);if(!v)throw new Error(`Runtime entry Constant(${p}.${m}) not found`);return i.buildConstant(p,m).dec(v.value)}),f=d((p,m)=>ad(p,m,r,i,c));return{constants:l,tx:f}},Kt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ld=async e=>{const t=Dt(Ar(await e.getMetadata())),n={},r=l=>new Proxy(n,{get(f,p){return l(p)}}),s=l=>{const f={};return r(p=>(f[p]||(f[p]={}),r(m=>(f[p][m]||(f[p][m]=l(p,m)),f[p][m]))))},o=er(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:h,buildViewFn:d}=Kr(o);return{query:s((...l)=>{const{value:f,args:p}=Kt(c,"Storage")(...l);return{value:f,args:p}}),tx:s((...l)=>Kt(a,"Call")(...l).codec),event:s((...l)=>Kt(h,"Event")(...l).codec),apis:s(Kt(i,"Runtime API")),constants:s(Kt(u,"Constant")),view:s(Kt(d,"ViewFn"))}};ae.AccountId=kt,ae.Binary=Le,ae.BlockNotPinnedError=Ne,ae.CompatibilityLevel=Oe,ae.Enum=$t,ae.FixedSizeBinary=Bn,ae.InvalidTxError=ss,ae._Enum=uo,ae.createClient=cd,ae.getOfflineApi=ud,ae.getSs58AddressInfo=hr,ae.getTypedCodecs=ld});
3
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function Dn(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=Vt(i),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(m){t={error:m}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}else i.remove(this);var f=this.initialTeardown;if(W(f))try{f()}catch(m){o=m instanceof Mr?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var l=Vt(d),h=l.next();!h.done;h=l.next()){var p=h.value;try{ni(p)}catch(m){o=o??[],m instanceof Mr?o=Re(Re([],Te(o)),Te(m.errors)):o.push(m)}}}catch(m){r={error:m}}finally{try{h&&!h.done&&(s=l.return)&&s.call(l)}finally{if(r)throw r.error}}}if(o)throw new Mr(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ni(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&Dn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Dn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),ei=Ct.EMPTY;function ti(e){return e instanceof Ct||e&&"closed"in e&&W(e.remove)&&W(e.add)&&W(e.unsubscribe)}function ni(e){W(e)?e():e.unsubscribe()}var rl={Promise:void 0},sl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Re([e,t],Te(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ri(e){sl.setTimeout(function(){throw e})}function ke(){}function Ln(e){e()}var cn=function(e){Ge(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ti(n)&&n.add(r)):r.destination=cl,r}return t.create=function(n,r,s){return new Ht(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),ol=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){Vn(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Vn(r)}else Vn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Vn(n)}},e}(),Ht=function(e){Ge(t,e);function t(n,r,s){var o=e.call(this)||this,i;return W(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,o.destination=new ol(i),o}return t}(cn);function Vn(e){ri(e)}function il(e){throw e}var cl={closed:!0,next:ke,error:il,complete:ke},Dr=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Qe(e){return e}function si(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return oi(e)}function oi(e){return e.length===0?Qe:e.length===1?e[0]:function(n){return e.reduce(function(r,s){return s(r)},n)}}var U=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=ul(t)?t:new Ht(t,n,r);return Ln(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=ii(n),new n(function(s,o){var i=new Ht({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[Dr]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return oi(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ii(t),new t(function(r,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 ii(e){var t;return(t=e??rl.Promise)!==null&&t!==void 0?t:Promise}function al(e){return e&&W(e.next)&&W(e.error)&&W(e.complete)}function ul(e){return e&&e instanceof cn||al(e)&&ti(e)}function ll(e){return W(e?.lift)}function G(e){return function(t){if(ll(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 K(e,t,n,r,s){return new fl(e,t,n,r,s)}var fl=function(e){Ge(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(f){n.error(f)}}:e.prototype._next,u._error=o?function(a){try{o(a)}catch(f){n.error(f)}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}(cn),hl=Ur(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ze=function(e){Ge(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new ci(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new hl},t.prototype.next=function(n){var r=this;Ln(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Vt(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;Ln(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;Ln(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?ei:(this.currentObservers=null,c.push(n),new Ct(function(){r.currentObservers=null,Dn(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 U;return n.source=this,n},t.create=function(n,r){return new ci(n,r)},t}(U),ci=function(e){Ge(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:ei},t}(ze),dl=function(e){Ge(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}(ze),Lr={now:function(){return(Lr.delegate||Date).now()},delegate:void 0},Fn=function(e){Ge(t,e);function t(n,r,s){n===void 0&&(n=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Lr);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,f=1;f<o.length&&o[f]<=u;f+=2)a=f;a&&o.splice(0,a+1)}},t}(ze),pl=function(e){Ge(t,e);function t(n,r){return e.call(this)||this}return t.prototype.schedule=function(n,r){return this},t}(Ct),ai={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Re([e,t],Te(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},vl=function(e){Ge(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),ai.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&&ai.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,Dn(o,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(pl),ui=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},e.now=Lr.now,e}(),ml=function(e){Ge(t,e);function t(n,r){r===void 0&&(r=ui.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}(ui),li=new ml(vl),yl=li,vt=new U(function(e){return e.complete()});function fi(e){return e&&W(e.schedule)}function Vr(e){return e[e.length-1]}function Fr(e){return W(Vr(e))?e.pop():void 0}function an(e){return fi(Vr(e))?e.pop():void 0}function bl(e,t){return typeof Vr(e)=="number"?e.pop():t}var hi=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function di(e){return W(e?.then)}function pi(e){return W(e[Dr])}function vi(e){return Symbol.asyncIterator&&W(e?.[Symbol.asyncIterator])}function mi(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 gl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var yi=gl();function bi(e){return W(e?.[yi])}function gi(e){return tl(this,arguments,function(){var n,r,s,o;return Jo(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,Ft(n.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Ft(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ft(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 wi(e){return W(e?.getReader)}function le(e){if(e instanceof U)return e;if(e!=null){if(pi(e))return wl(e);if(hi(e))return xl(e);if(di(e))return El(e);if(vi(e))return xi(e);if(bi(e))return kl(e);if(wi(e))return Al(e)}throw mi(e)}function wl(e){return new U(function(t){var n=e[Dr]();if(W(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function xl(e){return new U(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function El(e){return new U(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,ri)})}function kl(e){return new U(function(t){var n,r;try{for(var s=Vt(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 xi(e){return new U(function(t){Sl(e,t).catch(function(n){return t.error(n)})})}function Al(e){return xi(gi(e))}function Sl(e,t){var n,r,s,o;return el(this,void 0,void 0,function(){var i,c;return Jo(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=nl(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 mt(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 Ei(e,t){return t===void 0&&(t=0),G(function(n,r){n.subscribe(K(r,function(s){return mt(r,e,function(){return r.next(s)},t)},function(){return mt(r,e,function(){return r.complete()},t)},function(s){return mt(r,e,function(){return r.error(s)},t)}))})}function ki(e,t){return t===void 0&&(t=0),G(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function $l(e,t){return le(e).pipe(ki(t),Ei(t))}function Il(e,t){return le(e).pipe(ki(t),Ei(t))}function Bl(e,t){return new U(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Cl(e,t){return new U(function(n){var r;return mt(n,t,function(){r=e[yi](),mt(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 W(r?.return)&&r.return()}})}function Ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new U(function(n){mt(n,t,function(){var r=e[Symbol.asyncIterator]();mt(n,t,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function _l(e,t){return Ai(gi(e),t)}function Ol(e,t){if(e!=null){if(pi(e))return $l(e,t);if(hi(e))return Bl(e,t);if(di(e))return Il(e,t);if(vi(e))return Ai(e,t);if(bi(e))return Cl(e,t);if(wi(e))return _l(e,t)}throw mi(e)}function yt(e,t){return t?Ol(e,t):le(e)}function re(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return yt(e,n)}function Hn(e,t){var n=W(e)?e:function(){return e},r=function(s){return s.error(n())};return new U(r)}var Si=Ur(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Tl(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 Si)}})})}function je(e,t){return new Promise(function(n,r){var s=new Ht({next:function(o){n(o),s.unsubscribe()},error:r,complete:function(){r(new Si)}});e.subscribe(s)})}function Rl(e){return e instanceof Date&&!isNaN(e)}function S(e,t){return G(function(n,r){var s=0;n.subscribe(K(r,function(o){r.next(e.call(t,o,s++))}))})}var Pl=Array.isArray;function Ul(e,t){return Pl(t)?e.apply(void 0,Re([],Te(t))):e(t)}function $i(e){return S(function(t){return Ul(e,t)})}var Ml=Array.isArray,Dl=Object.getPrototypeOf,Ll=Object.prototype,Vl=Object.keys;function Fl(e){if(e.length===1){var t=e[0];if(Ml(t))return{args:t,keys:null};if(Hl(t)){var n=Vl(t);return{args:n.map(function(r){return t[r]}),keys:n}}}return{args:e,keys:null}}function Hl(e){return e&&typeof e=="object"&&Dl(e)===Ll}function zl(e,t){return e.reduce(function(n,r,s){return n[r]=t[s],n},{})}function zt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=Fr(e),s=Fl(e),o=s.args,i=s.keys;if(o.length===0)return yt([],n);var c=new U(Ii(o,n,i?function(u){return zl(i,u)}:Qe));return r?c.pipe($i(r)):c}function Ii(e,t,n){return n===void 0&&(n=Qe),function(r){Bi(t,function(){for(var s=e.length,o=new Array(s),i=s,c=s,u=function(f){Bi(t,function(){var d=yt(e[f],t),l=!1;d.subscribe(K(r,function(h){o[f]=h,l||(l=!0,c--),c||r.next(n(o.slice()))},function(){--i||r.complete()}))},r)},a=0;a<s;a++)u(a)},r)}}function Bi(e,t,n){e?mt(n,e,t):t()}function jl(e,t,n,r,s,o,i,c){var u=[],a=0,f=0,d=!1,l=function(){d&&!u.length&&!a&&t.complete()},h=function(m){return a<r?p(m):u.push(m)},p=function(m){a++;var v=!1;le(n(m,f++)).subscribe(K(t,function(y){t.next(y)},function(){v=!0},void 0,function(){if(v)try{a--;for(var y=function(){var b=u.shift();i||p(b)};u.length&&a<r;)y();l()}catch(b){t.error(b)}}))};return e.subscribe(K(t,h,function(){d=!0,l()})),function(){}}function R(e,t,n){return n===void 0&&(n=1/0),W(t)?R(function(r,s){return S(function(o,i){return t(r,o,s,i)})(le(e(r,s)))},n):(typeof t=="number"&&(n=t),G(function(r,s){return jl(r,s,e,n)}))}function zn(e){return e===void 0&&(e=1/0),R(Qe,e)}function ql(){return zn(1)}function jn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ql()(yt(e,an(e)))}function qn(e){return new U(function(t){le(e()).subscribe(t)})}var Wl={connector:function(){return new ze},resetOnDisconnect:!0};function Kl(e,t){t===void 0&&(t=Wl);var n=null,r=t.connector,s=t.resetOnDisconnect,o=s===void 0?!0:s,i=r(),c=new U(function(u){return i.subscribe(u)});return c.connect=function(){return(!n||n.closed)&&(n=qn(function(){return e}).subscribe(i),o&&n.add(function(){return i=r()})),n},c}function Wn(e,t,n){e===void 0&&(e=0),n===void 0&&(n=yl);var r=-1;return t!=null&&(fi(t)?n=t:r=t),new U(function(s){var o=Rl(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 un(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e),r=bl(e,1/0),s=e;return s.length?s.length===1?le(s[0]):zn(r)(yt(s,n)):vt}var Xl=Array.isArray;function Yl(e){return e.length===1&&Xl(e[0])?e[0]:e}function Pe(e,t){return G(function(n,r){var s=0;n.subscribe(K(r,function(o){return e.call(t,o,s++)&&r.next(o)}))})}function Ae(e){return G(function(t,n){var r=null,s=!1,o;r=t.subscribe(K(n,void 0,void 0,function(i){o=le(e(i,Ae(e)(t))),r?(r.unsubscribe(),r=null,o.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Ci(e,t,n,r,s){return function(o,i){var c=n,u=t,a=0;o.subscribe(K(i,function(f){var d=a++;u=c?e(u,f,d):(c=!0,f),r&&i.next(u)},s&&function(){c&&i.next(u),i.complete()}))}}function Gl(e,t){return G(Ci(e,t,arguments.length>=2,!1,!0))}function _i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Fr(e);return n?si(_i.apply(void 0,Re([],Te(e))),$i(n)):G(function(r,s){Ii(Re([r],Te(Yl(e))))(s)})}function Ql(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _i.apply(void 0,Re([],Te(e)))}function Nl(e,t){return W(t)?R(e,t,1):R(e,1)}function Q(e){return e<=0?function(){return vt}:G(function(t,n){var r=0;t.subscribe(K(n,function(s){++r<=e&&(n.next(s),e<=r&&n.complete())}))})}function Zl(e){return S(function(){return e})}function Jl(e,t){return R(function(n,r){return le(e(n,r)).pipe(Q(1),Zl(n))})}function ef(e,t){t===void 0&&(t=li);var n=Wn(e,t);return Jl(function(){return n})}function tf(e,t){return G(function(n,r){var s=new Set;n.subscribe(K(r,function(o){var i=e?e(o):o;s.has(i)||(s.add(i),r.next(o))})),t&&le(t).subscribe(K(r,function(){return s.clear()},ke))})}function ye(e,t){return t===void 0&&(t=Qe),e=e??nf,G(function(n,r){var s,o=!0;n.subscribe(K(r,function(i){var c=t(i);(o||!e(s,c))&&(o=!1,s=c,r.next(i))}))})}function nf(e,t){return e===t}function rf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(n){return jn(n,re.apply(void 0,Re([],Te(e))))}}function sf(e,t){return G(function(n,r){var s=0,o=null,i=!1;n.subscribe(K(r,function(c){o||(o=K(r,void 0,function(){o=null,i&&r.complete()}),le(e(c,s++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function of(){return G(function(e,t){var n,r=!1;e.subscribe(K(t,function(s){var o=n;n=s,r&&t.next([o,s]),r=!0}))})}function ln(e,t){return G(Ci(e,t,arguments.length>=2,!0))}function fn(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new ze}: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 f,d,l,h=0,p=!1,m=!1,v=function(){d?.unsubscribe(),d=void 0},y=function(){v(),f=l=void 0,p=m=!1},b=function(){var g=f;y(),g?.unsubscribe()};return G(function(g,w){h++,!m&&!p&&v();var k=l=l??n();w.add(function(){h--,h===0&&!m&&!p&&(d=Hr(b,u))}),k.subscribe(w),!f&&h>0&&(f=new Ht({next:function(I){return k.next(I)},error:function(I){m=!0,v(),d=Hr(y,s,I),k.error(I)},complete:function(){p=!0,v(),d=Hr(y,i),k.complete()}}),le(g).subscribe(f))})(a)}}function Hr(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 Ht({next:function(){s.unsubscribe(),e()}});return le(t.apply(void 0,Re([],Te(n)))).subscribe(s)}}function hn(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,fn({connector:function(){return new Fn(i,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}function Oi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=an(e);return G(function(r,s){(n?jn(e,r,n):jn(e,r)).subscribe(s)})}function Kn(e,t){return G(function(n,r){var s=null,o=0,i=!1,c=function(){return i&&!s&&r.complete()};n.subscribe(K(r,function(u){s?.unsubscribe();var a=0,f=o++;le(e(u,f)).subscribe(s=K(r,function(d){return r.next(t?t(u,d,f,a++):d)},function(){s=null,c()}))},function(){i=!0,c()}))})}function cf(){return Kn(Qe)}function Ti(e){return G(function(t,n){le(e).subscribe(K(n,function(){return n.complete()},ke)),!n.closed&&t.subscribe(n)})}function zr(e,t){return t===void 0&&(t=!1),G(function(n,r){var s=0;n.subscribe(K(r,function(o){var i=e(o,s++);(i||t)&&r.next(o),!i&&r.complete()}))})}function Xn(e,t,n){var r=W(e)||t||n?{next:e,error:t,complete:n}:e;return r?G(function(s,o){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var c=!0;s.subscribe(K(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)}))}):Qe}function jr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Fr(e);return G(function(r,s){for(var o=e.length,i=new Array(o),c=e.map(function(){return!1}),u=!1,a=function(d){le(e[d]).subscribe(K(s,function(l){i[d]=l,!u&&!c[d]&&(c[d]=!0,(u=c.every(Qe))&&(c=null))},ke))},f=0;f<o;f++)a(f);r.subscribe(K(s,function(d){if(u){var l=Re([d],Te(i));s.next(n?n.apply(void 0,Re([],Te(l))):l)}}))})}var af=Object.defineProperty,uf=(e,t,n)=>t in e?af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ri=(e,t,n)=>uf(e,typeof t!="symbol"?t+"":t,n);class Pi extends Error{constructor(t){super(t.message),Ri(this,"code"),Ri(this,"data"),this.code=t.code,this.data=t.data,this.name="RpcError"}}const Ui=()=>{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)})}}};class qr extends Error{constructor(){super("Client destroyed"),this.name="DestroyedError"}}let lf=1;const ff=e=>{let t=lf++;const n=new Map,r=Ui();let s=null;const o=(f,d,l)=>{s.send(JSON.stringify({jsonrpc:"2.0",id:f,method:d,params:l}))};function i(f){try{let d,l,h,p,m;if({id:d,result:l,error:h,params:p}=JSON.parse(f),d===null)throw new Error(p?.error?.message??"id null");if(d!=null){const b=n.get(d);return b?(n.delete(d),h?b.onError(new Pi(h)):b.onSuccess(l,(g,w)=>{const k=g;return r.subscribe(k,w),()=>{r.unsubscribe(k)}})):void 0}if({subscription:m,result:l,error:h}=p,!m||!h&&!Object.hasOwn(p,"result"))throw 0;const y=m;h?r.error(y,new Pi(h)):r.next(y,l)}catch(d){console.warn("Error parsing incomming message: "+f),console.error(d)}}s=e(i);const c=()=>{s?.disconnect(),s=null,r.errorAll(new qr),n.forEach(f=>f.onError(new qr)),n.clear()};let u=1;return{request:(f,d,l)=>{if(!s)throw new Error("Not connected");const h=`${t}-${u++}`;return l&&n.set(h,l),o(h,f,d),()=>{n.delete(h)}},disconnect:c}};class Mi extends Error{constructor(){super("ChainHead stopped"),this.name="StopError"}}class Yn extends Error{constructor(){super("ChainHead disjointed"),this.name="DisjointError"}}class Gn extends Error{constructor(){super("ChainHead operations limit reached"),this.name="OperationLimitError"}}class Di extends Error{constructor(t){super(t),this.name="OperationError"}}class Qn extends Error{constructor(){super("ChainHead operation inaccessible"),this.name="OperationInaccessibleError"}}const Ue={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:"",followEvent:""},Nn={chainName:"",genesisHash:"",properties:""},Wr={broadcast:"",stop:""};Object.entries({chainHead:Ue,chainSpec:Nn,transaction:Wr}).forEach(([e,t])=>{Object.keys(t).forEach(n=>{t[n]=`${e}_v1_${n}`})});class Li extends Error{constructor(t){super(`Invalid BlockHash: ${t}`),this.name="BlockHashNotFoundError"}}class hf extends Error{constructor(t){super(`Storage Error: ${t}`),this.name="StorageError"}}class df extends Error{constructor(t){super(`Call Error: ${t}`),this.name="CallError"}}const jt=()=>{},pf=e=>(t,n)=>{let r=e(Wr.broadcast,[t],{onSuccess:s=>{r=s===null?jt:()=>{e(Wr.stop,[s])},s===null&&n(new Error("Max # of broadcasted transactions has been reached"))},onError:n});return()=>{r()}};function vf(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),res:e,rej:t}}const qt=e=>(...t)=>new Promise((n,r)=>{let s=At;const[o,i]=t[t.length-1]instanceof AbortSignal?[t.slice(0,t.length-1),t[t.length-1]]:[t],c=()=>{s(),r(new eo)};i?.addEventListener("abort",c,{once:!0});const u=a=>f=>{s=At,i?.removeEventListener("abort",c),a(f)};s=e(u(n),u(r),...o)}),Vi=(e,t)=>n=>qt((r,s,...o)=>{let i=!0,c=()=>{i=!1};const[u,a]=t(...o);return n(e,u,{onSuccess:(f,d)=>{if(f.result==="limitReached")return s(new Gn);const{operationId:l}=f,h=()=>{n(Ue.stopOperation,[l])};if(!i)return h();let p=jt;const m=y=>{i=!1,p(),r(y)},v=y=>{i=!1,p(),s(y)};p=d(l,{next:y=>{const b=y;b.event==="operationError"?s(new Di(b.error)):b.event==="operationInaccessible"?s(new Qn):a(y,m,v)},error:v}),c=()=>{i&&(p(),h())}},onError:s}),()=>{c()}}),mf=Vi(Ue.body,e=>[[e],(t,n)=>{n(t.value)}]),yf=Vi(Ue.call,(e,t,n)=>[[e,t,n],(r,s)=>{s(r.output)}]),bf=e=>t=>new Promise((n,r)=>{e(Ue.header,[t],{onSuccess:n,onError:r})}),Fi=e=>(t,n,r,s,o,i,c)=>{if(n.length===0)return i(),At;let u=!0,a=()=>{u=!1};return e(Ue.storage,[t,n,r],{onSuccess:(f,d)=>{if(f.result==="limitReached"||f.discardedItems===n.length)return o(new Gn);const{operationId:l}=f,h=()=>{e(Ue.stopOperation,[l])};if(!u)return h();const p=d(f.operationId,{next:y=>{switch(y.event){case"operationStorageItems":{s(y.items);break}case"operationStorageDone":{v();break}case"operationError":{m(new Di(y.error));break}case"operationInaccessible":{m(new Qn);break}default:e(Ue.continue,[y.operationId])}},error:o});a=()=>{p(),e(Ue.stopOperation,[f.operationId])};const m=y=>{a=At,p(),o(y)},v=()=>{a=At,p(),i()};c(f.discardedItems)},onError:o}),()=>{a()}},gf=e=>{const t=Fi(e);return qt((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?l=>{a.push(l)}:l=>{a=l[0]?.[o]},r,()=>{try{n(u?a.flat():a)}catch(l){r(l)}},l=>{l>0&&(d(),r(new Gn))});return d})},wf=e=>t=>t.length>0?new Promise((n,r)=>{e(Ue.unpin,[t],{onSuccess(){n()},onError:r})}):Promise.resolve();function xf(e){return e.operationId!==void 0}function Ef(e){return(t,n,r)=>{const s=Ui(),o=new Set,i=vf();let c=i.promise,u=jt;const a=p=>{e(Ue.unfollow,[p])},f=p=>{u(),c!==null&&(p&&(c instanceof Promise?c.then(m=>{typeof m=="string"&&a(m)}):a(c)),c=null,o.forEach(m=>{m()}),o.clear(),s.errorAll(new Yn))},d=p=>{if(xf(p))return s.has(p.operationId)||console.warn("Uknown operationId on",p),s.next(p.operationId,p);switch(p.event){case"stop":return r(new Mi),f(!1);case"initialized":case"newBlock":case"bestBlockChanged":case"finalized":const{event:m,...v}=p;return n({type:m,...v})}console.warn("Invalid event",p)},l=p=>{r(p),f(!(p instanceof qr))};e(Ue.follow,[t],{onSuccess:(p,m)=>{c instanceof Promise&&(c=p,u=m(p,{next:d,error:l})),i.res(p)},onError:p=>{c=null,i.res(p),r(p)}});const h=(p,m,v)=>{const y=()=>{v?.onError(new Yn)};if(c===null)return y(),jt;const b=w=>{if(!v)return e(p,[w,...m]);o.add(y);const k=(T,x)=>c===null?(x.error(new Yn),jt):(s.subscribe(T,x),()=>{s.unsubscribe(T)}),I=e(p,[w,...m],{onSuccess:T=>{o.delete(y),v.onSuccess(T,k)},onError:T=>{o.delete(y),v.onError(T)}});return()=>{o.delete(y),I()}};if(typeof c=="string")return b(c);let g=jt;return c.then(w=>{if(w instanceof Error)return y();c&&(g=b(w))}),()=>{g()}};return{unfollow(){f(!0)},body:mf(h),call:yf(h),header:bf(h),storage:gf(h),storageSubscription:Fi(h),unpin:wf(h),_request:h}}}const kf=e=>{const t=qt((r,s,o,i)=>e(o,i,{onSuccess:r,onError:s}));let n=null;return async()=>n||(n=Promise.all([t(Nn.chainName,[]),t(Nn.genesisHash,[]),t(Nn.properties,[])]).then(([r,s,o])=>({name:r,genesisHash:s,properties:o})))},Af=e=>(t,n,r,s,o,i)=>{if(n.length===0)return i(),At;let c=!0,u=()=>{c=!1};return e("storage",[t,n,r],{onSuccess:(a,f)=>{const d=()=>{e("stopStorage",[a])};if(!c)return d();const l=f(a,{next:v=>{const{event:y}=v;if(y==="storage"){const{event:b,...g}=v;s(g)}else y==="storageDone"?m():p(new hf(v.error))},error:o}),h=()=>{u=At,l()};u=()=>{h(),d()};const p=v=>{h(),o(v)},m=()=>{h(),i()}},onError:o}),()=>{u()}},Sf=e=>qt((t,n,r,s,o,i)=>{const c=s.startsWith("descendants");let u=c?[]:null;const a=c?u.push.bind(u):({[s]:f})=>{u=f};return e(r,[{key:o,type:s}],i,a,f=>{n(f),u=null},()=>{t(u),u=null})}),Hi=()=>e=>e,zi=()=>(e,t)=>{if(e===null)throw new Li(t);return e},$f=e=>{const t=(f,...d)=>e(`archive_v1_${f}`,...d),n=f=>d=>qt((l,h,...p)=>t(f,p,{onSuccess:m=>{try{l(d(m,...p))}catch(v){h(v)}},onError:h})),r=n("header")(zi()),s=n("body")(zi()),o=Af(t),i=Sf(o),c=n("call")((f,d)=>{if(!f)throw new Li(d);if(!f.success)throw new df(f.error);return f.value}),u=n("finalizedHeight")(Hi()),a=n("hashByHeight")(Hi());return{header:r,body:s,storageSubscription:o,storage:i,call:c,finalizedHeight:u,hashByHeight:a}},Zn=new Map,If=e=>{const t=Zn.get(e);if(t)return t.refCount++,t.client;const{request:n,disconnect:r}=ff(e),s=()=>{const i=Zn.get(e);!i||i.refCount<=1?(Zn.delete(e),r()):i.refCount--},o={archive:$f(n),chainHead:Ef(n),transaction:pf(n),getChainSpecData:kf(n),destroy:s,request:qt((i,c,u,a)=>n(u,a,{onSuccess:i,onError:c})),_request:n};return Zn.set(e,{client:o,refCount:1}),o};var Bf=Object.defineProperty,Cf=(e,t,n)=>t in e?Bf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ji=(e,t,n)=>Cf(e,typeof t!="symbol"?t+"":t,n);class _f{constructor(){ji(this,"first"),ji(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 Of=()=>{const e=new Map,t=(l,h)=>{e.set(l,()=>{e.delete(l),h()})},n=l=>{e.get(l)?.()},r=new _f,s=r.unshift.bind(r),o=r.push.bind(r),i=(l,h)=>{const p=h?s:o;t(l.source$,p(l))},c=()=>{const l=r.pop();l&&(e.delete(l.source$),u(l))},u=l=>{const{source$:h,observer:p}=l;let m=!1;const v=h.subscribe({next(y){p.next(y)},error(y){(m=y instanceof Gn)?i(l,!0):p.error(y)},complete(){p.complete()}});v.closed?m||c():t(h,()=>{v.unsubscribe(),c()})},a=(l=!1)=>h=>new U(p=>{const m={observer:p,source$:h};return r.isEmpty()?u(m):i(m,l),()=>{n(h)}}),f=a();return{withRecovery:a,withRecoveryFn:l=>(...h)=>f(l(...h))}};class Ne extends Error{constructor(t,n){super(`Block ${t} is not pinned (${n})`),this.name="BlockNotPinnedError"}}const Tf=new Set(["best","finalized",null]),qi=e=>{const t=e.pipe(Ae(n=>n instanceof Qn?Wn(750).pipe(Nl(()=>t)):Hn(()=>n)));return t},Rf=(e,t,n)=>r=>(s,...o)=>{if(!Tf.has(s))return qi(r(s,...o)).pipe(n(s));const c=(s==="best"?t:e).pipe(Q(1),R(u=>r(u,...o).pipe(n(u))),Ae(u=>u instanceof Ne?c:Hn(()=>u)));return qi(c)},_t=e=>(...t)=>new U(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}}),Pf=e=>t=>(...n)=>e()[t](...n);function dn(e,t,n){return(r,...s)=>{const o=t(r,...s);return new U(i=>{let c=null,u=!1;const a=()=>{u||(u=!0,c=o.subscribe({next:l=>i.next(l),error:l=>i.error(l),complete:()=>i.complete()}),c.add(()=>{u=!1,c=null}))};let f=!1;const d=e.subscribe({next:l=>{const h=l.blocks.get(r);h?h.recovering?c?.unsubscribe():a():f&&i.error(new Ne(r,n)),f=l.recovering},error:l=>i.error(l)});return()=>{d.unsubscribe(),c?.unsubscribe()}})}}const Uf=e=>e.pipe(ln(({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)}),R(({newBlocks:t})=>t),fn()),Mf=(e,t)=>{const n=(r,s,o,i)=>new U(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(zn(),t(i));return n},Df=e=>{const t=async(n,r,s)=>{const o=n[r.idx],i=n[s.idx];if(n.length===2)return[o,i];const c=r.idx+Math.floor((s.idx-r.idx)/2),u={idx:c,id:await e(n[c])};if(u.id===r.id)return t(n,u,s);if(u.id===s.id)return t(n,r,u);const[a,[f,...d]]=await Promise.all([t(n,r,u),t(n,u,s)]);return[...a,...d]};return async n=>{if(n.length<2)return n;const r=n.length-1,[s]=n,o=n[r],[i,c]=await Promise.all([s,o].map(e));return i===c?[n[0]]:t(n,{idx:0,id:i},{idx:r,id:c})}},Lf=(e,t)=>{const n=Df(t);return r=>new U(s=>{let o=null;return r.subscribe({next(i){i.type==="initialized"?(o=[],Promise.all([e(i.finalizedBlockHashes[0]),n(i.finalizedBlockHashes)]).then(([c,u])=>{s.closed||(s.next({type:"initialized",finalizedBlockHashes:i.finalizedBlockHashes,runtimeChanges:new Set(u),number:c.number,parentHash:c.parentHash}),o.forEach(a=>{s.next(a)}),o=null)}).catch(c=>{s.closed||s.error(c)})):o?o.push(i):s.next(i)},error(i){s.error(i)},complete(){s.complete()}})})},Vf=e=>{let t=null,n=ke;const r=()=>{if(!t)throw new Error("Missing chainHead subscription");return t},s=u=>r().header(u).then(br.dec),o=async u=>r().storage(u,"hash","0x3a636f6465",null),i=Kl(new U(u=>{t=e(!0,a=>{u.next(a)},a=>{t=null,u.error(a)}),n=()=>{u.complete(),t?.unfollow()}}).pipe(Lf(s,o),Ff()));return{getHeader:s,getFollower:r,startFollow:()=>(i.connect(),()=>{n()}),follow$:i}},Ff=()=>e=>new U(t=>{const n=new Ct,r=()=>e.subscribe({next:s=>t.next(s),error:s=>{n.add(r()),s instanceof Mi?t.next({type:"stop-error"}):console.warn("ChainHead follow request failed, retrying\u2026",s)},complete:()=>t.complete()});return n.add(r()),n}),Hf=e=>ee(De.enc(e)),Wi=X(),zf=ht(Wi),jf=Se(De).dec,Ki=e=>{const t=e("Metadata_metadata_versions","").pipe(S(jf),Ae(()=>re([14]))),n=r=>{const[s]=r.filter(o=>o>13&&o<17).sort((o,i)=>i-o);return s===14?e("Metadata_metadata","").pipe(S(Wi.dec)):e("Metadata_metadata_at_version",Hf(s)).pipe(S(o=>zf.dec(o)))};return t.pipe(R(n))},Xi=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",bt={type:"void"},qf=(e,t=()=>null)=>{const n=new Map,r=new Set,s=f=>d=>{let l=n.get(d);if(l)return l;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const h=f(d);return l=n.get(d),l?Object.assign(l,h):(l={id:d,...h},n.set(d,l)),r.delete(d),l};let o=!0,i=!0;const c=s(f=>{const d=t(e[f]);if(d)return d;const{def:l,path:h,params:p}=e[f];if(l.tag==="composite"){if(l.value.length===0)return bt;if(l.value.length===1){const m=c(l.value[0].type);return o&&h.at(-1)==="AccountId32"&&Xi(m,32)?(o=!1,{type:"AccountId32"}):i&&h.at(-1)==="AccountId20"&&Xi(m,20)?(i=!1,{type:"AccountId20"}):m}return u(l.value)}if(l.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(l.value.length===0)return bt;const m={},v={};return l.value.forEach(y=>{const b=y.name;if(v[b]=y.docs,y.fields.length===0){m[b]={...bt,idx:y.index};return}if(y.fields.length===1&&!y.fields[0].name){m[b]={type:"lookupEntry",value:c(y.fields[0].type),idx:y.index};return}m[b]={...u(y.fields),idx:y.index}}),{type:"enum",value:m,innerDocs:v}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:m}=l.value,v=c(l.value.type);return!m||v.type==="void"?bt:m>1?{type:"array",value:v,len:l.value.len}:v}if(l.tag==="tuple")return l.value.length===0?bt:l.value.length>1?a(l.value.map(m=>c(m)),l.value.map(m=>e[m].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const m=c(l.value);return m.type==="void"?bt:{type:"compact",isBig:Number(m.value.slice(1))>32,size:m.value}}return{type:l.tag,isLSB:(e[l.value.bitOrderType].path.at(-1)??"LSB").toUpperCase().startsWith("LSB")}}),u=f=>{let d=!0;const l={},h={};return f.forEach((p,m)=>{d=d&&!!p.name;const v=p.name||m,y=c(p.type);y.type!=="void"&&(l[v]=y,h[v]=p.docs)}),d?{type:"struct",value:l,innerDocs:h}:a(Object.values(l),Object.values(h))},a=(f,d)=>{if(f.every(l=>l.id===f[0].id)&&d.every(l=>!l.length)){const[l]=f;return l.type==="void"?bt:{type:"array",value:f[0],len:f.length}}return{type:"tuple",value:f,innerDocs:d}};return c},Jn=e=>{const t=qf(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?{...bt,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})},Wf=(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},Kf=tn(),Yi=Wf((e,t,n,r)=>{if(e.type==="primitive")return Wo[e.value];if(e.type==="void")return _;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return wo;if(e.type==="compact")return e.isBig?Cn:B;if(e.type==="bitSequence")return On(e.isLSB);const s=h=>Yi(h,t,n,r),o=(h,p)=>{const m=s(h);return p?Se(m,p):Se(m)},i=h=>Fe(...h.map(s)),c=h=>{const p=Object.fromEntries(Object.entries(h).map(([m,v])=>[m,s(v)]));return oe(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Kf;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?tn(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 ht(s(e.value));if(e.type==="result")return _n(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(h=>{switch(h.type){case"void":return _;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]])),f=Object.values(e.value).map(h=>h.idx),l=f.every((h,p)=>h===p)?xe(a):xe(a,f);return e.byteLength?Xf(l,e.byteLength):l},dr,e=>e),Gi=(e,t=kt())=>{const n=new Map,r=s=>Yi(e(s),n,new Set,t);return s=>r(s)},Xf=(e,t)=>{const n=X(t);return j(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Yf=Ke(_,()=>{},()=>null),Kr=e=>{const{metadata:t}=e;let n=Gi(e);const r=t.pallets.find(l=>l.name==="System")?.constants.find(l=>l.name==="SS58Prefix");let s;if(r)try{const l=n(r.type).dec(r.value);typeof l=="number"&&(s=l,n=Gi(e,kt(l)))}catch{}const o=new Map,i=(l,h)=>{let p=o.get(l);p||o.set(l,p=jo(l));const m=t.pallets.find(x=>x.name===l).storage.items.find(x=>x.name===h),v=x=>x===_?Yf:x,y=(x,P,...M)=>{const J=p(...M),[,...q]=M;return{args:Fe(...q.map(([fe])=>fe)),keys:J,value:P,len:x,fallback:m.modifier===1?P.dec(m.fallback):void 0}};if(m.type.tag==="plain")return y(0,v(n(m.type.value)),h);const{key:b,value:g,hashers:w}=m.type.value,k=v(n(g)),I=w.map(x=>Wo[x.tag]),T=(()=>{if(I.length===1)return[[n(b),I[0]]];const x=e(b);switch(x.type){case"array":return I.map(P=>[n(x.value.id),P]);case"tuple":return x.value.map((P,M)=>[n(P.id),I[M]]);default:throw new Error("Invalid key type")}})();return y(I.length,k,h,...T)},c=l=>{switch(l.type){case"void":return _;case"lookupEntry":return n(l.value.id);case"tuple":return Fe(...Object.values(l.value).map(h=>n(h.id)));case"struct":return oe(Ut(l.value,h=>n(h.id)));case"array":return Se(n(l.value.id),l.len)}},u=(l,h)=>{const p=t.pallets.find(m=>m.name===l).constants.find(m=>m.name===h);return n(p.type)},a=l=>(h,p)=>{const m=t.pallets.find(b=>b.name===h),v=e(m[l].type);if(v.type!=="enum")throw null;const y=v.value[p];return{location:[m.index,y.idx],codec:c(v.value[p])}},f=(l,h)=>{const p=t.pallets.find(m=>m.name===l)?.viewFns.find(m=>m.name===h);if(!p)throw null;return{args:Fe(...p.inputs.map(m=>n(m.type))),value:n(p.output)}},d=(l,h)=>{const p=t.apis.find(m=>m.name===l)?.methods.find(m=>m.name===h);if(!p)throw null;return{args:Fe(...p.inputs.map(m=>n(m.type))),value:n(p.output)}};return{buildDefinition:n,buildStorage:i,buildEvent:a("events"),buildError:a("errors"),buildViewFn:f,buildRuntimeCall:d,buildCall:a("calls"),buildConstant:u,ss58Prefix:s}},Qi="CheckMortality",Ni=(e,t,n)=>{const r=Jn(e),s=Kr(r),o=s.buildStorage("System","Events"),i=e.extrinsic.signedExtensions.find(f=>f.identifier==="ChargeAssetTxPayment");let c=null;if(i){const f=r(i.type);if(f.type==="struct"){const d=f.value.asset_id;d.type==="option"&&(c=d.value.id)}}const u=Nf(r.metadata,s),a=f=>{const d=u(f);return"extra"in d&&d.extra[Qi]||{mortal:!1}};return{assetId:c,metadataRaw:t,codeHash:n,lookup:r,dynamicBuilder:s,events:{key:o.keys.enc(),dec:o.value.dec},accountId:kt(s.ss58Prefix),getMortalityFromTx:a}},Xr=X(1/0).dec,Gf=wn(et[1],e=>{const t=2<<e%16,n=Math.max(t>>12,1),r=(e>>4)*n;return{mortal:!0,period:t,phase:r}}),Qf=wt(e=>{const t=V.dec(e);if(t===0)return{mortal:!1};const n=V.dec(e);return Gf(Uint8Array.from([t,n]))}),Nf=(e,t)=>{const n=Object.fromEntries(e.extrinsic.signedExtensions.map(c=>[c.identifier,c.identifier===Qi?Qf:t.buildDefinition(c.type)[1]]));let r,s;const{extrinsic:o}=e;if("address"in o)r=t.buildDefinition(o.address)[1],s=t.buildDefinition(o.signature)[1];else{const c=e.lookup[o.type]?.params,u=c?.find(d=>d.name==="Call")?.type,a=c?.find(d=>d.name==="Address")?.type,f=c?.find(d=>d.name==="Signature")?.type;if(u==null||a==null||f==null)throw new Error("Call, Address and/or signature not found");r=t.buildDefinition(a)[1],s=t.buildDefinition(f)[1]}const i=oe.dec({address:r,signature:s,extra:oe.dec(n),callData:Xr});return wt(c=>{const u=B.dec(c),{type:a,version:f}=Ar[1](c);if(a==="bare")return{len:u,version:f,type:a,callData:Xr(c)};if(a==="signed")return{len:u,version:f,type:a,...i(c)};const d=V.dec(c);let l;if(e.version===16){const p=e.extrinsic.signedExtensionsByVersion.find(([m])=>m===d);if(!p)throw new Error("Unexpected extension version");l=oe.dec(Object.fromEntries(Object.entries(n).filter((m,v)=>p[1].includes(v))))}else l=oe.dec(n);const h=l(c);return{len:u,type:a,version:f,extensionVersion:d,extra:h,callData:Xr(c)}})},Zf=e=>t=>{const n=(...r)=>{const s=e();return s?t(s,...r).pipe(Ae(o=>{if(o instanceof Ne)return n(...r);if(o instanceof Qn)return Wn(750).pipe(R(()=>n(...r)));throw o})):vt};return n},Jf=(e,t,n,r)=>{const s=(o,i)=>o.pipe(R(c=>n(c).pipe(Ae(()=>re(null)),R(u=>u?re(u):i.pipe(Xn(a=>{r(c,a)}))),S(u=>({codeHash:c,metadataRaw:u,metadata:Dt(dt.dec(u))})))));return o=>{const i=Zf(o),c=o(),u=new Set([c]),a=i(t)().pipe(hn(1)),f=s(a,Ki(i(e))).pipe(S(({metadata:l,metadataRaw:h,codeHash:p})=>Ni(l,h,p)),hn(1)),d={at:c,runtime:f,codeHash$:a,addBlock:l=>(u.add(l),d),deleteBlocks:l=>(l.forEach(h=>{u.delete(h)}),u.size),usages:u};return f.subscribe({error(){}}),d}},pn=fn({connector:()=>new Fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0}),Zi=(e,t)=>()=>{const n=e.runtimes[t];return n?[...n.usages].at(-1)??null:e.blocks.has(t)?t:null},Ji=(e,t)=>{e.get(e.get(t).parent)?.children.delete(t),e.delete(t)},eh=(e,t)=>{t.forEach(n=>{Ji(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]})},th=(e,t,n,r,s,o,i,c)=>{const u=new ze,a=u.pipe(sf(()=>Wn(0)),S(()=>({type:"cleanup"}))),f=un(o,a,e).pipe(ln((l,h)=>{const p=m=>{eh(l,m),i(m)};switch(h.type){case"initialized":l.recovering&&!h.finalizedBlockHashes.some(y=>l.blocks.has(y))&&(l=ec());const m=h.finalizedBlockHashes.length-1;l.finalized=l.best=h.finalizedBlockHashes[m];let v=l.finalizedRuntime.at;return h.finalizedBlockHashes.forEach((y,b)=>{const g=b!==m,w=l.blocks.get(y);if(w)w.recovering=!1,w.unpinnable=g;else{const k=h.runtimeChanges.has(y);k&&(v=y),l.blocks.set(y,{hash:y,parent:b===0?h.parentHash:h.finalizedBlockHashes[b-1],children:new Set(b===m?[]:[h.finalizedBlockHashes[b+1]]),unpinnable:g,runtime:v,refCount:0,number:h.number+b,recovering:!1}),k&&(l.finalizedRuntime=l.runtimes[y]=d(Zi(l,y))),l.runtimes[v].usages.add(y)}}),l;case"stop-error":for(const y of l.blocks.values())y.recovering=!0;return l.recovering=!0,l;case"newBlock":{const{parentBlockHash:y,blockHash:b}=h;if(l.blocks.has(b))l.blocks.get(b).recovering=!1;else{const g=l.blocks.get(y);g.children.add(b);const w={hash:b,number:g.number+1,parent:y,children:new Set,runtime:h.newRuntime?b:g.runtime,unpinnable:!1,refCount:0,recovering:!1};l.blocks.set(b,w),h.newRuntime&&(l.runtimes[b]=d(Zi(l,b))),l.runtimes[w.runtime].addBlock(b)}return l}case"bestBlockChanged":{if(l.recovering){for(const[y,b]of l.blocks)b.recovering&&(Ji(l.blocks,y),c(y));l.recovering=!1}return l.best=h.bestBlockHash,l}case"finalized":{l.finalized=h.finalizedBlockHashes.slice(-1)[0];const{blocks:y}=l;y.get(l.best).number<y.get(l.finalized).number&&(l.best=l.finalized),l.finalizedRuntime=l.runtimes[y.get(l.finalized).runtime],h.prunedBlockHashes.forEach(g=>{const w=l.blocks.get(g);w&&(w.unpinnable=!0)});let b=y.get(y.get(l.finalized).parent);for(;b&&!b.unpinnable;)b.unpinnable=!0,b=y.get(b.parent);return u.next(),l}case"cleanup":{const y=[...l.blocks.values()].filter(({unpinnable:b,refCount:g})=>b&&!g).map(({hash:b})=>b);return p(y),l}case"blockUsage":{if(!l.blocks.has(h.value.hash))return l;const y=l.blocks.get(h.value.hash);if(y.refCount+=h.value.type==="hold"?1:-1,y.refCount===0&&!y.recovering&&y.unpinnable){const b=[y.hash];p(b)}return l}}},ec()),Pe(l=>!!l.finalizedRuntime.runtime),S(l=>({...l})),pn),d=Jf(dn(f,t,"pinned-blocks"),dn(f,n,"pinned-blocks"),r,s);return f},ec=()=>({best:"",finalized:"",runtimes:{},blocks:new Map,finalizedRuntime:{},recovering:!1}),tc=(e,t,n,r)=>{const s=c=>Ti(e.pipe(Pe(({blocks:u})=>!u.has(c)))),o=(c,u,a)=>{if(a)return re({hash:c,found:{type:!1,validity:null}});const f=s(c);return t(c).pipe(R(d=>{const l=d.indexOf(u);return l>-1?f(r(c)).pipe(S(h=>({hash:c,found:{type:!0,index:l,events:h}}))):n(c,u).pipe(S(h=>({hash:c,found:{type:!1,validity:h}})))}),f)},i=(c,u,a)=>o(c,u,a.has(c)).pipe(R(f=>{const{found:d}=f;return d.type||d.validity?.success===!1?re(f):e.pipe(s(c),R(l=>l.blocks.get(c).children),tf(),R(l=>i(l,u,a)))}));return c=>e.pipe(Q(1),R(u=>i(u.finalized,c,new Set(u.blocks.keys()))))},nh=new Uint8Array([2]),rh=(e,t)=>ee(se([nh,me(e),me(t)])),nc="TaggedTransactionQueue",rc="validate_transaction",[,sh]=xe({InvalidTransaction:xe({Call:_,Payment:_,Future:_,Stale:_,BadProof:_,AncientBirthBlock:_,ExhaustsResources:_,Custom:V,BadMandatory:_,MandatoryValidation:_,BadSigner:_}),UnknownTransaction:xe({CannotLookup:_,NoUnsignedValidator:_,Custom:V})}),oh=wt(e=>{const t=V.dec(e);if(t>1)throw new Error("Unable to decode validateTransaction result");if(!t)return{success:!0,value:void 0};let n;try{n=sh(e)}catch{n={type:"UnknownInvalidTx"}}return{success:!1,value:n}}),ih=(e,t)=>(n,r)=>{const s=t(n).pipe(S(o=>{try{return o.dynamicBuilder.buildRuntimeCall(nc,rc).value[1]}catch{return oh}}));return e(n,`${nc}_${rc}`,rh(r,n)).pipe(jr(s),S(([o,i])=>i(o)))},ch=e=>t=>new U(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}),ah=e=>t=>new U(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)}}),sc=(e,t=1/0)=>n=>new U(r=>{let s;const o=new Map,i=new Map,c=new Map;let u=0,a=0,f=0;const d=()=>{const l=o.get(a);if(!l){i.size===0&&(typeof s>"u"||s.closed)&&r.complete();return}const h=a++;o.delete(h),f!==h&&c.set(h,[]);let p=!1,m=l.subscribe({next(v){f===h?r.next(v):c.get(h).push(v)},complete(){if(p=!0,i.delete(h),h===f)for(f++;c.has(f)&&(c.get(f).forEach(v=>r.next(v)),c.delete(f),!i.has(f));)f++;d()},error(v){r.error(v)}});p||i.set(h,m)};return s=new Ct,s.add(n.subscribe({next(l){const h=u++;o.set(h,qn(()=>e(l,h))),i.size<t&&d()},error(l){r.error(l)},complete(){i.size===0&&r.complete()}})),()=>{i.forEach(l=>l.unsubscribe()),s.unsubscribe(),o.clear(),c.clear()}}),Yr=({hash:e,number:t,parent:n})=>({hash:e,number:t,parent:n}),uh=(e,t,n)=>{const{getFollower:r,startFollow:s,follow$:o,getHeader:i}=Vf(e),c=Pf(r),{withRecovery:u,withRecoveryFn:a}=Of(),f=new ze,d=E=>$=>new U(C=>{f.next({type:"blockUsage",value:{type:"hold",hash:E}});const L=$.subscribe(C);return L.add(()=>{setTimeout(()=>{f.next({type:"blockUsage",value:{type:"release",hash:E}})},0)}),L}),l=E=>($,...C)=>E($,...C).pipe(d($)),h=(E,$)=>(C,...L)=>new U(de=>{let ce=!1;return g.pipe(Q(1)).subscribe(qe=>{ce=qe.blocks.has(C)}),ce?E(C,...L).subscribe(de):de.error(new Ne(C,$))}),p=E=>r().unpin(E).catch($=>{if(!($ instanceof Yn))throw $}),m=(E,$)=>h(l(dn(g,a(_t(E)),`stop-${$}`)),$),v=new Map,y=l(a(_t(c("storage")))),b=E=>y(E,"hash","0x3a636f6465",null).pipe(S($=>$)),g=th(o,l(a(_t(c("call")))),b,t,n,f,E=>{p(E).catch($=>{console.error("unpin",$)}),E.forEach($=>{v.delete($)})},E=>{v.delete(E)}),w=h(l(E=>g.pipe(Q(1),R($=>$.runtimes[$.blocks.get(E).runtime].runtime))),"getRuntimeCtx"),k=E=>$=>$.pipe(sc(C=>w(E(C)).pipe(S(L=>[C,L])))),I=(E,$,C)=>{const L=v.get(E)??new Map,de=L.get($);if(de)return de;v.set(E,L);let ce;const qe=C.pipe(fn({connector:()=>ce=new Fn}),Xn({complete(){L.set($,ce)}}),ah());return L.set($,qe),qe},T=g.pipe(Pe(E=>!E.recovering),ye((E,$)=>E.finalized===$.finalized),ln((E,$)=>{let C=$.blocks.get($.finalized);const L=[C],de=E.at(-1);if(!de)return L;for(;C.number>de.number+1&&(C=$.blocks.get(C.parent),!!C);)L.unshift(C);return L},[]),zn(),S(Yr),pn),x=g.pipe(ye((E,$)=>E.best===$.best),S(E=>Yr(E.blocks.get(E.best))),pn),P=g.pipe(Pe(E=>!E.recovering),ye((E,$)=>E.finalized===$.finalized&&E.best===$.best),ln((E,$)=>{const C=Me=>E.get(Me)||Yr($.blocks.get(Me)),L=C($.best),de=C($.finalized),ce=L.number-de.number+1,qe=new Array(ce);for(let Me=0,Bc=L.hash;Me<ce;Me++)qe[Me]=C(Bc),Bc=qe[Me].parent;return new Map(qe.map(Me=>[Me.hash,Me]))},new Map),S(E=>[...E.values()]),pn),M=g.pipe(ye((E,$)=>E.finalizedRuntime===$.finalizedRuntime),Kn(({finalizedRuntime:{runtime:E}})=>E.pipe(ch(null))),pn),J=M.pipe(S(E=>E?.lookup.metadata??null)),q=Rf(T.pipe(S(E=>E.hash)),x.pipe(S(E=>E.hash)),d),fe=m(c("body"),"body"),N=E=>I(E,"body",fe(E)),he=m(c("storage"),"storage"),ie=q(h((E,$,C,L=null,de)=>g.pipe(Q(1),R(ce=>ce.runtimes[ce.blocks.get(E).runtime].runtime),R(ce=>{const qe=C(ce);return I(E,`storage-${$}-${qe}-${L??""}`,he(E,$,qe,L)).pipe(de?S(Me=>de(Me,ce)):Qe)})),"storage")),be=Mf(r,u),Je=q(h(dn(g,(E,$,C)=>be(E,$,C??null,!1),"storageQueries"),"storageQueries")),or=q(h(dn(g,E=>qn(()=>i(E)),"header"),"header")),Xt=E=>ie(E,"value",$=>$.events.key,null,($,C)=>C.events.dec($)),ls=m(c("call"),"call"),Sc=q((E,$,C)=>I(E,`call-${$}-${C}`,ls(E,$,C))),fs=ih(Sc,w),$c=E=>I(E,"body",fe(E)),fd=tc(g,$c,fs,Xt),hd=tc(g,$c,fs,()=>re()),dd=M.pipe(Pe(Boolean),Q(1),R(E=>{const{enc:$}=E.dynamicBuilder.buildStorage("System","BlockHash").keys;let C;try{C=$(0)}catch{C=$(0n)}return ie(null,"value",()=>C,null)}),hn(1));un(M,P).subscribe({error(){}});let hs=ke,yn=!1,ds=0;const pd=E=>{ds+=E,yn=!0,hs=s()},vd=E=>g.pipe(Q(1),R(({runtimes:$})=>un(...Object.values($).map(C=>C.codeHash$.pipe(R(L=>E===L?C.runtime:vt)))).pipe(rf(null),Q(1)))),Ic=(E,$=!1)=>{let C=E||"finalized",L=!1;if(yn&&g.pipe(Q(1)).subscribe(ce=>{C=ce[C]||C,L=ce.blocks.has(C)}),!L){if($)throw new Ne(C,"holdBlock");return ke}f.next({type:"blockUsage",value:{type:"hold",hash:C}});let de=()=>{f.next({type:"blockUsage",value:{type:"release",hash:C}}),de=ke};return()=>{de()}},md=E=>$=>new U(C=>{const L=$.subscribe(C);return L.closed||L.add(Ic(E)),L});return[{follow$:o,finalized$:T,best$:x,bestBlocks$:P,newBlocks$:Uf(g),runtime$:M,metadata$:J,genesis$:dd,getRuntime$:vd,header$:or,body$:N,call$:Sc,storage$:ie,storageQueries$:Je,eventsAt$:Xt,withHodl:md,holdBlock:Ic,trackTx$:fd,trackTxWithoutEvents$:hd,validateTx$:fs,pinnedBlocks$:g,withRuntime:k,getRuntimeContext$:q(w),unfollow:()=>{yn!=null&&(ds--,yn&&!ds&&(yn=null,hs(),hs=ke))}},pd]};var lh=e=>t=>new U(n=>e(t,r=>{n.error(r)}));const fh=({storageSubscription:e,...t})=>n=>{const r={},s=_t(t.storage),o=_t(t.call),i=_t(t.header),c=_t(t.body),u=m=>i(m).pipe(S(br[1])),a=m=>s(m,"hash","0x3a636f6465",null).pipe(S(v=>v)),f=(m,v)=>n(m).pipe(Ae(()=>re(null)),R(y=>y?re(y):Ki((...b)=>o(v,...b)).pipe(S(b=>Ni(Dt(dt.dec(b)),b,m)))),Xn(y=>{r[m]=y})),d=m=>a(m).pipe(R(v=>{const y=r[v];return y?re(y):f(v,m)})),l=(m,v,y,b=null,g)=>d(m).pipe(R(w=>s(m,v,y(w),b).pipe(S(k=>g?g(k,w):k))));return{body$:c,header$:u,storage$:l,storageQueries$:(m,v,y)=>new U(b=>e(m,v,y||null,g=>b.next(g),g=>b.error(g),()=>{b.complete()})),call$:o,eventsAt$:m=>l(m,"value",v=>v.events.key,null,(v,y)=>y.events.dec(v)),getRuntimeContext$:d}},hh=()=>re(null),er=new Map,dh=(e,t={})=>{const{getMetadata:n,setMetadata:r}=t,s=er.get(e);if(s)return s.refCount++,s.client;const o=()=>{const f=er.get(e);!f||f.refCount<=1?(er.delete(e),e.destroy()):f.refCount--};let i=null,c=0,u=null;const a={chainHead$:f=>{c++,u||(u=f||1),i||(i=uh(e.chainHead,n||hh,r||ke));const[d,l]=i;if(u===c){const h=c;c=0,u=null,i=null,l(h)}return d},archive:fh(e.archive),broadcastTx$:lh(e.transaction),destroy:o};return er.set(e,{client:a,refCount:1}),a},ph=(e,t)=>e.pipe(zr(n=>n.blocks.has(t)),ye((n,r)=>n.finalized===r.finalized&&n.best===r.best),S(n=>{if(n.blocks.get(t).number>n.blocks.get(n.best).number)return null;const{number:r}=n.blocks.get(t);let 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}),ye(),zr(n=>n!=="finalized",!0)),Ot=(e,t)=>(n,...r)=>e(n,...r).pipe(Ae(s=>{if(!(s instanceof Ne))throw s;return t(n,...r).pipe(Ae(o=>{throw console.warn(o),s}))}));class Tt{constructor(){}_runtime(t){}}class Gr{constructor(){}_compatibility(t){}}const tr=new WeakMap,oc=new WeakMap,nr=e=>e instanceof Tt?oc.get(e):tr.get(e);var gt=(e=>(e.Storage="storage",e.Tx="tx",e.Event="events",e.Const="constants",e.ViewFns="viewFns",e.Api="apis",e))(gt||{});const vh=Se(Gu),mh=Se(Br),yh=Fe(vh,mh),bh=(e,t)=>{const n=new Promise(async r=>{const s=t.runtime$.pipe(Pe(i=>i!=null));let o=await je(s);s.subscribe(i=>o=i),r(()=>o)});return Promise.all([e.metadataTypes.then(yh.dec),e.descriptors,n]).then(([[r,s],o,i])=>{const c=new Gr;return tr.set(c,{runtime:i,getEntryPoint(u,a,f){const d=o[u]?.[a]?.[f];if(d==null)throw new Error(`Descriptor for ${u} ${a}.${f} does not exist`);return r[d]},typedefNodes:s}),c})},gh=e=>new Promise(async t=>{const n=e.runtime$.pipe(Pe(s=>s!=null));let r=await je(n);n.subscribe(s=>r=s),t(()=>r)}).then(t=>{const n=new Tt;return oc.set(n,{runtime:t}),n}),Qr=new WeakMap,ic=e=>(Qr.has(e.metadataRaw)||Qr.set(e.metadataRaw,{compat:new Map,lookup:e.lookup,typeNodes:[]}),Qr.get(e.metadataRaw)),Rt=(e,t,n)=>{const r=(i,c)=>{var u;const a=ic(i);return(u=a.typeNodes)[c]||(u[c]=Pn(a.lookup(c)))};function s(i,c){if(i instanceof Tt)return{args:Oe.Identical,values:Oe.Identical};const u=tr.get(i);c||(c=u.runtime());const a=n(c);if(a==null)return{args:Oe.Incompatible,values:Oe.Incompatible};const f=u.typedefNodes,d=ic(c),l=t(u),h=Ju(l,p=>f[p],a,p=>r(c,p),d.compat);return{args:h.args.level,values:h.values.level}}const o=ac(e,i=>cc(s(i)));return{isCompatible:ac(e,(i,c)=>o(c)>=i),getCompatibilityLevel:o,getCompatibilityLevels:s,descriptors:e,withCompatibleRuntime:(i,c)=>u=>zt([u.pipe(i.withRuntime(c)),e]).pipe(S(([[a,f],d])=>[a,d,f])),compatibleRuntime$:(i,c)=>zt([e,i.getRuntimeContext$(c)]),argsAreCompatible:(i,c,u)=>{if(i instanceof Tt)return!0;const a=s(i,c);if(a.args===Oe.Incompatible)return!1;if(a.args>Oe.Partial)return!0;if(a.values===Oe.Incompatible)return!1;const f=n(c);return f==null?!1:Zo(f.args,d=>r(c,d),u)},valuesAreCompatible:(i,c,u)=>{if(i instanceof Tt)return!0;const a=s(i,c).values;if(a===Oe.Incompatible)return!1;if(a>Oe.Partial)return!0;const f=tr.get(i),d=t(f);return Zo(d.values,l=>f.typedefNodes[l],u)},getRuntimeTypedef:r}},cc=e=>Math.min(e.args,e.values),ac=(e,t)=>(...n)=>{const r=n.at(-1);return r instanceof Gr||r instanceof Tt?t(...n):e.then(s=>t(...n,s))},wh=(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 f=a.lookup.metadata.pallets.find(l=>l.name===e)?.constants.find(l=>l.name===t);if(f==null)throw new Error(`Runtime entry Constant(${e}.${t}) not found`);const d=a.dynamicBuilder.buildConstant(e,t).dec(f.value);return i.set(a,d),d},u=a=>{if(a){const f=nr(a).runtime(),d=c(f);if(!n(a,f,d))throw new Error(`Incompatible runtime entry Constant(${e}.${t})`);return d}return r.then(u)};return Object.assign(u,{isCompatible:s,getCompatibilityLevel:o})},xh=fn({connector:()=>new Fn(1),resetOnError:!0,resetOnComplete:!0,resetOnRefCountZero:!0});function vn(e,t){return new Promise((n,r)=>{let s=null,o=!1;const i=t?()=>{s?.unsubscribe(),r(new eo)}:ke;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 Nr=Symbol("EMPTY_VALUE"),Zr=e=>t=>new U(n=>{let r=0,s=null,o=Nr,i=!1;const c=()=>{const a=e(o,r++);o=Nr,s=a.subscribe({next(f){n.next(f)},error(f){n.error(f)},complete(){o!==Nr?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 uc={};const Eh=e=>t=>new U(n=>{let r=uc,s=t.subscribe({next(o){n.next(r=o)},error(o){n.error(o)},complete(){r===uc?n.complete():s=e(r).subscribe(n)}});return()=>{s.unsubscribe()}}),Wt=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)),kh=()=>{const e=new dl(new ze);return[e.pipe(cf()),()=>Xn({next:t=>e.value.next(t),error:t=>{e.value.error(t),e.next(new ze)},complete:()=>{e.value.complete(),e.next(new ze)}})]},Ah=(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,f=>f.hash),S(([f,d,l])=>{const h=l.lookup.metadata.pallets.find(p=>p.name===e)?.events?.type;if(h==null||l.lookup.metadata.lookup[h].def.tag!=="variant"||l.lookup.metadata.lookup[h].def.value.find(p=>p.name===t)==null)throw new Error(`Runtime entry Event(${e}.${t}) not found`);if(!i(d,l,null))throw u();return[f,d,l]}),sc(([f,d,l])=>n.eventsAt$(f.hash).pipe(S(h=>h.filter(p=>p.event.type===e&&p.event.value.type===t).map(p=>{if(!c(d,l,p.event.value.value))throw u();return{meta:{phase:p.phase,block:f},payload:p.event.value.value}})))),xh);return{watch:f=>a.pipe(R(d=>f?d.filter(l=>f(l.payload)):d)),pull:()=>je(a),filter:f=>f.filter(d=>d.type===e&&d.value.type===t).map(d=>d.value.value),getCompatibilityLevel:s,isCompatible:r}},Sh=(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((...f)=>{const d=f[f.length-1],l=Wt(d),{signal:h,at:p}=l?d:{},m=p??null,v=o(n,m).pipe(R(([y,b])=>{let g;try{g=b.dynamicBuilder.buildRuntimeCall(e,t)}catch{throw new Error(`Runtime entry RuntimeCall(${u}) not found`)}if(!i(y,b,f))throw a();return n.call$(m,u,ee(g.args.enc(f))).pipe(S(g.value.dec),S(w=>{if(!c(y,b,w))throw a();return w}))}),n.withHodl(m));return vn(v,h)},{getCompatibilityLevel:s,isCompatible:r})},lc=S(e=>e.mapped),$h=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,getCompatibilityLevels:i,descriptors:c,argsAreCompatible:u,valuesAreCompatible:a})=>{const f=e==="System"&&t==="Number",d=e==="System"&&t==="BlockHash",l=n.runtime$.pipe(Pe(Boolean),Q(1),S(({dynamicBuilder:x})=>typeof x.buildStorage("System","Number").value.dec(new Uint8Array(32))=="bigint"?BigInt:Qe),hn()),h=si(Ql(l),S(([x,P])=>P(x))),p=()=>new Error(`Incompatible runtime entry Storage(${e}.${t})`),m=x=>new Error(`Invalid Arguments calling ${e}.${t}(${x})`),v=x=>{try{return x.dynamicBuilder.buildStorage(e,t)}catch{throw new Error(`Runtime entry Storage(${e}.${t}) not found`)}},y=(...x)=>{const P=x[x.length-1],M=P==="best",J=M||P==="finalized"?x.slice(0,-1):x;return n[M?"best$":"finalized$"].pipe(Zr(()=>b(...J,M?{at:"best"}:{})),ye((q,fe)=>q.raw===fe.raw),lc)},b=(...x)=>{const P=x[x.length-1],M=Wt(P),{at:J}=M?P:{},q=J??null,fe=yt(c).pipe(R(N=>n.storage$(q,"value",he=>{const ie=v(he),be=x.length===ie.len?x:x.slice(0,-1);if(x!==be&&!M)throw m(x);if(!u(N,he,be))throw p();return ie.keys.enc(...be)},null,(he,ie)=>{const be=v(ie),Je=he===null?be.fallback:be.value.dec(he);if(!a(N,ie,Je))throw p();return{raw:he,mapped:Je}})),n.withHodl(q));return f?n.pinnedBlocks$.pipe(S(N=>{const he=q==="finalized"||!q?N.finalized:q==="best"?N.best:q,ie=N.blocks.get(he);if(!ie)throw new Ne(he,"System.Number");return ie.number}),ye(),h,S(N=>({raw:N.toString(),mapped:N})),Ae(N=>{if(N instanceof Ne)return fe;throw N})):d&&Number(x[0])===0?n.genesis$.pipe(S(N=>({raw:N,mapped:Bn.fromHex(N)}))):fe},g=async(...x)=>{const P=x[x.length-1],M=Wt(P),{signal:J}=M?P:{};return vn(b(...x).pipe(lc),J)},w=async(...x)=>{const P=x[x.length-1],M=Wt(P),{signal:J,at:q}=M?P:{},fe=q??null,N=yt(c).pipe(R(he=>n.storage$(fe,"descendantsValues",ie=>{const be=v(ie);if(cc(i(he,ie))===Oe.Incompatible)throw p();if(x.length>be.len)throw m(x);const Je=x.length>0&&M?x.slice(0,-1):x;if(x.length===be.len&&Je===x)throw m(x);return be.keys.enc(...Je)},null,(ie,be)=>{const Je=v(be),or=ie.map(({key:Xt,value:ls})=>({keyArgs:Je.keys.dec(Xt),value:Je.value.dec(ls)}));if(or.some(({value:Xt})=>!a(he,be,Xt)))throw p();return or})),n.withHodl(fe));return vn(N,J)},k=(x,P)=>Promise.all(x.map(M=>g(...P?[...M,P]:M))),I=(...x)=>{const P=x.at(-1),M=Wt(P);return r(e,t,M?x.slice(0,-1):x,M&&P.at==="best")},T=(...x)=>{const P=x.at(-1);if(P instanceof Gr||P instanceof Tt){const M=x.slice(0,-1),J=nr(P).runtime();if(!u(P,J,M))throw p();return v(J).keys.enc(...M)}return c.then(M=>T(...x,M))};return{isCompatible:s,getCompatibilityLevel:o,getKey:T,getValue:g,getValues:k,getEntries:w,watchValue:y,watchEntries:I}},Jr=()=>new Error("Unkown signer"),Ih=e=>{const{extrinsic:t}=e,n=Jn(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 Jr()}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 Jr();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 Jr()},Bh={Ed25519:0,Sr25519:1,Ecdsa:2},Ch=(e,t,n,r,s,o)=>{const[i,c]=Ih(e),u=se([Ar.enc({version:4,type:"signed"}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Bh[o],...n]),...r,s]);return se([pe.enc(u.length),u])},[rr,mn]=["<Bytes>","</Bytes>"].map(e=>Le.fromText(e).asBytes()),_h=e=>async t=>{let n=!0,r;for(r=0;n&&r<rr.length;r++)n=rr[r]===t[r];n=n&&r===rr.length;const s=t.length-mn.length;for(r=0;n&&r<mn.length;r++)n=mn[r]===t[s+r];return n=n&&r===mn.length,e(n?t:se([rr,t,mn]))};function Oh(e,t,n){return{publicKey:e,signTx:async(s,o,i,c,u=rn)=>{const a=Dt(kr(i)),f=[],d=[];a.extrinsic.signedExtensions.map(({identifier:p})=>{const m=o[p];if(!m)throw new Error(`Missing ${p} signed extension`);f.push(m.value),d.push(m.additionalSigned)});const l=se([s,...f,...d]),h=await n(l.length>256?u(l):l);return Ch(a,e,h,f,s,t)},signBytes:_h(n)}}Uint8Array.from([1]);const Th=(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 Rh(e){let t=0;for(;!(e&1);)t++,e>>=1;return t}const Ph=e=>1<<Math.ceil(Math.log2(e)),Uh=gn(X(2)[0],e=>{const t=Math.min(Math.max(Ph(e.period),4),65536),n=e.startAtBlock%t,r=Math.max(t>>12,1),s=Math.min(Math.max(Rh(t)-1,1),15),o=n/r<<4;return et[0](s|o)}),[Mh]=oe({tip:pe,asset:ht(X(1/0))}),fc=new Uint8Array,es=Uint8Array.from([0]),ts=e=>({value:e,additionalSigned:fc}),ns=e=>({value:fc,additionalSigned:e}),rs=(e,t)=>({value:e,additionalSigned:t}),hc=(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=[],f=Th(t,n),d=h=>{const[p,m]=r[h],v=c[h];try{return Ut({value:p,additionalSigned:m},(y,b)=>{const g=v?.[b];return g instanceof Uint8Array?g:y(g)})}catch{return a.push(h),null}},l=Ut(r,([h,p],m)=>{if(c[m])return d(m);switch(m){case"CheckNonce":return ts(h(i));case"CheckMortality":return s.mortal?rs(Uh({period:s.period,startAtBlock:s.startAtBlock.height}),me(s.startAtBlock.hash)):rs(es,e);case"ChargeTransactionPayment":return ts(h(o));case"ChargeAssetTxPayment":return ts(Mh({tip:o,asset:u.asset}));case"CheckGenesis":return ns(e);case"CheckMetadataHash":return rs(es,es);case"CheckSpecVersion":return ns(p(f.spec_version));case"CheckTxVersion":return ns(p(f.transaction_version));default:return d(m)}});return a.forEach(h=>{delete l[h]}),Ut(l,(h,p)=>({...h,identifier:p}))}},dc="AccountNonceApi_account_nonce",Dh={1:V.dec,2:et.dec,4:De.dec,8:Gt.dec},Lh=(e,t,n)=>e(n,dc,t).pipe(S(r=>{const s=me(r),o=Dh[s.length];if(!o)throw new Error(`${dc} retrieved wrong data`);return o(s)})),Vh=(e,t,n,r,s,o={})=>zt([o.nonce?re(o.nonce):Fh(e,ee(t.publicKey)),e.getRuntimeContext$(r.hash),e.genesis$]).pipe(Q(1),R(([i,c,u])=>{const a=hc(me(u),c.lookup,c.dynamicBuilder),f=o.mortality??{period:64,mortal:!0},d=a({nonce:i,tip:o.tip??0n,mortality:f.mortal?{mortal:!0,period:f.period,startAtBlock:{height:r.number,hash:r.hash}}:{mortal:!1},customSignedExtensions:s,asset:o.asset});return t.signTx(n,d,c.metadataRaw,r.number)})),Fh=(e,t)=>{const n=o=>e.newBlocks$.pipe(ln((i,c)=>c.parent===i?c.hash:i,o),Oi(o),ye()),r=o=>n(o).pipe(Q(2),Kn(i=>Lh(e.call$,t,i))),s=o=>zt(o.map(i=>r(i).pipe(S(c=>({success:!0,value:c})),Ae(c=>re({success:!1,value:c}))))).pipe(Q(1));return e.pinnedBlocks$.pipe(Pe(o=>!o.recovering&&o.blocks.size>0),Q(1),S(({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)}),Kn(s),S(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 Hh=Object.defineProperty,zh=(e,t,n)=>t in e?Hh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jh=(e,t,n)=>zh(e,t+"",n);const qh=e=>ee(rn(me(e))),Wh=(e,t)=>new U(n=>{const r=new Map;let s,o;const i=()=>{let u=s.best,a=r.get(u),f=s.blocks.get(u).number;for(;!a;){const h=s.blocks.get(u);if(!h)break;a=r.get(u=h.parent),f--}if(!a)return;const d=f<=s.blocks.get(s.finalized).number,l=a.found.type;if(l&&o?.found&&o.hash===a.hash){d&&n.complete();return}n.next(o=a.found.type?{found:l,hash:a.hash,number:f,index:a.found.index,events:a.found.events}:{found:l,validity:a.found.validity}),d&&(l?n.complete():a.found.validity?.success===!1&&n.error(new ss(a.found.validity.value)))},c=t.pipe(ye((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(ye((n,r)=>n===r)),Kh=(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 ss extends Error{constructor(t){super(JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r instanceof Le?r.asHex():r,2)),jh(this,"error"),this.name="InvalidTxError",this.error=t}}const os=(e,t,n,r=!1)=>{const s=qh(n),o=(a,f)=>({type:a,txHash:s,...f}),i=e.pinnedBlocks$.pipe(Q(1),R(a=>{let f=[];return a.finalizedRuntime.runtime.pipe(S(d=>d.getMortalityFromTx(n)),Ae(()=>re({mortal:!1})),S(d=>{const{best:l,finalized:h}=a;let p=l;for(;p!==h;)f.push(p),p=a.blocks.get(p).parent;if(f.push(h),!d.mortal)return[h,l];const{phase:m,period:v}=d,y=a.blocks.get(l),b=y.number,g=Math.floor((b-m)/v)*v+m;let w=[a.blocks.get(a.finalized)];for(;w.length&&w[0].number<g;)w=w.flatMap(k=>[...k.children]).map(k=>a.blocks.get(k)).filter(Boolean);return(w.length?w:[y]).map(k=>k.hash)}),R(d=>un(...[...new Set(d)].map(l=>e.validateTx$(l,n).pipe(S(h=>({at:l,result:h})))))),zr(({result:d})=>!d.success,!0),Gl((d,l)=>[...d,l],[]),S(d=>{const l=new Map(d.filter(({result:h})=>!h.success).map(h=>[h.at,h.result]));if(l.size<d.length)return null;throw new ss(l.get(f.find(h=>l.has(h))??[...l.keys()][0]).value)}),Pe(Boolean))})),c=new U(a=>{const f=e.trackTx$(n).subscribe(a);return f.add(t(n).subscribe({error(d){a.error(d)}})),f}),u=Wh(c,e.pinnedBlocks$).pipe(S(a=>a.found?o("txBestBlocksState",{found:!0,block:{index:a.index,number:a.number,hash:a.hash},...Kh(a.events,a.index)}):o("txBestBlocksState",{found:!1,isValid:a.validity?.success!==!1})));return jn(r?re(o("signed",{})):vt,i,re(o("broadcasted",{})),u.pipe(Eh(({found:a,type:f,...d})=>a?re(o("finalized",d)):vt)))},pc=async(e,t,n,r)=>Tl(os(e,t,n)).then(s=>{if(s.type!=="finalized")throw null;const o={...s};return delete o.type,o}),Xh=kt().enc,Yh=new Uint8Array(64),Gh=new Uint8Array(65),Qh=e=>()=>e?Gh:Yh,[,Nh]=oe({weight:oe({ref_time:Cn,proof_size:Cn}),class:xe({Normal:_,Operational:_,Mandatory:_}),partial_fee:bs}),vc=(e,t,n,r,{isCompatible:s,getCompatibilityLevel:o,compatibleRuntime$:i,argsAreCompatible:c,getRuntimeTypedef:u},a)=>Object.assign(f=>{const d=(w,k,I={})=>{const T=nr(w).runtime(),{dynamicBuilder:x,assetId:P,lookup:M}=T;let J;try{J=x.buildCall(e,t)}catch{throw new Error(`Runtime entry Tx(${e}.${t}) not found`)}if(a&&!c(w,T,k))throw new Error(`Incompatible runtime entry Tx(${e}.${t})`);let q=I;if(I.asset){if(P==null||!Cr(I.asset,Pn(M(P)),he=>u(T,he)))throw new Error("Incompatible runtime asset");q={...I,asset:x.buildDefinition(P).enc(I.asset)}}const{location:fe,codec:N}=J;return{callData:Le.fromBytes(se([new Uint8Array(fe),N.enc(k)])),options:q}},l=(w,k={})=>i(n,null).pipe(S(([I])=>d(I,w,k))),h=w=>w?d(w,f).callData:je(l(f).pipe(S(k=>k.callData))),p=(w,{...k},I)=>l(f,k).pipe(R(({callData:T,options:x})=>Vh(n,w,T.asBytes(),I,k.customSignedExtensions||{},x))),m=(w,{at:k,...I}={})=>(!k||k==="finalized"?n.finalized$:k==="best"?n.best$:n.bestBlocks$.pipe(S(T=>T.find(x=>x.hash===k)))).pipe(Q(1),R(T=>T?p(w,I,T).pipe(S(x=>({tx:ee(x),block:T}))):Hn(()=>new Error(`Uknown block ${k}`)))),v=(w,k)=>je(m(w,k)).then(I=>I.tx),y=(w,k)=>je(m(w,k)).then(({tx:I,block:T})=>pc(n,r,I,T.hash)),b=(w,k)=>m(w,k).pipe(R(({tx:I})=>os(n,r,I,!0))),g=async(w,k)=>{typeof w=="string"&&(w=w.startsWith("0x")?me(w):Xh(w));const I=w.length===20,T=Oh(w,I?"Ecdsa":"Sr25519",Qh(I)),x=me(await v(T,k)),P=ee(se([x,De.enc(x.length)])),M=n.getRuntimeContext$(null).pipe(S(q=>{try{return q.dynamicBuilder.buildRuntimeCall("TransactionPaymentApi","query_info").value[1]}catch{return Nh}})),J=n.call$(null,"TransactionPaymentApi_query_info",P);return je(zt([J,M]).pipe(S(([q,fe])=>fe(q))))};return{getPaymentInfo:g,getEstimatedFees:async(w,k)=>(await g(w,k)).partial_fee,decodedCall:{type:e,value:$t(t,f)},getEncodedData:h,sign:v,signSubmitAndWatch:b,signAndSubmit:y}},{getCompatibilityLevel:o,isCompatible:s});var Zh=Object.defineProperty,Jh=(e,t,n)=>t in e?Zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t,n)=>(Jh(e,typeof t!="symbol"?t+"":t,n),n),is=Symbol("SUSPENSE"),ed=class extends Promise{constructor(e){super(e)}},mc=class extends Error{constructor(){super(),this.name="NoSubscribersError"}},yc=class extends Error{constructor(){super(),this.name="EmptyObservableError"}},Be={},sr=class extends U{constructor(e,t,n=ke){super(r=>{const s=new cn({next:r.next.bind(r),error:r.error.bind(r),complete:ke});this.refCount++;let o;r.add(()=>{var i;this.refCount--,o.unsubscribe(),this.refCount===0&&(this.currentValue=Be,this.subscription&&this.subscription.unsubscribe(),n(),(i=this.subject)==null||i.complete(),this.subject=null,this.subscription=null,this.promise&&(this.promise.rej(new mc),this.promise=null))}),this.subject?(o=this.subject.subscribe(s),this.currentValue!==Be&&r.next(this.currentValue)):(this.subject=new ze,o=this.subject.subscribe(s),this.subscription=null,this.subscription=new cn({next:i=>{this.promise&&i!==is&&(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=Be;const a=(c=this.promise)==null?void 0:c.rej;a&&i===is&&(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 yc),this.promise=null),this.currentValue!==Be)return this.subject.complete();if(t===Be){const i=this.subject;return this.subject=null,i.error(new yc)}this.subject.next(this.currentValue=t),this.subject.complete()}}),e.subscribe(this.subscription),t!==Be&&this.currentValue===Be&&this.subject.next(this.currentValue=t))}),this.defaultValue=t,Ze(this,"subject",null),Ze(this,"subscription",null),Ze(this,"refCount",0),Ze(this,"currentValue",Be),Ze(this,"promise",null),Ze(this,"pipeState",(...r)=>{const s=super.pipe(...r);return s instanceof sr?s:new sr(s,Be)}),Ze(this,"getRefCount",()=>this.refCount),Ze(this,"getValue",()=>{if(this.promise)return this.promise.p;if(this.currentValue!==Be&&this.currentValue!==is)return this.currentValue;if(this.defaultValue!==Be)return this.defaultValue;if(this.refCount===0)throw new mc;const r=new ed((s,o)=>{this.promise={res:s,rej:o,p:null}});return this.promise.p=r,r}),Ze(this,"getDefaultValue",()=>this.defaultValue),t===Be&&delete this.getDefaultValue}};function bc(e,t){t.getValue=e.getValue,t.getRefCount=e.getRefCount,t.pipeState=e.pipeState,e.getDefaultValue&&(t.getDefaultValue=e.getDefaultValue)}function td(e,t){const n=new nd,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 sr(e(...o),r(...o),()=>{n.delete(i)}),a=new U(d=>{const l=n.get(i);let h=u;return l?l!==a&&(h=l,bc(h,a)):n.set(i,f),h.subscribe(d)});bc(u,a);const f=a;return n.set(i,f),f};return(...o)=>s(o)}var nd=class{constructor(){Ze(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 rd(e,t){return new sr(e,t)}var cs=(...e)=>(typeof e[0]=="function"?td:rd)(e[0],e.length>1?e[1]:Be);const gc=(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))}},wc=(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}},xc=(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)},sd=(e,t,n)=>{const r=cs((c,u,a)=>{const f=xc(c,u),d=(v,y)=>{const b=ph(e,y.hash).pipe(Pe(g=>!g),Q(1));return t(y.hash,"closestDescendantMerkleValue",()=>a).pipe(R(g=>g===v?.rootHash?re({...v,block:y,deltas:null,prev:v.block.hash}):t(y.hash,"descendantsValues",()=>a).pipe(n(()=>y.hash),S(([w,k])=>[w,f(k)]),S(([w,k])=>({prev:v&&v.block.hash,rootHash:g,block:y,...gc(v?.entries??[],w,k)})))),Ti(b),Ae(g=>g instanceof Ne?vt:Hn(()=>g)))},l=e.pipe(ye((v,y)=>v.finalized===y.finalized),Zr(({blocks:v,finalized:y})=>d(null,v.get(y))),Q(1),S(v=>({blocks:{[v.block.hash]:v},finalized:v.block.hash}))),[h,p]=kh(),m=e.pipe(ye((v,y)=>v.best===y.best),jr(h),Zr(([v,y])=>{const{best:b}=v,{blocks:g}=y;let w=g[b]?null:b;if(!w)return vt;const k=wc(w,g,v);return k?d(k,v.blocks.get(w)).pipe(S(I=>(g[w]=I,y))):(w=v.finalized,d(g[y.finalized],v.blocks.get(w)).pipe(S(I=>(I.prev=null,{blocks:{[w]:I},finalized:w}))))}));return un(l,m).pipe(p())}),s=c=>(u,a,f)=>{const d=r(u,a,f),l=xc(u,a),h=c?"finalized":"best";return zt([d.pipe(ef(0)),e.pipe(ye((p,m)=>p[h]===m[h]))]).pipe(S(([p,m])=>wc(m[h],p.blocks,m,!0)),Pe(Boolean),ye(),Oi(null),of(),jr(d),n(([[,p]])=>p.block.hash),S(([[[p,m],v],y])=>[p,m,v,l(y)]),R(([p,m,v,y])=>{if(!p)return[m];let b=m;const g=[];for(;b&&b.block.number>p.block.number;)g.unshift(b),b=b.prev?v.blocks[b.prev]:null;if(c&&(v.finalized=m.block.hash,g.length)){const{blocks:w}=v;Object.keys(w).forEach(k=>{w[k].block.number<g[0].block.number&&delete w[k]})}return p===b?g:[{...m,...p.rootHash===m.rootHash?{entries:p.entries,deltas:null}:gc(p.entries,m.entries,y)}]}))},o=cs(s(!0)),i=cs(s(!1));return(c,u,a,f)=>{const d=f?i:o;return e.pipe(Q(1),R(l=>l.runtimes[l.blocks.get(l[f?"best":"finalized"]).runtime].runtime),S(l=>l.dynamicBuilder.buildStorage(c,u).keys.enc(...a))).pipe(Q(1),R(l=>d(c,u,l)),S(({block:{hash:l,number:h,parent:p},deltas:m,entries:v},y)=>{const b=y>0?m:{deleted:[],upserted:v};return{block:{hash:l,number:h,parent:p},entries:v.map(as),deltas:b&&{deleted:b.deleted.map(as),upserted:b.upserted.map(as)}}}))}},as=e=>e.dec,Ec="RuntimeViewFunction",kc="execute_view_function",us=Ec+"_"+kc,od=(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 f=a[a.length-1],d=Wt(f),{signal:l,at:h}=d?f:{},p=h??null,m=o(n,p).pipe(R(([v,y])=>{let b;try{b=y.dynamicBuilder.buildRuntimeCall(Ec,kc)}catch{throw new Error(`Runtime entry RuntimeCall(${us}) not found`)}let g;try{g=y.dynamicBuilder.buildViewFn(e,t)}catch{throw new Error(`Runtime entry ViewFn(${e}.${t}) not found`)}if(!i(v,y,a))throw u();const w=g.args.enc(a),k=se([me(y.lookup.metadata.pallets.find(({name:I})=>I===e).viewFns.find(({name:I})=>I===t).id),B.enc(w.length),w]);return n.call$(p,us,ee(k)).pipe(S(I=>{try{const T=b.value.dec(I);if(!("success"in T&&"value"in T)||!("type"in T.value)&&!("asBytes"in T.value))throw null;return T}catch{throw new Error(`Unexpected RuntimeCall(${us}) type`)}}),S(({success:I,value:T})=>{if(!I)throw new Error(`ViewFn API Error: ${T.type}`);const x=g.value.dec(T.asBytes());if(!c(v,y,x))throw u();return x}))}),n.withHodl(p));return vn(m,l)},{getCompatibilityLevel:s,isCompatible:r})},id=/^(?:0x)?((?:[0-9a-fA-F][0-9a-fA-F])+)$/,Ac=(e,t,n)=>{const r={},s=v=>new Proxy(r,{get(y,b){return v(b)}}),o=v=>{const y={};return s(b=>(y[b]||(y[b]={}),s(g=>(y[b][g]||(y[b][g]=v(b,g)),y[b][g]))))},i=(v,y)=>v.lookup.metadata.pallets.find(b=>b.name===y),c=sd(t.pinnedBlocks$,t.storage$,t.withRuntime),u=o((v,y)=>$h(v,y,t,c,Rt(e,b=>b.getEntryPoint(gt.Storage,v,y),b=>{const g=i(b,v)?.storage?.items.find(w=>w.name===y);return g==null?null:Qu(g)}))),a=(v,y,b,g)=>{if(b==null)return null;const w=v.lookup(b);if(w.type!=="enum")throw new Error("Expected enum");if(w.value[g]==null)return null;const k=Nu(w.value[g]);return{args:y==="args"?k:Mn,values:y==="args"?Mn:k}},f=o((v,y)=>vc(v,y,t,n,Rt(e,b=>b.getEntryPoint(gt.Tx,v,y),b=>a(b,"args",i(b,v)?.calls?.type,y)),!0)),d=o((v,y)=>Ah(v,y,t,Rt(e,b=>b.getEntryPoint(gt.Event,v,y),b=>a(b,"values",i(b,v)?.events?.type,y)))),l=o((v,y)=>wh(v,y,Rt(e,b=>b.getEntryPoint(gt.Const,v,y),b=>{const g=i(b,v)?.constants.find(w=>w.name===y)?.type;return g==null?null:Zu(g)}))),h=o((v,y)=>Sh(v,y,t,Rt(e,b=>b.getEntryPoint(gt.Api,v,y),b=>No(b.lookup.metadata.apis.find(g=>g.name===v).methods.find(g=>g.name===y))))),p=o((v,y)=>od(v,y,t,Rt(e,b=>b.getEntryPoint(gt.ViewFns,v,y),b=>No(b.lookup.metadata.pallets.find(g=>g.name===v).viewFns.find(g=>g.name===y))))),m=(v,y)=>{const{lookup:b,dynamicBuilder:g}=nr(y).runtime();try{const w=g.buildDefinition(b.call).dec(v.asBytes()),k=w.type,I=w.value.type,T=w.value.value;return vc(k,I,t,n,Rt(e,x=>x.getEntryPoint(gt.Tx,k,I),x=>a(x,"args",i(x,k)?.calls?.type,I)),!1)(T)}catch{throw new Error("createTx: invalid call data")}};return{query:u,txFromCallData:(v,y)=>y?m(v,y):e.then(b=>m(v,b)),tx:f,event:d,apis:h,constants:l,view:p}};function cd(e,{getMetadata:t,setMetadata:n}={}){const r=If(e),s=dh(r,{getMetadata:t?v=>yt(t(v)):void 0,setMetadata:n}),{getChainSpecData:o}=r,{genesis$:i,...c}=s.chainHead$(),u=s.archive(c.getRuntime$),a={...c,genesis$:qn(o).pipe(S(({genesisHash:v})=>v),Ae(()=>i),hn(1)),storage$:Ot(c.storage$,u.storage$),body$:Ot(c.body$,u.body$),call$:Ot(c.call$,u.call$),header$:Ot(c.header$,u.header$),eventsAt$:Ot(c.eventsAt$,u.eventsAt$),storageQueries$:Ot(c.storageQueries$,u.storageQueries$),getRuntimeContext$:Ot(c.getRuntimeContext$,u.getRuntimeContext$)},f=r.request;let d;const l=new WeakMap,h=v=>{const y=l.get(v)||bh(v,a);return l.set(v,y),y},p=()=>d??(d=gh(a)),{broadcastTx$:m}=s;return{getChainSpecData:o,blocks$:a.newBlocks$,finalizedBlock$:a.finalized$,getFinalizedBlock:()=>je(a.finalized$),bestBlocks$:a.bestBlocks$,getBestBlocks:()=>je(a.bestBlocks$),watchBlockBody:a.body$,getBlockBody:v=>je(a.body$(v)),getBlockHeader:v=>je(a.header$(v??null)),submit:(...v)=>pc(a,m,...v),submitAndWatch:v=>os(a,m,v),getTypedApi:v=>{const y=h(v);return Object.assign(Ac(y,a,m),{compatibilityToken:y})},getUnsafeApi:()=>{const v=p();return Object.assign(Ac(v,a,m),{runtimeToken:v})},rawQuery:(v,{at:y,signal:b}={})=>vn(a.storage$(y??null,"value",()=>{const g=v.match(id)?.[1];return g?`0x${g}`:Le.fromText(v).asHex()}),b),destroy:()=>{a.unfollow(),s.destroy()},_request:f}}const ad=(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 f=Le.fromBytes(se([u,c.enc(a)]));return{encodedData:f,decodedCall:$t(e,$t(t,a)),sign:async(d,l)=>ee(await d.signTx(f.asBytes(),s(l),n,l.mortality.mortal?l.mortality.startAtBlock.height:0))}}},ud=async({genesis:e,getMetadata:t})=>{if(!e)throw new Error("Missing genesis hash");const n=me(e),r=await t(),s=Dt(dt.dec(r)),o=Jn(s),i=Kr(o),c=hc(n,o,i),u=p=>s.pallets.find(m=>m.name===p),a={},f=p=>new Proxy(a,{get(m,v){return p(v)}}),d=p=>{const m={};return f(v=>(m[v]||(m[v]={}),f(y=>(m[v][y]||(m[v][y]=p(v,y)),m[v][y]))))},l=d((p,m)=>{const v=u(p)?.constants.find(y=>y.name===m);if(!v)throw new Error(`Runtime entry Constant(${p}.${m}) not found`);return i.buildConstant(p,m).dec(v.value)}),h=d((p,m)=>ad(p,m,r,i,c));return{constants:l,tx:h}},Kt=(e,t)=>(n,r)=>{try{return e(n,r)}catch{throw new Error(`Runtime entry ${t}(${n}.${r}) not found`)}},ld=async e=>{const t=Dt(kr(await e.getMetadata())),n={},r=l=>new Proxy(n,{get(h,p){return l(p)}}),s=l=>{const h={};return r(p=>(h[p]||(h[p]={}),r(m=>(h[p][m]||(h[p][m]=l(p,m)),h[p][m]))))},o=Jn(t),{buildRuntimeCall:i,buildStorage:c,buildConstant:u,buildCall:a,buildEvent:f,buildViewFn:d}=Kr(o);return{query:s((...l)=>{const{value:h,args:p}=Kt(c,"Storage")(...l);return{value:h,args:p}}),tx:s((...l)=>Kt(a,"Call")(...l).codec),event:s((...l)=>Kt(f,"Event")(...l).codec),apis:s(Kt(i,"Runtime API")),constants:s(Kt(u,"Constant")),view:s(Kt(d,"ViewFn"))}};ae.AccountId=kt,ae.Binary=Le,ae.BlockNotPinnedError=Ne,ae.CompatibilityLevel=Oe,ae.Enum=$t,ae.FixedSizeBinary=Bn,ae.InvalidTxError=ss,ae._Enum=uo,ae.createClient=cd,ae.getOfflineApi=ud,ae.getSs58AddressInfo=fr,ae.getTypedCodecs=ld});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.15.2",
3
+ "version": "1.15.4",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -192,24 +192,24 @@
192
192
  },
193
193
  "dependencies": {
194
194
  "@rx-state/core": "^0.1.4",
195
- "@polkadot-api/cli": "0.14.4",
195
+ "@polkadot-api/cli": "0.14.6",
196
196
  "@polkadot-api/ink-contracts": "0.3.7",
197
+ "@polkadot-api/known-chains": "0.9.3",
197
198
  "@polkadot-api/json-rpc-provider": "0.0.4",
198
- "@polkadot-api/known-chains": "0.9.2",
199
199
  "@polkadot-api/logs-provider": "0.0.6",
200
- "@polkadot-api/metadata-builders": "0.13.1",
201
200
  "@polkadot-api/metadata-compatibility": "0.3.2",
202
- "@polkadot-api/observable-client": "0.13.3",
203
- "@polkadot-api/pjs-signer": "0.6.11",
201
+ "@polkadot-api/observable-client": "0.13.4",
202
+ "@polkadot-api/metadata-builders": "0.13.1",
204
203
  "@polkadot-api/polkadot-sdk-compat": "2.3.2",
204
+ "@polkadot-api/pjs-signer": "0.6.11",
205
205
  "@polkadot-api/polkadot-signer": "0.1.6",
206
206
  "@polkadot-api/signer": "0.2.4",
207
207
  "@polkadot-api/sm-provider": "0.1.7",
208
208
  "@polkadot-api/smoldot": "0.3.10",
209
+ "@polkadot-api/substrate-client": "0.4.3",
210
+ "@polkadot-api/utils": "0.2.0",
209
211
  "@polkadot-api/substrate-bindings": "0.15.1",
210
- "@polkadot-api/substrate-client": "0.4.1",
211
- "@polkadot-api/ws-provider": "0.4.1",
212
- "@polkadot-api/utils": "0.2.0"
212
+ "@polkadot-api/ws-provider": "0.4.1"
213
213
  },
214
214
  "devDependencies": {
215
215
  "rxjs": "^7.8.2",