@wishknish/knishio-client-js 0.7.4 → 0.7.6
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 +90 -28
- package/dist/client.cjs.js.map +1 -1
- package/dist/client.es.mjs +1680 -892
- package/dist/client.es.mjs.map +1 -1
- package/dist/client.iife.js +90 -28
- package/dist/client.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/KnishIOClient.js +74 -13
- package/src/Molecule.js +102 -14
- package/src/Wallet.js +48 -1
- package/src/index.js +233 -9
- package/src/libraries/CheckMolecule.js +211 -5
- package/src/query/QueryContinuId.js +8 -0
- package/src/query/QueryMetaTypeViaMolecule.js +223 -0
- package/src/query/QueryWalletList.js +2 -2
- package/src/response/ResponseContinuId.js +1 -1
- package/src/response/ResponseMetaTypeViaMolecule.js +210 -0
- package/src/response/ResponseRequestAuthorization.js +34 -1
- package/src/response/ResponseRequestAuthorizationGuest.js +32 -1
- package/src/response/ResponseWalletList.js +1 -1
package/dist/client.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
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
|
|
1
|
+
"use strict";var cs=Object.defineProperty;var us=(o,e,t)=>e in o?cs(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var j=(o,e,t)=>us(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("jssha"),T=require("@urql/core"),hs=require("graphql-ws"),wt=require("wonka");typeof self>"u"&&(global.self=global);class Wt{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 Te(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 De(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 Bt(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 Ut(o){return Wt.toHex(o,{})}function Ht(o){return Wt.toUint8Array(o)}function Pt(o){const e=Ht(o);return btoa(String.fromCharCode.apply(null,e))}function Kt(o){const e=new Uint8Array(atob(o).split("").map(t=>t.charCodeAt(0)));return Ut(e)}function Ke(o){return/^[A-F0-9]+$/i.test(o)}function Nt(o){return(typeof o=="number"||typeof o=="string"&&o.trim()!=="")&&!isNaN(o)}let de=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 Ft(o,e){return o.length?[o.slice(0,e)].concat(Ft(o.slice(e),e)):[]}function Lt(o,e){let t,n,s;const r=[Array,Date,Number,String,Boolean],i=Object.prototype.toString;for(e=e||[],t=0;t<e.length;t+=2)o===e[t]&&(n=e[t+1]);if(!n&&o&&typeof o=="object"){for(n={},t=0;t<r.length;t++)i.call(o)===i.call(s=new r[t](o))&&(n=t?s:[]);e.push(o,n);for(t in o)e.hasOwnProperty.call(o,t)&&(n[t]=Lt(o[t],e))}return n||o}function Qt(...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 ye(...o){return o.reduce((e,t)=>e.filter(n=>t.includes(n)))}class Ve{constructor(e={},t={}){this.policy=Ve.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 Qt(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 U{constructor(e=[]){this.meta=de.normalizeMeta(e)}merge(e){return this.meta=Array.from(new Set([...this.meta,...de.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 Ve(e,Object.keys(this.meta));return this.merge({policy:t.toJson()}),this}get(){return this.meta}}class x 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 ae extends x{constructor(e="The molecule does not contain atoms",t=null,n=null){super(e,t,n),this.name="AtomsMissingException"}}class ie{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(ie.isStructure(e[n])?ie.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]=ie.isStructure(e[s])?ie.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 ie.structure(this)}}class un extends ie{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 Re={4:un};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?ce.normalizeMeta(u):[],this.index=h,this.otsFragment=l,this.createdAt=String(+new Date),p!==null&&Object.prototype.hasOwnProperty.call(Re,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 H),i instanceof H||(i=new H(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 L("SHAKE256","TEXT"),s=g.sortAtoms(e);if(s.length===0)throw new ae;if(s.map(r=>{if(!(r instanceof g))throw new ae;return r}),s.every(r=>r.version&&Object.prototype.hasOwnProperty.call(Re,r.version)))n.update(JSON.stringify(s.map(r=>Re[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 Ct(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 ce.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 Ue(o=null,e=2048){if(o){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e*2})}else return Ke(e)}function ue(o,e=null){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:256})}function Ze(o,e){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e})}function Be({molecularHash:o=null,index:e=null}){return o!==null&&e!==null?ue(String(o)+String(e),"generateBatchId"):Ke(64)}class _e{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 _e(e.id,e.name,t)}static createFromDB(e){return new _e(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 hn extends x{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 Me=BigInt(2**32-1),rt=BigInt(32);function dn(o,e=!1){return e?{h:Number(o&Me),l:Number(o>>rt&Me)}:{h:Number(o>>rt&Me)|0,l:Number(o&Me)|0}}function pn(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}=dn(o[r],e);[n[r],s[r]]=[i,a]}return[n,s]}const fn=(o,e,t)=>o<<t|e>>>32-t,mn=(o,e,t)=>e<<t|o>>>32-t,yn=(o,e,t)=>e<<t-32|o>>>64-t,gn=(o,e,t)=>o<<t-32|e>>>64-t;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wn(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"}function it(o,e=""){if(!Number.isSafeInteger(o)||o<0){const t=e&&`"${e}" `;throw new Error(`${t}expected integer >0, got ${o}`)}}function D(o,e,t=""){const n=wn(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 ot(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 bn(o,e){D(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 qt(o){return new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4))}function Ut(...o){for(let e=0;e<o.length;e++)o[e].fill(0)}const kn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _n(o){return o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255}function Sn(o){for(let e=0;e<o.length;e++)o[e]=_n(o[e]);return o}const at=kn?o=>o:Sn;function Bt(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 Ne=o=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,o])}),An=BigInt(0),fe=BigInt(1),vn=BigInt(2),xn=BigInt(7),In=BigInt(256),Mn=BigInt(113),Ht=[],Pt=[],Kt=[];for(let o=0,e=fe,t=1,n=0;o<24;o++){[t,n]=[n,(2*t+3*n)%5],Ht.push(2*(5*n+t)),Pt.push((o+1)*(o+2)/2%64);let s=An;for(let r=0;r<7;r++)e=(e<<fe^(e>>xn)*Mn)%In,e&vn&&(s^=fe<<(fe<<BigInt(r))-fe);Kt.push(s)}const Nt=pn(Kt,!0),Tn=Nt[0],Cn=Nt[1],lt=(o,e,t)=>t>32?yn(o,e,t):fn(o,e,t),ct=(o,e,t)=>t>32?gn(o,e,t):mn(o,e,t);function En(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=lt(u,l,1)^t[a],p=ct(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=Pt[i],c=lt(s,r,a),u=ct(s,r,a),l=Ht[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]^=Tn[n],o[1]^=Cn[n]}Ut(t)}class Le{constructor(e,t,n,s=!1,r=24){F(this,"state");F(this,"pos",0);F(this,"posOut",0);F(this,"finished",!1);F(this,"state32");F(this,"destroyed",!1);F(this,"blockLen");F(this,"suffix");F(this,"outputLen");F(this,"enableXOF",!1);F(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=r,it(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=qt(this.state)}clone(){return this._cloneInto()}keccak(){at(this.state32),En(this.state32,this.rounds),at(this.state32),this.posOut=0,this.pos=0}update(e){ot(this),D(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){ot(this,!1),D(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 it(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(bn(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,Ut(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:r,enableXOF:i}=this;return e||(e=new Le(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 Lt=(o,e,t,n={})=>Bt(()=>new Le(e,o,t),n),On=Lt(6,136,32,Ne(8)),Rn=Lt(6,72,64,Ne(10)),Ft=(o,e,t,n={})=>Bt((s={})=>new Le(e,o,s.dkLen===void 0?t:s.dkLen,!0),n),Wn=Ft(31,168,16,Ne(11)),jt=Ft(31,136,32,Ne(12));function et(o){if(!Number.isSafeInteger(o)||o<0||o>4294967295)throw new Error("wrong u32 integer:"+o);return o}function Qt(o){return et(o),(o&o-1)===0&&o!==0}function Dt(o,e){et(o);let t=0;for(let n=0;n<e;n++,o>>>=1)t=t<<1|o&1;return t}function Vt(o){return et(o),31-Math.clz32(o)}function ut(o){const e=o.length;if(e<2||!Qt(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);const t=Vt(e);for(let n=0;n<e;n++){const s=Dt(n,t);if(n<s){const r=o[n];o[n]=o[s],o[s]=r}}return o}const ht=(o,e)=>{const{N:t,roots:n,dit:s,invertButterflies:r=!1,skipStages:i=0,brp:a=!0}=e,c=Vt(t);if(!Qt(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&&ut(l);for(let h=0,p=1;h<c-i;h++){const d=s?h+1+i:c-h,w=1<<d,$=w>>1,C=t>>d;for(let m=0;m<t;m+=w)for(let y=0,b=p++;y<$;y++){const T=r?s?t-b:b:y*C,k=m+y,A=m+y+$,v=n[T],I=l[A],_=l[k];if(u){const U=o.mul(I,v);l[k]=o.add(_,U),l[A]=o.sub(_,U)}else r?(l[k]=o.add(I,_),l[A]=o.mul(o.sub(I,_),v)):(l[k]=o.add(_,I),l[A]=o.mul(o.sub(_,I),v))}}return!s&&a&&ut(l),l}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const dt=$n;function De(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 qn(o){return Uint8Array.from(o)}function We(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]);D(l,u,o),r.set(l,a),typeof c!="number"&&l.fill(0),a+=u}return r},decode:s=>{D(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 Ve(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=>{D(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 G(...o){for(const e of o)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function pt(o){return(1<<o)-1}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Un=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=Dt(y,i),T=BigInt(r)**BigInt(b)%BigInt(n);m[y]=Number(T)|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=ht(h,{dit:!1,...p}),w=ht(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=pt(m),T=m*(t/8);return{bytesLen:T,encode:k=>{const A=new Uint8Array(T);for(let v=0,I=0,_=0,U=0;v<k.length;v++)for(I|=(y.encode(k[v])&b)<<_,_+=m;_>=8;_-=8,I>>=8)A[U++]=I&pt(_);return A},decode:k=>{const A=e(t);for(let v=0,I=0,_=0,U=0;v<k.length;v++)for(I|=k[v]<<_,_+=8;_>=m;_-=m,I>>=m)A[U++]=y.decode(I&b);return A}}}}},Bn=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(),G(r,n)}}},Hn=Bn(Wn);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const K=256,le=3329,Pn=3303,Kn=17,{mod:Se,nttZetas:Nn,NTT:te,bitsCoder:Ln}=Un({N:K,Q:le,F:Pn,ROOT_OF_UNITY:Kn,newPoly:o=>new Uint16Array(o),brvBits:7}),Fn={768:{N:K,Q:le,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},jn=o=>{if(o>=12)return{encode:t=>t,decode:t=>t};const e=2**(o-1);return{encode:t=>((t<<o)+le/2)/le,decode:t=>t*le+e>>>o}},me=o=>Ln(o,jn(o));function ne(o,e){for(let t=0;t<K;t++)o[t]=Se(o[t]+e[t])}function Qn(o,e){for(let t=0;t<K;t++)o[t]=Se(o[t]-e[t])}function Dn(o,e,t,n,s){const r=Se(e*n*s+o*t),i=Se(o*n+e*t);return{c0:r,c1:i}}function Te(o,e){for(let t=0;t<K/2;t++){let n=Nn[64+(t>>1)];t&1&&(n=-n);const{c0:s,c1:r}=Dn(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 ft(o){const e=new Uint16Array(K);for(let t=0;t<K;){const n=o();if(n.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<K&&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<le&&(e[t++]=r),t<K&&i<le&&(e[t++]=i)}}return e}function ye(o,e,t,n){const s=o(n*K/4,e,t),r=new Uint16Array(K),i=qt(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++]=Se(h-l),l=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return r}const Vn=o=>{const{K:e,PRF:t,XOF:n,HASH512:s,ETA1:r,ETA2:i,du:a,dv:c}=o,u=me(1),l=me(c),h=me(a),p=We("publicKey",Ve(me(12),e),32),d=Ve(me(12),e),w=We("ciphertext",Ve(h,e),l),$=We("seed",32,32);return{secretCoder:d,lengths:{secretKey:d.bytesLen,publicKey:p.bytesLen,cipherText:w.bytesLen},keygen:C=>{D(C,32,"seed");const m=new Uint8Array(33);m.set(C),m[32]=e;const y=s(m),[b,T]=$.decode(y),k=[],A=[];for(let _=0;_<e;_++)k.push(te.encode(ye(t,T,_,r)));const v=n(b);for(let _=0;_<e;_++){const U=te.encode(ye(t,T,e+_,r));for(let O=0;O<e;O++){const he=ft(v.get(O,_));ne(U,Te(he,k[O]))}A.push(U)}v.clean();const I={publicKey:p.encode([A,b]),secretKey:d.encode(k)};return G(b,T,k,A,m,y),I},encrypt:(C,m,y)=>{const[b,T]=p.decode(C),k=[];for(let O=0;O<e;O++)k.push(te.encode(ye(t,y,O,r)));const A=n(T),v=new Uint16Array(K),I=[];for(let O=0;O<e;O++){const he=ye(t,y,e+O,i),Qe=new Uint16Array(K);for(let Ie=0;Ie<e;Ie++){const sn=ft(A.get(O,Ie));ne(Qe,Te(sn,k[Ie]))}ne(he,te.decode(Qe)),I.push(he),ne(v,Te(b[O],k[O])),G(Qe)}A.clean();const _=ye(t,y,2*e,i);ne(_,te.decode(v));const U=u.decode(m);return ne(U,_),G(b,k,v,_),w.encode([I,U])},decrypt:(C,m)=>{const[y,b]=w.decode(C),T=d.decode(m),k=new Uint16Array(K);for(let A=0;A<e;A++)ne(k,Te(T[A],te.encode(y[A])));return Qn(b,te.decode(k)),G(k,T,y),u.encode(b)}}};function zn(o){const e=Vn(o),{HASH256:t,HASH512:n,KDF:s}=o,{secretCoder:r,lengths:i}=e,a=We("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=dt(u))=>{D(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 G(p,d),{publicKey:h,secretKey:w}},getPublicKey:l=>{const[h,p]=a.decode(l);return Uint8Array.from(p)},encapsulate:(l,h=dt(c))=>{D(l,i.publicKey,"publicKey"),D(h,c,"message");const p=l.subarray(0,384*o.K),d=r.encode(r.decode(qn(p)));if(!De(d,p))throw G(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");G(d);const w=n.create().update(h).update(t(l)).digest(),$=e.encrypt(l,h,w.subarray(32,64));return G(w.subarray(32)),{cipherText:$,sharedSecret:w.subarray(0,32)}},decapsulate:(l,h)=>{D(h,a.bytesLen,"secretKey"),D(l,i.cipherText,"cipherText");const p=a.bytesLen-96,d=p+32,w=t(h.subarray(p/2,d));if(!De(w,h.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");const[$,C,m,y]=a.decode(h),b=e.decrypt(l,$),T=n.create().update(b).update(m).digest(),k=T.subarray(0,32),A=e.encrypt(C,b,T.subarray(32,64)),v=De(l,A),I=s.create({dkLen:32}).update(y).update(l).digest();return G(b,A,v?I:k),v?k:I}}}function Jn(o,e,t){return jt.create({dkLen:o}).update(e).update(new Uint8Array([t])).digest()}const Gn={HASH256:On,HASH512:Rn,KDF:jt,XOF:Hn,PRF:Jn},ze=zn({...Gn,...Fn[768]});class S{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||ue(e,"Wallet::constructor"),this.position=this.position||S.generatePosition(),this.key=S.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||S.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 hn;return e&&!t&&(i=S.generatePosition(),t=ue(e,"Wallet::create")),new S({secret:e,bundle:t,token:n,position:i,batchId:s,characters:r})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&Oe(e)}static getTokenUnits(e){const t=[];return e.forEach(n=>{t.push(_e.createFromDB(n))}),t}static generateKey({secret:e,token:t,position:n}){const s=Oe(e)?e:Ze(e,1024),r=Oe(n)?n:Ze(n,256),a=BigInt(`0x${s}`)+BigInt(`0x${r}`),c=new L("SHAKE256","TEXT");c.update(a.toString(16)),t&&c.update(t);const u=new L("SHAKE256","TEXT");return u.update(c.getHash("HEX",{outputLen:8192})),u.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=ke(e,128),n=new L("SHAKE256","TEXT");for(const r in t){let i=t[r];for(let a=1;a<=16;a++){const c=new L("SHAKE256","TEXT");c.update(i),i=c.getHash("HEX",{outputLen:512})}n.update(i)}const s=new L("SHAKE256","TEXT");return s.update(n.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return Ke(e,"abcdef0123456789")}initializeMLKEM(){const e=Ue(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}=ze.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=S.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:Be({}))}async encryptMessage(e,t){const n=JSON.stringify(e),s=new TextEncoder().encode(n),r=this.deserializeKey(t),{cipherText:i,sharedSecret:a}=ze.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=ze.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 ge extends x{constructor(e="There is an atom without an index",t=null,n=null){super(e,t,n),this.name="AtomIndexException"}}class Xn extends x{constructor(e="The molecular hash does not match",t=null,n=null){super(e,t,n),this.name="MolecularHashMismatchException"}}class Zn extends x{constructor(e="The molecular hash is missing",t=null,n=null){super(e,t,n),this.name="MolecularHashMissingException"}}class mt extends x{constructor(e="",t=null,n=null){super(e,t,n),this.name="PolicyInvalidException"}}class zt extends x{constructor(e="OTS malformed",t=null,n=null){super(e,t,n),this.name="SignatureMalformedException"}}class Yn extends x{constructor(e="One-time signature (OTS) does not match!",t=null,n=null){super(e,t,n),this.name="SignatureMismatchException"}}class Y extends x{constructor(e="Insufficient balance to make transfer",t=null,n=null){super(e,t,n),this.name="TransferBalanceException"}}class yt extends x{constructor(e="Token transfer atoms are malformed",t=null,n=null){super(e,t,n),this.name="TransferMalformedException"}}class gt extends x{constructor(e="Token slugs for wallets in transfer do not match!",t=null,n=null){super(e,t,n),this.name="TransferMismatchedException"}}class wt extends x{constructor(e="Invalid remainder provided",t=null,n=null){super(e,t,n),this.name="TransferRemainderException"}}class es extends x{constructor(e="Sender and recipient(s) cannot be the same",t=null,n=null){super(e,t,n),this.name="TransferToSelfException"}}class ts extends x{constructor(e="Token transfer atoms are unbalanced",t=null,n=null){super(e,t,n),this.name="TransferUnbalancedException"}}class Q extends x{constructor(e="Empty meta data.",t=null,n=null){super(e,t,n),this.name="MetaMissingException"}}class se extends x{constructor(e="Wrong type of token for this isotope",t=null,n=null){super(e,t,n),this.name="WrongTokenTypeException"}}class qe extends x{constructor(e="Incorrect BatchId",t=null,n=null){super(e,t,n),this.name="BatchIdException"}}class bt{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 x{constructor(e="An incorrect argument!",t=null,n=null){super(e,t,n),this.name="RuleArgumentException"}}class ee extends x{constructor(e="Code exception",t=null,n=null){super(e,t,n),this.name="CodeException"}}class be{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(!ln(e))throw new ee("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 bt?e:bt.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new be({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 pe(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return pe(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return pe(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return pe(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return pe(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class Je{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 Je))throw new He;for(const n of t)if(!(n instanceof be))throw new He;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof Je?e:Je.toObject(e))}set callback(e){this.__callback.push(e instanceof be?e:be.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 E{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 ns{constructor(e){if(e.molecularHash===null)throw new Zn;if(!e.atoms.length)throw new ae;for(const t of e.atoms)if(t.index===null)throw new ge;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 ae("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 qe;for(const s of t)if(s.batchId===null)throw new qe}return!0}throw new qe}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new se(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new ge(`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 se(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 se(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const n=ce.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 mt(`${i} is missing from the meta.`);for(const c of a)if(!S.isBundleHash(c)&&!["all","self"].includes(c))throw new mt(`${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 se(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 se(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 se(`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 se(`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 gt;if(i.value<0)throw new yt;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 gt;if(i>0){if(r<0)throw new yt;if(a.walletAddress===n.walletAddress)throw new es}s+=r}if(s!==0)throw new ts;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 Y;if(i!==s)throw new wt}else if(r!==0)throw new wt;return!0}molecularHash(){if(this.molecule.molecularHash!==g.hashAtoms({atoms:this.molecule.atoms}))throw new Xn;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=Wt(t),t.length!==2048))throw new zt;const n=ke(t,128);let s="";for(const p in n){let d=n[p];for(let w=0,$=8+e[p];w<$;w++)d=new L("SHAKE256","TEXT").update(d).getHash("HEX",{outputLen:512});s+=d}const r=new L("SHAKE256","TEXT");r.update(s);const i=r.getHash("HEX",{outputLen:8192}),a=new L("SHAKE256","TEXT");a.update(i);const c=a.getHash("HEX",{outputLen:256}),u=this.molecule.atoms[0];let l=u.walletAddress;const h=E.get(u.aggregatedMeta(),"signingWallet");if(h&&(l=E.get(JSON.parse(h),"address")),c!==l)throw new Yn;return!0}}class we extends x{constructor(e="Insufficient balance for requested transfer",t=null,n=null){super(e,t,n),this.name="BalanceInsufficientException"}}class kt extends x{constructor(e="Amount cannot be negative!",t=null,n=null){super(e,t,n),this.name="NegativeAmountException"}}class z{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(Re,i)&&(this.version=String(i)),(s||n)&&(this.remainderWallet=s||S.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 z({}),JSON.parse(e)),n=Object.keys(new z({}));if(!Array.isArray(t.atoms))throw new ae;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 ae("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 z.isotopeFilter(e,this.atoms)}generateIndex(){return z.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=S.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 H(e)})),this}addPolicyAtom({metaType:e,metaId:t,meta:n={},policy:s={}}){const r=new H(n);r.addPolicy(s);const i=S.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 we;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 kt("Molecule::burnToken() - Amount to burn must be positive!");if(this.sourceWallet.balance-e<0)throw new we;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 kt("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=S.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 we;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 we;const n=S.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 we;const s=new H;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?Be({}):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 H(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 H({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 H),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 H().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:n}){const s={code:n,hash:ue(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(g.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new H(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 H(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 H({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 H({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 H(r),batchId:i})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(g.create({isotope:"U",wallet:this.sourceWallet,meta:new H(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 ae;!t&&!this.bundle&&(this.bundle=e||ue(this.secret,"Molecule::sign")),this.molecularHash=g.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let r=s.position;const i=E.get(s.aggregatedMeta(),"signingWallet");if(i&&(r=E.get(JSON.parse(i),"position")),!r)throw new zt("Signing wallet must have a position!");const a=S.generateKey({secret:this.secret,token:s.token,position:s.position}),c=ke(a,128),u=this.normalizedHash();let l="";for(const d in c){let w=c[d];for(let $=0,C=8-u[d];$<C;$++)w=new L("SHAKE256","TEXT").update(w).getHash("HEX",{outputLen:512});l+=w}n&&(l=Rt(l));const h=ke(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 z({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 S({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 S({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 ns(this).verify(e)}normalizedHash(){return z.normalize(z.enumerate(this.molecularHash))}}const Ge=10**18;class de{static val(e){return Math.abs(e*Ge)<1?0:e}static cmp(e,t,n=!1){const s=de.val(e)*Ge,r=de.val(t)*Ge;return Math.abs(s-r)<1?0:s>r?1:-1}static equal(e,t){return de.cmp(e,t)===0}}class Ae{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 Ae(e);return n.setWallet(t),n}static restore(e,t){const n=new S({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return Ae.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 oe extends x{constructor(e="GraphQL did not provide a valid response.",t=null,n=null){super(e,t,n),this.name="InvalidResponseException"}}class Pe extends x{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 oe;if(E.has(this.$__response,this.errorKey)){const s=E.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new Pe:new oe}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 Pe:new oe(`GraphQL Error: ${s}`)}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!this.response().data)throw new oe("Response has no data field");if(!E.has(this.response(),this.dataKey))throw new oe(`Missing expected field: ${this.dataKey}`);return E.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 N{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 ee("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new ee("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 ss 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 S({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 rs extends N{constructor(e,t){super(e,t),this.$__query=M.gql`query ($bundle: String!) {
|
|
4
|
+
${this.stack}`}}class se extends x{constructor(e="The molecule does not contain atoms",t=null,n=null){super(e,t,n),this.name="AtomsMissingException"}}class le{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(le.isStructure(e[n])?le.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]=le.isStructure(e[s])?le.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 le.structure(this)}}class ds extends le{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 Ne={4:ds};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?de.normalizeMeta(u):[],this.index=h,this.otsFragment=l,this.createdAt=String(+new Date),p!==null&&Object.prototype.hasOwnProperty.call(Ne,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 U),i instanceof U||(i=new U(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 L("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(Ne,r.version)))n.update(JSON.stringify(s.map(r=>Ne[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 Bt(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 de.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 Qe(o=null,e=2048){if(o){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e*2})}else return De(e)}function pe(o,e=null){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:256})}function ot(o,e){const t=new L("SHAKE256","TEXT");return t.update(o),t.getHash("HEX",{outputLen:e})}function ce({molecularHash:o=null,index:e=null}){return o!==null&&e!==null?pe(String(o)+String(e),"generateBatchId"):De(64)}class fe{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 fe(e.id,e.name,t)}static createFromDB(e){return new fe(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 Ye extends x{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 Ue=BigInt(2**32-1),kt=BigInt(32);function ps(o,e=!1){return e?{h:Number(o&Ue),l:Number(o>>kt&Ue)}:{h:Number(o>>kt&Ue)|0,l:Number(o&Ue)|0}}function fs(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}=ps(o[r],e);[n[r],s[r]]=[i,a]}return[n,s]}const ms=(o,e,t)=>o<<t|e>>>32-t,ys=(o,e,t)=>e<<t|o>>>32-t,gs=(o,e,t)=>e<<t-32|o>>>64-t,bs=(o,e,t)=>o<<t-32|e>>>64-t;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ws(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"}function St(o,e=""){if(!Number.isSafeInteger(o)||o<0){const t=e&&`"${e}" `;throw new Error(`${t}expected integer >0, got ${o}`)}}function z(o,e,t=""){const n=ws(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 _t(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 ks(o,e){z(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 jt(o){return new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4))}function Dt(...o){for(let e=0;e<o.length;e++)o[e].fill(0)}const Ss=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _s(o){return o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255}function As(o){for(let e=0;e<o.length;e++)o[e]=_s(o[e]);return o}const At=Ss?o=>o:As;function Vt(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 $s(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 ze=o=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,o])}),vs=BigInt(0),_e=BigInt(1),xs=BigInt(2),Is=BigInt(7),Ms=BigInt(256),Ts=BigInt(113),zt=[],Jt=[],Gt=[];for(let o=0,e=_e,t=1,n=0;o<24;o++){[t,n]=[n,(2*t+3*n)%5],zt.push(2*(5*n+t)),Jt.push((o+1)*(o+2)/2%64);let s=vs;for(let r=0;r<7;r++)e=(e<<_e^(e>>Is)*Ts)%Ms,e&xs&&(s^=_e<<(_e<<BigInt(r))-_e);Gt.push(s)}const Xt=fs(Gt,!0),Cs=Xt[0],Es=Xt[1],$t=(o,e,t)=>t>32?gs(o,e,t):ms(o,e,t),vt=(o,e,t)=>t>32?bs(o,e,t):ys(o,e,t);function Rs(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=$t(u,l,1)^t[a],p=vt(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=Jt[i],c=$t(s,r,a),u=vt(s,r,a),l=zt[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]^=Cs[n],o[1]^=Es[n]}Dt(t)}class Je{constructor(e,t,n,s=!1,r=24){j(this,"state");j(this,"pos",0);j(this,"posOut",0);j(this,"finished",!1);j(this,"state32");j(this,"destroyed",!1);j(this,"blockLen");j(this,"suffix");j(this,"outputLen");j(this,"enableXOF",!1);j(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=r,St(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=jt(this.state)}clone(){return this._cloneInto()}keccak(){At(this.state32),Rs(this.state32,this.rounds),At(this.state32),this.posOut=0,this.pos=0}update(e){_t(this),z(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){_t(this,!1),z(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 St(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ks(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,Dt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:r,enableXOF:i}=this;return e||(e=new Je(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 Zt=(o,e,t,n={})=>Vt(()=>new Je(e,o,t),n),Os=Zt(6,136,32,ze(8)),qs=Zt(6,72,64,ze(10)),Yt=(o,e,t,n={})=>Vt((s={})=>new Je(e,o,s.dkLen===void 0?t:s.dkLen,!0),n),Ws=Yt(31,168,16,ze(11)),en=Yt(31,136,32,ze(12));function yt(o){if(!Number.isSafeInteger(o)||o<0||o>4294967295)throw new Error("wrong u32 integer:"+o);return o}function tn(o){return yt(o),(o&o-1)===0&&o!==0}function nn(o,e){yt(o);let t=0;for(let n=0;n<e;n++,o>>>=1)t=t<<1|o&1;return t}function sn(o){return yt(o),31-Math.clz32(o)}function xt(o){const e=o.length;if(e<2||!tn(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);const t=sn(e);for(let n=0;n<e;n++){const s=nn(n,t);if(n<s){const r=o[n];o[n]=o[s],o[s]=r}}return o}const It=(o,e)=>{const{N:t,roots:n,dit:s,invertButterflies:r=!1,skipStages:i=0,brp:a=!0}=e,c=sn(t);if(!tn(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&&xt(l);for(let h=0,p=1;h<c-i;h++){const d=s?h+1+i:c-h,b=1<<d,$=b>>1,C=t>>d;for(let f=0;f<t;f+=b)for(let y=0,w=p++;y<$;y++){const E=r?s?t-w:w:y*C,k=f+y,A=f+y+$,v=n[E],I=l[A],S=l[k];if(u){const H=o.mul(I,v);l[k]=o.add(S,H),l[A]=o.sub(S,H)}else r?(l[k]=o.add(I,S),l[A]=o.mul(o.sub(I,S),v)):(l[k]=o.add(S,I),l[A]=o.mul(o.sub(S,I),v))}}return!s&&a&&xt(l),l}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Mt=$s;function et(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 Bs(o){return Uint8Array.from(o)}function Fe(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]);z(l,u,o),r.set(l,a),typeof c!="number"&&l.fill(0),a+=u}return r},decode:s=>{z(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 tt(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=>{z(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 Tt(o){return(1<<o)-1}/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const Us=o=>{const{newPoly:e,N:t,Q:n,F:s,ROOT_OF_UNITY:r,brvBits:i}=o,a=(f,y=n)=>{const w=f%y|0;return(w>=0?w|0:y+w|0)|0},c=(f,y=n)=>{const w=a(f,y)|0;return(w>y>>1?w-y|0:w)|0};function u(){const f=e(t);for(let y=0;y<t;y++){const w=nn(y,i),E=BigInt(r)**BigInt(w)%BigInt(n);f[y]=Number(E)|0}return f}const l=u(),h={add:(f,y)=>a((f|0)+(y|0))|0,sub:(f,y)=>a((f|0)-(y|0))|0,mul:(f,y)=>a((f|0)*(y|0))|0,inv:f=>{throw new Error("not implemented")}},p={N:t,roots:l,invertButterflies:!0,skipStages:1,brp:!1},d=It(h,{dit:!1,...p}),b=It(h,{dit:!0,...p});return{mod:a,smod:c,nttZetas:l,NTT:{encode:f=>d(f),decode:f=>{b(f);for(let y=0;y<f.length;y++)f[y]=a(s*f[y]);return f}},bitsCoder:(f,y)=>{const w=Tt(f),E=f*(t/8);return{bytesLen:E,encode:k=>{const A=new Uint8Array(E);for(let v=0,I=0,S=0,H=0;v<k.length;v++)for(I|=(y.encode(k[v])&w)<<S,S+=f;S>=8;S-=8,I>>=8)A[H++]=I&Tt(S);return A},decode:k=>{const A=e(t);for(let v=0,I=0,S=0,H=0;v<k.length;v++)for(I|=k[v]<<S,S+=8;S>=f;S-=f,I>>=f)A[H++]=y.decode(I&w);return A}}}}},Hs=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)}}},Ps=Hs(Ws);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */const F=256,ue=3329,Ks=3303,Ns=17,{mod:Ce,nttZetas:Fs,NTT:re,bitsCoder:Ls}=Us({N:F,Q:ue,F:Ks,ROOT_OF_UNITY:Ns,newPoly:o=>new Uint16Array(o),brvBits:7}),Qs={768:{N:F,Q:ue,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}},js=o=>{if(o>=12)return{encode:t=>t,decode:t=>t};const e=2**(o-1);return{encode:t=>((t<<o)+ue/2)/ue,decode:t=>t*ue+e>>>o}},Ae=o=>Ls(o,js(o));function ie(o,e){for(let t=0;t<F;t++)o[t]=Ce(o[t]+e[t])}function Ds(o,e){for(let t=0;t<F;t++)o[t]=Ce(o[t]-e[t])}function Vs(o,e,t,n,s){const r=Ce(e*n*s+o*t),i=Ce(o*n+e*t);return{c0:r,c1:i}}function He(o,e){for(let t=0;t<F/2;t++){let n=Fs[64+(t>>1)];t&1&&(n=-n);const{c0:s,c1:r}=Vs(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 Ct(o){const e=new Uint16Array(F);for(let t=0;t<F;){const n=o();if(n.length%3)throw new Error("SampleNTT: unaligned block");for(let s=0;t<F&&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<ue&&(e[t++]=r),t<F&&i<ue&&(e[t++]=i)}}return e}function $e(o,e,t,n){const s=o(n*F/4,e,t),r=new Uint16Array(F),i=jt(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++]=Ce(h-l),l=0,a=0)}if(a)throw new Error(`sampleCBD: leftover bits: ${a}`);return r}const zs=o=>{const{K:e,PRF:t,XOF:n,HASH512:s,ETA1:r,ETA2:i,du:a,dv:c}=o,u=Ae(1),l=Ae(c),h=Ae(a),p=Fe("publicKey",tt(Ae(12),e),32),d=tt(Ae(12),e),b=Fe("ciphertext",tt(h,e),l),$=Fe("seed",32,32);return{secretCoder:d,lengths:{secretKey:d.bytesLen,publicKey:p.bytesLen,cipherText:b.bytesLen},keygen:C=>{z(C,32,"seed");const f=new Uint8Array(33);f.set(C),f[32]=e;const y=s(f),[w,E]=$.decode(y),k=[],A=[];for(let S=0;S<e;S++)k.push(re.encode($e(t,E,S,r)));const v=n(w);for(let S=0;S<e;S++){const H=re.encode($e(t,E,e+S,r));for(let O=0;O<e;O++){const me=Ct(v.get(O,S));ie(H,He(me,k[O]))}A.push(H)}v.clean();const I={publicKey:p.encode([A,w]),secretKey:d.encode(k)};return X(w,E,k,A,f,y),I},encrypt:(C,f,y)=>{const[w,E]=p.decode(C),k=[];for(let O=0;O<e;O++)k.push(re.encode($e(t,y,O,r)));const A=n(E),v=new Uint16Array(F),I=[];for(let O=0;O<e;O++){const me=$e(t,y,e+O,i),Ze=new Uint16Array(F);for(let Be=0;Be<e;Be++){const ls=Ct(A.get(O,Be));ie(Ze,He(ls,k[Be]))}ie(me,re.decode(Ze)),I.push(me),ie(v,He(w[O],k[O])),X(Ze)}A.clean();const S=$e(t,y,2*e,i);ie(S,re.decode(v));const H=u.decode(f);return ie(H,S),X(w,k,v,S),b.encode([I,H])},decrypt:(C,f)=>{const[y,w]=b.decode(C),E=d.decode(f),k=new Uint16Array(F);for(let A=0;A<e;A++)ie(k,He(E[A],re.encode(y[A])));return Ds(w,re.decode(k)),X(k,E,y),u.encode(w)}}};function Js(o){const e=zs(o),{HASH256:t,HASH512:n,KDF:s}=o,{secretCoder:r,lengths:i}=e,a=Fe("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=Mt(u))=>{z(l,u,"seed");const{publicKey:h,secretKey:p}=e.keygen(l.subarray(0,32)),d=t(h),b=a.encode([p,h,d,l.subarray(32)]);return X(p,d),{publicKey:h,secretKey:b}},getPublicKey:l=>{const[h,p]=a.decode(l);return Uint8Array.from(p)},encapsulate:(l,h=Mt(c))=>{z(l,i.publicKey,"publicKey"),z(h,c,"message");const p=l.subarray(0,384*o.K),d=r.encode(r.decode(Bs(p)));if(!et(d,p))throw X(d),new Error("ML-KEM.encapsulate: wrong publicKey modulus");X(d);const b=n.create().update(h).update(t(l)).digest(),$=e.encrypt(l,h,b.subarray(32,64));return X(b.subarray(32)),{cipherText:$,sharedSecret:b.subarray(0,32)}},decapsulate:(l,h)=>{z(h,a.bytesLen,"secretKey"),z(l,i.cipherText,"cipherText");const p=a.bytesLen-96,d=p+32,b=t(h.subarray(p/2,d));if(!et(b,h.subarray(d,d+32)))throw new Error("invalid secretKey: hash check failed");const[$,C,f,y]=a.decode(h),w=e.decrypt(l,$),E=n.create().update(w).update(f).digest(),k=E.subarray(0,32),A=e.encrypt(C,w,E.subarray(32,64)),v=et(l,A),I=s.create({dkLen:32}).update(y).update(l).digest();return X(w,A,v?I:k),v?k:I}}}function Gs(o,e,t){return en.create({dkLen:o}).update(e).update(new Uint8Array([t])).digest()}const Xs={HASH256:Os,HASH512:qs,KDF:en,XOF:Ps,PRF:Gs},nt=Js({...Xs,...Qs[768]});class _{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||pe(e,"Wallet::constructor"),this.position=this.position||_.generatePosition(),this.key=_.generateKey({secret:e,token:this.token,position:this.position}),this.address=this.address||_.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 Ye;return e&&!t&&(i=_.generatePosition(),t=pe(e,"Wallet::create")),new _({secret:e,bundle:t,token:n,position:i,batchId:s,characters:r})}static isBundleHash(e){return typeof e!="string"?!1:e.length===64&&Ke(e)}static getTokenUnits(e){const t=[];return e.forEach(n=>{t.push(fe.createFromDB(n))}),t}static generateKey({secret:e,token:t,position:n}){if(!e)throw new Ye("Wallet::generateKey() - Secret is required!");if(!n)throw new Ye("Wallet::generateKey() - Position is required!");const s=Ke(e)?e:ot(e,1024),r=Ke(n)?n:ot(n,256),a=BigInt(`0x${s}`)+BigInt(`0x${r}`),c=new L("SHAKE256","TEXT");c.update(a.toString(16)),t&&c.update(t);const u=new L("SHAKE256","TEXT");return u.update(c.getHash("HEX",{outputLen:8192})),u.getHash("HEX",{outputLen:8192})}static generateAddress(e){const t=Te(e,128),n=new L("SHAKE256","TEXT");for(const r in t){let i=t[r];for(let a=1;a<=16;a++){const c=new L("SHAKE256","TEXT");c.update(i),i=c.getHash("HEX",{outputLen:512})}n.update(i)}const s=new L("SHAKE256","TEXT");return s.update(n.getHash("HEX",{outputLen:8192})),s.getHash("HEX",{outputLen:256})}static generatePosition(e=64){return De(e,"abcdef0123456789")}initializeMLKEM(){const e=Qe(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}=nt.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))}balanceAsNumber(){return Number(this.balance)}balanceAsBigInt(){const e=String(this.balance),t=e.includes(".")?e.split(".")[0]:e;return BigInt(t||"0")}setBalanceBigInt(e){this.balance=e.toString()}setBalanceNumber(e){this.balance=String(e)}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=_.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:ce({}))}async encryptMessage(e,t){const n=JSON.stringify(e),s=new TextEncoder().encode(n),r=this.deserializeKey(t),{cipherText:i,sharedSecret:a}=nt.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=nt.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 ge extends x{constructor(e="There is an atom without an index",t=null,n=null){super(e,t,n),this.name="AtomIndexException"}}class rn extends x{constructor(e="The molecular hash does not match",t=null,n=null){super(e,t,n),this.name="MolecularHashMismatchException"}}class on extends x{constructor(e="The molecular hash is missing",t=null,n=null){super(e,t,n),this.name="MolecularHashMissingException"}}class at extends x{constructor(e="",t=null,n=null){super(e,t,n),this.name="PolicyInvalidException"}}class gt extends x{constructor(e="OTS malformed",t=null,n=null){super(e,t,n),this.name="SignatureMalformedException"}}class an extends x{constructor(e="One-time signature (OTS) does not match!",t=null,n=null){super(e,t,n),this.name="SignatureMismatchException"}}class G extends x{constructor(e="Insufficient balance to make transfer",t=null,n=null){super(e,t,n),this.name="TransferBalanceException"}}class be extends x{constructor(e="Token transfer atoms are malformed",t=null,n=null){super(e,t,n),this.name="TransferMalformedException"}}class lt extends x{constructor(e="Token slugs for wallets in transfer do not match!",t=null,n=null){super(e,t,n),this.name="TransferMismatchedException"}}class ct extends x{constructor(e="Invalid remainder provided",t=null,n=null){super(e,t,n),this.name="TransferRemainderException"}}class ln extends x{constructor(e="Sender and recipient(s) cannot be the same",t=null,n=null){super(e,t,n),this.name="TransferToSelfException"}}class ve extends x{constructor(e="Token transfer atoms are unbalanced",t=null,n=null){super(e,t,n),this.name="TransferUnbalancedException"}}class B extends x{constructor(e="Empty meta data.",t=null,n=null){super(e,t,n),this.name="MetaMissingException"}}class ne extends x{constructor(e="Wrong type of token for this isotope",t=null,n=null){super(e,t,n),this.name="WrongTokenTypeException"}}class Ie extends x{constructor(e="Incorrect BatchId",t=null,n=null){super(e,t,n),this.name="BatchIdException"}}class Et{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 je extends x{constructor(e="An incorrect argument!",t=null,n=null){super(e,t,n),this.name="RuleArgumentException"}}class ee extends x{constructor(e="Code exception",t=null,n=null){super(e,t,n),this.name="CodeException"}}class Me{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 je('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(!Nt(e))throw new ee("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 Et?e:Et.toObject(e)}set metaType(e){this.__metaType=e}set metaId(e){this.__metaId=e}static toObject(e){const t=new Me({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 ye(Object.keys(this.toJSON()),["action","metaId","metaType","meta"]).length===4&&this._is("meta")}isCollect(){return ye(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("collect")}isBuffer(){return ye(Object.keys(this.toJSON()),["action","address","token","amount","comparison"]).length===5&&this._is("buffer")}isRemit(){return ye(Object.keys(this.toJSON()),["action","token","amount"]).length===3&&this._is("remit")}isBurn(){return ye(Object.keys(this.toJSON()),["action","token","amount","comparison"]).length===4&&this._is("burn")}_is(e){return this.__action.toLowerCase()===e.toLowerCase()}}class st{constructor({key:e,value:t,comparison:n}){if([e,t,n].some(s=>!s))throw new je("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 Ee{constructor({condition:e=[],callback:t=[]}){for(const n of e)if(!(n instanceof st))throw new je;for(const n of t)if(!(n instanceof Me))throw new je;this.__condition=e,this.__callback=t}set comparison(e){this.__condition.push(e instanceof st?e:st.toObject(e))}set callback(e){this.__callback.push(e instanceof Me?e:Me.toObject(e))}static toObject(e){if(!e.condition)throw new B("Rule::toObject() - Incorrect rule format! There is no condition field.");if(!e.callback)throw new B("Rule::toObject() - Incorrect rule format! There is no callback field.");const t=new Ee({});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 M{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 we{constructor(e){if(e.molecularHash===null)throw new on;if(!e.atoms.length)throw new se;for(const t of e.atoms)if(t.index===null)throw new ge;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.isotopeB()&&this.isotopeF()&&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 Ie;for(const s of t)if(s.batchId===null)throw new Ie}return!0}throw new Ie}isotopeI(){for(const e of this.molecule.getIsotopes("I")){if(e.token!=="USER")throw new ne(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index===0)throw new ge(`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 ne(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 B;if(t.token!=="USER")throw new ne(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);const n=de.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 at(`${i} is missing from the meta.`);for(const c of a)if(!_.isBundleHash(c)&&!["all","self"].includes(c))throw new at(`${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 ne(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 B(`Check::isotopeT() - Required meta field "${s}" is missing!`)}for(const s of["token"])if(!Object.prototype.hasOwnProperty.call(t,s)||!t[s])throw new B(`Check::isotopeT() - Required meta field "${s}" is missing!`);if(e.token!=="USER")throw new ne(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(e.index!==0)throw new ge(`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 B("Check::isotopeR() - Mixing rules with politics!")}if(t.rule){const n=JSON.parse(t.rule);if(!Array.isArray(n))throw new B("Check::isotopeR() - Incorrect rule format!");for(const s of n)Ee.toObject(s);if(n.length<1)throw new B("Check::isotopeR() - No rules!")}}return!0}isotopeP(){for(const e of this.molecule.getIsotopes("P")){if(e.token!=="USER")throw new ne(`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 B('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 ne(`Check::isotopeA() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);if(!e.metaType)throw new B('Check::isotopeA() - Required field "metaType" is missing!');if(!e.metaId)throw new B('Check::isotopeA() - Required field "metaId" is missing!');const t=e.aggregatedMeta();if(!Object.prototype.hasOwnProperty.call(t,"action")||!t.action)throw new B('Check::isotopeA() - Required meta field "action" is missing!')}return!0}isotopeB(){const e=this.molecule.getIsotopes("B");if(e.length===0)return!0;for(const n of e){if(!n.metaType||n.metaType!=="walletBundle")throw new B('Check::isotopeB() - B-isotope atoms must have metaType "walletBundle"!');if(!n.metaId)throw new B("Check::isotopeB() - B-isotope atoms must have a metaId!");const s=Number(n.value);if(Number.isNaN(s))throw new be("Check::isotopeB() - B-isotope atom value is not a valid number!")}const t=this.molecule.getIsotopes("V");if(t.length>0){let n=0;for(const s of[...t,...e]){const r=Number(s.value);Number.isNaN(r)||(n+=r)}if(n!==0)throw new ve("Check::isotopeB() - V+B atom values do not balance to zero!")}return!0}isotopeF(){const e=this.molecule.getIsotopes("F");if(e.length===0)return!0;for(const n of e){if(!n.metaType||n.metaType!=="walletBundle")throw new B('Check::isotopeF() - F-isotope atoms must have metaType "walletBundle"!');if(!n.metaId)throw new B("Check::isotopeF() - F-isotope atoms must have a metaId!");const s=Number(n.value);if(Number.isNaN(s))throw new be("Check::isotopeF() - F-isotope atom value is not a valid number!");if(s<0)throw new be("Check::isotopeF() - F-isotope atom value must not be negative!")}const t=this.molecule.getIsotopes("V");if(t.length>0){let n=0;for(const s of[...t,...e]){const r=Number(s.value);Number.isNaN(r)||(n+=r)}if(n!==0)throw new ve("Check::isotopeF() - V+F atom values do not balance to zero!")}return!0}isotopeV(e=null){const t=this.molecule.getIsotopes("V");if(t.length===0)return!0;const n=this.molecule.getIsotopes("B").length>0||this.molecule.getIsotopes("F").length>0,s=this.molecule.atoms[0];if(!n&&s.isotope==="V"&&t.length===2){const a=t[t.length-1];if(s.token!==a.token)throw new lt;if(a.value<0)throw new be;if(Number(s.value)+Number(a.value)!==0)throw new ve;return!0}let r=0,i=0;for(const a in this.molecule.atoms)if(Object.prototype.hasOwnProperty.call(this.molecule.atoms,a)){const c=this.molecule.atoms[a];if(c.isotope!=="V")continue;if(i=c.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');if(c.token!==s.token)throw new lt;if(a>0){if(i<0)throw new be;if(c.walletAddress===s.walletAddress)throw new ln}r+=i}if(!n&&r!==0)throw new ve;if(e){if(i=s.value*1,Number.isNaN(i))throw new TypeError('Invalid isotope "V" values');const a=Number(e.balance)+i;if(a<0)throw new G;if(!n&&a!==r)throw new ct}else if(i!==0)throw new ct;return!0}molecularHash(){if(this.molecule.molecularHash!==g.hashAtoms({atoms:this.molecule.atoms}))throw new rn;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=Kt(t),t.length!==2048))throw new gt;const n=Te(t,128);let s="";for(const p in n){let d=n[p];for(let b=0,$=8+e[p];b<$;b++)d=new L("SHAKE256","TEXT").update(d).getHash("HEX",{outputLen:512});s+=d}const r=new L("SHAKE256","TEXT");r.update(s);const i=r.getHash("HEX",{outputLen:8192}),a=new L("SHAKE256","TEXT");a.update(i);const c=a.getHash("HEX",{outputLen:256}),u=this.molecule.atoms[0];let l=u.walletAddress;const h=M.get(u.aggregatedMeta(),"signingWallet");if(h&&(l=M.get(JSON.parse(h),"address")),c!==l)throw new an;return!0}static fromServerData({molecularHash:e,bundleHash:t,cellSlug:n=null,status:s=null,createdAt:r=null,atoms:i=[]}){const a=i.map(c=>{let u=[];if(c.metasJson)try{const l=JSON.parse(c.metasJson);Array.isArray(l)?u=l:l&&typeof l=="object"&&(u=Object.entries(l).map(([h,p])=>({key:h,value:p})))}catch{u=[]}return{position:c.position||null,walletAddress:c.walletAddress||null,isotope:c.isotope||null,token:c.tokenSlug||c.token||null,value:c.value!=null?String(c.value):null,batchId:c.batchId||null,metaType:c.metaType||null,metaId:c.metaId||null,meta:u,index:c.index!=null?c.index:null,otsFragment:c.otsFragment||null,createdAt:c.createdAt||null}});return V.fromJSON({molecularHash:e,bundle:t,cellSlug:n,status:s,createdAt:r,atoms:a})}static verifyFromServerData(e){try{const t=we.fromServerData(e);return new we(t).verify(),{molecularHash:e.molecularHash,verified:!0,error:null}}catch(t){return{molecularHash:e.molecularHash||null,verified:!1,error:t.message||String(t)}}}}class ae extends x{constructor(e="Insufficient balance for requested transfer",t=null,n=null){super(e,t,n),this.name="BalanceInsufficientException"}}class Le extends x{constructor(e="Amount cannot be negative!",t=null,n=null){super(e,t,n),this.name="NegativeAmountException"}}class V{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=[],this.parentHashes=[],i!==null&&Object.prototype.hasOwnProperty.call(Ne,i)&&(this.version=String(i)),(s||n)&&(this.remainderWallet=s||_.create({secret:e,bundle:t,token:n.token,batchId:n.batchId,characters:n.characters}))}withParentHashes(e){return this.parentHashes=Array.isArray(e)?[...e]:[],this}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 V({}),JSON.parse(e)),n=Object.keys(new V({}));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 V.isotopeFilter(e,this.atoms)}generateIndex(){return V.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=_.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 U(e)})),this}addPolicyAtom({metaType:e,metaId:t,meta:n={},policy:s={}}){const r=new U(n);r.addPolicy(s);const i=_.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 Le("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 Le("Molecule::replenishToken() - Amount to replenish must be positive!");if(t.length){t=_.getTokenUnits(t),this.remainderWallet.tokenUnits=this.sourceWallet.tokenUnits;for(const n of t)this.remainderWallet.tokenUnits.push(n);this.remainderWallet.balance=String(this.remainderWallet.tokenUnits.length),this.sourceWallet.tokenUnits=t,this.sourceWallet.balance=String(this.sourceWallet.tokenUnits.length)}else this.remainderWallet.balance=String(Number(this.sourceWallet.balance)+e),this.sourceWallet.balance=String(e);return this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:Number(this.sourceWallet.balance)})),this.addAtom(g.create({isotope:"V",wallet:this.remainderWallet,value:Number(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}addStackableTransfer({recipientWallet:e,amount:t}){if(t<=0)throw new Le("Molecule::addStackableTransfer() - Amount must be positive!");if(this.sourceWallet.balance-t<0)throw new ae;const n=this.sourceWallet.batchId||ce({});return this.addAtom(g.create({isotope:"V",wallet:this.sourceWallet,value:-t,batchId:n})),this.addAtom(g.create({isotope:"V",wallet:e,value:t,metaType:"walletBundle",metaId:e.bundle,batchId:ce({})})),this.addAtom(g.create({isotope:"V",wallet:this.remainderWallet,value:this.sourceWallet.balance-t,metaType:"walletBundle",metaId:this.remainderWallet.bundle,batchId:n})),this}initDepositBuffer({amount:e,tradeRates:t}){if(this.sourceWallet.balance-e<0)throw new ae;const n=_.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 U;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?ce({}):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 U(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 Ee?a:Ee.toObject(a));const i=new U({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 U),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 U().setShadowWalletClaim(!0);return this.initWalletCreation(e,t)}initIdentifierCreation({type:e,contact:t,code:n}){const s={code:n,hash:pe(t.trim(),"Molecule::initIdentifierCreation")};return this.addAtom(g.create({isotope:"C",wallet:this.sourceWallet,metaType:"identifier",metaId:e,meta:new U(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 U(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 U({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 U({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 U(r),batchId:i})),this.addContinuIdAtom(),this}initAuthorization({meta:e}){return this.addAtom(g.create({isotope:"U",wallet:this.sourceWallet,meta:new U(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||pe(this.secret,"Molecule::sign")),this.molecularHash=g.hashAtoms({atoms:this.atoms});const s=this.atoms[0];let r=s.position;const i=M.get(s.aggregatedMeta(),"signingWallet");if(i&&(r=M.get(JSON.parse(i),"position")),!r)throw new gt("Signing wallet must have a position!");const a=_.generateKey({secret:this.secret,token:s.token,position:s.position}),c=Te(a,128),u=this.normalizedHash();let l="";for(const d in c){let b=c[d];for(let $=0,C=8-u[d];$<C;$++)b=new L("SHAKE256","TEXT").update(b).getHash("HEX",{outputLen:512});l+=b}n&&(l=Pt(l));const h=Te(l,Math.ceil(l.length/this.atoms.length));let p=null;for(let d=0,b=h.length;d<b;d++)this.atoms[d].otsFragment=h[d],p=this.atoms[d].position;return p}signSync(e={}){return this.sign(e)}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 this.parentHashes&&this.parentHashes.length>0&&(s.parentHashes=this.parentHashes),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 V({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,i.parentHashes=Array.isArray(r.parentHashes)?[...r.parentHashes]:[],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 _({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=String(r.sourceWallet.balance!=null?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 _({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=String(r.remainderWallet.balance!=null?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 we(this).verify(e)}normalizedHash(){return V.normalize(V.enumerate(this.molecularHash))}}class ke{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 ke(e);return n.setWallet(t),n}static restore(e,t){const n=new _({secret:t,token:"AUTH",position:e.wallet.position,characters:e.wallet.characters});return ke.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()}}}const rt=10**18;class he{static val(e){return Math.abs(e*rt)<1?0:e}static cmp(e,t,n=!1){const s=he.val(e)*rt,r=he.val(t)*rt;return Math.abs(s-r)<1?0:s>r?1:-1}static equal(e,t){return he.cmp(e,t)===0}}class te extends x{constructor(e="GraphQL did not provide a valid response.",t=null,n=null){super(e,t,n),this.name="InvalidResponseException"}}class Re extends x{constructor(e="Authorization token missing or invalid.",t=null,n=null){super(e,t,n),this.name="UnauthenticatedException"}}class R{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 te;if(M.has(this.$__response,this.errorKey)){const s=M.get(this.$__response,this.errorKey);throw String(s).includes("Unauthenticated")?new Re:new te}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 Re:new te(`GraphQL Error: ${s}`)}this.init()}init(){}data(){if(!this.dataKey)return this.response();if(!this.response().data)throw new te("Response has no data field");if(!M.has(this.response(),this.dataKey))throw new te(`Missing expected field: ${this.dataKey}`);return M.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 K{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 R({query:this,json:e})}createQuery({variables:e=null}){if(this.$__variables=this.compiledVariables(e),!this.uri())throw new ee("Query::createQuery() - Node URI was not initialized for this client instance!");if(this.$__query===null)throw new ee("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 R({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 cn extends R{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 _({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=String(t.amount!=null?t.amount:0)),e}}class un extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query ($bundle: String!) {
|
|
5
5
|
ContinuId(bundle: $bundle) {
|
|
6
6
|
address,
|
|
7
7
|
bundleHash,
|
|
@@ -13,7 +13,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
13
13
|
amount,
|
|
14
14
|
createdAt
|
|
15
15
|
}
|
|
16
|
-
}`}createResponse(e){return new
|
|
16
|
+
}`}createQueryContext(){return{requestPolicy:"network-only"}}createResponse(e){return new cn({query:this,json:e})}}class hn extends R{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=de.aggregateMeta(n.metas),t[n.bundleHash]=n}),t}}class dn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $bundleHashes: [ String! ] ) {
|
|
17
17
|
WalletBundle( bundleHashes: $bundleHashes ) {
|
|
18
18
|
bundleHash,
|
|
19
19
|
metas {
|
|
@@ -25,8 +25,8 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
25
25
|
},
|
|
26
26
|
createdAt
|
|
27
27
|
}
|
|
28
|
-
}`}createResponse(e){return new
|
|
29
|
-
Wallet( bundleHash: $bundleHash,
|
|
28
|
+
}`}createResponse(e){return new hn({query:this,json:e})}}class qe extends R{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=_.create({bundle:e.bundleHash,token:e.tokenSlug,batchId:e.batchId,characters:e.characters}):(n=new _({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(fe.createFromGraphQL(s));if(e.tradeRates.length)for(const s of e.tradeRates)n.tradeRates[s.tokenSlug]=s.amount;return n.balance=String(e.amount!=null?e.amount:0),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(qe.toClientWallet({data:s,secret:e}));return n}payload(){return this.getWallets()}}class pn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $bundleHash: String, $token: String ) {
|
|
29
|
+
Wallet( bundleHash: $bundleHash, token: $token ) {
|
|
30
30
|
address,
|
|
31
31
|
bundleHash,
|
|
32
32
|
token {
|
|
@@ -52,7 +52,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
52
52
|
amount
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
}`}createResponse(e){return new
|
|
55
|
+
}`}createResponse(e){return new qe({query:this,json:e})}}class fn extends R{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:qe.toClientWallet({data:e})}}class mn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
|
|
56
56
|
Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
|
|
57
57
|
address,
|
|
58
58
|
bundleHash,
|
|
@@ -74,7 +74,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
74
74
|
amount
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
}`}createResponse(e){return new
|
|
77
|
+
}`}createResponse(e){return new fn({query:this,json:e})}}class yn extends R{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 ut extends K{constructor(e,t){super(e,t),this.$__query=T.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
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 ) {
|
|
79
79
|
metaType,
|
|
80
80
|
instanceCount {
|
|
@@ -98,11 +98,11 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
98
98
|
total
|
|
99
99
|
}
|
|
100
100
|
}
|
|
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
|
|
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 yn({query:this,json:e})}}class Se extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $batchId: String ) {
|
|
102
102
|
Batch( batchId: $batchId ) {
|
|
103
|
-
${
|
|
103
|
+
${Se.getFields()},
|
|
104
104
|
children {
|
|
105
|
-
${
|
|
105
|
+
${Se.getFields()}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}`}static getFields(){return`batchId,
|
|
@@ -154,11 +154,11 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
154
154
|
throughMetas {
|
|
155
155
|
key,
|
|
156
156
|
value
|
|
157
|
-
}`}createResponse(e){const t=new
|
|
157
|
+
}`}createResponse(e){const t=new R({query:this,json:e});return t.dataKey="data.Batch",t}}class gn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $batchId: String ) {
|
|
158
158
|
BatchHistory( batchId: $batchId ) {
|
|
159
|
-
${
|
|
159
|
+
${Se.getFields()}
|
|
160
160
|
}
|
|
161
|
-
}`}createResponse(e){const t=new
|
|
161
|
+
}`}createResponse(e){const t=new R({query:this,json:e});return t.dataKey="data.BatchHistory",t}}class Q extends R{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ProposeMolecule"}),this.$__clientMolecule=e.molecule()}init(){const e=M.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 V({});return t.molecularHash=M.get(e,"molecularHash"),t.status=M.get(e,"status"),t.createdAt=M.get(e,"createdAt"),t}success(){return this.status()==="accepted"}status(){return M.get(this.data(),"status","rejected")}reason(){return M.get(this.data(),"reason","Invalid response from server")}payload(){return this.$__payload}}class We extends K{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 R({query:this,json:{data:null,errors:[{message:"Mutation was cancelled"}]}});throw s}}createQueryContext(){return{}}}class W extends We{constructor(e,t,n){super(e,t),this.$__molecule=n,this.$__remainderWallet=null,this.$__query=T.gql`mutation( $molecule: MoleculeInput! ) {
|
|
162
162
|
ProposeMolecule( molecule: $molecule ) {
|
|
163
163
|
molecularHash,
|
|
164
164
|
height,
|
|
@@ -171,13 +171,21 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
171
171
|
processedAt,
|
|
172
172
|
broadcastedAt,
|
|
173
173
|
}
|
|
174
|
-
}`}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 Q({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 bn extends Q{payloadKey(e){if(!M.has(this.payload(),e))throw new te(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);return M.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}expiresAt(){try{const t=this.payloadKey("expiresAt");if(t)return Number(t)}catch{}const e=Number(this.time());return e>=1577836800?e:Math.floor(Date.now()/1e3)+Math.floor(e/1e3)}encrypt(){return this.payloadKey("encrypt")}pubKey(){return this.payloadKey("key")}}class wn extends W{fillMolecule({meta:e}){this.$__molecule.initAuthorization({meta:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new bn({query:this,json:e})}}class kn extends Q{}class Sn extends W{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 kn({query:this,json:e})}}class _n extends Q{}class An extends W{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 _n({query:this,json:e})}}class $n extends Q{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 vn extends W{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 $n({query:this,json:e})}}class xn extends Q{}class In extends W{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 xn({query:this,json:e})}}class Mn extends Q{}class Tn extends W{fillMolecule({token:e,batchId:t=null}){const n=_.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 Mn({query:this,json:e})}}class Cn extends Q{}class En extends W{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 Cn({query:this,json:e})}}class Rn extends Q{}class On extends W{fillMolecule({host:e}){this.$__molecule.initPeering({host:e}),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Rn({query:this,json:e})}}class qn extends Q{}class Wn extends W{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 qn({query:this,json:e})}}class Bn extends R{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.LinkIdentifier"})}success(){return M.get(this.data(),"set")}message(){return M.get(this.data(),"message")}}class Un extends We{constructor(e,t){super(e,t),this.$__query=T.gql`mutation( $bundle: String!, $type: String!, $content: String! ) {
|
|
175
|
+
LinkIdentifier( bundle: $bundle, type: $type, content: $content ) {
|
|
176
|
+
type,
|
|
177
|
+
bundle,
|
|
178
|
+
content,
|
|
179
|
+
set,
|
|
180
|
+
message
|
|
181
|
+
}
|
|
182
|
+
}`}createResponse(e){return new Bn({query:this,json:e})}}class Hn extends Q{}class Pn extends W{fillMolecule(e){this.$__molecule.initWalletCreation(e),this.$__molecule.sign({}),this.$__molecule.check()}createResponse(e){return new Hn({query:this,json:e})}}class Kn extends R{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(!M.has(this.payload(),e))throw new te(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return M.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}expiresAt(){try{const t=this.payloadKey("expiresAt");if(t)return Number(t)}catch{}const e=Number(this.time());return e>=1577836800?e:Math.floor(Date.now()/1e3)+Math.floor(e/1e3)}pubKey(){return this.payloadKey("key")}encrypt(){return this.payloadKey("encrypt")}}class Nn extends We{constructor(e,t){super(e,t),this.$__query=T.gql`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
|
|
175
183
|
AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
|
|
176
184
|
token,
|
|
177
185
|
pubkey,
|
|
178
186
|
expiresAt
|
|
179
187
|
}
|
|
180
|
-
}`}createResponse(e){return new
|
|
188
|
+
}`}createResponse(e){return new Kn({query:this,json:e})}}class ht extends x{constructor(e="The shadow wallet does not exist",t=null,n=null){super(e,t,n),this.name="WalletShadowException"}}class Fn extends x{constructor(e="Stackable tokens with unit IDs cannot have decimal places!",t=null,n=null){super(e,t,n),this.name="StackableUnitDecimalsException"}}class xe extends x{constructor(e="Stackable tokens with unit IDs cannot have an amount!",t=null,n=null){super(e,t,n),this.name="StackableUnitAmountException"}}class Ge{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 ee("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");if(this.$__subscribe===null)throw new ee("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 ee(`${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 Zs extends Ge{constructor(e){super(e),this.$__subscribe=T.gql`
|
|
181
189
|
subscription onCreateMolecule ( $bundle: String! ) {
|
|
182
190
|
CreateMolecule( bundle: $bundle ) {
|
|
183
191
|
molecularHash,
|
|
@@ -222,7 +230,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
222
230
|
}
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
|
-
`}}class
|
|
233
|
+
`}}class Ys extends Ge{constructor(e){super(e),this.$__subscribe=T.gql`
|
|
226
234
|
subscription onWalletStatus ( $bundle: String!, $token: String! ) {
|
|
227
235
|
WalletStatus( bundle: $bundle, token: $token ) {
|
|
228
236
|
bundle,
|
|
@@ -231,7 +239,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
231
239
|
balance,
|
|
232
240
|
}
|
|
233
241
|
}
|
|
234
|
-
`}}class
|
|
242
|
+
`}}class er extends Ge{constructor(e){super(e),this.$__subscribe=T.gql`
|
|
235
243
|
subscription onActiveWallet ( $bundle: String! ) {
|
|
236
244
|
ActiveWallet( bundle: $bundle ) {
|
|
237
245
|
address,
|
|
@@ -269,7 +277,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
269
277
|
}
|
|
270
278
|
}
|
|
271
279
|
}
|
|
272
|
-
`}}class
|
|
280
|
+
`}}class tr extends Ge{constructor(e){super(e),this.$__subscribe=T.gql`
|
|
273
281
|
subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
|
|
274
282
|
ActiveUser( metaType: $metaType, metaId: $metaId ) {
|
|
275
283
|
bundleHash,
|
|
@@ -279,7 +287,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
279
287
|
createdAt,
|
|
280
288
|
updatedAt
|
|
281
289
|
}
|
|
282
|
-
}`}}class
|
|
290
|
+
}`}}class Ln extends R{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.ActiveSession"})}}class Qn extends We{constructor(e,t){super(e,t),this.$__query=T.gql`mutation(
|
|
283
291
|
$bundleHash: String!,
|
|
284
292
|
$metaType: String!,
|
|
285
293
|
$metaId: String!,
|
|
@@ -307,7 +315,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
307
315
|
createdAt,
|
|
308
316
|
updatedAt
|
|
309
317
|
}
|
|
310
|
-
}`}createResponse(e){return new
|
|
318
|
+
}`}createResponse(e){return new Ln({query:this,json:e})}}class jn extends R{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 Dn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
|
|
311
319
|
ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
|
|
312
320
|
bundleHash,
|
|
313
321
|
metaType,
|
|
@@ -316,7 +324,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
316
324
|
createdAt,
|
|
317
325
|
updatedAt
|
|
318
326
|
}
|
|
319
|
-
}`}createResponse(e){return new
|
|
327
|
+
}`}createResponse(e){return new jn({query:this,json:e})}}class Vn extends R{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 zn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query UserActivity (
|
|
320
328
|
$bundleHash:String,
|
|
321
329
|
$metaType: String,
|
|
322
330
|
$metaId: String,
|
|
@@ -389,7 +397,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
389
397
|
}
|
|
390
398
|
}
|
|
391
399
|
}
|
|
392
|
-
}`}createResponse(e){return new
|
|
400
|
+
}`}createResponse(e){return new Vn({query:this,json:e})}}class Jn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
|
|
393
401
|
Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
|
|
394
402
|
slug,
|
|
395
403
|
name,
|
|
@@ -399,7 +407,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
399
407
|
amount,
|
|
400
408
|
icon,
|
|
401
409
|
}
|
|
402
|
-
}`}createResponse(e){return new
|
|
410
|
+
}`}createResponse(e){return new R({query:this,json:e,dataKey:"data.Token"})}}class dt extends x{constructor(e="Authorization attempt rejected by ledger.",t=null,n=null){super(e,t,n),this.name="AuthorizationRejectedException"}}class Gn extends R{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 pt extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query(
|
|
403
411
|
$molecularHashes: [String!],
|
|
404
412
|
$bundleHashes: [String!],
|
|
405
413
|
$positions:[String!],
|
|
@@ -455,7 +463,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
455
463
|
total
|
|
456
464
|
}
|
|
457
465
|
}
|
|
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:
|
|
466
|
+
}`}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:b,batchIds:$,batchId:C,values:f,value:y,metaTypes:w,metaType:E,metaIds:k,metaId:A,indexes:v,index:I,filter:S,latest:H,queryArgs:O}){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)),b&&(d=d||[],d.push(b)),C&&($=$||[],$.push(C)),y&&(f=f||[],f.push(y)),E&&(w=w||[],w.push(E)),A&&(k=k||[],k.push(A)),I&&(v=v||[],v.push(I)),{molecularHashes:e,bundleHashes:n,positions:r,walletAddresses:a,isotopes:u,tokenSlugs:h,cellSlugs:d,batchIds:$,values:f,metaTypes:w,metaIds:k,indexes:v,filter:S,latest:H,queryArgs:O}}createResponse(e){return new Gn({query:this,json:e})}}class Xn extends R{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 Zn extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query( $metaType: String, $metaId: String, ) {
|
|
459
467
|
Policy( metaType: $metaType, metaId: $metaId ) {
|
|
460
468
|
molecularHash,
|
|
461
469
|
position,
|
|
@@ -466,7 +474,40 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
466
474
|
rule,
|
|
467
475
|
createdAt
|
|
468
476
|
}
|
|
469
|
-
}`}createResponse(e){return new
|
|
477
|
+
}`}createResponse(e){return new Xn({query:this,json:e})}}class Yn extends R{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 ft extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
478
|
+
MetaTypeViaAtom(
|
|
479
|
+
metaTypes: $metaTypes
|
|
480
|
+
metaIds: $metaIds
|
|
481
|
+
atomValues: $atomValues
|
|
482
|
+
cellSlugs: $cellSlugs
|
|
483
|
+
filter: $filter,
|
|
484
|
+
latest: $latest,
|
|
485
|
+
queryArgs: $queryArgs
|
|
486
|
+
countBy: $countBy
|
|
487
|
+
) {
|
|
488
|
+
metaType,
|
|
489
|
+
instanceCount {
|
|
490
|
+
key,
|
|
491
|
+
value
|
|
492
|
+
},
|
|
493
|
+
instances {
|
|
494
|
+
metaType,
|
|
495
|
+
metaId,
|
|
496
|
+
createdAt,
|
|
497
|
+
metas( values: $values, keys: $keys ) {
|
|
498
|
+
molecularHash,
|
|
499
|
+
position,
|
|
500
|
+
key,
|
|
501
|
+
value,
|
|
502
|
+
createdAt
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
paginatorInfo {
|
|
506
|
+
currentPage,
|
|
507
|
+
total
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}`}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 Yn({query:this,json:e})}}class Xe extends R{constructor({query:e,json:t}){super({query:e,json:t,dataKey:"data.MetaTypeViaAtom"})}static extractMetasFromMolecule(e,t,n){if(!e||!e.atoms)return[];const s=[];for(const r of e.atoms){if(r.metaType!==t||r.metaId!==n||!r.metasJson)continue;let i;try{if(i=JSON.parse(r.metasJson),!Array.isArray(i))continue}catch{continue}for(const a of i)s.push({molecularHash:e.molecularHash,position:r.position,key:a.key,value:a.value,createdAt:r.createdAt})}return s}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.map(s=>{let r=s.metas;return(!r||r.length===0)&&(r=Xe.extractMetasFromMolecule(s.molecule,s.metaType,s.metaId)),{...s,metas:r}})),n.instanceCount&&(t.instanceCount=n.instanceCount),n.paginatorInfo&&(t.paginatorInfo=n.paginatorInfo),t}verifyIntegrity(){var s;const e=[],t=this.data();if(!t||t.length===0)return{verified:!0,molecules:e};const n=((s=t[t.length-1])==null?void 0:s.instances)||[];for(const r of n)r.molecule&&e.push(we.verifyFromServerData(r.molecule));return{verified:e.length===0||e.every(r=>r.verified),molecules:e}}}class mt extends K{constructor(e,t){super(e,t),this.$__query=T.gql`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
470
511
|
MetaTypeViaAtom(
|
|
471
512
|
metaTypes: $metaTypes
|
|
472
513
|
metaIds: $metaIds
|
|
@@ -492,6 +533,27 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
492
533
|
key,
|
|
493
534
|
value,
|
|
494
535
|
createdAt
|
|
536
|
+
},
|
|
537
|
+
molecule {
|
|
538
|
+
molecularHash,
|
|
539
|
+
bundleHash,
|
|
540
|
+
cellSlug,
|
|
541
|
+
status,
|
|
542
|
+
createdAt,
|
|
543
|
+
atoms {
|
|
544
|
+
position,
|
|
545
|
+
walletAddress,
|
|
546
|
+
isotope,
|
|
547
|
+
tokenSlug,
|
|
548
|
+
value,
|
|
549
|
+
batchId,
|
|
550
|
+
metaType,
|
|
551
|
+
metaId,
|
|
552
|
+
index,
|
|
553
|
+
createdAt,
|
|
554
|
+
otsFragment,
|
|
555
|
+
metasJson
|
|
556
|
+
}
|
|
495
557
|
}
|
|
496
558
|
},
|
|
497
559
|
paginatorInfo {
|
|
@@ -499,7 +561,7 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
499
561
|
total
|
|
500
562
|
}
|
|
501
563
|
}
|
|
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 Qs({query:this,json:e})}}class Ds extends V{}class Vs extends q{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 Ds({query:this,json:e})}}class zs extends q{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class Js extends q{fillMolecule({recipients:e,signingWallet:t}){this.$__molecule.initWithdrawBuffer({recipients:e,signingWallet:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}function X(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 Z(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])}}}var R={exclude:[],include:[],logging:!0},Yt={},Gs={timeout:"true"},J=function(o,e){typeof window<"u"&&(Yt[o]=e)},Xs=function(){return Object.fromEntries(Object.entries(Yt).filter((function(o){var e,t=o[0];return!(!((e=R==null?void 0:R.exclude)===null||e===void 0)&&e.includes(t))})).filter((function(o){var e,t,n,s,r=o[0];return!((e=R==null?void 0:R.include)===null||e===void 0)&&e.some((function(i){return i.includes(".")}))?(t=R==null?void 0:R.include)===null||t===void 0?void 0:t.some((function(i){return i.startsWith(r)})):((n=R==null?void 0:R.include)===null||n===void 0?void 0:n.length)===0||((s=R==null?void 0:R.include)===null||s===void 0?void 0:s.includes(r))})).map((function(o){return[o[0],(0,o[1])()]})))};function Ee(o){return o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),(o^=o>>>16)>>>0}var B=new Uint32Array([597399067,2869860233,951274213,2716044179]);function j(o,e){return o<<e|o>>>32-e}function nt(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],B[0]),l[0]=j(l[0],15),l[0]=Math.imul(l[0],B[1]),i[0]=i[0]^l[0],i[0]=j(i[0],19),i[0]=i[0]+i[1],i[0]=Math.imul(i[0],5)+1444728091,l[1]=Math.imul(l[1],B[1]),l[1]=j(l[1],16),l[1]=Math.imul(l[1],B[2]),i[1]=i[1]^l[1],i[1]=j(i[1],17),i[1]=i[1]+i[2],i[1]=Math.imul(i[1],5)+197830471,l[2]=Math.imul(l[2],B[2]),l[2]=j(l[2],17),l[2]=Math.imul(l[2],B[3]),i[2]=i[2]^l[2],i[2]=j(i[2],15),i[2]=i[2]+i[3],i[2]=Math.imul(i[2],5)+2530024501,l[3]=Math.imul(l[3],B[3]),l[3]=j(l[3],18),l[3]=Math.imul(l[3],B[0]),i[3]=i[3]^l[3],i[3]=j(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],B[3]),u[3]=j(u[3],18),u[3]=Math.imul(u[3],B[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],B[2]),u[2]=j(u[2],17),u[2]=Math.imul(u[2],B[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],B[1]),u[1]=j(u[1],16),u[1]=Math.imul(u[1],B[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],B[0]),u[0]=j(u[0],15),u[0]=Math.imul(u[0],B[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]=Ee(i[0]),i[1]=Ee(i[1]),i[2]=Ee(i[2]),i[3]=Ee(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 Ys(o,e,t){return Promise.all(o.map((function(n){return Promise.race([n,Zs(e,t)])})))}var er="0.19.1";function tr(){return er}function en(){return X(this,void 0,void 0,(function(){var o,e,t,n,s;return Z(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),o=Xs(),e=Object.keys(o),[4,Ys(Object.values(o),(R==null?void 0:R.timeout)||1e3,Gs)];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,tn(s,R.exclude||[],R.include||[],"")];case 2:throw r.sent();case 3:return[2]}}))}))}function tn(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=tn(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 nr(o){return X(this,void 0,void 0,(function(){var e,t;return Z(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,en()];case 1:return e=n.sent(),t=nt(JSON.stringify(e)),Math.random()<.001&&R.logging&&(function(s,r){X(this,void 0,void 0,(function(){var i,a;return Z(this,(function(c){switch(c.label){case 0:if(i="https://logging.thumbmarkjs.com/v1/log",a={thumbmark:s,components:r,version:tr()},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 sr(o){for(var e=0,t=0;t<o.length;++t)e+=Math.abs(o[t]);return e}function nn(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(rr(r))}var a=new Uint8ClampedArray(n);return new ImageData(a,e,t)}function rr(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 xe(){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"}}J("audio",(function(){return X(this,void 0,void 0,(function(){return Z(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:sr(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 ir=xe().name!=="SamsungBrowser"?1:3,xt=280,It=20;xe().name!="Firefox"&&J("canvas",(function(){return document.createElement("canvas").getContext("2d"),new Promise((function(o){var e=Array.from({length:ir},(function(){return(function(){var t=document.createElement("canvas"),n=t.getContext("2d");if(!n)return new ImageData(1,1);t.width=xt,t.height=It;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:nt(nn(e,xt,It).data.toString()).toString()})}))}));var Xe,or=["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"],ar=["monospace","sans-serif","serif"];function Mt(o,e){if(!o)throw new Error("Canvas context not supported");return o.font,o.font="72px ".concat(e),o.measureText("WwMmLli0Oo").width}function lr(){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 cr(){var o=new Float32Array(1),e=new Uint8Array(o.buffer);return o[0]=1/0,o[0]=o[0]-o[0],e[3]}function ur(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 hr(){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 dr(){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}xe().name!="Firefox"&&J("fonts",(function(){var o=this;return new Promise((function(e,t){try{(function(n){var s;X(this,void 0,void 0,(function(){var r,i,a;return Z(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 X(o,void 0,void 0,(function(){var r,i,a,c;return Z(this,(function(u){return r=s.createElement("canvas"),i=r.getContext("2d"),a=ar.map((function(l){return Mt(i,l)})),c={},or.forEach((function(l){var h=Mt(i,l);a.includes(h)||(c[l]=h)})),e(c),[2]}))}))}))}catch{t({error:"unsupported"})}}))})),J("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:lr(),architecture:cr(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:n.jsHeapSizeLimit||0})}))})),J("locales",(function(){return new Promise((function(o){o({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),J("permissions",(function(){return X(this,void 0,void 0,(function(){var o;return Z(this,(function(e){return Xe=(R==null?void 0:R.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:(R==null?void 0:R.retries)||3},(function(){return(function(){return X(this,void 0,void 0,(function(){var t,n,s,r,i;return Z(this,(function(a){switch(a.label){case 0:t={},n=0,s=Xe,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 ur(t,Xe)}))]}))}))})),J("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})}))})),J("screen",(function(){return new Promise((function(o){o({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:hr()})}))})),J("system",(function(){return new Promise((function(o){var e=xe();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:dr()})}))}));var P,pr=xe().name!=="SamsungBrowser"?1:3,f=null;J("webgl",(function(){return X(this,void 0,void 0,(function(){var o;return Z(this,(function(e){typeof document<"u"&&((P=document.createElement("canvas")).width=200,P.height=100,f=P.getContext("webgl"));try{if(!f)throw new Error("WebGL not supported");return o=Array.from({length:pr},(function(){return(function(){try{if(!f)throw new Error("WebGL not supported");var t=`
|
|
564
|
+
}`}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 Xe({query:this,json:e})}}class es extends Q{}class ts extends W{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 es({query:this,json:e})}}class ns extends W{fillMolecule({amount:e,tradeRates:t}){this.$__molecule.initDepositBuffer({amount:e,tradeRates:t}),this.$__molecule.sign({}),this.$__molecule.check(this.$__molecule.sourceWallet)}}class ss extends W{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])}}}var q={exclude:[],include:[],logging:!0},rs={},nr={timeout:"true"},J=function(o,e){typeof window<"u"&&(rs[o]=e)},sr=function(){return Object.fromEntries(Object.entries(rs).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 Pe(o){return o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),(o^=o>>>16)>>>0}var P=new Uint32Array([597399067,2869860233,951274213,2716044179]);function D(o,e){return o<<e|o>>>32-e}function bt(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],P[0]),l[0]=D(l[0],15),l[0]=Math.imul(l[0],P[1]),i[0]=i[0]^l[0],i[0]=D(i[0],19),i[0]=i[0]+i[1],i[0]=Math.imul(i[0],5)+1444728091,l[1]=Math.imul(l[1],P[1]),l[1]=D(l[1],16),l[1]=Math.imul(l[1],P[2]),i[1]=i[1]^l[1],i[1]=D(i[1],17),i[1]=i[1]+i[2],i[1]=Math.imul(i[1],5)+197830471,l[2]=Math.imul(l[2],P[2]),l[2]=D(l[2],17),l[2]=Math.imul(l[2],P[3]),i[2]=i[2]^l[2],i[2]=D(i[2],15),i[2]=i[2]+i[3],i[2]=Math.imul(i[2],5)+2530024501,l[3]=Math.imul(l[3],P[3]),l[3]=D(l[3],18),l[3]=Math.imul(l[3],P[0]),i[3]=i[3]^l[3],i[3]=D(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],P[3]),u[3]=D(u[3],18),u[3]=Math.imul(u[3],P[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],P[2]),u[2]=D(u[2],17),u[2]=Math.imul(u[2],P[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],P[1]),u[1]=D(u[1],16),u[1]=Math.imul(u[1],P[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],P[0]),u[0]=D(u[0],15),u[0]=Math.imul(u[0],P[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]=Pe(i[0]),i[1]=Pe(i[1]),i[2]=Pe(i[2]),i[3]=Pe(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 rr(o,e){return new Promise((function(t){setTimeout((function(){return t(e)}),o)}))}function ir(o,e,t){return Promise.all(o.map((function(n){return Promise.race([n,rr(e,t)])})))}var or="0.19.1";function ar(){return or}function is(){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=sr(),e=Object.keys(o),[4,ir(Object.values(o),(q==null?void 0:q.timeout)||1e3,nr)];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,os(s,q.exclude||[],q.include||[],"")];case 2:throw r.sent();case 3:return[2]}}))}))}function os(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 b=os(l,e,t,h);Object.keys(b).length>0&&(s[u]=b)}},i=0,a=Object.entries(o);i<a.length;i++){var c=a[i];r(c[0],c[1])}return s}function lr(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,is()];case 1:return e=n.sent(),t=bt(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:ar()},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 cr(o){for(var e=0,t=0;t<o.length;++t)e+=Math.abs(o[t]);return e}function as(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(ur(r))}var a=new Uint8ClampedArray(n);return new ImageData(a,e,t)}function ur(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 Oe(){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"}}J("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:cr(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 hr=Oe().name!=="SamsungBrowser"?1:3,Rt=280,Ot=20;Oe().name!="Firefox"&&J("canvas",(function(){return document.createElement("canvas").getContext("2d"),new Promise((function(o){var e=Array.from({length:hr},(function(){return(function(){var t=document.createElement("canvas"),n=t.getContext("2d");if(!n)return new ImageData(1,1);t.width=Rt,t.height=Ot;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:bt(as(e,Rt,Ot).data.toString()).toString()})}))}));var it,dr=["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"],pr=["monospace","sans-serif","serif"];function qt(o,e){if(!o)throw new Error("Canvas context not supported");return o.font,o.font="72px ".concat(e),o.measureText("WwMmLli0Oo").width}function fr(){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 mr(){var o=new Float32Array(1),e=new Uint8Array(o.buffer);return o[0]=1/0,o[0]=o[0]-o[0],e[3]}function yr(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 gr(){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 br(){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}Oe().name!="Firefox"&&J("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=pr.map((function(l){return qt(i,l)})),c={},dr.forEach((function(l){var h=qt(i,l);a.includes(h)||(c[l]=h)})),e(c),[2]}))}))}))}catch{t({error:"unsupported"})}}))})),J("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:fr(),architecture:mr(),deviceMemory:t.toString()||"undefined",jsHeapSizeLimit:n.jsHeapSizeLimit||0})}))})),J("locales",(function(){return new Promise((function(o){o({languages:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}))})),J("permissions",(function(){return Z(this,void 0,void 0,(function(){var o;return Y(this,(function(e){return it=(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=it,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 yr(t,it)}))]}))}))})),J("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})}))})),J("screen",(function(){return new Promise((function(o){o({is_touchscreen:navigator.maxTouchPoints>0,maxTouchPoints:navigator.maxTouchPoints,colorDepth:screen.colorDepth,mediaMatches:gr()})}))})),J("system",(function(){return new Promise((function(o){var e=Oe();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:br()})}))}));var N,wr=Oe().name!=="SamsungBrowser"?1:3,m=null;J("webgl",(function(){return Z(this,void 0,void 0,(function(){var o;return Y(this,(function(e){typeof document<"u"&&((N=document.createElement("canvas")).width=200,N.height=100,m=N.getContext("webgl"));try{if(!m)throw new Error("WebGL not supported");return o=Array.from({length:wr},(function(){return(function(){try{if(!m)throw new Error("WebGL not supported");var t=`
|
|
503
565
|
attribute vec2 position;
|
|
504
566
|
void main() {
|
|
505
567
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
@@ -509,5 +571,5 @@ ${this.stack}`}}class ae extends x{constructor(e="The molecule does not contain
|
|
|
509
571
|
void main() {
|
|
510
572
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
511
573
|
}
|
|
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)*(P.width/2),c[4*l+3]=Math.sin(h)*(P.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,P.width,P.height),f.clearColor(0,0,0,1),f.clear(f.COLOR_BUFFER_BIT),f.drawArrays(f.LINES,0,2*a);var w=new Uint8ClampedArray(P.width*P.height*4);return f.readPixels(0,0,P.width,P.height,f.RGBA,f.UNSIGNED_BYTE,w),new ImageData(w,P.width,P.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:nt(nn(o,P.width,P.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));var re=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};J("math",(function(){return X(void 0,void 0,void 0,(function(){return Z(this,(function(o){return[2,{acos:Math.acos(.5),asin:re(Math.asin,-1,1,97),atan:re(Math.atan,-1,1,97),cos:re(Math.cos,0,Math.PI,97),cosh:Math.cosh(9/7),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:re(Math.sin,-Math.PI,Math.PI,97),sinh:re(Math.sinh,-9/7,7/9,97),sqrt:Math.sqrt(2),tan:re(Math.tan,0,2*Math.PI,97),tanh:re(Math.tanh,-9/7,7/9,97)}]}))}))}));class fr{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=[M.cacheExchange,M.fetchExchange];if(t&&t.socketUri){const r=an.createClient({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(M.subscriptionExchange({forwardSubscription:i=>({subscribe:a=>({unsubscribe:r.subscribe(i,a)})})}))}return M.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}=st.pipe(this.$__client.subscription(n,s),st.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 mr{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 fr({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 ee("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...`),ue(e)}getSecret(){if(!this.hasSecret())throw new Pe("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 Pe("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return nr()}getFingerprintData(){return en()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=S.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new S({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||S.create({secret:e,bundle:t,token:"USER",batchId:n.batchId,characters:n.characters}),new z({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 q))throw new ee(`${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(cs);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 Y;if(!s.position||!s.address)throw new Y("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(Es).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:n}){if(!t)throw new ee(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(Os).execute({variables:{bundle:e||this.getBundle(),token:t},closure:n})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(Rs).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:n}){return this.createSubscribe(Ws).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 $,C;return h?($=this.createQuery(vt),C=vt.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(_t),C=_t.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,count:u,countBy:l,cellSlug:this.getCellSlug()})),this.executeQuery($,C)}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(ve);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(hs);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:C,values:m,value:y,metaTypes:b,metaType:T,metaIds:k,metaId:A,indexes:v,index:I,filter:_,latest:U,queryArgs:O={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const he=this.createQuery(At);return await this.executeQuery(he,At.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:C,values:m,value:y,metaTypes:b,metaType:T,metaIds:k,metaId:A,indexes:v,index:I,filter:_,latest:U,queryArgs:O}))}async createWallet({token:e}){const t=new S({secret:this.getSecret(),token:e}),n=await this.createMoleculeMutation({mutationClass:Is});return n.fillMolecule(t),await this.executeQuery(n)}async queryActiveSession({bundleHash:e,metaType:t,metaId:n}){const s=this.createQuery(Hs);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(Ks);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(Us);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=E.get(n||{},"fungibility");if(i==="stackable"&&(n.batchId=s||Be({})),["nonfungible","stackable"].includes(i)&&r.length>0){if(E.get(n||{},"decimals")>0)throw new Cs;if(t>0)throw new Ce;t=r.length,n.splittable=1,n.decimals=0,n.tokenUnits=JSON.stringify(r)}const a=new S({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:ms});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:Vs,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:vs,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:Gt,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:Zt,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:_s});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:q,molecule:s});return await this.executeQuery(r)}async queryPolicy({metaType:e,metaId:t}){const n=this.createQuery(js);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(as);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(os);return this.executeQuery(s,{bundleHashes:e}).then(r=>n?r:r.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(rs);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(Ns),l=await this.executeQuery(u,{slug:e}),h=E.get(l.data(),"0.fungibility")==="stackable";if(!h&&i!==null)throw new qe("Expected Batch ID = null for non-stackable tokens.");if(h&&i===null&&(i=Be({})),s.length>0){if(n>0)throw new Ce;n=s.length,r.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(S.isBundleHash(t)?(a="walletBundle",c=t):t=S.create({secret:t,token:e})),t instanceof S&&(a="wallet",r.position=t.position,r.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const p=await this.createMoleculeMutation({mutationClass:gs});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:$s,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 St;t.forEach(s=>{if(!s.isShadow())throw new St});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 Ce;n=s.length}if(i===null&&(i=await this.querySourceWallet({token:t,amount:n})),i===null||de.cmp(i.balance,n)<0)throw new Y;const a=S.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:bs,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:zs,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:Js,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 Ce;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:q,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 Y("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:q,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 Y("Source wallet is missing or invalid.");if(!r.tokenUnits||!r.tokenUnits.length)throw new Y("Source wallet does not have token units.");if(!s.length)throw new Y("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 Y(`Fused token unit ID = ${h} does not found in the source wallet.`)});const a=S.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:q,molecule:u});return this.executeQuery(l)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const n=new S({secret:Ue(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(Ts),r={cellSlug:e,pubkey:n.pubkey,encrypt:t},i=await s.execute({variables:r});if(i.success()){const a=Ae.create({token:i.token(),expiresAt:i.time(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new $t(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${i.reason()}`);return i}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const n=new S({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:n}),r=await this.createMoleculeMutation({mutationClass:ps,molecule:s});r.fillMolecule({meta:{encrypt:t?"true":"false"}});const i=await r.execute({});if(i.success()){const a=Ae.create({token:i.token(),expiresAt:i.time(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new $t(`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=Ue(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)}}}exports.Atom=g;exports.KnishIOClient=mr;exports.Meta=ce;exports.Molecule=z;exports.MutationAppendRequest=Zt;exports.MutationPeering=Gt;exports.ResponseAppendRequest=Xt;exports.ResponsePeering=Jt;exports.Wallet=S;exports.base64ToHex=Wt;exports.bufferToHexString=Et;exports.charsetBaseConvert=Ct;exports.chunkSubstr=ke;exports.generateBundleHash=ue;exports.generateSecret=Ue;exports.hexStringToBuffer=Ot;exports.hexToBase64=Rt;exports.isHex=Oe;exports.randomString=Ke;exports.shake256=Ze;
|
|
574
|
+
`,s=m.createShader(m.VERTEX_SHADER),r=m.createShader(m.FRAGMENT_SHADER);if(!s||!r)throw new Error("Failed to create shaders");if(m.shaderSource(s,t),m.shaderSource(r,n),m.compileShader(s),!m.getShaderParameter(s,m.COMPILE_STATUS))throw new Error("Vertex shader compilation failed: "+m.getShaderInfoLog(s));if(m.compileShader(r),!m.getShaderParameter(r,m.COMPILE_STATUS))throw new Error("Fragment shader compilation failed: "+m.getShaderInfoLog(r));var i=m.createProgram();if(!i)throw new Error("Failed to create shader program");if(m.attachShader(i,s),m.attachShader(i,r),m.linkProgram(i),!m.getProgramParameter(i,m.LINK_STATUS))throw new Error("Shader program linking failed: "+m.getProgramInfoLog(i));m.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)*(N.width/2),c[4*l+3]=Math.sin(h)*(N.height/2)}var p=m.createBuffer();m.bindBuffer(m.ARRAY_BUFFER,p),m.bufferData(m.ARRAY_BUFFER,c,m.STATIC_DRAW);var d=m.getAttribLocation(i,"position");m.enableVertexAttribArray(d),m.vertexAttribPointer(d,2,m.FLOAT,!1,0,0),m.viewport(0,0,N.width,N.height),m.clearColor(0,0,0,1),m.clear(m.COLOR_BUFFER_BIT),m.drawArrays(m.LINES,0,2*a);var b=new Uint8ClampedArray(N.width*N.height*4);return m.readPixels(0,0,N.width,N.height,m.RGBA,m.UNSIGNED_BYTE,b),new ImageData(b,N.width,N.height)}catch{return new ImageData(1,1)}finally{m&&(m.bindBuffer(m.ARRAY_BUFFER,null),m.useProgram(null),m.viewport(0,0,m.drawingBufferWidth,m.drawingBufferHeight),m.clearColor(0,0,0,0))}})()})),[2,{commonImageHash:bt(as(o,N.width,N.height).data.toString()).toString()}]}catch{return[2,{webgl:"unsupported"}]}return[2]}))}))}));var oe=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};J("math",(function(){return Z(void 0,void 0,void 0,(function(){return Y(this,(function(o){return[2,{acos:Math.acos(.5),asin:oe(Math.asin,-1,1,97),atan:oe(Math.atan,-1,1,97),cos:oe(Math.cos,0,Math.PI,97),cosh:Math.cosh(9/7),e:Math.E,largeCos:Math.cos(1e20),largeSin:Math.sin(1e20),largeTan:Math.tan(1e20),log:Math.log(1e3),pi:Math.PI,sin:oe(Math.sin,-Math.PI,Math.PI,97),sinh:oe(Math.sinh,-9/7,7/9,97),sqrt:Math.sqrt(2),tan:oe(Math.tan,0,2*Math.PI,97),tanh:oe(Math.tanh,-9/7,7/9,97)}]}))}))}));class kr{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=[T.cacheExchange,T.fetchExchange];if(t&&t.socketUri){const r=hs.createClient({url:t.socketUri,connectionParams:()=>({authToken:this.$__authToken})});s.push(T.subscriptionExchange({forwardSubscription:i=>({subscribe:a=>({unsubscribe:r.subscribe(i,a)})})}))}return T.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}=wt.pipe(this.$__client.subscription(n,s),wt.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 Sr{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 kr({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 ee("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...`),pe(e)}getSecret(){if(!this.hasSecret())throw new Re("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 Re("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");return this.$__bundle}getFingerprint(){return lr()}getFingerprintData(){return is()}async getSourceWallet(){let e=(await this.queryContinuId({bundle:this.getBundle()})).payload();return e?e.key=_.generateKey({secret:this.getSecret(),token:e.token,position:e.position}):e=new _({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||_.create({secret:e,bundle:t,token:"USER",batchId:n.batchId,characters:n.characters}),new V({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 W))throw new ee(`${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(mn);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||he.cmp(s.balance,t)<0)throw new G;if(!s.position||!s.address)throw new G("Source wallet can not be a shadow wallet.");return s}async subscribeCreateMolecule({bundle:e,closure:t}){return await this.createSubscribe(Zs).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeWalletStatus({bundle:e,token:t,closure:n}){if(!t)throw new ee(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);return this.createSubscribe(Ys).execute({variables:{bundle:e||this.getBundle(),token:t},closure:n})}subscribeActiveWallet({bundle:e,closure:t}){return this.createSubscribe(er).execute({variables:{bundle:e||this.getBundle()},closure:t})}subscribeActiveSession({metaType:e,metaId:t,closure:n}){return this.createSubscribe(tr).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,throughMolecule:p=!1,values:d=null,keys:b=null,atomValues:$=null}){this.log("info",`KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);let C,f;return p?(C=this.createQuery(mt),f=mt.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,countBy:l,values:d,keys:b,atomValues:$,cellSlug:this.getCellSlug()})):h?(C=this.createQuery(ft),f=ft.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,countBy:l,values:d,keys:b,atomValues:$,cellSlug:this.getCellSlug()})):(C=this.createQuery(ut),f=ut.createVariables({metaType:e,metaId:t,key:n,value:s,latest:r,filter:a,queryArgs:c,count:u,countBy:l,cellSlug:this.getCellSlug()})),this.executeQuery(C,f)}async queryMetaVerified(e){const t=await this.queryMeta(e),n=t.payload();return n&&(n.integrity=t.verifyIntegrity()),t}async queryBatch({batchId:e}){this.log("info",`KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);const t=this.createQuery(Se);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(gn);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:b,batchIds:$,batchId:C,values:f,value:y,metaTypes:w,metaType:E,metaIds:k,metaId:A,indexes:v,index:I,filter:S,latest:H,queryArgs:O={limit:15,offset:1}}){this.log("info","KnishIOClient::queryAtom() - Querying atom instances");const me=this.createQuery(pt);return await this.executeQuery(me,pt.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:b,batchIds:$,batchId:C,values:f,value:y,metaTypes:w,metaType:E,metaIds:k,metaId:A,indexes:v,index:I,filter:S,latest:H,queryArgs:O}))}async createWallet({token:e}){const t=new _({secret:this.getSecret(),token:e}),n=await this.createMoleculeMutation({mutationClass:Pn});return n.fillMolecule(t),await this.executeQuery(n)}async queryActiveSession({bundleHash:e,metaType:t,metaId:n}){const s=this.createQuery(Dn);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(zn);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(Qn);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=M.get(n||{},"fungibility");if(i==="stackable"&&(n.batchId=s||ce({})),["nonfungible","stackable"].includes(i)&&r.length>0){if(M.get(n||{},"decimals")>0)throw new Fn;if(t>0)throw new xe;t=r.length,n.splittable=1,n.decimals=0,n.tokenUnits=JSON.stringify(r)}const a=new _({secret:this.getSecret(),bundle:this.getBundle(),token:e,batchId:s}),c=await this.createMoleculeMutation({mutationClass:Sn});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:ts,molecule:await this.createMolecule({secret:this.getSecret()})});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:En,molecule:await this.createMolecule({secret:this.getSecret()})}),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:On,molecule:await this.createMolecule({secret:this.getSecret()})});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:Wn,molecule:await this.createMolecule({secret:this.getSecret()})});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:In});return s.fillMolecule({type:e,contact:t,code:n}),await this.executeQuery(s)}async linkIdentifier({type:e,contact:t}){const n=this.createQuery(Un);return await this.executeQuery(n,{bundle:this.getBundle(),type:e,content:t})}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:W,molecule:s});return await this.executeQuery(r)}async queryPolicy({metaType:e,metaId:t}){const n=this.createQuery(Zn);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(pn);return this.executeQuery(s,{bundleHash:e||this.getBundle(),token: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(dn);return this.executeQuery(s,{bundleHashes:e}).then(r=>n?r:r.payload())}async queryContinuId({bundle:e}){const t=this.createQuery(un);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(Jn),l=await this.executeQuery(u,{slug:e}),h=M.get(l.data(),"0.fungibility")==="stackable";if(!h&&i!==null)throw new Ie("Expected Batch ID = null for non-stackable tokens.");if(h&&i===null&&(i=ce({})),s.length>0){if(n>0)throw new xe;n=s.length,r.tokenUnits=JSON.stringify(s)}t?(Object.prototype.toString.call(t)==="[object String]"&&(_.isBundleHash(t)?(a="walletBundle",c=t):t=_.create({secret:t,token:e})),t instanceof _&&(a="wallet",r.position=t.position,r.bundle=t.bundle,c=t.address)):(a="walletBundle",c=this.getBundle());const p=await this.createMoleculeMutation({mutationClass:An});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:Tn,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 ht;t.forEach(s=>{if(!s.isShadow())throw new ht});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 xe;n=s.length}if(i===null&&(i=await this.querySourceWallet({token:t,amount:n})),i===null||he.cmp(i.balance,n)<0)throw new G;const a=_.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:vn,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:ns,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:ss,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 xe;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:W,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 G("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:W,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 G("Source wallet is missing or invalid.");if(!r.tokenUnits||!r.tokenUnits.length)throw new G("Source wallet does not have token units.");if(!s.length)throw new G("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 G(`Fused token unit ID = ${h} does not found in the source wallet.`)});const a=_.create({bundle:e,token:t});a.initBatchId({sourceWallet:r});const c=r.createRemainder(this.getSecret());r.splitUnits(s,c),typeof n=="string"&&(n=new fe(n,n,{})),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:W,molecule:u});return this.executeQuery(l)}async requestGuestAuthToken({cellSlug:e,encrypt:t}){this.setCellSlug(e);const n=new _({secret:Qe(await this.getFingerprint()),token:"AUTH"}),s=await this.createQuery(Nn),r={cellSlug:e,pubkey:n.pubkey,encrypt:t},i=await s.execute({variables:r});if(i.success()){const a=ke.create({token:i.token(),expiresAt:i.expiresAt(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new dt(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${i.reason()}`);return i}async requestProfileAuthToken({secret:e,encrypt:t}){this.setSecret(e);const n=new _({secret:e,token:"AUTH"}),s=await this.createMolecule({secret:e,sourceWallet:n}),r=await this.createMoleculeMutation({mutationClass:wn,molecule:s});r.fillMolecule({meta:{encrypt:t?"true":"false"}});const i=await r.execute({});if(i.success()){const a=ke.create({token:i.token(),expiresAt:i.expiresAt(),pubkey:i.pubKey(),encrypt:i.encrypt()},n);this.setAuthToken(a)}else throw new dt(`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=Qe(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)}}}class _r extends R{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(!M.has(this.payload(),e))throw new te(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);return M.get(this.payload(),e)}token(){return this.payloadKey("token")}time(){return this.payloadKey("time")}}exports.Atom=g;exports.AtomIndexException=ge;exports.AtomMeta=U;exports.AtomsMissingException=se;exports.AuthToken=ke;exports.AuthorizationRejectedException=dt;exports.BalanceInsufficientException=ae;exports.BatchIdException=Ie;exports.CheckMolecule=we;exports.CodeException=ee;exports.Decimal=he;exports.Dot=M;exports.InvalidResponseException=te;exports.KnishIOClient=Sr;exports.Meta=de;exports.MetaMissingException=B;exports.MolecularHashMismatchException=rn;exports.MolecularHashMissingException=on;exports.Molecule=V;exports.Mutation=We;exports.MutationActiveSession=Qn;exports.MutationAppendRequest=Wn;exports.MutationClaimShadowWallet=Tn;exports.MutationCreateIdentifier=In;exports.MutationCreateMeta=En;exports.MutationCreateRule=ts;exports.MutationCreateToken=Sn;exports.MutationCreateWallet=Pn;exports.MutationDepositBufferToken=ns;exports.MutationLinkIdentifier=Un;exports.MutationPeering=On;exports.MutationProposeMolecule=W;exports.MutationRequestAuthorization=wn;exports.MutationRequestAuthorizationGuest=Nn;exports.MutationRequestTokens=An;exports.MutationTransferTokens=vn;exports.MutationWithdrawBufferToken=ss;exports.NegativeAmountException=Le;exports.PolicyInvalidException=at;exports.PolicyMeta=Ve;exports.Query=K;exports.QueryActiveSession=Dn;exports.QueryAtom=pt;exports.QueryBalance=mn;exports.QueryBatch=Se;exports.QueryBatchHistory=gn;exports.QueryContinuId=un;exports.QueryMetaType=ut;exports.QueryMetaTypeViaAtom=ft;exports.QueryMetaTypeViaMolecule=mt;exports.QueryPolicy=Zn;exports.QueryToken=Jn;exports.QueryUserActivity=zn;exports.QueryWalletBundle=dn;exports.QueryWalletList=pn;exports.Response=R;exports.ResponseActiveSession=Ln;exports.ResponseAppendRequest=qn;exports.ResponseAtom=Gn;exports.ResponseAuthorizationGuest=_r;exports.ResponseBalance=fn;exports.ResponseClaimShadowWallet=Mn;exports.ResponseContinuId=cn;exports.ResponseCreateIdentifier=xn;exports.ResponseCreateMeta=Cn;exports.ResponseCreateRule=es;exports.ResponseCreateToken=kn;exports.ResponseCreateWallet=Hn;exports.ResponseLinkIdentifier=Bn;exports.ResponseMetaType=yn;exports.ResponseMetaTypeViaAtom=Yn;exports.ResponseMetaTypeViaMolecule=Xe;exports.ResponsePeering=Rn;exports.ResponsePolicy=Xn;exports.ResponseProposeMolecule=Q;exports.ResponseQueryActiveSession=jn;exports.ResponseQueryUserActivity=Vn;exports.ResponseRequestAuthorization=bn;exports.ResponseRequestAuthorizationGuest=Kn;exports.ResponseRequestTokens=_n;exports.ResponseTransferTokens=$n;exports.ResponseWalletBundle=hn;exports.ResponseWalletList=qe;exports.SignatureMalformedException=gt;exports.SignatureMismatchException=an;exports.StackableUnitAmountException=xe;exports.StackableUnitDecimalsException=Fn;exports.TokenUnit=fe;exports.TransferBalanceException=G;exports.TransferMalformedException=be;exports.TransferMismatchedException=lt;exports.TransferRemainderException=ct;exports.TransferToSelfException=ln;exports.TransferUnbalancedException=ve;exports.UnauthenticatedException=Re;exports.Wallet=_;exports.WalletShadowException=ht;exports.WrongTokenTypeException=ne;exports.base64ToHex=Kt;exports.bufferToHexString=Ut;exports.charsetBaseConvert=Bt;exports.chunkArray=Ft;exports.chunkSubstr=Te;exports.deepCloning=Lt;exports.diff=Qt;exports.generateBatchId=ce;exports.generateBundleHash=pe;exports.generateSecret=Qe;exports.hexStringToBuffer=Ht;exports.hexToBase64=Pt;exports.intersect=ye;exports.isHex=Ke;exports.isNumeric=Nt;exports.randomString=De;exports.shake256=ot;
|
|
513
575
|
//# sourceMappingURL=client.cjs.js.map
|