@stakekit/widget 0.0.290 → 0.0.291
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/bundle/{assets-DvEv_w-P.js → assets-H3qs-BfM.js} +1 -1
- package/dist/bundle/{cardano-connector-Cqj1z0wD.js → cardano-connector-C1YrKgp8.js} +2 -2
- package/dist/bundle/{configured-chains-Nn1qeOjm.js → configured-chains-CljV1eCV.js} +1 -1
- package/dist/bundle/{cosmos-connector-meta-BMa49Bqn.js → cosmos-connector-meta-CogU-5R3.js} +1 -1
- package/dist/bundle/index.bundle.js +17718 -17703
- package/dist/bundle/{ledger-connector-cdqjHR7O.js → ledger-connector-PwjsEMH_.js} +16 -16
- package/dist/bundle/{network-BvWfFLMi.js → network-rRxrzik9.js} +1 -1
- package/dist/bundle/{solana-connector-t7ro7CGZ.js → solana-connector-mwCnoTC6.js} +3 -3
- package/dist/bundle/{stellar-connector-CGTk18nF.js → stellar-connector-CIkU0qDy.js} +2 -2
- package/dist/bundle/{substrate-connector-Blu0Fmlx.js → substrate-connector-BtpGbum5.js} +1 -1
- package/dist/bundle/{ton-connector-D_6F9QzE.js → ton-connector-B9Rb8DpG.js} +3 -3
- package/dist/bundle/{transaction-nCW9pp-W.js → transaction-BU8gNx_-.js} +3 -3
- package/dist/bundle/{transaction-DFK_HUua.js → transaction-C5Rdik4M.js} +22 -22
- package/dist/bundle/transaction-C6SgGYH0.js +23 -0
- package/dist/bundle/{transaction-Dd1bxz-u.js → transaction-D8vYa3xG.js} +9 -9
- package/dist/bundle/{tron-connector-CNS7QrN7.js → tron-connector-feSoCE1Z.js} +13 -13
- package/dist/bundle/{utils-B2hhTK5t.js → utils-B5UkNjd3.js} +1 -1
- package/dist/bundle/{wallet-manager-xXCqWo2v.js → wallet-manager-iwdzlSwY.js} +34 -34
- package/dist/package/{assets-CCANldg9.js → assets-DLmJ26y-.js} +1 -1
- package/dist/package/{cardano-connector-DiiSoILv.js → cardano-connector-CIrXiVTi.js} +2 -2
- package/dist/package/{configured-chains-CqS9GQgO.js → configured-chains-Ddwhz0AO.js} +1 -1
- package/dist/package/{cosmos-connector-meta-D2OXd_8A.js → cosmos-connector-meta-gXG2LZJw.js} +1 -1
- package/dist/package/index.package.js +69 -34
- package/dist/package/{ledger-connector-CoflrvIY.js → ledger-connector-DA2MGFO1.js} +5 -5
- package/dist/package/{network-DzIq3Eb-.js → network-DRWqFyX1.js} +1 -1
- package/dist/package/{solana-connector-BGL_7RtS.js → solana-connector-zdXBpO69.js} +3 -3
- package/dist/package/{stellar-connector-KA4sbBsT.js → stellar-connector-Bwd8_6fg.js} +2 -2
- package/dist/package/{substrate-connector-C47hmu7O.js → substrate-connector-DWxNzj24.js} +1 -1
- package/dist/package/{ton-connector-Os8-LilP.js → ton-connector-Bwc9mQfl.js} +3 -3
- package/dist/package/{transaction-BUvzBUD1.js → transaction-C10sHjOp.js} +1 -1
- package/dist/package/{transaction-BhlMhMmN.js → transaction-CRtu-oMo.js} +1 -1
- package/dist/package/{transaction-GC-w6eas.js → transaction-CYsojERR.js} +1 -1
- package/dist/package/{transaction-9ZjMuyda.js → transaction-cowIxlQK.js} +1 -1
- package/dist/package/{tron-connector-73EkJLaC.js → tron-connector-DQ9QzTbX.js} +3 -3
- package/dist/package/{wallet-manager-fjTGOCl1.js → wallet-manager-CV7OgeRF.js} +2 -2
- package/dist/types/domain/network/contract.d.ts +1 -1
- package/dist/types/domain/network/network-name.d.ts +7 -0
- package/dist/types/domain/wallet/contract.d.ts +0 -1
- package/dist/types/domain/wallet/wallet-policy.d.ts +9 -0
- package/dist/types/generated/api/legacy-networks.d.ts +1 -0
- package/dist/types/generated/api/yield-networks.d.ts +1 -0
- package/dist/types/index.bundle.d.ts +1 -1
- package/dist/types/index.package.d.ts +1 -1
- package/dist/types/public-api/react-types.d.ts +8 -0
- package/dist/types/public-api/types.d.ts +73 -23
- package/dist/website/assets/{assets-Cv_Ib61e.js → assets-h8USQKgq.js} +1 -1
- package/dist/website/assets/{cardano-connector-BQ5eYUAn.js → cardano-connector-C0Sq11R4.js} +1 -1
- package/dist/website/assets/{configured-chains-BHW1HK8Y.js → configured-chains-CIWlanAA.js} +1 -1
- package/dist/website/assets/{cosmos-connector-meta-PXOxxoiN.js → cosmos-connector-meta-rno_UNzC.js} +1 -1
- package/dist/website/assets/index-5Aa-rcFh.js +540 -0
- package/dist/website/assets/{ledger-connector-CfdYVk_B.js → ledger-connector-Dd5qrF8_.js} +2 -2
- package/dist/website/assets/{network-CpiZy7GL.js → network-BGx8nCzY.js} +1 -1
- package/dist/website/assets/{solana-connector-Dko0nLRl.js → solana-connector-B7Md4VDG.js} +1 -1
- package/dist/website/assets/{stellar-connector-CzEQ-GiL.js → stellar-connector-BwE5re5j.js} +1 -1
- package/dist/website/assets/{substrate-connector-BySKIZSU.js → substrate-connector-Bc3A8Ngf.js} +1 -1
- package/dist/website/assets/{ton-connector-DfHih6IL.js → ton-connector-1XbtGnNe.js} +1 -1
- package/dist/website/assets/{transaction-BgxiRDr6.js → transaction-BN_PDuuD.js} +1 -1
- package/dist/website/assets/{transaction-Z0G1srG_.js → transaction-BTjp5Yv_.js} +2 -2
- package/dist/website/assets/{transaction-qQ73FnRV.js → transaction-CRGTe3Dx.js} +2 -2
- package/dist/website/assets/transaction-DhoVCNGK.js +1 -0
- package/dist/website/assets/{tron-connector-BkQWCtpI.js → tron-connector-BPQRviGm.js} +2 -2
- package/dist/website/assets/{utils-BnE0E9wY.js → utils-Bi0bPCX2.js} +1 -1
- package/dist/website/assets/{wallet-manager-Bnoaodi-.js → wallet-manager-Dysx00HR.js} +3 -3
- package/dist/website/index.html +9 -9
- package/package.json +2 -2
- package/dist/bundle/transaction-B_6wJk3a.js +0 -23
- package/dist/types/domain/network/intersection.d.ts +0 -2
- package/dist/types/domain/network/network.d.ts +0 -3
- package/dist/types/domain/wallet/network.d.ts +0 -575
- package/dist/types/generated/api/legacy-schema.d.ts +0 -1017
- package/dist/types/generated/api/yield-schema.d.ts +0 -4328
- package/dist/website/assets/index-DPaiXt13.js +0 -540
- package/dist/website/assets/transaction-XbbbllS0.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/polkadot-ledger-transaction-36Qv7Wb4.js","assets/Result-Bvvef0v1.js","assets/registry-BQBI5S8m.js","assets/rolldown-runtime-BcKkbAw3.js","assets/dist-D6L6gF64.js","assets/sha3-DRlIjSdj.js","assets/_u64-BLNH_r32.js","assets/esm-CjTnkPtf.js","assets/dist-VPhQpe2v.js","assets/secp256k1-BcfUQvi6.js","assets/hmac-DY3QYcUU.js","assets/_shortw_utils-60uxgahw.js","assets/blake2b-BMPujwy0.js","assets/blake2-CL6aokTA.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e,t}from"./rolldown-runtime-BcKkbAw3.js";import{c as n,d as r,i,r as a,t as o}from"./Result-Bvvef0v1.js";import{hi as s}from"./Clock-BENq00-7.js";import{A as c,C as l,G as u,K as d,M as f,_t as p,k as m,nt as h,on as g,p as _,r as v,z as y}from"./assets-Cv_Ib61e.js";import{Dn as b,F as x,Qt as S,Rt as C,_n as ee,fr as w,gn as T,in as E,ir as D,n as O,s as te,t as ne,wn as re}from"./wagmi-connect-result-B59F3NGW.js";import{t as ie}from"./preload-helper-BLdHbfdN.js";import{S as ae,b as oe,c as se,n as ce,o as le,s as ue,t as de,w as fe,y as pe}from"./transaction-BgxiRDr6.js";import{a as me,o as he}from"./network-CpiZy7GL.js";import{$n as ge}from"./call-D7Y2Ksou.js";import{r as k,t as A}from"./dist-CELdgNh9.js";import{t as _e}from"./events-D2w4OsQJ.js";import{t as ve}from"./current-value-stream-DQSRX8Fd.js";import{a as ye,i as be,n as xe}from"./transaction-qQ73FnRV.js";import{n as Se}from"./transaction-XbbbllS0.js";import{t as Ce}from"./wagmi-connector-events-uWDzb_Wq.js";k();var we=e(_e()),Te=0,Ee=[],De=({type:e,message:t,data:n,context:r})=>{let i={type:e,id:String(++Te),date:new Date};t&&(i.message=t),n&&(i.data=n),r&&(i.context=r),Ae(i)},Oe=class e{type;context;constructor(e,t){this.type=e,this.context=t}trace(e,t){De({type:this.type,message:e,data:t,context:this.context})}getContext(){return this.context}setContext(e){this.context=e}updateContext(e){this.context={...this.context,...e}}getType(){return this.type}setType(e){this.type=e}withType(t){return new e(t,this.context)}withContext(t){return new e(this.type,t)}withUpdatedContext(t){return new e(this.type,{...this.context,...t})}},ke=e=>(Ee.push(e),()=>{let t=Ee.indexOf(e);t!==-1&&(Ee[t]=Ee[Ee.length-1],Ee.pop())});function Ae(e){for(let t=0;t<Ee.length;t++)try{Ee[t](e)}catch{}}typeof window<`u`&&(window.__ledgerLogsListen=ke);var je=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Me=Math.ceil,Ne=Math.floor,Pe=`[BigNumber Error] `,Fe=Pe+`Number primitive has more than 15 significant digits: `,Ie=0x5af3107a4000,j=14,Le=9007199254740991,Re=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],ze=1e7,M=1e9;function Be(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!je.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(N(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(Fe+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>Le||e!==Ne(e)))throw Error(Fe+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%j,l<0&&(f+=j),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=j;f<m;)y.c.push(+h.slice(f,f+=j));f=j-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=Be,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null){if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],N(n,0,M,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],N(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(N(n[0],-M,0,t),N(n[1],0,M,t),c=n[0],l=n[1]):(N(n,-M,M,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`)){if(n=e[t],n&&n.pop)N(n[0],-M,-1,t),N(n[1],1,M,t),u=n[0],d=n[1];else if(N(n,-M,M,t),n)u=-(d=n<0?-n:n);else throw Error(Pe+t+` cannot be zero: `+n)}if(e.hasOwnProperty(t=`CRYPTO`)){if(n=e[t],n===!!n){if(n){if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(Pe+`crypto unavailable`)}else f=n}else throw Error(Pe+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],N(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],N(n,0,M,t),m=n),e.hasOwnProperty(t=`FORMAT`)){if(n=e[t],typeof n==`object`)h=n;else throw Error(Pe+t+` not an object: `+n)}if(e.hasOwnProperty(t=`ALPHABET`)){if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(Pe+t+` invalid: `+n)}}else throw Error(Pe+`Object expected: `+e)}return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-M&&i<=M&&i===Ne(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%j,t<1&&(t+=j),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=Ie||n!==Ne(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(Pe+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return Ne(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:N(e,0,M),s=Me(e/j),f){if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(Pe+`crypto unavailable`)}if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=j,s&&e&&(c=Re[j-e],u[l]=Ne(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=j);for(l=1,c=u[0];c>=10;c/=10,l++);l<j&&(i-=j-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(Ke(He(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?Ke(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=Ke(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%ze,u=t/ze|0;for(e=e.slice();c--;)a=e[c]%ze,o=e[c]/ze|0,r=u*a+o*l,i=l*a+r%ze*ze+s,s=(i/n|0)+(r/ze|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,ee,w,T,E=r.s==i.s?1:-1,D=r.c,O=i.c;if(!D||!D[0]||!O||!O[0])return new v(!r.s||!i.s||(D?O&&D[0]==O[0]:!O)?NaN:D&&D[0]==0||!O?E*0:E/0);for(h=new v(E),g=h.c=[],l=r.e-i.e,E=a+l+1,s||(s=Ie,l=Ve(r.e/j)-Ve(i.e/j),E=E/j|0),u=0;O[u]==(D[u]||0);u++);if(O[u]>(D[u]||0)&&l--,E<0)g.push(1),d=!0;else{for(C=D.length,w=O.length,u=0,E+=2,f=Ne(s/(O[0]+1)),f>1&&(O=e(O,f,s),D=e(D,f,s),w=O.length,C=D.length),x=w,_=D.slice(0,w),y=_.length;y<w;_[y++]=0);T=O.slice(),T=[0].concat(T),ee=O[0],O[1]>=s/2&&ee++;do{if(f=0,c=t(O,_,w,y),c<0){if(b=_[0],w!=y&&(b=b*s+(_[1]||0)),f=Ne(b/ee),f>1)for(f>=s&&(f=s-1),p=e(O,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,w<m?T:O,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=O.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(O,_,w,y)<1;)f++,n(_,w<y?T:O,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=D[x]||0:(_=[D[x]],y=1)}while((x++<C||_[0]!=null)&&E--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==Ie){for(u=1,E=g[0];E>=10;E/=10,u++);S(h,a+(h.e=u+l*j-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:N(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=He(e.c),d=r==1||r==2&&(o<=c||o>=l)?Ge(d,o):Ke(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=He(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=Ge(d,a)}else if(t-=o+(r===2&&a>o),d=Ke(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=Ue(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*j-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(Pe+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=Re;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=j,o=t,c=p[l=0],f=Ne(c/m[i-o-1]%10);else if(l=Me((a+1)/j),l>=p.length){if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=j,o=a-j+1}else break out}else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=j,o=a-j+i,f=o<0?0:Ne(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(j-t%j)%j],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[j-a],p[l]=o>0?Ne(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==Ie&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=Ie)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=He(e.c),t=n<=c||n>=l?Ge(t,n):Ke(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return Ue(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return N(e,0,M),t==null?t=s:N(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-Ve(this.e/j))*j,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(Pe+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v((+C(p))**(l?e.s*(2-We(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&We(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=Me(m/j+2));for(l?(n=new v(.5),u&&(e.s=1),d=We(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=Ne(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=We(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:N(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return Ue(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return Ue(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=Ue(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&Ve(this.e/j)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return Ue(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=Ue(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/j,u=e.e/j,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=Ve(l),u=Ve(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=Ie-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=Ie}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=Ve(_.e/j)+Ve(e.e/j),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=Ie,g=ze,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/j,o=e.e/j,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=Ve(a),o=Ve(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/Ie|0,s[t]=Ie===s[t]?0:s[t]%Ie;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return N(e,1,M),t==null?t=s:N(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*j+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return N(e,-Le,Le),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=He(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=Ve((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),He(a.c).slice(0,u)===(n=He(r.c)).slice(0,u)){if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(N(e,0,M),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(N(e,0,M),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(Pe+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(Pe+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=He(y),c=n.e=g.length-_.e-1,n.c[0]=Re[(l=c%j)<0?j+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&N(e,1,M),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?Ge(He(r.c),a):Ke(He(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=Ke(He(r.c),r.e,`0`)):(N(e,2,g.length,`Base`),t=n(Ke(He(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function Ve(e){var t=e|0;return e>0||e===t?t:t-1}function He(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=j-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function Ue(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function N(e,t,n,r){if(e<t||e>n||e!==Ne(e))throw Error(Pe+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function We(e){var t=e.c.length-1;return Ve(e.e/j)==t&&e.c[t]%2!=0}function Ge(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function Ke(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var P=Be();function qe({id:e,name:t,address:n,currency:r,balance:i,spendableBalance:a,blockHeight:o,lastSyncDate:s,parentAccountId:c,publicKey:l,readiness:u}){return{id:e,name:t,address:n,currency:r,balance:new P(i),spendableBalance:new P(a),blockHeight:o,lastSyncDate:new Date(s),parentAccountId:c,publicKey:l,readiness:u}}var Je;function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Ye=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Xe=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Je=globalThis).__zod_globalConfig??(Je.__zod_globalConfig={});var Ze=globalThis.__zod_globalConfig;function Qe(e){return e&&Object.assign(Ze,e),Ze}function $e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function et(e,t){return typeof t==`bigint`?t.toString():t}function tt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nt(e){return e==null}function rt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function it(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var at=Symbol(`evaluating`);function I(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==at)return r===void 0&&(r=at,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ot(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function st(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ct(e){return JSON.stringify(e)}function lt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ut=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ft=tt(()=>{if(Ze.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pt(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return dt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function mt(e){return pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ht=new Set([`string`,`number`,`symbol`]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _t(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function vt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var yt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function bt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return _t(e,st(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ot(this,`shape`,e),e},checks:[]}))}function xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return _t(e,st(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ot(this,`shape`,r),r},checks:[]}))}function St(e,t){if(!pt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ot(this,`shape`,n),n}}))}function Ct(e,t){if(!pt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ot(this,`shape`,n),n}}))}function wt(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ot(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Tt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return _t(t,st(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ot(this,`shape`,i),i},checks:[]}))}function Et(e,t,n){return _t(t,st(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ot(this,`shape`,i),i}}))}function Dt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ot(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function kt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function At(e){return typeof e==`string`?e:e?.message}function jt(e,t,n){let r=e.message?e.message:At(e.inst?._zod.def?.error?.(e))??At(t?.error?.(e))??At(n.customError?.(e))??At(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Mt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Nt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Pt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,et,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ft=F(`$ZodError`,Pt),It=F(`$ZodError`,Pt,{Parent:Error});function Lt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Rt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var zt=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ye;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>jt(e,a,Qe())));throw ut(t,i?.callee),t}return o.value},Bt=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>jt(e,a,Qe())));throw ut(t,i?.callee),t}return o.value},Vt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ye;return a.issues.length?{success:!1,error:new(e??Ft)(a.issues.map(e=>jt(e,i,Qe())))}:{success:!0,data:a.value}},Ht=Vt(It),Ut=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>jt(e,i,Qe())))}:{success:!0,data:a.value}},Wt=Ut(It),Gt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return zt(e)(t,n,i)},Kt=e=>(t,n,r)=>zt(e)(t,n,r),qt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Bt(e)(t,n,i)},Jt=e=>async(t,n,r)=>Bt(e)(t,n,r),Yt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vt(e)(t,n,i)},Xt=e=>(t,n,r)=>Vt(e)(t,n,r),Zt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ut(e)(t,n,i)},Qt=e=>async(t,n,r)=>Ut(e)(t,n,r),$t=/^[cC][0-9a-z]{6,}$/,en=/^[0-9a-z]+$/,tn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nn=/^[0-9a-vA-V]{20}$/,rn=/^[A-Za-z0-9]{27}$/,an=/^[a-zA-Z0-9_-]{21}$/,on=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,sn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,cn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ln=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,un=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function dn(){return new RegExp(un,`u`)}var fn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,mn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_n=/^[A-Za-z0-9_-]*$/,vn=/^https?$/,yn=/^\+[1-9]\d{6,14}$/,bn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,xn=RegExp(`^${bn}$`);function Sn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cn(e){return RegExp(`^${Sn(e)}$`)}function wn(e){let t=Sn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${bn}T(?:${r})$`)}var Tn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},En=/^-?\d+$/,Dn=/^-?\d+(?:\.\d+)?$/,On=/^(?:true|false)$/i,kn=/^null$/i,An=/^undefined$/i,jn=/^[^A-Z]*$/,Mn=/^[^a-z]*$/,Nn=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pn={number:`number`,bigint:`bigint`,object:`date`},Fn=F(`$ZodCheckLessThan`,(e,t)=>{Nn.init(e,t);let n=Pn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),In=F(`$ZodCheckGreaterThan`,(e,t)=>{Nn.init(e,t);let n=Pn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ln=F(`$ZodCheckMultipleOf`,(e,t)=>{Nn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):it(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Rn=F(`$ZodCheckNumberFormat`,(e,t)=>{Nn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=yt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=En)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),zn=F(`$ZodCheckMaxLength`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Mt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Bn=F(`$ZodCheckMinLength`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Mt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vn=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Mt(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Hn=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Nn.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Un=F(`$ZodCheckRegex`,(e,t)=>{Hn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wn=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=jn,Hn.init(e,t)}),Gn=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Mn,Hn.init(e,t)}),Kn=F(`$ZodCheckIncludes`,(e,t)=>{Nn.init(e,t);let n=gt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),qn=F(`$ZodCheckStartsWith`,(e,t)=>{Nn.init(e,t);let n=RegExp(`^${gt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Jn=F(`$ZodCheckEndsWith`,(e,t)=>{Nn.init(e,t);let n=RegExp(`.*${gt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Yn=F(`$ZodCheckOverwrite`,(e,t)=>{Nn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Xn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
+
import{s as e,t}from"./rolldown-runtime-BcKkbAw3.js";import{c as n,d as r,i,r as a,t as o}from"./Result-Bvvef0v1.js";import{hi as s}from"./Clock-BENq00-7.js";import{A as c,B as l,C as u,K as d,M as f,k as p,p as m,q as h,r as g,rt as _,sn as v,vt as y}from"./assets-h8USQKgq.js";import{Dn as b,F as x,Qt as S,Rt as C,_n as ee,fr as w,gn as T,in as E,ir as D,n as O,s as te,t as ne,wn as re}from"./wagmi-connect-result-B59F3NGW.js";import{t as ie}from"./preload-helper-BLdHbfdN.js";import{S as ae,b as oe,c as se,n as ce,o as le,s as ue,t as de,w as fe,y as pe}from"./transaction-BN_PDuuD.js";import{a as me,o as he}from"./network-BGx8nCzY.js";import{$n as ge}from"./call-D7Y2Ksou.js";import{r as k,t as A}from"./dist-CELdgNh9.js";import{t as _e}from"./events-D2w4OsQJ.js";import{t as ve}from"./current-value-stream-DQSRX8Fd.js";import{a as ye,i as be,n as xe}from"./transaction-CRGTe3Dx.js";import{n as Se}from"./transaction-DhoVCNGK.js";import{t as Ce}from"./wagmi-connector-events-uWDzb_Wq.js";k();var we=e(_e()),Te=0,Ee=[],De=({type:e,message:t,data:n,context:r})=>{let i={type:e,id:String(++Te),date:new Date};t&&(i.message=t),n&&(i.data=n),r&&(i.context=r),Ae(i)},Oe=class e{type;context;constructor(e,t){this.type=e,this.context=t}trace(e,t){De({type:this.type,message:e,data:t,context:this.context})}getContext(){return this.context}setContext(e){this.context=e}updateContext(e){this.context={...this.context,...e}}getType(){return this.type}setType(e){this.type=e}withType(t){return new e(t,this.context)}withContext(t){return new e(this.type,t)}withUpdatedContext(t){return new e(this.type,{...this.context,...t})}},ke=e=>(Ee.push(e),()=>{let t=Ee.indexOf(e);t!==-1&&(Ee[t]=Ee[Ee.length-1],Ee.pop())});function Ae(e){for(let t=0;t<Ee.length;t++)try{Ee[t](e)}catch{}}typeof window<`u`&&(window.__ledgerLogsListen=ke);var je=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Me=Math.ceil,Ne=Math.floor,Pe=`[BigNumber Error] `,Fe=Pe+`Number primitive has more than 15 significant digits: `,Ie=0x5af3107a4000,j=14,Le=9007199254740991,Re=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],ze=1e7,M=1e9;function Be(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!je.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(N(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(Fe+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>Le||e!==Ne(e)))throw Error(Fe+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%j,l<0&&(f+=j),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=j;f<m;)y.c.push(+h.slice(f,f+=j));f=j-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=Be,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null){if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],N(n,0,M,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],N(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(N(n[0],-M,0,t),N(n[1],0,M,t),c=n[0],l=n[1]):(N(n,-M,M,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`)){if(n=e[t],n&&n.pop)N(n[0],-M,-1,t),N(n[1],1,M,t),u=n[0],d=n[1];else if(N(n,-M,M,t),n)u=-(d=n<0?-n:n);else throw Error(Pe+t+` cannot be zero: `+n)}if(e.hasOwnProperty(t=`CRYPTO`)){if(n=e[t],n===!!n){if(n){if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(Pe+`crypto unavailable`)}else f=n}else throw Error(Pe+t+` not true or false: `+n)}if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],N(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],N(n,0,M,t),m=n),e.hasOwnProperty(t=`FORMAT`)){if(n=e[t],typeof n==`object`)h=n;else throw Error(Pe+t+` not an object: `+n)}if(e.hasOwnProperty(t=`ALPHABET`)){if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(Pe+t+` invalid: `+n)}}else throw Error(Pe+`Object expected: `+e)}return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-M&&i<=M&&i===Ne(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%j,t<1&&(t+=j),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=Ie||n!==Ne(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(Pe+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return Ne(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:N(e,0,M),s=Me(e/j),f){if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(Pe+`crypto unavailable`)}if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=j,s&&e&&(c=Re[j-e],u[l]=Ne(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=j);for(l=1,c=u[0];c>=10;c/=10,l++);l<j&&(i-=j-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(Ke(He(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?Ke(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=Ke(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%ze,u=t/ze|0;for(e=e.slice();c--;)a=e[c]%ze,o=e[c]/ze|0,r=u*a+o*l,i=l*a+r%ze*ze+s,s=(i/n|0)+(r/ze|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,ee,w,T,E=r.s==i.s?1:-1,D=r.c,O=i.c;if(!D||!D[0]||!O||!O[0])return new v(!r.s||!i.s||(D?O&&D[0]==O[0]:!O)?NaN:D&&D[0]==0||!O?E*0:E/0);for(h=new v(E),g=h.c=[],l=r.e-i.e,E=a+l+1,s||(s=Ie,l=Ve(r.e/j)-Ve(i.e/j),E=E/j|0),u=0;O[u]==(D[u]||0);u++);if(O[u]>(D[u]||0)&&l--,E<0)g.push(1),d=!0;else{for(C=D.length,w=O.length,u=0,E+=2,f=Ne(s/(O[0]+1)),f>1&&(O=e(O,f,s),D=e(D,f,s),w=O.length,C=D.length),x=w,_=D.slice(0,w),y=_.length;y<w;_[y++]=0);T=O.slice(),T=[0].concat(T),ee=O[0],O[1]>=s/2&&ee++;do{if(f=0,c=t(O,_,w,y),c<0){if(b=_[0],w!=y&&(b=b*s+(_[1]||0)),f=Ne(b/ee),f>1)for(f>=s&&(f=s-1),p=e(O,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,w<m?T:O,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=O.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(O,_,w,y)<1;)f++,n(_,w<y?T:O,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=D[x]||0:(_=[D[x]],y=1)}while((x++<C||_[0]!=null)&&E--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==Ie){for(u=1,E=g[0];E>=10;E/=10,u++);S(h,a+(h.e=u+l*j-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:N(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=He(e.c),d=r==1||r==2&&(o<=c||o>=l)?Ge(d,o):Ke(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=He(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=Ge(d,a)}else if(t-=o+(r===2&&a>o),d=Ke(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=Ue(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*j-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(Pe+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=Re;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=j,o=t,c=p[l=0],f=Ne(c/m[i-o-1]%10);else if(l=Me((a+1)/j),l>=p.length){if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=j,o=a-j+1}else break out}else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=j,o=a-j+i,f=o<0?0:Ne(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(j-t%j)%j],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[j-a],p[l]=o>0?Ne(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==Ie&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=Ie)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=He(e.c),t=n<=c||n>=l?Ge(t,n):Ke(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return Ue(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return N(e,0,M),t==null?t=s:N(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-Ve(this.e/j))*j,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(Pe+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v((+C(p))**(l?e.s*(2-We(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&We(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=Me(m/j+2));for(l?(n=new v(.5),u&&(e.s=1),d=We(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=Ne(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=We(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:N(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return Ue(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return Ue(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=Ue(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&Ve(this.e/j)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return Ue(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=Ue(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/j,u=e.e/j,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=Ve(l),u=Ve(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=Ie-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=Ie}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=Ve(_.e/j)+Ve(e.e/j),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=Ie,g=ze,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/j,o=e.e/j,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=Ve(a),o=Ve(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/Ie|0,s[t]=Ie===s[t]?0:s[t]%Ie;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return N(e,1,M),t==null?t=s:N(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*j+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return N(e,-Le,Le),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=He(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=Ve((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),He(a.c).slice(0,u)===(n=He(r.c)).slice(0,u)){if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(N(e,0,M),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(N(e,0,M),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(Pe+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(Pe+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=He(y),c=n.e=g.length-_.e-1,n.c[0]=Re[(l=c%j)<0?j+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&N(e,1,M),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?Ge(He(r.c),a):Ke(He(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=Ke(He(r.c),r.e,`0`)):(N(e,2,g.length,`Base`),t=n(Ke(He(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function Ve(e){var t=e|0;return e>0||e===t?t:t-1}function He(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=j-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function Ue(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function N(e,t,n,r){if(e<t||e>n||e!==Ne(e))throw Error(Pe+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function We(e){var t=e.c.length-1;return Ve(e.e/j)==t&&e.c[t]%2!=0}function Ge(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function Ke(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var P=Be();function qe({id:e,name:t,address:n,currency:r,balance:i,spendableBalance:a,blockHeight:o,lastSyncDate:s,parentAccountId:c,publicKey:l,readiness:u}){return{id:e,name:t,address:n,currency:r,balance:new P(i),spendableBalance:new P(a),blockHeight:o,lastSyncDate:new Date(s),parentAccountId:c,publicKey:l,readiness:u}}var Je;function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Ye=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Xe=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Je=globalThis).__zod_globalConfig??(Je.__zod_globalConfig={});var Ze=globalThis.__zod_globalConfig;function Qe(e){return e&&Object.assign(Ze,e),Ze}function $e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function et(e,t){return typeof t==`bigint`?t.toString():t}function tt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nt(e){return e==null}function rt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function it(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var at=Symbol(`evaluating`);function I(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==at)return r===void 0&&(r=at,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ot(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function st(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ct(e){return JSON.stringify(e)}function lt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ut=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ft=tt(()=>{if(Ze.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pt(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return dt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function mt(e){return pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ht=new Set([`string`,`number`,`symbol`]);function gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _t(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function vt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var yt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function bt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return _t(e,st(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ot(this,`shape`,e),e},checks:[]}))}function xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return _t(e,st(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ot(this,`shape`,r),r},checks:[]}))}function St(e,t){if(!pt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ot(this,`shape`,n),n}}))}function Ct(e,t){if(!pt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ot(this,`shape`,n),n}}))}function wt(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return _t(e,st(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ot(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Tt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return _t(t,st(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ot(this,`shape`,i),i},checks:[]}))}function Et(e,t,n){return _t(t,st(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ot(this,`shape`,i),i}}))}function Dt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ot(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function kt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function At(e){return typeof e==`string`?e:e?.message}function jt(e,t,n){let r=e.message?e.message:At(e.inst?._zod.def?.error?.(e))??At(t?.error?.(e))??At(n.customError?.(e))??At(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Mt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Nt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Pt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,et,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ft=F(`$ZodError`,Pt),It=F(`$ZodError`,Pt,{Parent:Error});function Lt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Rt(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var zt=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ye;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>jt(e,a,Qe())));throw ut(t,i?.callee),t}return o.value},Bt=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>jt(e,a,Qe())));throw ut(t,i?.callee),t}return o.value},Vt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ye;return a.issues.length?{success:!1,error:new(e??Ft)(a.issues.map(e=>jt(e,i,Qe())))}:{success:!0,data:a.value}},Ht=Vt(It),Ut=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>jt(e,i,Qe())))}:{success:!0,data:a.value}},Wt=Ut(It),Gt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return zt(e)(t,n,i)},Kt=e=>(t,n,r)=>zt(e)(t,n,r),qt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Bt(e)(t,n,i)},Jt=e=>async(t,n,r)=>Bt(e)(t,n,r),Yt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Vt(e)(t,n,i)},Xt=e=>(t,n,r)=>Vt(e)(t,n,r),Zt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ut(e)(t,n,i)},Qt=e=>async(t,n,r)=>Ut(e)(t,n,r),$t=/^[cC][0-9a-z]{6,}$/,en=/^[0-9a-z]+$/,tn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nn=/^[0-9a-vA-V]{20}$/,rn=/^[A-Za-z0-9]{27}$/,an=/^[a-zA-Z0-9_-]{21}$/,on=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,sn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,cn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ln=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,un=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function dn(){return new RegExp(un,`u`)}var fn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,mn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_n=/^[A-Za-z0-9_-]*$/,vn=/^https?$/,yn=/^\+[1-9]\d{6,14}$/,bn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,xn=RegExp(`^${bn}$`);function Sn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cn(e){return RegExp(`^${Sn(e)}$`)}function wn(e){let t=Sn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${bn}T(?:${r})$`)}var Tn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},En=/^-?\d+$/,Dn=/^-?\d+(?:\.\d+)?$/,On=/^(?:true|false)$/i,kn=/^null$/i,An=/^undefined$/i,jn=/^[^A-Z]*$/,Mn=/^[^a-z]*$/,Nn=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pn={number:`number`,bigint:`bigint`,object:`date`},Fn=F(`$ZodCheckLessThan`,(e,t)=>{Nn.init(e,t);let n=Pn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),In=F(`$ZodCheckGreaterThan`,(e,t)=>{Nn.init(e,t);let n=Pn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ln=F(`$ZodCheckMultipleOf`,(e,t)=>{Nn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):it(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Rn=F(`$ZodCheckNumberFormat`,(e,t)=>{Nn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=yt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=En)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),zn=F(`$ZodCheckMaxLength`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Mt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Bn=F(`$ZodCheckMinLength`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Mt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vn=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;Nn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Mt(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Hn=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Nn.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Un=F(`$ZodCheckRegex`,(e,t)=>{Hn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wn=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=jn,Hn.init(e,t)}),Gn=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Mn,Hn.init(e,t)}),Kn=F(`$ZodCheckIncludes`,(e,t)=>{Nn.init(e,t);let n=gt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),qn=F(`$ZodCheckStartsWith`,(e,t)=>{Nn.init(e,t);let n=RegExp(`^${gt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Jn=F(`$ZodCheckEndsWith`,(e,t)=>{Nn.init(e,t);let n=RegExp(`.*${gt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Yn=F(`$ZodCheckOverwrite`,(e,t)=>{Nn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Xn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}},Zn={major:4,minor:4,patch:3},R=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Zn;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Dt(e),i;for(let a of t){if(a._zod.def.when){if(Ot(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Ye;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Dt(e,t))});else{if(e.issues.length===t)continue;r||=Dt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Dt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Ye;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Ye;return o.then(e=>t(e,r,a))}return t(o,r,a)}}I(e,`~standard`,()=>({validate:t=>{try{let n=Ht(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Wt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Qn=F(`$ZodString`,(e,t)=>{R.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Tn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),z=F(`$ZodStringFormat`,(e,t)=>{Hn.init(e,t),Qn.init(e,t)}),$n=F(`$ZodGUID`,(e,t)=>{t.pattern??=sn,z.init(e,t)}),er=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=cn(e)}else t.pattern??=cn();z.init(e,t)}),tr=F(`$ZodEmail`,(e,t)=>{t.pattern??=ln,z.init(e,t)}),nr=F(`$ZodURL`,(e,t)=>{z.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===vn.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),rr=F(`$ZodEmoji`,(e,t)=>{t.pattern??=dn(),z.init(e,t)}),ir=F(`$ZodNanoID`,(e,t)=>{t.pattern??=an,z.init(e,t)}),ar=F(`$ZodCUID`,(e,t)=>{t.pattern??=$t,z.init(e,t)}),or=F(`$ZodCUID2`,(e,t)=>{t.pattern??=en,z.init(e,t)}),sr=F(`$ZodULID`,(e,t)=>{t.pattern??=tn,z.init(e,t)}),cr=F(`$ZodXID`,(e,t)=>{t.pattern??=nn,z.init(e,t)}),lr=F(`$ZodKSUID`,(e,t)=>{t.pattern??=rn,z.init(e,t)}),ur=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=wn(t),z.init(e,t)}),dr=F(`$ZodISODate`,(e,t)=>{t.pattern??=xn,z.init(e,t)}),fr=F(`$ZodISOTime`,(e,t)=>{t.pattern??=Cn(t),z.init(e,t)}),pr=F(`$ZodISODuration`,(e,t)=>{t.pattern??=on,z.init(e,t)}),mr=F(`$ZodIPv4`,(e,t)=>{t.pattern??=fn,z.init(e,t),e._zod.bag.format=`ipv4`}),hr=F(`$ZodIPv6`,(e,t)=>{t.pattern??=pn,z.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),gr=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=mn,z.init(e,t)}),_r=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=hn,z.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function vr(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var yr=F(`$ZodBase64`,(e,t)=>{t.pattern??=gn,z.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{vr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function br(e){if(!_n.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return vr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var xr=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=_n,z.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{br(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Sr=F(`$ZodE164`,(e,t)=>{t.pattern??=yn,z.init(e,t)});function Cr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var wr=F(`$ZodJWT`,(e,t)=>{z.init(e,t),e._zod.check=n=>{Cr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Tr=F(`$ZodNumber`,(e,t)=>{R.init(e,t),e._zod.pattern=e._zod.bag.pattern??Dn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Er=F(`$ZodNumberFormat`,(e,t)=>{Rn.init(e,t),Tr.init(e,t)}),Dr=F(`$ZodBoolean`,(e,t)=>{R.init(e,t),e._zod.pattern=On,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Or=F(`$ZodUndefined`,(e,t)=>{R.init(e,t),e._zod.pattern=An,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),kr=F(`$ZodNull`,(e,t)=>{R.init(e,t),e._zod.pattern=kn,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Ar=F(`$ZodAny`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),jr=F(`$ZodUnknown`,(e,t)=>{R.init(e,t),e._zod.parse=e=>e}),Mr=F(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Nr=F(`$ZodVoid`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}});function Pr(e,t,n){e.issues.length&&t.issues.push(...kt(n,e.issues)),t.value[n]=e.value}var Fr=F(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Pr(t,n,e))):Pr(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Ir(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...kt(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Lr(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=vt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Rr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ir(e,n,i,t,u,d))):Ir(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var zr=F(`$ZodObject`,(e,t)=>{if(R.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=tt(()=>Lr(t));I(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=dt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Ir(n,t,e,s,r,i))):Ir(a,t,e,s,r,i)}return i?Rr(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Br=F(`$ZodObjectJIT`,(e,t)=>{zr.init(e,t);let n=e._zod.parse,r=tt(()=>Lr(t)),i=e=>{let t=new Xn([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ct(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=ct(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
5
5
|
if (${n}.issues.length) {
|
|
@@ -63,4 +63,4 @@ import{s as e,t}from"./rolldown-runtime-BcKkbAw3.js";import{c as n,d as r,i,r as
|
|
|
63
63
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=dt,s=!Ze.jitless,c=s&&ft.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Rr([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Vr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Dt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>jt(e,r,Qe())))}),t)}var Hr=F(`$ZodUnion`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),I(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),I(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>rt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Vr(t,r,e,i)):Vr(o,r,e,i)}}),Ur=F(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Hr.init(e,t);let n=e._zod.parse;I(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=tt(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!dt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Wr=F(`$ZodIntersection`,(e,t)=>{R.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Kr(e,t,n)):Kr(e,i,a)}});function Gr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pt(e)&&pt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Gr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Gr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Kr(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Dt(e))return e;let o=Gr(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var qr=F(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!pt(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>jt(e,r,Qe())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...kt(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...kt(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Dn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>jt(e,r,Qe())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...kt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...kt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Jr=F(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=$e(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ht.has(typeof e)).map(e=>typeof e==`string`?gt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Yr=F(`$ZodLiteral`,(e,t)=>{if(R.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?gt(e):e?gt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Xr=F(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Xe(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Ye;return n.value=i,n.fallback=!0,n}});function Zr(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Qr=F(`$ZodOptional`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Zr(e,r)):Zr(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),$r=F(`$ZodExactOptional`,(e,t)=>{Qr.init(e,t),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ei=F(`$ZodNullable`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.innerType._zod.optin),I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rt(e.source)}|null)$`):void 0}),I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ti=F(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ni(e,t)):ni(r,t)}});function ni(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ri=F(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ii=F(`$ZodNonOptional`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>ai(t,e)):ai(i,e)}});function ai(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var oi=F(`$ZodCatch`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>jt(e,n,Qe()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>jt(e,n,Qe()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),si=F(`$ZodPipe`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>t.in._zod.values),I(e._zod,`optin`,()=>t.in._zod.optin),I(e._zod,`optout`,()=>t.out._zod.optout),I(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ci(e,t.in,n)):ci(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ci(e,t.out,n)):ci(r,t.out,n)}});function ci(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var li=F(`$ZodReadonly`,(e,t)=>{R.init(e,t),I(e._zod,`propValues`,()=>t.innerType._zod.propValues),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`optin`,()=>t.innerType?._zod?.optin),I(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ui):ui(r)}});function ui(e){return e.value=Object.freeze(e.value),e}var di=F(`$ZodCustom`,(e,t)=>{Nn.init(e,t),R.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>fi(t,n,r,e));fi(i,n,r,e)}});function fi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Nt(e))}}var pi,mi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function hi(){return new mi}(pi=globalThis).__zod_globalRegistry??(pi.__zod_globalRegistry=hi());var gi=globalThis.__zod_globalRegistry;function _i(e,t){return new e({type:`string`,...L(t)})}function vi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function yi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function bi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function xi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Si(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Ci(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function wi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Ti(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Ei(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Di(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Oi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function ki(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Ai(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function ji(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function Mi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function Ni(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Pi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function Fi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Ii(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function Li(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Ri(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function zi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function Bi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Vi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Hi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function Ui(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Wi(e,t){return new e({type:`number`,checks:[],...L(t)})}function Gi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Ki(e,t){return new e({type:`boolean`,...L(t)})}function qi(e,t){return new e({type:`undefined`,...L(t)})}function Ji(e,t){return new e({type:`null`,...L(t)})}function Yi(e){return new e({type:`any`})}function Xi(e){return new e({type:`unknown`})}function Zi(e,t){return new e({type:`never`,...L(t)})}function Qi(e,t){return new e({type:`void`,...L(t)})}function $i(e,t){return new Fn({check:`less_than`,...L(t),value:e,inclusive:!1})}function ea(e,t){return new Fn({check:`less_than`,...L(t),value:e,inclusive:!0})}function ta(e,t){return new In({check:`greater_than`,...L(t),value:e,inclusive:!1})}function na(e,t){return new In({check:`greater_than`,...L(t),value:e,inclusive:!0})}function ra(e,t){return new Ln({check:`multiple_of`,...L(t),value:e})}function ia(e,t){return new zn({check:`max_length`,...L(t),maximum:e})}function aa(e,t){return new Bn({check:`min_length`,...L(t),minimum:e})}function oa(e,t){return new Vn({check:`length_equals`,...L(t),length:e})}function sa(e,t){return new Un({check:`string_format`,format:`regex`,...L(t),pattern:e})}function ca(e){return new Wn({check:`string_format`,format:`lowercase`,...L(e)})}function la(e){return new Gn({check:`string_format`,format:`uppercase`,...L(e)})}function ua(e,t){return new Kn({check:`string_format`,format:`includes`,...L(t),includes:e})}function da(e,t){return new qn({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function fa(e,t){return new Jn({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function pa(e){return new Yn({check:`overwrite`,tx:e})}function ma(e){return pa(t=>t.normalize(e))}function ha(){return pa(e=>e.trim())}function ga(){return pa(e=>e.toLowerCase())}function _a(){return pa(e=>e.toUpperCase())}function va(){return pa(e=>lt(e))}function ya(e,t,n){return new e({type:`array`,element:t,...L(n)})}function ba(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function xa(e,t){let n=Sa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Nt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Nt(r))}},e(t.value,t)),t);return n}function Sa(e,t){let n=new Nn({check:`custom`,...L(t)});return n._zod.check=e,n}function Ca(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??gi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function B(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,B(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ea(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function wa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
64
64
|
|
|
65
65
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ta(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Oa(t,`input`,e.processors),output:Oa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ea(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ea(r.element,n);if(r.type===`set`)return Ea(r.valueType,n);if(r.type===`lazy`)return Ea(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Ea(r.innerType,n);if(r.type===`intersection`)return Ea(r.left,n)||Ea(r.right,n);if(r.type===`record`||r.type===`map`)return Ea(r.keyType,n)||Ea(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ea(r.in,n)||Ea(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ea(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ea(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ea(e,n))return!0;return!!(r.rest&&Ea(r.rest,n))}return!1}var Da=(e,t={})=>n=>{let r=Ca({...n,processors:t});return B(e,r),wa(r,e),Ta(r,e)},Oa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ca({...i??{},target:a,io:t,processors:n});return B(e,o),wa(o,e),Ta(o,e)},ka={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Aa=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ka[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ja=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Ma=(e,t,n,r)=>{n.type=`boolean`},Na=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Pa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Fa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ia=(e,t,n,r)=>{n.not={}},La=(e,t,n,r)=>{let i=e._zod.def,a=$e(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ra=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},za=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ba=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Va=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=B(a.element,t,{...r,path:[...r.path,`items`]})},Ha=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=B(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=B(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ua=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>B(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Wa=(e,t,n,r)=>{let i=e._zod.def,a=B(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=B(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ga=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=B(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=B(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=B(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ka=(e,t,n,r)=>{let i=e._zod.def,a=B(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},qa=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ja=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ya=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Xa=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Za=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;B(o,t,r);let s=t.seen.get(e);s.ref=o},Qa=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},$a=(e,t,n,r)=>{let i=e._zod.def;B(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},eo=F(`ZodISODateTime`,(e,t)=>{ur.init(e,t),U.init(e,t)});function to(e){return Bi(eo,e)}var no=F(`ZodISODate`,(e,t)=>{dr.init(e,t),U.init(e,t)});function ro(e){return Vi(no,e)}var io=F(`ZodISOTime`,(e,t)=>{fr.init(e,t),U.init(e,t)});function ao(e){return Hi(io,e)}var oo=F(`ZodISODuration`,(e,t)=>{pr.init(e,t),U.init(e,t)});function so(e){return Ui(oo,e)}var co=(e,t)=>{Ft.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Rt(e,t)},flatten:{value:t=>Lt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,et,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,et,2)}},isEmpty:{get(){return e.issues.length===0}}})},lo=F(`ZodError`,co),uo=F(`ZodError`,co,{Parent:Error}),fo=zt(uo),po=Bt(uo),mo=Vt(uo),ho=Ut(uo),go=Gt(uo),_o=Kt(uo),vo=qt(uo),yo=Jt(uo),bo=Yt(uo),xo=Xt(uo),So=Zt(uo),Co=Qt(uo),wo=new WeakMap;function To(e,t,n){let r=Object.getPrototypeOf(e),i=wo.get(r);if(i||(i=new Set,wo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var V=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Oa(e,`input`),output:Oa(e,`output`)}}),e.toJSONSchema=Da(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mo(e,t,n),e.parseAsync=async(t,n)=>po(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ho(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>go(e,t,n),e.decode=(t,n)=>_o(e,t,n),e.encodeAsync=async(t,n)=>vo(e,t,n),e.decodeAsync=async(t,n)=>yo(e,t,n),e.safeEncode=(t,n)=>bo(e,t,n),e.safeDecode=(t,n)=>xo(e,t,n),e.safeEncodeAsync=async(t,n)=>So(e,t,n),e.safeDecodeAsync=async(t,n)=>Co(e,t,n),To(e,`ZodType`,{check(...e){let t=this.def;return this.clone(st(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _t(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Vs(e,t))},superRefine(e,t){return this.check(Hs(e,t))},overwrite(e){return this.check(pa(e))},optional(){return Cs(this)},exactOptional(){return Ts(this)},nullable(){return Ds(this)},nullish(){return Cs(Ds(this))},nonoptional(e){return Ns(this,e)},array(){return K(this)},or(e){return J([this,e])},and(e){return hs(this,e)},transform(e){return Ls(this,xs(e))},default(e){return ks(this,e)},prefault(e){return js(this,e)},catch(e){return Fs(this,e)},pipe(e){return Ls(this,e)},readonly(){return zs(this)},describe(e){let t=this.clone();return gi.add(t,{description:e}),t},meta(...e){if(e.length===0)return gi.get(this);let t=this.clone();return gi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return gi.get(e)?.description},configurable:!0}),e)),Eo=F(`_ZodString`,(e,t)=>{Qn.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,To(e,`_ZodString`,{regex(...e){return this.check(sa(...e))},includes(...e){return this.check(ua(...e))},startsWith(...e){return this.check(da(...e))},endsWith(...e){return this.check(fa(...e))},min(...e){return this.check(aa(...e))},max(...e){return this.check(ia(...e))},length(...e){return this.check(oa(...e))},nonempty(...e){return this.check(aa(1,...e))},lowercase(e){return this.check(ca(e))},uppercase(e){return this.check(la(e))},trim(){return this.check(ha())},normalize(...e){return this.check(ma(...e))},toLowerCase(){return this.check(ga())},toUpperCase(){return this.check(_a())},slugify(){return this.check(va())}})}),Do=F(`ZodString`,(e,t)=>{Qn.init(e,t),Eo.init(e,t),e.email=t=>e.check(vi(Oo,t)),e.url=t=>e.check(wi(jo,t)),e.jwt=t=>e.check(zi(Ko,t)),e.emoji=t=>e.check(Ti(Mo,t)),e.guid=t=>e.check(yi(ko,t)),e.uuid=t=>e.check(bi(Ao,t)),e.uuidv4=t=>e.check(xi(Ao,t)),e.uuidv6=t=>e.check(Si(Ao,t)),e.uuidv7=t=>e.check(Ci(Ao,t)),e.nanoid=t=>e.check(Ei(No,t)),e.guid=t=>e.check(yi(ko,t)),e.cuid=t=>e.check(Di(Po,t)),e.cuid2=t=>e.check(Oi(Fo,t)),e.ulid=t=>e.check(ki(Io,t)),e.base64=t=>e.check(Ii(Uo,t)),e.base64url=t=>e.check(Li(Wo,t)),e.xid=t=>e.check(Ai(Lo,t)),e.ksuid=t=>e.check(ji(Ro,t)),e.ipv4=t=>e.check(Mi(zo,t)),e.ipv6=t=>e.check(Ni(Bo,t)),e.cidrv4=t=>e.check(Pi(Vo,t)),e.cidrv6=t=>e.check(Fi(Ho,t)),e.e164=t=>e.check(Ri(Go,t)),e.datetime=t=>e.check(to(t)),e.date=t=>e.check(ro(t)),e.time=t=>e.check(ao(t)),e.duration=t=>e.check(so(t))});function H(e){return _i(Do,e)}var U=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Eo.init(e,t)}),Oo=F(`ZodEmail`,(e,t)=>{tr.init(e,t),U.init(e,t)}),ko=F(`ZodGUID`,(e,t)=>{$n.init(e,t),U.init(e,t)}),Ao=F(`ZodUUID`,(e,t)=>{er.init(e,t),U.init(e,t)}),jo=F(`ZodURL`,(e,t)=>{nr.init(e,t),U.init(e,t)}),Mo=F(`ZodEmoji`,(e,t)=>{rr.init(e,t),U.init(e,t)}),No=F(`ZodNanoID`,(e,t)=>{ir.init(e,t),U.init(e,t)}),Po=F(`ZodCUID`,(e,t)=>{ar.init(e,t),U.init(e,t)}),Fo=F(`ZodCUID2`,(e,t)=>{or.init(e,t),U.init(e,t)}),Io=F(`ZodULID`,(e,t)=>{sr.init(e,t),U.init(e,t)}),Lo=F(`ZodXID`,(e,t)=>{cr.init(e,t),U.init(e,t)}),Ro=F(`ZodKSUID`,(e,t)=>{lr.init(e,t),U.init(e,t)}),zo=F(`ZodIPv4`,(e,t)=>{mr.init(e,t),U.init(e,t)}),Bo=F(`ZodIPv6`,(e,t)=>{hr.init(e,t),U.init(e,t)}),Vo=F(`ZodCIDRv4`,(e,t)=>{gr.init(e,t),U.init(e,t)}),Ho=F(`ZodCIDRv6`,(e,t)=>{_r.init(e,t),U.init(e,t)}),Uo=F(`ZodBase64`,(e,t)=>{yr.init(e,t),U.init(e,t)}),Wo=F(`ZodBase64URL`,(e,t)=>{xr.init(e,t),U.init(e,t)}),Go=F(`ZodE164`,(e,t)=>{Sr.init(e,t),U.init(e,t)}),Ko=F(`ZodJWT`,(e,t)=>{wr.init(e,t),U.init(e,t)}),qo=F(`ZodNumber`,(e,t)=>{Tr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r),To(e,`ZodNumber`,{gt(e,t){return this.check(ta(e,t))},gte(e,t){return this.check(na(e,t))},min(e,t){return this.check(na(e,t))},lt(e,t){return this.check($i(e,t))},lte(e,t){return this.check(ea(e,t))},max(e,t){return this.check(ea(e,t))},int(e){return this.check(Yo(e))},safe(e){return this.check(Yo(e))},positive(e){return this.check(ta(0,e))},nonnegative(e){return this.check(na(0,e))},negative(e){return this.check($i(0,e))},nonpositive(e){return this.check(ea(0,e))},multipleOf(e,t){return this.check(ra(e,t))},step(e,t){return this.check(ra(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function W(e){return Wi(qo,e)}var Jo=F(`ZodNumberFormat`,(e,t)=>{Er.init(e,t),qo.init(e,t)});function Yo(e){return Gi(Jo,e)}var Xo=F(`ZodBoolean`,(e,t)=>{Dr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ma(e,t,n,r)});function Zo(e){return Ki(Xo,e)}var Qo=F(`ZodUndefined`,(e,t)=>{Or.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r)});function $o(e){return qi(Qo,e)}var es=F(`ZodNull`,(e,t)=>{kr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r)});function G(e){return Ji(es,e)}var ts=F(`ZodAny`,(e,t)=>{Ar.init(e,t),V.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ns(){return Yi(ts)}var rs=F(`ZodUnknown`,(e,t)=>{jr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function is(){return Xi(rs)}var as=F(`ZodNever`,(e,t)=>{Mr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r)});function os(e){return Zi(as,e)}var ss=F(`ZodVoid`,(e,t)=>{Nr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r)});function cs(e){return Qi(ss,e)}var ls=F(`ZodArray`,(e,t)=>{Fr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r),e.element=t.element,To(e,`ZodArray`,{min(e,t){return this.check(aa(e,t))},nonempty(e){return this.check(aa(1,e))},max(e,t){return this.check(ia(e,t))},length(e,t){return this.check(oa(e,t))},unwrap(){return this.element}})});function K(e,t){return ya(ls,e,t)}var us=F(`ZodObject`,(e,t)=>{Br.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r),I(e,`shape`,()=>t.shape),To(e,`ZodObject`,{keyof(){return Y(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:is()})},loose(){return this.clone({...this._zod.def,catchall:is()})},strict(){return this.clone({...this._zod.def,catchall:os()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return St(this,e)},safeExtend(e){return Ct(this,e)},merge(e){return wt(this,e)},pick(e){return bt(this,e)},omit(e){return xt(this,e)},partial(...e){return Tt(Ss,this,e[0])},required(...e){return Et(Ms,this,e[0])}})});function q(e,t){return new us({type:`object`,shape:e??{},...L(t)})}var ds=F(`ZodUnion`,(e,t)=>{Hr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),e.options=t.options});function J(e,t){return new ds({type:`union`,options:e,...L(t)})}var fs=F(`ZodDiscriminatedUnion`,(e,t)=>{ds.init(e,t),Ur.init(e,t)});function ps(e,t,n){return new fs({type:`union`,options:t,discriminator:e,...L(n)})}var ms=F(`ZodIntersection`,(e,t)=>{Wr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r)});function hs(e,t){return new ms({type:`intersection`,left:e,right:t})}var gs=F(`ZodRecord`,(e,t)=>{qr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function _s(e,t,n){return!t||!t._zod?new gs({type:`record`,keyType:H(),valueType:e,...L(t)}):new gs({type:`record`,keyType:e,valueType:t,...L(n)})}var vs=F(`ZodEnum`,(e,t)=>{Jr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new vs({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new vs({...t,checks:[],...L(r),entries:i})}});function Y(e,t){return new vs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var ys=F(`ZodLiteral`,(e,t)=>{Yr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function X(e,t){return new ys({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var bs=F(`ZodTransform`,(e,t)=>{Xr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Xe(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Nt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Nt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function xs(e){return new bs({type:`transform`,transform:e})}var Ss=F(`ZodOptional`,(e,t)=>{Qr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cs(e){return new Ss({type:`optional`,innerType:e})}var ws=F(`ZodExactOptional`,(e,t)=>{$r.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ts(e){return new ws({type:`optional`,innerType:e})}var Es=F(`ZodNullable`,(e,t)=>{ei.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ds(e){return new Es({type:`nullable`,innerType:e})}var Os=F(`ZodDefault`,(e,t)=>{ti.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ks(e,t){return new Os({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}var As=F(`ZodPrefault`,(e,t)=>{ri.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function js(e,t){return new As({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mt(t)}})}var Ms=F(`ZodNonOptional`,(e,t)=>{ii.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ns(e,t){return new Ms({type:`nonoptional`,innerType:e,...L(t)})}var Ps=F(`ZodCatch`,(e,t)=>{oi.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fs(e,t){return new Ps({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Is=F(`ZodPipe`,(e,t)=>{si.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.in=t.in,e.out=t.out});function Ls(e,t){return new Is({type:`pipe`,in:e,out:t})}var Rs=F(`ZodReadonly`,(e,t)=>{li.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zs(e){return new Rs({type:`readonly`,innerType:e})}var Bs=F(`ZodCustom`,(e,t)=>{di.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r)});function Vs(e,t={}){return ba(Bs,e,t)}function Hs(e,t){return xa(e,t)}var Us=q({ready:Zo(),reason:H().min(1).optional()}),Ws=q({id:H(),name:H(),address:H(),currency:H(),balance:H(),spendableBalance:H(),blockHeight:J([W(),$o()]),lastSyncDate:H(),parentAccountId:H().optional(),publicKey:H().optional(),readiness:Us.optional()}),Gs=Y([`CryptoCurrency`,`TokenCurrency`]),Ks=Y([`ERC20`]),qs=q({color:H(),ticker:H(),id:H(),name:H(),decimals:W()}),Js=ps(`type`,[qs.extend({type:X(Gs.enum.CryptoCurrency),family:H()}),qs.extend({type:X(Gs.enum.TokenCurrency),parent:H()}).extend({standard:Ks,contract:H()})]),Z=q({amount:H(),recipient:H()}),Q=Y(`aleo.algorand.aptos.bitcoin.cardano.casper.celo.crypto_org.cosmos.elrond.ethereum.filecoin.hedera.hypercore.internet_computer.kaspa.near.neo.polkadot.ripple.solana.stacks.stellar.sui.tezos.ton.tron.vechain`.split(`.`)),Ys=({family:e,mode:t,fees:n,assetId:r,memo:i,amount:a,recipient:o})=>({family:e,amount:a.toString(),recipient:o,fees:n?n.toString():void 0,memo:i,mode:t,assetId:r}),Xs=({family:e,mode:t,fees:n,assetId:r,memo:i,amount:a,recipient:o})=>({family:e,amount:new P(a),recipient:o,fees:n?new P(n):void 0,memo:i,mode:t,assetId:r}),Zs=({family:e,mode:t,fees:n,amount:r,recipient:i})=>({family:e,amount:r.toString(),recipient:i,fees:n?n.toString():void 0,mode:t}),Qs=({family:e,mode:t,fees:n,amount:r,recipient:i})=>({family:e,amount:new P(r),recipient:i,fees:n?new P(n):void 0,mode:t});function $s({family:e,amount:t,recipient:n,feePerByte:r,opReturnData:i,changeAddress:a}){return{family:e,amount:t.toString(),recipient:n,feePerByte:r?.toString(),opReturnDataHex:i?.toString(`hex`),changeAddress:a}}function ec({family:e,amount:t,recipient:n,feePerByte:r,opReturnDataHex:i,changeAddress:a}){return{family:e,amount:new P(t),recipient:n,feePerByte:r?new P(r):void 0,opReturnData:i?A.from(i,`hex`):void 0,changeAddress:a}}function tc({amount:e,family:t,fees:n=void 0,index:r=void 0,mode:i,recipient:a}){return{amount:e.toString(),family:t,fees:n?n.toString():void 0,index:r,mode:i,recipient:a}}function nc({amount:e,family:t,fees:n=void 0,index:r=void 0,mode:i,recipient:a}){return{amount:new P(e),family:t,fees:n?new P(n):void 0,index:r,mode:i,recipient:a}}var rc=({amount:e,recipient:t,family:n,mode:r,fees:i,gas:a,memo:o,sourceValidator:s,validators:c})=>({amount:e.toString(),recipient:t,family:n,mode:r,fees:i?i.toString():void 0,gas:a?a.toString():void 0,memo:o,sourceValidator:s??void 0,validators:c?c.map(e=>({...e,amount:e.amount.toString()})):void 0}),ic=({amount:e,recipient:t,family:n,mode:r,fees:i,gas:a,memo:o,sourceValidator:s,validators:c})=>({amount:new P(e),recipient:t,family:n,mode:r,fees:i?new P(i):void 0,gas:a?new P(a):void 0,memo:o,sourceValidator:s??void 0,validators:c?c.map(e=>({...e,amount:new P(e.amount)})):void 0}),ac=({family:e,mode:t,fees:n,amount:r,recipient:i})=>({family:e,amount:r.toString(),recipient:i,fees:n?n.toString():void 0,mode:t}),oc=({family:e,mode:t,fees:n,amount:r,recipient:i})=>({family:e,amount:new P(r),recipient:i,fees:n?new P(n):void 0,mode:t});k();function sc({family:e,amount:t,recipient:n,nonce:r,data:i,gasPrice:a,gasLimit:o,maxPriorityFeePerGas:s,maxFeePerGas:c,sponsored:l}){return{family:e,amount:t.toString(),recipient:n,nonce:r,data:i?i.toString(`hex`):void 0,gasPrice:a?a.toString():void 0,gasLimit:o?o.toString():void 0,maxPriorityFeePerGas:s?s.toString():void 0,maxFeePerGas:c?c.toString():void 0,sponsored:l}}function cc({family:e,amount:t,recipient:n,nonce:r,data:i,gasPrice:a,gasLimit:o,maxPriorityFeePerGas:s,maxFeePerGas:c,sponsored:l}){return{family:e,amount:new P(t),recipient:n,nonce:r,data:i?A.from(i,`hex`):void 0,gasPrice:a?new P(a):void 0,gasLimit:o?new P(o):void 0,maxPriorityFeePerGas:s?new P(s):void 0,maxFeePerGas:c?new P(c):void 0,sponsored:l}}function lc({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:e.toString(),recipient:t,family:n,mode:r,fees:i?.toString()}}function uc({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:new P(e),recipient:t,family:n,mode:r,fees:i?new P(i):void 0}}function dc({amount:e,family:t,memo:n=void 0,recipient:r}){return{amount:e.toString(),family:t,memo:n,recipient:r}}function fc({amount:e,family:t,memo:n=void 0,recipient:r}){return{amount:new P(e),family:t,memo:n,recipient:r}}function pc({family:e,amount:t,recipient:n,customFeeRate:r}){return{family:e,amount:t.toString(),recipient:n,customFeeRate:r?.toString()}}function mc({family:e,amount:t,recipient:n,customFeeRate:r}){return{family:e,amount:new P(t),recipient:n,customFeeRate:r?new P(r):void 0}}k();function hc({amount:e,data:t=void 0,family:n,method:r,nonce:i,params:a=void 0,gasLimit:o,gasFeeCap:s,gasPremium:c,recipient:l,version:u}){return{amount:e.toString(),data:t?t.toString(`hex`):void 0,family:n,gasLimit:o.toNumber(),gasFeeCap:s.toString(),gasPremium:c.toString(),method:r,nonce:i,params:a,recipient:l,version:u}}function gc({amount:e,data:t=void 0,family:n,method:r,nonce:i,params:a=void 0,gasLimit:o,gasFeeCap:s,gasPremium:c,recipient:l,version:u}){return{amount:new P(e),data:t?A.from(t,`hex`):void 0,family:n,gasLimit:new P(o),gasFeeCap:new P(s),gasPremium:new P(c),nonce:i,method:r,params:a,recipient:l,version:u}}function _c({amount:e,recipient:t,family:n}){return{amount:e.toString(),recipient:t,family:n}}function vc({amount:e,recipient:t,family:n}){return{amount:new P(e),recipient:t,family:n}}var yc=({amount:e,recipient:t,family:n,mode:r,fee:i,era:a,validators:o,numOfSlashingSpans:s,rewardDestination:c})=>({amount:e.toString(),recipient:t,family:n,mode:r,fee:i?i.toString():void 0,era:a,validators:o,numOfSlashingSpans:s,rewardDestination:c}),bc=({amount:e,recipient:t,family:n,mode:r,fee:i,era:a,validators:o,numOfSlashingSpans:s,rewardDestination:c})=>({amount:new P(e),recipient:t,family:n,mode:r,fee:i?new P(i):void 0,era:a,validators:o,numOfSlashingSpans:s,rewardDestination:c}),xc=({family:e,fee:t,tag:n,amount:r,recipient:i})=>({family:e,amount:r.toString(),recipient:i,fee:t?t.toString():void 0,tag:n}),Sc=({family:e,fee:t,tag:n,amount:r,recipient:i})=>({family:e,amount:new P(r),recipient:i,fee:t?new P(t):void 0,tag:n}),Cc=({amount:e,recipient:t,family:n,fees:r,memoType:i,memoValue:a})=>({amount:e.toString(),recipient:t,family:n,fees:r?r.toString():void 0,memoType:i,memoValue:a}),wc=({amount:e,recipient:t,family:n,fees:r,memoType:i,memoValue:a})=>({amount:new P(e),recipient:t,family:n,fees:r?new P(r):void 0,memoType:i,memoValue:a}),Tc=({amount:e,recipient:t,family:n,mode:r,fees:i,gasLimit:a})=>({amount:e.toString(),recipient:t,family:n,mode:r,fees:i?i.toString():void 0,gasLimit:a?a.toString():void 0}),Ec=({amount:e,recipient:t,family:n,mode:r,fees:i,gasLimit:a})=>({amount:new P(e),recipient:t,family:n,mode:r,fees:i?new P(i):void 0,gasLimit:a?new P(a):void 0}),Dc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.inspectSymbol=void 0,e.inspectSymbol=Symbol.for(`nodejs.util.inspect.custom`)})),Oc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.crc16=void 0;function t(e){let t=0,n=A.alloc(e.length+2);n.set(e);for(let e of n){let n=128;for(;n>0;)t<<=1,e&n&&(t+=1),n>>=1,t>65535&&(t&=65535,t^=4129)}return A.from([Math.floor(t/256),t%256])}e.crc16=t})),kc=t((e=>{k();var t;Object.defineProperty(e,"__esModule",{value:!0}),e.address=e.Address=void 0;var n=Dc(),r=Oc(),i=17,a=81,o=128;function s(e){if(typeof e==`string`&&!c.isFriendly(e))throw Error(`Unknown address type`);let t=A.isBuffer(e)?e:A.from(e,`base64`);if(t.length!==36)throw Error(`Unknown address type: byte length is not equal to 36`);let n=t.subarray(0,34),s=t.subarray(34,36),l=(0,r.crc16)(n);if(l[0]!==s[0]||l[1]!==s[1])throw Error(`Invalid checksum: `+e);let u=n[0],d=!1,f=!1;if(u&o&&(d=!0,u^=o),u!==i&&u!==a)throw`Unknown address tag`;f=u===i;let p=null;p=n[1]===255?-1:n[1];let m=n.subarray(2,34);return{isTestOnly:d,isBounceable:f,workchain:p,hashPart:m}}var c=class e{static isAddress(t){return t instanceof e}static isFriendly(e){return!(e.length!==48||!/^[A-Za-z0-9+/_-]+$/.test(e))}static isRaw(e){if(e.indexOf(`:`)===-1)return!1;let[t,n]=e.split(`:`);return!(!Number.isInteger(parseFloat(t))||!/[a-f0-9]+/.test(n.toLowerCase())||n.length!==64)}static normalize(t){return typeof t==`string`?e.parse(t).toString():t.toString()}static parse(t){if(e.isFriendly(t))return this.parseFriendly(t).address;if(e.isRaw(t))return this.parseRaw(t);throw Error(`Unknown address type: `+t)}static parseRaw(t){let n=parseInt(t.split(`:`)[0]),r=A.from(t.split(`:`)[1],`hex`);return new e(n,r)}static parseFriendly(t){if(A.isBuffer(t)){let n=s(t);return{isBounceable:n.isBounceable,isTestOnly:n.isTestOnly,address:new e(n.workchain,n.hashPart)}}{let n=s(t.replace(/\-/g,`+`).replace(/_/g,`/`));return{isBounceable:n.isBounceable,isTestOnly:n.isTestOnly,address:new e(n.workchain,n.hashPart)}}}constructor(e,n){if(this.toRawString=()=>this.workChain+`:`+this.hash.toString(`hex`),this.toRaw=()=>{let e=A.alloc(36);return e.set(this.hash),e.set([this.workChain,this.workChain,this.workChain,this.workChain],32),e},this.toStringBuffer=e=>{let t=e&&e.testOnly!==void 0?e.testOnly:!1,n=!(e&&e.bounceable!==void 0)||e.bounceable?i:a;t&&(n|=o);let s=A.alloc(34);s[0]=n,s[1]=this.workChain,s.set(this.hash,2);let c=A.alloc(36);return c.set(s),c.set((0,r.crc16)(s),34),c},this.toString=e=>{let t=e&&e.urlSafe!==void 0?e.urlSafe:!0,n=this.toStringBuffer(e);return t?n.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`):n.toString(`base64`)},this[t]=()=>this.toString(),n.length!==32)throw Error(`Invalid address hash length: `+n.length);this.workChain=e,this.hash=n,Object.freeze(this)}equals(e){return e.workChain===this.workChain&&e.hash.equals(this.hash)}};e.Address=c,t=n.inspectSymbol;function l(e){return c.parse(e)}e.address=l})),Ac=t((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ExternalAddress=void 0;var n=Dc();e.ExternalAddress=class e{static isAddress(t){return t instanceof e}constructor(e,n){this[t]=()=>this.toString(),this.value=e,this.bits=n}toString(){return`External<${this.bits}:${this.value}>`}},t=n.inspectSymbol})),jc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.base32Decode=e.base32Encode=void 0;var t=`abcdefghijklmnopqrstuvwxyz234567`;function n(e){let n=e.byteLength,r=0,i=0,a=``;for(let o=0;o<n;o++)for(i=i<<8|e[o],r+=8;r>=5;)a+=t[i>>>r-5&31],r-=5;return r>0&&(a+=t[i<<5-r&31]),a}e.base32Encode=n;function r(e,t){let n=e.indexOf(t);if(n===-1)throw Error(`Invalid character found: `+t);return n}function i(e){let n;n=e.toLowerCase();let{length:i}=n,a=0,o=0,s=0,c=A.alloc(i*5/8|0);for(let e=0;e<i;e++)o=o<<5|r(t,n[e]),a+=5,a>=8&&(c[s++]=o>>>a-8&255,a-=8);return c}e.base32Decode=i})),Mc=t((e=>{k();var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ADNLAddress=void 0;var n=Dc(),r=jc(),i=Oc();e.ADNLAddress=class e{static parseFriendly(t){if(t.length!==55)throw Error(`Invalid address`);t=`f`+t;let n=(0,r.base32Decode)(t);if(n[0]!==45)throw Error(`Invalid address`);let a=n.slice(33);if(!(0,i.crc16)(n.slice(0,33)).equals(a))throw Error(`Invalid address`);return new e(n.slice(1,33))}static parseRaw(t){let n=A.from(t,`base64`);return new e(n)}constructor(e){if(this.toRaw=()=>this.address.toString(`hex`).toUpperCase(),this.toString=()=>{let e=A.concat([A.from([45]),this.address]),t=(0,i.crc16)(e);return e=A.concat([e,t]),(0,r.base32Encode)(e).slice(1)},this[t]=()=>this.toString(),e.length!==32)throw Error(`Invalid address`);this.address=e}equals(e){return this.address.equals(e.address)}},t=n.inspectSymbol})),Nc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.paddedBufferToBits=e.bitsToPaddedBuffer=void 0;var t=Fc(),n=Pc();function r(e){let n=new t.BitBuilder(Math.ceil(e.length/8)*8);n.writeBits(e);let r=Math.ceil(e.length/8)*8-e.length;for(let e=0;e<r;e++)e===0?n.writeBit(1):n.writeBit(0);return n.buffer()}e.bitsToPaddedBuffer=r;function i(e){let t=0;for(let n=e.length-1;n>=0;n--)if(e[n]!==0){let r=e[n],i=r&-r;i&1||(i=Math.log2(i)+1),n>0&&(t=n<<3),t+=8-i;break}return new n.BitString(e,0,t)}e.paddedBufferToBits=i})),Pc=t((e=>{k();var t;Object.defineProperty(e,"__esModule",{value:!0}),e.BitString=void 0;var n=Nc(),r=Dc(),i=class e{static isBitString(t){return t instanceof e}constructor(e,n,r){if(this[t]=()=>this.toString(),r<0)throw Error(`Length ${r} is out of bounds`);this._length=r,this._data=e,this._offset=n}get length(){return this._length}at(e){if(e>=this._length)throw Error(`Index ${e} > ${this._length} is out of bounds`);if(e<0)throw Error(`Index ${e} < 0 is out of bounds`);let t=this._offset+e>>3,n=7-(this._offset+e)%8;return!!(this._data[t]&1<<n)}substring(t,n){if(t>this._length)throw Error(`Offset(${t}) > ${this._length} is out of bounds`);if(t<0)throw Error(`Offset(${t}) < 0 is out of bounds`);if(n===0)return e.EMPTY;if(t+n>this._length)throw Error(`Offset ${t} + Length ${n} > ${this._length} is out of bounds`);return new e(this._data,this._offset+t,n)}subbuffer(e,t){if(e>this._length||e<0)throw Error(`Offset ${e} is out of bounds`);if(e+t>this._length)throw Error(`Offset + Length = ${e+t} is out of bounds`);if(t%8!=0||(this._offset+e)%8!=0)return null;let n=this._offset+e>>3,r=n+(t>>3);return this._data.subarray(n,r)}equals(e){if(this._length!==e._length)return!1;for(let t=0;t<this._length;t++)if(this.at(t)!==e.at(t))return!1;return!0}toString(){let e=(0,n.bitsToPaddedBuffer)(this);if(this._length%4==0){let t=e.subarray(0,Math.ceil(this._length/8)).toString(`hex`).toUpperCase();return this._length%8==0?t:t.substring(0,t.length-1)}{let t=e.toString(`hex`).toUpperCase();return this._length%8<=4?t.substring(0,t.length-1)+`_`:t+`_`}}};e.BitString=i,t=r.inspectSymbol,i.EMPTY=new i(A.alloc(0),0,0)})),Fc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.BitBuilder=void 0;var t=kc(),n=Ac(),r=Pc();e.BitBuilder=class{constructor(e=1023){this._buffer=A.alloc(Math.ceil(e/8)),this._length=0}get length(){return this._length}writeBit(e){let t=this._length;if(t>this._buffer.length*8)throw Error(`BitBuilder overflow`);(typeof e==`boolean`&&e===!0||typeof e==`number`&&e>0)&&(this._buffer[t/8|0]|=1<<7-t%8),this._length++}writeBits(e){for(let t=0;t<e.length;t++)this.writeBit(e.at(t))}writeBuffer(e){if(this._length%8==0){if(this._length+e.length*8>this._buffer.length*8)throw Error(`BitBuilder overflow`);e.copy(this._buffer,this._length/8),this._length+=e.length*8}else for(let t=0;t<e.length;t++)this.writeUint(e[t],8)}writeUint(e,t){if(t<0||!Number.isSafeInteger(t))throw Error(`invalid bit length. Got ${t}`);let n=BigInt(e);if(t===0){if(n!==0n)throw Error(`value is not zero for ${t} bits. Got ${e}`);return}let r=1n<<BigInt(t);if(n<0||n>=r)throw Error(`bitLength is too small for a value ${e}. Got ${t}`);if(this._length+t>this._buffer.length*8)throw Error(`BitBuilder overflow`);let i=8-this._length%8;if(i>0){let e=Math.floor(this._length/8);if(t<i){let r=Number(n);this._buffer[e]|=r<<i-t,this._length+=t}else{let r=Number(n>>BigInt(t-i));this._buffer[e]|=r,this._length+=i}}for(t-=i;t>0;)t>=8?(this._buffer[this._length/8]=Number(n>>BigInt(t-8)&255n),this._length+=8,t-=8):(this._buffer[this._length/8]=Number(n<<BigInt(8-t)&255n),this._length+=t,t=0)}writeInt(e,t){let n=BigInt(e);if(t<0||!Number.isSafeInteger(t))throw Error(`invalid bit length. Got ${t}`);if(t===0){if(n!==0n)throw Error(`value is not zero for ${t} bits. Got ${e}`);return}if(t===1){if(n!==-1n&&n!==0n)throw Error(`value is not zero or -1 for ${t} bits. Got ${e}`);this.writeBit(n===-1n);return}let r=1n<<BigInt(t)-1n;if(n<-r||n>=r)throw Error(`value is out of range for ${t} bits. Got ${e}`);n<0?(this.writeBit(!0),n=r+n):this.writeBit(!1),this.writeUint(n,t-1)}writeVarUint(e,t){let n=BigInt(e);if(t<0||!Number.isSafeInteger(t))throw Error(`invalid bit length. Got ${t}`);if(n<0)throw Error(`value is negative. Got ${e}`);if(n===0n){this.writeUint(0,t);return}let r=Math.ceil(n.toString(2).length/8),i=r*8;this.writeUint(r,t),this.writeUint(n,i)}writeVarInt(e,t){let n=BigInt(e);if(t<0||!Number.isSafeInteger(t))throw Error(`invalid bit length. Got ${t}`);if(n===0n){this.writeUint(0,t);return}let r=n>0?n:-n,i=Math.ceil((r.toString(2).length+1)/8),a=i*8;this.writeUint(i,t),this.writeInt(n,a)}writeCoins(e){this.writeVarUint(e,4)}writeAddress(e){if(e==null){this.writeUint(0,2);return}if(t.Address.isAddress(e)){this.writeUint(2,2),this.writeUint(0,1),this.writeInt(e.workChain,8),this.writeBuffer(e.hash);return}if(n.ExternalAddress.isAddress(e)){this.writeUint(1,2),this.writeUint(e.bits,9),this.writeUint(e.value,e.bits);return}throw Error(`Invalid address. Got ${e}`)}build(){return new r.BitString(this._buffer,0,this._length)}buffer(){if(this._length%8!=0)throw Error(`BitBuilder buffer is not byte aligned`);return this._buffer.subarray(0,this._length/8)}}})),Ic=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CellType=void 0;var t;(function(e){e[e.Ordinary=-1]=`Ordinary`,e[e.PrunedBranch=1]=`PrunedBranch`,e[e.Library=2]=`Library`,e[e.MerkleProof=3]=`MerkleProof`,e[e.MerkleUpdate=4]=`MerkleUpdate`})(t||(e.CellType=t={}))})),Lc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.readUnaryLength=void 0;function t(e){let t=0;for(;e.loadBit();)t++;return t}e.readUnaryLength=t})),Rc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.BitReader=void 0;var t=kc(),n=Ac();e.BitReader=class e{constructor(e,t=0){this._checkpoints=[],this._bits=e,this._offset=t}get offset(){return this._offset}get remaining(){return this._bits.length-this._offset}skip(e){if(e<0||this._offset+e>this._bits.length)throw Error(`Index ${this._offset+e} is out of bounds`);this._offset+=e}reset(){this._offset=this._checkpoints.length>0?this._checkpoints.pop():0}save(){this._checkpoints.push(this._offset)}loadBit(){let e=this._bits.at(this._offset);return this._offset++,e}preloadBit(){return this._bits.at(this._offset)}loadBits(e){let t=this._bits.substring(this._offset,e);return this._offset+=e,t}preloadBits(e){return this._bits.substring(this._offset,e)}loadBuffer(e){let t=this._preloadBuffer(e,this._offset);return this._offset+=e*8,t}preloadBuffer(e){return this._preloadBuffer(e,this._offset)}loadUint(e){return this._toSafeInteger(this.loadUintBig(e),`loadUintBig`)}loadUintBig(e){let t=this.preloadUintBig(e);return this._offset+=e,t}preloadUint(e){return this._toSafeInteger(this._preloadUint(e,this._offset),`preloadUintBig`)}preloadUintBig(e){return this._preloadUint(e,this._offset)}loadInt(e){let t=this._preloadInt(e,this._offset);return this._offset+=e,this._toSafeInteger(t,`loadUintBig`)}loadIntBig(e){let t=this._preloadInt(e,this._offset);return this._offset+=e,t}preloadInt(e){return this._toSafeInteger(this._preloadInt(e,this._offset),`preloadIntBig`)}preloadIntBig(e){return this._preloadInt(e,this._offset)}loadVarUint(e){let t=Number(this.loadUint(e));return this._toSafeInteger(this.loadUintBig(t*8),`loadVarUintBig`)}loadVarUintBig(e){let t=Number(this.loadUint(e));return this.loadUintBig(t*8)}preloadVarUint(e){let t=Number(this._preloadUint(e,this._offset));return this._toSafeInteger(this._preloadUint(t*8,this._offset+e),`preloadVarUintBig`)}preloadVarUintBig(e){let t=Number(this._preloadUint(e,this._offset));return this._preloadUint(t*8,this._offset+e)}loadVarInt(e){let t=Number(this.loadUint(e));return this._toSafeInteger(this.loadIntBig(t*8),`loadVarIntBig`)}loadVarIntBig(e){let t=Number(this.loadUint(e));return this.loadIntBig(t*8)}preloadVarInt(e){let t=Number(this._preloadUint(e,this._offset));return this._toSafeInteger(this._preloadInt(t*8,this._offset+e),`preloadVarIntBig`)}preloadVarIntBig(e){let t=Number(this._preloadUint(e,this._offset));return this._preloadInt(t*8,this._offset+e)}loadCoins(){return this.loadVarUintBig(4)}preloadCoins(){return this.preloadVarUintBig(4)}loadAddress(){let e=Number(this._preloadUint(2,this._offset));if(e===2)return this._loadInternalAddress();throw Error(`Invalid address: `+e)}loadMaybeAddress(){let e=Number(this._preloadUint(2,this._offset));if(e===0)return this._offset+=2,null;if(e===2)return this._loadInternalAddress();throw Error(`Invalid address`)}loadExternalAddress(){if(Number(this._preloadUint(2,this._offset))===1)return this._loadExternalAddress();throw Error(`Invalid address`)}loadMaybeExternalAddress(){let e=Number(this._preloadUint(2,this._offset));if(e===0)return this._offset+=2,null;if(e===1)return this._loadExternalAddress();throw Error(`Invalid address`)}loadAddressAny(){let e=Number(this._preloadUint(2,this._offset));if(e===0)return this._offset+=2,null;if(e===2)return this._loadInternalAddress();if(e===1)return this._loadExternalAddress();throw Error(e===3?`Unsupported`:`Unreachable`)}loadPaddedBits(e){if(e%8!=0)throw Error(`Invalid number of bits`);let t=e;for(;;)if(this._bits.at(this._offset+t-1)){t--;break}else t--;let n=this._bits.substring(this._offset,t);return this._offset+=e,n}clone(){return new e(this._bits,this._offset)}_preloadInt(e,t){if(e==0)return 0n;let n=this._bits.at(t),r=0n;for(let n=0;n<e-1;n++)this._bits.at(t+1+n)&&(r+=1n<<BigInt(e-n-1-1));return n&&(r-=1n<<BigInt(e-1)),r}_preloadUint(e,t){if(e==0)return 0n;let n=0n;for(let r=0;r<e;r++)this._bits.at(t+r)&&(n+=1n<<BigInt(e-r-1));return n}_preloadBuffer(e,t){let n=this._bits.subbuffer(t,e*8);if(n)return n;let r=A.alloc(e);for(let n=0;n<e;n++)r[n]=Number(this._preloadUint(8,t+n*8));return r}_loadInternalAddress(){if(Number(this._preloadUint(2,this._offset))!==2)throw Error(`Invalid address`);let e,n;this._preloadUint(1,this._offset+2)!==0n&&(n=Number(this._preloadUint(5,this._offset+3)),e=this._preloadUint(n,this._offset+8),this._offset+=5+n);let r=Number(this._preloadInt(8,this._offset+3)),i=this._preloadBuffer(32,this._offset+11);if(n!==void 0&&e!==void 0){let t=Number(e),r=0,a=0,o=n;for(;o>0;){let e=Math.min(8-a,o),n=(1<<e)-1<<8-a-e,s=(t>>o-e&(1<<e)-1)<<8-a-e;i[r]=i[r]&~n|s,o-=e,a+=e,a===8&&(r++,a=0)}}return this._offset+=267,new t.Address(r,i)}_loadExternalAddress(){if(Number(this._preloadUint(2,this._offset))!==1)throw Error(`Invalid address`);let e=Number(this._preloadUint(9,this._offset+2)),t=this._preloadUint(e,this._offset+11);return this._offset+=11+e,new n.ExternalAddress(t,e)}_toSafeInteger(e,t){if(BigInt(2**53-1)<e||e<BigInt(-(2**53-1)))throw TypeError(`${e} is out of safe integer range. Use ${t} instead`);return Number(e)}}})),zc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.convertToMerkleProof=e.exoticMerkleProof=void 0;var t=Rc(),n=$();function r(e,n){let r=new t.BitReader(e);if(e.length!==280)throw Error(`Merkle Proof cell must have exactly (8 + 256 + 16) bits, got "${e.length}"`);if(n.length!==1)throw Error(`Merkle Proof cell must have exactly 1 ref, got "${n.length}"`);let i=r.loadUint(8);if(i!==3)throw Error(`Merkle Proof cell must have type 3, got "${i}"`);let a=r.loadBuffer(32),o=r.loadUint(16),s=n[0].hash(0),c=n[0].depth(0);if(o!==c)throw Error(`Merkle Proof cell ref depth must be exactly "${o}", got "${c}"`);if(!a.equals(s))throw Error(`Merkle Proof cell ref hash must be exactly "${a.toString(`hex`)}", got "${s.toString(`hex`)}"`);return{proofDepth:o,proofHash:a}}e.exoticMerkleProof=r;function i(e){return(0,n.beginCell)().storeUint(3,8).storeBuffer(e.hash(0)).storeUint(e.depth(0),16).storeRef(e).endCell({exotic:!0})}e.convertToMerkleProof=i})),Bc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateMerkleProof=e.generateMerkleProofDirect=void 0;var t=$(),n=Lc(),r=zc();function i(e){return(0,t.beginCell)().storeUint(1,8).storeUint(1,8).storeBuffer(e.hash(0)).storeUint(e.depth(0),16).endCell({exotic:!0})}function a(e,r,o,s){let c=r.asCell();if(s.length==0)return i(c);let l=+!!r.loadBit(),u=0,d=e;if(l===0){u=(0,n.readUnaryLength)(r);for(let e=0;e<u;e++)d+=r.loadBit()?`1`:`0`}else if(+!!r.loadBit()==0){u=r.loadUint(Math.ceil(Math.log2(o+1)));for(let e=0;e<u;e++)d+=r.loadBit()?`1`:`0`}else{let e=r.loadBit()?`1`:`0`;u=r.loadUint(Math.ceil(Math.log2(o+1)));for(let t=0;t<u;t++)d+=e}if(o-u===0)return c;{let e=c.beginParse(),n=e.loadRef(),r=e.loadRef();if(!n.isExotic){let e=s.filter(e=>d+`0`===e.slice(0,d.length+1));n=a(d+`0`,n.beginParse(),o-u-1,e)}if(!r.isExotic){let e=s.filter(e=>d+`1`===e.slice(0,d.length+1));r=a(d+`1`,r.beginParse(),o-u-1,e)}return(0,t.beginCell)().storeSlice(e).storeRef(n).storeRef(r).endCell()}}function o(e,n,r){return n.forEach(t=>{if(!e.has(t))throw Error(`Trying to generate merkle proof for a missing key "${t}"`)}),a(``,(0,t.beginCell)().storeDictDirect(e).asSlice(),r.bits,n.map(e=>r.serialize(e).toString(2).padStart(r.bits,`0`)))}e.generateMerkleProofDirect=o;function s(e,t,n){return(0,r.convertToMerkleProof)(o(e,t,n))}e.generateMerkleProof=s})),Vc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateMerkleUpdate=void 0;var t=$(),n=Bc();function r(e,n){return(0,t.beginCell)().storeUint(4,8).storeBuffer(e.hash(0)).storeBuffer(n.hash(0)).storeUint(e.depth(0),16).storeUint(n.depth(0),16).storeRef(e).storeRef(n).endCell({exotic:!0})}function i(e,t,i,a){let o=(0,n.generateMerkleProof)(e,[t],i).refs[0];e.set(t,a);let s=(0,n.generateMerkleProof)(e,[t],i).refs[0];return r(o,s)}e.generateMerkleUpdate=i})),Hc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseDict=void 0;function t(e){let t=0;for(;e.loadBit();)t++;return t}function n(e,r,i,a,o){let s=+!!r.loadBit(),c=0,l=e;if(s===0){c=t(r);for(let e=0;e<c;e++)l+=r.loadBit()?`1`:`0`}else if(+!!r.loadBit()==0){c=r.loadUint(Math.ceil(Math.log2(i+1)));for(let e=0;e<c;e++)l+=r.loadBit()?`1`:`0`}else{let e=r.loadBit()?`1`:`0`;c=r.loadUint(Math.ceil(Math.log2(i+1)));for(let t=0;t<c;t++)l+=e}if(i-c===0)a.set(BigInt(`0b`+l),o(r));else{let e=r.loadRef(),t=r.loadRef();e.isExotic||n(l+`0`,e.beginParse(),i-c-1,a,o),t.isExotic||n(l+`1`,t.beginParse(),i-c-1,a,o)}}function r(e,t,r){let i=new Map;return e&&n(``,e,t,i,r),i}e.parseDict=r})),Uc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.findCommonPrefix=void 0;function t(e,t=0){if(e.length===0)return``;let n=e[0].slice(t);for(let r=1;r<e.length;r++){let i=e[r];for(;i.indexOf(n,t)!==t;)if(n=n.substring(0,n.length-1),n===``)return n}return n}e.findCommonPrefix=t})),Wc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.serializeDict=e.detectLabelType=e.writeLabelSame=e.writeLabelLong=e.writeLabelShort=e.buildTree=void 0;var t=$(),n=Uc();function r(e,t){for(;e.length<t;)e=`0`+e;return e}function i(e,t){if(e.size===0)throw Error(`Internal inconsistency`);let n=new Map,r=new Map;for(let[i,a]of e.entries())i[t]===`0`?n.set(i,a):r.set(i,a);if(n.size===0)throw Error(`Internal inconsistency. Left emtpy.`);if(r.size===0)throw Error(`Internal inconsistency. Right emtpy.`);return{left:n,right:r}}function a(e,t){if(e.size===0)throw Error(`Internal inconsistency`);if(e.size===1)return{type:`leaf`,value:Array.from(e.values())[0]};let{left:n,right:r}=i(e,t);return{type:`fork`,left:o(n,t+1),right:o(r,t+1)}}function o(e,t=0){if(e.size===0)throw Error(`Internal inconsistency`);let r=(0,n.findCommonPrefix)(Array.from(e.keys()),t);return{label:r,node:a(e,r.length+t)}}function s(e,t){let n=new Map;for(let i of Array.from(e.keys())){let a=r(i.toString(2),t);n.set(a,e.get(i))}return o(n)}e.buildTree=s;function c(e,t){t.storeBit(0);for(let n=0;n<e.length;n++)t.storeBit(1);return t.storeBit(0),e.length>0&&t.storeUint(BigInt(`0b`+e),e.length),t}e.writeLabelShort=c;function l(e){return 1+e.length+1+e.length}function u(e,t,n){n.storeBit(1),n.storeBit(0);let r=Math.ceil(Math.log2(t+1));return n.storeUint(e.length,r),e.length>0&&n.storeUint(BigInt(`0b`+e),e.length),n}e.writeLabelLong=u;function d(e,t){return 2+Math.ceil(Math.log2(t+1))+e.length}function f(e,t,n,r){r.storeBit(1),r.storeBit(1),r.storeBit(e);let i=Math.ceil(Math.log2(n+1));r.storeUint(t,i)}e.writeLabelSame=f;function p(e){return 3+Math.ceil(Math.log2(e+1))}function m(e){if(e.length===0||e.length===1)return!0;for(let t=1;t<e.length;t++)if(e[t]!==e[0])return!1;return!0}function h(e,t){let n=`short`,r=l(e),i=d(e,t);if(i<r&&(r=i,n=`long`),m(e)){let e=p(t);e<r&&(r=e,n=`same`)}return n}e.detectLabelType=h;function g(e,t,n){let r=h(e,t);r===`short`?c(e,n):r===`long`?u(e,t,n):r===`same`&&f(e[0]===`1`,e.length,t,n)}function _(e,n,r,i){if(e.type===`leaf`&&r(e.value,i),e.type===`fork`){let a=(0,t.beginCell)(),o=(0,t.beginCell)();v(e.left,n-1,r,a),v(e.right,n-1,r,o),i.storeRef(a),i.storeRef(o)}}function v(e,t,n,r){g(e.label,t,r),_(e.node,t-e.label.length,n,r)}function y(e,t,n,r){v(s(e,t),t,n,r)}e.serializeDict=y})),Gc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.deserializeInternalKey=e.serializeInternalKey=void 0;var t=kc(),n=Pc(),r=Nc();function i(e){if(typeof e==`number`){if(!Number.isSafeInteger(e))throw Error(`Invalid key type: not a safe integer: `+e);return`n:`+e.toString(10)}if(typeof e==`bigint`)return`b:`+e.toString(10);if(t.Address.isAddress(e))return`a:`+e.toString();if(A.isBuffer(e))return`f:`+e.toString(`hex`);if(n.BitString.isBitString(e))return`B:`+e.toString();throw Error(`Invalid key type`)}e.serializeInternalKey=i;function a(e){let i=e.slice(0,2),a=e.slice(2);if(i===`n:`)return parseInt(a,10);if(i===`b:`)return BigInt(a);if(i===`a:`)return t.Address.parse(a);if(i===`f:`)return A.from(a,`hex`);if(i===`B:`){let e=a.slice(-1)==`_`;if(e||a.length%2!=0){let t=e?a.length-1:a.length,i=a.substr(0,t)+`0`;return!e&&t&1?new n.BitString(A.from(i,`hex`),0,t<<2):(0,r.paddedBufferToBits)(A.from(i,`hex`))}return new n.BitString(A.from(a,`hex`),0,a.length<<2)}throw Error(`Invalid key type: `+i)}e.deserializeInternalKey=a})),Kc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.Dictionary=void 0;var t=kc(),n=$(),r=ol(),i=Pc(),a=Bc(),o=Vc(),s=Hc(),c=Wc(),l=Gc(),u=class e{static empty(t,n){return t&&n?new e(new Map,t,n):new e(new Map,null,null)}static load(t,n,i){let a;if(i instanceof r.Cell){if(i.isExotic)return e.empty(t,n);a=i.beginParse()}else a=i;let o=a.loadMaybeRef();return o&&!o.isExotic?e.loadDirect(t,n,o.beginParse()):e.empty(t,n)}static loadDirect(t,n,i){if(!i)return e.empty(t,n);let a;a=i instanceof r.Cell?i.beginParse():i;let o=(0,s.parseDict)(a,t.bits,n.parse),c=new Map;for(let[e,n]of o)c.set((0,l.serializeInternalKey)(t.parse(e)),n);return new e(c,t,n)}constructor(e,t,n){this._key=t,this._value=n,this._map=e}get size(){return this._map.size}get(e){return this._map.get((0,l.serializeInternalKey)(e))}has(e){return this._map.has((0,l.serializeInternalKey)(e))}set(e,t){return this._map.set((0,l.serializeInternalKey)(e),t),this}delete(e){let t=(0,l.serializeInternalKey)(e);return this._map.delete(t)}clear(){this._map.clear()}*[Symbol.iterator](){for(let[e,t]of this._map)yield[(0,l.deserializeInternalKey)(e),t]}keys(){return Array.from(this._map.keys()).map(e=>(0,l.deserializeInternalKey)(e))}values(){return Array.from(this._map.values())}store(e,t,r){if(this._map.size===0)e.storeBit(0);else{let i=this._key;t!=null&&(i=t);let a=this._value;if(r!=null&&(a=r),!i)throw Error(`Key serializer is not defined`);if(!a)throw Error(`Value serializer is not defined`);let o=new Map;for(let[e,t]of this._map)o.set(i.serialize((0,l.deserializeInternalKey)(e)),t);e.storeBit(1);let s=(0,n.beginCell)();(0,c.serializeDict)(o,i.bits,a.serialize,s),e.storeRef(s.endCell())}}storeDirect(e,t,n){if(this._map.size===0)throw Error(`Cannot store empty dictionary directly`);let r=this._key;t!=null&&(r=t);let i=this._value;if(n!=null&&(i=n),!r)throw Error(`Key serializer is not defined`);if(!i)throw Error(`Value serializer is not defined`);let a=new Map;for(let[e,t]of this._map)a.set(r.serialize((0,l.deserializeInternalKey)(e)),t);(0,c.serializeDict)(a,r.bits,i.serialize,e)}generateMerkleProof(e){return(0,a.generateMerkleProof)(this,e,this._key)}generateMerkleProofDirect(e){return(0,a.generateMerkleProofDirect)(this,e,this._key)}generateMerkleUpdate(e,t){return(0,o.generateMerkleUpdate)(this,e,this._key,t)}};e.Dictionary=u,u.Keys={Address:()=>d(),BigInt:e=>f(e),Int:e=>p(e),BigUint:e=>m(e),Uint:e=>h(e),Buffer:e=>g(e),BitString:e=>_(e)},u.Values={BigInt:e=>y(e),Int:e=>v(e),BigVarInt:e=>b(e),BigUint:e=>C(e),Uint:e=>S(e),BigVarUint:e=>x(e),Bool:()=>ee(),Address:()=>w(),Cell:()=>T(),Buffer:e=>D(e),BitString:e=>O(e),Dictionary:(e,t)=>E(e,t)};function d(){return{bits:267,serialize:e=>{if(!t.Address.isAddress(e))throw Error(`Key is not an address`);return(0,n.beginCell)().storeAddress(e).endCell().beginParse().preloadUintBig(267)},parse:e=>(0,n.beginCell)().storeUint(e,267).endCell().beginParse().loadAddress()}}function f(e){return{bits:e,serialize:t=>{if(typeof t!=`bigint`)throw Error(`Key is not a bigint`);return(0,n.beginCell)().storeInt(t,e).endCell().beginParse().loadUintBig(e)},parse:t=>(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadIntBig(e)}}function p(e){return{bits:e,serialize:t=>{if(typeof t!=`number`)throw Error(`Key is not a number`);if(!Number.isSafeInteger(t))throw Error(`Key is not a safe integer: `+t);return(0,n.beginCell)().storeInt(t,e).endCell().beginParse().loadUintBig(e)},parse:t=>(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadInt(e)}}function m(e){return{bits:e,serialize:t=>{if(typeof t!=`bigint`)throw Error(`Key is not a bigint`);if(t<0)throw Error(`Key is negative: `+t);return(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadUintBig(e)},parse:t=>(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadUintBig(e)}}function h(e){return{bits:e,serialize:t=>{if(typeof t!=`number`)throw Error(`Key is not a number`);if(!Number.isSafeInteger(t))throw Error(`Key is not a safe integer: `+t);if(t<0)throw Error(`Key is negative: `+t);return(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadUintBig(e)},parse:t=>Number((0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadUint(e))}}function g(e){return{bits:e*8,serialize:t=>{if(!A.isBuffer(t))throw Error(`Key is not a buffer`);return(0,n.beginCell)().storeBuffer(t).endCell().beginParse().loadUintBig(e*8)},parse:t=>(0,n.beginCell)().storeUint(t,e*8).endCell().beginParse().loadBuffer(e)}}function _(e){return{bits:e,serialize:t=>{if(!i.BitString.isBitString(t))throw Error(`Key is not a BitString`);return(0,n.beginCell)().storeBits(t).endCell().beginParse().loadUintBig(e)},parse:t=>(0,n.beginCell)().storeUint(t,e).endCell().beginParse().loadBits(e)}}function v(e){return{serialize:(t,n)=>{n.storeInt(t,e)},parse:t=>{let n=t.loadInt(e);return t.endParse(),n}}}function y(e){return{serialize:(t,n)=>{n.storeInt(t,e)},parse:t=>{let n=t.loadIntBig(e);return t.endParse(),n}}}function b(e){return{serialize:(t,n)=>{n.storeVarInt(t,e)},parse:t=>{let n=t.loadVarIntBig(e);return t.endParse(),n}}}function x(e){return{serialize:(t,n)=>{n.storeVarUint(t,e)},parse:t=>{let n=t.loadVarUintBig(e);return t.endParse(),n}}}function S(e){return{serialize:(t,n)=>{n.storeUint(t,e)},parse:t=>{let n=t.loadUint(e);return t.endParse(),n}}}function C(e){return{serialize:(t,n)=>{n.storeUint(t,e)},parse:t=>{let n=t.loadUintBig(e);return t.endParse(),n}}}function ee(){return{serialize:(e,t)=>{t.storeBit(e)},parse:e=>{let t=e.loadBit();return e.endParse(),t}}}function w(){return{serialize:(e,t)=>{t.storeAddress(e)},parse:e=>{let t=e.loadAddress();return e.endParse(),t}}}function T(){return{serialize:(e,t)=>{t.storeRef(e)},parse:e=>{let t=e.loadRef();return e.endParse(),t}}}function E(e,t){return{serialize:(e,t)=>{e.store(t)},parse:n=>{let r=u.load(e,t,n);return n.endParse(),r}}}function D(e){return{serialize:(t,n)=>{if(t.length!==e)throw Error(`Invalid buffer size`);n.storeBuffer(t)},parse:t=>{let n=t.loadBuffer(e);return t.endParse(),n}}}function O(e){return{serialize:(t,n)=>{if(t.length!==e)throw Error(`Invalid BitString size`);n.storeBits(t)},parse:t=>{let n=t.loadBits(e);return t.endParse(),n}}}})),qc=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.writeString=e.stringToCell=e.readString=void 0;var t=$();function n(e){if(e.remainingBits%8!=0)throw Error(`Invalid string length: ${e.remainingBits}`);if(e.remainingRefs!==0&&e.remainingRefs!==1)throw Error(`invalid number of refs: ${e.remainingRefs}`);let t;return t=e.remainingBits===0?A.alloc(0):e.loadBuffer(e.remainingBits/8),e.remainingRefs===1&&(t=A.concat([t,n(e.loadRef().beginParse())])),t}function r(e){return n(e).toString()}e.readString=r;function i(e,n){if(e.length>0){let r=Math.floor(n.availableBits/8);if(e.length>r){let a=e.subarray(0,r),o=e.subarray(r);n=n.storeBuffer(a);let s=(0,t.beginCell)();i(o,s),n=n.storeRef(s.endCell())}else n=n.storeBuffer(e)}}function a(e){let n=(0,t.beginCell)();return i(A.from(e),n),n.endCell()}e.stringToCell=a;function o(e,t){i(A.from(e),t)}e.writeString=o})),Jc=t((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Slice=void 0;var n=Dc(),r=Kc(),i=$(),a=qc();e.Slice=class e{constructor(e,n){this[t]=()=>this.toString(),this._reader=e.clone(),this._refs=[...n],this._refsOffset=0}get remainingBits(){return this._reader.remaining}get offsetBits(){return this._reader.offset}get remainingRefs(){return this._refs.length-this._refsOffset}get offsetRefs(){return this._refsOffset}skip(e){return this._reader.skip(e),this}loadBit(){return this._reader.loadBit()}preloadBit(){return this._reader.preloadBit()}loadBoolean(){return this.loadBit()}loadMaybeBoolean(){return this.loadBit()?this.loadBoolean():null}loadBits(e){return this._reader.loadBits(e)}preloadBits(e){return this._reader.preloadBits(e)}loadUint(e){return this._reader.loadUint(e)}loadUintBig(e){return this._reader.loadUintBig(e)}preloadUint(e){return this._reader.preloadUint(e)}preloadUintBig(e){return this._reader.preloadUintBig(e)}loadMaybeUint(e){return this.loadBit()?this.loadUint(e):null}loadMaybeUintBig(e){return this.loadBit()?this.loadUintBig(e):null}loadInt(e){return this._reader.loadInt(e)}loadIntBig(e){return this._reader.loadIntBig(e)}preloadInt(e){return this._reader.preloadInt(e)}preloadIntBig(e){return this._reader.preloadIntBig(e)}loadMaybeInt(e){return this.loadBit()?this.loadInt(e):null}loadMaybeIntBig(e){return this.loadBit()?this.loadIntBig(e):null}loadVarUint(e){return this._reader.loadVarUint(e)}loadVarUintBig(e){return this._reader.loadVarUintBig(e)}preloadVarUint(e){return this._reader.preloadVarUint(e)}preloadVarUintBig(e){return this._reader.preloadVarUintBig(e)}loadVarInt(e){return this._reader.loadVarInt(e)}loadVarIntBig(e){return this._reader.loadVarIntBig(e)}preloadVarInt(e){return this._reader.preloadVarInt(e)}preloadVarIntBig(e){return this._reader.preloadVarIntBig(e)}loadCoins(){return this._reader.loadCoins()}preloadCoins(){return this._reader.preloadCoins()}loadMaybeCoins(){return this._reader.loadBit()?this._reader.loadCoins():null}loadAddress(){return this._reader.loadAddress()}loadMaybeAddress(){return this._reader.loadMaybeAddress()}loadExternalAddress(){return this._reader.loadExternalAddress()}loadMaybeExternalAddress(){return this._reader.loadMaybeExternalAddress()}loadAddressAny(){return this._reader.loadAddressAny()}loadRef(){if(this._refsOffset>=this._refs.length)throw Error(`No more references`);return this._refs[this._refsOffset++]}preloadRef(){if(this._refsOffset>=this._refs.length)throw Error(`No more references`);return this._refs[this._refsOffset]}loadMaybeRef(){return this.loadBit()?this.loadRef():null}preloadMaybeRef(){return this.preloadBit()?this.preloadRef():null}loadBuffer(e){return this._reader.loadBuffer(e)}preloadBuffer(e){return this._reader.preloadBuffer(e)}loadStringTail(){return(0,a.readString)(this)}loadMaybeStringTail(){return this.loadBit()?(0,a.readString)(this):null}loadStringRefTail(){return(0,a.readString)(this.loadRef().beginParse())}loadMaybeStringRefTail(){let e=this.loadMaybeRef();return e?(0,a.readString)(e.beginParse()):null}loadDict(e,t){return r.Dictionary.load(e,t,this)}loadDictDirect(e,t){return r.Dictionary.loadDirect(e,t,this)}endParse(){if(this.remainingBits>0||this.remainingRefs>0)throw Error(`Slice is not empty`)}asCell(){return(0,i.beginCell)().storeSlice(this).endCell()}asBuilder(){return(0,i.beginCell)().storeSlice(this)}clone(t=!1){if(t){let t=this._reader.clone();return t.reset(),new e(t,this._refs)}{let t=new e(this._reader,this._refs);return t._refsOffset=this._refsOffset,t}}toString(){return this.asCell().toString()}},t=n.inspectSymbol})),Yc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.exoticLibrary=void 0;var t=Rc();function n(e,n){let r=new t.BitReader(e);if(e.length!==264)throw Error(`Library cell must have exactly (8 + 256) bits, got "${e.length}"`);let i=r.loadUint(8);if(i!==2)throw Error(`Library cell must have type 2, got "${i}"`);return{}}e.exoticLibrary=n})),Xc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.exoticMerkleUpdate=void 0;var t=Rc();function n(e,n){let r=new t.BitReader(e);if(e.length!==552)throw Error(`Merkle Update cell must have exactly (8 + (2 * (256 + 16))) bits, got "${e.length}"`);if(n.length!==2)throw Error(`Merkle Update cell must have exactly 2 refs, got "${n.length}"`);let i=r.loadUint(8);if(i!==4)throw Error(`Merkle Update cell type must be exactly 4, got "${i}"`);let a=r.loadBuffer(32),o=r.loadBuffer(32),s=r.loadUint(16),c=r.loadUint(16);if(s!==n[0].depth(0))throw Error(`Merkle Update cell ref depth must be exactly "${s}", got "${n[0].depth(0)}"`);if(!a.equals(n[0].hash(0)))throw Error(`Merkle Update cell ref hash must be exactly "${a.toString(`hex`)}", got "${n[0].hash(0).toString(`hex`)}"`);if(c!==n[1].depth(0))throw Error(`Merkle Update cell ref depth must be exactly "${c}", got "${n[1].depth(0)}"`);if(!o.equals(n[1].hash(0)))throw Error(`Merkle Update cell ref hash must be exactly "${o.toString(`hex`)}", got "${n[1].hash(0).toString(`hex`)}"`);return{proofDepth1:s,proofDepth2:c,proofHash1:a,proofHash2:o}}e.exoticMerkleUpdate=n})),Zc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LevelMask=void 0,e.LevelMask=class e{constructor(e=0){this._mask=0,this._mask=e,this._hashIndex=t(this._mask),this._hashCount=this._hashIndex+1}get value(){return this._mask}get level(){return 32-Math.clz32(this._mask)}get hashIndex(){return this._hashIndex}get hashCount(){return this._hashCount}apply(t){return new e(this._mask&(1<<t)-1)}isSignificant(e){return e===0||(this._mask>>e-1)%2!=0}};function t(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}})),Qc=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.exoticPruned=void 0;var t=Rc(),n=Zc();function r(e,r){let i=new t.BitReader(e),a=i.loadUint(8);if(a!==1)throw Error(`Pruned branch cell must have type 1, got "${a}"`);if(r.length!==0)throw Error(`Pruned Branch cell can't has refs, got "${r.length}"`);let o;if(e.length===280)o=new n.LevelMask(1);else{if(o=new n.LevelMask(i.loadUint(8)),o.level<1||o.level>3)throw Error(`Pruned Branch cell level must be >= 1 and <= 3, got "${o.level}/${o.value}"`);let t=16+o.apply(o.level-1).hashCount*272;if(e.length!==t)throw Error(`Pruned branch cell must have exactly ${t} bits, got "${e.length}"`)}let s=[],c=[],l=[];for(let e=0;e<o.level;e++)c.push(i.loadBuffer(32));for(let e=0;e<o.level;e++)l.push(i.loadUint(16));for(let e=0;e<o.level;e++)s.push({depth:l[e],hash:c[e]});return{mask:o.value,pruned:s}}e.exoticPruned=r})),$c=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveExotic=void 0;var t=Rc(),n=Ic(),r=Yc(),i=zc(),a=Xc(),o=Qc(),s=Zc();function c(e,t){let r=(0,o.exoticPruned)(e,t),i=[],a=[],c=new s.LevelMask(r.mask);for(let e=0;e<r.pruned.length;e++)i.push(r.pruned[e].depth),a.push(r.pruned[e].hash);return{type:n.CellType.PrunedBranch,depths:i,hashes:a,mask:c}}function l(e,t){(0,r.exoticLibrary)(e,t);let i=[],a=[],o=new s.LevelMask;return{type:n.CellType.Library,depths:i,hashes:a,mask:o}}function u(e,t){(0,i.exoticMerkleProof)(e,t);let r=[],a=[],o=new s.LevelMask(t[0].level()>>1);return{type:n.CellType.MerkleProof,depths:r,hashes:a,mask:o}}function d(e,t){(0,a.exoticMerkleUpdate)(e,t);let r=[],i=[],o=new s.LevelMask((t[0].level()|t[1].level())>>1);return{type:n.CellType.MerkleUpdate,depths:r,hashes:i,mask:o}}function f(e,n){let r=new t.BitReader(e).preloadUint(8);if(r===1)return c(e,n);if(r===2)return l(e,n);if(r===3)return u(e,n);if(r===4)return d(e,n);throw Error(`Invalid exotic cell type: `+r)}e.resolveExotic=f})),el=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.getRepr=e.getBitsDescriptor=e.getRefsDescriptor=void 0;var t=Ic(),n=Nc();function r(e,n,r){return e.length+(r===t.CellType.Ordinary?0:1)*8+n*32}e.getRefsDescriptor=r;function i(e){let t=e.length;return Math.ceil(t/8)+Math.floor(t/8)}e.getBitsDescriptor=i;function a(e,a,o,s,c,l){let u=Math.ceil(a.length/8),d=A.alloc(2+u+34*o.length),f=0;d[f++]=r(o,c,l),d[f++]=i(e),(0,n.bitsToPaddedBuffer)(a).copy(d,f),f+=u;for(let e of o){let n;n=l==t.CellType.MerkleProof||l==t.CellType.MerkleUpdate?e.depth(s+1):e.depth(s),d[f++]=Math.floor(n/256),d[f++]=n%256}for(let e of o){let n;n=l==t.CellType.MerkleProof||l==t.CellType.MerkleUpdate?e.hash(s+1):e.hash(s),n.copy(d,f),f+=32}return d}e.getRepr=a})),tl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.wonderCalculator=void 0;var t=Pc(),n=Ic(),r=Zc(),i=Qc(),a=zc(),o=el(),s=ye(),c=Xc(),l=Yc();function u(e,u,d){let f,p=null;if(e===n.CellType.Ordinary){let e=0;for(let t of d)e|=t.mask.value;f=new r.LevelMask(e)}else if(e===n.CellType.PrunedBranch)p=(0,i.exoticPruned)(u,d),f=new r.LevelMask(p.mask);else if(e===n.CellType.MerkleProof)(0,a.exoticMerkleProof)(u,d),f=new r.LevelMask(d[0].mask.value>>1);else if(e===n.CellType.MerkleUpdate)(0,c.exoticMerkleUpdate)(u,d),f=new r.LevelMask((d[0].mask.value|d[1].mask.value)>>1);else if(e===n.CellType.Library)(0,l.exoticLibrary)(u,d),f=new r.LevelMask;else throw Error(`Unsupported exotic type`);let m=[],h=[],g=e===n.CellType.PrunedBranch?1:f.hashCount,_=f.hashCount-g;for(let r=0,i=0;r<=f.level;r++){if(!f.isSignificant(r))continue;if(i<_){i++;continue}let a;if(i===_){if(r!==0&&e!==n.CellType.PrunedBranch)throw Error(`Invalid`);a=u}else{if(r===0||e===n.CellType.PrunedBranch)throw Error(`Invalid: `+r+`, `+e);a=new t.BitString(h[i-_-1],0,256)}let c=0;for(let t of d){let i;i=e==n.CellType.MerkleProof||e==n.CellType.MerkleUpdate?t.depth(r+1):t.depth(r),c=Math.max(c,i)}d.length>0&&c++;let l=(0,o.getRepr)(u,a,d,r,f.apply(r).value,e),p=(0,s.sha256_sync)(l),g=i-_;m[g]=c,h[g]=p,i++}let v=[],y=[];if(p)for(let e=0;e<4;e++){let{hashIndex:t}=f.apply(e),{hashIndex:n}=f;t===n?(v.push(h[0]),y.push(m[0])):(v.push(p.pruned[t].hash),y.push(p.pruned[t].depth))}else for(let e=0;e<4;e++)v.push(h[f.apply(e).hashIndex]),y.push(m[f.apply(e).hashIndex]);return{mask:f,hashes:v,depths:y}}e.wonderCalculator=u})),nl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.topologicalSort=void 0;function t(e){let t=[e],n=new Map,r=new Set,i=[];for(;t.length>0;){let e=[...t];t=[];for(let i of e){let e=i.hash().toString(`hex`);if(!n.has(e)){r.add(e),n.set(e,{cell:i,refs:i.refs.map(e=>e.hash().toString(`hex`))});for(let e of i.refs)t.push(e)}}}let a=new Set;function o(e){if(!r.has(e))return;if(a.has(e))throw Error(`Not a DAG`);a.add(e);let t=n.get(e).refs;for(let e=t.length-1;e>=0;e--)o(t[e]);i.push(e),a.delete(e),r.delete(e)}for(;r.size>0;){let e=Array.from(r)[0];o(e)}let s=new Map;for(let e=0;e<i.length;e++)s.set(i[i.length-e-1],e);let c=[];for(let e=i.length-1;e>=0;e--){let t=i[e],r=n.get(t);c.push({cell:r.cell,refs:r.refs.map(e=>s.get(e))})}return c}e.topologicalSort=t})),rl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bitsForNumber=void 0;function t(e,t){let n=BigInt(e);if(t===`int`)return n===0n||n===-1n?1:(n>0?n:-n).toString(2).length+1;if(t===`uint`){if(n<0)throw Error(`value is negative. Got ${e}`);return n.toString(2).length}throw Error(`invalid mode. Got ${t}`)}e.bitsForNumber=t})),il=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.crc32c=void 0;var t=2197175160;function n(e){let n=-1;for(let r=0;r<e.length;r++)n^=e[r],n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1,n=n&1?n>>>1^t:n>>>1;n^=4294967295;let r=A.alloc(4);return r.writeInt32LE(n),r}e.crc32c=n})),al=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.serializeBoc=e.deserializeBoc=e.parseBoc=void 0;var t=Rc(),n=Pc(),r=ol(),i=nl(),a=rl(),o=Fc(),s=el(),c=Nc(),l=il();function u(e){return d(e&7)}function d(e){let t=0;for(let n=0;n<3;n++)t+=e&1,e>>=1;return t+1}function f(e,t){let r=e.loadUint(8),i=r%8,a=!!(r&8),o=e.loadUint(8),s=Math.ceil(o/2),c=!!(o%2),l=r>>5,d=!!(r&16),f=d?u(l)*32:0,p=d?u(l)*2:0;e.skip(f*8),e.skip(p*8);let m=n.BitString.EMPTY;s>0&&(m=c?e.loadPaddedBits(s*8):e.loadBits(s*8));let h=[];for(let n=0;n<i;n++)h.push(e.loadUint(t*8));return{bits:m,refs:h,exotic:a}}function p(e,t){return 2+Math.ceil(e.bits.length/8)+e.refs.length*t}function m(e){let r=new t.BitReader(new n.BitString(e,0,e.length*8)),i=r.loadUint(32);if(i===1761568243){let e=r.loadUint(8),t=r.loadUint(8),n=r.loadUint(e*8),i=r.loadUint(e*8),a=r.loadUint(e*8),o=r.loadUint(t*8);return{size:e,offBytes:t,cells:n,roots:i,absent:a,totalCellSize:o,index:r.loadBuffer(n*t),cellData:r.loadBuffer(o),root:[0]}}if(i===2898503464){let t=r.loadUint(8),n=r.loadUint(8),i=r.loadUint(t*8),a=r.loadUint(t*8),o=r.loadUint(t*8),s=r.loadUint(n*8),c=r.loadBuffer(i*n),u=r.loadBuffer(s),d=r.loadBuffer(4);if(!(0,l.crc32c)(e.subarray(0,e.length-4)).equals(d))throw Error(`Invalid CRC32C`);return{size:t,offBytes:n,cells:i,roots:a,absent:o,totalCellSize:s,index:c,cellData:u,root:[0]}}if(i===3052313714){let t=r.loadUint(1),n=r.loadUint(1);r.loadUint(1),r.loadUint(2);let i=r.loadUint(3),a=r.loadUint(8),o=r.loadUint(i*8),s=r.loadUint(i*8),c=r.loadUint(i*8),u=r.loadUint(a*8),d=[];for(let e=0;e<s;e++)d.push(r.loadUint(i*8));let f=null;t&&(f=r.loadBuffer(o*a));let p=r.loadBuffer(u);if(n){let t=r.loadBuffer(4);if(!(0,l.crc32c)(e.subarray(0,e.length-4)).equals(t))throw Error(`Invalid CRC32C`)}return{size:i,offBytes:a,cells:o,roots:s,absent:c,totalCellSize:u,index:f,cellData:p,root:d}}throw Error(`Invalid magic`)}e.parseBoc=m;function h(e){let i=m(e),a=new t.BitReader(new n.BitString(i.cellData,0,i.cellData.length*8)),o=[];for(let e=0;e<i.cells;e++){let e=f(a,i.size);o.push({...e,result:null})}for(let e=o.length-1;e>=0;e--){if(o[e].result)throw Error(`Impossible`);let t=[];for(let n of o[e].refs){if(!o[n].result)throw Error(`Invalid BOC file`);t.push(o[n].result)}o[e].result=new r.Cell({bits:o[e].bits,refs:t,exotic:o[e].exotic})}let s=[];for(let e=0;e<i.root.length;e++)s.push(o[i.root[e]].result);return s}e.deserializeBoc=h;function g(e,t,n,r){let i=(0,s.getRefsDescriptor)(e.refs,e.mask.value,e.type),a=(0,s.getBitsDescriptor)(e.bits);r.writeUint(i,8),r.writeUint(a,8),r.writeBuffer((0,c.bitsToPaddedBuffer)(e.bits));for(let e of t)r.writeUint(e,n*8)}function _(e,t){let n=(0,i.topologicalSort)(e),r=n.length,s=t.idx,c=t.crc32,u=Math.max(Math.ceil((0,a.bitsForNumber)(r,`uint`)/8),1),d=0,f=[];for(let e of n){let t=p(e.cell,u);d+=t,f.push(d)}let m=Math.max(Math.ceil((0,a.bitsForNumber)(d,`uint`)/8),1),h=(6+3*u+m+1*u+(s?r*m:0)+d+(c?4:0))*8,_=new o.BitBuilder(h);if(_.writeUint(3052313714,32),_.writeBit(s),_.writeBit(c),_.writeBit(!1),_.writeUint(0,2),_.writeUint(u,3),_.writeUint(m,8),_.writeUint(r,u*8),_.writeUint(1,u*8),_.writeUint(0,u*8),_.writeUint(d,m*8),_.writeUint(0,u*8),s)for(let e=0;e<r;e++)_.writeUint(f[e],m*8);for(let e=0;e<r;e++)g(n[e].cell,n[e].refs,u,_);if(c){let e=(0,l.crc32c)(_.buffer());_.writeBuffer(e)}let v=_.buffer();if(v.length!==h/8)throw Error(`Internal error`);return v}e.serializeBoc=_})),ol=t((e=>{k();var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Cell=void 0;var n=Dc(),r=Pc(),i=Ic(),a=Jc(),o=$c(),s=tl(),c=al(),l=Rc(),u=$(),d=class e{static fromBoc(e){return(0,c.deserializeBoc)(e)}static fromBase64(t){let n=e.fromBoc(A.from(t,`base64`));if(n.length!==1)throw Error(`Deserialized more than one cell`);return n[0]}static fromHex(t){let n=e.fromBoc(A.from(t,`hex`));if(n.length!==1)throw Error(`Deserialized more than one cell`);return n[0]}constructor(e){this._hashes=[],this._depths=[],this.beginParse=(e=!1)=>{if(this.isExotic&&!e)throw Error(`Exotic cells cannot be parsed`);return new a.Slice(new l.BitReader(this.bits),this.refs)},this.hash=(e=3)=>this._hashes[Math.min(this._hashes.length-1,e)],this.depth=(e=3)=>this._depths[Math.min(this._depths.length-1,e)],this.level=()=>this.mask.level,this.equals=e=>this.hash().equals(e.hash()),this[t]=()=>this.toString();let n=r.BitString.EMPTY;e&&e.bits&&(n=e.bits);let c=[];e&&e.refs&&(c=[...e.refs]);let u,d,f,p=i.CellType.Ordinary;if(e&&e.exotic){let e=(0,o.resolveExotic)(n,c),t=(0,s.wonderCalculator)(e.type,n,c);f=t.mask,d=t.depths,u=t.hashes,p=e.type}else{if(c.length>4)throw Error(`Invalid number of references`);if(n.length>1023)throw Error(`Bits overflow: ${n.length} > 1023`);let e=(0,s.wonderCalculator)(i.CellType.Ordinary,n,c);f=e.mask,d=e.depths,u=e.hashes,p=i.CellType.Ordinary}this.type=p,this.bits=n,this.refs=c,this.mask=f,this._depths=d,this._hashes=u,Object.freeze(this),Object.freeze(this.refs),Object.freeze(this.bits),Object.freeze(this.mask),Object.freeze(this._depths),Object.freeze(this._hashes)}get isExotic(){return this.type!==i.CellType.Ordinary}toBoc(e){let t=e&&e.idx!==null&&e.idx!==void 0?e.idx:!1,n=e&&e.crc32!==null&&e.crc32!==void 0?e.crc32:!0;return(0,c.serializeBoc)(this,{idx:t,crc32:n})}toString(e){let t=e||``,n=`x`;this.isExotic&&(this.type===i.CellType.MerkleProof?n=`p`:this.type===i.CellType.MerkleUpdate?n=`u`:this.type===i.CellType.PrunedBranch&&(n=`p`));let r=t+(this.isExotic?n:`x`)+`{`+this.bits.toString()+`}`;for(let e in this.refs){let n=this.refs[e];r+=`
|
|
66
|
-
`+n.toString(t+` `)}return r}asSlice(){return this.beginParse()}asBuilder(){return(0,u.beginCell)().storeSlice(this.asSlice())}};e.Cell=d,t=n.inspectSymbol,d.EMPTY=new d})),$=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Builder=e.beginCell=void 0;var t=Fc(),n=ol(),r=qc();function i(){return new a}e.beginCell=i;var a=class e{constructor(){this._bits=new t.BitBuilder,this._refs=[]}get bits(){return this._bits.length}get refs(){return this._refs.length}get availableBits(){return 1023-this.bits}get availableRefs(){return 4-this.refs}storeBit(e){return this._bits.writeBit(e),this}storeBits(e){return this._bits.writeBits(e),this}storeBuffer(e,t){if(t!=null&&e.length!==t)throw Error(`Buffer length ${e.length} is not equal to ${t}`);return this._bits.writeBuffer(e),this}storeMaybeBuffer(e,t){return e===null?this.storeBit(0):(this.storeBit(1),this.storeBuffer(e,t)),this}storeUint(e,t){return this._bits.writeUint(e,t),this}storeMaybeUint(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeUint(e,t)),this}storeInt(e,t){return this._bits.writeInt(e,t),this}storeMaybeInt(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeInt(e,t)),this}storeVarUint(e,t){return this._bits.writeVarUint(e,t),this}storeMaybeVarUint(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeVarUint(e,t)),this}storeVarInt(e,t){return this._bits.writeVarInt(e,t),this}storeMaybeVarInt(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeVarInt(e,t)),this}storeCoins(e){return this._bits.writeCoins(e),this}storeMaybeCoins(e){return e==null?this.storeBit(0):(this.storeBit(1),this.storeCoins(e)),this}storeAddress(e){return this._bits.writeAddress(e),this}storeRef(t){if(this._refs.length>=4)throw Error(`Too many references`);if(t instanceof n.Cell)this._refs.push(t);else if(t instanceof e)this._refs.push(t.endCell());else throw Error(`Invalid argument`);return this}storeMaybeRef(e){return e?(this.storeBit(1),this.storeRef(e)):this.storeBit(0),this}storeSlice(e){let t=e.clone();for(t.remainingBits>0&&this.storeBits(t.loadBits(t.remainingBits));t.remainingRefs>0;)this.storeRef(t.loadRef());return this}storeMaybeSlice(e){return e?(this.storeBit(1),this.storeSlice(e)):this.storeBit(0),this}storeBuilder(e){return this.storeSlice(e.endCell().beginParse())}storeMaybeBuilder(e){return e?(this.storeBit(1),this.storeBuilder(e)):this.storeBit(0),this}storeWritable(e){return typeof e==`object`?e.writeTo(this):e(this),this}storeMaybeWritable(e){return e?(this.storeBit(1),this.storeWritable(e)):this.storeBit(0),this}store(e){return this.storeWritable(e),this}storeStringTail(e){return(0,r.writeString)(e,this),this}storeMaybeStringTail(e){return e==null?this.storeBit(0):(this.storeBit(1),(0,r.writeString)(e,this)),this}storeStringRefTail(e){return this.storeRef(i().storeStringTail(e)),this}storeMaybeStringRefTail(e){return e==null?this.storeBit(0):(this.storeBit(1),this.storeStringRefTail(e)),this}storeDict(e,t,n){return e?e.store(this,t,n):this.storeBit(0),this}storeDictDirect(e,t,n){return e.storeDirect(this,t,n),this}endCell(e){return new n.Cell({bits:this._bits.build(),refs:this._refs,exotic:e?.exotic})}asCell(){return this.endCell()}asSlice(){return this.endCell().beginParse()}};e.Builder=a})),sl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SimpleLibraryValue=e.storeSimpleLibrary=e.loadSimpleLibrary=void 0;function t(e){return{public:e.loadBit(),root:e.loadRef()}}e.loadSimpleLibrary=t;function n(e){return t=>{t.storeBit(e.public),t.storeRef(e.root)}}e.storeSimpleLibrary=n,e.SimpleLibraryValue={serialize(e,t){n(e)(t)},parse(e){return t(e)}}})),cl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTickTock=e.loadTickTock=void 0;function t(e){return{tick:e.loadBit(),tock:e.loadBit()}}e.loadTickTock=t;function n(e){return t=>{t.storeBit(e.tick),t.storeBit(e.tock)}}e.storeTickTock=n})),ll=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStateInit=e.loadStateInit=void 0;var t=Kc(),n=sl(),r=cl();function i(e){let i;e.loadBit()&&(i=e.loadUint(5));let a;e.loadBit()&&(a=(0,r.loadTickTock)(e));let o=e.loadMaybeRef(),s=e.loadMaybeRef(),c=e.loadDict(t.Dictionary.Keys.BigUint(256),n.SimpleLibraryValue);return c.size===0&&(c=void 0),{splitDepth:i,special:a,code:o,data:s,libraries:c}}e.loadStateInit=i;function a(e){return t=>{e.splitDepth!==null&&e.splitDepth!==void 0?(t.storeBit(!0),t.storeUint(e.splitDepth,5)):t.storeBit(!1),e.special!==null&&e.special!==void 0?(t.storeBit(!0),t.store((0,r.storeTickTock)(e.special))):t.storeBit(!1),t.storeMaybeRef(e.code),t.storeMaybeRef(e.data),t.storeDict(e.libraries)}}e.storeStateInit=a})),ul=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contractAddress=void 0;var t=$(),n=ll(),r=kc();function i(e,i){let a=(0,t.beginCell)().store((0,n.storeStateInit)(i)).endCell().hash();return new r.Address(e,a)}e.contractAddress=i})),dl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseTuple=e.serializeTuple=e.parseTupleItem=e.serializeTupleItem=void 0;var t=$(),n=BigInt(`-9223372036854775808`),r=BigInt(`9223372036854775807`);function i(e,a){if(e.type===`null`)a.storeUint(0,8);else if(e.type===`int`)e.value<=r&&e.value>=n?(a.storeUint(1,8),a.storeInt(e.value,64)):(a.storeUint(256,15),a.storeInt(e.value,257));else if(e.type===`nan`)a.storeInt(767,16);else if(e.type===`cell`)a.storeUint(3,8),a.storeRef(e.cell);else if(e.type===`slice`)a.storeUint(4,8),a.storeUint(0,10),a.storeUint(e.cell.bits.length,10),a.storeUint(0,3),a.storeUint(e.cell.refs.length,3),a.storeRef(e.cell);else if(e.type===`builder`)a.storeUint(5,8),a.storeRef(e.cell);else if(e.type===`tuple`){let n=null,r=null;for(let a=0;a<e.items.length;a++){let o=n;n=r,r=o,a>1&&(n=(0,t.beginCell)().storeRef(r).storeRef(n).endCell());let s=(0,t.beginCell)();i(e.items[a],s),r=s.endCell()}a.storeUint(7,8),a.storeUint(e.items.length,16),n&&a.storeRef(n),r&&a.storeRef(r)}else throw Error(`Invalid value`)}e.serializeTupleItem=i;function a(e){let n=e.loadUint(8);if(n===0)return{type:`null`};if(n===1)return{type:`int`,value:e.loadIntBig(64)};if(n===2)return e.loadUint(7)===0?{type:`int`,value:e.loadIntBig(257)}:(e.loadBit(),{type:`nan`});if(n===3)return{type:`cell`,cell:e.loadRef()};if(n===4){let n=e.loadUint(10),r=e.loadUint(10),i=e.loadUint(3),a=e.loadUint(3),o=e.loadRef().beginParse();o.skip(n);let s=o.loadBits(r-n),c=(0,t.beginCell)().storeBits(s);if(i<a){for(let e=0;e<i;e++)o.loadRef();for(let e=0;e<a-i;e++)c.storeRef(o.loadRef())}return{type:`slice`,cell:c.endCell()}}if(n===5)return{type:`builder`,cell:e.loadRef()};if(n===7){let t=e.loadUint(16),n=[];if(t>1){let r=e.loadRef().beginParse(),i=e.loadRef().beginParse();n.unshift(a(i));for(let e=0;e<t-2;e++){let e=r;r=e.loadRef().beginParse(),i=e.loadRef().beginParse(),n.unshift(a(i))}n.unshift(a(r))}else t===1&&n.push(a(e.loadRef().beginParse()));return{type:`tuple`,items:n}}throw Error(`Unsupported stack item`)}e.parseTupleItem=a;function o(e,n){if(e.length>0){let r=(0,t.beginCell)();o(e.slice(0,e.length-1),r),n.storeRef(r.endCell()),i(e[e.length-1],n)}}function s(e){let n=(0,t.beginCell)();return n.storeUint(e.length,24),o([...e],n),n.endCell()}e.serializeTuple=s;function c(e){let t=[],n=e.beginParse(),r=n.loadUint(24);for(let e=0;e<r;e++){let e=n.loadRef();t.unshift(a(n)),n=e.beginParse()}return t}e.parseTuple=c})),fl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TupleReader=void 0,e.TupleReader=class e{constructor(e){this.items=[...e]}get remaining(){return this.items.length}peek(){if(this.items.length===0)throw Error(`EOF`);return this.items[0]}pop(){if(this.items.length===0)throw Error(`EOF`);let e=this.items[0];return this.items.splice(0,1),e}skip(e=1){for(let t=0;t<e;t++)this.pop();return this}readBigNumber(){let e=this.pop();if(e.type!==`int`)throw Error(`Not a number`);return e.value}readBigNumberOpt(){let e=this.pop();if(e.type===`null`)return null;if(e.type!==`int`)throw Error(`Not a number`);return e.value}readNumber(){return Number(this.readBigNumber())}readNumberOpt(){let e=this.readBigNumberOpt();return e===null?null:Number(e)}readBoolean(){return this.readNumber()!==0}readBooleanOpt(){let e=this.readNumberOpt();return e===null?null:e!==0}readAddress(){let e=this.readCell().beginParse().loadAddress();if(e!==null)return e;throw Error(`Not an address`)}readAddressOpt(){let e=this.readCellOpt();return e===null?null:e.beginParse().loadMaybeAddress()}readCell(){let e=this.pop();if(e.type!==`cell`&&e.type!==`slice`&&e.type!==`builder`)throw Error(`Not a cell: `+e.type);return e.cell}readCellOpt(){let e=this.pop();if(e.type===`null`)return null;if(e.type!==`cell`&&e.type!==`slice`&&e.type!==`builder`)throw Error(`Not a cell`);return e.cell}readTuple(){let t=this.pop();if(t.type!==`tuple`)throw Error(`Not a tuple`);return new e(t.items)}readTupleOpt(){let t=this.pop();if(t.type===`null`)return null;if(t.type!==`tuple`)throw Error(`Not a tuple`);return new e(t.items)}static readLispList(e){let t=[],n=e;for(;n!==null;){var r=n.pop();if(n.items.length===0||n.items[0].type!==`tuple`&&n.items[0].type!==`null`)throw Error(`Lisp list consists only from (any, tuple) elements and ends with null`);n=n.readTupleOpt(),t.push(r)}return t}readLispListDirect(){return this.items.length===1&&this.items[0].type===`null`?[]:e.readLispList(this)}readLispList(){return e.readLispList(this.readTupleOpt())}readBuffer(){let e=this.readCell().beginParse();if(e.remainingRefs!==0||e.remainingBits%8!=0)throw Error(`Not a buffer`);return e.loadBuffer(e.remainingBits/8)}readBufferOpt(){let e=this.readCellOpt();if(e!==null){let t=e.beginParse();if(t.remainingRefs!==0||t.remainingBits%8!=0)throw Error(`Not a buffer`);return t.loadBuffer(t.remainingBits/8)}return null}readString(){return this.readCell().beginParse().loadStringTail()}readStringOpt(){let e=this.readCellOpt();return e===null?null:e.beginParse().loadStringTail()}}})),pl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TupleBuilder=void 0;var t=$(),n=ol(),r=Jc();e.TupleBuilder=class{constructor(){this._tuple=[]}writeNumber(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`int`,value:BigInt(e)})}writeBoolean(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`int`,value:e?-1n:0n})}writeBuffer(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeBuffer(e).endCell()})}writeString(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeStringTail(e).endCell()})}writeCell(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`cell`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`cell`,cell:e.asCell()})}writeSlice(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`slice`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`slice`,cell:e.asCell()})}writeBuilder(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`builder`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`builder`,cell:e.asCell()})}writeTuple(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`tuple`,items:e})}writeAddress(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeAddress(e).endCell()})}build(){return[...this._tuple]}}})),ml=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fromNano=e.toNano=void 0;function t(e){if(typeof e==`bigint`)return e*1000000000n;{if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Invalid number`);if(Math.log10(e)<=6)e=e.toLocaleString(`en`,{minimumFractionDigits:9,useGrouping:!1});else if(e-Math.trunc(e)===0)e=e.toLocaleString(`en`,{maximumFractionDigits:0,useGrouping:!1});else throw Error(`Not enough precision for a number value. Use string value instead`)}let t=!1;for(;e.startsWith(`-`);)t=!t,e=e.slice(1);if(e===`.`)throw Error(`Invalid number`);let n=e.split(`.`);if(n.length>2)throw Error(`Invalid number`);let r=n[0],i=n[1];if(r||=`0`,i||=`0`,i.length>9)throw Error(`Invalid number`);for(;i.length<9;)i+=`0`;let a=BigInt(r)*1000000000n+BigInt(i);return t&&(a=-a),a}}e.toNano=t;function n(e){let t=BigInt(e),n=!1;t<0&&(n=!0,t=-t);let r=(t%1000000000n).toString();for(;r.length<9;)r=`0`+r;r=r.match(/^([0-9]*[1-9]|0)(0*)/)[1];let i=`${(t/1000000000n).toString()}${r===`0`?``:`.${r}`}`;return n&&(i=`-`+i),i}e.fromNano=n})),hl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.packExtraCurrencyCell=e.packExtraCurrencyDict=e.storeExtraCurrency=e.loadMaybeExtraCurrency=e.loadExtraCurrency=void 0;var t=$(),n=Kc();function r(e){let t=e instanceof n.Dictionary?e:n.Dictionary.loadDirect(n.Dictionary.Keys.Uint(32),n.Dictionary.Values.BigVarUint(5),e),r={};for(let[e,n]of t)r[e]=n;return r}e.loadExtraCurrency=r;function i(e){let t=e.loadMaybeRef();return t===null?t:r(t)}e.loadMaybeExtraCurrency=i;function a(e){return t=>{t.storeDict(o(e))}}e.storeExtraCurrency=a;function o(e){let t=n.Dictionary.empty(n.Dictionary.Keys.Uint(32),n.Dictionary.Values.BigVarUint(5));return Object.entries(e).map(([e,n])=>t.set(Number(e),n)),t}e.packExtraCurrencyDict=o;function s(e){return(0,t.beginCell)().storeDictDirect(o(e)).endCell()}e.packExtraCurrencyCell=s})),gl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.comment=e.external=e.internal=void 0;var t=kc(),n=ol(),r=$(),i=ml(),a=hl();function o(e){let o=!0;e.bounce!==null&&e.bounce!==void 0&&(o=e.bounce);let s;if(typeof e.to==`string`)s=t.Address.parse(e.to);else if(t.Address.isAddress(e.to))s=e.to;else throw Error(`Invalid address ${e.to}`);let c;c=typeof e.value==`string`?(0,i.toNano)(e.value):e.value;let l;e.extracurrency&&(l=(0,a.packExtraCurrencyDict)(e.extracurrency));let u=n.Cell.EMPTY;return typeof e.body==`string`?u=(0,r.beginCell)().storeUint(0,32).storeStringTail(e.body).endCell():e.body&&(u=e.body),{info:{type:`internal`,dest:s,value:{coins:c,other:l},bounce:o,ihrDisabled:!0,bounced:!1,ihrFee:0n,forwardFee:0n,createdAt:0,createdLt:0n},init:e.init??void 0,body:u}}e.internal=o;function s(e){let r;if(typeof e.to==`string`)r=t.Address.parse(e.to);else if(t.Address.isAddress(e.to))r=e.to;else throw Error(`Invalid address ${e.to}`);return{info:{type:`external-in`,dest:r,importFee:0n},init:e.init??void 0,body:e.body||n.Cell.EMPTY}}e.external=s;function c(e){return(0,r.beginCell)().storeUint(0,32).storeStringTail(e).endCell()}e.comment=c})),_l=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountState=e.loadAccountState=void 0;var t=ll();function n(e){return e.loadBit()?{type:`active`,state:(0,t.loadStateInit)(e)}:e.loadBit()?{type:`frozen`,stateHash:e.loadUintBig(256)}:{type:`uninit`}}e.loadAccountState=n;function r(e){return n=>{e.type===`active`?(n.storeBit(!0),n.store((0,t.storeStateInit)(e.state))):e.type===`frozen`?(n.storeBit(!1),n.storeBit(!0),n.storeUint(e.stateHash,256)):e.type===`uninit`&&(n.storeBit(!1),n.storeBit(!1))}}e.storeAccountState=r})),vl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCurrencyCollection=e.loadCurrencyCollection=void 0;var t=Kc();function n(e){let n=e.loadCoins(),r=e.loadDict(t.Dictionary.Keys.Uint(32),t.Dictionary.Values.BigVarUint(5));return r.size===0?{coins:n}:{other:r,coins:n}}e.loadCurrencyCollection=n;function r(e){return t=>{t.storeCoins(e.coins),e.other?t.storeDict(e.other):t.storeBit(0)}}e.storeCurrencyCollection=r})),yl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStorage=e.loadAccountStorage=void 0;var t=_l(),n=vl();function r(e){return{lastTransLt:e.loadUintBig(64),balance:(0,n.loadCurrencyCollection)(e),state:(0,t.loadAccountState)(e)}}e.loadAccountStorage=r;function i(e){return r=>{r.storeUint(e.lastTransLt,64),r.store((0,n.storeCurrencyCollection)(e.balance)),r.store((0,t.storeAccountState)(e.state))}}e.storeAccountStorage=i})),bl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageExtraInfo=e.loadStorageExtraInfo=void 0;function t(e){let t=e.loadUint(3);if(t===0)return null;if(t===1)return{dictHash:e.loadUintBig(256)};throw Error(`Invalid storage extra info header: ${t}`)}e.loadStorageExtraInfo=t;function n(e){return t=>{e==null?t.storeUint(0,3):(t.storeUint(1,3),t.storeUint(e.dictHash,256))}}e.storeStorageExtraInfo=n})),xl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageUsed=e.loadStorageUsed=void 0;function t(e){return{cells:e.loadVarUintBig(3),bits:e.loadVarUintBig(3)}}e.loadStorageUsed=t;function n(e){return t=>{t.storeVarUint(e.cells,3),t.storeVarUint(e.bits,3)}}e.storeStorageUsed=n})),Sl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageInfo=e.loadStorageInfo=void 0;var t=bl(),n=xl();function r(e){return{used:(0,n.loadStorageUsed)(e),storageExtra:(0,t.loadStorageExtraInfo)(e),lastPaid:e.loadUint(32),duePayment:e.loadMaybeCoins()}}e.loadStorageInfo=r;function i(e){return r=>{r.store((0,n.storeStorageUsed)(e.used)),r.store((0,t.storeStorageExtraInfo)(e.storageExtra)),r.storeUint(e.lastPaid,32),r.storeMaybeCoins(e.duePayment)}}e.storeStorageInfo=i})),Cl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccount=e.loadAccount=void 0;var t=yl(),n=Sl();function r(e){return{addr:e.loadAddress(),storageStats:(0,n.loadStorageInfo)(e),storage:(0,t.loadAccountStorage)(e)}}e.loadAccount=r;function i(e){return r=>{r.storeAddress(e.addr),r.store((0,n.storeStorageInfo)(e.storageStats)),r.store((0,t.storeAccountStorage)(e.storage))}}e.storeAccount=i})),wl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStatus=e.loadAccountStatus=void 0;function t(e){let t=e.loadUint(2);if(t===0)return`uninitialized`;if(t===1)return`frozen`;if(t===2)return`active`;if(t===3)return`non-existing`;throw Error(`Invalid data`)}e.loadAccountStatus=t;function n(e){return t=>{if(e===`uninitialized`)t.storeUint(0,2);else if(e===`frozen`)t.storeUint(1,2);else if(e===`active`)t.storeUint(2,2);else if(e===`non-existing`)t.storeUint(3,2);else throw Error(`Invalid data`);return t}}e.storeAccountStatus=n})),Tl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStatusChange=e.loadAccountStatusChange=void 0;function t(e){return e.loadBit()?e.loadBit()?`deleted`:`frozen`:`unchanged`}e.loadAccountStatusChange=t;function n(e){return t=>{if(e==`unchanged`)t.storeBit(0);else if(e===`frozen`)t.storeBit(1),t.storeBit(0);else if(e===`deleted`)t.storeBit(1),t.storeBit(1);else throw Error(`Invalid account status change`)}}e.storeAccountStatusChange=n})),El=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCommonMessageInfoRelaxed=e.loadCommonMessageInfoRelaxed=void 0;var t=vl();function n(e){if(!e.loadBit())return{type:`internal`,ihrDisabled:e.loadBit(),bounce:e.loadBit(),bounced:e.loadBit(),src:e.loadMaybeAddress(),dest:e.loadAddress(),value:(0,t.loadCurrencyCollection)(e),ihrFee:e.loadCoins(),forwardFee:e.loadCoins(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)};if(!e.loadBit())throw Error(`External In message is not possible for CommonMessageInfoRelaxed`);return{type:`external-out`,src:e.loadMaybeAddress(),dest:e.loadMaybeExternalAddress(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}}e.loadCommonMessageInfoRelaxed=n;function r(e){return n=>{if(e.type===`internal`)n.storeBit(0),n.storeBit(e.ihrDisabled),n.storeBit(e.bounce),n.storeBit(e.bounced),n.storeAddress(e.src),n.storeAddress(e.dest),n.store((0,t.storeCurrencyCollection)(e.value)),n.storeCoins(e.ihrFee),n.storeCoins(e.forwardFee),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else if(e.type===`external-out`)n.storeBit(1),n.storeBit(1),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else throw Error(`Unknown CommonMessageInfo type`)}}e.storeCommonMessageInfoRelaxed=r})),Dl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeMessageRelaxed=e.loadMessageRelaxed=void 0;var t=$(),n=El(),r=ll();function i(e){let t=(0,n.loadCommonMessageInfoRelaxed)(e),i=null;e.loadBit()&&(i=e.loadBit()?(0,r.loadStateInit)(e.loadRef().beginParse()):(0,r.loadStateInit)(e));let a=e.loadBit()?e.loadRef():e.asCell();return{info:t,init:i,body:a}}e.loadMessageRelaxed=i;function a(e,i){return a=>{if(a.store((0,n.storeCommonMessageInfoRelaxed)(e.info)),e.init){a.storeBit(!0);let n=(0,t.beginCell)().store((0,r.storeStateInit)(e.init)),o=!1;o=i&&i.forceRef?!0:!(a.availableBits-2>=n.bits),o?(a.storeBit(!0),a.storeRef(n)):(a.storeBit(!1),a.storeBuilder(n))}else a.storeBit(!1);let o=!1;o=i&&i.forceRef?!0:!(a.availableBits-1>=e.body.bits.length&&a.refs+e.body.refs.length<=4&&!e.body.isExotic),o?(a.storeBit(!0),a.storeRef(e.body)):(a.storeBit(!1),a.storeBuilder(e.body.asBuilder()))}}e.storeMessageRelaxed=a})),Ol=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeLibRef=e.loadLibRef=void 0;function t(e){return e.loadUint(1)===0?{type:`hash`,libHash:e.loadBuffer(32)}:{type:`ref`,library:e.loadRef()}}e.loadLibRef=t;function n(e){return t=>{e.type===`hash`?(t.storeUint(0,1),t.storeBuffer(e.libHash)):(t.storeUint(1,1),t.storeRef(e.library))}}e.storeLibRef=n})),kl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadOutList=e.storeOutList=e.loadOutAction=e.storeOutAction=void 0;var t=Dl(),n=$(),r=vl(),i=Ol();function a(e){switch(e.type){case`sendMsg`:return s(e);case`setCode`:return l(e);case`reserve`:return d(e);case`changeLibrary`:return p(e);default:throw Error(`Unknown action type ${e.type}`)}}e.storeOutAction=a;var o=247711853;function s(e){return r=>{r.storeUint(o,32).storeUint(e.mode,8).storeRef((0,n.beginCell)().store((0,t.storeMessageRelaxed)(e.outMsg)).endCell())}}var c=2907562126;function l(e){return t=>{t.storeUint(c,32).storeRef(e.newCode)}}var u=921090057;function d(e){return t=>{t.storeUint(u,32).storeUint(e.mode,8).store((0,r.storeCurrencyCollection)(e.currency))}}var f=653925844;function p(e){return t=>{t.storeUint(f,32).storeUint(e.mode,7).store((0,i.storeLibRef)(e.libRef))}}function m(e){let n=e.loadUint(32);if(n===o)return{type:`sendMsg`,mode:e.loadUint(8),outMsg:(0,t.loadMessageRelaxed)(e.loadRef().beginParse())};if(n===c)return{type:`setCode`,newCode:e.loadRef()};if(n===u)return{type:`reserve`,mode:e.loadUint(8),currency:(0,r.loadCurrencyCollection)(e)};if(n===f)return{type:`changeLibrary`,mode:e.loadUint(7),libRef:(0,i.loadLibRef)(e)};throw Error(`Unknown out action tag 0x${n.toString(16)}`)}e.loadOutAction=m;function h(e){let t=e.reduce((e,t)=>(0,n.beginCell)().storeRef(e).store(a(t)).endCell(),(0,n.beginCell)().endCell());return e=>{e.storeSlice(t.beginParse())}}e.storeOutList=h;function g(e){let t=[];for(;e.remainingRefs;){let n=e.loadRef();t.push(m(e)),e=n.beginParse()}return t.reverse()}e.loadOutList=g})),Al=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCommonMessageInfo=e.loadCommonMessageInfo=void 0;var t=vl();function n(e){return e.loadBit()?e.loadBit()?{type:`external-out`,src:e.loadAddress(),dest:e.loadMaybeExternalAddress(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}:{type:`external-in`,src:e.loadMaybeExternalAddress(),dest:e.loadAddress(),importFee:e.loadCoins()}:{type:`internal`,ihrDisabled:e.loadBit(),bounce:e.loadBit(),bounced:e.loadBit(),src:e.loadAddress(),dest:e.loadAddress(),value:(0,t.loadCurrencyCollection)(e),ihrFee:e.loadCoins(),forwardFee:e.loadCoins(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}}e.loadCommonMessageInfo=n;function r(e){return n=>{if(e.type===`internal`)n.storeBit(0),n.storeBit(e.ihrDisabled),n.storeBit(e.bounce),n.storeBit(e.bounced),n.storeAddress(e.src),n.storeAddress(e.dest),n.store((0,t.storeCurrencyCollection)(e.value)),n.storeCoins(e.ihrFee),n.storeCoins(e.forwardFee),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else if(e.type===`external-in`)n.storeBit(1),n.storeBit(0),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeCoins(e.importFee);else if(e.type===`external-out`)n.storeBit(1),n.storeBit(1),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else throw Error(`Unknown CommonMessageInfo type`)}}e.storeCommonMessageInfo=r})),jl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeComputeSkipReason=e.loadComputeSkipReason=void 0;function t(e){let t=e.loadUint(2);if(t===0)return`no-state`;if(t===1)return`bad-state`;if(t===2)return`no-gas`;throw Error(`Unknown ComputeSkipReason: ${t}`)}e.loadComputeSkipReason=t;function n(e){return t=>{if(e===`no-state`)t.storeUint(0,2);else if(e===`bad-state`)t.storeUint(1,2);else if(e===`no-gas`)t.storeUint(2,2);else throw Error(`Unknown ComputeSkipReason: ${e}`)}}e.storeComputeSkipReason=n})),Ml=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeDepthBalanceInfo=e.loadDepthBalanceInfo=void 0;var t=vl();function n(e){return{splitDepth:e.loadUint(5),balance:(0,t.loadCurrencyCollection)(e)}}e.loadDepthBalanceInfo=n;function r(e){return n=>{n.storeUint(e.splitDepth,5),n.store((0,t.storeCurrencyCollection)(e.balance))}}e.storeDepthBalanceInfo=r})),Nl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeHashUpdate=e.loadHashUpdate=void 0;function t(e){if(e.loadUint(8)!==114)throw Error(`Invalid data`);return{oldHash:e.loadBuffer(32),newHash:e.loadBuffer(32)}}e.loadHashUpdate=t;function n(e){return t=>{t.storeUint(114,8),t.storeBuffer(e.oldHash),t.storeBuffer(e.newHash)}}e.storeHashUpdate=n})),Pl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadMasterchainStateExtra=void 0;var t=Kc(),n=vl();function r(e){if(e.loadUint(16)!==52262)throw Error(`Invalid data`);e.loadBit()&&e.loadRef();let r=e.loadUintBig(256);return{config:t.Dictionary.load(t.Dictionary.Keys.Int(32),t.Dictionary.Values.Cell(),e),configAddress:r,globalBalance:(0,n.loadCurrencyCollection)(e)}}e.loadMasterchainStateExtra=r})),Fl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageValue=e.storeMessage=e.loadMessage=void 0;var t=$(),n=Al(),r=ll();function i(e){let t=(0,n.loadCommonMessageInfo)(e),i=null;e.loadBit()&&(i=e.loadBit()?(0,r.loadStateInit)(e.loadRef().beginParse()):(0,r.loadStateInit)(e));let a=e.loadBit()?e.loadRef():e.asCell();return{info:t,init:i,body:a}}e.loadMessage=i;function a(e,i){return a=>{if(a.store((0,n.storeCommonMessageInfo)(e.info)),e.init){a.storeBit(!0);let n=(0,t.beginCell)().store((0,r.storeStateInit)(e.init)),o=!1;o=i&&i.forceRef?!0:a.availableBits-2<n.bits+e.body.bits.length,o?(a.storeBit(!0),a.storeRef(n)):(a.storeBit(!1),a.storeBuilder(n))}else a.storeBit(!1);let o=!1;o=i&&i.forceRef?!0:a.availableBits-1<e.body.bits.length||a.refs+e.body.refs.length>4,o?(a.storeBit(!0),a.storeRef(e.body)):(a.storeBit(!1),a.storeBuilder(e.body.asBuilder()))}}e.storeMessage=a,e.MessageValue={serialize(e,n){n.storeRef((0,t.beginCell)().store(a(e)))},parse(e){return i(e.loadRef().beginParse())}}})),Il=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SendMode=void 0;var t;(function(e){e[e.CARRY_ALL_REMAINING_BALANCE=128]=`CARRY_ALL_REMAINING_BALANCE`,e[e.CARRY_ALL_REMAINING_INCOMING_VALUE=64]=`CARRY_ALL_REMAINING_INCOMING_VALUE`,e[e.DESTROY_ACCOUNT_IF_ZERO=32]=`DESTROY_ACCOUNT_IF_ZERO`,e[e.PAY_GAS_SEPARATELY=1]=`PAY_GAS_SEPARATELY`,e[e.IGNORE_ERRORS=2]=`IGNORE_ERRORS`,e[e.NONE=0]=`NONE`})(t||(e.SendMode=t={}))})),Ll=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ReserveMode=void 0;var t;(function(e){e[e.THIS_AMOUNT=0]=`THIS_AMOUNT`,e[e.LEAVE_THIS_AMOUNT=1]=`LEAVE_THIS_AMOUNT`,e[e.AT_MOST_THIS_AMOUNT=2]=`AT_MOST_THIS_AMOUNT`,e[e.LEAVE_MAX_THIS_AMOUNT=3]=`LEAVE_MAX_THIS_AMOUNT`,e[e.BEFORE_BALANCE_PLUS_THIS_AMOUNT=4]=`BEFORE_BALANCE_PLUS_THIS_AMOUNT`,e[e.LEAVE_BBALANCE_PLUS_THIS_AMOUNT=5]=`LEAVE_BBALANCE_PLUS_THIS_AMOUNT`,e[e.BEFORE_BALANCE_MINUS_THIS_AMOUNT=12]=`BEFORE_BALANCE_MINUS_THIS_AMOUNT`,e[e.LEAVE_BEFORE_BALANCE_MINUS_THIS_AMOUNT=13]=`LEAVE_BEFORE_BALANCE_MINUS_THIS_AMOUNT`})(t||(e.ReserveMode=t={}))})),Rl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardAccount=e.loadShardAccount=void 0;var t=$(),n=Cl();function r(e){let t=e.loadRef(),r;if(!t.isExotic){let e=t.beginParse();e.loadBit()&&(r=(0,n.loadAccount)(e))}return{account:r,lastTransactionHash:e.loadUintBig(256),lastTransactionLt:e.loadUintBig(64)}}e.loadShardAccount=r;function i(e){return r=>{e.account?r.storeRef((0,t.beginCell)().storeBit(!0).store((0,n.storeAccount)(e.account))):r.storeRef((0,t.beginCell)().storeBit(!1)),r.storeUint(e.lastTransactionHash,256),r.storeUint(e.lastTransactionLt,64)}}e.storeShardAccount=i})),zl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardAccounts=e.loadShardAccounts=e.ShardAccountRefValue=void 0;var t=Kc(),n=Ml(),r=Rl();e.ShardAccountRefValue={parse:e=>({depthBalanceInfo:(0,n.loadDepthBalanceInfo)(e),shardAccount:(0,r.loadShardAccount)(e)}),serialize(e,t){t.store((0,n.storeDepthBalanceInfo)(e.depthBalanceInfo)),t.store((0,r.storeShardAccount)(e.shardAccount))}};function i(n){return t.Dictionary.load(t.Dictionary.Keys.BigUint(256),e.ShardAccountRefValue,n)}e.loadShardAccounts=i;function a(e){return t=>{t.storeDict(e)}}e.storeShardAccounts=a})),Bl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardIdent=e.loadShardIdent=void 0;function t(e){if(e.loadUint(2)!==0)throw Error(`Invalid data`);return{shardPrefixBits:e.loadUint(6),workchainId:e.loadInt(32),shardPrefix:e.loadUintBig(64)}}e.loadShardIdent=t;function n(e){return t=>{t.storeUint(0,2),t.storeUint(e.shardPrefixBits,6),t.storeInt(e.workchainId,32),t.storeUint(e.shardPrefix,64)}}e.storeShardIdent=n})),Vl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadShardStateUnsplit=void 0;var t=Pl(),n=zl(),r=Bl();function i(e){if(e.loadUint(32)!==2418257890)throw Error(`Invalid data`);let i=e.loadInt(32),a=(0,r.loadShardIdent)(e),o=e.loadUint(32),s=e.loadUint(32),c=e.loadUint(32),l=e.loadUintBig(64),u=e.loadUint(32);e.loadRef();let d=e.loadBit(),f=e.loadRef(),p;f.isExotic||(p=(0,n.loadShardAccounts)(f.beginParse())),e.loadRef();let m=e.loadBit(),h=null;if(m){let n=e.loadRef();n.isExotic||(h=(0,t.loadMasterchainStateExtra)(n.beginParse()))}return{globalId:i,shardId:a,seqno:o,vertSeqNo:s,genUtime:c,genLt:l,minRefMcSeqno:u,beforeSplit:d,accounts:p,extras:h}}e.loadShardStateUnsplit=i})),Hl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeSplitMergeInfo=e.loadSplitMergeInfo=void 0;function t(e){return{currentShardPrefixLength:e.loadUint(6),accountSplitDepth:e.loadUint(6),thisAddress:e.loadUintBig(256),siblingAddress:e.loadUintBig(256)}}e.loadSplitMergeInfo=t;function n(e){return t=>{t.storeUint(e.currentShardPrefixLength,6),t.storeUint(e.accountSplitDepth,6),t.storeUint(e.thisAddress,256),t.storeUint(e.siblingAddress,256)}}e.storeSplitMergeInfo=n})),Ul=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionActionPhase=e.loadTransactionActionPhase=void 0;var t=Tl(),n=xl();function r(e){return{success:e.loadBit(),valid:e.loadBit(),noFunds:e.loadBit(),statusChange:(0,t.loadAccountStatusChange)(e),totalFwdFees:e.loadBit()?e.loadCoins():void 0,totalActionFees:e.loadBit()?e.loadCoins():void 0,resultCode:e.loadInt(32),resultArg:e.loadBit()?e.loadInt(32):void 0,totalActions:e.loadUint(16),specActions:e.loadUint(16),skippedActions:e.loadUint(16),messagesCreated:e.loadUint(16),actionListHash:e.loadUintBig(256),totalMessageSize:(0,n.loadStorageUsed)(e)}}e.loadTransactionActionPhase=r;function i(e){return r=>{r.storeBit(e.success),r.storeBit(e.valid),r.storeBit(e.noFunds),r.store((0,t.storeAccountStatusChange)(e.statusChange)),r.storeMaybeCoins(e.totalFwdFees),r.storeMaybeCoins(e.totalActionFees),r.storeInt(e.resultCode,32),r.storeMaybeInt(e.resultArg,32),r.storeUint(e.totalActions,16),r.storeUint(e.specActions,16),r.storeUint(e.skippedActions,16),r.storeUint(e.messagesCreated,16),r.storeUint(e.actionListHash,256),r.store((0,n.storeStorageUsed)(e.totalMessageSize))}}e.storeTransactionActionPhase=i})),Wl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionBouncePhase=e.loadTransactionBouncePhase=void 0;var t=xl();function n(e){return e.loadBit()?{type:`ok`,messageSize:(0,t.loadStorageUsed)(e),messageFees:e.loadCoins(),forwardFees:e.loadCoins()}:e.loadBit()?{type:`no-funds`,messageSize:(0,t.loadStorageUsed)(e),requiredForwardFees:e.loadCoins()}:{type:`negative-funds`}}e.loadTransactionBouncePhase=n;function r(e){return n=>{if(e.type===`ok`)n.storeBit(!0),n.store((0,t.storeStorageUsed)(e.messageSize)),n.storeCoins(e.messageFees),n.storeCoins(e.forwardFees);else if(e.type===`negative-funds`)n.storeBit(!1),n.storeBit(!1);else if(e.type===`no-funds`)n.storeBit(!1),n.storeBit(!0),n.store((0,t.storeStorageUsed)(e.messageSize)),n.storeCoins(e.requiredForwardFees);else throw Error(`Invalid TransactionBouncePhase type`)}}e.storeTransactionBouncePhase=r})),Gl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionComputePhase=e.loadTransactionComputePhase=void 0;var t=$(),n=jl();function r(e){if(!e.loadBit())return{type:`skipped`,reason:(0,n.loadComputeSkipReason)(e)};let t=e.loadBit(),r=e.loadBit(),i=e.loadBit(),a=e.loadCoins(),o=e.loadRef().beginParse();return{type:`vm`,success:t,messageStateUsed:r,accountActivated:i,gasFees:a,gasUsed:o.loadVarUintBig(3),gasLimit:o.loadVarUintBig(3),gasCredit:o.loadBit()?o.loadVarUintBig(2):void 0,mode:o.loadUint(8),exitCode:o.loadInt(32),exitArg:o.loadBit()?o.loadInt(32):void 0,vmSteps:o.loadUint(32),vmInitStateHash:o.loadUintBig(256),vmFinalStateHash:o.loadUintBig(256)}}e.loadTransactionComputePhase=r;function i(e){return r=>{if(e.type===`skipped`){r.storeBit(0),r.store((0,n.storeComputeSkipReason)(e.reason));return}r.storeBit(1),r.storeBit(e.success),r.storeBit(e.messageStateUsed),r.storeBit(e.accountActivated),r.storeCoins(e.gasFees),r.storeRef((0,t.beginCell)().storeVarUint(e.gasUsed,3).storeVarUint(e.gasLimit,3).store(t=>e.gasCredit!==void 0&&e.gasCredit!==null?t.storeBit(1).storeVarUint(e.gasCredit,2):t.storeBit(0)).storeUint(e.mode,8).storeInt(e.exitCode,32).store(t=>e.exitArg!==void 0&&e.exitArg!==null?t.storeBit(1).storeInt(e.exitArg,32):t.storeBit(0)).storeUint(e.vmSteps,32).storeUint(e.vmInitStateHash,256).storeUint(e.vmFinalStateHash,256).endCell())}}e.storeTransactionComputePhase=i})),Kl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionCreditPhase=e.loadTransactionCreditPhase=void 0;var t=vl();function n(e){return{dueFeesColelcted:e.loadBit()?e.loadCoins():void 0,credit:(0,t.loadCurrencyCollection)(e)}}e.loadTransactionCreditPhase=n;function r(e){return n=>{e.dueFeesColelcted===null||e.dueFeesColelcted===void 0?n.storeBit(!1):(n.storeBit(!0),n.storeCoins(e.dueFeesColelcted)),n.store((0,t.storeCurrencyCollection)(e.credit))}}e.storeTransactionCreditPhase=r})),ql=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionsStoragePhase=e.loadTransactionStoragePhase=void 0;var t=Tl();function n(e){let n=e.loadCoins(),r;e.loadBit()&&(r=e.loadCoins());let i=(0,t.loadAccountStatusChange)(e);return{storageFeesCollected:n,storageFeesDue:r,statusChange:i}}e.loadTransactionStoragePhase=n;function r(e){return n=>{n.storeCoins(e.storageFeesCollected),e.storageFeesDue===null||e.storageFeesDue===void 0?n.storeBit(!1):(n.storeBit(!0),n.storeCoins(e.storageFeesDue)),n.store((0,t.storeAccountStatusChange)(e.statusChange))}}e.storeTransactionsStoragePhase=r})),Jl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionDescription=e.loadTransactionDescription=void 0;var t=$(),n=Hl(),r=Yl(),i=Ul(),a=Wl(),o=Gl(),s=Kl(),c=ql();function l(e){let t=e.loadUint(4);if(t===0){let t=e.loadBit(),n;e.loadBit()&&(n=(0,c.loadTransactionStoragePhase)(e));let r;e.loadBit()&&(r=(0,s.loadTransactionCreditPhase)(e));let l=(0,o.loadTransactionComputePhase)(e),u;e.loadBit()&&(u=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let d=e.loadBit(),f;e.loadBit()&&(f=(0,a.loadTransactionBouncePhase)(e));let p=e.loadBit();return{type:`generic`,creditFirst:t,storagePhase:n,creditPhase:r,computePhase:l,actionPhase:u,bouncePhase:f,aborted:d,destroyed:p}}if(t===1)return{type:`storage`,storagePhase:(0,c.loadTransactionStoragePhase)(e)};if(t===2||t===3){let n=t===3,r=(0,c.loadTransactionStoragePhase)(e),a=(0,o.loadTransactionComputePhase)(e),s;e.loadBit()&&(s=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let l=e.loadBit(),u=e.loadBit();return{type:`tick-tock`,isTock:n,storagePhase:r,computePhase:a,actionPhase:s,aborted:l,destroyed:u}}if(t===4){let t=(0,n.loadSplitMergeInfo)(e),r;e.loadBit()&&(r=(0,c.loadTransactionStoragePhase)(e));let a=(0,o.loadTransactionComputePhase)(e),s;e.loadBit()&&(s=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let l=e.loadBit(),u=e.loadBit();return{type:`split-prepare`,splitInfo:t,storagePhase:r,computePhase:a,actionPhase:s,aborted:l,destroyed:u}}if(t===5)return{type:`split-install`,splitInfo:(0,n.loadSplitMergeInfo)(e),prepareTransaction:(0,r.loadTransaction)(e.loadRef().beginParse()),installed:e.loadBit()};throw Error(`Unsupported transaction description type ${t}`)}e.loadTransactionDescription=l;function u(e){return l=>{if(e.type===`generic`)l.storeUint(0,4),l.storeBit(e.creditFirst),e.storagePhase?(l.storeBit(!0),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase))):l.storeBit(!1),e.creditPhase?(l.storeBit(!0),l.store((0,s.storeTransactionCreditPhase)(e.creditPhase))):l.storeBit(!1),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.storeRef((0,t.beginCell)().store((0,i.storeTransactionActionPhase)(e.actionPhase)))):l.storeBit(!1),l.storeBit(e.aborted),e.bouncePhase?(l.storeBit(!0),l.store((0,a.storeTransactionBouncePhase)(e.bouncePhase))):l.storeBit(!1),l.storeBit(e.destroyed);else if(e.type===`storage`)l.storeUint(1,4),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase));else if(e.type===`tick-tock`)l.storeUint(e.isTock?3:2,4),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase)),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.storeRef((0,t.beginCell)().store((0,i.storeTransactionActionPhase)(e.actionPhase)))):l.storeBit(!1),l.storeBit(e.aborted),l.storeBit(e.destroyed);else if(e.type===`split-prepare`)l.storeUint(4,4),l.store((0,n.storeSplitMergeInfo)(e.splitInfo)),e.storagePhase?(l.storeBit(!0),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase))):l.storeBit(!1),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.store((0,i.storeTransactionActionPhase)(e.actionPhase))):l.storeBit(!1),l.storeBit(e.aborted),l.storeBit(e.destroyed);else if(e.type===`split-install`)l.storeUint(5,4),l.store((0,n.storeSplitMergeInfo)(e.splitInfo)),l.storeRef((0,t.beginCell)().store((0,r.storeTransaction)(e.prepareTransaction))),l.storeBit(e.installed);else throw Error(`Unsupported transaction description type ${e.type}`)}}e.storeTransactionDescription=u})),Yl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransaction=e.loadTransaction=void 0;var t=$(),n=Kc(),r=wl(),i=vl(),a=Nl(),o=Fl(),s=Jl();function c(e){let t=e.asCell();if(e.loadUint(4)!==7)throw Error(`Invalid data`);let c=e.loadUintBig(256),l=e.loadUintBig(64),u=e.loadUintBig(256),d=e.loadUintBig(64),f=e.loadUint(32),p=e.loadUint(15),m=(0,r.loadAccountStatus)(e),h=(0,r.loadAccountStatus)(e),g=e.loadRef().beginParse(),_=g.loadBit()?(0,o.loadMessage)(g.loadRef().beginParse()):void 0,v=g.loadDict(n.Dictionary.Keys.Uint(15),o.MessageValue);return g.endParse(),{address:c,lt:l,prevTransactionHash:u,prevTransactionLt:d,now:f,outMessagesCount:p,oldStatus:m,endStatus:h,inMessage:_,outMessages:v,totalFees:(0,i.loadCurrencyCollection)(e),stateUpdate:(0,a.loadHashUpdate)(e.loadRef().beginParse()),description:(0,s.loadTransactionDescription)(e.loadRef().beginParse()),raw:t,hash:()=>t.hash()}}e.loadTransaction=c;function l(e){return n=>{n.storeUint(7,4),n.storeUint(e.address,256),n.storeUint(e.lt,64),n.storeUint(e.prevTransactionHash,256),n.storeUint(e.prevTransactionLt,64),n.storeUint(e.now,32),n.storeUint(e.outMessagesCount,15),n.store((0,r.storeAccountStatus)(e.oldStatus)),n.store((0,r.storeAccountStatus)(e.endStatus));let c=(0,t.beginCell)();e.inMessage?(c.storeBit(!0),c.storeRef((0,t.beginCell)().store((0,o.storeMessage)(e.inMessage)))):c.storeBit(!1),c.storeDict(e.outMessages),n.storeRef(c),n.store((0,i.storeCurrencyCollection)(e.totalFees)),n.storeRef((0,t.beginCell)().store((0,a.storeHashUpdate)(e.stateUpdate))),n.storeRef((0,t.beginCell)().store((0,s.storeTransactionDescription)(e.description)))}}e.storeTransaction=l})),Xl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadSimpleLibrary=e.loadShardStateUnsplit=e.storeShardIdent=e.loadShardIdent=e.storeShardAccounts=e.loadShardAccounts=e.ShardAccountRefValue=e.storeShardAccount=e.loadShardAccount=e.ReserveMode=e.SendMode=e.storeMessageRelaxed=e.loadMessageRelaxed=e.storeMessage=e.loadMessage=e.loadMasterchainStateExtra=e.storeHashUpdate=e.loadHashUpdate=e.storeExtraCurrency=e.loadMaybeExtraCurrency=e.loadExtraCurrency=e.packExtraCurrencyDict=e.packExtraCurrencyCell=e.storeDepthBalanceInfo=e.loadDepthBalanceInfo=e.storeCurrencyCollection=e.loadCurrencyCollection=e.storeComputeSkipReason=e.loadComputeSkipReason=e.storeCommonMessageInfoRelaxed=e.loadCommonMessageInfoRelaxed=e.storeCommonMessageInfo=e.loadCommonMessageInfo=e.storeOutList=e.loadOutList=e.storeOutAction=e.loadOutAction=e.storeAccountStorage=e.loadAccountStorage=e.storeAccountStatusChange=e.loadAccountStatusChange=e.storeAccountStatus=e.loadAccountStatus=e.storeAccountState=e.loadAccountState=e.storeAccount=e.loadAccount=e.comment=e.external=e.internal=void 0,e.storeTransactionsStoragePhase=e.loadTransactionStoragePhase=e.storeTransactionDescription=e.loadTransactionDescription=e.storeTransactionCreditPhase=e.loadTransactionCreditPhase=e.storeTransactionComputePhase=e.loadTransactionComputePhase=e.storeTransactionBouncePhase=e.loadTransactionBouncePhase=e.storeTransactionActionPhase=e.loadTransactionActionPhase=e.storeTransaction=e.loadTransaction=e.storeTickTock=e.loadTickTock=e.storeStorageUsed=e.loadStorageUsed=e.storeStorageInfo=e.loadStorageInfo=e.storeStateInit=e.loadStateInit=e.storeSplitMergeInfo=e.loadSplitMergeInfo=e.storeLibRef=e.loadLibRef=e.storeSimpleLibrary=void 0;var t=gl();Object.defineProperty(e,"internal",{enumerable:!0,get:function(){return t.internal}}),Object.defineProperty(e,"external",{enumerable:!0,get:function(){return t.external}}),Object.defineProperty(e,"comment",{enumerable:!0,get:function(){return t.comment}});var n=Cl();Object.defineProperty(e,"loadAccount",{enumerable:!0,get:function(){return n.loadAccount}}),Object.defineProperty(e,"storeAccount",{enumerable:!0,get:function(){return n.storeAccount}});var r=_l();Object.defineProperty(e,"loadAccountState",{enumerable:!0,get:function(){return r.loadAccountState}}),Object.defineProperty(e,"storeAccountState",{enumerable:!0,get:function(){return r.storeAccountState}});var i=wl();Object.defineProperty(e,"loadAccountStatus",{enumerable:!0,get:function(){return i.loadAccountStatus}}),Object.defineProperty(e,"storeAccountStatus",{enumerable:!0,get:function(){return i.storeAccountStatus}});var a=Tl();Object.defineProperty(e,"loadAccountStatusChange",{enumerable:!0,get:function(){return a.loadAccountStatusChange}}),Object.defineProperty(e,"storeAccountStatusChange",{enumerable:!0,get:function(){return a.storeAccountStatusChange}});var o=yl();Object.defineProperty(e,"loadAccountStorage",{enumerable:!0,get:function(){return o.loadAccountStorage}}),Object.defineProperty(e,"storeAccountStorage",{enumerable:!0,get:function(){return o.storeAccountStorage}});var s=kl();Object.defineProperty(e,"loadOutAction",{enumerable:!0,get:function(){return s.loadOutAction}}),Object.defineProperty(e,"storeOutAction",{enumerable:!0,get:function(){return s.storeOutAction}}),Object.defineProperty(e,"loadOutList",{enumerable:!0,get:function(){return s.loadOutList}}),Object.defineProperty(e,"storeOutList",{enumerable:!0,get:function(){return s.storeOutList}});var c=Al();Object.defineProperty(e,"loadCommonMessageInfo",{enumerable:!0,get:function(){return c.loadCommonMessageInfo}}),Object.defineProperty(e,"storeCommonMessageInfo",{enumerable:!0,get:function(){return c.storeCommonMessageInfo}});var l=El();Object.defineProperty(e,"loadCommonMessageInfoRelaxed",{enumerable:!0,get:function(){return l.loadCommonMessageInfoRelaxed}}),Object.defineProperty(e,"storeCommonMessageInfoRelaxed",{enumerable:!0,get:function(){return l.storeCommonMessageInfoRelaxed}});var u=jl();Object.defineProperty(e,"loadComputeSkipReason",{enumerable:!0,get:function(){return u.loadComputeSkipReason}}),Object.defineProperty(e,"storeComputeSkipReason",{enumerable:!0,get:function(){return u.storeComputeSkipReason}});var d=vl();Object.defineProperty(e,"loadCurrencyCollection",{enumerable:!0,get:function(){return d.loadCurrencyCollection}}),Object.defineProperty(e,"storeCurrencyCollection",{enumerable:!0,get:function(){return d.storeCurrencyCollection}});var f=Ml();Object.defineProperty(e,"loadDepthBalanceInfo",{enumerable:!0,get:function(){return f.loadDepthBalanceInfo}}),Object.defineProperty(e,"storeDepthBalanceInfo",{enumerable:!0,get:function(){return f.storeDepthBalanceInfo}});var p=hl();Object.defineProperty(e,"packExtraCurrencyCell",{enumerable:!0,get:function(){return p.packExtraCurrencyCell}}),Object.defineProperty(e,"packExtraCurrencyDict",{enumerable:!0,get:function(){return p.packExtraCurrencyDict}}),Object.defineProperty(e,"loadExtraCurrency",{enumerable:!0,get:function(){return p.loadExtraCurrency}}),Object.defineProperty(e,"loadMaybeExtraCurrency",{enumerable:!0,get:function(){return p.loadMaybeExtraCurrency}}),Object.defineProperty(e,"storeExtraCurrency",{enumerable:!0,get:function(){return p.storeExtraCurrency}});var m=Nl();Object.defineProperty(e,"loadHashUpdate",{enumerable:!0,get:function(){return m.loadHashUpdate}}),Object.defineProperty(e,"storeHashUpdate",{enumerable:!0,get:function(){return m.storeHashUpdate}});var h=Pl();Object.defineProperty(e,"loadMasterchainStateExtra",{enumerable:!0,get:function(){return h.loadMasterchainStateExtra}});var g=Fl();Object.defineProperty(e,"loadMessage",{enumerable:!0,get:function(){return g.loadMessage}}),Object.defineProperty(e,"storeMessage",{enumerable:!0,get:function(){return g.storeMessage}});var _=Dl();Object.defineProperty(e,"loadMessageRelaxed",{enumerable:!0,get:function(){return _.loadMessageRelaxed}}),Object.defineProperty(e,"storeMessageRelaxed",{enumerable:!0,get:function(){return _.storeMessageRelaxed}});var v=Il();Object.defineProperty(e,"SendMode",{enumerable:!0,get:function(){return v.SendMode}});var y=Ll();Object.defineProperty(e,"ReserveMode",{enumerable:!0,get:function(){return y.ReserveMode}});var b=Rl();Object.defineProperty(e,"loadShardAccount",{enumerable:!0,get:function(){return b.loadShardAccount}}),Object.defineProperty(e,"storeShardAccount",{enumerable:!0,get:function(){return b.storeShardAccount}});var x=zl();Object.defineProperty(e,"ShardAccountRefValue",{enumerable:!0,get:function(){return x.ShardAccountRefValue}}),Object.defineProperty(e,"loadShardAccounts",{enumerable:!0,get:function(){return x.loadShardAccounts}}),Object.defineProperty(e,"storeShardAccounts",{enumerable:!0,get:function(){return x.storeShardAccounts}});var S=Bl();Object.defineProperty(e,"loadShardIdent",{enumerable:!0,get:function(){return S.loadShardIdent}}),Object.defineProperty(e,"storeShardIdent",{enumerable:!0,get:function(){return S.storeShardIdent}});var C=Vl();Object.defineProperty(e,"loadShardStateUnsplit",{enumerable:!0,get:function(){return C.loadShardStateUnsplit}});var ee=sl();Object.defineProperty(e,"loadSimpleLibrary",{enumerable:!0,get:function(){return ee.loadSimpleLibrary}}),Object.defineProperty(e,"storeSimpleLibrary",{enumerable:!0,get:function(){return ee.storeSimpleLibrary}});var w=Ol();Object.defineProperty(e,"loadLibRef",{enumerable:!0,get:function(){return w.loadLibRef}}),Object.defineProperty(e,"storeLibRef",{enumerable:!0,get:function(){return w.storeLibRef}});var T=Hl();Object.defineProperty(e,"loadSplitMergeInfo",{enumerable:!0,get:function(){return T.loadSplitMergeInfo}}),Object.defineProperty(e,"storeSplitMergeInfo",{enumerable:!0,get:function(){return T.storeSplitMergeInfo}});var E=ll();Object.defineProperty(e,"loadStateInit",{enumerable:!0,get:function(){return E.loadStateInit}}),Object.defineProperty(e,"storeStateInit",{enumerable:!0,get:function(){return E.storeStateInit}});var D=Sl();Object.defineProperty(e,"loadStorageInfo",{enumerable:!0,get:function(){return D.loadStorageInfo}}),Object.defineProperty(e,"storeStorageInfo",{enumerable:!0,get:function(){return D.storeStorageInfo}});var O=xl();Object.defineProperty(e,"loadStorageUsed",{enumerable:!0,get:function(){return O.loadStorageUsed}}),Object.defineProperty(e,"storeStorageUsed",{enumerable:!0,get:function(){return O.storeStorageUsed}});var te=cl();Object.defineProperty(e,"loadTickTock",{enumerable:!0,get:function(){return te.loadTickTock}}),Object.defineProperty(e,"storeTickTock",{enumerable:!0,get:function(){return te.storeTickTock}});var ne=Yl();Object.defineProperty(e,"loadTransaction",{enumerable:!0,get:function(){return ne.loadTransaction}}),Object.defineProperty(e,"storeTransaction",{enumerable:!0,get:function(){return ne.storeTransaction}});var re=Ul();Object.defineProperty(e,"loadTransactionActionPhase",{enumerable:!0,get:function(){return re.loadTransactionActionPhase}}),Object.defineProperty(e,"storeTransactionActionPhase",{enumerable:!0,get:function(){return re.storeTransactionActionPhase}});var ie=Wl();Object.defineProperty(e,"loadTransactionBouncePhase",{enumerable:!0,get:function(){return ie.loadTransactionBouncePhase}}),Object.defineProperty(e,"storeTransactionBouncePhase",{enumerable:!0,get:function(){return ie.storeTransactionBouncePhase}});var ae=Gl();Object.defineProperty(e,"loadTransactionComputePhase",{enumerable:!0,get:function(){return ae.loadTransactionComputePhase}}),Object.defineProperty(e,"storeTransactionComputePhase",{enumerable:!0,get:function(){return ae.storeTransactionComputePhase}});var oe=Kl();Object.defineProperty(e,"loadTransactionCreditPhase",{enumerable:!0,get:function(){return oe.loadTransactionCreditPhase}}),Object.defineProperty(e,"storeTransactionCreditPhase",{enumerable:!0,get:function(){return oe.storeTransactionCreditPhase}});var se=Jl();Object.defineProperty(e,"loadTransactionDescription",{enumerable:!0,get:function(){return se.loadTransactionDescription}}),Object.defineProperty(e,"storeTransactionDescription",{enumerable:!0,get:function(){return se.storeTransactionDescription}});var ce=ql();Object.defineProperty(e,"loadTransactionStoragePhase",{enumerable:!0,get:function(){return ce.loadTransactionStoragePhase}}),Object.defineProperty(e,"storeTransactionsStoragePhase",{enumerable:!0,get:function(){return ce.storeTransactionsStoragePhase}})})),Zl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.openContract=void 0;var t=kc(),n=ol();function r(e,r){let i,a=null;if(!t.Address.isAddress(e.address))throw Error(`Invalid address`);if(i=e.address,e.init){if(!(e.init.code instanceof n.Cell))throw Error(`Invalid init.code`);if(!(e.init.data instanceof n.Cell))throw Error(`Invalid init.data`);a=e.init}let o=r({address:i,init:a});return new Proxy(e,{get(e,t){let n=e[t];return typeof t==`string`&&(t.startsWith(`get`)||t.startsWith(`send`)||t.startsWith(`is`))&&typeof n==`function`?(...t)=>n.apply(e,[o,...t]):n}})}e.openContract=r})),Ql=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ComputeError=void 0,e.ComputeError=class e extends Error{constructor(t,n,r){super(t),this.exitCode=n,this.debugLogs=r&&r.debugLogs?r.debugLogs:null,this.logs=r&&r.logs?r.logs:null,Object.setPrototypeOf(this,e.prototype)}}})),$l=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.getMethodId=void 0;var t=new Int16Array([0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920]);function n(e){e instanceof A||(e=A.from(e));let n=0;for(let r=0;r<e.length;r++){let i=e[r];n=(t[(n>>8^i)&255]^n<<8)&65535}return n}function r(e){return n(e)&65535|65536}e.getMethodId=r})),eu=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.safeSignVerify=e.safeSign=void 0;var t=ye(),n=8,r=64;function i(e,i){let a=A.from(i);if(a.length>r)throw Error(`Seed can be longer than 64 bytes`);if(a.length<n)throw Error(`Seed must be at least 8 bytes`);return(0,t.sha256_sync)(A.concat([A.from([255,255]),a,e.hash()]))}function a(e,n,r=`ton-safe-sign-magic`){return(0,t.sign)(i(e,r),n)}e.safeSign=a;function o(e,n,r,a=`ton-safe-sign-magic`){return(0,t.signVerify)(i(e,a),n,r)}e.safeSignVerify=o})),tu=t((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.safeSignVerify=e.safeSign=e.getMethodId=e.base32Encode=e.base32Decode=e.crc32c=e.crc16=e.fromNano=e.toNano=e.ComputeError=e.openContract=e.TupleBuilder=e.TupleReader=e.serializeTupleItem=e.parseTupleItem=e.serializeTuple=e.parseTuple=e.generateMerkleUpdate=e.generateMerkleProofDirect=e.generateMerkleProof=e.exoticPruned=e.exoticMerkleUpdate=e.convertToMerkleProof=e.exoticMerkleProof=e.Dictionary=e.Cell=e.CellType=e.Slice=e.beginCell=e.Builder=e.BitBuilder=e.BitReader=e.BitString=e.contractAddress=e.ADNLAddress=e.ExternalAddress=e.address=e.Address=void 0;var r=kc();Object.defineProperty(e,"Address",{enumerable:!0,get:function(){return r.Address}}),Object.defineProperty(e,"address",{enumerable:!0,get:function(){return r.address}});var i=Ac();Object.defineProperty(e,"ExternalAddress",{enumerable:!0,get:function(){return i.ExternalAddress}});var a=Mc();Object.defineProperty(e,"ADNLAddress",{enumerable:!0,get:function(){return a.ADNLAddress}});var o=ul();Object.defineProperty(e,"contractAddress",{enumerable:!0,get:function(){return o.contractAddress}});var s=Pc();Object.defineProperty(e,"BitString",{enumerable:!0,get:function(){return s.BitString}});var c=Rc();Object.defineProperty(e,"BitReader",{enumerable:!0,get:function(){return c.BitReader}});var l=Fc();Object.defineProperty(e,"BitBuilder",{enumerable:!0,get:function(){return l.BitBuilder}});var u=$();Object.defineProperty(e,"Builder",{enumerable:!0,get:function(){return u.Builder}}),Object.defineProperty(e,"beginCell",{enumerable:!0,get:function(){return u.beginCell}});var d=Jc();Object.defineProperty(e,"Slice",{enumerable:!0,get:function(){return d.Slice}});var f=Ic();Object.defineProperty(e,"CellType",{enumerable:!0,get:function(){return f.CellType}});var p=ol();Object.defineProperty(e,"Cell",{enumerable:!0,get:function(){return p.Cell}});var m=Kc();Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return m.Dictionary}});var h=zc();Object.defineProperty(e,"exoticMerkleProof",{enumerable:!0,get:function(){return h.exoticMerkleProof}}),Object.defineProperty(e,"convertToMerkleProof",{enumerable:!0,get:function(){return h.convertToMerkleProof}});var g=Xc();Object.defineProperty(e,"exoticMerkleUpdate",{enumerable:!0,get:function(){return g.exoticMerkleUpdate}});var _=Qc();Object.defineProperty(e,"exoticPruned",{enumerable:!0,get:function(){return _.exoticPruned}});var v=Bc();Object.defineProperty(e,"generateMerkleProof",{enumerable:!0,get:function(){return v.generateMerkleProof}}),Object.defineProperty(e,"generateMerkleProofDirect",{enumerable:!0,get:function(){return v.generateMerkleProofDirect}});var y=Vc();Object.defineProperty(e,"generateMerkleUpdate",{enumerable:!0,get:function(){return y.generateMerkleUpdate}});var b=dl();Object.defineProperty(e,"parseTuple",{enumerable:!0,get:function(){return b.parseTuple}}),Object.defineProperty(e,"serializeTuple",{enumerable:!0,get:function(){return b.serializeTuple}}),Object.defineProperty(e,"parseTupleItem",{enumerable:!0,get:function(){return b.parseTupleItem}}),Object.defineProperty(e,"serializeTupleItem",{enumerable:!0,get:function(){return b.serializeTupleItem}});var x=fl();Object.defineProperty(e,"TupleReader",{enumerable:!0,get:function(){return x.TupleReader}});var S=pl();Object.defineProperty(e,"TupleBuilder",{enumerable:!0,get:function(){return S.TupleBuilder}}),n(Xl(),e);var C=Zl();Object.defineProperty(e,"openContract",{enumerable:!0,get:function(){return C.openContract}});var ee=Ql();Object.defineProperty(e,"ComputeError",{enumerable:!0,get:function(){return ee.ComputeError}});var w=ml();Object.defineProperty(e,"toNano",{enumerable:!0,get:function(){return w.toNano}}),Object.defineProperty(e,"fromNano",{enumerable:!0,get:function(){return w.fromNano}});var T=Oc();Object.defineProperty(e,"crc16",{enumerable:!0,get:function(){return T.crc16}});var E=il();Object.defineProperty(e,"crc32c",{enumerable:!0,get:function(){return E.crc32c}});var D=jc();Object.defineProperty(e,"base32Decode",{enumerable:!0,get:function(){return D.base32Decode}}),Object.defineProperty(e,"base32Encode",{enumerable:!0,get:function(){return D.base32Encode}});var O=$l();Object.defineProperty(e,"getMethodId",{enumerable:!0,get:function(){return O.getMethodId}});var te=eu();Object.defineProperty(e,"safeSign",{enumerable:!0,get:function(){return te.safeSign}}),Object.defineProperty(e,"safeSignVerify",{enumerable:!0,get:function(){return te.safeSignVerify}})}));k();var nu=tu(),ru=({amount:e,recipient:t,family:n,fees:r,comment:i,payload:a})=>({amount:e.toString(),recipient:t,family:n,fees:r.toString(),comment:i,payload:a?su(a):void 0}),iu=({amount:e,recipient:t,family:n,fees:r,comment:i,payload:a})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),comment:i,payload:a?ou(a):void 0}),au=e=>{try{return nu.Cell.fromBase64(e)}catch{return A.from(e,`hex`)}},ou=e=>{switch(e.type){case`unsafe`:return{type:e.type,message:nu.Cell.fromBase64(e.message)};case`jetton-transfer`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount),destination:nu.Address.parse(e.destination),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?nu.Cell.fromBase64(e.customPayload):null,forwardAmount:BigInt(e.forwardAmount),forwardPayload:e.forwardPayload?nu.Cell.fromBase64(e.forwardPayload):null,knownJetton:e.knownJetton};case`nft-transfer`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,newOwner:nu.Address.parse(e.newOwner),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?nu.Cell.fromBase64(e.customPayload):null,forwardAmount:BigInt(e.forwardAmount),forwardPayload:e.forwardPayload?nu.Cell.fromBase64(e.forwardPayload):null};case`jetton-burn`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?au(e.customPayload):null};case`add-whitelist`:case`single-nominator-change-validator`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,address:nu.Address.parse(e.address)};case`single-nominator-withdraw`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount)};case`tonstakers-deposit`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,appId:e.appId?BigInt(e.appId):null};case`vote-for-proposal`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,votingAddress:nu.Address.parse(e.votingAddress),expirationDate:e.expirationDate,vote:e.vote,needConfirmation:e.needConfirmation};case`change-dns-record`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,record:e.record.type===`wallet`?{type:e.record.type,value:e.record.value?{address:nu.Address.parse(e.record.value.address),capabilities:e.record.value.capabilities}:null}:{type:e.record.type,key:A.from(e.record.key,`hex`),value:e.record.value?nu.Cell.fromBase64(e.record.value):null}};case`token-bridge-pay-swap`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,swapId:A.from(e.swapId,`hex`)};case`tonwhales-pool-deposit`:return{type:e.type,queryId:BigInt(e.queryId),gasLimit:BigInt(e.gasLimit)};case`tonwhales-pool-withdraw`:return{type:e.type,queryId:BigInt(e.queryId),gasLimit:BigInt(e.gasLimit),amount:BigInt(e.amount)};case`vesting-send-msg-comment`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,sendMode:e.sendMode,value:BigInt(e.value),destination:nu.Address.parse(e.destination),text:e.text};case`comment`:return e;default:return e}},su=e=>{switch(e.type){case`unsafe`:return{type:e.type,message:e.message.toBoc().toString(`base64`)};case`jetton-transfer`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString(),destination:e.destination.toRawString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload?e.customPayload.toBoc().toString(`base64`):null,forwardAmount:e.forwardAmount.toString(),forwardPayload:e.forwardPayload?e.forwardPayload.toBoc().toString(`base64`):null,knownJetton:e.knownJetton};case`nft-transfer`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,newOwner:e.newOwner.toRawString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload?e.customPayload.toBoc().toString(`base64`):null,forwardAmount:e.forwardAmount.toString(),forwardPayload:e.forwardPayload?e.forwardPayload.toBoc().toString(`base64`):null};case`jetton-burn`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload&&`toBoc`in e.customPayload?e.customPayload.toBoc().toString(`base64`):e.customPayload?e.customPayload.toString(`hex`):null};case`add-whitelist`:case`single-nominator-change-validator`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,address:e.address.toRawString()};case`single-nominator-withdraw`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString()};case`tonstakers-deposit`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,appId:typeof e.appId==`bigint`?e.appId.toString():null};case`vote-for-proposal`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,votingAddress:e.votingAddress.toRawString(),expirationDate:e.expirationDate,vote:e.vote,needConfirmation:e.needConfirmation};case`change-dns-record`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,record:e.record.type===`wallet`?{type:e.record.type,value:e.record.value?{address:e.record.value.address.toRawString(),capabilities:e.record.value.capabilities}:null}:{type:e.record.type,key:e.record.key.toString(`hex`),value:e.record.value?e.record.value.toBoc().toString(`base64`):null}};case`token-bridge-pay-swap`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,swapId:e.swapId.toString(`hex`)};case`tonwhales-pool-deposit`:return{type:e.type,queryId:e.queryId.toString(),gasLimit:e.gasLimit.toString()};case`tonwhales-pool-withdraw`:return{type:e.type,queryId:e.queryId.toString(),gasLimit:e.gasLimit.toString(),amount:e.amount.toString()};case`vesting-send-msg-comment`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,sendMode:e.sendMode,value:e.value.toString(),destination:e.destination.toRawString(),text:e.text};case`comment`:return e;default:return e}},cu=({amount:e,recipient:t,family:n,mode:r,resource:i,duration:a,votes:o})=>({amount:e.toString(),recipient:t,family:n,mode:r,resource:i,duration:a,votes:o}),lu=({amount:e,recipient:t,family:n,mode:r,resource:i,duration:a,votes:o})=>({amount:new P(e),recipient:t,family:n,mode:r,resource:i,duration:a,votes:o});function uu({amount:e,data:t,family:n,fees:r,gasLimit:i,mode:a,recipient:o}){return{family:n,amount:e.toString(),recipient:o,mode:a,fees:r?r.toString():void 0,data:t,gasLimit:i}}function du({amount:e,data:t,family:n,fees:r,gasLimit:i,mode:a,recipient:o}){return{family:n,mode:a,amount:new P(e),recipient:o,fees:r?new P(r):void 0,data:t,gasLimit:i}}function fu({amount:e,family:t,fees:n,memo:r,mode:i,recipient:a}){return{amount:e.toString(),family:t,fees:n?n.toString():void 0,memo:r,mode:i,recipient:a}}function pu({amount:e,family:t,fees:n,memo:r,mode:i,recipient:a}){return{amount:new P(e),family:t,fees:n?new P(n):void 0,memo:r,mode:i,recipient:a}}function mu({amount:e,family:t,model:n,recipient:r,raw:i}){return{amount:e.toString(),family:t,model:JSON.stringify(n),recipient:r,raw:i}}function hu({family:e,amount:t,model:n,recipient:r,raw:i}){return{amount:new P(t),family:e,model:JSON.parse(n),recipient:r,raw:i}}var gu=({amount:e,recipient:t,family:n,estimatedFees:r,body:i})=>({amount:e.toString(),recipient:t,family:n,estimatedFees:r,body:i}),_u=({amount:e,recipient:t,family:n,estimatedFees:r,body:i})=>({amount:new P(e),recipient:t,family:n,estimatedFees:r,body:i}),vu=({amount:e,recipient:t,family:n,fee:r,nonce:i,memo:a,network:o,anchorMode:s})=>({amount:e.toString(),recipient:t,family:n,fee:r?.toString(),nonce:i?.toString(),memo:a,network:o,anchorMode:s}),yu=({amount:e,recipient:t,family:n,fee:r,nonce:i,memo:a,network:o,anchorMode:s})=>({amount:new P(e),recipient:t,family:n,fee:r?new P(r):void 0,nonce:i?new P(i):void 0,memo:a,network:o===`mainnet`?o:`testnet`,anchorMode:s}),bu=({amount:e,recipient:t,family:n,fees:r,memo:i})=>({amount:e.toFixed(),recipient:t,family:n,fees:r.toString(),memo:i}),xu=({amount:e,recipient:t,family:n,fees:r,memo:i})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),memo:i}),Su=({amount:e,recipient:t,family:n,fees:r,transferId:i})=>({amount:e.toFixed(),recipient:t,family:n,fees:r.toString(),transferId:i}),Cu=({amount:e,recipient:t,family:n,fees:r,transferId:i})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),transferId:i});function wu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:e.toString(),recipient:t,family:n,mode:r,fees:i?.toString()}}function Tu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:new P(e),recipient:t,family:n,mode:r,fees:i?new P(i):void 0}}function Eu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:e.toString(),recipient:t,family:n,mode:r,fees:i.toString()}}function Du({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:new P(e),recipient:t,family:n,mode:r,fees:new P(i)}}function Ou(e){switch(e.family){case`ethereum`:return sc(e);case`bitcoin`:return $s(e);case`algorand`:return Ys(e);case`aptos`:return Zs(e);case`crypto_org`:return ac(e);case`ripple`:return xc(e);case`celo`:return tc(e);case`cosmos`:return rc(e);case`hedera`:return dc(e);case`kaspa`:return pc(e);case`filecoin`:return hc(e);case`tezos`:return Tc(e);case`polkadot`:return yc(e);case`stellar`:return Cc(e);case`ton`:return ru(e);case`tron`:return cu(e);case`near`:return lc(e);case`neo`:return _c(e);case`elrond`:return uu(e);case`cardano`:return fu(e);case`solana`:return mu(e);case`vechain`:return gu(e);case`stacks`:return vu(e);case`internet_computer`:return bu(e);case`casper`:return Su(e);case`sui`:return wu(e);case`aleo`:return Eu(e);default:return e}}function ku(e){switch(e.family){case`ethereum`:return cc(e);case`bitcoin`:return ec(e);case`algorand`:return Xs(e);case`aptos`:return Qs(e);case`crypto_org`:return oc(e);case`ripple`:return Sc(e);case`celo`:return nc(e);case`cosmos`:return ic(e);case`hedera`:return fc(e);case`kaspa`:return mc(e);case`filecoin`:return gc(e);case`tezos`:return Ec(e);case`polkadot`:return bc(e);case`stellar`:return wc(e);case`ton`:return iu(e);case`tron`:return lu(e);case`near`:return uc(e);case`neo`:return vc(e);case`elrond`:return du(e);case`cardano`:return pu(e);case`solana`:return hu(e);case`vechain`:return _u(e);case`stacks`:return yu(e);case`internet_computer`:return xu(e);case`casper`:return Cu(e);case`sui`:return Tu(e);case`aleo`:return Du(e);default:return e}}var Au=Y([`send`,`optIn`,`claimReward`,`optOut`]),ju=Z.extend({family:X(Q.enum.algorand),mode:Au,fees:H().optional(),assetId:H().optional(),memo:H().optional()}),Mu=Y([`send`]),Nu=Z.extend({family:X(Q.enum.aptos),mode:Mu,fees:H().optional()}),Pu=Z.extend({family:X(Q.enum.bitcoin),feePerByte:H().optional(),opReturnDataHex:H().max(160).optional(),changeAddress:H().optional()}),Fu=Y([`send`,`lock`,`unlock`,`withdraw`,`vote`,`revoke`,`activate`,`register`]),Iu=Z.extend({family:X(Q.enum.celo),fees:H().optional().nullable(),mode:Fu,index:W().optional().nullable()}),Lu=Y([`send`,`delegate`,`undelegate`,`redelegate`,`claimReward`,`claimRewardCompound`]),Ru=q({address:H(),amount:H()}),zu=Z.extend({family:X(Q.enum.cosmos),mode:Lu,fees:H().optional(),gas:H().optional(),memo:H().optional(),sourceValidator:H().optional(),validators:K(Ru).optional()}),Bu=Z.extend({family:X(Q.enum.crypto_org),mode:H(),fees:H().optional()}),Vu=Z.extend({family:X(Q.enum.ethereum),nonce:W().optional(),data:H().optional(),gasPrice:H().optional(),gasLimit:H().optional(),maxPriorityFeePerGas:H().optional(),maxFeePerGas:H().optional(),sponsored:Zo().optional()}),Hu=Z.extend({family:X(Q.enum.near),mode:H(),fees:H().optional()}),Uu=Z.extend({family:X(Q.enum.neo)}),Wu=Y([`send`,`bond`,`unbond`,`rebond`,`withdrawUnbonded`,`setController`,`nominate`,`chill`,`claimReward`]),Gu=Y([`Staked`,`Stash`,`Controller`,`Account`,`None`]),Ku=Z.extend({family:X(Q.enum.polkadot),mode:Wu,fee:H().optional(),era:W().optional(),validators:K(H()).optional(),rewardDestination:Gu.optional(),numOfSlashingSpans:W().optional()}),qu=Z.extend({family:X(Q.enum.ripple),fee:H().optional(),tag:W()}),Ju=Z.extend({family:X(Q.enum.solana),model:H(),raw:Cs(H())}),Yu=Y([`MEMO_TEXT`,`MEMO_ID`,`MEMO_HASH`,`MEMO_RETURN`]),Xu=Z.extend({family:X(Q.enum.stellar),fees:H().optional(),memoType:Yu.optional(),memoValue:H().optional()}),Zu=Y([`send`,`delegate`,`undelegate`]),Qu=Z.extend({family:X(Q.enum.tezos),mode:Zu,fees:H().optional(),gasLimit:H().optional()}),$u=q({isEncrypted:Zo(),text:H()}),ed=q({type:X(`jetton-transfer`),queryId:J([H(),G()]),amount:H(),destination:H(),responseDestination:H(),customPayload:J([H(),G()]),forwardAmount:H(),forwardPayload:J([H(),G()]),knownJetton:J([q({jettonId:W(),workchain:W()}),G()])}),td=q({type:X(`nft-transfer`),queryId:J([H(),G()]),newOwner:H(),responseDestination:H(),customPayload:J([H(),G()]),forwardAmount:H(),forwardPayload:J([H(),G()])}),nd=J([q({type:X(`comment`),text:H()}),ed,td,q({type:X(`unsafe`),message:H()}),q({type:X(`jetton-burn`),queryId:J([H(),G()]),amount:H(),responseDestination:H(),customPayload:J([H(),G()])}),q({type:X(`add-whitelist`),queryId:J([H(),G()]),address:H()}),q({type:X(`single-nominator-withdraw`),queryId:J([H(),G()]),amount:H()}),q({type:X(`single-nominator-change-validator`),queryId:J([H(),G()]),address:H()}),q({type:X(`tonstakers-deposit`),queryId:J([H(),G()]),appId:J([H(),G()])}),q({type:X(`vote-for-proposal`),queryId:J([H(),G()]),votingAddress:H(),expirationDate:W(),vote:Zo(),needConfirmation:Zo()}),q({type:X(`change-dns-record`),queryId:J([H(),G()]),record:J([q({type:X(`wallet`),value:J([q({address:H(),capabilities:J([q({isWallet:Zo()}),G()])}),G()])}),q({type:X(`unknown`),key:H(),value:J([H(),G()])})])}),q({type:X(`token-bridge-pay-swap`),queryId:J([H(),G()]),swapId:H()}),q({type:X(`tonwhales-pool-deposit`),queryId:H(),gasLimit:H()}),q({type:X(`tonwhales-pool-withdraw`),queryId:H(),gasLimit:H(),amount:H()}),q({type:X(`vesting-send-msg-comment`),queryId:J([H(),G()]),sendMode:W(),value:H(),destination:H(),text:H()})]),rd=Z.extend({family:X(Q.enum.ton),fees:H(),comment:$u,payload:nd.optional()}),id=Y([`send`,`freeze`,`unfreeze`,`vote`,`claimReward`,`withdrawExpireUnfreeze`,`unDelegateResource`,`legacyUnfreeze`]),ad=Y([`BANDWIDTH`,`ENERGY`]),od=q({address:H(),voteCount:W()}),sd=Z.extend({family:X(Q.enum.tron),mode:id,resource:ad.optional(),duration:W().optional(),votes:K(od).default([])}),cd=Z.extend({family:X(Q.enum.hedera),memo:H().max(100).optional()}),ld=Z.extend({family:X(Q.enum.kaspa),customFeeRate:H().optional()}),ud=Z.extend({data:H().optional(),family:X(Q.enum.filecoin),gasLimit:W(),gasFeeCap:H(),gasPremium:H(),method:W(),nonce:W(),params:H().optional(),version:W()});Y([`send`,`delegate`,`reDelegateRewards`,`unDelegate`,`claimRewards`,`withdraw`]);var dd=Z.extend({family:X(Q.enum.elrond),mode:J([X(`send`),X(`delegate`),X(`reDelegateRewards`),X(`unDelegate`),X(`claimRewards`),X(`withdraw`)]),fees:H().optional(),data:H().optional(),gasLimit:W()}),fd=Z.extend({family:X(Q.enum.cardano),fees:H().optional(),mode:H(),memo:H().optional()}),pd=q({to:H().nullable(),value:J([H(),W()]),data:H(),comment:H().optional(),abi:H().optional()}),md=q({chainTag:W(),blockRef:H(),expiration:W(),clauses:K(pd),gasPriceCoef:W().optional(),gas:J([H(),W()]),dependsOn:H().nullable(),nonce:J([H(),W()]),maxFeePerGas:J([H(),W()]).optional(),maxPriorityFeePerGas:J([H(),W()]).optional(),reserved:q({features:W().optional(),unused:K(ns()).optional()}).optional()}),hd=Z.extend({family:X(Q.enum.vechain),estimatedFees:H(),body:md}),gd=Z.extend({family:X(Q.enum.stacks),fee:H().optional(),nonce:H().optional(),memo:H().optional(),network:H(),anchorMode:W()}),_d=Z.extend({family:X(Q.enum.internet_computer),fees:H(),memo:H().optional()}),vd=Z.extend({family:X(Q.enum.casper),fees:H(),transferId:H().optional()}),yd=Z.extend({family:X(Q.enum.sui),mode:H(),fees:H().optional()}),bd=Y([`transfer_public`]),xd=ps(`family`,[ju,Nu,Pu,Iu,zu,Bu,Vu,cd,ld,ud,Hu,Uu,Ku,qu,Xu,Qu,rd,sd,dd,fd,Ju,hd,gd,_d,vd,yd,Z.extend({family:X(Q.enum.aleo),mode:bd,fees:H()})]),Sd=class{prefix=``;constructor(e){this.prefix=e?`[${e}] `:``}log(e,...t){}warn(e,...t){}debug(e,...t){}error(e,...t){}},Cd=new Sd(`WindowMessage`),wd=class{target;logger;_onMessage;constructor(e=window,t=Cd){this.target=e,this.logger=t}connect=()=>{this.target.addEventListener(`message`,this._onMessageEvent,!1),this.target.document?.addEventListener(`message`,this._onMessageEvent,!1),this.logger.debug(`event listeners registered`)};disconnect=()=>{this.target.removeEventListener(`message`,this._onMessageEvent,!1),this.target.document?.removeEventListener(`message`,this._onMessageEvent,!1),this.logger.debug(`event listeners unregistered`)};_onMessageEvent=e=>{if(this._onMessage){if(this.logger.debug(`received message event`,e),e.data&&typeof e.data==`string`)try{let t=e.data;Date.now()>0?(this.logger.log(`received message`,t),this._onMessage(t)):this.logger.debug(`not a wallet API message`)}catch(e){this.logger.warn(`parse error`),e instanceof Error&&this._onMessage(e.message)}else this.logger.debug(`ignoring message same origin`)}else this.logger.debug(`no handler registered`)};set onMessage(e){this._onMessage=e}get onMessage(){return this._onMessage}send=e=>{try{this.target.ReactNativeWebView?(this.logger.log(`sending message (ReactNativeWebview)`,e),this.target.ReactNativeWebView.postMessage(e)):this.target.ElectronWebview?(this.logger.log(`sending message (ElectronWebview)`,e),this.target.ElectronWebview.postMessage(e)):(this.logger.log(`sending message`,e),this.target.top?.postMessage(e,`*`))}catch(e){throw this.logger.error(`unexpected error on send`,e),e}}},Td;(function(e){e.Slow=`slow`,e.Medium=`medium`,e.Fast=`fast`})(Td||={});var Ed;(function(e){e.Blue=`blue`,e.NanoS=`nanoS`,e.NanoX=`nanoX`})(Ed||={});var Dd;(function(e){e[e.SWAP=0]=`SWAP`,e[e.SELL=1]=`SELL`,e[e.FUND=2]=`FUND`})(Dd||={});var Od=Y([`NOT_IMPLEMENTED_BY_WALLET`,`ACCOUNT_NOT_FOUND`,`CURRENCY_NOT_FOUND`,`PERMISSION_DENIED`,`UNKNOWN_ERROR`,`UNAUTHORIZED_STORE`]),kd=q({code:X(Od.enum.NOT_IMPLEMENTED_BY_WALLET),message:H(),data:q({methodId:H()})}),Ad=q({code:X(Od.enum.ACCOUNT_NOT_FOUND),message:H(),data:q({accountId:H()})}),jd=q({code:X(Od.enum.CURRENCY_NOT_FOUND),message:H(),data:q({currencyId:H()})}),Md=q({code:X(Od.enum.PERMISSION_DENIED),message:H(),data:q({methodId:H()})}),Nd=q({name:H().optional(),message:H().optional(),stack:H().optional(),cause:is().optional(),code:H().optional()}),Pd=ps(`code`,[kd,Ad,jd,Md,q({code:X(Od.enum.UNKNOWN_ERROR),message:H(),data:Nd.passthrough()})]);function Fd(e){return{code:`UNKNOWN_ERROR`,message:`an unhandled error was thrown`,data:e}}var Id=class extends Error{errorData;constructor(e){super(e.message),this.errorData=e}getCode(){return this.errorData.code}getData(){return this.errorData}};function Ld(e){if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack},{code:n,cause:r}=e;return typeof n==`string`&&(t.code=n),r!==void 0&&(t.cause=r),t}return typeof e==`string`?{message:e}:typeof e==`object`&&e?e:{}}function Rd(e){if(!e||e.message===void 0&&e.name===void 0)return;let t=Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),e.code!==void 0&&(t.code=e.code),e.cause!==void 0&&(t.cause=e.cause),t}var zd=class extends Error{err;constructor(e){super(e.message),this.err=e}getCode(){return this.err.code}getData(){return this.err.data}},Bd;(function(e){e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.SERVER_ERROR=-32e3]=`SERVER_ERROR`})(Bd||={});var Vd=J([H(),W(),G()]),Hd=q({jsonrpc:X(`2.0`),method:H(),params:ns(),id:Vd.optional()}).strict(),Ud=q({code:W(),message:H(),data:ns().optional()}).strict(),Wd=q({jsonrpc:X(`2.0`),id:Vd,result:q({}).passthrough().optional()}).strict(),Gd=J([Hd,J([q({jsonrpc:X(`2.0`),id:Vd,error:Ud}).strict(),Wd])]);function Kd(e){try{let t=JSON.parse(e);return Gd.parse(t)}catch(e){throw e instanceof SyntaxError?new zd({code:Bd.PARSE_ERROR,message:`parse error`}):e instanceof lo?new zd({code:Bd.INVALID_REQUEST,message:`invalid request`}):e}}function qd(e){return{jsonrpc:`2.0`,...e}}var Jd=class{transport;requestHandlers;ongoingRequests={};constructor(e,t){this.transport=e,this.requestHandlers=t,this.transport.onMessage=e=>{this.handleMessage(e)}}_request(e){return new Promise((t,n)=>{if(!e.id){n(Error(`requests need to have an id`));return}let r=e=>{if(`error`in e){if(e.error.code===Bd.SERVER_ERROR){let t=Pd.parse(e.error.data);if(t.code===`UNKNOWN_ERROR`){n(Rd(t.data));return}n(new Id(t));return}n(new zd(e.error));return}t(e.result)};this.ongoingRequests[e.id]=r,this.transport.send(JSON.stringify(e))})}_notify(e){this.transport.send(JSON.stringify(e))}request(e,t){let n=crypto.randomUUID();return this._request({id:n,jsonrpc:`2.0`,method:e,params:t})}notify(e,t){return this._notify({jsonrpc:`2.0`,method:e,params:t})}async handleRpcRequest(e){try{let t=await this.onRequest(e);if(e.id){let n=qd({id:e.id,result:t});this.transport.send(JSON.stringify(n))}}catch(e){throw e instanceof lo?new zd({code:Bd.INVALID_PARAMS,message:e.message,data:e.flatten()}):e instanceof Id?new zd({code:Bd.SERVER_ERROR,message:`unexpected server error`,data:e.getData()}):e instanceof zd?e:new zd({code:Bd.SERVER_ERROR,message:`unexpected server error`,data:Fd(Ld(e))})}}async handleMessage(e){let t=!1,n;try{let r=Kd(e);n=r.id,`method`in r?await this.handleRpcRequest(r):(t=!0,this.handleRpcResponse(r))}catch(e){if(t)throw e;if(e instanceof zd){let t=qd({id:n??null,error:{code:e.getCode(),message:e.message,data:e.getData()}});this.transport.send(JSON.stringify(t));return}throw e}}handleRpcResponse(e){if(!e.id)return;let t=this.ongoingRequests[e.id];if(!t)throw Error(`no ongoingRequest ${e.id}`);t(e)}},Yd={params:q({accountId:H()}),result:q({maxSpendable:H().regex(/^(0|[1-9]\d*)$/)})},Xd={params:q({accountId:H(),derivationPath:H().optional()}),result:q({publicKey:H()})},Zd={params:q({currencyIds:K(H()).optional()}).optional(),result:q({rawAccounts:K(Ws)})},Qd={params:q({accountId:H(),tokenCurrency:H().optional()}),result:q({address:H()})},$d={params:q({currencyIds:K(H()).optional(),showAccountFilter:Zo().optional(),drawerConfiguration:q({assets:q({filter:H().optional(),leftElement:H().optional(),rightElement:H().optional()}).optional(),networks:q({leftElement:H().optional(),rightElement:H().optional()}).optional()}).optional(),useCase:H().optional(),uiUseCase:H().optional()}),result:q({rawAccount:Ws})},ef={params:q({accountId:H(),derivationPath:H().optional()}),result:q({address:H()})},tf={params:q({accountId:H(),intentions:K(Y([`payment`,`ordinal`])).optional()}),result:q({addresses:K(q({address:H(),publicKey:H().optional(),path:H().optional(),intention:H().optional()}))})},nf={params:q({accountId:H(),derivationPath:H().optional()}),result:q({publicKey:H()})},rf={params:q({accountId:H()}),result:q({xPub:H()})},af={params:q({accountId:H(),psbt:H(),broadcast:Zo().optional()}),result:q({psbtSigned:H(),txHash:H().optional()})},of={params:q({currencyIds:K(H()).optional()}).optional(),result:q({currencies:K(Js)})},sf=Y([`blue`,`nanoS`,`nanoSP`,`nanoX`,`stax`,`europa`,`apex`]),cf={params:q({transportId:H()}),result:q({transportId:H()})},lf={params:q({apduHex:H(),transportId:H()}),result:q({responseHex:H()})},uf={params:q({deviceId:H()}),result:q({transportId:H()})},df={params:q({appName:H().optional(),allowManager:Zo().optional(),appVersionRange:H().optional(),firmwareVersionRange:H().optional(),seeded:Zo().optional(),devices:sf.array().nonempty().optional()}),result:q({deviceId:H()})},ff={params:q({appName:H().optional(),allowManager:Zo().optional(),appVersionRange:H().optional(),firmwareVersionRange:H().optional(),seeded:Zo().optional(),devices:sf.array().nonempty().optional()}),result:q({transportId:H()})},pf=Y([`SLOW`,`MEDIUM`,`FAST`,`CUSTOM`]),mf=q({provider:H(),fromAccountId:H(),rawTransaction:xd,hexBinaryPayload:H(),hexSignature:H(),feeStrategy:pf,tokenCurrency:H().optional()}),hf={params:ps(`exchangeType`,[mf.extend({exchangeType:X(`FUND`)}),mf.extend({exchangeType:X(`SELL`)}),mf.extend({exchangeType:X(`SWAP`),toAccountId:H(),swapId:H(),rate:W()})]),result:q({transactionHash:H()})},gf={params:q({exchangeType:Y([`SWAP`,`SELL`,`FUND`,`SWAP_NG`,`SELL_NG`,`FUND_NG`])}),result:q({transactionId:H()})},_f=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),vf={params:q({accountId:H(),hexMessage:H(),options:_f.optional(),meta:_s(H(),is()).optional()}),result:q({hexSignedMessage:H()})},yf={params:q({key:H().min(1),storeId:H().min(1).optional()}),result:q({value:H().optional()})},bf={params:q({key:H(),value:H(),storeId:H().optional()}),result:cs().optional()},xf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),Sf={params:q({accountId:H(),rawTransaction:xd,options:xf.optional(),meta:_s(H(),is()).optional(),tokenCurrency:H().optional()}),result:q({signedTransactionHex:H()})},Cf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),wf={params:q({accountId:H(),rawTransaction:xd,options:Cf.optional(),meta:_s(H(),is()).optional(),tokenCurrency:H().optional()}),result:q({transactionHash:H()})},Tf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),Ef={params:q({accountId:H(),rawTransaction:H(),broadcast:Zo().optional(),options:Tf.optional(),meta:_s(H(),is()).optional()}),result:q({signedTransactionHex:H(),transactionHash:H().optional()})},Df={params:q({}),result:q({methodIds:K(H())})},Of={params:q({}),result:q({tracking:Zo(),wallet:q({name:H(),version:H()})})},kf={params:q({}),result:q({userId:H()})};Y([`account.getMaxSpendable`,`account.getPublicKey`,`account.list`,`account.receive`,`account.request`,`currency.list`,`device.close`,`device.exchange`,`device.transport`,`message.sign`,`transaction.sign`,`transaction.signRaw`,`transaction.signAndBroadcast`,`wallet.capabilities`,`wallet.info`,`wallet.userId`]);var Af;(function(e){e.Unknown=`Unknown`,e.LocationServicesDisabled=`LocationServicesDisabled`,e.LocationServicesUnauthorized=`LocationServicesUnauthorized`,e.BluetoothScanStartFailed=`BluetoothScanStartFailed`})(Af||={});var jf=class extends Error{id;constructor(e,t){let n=`TransportError`;super(e||n),this.name=n,this.message=e,this.stack=Error(e).stack,this.id=t}},Mf={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CLA_NOT_SUPPORTED_BOOTLOADER:28161,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,SW_BAD_STATE:45063};function Nf(e){switch(e){case 26368:return`Incorrect length`;case 26624:return`Missing critical parameter`;case 27010:return`Security not satisfied (dongle locked or have invalid access rights)`;case 27013:return`Condition of use not satisfied (denied by the user?)`;case 27264:return`Invalid data received`;case 27392:return`Invalid parameter received`;case 21781:return`Locked device`;case 45063:return`Unexpected state on the device`}if(28416<=e&&e<=28671)return`Internal error, please report`}var Pf=class e extends Error{statusCode;statusText;constructor(t,{canBeMappedToChildError:n=!0}={}){let r=Object.entries(Mf).find(([,e])=>e===t)?.[0]||`UNKNOWN_ERROR`,i=`Ledger device: ${Nf(t)||r} (0x${t.toString(16)})`;if(super(i||`TransportStatusError`),this.name=`TransportStatusError`,this.statusCode=t,this.statusText=r,Object.setPrototypeOf(this,e.prototype),n&&t===Mf.LOCKED_DEVICE)return new Ff(i)}},Ff=class e extends Pf{constructor(t){super(Mf.LOCKED_DEVICE,{canBeMappedToChildError:!1}),t&&(this.message=t),this.name=`LockedDeviceError`,Object.setPrototypeOf(this,e.prototype)}},If=class extends Error{name=`TransportRaceCondition`;constructor(e){super(e||`TransportRaceCondition`)}};k();var Lf=`transport`,Rf=class{exchangeTimeout=3e4;unresponsiveTimeout=15e3;deviceModel=null;tracer;constructor({context:e,logType:t}={}){this.tracer=new Oe(t??Lf,e)}static isSupported;static list;static listen;static open;exchange(e,{abortTimeoutMs:t}={}){throw Error(`exchange not implemented`)}exchangeBulk(e,t){let n=!1;return(async()=>{if(!n)for(let r of e){let e=await this.exchange(r);if(n)return;let i=e.readUInt16BE(e.length-2);if(i!==Mf.OK)throw new Pf(i);t.next(e)}})().then(()=>!n&&t.complete(),e=>!n&&t.error(e)),{unsubscribe:()=>{n=!0}}}setScrambleKey(e){}close(){return Promise.resolve()}_events=new we.default;on(e,t){this._events.on(e,t)}off(e,t){this._events.removeListener(e,t)}emit(e,...t){this._events.emit(e,...t)}setDebugMode(){}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}send=async(e,t,n,r,i=A.alloc(0),a=[Mf.OK],{abortTimeoutMs:o}={})=>{let s=this.tracer.withUpdatedContext({function:`send`});if(i.length>=256)throw s.trace(`data.length exceeded 256 bytes limit`,{dataLength:i.length}),new jf(`data.length exceed 256 bytes limit. Got: `+i.length,`DataLengthTooBig`);let c=await this.exchange(A.concat([A.from([e,t,n,r]),A.from([i.length]),i]),{abortTimeoutMs:o}),l=c.readUInt16BE(c.length-2);if(!a.some(e=>e===l))throw new Pf(l);return c};static create(e=3e3,t){return new Promise((n,r)=>{let i=!1,a=this.listen({next:t=>{i=!0,a&&a.unsubscribe(),o&&clearTimeout(o),this.open(t.descriptor,e).then(n,r)},error:e=>{o&&clearTimeout(o),r(e)},complete:()=>{o&&clearTimeout(o),i||r(new jf(this.ErrorMessage_NoDeviceFound,`NoDeviceFound`))}}),o=t?setTimeout(()=>{a.unsubscribe(),r(new jf(this.ErrorMessage_ListenTimeout,`ListenTimeout`))},t):null})}exchangeBusyPromise;async exchangeAtomicImpl(e){let t=this.tracer.withUpdatedContext({function:`exchangeAtomicImpl`,unresponsiveTimeout:this.unresponsiveTimeout});if(this.exchangeBusyPromise)throw t.trace(`Atomic exchange is already busy`),new If(`An action was already pending on the Ledger device. Please deny or reconnect.`);let n,r=new Promise(e=>{n=e});this.exchangeBusyPromise=r;let i=!1,a=setTimeout(()=>{t.trace(`Timeout reached, emitting Transport event "unresponsive"`,{unresponsiveTimeout:this.unresponsiveTimeout}),i=!0,this.emit(`unresponsive`)},this.unresponsiveTimeout);try{let n=await e();return i&&(t.trace(`Device was unresponsive, emitting responsive`),this.emit(`responsive`)),n}finally{t.trace(`Finalize, clearing busy guard`),clearTimeout(a),n&&n(),this.exchangeBusyPromise=null}}decorateAppAPIMethods(e,t,n){for(let r of t)e[r]=this.decorateAppAPIMethod(r,e[r],e,n)}_appAPIlock=null;decorateAppAPIMethod(e,t,n,r){return async(...i)=>{let{_appAPIlock:a}=this;if(a)return Promise.reject(new jf(`Ledger Device is busy (lock `+a+`)`,`TransportLocked`));try{return this._appAPIlock=e,this.setScrambleKey(r),await t.apply(n,i)}finally{this._appAPIlock=null}}}setTraceContext(e){this.tracer=this.tracer.withContext(e)}updateTraceContext(e){this.tracer.updateContext(e)}getTraceContext(){return this.tracer.getContext()}static ErrorMessage_ListenTimeout=`No Ledger device found (timeout)`;static ErrorMessage_NoDeviceFound=`No Ledger device found`};k();var zf=class e extends Rf{walletApi;transportId;constructor(e,t){super(),this.transportId=t,this.walletApi=e}static isSupported=()=>Promise.resolve(!0);static list=()=>Promise.resolve([]);static listen=e=>({unsubscribe:()=>{}});static open({walletApi:t,transportId:n}){return Promise.resolve(new e(t,n))}async exchange(e){let t=e.toString(`hex`),n=await this.walletApi.request(`device.exchange`,{transportId:this.transportId,apduHex:t}),r=lf.result.parse(n);return A.from(r.responseHex,`hex`)}setScrambleKey(){}async close(){let e=await this.walletApi.request(`device.close`,{transportId:this.transportId});cf.result.parse(e)}},Bf=class{client;constructor(e){this.client=e}async list(e){let t=await this.client.request(`account.list`,{currencyIds:e?.currencyIds});return Zd.result.parse(t).rawAccounts.map(qe)}async request(e){let t=await this.client.request(`account.request`,{currencyIds:e?.currencyIds,showAccountFilter:e?.showAccountFilter,drawerConfiguration:e?.drawerConfiguration,useCase:e?.useCase,uiUseCase:e?.uiUseCase});return qe($d.result.parse(t).rawAccount)}async receive(e){let t=await this.client.request(`account.receive`,{accountId:e});return Qd.result.parse(t).address}async getPublicKey(e,t){let n=await this.client.request(`account.getPublicKey`,{accountId:e,derivationPath:t});return Xd.result.parse(n).publicKey}async getMaxSpendable(e){let t=await this.client.request(`account.getMaxSpendable`,{accountId:e});return new P(Yd.result.parse(t).maxSpendable)}},Vf=class{client;constructor(e){this.client=e}async getAddress(e,t){let n=await this.client.request(`bitcoin.getAddress`,{accountId:e,derivationPath:t});return ef.result.parse(n).address}async getAddresses(e,t){let n=await this.client.request(`bitcoin.getAddresses`,{accountId:e,intentions:t});return tf.result.parse(n).addresses}async getPublicKey(e,t){let n=await this.client.request(`bitcoin.getPublicKey`,{accountId:e,derivationPath:t});return nf.result.parse(n).publicKey}async getXPub(e){let t=await this.client.request(`bitcoin.getXPub`,{accountId:e});return rf.result.parse(t).xPub}async signPsbt(e,t,n){let r=await this.client.request(`bitcoin.signPsbt`,{accountId:e,psbt:t,broadcast:n}),{psbtSigned:i,txHash:a}=af.result.parse(r);return{psbtSigned:i,txHash:a}}},Hf=class{client;constructor(e){this.client=e}async list(e){let t=await this.client.request(`currency.list`,{currencyIds:e?.currencyIds});return of.result.parse(t).currencies}},Uf=class{client;constructor(e){this.client=e}async transport(e){let t=await this.client.request(`device.transport`,e),n=ff.result.parse(t);return zf.open({walletApi:this.client,transportId:n.transportId})}async open(e){let t=await this.client.request(`device.open`,e),n=uf.result.parse(t);return zf.open({walletApi:this.client,transportId:n.transportId})}async select(e){let t=await this.client.request(`device.select`,e);return df.result.parse(t)}},Wf=class{client;constructor(e){this.client=e}async start(e){let t=await this.client.request(`exchange.start`,{exchangeType:e});return gf.result.parse(t).transactionId}async completeSwap({provider:e,fromAccountId:t,toAccountId:n,swapId:r,rate:i,transaction:a,binaryPayload:o,signature:s,feeStrategy:c,tokenCurrency:l}){let u=await this.client.request(`exchange.complete`,{exchangeType:`SWAP`,provider:e,fromAccountId:t,toAccountId:n,swapId:r,rate:i,rawTransaction:Ou(a),hexBinaryPayload:o.toString(`hex`),hexSignature:s.toString(`hex`),feeStrategy:c,tokenCurrency:l});return hf.result.parse(u).transactionHash}async completeSell({provider:e,fromAccountId:t,transaction:n,binaryPayload:r,signature:i,feeStrategy:a}){let o=await this.client.request(`exchange.complete`,{exchangeType:`SELL`,provider:e,fromAccountId:t,rawTransaction:Ou(n),hexBinaryPayload:r.toString(`hex`),hexSignature:i.toString(`hex`),feeStrategy:a});return hf.result.parse(o).transactionHash}async completeFund({provider:e,fromAccountId:t,transaction:n,binaryPayload:r,signature:i,feeStrategy:a,tokenCurrency:o}){let s=await this.client.request(`exchange.complete`,{exchangeType:`FUND`,provider:e,fromAccountId:t,rawTransaction:Ou(n),hexBinaryPayload:r.toString(`hex`),hexSignature:i.toString(`hex`),feeStrategy:a,tokenCurrency:o});return hf.result.parse(s).transactionHash}};k();var Gf=class{client;constructor(e){this.client=e}async sign(e,t,n,r){let i=await this.client.request(`message.sign`,{accountId:e,hexMessage:t.toString(`hex`),options:n,meta:r}),a=vf.result.parse(i);return A.from(a.hexSignedMessage,`hex`)}},Kf=class{client;constructor(e){this.client=e}async get(e,t){let n=await this.client.request(`storage.get`,{key:e,storeId:t});return yf.result.parse(n).value}async set(e,t,n){let r=await this.client.request(`storage.set`,{key:e,value:t,storeId:n});return bf.result.parse(r)}};k();var qf=class{client;constructor(e){this.client=e}async sign(e,t,n,r){let i=await this.client.request(`transaction.sign`,{accountId:e,rawTransaction:Ou(t),options:n,meta:r}),a=Sf.result.parse(i);return A.from(a.signedTransactionHex,`hex`)}async signRaw(e,t,n,r,i){let a=await this.client.request(`transaction.signRaw`,{accountId:e,rawTransaction:t,broadcast:n,options:r,meta:i});return Ef.result.parse(a)}async signAndBroadcast(e,t,n,r){let i=await this.client.request(`transaction.signAndBroadcast`,{accountId:e,rawTransaction:Ou(t),options:n,meta:r});return wf.result.parse(i).transactionHash}},Jf=class{client;constructor(e){this.client=e}async userId(){let e=await this.client.request(`wallet.userId`,{});return kf.result.parse(e).userId}async info(){let e=await this.client.request(`wallet.info`,{});return Of.result.parse(e)}async capabilities(){let e=await this.client.request(`wallet.capabilities`,{});return Df.result.parse(e).methodIds}},Yf=new Sd(`Wallet-API-Client`),Xf={"event.account.updated":e=>Promise.resolve()},Zf=class extends Jd{account;bitcoin;currency;device;message;storage;transaction;wallet;exchange;custom;logger;constructor(e,t=Yf,n,r={}){super(e,{...Xf,...r}),this.logger=t,this.account=new Bf(this),this.bitcoin=new Vf(this),this.currency=new Hf(this),this.device=new Uf(this),this.message=new Gf(this),this.storage=new Kf(this),this.transaction=new qf(this),this.wallet=new Jf(this),this.exchange=new Wf(this),this.custom=n?n(this):{}}setEventHandlers(e){this.requestHandlers={...Xf,...e}}onRequest(e){this.logger.log(e.method);let t=this.requestHandlers[e.method];if(!t)throw new zd({code:Bd.METHOD_NOT_FOUND,message:`method not found`});return t(e)}},Qf={near:{"*":{currencyId:`near`,family:`near`,network:`near`}},tezos:{"*":{currencyId:`tezos`,family:`tezos`,network:`tezos`}},solana:{"*":{currencyId:`solana`,family:`solana`,network:`solana`}},tron:{"*":{currencyId:`tron`,family:`tron`,network:`tron`}},ton:{"*":{currencyId:`ton`,family:`ton`,network:`ton`}},polkadot:{"*":{currencyId:`assethub_polkadot`,family:`polkadot`,network:`polkadot`}},celo:{"*":{currencyId:`celo`,family:`celo`,network:`celo`}},ethereum:{ethereum:{currencyId:`ethereum`,family:`ethereum`,network:`ethereum`},polygon:{currencyId:`polygon`,family:`ethereum`,network:`polygon`},arbitrum:{currencyId:`arbitrum`,family:`ethereum`,network:`arbitrum`},optimism:{currencyId:`optimism`,family:`ethereum`,network:`optimism`},avalanche_c_chain:{currencyId:`avalanche_c_chain`,family:`ethereum`,network:`avalanche-c`},ethereum_hoodi:{currencyId:`ethereum_hoodi`,family:`ethereum`,network:`ethereum-hoodi`},bsc:{currencyId:`bsc`,family:`ethereum`,network:`binance`}},cosmos:{cosmos:{currencyId:`cosmos`,family:`cosmos`,network:`cosmos`},crypto_org:{currencyId:`crypto_org`,family:`cosmos`,network:`cronos`},osmo:{currencyId:`osmo`,family:`cosmos`,network:`osmosis`},coreum:{currencyId:`coreum`,family:`cosmos`,network:`coreum`},axelar:{currencyId:`axelar`,family:`cosmos`,network:`axelar`},stargaze:{currencyId:`stargaze`,family:`cosmos`,network:`stargaze`},secret_network:{currencyId:`secret_network`,family:`cosmos`,network:`secret`},umee:{currencyId:`umee`,family:`cosmos`,network:`umee`},desmos:{currencyId:`desmos`,family:`cosmos`,network:`desmos`},onomy:{currencyId:`onomy`,family:`cosmos`,network:`onomy`},quicksilver:{currencyId:`quicksilver`,family:`cosmos`,network:`quicksilver`},persistence:{currencyId:`persistence`,family:`cosmos`,network:`persistence`},dydx:{currencyId:`dydx`,family:`cosmos`,network:`dydx`},injective:{currencyId:`injective`,family:`cosmos`,network:`injective`},sei:{currencyId:`sei`,family:`cosmos`,network:`sei`},mantra:{currencyId:`mantra`,family:`cosmos`,network:`mantra`}}},$f=new Map([[`polkadot`,1],[`avalanche-c`,2],[`tron`,3],[`binance`,4],[`cronos`,5],[`polygon`,6]]);k();var ep=be(),tp=l(c({amount:p(l(m)),gasLimit:p(l(m)),token:p(l(c({decimals:_})))})),np=h(tp),rp=h(y),ip=new Set([`polygon`,`optimism`,`arbitrum`,`avalanche-c`,`core`]),ap=class extends f()(`LedgerTransactionPreparationError`,{message:m}){},op=e=>new ap({message:e}),sp=ee(function*(){let e=yield*C(w({try:()=>ie(()=>import(`./polkadot-ledger-transaction-36Qv7Wb4.js`).then(e=>e.buildPolkadotLedgerTransaction),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])),catch:()=>op(`Could not load Polkadot transaction support`)}));return({family:t,network:n,tx:r,txMeta:i})=>u(rp)(r).pipe(b(()=>op(`Failed to parse tx`)),E(r=>n===`polkadot`?i?cp({loadPolkadotBuilder:e,payload:r,txMeta:i}):S(op(`Missing classic transaction metadata`)):T(lp({family:t,network:n,payload:r,txMeta:i})).pipe(b(op))))}),cp=({loadPolkadotBuilder:e,payload:t,txMeta:n})=>T(ce(de,t)).pipe(b(op),E(t=>e.pipe(E(e=>T(e({fee:vp(gp(n.gasEstimate)).toString(),payload:t,txMeta:n})).pipe(b(op)))))),lp=({family:e,network:t,payload:i,txMeta:s})=>{if(he(t))return ce(le,i).pipe(n(e=>up({network:t,tx:e})));if(e===`borrow`)return o(`Unsupported Borrow network`);if(!s)return o(`Missing classic transaction metadata`);switch(t){case`tron`:return ce(Se,i).pipe(a(()=>fp(s)));case`near`:return pp(s);case`tezos`:return mp(s);case`ton`:return ce(xe,i).pipe(a(e=>hp(e,s)));default:return me(t)?dp(s):r(i)}},up=({network:e,tx:t})=>{let n={amount:(t.value??0n).toString(),recipient:t.to,family:`ethereum`,gasLimit:t.gasLimit.toString(),data:A.from(ge(t.data)).toString(`hex`)};return t.maxFeePerGas&&t.maxPriorityFeePerGas&&!ip.has(e)?(n.maxFeePerGas=t.maxFeePerGas.toString(),n.maxPriorityFeePerGas=t.maxPriorityFeePerGas.toString()):t.gasPrice&&(n.gasPrice=t.gasPrice.toString()),n},dp=e=>{let t=e.rawArguments?.validatorAddress,n=yp(e.txType),i=_p(e)??(bp(n)?oe():null);return!t||i===null?o(`Missing Cosmos Ledger arguments`):r({family:`cosmos`,mode:n,validators:[{address:t,amount:i.toString()}],amount:i.toString(),recipient:t,memo:`via StakeKit CID-1009`})},fp=e=>{let t=_p(e),i=e.rawArguments?.tronResource,a=e.rawArguments?.validatorAddress??e.rawArguments?.validatorAddresses?.[0],s=e.address;return(()=>{switch(e.txType){case`FREEZE_BANDWIDTH`:case`FREEZE_ENERGY`:return!t||!i?o(`Missing Tron freeze arguments`):r({amount:t.toString(),recipient:s,family:`tron`,mode:`freeze`,resource:i});case`VOTE`:{let r=e.rawArguments?.validatorAddresses;return!t||!r?.length?o(`Missing Tron vote arguments`):Cp({txMeta:e,validatorAddresses:r}).pipe(n(e=>({amount:t.toString(),recipient:s,family:`tron`,mode:`vote`,votes:e})))}case`UNDELEGATE_BANDWIDTH`:case`UNDELEGATE_ENERGY`:return!t||!i||!a?o(`Missing Tron undelegate arguments`):r({amount:t.toString(),recipient:String(a),family:`tron`,mode:`unDelegateResource`,resource:i});case`UNFREEZE_LEGACY_BANDWIDTH`:case`UNFREEZE_LEGACY_ENERGY`:return r({amount:`0`,recipient:``,family:`tron`,mode:`legacyUnfreeze`,resource:i});case`UNFREEZE_BANDWIDTH`:case`UNFREEZE_ENERGY`:return!t||!i?o(`Missing Tron unfreeze arguments`):r({amount:t.toString(),recipient:s,family:`tron`,mode:`unfreeze`,resource:i});case`CLAIM_REWARDS`:return r({amount:`0`,recipient:s,family:`tron`,mode:`claimReward`});default:return o(`Unsupported Tron Ledger transaction type: ${e.txType}`)}})().pipe(n(e=>({...e,votes:e.votes??[]})))},pp=e=>{let t=e.rawArguments?.validatorAddress,n=_p(e);return!t||!n?o(`Missing Near Ledger arguments`):r({amount:n.toString(),recipient:t,family:`near`,mode:xp(e.txType),fees:vp(gp(e.gasEstimate)).toString()})},mp=e=>{let t=gp(e.gasEstimate),n=e.txType===`UNSTAKE`,i=n?``:e.rawArguments?.validatorAddress;return!n&&!i?o(`Missing Tezos Ledger validator`):r({family:`tezos`,mode:n?`undelegate`:`delegate`,amount:`0`,recipient:i??``,fees:vp(t).toString(),gasLimit:String(t?.gasLimit??0)})},hp=(e,t)=>{let n=gp(t.gasEstimate);if(!(`message`in e)){let t=e[0];return t?r({family:`ton`,amount:t.amount,recipient:t.address,fees:vp(n).toString(),comment:{text:t.payload,isEncrypted:!1}}):o(`Unsupported Ton Ledger transaction payload`)}try{let t=(0,ep.loadMessageRelaxed)(ep.Cell.fromBase64(e.message).beginParse()),i=t.info;return r({family:`ton`,amount:i.value.coins.toString(),recipient:i.dest.toString(),fees:vp(n).toString(),comment:{text:t.body.toBoc().toString(`base64`),isEncrypted:!1}})}catch{return o(`Unsupported Ton Ledger transaction payload`)}},gp=e=>e?d(np)(e).pipe(s):null,_p=e=>{if(e.amountRaw)return pe(e.amountRaw);let t=e.rawArguments?.amount??e.amount,n=e.inputToken?.decimals;return!t||n===void 0?null:pe(t).multipliedBy(pe(10).pow(n))},vp=e=>!e?.amount||!e.token?oe():pe(e.amount).multipliedBy(pe(10).pow(e.token.decimals)),yp=e=>{switch(e){case`STAKE`:return`delegate`;case`UNSTAKE`:return`undelegate`;case`RESTAKE`:case`REBOND`:return`redelegate`;case`RESTAKE_REWARDS`:return`claimRewardCompound`;case`CLAIM_REWARDS`:return`claimReward`;default:return`delegate`}},bp=e=>e===`claimReward`||e===`claimRewardCompound`,xp=e=>{switch(e){case`STAKE`:return`stake`;case`UNSTAKE`:return`unstake`;case`WITHDRAW`:case`CLAIM_UNSTAKED`:return`withdraw`;default:return`stake`}},Sp=e=>{let t=e.rawArguments?.amount??e.amount;if(t)return pe(t);let n=e.inputToken?.decimals;return!e.amountRaw||n===void 0?null:pe(e.amountRaw).dividedBy(pe(10).pow(n))},Cp=({txMeta:e,validatorAddresses:t})=>{let n=Sp(e);if(!n)return o(`Missing Tron vote arguments`);let i=t.length,a=n.dividedToIntegerBy(i),s=n.modulo(i).integerValue(fe.ROUND_FLOOR);if(!a.isFinite()||!s.isFinite()||a.isNegative()||s.isNegative())return o(`Invalid Tron vote count`);if(a.plus(1).gt(2**53-1))return o(`Tron vote count exceeds Ledger limits`);let c=ae(s);if(c==null)return o(`Invalid Tron vote count`);let l=t.map((e,t)=>{let n=ae(a.plus(+(t<c)));return n==null?null:{address:e,voteCount:n}});return l.some(e=>e==null)?o(`Invalid Tron vote count`):r(l.filter(e=>e!=null))},wp=({accounts:e,ledgerCurrencies:t,enabledChainsMap:n})=>{let{accountsFamilies:r,accountsCurrencies:i}=e.reduce((e,n)=>{let r=t.get(n.currency);return r&&(e.accountsFamilies.add(r),e.accountsCurrencies.add(n.currency)),e},{accountsFamilies:new Set,accountsCurrencies:new Set}),a=g(Qf).reduce((e,[t,a])=>{let o=Object.keys(a).reduce((e,t)=>{let o=a[t];if(!o)return e;let s=n.evm[o.network]?.wagmiChain||n.cosmos[o.network]?.wagmiChain||n.misc[o.network]?.wagmiChain||n.substrate[o.network]?.wagmiChain;return s?r.has(o.family)&&(t===`*`||i.has(o.currencyId))?{...e,[t]:{...o,chain:s,enabled:!0}}:$f.has(o.network)?{...e,[t]:{...o,chain:s,enabled:!1}}:e:e},{});return{...e,[t]:o}},{});return Object.keys(a).reduce((e,t)=>{let n=a[t],r=Object.keys(n).reduce((e,t)=>{let r=n[t];return r&&e.set(t,r),e},new Map);return e.set(t,r),e},new Map)},Tp=e=>w({try:()=>e.currency.list({currencyIds:Object.values(Qf).flatMap(e=>Object.values(e).map(e=>e.currencyId))}),catch:e=>new te({cause:e,message:`could not get currencies`,operation:`ledger-list-currencies`})}).pipe(re(e=>e.reduce((e,t)=>(t.type===`CryptoCurrency`?e.cryptoCurrency.set(t.id,t.family):e.tokenCurrency.push(t),e),{cryptoCurrency:new Map,tokenCurrency:[]})),re(e=>(e.tokenCurrency.forEach(t=>{let n=e.cryptoCurrency.get(t.parent);n&&e.cryptoCurrency.set(t.id,n)}),e.cryptoCurrency))),Ep=({walletDetailsParams:e,enabledChainsMap:t,isLedgerDappBrowser:n,prepareTransaction:a,queryParams:s,runWalletEffect:c})=>O(l=>{let u=ve([]),d=ve([]),f=ve(void 0),p=f.changes.pipe(x(e=>e?.parentAccountId??e?.id)),m=[],h=ve([]),g=null,_=null,v=null,y=new wd;y.connect();let b=new Zf(y),S=async e=>{l.emitter.emit(`message`,{type:`connecting`});let n=await c(Tp(b)),r=await c(w({try:()=>b.account.list(),catch:e=>new te({cause:e,message:`could not get accounts`,operation:`ledger-list-accounts`})}).pipe(re(e=>({accounts:e,accountsMap:new Map(e.map(e=>[e.id,e]))})),re(e=>e.accounts.map(t=>t.parentAccountId?(()=>{let n=e.accountsMap.get(t.parentAccountId);return n?{...t,currency:n.currency}:t})():t))));m=r.filter(e=>!e.parentAccountId);let a=wp({ledgerCurrencies:n,accounts:m,enabledChainsMap:t});_=new Map([...a.values()].flatMap(e=>[...e.values()].map(e=>[e.chain.id,e.currencyId]))),v=a;let{enabled:o,disabled:p}=[...a.values()].reduce((e,t)=>(t.forEach(t=>{t.enabled?e.enabled.push(t.chain):e.disabled.push(t.chain)}),e),{enabled:[],disabled:[]});u.set([...o,...p]),d.set(p);let y=r.reduce((e,t)=>{let r=n.get(t.currency);if(!r)return e;let i=a.get(r);if(!r||!i)return e;let o=i.get(`*`)||i.get(t.currency);return o&&e.push({account:t,chainItem:o}),e},[]).sort((e,t)=>($f.get(e.chainItem.network)||999)-($f.get(t.chainItem.network)||999));if(!y.length){let t=a.get(`ethereum`)?.get(`ethereum`);if(!t)throw Error(`Default chain not found`);return h.set([]),g=t,T([`N/A`]),E(t.chain.id.toString()),ne(e?.withCapabilities,[`N/A`],t.chain.id)}let x=s.accountId?s.accountId.startsWith(`js:`)?{type:`address`,address:s.accountId.split(`:`)[3]}:{type:`accountId`,accountId:s.accountId}:null,S=(x?y.find(e=>x.type===`address`?e.account.address===x.address:e.account.id===x.accountId):void 0)??(s.network?y.find(e=>e.chainItem.network===s.network):void 0)??y[0];if(!S)throw Error(`Account not found`);return f.set(S.account),g=S.chainItem,h.set(i(C())),T([S.account.address]),E(g.chain.id.toString()),ne(e?.withCapabilities,[S.account.address],g.chain.id)},C=()=>g?r(m.filter(e=>e.currency===g?.currencyId)):o(Error(`Current chain not found`)),{onAccountsChanged:T,onChainChanged:E,onDisconnect:D}=Ce(l.emitter,ue),O=async()=>({}),ie=async()=>n,ae=async()=>y.disconnect(),oe=async()=>{let e=g?.chain.id;if(!e)throw Error(`Chain not found`);return e},ce=async()=>[f.get()?.address],le=e=>{f.set(e),T([e.address])},de=e=>ee(function*(){let t=_?.get(e.id);if(!t)return yield*new te({message:`Chain not found`,operation:`ledger-request-account`});let n=yield*w({try:()=>b.account.request({currencyIds:[t]}),catch:e=>new te({cause:e,message:`could not request account`,operation:`ledger-request-account`})});return m.push(n),u.set([...u.get(),e]),d.set(d.get().filter(t=>t.id!==e.id)),yield*w({try:()=>fe({chainId:e.id}),catch:e=>new te({cause:e,message:`failed to switch to new chain`,operation:`ledger-switch-chain`})})}),fe=async({chainId:e})=>{let t=g;if(!t||!v)throw Error(`Chain not found`);let n=[...v.values()].flatMap(e=>[...e.values()]).find(t=>t.chain.id===e);if(!n)throw Error(`Chain not found`);if(t.chain.id!==n.chain.id||!f.get()){g=n;let e=i(C());h.set(e),f.set(e[0])}let r=f.get();if(!r)throw Error(`Account not found`);return E(e.toString()),T([r.address]),n.chain};return{...e,id:se.id,name:se.name,type:se.type,connect:S,onAccountsChanged:T,onChainChanged:E,onDisconnect:D,getProvider:O,isAuthorized:ie,getChainId:oe,disconnect:ae,switchChain:fe,getAccounts:ce,switchAccount:le,requestAndSwitchAccount:de,walletApiClient:b,$accountsOnCurrentChain:h.changes,$filteredChains:u.changes,$currentAccountId:p,$disabledChains:d.changes,noAccountPlaceholder:`N/A`,deserializeTransaction:ku,prepareTransaction:a}}),Dp=({enabledChainsMap:e,isLedgerDappBrowser:t,queryParams:n,runWalletEffect:r})=>ee(function*(){let i=yield*sp;return{groupName:`Ledger Live`,wallets:[()=>({id:se.id,name:se.name,iconUrl:v.ledgerLogo,iconBackground:`#fff`,chainGroup:{id:se.id,title:se.name,iconUrl:v.ledgerLogo},availability:{_tag:`Injected`,detect:D(t)},createConnector:a=>Ep({walletDetailsParams:a,enabledChainsMap:e,isLedgerDappBrowser:t,prepareTransaction:i,queryParams:n,runWalletEffect:r})})]}});export{Dp as ledgerLiveConnector};
|
|
66
|
+
`+n.toString(t+` `)}return r}asSlice(){return this.beginParse()}asBuilder(){return(0,u.beginCell)().storeSlice(this.asSlice())}};e.Cell=d,t=n.inspectSymbol,d.EMPTY=new d})),$=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Builder=e.beginCell=void 0;var t=Fc(),n=ol(),r=qc();function i(){return new a}e.beginCell=i;var a=class e{constructor(){this._bits=new t.BitBuilder,this._refs=[]}get bits(){return this._bits.length}get refs(){return this._refs.length}get availableBits(){return 1023-this.bits}get availableRefs(){return 4-this.refs}storeBit(e){return this._bits.writeBit(e),this}storeBits(e){return this._bits.writeBits(e),this}storeBuffer(e,t){if(t!=null&&e.length!==t)throw Error(`Buffer length ${e.length} is not equal to ${t}`);return this._bits.writeBuffer(e),this}storeMaybeBuffer(e,t){return e===null?this.storeBit(0):(this.storeBit(1),this.storeBuffer(e,t)),this}storeUint(e,t){return this._bits.writeUint(e,t),this}storeMaybeUint(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeUint(e,t)),this}storeInt(e,t){return this._bits.writeInt(e,t),this}storeMaybeInt(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeInt(e,t)),this}storeVarUint(e,t){return this._bits.writeVarUint(e,t),this}storeMaybeVarUint(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeVarUint(e,t)),this}storeVarInt(e,t){return this._bits.writeVarInt(e,t),this}storeMaybeVarInt(e,t){return e==null?this.storeBit(0):(this.storeBit(1),this.storeVarInt(e,t)),this}storeCoins(e){return this._bits.writeCoins(e),this}storeMaybeCoins(e){return e==null?this.storeBit(0):(this.storeBit(1),this.storeCoins(e)),this}storeAddress(e){return this._bits.writeAddress(e),this}storeRef(t){if(this._refs.length>=4)throw Error(`Too many references`);if(t instanceof n.Cell)this._refs.push(t);else if(t instanceof e)this._refs.push(t.endCell());else throw Error(`Invalid argument`);return this}storeMaybeRef(e){return e?(this.storeBit(1),this.storeRef(e)):this.storeBit(0),this}storeSlice(e){let t=e.clone();for(t.remainingBits>0&&this.storeBits(t.loadBits(t.remainingBits));t.remainingRefs>0;)this.storeRef(t.loadRef());return this}storeMaybeSlice(e){return e?(this.storeBit(1),this.storeSlice(e)):this.storeBit(0),this}storeBuilder(e){return this.storeSlice(e.endCell().beginParse())}storeMaybeBuilder(e){return e?(this.storeBit(1),this.storeBuilder(e)):this.storeBit(0),this}storeWritable(e){return typeof e==`object`?e.writeTo(this):e(this),this}storeMaybeWritable(e){return e?(this.storeBit(1),this.storeWritable(e)):this.storeBit(0),this}store(e){return this.storeWritable(e),this}storeStringTail(e){return(0,r.writeString)(e,this),this}storeMaybeStringTail(e){return e==null?this.storeBit(0):(this.storeBit(1),(0,r.writeString)(e,this)),this}storeStringRefTail(e){return this.storeRef(i().storeStringTail(e)),this}storeMaybeStringRefTail(e){return e==null?this.storeBit(0):(this.storeBit(1),this.storeStringRefTail(e)),this}storeDict(e,t,n){return e?e.store(this,t,n):this.storeBit(0),this}storeDictDirect(e,t,n){return e.storeDirect(this,t,n),this}endCell(e){return new n.Cell({bits:this._bits.build(),refs:this._refs,exotic:e?.exotic})}asCell(){return this.endCell()}asSlice(){return this.endCell().beginParse()}};e.Builder=a})),sl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SimpleLibraryValue=e.storeSimpleLibrary=e.loadSimpleLibrary=void 0;function t(e){return{public:e.loadBit(),root:e.loadRef()}}e.loadSimpleLibrary=t;function n(e){return t=>{t.storeBit(e.public),t.storeRef(e.root)}}e.storeSimpleLibrary=n,e.SimpleLibraryValue={serialize(e,t){n(e)(t)},parse(e){return t(e)}}})),cl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTickTock=e.loadTickTock=void 0;function t(e){return{tick:e.loadBit(),tock:e.loadBit()}}e.loadTickTock=t;function n(e){return t=>{t.storeBit(e.tick),t.storeBit(e.tock)}}e.storeTickTock=n})),ll=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStateInit=e.loadStateInit=void 0;var t=Kc(),n=sl(),r=cl();function i(e){let i;e.loadBit()&&(i=e.loadUint(5));let a;e.loadBit()&&(a=(0,r.loadTickTock)(e));let o=e.loadMaybeRef(),s=e.loadMaybeRef(),c=e.loadDict(t.Dictionary.Keys.BigUint(256),n.SimpleLibraryValue);return c.size===0&&(c=void 0),{splitDepth:i,special:a,code:o,data:s,libraries:c}}e.loadStateInit=i;function a(e){return t=>{e.splitDepth!==null&&e.splitDepth!==void 0?(t.storeBit(!0),t.storeUint(e.splitDepth,5)):t.storeBit(!1),e.special!==null&&e.special!==void 0?(t.storeBit(!0),t.store((0,r.storeTickTock)(e.special))):t.storeBit(!1),t.storeMaybeRef(e.code),t.storeMaybeRef(e.data),t.storeDict(e.libraries)}}e.storeStateInit=a})),ul=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contractAddress=void 0;var t=$(),n=ll(),r=kc();function i(e,i){let a=(0,t.beginCell)().store((0,n.storeStateInit)(i)).endCell().hash();return new r.Address(e,a)}e.contractAddress=i})),dl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseTuple=e.serializeTuple=e.parseTupleItem=e.serializeTupleItem=void 0;var t=$(),n=BigInt(`-9223372036854775808`),r=BigInt(`9223372036854775807`);function i(e,a){if(e.type===`null`)a.storeUint(0,8);else if(e.type===`int`)e.value<=r&&e.value>=n?(a.storeUint(1,8),a.storeInt(e.value,64)):(a.storeUint(256,15),a.storeInt(e.value,257));else if(e.type===`nan`)a.storeInt(767,16);else if(e.type===`cell`)a.storeUint(3,8),a.storeRef(e.cell);else if(e.type===`slice`)a.storeUint(4,8),a.storeUint(0,10),a.storeUint(e.cell.bits.length,10),a.storeUint(0,3),a.storeUint(e.cell.refs.length,3),a.storeRef(e.cell);else if(e.type===`builder`)a.storeUint(5,8),a.storeRef(e.cell);else if(e.type===`tuple`){let n=null,r=null;for(let a=0;a<e.items.length;a++){let o=n;n=r,r=o,a>1&&(n=(0,t.beginCell)().storeRef(r).storeRef(n).endCell());let s=(0,t.beginCell)();i(e.items[a],s),r=s.endCell()}a.storeUint(7,8),a.storeUint(e.items.length,16),n&&a.storeRef(n),r&&a.storeRef(r)}else throw Error(`Invalid value`)}e.serializeTupleItem=i;function a(e){let n=e.loadUint(8);if(n===0)return{type:`null`};if(n===1)return{type:`int`,value:e.loadIntBig(64)};if(n===2)return e.loadUint(7)===0?{type:`int`,value:e.loadIntBig(257)}:(e.loadBit(),{type:`nan`});if(n===3)return{type:`cell`,cell:e.loadRef()};if(n===4){let n=e.loadUint(10),r=e.loadUint(10),i=e.loadUint(3),a=e.loadUint(3),o=e.loadRef().beginParse();o.skip(n);let s=o.loadBits(r-n),c=(0,t.beginCell)().storeBits(s);if(i<a){for(let e=0;e<i;e++)o.loadRef();for(let e=0;e<a-i;e++)c.storeRef(o.loadRef())}return{type:`slice`,cell:c.endCell()}}if(n===5)return{type:`builder`,cell:e.loadRef()};if(n===7){let t=e.loadUint(16),n=[];if(t>1){let r=e.loadRef().beginParse(),i=e.loadRef().beginParse();n.unshift(a(i));for(let e=0;e<t-2;e++){let e=r;r=e.loadRef().beginParse(),i=e.loadRef().beginParse(),n.unshift(a(i))}n.unshift(a(r))}else t===1&&n.push(a(e.loadRef().beginParse()));return{type:`tuple`,items:n}}throw Error(`Unsupported stack item`)}e.parseTupleItem=a;function o(e,n){if(e.length>0){let r=(0,t.beginCell)();o(e.slice(0,e.length-1),r),n.storeRef(r.endCell()),i(e[e.length-1],n)}}function s(e){let n=(0,t.beginCell)();return n.storeUint(e.length,24),o([...e],n),n.endCell()}e.serializeTuple=s;function c(e){let t=[],n=e.beginParse(),r=n.loadUint(24);for(let e=0;e<r;e++){let e=n.loadRef();t.unshift(a(n)),n=e.beginParse()}return t}e.parseTuple=c})),fl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TupleReader=void 0,e.TupleReader=class e{constructor(e){this.items=[...e]}get remaining(){return this.items.length}peek(){if(this.items.length===0)throw Error(`EOF`);return this.items[0]}pop(){if(this.items.length===0)throw Error(`EOF`);let e=this.items[0];return this.items.splice(0,1),e}skip(e=1){for(let t=0;t<e;t++)this.pop();return this}readBigNumber(){let e=this.pop();if(e.type!==`int`)throw Error(`Not a number`);return e.value}readBigNumberOpt(){let e=this.pop();if(e.type===`null`)return null;if(e.type!==`int`)throw Error(`Not a number`);return e.value}readNumber(){return Number(this.readBigNumber())}readNumberOpt(){let e=this.readBigNumberOpt();return e===null?null:Number(e)}readBoolean(){return this.readNumber()!==0}readBooleanOpt(){let e=this.readNumberOpt();return e===null?null:e!==0}readAddress(){let e=this.readCell().beginParse().loadAddress();if(e!==null)return e;throw Error(`Not an address`)}readAddressOpt(){let e=this.readCellOpt();return e===null?null:e.beginParse().loadMaybeAddress()}readCell(){let e=this.pop();if(e.type!==`cell`&&e.type!==`slice`&&e.type!==`builder`)throw Error(`Not a cell: `+e.type);return e.cell}readCellOpt(){let e=this.pop();if(e.type===`null`)return null;if(e.type!==`cell`&&e.type!==`slice`&&e.type!==`builder`)throw Error(`Not a cell`);return e.cell}readTuple(){let t=this.pop();if(t.type!==`tuple`)throw Error(`Not a tuple`);return new e(t.items)}readTupleOpt(){let t=this.pop();if(t.type===`null`)return null;if(t.type!==`tuple`)throw Error(`Not a tuple`);return new e(t.items)}static readLispList(e){let t=[],n=e;for(;n!==null;){var r=n.pop();if(n.items.length===0||n.items[0].type!==`tuple`&&n.items[0].type!==`null`)throw Error(`Lisp list consists only from (any, tuple) elements and ends with null`);n=n.readTupleOpt(),t.push(r)}return t}readLispListDirect(){return this.items.length===1&&this.items[0].type===`null`?[]:e.readLispList(this)}readLispList(){return e.readLispList(this.readTupleOpt())}readBuffer(){let e=this.readCell().beginParse();if(e.remainingRefs!==0||e.remainingBits%8!=0)throw Error(`Not a buffer`);return e.loadBuffer(e.remainingBits/8)}readBufferOpt(){let e=this.readCellOpt();if(e!==null){let t=e.beginParse();if(t.remainingRefs!==0||t.remainingBits%8!=0)throw Error(`Not a buffer`);return t.loadBuffer(t.remainingBits/8)}return null}readString(){return this.readCell().beginParse().loadStringTail()}readStringOpt(){let e=this.readCellOpt();return e===null?null:e.beginParse().loadStringTail()}}})),pl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TupleBuilder=void 0;var t=$(),n=ol(),r=Jc();e.TupleBuilder=class{constructor(){this._tuple=[]}writeNumber(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`int`,value:BigInt(e)})}writeBoolean(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`int`,value:e?-1n:0n})}writeBuffer(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeBuffer(e).endCell()})}writeString(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeStringTail(e).endCell()})}writeCell(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`cell`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`cell`,cell:e.asCell()})}writeSlice(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`slice`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`slice`,cell:e.asCell()})}writeBuilder(e){e==null?this._tuple.push({type:`null`}):e instanceof n.Cell?this._tuple.push({type:`builder`,cell:e}):e instanceof r.Slice&&this._tuple.push({type:`builder`,cell:e.asCell()})}writeTuple(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`tuple`,items:e})}writeAddress(e){e==null?this._tuple.push({type:`null`}):this._tuple.push({type:`slice`,cell:(0,t.beginCell)().storeAddress(e).endCell()})}build(){return[...this._tuple]}}})),ml=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fromNano=e.toNano=void 0;function t(e){if(typeof e==`bigint`)return e*1000000000n;{if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Invalid number`);if(Math.log10(e)<=6)e=e.toLocaleString(`en`,{minimumFractionDigits:9,useGrouping:!1});else if(e-Math.trunc(e)===0)e=e.toLocaleString(`en`,{maximumFractionDigits:0,useGrouping:!1});else throw Error(`Not enough precision for a number value. Use string value instead`)}let t=!1;for(;e.startsWith(`-`);)t=!t,e=e.slice(1);if(e===`.`)throw Error(`Invalid number`);let n=e.split(`.`);if(n.length>2)throw Error(`Invalid number`);let r=n[0],i=n[1];if(r||=`0`,i||=`0`,i.length>9)throw Error(`Invalid number`);for(;i.length<9;)i+=`0`;let a=BigInt(r)*1000000000n+BigInt(i);return t&&(a=-a),a}}e.toNano=t;function n(e){let t=BigInt(e),n=!1;t<0&&(n=!0,t=-t);let r=(t%1000000000n).toString();for(;r.length<9;)r=`0`+r;r=r.match(/^([0-9]*[1-9]|0)(0*)/)[1];let i=`${(t/1000000000n).toString()}${r===`0`?``:`.${r}`}`;return n&&(i=`-`+i),i}e.fromNano=n})),hl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.packExtraCurrencyCell=e.packExtraCurrencyDict=e.storeExtraCurrency=e.loadMaybeExtraCurrency=e.loadExtraCurrency=void 0;var t=$(),n=Kc();function r(e){let t=e instanceof n.Dictionary?e:n.Dictionary.loadDirect(n.Dictionary.Keys.Uint(32),n.Dictionary.Values.BigVarUint(5),e),r={};for(let[e,n]of t)r[e]=n;return r}e.loadExtraCurrency=r;function i(e){let t=e.loadMaybeRef();return t===null?t:r(t)}e.loadMaybeExtraCurrency=i;function a(e){return t=>{t.storeDict(o(e))}}e.storeExtraCurrency=a;function o(e){let t=n.Dictionary.empty(n.Dictionary.Keys.Uint(32),n.Dictionary.Values.BigVarUint(5));return Object.entries(e).map(([e,n])=>t.set(Number(e),n)),t}e.packExtraCurrencyDict=o;function s(e){return(0,t.beginCell)().storeDictDirect(o(e)).endCell()}e.packExtraCurrencyCell=s})),gl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.comment=e.external=e.internal=void 0;var t=kc(),n=ol(),r=$(),i=ml(),a=hl();function o(e){let o=!0;e.bounce!==null&&e.bounce!==void 0&&(o=e.bounce);let s;if(typeof e.to==`string`)s=t.Address.parse(e.to);else if(t.Address.isAddress(e.to))s=e.to;else throw Error(`Invalid address ${e.to}`);let c;c=typeof e.value==`string`?(0,i.toNano)(e.value):e.value;let l;e.extracurrency&&(l=(0,a.packExtraCurrencyDict)(e.extracurrency));let u=n.Cell.EMPTY;return typeof e.body==`string`?u=(0,r.beginCell)().storeUint(0,32).storeStringTail(e.body).endCell():e.body&&(u=e.body),{info:{type:`internal`,dest:s,value:{coins:c,other:l},bounce:o,ihrDisabled:!0,bounced:!1,ihrFee:0n,forwardFee:0n,createdAt:0,createdLt:0n},init:e.init??void 0,body:u}}e.internal=o;function s(e){let r;if(typeof e.to==`string`)r=t.Address.parse(e.to);else if(t.Address.isAddress(e.to))r=e.to;else throw Error(`Invalid address ${e.to}`);return{info:{type:`external-in`,dest:r,importFee:0n},init:e.init??void 0,body:e.body||n.Cell.EMPTY}}e.external=s;function c(e){return(0,r.beginCell)().storeUint(0,32).storeStringTail(e).endCell()}e.comment=c})),_l=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountState=e.loadAccountState=void 0;var t=ll();function n(e){return e.loadBit()?{type:`active`,state:(0,t.loadStateInit)(e)}:e.loadBit()?{type:`frozen`,stateHash:e.loadUintBig(256)}:{type:`uninit`}}e.loadAccountState=n;function r(e){return n=>{e.type===`active`?(n.storeBit(!0),n.store((0,t.storeStateInit)(e.state))):e.type===`frozen`?(n.storeBit(!1),n.storeBit(!0),n.storeUint(e.stateHash,256)):e.type===`uninit`&&(n.storeBit(!1),n.storeBit(!1))}}e.storeAccountState=r})),vl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCurrencyCollection=e.loadCurrencyCollection=void 0;var t=Kc();function n(e){let n=e.loadCoins(),r=e.loadDict(t.Dictionary.Keys.Uint(32),t.Dictionary.Values.BigVarUint(5));return r.size===0?{coins:n}:{other:r,coins:n}}e.loadCurrencyCollection=n;function r(e){return t=>{t.storeCoins(e.coins),e.other?t.storeDict(e.other):t.storeBit(0)}}e.storeCurrencyCollection=r})),yl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStorage=e.loadAccountStorage=void 0;var t=_l(),n=vl();function r(e){return{lastTransLt:e.loadUintBig(64),balance:(0,n.loadCurrencyCollection)(e),state:(0,t.loadAccountState)(e)}}e.loadAccountStorage=r;function i(e){return r=>{r.storeUint(e.lastTransLt,64),r.store((0,n.storeCurrencyCollection)(e.balance)),r.store((0,t.storeAccountState)(e.state))}}e.storeAccountStorage=i})),bl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageExtraInfo=e.loadStorageExtraInfo=void 0;function t(e){let t=e.loadUint(3);if(t===0)return null;if(t===1)return{dictHash:e.loadUintBig(256)};throw Error(`Invalid storage extra info header: ${t}`)}e.loadStorageExtraInfo=t;function n(e){return t=>{e==null?t.storeUint(0,3):(t.storeUint(1,3),t.storeUint(e.dictHash,256))}}e.storeStorageExtraInfo=n})),xl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageUsed=e.loadStorageUsed=void 0;function t(e){return{cells:e.loadVarUintBig(3),bits:e.loadVarUintBig(3)}}e.loadStorageUsed=t;function n(e){return t=>{t.storeVarUint(e.cells,3),t.storeVarUint(e.bits,3)}}e.storeStorageUsed=n})),Sl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeStorageInfo=e.loadStorageInfo=void 0;var t=bl(),n=xl();function r(e){return{used:(0,n.loadStorageUsed)(e),storageExtra:(0,t.loadStorageExtraInfo)(e),lastPaid:e.loadUint(32),duePayment:e.loadMaybeCoins()}}e.loadStorageInfo=r;function i(e){return r=>{r.store((0,n.storeStorageUsed)(e.used)),r.store((0,t.storeStorageExtraInfo)(e.storageExtra)),r.storeUint(e.lastPaid,32),r.storeMaybeCoins(e.duePayment)}}e.storeStorageInfo=i})),Cl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccount=e.loadAccount=void 0;var t=yl(),n=Sl();function r(e){return{addr:e.loadAddress(),storageStats:(0,n.loadStorageInfo)(e),storage:(0,t.loadAccountStorage)(e)}}e.loadAccount=r;function i(e){return r=>{r.storeAddress(e.addr),r.store((0,n.storeStorageInfo)(e.storageStats)),r.store((0,t.storeAccountStorage)(e.storage))}}e.storeAccount=i})),wl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStatus=e.loadAccountStatus=void 0;function t(e){let t=e.loadUint(2);if(t===0)return`uninitialized`;if(t===1)return`frozen`;if(t===2)return`active`;if(t===3)return`non-existing`;throw Error(`Invalid data`)}e.loadAccountStatus=t;function n(e){return t=>{if(e===`uninitialized`)t.storeUint(0,2);else if(e===`frozen`)t.storeUint(1,2);else if(e===`active`)t.storeUint(2,2);else if(e===`non-existing`)t.storeUint(3,2);else throw Error(`Invalid data`);return t}}e.storeAccountStatus=n})),Tl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeAccountStatusChange=e.loadAccountStatusChange=void 0;function t(e){return e.loadBit()?e.loadBit()?`deleted`:`frozen`:`unchanged`}e.loadAccountStatusChange=t;function n(e){return t=>{if(e==`unchanged`)t.storeBit(0);else if(e===`frozen`)t.storeBit(1),t.storeBit(0);else if(e===`deleted`)t.storeBit(1),t.storeBit(1);else throw Error(`Invalid account status change`)}}e.storeAccountStatusChange=n})),El=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCommonMessageInfoRelaxed=e.loadCommonMessageInfoRelaxed=void 0;var t=vl();function n(e){if(!e.loadBit())return{type:`internal`,ihrDisabled:e.loadBit(),bounce:e.loadBit(),bounced:e.loadBit(),src:e.loadMaybeAddress(),dest:e.loadAddress(),value:(0,t.loadCurrencyCollection)(e),ihrFee:e.loadCoins(),forwardFee:e.loadCoins(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)};if(!e.loadBit())throw Error(`External In message is not possible for CommonMessageInfoRelaxed`);return{type:`external-out`,src:e.loadMaybeAddress(),dest:e.loadMaybeExternalAddress(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}}e.loadCommonMessageInfoRelaxed=n;function r(e){return n=>{if(e.type===`internal`)n.storeBit(0),n.storeBit(e.ihrDisabled),n.storeBit(e.bounce),n.storeBit(e.bounced),n.storeAddress(e.src),n.storeAddress(e.dest),n.store((0,t.storeCurrencyCollection)(e.value)),n.storeCoins(e.ihrFee),n.storeCoins(e.forwardFee),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else if(e.type===`external-out`)n.storeBit(1),n.storeBit(1),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else throw Error(`Unknown CommonMessageInfo type`)}}e.storeCommonMessageInfoRelaxed=r})),Dl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeMessageRelaxed=e.loadMessageRelaxed=void 0;var t=$(),n=El(),r=ll();function i(e){let t=(0,n.loadCommonMessageInfoRelaxed)(e),i=null;e.loadBit()&&(i=e.loadBit()?(0,r.loadStateInit)(e.loadRef().beginParse()):(0,r.loadStateInit)(e));let a=e.loadBit()?e.loadRef():e.asCell();return{info:t,init:i,body:a}}e.loadMessageRelaxed=i;function a(e,i){return a=>{if(a.store((0,n.storeCommonMessageInfoRelaxed)(e.info)),e.init){a.storeBit(!0);let n=(0,t.beginCell)().store((0,r.storeStateInit)(e.init)),o=!1;o=i&&i.forceRef?!0:!(a.availableBits-2>=n.bits),o?(a.storeBit(!0),a.storeRef(n)):(a.storeBit(!1),a.storeBuilder(n))}else a.storeBit(!1);let o=!1;o=i&&i.forceRef?!0:!(a.availableBits-1>=e.body.bits.length&&a.refs+e.body.refs.length<=4&&!e.body.isExotic),o?(a.storeBit(!0),a.storeRef(e.body)):(a.storeBit(!1),a.storeBuilder(e.body.asBuilder()))}}e.storeMessageRelaxed=a})),Ol=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeLibRef=e.loadLibRef=void 0;function t(e){return e.loadUint(1)===0?{type:`hash`,libHash:e.loadBuffer(32)}:{type:`ref`,library:e.loadRef()}}e.loadLibRef=t;function n(e){return t=>{e.type===`hash`?(t.storeUint(0,1),t.storeBuffer(e.libHash)):(t.storeUint(1,1),t.storeRef(e.library))}}e.storeLibRef=n})),kl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadOutList=e.storeOutList=e.loadOutAction=e.storeOutAction=void 0;var t=Dl(),n=$(),r=vl(),i=Ol();function a(e){switch(e.type){case`sendMsg`:return s(e);case`setCode`:return l(e);case`reserve`:return d(e);case`changeLibrary`:return p(e);default:throw Error(`Unknown action type ${e.type}`)}}e.storeOutAction=a;var o=247711853;function s(e){return r=>{r.storeUint(o,32).storeUint(e.mode,8).storeRef((0,n.beginCell)().store((0,t.storeMessageRelaxed)(e.outMsg)).endCell())}}var c=2907562126;function l(e){return t=>{t.storeUint(c,32).storeRef(e.newCode)}}var u=921090057;function d(e){return t=>{t.storeUint(u,32).storeUint(e.mode,8).store((0,r.storeCurrencyCollection)(e.currency))}}var f=653925844;function p(e){return t=>{t.storeUint(f,32).storeUint(e.mode,7).store((0,i.storeLibRef)(e.libRef))}}function m(e){let n=e.loadUint(32);if(n===o)return{type:`sendMsg`,mode:e.loadUint(8),outMsg:(0,t.loadMessageRelaxed)(e.loadRef().beginParse())};if(n===c)return{type:`setCode`,newCode:e.loadRef()};if(n===u)return{type:`reserve`,mode:e.loadUint(8),currency:(0,r.loadCurrencyCollection)(e)};if(n===f)return{type:`changeLibrary`,mode:e.loadUint(7),libRef:(0,i.loadLibRef)(e)};throw Error(`Unknown out action tag 0x${n.toString(16)}`)}e.loadOutAction=m;function h(e){let t=e.reduce((e,t)=>(0,n.beginCell)().storeRef(e).store(a(t)).endCell(),(0,n.beginCell)().endCell());return e=>{e.storeSlice(t.beginParse())}}e.storeOutList=h;function g(e){let t=[];for(;e.remainingRefs;){let n=e.loadRef();t.push(m(e)),e=n.beginParse()}return t.reverse()}e.loadOutList=g})),Al=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeCommonMessageInfo=e.loadCommonMessageInfo=void 0;var t=vl();function n(e){return e.loadBit()?e.loadBit()?{type:`external-out`,src:e.loadAddress(),dest:e.loadMaybeExternalAddress(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}:{type:`external-in`,src:e.loadMaybeExternalAddress(),dest:e.loadAddress(),importFee:e.loadCoins()}:{type:`internal`,ihrDisabled:e.loadBit(),bounce:e.loadBit(),bounced:e.loadBit(),src:e.loadAddress(),dest:e.loadAddress(),value:(0,t.loadCurrencyCollection)(e),ihrFee:e.loadCoins(),forwardFee:e.loadCoins(),createdLt:e.loadUintBig(64),createdAt:e.loadUint(32)}}e.loadCommonMessageInfo=n;function r(e){return n=>{if(e.type===`internal`)n.storeBit(0),n.storeBit(e.ihrDisabled),n.storeBit(e.bounce),n.storeBit(e.bounced),n.storeAddress(e.src),n.storeAddress(e.dest),n.store((0,t.storeCurrencyCollection)(e.value)),n.storeCoins(e.ihrFee),n.storeCoins(e.forwardFee),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else if(e.type===`external-in`)n.storeBit(1),n.storeBit(0),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeCoins(e.importFee);else if(e.type===`external-out`)n.storeBit(1),n.storeBit(1),n.storeAddress(e.src),n.storeAddress(e.dest),n.storeUint(e.createdLt,64),n.storeUint(e.createdAt,32);else throw Error(`Unknown CommonMessageInfo type`)}}e.storeCommonMessageInfo=r})),jl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeComputeSkipReason=e.loadComputeSkipReason=void 0;function t(e){let t=e.loadUint(2);if(t===0)return`no-state`;if(t===1)return`bad-state`;if(t===2)return`no-gas`;throw Error(`Unknown ComputeSkipReason: ${t}`)}e.loadComputeSkipReason=t;function n(e){return t=>{if(e===`no-state`)t.storeUint(0,2);else if(e===`bad-state`)t.storeUint(1,2);else if(e===`no-gas`)t.storeUint(2,2);else throw Error(`Unknown ComputeSkipReason: ${e}`)}}e.storeComputeSkipReason=n})),Ml=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeDepthBalanceInfo=e.loadDepthBalanceInfo=void 0;var t=vl();function n(e){return{splitDepth:e.loadUint(5),balance:(0,t.loadCurrencyCollection)(e)}}e.loadDepthBalanceInfo=n;function r(e){return n=>{n.storeUint(e.splitDepth,5),n.store((0,t.storeCurrencyCollection)(e.balance))}}e.storeDepthBalanceInfo=r})),Nl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeHashUpdate=e.loadHashUpdate=void 0;function t(e){if(e.loadUint(8)!==114)throw Error(`Invalid data`);return{oldHash:e.loadBuffer(32),newHash:e.loadBuffer(32)}}e.loadHashUpdate=t;function n(e){return t=>{t.storeUint(114,8),t.storeBuffer(e.oldHash),t.storeBuffer(e.newHash)}}e.storeHashUpdate=n})),Pl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadMasterchainStateExtra=void 0;var t=Kc(),n=vl();function r(e){if(e.loadUint(16)!==52262)throw Error(`Invalid data`);e.loadBit()&&e.loadRef();let r=e.loadUintBig(256);return{config:t.Dictionary.load(t.Dictionary.Keys.Int(32),t.Dictionary.Values.Cell(),e),configAddress:r,globalBalance:(0,n.loadCurrencyCollection)(e)}}e.loadMasterchainStateExtra=r})),Fl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageValue=e.storeMessage=e.loadMessage=void 0;var t=$(),n=Al(),r=ll();function i(e){let t=(0,n.loadCommonMessageInfo)(e),i=null;e.loadBit()&&(i=e.loadBit()?(0,r.loadStateInit)(e.loadRef().beginParse()):(0,r.loadStateInit)(e));let a=e.loadBit()?e.loadRef():e.asCell();return{info:t,init:i,body:a}}e.loadMessage=i;function a(e,i){return a=>{if(a.store((0,n.storeCommonMessageInfo)(e.info)),e.init){a.storeBit(!0);let n=(0,t.beginCell)().store((0,r.storeStateInit)(e.init)),o=!1;o=i&&i.forceRef?!0:a.availableBits-2<n.bits+e.body.bits.length,o?(a.storeBit(!0),a.storeRef(n)):(a.storeBit(!1),a.storeBuilder(n))}else a.storeBit(!1);let o=!1;o=i&&i.forceRef?!0:a.availableBits-1<e.body.bits.length||a.refs+e.body.refs.length>4,o?(a.storeBit(!0),a.storeRef(e.body)):(a.storeBit(!1),a.storeBuilder(e.body.asBuilder()))}}e.storeMessage=a,e.MessageValue={serialize(e,n){n.storeRef((0,t.beginCell)().store(a(e)))},parse(e){return i(e.loadRef().beginParse())}}})),Il=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SendMode=void 0;var t;(function(e){e[e.CARRY_ALL_REMAINING_BALANCE=128]=`CARRY_ALL_REMAINING_BALANCE`,e[e.CARRY_ALL_REMAINING_INCOMING_VALUE=64]=`CARRY_ALL_REMAINING_INCOMING_VALUE`,e[e.DESTROY_ACCOUNT_IF_ZERO=32]=`DESTROY_ACCOUNT_IF_ZERO`,e[e.PAY_GAS_SEPARATELY=1]=`PAY_GAS_SEPARATELY`,e[e.IGNORE_ERRORS=2]=`IGNORE_ERRORS`,e[e.NONE=0]=`NONE`})(t||(e.SendMode=t={}))})),Ll=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ReserveMode=void 0;var t;(function(e){e[e.THIS_AMOUNT=0]=`THIS_AMOUNT`,e[e.LEAVE_THIS_AMOUNT=1]=`LEAVE_THIS_AMOUNT`,e[e.AT_MOST_THIS_AMOUNT=2]=`AT_MOST_THIS_AMOUNT`,e[e.LEAVE_MAX_THIS_AMOUNT=3]=`LEAVE_MAX_THIS_AMOUNT`,e[e.BEFORE_BALANCE_PLUS_THIS_AMOUNT=4]=`BEFORE_BALANCE_PLUS_THIS_AMOUNT`,e[e.LEAVE_BBALANCE_PLUS_THIS_AMOUNT=5]=`LEAVE_BBALANCE_PLUS_THIS_AMOUNT`,e[e.BEFORE_BALANCE_MINUS_THIS_AMOUNT=12]=`BEFORE_BALANCE_MINUS_THIS_AMOUNT`,e[e.LEAVE_BEFORE_BALANCE_MINUS_THIS_AMOUNT=13]=`LEAVE_BEFORE_BALANCE_MINUS_THIS_AMOUNT`})(t||(e.ReserveMode=t={}))})),Rl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardAccount=e.loadShardAccount=void 0;var t=$(),n=Cl();function r(e){let t=e.loadRef(),r;if(!t.isExotic){let e=t.beginParse();e.loadBit()&&(r=(0,n.loadAccount)(e))}return{account:r,lastTransactionHash:e.loadUintBig(256),lastTransactionLt:e.loadUintBig(64)}}e.loadShardAccount=r;function i(e){return r=>{e.account?r.storeRef((0,t.beginCell)().storeBit(!0).store((0,n.storeAccount)(e.account))):r.storeRef((0,t.beginCell)().storeBit(!1)),r.storeUint(e.lastTransactionHash,256),r.storeUint(e.lastTransactionLt,64)}}e.storeShardAccount=i})),zl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardAccounts=e.loadShardAccounts=e.ShardAccountRefValue=void 0;var t=Kc(),n=Ml(),r=Rl();e.ShardAccountRefValue={parse:e=>({depthBalanceInfo:(0,n.loadDepthBalanceInfo)(e),shardAccount:(0,r.loadShardAccount)(e)}),serialize(e,t){t.store((0,n.storeDepthBalanceInfo)(e.depthBalanceInfo)),t.store((0,r.storeShardAccount)(e.shardAccount))}};function i(n){return t.Dictionary.load(t.Dictionary.Keys.BigUint(256),e.ShardAccountRefValue,n)}e.loadShardAccounts=i;function a(e){return t=>{t.storeDict(e)}}e.storeShardAccounts=a})),Bl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeShardIdent=e.loadShardIdent=void 0;function t(e){if(e.loadUint(2)!==0)throw Error(`Invalid data`);return{shardPrefixBits:e.loadUint(6),workchainId:e.loadInt(32),shardPrefix:e.loadUintBig(64)}}e.loadShardIdent=t;function n(e){return t=>{t.storeUint(0,2),t.storeUint(e.shardPrefixBits,6),t.storeInt(e.workchainId,32),t.storeUint(e.shardPrefix,64)}}e.storeShardIdent=n})),Vl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadShardStateUnsplit=void 0;var t=Pl(),n=zl(),r=Bl();function i(e){if(e.loadUint(32)!==2418257890)throw Error(`Invalid data`);let i=e.loadInt(32),a=(0,r.loadShardIdent)(e),o=e.loadUint(32),s=e.loadUint(32),c=e.loadUint(32),l=e.loadUintBig(64),u=e.loadUint(32);e.loadRef();let d=e.loadBit(),f=e.loadRef(),p;f.isExotic||(p=(0,n.loadShardAccounts)(f.beginParse())),e.loadRef();let m=e.loadBit(),h=null;if(m){let n=e.loadRef();n.isExotic||(h=(0,t.loadMasterchainStateExtra)(n.beginParse()))}return{globalId:i,shardId:a,seqno:o,vertSeqNo:s,genUtime:c,genLt:l,minRefMcSeqno:u,beforeSplit:d,accounts:p,extras:h}}e.loadShardStateUnsplit=i})),Hl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeSplitMergeInfo=e.loadSplitMergeInfo=void 0;function t(e){return{currentShardPrefixLength:e.loadUint(6),accountSplitDepth:e.loadUint(6),thisAddress:e.loadUintBig(256),siblingAddress:e.loadUintBig(256)}}e.loadSplitMergeInfo=t;function n(e){return t=>{t.storeUint(e.currentShardPrefixLength,6),t.storeUint(e.accountSplitDepth,6),t.storeUint(e.thisAddress,256),t.storeUint(e.siblingAddress,256)}}e.storeSplitMergeInfo=n})),Ul=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionActionPhase=e.loadTransactionActionPhase=void 0;var t=Tl(),n=xl();function r(e){return{success:e.loadBit(),valid:e.loadBit(),noFunds:e.loadBit(),statusChange:(0,t.loadAccountStatusChange)(e),totalFwdFees:e.loadBit()?e.loadCoins():void 0,totalActionFees:e.loadBit()?e.loadCoins():void 0,resultCode:e.loadInt(32),resultArg:e.loadBit()?e.loadInt(32):void 0,totalActions:e.loadUint(16),specActions:e.loadUint(16),skippedActions:e.loadUint(16),messagesCreated:e.loadUint(16),actionListHash:e.loadUintBig(256),totalMessageSize:(0,n.loadStorageUsed)(e)}}e.loadTransactionActionPhase=r;function i(e){return r=>{r.storeBit(e.success),r.storeBit(e.valid),r.storeBit(e.noFunds),r.store((0,t.storeAccountStatusChange)(e.statusChange)),r.storeMaybeCoins(e.totalFwdFees),r.storeMaybeCoins(e.totalActionFees),r.storeInt(e.resultCode,32),r.storeMaybeInt(e.resultArg,32),r.storeUint(e.totalActions,16),r.storeUint(e.specActions,16),r.storeUint(e.skippedActions,16),r.storeUint(e.messagesCreated,16),r.storeUint(e.actionListHash,256),r.store((0,n.storeStorageUsed)(e.totalMessageSize))}}e.storeTransactionActionPhase=i})),Wl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionBouncePhase=e.loadTransactionBouncePhase=void 0;var t=xl();function n(e){return e.loadBit()?{type:`ok`,messageSize:(0,t.loadStorageUsed)(e),messageFees:e.loadCoins(),forwardFees:e.loadCoins()}:e.loadBit()?{type:`no-funds`,messageSize:(0,t.loadStorageUsed)(e),requiredForwardFees:e.loadCoins()}:{type:`negative-funds`}}e.loadTransactionBouncePhase=n;function r(e){return n=>{if(e.type===`ok`)n.storeBit(!0),n.store((0,t.storeStorageUsed)(e.messageSize)),n.storeCoins(e.messageFees),n.storeCoins(e.forwardFees);else if(e.type===`negative-funds`)n.storeBit(!1),n.storeBit(!1);else if(e.type===`no-funds`)n.storeBit(!1),n.storeBit(!0),n.store((0,t.storeStorageUsed)(e.messageSize)),n.storeCoins(e.requiredForwardFees);else throw Error(`Invalid TransactionBouncePhase type`)}}e.storeTransactionBouncePhase=r})),Gl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionComputePhase=e.loadTransactionComputePhase=void 0;var t=$(),n=jl();function r(e){if(!e.loadBit())return{type:`skipped`,reason:(0,n.loadComputeSkipReason)(e)};let t=e.loadBit(),r=e.loadBit(),i=e.loadBit(),a=e.loadCoins(),o=e.loadRef().beginParse();return{type:`vm`,success:t,messageStateUsed:r,accountActivated:i,gasFees:a,gasUsed:o.loadVarUintBig(3),gasLimit:o.loadVarUintBig(3),gasCredit:o.loadBit()?o.loadVarUintBig(2):void 0,mode:o.loadUint(8),exitCode:o.loadInt(32),exitArg:o.loadBit()?o.loadInt(32):void 0,vmSteps:o.loadUint(32),vmInitStateHash:o.loadUintBig(256),vmFinalStateHash:o.loadUintBig(256)}}e.loadTransactionComputePhase=r;function i(e){return r=>{if(e.type===`skipped`){r.storeBit(0),r.store((0,n.storeComputeSkipReason)(e.reason));return}r.storeBit(1),r.storeBit(e.success),r.storeBit(e.messageStateUsed),r.storeBit(e.accountActivated),r.storeCoins(e.gasFees),r.storeRef((0,t.beginCell)().storeVarUint(e.gasUsed,3).storeVarUint(e.gasLimit,3).store(t=>e.gasCredit!==void 0&&e.gasCredit!==null?t.storeBit(1).storeVarUint(e.gasCredit,2):t.storeBit(0)).storeUint(e.mode,8).storeInt(e.exitCode,32).store(t=>e.exitArg!==void 0&&e.exitArg!==null?t.storeBit(1).storeInt(e.exitArg,32):t.storeBit(0)).storeUint(e.vmSteps,32).storeUint(e.vmInitStateHash,256).storeUint(e.vmFinalStateHash,256).endCell())}}e.storeTransactionComputePhase=i})),Kl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionCreditPhase=e.loadTransactionCreditPhase=void 0;var t=vl();function n(e){return{dueFeesColelcted:e.loadBit()?e.loadCoins():void 0,credit:(0,t.loadCurrencyCollection)(e)}}e.loadTransactionCreditPhase=n;function r(e){return n=>{e.dueFeesColelcted===null||e.dueFeesColelcted===void 0?n.storeBit(!1):(n.storeBit(!0),n.storeCoins(e.dueFeesColelcted)),n.store((0,t.storeCurrencyCollection)(e.credit))}}e.storeTransactionCreditPhase=r})),ql=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionsStoragePhase=e.loadTransactionStoragePhase=void 0;var t=Tl();function n(e){let n=e.loadCoins(),r;e.loadBit()&&(r=e.loadCoins());let i=(0,t.loadAccountStatusChange)(e);return{storageFeesCollected:n,storageFeesDue:r,statusChange:i}}e.loadTransactionStoragePhase=n;function r(e){return n=>{n.storeCoins(e.storageFeesCollected),e.storageFeesDue===null||e.storageFeesDue===void 0?n.storeBit(!1):(n.storeBit(!0),n.storeCoins(e.storageFeesDue)),n.store((0,t.storeAccountStatusChange)(e.statusChange))}}e.storeTransactionsStoragePhase=r})),Jl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransactionDescription=e.loadTransactionDescription=void 0;var t=$(),n=Hl(),r=Yl(),i=Ul(),a=Wl(),o=Gl(),s=Kl(),c=ql();function l(e){let t=e.loadUint(4);if(t===0){let t=e.loadBit(),n;e.loadBit()&&(n=(0,c.loadTransactionStoragePhase)(e));let r;e.loadBit()&&(r=(0,s.loadTransactionCreditPhase)(e));let l=(0,o.loadTransactionComputePhase)(e),u;e.loadBit()&&(u=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let d=e.loadBit(),f;e.loadBit()&&(f=(0,a.loadTransactionBouncePhase)(e));let p=e.loadBit();return{type:`generic`,creditFirst:t,storagePhase:n,creditPhase:r,computePhase:l,actionPhase:u,bouncePhase:f,aborted:d,destroyed:p}}if(t===1)return{type:`storage`,storagePhase:(0,c.loadTransactionStoragePhase)(e)};if(t===2||t===3){let n=t===3,r=(0,c.loadTransactionStoragePhase)(e),a=(0,o.loadTransactionComputePhase)(e),s;e.loadBit()&&(s=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let l=e.loadBit(),u=e.loadBit();return{type:`tick-tock`,isTock:n,storagePhase:r,computePhase:a,actionPhase:s,aborted:l,destroyed:u}}if(t===4){let t=(0,n.loadSplitMergeInfo)(e),r;e.loadBit()&&(r=(0,c.loadTransactionStoragePhase)(e));let a=(0,o.loadTransactionComputePhase)(e),s;e.loadBit()&&(s=(0,i.loadTransactionActionPhase)(e.loadRef().beginParse()));let l=e.loadBit(),u=e.loadBit();return{type:`split-prepare`,splitInfo:t,storagePhase:r,computePhase:a,actionPhase:s,aborted:l,destroyed:u}}if(t===5)return{type:`split-install`,splitInfo:(0,n.loadSplitMergeInfo)(e),prepareTransaction:(0,r.loadTransaction)(e.loadRef().beginParse()),installed:e.loadBit()};throw Error(`Unsupported transaction description type ${t}`)}e.loadTransactionDescription=l;function u(e){return l=>{if(e.type===`generic`)l.storeUint(0,4),l.storeBit(e.creditFirst),e.storagePhase?(l.storeBit(!0),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase))):l.storeBit(!1),e.creditPhase?(l.storeBit(!0),l.store((0,s.storeTransactionCreditPhase)(e.creditPhase))):l.storeBit(!1),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.storeRef((0,t.beginCell)().store((0,i.storeTransactionActionPhase)(e.actionPhase)))):l.storeBit(!1),l.storeBit(e.aborted),e.bouncePhase?(l.storeBit(!0),l.store((0,a.storeTransactionBouncePhase)(e.bouncePhase))):l.storeBit(!1),l.storeBit(e.destroyed);else if(e.type===`storage`)l.storeUint(1,4),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase));else if(e.type===`tick-tock`)l.storeUint(e.isTock?3:2,4),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase)),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.storeRef((0,t.beginCell)().store((0,i.storeTransactionActionPhase)(e.actionPhase)))):l.storeBit(!1),l.storeBit(e.aborted),l.storeBit(e.destroyed);else if(e.type===`split-prepare`)l.storeUint(4,4),l.store((0,n.storeSplitMergeInfo)(e.splitInfo)),e.storagePhase?(l.storeBit(!0),l.store((0,c.storeTransactionsStoragePhase)(e.storagePhase))):l.storeBit(!1),l.store((0,o.storeTransactionComputePhase)(e.computePhase)),e.actionPhase?(l.storeBit(!0),l.store((0,i.storeTransactionActionPhase)(e.actionPhase))):l.storeBit(!1),l.storeBit(e.aborted),l.storeBit(e.destroyed);else if(e.type===`split-install`)l.storeUint(5,4),l.store((0,n.storeSplitMergeInfo)(e.splitInfo)),l.storeRef((0,t.beginCell)().store((0,r.storeTransaction)(e.prepareTransaction))),l.storeBit(e.installed);else throw Error(`Unsupported transaction description type ${e.type}`)}}e.storeTransactionDescription=u})),Yl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.storeTransaction=e.loadTransaction=void 0;var t=$(),n=Kc(),r=wl(),i=vl(),a=Nl(),o=Fl(),s=Jl();function c(e){let t=e.asCell();if(e.loadUint(4)!==7)throw Error(`Invalid data`);let c=e.loadUintBig(256),l=e.loadUintBig(64),u=e.loadUintBig(256),d=e.loadUintBig(64),f=e.loadUint(32),p=e.loadUint(15),m=(0,r.loadAccountStatus)(e),h=(0,r.loadAccountStatus)(e),g=e.loadRef().beginParse(),_=g.loadBit()?(0,o.loadMessage)(g.loadRef().beginParse()):void 0,v=g.loadDict(n.Dictionary.Keys.Uint(15),o.MessageValue);return g.endParse(),{address:c,lt:l,prevTransactionHash:u,prevTransactionLt:d,now:f,outMessagesCount:p,oldStatus:m,endStatus:h,inMessage:_,outMessages:v,totalFees:(0,i.loadCurrencyCollection)(e),stateUpdate:(0,a.loadHashUpdate)(e.loadRef().beginParse()),description:(0,s.loadTransactionDescription)(e.loadRef().beginParse()),raw:t,hash:()=>t.hash()}}e.loadTransaction=c;function l(e){return n=>{n.storeUint(7,4),n.storeUint(e.address,256),n.storeUint(e.lt,64),n.storeUint(e.prevTransactionHash,256),n.storeUint(e.prevTransactionLt,64),n.storeUint(e.now,32),n.storeUint(e.outMessagesCount,15),n.store((0,r.storeAccountStatus)(e.oldStatus)),n.store((0,r.storeAccountStatus)(e.endStatus));let c=(0,t.beginCell)();e.inMessage?(c.storeBit(!0),c.storeRef((0,t.beginCell)().store((0,o.storeMessage)(e.inMessage)))):c.storeBit(!1),c.storeDict(e.outMessages),n.storeRef(c),n.store((0,i.storeCurrencyCollection)(e.totalFees)),n.storeRef((0,t.beginCell)().store((0,a.storeHashUpdate)(e.stateUpdate))),n.storeRef((0,t.beginCell)().store((0,s.storeTransactionDescription)(e.description)))}}e.storeTransaction=l})),Xl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loadSimpleLibrary=e.loadShardStateUnsplit=e.storeShardIdent=e.loadShardIdent=e.storeShardAccounts=e.loadShardAccounts=e.ShardAccountRefValue=e.storeShardAccount=e.loadShardAccount=e.ReserveMode=e.SendMode=e.storeMessageRelaxed=e.loadMessageRelaxed=e.storeMessage=e.loadMessage=e.loadMasterchainStateExtra=e.storeHashUpdate=e.loadHashUpdate=e.storeExtraCurrency=e.loadMaybeExtraCurrency=e.loadExtraCurrency=e.packExtraCurrencyDict=e.packExtraCurrencyCell=e.storeDepthBalanceInfo=e.loadDepthBalanceInfo=e.storeCurrencyCollection=e.loadCurrencyCollection=e.storeComputeSkipReason=e.loadComputeSkipReason=e.storeCommonMessageInfoRelaxed=e.loadCommonMessageInfoRelaxed=e.storeCommonMessageInfo=e.loadCommonMessageInfo=e.storeOutList=e.loadOutList=e.storeOutAction=e.loadOutAction=e.storeAccountStorage=e.loadAccountStorage=e.storeAccountStatusChange=e.loadAccountStatusChange=e.storeAccountStatus=e.loadAccountStatus=e.storeAccountState=e.loadAccountState=e.storeAccount=e.loadAccount=e.comment=e.external=e.internal=void 0,e.storeTransactionsStoragePhase=e.loadTransactionStoragePhase=e.storeTransactionDescription=e.loadTransactionDescription=e.storeTransactionCreditPhase=e.loadTransactionCreditPhase=e.storeTransactionComputePhase=e.loadTransactionComputePhase=e.storeTransactionBouncePhase=e.loadTransactionBouncePhase=e.storeTransactionActionPhase=e.loadTransactionActionPhase=e.storeTransaction=e.loadTransaction=e.storeTickTock=e.loadTickTock=e.storeStorageUsed=e.loadStorageUsed=e.storeStorageInfo=e.loadStorageInfo=e.storeStateInit=e.loadStateInit=e.storeSplitMergeInfo=e.loadSplitMergeInfo=e.storeLibRef=e.loadLibRef=e.storeSimpleLibrary=void 0;var t=gl();Object.defineProperty(e,"internal",{enumerable:!0,get:function(){return t.internal}}),Object.defineProperty(e,"external",{enumerable:!0,get:function(){return t.external}}),Object.defineProperty(e,"comment",{enumerable:!0,get:function(){return t.comment}});var n=Cl();Object.defineProperty(e,"loadAccount",{enumerable:!0,get:function(){return n.loadAccount}}),Object.defineProperty(e,"storeAccount",{enumerable:!0,get:function(){return n.storeAccount}});var r=_l();Object.defineProperty(e,"loadAccountState",{enumerable:!0,get:function(){return r.loadAccountState}}),Object.defineProperty(e,"storeAccountState",{enumerable:!0,get:function(){return r.storeAccountState}});var i=wl();Object.defineProperty(e,"loadAccountStatus",{enumerable:!0,get:function(){return i.loadAccountStatus}}),Object.defineProperty(e,"storeAccountStatus",{enumerable:!0,get:function(){return i.storeAccountStatus}});var a=Tl();Object.defineProperty(e,"loadAccountStatusChange",{enumerable:!0,get:function(){return a.loadAccountStatusChange}}),Object.defineProperty(e,"storeAccountStatusChange",{enumerable:!0,get:function(){return a.storeAccountStatusChange}});var o=yl();Object.defineProperty(e,"loadAccountStorage",{enumerable:!0,get:function(){return o.loadAccountStorage}}),Object.defineProperty(e,"storeAccountStorage",{enumerable:!0,get:function(){return o.storeAccountStorage}});var s=kl();Object.defineProperty(e,"loadOutAction",{enumerable:!0,get:function(){return s.loadOutAction}}),Object.defineProperty(e,"storeOutAction",{enumerable:!0,get:function(){return s.storeOutAction}}),Object.defineProperty(e,"loadOutList",{enumerable:!0,get:function(){return s.loadOutList}}),Object.defineProperty(e,"storeOutList",{enumerable:!0,get:function(){return s.storeOutList}});var c=Al();Object.defineProperty(e,"loadCommonMessageInfo",{enumerable:!0,get:function(){return c.loadCommonMessageInfo}}),Object.defineProperty(e,"storeCommonMessageInfo",{enumerable:!0,get:function(){return c.storeCommonMessageInfo}});var l=El();Object.defineProperty(e,"loadCommonMessageInfoRelaxed",{enumerable:!0,get:function(){return l.loadCommonMessageInfoRelaxed}}),Object.defineProperty(e,"storeCommonMessageInfoRelaxed",{enumerable:!0,get:function(){return l.storeCommonMessageInfoRelaxed}});var u=jl();Object.defineProperty(e,"loadComputeSkipReason",{enumerable:!0,get:function(){return u.loadComputeSkipReason}}),Object.defineProperty(e,"storeComputeSkipReason",{enumerable:!0,get:function(){return u.storeComputeSkipReason}});var d=vl();Object.defineProperty(e,"loadCurrencyCollection",{enumerable:!0,get:function(){return d.loadCurrencyCollection}}),Object.defineProperty(e,"storeCurrencyCollection",{enumerable:!0,get:function(){return d.storeCurrencyCollection}});var f=Ml();Object.defineProperty(e,"loadDepthBalanceInfo",{enumerable:!0,get:function(){return f.loadDepthBalanceInfo}}),Object.defineProperty(e,"storeDepthBalanceInfo",{enumerable:!0,get:function(){return f.storeDepthBalanceInfo}});var p=hl();Object.defineProperty(e,"packExtraCurrencyCell",{enumerable:!0,get:function(){return p.packExtraCurrencyCell}}),Object.defineProperty(e,"packExtraCurrencyDict",{enumerable:!0,get:function(){return p.packExtraCurrencyDict}}),Object.defineProperty(e,"loadExtraCurrency",{enumerable:!0,get:function(){return p.loadExtraCurrency}}),Object.defineProperty(e,"loadMaybeExtraCurrency",{enumerable:!0,get:function(){return p.loadMaybeExtraCurrency}}),Object.defineProperty(e,"storeExtraCurrency",{enumerable:!0,get:function(){return p.storeExtraCurrency}});var m=Nl();Object.defineProperty(e,"loadHashUpdate",{enumerable:!0,get:function(){return m.loadHashUpdate}}),Object.defineProperty(e,"storeHashUpdate",{enumerable:!0,get:function(){return m.storeHashUpdate}});var h=Pl();Object.defineProperty(e,"loadMasterchainStateExtra",{enumerable:!0,get:function(){return h.loadMasterchainStateExtra}});var g=Fl();Object.defineProperty(e,"loadMessage",{enumerable:!0,get:function(){return g.loadMessage}}),Object.defineProperty(e,"storeMessage",{enumerable:!0,get:function(){return g.storeMessage}});var _=Dl();Object.defineProperty(e,"loadMessageRelaxed",{enumerable:!0,get:function(){return _.loadMessageRelaxed}}),Object.defineProperty(e,"storeMessageRelaxed",{enumerable:!0,get:function(){return _.storeMessageRelaxed}});var v=Il();Object.defineProperty(e,"SendMode",{enumerable:!0,get:function(){return v.SendMode}});var y=Ll();Object.defineProperty(e,"ReserveMode",{enumerable:!0,get:function(){return y.ReserveMode}});var b=Rl();Object.defineProperty(e,"loadShardAccount",{enumerable:!0,get:function(){return b.loadShardAccount}}),Object.defineProperty(e,"storeShardAccount",{enumerable:!0,get:function(){return b.storeShardAccount}});var x=zl();Object.defineProperty(e,"ShardAccountRefValue",{enumerable:!0,get:function(){return x.ShardAccountRefValue}}),Object.defineProperty(e,"loadShardAccounts",{enumerable:!0,get:function(){return x.loadShardAccounts}}),Object.defineProperty(e,"storeShardAccounts",{enumerable:!0,get:function(){return x.storeShardAccounts}});var S=Bl();Object.defineProperty(e,"loadShardIdent",{enumerable:!0,get:function(){return S.loadShardIdent}}),Object.defineProperty(e,"storeShardIdent",{enumerable:!0,get:function(){return S.storeShardIdent}});var C=Vl();Object.defineProperty(e,"loadShardStateUnsplit",{enumerable:!0,get:function(){return C.loadShardStateUnsplit}});var ee=sl();Object.defineProperty(e,"loadSimpleLibrary",{enumerable:!0,get:function(){return ee.loadSimpleLibrary}}),Object.defineProperty(e,"storeSimpleLibrary",{enumerable:!0,get:function(){return ee.storeSimpleLibrary}});var w=Ol();Object.defineProperty(e,"loadLibRef",{enumerable:!0,get:function(){return w.loadLibRef}}),Object.defineProperty(e,"storeLibRef",{enumerable:!0,get:function(){return w.storeLibRef}});var T=Hl();Object.defineProperty(e,"loadSplitMergeInfo",{enumerable:!0,get:function(){return T.loadSplitMergeInfo}}),Object.defineProperty(e,"storeSplitMergeInfo",{enumerable:!0,get:function(){return T.storeSplitMergeInfo}});var E=ll();Object.defineProperty(e,"loadStateInit",{enumerable:!0,get:function(){return E.loadStateInit}}),Object.defineProperty(e,"storeStateInit",{enumerable:!0,get:function(){return E.storeStateInit}});var D=Sl();Object.defineProperty(e,"loadStorageInfo",{enumerable:!0,get:function(){return D.loadStorageInfo}}),Object.defineProperty(e,"storeStorageInfo",{enumerable:!0,get:function(){return D.storeStorageInfo}});var O=xl();Object.defineProperty(e,"loadStorageUsed",{enumerable:!0,get:function(){return O.loadStorageUsed}}),Object.defineProperty(e,"storeStorageUsed",{enumerable:!0,get:function(){return O.storeStorageUsed}});var te=cl();Object.defineProperty(e,"loadTickTock",{enumerable:!0,get:function(){return te.loadTickTock}}),Object.defineProperty(e,"storeTickTock",{enumerable:!0,get:function(){return te.storeTickTock}});var ne=Yl();Object.defineProperty(e,"loadTransaction",{enumerable:!0,get:function(){return ne.loadTransaction}}),Object.defineProperty(e,"storeTransaction",{enumerable:!0,get:function(){return ne.storeTransaction}});var re=Ul();Object.defineProperty(e,"loadTransactionActionPhase",{enumerable:!0,get:function(){return re.loadTransactionActionPhase}}),Object.defineProperty(e,"storeTransactionActionPhase",{enumerable:!0,get:function(){return re.storeTransactionActionPhase}});var ie=Wl();Object.defineProperty(e,"loadTransactionBouncePhase",{enumerable:!0,get:function(){return ie.loadTransactionBouncePhase}}),Object.defineProperty(e,"storeTransactionBouncePhase",{enumerable:!0,get:function(){return ie.storeTransactionBouncePhase}});var ae=Gl();Object.defineProperty(e,"loadTransactionComputePhase",{enumerable:!0,get:function(){return ae.loadTransactionComputePhase}}),Object.defineProperty(e,"storeTransactionComputePhase",{enumerable:!0,get:function(){return ae.storeTransactionComputePhase}});var oe=Kl();Object.defineProperty(e,"loadTransactionCreditPhase",{enumerable:!0,get:function(){return oe.loadTransactionCreditPhase}}),Object.defineProperty(e,"storeTransactionCreditPhase",{enumerable:!0,get:function(){return oe.storeTransactionCreditPhase}});var se=Jl();Object.defineProperty(e,"loadTransactionDescription",{enumerable:!0,get:function(){return se.loadTransactionDescription}}),Object.defineProperty(e,"storeTransactionDescription",{enumerable:!0,get:function(){return se.storeTransactionDescription}});var ce=ql();Object.defineProperty(e,"loadTransactionStoragePhase",{enumerable:!0,get:function(){return ce.loadTransactionStoragePhase}}),Object.defineProperty(e,"storeTransactionsStoragePhase",{enumerable:!0,get:function(){return ce.storeTransactionsStoragePhase}})})),Zl=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.openContract=void 0;var t=kc(),n=ol();function r(e,r){let i,a=null;if(!t.Address.isAddress(e.address))throw Error(`Invalid address`);if(i=e.address,e.init){if(!(e.init.code instanceof n.Cell))throw Error(`Invalid init.code`);if(!(e.init.data instanceof n.Cell))throw Error(`Invalid init.data`);a=e.init}let o=r({address:i,init:a});return new Proxy(e,{get(e,t){let n=e[t];return typeof t==`string`&&(t.startsWith(`get`)||t.startsWith(`send`)||t.startsWith(`is`))&&typeof n==`function`?(...t)=>n.apply(e,[o,...t]):n}})}e.openContract=r})),Ql=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ComputeError=void 0,e.ComputeError=class e extends Error{constructor(t,n,r){super(t),this.exitCode=n,this.debugLogs=r&&r.debugLogs?r.debugLogs:null,this.logs=r&&r.logs?r.logs:null,Object.setPrototypeOf(this,e.prototype)}}})),$l=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.getMethodId=void 0;var t=new Int16Array([0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920]);function n(e){e instanceof A||(e=A.from(e));let n=0;for(let r=0;r<e.length;r++){let i=e[r];n=(t[(n>>8^i)&255]^n<<8)&65535}return n}function r(e){return n(e)&65535|65536}e.getMethodId=r})),eu=t((e=>{k(),Object.defineProperty(e,"__esModule",{value:!0}),e.safeSignVerify=e.safeSign=void 0;var t=ye(),n=8,r=64;function i(e,i){let a=A.from(i);if(a.length>r)throw Error(`Seed can be longer than 64 bytes`);if(a.length<n)throw Error(`Seed must be at least 8 bytes`);return(0,t.sha256_sync)(A.concat([A.from([255,255]),a,e.hash()]))}function a(e,n,r=`ton-safe-sign-magic`){return(0,t.sign)(i(e,r),n)}e.safeSign=a;function o(e,n,r,a=`ton-safe-sign-magic`){return(0,t.signVerify)(i(e,a),n,r)}e.safeSignVerify=o})),tu=t((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.safeSignVerify=e.safeSign=e.getMethodId=e.base32Encode=e.base32Decode=e.crc32c=e.crc16=e.fromNano=e.toNano=e.ComputeError=e.openContract=e.TupleBuilder=e.TupleReader=e.serializeTupleItem=e.parseTupleItem=e.serializeTuple=e.parseTuple=e.generateMerkleUpdate=e.generateMerkleProofDirect=e.generateMerkleProof=e.exoticPruned=e.exoticMerkleUpdate=e.convertToMerkleProof=e.exoticMerkleProof=e.Dictionary=e.Cell=e.CellType=e.Slice=e.beginCell=e.Builder=e.BitBuilder=e.BitReader=e.BitString=e.contractAddress=e.ADNLAddress=e.ExternalAddress=e.address=e.Address=void 0;var r=kc();Object.defineProperty(e,"Address",{enumerable:!0,get:function(){return r.Address}}),Object.defineProperty(e,"address",{enumerable:!0,get:function(){return r.address}});var i=Ac();Object.defineProperty(e,"ExternalAddress",{enumerable:!0,get:function(){return i.ExternalAddress}});var a=Mc();Object.defineProperty(e,"ADNLAddress",{enumerable:!0,get:function(){return a.ADNLAddress}});var o=ul();Object.defineProperty(e,"contractAddress",{enumerable:!0,get:function(){return o.contractAddress}});var s=Pc();Object.defineProperty(e,"BitString",{enumerable:!0,get:function(){return s.BitString}});var c=Rc();Object.defineProperty(e,"BitReader",{enumerable:!0,get:function(){return c.BitReader}});var l=Fc();Object.defineProperty(e,"BitBuilder",{enumerable:!0,get:function(){return l.BitBuilder}});var u=$();Object.defineProperty(e,"Builder",{enumerable:!0,get:function(){return u.Builder}}),Object.defineProperty(e,"beginCell",{enumerable:!0,get:function(){return u.beginCell}});var d=Jc();Object.defineProperty(e,"Slice",{enumerable:!0,get:function(){return d.Slice}});var f=Ic();Object.defineProperty(e,"CellType",{enumerable:!0,get:function(){return f.CellType}});var p=ol();Object.defineProperty(e,"Cell",{enumerable:!0,get:function(){return p.Cell}});var m=Kc();Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return m.Dictionary}});var h=zc();Object.defineProperty(e,"exoticMerkleProof",{enumerable:!0,get:function(){return h.exoticMerkleProof}}),Object.defineProperty(e,"convertToMerkleProof",{enumerable:!0,get:function(){return h.convertToMerkleProof}});var g=Xc();Object.defineProperty(e,"exoticMerkleUpdate",{enumerable:!0,get:function(){return g.exoticMerkleUpdate}});var _=Qc();Object.defineProperty(e,"exoticPruned",{enumerable:!0,get:function(){return _.exoticPruned}});var v=Bc();Object.defineProperty(e,"generateMerkleProof",{enumerable:!0,get:function(){return v.generateMerkleProof}}),Object.defineProperty(e,"generateMerkleProofDirect",{enumerable:!0,get:function(){return v.generateMerkleProofDirect}});var y=Vc();Object.defineProperty(e,"generateMerkleUpdate",{enumerable:!0,get:function(){return y.generateMerkleUpdate}});var b=dl();Object.defineProperty(e,"parseTuple",{enumerable:!0,get:function(){return b.parseTuple}}),Object.defineProperty(e,"serializeTuple",{enumerable:!0,get:function(){return b.serializeTuple}}),Object.defineProperty(e,"parseTupleItem",{enumerable:!0,get:function(){return b.parseTupleItem}}),Object.defineProperty(e,"serializeTupleItem",{enumerable:!0,get:function(){return b.serializeTupleItem}});var x=fl();Object.defineProperty(e,"TupleReader",{enumerable:!0,get:function(){return x.TupleReader}});var S=pl();Object.defineProperty(e,"TupleBuilder",{enumerable:!0,get:function(){return S.TupleBuilder}}),n(Xl(),e);var C=Zl();Object.defineProperty(e,"openContract",{enumerable:!0,get:function(){return C.openContract}});var ee=Ql();Object.defineProperty(e,"ComputeError",{enumerable:!0,get:function(){return ee.ComputeError}});var w=ml();Object.defineProperty(e,"toNano",{enumerable:!0,get:function(){return w.toNano}}),Object.defineProperty(e,"fromNano",{enumerable:!0,get:function(){return w.fromNano}});var T=Oc();Object.defineProperty(e,"crc16",{enumerable:!0,get:function(){return T.crc16}});var E=il();Object.defineProperty(e,"crc32c",{enumerable:!0,get:function(){return E.crc32c}});var D=jc();Object.defineProperty(e,"base32Decode",{enumerable:!0,get:function(){return D.base32Decode}}),Object.defineProperty(e,"base32Encode",{enumerable:!0,get:function(){return D.base32Encode}});var O=$l();Object.defineProperty(e,"getMethodId",{enumerable:!0,get:function(){return O.getMethodId}});var te=eu();Object.defineProperty(e,"safeSign",{enumerable:!0,get:function(){return te.safeSign}}),Object.defineProperty(e,"safeSignVerify",{enumerable:!0,get:function(){return te.safeSignVerify}})}));k();var nu=tu(),ru=({amount:e,recipient:t,family:n,fees:r,comment:i,payload:a})=>({amount:e.toString(),recipient:t,family:n,fees:r.toString(),comment:i,payload:a?su(a):void 0}),iu=({amount:e,recipient:t,family:n,fees:r,comment:i,payload:a})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),comment:i,payload:a?ou(a):void 0}),au=e=>{try{return nu.Cell.fromBase64(e)}catch{return A.from(e,`hex`)}},ou=e=>{switch(e.type){case`unsafe`:return{type:e.type,message:nu.Cell.fromBase64(e.message)};case`jetton-transfer`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount),destination:nu.Address.parse(e.destination),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?nu.Cell.fromBase64(e.customPayload):null,forwardAmount:BigInt(e.forwardAmount),forwardPayload:e.forwardPayload?nu.Cell.fromBase64(e.forwardPayload):null,knownJetton:e.knownJetton};case`nft-transfer`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,newOwner:nu.Address.parse(e.newOwner),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?nu.Cell.fromBase64(e.customPayload):null,forwardAmount:BigInt(e.forwardAmount),forwardPayload:e.forwardPayload?nu.Cell.fromBase64(e.forwardPayload):null};case`jetton-burn`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount),responseDestination:nu.Address.parse(e.responseDestination),customPayload:e.customPayload?au(e.customPayload):null};case`add-whitelist`:case`single-nominator-change-validator`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,address:nu.Address.parse(e.address)};case`single-nominator-withdraw`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,amount:BigInt(e.amount)};case`tonstakers-deposit`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,appId:e.appId?BigInt(e.appId):null};case`vote-for-proposal`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,votingAddress:nu.Address.parse(e.votingAddress),expirationDate:e.expirationDate,vote:e.vote,needConfirmation:e.needConfirmation};case`change-dns-record`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,record:e.record.type===`wallet`?{type:e.record.type,value:e.record.value?{address:nu.Address.parse(e.record.value.address),capabilities:e.record.value.capabilities}:null}:{type:e.record.type,key:A.from(e.record.key,`hex`),value:e.record.value?nu.Cell.fromBase64(e.record.value):null}};case`token-bridge-pay-swap`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,swapId:A.from(e.swapId,`hex`)};case`tonwhales-pool-deposit`:return{type:e.type,queryId:BigInt(e.queryId),gasLimit:BigInt(e.gasLimit)};case`tonwhales-pool-withdraw`:return{type:e.type,queryId:BigInt(e.queryId),gasLimit:BigInt(e.gasLimit),amount:BigInt(e.amount)};case`vesting-send-msg-comment`:return{type:e.type,queryId:e.queryId?BigInt(e.queryId):null,sendMode:e.sendMode,value:BigInt(e.value),destination:nu.Address.parse(e.destination),text:e.text};case`comment`:return e;default:return e}},su=e=>{switch(e.type){case`unsafe`:return{type:e.type,message:e.message.toBoc().toString(`base64`)};case`jetton-transfer`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString(),destination:e.destination.toRawString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload?e.customPayload.toBoc().toString(`base64`):null,forwardAmount:e.forwardAmount.toString(),forwardPayload:e.forwardPayload?e.forwardPayload.toBoc().toString(`base64`):null,knownJetton:e.knownJetton};case`nft-transfer`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,newOwner:e.newOwner.toRawString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload?e.customPayload.toBoc().toString(`base64`):null,forwardAmount:e.forwardAmount.toString(),forwardPayload:e.forwardPayload?e.forwardPayload.toBoc().toString(`base64`):null};case`jetton-burn`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString(),responseDestination:e.responseDestination.toRawString(),customPayload:e.customPayload&&`toBoc`in e.customPayload?e.customPayload.toBoc().toString(`base64`):e.customPayload?e.customPayload.toString(`hex`):null};case`add-whitelist`:case`single-nominator-change-validator`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,address:e.address.toRawString()};case`single-nominator-withdraw`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,amount:e.amount.toString()};case`tonstakers-deposit`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,appId:typeof e.appId==`bigint`?e.appId.toString():null};case`vote-for-proposal`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,votingAddress:e.votingAddress.toRawString(),expirationDate:e.expirationDate,vote:e.vote,needConfirmation:e.needConfirmation};case`change-dns-record`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,record:e.record.type===`wallet`?{type:e.record.type,value:e.record.value?{address:e.record.value.address.toRawString(),capabilities:e.record.value.capabilities}:null}:{type:e.record.type,key:e.record.key.toString(`hex`),value:e.record.value?e.record.value.toBoc().toString(`base64`):null}};case`token-bridge-pay-swap`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,swapId:e.swapId.toString(`hex`)};case`tonwhales-pool-deposit`:return{type:e.type,queryId:e.queryId.toString(),gasLimit:e.gasLimit.toString()};case`tonwhales-pool-withdraw`:return{type:e.type,queryId:e.queryId.toString(),gasLimit:e.gasLimit.toString(),amount:e.amount.toString()};case`vesting-send-msg-comment`:return{type:e.type,queryId:typeof e.queryId==`bigint`?e.queryId.toString():null,sendMode:e.sendMode,value:e.value.toString(),destination:e.destination.toRawString(),text:e.text};case`comment`:return e;default:return e}},cu=({amount:e,recipient:t,family:n,mode:r,resource:i,duration:a,votes:o})=>({amount:e.toString(),recipient:t,family:n,mode:r,resource:i,duration:a,votes:o}),lu=({amount:e,recipient:t,family:n,mode:r,resource:i,duration:a,votes:o})=>({amount:new P(e),recipient:t,family:n,mode:r,resource:i,duration:a,votes:o});function uu({amount:e,data:t,family:n,fees:r,gasLimit:i,mode:a,recipient:o}){return{family:n,amount:e.toString(),recipient:o,mode:a,fees:r?r.toString():void 0,data:t,gasLimit:i}}function du({amount:e,data:t,family:n,fees:r,gasLimit:i,mode:a,recipient:o}){return{family:n,mode:a,amount:new P(e),recipient:o,fees:r?new P(r):void 0,data:t,gasLimit:i}}function fu({amount:e,family:t,fees:n,memo:r,mode:i,recipient:a}){return{amount:e.toString(),family:t,fees:n?n.toString():void 0,memo:r,mode:i,recipient:a}}function pu({amount:e,family:t,fees:n,memo:r,mode:i,recipient:a}){return{amount:new P(e),family:t,fees:n?new P(n):void 0,memo:r,mode:i,recipient:a}}function mu({amount:e,family:t,model:n,recipient:r,raw:i}){return{amount:e.toString(),family:t,model:JSON.stringify(n),recipient:r,raw:i}}function hu({family:e,amount:t,model:n,recipient:r,raw:i}){return{amount:new P(t),family:e,model:JSON.parse(n),recipient:r,raw:i}}var gu=({amount:e,recipient:t,family:n,estimatedFees:r,body:i})=>({amount:e.toString(),recipient:t,family:n,estimatedFees:r,body:i}),_u=({amount:e,recipient:t,family:n,estimatedFees:r,body:i})=>({amount:new P(e),recipient:t,family:n,estimatedFees:r,body:i}),vu=({amount:e,recipient:t,family:n,fee:r,nonce:i,memo:a,network:o,anchorMode:s})=>({amount:e.toString(),recipient:t,family:n,fee:r?.toString(),nonce:i?.toString(),memo:a,network:o,anchorMode:s}),yu=({amount:e,recipient:t,family:n,fee:r,nonce:i,memo:a,network:o,anchorMode:s})=>({amount:new P(e),recipient:t,family:n,fee:r?new P(r):void 0,nonce:i?new P(i):void 0,memo:a,network:o===`mainnet`?o:`testnet`,anchorMode:s}),bu=({amount:e,recipient:t,family:n,fees:r,memo:i})=>({amount:e.toFixed(),recipient:t,family:n,fees:r.toString(),memo:i}),xu=({amount:e,recipient:t,family:n,fees:r,memo:i})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),memo:i}),Su=({amount:e,recipient:t,family:n,fees:r,transferId:i})=>({amount:e.toFixed(),recipient:t,family:n,fees:r.toString(),transferId:i}),Cu=({amount:e,recipient:t,family:n,fees:r,transferId:i})=>({amount:new P(e),recipient:t,family:n,fees:new P(r),transferId:i});function wu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:e.toString(),recipient:t,family:n,mode:r,fees:i?.toString()}}function Tu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:new P(e),recipient:t,family:n,mode:r,fees:i?new P(i):void 0}}function Eu({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:e.toString(),recipient:t,family:n,mode:r,fees:i.toString()}}function Du({amount:e,recipient:t,family:n,mode:r,fees:i}){return{amount:new P(e),recipient:t,family:n,mode:r,fees:new P(i)}}function Ou(e){switch(e.family){case`ethereum`:return sc(e);case`bitcoin`:return $s(e);case`algorand`:return Ys(e);case`aptos`:return Zs(e);case`crypto_org`:return ac(e);case`ripple`:return xc(e);case`celo`:return tc(e);case`cosmos`:return rc(e);case`hedera`:return dc(e);case`kaspa`:return pc(e);case`filecoin`:return hc(e);case`tezos`:return Tc(e);case`polkadot`:return yc(e);case`stellar`:return Cc(e);case`ton`:return ru(e);case`tron`:return cu(e);case`near`:return lc(e);case`neo`:return _c(e);case`elrond`:return uu(e);case`cardano`:return fu(e);case`solana`:return mu(e);case`vechain`:return gu(e);case`stacks`:return vu(e);case`internet_computer`:return bu(e);case`casper`:return Su(e);case`sui`:return wu(e);case`aleo`:return Eu(e);default:return e}}function ku(e){switch(e.family){case`ethereum`:return cc(e);case`bitcoin`:return ec(e);case`algorand`:return Xs(e);case`aptos`:return Qs(e);case`crypto_org`:return oc(e);case`ripple`:return Sc(e);case`celo`:return nc(e);case`cosmos`:return ic(e);case`hedera`:return fc(e);case`kaspa`:return mc(e);case`filecoin`:return gc(e);case`tezos`:return Ec(e);case`polkadot`:return bc(e);case`stellar`:return wc(e);case`ton`:return iu(e);case`tron`:return lu(e);case`near`:return uc(e);case`neo`:return vc(e);case`elrond`:return du(e);case`cardano`:return pu(e);case`solana`:return hu(e);case`vechain`:return _u(e);case`stacks`:return yu(e);case`internet_computer`:return xu(e);case`casper`:return Cu(e);case`sui`:return Tu(e);case`aleo`:return Du(e);default:return e}}var Au=Y([`send`,`optIn`,`claimReward`,`optOut`]),ju=Z.extend({family:X(Q.enum.algorand),mode:Au,fees:H().optional(),assetId:H().optional(),memo:H().optional()}),Mu=Y([`send`]),Nu=Z.extend({family:X(Q.enum.aptos),mode:Mu,fees:H().optional()}),Pu=Z.extend({family:X(Q.enum.bitcoin),feePerByte:H().optional(),opReturnDataHex:H().max(160).optional(),changeAddress:H().optional()}),Fu=Y([`send`,`lock`,`unlock`,`withdraw`,`vote`,`revoke`,`activate`,`register`]),Iu=Z.extend({family:X(Q.enum.celo),fees:H().optional().nullable(),mode:Fu,index:W().optional().nullable()}),Lu=Y([`send`,`delegate`,`undelegate`,`redelegate`,`claimReward`,`claimRewardCompound`]),Ru=q({address:H(),amount:H()}),zu=Z.extend({family:X(Q.enum.cosmos),mode:Lu,fees:H().optional(),gas:H().optional(),memo:H().optional(),sourceValidator:H().optional(),validators:K(Ru).optional()}),Bu=Z.extend({family:X(Q.enum.crypto_org),mode:H(),fees:H().optional()}),Vu=Z.extend({family:X(Q.enum.ethereum),nonce:W().optional(),data:H().optional(),gasPrice:H().optional(),gasLimit:H().optional(),maxPriorityFeePerGas:H().optional(),maxFeePerGas:H().optional(),sponsored:Zo().optional()}),Hu=Z.extend({family:X(Q.enum.near),mode:H(),fees:H().optional()}),Uu=Z.extend({family:X(Q.enum.neo)}),Wu=Y([`send`,`bond`,`unbond`,`rebond`,`withdrawUnbonded`,`setController`,`nominate`,`chill`,`claimReward`]),Gu=Y([`Staked`,`Stash`,`Controller`,`Account`,`None`]),Ku=Z.extend({family:X(Q.enum.polkadot),mode:Wu,fee:H().optional(),era:W().optional(),validators:K(H()).optional(),rewardDestination:Gu.optional(),numOfSlashingSpans:W().optional()}),qu=Z.extend({family:X(Q.enum.ripple),fee:H().optional(),tag:W()}),Ju=Z.extend({family:X(Q.enum.solana),model:H(),raw:Cs(H())}),Yu=Y([`MEMO_TEXT`,`MEMO_ID`,`MEMO_HASH`,`MEMO_RETURN`]),Xu=Z.extend({family:X(Q.enum.stellar),fees:H().optional(),memoType:Yu.optional(),memoValue:H().optional()}),Zu=Y([`send`,`delegate`,`undelegate`]),Qu=Z.extend({family:X(Q.enum.tezos),mode:Zu,fees:H().optional(),gasLimit:H().optional()}),$u=q({isEncrypted:Zo(),text:H()}),ed=q({type:X(`jetton-transfer`),queryId:J([H(),G()]),amount:H(),destination:H(),responseDestination:H(),customPayload:J([H(),G()]),forwardAmount:H(),forwardPayload:J([H(),G()]),knownJetton:J([q({jettonId:W(),workchain:W()}),G()])}),td=q({type:X(`nft-transfer`),queryId:J([H(),G()]),newOwner:H(),responseDestination:H(),customPayload:J([H(),G()]),forwardAmount:H(),forwardPayload:J([H(),G()])}),nd=J([q({type:X(`comment`),text:H()}),ed,td,q({type:X(`unsafe`),message:H()}),q({type:X(`jetton-burn`),queryId:J([H(),G()]),amount:H(),responseDestination:H(),customPayload:J([H(),G()])}),q({type:X(`add-whitelist`),queryId:J([H(),G()]),address:H()}),q({type:X(`single-nominator-withdraw`),queryId:J([H(),G()]),amount:H()}),q({type:X(`single-nominator-change-validator`),queryId:J([H(),G()]),address:H()}),q({type:X(`tonstakers-deposit`),queryId:J([H(),G()]),appId:J([H(),G()])}),q({type:X(`vote-for-proposal`),queryId:J([H(),G()]),votingAddress:H(),expirationDate:W(),vote:Zo(),needConfirmation:Zo()}),q({type:X(`change-dns-record`),queryId:J([H(),G()]),record:J([q({type:X(`wallet`),value:J([q({address:H(),capabilities:J([q({isWallet:Zo()}),G()])}),G()])}),q({type:X(`unknown`),key:H(),value:J([H(),G()])})])}),q({type:X(`token-bridge-pay-swap`),queryId:J([H(),G()]),swapId:H()}),q({type:X(`tonwhales-pool-deposit`),queryId:H(),gasLimit:H()}),q({type:X(`tonwhales-pool-withdraw`),queryId:H(),gasLimit:H(),amount:H()}),q({type:X(`vesting-send-msg-comment`),queryId:J([H(),G()]),sendMode:W(),value:H(),destination:H(),text:H()})]),rd=Z.extend({family:X(Q.enum.ton),fees:H(),comment:$u,payload:nd.optional()}),id=Y([`send`,`freeze`,`unfreeze`,`vote`,`claimReward`,`withdrawExpireUnfreeze`,`unDelegateResource`,`legacyUnfreeze`]),ad=Y([`BANDWIDTH`,`ENERGY`]),od=q({address:H(),voteCount:W()}),sd=Z.extend({family:X(Q.enum.tron),mode:id,resource:ad.optional(),duration:W().optional(),votes:K(od).default([])}),cd=Z.extend({family:X(Q.enum.hedera),memo:H().max(100).optional()}),ld=Z.extend({family:X(Q.enum.kaspa),customFeeRate:H().optional()}),ud=Z.extend({data:H().optional(),family:X(Q.enum.filecoin),gasLimit:W(),gasFeeCap:H(),gasPremium:H(),method:W(),nonce:W(),params:H().optional(),version:W()});Y([`send`,`delegate`,`reDelegateRewards`,`unDelegate`,`claimRewards`,`withdraw`]);var dd=Z.extend({family:X(Q.enum.elrond),mode:J([X(`send`),X(`delegate`),X(`reDelegateRewards`),X(`unDelegate`),X(`claimRewards`),X(`withdraw`)]),fees:H().optional(),data:H().optional(),gasLimit:W()}),fd=Z.extend({family:X(Q.enum.cardano),fees:H().optional(),mode:H(),memo:H().optional()}),pd=q({to:H().nullable(),value:J([H(),W()]),data:H(),comment:H().optional(),abi:H().optional()}),md=q({chainTag:W(),blockRef:H(),expiration:W(),clauses:K(pd),gasPriceCoef:W().optional(),gas:J([H(),W()]),dependsOn:H().nullable(),nonce:J([H(),W()]),maxFeePerGas:J([H(),W()]).optional(),maxPriorityFeePerGas:J([H(),W()]).optional(),reserved:q({features:W().optional(),unused:K(ns()).optional()}).optional()}),hd=Z.extend({family:X(Q.enum.vechain),estimatedFees:H(),body:md}),gd=Z.extend({family:X(Q.enum.stacks),fee:H().optional(),nonce:H().optional(),memo:H().optional(),network:H(),anchorMode:W()}),_d=Z.extend({family:X(Q.enum.internet_computer),fees:H(),memo:H().optional()}),vd=Z.extend({family:X(Q.enum.casper),fees:H(),transferId:H().optional()}),yd=Z.extend({family:X(Q.enum.sui),mode:H(),fees:H().optional()}),bd=Y([`transfer_public`]),xd=ps(`family`,[ju,Nu,Pu,Iu,zu,Bu,Vu,cd,ld,ud,Hu,Uu,Ku,qu,Xu,Qu,rd,sd,dd,fd,Ju,hd,gd,_d,vd,yd,Z.extend({family:X(Q.enum.aleo),mode:bd,fees:H()})]),Sd=class{prefix=``;constructor(e){this.prefix=e?`[${e}] `:``}log(e,...t){}warn(e,...t){}debug(e,...t){}error(e,...t){}},Cd=new Sd(`WindowMessage`),wd=class{target;logger;_onMessage;constructor(e=window,t=Cd){this.target=e,this.logger=t}connect=()=>{this.target.addEventListener(`message`,this._onMessageEvent,!1),this.target.document?.addEventListener(`message`,this._onMessageEvent,!1),this.logger.debug(`event listeners registered`)};disconnect=()=>{this.target.removeEventListener(`message`,this._onMessageEvent,!1),this.target.document?.removeEventListener(`message`,this._onMessageEvent,!1),this.logger.debug(`event listeners unregistered`)};_onMessageEvent=e=>{if(this._onMessage){if(this.logger.debug(`received message event`,e),e.data&&typeof e.data==`string`)try{let t=e.data;Date.now()>0?(this.logger.log(`received message`,t),this._onMessage(t)):this.logger.debug(`not a wallet API message`)}catch(e){this.logger.warn(`parse error`),e instanceof Error&&this._onMessage(e.message)}else this.logger.debug(`ignoring message same origin`)}else this.logger.debug(`no handler registered`)};set onMessage(e){this._onMessage=e}get onMessage(){return this._onMessage}send=e=>{try{this.target.ReactNativeWebView?(this.logger.log(`sending message (ReactNativeWebview)`,e),this.target.ReactNativeWebView.postMessage(e)):this.target.ElectronWebview?(this.logger.log(`sending message (ElectronWebview)`,e),this.target.ElectronWebview.postMessage(e)):(this.logger.log(`sending message`,e),this.target.top?.postMessage(e,`*`))}catch(e){throw this.logger.error(`unexpected error on send`,e),e}}},Td;(function(e){e.Slow=`slow`,e.Medium=`medium`,e.Fast=`fast`})(Td||={});var Ed;(function(e){e.Blue=`blue`,e.NanoS=`nanoS`,e.NanoX=`nanoX`})(Ed||={});var Dd;(function(e){e[e.SWAP=0]=`SWAP`,e[e.SELL=1]=`SELL`,e[e.FUND=2]=`FUND`})(Dd||={});var Od=Y([`NOT_IMPLEMENTED_BY_WALLET`,`ACCOUNT_NOT_FOUND`,`CURRENCY_NOT_FOUND`,`PERMISSION_DENIED`,`UNKNOWN_ERROR`,`UNAUTHORIZED_STORE`]),kd=q({code:X(Od.enum.NOT_IMPLEMENTED_BY_WALLET),message:H(),data:q({methodId:H()})}),Ad=q({code:X(Od.enum.ACCOUNT_NOT_FOUND),message:H(),data:q({accountId:H()})}),jd=q({code:X(Od.enum.CURRENCY_NOT_FOUND),message:H(),data:q({currencyId:H()})}),Md=q({code:X(Od.enum.PERMISSION_DENIED),message:H(),data:q({methodId:H()})}),Nd=q({name:H().optional(),message:H().optional(),stack:H().optional(),cause:is().optional(),code:H().optional()}),Pd=ps(`code`,[kd,Ad,jd,Md,q({code:X(Od.enum.UNKNOWN_ERROR),message:H(),data:Nd.passthrough()})]);function Fd(e){return{code:`UNKNOWN_ERROR`,message:`an unhandled error was thrown`,data:e}}var Id=class extends Error{errorData;constructor(e){super(e.message),this.errorData=e}getCode(){return this.errorData.code}getData(){return this.errorData}};function Ld(e){if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack},{code:n,cause:r}=e;return typeof n==`string`&&(t.code=n),r!==void 0&&(t.cause=r),t}return typeof e==`string`?{message:e}:typeof e==`object`&&e?e:{}}function Rd(e){if(!e||e.message===void 0&&e.name===void 0)return;let t=Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),e.code!==void 0&&(t.code=e.code),e.cause!==void 0&&(t.cause=e.cause),t}var zd=class extends Error{err;constructor(e){super(e.message),this.err=e}getCode(){return this.err.code}getData(){return this.err.data}},Bd;(function(e){e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.SERVER_ERROR=-32e3]=`SERVER_ERROR`})(Bd||={});var Vd=J([H(),W(),G()]),Hd=q({jsonrpc:X(`2.0`),method:H(),params:ns(),id:Vd.optional()}).strict(),Ud=q({code:W(),message:H(),data:ns().optional()}).strict(),Wd=q({jsonrpc:X(`2.0`),id:Vd,result:q({}).passthrough().optional()}).strict(),Gd=J([Hd,J([q({jsonrpc:X(`2.0`),id:Vd,error:Ud}).strict(),Wd])]);function Kd(e){try{let t=JSON.parse(e);return Gd.parse(t)}catch(e){throw e instanceof SyntaxError?new zd({code:Bd.PARSE_ERROR,message:`parse error`}):e instanceof lo?new zd({code:Bd.INVALID_REQUEST,message:`invalid request`}):e}}function qd(e){return{jsonrpc:`2.0`,...e}}var Jd=class{transport;requestHandlers;ongoingRequests={};constructor(e,t){this.transport=e,this.requestHandlers=t,this.transport.onMessage=e=>{this.handleMessage(e)}}_request(e){return new Promise((t,n)=>{if(!e.id){n(Error(`requests need to have an id`));return}let r=e=>{if(`error`in e){if(e.error.code===Bd.SERVER_ERROR){let t=Pd.parse(e.error.data);if(t.code===`UNKNOWN_ERROR`){n(Rd(t.data));return}n(new Id(t));return}n(new zd(e.error));return}t(e.result)};this.ongoingRequests[e.id]=r,this.transport.send(JSON.stringify(e))})}_notify(e){this.transport.send(JSON.stringify(e))}request(e,t){let n=crypto.randomUUID();return this._request({id:n,jsonrpc:`2.0`,method:e,params:t})}notify(e,t){return this._notify({jsonrpc:`2.0`,method:e,params:t})}async handleRpcRequest(e){try{let t=await this.onRequest(e);if(e.id){let n=qd({id:e.id,result:t});this.transport.send(JSON.stringify(n))}}catch(e){throw e instanceof lo?new zd({code:Bd.INVALID_PARAMS,message:e.message,data:e.flatten()}):e instanceof Id?new zd({code:Bd.SERVER_ERROR,message:`unexpected server error`,data:e.getData()}):e instanceof zd?e:new zd({code:Bd.SERVER_ERROR,message:`unexpected server error`,data:Fd(Ld(e))})}}async handleMessage(e){let t=!1,n;try{let r=Kd(e);n=r.id,`method`in r?await this.handleRpcRequest(r):(t=!0,this.handleRpcResponse(r))}catch(e){if(t)throw e;if(e instanceof zd){let t=qd({id:n??null,error:{code:e.getCode(),message:e.message,data:e.getData()}});this.transport.send(JSON.stringify(t));return}throw e}}handleRpcResponse(e){if(!e.id)return;let t=this.ongoingRequests[e.id];if(!t)throw Error(`no ongoingRequest ${e.id}`);t(e)}},Yd={params:q({accountId:H()}),result:q({maxSpendable:H().regex(/^(0|[1-9]\d*)$/)})},Xd={params:q({accountId:H(),derivationPath:H().optional()}),result:q({publicKey:H()})},Zd={params:q({currencyIds:K(H()).optional()}).optional(),result:q({rawAccounts:K(Ws)})},Qd={params:q({accountId:H(),tokenCurrency:H().optional()}),result:q({address:H()})},$d={params:q({currencyIds:K(H()).optional(),showAccountFilter:Zo().optional(),drawerConfiguration:q({assets:q({filter:H().optional(),leftElement:H().optional(),rightElement:H().optional()}).optional(),networks:q({leftElement:H().optional(),rightElement:H().optional()}).optional()}).optional(),useCase:H().optional(),uiUseCase:H().optional()}),result:q({rawAccount:Ws})},ef={params:q({accountId:H(),derivationPath:H().optional()}),result:q({address:H()})},tf={params:q({accountId:H(),intentions:K(Y([`payment`,`ordinal`])).optional()}),result:q({addresses:K(q({address:H(),publicKey:H().optional(),path:H().optional(),intention:H().optional()}))})},nf={params:q({accountId:H(),derivationPath:H().optional()}),result:q({publicKey:H()})},rf={params:q({accountId:H()}),result:q({xPub:H()})},af={params:q({accountId:H(),psbt:H(),broadcast:Zo().optional()}),result:q({psbtSigned:H(),txHash:H().optional()})},of={params:q({currencyIds:K(H()).optional()}).optional(),result:q({currencies:K(Js)})},sf=Y([`blue`,`nanoS`,`nanoSP`,`nanoX`,`stax`,`europa`,`apex`]),cf={params:q({transportId:H()}),result:q({transportId:H()})},lf={params:q({apduHex:H(),transportId:H()}),result:q({responseHex:H()})},uf={params:q({deviceId:H()}),result:q({transportId:H()})},df={params:q({appName:H().optional(),allowManager:Zo().optional(),appVersionRange:H().optional(),firmwareVersionRange:H().optional(),seeded:Zo().optional(),devices:sf.array().nonempty().optional()}),result:q({deviceId:H()})},ff={params:q({appName:H().optional(),allowManager:Zo().optional(),appVersionRange:H().optional(),firmwareVersionRange:H().optional(),seeded:Zo().optional(),devices:sf.array().nonempty().optional()}),result:q({transportId:H()})},pf=Y([`SLOW`,`MEDIUM`,`FAST`,`CUSTOM`]),mf=q({provider:H(),fromAccountId:H(),rawTransaction:xd,hexBinaryPayload:H(),hexSignature:H(),feeStrategy:pf,tokenCurrency:H().optional()}),hf={params:ps(`exchangeType`,[mf.extend({exchangeType:X(`FUND`)}),mf.extend({exchangeType:X(`SELL`)}),mf.extend({exchangeType:X(`SWAP`),toAccountId:H(),swapId:H(),rate:W()})]),result:q({transactionHash:H()})},gf={params:q({exchangeType:Y([`SWAP`,`SELL`,`FUND`,`SWAP_NG`,`SELL_NG`,`FUND_NG`])}),result:q({transactionId:H()})},_f=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),vf={params:q({accountId:H(),hexMessage:H(),options:_f.optional(),meta:_s(H(),is()).optional()}),result:q({hexSignedMessage:H()})},yf={params:q({key:H().min(1),storeId:H().min(1).optional()}),result:q({value:H().optional()})},bf={params:q({key:H(),value:H(),storeId:H().optional()}),result:cs().optional()},xf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),Sf={params:q({accountId:H(),rawTransaction:xd,options:xf.optional(),meta:_s(H(),is()).optional(),tokenCurrency:H().optional()}),result:q({signedTransactionHex:H()})},Cf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),wf={params:q({accountId:H(),rawTransaction:xd,options:Cf.optional(),meta:_s(H(),is()).optional(),tokenCurrency:H().optional()}),result:q({transactionHash:H()})},Tf=q({hwAppId:H().optional(),dependencies:K(H()).optional()}),Ef={params:q({accountId:H(),rawTransaction:H(),broadcast:Zo().optional(),options:Tf.optional(),meta:_s(H(),is()).optional()}),result:q({signedTransactionHex:H(),transactionHash:H().optional()})},Df={params:q({}),result:q({methodIds:K(H())})},Of={params:q({}),result:q({tracking:Zo(),wallet:q({name:H(),version:H()})})},kf={params:q({}),result:q({userId:H()})};Y([`account.getMaxSpendable`,`account.getPublicKey`,`account.list`,`account.receive`,`account.request`,`currency.list`,`device.close`,`device.exchange`,`device.transport`,`message.sign`,`transaction.sign`,`transaction.signRaw`,`transaction.signAndBroadcast`,`wallet.capabilities`,`wallet.info`,`wallet.userId`]);var Af;(function(e){e.Unknown=`Unknown`,e.LocationServicesDisabled=`LocationServicesDisabled`,e.LocationServicesUnauthorized=`LocationServicesUnauthorized`,e.BluetoothScanStartFailed=`BluetoothScanStartFailed`})(Af||={});var jf=class extends Error{id;constructor(e,t){let n=`TransportError`;super(e||n),this.name=n,this.message=e,this.stack=Error(e).stack,this.id=t}},Mf={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CLA_NOT_SUPPORTED_BOOTLOADER:28161,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,SW_BAD_STATE:45063};function Nf(e){switch(e){case 26368:return`Incorrect length`;case 26624:return`Missing critical parameter`;case 27010:return`Security not satisfied (dongle locked or have invalid access rights)`;case 27013:return`Condition of use not satisfied (denied by the user?)`;case 27264:return`Invalid data received`;case 27392:return`Invalid parameter received`;case 21781:return`Locked device`;case 45063:return`Unexpected state on the device`}if(28416<=e&&e<=28671)return`Internal error, please report`}var Pf=class e extends Error{statusCode;statusText;constructor(t,{canBeMappedToChildError:n=!0}={}){let r=Object.entries(Mf).find(([,e])=>e===t)?.[0]||`UNKNOWN_ERROR`,i=`Ledger device: ${Nf(t)||r} (0x${t.toString(16)})`;if(super(i||`TransportStatusError`),this.name=`TransportStatusError`,this.statusCode=t,this.statusText=r,Object.setPrototypeOf(this,e.prototype),n&&t===Mf.LOCKED_DEVICE)return new Ff(i)}},Ff=class e extends Pf{constructor(t){super(Mf.LOCKED_DEVICE,{canBeMappedToChildError:!1}),t&&(this.message=t),this.name=`LockedDeviceError`,Object.setPrototypeOf(this,e.prototype)}},If=class extends Error{name=`TransportRaceCondition`;constructor(e){super(e||`TransportRaceCondition`)}};k();var Lf=`transport`,Rf=class{exchangeTimeout=3e4;unresponsiveTimeout=15e3;deviceModel=null;tracer;constructor({context:e,logType:t}={}){this.tracer=new Oe(t??Lf,e)}static isSupported;static list;static listen;static open;exchange(e,{abortTimeoutMs:t}={}){throw Error(`exchange not implemented`)}exchangeBulk(e,t){let n=!1;return(async()=>{if(!n)for(let r of e){let e=await this.exchange(r);if(n)return;let i=e.readUInt16BE(e.length-2);if(i!==Mf.OK)throw new Pf(i);t.next(e)}})().then(()=>!n&&t.complete(),e=>!n&&t.error(e)),{unsubscribe:()=>{n=!0}}}setScrambleKey(e){}close(){return Promise.resolve()}_events=new we.default;on(e,t){this._events.on(e,t)}off(e,t){this._events.removeListener(e,t)}emit(e,...t){this._events.emit(e,...t)}setDebugMode(){}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}send=async(e,t,n,r,i=A.alloc(0),a=[Mf.OK],{abortTimeoutMs:o}={})=>{let s=this.tracer.withUpdatedContext({function:`send`});if(i.length>=256)throw s.trace(`data.length exceeded 256 bytes limit`,{dataLength:i.length}),new jf(`data.length exceed 256 bytes limit. Got: `+i.length,`DataLengthTooBig`);let c=await this.exchange(A.concat([A.from([e,t,n,r]),A.from([i.length]),i]),{abortTimeoutMs:o}),l=c.readUInt16BE(c.length-2);if(!a.some(e=>e===l))throw new Pf(l);return c};static create(e=3e3,t){return new Promise((n,r)=>{let i=!1,a=this.listen({next:t=>{i=!0,a&&a.unsubscribe(),o&&clearTimeout(o),this.open(t.descriptor,e).then(n,r)},error:e=>{o&&clearTimeout(o),r(e)},complete:()=>{o&&clearTimeout(o),i||r(new jf(this.ErrorMessage_NoDeviceFound,`NoDeviceFound`))}}),o=t?setTimeout(()=>{a.unsubscribe(),r(new jf(this.ErrorMessage_ListenTimeout,`ListenTimeout`))},t):null})}exchangeBusyPromise;async exchangeAtomicImpl(e){let t=this.tracer.withUpdatedContext({function:`exchangeAtomicImpl`,unresponsiveTimeout:this.unresponsiveTimeout});if(this.exchangeBusyPromise)throw t.trace(`Atomic exchange is already busy`),new If(`An action was already pending on the Ledger device. Please deny or reconnect.`);let n,r=new Promise(e=>{n=e});this.exchangeBusyPromise=r;let i=!1,a=setTimeout(()=>{t.trace(`Timeout reached, emitting Transport event "unresponsive"`,{unresponsiveTimeout:this.unresponsiveTimeout}),i=!0,this.emit(`unresponsive`)},this.unresponsiveTimeout);try{let n=await e();return i&&(t.trace(`Device was unresponsive, emitting responsive`),this.emit(`responsive`)),n}finally{t.trace(`Finalize, clearing busy guard`),clearTimeout(a),n&&n(),this.exchangeBusyPromise=null}}decorateAppAPIMethods(e,t,n){for(let r of t)e[r]=this.decorateAppAPIMethod(r,e[r],e,n)}_appAPIlock=null;decorateAppAPIMethod(e,t,n,r){return async(...i)=>{let{_appAPIlock:a}=this;if(a)return Promise.reject(new jf(`Ledger Device is busy (lock `+a+`)`,`TransportLocked`));try{return this._appAPIlock=e,this.setScrambleKey(r),await t.apply(n,i)}finally{this._appAPIlock=null}}}setTraceContext(e){this.tracer=this.tracer.withContext(e)}updateTraceContext(e){this.tracer.updateContext(e)}getTraceContext(){return this.tracer.getContext()}static ErrorMessage_ListenTimeout=`No Ledger device found (timeout)`;static ErrorMessage_NoDeviceFound=`No Ledger device found`};k();var zf=class e extends Rf{walletApi;transportId;constructor(e,t){super(),this.transportId=t,this.walletApi=e}static isSupported=()=>Promise.resolve(!0);static list=()=>Promise.resolve([]);static listen=e=>({unsubscribe:()=>{}});static open({walletApi:t,transportId:n}){return Promise.resolve(new e(t,n))}async exchange(e){let t=e.toString(`hex`),n=await this.walletApi.request(`device.exchange`,{transportId:this.transportId,apduHex:t}),r=lf.result.parse(n);return A.from(r.responseHex,`hex`)}setScrambleKey(){}async close(){let e=await this.walletApi.request(`device.close`,{transportId:this.transportId});cf.result.parse(e)}},Bf=class{client;constructor(e){this.client=e}async list(e){let t=await this.client.request(`account.list`,{currencyIds:e?.currencyIds});return Zd.result.parse(t).rawAccounts.map(qe)}async request(e){let t=await this.client.request(`account.request`,{currencyIds:e?.currencyIds,showAccountFilter:e?.showAccountFilter,drawerConfiguration:e?.drawerConfiguration,useCase:e?.useCase,uiUseCase:e?.uiUseCase});return qe($d.result.parse(t).rawAccount)}async receive(e){let t=await this.client.request(`account.receive`,{accountId:e});return Qd.result.parse(t).address}async getPublicKey(e,t){let n=await this.client.request(`account.getPublicKey`,{accountId:e,derivationPath:t});return Xd.result.parse(n).publicKey}async getMaxSpendable(e){let t=await this.client.request(`account.getMaxSpendable`,{accountId:e});return new P(Yd.result.parse(t).maxSpendable)}},Vf=class{client;constructor(e){this.client=e}async getAddress(e,t){let n=await this.client.request(`bitcoin.getAddress`,{accountId:e,derivationPath:t});return ef.result.parse(n).address}async getAddresses(e,t){let n=await this.client.request(`bitcoin.getAddresses`,{accountId:e,intentions:t});return tf.result.parse(n).addresses}async getPublicKey(e,t){let n=await this.client.request(`bitcoin.getPublicKey`,{accountId:e,derivationPath:t});return nf.result.parse(n).publicKey}async getXPub(e){let t=await this.client.request(`bitcoin.getXPub`,{accountId:e});return rf.result.parse(t).xPub}async signPsbt(e,t,n){let r=await this.client.request(`bitcoin.signPsbt`,{accountId:e,psbt:t,broadcast:n}),{psbtSigned:i,txHash:a}=af.result.parse(r);return{psbtSigned:i,txHash:a}}},Hf=class{client;constructor(e){this.client=e}async list(e){let t=await this.client.request(`currency.list`,{currencyIds:e?.currencyIds});return of.result.parse(t).currencies}},Uf=class{client;constructor(e){this.client=e}async transport(e){let t=await this.client.request(`device.transport`,e),n=ff.result.parse(t);return zf.open({walletApi:this.client,transportId:n.transportId})}async open(e){let t=await this.client.request(`device.open`,e),n=uf.result.parse(t);return zf.open({walletApi:this.client,transportId:n.transportId})}async select(e){let t=await this.client.request(`device.select`,e);return df.result.parse(t)}},Wf=class{client;constructor(e){this.client=e}async start(e){let t=await this.client.request(`exchange.start`,{exchangeType:e});return gf.result.parse(t).transactionId}async completeSwap({provider:e,fromAccountId:t,toAccountId:n,swapId:r,rate:i,transaction:a,binaryPayload:o,signature:s,feeStrategy:c,tokenCurrency:l}){let u=await this.client.request(`exchange.complete`,{exchangeType:`SWAP`,provider:e,fromAccountId:t,toAccountId:n,swapId:r,rate:i,rawTransaction:Ou(a),hexBinaryPayload:o.toString(`hex`),hexSignature:s.toString(`hex`),feeStrategy:c,tokenCurrency:l});return hf.result.parse(u).transactionHash}async completeSell({provider:e,fromAccountId:t,transaction:n,binaryPayload:r,signature:i,feeStrategy:a}){let o=await this.client.request(`exchange.complete`,{exchangeType:`SELL`,provider:e,fromAccountId:t,rawTransaction:Ou(n),hexBinaryPayload:r.toString(`hex`),hexSignature:i.toString(`hex`),feeStrategy:a});return hf.result.parse(o).transactionHash}async completeFund({provider:e,fromAccountId:t,transaction:n,binaryPayload:r,signature:i,feeStrategy:a,tokenCurrency:o}){let s=await this.client.request(`exchange.complete`,{exchangeType:`FUND`,provider:e,fromAccountId:t,rawTransaction:Ou(n),hexBinaryPayload:r.toString(`hex`),hexSignature:i.toString(`hex`),feeStrategy:a,tokenCurrency:o});return hf.result.parse(s).transactionHash}};k();var Gf=class{client;constructor(e){this.client=e}async sign(e,t,n,r){let i=await this.client.request(`message.sign`,{accountId:e,hexMessage:t.toString(`hex`),options:n,meta:r}),a=vf.result.parse(i);return A.from(a.hexSignedMessage,`hex`)}},Kf=class{client;constructor(e){this.client=e}async get(e,t){let n=await this.client.request(`storage.get`,{key:e,storeId:t});return yf.result.parse(n).value}async set(e,t,n){let r=await this.client.request(`storage.set`,{key:e,value:t,storeId:n});return bf.result.parse(r)}};k();var qf=class{client;constructor(e){this.client=e}async sign(e,t,n,r){let i=await this.client.request(`transaction.sign`,{accountId:e,rawTransaction:Ou(t),options:n,meta:r}),a=Sf.result.parse(i);return A.from(a.signedTransactionHex,`hex`)}async signRaw(e,t,n,r,i){let a=await this.client.request(`transaction.signRaw`,{accountId:e,rawTransaction:t,broadcast:n,options:r,meta:i});return Ef.result.parse(a)}async signAndBroadcast(e,t,n,r){let i=await this.client.request(`transaction.signAndBroadcast`,{accountId:e,rawTransaction:Ou(t),options:n,meta:r});return wf.result.parse(i).transactionHash}},Jf=class{client;constructor(e){this.client=e}async userId(){let e=await this.client.request(`wallet.userId`,{});return kf.result.parse(e).userId}async info(){let e=await this.client.request(`wallet.info`,{});return Of.result.parse(e)}async capabilities(){let e=await this.client.request(`wallet.capabilities`,{});return Df.result.parse(e).methodIds}},Yf=new Sd(`Wallet-API-Client`),Xf={"event.account.updated":e=>Promise.resolve()},Zf=class extends Jd{account;bitcoin;currency;device;message;storage;transaction;wallet;exchange;custom;logger;constructor(e,t=Yf,n,r={}){super(e,{...Xf,...r}),this.logger=t,this.account=new Bf(this),this.bitcoin=new Vf(this),this.currency=new Hf(this),this.device=new Uf(this),this.message=new Gf(this),this.storage=new Kf(this),this.transaction=new qf(this),this.wallet=new Jf(this),this.exchange=new Wf(this),this.custom=n?n(this):{}}setEventHandlers(e){this.requestHandlers={...Xf,...e}}onRequest(e){this.logger.log(e.method);let t=this.requestHandlers[e.method];if(!t)throw new zd({code:Bd.METHOD_NOT_FOUND,message:`method not found`});return t(e)}},Qf={near:{"*":{currencyId:`near`,family:`near`,network:`near`}},tezos:{"*":{currencyId:`tezos`,family:`tezos`,network:`tezos`}},solana:{"*":{currencyId:`solana`,family:`solana`,network:`solana`}},tron:{"*":{currencyId:`tron`,family:`tron`,network:`tron`}},ton:{"*":{currencyId:`ton`,family:`ton`,network:`ton`}},polkadot:{"*":{currencyId:`assethub_polkadot`,family:`polkadot`,network:`polkadot`}},celo:{"*":{currencyId:`celo`,family:`celo`,network:`celo`}},ethereum:{ethereum:{currencyId:`ethereum`,family:`ethereum`,network:`ethereum`},polygon:{currencyId:`polygon`,family:`ethereum`,network:`polygon`},arbitrum:{currencyId:`arbitrum`,family:`ethereum`,network:`arbitrum`},optimism:{currencyId:`optimism`,family:`ethereum`,network:`optimism`},avalanche_c_chain:{currencyId:`avalanche_c_chain`,family:`ethereum`,network:`avalanche-c`},ethereum_hoodi:{currencyId:`ethereum_hoodi`,family:`ethereum`,network:`ethereum-hoodi`},bsc:{currencyId:`bsc`,family:`ethereum`,network:`binance`}},cosmos:{cosmos:{currencyId:`cosmos`,family:`cosmos`,network:`cosmos`},crypto_org:{currencyId:`crypto_org`,family:`cosmos`,network:`cronos`},osmo:{currencyId:`osmo`,family:`cosmos`,network:`osmosis`},coreum:{currencyId:`coreum`,family:`cosmos`,network:`coreum`},axelar:{currencyId:`axelar`,family:`cosmos`,network:`axelar`},stargaze:{currencyId:`stargaze`,family:`cosmos`,network:`stargaze`},secret_network:{currencyId:`secret_network`,family:`cosmos`,network:`secret`},umee:{currencyId:`umee`,family:`cosmos`,network:`umee`},desmos:{currencyId:`desmos`,family:`cosmos`,network:`desmos`},onomy:{currencyId:`onomy`,family:`cosmos`,network:`onomy`},quicksilver:{currencyId:`quicksilver`,family:`cosmos`,network:`quicksilver`},persistence:{currencyId:`persistence`,family:`cosmos`,network:`persistence`},dydx:{currencyId:`dydx`,family:`cosmos`,network:`dydx`},injective:{currencyId:`injective`,family:`cosmos`,network:`injective`},sei:{currencyId:`sei`,family:`cosmos`,network:`sei`},mantra:{currencyId:`mantra`,family:`cosmos`,network:`mantra`}}},$f=new Map([[`polkadot`,1],[`avalanche-c`,2],[`tron`,3],[`binance`,4],[`cronos`,5],[`polygon`,6]]);k();var ep=be(),tp=u(c({amount:y(u(p)),gasLimit:y(u(p)),token:y(u(c({decimals:m})))})),np=_(tp),rp=_(l),ip=new Set([`polygon`,`optimism`,`arbitrum`,`avalanche-c`,`core`]),ap=class extends f()(`LedgerTransactionPreparationError`,{message:p}){},op=e=>new ap({message:e}),sp=ee(function*(){let e=yield*C(w({try:()=>ie(()=>import(`./polkadot-ledger-transaction-36Qv7Wb4.js`).then(e=>e.buildPolkadotLedgerTransaction),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])),catch:()=>op(`Could not load Polkadot transaction support`)}));return({family:t,network:n,tx:r,txMeta:i})=>d(rp)(r).pipe(b(()=>op(`Failed to parse tx`)),E(r=>n===`polkadot`?i?cp({loadPolkadotBuilder:e,payload:r,txMeta:i}):S(op(`Missing classic transaction metadata`)):T(lp({family:t,network:n,payload:r,txMeta:i})).pipe(b(op))))}),cp=({loadPolkadotBuilder:e,payload:t,txMeta:n})=>T(ce(de,t)).pipe(b(op),E(t=>e.pipe(E(e=>T(e({fee:vp(gp(n.gasEstimate)).toString(),payload:t,txMeta:n})).pipe(b(op)))))),lp=({family:e,network:t,payload:i,txMeta:s})=>{if(he(t))return ce(le,i).pipe(n(e=>up({network:t,tx:e})));if(e===`borrow`)return o(`Unsupported Borrow network`);if(!s)return o(`Missing classic transaction metadata`);switch(t){case`tron`:return ce(Se,i).pipe(a(()=>fp(s)));case`near`:return pp(s);case`tezos`:return mp(s);case`ton`:return ce(xe,i).pipe(a(e=>hp(e,s)));default:return me(t)?dp(s):r(i)}},up=({network:e,tx:t})=>{let n={amount:(t.value??0n).toString(),recipient:t.to,family:`ethereum`,gasLimit:t.gasLimit.toString(),data:A.from(ge(t.data)).toString(`hex`)};return t.maxFeePerGas&&t.maxPriorityFeePerGas&&!ip.has(e)?(n.maxFeePerGas=t.maxFeePerGas.toString(),n.maxPriorityFeePerGas=t.maxPriorityFeePerGas.toString()):t.gasPrice&&(n.gasPrice=t.gasPrice.toString()),n},dp=e=>{let t=e.rawArguments?.validatorAddress,n=yp(e.txType),i=_p(e)??(bp(n)?oe():null);return!t||i===null?o(`Missing Cosmos Ledger arguments`):r({family:`cosmos`,mode:n,validators:[{address:t,amount:i.toString()}],amount:i.toString(),recipient:t,memo:`via StakeKit CID-1009`})},fp=e=>{let t=_p(e),i=e.rawArguments?.tronResource,a=e.rawArguments?.validatorAddress??e.rawArguments?.validatorAddresses?.[0],s=e.address;return(()=>{switch(e.txType){case`FREEZE_BANDWIDTH`:case`FREEZE_ENERGY`:return!t||!i?o(`Missing Tron freeze arguments`):r({amount:t.toString(),recipient:s,family:`tron`,mode:`freeze`,resource:i});case`VOTE`:{let r=e.rawArguments?.validatorAddresses;return!t||!r?.length?o(`Missing Tron vote arguments`):Cp({txMeta:e,validatorAddresses:r}).pipe(n(e=>({amount:t.toString(),recipient:s,family:`tron`,mode:`vote`,votes:e})))}case`UNDELEGATE_BANDWIDTH`:case`UNDELEGATE_ENERGY`:return!t||!i||!a?o(`Missing Tron undelegate arguments`):r({amount:t.toString(),recipient:String(a),family:`tron`,mode:`unDelegateResource`,resource:i});case`UNFREEZE_LEGACY_BANDWIDTH`:case`UNFREEZE_LEGACY_ENERGY`:return r({amount:`0`,recipient:``,family:`tron`,mode:`legacyUnfreeze`,resource:i});case`UNFREEZE_BANDWIDTH`:case`UNFREEZE_ENERGY`:return!t||!i?o(`Missing Tron unfreeze arguments`):r({amount:t.toString(),recipient:s,family:`tron`,mode:`unfreeze`,resource:i});case`CLAIM_REWARDS`:return r({amount:`0`,recipient:s,family:`tron`,mode:`claimReward`});default:return o(`Unsupported Tron Ledger transaction type: ${e.txType}`)}})().pipe(n(e=>({...e,votes:e.votes??[]})))},pp=e=>{let t=e.rawArguments?.validatorAddress,n=_p(e);return!t||!n?o(`Missing Near Ledger arguments`):r({amount:n.toString(),recipient:t,family:`near`,mode:xp(e.txType),fees:vp(gp(e.gasEstimate)).toString()})},mp=e=>{let t=gp(e.gasEstimate),n=e.txType===`UNSTAKE`,i=n?``:e.rawArguments?.validatorAddress;return!n&&!i?o(`Missing Tezos Ledger validator`):r({family:`tezos`,mode:n?`undelegate`:`delegate`,amount:`0`,recipient:i??``,fees:vp(t).toString(),gasLimit:String(t?.gasLimit??0)})},hp=(e,t)=>{let n=gp(t.gasEstimate);if(!(`message`in e)){let t=e[0];return t?r({family:`ton`,amount:t.amount,recipient:t.address,fees:vp(n).toString(),comment:{text:t.payload,isEncrypted:!1}}):o(`Unsupported Ton Ledger transaction payload`)}try{let t=(0,ep.loadMessageRelaxed)(ep.Cell.fromBase64(e.message).beginParse()),i=t.info;return r({family:`ton`,amount:i.value.coins.toString(),recipient:i.dest.toString(),fees:vp(n).toString(),comment:{text:t.body.toBoc().toString(`base64`),isEncrypted:!1}})}catch{return o(`Unsupported Ton Ledger transaction payload`)}},gp=e=>e?h(np)(e).pipe(s):null,_p=e=>{if(e.amountRaw)return pe(e.amountRaw);let t=e.rawArguments?.amount??e.amount,n=e.inputToken?.decimals;return!t||n===void 0?null:pe(t).multipliedBy(pe(10).pow(n))},vp=e=>!e?.amount||!e.token?oe():pe(e.amount).multipliedBy(pe(10).pow(e.token.decimals)),yp=e=>{switch(e){case`STAKE`:return`delegate`;case`UNSTAKE`:return`undelegate`;case`RESTAKE`:case`REBOND`:return`redelegate`;case`RESTAKE_REWARDS`:return`claimRewardCompound`;case`CLAIM_REWARDS`:return`claimReward`;default:return`delegate`}},bp=e=>e===`claimReward`||e===`claimRewardCompound`,xp=e=>{switch(e){case`STAKE`:return`stake`;case`UNSTAKE`:return`unstake`;case`WITHDRAW`:case`CLAIM_UNSTAKED`:return`withdraw`;default:return`stake`}},Sp=e=>{let t=e.rawArguments?.amount??e.amount;if(t)return pe(t);let n=e.inputToken?.decimals;return!e.amountRaw||n===void 0?null:pe(e.amountRaw).dividedBy(pe(10).pow(n))},Cp=({txMeta:e,validatorAddresses:t})=>{let n=Sp(e);if(!n)return o(`Missing Tron vote arguments`);let i=t.length,a=n.dividedToIntegerBy(i),s=n.modulo(i).integerValue(fe.ROUND_FLOOR);if(!a.isFinite()||!s.isFinite()||a.isNegative()||s.isNegative())return o(`Invalid Tron vote count`);if(a.plus(1).gt(2**53-1))return o(`Tron vote count exceeds Ledger limits`);let c=ae(s);if(c==null)return o(`Invalid Tron vote count`);let l=t.map((e,t)=>{let n=ae(a.plus(+(t<c)));return n==null?null:{address:e,voteCount:n}});return l.some(e=>e==null)?o(`Invalid Tron vote count`):r(l.filter(e=>e!=null))},wp=({accounts:e,ledgerCurrencies:t,enabledChainsMap:n})=>{let{accountsFamilies:r,accountsCurrencies:i}=e.reduce((e,n)=>{let r=t.get(n.currency);return r&&(e.accountsFamilies.add(r),e.accountsCurrencies.add(n.currency)),e},{accountsFamilies:new Set,accountsCurrencies:new Set}),a=v(Qf).reduce((e,[t,a])=>{let o=Object.keys(a).reduce((e,t)=>{let o=a[t];if(!o)return e;let s=n.evm[o.network]?.wagmiChain||n.cosmos[o.network]?.wagmiChain||n.misc[o.network]?.wagmiChain||n.substrate[o.network]?.wagmiChain;return s?r.has(o.family)&&(t===`*`||i.has(o.currencyId))?{...e,[t]:{...o,chain:s,enabled:!0}}:$f.has(o.network)?{...e,[t]:{...o,chain:s,enabled:!1}}:e:e},{});return{...e,[t]:o}},{});return Object.keys(a).reduce((e,t)=>{let n=a[t],r=Object.keys(n).reduce((e,t)=>{let r=n[t];return r&&e.set(t,r),e},new Map);return e.set(t,r),e},new Map)},Tp=e=>w({try:()=>e.currency.list({currencyIds:Object.values(Qf).flatMap(e=>Object.values(e).map(e=>e.currencyId))}),catch:e=>new te({cause:e,message:`could not get currencies`,operation:`ledger-list-currencies`})}).pipe(re(e=>e.reduce((e,t)=>(t.type===`CryptoCurrency`?e.cryptoCurrency.set(t.id,t.family):e.tokenCurrency.push(t),e),{cryptoCurrency:new Map,tokenCurrency:[]})),re(e=>(e.tokenCurrency.forEach(t=>{let n=e.cryptoCurrency.get(t.parent);n&&e.cryptoCurrency.set(t.id,n)}),e.cryptoCurrency))),Ep=({walletDetailsParams:e,enabledChainsMap:t,isLedgerDappBrowser:n,prepareTransaction:a,queryParams:s,runWalletEffect:c})=>O(l=>{let u=ve([]),d=ve([]),f=ve(void 0),p=f.changes.pipe(x(e=>e?.parentAccountId??e?.id)),m=[],h=ve([]),g=null,_=null,v=null,y=new wd;y.connect();let b=new Zf(y),S=async e=>{l.emitter.emit(`message`,{type:`connecting`});let n=await c(Tp(b)),r=await c(w({try:()=>b.account.list(),catch:e=>new te({cause:e,message:`could not get accounts`,operation:`ledger-list-accounts`})}).pipe(re(e=>({accounts:e,accountsMap:new Map(e.map(e=>[e.id,e]))})),re(e=>e.accounts.map(t=>t.parentAccountId?(()=>{let n=e.accountsMap.get(t.parentAccountId);return n?{...t,currency:n.currency}:t})():t))));m=r.filter(e=>!e.parentAccountId);let a=wp({ledgerCurrencies:n,accounts:m,enabledChainsMap:t});_=new Map([...a.values()].flatMap(e=>[...e.values()].map(e=>[e.chain.id,e.currencyId]))),v=a;let{enabled:o,disabled:p}=[...a.values()].reduce((e,t)=>(t.forEach(t=>{t.enabled?e.enabled.push(t.chain):e.disabled.push(t.chain)}),e),{enabled:[],disabled:[]});u.set([...o,...p]),d.set(p);let y=r.reduce((e,t)=>{let r=n.get(t.currency);if(!r)return e;let i=a.get(r);if(!r||!i)return e;let o=i.get(`*`)||i.get(t.currency);return o&&e.push({account:t,chainItem:o}),e},[]).sort((e,t)=>($f.get(e.chainItem.network)||999)-($f.get(t.chainItem.network)||999));if(!y.length){let t=a.get(`ethereum`)?.get(`ethereum`);if(!t)throw Error(`Default chain not found`);return h.set([]),g=t,T([`N/A`]),E(t.chain.id.toString()),ne(e?.withCapabilities,[`N/A`],t.chain.id)}let x=s.accountId?s.accountId.startsWith(`js:`)?{type:`address`,address:s.accountId.split(`:`)[3]}:{type:`accountId`,accountId:s.accountId}:null,S=(x?y.find(e=>x.type===`address`?e.account.address===x.address:e.account.id===x.accountId):void 0)??(s.network?y.find(e=>e.chainItem.network===s.network):void 0)??y[0];if(!S)throw Error(`Account not found`);return f.set(S.account),g=S.chainItem,h.set(i(C())),T([S.account.address]),E(g.chain.id.toString()),ne(e?.withCapabilities,[S.account.address],g.chain.id)},C=()=>g?r(m.filter(e=>e.currency===g?.currencyId)):o(Error(`Current chain not found`)),{onAccountsChanged:T,onChainChanged:E,onDisconnect:D}=Ce(l.emitter,ue),O=async()=>({}),ie=async()=>n,ae=async()=>y.disconnect(),oe=async()=>{let e=g?.chain.id;if(!e)throw Error(`Chain not found`);return e},ce=async()=>[f.get()?.address],le=e=>{f.set(e),T([e.address])},de=e=>ee(function*(){let t=_?.get(e.id);if(!t)return yield*new te({message:`Chain not found`,operation:`ledger-request-account`});let n=yield*w({try:()=>b.account.request({currencyIds:[t]}),catch:e=>new te({cause:e,message:`could not request account`,operation:`ledger-request-account`})});return m.push(n),u.set([...u.get(),e]),d.set(d.get().filter(t=>t.id!==e.id)),yield*w({try:()=>fe({chainId:e.id}),catch:e=>new te({cause:e,message:`failed to switch to new chain`,operation:`ledger-switch-chain`})})}),fe=async({chainId:e})=>{let t=g;if(!t||!v)throw Error(`Chain not found`);let n=[...v.values()].flatMap(e=>[...e.values()]).find(t=>t.chain.id===e);if(!n)throw Error(`Chain not found`);if(t.chain.id!==n.chain.id||!f.get()){g=n;let e=i(C());h.set(e),f.set(e[0])}let r=f.get();if(!r)throw Error(`Account not found`);return E(e.toString()),T([r.address]),n.chain};return{...e,id:se.id,name:se.name,type:se.type,connect:S,onAccountsChanged:T,onChainChanged:E,onDisconnect:D,getProvider:O,isAuthorized:ie,getChainId:oe,disconnect:ae,switchChain:fe,getAccounts:ce,switchAccount:le,requestAndSwitchAccount:de,walletApiClient:b,$accountsOnCurrentChain:h.changes,$filteredChains:u.changes,$currentAccountId:p,$disabledChains:d.changes,noAccountPlaceholder:`N/A`,deserializeTransaction:ku,prepareTransaction:a}}),Dp=({enabledChainsMap:e,isLedgerDappBrowser:t,queryParams:n,runWalletEffect:r})=>ee(function*(){let i=yield*sp;return{groupName:`Ledger Live`,wallets:[()=>({id:se.id,name:se.name,iconUrl:g.ledgerLogo,iconBackground:`#fff`,chainGroup:{id:se.id,title:se.name,iconUrl:g.ledgerLogo},availability:{_tag:`Injected`,detect:D(t)},createConnector:a=>Ep({walletDetailsParams:a,enabledChainsMap:e,isLedgerDappBrowser:t,prepareTransaction:i,queryParams:n,runWalletEffect:r})})]}});export{Dp as ledgerLiveConnector};
|