@wishknish/knishio-client-js 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.iife.js +10 -10
- package/package.json +1 -1
- package/src/AtomMeta.js +7 -6
- package/src/KnishIOClient.js +3 -3
- package/src/Meta.js +8 -6
package/dist/client.iife.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var KnishIO=function(P){"use strict";var Ya=Object.defineProperty;var Za=(P,ve,Le)=>ve in P?Ya(P,ve,{enumerable:!0,configurable:!0,writable:!0,value:Le}):P[ve]=Le;var ut=(P,ve,Le)=>Za(P,typeof ve!="symbol"?ve+"":ve,Le);const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="ARRAYBUFFER not supported by this environment",Fn="UINT8ARRAY not supported by this environment";function Wn(n,e,t,r){let s,i,o;const a=e||[0],c=(t=t||0)>>>3,l=r===-1?3:0;for(s=0;s<n.length;s+=1)o=s+c,i=o>>>2,a.length<=i&&a.push(0),a[i]|=n[s]<<8*(l+r*(o%4));return{value:a,binLen:8*n.length+t}}function Xe(n,e,t){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(n){case"HEX":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(u=0;u<o.length;u+=2){if(d=parseInt(o.substr(u,2),16),isNaN(d))throw new Error("String of HEX type contains invalid characters");for(m=(u>>>1)+g,h=m>>>2;y.length<=h;)y.push(0);y[h]|=d<<8*(w+l*(m%4))}return{value:y,binLen:4*o.length+c}}(r,s,i,t)};case"TEXT":return function(r,s,i){return function(o,a,c,l,u){let d,h,m,y,g,w,v,A,S=0;const p=c||[0],k=(l=l||0)>>>3;if(a==="UTF8")for(v=u===-1?3:0,m=0;m<o.length;m+=1)for(d=o.charCodeAt(m),h=[],128>d?h.push(d):2048>d?(h.push(192|d>>>6),h.push(128|63&d)):55296>d||57344<=d?h.push(224|d>>>12,128|d>>>6&63,128|63&d):(m+=1,d=65536+((1023&d)<<10|1023&o.charCodeAt(m)),h.push(240|d>>>18,128|d>>>12&63,128|d>>>6&63,128|63&d)),y=0;y<h.length;y+=1){for(w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=h[y]<<8*(v+u*(w%4)),S+=1}else for(v=u===-1?2:0,A=a==="UTF16LE"&&u!==1||a!=="UTF16LE"&&u===1,m=0;m<o.length;m+=1){for(d=o.charCodeAt(m),A===!0&&(y=255&d,d=y<<8|d>>>8),w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=d<<8*(v+u*(w%4)),S+=2}return{value:p,binLen:8*S+l}}(r,e,s,i,t)};case"B64":return function(r,s,i){return function(o,a,c,l){let u,d,h,m,y,g,w,v=0;const A=a||[0],S=(c=c||0)>>>3,p=l===-1?3:0,k=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),k!==-1&&k<o.length)throw new Error("Invalid '=' found in base-64 string");for(d=0;d<o.length;d+=4){for(y=o.substr(d,4),m=0,h=0;h<y.length;h+=1)u=ve.indexOf(y.charAt(h)),m|=u<<18-6*h;for(h=0;h<y.length-1;h+=1){for(w=v+S,g=w>>>2;A.length<=g;)A.push(0);A[g]|=(m>>>16-8*h&255)<<8*(p+l*(w%4)),v+=1}}return{value:A,binLen:8*v+c}}(r,s,i,t)};case"BYTES":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(d=0;d<o.length;d+=1)u=o.charCodeAt(d),m=d+g,h=m>>>2,y.length<=h&&y.push(0),y[h]|=u<<8*(w+l*(m%4));return{value:y,binLen:8*o.length+c}}(r,s,i,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(r,s,i){return function(o,a,c,l){return Wn(new Uint8Array(o),a,c,l)}(r,s,i,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(r,s,i){return Wn(r,s,i,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Dn(n,e,t,r){switch(n){case"HEX":return function(s){return function(i,o,a,c){const l="0123456789abcdef";let u,d,h="";const m=o/8,y=a===-1?3:0;for(u=0;u<m;u+=1)d=i[u>>>2]>>>8*(y+a*(u%4)),h+=l.charAt(d>>>4&15)+l.charAt(15&d);return c.outputUpper?h.toUpperCase():h}(s,e,t,r)};case"B64":return function(s){return function(i,o,a,c){let l,u,d,h,m,y="";const g=o/8,w=a===-1?3:0;for(l=0;l<g;l+=3)for(h=l+1<g?i[l+1>>>2]:0,m=l+2<g?i[l+2>>>2]:0,d=(i[l>>>2]>>>8*(w+a*(l%4))&255)<<16|(h>>>8*(w+a*((l+1)%4))&255)<<8|m>>>8*(w+a*((l+2)%4))&255,u=0;u<4;u+=1)y+=8*l+6*u<=o?ve.charAt(d>>>6*(3-u)&63):c.b64Pad;return y}(s,e,t,r)};case"BYTES":return function(s){return function(i,o,a){let c,l,u="";const d=o/8,h=a===-1?3:0;for(c=0;c<d;c+=1)l=i[c>>>2]>>>8*(h+a*(c%4))&255,u+=String.fromCharCode(l);return u}(s,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(s){return function(i,o,a){let c;const l=o/8,u=new ArrayBuffer(l),d=new Uint8Array(u),h=a===-1?3:0;for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(h+a*(c%4))&255;return u}(s,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(s){return function(i,o,a){let c;const l=o/8,u=a===-1?3:0,d=new Uint8Array(l);for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(u+a*(c%4))&255;return d}(s,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const ct=4294967296,x=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Te=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ht="Chosen SHA variant is not supported",jn="Cannot set numRounds with MAC";function qt(n,e){let t,r;const s=n.binLen>>>3,i=e.binLen>>>3,o=s<<3,a=4-s<<3;if(s%4!=0){for(t=0;t<i;t+=4)r=s+t>>>2,n.value[r]|=e.value[t>>>2]<<o,n.value.push(0),n.value[r+1]|=e.value[t>>>2]>>>a;return(n.value.length<<2)-4>=i+s&&n.value.pop(),{value:n.value,binLen:n.binLen+e.binLen}}return{value:n.value.concat(e.value),binLen:n.binLen+e.binLen}}function Qn(n){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},t=n||{},r="Output length must be a multiple of 8";if(e.outputUpper=t.outputUpper||!1,t.b64Pad&&(e.b64Pad=t.b64Pad),t.outputLen){if(t.outputLen%8!=0)throw new Error(r);e.outputLen=t.outputLen}else if(t.shakeLen){if(t.shakeLen%8!=0)throw new Error(r);e.outputLen=t.shakeLen}if(typeof e.outputUpper!="boolean")throw new Error("Invalid outputUpper formatting option");if(typeof e.b64Pad!="string")throw new Error("Invalid b64Pad formatting option");return e}function Ue(n,e,t,r){const s=n+" must include a value and format";if(!e){if(!r)throw new Error(s);return r}if(e.value===void 0||!e.format)throw new Error(s);return Xe(e.format,e.encoding||"UTF8",t)(e.value)}let Ht=class{constructor(e,t,r){const s=r||{};if(this.t=t,this.i=s.encoding||"UTF8",this.numRounds=s.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,r=0;const s=this.m>>>5,i=this.C(e,this.h,this.u),o=i.binLen,a=i.value,c=o>>>5;for(t=0;t<c;t+=s)r+this.m<=o&&(this.U=this.v(a.slice(t,t+s),this.U),r+=this.m);return this.A+=r,this.h=a.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,s,i=this.R;const o=Qn(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");i=o.outputLen}const a=Dn(e,i,this.T,o);if(this.H&&this.g)return a(this.g(o));for(s=this.F(this.h.slice(),this.u,this.A,this.L(this.U),i),r=1;r<this.numRounds;r+=1)this.K&&i%32!=0&&(s[s.length-1]&=16777215>>>24-i%32),s=this.F(s,i,0,this.B(this.o),i);return a(s)}setHMACKey(e,t,r){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const s=Xe(t,(r||{}).encoding||"UTF8",this.T);this.k(s(e))}k(e){const t=this.m>>>3,r=t/4-1;let s;if(this.numRounds!==1)throw new Error(jn);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=r;)e.value.push(0);for(s=0;s<=r;s+=1)this.S[s]=909522486^e.value[s],this.p[s]=1549556828^e.value[s];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const r=Qn(t);return Dn(e,this.R,this.T,r)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}};function Ye(n,e){return n<<e|n>>>32-e}function ke(n,e){return n>>>e|n<<32-e}function Vn(n,e){return n>>>e}function zn(n,e,t){return n^e^t}function Jn(n,e,t){return n&e^~n&t}function Gn(n,e,t){return n&e^n&t^e&t}function $s(n){return ke(n,2)^ke(n,13)^ke(n,22)}function X(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Is(n,e,t,r){const s=(65535&n)+(65535&e)+(65535&t)+(65535&r);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16))<<16|65535&s}function dt(n,e,t,r,s){const i=(65535&n)+(65535&e)+(65535&t)+(65535&r)+(65535&s);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function Ts(n){return ke(n,7)^ke(n,18)^Vn(n,3)}function Es(n){return ke(n,6)^ke(n,11)^ke(n,25)}function Cs(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Xn(n,e){let t,r,s,i,o,a,c;const l=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=0;c<80;c+=1)l[c]=c<16?n[c]:Ye(l[c-3]^l[c-8]^l[c-14]^l[c-16],1),a=c<20?dt(Ye(t,5),Jn(r,s,i),o,1518500249,l[c]):c<40?dt(Ye(t,5),zn(r,s,i),o,1859775393,l[c]):c<60?dt(Ye(t,5),Gn(r,s,i),o,2400959708,l[c]):dt(Ye(t,5),zn(r,s,i),o,3395469782,l[c]),o=i,i=s,s=Ye(r,30),r=t,t=a;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e}function Ms(n,e,t,r){let s;const i=15+(e+65>>>9<<4),o=e+t;for(;n.length<=i;)n.push(0);for(n[e>>>5]|=128<<24-e%32,n[i]=4294967295&o,n[i-1]=o/ct|0,s=0;s<n.length;s+=16)r=Xn(n.slice(s,s+16),r);return r}let Os=class extends Ht{constructor(e,t,r){if(e!=="SHA-1")throw new Error(ht);super(e,t,r);const s=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Xn,this.L=function(i){return i.slice()},this.B=Cs,this.F=Ms,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};function Yn(n){let e;return e=n=="SHA-224"?Te.slice():Ee.slice(),e}function Zn(n,e){let t,r,s,i,o,a,c,l,u,d,h;const m=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<64;h+=1)m[h]=h<16?n[h]:Is(ke(y=m[h-2],17)^ke(y,19)^Vn(y,10),m[h-7],Ts(m[h-15]),m[h-16]),u=dt(l,Es(o),Jn(o,a,c),x[h],m[h]),d=X($s(t),Gn(t,r,s)),l=c,c=a,a=o,o=X(i,u),i=s,s=r,r=t,t=X(u,d);var y;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e[5]=X(a,e[5]),e[6]=X(c,e[6]),e[7]=X(l,e[7]),e}let Ns=class extends Ht{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=Zn,this.L=function(i){return i.slice()},this.B=Yn,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=15+(u+65>>>9<<4),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=16)h=Zn(l.slice(y,y+16),h);return g=m==="SHA-224"?[h[0],h[1],h[2],h[3],h[4],h[5],h[6]]:h,g}(i,o,a,c,e)},this.U=Yn(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};class f{constructor(e,t){this.N=e,this.I=t}}function er(n,e){let t;return e>32?(t=64-e,new f(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new f(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function Se(n,e){let t;return e<32?(t=32-e,new f(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new f(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function tr(n,e){return new f(n.N>>>e,n.I>>>e|n.N<<32-e)}function Rs(n,e,t){return new f(n.N&e.N^n.N&t.N^e.N&t.N,n.I&e.I^n.I&t.I^e.I&t.I)}function Us(n){const e=Se(n,28),t=Se(n,34),r=Se(n,39);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function ge(n,e){let t,r;t=(65535&n.I)+(65535&e.I),r=(n.I>>>16)+(e.I>>>16)+(t>>>16);const s=(65535&r)<<16|65535&t;return t=(65535&n.N)+(65535&e.N)+(r>>>16),r=(n.N>>>16)+(e.N>>>16)+(t>>>16),new f((65535&r)<<16|65535&t,s)}function qs(n,e,t,r){let s,i;s=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I),i=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s>>>16);const o=(65535&i)<<16|65535&s;return s=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(i>>>16),i=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s>>>16),new f((65535&i)<<16|65535&s,o)}function Hs(n,e,t,r,s){let i,o;i=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I)+(65535&s.I),o=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s.I>>>16)+(i>>>16);const a=(65535&o)<<16|65535&i;return i=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(65535&s.N)+(o>>>16),o=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s.N>>>16)+(i>>>16),new f((65535&o)<<16|65535&i,a)}function ft(n,e){return new f(n.N^e.N,n.I^e.I)}function Bs(n){const e=Se(n,19),t=Se(n,61),r=tr(n,6);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ps(n){const e=Se(n,1),t=Se(n,8),r=tr(n,7);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ls(n){const e=Se(n,14),t=Se(n,18),r=Se(n,41);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}const Ks=[new f(x[0],3609767458),new f(x[1],602891725),new f(x[2],3964484399),new f(x[3],2173295548),new f(x[4],4081628472),new f(x[5],3053834265),new f(x[6],2937671579),new f(x[7],3664609560),new f(x[8],2734883394),new f(x[9],1164996542),new f(x[10],1323610764),new f(x[11],3590304994),new f(x[12],4068182383),new f(x[13],991336113),new f(x[14],633803317),new f(x[15],3479774868),new f(x[16],2666613458),new f(x[17],944711139),new f(x[18],2341262773),new f(x[19],2007800933),new f(x[20],1495990901),new f(x[21],1856431235),new f(x[22],3175218132),new f(x[23],2198950837),new f(x[24],3999719339),new f(x[25],766784016),new f(x[26],2566594879),new f(x[27],3203337956),new f(x[28],1034457026),new f(x[29],2466948901),new f(x[30],3758326383),new f(x[31],168717936),new f(x[32],1188179964),new f(x[33],1546045734),new f(x[34],1522805485),new f(x[35],2643833823),new f(x[36],2343527390),new f(x[37],1014477480),new f(x[38],1206759142),new f(x[39],344077627),new f(x[40],1290863460),new f(x[41],3158454273),new f(x[42],3505952657),new f(x[43],106217008),new f(x[44],3606008344),new f(x[45],1432725776),new f(x[46],1467031594),new f(x[47],851169720),new f(x[48],3100823752),new f(x[49],1363258195),new f(x[50],3750685593),new f(x[51],3785050280),new f(x[52],3318307427),new f(x[53],3812723403),new f(x[54],2003034995),new f(x[55],3602036899),new f(x[56],1575990012),new f(x[57],1125592928),new f(x[58],2716904306),new f(x[59],442776044),new f(x[60],593698344),new f(x[61],3733110249),new f(x[62],2999351573),new f(x[63],3815920427),new f(3391569614,3928383900),new f(3515267271,566280711),new f(3940187606,3454069534),new f(4118630271,4000239992),new f(116418474,1914138554),new f(174292421,2731055270),new f(289380356,3203993006),new f(460393269,320620315),new f(685471733,587496836),new f(852142971,1086792851),new f(1017036298,365543100),new f(1126000580,2618297676),new f(1288033470,3409855158),new f(1501505948,4234509866),new f(1607167915,987167468),new f(1816402316,1246189591)];function nr(n){return n==="SHA-384"?[new f(3418070365,Te[0]),new f(1654270250,Te[1]),new f(2438529370,Te[2]),new f(355462360,Te[3]),new f(1731405415,Te[4]),new f(41048885895,Te[5]),new f(3675008525,Te[6]),new f(1203062813,Te[7])]:[new f(Ee[0],4089235720),new f(Ee[1],2227873595),new f(Ee[2],4271175723),new f(Ee[3],1595750129),new f(Ee[4],2917565137),new f(Ee[5],725511199),new f(Ee[6],4215389547),new f(Ee[7],327033209)]}function rr(n,e){let t,r,s,i,o,a,c,l,u,d,h,m;const y=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<80;h+=1)h<16?(m=2*h,y[h]=new f(n[m],n[m+1])):y[h]=qs(Bs(y[h-2]),y[h-7],Ps(y[h-15]),y[h-16]),u=Hs(l,Ls(o),(w=a,v=c,new f((g=o).N&w.N^~g.N&v.N,g.I&w.I^~g.I&v.I)),Ks[h],y[h]),d=ge(Us(t),Rs(t,r,s)),l=c,c=a,a=o,o=ge(i,u),i=s,s=r,r=t,t=ge(u,d);var g,w,v;return e[0]=ge(t,e[0]),e[1]=ge(r,e[1]),e[2]=ge(s,e[2]),e[3]=ge(i,e[3]),e[4]=ge(o,e[4]),e[5]=ge(a,e[5]),e[6]=ge(c,e[6]),e[7]=ge(l,e[7]),e}let Fs=class extends Ht{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(ht);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Xe(this.t,this.i,this.T),this.v=rr,this.L=function(i){return i.slice()},this.B=nr,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=31+(u+129>>>10<<5),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ct|0,y=0;y<l.length;y+=32)h=rr(l.slice(y,y+32),h);return g=m==="SHA-384"?[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I]:[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I,h[6].N,h[6].I,h[7].N,h[7].I],g}(i,o,a,c,e)},this.U=nr(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};const Ws=[new f(0,1),new f(0,32898),new f(2147483648,32906),new f(2147483648,2147516416),new f(0,32907),new f(0,2147483649),new f(2147483648,2147516545),new f(2147483648,32777),new f(0,138),new f(0,136),new f(0,2147516425),new f(0,2147483658),new f(0,2147516555),new f(2147483648,139),new f(2147483648,32905),new f(2147483648,32771),new f(2147483648,32770),new f(2147483648,128),new f(0,32778),new f(2147483648,2147483658),new f(2147483648,2147516545),new f(2147483648,32896),new f(0,2147483649),new f(2147483648,2147516424)],Ds=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function mn(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new f(0,0),new f(0,0),new f(0,0),new f(0,0),new f(0,0)];return t}function js(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function Bt(n,e){let t,r,s,i;const o=[],a=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=ft(e[(r>>>1)%5][(r>>>1)/5|0],new f(n[r+1],n[r]));for(t=0;t<24;t+=1){for(i=mn(),r=0;r<5;r+=1)o[r]=(c=e[r][0],l=e[r][1],u=e[r][2],d=e[r][3],h=e[r][4],new f(c.N^l.N^u.N^d.N^h.N,c.I^l.I^u.I^d.I^h.I));for(r=0;r<5;r+=1)a[r]=ft(o[(r+4)%5],er(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(e[r][s],a[r]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)i[s][(2*r+3*s)%5]=er(e[r][s],Ds[r][s]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=ft(i[r][s],new f(~i[(r+1)%5][s].N&i[(r+2)%5][s].N,~i[(r+1)%5][s].I&i[(r+2)%5][s].I));e[0][0]=ft(e[0][0],Ws[t])}var c,l,u,d,h;return e}function sr(n){let e,t,r=0;const s=[0,0],i=[4294967295&n,n/ct&2097151];for(e=6;e>=0;e--)t=i[e>>2]>>>8*e&255,t===0&&r===0||(s[r+1>>2]|=t<<8*(r+1),r+=1);return r=r!==0?r:1,s[0]|=r,{value:r+1>4?s:[s[0]],binLen:8+8*r}}function gn(n){return qt(sr(n.binLen),n)}function ir(n,e){let t,r=sr(e);r=qt(r,n);const s=e>>>2,i=(s-r.value.length%s)%s;for(t=0;t<i;t++)r.value.push(0);return r.value}let Qs=class extends Ht{constructor(n,e,t){let r=6,s=0;super(n,e,t);const i=t||{};if(this.numRounds!==1){if(i.kmacKey||i.hmacKey)throw new Error(jn);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=Xe(this.t,this.i,this.T),this.v=Bt,this.L=js,this.B=mn,this.U=mn(),this.K=!1,n){case"SHA3-224":this.m=s=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=s=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=s=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=s=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":r=31,this.m=s=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":r=31,this.m=s=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":r=4,this.m=s=1344,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":r=4,this.m=s=1088,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=s=1344,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=s=1088,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(ht)}this.F=function(o,a,c,l,u){return function(d,h,m,y,g,w,v){let A,S,p=0;const k=[],b=g>>>5,I=h>>>5;for(A=0;A<I&&h>=g;A+=b)y=Bt(d.slice(A,A+b),y),h-=g;for(d=d.slice(A),h%=g;d.length<b;)d.push(0);for(A=h>>>3,d[A>>2]^=w<<A%4*8,d[b-1]^=2147483648,y=Bt(d,y);32*k.length<v&&(S=y[p%5][p/5|0],k.push(S.I),!(32*k.length>=v));)k.push(S.N),p+=1,64*p%g==0&&(Bt(null,y),p=0);return k}(o,a,0,l,s,r,u)},i.hmacKey&&this.k(Ue("hmacKey",i.hmacKey,this.T))}O(n,e){const t=function(s){const i=s||{};return{funcName:Ue("funcName",i.funcName,1,{value:[],binLen:0}),customization:Ue("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=qt(gn(t.funcName),gn(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const s=ir(r,this.m>>>3);for(let i=0;i<s.length;i+=this.m>>>5)this.U=this.v(s.slice(i,i+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(n){const e=function(r){const s=r||{};return{kmacKey:Ue("kmacKey",s.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Ue("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=ir(gn(e.kmacKey),this.m>>>3);for(let r=0;r<t.length;r+=this.m>>>5)this.U=this.v(t.slice(r,r+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(n){const e=qt({value:this.h.slice(),binLen:this.u},function(t){let r,s,i=0;const o=[0,0],a=[4294967295&t,t/ct&2097151];for(r=6;r>=0;r--)s=a[r>>2]>>>8*r&255,s===0&&i===0||(o[i>>2]|=s<<8*i,i+=1);return i=i!==0?i:1,o[i>>2]|=i<<8*i,{value:i+1>4?o:[o[0]],binLen:8+8*i}}(n.outputLen));return this.F(e.value,e.binLen,this.A,this.L(this.U),n.outputLen)}};class he{constructor(e,t,r){if(e=="SHA-1")this.P=new Os(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Ns(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Fs(e,t,r);else{if(e!="SHA3-224"&&e!="SHA3-256"&&e!="SHA3-384"&&e!="SHA3-512"&&e!="SHAKE128"&&e!="SHAKE256"&&e!="CSHAKE128"&&e!="CSHAKE256"&&e!="KMAC128"&&e!="KMAC256")throw new Error(ht);this.P=new Qs(e,t,r)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,r){this.P.setHMACKey(e,t,r)}getHMAC(e,t){return this.P.getHMAC(e,t)}}typeof self>"u"&&(global.self=global);class or{static toHex(e,t){const r=(c,l)=>{const u=l?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u[Math.floor(c/16)]+u[c%16]},s=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let i="",o=0,a=0;for(let c=0;c<e.length&&(i+=r(e[c],s.uppercase),c!==e.length-1);++c)s.grouping>0&&++o===s.grouping&&(o=0,s.rowlength>0&&++a===s.rowlength?(a=0,i+=`
|
|
2
|
-
`):i+=" ");return i}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const r=new Uint8Array(Math.floor(t.length/2));let s=-1;for(let i=0;i<t.length;++i){const o=t[i],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(a===-1)throw Error("unexpected character");s===-1?s=16*a:(r[Math.floor(i/2)]=s+a,s=-1)}return r}}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.toCamelCase||(String.prototype.toCamelCase=function(){return this.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)});function
|
|
1
|
+
var KnishIO=function(P){"use strict";var Ya=Object.defineProperty;var Za=(P,ve,Le)=>ve in P?Ya(P,ve,{enumerable:!0,configurable:!0,writable:!0,value:Le}):P[ve]=Le;var ct=(P,ve,Le)=>Za(P,typeof ve!="symbol"?ve+"":ve,Le);const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Le="ARRAYBUFFER not supported by this environment",Fn="UINT8ARRAY not supported by this environment";function Wn(n,e,t,r){let s,i,o;const a=e||[0],c=(t=t||0)>>>3,l=r===-1?3:0;for(s=0;s<n.length;s+=1)o=s+c,i=o>>>2,a.length<=i&&a.push(0),a[i]|=n[s]<<8*(l+r*(o%4));return{value:a,binLen:8*n.length+t}}function Ye(n,e,t){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(n){case"HEX":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;if(o.length%2!=0)throw new Error("String of HEX type must be in byte increments");const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(u=0;u<o.length;u+=2){if(d=parseInt(o.substr(u,2),16),isNaN(d))throw new Error("String of HEX type contains invalid characters");for(m=(u>>>1)+g,h=m>>>2;y.length<=h;)y.push(0);y[h]|=d<<8*(w+l*(m%4))}return{value:y,binLen:4*o.length+c}}(r,s,i,t)};case"TEXT":return function(r,s,i){return function(o,a,c,l,u){let d,h,m,y,g,w,v,A,S=0;const p=c||[0],k=(l=l||0)>>>3;if(a==="UTF8")for(v=u===-1?3:0,m=0;m<o.length;m+=1)for(d=o.charCodeAt(m),h=[],128>d?h.push(d):2048>d?(h.push(192|d>>>6),h.push(128|63&d)):55296>d||57344<=d?h.push(224|d>>>12,128|d>>>6&63,128|63&d):(m+=1,d=65536+((1023&d)<<10|1023&o.charCodeAt(m)),h.push(240|d>>>18,128|d>>>12&63,128|d>>>6&63,128|63&d)),y=0;y<h.length;y+=1){for(w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=h[y]<<8*(v+u*(w%4)),S+=1}else for(v=u===-1?2:0,A=a==="UTF16LE"&&u!==1||a!=="UTF16LE"&&u===1,m=0;m<o.length;m+=1){for(d=o.charCodeAt(m),A===!0&&(y=255&d,d=y<<8|d>>>8),w=S+k,g=w>>>2;p.length<=g;)p.push(0);p[g]|=d<<8*(v+u*(w%4)),S+=2}return{value:p,binLen:8*S+l}}(r,e,s,i,t)};case"B64":return function(r,s,i){return function(o,a,c,l){let u,d,h,m,y,g,w,v=0;const A=a||[0],S=(c=c||0)>>>3,p=l===-1?3:0,k=o.indexOf("=");if(o.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(o=o.replace(/=/g,""),k!==-1&&k<o.length)throw new Error("Invalid '=' found in base-64 string");for(d=0;d<o.length;d+=4){for(y=o.substr(d,4),m=0,h=0;h<y.length;h+=1)u=ve.indexOf(y.charAt(h)),m|=u<<18-6*h;for(h=0;h<y.length-1;h+=1){for(w=v+S,g=w>>>2;A.length<=g;)A.push(0);A[g]|=(m>>>16-8*h&255)<<8*(p+l*(w%4)),v+=1}}return{value:A,binLen:8*v+c}}(r,s,i,t)};case"BYTES":return function(r,s,i){return function(o,a,c,l){let u,d,h,m;const y=a||[0],g=(c=c||0)>>>3,w=l===-1?3:0;for(d=0;d<o.length;d+=1)u=o.charCodeAt(d),m=d+g,h=m>>>2,y.length<=h&&y.push(0),y[h]|=u<<8*(w+l*(m%4));return{value:y,binLen:8*o.length+c}}(r,s,i,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(r,s,i){return function(o,a,c,l){return Wn(new Uint8Array(o),a,c,l)}(r,s,i,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(r,s,i){return Wn(r,s,i,t)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Dn(n,e,t,r){switch(n){case"HEX":return function(s){return function(i,o,a,c){const l="0123456789abcdef";let u,d,h="";const m=o/8,y=a===-1?3:0;for(u=0;u<m;u+=1)d=i[u>>>2]>>>8*(y+a*(u%4)),h+=l.charAt(d>>>4&15)+l.charAt(15&d);return c.outputUpper?h.toUpperCase():h}(s,e,t,r)};case"B64":return function(s){return function(i,o,a,c){let l,u,d,h,m,y="";const g=o/8,w=a===-1?3:0;for(l=0;l<g;l+=3)for(h=l+1<g?i[l+1>>>2]:0,m=l+2<g?i[l+2>>>2]:0,d=(i[l>>>2]>>>8*(w+a*(l%4))&255)<<16|(h>>>8*(w+a*((l+1)%4))&255)<<8|m>>>8*(w+a*((l+2)%4))&255,u=0;u<4;u+=1)y+=8*l+6*u<=o?ve.charAt(d>>>6*(3-u)&63):c.b64Pad;return y}(s,e,t,r)};case"BYTES":return function(s){return function(i,o,a){let c,l,u="";const d=o/8,h=a===-1?3:0;for(c=0;c<d;c+=1)l=i[c>>>2]>>>8*(h+a*(c%4))&255,u+=String.fromCharCode(l);return u}(s,e,t)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch{throw new Error(Le)}return function(s){return function(i,o,a){let c;const l=o/8,u=new ArrayBuffer(l),d=new Uint8Array(u),h=a===-1?3:0;for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(h+a*(c%4))&255;return u}(s,e,t)};case"UINT8ARRAY":try{new Uint8Array(0)}catch{throw new Error(Fn)}return function(s){return function(i,o,a){let c;const l=o/8,u=a===-1?3:0,d=new Uint8Array(l);for(c=0;c<l;c+=1)d[c]=i[c>>>2]>>>8*(u+a*(c%4))&255;return d}(s,e,t)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const ht=4294967296,x=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Te=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],dt="Chosen SHA variant is not supported",jn="Cannot set numRounds with MAC";function qt(n,e){let t,r;const s=n.binLen>>>3,i=e.binLen>>>3,o=s<<3,a=4-s<<3;if(s%4!=0){for(t=0;t<i;t+=4)r=s+t>>>2,n.value[r]|=e.value[t>>>2]<<o,n.value.push(0),n.value[r+1]|=e.value[t>>>2]>>>a;return(n.value.length<<2)-4>=i+s&&n.value.pop(),{value:n.value,binLen:n.binLen+e.binLen}}return{value:n.value.concat(e.value),binLen:n.binLen+e.binLen}}function Qn(n){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},t=n||{},r="Output length must be a multiple of 8";if(e.outputUpper=t.outputUpper||!1,t.b64Pad&&(e.b64Pad=t.b64Pad),t.outputLen){if(t.outputLen%8!=0)throw new Error(r);e.outputLen=t.outputLen}else if(t.shakeLen){if(t.shakeLen%8!=0)throw new Error(r);e.outputLen=t.shakeLen}if(typeof e.outputUpper!="boolean")throw new Error("Invalid outputUpper formatting option");if(typeof e.b64Pad!="string")throw new Error("Invalid b64Pad formatting option");return e}function Ue(n,e,t,r){const s=n+" must include a value and format";if(!e){if(!r)throw new Error(s);return r}if(e.value===void 0||!e.format)throw new Error(s);return Ye(e.format,e.encoding||"UTF8",t)(e.value)}let Ht=class{constructor(e,t,r){const s=r||{};if(this.t=t,this.i=s.encoding||"UTF8",this.numRounds=s.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.H=!1,this.S=[],this.p=[]}update(e){let t,r=0;const s=this.m>>>5,i=this.C(e,this.h,this.u),o=i.binLen,a=i.value,c=o>>>5;for(t=0;t<c;t+=s)r+this.m<=o&&(this.U=this.v(a.slice(t,t+s),this.U),r+=this.m);return this.A+=r,this.h=a.slice(r>>>5),this.u=o%this.m,this.l=!0,this}getHash(e,t){let r,s,i=this.R;const o=Qn(t);if(this.K){if(o.outputLen===-1)throw new Error("Output length must be specified in options");i=o.outputLen}const a=Dn(e,i,this.T,o);if(this.H&&this.g)return a(this.g(o));for(s=this.F(this.h.slice(),this.u,this.A,this.L(this.U),i),r=1;r<this.numRounds;r+=1)this.K&&i%32!=0&&(s[s.length-1]&=16777215>>>24-i%32),s=this.F(s,i,0,this.B(this.o),i);return a(s)}setHMACKey(e,t,r){if(!this.M)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const s=Ye(t,(r||{}).encoding||"UTF8",this.T);this.k(s(e))}k(e){const t=this.m>>>3,r=t/4-1;let s;if(this.numRounds!==1)throw new Error(jn);if(this.H)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.F(e.value,e.binLen,0,this.B(this.o),this.R));e.value.length<=r;)e.value.push(0);for(s=0;s<=r;s+=1)this.S[s]=909522486^e.value[s],this.p[s]=1549556828^e.value[s];this.U=this.v(this.S,this.U),this.A=this.m,this.H=!0}getHMAC(e,t){const r=Qn(t);return Dn(e,this.R,this.T,r)(this.Y())}Y(){let e;if(!this.H)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.F(this.h.slice(),this.u,this.A,this.L(this.U),this.R);return e=this.v(this.p,this.B(this.o)),e=this.F(t,this.R,this.m,e,this.R),e}};function Ze(n,e){return n<<e|n>>>32-e}function ke(n,e){return n>>>e|n<<32-e}function Vn(n,e){return n>>>e}function zn(n,e,t){return n^e^t}function Jn(n,e,t){return n&e^~n&t}function Gn(n,e,t){return n&e^n&t^e&t}function $s(n){return ke(n,2)^ke(n,13)^ke(n,22)}function X(n,e){const t=(65535&n)+(65535&e);return(65535&(n>>>16)+(e>>>16)+(t>>>16))<<16|65535&t}function Is(n,e,t,r){const s=(65535&n)+(65535&e)+(65535&t)+(65535&r);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16))<<16|65535&s}function ft(n,e,t,r,s){const i=(65535&n)+(65535&e)+(65535&t)+(65535&r)+(65535&s);return(65535&(n>>>16)+(e>>>16)+(t>>>16)+(r>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function Ts(n){return ke(n,7)^ke(n,18)^Vn(n,3)}function Es(n){return ke(n,6)^ke(n,11)^ke(n,25)}function Cs(n){return[1732584193,4023233417,2562383102,271733878,3285377520]}function Xn(n,e){let t,r,s,i,o,a,c;const l=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=0;c<80;c+=1)l[c]=c<16?n[c]:Ze(l[c-3]^l[c-8]^l[c-14]^l[c-16],1),a=c<20?ft(Ze(t,5),Jn(r,s,i),o,1518500249,l[c]):c<40?ft(Ze(t,5),zn(r,s,i),o,1859775393,l[c]):c<60?ft(Ze(t,5),Gn(r,s,i),o,2400959708,l[c]):ft(Ze(t,5),zn(r,s,i),o,3395469782,l[c]),o=i,i=s,s=Ze(r,30),r=t,t=a;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e}function Ms(n,e,t,r){let s;const i=15+(e+65>>>9<<4),o=e+t;for(;n.length<=i;)n.push(0);for(n[e>>>5]|=128<<24-e%32,n[i]=4294967295&o,n[i-1]=o/ht|0,s=0;s<n.length;s+=16)r=Xn(n.slice(s,s+16),r);return r}let Os=class extends Ht{constructor(e,t,r){if(e!=="SHA-1")throw new Error(dt);super(e,t,r);const s=r||{};this.M=!0,this.g=this.Y,this.T=-1,this.C=Ye(this.t,this.i,this.T),this.v=Xn,this.L=function(i){return i.slice()},this.B=Cs,this.F=Ms,this.U=[1732584193,4023233417,2562383102,271733878,3285377520],this.m=512,this.R=160,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};function Yn(n){let e;return e=n=="SHA-224"?Te.slice():Ee.slice(),e}function Zn(n,e){let t,r,s,i,o,a,c,l,u,d,h;const m=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<64;h+=1)m[h]=h<16?n[h]:Is(ke(y=m[h-2],17)^ke(y,19)^Vn(y,10),m[h-7],Ts(m[h-15]),m[h-16]),u=ft(l,Es(o),Jn(o,a,c),x[h],m[h]),d=X($s(t),Gn(t,r,s)),l=c,c=a,a=o,o=X(i,u),i=s,s=r,r=t,t=X(u,d);var y;return e[0]=X(t,e[0]),e[1]=X(r,e[1]),e[2]=X(s,e[2]),e[3]=X(i,e[3]),e[4]=X(o,e[4]),e[5]=X(a,e[5]),e[6]=X(c,e[6]),e[7]=X(l,e[7]),e}let Ns=class extends Ht{constructor(e,t,r){if(e!=="SHA-224"&&e!=="SHA-256")throw new Error(dt);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Ye(this.t,this.i,this.T),this.v=Zn,this.L=function(i){return i.slice()},this.B=Yn,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=15+(u+65>>>9<<4),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ht|0,y=0;y<l.length;y+=16)h=Zn(l.slice(y,y+16),h);return g=m==="SHA-224"?[h[0],h[1],h[2],h[3],h[4],h[5],h[6]]:h,g}(i,o,a,c,e)},this.U=Yn(e),this.m=512,this.R=e==="SHA-224"?224:256,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};class f{constructor(e,t){this.N=e,this.I=t}}function er(n,e){let t;return e>32?(t=64-e,new f(n.I<<e|n.N>>>t,n.N<<e|n.I>>>t)):e!==0?(t=32-e,new f(n.N<<e|n.I>>>t,n.I<<e|n.N>>>t)):n}function Se(n,e){let t;return e<32?(t=32-e,new f(n.N>>>e|n.I<<t,n.I>>>e|n.N<<t)):(t=64-e,new f(n.I>>>e|n.N<<t,n.N>>>e|n.I<<t))}function tr(n,e){return new f(n.N>>>e,n.I>>>e|n.N<<32-e)}function Rs(n,e,t){return new f(n.N&e.N^n.N&t.N^e.N&t.N,n.I&e.I^n.I&t.I^e.I&t.I)}function Us(n){const e=Se(n,28),t=Se(n,34),r=Se(n,39);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function ge(n,e){let t,r;t=(65535&n.I)+(65535&e.I),r=(n.I>>>16)+(e.I>>>16)+(t>>>16);const s=(65535&r)<<16|65535&t;return t=(65535&n.N)+(65535&e.N)+(r>>>16),r=(n.N>>>16)+(e.N>>>16)+(t>>>16),new f((65535&r)<<16|65535&t,s)}function qs(n,e,t,r){let s,i;s=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I),i=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s>>>16);const o=(65535&i)<<16|65535&s;return s=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(i>>>16),i=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s>>>16),new f((65535&i)<<16|65535&s,o)}function Hs(n,e,t,r,s){let i,o;i=(65535&n.I)+(65535&e.I)+(65535&t.I)+(65535&r.I)+(65535&s.I),o=(n.I>>>16)+(e.I>>>16)+(t.I>>>16)+(r.I>>>16)+(s.I>>>16)+(i>>>16);const a=(65535&o)<<16|65535&i;return i=(65535&n.N)+(65535&e.N)+(65535&t.N)+(65535&r.N)+(65535&s.N)+(o>>>16),o=(n.N>>>16)+(e.N>>>16)+(t.N>>>16)+(r.N>>>16)+(s.N>>>16)+(i>>>16),new f((65535&o)<<16|65535&i,a)}function pt(n,e){return new f(n.N^e.N,n.I^e.I)}function Bs(n){const e=Se(n,19),t=Se(n,61),r=tr(n,6);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ps(n){const e=Se(n,1),t=Se(n,8),r=tr(n,7);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}function Ls(n){const e=Se(n,14),t=Se(n,18),r=Se(n,41);return new f(e.N^t.N^r.N,e.I^t.I^r.I)}const Ks=[new f(x[0],3609767458),new f(x[1],602891725),new f(x[2],3964484399),new f(x[3],2173295548),new f(x[4],4081628472),new f(x[5],3053834265),new f(x[6],2937671579),new f(x[7],3664609560),new f(x[8],2734883394),new f(x[9],1164996542),new f(x[10],1323610764),new f(x[11],3590304994),new f(x[12],4068182383),new f(x[13],991336113),new f(x[14],633803317),new f(x[15],3479774868),new f(x[16],2666613458),new f(x[17],944711139),new f(x[18],2341262773),new f(x[19],2007800933),new f(x[20],1495990901),new f(x[21],1856431235),new f(x[22],3175218132),new f(x[23],2198950837),new f(x[24],3999719339),new f(x[25],766784016),new f(x[26],2566594879),new f(x[27],3203337956),new f(x[28],1034457026),new f(x[29],2466948901),new f(x[30],3758326383),new f(x[31],168717936),new f(x[32],1188179964),new f(x[33],1546045734),new f(x[34],1522805485),new f(x[35],2643833823),new f(x[36],2343527390),new f(x[37],1014477480),new f(x[38],1206759142),new f(x[39],344077627),new f(x[40],1290863460),new f(x[41],3158454273),new f(x[42],3505952657),new f(x[43],106217008),new f(x[44],3606008344),new f(x[45],1432725776),new f(x[46],1467031594),new f(x[47],851169720),new f(x[48],3100823752),new f(x[49],1363258195),new f(x[50],3750685593),new f(x[51],3785050280),new f(x[52],3318307427),new f(x[53],3812723403),new f(x[54],2003034995),new f(x[55],3602036899),new f(x[56],1575990012),new f(x[57],1125592928),new f(x[58],2716904306),new f(x[59],442776044),new f(x[60],593698344),new f(x[61],3733110249),new f(x[62],2999351573),new f(x[63],3815920427),new f(3391569614,3928383900),new f(3515267271,566280711),new f(3940187606,3454069534),new f(4118630271,4000239992),new f(116418474,1914138554),new f(174292421,2731055270),new f(289380356,3203993006),new f(460393269,320620315),new f(685471733,587496836),new f(852142971,1086792851),new f(1017036298,365543100),new f(1126000580,2618297676),new f(1288033470,3409855158),new f(1501505948,4234509866),new f(1607167915,987167468),new f(1816402316,1246189591)];function nr(n){return n==="SHA-384"?[new f(3418070365,Te[0]),new f(1654270250,Te[1]),new f(2438529370,Te[2]),new f(355462360,Te[3]),new f(1731405415,Te[4]),new f(41048885895,Te[5]),new f(3675008525,Te[6]),new f(1203062813,Te[7])]:[new f(Ee[0],4089235720),new f(Ee[1],2227873595),new f(Ee[2],4271175723),new f(Ee[3],1595750129),new f(Ee[4],2917565137),new f(Ee[5],725511199),new f(Ee[6],4215389547),new f(Ee[7],327033209)]}function rr(n,e){let t,r,s,i,o,a,c,l,u,d,h,m;const y=[];for(t=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=0;h<80;h+=1)h<16?(m=2*h,y[h]=new f(n[m],n[m+1])):y[h]=qs(Bs(y[h-2]),y[h-7],Ps(y[h-15]),y[h-16]),u=Hs(l,Ls(o),(w=a,v=c,new f((g=o).N&w.N^~g.N&v.N,g.I&w.I^~g.I&v.I)),Ks[h],y[h]),d=ge(Us(t),Rs(t,r,s)),l=c,c=a,a=o,o=ge(i,u),i=s,s=r,r=t,t=ge(u,d);var g,w,v;return e[0]=ge(t,e[0]),e[1]=ge(r,e[1]),e[2]=ge(s,e[2]),e[3]=ge(i,e[3]),e[4]=ge(o,e[4]),e[5]=ge(a,e[5]),e[6]=ge(c,e[6]),e[7]=ge(l,e[7]),e}let Fs=class extends Ht{constructor(e,t,r){if(e!=="SHA-384"&&e!=="SHA-512")throw new Error(dt);super(e,t,r);const s=r||{};this.g=this.Y,this.M=!0,this.T=-1,this.C=Ye(this.t,this.i,this.T),this.v=rr,this.L=function(i){return i.slice()},this.B=nr,this.F=function(i,o,a,c){return function(l,u,d,h,m){let y,g;const w=31+(u+129>>>10<<5),v=u+d;for(;l.length<=w;)l.push(0);for(l[u>>>5]|=128<<24-u%32,l[w]=4294967295&v,l[w-1]=v/ht|0,y=0;y<l.length;y+=32)h=rr(l.slice(y,y+32),h);return g=m==="SHA-384"?[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I]:[h[0].N,h[0].I,h[1].N,h[1].I,h[2].N,h[2].I,h[3].N,h[3].I,h[4].N,h[4].I,h[5].N,h[5].I,h[6].N,h[6].I,h[7].N,h[7].I],g}(i,o,a,c,e)},this.U=nr(e),this.m=1024,this.R=e==="SHA-384"?384:512,this.K=!1,s.hmacKey&&this.k(Ue("hmacKey",s.hmacKey,this.T))}};const Ws=[new f(0,1),new f(0,32898),new f(2147483648,32906),new f(2147483648,2147516416),new f(0,32907),new f(0,2147483649),new f(2147483648,2147516545),new f(2147483648,32777),new f(0,138),new f(0,136),new f(0,2147516425),new f(0,2147483658),new f(0,2147516555),new f(2147483648,139),new f(2147483648,32905),new f(2147483648,32771),new f(2147483648,32770),new f(2147483648,128),new f(0,32778),new f(2147483648,2147483658),new f(2147483648,2147516545),new f(2147483648,32896),new f(0,2147483649),new f(2147483648,2147516424)],Ds=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function mn(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=[new f(0,0),new f(0,0),new f(0,0),new f(0,0),new f(0,0)];return t}function js(n){let e;const t=[];for(e=0;e<5;e+=1)t[e]=n[e].slice();return t}function Bt(n,e){let t,r,s,i;const o=[],a=[];if(n!==null)for(r=0;r<n.length;r+=2)e[(r>>>1)%5][(r>>>1)/5|0]=pt(e[(r>>>1)%5][(r>>>1)/5|0],new f(n[r+1],n[r]));for(t=0;t<24;t+=1){for(i=mn(),r=0;r<5;r+=1)o[r]=(c=e[r][0],l=e[r][1],u=e[r][2],d=e[r][3],h=e[r][4],new f(c.N^l.N^u.N^d.N^h.N,c.I^l.I^u.I^d.I^h.I));for(r=0;r<5;r+=1)a[r]=pt(o[(r+4)%5],er(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=pt(e[r][s],a[r]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)i[s][(2*r+3*s)%5]=er(e[r][s],Ds[r][s]);for(r=0;r<5;r+=1)for(s=0;s<5;s+=1)e[r][s]=pt(i[r][s],new f(~i[(r+1)%5][s].N&i[(r+2)%5][s].N,~i[(r+1)%5][s].I&i[(r+2)%5][s].I));e[0][0]=pt(e[0][0],Ws[t])}var c,l,u,d,h;return e}function sr(n){let e,t,r=0;const s=[0,0],i=[4294967295&n,n/ht&2097151];for(e=6;e>=0;e--)t=i[e>>2]>>>8*e&255,t===0&&r===0||(s[r+1>>2]|=t<<8*(r+1),r+=1);return r=r!==0?r:1,s[0]|=r,{value:r+1>4?s:[s[0]],binLen:8+8*r}}function gn(n){return qt(sr(n.binLen),n)}function ir(n,e){let t,r=sr(e);r=qt(r,n);const s=e>>>2,i=(s-r.value.length%s)%s;for(t=0;t<i;t++)r.value.push(0);return r.value}let Qs=class extends Ht{constructor(n,e,t){let r=6,s=0;super(n,e,t);const i=t||{};if(this.numRounds!==1){if(i.kmacKey||i.hmacKey)throw new Error(jn);if(this.o==="CSHAKE128"||this.o==="CSHAKE256")throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.T=1,this.C=Ye(this.t,this.i,this.T),this.v=Bt,this.L=js,this.B=mn,this.U=mn(),this.K=!1,n){case"SHA3-224":this.m=s=1152,this.R=224,this.M=!0,this.g=this.Y;break;case"SHA3-256":this.m=s=1088,this.R=256,this.M=!0,this.g=this.Y;break;case"SHA3-384":this.m=s=832,this.R=384,this.M=!0,this.g=this.Y;break;case"SHA3-512":this.m=s=576,this.R=512,this.M=!0,this.g=this.Y;break;case"SHAKE128":r=31,this.m=s=1344,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"SHAKE256":r=31,this.m=s=1088,this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"KMAC128":r=4,this.m=s=1344,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"KMAC256":r=4,this.m=s=1088,this.X(t),this.R=-1,this.K=!0,this.M=!1,this.g=this._;break;case"CSHAKE128":this.m=s=1344,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;case"CSHAKE256":this.m=s=1088,r=this.O(t),this.R=-1,this.K=!0,this.M=!1,this.g=null;break;default:throw new Error(dt)}this.F=function(o,a,c,l,u){return function(d,h,m,y,g,w,v){let A,S,p=0;const k=[],b=g>>>5,I=h>>>5;for(A=0;A<I&&h>=g;A+=b)y=Bt(d.slice(A,A+b),y),h-=g;for(d=d.slice(A),h%=g;d.length<b;)d.push(0);for(A=h>>>3,d[A>>2]^=w<<A%4*8,d[b-1]^=2147483648,y=Bt(d,y);32*k.length<v&&(S=y[p%5][p/5|0],k.push(S.I),!(32*k.length>=v));)k.push(S.N),p+=1,64*p%g==0&&(Bt(null,y),p=0);return k}(o,a,0,l,s,r,u)},i.hmacKey&&this.k(Ue("hmacKey",i.hmacKey,this.T))}O(n,e){const t=function(s){const i=s||{};return{funcName:Ue("funcName",i.funcName,1,{value:[],binLen:0}),customization:Ue("Customization",i.customization,1,{value:[],binLen:0})}}(n||{});e&&(t.funcName=e);const r=qt(gn(t.funcName),gn(t.customization));if(t.customization.binLen!==0||t.funcName.binLen!==0){const s=ir(r,this.m>>>3);for(let i=0;i<s.length;i+=this.m>>>5)this.U=this.v(s.slice(i,i+(this.m>>>5)),this.U),this.A+=this.m;return 4}return 31}X(n){const e=function(r){const s=r||{};return{kmacKey:Ue("kmacKey",s.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Ue("Customization",s.customization,1,{value:[],binLen:0})}}(n||{});this.O(n,e.funcName);const t=ir(gn(e.kmacKey),this.m>>>3);for(let r=0;r<t.length;r+=this.m>>>5)this.U=this.v(t.slice(r,r+(this.m>>>5)),this.U),this.A+=this.m;this.H=!0}_(n){const e=qt({value:this.h.slice(),binLen:this.u},function(t){let r,s,i=0;const o=[0,0],a=[4294967295&t,t/ht&2097151];for(r=6;r>=0;r--)s=a[r>>2]>>>8*r&255,s===0&&i===0||(o[i>>2]|=s<<8*i,i+=1);return i=i!==0?i:1,o[i>>2]|=i<<8*i,{value:i+1>4?o:[o[0]],binLen:8+8*i}}(n.outputLen));return this.F(e.value,e.binLen,this.A,this.L(this.U),n.outputLen)}};class he{constructor(e,t,r){if(e=="SHA-1")this.P=new Os(e,t,r);else if(e=="SHA-224"||e=="SHA-256")this.P=new Ns(e,t,r);else if(e=="SHA-384"||e=="SHA-512")this.P=new Fs(e,t,r);else{if(e!="SHA3-224"&&e!="SHA3-256"&&e!="SHA3-384"&&e!="SHA3-512"&&e!="SHAKE128"&&e!="SHAKE256"&&e!="CSHAKE128"&&e!="CSHAKE256"&&e!="KMAC128"&&e!="KMAC256")throw new Error(dt);this.P=new Qs(e,t,r)}}update(e){return this.P.update(e),this}getHash(e,t){return this.P.getHash(e,t)}setHMACKey(e,t,r){this.P.setHMACKey(e,t,r)}getHMAC(e,t){return this.P.getHMAC(e,t)}}typeof self>"u"&&(global.self=global);class or{static toHex(e,t){const r=(c,l)=>{const u=l?["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]:["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u[Math.floor(c/16)]+u[c%16]},s=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let i="",o=0,a=0;for(let c=0;c<e.length&&(i+=r(e[c],s.uppercase),c!==e.length-1);++c)s.grouping>0&&++o===s.grouping&&(o=0,s.rowlength>0&&++a===s.rowlength?(a=0,i+=`
|
|
2
|
+
`):i+=" ");return i}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const r=new Uint8Array(Math.floor(t.length/2));let s=-1;for(let i=0;i<t.length;++i){const o=t[i],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(o);if(a===-1)throw Error("unexpected character");s===-1?s=16*a:(r[Math.floor(i/2)]=s+a,s=-1)}return r}}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.toCamelCase||(String.prototype.toCamelCase=function(){return this.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`)});function yt(n,e){const t=Math.ceil(n.length/e),r=[];for(let s=0,i=0;s<t;++s,i+=e)r[s]=n.substr(i,e);return r}function Pt(n=256,e="abcdef0123456789"){let t=new Uint8Array(n);return t=crypto.getRandomValues(t),t=t.map(r=>e.charCodeAt(r%e.length)),String.fromCharCode.apply(null,t)}function ar(n,e,t,r,s){if(r=r||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?¿¡",s=s||r,e>r.length||t>s.length)return console.warn("Strings::charsetBaseConvert() - Can't convert",n,"to base",t,"greater than symbol table length. src-table:",r.length,"dest-table:",s.length),!1;let o=BigInt(0);for(let c=0;c<n.length;c++)o=o*BigInt(e)+BigInt(r.indexOf(n.charAt(c)));let a="";for(;o>0;){const c=o%BigInt(t);a=s.charAt(Number(c))+a,o/=BigInt(t)}return a||"0"}function lr(n){return or.toHex(n,{})}function ur(n){return or.toUint8Array(n)}function cr(n){const e=ur(n);return btoa(String.fromCharCode.apply(null,e))}function hr(n){const e=new Uint8Array(atob(n).split("").map(t=>t.charCodeAt(0)));return lr(e)}function dr(n){return/^[A-F0-9]+$/i.test(n)}function Vs(n){return(typeof n=="number"||typeof n=="string"&&n.trim()!=="")&&!isNaN(n)}let Ke=class{static normalizeMeta(e){if(Array.isArray(e))return e;const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push({key:r,value:e[r]});return t}static aggregateMeta(e){let t={};if(Array.isArray(e))for(const r of e)t[r.key]=r.value;else t=e;return t}};function fr(n,e){let t,r,s;const i=[Array,Date,Number,String,Boolean],o=Object.prototype.toString;for(e=e||[],t=0;t<e.length;t+=2)n===e[t]&&(r=e[t+1]);if(!r&&n&&typeof n=="object"){for(r={},t=0;t<i.length;t++)o.call(n)===o.call(s=new i[t](n))&&(r=t?s:[]);e.push(n,r);for(t in n)e.hasOwnProperty.call(n,t)&&(r[t]=fr(n[t],e))}return r||n}function zs(...n){return[].concat(...n.map((e,t)=>{const r=n.slice(0);r.splice(t,1);const s=[...new Set([].concat(...r))];return e.filter(i=>!s.includes(i))}))}function mt(...n){return n.reduce((e,t)=>e.filter(r=>t.includes(r)))}class wn{constructor(e={},t={}){this.policy=wn.normalizePolicy(e),this.fillDefault(t)}static normalizePolicy(e={}){const t={};for(const[r,s]of Object.entries(e))if(s!==null&&["read","write"].includes(r)){t[r]={};for(const[i,o]of Object.entries(s))t[r][i]=o}return t}fillDefault(e={}){const t=Array.from(this.policy).filter(s=>s.action==="read"),r=Array.from(this.policy).filter(s=>s.action==="write");for(const[s,i]of Object.entries({read:t,write:r})){const o=i.map(a=>a.key);this.policy[s]||(this.policy[s]={});for(const a of zs(e,o))this.policy[s][a]||(this.policy[s][a]=s==="write"&&!["characters","pubkey"].includes(a)?["self"]:["all"])}}get(){return this.policy}toJson(){return JSON.stringify(this.get())}}class le{constructor(e=[]){this.meta=Ke.normalizeMeta(e)}merge(e){return this.meta=Array.from(new Set([...this.meta,...Ke.normalizeMeta(e)])),this}addContext(e=null){return this}setAtomWallet(e){const t={pubkey:e.pubkey,characters:e.characters};return e.tokenUnits&&e.tokenUnits.length&&(t.tokenUnits=JSON.stringify(e.getTokenUnitsData())),e.tradeRates&&e.tradeRates.length&&(t.tradeRates=JSON.stringify(e.tradeRates)),this.merge(t),this}setMetaWallet(e){return this.merge({walletTokenSlug:e.token,walletBundleHash:e.bundle,walletAddress:e.address,walletPosition:e.position,walletBatchId:e.batchId,walletPubkey:e.pubkey,walletCharacters:e.characters}),this}setShadowWalletClaim(e){return this.merge({shadowWalletClaim:e*1}),this}setSigningWallet(e){return this.merge({signingWallet:JSON.stringify({tokenSlug:e.token,bundleHash:e.bundle,address:e.address,position:e.position,pubkey:e.pubkey,characters:e.characters})}),this}addPolicy(e){const t=new wn(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class q extends TypeError{constructor(e=null,t=null,r=null){if(super(e,t,r),e===null)throw new this(`Unknown ${this.constructor.name}`);this.name="BaseException"}toString(){return`${this.name}: ${this.message}.
|
|
3
3
|
Stack:
|
|
4
|
-
${this.stack}`}}class Ke extends q{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class Fe{static create(e){const t={};for(const r of Object.keys(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const r in e)t.push(Fe.isStructure(e[r])?Fe.structure(e[r]):e[r]);return t}case"[object Object]":{const t=[],r=Object.keys(e).sort((s,i)=>s===i?0:s<i?-1:1);for(const s of r)if(Object.prototype.hasOwnProperty.call(e,s)){const i={};i[s]=Fe.isStructure(e[s])?Fe.structure(e[s]):e[s],t.push(i)}if(t.length>0)return t;break}}return e}static isStructure(e){return["[object Object]","[object Array]"].includes(Object.prototype.toString.call(e))}view(){return Fe.structure(this)}}class Js extends Fe{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,index:u=null,createdAt:d=null,version:h=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l,this.index=u,this.createdAt=d,this.version=h}}const Lt={4:Js};class E{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,otsFragment:u=null,index:d=null,version:h=null}){this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i!==null?String(i):null,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l?yt.normalizeMeta(l):[],this.index=d,this.otsFragment=u,this.createdAt=String(+new Date),h!==null&&Object.prototype.hasOwnProperty.call(Lt,h)&&(this.version=String(h))}static getHashableProps(){return["position","walletAddress","isotope","token","value","batchId","metaType","metaId","meta","createdAt"]}static getUnclaimedProps(){return["otsFragment"]}static create({isotope:e,wallet:t=null,value:r=null,metaType:s=null,metaId:i=null,meta:o=null,batchId:a=null}){return o||(o=new le),o instanceof le||(o=new le(o)),t&&(o.setAtomWallet(t),a||(a=t.batchId)),new E({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:a,metaType:s,metaId:i,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new E({}),JSON.parse(e)),r=Object.keys(new E({}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t}static hashAtoms({atoms:e,output:t="base17"}){const r=new he("SHAKE256","TEXT"),s=E.sortAtoms(e);if(s.length===0)throw new Ke;if(s.map(i=>{if(!(i instanceof E))throw new Ke;return i}),s.every(i=>i.version&&Object.prototype.hasOwnProperty.call(Lt,i.version)))r.update(JSON.stringify(s.map(i=>Lt[i.version].create(i).view())));else{const i=String(e.length);let o=[];for(const a of s)o.push(i),o=o.concat(a.getHashableValues());for(const a of o)r.update(a)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return ar(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!E.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((r,s)=>r.index<s.index?-1:1),t}aggregatedMeta(){return yt.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of E.getHashableProps()){const r=this[t];if(!(r===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const s of r)typeof s.value<"u"&&s.value!==null&&(e.push(String(s.key)),e.push(String(s.value)));else e.push(r===null?"":String(r))}return e}}function Kt(n=null,e=2048){if(n){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return Pt(e)}function We(n,e=null){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function Ft({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?We(String(n)+String(e),"generateBatchId"):Pt(64)}class gt{constructor(e,t,r){this.id=e,this.name=t,this.metas=r||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new gt(e.id,e.name,t)}static createFromDB(e){return new gt(e[0],e[1],e.length>2?e[2]:{})}getFragmentZone(){return this.metas.fragmentZone||null}getFusedTokenUnits(){return this.metas.fusedTokenUnits||null}toData(){return[this.id,this.name,this.metas]}toGraphQLResponse(){return{id:this.id,name:this.name,metas:JSON.stringify(this.metas)}}}class Gs extends q{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,r=null){super(e,t,r),this.name="WalletCredentialException"}}function pr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function Xs(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Wt(n,...e){if(!Xs(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error("Uint8Array expected of length "+e+", got length="+n.length)}function yr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Ys(n,e){Wt(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Dt=BigInt(2**32-1),mr=BigInt(32);function Zs(n,e=!1){return e?{h:Number(n&Dt),l:Number(n>>mr&Dt)}:{h:Number(n>>mr&Dt)|0,l:Number(n&Dt)|0}}function ei(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Zs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const ti=(n,e,t)=>n<<t|e>>>32-t,ni=(n,e,t)=>e<<t|n>>>32-t,ri=(n,e,t)=>e<<t-32|n>>>64-t,si=(n,e,t)=>n<<t-32|e>>>64-t,Ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}const wr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ii(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function br(n){for(let e=0;e<n.length;e++)n[e]=ii(n[e])}const Ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(n){if(n>=Ce._0&&n<=Ce._9)return n-Ce._0;if(n>=Ce.A&&n<=Ce.F)return n-(Ce.A-10);if(n>=Ce.a&&n<=Ce.f)return n-(Ce.a-10)}function de(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=vr(n.charCodeAt(i)),a=vr(n.charCodeAt(i+1));if(o===void 0||a===void 0){const c=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=o*16+a}return r}function oi(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function bn(n){return typeof n=="string"&&(n=oi(n)),Wt(n),n}class ai{clone(){return this._cloneInto()}}function li(n){const e=r=>n().update(bn(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ui(n){const e=(r,s)=>n(s).update(bn(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function ci(n=32){if(Ze&&typeof Ze.getRandomValues=="function")return Ze.getRandomValues(new Uint8Array(n));if(Ze&&typeof Ze.randomBytes=="function")return Ze.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const kr=[],Sr=[],Ar=[],hi=BigInt(0),wt=BigInt(1),di=BigInt(2),fi=BigInt(7),pi=BigInt(256),yi=BigInt(113);for(let n=0,e=wt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],kr.push(2*(5*r+t)),Sr.push((n+1)*(n+2)/2%64);let s=hi;for(let i=0;i<7;i++)e=(e<<wt^(e>>fi)*yi)%pi,e&di&&(s^=wt<<(wt<<BigInt(i))-wt);Ar.push(s)}const[mi,gi]=ei(Ar,!0),xr=(n,e,t)=>t>32?ri(n,e,t):ti(n,e,t),_r=(n,e,t)=>t>32?si(n,e,t):ni(n,e,t);function wi(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],d=xr(l,u,1)^t[a],h=_r(l,u,1)^t[a+1];for(let m=0;m<50;m+=10)n[o+m]^=d,n[o+m+1]^=h}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Sr[o],c=xr(s,i,a),l=_r(s,i,a),u=kr[o];s=n[u],i=n[u+1],n[u]=c,n[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=mi[r],n[1]^=gi[r]}t.fill(0)}class jt extends ai{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,pr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gr(this.state)}keccak(){wr||br(this.state32),wi(this.state32,this.rounds),wr||br(this.state32),this.posOut=0,this.pos=0}update(e){yr(this);const{blockLen:t,state:r}=this;e=bn(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){yr(this,!1),Wt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ys(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:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new jt(t,r,s,o,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=o,e.destroyed=this.destroyed,e}}const $r=(n,e,t)=>li(()=>new jt(e,n,t)),bi=$r(6,136,256/8),vi=$r(6,72,512/8),Ir=(n,e,t)=>ui((r={})=>new jt(e,n,r.dkLen===void 0?t:r.dkLen,!0)),ki=Ir(31,168,128/8),Tr=Ir(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const qe=Wt,Er=ci;function Cr(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Qt(...n){const e=r=>typeof r=="number"?r:r.bytesLen,t=n.reduce((r,s)=>r+e(s),0);return{bytesLen:t,encode:r=>{const s=new Uint8Array(t);for(let i=0,o=0;i<n.length;i++){const a=n[i],c=e(a),l=typeof a=="number"?r[i]:a.encode(r[i]);qe(l,c),s.set(l,o),typeof a!="number"&&l.fill(0),o+=c}return s},decode:r=>{qe(r,t);const s=[];for(const i of n){const o=e(i),a=r.subarray(0,o);s.push(typeof i=="number"?a:i.decode(a)),r=r.subarray(o)}return s}}}function vn(n,e){const t=e*n.bytesLen;return{bytesLen:t,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const a=n.encode(r[i]);s.set(a,o),a.fill(0),o+=a.length}return s},decode:r=>{qe(r,t);const s=[];for(let i=0;i<r.length;i+=n.bytesLen)s.push(n.decode(r.subarray(i,i+n.bytesLen)));return s}}}function De(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Mr(n){return(1<<n)-1}de("0609608648016503040201"),de("0609608648016503040202"),de("0609608648016503040203"),de("0609608648016503040204"),de("0609608648016503040205"),de("0609608648016503040206"),de("0609608648016503040207"),de("0609608648016503040208"),de("0609608648016503040209"),de("060960864801650304020A"),de("060960864801650304020B"),de("060960864801650304020C");/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Si(n,e=8){const s=n.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const Ai=n=>{const{newPoly:e,N:t,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:o}=n,a=(g,w=r)=>{const v=g%w|0;return(v>=0?v|0:w+v|0)|0},c=(g,w=r)=>{const v=a(g,w)|0;return(v>w>>1?v-w|0:v)|0};function l(){const g=e(t);for(let w=0;w<t;w++){const v=Si(w,o),A=BigInt(i)**BigInt(v)%BigInt(r);g[w]=Number(A)|0}return g}const u=l(),d=128,h=1;return{mod:a,smod:c,nttZetas:u,NTT:{encode:g=>{for(let w=1,v=128;v>h;v>>=1)for(let A=0;A<t;A+=2*v){const S=u[w++];for(let p=A;p<A+v;p++){const k=a(S*g[p+v]);g[p+v]=a(g[p]-k)|0,g[p]=a(g[p]+k)|0}}return g},decode:g=>{for(let w=d-1,v=1+h;v<d+h;v<<=1)for(let A=0;A<t;A+=2*v){const S=u[w--];for(let p=A;p<A+v;p++){const k=g[p];g[p]=a(k+g[p+v]),g[p+v]=a(S*(g[p+v]-k))}}for(let w=0;w<g.length;w++)g[w]=a(s*g[w]);return g}},bitsCoder:(g,w)=>{const v=Mr(g),A=g*(t/8);return{bytesLen:A,encode:S=>{const p=new Uint8Array(A);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=(w.encode(S[k])&v)<<I,I+=g;I>=8;I-=8,b>>=8)p[H++]=b&Mr(I);return p},decode:S=>{const p=e(t);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=S[k]<<I,I+=8;I>=g;I-=g,b>>=g)p[H++]=w.decode(b&v);return p}}}}},xi=(n=>(e,t)=>{t||(t=n.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(t);let o=n.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(r[s+0]=l,r[s+1]=u,o.destroy(),o=n.create({}).update(r),a++,()=>(c++,o.xofInto(i))),clean:()=>{o.destroy(),i.fill(0),r.fill(0)}}})(ki);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const re=256,je=3329,_i=3303,$i=17,{mod:bt,nttZetas:Ii,NTT:Qe,bitsCoder:Ti}=Ai({N:re,Q:je,F:_i,ROOT_OF_UNITY:$i,newPoly:n=>new Uint16Array(n),brvBits:7}),Ei={768:{N:re,Q:je,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},Ci=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+je/2)/je,decode:t=>t*je+e>>>n}},vt=n=>Ti(n,Ci(n));function Ve(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]+e[t])}function Mi(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]-e[t])}function Oi(n,e,t,r,s){const i=bt(e*r*s+n*t),o=bt(n*r+e*t);return{c0:i,c1:o}}function Vt(n,e){for(let t=0;t<re/2;t++){let r=Ii[64+(t>>1)];t&1&&(r=-r);const{c0:s,c1:i}=Oi(n[2*t+0],n[2*t+1],e[2*t+0],e[2*t+1],r);n[2*t+0]=s,n[2*t+1]=i}return n}function Or(n){const e=new Uint16Array(re);for(let t=0;t<re;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<re&&s+3<=r.length;s+=3){const i=(r[s+0]>>0|r[s+1]<<8)&4095,o=(r[s+1]>>4|r[s+2]<<4)&4095;i<je&&(e[t++]=i),t<re&&o<je&&(e[t++]=o)}}return e}function kt(n,e,t,r){const s=n(r*re/4,e,t),i=new Uint16Array(re),o=gr(s);let a=0;for(let c=0,l=0,u=0,d=0;c<o.length;c++){let h=o[c];for(let m=0;m<32;m++)u+=h&1,h>>=1,a+=1,a===r?(d=u,u=0):a===2*r&&(i[l++]=bt(d-u),u=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return i}const Ni=n=>{const{K:e,PRF:t,XOF:r,HASH512:s,ETA1:i,ETA2:o,du:a,dv:c}=n,l=vt(1),u=vt(c),d=vt(a),h=Qt(vn(vt(12),e),32),m=vn(vt(12),e),y=Qt(vn(d,e),u),g=Qt(32,32);return{secretCoder:m,secretKeyLen:m.bytesLen,publicKeyLen:h.bytesLen,cipherTextLen:y.bytesLen,keygen:w=>{const v=new Uint8Array(33);v.set(w),v[32]=e;const A=s(v),[S,p]=g.decode(A),k=[],b=[];for(let W=0;W<e;W++)k.push(Qe.encode(kt(t,p,W,i)));const I=r(S);for(let W=0;W<e;W++){const me=Qe.encode(kt(t,p,e+W,i));for(let L=0;L<e;L++){const Re=Or(I.get(L,W));Ve(me,Vt(Re,k[L]))}b.push(me)}I.clean();const H={publicKey:h.encode([b,S]),secretKey:m.encode(k)};return De(S,p,k,b,v,A),H},encrypt:(w,v,A)=>{const[S,p]=h.decode(w),k=[];for(let L=0;L<e;L++)k.push(Qe.encode(kt(t,A,L,i)));const b=r(p),I=new Uint16Array(re),H=[];for(let L=0;L<e;L++){const Re=kt(t,A,e+L,o),ot=new Uint16Array(re);for(let C=0;C<e;C++){const B=Or(b.get(L,C));Ve(ot,Vt(B,k[C]))}Ve(Re,Qe.decode(ot)),H.push(Re),Ve(I,Vt(S[L],k[L])),ot.fill(0)}b.clean();const W=kt(t,A,2*e,o);Ve(W,Qe.decode(I));const me=l.decode(v);return Ve(me,W),De(S,k,I,W),y.encode([H,me])},decrypt:(w,v)=>{const[A,S]=y.decode(w),p=m.decode(v),k=new Uint16Array(re);for(let b=0;b<e;b++)Ve(k,Vt(p[b],Qe.encode(A[b])));return Mi(S,Qe.decode(k)),De(k,p,A),l.encode(S)}}};function Ri(n){const e=Ni(n),{HASH256:t,HASH512:r,KDF:s}=n,{secretCoder:i,cipherTextLen:o}=e,a=e.publicKeyLen,c=Qt(e.secretKeyLen,e.publicKeyLen,32,32),l=c.bytesLen,u=32;return{publicKeyLen:a,msgLen:u,keygen:(d=Er(64))=>{qe(d,64);const{publicKey:h,secretKey:m}=e.keygen(d.subarray(0,32)),y=t(h),g=c.encode([m,h,y,d.subarray(32)]);return De(m,y),{publicKey:h,secretKey:g}},encapsulate:(d,h=Er(32))=>{qe(d,a),qe(h,u);const m=d.subarray(0,384*n.K),y=i.encode(i.decode(m.slice()));if(!Cr(y,m))throw De(y),new Error("ML-KEM.encapsulate: wrong publicKey modulus");De(y);const g=r.create().update(h).update(t(d)).digest(),w=e.encrypt(d,h,g.subarray(32,64));return g.subarray(32).fill(0),{cipherText:w,sharedSecret:g.subarray(0,32)}},decapsulate:(d,h)=>{qe(h,l),qe(d,o);const[m,y,g,w]=c.decode(h),v=e.decrypt(d,m),A=r.create().update(v).update(g).digest(),S=A.subarray(0,32),p=e.encrypt(y,v,A.subarray(32,64)),k=Cr(d,p),b=s.create({dkLen:32}).update(w).update(d).digest();return De(v,p,k?b:S),k?S:b}}}function Ui(n,e,t){return Tr.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const kn=Ri({...{HASH256:bi,HASH512:vi,KDF:Tr,XOF:xi,PRF:Ui},...Ei[768]});class N{constructor({secret:e=null,bundle:t=null,token:r="USER",address:s=null,position:i=null,batchId:o=null,characters:a=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=s,this.position=i,this.bundle=t,this.batchId=o,this.characters=a,e&&(this.bundle=this.bundle||We(e,"Wallet::constructor"),this.position=this.position||N.generatePosition(),this.key=N.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||N.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:r,batchId:s=null,characters:i=null}){let o=null;if(!e&&!t)throw new Gs;return e&&!t&&(o=N.generatePosition(),t=We(e,"Wallet::create")),new N({secret:e,bundle:t,token:r,position:o,batchId:s,characters:i})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&dr(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(gt.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const i=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new he("SHAKE256","TEXT");o.update(i.toString(16)),t&&o.update(t);const a=new he("SHAKE256","TEXT");return a.update(o.getHash("HEX",{outputLen:8192})),a.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=pt(e,128),r=new he("SHAKE256","TEXT");for(const i in t){let o=t[i];for(let a=1;a<=16;a++){const c=new he("SHAKE256","TEXT");c.update(o),o=c.getHash("HEX",{outputLen:512})}r.update(o)}const s=new he("SHAKE256","TEXT");return s.update(r.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Pt(e,"abcdef0123456789")}initializeMLKEM(){const e=Kt(this.key,64),t=new Uint8Array(64);for(let i=0;i<64;i++)t[i]=parseInt(e.substr(i*2,2),16);const{publicKey:r,secretKey:s}=kn.keygen(t);this.pubkey=this.serializeKey(r),this.privkey=s}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((r,s)=>t.charCodeAt(s))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,r=null){if(e.length===0)return;const s=[],i=[];this.tokenUnits.forEach(o=>{e.includes(o.id)?s.push(o):i.push(o)}),this.tokenUnits=s,r!==null&&(r.tokenUnits=s),t.tokenUnits=i}createRemainder(e){const t=N.create({secret:e,token:this.token,characters:this.characters});return t.initBatchId({sourceWallet:this,isRemainder:!0}),t}isShadow(){return(typeof this.position>"u"||this.position===null)&&(typeof this.address>"u"||this.address===null)}initBatchId({sourceWallet:e,isRemainder:t=!1}){e.batchId&&(this.batchId=t?e.batchId:Ft({}))}async encryptMessage(e,t){const r=JSON.stringify(e),s=new TextEncoder().encode(r),i=this.deserializeKey(t),{cipherText:o,sharedSecret:a}=kn.encapsulate(i),c=await this.encryptWithSharedSecret(s,a);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e;let s;try{s=kn.decapsulate(this.deserializeKey(t),this.privkey)}catch(c){return console.error("Wallet::decryptMessage() - Decapsulation failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),null}let i;try{i=this.deserializeKey(r)}catch(c){return console.warn("Wallet::decryptMessage() - Deserialization failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),null}let o;try{o=await this.decryptWithSharedSecret(i,s)}catch(c){return console.warn("Wallet::decryptMessage() - Decryption failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),null}let a;try{a=new TextDecoder().decode(o)}catch(c){return console.warn("Wallet::decryptMessage() - Decoding failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),console.info("Wallet::decryptMessage() - decrypted Uint8Array",o),null}return JSON.parse(a)}async encryptWithSharedSecret(e,t){const r=crypto.getRandomValues(new Uint8Array(12)),s={name:"AES-GCM",iv:r},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt(s,i,e),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),a}async decryptWithSharedSecret(e,t){const s={name:"AES-GCM",iv:e.slice(0,12)},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt(s,i,e.slice(12));return new Uint8Array(o)}}class St extends q{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class qi extends q{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class Hi extends q{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Nr extends q{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Rr extends q{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class Bi extends q{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class Me extends q{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Ur extends q{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class qr extends q{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Hr extends q{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class Pi extends q{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class Li extends q{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class He extends q{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class At extends q{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class zt extends q{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Br{constructor({}){const e=arguments[0];for(const t in e)this[`__${t}`]=e[t]}static toObject(e){return new this(e)}toJSON(){const e={};for(const t of Object.keys(this))t.substring(0,2)==="__"&&(e[t.substring(2,t.length)]=this[t]);return e}}class Jt extends q{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class Oe extends q{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class xt{constructor({action:e,metaType:t=null,metaId:r=null,meta:s=null,address:i=null,token:o=null,amount:a=null,comparison:c=null}){if(s&&(this.meta=s),!e)throw new Jt('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=i,this.__token=o,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!Vs(e))throw new Oe("Parameter amount should be a string containing numbers");this.__amount=e}set token(e){this.__token=e}set address(e){this.__address=e}set meta(e){this.__meta=e instanceof Br?e:Br.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new xt({action:e.action});return e.metaType&&(t.metaType=e.metaType),e.metaId&&(t.metaId=e.metaId),e.meta&&(t.meta=e.meta),e.address&&(t.address=e.address),e.token&&(t.token=e.token),e.amount&&(t.amount=e.amount),e.comparison&&(t.comparison=e.comparison),t}toJSON(){const e={action:this.__action};return this.__metaType&&(e.metaType=this.__metaType),this.__metaId&&(e.metaId=this.__metaId),this.__meta&&(e.meta=this.__meta),this.__address&&(e.address=this.__address),this.__token&&(e.token=this.__token),this.__amount&&(e.amount=this.__amount),this.__comparison&&(e.comparison=this.__comparison),e}isReject(){return this._is("reject")}isMeta(){return mt(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return mt(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return mt(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Sn{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(s=>!s))throw new Jt("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=r}static toObject(e){return new this({key:e.key,value:e.value,comparison:e.comparison})}toJSON(){return{key:this.__key,value:this.__value,comparison:this.__comparison}}}class _t{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof Sn))throw new Jt;for(const r of t)if(!(r instanceof xt))throw new Jt;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Sn?e:Sn.toObject(e))}set callback(e){this.__callback.push(e instanceof xt?e:xt.toObject(e))}static toObject(e){if(!e.condition)throw new He("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new He("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new _t({});for(const r of e.condition)t.comparison=r;for(const r of e.callback)t.callback=r;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class K{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const r=Number(this.key);Number.isInteger(r)&&(this.key=r),this.__nextKey=this.arr.length,this.__next=this.__tic(e)}static __tic(e){return!Array.isArray(e)&&!(e instanceof Object)?!1:typeof e[this.key]<"u"}static has(e,t){return this.__init(e,t),this.__next?this.__nextKey===0?!0:this.has(e[this.key],this.arr.join(".")):!1}static get(e,t,r=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),r):r}static set(e,t,r){const s=t.split(".");let i=e;const o=s.length-1;for(let l=0;l<o;l++){const u=s[l],d=Number(u),h=Number.isInteger(d);(h?d:u in i)||(i[h?d:u]=s[l+1].match(/^\d+$/)?[]:{}),i=i[h?d:u]}const a=s[o],c=Number(a);return i[Number.isInteger(c)?c:a]=r,e}}class Ki{constructor(e){if(e.molecularHash===null)throw new Hi;if(!e.atoms.length)throw new Ke;for(const t of e.atoms)if(t.index===null)throw new St;this.molecule=e}verify(e){return this.molecularHash()&&this.ots()&&this.batchId()&&this.continuId()&&this.isotopeM()&&this.isotopeT()&&this.isotopeC()&&this.isotopeU()&&this.isotopeI()&&this.isotopeR()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new Ke("Check::continuId() - Molecule is missing required ContinuID Atom!");return!0}batchId(){if(this.molecule.atoms.length>0){const e=this.molecule.atoms[0];if(e.isotope==="V"&&e.batchId!==null){const t=this.molecule.getIsotopes("V"),r=t[t.length-1];if(e.batchId!==r.batchId)throw new zt;for(const s of t)if(s.batchId===null)throw new zt}return!0}throw new zt}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new At(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new St(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`)}return!0}isotopeU(){for(const e of this.molecule.getIsotopes("U")){if(e.token!=="AUTH")throw new At(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeM(){const e=["readPolicy","writePolicy"];for(const t of this.molecule.getIsotopes("M")){if(t.meta.length<1)throw new He;if(t.token!=="USER")throw new At(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=yt.aggregateMeta(t.meta);for(const s of e){let i=r[s];if(i){i=JSON.parse(i);for(const[o,a]of Object.entries(i))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Nr(`${o} is missing from the meta.`);for(const c of a)if(!N.isBundleHash(c)&&!["all","self"].includes(c))throw new Nr(`${c} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new At(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeT(){for(const e of this.molecule.getIsotopes("T")){const t=e.aggregatedMeta();if(String(e.metaType).toLowerCase()==="wallet"){for(const s of["position","bundle"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new At(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeR(){for(const e of this.molecule.getIsotopes("R")){const t=e.aggregatedMeta();if(t.policy){const r=JSON.parse(t.policy);if(!Object.keys(r).every(s=>["read","write"].includes(s)))throw new He("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new He("Check::isotopeR() - Incorrect rule format!");for(const s of r)_t.toObject(s);if(r.length<1)throw new He("Check::isotopeR() - No rules!")}}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const r=this.molecule.atoms[0];if(r.isotope==="V"&&t.length===2){const o=t[t.length-1];if(r.token!==o.token)throw new qr;if(o.value<0)throw new Ur;return!0}let s=0,i=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const a=this.molecule.atoms[o];if(a.isotope!=="V")continue;if(i=a.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');if(a.token!==r.token)throw new qr;if(o>0){if(i<0)throw new Ur;if(a.walletAddress===r.walletAddress)throw new Pi}s+=i}if(s!==i)throw new Li;if(e){if(i=r.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');const o=e.balance+i;if(o<0)throw new Me;if(o!==s)throw new Hr}else if(i!==0)throw new Hr;return!0}molecularHash(){if(this.molecule.molecularHash!==E.hashAtoms({atoms:this.molecule.atoms}))throw new qi;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(h=>h.otsFragment).reduce((h,m)=>h+m);if(t.length!==2048&&(t=hr(t),t.length!==2048))throw new Rr;const r=pt(t,128);let s="";for(const h in r){let m=r[h];for(let y=0,g=8+e[h];y<g;y++)m=new he("SHAKE256","TEXT").update(m).getHash("HEX",{outputLen:512});s+=m}const i=new he("SHAKE256","TEXT");i.update(s);const o=i.getHash("HEX",{outputLen:8192}),a=new he("SHAKE256","TEXT");a.update(o);const c=a.getHash("HEX",{outputLen:256}),l=this.molecule.atoms[0];let u=l.walletAddress;const d=K.get(l.aggregatedMeta(),"signingWallet");if(d&&(u=K.get(JSON.parse(d),"address")),c!==u)throw new Bi;return!0}}class $t extends q{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Pr extends q{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class Ae{constructor({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null,cellSlug:i=null,version:o=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=i,this.secret=e,this.bundle=t,this.sourceWallet=r,this.atoms=[],o!==null&&Object.prototype.hasOwnProperty.call(Lt,o)&&(this.version=String(o)),(s||r)&&(this.remainderWallet=s||N.create({secret:e,bundle:t,token:r.token,batchId:r.batchId,characters:r.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(r=>e.includes(r.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new Ae({}),JSON.parse(e)),r=Object.keys(new Ae({}));if(!Array.isArray(t.atoms))throw new Ke;for(const s in Object.keys(t.atoms)){t.atoms[s]=E.jsonToObject(JSON.stringify(t.atoms[s]));for(const i of["position","walletAddress","isotope"])if(t.atoms[s].isotope.toLowerCase()!=="r"&&(typeof t.atoms[s][i]>"u"||t.atoms[s][i]===null))throw new Ke("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t.atoms=E.sortAtoms(t.atoms),t}static enumerate(e){const t={0:-8,1:-7,2:-6,3:-5,4:-4,5:-3,6:-2,7:-1,8:0,9:1,a:2,b:3,c:4,d:5,e:6,f:7,g:8},r=[],s=e.toLowerCase().split("");for(let i=0,o=s.length;i<o;++i){const a=s[i];typeof t[a]<"u"&&(r[i]=t[a])}return r}static normalize(e){let t=e.reduce((s,i)=>s+i);const r=t<0;for(;t<0||t>0;)for(const s of Object.keys(e))if((r?e[s]<8:e[s]>-8)&&(r?(++e[s],++t):(--e[s],--t),t===0))break;return e}getIsotopes(e){return Ae.isotopeFilter(e,this.atoms)}generateIndex(){return Ae.generateNextAtomIndex(this.atoms)}fill(e){for(const t in Object.keys(e))this[t]=e[t]}addAtom(e){return this.molecularHash=null,e.index=this.generateIndex(),e.version=this.version,this.atoms.push(e),this.atoms=E.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(E.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}addPolicyAtom({metaType:e,metaId:t,meta:r={},policy:s={}}){const i=new le(r);i.addPolicy(s);const o=N.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(E.create({wallet:o,isotope:"R",metaType:e,metaId:t,meta:i})),this}fuseToken(e,t){const r=e.length;if(this.sourceWallet.balance-r<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(E.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Pr("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}replenishToken({amount:e,units:t=[]}){if(e<0)throw new Pr("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=N.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const r of t)this.remainderWallet.tokenUnits.push(r);this.remainderWallet.balance=this.remainderWallet.tokenUnits.length,this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=this.sourceWallet.tokenUnits.length}else this.remainderWallet.balance=this.sourceWallet.balance+e,this.sourceWallet.balance=e;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.remainderWallet.balance,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initValue({recipientWallet:e,amount:t}){if(this.sourceWallet.balance-t<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(E.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new $t;const r=N.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this}initWithdrawBuffer({recipients:e,signingWallet:t=null}){let r=0;for(const[i,o]of Object.entries(e||{}))r+=o;if(this.sourceWallet.balance-r<0)throw new $t;const s=new le;t&&s.setSigningWallet(t),this.addAtom(E.create({isotope:"B",wallet:this.sourceWallet,value:-r,meta:s,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[i,o]of Object.entries(e||{}))this.addAtom(new E({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?Ft({}):null,metaType:"walletBundle",metaId:i}));return this.addAtom(E.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:r}){const s=new le(r);return s.setMetaWallet(e),this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,value:t,metaType:"token",metaId:e.token,meta:s,batchId:e.batchId})),this.addContinuIdAtom(),this}createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=[];for(const a of r)i.push(a instanceof _t?a:_t.toObject(a));const o=new le({rule:JSON.stringify(i)});return o.addPolicy(s),this.addAtom(E.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new le),t.setMetaWallet(e);const r=E.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(r),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new le().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const s={code:r,hash:We(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new le(s)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:s}){return this.addAtom(E.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new le(e)})),this.addPolicyAtom({metaType:t,metaId:r,meta:e,policy:s}),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i={},batchId:o=null}){return i.token=e,this.local=1,this.addAtom(E.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:s,meta:new le(i),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(E.create({isotope:"U",wallet:this.sourceWallet,meta:new le(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(m=>!(m instanceof E)).length!==0)throw new Ke;!t&&!this.bundle&&(this.bundle=e||We(this.secret,"Molecule::sign")),this.molecularHash=E.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let i=s.position;const o=K.get(s.aggregatedMeta(),"signingWallet");if(o&&(i=K.get(JSON.parse(o),"position")),!i)throw new Rr("Signing wallet must have a position!");const a=N.generateKey({secret:this.secret,token:s.token,position:s.position}),c=pt(a,128),l=this.normalizedHash();let u="";for(const m in c){let y=c[m];for(let g=0,w=8-l[m];g<w;g++)y=new he("SHAKE256","TEXT").update(y).getHash("HEX",{outputLen:512});u+=y}r&&(u=cr(u));const d=pt(u,Math.ceil(u.length/this.atoms.length));let h=null;for(let m=0,y=d.length;m<y;m++)this.atoms[m].otsFragment=d[m],h=this.atoms[m].position;return h}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=fr(this);for(const t of["remainderWallet","secret","sourceWallet","cellSlugOrigin","version"])Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return e}check(e=null){new Ki(this).verify(e)}normalizedHash(){return Ae.normalize(Ae.enumerate(this.molecularHash))}}const An=10**18;class et{static val(e){return Math.abs(e*An)<1?0:e}static cmp(e,t,r=!1){const s=et.val(e)*An,i=et.val(t)*An;return Math.abs(s-i)<1?0:s>i?1:-1}static equal(e,t){return et.cmp(e,t)===0}}class It{constructor({token:e,expiresAt:t,encrypt:r,pubkey:s}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=s,this.$__encrypt=r}static create(e,t){const r=new It(e);return r.setWallet(t),r}static restore(e,t){const r=new N({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return It.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},r)}setWallet(e){this.$__wallet=e}getWallet(){return this.$__wallet}getSnapshot(){return{token:this.$__token,expiresAt:this.$__expiresAt,pubkey:this.$__pubkey,encrypt:this.$__encrypt,wallet:{position:this.$__wallet.position,characters:this.$__wallet.characters}}}getToken(){return this.$__token}getPubkey(){return this.$__pubkey}getExpireInterval(){return this.$__expiresAt*1e3-Date.now()}isExpired(){return!this.$__expiresAt||this.getExpireInterval()<0}getAuthData(){return{token:this.getToken(),pubkey:this.getPubkey(),wallet:this.getWallet()}}}class Tt extends q{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class xn extends q{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}class V{constructor({query:e,json:t,dataKey:r=null}){if(this.dataKey=r,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new Tt;if(K.has(this.$__response,this.errorKey)){const s=K.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new xn:new Tt}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!K.has(this.response(),this.dataKey))throw new Tt;return K.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}}class se{constructor(e,t){this.client=e,this.knishIOClient=t,this.$__variables=null,this.$__query=null,this.$__response=null,this.$__request=null}response(){return this.$__response}async createResponseRaw(e){return this.createResponse(e)}createResponse(e){return new V({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new Oe("Query::createQuery() - GraphQL subscription was not initialized!");return{query:this.$__query,variables:this.variables()}}async execute({variables:e=null,context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s=await this.client.query({...this.$__request,context:r});return this.$__response=await this.createResponseRaw(s),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Query was cancelled"}]}});throw s}}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}createQueryContext(){return{}}}class Fi extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ContinuId"})}payload(){let e=null;const t=this.data();return t&&(e=new N({secret:null,token:t.tokenSlug}),e.address=t.address,e.position=t.position,e.bundle=t.bundleHash,e.batchId=t.batchId,e.characters=t.characters,e.pubkey=t.pubkey,e.balance=t.amount*1),e}}var Be={NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",FIELD:"Field",FRAGMENT_DEFINITION:"FragmentDefinition"};class _n extends Error{constructor(e,t,r,s,i,o,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),o&&(this.originalError=o);var c=a;if(!c&&o){var l=o.extensions;l&&typeof l=="object"&&(c=l)}this.extensions=c||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}var O,_;function F(n){return new _n(`Syntax Error: Unexpected token at ${_} in ${n}`)}function ue(n){if(n.lastIndex=_,n.test(O))return O.slice(_,_=n.lastIndex)}var Gt=/ +(?=[^\s])/y;function Wi(n){for(var e=n.split(`
|
|
4
|
+
${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain atoms",t=null,r=null){super(e,t,r),this.name="AtomsMissingException"}}class We{static create(e){const t={};for(const r of Object.keys(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const r in e)t.push(We.isStructure(e[r])?We.structure(e[r]):e[r]);return t}case"[object Object]":{const t=[],r=Object.keys(e).sort((s,i)=>s===i?0:s<i?-1:1);for(const s of r)if(Object.prototype.hasOwnProperty.call(e,s)){const i={};i[s]=We.isStructure(e[s])?We.structure(e[s]):e[s],t.push(i)}if(t.length>0)return t;break}}return e}static isStructure(e){return["[object Object]","[object Array]"].includes(Object.prototype.toString.call(e))}view(){return We.structure(this)}}class Js extends We{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,index:u=null,createdAt:d=null,version:h=null}){super(),this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l,this.index=u,this.createdAt=d,this.version=h}}const Lt={4:Js};class E{constructor({position:e=null,walletAddress:t=null,isotope:r=null,token:s=null,value:i=null,batchId:o=null,metaType:a=null,metaId:c=null,meta:l=null,otsFragment:u=null,index:d=null,version:h=null}){this.position=e,this.walletAddress=t,this.isotope=r,this.token=s,this.value=i!==null?String(i):null,this.batchId=o,this.metaType=a,this.metaId=c,this.meta=l?Ke.normalizeMeta(l):[],this.index=d,this.otsFragment=u,this.createdAt=String(+new Date),h!==null&&Object.prototype.hasOwnProperty.call(Lt,h)&&(this.version=String(h))}static getHashableProps(){return["position","walletAddress","isotope","token","value","batchId","metaType","metaId","meta","createdAt"]}static getUnclaimedProps(){return["otsFragment"]}static create({isotope:e,wallet:t=null,value:r=null,metaType:s=null,metaId:i=null,meta:o=null,batchId:a=null}){return o||(o=new le),o instanceof le||(o=new le(o)),t&&(o.setAtomWallet(t),a||(a=t.batchId)),new E({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:r,batchId:a,metaType:s,metaId:i,meta:o.get()})}static jsonToObject(e){const t=Object.assign(new E({}),JSON.parse(e)),r=Object.keys(new E({}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t}static hashAtoms({atoms:e,output:t="base17"}){const r=new he("SHAKE256","TEXT"),s=E.sortAtoms(e);if(s.length===0)throw new Fe;if(s.map(i=>{if(!(i instanceof E))throw new Fe;return i}),s.every(i=>i.version&&Object.prototype.hasOwnProperty.call(Lt,i.version)))r.update(JSON.stringify(s.map(i=>Lt[i.version].create(i).view())));else{const i=String(e.length);let o=[];for(const a of s)o.push(i),o=o.concat(a.getHashableValues());for(const a of o)r.update(a)}switch(t){case"hex":return r.getHash("HEX",{outputLen:256});case"array":return r.getHash("ARRAYBUFFER",{outputLen:256});default:return ar(r.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!E.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((r,s)=>r.index<s.index?-1:1),t}aggregatedMeta(){return Ke.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of E.getHashableProps()){const r=this[t];if(!(r===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const s of r)typeof s.value<"u"&&s.value!==null&&(e.push(String(s.key)),e.push(String(s.value)));else e.push(r===null?"":String(r))}return e}}function Kt(n=null,e=2048){if(n){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:e*2})}else return Pt(e)}function De(n,e=null){const t=new he("SHAKE256","TEXT");return t.update(n),t.getHash("HEX",{outputLen:256})}function Ft({molecularHash:n=null,index:e=null}){return n!==null&&e!==null?De(String(n)+String(e),"generateBatchId"):Pt(64)}class gt{constructor(e,t,r){this.id=e,this.name=t,this.metas=r||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new gt(e.id,e.name,t)}static createFromDB(e){return new gt(e[0],e[1],e.length>2?e[2]:{})}getFragmentZone(){return this.metas.fragmentZone||null}getFusedTokenUnits(){return this.metas.fusedTokenUnits||null}toData(){return[this.id,this.name,this.metas]}toGraphQLResponse(){return{id:this.id,name:this.name,metas:JSON.stringify(this.metas)}}}class Gs extends q{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,r=null){super(e,t,r),this.name="WalletCredentialException"}}function pr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function Xs(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Wt(n,...e){if(!Xs(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error("Uint8Array expected of length "+e+", got length="+n.length)}function yr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Ys(n,e){Wt(n);const t=e.outputLen;if(n.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Dt=BigInt(2**32-1),mr=BigInt(32);function Zs(n,e=!1){return e?{h:Number(n&Dt),l:Number(n>>mr&Dt)}:{h:Number(n>>mr&Dt)|0,l:Number(n&Dt)|0}}function ei(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Zs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const ti=(n,e,t)=>n<<t|e>>>32-t,ni=(n,e,t)=>e<<t|n>>>32-t,ri=(n,e,t)=>e<<t-32|n>>>64-t,si=(n,e,t)=>n<<t-32|e>>>64-t,et=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gr(n){return new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4))}const wr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ii(n){return n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255}function br(n){for(let e=0;e<n.length;e++)n[e]=ii(n[e])}const Ce={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(n){if(n>=Ce._0&&n<=Ce._9)return n-Ce._0;if(n>=Ce.A&&n<=Ce.F)return n-(Ce.A-10);if(n>=Ce.a&&n<=Ce.f)return n-(Ce.a-10)}function de(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=vr(n.charCodeAt(i)),a=vr(n.charCodeAt(i+1));if(o===void 0||a===void 0){const c=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[s]=o*16+a}return r}function oi(n){if(typeof n!="string")throw new Error("utf8ToBytes expected string, got "+typeof n);return new Uint8Array(new TextEncoder().encode(n))}function bn(n){return typeof n=="string"&&(n=oi(n)),Wt(n),n}class ai{clone(){return this._cloneInto()}}function li(n){const e=r=>n().update(bn(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ui(n){const e=(r,s)=>n(s).update(bn(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}function ci(n=32){if(et&&typeof et.getRandomValues=="function")return et.getRandomValues(new Uint8Array(n));if(et&&typeof et.randomBytes=="function")return et.randomBytes(n);throw new Error("crypto.getRandomValues must be defined")}const kr=[],Sr=[],Ar=[],hi=BigInt(0),wt=BigInt(1),di=BigInt(2),fi=BigInt(7),pi=BigInt(256),yi=BigInt(113);for(let n=0,e=wt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],kr.push(2*(5*r+t)),Sr.push((n+1)*(n+2)/2%64);let s=hi;for(let i=0;i<7;i++)e=(e<<wt^(e>>fi)*yi)%pi,e&di&&(s^=wt<<(wt<<BigInt(i))-wt);Ar.push(s)}const[mi,gi]=ei(Ar,!0),xr=(n,e,t)=>t>32?ri(n,e,t):ti(n,e,t),_r=(n,e,t)=>t>32?si(n,e,t):ni(n,e,t);function wi(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],d=xr(l,u,1)^t[a],h=_r(l,u,1)^t[a+1];for(let m=0;m<50;m+=10)n[o+m]^=d,n[o+m+1]^=h}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Sr[o],c=xr(s,i,a),l=_r(s,i,a),u=kr[o];s=n[u],i=n[u+1],n[u]=c,n[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=mi[r],n[1]^=gi[r]}t.fill(0)}class jt extends ai{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,pr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=gr(this.state)}keccak(){wr||br(this.state32),wi(this.state32,this.rounds),wr||br(this.state32),this.posOut=0,this.pos=0}update(e){yr(this);const{blockLen:t,state:r}=this;e=bn(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){yr(this,!1),Wt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ys(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:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new jt(t,r,s,o,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=o,e.destroyed=this.destroyed,e}}const $r=(n,e,t)=>li(()=>new jt(e,n,t)),bi=$r(6,136,256/8),vi=$r(6,72,512/8),Ir=(n,e,t)=>ui((r={})=>new jt(e,n,r.dkLen===void 0?t:r.dkLen,!0)),ki=Ir(31,168,128/8),Tr=Ir(31,136,256/8);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const qe=Wt,Er=ci;function Cr(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Qt(...n){const e=r=>typeof r=="number"?r:r.bytesLen,t=n.reduce((r,s)=>r+e(s),0);return{bytesLen:t,encode:r=>{const s=new Uint8Array(t);for(let i=0,o=0;i<n.length;i++){const a=n[i],c=e(a),l=typeof a=="number"?r[i]:a.encode(r[i]);qe(l,c),s.set(l,o),typeof a!="number"&&l.fill(0),o+=c}return s},decode:r=>{qe(r,t);const s=[];for(const i of n){const o=e(i),a=r.subarray(0,o);s.push(typeof i=="number"?a:i.decode(a)),r=r.subarray(o)}return s}}}function vn(n,e){const t=e*n.bytesLen;return{bytesLen:t,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const s=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const a=n.encode(r[i]);s.set(a,o),a.fill(0),o+=a.length}return s},decode:r=>{qe(r,t);const s=[];for(let i=0;i<r.length;i+=n.bytesLen)s.push(n.decode(r.subarray(i,i+n.bytesLen)));return s}}}function je(...n){for(const e of n)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Mr(n){return(1<<n)-1}de("0609608648016503040201"),de("0609608648016503040202"),de("0609608648016503040203"),de("0609608648016503040204"),de("0609608648016503040205"),de("0609608648016503040206"),de("0609608648016503040207"),de("0609608648016503040208"),de("0609608648016503040209"),de("060960864801650304020A"),de("060960864801650304020B"),de("060960864801650304020C");/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Si(n,e=8){const s=n.toString(2).padStart(8,"0").slice(-e).padStart(7,"0").split("").reverse().join("");return Number.parseInt(s,2)}const Ai=n=>{const{newPoly:e,N:t,Q:r,F:s,ROOT_OF_UNITY:i,brvBits:o}=n,a=(g,w=r)=>{const v=g%w|0;return(v>=0?v|0:w+v|0)|0},c=(g,w=r)=>{const v=a(g,w)|0;return(v>w>>1?v-w|0:v)|0};function l(){const g=e(t);for(let w=0;w<t;w++){const v=Si(w,o),A=BigInt(i)**BigInt(v)%BigInt(r);g[w]=Number(A)|0}return g}const u=l(),d=128,h=1;return{mod:a,smod:c,nttZetas:u,NTT:{encode:g=>{for(let w=1,v=128;v>h;v>>=1)for(let A=0;A<t;A+=2*v){const S=u[w++];for(let p=A;p<A+v;p++){const k=a(S*g[p+v]);g[p+v]=a(g[p]-k)|0,g[p]=a(g[p]+k)|0}}return g},decode:g=>{for(let w=d-1,v=1+h;v<d+h;v<<=1)for(let A=0;A<t;A+=2*v){const S=u[w--];for(let p=A;p<A+v;p++){const k=g[p];g[p]=a(k+g[p+v]),g[p+v]=a(S*(g[p+v]-k))}}for(let w=0;w<g.length;w++)g[w]=a(s*g[w]);return g}},bitsCoder:(g,w)=>{const v=Mr(g),A=g*(t/8);return{bytesLen:A,encode:S=>{const p=new Uint8Array(A);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=(w.encode(S[k])&v)<<I,I+=g;I>=8;I-=8,b>>=8)p[H++]=b&Mr(I);return p},decode:S=>{const p=e(t);for(let k=0,b=0,I=0,H=0;k<S.length;k++)for(b|=S[k]<<I,I+=8;I>=g;I-=g,b>>=g)p[H++]=w.decode(b&v);return p}}}}},xi=(n=>(e,t)=>{t||(t=n.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const s=e.length,i=new Uint8Array(t);let o=n.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(r[s+0]=l,r[s+1]=u,o.destroy(),o=n.create({}).update(r),a++,()=>(c++,o.xofInto(i))),clean:()=>{o.destroy(),i.fill(0),r.fill(0)}}})(ki);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const re=256,Qe=3329,_i=3303,$i=17,{mod:bt,nttZetas:Ii,NTT:Ve,bitsCoder:Ti}=Ai({N:re,Q:Qe,F:_i,ROOT_OF_UNITY:$i,newPoly:n=>new Uint16Array(n),brvBits:7}),Ei={768:{N:re,Q:Qe,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},Ci=n=>{if(n>=12)return{encode:t=>t,decode:t=>t};const e=2**(n-1);return{encode:t=>((t<<n)+Qe/2)/Qe,decode:t=>t*Qe+e>>>n}},vt=n=>Ti(n,Ci(n));function ze(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]+e[t])}function Mi(n,e){for(let t=0;t<re;t++)n[t]=bt(n[t]-e[t])}function Oi(n,e,t,r,s){const i=bt(e*r*s+n*t),o=bt(n*r+e*t);return{c0:i,c1:o}}function Vt(n,e){for(let t=0;t<re/2;t++){let r=Ii[64+(t>>1)];t&1&&(r=-r);const{c0:s,c1:i}=Oi(n[2*t+0],n[2*t+1],e[2*t+0],e[2*t+1],r);n[2*t+0]=s,n[2*t+1]=i}return n}function Or(n){const e=new Uint16Array(re);for(let t=0;t<re;){const r=n();if(r.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<re&&s+3<=r.length;s+=3){const i=(r[s+0]>>0|r[s+1]<<8)&4095,o=(r[s+1]>>4|r[s+2]<<4)&4095;i<Qe&&(e[t++]=i),t<re&&o<Qe&&(e[t++]=o)}}return e}function kt(n,e,t,r){const s=n(r*re/4,e,t),i=new Uint16Array(re),o=gr(s);let a=0;for(let c=0,l=0,u=0,d=0;c<o.length;c++){let h=o[c];for(let m=0;m<32;m++)u+=h&1,h>>=1,a+=1,a===r?(d=u,u=0):a===2*r&&(i[l++]=bt(d-u),u=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return i}const Ni=n=>{const{K:e,PRF:t,XOF:r,HASH512:s,ETA1:i,ETA2:o,du:a,dv:c}=n,l=vt(1),u=vt(c),d=vt(a),h=Qt(vn(vt(12),e),32),m=vn(vt(12),e),y=Qt(vn(d,e),u),g=Qt(32,32);return{secretCoder:m,secretKeyLen:m.bytesLen,publicKeyLen:h.bytesLen,cipherTextLen:y.bytesLen,keygen:w=>{const v=new Uint8Array(33);v.set(w),v[32]=e;const A=s(v),[S,p]=g.decode(A),k=[],b=[];for(let W=0;W<e;W++)k.push(Ve.encode(kt(t,p,W,i)));const I=r(S);for(let W=0;W<e;W++){const me=Ve.encode(kt(t,p,e+W,i));for(let L=0;L<e;L++){const Re=Or(I.get(L,W));ze(me,Vt(Re,k[L]))}b.push(me)}I.clean();const H={publicKey:h.encode([b,S]),secretKey:m.encode(k)};return je(S,p,k,b,v,A),H},encrypt:(w,v,A)=>{const[S,p]=h.decode(w),k=[];for(let L=0;L<e;L++)k.push(Ve.encode(kt(t,A,L,i)));const b=r(p),I=new Uint16Array(re),H=[];for(let L=0;L<e;L++){const Re=kt(t,A,e+L,o),at=new Uint16Array(re);for(let C=0;C<e;C++){const B=Or(b.get(L,C));ze(at,Vt(B,k[C]))}ze(Re,Ve.decode(at)),H.push(Re),ze(I,Vt(S[L],k[L])),at.fill(0)}b.clean();const W=kt(t,A,2*e,o);ze(W,Ve.decode(I));const me=l.decode(v);return ze(me,W),je(S,k,I,W),y.encode([H,me])},decrypt:(w,v)=>{const[A,S]=y.decode(w),p=m.decode(v),k=new Uint16Array(re);for(let b=0;b<e;b++)ze(k,Vt(p[b],Ve.encode(A[b])));return Mi(S,Ve.decode(k)),je(k,p,A),l.encode(S)}}};function Ri(n){const e=Ni(n),{HASH256:t,HASH512:r,KDF:s}=n,{secretCoder:i,cipherTextLen:o}=e,a=e.publicKeyLen,c=Qt(e.secretKeyLen,e.publicKeyLen,32,32),l=c.bytesLen,u=32;return{publicKeyLen:a,msgLen:u,keygen:(d=Er(64))=>{qe(d,64);const{publicKey:h,secretKey:m}=e.keygen(d.subarray(0,32)),y=t(h),g=c.encode([m,h,y,d.subarray(32)]);return je(m,y),{publicKey:h,secretKey:g}},encapsulate:(d,h=Er(32))=>{qe(d,a),qe(h,u);const m=d.subarray(0,384*n.K),y=i.encode(i.decode(m.slice()));if(!Cr(y,m))throw je(y),new Error("ML-KEM.encapsulate: wrong publicKey modulus");je(y);const g=r.create().update(h).update(t(d)).digest(),w=e.encrypt(d,h,g.subarray(32,64));return g.subarray(32).fill(0),{cipherText:w,sharedSecret:g.subarray(0,32)}},decapsulate:(d,h)=>{qe(h,l),qe(d,o);const[m,y,g,w]=c.decode(h),v=e.decrypt(d,m),A=r.create().update(v).update(g).digest(),S=A.subarray(0,32),p=e.encrypt(y,v,A.subarray(32,64)),k=Cr(d,p),b=s.create({dkLen:32}).update(w).update(d).digest();return je(v,p,k?b:S),k?S:b}}}function Ui(n,e,t){return Tr.create({dkLen:n}).update(e).update(new Uint8Array([t])).digest()}const kn=Ri({...{HASH256:bi,HASH512:vi,KDF:Tr,XOF:xi,PRF:Ui},...Ei[768]});class N{constructor({secret:e=null,bundle:t=null,token:r="USER",address:s=null,position:i=null,batchId:o=null,characters:a=null}){this.token=r,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=s,this.position=i,this.bundle=t,this.batchId=o,this.characters=a,e&&(this.bundle=this.bundle||De(e,"Wallet::constructor"),this.position=this.position||N.generatePosition(),this.key=N.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||N.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:r,batchId:s=null,characters:i=null}){let o=null;if(!e&&!t)throw new Gs;return e&&!t&&(o=N.generatePosition(),t=De(e,"Wallet::create")),new N({secret:e,bundle:t,token:r,position:o,batchId:s,characters:i})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&dr(e)}static getTokenUnits(e){const t=[];return e.forEach(r=>{t.push(gt.createFromDB(r))}),t}static generateKey({secret:e,token:t,position:r}){const i=BigInt(`0x${e}`)+BigInt(`0x${r}`),o=new he("SHAKE256","TEXT");o.update(i.toString(16)),t&&o.update(t);const a=new he("SHAKE256","TEXT");return a.update(o.getHash("HEX",{outputLen:8192})),a.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=yt(e,128),r=new he("SHAKE256","TEXT");for(const i in t){let o=t[i];for(let a=1;a<=16;a++){const c=new he("SHAKE256","TEXT");c.update(o),o=c.getHash("HEX",{outputLen:512})}r.update(o)}const s=new he("SHAKE256","TEXT");return s.update(r.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Pt(e,"abcdef0123456789")}initializeMLKEM(){const e=Kt(this.key,64),t=new Uint8Array(64);for(let i=0;i<64;i++)t[i]=parseInt(e.substr(i*2,2),16);const{publicKey:r,secretKey:s}=kn.keygen(t);this.pubkey=this.serializeKey(r),this.privkey=s}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((r,s)=>t.charCodeAt(s))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,r=null){if(e.length===0)return;const s=[],i=[];this.tokenUnits.forEach(o=>{e.includes(o.id)?s.push(o):i.push(o)}),this.tokenUnits=s,r!==null&&(r.tokenUnits=s),t.tokenUnits=i}createRemainder(e){const t=N.create({secret:e,token:this.token,characters:this.characters});return t.initBatchId({sourceWallet:this,isRemainder:!0}),t}isShadow(){return(typeof this.position>"u"||this.position===null)&&(typeof this.address>"u"||this.address===null)}initBatchId({sourceWallet:e,isRemainder:t=!1}){e.batchId&&(this.batchId=t?e.batchId:Ft({}))}async encryptMessage(e,t){const r=JSON.stringify(e),s=new TextEncoder().encode(r),i=this.deserializeKey(t),{cipherText:o,sharedSecret:a}=kn.encapsulate(i),c=await this.encryptWithSharedSecret(s,a);return{cipherText:this.serializeKey(o),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:r}=e;let s;try{s=kn.decapsulate(this.deserializeKey(t),this.privkey)}catch(c){return console.error("Wallet::decryptMessage() - Decapsulation failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),null}let i;try{i=this.deserializeKey(r)}catch(c){return console.warn("Wallet::decryptMessage() - Deserialization failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),null}let o;try{o=await this.decryptWithSharedSecret(i,s)}catch(c){return console.warn("Wallet::decryptMessage() - Decryption failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),null}let a;try{a=new TextDecoder().decode(o)}catch(c){return console.warn("Wallet::decryptMessage() - Decoding failed",c),console.info("Wallet::decryptMessage() - my public key",this.pubkey),console.info("Wallet::decryptMessage() - our shared secret",s),console.info("Wallet::decryptMessage() - deserialized encrypted message",i),console.info("Wallet::decryptMessage() - decrypted Uint8Array",o),null}return JSON.parse(a)}async encryptWithSharedSecret(e,t){const r=crypto.getRandomValues(new Uint8Array(12)),s={name:"AES-GCM",iv:r},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),o=await crypto.subtle.encrypt(s,i,e),a=new Uint8Array(r.length+o.byteLength);return a.set(r),a.set(new Uint8Array(o),r.length),a}async decryptWithSharedSecret(e,t){const s={name:"AES-GCM",iv:e.slice(0,12)},i=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),o=await crypto.subtle.decrypt(s,i,e.slice(12));return new Uint8Array(o)}}class St extends q{constructor(e="There is an atom without an index",t=null,r=null){super(e,t,r),this.name="AtomIndexException"}}class qi extends q{constructor(e="The molecular hash does not match",t=null,r=null){super(e,t,r),this.name="MolecularHashMismatchException"}}class Hi extends q{constructor(e="The molecular hash is missing",t=null,r=null){super(e,t,r),this.name="MolecularHashMissingException"}}class Nr extends q{constructor(e="",t=null,r=null){super(e,t,r),this.name="PolicyInvalidException"}}class Rr extends q{constructor(e="OTS malformed",t=null,r=null){super(e,t,r),this.name="SignatureMalformedException"}}class Bi extends q{constructor(e="One-time signature (OTS) does not match!",t=null,r=null){super(e,t,r),this.name="SignatureMismatchException"}}class Me extends q{constructor(e="Insufficient balance to make transfer",t=null,r=null){super(e,t,r),this.name="TransferBalanceException"}}class Ur extends q{constructor(e="Token transfer atoms are malformed",t=null,r=null){super(e,t,r),this.name="TransferMalformedException"}}class qr extends q{constructor(e="Token slugs for wallets in transfer do not match!",t=null,r=null){super(e,t,r),this.name="TransferMismatchedException"}}class Hr extends q{constructor(e="Invalid remainder provided",t=null,r=null){super(e,t,r),this.name="TransferRemainderException"}}class Pi extends q{constructor(e="Sender and recipient(s) cannot be the same",t=null,r=null){super(e,t,r),this.name="TransferToSelfException"}}class Li extends q{constructor(e="Token transfer atoms are unbalanced",t=null,r=null){super(e,t,r),this.name="TransferUnbalancedException"}}class He extends q{constructor(e="Empty meta data.",t=null,r=null){super(e,t,r),this.name="MetaMissingException"}}class At extends q{constructor(e="Wrong type of token for this isotope",t=null,r=null){super(e,t,r),this.name="WrongTokenTypeException"}}class zt extends q{constructor(e="Incorrect BatchId",t=null,r=null){super(e,t,r),this.name="BatchIdException"}}class Br{constructor({}){const e=arguments[0];for(const t in e)this[`__${t}`]=e[t]}static toObject(e){return new this(e)}toJSON(){const e={};for(const t of Object.keys(this))t.substring(0,2)==="__"&&(e[t.substring(2,t.length)]=this[t]);return e}}class Jt extends q{constructor(e="An incorrect argument!",t=null,r=null){super(e,t,r),this.name="RuleArgumentException"}}class Oe extends q{constructor(e="Code exception",t=null,r=null){super(e,t,r),this.name="CodeException"}}class xt{constructor({action:e,metaType:t=null,metaId:r=null,meta:s=null,address:i=null,token:o=null,amount:a=null,comparison:c=null}){if(s&&(this.meta=s),!e)throw new Jt('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=r,this.__metaType=t,this.__action=e,this.__address=i,this.__token=o,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!Vs(e))throw new Oe("Parameter amount should be a string containing numbers");this.__amount=e}set token(e){this.__token=e}set address(e){this.__address=e}set meta(e){this.__meta=e instanceof Br?e:Br.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new xt({action:e.action});return e.metaType&&(t.metaType=e.metaType),e.metaId&&(t.metaId=e.metaId),e.meta&&(t.meta=e.meta),e.address&&(t.address=e.address),e.token&&(t.token=e.token),e.amount&&(t.amount=e.amount),e.comparison&&(t.comparison=e.comparison),t}toJSON(){const e={action:this.__action};return this.__metaType&&(e.metaType=this.__metaType),this.__metaId&&(e.metaId=this.__metaId),this.__meta&&(e.meta=this.__meta),this.__address&&(e.address=this.__address),this.__token&&(e.token=this.__token),this.__amount&&(e.amount=this.__amount),this.__comparison&&(e.comparison=this.__comparison),e}isReject(){return this._is("reject")}isMeta(){return mt(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return mt(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return mt(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return mt(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Sn{constructor({key:e,value:t,comparison:r}){if([e,t,r].some(s=>!s))throw new Jt("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=r}static toObject(e){return new this({key:e.key,value:e.value,comparison:e.comparison})}toJSON(){return{key:this.__key,value:this.__value,comparison:this.__comparison}}}class _t{constructor({condition:e=[],callback:t=[]}){for(const r of e)if(!(r instanceof Sn))throw new Jt;for(const r of t)if(!(r instanceof xt))throw new Jt;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Sn?e:Sn.toObject(e))}set callback(e){this.__callback.push(e instanceof xt?e:xt.toObject(e))}static toObject(e){if(!e.condition)throw new He("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new He("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new _t({});for(const r of e.condition)t.comparison=r;for(const r of e.callback)t.callback=r;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class K{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const r=Number(this.key);Number.isInteger(r)&&(this.key=r),this.__nextKey=this.arr.length,this.__next=this.__tic(e)}static __tic(e){return!Array.isArray(e)&&!(e instanceof Object)?!1:typeof e[this.key]<"u"}static has(e,t){return this.__init(e,t),this.__next?this.__nextKey===0?!0:this.has(e[this.key],this.arr.join(".")):!1}static get(e,t,r=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),r):r}static set(e,t,r){const s=t.split(".");let i=e;const o=s.length-1;for(let l=0;l<o;l++){const u=s[l],d=Number(u),h=Number.isInteger(d);(h?d:u in i)||(i[h?d:u]=s[l+1].match(/^\d+$/)?[]:{}),i=i[h?d:u]}const a=s[o],c=Number(a);return i[Number.isInteger(c)?c:a]=r,e}}class Ki{constructor(e){if(e.molecularHash===null)throw new Hi;if(!e.atoms.length)throw new Fe;for(const t of e.atoms)if(t.index===null)throw new St;this.molecule=e}verify(e){return this.molecularHash()&&this.ots()&&this.batchId()&&this.continuId()&&this.isotopeM()&&this.isotopeT()&&this.isotopeC()&&this.isotopeU()&&this.isotopeI()&&this.isotopeR()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new Fe("Check::continuId() - Molecule is missing required ContinuID Atom!");return!0}batchId(){if(this.molecule.atoms.length>0){const e=this.molecule.atoms[0];if(e.isotope==="V"&&e.batchId!==null){const t=this.molecule.getIsotopes("V"),r=t[t.length-1];if(e.batchId!==r.batchId)throw new zt;for(const s of t)if(s.batchId===null)throw new zt}return!0}throw new zt}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new At(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new St(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`)}return!0}isotopeU(){for(const e of this.molecule.getIsotopes("U")){if(e.token!=="AUTH")throw new At(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeM(){const e=["readPolicy","writePolicy"];for(const t of this.molecule.getIsotopes("M")){if(t.meta.length<1)throw new He;if(t.token!=="USER")throw new At(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const r=Ke.aggregateMeta(t.meta);for(const s of e){let i=r[s];if(i){i=JSON.parse(i);for(const[o,a]of Object.entries(i))if(!e.includes(o)){if(!Object.keys(r).includes(o))throw new Nr(`${o} is missing from the meta.`);for(const c of a)if(!N.isBundleHash(c)&&!["all","self"].includes(c))throw new Nr(`${c} does not correspond to the format of the policy.`)}}}}return!0}isotopeC(){for(const e of this.molecule.getIsotopes("C")){if(e.token!=="USER")throw new At(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeT(){for(const e of this.molecule.getIsotopes("T")){const t=e.aggregatedMeta();if(String(e.metaType).toLowerCase()==="wallet"){for(const s of["position","bundle"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new He(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new At(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new St(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`)}return!0}isotopeR(){for(const e of this.molecule.getIsotopes("R")){const t=e.aggregatedMeta();if(t.policy){const r=JSON.parse(t.policy);if(!Object.keys(r).every(s=>["read","write"].includes(s)))throw new He("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const r=JSON.parse(t.rule);if(!Array.isArray(r))throw new He("Check::isotopeR() - Incorrect rule format!");for(const s of r)_t.toObject(s);if(r.length<1)throw new He("Check::isotopeR() - No rules!")}}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const r=this.molecule.atoms[0];if(r.isotope==="V"&&t.length===2){const o=t[t.length-1];if(r.token!==o.token)throw new qr;if(o.value<0)throw new Ur;return!0}let s=0,i=0;for(const o in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,o)){const a=this.molecule.atoms[o];if(a.isotope!=="V")continue;if(i=a.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');if(a.token!==r.token)throw new qr;if(o>0){if(i<0)throw new Ur;if(a.walletAddress===r.walletAddress)throw new Pi}s+=i}if(s!==i)throw new Li;if(e){if(i=r.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');const o=e.balance+i;if(o<0)throw new Me;if(o!==s)throw new Hr}else if(i!==0)throw new Hr;return!0}molecularHash(){if(this.molecule.molecularHash!==E.hashAtoms({atoms:this.molecule.atoms}))throw new qi;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(h=>h.otsFragment).reduce((h,m)=>h+m);if(t.length!==2048&&(t=hr(t),t.length!==2048))throw new Rr;const r=yt(t,128);let s="";for(const h in r){let m=r[h];for(let y=0,g=8+e[h];y<g;y++)m=new he("SHAKE256","TEXT").update(m).getHash("HEX",{outputLen:512});s+=m}const i=new he("SHAKE256","TEXT");i.update(s);const o=i.getHash("HEX",{outputLen:8192}),a=new he("SHAKE256","TEXT");a.update(o);const c=a.getHash("HEX",{outputLen:256}),l=this.molecule.atoms[0];let u=l.walletAddress;const d=K.get(l.aggregatedMeta(),"signingWallet");if(d&&(u=K.get(JSON.parse(d),"address")),c!==u)throw new Bi;return!0}}class $t extends q{constructor(e="Insufficient balance for requested transfer",t=null,r=null){super(e,t,r),this.name="BalanceInsufficientException"}}class Pr extends q{constructor(e="Amount cannot be negative!",t=null,r=null){super(e,t,r),this.name="NegativeAmountException"}}class Ae{constructor({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null,cellSlug:i=null,version:o=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=i,this.secret=e,this.bundle=t,this.sourceWallet=r,this.atoms=[],o!==null&&Object.prototype.hasOwnProperty.call(Lt,o)&&(this.version=String(o)),(s||r)&&(this.remainderWallet=s||N.create({secret:e,bundle:t,token:r.token,batchId:r.batchId,characters:r.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(r=>e.includes(r.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new Ae({}),JSON.parse(e)),r=Object.keys(new Ae({}));if(!Array.isArray(t.atoms))throw new Fe;for(const s in Object.keys(t.atoms)){t.atoms[s]=E.jsonToObject(JSON.stringify(t.atoms[s]));for(const i of["position","walletAddress","isotope"])if(t.atoms[s].isotope.toLowerCase()!=="r"&&(typeof t.atoms[s][i]>"u"||t.atoms[s][i]===null))throw new Fe("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!r.includes(s)&&delete t[s];return t.atoms=E.sortAtoms(t.atoms),t}static enumerate(e){const t={0:-8,1:-7,2:-6,3:-5,4:-4,5:-3,6:-2,7:-1,8:0,9:1,a:2,b:3,c:4,d:5,e:6,f:7,g:8},r=[],s=e.toLowerCase().split("");for(let i=0,o=s.length;i<o;++i){const a=s[i];typeof t[a]<"u"&&(r[i]=t[a])}return r}static normalize(e){let t=e.reduce((s,i)=>s+i);const r=t<0;for(;t<0||t>0;)for(const s of Object.keys(e))if((r?e[s]<8:e[s]>-8)&&(r?(++e[s],++t):(--e[s],--t),t===0))break;return e}getIsotopes(e){return Ae.isotopeFilter(e,this.atoms)}generateIndex(){return Ae.generateNextAtomIndex(this.atoms)}fill(e){for(const t in Object.keys(e))this[t]=e[t]}addAtom(e){return this.molecularHash=null,e.index=this.generateIndex(),e.version=this.version,this.atoms.push(e),this.atoms=E.sortAtoms(this.atoms),this}addContinuIdAtom(){return this.addAtom(E.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}addPolicyAtom({metaType:e,metaId:t,meta:r={},policy:s={}}){const i=new le(r);i.addPolicy(s);const o=N.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(E.create({wallet:o,isotope:"R",metaType:e,metaId:t,meta:i})),this}fuseToken(e,t){const r=e.length;if(this.sourceWallet.balance-r<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-r})),this.addAtom(E.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Pr("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}replenishToken({amount:e,units:t=[]}){if(e<0)throw new Pr("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=N.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const r of t)this.remainderWallet.tokenUnits.push(r);this.remainderWallet.balance=this.remainderWallet.tokenUnits.length,this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=this.sourceWallet.tokenUnits.length}else this.remainderWallet.balance=this.sourceWallet.balance+e,this.sourceWallet.balance=e;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.remainderWallet.balance,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initValue({recipientWallet:e,amount:t}){if(this.sourceWallet.balance-t<0)throw new $t;return this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-t})),this.addAtom(E.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new $t;const r=N.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return r.tradeRates=t,this.addAtom(E.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(E.create({isotope:"B",wallet:r,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(E.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this}initWithdrawBuffer({recipients:e,signingWallet:t=null}){let r=0;for(const[i,o]of Object.entries(e||{}))r+=o;if(this.sourceWallet.balance-r<0)throw new $t;const s=new le;t&&s.setSigningWallet(t),this.addAtom(E.create({isotope:"B",wallet:this.sourceWallet,value:-r,meta:s,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[i,o]of Object.entries(e||{}))this.addAtom(new E({isotope:"V",token:this.sourceWallet.token,value:o,batchId:this.sourceWallet.batchId?Ft({}):null,metaType:"walletBundle",metaId:i}));return this.addAtom(E.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-r,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:r}){const s=new le(r);return s.setMetaWallet(e),this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,value:t,metaType:"token",metaId:e.token,meta:s,batchId:e.batchId})),this.addContinuIdAtom(),this}createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=[];for(const a of r)i.push(a instanceof _t?a:_t.toObject(a));const o=new le({rule:JSON.stringify(i)});return o.addPolicy(s),this.addAtom(E.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:o})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new le),t.setMetaWallet(e);const r=E.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(r),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new le().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:r}){const s={code:r,hash:De(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(E.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new le(s)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:r,policy:s}){return this.addAtom(E.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:r,meta:new le(e)})),this.addPolicyAtom({metaType:t,metaId:r,meta:e,policy:s}),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:r,metaId:s,meta:i={},batchId:o=null}){return i.token=e,this.local=1,this.addAtom(E.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:r,metaId:s,meta:new le(i),batchId:o})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(E.create({isotope:"U",wallet:this.sourceWallet,meta:new le(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:r=!0}){if(this.atoms.length===0||this.atoms.filter(m=>!(m instanceof E)).length!==0)throw new Fe;!t&&!this.bundle&&(this.bundle=e||De(this.secret,"Molecule::sign")),this.molecularHash=E.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let i=s.position;const o=K.get(s.aggregatedMeta(),"signingWallet");if(o&&(i=K.get(JSON.parse(o),"position")),!i)throw new Rr("Signing wallet must have a position!");const a=N.generateKey({secret:this.secret,token:s.token,position:s.position}),c=yt(a,128),l=this.normalizedHash();let u="";for(const m in c){let y=c[m];for(let g=0,w=8-l[m];g<w;g++)y=new he("SHAKE256","TEXT").update(y).getHash("HEX",{outputLen:512});u+=y}r&&(u=cr(u));const d=yt(u,Math.ceil(u.length/this.atoms.length));let h=null;for(let m=0,y=d.length;m<y;m++)this.atoms[m].otsFragment=d[m],h=this.atoms[m].position;return h}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(){const e=fr(this);for(const t of["remainderWallet","secret","sourceWallet","cellSlugOrigin","version"])Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];return e}check(e=null){new Ki(this).verify(e)}normalizedHash(){return Ae.normalize(Ae.enumerate(this.molecularHash))}}const An=10**18;class tt{static val(e){return Math.abs(e*An)<1?0:e}static cmp(e,t,r=!1){const s=tt.val(e)*An,i=tt.val(t)*An;return Math.abs(s-i)<1?0:s>i?1:-1}static equal(e,t){return tt.cmp(e,t)===0}}class It{constructor({token:e,expiresAt:t,encrypt:r,pubkey:s}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=s,this.$__encrypt=r}static create(e,t){const r=new It(e);return r.setWallet(t),r}static restore(e,t){const r=new N({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return It.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},r)}setWallet(e){this.$__wallet=e}getWallet(){return this.$__wallet}getSnapshot(){return{token:this.$__token,expiresAt:this.$__expiresAt,pubkey:this.$__pubkey,encrypt:this.$__encrypt,wallet:{position:this.$__wallet.position,characters:this.$__wallet.characters}}}getToken(){return this.$__token}getPubkey(){return this.$__pubkey}getExpireInterval(){return this.$__expiresAt*1e3-Date.now()}isExpired(){return!this.$__expiresAt||this.getExpireInterval()<0}getAuthData(){return{token:this.getToken(),pubkey:this.getPubkey(),wallet:this.getWallet()}}}class Tt extends q{constructor(e="GraphQL did not provide a valid response.",t=null,r=null){super(e,t,r),this.name="InvalidResponseException"}}class xn extends q{constructor(e="Authorization token missing or invalid.",t=null,r=null){super(e,t,r),this.name="UnauthenticatedException"}}class V{constructor({query:e,json:t,dataKey:r=null}){if(this.dataKey=r,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new Tt;if(K.has(this.$__response,this.errorKey)){const s=K.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new xn:new Tt}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!K.has(this.response(),this.dataKey))throw new Tt;return K.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}}class se{constructor(e,t){this.client=e,this.knishIOClient=t,this.$__variables=null,this.$__query=null,this.$__response=null,this.$__request=null}response(){return this.$__response}async createResponseRaw(e){return this.createResponse(e)}createResponse(e){return new V({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new Oe("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new Oe("Query::createQuery() - GraphQL subscription was not initialized!");return{query:this.$__query,variables:this.variables()}}async execute({variables:e=null,context:t={}}){this.$__request=this.createQuery({variables:e});const r={...t,...this.createQueryContext()};try{const s=await this.client.query({...this.$__request,context:r});return this.$__response=await this.createResponseRaw(s),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new V({query:this,json:{data:null,errors:[{message:"Query was cancelled"}]}});throw s}}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}createQueryContext(){return{}}}class Fi extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ContinuId"})}payload(){let e=null;const t=this.data();return t&&(e=new N({secret:null,token:t.tokenSlug}),e.address=t.address,e.position=t.position,e.bundle=t.bundleHash,e.batchId=t.batchId,e.characters=t.characters,e.pubkey=t.pubkey,e.balance=t.amount*1),e}}var Be={NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",FIELD:"Field",FRAGMENT_DEFINITION:"FragmentDefinition"};class _n extends Error{constructor(e,t,r,s,i,o,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),o&&(this.originalError=o);var c=a;if(!c&&o){var l=o.extensions;l&&typeof l=="object"&&(c=l)}this.extensions=c||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}var O,_;function F(n){return new _n(`Syntax Error: Unexpected token at ${_} in ${n}`)}function ue(n){if(n.lastIndex=_,n.test(O))return O.slice(_,_=n.lastIndex)}var Gt=/ +(?=[^\s])/y;function Wi(n){for(var e=n.split(`
|
|
5
5
|
`),t="",r=0,s=0,i=e.length-1,o=0;o<e.length;o++)Gt.lastIndex=0,Gt.test(e[o])&&(o&&(!r||Gt.lastIndex<r)&&(r=Gt.lastIndex),s=s||o,i=o);for(var a=s;a<=i;a++)a!==s&&(t+=`
|
|
6
|
-
`),t+=e[a].slice(r).replace(/\\"""/g,'"""');return t}function T(){for(var n=0|O.charCodeAt(_++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|O.charCodeAt(_++))if(n===35)for(;(n=O.charCodeAt(_++))!==10&&n!==13;);_--}var te=/[_A-Za-z]\w*/y,$n=new RegExp("(?:(null|true|false)|\\$("+te.source+')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|('+te.source+"))","y"),Pe=function(n){return n[n.Const=1]="Const",n[n.Var=2]="Var",n[n.Int=3]="Int",n[n.Float=4]="Float",n[n.BlockString=5]="BlockString",n[n.String=6]="String",n[n.Enum=7]="Enum",n}(Pe||{}),Di=/\\/;function Xt(n){var e,t;if($n.lastIndex=_,O.charCodeAt(_)===91){_++,T();for(var r=[];O.charCodeAt(_)!==93;)r.push(Xt(n));return _++,T(),{kind:"ListValue",values:r}}else if(O.charCodeAt(_)===123){_++,T();for(var s=[];O.charCodeAt(_)!==125;){if((e=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("ObjectField");T(),s.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Xt(n)})}return _++,T(),{kind:"ObjectValue",fields:s}}else if((t=$n.exec(O))!=null){if(_=$n.lastIndex,T(),(e=t[Pe.Const])!=null)return e==="null"?{kind:"NullValue"}:{kind:"BooleanValue",value:e==="true"};if((e=t[Pe.Var])!=null){if(n)throw F("Variable");return{kind:"Variable",name:{kind:"Name",value:e}}}else if((e=t[Pe.Int])!=null){var i;return(i=t[Pe.Float])!=null?{kind:"FloatValue",value:e+i}:{kind:"IntValue",value:e}}else{if((e=t[Pe.BlockString])!=null)return{kind:"StringValue",value:Wi(e.slice(3,-3)),block:!0};if((e=t[Pe.String])!=null)return{kind:"StringValue",value:Di.test(e)?JSON.parse(e):e.slice(1,-1),block:!1};if((e=t[Pe.Enum])!=null)return{kind:"EnumValue",value:e}}}throw F("Value")}function Lr(n){if(O.charCodeAt(_)===40){var e=[];_++,T();var t;do{if((t=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("Argument");T(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Xt(n)})}while(O.charCodeAt(_)!==41);return _++,T(),e}}function
|
|
6
|
+
`),t+=e[a].slice(r).replace(/\\"""/g,'"""');return t}function T(){for(var n=0|O.charCodeAt(_++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|O.charCodeAt(_++))if(n===35)for(;(n=O.charCodeAt(_++))!==10&&n!==13;);_--}var te=/[_A-Za-z]\w*/y,$n=new RegExp("(?:(null|true|false)|\\$("+te.source+')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|('+te.source+"))","y"),Pe=function(n){return n[n.Const=1]="Const",n[n.Var=2]="Var",n[n.Int=3]="Int",n[n.Float=4]="Float",n[n.BlockString=5]="BlockString",n[n.String=6]="String",n[n.Enum=7]="Enum",n}(Pe||{}),Di=/\\/;function Xt(n){var e,t;if($n.lastIndex=_,O.charCodeAt(_)===91){_++,T();for(var r=[];O.charCodeAt(_)!==93;)r.push(Xt(n));return _++,T(),{kind:"ListValue",values:r}}else if(O.charCodeAt(_)===123){_++,T();for(var s=[];O.charCodeAt(_)!==125;){if((e=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("ObjectField");T(),s.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Xt(n)})}return _++,T(),{kind:"ObjectValue",fields:s}}else if((t=$n.exec(O))!=null){if(_=$n.lastIndex,T(),(e=t[Pe.Const])!=null)return e==="null"?{kind:"NullValue"}:{kind:"BooleanValue",value:e==="true"};if((e=t[Pe.Var])!=null){if(n)throw F("Variable");return{kind:"Variable",name:{kind:"Name",value:e}}}else if((e=t[Pe.Int])!=null){var i;return(i=t[Pe.Float])!=null?{kind:"FloatValue",value:e+i}:{kind:"IntValue",value:e}}else{if((e=t[Pe.BlockString])!=null)return{kind:"StringValue",value:Wi(e.slice(3,-3)),block:!0};if((e=t[Pe.String])!=null)return{kind:"StringValue",value:Di.test(e)?JSON.parse(e):e.slice(1,-1),block:!1};if((e=t[Pe.Enum])!=null)return{kind:"EnumValue",value:e}}}throw F("Value")}function Lr(n){if(O.charCodeAt(_)===40){var e=[];_++,T();var t;do{if((t=ue(te))==null||(T(),O.charCodeAt(_++)!==58))throw F("Argument");T(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Xt(n)})}while(O.charCodeAt(_)!==41);return _++,T(),e}}function nt(n){if(O.charCodeAt(_)===64){var e=[],t;do{if(_++,(t=ue(te))==null)throw F("Directive");T(),e.push({kind:"Directive",name:{kind:"Name",value:t},arguments:Lr(n)})}while(O.charCodeAt(_)===64);return e}}function ji(){for(var n,e=0;O.charCodeAt(_)===91;)e++,_++,T();if((n=ue(te))==null)throw F("NamedType");T();var t={kind:"NamedType",name:{kind:"Name",value:n}};do if(O.charCodeAt(_)===33&&(_++,T(),t={kind:"NonNullType",type:t}),e){if(O.charCodeAt(_++)!==93)throw F("NamedType");T(),t={kind:"ListType",type:t}}while(e--);return t}var In=new RegExp("(?:(\\.{3})|("+te.source+"))","y"),Tn=function(n){return n[n.Spread=1]="Spread",n[n.Name=2]="Name",n}(Tn||{});function Yt(){var n=[],e,t;do if(In.lastIndex=_,(t=In.exec(O))!=null){if(_=In.lastIndex,t[Tn.Spread]!=null){T();var r=ue(te);if(r!=null&&r!=="on")T(),n.push({kind:"FragmentSpread",name:{kind:"Name",value:r},directives:nt(!1)});else{if(T(),r==="on"){if((r=ue(te))==null)throw F("NamedType");T()}var s=nt(!1);if(O.charCodeAt(_++)!==123)throw F("InlineFragment");T(),n.push({kind:"InlineFragment",typeCondition:r?{kind:"NamedType",name:{kind:"Name",value:r}}:void 0,directives:s,selectionSet:Yt()})}}else if((e=t[Tn.Name])!=null){var i=void 0;if(T(),O.charCodeAt(_)===58){if(_++,T(),i=e,(e=ue(te))==null)throw F("Field");T()}var o=Lr(!1);T();var a=nt(!1),c=void 0;O.charCodeAt(_)===123&&(_++,T(),c=Yt()),n.push({kind:"Field",alias:i?{kind:"Name",value:i}:void 0,name:{kind:"Name",value:e},arguments:o,directives:a,selectionSet:c})}}else throw F("SelectionSet");while(O.charCodeAt(_)!==125);return _++,T(),{kind:"SelectionSet",selections:n}}function Qi(){var n,e;if((n=ue(te))==null||(T(),ue(te)!=="on")||(T(),(e=ue(te))==null))throw F("FragmentDefinition");T();var t=nt(!1);if(O.charCodeAt(_++)!==123)throw F("FragmentDefinition");return T(),{kind:"FragmentDefinition",name:{kind:"Name",value:n},typeCondition:{kind:"NamedType",name:{kind:"Name",value:e}},directives:t,selectionSet:Yt()}}var Vi=/(?:query|mutation|subscription|fragment)/y;function zi(n){var e,t,r;if(n&&(T(),e=ue(te),t=function(){if(T(),O.charCodeAt(_)===40){var i=[];_++,T();var o;do{if(O.charCodeAt(_++)!==36||(o=ue(te))==null)throw F("Variable");if(T(),O.charCodeAt(_++)!==58)throw F("VariableDefinition");T();var a=ji(),c=void 0;O.charCodeAt(_)===61&&(_++,T(),c=Xt(!0)),T(),i.push({kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:o}},type:a,defaultValue:c,directives:nt(!0)})}while(O.charCodeAt(_)!==41);return _++,T(),i}}(),r=nt(!1)),O.charCodeAt(_)===123)return _++,T(),{kind:"OperationDefinition",operation:n||"query",name:e?{kind:"Name",value:e}:void 0,variableDefinitions:t,directives:r,selectionSet:Yt()}}function Ji(n,e){return _=0,function(r,s){var i,o;T();var a=[];do if((i=ue(Vi))==="fragment")T(),a.push(Qi());else if((o=zi(i))!=null)a.push(o);else throw F("Document");while(_<r.length);if(!s){var c;return{kind:"Document",definitions:a,set loc(l){c=l},get loc(){return c||(c={start:0,end:r.length,startToken:void 0,endToken:void 0,source:{body:r,name:"graphql.web",locationOffset:{line:1,column:1}}}),c}}}return{kind:"Document",definitions:a}}(O=typeof n.body=="string"?n.body:n,e&&e.noLocation)}function ie(n,e,t){for(var r="",s=0;s<n.length;s++)s&&(r+=e),r+=t(n[s]);return r}function Gi(n){return JSON.stringify(n)}function Xi(n){return`"""
|
|
7
7
|
`+n.replace(/"""/g,'\\"""')+`
|
|
8
8
|
"""`}var xe=`
|
|
9
9
|
`,j={OperationDefinition(n){var e=n.operation;return n.name&&(e+=" "+n.name.value),n.variableDefinitions&&n.variableDefinitions.length&&(n.name||(e+=" "),e+="("+ie(n.variableDefinitions,", ",j.VariableDefinition)+")"),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e!=="query"?e+" "+j.SelectionSet(n.selectionSet):j.SelectionSet(n.selectionSet)},VariableDefinition(n){var e=j.Variable(n.variable)+": "+Ne(n.type);return n.defaultValue&&(e+=" = "+Ne(n.defaultValue)),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},Field(n){var e=n.alias?n.alias.value+": "+n.name.value:n.name.value;if(n.arguments&&n.arguments.length){var t=ie(n.arguments,", ",j.Argument);e.length+t.length+2>80?e+="("+(xe+=" ")+ie(n.arguments,xe,j.Argument)+(xe=xe.slice(0,-2))+")":e+="("+t+")"}return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),n.selectionSet&&n.selectionSet.selections.length&&(e+=" "+j.SelectionSet(n.selectionSet)),e},StringValue(n){return n.block?Xi(n.value).replace(/\n/g,xe):Gi(n.value)},BooleanValue:n=>""+n.value,NullValue:n=>"null",IntValue:n=>n.value,FloatValue:n=>n.value,EnumValue:n=>n.value,Name:n=>n.value,Variable:n=>"$"+n.name.value,ListValue:n=>"["+ie(n.values,", ",Ne)+"]",ObjectValue:n=>"{"+ie(n.fields,", ",j.ObjectField)+"}",ObjectField:n=>n.name.value+": "+Ne(n.value),Document(n){return!n.definitions||!n.definitions.length?"":ie(n.definitions,`
|
|
10
10
|
|
|
11
11
|
`,Ne)},SelectionSet:n=>"{"+(xe+=" ")+ie(n.selections,xe,Ne)+(xe=xe.slice(0,-2))+"}",Argument:n=>n.name.value+": "+Ne(n.value),FragmentSpread(n){var e="..."+n.name.value;return n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e},InlineFragment(n){var e="...";return n.typeCondition&&(e+=" on "+n.typeCondition.name.value),n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+=" "+j.SelectionSet(n.selectionSet)},FragmentDefinition(n){var e="fragment "+n.name.value;return e+=" on "+n.typeCondition.name.value,n.directives&&n.directives.length&&(e+=" "+ie(n.directives," ",j.Directive)),e+" "+j.SelectionSet(n.selectionSet)},Directive(n){var e="@"+n.name.value;return n.arguments&&n.arguments.length&&(e+="("+ie(n.arguments,", ",j.Argument)+")"),e},NamedType:n=>n.name.value,ListType:n=>"["+Ne(n.type)+"]",NonNullType:n=>Ne(n.type)+"!"},Ne=n=>j[n.kind](n);function Yi(n){return xe=`
|
|
12
|
-
`,j[n.kind]?j[n.kind](n):""}var Kr=()=>{},ce=Kr;function we(n){return{tag:0,0:n}}function Et(n){return{tag:1,0:n}}var Fr=()=>typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator",Zi=n=>n;function J(n){return e=>t=>{var r=ce;e(s=>{s===0?t(0):s.tag===0?(r=s[0],t(s)):n(s[0])?t(s):r(0)})}}function Ct(n){return e=>t=>e(r=>{r===0||r.tag===0?t(r):t(Et(n(r[0])))})}function En(n){return e=>t=>{var r=[],s=ce,i=!1,o=!1;e(a=>{o||(a===0?(o=!0,r.length||t(0)):a.tag===0?s=a[0]:(i=!1,function(l){var u=ce;l(d=>{if(d===0){if(r.length){var h=r.indexOf(u);h>-1&&(r=r.slice()).splice(h,1),r.length||(o?t(0):i||(i=!0,s(0)))}}else d.tag===0?(r.push(u=d[0]),u(0)):r.length&&(t(d),u(0))})}(n(a[0])),i||(i=!0,s(0))))}),t(we(a=>{if(a===1){o||(o=!0,s(1));for(var c=0,l=r,u=r.length;c<u;c++)l[c](1);r.length=0}else{!o&&!i?(i=!0,s(0)):i=!1;for(var d=0,h=r,m=r.length;d<m;d++)h[d](0)}}))}}function eo(n){return En(Zi)(n)}function
|
|
13
|
-
`),o+=`[GraphQL] ${i[a].message}`;return o})(e.networkError,t);super(r),this.name="CombinedError",this.message=r,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var tn=(n,e)=>{for(var t=0|(e||5381),r=0,s=0|n.length;r<s;r++)t=(t<<5)+t+n.charCodeAt(r);return t},
|
|
12
|
+
`,j[n.kind]?j[n.kind](n):""}var Kr=()=>{},ce=Kr;function we(n){return{tag:0,0:n}}function Et(n){return{tag:1,0:n}}var Fr=()=>typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator",Zi=n=>n;function J(n){return e=>t=>{var r=ce;e(s=>{s===0?t(0):s.tag===0?(r=s[0],t(s)):n(s[0])?t(s):r(0)})}}function Ct(n){return e=>t=>e(r=>{r===0||r.tag===0?t(r):t(Et(n(r[0])))})}function En(n){return e=>t=>{var r=[],s=ce,i=!1,o=!1;e(a=>{o||(a===0?(o=!0,r.length||t(0)):a.tag===0?s=a[0]:(i=!1,function(l){var u=ce;l(d=>{if(d===0){if(r.length){var h=r.indexOf(u);h>-1&&(r=r.slice()).splice(h,1),r.length||(o?t(0):i||(i=!0,s(0)))}}else d.tag===0?(r.push(u=d[0]),u(0)):r.length&&(t(d),u(0))})}(n(a[0])),i||(i=!0,s(0))))}),t(we(a=>{if(a===1){o||(o=!0,s(1));for(var c=0,l=r,u=r.length;c<u;c++)l[c](1);r.length=0}else{!o&&!i?(i=!0,s(0)):i=!1;for(var d=0,h=r,m=r.length;d<m;d++)h[d](0)}}))}}function eo(n){return En(Zi)(n)}function rt(n){return eo(so(n))}function Wr(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0),n();else if(s.tag===0){var i=s[0];t(we(o=>{o===1?(r=!0,i(1),n()):i(o)}))}else t(s)})}}function Zt(n){return e=>t=>{var r=!1;e(s=>{if(!r)if(s===0)r=!0,t(0);else if(s.tag===0){var i=s[0];t(we(o=>{o===1&&(r=!0),i(o)}))}else n(s[0]),t(s)})}}function Dr(n){return e=>t=>e(r=>{r===0?t(0):r.tag===0?(t(r),n()):t(r)})}function Mt(n){var e=[],t=ce,r=!1;return s=>{e.push(s),e.length===1&&n(i=>{if(i===0){for(var o=0,a=e,c=e.length;o<c;o++)a[o](0);e.length=0}else if(i.tag===0)t=i[0];else{r=!1;for(var l=0,u=e,d=e.length;l<d;l++)u[l](i)}}),s(we(i=>{if(i===1){var o=e.indexOf(s);o>-1&&(e=e.slice()).splice(o,1),e.length||t(1)}else r||(r=!0,t(0))}))}}function jr(n){return e=>t=>{var r=ce,s=ce,i=!1,o=!1,a=!1,c=!1;e(l=>{c||(l===0?(c=!0,a||t(0)):l.tag===0?r=l[0]:(a&&(s(1),s=ce),i?i=!1:(i=!0,r(0)),function(d){a=!0,d(h=>{a&&(h===0?(a=!1,c?t(0):i||(i=!0,r(0))):h.tag===0?(o=!1,(s=h[0])(0)):(t(h),o?o=!1:s(0)))})}(n(l[0]))))}),t(we(l=>{l===1?(c||(c=!0,r(1)),a&&(a=!1,s(1))):(!c&&!i&&(i=!0,r(0)),a&&!o&&(o=!0,s(0)))}))}}function Qr(n){return e=>t=>{var r=ce,s=!1,i=0;e(o=>{s||(o===0?(s=!0,t(0)):o.tag===0?r=o[0]:i++<n?(t(o),!s&&i>=n&&(s=!0,t(0),r(1))):t(o))}),t(we(o=>{o===1&&!s?(s=!0,r(1)):o===0&&!s&&i<n&&r(0)}))}}function Cn(n){return e=>t=>{var r=ce,s=ce,i=!1;e(o=>{i||(o===0?(i=!0,s(1),t(0)):o.tag===0?(r=o[0],n(a=>{a===0||(a.tag===0?(s=a[0])(0):(i=!0,s(1),r(1),t(0)))})):t(o))}),t(we(o=>{o===1&&!i?(i=!0,r(1),s(1)):i||r(0)}))}}function to(n,e){return t=>r=>{var s=ce,i=!1;t(o=>{i||(o===0?(i=!0,r(0)):o.tag===0?(s=o[0],r(o)):n(o[0])?r(o):(i=!0,r(o),r(0),s(1)))})}}function no(n){return e=>n()(e)}function Vr(n){return e=>{var t=n[Fr()]&&n[Fr()]()||n,r=!1,s=!1,i=!1,o;e(we(async a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=await t.next()).done)r=!0,t.return&&await t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!(await t.throw(c)).done)&&e(0);else throw c}s=!1}}))}}function ro(n){return n[Symbol.asyncIterator]?Vr(n):e=>{var t=n[Symbol.iterator](),r=!1,s=!1,i=!1,o;e(we(a=>{if(a===1)r=!0,t.return&&t.return();else if(s)i=!0;else{for(i=s=!0;i&&!r;)if((o=t.next()).done)r=!0,t.return&&t.return(),e(0);else try{i=!1,e(Et(o.value))}catch(c){if(t.throw)(r=!!t.throw(c).done)&&e(0);else throw c}s=!1}}))}}var so=ro;function Mn(n){return e=>{var t=!1;e(we(r=>{r===1?t=!0:t||(t=!0,e(Et(n)),e(0))}))}}function zr(n){return e=>{var t=!1,r=n({next(s){t||e(Et(s))},complete(){t||(t=!0,e(0))}});e(we(s=>{s===1&&!t&&(t=!0,r())}))}}function Jr(){var n,e;return{source:Mt(zr(t=>(n=t.next,e=t.complete,Kr))),next(t){n&&n(t)},complete(){e&&e()}}}function en(n){return e=>{var t=ce,r=!1;return e(s=>{s===0?r=!0:s.tag===0?(t=s[0])(0):r||(n(s[0]),t(0))}),{unsubscribe(){r||(r=!0,t(1))}}}}function io(n){en(e=>{})(n)}function oo(n){return new Promise(e=>{var t=ce,r;n(s=>{s===0?Promise.resolve(r).then(e):s.tag===0?(t=s[0])(0):(r=s[0],t(0))})})}var ao=(...n)=>{for(var e=n[0],t=1,r=n.length;t<r;t++)e=n[t](e);return e},lo=n=>n&&typeof n.message=="string"&&(n.extensions||n.name==="GraphQLError")?n:typeof n=="object"&&typeof n.message=="string"?new _n(n.message,n.nodes,n.source,n.positions,n.path,n,n.extensions||{}):new _n(n);class On extends Error{constructor(e){var t=(e.graphQLErrors||[]).map(lo),r=((s,i)=>{var o="";if(s)return`[Network] ${s.message}`;if(i)for(var a=0,c=i.length;a<c;a++)o&&(o+=`
|
|
13
|
+
`),o+=`[GraphQL] ${i[a].message}`;return o})(e.networkError,t);super(r),this.name="CombinedError",this.message=r,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var tn=(n,e)=>{for(var t=0|(e||5381),r=0,s=0|n.length;r<s;r++)t=(t<<5)+t+n.charCodeAt(r);return t},Je=new Set,Gr=new WeakMap,st=(n,e)=>{if(n===null||Je.has(n))return"null";if(typeof n!="object")return JSON.stringify(n)||"";if(n.toJSON)return st(n.toJSON(),e);if(Array.isArray(n)){for(var t="[",r=0,s=n.length;r<s;r++)t.length>1&&(t+=","),t+=st(n[r],e)||"null";return t+="]"}else if(!e&&(rn!==it&&n instanceof rn||sn!==it&&n instanceof sn))return"null";var i=Object.keys(n).sort();if(!i.length&&n.constructor&&Object.getPrototypeOf(n).constructor!==Object.prototype.constructor){var o=Gr.get(n)||Math.random().toString(36).slice(2);return Gr.set(n,o),st({__key:o},e)}Je.add(n);for(var a="{",c=0,l=i.length;c<l;c++){var u=st(n[i[c]],e);u&&(a.length>1&&(a+=","),a+=st(i[c],e)+":"+u)}return Je.delete(n),a+="}"},Nn=(n,e,t)=>{if(!(t==null||typeof t!="object"||t.toJSON||Je.has(t)))if(Array.isArray(t))for(var r=0,s=t.length;r<s;r++)Nn(n,`${e}.${r}`,t[r]);else if(t instanceof rn||t instanceof sn)n.set(e,t);else{Je.add(t);for(var i in t)Nn(n,`${e}.${i}`,t[i])}},nn=(n,e)=>(Je.clear(),st(n,e||!1));class it{}var rn=typeof File<"u"?File:it,sn=typeof Blob<"u"?Blob:it,uo=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,co=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,ho=(n,e)=>e%2==0?n.replace(co,`
|
|
14
14
|
`):n,Xr=n=>n.split(uo).map(ho).join("").trim(),Yr=new Map,on=new Map,an=n=>{var e;return typeof n=="string"?e=Xr(n):n.loc&&on.get(n.__key)===n?e=n.loc.source.body:(e=Yr.get(n)||Xr(Yi(n)),Yr.set(n,e)),typeof n!="string"&&!n.loc&&(n.loc={start:0,end:e.length,source:{body:e,name:"gql",locationOffset:{line:1,column:1}}}),e},Zr=n=>{var e;if(n.documentId)e=tn(n.documentId);else if(e=tn(an(n)),n.definitions){var t=es(n);t&&(e=tn(`
|
|
15
|
-
# ${t}`,e))}return e},ln=n=>{var e,t;return typeof n=="string"?(e=Zr(n),t=on.get(e)||Ji(n,{noLocation:!0})):(e=n.__key||Zr(n),t=on.get(e)||n),t.loc||an(t),t.__key=e,on.set(e,t),t},Rn=(n,e,t)=>{var r=e||{},s=ln(n),i=nn(r,!0),o=s.__key;return i!=="{}"&&(o=tn(i,o)),{key:o,query:s,variables:r,extensions:t}},es=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},fo=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.operation}},un=(n,e,t)=>{if(!("data"in e||"errors"in e&&Array.isArray(e.errors)))throw new Error("No Content");var r=n.kind==="subscription";return{operation:n,data:e.data,error:Array.isArray(e.errors)?new On({graphQLErrors:e.errors,response:t}):void 0,extensions:e.extensions?{...e.extensions}:void 0,hasNext:e.hasNext==null?r:e.hasNext,stale:!1}},cn=(n,e)=>{if(typeof n=="object"&&n!=null){if(Array.isArray(n)){n=[...n];for(var t=0,r=e.length;t<r;t++)n[t]=cn(n[t],e[t]);return n}if(!n.constructor||n.constructor===Object){n={...n};for(var s in e)n[s]=cn(n[s],e[s]);return n}}return e},ts=(n,e,t,r)=>{var s=n.error?n.error.graphQLErrors:[],i=!!n.extensions||!!(e.payload||e).extensions,o={...n.extensions,...(e.payload||e).extensions},a=e.incremental;"path"in e&&(a=[e]);var c={data:n.data};if(a)for(var l=function(){var h=a[u];Array.isArray(h.errors)&&s.push(...h.errors),h.extensions&&(Object.assign(o,h.extensions),i=!0);var m="data",y=c,g=[];if(h.path)g=h.path;else if(r){var w=r.find(b=>b.id===h.id);h.subPath?g=[...w.path,...h.subPath]:g=w.path}for(var v=0,A=g.length;v<A;m=g[v++])y=y[m]=Array.isArray(y[m])?[...y[m]]:{...y[m]};if(h.items)for(var S=+m>=0?m:0,p=0,k=h.items.length;p<k;p++)y[S+p]=cn(y[S+p],h.items[p]);else h.data!==void 0&&(y[m]=cn(y[m],h.data))},u=0,d=a.length;u<d;u++)l();else c.data=(e.payload||e).data||n.data,s=e.errors||e.payload&&e.payload.errors||s;return{operation:n.operation,data:c.data,error:s.length?new On({graphQLErrors:s,response:t}):void 0,extensions:i?o:void 0,hasNext:e.hasNext!=null?e.hasNext:n.hasNext,stale:!1}},ns=(n,e,t)=>({operation:n,data:void 0,error:new On({networkError:e,response:t}),extensions:void 0,hasNext:!1,stale:!1});function rs(n){var e={query:void 0,documentId:void 0,operationName:es(n.query),variables:n.variables||void 0,extensions:n.extensions};return"documentId"in n.query&&n.query.documentId&&(!n.query.definitions||!n.query.definitions.length)?e.documentId=n.query.documentId:(!n.extensions||!n.extensions.persistedQuery||n.extensions.persistedQuery.miss)&&(e.query=an(n.query)),e}var po=(n,e)=>{var t=n.kind==="query"&&n.context.preferGetMethod;if(!t||!e)return n.context.url;var r=yo(n.context.url);for(var s in e){var i=e[s];i&&r[1].set(s,typeof i=="object"?nn(i):i)}var o=r.join("?");return o.length>2047&&t!=="force"?(n.context.preferGetMethod=!1,n.context.url):o},yo=n=>{var e=n.indexOf("?");return e>-1?[n.slice(0,e),new URLSearchParams(n.slice(e+1))]:[n,new URLSearchParams]},mo=(n,e)=>{if(e&&!(n.kind==="query"&&n.context.preferGetMethod)){var t=nn(e),r=(a=>{var c=new Map;return(rn!==
|
|
15
|
+
# ${t}`,e))}return e},ln=n=>{var e,t;return typeof n=="string"?(e=Zr(n),t=on.get(e)||Ji(n,{noLocation:!0})):(e=n.__key||Zr(n),t=on.get(e)||n),t.loc||an(t),t.__key=e,on.set(e,t),t},Rn=(n,e,t)=>{var r=e||{},s=ln(n),i=nn(r,!0),o=s.__key;return i!=="{}"&&(o=tn(i,o)),{key:o,query:s,variables:r,extensions:t}},es=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},fo=n=>{for(var e=0,t=n.definitions.length;e<t;e++){var r=n.definitions[e];if(r.kind===Be.OPERATION_DEFINITION)return r.operation}},un=(n,e,t)=>{if(!("data"in e||"errors"in e&&Array.isArray(e.errors)))throw new Error("No Content");var r=n.kind==="subscription";return{operation:n,data:e.data,error:Array.isArray(e.errors)?new On({graphQLErrors:e.errors,response:t}):void 0,extensions:e.extensions?{...e.extensions}:void 0,hasNext:e.hasNext==null?r:e.hasNext,stale:!1}},cn=(n,e)=>{if(typeof n=="object"&&n!=null){if(Array.isArray(n)){n=[...n];for(var t=0,r=e.length;t<r;t++)n[t]=cn(n[t],e[t]);return n}if(!n.constructor||n.constructor===Object){n={...n};for(var s in e)n[s]=cn(n[s],e[s]);return n}}return e},ts=(n,e,t,r)=>{var s=n.error?n.error.graphQLErrors:[],i=!!n.extensions||!!(e.payload||e).extensions,o={...n.extensions,...(e.payload||e).extensions},a=e.incremental;"path"in e&&(a=[e]);var c={data:n.data};if(a)for(var l=function(){var h=a[u];Array.isArray(h.errors)&&s.push(...h.errors),h.extensions&&(Object.assign(o,h.extensions),i=!0);var m="data",y=c,g=[];if(h.path)g=h.path;else if(r){var w=r.find(b=>b.id===h.id);h.subPath?g=[...w.path,...h.subPath]:g=w.path}for(var v=0,A=g.length;v<A;m=g[v++])y=y[m]=Array.isArray(y[m])?[...y[m]]:{...y[m]};if(h.items)for(var S=+m>=0?m:0,p=0,k=h.items.length;p<k;p++)y[S+p]=cn(y[S+p],h.items[p]);else h.data!==void 0&&(y[m]=cn(y[m],h.data))},u=0,d=a.length;u<d;u++)l();else c.data=(e.payload||e).data||n.data,s=e.errors||e.payload&&e.payload.errors||s;return{operation:n.operation,data:c.data,error:s.length?new On({graphQLErrors:s,response:t}):void 0,extensions:i?o:void 0,hasNext:e.hasNext!=null?e.hasNext:n.hasNext,stale:!1}},ns=(n,e,t)=>({operation:n,data:void 0,error:new On({networkError:e,response:t}),extensions:void 0,hasNext:!1,stale:!1});function rs(n){var e={query:void 0,documentId:void 0,operationName:es(n.query),variables:n.variables||void 0,extensions:n.extensions};return"documentId"in n.query&&n.query.documentId&&(!n.query.definitions||!n.query.definitions.length)?e.documentId=n.query.documentId:(!n.extensions||!n.extensions.persistedQuery||n.extensions.persistedQuery.miss)&&(e.query=an(n.query)),e}var po=(n,e)=>{var t=n.kind==="query"&&n.context.preferGetMethod;if(!t||!e)return n.context.url;var r=yo(n.context.url);for(var s in e){var i=e[s];i&&r[1].set(s,typeof i=="object"?nn(i):i)}var o=r.join("?");return o.length>2047&&t!=="force"?(n.context.preferGetMethod=!1,n.context.url):o},yo=n=>{var e=n.indexOf("?");return e>-1?[n.slice(0,e),new URLSearchParams(n.slice(e+1))]:[n,new URLSearchParams]},mo=(n,e)=>{if(e&&!(n.kind==="query"&&n.context.preferGetMethod)){var t=nn(e),r=(a=>{var c=new Map;return(rn!==it||sn!==it)&&(Je.clear(),Nn(c,"variables",a)),c})(e.variables);if(r.size){var s=new FormData;s.append("operations",t),s.append("map",nn({...[...r.keys()].map(a=>[a])}));var i=0;for(var o of r.values())s.append(""+i++,o);return s}return t}},go=(n,e)=>{var t={accept:n.kind==="subscription"?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},r=(typeof n.context.fetchOptions=="function"?n.context.fetchOptions():n.context.fetchOptions)||{};if(r.headers)if((o=>"has"in o&&!Object.keys(o).length)(r.headers))r.headers.forEach((o,a)=>{t[a]=o});else if(Array.isArray(r.headers))r.headers.forEach((o,a)=>{Array.isArray(o)?t[o[0]]?t[o[0]]=`${t[o[0]]},${o[1]}`:t[o[0]]=o[1]:t[a]=o});else for(var s in r.headers)t[s.toLowerCase()]=r.headers[s];var i=mo(n,e);return typeof i=="string"&&!t["content-type"]&&(t["content-type"]="application/json"),{...r,method:i?"POST":"GET",body:i,headers:t}},wo=typeof TextDecoder<"u"?new TextDecoder:null,bo=/boundary="?([^=";]+)"?/i,vo=/data: ?([^\n]+)/,ss=n=>n.constructor.name==="Buffer"?n.toString():wo.decode(n);async function*is(n){if(n.body[Symbol.asyncIterator])for await(var e of n.body)yield ss(e);else{var t=n.body.getReader(),r;try{for(;!(r=await t.read()).done;)yield ss(r.value)}finally{t.cancel()}}}async function*os(n,e){var t="",r;for await(var s of n)for(t+=s;(r=t.indexOf(e))>-1;)yield t.slice(0,r),t=t.slice(r+e.length)}async function*ko(n,e,t){var r=!0,s=null,i;try{yield await Promise.resolve();var o=(i=await(n.context.fetch||fetch)(e,t)).headers.get("Content-Type")||"",a;/multipart\/mixed/i.test(o)?a=async function*(d,h){var m=d.match(bo),y="--"+(m?m[1]:"-"),g=!0,w;for await(var v of os(is(h),`\r
|
|
16
16
|
`+y)){if(g){g=!1;var A=v.indexOf(y);if(A>-1)v=v.slice(A+y.length);else continue}try{yield w=JSON.parse(v.slice(v.indexOf(`\r
|
|
17
17
|
\r
|
|
18
18
|
`)+4))}catch(S){if(!w)throw S}if(w&&w.hasNext===!1)break}w&&w.hasNext!==!1&&(yield{hasNext:!1})}(o,i):/text\/event-stream/i.test(o)?a=async function*(d){var h;for await(var m of os(is(d),`
|
|
19
19
|
|
|
20
|
-
`)){var y=m.match(vo);if(y){var g=y[1];try{yield h=JSON.parse(g)}catch(w){if(!h)throw w}if(h&&h.hasNext===!1)break}}h&&h.hasNext!==!1&&(yield{hasNext:!1})}(i):/text\//i.test(o)?a=async function*(d){var h=await d.text();try{var m=JSON.parse(h);"production"!==!0&&console.warn('Found response with content-type "text/plain" but it had a valid "application/json" response.'),yield m}catch{throw new Error(h)}}(i):a=async function*(d){yield JSON.parse(await d.text())}(i);var c;for await(var l of a)l.pending&&!s?c=l.pending:l.pending&&(c=[...c,...l.pending]),s=s?ts(s,l,i,c):un(n,l,i),r=!1,yield s,r=!0;s||(yield s=un(n,{},i))}catch(u){if(!r)throw u;yield ns(n,i&&(i.status<200||i.status>=300)&&i.statusText?new Error(i.statusText):u,i)}}function So(n,e,t){var r;return typeof AbortController<"u"&&(t.signal=(r=new AbortController).signal),Wr(()=>{r&&r.abort()})(J(s=>!!s)(Vr(ko(n,e,t))))}var Un=(n,e)=>{if(Array.isArray(n))for(var t=0,r=n.length;t<r;t++)Un(n[t],e);else if(typeof n=="object"&&n!==null)for(var s in n)s==="__typename"&&typeof n[s]=="string"?e.add(n[s]):Un(n[s],e);return e},qn=n=>{if("definitions"in n){for(var e=[],t=0,r=n.definitions.length;t<r;t++){var s=qn(n.definitions[t]);e.push(s)}return{...n,definitions:e}}if("directives"in n&&n.directives&&n.directives.length){for(var i=[],o={},a=0,c=n.directives.length;a<c;a++){var l=n.directives[a],u=l.name.value;u[0]!=="_"?i.push(l):u=u.slice(1),o[u]=l}n={...n,directives:i,_directives:o}}if("selectionSet"in n){var d=[],h=n.kind===Be.OPERATION_DEFINITION;if(n.selectionSet){for(var m=0,y=n.selectionSet.selections.length;m<y;m++){var g=n.selectionSet.selections[m];h=h||g.kind===Be.FIELD&&g.name.value==="__typename"&&!g.alias;var w=qn(g);d.push(w)}return h||d.push({kind:Be.FIELD,name:{kind:Be.NAME,value:"__typename"},_generated:!0}),{...n,selectionSet:{...n.selectionSet,selections:d}}}}return n},as=new Map,Ao=n=>{var e=ln(n),t=as.get(e.__key);return t||(as.set(e.__key,t=qn(e)),Object.defineProperty(t,"__key",{value:e.__key,enumerable:!1})),t};function ls(n){var e=t=>n(t);return e.toPromise=()=>oo(Qr(1)(J(t=>!t.stale&&!t.hasNext)(e))),e.then=(t,r)=>e.toPromise().then(t,r),e.subscribe=t=>en(t)(e),e}function it(n,e,t){return{...e,kind:n,context:e.context?{...e.context,...t}:t||e.context}}var us=(n,e)=>it(n.kind,n,{meta:{...n.context.meta,...e}}),xo=()=>{};function Q(n){for(var e=new Map,t=[],r=[],s=Array.isArray(n)?n[0]:n||"",i=1;i<arguments.length;i++){var o=arguments[i];o&&o.definitions?r.push(o):s+=o,s+=arguments[0][i]}r.unshift(ln(s));for(var a=0;a<r.length;a++)for(var c=0;c<r[a].definitions.length;c++){var l=r[a].definitions[c];if(l.kind===Be.FRAGMENT_DEFINITION){var u=l.name.value,d=an(l);e.has(u)?e.get(u)!==d&&console.warn("[WARNING: Duplicate Fragment] A fragment with name `"+u+"` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."):(e.set(u,d),t.push(l))}else t.push(l)}return ln({kind:Be.DOCUMENT,definitions:t})}var Hn=({kind:n})=>n!=="mutation"&&n!=="query",_o=n=>{var e=Ao(n.query);if(e!==n.query){var t=it(n.kind,n);return t.query=e,t}else return n},$o=({forward:n,client:e,dispatchDebug:t})=>{var r=new Map,s=new Map,i=o=>o.kind==="query"&&o.context.requestPolicy!=="network-only"&&(o.context.requestPolicy==="cache-only"||r.has(o.key));return o=>{var a=Ct(l=>{var u=r.get(l.key);t({operation:l,...u?{type:"cacheHit",message:"The result was successfully retried from the cache"}:{type:"cacheMiss",message:"The result could not be retrieved from the cache"},source:"cacheExchange"});var d=u||un(l,{data:null});return d={...d,operation:us(l,{cacheOutcome:u?"hit":"miss"})},l.context.requestPolicy==="cache-and-network"&&(d.stale=!0,cs(e,l)),d})(J(l=>!Hn(l)&&i(l))(o)),c=Zt(l=>{var{operation:u}=l;if(u){var d=u.context.additionalTypenames||[];if(l.operation.kind!=="subscription"&&(d=(k=>[...Un(k,new Set)])(l.data).concat(d)),l.operation.kind==="mutation"||l.operation.kind==="subscription"){var h=new Set;t({type:"cacheInvalidation",message:`The following typenames have been invalidated: ${d}`,operation:u,data:{typenames:d,response:l},source:"cacheExchange"});for(var m=0;m<d.length;m++){var y=d[m],g=s.get(y);g||s.set(y,g=new Set);for(var w of g.values())h.add(w);g.clear()}for(var v of h.values())r.has(v)&&(u=r.get(v).operation,r.delete(v),cs(e,u))}else if(u.kind==="query"&&l.data){r.set(u.key,l);for(var A=0;A<d.length;A++){var S=d[A],p=s.get(S);p||s.set(S,p=new Set),p.add(u.key)}}}})(n(J(l=>l.kind!=="query"||l.context.requestPolicy!=="cache-only")(Ct(l=>us(l,{cacheOutcome:"miss"}))(nt([Ct(_o)(J(l=>!Hn(l)&&!i(l))(o)),J(l=>Hn(l))(o)])))));return nt([a,c])}},cs=(n,e)=>n.reexecuteOperation(it(e.kind,e,{requestPolicy:"network-only"})),Io=({forwardSubscription:n,enableAllOperations:e,isSubscriptionOperation:t})=>({client:r,forward:s})=>{var i=t||(o=>o.kind==="subscription"||!!e&&(o.kind==="query"||o.kind==="mutation"));return o=>{var a=En(l=>{var{key:u}=l,d=J(h=>h.kind==="teardown"&&h.key===u)(o);return Cn(d)((h=>{var m=n(rs(h),h);return zr(y=>{var g=!1,w,v;function A(S){y.next(v=v?ts(v,S):un(h,S))}return Promise.resolve().then(()=>{g||(w=m.subscribe({next:A,error(S){Array.isArray(S)?A({errors:S}):y.next(ns(h,S)),y.complete()},complete(){g||(g=!0,h.kind==="subscription"&&r.reexecuteOperation(it("teardown",h,h.context)),v&&v.hasNext&&A({hasNext:!1}),y.complete())}}))}),()=>{g=!0,w&&w.unsubscribe()}})})(l))})(J(l=>l.kind!=="teardown"&&i(l))(o)),c=s(J(l=>l.kind==="teardown"||!i(l))(o));return nt([a,c])}},To=({forward:n,dispatchDebug:e})=>t=>{var r=En(i=>{var o=rs(i),a=po(i,o),c=go(i,o);e({type:"fetchRequest",message:"A fetch request is being executed.",operation:i,data:{url:a,fetchOptions:c},source:"fetchExchange"});var l=Cn(J(u=>u.kind==="teardown"&&u.key===i.key)(t))(So(i,a,c));return Zt(u=>{var d=u.data?void 0:u.error;e({type:d?"fetchError":"fetchSuccess",message:`A ${d?"failed":"successful"} fetch response has been returned.`,operation:i,data:{url:a,fetchOptions:c,value:d||u},source:"fetchExchange"})})(l)})(J(i=>i.kind!=="teardown"&&(i.kind!=="subscription"||!!i.context.fetchSubscriptions))(t)),s=n(J(i=>i.kind==="teardown"||i.kind==="subscription"&&!i.context.fetchSubscriptions)(t));return nt([r,s])},Eo=n=>({client:e,forward:t,dispatchDebug:r})=>n.reduceRight((s,i)=>{var o=!1;return i({client:e,forward(a){{if(o)throw new Error("forward() must only be called once in each Exchange.");o=!0}return Mt(s(Mt(a)))},dispatchDebug(a){r({timestamp:Date.now(),source:i.name,...a})}})},t),Co=({dispatchDebug:n})=>e=>(e=Zt(t=>{if(t.kind!=="teardown"&&"production"!==!0){var r=`No exchange has handled operations of kind "${t.kind}". Check whether you've added an exchange responsible for these operations.`;n({type:"fallbackCatch",message:r,operation:t,source:"fallbackExchange"}),console.warn(r)}})(e),J(t=>!1)(e)),Mo=function n(e){if(!e.url)throw new Error("You are creating an urql-client without a url.");var t=0,r=new Map,s=new Map,i=new Set,o=[],a={url:e.url,fetchSubscriptions:e.fetchSubscriptions,fetchOptions:e.fetchOptions,fetch:e.fetch,preferGetMethod:e.preferGetMethod,requestPolicy:e.requestPolicy||"cache-first"},c=Jr();function l(p){(p.kind==="mutation"||p.kind==="teardown"||!i.has(p.key))&&(p.kind==="teardown"?i.delete(p.key):p.kind!=="mutation"&&i.add(p.key),c.next(p))}var u=!1;function d(p){if(p&&l(p),!u){for(u=!0;u&&(p=o.shift());)l(p);u=!1}}var h=p=>{var k=Cn(J(b=>b.kind==="teardown"&&b.key===p.key)(c.source))(J(b=>b.operation.kind===p.kind&&b.operation.key===p.key&&(!b.operation.context._instance||b.operation.context._instance===p.context._instance))(S));return p.kind!=="query"?k=to(b=>!!b.hasNext)(k):k=jr(b=>{var I=Mn(b);return b.stale||b.hasNext?I:nt([I,Ct(()=>(b.stale=!0,b))(Qr(1)(J(H=>H.key===p.key)(c.source)))])})(k),p.kind!=="mutation"?k=Wr(()=>{i.delete(p.key),r.delete(p.key),s.delete(p.key),u=!1;for(var b=o.length-1;b>=0;b--)o[b].key===p.key&&o.splice(b,1);l(it("teardown",p,p.context))})(Zt(b=>{if(b.stale)if(!b.hasNext)i.delete(p.key);else for(var I=0;I<o.length;I++){var H=o[I];if(H.key===b.operation.key){i.delete(H.key);break}}else b.hasNext||i.delete(p.key);r.set(p.key,b)})(k)):k=Dr(()=>{l(p)})(k),Mt(k)},m=this instanceof n?this:Object.create(n.prototype),y=Object.assign(m,{suspense:!!e.suspense,operations$:c.source,reexecuteOperation(p){if(p.kind==="teardown")d(p);else if(p.kind==="mutation")o.push(p),Promise.resolve().then(d);else if(s.has(p.key)){for(var k=!1,b=0;b<o.length;b++)o[b].key===p.key&&(o[b]=p,k=!0);k||i.has(p.key)&&p.context.requestPolicy!=="network-only"?(i.delete(p.key),Promise.resolve().then(d)):(o.push(p),Promise.resolve().then(d))}},createRequestOperation(p,k,b){b||(b={});var I;if(p!=="teardown"&&(I=fo(k.query))!==p)throw new Error(`Expected operation of type "${p}" but found "${I}"`);return it(p,k,{_instance:p==="mutation"?t=t+1|0:void 0,...a,...b,requestPolicy:b.requestPolicy||a.requestPolicy,suspense:b.suspense||b.suspense!==!1&&y.suspense})},executeRequestOperation(p){return p.kind==="mutation"?ls(h(p)):ls(no(()=>{var k=s.get(p.key);k||s.set(p.key,k=h(p)),k=Dr(()=>{d(p)})(k);var b=r.get(p.key);return p.kind==="query"&&b&&(b.stale||b.hasNext)?jr(Mn)(nt([k,J(I=>I===r.get(p.key))(Mn(b))])):k}))},executeQuery(p,k){var b=y.createRequestOperation("query",p,k);return y.executeRequestOperation(b)},executeSubscription(p,k){var b=y.createRequestOperation("subscription",p,k);return y.executeRequestOperation(b)},executeMutation(p,k){var b=y.createRequestOperation("mutation",p,k);return y.executeRequestOperation(b)},readQuery(p,k,b){var I=null;return en(H=>{I=H})(y.query(p,k,b)).unsubscribe(),I},query:(p,k,b)=>y.executeQuery(Rn(p,k),b),subscription:(p,k,b)=>y.executeSubscription(Rn(p,k),b),mutation:(p,k,b)=>y.executeMutation(Rn(p,k),b)}),g=xo;{var{next:w,source:v}=Jr();y.subscribeToDebugTarget=p=>en(p)(v),g=w}var A=Eo(e.exchanges),S=Mt(A({client:y,dispatchDebug:g,forward:Co({dispatchDebug:g})})(c.source));return io(S),y},Oo=Mo;class No extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($bundle: String!) {
|
|
20
|
+
`)){var y=m.match(vo);if(y){var g=y[1];try{yield h=JSON.parse(g)}catch(w){if(!h)throw w}if(h&&h.hasNext===!1)break}}h&&h.hasNext!==!1&&(yield{hasNext:!1})}(i):/text\//i.test(o)?a=async function*(d){var h=await d.text();try{var m=JSON.parse(h);"production"!==!0&&console.warn('Found response with content-type "text/plain" but it had a valid "application/json" response.'),yield m}catch{throw new Error(h)}}(i):a=async function*(d){yield JSON.parse(await d.text())}(i);var c;for await(var l of a)l.pending&&!s?c=l.pending:l.pending&&(c=[...c,...l.pending]),s=s?ts(s,l,i,c):un(n,l,i),r=!1,yield s,r=!0;s||(yield s=un(n,{},i))}catch(u){if(!r)throw u;yield ns(n,i&&(i.status<200||i.status>=300)&&i.statusText?new Error(i.statusText):u,i)}}function So(n,e,t){var r;return typeof AbortController<"u"&&(t.signal=(r=new AbortController).signal),Wr(()=>{r&&r.abort()})(J(s=>!!s)(Vr(ko(n,e,t))))}var Un=(n,e)=>{if(Array.isArray(n))for(var t=0,r=n.length;t<r;t++)Un(n[t],e);else if(typeof n=="object"&&n!==null)for(var s in n)s==="__typename"&&typeof n[s]=="string"?e.add(n[s]):Un(n[s],e);return e},qn=n=>{if("definitions"in n){for(var e=[],t=0,r=n.definitions.length;t<r;t++){var s=qn(n.definitions[t]);e.push(s)}return{...n,definitions:e}}if("directives"in n&&n.directives&&n.directives.length){for(var i=[],o={},a=0,c=n.directives.length;a<c;a++){var l=n.directives[a],u=l.name.value;u[0]!=="_"?i.push(l):u=u.slice(1),o[u]=l}n={...n,directives:i,_directives:o}}if("selectionSet"in n){var d=[],h=n.kind===Be.OPERATION_DEFINITION;if(n.selectionSet){for(var m=0,y=n.selectionSet.selections.length;m<y;m++){var g=n.selectionSet.selections[m];h=h||g.kind===Be.FIELD&&g.name.value==="__typename"&&!g.alias;var w=qn(g);d.push(w)}return h||d.push({kind:Be.FIELD,name:{kind:Be.NAME,value:"__typename"},_generated:!0}),{...n,selectionSet:{...n.selectionSet,selections:d}}}}return n},as=new Map,Ao=n=>{var e=ln(n),t=as.get(e.__key);return t||(as.set(e.__key,t=qn(e)),Object.defineProperty(t,"__key",{value:e.__key,enumerable:!1})),t};function ls(n){var e=t=>n(t);return e.toPromise=()=>oo(Qr(1)(J(t=>!t.stale&&!t.hasNext)(e))),e.then=(t,r)=>e.toPromise().then(t,r),e.subscribe=t=>en(t)(e),e}function ot(n,e,t){return{...e,kind:n,context:e.context?{...e.context,...t}:t||e.context}}var us=(n,e)=>ot(n.kind,n,{meta:{...n.context.meta,...e}}),xo=()=>{};function Q(n){for(var e=new Map,t=[],r=[],s=Array.isArray(n)?n[0]:n||"",i=1;i<arguments.length;i++){var o=arguments[i];o&&o.definitions?r.push(o):s+=o,s+=arguments[0][i]}r.unshift(ln(s));for(var a=0;a<r.length;a++)for(var c=0;c<r[a].definitions.length;c++){var l=r[a].definitions[c];if(l.kind===Be.FRAGMENT_DEFINITION){var u=l.name.value,d=an(l);e.has(u)?e.get(u)!==d&&console.warn("[WARNING: Duplicate Fragment] A fragment with name `"+u+"` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."):(e.set(u,d),t.push(l))}else t.push(l)}return ln({kind:Be.DOCUMENT,definitions:t})}var Hn=({kind:n})=>n!=="mutation"&&n!=="query",_o=n=>{var e=Ao(n.query);if(e!==n.query){var t=ot(n.kind,n);return t.query=e,t}else return n},$o=({forward:n,client:e,dispatchDebug:t})=>{var r=new Map,s=new Map,i=o=>o.kind==="query"&&o.context.requestPolicy!=="network-only"&&(o.context.requestPolicy==="cache-only"||r.has(o.key));return o=>{var a=Ct(l=>{var u=r.get(l.key);t({operation:l,...u?{type:"cacheHit",message:"The result was successfully retried from the cache"}:{type:"cacheMiss",message:"The result could not be retrieved from the cache"},source:"cacheExchange"});var d=u||un(l,{data:null});return d={...d,operation:us(l,{cacheOutcome:u?"hit":"miss"})},l.context.requestPolicy==="cache-and-network"&&(d.stale=!0,cs(e,l)),d})(J(l=>!Hn(l)&&i(l))(o)),c=Zt(l=>{var{operation:u}=l;if(u){var d=u.context.additionalTypenames||[];if(l.operation.kind!=="subscription"&&(d=(k=>[...Un(k,new Set)])(l.data).concat(d)),l.operation.kind==="mutation"||l.operation.kind==="subscription"){var h=new Set;t({type:"cacheInvalidation",message:`The following typenames have been invalidated: ${d}`,operation:u,data:{typenames:d,response:l},source:"cacheExchange"});for(var m=0;m<d.length;m++){var y=d[m],g=s.get(y);g||s.set(y,g=new Set);for(var w of g.values())h.add(w);g.clear()}for(var v of h.values())r.has(v)&&(u=r.get(v).operation,r.delete(v),cs(e,u))}else if(u.kind==="query"&&l.data){r.set(u.key,l);for(var A=0;A<d.length;A++){var S=d[A],p=s.get(S);p||s.set(S,p=new Set),p.add(u.key)}}}})(n(J(l=>l.kind!=="query"||l.context.requestPolicy!=="cache-only")(Ct(l=>us(l,{cacheOutcome:"miss"}))(rt([Ct(_o)(J(l=>!Hn(l)&&!i(l))(o)),J(l=>Hn(l))(o)])))));return rt([a,c])}},cs=(n,e)=>n.reexecuteOperation(ot(e.kind,e,{requestPolicy:"network-only"})),Io=({forwardSubscription:n,enableAllOperations:e,isSubscriptionOperation:t})=>({client:r,forward:s})=>{var i=t||(o=>o.kind==="subscription"||!!e&&(o.kind==="query"||o.kind==="mutation"));return o=>{var a=En(l=>{var{key:u}=l,d=J(h=>h.kind==="teardown"&&h.key===u)(o);return Cn(d)((h=>{var m=n(rs(h),h);return zr(y=>{var g=!1,w,v;function A(S){y.next(v=v?ts(v,S):un(h,S))}return Promise.resolve().then(()=>{g||(w=m.subscribe({next:A,error(S){Array.isArray(S)?A({errors:S}):y.next(ns(h,S)),y.complete()},complete(){g||(g=!0,h.kind==="subscription"&&r.reexecuteOperation(ot("teardown",h,h.context)),v&&v.hasNext&&A({hasNext:!1}),y.complete())}}))}),()=>{g=!0,w&&w.unsubscribe()}})})(l))})(J(l=>l.kind!=="teardown"&&i(l))(o)),c=s(J(l=>l.kind==="teardown"||!i(l))(o));return rt([a,c])}},To=({forward:n,dispatchDebug:e})=>t=>{var r=En(i=>{var o=rs(i),a=po(i,o),c=go(i,o);e({type:"fetchRequest",message:"A fetch request is being executed.",operation:i,data:{url:a,fetchOptions:c},source:"fetchExchange"});var l=Cn(J(u=>u.kind==="teardown"&&u.key===i.key)(t))(So(i,a,c));return Zt(u=>{var d=u.data?void 0:u.error;e({type:d?"fetchError":"fetchSuccess",message:`A ${d?"failed":"successful"} fetch response has been returned.`,operation:i,data:{url:a,fetchOptions:c,value:d||u},source:"fetchExchange"})})(l)})(J(i=>i.kind!=="teardown"&&(i.kind!=="subscription"||!!i.context.fetchSubscriptions))(t)),s=n(J(i=>i.kind==="teardown"||i.kind==="subscription"&&!i.context.fetchSubscriptions)(t));return rt([r,s])},Eo=n=>({client:e,forward:t,dispatchDebug:r})=>n.reduceRight((s,i)=>{var o=!1;return i({client:e,forward(a){{if(o)throw new Error("forward() must only be called once in each Exchange.");o=!0}return Mt(s(Mt(a)))},dispatchDebug(a){r({timestamp:Date.now(),source:i.name,...a})}})},t),Co=({dispatchDebug:n})=>e=>(e=Zt(t=>{if(t.kind!=="teardown"&&"production"!==!0){var r=`No exchange has handled operations of kind "${t.kind}". Check whether you've added an exchange responsible for these operations.`;n({type:"fallbackCatch",message:r,operation:t,source:"fallbackExchange"}),console.warn(r)}})(e),J(t=>!1)(e)),Mo=function n(e){if(!e.url)throw new Error("You are creating an urql-client without a url.");var t=0,r=new Map,s=new Map,i=new Set,o=[],a={url:e.url,fetchSubscriptions:e.fetchSubscriptions,fetchOptions:e.fetchOptions,fetch:e.fetch,preferGetMethod:e.preferGetMethod,requestPolicy:e.requestPolicy||"cache-first"},c=Jr();function l(p){(p.kind==="mutation"||p.kind==="teardown"||!i.has(p.key))&&(p.kind==="teardown"?i.delete(p.key):p.kind!=="mutation"&&i.add(p.key),c.next(p))}var u=!1;function d(p){if(p&&l(p),!u){for(u=!0;u&&(p=o.shift());)l(p);u=!1}}var h=p=>{var k=Cn(J(b=>b.kind==="teardown"&&b.key===p.key)(c.source))(J(b=>b.operation.kind===p.kind&&b.operation.key===p.key&&(!b.operation.context._instance||b.operation.context._instance===p.context._instance))(S));return p.kind!=="query"?k=to(b=>!!b.hasNext)(k):k=jr(b=>{var I=Mn(b);return b.stale||b.hasNext?I:rt([I,Ct(()=>(b.stale=!0,b))(Qr(1)(J(H=>H.key===p.key)(c.source)))])})(k),p.kind!=="mutation"?k=Wr(()=>{i.delete(p.key),r.delete(p.key),s.delete(p.key),u=!1;for(var b=o.length-1;b>=0;b--)o[b].key===p.key&&o.splice(b,1);l(ot("teardown",p,p.context))})(Zt(b=>{if(b.stale)if(!b.hasNext)i.delete(p.key);else for(var I=0;I<o.length;I++){var H=o[I];if(H.key===b.operation.key){i.delete(H.key);break}}else b.hasNext||i.delete(p.key);r.set(p.key,b)})(k)):k=Dr(()=>{l(p)})(k),Mt(k)},m=this instanceof n?this:Object.create(n.prototype),y=Object.assign(m,{suspense:!!e.suspense,operations$:c.source,reexecuteOperation(p){if(p.kind==="teardown")d(p);else if(p.kind==="mutation")o.push(p),Promise.resolve().then(d);else if(s.has(p.key)){for(var k=!1,b=0;b<o.length;b++)o[b].key===p.key&&(o[b]=p,k=!0);k||i.has(p.key)&&p.context.requestPolicy!=="network-only"?(i.delete(p.key),Promise.resolve().then(d)):(o.push(p),Promise.resolve().then(d))}},createRequestOperation(p,k,b){b||(b={});var I;if(p!=="teardown"&&(I=fo(k.query))!==p)throw new Error(`Expected operation of type "${p}" but found "${I}"`);return ot(p,k,{_instance:p==="mutation"?t=t+1|0:void 0,...a,...b,requestPolicy:b.requestPolicy||a.requestPolicy,suspense:b.suspense||b.suspense!==!1&&y.suspense})},executeRequestOperation(p){return p.kind==="mutation"?ls(h(p)):ls(no(()=>{var k=s.get(p.key);k||s.set(p.key,k=h(p)),k=Dr(()=>{d(p)})(k);var b=r.get(p.key);return p.kind==="query"&&b&&(b.stale||b.hasNext)?jr(Mn)(rt([k,J(I=>I===r.get(p.key))(Mn(b))])):k}))},executeQuery(p,k){var b=y.createRequestOperation("query",p,k);return y.executeRequestOperation(b)},executeSubscription(p,k){var b=y.createRequestOperation("subscription",p,k);return y.executeRequestOperation(b)},executeMutation(p,k){var b=y.createRequestOperation("mutation",p,k);return y.executeRequestOperation(b)},readQuery(p,k,b){var I=null;return en(H=>{I=H})(y.query(p,k,b)).unsubscribe(),I},query:(p,k,b)=>y.executeQuery(Rn(p,k),b),subscription:(p,k,b)=>y.executeSubscription(Rn(p,k),b),mutation:(p,k,b)=>y.executeMutation(Rn(p,k),b)}),g=xo;{var{next:w,source:v}=Jr();y.subscribeToDebugTarget=p=>en(p)(v),g=w}var A=Eo(e.exchanges),S=Mt(A({client:y,dispatchDebug:g,forward:Co({dispatchDebug:g})})(c.source));return io(S),y},Oo=Mo;class No extends se{constructor(e,t){super(e,t),this.$__query=Q`query ($bundle: String!) {
|
|
21
21
|
ContinuId(bundle: $bundle) {
|
|
22
22
|
address,
|
|
23
23
|
bundleHash,
|
|
@@ -29,7 +29,7 @@ ${this.stack}`}}class Ke extends q{constructor(e="The molecule does not contain
|
|
|
29
29
|
amount,
|
|
30
30
|
createdAt
|
|
31
31
|
}
|
|
32
|
-
}`}createResponse(e){return new Fi({query:this,json:e})}}class Ro extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.WalletBundle"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={};return e.forEach(r=>{r.metas=
|
|
32
|
+
}`}createResponse(e){return new Fi({query:this,json:e})}}class Ro extends V{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.WalletBundle"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={};return e.forEach(r=>{r.metas=Ke.aggregateMeta(r.metas),t[r.bundleHash]=r}),t}}class Uo extends se{constructor(e,t){super(e,t),this.$__query=Q`query( $bundleHashes: [ String! ] ) {
|
|
33
33
|
WalletBundle( bundleHashes: $bundleHashes ) {
|
|
34
34
|
bundleHash,
|
|
35
35
|
metas {
|
|
@@ -524,5 +524,5 @@ ${this.stack}`}}class Ke extends q{constructor(e="The molecule does not contain
|
|
|
524
524
|
void main() {
|
|
525
525
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
526
526
|
}
|
|
527
|
-
`,s=$.createShader($.VERTEX_SHADER),i=$.createShader($.FRAGMENT_SHADER);if(!s||!i)throw new Error("Failed to create shaders");if($.shaderSource(s,t),$.shaderSource(i,r),$.compileShader(s),!$.getShaderParameter(s,$.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+$.getShaderInfoLog(s));if($.compileShader(i),!$.getShaderParameter(i,$.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+$.getShaderInfoLog(i));var o=$.createProgram();if(!o)throw new Error("Failed to create shader program");if($.attachShader(o,s),$.attachShader(o,i),$.linkProgram(o),!$.getProgramParameter(o,$.LINK_STATUS))throw new Error("Shader program linking failed: "+$.getProgramInfoLog(o));$.useProgram(o);for(var a=137,c=new Float32Array(4*a),l=2*Math.PI/a,u=0;u<a;u++){var d=u*l;c[4*u]=0,c[4*u+1]=0,c[4*u+2]=Math.cos(d)*(ne.width/2),c[4*u+3]=Math.sin(d)*(ne.height/2)}var h=$.createBuffer();$.bindBuffer($.ARRAY_BUFFER,h),$.bufferData($.ARRAY_BUFFER,c,$.STATIC_DRAW);var m=$.getAttribLocation(o,"position");$.enableVertexAttribArray(m),$.vertexAttribPointer(m,2,$.FLOAT,!1,0,0),$.viewport(0,0,ne.width,ne.height),$.clearColor(0,0,0,1),$.clear($.COLOR_BUFFER_BIT),$.drawArrays($.LINES,0,2*a);var y=new Uint8ClampedArray(ne.width*ne.height*4);return $.readPixels(0,0,ne.width,ne.height,$.RGBA,$.UNSIGNED_BYTE,y),new ImageData(y,ne.width,ne.height)}catch{return new ImageData(1,1)}finally{$&&($.bindBuffer($.ARRAY_BUFFER,null),$.useProgram(null),$.viewport(0,0,$.drawingBufferWidth,$.drawingBufferHeight),$.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Pn(bs(n,ne.width,ne.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var Je=function(n,e,t,r){for(var s=(t-e)/r,i=0,o=0;o<r;o++)i+=n(e+(o+.5)*s);return i*s};be("math",function(){return $e(void 0,void 0,void 0,function(){return Ie(this,function(n){return[2,{acos:Math.acos(.5),asin:Je(Math.asin,-1,1,97),atan:Je(Math.atan,-1,1,97),cos:Je(Math.cos,0,Math.PI,97),cosh:Math.cosh(1.2857142857142858),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:Je(Math.sin,-Math.PI,Math.PI,97),sinh:Je(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:Je(Math.tan,0,2*Math.PI,97),tanh:Je(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function oe(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function Ge(n){return oe(n)==="object"}function Wa(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function As(n,e){return n.length<124?n:e}const Da="graphql-transport-ws";var pe=(n=>(n[n.InternalServerError=4500]="InternalServerError",n[n.InternalClientError=4005]="InternalClientError",n[n.BadRequest=4400]="BadRequest",n[n.BadResponse=4004]="BadResponse",n[n.Unauthorized=4401]="Unauthorized",n[n.Forbidden=4403]="Forbidden",n[n.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",n[n.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",n[n.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",n[n.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",n[n.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",n))(pe||{}),ye=(n=>(n.ConnectionInit="connection_init",n.ConnectionAck="connection_ack",n.Ping="ping",n.Pong="pong",n.Subscribe="subscribe",n.Next="next",n.Error="error",n.Complete="complete",n))(ye||{});function xs(n){if(!Ge(n))throw new Error(`Message is expected to be an object, but got ${oe(n)}`);if(!n.type)throw new Error("Message is missing the 'type' property");if(typeof n.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${oe(n.type)}`);switch(n.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(n.payload!=null&&!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${n.payload}"`);break}case"subscribe":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);if(typeof n.payload.query!="string")throw new Error(`"${n.type}" message payload expects the 'query' property to be a string, but got ${oe(n.payload.query)}`);if(n.payload.variables!=null&&!Ge(n.payload.variables))throw new Error(`"${n.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${oe(n.payload.variables)}`);if(n.payload.operationName!=null&&oe(n.payload.operationName)!=="string")throw new Error(`"${n.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${oe(n.payload.operationName)}`);if(n.payload.extensions!=null&&!Ge(n.payload.extensions))throw new Error(`"${n.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${oe(n.payload.extensions)}`);break}case"next":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Ge(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);break}case"error":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wa(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(n.payload)}`);break}case"complete":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${n.type}"`)}return n}function ja(n,e){return xs(typeof n=="string"?JSON.parse(n,e):n)}function Rt(n,e){return xs(n),JSON.stringify(n,e)}function Qa(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:a,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(B){const M=Math.pow(2,B);await new Promise(R=>setTimeout(R,M*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:d=Kn,on:h,webSocketImpl:m,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,B=>{const M=Math.random()*16|0;return(B=="x"?M:M&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:w}=n;let v;if(m){if(!za(m))throw new Error("Invalid WebSocket implementation provided");v=m}else typeof WebSocket<"u"?v=WebSocket:typeof global<"u"?v=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const A=v,S=(()=>{const C=(()=>{const M={};return{on(R,D){return M[R]=D,()=>{delete M[R]}},emit(R){"id"in R&&M[R.id]?.(R)}}})(),B={connecting:h?.connecting?[h.connecting]:[],opened:h?.opened?[h.opened]:[],connected:h?.connected?[h.connected]:[],ping:h?.ping?[h.ping]:[],pong:h?.pong?[h.pong]:[],message:h?.message?[C.emit,h.message]:[C.emit],closed:h?.closed?[h.closed]:[],error:h?.error?[h.error]:[]};return{onMessage:C.on,on(M,R){const D=B[M];return D.push(R),()=>{D.splice(D.indexOf(R),1)}},emit(M,...R){for(const D of[...B[M]])D(...R)}}})();function p(C){const B=[S.on("error",M=>{B.forEach(R=>R()),C(M)}),S.on("closed",M=>{B.forEach(R=>R()),C(M)})]}let k,b=0,I,H=!1,W=0,me=!1;async function L(){clearTimeout(I);const[C,B]=await(k??(k=new Promise((D,ae)=>(async()=>{if(H){if(await u(W),!b)return k=void 0,ae({code:1e3,reason:"All Subscriptions Gone"});W++}S.emit("connecting",H);const U=new A(typeof e=="function"?await e():e,Da);let at,Ut;function yn(){isFinite(o)&&o>0&&(clearTimeout(Ut),Ut=setTimeout(()=>{U.readyState===A.OPEN&&(U.send(Rt({type:ye.Ping})),S.emit("ping",!1,void 0))},o))}p(ee=>{k=void 0,clearTimeout(at),clearTimeout(Ut),ae(ee),ee instanceof _s&&(U.close(4499,"Terminated"),U.onerror=null,U.onclose=null)}),U.onerror=ee=>S.emit("error",ee),U.onclose=ee=>S.emit("closed",ee),U.onopen=async()=>{try{S.emit("opened",U);const ee=typeof t=="function"?await t():t;if(U.readyState!==A.OPEN)return;U.send(Rt(ee?{type:ye.ConnectionInit,payload:ee}:{type:ye.ConnectionInit},g)),isFinite(c)&&c>0&&(at=setTimeout(()=>{U.close(pe.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),yn()}catch(ee){S.emit("error",ee),U.close(pe.InternalClientError,As(ee instanceof Error?ee.message:String(ee),"Internal client error"))}};let lt=!1;U.onmessage=({data:ee})=>{try{const G=ja(ee,w);if(S.emit("message",G),G.type==="ping"||G.type==="pong"){S.emit(G.type,!0,G.payload),G.type==="pong"?yn():a||(U.send(Rt(G.payload?{type:ye.Pong,payload:G.payload}:{type:ye.Pong})),S.emit("pong",!1,G.payload));return}if(lt)return;if(G.type!==ye.ConnectionAck)throw new Error(`First message cannot be of type ${G.type}`);clearTimeout(at),lt=!0,S.emit("connected",U,G.payload,H),H=!1,W=0,D([U,new Promise((nl,Xa)=>p(Xa))])}catch(G){U.onmessage=null,S.emit("error",G),U.close(pe.BadResponse,As(G instanceof Error?G.message:String(G),"Bad response"))}}})())));C.readyState===A.CLOSING&&await B;let M=()=>{};const R=new Promise(D=>M=D);return[C,M,Promise.race([R.then(()=>{if(!b){const D=()=>C.close(1e3,"Normal Closure");isFinite(i)&&i>0?I=setTimeout(()=>{C.readyState===A.OPEN&&D()},i):D()}}),B])]}function Re(C){if(Kn(C)&&(Va(C.code)||[pe.InternalServerError,pe.InternalClientError,pe.BadRequest,pe.BadResponse,pe.Unauthorized,pe.SubprotocolNotAcceptable,pe.SubscriberAlreadyExists,pe.TooManyInitialisationRequests].includes(C.code)))throw C;if(me)return!1;if(Kn(C)&&C.code===1e3)return b>0;if(!l||W>=l||!d(C))throw C;return H=!0}r||(async()=>{for(b++;;)try{const[,,C]=await L();await C}catch(C){try{if(!Re(C))return}catch(B){return s?.(B)}}})();function ot(C,B){const M=y(C);let R=!1,D=!1,ae=()=>{b--,R=!0};return(async()=>{for(b++;;)try{const[U,at,Ut]=await L();if(R)return at();const yn=S.onMessage(M,lt=>{switch(lt.type){case ye.Next:{B.next(lt.payload);return}case ye.Error:{D=!0,R=!0,B.error(lt.payload),ae();return}case ye.Complete:{R=!0,ae();return}}});U.send(Rt({id:M,type:ye.Subscribe,payload:C},g)),ae=()=>{!R&&U.readyState===A.OPEN&&U.send(Rt({id:M,type:ye.Complete},g)),b--,R=!0,at()},await Ut.finally(yn);return}catch(U){if(!Re(U))return}})().then(()=>{D||B.complete()}).catch(U=>{B.error(U)}),()=>{R||ae()}}return{on:S.on,subscribe:ot,iterate(C){const B=[],M={done:!1,error:null,resolve:()=>{}},R=ot(C,{next(ae){B.push(ae),M.resolve()},error(ae){M.done=!0,M.error=ae,M.resolve()},complete(){M.done=!0,M.resolve()}}),D=async function*(){for(;;){for(B.length||await new Promise(U=>M.resolve=U);B.length;)yield B.shift();if(M.error)throw M.error;if(M.done)return}}();return D.throw=async ae=>(M.done||(M.done=!0,M.error=ae,M.resolve()),{done:!0,value:void 0}),D.return=async()=>(R(),{done:!0,value:void 0}),D},async dispose(){if(me=!0,k){const[C]=await k;C.close(1e3,"Normal Closure")}},terminate(){k&&S.emit("closed",new _s)}}}class _s extends Error{constructor(){super(...arguments);ut(this,"name","TerminatedCloseEvent");ut(this,"message","4499: Terminated");ut(this,"code",4499);ut(this,"reason","Terminated");ut(this,"wasClean",!1)}}function Kn(n){return Ge(n)&&"code"in n&&"reason"in n}function Va(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function za(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}class Ja{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:r}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!r,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:r}){const s=[$o,To];if(t&&t.socketUri){const i=Qa({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(Io({forwardSubscription:o=>({subscribe:a=>({unsubscribe:i.subscribe(o,a)})})}))}return Oo({url:e,exchanges:s,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken}})})}setAuthData({token:e,pubkey:t,wallet:r}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=r,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:r}=e,s=await this.$__client.query(t,r).toPromise();return this.formatResponse(s)}async mutate(e){const{mutation:t,variables:r}=e,s=await this.$__client.mutation(t,r).toPromise();return this.formatResponse(s)}subscribe(e,t){const{query:r,variables:s,operationName:i}=e,{unsubscribe:o}=ao(this.$__client.subscription(r,s),Ct(a=>{t(this.formatResponse(a))})).subscribe(()=>{});return this.$__subscriptionManager.set(i,{unsubscribe:o}),{unsubscribe:()=>this.unsubscribe(i)}}formatResponse(e){return{data:e.data,errors:e.error?[e.error]:void 0}}socketDisconnect(){this.soketi&&this.unsubscribeAll()}unsubscribe(e){const t=this.$__subscriptionManager.get(e);t&&(t.unsubscribe(),this.$__subscriptionManager.delete(e))}unsubscribeAll(){this.$__subscriptionManager.forEach((e,t)=>{this.unsubscribe(t)})}unsubscribeFromChannel(e){this.unsubscribe(e)}setEncryption(e=!1){this.cipherLink=e,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:e})}getAuthToken(){return this.$__authToken}getPubKey(){return this.$__pubkey}getWallet(){return this.$__wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}getUri(){return this.serverUri}setUri(e){this.serverUri=e,this.$__client=this.createUrqlClient({serverUri:e,socket:this.soketi,encrypt:!!this.cipherLink})}setSocketUri({socketUri:e,appKey:t}){this.soketi={socketUri:e,appKey:t},this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}}class Ga{constructor({uri:e,cellSlug:t=null,client:r=null,socket:s=null,serverSdkVersion:i=3,logging:o=!1}){this.initialize({uri:e,cellSlug:t,socket:s,client:r,serverSdkVersion:i,logging:o})}initialize({uri:e,cellSlug:t=null,socket:r=null,client:s=null,serverSdkVersion:i=3,logging:o=!1}){this.reset(),this.$__logging=o,this.$__authTokenObjects={},this.$__authInProcess=!1,this.abortControllers=new Map,this.setUri(e),t&&this.setCellSlug(t);for(const a in this.$__uris){const c=this.$__uris[a];this.$__authTokenObjects[c]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`),this.$__client=s||new Ja({socket:{socketUri:null,appKey:"knishio",...r||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=i}getRandomUri(){const e=Math.floor(Math.random()*this.$__uris.length);return this.$__uris[e]}switchEncryption(e){return this.$__encrypt===e?!1:(this.log("info",`KnishIOClient::switchEncryption() - Forcing encryption ${e?"on":"off"} to match node...`),this.$__encrypt=e,this.$__client.setEncryption(e),!0)}deinitialize(){this.log("info","KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."),this.reset()}subscribe(){if(!this.client().getSocketUri())throw new Oe("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}cellSlug(){return this.getCellSlug()}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){this.$__uris=typeof e=="object"?e:[e]}getUri(){return this.$__client.getUri()}uri(){return this.getUri()}client(){if(!this.$__authInProcess){const e=this.getRandomUri();this.$__client.setUri(e);const t=this.$__authTokenObjects[e];t?this.$__client.setAuthData(t.getAuthData()):this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}).then(()=>{})}return this.$__client}hasSecret(){return!!this.$__secret}setSecret(e){this.$__secret=e,this.$__bundle=this.hashSecret(e,"setSecret")}hashSecret(e,t=null){return this.log("info",`KnishIOClient::hashSecret(${t?`source: ${t}`:""}) - Computing wallet bundle from secret...`),We(e)}getSecret(){if(!this.hasSecret())throw new xn("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");return this.$__secret}hasBundle(){return!!this.$__bundle}getBundle(){if(!this.hasBundle())throw new xn("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return Ma()}getFingerprintData(){return gs()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=N.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new N({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!r&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(r=this.getRemainderWallet()),r===null&&(r=await this.getSourceWallet()),this.remainderWallet=s||N.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new Ae({secret:e,sourceWallet:r,remainderWallet:this.getRemainderWallet(),cellSlug:this.getCellSlug(),version:this.getServerSdkVersion()})}createQuery(e){return new e(this.client(),this)}createSubscribe(e){return new e(this.subscribe())}async createMoleculeMutation({mutationClass:e,molecule:t=null}){this.log("info",`KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);const r=t||await this.createMolecule({}),s=new e(this.client(),this,r);if(!(s instanceof Y))throw new Oe(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);return this.lastMoleculeQuery=s,s}async executeQuery(e,t=null){this.$__authToken&&this.$__authToken.isExpired()&&(this.log("info","KnishIOClient::executeQuery() - Access token is expired. Getting new one..."),await this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}));const r=new AbortController,s=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(s,r);try{const i=await e.execute({variables:t,context:{fetchOptions:{signal:r.signal}}});return this.abortControllers.delete(s),i}catch(i){if(i.name==="AbortError")this.log("warn","Query was cancelled");else throw i}}cancelQuery(e,t=null){const r=JSON.stringify({query:e.$__query,variables:t}),s=this.abortControllers.get(r);s&&(s.abort(),this.abortControllers.delete(r))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:r="regular"}){const s=this.createQuery(Bo);return this.executeQuery(s,{bundleHash:t||this.getBundle(),token:e,type:r})}async querySourceWallet({token:e,amount:t,type:r="regular"}){const s=(await this.queryBalance({token:e,type:r})).payload();if(s===null||et.cmp(s.balance,t)<0)throw new Me;if(!s.position||!s.address)throw new Me("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(oa).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new Oe(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(aa).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(la).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(ua).execute({variables:{metaType:e,metaId:t},closure:r})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:r=null,value:s=null,latest:i=!0,fields:o=null,filter:a=null,queryArgs:c=null,count:l=null,countBy:u=null,throughAtom:d=!0,values:h=null,keys:m=null,atomValues:y=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let g,w;return d?(g=this.createQuery(ys),w=ys.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,countBy:u,values:h,keys:m,atomValues:y})):(g=this.createQuery(hs),w=hs.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,count:l,countBy:u})),this.executeQuery(g,w).then(v=>v.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Ot);return await this.executeQuery(t,{batchId:e})}async queryBatchHistory({batchId:e}){this.log("info",`KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Lo);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const Re=this.createQuery(ps);return await this.executeQuery(Re,ps.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}))}async createWallet({token:e}){const t=new N({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:na});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const s=this.createQuery(fa);return await this.executeQuery(s,{bundleHash:e,metaType:t,metaId:r})}async queryUserActivity({bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u}){const d=this.createQuery(ya);return await this.executeQuery(d,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:l={}}){const u=this.createQuery(ha);return await this.executeQuery(u,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:JSON.stringify(l)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:s=null,units:i=[]}){const o=K.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=s||Ft({})),["nonfungible","stackable"].includes(o)&&i.length>0){if(K.get(r||{},"decimals")>0)throw new ia;if(t>0)throw new dn;t=i.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(i)}const a=new N({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:Do});return c.fillMolecule({recipientWallet:a,amount:t,meta:r||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:Sa,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return i.fillMolecule({metaType:e,metaId:t,rule:r,policy:s}),await this.executeQuery(i)}async createMeta({metaType:e,metaId:t,meta:r=null,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:ea,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),o=r||{};return i.fillMolecule({metaType:e,metaId:t,meta:o,policy:s}),await this.executeQuery(i)}async createIdentifier({type:e,contact:t,code:r}){const s=await this.createMoleculeMutation({mutationClass:Go});return s.fillMolecule({type:e,contact:t,code:r}),await this.executeQuery(s)}async createPolicy({metaType:e,metaId:t,policy:r={}}){const s=await this.createMolecule({});s.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:r}),s.addContinuIdAtom(),s.sign({bundle:this.getBundle()}),s.check();const i=await this.createMoleculeMutation({mutationClass:Y,molecule:s});return await this.executeQuery(i)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(ba);return await this.executeQuery(r,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:r=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const s=this.createQuery(qo);return this.executeQuery(s,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:r}).then(i=>i.payload())}queryBundle({bundle:e=null,fields:t=null,raw:r=!1}){this.log("info",`KnishIOClient::queryBundle() - Querying wallet bundle metadata${e?` for ${e}`:""}...`),e||(e=this.getBundle()),typeof e=="string"&&(e=[e]);const s=this.createQuery(Uo);return this.executeQuery(s,{bundleHashes:e}).then(i=>r?i:i.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(No);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:s=[],meta:i=null,batchId:o=null}){let a,c;i=i||{};const l=this.createQuery(ma),u=await this.executeQuery(l,{slug:e}),d=K.get(u.data(),"0.fungibility")==="stackable";if(!d&&o!==null)throw new zt("Expected Batch ID = null for non-stackable tokens.");if(d&&o===null&&(o=Ft({})),s.length>0){if(r>0)throw new dn;r=s.length,i.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(N.isBundleHash(t)?(a="walletBundle",c=t):t=N.create({secret:t,token:e})),t instanceof N&&(a="wallet",i.position=t.position,i.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const h=await this.createMoleculeMutation({mutationClass:Qo});return h.fillMolecule({token:e,amount:r,metaType:a,metaId:c,meta:i,batchId:o}),await this.executeQuery(h)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const s=await this.createMoleculeMutation({mutationClass:Yo,molecule:r});return s.fillMolecule({token:e,batchId:t}),await this.executeQuery(s)}async claimShadowWallets({token:e}){const t=await this.queryWallets({token:e});if(!t||!Array.isArray(t))throw new ds;t.forEach(s=>{if(!s.isShadow())throw new ds});const r=[];for(const s of t)r.push(await this.claimShadowWallet({token:e,batchId:s.batchId}));return r}async transferToken({bundleHash:e,token:t,amount:r=null,units:s=[],batchId:i=null,sourceWallet:o=null}){if(s.length>0){if(r>0)throw new dn;r=s.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||et.cmp(o.balance,r)<0)throw new Me;const a=N.create({bundle:e,token:t});i!==null?a.batchId=i:a.initBatchId({sourceWallet:o});const c=o.createRemainder(this.getSecret());o.splitUnits(s,c,a);const l=await this.createMolecule({sourceWallet:o,remainderWallet:c}),u=await this.createMoleculeMutation({mutationClass:zo,molecule:l});return u.fillMolecule({recipientWallet:a,amount:r}),await this.executeQuery(u)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:r,sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:Aa,molecule:o});return a.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(a)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:r=null,signingWallet:s=null}){r===null&&(r=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const i=r,o=await this.createMolecule({sourceWallet:r,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:xa,molecule:o}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:s}),await this.executeQuery(a)}async burnTokens({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret());if(r.length>0){if(t>0)throw new dn;t=r.length,s.splitUnits(r,i)}const o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.burnToken({amount:t}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async replenishToken({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:e})).payload()),!s)throw new Me("Source wallet is missing or invalid.");const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.replenishToken({amount:t,units:r}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:r,fusedTokenUnitIds:s,sourceWallet:i=null}){if(i===null&&(i=(await this.queryBalance({token:t})).payload()),i===null)throw new Me("Source wallet is missing or invalid.");if(!i.tokenUnits||!i.tokenUnits.length)throw new Me("Source wallet does not have token units.");if(!s.length)throw new Me("Fused token unit list is empty.");const o=[];i.tokenUnits.forEach(d=>{o.push(d.id)}),s.forEach(d=>{if(!o.includes(d))throw new Me(`Fused token unit ID = ${d} does not found in the source wallet.`)});const a=N.create({bundle:e,token:t});a.initBatchId({sourceWallet:i});const c=i.createRemainder(this.getSecret());i.splitUnits(s,c),r.metas.fusedTokenUnits=i.getTokenUnitsData(),a.tokenUnits=[r];const l=await this.createMolecule({sourceWallet:i,remainderWallet:c});l.fuseToken(i.tokenUnits,a),l.sign({bundle:this.getBundle()}),l.check();const u=await this.createMoleculeMutation({mutationClass:Y,molecule:l});return this.executeQuery(u)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new N({secret:Kt(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(sa),i={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await s.execute({variables:i});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new N({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:r}),i=await this.createMoleculeMutation({mutationClass:Fo,molecule:s});i.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await i.execute({});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:r=null,encrypt:s=!1}){if(this.$__serverSdkVersion<3)return this.log("warn","KnishIOClient::authorize() - Server SDK version does not require an authorization..."),null;e===null&&t&&(e=Kt(t)),r&&this.setCellSlug(r),this.$__authInProcess=!0;let i;return e?i=await this.requestProfileAuthToken({secret:e,encrypt:s}):i=await this.requestGuestAuthToken({cellSlug:r,encrypt:s}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(s),this.$__authInProcess=!1,i}setAuthToken(e){if(!e){this.log("info","KnishIOClient::setAuthToken() - authToken object is empty.");return}this.$__authTokenObjects[this.getUri()]=e,this.client().setAuthData(e.getAuthData()),this.$__authToken=e}getAuthToken(){return this.$__authToken}log(e,t){if(this.$__logging)switch(e){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}}}return P.Atom=E,P.KnishIOClient=Ga,P.Meta=yt,P.Molecule=Ae,P.Wallet=N,P.base64ToHex=hr,P.bufferToHexString=lr,P.charsetBaseConvert=ar,P.chunkSubstr=pt,P.generateBundleHash=We,P.generateSecret=Kt,P.hexStringToBuffer=ur,P.hexToBase64=cr,P.isHex=dr,P.randomString=Pt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({});
|
|
527
|
+
`,s=$.createShader($.VERTEX_SHADER),i=$.createShader($.FRAGMENT_SHADER);if(!s||!i)throw new Error("Failed to create shaders");if($.shaderSource(s,t),$.shaderSource(i,r),$.compileShader(s),!$.getShaderParameter(s,$.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+$.getShaderInfoLog(s));if($.compileShader(i),!$.getShaderParameter(i,$.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+$.getShaderInfoLog(i));var o=$.createProgram();if(!o)throw new Error("Failed to create shader program");if($.attachShader(o,s),$.attachShader(o,i),$.linkProgram(o),!$.getProgramParameter(o,$.LINK_STATUS))throw new Error("Shader program linking failed: "+$.getProgramInfoLog(o));$.useProgram(o);for(var a=137,c=new Float32Array(4*a),l=2*Math.PI/a,u=0;u<a;u++){var d=u*l;c[4*u]=0,c[4*u+1]=0,c[4*u+2]=Math.cos(d)*(ne.width/2),c[4*u+3]=Math.sin(d)*(ne.height/2)}var h=$.createBuffer();$.bindBuffer($.ARRAY_BUFFER,h),$.bufferData($.ARRAY_BUFFER,c,$.STATIC_DRAW);var m=$.getAttribLocation(o,"position");$.enableVertexAttribArray(m),$.vertexAttribPointer(m,2,$.FLOAT,!1,0,0),$.viewport(0,0,ne.width,ne.height),$.clearColor(0,0,0,1),$.clear($.COLOR_BUFFER_BIT),$.drawArrays($.LINES,0,2*a);var y=new Uint8ClampedArray(ne.width*ne.height*4);return $.readPixels(0,0,ne.width,ne.height,$.RGBA,$.UNSIGNED_BYTE,y),new ImageData(y,ne.width,ne.height)}catch{return new ImageData(1,1)}finally{$&&($.bindBuffer($.ARRAY_BUFFER,null),$.useProgram(null),$.viewport(0,0,$.drawingBufferWidth,$.drawingBufferHeight),$.clearColor(0,0,0,0))}}()}),[2,{commonImageHash:Pn(bs(n,ne.width,ne.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]})})});var Ge=function(n,e,t,r){for(var s=(t-e)/r,i=0,o=0;o<r;o++)i+=n(e+(o+.5)*s);return i*s};be("math",function(){return $e(void 0,void 0,void 0,function(){return Ie(this,function(n){return[2,{acos:Math.acos(.5),asin:Ge(Math.asin,-1,1,97),atan:Ge(Math.atan,-1,1,97),cos:Ge(Math.cos,0,Math.PI,97),cosh:Math.cosh(1.2857142857142858),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:Ge(Math.sin,-Math.PI,Math.PI,97),sinh:Ge(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:Ge(Math.tan,0,2*Math.PI,97),tanh:Ge(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]})})});function oe(n){return n===null?"null":Array.isArray(n)?"array":typeof n}function Xe(n){return oe(n)==="object"}function Wa(n){return Array.isArray(n)&&n.length>0&&n.every(e=>"message"in e)}function As(n,e){return n.length<124?n:e}const Da="graphql-transport-ws";var pe=(n=>(n[n.InternalServerError=4500]="InternalServerError",n[n.InternalClientError=4005]="InternalClientError",n[n.BadRequest=4400]="BadRequest",n[n.BadResponse=4004]="BadResponse",n[n.Unauthorized=4401]="Unauthorized",n[n.Forbidden=4403]="Forbidden",n[n.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",n[n.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",n[n.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",n[n.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",n[n.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",n))(pe||{}),ye=(n=>(n.ConnectionInit="connection_init",n.ConnectionAck="connection_ack",n.Ping="ping",n.Pong="pong",n.Subscribe="subscribe",n.Next="next",n.Error="error",n.Complete="complete",n))(ye||{});function xs(n){if(!Xe(n))throw new Error(`Message is expected to be an object, but got ${oe(n)}`);if(!n.type)throw new Error("Message is missing the 'type' property");if(typeof n.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${oe(n.type)}`);switch(n.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(n.payload!=null&&!Xe(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${n.payload}"`);break}case"subscribe":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Xe(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);if(typeof n.payload.query!="string")throw new Error(`"${n.type}" message payload expects the 'query' property to be a string, but got ${oe(n.payload.query)}`);if(n.payload.variables!=null&&!Xe(n.payload.variables))throw new Error(`"${n.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${oe(n.payload.variables)}`);if(n.payload.operationName!=null&&oe(n.payload.operationName)!=="string")throw new Error(`"${n.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${oe(n.payload.operationName)}`);if(n.payload.extensions!=null&&!Xe(n.payload.extensions))throw new Error(`"${n.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${oe(n.payload.extensions)}`);break}case"next":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Xe(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an object, but got ${oe(n.payload)}`);break}case"error":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);if(!Wa(n.payload))throw new Error(`"${n.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(n.payload)}`);break}case"complete":{if(typeof n.id!="string")throw new Error(`"${n.type}" message expects the 'id' property to be a string, but got ${oe(n.id)}`);if(!n.id)throw new Error(`"${n.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${n.type}"`)}return n}function ja(n,e){return xs(typeof n=="string"?JSON.parse(n,e):n)}function Rt(n,e){return xs(n),JSON.stringify(n,e)}function Qa(n){const{url:e,connectionParams:t,lazy:r=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:a,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(B){const M=Math.pow(2,B);await new Promise(R=>setTimeout(R,M*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:d=Kn,on:h,webSocketImpl:m,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,B=>{const M=Math.random()*16|0;return(B=="x"?M:M&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:w}=n;let v;if(m){if(!za(m))throw new Error("Invalid WebSocket implementation provided");v=m}else typeof WebSocket<"u"?v=WebSocket:typeof global<"u"?v=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const A=v,S=(()=>{const C=(()=>{const M={};return{on(R,D){return M[R]=D,()=>{delete M[R]}},emit(R){"id"in R&&M[R.id]?.(R)}}})(),B={connecting:h?.connecting?[h.connecting]:[],opened:h?.opened?[h.opened]:[],connected:h?.connected?[h.connected]:[],ping:h?.ping?[h.ping]:[],pong:h?.pong?[h.pong]:[],message:h?.message?[C.emit,h.message]:[C.emit],closed:h?.closed?[h.closed]:[],error:h?.error?[h.error]:[]};return{onMessage:C.on,on(M,R){const D=B[M];return D.push(R),()=>{D.splice(D.indexOf(R),1)}},emit(M,...R){for(const D of[...B[M]])D(...R)}}})();function p(C){const B=[S.on("error",M=>{B.forEach(R=>R()),C(M)}),S.on("closed",M=>{B.forEach(R=>R()),C(M)})]}let k,b=0,I,H=!1,W=0,me=!1;async function L(){clearTimeout(I);const[C,B]=await(k??(k=new Promise((D,ae)=>(async()=>{if(H){if(await u(W),!b)return k=void 0,ae({code:1e3,reason:"All Subscriptions Gone"});W++}S.emit("connecting",H);const U=new A(typeof e=="function"?await e():e,Da);let lt,Ut;function yn(){isFinite(o)&&o>0&&(clearTimeout(Ut),Ut=setTimeout(()=>{U.readyState===A.OPEN&&(U.send(Rt({type:ye.Ping})),S.emit("ping",!1,void 0))},o))}p(ee=>{k=void 0,clearTimeout(lt),clearTimeout(Ut),ae(ee),ee instanceof _s&&(U.close(4499,"Terminated"),U.onerror=null,U.onclose=null)}),U.onerror=ee=>S.emit("error",ee),U.onclose=ee=>S.emit("closed",ee),U.onopen=async()=>{try{S.emit("opened",U);const ee=typeof t=="function"?await t():t;if(U.readyState!==A.OPEN)return;U.send(Rt(ee?{type:ye.ConnectionInit,payload:ee}:{type:ye.ConnectionInit},g)),isFinite(c)&&c>0&&(lt=setTimeout(()=>{U.close(pe.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),yn()}catch(ee){S.emit("error",ee),U.close(pe.InternalClientError,As(ee instanceof Error?ee.message:String(ee),"Internal client error"))}};let ut=!1;U.onmessage=({data:ee})=>{try{const G=ja(ee,w);if(S.emit("message",G),G.type==="ping"||G.type==="pong"){S.emit(G.type,!0,G.payload),G.type==="pong"?yn():a||(U.send(Rt(G.payload?{type:ye.Pong,payload:G.payload}:{type:ye.Pong})),S.emit("pong",!1,G.payload));return}if(ut)return;if(G.type!==ye.ConnectionAck)throw new Error(`First message cannot be of type ${G.type}`);clearTimeout(lt),ut=!0,S.emit("connected",U,G.payload,H),H=!1,W=0,D([U,new Promise((nl,Xa)=>p(Xa))])}catch(G){U.onmessage=null,S.emit("error",G),U.close(pe.BadResponse,As(G instanceof Error?G.message:String(G),"Bad response"))}}})())));C.readyState===A.CLOSING&&await B;let M=()=>{};const R=new Promise(D=>M=D);return[C,M,Promise.race([R.then(()=>{if(!b){const D=()=>C.close(1e3,"Normal Closure");isFinite(i)&&i>0?I=setTimeout(()=>{C.readyState===A.OPEN&&D()},i):D()}}),B])]}function Re(C){if(Kn(C)&&(Va(C.code)||[pe.InternalServerError,pe.InternalClientError,pe.BadRequest,pe.BadResponse,pe.Unauthorized,pe.SubprotocolNotAcceptable,pe.SubscriberAlreadyExists,pe.TooManyInitialisationRequests].includes(C.code)))throw C;if(me)return!1;if(Kn(C)&&C.code===1e3)return b>0;if(!l||W>=l||!d(C))throw C;return H=!0}r||(async()=>{for(b++;;)try{const[,,C]=await L();await C}catch(C){try{if(!Re(C))return}catch(B){return s?.(B)}}})();function at(C,B){const M=y(C);let R=!1,D=!1,ae=()=>{b--,R=!0};return(async()=>{for(b++;;)try{const[U,lt,Ut]=await L();if(R)return lt();const yn=S.onMessage(M,ut=>{switch(ut.type){case ye.Next:{B.next(ut.payload);return}case ye.Error:{D=!0,R=!0,B.error(ut.payload),ae();return}case ye.Complete:{R=!0,ae();return}}});U.send(Rt({id:M,type:ye.Subscribe,payload:C},g)),ae=()=>{!R&&U.readyState===A.OPEN&&U.send(Rt({id:M,type:ye.Complete},g)),b--,R=!0,lt()},await Ut.finally(yn);return}catch(U){if(!Re(U))return}})().then(()=>{D||B.complete()}).catch(U=>{B.error(U)}),()=>{R||ae()}}return{on:S.on,subscribe:at,iterate(C){const B=[],M={done:!1,error:null,resolve:()=>{}},R=at(C,{next(ae){B.push(ae),M.resolve()},error(ae){M.done=!0,M.error=ae,M.resolve()},complete(){M.done=!0,M.resolve()}}),D=async function*(){for(;;){for(B.length||await new Promise(U=>M.resolve=U);B.length;)yield B.shift();if(M.error)throw M.error;if(M.done)return}}();return D.throw=async ae=>(M.done||(M.done=!0,M.error=ae,M.resolve()),{done:!0,value:void 0}),D.return=async()=>(R(),{done:!0,value:void 0}),D},async dispose(){if(me=!0,k){const[C]=await k;C.close(1e3,"Normal Closure")}},terminate(){k&&S.emit("closed",new _s)}}}class _s extends Error{constructor(){super(...arguments);ct(this,"name","TerminatedCloseEvent");ct(this,"message","4499: Terminated");ct(this,"code",4499);ct(this,"reason","Terminated");ct(this,"wasClean",!1)}}function Kn(n){return Xe(n)&&"code"in n&&"reason"in n}function Va(n){return[1e3,1001,1006,1005,1012,1013,1014].includes(n)?!1:n>=1e3&&n<=1999}function za(n){return typeof n=="function"&&"constructor"in n&&"CLOSED"in n&&"CLOSING"in n&&"CONNECTING"in n&&"OPEN"in n}class Ja{constructor({serverUri:e,socket:t=null,encrypt:r=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:r}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!r,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:r}){const s=[$o,To];if(t&&t.socketUri){const i=Qa({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(Io({forwardSubscription:o=>({subscribe:a=>({unsubscribe:i.subscribe(o,a)})})}))}return Oo({url:e,exchanges:s,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken}})})}setAuthData({token:e,pubkey:t,wallet:r}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=r,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:r}=e,s=await this.$__client.query(t,r).toPromise();return this.formatResponse(s)}async mutate(e){const{mutation:t,variables:r}=e,s=await this.$__client.mutation(t,r).toPromise();return this.formatResponse(s)}subscribe(e,t){const{query:r,variables:s,operationName:i}=e,{unsubscribe:o}=ao(this.$__client.subscription(r,s),Ct(a=>{t(this.formatResponse(a))})).subscribe(()=>{});return this.$__subscriptionManager.set(i,{unsubscribe:o}),{unsubscribe:()=>this.unsubscribe(i)}}formatResponse(e){return{data:e.data,errors:e.error?[e.error]:void 0}}socketDisconnect(){this.soketi&&this.unsubscribeAll()}unsubscribe(e){const t=this.$__subscriptionManager.get(e);t&&(t.unsubscribe(),this.$__subscriptionManager.delete(e))}unsubscribeAll(){this.$__subscriptionManager.forEach((e,t)=>{this.unsubscribe(t)})}unsubscribeFromChannel(e){this.unsubscribe(e)}setEncryption(e=!1){this.cipherLink=e,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:e})}getAuthToken(){return this.$__authToken}getPubKey(){return this.$__pubkey}getWallet(){return this.$__wallet}getServerUri(){return this.serverUri}getSocketUri(){return this.soketi?this.soketi.socketUri:null}getUri(){return this.serverUri}setUri(e){this.serverUri=e,this.$__client=this.createUrqlClient({serverUri:e,socket:this.soketi,encrypt:!!this.cipherLink})}setSocketUri({socketUri:e,appKey:t}){this.soketi={socketUri:e,appKey:t},this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}}class Ga{constructor({uri:e,cellSlug:t=null,client:r=null,socket:s=null,serverSdkVersion:i=3,logging:o=!1}){this.initialize({uri:e,cellSlug:t,socket:s,client:r,serverSdkVersion:i,logging:o})}initialize({uri:e,cellSlug:t=null,socket:r=null,client:s=null,serverSdkVersion:i=3,logging:o=!1}){this.reset(),this.$__logging=o,this.$__authTokenObjects={},this.$__authInProcess=!1,this.abortControllers=new Map,this.setUri(e),t&&this.setCellSlug(t);for(const a in this.$__uris){const c=this.$__uris[a];this.$__authTokenObjects[c]=null}this.log("info",`KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`),this.$__client=s||new Ja({socket:{socketUri:null,appKey:"knishio",...r||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=i}getRandomUri(){const e=Math.floor(Math.random()*this.$__uris.length);return this.$__uris[e]}switchEncryption(e){return this.$__encrypt===e?!1:(this.log("info",`KnishIOClient::switchEncryption() - Forcing encryption ${e?"on":"off"} to match node...`),this.$__encrypt=e,this.$__client.setEncryption(e),!0)}deinitialize(){this.log("info","KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."),this.reset()}subscribe(){if(!this.client().getSocketUri())throw new Oe("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}cellSlug(){return this.getCellSlug()}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){this.$__uris=typeof e=="object"?e:[e]}getUri(){return this.$__client.getUri()}uri(){return this.getUri()}client(){if(!this.$__authInProcess){const e=this.getRandomUri();this.$__client.setUri(e);const t=this.$__authTokenObjects[e];t?this.$__client.setAuthData(t.getAuthData()):this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}).then(()=>{})}return this.$__client}hasSecret(){return!!this.$__secret}setSecret(e){this.$__secret=e,this.$__bundle=this.hashSecret(e,"setSecret")}hashSecret(e,t=null){return this.log("info",`KnishIOClient::hashSecret(${t?`source: ${t}`:""}) - Computing wallet bundle from secret...`),De(e)}getSecret(){if(!this.hasSecret())throw new xn("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");return this.$__secret}hasBundle(){return!!this.$__bundle}getBundle(){if(!this.hasBundle())throw new xn("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return Ma()}getFingerprintData(){return gs()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=N.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new N({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:r=null,remainderWallet:s=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!r&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(r=this.getRemainderWallet()),r===null&&(r=await this.getSourceWallet()),this.remainderWallet=s||N.create({secret:e,bundle:t,token:"USER",batchId:r.batchId,characters:r.characters}),new Ae({secret:e,sourceWallet:r,remainderWallet:this.getRemainderWallet(),cellSlug:this.getCellSlug(),version:this.getServerSdkVersion()})}createQuery(e){return new e(this.client(),this)}createSubscribe(e){return new e(this.subscribe())}async createMoleculeMutation({mutationClass:e,molecule:t=null}){this.log("info",`KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);const r=t||await this.createMolecule({}),s=new e(this.client(),this,r);if(!(s instanceof Y))throw new Oe(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);return this.lastMoleculeQuery=s,s}async executeQuery(e,t=null){this.$__authToken&&this.$__authToken.isExpired()&&(this.log("info","KnishIOClient::executeQuery() - Access token is expired. Getting new one..."),await this.requestAuthToken({secret:this.$__secret,cellSlug:this.$__cellSlug,encrypt:this.$__encrypt}));const r=new AbortController,s=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(s,r);try{const i=await e.execute({variables:t,context:{fetchOptions:{signal:r.signal}}});return this.abortControllers.delete(s),i}catch(i){if(i.name==="AbortError")this.log("warn","Query was cancelled");else throw i}}cancelQuery(e,t=null){const r=JSON.stringify({query:e.$__query,variables:t}),s=this.abortControllers.get(r);s&&(s.abort(),this.abortControllers.delete(r))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:r="regular"}){const s=this.createQuery(Bo);return this.executeQuery(s,{bundleHash:t||this.getBundle(),token:e,type:r})}async querySourceWallet({token:e,amount:t,type:r="regular"}){const s=(await this.queryBalance({token:e,type:r})).payload();if(s===null||tt.cmp(s.balance,t)<0)throw new Me;if(!s.position||!s.address)throw new Me("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(oa).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:r}){if(!t)throw new Oe(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(aa).execute({variables:{bundle:e||this.getBundle(),token:t},closure:r})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(la).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:r}){return this.createSubscribe(ua).execute({variables:{metaType:e,metaId:t},closure:r})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:r=null,value:s=null,latest:i=!0,fields:o=null,filter:a=null,queryArgs:c=null,count:l=null,countBy:u=null,throughAtom:d=!0,values:h=null,keys:m=null,atomValues:y=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let g,w;return d?(g=this.createQuery(ys),w=ys.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,countBy:u,values:h,keys:m,atomValues:y})):(g=this.createQuery(hs),w=hs.createVariables({metaType:e,metaId:t,key:r,value:s,latest:i,filter:a,queryArgs:c,count:l,countBy:u})),this.executeQuery(g,w).then(v=>v.payload())}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Ot);return await this.executeQuery(t,{batchId:e})}async queryBatchHistory({batchId:e}){this.log("info",`KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Lo);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const Re=this.createQuery(ps);return await this.executeQuery(Re,ps.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:r,bundleHash:s,positions:i,position:o,walletAddresses:a,walletAddress:c,isotopes:l,isotope:u,tokenSlugs:d,tokenSlug:h,cellSlugs:m,cellSlug:y,batchIds:g,batchId:w,values:v,value:A,metaTypes:S,metaType:p,metaIds:k,metaId:b,indexes:I,index:H,filter:W,latest:me,queryArgs:L}))}async createWallet({token:e}){const t=new N({secret:this.getSecret(),token:e}),r=await this.createMoleculeMutation({mutationClass:na});return r.fillMolecule(t),await this.executeQuery(r)}async queryActiveSession({bundleHash:e,metaType:t,metaId:r}){const s=this.createQuery(fa);return await this.executeQuery(s,{bundleHash:e,metaType:t,metaId:r})}async queryUserActivity({bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u}){const d=this.createQuery(ya);return await this.executeQuery(d,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,countBy:l,interval:u})}async activeSession({bundle:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:l={}}){const u=this.createQuery(ha);return await this.executeQuery(u,{bundleHash:e,metaType:t,metaId:r,ipAddress:s,browser:i,osCpu:o,resolution:a,timeZone:c,json:JSON.stringify(l)})}async createToken({token:e,amount:t=null,meta:r=null,batchId:s=null,units:i=[]}){const o=K.get(r||{},"fungibility");if(o==="stackable"&&(r.batchId=s||Ft({})),["nonfungible","stackable"].includes(o)&&i.length>0){if(K.get(r||{},"decimals")>0)throw new ia;if(t>0)throw new dn;t=i.length,r.splittable=1,r.decimals=0,r.tokenUnits=JSON.stringify(i)}const a=new N({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:Do});return c.fillMolecule({recipientWallet:a,amount:t,meta:r||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:r,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:Sa,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return i.fillMolecule({metaType:e,metaId:t,rule:r,policy:s}),await this.executeQuery(i)}async createMeta({metaType:e,metaId:t,meta:r=null,policy:s={}}){const i=await this.createMoleculeMutation({mutationClass:ea,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),o=r||{};return i.fillMolecule({metaType:e,metaId:t,meta:o,policy:s}),await this.executeQuery(i)}async createIdentifier({type:e,contact:t,code:r}){const s=await this.createMoleculeMutation({mutationClass:Go});return s.fillMolecule({type:e,contact:t,code:r}),await this.executeQuery(s)}async createPolicy({metaType:e,metaId:t,policy:r={}}){const s=await this.createMolecule({});s.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:r}),s.addContinuIdAtom(),s.sign({bundle:this.getBundle()}),s.check();const i=await this.createMoleculeMutation({mutationClass:Y,molecule:s});return await this.executeQuery(i)}async queryPolicy({metaType:e,metaId:t}){const r=this.createQuery(ba);return await this.executeQuery(r,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:r=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const s=this.createQuery(qo);return this.executeQuery(s,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:r}).then(i=>i.payload())}queryBundle({bundle:e=null,fields:t=null,raw:r=!1}){this.log("info",`KnishIOClient::queryBundle() - Querying wallet bundle metadata${e?` for ${e}`:""}...`),e||(e=this.getBundle()),typeof e=="string"&&(e=[e]);const s=this.createQuery(Uo);return this.executeQuery(s,{bundleHashes:e}).then(i=>r?i:i.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(No);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:r=null,units:s=[],meta:i=null,batchId:o=null}){let a,c;i=i||{};const l=this.createQuery(ma),u=await this.executeQuery(l,{slug:e}),d=K.get(u.data(),"0.fungibility")==="stackable";if(!d&&o!==null)throw new zt("Expected Batch ID = null for non-stackable tokens.");if(d&&o===null&&(o=Ft({})),s.length>0){if(r>0)throw new dn;r=s.length,i.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(N.isBundleHash(t)?(a="walletBundle",c=t):t=N.create({secret:t,token:e})),t instanceof N&&(a="wallet",i.position=t.position,i.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const h=await this.createMoleculeMutation({mutationClass:Qo});return h.fillMolecule({token:e,amount:r,metaType:a,metaId:c,meta:i,batchId:o}),await this.executeQuery(h)}async claimShadowWallet({token:e,batchId:t=null,molecule:r=null}){const s=await this.createMoleculeMutation({mutationClass:Yo,molecule:r});return s.fillMolecule({token:e,batchId:t}),await this.executeQuery(s)}async claimShadowWallets({token:e}){const t=await this.queryWallets({token:e});if(!t||!Array.isArray(t))throw new ds;t.forEach(s=>{if(!s.isShadow())throw new ds});const r=[];for(const s of t)r.push(await this.claimShadowWallet({token:e,batchId:s.batchId}));return r}async transferToken({bundleHash:e,token:t,amount:r=null,units:s=[],batchId:i=null,sourceWallet:o=null}){if(s.length>0){if(r>0)throw new dn;r=s.length}if(o===null&&(o=await this.querySourceWallet({token:t,amount:r})),o===null||tt.cmp(o.balance,r)<0)throw new Me;const a=N.create({bundle:e,token:t});i!==null?a.batchId=i:a.initBatchId({sourceWallet:o});const c=o.createRemainder(this.getSecret());o.splitUnits(s,c,a);const l=await this.createMolecule({sourceWallet:o,remainderWallet:c}),u=await this.createMoleculeMutation({mutationClass:zo,molecule:l});return u.fillMolecule({recipientWallet:a,amount:r}),await this.executeQuery(u)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:r,sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:Aa,molecule:o});return a.fillMolecule({amount:t,tradeRates:r}),await this.executeQuery(a)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:r=null,signingWallet:s=null}){r===null&&(r=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const i=r,o=await this.createMolecule({sourceWallet:r,remainderWallet:i}),a=await this.createMoleculeMutation({mutationClass:xa,molecule:o}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:s}),await this.executeQuery(a)}async burnTokens({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const i=s.createRemainder(this.getSecret());if(r.length>0){if(t>0)throw new dn;t=r.length,s.splitUnits(r,i)}const o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.burnToken({amount:t}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async replenishToken({token:e,amount:t=null,units:r=[],sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:e})).payload()),!s)throw new Me("Source wallet is missing or invalid.");const i=s.createRemainder(this.getSecret()),o=await this.createMolecule({sourceWallet:s,remainderWallet:i});o.replenishToken({amount:t,units:r}),o.sign({bundle:this.getBundle()}),o.check();const a=await this.createMoleculeMutation({mutationClass:Y,molecule:o});return this.executeQuery(a)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:r,fusedTokenUnitIds:s,sourceWallet:i=null}){if(i===null&&(i=(await this.queryBalance({token:t})).payload()),i===null)throw new Me("Source wallet is missing or invalid.");if(!i.tokenUnits||!i.tokenUnits.length)throw new Me("Source wallet does not have token units.");if(!s.length)throw new Me("Fused token unit list is empty.");const o=[];i.tokenUnits.forEach(d=>{o.push(d.id)}),s.forEach(d=>{if(!o.includes(d))throw new Me(`Fused token unit ID = ${d} does not found in the source wallet.`)});const a=N.create({bundle:e,token:t});a.initBatchId({sourceWallet:i});const c=i.createRemainder(this.getSecret());i.splitUnits(s,c),r.metas.fusedTokenUnits=i.getTokenUnitsData(),a.tokenUnits=[r];const l=await this.createMolecule({sourceWallet:i,remainderWallet:c});l.fuseToken(i.tokenUnits,a),l.sign({bundle:this.getBundle()}),l.check();const u=await this.createMoleculeMutation({mutationClass:Y,molecule:l});return this.executeQuery(u)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const r=new N({secret:Kt(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(sa),i={cellSlug:e,pubkey:r.pubkey,encrypt:t},o=await s.execute({variables:i});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const r=new N({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:r}),i=await this.createMoleculeMutation({mutationClass:Fo,molecule:s});i.fillMolecule({meta:{encrypt:t?"true":"false"}});const o=await i.execute({});if(o.success()){const a=It.create(o.payload(),r);this.setAuthToken(a)}else throw new fs(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);return o}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:r=null,encrypt:s=!1}){if(this.$__serverSdkVersion<3)return this.log("warn","KnishIOClient::authorize() - Server SDK version does not require an authorization..."),null;e===null&&t&&(e=Kt(t)),r&&this.setCellSlug(r),this.$__authInProcess=!0;let i;return e?i=await this.requestProfileAuthToken({secret:e,encrypt:s}):i=await this.requestGuestAuthToken({cellSlug:r,encrypt:s}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(s),this.$__authInProcess=!1,i}setAuthToken(e){if(!e){this.log("info","KnishIOClient::setAuthToken() - authToken object is empty.");return}this.$__authTokenObjects[this.getUri()]=e,this.client().setAuthData(e.getAuthData()),this.$__authToken=e}getAuthToken(){return this.$__authToken}log(e,t){if(this.$__logging)switch(e){case"info":console.info(t);break;case"warn":console.warn(t);break;case"error":console.error(t);break;default:console.log(t)}}}return P.Atom=E,P.KnishIOClient=Ga,P.Meta=Ke,P.Molecule=Ae,P.Wallet=N,P.base64ToHex=hr,P.bufferToHexString=lr,P.charsetBaseConvert=ar,P.chunkSubstr=yt,P.generateBundleHash=De,P.generateSecret=Kt,P.hexStringToBuffer=ur,P.hexToBase64=cr,P.isHex=dr,P.randomString=Pt,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P}({});
|
|
528
528
|
//# sourceMappingURL=client.iife.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wishknish/knishio-client-js",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"productName": "Knish.IO Javascript SDK Client",
|
|
5
5
|
"description": "JavaScript implementation of the Knish.IO SDK to consume Knish.IO GraphQL APIs.",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
package/src/AtomMeta.js
CHANGED
|
@@ -47,6 +47,7 @@ License: https://github.com/WishKnish/KnishIO-Client-JS/blob/master/LICENSE
|
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
49
|
import PolicyMeta from './PolicyMeta'
|
|
50
|
+
import Meta from './Meta'
|
|
50
51
|
|
|
51
52
|
const USE_META_CONTEXT = false
|
|
52
53
|
const DEFAULT_META_CONTEXT = 'https://www.schema.org'
|
|
@@ -57,19 +58,19 @@ const DEFAULT_META_CONTEXT = 'https://www.schema.org'
|
|
|
57
58
|
export default class AtomMeta {
|
|
58
59
|
/**
|
|
59
60
|
*
|
|
60
|
-
* @param meta
|
|
61
|
+
* @param {object|array} meta
|
|
61
62
|
*/
|
|
62
|
-
constructor (meta =
|
|
63
|
-
this.meta = meta
|
|
63
|
+
constructor (meta = []) {
|
|
64
|
+
this.meta = Meta.normalizeMeta(meta)
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
*
|
|
68
|
-
* @param meta
|
|
69
|
+
* @param {object|array} meta
|
|
69
70
|
* @returns {AtomMeta}
|
|
70
71
|
*/
|
|
71
72
|
merge (meta) {
|
|
72
|
-
this.meta =
|
|
73
|
+
this.meta = Array.from(new Set([...this.meta, ...Meta.normalizeMeta(meta)]))
|
|
73
74
|
return this
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -180,7 +181,7 @@ export default class AtomMeta {
|
|
|
180
181
|
|
|
181
182
|
/**
|
|
182
183
|
*
|
|
183
|
-
* @returns {
|
|
184
|
+
* @returns {array}
|
|
184
185
|
*/
|
|
185
186
|
get () {
|
|
186
187
|
return this.meta
|
package/src/KnishIOClient.js
CHANGED
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
getFingerprint,
|
|
99
99
|
getFingerprintData
|
|
100
100
|
} from '@thumbmarkjs/thumbmarkjs'
|
|
101
|
-
import UrqlClientWrapper from
|
|
101
|
+
import UrqlClientWrapper from './libraries/urql/UrqlClientWrapper'
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Base client class providing a powerful but user-friendly wrapper
|
|
@@ -1236,8 +1236,8 @@ export default class KnishIOClient {
|
|
|
1236
1236
|
*
|
|
1237
1237
|
* @param {string} metaType - The type of the metadata entry.
|
|
1238
1238
|
* @param {string} metaId - The ID of the metadata entry.
|
|
1239
|
-
* @param {
|
|
1240
|
-
* @param {
|
|
1239
|
+
* @param {object|array} meta - The metadata object.
|
|
1240
|
+
* @param {object} [policy={}] - The policy object.
|
|
1241
1241
|
* @returns {Promise<ResponseCreateMeta>} - A Promise that resolves with the created metadata entry.
|
|
1242
1242
|
*/
|
|
1243
1243
|
async createMeta ({
|
package/src/Meta.js
CHANGED
|
@@ -57,14 +57,16 @@ export default class Meta {
|
|
|
57
57
|
* @return {array}
|
|
58
58
|
*/
|
|
59
59
|
static normalizeMeta (meta) {
|
|
60
|
-
|
|
60
|
+
// Ensuring that only object-based meta gets normalized
|
|
61
|
+
if (Array.isArray(meta)) {
|
|
62
|
+
return meta
|
|
63
|
+
}
|
|
61
64
|
|
|
65
|
+
// Converting object-based meta into array-based notation
|
|
66
|
+
const target = []
|
|
62
67
|
for (const property in meta) {
|
|
63
|
-
if (Object.prototype.hasOwnProperty.call(meta, property)
|
|
64
|
-
target.push({
|
|
65
|
-
key: property,
|
|
66
|
-
value: (meta[property]).toString()
|
|
67
|
-
})
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(meta, property)) {
|
|
69
|
+
target.push({ key: property, value: meta[property] })
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|