polkadot-api 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(mt,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(mt=typeof globalThis<"u"?globalThis:mt||self,bt(mt.papiInk={}))})(this,function(mt){"use strict";const bt=(t,e)=>t.type==="array"&&t.len===e&&t.value.type==="primitive"&&t.value.value==="u8",lt={type:"void"},qn=(t,e=()=>null)=>{const n=new Map,r=new Set,s=h=>d=>{let o=n.get(d);if(o)return o;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const y=h(d);return o=n.get(d),o?Object.assign(o,y):(o={id:d,...y},n.set(d,o)),r.delete(d),o};let i=!0,c=!0;const a=s(h=>{const d=e(t[h]);if(d)return d;const{def:o,path:y,params:p}=t[h];if(o.tag==="composite"){if(o.value.length===0)return lt;if(o.value.length===1){const f=a(o.value[0].type);return i&&y.at(-1)==="AccountId32"&&bt(f,32)?(i=!1,{type:"AccountId32"}):c&&y.at(-1)==="AccountId20"&&bt(f,20)?(c=!1,{type:"AccountId20"}):f}return l(o.value)}if(o.tag==="variant"){if(y.length===1&&y[0]==="Option"&&p.length===1&&p[0].name==="T"){const E=a(p[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(y.length===1&&y[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:a(p[0].type),ko:a(p[1].type)}};if(o.value.length===0)return lt;const f={},b={};return o.value.forEach(E=>{const O=E.name;if(b[O]=E.docs,E.fields.length===0){f[O]={...lt,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){f[O]={type:"lookupEntry",value:a(E.fields[0].type),idx:E.index};return}f[O]={...l(E.fields),idx:E.index}}),{type:"enum",value:f,innerDocs:b}}if(o.tag==="sequence")return{type:"sequence",value:a(o.value)};if(o.tag==="array"){const{len:f}=o.value,b=a(o.value.type);return!f||b.type==="void"?lt:f>1?{type:"array",value:b,len:o.value.len}:b}if(o.tag==="tuple")return o.value.length===0?lt:o.value.length>1?u(o.value.map(f=>a(f)),o.value.map(f=>t[f].docs)):a(o.value[0]);if(o.tag==="primitive")return{type:"primitive",value:o.value.tag};if(o.tag==="compact"){const f=a(o.value);return f.type==="void"?lt:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:o.tag}}),l=h=>{let d=!0;const o={},y={};return h.forEach((p,f)=>{d=d&&!!p.name;const b=p.name||f,E=a(p.type);E.type!=="void"&&(o[b]=E,y[b]=p.docs)}),d?{type:"struct",value:o,innerDocs:y}:u(Object.values(o),Object.values(y))},u=(h,d)=>{if(h.every(o=>o.id===h[0].id)&&d.every(o=>!o.length)){const[o]=h;return o.type==="void"?lt:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:d}};return a},Xn=t=>qn(t);var zn=Object.defineProperty,Yn=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fe=(t,e,n)=>(Yn(t,typeof e!="symbol"?e+"":e,n),n),Wt={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 Wn(t){const e=t.length%2,n=(t[1]==="x"?2:0)+e,r=(t.length-n)/2+e,s=new Uint8Array(r);e&&(s[0]=0|Wt[t[2]]);for(let i=0;i<r;){const c=n+i*2,a=Wt[t[c]],l=Wt[t[c+1]];s[e+i++]=a<<4|l}return s}var pe=class extends Uint8Array{constructor(t){super(t),fe(this,"i",0),fe(this,"v"),this.v=new DataView(t)}},P=t=>e=>t(e instanceof pe?e:new pe(e instanceof Uint8Array?e.buffer:typeof e=="string"?Wn(e).buffer:e)),z=t=>{const e=t.length;let n=0;for(let s=0;s<e;s++)n+=t[s].length;const r=new Uint8Array(n);for(let s=0,i=0;s<e;s++){const c=t[s];r.set(c,i),i+=c.byteLength}return r};function Tt(t,e){const n=Object.keys(t),r=n.length,s={};for(let i=0;i<r;i++){const c=n[i];s[c]=e(t[c],c)}return s}var Ft=P,$=(t,e)=>{const n=[t,e];return n.enc=t,n.dec=e,n},Gt=(t,e)=>n=>t(e(n)),_t=(t,e)=>n=>e(t(n)),q=([t,e],n,r)=>$(Gt(t,n),_t(e,r));function Fn(t,e){return P(n=>{const r=n.v[e](n.i,!0);return n.i+=t,r})}function Gn(t,e){return n=>{const r=new Uint8Array(t);return new DataView(r.buffer)[e](0,n,!0),r}}function nt(t,e,n){return $(Gn(t,n),Fn(t,e))}var U=nt(1,"getUint8","setUint8"),wt=nt(2,"getUint16","setUint16"),rt=nt(4,"getUint32","setUint32"),Dt=nt(8,"getBigUint64","setBigUint64"),Jn=nt(1,"getInt8","setInt8"),Qn=nt(2,"getInt16","setInt16"),Zn=nt(4,"getInt32","setInt32"),tr=nt(8,"getBigInt64","setBigInt64"),ye=t=>{const e=new Uint8Array(16),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),e},ge=t=>P(e=>{const{v:n,i:r}=e,s=n.getBigUint64(r,!0),i=n[t](r+8,!0);return e.i+=16,i<<64n|s}),er=$(ye,ge("getBigUint64")),nr=$(ye,ge("getBigInt64")),ve=t=>{const e=new Uint8Array(32),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),n.setBigInt64(16,t>>128n,!0),n.setBigInt64(24,t>>192n,!0),e},be=t=>P(e=>{let n=e.v.getBigUint64(e.i,!0);return e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<64n,e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<128n,e.i+=8,n|=e.v[t](e.i,!0)<<192n,e.i+=8,n}),rr=$(ve,be("getBigUint64")),sr=$(ve,be("getBigInt64")),ir=q(U,t=>t?1:0,Boolean),or=[U[1],wt[1],rt[1]],cr=P(t=>{const e=t[t.i],n=e&3;if(n<3)return or[n](t)>>>2;const r=(e>>>2)+4;t.i++;let s=0n;const i=r/8|0;let c=0n;for(let l=0;l<i;l++)s=Dt[1](t)<<c|s,c+=64n;let a=r%8;return a>3&&(s=BigInt(rt[1](t))<<c|s,c+=32n,a-=4),a>1&&(s=BigInt(wt[1](t))<<c|s,c+=16n,a-=2),a&&(s=BigInt(U[1](t))<<c|s),s}),ar=1n<<56n,ur=1<<24,lr=256,hr=4294967295n,dr=64,fr=16384,pr=1<<30,yr=t=>{if(t<0)throw new Error(`Wrong compact input (${t})`);const e=Number(t)<<2;if(t<dr)return U[0](e);if(t<fr)return wt[0](e|1);if(t<pr)return rt[0](e|2);let n=[new Uint8Array(1)],r=BigInt(t);for(;r>=ar;)n.push(Dt[0](r)),r>>=64n;r>=ur&&(n.push(rt[0](Number(r&hr))),r>>=32n);let s=Number(r);s>=lr&&(n.push(wt[0](s)),s>>=16),s&&n.push(U[0](s));const i=z(n);return i[0]=i.length-5<<2|3,i},_=$(yr,cr),gr=new TextEncoder,vr=t=>{const e=gr.encode(t);return z([_.enc(e.length),e])},br=new TextDecoder,wr=P(t=>{let e=_.dec(t);const n=new DataView(t.buffer,t.i,e);return t.i+=e,br.decode(n)}),I=$(vr,wr),mr=()=>{},Er=new Uint8Array(0),w=$(()=>Er,mr),we=t=>t===void 0?e=>z([_.enc(e.length),e]):e=>e.length===t?e:e.slice(0,t),me=t=>P(e=>{const n=t===void 0?_.dec(e):t!==1/0?t:e.byteLength-e.i,r=new Uint8Array(e.buffer.slice(e.i,e.i+n));return e.i+=n,r}),D=t=>$(we(t),me(t));D.enc=we,D.dec=me;var Ee=(t,e)=>{const n=Object.keys(t),r=new Map(e?.map((i,c)=>[n[c],i])??n.map((i,c)=>[i,c])),s=i=>r.get(i);return({tag:i,value:c})=>z([U.enc(s(i)),t[i](c)])},ke=(t,e)=>{const n=Object.keys(t),r=new Map(e?.map((s,i)=>[s,n[i]])??n.map((s,i)=>[i,s]));return P(s=>{const i=U.dec(s),c=r.get(i),a=t[c];return{tag:c,value:a(s)}})},X=(t,...e)=>$(Ee(Tt(t,([n])=>n),...e),ke(Tt(t,([,n])=>n),...e));X.enc=Ee,X.dec=ke;var $e=t=>P(e=>U[1](e)>0?t(e):void 0),xe=t=>e=>{const n=new Uint8Array(1);return e===void 0?n:(n[0]=1,z([n,t(e)]))},j=t=>$(xe(t[0]),$e(t[1]));j.enc=xe,j.dec=$e;var Ae=(t,e)=>P(n=>{const r=U[1](n)===0,i=(r?t:e)(n);return{success:r,value:i}}),Ie=(t,e)=>({success:n,value:r})=>z([U[0](n?0:1),(n?t:e)(r)]),St=(t,e)=>$(Ie(t[0],e[0]),Ae(t[1],e[1]));St.dec=Ae,St.enc=Ie;var Be=(...t)=>P(e=>t.map(n=>n(e))),Oe=(...t)=>e=>z(t.map((n,r)=>n(e[r]))),Y=(...t)=>$(Oe(...t.map(([e])=>e)),Be(...t.map(([,e])=>e)));Y.enc=Oe,Y.dec=Be;var Ue=t=>{const e=Object.keys(t);return Gt(Y.enc(...Object.values(t)),n=>e.map(r=>n[r]))},Le=t=>{const e=Object.keys(t);return _t(Y.dec(...Object.values(t)),n=>Object.fromEntries(n.map((r,s)=>[e[s],r])))},m=t=>$(Ue(Tt(t,e=>e[0])),Le(Tt(t,e=>e[1])));m.enc=Ue,m.dec=Le;var Te=(t,e)=>e>=0?n=>z(n.map(t)):n=>z([_.enc(n.length),z(n.map(t))]),_e=(t,e)=>P(n=>{const r=e>=0?e:_.dec(n),s=new Array(r);for(let i=0;i<r;i++)s[i]=t(n);return s}),x=(t,e)=>$(Te(t[0],e),_e(t[1],e));x.enc=Te,x.dec=_e;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function De(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function Jt(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function Se(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Qt(t){if(!Array.isArray(t))throw new Error("array expected")}function He(t,e){if(!De(!0,e))throw new Error(`${t}: array of strings expected`)}function $r(t,e){if(!De(!1,e))throw new Error(`${t}: array of numbers expected`)}function xr(...t){const e=i=>i,n=(i,c)=>a=>i(c(a)),r=t.map(i=>i.encode).reduceRight(n,e),s=t.map(i=>i.decode).reduce(n,e);return{encode:r,decode:s}}function Ar(t){const e=typeof t=="string"?t.split(""):t,n=e.length;He("alphabet",e);const r=new Map(e.map((s,i)=>[s,i]));return{encode:s=>(Qt(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:s=>(Qt(s),s.map(i=>{Jt("alphabet.decode",i);const c=r.get(i);if(c===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return c}))}}function Ir(t=""){return Jt("join",t),{encode:e=>(He("join.decode",e),e.join(t)),decode:e=>(Jt("join.decode",e),e.split(t))}}function Ce(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Qt(t),!t.length)return[];let r=0;const s=[],i=Array.from(t,a=>{if(Se(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),c=i.length;for(;;){let a=0,l=!0;for(let u=r;u<c;u++){const h=i[u],d=e*a,o=d+h;if(!Number.isSafeInteger(o)||d/e!==a||o-h!==d)throw new Error("convertRadix: carry overflow");const y=o/n;a=o%n;const p=Math.floor(y);if(i[u]=p,!Number.isSafeInteger(p)||p*n+a!==o)throw new Error("convertRadix: carry overflow");if(l)p?l=!1:r=u;else continue}if(s.push(a),l)break}for(let a=0;a<t.length-1&&t[a]===0;a++)s.push(0);return s.reverse()}function Br(t){Se(t);const e=2**8;return{encode:n=>{if(!kr(n))throw new Error("radix.encode input should be Uint8Array");return Ce(Array.from(n),e,t)},decode:n=>($r("radix.decode",n),Uint8Array.from(Ce(n,t,e)))}}const Ne=(t=>xr(Br(58),Ar(t),Ir("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ht(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Or(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ht(t,...e){if(!Or(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Et(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Zt(t,e){Ht(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ur(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function dt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ct(t,e){return t<<32-e|t>>>e}const H=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Me(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const W=H?t=>t:t=>Me(t);function C(t){for(let e=0;e<t.length;e++)t[e]=Me(t[e])}function Lr(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function F(t){return typeof t=="string"&&(t=Lr(t)),Ht(t),t}class Ve{clone(){return this._cloneInto()}}function Tr(t){const e=r=>t().update(F(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function _r(t){const e=(r,s)=>t(s).update(F(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}function Dr(t){const e=(r,s)=>t(s).update(F(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const Sr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,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]);class je extends Ve{constructor(e,n,r={},s,i,c){if(super(),this.blockLen=e,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ht(e),ht(n),ht(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(r.salt!==void 0&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error("personalization must be undefined or "+c);this.buffer=new Uint8Array(e),this.buffer32=dt(this.buffer)}update(e){Et(this);const{blockLen:n,buffer:r,buffer32:s}=this;e=F(e);const i=e.length,c=e.byteOffset,a=e.buffer;for(let l=0;l<i;){this.pos===n&&(H||C(s),this.compress(s,0,!1),H||C(s),this.pos=0);const u=Math.min(n-this.pos,i-l),h=c+l;if(u===n&&!(h%4)&&l+u<i){const d=new Uint32Array(a,h,Math.floor((i-l)/4));H||C(d);for(let o=0;l+n<i;o+=s.length,l+=n)this.length+=n,this.compress(d,o,!1);H||C(d);continue}r.set(e.subarray(l,l+u),this.pos),this.pos+=u,this.length+=u,l+=u}return this}digestInto(e){Et(this),Zt(e,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),H||C(r),this.compress(r,0,!0),H||C(r);const s=dt(e);this.get().forEach((i,c)=>s[c]=W(i))}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){const{buffer:n,length:r,finished:s,destroyed:i,outputLen:c,pos:a}=this;return e||(e=new this.constructor({dkLen:c})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=c,e.buffer.set(n),e.pos=a,e}}const Nt=BigInt(2**32-1),te=BigInt(32);function Mt(t,e=!1){return e?{h:Number(t&Nt),l:Number(t>>te&Nt)}:{h:Number(t>>te&Nt)|0,l:Number(t&Nt)|0}}function Re(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:i,l:c}=Mt(t[s],e);[n[s],r[s]]=[i,c]}return[n,r]}const Hr=(t,e)=>BigInt(t>>>0)<<te|BigInt(e>>>0),Cr=(t,e,n)=>t>>>n,Nr=(t,e,n)=>t<<32-n|e>>>n,Mr=(t,e,n)=>t>>>n|e<<32-n,Vr=(t,e,n)=>t<<32-n|e>>>n,jr=(t,e,n)=>t<<64-n|e>>>n-32,Rr=(t,e,n)=>t>>>n-32|e<<64-n,Pr=(t,e)=>e,Kr=(t,e)=>t,Pe=(t,e,n)=>t<<n|e>>>32-n,Ke=(t,e,n)=>e<<n|t>>>32-n,qe=(t,e,n)=>e<<n-32|t>>>64-n,Xe=(t,e,n)=>t<<n-32|e>>>64-n;function qr(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const N={fromBig:Mt,split:Re,toBig:Hr,shrSH:Cr,shrSL:Nr,rotrSH:Mr,rotrSL:Vr,rotrBH:jr,rotrBL:Rr,rotr32H:Pr,rotr32L:Kr,rotlSH:Pe,rotlSL:Ke,rotlBH:qe,rotlBL:Xe,add:qr,add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,r)=>e+n+r+(t/2**32|0)|0,add4L:(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),add4H:(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,add5H:(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,add5L:(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},B=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function st(t,e,n,r,s,i){const c=s[i],a=s[i+1];let l=g[2*t],u=g[2*t+1],h=g[2*e],d=g[2*e+1],o=g[2*n],y=g[2*n+1],p=g[2*r],f=g[2*r+1],b=N.add3L(l,h,c);u=N.add3H(b,u,d,a),l=b|0,{Dh:f,Dl:p}={Dh:f^u,Dl:p^l},{Dh:f,Dl:p}={Dh:N.rotr32H(f,p),Dl:N.rotr32L(f,p)},{h:y,l:o}=N.add(y,o,f,p),{Bh:d,Bl:h}={Bh:d^y,Bl:h^o},{Bh:d,Bl:h}={Bh:N.rotrSH(d,h,24),Bl:N.rotrSL(d,h,24)},g[2*t]=l,g[2*t+1]=u,g[2*e]=h,g[2*e+1]=d,g[2*n]=o,g[2*n+1]=y,g[2*r]=p,g[2*r+1]=f}function it(t,e,n,r,s,i){const c=s[i],a=s[i+1];let l=g[2*t],u=g[2*t+1],h=g[2*e],d=g[2*e+1],o=g[2*n],y=g[2*n+1],p=g[2*r],f=g[2*r+1],b=N.add3L(l,h,c);u=N.add3H(b,u,d,a),l=b|0,{Dh:f,Dl:p}={Dh:f^u,Dl:p^l},{Dh:f,Dl:p}={Dh:N.rotrSH(f,p,16),Dl:N.rotrSL(f,p,16)},{h:y,l:o}=N.add(y,o,f,p),{Bh:d,Bl:h}={Bh:d^y,Bl:h^o},{Bh:d,Bl:h}={Bh:N.rotrBH(d,h,63),Bl:N.rotrBL(d,h,63)},g[2*t]=l,g[2*t+1]=u,g[2*e]=h,g[2*e+1]=d,g[2*n]=o,g[2*n+1]=y,g[2*r]=p,g[2*r+1]=f}class Xr extends je{constructor(e={}){super(128,e.dkLen===void 0?64:e.dkLen,e,64,16,16),this.v0l=B[0]|0,this.v0h=B[1]|0,this.v1l=B[2]|0,this.v1h=B[3]|0,this.v2l=B[4]|0,this.v2h=B[5]|0,this.v3l=B[6]|0,this.v3h=B[7]|0,this.v4l=B[8]|0,this.v4h=B[9]|0,this.v5l=B[10]|0,this.v5h=B[11]|0,this.v6l=B[12]|0,this.v6h=B[13]|0,this.v7l=B[14]|0,this.v7h=B[15]|0;const n=e.key?e.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,e.salt){const r=dt(F(e.salt));this.v4l^=W(r[0]),this.v4h^=W(r[1]),this.v5l^=W(r[2]),this.v5h^=W(r[3])}if(e.personalization){const r=dt(F(e.personalization));this.v6l^=W(r[0]),this.v6h^=W(r[1]),this.v7l^=W(r[2]),this.v7h^=W(r[3])}if(e.key){const r=new Uint8Array(this.blockLen);r.set(F(e.key)),this.update(r)}}get(){let{v0l:e,v0h:n,v1l:r,v1h:s,v2l:i,v2h:c,v3l:a,v3h:l,v4l:u,v4h:h,v5l:d,v5h:o,v6l:y,v6h:p,v7l:f,v7h:b}=this;return[e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b]}set(e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b){this.v0l=e|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=i|0,this.v2h=c|0,this.v3l=a|0,this.v3h=l|0,this.v4l=u|0,this.v4h=h|0,this.v5l=d|0,this.v5h=o|0,this.v6l=y|0,this.v6h=p|0,this.v7l=f|0,this.v7h=b|0}compress(e,n,r){this.get().forEach((l,u)=>g[u]=l),g.set(B,16);let{h:s,l:i}=N.fromBig(BigInt(this.length));g[24]=B[8]^i,g[25]=B[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const a=Sr;for(let l=0;l<12;l++)st(0,4,8,12,e,n+2*a[c++]),it(0,4,8,12,e,n+2*a[c++]),st(1,5,9,13,e,n+2*a[c++]),it(1,5,9,13,e,n+2*a[c++]),st(2,6,10,14,e,n+2*a[c++]),it(2,6,10,14,e,n+2*a[c++]),st(3,7,11,15,e,n+2*a[c++]),it(3,7,11,15,e,n+2*a[c++]),st(0,5,10,15,e,n+2*a[c++]),it(0,5,10,15,e,n+2*a[c++]),st(1,6,11,12,e,n+2*a[c++]),it(1,6,11,12,e,n+2*a[c++]),st(2,7,8,13,e,n+2*a[c++]),it(2,7,8,13,e,n+2*a[c++]),st(3,4,9,14,e,n+2*a[c++]),it(3,4,9,14,e,n+2*a[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],g.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Vt=_r(t=>new Xr(t)),ze=new TextEncoder().encode("SS58PRE"),ee=2,Ye=t=>{try{const e=Ne.decode(t),n=e.subarray(0,e[0]&64?2:1),r=e.subarray(n.length,e.length-ee),s=e.subarray(n.length+r.length),i=Vt(Uint8Array.of(...ze,...n,...r),{dkLen:64}).subarray(0,ee);return s[0]===i[0]&&s[1]===i[1]?{isValid:!0,ss58Format:zr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},zr=t=>{const e=new DataView(t.buffer,t.byteOffset,t.byteLength);return e.byteLength===1?e.getUint8(0):e.getUint16(0)},We=t=>{const e=t<64?Uint8Array.of(t):Uint8Array.of((t&252)>>2|64,t>>8|(t&3)<<6);return n=>{const r=Vt(Uint8Array.of(...ze,...e,...n),{dkLen:64}).subarray(0,ee);return Ne.encode(Uint8Array.of(...e,...n,...r))}};function Yr(t,e){return n=>{const r=Ye(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==t)throw new Error("Invalid public key length");return s}}const ne=(t=42,e=32)=>q(D(e),Yr(e),We(t)),Fe="0123456789abcdef";function G(t){const e=new Array(t.length+1);e[0]="0x";for(let n=0;n<t.length;){const r=t[n++];e[n]=Fe[r>>4]+Fe[r&15]}return e.join("")}const re={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 kt(t){const e=t.length%2,n=(t[1]==="x"?2:0)+e,r=(t.length-n)/2+e,s=new Uint8Array(r);e&&(s[0]=0|re[t[2]]);for(let i=0;i<r;){const c=n+i*2,a=re[t[c]],l=re[t[c+1]];s[e+i++]=a<<4|l}return s}function Ge(t,e){return Object.fromEntries(Object.entries(t).map(([n,r])=>[n,e(r,n)]))}const ft=(...t)=>{const e=t.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.byteLength}return n};var Wr=Object.defineProperty,Je=t=>{throw TypeError(t)},Fr=(t,e,n)=>e in t?Wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$t=(t,e,n)=>Fr(t,typeof e!="symbol"?e+"":e,n),Qe=(t,e,n)=>e.has(t)||Je("Cannot "+n),J=(t,e,n)=>(Qe(t,e,"read from private field"),n?n.call(t):e.get(t)),xt=(t,e,n)=>e.has(t)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),pt=(t,e,n,r)=>(Qe(t,e,"write to private field"),e.set(t,n),n),Q,At,jt,Rt,Pt;const Gr=new TextEncoder,Jr=new TextDecoder,Qr=Y(_,D(1/0))[1];let Z=class{constructor(e,n=!1){if(xt(this,Q),xt(this,At,null),xt(this,jt,null),xt(this,Rt,null),xt(this,Pt,null),$t(this,"asText",()=>J(this,Pt)??pt(this,Pt,Jr.decode(J(this,Q)))),$t(this,"asHex",()=>J(this,jt)||pt(this,jt,G(J(this,Q)))),$t(this,"asOpaqueHex",()=>J(this,Rt)||pt(this,Rt,G(this.asBytes()))),$t(this,"asBytes",()=>J(this,Q)),$t(this,"asOpaqueBytes",()=>J(this,At)||pt(this,At,ft(_[0](J(this,Q).length),J(this,Q)))),n){try{const[r,s]=Qr(e);if(r===s.length){pt(this,Q,s),pt(this,At,e);return}}catch{}throw new Error("Invalid opaque bytes")}else pt(this,Q,e)}static fromText(e){return new this(Gr.encode(e))}static fromHex(e){return new this(kt(e))}static fromOpaqueHex(e){return new this(kt(e),!0)}static fromBytes(e){return new this(e)}static fromOpaqueBytes(e){return new this(e,!0)}};Q=new WeakMap,At=new WeakMap,jt=new WeakMap,Rt=new WeakMap,Pt=new WeakMap;const[Zr]=ne();let Ze=class extends Z{constructor(e){super(e)}static fromArray(e){return new this(new Uint8Array(e))}static fromAccountId32(e){return new this(Zr(e))}};const tn=t=>{const e=D.enc(t);return n=>e(n.asBytes())},en=t=>{const e=D.dec(t),n=t==null?Z:Ze;return r=>n.fromBytes(e(r))},It=t=>$(tn(t),en(t));It.enc=tn,It.dec=en;const v=_,ts=_,es=Ft(t=>{const e=v.dec(t),n=Math.ceil(e/8);return{bytes:D(n).dec(t),bitsLen:e}}),ns=t=>{if(t.bitsLen>t.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${t.bitsLen}, bytesLen:${t.bytes.length})`);const e=v.enc(t.bitsLen),n=new Uint8Array(t.bytes.length+e.length);return n.set(e,0),n.set(t.bytes,e.length),n},nn=$(ns,es),rs=q(U,t=>t.charCodeAt(0),String.fromCharCode),rn=t=>{const e=D.enc(t);return n=>e(kt(n))},sn=t=>{const e=D.dec(t);return n=>G(e(n))},ot=t=>$(rn(t),sn(t));ot.enc=rn,ot.dec=sn;const ss=new TextEncoder,is=new TextDecoder,os=t=>q(D(t),e=>ss.encode(e),e=>is.decode(e)),on=t=>{let e=n=>{const r=t();return e=r,r(n)};return n=>e(n)},cn=t=>{let e=n=>{const r=t(),s=r;return e=r,s(n)};return n=>e(n)},an=t=>$(on(()=>t().enc),cn(()=>t().dec)),cs={is(t,e){return t.type===e},as(t,e){if(e!==t.type)throw new Error(`Enum.as(enum, ${e}) used with actual type ${t.type}`);return t}},se=Object.assign((t,e)=>({type:t,value:e}),cs),as=new Proxy({},{get(t,e){return n=>se(e,n)}}),un=(...t)=>{const e=X.enc(...t);return n=>e({tag:n.type,value:n.value})},ln=(...t)=>{const e=X.dec(...t);return n=>{const{tag:r,value:s}=e(n);return se(r,s)}},yt=(t,...e)=>$(un(Ge(t,([n])=>n),...e),ln(Ge(t,([,n])=>n),...e));yt.enc=un,yt.dec=ln;const hn=[],dn=[],fn=[],us=BigInt(0),Bt=BigInt(1),ls=BigInt(2),hs=BigInt(7),ds=BigInt(256),fs=BigInt(113);for(let t=0,e=Bt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],hn.push(2*(5*r+n)),dn.push((t+1)*(t+2)/2%64);let s=us;for(let i=0;i<7;i++)e=(e<<Bt^(e>>hs)*fs)%ds,e&ls&&(s^=Bt<<(Bt<<BigInt(i))-Bt);fn.push(s)}const[ps,ys]=Re(fn,!0),pn=(t,e,n)=>n>32?qe(t,e,n):Pe(t,e,n),yn=(t,e,n)=>n>32?Xe(t,e,n):Ke(t,e,n);function gs(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let c=0;c<10;c++)n[c]=t[c]^t[c+10]^t[c+20]^t[c+30]^t[c+40];for(let c=0;c<10;c+=2){const a=(c+8)%10,l=(c+2)%10,u=n[l],h=n[l+1],d=pn(u,h,1)^n[a],o=yn(u,h,1)^n[a+1];for(let y=0;y<50;y+=10)t[c+y]^=d,t[c+y+1]^=o}let s=t[2],i=t[3];for(let c=0;c<24;c++){const a=dn[c],l=pn(s,i,a),u=yn(s,i,a),h=hn[c];s=t[h],i=t[h+1],t[h]=l,t[h+1]=u}for(let c=0;c<50;c+=10){for(let a=0;a<10;a++)n[a]=t[c+a];for(let a=0;a<10;a++)t[c+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=ps[r],t[1]^=ys[r]}n.fill(0)}class ie extends Ve{constructor(e,n,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ht(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=dt(this.state)}keccak(){H||C(this.state32),gs(this.state32,this.rounds),H||C(this.state32),this.posOut=0,this.pos=0}update(e){Et(this);const{blockLen:n,state:r}=this;e=F(e);const s=e.length;for(let i=0;i<s;){const c=Math.min(n-this.pos,s-i);for(let a=0;a<c;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,n&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Et(this,!1),Ht(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zt(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:c}=this;return e||(e=new ie(n,r,s,c,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=c,e.destroyed=this.destroyed,e}}const vs=((t,e,n)=>Tr(()=>new ie(e,t,n)))(1,136,256/8),gn=t=>{const e=t.slice(2),n=G(vs(e)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const i=parseInt(n[s],16),c=e[s];r[s]=i>7?c.toUpperCase():c}return`0x${r.join("")}`},bs=D(20)[1],vn=$(t=>{const e=kt(t);if(e.length!==20)throw new Error(`Invalid length found on EthAddress(${t})`);const n=G(e);if(t===n||t===n.toUpperCase())return e;if(gn(n)!==t)throw new Error(`Invalid checksum found on EthAddress(${t})`);return e},Ft(t=>gn(G(bs(t))))),bn=new TextEncoder,wn=new TextDecoder,ws=q(D(4),bn.encode.bind(bn),wn.decode.bind(wn)),oe=m({engine:ws,payload:ot()}),ms=yt({consensus:oe,seal:oe,preRuntime:oe,runtimeUpdated:w},[4,5,6,8]),ce=ot(32),Es=m({parentHash:ce,number:v,stateRoot:ce,extrinsicRoot:ce,digests:x(ms)}),tt=x(I),mn=j(I),ks=X({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),En=x(m({name:mn,type:v,typeName:mn,docs:tt})),$s=m({len:rt,type:v}),xs=m({bitStoreType:v,bitOrderType:v}),As=x(m({name:I,fields:En,index:U,docs:tt})),Is=X({composite:En,variant:As,sequence:v,array:$s,tuple:x(v),primitive:ks,compact:v,bitSequence:xs}),Bs=m({name:I,type:j(v)}),Os=x(Bs),Us=m({id:v,path:tt,params:Os,def:Is,docs:tt}),Kt=x(Us),Ls=X({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),Ts=x(Ls),_s=m({hashers:Ts,key:v,value:v}),Ds=m({name:I,modifier:U,type:X({plain:v,map:_s}),fallback:ot(),docs:tt}),Ss=j(m({prefix:I,items:x(Ds)})),kn={name:I,storage:Ss,calls:j(v),events:j(v),constants:x(m({name:I,type:v,value:ot(),docs:tt})),errors:j(v),index:U},Hs={...kn,docs:tt},Cs=new Uint8Array,$n=t=>$(()=>Cs,()=>t),Ns=m({type:v,version:U,signedExtensions:x(m({identifier:I,type:v,additionalSigned:v}))}),xn=m({lookup:Kt,pallets:x(m({...kn,docs:$n([])})),extrinsic:Ns,type:v,apis:$n([])}),Ms=m({name:I,methods:x(m({name:I,inputs:x(m({name:I,type:v})),output:v,docs:tt})),docs:tt}),Vs=m({version:U,address:v,call:v,signature:v,extra:v,signedExtensions:x(m({identifier:I,type:v,additionalSigned:v}))}),An=m({lookup:Kt,pallets:x(m(Hs)),extrinsic:Vs,type:v,apis:x(Ms),outerEnums:m({call:v,event:v,error:v}),custom:x(Y(I,m({type:v,value:ot()})))}),In=()=>{throw new Error("Unsupported metadata version!")},M=$(In,In),Ot=m({magicNumber:rt,metadata:X({v0:M,v1:M,v2:M,v3:M,v4:M,v5:M,v6:M,v7:M,v8:M,v9:M,v10:M,v11:M,v12:M,v13:M,v14:xn,v15:An})}),ae=D(),js=j(ae),Rs=Y(_,ae),Ps=t=>{try{return Ot.dec(t)}catch{}try{return Ot.dec(js.dec(t))}catch{}try{return Ot.dec(ae.dec(t))}catch{}try{return Ot.dec(Rs.dec(t)[1])}catch{}throw null},Ks={dkLen:32},ue=t=>Vt(t,Ks),qs={dkLen:16},le=t=>Vt(t,qs),Bn=t=>ft(le(t),t),et=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ct(t,e,n,r,s){return t=t+e+s|0,r=Ct(r^t,16),n=n+r|0,e=Ct(e^n,12),{a:t,b:e,c:n,d:r}}function at(t,e,n,r,s){return t=t+e+s|0,r=Ct(r^t,8),n=n+r|0,e=Ct(e^n,7),{a:t,b:e,c:n,d:r}}function On(t,e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b,E,O,V){let A=0;for(let vt=0;vt<r;vt++)({a:s,b:l,c:o,d:b}=ct(s,l,o,b,n[e+t[A++]])),{a:s,b:l,c:o,d:b}=at(s,l,o,b,n[e+t[A++]]),{a:i,b:u,c:y,d:E}=ct(i,u,y,E,n[e+t[A++]]),{a:i,b:u,c:y,d:E}=at(i,u,y,E,n[e+t[A++]]),{a:c,b:h,c:p,d:O}=ct(c,h,p,O,n[e+t[A++]]),{a:c,b:h,c:p,d:O}=at(c,h,p,O,n[e+t[A++]]),{a,b:d,c:f,d:V}=ct(a,d,f,V,n[e+t[A++]]),{a,b:d,c:f,d:V}=at(a,d,f,V,n[e+t[A++]]),{a:s,b:u,c:p,d:V}=ct(s,u,p,V,n[e+t[A++]]),{a:s,b:u,c:p,d:V}=at(s,u,p,V,n[e+t[A++]]),{a:i,b:h,c:f,d:b}=ct(i,h,f,b,n[e+t[A++]]),{a:i,b:h,c:f,d:b}=at(i,h,f,b,n[e+t[A++]]),{a:c,b:d,c:o,d:E}=ct(c,d,o,E,n[e+t[A++]]),{a:c,b:d,c:o,d:E}=at(c,d,o,E,n[e+t[A++]]),{a,b:l,c:y,d:O}=ct(a,l,y,O,n[e+t[A++]]),{a,b:l,c:y,d:O}=at(a,l,y,O,n[e+t[A++]]);return{v0:s,v1:i,v2:c,v3:a,v4:l,v5:u,v6:h,v7:d,v8:o,v9:y,v10:p,v11:f,v12:b,v13:E,v14:O,v15:V}}var K;(function(t){t[t.CHUNK_START=1]="CHUNK_START",t[t.CHUNK_END=2]="CHUNK_END",t[t.PARENT=4]="PARENT",t[t.ROOT=8]="ROOT",t[t.KEYED_HASH=16]="KEYED_HASH",t[t.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",t[t.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(K||(K={}));const Un=(()=>{const t=Array.from({length:16},(r,s)=>s),e=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=t;r<7;r++,s=e(s))n.push(...s);return Uint8Array.from(n)})();class he extends je{constructor(e={},n=0){if(super(64,e.dkLen===void 0?32:e.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=e.dkLen===void 0?32:e.dkLen,ht(this.outputLen),e.key!==void 0&&e.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(e.key!==void 0){const r=F(e.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=dt(r),H||C(this.IV),this.flags=n|K.KEYED_HASH}else if(e.context!==void 0){const r=new he({dkLen:32},K.DERIVE_KEY_CONTEXT).update(e.context).digest();this.IV=dt(r),H||C(this.IV),this.flags=n|K.DERIVE_KEY_MATERIAL}else this.IV=et.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Ur(this.bufferOut32)}get(){return[]}set(){}b2Compress(e,n,r,s=0){const{state:i,pos:c}=this,{h:a,l}=Mt(BigInt(e),!0),{v0:u,v1:h,v2:d,v3:o,v4:y,v5:p,v6:f,v7:b,v8:E,v9:O,v10:V,v11:A,v12:vt,v13:zt,v14:Yt,v15:$i}=On(Un,s,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],et[0],et[1],et[2],et[3],a,l,c,n);i[0]=u^E,i[1]=h^O,i[2]=d^V,i[3]=o^A,i[4]=y^vt,i[5]=p^zt,i[6]=f^Yt,i[7]=b^$i}compress(e,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=K.CHUNK_START),(this.chunkPos===15||r)&&(s|=K.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,e,n),this.chunkPos+=1,this.chunkPos===16||r){let i=this.state;this.state=this.IV.slice();for(let c,a=this.chunksDone+1;(r||!(a&1))&&(c=this.stack.pop());a>>=1)this.buffer32.set(c,0),this.buffer32.set(i,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|K.PARENT,this.buffer32,0),i=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(i)}this.pos=0}_cloneInto(e){e=super._cloneInto(e);const{IV:n,flags:r,state:s,chunkPos:i,posOut:c,chunkOut:a,stack:l,chunksDone:u}=this;return e.state.set(s.slice()),e.stack=l.map(h=>Uint32Array.from(h)),e.IV.set(n),e.flags=r,e.chunkPos=i,e.chunksDone=u,e.posOut=c,e.chunkOut=a,e.enableXOF=this.enableXOF,e.bufferOut32.set(this.bufferOut32),e}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let e of this.stack)e.fill(0)}b2CompressOut(){const{state:e,pos:n,flags:r,buffer32:s,bufferOut32:i}=this,{h:c,l:a}=Mt(BigInt(this.chunkOut++));H||C(s);const{v0:l,v1:u,v2:h,v3:d,v4:o,v5:y,v6:p,v7:f,v8:b,v9:E,v10:O,v11:V,v12:A,v13:vt,v14:zt,v15:Yt}=On(Un,0,s,7,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],et[0],et[1],et[2],et[3],a,c,n,r);i[0]=l^b,i[1]=u^E,i[2]=h^O,i[3]=d^V,i[4]=o^A,i[5]=y^vt,i[6]=p^zt,i[7]=f^Yt,i[8]=e[0]^b,i[9]=e[1]^E,i[10]=e[2]^O,i[11]=e[3]^V,i[12]=e[4]^A,i[13]=e[5]^vt,i[14]=e[6]^zt,i[15]=e[7]^Yt,H||(C(s),C(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let e=this.flags|K.ROOT;this.stack.length?(e|=K.PARENT,H||C(this.buffer32),this.compress(this.buffer32,0,!0),H||C(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):e|=(this.chunkPos?0:K.CHUNK_START)|K.CHUNK_END,this.flags=e,this.b2CompressOut()}writeInto(e){Et(this,!1),Ht(e),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,i-s);e.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(e)}xof(e){return ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zt(e,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Xs=Dr(t=>new he(t)),zs={dkLen:32},Ln=t=>Xs(t,zs),Ys=t=>ft(Ln(t),t),Tn=t=>t,gt=(t,e,n,r)=>new DataView(new Uint16Array([t,e,n,r]).buffer).getBigUint64(0,!0),de=2n**64n-1n,S=(t,e)=>t<<e&de|t>>64n-e,k=(t,e)=>t*e&de,L=(t,e)=>t+e&de,T=11400714785074694791n,R=14029467366897019727n,_n=1609587929392839161n,Ut=9650029242287828579n,Dn=2870177450012600261n;function ut(t,e=0n){let n=L(L(e,T),R),r=L(e,R),s=e,i=e-T,c=t.length,a=0,l=null;(function(){let o=0,y=o+c;if(c){if(l=new Uint8Array(32),c<32){l.set(t.subarray(0,c),a),a+=c;return}if(o<=y-32){const p=y-32;do{let f;f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),n=k(S(L(n,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),r=k(S(L(r,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),s=k(S(L(s,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),i=k(S(L(i,k(f,R)),31n),T),o+=8}while(o<=p)}o<y&&(l.set(t.subarray(o,y),a),a=y-o)}})(),t=l||t;let u,h=0;for(c>=32?(u=S(n,1n),u=L(u,S(r,7n)),u=L(u,S(s,12n)),u=L(u,S(i,18n)),n=k(S(k(n,R),31n),T),u=u^n,u=L(k(u,T),Ut),r=k(S(k(r,R),31n),T),u=u^r,u=L(k(u,T),Ut),s=k(S(k(s,R),31n),T),u=u^s,u=L(k(u,T),Ut),i=k(S(k(i,R),31n),T),u=u^i,u=L(k(u,T),Ut)):u=L(e,Dn),u=L(u,BigInt(c));h<=a-8;){let o=gt(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2],t[h+5]<<8|t[h+4],t[h+7]<<8|t[h+6]);o=k(S(k(o,R),31n),T),u=L(k(S(u^o,27n),T),Ut),h+=8}if(h+4<=a){let o=k(gt(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2],0,0),T);u=L(k(S(u^o,23n),R),_n),h+=4}for(;h<a;){const o=k(gt(t[h++],0,0,0),Dn);u=k(S(u^o,11n),T)}let d=u>>33n;return u=k(u^d,R),d=u>>29n,u=k(u^d,_n),d=u>>32n,u^=d,u}const qt=t=>{const e=new Uint8Array(16),n=new DataView(e.buffer);return n.setBigUint64(0,ut(t),!0),n.setBigUint64(8,ut(t,1n),!0),e},Sn=t=>{const e=new Uint8Array(32),n=new DataView(e.buffer);return n.setBigUint64(0,ut(t),!0),n.setBigUint64(8,ut(t,1n),!0),n.setBigUint64(16,ut(t,2n),!0),n.setBigUint64(24,ut(t,3n),!0),e},Hn=t=>ft(Dt.enc(ut(t)),t),Cn=new TextEncoder,Ws=new Map([[Tn,0],[Hn,8],[Bn,16],[le,-16],[ue,-32],[qt,-16],[Sn,-32]]),Fs=t=>{const e=qt(Cn.encode(t));return(n,...r)=>{const s=ft(e,qt(Cn.encode(n))),i=G(s),c=l=>{if(!l.startsWith(i))throw new Error(`key does not match this storage (${t}.${n})`);if(r.length===0)return[];const u=kt(l.slice(i.length)),h=new Array(r.length);for(let d=0,o=0;d<r.length;d++){const[y,p]=r[d],f=Ws.get(p);if(f==null)throw new Error("Unknown hasher");if(f<0){const b=f*-1;h[d]=G(u.slice(o,o+b)),o+=b}else o+=f,h[d]=y.dec(u.slice(o)),o+=y.enc(h[d]).length}return h},a=r.map(([{enc:l},u])=>h=>u(l(h)));return{enc:(...l)=>G(ft(s,...l.map((u,h)=>a[h](u)))),dec:c}}},Gs=Z.fromText("modlpy/utilisuba").asBytes(),Js=({threshold:t,signatories:e})=>{const n=Nn(e),r=ft(Gs,_.enc(n.length),...n,wt.enc(t));return ue(r)},Nn=t=>t.slice().sort((e,n)=>{for(let r=0;;r++){const s=r>=e.length,i=r>=n.length;if(s&&i)return 0;if(s)return-1;if(i)return 1;if(e[r]!==n[r])return e[r]>n[r]?1:-1}});var Qs=Object.freeze({__proto__:null,AccountId:ne,Bin:It,Binary:Z,Blake2128:le,Blake2128Concat:Bn,Blake2256:ue,Blake3256:Ln,Blake3256Concat:Ys,Bytes:D,Enum:se,FixedSizeBinary:Ze,Hex:ot,Identity:Tn,Option:j,Result:St,ScaleEnum:X,Self:an,Storage:Fs,Struct:m,Tuple:Y,Twox128:qt,Twox256:Sn,Twox64Concat:Hn,Variant:yt,Vector:x,_Enum:as,_void:w,bitSequence:nn,blockHeader:Es,bool:ir,char:rs,compact:_,compactBn:ts,compactNumber:v,createCodec:$,createDecoder:Ft,decAnyMetadata:Ps,enhanceCodec:q,enhanceDecoder:_t,enhanceEncoder:Gt,ethAccount:vn,fixedStr:os,fromBufferToBase58:We,getMultisigAccountId:Js,getSs58AddressInfo:Ye,h64:ut,i128:nr,i16:Qn,i256:sr,i32:Zn,i64:tr,i8:Jn,metadata:Ot,selfDecoder:cn,selfEncoder:on,sortMultisigSignatories:Nn,str:I,u128:er,u16:wt,u256:rr,u32:rt,u64:Dt,u8:U,v14:xn,v14Lookup:Kt,v15:An});const Zs=(t,e,n)=>(r,s,i,...c)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(i.has(a)){const u=e(()=>s.get(a),r,...c);return s.set(a,u),u}i.add(a);let l=t(r,s,i,...c);return i.delete(a),s.has(a)&&(l=n(l,s.get(a),r,...c)),s.set(a,l),l},ti=It(),ei=$(_[0],_t(_[1],BigInt)),ni=(t,e,n,r)=>{if(t.type==="primitive")return Qs[t.value];if(t.type==="void")return w;if(t.type==="AccountId32")return r;if(t.type==="AccountId20")return vn;if(t.type==="compact")return t.isBig?ei:_;if(t.type==="bitSequence")return nn;const s=o=>Mn(o,e,n,r),i=(o,y)=>{const p=s(o);return y?x(p,y):x(p)},c=o=>Y(...o.map(s)),a=o=>{const y=Object.fromEntries(Object.entries(o).map(([p,f])=>[p,s(f)]));return m(y)};if(t.type==="sequence"&&t.value.type==="primitive"&&t.value.value==="u8")return ti;if(t.type==="array")return t.value.type==="primitive"&&t.value.value==="u8"?It(t.len):i(t.value,t.len);if(t.type==="sequence")return i(t.value);if(t.type==="tuple")return c(t.value);if(t.type==="struct")return a(t.value);if(t.type==="option")return j(s(t.value));if(t.type==="result")return St(s(t.value.ok),s(t.value.ko));const l=Object.values(t.value).map(o=>{switch(o.type){case"void":return w;case"lookupEntry":return s(o.value);case"tuple":return c(o.value);case"struct":return a(o.value);case"array":return i(o.value,o.len)}}),u=Object.fromEntries(Object.keys(t.value).map((o,y)=>[o,l[y]])),h=Object.values(t.value).map(o=>o.idx),d=h.every((o,y)=>o===y)?yt(u):yt(u,h);return t.byteLength?si(d,t.byteLength):d},Mn=Zs(ni,an,t=>t),ri=(t,e=ne())=>{const n=new Map,r=s=>Mn(t(s),n,new Set,e);return s=>r(s)},si=(t,e)=>{const n=D(e);return $(r=>n.enc(t.enc(r)),r=>t.dec(n.dec(r)))},ii=t=>{const{metadata:e}=t,n=ri(t),r=(l="")=>{const u=t.storage[l];if(!u)throw new Error(`Storage entry ${l||"{root}"} not found`);const h=u.key==null?w:n(u.key);return{key:Vn(h,u.keyPrefix),value:n(u.typeId)}},s=l=>{const u=m(Object.fromEntries(l.args.map(h=>[h.label,n(h.type.type)])));return{call:Vn(u,l.selector),value:n(l.returnType.type)}},i=l=>{const u=e.spec.constructors.find(h=>h.label===l);if(!u)throw new Error(`Constructor ${l} not found`);return s(u)},c=l=>{const u=e.spec.messages.find(h=>h.label===l);if(!u)throw new Error(`Message ${l} not found`);return s(u)},a=l=>m(Object.fromEntries(l.args.map(u=>[u.label,n(u.type.type)])));return{buildConstructor:i,buildMessage:c,buildStorage:r,buildEvents:()=>yt(Object.fromEntries(e.spec.events.map(l=>[l.label,a(l)]))),buildEvent:l=>{const u=e.spec.events,h=(o,y)=>q(o,p=>p.value,p=>({type:y,value:p}));if(l){const o=u.find(y=>y.signature_topic===l);return o?h(a(o),o.label):null}const d=u.filter(o=>o.signature_topic===l);return d.length?oi(d.map(o=>h(a(o),o.label))):null}}},Vn=(t,e)=>{const n=Z.fromHex(e).asBytes(),r=Y(D(n.length),t);return q(r,s=>[n,s],([,s])=>s)},oi=t=>$(e=>{for(const n of t)try{n.enc(e)}catch{}throw new Error("Unable to encode")},e=>{for(const n of t)try{n.dec(e)}catch{}throw new Error("Unable to decode")}),jn=t=>q(X(t),e=>{if(typeof e=="string")return{tag:e,value:void 0};const[n,r]=Object.entries(e)[0];return{tag:n,value:r}},e=>({[e.tag]:e.value})),Lt=(t,e)=>q(x(t,e),n=>n??[],n=>n),Rn=j(I),Xt=Lt(I),ci=jn({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),Pn=Lt(m({name:Rn,type:v,typeName:Rn,docs:Xt})),ai=m({len:rt,type:v}),ui=m({bitStoreType:v,bitOrderType:v}),li=Lt(m({name:I,fields:Pn,index:U,docs:Xt})),hi=jn({composite:m({fields:Pn}),variant:m({variants:li}),sequence:m({type:v}),array:ai,tuple:x(v),primitive:ci,compact:v,bitSequence:ui}),di=m({name:I,type:j(v)}),fi=Lt(di),pi=m({id:v,path:Xt,params:fi,def:hi,docs:Xt}),yi=q(pi,t=>({id:t.id,path:t.type.path,params:t.type.params??[],def:t.type.def,docs:[]}),t=>({id:t.id,type:{def:t.def,path:t.path,params:t.params}})),gi=Lt(yi),vi=t=>{const e=gi.enc(t.types),n=Kt.dec(e),r=t.spec.environment.accountId.type,s=n.find(a=>a.id===r);s&&(s.path=["AccountId32"]);const i=bi(t,n),c=Xn(n);return Object.assign(c,{metadata:t,lookup:n,storage:i})};function bi(t,e){const n={},r=(s,i=[])=>{function c(l){const u=e.length;return e[u]={id:u,docs:[],def:l,params:[],path:[]},u}if("root"in s){const l=Number(t.version)===4?Z.fromBytes(Z.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,u=r(s.root.layout,i);if(s.root.ty!=null){let h=function(d,o){const y=t.types[d].type,p="composite"in y.def?new Map((y.def.composite.fields??[]).map(b=>[b.name,b.type])):null,f=new Map((y.params??[]).map(b=>[b.name,b.type]));if(f.size===2&&f.has("V")&&p&&p.size===2&&p.has("len")&&p.has("elements")){h(p.get("len"),[...o,"len"]),h(p.get("elements"),o);return}else f.size===3&&f.has("K")&&f.has("V")?n[o.join(".")]={keyPrefix:l,key:f.get("K"),typeId:f.get("V")}:f.size===2&&f.has("V")&&(n[o.join(".")]={keyPrefix:l,key:null,typeId:f.get("V")})};h(s.root.ty,i)}return n[i.join(".")]||(n[i.join(".")]={keyPrefix:l,key:null,typeId:u}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const l=r(s.array.layout,i);return l==null?null:c({tag:"array",value:{len:s.array.len,type:l}})}if("struct"in s){const l=s.struct.fields.map(u=>({name:u.name,type:r(u.layout,[...i,u.name]),typeName:void 0,docs:[]})).filter(u=>u.type!=null);return c({tag:"composite",value:l})}const a=Object.values(s.enum.variants).map((l,u)=>({name:l.name,fields:l.fields.map(h=>({name:h.name,type:r(h.layout,[...i,l.name,h.name]),typeName:void 0,docs:[]})).filter(h=>h.type!==null),index:u,docs:[]}));return c({tag:"variant",value:a})};return r(t.storage),n}const wi=t=>{const e=vi(t.metadata),n=ii(e);return{constructor:Kn(n.buildConstructor),message:Kn(n.buildMessage),storage:mi(n.buildStorage),event:Number(e.metadata.version)===4?Ei(n.buildEvents):ki(e,n.buildEvent)}},Kn=t=>e=>{const n=t(e);return{encode:r=>Z.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},mi=t=>e=>{const n=t(e);return{encode:r=>Z.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},Ei=t=>{const e=n=>t().dec(n.data.asBytes());return{decode:e,filter:(n,r=[])=>r.map(s=>"event"in s?s.event:s).filter(s=>s.type==="Contracts"&&s.value.type==="ContractEmitted"&&s.value.value.contract===n).map(s=>{try{return e(s.value.value)}catch(i){throw console.error(`Contract ${n} emitted an incompatible event`,s.value.value),i}})}},ki=(t,e)=>{const n=new Set(t.metadata.spec.events.map(i=>i.signature_topic).filter(i=>i!=null)),r=t.metadata.spec.events.some(i=>i.signature_topic==null),s=(i,c)=>{if(c!=null){if(!n.has(c))throw new Error(`Event with signature topic ${i} not found`);return e(c).dec(i.data.asBytes())}if(!r)throw new Error("Event signature topic required");return e(void 0).dec(i.data.asBytes())};return{decode:s,filter:(i,c=[])=>c.map(a=>"event"in a?a:{event:a,topics:a.topics}).filter(a=>a.event.type==="Contracts"&&a.event.value.type==="ContractEmitted"&&a.event.value.value.contract===i).map(a=>{const l=a.topics.map(h=>h.asHex()),u=l.find(h=>n.has(h));try{return s(a.event.value.value,u)}catch{return console.error(`Contract ${i} emitted an incompatible event`,{event:a.event.value.value.data.asHex(),eventTopics:l,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(a=>a!==null)}};mt.getInkClient=wi});
1
+ (function(mt,bt){typeof exports=="object"&&typeof module<"u"?bt(exports):typeof define=="function"&&define.amd?define(["exports"],bt):(mt=typeof globalThis<"u"?globalThis:mt||self,bt(mt.papiInk={}))})(this,function(mt){"use strict";const bt=(t,e)=>t.type==="array"&&t.len===e&&t.value.type==="primitive"&&t.value.value==="u8",lt={type:"void"},qn=(t,e=()=>null)=>{const n=new Map,r=new Set,s=h=>d=>{let o=n.get(d);if(o)return o;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const y=h(d);return o=n.get(d),o?Object.assign(o,y):(o={id:d,...y},n.set(d,o)),r.delete(d),o};let i=!0,c=!0;const a=s(h=>{const d=e(t[h]);if(d)return d;const{def:o,path:y,params:p}=t[h];if(o.tag==="composite"){if(o.value.length===0)return lt;if(o.value.length===1){const f=a(o.value[0].type);return i&&y.at(-1)==="AccountId32"&&bt(f,32)?(i=!1,{type:"AccountId32"}):c&&y.at(-1)==="AccountId20"&&bt(f,20)?(c=!1,{type:"AccountId20"}):f}return l(o.value)}if(o.tag==="variant"){if(y.length===1&&y[0]==="Option"&&p.length===1&&p[0].name==="T"){const E=a(p[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(y.length===1&&y[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:a(p[0].type),ko:a(p[1].type)}};if(o.value.length===0)return lt;const f={},b={};return o.value.forEach(E=>{const O=E.name;if(b[O]=E.docs,E.fields.length===0){f[O]={...lt,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){f[O]={type:"lookupEntry",value:a(E.fields[0].type),idx:E.index};return}f[O]={...l(E.fields),idx:E.index}}),{type:"enum",value:f,innerDocs:b}}if(o.tag==="sequence")return{type:"sequence",value:a(o.value)};if(o.tag==="array"){const{len:f}=o.value,b=a(o.value.type);return!f||b.type==="void"?lt:f>1?{type:"array",value:b,len:o.value.len}:b}if(o.tag==="tuple")return o.value.length===0?lt:o.value.length>1?u(o.value.map(f=>a(f)),o.value.map(f=>t[f].docs)):a(o.value[0]);if(o.tag==="primitive")return{type:"primitive",value:o.value.tag};if(o.tag==="compact"){const f=a(o.value);return f.type==="void"?lt:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:o.tag}}),l=h=>{let d=!0;const o={},y={};return h.forEach((p,f)=>{d=d&&!!p.name;const b=p.name||f,E=a(p.type);E.type!=="void"&&(o[b]=E,y[b]=p.docs)}),d?{type:"struct",value:o,innerDocs:y}:u(Object.values(o),Object.values(y))},u=(h,d)=>{if(h.every(o=>o.id===h[0].id)&&d.every(o=>!o.length)){const[o]=h;return o.type==="void"?lt:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:d}};return a},Xn=t=>qn(t);var zn=Object.defineProperty,Yn=(t,e,n)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,fe=(t,e,n)=>(Yn(t,typeof e!="symbol"?e+"":e,n),n),Wt={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 Wn(t){const e=t.length%2,n=(t[1]==="x"?2:0)+e,r=(t.length-n)/2+e,s=new Uint8Array(r);e&&(s[0]=0|Wt[t[2]]);for(let i=0;i<r;){const c=n+i*2,a=Wt[t[c]],l=Wt[t[c+1]];s[e+i++]=a<<4|l}return s}var pe=class extends Uint8Array{constructor(t){super(t),fe(this,"i",0),fe(this,"v"),this.v=new DataView(t)}},P=t=>e=>t(e instanceof pe?e:new pe(e instanceof Uint8Array?e.buffer:typeof e=="string"?Wn(e).buffer:e)),z=t=>{const e=t.length;let n=0;for(let s=0;s<e;s++)n+=t[s].length;const r=new Uint8Array(n);for(let s=0,i=0;s<e;s++){const c=t[s];r.set(c,i),i+=c.byteLength}return r};function Tt(t,e){const n=Object.keys(t),r=n.length,s={};for(let i=0;i<r;i++){const c=n[i];s[c]=e(t[c],c)}return s}var Ft=P,$=(t,e)=>{const n=[t,e];return n.enc=t,n.dec=e,n},Gt=(t,e)=>n=>t(e(n)),_t=(t,e)=>n=>e(t(n)),q=([t,e],n,r)=>$(Gt(t,n),_t(e,r));function Fn(t,e){return P(n=>{const r=n.v[e](n.i,!0);return n.i+=t,r})}function Gn(t,e){return n=>{const r=new Uint8Array(t);return new DataView(r.buffer)[e](0,n,!0),r}}function nt(t,e,n){return $(Gn(t,n),Fn(t,e))}var U=nt(1,"getUint8","setUint8"),wt=nt(2,"getUint16","setUint16"),rt=nt(4,"getUint32","setUint32"),Dt=nt(8,"getBigUint64","setBigUint64"),Jn=nt(1,"getInt8","setInt8"),Qn=nt(2,"getInt16","setInt16"),Zn=nt(4,"getInt32","setInt32"),tr=nt(8,"getBigInt64","setBigInt64"),ye=t=>{const e=new Uint8Array(16),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),e},ge=t=>P(e=>{const{v:n,i:r}=e,s=n.getBigUint64(r,!0),i=n[t](r+8,!0);return e.i+=16,i<<64n|s}),er=$(ye,ge("getBigUint64")),nr=$(ye,ge("getBigInt64")),ve=t=>{const e=new Uint8Array(32),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),n.setBigInt64(16,t>>128n,!0),n.setBigInt64(24,t>>192n,!0),e},be=t=>P(e=>{let n=e.v.getBigUint64(e.i,!0);return e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<64n,e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<128n,e.i+=8,n|=e.v[t](e.i,!0)<<192n,e.i+=8,n}),rr=$(ve,be("getBigUint64")),sr=$(ve,be("getBigInt64")),ir=q(U,t=>t?1:0,Boolean),or=[U[1],wt[1],rt[1]],cr=P(t=>{const e=t[t.i],n=e&3;if(n<3)return or[n](t)>>>2;const r=(e>>>2)+4;t.i++;let s=0n;const i=r/8|0;let c=0n;for(let l=0;l<i;l++)s=Dt[1](t)<<c|s,c+=64n;let a=r%8;return a>3&&(s=BigInt(rt[1](t))<<c|s,c+=32n,a-=4),a>1&&(s=BigInt(wt[1](t))<<c|s,c+=16n,a-=2),a&&(s=BigInt(U[1](t))<<c|s),s}),ar=1n<<56n,ur=1<<24,lr=256,hr=4294967295n,dr=64,fr=16384,pr=1<<30,yr=t=>{if(t<0)throw new Error(`Wrong compact input (${t})`);const e=Number(t)<<2;if(t<dr)return U[0](e);if(t<fr)return wt[0](e|1);if(t<pr)return rt[0](e|2);let n=[new Uint8Array(1)],r=BigInt(t);for(;r>=ar;)n.push(Dt[0](r)),r>>=64n;r>=ur&&(n.push(rt[0](Number(r&hr))),r>>=32n);let s=Number(r);s>=lr&&(n.push(wt[0](s)),s>>=16),s&&n.push(U[0](s));const i=z(n);return i[0]=i.length-5<<2|3,i},_=$(yr,cr),gr=new TextEncoder,vr=t=>{const e=gr.encode(t);return z([_.enc(e.length),e])},br=new TextDecoder,wr=P(t=>{let e=_.dec(t);const n=new DataView(t.buffer,t.i,e);return t.i+=e,br.decode(n)}),I=$(vr,wr),mr=()=>{},Er=new Uint8Array(0),w=$(()=>Er,mr),we=t=>t===void 0?e=>z([_.enc(e.length),e]):e=>e.length===t?e:e.slice(0,t),me=t=>P(e=>{const n=t===void 0?_.dec(e):t!==1/0?t:e.byteLength-e.i,r=new Uint8Array(e.buffer.slice(e.i,e.i+n));return e.i+=n,r}),D=t=>$(we(t),me(t));D.enc=we,D.dec=me;var Ee=(t,e)=>{const n=Object.keys(t),r=new Map(e?.map((i,c)=>[n[c],i])??n.map((i,c)=>[i,c])),s=i=>r.get(i);return({tag:i,value:c})=>z([U.enc(s(i)),t[i](c)])},ke=(t,e)=>{const n=Object.keys(t),r=new Map(e?.map((s,i)=>[s,n[i]])??n.map((s,i)=>[i,s]));return P(s=>{const i=U.dec(s),c=r.get(i),a=t[c];return{tag:c,value:a(s)}})},X=(t,...e)=>$(Ee(Tt(t,([n])=>n),...e),ke(Tt(t,([,n])=>n),...e));X.enc=Ee,X.dec=ke;var $e=t=>P(e=>U[1](e)>0?t(e):void 0),xe=t=>e=>{const n=new Uint8Array(1);return e===void 0?n:(n[0]=1,z([n,t(e)]))},j=t=>$(xe(t[0]),$e(t[1]));j.enc=xe,j.dec=$e;var Ae=(t,e)=>P(n=>{const r=U[1](n)===0,i=(r?t:e)(n);return{success:r,value:i}}),Ie=(t,e)=>({success:n,value:r})=>z([U[0](n?0:1),(n?t:e)(r)]),St=(t,e)=>$(Ie(t[0],e[0]),Ae(t[1],e[1]));St.dec=Ae,St.enc=Ie;var Be=(...t)=>P(e=>t.map(n=>n(e))),Oe=(...t)=>e=>z(t.map((n,r)=>n(e[r]))),Y=(...t)=>$(Oe(...t.map(([e])=>e)),Be(...t.map(([,e])=>e)));Y.enc=Oe,Y.dec=Be;var Ue=t=>{const e=Object.keys(t);return Gt(Y.enc(...Object.values(t)),n=>e.map(r=>n[r]))},Le=t=>{const e=Object.keys(t);return _t(Y.dec(...Object.values(t)),n=>Object.fromEntries(n.map((r,s)=>[e[s],r])))},m=t=>$(Ue(Tt(t,e=>e[0])),Le(Tt(t,e=>e[1])));m.enc=Ue,m.dec=Le;var Te=(t,e)=>e>=0?n=>z(n.map(t)):n=>z([_.enc(n.length),z(n.map(t))]),_e=(t,e)=>P(n=>{const r=e>=0?e:_.dec(n),s=new Array(r);for(let i=0;i<r;i++)s[i]=t(n);return s}),x=(t,e)=>$(Te(t[0],e),_e(t[1],e));x.enc=Te,x.dec=_e;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function De(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(n=>typeof n=="string"):e.every(n=>Number.isSafeInteger(n)):!1}function Jt(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function Se(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Qt(t){if(!Array.isArray(t))throw new Error("array expected")}function He(t,e){if(!De(!0,e))throw new Error(`${t}: array of strings expected`)}function $r(t,e){if(!De(!1,e))throw new Error(`${t}: array of numbers expected`)}function xr(...t){const e=i=>i,n=(i,c)=>a=>i(c(a)),r=t.map(i=>i.encode).reduceRight(n,e),s=t.map(i=>i.decode).reduce(n,e);return{encode:r,decode:s}}function Ar(t){const e=typeof t=="string"?t.split(""):t,n=e.length;He("alphabet",e);const r=new Map(e.map((s,i)=>[s,i]));return{encode:s=>(Qt(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:s=>(Qt(s),s.map(i=>{Jt("alphabet.decode",i);const c=r.get(i);if(c===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return c}))}}function Ir(t=""){return Jt("join",t),{encode:e=>(He("join.decode",e),e.join(t)),decode:e=>(Jt("join.decode",e),e.split(t))}}function Ce(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Qt(t),!t.length)return[];let r=0;const s=[],i=Array.from(t,a=>{if(Se(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),c=i.length;for(;;){let a=0,l=!0;for(let u=r;u<c;u++){const h=i[u],d=e*a,o=d+h;if(!Number.isSafeInteger(o)||d/e!==a||o-h!==d)throw new Error("convertRadix: carry overflow");const y=o/n;a=o%n;const p=Math.floor(y);if(i[u]=p,!Number.isSafeInteger(p)||p*n+a!==o)throw new Error("convertRadix: carry overflow");if(l)p?l=!1:r=u;else continue}if(s.push(a),l)break}for(let a=0;a<t.length-1&&t[a]===0;a++)s.push(0);return s.reverse()}function Br(t){Se(t);const e=2**8;return{encode:n=>{if(!kr(n))throw new Error("radix.encode input should be Uint8Array");return Ce(Array.from(n),e,t)},decode:n=>($r("radix.decode",n),Uint8Array.from(Ce(n,t,e)))}}const Ne=(t=>xr(Br(58),Ar(t),Ir("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ht(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Or(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ht(t,...e){if(!Or(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Et(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Zt(t,e){Ht(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ur(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function dt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ct(t,e){return t<<32-e|t>>>e}const H=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Me(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const W=H?t=>t:t=>Me(t);function C(t){for(let e=0;e<t.length;e++)t[e]=Me(t[e])}function Lr(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function F(t){return typeof t=="string"&&(t=Lr(t)),Ht(t),t}class Ve{clone(){return this._cloneInto()}}function Tr(t){const e=r=>t().update(F(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function _r(t){const e=(r,s)=>t(s).update(F(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}function Dr(t){const e=(r,s)=>t(s).update(F(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}const Sr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,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]);class je extends Ve{constructor(e,n,r={},s,i,c){if(super(),this.blockLen=e,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ht(e),ht(n),ht(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(r.salt!==void 0&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error("personalization must be undefined or "+c);this.buffer=new Uint8Array(e),this.buffer32=dt(this.buffer)}update(e){Et(this);const{blockLen:n,buffer:r,buffer32:s}=this;e=F(e);const i=e.length,c=e.byteOffset,a=e.buffer;for(let l=0;l<i;){this.pos===n&&(H||C(s),this.compress(s,0,!1),H||C(s),this.pos=0);const u=Math.min(n-this.pos,i-l),h=c+l;if(u===n&&!(h%4)&&l+u<i){const d=new Uint32Array(a,h,Math.floor((i-l)/4));H||C(d);for(let o=0;l+n<i;o+=s.length,l+=n)this.length+=n,this.compress(d,o,!1);H||C(d);continue}r.set(e.subarray(l,l+u),this.pos),this.pos+=u,this.length+=u,l+=u}return this}digestInto(e){Et(this),Zt(e,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),H||C(r),this.compress(r,0,!0),H||C(r);const s=dt(e);this.get().forEach((i,c)=>s[c]=W(i))}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){const{buffer:n,length:r,finished:s,destroyed:i,outputLen:c,pos:a}=this;return e||(e=new this.constructor({dkLen:c})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=c,e.buffer.set(n),e.pos=a,e}}const Nt=BigInt(2**32-1),te=BigInt(32);function Mt(t,e=!1){return e?{h:Number(t&Nt),l:Number(t>>te&Nt)}:{h:Number(t>>te&Nt)|0,l:Number(t&Nt)|0}}function Re(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:i,l:c}=Mt(t[s],e);[n[s],r[s]]=[i,c]}return[n,r]}const Hr=(t,e)=>BigInt(t>>>0)<<te|BigInt(e>>>0),Cr=(t,e,n)=>t>>>n,Nr=(t,e,n)=>t<<32-n|e>>>n,Mr=(t,e,n)=>t>>>n|e<<32-n,Vr=(t,e,n)=>t<<32-n|e>>>n,jr=(t,e,n)=>t<<64-n|e>>>n-32,Rr=(t,e,n)=>t>>>n-32|e<<64-n,Pr=(t,e)=>e,Kr=(t,e)=>t,Pe=(t,e,n)=>t<<n|e>>>32-n,Ke=(t,e,n)=>e<<n|t>>>32-n,qe=(t,e,n)=>e<<n-32|t>>>64-n,Xe=(t,e,n)=>t<<n-32|e>>>64-n;function qr(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const N={fromBig:Mt,split:Re,toBig:Hr,shrSH:Cr,shrSL:Nr,rotrSH:Mr,rotrSL:Vr,rotrBH:jr,rotrBL:Rr,rotr32H:Pr,rotr32L:Kr,rotlSH:Pe,rotlSL:Ke,rotlBH:qe,rotlBL:Xe,add:qr,add3L:(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),add3H:(t,e,n,r)=>e+n+r+(t/2**32|0)|0,add4L:(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),add4H:(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,add5H:(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,add5L:(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},B=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function st(t,e,n,r,s,i){const c=s[i],a=s[i+1];let l=g[2*t],u=g[2*t+1],h=g[2*e],d=g[2*e+1],o=g[2*n],y=g[2*n+1],p=g[2*r],f=g[2*r+1],b=N.add3L(l,h,c);u=N.add3H(b,u,d,a),l=b|0,{Dh:f,Dl:p}={Dh:f^u,Dl:p^l},{Dh:f,Dl:p}={Dh:N.rotr32H(f,p),Dl:N.rotr32L(f,p)},{h:y,l:o}=N.add(y,o,f,p),{Bh:d,Bl:h}={Bh:d^y,Bl:h^o},{Bh:d,Bl:h}={Bh:N.rotrSH(d,h,24),Bl:N.rotrSL(d,h,24)},g[2*t]=l,g[2*t+1]=u,g[2*e]=h,g[2*e+1]=d,g[2*n]=o,g[2*n+1]=y,g[2*r]=p,g[2*r+1]=f}function it(t,e,n,r,s,i){const c=s[i],a=s[i+1];let l=g[2*t],u=g[2*t+1],h=g[2*e],d=g[2*e+1],o=g[2*n],y=g[2*n+1],p=g[2*r],f=g[2*r+1],b=N.add3L(l,h,c);u=N.add3H(b,u,d,a),l=b|0,{Dh:f,Dl:p}={Dh:f^u,Dl:p^l},{Dh:f,Dl:p}={Dh:N.rotrSH(f,p,16),Dl:N.rotrSL(f,p,16)},{h:y,l:o}=N.add(y,o,f,p),{Bh:d,Bl:h}={Bh:d^y,Bl:h^o},{Bh:d,Bl:h}={Bh:N.rotrBH(d,h,63),Bl:N.rotrBL(d,h,63)},g[2*t]=l,g[2*t+1]=u,g[2*e]=h,g[2*e+1]=d,g[2*n]=o,g[2*n+1]=y,g[2*r]=p,g[2*r+1]=f}class Xr extends je{constructor(e={}){super(128,e.dkLen===void 0?64:e.dkLen,e,64,16,16),this.v0l=B[0]|0,this.v0h=B[1]|0,this.v1l=B[2]|0,this.v1h=B[3]|0,this.v2l=B[4]|0,this.v2h=B[5]|0,this.v3l=B[6]|0,this.v3h=B[7]|0,this.v4l=B[8]|0,this.v4h=B[9]|0,this.v5l=B[10]|0,this.v5h=B[11]|0,this.v6l=B[12]|0,this.v6h=B[13]|0,this.v7l=B[14]|0,this.v7h=B[15]|0;const n=e.key?e.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,e.salt){const r=dt(F(e.salt));this.v4l^=W(r[0]),this.v4h^=W(r[1]),this.v5l^=W(r[2]),this.v5h^=W(r[3])}if(e.personalization){const r=dt(F(e.personalization));this.v6l^=W(r[0]),this.v6h^=W(r[1]),this.v7l^=W(r[2]),this.v7h^=W(r[3])}if(e.key){const r=new Uint8Array(this.blockLen);r.set(F(e.key)),this.update(r)}}get(){let{v0l:e,v0h:n,v1l:r,v1h:s,v2l:i,v2h:c,v3l:a,v3h:l,v4l:u,v4h:h,v5l:d,v5h:o,v6l:y,v6h:p,v7l:f,v7h:b}=this;return[e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b]}set(e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b){this.v0l=e|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=i|0,this.v2h=c|0,this.v3l=a|0,this.v3h=l|0,this.v4l=u|0,this.v4h=h|0,this.v5l=d|0,this.v5h=o|0,this.v6l=y|0,this.v6h=p|0,this.v7l=f|0,this.v7h=b|0}compress(e,n,r){this.get().forEach((l,u)=>g[u]=l),g.set(B,16);let{h:s,l:i}=N.fromBig(BigInt(this.length));g[24]=B[8]^i,g[25]=B[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const a=Sr;for(let l=0;l<12;l++)st(0,4,8,12,e,n+2*a[c++]),it(0,4,8,12,e,n+2*a[c++]),st(1,5,9,13,e,n+2*a[c++]),it(1,5,9,13,e,n+2*a[c++]),st(2,6,10,14,e,n+2*a[c++]),it(2,6,10,14,e,n+2*a[c++]),st(3,7,11,15,e,n+2*a[c++]),it(3,7,11,15,e,n+2*a[c++]),st(0,5,10,15,e,n+2*a[c++]),it(0,5,10,15,e,n+2*a[c++]),st(1,6,11,12,e,n+2*a[c++]),it(1,6,11,12,e,n+2*a[c++]),st(2,7,8,13,e,n+2*a[c++]),it(2,7,8,13,e,n+2*a[c++]),st(3,4,9,14,e,n+2*a[c++]),it(3,4,9,14,e,n+2*a[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],g.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Vt=_r(t=>new Xr(t)),ze=new TextEncoder().encode("SS58PRE"),ee=2,Ye=t=>{try{const e=Ne.decode(t),n=e.subarray(0,e[0]&64?2:1),r=e.subarray(n.length,e.length-ee),s=e.subarray(n.length+r.length),i=Vt(Uint8Array.of(...ze,...n,...r),{dkLen:64}).subarray(0,ee);return s[0]===i[0]&&s[1]===i[1]?{isValid:!0,ss58Format:zr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},zr=t=>{const e=new DataView(t.buffer,t.byteOffset,t.byteLength);return e.byteLength===1?e.getUint8(0):e.getUint16(0)},We=t=>{const e=t<64?Uint8Array.of(t):Uint8Array.of((t&252)>>2|64,t>>8|(t&3)<<6);return n=>{const r=Vt(Uint8Array.of(...ze,...e,...n),{dkLen:64}).subarray(0,ee);return Ne.encode(Uint8Array.of(...e,...n,...r))}};function Yr(t,e){return n=>{const r=Ye(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==t)throw new Error("Invalid public key length");return s}}const ne=(t=42,e=32)=>q(D(e),Yr(e),We(t)),Fe="0123456789abcdef";function G(t){const e=new Array(t.length+1);e[0]="0x";for(let n=0;n<t.length;){const r=t[n++];e[n]=Fe[r>>4]+Fe[r&15]}return e.join("")}const re={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 kt(t){const e=t.length%2,n=(t[1]==="x"?2:0)+e,r=(t.length-n)/2+e,s=new Uint8Array(r);e&&(s[0]=0|re[t[2]]);for(let i=0;i<r;){const c=n+i*2,a=re[t[c]],l=re[t[c+1]];s[e+i++]=a<<4|l}return s}function Ge(t,e){return Object.fromEntries(Object.entries(t).map(([n,r])=>[n,e(r,n)]))}const ft=(...t)=>{const e=t.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.byteLength}return n};var Wr=Object.defineProperty,Je=t=>{throw TypeError(t)},Fr=(t,e,n)=>e in t?Wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$t=(t,e,n)=>Fr(t,typeof e!="symbol"?e+"":e,n),Qe=(t,e,n)=>e.has(t)||Je("Cannot "+n),J=(t,e,n)=>(Qe(t,e,"read from private field"),n?n.call(t):e.get(t)),xt=(t,e,n)=>e.has(t)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),pt=(t,e,n,r)=>(Qe(t,e,"write to private field"),e.set(t,n),n),Q,At,jt,Rt,Pt;const Gr=new TextEncoder,Jr=new TextDecoder,Qr=Y(_,D(1/0))[1];let Z=class{constructor(e,n=!1){if(xt(this,Q),xt(this,At,null),xt(this,jt,null),xt(this,Rt,null),xt(this,Pt,null),$t(this,"asText",()=>J(this,Pt)??pt(this,Pt,Jr.decode(J(this,Q)))),$t(this,"asHex",()=>J(this,jt)||pt(this,jt,G(J(this,Q)))),$t(this,"asOpaqueHex",()=>J(this,Rt)||pt(this,Rt,G(this.asBytes()))),$t(this,"asBytes",()=>J(this,Q)),$t(this,"asOpaqueBytes",()=>J(this,At)||pt(this,At,ft(_[0](J(this,Q).length),J(this,Q)))),n){try{const[r,s]=Qr(e);if(r===s.length){pt(this,Q,s),pt(this,At,e);return}}catch{}throw new Error("Invalid opaque bytes")}else pt(this,Q,e)}static fromText(e){return new this(Gr.encode(e))}static fromHex(e){return new this(kt(e))}static fromOpaqueHex(e){return new this(kt(e),!0)}static fromBytes(e){return new this(e)}static fromOpaqueBytes(e){return new this(e,!0)}};Q=new WeakMap,At=new WeakMap,jt=new WeakMap,Rt=new WeakMap,Pt=new WeakMap;const[Zr]=ne();let Ze=class extends Z{constructor(e){super(e)}static fromArray(e){return new this(new Uint8Array(e))}static fromAccountId32(e){return new this(Zr(e))}};const tn=t=>{const e=D.enc(t);return n=>e(n.asBytes())},en=t=>{const e=D.dec(t),n=t==null?Z:Ze;return r=>n.fromBytes(e(r))},It=t=>$(tn(t),en(t));It.enc=tn,It.dec=en;const v=_,ts=_,es=Ft(t=>{const e=v.dec(t),n=Math.ceil(e/8);return{bytes:D(n).dec(t),bitsLen:e}}),ns=t=>{if(t.bitsLen>t.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${t.bitsLen}, bytesLen:${t.bytes.length})`);const e=v.enc(t.bitsLen),n=new Uint8Array(t.bytes.length+e.length);return n.set(e,0),n.set(t.bytes,e.length),n},nn=$(ns,es),rs=q(U,t=>t.charCodeAt(0),String.fromCharCode),rn=t=>{const e=D.enc(t);return n=>e(kt(n))},sn=t=>{const e=D.dec(t);return n=>G(e(n))},ot=t=>$(rn(t),sn(t));ot.enc=rn,ot.dec=sn;const ss=new TextEncoder,is=new TextDecoder,os=t=>q(D(t),e=>ss.encode(e),e=>is.decode(e)),on=t=>{let e=n=>{const r=t();return e=r,r(n)};return n=>e(n)},cn=t=>{let e=n=>{const r=t(),s=r;return e=r,s(n)};return n=>e(n)},an=t=>$(on(()=>t().enc),cn(()=>t().dec)),cs={is(t,e){return t.type===e},as(t,e){if(e!==t.type)throw new Error(`Enum.as(enum, ${e}) used with actual type ${t.type}`);return t}},se=Object.assign((t,e)=>({type:t,value:e}),cs),as=new Proxy({},{get(t,e){return n=>se(e,n)}}),un=(...t)=>{const e=X.enc(...t);return n=>e({tag:n.type,value:n.value})},ln=(...t)=>{const e=X.dec(...t);return n=>{const{tag:r,value:s}=e(n);return se(r,s)}},yt=(t,...e)=>$(un(Ge(t,([n])=>n),...e),ln(Ge(t,([,n])=>n),...e));yt.enc=un,yt.dec=ln;const hn=[],dn=[],fn=[],us=BigInt(0),Bt=BigInt(1),ls=BigInt(2),hs=BigInt(7),ds=BigInt(256),fs=BigInt(113);for(let t=0,e=Bt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],hn.push(2*(5*r+n)),dn.push((t+1)*(t+2)/2%64);let s=us;for(let i=0;i<7;i++)e=(e<<Bt^(e>>hs)*fs)%ds,e&ls&&(s^=Bt<<(Bt<<BigInt(i))-Bt);fn.push(s)}const[ps,ys]=Re(fn,!0),pn=(t,e,n)=>n>32?qe(t,e,n):Pe(t,e,n),yn=(t,e,n)=>n>32?Xe(t,e,n):Ke(t,e,n);function gs(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let c=0;c<10;c++)n[c]=t[c]^t[c+10]^t[c+20]^t[c+30]^t[c+40];for(let c=0;c<10;c+=2){const a=(c+8)%10,l=(c+2)%10,u=n[l],h=n[l+1],d=pn(u,h,1)^n[a],o=yn(u,h,1)^n[a+1];for(let y=0;y<50;y+=10)t[c+y]^=d,t[c+y+1]^=o}let s=t[2],i=t[3];for(let c=0;c<24;c++){const a=dn[c],l=pn(s,i,a),u=yn(s,i,a),h=hn[c];s=t[h],i=t[h+1],t[h]=l,t[h+1]=u}for(let c=0;c<50;c+=10){for(let a=0;a<10;a++)n[a]=t[c+a];for(let a=0;a<10;a++)t[c+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=ps[r],t[1]^=ys[r]}n.fill(0)}class ie extends Ve{constructor(e,n,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ht(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=dt(this.state)}keccak(){H||C(this.state32),gs(this.state32,this.rounds),H||C(this.state32),this.posOut=0,this.pos=0}update(e){Et(this);const{blockLen:n,state:r}=this;e=F(e);const s=e.length;for(let i=0;i<s;){const c=Math.min(n-this.pos,s-i);for(let a=0;a<c;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Et(this,!1),Ht(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zt(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:c}=this;return e||(e=new ie(n,r,s,c,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=c,e.destroyed=this.destroyed,e}}const vs=((t,e,n)=>Tr(()=>new ie(e,t,n)))(1,136,256/8),gn=t=>{const e=t.slice(2),n=G(vs(e)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const i=parseInt(n[s],16),c=e[s];r[s]=i>7?c.toUpperCase():c}return`0x${r.join("")}`},bs=D(20)[1],vn=$(t=>{const e=kt(t);if(e.length!==20)throw new Error(`Invalid length found on EthAddress(${t})`);const n=G(e);if(t===n||t===n.toUpperCase())return e;if(gn(n)!==t)throw new Error(`Invalid checksum found on EthAddress(${t})`);return e},Ft(t=>gn(G(bs(t))))),bn=new TextEncoder,wn=new TextDecoder,ws=q(D(4),bn.encode.bind(bn),wn.decode.bind(wn)),oe=m({engine:ws,payload:ot()}),ms=yt({consensus:oe,seal:oe,preRuntime:oe,runtimeUpdated:w},[4,5,6,8]),ce=ot(32),Es=m({parentHash:ce,number:v,stateRoot:ce,extrinsicRoot:ce,digests:x(ms)}),tt=x(I),mn=j(I),ks=X({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),En=x(m({name:mn,type:v,typeName:mn,docs:tt})),$s=m({len:rt,type:v}),xs=m({bitStoreType:v,bitOrderType:v}),As=x(m({name:I,fields:En,index:U,docs:tt})),Is=X({composite:En,variant:As,sequence:v,array:$s,tuple:x(v),primitive:ks,compact:v,bitSequence:xs}),Bs=m({name:I,type:j(v)}),Os=x(Bs),Us=m({id:v,path:tt,params:Os,def:Is,docs:tt}),Kt=x(Us),Ls=X({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),Ts=x(Ls),_s=m({hashers:Ts,key:v,value:v}),Ds=m({name:I,modifier:U,type:X({plain:v,map:_s}),fallback:ot(),docs:tt}),Ss=j(m({prefix:I,items:x(Ds)})),kn={name:I,storage:Ss,calls:j(v),events:j(v),constants:x(m({name:I,type:v,value:ot(),docs:tt})),errors:j(v),index:U},Hs={...kn,docs:tt},Cs=new Uint8Array,$n=t=>$(()=>Cs,()=>t),Ns=m({type:v,version:U,signedExtensions:x(m({identifier:I,type:v,additionalSigned:v}))}),xn=m({lookup:Kt,pallets:x(m({...kn,docs:$n([])})),extrinsic:Ns,type:v,apis:$n([])}),Ms=m({name:I,methods:x(m({name:I,inputs:x(m({name:I,type:v})),output:v,docs:tt})),docs:tt}),Vs=m({version:U,address:v,call:v,signature:v,extra:v,signedExtensions:x(m({identifier:I,type:v,additionalSigned:v}))}),An=m({lookup:Kt,pallets:x(m(Hs)),extrinsic:Vs,type:v,apis:x(Ms),outerEnums:m({call:v,event:v,error:v}),custom:x(Y(I,m({type:v,value:ot()})))}),In=()=>{throw new Error("Unsupported metadata version!")},M=$(In,In),Ot=m({magicNumber:rt,metadata:X({v0:M,v1:M,v2:M,v3:M,v4:M,v5:M,v6:M,v7:M,v8:M,v9:M,v10:M,v11:M,v12:M,v13:M,v14:xn,v15:An})}),ae=D(),js=j(ae),Rs=Y(_,ae),Ps=t=>{try{return Ot.dec(t)}catch{}try{return Ot.dec(js.dec(t))}catch{}try{return Ot.dec(ae.dec(t))}catch{}try{return Ot.dec(Rs.dec(t)[1])}catch{}throw null},Ks={dkLen:32},ue=t=>Vt(t,Ks),qs={dkLen:16},le=t=>Vt(t,qs),Bn=t=>ft(le(t),t),et=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ct(t,e,n,r,s){return t=t+e+s|0,r=Ct(r^t,16),n=n+r|0,e=Ct(e^n,12),{a:t,b:e,c:n,d:r}}function at(t,e,n,r,s){return t=t+e+s|0,r=Ct(r^t,8),n=n+r|0,e=Ct(e^n,7),{a:t,b:e,c:n,d:r}}function On(t,e,n,r,s,i,c,a,l,u,h,d,o,y,p,f,b,E,O,V){let A=0;for(let vt=0;vt<r;vt++)({a:s,b:l,c:o,d:b}=ct(s,l,o,b,n[e+t[A++]])),{a:s,b:l,c:o,d:b}=at(s,l,o,b,n[e+t[A++]]),{a:i,b:u,c:y,d:E}=ct(i,u,y,E,n[e+t[A++]]),{a:i,b:u,c:y,d:E}=at(i,u,y,E,n[e+t[A++]]),{a:c,b:h,c:p,d:O}=ct(c,h,p,O,n[e+t[A++]]),{a:c,b:h,c:p,d:O}=at(c,h,p,O,n[e+t[A++]]),{a,b:d,c:f,d:V}=ct(a,d,f,V,n[e+t[A++]]),{a,b:d,c:f,d:V}=at(a,d,f,V,n[e+t[A++]]),{a:s,b:u,c:p,d:V}=ct(s,u,p,V,n[e+t[A++]]),{a:s,b:u,c:p,d:V}=at(s,u,p,V,n[e+t[A++]]),{a:i,b:h,c:f,d:b}=ct(i,h,f,b,n[e+t[A++]]),{a:i,b:h,c:f,d:b}=at(i,h,f,b,n[e+t[A++]]),{a:c,b:d,c:o,d:E}=ct(c,d,o,E,n[e+t[A++]]),{a:c,b:d,c:o,d:E}=at(c,d,o,E,n[e+t[A++]]),{a,b:l,c:y,d:O}=ct(a,l,y,O,n[e+t[A++]]),{a,b:l,c:y,d:O}=at(a,l,y,O,n[e+t[A++]]);return{v0:s,v1:i,v2:c,v3:a,v4:l,v5:u,v6:h,v7:d,v8:o,v9:y,v10:p,v11:f,v12:b,v13:E,v14:O,v15:V}}var K;(function(t){t[t.CHUNK_START=1]="CHUNK_START",t[t.CHUNK_END=2]="CHUNK_END",t[t.PARENT=4]="PARENT",t[t.ROOT=8]="ROOT",t[t.KEYED_HASH=16]="KEYED_HASH",t[t.DERIVE_KEY_CONTEXT=32]="DERIVE_KEY_CONTEXT",t[t.DERIVE_KEY_MATERIAL=64]="DERIVE_KEY_MATERIAL"})(K||(K={}));const Un=(()=>{const t=Array.from({length:16},(r,s)=>s),e=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=t;r<7;r++,s=e(s))n.push(...s);return Uint8Array.from(n)})();class he extends je{constructor(e={},n=0){if(super(64,e.dkLen===void 0?32:e.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=e.dkLen===void 0?32:e.dkLen,ht(this.outputLen),e.key!==void 0&&e.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(e.key!==void 0){const r=F(e.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=dt(r),H||C(this.IV),this.flags=n|K.KEYED_HASH}else if(e.context!==void 0){const r=new he({dkLen:32},K.DERIVE_KEY_CONTEXT).update(e.context).digest();this.IV=dt(r),H||C(this.IV),this.flags=n|K.DERIVE_KEY_MATERIAL}else this.IV=et.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Ur(this.bufferOut32)}get(){return[]}set(){}b2Compress(e,n,r,s=0){const{state:i,pos:c}=this,{h:a,l}=Mt(BigInt(e),!0),{v0:u,v1:h,v2:d,v3:o,v4:y,v5:p,v6:f,v7:b,v8:E,v9:O,v10:V,v11:A,v12:vt,v13:zt,v14:Yt,v15:$i}=On(Un,s,r,7,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],et[0],et[1],et[2],et[3],a,l,c,n);i[0]=u^E,i[1]=h^O,i[2]=d^V,i[3]=o^A,i[4]=y^vt,i[5]=p^zt,i[6]=f^Yt,i[7]=b^$i}compress(e,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=K.CHUNK_START),(this.chunkPos===15||r)&&(s|=K.CHUNK_END),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,e,n),this.chunkPos+=1,this.chunkPos===16||r){let i=this.state;this.state=this.IV.slice();for(let c,a=this.chunksDone+1;(r||!(a&1))&&(c=this.stack.pop());a>>=1)this.buffer32.set(c,0),this.buffer32.set(i,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|K.PARENT,this.buffer32,0),i=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(i)}this.pos=0}_cloneInto(e){e=super._cloneInto(e);const{IV:n,flags:r,state:s,chunkPos:i,posOut:c,chunkOut:a,stack:l,chunksDone:u}=this;return e.state.set(s.slice()),e.stack=l.map(h=>Uint32Array.from(h)),e.IV.set(n),e.flags=r,e.chunkPos=i,e.chunksDone=u,e.posOut=c,e.chunkOut=a,e.enableXOF=this.enableXOF,e.bufferOut32.set(this.bufferOut32),e}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let e of this.stack)e.fill(0)}b2CompressOut(){const{state:e,pos:n,flags:r,buffer32:s,bufferOut32:i}=this,{h:c,l:a}=Mt(BigInt(this.chunkOut++));H||C(s);const{v0:l,v1:u,v2:h,v3:d,v4:o,v5:y,v6:p,v7:f,v8:b,v9:E,v10:O,v11:V,v12:A,v13:vt,v14:zt,v15:Yt}=On(Un,0,s,7,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],et[0],et[1],et[2],et[3],a,c,n,r);i[0]=l^b,i[1]=u^E,i[2]=h^O,i[3]=d^V,i[4]=o^A,i[5]=y^vt,i[6]=p^zt,i[7]=f^Yt,i[8]=e[0]^b,i[9]=e[1]^E,i[10]=e[2]^O,i[11]=e[3]^V,i[12]=e[4]^A,i[13]=e[5]^vt,i[14]=e[6]^zt,i[15]=e[7]^Yt,H||(C(s),C(i)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let e=this.flags|K.ROOT;this.stack.length?(e|=K.PARENT,H||C(this.buffer32),this.compress(this.buffer32,0,!0),H||C(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):e|=(this.chunkPos?0:K.CHUNK_START)|K.CHUNK_END,this.flags=e,this.b2CompressOut()}writeInto(e){Et(this,!1),Ht(e),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,i-s);e.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(e)}xof(e){return ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zt(e,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Xs=Dr(t=>new he(t)),zs={dkLen:32},Ln=t=>Xs(t,zs),Ys=t=>ft(Ln(t),t),Tn=t=>t,gt=(t,e,n,r)=>new DataView(new Uint16Array([t,e,n,r]).buffer).getBigUint64(0,!0),de=2n**64n-1n,S=(t,e)=>t<<e&de|t>>64n-e,k=(t,e)=>t*e&de,L=(t,e)=>t+e&de,T=11400714785074694791n,R=14029467366897019727n,_n=1609587929392839161n,Ut=9650029242287828579n,Dn=2870177450012600261n;function ut(t,e=0n){let n=L(L(e,T),R),r=L(e,R),s=e,i=e-T,c=t.length,a=0,l=null;(function(){let o=0,y=o+c;if(c){if(l=new Uint8Array(32),c<32){l.set(t.subarray(0,c),a),a+=c;return}if(o<=y-32){const p=y-32;do{let f;f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),n=k(S(L(n,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),r=k(S(L(r,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),s=k(S(L(s,k(f,R)),31n),T),o+=8,f=gt(t[o+1]<<8|t[o],t[o+3]<<8|t[o+2],t[o+5]<<8|t[o+4],t[o+7]<<8|t[o+6]),i=k(S(L(i,k(f,R)),31n),T),o+=8}while(o<=p)}o<y&&(l.set(t.subarray(o,y),a),a=y-o)}})(),t=l||t;let u,h=0;for(c>=32?(u=S(n,1n),u=L(u,S(r,7n)),u=L(u,S(s,12n)),u=L(u,S(i,18n)),n=k(S(k(n,R),31n),T),u=u^n,u=L(k(u,T),Ut),r=k(S(k(r,R),31n),T),u=u^r,u=L(k(u,T),Ut),s=k(S(k(s,R),31n),T),u=u^s,u=L(k(u,T),Ut),i=k(S(k(i,R),31n),T),u=u^i,u=L(k(u,T),Ut)):u=L(e,Dn),u=L(u,BigInt(c));h<=a-8;){let o=gt(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2],t[h+5]<<8|t[h+4],t[h+7]<<8|t[h+6]);o=k(S(k(o,R),31n),T),u=L(k(S(u^o,27n),T),Ut),h+=8}if(h+4<=a){let o=k(gt(t[h+1]<<8|t[h],t[h+3]<<8|t[h+2],0,0),T);u=L(k(S(u^o,23n),R),_n),h+=4}for(;h<a;){const o=k(gt(t[h++],0,0,0),Dn);u=k(S(u^o,11n),T)}let d=u>>33n;return u=k(u^d,R),d=u>>29n,u=k(u^d,_n),d=u>>32n,u^=d,u}const qt=t=>{const e=new Uint8Array(16),n=new DataView(e.buffer);return n.setBigUint64(0,ut(t),!0),n.setBigUint64(8,ut(t,1n),!0),e},Sn=t=>{const e=new Uint8Array(32),n=new DataView(e.buffer);return n.setBigUint64(0,ut(t),!0),n.setBigUint64(8,ut(t,1n),!0),n.setBigUint64(16,ut(t,2n),!0),n.setBigUint64(24,ut(t,3n),!0),e},Hn=t=>ft(Dt.enc(ut(t)),t),Cn=new TextEncoder,Ws=new Map([[Tn,0],[Hn,8],[Bn,16],[le,-16],[ue,-32],[qt,-16],[Sn,-32]]),Fs=t=>{const e=qt(Cn.encode(t));return(n,...r)=>{const s=ft(e,qt(Cn.encode(n))),i=G(s),c=l=>{if(!l.startsWith(i))throw new Error(`key does not match this storage (${t}.${n})`);if(r.length===0)return[];const u=kt(l.slice(i.length)),h=new Array(r.length);for(let d=0,o=0;d<r.length;d++){const[y,p]=r[d],f=Ws.get(p);if(f==null)throw new Error("Unknown hasher");if(f<0){const b=f*-1;h[d]=G(u.slice(o,o+b)),o+=b}else o+=f,h[d]=y.dec(u.slice(o)),o+=y.enc(h[d]).length}return h},a=r.map(([{enc:l},u])=>h=>u(l(h)));return{enc:(...l)=>G(ft(s,...l.map((u,h)=>a[h](u)))),dec:c}}},Gs=Z.fromText("modlpy/utilisuba").asBytes(),Js=({threshold:t,signatories:e})=>{const n=Nn(e),r=ft(Gs,_.enc(n.length),...n,wt.enc(t));return ue(r)},Nn=t=>t.slice().sort((e,n)=>{for(let r=0;;r++){const s=r>=e.length,i=r>=n.length;if(s&&i)return 0;if(s)return-1;if(i)return 1;if(e[r]!==n[r])return e[r]>n[r]?1:-1}});var Qs=Object.freeze({__proto__:null,AccountId:ne,Bin:It,Binary:Z,Blake2128:le,Blake2128Concat:Bn,Blake2256:ue,Blake3256:Ln,Blake3256Concat:Ys,Bytes:D,Enum:se,FixedSizeBinary:Ze,Hex:ot,Identity:Tn,Option:j,Result:St,ScaleEnum:X,Self:an,Storage:Fs,Struct:m,Tuple:Y,Twox128:qt,Twox256:Sn,Twox64Concat:Hn,Variant:yt,Vector:x,_Enum:as,_void:w,bitSequence:nn,blockHeader:Es,bool:ir,char:rs,compact:_,compactBn:ts,compactNumber:v,createCodec:$,createDecoder:Ft,decAnyMetadata:Ps,enhanceCodec:q,enhanceDecoder:_t,enhanceEncoder:Gt,ethAccount:vn,fixedStr:os,fromBufferToBase58:We,getMultisigAccountId:Js,getSs58AddressInfo:Ye,h64:ut,i128:nr,i16:Qn,i256:sr,i32:Zn,i64:tr,i8:Jn,metadata:Ot,selfDecoder:cn,selfEncoder:on,sortMultisigSignatories:Nn,str:I,u128:er,u16:wt,u256:rr,u32:rt,u64:Dt,u8:U,v14:xn,v14Lookup:Kt,v15:An});const Zs=(t,e,n)=>(r,s,i,...c)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(i.has(a)){const u=e(()=>s.get(a),r,...c);return s.set(a,u),u}i.add(a);let l=t(r,s,i,...c);return i.delete(a),s.has(a)&&(l=n(l,s.get(a),r,...c)),s.set(a,l),l},ti=It(),ei=$(_[0],_t(_[1],BigInt)),ni=(t,e,n,r)=>{if(t.type==="primitive")return Qs[t.value];if(t.type==="void")return w;if(t.type==="AccountId32")return r;if(t.type==="AccountId20")return vn;if(t.type==="compact")return t.isBig?ei:_;if(t.type==="bitSequence")return nn;const s=o=>Mn(o,e,n,r),i=(o,y)=>{const p=s(o);return y?x(p,y):x(p)},c=o=>Y(...o.map(s)),a=o=>{const y=Object.fromEntries(Object.entries(o).map(([p,f])=>[p,s(f)]));return m(y)};if(t.type==="sequence"&&t.value.type==="primitive"&&t.value.value==="u8")return ti;if(t.type==="array")return t.value.type==="primitive"&&t.value.value==="u8"?It(t.len):i(t.value,t.len);if(t.type==="sequence")return i(t.value);if(t.type==="tuple")return c(t.value);if(t.type==="struct")return a(t.value);if(t.type==="option")return j(s(t.value));if(t.type==="result")return St(s(t.value.ok),s(t.value.ko));const l=Object.values(t.value).map(o=>{switch(o.type){case"void":return w;case"lookupEntry":return s(o.value);case"tuple":return c(o.value);case"struct":return a(o.value);case"array":return i(o.value,o.len)}}),u=Object.fromEntries(Object.keys(t.value).map((o,y)=>[o,l[y]])),h=Object.values(t.value).map(o=>o.idx),d=h.every((o,y)=>o===y)?yt(u):yt(u,h);return t.byteLength?si(d,t.byteLength):d},Mn=Zs(ni,an,t=>t),ri=(t,e=ne())=>{const n=new Map,r=s=>Mn(t(s),n,new Set,e);return s=>r(s)},si=(t,e)=>{const n=D(e);return $(r=>n.enc(t.enc(r)),r=>t.dec(n.dec(r)))},ii=t=>{const{metadata:e}=t,n=ri(t),r=(l="")=>{const u=t.storage[l];if(!u)throw new Error(`Storage entry ${l||"{root}"} not found`);const h=u.key==null?w:n(u.key);return{key:Vn(h,u.keyPrefix),value:n(u.typeId)}},s=l=>{const u=m(Object.fromEntries(l.args.map(h=>[h.label,n(h.type.type)])));return{call:Vn(u,l.selector),value:n(l.returnType.type)}},i=l=>{const u=e.spec.constructors.find(h=>h.label===l);if(!u)throw new Error(`Constructor ${l} not found`);return s(u)},c=l=>{const u=e.spec.messages.find(h=>h.label===l);if(!u)throw new Error(`Message ${l} not found`);return s(u)},a=l=>m(Object.fromEntries(l.args.map(u=>[u.label,n(u.type.type)])));return{buildConstructor:i,buildMessage:c,buildStorage:r,buildEvents:()=>yt(Object.fromEntries(e.spec.events.map(l=>[l.label,a(l)]))),buildEvent:l=>{const u=e.spec.events,h=(o,y)=>q(o,p=>p.value,p=>({type:y,value:p}));if(l){const o=u.find(y=>y.signature_topic===l);return o?h(a(o),o.label):null}const d=u.filter(o=>o.signature_topic===l);return d.length?oi(d.map(o=>h(a(o),o.label))):null}}},Vn=(t,e)=>{const n=Z.fromHex(e).asBytes(),r=Y(D(n.length),t);return q(r,s=>[n,s],([,s])=>s)},oi=t=>$(e=>{for(const n of t)try{n.enc(e)}catch{}throw new Error("Unable to encode")},e=>{for(const n of t)try{n.dec(e)}catch{}throw new Error("Unable to decode")}),jn=t=>q(X(t),e=>{if(typeof e=="string")return{tag:e,value:void 0};const[n,r]=Object.entries(e)[0];return{tag:n,value:r}},e=>({[e.tag]:e.value})),Lt=(t,e)=>q(x(t,e),n=>n??[],n=>n),Rn=j(I),Xt=Lt(I),ci=jn({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),Pn=Lt(m({name:Rn,type:v,typeName:Rn,docs:Xt})),ai=m({len:rt,type:v}),ui=m({bitStoreType:v,bitOrderType:v}),li=Lt(m({name:I,fields:Pn,index:U,docs:Xt})),hi=jn({composite:m({fields:Pn}),variant:m({variants:li}),sequence:m({type:v}),array:ai,tuple:x(v),primitive:ci,compact:v,bitSequence:ui}),di=m({name:I,type:j(v)}),fi=Lt(di),pi=m({id:v,path:Xt,params:fi,def:hi,docs:Xt}),yi=q(pi,t=>({id:t.id,path:t.type.path,params:t.type.params??[],def:t.type.def,docs:[]}),t=>({id:t.id,type:{def:t.def,path:t.path,params:t.params}})),gi=Lt(yi),vi=t=>{const e=gi.enc(t.types),n=Kt.dec(e),r=t.spec.environment.accountId.type,s=n.find(a=>a.id===r);s&&(s.path=["AccountId32"]);const i=bi(t,n),c=Xn(n);return Object.assign(c,{metadata:t,lookup:n,storage:i})};function bi(t,e){const n={},r=(s,i=[])=>{function c(l){const u=e.length;return e[u]={id:u,docs:[],def:l,params:[],path:[]},u}if("root"in s){const l=Number(t.version)===4?Z.fromBytes(Z.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,u=r(s.root.layout,i);if(s.root.ty!=null){let h=function(d,o){const y=t.types[d].type,p="composite"in y.def?new Map((y.def.composite.fields??[]).map(b=>[b.name,b.type])):null,f=new Map((y.params??[]).map(b=>[b.name,b.type]));if(f.size===2&&f.has("V")&&p&&p.size===2&&p.has("len")&&p.has("elements")){h(p.get("len"),[...o,"len"]),h(p.get("elements"),o);return}else f.size===3&&f.has("K")&&f.has("V")?n[o.join(".")]={keyPrefix:l,key:f.get("K"),typeId:f.get("V")}:f.size===2&&f.has("V")&&(n[o.join(".")]={keyPrefix:l,key:null,typeId:f.get("V")})};h(s.root.ty,i)}return n[i.join(".")]||(n[i.join(".")]={keyPrefix:l,key:null,typeId:u}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const l=r(s.array.layout,i);return l==null?null:c({tag:"array",value:{len:s.array.len,type:l}})}if("struct"in s){const l=s.struct.fields.map(u=>({name:u.name,type:r(u.layout,[...i,u.name]),typeName:void 0,docs:[]})).filter(u=>u.type!=null);return c({tag:"composite",value:l})}const a=Object.values(s.enum.variants).map((l,u)=>({name:l.name,fields:l.fields.map(h=>({name:h.name,type:r(h.layout,[...i,l.name,h.name]),typeName:void 0,docs:[]})).filter(h=>h.type!==null),index:u,docs:[]}));return c({tag:"variant",value:a})};return r(t.storage),n}const wi=t=>{const e=vi(t.metadata),n=ii(e);return{constructor:Kn(n.buildConstructor),message:Kn(n.buildMessage),storage:mi(n.buildStorage),event:Number(e.metadata.version)===4?Ei(n.buildEvents):ki(e,n.buildEvent)}},Kn=t=>e=>{const n=t(e);return{encode:r=>Z.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},mi=t=>e=>{const n=t(e);return{encode:r=>Z.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},Ei=t=>{const e=n=>t().dec(n.data.asBytes());return{decode:e,filter:(n,r=[])=>r.map(s=>"event"in s?s.event:s).filter(s=>s.type==="Contracts"&&s.value.type==="ContractEmitted"&&s.value.value.contract===n).map(s=>{try{return e(s.value.value)}catch(i){throw console.error(`Contract ${n} emitted an incompatible event`,s.value.value),i}})}},ki=(t,e)=>{const n=new Set(t.metadata.spec.events.map(i=>i.signature_topic).filter(i=>i!=null)),r=t.metadata.spec.events.some(i=>i.signature_topic==null),s=(i,c)=>{if(c!=null){if(!n.has(c))throw new Error(`Event with signature topic ${i} not found`);return e(c).dec(i.data.asBytes())}if(!r)throw new Error("Event signature topic required");return e(void 0).dec(i.data.asBytes())};return{decode:s,filter:(i,c=[])=>c.map(a=>"event"in a?a:{event:a,topics:a.topics}).filter(a=>a.event.type==="Contracts"&&a.event.value.type==="ContractEmitted"&&a.event.value.value.contract===i).map(a=>{const l=a.topics.map(h=>h.asHex()),u=l.find(h=>n.has(h));try{return s(a.event.value.value,u)}catch{return console.error(`Contract ${i} emitted an incompatible event`,{event:a.event.value.value.data.asHex(),eventTopics:l,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(a=>a!==null)}};mt.getInkClient=wi});
@@ -1 +1 @@
1
- (function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.papiLogsProvider={}))})(this,function(d){"use strict";var f=Object.defineProperty,b=(t,e,s)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,T=(t,e,s)=>b(t,typeof e!="symbol"?e+"":e,s);class k{constructor(...e){T(this,"first"),T(this,"last"),e.length!==0&&e.forEach(s=>this.push(s))}push(e){const s={value:e};this.last===void 0?(this.last=s,this.first=this.last):(this.last.next=s,this.last=s)}pop(){const e=this.first?.value;return this.first&&(this.first=this.first.next,this.first||(this.last=void 0)),e}peek(){return this.first?.value}}const v=">>",x="<<",y=t=>{const e=new Map;let s=-1;for(let r=0;r<t.length;r++){const[,u,l,g,a]=t[r].match(/^(\d*)-(.{24})-(.{2})-(.*)$/),o=Number(u);s=new Date(l).getTime();const n=e.get(o)??[];e.set(o,n),n.push({clientId:o,tick:s,type:g,msg:a})}return e},w=t=>{const e='TaggedTransactionQueue_validate_transaction","',s=t.lastIndexOf(e)+e.length+4,r=t.indexOf('"',s+1);return t.substring(s,r-64)},_={speed:1},E=(t,e={})=>{const{speed:s}={..._,...e};let r=1;const u=y(t[t.length-1]?t:t.slice(0,-1));return l=>{const g=r++,a=u.get(g),o=new k;let n=0,m=new Map;const $=async()=>{if(o.peek())for(;n<a.length&&p!==void 0;){const i=a[n];if(m.forEach((c,h)=>{i.msg=i.msg.replace(h,c)}),i.type===v){if(!o.peek()){p=setTimeout($,100);break}const c=o.pop();if(i.msg.includes("TaggedTransactionQueue_validate_transaction")&&c?.includes("TaggedTransactionQueue_validate_transaction")&&(m.set(w(i.msg),w(c)),m.forEach((h,O)=>{i.msg=i.msg.replace(O,h)})),c!==i.msg)throw console.log(`recieved: "${c}"`),console.log(`expected: "${i.msg}"`),new Error("unexpected messaged was received")}else{l(i.msg);const c=a[n+1];c&&await new Promise(h=>setTimeout(h,(c.tick-i.tick)/s))}n++}};let p=setTimeout($,200);return{send:i=>{o.push(i)},disconnect:()=>{clearTimeout(p),p=void 0}}}},I=(t,e)=>{let s=1,r,u="";const l=()=>{u=new Date().toISOString(),r=setTimeout(l,0)};return g=>{const a=s++;l();const o=e(n=>{t(`${a}-${u}-${x}-${n}`),g(n)});return{...o,send:n=>{t(`${a}-${u}-${v}-${n}`),o.send(n)},disconnect(){clearTimeout(r),o.disconnect()}}}};d.logsProvider=E,d.withLogsRecorder=I});
1
+ (function(u,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(u=typeof globalThis<"u"?globalThis:u||self,g(u.papiLogsProvider={}))})(this,function(u){"use strict";var g=Object.defineProperty,b=(t,e,s)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,v=(t,e,s)=>b(t,typeof e!="symbol"?e+"":e,s);let k=class{constructor(...e){v(this,"first"),v(this,"last"),e.length!==0&&e.forEach(s=>this.push(s))}push(e){const s={value:e};this.last===void 0?(this.last=s,this.first=this.last):(this.last.next=s,this.last=s)}pop(){const e=this.first?.value;return this.first&&(this.first=this.first.next,this.first||(this.last=void 0)),e}peek(){return this.first?.value}};const T=">>",x="<<",y=t=>{const e=new Map;let s=-1;for(let r=0;r<t.length;r++){const[,l,d,h,a]=t[r].match(/^(\d*)-(.{24})-(.{2})-(.*)$/),o=Number(l);s=new Date(d).getTime();const n=e.get(o)??[];e.set(o,n),n.push({clientId:o,tick:s,type:h,msg:a})}return e},w=t=>{const e='TaggedTransactionQueue_validate_transaction","',s=t.lastIndexOf(e)+e.length+4,r=t.indexOf('"',s+1);return t.substring(s,r-64)},_={speed:1},E=(t,e={})=>{const{speed:s}={..._,...e};let r=1;const l=y(t[t.length-1]?t:t.slice(0,-1));return d=>{const h=r++,a=l.get(h),o=new k;let n=0,m=new Map;const $=async()=>{if(o.peek())for(;n<a.length&&p!==void 0;){const i=a[n];if(m.forEach((c,f)=>{i.msg=i.msg.replace(f,c)}),i.type===T){if(!o.peek()){p=setTimeout($,100);break}const c=o.pop();if(i.msg.includes("TaggedTransactionQueue_validate_transaction")&&c?.includes("TaggedTransactionQueue_validate_transaction")&&(m.set(w(i.msg),w(c)),m.forEach((f,O)=>{i.msg=i.msg.replace(O,f)})),c!==i.msg)throw console.log(`recieved: "${c}"`),console.log(`expected: "${i.msg}"`),new Error("unexpected messaged was received")}else{d(i.msg);const c=a[n+1];c&&await new Promise(f=>setTimeout(f,(c.tick-i.tick)/s))}n++}};let p=setTimeout($,200);return{send:i=>{o.push(i)},disconnect:()=>{clearTimeout(p),p=void 0}}}},I=(t,e)=>{let s=1,r,l="";const d=()=>{l=new Date().toISOString(),r=setTimeout(d,0)};return h=>{const a=s++;d();const o=e(n=>{t(`${a}-${l}-${x}-${n}`),h(n)});return{...o,send:n=>{t(`${a}-${l}-${T}-${n}`),o.send(n)},disconnect(){clearTimeout(r),o.disconnect()}}}};u.logsProvider=E,u.withLogsRecorder=I});
@@ -1 +1 @@
1
- (function(k,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(k=typeof globalThis<"u"?globalThis:k||self,S(k.papiPolkadotSdkCompat={}))})(this,function(k){"use strict";const S=u=>{let c=null;const{send:a,disconnect:i}=u(s=>{c?.(JSON.parse(s))});return s=>(c=s,{send(p){a(JSON.stringify(p))},disconnect(){c=null,i()}})},$=u=>{let c=null;const{send:a,disconnect:i}=u(s=>{c?.(JSON.stringify(s))});return s=>(c=s,{send(p){a(JSON.parse(p))},disconnect(){c=null,i()}})},N=(...u)=>c=>$(u.reduce((a,i)=>i(a),S(c))),w={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},O={broadcast:"",stop:""},E={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:w,chainSpec:E,transaction:O}).forEach(([u,c])=>{Object.keys(c).forEach(a=>{c[a]=`${u}_v1_${a}`})});var G=Object.freeze({__proto__:null,chainHead:w,chainSpec:E,transaction:O});const L=u=>c=>{const{send:a,disconnect:i}=u(c);return{send:s=>{switch(s.method){case E.chainName:return a({...s,method:"system_chain"});case E.genesisHash:return a({...s,method:"chain_getBlockHash",params:[0]});case E.properties:return a({...s,method:"system_properties"})}a(s)},disconnect:i}},z=u=>c=>{const a=new Set,i=new Map,s=new Map,{send:p,disconnect:l}=u(r=>{if("id"in r){c(r);const{id:e,result:o}=r;if(a.has(e)){a.delete(e),i.set(o,new Set),s.set(o,new Map);return}}else{const{subscription:e}=r.params,o=i.get(e),t=s.get(e);if(o){const n=r.params.result,{event:h}=n;if(h==="initialized"&&n.finalizedBlockHashes.forEach(d=>{o.add(d)}),h==="newBlock"){const{parentBlockHash:d}=n;if(!o.has(d)){const m=t.get(d)??[];m.push(r),t.set(d,m);return}const f=n.blockHash;o.add(n.blockHash),c(r);const b=t.get(f);b&&(t.delete(f),b.forEach(m=>{o.add(m.params.result.blockHash),c(m)}));return}h==="stop"&&(o.delete(e),s.delete(e))}c(r)}});return{send:r=>{const e=r.params[0];switch(r.method){case w.follow:a.add(r.id);break;case w.unpin:const[o,t]=r.params;t.forEach(n=>{i.get(o)?.delete(n),s.get(o)?.delete(n)});break;case w.unfollow:i.delete(e),s.delete(e);break}p(r)},disconnect:l}},y=u=>({jsonrpc:"2.0",...u}),D=(u,c,a,i={})=>y({method:"chainHead_v1_followEvent",params:{subscription:u,result:{event:c,operationId:a,...i}}}),Q="__INNER_RQ_DesV",F=u=>{let c=0;const a=new Map,i=({id:p,error:l,result:r})=>{const e=a.get(p);return e&&(a.delete(p),l?e(!1,l):e(!0,r)),!e};let s=()=>{};return[p=>{const{send:l,disconnect:r}=u(e=>{i(e)&&p(e)});return s=l,{send:s,disconnect:()=>{a.clear(),r()}}},(p,l,r,e)=>{const o=Q+c++;a.set(o,(t,n)=>{(t?r:e)(n)}),s(y({id:o,method:p,params:l}))}]},X="__INNER_OP_DesV";let Y=0;const P=u=>c=>{const[a,i]=F(u),s=Z(i),p=new Map,l=new Map,{send:r,disconnect:e}=a(t=>{if("id"in t){const n=p.get(t.id);n&&(p.delete(t.id),t.result.result==="started"&&n(t.result.operationId))}else if(t.params){const{subscription:n,result:h}=t.params,{operationId:d}=h||{},f=l.get(n);f&&h.event==="stop"&&(f.forEach(m=>{m.cancel()}),l.delete(n));const b=f?.get(d);if(b)switch(h.event){case"operationInaccessible":case"operationError":b.cancel();break;case"operationStorageDone":if(b.isInnerDone)f.delete(d);else{b.isOutterDone=!0;return}}}c(t)}),o=(t,n,h)=>d=>{let f=()=>{};l.has(t)||l.set(t,new Map);const b=l.get(t),m={isOutterDone:!1,isInnerDone:!1,cancel:()=>{f()}};b.set(d,m);let g=0;const _=h.map(v=>s(v,n,H=>{c(D(t,"operationStorageItems",d,{items:H.map(([B,M])=>({key:B,value:M}))}))},H=>{f(),m.isOutterDone||r(y({method:"chainHead_v1_stopOperation",params:[d]})),c(D(t,"operationError",d,{error:typeof H=="string"?H:JSON.stringify(H)}))},()=>{++g===h.length&&(m.isOutterDone?(f(),c(D(t,"operationStorageDone",d))):m.isInnerDone=!0)}));f=()=>{b.delete(d),_.forEach(v=>v())}};return{send:t=>{switch(t.method){case w.storage:{const[n,h,d]=t.params,f=[],b=d.filter(g=>{const _=g.type==="descendantsValues";return _&&f.push(g.key),!_}),m=o(n,h,f);if(b.length)f.length&&p.set(t.id,m);else{const g=X+Y++;c(y({id:t.id,result:{result:"started",operationId:g}})),m(g),l.get(n).get(g).isOutterDone=!0;return}t.params[2]=b;break}case w.stopOperation:{const[n,h]=t.params,d=l.get(n)?.get(h);if(d&&(d.cancel(),d.isOutterDone))return;break}case w.unfollow:{const[n]=t.params;l.get(n)?.forEach(h=>h.cancel()),l.delete(n);break}}r(t)},disconnect:e}},Z=u=>(c,a,i,s,p)=>{let l=!0,r=!1,e=0;const o=h=>{l&&(l=!1,s(h))},t=1e3,n=h=>{u("state_getKeysPaged",[c,t,h||void 0,a],d=>{l&&(d.length>0&&(e++,u("state_queryStorageAt",[d,a],([{changes:f}])=>{l&&(e--,i(f),r&&!e&&p())},o)),d.length<t?(r=!0,e||p()):n(d.at(-1)))},o)};return n(),()=>{l=!1}},A=u=>c=>{const a=new Set,i=new Map,s=new Map,{send:p,disconnect:l}=u(r=>{if("id"in r){c(r);const{id:e,result:o}=r;if(a.has(e)){a.delete(e),i.set(o,new Set),s.set(o,new Map);return}}else{const{subscription:e}=r.params,o=i.get(e),t=s.get(e);if(o){const n=r.params.result,{event:h}=n;if(h==="initialized"&&n.finalizedBlockHashes.forEach(d=>{o.add(d)}),h==="finalized"&&(n.prunedBlockHashes=n.prunedBlockHashes.filter(d=>{o.has(d)})),h==="newBlock"){o.add(n.blockHash);const d=n.blockHash,f=t.get(d);if(f){t.delete(d),c(r),Promise.resolve().then(()=>{c(f)});return}}if(h==="bestBlockChanged"){const d=n.bestBlockHash;if(!o.has(d)){s.get(e).set(d,r);return}}h==="stop"&&(o.delete(e),s.delete(e))}c(r)}});return{send:r=>{const e=r.params[0];switch(r.method){case w.follow:a.add(r.id);break;case w.unpin:const[o,t]=r.params;t.forEach(n=>{i.get(o)?.delete(n),s.get(o)?.delete(n)});break;case w.unfollow:i.delete(e),s.delete(e);break}p(r)},disconnect:l}},x=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(u=>"operation"+u)),j=u=>x.has(u.params?.result?.event),C=u=>c=>{const a=new Set,i=new Map,s=new Map,p=new Map,{send:l,disconnect:r}=u(e=>{if("id"in e){c(e);const{id:o,result:t}=e;if(a.has(o)){a.delete(o),s.set(t,new Set),p.set(t,new Map);return}const n=i.get(o);if(n!==void 0){i.delete(o);const h=e.result?.operationId;if(h!==void 0&&s.has(n)){const d=s.get(n);d.add(h);const f=p.get(n)?.get(h);f&&(f.forEach(c),p.get(n).delete(h),j(f.at(-1))&&d.delete(h))}}}else{const{subscription:o,result:t}=e.params,n=s.get(o);if(n){const{operationId:h}=e.params.result;if(h!==void 0)if(n.has(h))j(e)&&n.delete(h);else{const d=p.get(o),f=d.get(h)??[];f.push(e),d.set(h,f);return}else t?.event==="stop"&&(s.delete(o),p.delete(o))}c(e)}});return{send:e=>{const o=e.params[0];switch(e.method){case w.follow:a.add(e.id);break;case w.body:case w.call:case w.storage:i.set(e.id,o);break;case w.unfollow:s.delete(o),p.delete(o);break;case w.stopOperation:s.get(o)?.delete(e.params[1])}l(e)},disconnect:r}},J=u=>c=>u(a=>{const i=a.params?.result;if(!("id"in a)&&i){const{prunedBlockHashes:s,finalizedBlockHash:p,event:l}=i;l==="finalized"&&Array.isArray(s)?i.prunedBlockHashes=[...new Set(i.prunedBlockHashes)]:l==="initialized"&&p&&(i.finalizedBlockHashes=[i.finalizedBlockHash],delete i.finalizedBlockHash)}c(a)}),R=u=>c=>{const{send:a,disconnect:i}=u(c);return{send:s=>{const{method:p,params:l,id:r,...e}=s;p==w.unpin&&l&&Array.isArray(l[1])?l[1].forEach((o,t)=>{a({...e,id:t===0?r:`${r}-patched-${t}`,method:p,params:[l[0],o]})}):a(s)},disconnect:i}},T=u=>({jsonrpc:"2.0",...u}),[I]=O.stop.split("_"),V="unstable",q="rpc_methods",K="__INTERNAL_ID",U=u=>c=>{let a=!0,i=[],s=t=>{i.push(t)},p=({id:t,result:n,error:h})=>{if(t!==K||!a)return;if(!n){if(console.error(h),e<4){setTimeout(o,200);return}n={methods:[]}}const d=new Set(n.methods),f={};[w,E,O].forEach(m=>{Object.values(m).forEach(g=>{if(d.has(g))f[g]=g;else{const[_,,v]=g.split("_"),H=`${_}_${V}_${v}`;if(d.has(H))f[g]=H,d.delete(H),d.add(g);else if(f[g]=null,_===I){let B;const M=g==="stop"?"unwatch":"submitAndWatch";[I+"Watch",I].find(te=>["v1",V].find(ne=>d.has(B=`${te}_${ne}_${M}`)))&&(f[g]=B,d.add(g))}}})}),p=c;const b=({method:m,...g})=>{if(m===q){Promise.resolve().then(()=>{c(T({id:g.id,result:{methods:[...d]}}))});return}const _=f[m];_===null?Promise.resolve().then(()=>{c({error:{code:-32603,message:`Method not found: ${m}`},id:g.id})}):l({method:_||m,...g})};for(let m=0;a&&m<i.length;m++)b(i[m]);i=[],a&&(s=b)};const{send:l,disconnect:r}=u(t=>{p(t)});let e=0;const o=()=>{e++,l(T({id:K,method:q,params:[]}))};return o(),{send:t=>{s(t)},disconnect(){a=!1,s=p=()=>{},i=[],r()}}},W=u=>c=>{let a=0;const i=new Map,{send:s,disconnect:p}=u(l=>{i.has(l.id)&&(l.id=i.get(l.id)),c(l)});return{send:l=>{if("id"in l){const r=a++;i.set(r,l.id),l.id=r}s(l)},disconnect:p}},ee=N(W,U,C,R,J,z,A,L,P);k.fixDescendantValues=P,k.fixPrematureBlocks=z,k.fixUnorderedBlocks=A,k.fixUnorderedEvents=C,k.fromParsed=$,k.methods=G,k.parsed=N,k.patchChainHeadEvents=J,k.toParsed=S,k.translate=U,k.unpinHash=R,k.withNumericIds=W,k.withPolkadotSdkCompat=ee});
1
+ (function(b,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(b=typeof globalThis<"u"?globalThis:b||self,E(b.papiPolkadotSdkCompat={}))})(this,function(b){"use strict";const E=h=>{let d=null;const{send:n,disconnect:i}=h(t=>{d?.(JSON.parse(t))});return t=>(d=t,{send(u){n(JSON.stringify(u))},disconnect(){d=null,i()}})},N=h=>{let d=null;const{send:n,disconnect:i}=h(t=>{d?.(JSON.stringify(t))});return t=>(d=t,{send(u){n(JSON.parse(u))},disconnect(){d=null,i()}})},z=(...h)=>d=>N(h.reduce((n,i)=>i(n),E(d))),k={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},y={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:k,chainSpec:O,transaction:y}).forEach(([h,d])=>{Object.keys(d).forEach(n=>{d[n]=`${h}_v1_${n}`})});var Q=Object.freeze({__proto__:null,chainHead:k,chainSpec:O,transaction:y});const F=h=>d=>{const{send:n,disconnect:i}=h(d);return{send:t=>{switch(t.method){case O.chainName:return n({...t,method:"system_chain"});case O.genesisHash:return n({...t,method:"chain_getBlockHash",params:[0]});case O.properties:return n({...t,method:"system_properties"})}n(t)},disconnect:i}},P=h=>d=>{const n=new Set,i=new Map,t=new Map,{send:u,disconnect:c}=h(o=>{if("id"in o){d(o);const{id:e,result:a}=o;if(n.has(e)){n.delete(e),i.set(a,new Set),t.set(a,new Map);return}}else{const{subscription:e}=o.params,a=i.get(e),r=t.get(e);if(a){const s=o.params.result,{event:l}=s;if(l==="initialized"&&s.finalizedBlockHashes.forEach(p=>{a.add(p)}),l==="newBlock"){const{parentBlockHash:p}=s;if(!a.has(p)){const g=r.get(p)??[];g.push(o),r.set(p,g);return}const f=s.blockHash;a.add(s.blockHash),d(o);const m=r.get(f);m&&(r.delete(f),m.forEach(g=>{a.add(g.params.result.blockHash),d(g)}));return}l==="stop"&&(a.delete(e),t.delete(e))}d(o)}});return{send:o=>{const e=o.params[0];switch(o.method){case k.follow:n.add(o.id);break;case k.unpin:const[a,r]=o.params;r.forEach(s=>{i.get(a)?.delete(s),t.get(a)?.delete(s)});break;case k.unfollow:i.delete(e),t.delete(e);break}u(o)},disconnect:c}},B=h=>({jsonrpc:"2.0",...h}),I=(h,d,n,i={})=>B({method:"chainHead_v1_followEvent",params:{subscription:h,result:{event:d,operationId:n,...i}}}),X="__INNER_RQ_DesV",Y=h=>{let d=0;const n=new Map,i=({id:u,error:c,result:o})=>{const e=n.get(u);return e&&(n.delete(u),c?e(!1,c):e(!0,o)),!e};let t=()=>{};return[u=>{const{send:c,disconnect:o}=h(e=>{i(e)&&u(e)});return t=c,{send:t,disconnect:()=>{n.clear(),o()}}},(u,c,o,e)=>{const a=X+d++;n.set(a,(r,s)=>{(r?o:e)(s)}),t(B({id:a,method:u,params:c}))}]},Z="__INNER_OP_DesV";let x=0;const j=h=>d=>{const[n,i]=Y(h),t=ee(i),u=new Map,c=new Map,{send:o,disconnect:e}=n(r=>{if("id"in r){const s=u.get(r.id);s&&(u.delete(r.id),r.result.result==="started"&&s(r.result.operationId))}else if(r.params){const{subscription:s,result:l}=r.params,{operationId:p}=l||{},f=c.get(s);f&&l.event==="stop"&&(f.forEach(g=>{g.cancel()}),c.delete(s));const m=f?.get(p);if(m)switch(l.event){case"operationInaccessible":case"operationError":m.cancel();break;case"operationStorageDone":if(m.isInnerDone)f.delete(p);else{m.isOutterDone=!0;return}}}d(r)}),a=(r,s,l)=>p=>{let f=()=>{};c.has(r)||c.set(r,new Map);const m=c.get(r),g={isOutterDone:!1,isInnerDone:!1,cancel:()=>{f()}};m.set(p,g);let v=0;const H=l.map(_=>t(_,s,w=>{d(I(r,"operationStorageItems",p,{items:w.map(([S,D])=>({key:S,value:D}))}))},w=>{f(),g.isOutterDone||o(B({method:"chainHead_v1_stopOperation",params:[p]})),d(I(r,"operationError",p,{error:typeof w=="string"?w:JSON.stringify(w)}))},()=>{++v===l.length&&(g.isOutterDone?(f(),d(I(r,"operationStorageDone",p))):g.isInnerDone=!0)}));f=()=>{m.delete(p),H.forEach(_=>_())}};return{send:r=>{switch(r.method){case k.storage:{const[s,l,p]=r.params,f=[],m=p.filter(v=>{const H=v.type==="descendantsValues";return H&&f.push(v.key),!H}),g=a(s,l,f);if(m.length)f.length&&u.set(r.id,g);else{const v=Z+x++;d(B({id:r.id,result:{result:"started",operationId:v}})),g(v),c.get(s).get(v).isOutterDone=!0;return}r.params[2]=m;break}case k.stopOperation:{const[s,l]=r.params,p=c.get(s)?.get(l);if(p&&(p.cancel(),p.isOutterDone))return;break}case k.unfollow:{const[s]=r.params;c.get(s)?.forEach(l=>l.cancel()),c.delete(s);break}}o(r)},disconnect:e}},ee=h=>(d,n,i,t,u)=>{let c=!0,o=!1,e=0;const a=l=>{c&&(c=!1,t(l))},r=1e3,s=l=>{h("state_getKeysPaged",[d,r,l||void 0,n],p=>{c&&(p.length>0&&(e++,h("state_queryStorageAt",[p,n],([{changes:f}])=>{c&&(e--,i(f),o&&!e&&u())},a)),p.length<r?(o=!0,e||u()):s(p.at(-1)))},a)};return s(),()=>{c=!1}},A=h=>d=>{const n=new Set,i=new Map,t=new Map,{send:u,disconnect:c}=h(o=>{if("id"in o){d(o);const{id:e,result:a}=o;if(n.has(e)){n.delete(e),i.set(a,new Set),t.set(a,new Map);return}}else{const{subscription:e}=o.params,a=i.get(e),r=t.get(e);if(a){const s=o.params.result,{event:l}=s;if(l==="initialized"&&s.finalizedBlockHashes.forEach(p=>{a.add(p)}),l==="finalized"&&(s.prunedBlockHashes=s.prunedBlockHashes.filter(p=>a.has(p))),l==="newBlock"){a.add(s.blockHash);const p=s.blockHash,f=r.get(p);if(f){r.delete(p),d(o),Promise.resolve().then(()=>{d(f)});return}}if(l==="bestBlockChanged"){const p=s.bestBlockHash;if(!a.has(p)){t.get(e).set(p,o);return}}l==="stop"&&(a.delete(e),t.delete(e))}d(o)}});return{send:o=>{const e=o.params[0];switch(o.method){case k.follow:n.add(o.id);break;case k.unpin:const[a,r]=o.params;r.forEach(s=>{i.get(a)?.delete(s),t.get(a)?.delete(s)});break;case k.unfollow:i.delete(e),t.delete(e);break}u(o)},disconnect:c}},te=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(h=>"operation"+h)),C=h=>te.has(h.params?.result?.event),J=h=>d=>{const n=new Set,i=new Map,t=new Map,u=new Map,{send:c,disconnect:o}=h(e=>{if("id"in e){d(e);const{id:a,result:r}=e;if(n.has(a)){n.delete(a),t.set(r,new Set),u.set(r,new Map);return}const s=i.get(a);if(s!==void 0){i.delete(a);const l=e.result?.operationId;if(l!==void 0&&t.has(s)){const p=t.get(s);p.add(l);const f=u.get(s)?.get(l);f&&(f.forEach(d),u.get(s).delete(l),C(f.at(-1))&&p.delete(l))}}}else{const{subscription:a,result:r}=e.params,s=t.get(a);if(s){const{operationId:l}=e.params.result;if(l!==void 0)if(s.has(l))C(e)&&s.delete(l);else{const p=u.get(a),f=p.get(l)??[];f.push(e),p.set(l,f);return}else r?.event==="stop"&&(t.delete(a),u.delete(a))}d(e)}});return{send:e=>{const a=e.params[0];switch(e.method){case k.follow:n.add(e.id);break;case k.body:case k.call:case k.storage:i.set(e.id,a);break;case k.unfollow:t.delete(a),u.delete(a);break;case k.stopOperation:t.get(a)?.delete(e.params[1])}c(e)},disconnect:o}},T=h=>d=>h(n=>{const i=n.params?.result;if(!("id"in n)&&i){const{prunedBlockHashes:t,finalizedBlockHash:u,event:c}=i;c==="finalized"&&Array.isArray(t)?i.prunedBlockHashes=[...new Set(i.prunedBlockHashes)]:c==="initialized"&&u&&(i.finalizedBlockHashes=[i.finalizedBlockHash],delete i.finalizedBlockHash)}d(n)}),R=h=>d=>{const{send:n,disconnect:i}=h(d);return{send:t=>{const{method:u,params:c,id:o,...e}=t;u==k.unpin&&c&&Array.isArray(c[1])?c[1].forEach((a,r)=>{n({...e,id:r===0?o:`${o}-patched-${r}`,method:u,params:[c[0],a]})}):n(t)},disconnect:i}},V=h=>({jsonrpc:"2.0",...h}),[$]=y.stop.split("_"),q="unstable",G="rpc_methods",K="__INTERNAL_ID",U=h=>d=>{let n=!0,i=[],t=l=>{i.push(l)};const u=({id:l,result:p,error:f})=>{if(l!==K||!n)return;if(!p){if(console.error(f),r<4){setTimeout(s,200);return}p={methods:[]}}const m=new Set(p.methods),g={};[k,O,y].forEach(_=>{Object.values(_).forEach(w=>{if(m.has(w))g[w]=w;else{const[S,,D]=w.split("_"),M=`${S}_${q}_${D}`;if(m.has(M))g[w]=M,m.delete(M),m.add(w);else if(g[w]=null,S===$){let L;const ne=w==="stop"?"unwatch":"submitAndWatch";[$+"Watch",$].find(oe=>["v1",q].find(ae=>m.has(L=`${oe}_${ae}_${ne}`)))&&(g[w]=L,m.add(w))}}})}),c=d;const v=({method:_,...w})=>{if(_===G){Promise.resolve().then(()=>{d(V({id:w.id,result:{methods:[...m]}}))});return}const S=g[_];S===null?_.split("_")[2]==="follow"?(a(),t({method:_,...w})):Promise.resolve().then(()=>{d({error:{code:-32603,message:`Method not found: ${_}`},id:w.id})}):o({method:S||_,...w})},H=[...i];i=[];for(let _=0;n&&_<H.length;_++)v(H[_]);n&&(t=v)};let c=u;const{send:o,disconnect:e}=h(l=>{c(l)}),a=()=>{n=!0,i=[],t=l=>{i.push(l)},c=u,s()};let r=0;const s=()=>{r++,o(V({id:K,method:G,params:[]}))};return s(),{send:l=>{t(l)},disconnect(){n=!1,t=c=()=>{},i=[],e()}}},W=h=>d=>{let n=0;const i=new Map,{send:t,disconnect:u}=h(c=>{i.has(c.id)&&(c.id=i.get(c.id)),d(c)});return{send:c=>{if("id"in c){const o=n++;i.set(o,c.id),c.id=o}t(c)},disconnect:u}},se=z(W,U,J,R,T,P,A,F,j);b.fixDescendantValues=j,b.fixPrematureBlocks=P,b.fixUnorderedBlocks=A,b.fixUnorderedEvents=J,b.fromParsed=N,b.methods=Q,b.parsed=z,b.patchChainHeadEvents=T,b.toParsed=E,b.translate=U,b.unpinHash=R,b.withNumericIds=W,b.withPolkadotSdkCompat=se});
@@ -1 +1 @@
1
- (function(m,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(m=typeof globalThis<"u"?globalThis:m||self,v(m.papiWsProviderWeb={}))})(this,function(m){"use strict";const v=s=>JSON.stringify({jsonrpc:"2.0",...s}),W=new Set(["v1","unstable"].map(s=>`chainHead_${s}_unfollow`)),G=s=>{let e={type:1,pending:[]};const r=n=>{if(e.type===0){const t=JSON.parse(n);if("id"in t)"result"in t&&e.onGoingRequests.get(t.id)?.type===0&&e.activeChainHeads.add(t.result),e.onGoingRequests.delete(t.id);else if("params"in t){const{subscription:a,result:i}=t.params;i?.event==="stop"&&e.activeChainHeads.delete(a)}}e.type!==2&&s(n)},o=n=>{if(e.type===2)return;if(e.type===1){e.pending.push(n);return}const t=JSON.parse(n);if(W.has(t.method)&&e.activeChainHeads.delete(t.params[0]),"id"in t){const{method:a,id:i}=t,c=a.startsWith("chainHead")?a.endsWith("follow")?{type:0,msg:n}:{type:1,id:i}:{type:2,msg:n};e.onGoingRequests.set(i,c)}e.connection.send(n)};return{send:o,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:n=>{if(e.type!==1)throw new Error("Nonesense");const{pending:t}=e,a=new Map,i=new Set;e={type:0,connection:n(r,()=>{e={type:1,pending:[]},i.forEach(c=>{r(v({params:{subscription:c,result:{event:"stop",internal:!0}}}))}),i.clear();for(const c of a.values())c.type===1?r(v({id:c.id,error:{code:-32603,message:"Internal error"},internal:!0})):o(c.msg);a.clear()}),onGoingRequests:a,activeChainHeads:i},t.forEach(o)}}},I=s=>e=>{let r=G(e);const o=()=>{s().then(n=>{if(r)r.connect((t,a)=>n(t,()=>{a(),o()}));else try{n(()=>{},()=>{}).disconnect()}catch{}},()=>{r&&setTimeout(o,0)})};return o(),{send:n=>{r?.send(n)},disconnect:()=>{r?.disconnect(),r=null}}};var f=(s=>(s[s.CONNECTING=0]="CONNECTING",s[s.CONNECTED=1]="CONNECTED",s[s.ERROR=2]="ERROR",s[s.CLOSE=3]="CLOSE",s))(f||{});const C={};["v1","unstable"].forEach(s=>{C[`chainHead_${s}_follow`]="follow",C[`chainHead_${s}_unfollow`]="unfollow"});const _=(s,e)=>{const r=new Set,o=new Map,n=new Set;return Object.assign(t=>{const{send:a,disconnect:i}=s(c=>{const l=JSON.parse(c);if("id"in l){const{id:p,result:h}=l,w=o.get(p);if(w){if(o.delete(p),r.has(h)){r.delete(h);return}n.add(h);const y=n.size+o.size;if(y>2)console.warn(`Too many chainHead follow subscriptions (${y})`);else if(l.error){console.warn(`chainHead follow failed on the ${y} sub`),e(),o.set(p,w),a(w);return}}}else{const{subscription:p,result:h}=l.params;h?.event==="stop"&&(n.has(p)?n.delete(p):r.add(p))}t(c)});return{send(c){const l=JSON.parse(c),p=C[l.method];p==="follow"?o.set(l.id,c):p==="unfollow"&&n.delete(l.params[0]),a(c)},disconnect:i}},{cleanup:()=>{r.clear(),o.clear(),n.clear()}})},H={type:f.ERROR,event:{type:"timeout"}},g=()=>{},$=s=>s.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),j=(s=>(...e)=>{let r=[],o=g,n=3500;const[t]=e;e.length===1&&typeof t=="object"&&!Array.isArray(t)?(r=$(t.endpoints),o=t.onStatusChanged??g,n=t.timeout??n):(typeof e[1]=="function"&&(o=e[1]),Array.isArray(t)?r=$(t):(r=[[t]],e[1]&&e[1]!==o&&(r[0][1]=e[1]),e[2]&&(o=e[2])));let a=0,i,c=null,l=g,p=g;const h=_(I(async()=>{const[y,R]=c||r[a++%r.length];c=null;const u=new s(y,R),b=()=>{try{u.addEventListener("error",g,{once:!0}),u.close()}catch{}};return o(i={type:f.CONNECTING,uri:y,protocols:R}),await new Promise((T,S)=>{const N=()=>{E(),T()},O=d=>{E(),d==null&&b(),console.error(`Unable to connect to ${y}${R?", protocols: "+R:""}`),o(i={type:d?f.ERROR:f.CLOSE,event:d}),setTimeout(S,d?300:0,d)},L=n!==1/0?setTimeout(()=>{E(),b(),o(i=H),S(H.event)},n):void 0,E=()=>{clearTimeout(L),u.removeEventListener("error",O),u.removeEventListener("open",N)};u.addEventListener("open",N),u.addEventListener("error",O),l=()=>{O(null)}}),o(i={type:f.CONNECTED,uri:y,protocols:R}),(T,S)=>{const N=d=>{typeof d.data=="string"&&T(d.data)},O=d=>A=>{console.warn(`WS halt (${d})`),o(i={type:d,event:A}),S()},L=O(f.ERROR),E=O(f.CLOSE);return u.addEventListener("message",N),u.addEventListener("error",L),u.addEventListener("close",E),l=d=>{p(),l=g,u.removeEventListener("message",N),u.removeEventListener("error",L),u.removeEventListener("close",E),b(),d&&E({})},{send:d=>{u.send(d)},disconnect:l}}}),()=>{w()});p=h.cleanup,delete h.cleanup;const w=(...y)=>{i.type!==f.CLOSE&&(y.length&&(c=y),i.type!==f.ERROR&&l(!0))};return Object.assign(h,{switch:w,getStatus:()=>i})})(WebSocket);m.WsEvent=f,m.getWsProvider=j});
1
+ (function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g.papiWsProviderWeb={}))})(this,function(g){"use strict";const w=o=>JSON.stringify({jsonrpc:"2.0",...o}),_=new Set(["v1","unstable"].map(o=>`chainHead_${o}_unfollow`)),W=o=>{let e={type:1,pending:[]};const r=t=>{if(e.type===0){const n=JSON.parse(t);if("id"in n)"result"in n&&e.onGoingRequests.get(n.id)?.type===0&&e.activeChainHeads.add(n.result),e.onGoingRequests.delete(n.id);else if("params"in n){const{subscription:c,result:i}=n.params;i?.event==="stop"&&e.activeChainHeads.delete(c)}}e.type!==2&&o(t)},s=t=>{if(e.type===2)return;if(e.type===1){e.pending.push(t);return}const n=JSON.parse(t);if(_.has(n.method)&&e.activeChainHeads.delete(n.params[0]),"id"in n){const{method:c,id:i}=n,p=c.startsWith("chainHead")?c.endsWith("follow")?{type:0,msg:t}:{type:1,id:i}:{type:2,msg:t};e.onGoingRequests.set(i,p)}e.connection.send(t)};return{send:s,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:t=>{if(e.type!==1)throw new Error("Nonesense");const{pending:n}=e,c=new Map,i=new Set;e={type:0,connection:t(r,()=>{e={type:1,pending:[]},i.forEach(p=>{r(w({params:{subscription:p,result:{event:"stop",internal:!0}}}))}),i.clear();for(const p of c.values())p.type===1?r(w({id:p.id,error:{code:-32603,message:"Internal error"},internal:!0})):s(p.msg);c.clear()}),onGoingRequests:c,activeChainHeads:i},n.forEach(s)}}},G=o=>e=>{let r=W(e);const s=()=>{o().then(t=>{if(r)r.connect((n,c)=>t(n,()=>{c(),s()}));else try{t(()=>{},()=>{}).disconnect()}catch{}},()=>{r&&setTimeout(s,0)})};return s(),{send:t=>{r?.send(t)},disconnect:()=>{r?.disconnect(),r=null}}};var h=(o=>(o[o.CONNECTING=0]="CONNECTING",o[o.CONNECTED=1]="CONNECTED",o[o.ERROR=2]="ERROR",o[o.CLOSE=3]="CLOSE",o))(h||{});const b={};["v1","unstable"].forEach(o=>{b[`chainHead_${o}_follow`]="follow",b[`chainHead_${o}_unfollow`]="unfollow"});const I=(o,e)=>{const r=new Set,s=new Map,t=new Set;let n;return Object.assign(c=>{const{send:i,disconnect:p}=o(u=>{const f=JSON.parse(u);if("id"in f){const{id:a,result:v}=f;if(a===n&&(n=void 0,v&&!v.methods.some(m=>{const[d,,N]=m.split("_");return d==="chainHead"&&N==="follow"}))){c(u),e();return}const y=s.get(a);if(y){if(s.delete(a),r.has(v)){r.delete(v);return}t.add(v);const m=t.size+s.size;if(m>2)console.warn(`Too many chainHead follow subscriptions (${m})`);else if(f.error){console.warn(`chainHead follow failed on the ${m} sub`),e(),s.set(a,y),i(y);return}}}else{const{subscription:a,result:v}=f.params;v?.event==="stop"&&(t.has(a)?t.delete(a):r.add(a))}c(u)});return{send(u){const f=JSON.parse(u);f.method==="rpc_methods"&&(n=f.id);const a=b[f.method];a==="follow"?s.set(f.id,u):a==="unfollow"&&t.delete(f.params[0]),i(u)},disconnect:p}},{cleanup:()=>{r.clear(),s.clear(),t.clear()}})},H={type:h.ERROR,event:{type:"timeout"}},O=()=>{},$=o=>o.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),j=(o=>(...e)=>{let r=[],s=O,t=3500;const[n]=e;e.length===1&&typeof n=="object"&&!Array.isArray(n)?(r=$(n.endpoints),s=n.onStatusChanged??O,t=n.timeout??t):(typeof e[1]=="function"&&(s=e[1]),Array.isArray(n)?r=$(n):(r=[[n]],e[1]&&e[1]!==s&&(r[0][1]=e[1]),e[2]&&(s=e[2])));let c=0,i,p=null,u=O,f=O;const a=I(G(async()=>{const[y,m]=p||r[c++%r.length];p=null;const d=new o(y,m),N=()=>{try{d.addEventListener("error",O,{once:!0}),d.close()}catch{}};return s(i={type:h.CONNECTING,uri:y,protocols:m}),await new Promise((T,L)=>{const S=()=>{E(),T()},R=l=>{E(),l==null&&N(),console.error(`Unable to connect to ${y}${m?", protocols: "+m:""}`),s(i={type:l?h.ERROR:h.CLOSE,event:l}),setTimeout(L,l?300:0,l)},C=t!==1/0?setTimeout(()=>{E(),N(),s(i=H),L(H.event)},t):void 0,E=()=>{clearTimeout(C),d.removeEventListener("error",R),d.removeEventListener("open",S)};d.addEventListener("open",S),d.addEventListener("error",R),u=()=>{R(null)}}),s(i={type:h.CONNECTED,uri:y,protocols:m}),(T,L)=>{const S=l=>{typeof l.data=="string"&&T(l.data)},R=l=>A=>{console.warn(`WS halt (${l})`),s(i={type:l,event:A}),L()},C=R(h.ERROR),E=R(h.CLOSE);return d.addEventListener("message",S),d.addEventListener("error",C),d.addEventListener("close",E),u=l=>{f(),u=O,d.removeEventListener("message",S),d.removeEventListener("error",C),d.removeEventListener("close",E),N(),l&&E({})},{send:l=>{d.send(l)},disconnect:u}}}),()=>{v()});f=a.cleanup,delete a.cleanup;const v=(...y)=>{i.type!==h.CLOSE&&(y.length&&(p=y),i.type!==h.ERROR&&u(!0))};return Object.assign(a,{switch:v,getStatus:()=>i})})(WebSocket);g.WsEvent=h,g.getWsProvider=j});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -192,27 +192,27 @@
192
192
  },
193
193
  "dependencies": {
194
194
  "@rx-state/core": "^0.1.4",
195
- "@polkadot-api/cli": "0.11.0",
195
+ "@polkadot-api/cli": "0.11.1",
196
196
  "@polkadot-api/ink-contracts": "0.2.5",
197
- "@polkadot-api/known-chains": "0.7.0",
198
197
  "@polkadot-api/json-rpc-provider": "0.0.4",
198
+ "@polkadot-api/known-chains": "0.7.1",
199
199
  "@polkadot-api/logs-provider": "0.0.6",
200
200
  "@polkadot-api/metadata-compatibility": "0.1.15",
201
201
  "@polkadot-api/metadata-builders": "0.10.1",
202
- "@polkadot-api/observable-client": "0.8.0",
203
- "@polkadot-api/polkadot-sdk-compat": "2.3.1",
202
+ "@polkadot-api/observable-client": "0.8.1",
204
203
  "@polkadot-api/pjs-signer": "0.6.4",
204
+ "@polkadot-api/polkadot-sdk-compat": "2.3.2",
205
205
  "@polkadot-api/polkadot-signer": "0.1.6",
206
206
  "@polkadot-api/signer": "0.1.14",
207
207
  "@polkadot-api/sm-provider": "0.1.7",
208
208
  "@polkadot-api/smoldot": "0.3.8",
209
- "@polkadot-api/substrate-client": "0.3.0",
210
209
  "@polkadot-api/substrate-bindings": "0.11.0",
211
- "@polkadot-api/ws-provider": "0.3.6",
212
- "@polkadot-api/utils": "0.1.2"
210
+ "@polkadot-api/substrate-client": "0.3.0",
211
+ "@polkadot-api/utils": "0.1.2",
212
+ "@polkadot-api/ws-provider": "0.4.0"
213
213
  },
214
214
  "devDependencies": {
215
- "rxjs": "^7.8.1",
215
+ "rxjs": "^7.8.2",
216
216
  "@polkadot-api/codegen": "0.13.0"
217
217
  },
218
218
  "scripts": {