wowok_agent 0.1.19 → 0.1.20

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/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{var e,t,r,s,i={22:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=t[e.charCodeAt(r)];if(255===u)return;for(var h=0,p=n-1;(0!==u||h<i)&&-1!==p;p--,h++)u+=a*c[p]>>>0,c[p]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");i=h,r++}for(var l=n-i;l!==n&&0===c[l];)l++;for(var m=new Uint8Array(s+(n-l)),_=s;l!==n;)m[_++]=c[l++];return m}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],p=0,l=d-1;(0!==h||p<s)&&-1!==l;l--,p++)h+=256*u[l]>>>0,u[l]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=p,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var _=o.repeat(r);m<d;++m)_+=e.charAt(u[m]);return _},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},211:()=>{},333:(e,t)=>{"use strict";t.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let e=0;e<32;e++){const t=r.charAt(e);s[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=i(t)^s>>5}t=i(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=i(t)^31&s}return t}function a(e,t,r,s){let i=0,n=0;const a=(1<<r)-1,o=[];for(let s=0;s<e.length;++s)for(i=i<<t|e[s],n+=t;n>=r;)n-=r,o.push(i>>n&a);if(s)n>0&&o.push(i<<r-n&a);else{if(n>=t)return"Excess padding";if(i<<r-n&a)return"Non-zero padding"}return o}function o(e){return a(e,8,5,!0)}function d(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t}function c(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function u(e){let t;function a(e,r){if(r=r||90,e.length<8)return e+" too short";if(e.length>r)return"Exceeds length limit";const a=e.toLowerCase(),o=e.toUpperCase();if(e!==a&&e!==o)return"Mixed-case string "+e;const d=(e=a).lastIndexOf("1");if(-1===d)return"No separator character for "+e;if(0===d)return"Missing prefix for "+e;const c=e.slice(0,d),u=e.slice(d+1);if(u.length<6)return"Data too short";let h=n(c);if("string"==typeof h)return h;const p=[];for(let e=0;e<u.length;++e){const t=u.charAt(e),r=s[t];if(void 0===r)return"Unknown character "+t;h=i(h)^r,e+6>=u.length||p.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:c,words:p}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=a(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=a(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,s,a){if(a=a||90,e.length+7+s.length>a)throw new TypeError("Exceeds length limit");let o=n(e=e.toLowerCase());if("string"==typeof o)throw new Error(o);let d=e+"1";for(let e=0;e<s.length;++e){const t=s[e];if(t>>5)throw new Error("Non 5-bit word");o=i(o)^t,d+=r.charAt(t)}for(let e=0;e<6;++e)o=i(o);o^=t;for(let e=0;e<6;++e)d+=r.charAt(o>>5*(5-e)&31);return d},toWords:o,fromWordsUnsafe:d,fromWords:c}}t.I=u("bech32"),u("bech32m")},364:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=e.charCodeAt(r);if(u>255)return;var h=t[u];if(255===h)return;for(var p=0,l=n-1;(0!==h||p<i)&&-1!==l;l--,p++)h+=a*c[l]>>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,r++}for(var m=n-i;m!==n&&0===c[m];)m++;for(var _=new Uint8Array(s+(n-m)),b=s;m!==n;)_[b++]=c[m++];return _}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],p=0,l=d-1;(0!==h||p<s)&&-1!==l;l--,p++)h+=256*u[l]>>>0,u[l]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=p,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var _=o.repeat(r);m<d;++m)_+=e.charAt(u[m]);return _},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},601:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var a=t(),o=t([1]),d=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),p=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,t,r,s){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=s>>24&255,e[t+5]=s>>16&255,e[t+6]=s>>8&255,e[t+7]=255&s}function _(e,t,r,s,i){var n,a=0;for(n=0;n<i;n++)a|=e[t+n]^r[s+n];return(1&a-1>>>8)-1}function b(e,t,r,s){return _(e,t,r,s,16)}function g(e,t,r,s){return _(e,t,r,s,32)}function y(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,_=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,f=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=n,E=a,w=o,x=d,O=c,I=u,C=h,B=p,S=l,P=m,j=_,A=b,k=g,U=y,N=f,D=v,R=0;R<20;R+=2)T^=(i=(k^=(i=(S^=(i=(O^=(i=T+k|0)<<7|i>>>25)+T|0)<<9|i>>>23)+O|0)<<13|i>>>19)+S|0)<<18|i>>>14,I^=(i=(E^=(i=(U^=(i=(P^=(i=I+E|0)<<7|i>>>25)+I|0)<<9|i>>>23)+P|0)<<13|i>>>19)+U|0)<<18|i>>>14,j^=(i=(C^=(i=(w^=(i=(N^=(i=j+C|0)<<7|i>>>25)+j|0)<<9|i>>>23)+N|0)<<13|i>>>19)+w|0)<<18|i>>>14,D^=(i=(A^=(i=(B^=(i=(x^=(i=D+A|0)<<7|i>>>25)+D|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,T^=(i=(x^=(i=(w^=(i=(E^=(i=T+x|0)<<7|i>>>25)+T|0)<<9|i>>>23)+E|0)<<13|i>>>19)+w|0)<<18|i>>>14,I^=(i=(O^=(i=(B^=(i=(C^=(i=I+O|0)<<7|i>>>25)+I|0)<<9|i>>>23)+C|0)<<13|i>>>19)+B|0)<<18|i>>>14,j^=(i=(P^=(i=(S^=(i=(A^=(i=j+P|0)<<7|i>>>25)+j|0)<<9|i>>>23)+A|0)<<13|i>>>19)+S|0)<<18|i>>>14,D^=(i=(N^=(i=(U^=(i=(k^=(i=D+N|0)<<7|i>>>25)+D|0)<<9|i>>>23)+k|0)<<13|i>>>19)+U|0)<<18|i>>>14;T=T+n|0,E=E+a|0,w=w+o|0,x=x+d|0,O=O+c|0,I=I+u|0,C=C+h|0,B=B+p|0,S=S+l|0,P=P+m|0,j=j+_|0,A=A+b|0,k=k+g|0,U=U+y|0,N=N+f|0,D=D+v|0,e[0]=T>>>0&255,e[1]=T>>>8&255,e[2]=T>>>16&255,e[3]=T>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=w>>>0&255,e[9]=w>>>8&255,e[10]=w>>>16&255,e[11]=w>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=I>>>0&255,e[21]=I>>>8&255,e[22]=I>>>16&255,e[23]=I>>>24&255,e[24]=C>>>0&255,e[25]=C>>>8&255,e[26]=C>>>16&255,e[27]=C>>>24&255,e[28]=B>>>0&255,e[29]=B>>>8&255,e[30]=B>>>16&255,e[31]=B>>>24&255,e[32]=S>>>0&255,e[33]=S>>>8&255,e[34]=S>>>16&255,e[35]=S>>>24&255,e[36]=P>>>0&255,e[37]=P>>>8&255,e[38]=P>>>16&255,e[39]=P>>>24&255,e[40]=j>>>0&255,e[41]=j>>>8&255,e[42]=j>>>16&255,e[43]=j>>>24&255,e[44]=A>>>0&255,e[45]=A>>>8&255,e[46]=A>>>16&255,e[47]=A>>>24&255,e[48]=k>>>0&255,e[49]=k>>>8&255,e[50]=k>>>16&255,e[51]=k>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=N>>>0&255,e[57]=N>>>8&255,e[58]=N>>>16&255,e[59]=N>>>24&255,e[60]=D>>>0&255,e[61]=D>>>8&255,e[62]=D>>>16&255,e[63]=D>>>24&255}(e,t,r,s)}function f(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,_=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,f=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=0;T<20;T+=2)n^=(i=(g^=(i=(l^=(i=(c^=(i=n+g|0)<<7|i>>>25)+n|0)<<9|i>>>23)+c|0)<<13|i>>>19)+l|0)<<18|i>>>14,u^=(i=(a^=(i=(y^=(i=(m^=(i=u+a|0)<<7|i>>>25)+u|0)<<9|i>>>23)+m|0)<<13|i>>>19)+y|0)<<18|i>>>14,_^=(i=(h^=(i=(o^=(i=(f^=(i=_+h|0)<<7|i>>>25)+_|0)<<9|i>>>23)+f|0)<<13|i>>>19)+o|0)<<18|i>>>14,v^=(i=(b^=(i=(p^=(i=(d^=(i=v+b|0)<<7|i>>>25)+v|0)<<9|i>>>23)+d|0)<<13|i>>>19)+p|0)<<18|i>>>14,n^=(i=(d^=(i=(o^=(i=(a^=(i=n+d|0)<<7|i>>>25)+n|0)<<9|i>>>23)+a|0)<<13|i>>>19)+o|0)<<18|i>>>14,u^=(i=(c^=(i=(p^=(i=(h^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,_^=(i=(m^=(i=(l^=(i=(b^=(i=_+m|0)<<7|i>>>25)+_|0)<<9|i>>>23)+b|0)<<13|i>>>19)+l|0)<<18|i>>>14,v^=(i=(f^=(i=(y^=(i=(g^=(i=v+f|0)<<7|i>>>25)+v|0)<<9|i>>>23)+g|0)<<13|i>>>19)+y|0)<<18|i>>>14;e[0]=n>>>0&255,e[1]=n>>>8&255,e[2]=n>>>16&255,e[3]=n>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=_>>>0&255,e[9]=_>>>8&255,e[10]=_>>>16&255,e[11]=_>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=p>>>0&255,e[21]=p>>>8&255,e[22]=p>>>16&255,e[23]=p>>>24&255,e[24]=l>>>0&255,e[25]=l>>>8&255,e[26]=l>>>16&255,e[27]=l>>>24&255,e[28]=m>>>0&255,e[29]=m>>>8&255,e[30]=m>>>16&255,e[31]=m>>>24&255}(e,t,r,s)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function T(e,t,r,s,i,n,a){var o,d,c=new Uint8Array(16),u=new Uint8Array(64);for(d=0;d<16;d++)c[d]=0;for(d=0;d<8;d++)c[d]=n[d];for(;i>=64;){for(y(u,c,a,v),d=0;d<64;d++)e[t+d]=r[s+d]^u[d];for(o=1,d=8;d<16;d++)o=o+(255&c[d])|0,c[d]=255&o,o>>>=8;i-=64,t+=64,s+=64}if(i>0)for(y(u,c,a,v),d=0;d<i;d++)e[t+d]=r[s+d]^u[d];return 0}function E(e,t,r,s,i){var n,a,o=new Uint8Array(16),d=new Uint8Array(64);for(a=0;a<16;a++)o[a]=0;for(a=0;a<8;a++)o[a]=s[a];for(;r>=64;){for(y(d,o,i,v),a=0;a<64;a++)e[t+a]=d[a];for(n=1,a=8;a<16;a++)n=n+(255&o[a])|0,o[a]=255&n,n>>>=8;r-=64,t+=64}if(r>0)for(y(d,o,i,v),a=0;a<r;a++)e[t+a]=d[a];return 0}function w(e,t,r,s,i){var n=new Uint8Array(32);f(n,s,i,v);for(var a=new Uint8Array(8),o=0;o<8;o++)a[o]=s[o+16];return E(e,t,r,a,n)}function x(e,t,r,s,i,n,a){var o=new Uint8Array(32);f(o,n,a,v);for(var d=new Uint8Array(8),c=0;c<8;c++)d[c]=n[c+16];return T(e,t,r,s,i,d,o)}var O=function(e){var t,r,s,i,n,a,o,d;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),s=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|s<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(s>>>7|i<<9),n=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|n<<12),this.r[5]=n>>>1&8190,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(n>>>14|a<<2),o=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|o<<5),d=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(o>>>8|d<<8),this.r[9]=d>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function I(e,t,r,s,i,n){var a=new O(n);return a.update(r,s,i),a.finish(e,t),0}function C(e,t,r,s,i,n){var a=new Uint8Array(16);return I(a,0,r,s,i,n),b(e,t,a,0)}function B(e,t,r,s,i){var n;if(r<32)return-1;for(x(e,0,t,0,r,s,i),I(e,16,e,32,r-32,e),n=0;n<16;n++)e[n]=0;return 0}function S(e,t,r,s,i){var n,a=new Uint8Array(32);if(r<32)return-1;if(w(a,0,32,s,i),0!==C(t,16,t,32,r-32,a))return-1;for(x(e,0,t,0,r,s,i),n=0;n<32;n++)e[n]=0;return 0}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function j(e){var t,r,s=1;for(t=0;t<16;t++)r=e[t]+s+65535,s=Math.floor(r/65536),e[t]=r-65536*s;e[0]+=s-1+37*(s-1)}function A(e,t,r){for(var s,i=~(r-1),n=0;n<16;n++)s=i&(e[n]^t[n]),e[n]^=s,t[n]^=s}function k(e,r){var s,i,n,a=t(),o=t();for(s=0;s<16;s++)o[s]=r[s];for(j(o),j(o),j(o),i=0;i<2;i++){for(a[0]=o[0]-65517,s=1;s<15;s++)a[s]=o[s]-65535-(a[s-1]>>16&1),a[s-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),n=a[15]>>16&1,a[14]&=65535,A(o,a,1-n)}for(s=0;s<16;s++)e[2*s]=255&o[s],e[2*s+1]=o[s]>>8}function U(e,t){var r=new Uint8Array(32),s=new Uint8Array(32);return k(r,e),k(s,t),g(r,0,s,0)}function N(e){var t=new Uint8Array(32);return k(t,e),1&t[0]}function D(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function R(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]+r[s]}function Y(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]-r[s]}function V(e,t,r){var s,i,n=0,a=0,o=0,d=0,c=0,u=0,h=0,p=0,l=0,m=0,_=0,b=0,g=0,y=0,f=0,v=0,T=0,E=0,w=0,x=0,O=0,I=0,C=0,B=0,S=0,P=0,j=0,A=0,k=0,U=0,N=0,D=r[0],R=r[1],Y=r[2],V=r[3],J=r[4],M=r[5],F=r[6],X=r[7],L=r[8],q=r[9],G=r[10],$=r[11],z=r[12],W=r[13],H=r[14],K=r[15];n+=(s=t[0])*D,a+=s*R,o+=s*Y,d+=s*V,c+=s*J,u+=s*M,h+=s*F,p+=s*X,l+=s*L,m+=s*q,_+=s*G,b+=s*$,g+=s*z,y+=s*W,f+=s*H,v+=s*K,a+=(s=t[1])*D,o+=s*R,d+=s*Y,c+=s*V,u+=s*J,h+=s*M,p+=s*F,l+=s*X,m+=s*L,_+=s*q,b+=s*G,g+=s*$,y+=s*z,f+=s*W,v+=s*H,T+=s*K,o+=(s=t[2])*D,d+=s*R,c+=s*Y,u+=s*V,h+=s*J,p+=s*M,l+=s*F,m+=s*X,_+=s*L,b+=s*q,g+=s*G,y+=s*$,f+=s*z,v+=s*W,T+=s*H,E+=s*K,d+=(s=t[3])*D,c+=s*R,u+=s*Y,h+=s*V,p+=s*J,l+=s*M,m+=s*F,_+=s*X,b+=s*L,g+=s*q,y+=s*G,f+=s*$,v+=s*z,T+=s*W,E+=s*H,w+=s*K,c+=(s=t[4])*D,u+=s*R,h+=s*Y,p+=s*V,l+=s*J,m+=s*M,_+=s*F,b+=s*X,g+=s*L,y+=s*q,f+=s*G,v+=s*$,T+=s*z,E+=s*W,w+=s*H,x+=s*K,u+=(s=t[5])*D,h+=s*R,p+=s*Y,l+=s*V,m+=s*J,_+=s*M,b+=s*F,g+=s*X,y+=s*L,f+=s*q,v+=s*G,T+=s*$,E+=s*z,w+=s*W,x+=s*H,O+=s*K,h+=(s=t[6])*D,p+=s*R,l+=s*Y,m+=s*V,_+=s*J,b+=s*M,g+=s*F,y+=s*X,f+=s*L,v+=s*q,T+=s*G,E+=s*$,w+=s*z,x+=s*W,O+=s*H,I+=s*K,p+=(s=t[7])*D,l+=s*R,m+=s*Y,_+=s*V,b+=s*J,g+=s*M,y+=s*F,f+=s*X,v+=s*L,T+=s*q,E+=s*G,w+=s*$,x+=s*z,O+=s*W,I+=s*H,C+=s*K,l+=(s=t[8])*D,m+=s*R,_+=s*Y,b+=s*V,g+=s*J,y+=s*M,f+=s*F,v+=s*X,T+=s*L,E+=s*q,w+=s*G,x+=s*$,O+=s*z,I+=s*W,C+=s*H,B+=s*K,m+=(s=t[9])*D,_+=s*R,b+=s*Y,g+=s*V,y+=s*J,f+=s*M,v+=s*F,T+=s*X,E+=s*L,w+=s*q,x+=s*G,O+=s*$,I+=s*z,C+=s*W,B+=s*H,S+=s*K,_+=(s=t[10])*D,b+=s*R,g+=s*Y,y+=s*V,f+=s*J,v+=s*M,T+=s*F,E+=s*X,w+=s*L,x+=s*q,O+=s*G,I+=s*$,C+=s*z,B+=s*W,S+=s*H,P+=s*K,b+=(s=t[11])*D,g+=s*R,y+=s*Y,f+=s*V,v+=s*J,T+=s*M,E+=s*F,w+=s*X,x+=s*L,O+=s*q,I+=s*G,C+=s*$,B+=s*z,S+=s*W,P+=s*H,j+=s*K,g+=(s=t[12])*D,y+=s*R,f+=s*Y,v+=s*V,T+=s*J,E+=s*M,w+=s*F,x+=s*X,O+=s*L,I+=s*q,C+=s*G,B+=s*$,S+=s*z,P+=s*W,j+=s*H,A+=s*K,y+=(s=t[13])*D,f+=s*R,v+=s*Y,T+=s*V,E+=s*J,w+=s*M,x+=s*F,O+=s*X,I+=s*L,C+=s*q,B+=s*G,S+=s*$,P+=s*z,j+=s*W,A+=s*H,k+=s*K,f+=(s=t[14])*D,v+=s*R,T+=s*Y,E+=s*V,w+=s*J,x+=s*M,O+=s*F,I+=s*X,C+=s*L,B+=s*q,S+=s*G,P+=s*$,j+=s*z,A+=s*W,k+=s*H,U+=s*K,v+=(s=t[15])*D,a+=38*(E+=s*Y),o+=38*(w+=s*V),d+=38*(x+=s*J),c+=38*(O+=s*M),u+=38*(I+=s*F),h+=38*(C+=s*X),p+=38*(B+=s*L),l+=38*(S+=s*q),m+=38*(P+=s*G),_+=38*(j+=s*$),b+=38*(A+=s*z),g+=38*(k+=s*W),y+=38*(U+=s*H),f+=38*(N+=s*K),n=(s=(n+=38*(T+=s*R))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n=(s=(n+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n+=i-1+37*(i-1),e[0]=n,e[1]=a,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=h,e[7]=p,e[8]=l,e[9]=m,e[10]=_,e[11]=b,e[12]=g,e[13]=y,e[14]=f,e[15]=v}function J(e,t){V(e,t,t)}function M(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=253;s>=0;s--)J(i,i),2!==s&&4!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function F(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=250;s>=0;s--)J(i,i),1!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function X(e,r,s){var i,n,a=new Uint8Array(32),o=new Float64Array(80),c=t(),u=t(),h=t(),p=t(),l=t(),m=t();for(n=0;n<31;n++)a[n]=r[n];for(a[31]=127&r[31]|64,a[0]&=248,D(o,s),n=0;n<16;n++)u[n]=o[n],p[n]=c[n]=h[n]=0;for(c[0]=p[0]=1,n=254;n>=0;--n)A(c,u,i=a[n>>>3]>>>(7&n)&1),A(h,p,i),R(l,c,h),Y(c,c,h),R(h,u,p),Y(u,u,p),J(p,l),J(m,c),V(c,h,c),V(h,u,l),R(l,c,h),Y(c,c,h),J(u,c),Y(h,p,m),V(c,h,d),R(c,c,p),V(h,h,c),V(c,p,m),V(p,u,o),J(u,l),A(c,u,i),A(h,p,i);for(n=0;n<16;n++)o[n+16]=c[n],o[n+32]=h[n],o[n+48]=u[n],o[n+64]=p[n];var _=o.subarray(32),b=o.subarray(16);return M(_,_),V(b,b,_),k(e,b),0}function L(e,t){return X(e,t,n)}function q(e,t){return s(t,32),L(e,t)}function G(e,t,r){var s=new Uint8Array(32);return X(s,r,t),f(e,i,s,v)}O.prototype.blocks=function(e,t,r){for(var s,i,n,a,o,d,c,u,h,p,l,m,_,b,g,y,f,v,T,E=this.fin?0:2048,w=this.h[0],x=this.h[1],O=this.h[2],I=this.h[3],C=this.h[4],B=this.h[5],S=this.h[6],P=this.h[7],j=this.h[8],A=this.h[9],k=this.r[0],U=this.r[1],N=this.r[2],D=this.r[3],R=this.r[4],Y=this.r[5],V=this.r[6],J=this.r[7],M=this.r[8],F=this.r[9];r>=16;)p=h=0,p+=(w+=8191&(s=255&e[t+0]|(255&e[t+1])<<8))*k,p+=(x+=8191&(s>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),p+=(O+=8191&(i>>>10|(n=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*M),p+=(I+=8191&(n>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*J),h=(p+=(C+=8191&(a>>>4|(o=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*V))>>>13,p&=8191,p+=(B+=o>>>1&8191)*(5*Y),p+=(S+=8191&(o>>>14|(d=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*R),p+=(P+=8191&(d>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*D),p+=(j+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*N),l=h+=(p+=(A+=u>>>5|E)*(5*U))>>>13,l+=w*U,l+=x*k,l+=O*(5*F),l+=I*(5*M),h=(l+=C*(5*J))>>>13,l&=8191,l+=B*(5*V),l+=S*(5*Y),l+=P*(5*R),l+=j*(5*D),h+=(l+=A*(5*N))>>>13,l&=8191,m=h,m+=w*N,m+=x*U,m+=O*k,m+=I*(5*F),h=(m+=C*(5*M))>>>13,m&=8191,m+=B*(5*J),m+=S*(5*V),m+=P*(5*Y),m+=j*(5*R),_=h+=(m+=A*(5*D))>>>13,_+=w*D,_+=x*N,_+=O*U,_+=I*k,h=(_+=C*(5*F))>>>13,_&=8191,_+=B*(5*M),_+=S*(5*J),_+=P*(5*V),_+=j*(5*Y),b=h+=(_+=A*(5*R))>>>13,b+=w*R,b+=x*D,b+=O*N,b+=I*U,h=(b+=C*k)>>>13,b&=8191,b+=B*(5*F),b+=S*(5*M),b+=P*(5*J),b+=j*(5*V),g=h+=(b+=A*(5*Y))>>>13,g+=w*Y,g+=x*R,g+=O*D,g+=I*N,h=(g+=C*U)>>>13,g&=8191,g+=B*k,g+=S*(5*F),g+=P*(5*M),g+=j*(5*J),y=h+=(g+=A*(5*V))>>>13,y+=w*V,y+=x*Y,y+=O*R,y+=I*D,h=(y+=C*N)>>>13,y&=8191,y+=B*U,y+=S*k,y+=P*(5*F),y+=j*(5*M),f=h+=(y+=A*(5*J))>>>13,f+=w*J,f+=x*V,f+=O*Y,f+=I*R,h=(f+=C*D)>>>13,f&=8191,f+=B*N,f+=S*U,f+=P*k,f+=j*(5*F),v=h+=(f+=A*(5*M))>>>13,v+=w*M,v+=x*J,v+=O*V,v+=I*Y,h=(v+=C*R)>>>13,v&=8191,v+=B*D,v+=S*N,v+=P*U,v+=j*k,T=h+=(v+=A*(5*F))>>>13,T+=w*F,T+=x*M,T+=O*J,T+=I*V,h=(T+=C*Y)>>>13,T&=8191,T+=B*R,T+=S*D,T+=P*N,T+=j*U,w=p=8191&(h=(h=((h+=(T+=A*k)>>>13)<<2)+h|0)+(p&=8191)|0),x=l+=h>>>=13,O=m&=8191,I=_&=8191,C=b&=8191,B=g&=8191,S=y&=8191,P=f&=8191,j=v&=8191,A=T&=8191,t+=16,r-=16;this.h[0]=w,this.h[1]=x,this.h[2]=O,this.h[3]=I,this.h[4]=C,this.h[5]=B,this.h[6]=S,this.h[7]=P,this.h[8]=j,this.h[9]=A},O.prototype.finish=function(e,t){var r,s,i,n,a=new Uint16Array(10);if(this.leftover){for(n=this.leftover,this.buffer[n++]=1;n<16;n++)this.buffer[n]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,n=2;n<10;n++)this.h[n]+=r,r=this.h[n]>>>13,this.h[n]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,a[0]=this.h[0]+5,r=a[0]>>>13,a[0]&=8191,n=1;n<10;n++)a[n]=this.h[n]+r,r=a[n]>>>13,a[n]&=8191;for(a[9]-=8192,s=(1^r)-1,n=0;n<10;n++)a[n]&=s;for(s=~s,n=0;n<10;n++)this.h[n]=this.h[n]&s|a[n];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,n=1;n<8;n++)i=(this.h[n]+this.pad[n]|0)+(i>>>16)|0,this.h[n]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,r){var s,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),s=0;s<i;s++)this.buffer[this.leftover+s]=e[t+s];if(r-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(s=0;s<r;s++)this.buffer[this.leftover+s]=e[t+s];this.leftover+=r}};var $=B,z=S,W=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function H(e,t,r,s){for(var i,n,a,o,d,c,u,h,p,l,m,_,b,g,y,f,v,T,E,w,x,O,I,C,B,S,P=new Int32Array(16),j=new Int32Array(16),A=e[0],k=e[1],U=e[2],N=e[3],D=e[4],R=e[5],Y=e[6],V=e[7],J=t[0],M=t[1],F=t[2],X=t[3],L=t[4],q=t[5],G=t[6],$=t[7],z=0;s>=128;){for(E=0;E<16;E++)w=8*E+z,P[E]=r[w+0]<<24|r[w+1]<<16|r[w+2]<<8|r[w+3],j[E]=r[w+4]<<24|r[w+5]<<16|r[w+6]<<8|r[w+7];for(E=0;E<80;E++)if(i=A,n=k,a=U,o=N,d=D,c=R,u=Y,p=J,l=M,m=F,_=X,b=L,g=q,y=G,I=65535&(O=$),C=O>>>16,B=65535&(x=V),S=x>>>16,I+=65535&(O=(L>>>14|D<<18)^(L>>>18|D<<14)^(D>>>9|L<<23)),C+=O>>>16,B+=65535&(x=(D>>>14|L<<18)^(D>>>18|L<<14)^(L>>>9|D<<23)),S+=x>>>16,I+=65535&(O=L&q^~L&G),C+=O>>>16,B+=65535&(x=D&R^~D&Y),S+=x>>>16,I+=65535&(O=W[2*E+1]),C+=O>>>16,B+=65535&(x=W[2*E]),S+=x>>>16,x=P[E%16],C+=(O=j[E%16])>>>16,B+=65535&x,S+=x>>>16,B+=(C+=(I+=65535&O)>>>16)>>>16,I=65535&(O=T=65535&I|C<<16),C=O>>>16,B=65535&(x=v=65535&B|(S+=B>>>16)<<16),S=x>>>16,I+=65535&(O=(J>>>28|A<<4)^(A>>>2|J<<30)^(A>>>7|J<<25)),C+=O>>>16,B+=65535&(x=(A>>>28|J<<4)^(J>>>2|A<<30)^(J>>>7|A<<25)),S+=x>>>16,C+=(O=J&M^J&F^M&F)>>>16,B+=65535&(x=A&k^A&U^k&U),S+=x>>>16,h=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,f=65535&I|C<<16,I=65535&(O=_),C=O>>>16,B=65535&(x=o),S=x>>>16,C+=(O=T)>>>16,B+=65535&(x=v),S+=x>>>16,k=i,U=n,N=a,D=o=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,R=d,Y=c,V=u,A=h,M=p,F=l,X=m,L=_=65535&I|C<<16,q=b,G=g,$=y,J=f,E%16==15)for(w=0;w<16;w++)x=P[w],I=65535&(O=j[w]),C=O>>>16,B=65535&x,S=x>>>16,x=P[(w+9)%16],I+=65535&(O=j[(w+9)%16]),C+=O>>>16,B+=65535&x,S+=x>>>16,v=P[(w+1)%16],I+=65535&(O=((T=j[(w+1)%16])>>>1|v<<31)^(T>>>8|v<<24)^(T>>>7|v<<25)),C+=O>>>16,B+=65535&(x=(v>>>1|T<<31)^(v>>>8|T<<24)^v>>>7),S+=x>>>16,v=P[(w+14)%16],C+=(O=((T=j[(w+14)%16])>>>19|v<<13)^(v>>>29|T<<3)^(T>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|T<<13)^(T>>>29|v<<3)^v>>>6),S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,P[w]=65535&B|S<<16,j[w]=65535&I|C<<16;I=65535&(O=J),C=O>>>16,B=65535&(x=A),S=x>>>16,x=e[0],C+=(O=t[0])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[0]=A=65535&B|S<<16,t[0]=J=65535&I|C<<16,I=65535&(O=M),C=O>>>16,B=65535&(x=k),S=x>>>16,x=e[1],C+=(O=t[1])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[1]=k=65535&B|S<<16,t[1]=M=65535&I|C<<16,I=65535&(O=F),C=O>>>16,B=65535&(x=U),S=x>>>16,x=e[2],C+=(O=t[2])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[2]=U=65535&B|S<<16,t[2]=F=65535&I|C<<16,I=65535&(O=X),C=O>>>16,B=65535&(x=N),S=x>>>16,x=e[3],C+=(O=t[3])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[3]=N=65535&B|S<<16,t[3]=X=65535&I|C<<16,I=65535&(O=L),C=O>>>16,B=65535&(x=D),S=x>>>16,x=e[4],C+=(O=t[4])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[4]=D=65535&B|S<<16,t[4]=L=65535&I|C<<16,I=65535&(O=q),C=O>>>16,B=65535&(x=R),S=x>>>16,x=e[5],C+=(O=t[5])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[5]=R=65535&B|S<<16,t[5]=q=65535&I|C<<16,I=65535&(O=G),C=O>>>16,B=65535&(x=Y),S=x>>>16,x=e[6],C+=(O=t[6])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[6]=Y=65535&B|S<<16,t[6]=G=65535&I|C<<16,I=65535&(O=$),C=O>>>16,B=65535&(x=V),S=x>>>16,x=e[7],C+=(O=t[7])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[7]=V=65535&B|S<<16,t[7]=$=65535&I|C<<16,z+=128,s-=128}return s}function K(e,t,r){var s,i=new Int32Array(8),n=new Int32Array(8),a=new Uint8Array(256),o=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,n[0]=4089235720,n[1]=2227873595,n[2]=4271175723,n[3]=1595750129,n[4]=2917565137,n[5]=725511199,n[6]=4215389547,n[7]=327033209,H(i,n,t,r),r%=128,s=0;s<r;s++)a[s]=t[o-r+s];for(a[r]=128,a[(r=256-128*(r<112?1:0))-9]=0,m(a,r-8,o/536870912|0,o<<3),H(i,n,a,r),s=0;s<8;s++)m(e,8*s,i[s],n[s]);return 0}function Q(e,r){var s=t(),i=t(),n=t(),a=t(),o=t(),d=t(),c=t(),h=t(),p=t();Y(s,e[1],e[0]),Y(p,r[1],r[0]),V(s,s,p),R(i,e[0],e[1]),R(p,r[0],r[1]),V(i,i,p),V(n,e[3],r[3]),V(n,n,u),V(a,e[2],r[2]),R(a,a,a),Y(o,i,s),Y(d,a,n),R(c,a,n),R(h,i,s),V(e[0],o,d),V(e[1],h,c),V(e[2],c,d),V(e[3],o,h)}function Z(e,t,r){var s;for(s=0;s<4;s++)A(e[s],t[s],r)}function ee(e,r){var s=t(),i=t(),n=t();M(n,r[2]),V(s,r[0],n),V(i,r[1],n),k(e,i),e[31]^=N(s)<<7}function te(e,t,r){var s,i;for(P(e[0],a),P(e[1],o),P(e[2],o),P(e[3],a),i=255;i>=0;--i)Z(e,t,s=r[i/8|0]>>(7&i)&1),Q(t,e),Q(e,e),Z(e,t,s)}function re(e,r){var s=[t(),t(),t(),t()];P(s[0],h),P(s[1],p),P(s[2],o),V(s[3],h,p),te(e,s,r)}function se(e,r,i){var n,a=new Uint8Array(64),o=[t(),t(),t(),t()];for(i||s(r,32),K(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(o,a),ee(e,o),n=0;n<32;n++)r[n+32]=e[n];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ne(e,t){var r,s,i,n;for(s=63;s>=32;--s){for(r=0,i=s-32,n=s-12;i<n;++i)t[i]+=r-16*t[s]*ie[i-(s-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[s]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ie[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ie[i];for(s=0;s<32;s++)t[s+1]+=t[s]>>8,e[s]=255&t[s]}function ae(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ne(e,r)}function oe(e,r,s,i){var n,a,o=new Uint8Array(64),d=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),h=[t(),t(),t(),t()];K(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var p=s+64;for(n=0;n<s;n++)e[64+n]=r[n];for(n=0;n<32;n++)e[32+n]=o[32+n];for(K(c,e.subarray(32),s+32),ae(c),re(h,c),ee(e,h),n=32;n<64;n++)e[n]=i[n];for(K(d,e,s+64),ae(d),n=0;n<64;n++)u[n]=0;for(n=0;n<32;n++)u[n]=c[n];for(n=0;n<32;n++)for(a=0;a<32;a++)u[n+a]+=d[n]*o[a];return ne(e.subarray(32),u),p}function de(e,r,s,i){var n,d=new Uint8Array(32),u=new Uint8Array(64),h=[t(),t(),t(),t()],p=[t(),t(),t(),t()];if(s<64)return-1;if(function(e,r){var s=t(),i=t(),n=t(),d=t(),u=t(),h=t(),p=t();return P(e[2],o),D(e[1],r),J(n,e[1]),V(d,n,c),Y(n,n,e[2]),R(d,e[2],d),J(u,d),J(h,u),V(p,h,u),V(s,p,n),V(s,s,d),F(s,s),V(s,s,n),V(s,s,d),V(s,s,d),V(e[0],s,d),J(i,e[0]),V(i,i,d),U(i,n)&&V(e[0],e[0],l),J(i,e[0]),V(i,i,d),U(i,n)?-1:(N(e[0])===r[31]>>7&&Y(e[0],a,e[0]),V(e[3],e[0],e[1]),0)}(p,i))return-1;for(n=0;n<s;n++)e[n]=r[n];for(n=0;n<32;n++)e[n+32]=i[n];if(K(u,e,s),ae(u),te(h,p,u),re(p,r.subarray(32)),Q(h,p),ee(d,h),s-=64,g(r,0,d,0)){for(n=0;n<s;n++)e[n]=0;return-1}for(n=0;n<s;n++)e[n]=r[n+64];return s}var ce,ue=64,he=32,pe=64;function le(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function _e(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:f,crypto_stream_xor:x,crypto_stream:w,crypto_stream_salsa20_xor:T,crypto_stream_salsa20:E,crypto_onetimeauth:I,crypto_onetimeauth_verify:C,crypto_verify_16:b,crypto_verify_32:g,crypto_secretbox:B,crypto_secretbox_open:S,crypto_scalarmult:X,crypto_scalarmult_base:L,crypto_box_beforenm:G,crypto_box_afternm:$,crypto_box:function(e,t,r,s,i,n){var a=new Uint8Array(32);return G(a,i,n),$(e,t,r,s,a)},crypto_box_open:function(e,t,r,s,i,n){var a=new Uint8Array(32);return G(a,i,n),z(e,t,r,s,a)},crypto_box_keypair:q,crypto_hash:K,crypto_sign:oe,crypto_sign_keypair:se,crypto_sign_open:de,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:he,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:c,L:ie,pack25519:k,unpack25519:D,M:V,A:R,S:J,Z:Y,pow2523:F,add:Q,set25519:P,modL:ne,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return s(t,e),t},e.secretbox=function(e,t,r){me(e,t,r),le(r,t);for(var s=new Uint8Array(32+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+32]=e[n];return B(i,s,s.length,t,r),i.subarray(16)},e.secretbox.open=function(e,t,r){me(e,t,r),le(r,t);for(var s=new Uint8Array(16+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+16]=e[n];return s.length<32||0!==S(i,s,s.length,t,r)?null:i.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(me(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=new Uint8Array(32);return X(r,e,t),r},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return L(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox(t,r,n)},e.box.before=function(e,t){me(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var r=new Uint8Array(32);return G(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox.open(t,r,n)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return q(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return L(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(me(e,t),t.length!==pe)throw new Error("bad secret key size");var r=new Uint8Array(ue+e.length);return oe(r,e,e.length,t),r},e.sign.open=function(e,t){if(me(e,t),t.length!==he)throw new Error("bad public key size");var r=new Uint8Array(e.length),s=de(r,e,e.length,t);if(s<0)return null;for(var i=new Uint8Array(s),n=0;n<i.length;n++)i[n]=r[n];return i},e.sign.detached=function(t,r){for(var s=e.sign(t,r),i=new Uint8Array(ue),n=0;n<i.length;n++)i[n]=s[n];return i},e.sign.detached.verify=function(e,t,r){if(me(e,t,r),t.length!==ue)throw new Error("bad signature size");if(r.length!==he)throw new Error("bad public key size");var s,i=new Uint8Array(ue+e.length),n=new Uint8Array(ue+e.length);for(s=0;s<ue;s++)i[s]=t[s];for(s=0;s<e.length;s++)i[s+ue]=e[s];return de(n,i,i.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(he),t=new Uint8Array(pe);return se(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(he),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(he),r=new Uint8Array(pe),s=0;s<32;s++)r[s]=e[s];return se(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=he,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){me(e);var t=new Uint8Array(64);return K(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===_(e,0,t,0,e.length)},e.setPRNG=function(e){s=e},(ce="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ce.getRandomValues?e.setPRNG((function(e,t){var r,s=new Uint8Array(t);for(r=0;r<t;r+=65536)ce.getRandomValues(s.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=s[r];_e(s)})):(ce=r(211))&&ce.randomBytes&&e.setPRNG((function(e,t){var r,s=ce.randomBytes(t);for(r=0;r<t;r++)e[r]=s[r];_e(s)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},725:(e,t,r)=>{const s=r(22);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},763:(e,t,r)=>{const s=r(364);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);a.r(i);var n={};e=e||[null,t({}),t([]),t(t)];for(var o=2&s&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>n[e]=()=>r[e]));return n.default=()=>r,a.d(i,n),i},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".index.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},s="wowok_agent:",a.l=(e,t,i,n)=>{if(r[e])r[e].push(t);else{var o,d;if(void 0!==i)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var h=c[u];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==s+i){o=h;break}}o||(d=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,a.nc&&o.setAttribute("nonce",a.nc),o.setAttribute("data-webpack",s+i),o.src=e),r[e]=[t];var p=(t,s)=>{o.onerror=o.onload=null,clearTimeout(l);var i=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(s))),t)return t(s)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),d&&document.head.appendChild(o)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var s=r.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=r[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={792:0};a.f.j=(t,r)=>{var s=a.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{var i=new Promise(((r,i)=>s=e[t]=[r,i]));r.push(s[2]=i);var n=a.p+a.u(t),o=new Error;a.l(n,(r=>{if(a.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+i+": "+n+")",o.name="ChunkLoadError",o.type=i,o.request=n,s[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var s,i,[n,o,d]=r,c=0;if(n.some((t=>0!==e[t]))){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);d&&d(a)}for(t&&t(r);c<n.length;c++)i=n[c],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var o={};return(()=>{"use strict";a.r(o),a.d(o,{Account:()=>cc,BCS:()=>Xl,CacheData:()=>Pd,CacheName:()=>jd,CacheType:()=>Dd,CallArbitration:()=>ql,CallBase:()=>bl,CallDemand:()=>zl,CallGuard:()=>Ql,CallMachine:()=>Wl,CallObjectPermission:()=>$l,CallPermission:()=>gl,CallPersonal:()=>tm,CallRepository:()=>Hl,CallService:()=>Kl,CallTreasury:()=>Gl,EVENT_QUERY:()=>ac,LocalStorageCache:()=>Ud,MemeryCache:()=>kd,OBJECT_KEY:()=>Ad,ResponseData:()=>_l,WOWOK:()=>e,WowokCache:()=>Nd,call_arbitration:()=>Tm,call_arbitration_json:()=>cm,call_demand:()=>pm,call_demand_json:()=>rm,call_guard:()=>bm,call_guard_json:()=>hm,call_machine:()=>gm,call_machine_json:()=>im,call_permission:()=>fm,call_permission_json:()=>am,call_personal:()=>ym,call_personal_json:()=>um,call_repository:()=>_m,call_repository_json:()=>nm,call_service:()=>lm,call_service_json:()=>sm,call_transfer_permission:()=>vm,call_transferpermission_json:()=>om,call_treasury:()=>mm,call_treasury_json:()=>dm,data2object:()=>sc,getSuiMoveConfig:()=>Ll,queryTableItem_ArbVote:()=>qd,queryTableItem_DemandPresenter:()=>Xd,queryTableItem_PermissionEntity:()=>Ld,queryTableItem_Personal:()=>Md,query_objects:()=>Jd,query_objects_json:()=>Rd,query_permission:()=>nc,query_permission_json:()=>ic,query_personal_json:()=>Vd,query_table:()=>Fd,query_table_json:()=>Yd,raw2type:()=>rc,tableItemQuery_MachineNode:()=>Gd,tableItemQuery_MarkTag:()=>Kd,tableItemQuery_ProgressHistory:()=>zd,tableItemQuery_RepositoryData:()=>Hd,tableItemQuery_ServiceSale:()=>$d,tableItemQuery_TreasuryHistory:()=>Wd});var e={};function t(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}a.r(e),a.d(e,{Arbitration:()=>xd,BCS:()=>Oa,Bcs:()=>Wa,BuyRequiredEnum:()=>ud,ContextType:()=>Xo,Demand:()=>Wo,ENTRYPOINT:()=>qo,ERROR:()=>Ba,Ed25519Keypair:()=>Zn,Entity:()=>yd,Errors:()=>Ca,FirstLetterUppercase:()=>Po,FunctionGroup:()=>rd,GUARD_QUERIES:()=>td,Guard:()=>id,GuardFunctions:()=>sd,GuardMaker:()=>ad,GuardParser:()=>_d,IsNumberType:()=>Fo,IsValidAddress:()=>co,IsValidArgType:()=>yo,IsValidArray:()=>To,IsValidBigint:()=>po,IsValidCoinType:()=>uo,IsValidDesription:()=>io,IsValidEndpoint:()=>oo,IsValidGuardIdentifier:()=>nd,IsValidInt:()=>fo,IsValidName:()=>no,IsValidName_AllowEmpty:()=>ao,IsValidOperatorType:()=>Jo,IsValidPercent:()=>vo,IsValidTokenType:()=>go,IsValidU128:()=>_o,IsValidU256:()=>bo,IsValidU64:()=>mo,IsValidU8:()=>lo,IsValidValueType:()=>Mo,LogicsInfo:()=>Uo,MAX_DESCRIPTION_LENGTH:()=>eo,MAX_ENDPOINT_LENGTH:()=>ro,MAX_NAME_LENGTH:()=>to,MAX_U128:()=>ja,MAX_U256:()=>Aa,MAX_U64:()=>Pa,MAX_U8:()=>Sa,MODULES:()=>Ao,Machine:()=>Zo,OPTION_NONE:()=>ka,OperatorType:()=>ko,OperatorTypeArray:()=>Yo,PAYMENT_MAX_RECEIVER_COUNT:()=>Ed,ParseType:()=>Oo,Passport:()=>bd,Permission:()=>Qo,PermissionIndex:()=>Ho,PermissionInfo:()=>Ko,Progress:()=>ed,Protocol:()=>$o,Repository:()=>md,RepositoryValueType:()=>Do,RepositoryValueTypeInfo:()=>Ro,Repository_Policy_Mode:()=>od,Repository_Type:()=>dd,ResolveBalance:()=>xo,ResolveU64:()=>Eo,Resource:()=>vd,RpcResultParser:()=>zo,SER_VALUE:()=>Lo,Service:()=>gd,Service_Discount_Type:()=>cd,SuiClient:()=>ei,TagName:()=>hd,TransactionBlock:()=>gs,Treasury:()=>Td,Treasury_Operation:()=>ld,Treasury_WithdrawMode:()=>pd,ValueType:()=>No,ValueTypeArray:()=>Vo,ValueTypeConvert:()=>Ua,Wowok:()=>fd,array_equal:()=>qa,array_unique:()=>Ga,capitalize:()=>$a,cb_U128:()=>Ma,cb_U256:()=>Fa,cb_U64:()=>Ja,cb_U8:()=>Va,concatenate:()=>Xa,create_payment:()=>wd,decodeSuiPrivateKey:()=>Un,deepClone:()=>Za,encodeSuiPrivateKey:()=>Nn,fromHEX:()=>ea,getFaucetHost:()=>Sd,getSuiMoveConfig:()=>Ia,getUTCDayStartByDivision:()=>ho,hasDuplicates:()=>jo,insertAtHead:()=>Io,isArr:()=>Qa,isValidHttpUrl:()=>Bo,normalizeSuiAddress:()=>de,numToUint8Array:()=>Ka,parseObjectType:()=>La,parse_object_type:()=>za,query_object:()=>So,readOption:()=>Na,readOptionString:()=>Da,readVec:()=>Ya,requestSuiFromFaucetV0:()=>Cd,requestSuiFromFaucetV1:()=>Bd,stringToUint8Array:()=>Ha,toFixed:()=>Co,toHEX:()=>ta,ulebDecode:()=>Ra});const r=8192;function s(e){if(e.length<r)return btoa(String.fromCharCode(...e));let t="";for(var s=0;s<e.length;s+=r){const i=e.slice(s,s+r);t+=String.fromCharCode(...i)}return btoa(t)}const i=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;e[n];){let s=t[e.charCodeAt(n)];if(255===s)return;let i=0;for(let e=d-1;(0!==s||i<o)&&-1!==e;e--,i++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw new Error("Non-zero carry");o=i,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let p=a;for(;u!==d;)h[p++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let p=s.repeat(i);for(;h<c;++h)p+=e.charAt(u[h]);return p},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n=e=>i.encode(e),d=e=>i.decode(e);function c(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function u(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function h(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class p{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class l{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return m(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return m(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return m(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return h(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return n(e);case"base64":return s(e);case"hex":return u(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function m(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var _,b,g,y,f=e=>{throw TypeError(e)},v=(e,t,r)=>t.has(e)||f("Cannot "+r),T=(e,t,r)=>(v(e,t,"read from private field"),r?r.call(e):t.get(e)),E=(e,t,r)=>t.has(e)?f("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),w=(e,t,r,s)=>(v(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);_=new WeakMap,b=new WeakMap;let x=class e{constructor(e){E(this,_),E(this,b),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),w(this,_,e.write),w(this,b,e.serialize??((e,t)=>{const r=new l({initialSize:this.serializedSize(e)??void 0,...t});return T(this,_).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),T(this,_).call(this,e,t)}serialize(e,t){return this.validate(e),new C(this,T(this,b).call(this,e,t))}parse(e){const t=new p(e);return this.read(t)}fromHex(e){return this.parse(c(e))}fromBase58(e){return this.parse(d(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>T(this,_).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>T(this,b).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const O=Symbol.for("@mysten/serialized-bcs");function I(e){return!!e&&"object"==typeof e&&!0===e[O]}class C{constructor(e,t){E(this,g),E(this,y),w(this,g,e),w(this,y,t)}get[O](){return!0}toBytes(){return T(this,y)}toHex(){return u(T(this,y))}toBase64(){return s(T(this,y))}toBase58(){return n(T(this,y))}parse(){return T(this,g).parse(T(this,y))}}function B({size:e,...t}){return new x({...t,serializedSize:()=>e})}function S({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function P({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function j(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function A(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??j(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function k(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}g=new WeakMap,y=new WeakMap;var U=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function N(e,t){return{kind:"validation",type:"check",reference:N,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"input",e,t),e}}}function D(e){return{kind:"validation",type:"integer",reference:D,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"integer",e,t),e}}}function R(e){return{kind:"transformation",type:"transform",reference:R,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Y(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function V(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function J(e,t){return{kind:"schema",type:"array",reference:J,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function M(e){return{kind:"schema",type:"bigint",reference:M,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"boolean",reference:F,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function X(e){return{kind:"schema",type:"lazy",reference:X,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function L(e,t){return{kind:"schema",type:"literal",reference:L,expects:j(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:A(this,"type",e,t),e}}}function q(e,...t){const r={kind:"schema",type:"nullable",reference:q,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Y(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function G(e,...t){const r={kind:"schema",type:"nullish",reference:G,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Y(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function $(e){return{kind:"schema",type:"number",reference:$,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?A(this,"type",e,t):e.typed=!0,e}}}function z(e,t){return{kind:"schema",type:"object",reference:z,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else A(this,"type",e,t);return e}}}function W(e,...t){const r={kind:"schema",type:"optional",reference:W,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Y(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function H(e,t,r){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(k(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else A(this,"type",e,t);return e}}}function K(e){return{kind:"schema",type:"string",reference:K,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function Q(e,t){return{kind:"schema",type:"tuple",reference:Q,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function Z(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ee(e,t){return{kind:"schema",type:"union",reference:ee,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];A(this,"type",e,t,{issues:Z(s)}),e.typed=!0}else{if(1===i?.length)return i[0];A(this,"type",e,t,{issues:Z(i)})}return e}}}function te(){return{kind:"schema",type:"unknown",reference:te,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function re(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new U(s.issues);return s.value}function se(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function ie(e){try{return 32===d(e).length}catch(e){return!1}}const ne=32;function ae(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===ne}function oe(e){return ae(e)}function de(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*ne,"0")}`}function ce(e,t=!1){return de(e,t)}function ue(e){return se(ee(Object.entries(e).map((([e,t])=>z({[e]:t})))),R((e=>({...e,$kind:Object.keys(e)[0]}))))}const he=se(K(),R((e=>de(e))),N(ae)),pe=he,le=K(),me=se(ee([K(),se($(),D())]),N((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),_e=z({objectId:he,version:me,digest:K()}),be=se(ee([z({GasCoin:L(!0)}),z({Input:se($(),D()),type:W(L("pure"))}),z({Input:se($(),D()),type:W(L("object"))}),z({Result:se($(),D())}),z({NestedResult:Q([se($(),D()),se($(),D())])})]),R((e=>({...e,$kind:Object.keys(e)[0]})))),ge=z({budget:q(me),price:q(me),owner:q(he),payment:q(J(_e))}),ye=(z({address:K(),module:K(),name:K(),typeParams:J(K())}),ee([L("address"),L("bool"),L("u8"),L("u16"),L("u32"),L("u64"),L("u128"),L("u256"),z({vector:X((()=>ye))}),z({datatype:z({package:K(),module:K(),type:K(),typeParameters:J(X((()=>ye)))})}),z({typeParameter:se($(),D())})])),fe=z({ref:q(ee([L("&"),L("&mut")])),body:ye}),ve=z({package:pe,module:K(),function:K(),typeArguments:J(K()),arguments:J(be),_argumentTypes:W(q(J(fe)))}),Te=z({name:K(),inputs:H(K(),ee([be,J(be)])),data:H(K(),te())}),Ee=ue({MoveCall:ve,TransferObjects:z({objects:J(be),address:be}),SplitCoins:z({coin:be,amounts:J(be)}),MergeCoins:z({destination:be,sources:J(be)}),Publish:z({modules:J(le),dependencies:J(pe)}),MakeMoveVec:z({type:q(K()),elements:J(be)}),Upgrade:z({modules:J(le),dependencies:J(pe),package:pe,ticket:be}),$Intent:Te}),we=ue({ImmOrOwnedObject:_e,SharedObject:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:_e}),xe=ue({Object:we,Pure:z({bytes:le}),UnresolvedPure:z({value:te()}),UnresolvedObject:z({objectId:pe,version:W(q(me)),digest:W(q(K())),initialSharedVersion:W(q(me))})}),Oe=ue({Object:we,Pure:z({bytes:le})}),Ie=ue({None:L(!0),Epoch:me}),Ce=z({version:L(2),sender:G(he),expiration:G(Ie),gasData:ge,inputs:J(xe),commands:J(Ee)}),Be={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>re(be,e))),address:re(be,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:re(be,e),amounts:t.map((e=>re(be,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:re(be,e),sources:t.map((e=>re(be,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:i})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e))),package:r,ticket:re(be,i)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>re(be,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>re(be,e))):re(be,t)]))),data:r}})},Se=/^vector<(.+)>$/,Pe=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class je{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(Se);if(r)return{vector:je.parseFromStr(r[1],t)};const s=e.match(Pe);if(s)return{struct:{address:t?de(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:je.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>je.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${je.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(je.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Ae=z({digest:K(),objectId:K(),version:ee([se($(),D()),K(),M()])}),ke=ue({ImmOrOwned:Ae,Shared:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:Ae}),Ue=ue({Object:ke,Pure:J(se($(),D()))}),Ne=ee([z({kind:L("Input"),index:se($(),D()),value:te(),type:W(L("object"))}),z({kind:L("Input"),index:se($(),D()),value:te(),type:L("pure")})]),De=ee([z({Epoch:se($(),D())}),z({None:q(L(!0))})]),Re=se(ee([$(),K(),M()]),N((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Ye=ee([z({bool:q(L(!0))}),z({u8:q(L(!0))}),z({u64:q(L(!0))}),z({u128:q(L(!0))}),z({address:q(L(!0))}),z({signer:q(L(!0))}),z({vector:X((()=>Ye))}),z({struct:X((()=>Ve))}),z({u16:q(L(!0))}),z({u32:q(L(!0))}),z({u256:q(L(!0))})]),Ve=z({address:K(),module:K(),name:K(),typeParams:J(Ye)}),Je=z({budget:W(Re),price:W(Re),payment:W(J(Ae)),owner:W(K())}),Me=ee([Ne,z({kind:L("GasCoin")}),z({kind:L("Result"),index:se($(),D())}),z({kind:L("NestedResult"),index:se($(),D()),resultIndex:se($(),D())})]),Fe=z({kind:L("MoveCall"),target:se(K(),N((e=>3===e.split("::").length))),typeArguments:J(K()),arguments:J(Me)}),Xe=z({kind:L("TransferObjects"),objects:J(Me),address:Me}),Le=z({kind:L("SplitCoins"),coin:Me,amounts:J(Me)}),qe=z({kind:L("MergeCoins"),destination:Me,sources:J(Me)}),Ge=z({kind:L("MakeMoveVec"),type:ee([z({Some:Ye}),z({None:q(L(!0))})]),objects:J(Me)}),$e=ee([Fe,Xe,Le,qe,z({kind:L("Publish"),modules:J(J(se($(),D()))),dependencies:J(K())}),z({kind:L("Upgrade"),modules:J(J(se($(),D()))),dependencies:J(K()),packageId:K(),ticket:Me}),Ge]);function ze(e){const r=e.inputs.map(((e,r)=>{if(e.Object)return{kind:"Input",index:r,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:r,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:r,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:r,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:r,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:je.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>We(e,r)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:We(e.MergeCoins.destination,r),sources:e.MergeCoins.sources.map((e=>We(e,r)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>We(e,r)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(t(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:We(e.SplitCoins.coin,r),amounts:e.SplitCoins.amounts.map((e=>We(e,r)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>We(e,r))),address:We(e.TransferObjects.address,r)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(t(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:We(e.Upgrade.ticket,r)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function We(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function He(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Ke(e){return ee(Object.entries(e).map((([e,t])=>z({[e]:t}))))}z({version:L(1),sender:W(K()),expiration:G(De),gasConfig:Je,inputs:J(Ne),transactions:J($e)});const Qe=Ke({GasCoin:L(!0),Input:se($(),D()),Result:se($(),D()),NestedResult:Q([se($(),D()),se($(),D())])}),Ze=z({budget:q(me),price:q(me),owner:q(he),payment:q(J(_e))}),et=z({package:pe,module:K(),function:K(),typeArguments:J(K()),arguments:J(Qe)}),tt=z({name:K(),inputs:H(K(),ee([Qe,J(Qe)])),data:H(K(),te())}),rt=Ke({MoveCall:et,TransferObjects:z({objects:J(Qe),address:Qe}),SplitCoins:z({coin:Qe,amounts:J(Qe)}),MergeCoins:z({destination:Qe,sources:J(Qe)}),Publish:z({modules:J(le),dependencies:J(pe)}),MakeMoveVec:z({type:q(K()),elements:J(Qe)}),Upgrade:z({modules:J(le),dependencies:J(pe),package:pe,ticket:Qe}),$Intent:tt}),st=Ke({ImmOrOwnedObject:_e,SharedObject:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:_e}),it=Ke({Object:st,Pure:z({bytes:le}),UnresolvedPure:z({value:te()}),UnresolvedObject:z({objectId:pe,version:W(q(me)),digest:W(q(K())),initialSharedVersion:W(q(me))})}),nt=Ke({None:L(!0),Epoch:me}),at=z({version:L(2),sender:G(he),expiration:G(nt),gasData:Ze,inputs:J(it),commands:J(rt)}),ot=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?s(e):e.toBase64()}}},dt=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:de(e)}}}),ct=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:de(e)}}}),ut=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:de(e)}}}),ht={u8:e=>S({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>S({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>S({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>P({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>P({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>P({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>B({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new x({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(h(e)),...e}),bytes:(e,t)=>B({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new x({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=h(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new x({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>ht.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new x({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new x({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new x({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new x({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>ht.vector(ht.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new x({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},pt=ht.bytes(ne).transform({validate:e=>{const t="string"==typeof e?e:u(e);if(!t||!ae(de(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?c(de(e)):e,output:e=>de(u(e))}),lt=ht.vector(ht.u8()).transform({name:"ObjectDigest",input:e=>d(e),output:e=>n(new Uint8Array(e)),validate:e=>{if(32!==d(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),mt=ht.struct("SuiObjectRef",{objectId:pt,version:ht.u64(),digest:lt}),_t=ht.struct("SharedObjectRef",{objectId:pt,initialSharedVersion:ht.u64(),mutable:ht.bool()}),bt=ht.enum("ObjectArg",{ImmOrOwnedObject:mt,SharedObject:_t,Receiving:mt}),gt=ht.enum("CallArg",{Pure:ht.struct("Pure",{bytes:ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})}),Object:bt}),yt=ht.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:ht.lazy((()=>yt)),struct:ht.lazy((()=>It)),u16:null,u32:null,u256:null}),ft=yt.transform({input:e=>"string"==typeof e?je.parseFromStr(e,!0):e,output:e=>je.tagToString(e)}),vt=ht.enum("Argument",{GasCoin:null,Input:ht.u16(),Result:ht.u16(),NestedResult:ht.tuple([ht.u16(),ht.u16()])}),Tt=ht.struct("ProgrammableMoveCall",{package:pt,module:ht.string(),function:ht.string(),typeArguments:ht.vector(ft),arguments:ht.vector(vt)}),Et=ht.enum("Command",{MoveCall:Tt,TransferObjects:ht.struct("TransferObjects",{objects:ht.vector(vt),address:vt}),SplitCoins:ht.struct("SplitCoins",{coin:vt,amounts:ht.vector(vt)}),MergeCoins:ht.struct("MergeCoins",{destination:vt,sources:ht.vector(vt)}),Publish:ht.struct("Publish",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(pt)}),MakeMoveVec:ht.struct("MakeMoveVec",{type:function(e){return ht.enum("Option",{None:null,Some:e})}(ft).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:ht.vector(vt)}),Upgrade:ht.struct("Upgrade",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(pt),package:pt,ticket:vt})}),wt=ht.struct("ProgrammableTransaction",{inputs:ht.vector(gt),commands:ht.vector(Et)}),xt=ht.enum("TransactionKind",{ProgrammableTransaction:wt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ot=ht.enum("TransactionExpiration",{None:null,Epoch:ht.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const It=ht.struct("StructTag",{address:pt,module:ht.string(),name:ht.string(),typeParams:ht.vector(yt)}),Ct=ht.struct("GasData",{payment:ht.vector(mt),owner:pt,price:ht.u64(),budget:ht.u64()}),Bt=ht.struct("TransactionDataV1",{kind:xt,sender:pt,gasData:Ct,expiration:Ot}),St=ht.enum("TransactionData",{V1:Bt}),Pt=ht.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),jt=ht.enum("IntentVersion",{V0:null}),At=ht.enum("AppId",{Sui:null}),kt=ht.struct("Intent",{scope:Pt,version:jt,appId:At});function Ut(e){return ht.struct(`IntentMessage<${e.name}>`,{intent:kt,value:e})}const Nt=ht.enum("CompressedSignature",{ED25519:ht.fixedArray(64,ht.u8()),Secp256k1:ht.fixedArray(64,ht.u8()),Secp256r1:ht.fixedArray(64,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Dt=ht.enum("PublicKey",{ED25519:ht.fixedArray(32,ht.u8()),Secp256k1:ht.fixedArray(33,ht.u8()),Secp256r1:ht.fixedArray(33,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Rt=ht.struct("MultiSigPkMap",{pubKey:Dt,weight:ht.u8()}),Yt=ht.struct("MultiSigPublicKey",{pk_map:ht.vector(Rt),threshold:ht.u16()}),Vt=ht.struct("MultiSig",{sigs:ht.vector(Nt),bitmap:ht.u16(),multisig_pk:Yt}),Jt=ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))}),Mt=ht.struct("SenderSignedTransaction",{intentMessage:Ut(St),txSignatures:ht.vector(Jt)}),Ft=ht.vector(Mt,{name:"SenderSignedData"}),Xt=ht.enum("PackageUpgradeError",{UnableToFetchPackage:ht.struct("UnableToFetchPackage",{packageId:pt}),NotAPackage:ht.struct("NotAPackage",{objectId:pt}),IncompatibleUpgrade:null,DigestDoesNotMatch:ht.struct("DigestDoesNotMatch",{digest:ht.vector(ht.u8())}),UnknownUpgradePolicy:ht.struct("UnknownUpgradePolicy",{policy:ht.u8()}),PackageIDDoesNotMatch:ht.struct("PackageIDDoesNotMatch",{packageId:pt,ticketId:pt})}),Lt=ht.struct("ModuleId",{address:pt,name:ht.string()}),qt=ht.struct("MoveLocation",{module:Lt,function:ht.u16(),instruction:ht.u16(),functionName:ht.option(ht.string())}),Gt=ht.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:ht.struct("IndexOutOfBounds",{idx:ht.u16()}),SecondaryIndexOutOfBounds:ht.struct("SecondaryIndexOutOfBounds",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidResultArity:ht.struct("InvalidResultArity",{resultIdx:ht.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),$t=ht.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),zt=ht.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:ht.struct("MoveObjectTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),MovePackageTooBig:ht.struct("MovePackageTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),CircularObjectOwnership:ht.struct("CircularObjectOwnership",{object:pt}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:ht.option(qt),MoveAbort:ht.tuple([qt,ht.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:ht.struct("CommandArgumentError",{argIdx:ht.u16(),kind:Gt}),TypeArgumentError:ht.struct("TypeArgumentError",{argumentIdx:ht.u16(),kind:$t}),UnusedValueWithoutDrop:ht.struct("UnusedValueWithoutDrop",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidPublicFunctionReturnType:ht.struct("InvalidPublicFunctionReturnType",{idx:ht.u16()}),InvalidTransferObject:null,EffectsTooLarge:ht.struct("EffectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:ht.struct("PackageUpgradeError",{upgradeError:Xt}),WrittenObjectsTooLarge:ht.struct("WrittenObjectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Wt=ht.enum("ExecutionStatus",{Success:null,Failed:ht.struct("ExecutionFailed",{error:zt,command:ht.option(ht.u64())})}),Ht=ht.struct("GasCostSummary",{computationCost:ht.u64(),storageCost:ht.u64(),storageRebate:ht.u64(),nonRefundableStorageFee:ht.u64()}),Kt=ht.enum("Owner",{AddressOwner:pt,ObjectOwner:pt,Shared:ht.struct("Shared",{initialSharedVersion:ht.u64()}),Immutable:null}),Qt=ht.struct("TransactionEffectsV1",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,modifiedAtVersions:ht.vector(ht.tuple([pt,ht.u64()])),sharedObjects:ht.vector(mt),transactionDigest:lt,created:ht.vector(ht.tuple([mt,Kt])),mutated:ht.vector(ht.tuple([mt,Kt])),unwrapped:ht.vector(ht.tuple([mt,Kt])),deleted:ht.vector(mt),unwrappedThenDeleted:ht.vector(mt),wrapped:ht.vector(mt),gasObject:ht.tuple([mt,Kt]),eventsDigest:ht.option(lt),dependencies:ht.vector(lt)}),Zt=ht.tuple([ht.u64(),lt]),er=ht.enum("ObjectIn",{NotExist:null,Exist:ht.tuple([Zt,Kt])}),tr=ht.enum("ObjectOut",{NotExist:null,ObjectWrite:ht.tuple([lt,Kt]),PackageWrite:Zt}),rr=ht.enum("IDOperation",{None:null,Created:null,Deleted:null}),sr=ht.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:rr}),ir=ht.enum("UnchangedSharedKind",{ReadOnlyRoot:Zt,MutateDeleted:ht.u64(),ReadDeleted:ht.u64(),Cancelled:ht.u64(),PerEpochConfig:null}),nr=ht.struct("TransactionEffectsV2",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,transactionDigest:lt,gasObjectIndex:ht.option(ht.u32()),eventsDigest:ht.option(lt),dependencies:ht.vector(lt),lamportVersion:ht.u64(),changedObjects:ht.vector(ht.tuple([pt,sr])),unchangedSharedObjects:ht.vector(ht.tuple([pt,ir])),auxDataDigest:ht.option(lt)}),ar=ht.enum("TransactionEffects",{V1:Qt,V2:nr}),or={...ht,U8:ht.u8(),U16:ht.u16(),U32:ht.u32(),U64:ht.u64(),U128:ht.u128(),U256:ht.u256(),ULEB128:ht.uleb128(),Bool:ht.bool(),String:ht.string(),Address:pt,AppId:At,Argument:vt,CallArg:gt,CompressedSignature:Nt,GasData:Ct,Intent:kt,IntentMessage:Ut,IntentScope:Pt,IntentVersion:jt,MultiSig:Vt,MultiSigPkMap:Rt,MultiSigPublicKey:Yt,ObjectArg:bt,ObjectDigest:lt,ProgrammableMoveCall:Tt,ProgrammableTransaction:wt,PublicKey:Dt,SenderSignedData:Ft,SenderSignedTransaction:Mt,SharedObjectRef:_t,StructTag:It,SuiObjectRef:mt,Command:Et,TransactionData:St,TransactionDataV1:Bt,TransactionExpiration:Ot,TransactionKind:xt,TypeTag:ft,TransactionEffects:ar},dr=(BigInt(1e9),ce("0x6"),"0x2::sui::SUI");function cr(e){if("string"==typeof e)switch(e){case"address":return or.Address;case"bool":return or.Bool;case"u8":return or.U8;case"u16":return or.U16;case"u32":return or.U32;case"u64":return or.U64;case"u128":return or.U128;case"u256":return or.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return or.vector(or.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=cr(e.vector);return t?or.vector(t):null}if("datatype"in e){const t=de(e.datatype.package);if(t===de("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=cr(e.datatype.typeParameters[0]);return t?or.vector(t):null}}if(t===de("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return or.Address}return null}function ur(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:ur(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(ur)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}ce("0x5");async function hr(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{pr(t,or.U64,e)}));break;case"TransferObjects":pr(t.TransferObjects.address,or.Address,e)}}));const a=new Map;if(n.size>0){const e=_r(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:ur(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:ur(e.MutableReference)}:{ref:null,body:ur(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&de(t.package)===de("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=cr(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=ot(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>ce(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>_r(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=de(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=ct({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:lr(e,t)}):mr(e,t)&&(s=ut({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??dt({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await _r(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await _r(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await _r(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:dr})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>re(_e,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function pr(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=ot(t.serialize(s.UnresolvedPure.value)))}function lr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function mr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function _r(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function br(e){function t(t,r){if("string"==typeof t)return e(gr(t).serialize(r));if(t instanceof Uint8Array||I(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(or.U8.serialize(t)),t.u16=t=>e(or.U16.serialize(t)),t.u32=t=>e(or.U32.serialize(t)),t.u64=t=>e(or.U64.serialize(t)),t.u128=t=>e(or.U128.serialize(t)),t.u256=t=>e(or.U256.serialize(t)),t.bool=t=>e(or.Bool.serialize(t)),t.string=t=>e(or.String.serialize(t)),t.address=t=>e(or.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(or.vector(gr(t)).serialize(r)),t.option=(t,r)=>e(or.option(gr(t)).serialize(r)),t}function gr(e){switch(e){case"u8":return or.u8();case"u16":return or.u16();case"u32":return or.u32();case"u64":return or.u64();case"u128":return or.u128();case"u256":return or.u256();case"bool":return or.bool();case"string":return or.string();case"id":case"address":return or.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?or.vector(gr(r)):or.option(gr(r))}throw new Error(`Invalid Pure type name: ${e}`)}function yr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function fr(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function vr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");yr(e.outputLen),yr(e.blockLen)}function Tr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Er(e,t){fr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function wr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function xr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Or=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Ir(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Cr=Or?e=>e:e=>Ir(e);function Br(e){for(let t=0;t<e.length;t++)e[t]=Ir(e[t])}const Sr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Pr(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function jr(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),fr(e),e}class Ar{clone(){return this._cloneInto()}}function kr(e){const t=t=>e().update(jr(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ur(e){const t=(t,r)=>e(r).update(jr(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const Nr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Dr extends Ar{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,yr(e),yr(t),yr(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=wr(this.buffer)}update(e){Tr(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=jr(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Or||Br(s),this.compress(s,0,!1),Or||Br(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Or||Br(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Or||Br(e)}}return this}digestInto(e){Tr(this),Er(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Or||Br(r),this.compress(r,0,!0),Or||Br(r);const s=wr(e);this.get().forEach(((e,t)=>s[t]=Cr(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Rr=BigInt(2**32-1),Yr=BigInt(32);function Vr(e,t=!1){return t?{h:Number(e&Rr),l:Number(e>>Yr&Rr)}:{h:0|Number(e>>Yr&Rr),l:0|Number(e&Rr)}}const Jr={fromBig:Vr,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Vr(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Yr|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Mr=Jr,Fr=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xr=new Uint32Array(32);function Lr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],p=Xr[2*r],l=Xr[2*r+1],m=Xr[2*s],_=Xr[2*s+1],b=Mr.add3L(d,u,a);c=Mr.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Mr.rotr32H(_,m),Dl:Mr.rotr32L(_,m)}),({h:l,l:p}=Mr.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Mr.rotrSH(h,u,24),Bl:Mr.rotrSL(h,u,24)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=p,Xr[2*r+1]=l,Xr[2*s]=m,Xr[2*s+1]=_}function qr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],p=Xr[2*r],l=Xr[2*r+1],m=Xr[2*s],_=Xr[2*s+1],b=Mr.add3L(d,u,a);c=Mr.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Mr.rotrSH(_,m,16),Dl:Mr.rotrSL(_,m,16)}),({h:l,l:p}=Mr.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Mr.rotrBH(h,u,63),Bl:Mr.rotrBL(h,u,63)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=p,Xr[2*r+1]=l,Xr[2*s]=m,Xr[2*s+1]=_}class Gr extends Dr{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Fr[0],this.v0h=0|Fr[1],this.v1l=0|Fr[2],this.v1h=0|Fr[3],this.v2l=0|Fr[4],this.v2h=0|Fr[5],this.v3l=0|Fr[6],this.v3h=0|Fr[7],this.v4l=0|Fr[8],this.v4h=0|Fr[9],this.v5l=0|Fr[10],this.v5h=0|Fr[11],this.v6l=0|Fr[12],this.v6h=0|Fr[13],this.v7l=0|Fr[14],this.v7h=0|Fr[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=wr(jr(e.salt));this.v4l^=Cr(t[0]),this.v4h^=Cr(t[1]),this.v5l^=Cr(t[2]),this.v5h^=Cr(t[3])}if(e.personalization){const t=wr(jr(e.personalization));this.v6l^=Cr(t[0]),this.v6h^=Cr(t[1]),this.v7l^=Cr(t[2]),this.v7h^=Cr(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(jr(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:p,v6h:l,v7l:m,v7h:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|p,this.v6h=0|l,this.v7l=0|m,this.v7h=0|_}compress(e,t,r){this.get().forEach(((e,t)=>Xr[t]=e)),Xr.set(Fr,16);let{h:s,l:i}=Mr.fromBig(BigInt(this.length));Xr[24]=Fr[8]^i,Xr[25]=Fr[9]^s,r&&(Xr[28]=~Xr[28],Xr[29]=~Xr[29]);let n=0;const a=Nr;for(let r=0;r<12;r++)Lr(0,4,8,12,e,t+2*a[n++]),qr(0,4,8,12,e,t+2*a[n++]),Lr(1,5,9,13,e,t+2*a[n++]),qr(1,5,9,13,e,t+2*a[n++]),Lr(2,6,10,14,e,t+2*a[n++]),qr(2,6,10,14,e,t+2*a[n++]),Lr(3,7,11,15,e,t+2*a[n++]),qr(3,7,11,15,e,t+2*a[n++]),Lr(0,5,10,15,e,t+2*a[n++]),qr(0,5,10,15,e,t+2*a[n++]),Lr(1,6,11,12,e,t+2*a[n++]),qr(1,6,11,12,e,t+2*a[n++]),Lr(2,7,8,13,e,t+2*a[n++]),qr(2,7,8,13,e,t+2*a[n++]),Lr(3,4,9,14,e,t+2*a[n++]),qr(3,4,9,14,e,t+2*a[n++]);this.v0l^=Xr[0]^Xr[16],this.v0h^=Xr[1]^Xr[17],this.v1l^=Xr[2]^Xr[18],this.v1h^=Xr[3]^Xr[19],this.v2l^=Xr[4]^Xr[20],this.v2h^=Xr[5]^Xr[21],this.v3l^=Xr[6]^Xr[22],this.v3h^=Xr[7]^Xr[23],this.v4l^=Xr[8]^Xr[24],this.v4h^=Xr[9]^Xr[25],this.v5l^=Xr[10]^Xr[26],this.v5h^=Xr[11]^Xr[27],this.v6l^=Xr[12]^Xr[28],this.v6h^=Xr[13]^Xr[29],this.v7l^=Xr[14]^Xr[30],this.v7h^=Xr[15]^Xr[31],Xr.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const $r=Ur((e=>new Gr(e)));function zr(e){return de(e).replace("0x","")}class Wr{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=or.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=or.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new Wr(re(Ce,e)):new Wr(re(Ce,function(e){return re(Ce,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(V(Ue,e.value)){const t=re(Ue,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:s(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?je.tagToString(e.type.Some):null,elements:e.objects.map((e=>He(e)))}};case"MergeCoins":return{MergeCoins:{destination:He(e.destination),sources:e.sources.map((e=>He(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>He(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:He(e.coin),amounts:e.amounts.map((e=>He(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>He(e))),address:He(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:He(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),$r(s,{dkLen:32})}(0,e);return n(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return or.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:zr(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:zr(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return or.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return Wr.getDigestFromBytes(e)}snapshot(){return re(Ce,this)}}function Hr(e){return"string"==typeof e?de(e):e.Object?e.Object.ImmOrOwnedObject?de(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?de(e.Object.Receiving.objectId):de(e.Object.SharedObject.objectId):e.UnresolvedObject?de(e.UnresolvedObject.objectId):void 0}var Kr,Qr,Zr,es,ts,rs,ss,is,ns,as=e=>{throw TypeError(e)},os=(e,t,r)=>t.has(e)||as("Cannot "+r),ds=(e,t,r)=>(os(e,t,"read from private field"),r?r.call(e):t.get(e)),cs=(e,t,r)=>t.has(e)?as("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),us=(e,t,r,s)=>(os(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),hs=(e,t,r)=>(os(e,t,"access private method"),r);const ps=Symbol.for("@mysten/transaction");function ls(e){return!!e&&"object"==typeof e&&!0===e[ps]}const ms={buildPlugins:[],serializationPlugins:[]},_s=Symbol.for("@mysten/transaction/registry");function bs(){try{const e=globalThis;return e[_s]||(e[_s]=ms),e[_s]}catch(e){return ms}}Kr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,es=new WeakMap,ts=new WeakSet,rs=function(e){return I(e)?this.pure(e):hs(this,ts,ss).call(this,e)},ss=function(e){return re(be,"function"==typeof e?e(this):e)},is=async function(e){if(!e.onlyTransactionKind&&!ds(this,es).sender)throw new Error("Missing transaction sender");await hs(this,ts,ns).call(this,[...ds(this,Qr),hr],e)},ns=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(ds(this,es),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let gs=class e{constructor(){cs(this,ts),cs(this,Kr),cs(this,Qr),cs(this,Zr,new Map),cs(this,es),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&V(be,e))return e;const t=Hr(e),r=ds(this,es).inputs.find((e=>t===Hr(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:ds(this,es).inputs.indexOf(r),type:"object"}:ds(this,es).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:de(e)}}:e)}));const e=bs();us(this,es,new Wr),us(this,Qr,[...e.buildPlugins]),us(this,Kr,[...e.serializationPlugins])}static fromKind(r){const s=new e;return us(s,es,Wr.fromKindBytes("string"==typeof r?t(r):r)),s}static from(r){const s=new e;return ls(r)?us(s,es,new Wr(r.getData())):"string"==typeof r&&r.startsWith("{")?us(s,es,Wr.restore(JSON.parse(r))):us(s,es,Wr.fromBytes("string"==typeof r?t(r):r)),s}static registerGlobalSerializationPlugin(e){bs().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){bs().buildPlugins.push(e)}addSerializationPlugin(e){ds(this,Kr).push(e)}addBuildPlugin(e){ds(this,Qr).push(e)}addIntentResolver(e,t){if(ds(this,Zr).has(e)&&ds(this,Zr).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);ds(this,Zr).set(e,t)}setSender(e){ds(this,es).sender=e}setSenderIfNotSet(e){ds(this,es).sender||(ds(this,es).sender=e)}setExpiration(e){ds(this,es).expiration=e?re(Ie,e):null}setGasPrice(e){ds(this,es).gasConfig.price=String(e)}setGasBudget(e){ds(this,es).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==ds(this,es).gasData.budget&&(ds(this,es).gasConfig.budget=String(e))}setGasOwner(e){ds(this,es).gasConfig.owner=e}setGasPayment(e){ds(this,es).gasConfig.payment=e.map((e=>re(_e,e)))}get blockData(){return ze(ds(this,es).snapshot())}getData(){return ds(this,es).snapshot()}get[ps](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:br((e=>I(e)?ds(this,es).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):ds(this,es).addInput("pure",V(Oe,e)?re(Oe,e):e instanceof Uint8Array?ot(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(dt(...e))}receivingRef(...e){return this.object(ut(...e))}sharedObjectRef(...e){return this.object(ct(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(ds(this,es).commands.push(e)-1)}splitCoins(e,t){return this.add(Be.SplitCoins("string"==typeof e?this.object(e):hs(this,ts,ss).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):hs(this,ts,rs).call(this,e)))))}mergeCoins(e,t){return this.add(Be.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Be.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Be.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Be.MoveCall({...t,arguments:e?.map((e=>hs(this,ts,rs).call(this,e)))}))}transferObjects(e,t){return this.add(Be.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):hs(this,ts,rs).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Be.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(ze(ds(this,es).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(re(at,ds(this,es).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await hs(this,ts,is).call(this,e),ds(this,es).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await hs(this,ts,is).call(this,e),ds(this,es).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of ds(this,es).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...ds(this,Kr)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!ds(this,Zr).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(ds(this,Zr).get(s))}await hs(this,ts,ns).call(this,r,e)}};const ys=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,fs=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,vs={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Ts extends Error{}class Es extends Ts{constructor(e,t){super(e),this.code=t,this.type=vs[t]??"ServerError"}}class ws extends Ts{constructor(e,t,r){super(e),this.status=t,this.statusText=r}}var xs,Os,Is,Cs,Bs,Ss,Ps,js,As,ks=e=>{throw TypeError(e)},Us=(e,t,r)=>t.has(e)||ks("Cannot "+r),Ns=(e,t,r)=>(Us(e,t,"read from private field"),r?r.call(e):t.get(e)),Ds=(e,t,r)=>t.has(e)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Rs=(e,t,r,s)=>(Us(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),Ys=(e,t,r)=>(Us(e,t,"access private method"),r);const Vs={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Js{constructor(e,t={}){if(Ds(this,Ps),Ds(this,xs,0),Ds(this,Os,0),Ds(this,Is,null),Ds(this,Cs,null),Ds(this,Bs,new Set),Ds(this,Ss,new Map),this.endpoint=e,this.options={...Vs,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t){const r=await Ys(this,Ps,js).call(this);return new Promise(((s,i)=>{Rs(this,xs,Ns(this,xs)+1),Ns(this,Ss).set(Ns(this,xs),{resolve:s,reject:i,timeout:setTimeout((()=>{Ns(this,Ss).delete(Ns(this,xs)),i(new Error(`Request timeout: ${e}`))}),this.options.callTimeout)}),r.send(JSON.stringify({jsonrpc:"2.0",id:Ns(this,xs),method:e,params:t}))})).then((({error:e,result:t})=>{if(e)throw new Es(e.message,e.code);return t}))}async subscribe(e){const t=new Ms(e);return Ns(this,Bs).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}xs=new WeakMap,Os=new WeakMap,Is=new WeakMap,Cs=new WeakMap,Bs=new WeakMap,Ss=new WeakMap,Ps=new WeakSet,js=function(){return Ns(this,Cs)||Rs(this,Cs,new Promise((e=>{Ns(this,Is)?.close(),Rs(this,Is,new this.options.WebSocketConstructor(this.endpoint)),Ns(this,Is).addEventListener("open",(()=>{Rs(this,Os,0),e(Ns(this,Is))})),Ns(this,Is).addEventListener("close",(()=>{var e,t;(e=this,t=Os,{set _(r){Rs(e,t,r,undefined)},get _(){return Ns(e,t,undefined)}})._++,Ns(this,Os)<=this.options.maxReconnects&&setTimeout((()=>{Ys(this,Ps,As).call(this)}),this.options.reconnectTimeout)})),Ns(this,Is).addEventListener("message",(({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&Ns(this,Ss).has(t.id)){const{resolve:e,timeout:r}=Ns(this,Ss).get(t.id);clearTimeout(r),e(t)}else if("params"in t){const{params:e}=t;Ns(this,Bs).forEach((t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)}))}}))}))),Ns(this,Cs)},As=async function(){return Ns(this,Is)?.close(),Rs(this,Cs,null),Promise.allSettled([...Ns(this,Bs)].map((e=>e.subscribe(this))))};class Ms{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=t)}}var Fs,Xs,Ls,qs,Gs,$s=e=>{throw TypeError(e)},zs=(e,t,r)=>t.has(e)||$s("Cannot "+r),Ws=(e,t,r)=>(zs(e,t,"read from private field"),r?r.call(e):t.get(e)),Hs=(e,t,r)=>t.has(e)?$s("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ks=(e,t,r,s)=>(zs(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Qs{constructor(e){Hs(this,qs),Hs(this,Fs,0),Hs(this,Xs),Hs(this,Ls),Ks(this,Xs,e)}fetch(e,t){const r=Ws(this,Xs).fetch??fetch;if(!r)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return r(e,t)}async request(e){Ks(this,Fs,Ws(this,Fs)+1);const t=await this.fetch(Ws(this,Xs).rpc?.url??Ws(this,Xs).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":"1.7.0","Client-Target-Api-Version":"1.32.0",...Ws(this,Xs).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Ws(this,Fs),method:e.method,params:e.params})});if(!t.ok)throw new ws(`Unexpected status code: ${t.status}`,t.status,t.statusText);const r=await t.json();if("error"in r&&null!=r.error)throw new Es(r.error.message,r.error.code);return r.result}async subscribe(e){const t=await(r=qs,s=Gs,zs(this,r,"access private method"),s).call(this).subscribe(e);var r,s;return async()=>!!await t()}}Fs=new WeakMap,Xs=new WeakMap,Ls=new WeakMap,qs=new WeakSet,Gs=function(){if(!Ws(this,Ls)){const e=Ws(this,Xs).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Ks(this,Ls,new Js(Ws(this,Xs).websocket?.url??Ws(this,Xs).url,{WebSocketConstructor:e,...Ws(this,Xs).websocket}))}return Ws(this,Ls)};const Zs=Symbol.for("@mysten/SuiClient");class ei{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Qs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,t){return await this.transport.request({method:e,params:t})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!oe(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Object id ${e}`)})),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,"descending"===(e.order||"descending")]})}async getTransactionBlock(e){if(!ie(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach((e=>{if(!ie(e))throw new Error(`Invalid Transaction digest ${e}`)})),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock({transactionBlock:e,signature:t,options:r,requestType:i}){const n=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:s(e),Array.isArray(t)?t:[t],r]});if("WaitForLocalExecution"===i)try{await this.waitForTransaction({digest:n.digest})}catch(e){}return n}async signAndExecuteTransaction({transaction:e,signer:t,...r}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(t.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:n}=await t.signTransaction(s);return this.executeTransactionBlock({transactionBlock:n,signature:i,...r})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Stake id ${e}`)})),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,"descending"===(e.order||"descending")]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){let t;if(ls(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=s(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=s(e.transactionBlock)}return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:s(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!oe(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"});return u(d(e.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:r,hasNextPage:s,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit]});return{hasNextPage:s,nextCursor:r,data:i.map((t=>function(e,t="at"){const r=e.toLowerCase();let s;if(r.includes("@")){if(!ys.test(r))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=r.split("@");s=[...t?t.split("."):[],i]}else{if(!fs.test(r))throw new Error(`Invalid SuiNS name ${e}`);s=r.split(".").slice(0,-1)}return"dot"===t?`${s.join(".")}.sui`:`${s.slice(0,-1).join(".")}@${s[s.length-1]}`}(t,e)))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version]})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:r=2e3,...s}){const i=AbortSignal.timeout(t),n=new Promise(((e,t)=>{i.addEventListener("abort",(()=>t(i.reason)))}));for(n.catch((()=>{}));!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(s)}catch(e){await Promise.race([new Promise((e=>setTimeout(e,r))),n])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}var ti=a(601),ri=a(333);function si(e,t){return or.IntentMessage(or.fixedArray(t.length,or.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const ii={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},ni={ED25519:32,Secp256k1:33,Secp256r1:33},ai={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function oi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}class di{equals(e){return oi(this.toRawBytes(),e.toRawBytes())}toBase64(){return s(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return s(this.toSuiBytes())}verifyWithIntent(e,t,r){const s=si(r,e),i=$r(s,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(or.vector(or.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return de(function(e){fr(e);let t="";for(let r=0;r<e.length;r++)t+=Sr[e[r]];return t}($r(this.toSuiBytes(),{dkLen:32})).slice(0,2*ne))}}function ci(e){return 9===e||32===e}const ui=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function hi(e){return pi[e.charCodeAt(0)]}const pi=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];function li(e,t){if(!Boolean(e))throw new Error(t)}function mi(e){return _i(e,[])}function _i(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const r=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:_i(t,r)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const r=Math.min(10,e.length),s=e.length-r,i=[];for(let s=0;s<r;++s)i.push(_i(e[s],t));return 1===s?i.push("... 1 more item"):s>1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}(e,r);return function(e,t){const r=Object.entries(e);if(0===r.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const s=r.map((([e,r])=>e+": "+_i(r,t)));return"{ "+s.join(", ")+" }"}(e,r)}(e,t);default:return String(e)}}Symbol.toStringTag,Symbol.toStringTag;const bi={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},gi=new Set(Object.keys(bi));function yi(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&gi.has(t)}var fi,vi,Ti;!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(fi||(fi={})),(Ti=vi||(vi={})).NAME="Name",Ti.DOCUMENT="Document",Ti.OPERATION_DEFINITION="OperationDefinition",Ti.VARIABLE_DEFINITION="VariableDefinition",Ti.SELECTION_SET="SelectionSet",Ti.FIELD="Field",Ti.ARGUMENT="Argument",Ti.FRAGMENT_SPREAD="FragmentSpread",Ti.INLINE_FRAGMENT="InlineFragment",Ti.FRAGMENT_DEFINITION="FragmentDefinition",Ti.VARIABLE="Variable",Ti.INT="IntValue",Ti.FLOAT="FloatValue",Ti.STRING="StringValue",Ti.BOOLEAN="BooleanValue",Ti.NULL="NullValue",Ti.ENUM="EnumValue",Ti.LIST="ListValue",Ti.OBJECT="ObjectValue",Ti.OBJECT_FIELD="ObjectField",Ti.DIRECTIVE="Directive",Ti.NAMED_TYPE="NamedType",Ti.LIST_TYPE="ListType",Ti.NON_NULL_TYPE="NonNullType",Ti.SCHEMA_DEFINITION="SchemaDefinition",Ti.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",Ti.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",Ti.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",Ti.FIELD_DEFINITION="FieldDefinition",Ti.INPUT_VALUE_DEFINITION="InputValueDefinition",Ti.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",Ti.UNION_TYPE_DEFINITION="UnionTypeDefinition",Ti.ENUM_TYPE_DEFINITION="EnumTypeDefinition",Ti.ENUM_VALUE_DEFINITION="EnumValueDefinition",Ti.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",Ti.DIRECTIVE_DEFINITION="DirectiveDefinition",Ti.SCHEMA_EXTENSION="SchemaExtension",Ti.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",Ti.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",Ti.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",Ti.UNION_TYPE_EXTENSION="UnionTypeExtension",Ti.ENUM_TYPE_EXTENSION="EnumTypeExtension",Ti.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";const Ei=Object.freeze({});function wi(e,t){const r=e[t];return"object"==typeof r?r:"function"==typeof r?{enter:r,leave:void 0}:{enter:e.enter,leave:e.leave}}const xi={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Oi(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ci("(",Oi(e.variableDefinitions,", "),")"),r=Oi([e.operation,Oi([e.name,t]),Oi(e.directives," ")]," ");return("query"===r?"":r+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:r,directives:s})=>e+": "+t+Ci(" = ",r)+Ci(" ",Oi(s," "))},SelectionSet:{leave:({selections:e})=>Ii(e)},Field:{leave({alias:e,name:t,arguments:r,directives:s,selectionSet:i}){const n=Ci("",e,": ")+t;let a=n+Ci("(",Oi(r,", "),")");return a.length>80&&(a=n+Ci("(\n",Bi(Oi(r,"\n")),"\n)")),Oi([a,Oi(s," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ci(" ",Oi(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:r})=>Oi(["...",Ci("on ",e),Oi(t," "),r]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:r,directives:s,selectionSet:i})=>`fragment ${e}${Ci("(",Oi(r,", "),")")} on ${t} ${Ci("",Oi(s," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e){const t=e.replace(/"""/g,'\\"""'),r=t.split(/\r\n|[\n\r]/g),s=1===r.length,i=r.length>1&&r.slice(1).every((e=>0===e.length||ci(e.charCodeAt(0)))),n=t.endsWith('\\"""'),a=e.endsWith('"')&&!n,o=e.endsWith("\\"),d=a||o,c=!s||e.length>70||d||i||n;let u="";const h=s&&ci(e.charCodeAt(0));return(c&&!h||i)&&(u+="\n"),u+=t,(c||d)&&(u+="\n"),'"""'+u+'"""'}(e):`"${e.replace(ui,hi)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Oi(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Oi(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ci("(",Oi(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:r})=>Ci("",e,"\n")+Oi(["schema",Oi(t," "),Ii(r)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi(["scalar",t,Oi(r," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["type",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:r,type:s,directives:i})=>Ci("",e,"\n")+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+": "+s+Ci(" ",Oi(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:r,defaultValue:s,directives:i})=>Ci("",e,"\n")+Oi([t+": "+r,Ci("= ",s),Oi(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["interface",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:r,types:s})=>Ci("",e,"\n")+Oi(["union",t,Oi(r," "),Ci("= ",Oi(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:r,values:s})=>Ci("",e,"\n")+Oi(["enum",t,Oi(r," "),Ii(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi([t,Oi(r," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:r,fields:s})=>Ci("",e,"\n")+Oi(["input",t,Oi(r," "),Ii(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:r,repeatable:s,locations:i})=>Ci("",e,"\n")+"directive @"+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+(s?" repeatable":"")+" on "+Oi(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Oi(["extend schema",Oi(e," "),Ii(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Oi(["extend scalar",e,Oi(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend type",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend interface",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:r})=>Oi(["extend union",e,Oi(t," "),Ci("= ",Oi(r," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:r})=>Oi(["extend enum",e,Oi(t," "),Ii(r)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:r})=>Oi(["extend input",e,Oi(t," "),Ii(r)]," ")}};function Oi(e,t=""){var r;return null!==(r=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==r?r:""}function Ii(e){return Ci("{\n",Bi(Oi(e,"\n")),"\n}")}function Ci(e,t,r=""){return null!=t&&""!==t?e+t+r:""}function Bi(e){return Ci(" ",e.replace(/\n/g,"\n "))}function Si(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}var Pi,ji,Ai,ki,Ui=e=>{throw TypeError(e)},Ni=(e,t,r)=>t.has(e)||Ui("Cannot "+r),Di=(e,t,r)=>(Ni(e,t,"read from private field"),r?r.call(e):t.get(e)),Ri=(e,t,r)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Yi=(e,t,r,s)=>(Ni(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Vi extends Error{}class Ji{constructor({url:e,fetch:t=fetch,headers:r={},queries:s={}}){Ri(this,Pi),Ri(this,ji),Ri(this,Ai),Ri(this,ki),Yi(this,Pi,e),Yi(this,ji,s),Yi(this,Ai,r),Yi(this,ki,((...e)=>t(...e)))}async query(e){const t=await Di(this,ki).call(this,Di(this,Pi),{method:"POST",headers:{"Content-Type":"application/json",...Di(this,Ai)},body:JSON.stringify({query:"string"==typeof e.query?String(e.query):(r=e.query,function(e,t,r=bi){const s=new Map;for(const e of Object.values(vi))s.set(e,wi(t,e));let i,n,a,o=Array.isArray(e),d=[e],c=-1,u=[],h=e;const p=[],l=[];do{c++;const e=c===d.length,g=e&&0!==u.length;if(e){if(n=0===l.length?void 0:p[p.length-1],h=a,a=l.pop(),g)if(o){h=h.slice();let e=0;for(const[t,r]of u){const s=t-e;null===r?(h.splice(s,1),e++):h[s]=r}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[e,t]of u)h[e]=t}c=i.index,d=i.keys,u=i.edits,o=i.inArray,i=i.prev}else if(a){if(n=o?c:d[c],h=a[n],null==h)continue;p.push(n)}let y;if(!Array.isArray(h)){var m,_;yi(h)||li(!1,`Invalid AST Node: ${mi(h)}.`);const r=e?null===(m=s.get(h.kind))||void 0===m?void 0:m.leave:null===(_=s.get(h.kind))||void 0===_?void 0:_.enter;if(y=null==r?void 0:r.call(t,h,n,a,p,l),y===Ei)break;if(!1===y){if(!e){p.pop();continue}}else if(void 0!==y&&(u.push([n,y]),!e)){if(!yi(y)){p.pop();continue}h=y}}var b;void 0===y&&g&&u.push([n,h]),e?p.pop():(i={inArray:o,index:c,keys:d,edits:u,prev:i},o=Array.isArray(h),d=o?h:null!==(b=r[h.kind])&&void 0!==b?b:[],c=-1,u=[],a&&l.push(a),a=h)}while(void 0!==i);return 0!==u.length?u[u.length-1][1]:e}(r,xi)),variables:e.variables,extensions:e.extensions,operationName:e.operationName})});var r;if(!t.ok)throw new Vi(`GraphQL request failed: ${t.statusText} (${t.status})`);return await t.json()}async execute(e,t){return this.query({...t,query:Di(this,ji)[e]})}}Pi=new WeakMap,ji=new WeakMap,Ai=new WeakMap,ki=new WeakMap;var Mi,Fi,Xi="Document",Li="FragmentDefinition";class qi extends Error{constructor(e,t,r,s,i,n,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),n&&(this.originalError=n);var o=a;if(!o&&n){var d=n.extensions;d&&"object"==typeof d&&(o=d)}this.extensions=o||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}function Gi(e){return new qi(`Syntax Error: Unexpected token at ${Fi} in ${e}`)}function $i(e){if(e.lastIndex=Fi,e.test(Mi))return Mi.slice(Fi,Fi=e.lastIndex)}var zi=/ +(?=[^\s])/y;function Wi(e){for(var t=e.split("\n"),r="",s=0,i=0,n=t.length-1,a=0;a<t.length;a++)zi.lastIndex=0,zi.test(t[a])&&(a&&(!s||zi.lastIndex<s)&&(s=zi.lastIndex),i=i||a,n=a);for(var o=i;o<=n;o++)o!==i&&(r+="\n"),r+=t[o].slice(s).replace(/\\"""/g,'"""');return r}function Hi(){for(var e=0|Mi.charCodeAt(Fi++);9===e||10===e||13===e||32===e||35===e||44===e||65279===e;e=0|Mi.charCodeAt(Fi++))if(35===e)for(;10!==(e=Mi.charCodeAt(Fi++))&&13!==e;);Fi--}function Ki(){for(var e=Fi,t=0|Mi.charCodeAt(Fi++);t>=48&&t<=57||t>=65&&t<=90||95===t||t>=97&&t<=122;t=0|Mi.charCodeAt(Fi++));if(e===Fi-1)throw Gi("Name");var r=Mi.slice(e,--Fi);return Hi(),r}function Qi(){return{kind:"Name",value:Ki()}}var Zi=/(?:"""|(?:[\s\S]*?[^\\])""")/y,en=/(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;function tn(e){var t;switch(Mi.charCodeAt(Fi)){case 91:Fi++,Hi();for(var r=[];93!==Mi.charCodeAt(Fi);)r.push(tn(e));return Fi++,Hi(),{kind:"ListValue",values:r};case 123:Fi++,Hi();for(var s=[];125!==Mi.charCodeAt(Fi);){var i=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("ObjectField");Hi(),s.push({kind:"ObjectField",name:i,value:tn(e)})}return Fi++,Hi(),{kind:"ObjectValue",fields:s};case 36:if(e)throw Gi("Variable");return Fi++,{kind:"Variable",name:Qi()};case 34:if(34===Mi.charCodeAt(Fi+1)&&34===Mi.charCodeAt(Fi+2)){if(Fi+=3,null==(t=$i(Zi)))throw Gi("StringValue");return Hi(),{kind:"StringValue",value:Wi(t.slice(0,-3)),block:!0}}var n,a=Fi;Fi++;var o=!1;for(n=0|Mi.charCodeAt(Fi++);92===n&&(Fi++,o=!0)||10!==n&&13!==n&&34!==n&&n;n=0|Mi.charCodeAt(Fi++));if(34!==n)throw Gi("StringValue");return t=Mi.slice(a,Fi),Hi(),{kind:"StringValue",value:o?JSON.parse(t):t.slice(1,-1),block:!1};case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:for(var d,c=Fi++;(d=0|Mi.charCodeAt(Fi++))>=48&&d<=57;);var u=Mi.slice(c,--Fi);if(46===(d=Mi.charCodeAt(Fi))||69===d||101===d){if(null==(t=$i(en)))throw Gi("FloatValue");return Hi(),{kind:"FloatValue",value:u+t}}return Hi(),{kind:"IntValue",value:u};case 110:if(117===Mi.charCodeAt(Fi+1)&&108===Mi.charCodeAt(Fi+2)&&108===Mi.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"NullValue"};break;case 116:if(114===Mi.charCodeAt(Fi+1)&&117===Mi.charCodeAt(Fi+2)&&101===Mi.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"BooleanValue",value:!0};break;case 102:if(97===Mi.charCodeAt(Fi+1)&&108===Mi.charCodeAt(Fi+2)&&115===Mi.charCodeAt(Fi+3)&&101===Mi.charCodeAt(Fi+4))return Fi+=5,Hi(),{kind:"BooleanValue",value:!1}}return{kind:"EnumValue",value:Ki()}}function rn(e){if(40===Mi.charCodeAt(Fi)){var t=[];Fi++,Hi();do{var r=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("Argument");Hi(),t.push({kind:"Argument",name:r,value:tn(e)})}while(41!==Mi.charCodeAt(Fi));return Fi++,Hi(),t}}function sn(e){if(64===Mi.charCodeAt(Fi)){var t=[];do{Fi++,t.push({kind:"Directive",name:Qi(),arguments:rn(e)})}while(64===Mi.charCodeAt(Fi));return t}}function nn(){for(var e=0;91===Mi.charCodeAt(Fi);)e++,Fi++,Hi();var t={kind:"NamedType",name:Qi()};do{if(33===Mi.charCodeAt(Fi)&&(Fi++,Hi(),t={kind:"NonNullType",type:t}),e){if(93!==Mi.charCodeAt(Fi++))throw Gi("NamedType");Hi(),t={kind:"ListType",type:t}}}while(e--);return t}function an(){if(123!==Mi.charCodeAt(Fi++))throw Gi("SelectionSet");return Hi(),on()}function on(){var e=[];do{if(46===Mi.charCodeAt(Fi)){if(46!==Mi.charCodeAt(++Fi)||46!==Mi.charCodeAt(++Fi))throw Gi("SelectionSet");switch(Fi++,Hi(),Mi.charCodeAt(Fi)){case 64:e.push({kind:"InlineFragment",typeCondition:void 0,directives:sn(!1),selectionSet:an()});break;case 111:110===Mi.charCodeAt(Fi+1)?(Fi+=2,Hi(),e.push({kind:"InlineFragment",typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()})):e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)});break;case 123:Fi++,Hi(),e.push({kind:"InlineFragment",typeCondition:void 0,directives:void 0,selectionSet:on()});break;default:e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)})}}else{var t=Qi(),r=void 0;58===Mi.charCodeAt(Fi)&&(Fi++,Hi(),r=t,t=Qi());var s=rn(!1),i=sn(!1),n=void 0;123===Mi.charCodeAt(Fi)&&(Fi++,Hi(),n=on()),e.push({kind:"Field",alias:r,name:t,arguments:s,directives:i,selectionSet:n})}}while(125!==Mi.charCodeAt(Fi));return Fi++,Hi(),{kind:"SelectionSet",selections:e}}function dn(){if(Hi(),40===Mi.charCodeAt(Fi)){var e=[];Fi++,Hi();do{if(36!==Mi.charCodeAt(Fi++))throw Gi("Variable");var t=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("VariableDefinition");Hi();var r=nn(),s=void 0;61===Mi.charCodeAt(Fi)&&(Fi++,Hi(),s=tn(!0)),Hi(),e.push({kind:"VariableDefinition",variable:{kind:"Variable",name:t},type:r,defaultValue:s,directives:sn(!0)})}while(41!==Mi.charCodeAt(Fi));return Fi++,Hi(),e}}function cn(){var e=Qi();if(111!==Mi.charCodeAt(Fi++)||110!==Mi.charCodeAt(Fi++))throw Gi("FragmentDefinition");return Hi(),{kind:"FragmentDefinition",name:e,typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()}}function un(){var e=[];do{if(123===Mi.charCodeAt(Fi))Fi++,Hi(),e.push({kind:"OperationDefinition",operation:"query",name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:on()});else{var t=Ki();switch(t){case"fragment":e.push(cn());break;case"query":case"mutation":case"subscription":var r,s=void 0;40!==(r=Mi.charCodeAt(Fi))&&64!==r&&123!==r&&(s=Qi()),e.push({kind:"OperationDefinition",operation:t,name:s,variableDefinitions:dn(),directives:sn(!1),selectionSet:an()});break;default:throw Gi("Document")}}}while(Fi<Mi.length);return e}function hn(e,t){return Mi=e.body?e.body:e,Fi=0,Hi(),t&&t.noLocation?{kind:"Document",definitions:un()}:{kind:"Document",definitions:un(),loc:{start:0,end:Mi.length,startToken:void 0,endToken:void 0,source:{body:Mi,name:"graphql.web",locationOffset:{line:1,column:1}}}}}var pn=0,ln=new Set;function mn(){function e(e,t){var r,s,i=hn(e).definitions,n=new Set;for(var a of t||[])for(var o of a.definitions)o.kind!==Li||n.has(o)||(i.push(o),n.add(o));return(r=i[0].kind===Li)&&i[0].directives&&(i[0].directives=i[0].directives.filter((e=>"_unmask"!==e.name.value))),{kind:Xi,definitions:i,get loc(){if(!s&&r){var i=e+function(e){try{pn++;var t="";for(var r of e)if(!ln.has(r)){ln.add(r);var{loc:s}=r;s&&(t+=s.source.body)}return t}finally{0==--pn&&ln.clear()}}(t||[]);return{start:0,end:i.length,source:{body:i,name:"GraphQLTada",locationOffset:{line:1,column:1}}}}return s},set loc(e){s=e}}}return e.scalar=function(e,t){return t},e.persisted=function(e,t){return{kind:Xi,definitions:t?t.definitions:[],documentId:e}},e}mn();const _n=mn();function bn(e){if(1!==e.length)throw new Error("Invalid base64Url character: "+e);const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(e);if(-1===t)throw new Error("Invalid base64Url character: "+e);const r=t.toString(2).padStart(6,"0");return Array.from(r).map(Number)}function gn(e,t){const r=function(e,t){if(e.length<2)throw new Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let r=function(e){let t=[];for(let r=0;r<e.length;r++){const s=bn(e.charAt(r));t=t.concat(s)}return t}(e);const s=t%4;if(0===s);else if(1===s)r=r.slice(2);else{if(2!==s)throw new Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);r=r.slice(4)}const i=(t+e.length-1)%4;if(3===i);else if(2===i)r=r.slice(0,r.length-2);else{if(1!==i)throw new Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);r=r.slice(0,r.length-4)}if(r.length%8!=0)throw new Error("We should never reach here...");const n=new Uint8Array(Math.floor(r.length/8));let a=0;for(let e=0;e<r.length;e+=8){const t=r.slice(e,e+8),s=parseInt(t.join(""),2);n[a++]=s}return(new TextDecoder).decode(n)}(e.value,e.indexMod4),[s,i]=function(e){if("}"!==e.slice(-1)&&","!==e.slice(-1))throw new Error("Invalid claim");const t=JSON.parse("{"+e.slice(0,-1)+"}");if(1!==Object.keys(t).length)throw new Error("Invalid claim");const r=Object.keys(t)[0];return[r,t[r]]}(r);if(s!==t)throw new Error(`Invalid field name: found ${s} expected ${t}`);return i}const yn=ht.struct("ZkLoginSignature",{inputs:ht.struct("ZkLoginSignatureInputs",{proofPoints:ht.struct("ZkLoginSignatureInputsProofPoints",{a:ht.vector(ht.string()),b:ht.vector(ht.vector(ht.string())),c:ht.vector(ht.string())}),issBase64Details:ht.struct("ZkLoginSignatureInputsClaim",{value:ht.string(),indexMod4:ht.u8()}),headerBase64:ht.string(),addressSeed:ht.string()}),maxEpoch:ht.u64(),userSignature:ht.vector(ht.u8())});var fn,vn,Tn=e=>{throw TypeError(e)},En=(e,t,r)=>t.has(e)||Tn("Cannot "+r),wn=(e,t,r)=>(En(e,t,"read from private field"),r?r.call(e):t.get(e)),xn=(e,t,r)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),On=(e,t,r,s)=>(En(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);fn=new WeakMap,vn=new WeakMap;let In=class e extends di{constructor(e,{client:r}={}){super(),xn(this,fn),xn(this,vn),On(this,vn,r),"string"==typeof e?On(this,fn,t(e)):e instanceof Uint8Array?On(this,fn,e):On(this,fn,Uint8Array.from(e))}equals(e){return super.equals(e)}toRawBytes(){return wn(this,fn)}flag(){return ii.ZkLogin}async verify(e,t){throw Error("does not support")}verifyPersonalMessage(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"PERSONAL_MESSAGE",client:wn(this,vn)})}verifyTransaction(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"TRANSACTION_DATA",client:wn(this,vn)})}};const Cn=_n("\n\tquery Zklogin(\n\t\t$bytes: Base64!\n\t\t$signature: Base64!\n\t\t$intentScope: ZkLoginIntentScope!\n\t\t$author: SuiAddress!\n\t) {\n\t\tverifyZkloginSignature(\n\t\t\tbytes: $bytes\n\t\t\tsignature: $signature\n\t\t\tintentScope: $intentScope\n\t\t\tauthor: $author\n\t\t) {\n\t\t\tsuccess\n\t\t\terrors\n\t\t}\n\t}\n");async function Bn({address:e,bytes:t,signature:r,intentScope:s,client:i=new Ji({url:"https://sui-mainnet.mystenlabs.com/graphql"})}){const n=await i.query({query:Cn,variables:{bytes:t,signature:r,intentScope:s,author:e}});return!0===n.data?.verifyZkloginSignature.success&&0===n.data?.verifyZkloginSignature.errors.length}function Sn(e){const r="string"==typeof e?t(e):e;if(r[0]!==ii.ZkLogin)throw new Error("Invalid signature scheme");const i=r.slice(1),{inputs:n,maxEpoch:a,userSignature:o}=function(e){return yn.parse("string"==typeof e?t(e):e)}(i),{issBase64Details:d,addressSeed:c}=n,u=gn(d,"iss"),h=function(e,t){const r=(n=32,function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=Pr(e.charCodeAt(i)),n=Pr(e.charCodeAt(i+1));if(void 0===r||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}s[t]=16*r+n}return s}(e.toString(16).padStart(2*n,"0").slice(2*-n))),s=(new TextEncoder).encode(t),i=new Uint8Array(1+s.length+r.length);var n;return i.set([s.length],0),i.set(s,1),i.set(r,1+s.length),new In(i,void 0)}(BigInt(c),u);return{serializedSignature:s(r),signatureScheme:"ZkLogin",zkLogin:{inputs:n,maxEpoch:a,userSignature:o,iss:u,addressSeed:BigInt(c)},signature:r,publicKey:h.toRawBytes()}}const Pn=32,jn="suiprivkey";class An{async signWithIntent(e,t){const r=si(t,e),i=$r(r,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const i=r.toRawBytes(),n=new Uint8Array(1+e.length+i.length);return n.set([ii[t]]),n.set(e,1),n.set(i,1+e.length),s(n)}({signature:await this.sign(i),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:s(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(ht.vector(ht.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:s(e),signature:t}}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class kn extends An{}function Un(e){const{prefix:t,words:r}=ri.I.decode(e);if(t!==jn)throw new Error("invalid private key prefix");const s=new Uint8Array(ri.I.fromWords(r)),i=s.slice(1);return{schema:ai[s[0]],secretKey:i}}function Nn(e,t){if(e.length!==Pn)throw new Error("Invalid bytes length");const r=ii[t],s=new Uint8Array(e.length+1);return s.set([r]),s.set(e,1),ri.I.encode(jn,ri.I.toWords(s))}class Dn extends Ar{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,vr(e);const r=jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tr(this),this.iHash.update(e),this}digestInto(e){Tr(this),fr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:n,outputLen:a}=this;return e.finished=s,e.destroyed=i,e.blockLen=n,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Rn=(e,t,r)=>new Dn(e,t).update(r).digest();Rn.create=(e,t)=>new Dn(e,t);class Yn extends Ar{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=xr(this.buffer)}update(e){Tr(this);const{view:t,buffer:r,blockLen:s}=this,i=(e=jr(e)).length;for(let n=0;n<i;){const a=Math.min(s-this.pos,i-n);if(a!==s)r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(t,0),this.pos=0);else{const t=xr(e);for(;s<=i-n;n+=s)this.process(t,n)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tr(this),Er(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let e=n;e<s;e++)t[e]=0;!function(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),a=Number(r>>i&n),o=Number(r&n),d=s?4:0,c=s?0:4;e.setUint32(t+d,a,s),e.setUint32(t+c,o,s)}(r,s-8,BigInt(8*this.length),i),this.process(r,0);const a=xr(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=o/4,c=this.get();if(d>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)a.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:n,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=n,s%t&&e.buffer.set(r),e}}const[Vn,Jn]=(()=>Mr.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Mn=new Uint32Array(80),Fn=new Uint32Array(80);class Xn extends Yn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:n,Dh:a,Dl:o,Eh:d,El:c,Fh:u,Fl:h,Gh:p,Gl:l,Hh:m,Hl:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|s,this.Ch=0|i,this.Cl=0|n,this.Dh=0|a,this.Dl=0|o,this.Eh=0|d,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|p,this.Gl=0|l,this.Hh=0|m,this.Hl=0|_}process(e,t){for(let r=0;r<16;r++,t+=4)Mn[r]=e.getUint32(t),Fn[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Mn[e-15],r=0|Fn[e-15],s=Mr.rotrSH(t,r,1)^Mr.rotrSH(t,r,8)^Mr.shrSH(t,r,7),i=Mr.rotrSL(t,r,1)^Mr.rotrSL(t,r,8)^Mr.shrSL(t,r,7),n=0|Mn[e-2],a=0|Fn[e-2],o=Mr.rotrSH(n,a,19)^Mr.rotrBH(n,a,61)^Mr.shrSH(n,a,6),d=Mr.rotrSL(n,a,19)^Mr.rotrBL(n,a,61)^Mr.shrSL(n,a,6),c=Mr.add4L(i,d,Fn[e-7],Fn[e-16]),u=Mr.add4H(c,s,o,Mn[e-7],Mn[e-16]);Mn[e]=0|u,Fn[e]=0|c}let{Ah:r,Al:s,Bh:i,Bl:n,Ch:a,Cl:o,Dh:d,Dl:c,Eh:u,El:h,Fh:p,Fl:l,Gh:m,Gl:_,Hh:b,Hl:g}=this;for(let e=0;e<80;e++){const t=Mr.rotrSH(u,h,14)^Mr.rotrSH(u,h,18)^Mr.rotrBH(u,h,41),y=Mr.rotrSL(u,h,14)^Mr.rotrSL(u,h,18)^Mr.rotrBL(u,h,41),f=u&p^~u&m,v=h&l^~h&_,T=Mr.add5L(g,y,v,Jn[e],Fn[e]),E=Mr.add5H(T,b,t,f,Vn[e],Mn[e]),w=0|T,x=Mr.rotrSH(r,s,28)^Mr.rotrBH(r,s,34)^Mr.rotrBH(r,s,39),O=Mr.rotrSL(r,s,28)^Mr.rotrBL(r,s,34)^Mr.rotrBL(r,s,39),I=r&i^r&a^i&a,C=s&n^s&o^n&o;b=0|m,g=0|_,m=0|p,_=0|l,p=0|u,l=0|h,({h:u,l:h}=Mr.add(0|d,0|c,0|E,0|w)),d=0|a,c=0|o,a=0|i,o=0|n,i=0|r,n=0|s;const B=Mr.add3L(w,O,C);r=Mr.add3H(B,E,x,I),s=0|B}({h:r,l:s}=Mr.add(0|this.Ah,0|this.Al,0|r,0|s)),({h:i,l:n}=Mr.add(0|this.Bh,0|this.Bl,0|i,0|n)),({h:a,l:o}=Mr.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:d,l:c}=Mr.add(0|this.Dh,0|this.Dl,0|d,0|c)),({h:u,l:h}=Mr.add(0|this.Eh,0|this.El,0|u,0|h)),({h:p,l}=Mr.add(0|this.Fh,0|this.Fl,0|p,0|l)),({h:m,l:_}=Mr.add(0|this.Gh,0|this.Gl,0|m,0|_)),({h:b,l:g}=Mr.add(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,s,i,n,a,o,d,c,u,h,p,l,m,_,b,g)}roundClean(){Mn.fill(0),Fn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ln=kr((()=>new Xn));function qn(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function Gn(e,t=""){return function(e,t,r){const{c:s,dkLen:i,DK:n,PRF:a,PRFSalt:o}=function(e,t,r,s){vr(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},t)}(0,s),{c:n,dkLen:a,asyncTick:o}=i;if(yr(n),yr(a),yr(o),n<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const d=jr(t),c=jr(r),u=new Uint8Array(a),h=Rn.create(e,d),p=h._cloneInto().update(c);return{c:n,dkLen:a,asyncTick:o,DK:u,PRF:h,PRFSalt:p}}(e,t,r,{c:2048,dkLen:64});let d;const c=new Uint8Array(4),u=xr(c),h=new Uint8Array(a.outputLen);for(let e=1,t=0;t<i;e++,t+=a.outputLen){const r=n.subarray(t,t+a.outputLen);u.setInt32(0,e,!1),(d=o._cloneInto(d)).update(c).digestInto(h),r.set(h.subarray(0,r.length));for(let e=1;e<s;e++){a._cloneInto(d).update(h).digestInto(h);for(let e=0;e<r.length;e++)r[e]^=h[e]}}return function(e,t,r,s,i){return e.destroy(),t.destroy(),s&&s.destroy(),i.fill(0),r}(a,o,n,d,h)}(Ln,function(e){const t=qn(e),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}(e).nfkd,(e=>qn("mnemonic"+e))(t))}function $n(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}const zn=new RegExp("^m(\\/[0-9]+')+$"),Wn=e=>e.replace("'",""),Hn=(e,t,r=2147483648)=>{if(!(e=>!!zn.test(e)&&!e.split("/").slice(1).map(Wn).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:s,chainCode:i}=(e=>{const t=Rn.create(Ln,"ed25519 seed").update(c(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Wn).map((e=>parseInt(e,10))).reduce(((e,t)=>(({key:e,chainCode:t},r)=>{const s=new ArrayBuffer(4);new DataView(s).setUint32(0,r);const i=new Uint8Array(1+e.length+s.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(s,0,s.byteLength),e.length+1);const n=Rn.create(Ln,t).update(i).digest();return{key:n.slice(0,32),chainCode:n.slice(32)}})(e,t+r)),{key:s,chainCode:i})};class Kn extends di{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return ii.ED25519}async verify(e,r){let s;if("string"==typeof r){const e=function(e){const r=t(e),s=ai[r[0]];switch(s){case"MultiSig":return{serializedSignature:e,signatureScheme:s,multisig:or.MultiSig.parse(r.slice(1)),bytes:r};case"ZkLogin":return Sn(e);case"ED25519":case"Secp256k1":case"Secp256r1":const t=ni[s],i=r.slice(1,r.length-t);return{serializedSignature:e,signatureScheme:s,signature:i,publicKey:r.slice(1+i.length),bytes:r};default:throw new Error("Unsupported signature scheme")}}(r);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!oi(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");s=e.signature}else s=r;return ti.sign.detached.verify(e,s,this.toRawBytes())}}Kn.SIZE=32;const Qn="m/44'/784'/0'/0'/0'";class Zn extends kn{constructor(e){super(),this.keypair=e||ti.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Zn(ti.sign.keyPair())}static fromSecretKey(e,t){const r=e.length;if(r!==Pn)throw new Error(`Wrong secretKey size. Expected ${Pn} bytes, got ${r}.`);const s=ti.sign.keyPair.fromSeed(e);if(!t||!t.skipValidation){const e=(new TextEncoder).encode("sui validation"),t=ti.sign.detached(e,s.secretKey);if(!ti.sign.detached.verify(e,t,s.publicKey))throw new Error("provided secretKey is invalid")}return new Zn(s)}getPublicKey(){return new Kn(this.keypair.publicKey)}getSecretKey(){return Nn(this.keypair.secretKey.slice(0,Pn),this.getKeyScheme())}async sign(e){return ti.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Qn),!$n(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,function(e){return u(function(e){return Gn(e,"")}(e))}(e));return Zn.fromSecretKey(r)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Qn),!$n(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,e);return Zn.fromSecretKey(r)}}function ea(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function ta(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}var ra=a(725);const sa=e=>ra.encode(e),ia=e=>ra.decode(e);function na(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const aa=8192;function oa(e){if(e.length<aa)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=aa){const s=e.slice(r,r+aa);t+=String.fromCharCode(...s)}return btoa(t)}class da{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class ca{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ua(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return ua(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return ua(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return sa(e);case"base64":return oa(e);case"hex":return ta(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function ua(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var ha,pa,la,ma,_a=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},ba=(e,t,r)=>(_a(e,t,"read from private field"),r?r.call(e):t.get(e)),ga=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},ya=(e,t,r,s)=>(_a(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const fa=class{constructor(e){ga(this,ha,void 0),ga(this,pa,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),ya(this,ha,e.write),ya(this,pa,e.serialize??((e,t)=>{const r=new ca({size:this.serializedSize(e)??void 0,...t});return ba(this,ha).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),ba(this,ha).call(this,e,t)}serialize(e,t){return this.validate(e),new Ea(this,ba(this,pa).call(this,e,t))}parse(e){const t=new da(e);return this.read(t)}transform({name:e,input:t,output:r}){return new fa({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>ba(this,ha).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>ba(this,pa).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let va=fa;ha=new WeakMap,pa=new WeakMap;const Ta=Symbol.for("@mysten/serialized-bcs");class Ea{constructor(e,t){ga(this,la,void 0),ga(this,ma,void 0),ya(this,la,e),ya(this,ma,t)}get[Ta](){return!0}toBytes(){return ba(this,ma)}toHex(){return ta(ba(this,ma))}toBase64(){return oa(ba(this,ma))}toBase58(){return sa(ba(this,ma))}parse(){return ba(this,la).parse(ba(this,ma))}}la=new WeakMap,ma=new WeakMap;const wa=32,xa=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof xa)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(xa.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Oa.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Oa.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Oa.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Oa.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Oa.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Oa.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Oa.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Oa.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Oa.HEX,(function(e,t){return e.writeVec(Array.from(ea(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return ta(new Uint8Array(t))})),t.registerType(Oa.BASE58,(function(e,t){return e.writeVec(Array.from(ia(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return sa(new Uint8Array(t))})),t.registerType(Oa.BASE64,(function(e,t){return e.writeVec(Array.from(na(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return oa(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new xa(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return ia(e);case"base64":return na(e);case"hex":return ea(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new xa(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new ca(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new da(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new va({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new va({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return na(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return oa(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return ea(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return ta(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],p,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,p,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let p=n.indexOf(h),l=-1===p?h:a[p];{let{name:r,params:s}=this.parseTypeName(l);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Oa=xa;function Ia(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:wa,addressEncoding:"hex"}}var Ca;Oa.U8="u8",Oa.U16="u16",Oa.U32="u32",Oa.U64="u64",Oa.U128="u128",Oa.U256="u256",Oa.BOOL="bool",Oa.VECTOR="vector",Oa.ADDRESS="address",Oa.STRING="string",Oa.HEX="hex-string",Oa.BASE58="base58-string",Oa.BASE64="base64-string",function(e){e.IsValidDesription="invalid description",e.IsValidName="invalid name",e.IsValidName_AllowEmpty="invalid name",e.IsValidEndpoint="invalid endpoint",e.IsValidAddress="invalid address",e.IsValidArgType="invalid argument type",e.IsValidTokenType="invalid token type",e.IsValidUint="invalid uint",e.IsValidInt="invalid int",e.IsValidU64="invalid u64",e.IsValidU8="invalid u8",e.IsValidPercent="invalid percent",e.IsValidArray="invalid array",e.IsValidObjects="invalid objects",e.AllInvalid="one valid at least",e.InvalidParam="invalid parameter",e.IsValidPermissionIndex="invalid permission index",e.IsValidKey="invalid key",e.Fail="fail",e.IsValidIndentifier="indentifier invalid",e.isValidHttpUrl="invalid url",e.IsValidBizPermissionIndex="invalid biz-permission index",e.bcsTypeInvalid="invalid bcs type",e.IsValidServiceItemName="invalid service item name",e.IsValidCoinType="not the coin type",e.IsValidGuardIdentifier="guard identifier invalid",e.noPermission="no permission"}(Ca||(Ca={}));const Ba=(e,t)=>{throw e.toString()+(t?" "+t:"")},Sa=BigInt("255"),Pa=BigInt("18446744073709551615"),ja=BigInt("340282366920938463463374607431768211455"),Aa=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),ka=0,Ua=e=>e===No.TYPE_U8||e===No.TYPE_U64||e===No.TYPE_U128||e===No.TYPE_U256?Do.PositiveNumber:e===No.TYPE_VEC_U8||e===No.TYPE_VEC_U64||e===No.TYPE_VEC_U128||e===No.TYPE_VEC_U256||e===No.TYPE_VEC_BOOL?Do.PositiveNumber_Vec:e===No.TYPE_ADDRESS?Do.Address:e===No.TYPE_VEC_ADDRESS?Do.Address_Vec:e===No.TYPE_STRING?Do.String:e===No.TYPE_VEC_STRING?Do.String_Vec:e===No.TYPE_BOOL?Do.Bool:-1,Na=(e,t)=>{let r=e.splice(0,1);return 1==r[0]?{bNone:!1,value:Wa.getInstance().de(t,Uint8Array.from(e))}:(0==r[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka})},Da=e=>{let t=e.splice(0,1);if(1==t[0]){let t=Ra(Uint8Array.from(e)),r=Wa.getInstance().de(No.TYPE_STRING,Uint8Array.from(e));return e.splice(0,t.value+t.length),{bNone:!1,value:r}}return 0==t[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka}},Ra=e=>{let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}},Ya=(e,t)=>{let r=Ra(Uint8Array.from(e));e.splice(0,r.length);let s=[];for(let i=0;i<r.value;i++)s.push(t(e,i,r.value));return s},Va=(e,t,r)=>e.shift(),Ja=(e,t,r)=>e.splice(0,8),Ma=(e,t,r)=>e.splice(0,16),Fa=(e,t,r)=>e.splice(0,32),Xa=(e,...t)=>{let r=0;for(const e of t)r+=e.length;const s=new e(r);let i=0;for(const e of t)s.set(e,i),i+=e.length;return s},La=(e,t="payment::Payment<")=>{if(e){const r=e.indexOf(t);if(r>0)return e.slice(r+t.length,e.length-1)}return""},qa=(e,t)=>e.length===t.length&&!e.some((e=>!t.includes(e))),Ga=e=>{for(var t=[],r=0;r<e.length;r++)-1==t.indexOf(e[r])&&t.push(e[r]);return t};function $a(e){return e&&e[0].toUpperCase()+e.slice(1)}function za(e){var t=[];let r=e.indexOf("<");return r>=0&&(t=e.slice(r+1,e.length-1).split(",")),t}class Wa{bcs=new Oa(Ia());static _instance;constructor(){this.bcs.registerEnumType("Option<T>",{none:null,some:"T"}),this.bcs.registerStructType("EntStruct",{avatar:"vector<u8>",resource:"Option<address>",safer_name:"vector<string>",safer_value:"vector<string>",like:Oa.U32,dislike:Oa.U32}),this.bcs.registerStructType("TagStruct",{nick:"string",tags:"vector<string>"}),this.bcs.registerStructType("PersonalInfo",{name:"vector<u8>",description:"vector<u8>",avatar:Oa.STRING,twitter:Oa.STRING,discord:Oa.STRING,homepage:Oa.STRING}),this.bcs.registerStructType("OptionAddress",{address:"Option<address>"}),this.bcs.registerStructType("Guards",{guards:"vector<OptionAddress>"}),this.bcs.registerStructType("Perm",{index:Oa.U64,guard:"Option<address>"}),this.bcs.registerStructType("Perms",{perms:"vector<Perm>"})}static getInstance(){return Wa._instance||(Wa._instance=new Wa),Wa._instance}ser_option_u32(e){return this.bcs.ser("Option<u32>",{some:e}).toBytes()}ser(e,t){if("string"==typeof e)return this.bcs.ser(e,t).toBytes();switch(e){case No.TYPE_BOOL:return this.bcs.ser(Oa.BOOL,t).toBytes();case No.TYPE_ADDRESS:return this.bcs.ser(Oa.ADDRESS,t).toBytes();case No.TYPE_U64:return this.bcs.ser(Oa.U64,t).toBytes();case No.TYPE_U8:return this.bcs.ser(Oa.U8,t).toBytes();case No.TYPE_VEC_U8:return this.bcs.ser("vector<u8>",t).toBytes();case No.TYPE_U128:return this.bcs.ser(Oa.U128,t).toBytes();case No.TYPE_VEC_ADDRESS:return this.bcs.ser("vector<address>",t).toBytes();case No.TYPE_VEC_BOOL:return this.bcs.ser("vector<bool>",t).toBytes();case No.TYPE_VEC_VEC_U8:return this.bcs.ser("vector<vector<u8>>",t).toBytes();case No.TYPE_VEC_U64:return this.bcs.ser("vector<u64>",t).toBytes();case No.TYPE_VEC_U128:return this.bcs.ser("vector<u128>",t).toBytes();case No.TYPE_OPTION_ADDRESS:return this.bcs.ser("Option<address>",{some:t}).toBytes();case No.TYPE_OPTION_BOOL:return this.bcs.ser("Option<bool>",{some:t}).toBytes();case No.TYPE_OPTION_U8:return this.bcs.ser("Option<u8>",{some:t}).toBytes();case No.TYPE_OPTION_U64:return this.bcs.ser("Option<u64>",{some:t}).toBytes();case No.TYPE_OPTION_U128:return this.bcs.ser("Option<u128>",{some:t}).toBytes();case No.TYPE_OPTION_U256:return this.bcs.ser("Option<u256>",{some:t}).toBytes();case No.TYPE_OPTION_STRING:return this.bcs.ser("Option<string>",{some:t}).toBytes();case No.TYPE_VEC_U256:return this.bcs.ser("vector<u256>",t).toBytes();case No.TYPE_U256:return this.bcs.ser(Oa.U256,t).toBytes();case No.TYPE_STRING:const e=(new TextEncoder).encode(t);return this.bcs.ser("vector<u8>",e).toBytes();case No.TYPE_VEC_STRING:return this.bcs.ser("vector<vector<u8>>",t.map((e=>(new TextEncoder).encode(e)))).toBytes();default:Ba(Ca.bcsTypeInvalid,"ser")}return new Uint8Array}de(e,t){if("string"==typeof e)return this.bcs.de(e,t);switch(e){case No.TYPE_BOOL:return this.bcs.de(Oa.BOOL,t);case No.TYPE_ADDRESS:return this.bcs.de(Oa.ADDRESS,t);case No.TYPE_U64:return this.bcs.de(Oa.U64,t);case No.TYPE_U8:return this.bcs.de(Oa.U8,t);case No.TYPE_VEC_U8:return this.bcs.de("vector<u8>",t);case No.TYPE_U128:return this.bcs.de(Oa.U128,t);case No.TYPE_VEC_ADDRESS:return this.bcs.de("vector<address>",t);case No.TYPE_VEC_BOOL:return this.bcs.de("vector<bool>",t);case No.TYPE_VEC_VEC_U8:return this.bcs.de("vector<vector<u8>>",t);case No.TYPE_VEC_U64:return this.bcs.de("vector<u64>",t);case No.TYPE_VEC_U128:return this.bcs.de("vector<u128>",t);case No.TYPE_OPTION_ADDRESS:return this.bcs.de("Option<address>",t);case No.TYPE_OPTION_BOOL:return this.bcs.de("Option<bool>",t);case No.TYPE_OPTION_U8:return this.bcs.de("Option<u8>",t);case No.TYPE_OPTION_U64:return this.bcs.de("Option<u64>",t);case No.TYPE_OPTION_U128:return this.bcs.de("Option<u128>",t);case No.TYPE_OPTION_U256:return this.bcs.de("Option<u256>",t);case No.TYPE_OPTION_STRING:return this.bcs.de("Option<string>",t);case No.TYPE_VEC_U256:return this.bcs.de("vector<u256>",t);case No.TYPE_STRING:return(new TextDecoder).decode(Uint8Array.from(this.bcs.de("vector<u8>",t)));case No.TYPE_VEC_STRING:return this.bcs.de("vector<string>",t);case No.TYPE_U256:return this.bcs.de(Oa.U256,t);default:Ba(Ca.bcsTypeInvalid,"de")}}de_ent(e){if(!e||e.length<2)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("EntStruct",Uint8Array.from(t))}de_entInfo(e){if(!e||0===e.length)return;let t=this.bcs.de("PersonalInfo",e);return t.name=(new TextDecoder).decode(Uint8Array.from(t.name)),t.description=(new TextDecoder).decode(Uint8Array.from(t.description)),t}de_tags(e){if(!e||0===e.length)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("TagStruct",Uint8Array.from(t))}de_perms(e){return!e||e.length<1?"":this.bcs.de("Perms",e).perms.map((e=>({index:e?.index,guard:e?.guard?.none?void 0:"0x"+e?.guard?.some})))}}function Ha(e){const t=(new TextEncoder).encode(e);return new Uint8Array(t.buffer)}function Ka(e){if(!e)return new Uint8Array(0);const t=[];for(t.unshift(255&e);e>=256;)e>>>=8,t.unshift(255&e);return new Uint8Array(t)}const Qa=e=>"[object Array]"==Object.prototype.toString.call(e),Za=(e,t)=>{let r=t||{};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("object"==typeof e[t]&&null!==e[t]?(r[t]=Qa(e[t])?[]:{},Za(e[t],r[t])):r[t]=e[t]);return r},eo=4e3,to=64,ro=1024,so=(e,t)=>Wa.getInstance().ser(No.TYPE_STRING,e).length<=t,io=e=>so(e,eo),no=e=>!(!e||0===e.length)&&so(e,to),ao=e=>so(e,to),oo=e=>e.length>0&&e.length<=ro&&Bo(e),co=e=>!(!e||!ae(e)),uo=e=>!!e&&(e.startsWith("0x2::coin::Coin")||e.startsWith("0x0000000000000000000000000000000000000000000000000000000000000002")),ho=(e=864e5)=>{const t=Date.now();return Math.floor(t/e)*e},po=(e,t=Aa,r)=>{if(""===e||void 0===e)return!1;try{const s=BigInt(e);if(s<=t)return void 0===r||s>=r}catch(e){}return!1},lo=(e,t=0)=>po(e,Sa,BigInt(t)),mo=(e,t=0)=>po(e,Pa,BigInt(t)),_o=(e,t=0)=>po(e,ja,BigInt(t)),bo=(e,t=0)=>po(e,Aa,BigInt(t)),go=e=>{if(!e||0===e.length)return!1;let t=e.split("::");return 3===t.length&&!(!co(t[0])&&"0x2"!=t[0]||0===t[1].length||0===t[2].length)},yo=e=>!(!e||0===e.length)&&!(e.split("::").length<3),fo=e=>("string"==typeof e&&(e=parseInt(e)),Number.isSafeInteger(e)),vo=e=>po(e,BigInt(100),BigInt(0)),To=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r]))return!1;return!0},Eo=e=>e>Pa?Pa:e;function wo(e){const t=e.trim();if(-1!==t.indexOf(".")){let e=t.length-1;for(;"0"===t[e];)e--;return"."===t[e]&&e--,t.slice(0,e+1)}return t}const xo=(e,t)=>{if(!e)return"";if("0"===e)return"0";if(t<=0)return e;var r=t-e.length;return wo(0===r?"."+e:r<0?e.slice(0,Math.abs(r))+"."+e.slice(Math.abs(r)):"."+e.padStart(t,"0"))},Oo=e=>{if(e){const t="0x2::coin::Coin<";let r=e.indexOf(t);if(r>=0){let s=e.slice(r+t.length,e.length-1);if(-1===s.indexOf("<")){for(;">"==s[s.length-1];)s=s.slice(0,-1);let e=s.lastIndexOf("::");return{isCoin:!0,coin:s,token:s.slice(e+2)}}}}return{isCoin:!1,coin:"",token:""}};function Io(e,t){const r=e.length+1,s=new Uint8Array(r);return s.set([t],0),s.set(e,1),s}function Co(e){let t="";var r;return Math.abs(e)<1?(r=parseInt(e.toString().split("e-")[1]))&&(e*=Math.pow(10,r-1),t="0."+new Array(r).join("0")+e.toString().substring(2)):(r=parseInt(e.toString().split("+")[1]))>20&&(r-=20,t=(e/=Math.pow(10,r))+new Array(r+1).join("0")),t}function Bo(e){let t;try{t=new URL(e)}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol||"ipfs:"===t.protocol}const So=e=>{e.id&&(e?.onBegin&&e.onBegin(e.id),$o.Client().getObject({id:e.id,options:{showContent:!0,showType:!0,showOwner:!0}}).then((t=>{t.error?e?.onObjectErr&&e.onObjectErr(e.id,t.error):e?.onObjectRes&&e.onObjectRes(e.id,t)})).catch((t=>{console.log(t),e?.onObjectErr&&e.onObjectErr(e.id,t)})),$o.Client().getDynamicFields({parentId:e.id}).then((t=>{e?.onDynamicRes&&e.onDynamicRes(e.id,t),t.data.length>0&&$o.Client().multiGetObjects({ids:t.data.map((e=>e.objectId)),options:{showContent:!0}}).then((t=>{e?.onFieldsRes&&e.onFieldsRes(e.id,t)})).catch((t=>{console.log(t),e?.onFieldsErr&&e.onFieldsErr(e.id,t)}))})).catch((t=>{console.log(t),e?.onDynamicErr&&e.onDynamicErr(e.id,t)})))},Po=e=>e?e.substring(0,1).toUpperCase()+e.substring(1):"";function jo(e){return e.some(((t,r)=>e.findIndex((e=>e===t))!==r))}var Ao,ko;!function(e){e.machine="machine",e.progress="progress",e.repository="repository",e.permission="permission",e.passport="passport",e.guard="guard",e.demand="demand",e.order="order",e.service="service",e.resource="resource",e.entity="entity",e.wowok="wowok",e.treasury="treasury",e.payment="payment",e.arbitration="arbitration",e.arb="arb"}(Ao||(Ao={})),function(e){e[e.TYPE_QUERY=1]="TYPE_QUERY",e[e.TYPE_NUMBER_ADD=2]="TYPE_NUMBER_ADD",e[e.TYPE_NUMBER_SUBTRACT=3]="TYPE_NUMBER_SUBTRACT",e[e.TYPE_NUMBER_MULTIPLY=4]="TYPE_NUMBER_MULTIPLY",e[e.TYPE_NUMBER_DEVIDE=5]="TYPE_NUMBER_DEVIDE",e[e.TYPE_NUMBER_MOD=6]="TYPE_NUMBER_MOD",e[e.TYPE_NUMBER_ADDRESS=7]="TYPE_NUMBER_ADDRESS",e[e.TYPE_LOGIC_AS_U256_GREATER=11]="TYPE_LOGIC_AS_U256_GREATER",e[e.TYPE_LOGIC_AS_U256_GREATER_EQUAL=12]="TYPE_LOGIC_AS_U256_GREATER_EQUAL",e[e.TYPE_LOGIC_AS_U256_LESSER=13]="TYPE_LOGIC_AS_U256_LESSER",e[e.TYPE_LOGIC_AS_U256_LESSER_EQUAL=14]="TYPE_LOGIC_AS_U256_LESSER_EQUAL",e[e.TYPE_LOGIC_AS_U256_EQUAL=15]="TYPE_LOGIC_AS_U256_EQUAL",e[e.TYPE_LOGIC_EQUAL=16]="TYPE_LOGIC_EQUAL",e[e.TYPE_LOGIC_HAS_SUBSTRING=17]="TYPE_LOGIC_HAS_SUBSTRING",e[e.TYPE_LOGIC_NOT=18]="TYPE_LOGIC_NOT",e[e.TYPE_LOGIC_AND=19]="TYPE_LOGIC_AND",e[e.TYPE_LOGIC_OR=20]="TYPE_LOGIC_OR"}(ko||(ko={}));const Uo=[[ko.TYPE_LOGIC_AS_U256_GREATER,"Unsigned Integer >","The first item > anything that follows"],[ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL,"Unsigned Integer >=","The first item >= anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER,"Unsigned Integer <","The first item < anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL,"Unsigned Integer <=","The first item <= anything that follows"],[ko.TYPE_LOGIC_AS_U256_EQUAL,"Unsigned Integer =","The first item = anything that follows"],[ko.TYPE_LOGIC_EQUAL,"Equal","Data and type are exactly equal for all items"],[ko.TYPE_LOGIC_HAS_SUBSTRING,"Has Sub String","The first string contains anything that follows"],[ko.TYPE_LOGIC_NOT,"Not","Not operation"],[ko.TYPE_LOGIC_AND,"And","All Items And operations"],[ko.TYPE_LOGIC_OR,"Or","All Items Or operations"]];var No,Do;!function(e){e[e.TYPE_BOOL=100]="TYPE_BOOL",e[e.TYPE_ADDRESS=101]="TYPE_ADDRESS",e[e.TYPE_U8=102]="TYPE_U8",e[e.TYPE_U64=103]="TYPE_U64",e[e.TYPE_VEC_U8=104]="TYPE_VEC_U8",e[e.TYPE_U128=105]="TYPE_U128",e[e.TYPE_VEC_ADDRESS=106]="TYPE_VEC_ADDRESS",e[e.TYPE_VEC_BOOL=107]="TYPE_VEC_BOOL",e[e.TYPE_VEC_VEC_U8=108]="TYPE_VEC_VEC_U8",e[e.TYPE_VEC_U64=109]="TYPE_VEC_U64",e[e.TYPE_VEC_U128=110]="TYPE_VEC_U128",e[e.TYPE_OPTION_ADDRESS=111]="TYPE_OPTION_ADDRESS",e[e.TYPE_OPTION_BOOL=112]="TYPE_OPTION_BOOL",e[e.TYPE_OPTION_U8=113]="TYPE_OPTION_U8",e[e.TYPE_OPTION_U64=114]="TYPE_OPTION_U64",e[e.TYPE_OPTION_U128=115]="TYPE_OPTION_U128",e[e.TYPE_OPTION_U256=116]="TYPE_OPTION_U256",e[e.TYPE_OPTION_STRING=117]="TYPE_OPTION_STRING",e[e.TYPE_OPTION_VEC_U8=118]="TYPE_OPTION_VEC_U8",e[e.TYPE_VEC_U256=119]="TYPE_VEC_U256",e[e.TYPE_STRING=120]="TYPE_STRING",e[e.TYPE_VEC_STRING=121]="TYPE_VEC_STRING",e[e.TYPE_U256=122]="TYPE_U256"}(No||(No={})),function(e){e[e.Address=200]="Address",e[e.Address_Vec=201]="Address_Vec",e[e.PositiveNumber=202]="PositiveNumber",e[e.PositiveNumber_Vec=203]="PositiveNumber_Vec",e[e.String=204]="String",e[e.String_Vec=205]="String_Vec",e[e.Bool=206]="Bool"}(Do||(Do={}));const Ro=[{type:Do.String,name:"string",description:"String."},{type:Do.Address,name:"address",description:"Object id or Personal address."},{type:Do.PositiveNumber,name:"unsigned integer",description:"Including u8, u16 ,..., u256"},{type:Do.String_Vec,name:"string vector",description:"Vector of string."},{type:Do.Address_Vec,name:"address vector",description:"Vector of address."},{type:Do.PositiveNumber_Vec,name:"unsigned integer vector",description:"Vector of unsigned integer"},{type:Do.Bool,name:"bool",description:"True or False."}],Yo=Object.values(ko).filter((e=>"number"==typeof e)),Vo=Object.values(No).filter((e=>"number"==typeof e)),Jo=e=>Yo.includes(e),Mo=e=>Vo.includes(e),Fo=e=>e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U64||e===No.TYPE_U8;var Xo;!function(e){e[e.TYPE_SIGNER=60]="TYPE_SIGNER",e[e.TYPE_CLOCK=61]="TYPE_CLOCK",e[e.TYPE_GUARD=62]="TYPE_GUARD",e[e.TYPE_CONSTANT=80]="TYPE_CONSTANT"}(Xo||(Xo={}));const Lo=[{type:No.TYPE_BOOL,name:"bool",description:"boolean. eg:true or false",validator:e=>!0===e||!1===e},{type:No.TYPE_ADDRESS,name:"address",description:"address or object-id. eg:0x6789af",validator:co},{type:Xo.TYPE_SIGNER,name:"txn signer",description:"signer address of the transaction"},{type:Xo.TYPE_GUARD,name:"guard address",description:"current guard address"},{type:Xo.TYPE_CLOCK,name:"txn time",description:"unsigned-64 number for the transaction time"},{type:No.TYPE_U64,name:"number",description:"unsigned-64 number. eg:23870233",validator:mo},{type:No.TYPE_U8,name:"number",description:"unsigned-8 number. eg:255",validator:lo},{type:No.TYPE_VEC_U8,name:"string",description:'string or unsigned-8 number array. eg:"[1,2,3]"'},{type:No.TYPE_U128,name:"number",description:"unsigned-8 number. eg:12348900999",validator:_o},{type:No.TYPE_VEC_ADDRESS,name:"[address]",description:"address array. eg:[0x2277f2, 0x3344af]"},{type:No.TYPE_VEC_BOOL,name:"[bool]",description:"boolean array. eg:[true, false, true]"},{type:No.TYPE_VEC_VEC_U8,name:"[[number]]",description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},{type:No.TYPE_VEC_U64,name:"[number]",description:"unsigned-64 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_U128,name:"[number]",description:"unsigned-128 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_OPTION_ADDRESS,name:"option",description:"option of address. eg:none or address"},{type:No.TYPE_OPTION_BOOL,name:"option",description:"option of bool. eg:none or boolean value"},{type:No.TYPE_OPTION_U8,name:"option",description:"option of u8. eg:none or u8 value"},{type:No.TYPE_OPTION_U64,name:"option",description:"option of u64. eg:none or u64 value"},{type:No.TYPE_OPTION_U128,name:"option",description:"option of u128. eg:none or u128 value"},{type:No.TYPE_OPTION_U256,name:"option",description:"option of u256. eg:none or u256 value"},{type:No.TYPE_VEC_U256,name:"[number]",description:"unsigned-256 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_STRING,name:"[string]",description:'ascii string array. eg:["abc", "hi"]'},{type:No.TYPE_STRING,name:"string",description:'eg:"wowok"'},{type:No.TYPE_OPTION_STRING,name:"option",description:"option of string. eg:none or string value"},{type:No.TYPE_U256,name:"number",description:"unsigned-256 number. eg:12345678901233",validator:bo}];var qo;!function(e){e.mainnet="mainnet",e.testnet="testnet",e.devnet="devnet",e.localnet="localnet"}(qo||(qo={}));const Go="0xd9705a4f0b7ae3400d3af4ba781b2d2f6b4dc5dd81e2e1ce2bc949c16583df7f";class $o{network="";packages=new Map;signer="";wowok_object="";entity_object="";treasury_cap="";oracle_object="";txb;static _instance;constructor(e=qo.testnet){this.use_network(e),this.new_session()}static Instance(){return $o._instance||($o._instance=new $o),$o._instance}static Client(){return new ei({url:$o.Instance().networkUrl()})}client(){return new ei({url:this.networkUrl()})}use_network(e=qo.testnet){switch(this.network=e,e){case qo.localnet:case qo.devnet:break;case qo.testnet:this.packages.set("wowok","0xd1ed1921f385bb6c016070325950e87f1d0e3b6a5dcc67c7a9a7b66618f29239"),this.packages.set("base",Go),this.packages.set("wowok_origin","0xd1ed1921f385bb6c016070325950e87f1d0e3b6a5dcc67c7a9a7b66618f29239"),this.packages.set("base_origin","0xd9705a4f0b7ae3400d3af4ba781b2d2f6b4dc5dd81e2e1ce2bc949c16583df7f"),this.wowok_object="0x04bc9f2680baa9e1cc1e52b329f7d7790afeb95f097b704c10116c257c5d07c4",this.entity_object="0x70623568c63000b21b7b5e180c7e5415970763335c3e3b90b1795b0fc164c60d",this.treasury_cap="0xfe7b18c27914fef876dfefd018350cfe33c45b6c5fbe5931f9449048e834da5b",this.oracle_object="0x70b4a282626aef7d31822079a1727a6576c718e9640cb30ad4c385d632138689";break;case qo.mainnet:this.packages.set("wowok",""),this.packages.set("base",""),this.packages.set("wowok_origin",""),this.packages.set("base_origin",""),this.wowok_object="",this.entity_object="",this.treasury_cap="",this.oracle_object=""}}package(e){return this.packages.get(e)??""}objectWowok(){return this.wowok_object}objectEntity(){return this.entity_object}objectOracle(){return this.oracle_object}objectTreasuryCap(){return this.treasury_cap}networkUrl(){switch(this.network){case qo.localnet:return"http://127.0.0.1:9000";case qo.devnet:return"https://fullnode.devnet.sui.io:443";case qo.testnet:return"https://fullnode.testnet.sui.io:443";case qo.mainnet:return"https://fullnode.mainnet.sui.io:443"}return""}machineFn=e=>`${this.packages.get("wowok")}::${Ao.machine}::${e}`;progressFn=e=>`${this.packages.get("wowok")}::${Ao.progress}::${e}`;repositoryFn=e=>`${this.packages.get("wowok")}::${Ao.repository}::${e}`;permissionFn=e=>`${this.packages.get("wowok")}::${Ao.permission}::${e}`;passportFn=e=>`${this.packages.get("wowok")}::${Ao.passport}::${e}`;demandFn=e=>`${this.packages.get("wowok")}::${Ao.demand}::${e}`;orderFn=e=>`${this.packages.get("wowok")}::${Ao.order}::${e}`;serviceFn=e=>`${this.packages.get("wowok")}::${Ao.service}::${e}`;resourceFn=e=>`${this.packages.get("wowok")}::${Ao.resource}::${e}`;entityFn=e=>`${this.packages.get("wowok")}::${Ao.entity}::${e}`;wowokFn=e=>`${this.packages.get("wowok")}::${Ao.wowok}::${e}`;treasuryFn=e=>`${this.packages.get("wowok")}::${Ao.treasury}::${e}`;paymentFn=e=>`${this.packages.get("wowok")}::${Ao.payment}::${e}`;guardFn=e=>`${this.packages.get("base")}::${Ao.guard}::${e}`;baseWowokFn=e=>`${this.packages.get("base")}::${Ao.wowok}::${e}`;arbitrationFn=e=>`${this.packages.get("wowok")}::${Ao.arbitration}::${e}`;arbFn=e=>`${this.packages.get("wowok")}::${Ao.arb}::${e}`;query=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()}),s=e.map((e=>e.objectid)),i=await r.call("sui_multiGetObjects",[s,t]);for(let r=0;r<i.length;r++)e.forEach((e=>{e.callback(this,i[r],e,t)}));return i};query_raw=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()});return await r.call("sui_multiGetObjects",[e,t])};new_session=()=>(this.txb=new gs,this.txb);sessionCurrent=()=>this.txb?this.txb:this.new_session();sign_excute=async(e,t,r,s={showObjectChanges:!0})=>{const i=new ei({url:this.networkUrl()});e.forEach((e=>{e(this,r)}));const n=ea(t),a=Zn.fromSecretKey(n),o=await i.signAndExecuteTransaction({transaction:this.sessionCurrent(),signer:a,options:s});return this.txb=void 0,o};static SUI_TOKEN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";static SUI_COIN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<0x2::sui::SUI>";WOWOK_TOKEN_TYPE=()=>this.packages.get("base")+"::wowok::WOWOK";WOWOK_COIN_TYPE=()=>"0x2::coin::Coin<"+this.packages.get("base")+"::wowok::WOWOK>";COINS_TYPE=()=>{switch(this.network){case qo.testnet:return this.CoinTypes_Testnet.filter((e=>!0!==e.alias));case qo.mainnet:return this.CoinTypes_Mainnet.filter((e=>!0!==e.alias))}return[]};update_coinType=(e,t,r)=>{if(r&&e)switch(this.network){case qo.testnet:(s=this.CoinTypes_Testnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Testnet=s;break;case qo.mainnet:var s;(s=this.CoinTypes_Mainnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Mainnet=s}};explorerUrl=(e,t="object")=>this.network===qo.testnet?"https://testnet.suivision.xyz/"+t+"/"+e:this.network===qo.mainnet?"https://suivision.xyz/"+t+"/"+e:"";CoinTypes_Testnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9}];CoinTypes_Mainnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9},{symbol:"USDT",type:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",decimals:6},{symbol:"USDC",type:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",decimals:6},{symbol:"WETH",type:"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",decimals:8},{symbol:"WBNB",type:"0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",decimals:8}];coinTypeInfo=(e,t)=>{if(!e)return"loading";return this.COINS_TYPE().find((t=>t?.type===e))||($o.Client().getCoinMetadata({coinType:e}).then((r=>{r?.decimals&&r?.symbol&&(this.update_coinType(e,r?.decimals,r?.symbol),t({symbol:r.symbol,decimals:r.decimals,type:e}))})).catch((e=>{console.log(e)})),"loading")};static CLOCK_OBJECT={objectId:"0x6",mutable:!1,initialSharedVersion:1};static TXB_OBJECT(e,t){return"string"==typeof t?e.object(t):t}static IsValidObjects=e=>To(e,(e=>!(!e||"string"==typeof e&&!oe(e))));WOWOK_OBJECTS_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"+$a(e)));WOWOK_OBJECTS_PREFIX_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"));hasPackage(e){for(let t of this.packages.values())if(e.includes(t))return!0;return!1}object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.lastIndexOf("::");if(r>0)return e.slice(r+2)}return""};module_object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.indexOf("::");if(r>0)return e.slice(r+2)}return""}}class zo{static Object_Type_Extra=()=>{let e=Object.keys(Ao).map((e=>e+"::"+$a(e)));return e.push("order::Discount"),e};static objectids_from_response=(e,t,r)=>{let s=new Map;return t?.objectChanges&&t.objectChanges.forEach((t=>{zo.Object_Type_Extra().forEach((r=>{"created"==t.type&&e.module_object_name_from_type_repr(t.objectType)===r&&(s.has(r)?s.get(r)?.push(t.objectId):s.set(r,[t.objectId]))}))})),r&&s.forEach(((e,t)=>{r.has(t)?r.set(t,r.get(t).concat(e)):r.set(t,e)})),s}}class Wo{bounty_type;permission;object;txb;get_bounty_type(){return this.bounty_type}get_object(){return this.object}static From(e,t,r,s){let i=new Wo(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.bounty_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i,n,a){io(n)||Ba(Ca.IsValidDesription),yo(t)||Ba(Ca.IsValidArgType,t),mo(s)||Ba(Ca.IsValidUint,"time");let o=new Wo(e,t,i);const d=e.sharedObjectRef($o.CLOCK_OBJECT);return o.object=a?e.moveCall({target:$o.Instance().demandFn("new_with_passport"),arguments:[a,e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().demandFn("new"),arguments:[e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}),o}launch(){return this.txb.moveCall({target:$o.Instance().demandFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.bounty_type]})}refund(e){const t=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e?this.txb.moveCall({target:$o.Instance().demandFn("refund_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}expand_time(e,t,r){mo(t)||Ba(Ca.IsValidUint,"time"),r?this.txb.moveCall({target:$o.Instance().demandFn("time_expand_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("time_expand"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_guard(e,t,r){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"guard"),void 0===t||lo(t)||Ba(Ca.InvalidParam,"set_guard.service_identifier");let s=this.txb.pure.option("u8",void 0!==t?t:void 0);r?e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().demandFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}yes(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().demandFn("yes_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("yes"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}deposit(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]})}present(e,t,r,s){io(r)||Ba(Ca.IsValidDesription,"present.tips"),t&&!yo(t)&&Ba(Ca.IsValidArgType,"service_pay_type"),"number"==typeof e?lo(e)&&s||Ba(Ca.IsValidU8,"present.service or present.passport"):$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"present.service"),s?"number"==typeof e?this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport2"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(r)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]}):"number"!=typeof e&&this.txb.moveCall({target:$o.Instance().demandFn("present"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]}),this.permission=e}static parseObjectType=e=>La(e,"demand::Demand<");static MAX_BOUNTY_COUNT=300;static MAX_PRESENTERS_COUNT=200}var Ho;!function(e){e[e.repository=100]="repository",e[e.repository_description=101]="repository_description",e[e.repository_mode=102]="repository_mode",e[e.repository_policies=103]="repository_policies",e[e.repository_reference=104]="repository_reference",e[e.service=200]="service",e[e.service_description=201]="service_description",e[e.service_sales=202]="service_sales",e[e.service_payee=203]="service_payee",e[e.service_repository=204]="service_repository",e[e.service_withdraw_guards=205]="service_withdraw_guards",e[e.service_refund_guards=206]="service_refund_guards",e[e.service_discount_transfer=207]="service_discount_transfer",e[e.service_withdraw=208]="service_withdraw",e[e.service_buyer_guard=209]="service_buyer_guard",e[e.service_machine=210]="service_machine",e[e.service_endpoint=211]="service_endpoint",e[e.service_publish=212]="service_publish",e[e.service_clone=213]="service_clone",e[e.service_customer_required=214]="service_customer_required",e[e.service_pause=215]="service_pause",e[e.service_treasury=216]="service_treasury",e[e.service_arbitration=217]="service_arbitration",e[e.demand=260]="demand",e[e.demand_refund=261]="demand_refund",e[e.demand_expand_time=262]="demand_expand_time",e[e.demand_guard=263]="demand_guard",e[e.demand_description=264]="demand_description",e[e.demand_yes=265]="demand_yes",e[e.machine=600]="machine",e[e.machine_description=601]="machine_description",e[e.machine_repository=602]="machine_repository",e[e.machine_clone=604]="machine_clone",e[e.machine_node=606]="machine_node",e[e.machine_endpoint=608]="machine_endpoint",e[e.machine_pause=609]="machine_pause",e[e.machine_publish=610]="machine_publish",e[e.progress=650]="progress",e[e.progress_namedOperator=651]="progress_namedOperator",e[e.progress_bind_task=652]="progress_bind_task",e[e.progress_context_repository=653]="progress_context_repository",e[e.progress_unhold=654]="progress_unhold",e[e.progress_parent=655]="progress_parent",e[e.treasury=700]="treasury",e[e.treasury_receive=701]="treasury_receive",e[e.treasury_deposit=702]="treasury_deposit",e[e.treasury_withdraw=703]="treasury_withdraw",e[e.treasury_descritption=704]="treasury_descritption",e[e.treasury_deposit_guard=705]="treasury_deposit_guard",e[e.treasury_withdraw_mode=706]="treasury_withdraw_mode",e[e.treasury_withdraw_guard=707]="treasury_withdraw_guard",e[e.arbitration=800]="arbitration",e[e.arbitration_description=801]="arbitration_description",e[e.arbitration_fee=802]="arbitration_fee",e[e.arbitration_voting_guard=803]="arbitration_voting_guard",e[e.arbitration_endpoint=804]="arbitration_endpoint",e[e.arbitration_guard=805]="arbitration_guard",e[e.arbitration_pause=806]="arbitration_pause",e[e.arbitration_vote=807]="arbitration_vote",e[e.arbitration_arbitration=808]="arbitration_arbitration",e[e.arbitration_withdraw=809]="arbitration_withdraw",e[e.arbitration_treasury=810]="arbitration_treasury",e[e.user_defined_start=1e3]="user_defined_start"}(Ho||(Ho={}));const Ko=[{index:Ho.repository,name:"Repository",description:"Launch new Repository",module:Ao.repository},{index:Ho.repository_description,name:"Description",description:"Set Repository description",module:Ao.repository},{index:Ho.repository_mode,name:"Policy mode",description:"Set Repository mode",module:Ao.repository},{index:Ho.repository_policies,name:"Policy",description:"Set Repository policies",module:Ao.repository},{index:Ho.repository_reference,name:"Reference",description:"Set Repository reference",module:Ao.repository},{index:Ho.service,name:"Service",description:"Launch new Service",module:Ao.service},{index:Ho.service_description,name:"Description",description:"Set Service description",module:Ao.service},{index:Ho.service_sales,name:"Sales",description:"Set Service sales items",module:Ao.service},{index:Ho.service_payee,name:"Payee",description:"Set Service payee",module:Ao.service},{index:Ho.service_repository,name:"Repository",description:"Set Service repositories",module:Ao.service},{index:Ho.service_withdraw_guards,name:"Withdraw Guard",description:"Set Service withdraw guards",module:Ao.service},{index:Ho.service_refund_guards,name:"Refund Guard",description:"Set Service refund guards",module:Ao.service},{index:Ho.service_discount_transfer,name:"Discount",description:"Launch discounts for Service",module:Ao.service},{index:Ho.service_buyer_guard,name:"Buyer Guard",description:"Set Guard of buying for Service",module:Ao.service},{index:Ho.service_machine,name:"Machine",description:"Set Machine for Service",module:Ao.service},{index:Ho.service_endpoint,name:"Endpoint",description:"Set Service endpoint",module:Ao.service},{index:Ho.service_publish,name:"Publish",description:"Allowing the creation of Order",module:Ao.service},{index:Ho.service_clone,name:"Clone",description:"Clone Service",module:Ao.service},{index:Ho.service_customer_required,name:"Buyer info",description:"Set Service buyer info required",module:Ao.service},{index:Ho.service_pause,name:"Pause",description:"Pause/Unpause Service",module:Ao.service},{index:Ho.service_treasury,name:"Treasury",description:"Externally withdrawable treasury for compensation or rewards",module:Ao.service},{index:Ho.service_arbitration,name:"Arbitration",description:"Add/Remove arbitration that allows refunds from orders at any time based on arbitration results",module:Ao.service},{index:Ho.demand,name:"Demand",description:"Launch new Demand",module:Ao.demand},{index:Ho.demand_refund,name:"Refund",description:"Refund from Demand",module:Ao.demand},{index:Ho.demand_expand_time,name:"Expand deadline",description:"Expand Demand deadline",module:Ao.demand},{index:Ho.demand_guard,name:"Guard",description:"Set Demand guard",module:Ao.demand},{index:Ho.demand_description,name:"Description",description:"Set Demand description",module:Ao.demand},{index:Ho.demand_yes,name:"Yes",description:"Pick the Deamand serice",module:Ao.demand},{index:Ho.machine,name:"Machine",description:"Launch new Machine",module:Ao.machine},{index:Ho.machine_description,name:"Description",description:"Set Machine description",module:Ao.machine},{index:Ho.machine_repository,name:"Repository",description:"Set Machine repository",module:Ao.machine},{index:Ho.machine_clone,name:"Clone",description:"Clone Machine",module:Ao.machine},{index:Ho.machine_node,name:"Node",description:"Set Machine nodes",module:Ao.machine},{index:Ho.machine_endpoint,name:"Endpoint",description:"Set Machine endpoint",module:Ao.machine},{index:Ho.machine_pause,name:"Pause",description:"Pause/Unpause Machine",module:Ao.machine},{index:Ho.machine_publish,name:"Publish",description:"Allowing the creation of Progress",module:Ao.machine},{index:Ho.progress,name:"Progress",description:"Launch new Progress",module:Ao.progress},{index:Ho.progress_namedOperator,name:"Operator",description:"Set Progress operators",module:Ao.progress},{index:Ho.progress_bind_task,name:"Bind",description:"Set Progress task",module:Ao.progress},{index:Ho.progress_context_repository,name:"Repository",description:"Set Progress repository",module:Ao.progress},{index:Ho.progress_unhold,name:"Unhold",description:"Release Progress holdings",module:Ao.progress},{index:Ho.progress_parent,name:"Parent",description:"Set Progress parent",module:Ao.progress},{index:Ho.treasury,name:"Treasury",description:"Launch new Treasury",module:Ao.treasury},{index:Ho.treasury_deposit,name:"Deposit",description:"Deposit coins",module:Ao.treasury},{index:Ho.treasury_receive,name:"Receive",description:"Receive coins from some address sent",module:Ao.treasury},{index:Ho.treasury_withdraw,name:"Withdraw",description:"Withdraw coins",module:Ao.treasury},{index:Ho.treasury_withdraw_guard,name:"Withdraw Guard",description:"Add/Remove Treasury withdraw guard",module:Ao.treasury},{index:Ho.treasury_withdraw_mode,name:"Withdraw mode",description:"Set Treasury withdraw mode",module:Ao.treasury},{index:Ho.treasury_deposit_guard,name:"Deposit Guard",description:"Set Treasury deposit guard",module:Ao.treasury},{index:Ho.treasury_descritption,name:"Description",description:"Set Treasury description",module:Ao.treasury},{index:Ho.arbitration,name:"Arbitration",description:"Launch new Arbitration",module:Ao.arbitration},{index:Ho.arbitration_description,name:"Description",description:"Set Arbitration description",module:Ao.arbitration},{index:Ho.arbitration_endpoint,name:"Endpoint",description:"Set Arbitration endpoint",module:Ao.arbitration},{index:Ho.arbitration_fee,name:"Fee",description:"Set Arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_guard,name:"Guard",description:"Set Guard to apply for arbitration",module:Ao.arbitration},{index:Ho.arbitration_arbitration,name:"Arbitrate",description:"Determine the outcome of arbitration",module:Ao.arbitration},{index:Ho.arbitration_pause,name:"Pause",description:"Allowing/forbidding the creation of Arb",module:Ao.arbitration},{index:Ho.arbitration_voting_guard,name:"Voting Guard",description:"Add/Remove voting Guard",module:Ao.arbitration},{index:Ho.arbitration_vote,name:"Vote",description:"Vote on the application for arbitration",module:Ao.arbitration},{index:Ho.arbitration_withdraw,name:"Withdraw",description:"Withdraw the arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_treasury,name:"Withdraw",description:"Set Treasury that fees was collected at the time of withdrawal",module:Ao.arbitration}];class Qo{txb;object;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new Qo(e);return r.object=$o.TXB_OBJECT(e,t),r}static New(e,t){io(t)||Ba(Ca.IsValidDesription);let r=new Qo(e);return r.object=e.moveCall({target:$o.Instance().permissionFn("new"),arguments:[e.pure.string(t)]}),r}launch(){return this.txb.moveCall({target:$o.Instance().permissionFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_bizPermission(e,t){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"add_bizPermission"),no(t)||Ba(Ca.IsValidName,"add_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),this.txb.pure.string(t)]})}remove_bizPermission(e){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"remove_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e)]})}transfer_permission(e,t){co(e)&&co(t)||Ba(Ca.IsValidAddress,"transfer_permission"),this.txb.moveCall({target:$o.Instance().permissionFn("change_entity"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.address(t)]})}add_entity2(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_entity2"),void 0!==t?this.txb.moveCall({target:$o.Instance().permissionFn("add_with_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(t),this.txb.pure.vector("address",Ga(e))]}):this.txb.moveCall({target:$o.Instance().permissionFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}add_entity3(e){if(0===e.length)return;const t=[];e.forEach((e=>{e.entities.forEach((r=>{const s=t.find((e=>e.address===r.address));if(s){const t=s.permissions.find((t=>t.index===e.index));t?t.guard=r.guard:s.permissions.push({guard:r.guard,index:e.index})}else t.push({address:r.address,permissions:[{guard:r.guard,index:e.index}]})}))})),this.add_entity(t)}add_entity(e){if(0===e.length)return;let t=!0;e.forEach((e=>{co(e.address)||(t=!1),e.permissions.forEach((e=>{Qo.IsValidPermissionIndex(e.index)||(t=!1),e?.guard&&!$o.IsValidObjects([e.guard])&&(t=!1)}))})),t||Ba(Ca.InvalidParam,"add_entity.entities");let r=[];for(let t=0;t<e.length;t++){let s=e[t],i=[];for(let e=0;e<s.permissions.length;e++){let t=s.permissions[e];Qo.IsValidPermissionIndex(t.index)&&(i.includes(t.index)||(i.push(t.index),t?.guard&&r.push({address:s.address,index:t.index,guard:t.guard})))}i.length>0&&this.txb.moveCall({target:$o.Instance().permissionFn("add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(s.address),this.txb.pure.vector("u64",i)]})}r.forEach((({address:e,index:t,guard:r})=>{this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]})}))}set_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"address"),Qo.IsValidPermissionIndex(t)||Qo.IsValidBizPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex,"index"),r?this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]}):this.txb.moveCall({target:$o.Instance().permissionFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t)]})}remove_index(e,t){co(e)||Ba(Ca.IsValidAddress),0!==t.length&&(To(t,Qo.IsValidPermissionIndex)||Ba(Ca.InvalidParam,"index"),this.txb.moveCall({target:$o.Instance().permissionFn("remove_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.vector("u64",Ga(t))]}))}remove_entity(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}set_description(e){io(e)||Ba(Ca.IsValidDesription),this.txb.moveCall({target:$o.Instance().permissionFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}add_admin(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("admin_add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}remove_admin(e,t){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"admin"),t?this.txb.moveCall({target:$o.Instance().permissionFn("admins_clear"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]}):e&&this.txb.moveCall({target:$o.Instance().permissionFn("admin_remove_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}change_owner(e){co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().permissionFn("builder_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}query_permissions_all(e){co(e)||Ba(Ca.InvalidParam,"query_permissions"),this.txb.moveCall({target:$o.Instance().permissionFn("query_permissions_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}QueryPermissions(e,t,r,s){this.query_permissions_all(t),$o.Client().devInspectTransactionBlock({sender:s??t,transactionBlock:this.txb}).then((s=>{if(s.results&&s.results[0].returnValues&&2!==s.results[0].returnValues.length)return void r({who:t,object:e});const i=Wa.getInstance().de(Oa.U8,Uint8Array.from(s.results[0].returnValues[0][0]));if(i===Qo.PERMISSION_ADMIN||i===Qo.PERMISSION_OWNER_AND_ADMIN)r({who:t,admin:!0,owner:i%2==1,items:[],object:e});else{const n=Wa.getInstance().de_perms(Uint8Array.from(s.results[0].returnValues[1][0]));r({who:t,admin:!1,owner:i%2==1,items:n.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e})}})).catch((s=>{console.log(s),r({who:t,object:e})}))}static HasPermission(e,t,r=!1){if(e){if(e.admin)return{has:!0,owner:e.owner};let r=e.items?.find((e=>e.query==t));return r?{has:r.permission,guard:r.guard,owner:e.owner}:{has:!1,guard:void 0,owner:e?.owner}}if(r)return{has:!1,guard:void 0,owner:!1}}static MAX_ADMIN_COUNT=64;static MAX_ENTITY_COUNT=2e3;static MAX_PERMISSION_INDEX_COUNT=200;static MAX_PERSONAL_PERMISSION_COUNT=200;static PERMISSION_NORMAL=0;static PERMISSION_OWNER=1;static PERMISSION_ADMIN=2;static PERMISSION_OWNER_AND_ADMIN=3;static BUSINESS_PERMISSIONS_START=Ho.user_defined_start;static IsValidBizPermissionIndex=e=>e>=Qo.BUSINESS_PERMISSIONS_START&&mo(e);static IsValidPermissionIndex=e=>!!Object.values(Ho).includes(e)||Qo.IsValidBizPermissionIndex(e)}class Zo{txb;object;permission;get_object(){return this.object}static From(e,t,r){let s=new Zo(e,t);return s.object=$o.TXB_OBJECT(e,r),s}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription),s&&!oo(s)&&Ba(Ca.IsValidEndpoint);let n=new Zo(e,t),a=e.pure.option("string",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().machineFn("new_with_passport"),arguments:[i,e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().machineFn("new"),arguments:[e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}),n}add_node(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{no(e.name)||(r=!1),e.pairs.forEach((e=>{ao(e.prior_node)||(r=!1),e?.threshold&&!fo(e.threshold)&&(r=!1),e.forwards.forEach((e=>{""!==Zo.checkValidForward(e)&&(r=!1)}))}))})),r||Ba(Ca.InvalidParam,"add_node");let s=[];e.forEach((e=>{let t=this.txb.moveCall({target:$o.Instance().machineFn("node_new"),arguments:[this.txb.pure.string(e.name)]});e.pairs.forEach((e=>{let r=this.txb.pure.option("u32",e?.threshold);e.forwards.forEach((s=>{this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[t,this.txb.pure.string(e.prior_node),this.txb.pure.string(s.name),r,this.forward(s)]})})),0===e.forwards.length&&this.txb.moveCall({target:$o.Instance().machineFn("forward_add_none"),arguments:[t,this.txb.pure.string(e.prior_node),r]})})),s.push(t)})),this.add_node2(s,t)}forward(e){let t,r=e?.weight?e.weight:1;return e?.namedOperator&&no(e.namedOperator)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward2"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r)]}):void 0!==e?.permission&&mo(e.permission)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward3"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward4"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r)]}):Ba(Ca.InvalidParam,"forward"),e?.suppliers?.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"forward.suppliers:"+e.object),this.txb.moveCall({target:$o.Instance().serviceFn("add_to"),arguments:[this.txb.object(e.object),this.txb.pure.bool(e.bRequired??!1),t],typeArguments:[e.pay_token_type]})})),t}add_node2(e,t){if(0===e.length)return;let r=e.map((e=>$o.TXB_OBJECT(this.txb,e)));t?this.txb.moveCall({target:$o.Instance().machineFn("node_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]})}fetch_node(e,t){return no(e)||Ba(Ca.IsValidName,"fetch_node"),t?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}rename_node(e,t,r){e!==t&&(no(e)||Ba(Ca.IsValidName,"rename_node"),no(t)||Ba(Ca.IsValidName,"rename_node"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_node(e,t=!1,r){0!==e.length&&(To(e,no)||Ba(Ca.IsValidArray,"nodes_name"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}launch(){return this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().machineFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}add_repository(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("repository_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_repository"),r?t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.object)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}clone(e,t){let r;return r=t?this.txb.moveCall({target:$o.Instance().machineFn("clone_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}),e?this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,r)]}):r}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]})}publish(e){e?this.txb.moveCall({target:$o.Instance().machineFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"new_permission"),this.txb.moveCall({target:$o.Instance().machineFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}add_forward(e,t,r,s,i,n){ao(e)||Ba(Ca.IsValidName_AllowEmpty,"add_forward"),no(t)||Ba(Ca.IsValidName,"add_forward");const a=Zo.checkValidForward(r);let o;a&&Ba(Ca.InvalidParam,a),o=n?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]});const d=this.forward(r),c=this.txb.pure.option("u32",s??void 0);this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(r.name),c,d]}),i&&i!==r.name&&this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(i)]}),this.add_node2([o],n)}remove_pair(e,t,r){let s;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_pair"),no(t)||Ba(Ca.IsValidName,"remove_pair"),s=r?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("pair_remove"),arguments:[s,this.txb.pure.string(e)]}),this.add_node2([s],r)}remove_forward(e,t,r,s){let i;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_forward"),no(t)||Ba(Ca.IsValidName,"remove_forward"),i=s?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[i,this.txb.pure.string(e),this.txb.pure.string(r)]}),this.add_node2([i],s)}static rpc_de_nodes(e){const t=[];return e.forEach((e=>{t.push({name:e.data.content.fields.name,pairs:Zo.rpc_de_pair(e?.data.content.fields.value)})})),t}static rpc_de_pair(e){let t=[];return e.fields.value.fields.contents.forEach((e=>{let r=[];e.fields.value.fields.forwards.fields.contents.forEach((e=>{let t=e.fields.key,s=e.fields.value.fields.weight,i=e.fields.value.fields.guard,n=e.fields.value.fields.namedOperator,a=e.fields.value.fields.permission_index;r.push({name:t,namedOperator:n,permission:a,weight:s,guard:i||"",suppliers:e.fields.value.fields.suppliers.fields.contents.map((e=>({object:e.fields.key,bRequired:e.fields.value,pay_token_type:""})))})})),t.push({prior_node:e.fields.key,threshold:e.fields.value.fields.threshold,forwards:r})})),t}static namedOperators(e){let t=[];return e.forEach((e=>{e.pairs.forEach((e=>{e.forwards.forEach((e=>{e?.namedOperator&&!t.find((t=>t===e.namedOperator))&&t.push(e.namedOperator)}))}))})),t}static checkValidForward(e){return no(e.name)?e?.namedOperator&&!ao(e?.namedOperator)?"Progress Operator invalid":e?.permission&&!Qo.IsValidPermissionIndex(e?.permission)?"Permission index invalid":e?.permission||e?.namedOperator?e?.weight&&!mo(e.weight)?"Weight invalid":"":"Business-Permissions invalid":"Forward name invalid"}static INITIAL_NODE_NAME="";static OPERATOR_ORDER_PAYER="OrderPayer"}class ed{permission;machine;object;txb;get_object(){return this.object}constructor(e,t,r){this.permission=r,this.txb=e,this.machine=t,this.object=""}static From(e,t,r,s){let i=new ed(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i){$o.IsValidObjects([t,r])||Ba(Ca.IsValidObjects,"machine & permission");let n=new ed(e,t,r),a=e.pure.option("address",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().progressFn("new_with_passport"),arguments:[i,a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}):e.moveCall({target:$o.Instance().progressFn("new"),arguments:[a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_namedOperator(e,t,r){no(e)||Ba(Ca.IsValidName,"name"),e===Zo.OPERATOR_ORDER_PAYER&&Ba(Ca.InvalidParam,"name cannot be "+Zo.OPERATOR_ORDER_PAYER),(t.length>ed.MAX_NAMED_OPERATOR_COUNT||!To(t,co))&&Ba(Ca.InvalidParam,"addresses"),r?this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",Ga(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",Ga(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}bind_task(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().progressFn("task_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("task_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}set_context_repository(e,t){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"repository"),t?e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}unhold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"unhold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?this.txb.moveCall({target:$o.Instance().progressFn("unhold_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]}):this.txb.moveCall({target:$o.Instance().progressFn("unhold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}parent_none(e){e?this.txb.moveCall({target:$o.Instance().progressFn("parent_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}parent(e,t){co(e.parent_id)&&fo(e.parent_session_id)||Ba(Ca.InvalidParam,"parent"),e.next_node&&e.forward||Ba(Ca.InvalidParam,"parent"),t?this.txb.moveCall({target:$o.Instance().progressFn("parent_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]})}deliverable(e){io(e.msg)||Ba(Ca.IsValidDesription,"deliverable.msg"),e.orders.length>0&&!$o.IsValidObjects(e.orders.map((e=>e.object)))&&Ba(Ca.IsValidObjects,"deliverable.orders");const t=this.txb.moveCall({target:$o.Instance().progressFn("deliverable_new"),arguments:[this.txb.pure.string(e.msg)]});return e.orders.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"deliverable.orders:"+e.object),this.txb.moveCall({target:$o.Instance().orderFn("as_deliverable"),arguments:[this.txb.object(e.object),t],typeArguments:[e.pay_token_type]})})),t}next(e,t,r){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"next");const s=this.deliverable(t),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().progressFn("next_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]}):this.txb.moveCall({target:$o.Instance().progressFn("next"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]})}hold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"hold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return this.txb.moveCall({target:$o.Instance().progressFn("hold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}static QueryForwardGuard=async(e,t,r,s,i)=>{if(!(e&&t&&s&&i))return void Ba(Ca.InvalidParam,"QueryForwardGuard");const n=new gs;n.moveCall({target:$o.Instance().progressFn("query_guard"),arguments:[$o.TXB_OBJECT(n,e),$o.TXB_OBJECT(n,t),n.pure.string(s),n.pure.string(i)]});const a=await $o.Client().devInspectTransactionBlock({sender:r,transactionBlock:n});if(1===a.results?.length&&1===a.results[0].returnValues?.length){const e=Wa.getInstance().de("Option<address>",Uint8Array.from(a.results[0].returnValues[0][0]));return e?.some?"0x"+e?.some:void 0}};static DeSessions=e=>{let t=[];return e?.fields?.contents?.forEach((e=>{var r={next_node:e.fields.key,holders:[],weights:e.fields.value.fields.weights,threshold:e.fields.value.fields.threshold};e.fields.value.fields.forwards.fields.contents.forEach((e=>{r.holders.push({forward:e.fields.key,accomplished:e.fields.value.fields.accomplished,time:e.fields.value.fields.time,who:e.fields.value.fields.who,deliverable:{msg:e.fields.value.fields.msg,orders:e.fields.value.fields.orders??[]}})})),t.push(r)})),t};static DeHistories=e=>e?.map((e=>ed.DeHistory(e?.data?.content?.fields)));static DeHistory=e=>({id:parseInt(e?.name),node:e?.value?.fields?.node,next_node:e?.value?.fields?.next_node,sessions:ed.DeSessions(e?.value.fields?.session),time:e?.value?.fields?.time});static MAX_NAMED_OPERATOR_COUNT=20;static MAX_DELEVERABLE_ORDER_COUNT=20;static IsValidProgressNext=e=>no(e.forward)&&no(e.next_node_name)}const td=[{module:Ao.permission,query_name:"Owner",query_id:1,parameters:[],return:No.TYPE_ADDRESS,description:"Owner's address."},{module:Ao.permission,query_name:"Is Admin",query_id:2,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain address an administrator?",parameters_description:["address"]},{module:Ao.permission,query_name:"Has Rights",query_id:3,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Does an address have a certain permission(Admin always have permissions)?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Contains Address",query_id:4,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is included in the personnel permission table?",parameters_description:["address"]},{module:Ao.permission,query_name:"Contains Permission",query_id:5,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Whether a certain permission for a certain address is defined in the personnel permission table?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Contains Permission Guard",query_id:6,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Whether a permission guard for a certain address is defined in the personnel permission table?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Permission Guard",query_id:7,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_ADDRESS,description:"Permission guard for a certain address.",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Number of Entities",query_id:8,parameters:[],return:No.TYPE_U64,description:"Number of entities in the personnel permission table."},{module:Ao.permission,query_name:"Number of Admin",query_id:9,parameters:[],return:No.TYPE_U64,description:"Number of administrators."},{module:Ao.repository,query_name:"Permission",query_id:100,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.repository,query_name:"Contains Policy",query_id:101,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Is a consensus policy included?",parameters_description:["the filed name"]},{module:Ao.repository,query_name:"Is Permission set of Policy",query_id:102,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does a certain consensus policy set data operation permissions?",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Permission of Policy",query_id:103,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"The permission index of a certain consensus policy in the Permission object.",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Value Type of Policy",query_id:104,parameters:[No.TYPE_STRING],return:No.TYPE_U8,description:"Data types defined by consensus policy.",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Contains Data",query_id:105,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does it contain data for a certain field of an address?",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Raw data without Type",query_id:106,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U8,description:"Data for a field at an address and does not contain data type information.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Raw data",query_id:107,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U8,description:"Data for a field at an address, and the first byte contains data type information.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Type",query_id:108,parameters:[],return:No.TYPE_U8,description:"The repository Type. 0: Normal; 1: Wowok greenee."},{module:Ao.repository,query_name:"Policy Mode",query_id:109,parameters:[],return:No.TYPE_U8,description:"Policy Mode. 0: Free mode; 1: Strict mode."},{module:Ao.repository,query_name:"Reference Count",query_id:110,parameters:[],return:No.TYPE_U64,description:"The number of times it is referenced by other objects."},{module:Ao.repository,query_name:"Is Referenced by An Object",query_id:111,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is it referenced by an object?",parameters_description:["address"]},{module:Ao.repository,query_name:"Number Data",query_id:112,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_U256,description:"Data for a field at an address and get unsigned integer type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"String Data",query_id:113,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_STRING,description:"Data for a field at an address and get string type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Address Data",query_id:114,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"Data for a field at an address and get address type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Bool Data",query_id:115,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Data for a field at an address and get bool type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Number Vector Data",query_id:116,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U256,description:"Data for a field at an address and get unsigned integer vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"String Vector Data",query_id:117,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_STRING,description:"Data for a field at an address and get string vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Address Vector Data",query_id:118,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_ADDRESS,description:"Data for a field at an address and get address vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Bool Vector Data",query_id:119,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_BOOL,description:"Data for a field at an address and get bool vector type data.",parameters_description:["address","the field name"]},{module:Ao.entity,query_name:"Has Entity",query_id:200,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is an entity already registered?",parameters_description:["address"]},{module:Ao.entity,query_name:"Likes",query_id:201,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The number of likes for an address by other addresses.",parameters_description:["address"]},{module:Ao.entity,query_name:"Dislikes",query_id:202,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The number of dislikes for an address by other addresses.",parameters_description:["address"]},{module:Ao.entity,query_name:"Entity Info",query_id:203,parameters:[No.TYPE_ADDRESS],return:No.TYPE_VEC_U8,description:"Public information about an entity.",parameters_description:["address"]},{module:Ao.entity,query_name:"Has Resource by Entity?",query_id:204,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an entity created a resource?",parameters_description:["address"]},{module:Ao.entity,query_name:"Entity Resource",query_id:205,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"The address of a resource object created by an entity.",parameters_description:["address"]},{module:Ao.demand,query_name:"Permission",query_id:300,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.demand,query_name:"Deadline",query_id:302,parameters:[],return:No.TYPE_U64,description:"The expiration time of presenting."},{module:Ao.demand,query_name:"Bounty Count",query_id:303,parameters:[],return:No.TYPE_U64,description:"Number of Bounties."},{module:Ao.demand,query_name:"Has Guard",query_id:304,parameters:[],return:No.TYPE_BOOL,description:"Whether the present guard is set?"},{module:Ao.demand,query_name:"Guard",query_id:305,parameters:[],return:No.TYPE_ADDRESS,description:"The present guard address."},{module:Ao.demand,query_name:"Has Service Picked",query_id:306,parameters:[],return:No.TYPE_BOOL,description:"Whether a service has been picked and bounties given?"},{module:Ao.demand,query_name:"Service Picked",query_id:307,parameters:[],return:No.TYPE_ADDRESS,description:"Service address that has been picked."},{module:Ao.demand,query_name:"Presenter Count",query_id:308,parameters:[],return:No.TYPE_U64,description:"Number of presenters."},{module:Ao.demand,query_name:"Has Presenter",query_id:309,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain address a presenter?",parameters_description:["address"]},{module:Ao.demand,query_name:"Who Got Bounty",query_id:310,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"The address that bounties given.",parameters_description:["address"]},{module:Ao.service,query_name:"Permission",query_id:400,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.service,query_name:"Payee",query_id:401,parameters:[],return:No.TYPE_ADDRESS,description:"Payee address, that all order withdrawals will be collected to this address."},{module:Ao.service,query_name:"Has Buying Guard",query_id:402,parameters:[],return:No.TYPE_BOOL,description:"Is the guard condition of buying set?"},{module:Ao.service,query_name:"Buying Guard",query_id:403,parameters:[],return:No.TYPE_ADDRESS,description:"Buying guard, that Purchase only if you meet the conditions of the guard."},{module:Ao.service,query_name:"Contains Repository",query_id:404,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain repository one of the service's consensus repositories?",parameters_description:["address"]},{module:Ao.service,query_name:"Has Withdrawing Guard",query_id:405,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether a certain guard is set when withdrawing money?",parameters_description:["address"]},{module:Ao.service,query_name:"Withdrawing Guard Percent",query_id:406,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The percentage of withdrawals allowed by a certain withdrawal guard.",parameters_description:["address"]},{module:Ao.service,query_name:"Has Refunding Guard",query_id:407,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether a certain guard is set when refunding money?",parameters_description:["address"]},{module:Ao.service,query_name:"Refunding Guard Percent",query_id:408,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The percentage of refund allowed by a certain refund guard.",parameters_description:["address"]},{module:Ao.service,query_name:"Has Sales Item",query_id:409,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Is there a sales item for the service?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Sale Item Price",query_id:410,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"What is the price of a certain sale item?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Sale Item Inventory",query_id:411,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"How much inventory is there for a certain sales item?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Has Machine",query_id:412,parameters:[],return:No.TYPE_BOOL,description:"Has the machine(progress generator) that serves the order been set up?"},{module:Ao.service,query_name:"Machine",query_id:413,parameters:[],return:No.TYPE_ADDRESS,description:"Machine address, that generate progresses serving the execution process of order."},{module:Ao.service,query_name:"Paused",query_id:414,parameters:[],return:No.TYPE_BOOL,description:"Pause the creation of new order?"},{module:Ao.service,query_name:"Published",query_id:415,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create orders?"},{module:Ao.service,query_name:"Has Required Info",query_id:416,parameters:[],return:No.TYPE_BOOL,description:"Whether the necessary information that needs to be provided by the customer is set?"},{module:Ao.service,query_name:"Required Info of Service-Pubkey",query_id:417,parameters:[],return:No.TYPE_STRING,description:"The public key used to encrypt customer information, and only the service provider can decrypt and view customer information."},{module:Ao.service,query_name:"Required Info",query_id:418,parameters:[],return:No.TYPE_VEC_STRING,description:"Names of the required information item that needs to be provided by the customer."},{module:Ao.service,query_name:"Number of Treasuries",query_id:419,parameters:[],return:No.TYPE_U64,description:"The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives."},{module:Ao.service,query_name:"Contains Treasury",query_id:420,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?",parameters_description:["treasury address"]},{module:Ao.service,query_name:"Number of Arbitrations",query_id:421,parameters:[],return:No.TYPE_U64,description:"The number of arbitrations that allows a refund to be made from the order at any time based on the arbitration result."},{module:Ao.service,query_name:"Contains Arbitration",query_id:422,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does it contain an arbitration that allows a refund to be made from the order at any time based on the arbitration result.?",parameters_description:["arbitration address"]},{module:Ao.order,query_name:"Amount",query_id:500,parameters:[],return:No.TYPE_U64,description:"Order amount."},{module:Ao.order,query_name:"Payer",query_id:501,parameters:[],return:No.TYPE_ADDRESS,description:"Order payer."},{module:Ao.order,query_name:"Service",query_id:502,parameters:[],return:No.TYPE_ADDRESS,description:"Service for creating orders."},{module:Ao.order,query_name:"Has Progress",query_id:503,parameters:[],return:No.TYPE_BOOL,description:"Is there a Progress for executing the order process?"},{module:Ao.order,query_name:"Progress",query_id:504,parameters:[],return:No.TYPE_ADDRESS,description:"Progress address for executing the order process."},{module:Ao.order,query_name:"Required Info",query_id:505,parameters:[],return:No.TYPE_BOOL,description:"Is Required Info set?"},{module:Ao.order,query_name:"Discount Used",query_id:506,parameters:[],return:No.TYPE_BOOL,description:"Discount coupon used for this order?"},{module:Ao.order,query_name:"Discount",query_id:507,parameters:[],return:No.TYPE_ADDRESS,description:"Discount address that already used."},{module:Ao.order,query_name:"Balance",query_id:508,parameters:[],return:No.TYPE_U64,description:"The amount currently in the order."},{module:Ao.order,query_name:"Number of Agents",query_id:511,parameters:[],return:No.TYPE_U64,description:"The number of agents for the order."},{module:Ao.order,query_name:"Has Agent",query_id:512,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is an order agent?",parameters_description:["agent address"]},{module:Ao.order,query_name:"Number of Disputes",query_id:513,parameters:[],return:No.TYPE_U64,description:"Number of arbitrations for the order."},{module:Ao.order,query_name:"Has Arb",query_id:514,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does the order contain an Arb for arbitration?",parameters_description:["arb address"]},{module:Ao.machine,query_name:"Permission",query_id:700,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.machine,query_name:"Paused",query_id:701,parameters:[],return:No.TYPE_BOOL,description:"Pause the creation of new Progress?"},{module:Ao.machine,query_name:"Published",query_id:702,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create Progress?"},{module:Ao.machine,query_name:"Is Consensus Repository",query_id:703,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is a consensus repository?",parameters_description:["adddress"]},{module:Ao.machine,query_name:"Has Endpoint",query_id:704,parameters:[],return:No.TYPE_BOOL,description:"Is the endpoint set?"},{module:Ao.machine,query_name:"Endpoint",query_id:705,parameters:[],return:No.TYPE_STRING,description:"Endpoint url/ipfs."},{module:Ao.progress,query_name:"Machine",query_id:800,parameters:[],return:No.TYPE_ADDRESS,description:"The Machine object that created this Progress."},{module:Ao.progress,query_name:"Current Node",query_id:801,parameters:[],return:No.TYPE_STRING,description:"The name of the currently running node."},{module:Ao.progress,query_name:"Has Parent",query_id:802,parameters:[],return:No.TYPE_BOOL,description:"Is the parent Progress defined?"},{module:Ao.progress,query_name:"Parent",query_id:803,parameters:[],return:No.TYPE_ADDRESS,description:"The parent Progress, that contains some child Progress."},{module:Ao.progress,query_name:"Has Task",query_id:804,parameters:[],return:No.TYPE_BOOL,description:"Does it contain clear task(eg. an Order)?"},{module:Ao.progress,query_name:"Task",query_id:805,parameters:[],return:No.TYPE_ADDRESS,description:"Task object address."},{module:Ao.progress,query_name:"Has Unique Permission",query_id:806,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does Progress define a unique operation permission?",parameters_description:["operator name"]},{module:Ao.progress,query_name:"Is Unique Permission Operator",query_id:807,parameters:[No.TYPE_STRING,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is an address an operator with unique permissions?",parameters_description:["operator name","address"]},{module:Ao.progress,query_name:"Has Context Repository",query_id:808,parameters:[],return:No.TYPE_BOOL,description:"Whether the repository reference for Progress is set?"},{module:Ao.progress,query_name:"Context Repository",query_id:809,parameters:[],return:No.TYPE_ADDRESS,description:"Repository reference for Progress."},{module:Ao.progress,query_name:"Last Session Time",query_id:810,parameters:[],return:No.TYPE_U64,description:"Time when the previous session was completed."},{module:Ao.progress,query_name:"Last Session Node",query_id:811,parameters:[],return:No.TYPE_STRING,description:"The name of the last completed node."},{module:Ao.progress,query_name:"Current Session-id",query_id:812,parameters:[],return:No.TYPE_U64,description:"The session id of ongoing node."},{module:Ao.progress,query_name:"Parent Session-id",query_id:813,parameters:[],return:No.TYPE_U64,description:"The child process was started in the Session-id phase of the parent process."},{module:Ao.progress,query_name:"Parent Next Node",query_id:814,parameters:[],return:No.TYPE_STRING,description:"The child process is started at the next node stage of the parent process."},{module:Ao.progress,query_name:"Parent Forward",query_id:815,parameters:[],return:No.TYPE_STRING,description:"The child process is started in the Forward phase of the next node of the parent process."},{module:Ao.progress,query_name:"Parent Node",query_id:816,parameters:[],return:No.TYPE_STRING,description:"The node name of the parent process where the child process is located."},{module:Ao.progress,query_name:"Forward Accomplished",query_id:817,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Has the forward been accomplished?",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Operator",query_id:818,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"The forward operator.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Message",query_id:819,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_STRING,description:"The forward message.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Order Count",query_id:820,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The forward Order count.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward time",query_id:821,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The time when the forward was last triggered.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Session Time",query_id:822,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"The time a node that closest time to the current node completes its session.",parameters_description:["node name"]},{module:Ao.progress,query_name:"Closest Forward Accomplished",query_id:823,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Has the forward been accomplished?",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Operator",query_id:824,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"The operator of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Message",query_id:825,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_STRING,description:"The message of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Order Count",query_id:826,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The Order count of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward time",query_id:827,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The time when the forward that closest time to the current node was last triggered.",parameters_description:["node name","next node name","forward name"]},{module:Ao.wowok,query_name:"Builder",query_id:900,parameters:[],return:No.TYPE_ADDRESS,description:"Builder address of Wowok."},{module:Ao.wowok,query_name:"Object of Entities",query_id:901,parameters:[],return:No.TYPE_ADDRESS,description:"The address of entity information object."},{module:Ao.wowok,query_name:"Grantor Count",query_id:902,parameters:[],return:No.TYPE_U64,description:"Number of registered grantors."},{module:Ao.wowok,query_name:"Has Grantor",query_id:903,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address has been registered as a grantor?",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Name",query_id:904,parameters:[No.TYPE_ADDRESS],return:No.TYPE_STRING,description:"Name of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Registration Time",query_id:905,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Registration time of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Expired Time",query_id:906,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The expiration time of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantee Object for Grantor",query_id:907,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Grantee repository address of a grantor.",parameters_description:["address"]},{module:Ao.payment,query_name:"Sender",query_id:1200,parameters:[],return:No.TYPE_ADDRESS,description:"Payment originator address."},{module:Ao.payment,query_name:"Total Amount",query_id:1201,parameters:[],return:No.TYPE_U128,description:"Payment amount."},{module:Ao.payment,query_name:"Remark",query_id:1202,parameters:[],return:No.TYPE_STRING,description:"Payment remark.",parameters_description:["address"]},{module:Ao.payment,query_name:"Has Guard for Perpose",query_id:1203,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment references a Guard?"},{module:Ao.payment,query_name:"Has Object for Perpose",query_id:1204,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment references an Object?"},{module:Ao.payment,query_name:"Guard for Perpose",query_id:1205,parameters:[],return:No.TYPE_ADDRESS,description:"The Guard referenced by this payment."},{module:Ao.payment,query_name:"Object for Perpose",query_id:1206,parameters:[],return:No.TYPE_ADDRESS,description:"The Object referenced by this payment."},{module:Ao.payment,query_name:"Number of Recipients",query_id:1207,parameters:[],return:No.TYPE_U64,description:"Number of recipients to receive payment from."},{module:Ao.payment,query_name:"Is a Recipient",query_id:1208,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a recipient received the payment?",parameters_description:["address"]},{module:Ao.payment,query_name:"Amount for a Recipient",query_id:1209,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The amount of payment received by an address.",parameters_description:["address"]},{module:Ao.payment,query_name:"Time",query_id:1210,parameters:[],return:No.TYPE_U64,description:"Payment time"},{module:Ao.payment,query_name:"Is from Treasury",query_id:1211,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment comes from a Treasury?"},{module:Ao.payment,query_name:"Treasury Address",query_id:1212,parameters:[],return:No.TYPE_ADDRESS,description:"The Treasury from which the payment comes."},{module:Ao.payment,query_name:"Biz-ID",query_id:1213,parameters:[],return:No.TYPE_U64,description:"Bisiness ID number of the payment."},{module:Ao.payment,query_name:"Check the purpose of payment",query_id:1214,parameters:[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Do Guard, Object Perpose, and Biz-ID match?",parameters_description:["guard address","object address","Biz-ID"]},{module:Ao.payment,query_name:"Check & Amount for a Recipient",query_id:1215,parameters:[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Check and get the amount of payment received by an address.",parameters_description:["guard address","object address","Biz-ID","recipient address"]},{module:Ao.treasury,query_name:"Permission",query_id:1400,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.treasury,query_name:"Balance",query_id:1401,parameters:[],return:No.TYPE_U64,description:"Treasury balance."},{module:Ao.treasury,query_name:"Number of Flow Records",query_id:1402,parameters:[],return:No.TYPE_U64,description:"Number of treasury transactions."},{module:Ao.treasury,query_name:"Inflow Amount",query_id:1403,parameters:[],return:No.TYPE_U128,description:"Treasury inflow amount."},{module:Ao.treasury,query_name:"Outflow Amount",query_id:1404,parameters:[],return:No.TYPE_U128,description:"Treasury outflow amount."},{module:Ao.treasury,query_name:"Has Deposit Guard",query_id:1405,parameters:[],return:No.TYPE_BOOL,description:"Whether the deposit Guard set?"},{module:Ao.treasury,query_name:"Deposit Guard",query_id:1406,parameters:[],return:No.TYPE_ADDRESS,description:"Deposit Guard address."},{module:Ao.treasury,query_name:"Number of Withdraw Guards",query_id:1407,parameters:[],return:No.TYPE_U64,description:"Number of withdraw guards."},{module:Ao.treasury,query_name:"Has Withdraw Guard",query_id:1408,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has a Withdraw Guard added?",parameters_description:["guard address"]},{module:Ao.treasury,query_name:"Withdrawal Amount with Guard",query_id:1409,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"withdrawal amount corresponding the Guard.",parameters_description:["guard address"]},{module:Ao.treasury,query_name:"Recent Time with Operation",query_id:1410,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"Time of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Signer with Operation",query_id:1411,parameters:[No.TYPE_U8],return:No.TYPE_ADDRESS,description:"Signer address of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Payment with Operation",query_id:1412,parameters:[No.TYPE_U8],return:No.TYPE_ADDRESS,description:"Payment address of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Amount with Operation",query_id:1413,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"Amount of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Time with Op/Pmt",query_id:1414,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation with payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Signer with Op&Pmt",query_id:1415,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Signer of the most recent fund operationwith payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Pmt",query_id:1416,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation with payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Time with Op/Sgr",query_id:1417,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation with signer specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Payment with Op/Sgr",query_id:1418,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Payment of the most recent fund operation with singner specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Sgr",query_id:1419,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation with singer specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Time with Op/Pmt/Sgr",query_id:1420,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation.",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Pmt/Sgr",query_id:1421,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation.",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Has Operation",query_id:1422,parameters:[No.TYPE_U8],return:No.TYPE_BOOL,description:"Whether there was a fund operation?",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Has Operation with Pmt",query_id:1423,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation with payment specified?",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Has Operation with Sgr",query_id:1424,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation with singer specified?",parameters_description:["operation","singer address"]},{module:Ao.treasury,query_name:"Has Operation with Pmt/Sgr",query_id:1425,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation?",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Operation at Least Times",query_id:1426,parameters:[No.TYPE_U8,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does it operate at least a certain number of times?",parameters_description:["operation","at least times"]},{module:Ao.treasury,query_name:"Operation at Least Times by a Signer",query_id:1427,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does it operate at least a certain number of times by a signer?",parameters_description:["operation","signer address","at least times"]},{module:Ao.arbitration,query_name:"Permission",query_id:1500,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.arbitration,query_name:"Paused",query_id:1501,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create Arb?"},{module:Ao.arbitration,query_name:"Fee",query_id:1502,parameters:[],return:No.TYPE_U64,description:"Cost of arbitration."},{module:Ao.arbitration,query_name:"Has Endpoint",query_id:1503,parameters:[],return:No.TYPE_BOOL,description:"Is the endpoint set?"},{module:Ao.arbitration,query_name:"Endpoint",query_id:1504,parameters:[],return:No.TYPE_STRING,description:"Endpoint url/ipfs."},{module:Ao.arbitration,query_name:"Has Customer Guard",query_id:1505,parameters:[],return:No.TYPE_BOOL,description:"Is there Guard set to apply for arbitration?"},{module:Ao.arbitration,query_name:"Customer Guard",query_id:1506,parameters:[],return:No.TYPE_ADDRESS,description:"Guard to apply for arbitration."},{module:Ao.arbitration,query_name:"Number of Voting Guard",query_id:1507,parameters:[],return:No.TYPE_U64,description:"Number of voting guards."},{module:Ao.arbitration,query_name:"Has Voting Guard",query_id:1508,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has the voting Guard added?",parameters_description:["guard address"]},{module:Ao.arbitration,query_name:"Voting Weight",query_id:1509,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Voting weight of the voting Guard.",parameters_description:["guard address"]},{module:Ao.arbitration,query_name:"Treasury",query_id:1510,parameters:[],return:No.TYPE_ADDRESS,description:"The address of the Treasury where fees was collected at the time of withdrawal."},{module:Ao.arb,query_name:"Order",query_id:1600,parameters:[],return:No.TYPE_ADDRESS,description:"Order under arbitration."},{module:Ao.arb,query_name:"Arbitration",query_id:1601,parameters:[],return:No.TYPE_ADDRESS,description:"Arbitration object address."},{module:Ao.arb,query_name:"Feedback",query_id:1602,parameters:[],return:No.TYPE_STRING,description:"Arbitration feedback."},{module:Ao.arb,query_name:"Has Compensation",query_id:1603,parameters:[],return:No.TYPE_BOOL,description:"Whether there is an arbitration result?"},{module:Ao.arb,query_name:"Compensation",query_id:1604,parameters:[],return:No.TYPE_U64,description:"Compensation should be given to the order payer."},{module:Ao.arb,query_name:"Unclaimed Arbitration Costs",query_id:1605,parameters:[],return:No.TYPE_U64,description:"Unclaimed arbitration costs."},{module:Ao.arb,query_name:"Turnout",query_id:1606,parameters:[],return:No.TYPE_U64,description:"The number of addresses have voted."},{module:Ao.arb,query_name:"Has voted",query_id:1607,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has someone voted?",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting weight",query_id:1608,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The weight of a complete vote for the address.",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting Time",query_id:1609,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The time of a complete vote for the address.",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting Option",query_id:1610,parameters:[No.TYPE_ADDRESS,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does an address complete voting for the option?",parameters_description:["voter address","option index"]},{module:Ao.arb,query_name:"Number of Options",query_id:1611,parameters:[],return:No.TYPE_U64,description:"Number of voting options."},{module:Ao.arb,query_name:"Number of Votes",query_id:1612,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"The number of votes received for an option.",parameters_description:["option index"]}];var rd;!function(e){e.txn="Txn Functions",e.number="Number Crunching",e.logic="Compare or Logic"}(rd||(rd={}));const sd=[{from:"type",name:"Txn Signer",value:Xo.TYPE_SIGNER,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"Txn Time",value:Xo.TYPE_CLOCK,group:rd.txn,return:No.TYPE_U64},{from:"type",name:"Guard Address",value:Xo.TYPE_GUARD,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber to Address",value:ko.TYPE_NUMBER_ADDRESS,group:rd.number,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber Add (+)",value:ko.TYPE_NUMBER_ADD,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Subtract (-)",value:ko.TYPE_NUMBER_SUBTRACT,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Multiply (*)",value:ko.TYPE_NUMBER_MULTIPLY,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Devide (/)",value:ko.TYPE_NUMBER_DEVIDE,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Mod (%)",value:ko.TYPE_NUMBER_MOD,group:rd.number,return:"number"}];class id{static MAX_INPUT_LENGTH=10240;txb;object;get_object(){return this.object}static From(e,t){let r=new id(e);return r.object=$o.TXB_OBJECT(e,t),r}constructor(e){this.txb=e,this.object=""}static New(e,t,r){r.IsReady()||Ba(Ca.InvalidParam,"launch maker"),io(t)||Ba(Ca.IsValidDesription);let s=r.get_input()[0],i=r.get_constant();(0==s.length||s.length>id.MAX_INPUT_LENGTH)&&Ba(Ca.InvalidParam,"launch input");let n=!0;i?.forEach(((e,t)=>{ad.IsValidIndentifier(t)||(n=!1),e.value&&e.bWitness&&(n=!1),void 0!==e.value||e.bWitness||(n=!1)})),n||Ba(Ca.InvalidParam,"launch constants");let a=new Uint8Array(s),o=new id(e);return o.object=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(t),e.pure.vector("u8",[].slice.call(a.reverse()))]}),i?.forEach(((t,r)=>{if(t.bWitness){const s=new Uint8Array(1);s.set([t.type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}else{const s=Io(t.value,t.type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}})),o}launch(){return this.txb.moveCall({target:$o.Instance().guardFn("create"),arguments:[this.txb.object(this.object)]})}static everyone_guard(e){return e.moveCall({target:$o.Instance().guardFn("everyone_guard"),arguments:[]})}static QueryAddressIdentifiers(e,t,r){const s=new gs;s.moveCall({target:$o.Instance().guardFn("query_address_identifiers"),arguments:[s.object(e)]}),$o.Client().devInspectTransactionBlock({sender:r,transactionBlock:s}).then((e=>{if(e.results&&e.results[0]?.returnValues&&1!==e.results[0]?.returnValues?.length)return void t({err:"not match",txb:s,identifiers:[]});const r=Wa.getInstance().de("vector<u8>",Uint8Array.from(e.results[0].returnValues[0][0]));t({identifiers:r,txb:s})})).catch((e=>{console.log(e),t({err:e,txb:s,identifiers:[]})}))}static BoolCmd=td.filter((e=>e.return===No.TYPE_BOOL));static IsBoolCmd=e=>id.BoolCmd.some((t=>t.query_id==e));static CmdFilter=e=>td.filter((t=>t.return===e));static GetCmd=e=>td.find((t=>t[2]==e));static GetCmdOption=e=>{const t=id.GetCmd(e);return t?{from:"query",name:t[1],value:t[2],group:Po(t[0]),return:t[4]}:t};static GetInputParams=e=>{const t=id.GetCmd(e);return t?t[3]:[]};static GetModuleName=e=>{let t=id.GetCmd(e);return t?Po(t[0]):""};static NumberOptions=()=>[...id.CmdFilter(No.TYPE_U8),...id.CmdFilter(No.TYPE_U64),...id.CmdFilter(No.TYPE_U128),...id.CmdFilter(No.TYPE_U256)].map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))).concat(id.Crunchings);static Signer=sd.find((e=>"Txn Signer"===e.name&&e.value===Xo.TYPE_SIGNER));static Time=sd.find((e=>"Txn Time"===e.name&&e.value===Xo.TYPE_CLOCK));static Guard=sd.find((e=>"Guard Address"===e.name&&e.value===Xo.TYPE_GUARD));static Logics=()=>Uo.map((e=>({from:"type",name:e[1],value:e[0],group:rd.logic,return:No.TYPE_BOOL})));static Crunchings=sd.filter((e=>e.value===ko.TYPE_NUMBER_ADD||e.value===ko.TYPE_NUMBER_SUBTRACT||e.value===ko.TYPE_NUMBER_MULTIPLY||e.value===ko.TYPE_NUMBER_DEVIDE||e.value===ko.TYPE_NUMBER_MOD||e.value===ko.TYPE_NUMBER_ADDRESS));static CommonOptions=e=>id.CmdFilter(e).map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return})));static AllOptions=()=>[...td.map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...sd];static StringOptions=()=>[...id.CmdFilter(No.TYPE_STRING)].map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return})));static BoolOptions=()=>[...id.BoolCmd.map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...id.Logics()];static AddressOptions=()=>[...td.filter((e=>e.return===No.TYPE_ADDRESS)).map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...sd.filter((e=>e.return===No.TYPE_ADDRESS))];static Options=e=>{if("number"===e)return id.NumberOptions();if("any"===e)return id.AllOptions();switch(e){case No.TYPE_BOOL:return id.BoolOptions();case No.TYPE_STRING:return id.StringOptions()}return id.CommonOptions(e)}}const nd=e=>lo(e)&&0!==e;class ad{data=[];type_validator=[];constant=new Map;static _witness_index=1;static _const_index=255;static GetWitnessIndex(){return this._witness_index>=this._const_index&&Ba(Ca.Fail,"too many witness"),ad._witness_index++}static getConstIndex(){return this._const_index<=this._witness_index&&Ba(Ca.Fail,"too many const"),ad._const_index--}static IsValidIndentifier=e=>!(!lo(e)||e<1);constructor(){}add_constant(e,t,r,s=!0){return void 0===r&&(r=void 0===t?ad.GetWitnessIndex():ad.getConstIndex()),this.constant.get(r)||(s&&void 0!==t&&(t=Wa.getInstance().ser(e,t)),this.constant.set(r,{type:e,value:void 0===t?void 0:t,bWitness:void 0===t})),r}add_param(e,t){switch(e){case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U64:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U8:case No.TYPE_VEC_U256:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(e,t)),this.type_validator.push(e);break;case No.TYPE_STRING:case No.TYPE_VEC_U8:t||Ba(Ca.InvalidParam,"param: "+e),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),"string"==typeof t?this.data.push(Wa.getInstance().ser(No.TYPE_STRING,t)):this.data.push(Wa.getInstance().ser(No.TYPE_VEC_U8,t)),this.type_validator.push(e);break;case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_ADDRESS);break;case Xo.TYPE_CLOCK:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_U64);break;case Xo.TYPE_CONSTANT:nd(t)||Ba(Ca.IsValidGuardIdentifier,"add_param param:"+e);var r=this.constant.get(t);r||Ba(Ca.Fail,"identifier not in constant:"+t),this.type_validator.push(r.type),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,t));break;default:Ba(Ca.InvalidParam,"add_param type:"+e)}return this}add_query(e,t,r){let s=td.findIndex((r=>r.module==e&&r.query_name==t));-1==s&&Ba(Ca.InvalidParam,"query_name:"+t),"number"==typeof r?ad.IsValidIndentifier(r)||Ba(Ca.InvalidParam,"object_address_from:"+t):co(r)||Ba(Ca.InvalidParam,"object_address_from:"+t);let i=this.type_validator.length-td[s].parameters.length;i<0&&Ba(Ca.InvalidParam,"offset:"+t);let n=this.type_validator.slice(i);if(qa(n,td[s].parameters)||Ba(Ca.Fail,"array_equal:"+t),this.data.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof r)this.data.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),this.data.push(Wa.getInstance().ser(No.TYPE_ADDRESS,r));else{let e=this.constant.get(r);e||Ba(Ca.Fail,"object_address_from not in constant:"+t),e?.type==No.TYPE_ADDRESS?(this.data.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,r))):Ba(Ca.Fail,"type bWitness not match:"+t)}return this.data.push(Wa.getInstance().ser("u16",td[s].query_id)),this.type_validator.splice(i,td[s].parameters.length),this.type_validator.push(td[s].return),this}add_logic(e,t=2){var r=Uo.find((t=>t[0]===e));r&&(r=r[1]);let s,i=2,n=No.TYPE_BOOL;switch(e){case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-e])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),s=this.type_validator[this.type_validator.length-1];for(let e=2;e<=i;++e)this.type_validator[this.type_validator.length-e]!==s&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_HAS_SUBSTRING:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!==No.TYPE_STRING&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_NOT:i=1,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),this.type_validator[this.type_validator.length-1]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADDRESS:i=1,n=No.TYPE_ADDRESS,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_NUMBER_MOD:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);n=No.TYPE_U256;break;default:Ba(Ca.InvalidParam,"add_logic type invalid:"+r)}return this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),ad.is_multi_input_op(e)&&this.data.push(Wa.getInstance().ser(No.TYPE_U8,t)),this.type_validator.splice(this.type_validator.length-i),this.type_validator.push(n),this}hasIdentifier(e){return this.constant.has(e)}build(e=!1){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL||Ba(Ca.Fail,"type_validator check"),e&&this.add_logic(ko.TYPE_LOGIC_NOT),this.data.push(Xa(Uint8Array,...this.data)),this.data.splice(0,this.data.length-1),this}IsReady(){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL&&1==this.data.length}combine(e,t=!0,r=!1){e.IsReady()&&this.IsReady()||Ba(Ca.Fail,"both should built yet");let s=new ad;this.constant.forEach(((e,t)=>{s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})})),e.constant.forEach(((e,t)=>{s.constant.has(t)&&!r&&Ba(Ca.Fail,"constant identifier exist"),s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})}));let i=t?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return s.data.push(Xa(Uint8Array,...this.data,...e.data,Wa.getInstance().ser(No.TYPE_U8,i),Wa.getInstance().ser(No.TYPE_U8,2))),this.data.splice(0,this.data.length-1),s.type_validator=this.type_validator,s}get_constant(){return this.constant}get_input(){return this.data}static input_combine(e,t,r=!0){let s=r?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return Xa(Uint8Array,e,t,Wa.getInstance().ser(No.TYPE_U8,s),Wa.getInstance().ser(No.TYPE_U8,2))}static input_not(e){return Xa(Uint8Array,e,Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_LOGIC_NOT))}static match_u256(e){return e==No.TYPE_U8||e==No.TYPE_U64||e==No.TYPE_U128||e==No.TYPE_U256}static is_multi_input_op(e){return e===ko.TYPE_LOGIC_AS_U256_GREATER||e===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_EQUAL||e===ko.TYPE_LOGIC_EQUAL||e===ko.TYPE_LOGIC_HAS_SUBSTRING||e===ko.TYPE_LOGIC_AND||e===ko.TYPE_LOGIC_OR||e===ko.TYPE_NUMBER_ADD||e===ko.TYPE_NUMBER_DEVIDE||e===ko.TYPE_NUMBER_MULTIPLY||e===ko.TYPE_NUMBER_SUBTRACT||e===ko.TYPE_NUMBER_MOD}}var od,dd,cd,ud,hd,pd,ld;!function(e){e[e.POLICY_MODE_FREE=0]="POLICY_MODE_FREE",e[e.POLICY_MODE_STRICT=1]="POLICY_MODE_STRICT"}(od||(od={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.WOWOK_GRANTEE=1]="WOWOK_GRANTEE",e[e.WOWOK_ORACLE=2]="WOWOK_ORACLE"}(dd||(dd={}));class md{permission;object;txb;get_object(){return this.object}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static From(e,t,r){let s=new md(e,t);return s.object=$o.TXB_OBJECT(e,r),s}static New(e,t,r,s=od.POLICY_MODE_FREE,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription);let n=new md(e,t);return n.object=i?e.moveCall({target:$o.Instance().repositoryFn("new_with_passport"),arguments:[i,e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().repositoryFn("new"),arguments:[e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().repositoryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_data(e){md.IsValidName(e.key)||Ba(Ca.IsValidName,"add_data");let t=!0;e.data.forEach((e=>{co(e.address)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}add_data2(e){co(e.address)||Ba(Ca.IsValidAddress,"add_data2");let t=!0;e.data.forEach((e=>{md.IsValidName(e.key)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data2"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}remove(e,t){md.IsValidName(t)||Ba(Ca.IsValidName),co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().repositoryFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}add_reference(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_reference"),t?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_reference(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_reference"),t?r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}add_policies(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{io(e.description)&&md.IsValidName(e.key)||(r=!1)})),r||Ba(Ca.InvalidParam,"policies"),e.forEach((e=>{let r=this.txb.pure.option("u64",e?.permissionIndex?e?.permissionIndex:void 0);t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]})}))}remove_policies(e,t,r){0!==e.length&&(To(e,md.IsValidName)||Ba(Ca.InvalidParam,"policy_keys"),r?t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}rename_policy(e,t,r){no(e)&&no(t)||Ba(Ca.IsValidName,"change_policy"),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().repositoryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_mode(e,t){t?this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_description(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy"),io(t)||Ba(Ca.IsValidDesription),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_permission(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy");let s=this.txb.pure.option("u64",void 0);void 0!==t&&(Qo.IsValidPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex),s=this.txb.pure.option("u64",t)),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().repositoryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}static MAX_POLICY_COUNT=120;static MAX_KEY_LENGTH=128;static MAX_VALUE_LENGTH=204800;static MAX_REFERENCE_COUNT=100;static IsValidName=e=>e.length<=md.MAX_KEY_LENGTH&&0!=e.length;static IsValidValue=e=>e.length<md.MAX_VALUE_LENGTH;static rpc_de_data(e){const t=e?.map((e=>{const t=new Uint8Array(e?.data?.content?.fields?.value),r=t?.length>0?t[0]:null;var s=t.length>0?t.slice(1):Uint8Array.from([]);return r===No.TYPE_STRING?(s=Wa.getInstance().de(No.TYPE_VEC_U8,s),s=(new TextDecoder).decode(Uint8Array.from(s))):r===No.TYPE_VEC_STRING?s=(s=Wa.getInstance().de(No.TYPE_VEC_VEC_U8,s)).map((e=>(new TextDecoder).decode(Uint8Array.from(e)))):(s=Wa.getInstance().de(t[0],s),r===No.TYPE_ADDRESS?s="0x"+s:r===No.TYPE_VEC_ADDRESS?s=s.map((e=>"0x"+e)):r===No.TYPE_BOOL&&(s=s?"True":"False")),{object:e?.data?.content?.fields?.id?.id,id:e?.data?.content?.fields?.name?.fields?.id,name:e?.data?.content?.fields?.name?.fields?.key,data:s,dataType:Ua(r)}}));return t}static DataType2ValueType(e){try{const t=BigInt(e);if(No.TYPE_U8,t<=Sa);else if(t<=Pa)No.TYPE_U64;else if(t<=ja)No.TYPE_U128;else{if(!(t<=Aa))return;No.TYPE_U256}}catch(e){console.log(e)}}static ResolveRepositoryData=(e,t)=>{if(e===Do.String)return{type:No.TYPE_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_U8,(new TextEncoder).encode(t.toString()))};if(e===Do.PositiveNumber){const e=md.DataType2ValueType(t);if(!e)return;return{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.Address){if(!co(t))return;return{type:No.TYPE_ADDRESS,data:Wa.getInstance().ser(No.TYPE_ADDRESS,t)}}if(e===Do.Address_Vec){for(let e=0;e<t.length;++e)if(!co(t[e]))return;return{type:No.TYPE_VEC_ADDRESS,data:Wa.getInstance().ser(No.TYPE_VEC_ADDRESS,t)}}if(e===Do.PositiveNumber_Vec){let e=No.TYPE_U8;for(let r=0;r<t.length;++r){const r=md.DataType2ValueType(t);if(!r)return;r>e&&(e=r)}return e=e===No.TYPE_U8?No.TYPE_VEC_U8:e===No.TYPE_U64?No.TYPE_VEC_U64:e===No.TYPE_U128?No.TYPE_VEC_U128:No.TYPE_VEC_U256,{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.String_Vec){const e=t.map((e=>(new TextEncoder).encode(e)));return{type:No.TYPE_VEC_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_VEC_U8,e)}}if(e===Do.Bool){if("boolean"!=typeof t)return;return{type:No.TYPE_BOOL,data:Wa.getInstance().ser(No.TYPE_BOOL,t)}}}}class _d{guard_list=[];guards;constructor(e){this.guards=e}guardlist=()=>this.guard_list;static DeGuardObject_FromData=(e,t)=>{let r=_d.parse_constant(e),s=_d.parse_bcs(r,t);s&&0!=s.length||Ba(Ca.Fail,"GuardObject: data parsed error");let i=[];return s.forEach((e=>{_d.ResolveData(r,i,{...e,child:[]})})),1!=i.length&&Ba(Ca.Fail,"GuardObject: parse error"),{object:i.pop(),constant:r}};static DeGuardObject=async(e,t)=>{co(t)||Ba(Ca.IsValidAddress,"GuardObject guard");let r=await e.query_raw([t]);0!=r.length&&r[0].data&&r[0].data?.objectId==t||Ba(Ca.Fail,"GuardObject query error");let s=r[0].data.content;return s?.type!=e.package("base")+"::guard::Guard"&&Ba(Ca.Fail,"GuardObject object invalid"),_d.DeGuardObject_FromData(s.fields.constants,s.fields.input.fields.bytes)};static ResolveData=(e,t,r)=>{switch(r.type){case ko.TYPE_LOGIC_NOT:return r.ret_type=No.TYPE_BOOL,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT"),(s=t.pop()).ret_type&&s.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_NUMBER_ADDRESS:var s;return r.ret_type=No.TYPE_ADDRESS,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS"),(s=t.pop()).ret_type&&ad.match_u256(s.ret_type)||Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:r.type===ko.TYPE_LOGIC_AS_U256_GREATER||r.type===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_LESSER||r.type===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_EQUAL?r.ret_type=No.TYPE_BOOL:r.ret_type=No.TYPE_U256,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&ad.match_u256(n.ret_type)||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_EQUAL:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);var i=t.pop();r.child.push(i);for(let e=1;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==i.ret_type||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_HAS_SUBSTRING:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==No.TYPE_STRING||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e){var n;(n=t.pop()).ret_type&&n.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n)}return void t.push(r);case ko.TYPE_QUERY:r?.cmd||Ba(Ca.Fail,"OperateParamCount: cmd invalid "+r.type);let a=id.GetCmd(r.cmd);return a||Ba(Ca.Fail,"OperateParamCount: cmd not supported "+r.type),r.ret_type=a[4],t.length<a[3].length&&Ba(Ca.Fail,"OperateParamCount: cmd param lost "+r.type),a[3].forEach((e=>{let s=t.pop();s?.ret_type&&s.ret_type==e||Ba(Ca.Fail,"OperateParamCount: cmd param not match "+r.type),r.child.push(s)})),void t.push(r);case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_U64:case No.TYPE_U8:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U256:case No.TYPE_VEC_U64:case No.TYPE_VEC_U8:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U8:case No.TYPE_STRING:return r.ret_type=r.type,void t.push(r);case Xo.TYPE_CLOCK:return r.ret_type=No.TYPE_U64,void t.push(r);case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:return r.ret_type=No.TYPE_ADDRESS,void t.push(r);case Xo.TYPE_CONSTANT:let o=e.find((e=>e.identifier==r?.identifier));return o||Ba(Ca.Fail,"OperateParamCount: identifier invalid "+r.type),r.ret_type=o?.type,void t.push(r)}Ba(Ca.Fail,"OperateParamCount: type invalid "+r.type)};static Parse_Guard_Helper(e,t){const r=$o.Instance(),s=new _d(e);return t.forEach((e=>{const t=e.data?.content;if(t||Ba(Ca.Fail,"Parse_Guard_Helper invalid content"),-1===r.WOWOK_OBJECTS_TYPE().findIndex((e=>e.includes("guard::Guard")&&e==t.type))&&Ba(Ca.Fail,"Parse_Guard_Helper invalid type: "+t.type),t.fields.input.type===r.package("base")+"::bcs::BCS"){const r=_d.parse_constant(t.fields.constants),i=_d.parse_bcs(r,Uint8Array.from(t.fields.input.fields.bytes));s.guard_list.push({id:t.fields.id.id,input:[...i],constant:[...r],digest:e.data?.digest??"",version:e.data?.version??""})}else Ba(Ca.Fail,"Parse_Guard_Helper invalid package: "+t.fields.input.type)})),s}static Create=async(e,t)=>{if(!To(e,co))return void(t&&t(void 0));let r=Ga(e);if(!t){const t=await $o.Instance().query_raw(r);return _d.Parse_Guard_Helper(e,t)}$o.Instance().query_raw(r).then((r=>{t(_d.Parse_Guard_Helper(e,r))})).catch((e=>{console.log(e),t(void 0)}))};future_fills=()=>{const e=[];return this.guard_list.forEach((t=>{t.constant.filter((e=>e.bWitness)).forEach((r=>{const s=t.input.filter((e=>e.identifier===r.identifier&&void 0!==e.cmd)).map((e=>e.cmd));let i=0;t.input.forEach((e=>{e.identifier===r.identifier&&i++})),e.push({guard:t.id,witness:void 0,identifier:r.identifier,type:r.type,cmd:s??[],cited:i})}))})),e};static parse_constant=e=>{let t=[];return e.forEach((e=>{let r=e?.fields??e;const s=Uint8Array.from(r.value),i=s.slice(0,1)[0];if(r.bWitness)t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:void 0});else{var n=s.slice(1);switch(i){case No.TYPE_ADDRESS:n="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(n)).toString();break;case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_U8:case No.TYPE_VEC_U64:case No.TYPE_VEC_U128:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U256:case No.TYPE_VEC_U256:case No.TYPE_STRING:case No.TYPE_OPTION_STRING:case No.TYPE_OPTION_VEC_U8:case No.TYPE_VEC_STRING:Lo.find((e=>e.type==i))||Ba(Ca.Fail,"GuardObject de error"),n=Wa.getInstance().de(i,Uint8Array.from(n));break;default:Ba(Ca.Fail,"GuardObject constant type invalid:"+i)}t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:n})}})),t};static parse_bcs=(e,t)=>{let r=Uint8Array.from(t),s=[].slice.call(r.reverse()),i=[];for(;s.length>0;){let t,r,n,a=s.shift();switch(a){case Xo.TYPE_SIGNER:case Xo.TYPE_CLOCK:case Xo.TYPE_GUARD:case ko.TYPE_LOGIC_NOT:case ko.TYPE_NUMBER_ADDRESS:break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_LOGIC_EQUAL:case ko.TYPE_LOGIC_HAS_SUBSTRING:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:t=s.shift();break;case Xo.TYPE_CONSTANT:n=s.shift();break;case No.TYPE_ADDRESS:t="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString(),s.splice(0,32);break;case No.TYPE_BOOL:case No.TYPE_U8:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.shift();break;case No.TYPE_U64:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8);break;case No.TYPE_U128:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16);break;case No.TYPE_U256:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32);break;case No.TYPE_VEC_U8:case No.TYPE_VEC_BOOL:case No.TYPE_STRING:let i=Ra(Uint8Array.from(s));t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,i.value+i.length);break;case No.TYPE_VEC_ADDRESS:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U128:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16*i.value+i.length);break;case No.TYPE_VEC_U256:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U64:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8*i.value+i.length);break;case No.TYPE_VEC_VEC_U8:case No.TYPE_VEC_STRING:i=Ra(Uint8Array.from(s)),s.splice(0,i.length);let o=[];for(let e=0;e<i.value;e++){let e=Ra(Uint8Array.from(s));o.push(Wa.getInstance().de(No.TYPE_VEC_U8,Uint8Array.from(s))),s.splice(0,e.length+e.value)}t=o;break;case ko.TYPE_QUERY:let d=s.splice(0,1);if(d[0]==No.TYPE_ADDRESS){let e="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString();s.splice(0,32),t=e,r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else if(d[0]==Xo.TYPE_CONSTANT){let t=s.splice(0,1);e.find((e=>e.identifier==t[0]&&e.type==No.TYPE_ADDRESS))||Ba(Ca.Fail,"GuardObject: indentifier not in constant"),n=t[0],r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else Ba(Ca.Fail,"GuardObject: constant type invalid");break;case No.TYPE_OPTION_ADDRESS:let c=Na(s,No.TYPE_ADDRESS);t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_BOOL:c=Na(s,No.TYPE_BOOL),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U8:c=Na(s,No.TYPE_U8),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U128:c=Na(s,No.TYPE_U128),t=c.value,c.bNone||s.splice(0,16);break;case No.TYPE_OPTION_U256:c=Na(s,No.TYPE_U256),t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_U64:c=Na(s,No.TYPE_U64),t=c.value,c.bNone||s.splice(0,8);break;case No.TYPE_OPTION_STRING:c=Da(s),t=c.value;break;default:Ba(Ca.Fail,"GuardObject: parse_bcs types "+a)}i.push({type:a,value:t,cmd:r,identifier:n})}return i};done=async(e,t)=>{let r=[];if(this.guard_list.forEach((t=>{t.constant.forEach((t=>{if(t.bWitness){const r=e?.find((e=>e.identifier===t.identifier));r?t.value=r.witness:Ba(Ca.Fail,"done: invalid witness "+t.identifier)}})),t.input.filter((e=>void 0!==e.cmd)).forEach((e=>{if(void 0!==e.identifier){const s=t.constant.find((t=>t.identifier===e.identifier&&t.type===No.TYPE_ADDRESS));s&&co(s.value)||Ba(Ca.Fail,"done: invalid identifier "+e.identifier),r.push(s.value)}else r.push(e.value)}))})),t)return 0===r.length?void t(this.done_helper([])):void $o.Instance().query_raw(Ga(r),{showType:!0}).then((e=>{t(this.done_helper(e))})).catch((e=>{console.log(e),t(void 0)}));{let e=[];return r.length>0&&(e=await $o.Instance().query_raw(Ga(r),{showType:!0})),this.done_helper(e)}};done_helper(e){let t=[],r=[];return this.guard_list.forEach((s=>{r.push(s.id),s.input.filter((e=>void 0!==e.cmd)).forEach((r=>{let i=r.value;i||void 0===r.identifier||(i=s.constant.find((e=>e.identifier==r.identifier))?.value);let n=e.find((e=>e.data?.objectId==i));n||Ba(Ca.Fail,"query object not match");let a=this.object_query(n.data);a||Ba(Ca.Fail,"query object fail"),t.push(a)}))})),{query:t,info:this.guard_list}}object_query=(e,t="guard_query")=>{for(let r=0;r<$o.Instance().WOWOK_OBJECTS_TYPE().length;r++)if(e.type.includes($o.Instance().WOWOK_OBJECTS_TYPE()[r]))return{target:$o.Instance().WOWOK_OBJECTS_PREFIX_TYPE()[r]+t,object:ct({objectId:e.objectId,mutable:!1,initialSharedVersion:e.version}),types:za(e.type),id:e.objectId}}}class bd{static MAX_GUARD_COUNT=8;passport;txb;get_object(){return this.passport}constructor(e,t,r=!1){(0===t.info.length||t.info.length>bd.MAX_GUARD_COUNT)&&Ba(Ca.InvalidParam,"guards"),this.txb=e,this.passport=this.txb.moveCall({target:$o.Instance().passportFn("new"),arguments:[]}),t.info.forEach((t=>{const r=t.constant.filter((e=>e.bWitness)).map((e=>e.identifier)),s=t.constant.filter((e=>e.bWitness)).map((e=>{const t=Wa.getInstance().ser(e.type,e.value);let r=new Uint8Array(t.length+1);return r.set([e.type],0),r.set(t,1),[].slice.call(r)})),i=void 0!==t.version&&void 0!==t.digest?e.objectRef({objectId:t.id,version:t.version,digest:t.digest}):e.object(t.id);this.txb.moveCall({target:$o.Instance().passportFn("guard_add"),arguments:[this.passport,i,this.txb.pure.vector("u8",[].slice.call(r)),this.txb.pure(Wa.getInstance().ser("vector<vector<u8>>",[...s]))]})}));const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?.query.forEach((e=>{this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]}),this.txb.moveCall({target:e.target,arguments:[r?this.txb.object(e.object):this.txb.object(e.id),this.passport],typeArguments:e.types})})),this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]})}destroy(){this.txb.moveCall({target:$o.Instance().passportFn("destroy"),arguments:[this.passport]})}freeze(){this.txb.moveCall({target:$o.Instance().passportFn("freezen"),arguments:[this.passport]})}query_result(e,t){this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]}),$o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb}).then((e=>{const r=bd.ResolveQueryRes(this.txb,e);r&&t(r)})).catch((e=>{console.log(e)}))}query_result_async=async e=>{this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]});const t=await $o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb});return bd.ResolveQueryRes(this.txb,t)};static ResolveQueryRes(e,t){for(let r=0;r<t.results?.length;++r){const s=t.results[r];if(s?.returnValues&&2===s.returnValues.length&&"bool"===s.returnValues[0][1]&&"vector<address>"===s.returnValues[1][1])return{txb:e,result:Wa.getInstance().de("bool",Uint8Array.from(s.returnValues[0][0])),guards:Wa.getInstance().de("vector<address>",Uint8Array.from(s.returnValues[1][0])).map((e=>"0x"+e))}}}}!function(e){e[e.ratio=0]="ratio",e[e.minus=1]="minus"}(cd||(cd={})),function(e){e.address="address",e.phone="phone",e.name="name",e.postcode="postcode"}(ud||(ud={}));class gd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new gd(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n){$o.IsValidObjects([r,i])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New: pay_token_type"),io(s)||Ba(Ca.IsValidDesription);let a=t,o=new gd(e,a,r);return o.object=n?e.moveCall({target:$o.Instance().serviceFn("new_with_passport"),arguments:[n,e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}):e.moveCall({target:$o.Instance().serviceFn("new"),arguments:[e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}),o}launch(){return this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().serviceFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_price(e,t,r=!0,s){mo(t)||Ba(Ca.IsValidU64,"set_price price"),gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_price item"),s?this.txb.moveCall({target:$o.Instance().serviceFn("price_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("price_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"item"),mo(t)||Ba(Ca.IsValidU64,"stock"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"add_stock item"),mo(t)||Ba(Ca.IsValidUint,"add_stock stock_add"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_add_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}reduce_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"reduce_stock item"),mo(t)||Ba(Ca.IsValidUint,"reduce_stock stock_reduce"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_sale_endpoint(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_sale_endpoint item"),t&&!oo(t)&&Ba(Ca.IsValidEndpoint,"set_sale_endpoint endpoint");let i=this.txb.pure.option("string",t||void 0);s?this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_payee(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_payee"),t?this.txb.moveCall({target:$o.Instance().serviceFn("payee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("payee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_repository(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"repository_add"),t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_add_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"repository_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_arbitration(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"add_arbitration.arbitraion"),go(t)||Ba(Ca.IsValidTokenType,"add_arbitration.arbitraion_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]})}remove_arbitration(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_arbitration.address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_withdraw_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_withdraw_guards(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_refund_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_refund_guards(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.InvalidParam,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}is_valid_sale(e){let t=!0,r=[];return e.forEach((e=>{gd.IsValidItemName(e.item)||(t=!1),mo(e.price)||(t=!1),mo(e.stock)||(t=!1),r.includes(e.item)&&(t=!1),r.push(e.item)})),t}add_sales(e,t=!1,r){if(0===e.length)return;this.is_valid_sale(e)||Ba(Ca.InvalidParam,"add_sales");let s=[],i=[],n=[],a=[];e.forEach((e=>{e.endpoint&&!oo(e.endpoint)&&Ba(Ca.IsValidEndpoint,"add_sales"),s.push(e.item),i.push(e.price),n.push(e.stock),a.push(e.endpoint??"")})),r?this.txb.moveCall({target:$o.Instance().serviceFn("sales_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_sales(e,t){0!==e.length&&(To(e,gd.IsValidItemName)||Ba(Ca.IsValidArray,"remove_sales"),t?this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}discount_transfer(e,t){(!e||e.length>gd.MAX_DISCOUNT_RECEIVER_COUNT)&&Ba(Ca.InvalidParam,"discount_dispatch");let r=!0;e.forEach((e=>{co(e.receiver)||(r=!1),(!mo(e.count)||e.count>gd.MAX_DISCOUNT_COUNT_ONCE)&&(r=!1),ao(e.discount.name)||(r=!1),e.discount.type!=cd.ratio||vo(e.discount.off)||(r=!1),mo(e.discount.duration_minutes)||(r=!1),e.discount?.time_start&&!mo(e.discount.time_start)&&(r=!1),e.discount?.price_greater&&!mo(e.discount.price_greater)&&(r=!1)})),r||Ba(Ca.InvalidParam,"discount_dispatch");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e.forEach((e=>{let r=this.txb.pure.option("u64",e.discount?.price_greater?e.discount?.price_greater:void 0),i=this.txb.pure.option("u64",e.discount?.time_start?e.discount?.time_start:void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]})}))}withdraw(e,t,r){$o.IsValidObjects([e,t.treasury,t.withdraw_guard,r])||Ba(Ca.IsValidObjects),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t.for_guard?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_buy_guard(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_machine(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}publish(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}clone(e,t,r){let s;return s=r?this.txb.moveCall({target:$o.Instance().serviceFn("clone_withpassport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}),t?this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,s)],typeArguments:[e||this.pay_token_type]}):s}set_customer_required(e,t,r){t.length>0&&!e&&Ba(Ca.InvalidParam,"set_customer_required"),e.length>gd.MAX_PUBKEY_SIZE&&Ba(Ca.InvalidParam,"set_customer_required.pubkey"),t.length>gd.MAX_REQUIRES_COUNT&&Ba(Ca.InvalidParam,"set_customer_required.customer_required"),To(t,no)||Ba(Ca.IsValidArray,"set_customer_required.customer_required");let s=Ga(t);r?this.txb.moveCall({target:$o.Instance().serviceFn("required_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_customer_required(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("required_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}change_required_pubkey(e,t){e||Ba(Ca.InvalidParam,"pubkey"),t?this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().serviceFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}refund_withArb(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"refund_withArb.order or arb"),go(r)||Ba(Ca.IsValidTokenType,"refund_withArb.arb_type");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_arb"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),this.txb.object(s)],typeArguments:[this.pay_token_type,r]})}refund(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"refund.order"),t&&!$o.IsValidObjects([t])&&Ba(Ca.IsValidObjects,"refund.refund_guard"),r&&!t&&Ba(Ca.InvalidParam,"refund.passport need refund_guard");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);r&&t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),r,this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}update_order_required_info(e,t){t.customer_pubkey&&0!==t.customer_info_crypt.length&&($o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"update_order_required_info.order"),this.txb.moveCall({target:$o.Instance().serviceFn("order_required_info_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(t.customer_pubkey),this.txb.pure.string(t.customer_info_crypt)],typeArguments:[this.pay_token_type]}))}order(e,t,r,s,i,n){0===e.length&&Ba(Ca.InvalidParam,"order.buy_items empty");let a=!0,o=[];e.forEach((e=>{gd.IsValidItemName(e.item)||(a=!1),mo(e.max_price)||(a=!1),mo(e.count)||(a=!1),o.includes(e.item)&&(a=!1),o.push(e.item)})),a||Ba(Ca.InvalidParam,"buy_items invalid");let d,c=[],u=[],h=[];e.forEach((e=>{c.push(e.item),u.push(BigInt(e.max_price)),h.push(BigInt(e.count))}));const p=this.txb.sharedObjectRef($o.CLOCK_OBJECT);d=n?r?this.txb.moveCall({target:$o.Instance().serviceFn("dicount_buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(p)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}):r?this.txb.moveCall({target:$o.Instance().serviceFn("disoucnt_buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(p)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}),i&&this.update_order_required_info(d,i);var l=void 0;return s&&(l=this.order_bind_machine(d,s)),{order:d,progress:l}}order_launch(e){var t;return e.progress&&(t=this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e.progress)]})),{order:this.txb.moveCall({target:$o.Instance().serviceFn("order_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.order)],typeArguments:[this.pay_token_type]}),progress:t}}buy(e,t,r,s,i,n){const a=this.order(e,t,r,s,i,n);return this.order_launch(a)}order_bind_machine(e,t){return $o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"order & machine"),this.txb.moveCall({target:$o.Instance().serviceFn("order_bind_machine"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]})}add_treasury(e,t,r){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"add_treasury.treasury"),go(e)||Ba(Ca.IsValidTokenType,"add_treasury.treasury_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]})}remove_treasury(e,t,r){(t||0!==e.length)&&(r?t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().serviceFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}set_order_agent(e,t,r){gd.SetOrderAgent(this.txb,this.pay_token_type,e,t,r)}change_order_payer(e,t,r){gd.ChangeOrderPayer(this.txb,this.pay_token_type,e,t,r)}static MAX_DISCOUNT_COUNT_ONCE=200;static MAX_DISCOUNT_RECEIVER_COUNT=20;static MAX_GUARD_COUNT=16;static MAX_REPOSITORY_COUNT=32;static MAX_ITEM_NAME_LENGTH=256;static MAX_TREASURY_COUNT=8;static MAX_ORDER_AGENT_COUNT=8;static MAX_ORDER_ARBS_COUNT=8;static MAX_ARBITRATION_COUNT=8;static MAX_REQUIRES_COUNT=16;static MAX_PUBKEY_SIZE=3e3;static IsValidItemName(e){return!!e&&(new TextEncoder).encode(e).length<=gd.MAX_ITEM_NAME_LENGTH}static parseObjectType=e=>La(e,"service::Service<");static parseOrderObjectType=e=>La(e,"order::Order<");static endpoint=(e,t,r)=>t||(e?e+"/sales/"+encodeURI(r):void 0);static DiscountObjects=(e,t)=>{$o.Client().getOwnedObjects({owner:e,filter:{MoveModule:{module:"order",package:$o.Instance().package("wowok")}},options:{showContent:!0,showType:!0}}).then((r=>{t(e,r.data.map((e=>e.data)))})).catch((e=>{console.log(e)}))};static SetOrderAgent=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"SetOrderAgent.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"SetOrderAgent.order"),To(s,co)||Ba(Ca.IsValidArray,"SetOrderAgent.agent"),Ga(s).length>gd.MAX_ORDER_AGENT_COUNT&&Ba(Ca.Fail,"SetOrderAgent.agent count"),e.moveCall({target:$o.Instance().orderFn("agent_set"),arguments:[e.object(r),e.pure.vector("address",Ga(s))],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})};static ChangeOrderPayer=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"ChangeOrderPayer.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"ChangeOrderPayer.order"),co(s)||Ba(Ca.IsValidAddress,"ChangeOrderPayer.new_addr"),e.moveCall({target:$o.Instance().orderFn("payer_change"),arguments:[e.object(r),e.pure.address(s)],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})}}class yd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new yd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectEntity()),t}mark(e,t,r){"string"!=typeof t||co(t)||Ba(Ca.IsValidAddress,r),this.txb.moveCall({target:$o.Instance().entityFn(r),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),"string"==typeof t?this.txb.pure.address(t):t]})}update(e){e?.name&&!no(e.name)&&Ba(Ca.IsValidName,"update"),e?.description&&!io(e.description)&&Ba(Ca.IsValidDesription,"update"),e?.avatar&&!Bo(e.avatar)&&Ba(Ca.isValidHttpUrl,"update:avatar"),e?.twitter&&!no(e.twitter)&&Ba(Ca.IsValidName,"update:twitter"),e?.homepage&&!Bo(e.homepage)&&Ba(Ca.isValidHttpUrl,"update:homepage"),e?.discord&&!no(e.discord)&&Ba(Ca.IsValidName,"update:discord");const t=Wa.getInstance().bcs.ser("PersonalInfo",{name:e.name?(new TextEncoder).encode(e.name):"",description:e?.description?(new TextEncoder).encode(e.description):"",avatar:e?.avatar??"",twitter:e?.twitter??"",discord:e?.discord??"",homepage:e?.homepage??""}).toBytes();this.txb.moveCall({target:$o.Instance().entityFn("avatar_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("u8",[].slice.call(t))]})}create_resource(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}create_resource2(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create2"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}destroy_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_destroy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}use_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_use"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}transfer_resource(e,t){return co(t)||Ba(Ca.IsValidAddress,"transfer_resource"),this.txb.moveCall({target:$o.Instance().entityFn("resource_transfer"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),this.txb.pure.address(t)]})}query_ent(e){co(e)||Ba(Ca.InvalidParam,"query_ent"),this.txb.moveCall({target:$o.Instance().entityFn("QueryEnt"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}}class fd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new fd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectWowok()),t}register_grantor(e,t){no(e)||Ba(Ca.IsValidName,"register_grantor"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"register_grantor");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().wowokFn("grantor_register"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.object(r),$o.TXB_OBJECT(this.txb,t)]})}grantor_time_expand_1year(e){co(e)||Ba(Ca.IsValidAddress,"grantor_time_expand_1year"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}grantor_rename(e){no(e)||Ba(Ca.IsValidName,"grantor_rename"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}mint(e,t){co(t)||Ba(Ca.IsValidAddress,"mint"),mo(e)||Ba(Ca.IsValidU64,"mint"),this.txb.moveCall({target:$o.Instance().baseWowokFn("mint"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectTreasuryCap()),this.txb.pure.u64(e),this.txb.pure.address(t)]})}oracle(e,t){return io(e)||Ba(Ca.IsValidDesription,"oracle.description"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"oracle.permission"),this.txb.moveCall({target:$o.Instance().wowokFn("oracle_repository"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectOracle()),this.txb.pure.string(e),this.txb.object(t)]})}}!function(e){e.Like="like",e.Dislike="dislike",e.Launch="launch",e.Order="order",e.Payment="payment"}(hd||(hd={}));class vd{static MAX_ADDRESS_COUNT_FOR_TAG=1e3;static MAX_TAG_COUNT_FOR_ADDRESS=64;object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new vd(e);return r.object=$o.TXB_OBJECT(e,t),r}launch(){return this.object||Ba(Ca.Fail,"launch object Invalid"),this.txb.moveCall({target:$o.Instance().resourceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}resolve_add(e,t){return t.find((e=>e===hd.Like))&&yd.From(this.txb).mark(this,e,hd.Like),t.find((e=>e===hd.Dislike))&&yd.From(this.txb).mark(this,e,hd.Dislike),t.filter((e=>e!==hd.Like&&e!==hd.Dislike&&no(e)))}add(e,t,r){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: add.address");var s=this.resolve_add(e,t);(r||0!==s.length)&&(r&&!no(r)&&Ba(Ca.IsValidName,"Resource: add.name"),s.length>vd.MAX_TAG_COUNT_FOR_ADDRESS&&(s=s.slice(0,vd.MAX_TAG_COUNT_FOR_ADDRESS)),this.txb.moveCall({target:$o.Instance().resourceFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.option("string",r),this.txb.pure.vector("string",s)]}))}remove(e,t){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: remove.address"),this.txb.moveCall({target:$o.Instance().resourceFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.vector("string",t)]})}removeall(e){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: removeall.address"),this.txb.moveCall({target:$o.Instance().resourceFn("removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e]})}static TagData(e,t=!0){const r=[];return e.forEach((e=>{e.tags.forEach((t=>{const s=r.find((e=>e.tag===t));s?s.address.find((t=>t===e.address))||s.address.push(e.address):r.push({tag:t,address:[e.address]})}))})),t&&Object.keys(hd).forEach((e=>{r.find((t=>t.tag===hd[e]))||r.push({tag:hd[e],address:[]})})),r}static Tags(e){const t=[];return e.address.forEach((r=>{const s=t.find((e=>e.address===r));s?s.tags.find((t=>t===e.tag))||s.tags.push(e.tag):t.push({address:r,tags:[e.tag]})})),t}}!function(e){e[e.PERMISSION=0]="PERMISSION",e[e.GUARD_ONLY_AND_IMMUTABLE=1]="GUARD_ONLY_AND_IMMUTABLE",e[e.BOTH_PERMISSION_AND_GUARD=2]="BOTH_PERMISSION_AND_GUARD"}(pd||(pd={})),function(e){e[e.WITHDRAW=1]="WITHDRAW",e[e.DEPOSIT=2]="DEPOSIT",e[e.RECEIVE=4]="RECEIVE"}(ld||(ld={}));class Td{token_type;permission;object;txb;get_token_type(){return this.token_type}get_object(){return this.object}static From(e,t,r,s){let i=new Td(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.token_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"Treasury.New permission, bounty"),io(s)||Ba(Ca.IsValidDesription,"Treasury.New.description"),yo(t)||Ba(Ca.IsValidArgType,t);let n=new Td(e,t,r);return n.object=i?e.moveCall({target:$o.Instance().treasuryFn("new_with_passport"),arguments:[i,e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}):e.moveCall({target:$o.Instance().treasuryFn("new"),arguments:[e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}),n}launch(){return this.txb.moveCall({target:$o.Instance().treasuryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.token_type]})}set_deposit_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_deposit_guard.guard"),t?e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}deposit(e,t){$o.IsValidObjects([e.coin])||Ba(Ca.IsValidObjects,"deposit.param.coin"),io(e.remark)||Ba(Ca.IsValidDesription,"deposit.param.remark"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"deposit.param.for_object"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"deposit.param.for_guard"),void 0===e.index||mo(e.index)||Ba(Ca.InvalidParam,"deposit.param.index");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}receive(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidArray,"receive.payment&received");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().treasuryFn("receive_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("receive"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}withdraw(e,t){if(0===e.items.length)return;To(e.items,(e=>mo(e.amount)&&co(e.address)))||Ba(Ca.IsValidArray,"withdraw.param.items"),io(e.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark"),mo(e.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.for_guard"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),e?.withdraw_guard&&!co(e.withdraw_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard"),e?.withdraw_guard&&!t&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return e.withdraw_guard&&t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard_forGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().treasuryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_withdraw_mode(e,t){t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}add_withdraw_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"add_withdraw_guard.guard"),mo(t)||Ba(Ca.IsValidU64,"add_withdraw_guard.amount"),r?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}remove_withdraw_guard(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"add_withdraw_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"change_permission.new_permission"),this.txb.moveCall({target:$o.Instance().treasuryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.token_type]}),this.permission=e}static parseObjectType=e=>La(e,"treasury::Treasury<");static MAX_WITHDRAW_GUARD_COUNT=16}const Ed=200;function wd(e,t,r){t||Ba(Ca.InvalidParam,"Payment.New.pay_token_type"),r.receiver.length>Ed&&Ba(Ca.InvalidParam,"Payment.New.param.receiver"),To(r.receiver,(e=>co(e.address)&&$o.IsValidObjects([e.coin])))||Ba(Ca.IsValidArray,"Payment.New.param.receiver"),r?.for_object&&!co(r.for_object)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_object"),r?.for_guard&&!co(r.for_guard)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_guard"),r?.business_remark&&!io(r?.business_remark)&&Ba(Ca.IsValidDesription,"Payment.New.param.business_remark");let s=e.pure.option("address",r.for_object?r.for_object:void 0);const i=e.sharedObjectRef($o.CLOCK_OBJECT);return r.for_guard?e.moveCall({target:$o.Instance().paymentFn("create_withGuard"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.object(r.for_guard),e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().paymentFn("create"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]})}class xd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new xd(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n,a){$o.IsValidObjects([r,n])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New.token_type"),io(s)||Ba(Ca.IsValidDesription),mo(i)||Ba(Ca.IsValidU64,"New.fee");let o=t,d=new xd(e,o,r);return d.object=a?e.moveCall({target:$o.Instance().arbitrationFn("new_with_passport"),arguments:[a,e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}):e.moveCall({target:$o.Instance().arbitrationFn("new"),arguments:[e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}),d}launch(){return this.txb.moveCall({target:$o.Instance().arbitrationFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_fee(e,t){mo(e)||Ba(Ca.IsValidU64,"set_fee.fee"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint,"set_endpoint.endpoint"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_voting_guard(e,t){0!==e.length&&(To(e,(e=>$o.IsValidObjects([e.guard])&&mo(e.voting_weight)))||Ba(Ca.IsValidArray,"add_voting_guard.guard"),t?e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})):e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})))}remove_voting_guard(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_voting_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}set_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_guard.apply_guard"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().arbitrationFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}vote(e,t){e.voting_guard&&!$o.IsValidObjects([e.voting_guard])&&Ba(Ca.IsValidObjects,"vote.param.voting_guard"),To(e.agrees,(e=>mo(e)&&e<xd.MAX_PROPOSITION_COUNT))||Ba(Ca.IsValidArray,"vote.param.agrees"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"vote.param.arb");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?e.voting_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("vote_with_passport"),arguments:[t,this.txb.object(e.voting_guard),$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote2_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arbitration(e,t){io(e.feedback)||Ba(Ca.IsValidDesription,"arbitration.param.feedback"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"arbitration.param.arb"),e.indemnity&&!mo(e.indemnity)&&Ba(Ca.IsValidU64,"arbitration.param.indemnity");let r=this.txb.pure.option("u64",e.indemnity?e.indemnity:void 0);t?this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}withdraw_fee(e,t,r){$o.IsValidObjects([e,t.treasury])||Ba(Ca.IsValidObjects,"withdraw_fee.arb or treasury"),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw_fee.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw_fee.param.for_object"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw_fee.param.remark"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw_fee.param.index");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_withdrawTreasury(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_withdrawTreasury.treasury"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arb(e,t){return $o.IsValidObjects([e.order])||Ba(Ca.IsValidObjects,"arb.param.order"),go(e.order_token_type)||Ba(Ca.IsValidTokenType,"arb.param.order_token_type"),io(e.description)||Ba(Ca.IsValidDesription,"arb.param.description"),To(e.votable_proposition,no)||Ba(Ca.IsValidArray,"arb.param.votable_proposition"),t?e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]}):e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]})}arb_launch(e){return this.txb.moveCall({target:$o.Instance().arbFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}dispute(e,t){const r=this.arb(e,t);return this.arb_launch(r)}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().arbitrationFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}static parseObjectType=e=>La(e,"arbitration::Arbitration<");static parseArbObjectType=e=>La(e,"arb::Arb<");static queryArbVoted=()=>{};static MAX_PROPOSITION_COUNT=16;static MAX_VOTING_GUARD_COUNT=16}class Od extends Error{}async function Id({host:e,path:t,body:r,headers:s,method:i}){const n=new URL(t,e).toString(),a=await fetch(n,{method:i,body:r?JSON.stringify(r):void 0,headers:{"Content-Type":"application/json",...s||{}}});if(429===a.status)throw new Od("Too many requests from this client have been sent to the faucet. Please retry later");try{const e=await a.json();if(e.error)throw new Error(`Faucet returns error: ${e.error}`);return e}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${a.status}, response ${a}`)}}async function Cd(e){return Id({host:e.host,path:"/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}async function Bd(e){return Id({host:e.host,path:"/v1/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}function Sd(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}class Pd{constructor(e){this.expire=e}expire_time(){return this.expire}expire}var jd;!function(e){e.object="OBJECT",e.personal="PERSONAL",e.table="TABLE"}(jd||(jd={}));const Ad=(e,t)=>e+$o.Instance().package("wowok_origin")+t+"-V2";class kd extends Pd{constructor(e=1e4){super(e)}data=new Map;load(e){return this.data.get(e)}save(e,t){this.data.set(e,t)}remove(e){this.data.delete(e)}}class Ud extends Pd{constructor(e=1e4){super(e)}load(e){return localStorage.getItem(e)}save(e,t){return localStorage.setItem(e,t)}remove(e){return localStorage.removeItem(e)}}class Nd{static _instance;cache=new Map;constructor(){}static Instance(){return Nd._instance||(Nd._instance=new Nd),Nd._instance}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}}var Dd;!function(e){e.localStorage="localStorage",e.memoryStorage="memoryStorage"}(Dd||(Dd={}));const Rd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Jd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Yd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Fd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Vd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Md(t)??""})}catch(e){return JSON.stringify({error:e?.toString()})}},Jd=async e=>{var t=[];const r=[],s=(new Date).getTime(),i=Nd.Instance().get(jd.object);if(i)for(let n=0;n<e.objects.length;++n){try{let a=i.load(Ad(e.objects[n],jd.object));if(a){const i=JSON.parse(a);if("INFINITE"!==i?.expire&&(e?.no_cache||i.expire<=s)&&(e.showOwner||e.showContent))r.push(e.objects[n]);else{const e=sc(JSON.parse(i.data));e.cache_expire=i.expire,t.push(e)}}}catch(e){console.log(e)}r.push(e.objects[n])}if(r.length>0){const s=await $o.Client().multiGetObjects({ids:[...r],options:{showContent:e.showContent,showType:e.showType,showOwner:e.showOwner}}),i=Nd.Instance().get(jd.object);if(i){const e=(new Date).getTime();s.forEach((t=>{try{if(t?.data){const r=t.data?.type??t.data?.content?.type??void 0,s=r?$o.Instance().object_name_from_type_repr(r):void 0,n={expire:"Guard"===s||"Payment"===s?"INFINITE":i.expire_time()+e,data:JSON.stringify(t.data)};i.save(Ad(t.data.objectId,jd.object),JSON.stringify(n))}}catch(e){console.log(e)}}))}t=t.concat(s.map((e=>sc(e?.data))))}return{objects:t}},Md=async e=>{co(e.address)||Ba(Ca.IsValidAddress,"entity.address");const t=(new Date).getTime(),r=Nd.Instance().get(jd.personal);if(r&&!e.no_cache)try{let s=r.load(Ad(e.address,jd.personal));if(s){const e=JSON.parse(s);if("INFINITE"===e?.expire||e.expire<=t){const t=JSON.parse(e.data);return t.cache_expire=e.expire,t}}}catch(e){console.log(e)}const s=await tc(Qd($o.Instance().objectEntity(),e.address));if("Personal"===s.type){if(r)try{const t=r.expire_time()+(new Date).getTime(),i={expire:t,data:JSON.stringify(s)};r.save(Ad(e.address,jd.personal),JSON.stringify(i)),s.cache_expire=t}catch(e){console.log(e)}return s}},Fd=async e=>{const t=await $o.Client().getDynamicFields({parentId:e.parent,cursor:e.cursor,limit:e.limit});return{items:t?.data?.map((e=>({object:e.objectId,type:e.type,version:e.version,key:{type:e.name.type,value:e.name.value}}))),nextCursor:t.nextCursor,hasNextPage:t.hasNextPage}},Xd=async(e,t)=>await tc(Qd(e,t)),Ld=async(e,t)=>await tc(Qd(e,t)),qd=async(e,t)=>await tc(Qd(e,t)),Gd=async(e,t)=>await tc(Zd(e,t)),$d=async(e,t)=>await tc(Zd(e,t)),zd=async(e,t)=>await tc(ec(e,t)),Wd=async(e,t)=>await tc(ec(e,t)),Hd=async(e,t,r)=>("string"!=typeof e&&(e=e.object),await tc({parent:e,key:{type:$o.Instance().package("wowok")+"::repository::DataKey",value:{id:t,key:r}}})),Kd=async(e,t)=>await tc(Qd(e,t));function Qd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"address",value:t}}}function Zd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"0x1::string::String",value:t}}}function ec(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"u64",value:t}}}const tc=async e=>{const t=await $o.Client().getDynamicFieldObject({parentId:e.parent,name:{type:e.key.type,value:e.key.value}});return sc(t?.data)};function rc(e){if(!e)return;const t=$o.Instance().object_name_from_type_repr(e);if("Permission"===t||"Demand"===t||"Machine"===t||"Progress"===t||"Order"===t||"Service"===t||"Treasury"===t||"Arb"===t||"Repository"===t||"Payment"===t||"Discount"===t||"Guard"===t||"Arbitration"===t)return t;if("Resource"===t)return"PersonalMark";const r=e?.indexOf("0x2::dynamic_field::Field<");if(0===r){const t=e?.substring(26);if(t&&$o.Instance().hasPackage(t)){if(t.includes("::demand::Tips>"))return"TableItem_DemandPresenter";if(t.includes("::machine::NodePair>>>"))return"TableItem_MachineNode";if(t.includes("::progress::History>"))return"TableItem_ProgressHistory";if(t.includes("::service::Sale>"))return"TableItem_ServiceSale";if(t.includes("::treasury::Record>"))return"TableItem_TreasuryHistory";if(t.includes("::arb::Voted>"))return"TableItem_ArbVote";if(t.includes("::permission::Perm>>"))return"TableItem_PermissionEntity";if(t.includes("::repository::DataKey"))return"TableItem_RepositoryData";if(t.includes("::entity::Ent>"))return"Personal";if(t.includes("::resource::Tags>"))return"TableItem_PersonalMark"}}}function sc(e){const t=e?.content?.fields,r=e?.objectId??t?.id?.id??void 0,s=e?.type??e?.content?.type??void 0,i=e?.version??void 0,n=e?.owner??void 0,a=rc(s);if(a)switch(a){case"Permission":return{object:r,type:a,type_raw:s,owner:n,version:i,builder:t?.builder??"",admin:t?.admin,description:t?.description??"",entity_count:parseInt(t?.table?.fields?.size),biz_permission:t?.user_define?.fields?.contents?.map((e=>({id:parseInt(e?.fields?.key),name:e?.fields?.value})))};case"Demand":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,guard:t?.guard?{object:t?.guard,service_id_in_guard:t?.service_identifier}:void 0,time_expire:t?.time_expire,yes:t?.yes,presenter_count:parseInt(t?.presenters?.fields?.size),bounty:t?.bounty?.map((e=>({type:e?.fields?.type,object:e?.fields?.id?.id,balance:e?.fields?.balance})))};case"Machine":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission??"",description:t?.description??"",bPaused:t?.bPaused,bPublished:t?.bPublished,endpoint:t?.endpoint,consensus_repository:t?.consensus_repositories,node_count:parseInt(t?.nodes?.fields?.size)};case"Progress":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,current:t?.current,task:t?.task,parent:t?.parent,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),namedOperator:t?.namedOperator?.fields?.contents?.map((e=>({name:e?.fields?.key,operator:e?.fields?.value}))),session:t?.session?.fields?.contents?.map((e=>({weights:e?.fields?.value?.fields?.weight,threshold:e?.fields?.value?.fields?.threshold,next_node:e?.fields?.key,forward:e?.fields?.value?.fields?.forwards?.fields?.contents?.map((e=>({forward_name:e?.fields?.key,accomplished:e?.fields?.value?.fields?.accomplished,msg:e?.fields?.value?.fields?.msg,orders:e?.fields?.value?.fields?.orders,time:e?.fields?.value?.fields?.time,holder:e?.fields?.value?.fields?.who})))})))};case"Order":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,amount:t?.amount,agent:t?.agent,arb:t?.dispute,payer:t?.payer,progress:t?.progress,discount:t?.discount,balance:t?.payed,required_info:t?.required_info?{pubkey:t?.required_info?.fields?.customer_pub,msg_encrypted:t?.required_info?.fields?.info}:void 0,item:t?.items?.map((e=>({name:e?.fields?.name,price:e?.fields?.price,stock:e?.fields?.stock,endpoint:e?.fields?.endpoint})))};case"Service":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,permission:t?.permission,description:t?.description,arbitration:t?.arbitrations,bPaused:t?.bPaused,bPublished:t?.bPublished,buy_guard:t?.buy_guard,endpoint:t?.endpoint,payee:t?.payee,repository:t?.repositories,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),refund_guard:t?.refund_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),sales_count:parseInt(t?.sales?.fields?.size),extern_withdraw_treasury:t?.extern_withdraw_treasuries,customer_required_info:t?.customer_required?{pubkey:t?.customer_required?.fields?.service_pubkey,required_info:t?.customer_required?.fields?.customer_required_info}:void 0};case"Treasury":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,withdraw_mode:t?.withdraw_mode,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),balance:t?.balance,deposit_guard:t?.deposit_guard,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value})))};case"Arbitration":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,fee:t?.fee,fee_treasury:t?.fee_treasury,usage_guard:t?.usage_guard,endpoint:t?.endpoint,bPaused:t?.bPaused,voting_guard:t?.voting_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,weights:e?.fields?.value})))};case"Arb":return{object:r,type:a,type_raw:s,owner:n,version:i,arbitration:t?.arbitration,description:t?.description,fee:t?.fee,feedback:t?.feedback,indemnity:t?.indemnity,order:t?.order,voted_count:parseInt(t?.voted?.fields?.size),proposition:t?.proposition?.fields?.contents?.map((e=>({proposition:e?.fields?.key,votes:e?.fields?.value})))};case"Repository":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,policy_mode:t?.policy_mode,data_count:parseInt(t?.data?.fields?.size),reference:t?.reference,rep_type:t?.type,policy:t?.policies?.fields?.contents?.map((e=>({key:e?.fields?.key,description:e?.fields?.value?.fields?.description,permissionIndex:e?.fields?.value?.fields?.permission_index,dataType:e?.fields?.value?.fields?.value_type})))};case"Payment":return{object:r,type:a,type_raw:s,owner:n,version:i,signer:t?.signer,time:t?.time,remark:t?.remark,from:t?.from,biz_id:t?.index,for_guard:t?.for_guard,for_object:t?.for_object,amount:t?.amount,record:t?.record?.map((e=>({recipient:e?.fields?.recipient,amount:e?.fields?.amount})))};case"Discount":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,time_start:t?.time_start,time_end:t?.time_end,price_greater:t?.price_greater,off_type:t?.type,off:t?.off,name:t?.name};case"Guard":return{object:r,type:a,type_raw:s,owner:n,version:i,description:t?.description,input:Uint8Array.from(t?.input?.fields?.bytes),identifier:t?.constants?.map((e=>({id:e?.fields?.identifier,bWitness:e?.fields?.bWitness,value:Uint8Array.from(e?.fields?.value)})))};case"PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,tag_count:parseInt(t?.tags?.fields?.size)};case"TableItem_DemandPresenter":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.name,presenter:t?.value?.fields?.who,recommendation:t?.value?.fields?.tips};case"TableItem_ProgressHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,history:ed.DeHistory(t)};case"TableItem_ServiceSale":return{object:r,type:a,type_raw:s,owner:n,version:i,item:{item:t?.name,stock:t?.value?.fields?.stock,price:t?.value?.fields?.price,endpoint:t?.value?.fields?.endpoint}};case"TableItem_TreasuryHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,id:t?.name,payment:t?.value?.fields?.payment,signer:t?.value?.fields?.signer,operation:t?.value?.fields?.op,amount:t?.value?.fields?.amount,time:t?.value?.fields?.time};case"TableItem_ArbVote":return{object:r,type:a,type_raw:s,owner:n,version:i,singer:t?.name,vote:t?.value?.fields?.agrees,time:t?.value?.fields?.time,weight:t?.value?.fields?.weight};case"TableItem_PermissionEntity":return{object:r,type:a,type_raw:s,owner:n,version:i,entity:t?.name,permission:t?.value?.map((e=>({id:e?.fields.index,guard:e?.fields.guard})))};case"TableItem_RepositoryData":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name?.fields?.id,key:t?.name?.fields?.key,data:Uint8Array.from(t?.value)};case"Personal":const o=Wa.getInstance().de_entInfo(Uint8Array.from(t?.value?.fields?.avatar));return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,like:t?.value?.fields?.like,dislike:t?.value?.fields?.dislike,mark_object:t?.value?.fields?.resource,lastActive_digest:e?.previousTransaction,info:{homepage:o?.homepage,name:o?.name,avatar:o?.avatar,twitter:o?.twitter,discord:o?.discord,description:o?.description}};case"TableItem_PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,name:t?.value?.fields?.nick,tags:t?.value?.fields?.tags}}return{object:r,type:void 0,type_raw:s,owner:n,version:i}}const ic=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await nc(t)})}catch(e){return JSON.stringify({error:e})}},nc=async e=>{co(e.permission_object)||Ba(Ca.IsValidAddress,"permission.permission_object");const t=new gs;Qo.From(t,e.permission_object).query_permissions_all(e.address);const r=await $o.Client().devInspectTransactionBlock({sender:e.address,transactionBlock:t});r.results&&r.results[0].returnValues&&2!==r.results[0].returnValues.length&&Ba(Ca.Fail,"permission.retValues");const s=Wa.getInstance().de(Oa.U8,Uint8Array.from(r.results[0].returnValues[0][0]));if(s===Qo.PERMISSION_ADMIN||s===Qo.PERMISSION_OWNER_AND_ADMIN)return{who:e.address,admin:!0,owner:s%2==1,items:[],object:e.permission_object};{const t=Wa.getInstance().de_perms(Uint8Array.from(r.results[0].returnValues[1][0]));return{who:e.address,admin:!1,owner:s%2==1,items:t.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e.permission_object}}};var ac;!function(e){e.query_events_json=async t=>{try{const r=JSON.parse(t);return JSON.stringify({data:await e.query_events(r)})}catch(e){return JSON.stringify({error:e?.toString()})}},e.query_events=e=>{switch(e.type){case"OnNewArb":return t(e.cursor,e.limit,e.order);case"OnNewProgress":return s(e.cursor,e.limit,e.order);case"OnPresentService":return r(e.cursor,e.limit,e.order);case"OnNewOrder":return i(e.cursor,e.limit,e.order)}};const t=async(e,t,r)=>await n($o.Instance().package("wowok")+"::arb::NewArbEvent",e,t,r),r=async(e,t,r)=>await n($o.Instance().package("wowok")+"::demand::PresentEvent",e,t,r),s=async(e,t,r)=>await n($o.Instance().package("wowok")+"::progress::NewProgressEvent",e,t,r),i=async(e,t,r)=>await n($o.Instance().package("wowok")+"::order::NewOrderEvent",e,t,r),n=async(e,t,r,s)=>{const i=await $o.Client().queryEvents({query:{MoveEventType:e},cursor:t,limit:r,order:s}),n=i?.data?.map((e=>{if(e?.packageId===$o.Instance().package("wowok")){if(e?.type?.includes("::order::NewOrderEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",order:e?.parsedJson?.object,service:e?.parsedJson?.service,progress:e?.parsedJson?.progress,amount:e?.parsedJson?.amount};if(e?.type?.includes("::demand::PresentEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",demand:e?.parsedJson?.object,service:e?.parsedJson?.service,recommendation:e?.parsedJson?.tips};if(e?.type?.includes("::progress::NewProgressEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",progress:e?.parsedJson?.object,machine:e?.parsedJson?.machine,task:e?.parsedJson?.task};if(e?.type?.includes("::arb::NewArbEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",arb:e?.parsedJson?.object,arbitration:e?.parsedJson?.arbitration,order:e?.parsedJson?.order};if(e?.type?.includes("::entity::NewEntityEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",resource:e?.parsedJson?.resource?.some,address:e?.parsedJson?.target}}return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:""}}));return{data:n,hasNextPage:i?.hasNextPage,nextCursor:i?.nextCursor}}}(ac||(ac={}));const oc="wowok.acc.dat",dc="wowok-acc-v1";class cc{constructor(e="File"){this.storage=e}static _instance;static Instance(){return cc._instance||(cc._instance=new cc),cc._instance}storage="File";_add(e,t,r){var s,i="0x"+ta(Un(Zn.generate().getSecretKey()).secretKey);try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));return e?e.default=r:(r&&s.forEach((e=>e.default=!1)),s.push({name:t,key:i,default:r})),s}}catch(e){}return[{name:t,key:i,default:r}]}_default(e){var t;try{if(e&&(t=JSON.parse(e))){const e=t.find((e=>e.default));if(e)return e}}catch(e){}}_get(e,t,r){var s;try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));if(e)return e;if(r)return s.find((e=>e.default))}}catch(e){}}_rename(e,t,r,s=!0){var i;try{if(e&&(i=JSON.parse(e)),i){const e=i.find((e=>e.name===t));if(!e)return;const n=i.find((e=>e.name===r));if(!n)return e.name=r,i;if(s)return e.name=r,n.name=t,i}}catch(e){}}set_storage(e="File"){this.storage=e}async gen(e,t){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);r.readFile(n,"utf-8",((s,i)=>{const a=this._add(i,e,t);r.writeFileSync(n,JSON.stringify(a),"utf-8")}))}else if("Explorer"===this.storage){const r=this._add(localStorage.getItem(dc),e,t);localStorage.setItem(dc,JSON.stringify(r))}}catch(e){}}async default(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return this._default(e.readFileSync(s,"utf-8"))}if("Explorer"===this.storage)return this._default(localStorage.getItem(dc))}catch(e){}}async get(e,t=!0){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);return this._get(r.readFileSync(n,"utf-8"),e,t)}if("Explorer"===this.storage)return this._get(localStorage.getItem(dc),e,t)}catch(e){}}async rename(e,t,r=!0){var s;try{if("File"===this.storage){const[i,n,o]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),d=o.join(n.homedir(),oc);(s=this._rename(i.readFileSync(d,"utf-8"),e,t,r))&&i.writeFileSync(d,JSON.stringify(s),"utf-8")}else"Explorer"===this.storage&&(s=this._rename(localStorage.getItem(dc),e,t,r))&&localStorage.setItem(dc,JSON.stringify(s))}catch(e){}return!!s}async get_address(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiAddress()}async get_pubkey(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiPublicKey()}async get_pair(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key))}async list(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return JSON.parse(e.readFileSync(s,"utf-8")).map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}if("Explorer"===this.storage)return JSON.parse(localStorage.getItem(dc)??"").map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}catch(e){}return[]}async faucet(e){const t=await this.get_address(e,!0);t&&await Cd({host:Sd("testnet"),recipient:t}).catch((e=>{}))}balance=async(e,t)=>{const r=await this.get_address(e);if(r)return await $o.Client().getBalance({owner:r,coinType:t})};coin=async(e,t)=>{const r=await this.get_address(e);if(r)return(await $o.Client().getCoins({owner:r,coinType:t})).data};get_coin_object=async(e,t,r,s)=>{const i=await this.get_address(r),n=BigInt(t);if(i&&n>BigInt(0)){if(s&&"0x2::sui::SUI"!==s&&"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"!==s){const t=await $o.Client().getCoins({owner:i,coinType:s}),r=[];var a=BigInt(0);for(let e=0;e<t.data.length&&(a+=BigInt(t.data[e].balance),r.push(t.data[e].coinObjectId),!(a>=n));++e);if(1===r.length)return e.splitCoins(r[0],[n]);{const t=r.pop();return e.mergeCoins(t,r),e.splitCoins(t,[n])}}return e.splitCoins(e.gas,[n])}};coin_with_balance=async(e,t,r)=>{const s=await this.get_pair(t,!0);s||Ba(Ca.Fail,"account invalid");const i=new gs,n=await cc.Instance().get_coin_object(i,e,t,r);if(n){i.transferObjects([n],s?.toSuiAddress());const e=await $o.Client().signAndExecuteTransaction({transaction:i,signer:s,options:{showObjectChanges:!0}}),t=r??"0x2::sui::SUI";return e?.objectChanges.find((e=>"created"===e?.type&&(e?.objectType).includes(t)))?.objectId}}}function uc(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const hc=8192;function pc(e){if(e.length<hc)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=hc){const s=e.slice(r,r+hc);t+=String.fromCharCode(...s)}return btoa(t)}const lc=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;n<e.length;){const s=e.charCodeAt(n);if(s>255)return;let i=t[s];if(255===i)return;let a=0;for(let e=d-1;(0!==i||a<o)&&-1!==e;e--,a++)i+=r*c[e]>>>0,c[e]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");o=a,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let p=a;for(;u!==d;)h[p++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let p=s.repeat(i);for(;h<c;++h)p+=e.charAt(u[h]);return p},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),mc=e=>lc.encode(e),_c=e=>lc.decode(e);function bc(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function gc(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function yc(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class fc{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class vc{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Tc(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Tc(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Tc(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return yc(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return mc(e);case"base64":return pc(e);case"hex":return gc(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Tc(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Ec,wc,xc,Oc,Ic=e=>{throw TypeError(e)},Cc=(e,t,r)=>t.has(e)||Ic("Cannot "+r),Bc=(e,t,r)=>(Cc(e,t,"read from private field"),r?r.call(e):t.get(e)),Sc=(e,t,r)=>t.has(e)?Ic("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Pc=(e,t,r,s)=>(Cc(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);Ec=new WeakMap,wc=new WeakMap;let jc=class e{constructor(e){Sc(this,Ec),Sc(this,wc),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Pc(this,Ec,e.write),Pc(this,wc,e.serialize??((e,t)=>{const r=new vc({initialSize:this.serializedSize(e)??void 0,...t});return Bc(this,Ec).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Bc(this,Ec).call(this,e,t)}serialize(e,t){return this.validate(e),new Uc(this,Bc(this,wc).call(this,e,t))}parse(e){const t=new fc(e);return this.read(t)}fromHex(e){return this.parse(bc(e))}fromBase58(e){return this.parse(_c(e))}fromBase64(e){return this.parse(uc(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>Bc(this,Ec).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>Bc(this,wc).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const Ac=Symbol.for("@mysten/serialized-bcs");function kc(e){return!!e&&"object"==typeof e&&!0===e[Ac]}class Uc{constructor(e,t){Sc(this,xc),Sc(this,Oc),Pc(this,xc,e),Pc(this,Oc,t)}get[Ac](){return!0}toBytes(){return Bc(this,Oc)}toHex(){return gc(Bc(this,Oc))}toBase64(){return pc(Bc(this,Oc))}toBase58(){return mc(Bc(this,Oc))}parse(){return Bc(this,xc).parse(Bc(this,Oc))}}function Nc({size:e,...t}){return new jc({...t,serializedSize:()=>e})}function Dc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function Rc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function Yc(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Vc(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??Yc(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function Jc(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}xc=new WeakMap,Oc=new WeakMap;var Mc=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Fc(e,t){return{kind:"validation",type:"check",reference:Fc,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"input",e,t),e}}}function Xc(e){return{kind:"validation",type:"integer",reference:Xc,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"integer",e,t),e}}}function Lc(e){return{kind:"transformation",type:"transform",reference:Lc,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function qc(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function Gc(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function $c(e,t){return{kind:"schema",type:"array",reference:$c,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function zc(e){return{kind:"schema",type:"bigint",reference:zc,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Wc(e){return{kind:"schema",type:"boolean",reference:Wc,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Hc(e){return{kind:"schema",type:"lazy",reference:Hc,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function Kc(e,t){return{kind:"schema",type:"literal",reference:Kc,expects:Yc(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Vc(this,"type",e,t),e}}}function Qc(e,...t){const r={kind:"schema",type:"nullable",reference:Qc,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=qc(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function Zc(e,...t){const r={kind:"schema",type:"nullish",reference:Zc,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=qc(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function eu(e){return{kind:"schema",type:"number",reference:eu,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Vc(this,"type",e,t):e.typed=!0,e}}}function tu(e,t){return{kind:"schema",type:"object",reference:tu,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else Vc(this,"type",e,t);return e}}}function ru(e,...t){const r={kind:"schema",type:"optional",reference:ru,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=qc(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function su(e,t,r){return{kind:"schema",type:"record",reference:su,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(Jc(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else Vc(this,"type",e,t);return e}}}function iu(e){return{kind:"schema",type:"string",reference:iu,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function nu(e,t){return{kind:"schema",type:"tuple",reference:nu,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function au(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ou(e,t){return{kind:"schema",type:"union",reference:ou,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];Vc(this,"type",e,t,{issues:au(s)}),e.typed=!0}else{if(1===i?.length)return i[0];Vc(this,"type",e,t,{issues:au(i)})}return e}}}function du(){return{kind:"schema",type:"unknown",reference:du,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function cu(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new Mc(s.issues);return s.value}function uu(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function hu(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function pu(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(64,"0")}`}function lu(e,t=!1){return pu(e,t)}function mu(e){return uu(ou(Object.entries(e).map((([e,t])=>tu({[e]:t})))),Lc((e=>({...e,$kind:Object.keys(e)[0]}))))}const _u=uu(iu(),Lc((e=>pu(e))),Fc(hu)),bu=_u,gu=iu(),yu=uu(ou([iu(),uu(eu(),Xc())]),Fc((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),fu=tu({objectId:_u,version:yu,digest:iu()}),vu=uu(ou([tu({GasCoin:Kc(!0)}),tu({Input:uu(eu(),Xc()),type:ru(Kc("pure"))}),tu({Input:uu(eu(),Xc()),type:ru(Kc("object"))}),tu({Result:uu(eu(),Xc())}),tu({NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])})]),Lc((e=>({...e,$kind:Object.keys(e)[0]})))),Tu=tu({budget:Qc(yu),price:Qc(yu),owner:Qc(_u),payment:Qc($c(fu))}),Eu=(tu({address:iu(),module:iu(),name:iu(),typeParams:$c(iu())}),ou([Kc("address"),Kc("bool"),Kc("u8"),Kc("u16"),Kc("u32"),Kc("u64"),Kc("u128"),Kc("u256"),tu({vector:Hc((()=>Eu))}),tu({datatype:tu({package:iu(),module:iu(),type:iu(),typeParameters:$c(Hc((()=>Eu)))})}),tu({typeParameter:uu(eu(),Xc())})])),wu=tu({ref:Qc(ou([Kc("&"),Kc("&mut")])),body:Eu}),xu=tu({package:bu,module:iu(),function:iu(),typeArguments:$c(iu()),arguments:$c(vu),_argumentTypes:ru(Qc($c(wu)))}),Ou=tu({name:iu(),inputs:su(iu(),ou([vu,$c(vu)])),data:su(iu(),du())}),Iu=mu({MoveCall:xu,TransferObjects:tu({objects:$c(vu),address:vu}),SplitCoins:tu({coin:vu,amounts:$c(vu)}),MergeCoins:tu({destination:vu,sources:$c(vu)}),Publish:tu({modules:$c(gu),dependencies:$c(bu)}),MakeMoveVec:tu({type:Qc(iu()),elements:$c(vu)}),Upgrade:tu({modules:$c(gu),dependencies:$c(bu),package:bu,ticket:vu}),$Intent:Ou}),Cu=mu({ImmOrOwnedObject:fu,SharedObject:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:fu}),Bu=mu({Object:Cu,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:bu,version:ru(Qc(yu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(yu))})}),Su=mu({Object:Cu,Pure:tu({bytes:gu})}),Pu=mu({None:Kc(!0),Epoch:yu}),ju=tu({version:Kc(2),sender:Zc(_u),expiration:Zc(Pu),gasData:Tu,inputs:$c(Bu),commands:$c(Iu)}),Au={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>cu(vu,e))),address:cu(vu,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:cu(vu,e),amounts:t.map((e=>cu(vu,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:cu(vu,e),sources:t.map((e=>cu(vu,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:pc(new Uint8Array(e)))),dependencies:t.map((e=>lu(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:s})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:pc(new Uint8Array(e)))),dependencies:t.map((e=>lu(e))),package:r,ticket:cu(vu,s)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>cu(vu,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>cu(vu,e))):cu(vu,t)]))),data:r}})},ku=/^vector<(.+)>$/,Uu=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Nu{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(ku);if(r)return{vector:Nu.parseFromStr(r[1],t)};const s=e.match(Uu);if(s)return{struct:{address:t?pu(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:Nu.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>Nu.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Nu.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(Nu.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Du=tu({digest:iu(),objectId:iu(),version:ou([uu(eu(),Xc()),iu(),zc()])}),Ru=mu({ImmOrOwned:Du,Shared:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:Du}),Yu=mu({Object:Ru,Pure:$c(uu(eu(),Xc()))}),Vu=ou([tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:ru(Kc("object"))}),tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:Kc("pure")})]),Ju=ou([tu({Epoch:uu(eu(),Xc())}),tu({None:Qc(Kc(!0))})]),Mu=uu(ou([eu(),iu(),zc()]),Fc((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Fu=ou([tu({bool:Qc(Kc(!0))}),tu({u8:Qc(Kc(!0))}),tu({u64:Qc(Kc(!0))}),tu({u128:Qc(Kc(!0))}),tu({address:Qc(Kc(!0))}),tu({signer:Qc(Kc(!0))}),tu({vector:Hc((()=>Fu))}),tu({struct:Hc((()=>Xu))}),tu({u16:Qc(Kc(!0))}),tu({u32:Qc(Kc(!0))}),tu({u256:Qc(Kc(!0))})]),Xu=tu({address:iu(),module:iu(),name:iu(),typeParams:$c(Fu)}),Lu=tu({budget:ru(Mu),price:ru(Mu),payment:ru($c(Du)),owner:ru(iu())}),qu=ou([Vu,tu({kind:Kc("GasCoin")}),tu({kind:Kc("Result"),index:uu(eu(),Xc())}),tu({kind:Kc("NestedResult"),index:uu(eu(),Xc()),resultIndex:uu(eu(),Xc())})]),Gu=tu({kind:Kc("MoveCall"),target:uu(iu(),Fc((e=>3===e.split("::").length))),typeArguments:$c(iu()),arguments:$c(qu)}),$u=tu({kind:Kc("TransferObjects"),objects:$c(qu),address:qu}),zu=tu({kind:Kc("SplitCoins"),coin:qu,amounts:$c(qu)}),Wu=tu({kind:Kc("MergeCoins"),destination:qu,sources:$c(qu)}),Hu=tu({kind:Kc("MakeMoveVec"),type:ou([tu({Some:Fu}),tu({None:Qc(Kc(!0))})]),objects:$c(qu)}),Ku=ou([Gu,$u,zu,Wu,tu({kind:Kc("Publish"),modules:$c($c(uu(eu(),Xc()))),dependencies:$c(iu())}),tu({kind:Kc("Upgrade"),modules:$c($c(uu(eu(),Xc()))),dependencies:$c(iu()),packageId:iu(),ticket:qu}),Hu]);function Qu(e){const t=e.inputs.map(((e,t)=>{if(e.Object)return{kind:"Input",index:t,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:t,value:{Pure:Array.from(uc(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:t,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:t,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:t,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Nu.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>Zu(e,t)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Zu(e.MergeCoins.destination,t),sources:e.MergeCoins.sources.map((e=>Zu(e,t)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>Zu(e,t)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(uc(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Zu(e.SplitCoins.coin,t),amounts:e.SplitCoins.amounts.map((e=>Zu(e,t)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>Zu(e,t))),address:Zu(e.TransferObjects.address,t)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(uc(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Zu(e.Upgrade.ticket,t)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function Zu(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function eh(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function th(e){return ou(Object.entries(e).map((([e,t])=>tu({[e]:t}))))}tu({version:Kc(1),sender:ru(iu()),expiration:Zc(Ju),gasConfig:Lu,inputs:$c(Vu),transactions:$c(Ku)});const rh=th({GasCoin:Kc(!0),Input:uu(eu(),Xc()),Result:uu(eu(),Xc()),NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])}),sh=tu({budget:Qc(yu),price:Qc(yu),owner:Qc(_u),payment:Qc($c(fu))}),ih=tu({package:bu,module:iu(),function:iu(),typeArguments:$c(iu()),arguments:$c(rh)}),nh=tu({name:iu(),inputs:su(iu(),ou([rh,$c(rh)])),data:su(iu(),du())}),ah=th({MoveCall:ih,TransferObjects:tu({objects:$c(rh),address:rh}),SplitCoins:tu({coin:rh,amounts:$c(rh)}),MergeCoins:tu({destination:rh,sources:$c(rh)}),Publish:tu({modules:$c(gu),dependencies:$c(bu)}),MakeMoveVec:tu({type:Qc(iu()),elements:$c(rh)}),Upgrade:tu({modules:$c(gu),dependencies:$c(bu),package:bu,ticket:rh}),$Intent:nh}),oh=th({ImmOrOwnedObject:fu,SharedObject:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:fu}),dh=th({Object:oh,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:bu,version:ru(Qc(yu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(yu))})}),ch=th({None:Kc(!0),Epoch:yu}),uh=tu({version:Kc(2),sender:Zc(_u),expiration:Zc(ch),gasData:sh,inputs:$c(dh),commands:$c(ah)}),hh=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?pc(e):e.toBase64()}}},ph=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:pu(e)}}}),lh=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:pu(e)}}}),mh=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:pu(e)}}}),_h={u8:e=>Dc({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>Dc({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>Dc({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>Rc({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>Rc({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>Rc({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>Nc({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new jc({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(yc(e)),...e}),bytes:(e,t)=>Nc({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new jc({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=yc(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new jc({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>_h.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new jc({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new jc({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new jc({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new jc({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>_h.vector(_h.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new jc({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},bh=_h.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:gc(e);if(!t||!hu(pu(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?bc(pu(e)):e,output:e=>pu(gc(e))}),gh=_h.vector(_h.u8()).transform({name:"ObjectDigest",input:e=>_c(e),output:e=>mc(new Uint8Array(e)),validate:e=>{if(32!==_c(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),yh=_h.struct("SuiObjectRef",{objectId:bh,version:_h.u64(),digest:gh}),fh=_h.struct("SharedObjectRef",{objectId:bh,initialSharedVersion:_h.u64(),mutable:_h.bool()}),vh=_h.enum("ObjectArg",{ImmOrOwnedObject:yh,SharedObject:fh,Receiving:yh}),Th=_h.enum("CallArg",{Pure:_h.struct("Pure",{bytes:_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})}),Object:vh}),Eh=_h.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:_h.lazy((()=>Eh)),struct:_h.lazy((()=>Ph)),u16:null,u32:null,u256:null}),wh=Eh.transform({input:e=>"string"==typeof e?Nu.parseFromStr(e,!0):e,output:e=>Nu.tagToString(e)}),xh=_h.enum("Argument",{GasCoin:null,Input:_h.u16(),Result:_h.u16(),NestedResult:_h.tuple([_h.u16(),_h.u16()])}),Oh=_h.struct("ProgrammableMoveCall",{package:bh,module:_h.string(),function:_h.string(),typeArguments:_h.vector(wh),arguments:_h.vector(xh)}),Ih=_h.enum("Command",{MoveCall:Oh,TransferObjects:_h.struct("TransferObjects",{objects:_h.vector(xh),address:xh}),SplitCoins:_h.struct("SplitCoins",{coin:xh,amounts:_h.vector(xh)}),MergeCoins:_h.struct("MergeCoins",{destination:xh,sources:_h.vector(xh)}),Publish:_h.struct("Publish",{modules:_h.vector(_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})),dependencies:_h.vector(bh)}),MakeMoveVec:_h.struct("MakeMoveVec",{type:function(e){return _h.enum("Option",{None:null,Some:e})}(wh).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:_h.vector(xh)}),Upgrade:_h.struct("Upgrade",{modules:_h.vector(_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})),dependencies:_h.vector(bh),package:bh,ticket:xh})}),Ch=_h.struct("ProgrammableTransaction",{inputs:_h.vector(Th),commands:_h.vector(Ih)}),Bh=_h.enum("TransactionKind",{ProgrammableTransaction:Ch,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Sh=_h.enum("TransactionExpiration",{None:null,Epoch:_h.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})}),Ph=_h.struct("StructTag",{address:bh,module:_h.string(),name:_h.string(),typeParams:_h.vector(Eh)}),jh=_h.struct("GasData",{payment:_h.vector(yh),owner:bh,price:_h.u64(),budget:_h.u64()}),Ah=_h.struct("TransactionDataV1",{kind:Bh,sender:bh,gasData:jh,expiration:Sh}),kh=_h.enum("TransactionData",{V1:Ah}),Uh=_h.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Nh=_h.enum("IntentVersion",{V0:null}),Dh=_h.enum("AppId",{Sui:null}),Rh=_h.struct("Intent",{scope:Uh,version:Nh,appId:Dh});function Yh(e){return _h.struct(`IntentMessage<${e.name}>`,{intent:Rh,value:e})}const Vh=_h.enum("CompressedSignature",{ED25519:_h.fixedArray(64,_h.u8()),Secp256k1:_h.fixedArray(64,_h.u8()),Secp256r1:_h.fixedArray(64,_h.u8()),ZkLogin:_h.vector(_h.u8())}),Jh=_h.enum("PublicKey",{ED25519:_h.fixedArray(32,_h.u8()),Secp256k1:_h.fixedArray(33,_h.u8()),Secp256r1:_h.fixedArray(33,_h.u8()),ZkLogin:_h.vector(_h.u8())}),Mh=_h.struct("MultiSigPkMap",{pubKey:Jh,weight:_h.u8()}),Fh=_h.struct("MultiSigPublicKey",{pk_map:_h.vector(Mh),threshold:_h.u16()}),Xh=_h.struct("MultiSig",{sigs:_h.vector(Vh),bitmap:_h.u16(),multisig_pk:Fh}),Lh=_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))}),qh=_h.struct("SenderSignedTransaction",{intentMessage:Yh(kh),txSignatures:_h.vector(Lh)}),Gh=_h.vector(qh,{name:"SenderSignedData"}),$h=_h.enum("PackageUpgradeError",{UnableToFetchPackage:_h.struct("UnableToFetchPackage",{packageId:bh}),NotAPackage:_h.struct("NotAPackage",{objectId:bh}),IncompatibleUpgrade:null,DigestDoesNotMatch:_h.struct("DigestDoesNotMatch",{digest:_h.vector(_h.u8())}),UnknownUpgradePolicy:_h.struct("UnknownUpgradePolicy",{policy:_h.u8()}),PackageIDDoesNotMatch:_h.struct("PackageIDDoesNotMatch",{packageId:bh,ticketId:bh})}),zh=_h.struct("ModuleId",{address:bh,name:_h.string()}),Wh=_h.struct("MoveLocation",{module:zh,function:_h.u16(),instruction:_h.u16(),functionName:_h.option(_h.string())}),Hh=_h.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:_h.struct("IndexOutOfBounds",{idx:_h.u16()}),SecondaryIndexOutOfBounds:_h.struct("SecondaryIndexOutOfBounds",{resultIdx:_h.u16(),secondaryIdx:_h.u16()}),InvalidResultArity:_h.struct("InvalidResultArity",{resultIdx:_h.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),Kh=_h.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Qh=_h.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:_h.struct("MoveObjectTooBig",{objectSize:_h.u64(),maxObjectSize:_h.u64()}),MovePackageTooBig:_h.struct("MovePackageTooBig",{objectSize:_h.u64(),maxObjectSize:_h.u64()}),CircularObjectOwnership:_h.struct("CircularObjectOwnership",{object:bh}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:_h.option(Wh),MoveAbort:_h.tuple([Wh,_h.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:_h.struct("CommandArgumentError",{argIdx:_h.u16(),kind:Hh}),TypeArgumentError:_h.struct("TypeArgumentError",{argumentIdx:_h.u16(),kind:Kh}),UnusedValueWithoutDrop:_h.struct("UnusedValueWithoutDrop",{resultIdx:_h.u16(),secondaryIdx:_h.u16()}),InvalidPublicFunctionReturnType:_h.struct("InvalidPublicFunctionReturnType",{idx:_h.u16()}),InvalidTransferObject:null,EffectsTooLarge:_h.struct("EffectsTooLarge",{currentSize:_h.u64(),maxSize:_h.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:_h.struct("PackageUpgradeError",{upgradeError:$h}),WrittenObjectsTooLarge:_h.struct("WrittenObjectsTooLarge",{currentSize:_h.u64(),maxSize:_h.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Zh=_h.enum("ExecutionStatus",{Success:null,Failed:_h.struct("ExecutionFailed",{error:Qh,command:_h.option(_h.u64())})}),ep=_h.struct("GasCostSummary",{computationCost:_h.u64(),storageCost:_h.u64(),storageRebate:_h.u64(),nonRefundableStorageFee:_h.u64()}),tp=_h.enum("Owner",{AddressOwner:bh,ObjectOwner:bh,Shared:_h.struct("Shared",{initialSharedVersion:_h.u64()}),Immutable:null}),rp=_h.struct("TransactionEffectsV1",{status:Zh,executedEpoch:_h.u64(),gasUsed:ep,modifiedAtVersions:_h.vector(_h.tuple([bh,_h.u64()])),sharedObjects:_h.vector(yh),transactionDigest:gh,created:_h.vector(_h.tuple([yh,tp])),mutated:_h.vector(_h.tuple([yh,tp])),unwrapped:_h.vector(_h.tuple([yh,tp])),deleted:_h.vector(yh),unwrappedThenDeleted:_h.vector(yh),wrapped:_h.vector(yh),gasObject:_h.tuple([yh,tp]),eventsDigest:_h.option(gh),dependencies:_h.vector(gh)}),sp=_h.tuple([_h.u64(),gh]),ip=_h.enum("ObjectIn",{NotExist:null,Exist:_h.tuple([sp,tp])}),np=_h.enum("ObjectOut",{NotExist:null,ObjectWrite:_h.tuple([gh,tp]),PackageWrite:sp}),ap=_h.enum("IDOperation",{None:null,Created:null,Deleted:null}),op=_h.struct("EffectsObjectChange",{inputState:ip,outputState:np,idOperation:ap}),dp=_h.enum("UnchangedSharedKind",{ReadOnlyRoot:sp,MutateDeleted:_h.u64(),ReadDeleted:_h.u64(),Cancelled:_h.u64(),PerEpochConfig:null}),cp=_h.struct("TransactionEffectsV2",{status:Zh,executedEpoch:_h.u64(),gasUsed:ep,transactionDigest:gh,gasObjectIndex:_h.option(_h.u32()),eventsDigest:_h.option(gh),dependencies:_h.vector(gh),lamportVersion:_h.u64(),changedObjects:_h.vector(_h.tuple([bh,op])),unchangedSharedObjects:_h.vector(_h.tuple([bh,dp])),auxDataDigest:_h.option(gh)}),up=_h.enum("TransactionEffects",{V1:rp,V2:cp}),hp={..._h,U8:_h.u8(),U16:_h.u16(),U32:_h.u32(),U64:_h.u64(),U128:_h.u128(),U256:_h.u256(),ULEB128:_h.uleb128(),Bool:_h.bool(),String:_h.string(),Address:bh,AppId:Dh,Argument:xh,CallArg:Th,CompressedSignature:Vh,GasData:jh,Intent:Rh,IntentMessage:Yh,IntentScope:Uh,IntentVersion:Nh,MultiSig:Xh,MultiSigPkMap:Mh,MultiSigPublicKey:Fh,ObjectArg:vh,ObjectDigest:gh,ProgrammableMoveCall:Oh,ProgrammableTransaction:Ch,PublicKey:Jh,SenderSignedData:Gh,SenderSignedTransaction:qh,SharedObjectRef:fh,StructTag:Ph,SuiObjectRef:yh,Command:Ih,TransactionData:kh,TransactionDataV1:Ah,TransactionExpiration:Sh,TransactionKind:Bh,TypeTag:wh,TransactionEffects:up},pp=(BigInt(1e9),lu("0x6"),"0x2::sui::SUI");function lp(e){if("string"==typeof e)switch(e){case"address":return hp.Address;case"bool":return hp.Bool;case"u8":return hp.U8;case"u16":return hp.U16;case"u32":return hp.U32;case"u64":return hp.U64;case"u128":return hp.U128;case"u256":return hp.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return hp.vector(hp.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=lp(e.vector);return t?hp.vector(t):null}if("datatype"in e){const t=pu(e.datatype.package);if(t===pu("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return hp.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return hp.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=lp(e.datatype.typeParameters[0]);return t?hp.vector(t):null}}if(t===pu("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return hp.Address}return null}function mp(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:mp(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(mp)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}lu("0x5");async function _p(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{bp(t,hp.U64,e)}));break;case"TransferObjects":bp(t.TransferObjects.address,hp.Address,e)}}));const a=new Map;if(n.size>0){const e=fp(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:mp(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:mp(e.MutableReference)}:{ref:null,body:mp(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&pu(t.package)===pu("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=lp(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=hh(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>lu(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>fp(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=pu(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=lh({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:gp(e,t)}):yp(e,t)&&(s=mh({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??ph({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await fp(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await fp(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await fp(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:pp})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>cu(fu,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function bp(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=hh(t.serialize(s.UnresolvedPure.value)))}function gp(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function yp(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function fp(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function vp(e){function t(t,r){if("string"==typeof t)return e(Tp(t).serialize(r));if(t instanceof Uint8Array||kc(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(hp.U8.serialize(t)),t.u16=t=>e(hp.U16.serialize(t)),t.u32=t=>e(hp.U32.serialize(t)),t.u64=t=>e(hp.U64.serialize(t)),t.u128=t=>e(hp.U128.serialize(t)),t.u256=t=>e(hp.U256.serialize(t)),t.bool=t=>e(hp.Bool.serialize(t)),t.string=t=>e(hp.String.serialize(t)),t.address=t=>e(hp.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(hp.vector(Tp(t)).serialize(r)),t.option=(t,r)=>e(hp.option(Tp(t)).serialize(r)),t}function Tp(e){switch(e){case"u8":return hp.u8();case"u16":return hp.u16();case"u32":return hp.u32();case"u64":return hp.u64();case"u128":return hp.u128();case"u256":return hp.u256();case"bool":return hp.bool();case"string":return hp.string();case"id":case"address":return hp.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?hp.vector(Tp(r)):hp.option(Tp(r))}throw new Error(`Invalid Pure type name: ${e}`)}function Ep(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wp(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Op(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}const Ip=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Cp(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Bp=Ip?e=>e:e=>Cp(e);function Sp(e){for(let t=0;t<e.length;t++)e[t]=Cp(e[t])}function Pp(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),wp(e),e}class jp{clone(){return this._cloneInto()}}function Ap(e){const t=(t,r)=>e(r).update(Pp(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const kp=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Up extends jp{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,Ep(e),Ep(t),Ep(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=Op(this.buffer)}update(e){xp(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=Pp(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Ip||Sp(s),this.compress(s,0,!1),Ip||Sp(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Ip||Sp(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Ip||Sp(e)}}return this}digestInto(e){xp(this),function(e,t){wp(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Ip||Sp(r),this.compress(r,0,!0),Ip||Sp(r);const s=Op(e);this.get().forEach(((e,t)=>s[t]=Bp(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Np=BigInt(2**32-1),Dp=BigInt(32);function Rp(e,t=!1){return t?{h:Number(e&Np),l:Number(e>>Dp&Np)}:{h:0|Number(e>>Dp&Np),l:0|Number(e&Np)}}const Yp={fromBig:Rp,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Rp(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Dp|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Vp=Yp,Jp=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Mp=new Uint32Array(32);function Fp(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Mp[2*e],c=Mp[2*e+1],u=Mp[2*t],h=Mp[2*t+1],p=Mp[2*r],l=Mp[2*r+1],m=Mp[2*s],_=Mp[2*s+1],b=Vp.add3L(d,u,a);c=Vp.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Vp.rotr32H(_,m),Dl:Vp.rotr32L(_,m)}),({h:l,l:p}=Vp.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Vp.rotrSH(h,u,24),Bl:Vp.rotrSL(h,u,24)}),Mp[2*e]=d,Mp[2*e+1]=c,Mp[2*t]=u,Mp[2*t+1]=h,Mp[2*r]=p,Mp[2*r+1]=l,Mp[2*s]=m,Mp[2*s+1]=_}function Xp(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Mp[2*e],c=Mp[2*e+1],u=Mp[2*t],h=Mp[2*t+1],p=Mp[2*r],l=Mp[2*r+1],m=Mp[2*s],_=Mp[2*s+1],b=Vp.add3L(d,u,a);c=Vp.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Vp.rotrSH(_,m,16),Dl:Vp.rotrSL(_,m,16)}),({h:l,l:p}=Vp.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Vp.rotrBH(h,u,63),Bl:Vp.rotrBL(h,u,63)}),Mp[2*e]=d,Mp[2*e+1]=c,Mp[2*t]=u,Mp[2*t+1]=h,Mp[2*r]=p,Mp[2*r+1]=l,Mp[2*s]=m,Mp[2*s+1]=_}class Lp extends Up{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Jp[0],this.v0h=0|Jp[1],this.v1l=0|Jp[2],this.v1h=0|Jp[3],this.v2l=0|Jp[4],this.v2h=0|Jp[5],this.v3l=0|Jp[6],this.v3h=0|Jp[7],this.v4l=0|Jp[8],this.v4h=0|Jp[9],this.v5l=0|Jp[10],this.v5h=0|Jp[11],this.v6l=0|Jp[12],this.v6h=0|Jp[13],this.v7l=0|Jp[14],this.v7h=0|Jp[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=Op(Pp(e.salt));this.v4l^=Bp(t[0]),this.v4h^=Bp(t[1]),this.v5l^=Bp(t[2]),this.v5h^=Bp(t[3])}if(e.personalization){const t=Op(Pp(e.personalization));this.v6l^=Bp(t[0]),this.v6h^=Bp(t[1]),this.v7l^=Bp(t[2]),this.v7h^=Bp(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(Pp(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:p,v6h:l,v7l:m,v7h:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|p,this.v6h=0|l,this.v7l=0|m,this.v7h=0|_}compress(e,t,r){this.get().forEach(((e,t)=>Mp[t]=e)),Mp.set(Jp,16);let{h:s,l:i}=Vp.fromBig(BigInt(this.length));Mp[24]=Jp[8]^i,Mp[25]=Jp[9]^s,r&&(Mp[28]=~Mp[28],Mp[29]=~Mp[29]);let n=0;const a=kp;for(let r=0;r<12;r++)Fp(0,4,8,12,e,t+2*a[n++]),Xp(0,4,8,12,e,t+2*a[n++]),Fp(1,5,9,13,e,t+2*a[n++]),Xp(1,5,9,13,e,t+2*a[n++]),Fp(2,6,10,14,e,t+2*a[n++]),Xp(2,6,10,14,e,t+2*a[n++]),Fp(3,7,11,15,e,t+2*a[n++]),Xp(3,7,11,15,e,t+2*a[n++]),Fp(0,5,10,15,e,t+2*a[n++]),Xp(0,5,10,15,e,t+2*a[n++]),Fp(1,6,11,12,e,t+2*a[n++]),Xp(1,6,11,12,e,t+2*a[n++]),Fp(2,7,8,13,e,t+2*a[n++]),Xp(2,7,8,13,e,t+2*a[n++]),Fp(3,4,9,14,e,t+2*a[n++]),Xp(3,4,9,14,e,t+2*a[n++]);this.v0l^=Mp[0]^Mp[16],this.v0h^=Mp[1]^Mp[17],this.v1l^=Mp[2]^Mp[18],this.v1h^=Mp[3]^Mp[19],this.v2l^=Mp[4]^Mp[20],this.v2h^=Mp[5]^Mp[21],this.v3l^=Mp[6]^Mp[22],this.v3h^=Mp[7]^Mp[23],this.v4l^=Mp[8]^Mp[24],this.v4h^=Mp[9]^Mp[25],this.v5l^=Mp[10]^Mp[26],this.v5h^=Mp[11]^Mp[27],this.v6l^=Mp[12]^Mp[28],this.v6h^=Mp[13]^Mp[29],this.v7l^=Mp[14]^Mp[30],this.v7h^=Mp[15]^Mp[31],Mp.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const qp=Ap((e=>new Lp(e)));function Gp(e){return pu(e).replace("0x","")}class $p{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=hp.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return $p.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=hp.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return $p.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new $p(cu(ju,e)):new $p(cu(ju,function(e){return cu(ju,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(Gc(Yu,e.value)){const t=cu(Yu,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:pc(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Nu.tagToString(e.type.Some):null,elements:e.objects.map((e=>eh(e)))}};case"MergeCoins":return{MergeCoins:{destination:eh(e.destination),sources:e.sources.map((e=>eh(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>eh(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>pc(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:eh(e.coin),amounts:e.amounts.map((e=>eh(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>eh(e))),address:eh(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>pc(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:eh(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),qp(s,{dkLen:32})}(0,e);return mc(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return hp.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:Gp(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:Gp(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return hp.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return $p.getDigestFromBytes(e)}snapshot(){return cu(ju,this)}}function zp(e){return"string"==typeof e?pu(e):e.Object?e.Object.ImmOrOwnedObject?pu(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?pu(e.Object.Receiving.objectId):pu(e.Object.SharedObject.objectId):e.UnresolvedObject?pu(e.UnresolvedObject.objectId):void 0}var Wp,Hp,Kp,Qp,Zp,el,tl,rl,sl,il=e=>{throw TypeError(e)},nl=(e,t,r)=>t.has(e)||il("Cannot "+r),al=(e,t,r)=>(nl(e,t,"read from private field"),r?r.call(e):t.get(e)),ol=(e,t,r)=>t.has(e)?il("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),dl=(e,t,r,s)=>(nl(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),cl=(e,t,r)=>(nl(e,t,"access private method"),r);const ul=Symbol.for("@mysten/transaction"),hl={buildPlugins:[],serializationPlugins:[]},pl=Symbol.for("@mysten/transaction/registry");function ll(){try{const e=globalThis;return e[pl]||(e[pl]=hl),e[pl]}catch(e){return hl}}Wp=new WeakMap,Hp=new WeakMap,Kp=new WeakMap,Qp=new WeakMap,Zp=new WeakSet,el=function(e){return kc(e)?this.pure(e):cl(this,Zp,tl).call(this,e)},tl=function(e){return cu(vu,"function"==typeof e?e(this):e)},rl=async function(e){if(!e.onlyTransactionKind&&!al(this,Qp).sender)throw new Error("Missing transaction sender");await cl(this,Zp,sl).call(this,[...al(this,Hp),_p],e)},sl=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(al(this,Qp),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let ml=class e{constructor(){ol(this,Zp),ol(this,Wp),ol(this,Hp),ol(this,Kp,new Map),ol(this,Qp),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&Gc(vu,e))return e;const t=zp(e),r=al(this,Qp).inputs.find((e=>t===zp(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:al(this,Qp).inputs.indexOf(r),type:"object"}:al(this,Qp).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:pu(e)}}:e)}));const e=ll();dl(this,Qp,new $p),dl(this,Hp,[...e.buildPlugins]),dl(this,Wp,[...e.serializationPlugins])}static fromKind(t){const r=new e;return dl(r,Qp,$p.fromKindBytes("string"==typeof t?uc(t):t)),r}static from(t){const r=new e;var s;return(s=t)&&"object"==typeof s&&!0===s[ul]?dl(r,Qp,new $p(t.getData())):"string"==typeof t&&t.startsWith("{")?dl(r,Qp,$p.restore(JSON.parse(t))):dl(r,Qp,$p.fromBytes("string"==typeof t?uc(t):t)),r}static registerGlobalSerializationPlugin(e){ll().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){ll().buildPlugins.push(e)}addSerializationPlugin(e){al(this,Wp).push(e)}addBuildPlugin(e){al(this,Hp).push(e)}addIntentResolver(e,t){if(al(this,Kp).has(e)&&al(this,Kp).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);al(this,Kp).set(e,t)}setSender(e){al(this,Qp).sender=e}setSenderIfNotSet(e){al(this,Qp).sender||(al(this,Qp).sender=e)}setExpiration(e){al(this,Qp).expiration=e?cu(Pu,e):null}setGasPrice(e){al(this,Qp).gasConfig.price=String(e)}setGasBudget(e){al(this,Qp).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==al(this,Qp).gasData.budget&&(al(this,Qp).gasConfig.budget=String(e))}setGasOwner(e){al(this,Qp).gasConfig.owner=e}setGasPayment(e){al(this,Qp).gasConfig.payment=e.map((e=>cu(fu,e)))}get blockData(){return Qu(al(this,Qp).snapshot())}getData(){return al(this,Qp).snapshot()}get[ul](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:vp((e=>kc(e)?al(this,Qp).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):al(this,Qp).addInput("pure",Gc(Su,e)?cu(Su,e):e instanceof Uint8Array?hh(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(ph(...e))}receivingRef(...e){return this.object(mh(...e))}sharedObjectRef(...e){return this.object(lh(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(al(this,Qp).commands.push(e)-1)}splitCoins(e,t){return this.add(Au.SplitCoins("string"==typeof e?this.object(e):cl(this,Zp,tl).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):cl(this,Zp,el).call(this,e)))))}mergeCoins(e,t){return this.add(Au.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Au.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Au.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Au.MoveCall({...t,arguments:e?.map((e=>cl(this,Zp,el).call(this,e)))}))}transferObjects(e,t){return this.add(Au.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):cl(this,Zp,el).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Au.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(Qu(al(this,Qp).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(cu(uh,al(this,Qp).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await cl(this,Zp,rl).call(this,e),al(this,Qp).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await cl(this,Zp,rl).call(this,e),al(this,Qp).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of al(this,Qp).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...al(this,Wp)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!al(this,Kp).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(al(this,Kp).get(s))}await cl(this,Zp,sl).call(this,r,e)}};function _l(e){const t=[];return e?.objectChanges?.forEach((e=>{const r=e?.objectType,s=rc(r);s&&t.push({type:s,type_raw:r,object:e?.objectId,version:e?.version,owner:e?.owner,change:e.type})})),t}class bl{resouceObject;async operate(e,t,r){}constructor(){}async call(e){}async call_with_witness(e,t){if(e.guard.length>0){const r=await _d.Create([...e.guard]);if(r){const s=await r.done(e.witness);if(s){const e=new ml,r=new bd(e,s);return await this.operate(new ml,r?.get_object(),t),r.destroy(),await this.sign_and_commit(e,t)}}else Ba(Ca.Fail,"guard verify")}}async check_permission_and_call(e,t,r,s,i,n){var a=[];if(t.length>0||s){const r=await cc.Instance().get_address(n);r||Ba(Ca.InvalidParam,"check_permission_and_call: account invalid");const o=await nc({permission_object:e,address:r});s&&!o.owner&&Ba(Ca.noPermission,"owner"),i&&!o.admin&&Ba(Ca.noPermission,"admin"),t.forEach((e=>{const t=Qo.HasPermission(o,e);t?.has||Ba(Ca.noPermission,e),t?.guard&&a.push(t.guard)}))}if(r.length>0&&(a=a.concat(r)),a.length>0){const e=await _d.Create([...a]),t=e?e.future_fills():[];if(e||Ba(Ca.Fail,"guard parse"),e&&0===t.length){const t=await e.done();if(t){const e=new ml,r=new bd(e,t);return await this.operate(new ml,r?.get_object(),n),r.destroy(),await this.sign_and_commit(e,n)}}return{guard:[...a],witness:e.future_fills()}}return await this.exec()}async exec(e){const t=new ml;return await this.operate(t,void 0,e),await this.sign_and_commit(t,e)}async new_with_mark(e,t,r,s,i=[hd.Launch]){const n=Ga(r?.tags?[...r.tags,...i]:[...i]);if(this.resouceObject)vd.From(e,this.resouceObject).add(t,n,r?.name);else{const i=await cc.Instance().get_address(s);if(i){const s=await Md({address:i});s?.mark_object?vd.From(e,s.mark_object).add(t,n,r?.name):(this.resouceObject=yd.From(e).create_resource2(),vd.From(e,this.resouceObject).add(t,n,r?.name))}else Ba(Ca.InvalidParam,"account - "+s)}}async sign_and_commit(e,t){const r=await cc.Instance().get_pair(t,!0);return r||Ba(Ca.Fail,"account invalid"),this.resouceObject&&(vd.From(e,this.resouceObject).launch(),this.resouceObject=void 0),await $o.Client().signAndExecuteTransaction({transaction:e,signer:r,options:{showObjectChanges:!0}})}}class gl extends bl{data;constructor(e){super(),this.data=e}async call(e){var t=!1,r=!1;const s=this.data?.object?.address;return s&&co(s)?(void 0===this.data?.builder&&void 0===this.data?.admin||(t=!0),void 0===this.data?.permission&&void 0===this.data?.biz_permission||(r=!0),void 0!==this.data?.description&&(r=!0),await this.check_permission_and_call(s,[],[],t,r,e)):await this.exec(e)}async operate(e,t,r){let s;const i=this.data?.object?.address;if(s=i&&co(i)?Qo.From(e,i):Qo.New(e,this.data?.description??""),s){if(void 0!==this.data?.description&&this.data.object&&s?.set_description(this.data.description),void 0!==this.data?.admin)switch(this.data.admin?.op){case"add":s?.add_admin(this.data.admin.addresses);break;case"remove":s?.remove_admin(this.data.admin.addresses);break;case"set":s?.remove_admin([],!0),s?.add_admin(this.data.admin.addresses);break;case"removeall":s?.remove_admin([],!0)}if(void 0!==this.data?.biz_permission)switch(this.data.biz_permission.op){case"add":this.data.biz_permission.data.forEach((e=>{s?.add_bizPermission(e.index,e.name)}));break;case"remove":this.data.biz_permission.permissions.forEach((e=>{s?.remove_bizPermission(e)}))}if(void 0!==this.data?.permission)switch(this.data.permission.op){case"add entity":s?.add_entity(this.data.permission.entities);break;case"add permission":s?.add_entity3(this.data.permission.permissions);break;case"remove entity":s?.remove_entity(this.data.permission.addresses);break;case"remove permission":s?.remove_index(this.data.permission.address,this.data.permission.index);break;case"transfer permission":s?.transfer_permission(this.data.permission.from_address,this.data.permission.to_address)}void 0!==this.data?.builder&&s?.change_owner(this.data.builder),i||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}var yl=a(763);const fl=e=>yl.encode(e),vl=e=>yl.decode(e);function Tl(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const El=8192;function wl(e){if(e.length<El)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=El){const s=e.slice(r,r+El);t+=String.fromCharCode(...s)}return btoa(t)}function xl(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function Ol(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}class Il{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class Cl{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Bl(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Bl(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Bl(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return fl(e);case"base64":return wl(e);case"hex":return Ol(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Bl(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Sl,Pl,jl,Al,kl=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ul=(e,t,r)=>(kl(e,t,"read from private field"),r?r.call(e):t.get(e)),Nl=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Dl=(e,t,r,s)=>(kl(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const Rl=class{constructor(e){Nl(this,Sl,void 0),Nl(this,Pl,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Dl(this,Sl,e.write),Dl(this,Pl,e.serialize??((e,t)=>{const r=new Cl({size:this.serializedSize(e)??void 0,...t});return Ul(this,Sl).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Ul(this,Sl).call(this,e,t)}serialize(e,t){return this.validate(e),new Jl(this,Ul(this,Pl).call(this,e,t))}parse(e){const t=new Il(e);return this.read(t)}transform({name:e,input:t,output:r}){return new Rl({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>Ul(this,Sl).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>Ul(this,Pl).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let Yl=Rl;Sl=new WeakMap,Pl=new WeakMap;const Vl=Symbol.for("@mysten/serialized-bcs");class Jl{constructor(e,t){Nl(this,jl,void 0),Nl(this,Al,void 0),Dl(this,jl,e),Dl(this,Al,t)}get[Vl](){return!0}toBytes(){return Ul(this,Al)}toHex(){return Ol(Ul(this,Al))}toBase64(){return wl(Ul(this,Al))}toBase58(){return fl(Ul(this,Al))}parse(){return Ul(this,jl).parse(Ul(this,Al))}}jl=new WeakMap,Al=new WeakMap;const Ml=32,Fl=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Fl)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(Fl.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Xl.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Xl.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Xl.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Xl.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Xl.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Xl.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Xl.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Xl.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Xl.HEX,(function(e,t){return e.writeVec(Array.from(xl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return Ol(new Uint8Array(t))})),t.registerType(Xl.BASE58,(function(e,t){return e.writeVec(Array.from(vl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return fl(new Uint8Array(t))})),t.registerType(Xl.BASE64,(function(e,t){return e.writeVec(Array.from(Tl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return wl(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new Fl(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return vl(e);case"base64":return Tl(e);case"hex":return xl(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new Fl(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new Cl(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new Il(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new Yl({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new Yl({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return Tl(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return wl(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return xl(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return Ol(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],p,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,p,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let p=n.indexOf(h),l=-1===p?h:a[p];{let{name:r,params:s}=this.parseTypeName(l);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Xl=Fl;function Ll(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ml,addressEncoding:"hex"}}Xl.U8="u8",Xl.U16="u16",Xl.U32="u32",Xl.U64="u64",Xl.U128="u128",Xl.U256="u256",Xl.BOOL="bool",Xl.VECTOR="vector",Xl.ADDRESS="address",Xl.STRING="string",Xl.HEX="hex-string",Xl.BASE58="base58-string",Xl.BASE64="base64-string";class ql extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"arbitration.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.fee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.arbitration),void 0!==this.data?.description&&n&&r.push(Ho.arbitration_description),void 0!==this.data?.bPaused&&r.push(Ho.arbitration_pause),null==this.data?.endpoint&&r.push(Ho.arbitration_endpoint),void 0!==this.data?.fee&&n&&r.push(Ho.arbitration_fee),void 0!==a&&n&&r.push(Ho.arbitration_treasury),void 0!==this.data?.guard&&r.push(Ho.arbitration_guard),void 0!==this.data?.voting_guard&&r.push(Ho.arbitration_voting_guard),void 0!==this.data?.arb_arbitration&&r.push(Ho.arbitration_arbitration),void 0!==this.data?.arb_new?.guard)if(co(this.data.arb_new.guard))t.push(this.data.arb_new.guard);else if(n){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Arbitration"===e.objects[0].type&&(s=e.objects[0])}s?.usage_guard&&t.push(s.usage_guard)}else this.data?.guard&&co(this.data?.guard)&&t.push(this.data.guard);return void 0!==this.data?.arb_vote&&r.push(Ho.treasury_receive),"string"==typeof this.data?.arb_vote?.voting_guard&&co(this.data?.arb_vote?.voting_guard)&&t.push(this.data?.arb_vote?.voting_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.fee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a?s=xd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.fee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i?i.get_object():a,r,i?void 0:t)}s=xd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",BigInt(this.data?.fee??0),n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;var c;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.fee&&o&&s?.set_fee(BigInt(this.data.fee),a),void 0!==d&&o&&s?.set_withdrawTreasury(d,a),void 0!==this.data?.arb_new){const t=BigInt(this.data.arb_new.data.fee),i=this.data?.arb_new.data;c=s?.arb({order:i.order,order_token_type:i.order_token_type,description:i.description,votable_proposition:i.votable_proposition,fee:t>BigInt(0)?await cc.Instance().get_coin_object(e,t,r,this.data.type_parameter):void 0},a)}if(void 0!==this.data?.arb_arbitration){const e=this.data.arb_arbitration.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_arbitration"),s?.arbitration({arb:e,feedback:this.data.arb_arbitration.feedback,indemnity:this.data.arb_arbitration.indemnity},a)}if(void 0!==this.data?.arb_vote){const e=this.data.arb_vote.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_vote"),s?.vote({arb:e,voting_guard:this.data.arb_vote.voting_guard,agrees:this.data.arb_vote.agrees},a)}if(void 0!==this.data?.arb_withdraw_fee){const e=this.data.arb_withdraw_fee.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_withdraw_fee"),s?.withdraw_fee(e,this.data.arb_withdraw_fee.data,a)}if(c&&await this.new_with_mark(e,s?.arb_launch(c),this.data?.arb_new?.namedNew,r),void 0!==this.data?.voting_guard)switch(this.data.voting_guard.op){case"add":s?.add_voting_guard(this.data.voting_guard.data,a);break;case"remove":s?.remove_voting_guard(this.data.voting_guard.guards,!1,a);break;case"set":s?.remove_voting_guard([],!0,a),s?.add_voting_guard(this.data.voting_guard.data,a);break;case"removeall":s?.remove_voting_guard([],!0,a)}void 0!==this.data.guard&&s?.set_guard(this.data.guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),n&&await this.new_with_mark(e,n.launch(),this.data?.fee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Gl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"treasury.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.treasury),void 0!==this.data?.description&&n&&r.push(Ho.treasury_descritption),void 0!==this.data?.withdraw_mode&&r.push(Ho.treasury_withdraw_mode),null==this.data?.withdraw_guard&&r.push(Ho.treasury_withdraw_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit?.guard)if(co(this.data.deposit.guard))t.push(this.data.deposit.guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}s?.deposit_guard&&t.push(s?.deposit_guard)}else this.data?.deposit_guard&&co(this.data?.deposit_guard)&&t.push(this.data.deposit_guard);if(void 0!==this.data?.receive&&r.push(Ho.treasury_receive),void 0!==this.data?.withdraw?.withdraw_guard){if("string"==typeof this.data.withdraw.withdraw_guard&&co(this.data.withdraw.withdraw_guard))t.push(this.data.withdraw.withdraw_guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}"string"==typeof s?.withdraw_guard&&t.push(s?.withdraw_guard)}}else r.push(Ho.treasury_withdraw);return await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&n&&co(n)?s=Td.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Td.New(e,this.data.type_parameter,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data.deposit){const t=await cc.Instance().get_coin_object(e,this.data.deposit.data.balance,r,this.data.type_parameter);if(t){const e=this.data.deposit.data?.index??0;s?.deposit({coin:t,index:BigInt(e),remark:this.data.deposit.data.remark??"",for_guard:this.data.deposit.data?.for_guard,for_object:this.data.deposit.data?.for_object})}}if(void 0!==this.data?.receive&&s?.receive(this.data.receive.payment,this.data.receive.received_object,n),void 0!==this.data?.withdraw&&s?.withdraw(this.data.withdraw,n),void 0!==this.data?.deposit_guard&&s?.set_deposit_guard(this.data.deposit_guard,n),void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"remove":s?.remove_withdraw_guard(this.data.withdraw_guard.guards,!1,n);break;case"set":s?.remove_withdraw_guard([],!0,n),this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"removeall":s?.remove_withdraw_guard([],!0,n)}void 0!==this.data?.withdraw_mode&&s?.set_withdraw_mode(this.data.withdraw_mode,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class $l extends bl{data;constructor(e){super(),this.data=e}async call(e){if(co(this.data.new_permission)||Ba(Ca.InvalidParam,"CallObjectPermission_Data.new_permission"+this.data.new_permission),this.data?.objects.length>0)return await this.exec(e)}async operate(e,t){const r=await Jd({objects:this.data.objects,showContent:!0});r.objects?.forEach((t=>{switch(t.type){case"Demand":const r=t;Wo.From(e,Wo.parseObjectType(r.type_raw),r.permission,r.object).change_permission(this.data.new_permission);break;case"Machine":const s=t;Zo.From(e,s.permission,s.object).change_permission(this.data.new_permission);break;case"Service":const i=t;gd.From(e,gd.parseObjectType(i.type_raw),i.permission,i.object).change_permission(this.data.new_permission);break;case"Treasury":const n=t;Td.From(e,Td.parseObjectType(n.type_raw),n.permission,n.object).change_permission(this.data.new_permission);break;case"Arbitration":const a=t;xd.From(e,xd.parseObjectType(a.type_raw),a.permission,a.object).change_permission(this.data.new_permission);break;case"Repository":const o=t;md.From(e,o.permission,o.object).change_permission(this.data.new_permission)}}))}}class zl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"demand.type_parameter");const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.demand),void 0!==this.data?.description&&i&&r.push(Ho.demand_description),void 0!==this.data?.time_expire&&i&&r.push(Ho.demand_expand_time),void 0!==this.data?.guard&&r.push(Ho.demand_guard),"reward"===this.data?.bounty?.op&&r.push(Ho.demand_yes),"refund"===this.data?.bounty?.op&&r.push(Ho.demand_refund),void 0!==this.data?.present?.guard)if(co(this.data.present.guard))t.push(this.data.present.guard);else if(i){const e=await Jd({objects:[i],showContent:!0});if(e?.objects&&"Demand"===e?.objects[0]?.type){const r=e?.objects[0];r?.guard&&t.push(r?.guard.object)}}else this.data?.guard?.address&&co(this.data?.guard.address)&&t.push(this.data.guard.address);return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&this.data.permission&&co(n)?s=Wo.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=void 0!==this.data.time_expire?Wo.New(e,this.data.type_parameter,"duration"===this.data.time_expire?.op,"duration"===this.data.time_expire?.op?this.data.time_expire.minutes:this.data.time_expire?.time,i?i.get_object():n,this.data?.description??"",i?void 0:t):Wo.New(e,this.data.type_parameter,!0,43200,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.time_expire&&a&&s?.expand_time("duration"===this.data.time_expire.op,"duration"===this.data.time_expire.op?this.data.time_expire.minutes:this.data.time_expire.time,n),void 0!==this.data?.bounty)if("add"===this.data.bounty.op){if(co(this.data.bounty.object?.address))s.deposit(this.data.bounty.object?.address);else if(void 0!==this.data.bounty.object?.balance){uo(this.data.type_parameter)||Ba(Ca.IsValidCoinType,"demand bounty");const t=await cc.Instance().get_coin_object(e,this.data.bounty.object?.balance,r,this.data.type_parameter);t&&s.deposit(t)}}else"reward"===this.data.bounty.op?s?.yes(this.data.bounty.service,n):"refund"===this.data.bounty.op&&s?.refund(n);void 0!==this.data?.present&&s?.present(this.data.present.service,this.data.present.service_pay_type,this.data.present.recommend_words,n),void 0!==this.data?.guard&&s?.set_guard(this.data.guard.address,this.data.guard?.service_id_in_guard??void 0,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Wl extends bl{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.machine),void 0!==this.data?.description&&i&&r.push(Ho.machine_description),void 0!==this.data?.endpoint&&i&&r.push(Ho.machine_endpoint),void 0!==this.data?.consensus_repository&&r.push(Ho.machine_repository),void 0!==this.data?.nodes&&r.push(Ho.machine_node),this.data?.bPublished&&r.push(Ho.machine_publish),void 0!==this.data?.progress_new&&r.push(Ho.progress),void 0!==this.data?.progress_context_repository&&r.push(Ho.progress_context_repository),void 0!==this.data?.progress_namedOperator&&r.push(Ho.progress_namedOperator),void 0!==this.data?.progress_parent&&r.push(Ho.progress_parent),void 0!==this.data?.progress_task&&r.push(Ho.progress_bind_task),void 0!==this.data?.progress_hold&&this.data.progress_hold.adminUnhold&&r.push(Ho.progress_unhold),void 0!==this.data?.bPaused&&r.push(Ho.machine_pause),void 0!==this.data?.progress_next?.guard)if(co(this.data?.progress_next?.guard))t.push(this.data?.progress_next?.guard);else if(this.data?.object&&co(i)){const e=await ed.QueryForwardGuard(this.data?.progress_next.progress,i,await cc.Instance().get_address()??"0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f",this.data.progress_next.operation.next_node_name,this.data.progress_next.operation.forward);e&&t.push(e)}return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&n&&co(n)?s=Zo.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Zo.New(e,i?i.get_object():n,this.data?.description??"",this.data?.endpoint??"",i?void 0:t)}if(s){const d=i?i.get_object():n,c=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,c),void 0!==this.data?.endpoint&&a&&s?.set_endpoint(this.data.endpoint,c),void 0!==this.data?.consensus_repository)switch(this.data.consensus_repository.op){case"add":this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)));break;case"remove":s?.remove_repository(this.data.consensus_repository.repositories,!1,c);break;case"removeall":s?.remove_repository([],!0,c);break;case"set":s?.remove_repository([],!0,c),this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)))}if(void 0!==this.data?.nodes)switch(this.data?.nodes?.op){case"add":s?.add_node(this.data.nodes.data,c);break;case"remove":s?.remove_node(this.data.nodes.names,this.data.nodes?.bTransferMyself,c);break;case"rename node":this.data.nodes.data.forEach((e=>s?.rename_node(e.old,e.new,c)));break;case"add from myself":s?.add_node2(this.data.nodes.addresses,c);break;case"add forward":this.data.nodes.data.forEach((e=>s?.add_forward(e.prior_node_name,e.node_name,e.forward,e.threshold,e.remove_forward,c)));break;case"remove forward":this.data.nodes.data.forEach((e=>s?.remove_forward(e.prior_node_name,e.node_name,e.forward_name,c)));break;case"remove pair":this.data.nodes.pairs.forEach((e=>s.remove_pair(e.prior_node_name,e.node_name,c)))}var o;if(this.data?.bPublished&&s?.publish(t),void 0!==this.data?.progress_new&&(o=ed?.New(e,s?.get_object(),d,this.data?.progress_new.task_address,c)),void 0!==this.data?.progress_context_repository){const t=this.data?.progress_context_repository.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_context_repository"),ed.From(e,s?.get_object(),d,t).set_context_repository(this.data?.progress_context_repository.repository,c)}if(void 0!==this.data?.progress_namedOperator){const t=this.data?.progress_namedOperator.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_namedOperator");let r=ed.From(e,s?.get_object(),d,t);this.data.progress_namedOperator.data.forEach((e=>r.set_namedOperator(e.name,e.operators,c)))}if(void 0!==this.data?.progress_parent){const t=this.data?.progress_parent.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_parent"),this.data.progress_parent.parent?ed.From(e,s?.get_object(),d,t).parent(this.data.progress_parent.parent):ed.From(e,s?.get_object(),d,t).parent_none()}if(void 0!==this.data?.progress_task){const t=this.data?.progress_task.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_task"),ed.From(e,s?.get_object(),d,t).bind_task(this.data.progress_task.task,c)}if(void 0!==this.data?.progress_hold){const t=this.data?.progress_hold.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_hold"),this.data?.progress_hold.adminUnhold?ed.From(e,s?.get_object(),d,t).unhold(this.data.progress_hold.operation,c):ed.From(e,s?.get_object(),d,t).hold(this.data.progress_hold.operation,this.data.progress_hold.bHold)}const u=o?.launch();u&&await this.new_with_mark(e,u,this.data?.progress_new?.namedNew,r),void 0!==this.data?.progress_next&&ed.From(e,s?.get_object(),d,this.data?.progress_next.progress).next(this.data.progress_next.operation,this.data.progress_next.deliverable,c),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,c),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s?.clone(!0,c),this.data?.clone_new?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Hl extends bl{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=this.data?.permission?.address,s=this.data?.object?.address;return r&&co(r)?(this.data?.object||t.push(Ho.repository),void 0!==this.data?.description&&s&&t.push(Ho.repository_description),void 0!==this.data?.mode&&s&&t.push(Ho.repository_mode),void 0!==this.data?.reference&&t.push(Ho.repository_reference),void 0!==this.data?.policy&&t.push(Ho.repository_policies),await this.check_permission_and_call(r,t,[],!1,void 0,e)):await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.permission&&co(n)?s=md.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=md.New(e,i?i.get_object():n,this.data?.description??"",this.data?.mode,i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.reference)switch(this.data.reference.op){case"set":s?.remove_reference([],!0,n),s?.add_reference(this.data.reference.addresses,n);break;case"add":s?.add_reference(this.data.reference.addresses,n);break;case"remove":s?.remove_reference(this.data.reference.addresses,!1,n);break;case"removeall":s?.remove_reference([],!0,n)}if(void 0!==this.data?.mode&&a&&s?.set_policy_mode(this.data.mode,n),void 0!==this.data?.policy)switch(this.data.policy.op){case"set":s?.remove_policies([],!0,n),s?.add_policies(this.data.policy.data,n);break;case"add":s?.add_policies(this.data.policy.data,n);break;case"remove":s?.remove_policies(this.data.policy.keys,!1,n);break;case"removeall":s?.remove_policies([],!0,n);break;case"rename":this.data.policy.data.forEach((e=>{s?.rename_policy(e.old,e.new,n)}))}if(void 0!==this.data?.data)switch(this.data.data.op){case"add":void 0!==this.data.data?.data?.key?s?.add_data(this.data.data.data):void 0!==this.data.data?.data?.address&&s?.add_data2(this.data.data.data);break;case"remove":this.data.data.data.forEach((e=>s?.remove(e.address,e.key)))}i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Kl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"service.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.payee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.service),void 0!==this.data?.description&&n&&r.push(Ho.service_description),void 0!==this.data?.bPaused&&r.push(Ho.service_pause),this.data?.bPublished&&r.push(Ho.service_publish),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.repository&&r.push(Ho.service_repository),void 0!==this.data?.clone_new&&r.push(Ho.service_clone),void 0!==this.data?.gen_discount&&r.push(Ho.service_discount_transfer),void 0!==this.data?.arbitration&&r.push(Ho.service_arbitration),void 0!==this.data?.buy_guard&&r.push(Ho.service_buyer_guard),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.extern_withdraw_treasury&&r.push(Ho.service_treasury),void 0!==this.data?.machine&&r.push(Ho.service_machine),void 0!==a&&n&&r.push(Ho.service_payee),void 0!==this.data?.withdraw_guard&&r.push(Ho.service_withdraw_guards),void 0!==this.data?.refund_guard&&r.push(Ho.service_refund_guards),void 0!==this.data?.customer_required_info&&r.push(Ho.service_customer_required),void 0!==this.data?.sales&&r.push(Ho.service_sales),void 0!==this.data?.order_new?.guard)if(co(this.data.order_new.guard))t.push(this.data.order_new.guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Service"===e.objects[0].type&&(s=e.objects[0])}s?.buy_guard&&t.push(s?.buy_guard)}else this.data?.buy_guard&&co(this.data.buy_guard)&&t.push(this.data?.buy_guard);return co(this.data?.order_refund?.guard)&&t.push(this.data?.order_refund?.guard),void 0!==this.data.order_withdrawl&&r.push(Ho.service_withdraw),"string"==typeof this.data?.order_withdrawl?.data?.withdraw_guard&&co(this.data?.order_withdrawl?.data?.withdraw_guard)&&t.push(this.data?.order_withdrawl?.data?.withdraw_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.payee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a&&co(a)?s=gd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.payee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i??a,r,i?void 0:t)}s=gd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.payee_treasury&&o&&s?.set_payee(d,a),void 0!==this.data?.gen_discount&&s?.discount_transfer(this.data.gen_discount,a),void 0!==this.data?.repository)switch(this.data.repository.op){case"add":this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"remove":s?.remove_repository(this.data.repository.repositories,!1,a);break;case"set":s?.remove_repository([],!0,a),this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"removeall":s?.remove_repository([],!0,a)}if(void 0!==this.data?.extern_withdraw_treasury)switch(this.data.extern_withdraw_treasury.op){case"add":this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"set":s?.remove_treasury([],!0,a),this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"remove":s?.remove_treasury(this.data.extern_withdraw_treasury.addresses,!1,a);break;case"removeall":s?.remove_treasury([],!1,a)}if(void 0!==this.data?.machine&&s?.set_machine(this.data.machine,a),void 0!==this.data?.arbitration)switch(this.data.arbitration.op){case"add":this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.token_type,a)));break;case"set":s?.remove_arbitration([],!0,a),this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.token_type,a)));break;case"remove":s?.remove_arbitration(this.data.arbitration.addresses,!1,a);break;case"removeall":s?.remove_arbitration([],!1,a)}if(void 0!==this.data?.customer_required_info&&(this.data.customer_required_info.required_info&&this.data.customer_required_info.pubkey?s?.set_customer_required(this.data.customer_required_info.pubkey,this.data.customer_required_info.required_info,a):this.data.customer_required_info.pubkey&&s?.change_required_pubkey(this.data.customer_required_info.pubkey,a)),void 0!==this.data?.sales)switch(this.data.sales.op){case"add":s?.add_sales(this.data.sales.sales,!1,a);break;case"remove":s?.remove_sales(this.data.sales.sales_name,a)}if(void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"set":s?.remove_withdraw_guards([],!0,a),s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"remove":s?.remove_withdraw_guards(this.data.withdraw_guard.addresses,!1,a);break;case"removeall":s?.remove_withdraw_guards([],!0,a)}if(void 0!==this.data?.refund_guard)switch(this.data.refund_guard.op){case"add":s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"set":s?.remove_refund_guards([],!0,a),s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"remove":s?.remove_refund_guards(this.data.refund_guard.addresses,!1,a);break;case"removeall":s?.remove_refund_guards([],!0,a)}var c;if(this.data?.bPublished&&s?.publish(a),void 0!==this.data?.order_new){let t,i=BigInt(0);this.data.order_new.buy_items.forEach((e=>{i+=BigInt(e.max_price)*BigInt(e.count)})),i>BigInt(0)&&(t=await cc.Instance().get_coin_object(e,i,r,this.data.type_parameter),t&&(c=s.order(this.data.order_new.buy_items,t,this.data.order_new.discount,this.data.order_new.machine,this.data.order_new.customer_info_crypto,a)))}if(void 0!==this.data?.order_agent){const e=this.data.order_agent.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_agent"),s?.set_order_agent(e,this.data.order_agent.agents,this.data.order_agent.progress)}if(void 0!==this.data?.order_required_info){const e=this.data.order_required_info.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_required_info"),s?.update_order_required_info(e,this.data.order_required_info.info)}if(void 0!==this.data?.order_refund){const e=this.data.order_refund.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_refund"),this.data?.order_refund?.arb&&this.data?.order_refund?.arb_token_type?s?.refund_withArb(e,this.data?.order_refund?.arb,this.data?.order_refund?.arb_token_type):s?.refund(e,this.data?.order_refund?.guard,a)}if(void 0!==this.data?.order_withdrawl&&a){const e=this.data.order_withdrawl.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_withdrawl"),s?.withdraw(e,this.data.order_withdrawl.data,a)}if(void 0!==this.data?.order_payer&&s){const e=this.data.order_payer.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_payer"),s?.change_order_payer(e,this.data.order_payer.payer_new,this.data.order_payer.progress)}if(c&&this?.data?.order_new){const t=s.order_launch(c);await this.new_with_mark(e,t.order,this.data?.order_new?.namedNewOrder,r,[hd.Launch,hd.Order]),t?.progress&&await this.new_with_mark(e,t.progress,this.data?.order_new?.namedNewProgress,r,[hd.Launch])}void 0!==this.data?.buy_guard&&s?.set_buy_guard(this.data.buy_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s.clone(this.data.clone_new?.token_type_new,!0,a),this.data?.clone_new?.namedNew,r),n&&await this.new_with_mark(e,n.launch(),this.data?.payee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Ql extends bl{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){this.data?.root||Ba(Ca.InvalidParam,"guard root node invalid"),io(this.data?.description)||Ba(Ca.IsValidDesription,"build_guard - "+this.data.description),this.data?.table?.forEach((e=>{(!lo(e.identifier)||e.identifier<1)&&Ba(Ca.InvalidParam,"table.identifer invalid"),e.bWitness||void 0!==e.value||Ba(Ca.InvalidParam,"table.value")})),this.data?.table&&jo(this.data?.table?.map((e=>e.identifier)))&&Ba(Ca.InvalidParam,"table.identifer duplicates");var s=[];Zl(this.data.root,No.TYPE_BOOL,this.data?.table??[],s);const i=Xa(Uint8Array,...s),n=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(this.data.description),e.pure.vector("u8",[].slice.call(i.reverse()))]});this.data?.table?.forEach((t=>{if(t.bWitness){const r=new Uint8Array(1);r.set([t.value_type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}else{const r=Io(Uint8Array.from(Wa.getInstance().ser(t.value_type,t.value)),t.value_type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}}));const a=e.moveCall({target:$o.Instance().guardFn("create"),arguments:[e.object(n)]});await this.new_with_mark(e,a,this.data?.namedNew,r)}}const Zl=(e,t,r,s)=>{const i=e;if(void 0!==i?.identifier){const e=r.find((e=>e.identifier===i.identifier));e?(em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))):Ba(Ca.InvalidParam,"node identifier - "+JSON.stringify(i))}else if(void 0!==i?.query){var n;if("string"==typeof i.query?n=td.find((e=>e.query_name===i.query)):"number"==typeof i.query&&(n=td.find((e=>e.query_id===i.query))),n||Ba(Ca.InvalidParam,"query invalid - "+i?.query),em(n.return,t,i),n.parameters.length===i.parameters.length)for(let e=i.parameters.length-1;e>=0;--e)Zl(i.parameters[e],n.parameters[e],r,s);else Ba(Ca.InvalidParam,"node query parameters length not match - "+JSON.stringify(i));if(s.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof i.object)co(i.object)||Ba(Ca.InvalidParam,"node object from address string - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),s.push(Wa.getInstance().ser(No.TYPE_ADDRESS,i.object));else{const e=r.find((e=>e.identifier===i.object));e?(em(e.value_type,No.TYPE_ADDRESS,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.object))):Ba(Ca.InvalidParam,"node object from identifier - "+JSON.stringify(i))}s.push(Wa.getInstance().ser("u16",n.query_id))}else if(void 0!==i?.logic)switch(em(No.TYPE_BOOL,t,i),i?.logic){case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_NOT:1!==i.parameters.length&&Ba(Ca.InvalidParam,"node logic parameters length must be 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic));break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"variable",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_HAS_SUBSTRING:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_STRING,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length))}else if(void 0!==i?.calc)i?.calc===ko.TYPE_NUMBER_ADDRESS?(em(No.TYPE_ADDRESS,t,i),1!==i.parameters.length&&Ba(Ca.InvalidParam,"node TYPE_NUMBER_ADDRESS parameters length must == 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc))):(em(No.TYPE_U256,t,i),i.parameters.length<2&&Ba(Ca.InvalidParam,"node calc parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length)));else if(void 0!==i?.value_type)em(i?.value_type,t,i),void 0===i?.value&&Ba(Ca.InvalidParam,"node value undefined - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.value_type)),i.value_type==No.TYPE_STRING||i.value_type===No.TYPE_VEC_U8?"string"==typeof i.value?s.push(Wa.getInstance().ser(No.TYPE_STRING,i.value)):s.push(Wa.getInstance().ser(No.TYPE_VEC_U8,i.value)):s.push(Wa.getInstance().ser(i?.value_type,i.value));else if(void 0!==i?.context)switch(s.push(Wa.getInstance().ser(No.TYPE_U8,i.context)),i.context){case Xo.TYPE_CLOCK:em(No.TYPE_U64,t,i);break;case Xo.TYPE_GUARD:case Xo.TYPE_SIGNER:em(No.TYPE_ADDRESS,t,i)}else if(void 0!==i?.identifier){nd(i.identifier)||Ba(Ca.IsValidGuardIdentifier,"node - "+JSON.stringify(i));const e=r.find((e=>e.identifier===i.identifier));e||Ba(Ca.InvalidParam,"identifier not found. node - "+JSON.stringify(i)),em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))}else Ba(Ca.InvalidParam,"node - "+JSON.stringify(i))},em=(e,t,r)=>{if("variable"===t)t=e;else if("number"===t){if(e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U8||e===No.TYPE_U64||e===Xo.TYPE_CLOCK)return}else if(t===No.TYPE_ADDRESS&&(e===Xo.TYPE_SIGNER||e===Xo.TYPE_GUARD))return;if(e!==t){var s="";r&&(s=" - "+JSON.stringify(r)),Ba(Ca.InvalidParam,"checkType: "+e+" require type: "+t+s)}};class tm extends bl{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){let s,i=yd.From(e);const n=this.data?.object?.address;if(s=n&&co(n)?vd.From(e,n):vd.From(e,i.create_resource2()),"destroy"!==this.data?.mark?.op){if(void 0!==this.data?.information&&i.update(this.data.information),s&&s?.get_object()){if(void 0!==this.data?.mark)switch(this.data.mark.op){case"add or set":this.data.mark.data.forEach((e=>{s?.add(e.address,e.tags,e.name)}));break;case"remove":this.data.mark.data.forEach((e=>{s?.remove(e.address,e.tags)}));break;case"removeall":this.data.mark.addresses.forEach((e=>{s?.removeall(e)}))}"transfer"===this.data?.mark?.op&&s&&co(this.data.mark.address)&&i.transfer_resource(s,this.data.mark.address),"replace"===this.data?.mark?.op&&co(this.data.mark.address)&&i.use_resource(vd.From(e,this.data.mark.address)),!n&&s&&await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}else i.destroy_resource(s)}}const rm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await pm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},sm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await lm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},im=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await gm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},nm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await _m(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},am=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await fm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},om=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await vm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},dm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await mm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},cm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Tm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},um=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await ym(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},hm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await bm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},pm=async e=>{const t=new zl(e.data);return Em(t,e.account,e.witness)},lm=async e=>{const t=new Kl(e.data);return Em(t,e.account,e.witness)},mm=async e=>{const t=new Gl(e.data);return Em(t,e.account,e.witness)},_m=async e=>{const t=new Hl(e.data);return Em(t,e.account,e.witness)},bm=async e=>{const t=new Ql(e.data);return Em(t,e.account,e.witness)},gm=async e=>{const t=new Wl(e.data);return Em(t,e.account,e.witness)},ym=async e=>{const t=new tm(e.data);return Em(t,e.account,e.witness)},fm=async e=>{const t=new gl(e.data);return Em(t,e.account,e.witness)},vm=async e=>{const t=new $l(e.data);return Em(t,e.account,e.witness)},Tm=async e=>{const t=new ql(e.data);return Em(t,e.account,e.witness)},Em=async(e,t,r)=>r?e.call_with_witness(r,t):e.call(t)})(),o})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{var e,t,r,s,i={22:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=t[e.charCodeAt(r)];if(255===u)return;for(var h=0,p=n-1;(0!==u||h<i)&&-1!==p;p--,h++)u+=a*c[p]>>>0,c[p]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");i=h,r++}for(var l=n-i;l!==n&&0===c[l];)l++;for(var m=new Uint8Array(s+(n-l)),_=s;l!==n;)m[_++]=c[l++];return m}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],p=0,l=d-1;(0!==h||p<s)&&-1!==l;l--,p++)h+=256*u[l]>>>0,u[l]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=p,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var _=o.repeat(r);m<d;++m)_+=e.charAt(u[m]);return _},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},211:()=>{},333:(e,t)=>{"use strict";t.I=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let e=0;e<32;e++){const t=r.charAt(e);s[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);if(s<33||s>126)return"Invalid prefix ("+e+")";t=i(t)^s>>5}t=i(t);for(let r=0;r<e.length;++r){const s=e.charCodeAt(r);t=i(t)^31&s}return t}function a(e,t,r,s){let i=0,n=0;const a=(1<<r)-1,o=[];for(let s=0;s<e.length;++s)for(i=i<<t|e[s],n+=t;n>=r;)n-=r,o.push(i>>n&a);if(s)n>0&&o.push(i<<r-n&a);else{if(n>=t)return"Excess padding";if(i<<r-n&a)return"Non-zero padding"}return o}function o(e){return a(e,8,5,!0)}function d(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t}function c(e){const t=a(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function u(e){let t;function a(e,r){if(r=r||90,e.length<8)return e+" too short";if(e.length>r)return"Exceeds length limit";const a=e.toLowerCase(),o=e.toUpperCase();if(e!==a&&e!==o)return"Mixed-case string "+e;const d=(e=a).lastIndexOf("1");if(-1===d)return"No separator character for "+e;if(0===d)return"Missing prefix for "+e;const c=e.slice(0,d),u=e.slice(d+1);if(u.length<6)return"Data too short";let h=n(c);if("string"==typeof h)return h;const p=[];for(let e=0;e<u.length;++e){const t=u.charAt(e),r=s[t];if(void 0===r)return"Unknown character "+t;h=i(h)^r,e+6>=u.length||p.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:c,words:p}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=a(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=a(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,s,a){if(a=a||90,e.length+7+s.length>a)throw new TypeError("Exceeds length limit");let o=n(e=e.toLowerCase());if("string"==typeof o)throw new Error(o);let d=e+"1";for(let e=0;e<s.length;++e){const t=s[e];if(t>>5)throw new Error("Non 5-bit word");o=i(o)^t,d+=r.charAt(t)}for(let e=0;e<6;++e)o=i(o);o^=t;for(let e=0;e<6;++e)d+=r.charAt(o>>5*(5-e)&31);return d},toWords:o,fromWordsUnsafe:d,fromWords:c}}t.I=u("bech32"),u("bech32m")},364:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),n=i.charCodeAt(0);if(255!==t[n])throw new TypeError(i+" is ambiguous");t[n]=s}var a=e.length,o=e.charAt(0),d=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,s=0,i=0;e[r]===o;)s++,r++;for(var n=(e.length-r)*d+1>>>0,c=new Uint8Array(n);e[r];){var u=e.charCodeAt(r);if(u>255)return;var h=t[u];if(255===h)return;for(var p=0,l=n-1;(0!==h||p<i)&&-1!==l;l--,p++)h+=a*c[l]>>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,r++}for(var m=n-i;m!==n&&0===c[m];)m++;for(var _=new Uint8Array(s+(n-m)),b=s;m!==n;)_[b++]=c[m++];return _}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var d=(n-i)*c+1>>>0,u=new Uint8Array(d);i!==n;){for(var h=t[i],p=0,l=d-1;(0!==h||p<s)&&-1!==l;l--,p++)h+=256*u[l]>>>0,u[l]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");s=p,i++}for(var m=d-s;m!==d&&0===u[m];)m++;for(var _=o.repeat(r);m<d;++m)_+=e.charAt(u[m]);return _},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},601:(e,t,r)=>{!function(e){"use strict";var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var a=t(),o=t([1]),d=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),p=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,t,r,s){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=s>>24&255,e[t+5]=s>>16&255,e[t+6]=s>>8&255,e[t+7]=255&s}function _(e,t,r,s,i){var n,a=0;for(n=0;n<i;n++)a|=e[t+n]^r[s+n];return(1&a-1>>>8)-1}function b(e,t,r,s){return _(e,t,r,s,16)}function g(e,t,r,s){return _(e,t,r,s,32)}function y(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,_=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,f=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=n,E=a,w=o,x=d,O=c,I=u,C=h,B=p,S=l,P=m,j=_,A=b,k=g,U=y,N=f,D=v,R=0;R<20;R+=2)T^=(i=(k^=(i=(S^=(i=(O^=(i=T+k|0)<<7|i>>>25)+T|0)<<9|i>>>23)+O|0)<<13|i>>>19)+S|0)<<18|i>>>14,I^=(i=(E^=(i=(U^=(i=(P^=(i=I+E|0)<<7|i>>>25)+I|0)<<9|i>>>23)+P|0)<<13|i>>>19)+U|0)<<18|i>>>14,j^=(i=(C^=(i=(w^=(i=(N^=(i=j+C|0)<<7|i>>>25)+j|0)<<9|i>>>23)+N|0)<<13|i>>>19)+w|0)<<18|i>>>14,D^=(i=(A^=(i=(B^=(i=(x^=(i=D+A|0)<<7|i>>>25)+D|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,T^=(i=(x^=(i=(w^=(i=(E^=(i=T+x|0)<<7|i>>>25)+T|0)<<9|i>>>23)+E|0)<<13|i>>>19)+w|0)<<18|i>>>14,I^=(i=(O^=(i=(B^=(i=(C^=(i=I+O|0)<<7|i>>>25)+I|0)<<9|i>>>23)+C|0)<<13|i>>>19)+B|0)<<18|i>>>14,j^=(i=(P^=(i=(S^=(i=(A^=(i=j+P|0)<<7|i>>>25)+j|0)<<9|i>>>23)+A|0)<<13|i>>>19)+S|0)<<18|i>>>14,D^=(i=(N^=(i=(U^=(i=(k^=(i=D+N|0)<<7|i>>>25)+D|0)<<9|i>>>23)+k|0)<<13|i>>>19)+U|0)<<18|i>>>14;T=T+n|0,E=E+a|0,w=w+o|0,x=x+d|0,O=O+c|0,I=I+u|0,C=C+h|0,B=B+p|0,S=S+l|0,P=P+m|0,j=j+_|0,A=A+b|0,k=k+g|0,U=U+y|0,N=N+f|0,D=D+v|0,e[0]=T>>>0&255,e[1]=T>>>8&255,e[2]=T>>>16&255,e[3]=T>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=w>>>0&255,e[9]=w>>>8&255,e[10]=w>>>16&255,e[11]=w>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=I>>>0&255,e[21]=I>>>8&255,e[22]=I>>>16&255,e[23]=I>>>24&255,e[24]=C>>>0&255,e[25]=C>>>8&255,e[26]=C>>>16&255,e[27]=C>>>24&255,e[28]=B>>>0&255,e[29]=B>>>8&255,e[30]=B>>>16&255,e[31]=B>>>24&255,e[32]=S>>>0&255,e[33]=S>>>8&255,e[34]=S>>>16&255,e[35]=S>>>24&255,e[36]=P>>>0&255,e[37]=P>>>8&255,e[38]=P>>>16&255,e[39]=P>>>24&255,e[40]=j>>>0&255,e[41]=j>>>8&255,e[42]=j>>>16&255,e[43]=j>>>24&255,e[44]=A>>>0&255,e[45]=A>>>8&255,e[46]=A>>>16&255,e[47]=A>>>24&255,e[48]=k>>>0&255,e[49]=k>>>8&255,e[50]=k>>>16&255,e[51]=k>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=N>>>0&255,e[57]=N>>>8&255,e[58]=N>>>16&255,e[59]=N>>>24&255,e[60]=D>>>0&255,e[61]=D>>>8&255,e[62]=D>>>16&255,e[63]=D>>>24&255}(e,t,r,s)}function f(e,t,r,s){!function(e,t,r,s){for(var i,n=255&s[0]|(255&s[1])<<8|(255&s[2])<<16|(255&s[3])<<24,a=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&s[4]|(255&s[5])<<8|(255&s[6])<<16|(255&s[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,p=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,m=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,_=255&s[8]|(255&s[9])<<8|(255&s[10])<<16|(255&s[11])<<24,b=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,y=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,f=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&s[12]|(255&s[13])<<8|(255&s[14])<<16|(255&s[15])<<24,T=0;T<20;T+=2)n^=(i=(g^=(i=(l^=(i=(c^=(i=n+g|0)<<7|i>>>25)+n|0)<<9|i>>>23)+c|0)<<13|i>>>19)+l|0)<<18|i>>>14,u^=(i=(a^=(i=(y^=(i=(m^=(i=u+a|0)<<7|i>>>25)+u|0)<<9|i>>>23)+m|0)<<13|i>>>19)+y|0)<<18|i>>>14,_^=(i=(h^=(i=(o^=(i=(f^=(i=_+h|0)<<7|i>>>25)+_|0)<<9|i>>>23)+f|0)<<13|i>>>19)+o|0)<<18|i>>>14,v^=(i=(b^=(i=(p^=(i=(d^=(i=v+b|0)<<7|i>>>25)+v|0)<<9|i>>>23)+d|0)<<13|i>>>19)+p|0)<<18|i>>>14,n^=(i=(d^=(i=(o^=(i=(a^=(i=n+d|0)<<7|i>>>25)+n|0)<<9|i>>>23)+a|0)<<13|i>>>19)+o|0)<<18|i>>>14,u^=(i=(c^=(i=(p^=(i=(h^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,_^=(i=(m^=(i=(l^=(i=(b^=(i=_+m|0)<<7|i>>>25)+_|0)<<9|i>>>23)+b|0)<<13|i>>>19)+l|0)<<18|i>>>14,v^=(i=(f^=(i=(y^=(i=(g^=(i=v+f|0)<<7|i>>>25)+v|0)<<9|i>>>23)+g|0)<<13|i>>>19)+y|0)<<18|i>>>14;e[0]=n>>>0&255,e[1]=n>>>8&255,e[2]=n>>>16&255,e[3]=n>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=_>>>0&255,e[9]=_>>>8&255,e[10]=_>>>16&255,e[11]=_>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=p>>>0&255,e[21]=p>>>8&255,e[22]=p>>>16&255,e[23]=p>>>24&255,e[24]=l>>>0&255,e[25]=l>>>8&255,e[26]=l>>>16&255,e[27]=l>>>24&255,e[28]=m>>>0&255,e[29]=m>>>8&255,e[30]=m>>>16&255,e[31]=m>>>24&255}(e,t,r,s)}var v=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function T(e,t,r,s,i,n,a){var o,d,c=new Uint8Array(16),u=new Uint8Array(64);for(d=0;d<16;d++)c[d]=0;for(d=0;d<8;d++)c[d]=n[d];for(;i>=64;){for(y(u,c,a,v),d=0;d<64;d++)e[t+d]=r[s+d]^u[d];for(o=1,d=8;d<16;d++)o=o+(255&c[d])|0,c[d]=255&o,o>>>=8;i-=64,t+=64,s+=64}if(i>0)for(y(u,c,a,v),d=0;d<i;d++)e[t+d]=r[s+d]^u[d];return 0}function E(e,t,r,s,i){var n,a,o=new Uint8Array(16),d=new Uint8Array(64);for(a=0;a<16;a++)o[a]=0;for(a=0;a<8;a++)o[a]=s[a];for(;r>=64;){for(y(d,o,i,v),a=0;a<64;a++)e[t+a]=d[a];for(n=1,a=8;a<16;a++)n=n+(255&o[a])|0,o[a]=255&n,n>>>=8;r-=64,t+=64}if(r>0)for(y(d,o,i,v),a=0;a<r;a++)e[t+a]=d[a];return 0}function w(e,t,r,s,i){var n=new Uint8Array(32);f(n,s,i,v);for(var a=new Uint8Array(8),o=0;o<8;o++)a[o]=s[o+16];return E(e,t,r,a,n)}function x(e,t,r,s,i,n,a){var o=new Uint8Array(32);f(o,n,a,v);for(var d=new Uint8Array(8),c=0;c<8;c++)d[c]=n[c+16];return T(e,t,r,s,i,d,o)}var O=function(e){var t,r,s,i,n,a,o,d;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),s=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|s<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(s>>>7|i<<9),n=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|n<<12),this.r[5]=n>>>1&8190,a=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(n>>>14|a<<2),o=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(a>>>11|o<<5),d=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(o>>>8|d<<8),this.r[9]=d>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function I(e,t,r,s,i,n){var a=new O(n);return a.update(r,s,i),a.finish(e,t),0}function C(e,t,r,s,i,n){var a=new Uint8Array(16);return I(a,0,r,s,i,n),b(e,t,a,0)}function B(e,t,r,s,i){var n;if(r<32)return-1;for(x(e,0,t,0,r,s,i),I(e,16,e,32,r-32,e),n=0;n<16;n++)e[n]=0;return 0}function S(e,t,r,s,i){var n,a=new Uint8Array(32);if(r<32)return-1;if(w(a,0,32,s,i),0!==C(t,16,t,32,r-32,a))return-1;for(x(e,0,t,0,r,s,i),n=0;n<32;n++)e[n]=0;return 0}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function j(e){var t,r,s=1;for(t=0;t<16;t++)r=e[t]+s+65535,s=Math.floor(r/65536),e[t]=r-65536*s;e[0]+=s-1+37*(s-1)}function A(e,t,r){for(var s,i=~(r-1),n=0;n<16;n++)s=i&(e[n]^t[n]),e[n]^=s,t[n]^=s}function k(e,r){var s,i,n,a=t(),o=t();for(s=0;s<16;s++)o[s]=r[s];for(j(o),j(o),j(o),i=0;i<2;i++){for(a[0]=o[0]-65517,s=1;s<15;s++)a[s]=o[s]-65535-(a[s-1]>>16&1),a[s-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),n=a[15]>>16&1,a[14]&=65535,A(o,a,1-n)}for(s=0;s<16;s++)e[2*s]=255&o[s],e[2*s+1]=o[s]>>8}function U(e,t){var r=new Uint8Array(32),s=new Uint8Array(32);return k(r,e),k(s,t),g(r,0,s,0)}function N(e){var t=new Uint8Array(32);return k(t,e),1&t[0]}function D(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function R(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]+r[s]}function Y(e,t,r){for(var s=0;s<16;s++)e[s]=t[s]-r[s]}function V(e,t,r){var s,i,n=0,a=0,o=0,d=0,c=0,u=0,h=0,p=0,l=0,m=0,_=0,b=0,g=0,y=0,f=0,v=0,T=0,E=0,w=0,x=0,O=0,I=0,C=0,B=0,S=0,P=0,j=0,A=0,k=0,U=0,N=0,D=r[0],R=r[1],Y=r[2],V=r[3],J=r[4],M=r[5],F=r[6],X=r[7],q=r[8],L=r[9],G=r[10],$=r[11],z=r[12],W=r[13],H=r[14],K=r[15];n+=(s=t[0])*D,a+=s*R,o+=s*Y,d+=s*V,c+=s*J,u+=s*M,h+=s*F,p+=s*X,l+=s*q,m+=s*L,_+=s*G,b+=s*$,g+=s*z,y+=s*W,f+=s*H,v+=s*K,a+=(s=t[1])*D,o+=s*R,d+=s*Y,c+=s*V,u+=s*J,h+=s*M,p+=s*F,l+=s*X,m+=s*q,_+=s*L,b+=s*G,g+=s*$,y+=s*z,f+=s*W,v+=s*H,T+=s*K,o+=(s=t[2])*D,d+=s*R,c+=s*Y,u+=s*V,h+=s*J,p+=s*M,l+=s*F,m+=s*X,_+=s*q,b+=s*L,g+=s*G,y+=s*$,f+=s*z,v+=s*W,T+=s*H,E+=s*K,d+=(s=t[3])*D,c+=s*R,u+=s*Y,h+=s*V,p+=s*J,l+=s*M,m+=s*F,_+=s*X,b+=s*q,g+=s*L,y+=s*G,f+=s*$,v+=s*z,T+=s*W,E+=s*H,w+=s*K,c+=(s=t[4])*D,u+=s*R,h+=s*Y,p+=s*V,l+=s*J,m+=s*M,_+=s*F,b+=s*X,g+=s*q,y+=s*L,f+=s*G,v+=s*$,T+=s*z,E+=s*W,w+=s*H,x+=s*K,u+=(s=t[5])*D,h+=s*R,p+=s*Y,l+=s*V,m+=s*J,_+=s*M,b+=s*F,g+=s*X,y+=s*q,f+=s*L,v+=s*G,T+=s*$,E+=s*z,w+=s*W,x+=s*H,O+=s*K,h+=(s=t[6])*D,p+=s*R,l+=s*Y,m+=s*V,_+=s*J,b+=s*M,g+=s*F,y+=s*X,f+=s*q,v+=s*L,T+=s*G,E+=s*$,w+=s*z,x+=s*W,O+=s*H,I+=s*K,p+=(s=t[7])*D,l+=s*R,m+=s*Y,_+=s*V,b+=s*J,g+=s*M,y+=s*F,f+=s*X,v+=s*q,T+=s*L,E+=s*G,w+=s*$,x+=s*z,O+=s*W,I+=s*H,C+=s*K,l+=(s=t[8])*D,m+=s*R,_+=s*Y,b+=s*V,g+=s*J,y+=s*M,f+=s*F,v+=s*X,T+=s*q,E+=s*L,w+=s*G,x+=s*$,O+=s*z,I+=s*W,C+=s*H,B+=s*K,m+=(s=t[9])*D,_+=s*R,b+=s*Y,g+=s*V,y+=s*J,f+=s*M,v+=s*F,T+=s*X,E+=s*q,w+=s*L,x+=s*G,O+=s*$,I+=s*z,C+=s*W,B+=s*H,S+=s*K,_+=(s=t[10])*D,b+=s*R,g+=s*Y,y+=s*V,f+=s*J,v+=s*M,T+=s*F,E+=s*X,w+=s*q,x+=s*L,O+=s*G,I+=s*$,C+=s*z,B+=s*W,S+=s*H,P+=s*K,b+=(s=t[11])*D,g+=s*R,y+=s*Y,f+=s*V,v+=s*J,T+=s*M,E+=s*F,w+=s*X,x+=s*q,O+=s*L,I+=s*G,C+=s*$,B+=s*z,S+=s*W,P+=s*H,j+=s*K,g+=(s=t[12])*D,y+=s*R,f+=s*Y,v+=s*V,T+=s*J,E+=s*M,w+=s*F,x+=s*X,O+=s*q,I+=s*L,C+=s*G,B+=s*$,S+=s*z,P+=s*W,j+=s*H,A+=s*K,y+=(s=t[13])*D,f+=s*R,v+=s*Y,T+=s*V,E+=s*J,w+=s*M,x+=s*F,O+=s*X,I+=s*q,C+=s*L,B+=s*G,S+=s*$,P+=s*z,j+=s*W,A+=s*H,k+=s*K,f+=(s=t[14])*D,v+=s*R,T+=s*Y,E+=s*V,w+=s*J,x+=s*M,O+=s*F,I+=s*X,C+=s*q,B+=s*L,S+=s*G,P+=s*$,j+=s*z,A+=s*W,k+=s*H,U+=s*K,v+=(s=t[15])*D,a+=38*(E+=s*Y),o+=38*(w+=s*V),d+=38*(x+=s*J),c+=38*(O+=s*M),u+=38*(I+=s*F),h+=38*(C+=s*X),p+=38*(B+=s*q),l+=38*(S+=s*L),m+=38*(P+=s*G),_+=38*(j+=s*$),b+=38*(A+=s*z),g+=38*(k+=s*W),y+=38*(U+=s*H),f+=38*(N+=s*K),n=(s=(n+=38*(T+=s*R))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n=(s=(n+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(s/65536)),a=(s=a+i+65535)-65536*(i=Math.floor(s/65536)),o=(s=o+i+65535)-65536*(i=Math.floor(s/65536)),d=(s=d+i+65535)-65536*(i=Math.floor(s/65536)),c=(s=c+i+65535)-65536*(i=Math.floor(s/65536)),u=(s=u+i+65535)-65536*(i=Math.floor(s/65536)),h=(s=h+i+65535)-65536*(i=Math.floor(s/65536)),p=(s=p+i+65535)-65536*(i=Math.floor(s/65536)),l=(s=l+i+65535)-65536*(i=Math.floor(s/65536)),m=(s=m+i+65535)-65536*(i=Math.floor(s/65536)),_=(s=_+i+65535)-65536*(i=Math.floor(s/65536)),b=(s=b+i+65535)-65536*(i=Math.floor(s/65536)),g=(s=g+i+65535)-65536*(i=Math.floor(s/65536)),y=(s=y+i+65535)-65536*(i=Math.floor(s/65536)),f=(s=f+i+65535)-65536*(i=Math.floor(s/65536)),v=(s=v+i+65535)-65536*(i=Math.floor(s/65536)),n+=i-1+37*(i-1),e[0]=n,e[1]=a,e[2]=o,e[3]=d,e[4]=c,e[5]=u,e[6]=h,e[7]=p,e[8]=l,e[9]=m,e[10]=_,e[11]=b,e[12]=g,e[13]=y,e[14]=f,e[15]=v}function J(e,t){V(e,t,t)}function M(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=253;s>=0;s--)J(i,i),2!==s&&4!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function F(e,r){var s,i=t();for(s=0;s<16;s++)i[s]=r[s];for(s=250;s>=0;s--)J(i,i),1!==s&&V(i,i,r);for(s=0;s<16;s++)e[s]=i[s]}function X(e,r,s){var i,n,a=new Uint8Array(32),o=new Float64Array(80),c=t(),u=t(),h=t(),p=t(),l=t(),m=t();for(n=0;n<31;n++)a[n]=r[n];for(a[31]=127&r[31]|64,a[0]&=248,D(o,s),n=0;n<16;n++)u[n]=o[n],p[n]=c[n]=h[n]=0;for(c[0]=p[0]=1,n=254;n>=0;--n)A(c,u,i=a[n>>>3]>>>(7&n)&1),A(h,p,i),R(l,c,h),Y(c,c,h),R(h,u,p),Y(u,u,p),J(p,l),J(m,c),V(c,h,c),V(h,u,l),R(l,c,h),Y(c,c,h),J(u,c),Y(h,p,m),V(c,h,d),R(c,c,p),V(h,h,c),V(c,p,m),V(p,u,o),J(u,l),A(c,u,i),A(h,p,i);for(n=0;n<16;n++)o[n+16]=c[n],o[n+32]=h[n],o[n+48]=u[n],o[n+64]=p[n];var _=o.subarray(32),b=o.subarray(16);return M(_,_),V(b,b,_),k(e,b),0}function q(e,t){return X(e,t,n)}function L(e,t){return s(t,32),q(e,t)}function G(e,t,r){var s=new Uint8Array(32);return X(s,r,t),f(e,i,s,v)}O.prototype.blocks=function(e,t,r){for(var s,i,n,a,o,d,c,u,h,p,l,m,_,b,g,y,f,v,T,E=this.fin?0:2048,w=this.h[0],x=this.h[1],O=this.h[2],I=this.h[3],C=this.h[4],B=this.h[5],S=this.h[6],P=this.h[7],j=this.h[8],A=this.h[9],k=this.r[0],U=this.r[1],N=this.r[2],D=this.r[3],R=this.r[4],Y=this.r[5],V=this.r[6],J=this.r[7],M=this.r[8],F=this.r[9];r>=16;)p=h=0,p+=(w+=8191&(s=255&e[t+0]|(255&e[t+1])<<8))*k,p+=(x+=8191&(s>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),p+=(O+=8191&(i>>>10|(n=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*M),p+=(I+=8191&(n>>>7|(a=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*J),h=(p+=(C+=8191&(a>>>4|(o=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*V))>>>13,p&=8191,p+=(B+=o>>>1&8191)*(5*Y),p+=(S+=8191&(o>>>14|(d=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*R),p+=(P+=8191&(d>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*D),p+=(j+=8191&(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*N),l=h+=(p+=(A+=u>>>5|E)*(5*U))>>>13,l+=w*U,l+=x*k,l+=O*(5*F),l+=I*(5*M),h=(l+=C*(5*J))>>>13,l&=8191,l+=B*(5*V),l+=S*(5*Y),l+=P*(5*R),l+=j*(5*D),h+=(l+=A*(5*N))>>>13,l&=8191,m=h,m+=w*N,m+=x*U,m+=O*k,m+=I*(5*F),h=(m+=C*(5*M))>>>13,m&=8191,m+=B*(5*J),m+=S*(5*V),m+=P*(5*Y),m+=j*(5*R),_=h+=(m+=A*(5*D))>>>13,_+=w*D,_+=x*N,_+=O*U,_+=I*k,h=(_+=C*(5*F))>>>13,_&=8191,_+=B*(5*M),_+=S*(5*J),_+=P*(5*V),_+=j*(5*Y),b=h+=(_+=A*(5*R))>>>13,b+=w*R,b+=x*D,b+=O*N,b+=I*U,h=(b+=C*k)>>>13,b&=8191,b+=B*(5*F),b+=S*(5*M),b+=P*(5*J),b+=j*(5*V),g=h+=(b+=A*(5*Y))>>>13,g+=w*Y,g+=x*R,g+=O*D,g+=I*N,h=(g+=C*U)>>>13,g&=8191,g+=B*k,g+=S*(5*F),g+=P*(5*M),g+=j*(5*J),y=h+=(g+=A*(5*V))>>>13,y+=w*V,y+=x*Y,y+=O*R,y+=I*D,h=(y+=C*N)>>>13,y&=8191,y+=B*U,y+=S*k,y+=P*(5*F),y+=j*(5*M),f=h+=(y+=A*(5*J))>>>13,f+=w*J,f+=x*V,f+=O*Y,f+=I*R,h=(f+=C*D)>>>13,f&=8191,f+=B*N,f+=S*U,f+=P*k,f+=j*(5*F),v=h+=(f+=A*(5*M))>>>13,v+=w*M,v+=x*J,v+=O*V,v+=I*Y,h=(v+=C*R)>>>13,v&=8191,v+=B*D,v+=S*N,v+=P*U,v+=j*k,T=h+=(v+=A*(5*F))>>>13,T+=w*F,T+=x*M,T+=O*J,T+=I*V,h=(T+=C*Y)>>>13,T&=8191,T+=B*R,T+=S*D,T+=P*N,T+=j*U,w=p=8191&(h=(h=((h+=(T+=A*k)>>>13)<<2)+h|0)+(p&=8191)|0),x=l+=h>>>=13,O=m&=8191,I=_&=8191,C=b&=8191,B=g&=8191,S=y&=8191,P=f&=8191,j=v&=8191,A=T&=8191,t+=16,r-=16;this.h[0]=w,this.h[1]=x,this.h[2]=O,this.h[3]=I,this.h[4]=C,this.h[5]=B,this.h[6]=S,this.h[7]=P,this.h[8]=j,this.h[9]=A},O.prototype.finish=function(e,t){var r,s,i,n,a=new Uint16Array(10);if(this.leftover){for(n=this.leftover,this.buffer[n++]=1;n<16;n++)this.buffer[n]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,n=2;n<10;n++)this.h[n]+=r,r=this.h[n]>>>13,this.h[n]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,a[0]=this.h[0]+5,r=a[0]>>>13,a[0]&=8191,n=1;n<10;n++)a[n]=this.h[n]+r,r=a[n]>>>13,a[n]&=8191;for(a[9]-=8192,s=(1^r)-1,n=0;n<10;n++)a[n]&=s;for(s=~s,n=0;n<10;n++)this.h[n]=this.h[n]&s|a[n];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,n=1;n<8;n++)i=(this.h[n]+this.pad[n]|0)+(i>>>16)|0,this.h[n]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,r){var s,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),s=0;s<i;s++)this.buffer[this.leftover+s]=e[t+s];if(r-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(s=0;s<r;s++)this.buffer[this.leftover+s]=e[t+s];this.leftover+=r}};var $=B,z=S,W=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function H(e,t,r,s){for(var i,n,a,o,d,c,u,h,p,l,m,_,b,g,y,f,v,T,E,w,x,O,I,C,B,S,P=new Int32Array(16),j=new Int32Array(16),A=e[0],k=e[1],U=e[2],N=e[3],D=e[4],R=e[5],Y=e[6],V=e[7],J=t[0],M=t[1],F=t[2],X=t[3],q=t[4],L=t[5],G=t[6],$=t[7],z=0;s>=128;){for(E=0;E<16;E++)w=8*E+z,P[E]=r[w+0]<<24|r[w+1]<<16|r[w+2]<<8|r[w+3],j[E]=r[w+4]<<24|r[w+5]<<16|r[w+6]<<8|r[w+7];for(E=0;E<80;E++)if(i=A,n=k,a=U,o=N,d=D,c=R,u=Y,p=J,l=M,m=F,_=X,b=q,g=L,y=G,I=65535&(O=$),C=O>>>16,B=65535&(x=V),S=x>>>16,I+=65535&(O=(q>>>14|D<<18)^(q>>>18|D<<14)^(D>>>9|q<<23)),C+=O>>>16,B+=65535&(x=(D>>>14|q<<18)^(D>>>18|q<<14)^(q>>>9|D<<23)),S+=x>>>16,I+=65535&(O=q&L^~q&G),C+=O>>>16,B+=65535&(x=D&R^~D&Y),S+=x>>>16,I+=65535&(O=W[2*E+1]),C+=O>>>16,B+=65535&(x=W[2*E]),S+=x>>>16,x=P[E%16],C+=(O=j[E%16])>>>16,B+=65535&x,S+=x>>>16,B+=(C+=(I+=65535&O)>>>16)>>>16,I=65535&(O=T=65535&I|C<<16),C=O>>>16,B=65535&(x=v=65535&B|(S+=B>>>16)<<16),S=x>>>16,I+=65535&(O=(J>>>28|A<<4)^(A>>>2|J<<30)^(A>>>7|J<<25)),C+=O>>>16,B+=65535&(x=(A>>>28|J<<4)^(J>>>2|A<<30)^(J>>>7|A<<25)),S+=x>>>16,C+=(O=J&M^J&F^M&F)>>>16,B+=65535&(x=A&k^A&U^k&U),S+=x>>>16,h=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,f=65535&I|C<<16,I=65535&(O=_),C=O>>>16,B=65535&(x=o),S=x>>>16,C+=(O=T)>>>16,B+=65535&(x=v),S+=x>>>16,k=i,U=n,N=a,D=o=65535&(B+=(C+=(I+=65535&O)>>>16)>>>16)|(S+=B>>>16)<<16,R=d,Y=c,V=u,A=h,M=p,F=l,X=m,q=_=65535&I|C<<16,L=b,G=g,$=y,J=f,E%16==15)for(w=0;w<16;w++)x=P[w],I=65535&(O=j[w]),C=O>>>16,B=65535&x,S=x>>>16,x=P[(w+9)%16],I+=65535&(O=j[(w+9)%16]),C+=O>>>16,B+=65535&x,S+=x>>>16,v=P[(w+1)%16],I+=65535&(O=((T=j[(w+1)%16])>>>1|v<<31)^(T>>>8|v<<24)^(T>>>7|v<<25)),C+=O>>>16,B+=65535&(x=(v>>>1|T<<31)^(v>>>8|T<<24)^v>>>7),S+=x>>>16,v=P[(w+14)%16],C+=(O=((T=j[(w+14)%16])>>>19|v<<13)^(v>>>29|T<<3)^(T>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|T<<13)^(T>>>29|v<<3)^v>>>6),S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,P[w]=65535&B|S<<16,j[w]=65535&I|C<<16;I=65535&(O=J),C=O>>>16,B=65535&(x=A),S=x>>>16,x=e[0],C+=(O=t[0])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[0]=A=65535&B|S<<16,t[0]=J=65535&I|C<<16,I=65535&(O=M),C=O>>>16,B=65535&(x=k),S=x>>>16,x=e[1],C+=(O=t[1])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[1]=k=65535&B|S<<16,t[1]=M=65535&I|C<<16,I=65535&(O=F),C=O>>>16,B=65535&(x=U),S=x>>>16,x=e[2],C+=(O=t[2])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[2]=U=65535&B|S<<16,t[2]=F=65535&I|C<<16,I=65535&(O=X),C=O>>>16,B=65535&(x=N),S=x>>>16,x=e[3],C+=(O=t[3])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[3]=N=65535&B|S<<16,t[3]=X=65535&I|C<<16,I=65535&(O=q),C=O>>>16,B=65535&(x=D),S=x>>>16,x=e[4],C+=(O=t[4])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[4]=D=65535&B|S<<16,t[4]=q=65535&I|C<<16,I=65535&(O=L),C=O>>>16,B=65535&(x=R),S=x>>>16,x=e[5],C+=(O=t[5])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[5]=R=65535&B|S<<16,t[5]=L=65535&I|C<<16,I=65535&(O=G),C=O>>>16,B=65535&(x=Y),S=x>>>16,x=e[6],C+=(O=t[6])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[6]=Y=65535&B|S<<16,t[6]=G=65535&I|C<<16,I=65535&(O=$),C=O>>>16,B=65535&(x=V),S=x>>>16,x=e[7],C+=(O=t[7])>>>16,B+=65535&x,S+=x>>>16,S+=(B+=(C+=(I+=65535&O)>>>16)>>>16)>>>16,e[7]=V=65535&B|S<<16,t[7]=$=65535&I|C<<16,z+=128,s-=128}return s}function K(e,t,r){var s,i=new Int32Array(8),n=new Int32Array(8),a=new Uint8Array(256),o=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,n[0]=4089235720,n[1]=2227873595,n[2]=4271175723,n[3]=1595750129,n[4]=2917565137,n[5]=725511199,n[6]=4215389547,n[7]=327033209,H(i,n,t,r),r%=128,s=0;s<r;s++)a[s]=t[o-r+s];for(a[r]=128,a[(r=256-128*(r<112?1:0))-9]=0,m(a,r-8,o/536870912|0,o<<3),H(i,n,a,r),s=0;s<8;s++)m(e,8*s,i[s],n[s]);return 0}function Q(e,r){var s=t(),i=t(),n=t(),a=t(),o=t(),d=t(),c=t(),h=t(),p=t();Y(s,e[1],e[0]),Y(p,r[1],r[0]),V(s,s,p),R(i,e[0],e[1]),R(p,r[0],r[1]),V(i,i,p),V(n,e[3],r[3]),V(n,n,u),V(a,e[2],r[2]),R(a,a,a),Y(o,i,s),Y(d,a,n),R(c,a,n),R(h,i,s),V(e[0],o,d),V(e[1],h,c),V(e[2],c,d),V(e[3],o,h)}function Z(e,t,r){var s;for(s=0;s<4;s++)A(e[s],t[s],r)}function ee(e,r){var s=t(),i=t(),n=t();M(n,r[2]),V(s,r[0],n),V(i,r[1],n),k(e,i),e[31]^=N(s)<<7}function te(e,t,r){var s,i;for(P(e[0],a),P(e[1],o),P(e[2],o),P(e[3],a),i=255;i>=0;--i)Z(e,t,s=r[i/8|0]>>(7&i)&1),Q(t,e),Q(e,e),Z(e,t,s)}function re(e,r){var s=[t(),t(),t(),t()];P(s[0],h),P(s[1],p),P(s[2],o),V(s[3],h,p),te(e,s,r)}function se(e,r,i){var n,a=new Uint8Array(64),o=[t(),t(),t(),t()];for(i||s(r,32),K(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,re(o,a),ee(e,o),n=0;n<32;n++)r[n+32]=e[n];return 0}var ie=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ne(e,t){var r,s,i,n;for(s=63;s>=32;--s){for(r=0,i=s-32,n=s-12;i<n;++i)t[i]+=r-16*t[s]*ie[i-(s-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[s]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ie[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ie[i];for(s=0;s<32;s++)t[s+1]+=t[s]>>8,e[s]=255&t[s]}function ae(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ne(e,r)}function oe(e,r,s,i){var n,a,o=new Uint8Array(64),d=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),h=[t(),t(),t(),t()];K(o,i,32),o[0]&=248,o[31]&=127,o[31]|=64;var p=s+64;for(n=0;n<s;n++)e[64+n]=r[n];for(n=0;n<32;n++)e[32+n]=o[32+n];for(K(c,e.subarray(32),s+32),ae(c),re(h,c),ee(e,h),n=32;n<64;n++)e[n]=i[n];for(K(d,e,s+64),ae(d),n=0;n<64;n++)u[n]=0;for(n=0;n<32;n++)u[n]=c[n];for(n=0;n<32;n++)for(a=0;a<32;a++)u[n+a]+=d[n]*o[a];return ne(e.subarray(32),u),p}function de(e,r,s,i){var n,d=new Uint8Array(32),u=new Uint8Array(64),h=[t(),t(),t(),t()],p=[t(),t(),t(),t()];if(s<64)return-1;if(function(e,r){var s=t(),i=t(),n=t(),d=t(),u=t(),h=t(),p=t();return P(e[2],o),D(e[1],r),J(n,e[1]),V(d,n,c),Y(n,n,e[2]),R(d,e[2],d),J(u,d),J(h,u),V(p,h,u),V(s,p,n),V(s,s,d),F(s,s),V(s,s,n),V(s,s,d),V(s,s,d),V(e[0],s,d),J(i,e[0]),V(i,i,d),U(i,n)&&V(e[0],e[0],l),J(i,e[0]),V(i,i,d),U(i,n)?-1:(N(e[0])===r[31]>>7&&Y(e[0],a,e[0]),V(e[3],e[0],e[1]),0)}(p,i))return-1;for(n=0;n<s;n++)e[n]=r[n];for(n=0;n<32;n++)e[n+32]=i[n];if(K(u,e,s),ae(u),te(h,p,u),re(p,r.subarray(32)),Q(h,p),ee(d,h),s-=64,g(r,0,d,0)){for(n=0;n<s;n++)e[n]=0;return-1}for(n=0;n<s;n++)e[n]=r[n+64];return s}var ce,ue=64,he=32,pe=64;function le(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function me(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function _e(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:f,crypto_stream_xor:x,crypto_stream:w,crypto_stream_salsa20_xor:T,crypto_stream_salsa20:E,crypto_onetimeauth:I,crypto_onetimeauth_verify:C,crypto_verify_16:b,crypto_verify_32:g,crypto_secretbox:B,crypto_secretbox_open:S,crypto_scalarmult:X,crypto_scalarmult_base:q,crypto_box_beforenm:G,crypto_box_afternm:$,crypto_box:function(e,t,r,s,i,n){var a=new Uint8Array(32);return G(a,i,n),$(e,t,r,s,a)},crypto_box_open:function(e,t,r,s,i,n){var a=new Uint8Array(32);return G(a,i,n),z(e,t,r,s,a)},crypto_box_keypair:L,crypto_hash:K,crypto_sign:oe,crypto_sign_keypair:se,crypto_sign_open:de,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:he,crypto_sign_SECRETKEYBYTES:pe,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:c,L:ie,pack25519:k,unpack25519:D,M:V,A:R,S:J,Z:Y,pow2523:F,add:Q,set25519:P,modL:ne,scalarmult:te,scalarbase:re},e.randomBytes=function(e){var t=new Uint8Array(e);return s(t,e),t},e.secretbox=function(e,t,r){me(e,t,r),le(r,t);for(var s=new Uint8Array(32+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+32]=e[n];return B(i,s,s.length,t,r),i.subarray(16)},e.secretbox.open=function(e,t,r){me(e,t,r),le(r,t);for(var s=new Uint8Array(16+e.length),i=new Uint8Array(s.length),n=0;n<e.length;n++)s[n+16]=e[n];return s.length<32||0!==S(i,s,s.length,t,r)?null:i.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(me(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=new Uint8Array(32);return X(r,e,t),r},e.scalarMult.base=function(e){if(me(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return q(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox(t,r,n)},e.box.before=function(e,t){me(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var r=new Uint8Array(32);return G(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,s,i){var n=e.box.before(s,i);return e.secretbox.open(t,r,n)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return L(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(me(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return q(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(me(e,t),t.length!==pe)throw new Error("bad secret key size");var r=new Uint8Array(ue+e.length);return oe(r,e,e.length,t),r},e.sign.open=function(e,t){if(me(e,t),t.length!==he)throw new Error("bad public key size");var r=new Uint8Array(e.length),s=de(r,e,e.length,t);if(s<0)return null;for(var i=new Uint8Array(s),n=0;n<i.length;n++)i[n]=r[n];return i},e.sign.detached=function(t,r){for(var s=e.sign(t,r),i=new Uint8Array(ue),n=0;n<i.length;n++)i[n]=s[n];return i},e.sign.detached.verify=function(e,t,r){if(me(e,t,r),t.length!==ue)throw new Error("bad signature size");if(r.length!==he)throw new Error("bad public key size");var s,i=new Uint8Array(ue+e.length),n=new Uint8Array(ue+e.length);for(s=0;s<ue;s++)i[s]=t[s];for(s=0;s<e.length;s++)i[s+ue]=e[s];return de(n,i,i.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(he),t=new Uint8Array(pe);return se(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(me(e),e.length!==pe)throw new Error("bad secret key size");for(var t=new Uint8Array(he),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(me(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(he),r=new Uint8Array(pe),s=0;s<32;s++)r[s]=e[s];return se(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=he,e.sign.secretKeyLength=pe,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){me(e);var t=new Uint8Array(64);return K(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return me(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===_(e,0,t,0,e.length)},e.setPRNG=function(e){s=e},(ce="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&ce.getRandomValues?e.setPRNG((function(e,t){var r,s=new Uint8Array(t);for(r=0;r<t;r+=65536)ce.getRandomValues(s.subarray(r,r+Math.min(t-r,65536)));for(r=0;r<t;r++)e[r]=s[r];_e(s)})):(ce=r(211))&&ce.randomBytes&&e.setPRNG((function(e,t){var r,s=ce.randomBytes(t);for(r=0;r<t;r++)e[r]=s[r];_e(s)}))}(e.exports?e.exports:self.nacl=self.nacl||{})},725:(e,t,r)=>{const s=r(22);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},763:(e,t,r)=>{const s=r(364);e.exports=s("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var i=Object.create(null);a.r(i);var n={};e=e||[null,t({}),t([]),t(t)];for(var o=2&s&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>n[e]=()=>r[e]));return n.default=()=>r,a.d(i,n),i},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".index.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},s="wowok_agent:",a.l=(e,t,i,n)=>{if(r[e])r[e].push(t);else{var o,d;if(void 0!==i)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var h=c[u];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==s+i){o=h;break}}o||(d=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,a.nc&&o.setAttribute("nonce",a.nc),o.setAttribute("data-webpack",s+i),o.src=e),r[e]=[t];var p=(t,s)=>{o.onerror=o.onload=null,clearTimeout(l);var i=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach((e=>e(s))),t)return t(s)},l=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),d&&document.head.appendChild(o)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var s=r.length-1;s>-1&&(!e||!/^http(s?):/.test(e));)e=r[s--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={792:0};a.f.j=(t,r)=>{var s=a.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else{var i=new Promise(((r,i)=>s=e[t]=[r,i]));r.push(s[2]=i);var n=a.p+a.u(t),o=new Error;a.l(n,(r=>{if(a.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+i+": "+n+")",o.name="ChunkLoadError",o.type=i,o.request=n,s[1](o)}}),"chunk-"+t,t)}};var t=(t,r)=>{var s,i,[n,o,d]=r,c=0;if(n.some((t=>0!==e[t]))){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);d&&d(a)}for(t&&t(r);c<n.length;c++)i=n[c],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var o={};return(()=>{"use strict";a.r(o),a.d(o,{Account:()=>cc,BCS:()=>Xl,CacheData:()=>Pd,CacheName:()=>jd,CacheType:()=>Dd,CallArbitration:()=>Ll,CallBase:()=>bl,CallDemand:()=>zl,CallGuard:()=>Ql,CallMachine:()=>Wl,CallObjectPermission:()=>$l,CallPermission:()=>gl,CallPersonal:()=>tm,CallRepository:()=>Hl,CallService:()=>Kl,CallTreasury:()=>Gl,EVENT_QUERY:()=>ac,LocalStorageCache:()=>Ud,MemeryCache:()=>kd,OBJECT_KEY:()=>Ad,ResponseData:()=>_l,WOWOK:()=>e,WowokCache:()=>Nd,call_arbitration:()=>Tm,call_arbitration_json:()=>cm,call_demand:()=>pm,call_demand_json:()=>rm,call_guard:()=>bm,call_guard_json:()=>hm,call_machine:()=>gm,call_machine_json:()=>im,call_permission:()=>fm,call_permission_json:()=>am,call_personal:()=>ym,call_personal_json:()=>um,call_repository:()=>_m,call_repository_json:()=>nm,call_service:()=>lm,call_service_json:()=>sm,call_transfer_permission:()=>vm,call_transferpermission_json:()=>om,call_treasury:()=>mm,call_treasury_json:()=>dm,data2object:()=>sc,getSuiMoveConfig:()=>ql,queryTableItem_ArbVote:()=>Ld,queryTableItem_DemandPresenter:()=>Xd,queryTableItem_PermissionEntity:()=>qd,queryTableItem_Personal:()=>Md,query_objects:()=>Jd,query_objects_json:()=>Rd,query_permission:()=>nc,query_permission_json:()=>ic,query_personal_json:()=>Vd,query_table:()=>Fd,query_table_json:()=>Yd,raw2type:()=>rc,tableItemQuery_MachineNode:()=>Gd,tableItemQuery_MarkTag:()=>Kd,tableItemQuery_ProgressHistory:()=>zd,tableItemQuery_RepositoryData:()=>Hd,tableItemQuery_ServiceSale:()=>$d,tableItemQuery_TreasuryHistory:()=>Wd});var e={};function t(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}a.r(e),a.d(e,{Arbitration:()=>xd,BCS:()=>Oa,Bcs:()=>Wa,BuyRequiredEnum:()=>ud,ContextType:()=>Xo,Demand:()=>Wo,ENTRYPOINT:()=>Lo,ERROR:()=>Ba,Ed25519Keypair:()=>Zn,Entity:()=>yd,Errors:()=>Ca,FirstLetterUppercase:()=>Po,FunctionGroup:()=>rd,GUARD_QUERIES:()=>td,Guard:()=>id,GuardFunctions:()=>sd,GuardMaker:()=>ad,GuardParser:()=>_d,IsNumberType:()=>Fo,IsValidAddress:()=>co,IsValidArgType:()=>yo,IsValidArray:()=>To,IsValidBigint:()=>po,IsValidCoinType:()=>uo,IsValidDesription:()=>io,IsValidEndpoint:()=>oo,IsValidGuardIdentifier:()=>nd,IsValidInt:()=>fo,IsValidName:()=>no,IsValidName_AllowEmpty:()=>ao,IsValidOperatorType:()=>Jo,IsValidPercent:()=>vo,IsValidTokenType:()=>go,IsValidU128:()=>_o,IsValidU256:()=>bo,IsValidU64:()=>mo,IsValidU8:()=>lo,IsValidValueType:()=>Mo,LogicsInfo:()=>Uo,MAX_DESCRIPTION_LENGTH:()=>eo,MAX_ENDPOINT_LENGTH:()=>ro,MAX_NAME_LENGTH:()=>to,MAX_U128:()=>ja,MAX_U256:()=>Aa,MAX_U64:()=>Pa,MAX_U8:()=>Sa,MODULES:()=>Ao,Machine:()=>Zo,OPTION_NONE:()=>ka,OperatorType:()=>ko,OperatorTypeArray:()=>Yo,PAYMENT_MAX_RECEIVER_COUNT:()=>Ed,ParseType:()=>Oo,Passport:()=>bd,Permission:()=>Qo,PermissionIndex:()=>Ho,PermissionInfo:()=>Ko,Progress:()=>ed,Protocol:()=>$o,Repository:()=>md,RepositoryValueType:()=>Do,RepositoryValueTypeInfo:()=>Ro,Repository_Policy_Mode:()=>od,Repository_Type:()=>dd,ResolveBalance:()=>xo,ResolveU64:()=>Eo,Resource:()=>vd,RpcResultParser:()=>zo,SER_VALUE:()=>qo,Service:()=>gd,Service_Discount_Type:()=>cd,SuiClient:()=>ei,TagName:()=>hd,TransactionBlock:()=>gs,Treasury:()=>Td,Treasury_Operation:()=>ld,Treasury_WithdrawMode:()=>pd,ValueType:()=>No,ValueTypeArray:()=>Vo,ValueTypeConvert:()=>Ua,Wowok:()=>fd,array_equal:()=>La,array_unique:()=>Ga,capitalize:()=>$a,cb_U128:()=>Ma,cb_U256:()=>Fa,cb_U64:()=>Ja,cb_U8:()=>Va,concatenate:()=>Xa,create_payment:()=>wd,decodeSuiPrivateKey:()=>Un,deepClone:()=>Za,encodeSuiPrivateKey:()=>Nn,fromHEX:()=>ea,getFaucetHost:()=>Sd,getSuiMoveConfig:()=>Ia,getUTCDayStartByDivision:()=>ho,hasDuplicates:()=>jo,insertAtHead:()=>Io,isArr:()=>Qa,isValidHttpUrl:()=>Bo,normalizeSuiAddress:()=>de,numToUint8Array:()=>Ka,parseObjectType:()=>qa,parse_object_type:()=>za,query_object:()=>So,readOption:()=>Na,readOptionString:()=>Da,readVec:()=>Ya,requestSuiFromFaucetV0:()=>Cd,requestSuiFromFaucetV1:()=>Bd,stringToUint8Array:()=>Ha,toFixed:()=>Co,toHEX:()=>ta,ulebDecode:()=>Ra});const r=8192;function s(e){if(e.length<r)return btoa(String.fromCharCode(...e));let t="";for(var s=0;s<e.length;s+=r){const i=e.slice(s,s+r);t+=String.fromCharCode(...i)}return btoa(t)}const i=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;e[n];){let s=t[e.charCodeAt(n)];if(255===s)return;let i=0;for(let e=d-1;(0!==s||i<o)&&-1!==e;e--,i++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw new Error("Non-zero carry");o=i,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let p=a;for(;u!==d;)h[p++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let p=s.repeat(i);for(;h<c;++h)p+=e.charAt(u[h]);return p},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),n=e=>i.encode(e),d=e=>i.decode(e);function c(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function u(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function h(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class p{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class l{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return m(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return m(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return m(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return h(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return n(e);case"base64":return s(e);case"hex":return u(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function m(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var _,b,g,y,f=e=>{throw TypeError(e)},v=(e,t,r)=>t.has(e)||f("Cannot "+r),T=(e,t,r)=>(v(e,t,"read from private field"),r?r.call(e):t.get(e)),E=(e,t,r)=>t.has(e)?f("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),w=(e,t,r,s)=>(v(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);_=new WeakMap,b=new WeakMap;let x=class e{constructor(e){E(this,_),E(this,b),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),w(this,_,e.write),w(this,b,e.serialize??((e,t)=>{const r=new l({initialSize:this.serializedSize(e)??void 0,...t});return T(this,_).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),T(this,_).call(this,e,t)}serialize(e,t){return this.validate(e),new C(this,T(this,b).call(this,e,t))}parse(e){const t=new p(e);return this.read(t)}fromHex(e){return this.parse(c(e))}fromBase58(e){return this.parse(d(e))}fromBase64(e){return this.parse(t(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>T(this,_).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>T(this,b).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const O=Symbol.for("@mysten/serialized-bcs");function I(e){return!!e&&"object"==typeof e&&!0===e[O]}class C{constructor(e,t){E(this,g),E(this,y),w(this,g,e),w(this,y,t)}get[O](){return!0}toBytes(){return T(this,y)}toHex(){return u(T(this,y))}toBase64(){return s(T(this,y))}toBase58(){return n(T(this,y))}parse(){return T(this,g).parse(T(this,y))}}function B({size:e,...t}){return new x({...t,serializedSize:()=>e})}function S({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function P({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function j(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function A(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??j(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function k(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}g=new WeakMap,y=new WeakMap;var U=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function N(e,t){return{kind:"validation",type:"check",reference:N,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"input",e,t),e}}}function D(e){return{kind:"validation",type:"integer",reference:D,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&A(this,"integer",e,t),e}}}function R(e){return{kind:"transformation",type:"transform",reference:R,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Y(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function V(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function J(e,t){return{kind:"schema",type:"array",reference:J,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function M(e){return{kind:"schema",type:"bigint",reference:M,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function F(e){return{kind:"schema",type:"boolean",reference:F,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function X(e){return{kind:"schema",type:"lazy",reference:X,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function q(e,t){return{kind:"schema",type:"literal",reference:q,expects:j(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:A(this,"type",e,t),e}}}function L(e,...t){const r={kind:"schema",type:"nullable",reference:L,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Y(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function G(e,...t){const r={kind:"schema",type:"nullish",reference:G,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Y(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function $(e){return{kind:"schema",type:"number",reference:$,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?A(this,"type",e,t):e.typed=!0,e}}}function z(e,t){return{kind:"schema",type:"object",reference:z,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else A(this,"type",e,t);return e}}}function W(e,...t){const r={kind:"schema",type:"optional",reference:W,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Y(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function H(e,t,r){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(k(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else A(this,"type",e,t);return e}}}function K(e){return{kind:"schema",type:"string",reference:K,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:A(this,"type",e,t),e}}}function Q(e,t){return{kind:"schema",type:"tuple",reference:Q,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else A(this,"type",e,t);return e}}}function Z(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ee(e,t){return{kind:"schema",type:"union",reference:ee,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];A(this,"type",e,t,{issues:Z(s)}),e.typed=!0}else{if(1===i?.length)return i[0];A(this,"type",e,t,{issues:Z(i)})}return e}}}function te(){return{kind:"schema",type:"unknown",reference:te,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function re(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new U(s.issues);return s.value}function se(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function ie(e){try{return 32===d(e).length}catch(e){return!1}}const ne=32;function ae(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===ne}function oe(e){return ae(e)}function de(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*ne,"0")}`}function ce(e,t=!1){return de(e,t)}function ue(e){return se(ee(Object.entries(e).map((([e,t])=>z({[e]:t})))),R((e=>({...e,$kind:Object.keys(e)[0]}))))}const he=se(K(),R((e=>de(e))),N(ae)),pe=he,le=K(),me=se(ee([K(),se($(),D())]),N((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),_e=z({objectId:he,version:me,digest:K()}),be=se(ee([z({GasCoin:q(!0)}),z({Input:se($(),D()),type:W(q("pure"))}),z({Input:se($(),D()),type:W(q("object"))}),z({Result:se($(),D())}),z({NestedResult:Q([se($(),D()),se($(),D())])})]),R((e=>({...e,$kind:Object.keys(e)[0]})))),ge=z({budget:L(me),price:L(me),owner:L(he),payment:L(J(_e))}),ye=(z({address:K(),module:K(),name:K(),typeParams:J(K())}),ee([q("address"),q("bool"),q("u8"),q("u16"),q("u32"),q("u64"),q("u128"),q("u256"),z({vector:X((()=>ye))}),z({datatype:z({package:K(),module:K(),type:K(),typeParameters:J(X((()=>ye)))})}),z({typeParameter:se($(),D())})])),fe=z({ref:L(ee([q("&"),q("&mut")])),body:ye}),ve=z({package:pe,module:K(),function:K(),typeArguments:J(K()),arguments:J(be),_argumentTypes:W(L(J(fe)))}),Te=z({name:K(),inputs:H(K(),ee([be,J(be)])),data:H(K(),te())}),Ee=ue({MoveCall:ve,TransferObjects:z({objects:J(be),address:be}),SplitCoins:z({coin:be,amounts:J(be)}),MergeCoins:z({destination:be,sources:J(be)}),Publish:z({modules:J(le),dependencies:J(pe)}),MakeMoveVec:z({type:L(K()),elements:J(be)}),Upgrade:z({modules:J(le),dependencies:J(pe),package:pe,ticket:be}),$Intent:Te}),we=ue({ImmOrOwnedObject:_e,SharedObject:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:_e}),xe=ue({Object:we,Pure:z({bytes:le}),UnresolvedPure:z({value:te()}),UnresolvedObject:z({objectId:pe,version:W(L(me)),digest:W(L(K())),initialSharedVersion:W(L(me))})}),Oe=ue({Object:we,Pure:z({bytes:le})}),Ie=ue({None:q(!0),Epoch:me}),Ce=z({version:q(2),sender:G(he),expiration:G(Ie),gasData:ge,inputs:J(xe),commands:J(Ee)}),Be={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>re(be,e))),address:re(be,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:re(be,e),amounts:t.map((e=>re(be,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:re(be,e),sources:t.map((e=>re(be,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:i})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:s(new Uint8Array(e)))),dependencies:t.map((e=>ce(e))),package:r,ticket:re(be,i)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>re(be,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>re(be,e))):re(be,t)]))),data:r}})},Se=/^vector<(.+)>$/,Pe=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class je{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(Se);if(r)return{vector:je.parseFromStr(r[1],t)};const s=e.match(Pe);if(s)return{struct:{address:t?de(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:je.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>je.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${je.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(je.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Ae=z({digest:K(),objectId:K(),version:ee([se($(),D()),K(),M()])}),ke=ue({ImmOrOwned:Ae,Shared:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:Ae}),Ue=ue({Object:ke,Pure:J(se($(),D()))}),Ne=ee([z({kind:q("Input"),index:se($(),D()),value:te(),type:W(q("object"))}),z({kind:q("Input"),index:se($(),D()),value:te(),type:q("pure")})]),De=ee([z({Epoch:se($(),D())}),z({None:L(q(!0))})]),Re=se(ee([$(),K(),M()]),N((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Ye=ee([z({bool:L(q(!0))}),z({u8:L(q(!0))}),z({u64:L(q(!0))}),z({u128:L(q(!0))}),z({address:L(q(!0))}),z({signer:L(q(!0))}),z({vector:X((()=>Ye))}),z({struct:X((()=>Ve))}),z({u16:L(q(!0))}),z({u32:L(q(!0))}),z({u256:L(q(!0))})]),Ve=z({address:K(),module:K(),name:K(),typeParams:J(Ye)}),Je=z({budget:W(Re),price:W(Re),payment:W(J(Ae)),owner:W(K())}),Me=ee([Ne,z({kind:q("GasCoin")}),z({kind:q("Result"),index:se($(),D())}),z({kind:q("NestedResult"),index:se($(),D()),resultIndex:se($(),D())})]),Fe=z({kind:q("MoveCall"),target:se(K(),N((e=>3===e.split("::").length))),typeArguments:J(K()),arguments:J(Me)}),Xe=z({kind:q("TransferObjects"),objects:J(Me),address:Me}),qe=z({kind:q("SplitCoins"),coin:Me,amounts:J(Me)}),Le=z({kind:q("MergeCoins"),destination:Me,sources:J(Me)}),Ge=z({kind:q("MakeMoveVec"),type:ee([z({Some:Ye}),z({None:L(q(!0))})]),objects:J(Me)}),$e=ee([Fe,Xe,qe,Le,z({kind:q("Publish"),modules:J(J(se($(),D()))),dependencies:J(K())}),z({kind:q("Upgrade"),modules:J(J(se($(),D()))),dependencies:J(K()),packageId:K(),ticket:Me}),Ge]);function ze(e){const r=e.inputs.map(((e,r)=>{if(e.Object)return{kind:"Input",index:r,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:r,value:{Pure:Array.from(t(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:r,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:r,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:r,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:je.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>We(e,r)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:We(e.MergeCoins.destination,r),sources:e.MergeCoins.sources.map((e=>We(e,r)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>We(e,r)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(t(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:We(e.SplitCoins.coin,r),amounts:e.SplitCoins.amounts.map((e=>We(e,r)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>We(e,r))),address:We(e.TransferObjects.address,r)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(t(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:We(e.Upgrade.ticket,r)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function We(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function He(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function Ke(e){return ee(Object.entries(e).map((([e,t])=>z({[e]:t}))))}z({version:q(1),sender:W(K()),expiration:G(De),gasConfig:Je,inputs:J(Ne),transactions:J($e)});const Qe=Ke({GasCoin:q(!0),Input:se($(),D()),Result:se($(),D()),NestedResult:Q([se($(),D()),se($(),D())])}),Ze=z({budget:L(me),price:L(me),owner:L(he),payment:L(J(_e))}),et=z({package:pe,module:K(),function:K(),typeArguments:J(K()),arguments:J(Qe)}),tt=z({name:K(),inputs:H(K(),ee([Qe,J(Qe)])),data:H(K(),te())}),rt=Ke({MoveCall:et,TransferObjects:z({objects:J(Qe),address:Qe}),SplitCoins:z({coin:Qe,amounts:J(Qe)}),MergeCoins:z({destination:Qe,sources:J(Qe)}),Publish:z({modules:J(le),dependencies:J(pe)}),MakeMoveVec:z({type:L(K()),elements:J(Qe)}),Upgrade:z({modules:J(le),dependencies:J(pe),package:pe,ticket:Qe}),$Intent:tt}),st=Ke({ImmOrOwnedObject:_e,SharedObject:z({objectId:pe,initialSharedVersion:me,mutable:F()}),Receiving:_e}),it=Ke({Object:st,Pure:z({bytes:le}),UnresolvedPure:z({value:te()}),UnresolvedObject:z({objectId:pe,version:W(L(me)),digest:W(L(K())),initialSharedVersion:W(L(me))})}),nt=Ke({None:q(!0),Epoch:me}),at=z({version:q(2),sender:G(he),expiration:G(nt),gasData:Ze,inputs:J(it),commands:J(rt)}),ot=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?s(e):e.toBase64()}}},dt=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:de(e)}}}),ct=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:de(e)}}}),ut=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:de(e)}}}),ht={u8:e=>S({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>S({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>S({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>P({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>P({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>P({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>B({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new x({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(h(e)),...e}),bytes:(e,t)=>B({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new x({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=h(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new x({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>ht.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new x({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new x({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new x({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new x({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>ht.vector(ht.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new x({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},pt=ht.bytes(ne).transform({validate:e=>{const t="string"==typeof e?e:u(e);if(!t||!ae(de(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?c(de(e)):e,output:e=>de(u(e))}),lt=ht.vector(ht.u8()).transform({name:"ObjectDigest",input:e=>d(e),output:e=>n(new Uint8Array(e)),validate:e=>{if(32!==d(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),mt=ht.struct("SuiObjectRef",{objectId:pt,version:ht.u64(),digest:lt}),_t=ht.struct("SharedObjectRef",{objectId:pt,initialSharedVersion:ht.u64(),mutable:ht.bool()}),bt=ht.enum("ObjectArg",{ImmOrOwnedObject:mt,SharedObject:_t,Receiving:mt}),gt=ht.enum("CallArg",{Pure:ht.struct("Pure",{bytes:ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})}),Object:bt}),yt=ht.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:ht.lazy((()=>yt)),struct:ht.lazy((()=>It)),u16:null,u32:null,u256:null}),ft=yt.transform({input:e=>"string"==typeof e?je.parseFromStr(e,!0):e,output:e=>je.tagToString(e)}),vt=ht.enum("Argument",{GasCoin:null,Input:ht.u16(),Result:ht.u16(),NestedResult:ht.tuple([ht.u16(),ht.u16()])}),Tt=ht.struct("ProgrammableMoveCall",{package:pt,module:ht.string(),function:ht.string(),typeArguments:ht.vector(ft),arguments:ht.vector(vt)}),Et=ht.enum("Command",{MoveCall:Tt,TransferObjects:ht.struct("TransferObjects",{objects:ht.vector(vt),address:vt}),SplitCoins:ht.struct("SplitCoins",{coin:vt,amounts:ht.vector(vt)}),MergeCoins:ht.struct("MergeCoins",{destination:vt,sources:ht.vector(vt)}),Publish:ht.struct("Publish",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(pt)}),MakeMoveVec:ht.struct("MakeMoveVec",{type:function(e){return ht.enum("Option",{None:null,Some:e})}(ft).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:ht.vector(vt)}),Upgrade:ht.struct("Upgrade",{modules:ht.vector(ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))})),dependencies:ht.vector(pt),package:pt,ticket:vt})}),wt=ht.struct("ProgrammableTransaction",{inputs:ht.vector(gt),commands:ht.vector(Et)}),xt=ht.enum("TransactionKind",{ProgrammableTransaction:wt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ot=ht.enum("TransactionExpiration",{None:null,Epoch:ht.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const It=ht.struct("StructTag",{address:pt,module:ht.string(),name:ht.string(),typeParams:ht.vector(yt)}),Ct=ht.struct("GasData",{payment:ht.vector(mt),owner:pt,price:ht.u64(),budget:ht.u64()}),Bt=ht.struct("TransactionDataV1",{kind:xt,sender:pt,gasData:Ct,expiration:Ot}),St=ht.enum("TransactionData",{V1:Bt}),Pt=ht.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),jt=ht.enum("IntentVersion",{V0:null}),At=ht.enum("AppId",{Sui:null}),kt=ht.struct("Intent",{scope:Pt,version:jt,appId:At});function Ut(e){return ht.struct(`IntentMessage<${e.name}>`,{intent:kt,value:e})}const Nt=ht.enum("CompressedSignature",{ED25519:ht.fixedArray(64,ht.u8()),Secp256k1:ht.fixedArray(64,ht.u8()),Secp256r1:ht.fixedArray(64,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Dt=ht.enum("PublicKey",{ED25519:ht.fixedArray(32,ht.u8()),Secp256k1:ht.fixedArray(33,ht.u8()),Secp256r1:ht.fixedArray(33,ht.u8()),ZkLogin:ht.vector(ht.u8())}),Rt=ht.struct("MultiSigPkMap",{pubKey:Dt,weight:ht.u8()}),Yt=ht.struct("MultiSigPublicKey",{pk_map:ht.vector(Rt),threshold:ht.u16()}),Vt=ht.struct("MultiSig",{sigs:ht.vector(Nt),bitmap:ht.u16(),multisig_pk:Yt}),Jt=ht.vector(ht.u8()).transform({input:e=>"string"==typeof e?t(e):e,output:e=>s(new Uint8Array(e))}),Mt=ht.struct("SenderSignedTransaction",{intentMessage:Ut(St),txSignatures:ht.vector(Jt)}),Ft=ht.vector(Mt,{name:"SenderSignedData"}),Xt=ht.enum("PackageUpgradeError",{UnableToFetchPackage:ht.struct("UnableToFetchPackage",{packageId:pt}),NotAPackage:ht.struct("NotAPackage",{objectId:pt}),IncompatibleUpgrade:null,DigestDoesNotMatch:ht.struct("DigestDoesNotMatch",{digest:ht.vector(ht.u8())}),UnknownUpgradePolicy:ht.struct("UnknownUpgradePolicy",{policy:ht.u8()}),PackageIDDoesNotMatch:ht.struct("PackageIDDoesNotMatch",{packageId:pt,ticketId:pt})}),qt=ht.struct("ModuleId",{address:pt,name:ht.string()}),Lt=ht.struct("MoveLocation",{module:qt,function:ht.u16(),instruction:ht.u16(),functionName:ht.option(ht.string())}),Gt=ht.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:ht.struct("IndexOutOfBounds",{idx:ht.u16()}),SecondaryIndexOutOfBounds:ht.struct("SecondaryIndexOutOfBounds",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidResultArity:ht.struct("InvalidResultArity",{resultIdx:ht.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),$t=ht.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),zt=ht.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:ht.struct("MoveObjectTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),MovePackageTooBig:ht.struct("MovePackageTooBig",{objectSize:ht.u64(),maxObjectSize:ht.u64()}),CircularObjectOwnership:ht.struct("CircularObjectOwnership",{object:pt}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:ht.option(Lt),MoveAbort:ht.tuple([Lt,ht.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:ht.struct("CommandArgumentError",{argIdx:ht.u16(),kind:Gt}),TypeArgumentError:ht.struct("TypeArgumentError",{argumentIdx:ht.u16(),kind:$t}),UnusedValueWithoutDrop:ht.struct("UnusedValueWithoutDrop",{resultIdx:ht.u16(),secondaryIdx:ht.u16()}),InvalidPublicFunctionReturnType:ht.struct("InvalidPublicFunctionReturnType",{idx:ht.u16()}),InvalidTransferObject:null,EffectsTooLarge:ht.struct("EffectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:ht.struct("PackageUpgradeError",{upgradeError:Xt}),WrittenObjectsTooLarge:ht.struct("WrittenObjectsTooLarge",{currentSize:ht.u64(),maxSize:ht.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Wt=ht.enum("ExecutionStatus",{Success:null,Failed:ht.struct("ExecutionFailed",{error:zt,command:ht.option(ht.u64())})}),Ht=ht.struct("GasCostSummary",{computationCost:ht.u64(),storageCost:ht.u64(),storageRebate:ht.u64(),nonRefundableStorageFee:ht.u64()}),Kt=ht.enum("Owner",{AddressOwner:pt,ObjectOwner:pt,Shared:ht.struct("Shared",{initialSharedVersion:ht.u64()}),Immutable:null}),Qt=ht.struct("TransactionEffectsV1",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,modifiedAtVersions:ht.vector(ht.tuple([pt,ht.u64()])),sharedObjects:ht.vector(mt),transactionDigest:lt,created:ht.vector(ht.tuple([mt,Kt])),mutated:ht.vector(ht.tuple([mt,Kt])),unwrapped:ht.vector(ht.tuple([mt,Kt])),deleted:ht.vector(mt),unwrappedThenDeleted:ht.vector(mt),wrapped:ht.vector(mt),gasObject:ht.tuple([mt,Kt]),eventsDigest:ht.option(lt),dependencies:ht.vector(lt)}),Zt=ht.tuple([ht.u64(),lt]),er=ht.enum("ObjectIn",{NotExist:null,Exist:ht.tuple([Zt,Kt])}),tr=ht.enum("ObjectOut",{NotExist:null,ObjectWrite:ht.tuple([lt,Kt]),PackageWrite:Zt}),rr=ht.enum("IDOperation",{None:null,Created:null,Deleted:null}),sr=ht.struct("EffectsObjectChange",{inputState:er,outputState:tr,idOperation:rr}),ir=ht.enum("UnchangedSharedKind",{ReadOnlyRoot:Zt,MutateDeleted:ht.u64(),ReadDeleted:ht.u64(),Cancelled:ht.u64(),PerEpochConfig:null}),nr=ht.struct("TransactionEffectsV2",{status:Wt,executedEpoch:ht.u64(),gasUsed:Ht,transactionDigest:lt,gasObjectIndex:ht.option(ht.u32()),eventsDigest:ht.option(lt),dependencies:ht.vector(lt),lamportVersion:ht.u64(),changedObjects:ht.vector(ht.tuple([pt,sr])),unchangedSharedObjects:ht.vector(ht.tuple([pt,ir])),auxDataDigest:ht.option(lt)}),ar=ht.enum("TransactionEffects",{V1:Qt,V2:nr}),or={...ht,U8:ht.u8(),U16:ht.u16(),U32:ht.u32(),U64:ht.u64(),U128:ht.u128(),U256:ht.u256(),ULEB128:ht.uleb128(),Bool:ht.bool(),String:ht.string(),Address:pt,AppId:At,Argument:vt,CallArg:gt,CompressedSignature:Nt,GasData:Ct,Intent:kt,IntentMessage:Ut,IntentScope:Pt,IntentVersion:jt,MultiSig:Vt,MultiSigPkMap:Rt,MultiSigPublicKey:Yt,ObjectArg:bt,ObjectDigest:lt,ProgrammableMoveCall:Tt,ProgrammableTransaction:wt,PublicKey:Dt,SenderSignedData:Ft,SenderSignedTransaction:Mt,SharedObjectRef:_t,StructTag:It,SuiObjectRef:mt,Command:Et,TransactionData:St,TransactionDataV1:Bt,TransactionExpiration:Ot,TransactionKind:xt,TypeTag:ft,TransactionEffects:ar},dr=(BigInt(1e9),ce("0x6"),"0x2::sui::SUI");function cr(e){if("string"==typeof e)switch(e){case"address":return or.Address;case"bool":return or.Bool;case"u8":return or.U8;case"u16":return or.U16;case"u32":return or.U32;case"u64":return or.U64;case"u128":return or.U128;case"u256":return or.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return or.vector(or.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=cr(e.vector);return t?or.vector(t):null}if("datatype"in e){const t=de(e.datatype.package);if(t===de("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return or.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=cr(e.datatype.typeParameters[0]);return t?or.vector(t):null}}if(t===de("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return or.Address}return null}function ur(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:ur(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(ur)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}ce("0x5");async function hr(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{pr(t,or.U64,e)}));break;case"TransferObjects":pr(t.TransferObjects.address,or.Address,e)}}));const a=new Map;if(n.size>0){const e=_r(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:ur(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:ur(e.MutableReference)}:{ref:null,body:ur(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&de(t.package)===de("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=cr(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=ot(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>ce(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>_r(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=de(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=ct({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:lr(e,t)}):mr(e,t)&&(s=ut({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??dt({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await _r(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await _r(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await _r(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:dr})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>re(_e,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function pr(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=ot(t.serialize(s.UnresolvedPure.value)))}function lr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function mr(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function _r(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function br(e){function t(t,r){if("string"==typeof t)return e(gr(t).serialize(r));if(t instanceof Uint8Array||I(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(or.U8.serialize(t)),t.u16=t=>e(or.U16.serialize(t)),t.u32=t=>e(or.U32.serialize(t)),t.u64=t=>e(or.U64.serialize(t)),t.u128=t=>e(or.U128.serialize(t)),t.u256=t=>e(or.U256.serialize(t)),t.bool=t=>e(or.Bool.serialize(t)),t.string=t=>e(or.String.serialize(t)),t.address=t=>e(or.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(or.vector(gr(t)).serialize(r)),t.option=(t,r)=>e(or.option(gr(t)).serialize(r)),t}function gr(e){switch(e){case"u8":return or.u8();case"u16":return or.u16();case"u32":return or.u32();case"u64":return or.u64();case"u128":return or.u128();case"u256":return or.u256();case"bool":return or.bool();case"string":return or.string();case"id":case"address":return or.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?or.vector(gr(r)):or.option(gr(r))}throw new Error(`Invalid Pure type name: ${e}`)}function yr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function fr(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function vr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");yr(e.outputLen),yr(e.blockLen)}function Tr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Er(e,t){fr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function wr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function xr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Or=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Ir(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Cr=Or?e=>e:e=>Ir(e);function Br(e){for(let t=0;t<e.length;t++)e[t]=Ir(e[t])}const Sr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Pr(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function jr(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),fr(e),e}class Ar{clone(){return this._cloneInto()}}function kr(e){const t=t=>e().update(jr(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ur(e){const t=(t,r)=>e(r).update(jr(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const Nr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Dr extends Ar{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,yr(e),yr(t),yr(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=wr(this.buffer)}update(e){Tr(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=jr(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Or||Br(s),this.compress(s,0,!1),Or||Br(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Or||Br(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Or||Br(e)}}return this}digestInto(e){Tr(this),Er(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Or||Br(r),this.compress(r,0,!0),Or||Br(r);const s=wr(e);this.get().forEach(((e,t)=>s[t]=Cr(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Rr=BigInt(2**32-1),Yr=BigInt(32);function Vr(e,t=!1){return t?{h:Number(e&Rr),l:Number(e>>Yr&Rr)}:{h:0|Number(e>>Yr&Rr),l:0|Number(e&Rr)}}const Jr={fromBig:Vr,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Vr(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Yr|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Mr=Jr,Fr=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Xr=new Uint32Array(32);function qr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],p=Xr[2*r],l=Xr[2*r+1],m=Xr[2*s],_=Xr[2*s+1],b=Mr.add3L(d,u,a);c=Mr.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Mr.rotr32H(_,m),Dl:Mr.rotr32L(_,m)}),({h:l,l:p}=Mr.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Mr.rotrSH(h,u,24),Bl:Mr.rotrSL(h,u,24)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=p,Xr[2*r+1]=l,Xr[2*s]=m,Xr[2*s+1]=_}function Lr(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Xr[2*e],c=Xr[2*e+1],u=Xr[2*t],h=Xr[2*t+1],p=Xr[2*r],l=Xr[2*r+1],m=Xr[2*s],_=Xr[2*s+1],b=Mr.add3L(d,u,a);c=Mr.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Mr.rotrSH(_,m,16),Dl:Mr.rotrSL(_,m,16)}),({h:l,l:p}=Mr.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Mr.rotrBH(h,u,63),Bl:Mr.rotrBL(h,u,63)}),Xr[2*e]=d,Xr[2*e+1]=c,Xr[2*t]=u,Xr[2*t+1]=h,Xr[2*r]=p,Xr[2*r+1]=l,Xr[2*s]=m,Xr[2*s+1]=_}class Gr extends Dr{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Fr[0],this.v0h=0|Fr[1],this.v1l=0|Fr[2],this.v1h=0|Fr[3],this.v2l=0|Fr[4],this.v2h=0|Fr[5],this.v3l=0|Fr[6],this.v3h=0|Fr[7],this.v4l=0|Fr[8],this.v4h=0|Fr[9],this.v5l=0|Fr[10],this.v5h=0|Fr[11],this.v6l=0|Fr[12],this.v6h=0|Fr[13],this.v7l=0|Fr[14],this.v7h=0|Fr[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=wr(jr(e.salt));this.v4l^=Cr(t[0]),this.v4h^=Cr(t[1]),this.v5l^=Cr(t[2]),this.v5h^=Cr(t[3])}if(e.personalization){const t=wr(jr(e.personalization));this.v6l^=Cr(t[0]),this.v6h^=Cr(t[1]),this.v7l^=Cr(t[2]),this.v7h^=Cr(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(jr(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:p,v6h:l,v7l:m,v7h:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|p,this.v6h=0|l,this.v7l=0|m,this.v7h=0|_}compress(e,t,r){this.get().forEach(((e,t)=>Xr[t]=e)),Xr.set(Fr,16);let{h:s,l:i}=Mr.fromBig(BigInt(this.length));Xr[24]=Fr[8]^i,Xr[25]=Fr[9]^s,r&&(Xr[28]=~Xr[28],Xr[29]=~Xr[29]);let n=0;const a=Nr;for(let r=0;r<12;r++)qr(0,4,8,12,e,t+2*a[n++]),Lr(0,4,8,12,e,t+2*a[n++]),qr(1,5,9,13,e,t+2*a[n++]),Lr(1,5,9,13,e,t+2*a[n++]),qr(2,6,10,14,e,t+2*a[n++]),Lr(2,6,10,14,e,t+2*a[n++]),qr(3,7,11,15,e,t+2*a[n++]),Lr(3,7,11,15,e,t+2*a[n++]),qr(0,5,10,15,e,t+2*a[n++]),Lr(0,5,10,15,e,t+2*a[n++]),qr(1,6,11,12,e,t+2*a[n++]),Lr(1,6,11,12,e,t+2*a[n++]),qr(2,7,8,13,e,t+2*a[n++]),Lr(2,7,8,13,e,t+2*a[n++]),qr(3,4,9,14,e,t+2*a[n++]),Lr(3,4,9,14,e,t+2*a[n++]);this.v0l^=Xr[0]^Xr[16],this.v0h^=Xr[1]^Xr[17],this.v1l^=Xr[2]^Xr[18],this.v1h^=Xr[3]^Xr[19],this.v2l^=Xr[4]^Xr[20],this.v2h^=Xr[5]^Xr[21],this.v3l^=Xr[6]^Xr[22],this.v3h^=Xr[7]^Xr[23],this.v4l^=Xr[8]^Xr[24],this.v4h^=Xr[9]^Xr[25],this.v5l^=Xr[10]^Xr[26],this.v5h^=Xr[11]^Xr[27],this.v6l^=Xr[12]^Xr[28],this.v6h^=Xr[13]^Xr[29],this.v7l^=Xr[14]^Xr[30],this.v7h^=Xr[15]^Xr[31],Xr.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const $r=Ur((e=>new Gr(e)));function zr(e){return de(e).replace("0x","")}class Wr{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=or.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=or.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return Wr.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new Wr(re(Ce,e)):new Wr(re(Ce,function(e){return re(Ce,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(V(Ue,e.value)){const t=re(Ue,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:s(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?je.tagToString(e.type.Some):null,elements:e.objects.map((e=>He(e)))}};case"MergeCoins":return{MergeCoins:{destination:He(e.destination),sources:e.sources.map((e=>He(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>He(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:He(e.coin),amounts:e.amounts.map((e=>He(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>He(e))),address:He(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>s(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:He(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),$r(s,{dkLen:32})}(0,e);return n(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return or.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:zr(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:zr(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return or.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return Wr.getDigestFromBytes(e)}snapshot(){return re(Ce,this)}}function Hr(e){return"string"==typeof e?de(e):e.Object?e.Object.ImmOrOwnedObject?de(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?de(e.Object.Receiving.objectId):de(e.Object.SharedObject.objectId):e.UnresolvedObject?de(e.UnresolvedObject.objectId):void 0}var Kr,Qr,Zr,es,ts,rs,ss,is,ns,as=e=>{throw TypeError(e)},os=(e,t,r)=>t.has(e)||as("Cannot "+r),ds=(e,t,r)=>(os(e,t,"read from private field"),r?r.call(e):t.get(e)),cs=(e,t,r)=>t.has(e)?as("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),us=(e,t,r,s)=>(os(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),hs=(e,t,r)=>(os(e,t,"access private method"),r);const ps=Symbol.for("@mysten/transaction");function ls(e){return!!e&&"object"==typeof e&&!0===e[ps]}const ms={buildPlugins:[],serializationPlugins:[]},_s=Symbol.for("@mysten/transaction/registry");function bs(){try{const e=globalThis;return e[_s]||(e[_s]=ms),e[_s]}catch(e){return ms}}Kr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,es=new WeakMap,ts=new WeakSet,rs=function(e){return I(e)?this.pure(e):hs(this,ts,ss).call(this,e)},ss=function(e){return re(be,"function"==typeof e?e(this):e)},is=async function(e){if(!e.onlyTransactionKind&&!ds(this,es).sender)throw new Error("Missing transaction sender");await hs(this,ts,ns).call(this,[...ds(this,Qr),hr],e)},ns=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(ds(this,es),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let gs=class e{constructor(){cs(this,ts),cs(this,Kr),cs(this,Qr),cs(this,Zr,new Map),cs(this,es),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&V(be,e))return e;const t=Hr(e),r=ds(this,es).inputs.find((e=>t===Hr(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:ds(this,es).inputs.indexOf(r),type:"object"}:ds(this,es).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:de(e)}}:e)}));const e=bs();us(this,es,new Wr),us(this,Qr,[...e.buildPlugins]),us(this,Kr,[...e.serializationPlugins])}static fromKind(r){const s=new e;return us(s,es,Wr.fromKindBytes("string"==typeof r?t(r):r)),s}static from(r){const s=new e;return ls(r)?us(s,es,new Wr(r.getData())):"string"==typeof r&&r.startsWith("{")?us(s,es,Wr.restore(JSON.parse(r))):us(s,es,Wr.fromBytes("string"==typeof r?t(r):r)),s}static registerGlobalSerializationPlugin(e){bs().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){bs().buildPlugins.push(e)}addSerializationPlugin(e){ds(this,Kr).push(e)}addBuildPlugin(e){ds(this,Qr).push(e)}addIntentResolver(e,t){if(ds(this,Zr).has(e)&&ds(this,Zr).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);ds(this,Zr).set(e,t)}setSender(e){ds(this,es).sender=e}setSenderIfNotSet(e){ds(this,es).sender||(ds(this,es).sender=e)}setExpiration(e){ds(this,es).expiration=e?re(Ie,e):null}setGasPrice(e){ds(this,es).gasConfig.price=String(e)}setGasBudget(e){ds(this,es).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==ds(this,es).gasData.budget&&(ds(this,es).gasConfig.budget=String(e))}setGasOwner(e){ds(this,es).gasConfig.owner=e}setGasPayment(e){ds(this,es).gasConfig.payment=e.map((e=>re(_e,e)))}get blockData(){return ze(ds(this,es).snapshot())}getData(){return ds(this,es).snapshot()}get[ps](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:br((e=>I(e)?ds(this,es).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):ds(this,es).addInput("pure",V(Oe,e)?re(Oe,e):e instanceof Uint8Array?ot(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(dt(...e))}receivingRef(...e){return this.object(ut(...e))}sharedObjectRef(...e){return this.object(ct(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(ds(this,es).commands.push(e)-1)}splitCoins(e,t){return this.add(Be.SplitCoins("string"==typeof e?this.object(e):hs(this,ts,ss).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):hs(this,ts,rs).call(this,e)))))}mergeCoins(e,t){return this.add(Be.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Be.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Be.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Be.MoveCall({...t,arguments:e?.map((e=>hs(this,ts,rs).call(this,e)))}))}transferObjects(e,t){return this.add(Be.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):hs(this,ts,rs).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Be.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(ze(ds(this,es).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(re(at,ds(this,es).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await hs(this,ts,is).call(this,e),ds(this,es).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await hs(this,ts,is).call(this,e),ds(this,es).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of ds(this,es).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...ds(this,Kr)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!ds(this,Zr).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(ds(this,Zr).get(s))}await hs(this,ts,ns).call(this,r,e)}};const ys=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,fs=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,vs={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class Ts extends Error{}class Es extends Ts{constructor(e,t){super(e),this.code=t,this.type=vs[t]??"ServerError"}}class ws extends Ts{constructor(e,t,r){super(e),this.status=t,this.statusText=r}}var xs,Os,Is,Cs,Bs,Ss,Ps,js,As,ks=e=>{throw TypeError(e)},Us=(e,t,r)=>t.has(e)||ks("Cannot "+r),Ns=(e,t,r)=>(Us(e,t,"read from private field"),r?r.call(e):t.get(e)),Ds=(e,t,r)=>t.has(e)?ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Rs=(e,t,r,s)=>(Us(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),Ys=(e,t,r)=>(Us(e,t,"access private method"),r);const Vs={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Js{constructor(e,t={}){if(Ds(this,Ps),Ds(this,xs,0),Ds(this,Os,0),Ds(this,Is,null),Ds(this,Cs,null),Ds(this,Bs,new Set),Ds(this,Ss,new Map),this.endpoint=e,this.options={...Vs,...t},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}(this.endpoint))}async makeRequest(e,t){const r=await Ys(this,Ps,js).call(this);return new Promise(((s,i)=>{Rs(this,xs,Ns(this,xs)+1),Ns(this,Ss).set(Ns(this,xs),{resolve:s,reject:i,timeout:setTimeout((()=>{Ns(this,Ss).delete(Ns(this,xs)),i(new Error(`Request timeout: ${e}`))}),this.options.callTimeout)}),r.send(JSON.stringify({jsonrpc:"2.0",id:Ns(this,xs),method:e,params:t}))})).then((({error:e,result:t})=>{if(e)throw new Es(e.message,e.code);return t}))}async subscribe(e){const t=new Ms(e);return Ns(this,Bs).add(t),await t.subscribe(this),()=>t.unsubscribe(this)}}xs=new WeakMap,Os=new WeakMap,Is=new WeakMap,Cs=new WeakMap,Bs=new WeakMap,Ss=new WeakMap,Ps=new WeakSet,js=function(){return Ns(this,Cs)||Rs(this,Cs,new Promise((e=>{Ns(this,Is)?.close(),Rs(this,Is,new this.options.WebSocketConstructor(this.endpoint)),Ns(this,Is).addEventListener("open",(()=>{Rs(this,Os,0),e(Ns(this,Is))})),Ns(this,Is).addEventListener("close",(()=>{var e,t;(e=this,t=Os,{set _(r){Rs(e,t,r,undefined)},get _(){return Ns(e,t,undefined)}})._++,Ns(this,Os)<=this.options.maxReconnects&&setTimeout((()=>{Ys(this,Ps,As).call(this)}),this.options.reconnectTimeout)})),Ns(this,Is).addEventListener("message",(({data:e})=>{let t;try{t=JSON.parse(e)}catch(t){return void console.error(new Error(`Failed to parse RPC message: ${e}`,{cause:t}))}if("id"in t&&null!=t.id&&Ns(this,Ss).has(t.id)){const{resolve:e,timeout:r}=Ns(this,Ss).get(t.id);clearTimeout(r),e(t)}else if("params"in t){const{params:e}=t;Ns(this,Bs).forEach((t=>{t.subscriptionId===e.subscription&&e.subscription===t.subscriptionId&&t.onMessage(e.result)}))}}))}))),Ns(this,Cs)},As=async function(){return Ns(this,Is)?.close(),Rs(this,Cs,null),Promise.allSettled([...Ns(this,Bs)].map((e=>e.subscribe(this))))};class Ms{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:t}=this;return this.subscribed=!1,null!=t&&(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[t]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const t=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=t)}}var Fs,Xs,qs,Ls,Gs,$s=e=>{throw TypeError(e)},zs=(e,t,r)=>t.has(e)||$s("Cannot "+r),Ws=(e,t,r)=>(zs(e,t,"read from private field"),r?r.call(e):t.get(e)),Hs=(e,t,r)=>t.has(e)?$s("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ks=(e,t,r,s)=>(zs(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Qs{constructor(e){Hs(this,Ls),Hs(this,Fs,0),Hs(this,Xs),Hs(this,qs),Ks(this,Xs,e)}fetch(e,t){const r=Ws(this,Xs).fetch??fetch;if(!r)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return r(e,t)}async request(e){Ks(this,Fs,Ws(this,Fs)+1);const t=await this.fetch(Ws(this,Xs).rpc?.url??Ws(this,Xs).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":"1.7.0","Client-Target-Api-Version":"1.32.0",...Ws(this,Xs).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:Ws(this,Fs),method:e.method,params:e.params})});if(!t.ok)throw new ws(`Unexpected status code: ${t.status}`,t.status,t.statusText);const r=await t.json();if("error"in r&&null!=r.error)throw new Es(r.error.message,r.error.code);return r.result}async subscribe(e){const t=await(r=Ls,s=Gs,zs(this,r,"access private method"),s).call(this).subscribe(e);var r,s;return async()=>!!await t()}}Fs=new WeakMap,Xs=new WeakMap,qs=new WeakMap,Ls=new WeakSet,Gs=function(){if(!Ws(this,qs)){const e=Ws(this,Xs).WebSocketConstructor??WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Ks(this,qs,new Js(Ws(this,Xs).websocket?.url??Ws(this,Xs).url,{WebSocketConstructor:e,...Ws(this,Xs).websocket}))}return Ws(this,qs)};const Zs=Symbol.for("@mysten/SuiClient");class ei{get[Zs](){return!0}constructor(e){this.transport=e.transport??new Qs({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,t){return await this.transport.request({method:e,params:t})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!oe(ce(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Object id ${e}`)})),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,"descending"===(e.order||"descending")]})}async getTransactionBlock(e){if(!ie(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach((e=>{if(!ie(e))throw new Error(`Invalid Transaction digest ${e}`)})),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock({transactionBlock:e,signature:t,options:r,requestType:i}){const n=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof e?e:s(e),Array.isArray(t)?t:[t],r]});if("WaitForLocalExecution"===i)try{await this.waitForTransaction({digest:n.digest})}catch(e){}return n}async signAndExecuteTransaction({transaction:e,signer:t,...r}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(t.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:n}=await t.signTransaction(s);return this.executeTransactionBlock({transactionBlock:n,signature:i,...r})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!ae(de(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach((e=>{if(!e||!oe(ce(e)))throw new Error(`Invalid Sui Stake id ${e}`)})),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,"descending"===(e.order||"descending")]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){let t;if(ls(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),t=s(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof e.transactionBlock)t=e.transactionBlock;else{if(!(e.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");t=s(e.transactionBlock)}return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,t,e.gasPrice?.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof e.transactionBlock?e.transactionBlock:s(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!oe(ce(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e?.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e?.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e?.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e?.cursor,e?.limit,e?.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"});return u(d(e.digest).slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames({format:e="dot",...t}){const{nextCursor:r,hasNextPage:s,data:i}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[t.address,t.cursor,t.limit]});return{hasNextPage:s,nextCursor:r,data:i.map((t=>function(e,t="at"){const r=e.toLowerCase();let s;if(r.includes("@")){if(!ys.test(r))throw new Error(`Invalid SuiNS name ${e}`);const[t,i]=r.split("@");s=[...t?t.split("."):[],i]}else{if(!fs.test(r))throw new Error(`Invalid SuiNS name ${e}`);s=r.split(".").slice(0,-1)}return"dot"===t?`${s.join(".")}.sui`:`${s.slice(0,-1).join(".")}@${s[s.length-1]}`}(t,e)))}}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e?.version]})}async waitForTransaction({signal:e,timeout:t=6e4,pollInterval:r=2e3,...s}){const i=AbortSignal.timeout(t),n=new Promise(((e,t)=>{i.addEventListener("abort",(()=>t(i.reason)))}));for(n.catch((()=>{}));!i.aborted;){e?.throwIfAborted();try{return await this.getTransactionBlock(s)}catch(e){await Promise.race([new Promise((e=>setTimeout(e,r))),n])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}var ti=a(601),ri=a(333);function si(e,t){return or.IntentMessage(or.fixedArray(t.length,or.u8())).serialize({intent:{scope:{[e]:!0},version:{V0:!0},appId:{Sui:!0}},value:t}).toBytes()}const ii={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},ni={ED25519:32,Secp256k1:33,Secp256r1:33},ai={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function oi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}class di{equals(e){return oi(this.toRawBytes(),e.toRawBytes())}toBase64(){return s(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){return s(this.toSuiBytes())}verifyWithIntent(e,t,r){const s=si(r,e),i=$r(s,{dkLen:32});return this.verify(i,t)}verifyPersonalMessage(e,t){return this.verifyWithIntent(or.vector(or.u8()).serialize(e).toBytes(),t,"PersonalMessage")}verifyTransaction(e,t){return this.verifyWithIntent(e,t,"TransactionData")}toSuiBytes(){const e=this.toRawBytes(),t=new Uint8Array(e.length+1);return t.set([this.flag()]),t.set(e,1),t}toSuiAddress(){return de(function(e){fr(e);let t="";for(let r=0;r<e.length;r++)t+=Sr[e[r]];return t}($r(this.toSuiBytes(),{dkLen:32})).slice(0,2*ne))}}function ci(e){return 9===e||32===e}const ui=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function hi(e){return pi[e.charCodeAt(0)]}const pi=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];function li(e,t){if(!Boolean(e))throw new Error(t)}function mi(e){return _i(e,[])}function _i(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const r=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:_i(t,r)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const r=Math.min(10,e.length),s=e.length-r,i=[];for(let s=0;s<r;++s)i.push(_i(e[s],t));return 1===s?i.push("... 1 more item"):s>1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}(e,r);return function(e,t){const r=Object.entries(e);if(0===r.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const s=r.map((([e,r])=>e+": "+_i(r,t)));return"{ "+s.join(", ")+" }"}(e,r)}(e,t);default:return String(e)}}Symbol.toStringTag,Symbol.toStringTag;const bi={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},gi=new Set(Object.keys(bi));function yi(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&gi.has(t)}var fi,vi,Ti;!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(fi||(fi={})),(Ti=vi||(vi={})).NAME="Name",Ti.DOCUMENT="Document",Ti.OPERATION_DEFINITION="OperationDefinition",Ti.VARIABLE_DEFINITION="VariableDefinition",Ti.SELECTION_SET="SelectionSet",Ti.FIELD="Field",Ti.ARGUMENT="Argument",Ti.FRAGMENT_SPREAD="FragmentSpread",Ti.INLINE_FRAGMENT="InlineFragment",Ti.FRAGMENT_DEFINITION="FragmentDefinition",Ti.VARIABLE="Variable",Ti.INT="IntValue",Ti.FLOAT="FloatValue",Ti.STRING="StringValue",Ti.BOOLEAN="BooleanValue",Ti.NULL="NullValue",Ti.ENUM="EnumValue",Ti.LIST="ListValue",Ti.OBJECT="ObjectValue",Ti.OBJECT_FIELD="ObjectField",Ti.DIRECTIVE="Directive",Ti.NAMED_TYPE="NamedType",Ti.LIST_TYPE="ListType",Ti.NON_NULL_TYPE="NonNullType",Ti.SCHEMA_DEFINITION="SchemaDefinition",Ti.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",Ti.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",Ti.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",Ti.FIELD_DEFINITION="FieldDefinition",Ti.INPUT_VALUE_DEFINITION="InputValueDefinition",Ti.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",Ti.UNION_TYPE_DEFINITION="UnionTypeDefinition",Ti.ENUM_TYPE_DEFINITION="EnumTypeDefinition",Ti.ENUM_VALUE_DEFINITION="EnumValueDefinition",Ti.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",Ti.DIRECTIVE_DEFINITION="DirectiveDefinition",Ti.SCHEMA_EXTENSION="SchemaExtension",Ti.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",Ti.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",Ti.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",Ti.UNION_TYPE_EXTENSION="UnionTypeExtension",Ti.ENUM_TYPE_EXTENSION="EnumTypeExtension",Ti.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";const Ei=Object.freeze({});function wi(e,t){const r=e[t];return"object"==typeof r?r:"function"==typeof r?{enter:r,leave:void 0}:{enter:e.enter,leave:e.leave}}const xi={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>Oi(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Ci("(",Oi(e.variableDefinitions,", "),")"),r=Oi([e.operation,Oi([e.name,t]),Oi(e.directives," ")]," ");return("query"===r?"":r+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:r,directives:s})=>e+": "+t+Ci(" = ",r)+Ci(" ",Oi(s," "))},SelectionSet:{leave:({selections:e})=>Ii(e)},Field:{leave({alias:e,name:t,arguments:r,directives:s,selectionSet:i}){const n=Ci("",e,": ")+t;let a=n+Ci("(",Oi(r,", "),")");return a.length>80&&(a=n+Ci("(\n",Bi(Oi(r,"\n")),"\n)")),Oi([a,Oi(s," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Ci(" ",Oi(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:r})=>Oi(["...",Ci("on ",e),Oi(t," "),r]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:r,directives:s,selectionSet:i})=>`fragment ${e}${Ci("(",Oi(r,", "),")")} on ${t} ${Ci("",Oi(s," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e){const t=e.replace(/"""/g,'\\"""'),r=t.split(/\r\n|[\n\r]/g),s=1===r.length,i=r.length>1&&r.slice(1).every((e=>0===e.length||ci(e.charCodeAt(0)))),n=t.endsWith('\\"""'),a=e.endsWith('"')&&!n,o=e.endsWith("\\"),d=a||o,c=!s||e.length>70||d||i||n;let u="";const h=s&&ci(e.charCodeAt(0));return(c&&!h||i)&&(u+="\n"),u+=t,(c||d)&&(u+="\n"),'"""'+u+'"""'}(e):`"${e.replace(ui,hi)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+Oi(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+Oi(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Ci("(",Oi(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:r})=>Ci("",e,"\n")+Oi(["schema",Oi(t," "),Ii(r)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi(["scalar",t,Oi(r," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["type",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:r,type:s,directives:i})=>Ci("",e,"\n")+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+": "+s+Ci(" ",Oi(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:r,defaultValue:s,directives:i})=>Ci("",e,"\n")+Oi([t+": "+r,Ci("= ",s),Oi(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:r,directives:s,fields:i})=>Ci("",e,"\n")+Oi(["interface",t,Ci("implements ",Oi(r," & ")),Oi(s," "),Ii(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:r,types:s})=>Ci("",e,"\n")+Oi(["union",t,Oi(r," "),Ci("= ",Oi(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:r,values:s})=>Ci("",e,"\n")+Oi(["enum",t,Oi(r," "),Ii(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:r})=>Ci("",e,"\n")+Oi([t,Oi(r," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:r,fields:s})=>Ci("",e,"\n")+Oi(["input",t,Oi(r," "),Ii(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:r,repeatable:s,locations:i})=>Ci("",e,"\n")+"directive @"+t+(Si(r)?Ci("(\n",Bi(Oi(r,"\n")),"\n)"):Ci("(",Oi(r,", "),")"))+(s?" repeatable":"")+" on "+Oi(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>Oi(["extend schema",Oi(e," "),Ii(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>Oi(["extend scalar",e,Oi(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend type",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:r,fields:s})=>Oi(["extend interface",e,Ci("implements ",Oi(t," & ")),Oi(r," "),Ii(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:r})=>Oi(["extend union",e,Oi(t," "),Ci("= ",Oi(r," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:r})=>Oi(["extend enum",e,Oi(t," "),Ii(r)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:r})=>Oi(["extend input",e,Oi(t," "),Ii(r)]," ")}};function Oi(e,t=""){var r;return null!==(r=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==r?r:""}function Ii(e){return Ci("{\n",Bi(Oi(e,"\n")),"\n}")}function Ci(e,t,r=""){return null!=t&&""!==t?e+t+r:""}function Bi(e){return Ci(" ",e.replace(/\n/g,"\n "))}function Si(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}var Pi,ji,Ai,ki,Ui=e=>{throw TypeError(e)},Ni=(e,t,r)=>t.has(e)||Ui("Cannot "+r),Di=(e,t,r)=>(Ni(e,t,"read from private field"),r?r.call(e):t.get(e)),Ri=(e,t,r)=>t.has(e)?Ui("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Yi=(e,t,r,s)=>(Ni(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);class Vi extends Error{}class Ji{constructor({url:e,fetch:t=fetch,headers:r={},queries:s={}}){Ri(this,Pi),Ri(this,ji),Ri(this,Ai),Ri(this,ki),Yi(this,Pi,e),Yi(this,ji,s),Yi(this,Ai,r),Yi(this,ki,((...e)=>t(...e)))}async query(e){const t=await Di(this,ki).call(this,Di(this,Pi),{method:"POST",headers:{"Content-Type":"application/json",...Di(this,Ai)},body:JSON.stringify({query:"string"==typeof e.query?String(e.query):(r=e.query,function(e,t,r=bi){const s=new Map;for(const e of Object.values(vi))s.set(e,wi(t,e));let i,n,a,o=Array.isArray(e),d=[e],c=-1,u=[],h=e;const p=[],l=[];do{c++;const e=c===d.length,g=e&&0!==u.length;if(e){if(n=0===l.length?void 0:p[p.length-1],h=a,a=l.pop(),g)if(o){h=h.slice();let e=0;for(const[t,r]of u){const s=t-e;null===r?(h.splice(s,1),e++):h[s]=r}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[e,t]of u)h[e]=t}c=i.index,d=i.keys,u=i.edits,o=i.inArray,i=i.prev}else if(a){if(n=o?c:d[c],h=a[n],null==h)continue;p.push(n)}let y;if(!Array.isArray(h)){var m,_;yi(h)||li(!1,`Invalid AST Node: ${mi(h)}.`);const r=e?null===(m=s.get(h.kind))||void 0===m?void 0:m.leave:null===(_=s.get(h.kind))||void 0===_?void 0:_.enter;if(y=null==r?void 0:r.call(t,h,n,a,p,l),y===Ei)break;if(!1===y){if(!e){p.pop();continue}}else if(void 0!==y&&(u.push([n,y]),!e)){if(!yi(y)){p.pop();continue}h=y}}var b;void 0===y&&g&&u.push([n,h]),e?p.pop():(i={inArray:o,index:c,keys:d,edits:u,prev:i},o=Array.isArray(h),d=o?h:null!==(b=r[h.kind])&&void 0!==b?b:[],c=-1,u=[],a&&l.push(a),a=h)}while(void 0!==i);return 0!==u.length?u[u.length-1][1]:e}(r,xi)),variables:e.variables,extensions:e.extensions,operationName:e.operationName})});var r;if(!t.ok)throw new Vi(`GraphQL request failed: ${t.statusText} (${t.status})`);return await t.json()}async execute(e,t){return this.query({...t,query:Di(this,ji)[e]})}}Pi=new WeakMap,ji=new WeakMap,Ai=new WeakMap,ki=new WeakMap;var Mi,Fi,Xi="Document",qi="FragmentDefinition";class Li extends Error{constructor(e,t,r,s,i,n,a){super(e),this.name="GraphQLError",this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),r&&(this.source=r),s&&(this.positions=s),n&&(this.originalError=n);var o=a;if(!o&&n){var d=n.extensions;d&&"object"==typeof d&&(o=d)}this.extensions=o||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return"GraphQLError"}}function Gi(e){return new Li(`Syntax Error: Unexpected token at ${Fi} in ${e}`)}function $i(e){if(e.lastIndex=Fi,e.test(Mi))return Mi.slice(Fi,Fi=e.lastIndex)}var zi=/ +(?=[^\s])/y;function Wi(e){for(var t=e.split("\n"),r="",s=0,i=0,n=t.length-1,a=0;a<t.length;a++)zi.lastIndex=0,zi.test(t[a])&&(a&&(!s||zi.lastIndex<s)&&(s=zi.lastIndex),i=i||a,n=a);for(var o=i;o<=n;o++)o!==i&&(r+="\n"),r+=t[o].slice(s).replace(/\\"""/g,'"""');return r}function Hi(){for(var e=0|Mi.charCodeAt(Fi++);9===e||10===e||13===e||32===e||35===e||44===e||65279===e;e=0|Mi.charCodeAt(Fi++))if(35===e)for(;10!==(e=Mi.charCodeAt(Fi++))&&13!==e;);Fi--}function Ki(){for(var e=Fi,t=0|Mi.charCodeAt(Fi++);t>=48&&t<=57||t>=65&&t<=90||95===t||t>=97&&t<=122;t=0|Mi.charCodeAt(Fi++));if(e===Fi-1)throw Gi("Name");var r=Mi.slice(e,--Fi);return Hi(),r}function Qi(){return{kind:"Name",value:Ki()}}var Zi=/(?:"""|(?:[\s\S]*?[^\\])""")/y,en=/(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;function tn(e){var t;switch(Mi.charCodeAt(Fi)){case 91:Fi++,Hi();for(var r=[];93!==Mi.charCodeAt(Fi);)r.push(tn(e));return Fi++,Hi(),{kind:"ListValue",values:r};case 123:Fi++,Hi();for(var s=[];125!==Mi.charCodeAt(Fi);){var i=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("ObjectField");Hi(),s.push({kind:"ObjectField",name:i,value:tn(e)})}return Fi++,Hi(),{kind:"ObjectValue",fields:s};case 36:if(e)throw Gi("Variable");return Fi++,{kind:"Variable",name:Qi()};case 34:if(34===Mi.charCodeAt(Fi+1)&&34===Mi.charCodeAt(Fi+2)){if(Fi+=3,null==(t=$i(Zi)))throw Gi("StringValue");return Hi(),{kind:"StringValue",value:Wi(t.slice(0,-3)),block:!0}}var n,a=Fi;Fi++;var o=!1;for(n=0|Mi.charCodeAt(Fi++);92===n&&(Fi++,o=!0)||10!==n&&13!==n&&34!==n&&n;n=0|Mi.charCodeAt(Fi++));if(34!==n)throw Gi("StringValue");return t=Mi.slice(a,Fi),Hi(),{kind:"StringValue",value:o?JSON.parse(t):t.slice(1,-1),block:!1};case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:for(var d,c=Fi++;(d=0|Mi.charCodeAt(Fi++))>=48&&d<=57;);var u=Mi.slice(c,--Fi);if(46===(d=Mi.charCodeAt(Fi))||69===d||101===d){if(null==(t=$i(en)))throw Gi("FloatValue");return Hi(),{kind:"FloatValue",value:u+t}}return Hi(),{kind:"IntValue",value:u};case 110:if(117===Mi.charCodeAt(Fi+1)&&108===Mi.charCodeAt(Fi+2)&&108===Mi.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"NullValue"};break;case 116:if(114===Mi.charCodeAt(Fi+1)&&117===Mi.charCodeAt(Fi+2)&&101===Mi.charCodeAt(Fi+3))return Fi+=4,Hi(),{kind:"BooleanValue",value:!0};break;case 102:if(97===Mi.charCodeAt(Fi+1)&&108===Mi.charCodeAt(Fi+2)&&115===Mi.charCodeAt(Fi+3)&&101===Mi.charCodeAt(Fi+4))return Fi+=5,Hi(),{kind:"BooleanValue",value:!1}}return{kind:"EnumValue",value:Ki()}}function rn(e){if(40===Mi.charCodeAt(Fi)){var t=[];Fi++,Hi();do{var r=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("Argument");Hi(),t.push({kind:"Argument",name:r,value:tn(e)})}while(41!==Mi.charCodeAt(Fi));return Fi++,Hi(),t}}function sn(e){if(64===Mi.charCodeAt(Fi)){var t=[];do{Fi++,t.push({kind:"Directive",name:Qi(),arguments:rn(e)})}while(64===Mi.charCodeAt(Fi));return t}}function nn(){for(var e=0;91===Mi.charCodeAt(Fi);)e++,Fi++,Hi();var t={kind:"NamedType",name:Qi()};do{if(33===Mi.charCodeAt(Fi)&&(Fi++,Hi(),t={kind:"NonNullType",type:t}),e){if(93!==Mi.charCodeAt(Fi++))throw Gi("NamedType");Hi(),t={kind:"ListType",type:t}}}while(e--);return t}function an(){if(123!==Mi.charCodeAt(Fi++))throw Gi("SelectionSet");return Hi(),on()}function on(){var e=[];do{if(46===Mi.charCodeAt(Fi)){if(46!==Mi.charCodeAt(++Fi)||46!==Mi.charCodeAt(++Fi))throw Gi("SelectionSet");switch(Fi++,Hi(),Mi.charCodeAt(Fi)){case 64:e.push({kind:"InlineFragment",typeCondition:void 0,directives:sn(!1),selectionSet:an()});break;case 111:110===Mi.charCodeAt(Fi+1)?(Fi+=2,Hi(),e.push({kind:"InlineFragment",typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()})):e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)});break;case 123:Fi++,Hi(),e.push({kind:"InlineFragment",typeCondition:void 0,directives:void 0,selectionSet:on()});break;default:e.push({kind:"FragmentSpread",name:Qi(),directives:sn(!1)})}}else{var t=Qi(),r=void 0;58===Mi.charCodeAt(Fi)&&(Fi++,Hi(),r=t,t=Qi());var s=rn(!1),i=sn(!1),n=void 0;123===Mi.charCodeAt(Fi)&&(Fi++,Hi(),n=on()),e.push({kind:"Field",alias:r,name:t,arguments:s,directives:i,selectionSet:n})}}while(125!==Mi.charCodeAt(Fi));return Fi++,Hi(),{kind:"SelectionSet",selections:e}}function dn(){if(Hi(),40===Mi.charCodeAt(Fi)){var e=[];Fi++,Hi();do{if(36!==Mi.charCodeAt(Fi++))throw Gi("Variable");var t=Qi();if(58!==Mi.charCodeAt(Fi++))throw Gi("VariableDefinition");Hi();var r=nn(),s=void 0;61===Mi.charCodeAt(Fi)&&(Fi++,Hi(),s=tn(!0)),Hi(),e.push({kind:"VariableDefinition",variable:{kind:"Variable",name:t},type:r,defaultValue:s,directives:sn(!0)})}while(41!==Mi.charCodeAt(Fi));return Fi++,Hi(),e}}function cn(){var e=Qi();if(111!==Mi.charCodeAt(Fi++)||110!==Mi.charCodeAt(Fi++))throw Gi("FragmentDefinition");return Hi(),{kind:"FragmentDefinition",name:e,typeCondition:{kind:"NamedType",name:Qi()},directives:sn(!1),selectionSet:an()}}function un(){var e=[];do{if(123===Mi.charCodeAt(Fi))Fi++,Hi(),e.push({kind:"OperationDefinition",operation:"query",name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:on()});else{var t=Ki();switch(t){case"fragment":e.push(cn());break;case"query":case"mutation":case"subscription":var r,s=void 0;40!==(r=Mi.charCodeAt(Fi))&&64!==r&&123!==r&&(s=Qi()),e.push({kind:"OperationDefinition",operation:t,name:s,variableDefinitions:dn(),directives:sn(!1),selectionSet:an()});break;default:throw Gi("Document")}}}while(Fi<Mi.length);return e}function hn(e,t){return Mi=e.body?e.body:e,Fi=0,Hi(),t&&t.noLocation?{kind:"Document",definitions:un()}:{kind:"Document",definitions:un(),loc:{start:0,end:Mi.length,startToken:void 0,endToken:void 0,source:{body:Mi,name:"graphql.web",locationOffset:{line:1,column:1}}}}}var pn=0,ln=new Set;function mn(){function e(e,t){var r,s,i=hn(e).definitions,n=new Set;for(var a of t||[])for(var o of a.definitions)o.kind!==qi||n.has(o)||(i.push(o),n.add(o));return(r=i[0].kind===qi)&&i[0].directives&&(i[0].directives=i[0].directives.filter((e=>"_unmask"!==e.name.value))),{kind:Xi,definitions:i,get loc(){if(!s&&r){var i=e+function(e){try{pn++;var t="";for(var r of e)if(!ln.has(r)){ln.add(r);var{loc:s}=r;s&&(t+=s.source.body)}return t}finally{0==--pn&&ln.clear()}}(t||[]);return{start:0,end:i.length,source:{body:i,name:"GraphQLTada",locationOffset:{line:1,column:1}}}}return s},set loc(e){s=e}}}return e.scalar=function(e,t){return t},e.persisted=function(e,t){return{kind:Xi,definitions:t?t.definitions:[],documentId:e}},e}mn();const _n=mn();function bn(e){if(1!==e.length)throw new Error("Invalid base64Url character: "+e);const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(e);if(-1===t)throw new Error("Invalid base64Url character: "+e);const r=t.toString(2).padStart(6,"0");return Array.from(r).map(Number)}function gn(e,t){const r=function(e,t){if(e.length<2)throw new Error(`Input (s = ${e}) is not tightly packed because s.length < 2`);let r=function(e){let t=[];for(let r=0;r<e.length;r++){const s=bn(e.charAt(r));t=t.concat(s)}return t}(e);const s=t%4;if(0===s);else if(1===s)r=r.slice(2);else{if(2!==s)throw new Error(`Input (s = ${e}) is not tightly packed because i%4 = 3 (i = ${t}))`);r=r.slice(4)}const i=(t+e.length-1)%4;if(3===i);else if(2===i)r=r.slice(0,r.length-2);else{if(1!==i)throw new Error(`Input (s = ${e}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${t}))`);r=r.slice(0,r.length-4)}if(r.length%8!=0)throw new Error("We should never reach here...");const n=new Uint8Array(Math.floor(r.length/8));let a=0;for(let e=0;e<r.length;e+=8){const t=r.slice(e,e+8),s=parseInt(t.join(""),2);n[a++]=s}return(new TextDecoder).decode(n)}(e.value,e.indexMod4),[s,i]=function(e){if("}"!==e.slice(-1)&&","!==e.slice(-1))throw new Error("Invalid claim");const t=JSON.parse("{"+e.slice(0,-1)+"}");if(1!==Object.keys(t).length)throw new Error("Invalid claim");const r=Object.keys(t)[0];return[r,t[r]]}(r);if(s!==t)throw new Error(`Invalid field name: found ${s} expected ${t}`);return i}const yn=ht.struct("ZkLoginSignature",{inputs:ht.struct("ZkLoginSignatureInputs",{proofPoints:ht.struct("ZkLoginSignatureInputsProofPoints",{a:ht.vector(ht.string()),b:ht.vector(ht.vector(ht.string())),c:ht.vector(ht.string())}),issBase64Details:ht.struct("ZkLoginSignatureInputsClaim",{value:ht.string(),indexMod4:ht.u8()}),headerBase64:ht.string(),addressSeed:ht.string()}),maxEpoch:ht.u64(),userSignature:ht.vector(ht.u8())});var fn,vn,Tn=e=>{throw TypeError(e)},En=(e,t,r)=>t.has(e)||Tn("Cannot "+r),wn=(e,t,r)=>(En(e,t,"read from private field"),r?r.call(e):t.get(e)),xn=(e,t,r)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),On=(e,t,r,s)=>(En(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);fn=new WeakMap,vn=new WeakMap;let In=class e extends di{constructor(e,{client:r}={}){super(),xn(this,fn),xn(this,vn),On(this,vn,r),"string"==typeof e?On(this,fn,t(e)):e instanceof Uint8Array?On(this,fn,e):On(this,fn,Uint8Array.from(e))}equals(e){return super.equals(e)}toRawBytes(){return wn(this,fn)}flag(){return ii.ZkLogin}async verify(e,t){throw Error("does not support")}verifyPersonalMessage(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"PERSONAL_MESSAGE",client:wn(this,vn)})}verifyTransaction(t,r){const i=Sn(r);return Bn({address:new e(i.publicKey).toSuiAddress(),bytes:s(t),signature:i.serializedSignature,intentScope:"TRANSACTION_DATA",client:wn(this,vn)})}};const Cn=_n("\n\tquery Zklogin(\n\t\t$bytes: Base64!\n\t\t$signature: Base64!\n\t\t$intentScope: ZkLoginIntentScope!\n\t\t$author: SuiAddress!\n\t) {\n\t\tverifyZkloginSignature(\n\t\t\tbytes: $bytes\n\t\t\tsignature: $signature\n\t\t\tintentScope: $intentScope\n\t\t\tauthor: $author\n\t\t) {\n\t\t\tsuccess\n\t\t\terrors\n\t\t}\n\t}\n");async function Bn({address:e,bytes:t,signature:r,intentScope:s,client:i=new Ji({url:"https://sui-mainnet.mystenlabs.com/graphql"})}){const n=await i.query({query:Cn,variables:{bytes:t,signature:r,intentScope:s,author:e}});return!0===n.data?.verifyZkloginSignature.success&&0===n.data?.verifyZkloginSignature.errors.length}function Sn(e){const r="string"==typeof e?t(e):e;if(r[0]!==ii.ZkLogin)throw new Error("Invalid signature scheme");const i=r.slice(1),{inputs:n,maxEpoch:a,userSignature:o}=function(e){return yn.parse("string"==typeof e?t(e):e)}(i),{issBase64Details:d,addressSeed:c}=n,u=gn(d,"iss"),h=function(e,t){const r=(n=32,function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=Pr(e.charCodeAt(i)),n=Pr(e.charCodeAt(i+1));if(void 0===r||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}s[t]=16*r+n}return s}(e.toString(16).padStart(2*n,"0").slice(2*-n))),s=(new TextEncoder).encode(t),i=new Uint8Array(1+s.length+r.length);var n;return i.set([s.length],0),i.set(s,1),i.set(r,1+s.length),new In(i,void 0)}(BigInt(c),u);return{serializedSignature:s(r),signatureScheme:"ZkLogin",zkLogin:{inputs:n,maxEpoch:a,userSignature:o,iss:u,addressSeed:BigInt(c)},signature:r,publicKey:h.toRawBytes()}}const Pn=32,jn="suiprivkey";class An{async signWithIntent(e,t){const r=si(t,e),i=$r(r,{dkLen:32});return{signature:function({signature:e,signatureScheme:t,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const i=r.toRawBytes(),n=new Uint8Array(1+e.length+i.length);return n.set([ii[t]]),n.set(e,1),n.set(i,1+e.length),s(n)}({signature:await this.sign(i),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:s(e)}}async signTransaction(e){return this.signWithIntent(e,"TransactionData")}async signPersonalMessage(e){const{signature:t}=await this.signWithIntent(ht.vector(ht.u8()).serialize(e).toBytes(),"PersonalMessage");return{bytes:s(e),signature:t}}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class kn extends An{}function Un(e){const{prefix:t,words:r}=ri.I.decode(e);if(t!==jn)throw new Error("invalid private key prefix");const s=new Uint8Array(ri.I.fromWords(r)),i=s.slice(1);return{schema:ai[s[0]],secretKey:i}}function Nn(e,t){if(e.length!==Pn)throw new Error("Invalid bytes length");const r=ii[t],s=new Uint8Array(e.length+1);return s.set([r]),s.set(e,1),ri.I.encode(jn,ri.I.toWords(s))}class Dn extends Ar{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,vr(e);const r=jr(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tr(this),this.iHash.update(e),this}digestInto(e){Tr(this),fr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:n,outputLen:a}=this;return e.finished=s,e.destroyed=i,e.blockLen=n,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Rn=(e,t,r)=>new Dn(e,t).update(r).digest();Rn.create=(e,t)=>new Dn(e,t);class Yn extends Ar{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=xr(this.buffer)}update(e){Tr(this);const{view:t,buffer:r,blockLen:s}=this,i=(e=jr(e)).length;for(let n=0;n<i;){const a=Math.min(s-this.pos,i-n);if(a!==s)r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===s&&(this.process(t,0),this.pos=0);else{const t=xr(e);for(;s<=i-n;n+=s)this.process(t,n)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tr(this),Er(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let e=n;e<s;e++)t[e]=0;!function(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),a=Number(r>>i&n),o=Number(r&n),d=s?4:0,c=s?0:4;e.setUint32(t+d,a,s),e.setUint32(t+c,o,s)}(r,s-8,BigInt(8*this.length),i),this.process(r,0);const a=xr(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=o/4,c=this.get();if(d>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)a.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:n,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=n,s%t&&e.buffer.set(r),e}}const[Vn,Jn]=(()=>Mr.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Mn=new Uint32Array(80),Fn=new Uint32Array(80);class Xn extends Yn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:n,Dh:a,Dl:o,Eh:d,El:c,Fh:u,Fl:h,Gh:p,Gl:l,Hh:m,Hl:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|s,this.Ch=0|i,this.Cl=0|n,this.Dh=0|a,this.Dl=0|o,this.Eh=0|d,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|p,this.Gl=0|l,this.Hh=0|m,this.Hl=0|_}process(e,t){for(let r=0;r<16;r++,t+=4)Mn[r]=e.getUint32(t),Fn[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Mn[e-15],r=0|Fn[e-15],s=Mr.rotrSH(t,r,1)^Mr.rotrSH(t,r,8)^Mr.shrSH(t,r,7),i=Mr.rotrSL(t,r,1)^Mr.rotrSL(t,r,8)^Mr.shrSL(t,r,7),n=0|Mn[e-2],a=0|Fn[e-2],o=Mr.rotrSH(n,a,19)^Mr.rotrBH(n,a,61)^Mr.shrSH(n,a,6),d=Mr.rotrSL(n,a,19)^Mr.rotrBL(n,a,61)^Mr.shrSL(n,a,6),c=Mr.add4L(i,d,Fn[e-7],Fn[e-16]),u=Mr.add4H(c,s,o,Mn[e-7],Mn[e-16]);Mn[e]=0|u,Fn[e]=0|c}let{Ah:r,Al:s,Bh:i,Bl:n,Ch:a,Cl:o,Dh:d,Dl:c,Eh:u,El:h,Fh:p,Fl:l,Gh:m,Gl:_,Hh:b,Hl:g}=this;for(let e=0;e<80;e++){const t=Mr.rotrSH(u,h,14)^Mr.rotrSH(u,h,18)^Mr.rotrBH(u,h,41),y=Mr.rotrSL(u,h,14)^Mr.rotrSL(u,h,18)^Mr.rotrBL(u,h,41),f=u&p^~u&m,v=h&l^~h&_,T=Mr.add5L(g,y,v,Jn[e],Fn[e]),E=Mr.add5H(T,b,t,f,Vn[e],Mn[e]),w=0|T,x=Mr.rotrSH(r,s,28)^Mr.rotrBH(r,s,34)^Mr.rotrBH(r,s,39),O=Mr.rotrSL(r,s,28)^Mr.rotrBL(r,s,34)^Mr.rotrBL(r,s,39),I=r&i^r&a^i&a,C=s&n^s&o^n&o;b=0|m,g=0|_,m=0|p,_=0|l,p=0|u,l=0|h,({h:u,l:h}=Mr.add(0|d,0|c,0|E,0|w)),d=0|a,c=0|o,a=0|i,o=0|n,i=0|r,n=0|s;const B=Mr.add3L(w,O,C);r=Mr.add3H(B,E,x,I),s=0|B}({h:r,l:s}=Mr.add(0|this.Ah,0|this.Al,0|r,0|s)),({h:i,l:n}=Mr.add(0|this.Bh,0|this.Bl,0|i,0|n)),({h:a,l:o}=Mr.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:d,l:c}=Mr.add(0|this.Dh,0|this.Dl,0|d,0|c)),({h:u,l:h}=Mr.add(0|this.Eh,0|this.El,0|u,0|h)),({h:p,l}=Mr.add(0|this.Fh,0|this.Fl,0|p,0|l)),({h:m,l:_}=Mr.add(0|this.Gh,0|this.Gl,0|m,0|_)),({h:b,l:g}=Mr.add(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,s,i,n,a,o,d,c,u,h,p,l,m,_,b,g)}roundClean(){Mn.fill(0),Fn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const qn=kr((()=>new Xn));function Ln(e){if("string"!=typeof e)throw new TypeError("invalid mnemonic type: "+typeof e);return e.normalize("NFKD")}function Gn(e,t=""){return function(e,t,r){const{c:s,dkLen:i,DK:n,PRF:a,PRFSalt:o}=function(e,t,r,s){vr(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},t)}(0,s),{c:n,dkLen:a,asyncTick:o}=i;if(yr(n),yr(a),yr(o),n<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const d=jr(t),c=jr(r),u=new Uint8Array(a),h=Rn.create(e,d),p=h._cloneInto().update(c);return{c:n,dkLen:a,asyncTick:o,DK:u,PRF:h,PRFSalt:p}}(e,t,r,{c:2048,dkLen:64});let d;const c=new Uint8Array(4),u=xr(c),h=new Uint8Array(a.outputLen);for(let e=1,t=0;t<i;e++,t+=a.outputLen){const r=n.subarray(t,t+a.outputLen);u.setInt32(0,e,!1),(d=o._cloneInto(d)).update(c).digestInto(h),r.set(h.subarray(0,r.length));for(let e=1;e<s;e++){a._cloneInto(d).update(h).digestInto(h);for(let e=0;e<r.length;e++)r[e]^=h[e]}}return function(e,t,r,s,i){return e.destroy(),t.destroy(),s&&s.destroy(),i.fill(0),r}(a,o,n,d,h)}(qn,function(e){const t=Ln(e),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}(e).nfkd,(e=>Ln("mnemonic"+e))(t))}function $n(e){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(e)}const zn=new RegExp("^m(\\/[0-9]+')+$"),Wn=e=>e.replace("'",""),Hn=(e,t,r=2147483648)=>{if(!(e=>!!zn.test(e)&&!e.split("/").slice(1).map(Wn).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:s,chainCode:i}=(e=>{const t=Rn.create(qn,"ed25519 seed").update(c(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(Wn).map((e=>parseInt(e,10))).reduce(((e,t)=>(({key:e,chainCode:t},r)=>{const s=new ArrayBuffer(4);new DataView(s).setUint32(0,r);const i=new Uint8Array(1+e.length+s.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(e,1),i.set(new Uint8Array(s,0,s.byteLength),e.length+1);const n=Rn.create(qn,t).update(i).digest();return{key:n.slice(0,32),chainCode:n.slice(32)}})(e,t+r)),{key:s,chainCode:i})};class Kn extends di{constructor(e){if(super(),"string"==typeof e?this.data=t(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return ii.ED25519}async verify(e,r){let s;if("string"==typeof r){const e=function(e){const r=t(e),s=ai[r[0]];switch(s){case"MultiSig":return{serializedSignature:e,signatureScheme:s,multisig:or.MultiSig.parse(r.slice(1)),bytes:r};case"ZkLogin":return Sn(e);case"ED25519":case"Secp256k1":case"Secp256r1":const t=ni[s],i=r.slice(1,r.length-t);return{serializedSignature:e,signatureScheme:s,signature:i,publicKey:r.slice(1+i.length),bytes:r};default:throw new Error("Unsupported signature scheme")}}(r);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!oi(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");s=e.signature}else s=r;return ti.sign.detached.verify(e,s,this.toRawBytes())}}Kn.SIZE=32;const Qn="m/44'/784'/0'/0'/0'";class Zn extends kn{constructor(e){super(),this.keypair=e||ti.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new Zn(ti.sign.keyPair())}static fromSecretKey(e,t){const r=e.length;if(r!==Pn)throw new Error(`Wrong secretKey size. Expected ${Pn} bytes, got ${r}.`);const s=ti.sign.keyPair.fromSeed(e);if(!t||!t.skipValidation){const e=(new TextEncoder).encode("sui validation"),t=ti.sign.detached(e,s.secretKey);if(!ti.sign.detached.verify(e,t,s.publicKey))throw new Error("provided secretKey is invalid")}return new Zn(s)}getPublicKey(){return new Kn(this.keypair.publicKey)}getSecretKey(){return Nn(this.keypair.secretKey.slice(0,Pn),this.getKeyScheme())}async sign(e){return ti.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=Qn),!$n(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,function(e){return u(function(e){return Gn(e,"")}(e))}(e));return Zn.fromSecretKey(r)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=Qn),!$n(t))throw new Error("Invalid derivation path");const{key:r}=Hn(t,e);return Zn.fromSecretKey(r)}}function ea(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function ta(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}var ra=a(725);const sa=e=>ra.encode(e),ia=e=>ra.decode(e);function na(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const aa=8192;function oa(e){if(e.length<aa)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=aa){const s=e.slice(r,r+aa);t+=String.fromCharCode(...s)}return btoa(t)}class da{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class ca{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return ua(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return ua(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return ua(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return sa(e);case"base64":return oa(e);case"hex":return ta(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function ua(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var ha,pa,la,ma,_a=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},ba=(e,t,r)=>(_a(e,t,"read from private field"),r?r.call(e):t.get(e)),ga=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},ya=(e,t,r,s)=>(_a(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const fa=class{constructor(e){ga(this,ha,void 0),ga(this,pa,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),ya(this,ha,e.write),ya(this,pa,e.serialize??((e,t)=>{const r=new ca({size:this.serializedSize(e)??void 0,...t});return ba(this,ha).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),ba(this,ha).call(this,e,t)}serialize(e,t){return this.validate(e),new Ea(this,ba(this,pa).call(this,e,t))}parse(e){const t=new da(e);return this.read(t)}transform({name:e,input:t,output:r}){return new fa({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>ba(this,ha).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>ba(this,pa).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let va=fa;ha=new WeakMap,pa=new WeakMap;const Ta=Symbol.for("@mysten/serialized-bcs");class Ea{constructor(e,t){ga(this,la,void 0),ga(this,ma,void 0),ya(this,la,e),ya(this,ma,t)}get[Ta](){return!0}toBytes(){return ba(this,ma)}toHex(){return ta(ba(this,ma))}toBase64(){return oa(ba(this,ma))}toBase58(){return sa(ba(this,ma))}parse(){return ba(this,la).parse(ba(this,ma))}}la=new WeakMap,ma=new WeakMap;const wa=32,xa=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof xa)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(xa.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Oa.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Oa.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Oa.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Oa.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Oa.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Oa.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Oa.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Oa.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Oa.HEX,(function(e,t){return e.writeVec(Array.from(ea(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return ta(new Uint8Array(t))})),t.registerType(Oa.BASE58,(function(e,t){return e.writeVec(Array.from(ia(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return sa(new Uint8Array(t))})),t.registerType(Oa.BASE64,(function(e,t){return e.writeVec(Array.from(na(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return oa(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new xa(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return ia(e);case"base64":return na(e);case"hex":return ea(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new xa(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new ca(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new da(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new va({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new va({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return na(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return oa(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return ea(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return ta(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],p,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,p,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let p=n.indexOf(h),l=-1===p?h:a[p];{let{name:r,params:s}=this.parseTypeName(l);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Oa=xa;function Ia(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:wa,addressEncoding:"hex"}}var Ca;Oa.U8="u8",Oa.U16="u16",Oa.U32="u32",Oa.U64="u64",Oa.U128="u128",Oa.U256="u256",Oa.BOOL="bool",Oa.VECTOR="vector",Oa.ADDRESS="address",Oa.STRING="string",Oa.HEX="hex-string",Oa.BASE58="base58-string",Oa.BASE64="base64-string",function(e){e.IsValidDesription="invalid description",e.IsValidName="invalid name",e.IsValidName_AllowEmpty="invalid name",e.IsValidEndpoint="invalid endpoint",e.IsValidAddress="invalid address",e.IsValidArgType="invalid argument type",e.IsValidTokenType="invalid token type",e.IsValidUint="invalid uint",e.IsValidInt="invalid int",e.IsValidU64="invalid u64",e.IsValidU8="invalid u8",e.IsValidPercent="invalid percent",e.IsValidArray="invalid array",e.IsValidObjects="invalid objects",e.AllInvalid="one valid at least",e.InvalidParam="invalid parameter",e.IsValidPermissionIndex="invalid permission index",e.IsValidKey="invalid key",e.Fail="fail",e.IsValidIndentifier="indentifier invalid",e.isValidHttpUrl="invalid url",e.IsValidBizPermissionIndex="invalid biz-permission index",e.bcsTypeInvalid="invalid bcs type",e.IsValidServiceItemName="invalid service item name",e.IsValidCoinType="not the coin type",e.IsValidGuardIdentifier="guard identifier invalid",e.noPermission="no permission"}(Ca||(Ca={}));const Ba=(e,t)=>{throw e.toString()+(t?" "+t:"")},Sa=BigInt("255"),Pa=BigInt("18446744073709551615"),ja=BigInt("340282366920938463463374607431768211455"),Aa=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),ka=0,Ua=e=>e===No.TYPE_U8||e===No.TYPE_U64||e===No.TYPE_U128||e===No.TYPE_U256?Do.PositiveNumber:e===No.TYPE_VEC_U8||e===No.TYPE_VEC_U64||e===No.TYPE_VEC_U128||e===No.TYPE_VEC_U256||e===No.TYPE_VEC_BOOL?Do.PositiveNumber_Vec:e===No.TYPE_ADDRESS?Do.Address:e===No.TYPE_VEC_ADDRESS?Do.Address_Vec:e===No.TYPE_STRING?Do.String:e===No.TYPE_VEC_STRING?Do.String_Vec:e===No.TYPE_BOOL?Do.Bool:-1,Na=(e,t)=>{let r=e.splice(0,1);return 1==r[0]?{bNone:!1,value:Wa.getInstance().de(t,Uint8Array.from(e))}:(0==r[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka})},Da=e=>{let t=e.splice(0,1);if(1==t[0]){let t=Ra(Uint8Array.from(e)),r=Wa.getInstance().de(No.TYPE_STRING,Uint8Array.from(e));return e.splice(0,t.value+t.length),{bNone:!1,value:r}}return 0==t[0]||Ba(Ca.Fail,"readOption: option invalid"),{bNone:!0,value:ka}},Ra=e=>{let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}},Ya=(e,t)=>{let r=Ra(Uint8Array.from(e));e.splice(0,r.length);let s=[];for(let i=0;i<r.value;i++)s.push(t(e,i,r.value));return s},Va=(e,t,r)=>e.shift(),Ja=(e,t,r)=>e.splice(0,8),Ma=(e,t,r)=>e.splice(0,16),Fa=(e,t,r)=>e.splice(0,32),Xa=(e,...t)=>{let r=0;for(const e of t)r+=e.length;const s=new e(r);let i=0;for(const e of t)s.set(e,i),i+=e.length;return s},qa=(e,t="payment::Payment<")=>{if(e){const r=e.indexOf(t);if(r>0)return e.slice(r+t.length,e.length-1)}return""},La=(e,t)=>e.length===t.length&&!e.some((e=>!t.includes(e))),Ga=e=>{for(var t=[],r=0;r<e.length;r++)-1==t.indexOf(e[r])&&t.push(e[r]);return t};function $a(e){return e&&e[0].toUpperCase()+e.slice(1)}function za(e){var t=[];let r=e.indexOf("<");return r>=0&&(t=e.slice(r+1,e.length-1).split(",")),t}class Wa{bcs=new Oa(Ia());static _instance;constructor(){this.bcs.registerEnumType("Option<T>",{none:null,some:"T"}),this.bcs.registerStructType("EntStruct",{avatar:"vector<u8>",resource:"Option<address>",safer_name:"vector<string>",safer_value:"vector<string>",like:Oa.U32,dislike:Oa.U32}),this.bcs.registerStructType("TagStruct",{nick:"string",tags:"vector<string>"}),this.bcs.registerStructType("PersonalInfo",{name:"vector<u8>",description:"vector<u8>",avatar:Oa.STRING,twitter:Oa.STRING,discord:Oa.STRING,homepage:Oa.STRING}),this.bcs.registerStructType("OptionAddress",{address:"Option<address>"}),this.bcs.registerStructType("Guards",{guards:"vector<OptionAddress>"}),this.bcs.registerStructType("Perm",{index:Oa.U64,guard:"Option<address>"}),this.bcs.registerStructType("Perms",{perms:"vector<Perm>"})}static getInstance(){return Wa._instance||(Wa._instance=new Wa),Wa._instance}ser_option_u32(e){return this.bcs.ser("Option<u32>",{some:e}).toBytes()}ser(e,t){if("string"==typeof e)return this.bcs.ser(e,t).toBytes();switch(e){case No.TYPE_BOOL:return this.bcs.ser(Oa.BOOL,t).toBytes();case No.TYPE_ADDRESS:return this.bcs.ser(Oa.ADDRESS,t).toBytes();case No.TYPE_U64:return this.bcs.ser(Oa.U64,t).toBytes();case No.TYPE_U8:return this.bcs.ser(Oa.U8,t).toBytes();case No.TYPE_VEC_U8:return this.bcs.ser("vector<u8>",t).toBytes();case No.TYPE_U128:return this.bcs.ser(Oa.U128,t).toBytes();case No.TYPE_VEC_ADDRESS:return this.bcs.ser("vector<address>",t).toBytes();case No.TYPE_VEC_BOOL:return this.bcs.ser("vector<bool>",t).toBytes();case No.TYPE_VEC_VEC_U8:return this.bcs.ser("vector<vector<u8>>",t).toBytes();case No.TYPE_VEC_U64:return this.bcs.ser("vector<u64>",t).toBytes();case No.TYPE_VEC_U128:return this.bcs.ser("vector<u128>",t).toBytes();case No.TYPE_OPTION_ADDRESS:return this.bcs.ser("Option<address>",{some:t}).toBytes();case No.TYPE_OPTION_BOOL:return this.bcs.ser("Option<bool>",{some:t}).toBytes();case No.TYPE_OPTION_U8:return this.bcs.ser("Option<u8>",{some:t}).toBytes();case No.TYPE_OPTION_U64:return this.bcs.ser("Option<u64>",{some:t}).toBytes();case No.TYPE_OPTION_U128:return this.bcs.ser("Option<u128>",{some:t}).toBytes();case No.TYPE_OPTION_U256:return this.bcs.ser("Option<u256>",{some:t}).toBytes();case No.TYPE_OPTION_STRING:return this.bcs.ser("Option<string>",{some:t}).toBytes();case No.TYPE_VEC_U256:return this.bcs.ser("vector<u256>",t).toBytes();case No.TYPE_U256:return this.bcs.ser(Oa.U256,t).toBytes();case No.TYPE_STRING:const e=(new TextEncoder).encode(t);return this.bcs.ser("vector<u8>",e).toBytes();case No.TYPE_VEC_STRING:return this.bcs.ser("vector<vector<u8>>",t.map((e=>(new TextEncoder).encode(e)))).toBytes();default:Ba(Ca.bcsTypeInvalid,"ser")}return new Uint8Array}de(e,t){if("string"==typeof e)return this.bcs.de(e,t);switch(e){case No.TYPE_BOOL:return this.bcs.de(Oa.BOOL,t);case No.TYPE_ADDRESS:return this.bcs.de(Oa.ADDRESS,t);case No.TYPE_U64:return this.bcs.de(Oa.U64,t);case No.TYPE_U8:return this.bcs.de(Oa.U8,t);case No.TYPE_VEC_U8:return this.bcs.de("vector<u8>",t);case No.TYPE_U128:return this.bcs.de(Oa.U128,t);case No.TYPE_VEC_ADDRESS:return this.bcs.de("vector<address>",t);case No.TYPE_VEC_BOOL:return this.bcs.de("vector<bool>",t);case No.TYPE_VEC_VEC_U8:return this.bcs.de("vector<vector<u8>>",t);case No.TYPE_VEC_U64:return this.bcs.de("vector<u64>",t);case No.TYPE_VEC_U128:return this.bcs.de("vector<u128>",t);case No.TYPE_OPTION_ADDRESS:return this.bcs.de("Option<address>",t);case No.TYPE_OPTION_BOOL:return this.bcs.de("Option<bool>",t);case No.TYPE_OPTION_U8:return this.bcs.de("Option<u8>",t);case No.TYPE_OPTION_U64:return this.bcs.de("Option<u64>",t);case No.TYPE_OPTION_U128:return this.bcs.de("Option<u128>",t);case No.TYPE_OPTION_U256:return this.bcs.de("Option<u256>",t);case No.TYPE_OPTION_STRING:return this.bcs.de("Option<string>",t);case No.TYPE_VEC_U256:return this.bcs.de("vector<u256>",t);case No.TYPE_STRING:return(new TextDecoder).decode(Uint8Array.from(this.bcs.de("vector<u8>",t)));case No.TYPE_VEC_STRING:return this.bcs.de("vector<string>",t);case No.TYPE_U256:return this.bcs.de(Oa.U256,t);default:Ba(Ca.bcsTypeInvalid,"de")}}de_ent(e){if(!e||e.length<2)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("EntStruct",Uint8Array.from(t))}de_entInfo(e){if(!e||0===e.length)return;let t=this.bcs.de("PersonalInfo",e);return t.name=(new TextDecoder).decode(Uint8Array.from(t.name)),t.description=(new TextDecoder).decode(Uint8Array.from(t.description)),t}de_tags(e){if(!e||0===e.length)return"";const t=this.bcs.de("vector<u8>",e);return this.bcs.de("TagStruct",Uint8Array.from(t))}de_perms(e){return!e||e.length<1?"":this.bcs.de("Perms",e).perms.map((e=>({index:e?.index,guard:e?.guard?.none?void 0:"0x"+e?.guard?.some})))}}function Ha(e){const t=(new TextEncoder).encode(e);return new Uint8Array(t.buffer)}function Ka(e){if(!e)return new Uint8Array(0);const t=[];for(t.unshift(255&e);e>=256;)e>>>=8,t.unshift(255&e);return new Uint8Array(t)}const Qa=e=>"[object Array]"==Object.prototype.toString.call(e),Za=(e,t)=>{let r=t||{};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("object"==typeof e[t]&&null!==e[t]?(r[t]=Qa(e[t])?[]:{},Za(e[t],r[t])):r[t]=e[t]);return r},eo=4e3,to=64,ro=1024,so=(e,t)=>Wa.getInstance().ser(No.TYPE_STRING,e).length<=t,io=e=>so(e,eo),no=e=>!(!e||0===e.length)&&so(e,to),ao=e=>so(e,to),oo=e=>e.length>0&&e.length<=ro&&Bo(e),co=e=>!(!e||!ae(e)),uo=e=>!!e&&(e.startsWith("0x2::coin::Coin")||e.startsWith("0x0000000000000000000000000000000000000000000000000000000000000002")),ho=(e=864e5)=>{const t=Date.now();return Math.floor(t/e)*e},po=(e,t=Aa,r)=>{if(""===e||void 0===e)return!1;try{const s=BigInt(e);if(s<=t)return void 0===r||s>=r}catch(e){}return!1},lo=(e,t=0)=>po(e,Sa,BigInt(t)),mo=(e,t=0)=>po(e,Pa,BigInt(t)),_o=(e,t=0)=>po(e,ja,BigInt(t)),bo=(e,t=0)=>po(e,Aa,BigInt(t)),go=e=>{if(!e||0===e.length)return!1;let t=e.split("::");return 3===t.length&&!(!co(t[0])&&"0x2"!=t[0]||0===t[1].length||0===t[2].length)},yo=e=>!(!e||0===e.length)&&!(e.split("::").length<3),fo=e=>("string"==typeof e&&(e=parseInt(e)),Number.isSafeInteger(e)),vo=e=>po(e,BigInt(100),BigInt(0)),To=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r]))return!1;return!0},Eo=e=>e>Pa?Pa:e;function wo(e){const t=e.trim();if(-1!==t.indexOf(".")){let e=t.length-1;for(;"0"===t[e];)e--;return"."===t[e]&&e--,t.slice(0,e+1)}return t}const xo=(e,t)=>{if(!e)return"";if("0"===e)return"0";if(t<=0)return e;var r=t-e.length;return wo(0===r?"."+e:r<0?e.slice(0,Math.abs(r))+"."+e.slice(Math.abs(r)):"."+e.padStart(t,"0"))},Oo=e=>{if(e){const t="0x2::coin::Coin<";let r=e.indexOf(t);if(r>=0){let s=e.slice(r+t.length,e.length-1);if(-1===s.indexOf("<")){for(;">"==s[s.length-1];)s=s.slice(0,-1);let e=s.lastIndexOf("::");return{isCoin:!0,coin:s,token:s.slice(e+2)}}}}return{isCoin:!1,coin:"",token:""}};function Io(e,t){const r=e.length+1,s=new Uint8Array(r);return s.set([t],0),s.set(e,1),s}function Co(e){let t="";var r;return Math.abs(e)<1?(r=parseInt(e.toString().split("e-")[1]))&&(e*=Math.pow(10,r-1),t="0."+new Array(r).join("0")+e.toString().substring(2)):(r=parseInt(e.toString().split("+")[1]))>20&&(r-=20,t=(e/=Math.pow(10,r))+new Array(r+1).join("0")),t}function Bo(e){let t;try{t=new URL(e)}catch(e){return!1}return"http:"===t.protocol||"https:"===t.protocol||"ipfs:"===t.protocol}const So=e=>{e.id&&(e?.onBegin&&e.onBegin(e.id),$o.Client().getObject({id:e.id,options:{showContent:!0,showType:!0,showOwner:!0}}).then((t=>{t.error?e?.onObjectErr&&e.onObjectErr(e.id,t.error):e?.onObjectRes&&e.onObjectRes(e.id,t)})).catch((t=>{console.log(t),e?.onObjectErr&&e.onObjectErr(e.id,t)})),$o.Client().getDynamicFields({parentId:e.id}).then((t=>{e?.onDynamicRes&&e.onDynamicRes(e.id,t),t.data.length>0&&$o.Client().multiGetObjects({ids:t.data.map((e=>e.objectId)),options:{showContent:!0}}).then((t=>{e?.onFieldsRes&&e.onFieldsRes(e.id,t)})).catch((t=>{console.log(t),e?.onFieldsErr&&e.onFieldsErr(e.id,t)}))})).catch((t=>{console.log(t),e?.onDynamicErr&&e.onDynamicErr(e.id,t)})))},Po=e=>e?e.substring(0,1).toUpperCase()+e.substring(1):"";function jo(e){return e.some(((t,r)=>e.findIndex((e=>e===t))!==r))}var Ao,ko;!function(e){e.machine="machine",e.progress="progress",e.repository="repository",e.permission="permission",e.passport="passport",e.guard="guard",e.demand="demand",e.order="order",e.service="service",e.resource="resource",e.entity="entity",e.wowok="wowok",e.treasury="treasury",e.payment="payment",e.arbitration="arbitration",e.arb="arb"}(Ao||(Ao={})),function(e){e[e.TYPE_QUERY=1]="TYPE_QUERY",e[e.TYPE_NUMBER_ADD=2]="TYPE_NUMBER_ADD",e[e.TYPE_NUMBER_SUBTRACT=3]="TYPE_NUMBER_SUBTRACT",e[e.TYPE_NUMBER_MULTIPLY=4]="TYPE_NUMBER_MULTIPLY",e[e.TYPE_NUMBER_DEVIDE=5]="TYPE_NUMBER_DEVIDE",e[e.TYPE_NUMBER_MOD=6]="TYPE_NUMBER_MOD",e[e.TYPE_NUMBER_ADDRESS=7]="TYPE_NUMBER_ADDRESS",e[e.TYPE_LOGIC_AS_U256_GREATER=11]="TYPE_LOGIC_AS_U256_GREATER",e[e.TYPE_LOGIC_AS_U256_GREATER_EQUAL=12]="TYPE_LOGIC_AS_U256_GREATER_EQUAL",e[e.TYPE_LOGIC_AS_U256_LESSER=13]="TYPE_LOGIC_AS_U256_LESSER",e[e.TYPE_LOGIC_AS_U256_LESSER_EQUAL=14]="TYPE_LOGIC_AS_U256_LESSER_EQUAL",e[e.TYPE_LOGIC_AS_U256_EQUAL=15]="TYPE_LOGIC_AS_U256_EQUAL",e[e.TYPE_LOGIC_EQUAL=16]="TYPE_LOGIC_EQUAL",e[e.TYPE_LOGIC_HAS_SUBSTRING=17]="TYPE_LOGIC_HAS_SUBSTRING",e[e.TYPE_LOGIC_NOT=18]="TYPE_LOGIC_NOT",e[e.TYPE_LOGIC_AND=19]="TYPE_LOGIC_AND",e[e.TYPE_LOGIC_OR=20]="TYPE_LOGIC_OR"}(ko||(ko={}));const Uo=[[ko.TYPE_LOGIC_AS_U256_GREATER,"Unsigned Integer >","The first item > anything that follows"],[ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL,"Unsigned Integer >=","The first item >= anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER,"Unsigned Integer <","The first item < anything that follows"],[ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL,"Unsigned Integer <=","The first item <= anything that follows"],[ko.TYPE_LOGIC_AS_U256_EQUAL,"Unsigned Integer =","The first item = anything that follows"],[ko.TYPE_LOGIC_EQUAL,"Equal","Data and type are exactly equal for all items"],[ko.TYPE_LOGIC_HAS_SUBSTRING,"Has Sub String","The first string contains anything that follows"],[ko.TYPE_LOGIC_NOT,"Not","Not operation"],[ko.TYPE_LOGIC_AND,"And","All Items And operations"],[ko.TYPE_LOGIC_OR,"Or","All Items Or operations"]];var No,Do;!function(e){e[e.TYPE_BOOL=100]="TYPE_BOOL",e[e.TYPE_ADDRESS=101]="TYPE_ADDRESS",e[e.TYPE_U8=102]="TYPE_U8",e[e.TYPE_U64=103]="TYPE_U64",e[e.TYPE_VEC_U8=104]="TYPE_VEC_U8",e[e.TYPE_U128=105]="TYPE_U128",e[e.TYPE_VEC_ADDRESS=106]="TYPE_VEC_ADDRESS",e[e.TYPE_VEC_BOOL=107]="TYPE_VEC_BOOL",e[e.TYPE_VEC_VEC_U8=108]="TYPE_VEC_VEC_U8",e[e.TYPE_VEC_U64=109]="TYPE_VEC_U64",e[e.TYPE_VEC_U128=110]="TYPE_VEC_U128",e[e.TYPE_OPTION_ADDRESS=111]="TYPE_OPTION_ADDRESS",e[e.TYPE_OPTION_BOOL=112]="TYPE_OPTION_BOOL",e[e.TYPE_OPTION_U8=113]="TYPE_OPTION_U8",e[e.TYPE_OPTION_U64=114]="TYPE_OPTION_U64",e[e.TYPE_OPTION_U128=115]="TYPE_OPTION_U128",e[e.TYPE_OPTION_U256=116]="TYPE_OPTION_U256",e[e.TYPE_OPTION_STRING=117]="TYPE_OPTION_STRING",e[e.TYPE_OPTION_VEC_U8=118]="TYPE_OPTION_VEC_U8",e[e.TYPE_VEC_U256=119]="TYPE_VEC_U256",e[e.TYPE_STRING=120]="TYPE_STRING",e[e.TYPE_VEC_STRING=121]="TYPE_VEC_STRING",e[e.TYPE_U256=122]="TYPE_U256"}(No||(No={})),function(e){e[e.Address=200]="Address",e[e.Address_Vec=201]="Address_Vec",e[e.PositiveNumber=202]="PositiveNumber",e[e.PositiveNumber_Vec=203]="PositiveNumber_Vec",e[e.String=204]="String",e[e.String_Vec=205]="String_Vec",e[e.Bool=206]="Bool"}(Do||(Do={}));const Ro=[{type:Do.String,name:"string",description:"String."},{type:Do.Address,name:"address",description:"Object id or Personal address."},{type:Do.PositiveNumber,name:"unsigned integer",description:"Including u8, u16 ,..., u256"},{type:Do.String_Vec,name:"string vector",description:"Vector of string."},{type:Do.Address_Vec,name:"address vector",description:"Vector of address."},{type:Do.PositiveNumber_Vec,name:"unsigned integer vector",description:"Vector of unsigned integer"},{type:Do.Bool,name:"bool",description:"True or False."}],Yo=Object.values(ko).filter((e=>"number"==typeof e)),Vo=Object.values(No).filter((e=>"number"==typeof e)),Jo=e=>Yo.includes(e),Mo=e=>Vo.includes(e),Fo=e=>e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U64||e===No.TYPE_U8;var Xo;!function(e){e[e.TYPE_SIGNER=60]="TYPE_SIGNER",e[e.TYPE_CLOCK=61]="TYPE_CLOCK",e[e.TYPE_GUARD=62]="TYPE_GUARD",e[e.TYPE_CONSTANT=80]="TYPE_CONSTANT"}(Xo||(Xo={}));const qo=[{type:No.TYPE_BOOL,name:"bool",description:"boolean. eg:true or false",validator:e=>!0===e||!1===e},{type:No.TYPE_ADDRESS,name:"address",description:"address or object-id. eg:0x6789af",validator:co},{type:Xo.TYPE_SIGNER,name:"txn signer",description:"signer address of the transaction"},{type:Xo.TYPE_GUARD,name:"guard address",description:"current guard address"},{type:Xo.TYPE_CLOCK,name:"txn time",description:"unsigned-64 number for the transaction time"},{type:No.TYPE_U64,name:"number",description:"unsigned-64 number. eg:23870233",validator:mo},{type:No.TYPE_U8,name:"number",description:"unsigned-8 number. eg:255",validator:lo},{type:No.TYPE_VEC_U8,name:"string",description:'string or unsigned-8 number array. eg:"[1,2,3]"'},{type:No.TYPE_U128,name:"number",description:"unsigned-8 number. eg:12348900999",validator:_o},{type:No.TYPE_VEC_ADDRESS,name:"[address]",description:"address array. eg:[0x2277f2, 0x3344af]"},{type:No.TYPE_VEC_BOOL,name:"[bool]",description:"boolean array. eg:[true, false, true]"},{type:No.TYPE_VEC_VEC_U8,name:"[[number]]",description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},{type:No.TYPE_VEC_U64,name:"[number]",description:"unsigned-64 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_U128,name:"[number]",description:"unsigned-128 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_OPTION_ADDRESS,name:"option",description:"option of address. eg:none or address"},{type:No.TYPE_OPTION_BOOL,name:"option",description:"option of bool. eg:none or boolean value"},{type:No.TYPE_OPTION_U8,name:"option",description:"option of u8. eg:none or u8 value"},{type:No.TYPE_OPTION_U64,name:"option",description:"option of u64. eg:none or u64 value"},{type:No.TYPE_OPTION_U128,name:"option",description:"option of u128. eg:none or u128 value"},{type:No.TYPE_OPTION_U256,name:"option",description:"option of u256. eg:none or u256 value"},{type:No.TYPE_VEC_U256,name:"[number]",description:"unsigned-256 number array. eg:[123, 778888, 42312]"},{type:No.TYPE_VEC_STRING,name:"[string]",description:'ascii string array. eg:["abc", "hi"]'},{type:No.TYPE_STRING,name:"string",description:'eg:"wowok"'},{type:No.TYPE_OPTION_STRING,name:"option",description:"option of string. eg:none or string value"},{type:No.TYPE_U256,name:"number",description:"unsigned-256 number. eg:12345678901233",validator:bo}];var Lo;!function(e){e.mainnet="mainnet",e.testnet="testnet",e.devnet="devnet",e.localnet="localnet"}(Lo||(Lo={}));const Go="0xd9705a4f0b7ae3400d3af4ba781b2d2f6b4dc5dd81e2e1ce2bc949c16583df7f";class $o{network="";packages=new Map;signer="";wowok_object="";entity_object="";treasury_cap="";oracle_object="";txb;static _instance;constructor(e=Lo.testnet){this.use_network(e),this.new_session()}static Instance(){return $o._instance||($o._instance=new $o),$o._instance}static Client(){return new ei({url:$o.Instance().networkUrl()})}client(){return new ei({url:this.networkUrl()})}use_network(e=Lo.testnet){switch(this.network=e,e){case Lo.localnet:case Lo.devnet:break;case Lo.testnet:this.packages.set("wowok","0xd1ed1921f385bb6c016070325950e87f1d0e3b6a5dcc67c7a9a7b66618f29239"),this.packages.set("base",Go),this.packages.set("wowok_origin","0xd1ed1921f385bb6c016070325950e87f1d0e3b6a5dcc67c7a9a7b66618f29239"),this.packages.set("base_origin","0xd9705a4f0b7ae3400d3af4ba781b2d2f6b4dc5dd81e2e1ce2bc949c16583df7f"),this.wowok_object="0x04bc9f2680baa9e1cc1e52b329f7d7790afeb95f097b704c10116c257c5d07c4",this.entity_object="0x70623568c63000b21b7b5e180c7e5415970763335c3e3b90b1795b0fc164c60d",this.treasury_cap="0xfe7b18c27914fef876dfefd018350cfe33c45b6c5fbe5931f9449048e834da5b",this.oracle_object="0x70b4a282626aef7d31822079a1727a6576c718e9640cb30ad4c385d632138689";break;case Lo.mainnet:this.packages.set("wowok",""),this.packages.set("base",""),this.packages.set("wowok_origin",""),this.packages.set("base_origin",""),this.wowok_object="",this.entity_object="",this.treasury_cap="",this.oracle_object=""}}package(e){return this.packages.get(e)??""}objectWowok(){return this.wowok_object}objectEntity(){return this.entity_object}objectOracle(){return this.oracle_object}objectTreasuryCap(){return this.treasury_cap}networkUrl(){switch(this.network){case Lo.localnet:return"http://127.0.0.1:9000";case Lo.devnet:return"https://fullnode.devnet.sui.io:443";case Lo.testnet:return"https://fullnode.testnet.sui.io:443";case Lo.mainnet:return"https://fullnode.mainnet.sui.io:443"}return""}machineFn=e=>`${this.packages.get("wowok")}::${Ao.machine}::${e}`;progressFn=e=>`${this.packages.get("wowok")}::${Ao.progress}::${e}`;repositoryFn=e=>`${this.packages.get("wowok")}::${Ao.repository}::${e}`;permissionFn=e=>`${this.packages.get("wowok")}::${Ao.permission}::${e}`;passportFn=e=>`${this.packages.get("wowok")}::${Ao.passport}::${e}`;demandFn=e=>`${this.packages.get("wowok")}::${Ao.demand}::${e}`;orderFn=e=>`${this.packages.get("wowok")}::${Ao.order}::${e}`;serviceFn=e=>`${this.packages.get("wowok")}::${Ao.service}::${e}`;resourceFn=e=>`${this.packages.get("wowok")}::${Ao.resource}::${e}`;entityFn=e=>`${this.packages.get("wowok")}::${Ao.entity}::${e}`;wowokFn=e=>`${this.packages.get("wowok")}::${Ao.wowok}::${e}`;treasuryFn=e=>`${this.packages.get("wowok")}::${Ao.treasury}::${e}`;paymentFn=e=>`${this.packages.get("wowok")}::${Ao.payment}::${e}`;guardFn=e=>`${this.packages.get("base")}::${Ao.guard}::${e}`;baseWowokFn=e=>`${this.packages.get("base")}::${Ao.wowok}::${e}`;arbitrationFn=e=>`${this.packages.get("wowok")}::${Ao.arbitration}::${e}`;arbFn=e=>`${this.packages.get("wowok")}::${Ao.arb}::${e}`;query=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()}),s=e.map((e=>e.objectid)),i=await r.call("sui_multiGetObjects",[s,t]);for(let r=0;r<i.length;r++)e.forEach((e=>{e.callback(this,i[r],e,t)}));return i};query_raw=async(e,t={showContent:!0})=>{const r=new ei({url:this.networkUrl()});return await r.call("sui_multiGetObjects",[e,t])};new_session=()=>(this.txb=new gs,this.txb);sessionCurrent=()=>this.txb?this.txb:this.new_session();sign_excute=async(e,t,r,s={showObjectChanges:!0})=>{const i=new ei({url:this.networkUrl()});e.forEach((e=>{e(this,r)}));const n=ea(t),a=Zn.fromSecretKey(n),o=await i.signAndExecuteTransaction({transaction:this.sessionCurrent(),signer:a,options:s});return this.txb=void 0,o};static SUI_TOKEN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";static SUI_COIN_TYPE="0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<0x2::sui::SUI>";WOWOK_TOKEN_TYPE=()=>this.packages.get("base")+"::wowok::WOWOK";WOWOK_COIN_TYPE=()=>"0x2::coin::Coin<"+this.packages.get("base")+"::wowok::WOWOK>";COINS_TYPE=()=>{switch(this.network){case Lo.testnet:return this.CoinTypes_Testnet.filter((e=>!0!==e.alias));case Lo.mainnet:return this.CoinTypes_Mainnet.filter((e=>!0!==e.alias))}return[]};update_coinType=(e,t,r)=>{if(r&&e)switch(this.network){case Lo.testnet:(s=this.CoinTypes_Testnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Testnet=s;break;case Lo.mainnet:var s;(s=this.CoinTypes_Mainnet.filter((t=>t?.type!==e))).push({symbol:r,type:e,decimals:t}),this.CoinTypes_Mainnet=s}};explorerUrl=(e,t="object")=>this.network===Lo.testnet?"https://testnet.suivision.xyz/"+t+"/"+e:this.network===Lo.mainnet?"https://suivision.xyz/"+t+"/"+e:"";CoinTypes_Testnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9}];CoinTypes_Mainnet=[{symbol:"SUI",type:"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",decimals:9,alias:!0},{symbol:"SUI",type:"0x2::sui::SUI",decimals:9},{symbol:"WOW",type:Go+"::wowok::WOWOK",decimals:9},{symbol:"USDT",type:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",decimals:6},{symbol:"USDC",type:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",decimals:6},{symbol:"WETH",type:"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",decimals:8},{symbol:"WBNB",type:"0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",decimals:8}];coinTypeInfo=(e,t)=>{if(!e)return"loading";return this.COINS_TYPE().find((t=>t?.type===e))||($o.Client().getCoinMetadata({coinType:e}).then((r=>{r?.decimals&&r?.symbol&&(this.update_coinType(e,r?.decimals,r?.symbol),t({symbol:r.symbol,decimals:r.decimals,type:e}))})).catch((e=>{console.log(e)})),"loading")};static CLOCK_OBJECT={objectId:"0x6",mutable:!1,initialSharedVersion:1};static TXB_OBJECT(e,t){return"string"==typeof t?e.object(t):t}static IsValidObjects=e=>To(e,(e=>!(!e||"string"==typeof e&&!oe(e))));WOWOK_OBJECTS_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"+$a(e)));WOWOK_OBJECTS_PREFIX_TYPE=()=>Object.keys(Ao).map((e=>(e===Ao.guard?this.packages.get("base"):this.packages.get("wowok"))+"::"+e+"::"));hasPackage(e){for(let t of this.packages.values())if(e.includes(t))return!0;return!1}object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.lastIndexOf("::");if(r>0)return e.slice(r+2)}return""};module_object_name_from_type_repr=e=>{if(!e)return"";let t=e.indexOf("::");if(t>0&&this.hasPackage(e.slice(0,t))){t=e.indexOf("<"),t>0&&(e=e.slice(0,t));let r=e.indexOf("::");if(r>0)return e.slice(r+2)}return""}}class zo{static Object_Type_Extra=()=>{let e=Object.keys(Ao).map((e=>e+"::"+$a(e)));return e.push("order::Discount"),e};static objectids_from_response=(e,t,r)=>{let s=new Map;return t?.objectChanges&&t.objectChanges.forEach((t=>{zo.Object_Type_Extra().forEach((r=>{"created"==t.type&&e.module_object_name_from_type_repr(t.objectType)===r&&(s.has(r)?s.get(r)?.push(t.objectId):s.set(r,[t.objectId]))}))})),r&&s.forEach(((e,t)=>{r.has(t)?r.set(t,r.get(t).concat(e)):r.set(t,e)})),s}}class Wo{bounty_type;permission;object;txb;get_bounty_type(){return this.bounty_type}get_object(){return this.object}static From(e,t,r,s){let i=new Wo(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.bounty_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i,n,a){io(n)||Ba(Ca.IsValidDesription),yo(t)||Ba(Ca.IsValidArgType,t),mo(s)||Ba(Ca.IsValidUint,"time");let o=new Wo(e,t,i);const d=e.sharedObjectRef($o.CLOCK_OBJECT);return o.object=a?e.moveCall({target:$o.Instance().demandFn("new_with_passport"),arguments:[a,e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().demandFn("new"),arguments:[e.pure.string(n),e.pure.bool(r),e.pure.u64(s),e.object(d),$o.TXB_OBJECT(e,i)],typeArguments:[t]}),o}launch(){return this.txb.moveCall({target:$o.Instance().demandFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.bounty_type]})}refund(e){const t=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e?this.txb.moveCall({target:$o.Instance().demandFn("refund_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}expand_time(e,t,r){mo(t)||Ba(Ca.IsValidUint,"time"),r?this.txb.moveCall({target:$o.Instance().demandFn("time_expand_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("time_expand"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_guard(e,t,r){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"guard"),void 0===t||lo(t)||Ba(Ca.InvalidParam,"set_guard.service_identifier");let s=this.txb.pure.option("u8",void 0!==t?t:void 0);r?e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):e?this.txb.moveCall({target:$o.Instance().demandFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),s,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().demandFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}yes(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().demandFn("yes_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("yes"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.bounty_type]})}deposit(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]})}present(e,t,r,s){io(r)||Ba(Ca.IsValidDesription,"present.tips"),t&&!yo(t)&&Ba(Ca.IsValidArgType,"service_pay_type"),"number"==typeof e?lo(e)&&s||Ba(Ca.IsValidU8,"present.service or present.passport"):$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"present.service"),s?"number"==typeof e?this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport2"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(r)],typeArguments:[this.bounty_type]}):this.txb.moveCall({target:$o.Instance().demandFn("present_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]}):"number"!=typeof e&&this.txb.moveCall({target:$o.Instance().demandFn("present"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(r)],typeArguments:[this.bounty_type,t]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().demandFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.bounty_type]}),this.permission=e}static parseObjectType=e=>qa(e,"demand::Demand<");static MAX_BOUNTY_COUNT=300;static MAX_PRESENTERS_COUNT=200}var Ho;!function(e){e[e.repository=100]="repository",e[e.repository_description=101]="repository_description",e[e.repository_mode=102]="repository_mode",e[e.repository_policies=103]="repository_policies",e[e.repository_reference=104]="repository_reference",e[e.service=200]="service",e[e.service_description=201]="service_description",e[e.service_sales=202]="service_sales",e[e.service_payee=203]="service_payee",e[e.service_repository=204]="service_repository",e[e.service_withdraw_guards=205]="service_withdraw_guards",e[e.service_refund_guards=206]="service_refund_guards",e[e.service_discount_transfer=207]="service_discount_transfer",e[e.service_withdraw=208]="service_withdraw",e[e.service_buyer_guard=209]="service_buyer_guard",e[e.service_machine=210]="service_machine",e[e.service_endpoint=211]="service_endpoint",e[e.service_publish=212]="service_publish",e[e.service_clone=213]="service_clone",e[e.service_customer_required=214]="service_customer_required",e[e.service_pause=215]="service_pause",e[e.service_treasury=216]="service_treasury",e[e.service_arbitration=217]="service_arbitration",e[e.demand=260]="demand",e[e.demand_refund=261]="demand_refund",e[e.demand_expand_time=262]="demand_expand_time",e[e.demand_guard=263]="demand_guard",e[e.demand_description=264]="demand_description",e[e.demand_yes=265]="demand_yes",e[e.machine=600]="machine",e[e.machine_description=601]="machine_description",e[e.machine_repository=602]="machine_repository",e[e.machine_clone=604]="machine_clone",e[e.machine_node=606]="machine_node",e[e.machine_endpoint=608]="machine_endpoint",e[e.machine_pause=609]="machine_pause",e[e.machine_publish=610]="machine_publish",e[e.progress=650]="progress",e[e.progress_namedOperator=651]="progress_namedOperator",e[e.progress_bind_task=652]="progress_bind_task",e[e.progress_context_repository=653]="progress_context_repository",e[e.progress_unhold=654]="progress_unhold",e[e.progress_parent=655]="progress_parent",e[e.treasury=700]="treasury",e[e.treasury_receive=701]="treasury_receive",e[e.treasury_deposit=702]="treasury_deposit",e[e.treasury_withdraw=703]="treasury_withdraw",e[e.treasury_descritption=704]="treasury_descritption",e[e.treasury_deposit_guard=705]="treasury_deposit_guard",e[e.treasury_withdraw_mode=706]="treasury_withdraw_mode",e[e.treasury_withdraw_guard=707]="treasury_withdraw_guard",e[e.arbitration=800]="arbitration",e[e.arbitration_description=801]="arbitration_description",e[e.arbitration_fee=802]="arbitration_fee",e[e.arbitration_voting_guard=803]="arbitration_voting_guard",e[e.arbitration_endpoint=804]="arbitration_endpoint",e[e.arbitration_guard=805]="arbitration_guard",e[e.arbitration_pause=806]="arbitration_pause",e[e.arbitration_vote=807]="arbitration_vote",e[e.arbitration_arbitration=808]="arbitration_arbitration",e[e.arbitration_withdraw=809]="arbitration_withdraw",e[e.arbitration_treasury=810]="arbitration_treasury",e[e.user_defined_start=1e3]="user_defined_start"}(Ho||(Ho={}));const Ko=[{index:Ho.repository,name:"Repository",description:"Launch new Repository",module:Ao.repository},{index:Ho.repository_description,name:"Description",description:"Set Repository description",module:Ao.repository},{index:Ho.repository_mode,name:"Policy mode",description:"Set Repository mode",module:Ao.repository},{index:Ho.repository_policies,name:"Policy",description:"Set Repository policies",module:Ao.repository},{index:Ho.repository_reference,name:"Reference",description:"Set Repository reference",module:Ao.repository},{index:Ho.service,name:"Service",description:"Launch new Service",module:Ao.service},{index:Ho.service_description,name:"Description",description:"Set Service description",module:Ao.service},{index:Ho.service_sales,name:"Sales",description:"Set Service sales items",module:Ao.service},{index:Ho.service_payee,name:"Payee",description:"Set Service payee",module:Ao.service},{index:Ho.service_repository,name:"Repository",description:"Set Service repositories",module:Ao.service},{index:Ho.service_withdraw_guards,name:"Withdraw Guard",description:"Set Service withdraw guards",module:Ao.service},{index:Ho.service_refund_guards,name:"Refund Guard",description:"Set Service refund guards",module:Ao.service},{index:Ho.service_discount_transfer,name:"Discount",description:"Launch discounts for Service",module:Ao.service},{index:Ho.service_buyer_guard,name:"Buyer Guard",description:"Set Guard of buying for Service",module:Ao.service},{index:Ho.service_machine,name:"Machine",description:"Set Machine for Service",module:Ao.service},{index:Ho.service_endpoint,name:"Endpoint",description:"Set Service endpoint",module:Ao.service},{index:Ho.service_publish,name:"Publish",description:"Allowing the creation of Order",module:Ao.service},{index:Ho.service_clone,name:"Clone",description:"Clone Service",module:Ao.service},{index:Ho.service_customer_required,name:"Buyer info",description:"Set Service buyer info required",module:Ao.service},{index:Ho.service_pause,name:"Pause",description:"Pause/Unpause Service",module:Ao.service},{index:Ho.service_treasury,name:"Treasury",description:"Externally withdrawable treasury for compensation or rewards",module:Ao.service},{index:Ho.service_arbitration,name:"Arbitration",description:"Add/Remove arbitration that allows refunds from orders at any time based on arbitration results",module:Ao.service},{index:Ho.demand,name:"Demand",description:"Launch new Demand",module:Ao.demand},{index:Ho.demand_refund,name:"Refund",description:"Refund from Demand",module:Ao.demand},{index:Ho.demand_expand_time,name:"Expand deadline",description:"Expand Demand deadline",module:Ao.demand},{index:Ho.demand_guard,name:"Guard",description:"Set Demand guard",module:Ao.demand},{index:Ho.demand_description,name:"Description",description:"Set Demand description",module:Ao.demand},{index:Ho.demand_yes,name:"Yes",description:"Pick the Deamand serice",module:Ao.demand},{index:Ho.machine,name:"Machine",description:"Launch new Machine",module:Ao.machine},{index:Ho.machine_description,name:"Description",description:"Set Machine description",module:Ao.machine},{index:Ho.machine_repository,name:"Repository",description:"Set Machine repository",module:Ao.machine},{index:Ho.machine_clone,name:"Clone",description:"Clone Machine",module:Ao.machine},{index:Ho.machine_node,name:"Node",description:"Set Machine nodes",module:Ao.machine},{index:Ho.machine_endpoint,name:"Endpoint",description:"Set Machine endpoint",module:Ao.machine},{index:Ho.machine_pause,name:"Pause",description:"Pause/Unpause Machine",module:Ao.machine},{index:Ho.machine_publish,name:"Publish",description:"Allowing the creation of Progress",module:Ao.machine},{index:Ho.progress,name:"Progress",description:"Launch new Progress",module:Ao.progress},{index:Ho.progress_namedOperator,name:"Operator",description:"Set Progress operators",module:Ao.progress},{index:Ho.progress_bind_task,name:"Bind",description:"Set Progress task",module:Ao.progress},{index:Ho.progress_context_repository,name:"Repository",description:"Set Progress repository",module:Ao.progress},{index:Ho.progress_unhold,name:"Unhold",description:"Release Progress holdings",module:Ao.progress},{index:Ho.progress_parent,name:"Parent",description:"Set Progress parent",module:Ao.progress},{index:Ho.treasury,name:"Treasury",description:"Launch new Treasury",module:Ao.treasury},{index:Ho.treasury_deposit,name:"Deposit",description:"Deposit coins",module:Ao.treasury},{index:Ho.treasury_receive,name:"Receive",description:"Receive coins from some address sent",module:Ao.treasury},{index:Ho.treasury_withdraw,name:"Withdraw",description:"Withdraw coins",module:Ao.treasury},{index:Ho.treasury_withdraw_guard,name:"Withdraw Guard",description:"Add/Remove Treasury withdraw guard",module:Ao.treasury},{index:Ho.treasury_withdraw_mode,name:"Withdraw mode",description:"Set Treasury withdraw mode",module:Ao.treasury},{index:Ho.treasury_deposit_guard,name:"Deposit Guard",description:"Set Treasury deposit guard",module:Ao.treasury},{index:Ho.treasury_descritption,name:"Description",description:"Set Treasury description",module:Ao.treasury},{index:Ho.arbitration,name:"Arbitration",description:"Launch new Arbitration",module:Ao.arbitration},{index:Ho.arbitration_description,name:"Description",description:"Set Arbitration description",module:Ao.arbitration},{index:Ho.arbitration_endpoint,name:"Endpoint",description:"Set Arbitration endpoint",module:Ao.arbitration},{index:Ho.arbitration_fee,name:"Fee",description:"Set Arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_guard,name:"Guard",description:"Set Guard to apply for arbitration",module:Ao.arbitration},{index:Ho.arbitration_arbitration,name:"Arbitrate",description:"Determine the outcome of arbitration",module:Ao.arbitration},{index:Ho.arbitration_pause,name:"Pause",description:"Allowing/forbidding the creation of Arb",module:Ao.arbitration},{index:Ho.arbitration_voting_guard,name:"Voting Guard",description:"Add/Remove voting Guard",module:Ao.arbitration},{index:Ho.arbitration_vote,name:"Vote",description:"Vote on the application for arbitration",module:Ao.arbitration},{index:Ho.arbitration_withdraw,name:"Withdraw",description:"Withdraw the arbitration fee",module:Ao.arbitration},{index:Ho.arbitration_treasury,name:"Withdraw",description:"Set Treasury that fees was collected at the time of withdrawal",module:Ao.arbitration}];class Qo{txb;object;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new Qo(e);return r.object=$o.TXB_OBJECT(e,t),r}static New(e,t){io(t)||Ba(Ca.IsValidDesription);let r=new Qo(e);return r.object=e.moveCall({target:$o.Instance().permissionFn("new"),arguments:[e.pure.string(t)]}),r}launch(){return this.txb.moveCall({target:$o.Instance().permissionFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_bizPermission(e,t){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"add_bizPermission"),no(t)||Ba(Ca.IsValidName,"add_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),this.txb.pure.string(t)]})}remove_bizPermission(e){Qo.IsValidBizPermissionIndex(e)||Ba(Ca.IsValidBizPermissionIndex,"remove_bizPermission"),this.txb.moveCall({target:$o.Instance().permissionFn("user_define_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e)]})}transfer_permission(e,t){co(e)&&co(t)||Ba(Ca.IsValidAddress,"transfer_permission"),this.txb.moveCall({target:$o.Instance().permissionFn("change_entity"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.address(t)]})}add_entity2(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_entity2"),void 0!==t?this.txb.moveCall({target:$o.Instance().permissionFn("add_with_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(t),this.txb.pure.vector("address",Ga(e))]}):this.txb.moveCall({target:$o.Instance().permissionFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}add_entity3(e){if(0===e.length)return;const t=[];e.forEach((e=>{e.entities.forEach((r=>{const s=t.find((e=>e.address===r.address));if(s){const t=s.permissions.find((t=>t.index===e.index));t?t.guard=r.guard:s.permissions.push({guard:r.guard,index:e.index})}else t.push({address:r.address,permissions:[{guard:r.guard,index:e.index}]})}))})),this.add_entity(t)}add_entity(e){if(0===e.length)return;let t=!0;e.forEach((e=>{co(e.address)||(t=!1),e.permissions.forEach((e=>{Qo.IsValidPermissionIndex(e.index)||(t=!1),e?.guard&&!$o.IsValidObjects([e.guard])&&(t=!1)}))})),t||Ba(Ca.InvalidParam,"add_entity.entities");let r=[];for(let t=0;t<e.length;t++){let s=e[t],i=[];for(let e=0;e<s.permissions.length;e++){let t=s.permissions[e];Qo.IsValidPermissionIndex(t.index)&&(i.includes(t.index)||(i.push(t.index),t?.guard&&r.push({address:s.address,index:t.index,guard:t.guard})))}i.length>0&&this.txb.moveCall({target:$o.Instance().permissionFn("add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(s.address),this.txb.pure.vector("u64",i)]})}r.forEach((({address:e,index:t,guard:r})=>{this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]})}))}set_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"address"),Qo.IsValidPermissionIndex(t)||Qo.IsValidBizPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex,"index"),r?this.txb.moveCall({target:$o.Instance().permissionFn("guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,r)]}):this.txb.moveCall({target:$o.Instance().permissionFn("guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.u64(t)]})}remove_index(e,t){co(e)||Ba(Ca.IsValidAddress),0!==t.length&&(To(t,Qo.IsValidPermissionIndex)||Ba(Ca.InvalidParam,"index"),this.txb.moveCall({target:$o.Instance().permissionFn("remove_index"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.vector("u64",Ga(t))]}))}remove_entity(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}set_description(e){io(e)||Ba(Ca.IsValidDesription),this.txb.moveCall({target:$o.Instance().permissionFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}add_admin(e){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray),this.txb.moveCall({target:$o.Instance().permissionFn("admin_add_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}remove_admin(e,t){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"admin"),t?this.txb.moveCall({target:$o.Instance().permissionFn("admins_clear"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]}):e&&this.txb.moveCall({target:$o.Instance().permissionFn("admin_remove_batch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e))]}))}change_owner(e){co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().permissionFn("builder_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}query_permissions_all(e){co(e)||Ba(Ca.InvalidParam,"query_permissions"),this.txb.moveCall({target:$o.Instance().permissionFn("query_permissions_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}QueryPermissions(e,t,r,s){this.query_permissions_all(t),$o.Client().devInspectTransactionBlock({sender:s??t,transactionBlock:this.txb}).then((s=>{if(s.results&&s.results[0].returnValues&&2!==s.results[0].returnValues.length)return void r({who:t,object:e});const i=Wa.getInstance().de(Oa.U8,Uint8Array.from(s.results[0].returnValues[0][0]));if(i===Qo.PERMISSION_ADMIN||i===Qo.PERMISSION_OWNER_AND_ADMIN)r({who:t,admin:!0,owner:i%2==1,items:[],object:e});else{const n=Wa.getInstance().de_perms(Uint8Array.from(s.results[0].returnValues[1][0]));r({who:t,admin:!1,owner:i%2==1,items:n.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e})}})).catch((s=>{console.log(s),r({who:t,object:e})}))}static HasPermission(e,t,r=!1){if(e){if(e.admin)return{has:!0,owner:e.owner};let r=e.items?.find((e=>e.query==t));return r?{has:r.permission,guard:r.guard,owner:e.owner}:{has:!1,guard:void 0,owner:e?.owner}}if(r)return{has:!1,guard:void 0,owner:!1}}static MAX_ADMIN_COUNT=64;static MAX_ENTITY_COUNT=2e3;static MAX_PERMISSION_INDEX_COUNT=200;static MAX_PERSONAL_PERMISSION_COUNT=200;static PERMISSION_NORMAL=0;static PERMISSION_OWNER=1;static PERMISSION_ADMIN=2;static PERMISSION_OWNER_AND_ADMIN=3;static BUSINESS_PERMISSIONS_START=Ho.user_defined_start;static IsValidBizPermissionIndex=e=>e>=Qo.BUSINESS_PERMISSIONS_START&&mo(e);static IsValidPermissionIndex=e=>!!Object.values(Ho).includes(e)||Qo.IsValidBizPermissionIndex(e)}class Zo{txb;object;permission;get_object(){return this.object}static From(e,t,r){let s=new Zo(e,t);return s.object=$o.TXB_OBJECT(e,r),s}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription),s&&!oo(s)&&Ba(Ca.IsValidEndpoint);let n=new Zo(e,t),a=e.pure.option("string",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().machineFn("new_with_passport"),arguments:[i,e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().machineFn("new"),arguments:[e.pure.string(r),a,$o.TXB_OBJECT(e,t)]}),n}add_node(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{no(e.name)||(r=!1),e.pairs.forEach((e=>{ao(e.prior_node)||(r=!1),e?.threshold&&!fo(e.threshold)&&(r=!1),e.forwards.forEach((e=>{""!==Zo.checkValidForward(e)&&(r=!1)}))}))})),r||Ba(Ca.InvalidParam,"add_node");let s=[];e.forEach((e=>{let t=this.txb.moveCall({target:$o.Instance().machineFn("node_new"),arguments:[this.txb.pure.string(e.name)]});e.pairs.forEach((e=>{let r=this.txb.pure.option("u32",e?.threshold);e.forwards.forEach((s=>{this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[t,this.txb.pure.string(e.prior_node),this.txb.pure.string(s.name),r,this.forward(s)]})})),0===e.forwards.length&&this.txb.moveCall({target:$o.Instance().machineFn("forward_add_none"),arguments:[t,this.txb.pure.string(e.prior_node),r]})})),s.push(t)})),this.add_node2(s,t)}forward(e){let t,r=e?.weight?e.weight:1;return e?.namedOperator&&no(e.namedOperator)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward2"),arguments:[this.txb.pure.string(e.namedOperator),this.txb.pure.u16(r)]}):void 0!==e?.permission&&mo(e.permission)?t=e?.guard?this.txb.moveCall({target:$o.Instance().machineFn("forward3"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r),this.txb.object($o.TXB_OBJECT(this.txb,e.guard))]}):this.txb.moveCall({target:$o.Instance().machineFn("forward4"),arguments:[this.txb.pure.u64(e.permission),this.txb.pure.u16(r)]}):Ba(Ca.InvalidParam,"forward"),e?.suppliers?.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"forward.suppliers:"+e.object),this.txb.moveCall({target:$o.Instance().serviceFn("add_to"),arguments:[this.txb.object(e.object),this.txb.pure.bool(e.bRequired??!1),t],typeArguments:[e.pay_token_type]})})),t}add_node2(e,t){if(0===e.length)return;let r=e.map((e=>$o.TXB_OBJECT(this.txb,e)));t?this.txb.moveCall({target:$o.Instance().machineFn("node_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.makeMoveVec({elements:r}),$o.TXB_OBJECT(this.txb,this.permission)]})}fetch_node(e,t){return no(e)||Ba(Ca.IsValidName,"fetch_node"),t?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}rename_node(e,t,r){e!==t&&(no(e)||Ba(Ca.IsValidName,"rename_node"),no(t)||Ba(Ca.IsValidName,"rename_node"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_node(e,t=!1,r){0!==e.length&&(To(e,no)||Ba(Ca.IsValidArray,"nodes_name"),r?this.txb.moveCall({target:$o.Instance().machineFn("node_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",e),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)]}))}launch(){return this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().machineFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}add_repository(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("repository_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_repository"),r?t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.object)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().machineFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}clone(e,t){let r;return r=t?this.txb.moveCall({target:$o.Instance().machineFn("clone_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}),e?this.txb.moveCall({target:$o.Instance().machineFn("create"),arguments:[$o.TXB_OBJECT(this.txb,r)]}):r}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().machineFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)]})}publish(e){e?this.txb.moveCall({target:$o.Instance().machineFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"new_permission"),this.txb.moveCall({target:$o.Instance().machineFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}add_forward(e,t,r,s,i,n){ao(e)||Ba(Ca.IsValidName_AllowEmpty,"add_forward"),no(t)||Ba(Ca.IsValidName,"add_forward");const a=Zo.checkValidForward(r);let o;a&&Ba(Ca.InvalidParam,a),o=n?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]});const d=this.forward(r),c=this.txb.pure.option("u32",s??void 0);this.txb.moveCall({target:$o.Instance().machineFn("forward_add"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(r.name),c,d]}),i&&i!==r.name&&this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[o,this.txb.pure.string(e),this.txb.pure.string(i)]}),this.add_node2([o],n)}remove_pair(e,t,r){let s;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_pair"),no(t)||Ba(Ca.IsValidName,"remove_pair"),s=r?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("pair_remove"),arguments:[s,this.txb.pure.string(e)]}),this.add_node2([s],r)}remove_forward(e,t,r,s){let i;ao(e)||Ba(Ca.IsValidName_AllowEmpty,"remove_forward"),no(t)||Ba(Ca.IsValidName,"remove_forward"),i=s?this.txb.moveCall({target:$o.Instance().machineFn("node_fetch_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().machineFn("node_fetch"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}),this.txb.moveCall({target:$o.Instance().machineFn("forward_remove"),arguments:[i,this.txb.pure.string(e),this.txb.pure.string(r)]}),this.add_node2([i],s)}static rpc_de_nodes(e){const t=[];return e.forEach((e=>{t.push({name:e.data.content.fields.name,pairs:Zo.rpc_de_pair(e?.data.content.fields.value)})})),t}static rpc_de_pair(e){let t=[];return e.fields.value.fields.contents.forEach((e=>{let r=[];e.fields.value.fields.forwards.fields.contents.forEach((e=>{let t=e.fields.key,s=e.fields.value.fields.weight,i=e.fields.value.fields.guard,n=e.fields.value.fields.namedOperator,a=e.fields.value.fields.permission_index;r.push({name:t,namedOperator:n,permission:a,weight:s,guard:i||"",suppliers:e.fields.value.fields.suppliers.fields.contents.map((e=>({object:e.fields.key,bRequired:e.fields.value,pay_token_type:""})))})})),t.push({prior_node:e.fields.key,threshold:e.fields.value.fields.threshold,forwards:r})})),t}static namedOperators(e){let t=[];return e.forEach((e=>{e.pairs.forEach((e=>{e.forwards.forEach((e=>{e?.namedOperator&&!t.find((t=>t===e.namedOperator))&&t.push(e.namedOperator)}))}))})),t}static checkValidForward(e){return no(e.name)?e?.namedOperator&&!ao(e?.namedOperator)?"Progress Operator invalid":e?.permission&&!Qo.IsValidPermissionIndex(e?.permission)?"Permission index invalid":e?.permission||e?.namedOperator?e?.weight&&!mo(e.weight)?"Weight invalid":"":"Business-Permissions invalid":"Forward name invalid"}static INITIAL_NODE_NAME="";static OPERATOR_ORDER_PAYER="OrderPayer"}class ed{permission;machine;object;txb;get_object(){return this.object}constructor(e,t,r){this.permission=r,this.txb=e,this.machine=t,this.object=""}static From(e,t,r,s){let i=new ed(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i){$o.IsValidObjects([t,r])||Ba(Ca.IsValidObjects,"machine & permission");let n=new ed(e,t,r),a=e.pure.option("address",s||void 0);return n.object=i?e.moveCall({target:$o.Instance().progressFn("new_with_passport"),arguments:[i,a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}):e.moveCall({target:$o.Instance().progressFn("new"),arguments:[a,$o.TXB_OBJECT(e,t),$o.TXB_OBJECT(e,r)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}set_namedOperator(e,t,r){no(e)||Ba(Ca.IsValidName,"name"),e===Zo.OPERATOR_ORDER_PAYER&&Ba(Ca.InvalidParam,"name cannot be "+Zo.OPERATOR_ORDER_PAYER),(t.length>ed.MAX_NAMED_OPERATOR_COUNT||!To(t,co))&&Ba(Ca.InvalidParam,"addresses"),r?this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",Ga(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("namedOperator_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.vector("address",Ga(t)),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}bind_task(e,t){co(e)||Ba(Ca.IsValidAddress),t?this.txb.moveCall({target:$o.Instance().progressFn("task_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("task_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}set_context_repository(e,t){e&&!$o.IsValidObjects([e])&&Ba(Ca.IsValidObjects,"repository"),t?e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):e?this.txb.moveCall({target:$o.Instance().progressFn("context_repository_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("context_repository_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}unhold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"unhold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?this.txb.moveCall({target:$o.Instance().progressFn("unhold_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]}):this.txb.moveCall({target:$o.Instance().progressFn("unhold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}parent_none(e){e?this.txb.moveCall({target:$o.Instance().progressFn("parent_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),$o.TXB_OBJECT(this.txb,this.permission)]})}parent(e,t){co(e.parent_id)&&fo(e.parent_session_id)||Ba(Ca.InvalidParam,"parent"),e.next_node&&e.forward||Ba(Ca.InvalidParam,"parent"),t?this.txb.moveCall({target:$o.Instance().progressFn("parent_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().progressFn("parent_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.object(e.parent_id),this.txb.pure.u64(e.parent_session_id),this.txb.pure.string(e.next_node),this.txb.pure.string(e.forward),$o.TXB_OBJECT(this.txb,this.permission)]})}deliverable(e){io(e.msg)||Ba(Ca.IsValidDesription,"deliverable.msg"),e.orders.length>0&&!$o.IsValidObjects(e.orders.map((e=>e.object)))&&Ba(Ca.IsValidObjects,"deliverable.orders");const t=this.txb.moveCall({target:$o.Instance().progressFn("deliverable_new"),arguments:[this.txb.pure.string(e.msg)]});return e.orders.forEach((e=>{go(e.pay_token_type)||Ba(Ca.IsValidTokenType,"deliverable.orders:"+e.object),this.txb.moveCall({target:$o.Instance().orderFn("as_deliverable"),arguments:[this.txb.object(e.object),t],typeArguments:[e.pay_token_type]})})),t}next(e,t,r){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"next");const s=this.deliverable(t),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().progressFn("next_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]}):this.txb.moveCall({target:$o.Instance().progressFn("next"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),s,$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(i)]})}hold(e,t){ed.IsValidProgressNext(e)||Ba(Ca.InvalidParam,"hold");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return this.txb.moveCall({target:$o.Instance().progressFn("hold"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.machine),this.txb.pure.string(e.next_node_name),this.txb.pure.string(e.forward),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission),this.txb.object(r)]})}static QueryForwardGuard=async(e,t,r,s,i)=>{if(!(e&&t&&s&&i))return void Ba(Ca.InvalidParam,"QueryForwardGuard");const n=new gs;n.moveCall({target:$o.Instance().progressFn("query_guard"),arguments:[$o.TXB_OBJECT(n,e),$o.TXB_OBJECT(n,t),n.pure.string(s),n.pure.string(i)]});const a=await $o.Client().devInspectTransactionBlock({sender:r,transactionBlock:n});if(1===a.results?.length&&1===a.results[0].returnValues?.length){const e=Wa.getInstance().de("Option<address>",Uint8Array.from(a.results[0].returnValues[0][0]));return e?.some?"0x"+e?.some:void 0}};static DeSessions=e=>{let t=[];return e?.fields?.contents?.forEach((e=>{var r={next_node:e.fields.key,holders:[],weights:e.fields.value.fields.weights,threshold:e.fields.value.fields.threshold};e.fields.value.fields.forwards.fields.contents.forEach((e=>{r.holders.push({forward:e.fields.key,accomplished:e.fields.value.fields.accomplished,time:e.fields.value.fields.time,who:e.fields.value.fields.who,deliverable:{msg:e.fields.value.fields.msg,orders:e.fields.value.fields.orders??[]}})})),t.push(r)})),t};static DeHistories=e=>e?.map((e=>ed.DeHistory(e?.data?.content?.fields)));static DeHistory=e=>({id:parseInt(e?.name),node:e?.value?.fields?.node,next_node:e?.value?.fields?.next_node,sessions:ed.DeSessions(e?.value.fields?.session),time:e?.value?.fields?.time});static MAX_NAMED_OPERATOR_COUNT=20;static MAX_DELEVERABLE_ORDER_COUNT=20;static IsValidProgressNext=e=>no(e.forward)&&no(e.next_node_name)}const td=[{module:Ao.permission,query_name:"Owner",query_id:1,parameters:[],return:No.TYPE_ADDRESS,description:"Owner's address."},{module:Ao.permission,query_name:"Is Admin",query_id:2,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain address an administrator?",parameters_description:["address"]},{module:Ao.permission,query_name:"Has Rights",query_id:3,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Does an address have a certain permission(Admin always have permissions)?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Contains Address",query_id:4,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is included in the personnel permission table?",parameters_description:["address"]},{module:Ao.permission,query_name:"Contains Permission",query_id:5,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Whether a certain permission for a certain address is defined in the personnel permission table?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Contains Permission Guard",query_id:6,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Whether a permission guard for a certain address is defined in the personnel permission table?",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Permission Guard",query_id:7,parameters:[No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_ADDRESS,description:"Permission guard for a certain address.",parameters_description:["address","permission index"]},{module:Ao.permission,query_name:"Number of Entities",query_id:8,parameters:[],return:No.TYPE_U64,description:"Number of entities in the personnel permission table."},{module:Ao.permission,query_name:"Number of Admin",query_id:9,parameters:[],return:No.TYPE_U64,description:"Number of administrators."},{module:Ao.repository,query_name:"Permission",query_id:100,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.repository,query_name:"Contains Policy",query_id:101,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Is a consensus policy included?",parameters_description:["the filed name"]},{module:Ao.repository,query_name:"Is Permission set of Policy",query_id:102,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does a certain consensus policy set data operation permissions?",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Permission of Policy",query_id:103,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"The permission index of a certain consensus policy in the Permission object.",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Value Type of Policy",query_id:104,parameters:[No.TYPE_STRING],return:No.TYPE_U8,description:"Data types defined by consensus policy.",parameters_description:["the policy name"]},{module:Ao.repository,query_name:"Contains Data",query_id:105,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does it contain data for a certain field of an address?",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Raw data without Type",query_id:106,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U8,description:"Data for a field at an address and does not contain data type information.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Raw data",query_id:107,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U8,description:"Data for a field at an address, and the first byte contains data type information.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Type",query_id:108,parameters:[],return:No.TYPE_U8,description:"The repository Type. 0: Normal; 1: Wowok greenee."},{module:Ao.repository,query_name:"Policy Mode",query_id:109,parameters:[],return:No.TYPE_U8,description:"Policy Mode. 0: Free mode; 1: Strict mode."},{module:Ao.repository,query_name:"Reference Count",query_id:110,parameters:[],return:No.TYPE_U64,description:"The number of times it is referenced by other objects."},{module:Ao.repository,query_name:"Is Referenced by An Object",query_id:111,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is it referenced by an object?",parameters_description:["address"]},{module:Ao.repository,query_name:"Number Data",query_id:112,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_U256,description:"Data for a field at an address and get unsigned integer type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"String Data",query_id:113,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_STRING,description:"Data for a field at an address and get string type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Address Data",query_id:114,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"Data for a field at an address and get address type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Bool Data",query_id:115,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Data for a field at an address and get bool type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Number Vector Data",query_id:116,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_U256,description:"Data for a field at an address and get unsigned integer vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"String Vector Data",query_id:117,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_STRING,description:"Data for a field at an address and get string vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Address Vector Data",query_id:118,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_ADDRESS,description:"Data for a field at an address and get address vector type data.",parameters_description:["address","the field name"]},{module:Ao.repository,query_name:"Bool Vector Data",query_id:119,parameters:[No.TYPE_ADDRESS,No.TYPE_STRING],return:No.TYPE_VEC_BOOL,description:"Data for a field at an address and get bool vector type data.",parameters_description:["address","the field name"]},{module:Ao.entity,query_name:"Has Entity",query_id:200,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is an entity already registered?",parameters_description:["address"]},{module:Ao.entity,query_name:"Likes",query_id:201,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The number of likes for an address by other addresses.",parameters_description:["address"]},{module:Ao.entity,query_name:"Dislikes",query_id:202,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The number of dislikes for an address by other addresses.",parameters_description:["address"]},{module:Ao.entity,query_name:"Entity Info",query_id:203,parameters:[No.TYPE_ADDRESS],return:No.TYPE_VEC_U8,description:"Public information about an entity.",parameters_description:["address"]},{module:Ao.entity,query_name:"Has Resource by Entity?",query_id:204,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an entity created a resource?",parameters_description:["address"]},{module:Ao.entity,query_name:"Entity Resource",query_id:205,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"The address of a resource object created by an entity.",parameters_description:["address"]},{module:Ao.demand,query_name:"Permission",query_id:300,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.demand,query_name:"Deadline",query_id:302,parameters:[],return:No.TYPE_U64,description:"The expiration time of presenting."},{module:Ao.demand,query_name:"Bounty Count",query_id:303,parameters:[],return:No.TYPE_U64,description:"Number of Bounties."},{module:Ao.demand,query_name:"Has Guard",query_id:304,parameters:[],return:No.TYPE_BOOL,description:"Whether the present guard is set?"},{module:Ao.demand,query_name:"Guard",query_id:305,parameters:[],return:No.TYPE_ADDRESS,description:"The present guard address."},{module:Ao.demand,query_name:"Has Service Picked",query_id:306,parameters:[],return:No.TYPE_BOOL,description:"Whether a service has been picked and bounties given?"},{module:Ao.demand,query_name:"Service Picked",query_id:307,parameters:[],return:No.TYPE_ADDRESS,description:"Service address that has been picked."},{module:Ao.demand,query_name:"Presenter Count",query_id:308,parameters:[],return:No.TYPE_U64,description:"Number of presenters."},{module:Ao.demand,query_name:"Has Presenter",query_id:309,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain address a presenter?",parameters_description:["address"]},{module:Ao.demand,query_name:"Who Got Bounty",query_id:310,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"The address that bounties given.",parameters_description:["address"]},{module:Ao.service,query_name:"Permission",query_id:400,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.service,query_name:"Payee",query_id:401,parameters:[],return:No.TYPE_ADDRESS,description:"Payee address, that all order withdrawals will be collected to this address."},{module:Ao.service,query_name:"Has Buying Guard",query_id:402,parameters:[],return:No.TYPE_BOOL,description:"Is the guard condition of buying set?"},{module:Ao.service,query_name:"Buying Guard",query_id:403,parameters:[],return:No.TYPE_ADDRESS,description:"Buying guard, that Purchase only if you meet the conditions of the guard."},{module:Ao.service,query_name:"Contains Repository",query_id:404,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a certain repository one of the service's consensus repositories?",parameters_description:["address"]},{module:Ao.service,query_name:"Has Withdrawing Guard",query_id:405,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether a certain guard is set when withdrawing money?",parameters_description:["address"]},{module:Ao.service,query_name:"Withdrawing Guard Percent",query_id:406,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The percentage of withdrawals allowed by a certain withdrawal guard.",parameters_description:["address"]},{module:Ao.service,query_name:"Has Refunding Guard",query_id:407,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether a certain guard is set when refunding money?",parameters_description:["address"]},{module:Ao.service,query_name:"Refunding Guard Percent",query_id:408,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The percentage of refund allowed by a certain refund guard.",parameters_description:["address"]},{module:Ao.service,query_name:"Has Sales Item",query_id:409,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Is there a sales item for the service?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Sale Item Price",query_id:410,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"What is the price of a certain sale item?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Sale Item Inventory",query_id:411,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"How much inventory is there for a certain sales item?",parameters_description:["the item name"]},{module:Ao.service,query_name:"Has Machine",query_id:412,parameters:[],return:No.TYPE_BOOL,description:"Has the machine(progress generator) that serves the order been set up?"},{module:Ao.service,query_name:"Machine",query_id:413,parameters:[],return:No.TYPE_ADDRESS,description:"Machine address, that generate progresses serving the execution process of order."},{module:Ao.service,query_name:"Paused",query_id:414,parameters:[],return:No.TYPE_BOOL,description:"Pause the creation of new order?"},{module:Ao.service,query_name:"Published",query_id:415,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create orders?"},{module:Ao.service,query_name:"Has Required Info",query_id:416,parameters:[],return:No.TYPE_BOOL,description:"Whether the necessary information that needs to be provided by the customer is set?"},{module:Ao.service,query_name:"Required Info of Service-Pubkey",query_id:417,parameters:[],return:No.TYPE_STRING,description:"The public key used to encrypt customer information, and only the service provider can decrypt and view customer information."},{module:Ao.service,query_name:"Required Info",query_id:418,parameters:[],return:No.TYPE_VEC_STRING,description:"Names of the required information item that needs to be provided by the customer."},{module:Ao.service,query_name:"Number of Treasuries",query_id:419,parameters:[],return:No.TYPE_U64,description:"The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives."},{module:Ao.service,query_name:"Contains Treasury",query_id:420,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?",parameters_description:["treasury address"]},{module:Ao.service,query_name:"Number of Arbitrations",query_id:421,parameters:[],return:No.TYPE_U64,description:"The number of arbitrations that allows a refund to be made from the order at any time based on the arbitration result."},{module:Ao.service,query_name:"Contains Arbitration",query_id:422,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does it contain an arbitration that allows a refund to be made from the order at any time based on the arbitration result.?",parameters_description:["arbitration address"]},{module:Ao.order,query_name:"Amount",query_id:500,parameters:[],return:No.TYPE_U64,description:"Order amount."},{module:Ao.order,query_name:"Payer",query_id:501,parameters:[],return:No.TYPE_ADDRESS,description:"Order payer."},{module:Ao.order,query_name:"Service",query_id:502,parameters:[],return:No.TYPE_ADDRESS,description:"Service for creating orders."},{module:Ao.order,query_name:"Has Progress",query_id:503,parameters:[],return:No.TYPE_BOOL,description:"Is there a Progress for executing the order process?"},{module:Ao.order,query_name:"Progress",query_id:504,parameters:[],return:No.TYPE_ADDRESS,description:"Progress address for executing the order process."},{module:Ao.order,query_name:"Required Info",query_id:505,parameters:[],return:No.TYPE_BOOL,description:"Is Required Info set?"},{module:Ao.order,query_name:"Discount Used",query_id:506,parameters:[],return:No.TYPE_BOOL,description:"Discount coupon used for this order?"},{module:Ao.order,query_name:"Discount",query_id:507,parameters:[],return:No.TYPE_ADDRESS,description:"Discount address that already used."},{module:Ao.order,query_name:"Balance",query_id:508,parameters:[],return:No.TYPE_U64,description:"The amount currently in the order."},{module:Ao.order,query_name:"Number of Agents",query_id:511,parameters:[],return:No.TYPE_U64,description:"The number of agents for the order."},{module:Ao.order,query_name:"Has Agent",query_id:512,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is an order agent?",parameters_description:["agent address"]},{module:Ao.order,query_name:"Number of Disputes",query_id:513,parameters:[],return:No.TYPE_U64,description:"Number of arbitrations for the order."},{module:Ao.order,query_name:"Has Arb",query_id:514,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Does the order contain an Arb for arbitration?",parameters_description:["arb address"]},{module:Ao.machine,query_name:"Permission",query_id:700,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.machine,query_name:"Paused",query_id:701,parameters:[],return:No.TYPE_BOOL,description:"Pause the creation of new Progress?"},{module:Ao.machine,query_name:"Published",query_id:702,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create Progress?"},{module:Ao.machine,query_name:"Is Consensus Repository",query_id:703,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address is a consensus repository?",parameters_description:["adddress"]},{module:Ao.machine,query_name:"Has Endpoint",query_id:704,parameters:[],return:No.TYPE_BOOL,description:"Is the endpoint set?"},{module:Ao.machine,query_name:"Endpoint",query_id:705,parameters:[],return:No.TYPE_STRING,description:"Endpoint url/ipfs."},{module:Ao.progress,query_name:"Machine",query_id:800,parameters:[],return:No.TYPE_ADDRESS,description:"The Machine object that created this Progress."},{module:Ao.progress,query_name:"Current Node",query_id:801,parameters:[],return:No.TYPE_STRING,description:"The name of the currently running node."},{module:Ao.progress,query_name:"Has Parent",query_id:802,parameters:[],return:No.TYPE_BOOL,description:"Is the parent Progress defined?"},{module:Ao.progress,query_name:"Parent",query_id:803,parameters:[],return:No.TYPE_ADDRESS,description:"The parent Progress, that contains some child Progress."},{module:Ao.progress,query_name:"Has Task",query_id:804,parameters:[],return:No.TYPE_BOOL,description:"Does it contain clear task(eg. an Order)?"},{module:Ao.progress,query_name:"Task",query_id:805,parameters:[],return:No.TYPE_ADDRESS,description:"Task object address."},{module:Ao.progress,query_name:"Has Unique Permission",query_id:806,parameters:[No.TYPE_STRING],return:No.TYPE_BOOL,description:"Does Progress define a unique operation permission?",parameters_description:["operator name"]},{module:Ao.progress,query_name:"Is Unique Permission Operator",query_id:807,parameters:[No.TYPE_STRING,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is an address an operator with unique permissions?",parameters_description:["operator name","address"]},{module:Ao.progress,query_name:"Has Context Repository",query_id:808,parameters:[],return:No.TYPE_BOOL,description:"Whether the repository reference for Progress is set?"},{module:Ao.progress,query_name:"Context Repository",query_id:809,parameters:[],return:No.TYPE_ADDRESS,description:"Repository reference for Progress."},{module:Ao.progress,query_name:"Last Session Time",query_id:810,parameters:[],return:No.TYPE_U64,description:"Time when the previous session was completed."},{module:Ao.progress,query_name:"Last Session Node",query_id:811,parameters:[],return:No.TYPE_STRING,description:"The name of the last completed node."},{module:Ao.progress,query_name:"Current Session-id",query_id:812,parameters:[],return:No.TYPE_U64,description:"The session id of ongoing node."},{module:Ao.progress,query_name:"Parent Session-id",query_id:813,parameters:[],return:No.TYPE_U64,description:"The child process was started in the Session-id phase of the parent process."},{module:Ao.progress,query_name:"Parent Next Node",query_id:814,parameters:[],return:No.TYPE_STRING,description:"The child process is started at the next node stage of the parent process."},{module:Ao.progress,query_name:"Parent Forward",query_id:815,parameters:[],return:No.TYPE_STRING,description:"The child process is started in the Forward phase of the next node of the parent process."},{module:Ao.progress,query_name:"Parent Node",query_id:816,parameters:[],return:No.TYPE_STRING,description:"The node name of the parent process where the child process is located."},{module:Ao.progress,query_name:"Forward Accomplished",query_id:817,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Has the forward been accomplished?",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Operator",query_id:818,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"The forward operator.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Message",query_id:819,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_STRING,description:"The forward message.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward Order Count",query_id:820,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The forward Order count.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Forward time",query_id:821,parameters:[No.TYPE_U64,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The time when the forward was last triggered.",parameters_description:["session-id","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Session Time",query_id:822,parameters:[No.TYPE_STRING],return:No.TYPE_U64,description:"The time a node that closest time to the current node completes its session.",parameters_description:["node name"]},{module:Ao.progress,query_name:"Closest Forward Accomplished",query_id:823,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_BOOL,description:"Has the forward been accomplished?",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Operator",query_id:824,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_ADDRESS,description:"The operator of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Message",query_id:825,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_STRING,description:"The message of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward Order Count",query_id:826,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The Order count of the forward that closest time to the current node.",parameters_description:["node name","next node name","forward name"]},{module:Ao.progress,query_name:"Closest Forward time",query_id:827,parameters:[No.TYPE_STRING,No.TYPE_STRING,No.TYPE_STRING],return:No.TYPE_U64,description:"The time when the forward that closest time to the current node was last triggered.",parameters_description:["node name","next node name","forward name"]},{module:Ao.wowok,query_name:"Builder",query_id:900,parameters:[],return:No.TYPE_ADDRESS,description:"Builder address of Wowok."},{module:Ao.wowok,query_name:"Object of Entities",query_id:901,parameters:[],return:No.TYPE_ADDRESS,description:"The address of entity information object."},{module:Ao.wowok,query_name:"Grantor Count",query_id:902,parameters:[],return:No.TYPE_U64,description:"Number of registered grantors."},{module:Ao.wowok,query_name:"Has Grantor",query_id:903,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether an address has been registered as a grantor?",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Name",query_id:904,parameters:[No.TYPE_ADDRESS],return:No.TYPE_STRING,description:"Name of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Registration Time",query_id:905,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Registration time of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantor Expired Time",query_id:906,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The expiration time of a grantor.",parameters_description:["address"]},{module:Ao.wowok,query_name:"Grantee Object for Grantor",query_id:907,parameters:[No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Grantee repository address of a grantor.",parameters_description:["address"]},{module:Ao.payment,query_name:"Sender",query_id:1200,parameters:[],return:No.TYPE_ADDRESS,description:"Payment originator address."},{module:Ao.payment,query_name:"Total Amount",query_id:1201,parameters:[],return:No.TYPE_U128,description:"Payment amount."},{module:Ao.payment,query_name:"Remark",query_id:1202,parameters:[],return:No.TYPE_STRING,description:"Payment remark.",parameters_description:["address"]},{module:Ao.payment,query_name:"Has Guard for Perpose",query_id:1203,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment references a Guard?"},{module:Ao.payment,query_name:"Has Object for Perpose",query_id:1204,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment references an Object?"},{module:Ao.payment,query_name:"Guard for Perpose",query_id:1205,parameters:[],return:No.TYPE_ADDRESS,description:"The Guard referenced by this payment."},{module:Ao.payment,query_name:"Object for Perpose",query_id:1206,parameters:[],return:No.TYPE_ADDRESS,description:"The Object referenced by this payment."},{module:Ao.payment,query_name:"Number of Recipients",query_id:1207,parameters:[],return:No.TYPE_U64,description:"Number of recipients to receive payment from."},{module:Ao.payment,query_name:"Is a Recipient",query_id:1208,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Is a recipient received the payment?",parameters_description:["address"]},{module:Ao.payment,query_name:"Amount for a Recipient",query_id:1209,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The amount of payment received by an address.",parameters_description:["address"]},{module:Ao.payment,query_name:"Time",query_id:1210,parameters:[],return:No.TYPE_U64,description:"Payment time"},{module:Ao.payment,query_name:"Is from Treasury",query_id:1211,parameters:[],return:No.TYPE_BOOL,description:"Whether the payment comes from a Treasury?"},{module:Ao.payment,query_name:"Treasury Address",query_id:1212,parameters:[],return:No.TYPE_ADDRESS,description:"The Treasury from which the payment comes."},{module:Ao.payment,query_name:"Biz-ID",query_id:1213,parameters:[],return:No.TYPE_U64,description:"Bisiness ID number of the payment."},{module:Ao.payment,query_name:"Check the purpose of payment",query_id:1214,parameters:[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64],return:No.TYPE_BOOL,description:"Do Guard, Object Perpose, and Biz-ID match?",parameters_description:["guard address","object address","Biz-ID"]},{module:Ao.payment,query_name:"Check & Amount for a Recipient",query_id:1215,parameters:[No.TYPE_ADDRESS,No.TYPE_ADDRESS,No.TYPE_U64,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Check and get the amount of payment received by an address.",parameters_description:["guard address","object address","Biz-ID","recipient address"]},{module:Ao.treasury,query_name:"Permission",query_id:1400,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.treasury,query_name:"Balance",query_id:1401,parameters:[],return:No.TYPE_U64,description:"Treasury balance."},{module:Ao.treasury,query_name:"Number of Flow Records",query_id:1402,parameters:[],return:No.TYPE_U64,description:"Number of treasury transactions."},{module:Ao.treasury,query_name:"Inflow Amount",query_id:1403,parameters:[],return:No.TYPE_U128,description:"Treasury inflow amount."},{module:Ao.treasury,query_name:"Outflow Amount",query_id:1404,parameters:[],return:No.TYPE_U128,description:"Treasury outflow amount."},{module:Ao.treasury,query_name:"Has Deposit Guard",query_id:1405,parameters:[],return:No.TYPE_BOOL,description:"Whether the deposit Guard set?"},{module:Ao.treasury,query_name:"Deposit Guard",query_id:1406,parameters:[],return:No.TYPE_ADDRESS,description:"Deposit Guard address."},{module:Ao.treasury,query_name:"Number of Withdraw Guards",query_id:1407,parameters:[],return:No.TYPE_U64,description:"Number of withdraw guards."},{module:Ao.treasury,query_name:"Has Withdraw Guard",query_id:1408,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has a Withdraw Guard added?",parameters_description:["guard address"]},{module:Ao.treasury,query_name:"Withdrawal Amount with Guard",query_id:1409,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"withdrawal amount corresponding the Guard.",parameters_description:["guard address"]},{module:Ao.treasury,query_name:"Recent Time with Operation",query_id:1410,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"Time of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Signer with Operation",query_id:1411,parameters:[No.TYPE_U8],return:No.TYPE_ADDRESS,description:"Signer address of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Payment with Operation",query_id:1412,parameters:[No.TYPE_U8],return:No.TYPE_ADDRESS,description:"Payment address of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Amount with Operation",query_id:1413,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"Amount of the most recent fund operation.",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Recent Time with Op/Pmt",query_id:1414,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation with payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Signer with Op&Pmt",query_id:1415,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Signer of the most recent fund operationwith payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Pmt",query_id:1416,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation with payment specified.",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Recent Time with Op/Sgr",query_id:1417,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation with signer specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Payment with Op/Sgr",query_id:1418,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_ADDRESS,description:"Payment of the most recent fund operation with singner specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Sgr",query_id:1419,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation with singer specified.",parameters_description:["operation","signer address"]},{module:Ao.treasury,query_name:"Recent Time with Op/Pmt/Sgr",query_id:1420,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Time of the most recent fund operation.",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Recent Amount with Op/Pmt/Sgr",query_id:1421,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Amount of the most recent fund operation.",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Has Operation",query_id:1422,parameters:[No.TYPE_U8],return:No.TYPE_BOOL,description:"Whether there was a fund operation?",parameters_description:["operation"]},{module:Ao.treasury,query_name:"Has Operation with Pmt",query_id:1423,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation with payment specified?",parameters_description:["operation","payment address"]},{module:Ao.treasury,query_name:"Has Operation with Sgr",query_id:1424,parameters:[No.TYPE_U8,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation with singer specified?",parameters_description:["operation","singer address"]},{module:Ao.treasury,query_name:"Has Operation with Pmt/Sgr",query_id:1425,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Whether there was a fund operation?",parameters_description:["operation","payment address","singer address"]},{module:Ao.treasury,query_name:"Operation at Least Times",query_id:1426,parameters:[No.TYPE_U8,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does it operate at least a certain number of times?",parameters_description:["operation","at least times"]},{module:Ao.treasury,query_name:"Operation at Least Times by a Signer",query_id:1427,parameters:[No.TYPE_U8,No.TYPE_ADDRESS,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does it operate at least a certain number of times by a signer?",parameters_description:["operation","signer address","at least times"]},{module:Ao.arbitration,query_name:"Permission",query_id:1500,parameters:[],return:No.TYPE_ADDRESS,description:"Permission object address."},{module:Ao.arbitration,query_name:"Paused",query_id:1501,parameters:[],return:No.TYPE_BOOL,description:"Is it allowed to create Arb?"},{module:Ao.arbitration,query_name:"Fee",query_id:1502,parameters:[],return:No.TYPE_U64,description:"Cost of arbitration."},{module:Ao.arbitration,query_name:"Has Endpoint",query_id:1503,parameters:[],return:No.TYPE_BOOL,description:"Is the endpoint set?"},{module:Ao.arbitration,query_name:"Endpoint",query_id:1504,parameters:[],return:No.TYPE_STRING,description:"Endpoint url/ipfs."},{module:Ao.arbitration,query_name:"Has Customer Guard",query_id:1505,parameters:[],return:No.TYPE_BOOL,description:"Is there Guard set to apply for arbitration?"},{module:Ao.arbitration,query_name:"Customer Guard",query_id:1506,parameters:[],return:No.TYPE_ADDRESS,description:"Guard to apply for arbitration."},{module:Ao.arbitration,query_name:"Number of Voting Guard",query_id:1507,parameters:[],return:No.TYPE_U64,description:"Number of voting guards."},{module:Ao.arbitration,query_name:"Has Voting Guard",query_id:1508,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has the voting Guard added?",parameters_description:["guard address"]},{module:Ao.arbitration,query_name:"Voting Weight",query_id:1509,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"Voting weight of the voting Guard.",parameters_description:["guard address"]},{module:Ao.arbitration,query_name:"Treasury",query_id:1510,parameters:[],return:No.TYPE_ADDRESS,description:"The address of the Treasury where fees was collected at the time of withdrawal."},{module:Ao.arb,query_name:"Order",query_id:1600,parameters:[],return:No.TYPE_ADDRESS,description:"Order under arbitration."},{module:Ao.arb,query_name:"Arbitration",query_id:1601,parameters:[],return:No.TYPE_ADDRESS,description:"Arbitration object address."},{module:Ao.arb,query_name:"Feedback",query_id:1602,parameters:[],return:No.TYPE_STRING,description:"Arbitration feedback."},{module:Ao.arb,query_name:"Has Compensation",query_id:1603,parameters:[],return:No.TYPE_BOOL,description:"Whether there is an arbitration result?"},{module:Ao.arb,query_name:"Compensation",query_id:1604,parameters:[],return:No.TYPE_U64,description:"Compensation should be given to the order payer."},{module:Ao.arb,query_name:"Unclaimed Arbitration Costs",query_id:1605,parameters:[],return:No.TYPE_U64,description:"Unclaimed arbitration costs."},{module:Ao.arb,query_name:"Turnout",query_id:1606,parameters:[],return:No.TYPE_U64,description:"The number of addresses have voted."},{module:Ao.arb,query_name:"Has voted",query_id:1607,parameters:[No.TYPE_ADDRESS],return:No.TYPE_BOOL,description:"Has someone voted?",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting weight",query_id:1608,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The weight of a complete vote for the address.",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting Time",query_id:1609,parameters:[No.TYPE_ADDRESS],return:No.TYPE_U64,description:"The time of a complete vote for the address.",parameters_description:["voter address"]},{module:Ao.arb,query_name:"Voting Option",query_id:1610,parameters:[No.TYPE_ADDRESS,No.TYPE_U8],return:No.TYPE_BOOL,description:"Does an address complete voting for the option?",parameters_description:["voter address","option index"]},{module:Ao.arb,query_name:"Number of Options",query_id:1611,parameters:[],return:No.TYPE_U64,description:"Number of voting options."},{module:Ao.arb,query_name:"Number of Votes",query_id:1612,parameters:[No.TYPE_U8],return:No.TYPE_U64,description:"The number of votes received for an option.",parameters_description:["option index"]}];var rd;!function(e){e.txn="Txn Functions",e.number="Number Crunching",e.logic="Compare or Logic"}(rd||(rd={}));const sd=[{from:"type",name:"Txn Signer",value:Xo.TYPE_SIGNER,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"Txn Time",value:Xo.TYPE_CLOCK,group:rd.txn,return:No.TYPE_U64},{from:"type",name:"Guard Address",value:Xo.TYPE_GUARD,group:rd.txn,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber to Address",value:ko.TYPE_NUMBER_ADDRESS,group:rd.number,return:No.TYPE_ADDRESS},{from:"type",name:"PositiveNumber Add (+)",value:ko.TYPE_NUMBER_ADD,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Subtract (-)",value:ko.TYPE_NUMBER_SUBTRACT,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Multiply (*)",value:ko.TYPE_NUMBER_MULTIPLY,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Devide (/)",value:ko.TYPE_NUMBER_DEVIDE,group:rd.number,return:"number"},{from:"type",name:"PositiveNumber Mod (%)",value:ko.TYPE_NUMBER_MOD,group:rd.number,return:"number"}];class id{static MAX_INPUT_LENGTH=10240;txb;object;get_object(){return this.object}static From(e,t){let r=new id(e);return r.object=$o.TXB_OBJECT(e,t),r}constructor(e){this.txb=e,this.object=""}static New(e,t,r){r.IsReady()||Ba(Ca.InvalidParam,"launch maker"),io(t)||Ba(Ca.IsValidDesription);let s=r.get_input()[0],i=r.get_constant();(0==s.length||s.length>id.MAX_INPUT_LENGTH)&&Ba(Ca.InvalidParam,"launch input");let n=!0;i?.forEach(((e,t)=>{ad.IsValidIndentifier(t)||(n=!1),e.value&&e.bWitness&&(n=!1),void 0!==e.value||e.bWitness||(n=!1)})),n||Ba(Ca.InvalidParam,"launch constants");let a=new Uint8Array(s),o=new id(e);return o.object=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(t),e.pure.vector("u8",[].slice.call(a.reverse()))]}),i?.forEach(((t,r)=>{if(t.bWitness){const s=new Uint8Array(1);s.set([t.type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}else{const s=Io(t.value,t.type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(o.object),e.pure.u8(r),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(s)),e.pure.bool(!0)]})}})),o}launch(){return this.txb.moveCall({target:$o.Instance().guardFn("create"),arguments:[this.txb.object(this.object)]})}static everyone_guard(e){return e.moveCall({target:$o.Instance().guardFn("everyone_guard"),arguments:[]})}static QueryAddressIdentifiers(e,t,r){const s=new gs;s.moveCall({target:$o.Instance().guardFn("query_address_identifiers"),arguments:[s.object(e)]}),$o.Client().devInspectTransactionBlock({sender:r,transactionBlock:s}).then((e=>{if(e.results&&e.results[0]?.returnValues&&1!==e.results[0]?.returnValues?.length)return void t({err:"not match",txb:s,identifiers:[]});const r=Wa.getInstance().de("vector<u8>",Uint8Array.from(e.results[0].returnValues[0][0]));t({identifiers:r,txb:s})})).catch((e=>{console.log(e),t({err:e,txb:s,identifiers:[]})}))}static BoolCmd=td.filter((e=>e.return===No.TYPE_BOOL));static IsBoolCmd=e=>id.BoolCmd.some((t=>t.query_id==e));static CmdFilter=e=>td.filter((t=>t.return===e));static GetCmd=e=>td.find((t=>t.query_id==e));static GetCmdOption=e=>{const t=id.GetCmd(e);return t?{from:"query",name:t.query_name,value:t.query_id,group:Po(t.module),return:t.return}:t};static GetInputParams=e=>{const t=id.GetCmd(e);return t?t.parameters:[]};static GetModuleName=e=>{let t=id.GetCmd(e);return t?Po(t.module):""};static NumberOptions=()=>[...id.CmdFilter(No.TYPE_U8),...id.CmdFilter(No.TYPE_U64),...id.CmdFilter(No.TYPE_U128),...id.CmdFilter(No.TYPE_U256)].map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))).concat(id.Crunchings);static Signer=sd.find((e=>"Txn Signer"===e.name&&e.value===Xo.TYPE_SIGNER));static Time=sd.find((e=>"Txn Time"===e.name&&e.value===Xo.TYPE_CLOCK));static Guard=sd.find((e=>"Guard Address"===e.name&&e.value===Xo.TYPE_GUARD));static Logics=()=>Uo.map((e=>({from:"type",name:e[1],value:e[0],group:rd.logic,return:No.TYPE_BOOL})));static Crunchings=sd.filter((e=>e.value===ko.TYPE_NUMBER_ADD||e.value===ko.TYPE_NUMBER_SUBTRACT||e.value===ko.TYPE_NUMBER_MULTIPLY||e.value===ko.TYPE_NUMBER_DEVIDE||e.value===ko.TYPE_NUMBER_MOD||e.value===ko.TYPE_NUMBER_ADDRESS));static CommonOptions=e=>id.CmdFilter(e).map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return})));static AllOptions=()=>[...td.map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...sd];static StringOptions=()=>[...id.CmdFilter(No.TYPE_STRING)].map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return})));static BoolOptions=()=>[...id.BoolCmd.map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...id.Logics()];static AddressOptions=()=>[...td.filter((e=>e.return===No.TYPE_ADDRESS)).map((e=>({from:"query",name:e.query_name,value:e.query_id,group:Po(e.module),return:e.return}))),...sd.filter((e=>e.return===No.TYPE_ADDRESS))];static Options=e=>{if("number"===e)return id.NumberOptions();if("any"===e)return id.AllOptions();switch(e){case No.TYPE_BOOL:return id.BoolOptions();case No.TYPE_STRING:return id.StringOptions()}return id.CommonOptions(e)}}const nd=e=>lo(e)&&0!==e;class ad{data=[];type_validator=[];constant=new Map;static _witness_index=1;static _const_index=255;static GetWitnessIndex(){return this._witness_index>=this._const_index&&Ba(Ca.Fail,"too many witness"),ad._witness_index++}static getConstIndex(){return this._const_index<=this._witness_index&&Ba(Ca.Fail,"too many const"),ad._const_index--}static IsValidIndentifier=e=>!(!lo(e)||e<1);constructor(){}add_constant(e,t,r,s=!0){return void 0===r&&(r=void 0===t?ad.GetWitnessIndex():ad.getConstIndex()),this.constant.get(r)||(s&&void 0!==t&&(t=Wa.getInstance().ser(e,t)),this.constant.set(r,{type:e,value:void 0===t?void 0:t,bWitness:void 0===t})),r}add_param(e,t){switch(e){case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U64:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U8:case No.TYPE_VEC_U256:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(e,t)),this.type_validator.push(e);break;case No.TYPE_STRING:case No.TYPE_VEC_U8:t||Ba(Ca.InvalidParam,"param: "+e),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),"string"==typeof t?this.data.push(Wa.getInstance().ser(No.TYPE_STRING,t)):this.data.push(Wa.getInstance().ser(No.TYPE_VEC_U8,t)),this.type_validator.push(e);break;case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_ADDRESS);break;case Xo.TYPE_CLOCK:this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.type_validator.push(No.TYPE_U64);break;case Xo.TYPE_CONSTANT:nd(t)||Ba(Ca.IsValidGuardIdentifier,"add_param param:"+e);var r=this.constant.get(t);r||Ba(Ca.Fail,"identifier not in constant:"+t),this.type_validator.push(r.type),this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,t));break;default:Ba(Ca.InvalidParam,"add_param type:"+e)}return this}add_query(e,t,r){const s=td.filter((r=>r.module==e&&r.query_name==t));return 1!==s.length&&Ba(Ca.InvalidParam,"add_query2:"+t),this.add_query2(s[0].query_id,r)}add_query2(e,t){const r=td.findIndex((t=>t.query_id==e));-1==r&&Ba(Ca.InvalidParam,"query_id:"+e),"number"==typeof t?ad.IsValidIndentifier(t)||Ba(Ca.InvalidParam,"object_address_from:"+e):co(t)||Ba(Ca.InvalidParam,"object_address_from:"+e);let s=this.type_validator.length-td[r].parameters.length;s<0&&Ba(Ca.InvalidParam,"offset:"+e);let i=this.type_validator.slice(s);if(La(i,td[r].parameters)||Ba(Ca.Fail,"array_equal:"+e),this.data.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof t)this.data.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),this.data.push(Wa.getInstance().ser(No.TYPE_ADDRESS,t));else{let r=this.constant.get(t);r||Ba(Ca.Fail,"object_address_from not in constant:"+e),r?.type==No.TYPE_ADDRESS?(this.data.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),this.data.push(Wa.getInstance().ser(No.TYPE_U8,t))):Ba(Ca.Fail,"type bWitness not match:"+e)}return this.data.push(Wa.getInstance().ser("u16",td[r].query_id)),this.type_validator.splice(s,td[r].parameters.length),this.type_validator.push(td[r].return),this}add_logic(e,t=2){var r=Uo.find((t=>t[0]===e));r&&(r=r[1]);let s,i=2,n=No.TYPE_BOOL;switch(e){case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-e])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_EQUAL:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),s=this.type_validator[this.type_validator.length-1];for(let e=2;e<=i;++e)this.type_validator[this.type_validator.length-e]!==s&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_HAS_SUBSTRING:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!==No.TYPE_STRING&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_NOT:i=1,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),this.type_validator[this.type_validator.length-1]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADDRESS:i=1,n=No.TYPE_ADDRESS,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r),ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)this.type_validator[this.type_validator.length-e]!=No.TYPE_BOOL&&Ba(Ca.Fail,"type_validator check:"+r);break;case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_NUMBER_MOD:(!t||t<2)&&Ba(Ca.Fail,"logic param invalid:"+r),i=t,this.type_validator.length<i&&Ba(Ca.Fail,"type_validator.length:"+r);for(let e=1;e<=i;++e)ad.match_u256(this.type_validator[this.type_validator.length-1])||Ba(Ca.Fail,"type_validator check:"+r);n=No.TYPE_U256;break;default:Ba(Ca.InvalidParam,"add_logic type invalid:"+r)}return this.data.push(Wa.getInstance().ser(No.TYPE_U8,e)),ad.is_multi_input_op(e)&&this.data.push(Wa.getInstance().ser(No.TYPE_U8,t)),this.type_validator.splice(this.type_validator.length-i),this.type_validator.push(n),this}hasIdentifier(e){return this.constant.has(e)}build(e=!1){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL||Ba(Ca.Fail,"type_validator check"),e&&this.add_logic(ko.TYPE_LOGIC_NOT),this.data.push(Xa(Uint8Array,...this.data)),this.data.splice(0,this.data.length-1),this}IsReady(){return 1==this.type_validator.length&&this.type_validator[0]==No.TYPE_BOOL&&1==this.data.length}combine(e,t=!0,r=!1){e.IsReady()&&this.IsReady()||Ba(Ca.Fail,"both should built yet");let s=new ad;this.constant.forEach(((e,t)=>{s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})})),e.constant.forEach(((e,t)=>{s.constant.has(t)&&!r&&Ba(Ca.Fail,"constant identifier exist"),s.constant.set(t,{type:e.type,value:e.value,bWitness:e.bWitness})}));let i=t?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return s.data.push(Xa(Uint8Array,...this.data,...e.data,Wa.getInstance().ser(No.TYPE_U8,i),Wa.getInstance().ser(No.TYPE_U8,2))),this.data.splice(0,this.data.length-1),s.type_validator=this.type_validator,s}get_constant(){return this.constant}get_input(){return this.data}static input_combine(e,t,r=!0){let s=r?ko.TYPE_LOGIC_AND:ko.TYPE_LOGIC_OR;return Xa(Uint8Array,e,t,Wa.getInstance().ser(No.TYPE_U8,s),Wa.getInstance().ser(No.TYPE_U8,2))}static input_not(e){return Xa(Uint8Array,e,Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_LOGIC_NOT))}static match_u256(e){return e==No.TYPE_U8||e==No.TYPE_U64||e==No.TYPE_U128||e==No.TYPE_U256}static is_multi_input_op(e){return e===ko.TYPE_LOGIC_AS_U256_GREATER||e===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER||e===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||e===ko.TYPE_LOGIC_AS_U256_EQUAL||e===ko.TYPE_LOGIC_EQUAL||e===ko.TYPE_LOGIC_HAS_SUBSTRING||e===ko.TYPE_LOGIC_AND||e===ko.TYPE_LOGIC_OR||e===ko.TYPE_NUMBER_ADD||e===ko.TYPE_NUMBER_DEVIDE||e===ko.TYPE_NUMBER_MULTIPLY||e===ko.TYPE_NUMBER_SUBTRACT||e===ko.TYPE_NUMBER_MOD}}var od,dd,cd,ud,hd,pd,ld;!function(e){e[e.POLICY_MODE_FREE=0]="POLICY_MODE_FREE",e[e.POLICY_MODE_STRICT=1]="POLICY_MODE_STRICT"}(od||(od={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.WOWOK_GRANTEE=1]="WOWOK_GRANTEE",e[e.WOWOK_ORACLE=2]="WOWOK_ORACLE"}(dd||(dd={}));class md{permission;object;txb;get_object(){return this.object}constructor(e,t){this.txb=e,this.permission=t,this.object=""}static From(e,t,r){let s=new md(e,t);return s.object=$o.TXB_OBJECT(e,r),s}static New(e,t,r,s=od.POLICY_MODE_FREE,i){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"permission"),io(r)||Ba(Ca.IsValidDesription);let n=new md(e,t);return n.object=i?e.moveCall({target:$o.Instance().repositoryFn("new_with_passport"),arguments:[i,e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}):e.moveCall({target:$o.Instance().repositoryFn("new"),arguments:[e.pure.string(r),e.pure.u8(s),$o.TXB_OBJECT(e,t)]}),n}launch(){return this.txb.moveCall({target:$o.Instance().repositoryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}add_data(e){md.IsValidName(e.key)||Ba(Ca.IsValidName,"add_data");let t=!0;e.data.forEach((e=>{co(e.address)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(t.address),this.txb.pure.string(e.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}add_data2(e){co(e.address)||Ba(Ca.IsValidAddress,"add_data2");let t=!0;e.data.forEach((e=>{md.IsValidName(e.key)||(t=!1),md.IsValidValue(e.bcsBytes)||(t=!1)})),t||Ba(Ca.InvalidParam,"add_data2"),void 0!==e?.value_type?e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.u8(e.value_type),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]}))):e.data.forEach((t=>this.txb.moveCall({target:$o.Instance().repositoryFn("add_typed_data"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e.address),this.txb.pure.string(t.key),this.txb.pure.vector("u8",[...t.bcsBytes]),$o.TXB_OBJECT(this.txb,this.permission)]})))}remove(e,t){md.IsValidName(t)||Ba(Ca.IsValidName),co(e)||Ba(Ca.IsValidAddress),this.txb.moveCall({target:$o.Instance().repositoryFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}add_reference(e,t){0!==e.length&&(To(e,co)||Ba(Ca.IsValidArray,"add_reference"),t?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}remove_reference(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_reference"),t?r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):r?this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("reference_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}add_policies(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{io(e.description)&&md.IsValidName(e.key)||(r=!1)})),r||Ba(Ca.InvalidParam,"policies"),e.forEach((e=>{let r=this.txb.pure.option("u64",e?.permissionIndex?e?.permissionIndex:void 0);t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.key),this.txb.pure.string(e.description),r,this.txb.pure.u8(e.dataType),$o.TXB_OBJECT(this.txb,this.permission)]})}))}remove_policies(e,t,r){0!==e.length&&(To(e,md.IsValidName)||Ba(Ca.InvalidParam,"policy_keys"),r?t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}):t?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)]}))}rename_policy(e,t,r){no(e)&&no(t)||Ba(Ca.IsValidName,"change_policy"),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_rename"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().repositoryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_mode(e,t){t?this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_description(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy"),io(t)||Ba(Ca.IsValidDesription),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.string(t),$o.TXB_OBJECT(this.txb,this.permission)]})}set_policy_permission(e,t,r){md.IsValidName(e)||Ba(Ca.IsValidName,"policy");let s=this.txb.pure.option("u64",void 0);void 0!==t&&(Qo.IsValidPermissionIndex(t)||Ba(Ca.IsValidPermissionIndex),s=this.txb.pure.option("u64",t)),r?this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]}):this.txb.moveCall({target:$o.Instance().repositoryFn("policy_permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),s,$o.TXB_OBJECT(this.txb,this.permission)]})}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().repositoryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[]}),this.permission=e}static MAX_POLICY_COUNT=120;static MAX_KEY_LENGTH=128;static MAX_VALUE_LENGTH=204800;static MAX_REFERENCE_COUNT=100;static IsValidName=e=>e.length<=md.MAX_KEY_LENGTH&&0!=e.length;static IsValidValue=e=>e.length<md.MAX_VALUE_LENGTH;static rpc_de_data(e){const t=e?.map((e=>{const t=new Uint8Array(e?.data?.content?.fields?.value),r=t?.length>0?t[0]:null;var s=t.length>0?t.slice(1):Uint8Array.from([]);return r===No.TYPE_STRING?(s=Wa.getInstance().de(No.TYPE_VEC_U8,s),s=(new TextDecoder).decode(Uint8Array.from(s))):r===No.TYPE_VEC_STRING?s=(s=Wa.getInstance().de(No.TYPE_VEC_VEC_U8,s)).map((e=>(new TextDecoder).decode(Uint8Array.from(e)))):(s=Wa.getInstance().de(t[0],s),r===No.TYPE_ADDRESS?s="0x"+s:r===No.TYPE_VEC_ADDRESS?s=s.map((e=>"0x"+e)):r===No.TYPE_BOOL&&(s=s?"True":"False")),{object:e?.data?.content?.fields?.id?.id,id:e?.data?.content?.fields?.name?.fields?.id,name:e?.data?.content?.fields?.name?.fields?.key,data:s,dataType:Ua(r)}}));return t}static DataType2ValueType(e){try{const t=BigInt(e);if(No.TYPE_U8,t<=Sa);else if(t<=Pa)No.TYPE_U64;else if(t<=ja)No.TYPE_U128;else{if(!(t<=Aa))return;No.TYPE_U256}}catch(e){console.log(e)}}static ResolveRepositoryData=(e,t)=>{if(e===Do.String)return{type:No.TYPE_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_U8,(new TextEncoder).encode(t.toString()))};if(e===Do.PositiveNumber){const e=md.DataType2ValueType(t);if(!e)return;return{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.Address){if(!co(t))return;return{type:No.TYPE_ADDRESS,data:Wa.getInstance().ser(No.TYPE_ADDRESS,t)}}if(e===Do.Address_Vec){for(let e=0;e<t.length;++e)if(!co(t[e]))return;return{type:No.TYPE_VEC_ADDRESS,data:Wa.getInstance().ser(No.TYPE_VEC_ADDRESS,t)}}if(e===Do.PositiveNumber_Vec){let e=No.TYPE_U8;for(let r=0;r<t.length;++r){const r=md.DataType2ValueType(t);if(!r)return;r>e&&(e=r)}return e=e===No.TYPE_U8?No.TYPE_VEC_U8:e===No.TYPE_U64?No.TYPE_VEC_U64:e===No.TYPE_U128?No.TYPE_VEC_U128:No.TYPE_VEC_U256,{type:e,data:Wa.getInstance().ser(e,t)}}if(e===Do.String_Vec){const e=t.map((e=>(new TextEncoder).encode(e)));return{type:No.TYPE_VEC_STRING,data:Wa.getInstance().ser(No.TYPE_VEC_VEC_U8,e)}}if(e===Do.Bool){if("boolean"!=typeof t)return;return{type:No.TYPE_BOOL,data:Wa.getInstance().ser(No.TYPE_BOOL,t)}}}}class _d{guard_list=[];guards;constructor(e){this.guards=e}guardlist=()=>this.guard_list;static DeGuardObject_FromData=(e,t)=>{let r=_d.parse_constant(e),s=_d.parse_bcs(r,t);s&&0!=s.length||Ba(Ca.Fail,"GuardObject: data parsed error");let i=[];return s.forEach((e=>{_d.ResolveData(r,i,{...e,child:[]})})),1!=i.length&&Ba(Ca.Fail,"GuardObject: parse error"),{object:i.pop(),constant:r}};static DeGuardObject=async(e,t)=>{co(t)||Ba(Ca.IsValidAddress,"GuardObject guard");let r=await e.query_raw([t]);0!=r.length&&r[0].data&&r[0].data?.objectId==t||Ba(Ca.Fail,"GuardObject query error");let s=r[0].data.content;return s?.type!=e.package("base")+"::guard::Guard"&&Ba(Ca.Fail,"GuardObject object invalid"),_d.DeGuardObject_FromData(s.fields.constants,s.fields.input.fields.bytes)};static ResolveData=(e,t,r)=>{switch(r.type){case ko.TYPE_LOGIC_NOT:return r.ret_type=No.TYPE_BOOL,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT"),(s=t.pop()).ret_type&&s.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: TYPE_LOGIC_NOT type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_NUMBER_ADDRESS:var s;return r.ret_type=No.TYPE_ADDRESS,t.length<1&&Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS"),(s=t.pop()).ret_type&&ad.match_u256(s.ret_type)||Ba(Ca.Fail,"ResolveData: TYPE_NUMBER_ADDRESS type invalid"),r.child.push(s),void t.push(r);case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:r.type===ko.TYPE_LOGIC_AS_U256_GREATER||r.type===ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_LESSER||r.type===ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL||r.type===ko.TYPE_LOGIC_AS_U256_EQUAL?r.ret_type=No.TYPE_BOOL:r.ret_type=No.TYPE_U256,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&ad.match_u256(n.ret_type)||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_EQUAL:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);var i=t.pop();r.child.push(i);for(let e=1;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==i.ret_type||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_HAS_SUBSTRING:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e)(n=t.pop()).ret_type&&n.ret_type==No.TYPE_STRING||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n);return void t.push(r);case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:r.ret_type=No.TYPE_BOOL,(t.length<r.value||r.value<2)&&Ba(Ca.Fail,"ResolveData: "+r.type);for(let e=0;e<r.value;++e){var n;(n=t.pop()).ret_type&&n.ret_type==No.TYPE_BOOL||Ba(Ca.Fail,"ResolveData: "+r.type+" INVALID param type"),r.child.push(n)}return void t.push(r);case ko.TYPE_QUERY:r?.cmd||Ba(Ca.Fail,"OperateParamCount: cmd invalid "+r.type);let a=id.GetCmd(r.cmd);return a||Ba(Ca.Fail,"OperateParamCount: cmd not supported "+r.type),r.ret_type=a?.return,t.length<a.parameters.length&&Ba(Ca.Fail,"OperateParamCount: cmd param lost "+r.type),a.parameters.forEach((e=>{let s=t.pop();s?.ret_type&&s.ret_type==e||Ba(Ca.Fail,"OperateParamCount: cmd param not match "+r.type),r.child.push(s)})),void t.push(r);case No.TYPE_ADDRESS:case No.TYPE_BOOL:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_U64:case No.TYPE_U8:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_U128:case No.TYPE_VEC_U256:case No.TYPE_VEC_U64:case No.TYPE_VEC_U8:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U256:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U8:case No.TYPE_STRING:return r.ret_type=r.type,void t.push(r);case Xo.TYPE_CLOCK:return r.ret_type=No.TYPE_U64,void t.push(r);case Xo.TYPE_SIGNER:case Xo.TYPE_GUARD:return r.ret_type=No.TYPE_ADDRESS,void t.push(r);case Xo.TYPE_CONSTANT:let o=e.find((e=>e.identifier==r?.identifier));return o||Ba(Ca.Fail,"OperateParamCount: identifier invalid "+r.type),r.ret_type=o?.type,void t.push(r)}Ba(Ca.Fail,"OperateParamCount: type invalid "+r.type)};static Parse_Guard_Helper(e,t){const r=$o.Instance(),s=new _d(e);return t.forEach((e=>{const t=e.data?.content;if(t||Ba(Ca.Fail,"Parse_Guard_Helper invalid content"),-1===r.WOWOK_OBJECTS_TYPE().findIndex((e=>e.includes("guard::Guard")&&e==t.type))&&Ba(Ca.Fail,"Parse_Guard_Helper invalid type: "+t.type),t.fields.input.type===r.package("base")+"::bcs::BCS"){const r=_d.parse_constant(t.fields.constants),i=_d.parse_bcs(r,Uint8Array.from(t.fields.input.fields.bytes));s.guard_list.push({id:t.fields.id.id,input:[...i],constant:[...r],digest:e.data?.digest??"",version:e.data?.version??""})}else Ba(Ca.Fail,"Parse_Guard_Helper invalid package: "+t.fields.input.type)})),s}static Create=async(e,t)=>{if(!To(e,co))return void(t&&t(void 0));let r=Ga(e);if(!t){const t=await $o.Instance().query_raw(r);return _d.Parse_Guard_Helper(e,t)}$o.Instance().query_raw(r).then((r=>{t(_d.Parse_Guard_Helper(e,r))})).catch((e=>{console.log(e),t(void 0)}))};future_fills=()=>{const e=[];return this.guard_list.forEach((t=>{t.constant.filter((e=>e.bWitness)).forEach((r=>{const s=t.input.filter((e=>e.identifier===r.identifier&&void 0!==e.cmd)).map((e=>e.cmd));let i=0;t.input.forEach((e=>{e.identifier===r.identifier&&i++})),e.push({guard:t.id,witness:void 0,identifier:r.identifier,type:r.type,cmd:s??[],cited:i})}))})),e};static parse_constant=e=>{let t=[];return e.forEach((e=>{let r=e?.fields??e;const s=Uint8Array.from(r.value),i=s.slice(0,1)[0];if(r.bWitness)t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:void 0});else{var n=s.slice(1);switch(i){case No.TYPE_ADDRESS:n="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(n)).toString();break;case No.TYPE_BOOL:case No.TYPE_U8:case No.TYPE_U64:case No.TYPE_U128:case No.TYPE_U256:case No.TYPE_VEC_U8:case No.TYPE_VEC_U64:case No.TYPE_VEC_U128:case No.TYPE_VEC_ADDRESS:case No.TYPE_VEC_BOOL:case No.TYPE_VEC_VEC_U8:case No.TYPE_OPTION_ADDRESS:case No.TYPE_OPTION_BOOL:case No.TYPE_OPTION_U128:case No.TYPE_OPTION_U8:case No.TYPE_OPTION_U64:case No.TYPE_OPTION_U256:case No.TYPE_VEC_U256:case No.TYPE_STRING:case No.TYPE_OPTION_STRING:case No.TYPE_OPTION_VEC_U8:case No.TYPE_VEC_STRING:qo.find((e=>e.type==i))||Ba(Ca.Fail,"GuardObject de error"),n=Wa.getInstance().de(i,Uint8Array.from(n));break;default:Ba(Ca.Fail,"GuardObject constant type invalid:"+i)}t.push({identifier:r.identifier,type:i,bWitness:r.bWitness,value:n})}})),t};static parse_bcs=(e,t)=>{let r=Uint8Array.from(t),s=[].slice.call(r.reverse()),i=[];for(;s.length>0;){let t,r,n,a=s.shift();switch(a){case Xo.TYPE_SIGNER:case Xo.TYPE_CLOCK:case Xo.TYPE_GUARD:case ko.TYPE_LOGIC_NOT:case ko.TYPE_NUMBER_ADDRESS:break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:case ko.TYPE_LOGIC_EQUAL:case ko.TYPE_LOGIC_HAS_SUBSTRING:case ko.TYPE_NUMBER_ADD:case ko.TYPE_NUMBER_DEVIDE:case ko.TYPE_NUMBER_MOD:case ko.TYPE_NUMBER_MULTIPLY:case ko.TYPE_NUMBER_SUBTRACT:case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:t=s.shift();break;case Xo.TYPE_CONSTANT:n=s.shift();break;case No.TYPE_ADDRESS:t="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString(),s.splice(0,32);break;case No.TYPE_BOOL:case No.TYPE_U8:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.shift();break;case No.TYPE_U64:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8);break;case No.TYPE_U128:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16);break;case No.TYPE_U256:t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32);break;case No.TYPE_VEC_U8:case No.TYPE_VEC_BOOL:case No.TYPE_STRING:let i=Ra(Uint8Array.from(s));t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,i.value+i.length);break;case No.TYPE_VEC_ADDRESS:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U128:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,16*i.value+i.length);break;case No.TYPE_VEC_U256:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,32*i.value+i.length);break;case No.TYPE_VEC_U64:i=Ra(Uint8Array.from(s)),t=Wa.getInstance().de(a,Uint8Array.from(s)),s.splice(0,8*i.value+i.length);break;case No.TYPE_VEC_VEC_U8:case No.TYPE_VEC_STRING:i=Ra(Uint8Array.from(s)),s.splice(0,i.length);let o=[];for(let e=0;e<i.value;e++){let e=Ra(Uint8Array.from(s));o.push(Wa.getInstance().de(No.TYPE_VEC_U8,Uint8Array.from(s))),s.splice(0,e.length+e.value)}t=o;break;case ko.TYPE_QUERY:let d=s.splice(0,1);if(d[0]==No.TYPE_ADDRESS){let e="0x"+Wa.getInstance().de(No.TYPE_ADDRESS,Uint8Array.from(s)).toString();s.splice(0,32),t=e,r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else if(d[0]==Xo.TYPE_CONSTANT){let t=s.splice(0,1);e.find((e=>e.identifier==t[0]&&e.type==No.TYPE_ADDRESS))||Ba(Ca.Fail,"GuardObject: indentifier not in constant"),n=t[0],r=Wa.getInstance().de("u16",Uint8Array.from(s.splice(0,2)))}else Ba(Ca.Fail,"GuardObject: constant type invalid");break;case No.TYPE_OPTION_ADDRESS:let c=Na(s,No.TYPE_ADDRESS);t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_BOOL:c=Na(s,No.TYPE_BOOL),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U8:c=Na(s,No.TYPE_U8),t=c.value,c.bNone||s.splice(0,1);break;case No.TYPE_OPTION_U128:c=Na(s,No.TYPE_U128),t=c.value,c.bNone||s.splice(0,16);break;case No.TYPE_OPTION_U256:c=Na(s,No.TYPE_U256),t=c.value,c.bNone||s.splice(0,32);break;case No.TYPE_OPTION_U64:c=Na(s,No.TYPE_U64),t=c.value,c.bNone||s.splice(0,8);break;case No.TYPE_OPTION_STRING:c=Da(s),t=c.value;break;default:Ba(Ca.Fail,"GuardObject: parse_bcs types "+a)}i.push({type:a,value:t,cmd:r,identifier:n})}return i};done=async(e,t)=>{let r=[];if(this.guard_list.forEach((t=>{t.constant.forEach((t=>{if(t.bWitness){const r=e?.find((e=>e.identifier===t.identifier));r?t.value=r.witness:Ba(Ca.Fail,"done: invalid witness "+t.identifier)}})),t.input.filter((e=>void 0!==e.cmd)).forEach((e=>{if(void 0!==e.identifier){const s=t.constant.find((t=>t.identifier===e.identifier&&t.type===No.TYPE_ADDRESS));s&&co(s.value)||Ba(Ca.Fail,"done: invalid identifier "+e.identifier),r.push(s.value)}else r.push(e.value)}))})),t)return 0===r.length?void t(this.done_helper([])):void $o.Instance().query_raw(Ga(r),{showType:!0}).then((e=>{t(this.done_helper(e))})).catch((e=>{console.log(e),t(void 0)}));{let e=[];return r.length>0&&(e=await $o.Instance().query_raw(Ga(r),{showType:!0})),this.done_helper(e)}};done_helper(e){let t=[],r=[];return this.guard_list.forEach((s=>{r.push(s.id),s.input.filter((e=>void 0!==e.cmd)).forEach((r=>{let i=r.value;i||void 0===r.identifier||(i=s.constant.find((e=>e.identifier==r.identifier))?.value);let n=e.find((e=>e.data?.objectId==i));n||Ba(Ca.Fail,"query object not match");let a=this.object_query(n.data);a||Ba(Ca.Fail,"query object fail"),t.push(a)}))})),{query:t,info:this.guard_list}}object_query=(e,t="guard_query")=>{for(let r=0;r<$o.Instance().WOWOK_OBJECTS_TYPE().length;r++)if(e.type.includes($o.Instance().WOWOK_OBJECTS_TYPE()[r]))return{target:$o.Instance().WOWOK_OBJECTS_PREFIX_TYPE()[r]+t,object:ct({objectId:e.objectId,mutable:!1,initialSharedVersion:e.version}),types:za(e.type),id:e.objectId}}}class bd{static MAX_GUARD_COUNT=8;passport;txb;get_object(){return this.passport}constructor(e,t,r=!1){(0===t.info.length||t.info.length>bd.MAX_GUARD_COUNT)&&Ba(Ca.InvalidParam,"guards"),this.txb=e,this.passport=this.txb.moveCall({target:$o.Instance().passportFn("new"),arguments:[]}),t.info.forEach((t=>{const r=t.constant.filter((e=>e.bWitness)).map((e=>e.identifier)),s=t.constant.filter((e=>e.bWitness)).map((e=>{const t=Wa.getInstance().ser(e.type,e.value);let r=new Uint8Array(t.length+1);return r.set([e.type],0),r.set(t,1),[].slice.call(r)})),i=void 0!==t.version&&void 0!==t.digest?e.objectRef({objectId:t.id,version:t.version,digest:t.digest}):e.object(t.id);this.txb.moveCall({target:$o.Instance().passportFn("guard_add"),arguments:[this.passport,i,this.txb.pure.vector("u8",[].slice.call(r)),this.txb.pure(Wa.getInstance().ser("vector<vector<u8>>",[...s]))]})}));const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?.query.forEach((e=>{this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]}),this.txb.moveCall({target:e.target,arguments:[r?this.txb.object(e.object):this.txb.object(e.id),this.passport],typeArguments:e.types})})),this.txb.moveCall({target:$o.Instance().passportFn("passport_verify"),arguments:[this.passport,this.txb.object(s)]})}destroy(){this.txb.moveCall({target:$o.Instance().passportFn("destroy"),arguments:[this.passport]})}freeze(){this.txb.moveCall({target:$o.Instance().passportFn("freezen"),arguments:[this.passport]})}query_result(e,t){this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]}),$o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb}).then((e=>{const r=bd.ResolveQueryRes(this.txb,e);r&&t(r)})).catch((e=>{console.log(e)}))}query_result_async=async e=>{this.txb.moveCall({target:$o.Instance().passportFn("query_result"),arguments:[this.passport]});const t=await $o.Client().devInspectTransactionBlock({sender:e,transactionBlock:this.txb});return bd.ResolveQueryRes(this.txb,t)};static ResolveQueryRes(e,t){for(let r=0;r<t.results?.length;++r){const s=t.results[r];if(s?.returnValues&&2===s.returnValues.length&&"bool"===s.returnValues[0][1]&&"vector<address>"===s.returnValues[1][1])return{txb:e,result:Wa.getInstance().de("bool",Uint8Array.from(s.returnValues[0][0])),guards:Wa.getInstance().de("vector<address>",Uint8Array.from(s.returnValues[1][0])).map((e=>"0x"+e))}}}}!function(e){e[e.ratio=0]="ratio",e[e.minus=1]="minus"}(cd||(cd={})),function(e){e.address="address",e.phone="phone",e.name="name",e.postcode="postcode"}(ud||(ud={}));class gd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new gd(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n){$o.IsValidObjects([r,i])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New: pay_token_type"),io(s)||Ba(Ca.IsValidDesription);let a=t,o=new gd(e,a,r);return o.object=n?e.moveCall({target:$o.Instance().serviceFn("new_with_passport"),arguments:[n,e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}):e.moveCall({target:$o.Instance().serviceFn("new"),arguments:[e.pure.string(s),e.object(i),$o.TXB_OBJECT(e,r)],typeArguments:[a]}),o}launch(){return this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription),t?this.txb.moveCall({target:$o.Instance().serviceFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_price(e,t,r=!0,s){mo(t)||Ba(Ca.IsValidU64,"set_price price"),gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_price item"),s?this.txb.moveCall({target:$o.Instance().serviceFn("price_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("price_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"item"),mo(t)||Ba(Ca.IsValidU64,"stock"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"add_stock item"),mo(t)||Ba(Ca.IsValidUint,"add_stock stock_add"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_add_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}reduce_stock(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"reduce_stock item"),mo(t)||Ba(Ca.IsValidUint,"reduce_stock stock_reduce"),s?this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("stock_reduce"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.pure.u64(t),this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_sale_endpoint(e,t,r=!0,s){gd.IsValidItemName(e)||Ba(Ca.IsValidServiceItemName,"set_sale_endpoint item"),t&&!oo(t)&&Ba(Ca.IsValidEndpoint,"set_sale_endpoint endpoint");let i=this.txb.pure.option("string",t||void 0);s?this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set_with_passport"),arguments:[s,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sale_endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),i,this.txb.pure.bool(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_payee(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_payee"),t?this.txb.moveCall({target:$o.Instance().serviceFn("payee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("payee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_repository(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"repository_add"),t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_add_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_repository(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"repository_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("repository_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_arbitration(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"add_arbitration.arbitraion"),go(t)||Ba(Ca.IsValidTokenType,"add_arbitration.arbitraion_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,t]})}remove_arbitration(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_arbitration.address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("arbitration_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_withdraw_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_withdraw_guards(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}add_refund_guards(e,t){if(0===e.length)return;let r=!0;e.forEach((e=>{$o.IsValidObjects([e.guard])||(r=!1),vo(e.percent)||(r=!1)})),r||Ba(Ca.InvalidParam,"guards"),e.forEach((e=>{t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.guard),this.txb.pure.u8(e.percent),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}))}remove_refund_guards(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.InvalidParam,"guard_address"),r?t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}is_valid_sale(e){let t=!0,r=[];return e.forEach((e=>{gd.IsValidItemName(e.item)||(t=!1),mo(e.price)||(t=!1),mo(e.stock)||(t=!1),r.includes(e.item)&&(t=!1),r.push(e.item)})),t}add_sales(e,t=!1,r){if(0===e.length)return;this.is_valid_sale(e)||Ba(Ca.InvalidParam,"add_sales");let s=[],i=[],n=[],a=[];e.forEach((e=>{e.endpoint&&!oo(e.endpoint)&&Ba(Ca.IsValidEndpoint,"add_sales"),s.push(e.item),i.push(e.price),n.push(e.stock),a.push(e.endpoint??"")})),r?this.txb.moveCall({target:$o.Instance().serviceFn("sales_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.vector("string",a),this.txb.pure.vector("u64",i),this.txb.pure.vector("u64",n),this.txb.pure.bool(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_sales(e,t){0!==e.length&&(To(e,gd.IsValidItemName)||Ba(Ca.IsValidArray,"remove_sales"),t?this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("sales_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",Ga(e)),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}discount_transfer(e,t){(!e||e.length>gd.MAX_DISCOUNT_RECEIVER_COUNT)&&Ba(Ca.InvalidParam,"discount_dispatch");let r=!0;e.forEach((e=>{co(e.receiver)||(r=!1),(!mo(e.count)||e.count>gd.MAX_DISCOUNT_COUNT_ONCE)&&(r=!1),ao(e.discount.name)||(r=!1),e.discount.type!=cd.ratio||vo(e.discount.off)||(r=!1),mo(e.discount.duration_minutes)||(r=!1),e.discount?.time_start&&!mo(e.discount.time_start)&&(r=!1),e.discount?.price_greater&&!mo(e.discount.price_greater)&&(r=!1)})),r||Ba(Ca.InvalidParam,"discount_dispatch");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);e.forEach((e=>{let r=this.txb.pure.option("u64",e.discount?.price_greater?e.discount?.price_greater:void 0),i=this.txb.pure.option("u64",e.discount?.time_start?e.discount?.time_start:void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("dicscount_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e.discount.name),this.txb.pure.u8(e.discount.type),this.txb.pure.u64(e.discount.off),r,i,this.txb.pure.u64(e.discount.duration_minutes),this.txb.pure.u64(e.count),$o.TXB_OBJECT(this.txb,this.permission),this.txb.pure.address(e.receiver),this.txb.object(s)],typeArguments:[this.pay_token_type]})}))}withdraw(e,t,r){$o.IsValidObjects([e,t.treasury,t.withdraw_guard,r])||Ba(Ca.IsValidObjects),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t.for_guard?this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t.withdraw_guard),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_buy_guard(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_machine(e,t){t?e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().serviceFn("machine_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("machine_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint);let r=this.txb.pure.option("string",e||void 0);t?this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}publish(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("publish_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("publish"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}clone(e,t,r){let s;return s=r?this.txb.moveCall({target:$o.Instance().serviceFn("clone_withpassport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("clone"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e||this.pay_token_type]}),t?this.txb.moveCall({target:$o.Instance().serviceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,s)],typeArguments:[e||this.pay_token_type]}):s}set_customer_required(e,t,r){t.length>0&&!e&&Ba(Ca.InvalidParam,"set_customer_required"),e.length>gd.MAX_PUBKEY_SIZE&&Ba(Ca.InvalidParam,"set_customer_required.pubkey"),t.length>gd.MAX_REQUIRES_COUNT&&Ba(Ca.InvalidParam,"set_customer_required.customer_required"),To(t,no)||Ba(Ca.IsValidArray,"set_customer_required.customer_required");let s=Ga(t);r?this.txb.moveCall({target:$o.Instance().serviceFn("required_set_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",s),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}remove_customer_required(e){e?this.txb.moveCall({target:$o.Instance().serviceFn("required_none_with_passport"),arguments:[e,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}change_required_pubkey(e,t){e||Ba(Ca.InvalidParam,"pubkey"),t?this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("required_pubkey_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().serviceFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}refund_withArb(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"refund_withArb.order or arb"),go(r)||Ba(Ca.IsValidTokenType,"refund_withArb.arb_type");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_arb"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),this.txb.object(s)],typeArguments:[this.pay_token_type,r]})}refund(e,t,r){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"refund.order"),t&&!$o.IsValidObjects([t])&&Ba(Ca.IsValidObjects,"refund.refund_guard"),r&&!t&&Ba(Ca.InvalidParam,"refund.passport need refund_guard");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);r&&t?this.txb.moveCall({target:$o.Instance().serviceFn("refund_with_passport"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.object(t),r,this.txb.object(s)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("refund"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}update_order_required_info(e,t){t.customer_pubkey&&0!==t.customer_info_crypt.length&&($o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"update_order_required_info.order"),this.txb.moveCall({target:$o.Instance().serviceFn("order_required_info_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),this.txb.pure.string(t.customer_pubkey),this.txb.pure.string(t.customer_info_crypt)],typeArguments:[this.pay_token_type]}))}order(e,t,r,s,i,n){0===e.length&&Ba(Ca.InvalidParam,"order.buy_items empty");let a=!0,o=[];e.forEach((e=>{gd.IsValidItemName(e.item)||(a=!1),mo(e.max_price)||(a=!1),mo(e.count)||(a=!1),o.includes(e.item)&&(a=!1),o.push(e.item)})),a||Ba(Ca.InvalidParam,"buy_items invalid");let d,c=[],u=[],h=[];e.forEach((e=>{c.push(e.item),u.push(BigInt(e.max_price)),h.push(BigInt(e.count))}));const p=this.txb.sharedObjectRef($o.CLOCK_OBJECT);d=n?r?this.txb.moveCall({target:$o.Instance().serviceFn("dicount_buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(p)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy_with_passport"),arguments:[n,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}):r?this.txb.moveCall({target:$o.Instance().serviceFn("disoucnt_buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t),$o.TXB_OBJECT(this.txb,r),this.txb.object(p)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("buy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("string",c),this.txb.pure.vector("u64",u),this.txb.pure.vector("u64",h),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]}),i&&this.update_order_required_info(d,i);var l=void 0;return s&&(l=this.order_bind_machine(d,s)),{order:d,progress:l}}order_launch(e){var t;return e.progress&&(t=this.txb.moveCall({target:$o.Instance().progressFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e.progress)]})),{order:this.txb.moveCall({target:$o.Instance().serviceFn("order_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.order)],typeArguments:[this.pay_token_type]}),progress:t}}buy(e,t,r,s,i,n){const a=this.order(e,t,r,s,i,n);return this.order_launch(a)}order_bind_machine(e,t){return $o.IsValidObjects([e,t])||Ba(Ca.IsValidObjects,"order & machine"),this.txb.moveCall({target:$o.Instance().serviceFn("order_bind_machine"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e),$o.TXB_OBJECT(this.txb,t)],typeArguments:[this.pay_token_type]})}add_treasury(e,t,r){$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"add_treasury.treasury"),go(e)||Ba(Ca.IsValidTokenType,"add_treasury.treasury_token_type"),r?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type,e]})}remove_treasury(e,t,r){(t||0!==e.length)&&(r?t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().serviceFn("treasury_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().serviceFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}set_order_agent(e,t,r){gd.SetOrderAgent(this.txb,this.pay_token_type,e,t,r)}change_order_payer(e,t,r){gd.ChangeOrderPayer(this.txb,this.pay_token_type,e,t,r)}static MAX_DISCOUNT_COUNT_ONCE=200;static MAX_DISCOUNT_RECEIVER_COUNT=20;static MAX_GUARD_COUNT=16;static MAX_REPOSITORY_COUNT=32;static MAX_ITEM_NAME_LENGTH=256;static MAX_TREASURY_COUNT=8;static MAX_ORDER_AGENT_COUNT=8;static MAX_ORDER_ARBS_COUNT=8;static MAX_ARBITRATION_COUNT=8;static MAX_REQUIRES_COUNT=16;static MAX_PUBKEY_SIZE=3e3;static IsValidItemName(e){return!!e&&(new TextEncoder).encode(e).length<=gd.MAX_ITEM_NAME_LENGTH}static parseObjectType=e=>qa(e,"service::Service<");static parseOrderObjectType=e=>qa(e,"order::Order<");static endpoint=(e,t,r)=>t||(e?e+"/sales/"+encodeURI(r):void 0);static DiscountObjects=(e,t)=>{$o.Client().getOwnedObjects({owner:e,filter:{MoveModule:{module:"order",package:$o.Instance().package("wowok")}},options:{showContent:!0,showType:!0}}).then((r=>{t(e,r.data.map((e=>e.data)))})).catch((e=>{console.log(e)}))};static SetOrderAgent=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"SetOrderAgent.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"SetOrderAgent.order"),To(s,co)||Ba(Ca.IsValidArray,"SetOrderAgent.agent"),Ga(s).length>gd.MAX_ORDER_AGENT_COUNT&&Ba(Ca.Fail,"SetOrderAgent.agent count"),e.moveCall({target:$o.Instance().orderFn("agent_set"),arguments:[e.object(r),e.pure.vector("address",Ga(s))],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})};static ChangeOrderPayer=(e,t,r,s,i)=>{go(t)||Ba(Ca.IsValidTokenType,"ChangeOrderPayer.order_token_type"),$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"ChangeOrderPayer.order"),co(s)||Ba(Ca.IsValidAddress,"ChangeOrderPayer.new_addr"),e.moveCall({target:$o.Instance().orderFn("payer_change"),arguments:[e.object(r),e.pure.address(s)],typeArguments:[t]}),i&&e.moveCall({target:$o.Instance().orderFn("order_ops_to_progress"),arguments:[e.object(r),e.object(i)],typeArguments:[t]})}}class yd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new yd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectEntity()),t}mark(e,t,r){"string"!=typeof t||co(t)||Ba(Ca.IsValidAddress,r),this.txb.moveCall({target:$o.Instance().entityFn(r),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),"string"==typeof t?this.txb.pure.address(t):t]})}update(e){e?.name&&!no(e.name)&&Ba(Ca.IsValidName,"update"),e?.description&&!io(e.description)&&Ba(Ca.IsValidDesription,"update"),e?.avatar&&!Bo(e.avatar)&&Ba(Ca.isValidHttpUrl,"update:avatar"),e?.twitter&&!no(e.twitter)&&Ba(Ca.IsValidName,"update:twitter"),e?.homepage&&!Bo(e.homepage)&&Ba(Ca.isValidHttpUrl,"update:homepage"),e?.discord&&!no(e.discord)&&Ba(Ca.IsValidName,"update:discord");const t=Wa.getInstance().bcs.ser("PersonalInfo",{name:e.name?(new TextEncoder).encode(e.name):"",description:e?.description?(new TextEncoder).encode(e.description):"",avatar:e?.avatar??"",twitter:e?.twitter??"",discord:e?.discord??"",homepage:e?.homepage??""}).toBytes();this.txb.moveCall({target:$o.Instance().entityFn("avatar_update"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("u8",[].slice.call(t))]})}create_resource(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}create_resource2(){return this.txb.moveCall({target:$o.Instance().entityFn("resource_create2"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}destroy_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_destroy"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}use_resource(e){return this.txb.moveCall({target:$o.Instance().entityFn("resource_use"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object())]})}transfer_resource(e,t){return co(t)||Ba(Ca.IsValidAddress,"transfer_resource"),this.txb.moveCall({target:$o.Instance().entityFn("resource_transfer"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.get_object()),this.txb.pure.address(t)]})}query_ent(e){co(e)||Ba(Ca.InvalidParam,"query_ent"),this.txb.moveCall({target:$o.Instance().entityFn("QueryEnt"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}}class fd{object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e){let t=new fd(e);return t.object=$o.TXB_OBJECT(e,$o.Instance().objectWowok()),t}register_grantor(e,t){no(e)||Ba(Ca.IsValidName,"register_grantor"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"register_grantor");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);this.txb.moveCall({target:$o.Instance().wowokFn("grantor_register"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),this.txb.object(r),$o.TXB_OBJECT(this.txb,t)]})}grantor_time_expand_1year(e){co(e)||Ba(Ca.IsValidAddress,"grantor_time_expand_1year"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.address(e)]})}grantor_rename(e){no(e)||Ba(Ca.IsValidName,"grantor_rename"),this.txb.moveCall({target:$o.Instance().wowokFn("grantor_time_expand_1year"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e)]})}mint(e,t){co(t)||Ba(Ca.IsValidAddress,"mint"),mo(e)||Ba(Ca.IsValidU64,"mint"),this.txb.moveCall({target:$o.Instance().baseWowokFn("mint"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectTreasuryCap()),this.txb.pure.u64(e),this.txb.pure.address(t)]})}oracle(e,t){return io(e)||Ba(Ca.IsValidDesription,"oracle.description"),$o.IsValidObjects([t])||Ba(Ca.IsValidObjects,"oracle.permission"),this.txb.moveCall({target:$o.Instance().wowokFn("oracle_repository"),arguments:[$o.TXB_OBJECT(this.txb,$o.Instance().objectOracle()),this.txb.pure.string(e),this.txb.object(t)]})}}!function(e){e.Like="like",e.Dislike="dislike",e.Launch="launch",e.Order="order",e.Payment="payment"}(hd||(hd={}));class vd{static MAX_ADDRESS_COUNT_FOR_TAG=1e3;static MAX_TAG_COUNT_FOR_ADDRESS=64;object;txb;get_object(){return this.object}constructor(e){this.txb=e,this.object=""}static From(e,t){let r=new vd(e);return r.object=$o.TXB_OBJECT(e,t),r}launch(){return this.object||Ba(Ca.Fail,"launch object Invalid"),this.txb.moveCall({target:$o.Instance().resourceFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)]})}resolve_add(e,t){return t.find((e=>e===hd.Like))&&yd.From(this.txb).mark(this,e,hd.Like),t.find((e=>e===hd.Dislike))&&yd.From(this.txb).mark(this,e,hd.Dislike),t.filter((e=>e!==hd.Like&&e!==hd.Dislike&&no(e)))}add(e,t,r){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: add.address");var s=this.resolve_add(e,t);(r||0!==s.length)&&(r&&!no(r)&&Ba(Ca.IsValidName,"Resource: add.name"),s.length>vd.MAX_TAG_COUNT_FOR_ADDRESS&&(s=s.slice(0,vd.MAX_TAG_COUNT_FOR_ADDRESS)),this.txb.moveCall({target:$o.Instance().resourceFn("add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.option("string",r),this.txb.pure.vector("string",s)]}))}remove(e,t){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: remove.address"),this.txb.moveCall({target:$o.Instance().resourceFn("remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e,this.txb.pure.vector("string",t)]})}removeall(e){"string"!=typeof e||co(e)||Ba(Ca.IsValidAddress,"Resource: removeall.address"),this.txb.moveCall({target:$o.Instance().resourceFn("removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),"string"==typeof e?this.txb.pure.address(e):e]})}static TagData(e,t=!0){const r=[];return e.forEach((e=>{e.tags.forEach((t=>{const s=r.find((e=>e.tag===t));s?s.address.find((t=>t===e.address))||s.address.push(e.address):r.push({tag:t,address:[e.address]})}))})),t&&Object.keys(hd).forEach((e=>{r.find((t=>t.tag===hd[e]))||r.push({tag:hd[e],address:[]})})),r}static Tags(e){const t=[];return e.address.forEach((r=>{const s=t.find((e=>e.address===r));s?s.tags.find((t=>t===e.tag))||s.tags.push(e.tag):t.push({address:r,tags:[e.tag]})})),t}}!function(e){e[e.PERMISSION=0]="PERMISSION",e[e.GUARD_ONLY_AND_IMMUTABLE=1]="GUARD_ONLY_AND_IMMUTABLE",e[e.BOTH_PERMISSION_AND_GUARD=2]="BOTH_PERMISSION_AND_GUARD"}(pd||(pd={})),function(e){e[e.WITHDRAW=1]="WITHDRAW",e[e.DEPOSIT=2]="DEPOSIT",e[e.RECEIVE=4]="RECEIVE"}(ld||(ld={}));class Td{token_type;permission;object;txb;get_token_type(){return this.token_type}get_object(){return this.object}static From(e,t,r,s){let i=new Td(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}constructor(e,t,r){this.token_type=t,this.permission=r,this.txb=e,this.object=""}static New(e,t,r,s,i){$o.IsValidObjects([r])||Ba(Ca.IsValidObjects,"Treasury.New permission, bounty"),io(s)||Ba(Ca.IsValidDesription,"Treasury.New.description"),yo(t)||Ba(Ca.IsValidArgType,t);let n=new Td(e,t,r);return n.object=i?e.moveCall({target:$o.Instance().treasuryFn("new_with_passport"),arguments:[i,e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}):e.moveCall({target:$o.Instance().treasuryFn("new"),arguments:[e.pure.string(s),$o.TXB_OBJECT(e,r)],typeArguments:[t]}),n}launch(){return this.txb.moveCall({target:$o.Instance().treasuryFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.token_type]})}set_deposit_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_deposit_guard.guard"),t?e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}deposit(e,t){$o.IsValidObjects([e.coin])||Ba(Ca.IsValidObjects,"deposit.param.coin"),io(e.remark)||Ba(Ca.IsValidDesription,"deposit.param.remark"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"deposit.param.for_object"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"deposit.param.for_guard"),void 0===e.index||mo(e.index)||Ba(Ca.InvalidParam,"deposit.param.index");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("deposit_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("deposit"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,e.coin),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}receive(e,t,r){$o.IsValidObjects([e,t])||Ba(Ca.IsValidArray,"receive.payment&received");const s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?this.txb.moveCall({target:$o.Instance().treasuryFn("receive_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("receive"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(t),this.txb.object(e),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}withdraw(e,t){if(0===e.items.length)return;To(e.items,(e=>mo(e.amount)&&co(e.address)))||Ba(Ca.IsValidArray,"withdraw.param.items"),io(e.remark)||Ba(Ca.IsValidDesription,"withdraw.param.remark"),mo(e.index)||Ba(Ca.IsValidU64,"withdraw.param.index"),e?.for_guard&&!co(e.for_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.for_guard"),e?.for_object&&!co(e.for_object)&&Ba(Ca.IsValidAddress,"withdraw.param.for_object"),e?.withdraw_guard&&!co(e.withdraw_guard)&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard"),e?.withdraw_guard&&!t&&Ba(Ca.IsValidAddress,"withdraw.param.withdraw_guard");const r=this.txb.pure.option("address",e.for_object?e.for_object:void 0),s=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return e.withdraw_guard&&t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard_forGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_useGuard"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),this.txb.object(e.withdraw_guard)],typeArguments:[this.token_type]}):t?e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):e.for_guard?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(e.for_guard),this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e.items.map((e=>e.address))),this.txb.pure.vector("u64",e.items.map((e=>e.amount))),this.txb.pure.u64(e.index),this.txb.pure.string(e.remark),r,this.txb.object(s),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().treasuryFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}set_withdraw_mode(e,t){t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_mode_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u8(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}add_withdraw_guard(e,t,r){co(e)||Ba(Ca.IsValidAddress,"add_withdraw_guard.guard"),mo(t)||Ba(Ca.IsValidU64,"add_withdraw_guard.amount"),r?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.pure.u64(t),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]})}remove_withdraw_guard(e,t,r){(0!==e.length||t)&&(To(e,co)||Ba(Ca.IsValidArray,"add_withdraw_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):t?this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove_all"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}):this.txb.moveCall({target:$o.Instance().treasuryFn("withdraw_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.token_type]}))}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"change_permission.new_permission"),this.txb.moveCall({target:$o.Instance().treasuryFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.token_type]}),this.permission=e}static parseObjectType=e=>qa(e,"treasury::Treasury<");static MAX_WITHDRAW_GUARD_COUNT=16}const Ed=200;function wd(e,t,r){t||Ba(Ca.InvalidParam,"Payment.New.pay_token_type"),r.receiver.length>Ed&&Ba(Ca.InvalidParam,"Payment.New.param.receiver"),To(r.receiver,(e=>co(e.address)&&$o.IsValidObjects([e.coin])))||Ba(Ca.IsValidArray,"Payment.New.param.receiver"),r?.for_object&&!co(r.for_object)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_object"),r?.for_guard&&!co(r.for_guard)&&Ba(Ca.IsValidAddress,"Payment.New.param.for_guard"),r?.business_remark&&!io(r?.business_remark)&&Ba(Ca.IsValidDesription,"Payment.New.param.business_remark");let s=e.pure.option("address",r.for_object?r.for_object:void 0);const i=e.sharedObjectRef($o.CLOCK_OBJECT);return r.for_guard?e.moveCall({target:$o.Instance().paymentFn("create_withGuard"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.object(r.for_guard),e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]}):e.moveCall({target:$o.Instance().paymentFn("create"),arguments:[e.pure.vector("address",r.receiver.map((e=>e.address))),e.makeMoveVec({elements:r.receiver.map((e=>e.coin))}),s,e.pure.u64(r.business_index),e.pure.string(r.business_remark),e.object(i)],typeArguments:[t]})}class xd{pay_token_type;permission;object;txb;get_pay_type(){return this.pay_token_type}get_object(){return this.object}constructor(e,t,r){this.pay_token_type=t,this.txb=e,this.permission=r,this.object=""}static From(e,t,r,s){let i=new xd(e,t,r);return i.object=$o.TXB_OBJECT(e,s),i}static New(e,t,r,s,i,n,a){$o.IsValidObjects([r,n])||Ba(Ca.IsValidObjects),go(t)||Ba(Ca.IsValidTokenType,"New.token_type"),io(s)||Ba(Ca.IsValidDesription),mo(i)||Ba(Ca.IsValidU64,"New.fee");let o=t,d=new xd(e,o,r);return d.object=a?e.moveCall({target:$o.Instance().arbitrationFn("new_with_passport"),arguments:[a,e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}):e.moveCall({target:$o.Instance().arbitrationFn("new"),arguments:[e.pure.string(s),e.pure.u64(i),e.object(n),$o.TXB_OBJECT(e,r)],typeArguments:[o]}),d}launch(){return this.txb.moveCall({target:$o.Instance().arbitrationFn("create"),arguments:[$o.TXB_OBJECT(this.txb,this.object)],typeArguments:[this.pay_token_type]})}set_description(e,t){io(e)||Ba(Ca.IsValidDesription,"set_description.description"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("description_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_fee(e,t){mo(e)||Ba(Ca.IsValidU64,"set_fee.fee"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("fee_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.u64(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_endpoint(e,t){e&&!oo(e)&&Ba(Ca.IsValidEndpoint,"set_endpoint.endpoint"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.string(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("endpoint_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}add_voting_guard(e,t){0!==e.length&&(To(e,(e=>$o.IsValidObjects([e.guard])&&mo(e.voting_weight)))||Ba(Ca.IsValidArray,"add_voting_guard.guard"),t?e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})):e.forEach((e=>{this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_add"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.guard),this.txb.pure.u64(e.voting_weight),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})})))}remove_voting_guard(e,t,r){(t||0!==e.length)&&(To(e,co)||Ba(Ca.IsValidArray,"remove_voting_guard.guard"),r?t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t?this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_removeall"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("voting_guard_remove"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.vector("address",e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}))}set_guard(e,t){e&&!co(e)&&Ba(Ca.IsValidAddress,"set_guard.apply_guard"),t?e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):e?this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("usage_guard_none"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}pause(e,t){t?this.txb.moveCall({target:$o.Instance().arbitrationFn("pause_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("pause"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.pure.bool(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}vote(e,t){e.voting_guard&&!$o.IsValidObjects([e.voting_guard])&&Ba(Ca.IsValidObjects,"vote.param.voting_guard"),To(e.agrees,(e=>mo(e)&&e<xd.MAX_PROPOSITION_COUNT))||Ba(Ca.IsValidArray,"vote.param.agrees"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"vote.param.arb");const r=this.txb.sharedObjectRef($o.CLOCK_OBJECT);t?e.voting_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("vote_with_passport"),arguments:[t,this.txb.object(e.voting_guard),$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote2_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("vote"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.vector("u8",e.agrees),this.txb.object(r),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arbitration(e,t){io(e.feedback)||Ba(Ca.IsValidDesription,"arbitration.param.feedback"),$o.IsValidObjects([e.arb])||Ba(Ca.IsValidObjects,"arbitration.param.arb"),e.indemnity&&!mo(e.indemnity)&&Ba(Ca.IsValidU64,"arbitration.param.indemnity");let r=this.txb.pure.option("u64",e.indemnity?e.indemnity:void 0);t?this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("arbitration"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.arb),this.txb.pure.string(e.feedback),r,$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}withdraw_fee(e,t,r){$o.IsValidObjects([e,t.treasury])||Ba(Ca.IsValidObjects,"withdraw_fee.arb or treasury"),t?.for_guard&&!$o.IsValidObjects([t.for_guard])&&Ba(Ca.IsValidObjects,"withdraw_fee.param.for_guard"),t?.for_object&&!co(t.for_object)&&Ba(Ca.IsValidAddress,"withdraw_fee.param.for_object"),io(t.remark)||Ba(Ca.IsValidDesription,"withdraw_fee.param.remark"),mo(t.index)||Ba(Ca.IsValidU64,"withdraw_fee.param.index");const s=this.txb.pure.option("address",t.for_object?t.for_object:void 0),i=this.txb.sharedObjectRef($o.CLOCK_OBJECT);return r?t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_with_passport"),arguments:[r,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):t.for_guard?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_forGuard"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.object(t.for_guard),this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),this.txb.object(t.treasury),s,this.txb.pure.u64(t.index),this.txb.pure.string(t.remark),this.txb.object(i),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}set_withdrawTreasury(e,t){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects,"set_withdrawTreasury.treasury"),t?this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("withdraw_treasury_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e),$o.TXB_OBJECT(this.txb,this.permission)],typeArguments:[this.pay_token_type]})}arb(e,t){return $o.IsValidObjects([e.order])||Ba(Ca.IsValidObjects,"arb.param.order"),go(e.order_token_type)||Ba(Ca.IsValidTokenType,"arb.param.order_token_type"),io(e.description)||Ba(Ca.IsValidDesription,"arb.param.description"),To(e.votable_proposition,no)||Ba(Ca.IsValidArray,"arb.param.votable_proposition"),t?e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute_with_passport"),arguments:[t,$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]}):e.fee?this.txb.moveCall({target:$o.Instance().arbitrationFn("dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition)),this.txb.object(e.fee)],typeArguments:[this.pay_token_type,e.order_token_type]}):this.txb.moveCall({target:$o.Instance().arbitrationFn("free_dispute"),arguments:[$o.TXB_OBJECT(this.txb,this.object),this.txb.object(e.order),this.txb.pure.string(e.description),this.txb.pure.vector("string",Ga(e.votable_proposition))],typeArguments:[this.pay_token_type,e.order_token_type]})}arb_launch(e){return this.txb.moveCall({target:$o.Instance().arbFn("create"),arguments:[$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]})}dispute(e,t){const r=this.arb(e,t);return this.arb_launch(r)}change_permission(e){$o.IsValidObjects([e])||Ba(Ca.IsValidObjects),this.txb.moveCall({target:$o.Instance().arbitrationFn("permission_set"),arguments:[$o.TXB_OBJECT(this.txb,this.object),$o.TXB_OBJECT(this.txb,this.permission),$o.TXB_OBJECT(this.txb,e)],typeArguments:[this.pay_token_type]}),this.permission=e}static parseObjectType=e=>qa(e,"arbitration::Arbitration<");static parseArbObjectType=e=>qa(e,"arb::Arb<");static queryArbVoted=()=>{};static MAX_PROPOSITION_COUNT=16;static MAX_VOTING_GUARD_COUNT=16}class Od extends Error{}async function Id({host:e,path:t,body:r,headers:s,method:i}){const n=new URL(t,e).toString(),a=await fetch(n,{method:i,body:r?JSON.stringify(r):void 0,headers:{"Content-Type":"application/json",...s||{}}});if(429===a.status)throw new Od("Too many requests from this client have been sent to the faucet. Please retry later");try{const e=await a.json();if(e.error)throw new Error(`Faucet returns error: ${e.error}`);return e}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${a.status}, response ${a}`)}}async function Cd(e){return Id({host:e.host,path:"/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}async function Bd(e){return Id({host:e.host,path:"/v1/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}function Sd(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}class Pd{constructor(e){this.expire=e}expire_time(){return this.expire}expire}var jd;!function(e){e.object="OBJECT",e.personal="PERSONAL",e.table="TABLE"}(jd||(jd={}));const Ad=(e,t)=>e+$o.Instance().package("wowok_origin")+t+"-V2";class kd extends Pd{constructor(e=1e4){super(e)}data=new Map;load(e){return this.data.get(e)}save(e,t){this.data.set(e,t)}remove(e){this.data.delete(e)}}class Ud extends Pd{constructor(e=1e4){super(e)}load(e){return localStorage.getItem(e)}save(e,t){return localStorage.setItem(e,t)}remove(e){return localStorage.removeItem(e)}}class Nd{static _instance;cache=new Map;constructor(){}static Instance(){return Nd._instance||(Nd._instance=new Nd),Nd._instance}set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}}var Dd;!function(e){e.localStorage="localStorage",e.memoryStorage="memoryStorage"}(Dd||(Dd={}));const Rd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Jd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Yd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Fd(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},Vd=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Md(t)??""})}catch(e){return JSON.stringify({error:e?.toString()})}},Jd=async e=>{var t=[];const r=[],s=(new Date).getTime(),i=Nd.Instance().get(jd.object);if(i)for(let n=0;n<e.objects.length;++n){try{let a=i.load(Ad(e.objects[n],jd.object));if(a){const i=JSON.parse(a);if("INFINITE"!==i?.expire&&(e?.no_cache||i.expire<=s)&&(e.showOwner||e.showContent))r.push(e.objects[n]);else{const e=sc(JSON.parse(i.data));e.cache_expire=i.expire,t.push(e)}}}catch(e){console.log(e)}r.push(e.objects[n])}if(r.length>0){const s=await $o.Client().multiGetObjects({ids:[...r],options:{showContent:e.showContent,showType:e.showType,showOwner:e.showOwner}}),i=Nd.Instance().get(jd.object);if(i){const e=(new Date).getTime();s.forEach((t=>{try{if(t?.data){const r=t.data?.type??t.data?.content?.type??void 0,s=r?$o.Instance().object_name_from_type_repr(r):void 0,n={expire:"Guard"===s||"Payment"===s?"INFINITE":i.expire_time()+e,data:JSON.stringify(t.data)};i.save(Ad(t.data.objectId,jd.object),JSON.stringify(n))}}catch(e){console.log(e)}}))}t=t.concat(s.map((e=>sc(e?.data))))}return{objects:t}},Md=async e=>{co(e.address)||Ba(Ca.IsValidAddress,"entity.address");const t=(new Date).getTime(),r=Nd.Instance().get(jd.personal);if(r&&!e.no_cache)try{let s=r.load(Ad(e.address,jd.personal));if(s){const e=JSON.parse(s);if("INFINITE"===e?.expire||e.expire<=t){const t=JSON.parse(e.data);return t.cache_expire=e.expire,t}}}catch(e){console.log(e)}const s=await tc(Qd($o.Instance().objectEntity(),e.address));if("Personal"===s.type){if(r)try{const t=r.expire_time()+(new Date).getTime(),i={expire:t,data:JSON.stringify(s)};r.save(Ad(e.address,jd.personal),JSON.stringify(i)),s.cache_expire=t}catch(e){console.log(e)}return s}},Fd=async e=>{const t=await $o.Client().getDynamicFields({parentId:e.parent,cursor:e.cursor,limit:e.limit});return{items:t?.data?.map((e=>({object:e.objectId,type:e.type,version:e.version,key:{type:e.name.type,value:e.name.value}}))),nextCursor:t.nextCursor,hasNextPage:t.hasNextPage}},Xd=async(e,t)=>await tc(Qd(e,t)),qd=async(e,t)=>await tc(Qd(e,t)),Ld=async(e,t)=>await tc(Qd(e,t)),Gd=async(e,t)=>await tc(Zd(e,t)),$d=async(e,t)=>await tc(Zd(e,t)),zd=async(e,t)=>await tc(ec(e,t)),Wd=async(e,t)=>await tc(ec(e,t)),Hd=async(e,t,r)=>("string"!=typeof e&&(e=e.object),await tc({parent:e,key:{type:$o.Instance().package("wowok")+"::repository::DataKey",value:{id:t,key:r}}})),Kd=async(e,t)=>await tc(Qd(e,t));function Qd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"address",value:t}}}function Zd(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"0x1::string::String",value:t}}}function ec(e,t){return"string"!=typeof e&&(e=e.object),{parent:e,key:{type:"u64",value:t}}}const tc=async e=>{const t=await $o.Client().getDynamicFieldObject({parentId:e.parent,name:{type:e.key.type,value:e.key.value}});return sc(t?.data)};function rc(e){if(!e)return;const t=$o.Instance().object_name_from_type_repr(e);if("Permission"===t||"Demand"===t||"Machine"===t||"Progress"===t||"Order"===t||"Service"===t||"Treasury"===t||"Arb"===t||"Repository"===t||"Payment"===t||"Discount"===t||"Guard"===t||"Arbitration"===t)return t;if("Resource"===t)return"PersonalMark";const r=e?.indexOf("0x2::dynamic_field::Field<");if(0===r){const t=e?.substring(26);if(t&&$o.Instance().hasPackage(t)){if(t.includes("::demand::Tips>"))return"TableItem_DemandPresenter";if(t.includes("::machine::NodePair>>>"))return"TableItem_MachineNode";if(t.includes("::progress::History>"))return"TableItem_ProgressHistory";if(t.includes("::service::Sale>"))return"TableItem_ServiceSale";if(t.includes("::treasury::Record>"))return"TableItem_TreasuryHistory";if(t.includes("::arb::Voted>"))return"TableItem_ArbVote";if(t.includes("::permission::Perm>>"))return"TableItem_PermissionEntity";if(t.includes("::repository::DataKey"))return"TableItem_RepositoryData";if(t.includes("::entity::Ent>"))return"Personal";if(t.includes("::resource::Tags>"))return"TableItem_PersonalMark"}}}function sc(e){const t=e?.content?.fields,r=e?.objectId??t?.id?.id??void 0,s=e?.type??e?.content?.type??void 0,i=e?.version??void 0,n=e?.owner??void 0,a=rc(s);if(a)switch(a){case"Permission":return{object:r,type:a,type_raw:s,owner:n,version:i,builder:t?.builder??"",admin:t?.admin,description:t?.description??"",entity_count:parseInt(t?.table?.fields?.size),biz_permission:t?.user_define?.fields?.contents?.map((e=>({id:parseInt(e?.fields?.key),name:e?.fields?.value})))};case"Demand":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,guard:t?.guard?{object:t?.guard,service_id_in_guard:t?.service_identifier}:void 0,time_expire:t?.time_expire,yes:t?.yes,presenter_count:parseInt(t?.presenters?.fields?.size),bounty:t?.bounty?.map((e=>({type:e?.fields?.type,object:e?.fields?.id?.id,balance:e?.fields?.balance})))};case"Machine":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission??"",description:t?.description??"",bPaused:t?.bPaused,bPublished:t?.bPublished,endpoint:t?.endpoint,consensus_repository:t?.consensus_repositories,node_count:parseInt(t?.nodes?.fields?.size)};case"Progress":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,current:t?.current,task:t?.task,parent:t?.parent,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),namedOperator:t?.namedOperator?.fields?.contents?.map((e=>({name:e?.fields?.key,operator:e?.fields?.value}))),session:t?.session?.fields?.contents?.map((e=>({weights:e?.fields?.value?.fields?.weight,threshold:e?.fields?.value?.fields?.threshold,next_node:e?.fields?.key,forward:e?.fields?.value?.fields?.forwards?.fields?.contents?.map((e=>({forward_name:e?.fields?.key,accomplished:e?.fields?.value?.fields?.accomplished,msg:e?.fields?.value?.fields?.msg,orders:e?.fields?.value?.fields?.orders,time:e?.fields?.value?.fields?.time,holder:e?.fields?.value?.fields?.who})))})))};case"Order":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,amount:t?.amount,agent:t?.agent,arb:t?.dispute,payer:t?.payer,progress:t?.progress,discount:t?.discount,balance:t?.payed,required_info:t?.required_info?{pubkey:t?.required_info?.fields?.customer_pub,msg_encrypted:t?.required_info?.fields?.info}:void 0,item:t?.items?.map((e=>({name:e?.fields?.name,price:e?.fields?.price,stock:e?.fields?.stock,endpoint:e?.fields?.endpoint})))};case"Service":return{object:r,type:a,type_raw:s,owner:n,version:i,machine:t?.machine,permission:t?.permission,description:t?.description,arbitration:t?.arbitrations,bPaused:t?.bPaused,bPublished:t?.bPublished,buy_guard:t?.buy_guard,endpoint:t?.endpoint,payee:t?.payee,repository:t?.repositories,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),refund_guard:t?.refund_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value}))),sales_count:parseInt(t?.sales?.fields?.size),extern_withdraw_treasury:t?.extern_withdraw_treasuries,customer_required_info:t?.customer_required?{pubkey:t?.customer_required?.fields?.service_pubkey,required_info:t?.customer_required?.fields?.customer_required_info}:void 0};case"Treasury":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,withdraw_mode:t?.withdraw_mode,history_count:parseInt(t?.history?.fields?.contents?.fields?.size),balance:t?.balance,deposit_guard:t?.deposit_guard,withdraw_guard:t?.withdraw_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,percent:e?.fields?.value})))};case"Arbitration":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,fee:t?.fee,fee_treasury:t?.fee_treasury,usage_guard:t?.usage_guard,endpoint:t?.endpoint,bPaused:t?.bPaused,voting_guard:t?.voting_guard?.fields?.contents?.map((e=>({object:e?.fields?.key,weights:e?.fields?.value})))};case"Arb":return{object:r,type:a,type_raw:s,owner:n,version:i,arbitration:t?.arbitration,description:t?.description,fee:t?.fee,feedback:t?.feedback,indemnity:t?.indemnity,order:t?.order,voted_count:parseInt(t?.voted?.fields?.size),proposition:t?.proposition?.fields?.contents?.map((e=>({proposition:e?.fields?.key,votes:e?.fields?.value})))};case"Repository":return{object:r,type:a,type_raw:s,owner:n,version:i,permission:t?.permission,description:t?.description,policy_mode:t?.policy_mode,data_count:parseInt(t?.data?.fields?.size),reference:t?.reference,rep_type:t?.type,policy:t?.policies?.fields?.contents?.map((e=>({key:e?.fields?.key,description:e?.fields?.value?.fields?.description,permissionIndex:e?.fields?.value?.fields?.permission_index,dataType:e?.fields?.value?.fields?.value_type})))};case"Payment":return{object:r,type:a,type_raw:s,owner:n,version:i,signer:t?.signer,time:t?.time,remark:t?.remark,from:t?.from,biz_id:t?.index,for_guard:t?.for_guard,for_object:t?.for_object,amount:t?.amount,record:t?.record?.map((e=>({recipient:e?.fields?.recipient,amount:e?.fields?.amount})))};case"Discount":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.service,time_start:t?.time_start,time_end:t?.time_end,price_greater:t?.price_greater,off_type:t?.type,off:t?.off,name:t?.name};case"Guard":return{object:r,type:a,type_raw:s,owner:n,version:i,description:t?.description,input:Uint8Array.from(t?.input?.fields?.bytes),identifier:t?.constants?.map((e=>({id:e?.fields?.identifier,bWitness:e?.fields?.bWitness,value:Uint8Array.from(e?.fields?.value)})))};case"PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,tag_count:parseInt(t?.tags?.fields?.size)};case"TableItem_DemandPresenter":return{object:r,type:a,type_raw:s,owner:n,version:i,service:t?.name,presenter:t?.value?.fields?.who,recommendation:t?.value?.fields?.tips};case"TableItem_ProgressHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,history:ed.DeHistory(t)};case"TableItem_ServiceSale":return{object:r,type:a,type_raw:s,owner:n,version:i,item:{item:t?.name,stock:t?.value?.fields?.stock,price:t?.value?.fields?.price,endpoint:t?.value?.fields?.endpoint}};case"TableItem_TreasuryHistory":return{object:r,type:a,type_raw:s,owner:n,version:i,id:t?.name,payment:t?.value?.fields?.payment,signer:t?.value?.fields?.signer,operation:t?.value?.fields?.op,amount:t?.value?.fields?.amount,time:t?.value?.fields?.time};case"TableItem_ArbVote":return{object:r,type:a,type_raw:s,owner:n,version:i,singer:t?.name,vote:t?.value?.fields?.agrees,time:t?.value?.fields?.time,weight:t?.value?.fields?.weight};case"TableItem_PermissionEntity":return{object:r,type:a,type_raw:s,owner:n,version:i,entity:t?.name,permission:t?.value?.map((e=>({id:e?.fields.index,guard:e?.fields.guard})))};case"TableItem_RepositoryData":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name?.fields?.id,key:t?.name?.fields?.key,data:Uint8Array.from(t?.value)};case"Personal":const o=Wa.getInstance().de_entInfo(Uint8Array.from(t?.value?.fields?.avatar));return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,like:t?.value?.fields?.like,dislike:t?.value?.fields?.dislike,mark_object:t?.value?.fields?.resource,lastActive_digest:e?.previousTransaction,info:{homepage:o?.homepage,name:o?.name,avatar:o?.avatar,twitter:o?.twitter,discord:o?.discord,description:o?.description}};case"TableItem_PersonalMark":return{object:r,type:a,type_raw:s,owner:n,version:i,address:t?.name,name:t?.value?.fields?.nick,tags:t?.value?.fields?.tags}}return{object:r,type:void 0,type_raw:s,owner:n,version:i}}const ic=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await nc(t)})}catch(e){return JSON.stringify({error:e})}},nc=async e=>{co(e.permission_object)||Ba(Ca.IsValidAddress,"permission.permission_object");const t=new gs;Qo.From(t,e.permission_object).query_permissions_all(e.address);const r=await $o.Client().devInspectTransactionBlock({sender:e.address,transactionBlock:t});r.results&&r.results[0].returnValues&&2!==r.results[0].returnValues.length&&Ba(Ca.Fail,"permission.retValues");const s=Wa.getInstance().de(Oa.U8,Uint8Array.from(r.results[0].returnValues[0][0]));if(s===Qo.PERMISSION_ADMIN||s===Qo.PERMISSION_OWNER_AND_ADMIN)return{who:e.address,admin:!0,owner:s%2==1,items:[],object:e.permission_object};{const t=Wa.getInstance().de_perms(Uint8Array.from(r.results[0].returnValues[1][0]));return{who:e.address,admin:!1,owner:s%2==1,items:t.map((e=>({query:e?.index,permission:!0,guard:e?.guard}))),object:e.permission_object}}};var ac;!function(e){e.query_events_json=async t=>{try{const r=JSON.parse(t);return JSON.stringify({data:await e.query_events(r)})}catch(e){return JSON.stringify({error:e?.toString()})}},e.query_events=e=>{switch(e.type){case"OnNewArb":return t(e.cursor,e.limit,e.order);case"OnNewProgress":return s(e.cursor,e.limit,e.order);case"OnPresentService":return r(e.cursor,e.limit,e.order);case"OnNewOrder":return i(e.cursor,e.limit,e.order)}};const t=async(e,t,r)=>await n($o.Instance().package("wowok")+"::arb::NewArbEvent",e,t,r),r=async(e,t,r)=>await n($o.Instance().package("wowok")+"::demand::PresentEvent",e,t,r),s=async(e,t,r)=>await n($o.Instance().package("wowok")+"::progress::NewProgressEvent",e,t,r),i=async(e,t,r)=>await n($o.Instance().package("wowok")+"::order::NewOrderEvent",e,t,r),n=async(e,t,r,s)=>{const i=await $o.Client().queryEvents({query:{MoveEventType:e},cursor:t,limit:r,order:s}),n=i?.data?.map((e=>{if(e?.packageId===$o.Instance().package("wowok")){if(e?.type?.includes("::order::NewOrderEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",order:e?.parsedJson?.object,service:e?.parsedJson?.service,progress:e?.parsedJson?.progress,amount:e?.parsedJson?.amount};if(e?.type?.includes("::demand::PresentEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",demand:e?.parsedJson?.object,service:e?.parsedJson?.service,recommendation:e?.parsedJson?.tips};if(e?.type?.includes("::progress::NewProgressEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",progress:e?.parsedJson?.object,machine:e?.parsedJson?.machine,task:e?.parsedJson?.task};if(e?.type?.includes("::arb::NewArbEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",arb:e?.parsedJson?.object,arbitration:e?.parsedJson?.arbitration,order:e?.parsedJson?.order};if(e?.type?.includes("::entity::NewEntityEvent"))return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:"NewOrderEvent",resource:e?.parsedJson?.resource?.some,address:e?.parsedJson?.target}}return{id:e?.id,time:e?.timestampMs,type_raw:e?.type,sender:e?.sender,type:""}}));return{data:n,hasNextPage:i?.hasNextPage,nextCursor:i?.nextCursor}}}(ac||(ac={}));const oc="wowok.acc.dat",dc="wowok-acc-v1";class cc{constructor(e="File"){this.storage=e}static _instance;static Instance(){return cc._instance||(cc._instance=new cc),cc._instance}storage="File";_add(e,t,r){var s,i="0x"+ta(Un(Zn.generate().getSecretKey()).secretKey);try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));return e?e.default=r:(r&&s.forEach((e=>e.default=!1)),s.push({name:t,key:i,default:r})),s}}catch(e){}return[{name:t,key:i,default:r}]}_default(e){var t;try{if(e&&(t=JSON.parse(e))){const e=t.find((e=>e.default));if(e)return e}}catch(e){}}_get(e,t,r){var s;try{if(e&&(s=JSON.parse(e))){const e=s.find((e=>e.name===t));if(e)return e;if(r)return s.find((e=>e.default))}}catch(e){}}_rename(e,t,r,s=!0){var i;try{if(e&&(i=JSON.parse(e)),i){const e=i.find((e=>e.name===t));if(!e)return;const n=i.find((e=>e.name===r));if(!n)return e.name=r,i;if(s)return e.name=r,n.name=t,i}}catch(e){}}set_storage(e="File"){this.storage=e}async gen(e,t){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);r.readFile(n,"utf-8",((s,i)=>{const a=this._add(i,e,t);r.writeFileSync(n,JSON.stringify(a),"utf-8")}))}else if("Explorer"===this.storage){const r=this._add(localStorage.getItem(dc),e,t);localStorage.setItem(dc,JSON.stringify(r))}}catch(e){}}async default(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return this._default(e.readFileSync(s,"utf-8"))}if("Explorer"===this.storage)return this._default(localStorage.getItem(dc))}catch(e){}}async get(e,t=!0){try{if("File"===this.storage){const[r,s,i]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),n=i.join(s.homedir(),oc);return this._get(r.readFileSync(n,"utf-8"),e,t)}if("Explorer"===this.storage)return this._get(localStorage.getItem(dc),e,t)}catch(e){}}async rename(e,t,r=!0){var s;try{if("File"===this.storage){const[i,n,o]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),d=o.join(n.homedir(),oc);(s=this._rename(i.readFileSync(d,"utf-8"),e,t,r))&&i.writeFileSync(d,JSON.stringify(s),"utf-8")}else"Explorer"===this.storage&&(s=this._rename(localStorage.getItem(dc),e,t,r))&&localStorage.setItem(dc,JSON.stringify(s))}catch(e){}return!!s}async get_address(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiAddress()}async get_pubkey(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key)).getPublicKey().toSuiPublicKey()}async get_pair(e,t=!0){const r=await this.get(e,t);if(r)return Zn.fromSecretKey(ea(r.key))}async list(){try{if("File"===this.storage){const[e,t,r]=await Promise.all([a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23)),a.e(124).then(a.t.bind(a,124,23))]),s=r.join(t.homedir(),oc);return JSON.parse(e.readFileSync(s,"utf-8")).map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}if("Explorer"===this.storage)return JSON.parse(localStorage.getItem(dc)??"").map((e=>({name:e.name,default:e?.default,address:Zn.fromSecretKey(ea(e.key)).getPublicKey().toSuiAddress()})))}catch(e){}return[]}async faucet(e){const t=await this.get_address(e,!0);t&&await Cd({host:Sd("testnet"),recipient:t}).catch((e=>{}))}balance=async(e,t)=>{const r=await this.get_address(e);if(r)return await $o.Client().getBalance({owner:r,coinType:t})};coin=async(e,t)=>{const r=await this.get_address(e);if(r)return(await $o.Client().getCoins({owner:r,coinType:t})).data};get_coin_object=async(e,t,r,s)=>{const i=await this.get_address(r),n=BigInt(t);if(i&&n>BigInt(0)){if(s&&"0x2::sui::SUI"!==s&&"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"!==s){const t=await $o.Client().getCoins({owner:i,coinType:s}),r=[];var a=BigInt(0);for(let e=0;e<t.data.length&&(a+=BigInt(t.data[e].balance),r.push(t.data[e].coinObjectId),!(a>=n));++e);if(1===r.length)return e.splitCoins(r[0],[n]);{const t=r.pop();return e.mergeCoins(t,r),e.splitCoins(t,[n])}}return e.splitCoins(e.gas,[n])}};coin_with_balance=async(e,t,r)=>{const s=await this.get_pair(t,!0);s||Ba(Ca.Fail,"account invalid");const i=new gs,n=await cc.Instance().get_coin_object(i,e,t,r);if(n){i.transferObjects([n],s?.toSuiAddress());const e=await $o.Client().signAndExecuteTransaction({transaction:i,signer:s,options:{showObjectChanges:!0}}),t=r??"0x2::sui::SUI";return e?.objectChanges.find((e=>"created"===e?.type&&(e?.objectType).includes(t)))?.objectId}}}function uc(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const hc=8192;function pc(e){if(e.length<hc)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=hc){const s=e.slice(r,r+hc);t+=String.fromCharCode(...s)}return btoa(t)}const lc=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){const s=e.charAt(r),i=s.charCodeAt(0);if(255!==t[i])throw new TypeError(s+" is ambiguous");t[i]=r}const r=e.length,s=e.charAt(0),i=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,o=0;for(;e[n]===s;)a++,n++;const d=(e.length-n)*i+1>>>0,c=new Uint8Array(d);for(;n<e.length;){const s=e.charCodeAt(n);if(s>255)return;let i=t[s];if(255===i)return;let a=0;for(let e=d-1;(0!==i||a<o)&&-1!==e;e--,a++)i+=r*c[e]>>>0,c[e]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");o=a,n++}let u=d-o;for(;u!==d&&0===c[u];)u++;const h=new Uint8Array(a+(d-u));let p=a;for(;u!==d;)h[p++]=c[u++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,o=0;const d=t.length;for(;o!==d&&0===t[o];)o++,i++;const c=(d-o)*n+1>>>0,u=new Uint8Array(c);for(;o!==d;){let e=t[o],s=0;for(let t=c-1;(0!==e||s<a)&&-1!==t;t--,s++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");a=s,o++}let h=c-a;for(;h!==c&&0===u[h];)h++;let p=s.repeat(i);for(;h<c;++h)p+=e.charAt(u[h]);return p},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),mc=e=>lc.encode(e),_c=e=>lc.decode(e);function bc(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function gc(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}function yc(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}class fc{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class vc{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Tc(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Tc(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Tc(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return yc(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return mc(e);case"base64":return pc(e);case"hex":return gc(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Tc(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Ec,wc,xc,Oc,Ic=e=>{throw TypeError(e)},Cc=(e,t,r)=>t.has(e)||Ic("Cannot "+r),Bc=(e,t,r)=>(Cc(e,t,"read from private field"),r?r.call(e):t.get(e)),Sc=(e,t,r)=>t.has(e)?Ic("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Pc=(e,t,r,s)=>(Cc(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);Ec=new WeakMap,wc=new WeakMap;let jc=class e{constructor(e){Sc(this,Ec),Sc(this,wc),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Pc(this,Ec,e.write),Pc(this,wc,e.serialize??((e,t)=>{const r=new vc({initialSize:this.serializedSize(e)??void 0,...t});return Bc(this,Ec).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Bc(this,Ec).call(this,e,t)}serialize(e,t){return this.validate(e),new Uc(this,Bc(this,wc).call(this,e,t))}parse(e){const t=new fc(e);return this.read(t)}fromHex(e){return this.parse(bc(e))}fromBase58(e){return this.parse(_c(e))}fromBase64(e){return this.parse(uc(e))}transform({name:t,input:r,output:s,validate:i}){return new e({name:t??this.name,read:e=>s(this.read(e)),write:(e,t)=>Bc(this,Ec).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>Bc(this,wc).call(this,r(e),t),validate:e=>{i?.(e),this.validate(r(e))}})}};const Ac=Symbol.for("@mysten/serialized-bcs");function kc(e){return!!e&&"object"==typeof e&&!0===e[Ac]}class Uc{constructor(e,t){Sc(this,xc),Sc(this,Oc),Pc(this,xc,e),Pc(this,Oc,t)}get[Ac](){return!0}toBytes(){return Bc(this,Oc)}toHex(){return gc(Bc(this,Oc))}toBase64(){return pc(Bc(this,Oc))}toBase58(){return mc(Bc(this,Oc))}parse(){return Bc(this,xc).parse(Bc(this,Oc))}}function Nc({size:e,...t}){return new jc({...t,serializedSize:()=>e})}function Dc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function Rc({readMethod:e,writeMethod:t,...r}){return Nc({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function Yc(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function Vc(e,t,r,s,i){const n=i&&"input"in i?i.input:r.value,a=i?.expected??e.expects??null,o=i?.received??Yc(n),d={kind:e.kind,type:e.type,input:n,expected:a,received:o,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},c="schema"===e.kind,u=i?.message??e.message??(e.reference,void d.lang)??(c?void d.lang:null)??s.message??void d.lang;u&&(d.message="function"==typeof u?u(d):u),c&&(r.typed=!1),r.issues?r.issues.push(d):r.issues=[d]}function Jc(e,t){return Object.hasOwn(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}xc=new WeakMap,Oc=new WeakMap;var Mc=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Fc(e,t){return{kind:"validation",type:"check",reference:Fc,async:!1,expects:null,requirement:e,message:t,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"input",e,t),e}}}function Xc(e){return{kind:"validation",type:"integer",reference:Xc,async:!1,expects:null,requirement:Number.isInteger,message:e,_run(e,t){return e.typed&&!this.requirement(e.value)&&Vc(this,"integer",e,t),e}}}function qc(e){return{kind:"transformation",type:"transform",reference:qc,async:!1,operation:e,_run(e){return e.value=this.operation(e.value),e}}}function Lc(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function Gc(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function $c(e,t){return{kind:"schema",type:"array",reference:$c,expects:"Array",async:!1,item:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<r.length;s++){const i=r[s],n=this.item._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function zc(e){return{kind:"schema",type:"bigint",reference:zc,expects:"bigint",async:!1,message:e,_run(e,t){return"bigint"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Wc(e){return{kind:"schema",type:"boolean",reference:Wc,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function Hc(e){return{kind:"schema",type:"lazy",reference:Hc,expects:"unknown",async:!1,getter:e,_run(e,t){return this.getter(e.value)._run(e,t)}}}function Kc(e,t){return{kind:"schema",type:"literal",reference:Kc,expects:Yc(e),async:!1,literal:e,message:t,_run(e,t){return e.value===this.literal?e.typed=!0:Vc(this,"type",e,t),e}}}function Qc(e,...t){const r={kind:"schema",type:"nullable",reference:Qc,expects:`${e.expects} | null`,async:!1,wrapped:e,_run(e,t){return null===e.value&&("default"in this&&(e.value=Lc(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function Zc(e,...t){const r={kind:"schema",type:"nullish",reference:Zc,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(e,t){return null!==e.value&&void 0!==e.value||("default"in this&&(e.value=Lc(this,e,t)),null!==e.value&&void 0!==e.value)?this.wrapped._run(e,t):(e.typed=!0,e)}};return 0 in t&&(r.default=t[0]),r}function eu(e){return{kind:"schema",type:"number",reference:eu,expects:"number",async:!1,message:e,_run(e,t){return"number"!=typeof e.value||isNaN(e.value)?Vc(this,"type",e,t):e.typed=!0,e}}}function tu(e,t){return{kind:"schema",type:"object",reference:tu,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in this.entries){const i=r[s],n=this.entries[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"object",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),(void 0!==n.value||s in r)&&(e.value[s]=n.value)}}else Vc(this,"type",e,t);return e}}}function ru(e,...t){const r={kind:"schema",type:"optional",reference:ru,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=Lc(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(r.default=t[0]),r}function su(e,t,r){return{kind:"schema",type:"record",reference:su,expects:"Object",async:!1,key:e,value:t,message:r,_run(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const s in r)if(Jc(r,s)){const i=r[s],n=this.key._run({typed:!1,value:s},t);if(n.issues){const a={type:"object",origin:"key",input:r,key:s,value:i};for(const t of n.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const n={type:"object",origin:"value",input:r,key:s,value:i};for(const t of a.issues)t.path?t.path.unshift(n):t.path=[n],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}n.typed&&a.typed||(e.typed=!1),n.typed&&(e.value[n.value]=a.value)}}else Vc(this,"type",e,t);return e}}}function iu(e){return{kind:"schema",type:"string",reference:iu,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:Vc(this,"type",e,t),e}}}function nu(e,t){return{kind:"schema",type:"tuple",reference:nu,expects:"Array",async:!1,items:e,message:t,_run(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let s=0;s<this.items.length;s++){const i=r[s],n=this.items[s]._run({typed:!1,value:i},t);if(n.issues){const a={type:"array",origin:"value",input:r,key:s,value:i};for(const t of n.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=n.issues),t.abortEarly){e.typed=!1;break}}n.typed||(e.typed=!1),e.value.push(n.value)}}else Vc(this,"type",e,t);return e}}}function au(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function ou(e,t){return{kind:"schema",type:"union",reference:ou,expects:[...new Set(e.map((e=>e.expects)))].join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){let r,s,i;for(const n of this.options){const a=n._run({typed:!1,value:e.value},t);if(a.typed){if(!a.issues){r=a;break}s?s.push(a):s=[a]}else i?i.push(a):i=[a]}if(r)return r;if(s){if(1===s.length)return s[0];Vc(this,"type",e,t,{issues:au(s)}),e.typed=!0}else{if(1===i?.length)return i[0];Vc(this,"type",e,t,{issues:au(i)})}return e}}}function du(){return{kind:"schema",type:"unknown",reference:du,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}function cu(e,t,r){const s=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}}(r));if(s.issues)throw new Mc(s.issues);return s.value}function uu(...e){return{...e[0],pipe:e,_run(t,r){for(let s=0;s<e.length;s++){if(t.issues&&("schema"===e[s].kind||"transformation"===e[s].kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=e[s]._run(t,r))}return t}}}function hu(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&32===function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)}function pu(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(64,"0")}`}function lu(e,t=!1){return pu(e,t)}function mu(e){return uu(ou(Object.entries(e).map((([e,t])=>tu({[e]:t})))),qc((e=>({...e,$kind:Object.keys(e)[0]}))))}const _u=uu(iu(),qc((e=>pu(e))),Fc(hu)),bu=_u,gu=iu(),yu=uu(ou([iu(),uu(eu(),Xc())]),Fc((e=>{try{return BigInt(e),BigInt(e)>=0&&BigInt(e)<=18446744073709551615n}catch{return!1}}),"Invalid u64")),fu=tu({objectId:_u,version:yu,digest:iu()}),vu=uu(ou([tu({GasCoin:Kc(!0)}),tu({Input:uu(eu(),Xc()),type:ru(Kc("pure"))}),tu({Input:uu(eu(),Xc()),type:ru(Kc("object"))}),tu({Result:uu(eu(),Xc())}),tu({NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])})]),qc((e=>({...e,$kind:Object.keys(e)[0]})))),Tu=tu({budget:Qc(yu),price:Qc(yu),owner:Qc(_u),payment:Qc($c(fu))}),Eu=(tu({address:iu(),module:iu(),name:iu(),typeParams:$c(iu())}),ou([Kc("address"),Kc("bool"),Kc("u8"),Kc("u16"),Kc("u32"),Kc("u64"),Kc("u128"),Kc("u256"),tu({vector:Hc((()=>Eu))}),tu({datatype:tu({package:iu(),module:iu(),type:iu(),typeParameters:$c(Hc((()=>Eu)))})}),tu({typeParameter:uu(eu(),Xc())})])),wu=tu({ref:Qc(ou([Kc("&"),Kc("&mut")])),body:Eu}),xu=tu({package:bu,module:iu(),function:iu(),typeArguments:$c(iu()),arguments:$c(vu),_argumentTypes:ru(Qc($c(wu)))}),Ou=tu({name:iu(),inputs:su(iu(),ou([vu,$c(vu)])),data:su(iu(),du())}),Iu=mu({MoveCall:xu,TransferObjects:tu({objects:$c(vu),address:vu}),SplitCoins:tu({coin:vu,amounts:$c(vu)}),MergeCoins:tu({destination:vu,sources:$c(vu)}),Publish:tu({modules:$c(gu),dependencies:$c(bu)}),MakeMoveVec:tu({type:Qc(iu()),elements:$c(vu)}),Upgrade:tu({modules:$c(gu),dependencies:$c(bu),package:bu,ticket:vu}),$Intent:Ou}),Cu=mu({ImmOrOwnedObject:fu,SharedObject:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:fu}),Bu=mu({Object:Cu,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:bu,version:ru(Qc(yu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(yu))})}),Su=mu({Object:Cu,Pure:tu({bytes:gu})}),Pu=mu({None:Kc(!0),Epoch:yu}),ju=tu({version:Kc(2),sender:Zc(_u),expiration:Zc(Pu),gasData:Tu,inputs:$c(Bu),commands:$c(Iu)}),Au={MoveCall(e){const[t,r="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>cu(vu,e))),address:cu(vu,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:cu(vu,e),amounts:t.map((e=>cu(vu,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:cu(vu,e),sources:t.map((e=>cu(vu,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:pc(new Uint8Array(e)))),dependencies:t.map((e=>lu(e)))}}),Upgrade:({modules:e,dependencies:t,package:r,ticket:s})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:pc(new Uint8Array(e)))),dependencies:t.map((e=>lu(e))),package:r,ticket:cu(vu,s)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>cu(vu,e)))}}),Intent:({name:e,inputs:t={},data:r={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>cu(vu,e))):cu(vu,t)]))),data:r}})},ku=/^vector<(.+)>$/,Uu=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class Nu{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(ku);if(r)return{vector:Nu.parseFromStr(r[1],t)};const s=e.match(Uu);if(s)return{struct:{address:t?pu(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:Nu.parseStructTypeArgs(s[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e).map((e=>Nu.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${Nu.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(Nu.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}const Du=tu({digest:iu(),objectId:iu(),version:ou([uu(eu(),Xc()),iu(),zc()])}),Ru=mu({ImmOrOwned:Du,Shared:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:Du}),Yu=mu({Object:Ru,Pure:$c(uu(eu(),Xc()))}),Vu=ou([tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:ru(Kc("object"))}),tu({kind:Kc("Input"),index:uu(eu(),Xc()),value:du(),type:Kc("pure")})]),Ju=ou([tu({Epoch:uu(eu(),Xc())}),tu({None:Qc(Kc(!0))})]),Mu=uu(ou([eu(),iu(),zc()]),Fc((e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}))),Fu=ou([tu({bool:Qc(Kc(!0))}),tu({u8:Qc(Kc(!0))}),tu({u64:Qc(Kc(!0))}),tu({u128:Qc(Kc(!0))}),tu({address:Qc(Kc(!0))}),tu({signer:Qc(Kc(!0))}),tu({vector:Hc((()=>Fu))}),tu({struct:Hc((()=>Xu))}),tu({u16:Qc(Kc(!0))}),tu({u32:Qc(Kc(!0))}),tu({u256:Qc(Kc(!0))})]),Xu=tu({address:iu(),module:iu(),name:iu(),typeParams:$c(Fu)}),qu=tu({budget:ru(Mu),price:ru(Mu),payment:ru($c(Du)),owner:ru(iu())}),Lu=ou([Vu,tu({kind:Kc("GasCoin")}),tu({kind:Kc("Result"),index:uu(eu(),Xc())}),tu({kind:Kc("NestedResult"),index:uu(eu(),Xc()),resultIndex:uu(eu(),Xc())})]),Gu=tu({kind:Kc("MoveCall"),target:uu(iu(),Fc((e=>3===e.split("::").length))),typeArguments:$c(iu()),arguments:$c(Lu)}),$u=tu({kind:Kc("TransferObjects"),objects:$c(Lu),address:Lu}),zu=tu({kind:Kc("SplitCoins"),coin:Lu,amounts:$c(Lu)}),Wu=tu({kind:Kc("MergeCoins"),destination:Lu,sources:$c(Lu)}),Hu=tu({kind:Kc("MakeMoveVec"),type:ou([tu({Some:Fu}),tu({None:Qc(Kc(!0))})]),objects:$c(Lu)}),Ku=ou([Gu,$u,zu,Wu,tu({kind:Kc("Publish"),modules:$c($c(uu(eu(),Xc()))),dependencies:$c(iu())}),tu({kind:Kc("Upgrade"),modules:$c($c(uu(eu(),Xc()))),dependencies:$c(iu()),packageId:iu(),ticket:Lu}),Hu]);function Qu(e){const t=e.inputs.map(((e,t)=>{if(e.Object)return{kind:"Input",index:t,value:{Object:e.Object.ImmOrOwnedObject?{ImmOrOwned:e.Object.ImmOrOwnedObject}:e.Object.Receiving?{Receiving:{digest:e.Object.Receiving.digest,version:e.Object.Receiving.version,objectId:e.Object.Receiving.objectId}}:{Shared:{mutable:e.Object.SharedObject.mutable,initialSharedVersion:e.Object.SharedObject.initialSharedVersion,objectId:e.Object.SharedObject.objectId}}},type:"object"};if(e.Pure)return{kind:"Input",index:t,value:{Pure:Array.from(uc(e.Pure.bytes))},type:"pure"};if(e.UnresolvedPure)return{kind:"Input",type:"pure",index:t,value:e.UnresolvedPure.value};if(e.UnresolvedObject)return{kind:"Input",type:"object",index:t,value:e.UnresolvedObject.objectId};throw new Error("Invalid input")}));return{version:1,sender:e.sender??void 0,expiration:"Epoch"===e.expiration?.$kind?{Epoch:Number(e.expiration.Epoch)}:e.expiration?{None:!0}:null,gasConfig:{owner:e.gasData.owner??void 0,budget:e.gasData.budget??void 0,price:e.gasData.price??void 0,payment:e.gasData.payment??void 0},inputs:t,transactions:e.commands.map((e=>{if(e.MakeMoveVec)return{kind:"MakeMoveVec",type:null===e.MakeMoveVec.type?{None:!0}:{Some:Nu.parseFromStr(e.MakeMoveVec.type)},objects:e.MakeMoveVec.elements.map((e=>Zu(e,t)))};if(e.MergeCoins)return{kind:"MergeCoins",destination:Zu(e.MergeCoins.destination,t),sources:e.MergeCoins.sources.map((e=>Zu(e,t)))};if(e.MoveCall)return{kind:"MoveCall",target:`${e.MoveCall.package}::${e.MoveCall.module}::${e.MoveCall.function}`,typeArguments:e.MoveCall.typeArguments,arguments:e.MoveCall.arguments.map((e=>Zu(e,t)))};if(e.Publish)return{kind:"Publish",modules:e.Publish.modules.map((e=>Array.from(uc(e)))),dependencies:e.Publish.dependencies};if(e.SplitCoins)return{kind:"SplitCoins",coin:Zu(e.SplitCoins.coin,t),amounts:e.SplitCoins.amounts.map((e=>Zu(e,t)))};if(e.TransferObjects)return{kind:"TransferObjects",objects:e.TransferObjects.objects.map((e=>Zu(e,t))),address:Zu(e.TransferObjects.address,t)};if(e.Upgrade)return{kind:"Upgrade",modules:e.Upgrade.modules.map((e=>Array.from(uc(e)))),dependencies:e.Upgrade.dependencies,packageId:e.Upgrade.package,ticket:Zu(e.Upgrade.ticket,t)};throw new Error(`Unknown transaction ${Object.keys(e)}`)}))}}function Zu(e,t){if("GasCoin"===e.$kind)return{kind:"GasCoin"};if("Result"===e.$kind)return{kind:"Result",index:e.Result};if("NestedResult"===e.$kind)return{kind:"NestedResult",index:e.NestedResult[0],resultIndex:e.NestedResult[1]};if("Input"===e.$kind)return t[e.Input];throw new Error(`Invalid argument ${Object.keys(e)}`)}function eh(e){switch(e.kind){case"GasCoin":return{GasCoin:!0};case"Result":return{Result:e.index};case"NestedResult":return{NestedResult:[e.index,e.resultIndex]};case"Input":return{Input:e.index}}}function th(e){return ou(Object.entries(e).map((([e,t])=>tu({[e]:t}))))}tu({version:Kc(1),sender:ru(iu()),expiration:Zc(Ju),gasConfig:qu,inputs:$c(Vu),transactions:$c(Ku)});const rh=th({GasCoin:Kc(!0),Input:uu(eu(),Xc()),Result:uu(eu(),Xc()),NestedResult:nu([uu(eu(),Xc()),uu(eu(),Xc())])}),sh=tu({budget:Qc(yu),price:Qc(yu),owner:Qc(_u),payment:Qc($c(fu))}),ih=tu({package:bu,module:iu(),function:iu(),typeArguments:$c(iu()),arguments:$c(rh)}),nh=tu({name:iu(),inputs:su(iu(),ou([rh,$c(rh)])),data:su(iu(),du())}),ah=th({MoveCall:ih,TransferObjects:tu({objects:$c(rh),address:rh}),SplitCoins:tu({coin:rh,amounts:$c(rh)}),MergeCoins:tu({destination:rh,sources:$c(rh)}),Publish:tu({modules:$c(gu),dependencies:$c(bu)}),MakeMoveVec:tu({type:Qc(iu()),elements:$c(rh)}),Upgrade:tu({modules:$c(gu),dependencies:$c(bu),package:bu,ticket:rh}),$Intent:nh}),oh=th({ImmOrOwnedObject:fu,SharedObject:tu({objectId:bu,initialSharedVersion:yu,mutable:Wc()}),Receiving:fu}),dh=th({Object:oh,Pure:tu({bytes:gu}),UnresolvedPure:tu({value:du()}),UnresolvedObject:tu({objectId:bu,version:ru(Qc(yu)),digest:ru(Qc(iu())),initialSharedVersion:ru(Qc(yu))})}),ch=th({None:Kc(!0),Epoch:yu}),uh=tu({version:Kc(2),sender:Zc(_u),expiration:Zc(ch),gasData:sh,inputs:$c(dh),commands:$c(ah)}),hh=function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?pc(e):e.toBase64()}}},ph=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:r,objectId:pu(e)}}}),lh=({objectId:e,mutable:t,initialSharedVersion:r})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:r,objectId:pu(e)}}}),mh=({objectId:e,digest:t,version:r})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:r,objectId:pu(e)}}}),_h={u8:e=>Dc({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>Dc({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>Dc({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>Rc({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>Rc({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>Rc({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>Nc({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>function({serialize:e,...t}){const r=new jc({...t,serialize:e,write:(e,t)=>{for(const s of r.serialize(e).toBytes())t.write8(s)}});return r}({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(yc(e)),...e}),bytes:(e,t)=>Nc({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let s=0;s<e;s++)r.write8(t[s]??0)},...t,validate:r=>{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>function({toBytes:e,fromBytes:t,...r}){return new jc({...r,read:e=>{const r=e.readULEB(),s=e.readBytes(r);return t(s)},write:(t,r)=>{const s=e(t);r.writeULEB(s.length);for(let e=0;e<s.length;e++)r.write8(s[e])},serialize:t=>{const r=e(t),s=yc(r.length),i=new Uint8Array(s.length+r.length);return i.set(s,0),i.set(r,s.length),i},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new jc({name:`${t.name}[${e}]`,read:r=>{const s=new Array(e);for(let i=0;i<e;i++)s[i]=t.read(r);return s},write:(e,r)=>{for(const s of e)t.write(s,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>_h.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new jc({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),s=new Array(r);for(let i=0;i<r;i++)s[i]=e.read(t);return s},write:(t,r)=>{r.writeULEB(t.length);for(const s of t)e.write(s,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new jc({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let s=0;s<e.length;s++){const i=e[s].serializedSize(t[s]);if(null==i)return null;r+=i}return r},read:t=>{const r=[];for(const s of e)r.push(s.read(t));return r},write:(t,r)=>{for(let s=0;s<e.length;s++)e[s].write(t[s],r)},...t,validate:r=>{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const s=Object.entries(t);return new jc({name:e,serializedSize:e=>{let t=0;for(const[r,i]of s){const s=i.serializedSize(e[r]);if(null==s)return null;t+=s}return t},read:e=>{const t={};for(const[r,i]of s)t[r]=i.read(e);return t},write:(e,t)=>{for(const[r,i]of s)i.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const s=Object.entries(t);return new jc({name:e,read:t=>{const r=t.readULEB(),i=s[r];if(!i)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[n,a]=i;return{[n]:a?.read(t)??!0,$kind:n}},write:(e,r)=>{const[i,n]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e<s.length;e++){const[t,a]=s[e];if(t===i)return r.writeULEB(e),void a?.write(n,r)}},...r,validate:s=>{if(r?.validate?.(s),"object"!=typeof s||null==s)throw new TypeError("Expected object, found "+typeof s);const i=Object.keys(s).filter((e=>void 0!==s[e]&&Object.hasOwn(t,e)));if(1!==i.length)throw new TypeError(`Expected object with one key, but found ${i.length} for type ${e}}`);const[n]=i;if(!Object.hasOwn(t,n))throw new TypeError(`Invalid enum variant ${n}`)}})},map:(e,t)=>_h.vector(_h.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,s]of e)t.set(r,s);return t}}),lazy:e=>function(e){let t=null;function r(){return t||(t=e()),t}return new jc({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}(e)},bh=_h.bytes(32).transform({validate:e=>{const t="string"==typeof e?e:gc(e);if(!t||!hu(pu(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?bc(pu(e)):e,output:e=>pu(gc(e))}),gh=_h.vector(_h.u8()).transform({name:"ObjectDigest",input:e=>_c(e),output:e=>mc(new Uint8Array(e)),validate:e=>{if(32!==_c(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),yh=_h.struct("SuiObjectRef",{objectId:bh,version:_h.u64(),digest:gh}),fh=_h.struct("SharedObjectRef",{objectId:bh,initialSharedVersion:_h.u64(),mutable:_h.bool()}),vh=_h.enum("ObjectArg",{ImmOrOwnedObject:yh,SharedObject:fh,Receiving:yh}),Th=_h.enum("CallArg",{Pure:_h.struct("Pure",{bytes:_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})}),Object:vh}),Eh=_h.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:_h.lazy((()=>Eh)),struct:_h.lazy((()=>Ph)),u16:null,u32:null,u256:null}),wh=Eh.transform({input:e=>"string"==typeof e?Nu.parseFromStr(e,!0):e,output:e=>Nu.tagToString(e)}),xh=_h.enum("Argument",{GasCoin:null,Input:_h.u16(),Result:_h.u16(),NestedResult:_h.tuple([_h.u16(),_h.u16()])}),Oh=_h.struct("ProgrammableMoveCall",{package:bh,module:_h.string(),function:_h.string(),typeArguments:_h.vector(wh),arguments:_h.vector(xh)}),Ih=_h.enum("Command",{MoveCall:Oh,TransferObjects:_h.struct("TransferObjects",{objects:_h.vector(xh),address:xh}),SplitCoins:_h.struct("SplitCoins",{coin:xh,amounts:_h.vector(xh)}),MergeCoins:_h.struct("MergeCoins",{destination:xh,sources:_h.vector(xh)}),Publish:_h.struct("Publish",{modules:_h.vector(_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})),dependencies:_h.vector(bh)}),MakeMoveVec:_h.struct("MakeMoveVec",{type:function(e){return _h.enum("Option",{None:null,Some:e})}(wh).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:_h.vector(xh)}),Upgrade:_h.struct("Upgrade",{modules:_h.vector(_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))})),dependencies:_h.vector(bh),package:bh,ticket:xh})}),Ch=_h.struct("ProgrammableTransaction",{inputs:_h.vector(Th),commands:_h.vector(Ih)}),Bh=_h.enum("TransactionKind",{ProgrammableTransaction:Ch,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Sh=_h.enum("TransactionExpiration",{None:null,Epoch:_h.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})}),Ph=_h.struct("StructTag",{address:bh,module:_h.string(),name:_h.string(),typeParams:_h.vector(Eh)}),jh=_h.struct("GasData",{payment:_h.vector(yh),owner:bh,price:_h.u64(),budget:_h.u64()}),Ah=_h.struct("TransactionDataV1",{kind:Bh,sender:bh,gasData:jh,expiration:Sh}),kh=_h.enum("TransactionData",{V1:Ah}),Uh=_h.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Nh=_h.enum("IntentVersion",{V0:null}),Dh=_h.enum("AppId",{Sui:null}),Rh=_h.struct("Intent",{scope:Uh,version:Nh,appId:Dh});function Yh(e){return _h.struct(`IntentMessage<${e.name}>`,{intent:Rh,value:e})}const Vh=_h.enum("CompressedSignature",{ED25519:_h.fixedArray(64,_h.u8()),Secp256k1:_h.fixedArray(64,_h.u8()),Secp256r1:_h.fixedArray(64,_h.u8()),ZkLogin:_h.vector(_h.u8())}),Jh=_h.enum("PublicKey",{ED25519:_h.fixedArray(32,_h.u8()),Secp256k1:_h.fixedArray(33,_h.u8()),Secp256r1:_h.fixedArray(33,_h.u8()),ZkLogin:_h.vector(_h.u8())}),Mh=_h.struct("MultiSigPkMap",{pubKey:Jh,weight:_h.u8()}),Fh=_h.struct("MultiSigPublicKey",{pk_map:_h.vector(Mh),threshold:_h.u16()}),Xh=_h.struct("MultiSig",{sigs:_h.vector(Vh),bitmap:_h.u16(),multisig_pk:Fh}),qh=_h.vector(_h.u8()).transform({input:e=>"string"==typeof e?uc(e):e,output:e=>pc(new Uint8Array(e))}),Lh=_h.struct("SenderSignedTransaction",{intentMessage:Yh(kh),txSignatures:_h.vector(qh)}),Gh=_h.vector(Lh,{name:"SenderSignedData"}),$h=_h.enum("PackageUpgradeError",{UnableToFetchPackage:_h.struct("UnableToFetchPackage",{packageId:bh}),NotAPackage:_h.struct("NotAPackage",{objectId:bh}),IncompatibleUpgrade:null,DigestDoesNotMatch:_h.struct("DigestDoesNotMatch",{digest:_h.vector(_h.u8())}),UnknownUpgradePolicy:_h.struct("UnknownUpgradePolicy",{policy:_h.u8()}),PackageIDDoesNotMatch:_h.struct("PackageIDDoesNotMatch",{packageId:bh,ticketId:bh})}),zh=_h.struct("ModuleId",{address:bh,name:_h.string()}),Wh=_h.struct("MoveLocation",{module:zh,function:_h.u16(),instruction:_h.u16(),functionName:_h.option(_h.string())}),Hh=_h.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:_h.struct("IndexOutOfBounds",{idx:_h.u16()}),SecondaryIndexOutOfBounds:_h.struct("SecondaryIndexOutOfBounds",{resultIdx:_h.u16(),secondaryIdx:_h.u16()}),InvalidResultArity:_h.struct("InvalidResultArity",{resultIdx:_h.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),Kh=_h.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),Qh=_h.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:_h.struct("MoveObjectTooBig",{objectSize:_h.u64(),maxObjectSize:_h.u64()}),MovePackageTooBig:_h.struct("MovePackageTooBig",{objectSize:_h.u64(),maxObjectSize:_h.u64()}),CircularObjectOwnership:_h.struct("CircularObjectOwnership",{object:bh}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:_h.option(Wh),MoveAbort:_h.tuple([Wh,_h.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:_h.struct("CommandArgumentError",{argIdx:_h.u16(),kind:Hh}),TypeArgumentError:_h.struct("TypeArgumentError",{argumentIdx:_h.u16(),kind:Kh}),UnusedValueWithoutDrop:_h.struct("UnusedValueWithoutDrop",{resultIdx:_h.u16(),secondaryIdx:_h.u16()}),InvalidPublicFunctionReturnType:_h.struct("InvalidPublicFunctionReturnType",{idx:_h.u16()}),InvalidTransferObject:null,EffectsTooLarge:_h.struct("EffectsTooLarge",{currentSize:_h.u64(),maxSize:_h.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:_h.struct("PackageUpgradeError",{upgradeError:$h}),WrittenObjectsTooLarge:_h.struct("WrittenObjectsTooLarge",{currentSize:_h.u64(),maxSize:_h.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),Zh=_h.enum("ExecutionStatus",{Success:null,Failed:_h.struct("ExecutionFailed",{error:Qh,command:_h.option(_h.u64())})}),ep=_h.struct("GasCostSummary",{computationCost:_h.u64(),storageCost:_h.u64(),storageRebate:_h.u64(),nonRefundableStorageFee:_h.u64()}),tp=_h.enum("Owner",{AddressOwner:bh,ObjectOwner:bh,Shared:_h.struct("Shared",{initialSharedVersion:_h.u64()}),Immutable:null}),rp=_h.struct("TransactionEffectsV1",{status:Zh,executedEpoch:_h.u64(),gasUsed:ep,modifiedAtVersions:_h.vector(_h.tuple([bh,_h.u64()])),sharedObjects:_h.vector(yh),transactionDigest:gh,created:_h.vector(_h.tuple([yh,tp])),mutated:_h.vector(_h.tuple([yh,tp])),unwrapped:_h.vector(_h.tuple([yh,tp])),deleted:_h.vector(yh),unwrappedThenDeleted:_h.vector(yh),wrapped:_h.vector(yh),gasObject:_h.tuple([yh,tp]),eventsDigest:_h.option(gh),dependencies:_h.vector(gh)}),sp=_h.tuple([_h.u64(),gh]),ip=_h.enum("ObjectIn",{NotExist:null,Exist:_h.tuple([sp,tp])}),np=_h.enum("ObjectOut",{NotExist:null,ObjectWrite:_h.tuple([gh,tp]),PackageWrite:sp}),ap=_h.enum("IDOperation",{None:null,Created:null,Deleted:null}),op=_h.struct("EffectsObjectChange",{inputState:ip,outputState:np,idOperation:ap}),dp=_h.enum("UnchangedSharedKind",{ReadOnlyRoot:sp,MutateDeleted:_h.u64(),ReadDeleted:_h.u64(),Cancelled:_h.u64(),PerEpochConfig:null}),cp=_h.struct("TransactionEffectsV2",{status:Zh,executedEpoch:_h.u64(),gasUsed:ep,transactionDigest:gh,gasObjectIndex:_h.option(_h.u32()),eventsDigest:_h.option(gh),dependencies:_h.vector(gh),lamportVersion:_h.u64(),changedObjects:_h.vector(_h.tuple([bh,op])),unchangedSharedObjects:_h.vector(_h.tuple([bh,dp])),auxDataDigest:_h.option(gh)}),up=_h.enum("TransactionEffects",{V1:rp,V2:cp}),hp={..._h,U8:_h.u8(),U16:_h.u16(),U32:_h.u32(),U64:_h.u64(),U128:_h.u128(),U256:_h.u256(),ULEB128:_h.uleb128(),Bool:_h.bool(),String:_h.string(),Address:bh,AppId:Dh,Argument:xh,CallArg:Th,CompressedSignature:Vh,GasData:jh,Intent:Rh,IntentMessage:Yh,IntentScope:Uh,IntentVersion:Nh,MultiSig:Xh,MultiSigPkMap:Mh,MultiSigPublicKey:Fh,ObjectArg:vh,ObjectDigest:gh,ProgrammableMoveCall:Oh,ProgrammableTransaction:Ch,PublicKey:Jh,SenderSignedData:Gh,SenderSignedTransaction:Lh,SharedObjectRef:fh,StructTag:Ph,SuiObjectRef:yh,Command:Ih,TransactionData:kh,TransactionDataV1:Ah,TransactionExpiration:Sh,TransactionKind:Bh,TypeTag:wh,TransactionEffects:up},pp=(BigInt(1e9),lu("0x6"),"0x2::sui::SUI");function lp(e){if("string"==typeof e)switch(e){case"address":return hp.Address;case"bool":return hp.Bool;case"u8":return hp.U8;case"u16":return hp.U16;case"u32":return hp.U32;case"u64":return hp.U64;case"u128":return hp.U128;case"u256":return hp.U256;default:throw new Error(`Unknown type signature ${e}`)}if("vector"in e){if("u8"===e.vector)return hp.vector(hp.U8).transform({input:e=>"string"==typeof e?(new TextEncoder).encode(e):e,output:e=>e});const t=lp(e.vector);return t?hp.vector(t):null}if("datatype"in e){const t=pu(e.datatype.package);if(t===pu("0x1")){if("ascii"===e.datatype.module&&"String"===e.datatype.type)return hp.String;if("string"===e.datatype.module&&"String"===e.datatype.type)return hp.String;if("option"===e.datatype.module&&"Option"===e.datatype.type){const t=lp(e.datatype.typeParameters[0]);return t?hp.vector(t):null}}if(t===pu("0x2")&&"object"===e.datatype.module&&"ID"===e.datatype.type)return hp.Address}return null}function mp(e){if("string"==typeof e)switch(e){case"Address":return"address";case"Bool":return"bool";case"U8":return"u8";case"U16":return"u16";case"U32":return"u32";case"U64":return"u64";case"U128":return"u128";case"U256":return"u256";default:throw new Error(`Unexpected type ${e}`)}if("Vector"in e)return{vector:mp(e.Vector)};if("Struct"in e)return{datatype:{package:e.Struct.address,module:e.Struct.module,type:e.Struct.name,typeParameters:e.Struct.typeArguments.map(mp)}};if("TypeParameter"in e)return{typeParameter:e.TypeParameter};throw new Error(`Unexpected type ${JSON.stringify(e)}`)}lu("0x5");async function _p(e,t,r){return await async function(e,t){const{inputs:r,commands:s}=e,i=[],n=new Set;s.forEach((t=>{if(t.MoveCall){if(t.MoveCall._argumentTypes)return;if(t.MoveCall.arguments.map((t=>"Input"===t.$kind?e.inputs[t.Input]:null)).some((e=>e?.UnresolvedPure||e?.UnresolvedObject))){const e=`${t.MoveCall.package}::${t.MoveCall.module}::${t.MoveCall.function}`;n.add(e),i.push(t.MoveCall)}}switch(t.$kind){case"SplitCoins":t.SplitCoins.amounts.forEach((t=>{bp(t,hp.U64,e)}));break;case"TransferObjects":bp(t.TransferObjects.address,hp.Address,e)}}));const a=new Map;if(n.size>0){const e=fp(t);await Promise.all([...n].map((async t=>{const[r,s,i]=t.split("::"),n=await e.getNormalizedMoveFunction({package:r,module:s,function:i});a.set(t,n.parameters.map((e=>function(e){return"object"==typeof e&&"Reference"in e?{ref:"&",body:mp(e.Reference)}:"object"==typeof e&&"MutableReference"in e?{ref:"&mut",body:mp(e.MutableReference)}:{ref:null,body:mp(e)}}(e))))})))}i.length&&await Promise.all(i.map((async e=>{const t=a.get(`${e.package}::${e.module}::${e.function}`);if(!t)return;const r=t.length>0&&function(e){const t="object"==typeof e.body&&"datatype"in e.body?e.body.datatype:null;return!!t&&pu(t.package)===pu("0x2")&&"tx_context"===t.module&&"TxContext"===t.type}(t.at(-1))?t.slice(0,t.length-1):t;e._argumentTypes=r}))),s.forEach((e=>{if(!e.MoveCall)return;const t=e.MoveCall,s=`${t.package}::${t.module}::${t.function}`,i=t._argumentTypes;if(i){if(i.length!==e.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${s}`);i.forEach(((e,s)=>{const i=t.arguments[s];if("Input"!==i.$kind)return;const n=r[i.Input];if(!n.UnresolvedPure&&!n.UnresolvedObject)return;const a=n.UnresolvedPure?.value??n.UnresolvedObject?.objectId,o=lp(e.body);if(o)return i.type="pure",void(r[r.indexOf(n)]=hh(o.serialize(a)));if("string"!=typeof a)throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(a,null,2)}`);i.type="object";const d=n.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:a}}:n;r[i.Input]=d}))}}))}(e,t),await async function(e,t){const r=e.inputs.filter((e=>e.UnresolvedObject&&!(e.UnresolvedObject.version||e.UnresolvedObject?.initialSharedVersion))),s=[...new Set(r.map((e=>lu(e.UnresolvedObject.objectId))))],i=s.length?(d=s,Array.from({length:Math.ceil(d.length/50)},((e,t)=>d.slice(50*t,50*t+50)))):[],n=(await Promise.all(i.map((e=>fp(t).multiGetObjects({ids:e,options:{showOwner:!0}}))))).flat(),a=new Map(s.map(((e,t)=>[e,n[t]]))),o=Array.from(a).filter((([e,t])=>t.error)).map((([e,t])=>JSON.stringify(t.error)));var d;if(o.length)throw new Error(`The following input objects are invalid: ${o.join(", ")}`);const c=n.map((e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,r=t&&"object"==typeof t&&"Shared"in t?t.Shared.initial_shared_version:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:r}})),u=new Map(s.map(((e,t)=>[e,c[t]])));for(const[t,r]of e.inputs.entries()){if(!r.UnresolvedObject)continue;let s;const i=pu(r.UnresolvedObject.objectId),n=u.get(i);r.UnresolvedObject.initialSharedVersion??n?.initialSharedVersion?s=lh({objectId:i,initialSharedVersion:r.UnresolvedObject.initialSharedVersion||n?.initialSharedVersion,mutable:gp(e,t)}):yp(e,t)&&(s=mh({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})),e.inputs[e.inputs.indexOf(r)]=s??ph({objectId:i,digest:r.UnresolvedObject.digest??n?.digest,version:r.UnresolvedObject.version??n?.version})}}(e,t),t.onlyTransactionKind||(await async function(e,t){e.gasConfig.price||(e.gasConfig.price=String(await fp(t).getReferenceGasPrice()))}(e,t),await async function(e,t){if(e.gasConfig.budget)return;const r=await fp(t).dryRunTransactionBlock({transactionBlock:e.build({overrides:{gasData:{budget:String(5e10),payment:[]}}})});if("success"!==r.effects.status.status)throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const s=1000n*BigInt(e.gasConfig.price||1n),i=BigInt(r.effects.gasUsed.computationCost)+s,n=i+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);e.gasConfig.budget=String(n>i?n:i)}(e,t),await async function(e,t){if(!e.gasConfig.payment){const r=(await fp(t).getCoins({owner:e.gasConfig.owner||e.sender,coinType:pp})).data.filter((t=>!e.inputs.find((e=>!!e.Object?.ImmOrOwnedObject&&t.coinObjectId===e.Object.ImmOrOwnedObject.objectId)))).map((e=>({objectId:e.coinObjectId,digest:e.digest,version:e.version})));if(!r.length)throw new Error("No valid gas coins found for the transaction.");e.gasConfig.payment=r.map((e=>cu(fu,e)))}}(e,t)),await function(e){e.inputs.forEach(((e,t)=>{if("Object"!==e.$kind&&"Pure"!==e.$kind)throw new Error(`Input at index ${t} has not been resolved. Expected a Pure or Object input, but found ${JSON.stringify(e)}`)}))}(e),await r()}function bp(e,t,r){if("Input"!==e.$kind)return;const s=r.inputs[e.Input];"UnresolvedPure"===s.$kind&&(r.inputs[e.Input]=hh(t.serialize(s.UnresolvedPure.value)))}function gp(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r="&"!==t.MoveCall._argumentTypes[s].ref||r}"MakeMoveVec"!==t.$kind&&"MergeCoins"!==t.$kind&&"SplitCoins"!==t.$kind||(r=!0)})),r}function yp(e,t){let r=!1;return e.getInputUses(t,((e,t)=>{if(t.MoveCall&&t.MoveCall._argumentTypes){const s=t.MoveCall.arguments.indexOf(e);r=function(e){return"object"==typeof e.body&&"datatype"in e.body&&("0x2"===e.body.datatype.package&&"transfer"===e.body.datatype.module&&"Receiving"===e.body.datatype.type)}(t.MoveCall._argumentTypes[s])||r}})),r}function fp(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}function vp(e){function t(t,r){if("string"==typeof t)return e(Tp(t).serialize(r));if(t instanceof Uint8Array||kc(t))return e(t);throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value")}return t.u8=t=>e(hp.U8.serialize(t)),t.u16=t=>e(hp.U16.serialize(t)),t.u32=t=>e(hp.U32.serialize(t)),t.u64=t=>e(hp.U64.serialize(t)),t.u128=t=>e(hp.U128.serialize(t)),t.u256=t=>e(hp.U256.serialize(t)),t.bool=t=>e(hp.Bool.serialize(t)),t.string=t=>e(hp.String.serialize(t)),t.address=t=>e(hp.Address.serialize(t)),t.id=t.address,t.vector=(t,r)=>e(hp.vector(Tp(t)).serialize(r)),t.option=(t,r)=>e(hp.option(Tp(t)).serialize(r)),t}function Tp(e){switch(e){case"u8":return hp.u8();case"u16":return hp.u16();case"u32":return hp.u32();case"u64":return hp.u64();case"u128":return hp.u128();case"u256":return hp.u256();case"bool":return hp.bool();case"string":return hp.string();case"id":case"address":return hp.Address}const t=e.match(/^(vector|option)<(.+)>$/);if(t){const[e,r]=t.slice(1);return"vector"===e?hp.vector(Tp(r)):hp.option(Tp(r))}throw new Error(`Invalid Pure type name: ${e}`)}function Ep(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wp(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xp(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Op(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}const Ip=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Cp(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Bp=Ip?e=>e:e=>Cp(e);function Sp(e){for(let t=0;t<e.length;t++)e[t]=Cp(e[t])}function Pp(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),wp(e),e}class jp{clone(){return this._cloneInto()}}function Ap(e){const t=(t,r)=>e(r).update(Pp(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}const kp=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]);class Up extends jp{constructor(e,t,r={},s,i,n){if(super(),this.blockLen=e,this.outputLen=t,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,Ep(e),Ep(t),Ep(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");if(void 0!==r.key&&(r.key.length<1||r.key.length>s))throw new Error("key length must be undefined or 1.."+s);if(void 0!==r.salt&&r.salt.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==r.personalization&&r.personalization.length!==n)throw new Error("personalization must be undefined or "+n);this.buffer=new Uint8Array(e),this.buffer32=Op(this.buffer)}update(e){xp(this);const{blockLen:t,buffer:r,buffer32:s}=this,i=(e=Pp(e)).length,n=e.byteOffset,a=e.buffer;for(let o=0;o<i;){this.pos===t&&(Ip||Sp(s),this.compress(s,0,!1),Ip||Sp(s),this.pos=0);const d=Math.min(t-this.pos,i-o),c=n+o;if(d!==t||c%4||!(o+d<i))r.set(e.subarray(o,o+d),this.pos),this.pos+=d,this.length+=d,o+=d;else{const e=new Uint32Array(a,c,Math.floor((i-o)/4));Ip||Sp(e);for(let r=0;o+t<i;r+=s.length,o+=t)this.length+=t,this.compress(e,r,!1);Ip||Sp(e)}}return this}digestInto(e){xp(this),function(e,t){wp(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this);const{pos:t,buffer32:r}=this;this.finished=!0,this.buffer.subarray(t).fill(0),Ip||Sp(r),this.compress(r,0,!0),Ip||Sp(r);const s=Op(e);this.get().forEach(((e,t)=>s[t]=Bp(e)))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){const{buffer:t,length:r,finished:s,destroyed:i,outputLen:n,pos:a}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.length=r,e.finished=s,e.destroyed=i,e.outputLen=n,e.buffer.set(t),e.pos=a,e}}const Np=BigInt(2**32-1),Dp=BigInt(32);function Rp(e,t=!1){return t?{h:Number(e&Np),l:Number(e>>Dp&Np)}:{h:0|Number(e>>Dp&Np),l:0|Number(e&Np)}}const Yp={fromBig:Rp,split:function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:a}=Rp(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]},toBig:(e,t)=>BigInt(e>>>0)<<Dp|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,s){const i=(t>>>0)+(s>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,s)=>t+r+s+(e/2**32|0)|0,add4L:(e,t,r,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),add4H:(e,t,r,s,i)=>t+r+s+i+(e/2**32|0)|0,add5H:(e,t,r,s,i,n)=>t+r+s+i+n+(e/2**32|0)|0,add5L:(e,t,r,s,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)+(i>>>0)},Vp=Yp,Jp=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Mp=new Uint32Array(32);function Fp(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Mp[2*e],c=Mp[2*e+1],u=Mp[2*t],h=Mp[2*t+1],p=Mp[2*r],l=Mp[2*r+1],m=Mp[2*s],_=Mp[2*s+1],b=Vp.add3L(d,u,a);c=Vp.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Vp.rotr32H(_,m),Dl:Vp.rotr32L(_,m)}),({h:l,l:p}=Vp.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Vp.rotrSH(h,u,24),Bl:Vp.rotrSL(h,u,24)}),Mp[2*e]=d,Mp[2*e+1]=c,Mp[2*t]=u,Mp[2*t+1]=h,Mp[2*r]=p,Mp[2*r+1]=l,Mp[2*s]=m,Mp[2*s+1]=_}function Xp(e,t,r,s,i,n){const a=i[n],o=i[n+1];let d=Mp[2*e],c=Mp[2*e+1],u=Mp[2*t],h=Mp[2*t+1],p=Mp[2*r],l=Mp[2*r+1],m=Mp[2*s],_=Mp[2*s+1],b=Vp.add3L(d,u,a);c=Vp.add3H(b,c,h,o),d=0|b,({Dh:_,Dl:m}={Dh:_^c,Dl:m^d}),({Dh:_,Dl:m}={Dh:Vp.rotrSH(_,m,16),Dl:Vp.rotrSL(_,m,16)}),({h:l,l:p}=Vp.add(l,p,_,m)),({Bh:h,Bl:u}={Bh:h^l,Bl:u^p}),({Bh:h,Bl:u}={Bh:Vp.rotrBH(h,u,63),Bl:Vp.rotrBL(h,u,63)}),Mp[2*e]=d,Mp[2*e+1]=c,Mp[2*t]=u,Mp[2*t+1]=h,Mp[2*r]=p,Mp[2*r+1]=l,Mp[2*s]=m,Mp[2*s+1]=_}class qp extends Up{constructor(e={}){super(128,void 0===e.dkLen?64:e.dkLen,e,64,16,16),this.v0l=0|Jp[0],this.v0h=0|Jp[1],this.v1l=0|Jp[2],this.v1h=0|Jp[3],this.v2l=0|Jp[4],this.v2h=0|Jp[5],this.v3l=0|Jp[6],this.v3h=0|Jp[7],this.v4l=0|Jp[8],this.v4h=0|Jp[9],this.v5l=0|Jp[10],this.v5h=0|Jp[11],this.v6l=0|Jp[12],this.v6h=0|Jp[13],this.v7l=0|Jp[14],this.v7h=0|Jp[15];const t=e.key?e.key.length:0;if(this.v0l^=this.outputLen|t<<8|65536|1<<24,e.salt){const t=Op(Pp(e.salt));this.v4l^=Bp(t[0]),this.v4h^=Bp(t[1]),this.v5l^=Bp(t[2]),this.v5h^=Bp(t[3])}if(e.personalization){const t=Op(Pp(e.personalization));this.v6l^=Bp(t[0]),this.v6h^=Bp(t[1]),this.v7l^=Bp(t[2]),this.v7h^=Bp(t[3])}if(e.key){const t=new Uint8Array(this.blockLen);t.set(Pp(e.key)),this.update(t)}}get(){let{v0l:e,v0h:t,v1l:r,v1h:s,v2l:i,v2h:n,v3l:a,v3h:o,v4l:d,v4h:c,v5l:u,v5h:h,v6l:p,v6h:l,v7l:m,v7h:_}=this;return[e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_]}set(e,t,r,s,i,n,a,o,d,c,u,h,p,l,m,_){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|s,this.v2l=0|i,this.v2h=0|n,this.v3l=0|a,this.v3h=0|o,this.v4l=0|d,this.v4h=0|c,this.v5l=0|u,this.v5h=0|h,this.v6l=0|p,this.v6h=0|l,this.v7l=0|m,this.v7h=0|_}compress(e,t,r){this.get().forEach(((e,t)=>Mp[t]=e)),Mp.set(Jp,16);let{h:s,l:i}=Vp.fromBig(BigInt(this.length));Mp[24]=Jp[8]^i,Mp[25]=Jp[9]^s,r&&(Mp[28]=~Mp[28],Mp[29]=~Mp[29]);let n=0;const a=kp;for(let r=0;r<12;r++)Fp(0,4,8,12,e,t+2*a[n++]),Xp(0,4,8,12,e,t+2*a[n++]),Fp(1,5,9,13,e,t+2*a[n++]),Xp(1,5,9,13,e,t+2*a[n++]),Fp(2,6,10,14,e,t+2*a[n++]),Xp(2,6,10,14,e,t+2*a[n++]),Fp(3,7,11,15,e,t+2*a[n++]),Xp(3,7,11,15,e,t+2*a[n++]),Fp(0,5,10,15,e,t+2*a[n++]),Xp(0,5,10,15,e,t+2*a[n++]),Fp(1,6,11,12,e,t+2*a[n++]),Xp(1,6,11,12,e,t+2*a[n++]),Fp(2,7,8,13,e,t+2*a[n++]),Xp(2,7,8,13,e,t+2*a[n++]),Fp(3,4,9,14,e,t+2*a[n++]),Xp(3,4,9,14,e,t+2*a[n++]);this.v0l^=Mp[0]^Mp[16],this.v0h^=Mp[1]^Mp[17],this.v1l^=Mp[2]^Mp[18],this.v1h^=Mp[3]^Mp[19],this.v2l^=Mp[4]^Mp[20],this.v2h^=Mp[5]^Mp[21],this.v3l^=Mp[6]^Mp[22],this.v3h^=Mp[7]^Mp[23],this.v4l^=Mp[8]^Mp[24],this.v4h^=Mp[9]^Mp[25],this.v5l^=Mp[10]^Mp[26],this.v5h^=Mp[11]^Mp[27],this.v6l^=Mp[12]^Mp[28],this.v6h^=Mp[13]^Mp[29],this.v7l^=Mp[14]^Mp[30],this.v7h^=Mp[15]^Mp[31],Mp.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Lp=Ap((e=>new qp(e)));function Gp(e){return pu(e).replace("0x","")}class $p{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=hp.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return $p.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=hp.TransactionData.parse(e),r=t?.V1,s=r.kind.ProgrammableTransaction;if(!r||!s)throw new Error("Unable to deserialize from bytes.");return $p.restore({version:2,sender:r.sender,expiration:r.expiration,gasData:r.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new $p(cu(ju,e)):new $p(cu(ju,function(e){return cu(ju,{version:2,sender:e.sender??null,expiration:e.expiration?"Epoch"in e.expiration?{Epoch:e.expiration.Epoch}:{None:!0}:null,gasData:{owner:e.gasConfig.owner??null,budget:e.gasConfig.budget?.toString()??null,price:e.gasConfig.price?.toString()??null,payment:e.gasConfig.payment?.map((e=>({digest:e.digest,objectId:e.objectId,version:e.version.toString()})))??null},inputs:e.inputs.map((e=>{if("Input"===e.kind){if(Gc(Yu,e.value)){const t=cu(Yu,e.value);if(t.Object){if(t.Object.ImmOrOwned)return{Object:{ImmOrOwnedObject:{objectId:t.Object.ImmOrOwned.objectId,version:String(t.Object.ImmOrOwned.version),digest:t.Object.ImmOrOwned.digest}}};if(t.Object.Shared)return{Object:{SharedObject:{mutable:t.Object.Shared.mutable??null,initialSharedVersion:t.Object.Shared.initialSharedVersion,objectId:t.Object.Shared.objectId}}};if(t.Object.Receiving)return{Object:{Receiving:{digest:t.Object.Receiving.digest,version:String(t.Object.Receiving.version),objectId:t.Object.Receiving.objectId}}};throw new Error("Invalid object input")}return{Pure:{bytes:pc(new Uint8Array(t.Pure))}}}return"object"===e.type?{UnresolvedObject:{objectId:e.value}}:{UnresolvedPure:{value:e.value}}}throw new Error("Invalid input")})),commands:e.transactions.map((e=>{switch(e.kind){case"MakeMoveVec":return{MakeMoveVec:{type:"Some"in e.type?Nu.tagToString(e.type.Some):null,elements:e.objects.map((e=>eh(e)))}};case"MergeCoins":return{MergeCoins:{destination:eh(e.destination),sources:e.sources.map((e=>eh(e)))}};case"MoveCall":{const[t,r,s]=e.target.split("::");return{MoveCall:{package:t,module:r,function:s,typeArguments:e.typeArguments,arguments:e.arguments.map((e=>eh(e)))}}}case"Publish":return{Publish:{modules:e.modules.map((e=>pc(Uint8Array.from(e)))),dependencies:e.dependencies}};case"SplitCoins":return{SplitCoins:{coin:eh(e.coin),amounts:e.amounts.map((e=>eh(e)))}};case"TransferObjects":return{TransferObjects:{objects:e.objects.map((e=>eh(e))),address:eh(e.address)}};case"Upgrade":return{Upgrade:{modules:e.modules.map((e=>pc(Uint8Array.from(e)))),dependencies:e.dependencies,package:e.packageId,ticket:eh(e.ticket)}}}throw new Error(`Unknown transaction ${Object.keys(e)}`)}))})}(e)))}static getDigestFromBytes(e){const t=function(e,t){const r=Array.from("TransactionData::").map((e=>e.charCodeAt(0))),s=new Uint8Array(r.length+t.length);return s.set(r),s.set(t,r.length),Lp(s,{dkLen:32})}(0,e);return mc(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:r}={}){const s=this.inputs,i=this.commands,n={ProgrammableTransaction:{inputs:s,commands:i}};if(r)return hp.TransactionKind.serialize(n,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,d={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!d.budget)throw new Error("Missing gas budget");if(!d.payment)throw new Error("Missing gas payment");if(!d.price)throw new Error("Missing gas price");const c={sender:Gp(o),expiration:a||{None:!0},gasData:{payment:d.payment,owner:Gp(this.gasData.owner??o),price:BigInt(d.price),budget:BigInt(d.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:i}}};return hp.TransactionData.serialize({V1:c},{maxSize:e}).toBytes()}addInput(e,t){const r=this.inputs.length;return this.inputs.push(t),{Input:r,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((r,s)=>("Input"===r.$kind&&r.Input===e&&t(r,s),r)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((r=>e(r,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((r=>e(r,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((r=>e(r,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((r=>e(r,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((r=>e(r,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const r=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,i]of Object.entries(r))t.$Intent.inputs[s]=Array.isArray(i)?i.map((r=>e(r,t))):e(i,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const r=t.length-1;this.commands.splice(e,1,...t),0!==r&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=r);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=r)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return $p.getDigestFromBytes(e)}snapshot(){return cu(ju,this)}}function zp(e){return"string"==typeof e?pu(e):e.Object?e.Object.ImmOrOwnedObject?pu(e.Object.ImmOrOwnedObject.objectId):e.Object.Receiving?pu(e.Object.Receiving.objectId):pu(e.Object.SharedObject.objectId):e.UnresolvedObject?pu(e.UnresolvedObject.objectId):void 0}var Wp,Hp,Kp,Qp,Zp,el,tl,rl,sl,il=e=>{throw TypeError(e)},nl=(e,t,r)=>t.has(e)||il("Cannot "+r),al=(e,t,r)=>(nl(e,t,"read from private field"),r?r.call(e):t.get(e)),ol=(e,t,r)=>t.has(e)?il("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),dl=(e,t,r,s)=>(nl(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),cl=(e,t,r)=>(nl(e,t,"access private method"),r);const ul=Symbol.for("@mysten/transaction"),hl={buildPlugins:[],serializationPlugins:[]},pl=Symbol.for("@mysten/transaction/registry");function ll(){try{const e=globalThis;return e[pl]||(e[pl]=hl),e[pl]}catch(e){return hl}}Wp=new WeakMap,Hp=new WeakMap,Kp=new WeakMap,Qp=new WeakMap,Zp=new WeakSet,el=function(e){return kc(e)?this.pure(e):cl(this,Zp,tl).call(this,e)},tl=function(e){return cu(vu,"function"==typeof e?e(this):e)},rl=async function(e){if(!e.onlyTransactionKind&&!al(this,Qp).sender)throw new Error("Missing transaction sender");await cl(this,Zp,sl).call(this,[...al(this,Hp),_p],e)},sl=async function(e,t){const r=s=>{if(s>=e.length)return()=>{};const i=e[s];return async()=>{const e=r(s+1);let n=!1,a=!1;if(await i(al(this,Qp),t,(async()=>{if(n)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);n=!0,await e(),a=!0})),!n)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await r(0)()};let ml=class e{constructor(){ol(this,Zp),ol(this,Wp),ol(this,Hp),ol(this,Kp,new Map),ol(this,Qp),this.object=function(e){function t(t){return e(t)}return t.system=()=>t("0x5"),t.clock=()=>t("0x6"),t.random=()=>t("0x8"),t.denyList=()=>t("0x403"),t}((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&Gc(vu,e))return e;const t=zp(e),r=al(this,Qp).inputs.find((e=>t===zp(e)));return r?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(r.Object.SharedObject.mutable=r.Object.SharedObject.mutable||e.Object.SharedObject.mutable),r?{$kind:"Input",Input:al(this,Qp).inputs.indexOf(r),type:"object"}:al(this,Qp).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:pu(e)}}:e)}));const e=ll();dl(this,Qp,new $p),dl(this,Hp,[...e.buildPlugins]),dl(this,Wp,[...e.serializationPlugins])}static fromKind(t){const r=new e;return dl(r,Qp,$p.fromKindBytes("string"==typeof t?uc(t):t)),r}static from(t){const r=new e;var s;return(s=t)&&"object"==typeof s&&!0===s[ul]?dl(r,Qp,new $p(t.getData())):"string"==typeof t&&t.startsWith("{")?dl(r,Qp,$p.restore(JSON.parse(t))):dl(r,Qp,$p.fromBytes("string"==typeof t?uc(t):t)),r}static registerGlobalSerializationPlugin(e){ll().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){ll().buildPlugins.push(e)}addSerializationPlugin(e){al(this,Wp).push(e)}addBuildPlugin(e){al(this,Hp).push(e)}addIntentResolver(e,t){if(al(this,Kp).has(e)&&al(this,Kp).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);al(this,Kp).set(e,t)}setSender(e){al(this,Qp).sender=e}setSenderIfNotSet(e){al(this,Qp).sender||(al(this,Qp).sender=e)}setExpiration(e){al(this,Qp).expiration=e?cu(Pu,e):null}setGasPrice(e){al(this,Qp).gasConfig.price=String(e)}setGasBudget(e){al(this,Qp).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==al(this,Qp).gasData.budget&&(al(this,Qp).gasConfig.budget=String(e))}setGasOwner(e){al(this,Qp).gasConfig.owner=e}setGasPayment(e){al(this,Qp).gasConfig.payment=e.map((e=>cu(fu,e)))}get blockData(){return Qu(al(this,Qp).snapshot())}getData(){return al(this,Qp).snapshot()}get[ul](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:vp((e=>kc(e)?al(this,Qp).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):al(this,Qp).addInput("pure",Gc(Su,e)?cu(Su,e):e instanceof Uint8Array?hh(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(ph(...e))}receivingRef(...e){return this.object(mh(...e))}sharedObjectRef(...e){return this.object(lh(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],r=r=>t[r]??(t[r]={$kind:"NestedResult",NestedResult:[e,r]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield r(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:r(s)}})}(al(this,Qp).commands.push(e)-1)}splitCoins(e,t){return this.add(Au.SplitCoins("string"==typeof e?this.object(e):cl(this,Zp,tl).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):cl(this,Zp,el).call(this,e)))))}mergeCoins(e,t){return this.add(Au.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(Au.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:r,ticket:s}){return this.add(Au.Upgrade({modules:e,dependencies:t,package:r,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(Au.MoveCall({...t,arguments:e?.map((e=>cl(this,Zp,el).call(this,e)))}))}transferObjects(e,t){return this.add(Au.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):cl(this,Zp,el).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(Au.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify(Qu(al(this,Qp).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify(cu(uh,al(this,Qp).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...r}=e,s=await this.build(r);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await cl(this,Zp,rl).call(this,e),al(this,Qp).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await cl(this,Zp,rl).call(this,e),al(this,Qp).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of al(this,Qp).commands)e.$Intent&&t.add(e.$Intent.name);const r=[...al(this,Wp)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!al(this,Kp).has(s))throw new Error(`Missing intent resolver for ${s}`);r.push(al(this,Kp).get(s))}await cl(this,Zp,sl).call(this,r,e)}};function _l(e){const t=[];return e?.objectChanges?.forEach((e=>{const r=e?.objectType,s=rc(r);s&&t.push({type:s,type_raw:r,object:e?.objectId,version:e?.version,owner:e?.owner,change:e.type})})),t}class bl{resouceObject;async operate(e,t,r){}constructor(){}async call(e){}async call_with_witness(e,t){if(e.guard.length>0){const r=await _d.Create([...e.guard]);if(r){const s=await r.done(e.witness);if(s){const e=new ml,r=new bd(e,s);return await this.operate(new ml,r?.get_object(),t),r.destroy(),await this.sign_and_commit(e,t)}}else Ba(Ca.Fail,"guard verify")}}async check_permission_and_call(e,t,r,s,i,n){var a=[];if(t.length>0||s){const r=await cc.Instance().get_address(n);r||Ba(Ca.InvalidParam,"check_permission_and_call: account invalid");const o=await nc({permission_object:e,address:r});s&&!o.owner&&Ba(Ca.noPermission,"owner"),i&&!o.admin&&Ba(Ca.noPermission,"admin"),t.forEach((e=>{const t=Qo.HasPermission(o,e);t?.has||Ba(Ca.noPermission,e),t?.guard&&a.push(t.guard)}))}if(r.length>0&&(a=a.concat(r)),a.length>0){const e=await _d.Create([...a]),t=e?e.future_fills():[];if(e||Ba(Ca.Fail,"guard parse"),e&&0===t.length){const t=await e.done();if(t){const e=new ml,r=new bd(e,t);return await this.operate(new ml,r?.get_object(),n),r.destroy(),await this.sign_and_commit(e,n)}}return{guard:[...a],witness:e.future_fills()}}return await this.exec()}async exec(e){const t=new ml;return await this.operate(t,void 0,e),await this.sign_and_commit(t,e)}async new_with_mark(e,t,r,s,i=[hd.Launch]){const n=Ga(r?.tags?[...r.tags,...i]:[...i]);if(this.resouceObject)vd.From(e,this.resouceObject).add(t,n,r?.name);else{const i=await cc.Instance().get_address(s);if(i){const s=await Md({address:i});s?.mark_object?vd.From(e,s.mark_object).add(t,n,r?.name):(this.resouceObject=yd.From(e).create_resource2(),vd.From(e,this.resouceObject).add(t,n,r?.name))}else Ba(Ca.InvalidParam,"account - "+s)}}async sign_and_commit(e,t){const r=await cc.Instance().get_pair(t,!0);return r||Ba(Ca.Fail,"account invalid"),this.resouceObject&&(vd.From(e,this.resouceObject).launch(),this.resouceObject=void 0),await $o.Client().signAndExecuteTransaction({transaction:e,signer:r,options:{showObjectChanges:!0}})}}class gl extends bl{data;constructor(e){super(),this.data=e}async call(e){var t=!1,r=!1;const s=this.data?.object?.address;return s&&co(s)?(void 0===this.data?.builder&&void 0===this.data?.admin||(t=!0),void 0===this.data?.permission&&void 0===this.data?.biz_permission||(r=!0),void 0!==this.data?.description&&(r=!0),await this.check_permission_and_call(s,[],[],t,r,e)):await this.exec(e)}async operate(e,t,r){let s;const i=this.data?.object?.address;if(s=i&&co(i)?Qo.From(e,i):Qo.New(e,this.data?.description??""),s){if(void 0!==this.data?.description&&this.data.object&&s?.set_description(this.data.description),void 0!==this.data?.admin)switch(this.data.admin?.op){case"add":s?.add_admin(this.data.admin.addresses);break;case"remove":s?.remove_admin(this.data.admin.addresses);break;case"set":s?.remove_admin([],!0),s?.add_admin(this.data.admin.addresses);break;case"removeall":s?.remove_admin([],!0)}if(void 0!==this.data?.biz_permission)switch(this.data.biz_permission.op){case"add":this.data.biz_permission.data.forEach((e=>{s?.add_bizPermission(e.index,e.name)}));break;case"remove":this.data.biz_permission.permissions.forEach((e=>{s?.remove_bizPermission(e)}))}if(void 0!==this.data?.permission)switch(this.data.permission.op){case"add entity":s?.add_entity(this.data.permission.entities);break;case"add permission":s?.add_entity3(this.data.permission.permissions);break;case"remove entity":s?.remove_entity(this.data.permission.addresses);break;case"remove permission":s?.remove_index(this.data.permission.address,this.data.permission.index);break;case"transfer permission":s?.transfer_permission(this.data.permission.from_address,this.data.permission.to_address)}void 0!==this.data?.builder&&s?.change_owner(this.data.builder),i||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}var yl=a(763);const fl=e=>yl.encode(e),vl=e=>yl.decode(e);function Tl(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}const El=8192;function wl(e){if(e.length<El)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=El){const s=e.slice(r,r+El);t+=String.fromCharCode(...s)}return btoa(t)}function xl(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,s=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(s)}function Ol(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}class Il{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:s}=function(e){let t=0,r=0,s=0;for(;;){let i=e[s];if(s+=1,t|=(127&i)<<r,!(128&i))break;r+=7}return{value:t,length:s}}(t);return this.shift(s),r}readVec(e){let t=this.readULEB(),r=[];for(let s=0;s<t;s++)r.push(e(this,s,t));return r}}class Cl{constructor({size:e=1024,maxSize:t,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t||e,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return Bl(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return Bl(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return Bl(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return function(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,s)=>t(this,r,s,e.length))),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return function(e,t){switch(t){case"base58":return fl(e);case"base64":return wl(e);case"hex":return Ol(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(this.toBytes(),e)}}function Bl(e,t){let r=new Uint8Array(t),s=0;for(;e>0;)r[s]=Number(e%BigInt(256)),e/=BigInt(256),s+=1;return r}var Sl,Pl,jl,Al,kl=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ul=(e,t,r)=>(kl(e,t,"read from private field"),r?r.call(e):t.get(e)),Nl=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Dl=(e,t,r,s)=>(kl(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);const Rl=class{constructor(e){Nl(this,Sl,void 0),Nl(this,Pl,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Dl(this,Sl,e.write),Dl(this,Pl,e.serialize??((e,t)=>{const r=new Cl({size:this.serializedSize(e)??void 0,...t});return Ul(this,Sl).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),Ul(this,Sl).call(this,e,t)}serialize(e,t){return this.validate(e),new Jl(this,Ul(this,Pl).call(this,e,t))}parse(e){const t=new Il(e);return this.read(t)}transform({name:e,input:t,output:r}){return new Rl({name:e??this.name,read:e=>r(this.read(e)),write:(e,r)=>Ul(this,Sl).call(this,t(e),r),serializedSize:e=>this.serializedSize(t(e)),serialize:(e,r)=>Ul(this,Pl).call(this,t(e),r),validate:e=>this.validate(t(e))})}};let Yl=Rl;Sl=new WeakMap,Pl=new WeakMap;const Vl=Symbol.for("@mysten/serialized-bcs");class Jl{constructor(e,t){Nl(this,jl,void 0),Nl(this,Al,void 0),Dl(this,jl,e),Dl(this,Al,t)}get[Vl](){return!0}toBytes(){return Ul(this,Al)}toHex(){return Ol(Ul(this,Al))}toBase64(){return wl(Ul(this,Al))}toBase58(){return fl(Ul(this,Al))}parse(){return Ul(this,jl).parse(Ul(this,Al))}}jl=new WeakMap,Al=new WeakMap;const Ml=32,Fl=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Fl)return this.schema=e.schema,void(this.types=new Map(e.types));if(this.schema=e,this.registerAddressType(Fl.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);var t;!1!==e.withPrimitives&&((t=this).registerType(Xl.U8,(function(e,t){return e.write8(t)}),(function(e){return e.read8()}),(e=>e<256)),t.registerType(Xl.U16,(function(e,t){return e.write16(t)}),(function(e){return e.read16()}),(e=>e<65536)),t.registerType(Xl.U32,(function(e,t){return e.write32(t)}),(function(e){return e.read32()}),(e=>e<=4294967296n)),t.registerType(Xl.U64,(function(e,t){return e.write64(t)}),(function(e){return e.read64()})),t.registerType(Xl.U128,(function(e,t){return e.write128(t)}),(function(e){return e.read128()})),t.registerType(Xl.U256,(function(e,t){return e.write256(t)}),(function(e){return e.read256()})),t.registerType(Xl.BOOL,(function(e,t){return e.write8(t)}),(function(e){return"1"===e.read8().toString(10)})),t.registerType(Xl.STRING,(function(e,t){return e.writeVec(Array.from(t),((e,t)=>e.write8(t.charCodeAt(0))))}),(function(e){return e.readVec((e=>e.read8())).map((e=>String.fromCharCode(Number(e)))).join("")}),(e=>!0)),t.registerType(Xl.HEX,(function(e,t){return e.writeVec(Array.from(xl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return Ol(new Uint8Array(t))})),t.registerType(Xl.BASE58,(function(e,t){return e.writeVec(Array.from(vl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return fl(new Uint8Array(t))})),t.registerType(Xl.BASE64,(function(e,t){return e.writeVec(Array.from(Tl(t)),((e,t)=>e.write8(t)))}),(function(e){let t=e.readVec((e=>e.read8()));return wl(new Uint8Array(t))})))}tempKey(){return"bcs-struct-"+ ++this.counter}ser(e,t,r){if("string"==typeof e||Array.isArray(e)){const{name:s,params:i}=this.parseTypeName(e);return this.getTypeInterface(s).encode(this,t,r,i)}if("object"==typeof e){const s=this.tempKey();return new Fl(this).registerStructType(s,e).ser(s,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function. \n${JSON.stringify(e)}`)}de(e,t,r){if("string"==typeof t){if(!r)throw new Error("To pass a string to `bcs.de`, specify encoding");t=function(e,t){switch(t){case"base58":return vl(e);case"base64":return Tl(e);case"hex":return xl(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}(t,r)}if("string"==typeof e||Array.isArray(e)){const{name:r,params:s}=this.parseTypeName(e);return this.getTypeInterface(r).decode(this,t,s)}if("object"==typeof e){const s=new Fl(this),i=this.tempKey();return s.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function. \n${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,s=()=>!0){const{name:i,params:n}=this.parseTypeName(e);return this.types.set(i,{encode(e,t,r,s){const i=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return this._encodeRaw.call(e,new Cl(r),t,s,i)},decode(e,t,r){const s=n.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return this._decodeRaw.call(e,new Il(t),r,s)},_encodeRaw(e,r,n,a){if(s(r))return t.call(this,e,r,n,a);throw new Error(`Validation failed for type ${i}, data: ${r}`)},_decodeRaw(e,t,s){return r.call(this,e,t,s)}}),this}registerBcsType(e,t){return this.registerType(e,((e,r,s)=>{const i=s.map((e=>new Yl({name:String(e),write:(t,r)=>{const{name:i,params:n}=this.parseTypeName(e),a=this.getTypeInterface(i),o=n.reduce(((e,t,r)=>Object.assign(e,{[t]:s[r]})),{});return a._encodeRaw.call(this,r,t,n,o)},read:()=>{throw new Error("Not implemented")}})));return t(...i).write(r,e),e}),((e,r)=>{const s=r.map((e=>new Yl({name:String(e),write:(e,t)=>{throw new Error("Not implemented")},read:t=>{const{name:s,params:i}=this.parseTypeName(e),n=this.getTypeInterface(s),a=i.reduce(((e,t,s)=>Object.assign(e,{[t]:r[s]})),{});return n._decodeRaw.call(this,t,i,a)}})));return t(...s).read(e)})),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,(function(e,t){return Tl(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return wl(e.readBytes(t))}));case"hex":return this.registerType(e,(function(e,t){return xl(t).reduce(((e,t)=>e.write8(t)),e)}),(function(e){return Ol(e.readBytes(t))}));default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,(function(t,r,s,i){return t.writeVec(r,((t,r)=>{let n=s[0];if(!n)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:a,params:o}=this.parseTypeName(n);if(this.hasType(a))return this.getTypeInterface(a)._encodeRaw.call(this,t,r,o,i);if(!(a in i))throw new Error(`Unable to find a matching type definition for ${a} in vector; make sure you passed a generic`);let{name:d,params:c}=this.parseTypeName(i[a]);return this.getTypeInterface(d)._encodeRaw.call(this,t,r,c,i)}))}),(function(t,r,s){return t.readVec((t=>{let i=r[0];if(!i)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:n,params:a}=this.parseTypeName(i);if(this.hasType(n))return this.getTypeInterface(n)._decodeRaw.call(this,t,a,s);if(!(n in s))throw new Error(`Unable to find a matching type definition for ${n} in vector; make sure you passed a generic`);let{name:o,params:d}=this.parseTypeName(s[n]);return this.getTypeInterface(o)._decodeRaw.call(this,t,d,s)}))}))}registerStructType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t||t.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${t}`);if(a.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${a.length}`);for(let d of s){if(!(d in t))throw new Error(`Struct ${i} requires field ${d}:${r[d]}`);const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(a[r]);if(this.hasType(c)){this.getTypeInterface(c)._encodeRaw.call(this,e,t[d],u,o);continue}if(!(c in o))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(o[c]);this.getTypeInterface(h)._encodeRaw.call(this,e,t[d],p,o)}else this.getTypeInterface(s)._encodeRaw.call(this,e,t[d],c,o)}return e}),(function(e,t,a){if(t.length!==n.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${n.length}, got: ${t.length}`);let o={};for(let d of s){const{name:s,params:c}=this.parseTypeName(r[d]);if(n.includes(s)){const r=n.indexOf(s);let{name:c,params:u}=this.parseTypeName(t[r]);if(this.hasType(c)){o[d]=this.getTypeInterface(c)._decodeRaw.call(this,e,u,a);continue}if(!(c in a))throw new Error(`Unable to find a matching type definition for ${c} in ${i}; make sure you passed a generic`);let{name:h,params:p}=this.parseTypeName(a[c]);o[d]=this.getTypeInterface(h)._decodeRaw.call(this,e,p,a)}else o[d]=this.getTypeInterface(s)._decodeRaw.call(this,e,c,a)}return o}))}registerEnumType(e,t){for(let e in t){let r=this.tempKey(),s=t[e];null===s||Array.isArray(s)||"string"==typeof s||(t[e]=r,this.registerStructType(r,s))}let r=Object.freeze(t),s=Object.keys(r),{name:i,params:n}=this.parseTypeName(e);return this.registerType(e,(function(e,t,a,o){if(!t)throw new Error(`Unable to write enum "${i}", missing data.\nReceived: "${t}"`);if("object"!=typeof t)throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${s.join(" | ")}".\nReceived: "${JSON.stringify(t)}"`);let d=Object.keys(t)[0];if(void 0===d)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let c=s.indexOf(d);if(-1===c)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${s.join(" | ")}"; received "${d}"`);let u=s[c],h=r[u];if(e.write8(c),null===h)return e;let p=n.indexOf(h),l=-1===p?h:a[p];{let{name:r,params:s}=this.parseTypeName(l);return this.getTypeInterface(r)._encodeRaw.call(this,e,t[d],s,o)}}),(function(e,t,a){let o=e.readULEB(),d=s[o],c=r[d];if(-1===o)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${o}"`);if(null===c)return{[d]:!0};let u=n.indexOf(c),h=-1===u?c:t[u];{let{name:t,params:r}=this.parseTypeName(h);return{[d]:this.getTypeInterface(t)._decodeRaw.call(this,e,r,a)}}}))}getTypeInterface(e){let t=this.types.get(e);if("string"==typeof t){let e=[];for(;"string"==typeof t;){if(e.includes(t))throw new Error(`Recursive definition found: ${e.join(" -> ")} -> ${t}`);e.push(t),t=this.types.get(t)}}if(void 0===t)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[t,...r]=e;return{name:t,params:r}}if("string"!=typeof e)throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],s=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(-1===s&&-1===i)return{name:e,params:[]};if(-1===s||-1===i)throw new Error(`Unclosed generic in name '${e}'`);let n=e.slice(0,s),a=function(e,t=["<",">"]){const[r,s]=t,i=[];let n="",a=0;for(let t=0;t<e.length;t++){const o=e[t];o===r&&a++,o===s&&a--,0!==a||","!==o?n+=o:(i.push(n.trim()),n="")}return i.push(n.trim()),i}(e.slice(s+1,e.length-i-1),this.schema.genericSeparators);return{name:n,params:a}}};let Xl=Fl;function ql(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:Ml,addressEncoding:"hex"}}Xl.U8="u8",Xl.U16="u16",Xl.U32="u32",Xl.U64="u64",Xl.U128="u128",Xl.U256="u256",Xl.BOOL="bool",Xl.VECTOR="vector",Xl.ADDRESS="address",Xl.STRING="string",Xl.HEX="hex-string",Xl.BASE58="base58-string",Xl.BASE64="base64-string";class Ll extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"arbitration.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.fee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.arbitration),void 0!==this.data?.description&&n&&r.push(Ho.arbitration_description),void 0!==this.data?.bPaused&&r.push(Ho.arbitration_pause),null==this.data?.endpoint&&r.push(Ho.arbitration_endpoint),void 0!==this.data?.fee&&n&&r.push(Ho.arbitration_fee),void 0!==a&&n&&r.push(Ho.arbitration_treasury),void 0!==this.data?.guard&&r.push(Ho.arbitration_guard),void 0!==this.data?.voting_guard&&r.push(Ho.arbitration_voting_guard),void 0!==this.data?.arb_arbitration&&r.push(Ho.arbitration_arbitration),void 0!==this.data?.arb_new?.guard)if(co(this.data.arb_new.guard))t.push(this.data.arb_new.guard);else if(n){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Arbitration"===e.objects[0].type&&(s=e.objects[0])}s?.usage_guard&&t.push(s.usage_guard)}else this.data?.guard&&co(this.data?.guard)&&t.push(this.data.guard);return void 0!==this.data?.arb_vote&&r.push(Ho.treasury_receive),"string"==typeof this.data?.arb_vote?.voting_guard&&co(this.data?.arb_vote?.voting_guard)&&t.push(this.data?.arb_vote?.voting_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.fee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a?s=xd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.fee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i?i.get_object():a,r,i?void 0:t)}s=xd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",BigInt(this.data?.fee??0),n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;var c;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.fee&&o&&s?.set_fee(BigInt(this.data.fee),a),void 0!==d&&o&&s?.set_withdrawTreasury(d,a),void 0!==this.data?.arb_new){const t=BigInt(this.data.arb_new.data.fee),i=this.data?.arb_new.data;c=s?.arb({order:i.order,order_token_type:i.order_token_type,description:i.description,votable_proposition:i.votable_proposition,fee:t>BigInt(0)?await cc.Instance().get_coin_object(e,t,r,this.data.type_parameter):void 0},a)}if(void 0!==this.data?.arb_arbitration){const e=this.data.arb_arbitration.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_arbitration"),s?.arbitration({arb:e,feedback:this.data.arb_arbitration.feedback,indemnity:this.data.arb_arbitration.indemnity},a)}if(void 0!==this.data?.arb_vote){const e=this.data.arb_vote.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_vote"),s?.vote({arb:e,voting_guard:this.data.arb_vote.voting_guard,agrees:this.data.arb_vote.agrees},a)}if(void 0!==this.data?.arb_withdraw_fee){const e=this.data.arb_withdraw_fee.arb??c;e||Ba(Ca.Fail,"arb invalid: arb_withdraw_fee"),s?.withdraw_fee(e,this.data.arb_withdraw_fee.data,a)}if(c&&await this.new_with_mark(e,s?.arb_launch(c),this.data?.arb_new?.namedNew,r),void 0!==this.data?.voting_guard)switch(this.data.voting_guard.op){case"add":s?.add_voting_guard(this.data.voting_guard.data,a);break;case"remove":s?.remove_voting_guard(this.data.voting_guard.guards,!1,a);break;case"set":s?.remove_voting_guard([],!0,a),s?.add_voting_guard(this.data.voting_guard.data,a);break;case"removeall":s?.remove_voting_guard([],!0,a)}void 0!==this.data.guard&&s?.set_guard(this.data.guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),n&&await this.new_with_mark(e,n.launch(),this.data?.fee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Gl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"treasury.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.treasury),void 0!==this.data?.description&&n&&r.push(Ho.treasury_descritption),void 0!==this.data?.withdraw_mode&&r.push(Ho.treasury_withdraw_mode),null==this.data?.withdraw_guard&&r.push(Ho.treasury_withdraw_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit_guard&&r.push(Ho.treasury_deposit_guard),void 0!==this.data?.deposit?.guard)if(co(this.data.deposit.guard))t.push(this.data.deposit.guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}s?.deposit_guard&&t.push(s?.deposit_guard)}else this.data?.deposit_guard&&co(this.data?.deposit_guard)&&t.push(this.data.deposit_guard);if(void 0!==this.data?.receive&&r.push(Ho.treasury_receive),void 0!==this.data?.withdraw?.withdraw_guard){if("string"==typeof this.data.withdraw.withdraw_guard&&co(this.data.withdraw.withdraw_guard))t.push(this.data.withdraw.withdraw_guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Treasury"===e.objects[0].type&&(s=e.objects[0])}"string"==typeof s?.withdraw_guard&&t.push(s?.withdraw_guard)}}else r.push(Ho.treasury_withdraw);return await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&n&&co(n)?s=Td.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Td.New(e,this.data.type_parameter,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data.deposit){const t=await cc.Instance().get_coin_object(e,this.data.deposit.data.balance,r,this.data.type_parameter);if(t){const e=this.data.deposit.data?.index??0;s?.deposit({coin:t,index:BigInt(e),remark:this.data.deposit.data.remark??"",for_guard:this.data.deposit.data?.for_guard,for_object:this.data.deposit.data?.for_object})}}if(void 0!==this.data?.receive&&s?.receive(this.data.receive.payment,this.data.receive.received_object,n),void 0!==this.data?.withdraw&&s?.withdraw(this.data.withdraw,n),void 0!==this.data?.deposit_guard&&s?.set_deposit_guard(this.data.deposit_guard,n),void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"remove":s?.remove_withdraw_guard(this.data.withdraw_guard.guards,!1,n);break;case"set":s?.remove_withdraw_guard([],!0,n),this.data.withdraw_guard.data.forEach((e=>s?.add_withdraw_guard(e.guard,BigInt(e.amount),n)));break;case"removeall":s?.remove_withdraw_guard([],!0,n)}void 0!==this.data?.withdraw_mode&&s?.set_withdraw_mode(this.data.withdraw_mode,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class $l extends bl{data;constructor(e){super(),this.data=e}async call(e){if(co(this.data.new_permission)||Ba(Ca.InvalidParam,"CallObjectPermission_Data.new_permission"+this.data.new_permission),this.data?.objects.length>0)return await this.exec(e)}async operate(e,t){const r=await Jd({objects:this.data.objects,showContent:!0});r.objects?.forEach((t=>{switch(t.type){case"Demand":const r=t;Wo.From(e,Wo.parseObjectType(r.type_raw),r.permission,r.object).change_permission(this.data.new_permission);break;case"Machine":const s=t;Zo.From(e,s.permission,s.object).change_permission(this.data.new_permission);break;case"Service":const i=t;gd.From(e,gd.parseObjectType(i.type_raw),i.permission,i.object).change_permission(this.data.new_permission);break;case"Treasury":const n=t;Td.From(e,Td.parseObjectType(n.type_raw),n.permission,n.object).change_permission(this.data.new_permission);break;case"Arbitration":const a=t;xd.From(e,xd.parseObjectType(a.type_raw),a.permission,a.object).change_permission(this.data.new_permission);break;case"Repository":const o=t;md.From(e,o.permission,o.object).change_permission(this.data.new_permission)}}))}}class zl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data?.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"demand.type_parameter");const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.demand),void 0!==this.data?.description&&i&&r.push(Ho.demand_description),void 0!==this.data?.time_expire&&i&&r.push(Ho.demand_expand_time),void 0!==this.data?.guard&&r.push(Ho.demand_guard),"reward"===this.data?.bounty?.op&&r.push(Ho.demand_yes),"refund"===this.data?.bounty?.op&&r.push(Ho.demand_refund),void 0!==this.data?.present?.guard)if(co(this.data.present.guard))t.push(this.data.present.guard);else if(i){const e=await Jd({objects:[i],showContent:!0});if(e?.objects&&"Demand"===e?.objects[0]?.type){const r=e?.objects[0];r?.guard&&t.push(r?.guard.object)}}else this.data?.guard?.address&&co(this.data?.guard.address)&&t.push(this.data.guard.address);return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.type_parameter&&this.data.permission&&co(n)?s=Wo.From(e,this.data.type_parameter,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=void 0!==this.data.time_expire?Wo.New(e,this.data.type_parameter,"duration"===this.data.time_expire?.op,"duration"===this.data.time_expire?.op?this.data.time_expire.minutes:this.data.time_expire?.time,i?i.get_object():n,this.data?.description??"",i?void 0:t):Wo.New(e,this.data.type_parameter,!0,43200,i?i.get_object():n,this.data?.description??"",i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.time_expire&&a&&s?.expand_time("duration"===this.data.time_expire.op,"duration"===this.data.time_expire.op?this.data.time_expire.minutes:this.data.time_expire.time,n),void 0!==this.data?.bounty)if("add"===this.data.bounty.op){if(co(this.data.bounty.object?.address))s.deposit(this.data.bounty.object?.address);else if(void 0!==this.data.bounty.object?.balance){uo(this.data.type_parameter)||Ba(Ca.IsValidCoinType,"demand bounty");const t=await cc.Instance().get_coin_object(e,this.data.bounty.object?.balance,r,this.data.type_parameter);t&&s.deposit(t)}}else"reward"===this.data.bounty.op?s?.yes(this.data.bounty.service,n):"refund"===this.data.bounty.op&&s?.refund(n);void 0!==this.data?.present&&s?.present(this.data.present.service,this.data.present.service_pay_type,this.data.present.recommend_words,n),void 0!==this.data?.guard&&s?.set_guard(this.data.guard.address,this.data.guard?.service_id_in_guard??void 0,n),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Wl extends bl{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=[],s=this.data?.permission?.address,i=this.data?.object?.address;if(s&&co(s)){if(this.data?.object||r.push(Ho.machine),void 0!==this.data?.description&&i&&r.push(Ho.machine_description),void 0!==this.data?.endpoint&&i&&r.push(Ho.machine_endpoint),void 0!==this.data?.consensus_repository&&r.push(Ho.machine_repository),void 0!==this.data?.nodes&&r.push(Ho.machine_node),this.data?.bPublished&&r.push(Ho.machine_publish),void 0!==this.data?.progress_new&&r.push(Ho.progress),void 0!==this.data?.progress_context_repository&&r.push(Ho.progress_context_repository),void 0!==this.data?.progress_namedOperator&&r.push(Ho.progress_namedOperator),void 0!==this.data?.progress_parent&&r.push(Ho.progress_parent),void 0!==this.data?.progress_task&&r.push(Ho.progress_bind_task),void 0!==this.data?.progress_hold&&this.data.progress_hold.adminUnhold&&r.push(Ho.progress_unhold),void 0!==this.data?.bPaused&&r.push(Ho.machine_pause),void 0!==this.data?.progress_next?.guard)if(co(this.data?.progress_next?.guard))t.push(this.data?.progress_next?.guard);else if(this.data?.object&&co(i)){const e=await ed.QueryForwardGuard(this.data?.progress_next.progress,i,await cc.Instance().get_address()??"0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f",this.data.progress_next.operation.next_node_name,this.data.progress_next.operation.forward);e&&t.push(e)}return await this.check_permission_and_call(s,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&n&&co(n)?s=Zo.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=Zo.New(e,i?i.get_object():n,this.data?.description??"",this.data?.endpoint??"",i?void 0:t)}if(s){const d=i?i.get_object():n,c=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,c),void 0!==this.data?.endpoint&&a&&s?.set_endpoint(this.data.endpoint,c),void 0!==this.data?.consensus_repository)switch(this.data.consensus_repository.op){case"add":this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)));break;case"remove":s?.remove_repository(this.data.consensus_repository.repositories,!1,c);break;case"removeall":s?.remove_repository([],!0,c);break;case"set":s?.remove_repository([],!0,c),this.data.consensus_repository.repositories.forEach((e=>s?.add_repository(e,c)))}if(void 0!==this.data?.nodes)switch(this.data?.nodes?.op){case"add":s?.add_node(this.data.nodes.data,c);break;case"remove":s?.remove_node(this.data.nodes.names,this.data.nodes?.bTransferMyself,c);break;case"rename node":this.data.nodes.data.forEach((e=>s?.rename_node(e.old,e.new,c)));break;case"add from myself":s?.add_node2(this.data.nodes.addresses,c);break;case"add forward":this.data.nodes.data.forEach((e=>s?.add_forward(e.prior_node_name,e.node_name,e.forward,e.threshold,e.remove_forward,c)));break;case"remove forward":this.data.nodes.data.forEach((e=>s?.remove_forward(e.prior_node_name,e.node_name,e.forward_name,c)));break;case"remove pair":this.data.nodes.pairs.forEach((e=>s.remove_pair(e.prior_node_name,e.node_name,c)))}var o;if(this.data?.bPublished&&s?.publish(t),void 0!==this.data?.progress_new&&(o=ed?.New(e,s?.get_object(),d,this.data?.progress_new.task_address,c)),void 0!==this.data?.progress_context_repository){const t=this.data?.progress_context_repository.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_context_repository"),ed.From(e,s?.get_object(),d,t).set_context_repository(this.data?.progress_context_repository.repository,c)}if(void 0!==this.data?.progress_namedOperator){const t=this.data?.progress_namedOperator.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_namedOperator");let r=ed.From(e,s?.get_object(),d,t);this.data.progress_namedOperator.data.forEach((e=>r.set_namedOperator(e.name,e.operators,c)))}if(void 0!==this.data?.progress_parent){const t=this.data?.progress_parent.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_parent"),this.data.progress_parent.parent?ed.From(e,s?.get_object(),d,t).parent(this.data.progress_parent.parent):ed.From(e,s?.get_object(),d,t).parent_none()}if(void 0!==this.data?.progress_task){const t=this.data?.progress_task.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_task"),ed.From(e,s?.get_object(),d,t).bind_task(this.data.progress_task.task,c)}if(void 0!==this.data?.progress_hold){const t=this.data?.progress_hold.progress??o?.get_object();t||Ba(Ca.Fail,"progress invalid: progress_hold"),this.data?.progress_hold.adminUnhold?ed.From(e,s?.get_object(),d,t).unhold(this.data.progress_hold.operation,c):ed.From(e,s?.get_object(),d,t).hold(this.data.progress_hold.operation,this.data.progress_hold.bHold)}const u=o?.launch();u&&await this.new_with_mark(e,u,this.data?.progress_new?.namedNew,r),void 0!==this.data?.progress_next&&ed.From(e,s?.get_object(),d,this.data?.progress_next.progress).next(this.data.progress_next.operation,this.data.progress_next.deliverable,c),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,c),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s?.clone(!0,c),this.data?.clone_new?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),a||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Hl extends bl{data;constructor(e){super(),this.data=e}async call(e){const t=[],r=this.data?.permission?.address,s=this.data?.object?.address;return r&&co(r)?(this.data?.object||t.push(Ho.repository),void 0!==this.data?.description&&s&&t.push(Ho.repository_description),void 0!==this.data?.mode&&s&&t.push(Ho.repository_mode),void 0!==this.data?.reference&&t.push(Ho.repository_reference),void 0!==this.data?.policy&&t.push(Ho.repository_policies),await this.check_permission_and_call(r,t,[],!1,void 0,e)):await this.exec(e)}async operate(e,t,r){let s,i;const n=this.data?.permission?.address,a=this.data?.object?.address;if(a)co(a)&&this.data.permission&&co(n)?s=md.From(e,n,a):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!n||!co(n)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}s=md.New(e,i?i.get_object():n,this.data?.description??"",this.data?.mode,i?void 0:t)}if(s){const n=i?void 0:t;if(void 0!==this.data?.description&&a&&s?.set_description(this.data.description,n),void 0!==this.data?.reference)switch(this.data.reference.op){case"set":s?.remove_reference([],!0,n),s?.add_reference(this.data.reference.addresses,n);break;case"add":s?.add_reference(this.data.reference.addresses,n);break;case"remove":s?.remove_reference(this.data.reference.addresses,!1,n);break;case"removeall":s?.remove_reference([],!0,n)}if(void 0!==this.data?.mode&&a&&s?.set_policy_mode(this.data.mode,n),void 0!==this.data?.policy)switch(this.data.policy.op){case"set":s?.remove_policies([],!0,n),s?.add_policies(this.data.policy.data,n);break;case"add":s?.add_policies(this.data.policy.data,n);break;case"remove":s?.remove_policies(this.data.policy.keys,!1,n);break;case"removeall":s?.remove_policies([],!0,n);break;case"rename":this.data.policy.data.forEach((e=>{s?.rename_policy(e.old,e.new,n)}))}if(void 0!==this.data?.data)switch(this.data.data.op){case"add":void 0!==this.data.data?.data?.key?s?.add_data(this.data.data.data):void 0!==this.data.data?.data?.address&&s?.add_data2(this.data.data.data);break;case"remove":this.data.data.data.forEach((e=>s?.remove(e.address,e.key)))}i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),this.data.object||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Kl extends bl{data;constructor(e){super(),this.data=e}async call(e){this.data.type_parameter&&yo(this.data.type_parameter)||Ba(Ca.IsValidArgType,"service.type_parameter");const t=[],r=[];var s;const i=this.data?.permission?.address,n=this.data?.object?.address,a=this.data?.payee_treasury?.address;if(i&&co(i)){if(this.data?.object||r.push(Ho.service),void 0!==this.data?.description&&n&&r.push(Ho.service_description),void 0!==this.data?.bPaused&&r.push(Ho.service_pause),this.data?.bPublished&&r.push(Ho.service_publish),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.repository&&r.push(Ho.service_repository),void 0!==this.data?.clone_new&&r.push(Ho.service_clone),void 0!==this.data?.gen_discount&&r.push(Ho.service_discount_transfer),void 0!==this.data?.arbitration&&r.push(Ho.service_arbitration),void 0!==this.data?.buy_guard&&r.push(Ho.service_buyer_guard),void 0!==this.data?.endpoint&&r.push(Ho.service_endpoint),void 0!==this.data?.extern_withdraw_treasury&&r.push(Ho.service_treasury),void 0!==this.data?.machine&&r.push(Ho.service_machine),void 0!==a&&n&&r.push(Ho.service_payee),void 0!==this.data?.withdraw_guard&&r.push(Ho.service_withdraw_guards),void 0!==this.data?.refund_guard&&r.push(Ho.service_refund_guards),void 0!==this.data?.customer_required_info&&r.push(Ho.service_customer_required),void 0!==this.data?.sales&&r.push(Ho.service_sales),void 0!==this.data?.order_new?.guard)if(co(this.data.order_new.guard))t.push(this.data.order_new.guard);else if(this.data.object){if(!s){const e=await Jd({objects:[n],showContent:!0});e?.objects&&"Service"===e.objects[0].type&&(s=e.objects[0])}s?.buy_guard&&t.push(s?.buy_guard)}else this.data?.buy_guard&&co(this.data.buy_guard)&&t.push(this.data?.buy_guard);return co(this.data?.order_refund?.guard)&&t.push(this.data?.order_refund?.guard),void 0!==this.data.order_withdrawl&&r.push(Ho.service_withdraw),"string"==typeof this.data?.order_withdrawl?.data?.withdraw_guard&&co(this.data?.order_withdrawl?.data?.withdraw_guard)&&t.push(this.data?.order_withdrawl?.data?.withdraw_guard),await this.check_permission_and_call(i,r,t,!1,void 0,e)}return await this.exec(e)}async operate(e,t,r){let s,i,n;const a=this.data?.permission?.address,o=this.data?.object?.address,d=this.data?.payee_treasury?.address;if(o)co(o)&&this.data.type_parameter&&a&&co(a)?s=gd.From(e,this.data.type_parameter,a,o):Ba(Ca.InvalidParam,"object or permission address invalid.");else{if(!a||!co(a)){const t=this.data?.permission?.description??"";i=Qo.New(e,t)}if(!d||!co(d)){const r=this.data?.payee_treasury?.description??"";n=Td.New(e,this.data?.type_parameter,i??a,r,i?void 0:t)}s=gd.New(e,this.data.type_parameter,i?i.get_object():a,this.data?.description??"",n?n.get_object():d,i?void 0:t)}if(s){const a=i?void 0:t;if(void 0!==this.data?.description&&o&&s?.set_description(this.data.description,a),void 0!==this.data?.endpoint&&s?.set_endpoint(this.data.endpoint,a),void 0!==this.data?.payee_treasury&&o&&s?.set_payee(d,a),void 0!==this.data?.gen_discount&&s?.discount_transfer(this.data.gen_discount,a),void 0!==this.data?.repository)switch(this.data.repository.op){case"add":this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"remove":s?.remove_repository(this.data.repository.repositories,!1,a);break;case"set":s?.remove_repository([],!0,a),this.data.repository.repositories.forEach((e=>s?.add_repository(e,a)));break;case"removeall":s?.remove_repository([],!0,a)}if(void 0!==this.data?.extern_withdraw_treasury)switch(this.data.extern_withdraw_treasury.op){case"add":this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"set":s?.remove_treasury([],!0,a),this.data.extern_withdraw_treasury.treasuries.forEach((e=>s?.add_treasury(e.token_type,e.address,a)));break;case"remove":s?.remove_treasury(this.data.extern_withdraw_treasury.addresses,!1,a);break;case"removeall":s?.remove_treasury([],!1,a)}if(void 0!==this.data?.machine&&s?.set_machine(this.data.machine,a),void 0!==this.data?.arbitration)switch(this.data.arbitration.op){case"add":this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.token_type,a)));break;case"set":s?.remove_arbitration([],!0,a),this.data.arbitration.arbitrations.forEach((e=>s?.add_arbitration(e.address,e.token_type,a)));break;case"remove":s?.remove_arbitration(this.data.arbitration.addresses,!1,a);break;case"removeall":s?.remove_arbitration([],!1,a)}if(void 0!==this.data?.customer_required_info&&(this.data.customer_required_info.required_info&&this.data.customer_required_info.pubkey?s?.set_customer_required(this.data.customer_required_info.pubkey,this.data.customer_required_info.required_info,a):this.data.customer_required_info.pubkey&&s?.change_required_pubkey(this.data.customer_required_info.pubkey,a)),void 0!==this.data?.sales)switch(this.data.sales.op){case"add":s?.add_sales(this.data.sales.sales,!1,a);break;case"remove":s?.remove_sales(this.data.sales.sales_name,a)}if(void 0!==this.data?.withdraw_guard)switch(this.data.withdraw_guard.op){case"add":s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"set":s?.remove_withdraw_guards([],!0,a),s?.add_withdraw_guards(this.data.withdraw_guard.guards,a);break;case"remove":s?.remove_withdraw_guards(this.data.withdraw_guard.addresses,!1,a);break;case"removeall":s?.remove_withdraw_guards([],!0,a)}if(void 0!==this.data?.refund_guard)switch(this.data.refund_guard.op){case"add":s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"set":s?.remove_refund_guards([],!0,a),s?.add_refund_guards(this.data.refund_guard.guards,a);break;case"remove":s?.remove_refund_guards(this.data.refund_guard.addresses,!1,a);break;case"removeall":s?.remove_refund_guards([],!0,a)}var c;if(this.data?.bPublished&&s?.publish(a),void 0!==this.data?.order_new){let t,i=BigInt(0);this.data.order_new.buy_items.forEach((e=>{i+=BigInt(e.max_price)*BigInt(e.count)})),i>BigInt(0)&&(t=await cc.Instance().get_coin_object(e,i,r,this.data.type_parameter),t&&(c=s.order(this.data.order_new.buy_items,t,this.data.order_new.discount,this.data.order_new.machine,this.data.order_new.customer_info_crypto,a)))}if(void 0!==this.data?.order_agent){const e=this.data.order_agent.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_agent"),s?.set_order_agent(e,this.data.order_agent.agents,this.data.order_agent.progress)}if(void 0!==this.data?.order_required_info){const e=this.data.order_required_info.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_required_info"),s?.update_order_required_info(e,this.data.order_required_info.info)}if(void 0!==this.data?.order_refund){const e=this.data.order_refund.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_refund"),this.data?.order_refund?.arb&&this.data?.order_refund?.arb_token_type?s?.refund_withArb(e,this.data?.order_refund?.arb,this.data?.order_refund?.arb_token_type):s?.refund(e,this.data?.order_refund?.guard,a)}if(void 0!==this.data?.order_withdrawl&&a){const e=this.data.order_withdrawl.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_withdrawl"),s?.withdraw(e,this.data.order_withdrawl.data,a)}if(void 0!==this.data?.order_payer&&s){const e=this.data.order_payer.order??c?.order;e||Ba(Ca.Fail,"order invalid: order_payer"),s?.change_order_payer(e,this.data.order_payer.payer_new,this.data.order_payer.progress)}if(c&&this?.data?.order_new){const t=s.order_launch(c);await this.new_with_mark(e,t.order,this.data?.order_new?.namedNewOrder,r,[hd.Launch,hd.Order]),t?.progress&&await this.new_with_mark(e,t.progress,this.data?.order_new?.namedNewProgress,r,[hd.Launch])}void 0!==this.data?.buy_guard&&s?.set_buy_guard(this.data.buy_guard,a),void 0!==this.data?.bPaused&&s?.pause(this.data.bPaused,a),void 0!==this.data?.clone_new&&s&&await this.new_with_mark(e,s.clone(this.data.clone_new?.token_type_new,!0,a),this.data?.clone_new?.namedNew,r),n&&await this.new_with_mark(e,n.launch(),this.data?.payee_treasury?.namedNew,r),i&&await this.new_with_mark(e,i.launch(),this.data?.permission?.namedNew,r),o||await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}}class Ql extends bl{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){this.data?.root||Ba(Ca.InvalidParam,"guard root node invalid"),io(this.data?.description)||Ba(Ca.IsValidDesription,"build_guard - "+this.data.description),this.data?.table?.forEach((e=>{(!lo(e.identifier)||e.identifier<1)&&Ba(Ca.InvalidParam,"table.identifer invalid"),e.bWitness||void 0!==e.value||Ba(Ca.InvalidParam,"table.value")})),this.data?.table&&jo(this.data?.table?.map((e=>e.identifier)))&&Ba(Ca.InvalidParam,"table.identifer duplicates");var s=[];Zl(this.data.root,No.TYPE_BOOL,this.data?.table??[],s);const i=Xa(Uint8Array,...s),n=e.moveCall({target:$o.Instance().guardFn("new"),arguments:[e.pure.string(this.data.description),e.pure.vector("u8",[].slice.call(i.reverse()))]});this.data?.table?.forEach((t=>{if(t.bWitness){const r=new Uint8Array(1);r.set([t.value_type],0),e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!0),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}else{const r=Io(Uint8Array.from(Wa.getInstance().ser(t.value_type,t.value)),t.value_type);e.moveCall({target:$o.Instance().guardFn("constant_add"),arguments:[e.object(n),e.pure.u8(t.identifier),e.pure.bool(!1),e.pure.vector("u8",[].slice.call(r)),e.pure.bool(!1)]})}}));const a=e.moveCall({target:$o.Instance().guardFn("create"),arguments:[e.object(n)]});await this.new_with_mark(e,a,this.data?.namedNew,r)}}const Zl=(e,t,r,s)=>{const i=e;if(void 0!==i?.identifier){const e=r.find((e=>e.identifier===i.identifier));e?(em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))):Ba(Ca.InvalidParam,"node identifier - "+JSON.stringify(i))}else if(void 0!==i?.query){var n;if("string"==typeof i.query?n=td.find((e=>e.query_name===i.query)):"number"==typeof i.query&&(n=td.find((e=>e.query_id===i.query))),n||Ba(Ca.InvalidParam,"query invalid - "+i?.query),em(n.return,t,i),n.parameters.length===i.parameters.length)for(let e=i.parameters.length-1;e>=0;--e)Zl(i.parameters[e],n.parameters[e],r,s);else Ba(Ca.InvalidParam,"node query parameters length not match - "+JSON.stringify(i));if(s.push(Wa.getInstance().ser(No.TYPE_U8,ko.TYPE_QUERY)),"string"==typeof i.object)co(i.object)||Ba(Ca.InvalidParam,"node object from address string - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,No.TYPE_ADDRESS)),s.push(Wa.getInstance().ser(No.TYPE_ADDRESS,i.object));else{const e=r.find((e=>e.identifier===i.object));e?(em(e.value_type,No.TYPE_ADDRESS,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.object))):Ba(Ca.InvalidParam,"node object from identifier - "+JSON.stringify(i))}s.push(Wa.getInstance().ser("u16",n.query_id))}else if(void 0!==i?.logic)switch(em(No.TYPE_BOOL,t,i),i?.logic){case ko.TYPE_LOGIC_AND:case ko.TYPE_LOGIC_OR:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_NOT:1!==i.parameters.length&&Ba(Ca.InvalidParam,"node logic parameters length must be 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_BOOL,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic));break;case ko.TYPE_LOGIC_AS_U256_GREATER:case ko.TYPE_LOGIC_AS_U256_GREATER_EQUAL:case ko.TYPE_LOGIC_AS_U256_LESSER:case ko.TYPE_LOGIC_AS_U256_LESSER_EQUAL:case ko.TYPE_LOGIC_AS_U256_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_EQUAL:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"variable",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length));break;case ko.TYPE_LOGIC_HAS_SUBSTRING:i.parameters.length<2&&Ba(Ca.InvalidParam,"node logic parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,No.TYPE_STRING,r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.logic)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length))}else if(void 0!==i?.calc)i?.calc===ko.TYPE_NUMBER_ADDRESS?(em(No.TYPE_ADDRESS,t,i),1!==i.parameters.length&&Ba(Ca.InvalidParam,"node TYPE_NUMBER_ADDRESS parameters length must == 1"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc))):(em(No.TYPE_U256,t,i),i.parameters.length<2&&Ba(Ca.InvalidParam,"node calc parameters length must >= 2"+JSON.stringify(i)),i.parameters.reverse().forEach((e=>Zl(e,"number",r,s))),s.push(Wa.getInstance().ser(No.TYPE_U8,i.calc)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.parameters.length)));else if(void 0!==i?.value_type)em(i?.value_type,t,i),void 0===i?.value&&Ba(Ca.InvalidParam,"node value undefined - "+JSON.stringify(i)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.value_type)),i.value_type==No.TYPE_STRING||i.value_type===No.TYPE_VEC_U8?"string"==typeof i.value?s.push(Wa.getInstance().ser(No.TYPE_STRING,i.value)):s.push(Wa.getInstance().ser(No.TYPE_VEC_U8,i.value)):s.push(Wa.getInstance().ser(i?.value_type,i.value));else if(void 0!==i?.context)switch(s.push(Wa.getInstance().ser(No.TYPE_U8,i.context)),i.context){case Xo.TYPE_CLOCK:em(No.TYPE_U64,t,i);break;case Xo.TYPE_GUARD:case Xo.TYPE_SIGNER:em(No.TYPE_ADDRESS,t,i)}else if(void 0!==i?.identifier){nd(i.identifier)||Ba(Ca.IsValidGuardIdentifier,"node - "+JSON.stringify(i));const e=r.find((e=>e.identifier===i.identifier));e||Ba(Ca.InvalidParam,"identifier not found. node - "+JSON.stringify(i)),em(e.value_type,t,i),s.push(Wa.getInstance().ser(No.TYPE_U8,Xo.TYPE_CONSTANT)),s.push(Wa.getInstance().ser(No.TYPE_U8,i.identifier))}else Ba(Ca.InvalidParam,"node - "+JSON.stringify(i))},em=(e,t,r)=>{if("variable"===t)t=e;else if("number"===t){if(e===No.TYPE_U128||e===No.TYPE_U256||e===No.TYPE_U8||e===No.TYPE_U64||e===Xo.TYPE_CLOCK)return}else if(t===No.TYPE_ADDRESS&&(e===Xo.TYPE_SIGNER||e===Xo.TYPE_GUARD))return;if(e!==t){var s="";r&&(s=" - "+JSON.stringify(r)),Ba(Ca.InvalidParam,"checkType: "+e+" require type: "+t+s)}};class tm extends bl{data;constructor(e){super(),this.data=e}async call(e){return await this.exec(e)}async operate(e,t,r){let s,i=yd.From(e);const n=this.data?.object?.address;if(s=n&&co(n)?vd.From(e,n):vd.From(e,i.create_resource2()),"destroy"!==this.data?.mark?.op){if(void 0!==this.data?.information&&i.update(this.data.information),s&&s?.get_object()){if(void 0!==this.data?.mark)switch(this.data.mark.op){case"add or set":this.data.mark.data.forEach((e=>{s?.add(e.address,e.tags,e.name)}));break;case"remove":this.data.mark.data.forEach((e=>{s?.remove(e.address,e.tags)}));break;case"removeall":this.data.mark.addresses.forEach((e=>{s?.removeall(e)}))}"transfer"===this.data?.mark?.op&&s&&co(this.data.mark.address)&&i.transfer_resource(s,this.data.mark.address),"replace"===this.data?.mark?.op&&co(this.data.mark.address)&&i.use_resource(vd.From(e,this.data.mark.address)),!n&&s&&await this.new_with_mark(e,s.launch(),this.data?.object?.namedNew,r)}}else i.destroy_resource(s)}}const rm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await pm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},sm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await lm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},im=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await gm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},nm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await _m(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},am=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await fm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},om=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await vm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},dm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await mm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},cm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await Tm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},um=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await ym(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},hm=async e=>{try{const t=JSON.parse(e);return JSON.stringify({data:await bm(t)})}catch(e){return JSON.stringify({error:e?.toString()})}},pm=async e=>{const t=new zl(e.data);return Em(t,e.account,e.witness)},lm=async e=>{const t=new Kl(e.data);return Em(t,e.account,e.witness)},mm=async e=>{const t=new Gl(e.data);return Em(t,e.account,e.witness)},_m=async e=>{const t=new Hl(e.data);return Em(t,e.account,e.witness)},bm=async e=>{const t=new Ql(e.data);return Em(t,e.account,e.witness)},gm=async e=>{const t=new Wl(e.data);return Em(t,e.account,e.witness)},ym=async e=>{const t=new tm(e.data);return Em(t,e.account,e.witness)},fm=async e=>{const t=new gl(e.data);return Em(t,e.account,e.witness)},vm=async e=>{const t=new $l(e.data);return Em(t,e.account,e.witness)},Tm=async e=>{const t=new Ll(e.data);return Em(t,e.account,e.witness)},Em=async(e,t,r)=>r?e.call_with_witness(r,t):e.call(t)})(),o})()));