@wishknish/knishio-client-js 0.6.4 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs.js +513 -0
- package/dist/client.cjs.js.map +1 -0
- package/dist/client.es.mjs +8176 -0
- package/dist/client.es.mjs.map +1 -0
- package/dist/client.iife.js +30 -45
- package/dist/client.iife.js.map +1 -0
- package/package.json +48 -28
- package/src/Atom.js +132 -5
- package/src/AtomMeta.js +7 -8
- package/src/AuthToken.js +1 -1
- package/src/KnishIOClient.js +133 -76
- package/src/Meta.js +6 -2
- package/src/Molecule.js +289 -38
- package/src/PolicyMeta.js +1 -1
- package/src/Wallet.js +19 -11
- package/src/exception/AtomIndexException.js +1 -1
- package/src/exception/AtomsMissingException.js +1 -1
- package/src/exception/AuthorizationRejectedException.js +1 -1
- package/src/exception/BalanceInsufficientException.js +1 -1
- package/src/exception/BatchIdException.js +1 -1
- package/src/exception/CodeException.js +1 -1
- package/src/exception/DecryptionKeyException.js +1 -1
- package/src/exception/InvalidResponseException.js +1 -1
- package/src/exception/MetaMissingException.js +1 -1
- package/src/exception/MolecularHashMismatchException.js +1 -1
- package/src/exception/MolecularHashMissingException.js +1 -1
- package/src/exception/NegativeAmountException.js +1 -1
- package/src/exception/PolicyInvalidException.js +1 -1
- package/src/exception/SignatureMalformedException.js +1 -1
- package/src/exception/SignatureMismatchException.js +1 -1
- package/src/exception/StackableUnitAmountException.js +1 -1
- package/src/exception/StackableUnitDecimalsException.js +1 -1
- package/src/exception/TransferBalanceException.js +1 -1
- package/src/exception/TransferMalformedException.js +1 -1
- package/src/exception/TransferMismatchedException.js +1 -1
- package/src/exception/TransferRemainderException.js +1 -1
- package/src/exception/TransferToSelfException.js +1 -1
- package/src/exception/TransferUnbalancedException.js +1 -1
- package/src/exception/UnauthenticatedException.js +1 -1
- package/src/exception/WalletCredentialException.js +1 -1
- package/src/exception/WalletShadowException.js +1 -1
- package/src/exception/WrongTokenTypeException.js +1 -1
- package/src/exception/index.js +25 -25
- package/src/index.js +23 -9
- package/src/instance/Rules/Callback.js +5 -5
- package/src/instance/Rules/Condition.js +1 -1
- package/src/instance/Rules/Rule.js +4 -4
- package/src/instance/Rules/exception/RuleArgumentException.js +1 -1
- package/src/libraries/CheckMolecule.js +76 -24
- package/src/libraries/crypto.js +16 -2
- package/src/libraries/strings.js +1 -1
- package/src/libraries/urql/UrqlClientWrapper.js +3 -1
- package/src/mutation/Mutation.js +2 -2
- package/src/mutation/MutationActiveSession.js +2 -2
- package/src/mutation/MutationAppendRequest.js +91 -0
- package/src/mutation/MutationClaimShadowWallet.js +3 -3
- package/src/mutation/MutationCreateIdentifier.js +2 -2
- package/src/mutation/MutationCreateMeta.js +2 -2
- package/src/mutation/MutationCreateRule.js +2 -2
- package/src/mutation/MutationCreateToken.js +2 -2
- package/src/mutation/MutationCreateWallet.js +2 -2
- package/src/mutation/MutationDepositBufferToken.js +1 -1
- package/src/mutation/MutationLinkIdentifier.js +2 -2
- package/src/mutation/MutationPeering.js +82 -0
- package/src/mutation/MutationProposeMolecule.js +2 -2
- package/src/mutation/MutationRequestAuthorization.js +2 -2
- package/src/mutation/MutationRequestAuthorizationGuest.js +2 -2
- package/src/mutation/MutationRequestTokens.js +2 -2
- package/src/mutation/MutationTransferTokens.js +2 -2
- package/src/mutation/MutationWithdrawBufferToken.js +1 -1
- package/src/query/Query.js +2 -2
- package/src/query/QueryActiveSession.js +2 -2
- package/src/query/QueryAtom.js +2 -2
- package/src/query/QueryBalance.js +2 -2
- package/src/query/QueryBatch.js +2 -2
- package/src/query/QueryBatchHistory.js +3 -3
- package/src/query/QueryContinuId.js +2 -2
- package/src/query/QueryMetaType.js +11 -5
- package/src/query/QueryMetaTypeViaAtom.js +11 -4
- package/src/query/QueryPolicy.js +2 -2
- package/src/query/QueryToken.js +2 -2
- package/src/query/QueryUserActivity.js +2 -2
- package/src/query/QueryWalletBundle.js +2 -2
- package/src/query/QueryWalletList.js +2 -2
- package/src/response/Response.js +168 -4
- package/src/response/ResponseActiveSession.js +2 -2
- package/src/response/{ResponseMetaBatch.js → ResponseAppendRequest.js} +4 -21
- package/src/response/ResponseAtom.js +2 -2
- package/src/response/ResponseAuthorizationGuest.js +4 -4
- package/src/response/ResponseBalance.js +9 -4
- package/src/response/ResponseClaimShadowWallet.js +1 -1
- package/src/response/ResponseContinuId.js +3 -3
- package/src/response/ResponseCreateIdentifier.js +1 -1
- package/src/response/ResponseCreateMeta.js +1 -1
- package/src/response/ResponseCreateRule.js +1 -1
- package/src/response/ResponseCreateToken.js +1 -1
- package/src/response/ResponseCreateWallet.js +1 -1
- package/src/response/ResponseLinkIdentifier.js +3 -3
- package/src/response/ResponseMetaType.js +2 -2
- package/src/response/ResponseMetaTypeViaAtom.js +2 -2
- package/src/response/ResponsePeering.js +55 -0
- package/src/response/ResponsePolicy.js +2 -2
- package/src/response/ResponseProposeMolecule.js +3 -3
- package/src/response/ResponseQueryActiveSession.js +2 -2
- package/src/response/ResponseQueryUserActivity.js +2 -2
- package/src/response/ResponseRequestAuthorization.js +3 -3
- package/src/response/ResponseRequestAuthorizationGuest.js +3 -3
- package/src/response/ResponseRequestTokens.js +1 -1
- package/src/response/ResponseTransferTokens.js +1 -1
- package/src/response/ResponseWalletBundle.js +3 -3
- package/src/response/ResponseWalletList.js +4 -4
- package/src/subscribe/ActiveSessionSubscribe.js +1 -1
- package/src/subscribe/ActiveWalletSubscribe.js +1 -1
- package/src/subscribe/CreateMoleculeSubscribe.js +1 -1
- package/src/subscribe/Subscribe.js +1 -1
- package/src/subscribe/WalletStatusSubscribe.js +1 -1
- package/src/types/index.js +2 -2
- package/src/versions/Version4.js +1 -1
- package/src/versions/index.js +1 -1
package/dist/client.iife.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
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,_=[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),_[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(_[0],3609767458),new f(_[1],602891725),new f(_[2],3964484399),new f(_[3],2173295548),new f(_[4],4081628472),new f(_[5],3053834265),new f(_[6],2937671579),new f(_[7],3664609560),new f(_[8],2734883394),new f(_[9],1164996542),new f(_[10],1323610764),new f(_[11],3590304994),new f(_[12],4068182383),new f(_[13],991336113),new f(_[14],633803317),new f(_[15],3479774868),new f(_[16],2666613458),new f(_[17],944711139),new f(_[18],2341262773),new f(_[19],2007800933),new f(_[20],1495990901),new f(_[21],1856431235),new f(_[22],3175218132),new f(_[23],2198950837),new f(_[24],3999719339),new f(_[25],766784016),new f(_[26],2566594879),new f(_[27],3203337956),new f(_[28],1034457026),new f(_[29],2466948901),new f(_[30],3758326383),new f(_[31],168717936),new f(_[32],1188179964),new f(_[33],1546045734),new f(_[34],1522805485),new f(_[35],2643833823),new f(_[36],2343527390),new f(_[37],1014477480),new f(_[38],1206759142),new f(_[39],344077627),new f(_[40],1290863460),new f(_[41],3158454273),new f(_[42],3505952657),new f(_[43],106217008),new f(_[44],3606008344),new f(_[45],1432725776),new f(_[46],1467031594),new f(_[47],851169720),new f(_[48],3100823752),new f(_[49],1363258195),new f(_[50],3750685593),new f(_[51],3785050280),new f(_[52],3318307427),new f(_[53],3812723403),new f(_[54],2003034995),new f(_[55],3602036899),new f(_[56],1575990012),new f(_[57],1125592928),new f(_[58],2716904306),new f(_[59],442776044),new f(_[60],593698344),new f(_[61],3733110249),new f(_[62],2999351573),new f(_[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
|
-
`):
|
|
1
|
+
var KnishIOClient=(function(x,O,v,rn,rt){"use strict";var pr=Object.defineProperty;var fr=(x,O,v)=>O in x?pr(x,O,{enumerable:!0,configurable:!0,writable:!0,value:v}):x[O]=v;var z=(x,O,v)=>fr(x,typeof O!="symbol"?O+"":O,v);typeof self>"u"&&(global.self=global);class it{static toHex(e,t){const n=(c,u)=>{const l=u?["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 l[Math.floor(c/16)]+l[c%16]},s=Object.assign({grouping:0,rowlength:0,uppercase:!1},t||{});let r="",i=0,a=0;for(let c=0;c<e.length&&(r+=n(e[c],s.uppercase),c!==e.length-1);++c)s.grouping>0&&++i===s.grouping&&(i=0,s.rowlength>0&&++a===s.rowlength?(a=0,r+=`
|
|
2
|
+
`):r+=" ");return r}static toUint8Array(e){let t=e.toLowerCase().replace(/\s/g,"");t.length%2===1&&(t=`0${t}`);const n=new Uint8Array(Math.floor(t.length/2));let s=-1;for(let r=0;r<t.length;++r){const i=t[r],a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"].indexOf(i);if(a===-1)throw Error("unexpected character");s===-1?s=16*a:(n[Math.floor(r/2)]=s+a,s=-1)}return n}}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,(o,e)=>e.toUpperCase())}),String.prototype.toSnakeCase||(String.prototype.toSnakeCase=function(){return this.replace(/[A-Z]/g,o=>`_${o.toLowerCase()}`)});function fe(o,e){const t=Math.ceil(o.length/e),n=[];for(let s=0,r=0;s<t;++s,r+=e)n[s]=o.substr(r,e);return n}function Me(o=256,e="abcdef0123456789"){let t=new Uint8Array(o);return t=crypto.getRandomValues(t),t=t.map(n=>e.charCodeAt(n%e.length)),String.fromCharCode.apply(null,t)}function ot(o,e,t,n,s){if(n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?¿¡",s=s||n,e>n.length||t>s.length)return console.warn("Strings::charsetBaseConvert() - Can't convert",o,"to base",t,"greater than symbol table length. src-table:",n.length,"dest-table:",s.length),!1;let i=BigInt(0);for(let c=0;c<o.length;c++)i=i*BigInt(e)+BigInt(n.indexOf(o.charAt(c)));let a="";for(;i>0;){const c=i%BigInt(t);a=s.charAt(Number(c))+a,i/=BigInt(t)}return a||"0"}function at(o){return it.toHex(o,{})}function lt(o){return it.toUint8Array(o)}function ct(o){const e=lt(o);return btoa(String.fromCharCode.apply(null,e))}function ut(o){const e=new Uint8Array(atob(o).split("").map(t=>t.charCodeAt(0)));return at(e)}function Te(o){return/^[A-F0-9]+$/i.test(o)}function on(o){return(typeof o=="number"||typeof o=="string"&&o.trim()!=="")&&!isNaN(o)}let ne=class{static normalizeMeta(e){if(Array.isArray(e))return e.map(n=>({key:n.key,value:n.value==null?null:String(n.value)}));const t=[];for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=e[n];t.push({key:n,value:s==null?null:String(s)})}return t}static aggregateMeta(e){let t={};if(Array.isArray(e))for(const n of e)t[n.key]=n.value;else t=e;return t}};function an(...o){return[].concat(...o.map((e,t)=>{const n=o.slice(0);n.splice(t,1);const s=[...new Set([].concat(...n))];return e.filter(r=>!s.includes(r))}))}function me(...o){return o.reduce((e,t)=>e.filter(n=>t.includes(n)))}class De{constructor(e={},t={}){this.policy=De.normalizePolicy(e),this.fillDefault(t)}static normalizePolicy(e={}){const t={};for(const[n,s]of Object.entries(e))if(s!==null&&["read","write"].includes(n)){t[n]={};for(const[r,i]of Object.entries(s))t[n][r]=i}return t}fillDefault(e={}){const t=Array.from(this.policy).filter(s=>s.action==="read"),n=Array.from(this.policy).filter(s=>s.action==="write");for(const[s,r]of Object.entries({read:t,write:n})){const i=r.map(a=>a.key);this.policy[s]||(this.policy[s]={});for(const a of an(e,i))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 P{constructor(e=[]){this.meta=ne.normalizeMeta(e)}merge(e){return this.meta=Array.from(new Set([...this.meta,...ne.normalizeMeta(e)])),this}addContext(e=null){return this}setAtomWallet(e){const t={};return e.tokenUnits&&e.tokenUnits.length&&(t.tokenUnits=JSON.stringify(e.getTokenUnitsData())),e.tradeRates&&e.tradeRates.length&&(t.tradeRates=JSON.stringify(e.tradeRates)),Object.keys(t).length>0&&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 De(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class M extends TypeError{constructor(e=null,t=null,n=null){if(super(e,t,n),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 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),_r=(n,e,t)=>t>32?ri(n,e,t):ti(n,e,t),xr=(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=_r(l,u,1)^t[a],h=xr(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=_r(s,i,a),l=xr(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}}}}},_i=(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,xi=3303,$i=17,{mod:bt,nttZetas:Ii,NTT:Ve,bitsCoder:Ti}=Ai({N:re,Q:Qe,F:xi,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:_i,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 _t{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 _t({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 xt{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 _t))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 _t?e:_t.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 xt({});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)xt.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 xt?a:xt.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 _n 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 _n: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 xn 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,x;function F(n){return new xn(`Syntax Error: Unexpected token at ${x} in ${n}`)}function ue(n){if(n.lastIndex=x,n.test(O))return O.slice(x,x=n.lastIndex)}var Gt=/ +(?=[^\s])/y;function Wi(n){for(var e=n.split(`
|
|
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(x++);n===9||n===10||n===13||n===32||n===35||n===44||n===65279;n=0|O.charCodeAt(x++))if(n===35)for(;(n=O.charCodeAt(x++))!==10&&n!==13;);x--}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=x,O.charCodeAt(x)===91){x++,T();for(var r=[];O.charCodeAt(x)!==93;)r.push(Xt(n));return x++,T(),{kind:"ListValue",values:r}}else if(O.charCodeAt(x)===123){x++,T();for(var s=[];O.charCodeAt(x)!==125;){if((e=ue(te))==null||(T(),O.charCodeAt(x++)!==58))throw F("ObjectField");T(),s.push({kind:"ObjectField",name:{kind:"Name",value:e},value:Xt(n)})}return x++,T(),{kind:"ObjectValue",fields:s}}else if((t=$n.exec(O))!=null){if(x=$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(x)===40){var e=[];x++,T();var t;do{if((t=ue(te))==null||(T(),O.charCodeAt(x++)!==58))throw F("Argument");T(),e.push({kind:"Argument",name:{kind:"Name",value:t},value:Xt(n)})}while(O.charCodeAt(x)!==41);return x++,T(),e}}function nt(n){if(O.charCodeAt(x)===64){var e=[],t;do{if(x++,(t=ue(te))==null)throw F("Directive");T(),e.push({kind:"Directive",name:{kind:"Name",value:t},arguments:Lr(n)})}while(O.charCodeAt(x)===64);return e}}function ji(){for(var n,e=0;O.charCodeAt(x)===91;)e++,x++,T();if((n=ue(te))==null)throw F("NamedType");T();var t={kind:"NamedType",name:{kind:"Name",value:n}};do if(O.charCodeAt(x)===33&&(x++,T(),t={kind:"NonNullType",type:t}),e){if(O.charCodeAt(x++)!==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=x,(t=In.exec(O))!=null){if(x=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(x++)!==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(x)===58){if(x++,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(x)===123&&(x++,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(x)!==125);return x++,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(x++)!==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(x)===40){var i=[];x++,T();var o;do{if(O.charCodeAt(x++)!==36||(o=ue(te))==null)throw F("Variable");if(T(),O.charCodeAt(x++)!==58)throw F("VariableDefinition");T();var a=ji(),c=void 0;O.charCodeAt(x)===61&&(x++,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(x)!==41);return x++,T(),i}}(),r=nt(!1)),O.charCodeAt(x)===123)return x++,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 x=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(x<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
|
-
`+n.replace(/"""/g,'\\"""')+`
|
|
8
|
-
"""`}var _e=`
|
|
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+="("+(_e+=" ")+ie(n.arguments,_e,j.Argument)+(_e=_e.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,_e):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
|
-
|
|
11
|
-
`,Ne)},SelectionSet:n=>"{"+(_e+=" ")+ie(n.selections,_e,Ne)+(_e=_e.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 _e=`
|
|
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 xn(n.message,n.nodes,n.source,n.positions,n.path,n,n.extensions||{}):new xn(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
|
-
`):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!==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
|
-
`+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
|
-
\r
|
|
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
|
-
|
|
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}}),_o=()=>{};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",xo=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(xo)(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=_o;{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!) {
|
|
4
|
+
${this.stack}`}}class se extends M{constructor(e="The molecule does not contain atoms",t=null,n=null){super(e,t,n),this.name="AtomsMissingException"}}class re{static create(e){const t={};for(const n of Object.keys(e))Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return new this(t)}static structure(e){switch(Object.prototype.toString.call(e)){case"[object Array]":{const t=[];for(const n in e)t.push(re.isStructure(e[n])?re.structure(e[n]):e[n]);return t}case"[object Object]":{const t=[],n=Object.keys(e).sort((s,r)=>s===r?0:s<r?-1:1);for(const s of n)if(Object.prototype.hasOwnProperty.call(e,s)){const r={};r[s]=re.isStructure(e[s])?re.structure(e[s]):e[s],t.push(r)}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 re.structure(this)}}class ln extends re{constructor({position:e=null,walletAddress:t=null,isotope:n=null,token:s=null,value:r=null,batchId:i=null,metaType:a=null,metaId:c=null,meta:u=null,index:l=null,createdAt:h=null,version:p=null}){super(),this.position=e,this.walletAddress=t,this.isotope=n,this.token=s,this.value=r,this.batchId=i,this.metaType=a,this.metaId=c,this.meta=u,this.index=l,this.createdAt=h,this.version=p}}const Ce={4:ln};class g{constructor({position:e=null,walletAddress:t=null,isotope:n=null,token:s=null,value:r=null,batchId:i=null,metaType:a=null,metaId:c=null,meta:u=null,otsFragment:l=null,index:h=null,version:p=null}){this.position=e,this.walletAddress=t,this.isotope=n,this.token=s,this.value=r!==null?String(r):null,this.batchId=i,this.metaType=a,this.metaId=c,this.meta=u?ne.normalizeMeta(u):[],this.index=h,this.otsFragment=l,this.createdAt=String(+new Date),p!==null&&Object.prototype.hasOwnProperty.call(Ce,p)&&(this.version=String(p))}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:n=null,metaType:s=null,metaId:r=null,meta:i=null,batchId:a=null}){return i||(i=new P),i instanceof P||(i=new P(i)),t&&(i.setAtomWallet(t),a||(a=t.batchId)),new g({position:t?t.position:null,walletAddress:t?t.address:null,isotope:e,token:t?t.token:null,value:n,batchId:a,metaType:s,metaId:r,meta:i.get()})}static jsonToObject(e){const t=Object.assign(new g({}),JSON.parse(e)),n=Object.keys(new g({}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!n.includes(s)&&delete t[s];return t}toJSON(e={}){const{includeOtsFragments:t=!0,validateFields:n=!1}=e;try{if(n){const r=["position","walletAddress","isotope","token"];for(const i of r)if(!this[i])throw new Error(`Required field '${i}' is missing or empty`)}const s={position:this.position??"",walletAddress:this.walletAddress??"",isotope:this.isotope,token:this.token??"",value:this.value,batchId:this.batchId,metaType:this.metaType,metaId:this.metaId,meta:this.meta||[],index:this.index,createdAt:this.createdAt,version:this.version};return t&&this.otsFragment&&(s.otsFragment=this.otsFragment),s}catch(s){throw new Error(`Atom serialization failed: ${s.message}`)}}static fromJSON(e,t={}){const{validateStructure:n=!0,strictMode:s=!1}=t;try{const r=typeof e=="string"?JSON.parse(e):e;if(s||n){const a=["position","walletAddress","isotope","token"];for(const c of a)if(!r[c])throw new Error(`Required field '${c}' is missing or empty`)}const i=new g({position:r.position,walletAddress:r.walletAddress,isotope:r.isotope,token:r.token,value:r.value,batchId:r.batchId,metaType:r.metaType,metaId:r.metaId,meta:r.meta,index:r.index,version:r.version});return r.otsFragment&&(i.otsFragment=r.otsFragment),r.createdAt&&(i.createdAt=r.createdAt),i}catch(r){throw new Error(`Atom deserialization failed: ${r.message}`)}}static hashAtoms({atoms:e,output:t="base17"}){const n=new O("SHAKE256","TEXT"),s=g.sortAtoms(e);if(s.length===0)throw new se;if(s.map(r=>{if(!(r instanceof g))throw new se;return r}),s.every(r=>r.version&&Object.prototype.hasOwnProperty.call(Ce,r.version)))n.update(JSON.stringify(s.map(r=>Ce[r.version].create(r).view())));else{const r=String(e.length);let i=[];for(const a of s)i.push(r),i=i.concat(a.getHashableValues());for(const a of i)n.update(a)}switch(t){case"hex":return n.getHash("HEX",{outputLen:256});case"array":return n.getHash("ARRAYBUFFER",{outputLen:256});default:return ot(n.getHash("HEX",{outputLen:256}),16,17,"0123456789abcdef","0123456789abcdefg").padStart(64,"0")}}static jsonSerialization(e,t){if(!g.getUnclaimedProps().includes(e))return t}static sortAtoms(e){const t=[...e];return t.sort((n,s)=>n.index<s.index?-1:1),t}aggregatedMeta(){return ne.aggregateMeta(this.meta)}getHashableValues(){const e=[];for(const t of g.getHashableProps()){const n=this[t];if(!(n===null&&!["position","walletAddress"].includes(t)))if(t==="meta")for(const s of n)typeof s.value<"u"&&s.value!==null&&(e.push(String(s.key)),e.push(String(s.value)));else e.push(n===null?"":String(n))}return e}}function Ee(o=null,e=2048){if(o){const t=new O("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e*2})}else return Me(e)}function ie(o,e=null){const t=new O("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:256})}function Ve(o,e){const t=new O("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e})}function Oe({molecularHash:o=null,index:e=null}){return o!==null&&e!==null?ie(String(o)+String(e),"generateBatchId"):Me(64)}class ye{constructor(e,t,n){this.id=e,this.name=t,this.metas=n||{}}static createFromGraphQL(e){let t=e.metas||{};return t.length&&(t=JSON.parse(t),t||(t={})),new ye(e.id,e.name,t)}static createFromDB(e){return new ye(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 cn extends M{constructor(e="Attempting to create a wallet with no credentials (secret or bundle hash)",t=null,n=null){super(e,t,n),this.name="WalletCredentialException"}}const Re=BigInt(2**32-1),ht=BigInt(32);function un(o,e=!1){return e?{h:Number(o&Re),l:Number(o>>ht&Re)}:{h:Number(o>>ht&Re)|0,l:Number(o&Re)|0}}function hn(o,e=!1){const t=o.length;let n=new Uint32Array(t),s=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=un(o[r],e);[n[r],s[r]]=[i,a]}return[n,s]}const dn=(o,e,t)=>o<<t|e>>>32-t,pn=(o,e,t)=>e<<t|o>>>32-t,fn=(o,e,t)=>e<<t-32|o>>>64-t,mn=(o,e,t)=>o<<t-32|e>>>64-t;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function yn(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"}function dt(o,e=""){if(!Number.isSafeInteger(o)||o<0){const t=e&&`"${e}" `;throw new Error(`${t}expected integer >0, got ${o}`)}}function j(o,e,t=""){const n=yn(o),s=o==null?void 0:o.length,r=e!==void 0;if(!n||r&&s!==e){const i=t&&`"${t}" `,a=r?` of length ${e}`:"",c=n?`length=${s}`:`type=${typeof o}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return o}function pt(o,e=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(e&&o.finished)throw new Error("Hash#digest() has already been called")}function gn(o,e){j(o,void 0,"digestInto() output");const t=e.outputLen;if(o.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function ft(o){return new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4))}function mt(...o){for(let e=0;e<o.length;e++)o[e].fill(0)}const wn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bn(o){return o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255}function kn(o){for(let e=0;e<o.length;e++)o[e]=bn(o[e]);return o}const yt=wn?o=>o:kn;function gt(o,e={}){const t=(s,r)=>o(r).update(s).digest(),n=o(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=s=>o(s),Object.assign(t,e),Object.freeze(t)}function _n(o=32){const e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(e==null?void 0:e.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(o))}const We=o=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,o])}),Sn=BigInt(0),ge=BigInt(1),$n=BigInt(2),An=BigInt(7),vn=BigInt(256),xn=BigInt(113),wt=[],bt=[],kt=[];for(let o=0,e=ge,t=1,n=0;o<24;o++){[t,n]=[n,(2*t+3*n)%5],wt.push(2*(5*n+t)),bt.push((o+1)*(o+2)/2%64);let s=Sn;for(let r=0;r<7;r++)e=(e<<ge^(e>>An)*xn)%vn,e&$n&&(s^=ge<<(ge<<BigInt(r))-ge);kt.push(s)}const _t=hn(kt,!0),In=_t[0],Mn=_t[1],St=(o,e,t)=>t>32?fn(o,e,t):dn(o,e,t),$t=(o,e,t)=>t>32?mn(o,e,t):pn(o,e,t);function Tn(o,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=o[i]^o[i+10]^o[i+20]^o[i+30]^o[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,c=(i+2)%10,u=t[c],l=t[c+1],h=St(u,l,1)^t[a],p=$t(u,l,1)^t[a+1];for(let d=0;d<50;d+=10)o[i+d]^=h,o[i+d+1]^=p}let s=o[2],r=o[3];for(let i=0;i<24;i++){const a=bt[i],c=St(s,r,a),u=$t(s,r,a),l=wt[i];s=o[l],r=o[l+1],o[l]=c,o[l+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=o[i+a];for(let a=0;a<10;a++)o[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}o[0]^=In[n],o[1]^=Mn[n]}mt(t)}class qe{constructor(e,t,n,s=!1,r=24){z(this,"state");z(this,"pos",0);z(this,"posOut",0);z(this,"finished",!1);z(this,"state32");z(this,"destroyed",!1);z(this,"blockLen");z(this,"suffix");z(this,"outputLen");z(this,"enableXOF",!1);z(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=r,dt(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ft(this.state)}clone(){return this._cloneInto()}keccak(){yt(this.state32),Tn(this.state32,this.rounds),yt(this.state32),this.posOut=0,this.pos=0}update(e){pt(this),j(e);const{blockLen:t,state:n}=this,s=e.length;for(let r=0;r<s;){const i=Math.min(t-this.pos,s-r);for(let a=0;a<i;a++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){pt(this,!1),j(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,r=e.length;s<r;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return dt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gn(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,mt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:r,enableXOF:i}=this;return e||(e=new qe(t,n,s,i,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=s,e.enableXOF=i,e.destroyed=this.destroyed,e}}const At=(o,e,t,n={})=>gt(()=>new qe(e,o,t),n),Cn=At(6,136,32,We(8)),En=At(6,72,64,We(10)),vt=(o,e,t,n={})=>gt((s={})=>new qe(e,o,s.dkLen===void 0?t:s.dkLen,!0),n),On=vt(31,168,16,We(11)),xt=vt(31,136,32,We(12));function ze(o){if(!Number.isSafeInteger(o)||o<0||o>4294967295)throw new Error("wrong u32 integer:"+o);return o}function It(o){return ze(o),(o&o-1)===0&&o!==0}function Mt(o,e){ze(o);let t=0;for(let n=0;n<e;n++,o>>>=1)t=t<<1|o&1;return t}function Tt(o){return ze(o),31-Math.clz32(o)}function Ct(o){const e=o.length;if(e<2||!It(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);const t=Tt(e);for(let n=0;n<e;n++){const s=Mt(n,t);if(n<s){const r=o[n];o[n]=o[s],o[s]=r}}return o}const Et=(o,e)=>{const{N:t,roots:n,dit:s,invertButterflies:r=!1,skipStages:i=0,brp:a=!0}=e,c=Tt(t);if(!It(t))throw new Error("FFT: Polynomial size should be power of two");const u=s!==r;return l=>{if(l.length!==t)throw new Error("FFT: wrong Polynomial length");s&&a&&Ct(l);for(let h=0,p=1;h<c-i;h++){const d=s?h+1+i:c-h,w=1<<d,$=w>>1,E=t>>d;for(let m=0;m<t;m+=w)for(let y=0,b=p++;y<$;y++){const C=r?s?t-b:b:y*E,_=m+y,A=m+y+$,I=n[C],T=l[A],S=l[_];if(u){const K=o.mul(T,I);l[_]=o.add(S,K),l[A]=o.sub(S,K)}else r?(l[_]=o.add(T,S),l[A]=o.mul(o.sub(T,S),I)):(l[_]=o.add(S,T),l[A]=o.mul(o.sub(S,T),I))}}return!s&&a&&Ct(l),l}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Ot=_n;function Je(o,e){if(o.length!==e.length)return!1;let t=0;for(let n=0;n<o.length;n++)t|=o[n]^e[n];return t===0}function Rn(o){return Uint8Array.from(o)}function Ue(o,...e){const t=s=>typeof s=="number"?s:s.bytesLen,n=e.reduce((s,r)=>s+t(r),0);return{bytesLen:n,encode:s=>{const r=new Uint8Array(n);for(let i=0,a=0;i<e.length;i++){const c=e[i],u=t(c),l=typeof c=="number"?s[i]:c.encode(s[i]);j(l,u,o),r.set(l,a),typeof c!="number"&&l.fill(0),a+=u}return r},decode:s=>{j(s,n,o);const r=[];for(const i of e){const a=t(i),c=s.subarray(0,a);r.push(typeof i=="number"?c:i.decode(c)),s=s.subarray(a)}return r}}}function Ge(o,e){const t=e*o.bytesLen;return{bytesLen:t,encode:n=>{if(n.length!==e)throw new Error(`vecCoder.encode: wrong length=${n.length}. Expected: ${e}`);const s=new Uint8Array(t);for(let r=0,i=0;r<n.length;r++){const a=o.encode(n[r]);s.set(a,i),a.fill(0),i+=a.length}return s},decode:n=>{j(n,t);const s=[];for(let r=0;r<n.length;r+=o.bytesLen)s.push(o.decode(n.subarray(r,r+o.bytesLen)));return s}}}function X(...o){for(const e of o)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function Rt(o){return(1<<o)-1}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Wn=o=>{const{newPoly:e,N:t,Q:n,F:s,ROOT_OF_UNITY:r,brvBits:i}=o,a=(m,y=n)=>{const b=m%y|0;return(b>=0?b|0:y+b|0)|0},c=(m,y=n)=>{const b=a(m,y)|0;return(b>y>>1?b-y|0:b)|0};function u(){const m=e(t);for(let y=0;y<t;y++){const b=Mt(y,i),C=BigInt(r)**BigInt(b)%BigInt(n);m[y]=Number(C)|0}return m}const l=u(),h={add:(m,y)=>a((m|0)+(y|0))|0,sub:(m,y)=>a((m|0)-(y|0))|0,mul:(m,y)=>a((m|0)*(y|0))|0,inv:m=>{throw new Error("not implemented")}},p={N:t,roots:l,invertButterflies:!0,skipStages:1,brp:!1},d=Et(h,{dit:!1,...p}),w=Et(h,{dit:!0,...p});return{mod:a,smod:c,nttZetas:l,NTT:{encode:m=>d(m),decode:m=>{w(m);for(let y=0;y<m.length;y++)m[y]=a(s*m[y]);return m}},bitsCoder:(m,y)=>{const b=Rt(m),C=m*(t/8);return{bytesLen:C,encode:_=>{const A=new Uint8Array(C);for(let I=0,T=0,S=0,K=0;I<_.length;I++)for(T|=(y.encode(_[I])&b)<<S,S+=m;S>=8;S-=8,T>>=8)A[K++]=T&Rt(S);return A},decode:_=>{const A=e(t);for(let I=0,T=0,S=0,K=0;I<_.length;I++)for(T|=_[I]<<S,S+=8;S>=m;S-=m,T>>=m)A[K++]=y.decode(T&b);return A}}}}},qn=(o=>(e,t)=>{t||(t=o.blockLen);const n=new Uint8Array(e.length+2);n.set(e);const s=e.length,r=new Uint8Array(t);let i=o.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,l)=>(n[s+0]=u,n[s+1]=l,i.destroy(),i=o.create({}).update(n),a++,()=>(c++,i.xofInto(r))),clean:()=>{i.destroy(),X(r,n)}}})(On);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const N=256,oe=3329,Un=3303,Bn=17,{mod:we,nttZetas:Pn,NTT:ae,bitsCoder:Hn}=Wn({N,Q:oe,F:Un,ROOT_OF_UNITY:Bn,newPoly:o=>new Uint16Array(o),brvBits:7}),Kn={768:{N,Q:oe,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},Ln=o=>{if(o>=12)return{encode:t=>t,decode:t=>t};const e=2**(o-1);return{encode:t=>((t<<o)+oe/2)/oe,decode:t=>t*oe+e>>>o}},be=o=>Hn(o,Ln(o));function le(o,e){for(let t=0;t<N;t++)o[t]=we(o[t]+e[t])}function Nn(o,e){for(let t=0;t<N;t++)o[t]=we(o[t]-e[t])}function Fn(o,e,t,n,s){const r=we(e*n*s+o*t),i=we(o*n+e*t);return{c0:r,c1:i}}function Be(o,e){for(let t=0;t<N/2;t++){let n=Pn[64+(t>>1)];t&1&&(n=-n);const{c0:s,c1:r}=Fn(o[2*t+0],o[2*t+1],e[2*t+0],e[2*t+1],n);o[2*t+0]=s,o[2*t+1]=r}return o}function Wt(o){const e=new Uint16Array(N);for(let t=0;t<N;){const n=o();if(n.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<N&&s+3<=n.length;s+=3){const r=(n[s+0]>>0|n[s+1]<<8)&4095,i=(n[s+1]>>4|n[s+2]<<4)&4095;r<oe&&(e[t++]=r),t<N&&i<oe&&(e[t++]=i)}}return e}function ke(o,e,t,n){const s=o(n*N/4,e,t),r=new Uint16Array(N),i=ft(s);let a=0;for(let c=0,u=0,l=0,h=0;c<i.length;c++){let p=i[c];for(let d=0;d<32;d++)l+=p&1,p>>=1,a+=1,a===n?(h=l,l=0):a===2*n&&(r[u++]=we(h-l),l=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return r}const jn=o=>{const{K:e,PRF:t,XOF:n,HASH512:s,ETA1:r,ETA2:i,du:a,dv:c}=o,u=be(1),l=be(c),h=be(a),p=Ue("publicKey",Ge(be(12),e),32),d=Ge(be(12),e),w=Ue("ciphertext",Ge(h,e),l),$=Ue("seed",32,32);return{secretCoder:d,lengths:{secretKey:d.bytesLen,publicKey:p.bytesLen,cipherText:w.bytesLen},keygen:E=>{j(E,32,"seed");const m=new Uint8Array(33);m.set(E),m[32]=e;const y=s(m),[b,C]=$.decode(y),_=[],A=[];for(let S=0;S<e;S++)_.push(ae.encode(ke(t,C,S,r)));const I=n(b);for(let S=0;S<e;S++){const K=ae.encode(ke(t,C,e+S,r));for(let U=0;U<e;U++){const pe=Wt(I.get(U,S));le(K,Be(pe,_[U]))}A.push(K)}I.clean();const T={publicKey:p.encode([A,b]),secretKey:d.encode(_)};return X(b,C,_,A,m,y),T},encrypt:(E,m,y)=>{const[b,C]=p.decode(E),_=[];for(let U=0;U<e;U++)_.push(ae.encode(ke(t,y,U,r)));const A=n(C),I=new Uint16Array(N),T=[];for(let U=0;U<e;U++){const pe=ke(t,y,e+U,i),st=new Uint16Array(N);for(let Qe=0;Qe<e;Qe++){const dr=Wt(A.get(U,Qe));le(st,Be(dr,_[Qe]))}le(pe,ae.decode(st)),T.push(pe),le(I,Be(b[U],_[U])),X(st)}A.clean();const S=ke(t,y,2*e,i);le(S,ae.decode(I));const K=u.decode(m);return le(K,S),X(b,_,I,S),w.encode([T,K])},decrypt:(E,m)=>{const[y,b]=w.decode(E),C=d.decode(m),_=new Uint16Array(N);for(let A=0;A<e;A++)le(_,Be(C[A],ae.encode(y[A])));return Nn(b,ae.decode(_)),X(_,C,y),u.encode(b)}}};function Qn(o){const e=jn(o),{HASH256:t,HASH512:n,KDF:s}=o,{secretCoder:r,lengths:i}=e,a=Ue("secretKey",i.secretKey,i.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...i,seed:64,msg:c,msgRand:c,secretKey:a.bytesLen},keygen:(l=Ot(u))=>{j(l,u,"seed");const{publicKey:h,secretKey:p}=e.keygen(l.subarray(0,32)),d=t(h),w=a.encode([p,h,d,l.subarray(32)]);return X(p,d),{publicKey:h,secretKey:w}},getPublicKey:l=>{const[h,p]=a.decode(l);return Uint8Array.from(p)},encapsulate:(l,h=Ot(c))=>{j(l,i.publicKey,"publicKey"),j(h,c,"message");const p=l.subarray(0,384*o.K),d=r.encode(r.decode(Rn(p)));if(!Je(d,p))throw X(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");X(d);const w=n.create().update(h).update(t(l)).digest(),$=e.encrypt(l,h,w.subarray(32,64));return X(w.subarray(32)),{cipherText:$,sharedSecret:w.subarray(0,32)}},decapsulate:(l,h)=>{j(h,a.bytesLen,"secretKey"),j(l,i.cipherText,"cipherText");const p=a.bytesLen-96,d=p+32,w=t(h.subarray(p/2,d));if(!Je(w,h.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");const[$,E,m,y]=a.decode(h),b=e.decrypt(l,$),C=n.create().update(b).update(m).digest(),_=C.subarray(0,32),A=e.encrypt(E,b,C.subarray(32,64)),I=Je(l,A),T=s.create({dkLen:32}).update(y).update(l).digest();return X(b,A,I?T:_),I?_:T}}}function Dn(o,e,t){return xt.create({dkLen:o}).update(e).update(new Uint8Array([t])).digest()}const Xe=Qn({...{HASH256:Cn,HASH512:En,KDF:xt,XOF:qn,PRF:Dn},...Kn[768]});class k{constructor({secret:e=null,bundle:t=null,token:n="USER",address:s=null,position:r=null,batchId:i=null,characters:a=null}){this.token=n,this.balance=0,this.molecules={},this.key=null,this.privkey=null,this.pubkey=null,this.tokenUnits=[],this.tradeRates={},this.address=s,this.position=r,this.bundle=t,this.batchId=i,this.characters=a,e&&(this.bundle=this.bundle||ie(e,"Wallet::constructor"),this.position=this.position||k.generatePosition(),this.key=k.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||k.generateAddress(this.key),this.characters=this.characters||"BASE64",this.initializeMLKEM())}static create({secret:e=null,bundle:t=null,token:n,batchId:s=null,characters:r=null}){let i=null;if(!e&&!t)throw new cn;return e&&!t&&(i=k.generatePosition(),t=ie(e,"Wallet::create")),new k({secret:e,bundle:t,token:n,position:i,batchId:s,characters:r})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&Te(e)}static getTokenUnits(e){const t=[];return e.forEach(n=>{t.push(ye.createFromDB(n))}),t}static generateKey({secret:e,token:t,position:n}){const s=Te(e)?e:Ve(e,1024),r=Te(n)?n:Ve(n,256),a=BigInt(`0x${s}`)+BigInt(`0x${r}`),c=new O("SHAKE256","TEXT");c.update(a.toString(16)),t&&c.update(t);const u=new O("SHAKE256","TEXT");return u.update(c.getHash("HEX",{outputLen:8192})),u.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=fe(e,128),n=new O("SHAKE256","TEXT");for(const r in t){let i=t[r];for(let a=1;a<=16;a++){const c=new O("SHAKE256","TEXT");c.update(i),i=c.getHash("HEX",{outputLen:512})}n.update(i)}const s=new O("SHAKE256","TEXT");return s.update(n.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Me(e,"abcdef0123456789")}initializeMLKEM(){const e=Ee(this.key,128),t=new Uint8Array(64);for(let r=0;r<64;r++)t[r]=parseInt(e.substr(r*2,2),16);const{publicKey:n,secretKey:s}=Xe.keygen(t);this.pubkey=this.serializeKey(n),this.privkey=s}serializeKey(e){return btoa(String.fromCharCode.apply(null,e))}deserializeKey(e){const t=atob(e);return new Uint8Array(t.length).map((n,s)=>t.charCodeAt(s))}getTokenUnitsData(){const e=[];return this.tokenUnits.forEach(t=>{e.push(t.toData())}),e}splitUnits(e,t,n=null){if(e.length===0)return;const s=[],r=[];this.tokenUnits.forEach(i=>{e.includes(i.id)?s.push(i):r.push(i)}),this.tokenUnits=s,n!==null&&(n.tokenUnits=s),t.tokenUnits=r}createRemainder(e){const t=k.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:Oe({}))}async encryptMessage(e,t){const n=JSON.stringify(e),s=new TextEncoder().encode(n),r=this.deserializeKey(t),{cipherText:i,sharedSecret:a}=Xe.encapsulate(r),c=await this.encryptWithSharedSecret(s,a);return{cipherText:this.serializeKey(i),encryptedMessage:this.serializeKey(c)}}async decryptMessage(e){const{cipherText:t,encryptedMessage:n}=e;let s;try{s=Xe.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 r;try{r=this.deserializeKey(n)}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 i;try{i=await this.decryptWithSharedSecret(r,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",r),null}let a;try{a=new TextDecoder().decode(i)}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",r),console.info("Wallet::decryptMessage() - decrypted Uint8Array",i),null}return JSON.parse(a)}async encryptWithSharedSecret(e,t){const n=crypto.getRandomValues(new Uint8Array(12)),s={name:"AES-GCM",iv:n},r=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt"]),i=await crypto.subtle.encrypt(s,r,e),a=new Uint8Array(n.length+i.byteLength);return a.set(n),a.set(new Uint8Array(i),n.length),a}async decryptWithSharedSecret(e,t){const s={name:"AES-GCM",iv:e.slice(0,12)},r=await crypto.subtle.importKey("raw",t,{name:"AES-GCM"},!1,["decrypt"]),i=await crypto.subtle.decrypt(s,r,e.slice(12));return new Uint8Array(i)}}class _e extends M{constructor(e="There is an atom without an index",t=null,n=null){super(e,t,n),this.name="AtomIndexException"}}class Vn extends M{constructor(e="The molecular hash does not match",t=null,n=null){super(e,t,n),this.name="MolecularHashMismatchException"}}class zn extends M{constructor(e="The molecular hash is missing",t=null,n=null){super(e,t,n),this.name="MolecularHashMissingException"}}class qt extends M{constructor(e="",t=null,n=null){super(e,t,n),this.name="PolicyInvalidException"}}class Ut extends M{constructor(e="OTS malformed",t=null,n=null){super(e,t,n),this.name="SignatureMalformedException"}}class Jn extends M{constructor(e="One-time signature (OTS) does not match!",t=null,n=null){super(e,t,n),this.name="SignatureMismatchException"}}class ee extends M{constructor(e="Insufficient balance to make transfer",t=null,n=null){super(e,t,n),this.name="TransferBalanceException"}}class Bt extends M{constructor(e="Token transfer atoms are malformed",t=null,n=null){super(e,t,n),this.name="TransferMalformedException"}}class Pt extends M{constructor(e="Token slugs for wallets in transfer do not match!",t=null,n=null){super(e,t,n),this.name="TransferMismatchedException"}}class Ht extends M{constructor(e="Invalid remainder provided",t=null,n=null){super(e,t,n),this.name="TransferRemainderException"}}class Gn extends M{constructor(e="Sender and recipient(s) cannot be the same",t=null,n=null){super(e,t,n),this.name="TransferToSelfException"}}class Xn extends M{constructor(e="Token transfer atoms are unbalanced",t=null,n=null){super(e,t,n),this.name="TransferUnbalancedException"}}class Q extends M{constructor(e="Empty meta data.",t=null,n=null){super(e,t,n),this.name="MetaMissingException"}}class ce extends M{constructor(e="Wrong type of token for this isotope",t=null,n=null){super(e,t,n),this.name="WrongTokenTypeException"}}class Pe extends M{constructor(e="Incorrect BatchId",t=null,n=null){super(e,t,n),this.name="BatchIdException"}}class Kt{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 He extends M{constructor(e="An incorrect argument!",t=null,n=null){super(e,t,n),this.name="RuleArgumentException"}}class te extends M{constructor(e="Code exception",t=null,n=null){super(e,t,n),this.name="CodeException"}}class Se{constructor({action:e,metaType:t=null,metaId:n=null,meta:s=null,address:r=null,token:i=null,amount:a=null,comparison:c=null}){if(s&&(this.meta=s),!e)throw new He('Callback structure violated, missing mandatory "action" parameter.');this.__metaId=n,this.__metaType=t,this.__action=e,this.__address=r,this.__token=i,this.__amount=a,this.__comparison=c}set comparison(e){this.__comparison=e}set amount(e){if(!on(e))throw new te("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 Kt?e:Kt.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new Se({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 me(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return me(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return me(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return me(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return me(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Ze{constructor({key:e,value:t,comparison:n}){if([e,t,n].some(s=>!s))throw new He("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");this.__key=e,this.__value=t,this.__comparison=n}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 $e{constructor({condition:e=[],callback:t=[]}){for(const n of e)if(!(n instanceof Ze))throw new He;for(const n of t)if(!(n instanceof Se))throw new He;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Ze?e:Ze.toObject(e))}set callback(e){this.__callback.push(e instanceof Se?e:Se.toObject(e))}static toObject(e){if(!e.condition)throw new Q("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new Q("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new $e({});for(const n of e.condition)t.comparison=n;for(const n of e.callback)t.callback=n;return t}toJSON(){return{condition:this.__condition,callback:this.__callback}}}class R{static __init(e,t){this.arr=String(t).split("."),this.key=this.arr.shift();const n=Number(this.key);Number.isInteger(n)&&(this.key=n),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,n=null){return this.__init(e,t),this.__next?this.__nextKey===0?e[this.key]:this.get(e[this.key],this.arr.join("."),n):n}static set(e,t,n){const s=t.split(".");let r=e;const i=s.length-1;for(let u=0;u<i;u++){const l=s[u],h=Number(l),p=Number.isInteger(h);(p?h:l in r)||(r[p?h:l]=s[u+1].match(/^\d+$/)?[]:{}),r=r[p?h:l]}const a=s[i],c=Number(a);return r[Number.isInteger(c)?c:a]=n,e}}class Zn{constructor(e){if(e.molecularHash===null)throw new zn;if(!e.atoms.length)throw new se;for(const t of e.atoms)if(t.index===null)throw new _e;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.isotopeP()&&this.isotopeA()&&this.isotopeV(e)}continuId(){if(this.molecule.atoms[0].token==="USER"&&this.molecule.getIsotopes("I").length<1)throw new se("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"),n=t[t.length-1];if(e.batchId!==n.batchId)throw new Pe;for(const s of t)if(s.batchId===null)throw new Pe}return!0}throw new Pe}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new ce(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new _e(`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 ce(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new _e(`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 Q;if(t.token!=="USER")throw new ce(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const n=ne.aggregateMeta(t.meta);for(const s of e){let r=n[s];if(r){r=JSON.parse(r);for(const[i,a]of Object.entries(r))if(!e.includes(i)){if(!Object.keys(n).includes(i))throw new qt(`${i} is missing from the meta.`);for(const c of a)if(!k.isBundleHash(c)&&!["all","self"].includes(c))throw new qt(`${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 ce(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new _e(`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 Q(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new Q(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new ce(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new _e(`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 n=JSON.parse(t.policy);if(!Object.keys(n).every(s=>["read","write"].includes(s)))throw new Q("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const n=JSON.parse(t.rule);if(!Array.isArray(n))throw new Q("Check::isotopeR() - Incorrect rule format!");for(const s of n)$e.toObject(s);if(n.length<1)throw new Q("Check::isotopeR() - No rules!")}}return!0}isotopeP(){for(const e of this.molecule.getIsotopes("P")){if(e.token!=="USER")throw new ce(`Check::isotopeP() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);const t=e.aggregatedMeta();if(!Object.prototype.hasOwnProperty.call(t,"peerHost")||!t.peerHost)throw new Q('Check::isotopeP() - Required meta field "peerHost" is missing!')}return!0}isotopeA(){for(const e of this.molecule.getIsotopes("A")){if(e.token!=="USER")throw new ce(`Check::isotopeA() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(!e.metaType)throw new Q('Check::isotopeA() - Required field "metaType" is missing!');if(!e.metaId)throw new Q('Check::isotopeA() - Required field "metaId" is missing!');const t=e.aggregatedMeta();if(!Object.prototype.hasOwnProperty.call(t,"action")||!t.action)throw new Q('Check::isotopeA() - Required meta field "action" is missing!')}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const n=this.molecule.atoms[0];if(n.isotope==="V"&&t.length===2){const i=t[t.length-1];if(n.token!==i.token)throw new Pt;if(i.value<0)throw new Bt;return!0}let s=0,r=0;for(const i in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,i)){const a=this.molecule.atoms[i];if(a.isotope!=="V")continue;if(r=a.value*1,Number.isNaN(r))throw new TypeError('Invalid isotope "V" values');if(a.token!==n.token)throw new Pt;if(i>0){if(r<0)throw new Bt;if(a.walletAddress===n.walletAddress)throw new Gn}s+=r}if(s!==0)throw new Xn;if(e){if(r=n.value*1,Number.isNaN(r))throw new TypeError('Invalid isotope "V" values');const i=e.balance+r;if(i<0)throw new ee;if(i!==s)throw new Ht}else if(r!==0)throw new Ht;return!0}molecularHash(){if(this.molecule.molecularHash!==g.hashAtoms({atoms:this.molecule.atoms}))throw new Vn;return!0}ots(){const e=this.molecule.normalizedHash();let t=this.molecule.atoms.map(p=>p.otsFragment).reduce((p,d)=>p+d);if(t.length!==2048&&(t=ut(t),t.length!==2048))throw new Ut;const n=fe(t,128);let s="";for(const p in n){let d=n[p];for(let w=0,$=8+e[p];w<$;w++)d=new O("SHAKE256","TEXT").update(d).getHash("HEX",{outputLen:512});s+=d}const r=new O("SHAKE256","TEXT");r.update(s);const i=r.getHash("HEX",{outputLen:8192}),a=new O("SHAKE256","TEXT");a.update(i);const c=a.getHash("HEX",{outputLen:256}),u=this.molecule.atoms[0];let l=u.walletAddress;const h=R.get(u.aggregatedMeta(),"signingWallet");if(h&&(l=R.get(JSON.parse(h),"address")),c!==l)throw new Jn;return!0}}class Ae extends M{constructor(e="Insufficient balance for requested transfer",t=null,n=null){super(e,t,n),this.name="BalanceInsufficientException"}}class Lt extends M{constructor(e="Amount cannot be negative!",t=null,n=null){super(e,t,n),this.name="NegativeAmountException"}}class J{constructor({secret:e=null,bundle:t=null,sourceWallet:n=null,remainderWallet:s=null,cellSlug:r=null,version:i=null}){this.status=null,this.molecularHash=null,this.createdAt=String(+new Date),this.cellSlugOrigin=this.cellSlug=r,this.secret=e,this.bundle=t,this.sourceWallet=n,this.atoms=[],i!==null&&Object.prototype.hasOwnProperty.call(Ce,i)&&(this.version=String(i)),(s||n)&&(this.remainderWallet=s||k.create({secret:e,bundle:t,token:n.token,batchId:n.batchId,characters:n.characters}))}get cellSlugDelimiter(){return"."}static isotopeFilter(e,t){return Array.isArray(e)||(e=[e]),t.filter(n=>e.includes(n.isotope))}static generateNextAtomIndex(e){return e.length}static jsonToObject(e){const t=Object.assign(new J({}),JSON.parse(e)),n=Object.keys(new J({}));if(!Array.isArray(t.atoms))throw new se;for(const s in Object.keys(t.atoms)){t.atoms[s]=g.jsonToObject(JSON.stringify(t.atoms[s]));for(const r of["position","walletAddress","isotope"])if(t.atoms[s].isotope.toLowerCase()!=="r"&&(typeof t.atoms[s][r]>"u"||t.atoms[s][r]===null))throw new se("MolecularStructure::jsonToObject() - Required Atom properties are missing!")}for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!n.includes(s)&&delete t[s];return t.atoms=g.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},n=[],s=e.toLowerCase().split("");for(let r=0,i=s.length;r<i;++r){const a=s[r];typeof t[a]<"u"&&(n[r]=t[a])}return n}static normalize(e){let t=e.reduce((s,r)=>s+r);const n=t<0;for(;t<0||t>0;)for(const s of Object.keys(e))if((n?e[s]<8:e[s]>-8)&&(n?(++e[s],++t):(--e[s],--t),t===0))break;return e}getIsotopes(e){return J.isotopeFilter(e,this.atoms)}generateIndex(){return J.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=g.sortAtoms(this.atoms),this}addContinuIdAtom(){(!this.remainderWallet||this.remainderWallet.token!=="USER")&&(this.remainderWallet=k.create({secret:this.secret,bundle:this.bundle}));const e={};return this.sourceWallet&&this.sourceWallet.position&&(e.previousPosition=this.sourceWallet.position),this.remainderWallet.pubkey&&(e.pubkey=this.remainderWallet.pubkey),this.remainderWallet.characters&&(e.characters=this.remainderWallet.characters),this.addAtom(g.create({isotope:"I",wallet:this.remainderWallet,metaType:"walletBundle",metaId:this.remainderWallet.bundle,meta:new P(e)})),this}addPolicyAtom({metaType:e,metaId:t,meta:n={},policy:s={}}){const r=new P(n);r.addPolicy(s);const i=k.create({secret:this.secret,bundle:this.sourceWallet.bundle,token:"USER"});return this.addAtom(g.create({wallet:i,isotope:"R",metaType:e,metaId:t,meta:r})),this}fuseToken(e,t){const n=e.length;if(this.sourceWallet.balance-n<0)throw new Ae;return this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:-n})),this.addAtom(g.create({isotope:"F",wallet:t,value:1,metaType:"walletBundle",metaId:t.bundle})),this.addAtom(g.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-n,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}burnToken({amount:e,walletBundle:t=null}){if(e<0)throw new Lt("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new Ae;return this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:-e})),this.addAtom(g.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 Lt("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=k.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const n of t)this.remainderWallet.tokenUnits.push(n);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(g.create({isotope:"V",wallet:this.sourceWallet,value:this.sourceWallet.balance})),this.addAtom(g.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 Ae;return this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:-this.sourceWallet.balance})),this.addAtom(g.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle})),this.addAtom(g.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 Ae;const n=k.create({secret:this.secret,bundle:this.bundle,token:this.sourceWallet.token,batchId:this.sourceWallet.batchId});return n.tradeRates=t,this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:-this.sourceWallet.balance})),this.addAtom(g.create({isotope:"B",wallet:n,value:e,metaType:"walletBundle",metaId:this.sourceWallet.bundle})),this.addAtom(g.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 n=0;for(const[r,i]of Object.entries(e||{}))n+=i;if(this.sourceWallet.balance-n<0)throw new Ae;const s=new P;t&&s.setSigningWallet(t),this.addAtom(g.create({isotope:"B",wallet:this.sourceWallet,value:-this.sourceWallet.balance,meta:s,metaType:"walletBundle",metaId:this.sourceWallet.bundle}));for(const[r,i]of Object.entries(e||{}))this.addAtom(new g({isotope:"V",token:this.sourceWallet.token,value:i,batchId:this.sourceWallet.batchId?Oe({}):null,metaType:"walletBundle",metaId:r}));return this.addAtom(g.create({isotope:"B",wallet:this.remainderWallet,value:this.sourceWallet.balance-n,metaType:"walletBundle",metaId:this.remainderWallet.bundle})),this}initTokenCreation({recipientWallet:e,amount:t,meta:n}){const s=new P(n);return s.setMetaWallet(e),this.addAtom(g.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:n,policy:s={}}){const r=[];for(const a of n)r.push(a instanceof $e?a:$e.toObject(a));const i=new P({rule:JSON.stringify(r)});return i.addPolicy(s),this.addAtom(g.create({isotope:"R",wallet:this.sourceWallet,metaType:e,metaId:t,meta:i})),this.addContinuIdAtom(),this}initWalletCreation(e,t=null){t||(t=new P),t.setMetaWallet(e);const n=g.create({isotope:"C",wallet:this.sourceWallet,metaType:"wallet",metaId:e.address,meta:t,batchId:e.batchId});return this.addAtom(n),this.addContinuIdAtom(),this}initShadowWalletClaim(e){const t=new P().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:n}){const s={code:n,hash:ie(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(g.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new P(s)})),this.addContinuIdAtom(),this}initMeta({meta:e,metaType:t,metaId:n,policy:s}){return this.addAtom(g.create({isotope:"M",wallet:this.sourceWallet,metaType:t,metaId:n,meta:new P(e)})),s&&Object.keys(s).length>0&&this.addPolicyAtom({metaType:t,metaId:n,meta:e,policy:s}),this.addContinuIdAtom(),this}initPeering({host:e}){return this.addAtom(g.create({isotope:"P",wallet:this.sourceWallet,metaType:"walletBundle",metaId:this.bundle,meta:new P({peerHost:e})})),this.addContinuIdAtom(),this}initAppendRequest({metaType:e,metaId:t,action:n,meta:s={}}){return this.addAtom(g.create({isotope:"A",wallet:this.sourceWallet,metaType:e,metaId:t,meta:new P({action:n,...s})})),this.addContinuIdAtom(),this}initTokenRequest({token:e,amount:t,metaType:n,metaId:s,meta:r={},batchId:i=null}){return r.token=e,r.amount=String(t),this.addAtom(g.create({isotope:"T",wallet:this.sourceWallet,value:t,metaType:n,metaId:s,meta:new P(r),batchId:i})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(g.create({isotope:"U",wallet:this.sourceWallet,meta:new P(e)})),this.addContinuIdAtom(),this}sign({bundle:e=null,anonymous:t=!1,compressed:n=!0}){if(this.atoms.length===0||this.atoms.filter(d=>!(d instanceof g)).length!==0)throw new se;!t&&!this.bundle&&(this.bundle=e||ie(this.secret,"Molecule::sign")),this.molecularHash=g.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let r=s.position;const i=R.get(s.aggregatedMeta(),"signingWallet");if(i&&(r=R.get(JSON.parse(i),"position")),!r)throw new Ut("Signing wallet must have a position!");const a=k.generateKey({secret:this.secret,token:s.token,position:s.position}),c=fe(a,128),u=this.normalizedHash();let l="";for(const d in c){let w=c[d];for(let $=0,E=8-u[d];$<E;$++)w=new O("SHAKE256","TEXT").update(w).getHash("HEX",{outputLen:512});l+=w}n&&(l=ct(l));const h=fe(l,Math.ceil(l.length/this.atoms.length));let p=null;for(let d=0,w=h.length;d<w;d++)this.atoms[d].otsFragment=h[d],p=this.atoms[d].position;return p}cellSlugBase(){return(this.cellSlug||"").split(this.cellSlugDelimiter)[0]}toJSON(e={}){const{includeValidationContext:t=!1,includeOtsFragments:n=!0}=e;try{const s={status:this.status,molecularHash:this.molecularHash,createdAt:this.createdAt,cellSlug:this.cellSlug,bundle:this.bundle,atoms:this.atoms.map(r=>r.toJSON({includeOtsFragments:n}))};return t&&(s.cellSlugOrigin=this.cellSlugOrigin,s.version=this.version,this.sourceWallet&&(s.sourceWallet={address:this.sourceWallet.address,position:this.sourceWallet.position,token:this.sourceWallet.token,balance:this.sourceWallet.balance||0,bundle:this.sourceWallet.bundle,batchId:this.sourceWallet.batchId||null,characters:this.sourceWallet.characters||"BASE64",pubkey:this.sourceWallet.pubkey||null,tokenUnits:this.sourceWallet.tokenUnits||[],tradeRates:this.sourceWallet.tradeRates||{},molecules:this.sourceWallet.molecules||{}}),this.remainderWallet&&(s.remainderWallet={address:this.remainderWallet.address,position:this.remainderWallet.position,token:this.remainderWallet.token,balance:this.remainderWallet.balance||0,bundle:this.remainderWallet.bundle,batchId:this.remainderWallet.batchId||null,characters:this.remainderWallet.characters||"BASE64",pubkey:this.remainderWallet.pubkey||null,tokenUnits:this.remainderWallet.tokenUnits||[],tradeRates:this.remainderWallet.tradeRates||{},molecules:this.remainderWallet.molecules||{}})),s}catch(s){throw new Error(`Molecule serialization failed: ${s.message}`)}}static fromJSON(e,t={}){const{includeValidationContext:n=!1,validateStructure:s=!0}=t;try{const r=typeof e=="string"?JSON.parse(e):e;if(s&&(!r.molecularHash||!Array.isArray(r.atoms)))throw new Error("Invalid molecule data: missing molecularHash or atoms array");const i=new J({secret:null,bundle:r.bundle||null,cellSlug:r.cellSlug||null,version:r.version||null});return i.status=r.status,i.molecularHash=r.molecularHash,i.createdAt=r.createdAt||String(+new Date),i.cellSlugOrigin=r.cellSlugOrigin,Array.isArray(r.atoms)&&(i.atoms=r.atoms.map((a,c)=>{try{return g.fromJSON(a)}catch(u){throw new Error(`Failed to reconstruct atom ${c}: ${u.message}`)}})),n&&(r.sourceWallet&&(i.sourceWallet=new k({secret:null,token:r.sourceWallet.token,position:r.sourceWallet.position,bundle:r.sourceWallet.bundle,batchId:r.sourceWallet.batchId,characters:r.sourceWallet.characters}),i.sourceWallet.balance=r.sourceWallet.balance||0,i.sourceWallet.address=r.sourceWallet.address,r.sourceWallet.pubkey&&(i.sourceWallet.pubkey=r.sourceWallet.pubkey),i.sourceWallet.tokenUnits=r.sourceWallet.tokenUnits||[],i.sourceWallet.tradeRates=r.sourceWallet.tradeRates||{},i.sourceWallet.molecules=r.sourceWallet.molecules||{}),r.remainderWallet&&(i.remainderWallet=new k({secret:null,token:r.remainderWallet.token,position:r.remainderWallet.position,bundle:r.remainderWallet.bundle,batchId:r.remainderWallet.batchId,characters:r.remainderWallet.characters}),i.remainderWallet.balance=r.remainderWallet.balance||0,i.remainderWallet.address=r.remainderWallet.address,r.remainderWallet.pubkey&&(i.remainderWallet.pubkey=r.remainderWallet.pubkey),i.remainderWallet.tokenUnits=r.remainderWallet.tokenUnits||[],i.remainderWallet.tradeRates=r.remainderWallet.tradeRates||{},i.remainderWallet.molecules=r.remainderWallet.molecules||{})),i}catch(r){throw new Error(`Molecule deserialization failed: ${r.message}`)}}check(e=null){return new Zn(this).verify(e)}normalizedHash(){return J.normalize(J.enumerate(this.molecularHash))}}const Ye=10**18;class de{static val(e){return Math.abs(e*Ye)<1?0:e}static cmp(e,t,n=!1){const s=de.val(e)*Ye,r=de.val(t)*Ye;return Math.abs(s-r)<1?0:s>r?1:-1}static equal(e,t){return de.cmp(e,t)===0}}class ve{constructor({token:e,expiresAt:t,encrypt:n,pubkey:s}){this.$__token=e,this.$__expiresAt=t,this.$__pubkey=s,this.$__encrypt=n}static create(e,t){const n=new ve(e);return n.setWallet(t),n}static restore(e,t){const n=new k({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return ve.create({token:e.token,expiresAt:e.expiresAt,pubkey:e.pubkey,encrypt:e.encrypt},n)}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 ue extends M{constructor(e="GraphQL did not provide a valid response.",t=null,n=null){super(e,t,n),this.name="InvalidResponseException"}}class Ke extends M{constructor(e="Authorization token missing or invalid.",t=null,n=null){super(e,t,n),this.name="UnauthenticatedException"}}class W{constructor({query:e,json:t,dataKey:n=null}){if(this.dataKey=n,this.errorKey="exception",this.$__payload=null,this.$__query=e,this.$__originResponse=t,this.$__response=t,typeof this.$__response>"u"||this.$__response===null)throw new ue;if(R.has(this.$__response,this.errorKey)){const s=R.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new Ke:new ue}if(this.$__response.errors&&Array.isArray(this.$__response.errors)&&this.$__response.errors.length>0){const s=this.$__response.errors[0].message||"Unknown GraphQL error";throw s.includes("Unauthenticated")?new Ke:new ue(`GraphQL Error: ${s}`)}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!this.response().data)throw new ue("Response has no data field");if(!R.has(this.response(),this.dataKey))throw new ue(`Missing expected field: ${this.dataKey}`);return R.get(this.response(),this.dataKey)}response(){return this.$__response}payload(){return null}query(){return this.$__query}status(){return null}success(){var e,t;return!((t=(e=this.$__response)==null?void 0:e.errors)!=null&&t.length)}error(){var e,t;return(t=(e=this.$__response)==null?void 0:e.errors)!=null&&t.length?this.$__response.errors[0].message||"Unknown error":null}reason(){return this.error()}toValidationResult(){var e;return this.success()&&this.payload()!==null?{success:!0,data:this.payload(),warnings:[]}:{success:!1,error:{message:this.reason()||"Unknown error",context:this.constructor.name,details:((e=this.$__response)==null?void 0:e.errors)||[]}}}onSuccess(e){if(this.success()&&this.payload()!==null)try{e(this.payload())}catch(t){console.warn("Response.onSuccess callback failed:",t)}return this}onFailure(e){if(!this.success())try{e(this.reason()||"Unknown error")}catch(t){console.warn("Response.onFailure callback failed:",t)}return this}debug(e=null){var n,s,r;const t=e?`[${e}]`:`[${this.constructor.name}]`;return this.success()?console.debug(`${t} Success:`,{payload:this.payload(),query:(s=(n=this.$__query)==null?void 0:n.constructor)==null?void 0:s.name,dataKey:this.dataKey}):console.debug(`${t} Failure:`,{error:this.reason(),errors:(r=this.$__response)==null?void 0:r.errors,rawData:this.$__response}),this}toPromise(){return this.success()&&this.payload()!==null?Promise.resolve(this.payload()):Promise.reject(new Error(this.reason()||"Unknown error"))}map(e){if(this.success()&&this.payload()!==null)try{const t=e(this.payload()),n=Object.create(Object.getPrototypeOf(this));return Object.assign(n,this),n.$__payload=t,n}catch(t){const n=Object.create(Object.getPrototypeOf(this));return Object.assign(n,this),n.$__response={errors:[{message:`Mapping failed: ${t.message}`}]},n}else return this}}class F{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 W({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new te("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new te("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 n={...t,...this.createQueryContext()};try{const s=await this.client.query({...this.$__request,context:n});return this.$__response=await this.createResponseRaw(s),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Query was cancelled"),new W({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 Yn extends W{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 k({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}}class es extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query ($bundle: String!) {
|
|
21
5
|
ContinuId(bundle: $bundle) {
|
|
22
6
|
address,
|
|
23
7
|
bundleHash,
|
|
@@ -29,7 +13,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
29
13
|
amount,
|
|
30
14
|
createdAt
|
|
31
15
|
}
|
|
32
|
-
}`}createResponse(e){return new
|
|
16
|
+
}`}createResponse(e){return new Yn({query:this,json:e})}}class ts extends W{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(n=>{n.metas=ne.aggregateMeta(n.metas),t[n.bundleHash]=n}),t}}class ns extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $bundleHashes: [ String! ] ) {
|
|
33
17
|
WalletBundle( bundleHashes: $bundleHashes ) {
|
|
34
18
|
bundleHash,
|
|
35
19
|
metas {
|
|
@@ -41,7 +25,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
41
25
|
},
|
|
42
26
|
createdAt
|
|
43
27
|
}
|
|
44
|
-
}`}createResponse(e){return new
|
|
28
|
+
}`}createResponse(e){return new ts({query:this,json:e})}}class Le extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Wallet"})}static toClientWallet({data:e,secret:t=null}){let n;if(e.position===null||typeof e.position>"u"?n=k.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(n=new k({secret:t,token:e.tokenSlug,position:e.position,batchId:e.batchId,characters:e.characters}),n.address=e.address,n.bundle=e.bundleHash),e.token&&(n.tokenName=e.token.name,n.tokenAmount=e.token.amount,n.tokenSupply=e.token.supply,n.tokenFungibility=e.token.fungibility),e.tokenUnits.length)for(const s of e.tokenUnits)n.tokenUnits.push(ye.createFromGraphQL(s));if(e.tradeRates.length)for(const s of e.tradeRates)n.tradeRates[s.tokenSlug]=s.amount;return n.balance=Number(e.amount),n.pubkey=e.pubkey,n.createdAt=e.createdAt,n}getWallets(e=null){const t=this.data();if(!t)return null;const n=[];for(const s of t)n.push(Le.toClientWallet({data:s,secret:e}));return n}payload(){return this.getWallets()}}class ss extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $bundleHash: String, $tokenSlug: String ) {
|
|
45
29
|
Wallet( bundleHash: $bundleHash, tokenSlug: $tokenSlug ) {
|
|
46
30
|
address,
|
|
47
31
|
bundleHash,
|
|
@@ -68,7 +52,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
68
52
|
amount
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
|
-
}`}createResponse(e){return new
|
|
55
|
+
}`}createResponse(e){return new Le({query:this,json:e})}}class rs extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Balance"})}payload(){let e=this.data();return Array.isArray(e)&&(e=e.length>0?e[0]:null),!e||!e.bundleHash||!e.tokenSlug?null:Le.toClientWallet({data:e})}}class is extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
|
|
72
56
|
Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
|
|
73
57
|
address,
|
|
74
58
|
bundleHash,
|
|
@@ -90,8 +74,8 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
90
74
|
amount
|
|
91
75
|
}
|
|
92
76
|
}
|
|
93
|
-
}`}createResponse(e){return new
|
|
94
|
-
MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy ) {
|
|
77
|
+
}`}createResponse(e){return new rs({query:this,json:e})}}class os extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaType"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},n=e.pop();return n.instances&&(t.instances=n.instances),n.instanceCount&&(t.instanceCount=n.instanceCount),n.paginatorInfo&&(t.paginatorInfo=n.paginatorInfo),t}}class Nt extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String, $cellSlug: String ) {
|
|
78
|
+
MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy, cellSlug: $cellSlug ) {
|
|
95
79
|
metaType,
|
|
96
80
|
instanceCount {
|
|
97
81
|
key,
|
|
@@ -114,11 +98,11 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
114
98
|
total
|
|
115
99
|
}
|
|
116
100
|
}
|
|
117
|
-
}`}static createVariables({metaType:e=null,metaId:t=null,key:
|
|
101
|
+
}`}static createVariables({metaType:e=null,metaId:t=null,key:n=null,value:s=null,latest:r=null,filter:i=null,queryArgs:a=null,count:c=null,countBy:u=null,cellSlug:l=null}){const h={};return e&&(h[typeof e=="string"?"metaType":"metaTypes"]=e),t&&(h[typeof t=="string"?"metaId":"metaIds"]=t),n&&(h[typeof n=="string"?"key":"keys"]=n),s&&(h[typeof s=="string"?"value":"values"]=s),h.latest=r===!0,i&&(h.filter=i),a&&((typeof a.limit>"u"||a.limit===0)&&(a.limit="*"),h.queryArgs=a),c&&(h.count=c),u&&(h.countBy=u),l&&(h.cellSlug=l),h}createResponse(e){return new os({query:this,json:e})}}class xe extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $batchId: String ) {
|
|
118
102
|
Batch( batchId: $batchId ) {
|
|
119
|
-
${
|
|
103
|
+
${xe.getFields()},
|
|
120
104
|
children {
|
|
121
|
-
${
|
|
105
|
+
${xe.getFields()}
|
|
122
106
|
}
|
|
123
107
|
}
|
|
124
108
|
}`}static getFields(){return`batchId,
|
|
@@ -170,11 +154,11 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
170
154
|
throughMetas {
|
|
171
155
|
key,
|
|
172
156
|
value
|
|
173
|
-
}`}createResponse(e){const t=new
|
|
157
|
+
}`}createResponse(e){const t=new W({query:this,json:e});return t.dataKey="data.Batch",t}}class as extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $batchId: String ) {
|
|
174
158
|
BatchHistory( batchId: $batchId ) {
|
|
175
|
-
${
|
|
159
|
+
${xe.getFields()}
|
|
176
160
|
}
|
|
177
|
-
}`}createResponse(e){const t=new
|
|
161
|
+
}`}createResponse(e){const t=new W({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class D extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=R.get(this.data(),"payload");try{this.$__payload=Object.prototype.toString.call(e)==="[object String]"?JSON.parse(e):e}catch{this.$__payload=null}}clientMolecule(){return this.$__clientMolecule}molecule(){const e=this.data();if(!e)return null;const t=new J({});return t.molecularHash=R.get(e,"molecularHash"),t.status=R.get(e,"status"),t.createdAt=R.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return R.get(this.data(),"status","rejected")}reason(){return R.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class et extends F{createQuery({variables:e=null}){const t=super.createQuery({variables:e});return t.mutation=t.query,delete t.query,t}async execute({variables:e={},context:t={}}){this.$__request=this.createQuery({variables:e});const n={...t,...this.createQueryContext()};try{const s={...this.$__request,context:n},r=await this.client.mutate(s);return this.$__response=await this.createResponseRaw(r),this.$__response}catch(s){if(s.name==="AbortError")return this.knishIOClient.log("warn","Mutation was cancelled"),new W({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw s}}createQueryContext(){return{}}}class B extends et{constructor(e,t,n){super(e,t),this.$__molecule=n,this.$__remainderWallet=null,this.$__query=v.gql`mutation( $molecule: MoleculeInput! ) {
|
|
178
162
|
ProposeMolecule( molecule: $molecule ) {
|
|
179
163
|
molecularHash,
|
|
180
164
|
height,
|
|
@@ -187,13 +171,13 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
187
171
|
processedAt,
|
|
188
172
|
broadcastedAt,
|
|
189
173
|
}
|
|
190
|
-
}`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new
|
|
174
|
+
}`}compiledVariables(e){return{...super.compiledVariables(e),molecule:this.molecule()}}createResponse(e){return new D({query:this,json:e})}async execute({variables:e=null}){return e=e||{},e.molecule=this.molecule(),super.execute({variables:e})}remainderWallet(){return this.$__remainderWallet}molecule(){return this.$__molecule}}class ls extends D{payloadKey(e){if(!R.has(this.payload(),e))throw new ue(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return R.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}encrypt(){return this.payloadKey("encrypt")}pubKey(){return this.payloadKey("key")}}class cs extends B{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ls({query:this,json:e})}}class us extends D{}class hs extends B{fillMolecule({recipientWallet:e,amount:t,meta:n=null}){this.$__molecule.initTokenCreation({recipientWallet:e,amount:t,meta:n||{}}),this.$__molecule.sign({bundle:e.bundle}),this.$__molecule.check()}createResponse(e){return new us({query:this,json:e})}}class ds extends D{}class ps extends B{fillMolecule({token:e,amount:t,metaType:n,metaId:s,meta:r=null,batchId:i=null}){this.$__molecule.initTokenRequest({token:e,amount:t,metaType:n,metaId:s,meta:r||{},batchId:i}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ds({query:this,json:e})}}class fs extends D{payload(){const e={reason:null,status:null},t=this.data();return e.reason=typeof t.reason>"u"?"Invalid response from server":t.reason,e.status=typeof t.status>"u"?"rejected":t.status,e}}class ms extends B{fillMolecule({recipientWallet:e,amount:t}){this.$__molecule.initValue({recipientWallet:e,amount:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}createResponse(e){return new fs({query:this,json:e})}}class ys extends D{}class gs extends B{fillMolecule({type:e,contact:t,code:n}){this.$__molecule.initIdentifierCreation({type:e,contact:t,code:n}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ys({query:this,json:e})}}class ws extends D{}class bs extends B{fillMolecule({token:e,batchId:t=null}){const n=k.create({secret:this.$__molecule.secret,bundle:this.$__molecule.bundle,token:e,batchId:t});this.$__molecule.initShadowWalletClaim(n),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ws({query:this,json:e})}}class ks extends D{}class _s extends B{fillMolecule({metaType:e,metaId:t,meta:n,policy:s}){this.$__molecule.initMeta({meta:n,metaType:e,metaId:t,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ks({query:this,json:e})}}class Ft extends D{}class jt extends B{fillMolecule({host:e}){this.$__molecule.initPeering({host:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Ft({query:this,json:e})}}class Qt extends D{}class Dt extends B{fillMolecule({metaType:e,metaId:t,action:n,meta:s={}}){this.$__molecule.initAppendRequest({metaType:e,metaId:t,action:n,meta:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Qt({query:this,json:e})}}class Ss extends D{}class $s extends B{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Ss({query:this,json:e})}}class As extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.AccessToken"})}reason(){return"Invalid response from server"}success(){return this.payload()!==null}payload(){return this.data()}payloadKey(e){if(!R.has(this.payload(),e))throw new ue(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return R.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}pubKey(){return this.payloadKey("key")}encrypt(){return this.payloadKey("encrypt")}}class vs extends et{constructor(e,t){super(e,t),this.$__query=v.gql`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
|
|
191
175
|
AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
|
|
192
176
|
token,
|
|
193
177
|
pubkey,
|
|
194
178
|
expiresAt
|
|
195
179
|
}
|
|
196
|
-
}`}createResponse(e){return new
|
|
180
|
+
}`}createResponse(e){return new As({query:this,json:e})}}class Vt extends M{constructor(e="The shadow wallet does not exist",t=null,n=null){super(e,t,n),this.name="WalletShadowException"}}class xs extends M{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,n=null){super(e,t,n),this.name="StackableUnitDecimalsException"}}class Ne extends M{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,n=null){super(e,t,n),this.name="StackableUnitAmountException"}}class Fe{constructor(e){this.client=e,this.$__variables=null,this.$__subscribe=null}createSubscribe({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new te("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new te("Subscribe::createSubscribe() - GraphQL subscription was not initialized!");return{query:this.$__subscribe,variables:this.variables(),fetchPolicy:"no-cache"}}async execute({variables:e=null,closure:t}){if(!t)throw new te(`${this.constructor.name}::execute() - closure parameter is required!`);return this.$__request=this.createSubscribe({variables:e}),this.client.subscribe(this.$__request,t)}compiledVariables(e=null){return e||{}}uri(){return this.client.getUri()}variables(){return this.$__variables}}class Is extends Fe{constructor(e){super(e),this.$__subscribe=v.gql`
|
|
197
181
|
subscription onCreateMolecule ( $bundle: String! ) {
|
|
198
182
|
CreateMolecule( bundle: $bundle ) {
|
|
199
183
|
molecularHash,
|
|
@@ -238,7 +222,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
238
222
|
}
|
|
239
223
|
}
|
|
240
224
|
}
|
|
241
|
-
`}}class
|
|
225
|
+
`}}class Ms extends Fe{constructor(e){super(e),this.$__subscribe=v.gql`
|
|
242
226
|
subscription onWalletStatus ( $bundle: String!, $token: String! ) {
|
|
243
227
|
WalletStatus( bundle: $bundle, token: $token ) {
|
|
244
228
|
bundle,
|
|
@@ -247,7 +231,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
247
231
|
balance,
|
|
248
232
|
}
|
|
249
233
|
}
|
|
250
|
-
`}}class
|
|
234
|
+
`}}class Ts extends Fe{constructor(e){super(e),this.$__subscribe=v.gql`
|
|
251
235
|
subscription onActiveWallet ( $bundle: String! ) {
|
|
252
236
|
ActiveWallet( bundle: $bundle ) {
|
|
253
237
|
address,
|
|
@@ -285,7 +269,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
285
269
|
}
|
|
286
270
|
}
|
|
287
271
|
}
|
|
288
|
-
`}}class
|
|
272
|
+
`}}class Cs extends Fe{constructor(e){super(e),this.$__subscribe=v.gql`
|
|
289
273
|
subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
|
|
290
274
|
ActiveUser( metaType: $metaType, metaId: $metaId ) {
|
|
291
275
|
bundleHash,
|
|
@@ -295,7 +279,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
295
279
|
createdAt,
|
|
296
280
|
updatedAt
|
|
297
281
|
}
|
|
298
|
-
}`}}class
|
|
282
|
+
}`}}class Es extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class Os extends et{constructor(e,t){super(e,t),this.$__query=v.gql`mutation(
|
|
299
283
|
$bundleHash: String!,
|
|
300
284
|
$metaType: String!,
|
|
301
285
|
$metaId: String!,
|
|
@@ -323,7 +307,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
323
307
|
createdAt,
|
|
324
308
|
updatedAt
|
|
325
309
|
}
|
|
326
|
-
}`}createResponse(e){return new
|
|
310
|
+
}`}createResponse(e){return new Es({query:this,json:e})}}class Rs extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveUser"})}payload(){const e=this.data();if(!e)return null;const t=[];for(const n of e){const s={...n};s.jsonData&&(s.jsonData=JSON.parse(s.jsonData)),s.createdAt&&(s.createdAt=new Date(s.createdAt)),s.updatedAt&&(s.updatedAt=new Date(s.updatedAt)),t.push(s)}return t}}class Ws extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
|
|
327
311
|
ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
|
|
328
312
|
bundleHash,
|
|
329
313
|
metaType,
|
|
@@ -332,7 +316,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
332
316
|
createdAt,
|
|
333
317
|
updatedAt
|
|
334
318
|
}
|
|
335
|
-
}`}createResponse(e){return new
|
|
319
|
+
}`}createResponse(e){return new Rs({query:this,json:e})}}class qs extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.UserActivity"})}payload(){const e=JSON.parse(JSON.stringify(this.data()));if(e.instances)for(const t of e.instances)t.jsonData=JSON.parse(t.jsonData);return e}}class Us extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query UserActivity (
|
|
336
320
|
$bundleHash:String,
|
|
337
321
|
$metaType: String,
|
|
338
322
|
$metaId: String,
|
|
@@ -405,7 +389,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
405
389
|
}
|
|
406
390
|
}
|
|
407
391
|
}
|
|
408
|
-
}`}createResponse(e){return new
|
|
392
|
+
}`}createResponse(e){return new qs({query:this,json:e})}}class Bs extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
|
|
409
393
|
Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
|
|
410
394
|
slug,
|
|
411
395
|
name,
|
|
@@ -415,7 +399,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
415
399
|
amount,
|
|
416
400
|
icon,
|
|
417
401
|
}
|
|
418
|
-
}`}createResponse(e){return new
|
|
402
|
+
}`}createResponse(e){return new W({query:this,json:e,dataKey:"data.Token"})}}class zt extends M{constructor(e="Authorization attempt rejected by ledger.",t=null,n=null){super(e,t,n),this.name="AuthorizationRejectedException"}}class Ps extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.Atom"})}payload(){const e=this.data();if(!e)return null;const t={instances:[],instanceCount:{},paginatorInfo:{}};if(e.instances){t.instances=e.instances;for(const n in t.instances){const s=t.instances[n];s.metasJson&&(t.instances[n].metas=JSON.parse(s.metasJson))}}return e.instanceCount&&(t.instanceCount=e.instanceCount),e.paginatorInfo&&(t.paginatorInfo=e.paginatorInfo),t}metas(){const e=this.payload(),t=[];if(e&&e.instances)for(const n of e.instances)n.metasJson&&t.push(JSON.parse(n.metasJson));return t}}class Jt extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query(
|
|
419
403
|
$molecularHashes: [String!],
|
|
420
404
|
$bundleHashes: [String!],
|
|
421
405
|
$positions:[String!],
|
|
@@ -471,7 +455,7 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
471
455
|
total
|
|
472
456
|
}
|
|
473
457
|
}
|
|
474
|
-
}`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:
|
|
458
|
+
}`}static createVariables({molecularHashes:e,molecularHash:t,bundleHashes:n,bundleHash:s,positions:r,position:i,walletAddresses:a,walletAddress:c,isotopes:u,isotope:l,tokenSlugs:h,tokenSlug:p,cellSlugs:d,cellSlug:w,batchIds:$,batchId:E,values:m,value:y,metaTypes:b,metaType:C,metaIds:_,metaId:A,indexes:I,index:T,filter:S,latest:K,queryArgs:U}){return t&&(e=e||[],e.push(t)),s&&(n=n||[],n.push(s)),i&&(r=r||[],r.push(i)),c&&(a=a||[],a.push(c)),l&&(u=u||[],u.push(l)),p&&(h=h||[],h.push(p)),w&&(d=d||[],d.push(w)),E&&($=$||[],$.push(E)),y&&(m=m||[],m.push(y)),C&&(b=b||[],b.push(C)),A&&(_=_||[],_.push(A)),T&&(I=I||[],I.push(T)),{molecularHashes:e,bundleHashes:n,positions:r,walletAddresses:a,isotopes:u,tokenSlugs:h,cellSlugs:d,batchIds:$,values:m,metaTypes:b,metaIds:_,indexes:I,filter:S,latest:K,queryArgs:U}}createResponse(e){return new Ps({query:this,json:e})}}class Hs extends W{constructor({query:e,json:t}){super({query:e,json:t}),this.dataKey="data.Policy",this.init()}payload(){const e=this.data();return e&&e.callback?JSON.parse(e.callback):null}}class Ks extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query( $metaType: String, $metaId: String, ) {
|
|
475
459
|
Policy( metaType: $metaType, metaId: $metaId ) {
|
|
476
460
|
molecularHash,
|
|
477
461
|
position,
|
|
@@ -482,11 +466,12 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
482
466
|
rule,
|
|
483
467
|
createdAt
|
|
484
468
|
}
|
|
485
|
-
}`}createResponse(e){return new
|
|
469
|
+
}`}createResponse(e){return new Hs({query:this,json:e})}}class Ls extends W{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaTypeViaAtom"})}payload(){const e=this.data();if(!e||e.length===0)return null;const t={instances:{},instanceCount:{},paginatorInfo:{}},n=e.pop();return n.instances&&(t.instances=n.instances),n.instanceCount&&(t.instanceCount=n.instanceCount),n.paginatorInfo&&(t.paginatorInfo=n.paginatorInfo),t}}class Gt extends F{constructor(e,t){super(e,t),this.$__query=v.gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
486
470
|
MetaTypeViaAtom(
|
|
487
471
|
metaTypes: $metaTypes
|
|
488
472
|
metaIds: $metaIds
|
|
489
473
|
atomValues: $atomValues
|
|
474
|
+
cellSlugs: $cellSlugs
|
|
490
475
|
filter: $filter,
|
|
491
476
|
latest: $latest,
|
|
492
477
|
queryArgs: $queryArgs
|
|
@@ -514,15 +499,15 @@ ${this.stack}`}}class Fe extends q{constructor(e="The molecule does not contain
|
|
|
514
499
|
total
|
|
515
500
|
}
|
|
516
501
|
}
|
|
517
|
-
}`}static createVariables({metaType:e=null,metaId:t=null,key:r=null,value:s=null,keys:i=null,values:o=null,atomValues:a=null,latest:c=null,filter:l=null,queryArgs:u=null,countBy:d=null}){const h={};return a&&(h.atomValues=a),i&&(h.keys=i),o&&(h.values=o),e&&(h.metaTypes=typeof e=="string"?[e]:e),t&&(h.metaIds=typeof t=="string"?[t]:t),d&&(h.countBy=d),l&&(h.filter=l),r&&s&&(h.filter=h.filter||[],h.filter.push({key:r,value:s,comparison:"="})),h.latest=c===!0,u&&((typeof u.limit>"u"||u.limit===0)&&(u.limit="*"),h.queryArgs=u),h}createResponse(e){return new va({query:this,json:e})}}class ka extends xe{}class Sa extends Y{fillMolecule({metaType:e,metaId:t,rule:r,policy:s}){this.$__molecule.createRule({metaType:e,metaId:t,rule:r,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new ka({query:this,json:e})}}class Aa extends Y{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class _a extends Y{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function $e(n,e,t,r){return new(t||(t=Promise))(function(s,i){function o(l){try{c(r.next(l))}catch(u){i(u)}}function a(l){try{c(r.throw(l))}catch(u){i(u)}}function c(l){var u;l.done?s(l.value):(u=l.value,u instanceof t?u:new t(function(d){d(u)})).then(o,a)}c((r=r.apply(n,[])).next())})}function Ie(n,e){var t,r,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(t=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(s=o.trys,!((s=s.length>0&&s[s.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){o.label=u[1];break}if(u[0]===6&&o.label<s[1]){o.label=s[1],s=u;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(u);break}s[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(n,o)}catch(d){u=[6,d],r=0}finally{t=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}typeof SuppressedError=="function"&&SuppressedError;var z={exclude:[],include:[],logging:!0},ms={},xa={timeout:"true"},be=function(n,e){typeof window<"u"&&(ms[n]=e)},$a=function(){return Object.fromEntries(Object.entries(ms).filter(function(n){var e,t=n[0];return!(!((e=z?.exclude)===null||e===void 0)&&e.includes(t))}).filter(function(n){var e,t,r,s,i=n[0];return!((e=z?.include)===null||e===void 0)&&e.some(function(o){return o.includes(".")})?(t=z?.include)===null||t===void 0?void 0:t.some(function(o){return o.startsWith(i)}):((r=z?.include)===null||r===void 0?void 0:r.length)===0||((s=z?.include)===null||s===void 0?void 0:s.includes(i))}).map(function(n){return[n[0],(0,n[1])()]}))};function pn(n){return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),(n^=n>>>16)>>>0}var Z=new Uint32Array([597399067,2869860233,951274213,2716044179]);function fe(n,e){return n<<e|n>>>32-e}function Pn(n,e){var t;if(e===void 0&&(e=0),e=e?0|e:0,typeof n=="string"&&(t=n,n=new TextEncoder().encode(t).buffer),!(n instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var r=new Uint32Array([e,e,e,e]);(function(i,o){for(var a=i.byteLength/16|0,c=new Uint32Array(i,0,4*a),l=0;l<a;l++){var u=c.subarray(4*l,4*(l+1));u[0]=Math.imul(u[0],Z[0]),u[0]=fe(u[0],15),u[0]=Math.imul(u[0],Z[1]),o[0]=o[0]^u[0],o[0]=fe(o[0],19),o[0]=o[0]+o[1],o[0]=Math.imul(o[0],5)+1444728091,u[1]=Math.imul(u[1],Z[1]),u[1]=fe(u[1],16),u[1]=Math.imul(u[1],Z[2]),o[1]=o[1]^u[1],o[1]=fe(o[1],17),o[1]=o[1]+o[2],o[1]=Math.imul(o[1],5)+197830471,u[2]=Math.imul(u[2],Z[2]),u[2]=fe(u[2],17),u[2]=Math.imul(u[2],Z[3]),o[2]=o[2]^u[2],o[2]=fe(o[2],15),o[2]=o[2]+o[3],o[2]=Math.imul(o[2],5)+2530024501,u[3]=Math.imul(u[3],Z[3]),u[3]=fe(u[3],18),u[3]=Math.imul(u[3],Z[0]),o[3]=o[3]^u[3],o[3]=fe(o[3],13),o[3]=o[3]+o[0],o[3]=Math.imul(o[3],5)+850148119}})(n,r),function(i,o){var a=i.byteLength/16|0,c=i.byteLength%16,l=new Uint32Array(4),u=new Uint8Array(i,16*a,c);switch(c){case 15:l[3]=l[3]^u[14]<<16;case 14:l[3]=l[3]^u[13]<<8;case 13:l[3]=l[3]^u[12]<<0,l[3]=Math.imul(l[3],Z[3]),l[3]=fe(l[3],18),l[3]=Math.imul(l[3],Z[0]),o[3]=o[3]^l[3];case 12:l[2]=l[2]^u[11]<<24;case 11:l[2]=l[2]^u[10]<<16;case 10:l[2]=l[2]^u[9]<<8;case 9:l[2]=l[2]^u[8]<<0,l[2]=Math.imul(l[2],Z[2]),l[2]=fe(l[2],17),l[2]=Math.imul(l[2],Z[3]),o[2]=o[2]^l[2];case 8:l[1]=l[1]^u[7]<<24;case 7:l[1]=l[1]^u[6]<<16;case 6:l[1]=l[1]^u[5]<<8;case 5:l[1]=l[1]^u[4]<<0,l[1]=Math.imul(l[1],Z[1]),l[1]=fe(l[1],16),l[1]=Math.imul(l[1],Z[2]),o[1]=o[1]^l[1];case 4:l[0]=l[0]^u[3]<<24;case 3:l[0]=l[0]^u[2]<<16;case 2:l[0]=l[0]^u[1]<<8;case 1:l[0]=l[0]^u[0]<<0,l[0]=Math.imul(l[0],Z[0]),l[0]=fe(l[0],15),l[0]=Math.imul(l[0],Z[1]),o[0]=o[0]^l[0]}}(n,r),function(i,o){o[0]=o[0]^i.byteLength,o[1]=o[1]^i.byteLength,o[2]=o[2]^i.byteLength,o[3]=o[3]^i.byteLength,o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0,o[0]=pn(o[0]),o[1]=pn(o[1]),o[2]=pn(o[2]),o[3]=pn(o[3]),o[0]=o[0]+o[1]|0,o[0]=o[0]+o[2]|0,o[0]=o[0]+o[3]|0,o[1]=o[1]+o[0]|0,o[2]=o[2]+o[0]|0,o[3]=o[3]+o[0]|0}(n,r);var s=new Uint8Array(r.buffer);return Array.from(s).map(function(i){return i.toString(16).padStart(2,"0")}).join("")}function Ia(n,e){return new Promise(function(t){setTimeout(function(){return t(e)},n)})}function Ta(n,e,t){return Promise.all(n.map(function(r){return Promise.race([r,Ia(e,t)])}))}var Ea="0.19.1";function Ca(){return Ea}function gs(){return $e(this,void 0,void 0,function(){var n,e,t,r,s;return Ie(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=$a(),e=Object.keys(n),[4,Ta(Object.values(n),z?.timeout||1e3,xa)];case 1:return t=i.sent(),r=t.filter(function(o){return o!==void 0}),s={},r.forEach(function(o,a){s[e[a]]=o}),[2,ws(s,z.exclude||[],z.include||[],"")];case 2:throw i.sent();case 3:return[2]}})})}function ws(n,e,t,r){r===void 0&&(r="");for(var s={},i=function(l,u){var d=r+l+".";if(typeof u!="object"||Array.isArray(u)){var h=e.some(function(g){return d.startsWith(g)}),m=t.some(function(g){return d.startsWith(g)});h&&!m||(s[l]=u)}else{var y=ws(u,e,t,d);Object.keys(y).length>0&&(s[l]=y)}},o=0,a=Object.entries(n);o<a.length;o++){var c=a[o];i(c[0],c[1])}return s}function Ma(n){return $e(this,void 0,void 0,function(){var e,t;return Ie(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,gs()];case 1:return e=r.sent(),t=Pn(JSON.stringify(e)),Math.random()<.001&&z.logging&&function(s,i){$e(this,void 0,void 0,function(){var o,a;return Ie(this,function(c){switch(c.label){case 0:if(o="https://logging.thumbmarkjs.com/v1/log",a={thumbmark:s,components:i,version:Ca()},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:case 3:return c.sent(),[3,4];case 4:return[2]}})})}(t,e),[2,t.toString()];case 2:throw r.sent();case 3:return[2]}})})}function Oa(n){for(var e=0,t=0;t<n.length;++t)e+=Math.abs(n[t]);return e}function bs(n,e,t){for(var r=[],s=0;s<n[0].data.length;s++){for(var i=[],o=0;o<n.length;o++)i.push(n[o].data[s]);r.push(Na(i))}var a=new Uint8ClampedArray(r);return new ImageData(a,e,t)}function Na(n){if(n.length===0)return 0;for(var e={},t=0,r=n;t<r.length;t++)e[i=r[t]]=(e[i]||0)+1;var s=n[0];for(var i in e)e[i]>e[s]&&(s=parseInt(i,10));return s}function Nt(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var n=navigator.userAgent,e={Edg:"Edge",OPR:"Opera"},t=0,r=[/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/];t<r.length;t++){var s=r[t],i=n.match(s);if(i&&i.groups)return{name:e[i.groups.name]||i.groups.name,version:i.groups.version}}return{name:"unknown",version:"unknown"}}be("audio",function(){return $e(this,void 0,void 0,function(){return Ie(this,function(n){return[2,new Promise(function(e,t){try{var r=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),s=r.createBufferSource(),i=r.createOscillator();i.frequency.value=1e3;var o,a=r.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,i.connect(a),a.connect(r.destination),i.start(),r.oncomplete=function(c){o=c.renderedBuffer.getChannelData(0),e({sampleHash:Oa(o),oscillator:i.type,maxChannels:r.destination.maxChannelCount,channelCountMode:s.channelCountMode})},r.startRendering()}catch(c){console.error("Error creating audio fingerprint:",c),t(c)}})]})})});var Ra=Nt().name!=="SamsungBrowser"?1:3,vs=280,ks=20;Nt().name!="Firefox"&&be("canvas",function(){return document.createElement("canvas").getContext("2d"),new Promise(function(n){var e=Array.from({length:Ra},function(){return function(){var t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return new ImageData(1,1);t.width=vs,t.height=ks;var s=r.createLinearGradient(0,0,t.width,t.height);s.addColorStop(0,"red"),s.addColorStop(.16666666666666666,"orange"),s.addColorStop(.3333333333333333,"yellow"),s.addColorStop(.5,"green"),s.addColorStop(.6666666666666666,"blue"),s.addColorStop(.8333333333333334,"indigo"),s.addColorStop(1,"violet"),r.fillStyle=s,r.fillRect(0,0,t.width,t.height);var i="Random Text WMwmil10Oo";r.font="23.123px Arial",r.fillStyle="black",r.fillText(i,-5,15),r.fillStyle="rgba(0, 0, 255, 0.5)",r.fillText(i,-3.3,17.7),r.beginPath(),r.moveTo(0,0),r.lineTo(2*t.width/7,t.height),r.strokeStyle="white",r.lineWidth=2,r.stroke();var o=r.getImageData(0,0,t.width,t.height);return o}()});n({commonImageDataHash:Pn(bs(e,vs,ks).data.toString()).toString()})})});var Ln,Ua=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],qa=["monospace","sans-serif","serif"];function Ss(n,e){if(!n)throw new Error("Canvas context not supported");return n.font,n.font="72px ".concat(e),n.measureText("WwMmLli0Oo").width}function Ha(){var n,e=document.createElement("canvas"),t=(n=e.getContext("webgl"))!==null&&n!==void 0?n:e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{var r=(t.getParameter(t.VENDOR)||"").toString(),s=(t.getParameter(t.RENDERER)||"").toString(),i={vendor:r,renderer:s,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!s.length||!r.length){var o=t.getExtension("WEBGL_debug_renderer_info");if(o){var a=(t.getParameter(o.UNMASKED_VENDOR_WEBGL)||"").toString(),c=(t.getParameter(o.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(i.vendorUnmasked=a),c&&(i.rendererUnmasked=c)}}return i}catch{}return"undefined"}function Ba(){var n=new Float32Array(1),e=new Uint8Array(n.buffer);return n[0]=1/0,n[0]=n[0]-n[0],e[3]}function Pa(n,e){var t={};return e.forEach(function(r){var s=function(i){if(i.length===0)return null;var o={};i.forEach(function(l){var u=String(l);o[u]=(o[u]||0)+1});var a=i[0],c=1;return Object.keys(o).forEach(function(l){o[l]>c&&(a=l,c=o[l])}),a}(n.map(function(i){return r in i?i[r]:void 0}).filter(function(i){return i!==void 0}));s&&(t[r]=s)}),t}function La(){var n=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach(function(t){e[t].forEach(function(r){matchMedia("(".concat(t,": ").concat(r,")")).matches&&n.push("".concat(t,": ").concat(r))})}),n}function Ka(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var n=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(n(e))return e}catch{return 0}return 0}Nt().name!="Firefox"&&be("fonts",function(){var n=this;return new Promise(function(e,t){try{(function(r){var s;$e(this,void 0,void 0,function(){var i,o,a;return Ie(this,function(c){switch(c.label){case 0:return document.body?[3,2]:[4,(l=50,new Promise(function(d){return setTimeout(d,l,u)}))];case 1:return c.sent(),[3,0];case 2:if((i=document.createElement("iframe")).setAttribute("frameBorder","0"),(o=i.style).setProperty("position","fixed"),o.setProperty("display","block","important"),o.setProperty("visibility","visible"),o.setProperty("border","0"),o.setProperty("opacity","0"),i.src="about:blank",document.body.appendChild(i),!(a=i.contentDocument||((s=i.contentWindow)===null||s===void 0?void 0:s.document)))throw new Error("Iframe document is not accessible");return r({iframe:a}),setTimeout(function(){document.body.removeChild(i)},0),[2]}var l,u})})})(function(r){var s=r.iframe;return $e(n,void 0,void 0,function(){var i,o,a,c;return Ie(this,function(l){return i=s.createElement("canvas"),o=i.getContext("2d"),a=qa.map(function(u){return Ss(o,u)}),c={},Ua.forEach(function(u){var d=Ss(o,u);a.includes(d)||(c[u]=d)}),e(c),[2]})})})}catch{t({error:"unsupported"})}})}),be("hardware",function(){return new Promise(function(n,e){var t=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,r=window.performance&&window.performance.memory?window.performance.memory:0;n({videocard:Ha(),architecture:Ba(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:r.jsHeapSizeLimit||0})})}),be("locales",function(){return new Promise(function(n){n({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})})}),be("permissions",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){return Ln=z?.permissions_to_check||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],n=Array.from({length:z?.retries||3},function(){return function(){return $e(this,void 0,void 0,function(){var t,r,s,i,o;return Ie(this,function(a){switch(a.label){case 0:t={},r=0,s=Ln,a.label=1;case 1:if(!(r<s.length))return[3,6];i=s[r],a.label=2;case 2:return a.trys.push([2,4,,5]),[4,navigator.permissions.query({name:i})];case 3:return o=a.sent(),t[i]=o.state.toString(),[3,5];case 4:return a.sent(),[3,5];case 5:return r++,[3,1];case 6:return[2,t]}})})}()}),[2,Promise.all(n).then(function(t){return Pa(t,Ln)})]})})}),be("plugins",function(){var n=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var t=navigator.plugins[e];n.push([t.name,t.filename,t.description].join("|"))}return new Promise(function(r){r({plugins:n})})}),be("screen",function(){return new Promise(function(n){n({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:La()})})}),be("system",function(){return new Promise(function(n){var e=Nt();n({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:Ka()})})});var ne,Fa=Nt().name!=="SamsungBrowser"?1:3,$=null;be("webgl",function(){return $e(this,void 0,void 0,function(){var n;return Ie(this,function(e){typeof document<"u"&&((ne=document.createElement("canvas")).width=200,ne.height=100,$=ne.getContext("webgl"));try{if(!$)throw new Error("WebGL not supported");return n=Array.from({length:Fa},function(){return function(){try{if(!$)throw new Error("WebGL not supported");var t=`
|
|
502
|
+
}`}static createVariables({metaType:e=null,metaId:t=null,key:n=null,value:s=null,keys:r=null,values:i=null,atomValues:a=null,latest:c=null,filter:u=null,queryArgs:l=null,countBy:h=null,cellSlug:p=null}){const d={};return a&&(d.atomValues=a),r&&(d.keys=r),i&&(d.values=i),e&&(d.metaTypes=typeof e=="string"?[e]:e),t&&(d.metaIds=typeof t=="string"?[t]:t),p&&(d.cellSlugs=typeof p=="string"?[p]:p),h&&(d.countBy=h),u&&(d.filter=u),n&&s&&(d.filter=d.filter||[],d.filter.push({key:n,value:s,comparison:"="})),d.latest=c===!0,l&&((typeof l.limit>"u"||l.limit===0)&&(l.limit="*"),d.queryArgs=l),d}createResponse(e){return new Ls({query:this,json:e})}}class Ns extends D{}class Fs extends B{fillMolecule({metaType:e,metaId:t,rule:n,policy:s}){this.$__molecule.createRule({metaType:e,metaId:t,rule:n,policy:s}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Ns({query:this,json:e})}}class js extends B{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class Qs extends B{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function Z(o,e,t,n){return new(t||(t=Promise))((function(s,r){function i(u){try{c(n.next(u))}catch(l){r(l)}}function a(u){try{c(n.throw(u))}catch(l){r(l)}}function c(u){var l;u.done?s(u.value):(l=u.value,l instanceof t?l:new t((function(h){h(l)}))).then(i,a)}c((n=n.apply(o,[])).next())}))}function Y(o,e){var t,n,s,r,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(c){return function(u){return(function(l){if(t)throw new TypeError("Generator is already executing.");for(;r&&(r=0,l[0]&&(i=0)),i;)try{if(t=1,n&&(s=2&l[0]?n.return:l[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,l[1])).done)return s;switch(n=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(s=i.trys,!((s=s.length>0&&s[s.length-1])||l[0]!==6&&l[0]!==2)){i=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){i.label=l[1];break}if(l[0]===6&&i.label<s[1]){i.label=s[1],s=l;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(l);break}s[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(o,i)}catch(h){l=[6,h],n=0}finally{t=s=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}})([c,u])}}}typeof SuppressedError=="function"&&SuppressedError;var q={exclude:[],include:[],logging:!0},Xt={},Ds={timeout:"true"},G=function(o,e){typeof window<"u"&&(Xt[o]=e)},Vs=function(){return Object.fromEntries(Object.entries(Xt).filter((function(o){var e,t=o[0];return!(!((e=q==null?void 0:q.exclude)===null||e===void 0)&&e.includes(t))})).filter((function(o){var e,t,n,s,r=o[0];return!((e=q==null?void 0:q.include)===null||e===void 0)&&e.some((function(i){return i.includes(".")}))?(t=q==null?void 0:q.include)===null||t===void 0?void 0:t.some((function(i){return i.startsWith(r)})):((n=q==null?void 0:q.include)===null||n===void 0?void 0:n.length)===0||((s=q==null?void 0:q.include)===null||s===void 0?void 0:s.includes(r))})).map((function(o){return[o[0],(0,o[1])()]})))};function je(o){return o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),(o^=o>>>16)>>>0}var H=new Uint32Array([597399067,2869860233,951274213,2716044179]);function V(o,e){return o<<e|o>>>32-e}function tt(o,e){var t;if(e===void 0&&(e=0),e=e?0|e:0,typeof o=="string"&&(t=o,o=new TextEncoder().encode(t).buffer),!(o instanceof ArrayBuffer))throw new TypeError("Expected key to be ArrayBuffer or string");var n=new Uint32Array([e,e,e,e]);(function(r,i){for(var a=r.byteLength/16|0,c=new Uint32Array(r,0,4*a),u=0;u<a;u++){var l=c.subarray(4*u,4*(u+1));l[0]=Math.imul(l[0],H[0]),l[0]=V(l[0],15),l[0]=Math.imul(l[0],H[1]),i[0]=i[0]^l[0],i[0]=V(i[0],19),i[0]=i[0]+i[1],i[0]=Math.imul(i[0],5)+1444728091,l[1]=Math.imul(l[1],H[1]),l[1]=V(l[1],16),l[1]=Math.imul(l[1],H[2]),i[1]=i[1]^l[1],i[1]=V(i[1],17),i[1]=i[1]+i[2],i[1]=Math.imul(i[1],5)+197830471,l[2]=Math.imul(l[2],H[2]),l[2]=V(l[2],17),l[2]=Math.imul(l[2],H[3]),i[2]=i[2]^l[2],i[2]=V(i[2],15),i[2]=i[2]+i[3],i[2]=Math.imul(i[2],5)+2530024501,l[3]=Math.imul(l[3],H[3]),l[3]=V(l[3],18),l[3]=Math.imul(l[3],H[0]),i[3]=i[3]^l[3],i[3]=V(i[3],13),i[3]=i[3]+i[0],i[3]=Math.imul(i[3],5)+850148119}})(o,n),(function(r,i){var a=r.byteLength/16|0,c=r.byteLength%16,u=new Uint32Array(4),l=new Uint8Array(r,16*a,c);switch(c){case 15:u[3]=u[3]^l[14]<<16;case 14:u[3]=u[3]^l[13]<<8;case 13:u[3]=u[3]^l[12]<<0,u[3]=Math.imul(u[3],H[3]),u[3]=V(u[3],18),u[3]=Math.imul(u[3],H[0]),i[3]=i[3]^u[3];case 12:u[2]=u[2]^l[11]<<24;case 11:u[2]=u[2]^l[10]<<16;case 10:u[2]=u[2]^l[9]<<8;case 9:u[2]=u[2]^l[8]<<0,u[2]=Math.imul(u[2],H[2]),u[2]=V(u[2],17),u[2]=Math.imul(u[2],H[3]),i[2]=i[2]^u[2];case 8:u[1]=u[1]^l[7]<<24;case 7:u[1]=u[1]^l[6]<<16;case 6:u[1]=u[1]^l[5]<<8;case 5:u[1]=u[1]^l[4]<<0,u[1]=Math.imul(u[1],H[1]),u[1]=V(u[1],16),u[1]=Math.imul(u[1],H[2]),i[1]=i[1]^u[1];case 4:u[0]=u[0]^l[3]<<24;case 3:u[0]=u[0]^l[2]<<16;case 2:u[0]=u[0]^l[1]<<8;case 1:u[0]=u[0]^l[0]<<0,u[0]=Math.imul(u[0],H[0]),u[0]=V(u[0],15),u[0]=Math.imul(u[0],H[1]),i[0]=i[0]^u[0]}})(o,n),(function(r,i){i[0]=i[0]^r.byteLength,i[1]=i[1]^r.byteLength,i[2]=i[2]^r.byteLength,i[3]=i[3]^r.byteLength,i[0]=i[0]+i[1]|0,i[0]=i[0]+i[2]|0,i[0]=i[0]+i[3]|0,i[1]=i[1]+i[0]|0,i[2]=i[2]+i[0]|0,i[3]=i[3]+i[0]|0,i[0]=je(i[0]),i[1]=je(i[1]),i[2]=je(i[2]),i[3]=je(i[3]),i[0]=i[0]+i[1]|0,i[0]=i[0]+i[2]|0,i[0]=i[0]+i[3]|0,i[1]=i[1]+i[0]|0,i[2]=i[2]+i[0]|0,i[3]=i[3]+i[0]|0})(o,n);var s=new Uint8Array(n.buffer);return Array.from(s).map((function(r){return r.toString(16).padStart(2,"0")})).join("")}function zs(o,e){return new Promise((function(t){setTimeout((function(){return t(e)}),o)}))}function Js(o,e,t){return Promise.all(o.map((function(n){return Promise.race([n,zs(e,t)])})))}var Gs="0.19.1";function Xs(){return Gs}function Zt(){return Z(this,void 0,void 0,(function(){var o,e,t,n,s;return Y(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),o=Vs(),e=Object.keys(o),[4,Js(Object.values(o),(q==null?void 0:q.timeout)||1e3,Ds)];case 1:return t=r.sent(),n=t.filter((function(i){return i!==void 0})),s={},n.forEach((function(i,a){s[e[a]]=i})),[2,Yt(s,q.exclude||[],q.include||[],"")];case 2:throw r.sent();case 3:return[2]}}))}))}function Yt(o,e,t,n){n===void 0&&(n="");for(var s={},r=function(u,l){var h=n+u+".";if(typeof l!="object"||Array.isArray(l)){var p=e.some((function($){return h.startsWith($)})),d=t.some((function($){return h.startsWith($)}));p&&!d||(s[u]=l)}else{var w=Yt(l,e,t,h);Object.keys(w).length>0&&(s[u]=w)}},i=0,a=Object.entries(o);i<a.length;i++){var c=a[i];r(c[0],c[1])}return s}function Zs(o){return Z(this,void 0,void 0,(function(){var e,t;return Y(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,Zt()];case 1:return e=n.sent(),t=tt(JSON.stringify(e)),Math.random()<.001&&q.logging&&(function(s,r){Z(this,void 0,void 0,(function(){var i,a;return Y(this,(function(c){switch(c.label){case 0:if(i="https://logging.thumbmarkjs.com/v1/log",a={thumbmark:s,components:r,version:Xs()},sessionStorage.getItem("_tmjs_l"))return[3,4];sessionStorage.setItem("_tmjs_l","1"),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:case 3:return c.sent(),[3,4];case 4:return[2]}}))}))})(t,e),[2,t.toString()];case 2:throw n.sent();case 3:return[2]}}))}))}function Ys(o){for(var e=0,t=0;t<o.length;++t)e+=Math.abs(o[t]);return e}function en(o,e,t){for(var n=[],s=0;s<o[0].data.length;s++){for(var r=[],i=0;i<o.length;i++)r.push(o[i].data[s]);n.push(er(r))}var a=new Uint8ClampedArray(n);return new ImageData(a,e,t)}function er(o){if(o.length===0)return 0;for(var e={},t=0,n=o;t<n.length;t++)e[r=n[t]]=(e[r]||0)+1;var s=o[0];for(var r in e)e[r]>e[s]&&(s=parseInt(r,10));return s}function Ie(){if(typeof navigator>"u")return{name:"unknown",version:"unknown"};for(var o=navigator.userAgent,e={Edg:"Edge",OPR:"Opera"},t=0,n=[/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/,/(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/,/(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/,/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/];t<n.length;t++){var s=n[t],r=o.match(s);if(r&&r.groups)return{name:e[r.groups.name]||r.groups.name,version:r.groups.version}}return{name:"unknown",version:"unknown"}}G("audio",(function(){return Z(this,void 0,void 0,(function(){return Y(this,(function(o){return[2,new Promise((function(e,t){try{var n=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,5e3,44100),s=n.createBufferSource(),r=n.createOscillator();r.frequency.value=1e3;var i,a=n.createDynamicsCompressor();a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.2,r.connect(a),a.connect(n.destination),r.start(),n.oncomplete=function(c){i=c.renderedBuffer.getChannelData(0),e({sampleHash:Ys(i),oscillator:r.type,maxChannels:n.destination.maxChannelCount,channelCountMode:s.channelCountMode})},n.startRendering()}catch(c){console.error("Error creating audio fingerprint:",c),t(c)}}))]}))}))}));var tr=Ie().name!=="SamsungBrowser"?1:3,tn=280,nn=20;Ie().name!="Firefox"&&G("canvas",(function(){return document.createElement("canvas").getContext("2d"),new Promise((function(o){var e=Array.from({length:tr},(function(){return(function(){var t=document.createElement("canvas"),n=t.getContext("2d");if(!n)return new ImageData(1,1);t.width=tn,t.height=nn;var s=n.createLinearGradient(0,0,t.width,t.height);s.addColorStop(0,"red"),s.addColorStop(.16666666666666666,"orange"),s.addColorStop(.3333333333333333,"yellow"),s.addColorStop(.5,"green"),s.addColorStop(.6666666666666666,"blue"),s.addColorStop(.8333333333333334,"indigo"),s.addColorStop(1,"violet"),n.fillStyle=s,n.fillRect(0,0,t.width,t.height);var r="Random Text WMwmil10Oo";n.font="23.123px Arial",n.fillStyle="black",n.fillText(r,-5,15),n.fillStyle="rgba(0, 0, 255, 0.5)",n.fillText(r,-3.3,17.7),n.beginPath(),n.moveTo(0,0),n.lineTo(2*t.width/7,t.height),n.strokeStyle="white",n.lineWidth=2,n.stroke();var i=n.getImageData(0,0,t.width,t.height);return i})()}));o({commonImageDataHash:tt(en(e,tn,nn).data.toString()).toString()})}))}));var nt,nr=["Arial","Arial Black","Arial Narrow","Arial Rounded MT","Arimo","Archivo","Barlow","Bebas Neue","Bitter","Bookman","Calibri","Cabin","Candara","Century","Century Gothic","Comic Sans MS","Constantia","Courier","Courier New","Crimson Text","DM Mono","DM Sans","DM Serif Display","DM Serif Text","Dosis","Droid Sans","Exo","Fira Code","Fira Sans","Franklin Gothic Medium","Garamond","Geneva","Georgia","Gill Sans","Helvetica","Impact","Inconsolata","Indie Flower","Inter","Josefin Sans","Karla","Lato","Lexend","Lucida Bright","Lucida Console","Lucida Sans Unicode","Manrope","Merriweather","Merriweather Sans","Montserrat","Myriad","Noto Sans","Nunito","Nunito Sans","Open Sans","Optima","Orbitron","Oswald","Pacifico","Palatino","Perpetua","PT Sans","PT Serif","Poppins","Prompt","Public Sans","Quicksand","Rajdhani","Recursive","Roboto","Roboto Condensed","Rockwell","Rubik","Segoe Print","Segoe Script","Segoe UI","Sora","Source Sans Pro","Space Mono","Tahoma","Taviraj","Times","Times New Roman","Titillium Web","Trebuchet MS","Ubuntu","Varela Round","Verdana","Work Sans"],sr=["monospace","sans-serif","serif"];function sn(o,e){if(!o)throw new Error("Canvas context not supported");return o.font,o.font="72px ".concat(e),o.measureText("WwMmLli0Oo").width}function rr(){var o,e=document.createElement("canvas"),t=(o=e.getContext("webgl"))!==null&&o!==void 0?o:e.getContext("experimental-webgl");if(t&&"getParameter"in t)try{var n=(t.getParameter(t.VENDOR)||"").toString(),s=(t.getParameter(t.RENDERER)||"").toString(),r={vendor:n,renderer:s,version:(t.getParameter(t.VERSION)||"").toString(),shadingLanguageVersion:(t.getParameter(t.SHADING_LANGUAGE_VERSION)||"").toString()};if(!s.length||!n.length){var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var a=(t.getParameter(i.UNMASKED_VENDOR_WEBGL)||"").toString(),c=(t.getParameter(i.UNMASKED_RENDERER_WEBGL)||"").toString();a&&(r.vendorUnmasked=a),c&&(r.rendererUnmasked=c)}}return r}catch{}return"undefined"}function ir(){var o=new Float32Array(1),e=new Uint8Array(o.buffer);return o[0]=1/0,o[0]=o[0]-o[0],e[3]}function or(o,e){var t={};return e.forEach((function(n){var s=(function(r){if(r.length===0)return null;var i={};r.forEach((function(u){var l=String(u);i[l]=(i[l]||0)+1}));var a=r[0],c=1;return Object.keys(i).forEach((function(u){i[u]>c&&(a=u,c=i[u])})),a})(o.map((function(r){return n in r?r[n]:void 0})).filter((function(r){return r!==void 0})));s&&(t[n]=s)})),t}function ar(){var o=[],e={"prefers-contrast":["high","more","low","less","forced","no-preference"],"any-hover":["hover","none"],"any-pointer":["none","coarse","fine"],pointer:["none","coarse","fine"],hover:["hover","none"],update:["fast","slow"],"inverted-colors":["inverted","none"],"prefers-reduced-motion":["reduce","no-preference"],"prefers-reduced-transparency":["reduce","no-preference"],scripting:["none","initial-only","enabled"],"forced-colors":["active","none"]};return Object.keys(e).forEach((function(t){e[t].forEach((function(n){matchMedia("(".concat(t,": ").concat(n,")")).matches&&o.push("".concat(t,": ").concat(n))}))})),o}function lr(){if(window.location.protocol==="https:"&&typeof window.ApplePaySession=="function")try{for(var o=window.ApplePaySession.supportsVersion,e=15;e>0;e--)if(o(e))return e}catch{return 0}return 0}Ie().name!="Firefox"&&G("fonts",(function(){var o=this;return new Promise((function(e,t){try{(function(n){var s;Z(this,void 0,void 0,(function(){var r,i,a;return Y(this,(function(c){switch(c.label){case 0:return document.body?[3,2]:[4,(u=50,new Promise((function(h){return setTimeout(h,u,l)})))];case 1:return c.sent(),[3,0];case 2:if((r=document.createElement("iframe")).setAttribute("frameBorder","0"),(i=r.style).setProperty("position","fixed"),i.setProperty("display","block","important"),i.setProperty("visibility","visible"),i.setProperty("border","0"),i.setProperty("opacity","0"),r.src="about:blank",document.body.appendChild(r),!(a=r.contentDocument||((s=r.contentWindow)===null||s===void 0?void 0:s.document)))throw new Error("Iframe document is not accessible");return n({iframe:a}),setTimeout((function(){document.body.removeChild(r)}),0),[2]}var u,l}))}))})((function(n){var s=n.iframe;return Z(o,void 0,void 0,(function(){var r,i,a,c;return Y(this,(function(u){return r=s.createElement("canvas"),i=r.getContext("2d"),a=sr.map((function(l){return sn(i,l)})),c={},nr.forEach((function(l){var h=sn(i,l);a.includes(h)||(c[l]=h)})),e(c),[2]}))}))}))}catch{t({error:"unsupported"})}}))})),G("hardware",(function(){return new Promise((function(o,e){var t=navigator.deviceMemory!==void 0?navigator.deviceMemory:0,n=window.performance&&window.performance.memory?window.performance.memory:0;o({videocard:rr(),architecture:ir(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:n.jsHeapSizeLimit||0})}))})),G("locales",(function(){return new Promise((function(o){o({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),G("permissions",(function(){return Z(this,void 0,void 0,(function(){var o;return Y(this,(function(e){return nt=(q==null?void 0:q.permissions_to_check)||["accelerometer","accessibility","accessibility-events","ambient-light-sensor","background-fetch","background-sync","bluetooth","camera","clipboard-read","clipboard-write","device-info","display-capture","gyroscope","geolocation","local-fonts","magnetometer","microphone","midi","nfc","notifications","payment-handler","persistent-storage","push","speaker","storage-access","top-level-storage-access","window-management","query"],o=Array.from({length:(q==null?void 0:q.retries)||3},(function(){return(function(){return Z(this,void 0,void 0,(function(){var t,n,s,r,i;return Y(this,(function(a){switch(a.label){case 0:t={},n=0,s=nt,a.label=1;case 1:if(!(n<s.length))return[3,6];r=s[n],a.label=2;case 2:return a.trys.push([2,4,,5]),[4,navigator.permissions.query({name:r})];case 3:return i=a.sent(),t[r]=i.state.toString(),[3,5];case 4:return a.sent(),[3,5];case 5:return n++,[3,1];case 6:return[2,t]}}))}))})()})),[2,Promise.all(o).then((function(t){return or(t,nt)}))]}))}))})),G("plugins",(function(){var o=[];if(navigator.plugins)for(var e=0;e<navigator.plugins.length;e++){var t=navigator.plugins[e];o.push([t.name,t.filename,t.description].join("|"))}return new Promise((function(n){n({plugins:o})}))})),G("screen",(function(){return new Promise((function(o){o({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:ar()})}))})),G("system",(function(){return new Promise((function(o){var e=Ie();o({platform:window.navigator.platform,cookieEnabled:window.navigator.cookieEnabled,productSub:navigator.productSub,product:navigator.product,useragent:navigator.userAgent,hardwareConcurrency:navigator.hardwareConcurrency,browser:{name:e.name,version:e.version},applePayVersion:lr()})}))}));var L,cr=Ie().name!=="SamsungBrowser"?1:3,f=null;G("webgl",(function(){return Z(this,void 0,void 0,(function(){var o;return Y(this,(function(e){typeof document<"u"&&((L=document.createElement("canvas")).width=200,L.height=100,f=L.getContext("webgl"));try{if(!f)throw new Error("WebGL not supported");return o=Array.from({length:cr},(function(){return(function(){try{if(!f)throw new Error("WebGL not supported");var t=`
|
|
518
503
|
attribute vec2 position;
|
|
519
504
|
void main() {
|
|
520
505
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
521
506
|
}
|
|
522
|
-
`,
|
|
507
|
+
`,n=`
|
|
523
508
|
precision mediump float;
|
|
524
509
|
void main() {
|
|
525
510
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
526
511
|
}
|
|
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 _s(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 _s(typeof n=="string"?JSON.parse(n,e):n)}function Rt(n,e){return _s(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 xs&&(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 xs)}}}class xs 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){if(this.$__uris=typeof e=="object"?e:[e],this.$__client){const t=this.getRandomUri();this.$__client.setUri(t)}}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 _n("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 _n("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:_a,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}({});
|
|
512
|
+
`,s=f.createShader(f.VERTEX_SHADER),r=f.createShader(f.FRAGMENT_SHADER);if(!s||!r)throw new Error("Failed to create shaders");if(f.shaderSource(s,t),f.shaderSource(r,n),f.compileShader(s),!f.getShaderParameter(s,f.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+f.getShaderInfoLog(s));if(f.compileShader(r),!f.getShaderParameter(r,f.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+f.getShaderInfoLog(r));var i=f.createProgram();if(!i)throw new Error("Failed to create shader program");if(f.attachShader(i,s),f.attachShader(i,r),f.linkProgram(i),!f.getProgramParameter(i,f.LINK_STATUS))throw new Error("Shader program linking failed: "+f.getProgramInfoLog(i));f.useProgram(i);for(var a=137,c=new Float32Array(4*a),u=2*Math.PI/a,l=0;l<a;l++){var h=l*u;c[4*l]=0,c[4*l+1]=0,c[4*l+2]=Math.cos(h)*(L.width/2),c[4*l+3]=Math.sin(h)*(L.height/2)}var p=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,p),f.bufferData(f.ARRAY_BUFFER,c,f.STATIC_DRAW);var d=f.getAttribLocation(i,"position");f.enableVertexAttribArray(d),f.vertexAttribPointer(d,2,f.FLOAT,!1,0,0),f.viewport(0,0,L.width,L.height),f.clearColor(0,0,0,1),f.clear(f.COLOR_BUFFER_BIT),f.drawArrays(f.LINES,0,2*a);var w=new Uint8ClampedArray(L.width*L.height*4);return f.readPixels(0,0,L.width,L.height,f.RGBA,f.UNSIGNED_BYTE,w),new ImageData(w,L.width,L.height)}catch{return new ImageData(1,1)}finally{f&&(f.bindBuffer(f.ARRAY_BUFFER,null),f.useProgram(null),f.viewport(0,0,f.drawingBufferWidth,f.drawingBufferHeight),f.clearColor(0,0,0,0))}})()})),[2,{commonImageHash:tt(en(o,L.width,L.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));var he=function(o,e,t,n){for(var s=(t-e)/n,r=0,i=0;i<n;i++)r+=o(e+(i+.5)*s);return r*s};G("math",(function(){return Z(void 0,void 0,void 0,(function(){return Y(this,(function(o){return[2,{acos:Math.acos(.5),asin:he(Math.asin,-1,1,97),atan:he(Math.atan,-1,1,97),cos:he(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:he(Math.sin,-Math.PI,Math.PI,97),sinh:he(Math.sinh,-1.2857142857142858,.7777777777777778,97),sqrt:Math.sqrt(2),tan:he(Math.tan,0,2*Math.PI,97),tanh:he(Math.tanh,-1.2857142857142858,.7777777777777778,97)}]}))}))}));class ur{constructor({serverUri:e,socket:t=null,encrypt:n=!1}){this.$__client=this.createUrqlClient({serverUri:e,socket:t,encrypt:n}),this.$__authToken="",this.$__pubkey=null,this.$__wallet=null,this.serverUri=e,this.soketi=t,this.cipherLink=!!n,this.$__subscriptionManager=new Map}createUrqlClient({serverUri:e,socket:t,encrypt:n}){const s=[v.cacheExchange,v.fetchExchange];if(t&&t.socketUri){const r=rn.createClient({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(v.subscriptionExchange({forwardSubscription:i=>({subscribe:a=>({unsubscribe:r.subscribe(i,a)})})}))}return v.createClient({url:e,exchanges:s,fetchOptions:()=>({headers:{"X-Auth-Token":this.$__authToken},signal:AbortSignal.timeout(6e4)})})}setAuthData({token:e,pubkey:t,wallet:n}){this.$__authToken=e,this.$__pubkey=t,this.$__wallet=n,this.$__client=this.createUrqlClient({serverUri:this.serverUri,socket:this.soketi,encrypt:!!this.cipherLink})}async query(e){const{query:t,variables:n}=e,s=await this.$__client.query(t,n).toPromise();return this.formatResponse(s)}async mutate(e){const{mutation:t,variables:n}=e,s=await this.$__client.mutation(t,n).toPromise();return this.formatResponse(s)}subscribe(e,t){const{query:n,variables:s,operationName:r}=e,{unsubscribe:i}=rt.pipe(this.$__client.subscription(n,s),rt.map(a=>{t(this.formatResponse(a))})).subscribe(()=>{});return this.$__subscriptionManager.set(r,{unsubscribe:i}),{unsubscribe:()=>this.unsubscribe(r)}}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 hr{constructor({uri:e,cellSlug:t=null,client:n=null,socket:s=null,serverSdkVersion:r=3,logging:i=!1}){this.initialize({uri:e,cellSlug:t,socket:s,client:n,serverSdkVersion:r,logging:i})}initialize({uri:e,cellSlug:t=null,socket:n=null,client:s=null,serverSdkVersion:r=3,logging:i=!1}){this.reset(),this.$__logging=i,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 ${r}...`),this.$__client=s||new ur({socket:{socketUri:null,appKey:"knishio",...n||{}},serverUri:this.getRandomUri()}),this.$__serverSdkVersion=r}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 te("KnishIOClient::subscribe() - Socket client not initialized!");return this.client()}getServerSdkVersion(){return this.$__serverSdkVersion}reset(){this.$__secret="",this.$__bundle="",this.remainderWallet=null}getCellSlug(){return this.$__cellSlug||null}setCellSlug(e){this.$__cellSlug=e}setUri(e){if(this.$__uris=typeof e=="object"?e:[e],this.$__client){const t=this.getRandomUri();this.$__client.setUri(t)}}getUri(){return this.$__client.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}).catch(n=>{this.log("warn",`KnishIOClient::client() - Background authorization failed: ${n.message}`)})}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...`),ie(e)}getSecret(){if(!this.hasSecret())throw new Ke("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 Ke("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return Zs()}getFingerprintData(){return Zt()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=k.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new k({secret:this.getSecret()}),e}getRemainderWallet(){return this.remainderWallet}async createMolecule({secret:e=null,bundle:t=null,sourceWallet:n=null,remainderWallet:s=null}){return this.log("info","KnishIOClient::createMolecule() - Creating a new molecule..."),e=e||this.getSecret(),t=t||this.getBundle(),!n&&this.lastMoleculeQuery&&this.getRemainderWallet().token==="USER"&&this.lastMoleculeQuery.response()&&this.lastMoleculeQuery.response().success()&&(n=this.getRemainderWallet()),n===null&&(n=await this.getSourceWallet()),this.remainderWallet=s||k.create({secret:e,bundle:t,token:"USER",batchId:n.batchId,characters:n.characters}),new J({secret:e,sourceWallet:n,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 n=t||await this.createMolecule({}),s=new e(this.client(),this,n);if(!(s instanceof B))throw new te(`${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.$__authInProcess&&(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 n=new AbortController,s=JSON.stringify({query:e.$__query,variables:t});this.abortControllers.set(s,n);try{const r=await e.execute({variables:t,context:{fetchOptions:{signal:n.signal}}});return this.abortControllers.delete(s),r}catch(r){if(r.name==="AbortError")this.log("warn","Query was cancelled");else throw r}}cancelQuery(e,t=null){const n=JSON.stringify({query:e.$__query,variables:t}),s=this.abortControllers.get(n);s&&(s.abort(),this.abortControllers.delete(n))}cancelAllQueries(){for(const e of this.abortControllers.values())e.abort();this.abortControllers.clear()}async queryBalance({token:e,bundle:t=null,type:n="regular"}){const s=this.createQuery(is);return this.executeQuery(s,{bundleHash:t||this.getBundle(),token:e,type:n})}async querySourceWallet({token:e,amount:t,type:n="regular"}){const s=(await this.queryBalance({token:e,type:n})).payload();if(s===null||de.cmp(s.balance,t)<0)throw new ee;if(!s.position||!s.address)throw new ee("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(Is).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:n}){if(!t)throw new te(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(Ms).execute({variables:{bundle:e||this.getBundle(),token:t},closure:n})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(Ts).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:n}){return this.createSubscribe(Cs).execute({variables:{metaType:e,metaId:t},closure:n})}unsubscribe(e){this.subscribe().unsubscribe(e)}unsubscribeAll(){this.subscribe().unsubscribeAll()}queryMeta({metaType:e,metaId:t=null,key:n=null,value:s=null,latest:r=!0,fields:i=null,filter:a=null,queryArgs:c=null,count:u=null,countBy:l=null,throughAtom:h=!0,values:p=null,keys:d=null,atomValues:w=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let $,E;return h?($=this.createQuery(Gt),E=Gt.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,countBy:l,values:p,keys:d,atomValues:w,cellSlug:this.getCellSlug()})):($=this.createQuery(Nt),E=Nt.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,count:u,countBy:l,cellSlug:this.getCellSlug()})),this.executeQuery($,E)}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(xe);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(as);return await this.executeQuery(t,{batchId:e})}async queryAtom({molecularHashes:e,molecularHash:t,bundleHashes:n,bundleHash:s,positions:r,position:i,walletAddresses:a,walletAddress:c,isotopes:u,isotope:l,tokenSlugs:h,tokenSlug:p,cellSlugs:d,cellSlug:w,batchIds:$,batchId:E,values:m,value:y,metaTypes:b,metaType:C,metaIds:_,metaId:A,indexes:I,index:T,filter:S,latest:K,queryArgs:U={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const pe=this.createQuery(Jt);return await this.executeQuery(pe,Jt.createVariables({molecularHashes:e,molecularHash:t,bundleHashes:n,bundleHash:s,positions:r,position:i,walletAddresses:a,walletAddress:c,isotopes:u,isotope:l,tokenSlugs:h,tokenSlug:p,cellSlugs:d,cellSlug:w,batchIds:$,batchId:E,values:m,value:y,metaTypes:b,metaType:C,metaIds:_,metaId:A,indexes:I,index:T,filter:S,latest:K,queryArgs:U}))}async createWallet({token:e}){const t=new k({secret:this.getSecret(),token:e}),n=await this.createMoleculeMutation({mutationClass:$s});return n.fillMolecule(t),await this.executeQuery(n)}async queryActiveSession({bundleHash:e,metaType:t,metaId:n}){const s=this.createQuery(Ws);return await this.executeQuery(s,{bundleHash:e,metaType:t,metaId:n})}async queryUserActivity({bundleHash:e,metaType:t,metaId:n,ipAddress:s,browser:r,osCpu:i,resolution:a,timeZone:c,countBy:u,interval:l}){const h=this.createQuery(Us);return await this.executeQuery(h,{bundleHash:e,metaType:t,metaId:n,ipAddress:s,browser:r,osCpu:i,resolution:a,timeZone:c,countBy:u,interval:l})}async activeSession({bundle:e,metaType:t,metaId:n,ipAddress:s,browser:r,osCpu:i,resolution:a,timeZone:c,json:u={}}){const l=this.createQuery(Os);return await this.executeQuery(l,{bundleHash:e,metaType:t,metaId:n,ipAddress:s,browser:r,osCpu:i,resolution:a,timeZone:c,json:JSON.stringify(u)})}async createToken({token:e,amount:t=null,meta:n=null,batchId:s=null,units:r=[]}){const i=R.get(n||{},"fungibility");if(i==="stackable"&&(n.batchId=s||Oe({})),["nonfungible","stackable"].includes(i)&&r.length>0){if(R.get(n||{},"decimals")>0)throw new xs;if(t>0)throw new Ne;t=r.length,n.splittable=1,n.decimals=0,n.tokenUnits=JSON.stringify(r)}const a=new k({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:hs});return c.fillMolecule({recipientWallet:a,amount:t,meta:n||{}}),await this.executeQuery(c)}async createRule({metaType:e,metaId:t,rule:n,policy:s={}}){const r=await this.createMoleculeMutation({mutationClass:Fs,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return r.fillMolecule({metaType:e,metaId:t,rule:n,policy:s}),await this.executeQuery(r)}async createMeta({metaType:e,metaId:t,meta:n=null,policy:s={}}){const r=await this.createMoleculeMutation({mutationClass:_s,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})}),i=n||{};return r.fillMolecule({metaType:e,metaId:t,meta:i,policy:s}),await this.executeQuery(r)}async registerPeer({host:e}){const t=await this.createMoleculeMutation({mutationClass:jt,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return t.fillMolecule({host:e}),await this.executeQuery(t)}async appendRequest({metaType:e,metaId:t,action:n,meta:s={}}){const r=await this.createMoleculeMutation({mutationClass:Dt,molecule:await this.createMolecule({secret:this.getSecret(),sourceWallet:await this.getSourceWallet()})});return r.fillMolecule({metaType:e,metaId:t,action:n,meta:s}),await this.executeQuery(r)}async createIdentifier({type:e,contact:t,code:n}){const s=await this.createMoleculeMutation({mutationClass:gs});return s.fillMolecule({type:e,contact:t,code:n}),await this.executeQuery(s)}async createPolicy({metaType:e,metaId:t,policy:n={}}){const s=await this.createMolecule({});s.addPolicyAtom({metaType:e,metaId:t,meta:{},policy:n}),s.addContinuIdAtom(),s.sign({bundle:this.getBundle()}),s.check();const r=await this.createMoleculeMutation({mutationClass:B,molecule:s});return await this.executeQuery(r)}async queryPolicy({metaType:e,metaId:t}){const n=this.createQuery(Ks);return await this.executeQuery(n,{metaType:e,metaId:t})}queryWallets({bundle:e=null,token:t=null,unspent:n=!0}){this.log("info",`KnishIOClient::queryWallets() - Querying wallets${e?` for ${e}`:""}...`);const s=this.createQuery(ss);return this.executeQuery(s,{bundleHash:e||this.getBundle(),tokenSlug:t,unspent:n}).then(r=>r.payload())}queryBundle({bundle:e=null,fields:t=null,raw:n=!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(ns);return this.executeQuery(s,{bundleHashes:e}).then(r=>n?r:r.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(es);return this.executeQuery(t,{bundle:e})}async requestTokens({token:e,to:t,amount:n=null,units:s=[],meta:r=null,batchId:i=null}){let a,c;r=r||{};const u=this.createQuery(Bs),l=await this.executeQuery(u,{slug:e}),h=R.get(l.data(),"0.fungibility")==="stackable";if(!h&&i!==null)throw new Pe("Expected Batch ID = null for non-stackable tokens.");if(h&&i===null&&(i=Oe({})),s.length>0){if(n>0)throw new Ne;n=s.length,r.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(k.isBundleHash(t)?(a="walletBundle",c=t):t=k.create({secret:t,token:e})),t instanceof k&&(a="wallet",r.position=t.position,r.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const p=await this.createMoleculeMutation({mutationClass:ps});return p.fillMolecule({token:e,amount:n,metaType:a,metaId:c,meta:r,batchId:i}),await this.executeQuery(p)}async claimShadowWallet({token:e,batchId:t=null,molecule:n=null}){const s=await this.createMoleculeMutation({mutationClass:bs,molecule:n});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 Vt;t.forEach(s=>{if(!s.isShadow())throw new Vt});const n=[];for(const s of t)n.push(await this.claimShadowWallet({token:e,batchId:s.batchId}));return n}async transferToken({bundleHash:e,token:t,amount:n=null,units:s=[],batchId:r=null,sourceWallet:i=null}){if(s.length>0){if(n>0)throw new Ne;n=s.length}if(i===null&&(i=await this.querySourceWallet({token:t,amount:n})),i===null||de.cmp(i.balance,n)<0)throw new ee;const a=k.create({bundle:e,token:t});r!==null?a.batchId=r:a.initBatchId({sourceWallet:i});const c=i.createRemainder(this.getSecret());i.splitUnits(s,c,a);const u=await this.createMolecule({sourceWallet:i,remainderWallet:c}),l=await this.createMoleculeMutation({mutationClass:ms,molecule:u});return l.fillMolecule({recipientWallet:a,amount:n}),await this.executeQuery(l)}async depositBufferToken({tokenSlug:e,amount:t,tradeRates:n,sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const r=s.createRemainder(this.getSecret()),i=await this.createMolecule({sourceWallet:s,remainderWallet:r}),a=await this.createMoleculeMutation({mutationClass:js,molecule:i});return a.fillMolecule({amount:t,tradeRates:n}),await this.executeQuery(a)}async withdrawBufferToken({tokenSlug:e,amount:t,sourceWallet:n=null,signingWallet:s=null}){n===null&&(n=await this.querySourceWallet({token:e,amount:t,type:"buffer"}));const r=n,i=await this.createMolecule({sourceWallet:n,remainderWallet:r}),a=await this.createMoleculeMutation({mutationClass:Qs,molecule:i}),c={};return c[this.getBundle()]=t,a.fillMolecule({recipients:c,signingWallet:s}),await this.executeQuery(a)}async burnTokens({token:e,amount:t=null,units:n=[],sourceWallet:s=null}){s===null&&(s=await this.querySourceWallet({token:e,amount:t}));const r=s.createRemainder(this.getSecret());if(n.length>0){if(t>0)throw new Ne;t=n.length,s.splitUnits(n,r)}const i=await this.createMolecule({sourceWallet:s,remainderWallet:r});i.burnToken({amount:t}),i.sign({bundle:this.getBundle()}),i.check();const a=await this.createMoleculeMutation({mutationClass:B,molecule:i});return this.executeQuery(a)}async replenishToken({token:e,amount:t=null,units:n=[],sourceWallet:s=null}){if(s===null&&(s=(await this.queryBalance({token:e})).payload()),!s)throw new ee("Source wallet is missing or invalid.");const r=s.createRemainder(this.getSecret()),i=await this.createMolecule({sourceWallet:s,remainderWallet:r});i.replenishToken({amount:t,units:n}),i.sign({bundle:this.getBundle()}),i.check();const a=await this.createMoleculeMutation({mutationClass:B,molecule:i});return this.executeQuery(a)}async fuseToken({bundleHash:e,tokenSlug:t,newTokenUnit:n,fusedTokenUnitIds:s,sourceWallet:r=null}){if(r===null&&(r=(await this.queryBalance({token:t})).payload()),r===null)throw new ee("Source wallet is missing or invalid.");if(!r.tokenUnits||!r.tokenUnits.length)throw new ee("Source wallet does not have token units.");if(!s.length)throw new ee("Fused token unit list is empty.");const i=[];r.tokenUnits.forEach(h=>{i.push(h.id)}),s.forEach(h=>{if(!i.includes(h))throw new ee(`Fused token unit ID = ${h} does not found in the source wallet.`)});const a=k.create({bundle:e,token:t});a.initBatchId({sourceWallet:r});const c=r.createRemainder(this.getSecret());r.splitUnits(s,c),n.metas.fusedTokenUnits=r.getTokenUnitsData(),a.tokenUnits=[n];const u=await this.createMolecule({sourceWallet:r,remainderWallet:c});u.fuseToken(r.tokenUnits,a),u.sign({bundle:this.getBundle()}),u.check();const l=await this.createMoleculeMutation({mutationClass:B,molecule:u});return this.executeQuery(l)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const n=new k({secret:Ee(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(vs),r={cellSlug:e,pubkey:n.pubkey,encrypt:t},i=await s.execute({variables:r});if(i.success()){const a=ve.create({token:i.token(),expiresAt:i.time(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new zt(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${i.reason()}`);return i}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const n=new k({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:n}),r=await this.createMoleculeMutation({mutationClass:cs,molecule:s});r.fillMolecule({meta:{encrypt:t?"true":"false"}});const i=await r.execute({});if(i.success()){const a=ve.create({token:i.token(),expiresAt:i.time(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new zt(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${i.reason()}`);return i}async requestAuthToken({secret:e=null,seed:t=null,cellSlug:n=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=Ee(t)),n&&this.setCellSlug(n),this.$__authInProcess=!0;let r;return e?r=await this.requestProfileAuthToken({secret:e,encrypt:s}):r=await this.requestGuestAuthToken({cellSlug:n,encrypt:s}),this.log("info",`KnishIOClient::authorize() - Successfully retrieved auth token ${this.$__authToken.getToken()}...`),this.switchEncryption(s),this.$__authInProcess=!1,r}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 x.Atom=g,x.KnishIOClient=hr,x.Meta=ne,x.Molecule=J,x.MutationAppendRequest=Dt,x.MutationPeering=jt,x.ResponseAppendRequest=Qt,x.ResponsePeering=Ft,x.Wallet=k,x.base64ToHex=ut,x.bufferToHexString=at,x.charsetBaseConvert=ot,x.chunkSubstr=fe,x.generateBundleHash=ie,x.generateSecret=Ee,x.hexStringToBuffer=lt,x.hexToBase64=ct,x.isHex=Te,x.randomString=Me,x.shake256=Ve,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"}),x})({},jsSHA,UrqlCore,GraphQLWS,wonka);
|
|
528
513
|
//# sourceMappingURL=client.iife.js.map
|